@hotmeshio/long-tail 0.20.0 → 0.21.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 (361) hide show
  1. package/README.md +4 -4
  2. package/build/api/escalations/accumulate.d.ts +104 -0
  3. package/build/api/escalations/accumulate.js +541 -0
  4. package/build/api/escalations/index.d.ts +1 -0
  5. package/build/api/escalations/index.js +11 -1
  6. package/build/api/roles.d.ts +4 -5
  7. package/build/api/roles.js +53 -4
  8. package/build/api/scan-codes/context.d.ts +14 -1
  9. package/build/api/scan-codes/context.js +30 -2
  10. package/build/api/scan-codes/execute.js +2 -0
  11. package/build/api/scan-codes/identity.js +1 -0
  12. package/build/api/scan-codes/verbs.d.ts +21 -0
  13. package/build/api/scan-codes/verbs.js +122 -3
  14. package/build/index.d.ts +2 -1
  15. package/build/index.js +63 -2
  16. package/build/lib/db/schemas/036_role_portals.sql +12 -0
  17. package/build/routes/escalations/accumulate.d.ts +7 -0
  18. package/build/routes/escalations/accumulate.js +158 -0
  19. package/build/routes/escalations/index.js +5 -0
  20. package/build/sdk/index.d.ts +28 -0
  21. package/build/sdk/index.js +9 -0
  22. package/build/services/escalation/accumulate.d.ts +81 -0
  23. package/build/services/escalation/accumulate.js +154 -0
  24. package/build/services/escalation/index.d.ts +1 -0
  25. package/build/services/escalation/index.js +1 -0
  26. package/build/services/mcp/playwright-server/schemas.d.ts +2 -2
  27. package/build/services/orchestrator/condition.d.ts +40 -3
  28. package/build/services/orchestrator/condition.js +42 -2
  29. package/build/services/role/index.js +1 -0
  30. package/build/services/role/seed.js +6 -1
  31. package/build/services/role/sql.d.ts +6 -3
  32. package/build/services/role/sql.js +7 -2
  33. package/build/services/role/types.d.ts +38 -10
  34. package/build/services/role/types.js +10 -1
  35. package/build/services/scan-code/index.d.ts +1 -1
  36. package/build/services/scan-code/index.js +3 -1
  37. package/build/services/scan-code/parse.d.ts +17 -3
  38. package/build/services/scan-code/parse.js +37 -4
  39. package/build/services/scan-code/validate.js +35 -0
  40. package/build/shared/form-validation/display-only-widgets.d.ts +16 -0
  41. package/build/shared/form-validation/display-only-widgets.js +25 -0
  42. package/build/shared/form-validation/index.d.ts +2 -0
  43. package/build/shared/form-validation/index.js +2 -0
  44. package/build/shared/form-validation/x-lt-bind.d.ts +2 -14
  45. package/build/shared/form-validation/x-lt-bind.js +12 -8
  46. package/build/shared/form-validation/x-lt-invoke.d.ts +38 -0
  47. package/build/shared/form-validation/x-lt-invoke.js +103 -0
  48. package/build/system/mcp-servers/admin/escalations.js +44 -0
  49. package/build/system/mcp-servers/admin/schemas.d.ts +195 -13
  50. package/build/system/mcp-servers/admin/schemas.js +40 -3
  51. package/build/system/mcp-servers/admin/users.js +1 -0
  52. package/build/system/mcp-servers/docs.js +4 -0
  53. package/build/system/mcp-servers/human-queue-schemas.d.ts +85 -0
  54. package/build/system/mcp-servers/human-queue-schemas.js +19 -1
  55. package/build/system/mcp-servers/human-queue.d.ts +2 -0
  56. package/build/system/mcp-servers/human-queue.js +77 -0
  57. package/build/system/seed/tool-manifests-admin.d.ts +1108 -100
  58. package/build/system/seed/tool-manifests-admin.js +4 -1
  59. package/build/system/seed/tool-manifests-escalation.d.ts +174 -0
  60. package/build/system/seed/tool-manifests-escalation.js +56 -0
  61. package/build/tsconfig.tsbuildinfo +1 -1
  62. package/build/types/escalation.d.ts +52 -0
  63. package/build/types/escalation.js +29 -1
  64. package/build/types/index.d.ts +4 -4
  65. package/build/types/index.js +4 -1
  66. package/build/types/scan-code.d.ts +55 -1
  67. package/build/types/scan-code.js +29 -2
  68. package/build/types/startup.d.ts +20 -0
  69. package/dashboard/dist/assets/{AdminDashboard-DplvDBti.js → AdminDashboard-Covdam48.js} +2 -2
  70. package/dashboard/dist/assets/{AdminDashboard-DplvDBti.js.map → AdminDashboard-Covdam48.js.map} +1 -1
  71. package/dashboard/dist/assets/{AgentConfigPage-D8Bf6YxO.js → AgentConfigPage-CE1k6J5r.js} +6 -6
  72. package/dashboard/dist/assets/{AgentConfigPage-D8Bf6YxO.js.map → AgentConfigPage-CE1k6J5r.js.map} +1 -1
  73. package/dashboard/dist/assets/{AgentDetailPage-BN8g0Y2G.js → AgentDetailPage-CWJZIZP1.js} +3 -3
  74. package/dashboard/dist/assets/{AgentDetailPage-BN8g0Y2G.js.map → AgentDetailPage-CWJZIZP1.js.map} +1 -1
  75. package/dashboard/dist/assets/AgentsPage---Dg5ufF.js +2 -0
  76. package/dashboard/dist/assets/{AgentsPage-7JJBHku8.js.map → AgentsPage---Dg5ufF.js.map} +1 -1
  77. package/dashboard/dist/assets/AvailableEscalationsPage-CpbC8oTN.js +2 -0
  78. package/dashboard/dist/assets/AvailableEscalationsPage-CpbC8oTN.js.map +1 -0
  79. package/dashboard/dist/assets/{BotPicker-CGCnIz8I.js → BotPicker-D3drO3-T.js} +2 -2
  80. package/dashboard/dist/assets/{BotPicker-CGCnIz8I.js.map → BotPicker-D3drO3-T.js.map} +1 -1
  81. package/dashboard/dist/assets/BulkAssignModal-BOAWsViq.js +2 -0
  82. package/dashboard/dist/assets/{BulkAssignModal-NJBcoj-f.js.map → BulkAssignModal-BOAWsViq.js.map} +1 -1
  83. package/dashboard/dist/assets/CapabilitiesPage-RGgD3YZO.js +2 -0
  84. package/dashboard/dist/assets/{CapabilitiesPage-F8dpNn9B.js.map → CapabilitiesPage-RGgD3YZO.js.map} +1 -1
  85. package/dashboard/dist/assets/{CollapsibleSection-BZW6VpCU.js → CollapsibleSection-DNkZn87n.js} +2 -2
  86. package/dashboard/dist/assets/{CollapsibleSection-BZW6VpCU.js.map → CollapsibleSection-DNkZn87n.js.map} +1 -1
  87. package/dashboard/dist/assets/{ConfirmDeleteModal-64adXLdq.js → ConfirmDeleteModal-BqzOwhPr.js} +2 -2
  88. package/dashboard/dist/assets/{ConfirmDeleteModal-64adXLdq.js.map → ConfirmDeleteModal-BqzOwhPr.js.map} +1 -1
  89. package/dashboard/dist/assets/{CountdownTimer-BxDub9d2.js → CountdownTimer-BaexQMK6.js} +2 -2
  90. package/dashboard/dist/assets/{CountdownTimer-BxDub9d2.js.map → CountdownTimer-BaexQMK6.js.map} +1 -1
  91. package/dashboard/dist/assets/{CredentialsPage-CnLzopLL.js → CredentialsPage-D7abp0aS.js} +2 -2
  92. package/dashboard/dist/assets/{CredentialsPage-CnLzopLL.js.map → CredentialsPage-D7abp0aS.js.map} +1 -1
  93. package/dashboard/dist/assets/{CronLabel-CAD5UYDT.js → CronLabel-DZiWmTwJ.js} +2 -2
  94. package/dashboard/dist/assets/{CronLabel-CAD5UYDT.js.map → CronLabel-DZiWmTwJ.js.map} +1 -1
  95. package/dashboard/dist/assets/DataTable-spX1dFyb.js +2 -0
  96. package/dashboard/dist/assets/DataTable-spX1dFyb.js.map +1 -0
  97. package/dashboard/dist/assets/{DropZone-XlcY8hEH.js → DropZone-f1o-GLM8.js} +2 -2
  98. package/dashboard/dist/assets/{DropZone-XlcY8hEH.js.map → DropZone-f1o-GLM8.js.map} +1 -1
  99. package/dashboard/dist/assets/{ElapsedCell-CwO4ufd0.js → ElapsedCell-BdGO_w4v.js} +2 -2
  100. package/dashboard/dist/assets/{ElapsedCell-CwO4ufd0.js.map → ElapsedCell-BdGO_w4v.js.map} +1 -1
  101. package/dashboard/dist/assets/EntityTimelinePanel-DIDcF5Yu.js +2 -0
  102. package/dashboard/dist/assets/{EntityTimelinePanel-CkF-oW-m.js.map → EntityTimelinePanel-DIDcF5Yu.js.map} +1 -1
  103. package/dashboard/dist/assets/{EscalationListSchemaPage-h9JO_q5f.js → EscalationListSchemaPage-C28rn9XC.js} +3 -3
  104. package/dashboard/dist/assets/{EscalationListSchemaPage-h9JO_q5f.js.map → EscalationListSchemaPage-C28rn9XC.js.map} +1 -1
  105. package/dashboard/dist/assets/EscalationListView-CkBnkpDJ.js +2 -0
  106. package/dashboard/dist/assets/EscalationListView-CkBnkpDJ.js.map +1 -0
  107. package/dashboard/dist/assets/{EscalationSchemaPage-mJFL5_Se.js → EscalationSchemaPage-W5r0A1kj.js} +3 -3
  108. package/dashboard/dist/assets/{EscalationSchemaPage-mJFL5_Se.js.map → EscalationSchemaPage-W5r0A1kj.js.map} +1 -1
  109. package/dashboard/dist/assets/EscalationTimeline-DKyTz6sM.js +2 -0
  110. package/dashboard/dist/assets/EscalationTimeline-DKyTz6sM.js.map +1 -0
  111. package/dashboard/dist/assets/EscalationTitleSelect-CzKfavri.js +2 -0
  112. package/dashboard/dist/assets/EscalationTitleSelect-CzKfavri.js.map +1 -0
  113. package/dashboard/dist/assets/{EscalationsOverview-DlXUFqWJ.js → EscalationsOverview-Tdu3Yx2c.js} +2 -2
  114. package/dashboard/dist/assets/{EscalationsOverview-DlXUFqWJ.js.map → EscalationsOverview-Tdu3Yx2c.js.map} +1 -1
  115. package/dashboard/dist/assets/{EventTable-Ike2xchn.js → EventTable-DiIxOJwO.js} +2 -2
  116. package/dashboard/dist/assets/{EventTable-Ike2xchn.js.map → EventTable-DiIxOJwO.js.map} +1 -1
  117. package/dashboard/dist/assets/{FilterBar-DMOR-O1c.js → FilterBar-CvMBCVIo.js} +2 -2
  118. package/dashboard/dist/assets/{FilterBar-DMOR-O1c.js.map → FilterBar-CvMBCVIo.js.map} +1 -1
  119. package/dashboard/dist/assets/GraphInvokePage-DO-yyhi6.js +2 -0
  120. package/dashboard/dist/assets/{GraphInvokePage-CKtvWowP.js.map → GraphInvokePage-DO-yyhi6.js.map} +1 -1
  121. package/dashboard/dist/assets/HomePage-DSS3eHR2.js +2 -0
  122. package/dashboard/dist/assets/{HomePage-BQ3Q791Q.js.map → HomePage-DSS3eHR2.js.map} +1 -1
  123. package/dashboard/dist/assets/ListToolbar-C3-Tqqub.js +2 -0
  124. package/dashboard/dist/assets/{ListToolbar-DdJzj472.js.map → ListToolbar-C3-Tqqub.js.map} +1 -1
  125. package/dashboard/dist/assets/{McpOverview-BbtrduWn.js → McpOverview-DEJmsdVi.js} +2 -2
  126. package/dashboard/dist/assets/{McpOverview-BbtrduWn.js.map → McpOverview-DEJmsdVi.js.map} +1 -1
  127. package/dashboard/dist/assets/{McpQueryDetailPage-C1L4T-Wt.js → McpQueryDetailPage-DYJr16l7.js} +2 -2
  128. package/dashboard/dist/assets/{McpQueryDetailPage-C1L4T-Wt.js.map → McpQueryDetailPage-DYJr16l7.js.map} +1 -1
  129. package/dashboard/dist/assets/McpQueryPage-BBcG_UuU.js +2 -0
  130. package/dashboard/dist/assets/{McpQueryPage-CfJy7HZ7.js.map → McpQueryPage-BBcG_UuU.js.map} +1 -1
  131. package/dashboard/dist/assets/{McpRunDetailPage-CA9yv7he.js → McpRunDetailPage-C6xw0kBg.js} +2 -2
  132. package/dashboard/dist/assets/{McpRunDetailPage-CA9yv7he.js.map → McpRunDetailPage-C6xw0kBg.js.map} +1 -1
  133. package/dashboard/dist/assets/McpRunsPage-CRQqrF4Q.js +2 -0
  134. package/dashboard/dist/assets/{McpRunsPage-D7QXjW9z.js.map → McpRunsPage-CRQqrF4Q.js.map} +1 -1
  135. package/dashboard/dist/assets/{NamespacePill-Bb3revqD.js → NamespacePill-DADRJOUl.js} +2 -2
  136. package/dashboard/dist/assets/{NamespacePill-Bb3revqD.js.map → NamespacePill-DADRJOUl.js.map} +1 -1
  137. package/dashboard/dist/assets/OperationsPage-Dlfwzf-0.js +3 -0
  138. package/dashboard/dist/assets/OperationsPage-Dlfwzf-0.js.map +1 -0
  139. package/dashboard/dist/assets/OperatorDashboard-DoiDGZ9R.js +2 -0
  140. package/dashboard/dist/assets/{OperatorDashboard-sXNDh1Ph.js.map → OperatorDashboard-DoiDGZ9R.js.map} +1 -1
  141. package/dashboard/dist/assets/{PageHeader-Di5Sz3an.js → PageHeader-Csq434-v.js} +2 -2
  142. package/dashboard/dist/assets/{PageHeader-Di5Sz3an.js.map → PageHeader-Csq434-v.js.map} +1 -1
  143. package/dashboard/dist/assets/{PageHeaderWithStats-DutKJ-h2.js → PageHeaderWithStats-CSnk1p5A.js} +2 -2
  144. package/dashboard/dist/assets/{PageHeaderWithStats-DutKJ-h2.js.map → PageHeaderWithStats-CSnk1p5A.js.map} +1 -1
  145. package/dashboard/dist/assets/{PersonaDetailPage-NeHD-Gra.js → PersonaDetailPage-BzbA4Prr.js} +2 -2
  146. package/dashboard/dist/assets/{PersonaDetailPage-NeHD-Gra.js.map → PersonaDetailPage-BzbA4Prr.js.map} +1 -1
  147. package/dashboard/dist/assets/{PersonasPage-DavKXRWX.js → PersonasPage-B36yn4hU.js} +2 -2
  148. package/dashboard/dist/assets/{PersonasPage-DavKXRWX.js.map → PersonasPage-B36yn4hU.js.map} +1 -1
  149. package/dashboard/dist/assets/PortalPage-BkD4YfDf.js +2 -0
  150. package/dashboard/dist/assets/PortalPage-BkD4YfDf.js.map +1 -0
  151. package/dashboard/dist/assets/{ProcessDetailPage-DkdKJGe6.js → ProcessDetailPage-BT0eiBWY.js} +2 -2
  152. package/dashboard/dist/assets/{ProcessDetailPage-DkdKJGe6.js.map → ProcessDetailPage-BT0eiBWY.js.map} +1 -1
  153. package/dashboard/dist/assets/ProcessesListPage-BEqeeNae.js +2 -0
  154. package/dashboard/dist/assets/{ProcessesListPage-CjwVKe32.js.map → ProcessesListPage-BEqeeNae.js.map} +1 -1
  155. package/dashboard/dist/assets/ResolverForm-BwgjIX97.js +7 -0
  156. package/dashboard/dist/assets/ResolverForm-BwgjIX97.js.map +1 -0
  157. package/dashboard/dist/assets/RoleDetailPage-BFuLNJXa.js +8 -0
  158. package/dashboard/dist/assets/RoleDetailPage-BFuLNJXa.js.map +1 -0
  159. package/dashboard/dist/assets/{RolePill-DhnVPK4q.js → RolePill-BafrASDX.js} +2 -2
  160. package/dashboard/dist/assets/{RolePill-DhnVPK4q.js.map → RolePill-BafrASDX.js.map} +1 -1
  161. package/dashboard/dist/assets/{RolesPage-OM9KM8Pg.js → RolesPage-80quJU5-.js} +2 -2
  162. package/dashboard/dist/assets/{RolesPage-OM9KM8Pg.js.map → RolesPage-80quJU5-.js.map} +1 -1
  163. package/dashboard/dist/assets/RunAsSelector-BoePhWVD.js +2 -0
  164. package/dashboard/dist/assets/{RunAsSelector-fFMt1bGe.js.map → RunAsSelector-BoePhWVD.js.map} +1 -1
  165. package/dashboard/dist/assets/{ScanCodesPage-AujH-pPQ.js → ScanCodesPage-Cu1bKEix.js} +2 -2
  166. package/dashboard/dist/assets/{ScanCodesPage-AujH-pPQ.js.map → ScanCodesPage-Cu1bKEix.js.map} +1 -1
  167. package/dashboard/dist/assets/ScanSchemeDetailPage-D9AbS6UY.js +2 -0
  168. package/dashboard/dist/assets/ScanSchemeDetailPage-D9AbS6UY.js.map +1 -0
  169. package/dashboard/dist/assets/ScanStationPage-gcZGefvT.js +2 -0
  170. package/dashboard/dist/assets/{ScanStationPage-C1_ppDoZ.js.map → ScanStationPage-gcZGefvT.js.map} +1 -1
  171. package/dashboard/dist/assets/{ScopeBadge-CXUg0FHo.js → ScopeBadge-b6MIBiYD.js} +2 -2
  172. package/dashboard/dist/assets/{ScopeBadge-CXUg0FHo.js.map → ScopeBadge-b6MIBiYD.js.map} +1 -1
  173. package/dashboard/dist/assets/{StickyPagination-B91Pk9xh.js → StickyPagination-9ITrei_d.js} +2 -2
  174. package/dashboard/dist/assets/{StickyPagination-B91Pk9xh.js.map → StickyPagination-9ITrei_d.js.map} +1 -1
  175. package/dashboard/dist/assets/{StreamMessageDetail-C7SPqaJt.js → StreamMessageDetail-BkYvEHFY.js} +2 -2
  176. package/dashboard/dist/assets/{StreamMessageDetail-C7SPqaJt.js.map → StreamMessageDetail-BkYvEHFY.js.map} +1 -1
  177. package/dashboard/dist/assets/{SwimlaneTimeline-BcHR8ylf.js → SwimlaneTimeline-B1rotFix.js} +2 -2
  178. package/dashboard/dist/assets/{SwimlaneTimeline-BcHR8ylf.js.map → SwimlaneTimeline-B1rotFix.js.map} +1 -1
  179. package/dashboard/dist/assets/{TagInput-BZ8vb2oW.js → TagInput-ZrIIrEUP.js} +2 -2
  180. package/dashboard/dist/assets/{TagInput-BZ8vb2oW.js.map → TagInput-ZrIIrEUP.js.map} +1 -1
  181. package/dashboard/dist/assets/{TaskDetailPage-Bqj0I_I0.js → TaskDetailPage-zhn_U_eC.js} +2 -2
  182. package/dashboard/dist/assets/{TaskDetailPage-Bqj0I_I0.js.map → TaskDetailPage-zhn_U_eC.js.map} +1 -1
  183. package/dashboard/dist/assets/{TaskQueuePill-Bxir8WRl.js → TaskQueuePill-DkQ1uc6y.js} +2 -2
  184. package/dashboard/dist/assets/{TaskQueuePill-Bxir8WRl.js.map → TaskQueuePill-DkQ1uc6y.js.map} +1 -1
  185. package/dashboard/dist/assets/TasksListPage-CNbNeagx.js +2 -0
  186. package/dashboard/dist/assets/{TasksListPage-BB1f79lL.js.map → TasksListPage-CNbNeagx.js.map} +1 -1
  187. package/dashboard/dist/assets/{TimeAgo-BFnODmNe.js → TimeAgo-0YVMBwls.js} +2 -2
  188. package/dashboard/dist/assets/{TimeAgo-BFnODmNe.js.map → TimeAgo-0YVMBwls.js.map} +1 -1
  189. package/dashboard/dist/assets/{TimestampCell-BXgLOBsr.js → TimestampCell-DB7r3np8.js} +2 -2
  190. package/dashboard/dist/assets/{TimestampCell-BXgLOBsr.js.map → TimestampCell-DB7r3np8.js.map} +1 -1
  191. package/dashboard/dist/assets/{ToolPill-FkgTXIhq.js → ToolPill-Baxm02L6.js} +2 -2
  192. package/dashboard/dist/assets/{ToolPill-FkgTXIhq.js.map → ToolPill-Baxm02L6.js.map} +1 -1
  193. package/dashboard/dist/assets/ToolTestPanel-BLfA02wv.js +2 -0
  194. package/dashboard/dist/assets/{ToolTestPanel-Bwe3J5lj.js.map → ToolTestPanel-BLfA02wv.js.map} +1 -1
  195. package/dashboard/dist/assets/{TopicDetailPage-DAF07vZ9.js → TopicDetailPage-eAqPKShq.js} +3 -3
  196. package/dashboard/dist/assets/{TopicDetailPage-DAF07vZ9.js.map → TopicDetailPage-eAqPKShq.js.map} +1 -1
  197. package/dashboard/dist/assets/TopicsPage-BNNWD-zl.js +2 -0
  198. package/dashboard/dist/assets/{TopicsPage-C1gxBUap.js.map → TopicsPage-BNNWD-zl.js.map} +1 -1
  199. package/dashboard/dist/assets/{UserName-BzXJUE6q.js → UserName-Pw46tO_k.js} +2 -2
  200. package/dashboard/dist/assets/{UserName-BzXJUE6q.js.map → UserName-Pw46tO_k.js.map} +1 -1
  201. package/dashboard/dist/assets/{WorkflowExecutionPage-SkRU5cRX.js → WorkflowExecutionPage-DvA51lT3.js} +2 -2
  202. package/dashboard/dist/assets/{WorkflowExecutionPage-SkRU5cRX.js.map → WorkflowExecutionPage-DvA51lT3.js.map} +1 -1
  203. package/dashboard/dist/assets/{WorkflowPill--AYMW7u_.js → WorkflowPill-ZepbO_ny.js} +2 -2
  204. package/dashboard/dist/assets/{WorkflowPill--AYMW7u_.js.map → WorkflowPill-ZepbO_ny.js.map} +1 -1
  205. package/dashboard/dist/assets/WorkflowsDashboard-DFDTwnhn.js +2 -0
  206. package/dashboard/dist/assets/{WorkflowsDashboard-CZAqRk1N.js.map → WorkflowsDashboard-DFDTwnhn.js.map} +1 -1
  207. package/dashboard/dist/assets/{WorkflowsOverview-BoN44VTE.js → WorkflowsOverview-5i2Tcy-p.js} +2 -2
  208. package/dashboard/dist/assets/{WorkflowsOverview-BoN44VTE.js.map → WorkflowsOverview-5i2Tcy-p.js.map} +1 -1
  209. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CqjhtdJf.js → YamlWorkflowDetailPage-p4VEYZS0.js} +11 -11
  210. package/dashboard/dist/assets/{YamlWorkflowDetailPage-CqjhtdJf.js.map → YamlWorkflowDetailPage-p4VEYZS0.js.map} +1 -1
  211. package/dashboard/dist/assets/{YamlWorkflowsPage-CwnJkzyb.js → YamlWorkflowsPage-Cq-hMVxl.js} +2 -2
  212. package/dashboard/dist/assets/{YamlWorkflowsPage-CwnJkzyb.js.map → YamlWorkflowsPage-Cq-hMVxl.js.map} +1 -1
  213. package/dashboard/dist/assets/{agents-gV0Ys-sY.js → agents-EyBPJMYa.js} +2 -2
  214. package/dashboard/dist/assets/{agents-gV0Ys-sY.js.map → agents-EyBPJMYa.js.map} +1 -1
  215. package/dashboard/dist/assets/{bots-B97itB3I.js → bots-DX6jjqtF.js} +2 -2
  216. package/dashboard/dist/assets/{bots-B97itB3I.js.map → bots-DX6jjqtF.js.map} +1 -1
  217. package/dashboard/dist/assets/{capabilities-CR9xZgGd.js → capabilities-ZdLv9xBQ.js} +2 -2
  218. package/dashboard/dist/assets/{capabilities-CR9xZgGd.js.map → capabilities-ZdLv9xBQ.js.map} +1 -1
  219. package/dashboard/dist/assets/{constants-BHkpVaqx.js → constants-CeBBTzf5.js} +2 -2
  220. package/dashboard/dist/assets/{constants-BHkpVaqx.js.map → constants-CeBBTzf5.js.map} +1 -1
  221. package/dashboard/dist/assets/{controlplane-YxvP1KCa.js → controlplane-CpvZaJuw.js} +2 -2
  222. package/dashboard/dist/assets/{controlplane-YxvP1KCa.js.map → controlplane-CpvZaJuw.js.map} +1 -1
  223. package/dashboard/dist/assets/escalation-columns-Mvsze5eV.js +2 -0
  224. package/dashboard/dist/assets/escalation-columns-Mvsze5eV.js.map +1 -0
  225. package/dashboard/dist/assets/index-B_GT23TE.js +3 -0
  226. package/dashboard/dist/assets/index-B_GT23TE.js.map +1 -0
  227. package/dashboard/dist/assets/index-BbCjGO3M.js +2 -0
  228. package/dashboard/dist/assets/{index-CFbo9FU9.js.map → index-BbCjGO3M.js.map} +1 -1
  229. package/dashboard/dist/assets/{index-DMeaiKgf.js → index-Bhb89oHH.js} +2 -2
  230. package/dashboard/dist/assets/{index-DMeaiKgf.js.map → index-Bhb89oHH.js.map} +1 -1
  231. package/dashboard/dist/assets/index-CgUcYveM.js +67 -0
  232. package/dashboard/dist/assets/index-CgUcYveM.js.map +1 -0
  233. package/dashboard/dist/assets/index-Cn8uJsd7.js +2 -0
  234. package/dashboard/dist/assets/{index-BQpV-DTG.js.map → index-Cn8uJsd7.js.map} +1 -1
  235. package/dashboard/dist/assets/index-D-Xs4rAW.js +2 -0
  236. package/dashboard/dist/assets/{index-Bp9KBLT5.js.map → index-D-Xs4rAW.js.map} +1 -1
  237. package/dashboard/dist/assets/{index-DwOnWeu8.js → index-DGmzBY9D.js} +2 -2
  238. package/dashboard/dist/assets/{index-DwOnWeu8.js.map → index-DGmzBY9D.js.map} +1 -1
  239. package/dashboard/dist/assets/{index-CIpHj4di.js → index-DZhtP2Ok.js} +2 -2
  240. package/dashboard/dist/assets/{index-CIpHj4di.js.map → index-DZhtP2Ok.js.map} +1 -1
  241. package/dashboard/dist/assets/index-Dh8MJl3L.css +1 -0
  242. package/dashboard/dist/assets/index-DkrBFFSO.js +13 -0
  243. package/dashboard/dist/assets/{index-Cfvkl2J0.js.map → index-DkrBFFSO.js.map} +1 -1
  244. package/dashboard/dist/assets/{index-B9BBCqLI.js → index-Eo-l3Lqo.js} +2 -2
  245. package/dashboard/dist/assets/{index-B9BBCqLI.js.map → index-Eo-l3Lqo.js.map} +1 -1
  246. package/dashboard/dist/assets/index-PfSRKerc.js +2 -0
  247. package/dashboard/dist/assets/{index-CUZ6LYye.js.map → index-PfSRKerc.js.map} +1 -1
  248. package/dashboard/dist/assets/{index-ipqwPavs.js → index-oFKUFGQL.js} +2 -2
  249. package/dashboard/dist/assets/{index-ipqwPavs.js.map → index-oFKUFGQL.js.map} +1 -1
  250. package/dashboard/dist/assets/index-z5Hpeidu.js +2 -0
  251. package/dashboard/dist/assets/index-z5Hpeidu.js.map +1 -0
  252. package/dashboard/dist/assets/{knowledge-XX6cW4Ob.js → knowledge-CgloEkaf.js} +2 -2
  253. package/dashboard/dist/assets/{knowledge-XX6cW4Ob.js.map → knowledge-CgloEkaf.js.map} +1 -1
  254. package/dashboard/dist/assets/{mcp-CH13hNH2.js → mcp-Bix7QYO7.js} +2 -2
  255. package/dashboard/dist/assets/{mcp-CH13hNH2.js.map → mcp-Bix7QYO7.js.map} +1 -1
  256. package/dashboard/dist/assets/{mcp-query-Duydd3JA.js → mcp-query-o-sGX2ST.js} +2 -2
  257. package/dashboard/dist/assets/{mcp-query-Duydd3JA.js.map → mcp-query-o-sGX2ST.js.map} +1 -1
  258. package/dashboard/dist/assets/metadata-display-COo3mMCr.js +2 -0
  259. package/dashboard/dist/assets/metadata-display-COo3mMCr.js.map +1 -0
  260. package/dashboard/dist/assets/{personas-mDk4lLQS.js → personas-30azkJ_s.js} +2 -2
  261. package/dashboard/dist/assets/{personas-mDk4lLQS.js.map → personas-30azkJ_s.js.map} +1 -1
  262. package/dashboard/dist/assets/{pipelines-B5GcgCeF.js → pipelines-Bfk2GFK7.js} +2 -2
  263. package/dashboard/dist/assets/{pipelines-B5GcgCeF.js.map → pipelines-Bfk2GFK7.js.map} +1 -1
  264. package/dashboard/dist/assets/{tasks-CItmNsRp.js → tasks-CpdopewW.js} +2 -2
  265. package/dashboard/dist/assets/{tasks-CItmNsRp.js.map → tasks-CpdopewW.js.map} +1 -1
  266. package/dashboard/dist/assets/{topics-CJYG7BX5.js → topics--bvCV9Yp.js} +2 -2
  267. package/dashboard/dist/assets/{topics-CJYG7BX5.js.map → topics--bvCV9Yp.js.map} +1 -1
  268. package/dashboard/dist/assets/useContainerWidth-DSLp1gEm.js +2 -0
  269. package/dashboard/dist/assets/useContainerWidth-DSLp1gEm.js.map +1 -0
  270. package/dashboard/dist/assets/{useDebouncedValue-BrwgXcp8.js → useDebouncedValue-Da0lPmj3.js} +2 -2
  271. package/dashboard/dist/assets/{useDebouncedValue-BrwgXcp8.js.map → useDebouncedValue-Da0lPmj3.js.map} +1 -1
  272. package/dashboard/dist/assets/{useNamespace-CHty0HAS.js → useNamespace-DD_Esl6n.js} +2 -2
  273. package/dashboard/dist/assets/{useNamespace-CHty0HAS.js.map → useNamespace-DD_Esl6n.js.map} +1 -1
  274. package/dashboard/dist/assets/{useYamlActivityEvents-CoTsia7t.js → useYamlActivityEvents-AeAhZJJk.js} +2 -2
  275. package/dashboard/dist/assets/{useYamlActivityEvents-CoTsia7t.js.map → useYamlActivityEvents-AeAhZJJk.js.map} +1 -1
  276. package/dashboard/dist/assets/{vendor-icons-DeBdvyKJ.js → vendor-icons-B7OcUM6b.js} +2 -2
  277. package/dashboard/dist/assets/{vendor-icons-DeBdvyKJ.js.map → vendor-icons-B7OcUM6b.js.map} +1 -1
  278. package/dashboard/dist/assets/{yaml-workflows-CiWwx5rM.js → yaml-workflows-BHAOOGvn.js} +2 -2
  279. package/dashboard/dist/assets/{yaml-workflows-CiWwx5rM.js.map → yaml-workflows-BHAOOGvn.js.map} +1 -1
  280. package/dashboard/dist/index.html +3 -3
  281. package/docs/accumulator.md +113 -0
  282. package/docs/api/http/escalations.md +90 -0
  283. package/docs/api/http/roles.md +1 -0
  284. package/docs/api/sdk/escalations.md +92 -0
  285. package/docs/api/sdk/roles.md +2 -0
  286. package/docs/architecture.md +1 -1
  287. package/docs/code-owned-configuration.md +2 -1
  288. package/docs/dashboard.md +10 -4
  289. package/docs/hitl/design.md +1 -1
  290. package/docs/hitl/escalation.md +37 -1
  291. package/docs/hitl/invoke-form.md +4 -0
  292. package/docs/hitl/pinned-views.md +4 -0
  293. package/docs/hitl/portal.md +97 -0
  294. package/docs/hitl/resolution.md +41 -0
  295. package/docs/hitl/x-lt-embed.md +1 -1
  296. package/docs/hitl/x-lt-invoke.md +95 -0
  297. package/docs/hitl/x-lt-list-schema.md +3 -1
  298. package/docs/hitl/x-lt-widget.md +1 -0
  299. package/docs/hitl-guide.md +8 -1
  300. package/docs/scan-codes.md +33 -9
  301. package/docs/sdk.md +1 -1
  302. package/docs/workflows.md +2 -2
  303. package/package.json +4 -2
  304. package/dashboard/dist/assets/AgentsPage-7JJBHku8.js +0 -2
  305. package/dashboard/dist/assets/AvailableEscalationsPage-lz5qwSjg.js +0 -2
  306. package/dashboard/dist/assets/AvailableEscalationsPage-lz5qwSjg.js.map +0 -1
  307. package/dashboard/dist/assets/BulkAssignModal-NJBcoj-f.js +0 -2
  308. package/dashboard/dist/assets/CapabilitiesPage-F8dpNn9B.js +0 -2
  309. package/dashboard/dist/assets/DataTable-7C7riavf.js +0 -2
  310. package/dashboard/dist/assets/DataTable-7C7riavf.js.map +0 -1
  311. package/dashboard/dist/assets/EntityTimelinePanel-CkF-oW-m.js +0 -2
  312. package/dashboard/dist/assets/EscalationListView-AHW2xtlr.js +0 -2
  313. package/dashboard/dist/assets/EscalationListView-AHW2xtlr.js.map +0 -1
  314. package/dashboard/dist/assets/GraphInvokePage-CKtvWowP.js +0 -2
  315. package/dashboard/dist/assets/HomePage-BQ3Q791Q.js +0 -2
  316. package/dashboard/dist/assets/ListToolbar-DdJzj472.js +0 -2
  317. package/dashboard/dist/assets/McpQueryPage-CfJy7HZ7.js +0 -2
  318. package/dashboard/dist/assets/McpRunsPage-D7QXjW9z.js +0 -2
  319. package/dashboard/dist/assets/OperationsPage-aLHHAP2X.js +0 -3
  320. package/dashboard/dist/assets/OperationsPage-aLHHAP2X.js.map +0 -1
  321. package/dashboard/dist/assets/OperatorDashboard-sXNDh1Ph.js +0 -2
  322. package/dashboard/dist/assets/ProcessesListPage-CjwVKe32.js +0 -2
  323. package/dashboard/dist/assets/ResolverForm-Bk-wDkN-.js +0 -3
  324. package/dashboard/dist/assets/ResolverForm-Bk-wDkN-.js.map +0 -1
  325. package/dashboard/dist/assets/RoleDetailPage-WQt0y5l7.js +0 -8
  326. package/dashboard/dist/assets/RoleDetailPage-WQt0y5l7.js.map +0 -1
  327. package/dashboard/dist/assets/RunAsSelector-fFMt1bGe.js +0 -2
  328. package/dashboard/dist/assets/ScanSchemeDetailPage-eKQpmsC_.js +0 -2
  329. package/dashboard/dist/assets/ScanSchemeDetailPage-eKQpmsC_.js.map +0 -1
  330. package/dashboard/dist/assets/ScanStationPage-C1_ppDoZ.js +0 -2
  331. package/dashboard/dist/assets/TasksListPage-BB1f79lL.js +0 -2
  332. package/dashboard/dist/assets/ToolTestPanel-Bwe3J5lj.js +0 -2
  333. package/dashboard/dist/assets/TopicsPage-C1gxBUap.js +0 -2
  334. package/dashboard/dist/assets/WorkflowsDashboard-CZAqRk1N.js +0 -2
  335. package/dashboard/dist/assets/escalation-columns-uq-IV2aj.js +0 -2
  336. package/dashboard/dist/assets/escalation-columns-uq-IV2aj.js.map +0 -1
  337. package/dashboard/dist/assets/index-3ezfWLkE.js +0 -6
  338. package/dashboard/dist/assets/index-3ezfWLkE.js.map +0 -1
  339. package/dashboard/dist/assets/index-BQpV-DTG.js +0 -2
  340. package/dashboard/dist/assets/index-Bp9KBLT5.js +0 -2
  341. package/dashboard/dist/assets/index-Bpvfr4OW.css +0 -1
  342. package/dashboard/dist/assets/index-CFbo9FU9.js +0 -2
  343. package/dashboard/dist/assets/index-CIwlVfvV.js +0 -67
  344. package/dashboard/dist/assets/index-CIwlVfvV.js.map +0 -1
  345. package/dashboard/dist/assets/index-CUZ6LYye.js +0 -2
  346. package/dashboard/dist/assets/index-Cfvkl2J0.js +0 -13
  347. package/dashboard/dist/assets/index-SGyrXGp8.js +0 -3
  348. package/dashboard/dist/assets/index-SGyrXGp8.js.map +0 -1
  349. package/dashboard/dist/assets/invoke-context-DrVyUEfs.js +0 -2
  350. package/dashboard/dist/assets/invoke-context-DrVyUEfs.js.map +0 -1
  351. package/dashboard/dist/assets/metadata-display--TzK0REC.js +0 -2
  352. package/dashboard/dist/assets/metadata-display--TzK0REC.js.map +0 -1
  353. package/dashboard/dist/assets/resolver-payload-m9AGKZ3a.js +0 -2
  354. package/dashboard/dist/assets/resolver-payload-m9AGKZ3a.js.map +0 -1
  355. package/docs/compilation.md +0 -152
  356. package/docs/compiler.md +0 -311
  357. package/docs/contributing.md +0 -56
  358. package/docs/design-principles.md +0 -245
  359. package/docs/schema-exchange.md +0 -173
  360. package/docs/self-test.md +0 -106
  361. package/docs/story.md +0 -184
@@ -0,0 +1,67 @@
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={};/**
3
+ * @license React
4
+ * scheduler.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var Og;function DS(){return Og||(Og=1,(function(n){function t(H,Z){var le=H.length;H.push(Z);e:for(;0<le;){var _e=le-1>>>1,Ee=H[_e];if(0<o(Ee,Z))H[_e]=Z,H[le]=Ee,le=_e;else break e}}function s(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var Z=H[0],le=H.pop();if(le!==Z){H[0]=le;e:for(var _e=0,Ee=H.length,Ne=Ee>>>1;_e<Ne;){var ke=2*(_e+1)-1,Te=H[ke],st=ke+1,Nt=H[st];if(0>o(Te,le))st<Ee&&0>o(Nt,Te)?(H[_e]=Nt,H[st]=le,_e=st):(H[_e]=Te,H[ke]=le,_e=ke);else if(st<Ee&&0>o(Nt,le))H[_e]=Nt,H[st]=le,_e=st;else break e}}return Z}function o(H,Z){var le=H.sortIndex-Z.sortIndex;return le!==0?le:H.id-Z.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var d=Date,y=d.now();n.unstable_now=function(){return d.now()-y}}var g=[],u=[],m=1,b=null,x=3,v=!1,_=!1,S=!1,C=!1,L=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,ie=typeof setImmediate<"u"?setImmediate:null;function oe(H){for(var Z=s(u);Z!==null;){if(Z.callback===null)i(u);else if(Z.startTime<=H)i(u),Z.sortIndex=Z.expirationTime,t(g,Z);else break;Z=s(u)}}function D(H){if(S=!1,oe(H),!_)if(s(g)!==null)_=!0,$||($=!0,Q());else{var Z=s(u);Z!==null&&we(D,Z.startTime-H)}}var $=!1,ee=-1,K=5,I=-1;function M(){return C?!0:!(n.unstable_now()-I<K)}function J(){if(C=!1,$){var H=n.unstable_now();I=H;var Z=!0;try{e:{_=!1,S&&(S=!1,P(ee),ee=-1),v=!0;var le=x;try{t:{for(oe(H),b=s(g);b!==null&&!(b.expirationTime>H&&M());){var _e=b.callback;if(typeof _e=="function"){b.callback=null,x=b.priorityLevel;var Ee=_e(b.expirationTime<=H);if(H=n.unstable_now(),typeof Ee=="function"){b.callback=Ee,oe(H),Z=!0;break t}b===s(g)&&i(g),oe(H)}else i(g);b=s(g)}if(b!==null)Z=!0;else{var Ne=s(u);Ne!==null&&we(D,Ne.startTime-H),Z=!1}}break e}finally{b=null,x=le,v=!1}Z=void 0}}finally{Z?Q():$=!1}}}var Q;if(typeof ie=="function")Q=function(){ie(J)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,be=he.port2;he.port1.onmessage=J,Q=function(){be.postMessage(null)}}else Q=function(){L(J,0)};function we(H,Z){ee=L(function(){H(n.unstable_now())},Z)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(H){H.callback=null},n.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<H?Math.floor(1e3/H):5},n.unstable_getCurrentPriorityLevel=function(){return x},n.unstable_next=function(H){switch(x){case 1:case 2:case 3:var Z=3;break;default:Z=x}var le=x;x=Z;try{return H()}finally{x=le}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function(H,Z){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var le=x;x=H;try{return Z()}finally{x=le}},n.unstable_scheduleCallback=function(H,Z,le){var _e=n.unstable_now();switch(typeof le=="object"&&le!==null?(le=le.delay,le=typeof le=="number"&&0<le?_e+le:_e):le=_e,H){case 1:var Ee=-1;break;case 2:Ee=250;break;case 5:Ee=1073741823;break;case 4:Ee=1e4;break;default:Ee=5e3}return Ee=le+Ee,H={id:m++,callback:Z,priorityLevel:H,startTime:le,expirationTime:Ee,sortIndex:-1},le>_e?(H.sortIndex=le,t(u,H),s(g)===null&&H===s(u)&&(S?(P(ee),ee=-1):S=!0,we(D,le-_e))):(H.sortIndex=Ee,t(g,H),_||v||(_=!0,$||($=!0,Q()))),H},n.unstable_shouldYield=M,n.unstable_wrapCallback=function(H){var Z=x;return function(){var le=x;x=Z;try{return H.apply(this,arguments)}finally{x=le}}}})(Yh)),Yh}var Ag;function qS(){return Ag||(Ag=1,Vh.exports=DS()),Vh.exports}/**
11
+ * @license React
12
+ * react-dom-client.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var jg;function LS(){if(jg)return to;jg=1;var n=qS(),t=Xw(),s=nS();function i(e){var r="https://react.dev/errors/"+e;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var r=e,a=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(a=r.return),e=r.return;while(e)}return r.tag===3?a:null}function d(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function y(e){if(e.tag===31){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function g(e){if(c(e)!==e)throw Error(i(188))}function u(e){var r=e.alternate;if(!r){if(r=c(e),r===null)throw Error(i(188));return r!==e?null:e}for(var a=e,l=r;;){var f=a.return;if(f===null)break;var p=f.alternate;if(p===null){if(l=f.return,l!==null){a=l;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===a)return g(f),e;if(p===l)return g(f),r;p=p.sibling}throw Error(i(188))}if(a.return!==l.return)a=f,l=p;else{for(var w=!1,O=f.child;O;){if(O===a){w=!0,a=f,l=p;break}if(O===l){w=!0,l=f,a=p;break}O=O.sibling}if(!w){for(O=p.child;O;){if(O===a){w=!0,a=p,l=f;break}if(O===l){w=!0,l=p,a=f;break}O=O.sibling}if(!w)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?e:r}function m(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e;for(e=e.child;e!==null;){if(r=m(e),r!==null)return r;e=e.sibling}return null}var b=Object.assign,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),oe=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),J=Symbol.iterator;function Q(e){return e===null||typeof e!="object"?null:(e=J&&e[J]||e["@@iterator"],typeof e=="function"?e:null)}var he=Symbol.for("react.client.reference");function be(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===he?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case L:return"Profiler";case C:return"StrictMode";case D:return"Suspense";case $:return"SuspenseList";case I:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case _:return"Portal";case ie:return e.displayName||"Context";case P:return(e._context.displayName||"Context")+".Consumer";case oe:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:be(e.type)||"Memo";case K:r=e._payload,e=e._init;try{return be(e(r))}catch{}}return null}var we=Array.isArray,H=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},_e=[],Ee=-1;function Ne(e){return{current:e}}function ke(e){0>Ee||(e.current=_e[Ee],_e[Ee]=null,Ee--)}function Te(e,r){Ee++,_e[Ee]=e.current,e.current=r}var st=Ne(null),Nt=Ne(null),Bt=Ne(null),gt=Ne(null);function bt(e,r){switch(Te(Bt,r),Te(Nt,e),Te(st,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?Gy(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=Gy(r),e=Vy(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ke(st),Te(st,e)}function ue(){ke(st),ke(Nt),ke(Bt)}function Je(e){e.memoizedState!==null&&Te(gt,e);var r=st.current,a=Vy(r,e.type);r!==a&&(Te(Nt,e),Te(st,a))}function jn(e){Nt.current===e&&(ke(st),ke(Nt)),gt.current===e&&(ke(gt),Xa._currentValue=le)}var lr,ve;function Fe(e){if(lr===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);lr=r&&r[1]||"",ve=-1<a.stack.indexOf(`
19
+ at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
20
+ `+lr+e+ve}var St=!1;function lt(e,r){if(!e||St)return"";St=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(r){var se=function(){throw Error()};if(Object.defineProperty(se.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(se,[])}catch(X){var V=X}Reflect.construct(e,[],se)}else{try{se.call()}catch(X){V=X}e.call(se.prototype)}}else{try{throw Error()}catch(X){V=X}(se=e())&&typeof se.catch=="function"&&se.catch(function(){})}}catch(X){if(X&&V&&typeof X.stack=="string")return[X.stack,V.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=l.DetermineComponentFrameRoot(),w=p[0],O=p[1];if(w&&O){var R=w.split(`
21
+ `),G=O.split(`
22
+ `);for(f=l=0;l<R.length&&!R[l].includes("DetermineComponentFrameRoot");)l++;for(;f<G.length&&!G[f].includes("DetermineComponentFrameRoot");)f++;if(l===R.length||f===G.length)for(l=R.length-1,f=G.length-1;1<=l&&0<=f&&R[l]!==G[f];)f--;for(;1<=l&&0<=f;l--,f--)if(R[l]!==G[f]){if(l!==1||f!==1)do if(l--,f--,0>f||R[l]!==G[f]){var W=`
23
+ `+R[l].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),W}while(1<=l&&0<=f);break}}}finally{St=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?Fe(a):""}function Pr(e,r){switch(e.tag){case 26:case 27:case 5:return Fe(e.type);case 16:return Fe("Lazy");case 13:return e.child!==r&&r!==null?Fe("Suspense Fallback"):Fe("Suspense");case 19:return Fe("SuspenseList");case 0:case 15:return lt(e.type,!1);case 11:return lt(e.type.render,!1);case 1:return lt(e.type,!0);case 31:return Fe("Activity");default:return""}}function Bo(e){try{var r="",a=null;do r+=Pr(e,a),a=e,e=e.return;while(e);return r}catch(l){return`
24
+ Error generating stack: `+l.message+`
25
+ `+l.stack}}var oa=Object.prototype.hasOwnProperty,la=n.unstable_scheduleCallback,cr=n.unstable_cancelCallback,Po=n.unstable_shouldYield,ni=n.unstable_requestPaint,ct=n.unstable_now,Du=n.unstable_getCurrentPriorityLevel,Uo=n.unstable_ImmediatePriority,zo=n.unstable_UserBlockingPriority,ri=n.unstable_NormalPriority,qu=n.unstable_LowPriority,Io=n.unstable_IdlePriority,Lu=n.log,$o=n.unstable_setDisableYieldValue,As=null,xt=null;function an(e){if(typeof Lu=="function"&&$o(e),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(As,e)}catch{}}var Ht=Math.clz32?Math.clz32:si,ca=Math.log,ua=Math.LN2;function si(e){return e>>>=0,e===0?32:31-(ca(e)/ua|0)|0}var Ur=256,ur=262144,zr=4194304;function In(e){var r=e&42;if(r!==0)return r;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function js(e,r,a){var l=e.pendingLanes;if(l===0)return 0;var f=0,p=e.suspendedLanes,w=e.pingedLanes;e=e.warmLanes;var O=l&134217727;return O!==0?(l=O&~p,l!==0?f=In(l):(w&=O,w!==0?f=In(w):a||(a=O&~e,a!==0&&(f=In(a))))):(O=l&~p,O!==0?f=In(O):w!==0?f=In(w):a||(a=l&~e,a!==0&&(f=In(a)))),f===0?0:r!==0&&r!==f&&(r&p)===0&&(p=f&-f,a=r&-r,p>=a||p===32&&(a&4194048)!==0)?r:f}function ks(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function fa(e,r){switch(e){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ii(){var e=zr;return zr<<=1,(zr&62914560)===0&&(zr=4194304),e}function Ir(e){for(var r=[],a=0;31>a;a++)r.push(e);return r}function $n(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function $r(e,r,a,l,f,p){var w=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var O=e.entanglements,R=e.expirationTimes,G=e.hiddenUpdates;for(a=w&~a;0<a;){var W=31-Ht(a),se=1<<W;O[W]=0,R[W]=-1;var V=G[W];if(V!==null)for(G[W]=null,W=0;W<V.length;W++){var X=V[W];X!==null&&(X.lane&=-536870913)}a&=~se}l!==0&&Hr(e,l,0),p!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=p&~(w&~r))}function Hr(e,r,a){e.pendingLanes|=r,e.suspendedLanes&=~r;var l=31-Ht(r);e.entangledLanes|=r,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function Ns(e,r){var a=e.entangledLanes|=r;for(e=e.entanglements;a;){var l=31-Ht(a),f=1<<l;f&r|e[l]&r&&(e[l]|=r),a&=~f}}function Fr(e,r){var a=r&-r;return a=(a&42)!==0?1:fr(a),(a&(e.suspendedLanes|r))!==0?0:a}function fr(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ts(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ha(){var e=Z.p;return e!==0?e:(e=window.event,e===void 0?32:pg(e.type))}function Ho(e,r){var a=Z.p;try{return Z.p=e,r()}finally{Z.p=a}}var Zn=Math.random().toString(36).slice(2),nt="__reactFiber$"+Zn,dt="__reactProps$"+Zn,on="__reactContainer$"+Zn,Cs="__reactEvents$"+Zn,da="__reactListeners$"+Zn,Fo="__reactHandles$"+Zn,Go="__reactResources$"+Zn,Tt="__reactMarker$"+Zn;function ai(e){delete e[nt],delete e[dt],delete e[Cs],delete e[da],delete e[Fo]}function A(e){var r=e[nt];if(r)return r;for(var a=e.parentNode;a;){if(r=a[on]||a[nt]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(e=Zy(e);e!==null;){if(a=e[nt])return a;e=Zy(e)}return r}e=a,a=e.parentNode}return null}function N(e){if(e=e[nt]||e[on]){var r=e.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return e}return null}function k(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e.stateNode;throw Error(i(33))}function T(e){var r=e[Go];return r||(r=e[Go]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function q(e){e[Tt]=!0}var z=new Set,re={};function ae(e,r){Y(e,r),Y(e+"Capture",r)}function Y(e,r){for(re[e]=r,e=0;e<r.length;e++)z.add(r[e])}var ne=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ye={},Re={};function it(e){return oa.call(Re,e)?!0:oa.call(ye,e)?!1:ne.test(e)?Re[e]=!0:(ye[e]=!0,!1)}function Ft(e,r,a){if(it(r))if(a===null)e.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(r);return;case"boolean":var l=r.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(r);return}}e.setAttribute(r,""+a)}}function Hn(e,r,a){if(a===null)e.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttribute(r,""+a)}}function hr(e,r,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(r,a,""+l)}}function kn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Bm(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function $v(e,r,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,r);if(!e.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,p=l.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return f.call(this)},set:function(w){a=""+w,p.call(this,w)}}),Object.defineProperty(e,r,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(w){a=""+w},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function Bu(e){if(!e._valueTracker){var r=Bm(e)?"checked":"value";e._valueTracker=$v(e,r,""+e[r])}}function Pm(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return e&&(l=Bm(e)?e.checked?"true":"false":e.value),e=l,e!==a?(r.setValue(e),!0):!1}function Vo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Hv=/[\n"\\]/g;function Nn(e){return e.replace(Hv,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Pu(e,r,a,l,f,p,w,O){e.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?e.type=w:e.removeAttribute("type"),r!=null?w==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+kn(r)):e.value!==""+kn(r)&&(e.value=""+kn(r)):w!=="submit"&&w!=="reset"||e.removeAttribute("value"),r!=null?Uu(e,w,kn(r)):a!=null?Uu(e,w,kn(a)):l!=null&&e.removeAttribute("value"),f==null&&p!=null&&(e.defaultChecked=!!p),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?e.name=""+kn(O):e.removeAttribute("name")}function Um(e,r,a,l,f,p,w,O){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),r!=null||a!=null){if(!(p!=="submit"&&p!=="reset"||r!=null)){Bu(e);return}a=a!=null?""+kn(a):"",r=r!=null?""+kn(r):a,O||r===e.value||(e.value=r),e.defaultValue=r}l=l??f,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=O?e.checked:!!l,e.defaultChecked=!!l,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(e.name=w),Bu(e)}function Uu(e,r,a){r==="number"&&Vo(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function oi(e,r,a,l){if(e=e.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<e.length;a++)f=r.hasOwnProperty("$"+e[a].value),e[a].selected!==f&&(e[a].selected=f),f&&l&&(e[a].defaultSelected=!0)}else{for(a=""+kn(a),r=null,f=0;f<e.length;f++){if(e[f].value===a){e[f].selected=!0,l&&(e[f].defaultSelected=!0);return}r!==null||e[f].disabled||(r=e[f])}r!==null&&(r.selected=!0)}}function zm(e,r,a){if(r!=null&&(r=""+kn(r),r!==e.value&&(e.value=r),a==null)){e.defaultValue!==r&&(e.defaultValue=r);return}e.defaultValue=a!=null?""+kn(a):""}function Im(e,r,a,l){if(r==null){if(l!=null){if(a!=null)throw Error(i(92));if(we(l)){if(1<l.length)throw Error(i(93));l=l[0]}a=l}a==null&&(a=""),r=a}a=kn(r),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),Bu(e)}function li(e,r){if(r){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=r;return}}e.textContent=r}var Fv=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function $m(e,r,a){var l=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="":l?e.setProperty(r,a):typeof a!="number"||a===0||Fv.has(r)?r==="float"?e.cssFloat=a:e[r]=(""+a).trim():e[r]=a+"px"}function Hm(e,r,a){if(r!=null&&typeof r!="object")throw Error(i(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||r!=null&&r.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var f in r)l=r[f],r.hasOwnProperty(f)&&a[f]!==l&&$m(e,f,l)}else for(var p in r)r.hasOwnProperty(p)&&$m(e,p,r[p])}function zu(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Gv=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Vv=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Yo(e){return Vv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function dr(){}var Iu=null;function $u(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ci=null,ui=null;function Fm(e){var r=N(e);if(r&&(e=r.stateNode)){var a=e[dt]||null;e:switch(e=r.stateNode,r.type){case"input":if(Pu(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Nn(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==e&&l.form===e.form){var f=l[dt]||null;if(!f)throw Error(i(90));Pu(l,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(r=0;r<a.length;r++)l=a[r],l.form===e.form&&Pm(l)}break e;case"textarea":zm(e,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&oi(e,!!a.multiple,r,!1)}}}var Hu=!1;function Gm(e,r,a){if(Hu)return e(r,a);Hu=!0;try{var l=e(r);return l}finally{if(Hu=!1,(ci!==null||ui!==null)&&(Dl(),ci&&(r=ci,e=ui,ui=ci=null,Fm(r),e)))for(r=0;r<e.length;r++)Fm(e[r])}}function ma(e,r){var a=e.stateNode;if(a===null)return null;var l=a[dt]||null;if(l===null)return null;a=l[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mr)try{var pa={};Object.defineProperty(pa,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",pa,pa),window.removeEventListener("test",pa,pa)}catch{Fu=!1}var Gr=null,Gu=null,Ko=null;function Vm(){if(Ko)return Ko;var e,r=Gu,a=r.length,l,f="value"in Gr?Gr.value:Gr.textContent,p=f.length;for(e=0;e<a&&r[e]===f[e];e++);var w=a-e;for(l=1;l<=w&&r[a-l]===f[p-l];l++);return Ko=f.slice(e,1<l?1-l:void 0)}function Jo(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function Qo(){return!0}function Ym(){return!1}function Wt(e){function r(a,l,f,p,w){this._reactName=a,this._targetInst=f,this.type=l,this.nativeEvent=p,this.target=w,this.currentTarget=null;for(var O in e)e.hasOwnProperty(O)&&(a=e[O],this[O]=a?a(p):p[O]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?Qo:Ym,this.isPropagationStopped=Ym,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Qo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Qo)},persist:function(){},isPersistent:Qo}),r}var Ms={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xo=Wt(Ms),ya=b({},Ms,{view:0,detail:0}),Yv=Wt(ya),Vu,Yu,ga,Wo=b({},ya,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ju,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ga&&(ga&&e.type==="mousemove"?(Vu=e.screenX-ga.screenX,Yu=e.screenY-ga.screenY):Yu=Vu=0,ga=e),Vu)},movementY:function(e){return"movementY"in e?e.movementY:Yu}}),Km=Wt(Wo),Kv=b({},Wo,{dataTransfer:0}),Jv=Wt(Kv),Qv=b({},ya,{relatedTarget:0}),Ku=Wt(Qv),Xv=b({},Ms,{animationName:0,elapsedTime:0,pseudoElement:0}),Wv=Wt(Xv),Zv=b({},Ms,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),e_=Wt(Zv),t_=b({},Ms,{data:0}),Jm=Wt(t_),n_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},r_={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},s_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function i_(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=s_[e])?!!r[e]:!1}function Ju(){return i_}var a_=b({},ya,{key:function(e){if(e.key){var r=n_[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=Jo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?r_[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ju,charCode:function(e){return e.type==="keypress"?Jo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Jo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),o_=Wt(a_),l_=b({},Wo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qm=Wt(l_),c_=b({},ya,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ju}),u_=Wt(c_),f_=b({},Ms,{propertyName:0,elapsedTime:0,pseudoElement:0}),h_=Wt(f_),d_=b({},Wo,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),m_=Wt(d_),p_=b({},Ms,{newState:0,oldState:0}),y_=Wt(p_),g_=[9,13,27,32],Qu=mr&&"CompositionEvent"in window,ba=null;mr&&"documentMode"in document&&(ba=document.documentMode);var b_=mr&&"TextEvent"in window&&!ba,Xm=mr&&(!Qu||ba&&8<ba&&11>=ba),Wm=" ",Zm=!1;function e0(e,r){switch(e){case"keyup":return g_.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function t0(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fi=!1;function x_(e,r){switch(e){case"compositionend":return t0(r);case"keypress":return r.which!==32?null:(Zm=!0,Wm);case"textInput":return e=r.data,e===Wm&&Zm?null:e;default:return null}}function v_(e,r){if(fi)return e==="compositionend"||!Qu&&e0(e,r)?(e=Vm(),Ko=Gu=Gr=null,fi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Xm&&r.locale!=="ko"?null:r.data;default:return null}}var __={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function n0(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!__[e.type]:r==="textarea"}function r0(e,r,a,l){ci?ui?ui.push(l):ui=[l]:ci=l,r=Il(r,"onChange"),0<r.length&&(a=new Xo("onChange","change",null,a,l),e.push({event:a,listeners:r}))}var xa=null,va=null;function w_(e){Uy(e,0)}function Zo(e){var r=k(e);if(Pm(r))return e}function s0(e,r){if(e==="change")return r}var i0=!1;if(mr){var Xu;if(mr){var Wu="oninput"in document;if(!Wu){var a0=document.createElement("div");a0.setAttribute("oninput","return;"),Wu=typeof a0.oninput=="function"}Xu=Wu}else Xu=!1;i0=Xu&&(!document.documentMode||9<document.documentMode)}function o0(){xa&&(xa.detachEvent("onpropertychange",l0),va=xa=null)}function l0(e){if(e.propertyName==="value"&&Zo(va)){var r=[];r0(r,va,e,$u(e)),Gm(w_,r)}}function S_(e,r,a){e==="focusin"?(o0(),xa=r,va=a,xa.attachEvent("onpropertychange",l0)):e==="focusout"&&o0()}function E_(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zo(va)}function O_(e,r){if(e==="click")return Zo(r)}function A_(e,r){if(e==="input"||e==="change")return Zo(r)}function j_(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var ln=typeof Object.is=="function"?Object.is:j_;function _a(e,r){if(ln(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var a=Object.keys(e),l=Object.keys(r);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var f=a[l];if(!oa.call(r,f)||!ln(e[f],r[f]))return!1}return!0}function c0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function u0(e,r){var a=c0(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=r&&l>=r)return{node:a,offset:r-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=c0(a)}}function f0(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?f0(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function h0(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=Vo(e.document);r instanceof e.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)e=r.contentWindow;else break;r=Vo(e.document)}return r}function Zu(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var k_=mr&&"documentMode"in document&&11>=document.documentMode,hi=null,ef=null,wa=null,tf=!1;function d0(e,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;tf||hi==null||hi!==Vo(l)||(l=hi,"selectionStart"in l&&Zu(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),wa&&_a(wa,l)||(wa=l,l=Il(ef,"onSelect"),0<l.length&&(r=new Xo("onSelect","select",null,r,a),e.push({event:r,listeners:l}),r.target=hi)))}function Rs(e,r){var a={};return a[e.toLowerCase()]=r.toLowerCase(),a["Webkit"+e]="webkit"+r,a["Moz"+e]="moz"+r,a}var di={animationend:Rs("Animation","AnimationEnd"),animationiteration:Rs("Animation","AnimationIteration"),animationstart:Rs("Animation","AnimationStart"),transitionrun:Rs("Transition","TransitionRun"),transitionstart:Rs("Transition","TransitionStart"),transitioncancel:Rs("Transition","TransitionCancel"),transitionend:Rs("Transition","TransitionEnd")},nf={},m0={};mr&&(m0=document.createElement("div").style,"AnimationEvent"in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),"TransitionEvent"in window||delete di.transitionend.transition);function Ds(e){if(nf[e])return nf[e];if(!di[e])return e;var r=di[e],a;for(a in r)if(r.hasOwnProperty(a)&&a in m0)return nf[e]=r[a];return e}var p0=Ds("animationend"),y0=Ds("animationiteration"),g0=Ds("animationstart"),N_=Ds("transitionrun"),T_=Ds("transitionstart"),C_=Ds("transitioncancel"),b0=Ds("transitionend"),x0=new Map,rf="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");rf.push("scrollEnd");function Fn(e,r){x0.set(e,r),ae(r,[e])}var el=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Tn=[],mi=0,sf=0;function tl(){for(var e=mi,r=sf=mi=0;r<e;){var a=Tn[r];Tn[r++]=null;var l=Tn[r];Tn[r++]=null;var f=Tn[r];Tn[r++]=null;var p=Tn[r];if(Tn[r++]=null,l!==null&&f!==null){var w=l.pending;w===null?f.next=f:(f.next=w.next,w.next=f),l.pending=f}p!==0&&v0(a,f,p)}}function nl(e,r,a,l){Tn[mi++]=e,Tn[mi++]=r,Tn[mi++]=a,Tn[mi++]=l,sf|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function af(e,r,a,l){return nl(e,r,a,l),rl(e)}function qs(e,r){return nl(e,null,null,r),rl(e)}function v0(e,r,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var f=!1,p=e.return;p!==null;)p.childLanes|=a,l=p.alternate,l!==null&&(l.childLanes|=a),p.tag===22&&(e=p.stateNode,e===null||e._visibility&1||(f=!0)),e=p,p=p.return;return e.tag===3?(p=e.stateNode,f&&r!==null&&(f=31-Ht(a),e=p.hiddenUpdates,l=e[f],l===null?e[f]=[r]:l.push(r),r.lane=a|536870912),p):null}function rl(e){if(50<Fa)throw Fa=0,ph=null,Error(i(185));for(var r=e.return;r!==null;)e=r,r=e.return;return e.tag===3?e.stateNode:null}var pi={};function M_(e,r,a,l){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function cn(e,r,a,l){return new M_(e,r,a,l)}function of(e){return e=e.prototype,!(!e||!e.isReactComponent)}function pr(e,r){var a=e.alternate;return a===null?(a=cn(e.tag,r,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=r,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,r=e.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function _0(e,r){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=r,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,r=a.dependencies,e.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),e}function sl(e,r,a,l,f,p){var w=0;if(l=e,typeof e=="function")of(e)&&(w=1);else if(typeof e=="string")w=Bw(e,a,st.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case I:return e=cn(31,a,r,f),e.elementType=I,e.lanes=p,e;case S:return Ls(a.children,f,p,r);case C:w=8,f|=24;break;case L:return e=cn(12,a,r,f|2),e.elementType=L,e.lanes=p,e;case D:return e=cn(13,a,r,f),e.elementType=D,e.lanes=p,e;case $:return e=cn(19,a,r,f),e.elementType=$,e.lanes=p,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ie:w=10;break e;case P:w=9;break e;case oe:w=11;break e;case ee:w=14;break e;case K:w=16,l=null;break e}w=29,a=Error(i(130,e===null?"null":typeof e,"")),l=null}return r=cn(w,a,r,f),r.elementType=e,r.type=l,r.lanes=p,r}function Ls(e,r,a,l){return e=cn(7,e,l,r),e.lanes=a,e}function lf(e,r,a){return e=cn(6,e,null,r),e.lanes=a,e}function w0(e){var r=cn(18,null,null,0);return r.stateNode=e,r}function cf(e,r,a){return r=cn(4,e.children!==null?e.children:[],e.key,r),r.lanes=a,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}var S0=new WeakMap;function Cn(e,r){if(typeof e=="object"&&e!==null){var a=S0.get(e);return a!==void 0?a:(r={value:e,source:r,stack:Bo(r)},S0.set(e,r),r)}return{value:e,source:r,stack:Bo(r)}}var yi=[],gi=0,il=null,Sa=0,Mn=[],Rn=0,Vr=null,er=1,tr="";function yr(e,r){yi[gi++]=Sa,yi[gi++]=il,il=e,Sa=r}function E0(e,r,a){Mn[Rn++]=er,Mn[Rn++]=tr,Mn[Rn++]=Vr,Vr=e;var l=er;e=tr;var f=32-Ht(l)-1;l&=~(1<<f),a+=1;var p=32-Ht(r)+f;if(30<p){var w=f-f%5;p=(l&(1<<w)-1).toString(32),l>>=w,f-=w,er=1<<32-Ht(r)+f|a<<f|l,tr=p+e}else er=1<<p|a<<f|l,tr=e}function uf(e){e.return!==null&&(yr(e,1),E0(e,1,0))}function ff(e){for(;e===il;)il=yi[--gi],yi[gi]=null,Sa=yi[--gi],yi[gi]=null;for(;e===Vr;)Vr=Mn[--Rn],Mn[Rn]=null,tr=Mn[--Rn],Mn[Rn]=null,er=Mn[--Rn],Mn[Rn]=null}function O0(e,r){Mn[Rn++]=er,Mn[Rn++]=tr,Mn[Rn++]=Vr,er=r.id,tr=r.overflow,Vr=e}var Pt=null,at=null,Ie=!1,Yr=null,Dn=!1,hf=Error(i(519));function Kr(e){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ea(Cn(r,e)),hf}function A0(e){var r=e.stateNode,a=e.type,l=e.memoizedProps;switch(r[nt]=e,r[dt]=l,a){case"dialog":Le("cancel",r),Le("close",r);break;case"iframe":case"object":case"embed":Le("load",r);break;case"video":case"audio":for(a=0;a<Va.length;a++)Le(Va[a],r);break;case"source":Le("error",r);break;case"img":case"image":case"link":Le("error",r),Le("load",r);break;case"details":Le("toggle",r);break;case"input":Le("invalid",r),Um(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Le("invalid",r);break;case"textarea":Le("invalid",r),Im(r,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||l.suppressHydrationWarning===!0||Hy(r.textContent,a)?(l.popover!=null&&(Le("beforetoggle",r),Le("toggle",r)),l.onScroll!=null&&Le("scroll",r),l.onScrollEnd!=null&&Le("scrollend",r),l.onClick!=null&&(r.onclick=dr),r=!0):r=!1,r||Kr(e,!0)}function j0(e){for(Pt=e.return;Pt;)switch(Pt.tag){case 5:case 31:case 13:Dn=!1;return;case 27:case 3:Dn=!0;return;default:Pt=Pt.return}}function bi(e){if(e!==Pt)return!1;if(!Ie)return j0(e),Ie=!0,!1;var r=e.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Th(e.type,e.memoizedProps)),a=!a),a&&at&&Kr(e),j0(e),r===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));at=Wy(e)}else if(r===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));at=Wy(e)}else r===27?(r=at,ls(e.type)?(e=qh,qh=null,at=e):at=r):at=Pt?Ln(e.stateNode.nextSibling):null;return!0}function Bs(){at=Pt=null,Ie=!1}function df(){var e=Yr;return e!==null&&(nn===null?nn=e:nn.push.apply(nn,e),Yr=null),e}function Ea(e){Yr===null?Yr=[e]:Yr.push(e)}var mf=Ne(null),Ps=null,gr=null;function Jr(e,r,a){Te(mf,r._currentValue),r._currentValue=a}function br(e){e._currentValue=mf.current,ke(mf)}function pf(e,r,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,l!==null&&(l.childLanes|=r)):l!==null&&(l.childLanes&r)!==r&&(l.childLanes|=r),e===a)break;e=e.return}}function yf(e,r,a,l){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var p=f.dependencies;if(p!==null){var w=f.child;p=p.firstContext;e:for(;p!==null;){var O=p;p=f;for(var R=0;R<r.length;R++)if(O.context===r[R]){p.lanes|=a,O=p.alternate,O!==null&&(O.lanes|=a),pf(p.return,a,e),l||(w=null);break e}p=O.next}}else if(f.tag===18){if(w=f.return,w===null)throw Error(i(341));w.lanes|=a,p=w.alternate,p!==null&&(p.lanes|=a),pf(w,a,e),w=null}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===e){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}}function xi(e,r,a,l){e=null;for(var f=r,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var w=f.alternate;if(w===null)throw Error(i(387));if(w=w.memoizedProps,w!==null){var O=f.type;ln(f.pendingProps.value,w.value)||(e!==null?e.push(O):e=[O])}}else if(f===gt.current){if(w=f.alternate,w===null)throw Error(i(387));w.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Xa):e=[Xa])}f=f.return}e!==null&&yf(r,e,a,l),r.flags|=262144}function al(e){for(e=e.firstContext;e!==null;){if(!ln(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Us(e){Ps=e,gr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ut(e){return k0(Ps,e)}function ol(e,r){return Ps===null&&Us(e),k0(e,r)}function k0(e,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},gr===null){if(e===null)throw Error(i(308));gr=r,e.dependencies={lanes:0,firstContext:r},e.flags|=524288}else gr=gr.next=r;return a}var R_=typeof AbortController<"u"?AbortController:function(){var e=[],r=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){r.aborted=!0,e.forEach(function(a){return a()})}},D_=n.unstable_scheduleCallback,q_=n.unstable_NormalPriority,Et={$$typeof:ie,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gf(){return{controller:new R_,data:new Map,refCount:0}}function Oa(e){e.refCount--,e.refCount===0&&D_(q_,function(){e.controller.abort()})}var Aa=null,bf=0,vi=0,_i=null;function L_(e,r){if(Aa===null){var a=Aa=[];bf=0,vi=_h(),_i={status:"pending",value:void 0,then:function(l){a.push(l)}}}return bf++,r.then(N0,N0),r}function N0(){if(--bf===0&&Aa!==null){_i!==null&&(_i.status="fulfilled");var e=Aa;Aa=null,vi=0,_i=null;for(var r=0;r<e.length;r++)(0,e[r])()}}function B_(e,r){var a=[],l={status:"pending",value:null,reason:null,then:function(f){a.push(f)}};return e.then(function(){l.status="fulfilled",l.value=r;for(var f=0;f<a.length;f++)(0,a[f])(r)},function(f){for(l.status="rejected",l.reason=f,f=0;f<a.length;f++)(0,a[f])(void 0)}),l}var T0=H.S;H.S=function(e,r){dy=ct(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&L_(e,r),T0!==null&&T0(e,r)};var zs=Ne(null);function xf(){var e=zs.current;return e!==null?e:rt.pooledCache}function ll(e,r){r===null?Te(zs,zs.current):Te(zs,r.pool)}function C0(){var e=xf();return e===null?null:{parent:Et._currentValue,pool:e}}var wi=Error(i(460)),vf=Error(i(474)),cl=Error(i(542)),ul={then:function(){}};function M0(e){return e=e.status,e==="fulfilled"||e==="rejected"}function R0(e,r,a){switch(a=e[a],a===void 0?e.push(r):a!==r&&(r.then(dr,dr),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,q0(e),e;default:if(typeof r.status=="string")r.then(dr,dr);else{if(e=rt,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=r,e.status="pending",e.then(function(l){if(r.status==="pending"){var f=r;f.status="fulfilled",f.value=l}},function(l){if(r.status==="pending"){var f=r;f.status="rejected",f.reason=l}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,q0(e),e}throw $s=r,wi}}function Is(e){try{var r=e._init;return r(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?($s=a,wi):a}}var $s=null;function D0(){if($s===null)throw Error(i(459));var e=$s;return $s=null,e}function q0(e){if(e===wi||e===cl)throw Error(i(483))}var Si=null,ja=0;function fl(e){var r=ja;return ja+=1,Si===null&&(Si=[]),R0(Si,e,r)}function ka(e,r){r=r.props.ref,e.ref=r!==void 0?r:null}function hl(e,r){throw r.$$typeof===x?Error(i(525)):(e=Object.prototype.toString.call(r),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)))}function L0(e){function r(U,B){if(e){var F=U.deletions;F===null?(U.deletions=[B],U.flags|=16):F.push(B)}}function a(U,B){if(!e)return null;for(;B!==null;)r(U,B),B=B.sibling;return null}function l(U){for(var B=new Map;U!==null;)U.key!==null?B.set(U.key,U):B.set(U.index,U),U=U.sibling;return B}function f(U,B){return U=pr(U,B),U.index=0,U.sibling=null,U}function p(U,B,F){return U.index=F,e?(F=U.alternate,F!==null?(F=F.index,F<B?(U.flags|=67108866,B):F):(U.flags|=67108866,B)):(U.flags|=1048576,B)}function w(U){return e&&U.alternate===null&&(U.flags|=67108866),U}function O(U,B,F,te){return B===null||B.tag!==6?(B=lf(F,U.mode,te),B.return=U,B):(B=f(B,F),B.return=U,B)}function R(U,B,F,te){var Oe=F.type;return Oe===S?W(U,B,F.props.children,te,F.key):B!==null&&(B.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===K&&Is(Oe)===B.type)?(B=f(B,F.props),ka(B,F),B.return=U,B):(B=sl(F.type,F.key,F.props,null,U.mode,te),ka(B,F),B.return=U,B)}function G(U,B,F,te){return B===null||B.tag!==4||B.stateNode.containerInfo!==F.containerInfo||B.stateNode.implementation!==F.implementation?(B=cf(F,U.mode,te),B.return=U,B):(B=f(B,F.children||[]),B.return=U,B)}function W(U,B,F,te,Oe){return B===null||B.tag!==7?(B=Ls(F,U.mode,te,Oe),B.return=U,B):(B=f(B,F),B.return=U,B)}function se(U,B,F){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=lf(""+B,U.mode,F),B.return=U,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case v:return F=sl(B.type,B.key,B.props,null,U.mode,F),ka(F,B),F.return=U,F;case _:return B=cf(B,U.mode,F),B.return=U,B;case K:return B=Is(B),se(U,B,F)}if(we(B)||Q(B))return B=Ls(B,U.mode,F,null),B.return=U,B;if(typeof B.then=="function")return se(U,fl(B),F);if(B.$$typeof===ie)return se(U,ol(U,B),F);hl(U,B)}return null}function V(U,B,F,te){var Oe=B!==null?B.key:null;if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return Oe!==null?null:O(U,B,""+F,te);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case v:return F.key===Oe?R(U,B,F,te):null;case _:return F.key===Oe?G(U,B,F,te):null;case K:return F=Is(F),V(U,B,F,te)}if(we(F)||Q(F))return Oe!==null?null:W(U,B,F,te,null);if(typeof F.then=="function")return V(U,B,fl(F),te);if(F.$$typeof===ie)return V(U,B,ol(U,F),te);hl(U,F)}return null}function X(U,B,F,te,Oe){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return U=U.get(F)||null,O(B,U,""+te,Oe);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case v:return U=U.get(te.key===null?F:te.key)||null,R(B,U,te,Oe);case _:return U=U.get(te.key===null?F:te.key)||null,G(B,U,te,Oe);case K:return te=Is(te),X(U,B,F,te,Oe)}if(we(te)||Q(te))return U=U.get(F)||null,W(B,U,te,Oe,null);if(typeof te.then=="function")return X(U,B,F,fl(te),Oe);if(te.$$typeof===ie)return X(U,B,F,ol(B,te),Oe);hl(B,te)}return null}function ge(U,B,F,te){for(var Oe=null,Ve=null,xe=B,Me=B=0,Pe=null;xe!==null&&Me<F.length;Me++){xe.index>Me?(Pe=xe,xe=null):Pe=xe.sibling;var Ye=V(U,xe,F[Me],te);if(Ye===null){xe===null&&(xe=Pe);break}e&&xe&&Ye.alternate===null&&r(U,xe),B=p(Ye,B,Me),Ve===null?Oe=Ye:Ve.sibling=Ye,Ve=Ye,xe=Pe}if(Me===F.length)return a(U,xe),Ie&&yr(U,Me),Oe;if(xe===null){for(;Me<F.length;Me++)xe=se(U,F[Me],te),xe!==null&&(B=p(xe,B,Me),Ve===null?Oe=xe:Ve.sibling=xe,Ve=xe);return Ie&&yr(U,Me),Oe}for(xe=l(xe);Me<F.length;Me++)Pe=X(xe,U,Me,F[Me],te),Pe!==null&&(e&&Pe.alternate!==null&&xe.delete(Pe.key===null?Me:Pe.key),B=p(Pe,B,Me),Ve===null?Oe=Pe:Ve.sibling=Pe,Ve=Pe);return e&&xe.forEach(function(ds){return r(U,ds)}),Ie&&yr(U,Me),Oe}function je(U,B,F,te){if(F==null)throw Error(i(151));for(var Oe=null,Ve=null,xe=B,Me=B=0,Pe=null,Ye=F.next();xe!==null&&!Ye.done;Me++,Ye=F.next()){xe.index>Me?(Pe=xe,xe=null):Pe=xe.sibling;var ds=V(U,xe,Ye.value,te);if(ds===null){xe===null&&(xe=Pe);break}e&&xe&&ds.alternate===null&&r(U,xe),B=p(ds,B,Me),Ve===null?Oe=ds:Ve.sibling=ds,Ve=ds,xe=Pe}if(Ye.done)return a(U,xe),Ie&&yr(U,Me),Oe;if(xe===null){for(;!Ye.done;Me++,Ye=F.next())Ye=se(U,Ye.value,te),Ye!==null&&(B=p(Ye,B,Me),Ve===null?Oe=Ye:Ve.sibling=Ye,Ve=Ye);return Ie&&yr(U,Me),Oe}for(xe=l(xe);!Ye.done;Me++,Ye=F.next())Ye=X(xe,U,Me,Ye.value,te),Ye!==null&&(e&&Ye.alternate!==null&&xe.delete(Ye.key===null?Me:Ye.key),B=p(Ye,B,Me),Ve===null?Oe=Ye:Ve.sibling=Ye,Ve=Ye);return e&&xe.forEach(function(Kw){return r(U,Kw)}),Ie&&yr(U,Me),Oe}function tt(U,B,F,te){if(typeof F=="object"&&F!==null&&F.type===S&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case v:e:{for(var Oe=F.key;B!==null;){if(B.key===Oe){if(Oe=F.type,Oe===S){if(B.tag===7){a(U,B.sibling),te=f(B,F.props.children),te.return=U,U=te;break e}}else if(B.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===K&&Is(Oe)===B.type){a(U,B.sibling),te=f(B,F.props),ka(te,F),te.return=U,U=te;break e}a(U,B);break}else r(U,B);B=B.sibling}F.type===S?(te=Ls(F.props.children,U.mode,te,F.key),te.return=U,U=te):(te=sl(F.type,F.key,F.props,null,U.mode,te),ka(te,F),te.return=U,U=te)}return w(U);case _:e:{for(Oe=F.key;B!==null;){if(B.key===Oe)if(B.tag===4&&B.stateNode.containerInfo===F.containerInfo&&B.stateNode.implementation===F.implementation){a(U,B.sibling),te=f(B,F.children||[]),te.return=U,U=te;break e}else{a(U,B);break}else r(U,B);B=B.sibling}te=cf(F,U.mode,te),te.return=U,U=te}return w(U);case K:return F=Is(F),tt(U,B,F,te)}if(we(F))return ge(U,B,F,te);if(Q(F)){if(Oe=Q(F),typeof Oe!="function")throw Error(i(150));return F=Oe.call(F),je(U,B,F,te)}if(typeof F.then=="function")return tt(U,B,fl(F),te);if(F.$$typeof===ie)return tt(U,B,ol(U,F),te);hl(U,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,B!==null&&B.tag===6?(a(U,B.sibling),te=f(B,F),te.return=U,U=te):(a(U,B),te=lf(F,U.mode,te),te.return=U,U=te),w(U)):a(U,B)}return function(U,B,F,te){try{ja=0;var Oe=tt(U,B,F,te);return Si=null,Oe}catch(xe){if(xe===wi||xe===cl)throw xe;var Ve=cn(29,xe,null,U.mode);return Ve.lanes=te,Ve.return=U,Ve}finally{}}}var Hs=L0(!0),B0=L0(!1),Qr=!1;function _f(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wf(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Xr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Wr(e,r,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ke&2)!==0){var f=l.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),l.pending=r,r=rl(e),v0(e,null,a),r}return nl(e,l,r,a),rl(e)}function Na(e,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var l=r.lanes;l&=e.pendingLanes,a|=l,r.lanes=a,Ns(e,a)}}function Sf(e,r){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var f=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var w={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};p===null?f=p=w:p=p.next=w,a=a.next}while(a!==null);p===null?f=p=r:p=p.next=r}else f=p=r;a={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=r:e.next=r,a.lastBaseUpdate=r}var Ef=!1;function Ta(){if(Ef){var e=_i;if(e!==null)throw e}}function Ca(e,r,a,l){Ef=!1;var f=e.updateQueue;Qr=!1;var p=f.firstBaseUpdate,w=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var R=O,G=R.next;R.next=null,w===null?p=G:w.next=G,w=R;var W=e.alternate;W!==null&&(W=W.updateQueue,O=W.lastBaseUpdate,O!==w&&(O===null?W.firstBaseUpdate=G:O.next=G,W.lastBaseUpdate=R))}if(p!==null){var se=f.baseState;w=0,W=G=R=null,O=p;do{var V=O.lane&-536870913,X=V!==O.lane;if(X?(Be&V)===V:(l&V)===V){V!==0&&V===vi&&(Ef=!0),W!==null&&(W=W.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var ge=e,je=O;V=r;var tt=a;switch(je.tag){case 1:if(ge=je.payload,typeof ge=="function"){se=ge.call(tt,se,V);break e}se=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=je.payload,V=typeof ge=="function"?ge.call(tt,se,V):ge,V==null)break e;se=b({},se,V);break e;case 2:Qr=!0}}V=O.callback,V!==null&&(e.flags|=64,X&&(e.flags|=8192),X=f.callbacks,X===null?f.callbacks=[V]:X.push(V))}else X={lane:V,tag:O.tag,payload:O.payload,callback:O.callback,next:null},W===null?(G=W=X,R=se):W=W.next=X,w|=V;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;X=O,O=X.next,X.next=null,f.lastBaseUpdate=X,f.shared.pending=null}}while(!0);W===null&&(R=se),f.baseState=R,f.firstBaseUpdate=G,f.lastBaseUpdate=W,p===null&&(f.shared.lanes=0),rs|=w,e.lanes=w,e.memoizedState=se}}function P0(e,r){if(typeof e!="function")throw Error(i(191,e));e.call(r)}function U0(e,r){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)P0(a[e],r)}var Ei=Ne(null),dl=Ne(0);function z0(e,r){e=jr,Te(dl,e),Te(Ei,r),jr=e|r.baseLanes}function Of(){Te(dl,jr),Te(Ei,Ei.current)}function Af(){jr=dl.current,ke(Ei),ke(dl)}var un=Ne(null),qn=null;function Zr(e){var r=e.alternate;Te(vt,vt.current&1),Te(un,e),qn===null&&(r===null||Ei.current!==null||r.memoizedState!==null)&&(qn=e)}function jf(e){Te(vt,vt.current),Te(un,e),qn===null&&(qn=e)}function I0(e){e.tag===22?(Te(vt,vt.current),Te(un,e),qn===null&&(qn=e)):es()}function es(){Te(vt,vt.current),Te(un,un.current)}function fn(e){ke(un),qn===e&&(qn=null),ke(vt)}var vt=Ne(0);function ml(e){for(var r=e;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Rh(a)||Dh(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var xr=0,Ce=null,Ze=null,Ot=null,pl=!1,Oi=!1,Fs=!1,yl=0,Ma=0,Ai=null,P_=0;function mt(){throw Error(i(321))}function kf(e,r){if(r===null)return!1;for(var a=0;a<r.length&&a<e.length;a++)if(!ln(e[a],r[a]))return!1;return!0}function Nf(e,r,a,l,f,p){return xr=p,Ce=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,H.H=e===null||e.memoizedState===null?Ep:Ff,Fs=!1,p=a(l,f),Fs=!1,Oi&&(p=H0(r,a,l,f)),$0(e),p}function $0(e){H.H=qa;var r=Ze!==null&&Ze.next!==null;if(xr=0,Ot=Ze=Ce=null,pl=!1,Ma=0,Ai=null,r)throw Error(i(300));e===null||At||(e=e.dependencies,e!==null&&al(e)&&(At=!0))}function H0(e,r,a,l){Ce=e;var f=0;do{if(Oi&&(Ai=null),Ma=0,Oi=!1,25<=f)throw Error(i(301));if(f+=1,Ot=Ze=null,e.updateQueue!=null){var p=e.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}H.H=Op,p=r(a,l)}while(Oi);return p}function U_(){var e=H.H,r=e.useState()[0];return r=typeof r.then=="function"?Ra(r):r,e=e.useState()[0],(Ze!==null?Ze.memoizedState:null)!==e&&(Ce.flags|=1024),r}function Tf(){var e=yl!==0;return yl=0,e}function Cf(e,r,a){r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~a}function Mf(e){if(pl){for(e=e.memoizedState;e!==null;){var r=e.queue;r!==null&&(r.pending=null),e=e.next}pl=!1}xr=0,Ot=Ze=Ce=null,Oi=!1,Ma=yl=0,Ai=null}function Gt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ot===null?Ce.memoizedState=Ot=e:Ot=Ot.next=e,Ot}function _t(){if(Ze===null){var e=Ce.alternate;e=e!==null?e.memoizedState:null}else e=Ze.next;var r=Ot===null?Ce.memoizedState:Ot.next;if(r!==null)Ot=r,Ze=e;else{if(e===null)throw Ce.alternate===null?Error(i(467)):Error(i(310));Ze=e,e={memoizedState:Ze.memoizedState,baseState:Ze.baseState,baseQueue:Ze.baseQueue,queue:Ze.queue,next:null},Ot===null?Ce.memoizedState=Ot=e:Ot=Ot.next=e}return Ot}function gl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ra(e){var r=Ma;return Ma+=1,Ai===null&&(Ai=[]),e=R0(Ai,e,r),r=Ce,(Ot===null?r.memoizedState:Ot.next)===null&&(r=r.alternate,H.H=r===null||r.memoizedState===null?Ep:Ff),e}function bl(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ra(e);if(e.$$typeof===ie)return Ut(e)}throw Error(i(438,String(e)))}function Rf(e){var r=null,a=Ce.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=Ce.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(r={data:l.data.map(function(f){return f.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=gl(),Ce.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(e),l=0;l<e;l++)a[l]=M;return r.index++,a}function vr(e,r){return typeof r=="function"?r(e):r}function xl(e){var r=_t();return Df(r,Ze,e)}function Df(e,r,a){var l=e.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=a;var f=e.baseQueue,p=l.pending;if(p!==null){if(f!==null){var w=f.next;f.next=p.next,p.next=w}r.baseQueue=f=p,l.pending=null}if(p=e.baseState,f===null)e.memoizedState=p;else{r=f.next;var O=w=null,R=null,G=r,W=!1;do{var se=G.lane&-536870913;if(se!==G.lane?(Be&se)===se:(xr&se)===se){var V=G.revertLane;if(V===0)R!==null&&(R=R.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),se===vi&&(W=!0);else if((xr&V)===V){G=G.next,V===vi&&(W=!0);continue}else se={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},R===null?(O=R=se,w=p):R=R.next=se,Ce.lanes|=V,rs|=V;se=G.action,Fs&&a(p,se),p=G.hasEagerState?G.eagerState:a(p,se)}else V={lane:se,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},R===null?(O=R=V,w=p):R=R.next=V,Ce.lanes|=se,rs|=se;G=G.next}while(G!==null&&G!==r);if(R===null?w=p:R.next=O,!ln(p,e.memoizedState)&&(At=!0,W&&(a=_i,a!==null)))throw a;e.memoizedState=p,e.baseState=w,e.baseQueue=R,l.lastRenderedState=p}return f===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function qf(e){var r=_t(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=a.dispatch,f=a.pending,p=r.memoizedState;if(f!==null){a.pending=null;var w=f=f.next;do p=e(p,w.action),w=w.next;while(w!==f);ln(p,r.memoizedState)||(At=!0),r.memoizedState=p,r.baseQueue===null&&(r.baseState=p),a.lastRenderedState=p}return[p,l]}function F0(e,r,a){var l=Ce,f=_t(),p=Ie;if(p){if(a===void 0)throw Error(i(407));a=a()}else a=r();var w=!ln((Ze||f).memoizedState,a);if(w&&(f.memoizedState=a,At=!0),f=f.queue,Pf(Y0.bind(null,l,f,e),[e]),f.getSnapshot!==r||w||Ot!==null&&Ot.memoizedState.tag&1){if(l.flags|=2048,ji(9,{destroy:void 0},V0.bind(null,l,f,a,r),null),rt===null)throw Error(i(349));p||(xr&127)!==0||G0(l,r,a)}return a}function G0(e,r,a){e.flags|=16384,e={getSnapshot:r,value:a},r=Ce.updateQueue,r===null?(r=gl(),Ce.updateQueue=r,r.stores=[e]):(a=r.stores,a===null?r.stores=[e]:a.push(e))}function V0(e,r,a,l){r.value=a,r.getSnapshot=l,K0(r)&&J0(e)}function Y0(e,r,a){return a(function(){K0(r)&&J0(e)})}function K0(e){var r=e.getSnapshot;e=e.value;try{var a=r();return!ln(e,a)}catch{return!0}}function J0(e){var r=qs(e,2);r!==null&&rn(r,e,2)}function Lf(e){var r=Gt();if(typeof e=="function"){var a=e;if(e=a(),Fs){an(!0);try{a()}finally{an(!1)}}}return r.memoizedState=r.baseState=e,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:e},r}function Q0(e,r,a,l){return e.baseState=a,Df(e,Ze,typeof l=="function"?l:vr)}function z_(e,r,a,l,f){if(wl(e))throw Error(i(485));if(e=r.action,e!==null){var p={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){p.listeners.push(w)}};H.T!==null?a(!0):p.isTransition=!1,l(p),a=r.pending,a===null?(p.next=r.pending=p,X0(r,p)):(p.next=a.next,r.pending=a.next=p)}}function X0(e,r){var a=r.action,l=r.payload,f=e.state;if(r.isTransition){var p=H.T,w={};H.T=w;try{var O=a(f,l),R=H.S;R!==null&&R(w,O),W0(e,r,O)}catch(G){Bf(e,r,G)}finally{p!==null&&w.types!==null&&(p.types=w.types),H.T=p}}else try{p=a(f,l),W0(e,r,p)}catch(G){Bf(e,r,G)}}function W0(e,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Z0(e,r,l)},function(l){return Bf(e,r,l)}):Z0(e,r,a)}function Z0(e,r,a){r.status="fulfilled",r.value=a,ep(r),e.state=a,r=e.pending,r!==null&&(a=r.next,a===r?e.pending=null:(a=a.next,r.next=a,X0(e,a)))}function Bf(e,r,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,ep(r),r=r.next;while(r!==l)}e.action=null}function ep(e){e=e.listeners;for(var r=0;r<e.length;r++)(0,e[r])()}function tp(e,r){return r}function np(e,r){if(Ie){var a=rt.formState;if(a!==null){e:{var l=Ce;if(Ie){if(at){t:{for(var f=at,p=Dn;f.nodeType!==8;){if(!p){f=null;break t}if(f=Ln(f.nextSibling),f===null){f=null;break t}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){at=Ln(f.nextSibling),l=f.data==="F!";break e}}Kr(l)}l=!1}l&&(r=a[0])}}return a=Gt(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tp,lastRenderedState:r},a.queue=l,a=_p.bind(null,Ce,l),l.dispatch=a,l=Lf(!1),p=Hf.bind(null,Ce,!1,l.queue),l=Gt(),f={state:r,dispatch:null,action:e,pending:null},l.queue=f,a=z_.bind(null,Ce,f,p,a),f.dispatch=a,l.memoizedState=e,[r,a,!1]}function rp(e){var r=_t();return sp(r,Ze,e)}function sp(e,r,a){if(r=Df(e,r,tp)[0],e=xl(vr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=Ra(r)}catch(w){throw w===wi?cl:w}else l=r;r=_t();var f=r.queue,p=f.dispatch;return a!==r.memoizedState&&(Ce.flags|=2048,ji(9,{destroy:void 0},I_.bind(null,f,a),null)),[l,p,e]}function I_(e,r){e.action=r}function ip(e){var r=_t(),a=Ze;if(a!==null)return sp(r,a,e);_t(),r=r.memoizedState,a=_t();var l=a.queue.dispatch;return a.memoizedState=e,[r,l,!1]}function ji(e,r,a,l){return e={tag:e,create:a,deps:l,inst:r,next:null},r=Ce.updateQueue,r===null&&(r=gl(),Ce.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,r.lastEffect=e),e}function ap(){return _t().memoizedState}function vl(e,r,a,l){var f=Gt();Ce.flags|=e,f.memoizedState=ji(1|r,{destroy:void 0},a,l===void 0?null:l)}function _l(e,r,a,l){var f=_t();l=l===void 0?null:l;var p=f.memoizedState.inst;Ze!==null&&l!==null&&kf(l,Ze.memoizedState.deps)?f.memoizedState=ji(r,p,a,l):(Ce.flags|=e,f.memoizedState=ji(1|r,p,a,l))}function op(e,r){vl(8390656,8,e,r)}function Pf(e,r){_l(2048,8,e,r)}function $_(e){Ce.flags|=4;var r=Ce.updateQueue;if(r===null)r=gl(),Ce.updateQueue=r,r.events=[e];else{var a=r.events;a===null?r.events=[e]:a.push(e)}}function lp(e){var r=_t().memoizedState;return $_({ref:r,nextImpl:e}),function(){if((Ke&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function cp(e,r){return _l(4,2,e,r)}function up(e,r){return _l(4,4,e,r)}function fp(e,r){if(typeof r=="function"){e=e();var a=r(e);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function hp(e,r,a){a=a!=null?a.concat([e]):null,_l(4,4,fp.bind(null,r,e),a)}function Uf(){}function dp(e,r){var a=_t();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&kf(r,l[1])?l[0]:(a.memoizedState=[e,r],e)}function mp(e,r){var a=_t();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&kf(r,l[1]))return l[0];if(l=e(),Fs){an(!0);try{e()}finally{an(!1)}}return a.memoizedState=[l,r],l}function zf(e,r,a){return a===void 0||(xr&1073741824)!==0&&(Be&261930)===0?e.memoizedState=r:(e.memoizedState=a,e=py(),Ce.lanes|=e,rs|=e,a)}function pp(e,r,a,l){return ln(a,r)?a:Ei.current!==null?(e=zf(e,a,l),ln(e,r)||(At=!0),e):(xr&42)===0||(xr&1073741824)!==0&&(Be&261930)===0?(At=!0,e.memoizedState=a):(e=py(),Ce.lanes|=e,rs|=e,r)}function yp(e,r,a,l,f){var p=Z.p;Z.p=p!==0&&8>p?p:8;var w=H.T,O={};H.T=O,Hf(e,!1,r,a);try{var R=f(),G=H.S;if(G!==null&&G(O,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var W=B_(R,l);Da(e,r,W,mn(e))}else Da(e,r,l,mn(e))}catch(se){Da(e,r,{then:function(){},status:"rejected",reason:se},mn())}finally{Z.p=p,w!==null&&O.types!==null&&(w.types=O.types),H.T=w}}function H_(){}function If(e,r,a,l){if(e.tag!==5)throw Error(i(476));var f=gp(e).queue;yp(e,f,r,le,a===null?H_:function(){return bp(e),a(l)})}function gp(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:le},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function bp(e){var r=gp(e);r.next===null&&(r=e.alternate.memoizedState),Da(e,r.next.queue,{},mn())}function $f(){return Ut(Xa)}function xp(){return _t().memoizedState}function vp(){return _t().memoizedState}function F_(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var a=mn();e=Xr(a);var l=Wr(r,e,a);l!==null&&(rn(l,r,a),Na(l,r,a)),r={cache:gf()},e.payload=r;return}r=r.return}}function G_(e,r,a){var l=mn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},wl(e)?wp(r,a):(a=af(e,r,a,l),a!==null&&(rn(a,e,l),Sp(a,r,l)))}function _p(e,r,a){var l=mn();Da(e,r,a,l)}function Da(e,r,a,l){var f={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(wl(e))wp(r,f);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=r.lastRenderedReducer,p!==null))try{var w=r.lastRenderedState,O=p(w,a);if(f.hasEagerState=!0,f.eagerState=O,ln(O,w))return nl(e,r,f,0),rt===null&&tl(),!1}catch{}finally{}if(a=af(e,r,f,l),a!==null)return rn(a,e,l),Sp(a,r,l),!0}return!1}function Hf(e,r,a,l){if(l={lane:2,revertLane:_h(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wl(e)){if(r)throw Error(i(479))}else r=af(e,a,l,2),r!==null&&rn(r,e,2)}function wl(e){var r=e.alternate;return e===Ce||r!==null&&r===Ce}function wp(e,r){Oi=pl=!0;var a=e.pending;a===null?r.next=r:(r.next=a.next,a.next=r),e.pending=r}function Sp(e,r,a){if((a&4194048)!==0){var l=r.lanes;l&=e.pendingLanes,a|=l,r.lanes=a,Ns(e,a)}}var qa={readContext:Ut,use:bl,useCallback:mt,useContext:mt,useEffect:mt,useImperativeHandle:mt,useLayoutEffect:mt,useInsertionEffect:mt,useMemo:mt,useReducer:mt,useRef:mt,useState:mt,useDebugValue:mt,useDeferredValue:mt,useTransition:mt,useSyncExternalStore:mt,useId:mt,useHostTransitionStatus:mt,useFormState:mt,useActionState:mt,useOptimistic:mt,useMemoCache:mt,useCacheRefresh:mt};qa.useEffectEvent=mt;var Ep={readContext:Ut,use:bl,useCallback:function(e,r){return Gt().memoizedState=[e,r===void 0?null:r],e},useContext:Ut,useEffect:op,useImperativeHandle:function(e,r,a){a=a!=null?a.concat([e]):null,vl(4194308,4,fp.bind(null,r,e),a)},useLayoutEffect:function(e,r){return vl(4194308,4,e,r)},useInsertionEffect:function(e,r){vl(4,2,e,r)},useMemo:function(e,r){var a=Gt();r=r===void 0?null:r;var l=e();if(Fs){an(!0);try{e()}finally{an(!1)}}return a.memoizedState=[l,r],l},useReducer:function(e,r,a){var l=Gt();if(a!==void 0){var f=a(r);if(Fs){an(!0);try{a(r)}finally{an(!1)}}}else f=r;return l.memoizedState=l.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},l.queue=e,e=e.dispatch=G_.bind(null,Ce,e),[l.memoizedState,e]},useRef:function(e){var r=Gt();return e={current:e},r.memoizedState=e},useState:function(e){e=Lf(e);var r=e.queue,a=_p.bind(null,Ce,r);return r.dispatch=a,[e.memoizedState,a]},useDebugValue:Uf,useDeferredValue:function(e,r){var a=Gt();return zf(a,e,r)},useTransition:function(){var e=Lf(!1);return e=yp.bind(null,Ce,e.queue,!0,!1),Gt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,a){var l=Ce,f=Gt();if(Ie){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),rt===null)throw Error(i(349));(Be&127)!==0||G0(l,r,a)}f.memoizedState=a;var p={value:a,getSnapshot:r};return f.queue=p,op(Y0.bind(null,l,p,e),[e]),l.flags|=2048,ji(9,{destroy:void 0},V0.bind(null,l,p,a,r),null),a},useId:function(){var e=Gt(),r=rt.identifierPrefix;if(Ie){var a=tr,l=er;a=(l&~(1<<32-Ht(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=yl++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=P_++,r="_"+r+"r_"+a.toString(32)+"_";return e.memoizedState=r},useHostTransitionStatus:$f,useFormState:np,useActionState:np,useOptimistic:function(e){var r=Gt();r.memoizedState=r.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Hf.bind(null,Ce,!0,a),a.dispatch=r,[e,r]},useMemoCache:Rf,useCacheRefresh:function(){return Gt().memoizedState=F_.bind(null,Ce)},useEffectEvent:function(e){var r=Gt(),a={impl:e};return r.memoizedState=a,function(){if((Ke&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}},Ff={readContext:Ut,use:bl,useCallback:dp,useContext:Ut,useEffect:Pf,useImperativeHandle:hp,useInsertionEffect:cp,useLayoutEffect:up,useMemo:mp,useReducer:xl,useRef:ap,useState:function(){return xl(vr)},useDebugValue:Uf,useDeferredValue:function(e,r){var a=_t();return pp(a,Ze.memoizedState,e,r)},useTransition:function(){var e=xl(vr)[0],r=_t().memoizedState;return[typeof e=="boolean"?e:Ra(e),r]},useSyncExternalStore:F0,useId:xp,useHostTransitionStatus:$f,useFormState:rp,useActionState:rp,useOptimistic:function(e,r){var a=_t();return Q0(a,Ze,e,r)},useMemoCache:Rf,useCacheRefresh:vp};Ff.useEffectEvent=lp;var Op={readContext:Ut,use:bl,useCallback:dp,useContext:Ut,useEffect:Pf,useImperativeHandle:hp,useInsertionEffect:cp,useLayoutEffect:up,useMemo:mp,useReducer:qf,useRef:ap,useState:function(){return qf(vr)},useDebugValue:Uf,useDeferredValue:function(e,r){var a=_t();return Ze===null?zf(a,e,r):pp(a,Ze.memoizedState,e,r)},useTransition:function(){var e=qf(vr)[0],r=_t().memoizedState;return[typeof e=="boolean"?e:Ra(e),r]},useSyncExternalStore:F0,useId:xp,useHostTransitionStatus:$f,useFormState:ip,useActionState:ip,useOptimistic:function(e,r){var a=_t();return Ze!==null?Q0(a,Ze,e,r):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Rf,useCacheRefresh:vp};Op.useEffectEvent=lp;function Gf(e,r,a,l){r=e.memoizedState,a=a(l,r),a=a==null?r:b({},r,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Vf={enqueueSetState:function(e,r,a){e=e._reactInternals;var l=mn(),f=Xr(l);f.payload=r,a!=null&&(f.callback=a),r=Wr(e,f,l),r!==null&&(rn(r,e,l),Na(r,e,l))},enqueueReplaceState:function(e,r,a){e=e._reactInternals;var l=mn(),f=Xr(l);f.tag=1,f.payload=r,a!=null&&(f.callback=a),r=Wr(e,f,l),r!==null&&(rn(r,e,l),Na(r,e,l))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var a=mn(),l=Xr(a);l.tag=2,r!=null&&(l.callback=r),r=Wr(e,l,a),r!==null&&(rn(r,e,a),Na(r,e,a))}};function Ap(e,r,a,l,f,p,w){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,p,w):r.prototype&&r.prototype.isPureReactComponent?!_a(a,l)||!_a(f,p):!0}function jp(e,r,a,l){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,l),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,l),r.state!==e&&Vf.enqueueReplaceState(r,r.state,null)}function Gs(e,r){var a=r;if("ref"in r){a={};for(var l in r)l!=="ref"&&(a[l]=r[l])}if(e=e.defaultProps){a===r&&(a=b({},a));for(var f in e)a[f]===void 0&&(a[f]=e[f])}return a}function kp(e){el(e)}function Np(e){console.error(e)}function Tp(e){el(e)}function Sl(e,r){try{var a=e.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function Cp(e,r,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Yf(e,r,a){return a=Xr(a),a.tag=3,a.payload={element:null},a.callback=function(){Sl(e,r)},a}function Mp(e){return e=Xr(e),e.tag=3,e}function Rp(e,r,a,l){var f=a.type.getDerivedStateFromError;if(typeof f=="function"){var p=l.value;e.payload=function(){return f(p)},e.callback=function(){Cp(r,a,l)}}var w=a.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(e.callback=function(){Cp(r,a,l),typeof f!="function"&&(ss===null?ss=new Set([this]):ss.add(this));var O=l.stack;this.componentDidCatch(l.value,{componentStack:O!==null?O:""})})}function V_(e,r,a,l,f){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&xi(r,a,f,!0),a=un.current,a!==null){switch(a.tag){case 31:case 13:return qn===null?ql():a.alternate===null&&pt===0&&(pt=3),a.flags&=-257,a.flags|=65536,a.lanes=f,l===ul?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),bh(e,l,f)),!1;case 22:return a.flags|=65536,l===ul?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([l]):a.add(l)),bh(e,l,f)),!1}throw Error(i(435,a.tag))}return bh(e,l,f),ql(),!1}if(Ie)return r=un.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=f,l!==hf&&(e=Error(i(422),{cause:l}),Ea(Cn(e,a)))):(l!==hf&&(r=Error(i(423),{cause:l}),Ea(Cn(r,a))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,l=Cn(l,a),f=Yf(e.stateNode,l,f),Sf(e,f),pt!==4&&(pt=2)),!1;var p=Error(i(520),{cause:l});if(p=Cn(p,a),Ha===null?Ha=[p]:Ha.push(p),pt!==4&&(pt=2),r===null)return!0;l=Cn(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,e=f&-f,a.lanes|=e,e=Yf(a.stateNode,l,e),Sf(a,e),!1;case 1:if(r=a.type,p=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(ss===null||!ss.has(p))))return a.flags|=65536,f&=-f,a.lanes|=f,f=Mp(f),Rp(f,e,a,l),Sf(a,f),!1}a=a.return}while(a!==null);return!1}var Kf=Error(i(461)),At=!1;function zt(e,r,a,l){r.child=e===null?B0(r,null,a,l):Hs(r,e.child,a,l)}function Dp(e,r,a,l,f){a=a.render;var p=r.ref;if("ref"in l){var w={};for(var O in l)O!=="ref"&&(w[O]=l[O])}else w=l;return Us(r),l=Nf(e,r,a,w,p,f),O=Tf(),e!==null&&!At?(Cf(e,r,f),_r(e,r,f)):(Ie&&O&&uf(r),r.flags|=1,zt(e,r,l,f),r.child)}function qp(e,r,a,l,f){if(e===null){var p=a.type;return typeof p=="function"&&!of(p)&&p.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=p,Lp(e,r,p,l,f)):(e=sl(a.type,null,l,r,r.mode,f),e.ref=r.ref,e.return=r,r.child=e)}if(p=e.child,!nh(e,f)){var w=p.memoizedProps;if(a=a.compare,a=a!==null?a:_a,a(w,l)&&e.ref===r.ref)return _r(e,r,f)}return r.flags|=1,e=pr(p,l),e.ref=r.ref,e.return=r,r.child=e}function Lp(e,r,a,l,f){if(e!==null){var p=e.memoizedProps;if(_a(p,l)&&e.ref===r.ref)if(At=!1,r.pendingProps=l=p,nh(e,f))(e.flags&131072)!==0&&(At=!0);else return r.lanes=e.lanes,_r(e,r,f)}return Jf(e,r,a,l,f)}function Bp(e,r,a,l){var f=l.children,p=e!==null?e.memoizedState:null;if(e===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((r.flags&128)!==0){if(p=p!==null?p.baseLanes|a:a,e!==null){for(l=r.child=e.child,f=0;l!==null;)f=f|l.lanes|l.childLanes,l=l.sibling;l=f&~p}else l=0,r.child=null;return Pp(e,r,p,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},e!==null&&ll(r,p!==null?p.cachePool:null),p!==null?z0(r,p):Of(),I0(r);else return l=r.lanes=536870912,Pp(e,r,p!==null?p.baseLanes|a:a,a,l)}else p!==null?(ll(r,p.cachePool),z0(r,p),es(),r.memoizedState=null):(e!==null&&ll(r,null),Of(),es());return zt(e,r,f,a),r.child}function La(e,r){return e!==null&&e.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Pp(e,r,a,l,f){var p=xf();return p=p===null?null:{parent:Et._currentValue,pool:p},r.memoizedState={baseLanes:a,cachePool:p},e!==null&&ll(r,null),Of(),I0(r),e!==null&&xi(e,r,l,!0),r.childLanes=f,null}function El(e,r){return r=Al({mode:r.mode,children:r.children},e.mode),r.ref=e.ref,e.child=r,r.return=e,r}function Up(e,r,a){return Hs(r,e.child,null,a),e=El(r,r.pendingProps),e.flags|=2,fn(r),r.memoizedState=null,e}function Y_(e,r,a){var l=r.pendingProps,f=(r.flags&128)!==0;if(r.flags&=-129,e===null){if(Ie){if(l.mode==="hidden")return e=El(r,l),r.lanes=536870912,La(null,e);if(jf(r),(e=at)?(e=Xy(e,Dn),e=e!==null&&e.data==="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Vr!==null?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},a=w0(e),a.return=r,r.child=a,Pt=r,at=null)):e=null,e===null)throw Kr(r);return r.lanes=536870912,null}return El(r,l)}var p=e.memoizedState;if(p!==null){var w=p.dehydrated;if(jf(r),f)if(r.flags&256)r.flags&=-257,r=Up(e,r,a);else if(r.memoizedState!==null)r.child=e.child,r.flags|=128,r=null;else throw Error(i(558));else if(At||xi(e,r,a,!1),f=(a&e.childLanes)!==0,At||f){if(l=rt,l!==null&&(w=Fr(l,a),w!==0&&w!==p.retryLane))throw p.retryLane=w,qs(e,w),rn(l,e,w),Kf;ql(),r=Up(e,r,a)}else e=p.treeContext,at=Ln(w.nextSibling),Pt=r,Ie=!0,Yr=null,Dn=!1,e!==null&&O0(r,e),r=El(r,l),r.flags|=4096;return r}return e=pr(e.child,{mode:l.mode,children:l.children}),e.ref=r.ref,r.child=e,e.return=r,e}function Ol(e,r){var a=r.ref;if(a===null)e!==null&&e.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(i(284));(e===null||e.ref!==a)&&(r.flags|=4194816)}}function Jf(e,r,a,l,f){return Us(r),a=Nf(e,r,a,l,void 0,f),l=Tf(),e!==null&&!At?(Cf(e,r,f),_r(e,r,f)):(Ie&&l&&uf(r),r.flags|=1,zt(e,r,a,f),r.child)}function zp(e,r,a,l,f,p){return Us(r),r.updateQueue=null,a=H0(r,l,a,f),$0(e),l=Tf(),e!==null&&!At?(Cf(e,r,p),_r(e,r,p)):(Ie&&l&&uf(r),r.flags|=1,zt(e,r,a,p),r.child)}function Ip(e,r,a,l,f){if(Us(r),r.stateNode===null){var p=pi,w=a.contextType;typeof w=="object"&&w!==null&&(p=Ut(w)),p=new a(l,p),r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Vf,r.stateNode=p,p._reactInternals=r,p=r.stateNode,p.props=l,p.state=r.memoizedState,p.refs={},_f(r),w=a.contextType,p.context=typeof w=="object"&&w!==null?Ut(w):pi,p.state=r.memoizedState,w=a.getDerivedStateFromProps,typeof w=="function"&&(Gf(r,a,w,l),p.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(w=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),w!==p.state&&Vf.enqueueReplaceState(p,p.state,null),Ca(r,l,p,f),Ta(),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308),l=!0}else if(e===null){p=r.stateNode;var O=r.memoizedProps,R=Gs(a,O);p.props=R;var G=p.context,W=a.contextType;w=pi,typeof W=="object"&&W!==null&&(w=Ut(W));var se=a.getDerivedStateFromProps;W=typeof se=="function"||typeof p.getSnapshotBeforeUpdate=="function",O=r.pendingProps!==O,W||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(O||G!==w)&&jp(r,p,l,w),Qr=!1;var V=r.memoizedState;p.state=V,Ca(r,l,p,f),Ta(),G=r.memoizedState,O||V!==G||Qr?(typeof se=="function"&&(Gf(r,a,se,l),G=r.memoizedState),(R=Qr||Ap(r,a,R,l,V,G,w))?(W||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(r.flags|=4194308)):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=l,r.memoizedState=G),p.props=l,p.state=G,p.context=w,l=R):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{p=r.stateNode,wf(e,r),w=r.memoizedProps,W=Gs(a,w),p.props=W,se=r.pendingProps,V=p.context,G=a.contextType,R=pi,typeof G=="object"&&G!==null&&(R=Ut(G)),O=a.getDerivedStateFromProps,(G=typeof O=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(w!==se||V!==R)&&jp(r,p,l,R),Qr=!1,V=r.memoizedState,p.state=V,Ca(r,l,p,f),Ta();var X=r.memoizedState;w!==se||V!==X||Qr||e!==null&&e.dependencies!==null&&al(e.dependencies)?(typeof O=="function"&&(Gf(r,a,O,l),X=r.memoizedState),(W=Qr||Ap(r,a,W,l,V,X,R)||e!==null&&e.dependencies!==null&&al(e.dependencies))?(G||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(l,X,R),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(l,X,R)),typeof p.componentDidUpdate=="function"&&(r.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof p.componentDidUpdate!="function"||w===e.memoizedProps&&V===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&V===e.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=X),p.props=l,p.state=X,p.context=R,l=W):(typeof p.componentDidUpdate!="function"||w===e.memoizedProps&&V===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||w===e.memoizedProps&&V===e.memoizedState||(r.flags|=1024),l=!1)}return p=l,Ol(e,r),l=(r.flags&128)!==0,p||l?(p=r.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:p.render(),r.flags|=1,e!==null&&l?(r.child=Hs(r,e.child,null,f),r.child=Hs(r,null,a,f)):zt(e,r,a,f),r.memoizedState=p.state,e=r.child):e=_r(e,r,f),e}function $p(e,r,a,l){return Bs(),r.flags|=256,zt(e,r,a,l),r.child}var Qf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Xf(e){return{baseLanes:e,cachePool:C0()}}function Wf(e,r,a){return e=e!==null?e.childLanes&~a:0,r&&(e|=dn),e}function Hp(e,r,a){var l=r.pendingProps,f=!1,p=(r.flags&128)!==0,w;if((w=p)||(w=e!==null&&e.memoizedState===null?!1:(vt.current&2)!==0),w&&(f=!0,r.flags&=-129),w=(r.flags&32)!==0,r.flags&=-33,e===null){if(Ie){if(f?Zr(r):es(),(e=at)?(e=Xy(e,Dn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Vr!==null?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},a=w0(e),a.return=r,r.child=a,Pt=r,at=null)):e=null,e===null)throw Kr(r);return Dh(e)?r.lanes=32:r.lanes=536870912,null}var O=l.children;return l=l.fallback,f?(es(),f=r.mode,O=Al({mode:"hidden",children:O},f),l=Ls(l,f,a,null),O.return=r,l.return=r,O.sibling=l,r.child=O,l=r.child,l.memoizedState=Xf(a),l.childLanes=Wf(e,w,a),r.memoizedState=Qf,La(null,l)):(Zr(r),Zf(r,O))}var R=e.memoizedState;if(R!==null&&(O=R.dehydrated,O!==null)){if(p)r.flags&256?(Zr(r),r.flags&=-257,r=eh(e,r,a)):r.memoizedState!==null?(es(),r.child=e.child,r.flags|=128,r=null):(es(),O=l.fallback,f=r.mode,l=Al({mode:"visible",children:l.children},f),O=Ls(O,f,a,null),O.flags|=2,l.return=r,O.return=r,l.sibling=O,r.child=l,Hs(r,e.child,null,a),l=r.child,l.memoizedState=Xf(a),l.childLanes=Wf(e,w,a),r.memoizedState=Qf,r=La(null,l));else if(Zr(r),Dh(O)){if(w=O.nextSibling&&O.nextSibling.dataset,w)var G=w.dgst;w=G,l=Error(i(419)),l.stack="",l.digest=w,Ea({value:l,source:null,stack:null}),r=eh(e,r,a)}else if(At||xi(e,r,a,!1),w=(a&e.childLanes)!==0,At||w){if(w=rt,w!==null&&(l=Fr(w,a),l!==0&&l!==R.retryLane))throw R.retryLane=l,qs(e,l),rn(w,e,l),Kf;Rh(O)||ql(),r=eh(e,r,a)}else Rh(O)?(r.flags|=192,r.child=e.child,r=null):(e=R.treeContext,at=Ln(O.nextSibling),Pt=r,Ie=!0,Yr=null,Dn=!1,e!==null&&O0(r,e),r=Zf(r,l.children),r.flags|=4096);return r}return f?(es(),O=l.fallback,f=r.mode,R=e.child,G=R.sibling,l=pr(R,{mode:"hidden",children:l.children}),l.subtreeFlags=R.subtreeFlags&65011712,G!==null?O=pr(G,O):(O=Ls(O,f,a,null),O.flags|=2),O.return=r,l.return=r,l.sibling=O,r.child=l,La(null,l),l=r.child,O=e.child.memoizedState,O===null?O=Xf(a):(f=O.cachePool,f!==null?(R=Et._currentValue,f=f.parent!==R?{parent:R,pool:R}:f):f=C0(),O={baseLanes:O.baseLanes|a,cachePool:f}),l.memoizedState=O,l.childLanes=Wf(e,w,a),r.memoizedState=Qf,La(e.child,l)):(Zr(r),a=e.child,e=a.sibling,a=pr(a,{mode:"visible",children:l.children}),a.return=r,a.sibling=null,e!==null&&(w=r.deletions,w===null?(r.deletions=[e],r.flags|=16):w.push(e)),r.child=a,r.memoizedState=null,a)}function Zf(e,r){return r=Al({mode:"visible",children:r},e.mode),r.return=e,e.child=r}function Al(e,r){return e=cn(22,e,null,r),e.lanes=0,e}function eh(e,r,a){return Hs(r,e.child,null,a),e=Zf(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Fp(e,r,a){e.lanes|=r;var l=e.alternate;l!==null&&(l.lanes|=r),pf(e.return,r,a)}function th(e,r,a,l,f,p){var w=e.memoizedState;w===null?e.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:f,treeForkCount:p}:(w.isBackwards=r,w.rendering=null,w.renderingStartTime=0,w.last=l,w.tail=a,w.tailMode=f,w.treeForkCount=p)}function Gp(e,r,a){var l=r.pendingProps,f=l.revealOrder,p=l.tail;l=l.children;var w=vt.current,O=(w&2)!==0;if(O?(w=w&1|2,r.flags|=128):w&=1,Te(vt,w),zt(e,r,l,a),l=Ie?Sa:0,!O&&e!==null&&(e.flags&128)!==0)e:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Fp(e,a,r);else if(e.tag===19)Fp(e,a,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break e;for(;e.sibling===null;){if(e.return===null||e.return===r)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(a=r.child,f=null;a!==null;)e=a.alternate,e!==null&&ml(e)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),th(r,!1,f,a,p,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(e=f.alternate,e!==null&&ml(e)===null){r.child=f;break}e=f.sibling,f.sibling=a,a=f,f=e}th(r,!0,a,null,p,l);break;case"together":th(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function _r(e,r,a){if(e!==null&&(r.dependencies=e.dependencies),rs|=r.lanes,(a&r.childLanes)===0)if(e!==null){if(xi(e,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(e!==null&&r.child!==e.child)throw Error(i(153));if(r.child!==null){for(e=r.child,a=pr(e,e.pendingProps),r.child=a,a.return=r;e.sibling!==null;)e=e.sibling,a=a.sibling=pr(e,e.pendingProps),a.return=r;a.sibling=null}return r.child}function nh(e,r){return(e.lanes&r)!==0?!0:(e=e.dependencies,!!(e!==null&&al(e)))}function K_(e,r,a){switch(r.tag){case 3:bt(r,r.stateNode.containerInfo),Jr(r,Et,e.memoizedState.cache),Bs();break;case 27:case 5:Je(r);break;case 4:bt(r,r.stateNode.containerInfo);break;case 10:Jr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,jf(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(Zr(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Hp(e,r,a):(Zr(r),e=_r(e,r,a),e!==null?e.sibling:null);Zr(r);break;case 19:var f=(e.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(xi(e,r,a,!1),l=(a&r.childLanes)!==0),f){if(l)return Gp(e,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Te(vt,vt.current),l)break;return null;case 22:return r.lanes=0,Bp(e,r,a,r.pendingProps);case 24:Jr(r,Et,e.memoizedState.cache)}return _r(e,r,a)}function Vp(e,r,a){if(e!==null)if(e.memoizedProps!==r.pendingProps)At=!0;else{if(!nh(e,a)&&(r.flags&128)===0)return At=!1,K_(e,r,a);At=(e.flags&131072)!==0}else At=!1,Ie&&(r.flags&1048576)!==0&&E0(r,Sa,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(e=Is(r.elementType),r.type=e,typeof e=="function")of(e)?(l=Gs(e,l),r.tag=1,r=Ip(null,r,e,l,a)):(r.tag=0,r=Jf(null,r,e,l,a));else{if(e!=null){var f=e.$$typeof;if(f===oe){r.tag=11,r=Dp(null,r,e,l,a);break e}else if(f===ee){r.tag=14,r=qp(null,r,e,l,a);break e}}throw r=be(e)||e,Error(i(306,r,""))}}return r;case 0:return Jf(e,r,r.type,r.pendingProps,a);case 1:return l=r.type,f=Gs(l,r.pendingProps),Ip(e,r,l,f,a);case 3:e:{if(bt(r,r.stateNode.containerInfo),e===null)throw Error(i(387));l=r.pendingProps;var p=r.memoizedState;f=p.element,wf(e,r),Ca(r,l,null,a);var w=r.memoizedState;if(l=w.cache,Jr(r,Et,l),l!==p.cache&&yf(r,[Et],a,!0),Ta(),l=w.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:w.cache},r.updateQueue.baseState=p,r.memoizedState=p,r.flags&256){r=$p(e,r,l,a);break e}else if(l!==f){f=Cn(Error(i(424)),r),Ea(f),r=$p(e,r,l,a);break e}else{switch(e=r.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(at=Ln(e.firstChild),Pt=r,Ie=!0,Yr=null,Dn=!0,a=B0(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Bs(),l===f){r=_r(e,r,a);break e}zt(e,r,l,a)}r=r.child}return r;case 26:return Ol(e,r),e===null?(a=rg(r.type,null,r.pendingProps,null))?r.memoizedState=a:Ie||(a=r.type,e=r.pendingProps,l=$l(Bt.current).createElement(a),l[nt]=r,l[dt]=e,It(l,a,e),q(l),r.stateNode=l):r.memoizedState=rg(r.type,e.memoizedProps,r.pendingProps,e.memoizedState),null;case 27:return Je(r),e===null&&Ie&&(l=r.stateNode=eg(r.type,r.pendingProps,Bt.current),Pt=r,Dn=!0,f=at,ls(r.type)?(qh=f,at=Ln(l.firstChild)):at=f),zt(e,r,r.pendingProps.children,a),Ol(e,r),e===null&&(r.flags|=4194304),r.child;case 5:return e===null&&Ie&&((f=l=at)&&(l=Ew(l,r.type,r.pendingProps,Dn),l!==null?(r.stateNode=l,Pt=r,at=Ln(l.firstChild),Dn=!1,f=!0):f=!1),f||Kr(r)),Je(r),f=r.type,p=r.pendingProps,w=e!==null?e.memoizedProps:null,l=p.children,Th(f,p)?l=null:w!==null&&Th(f,w)&&(r.flags|=32),r.memoizedState!==null&&(f=Nf(e,r,U_,null,null,a),Xa._currentValue=f),Ol(e,r),zt(e,r,l,a),r.child;case 6:return e===null&&Ie&&((e=a=at)&&(a=Ow(a,r.pendingProps,Dn),a!==null?(r.stateNode=a,Pt=r,at=null,e=!0):e=!1),e||Kr(r)),null;case 13:return Hp(e,r,a);case 4:return bt(r,r.stateNode.containerInfo),l=r.pendingProps,e===null?r.child=Hs(r,null,l,a):zt(e,r,l,a),r.child;case 11:return Dp(e,r,r.type,r.pendingProps,a);case 7:return zt(e,r,r.pendingProps,a),r.child;case 8:return zt(e,r,r.pendingProps.children,a),r.child;case 12:return zt(e,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,Jr(r,r.type,l.value),zt(e,r,l.children,a),r.child;case 9:return f=r.type._context,l=r.pendingProps.children,Us(r),f=Ut(f),l=l(f),r.flags|=1,zt(e,r,l,a),r.child;case 14:return qp(e,r,r.type,r.pendingProps,a);case 15:return Lp(e,r,r.type,r.pendingProps,a);case 19:return Gp(e,r,a);case 31:return Y_(e,r,a);case 22:return Bp(e,r,a,r.pendingProps);case 24:return Us(r),l=Ut(Et),e===null?(f=xf(),f===null&&(f=rt,p=gf(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=a),f=p),r.memoizedState={parent:l,cache:f},_f(r),Jr(r,Et,f)):((e.lanes&a)!==0&&(wf(e,r),Ca(r,null,null,a),Ta()),f=e.memoizedState,p=r.memoizedState,f.parent!==l?(f={parent:l,cache:l},r.memoizedState=f,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=f),Jr(r,Et,l)):(l=p.cache,Jr(r,Et,l),l!==f.cache&&yf(r,[Et],a,!0))),zt(e,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function wr(e){e.flags|=4}function rh(e,r,a,l,f){if((r=(e.mode&32)!==0)&&(r=!1),r){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(xy())e.flags|=8192;else throw $s=ul,vf}else e.flags&=-16777217}function Yp(e,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!lg(r))if(xy())e.flags|=8192;else throw $s=ul,vf}function jl(e,r){r!==null&&(e.flags|=4),e.flags&16384&&(r=e.tag!==22?ii():536870912,e.lanes|=r,Ci|=r)}function Ba(e,r){if(!Ie)switch(e.tailMode){case"hidden":r=e.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function ot(e){var r=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(r)for(var f=e.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags&65011712,l|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=a,r}function J_(e,r,a){var l=r.pendingProps;switch(ff(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ot(r),null;case 1:return ot(r),null;case 3:return a=r.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),br(Et),ue(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(bi(r)?wr(r):e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,df())),ot(r),null;case 26:var f=r.type,p=r.memoizedState;return e===null?(wr(r),p!==null?(ot(r),Yp(r,p)):(ot(r),rh(r,f,null,l,a))):p?p!==e.memoizedState?(wr(r),ot(r),Yp(r,p)):(ot(r),r.flags&=-16777217):(e=e.memoizedProps,e!==l&&wr(r),ot(r),rh(r,f,e,l,a)),null;case 27:if(jn(r),a=Bt.current,f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ot(r),null}e=st.current,bi(r)?A0(r):(e=eg(f,l,a),r.stateNode=e,wr(r))}return ot(r),null;case 5:if(jn(r),f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ot(r),null}if(p=st.current,bi(r))A0(r);else{var w=$l(Bt.current);switch(p){case 1:p=w.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:p=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":p=w.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":p=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":p=w.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof l.is=="string"?w.createElement("select",{is:l.is}):w.createElement("select"),l.multiple?p.multiple=!0:l.size&&(p.size=l.size);break;default:p=typeof l.is=="string"?w.createElement(f,{is:l.is}):w.createElement(f)}}p[nt]=r,p[dt]=l;e:for(w=r.child;w!==null;){if(w.tag===5||w.tag===6)p.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===r)break e;for(;w.sibling===null;){if(w.return===null||w.return===r)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}r.stateNode=p;e:switch(It(p,f,l),f){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&wr(r)}}return ot(r),rh(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,a),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==l&&wr(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(i(166));if(e=Bt.current,bi(r)){if(e=r.stateNode,a=r.memoizedProps,l=null,f=Pt,f!==null)switch(f.tag){case 27:case 5:l=f.memoizedProps}e[nt]=r,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Hy(e.nodeValue,a)),e||Kr(r,!0)}else e=$l(e).createTextNode(l),e[nt]=r,r.stateNode=e}return ot(r),null;case 31:if(a=r.memoizedState,e===null||e.memoizedState!==null){if(l=bi(r),a!==null){if(e===null){if(!l)throw Error(i(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[nt]=r}else Bs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ot(r),e=!1}else a=df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return r.flags&256?(fn(r),r):(fn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ot(r),null;case 13:if(l=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=bi(r),l!==null&&l.dehydrated!==null){if(e===null){if(!f)throw Error(i(318));if(f=r.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[nt]=r}else Bs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ot(r),f=!1}else f=df(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return r.flags&256?(fn(r),r):(fn(r),null)}return fn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=r.child,f=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(f=l.alternate.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==f&&(l.flags|=2048)),a!==e&&a&&(r.child.flags|=8192),jl(r,r.updateQueue),ot(r),null);case 4:return ue(),e===null&&Oh(r.stateNode.containerInfo),ot(r),null;case 10:return br(r.type),ot(r),null;case 19:if(ke(vt),l=r.memoizedState,l===null)return ot(r),null;if(f=(r.flags&128)!==0,p=l.rendering,p===null)if(f)Ba(l,!1);else{if(pt!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(p=ml(e),p!==null){for(r.flags|=128,Ba(l,!1),e=p.updateQueue,r.updateQueue=e,jl(r,e),r.subtreeFlags=0,e=a,a=r.child;a!==null;)_0(a,e),a=a.sibling;return Te(vt,vt.current&1|2),Ie&&yr(r,l.treeForkCount),r.child}e=e.sibling}l.tail!==null&&ct()>Ml&&(r.flags|=128,f=!0,Ba(l,!1),r.lanes=4194304)}else{if(!f)if(e=ml(p),e!==null){if(r.flags|=128,f=!0,e=e.updateQueue,r.updateQueue=e,jl(r,e),Ba(l,!0),l.tail===null&&l.tailMode==="hidden"&&!p.alternate&&!Ie)return ot(r),null}else 2*ct()-l.renderingStartTime>Ml&&a!==536870912&&(r.flags|=128,f=!0,Ba(l,!1),r.lanes=4194304);l.isBackwards?(p.sibling=r.child,r.child=p):(e=l.last,e!==null?e.sibling=p:r.child=p,l.last=p)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=ct(),e.sibling=null,a=vt.current,Te(vt,f?a&1|2:a&1),Ie&&yr(r,l.treeForkCount),e):(ot(r),null);case 22:case 23:return fn(r),Af(),l=r.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(r.flags|=8192):l&&(r.flags|=8192),l?(a&536870912)!==0&&(r.flags&128)===0&&(ot(r),r.subtreeFlags&6&&(r.flags|=8192)):ot(r),a=r.updateQueue,a!==null&&jl(r,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),l!==a&&(r.flags|=2048),e!==null&&ke(zs),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),br(Et),ot(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function Q_(e,r){switch(ff(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return br(Et),ue(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return jn(r),null;case 31:if(r.memoizedState!==null){if(fn(r),r.alternate===null)throw Error(i(340));Bs()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(fn(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Bs()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return ke(vt),null;case 4:return ue(),null;case 10:return br(r.type),null;case 22:case 23:return fn(r),Af(),e!==null&&ke(zs),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return br(Et),null;case 25:return null;default:return null}}function Kp(e,r){switch(ff(r),r.tag){case 3:br(Et),ue();break;case 26:case 27:case 5:jn(r);break;case 4:ue();break;case 31:r.memoizedState!==null&&fn(r);break;case 13:fn(r);break;case 19:ke(vt);break;case 10:br(r.type);break;case 22:case 23:fn(r),Af(),e!==null&&ke(zs);break;case 24:br(Et)}}function Pa(e,r){try{var a=r.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var f=l.next;a=f;do{if((a.tag&e)===e){l=void 0;var p=a.create,w=a.inst;l=p(),w.destroy=l}a=a.next}while(a!==f)}}catch(O){Xe(r,r.return,O)}}function ts(e,r,a){try{var l=r.updateQueue,f=l!==null?l.lastEffect:null;if(f!==null){var p=f.next;l=p;do{if((l.tag&e)===e){var w=l.inst,O=w.destroy;if(O!==void 0){w.destroy=void 0,f=r;var R=a,G=O;try{G()}catch(W){Xe(f,R,W)}}}l=l.next}while(l!==p)}}catch(W){Xe(r,r.return,W)}}function Jp(e){var r=e.updateQueue;if(r!==null){var a=e.stateNode;try{U0(r,a)}catch(l){Xe(e,e.return,l)}}}function Qp(e,r,a){a.props=Gs(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){Xe(e,r,l)}}function Ua(e,r){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(f){Xe(e,r,f)}}function nr(e,r){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(f){Xe(e,r,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(f){Xe(e,r,f)}else a.current=null}function Xp(e){var r=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(f){Xe(e,e.return,f)}}function sh(e,r,a){try{var l=e.stateNode;bw(l,e.type,a,r),l[dt]=r}catch(f){Xe(e,e.return,f)}}function Wp(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ls(e.type)||e.tag===4}function ih(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Wp(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ls(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ah(e,r,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(e),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=dr));else if(l!==4&&(l===27&&ls(e.type)&&(a=e.stateNode,r=null),e=e.child,e!==null))for(ah(e,r,a),e=e.sibling;e!==null;)ah(e,r,a),e=e.sibling}function kl(e,r,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,r?a.insertBefore(e,r):a.appendChild(e);else if(l!==4&&(l===27&&ls(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(kl(e,r,a),e=e.sibling;e!==null;)kl(e,r,a),e=e.sibling}function Zp(e){var r=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,f=r.attributes;f.length;)r.removeAttributeNode(f[0]);It(r,l,a),r[nt]=e,r[dt]=a}catch(p){Xe(e,e.return,p)}}var Sr=!1,jt=!1,oh=!1,ey=typeof WeakSet=="function"?WeakSet:Set,Rt=null;function X_(e,r){if(e=e.containerInfo,kh=Jl,e=h0(e),Zu(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var f=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var w=0,O=-1,R=-1,G=0,W=0,se=e,V=null;t:for(;;){for(var X;se!==a||f!==0&&se.nodeType!==3||(O=w+f),se!==p||l!==0&&se.nodeType!==3||(R=w+l),se.nodeType===3&&(w+=se.nodeValue.length),(X=se.firstChild)!==null;)V=se,se=X;for(;;){if(se===e)break t;if(V===a&&++G===f&&(O=w),V===p&&++W===l&&(R=w),(X=se.nextSibling)!==null)break;se=V,V=se.parentNode}se=X}a=O===-1||R===-1?null:{start:O,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(Nh={focusedElem:e,selectionRange:a},Jl=!1,Rt=r;Rt!==null;)if(r=Rt,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Rt=e;else for(;Rt!==null;){switch(r=Rt,p=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)f=e[a],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&p!==null){e=void 0,a=r,f=p.memoizedProps,p=p.memoizedState,l=a.stateNode;try{var ge=Gs(a.type,f);e=l.getSnapshotBeforeUpdate(ge,p),l.__reactInternalSnapshotBeforeUpdate=e}catch(je){Xe(a,a.return,je)}}break;case 3:if((e&1024)!==0){if(e=r.stateNode.containerInfo,a=e.nodeType,a===9)Mh(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Mh(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(i(163))}if(e=r.sibling,e!==null){e.return=r.return,Rt=e;break}Rt=r.return}}function ty(e,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Or(e,a),l&4&&Pa(5,a);break;case 1:if(Or(e,a),l&4)if(e=a.stateNode,r===null)try{e.componentDidMount()}catch(w){Xe(a,a.return,w)}else{var f=Gs(a.type,r.memoizedProps);r=r.memoizedState;try{e.componentDidUpdate(f,r,e.__reactInternalSnapshotBeforeUpdate)}catch(w){Xe(a,a.return,w)}}l&64&&Jp(a),l&512&&Ua(a,a.return);break;case 3:if(Or(e,a),l&64&&(e=a.updateQueue,e!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{U0(e,r)}catch(w){Xe(a,a.return,w)}}break;case 27:r===null&&l&4&&Zp(a);case 26:case 5:Or(e,a),r===null&&l&4&&Xp(a),l&512&&Ua(a,a.return);break;case 12:Or(e,a);break;case 31:Or(e,a),l&4&&sy(e,a);break;case 13:Or(e,a),l&4&&iy(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=aw.bind(null,a),Aw(e,a))));break;case 22:if(l=a.memoizedState!==null||Sr,!l){r=r!==null&&r.memoizedState!==null||jt,f=Sr;var p=jt;Sr=l,(jt=r)&&!p?Ar(e,a,(a.subtreeFlags&8772)!==0):Or(e,a),Sr=f,jt=p}break;case 30:break;default:Or(e,a)}}function ny(e){var r=e.alternate;r!==null&&(e.alternate=null,ny(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&ai(r)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var ut=null,Zt=!1;function Er(e,r,a){for(a=a.child;a!==null;)ry(e,r,a),a=a.sibling}function ry(e,r,a){if(xt&&typeof xt.onCommitFiberUnmount=="function")try{xt.onCommitFiberUnmount(As,a)}catch{}switch(a.tag){case 26:jt||nr(a,r),Er(e,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:jt||nr(a,r);var l=ut,f=Zt;ls(a.type)&&(ut=a.stateNode,Zt=!1),Er(e,r,a),Ka(a.stateNode),ut=l,Zt=f;break;case 5:jt||nr(a,r);case 6:if(l=ut,f=Zt,ut=null,Er(e,r,a),ut=l,Zt=f,ut!==null)if(Zt)try{(ut.nodeType===9?ut.body:ut.nodeName==="HTML"?ut.ownerDocument.body:ut).removeChild(a.stateNode)}catch(p){Xe(a,r,p)}else try{ut.removeChild(a.stateNode)}catch(p){Xe(a,r,p)}break;case 18:ut!==null&&(Zt?(e=ut,Jy(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Ui(e)):Jy(ut,a.stateNode));break;case 4:l=ut,f=Zt,ut=a.stateNode.containerInfo,Zt=!0,Er(e,r,a),ut=l,Zt=f;break;case 0:case 11:case 14:case 15:ts(2,a,r),jt||ts(4,a,r),Er(e,r,a);break;case 1:jt||(nr(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Qp(a,r,l)),Er(e,r,a);break;case 21:Er(e,r,a);break;case 22:jt=(l=jt)||a.memoizedState!==null,Er(e,r,a),jt=l;break;default:Er(e,r,a)}}function sy(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ui(e)}catch(a){Xe(r,r.return,a)}}}function iy(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ui(e)}catch(a){Xe(r,r.return,a)}}function W_(e){switch(e.tag){case 31:case 13:case 19:var r=e.stateNode;return r===null&&(r=e.stateNode=new ey),r;case 22:return e=e.stateNode,r=e._retryCache,r===null&&(r=e._retryCache=new ey),r;default:throw Error(i(435,e.tag))}}function Nl(e,r){var a=W_(e);r.forEach(function(l){if(!a.has(l)){a.add(l);var f=ow.bind(null,e,l);l.then(f,f)}})}function en(e,r){var a=r.deletions;if(a!==null)for(var l=0;l<a.length;l++){var f=a[l],p=e,w=r,O=w;e:for(;O!==null;){switch(O.tag){case 27:if(ls(O.type)){ut=O.stateNode,Zt=!1;break e}break;case 5:ut=O.stateNode,Zt=!1;break e;case 3:case 4:ut=O.stateNode.containerInfo,Zt=!0;break e}O=O.return}if(ut===null)throw Error(i(160));ry(p,w,f),ut=null,Zt=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)ay(r,e),r=r.sibling}var Gn=null;function ay(e,r){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:en(r,e),tn(e),l&4&&(ts(3,e,e.return),Pa(3,e),ts(5,e,e.return));break;case 1:en(r,e),tn(e),l&512&&(jt||a===null||nr(a,a.return)),l&64&&Sr&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var f=Gn;if(en(r,e),tn(e),l&512&&(jt||a===null||nr(a,a.return)),l&4){var p=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,f=f.ownerDocument||f;t:switch(l){case"title":p=f.getElementsByTagName("title")[0],(!p||p[Tt]||p[nt]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(l),f.head.insertBefore(p,f.querySelector("head > title"))),It(p,l,a),p[nt]=e,q(p),l=p;break e;case"link":var w=ag("link","href",f).get(l+(a.href||""));if(w){for(var O=0;O<w.length;O++)if(p=w[O],p.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&p.getAttribute("rel")===(a.rel==null?null:a.rel)&&p.getAttribute("title")===(a.title==null?null:a.title)&&p.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){w.splice(O,1);break t}}p=f.createElement(l),It(p,l,a),f.head.appendChild(p);break;case"meta":if(w=ag("meta","content",f).get(l+(a.content||""))){for(O=0;O<w.length;O++)if(p=w[O],p.getAttribute("content")===(a.content==null?null:""+a.content)&&p.getAttribute("name")===(a.name==null?null:a.name)&&p.getAttribute("property")===(a.property==null?null:a.property)&&p.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&p.getAttribute("charset")===(a.charSet==null?null:a.charSet)){w.splice(O,1);break t}}p=f.createElement(l),It(p,l,a),f.head.appendChild(p);break;default:throw Error(i(468,l))}p[nt]=e,q(p),l=p}e.stateNode=l}else og(f,e.type,e.stateNode);else e.stateNode=ig(f,l,e.memoizedProps);else p!==l?(p===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):p.count--,l===null?og(f,e.type,e.stateNode):ig(f,l,e.memoizedProps)):l===null&&e.stateNode!==null&&sh(e,e.memoizedProps,a.memoizedProps)}break;case 27:en(r,e),tn(e),l&512&&(jt||a===null||nr(a,a.return)),a!==null&&l&4&&sh(e,e.memoizedProps,a.memoizedProps);break;case 5:if(en(r,e),tn(e),l&512&&(jt||a===null||nr(a,a.return)),e.flags&32){f=e.stateNode;try{li(f,"")}catch(ge){Xe(e,e.return,ge)}}l&4&&e.stateNode!=null&&(f=e.memoizedProps,sh(e,f,a!==null?a.memoizedProps:f)),l&1024&&(oh=!0);break;case 6:if(en(r,e),tn(e),l&4){if(e.stateNode===null)throw Error(i(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(ge){Xe(e,e.return,ge)}}break;case 3:if(Gl=null,f=Gn,Gn=Hl(r.containerInfo),en(r,e),Gn=f,tn(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Ui(r.containerInfo)}catch(ge){Xe(e,e.return,ge)}oh&&(oh=!1,oy(e));break;case 4:l=Gn,Gn=Hl(e.stateNode.containerInfo),en(r,e),tn(e),Gn=l;break;case 12:en(r,e),tn(e);break;case 31:en(r,e),tn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 13:en(r,e),tn(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Cl=ct()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 22:f=e.memoizedState!==null;var R=a!==null&&a.memoizedState!==null,G=Sr,W=jt;if(Sr=G||f,jt=W||R,en(r,e),jt=W,Sr=G,tn(e),l&8192)e:for(r=e.stateNode,r._visibility=f?r._visibility&-2:r._visibility|1,f&&(a===null||R||Sr||jt||Vs(e)),a=null,r=e;;){if(r.tag===5||r.tag===26){if(a===null){R=a=r;try{if(p=R.stateNode,f)w=p.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none";else{O=R.stateNode;var se=R.memoizedProps.style,V=se!=null&&se.hasOwnProperty("display")?se.display:null;O.style.display=V==null||typeof V=="boolean"?"":(""+V).trim()}}catch(ge){Xe(R,R.return,ge)}}}else if(r.tag===6){if(a===null){R=r;try{R.stateNode.nodeValue=f?"":R.memoizedProps}catch(ge){Xe(R,R.return,ge)}}}else if(r.tag===18){if(a===null){R=r;try{var X=R.stateNode;f?Qy(X,!0):Qy(R.stateNode,!1)}catch(ge){Xe(R,R.return,ge)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===e)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break e;for(;r.sibling===null;){if(r.return===null||r.return===e)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Nl(e,a))));break;case 19:en(r,e),tn(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Nl(e,l)));break;case 30:break;case 21:break;default:en(r,e),tn(e)}}function tn(e){var r=e.flags;if(r&2){try{for(var a,l=e.return;l!==null;){if(Wp(l)){a=l;break}l=l.return}if(a==null)throw Error(i(160));switch(a.tag){case 27:var f=a.stateNode,p=ih(e);kl(e,p,f);break;case 5:var w=a.stateNode;a.flags&32&&(li(w,""),a.flags&=-33);var O=ih(e);kl(e,O,w);break;case 3:case 4:var R=a.stateNode.containerInfo,G=ih(e);ah(e,G,R);break;default:throw Error(i(161))}}catch(W){Xe(e,e.return,W)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function oy(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var r=e;oy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),e=e.sibling}}function Or(e,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)ty(e,r.alternate,r),r=r.sibling}function Vs(e){for(e=e.child;e!==null;){var r=e;switch(r.tag){case 0:case 11:case 14:case 15:ts(4,r,r.return),Vs(r);break;case 1:nr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&Qp(r,r.return,a),Vs(r);break;case 27:Ka(r.stateNode);case 26:case 5:nr(r,r.return),Vs(r);break;case 22:r.memoizedState===null&&Vs(r);break;case 30:Vs(r);break;default:Vs(r)}e=e.sibling}}function Ar(e,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var l=r.alternate,f=e,p=r,w=p.flags;switch(p.tag){case 0:case 11:case 15:Ar(f,p,a),Pa(4,p);break;case 1:if(Ar(f,p,a),l=p,f=l.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(G){Xe(l,l.return,G)}if(l=p,f=l.updateQueue,f!==null){var O=l.stateNode;try{var R=f.shared.hiddenCallbacks;if(R!==null)for(f.shared.hiddenCallbacks=null,f=0;f<R.length;f++)P0(R[f],O)}catch(G){Xe(l,l.return,G)}}a&&w&64&&Jp(p),Ua(p,p.return);break;case 27:Zp(p);case 26:case 5:Ar(f,p,a),a&&l===null&&w&4&&Xp(p),Ua(p,p.return);break;case 12:Ar(f,p,a);break;case 31:Ar(f,p,a),a&&w&4&&sy(f,p);break;case 13:Ar(f,p,a),a&&w&4&&iy(f,p);break;case 22:p.memoizedState===null&&Ar(f,p,a),Ua(p,p.return);break;case 30:break;default:Ar(f,p,a)}r=r.sibling}}function lh(e,r){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(e=r.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Oa(a))}function ch(e,r){e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&Oa(e))}function Vn(e,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)ly(e,r,a,l),r=r.sibling}function ly(e,r,a,l){var f=r.flags;switch(r.tag){case 0:case 11:case 15:Vn(e,r,a,l),f&2048&&Pa(9,r);break;case 1:Vn(e,r,a,l);break;case 3:Vn(e,r,a,l),f&2048&&(e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&Oa(e)));break;case 12:if(f&2048){Vn(e,r,a,l),e=r.stateNode;try{var p=r.memoizedProps,w=p.id,O=p.onPostCommit;typeof O=="function"&&O(w,r.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(R){Xe(r,r.return,R)}}else Vn(e,r,a,l);break;case 31:Vn(e,r,a,l);break;case 13:Vn(e,r,a,l);break;case 23:break;case 22:p=r.stateNode,w=r.alternate,r.memoizedState!==null?p._visibility&2?Vn(e,r,a,l):za(e,r):p._visibility&2?Vn(e,r,a,l):(p._visibility|=2,ki(e,r,a,l,(r.subtreeFlags&10256)!==0||!1)),f&2048&&lh(w,r);break;case 24:Vn(e,r,a,l),f&2048&&ch(r.alternate,r);break;default:Vn(e,r,a,l)}}function ki(e,r,a,l,f){for(f=f&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var p=e,w=r,O=a,R=l,G=w.flags;switch(w.tag){case 0:case 11:case 15:ki(p,w,O,R,f),Pa(8,w);break;case 23:break;case 22:var W=w.stateNode;w.memoizedState!==null?W._visibility&2?ki(p,w,O,R,f):za(p,w):(W._visibility|=2,ki(p,w,O,R,f)),f&&G&2048&&lh(w.alternate,w);break;case 24:ki(p,w,O,R,f),f&&G&2048&&ch(w.alternate,w);break;default:ki(p,w,O,R,f)}r=r.sibling}}function za(e,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=e,l=r,f=l.flags;switch(l.tag){case 22:za(a,l),f&2048&&lh(l.alternate,l);break;case 24:za(a,l),f&2048&&ch(l.alternate,l);break;default:za(a,l)}r=r.sibling}}var Ia=8192;function Ni(e,r,a){if(e.subtreeFlags&Ia)for(e=e.child;e!==null;)cy(e,r,a),e=e.sibling}function cy(e,r,a){switch(e.tag){case 26:Ni(e,r,a),e.flags&Ia&&e.memoizedState!==null&&Pw(a,Gn,e.memoizedState,e.memoizedProps);break;case 5:Ni(e,r,a);break;case 3:case 4:var l=Gn;Gn=Hl(e.stateNode.containerInfo),Ni(e,r,a),Gn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=Ia,Ia=16777216,Ni(e,r,a),Ia=l):Ni(e,r,a));break;default:Ni(e,r,a)}}function uy(e){var r=e.alternate;if(r!==null&&(e=r.child,e!==null)){r.child=null;do r=e.sibling,e.sibling=null,e=r;while(e!==null)}}function $a(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Rt=l,hy(l,e)}uy(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)fy(e),e=e.sibling}function fy(e){switch(e.tag){case 0:case 11:case 15:$a(e),e.flags&2048&&ts(9,e,e.return);break;case 3:$a(e);break;case 12:$a(e);break;case 22:var r=e.stateNode;e.memoizedState!==null&&r._visibility&2&&(e.return===null||e.return.tag!==13)?(r._visibility&=-3,Tl(e)):$a(e);break;default:$a(e)}}function Tl(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Rt=l,hy(l,e)}uy(e)}for(e=e.child;e!==null;){switch(r=e,r.tag){case 0:case 11:case 15:ts(8,r,r.return),Tl(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Tl(r));break;default:Tl(r)}e=e.sibling}}function hy(e,r){for(;Rt!==null;){var a=Rt;switch(a.tag){case 0:case 11:case 15:ts(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Oa(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Rt=l;else e:for(a=e;Rt!==null;){l=Rt;var f=l.sibling,p=l.return;if(ny(l),l===a){Rt=null;break e}if(f!==null){f.return=p,Rt=f;break e}Rt=p}}}var Z_={getCacheForType:function(e){var r=Ut(Et),a=r.data.get(e);return a===void 0&&(a=e(),r.data.set(e,a)),a},cacheSignal:function(){return Ut(Et).controller.signal}},ew=typeof WeakMap=="function"?WeakMap:Map,Ke=0,rt=null,qe=null,Be=0,Qe=0,hn=null,ns=!1,Ti=!1,uh=!1,jr=0,pt=0,rs=0,Ys=0,fh=0,dn=0,Ci=0,Ha=null,nn=null,hh=!1,Cl=0,dy=0,Ml=1/0,Rl=null,ss=null,Ct=0,is=null,Mi=null,kr=0,dh=0,mh=null,my=null,Fa=0,ph=null;function mn(){return(Ke&2)!==0&&Be!==0?Be&-Be:H.T!==null?_h():ha()}function py(){if(dn===0)if((Be&536870912)===0||Ie){var e=ur;ur<<=1,(ur&3932160)===0&&(ur=262144),dn=e}else dn=536870912;return e=un.current,e!==null&&(e.flags|=32),dn}function rn(e,r,a){(e===rt&&(Qe===2||Qe===9)||e.cancelPendingCommit!==null)&&(Ri(e,0),as(e,Be,dn,!1)),$n(e,a),((Ke&2)===0||e!==rt)&&(e===rt&&((Ke&2)===0&&(Ys|=a),pt===4&&as(e,Be,dn,!1)),rr(e))}function yy(e,r,a){if((Ke&6)!==0)throw Error(i(327));var l=!a&&(r&127)===0&&(r&e.expiredLanes)===0||ks(e,r),f=l?rw(e,r):gh(e,r,!0),p=l;do{if(f===0){Ti&&!l&&as(e,r,0,!1);break}else{if(a=e.current.alternate,p&&!tw(a)){f=gh(e,r,!1),p=!1;continue}if(f===2){if(p=r,e.errorRecoveryDisabledLanes&p)var w=0;else w=e.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){r=w;e:{var O=e;f=Ha;var R=O.current.memoizedState.isDehydrated;if(R&&(Ri(O,w).flags|=256),w=gh(O,w,!1),w!==2){if(uh&&!R){O.errorRecoveryDisabledLanes|=p,Ys|=p,f=4;break e}p=nn,nn=f,p!==null&&(nn===null?nn=p:nn.push.apply(nn,p))}f=w}if(p=!1,f!==2)continue}}if(f===1){Ri(e,0),as(e,r,0,!0);break}e:{switch(l=e,p=f,p){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:as(l,r,dn,!ns);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(f=Cl+300-ct(),10<f)){if(as(l,r,dn,!ns),js(l,0,!0)!==0)break e;kr=r,l.timeoutHandle=Yy(gy.bind(null,l,a,nn,Rl,hh,r,dn,Ys,Ci,ns,p,"Throttled",-0,0),f);break e}gy(l,a,nn,Rl,hh,r,dn,Ys,Ci,ns,p,null,-0,0)}}break}while(!0);rr(e)}function gy(e,r,a,l,f,p,w,O,R,G,W,se,V,X){if(e.timeoutHandle=-1,se=r.subtreeFlags,se&8192||(se&16785408)===16785408){se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dr},cy(r,p,se);var ge=(p&62914560)===p?Cl-ct():(p&4194048)===p?dy-ct():0;if(ge=Uw(se,ge),ge!==null){kr=p,e.cancelPendingCommit=ge(Oy.bind(null,e,r,p,a,l,f,w,O,R,W,se,null,V,X)),as(e,p,w,!G);return}}Oy(e,r,p,a,l,f,w,O,R)}function tw(e){for(var r=e;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var f=a[l],p=f.getSnapshot;f=f.value;try{if(!ln(p(),f))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function as(e,r,a,l){r&=~fh,r&=~Ys,e.suspendedLanes|=r,e.pingedLanes&=~r,l&&(e.warmLanes|=r),l=e.expirationTimes;for(var f=r;0<f;){var p=31-Ht(f),w=1<<p;l[p]=-1,f&=~w}a!==0&&Hr(e,a,r)}function Dl(){return(Ke&6)===0?(Ga(0),!1):!0}function yh(){if(qe!==null){if(Qe===0)var e=qe.return;else e=qe,gr=Ps=null,Mf(e),Si=null,ja=0,e=qe;for(;e!==null;)Kp(e.alternate,e),e=e.return;qe=null}}function Ri(e,r){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,_w(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),kr=0,yh(),rt=e,qe=a=pr(e.current,null),Be=r,Qe=0,hn=null,ns=!1,Ti=ks(e,r),uh=!1,Ci=dn=fh=Ys=rs=pt=0,nn=Ha=null,hh=!1,(r&8)!==0&&(r|=r&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=r;0<l;){var f=31-Ht(l),p=1<<f;r|=e[f],l&=~p}return jr=r,tl(),a}function by(e,r){Ce=null,H.H=qa,r===wi||r===cl?(r=D0(),Qe=3):r===vf?(r=D0(),Qe=4):Qe=r===Kf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,hn=r,qe===null&&(pt=1,Sl(e,Cn(r,e.current)))}function xy(){var e=un.current;return e===null?!0:(Be&4194048)===Be?qn===null:(Be&62914560)===Be||(Be&536870912)!==0?e===qn:!1}function vy(){var e=H.H;return H.H=qa,e===null?qa:e}function _y(){var e=H.A;return H.A=Z_,e}function ql(){pt=4,ns||(Be&4194048)!==Be&&un.current!==null||(Ti=!0),(rs&134217727)===0&&(Ys&134217727)===0||rt===null||as(rt,Be,dn,!1)}function gh(e,r,a){var l=Ke;Ke|=2;var f=vy(),p=_y();(rt!==e||Be!==r)&&(Rl=null,Ri(e,r)),r=!1;var w=pt;e:do try{if(Qe!==0&&qe!==null){var O=qe,R=hn;switch(Qe){case 8:yh(),w=6;break e;case 3:case 2:case 9:case 6:un.current===null&&(r=!0);var G=Qe;if(Qe=0,hn=null,Di(e,O,R,G),a&&Ti){w=0;break e}break;default:G=Qe,Qe=0,hn=null,Di(e,O,R,G)}}nw(),w=pt;break}catch(W){by(e,W)}while(!0);return r&&e.shellSuspendCounter++,gr=Ps=null,Ke=l,H.H=f,H.A=p,qe===null&&(rt=null,Be=0,tl()),w}function nw(){for(;qe!==null;)wy(qe)}function rw(e,r){var a=Ke;Ke|=2;var l=vy(),f=_y();rt!==e||Be!==r?(Rl=null,Ml=ct()+500,Ri(e,r)):Ti=ks(e,r);e:do try{if(Qe!==0&&qe!==null){r=qe;var p=hn;t:switch(Qe){case 1:Qe=0,hn=null,Di(e,r,p,1);break;case 2:case 9:if(M0(p)){Qe=0,hn=null,Sy(r);break}r=function(){Qe!==2&&Qe!==9||rt!==e||(Qe=7),rr(e)},p.then(r,r);break e;case 3:Qe=7;break e;case 4:Qe=5;break e;case 7:M0(p)?(Qe=0,hn=null,Sy(r)):(Qe=0,hn=null,Di(e,r,p,7));break;case 5:var w=null;switch(qe.tag){case 26:w=qe.memoizedState;case 5:case 27:var O=qe;if(w?lg(w):O.stateNode.complete){Qe=0,hn=null;var R=O.sibling;if(R!==null)qe=R;else{var G=O.return;G!==null?(qe=G,Ll(G)):qe=null}break t}}Qe=0,hn=null,Di(e,r,p,5);break;case 6:Qe=0,hn=null,Di(e,r,p,6);break;case 8:yh(),pt=6;break e;default:throw Error(i(462))}}sw();break}catch(W){by(e,W)}while(!0);return gr=Ps=null,H.H=l,H.A=f,Ke=a,qe!==null?0:(rt=null,Be=0,tl(),pt)}function sw(){for(;qe!==null&&!Po();)wy(qe)}function wy(e){var r=Vp(e.alternate,e,jr);e.memoizedProps=e.pendingProps,r===null?Ll(e):qe=r}function Sy(e){var r=e,a=r.alternate;switch(r.tag){case 15:case 0:r=zp(a,r,r.pendingProps,r.type,void 0,Be);break;case 11:r=zp(a,r,r.pendingProps,r.type.render,r.ref,Be);break;case 5:Mf(r);default:Kp(a,r),r=qe=_0(r,jr),r=Vp(a,r,jr)}e.memoizedProps=e.pendingProps,r===null?Ll(e):qe=r}function Di(e,r,a,l){gr=Ps=null,Mf(r),Si=null,ja=0;var f=r.return;try{if(V_(e,f,r,a,Be)){pt=1,Sl(e,Cn(a,e.current)),qe=null;return}}catch(p){if(f!==null)throw qe=f,p;pt=1,Sl(e,Cn(a,e.current)),qe=null;return}r.flags&32768?(Ie||l===1?e=!0:Ti||(Be&536870912)!==0?e=!1:(ns=e=!0,(l===2||l===9||l===3||l===6)&&(l=un.current,l!==null&&l.tag===13&&(l.flags|=16384))),Ey(r,e)):Ll(r)}function Ll(e){var r=e;do{if((r.flags&32768)!==0){Ey(r,ns);return}e=r.return;var a=J_(r.alternate,r,jr);if(a!==null){qe=a;return}if(r=r.sibling,r!==null){qe=r;return}qe=r=e}while(r!==null);pt===0&&(pt=5)}function Ey(e,r){do{var a=Q_(e.alternate,e);if(a!==null){a.flags&=32767,qe=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(e=e.sibling,e!==null)){qe=e;return}qe=e=a}while(e!==null);pt=6,qe=null}function Oy(e,r,a,l,f,p,w,O,R){e.cancelPendingCommit=null;do Bl();while(Ct!==0);if((Ke&6)!==0)throw Error(i(327));if(r!==null){if(r===e.current)throw Error(i(177));if(p=r.lanes|r.childLanes,p|=sf,$r(e,a,p,w,O,R),e===rt&&(qe=rt=null,Be=0),Mi=r,is=e,kr=a,dh=p,mh=f,my=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,lw(ri,function(){return Ty(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=H.T,H.T=null,f=Z.p,Z.p=2,w=Ke,Ke|=4;try{X_(e,r,a)}finally{Ke=w,Z.p=f,H.T=l}}Ct=1,Ay(),jy(),ky()}}function Ay(){if(Ct===1){Ct=0;var e=is,r=Mi,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=H.T,H.T=null;var l=Z.p;Z.p=2;var f=Ke;Ke|=4;try{ay(r,e);var p=Nh,w=h0(e.containerInfo),O=p.focusedElem,R=p.selectionRange;if(w!==O&&O&&O.ownerDocument&&f0(O.ownerDocument.documentElement,O)){if(R!==null&&Zu(O)){var G=R.start,W=R.end;if(W===void 0&&(W=G),"selectionStart"in O)O.selectionStart=G,O.selectionEnd=Math.min(W,O.value.length);else{var se=O.ownerDocument||document,V=se&&se.defaultView||window;if(V.getSelection){var X=V.getSelection(),ge=O.textContent.length,je=Math.min(R.start,ge),tt=R.end===void 0?je:Math.min(R.end,ge);!X.extend&&je>tt&&(w=tt,tt=je,je=w);var U=u0(O,je),B=u0(O,tt);if(U&&B&&(X.rangeCount!==1||X.anchorNode!==U.node||X.anchorOffset!==U.offset||X.focusNode!==B.node||X.focusOffset!==B.offset)){var F=se.createRange();F.setStart(U.node,U.offset),X.removeAllRanges(),je>tt?(X.addRange(F),X.extend(B.node,B.offset)):(F.setEnd(B.node,B.offset),X.addRange(F))}}}}for(se=[],X=O;X=X.parentNode;)X.nodeType===1&&se.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<se.length;O++){var te=se[O];te.element.scrollLeft=te.left,te.element.scrollTop=te.top}}Jl=!!kh,Nh=kh=null}finally{Ke=f,Z.p=l,H.T=a}}e.current=r,Ct=2}}function jy(){if(Ct===2){Ct=0;var e=is,r=Mi,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=H.T,H.T=null;var l=Z.p;Z.p=2;var f=Ke;Ke|=4;try{ty(e,r.alternate,r)}finally{Ke=f,Z.p=l,H.T=a}}Ct=3}}function ky(){if(Ct===4||Ct===3){Ct=0,ni();var e=is,r=Mi,a=kr,l=my;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ct=5:(Ct=0,Mi=is=null,Ny(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(ss=null),Ts(a),r=r.stateNode,xt&&typeof xt.onCommitFiberRoot=="function")try{xt.onCommitFiberRoot(As,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=H.T,f=Z.p,Z.p=2,H.T=null;try{for(var p=e.onRecoverableError,w=0;w<l.length;w++){var O=l[w];p(O.value,{componentStack:O.stack})}}finally{H.T=r,Z.p=f}}(kr&3)!==0&&Bl(),rr(e),f=e.pendingLanes,(a&261930)!==0&&(f&42)!==0?e===ph?Fa++:(Fa=0,ph=e):Fa=0,Ga(0)}}function Ny(e,r){(e.pooledCacheLanes&=r)===0&&(r=e.pooledCache,r!=null&&(e.pooledCache=null,Oa(r)))}function Bl(){return Ay(),jy(),ky(),Ty()}function Ty(){if(Ct!==5)return!1;var e=is,r=dh;dh=0;var a=Ts(kr),l=H.T,f=Z.p;try{Z.p=32>a?32:a,H.T=null,a=mh,mh=null;var p=is,w=kr;if(Ct=0,Mi=is=null,kr=0,(Ke&6)!==0)throw Error(i(331));var O=Ke;if(Ke|=4,fy(p.current),ly(p,p.current,w,a),Ke=O,Ga(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(As,p)}catch{}return!0}finally{Z.p=f,H.T=l,Ny(e,r)}}function Cy(e,r,a){r=Cn(a,r),r=Yf(e.stateNode,r,2),e=Wr(e,r,2),e!==null&&($n(e,2),rr(e))}function Xe(e,r,a){if(e.tag===3)Cy(e,e,a);else for(;r!==null;){if(r.tag===3){Cy(r,e,a);break}else if(r.tag===1){var l=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ss===null||!ss.has(l))){e=Cn(a,e),a=Mp(2),l=Wr(r,a,2),l!==null&&(Rp(a,l,r,e),$n(l,2),rr(l));break}}r=r.return}}function bh(e,r,a){var l=e.pingCache;if(l===null){l=e.pingCache=new ew;var f=new Set;l.set(r,f)}else f=l.get(r),f===void 0&&(f=new Set,l.set(r,f));f.has(a)||(uh=!0,f.add(a),e=iw.bind(null,e,r,a),r.then(e,e))}function iw(e,r,a){var l=e.pingCache;l!==null&&l.delete(r),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,rt===e&&(Be&a)===a&&(pt===4||pt===3&&(Be&62914560)===Be&&300>ct()-Cl?(Ke&2)===0&&Ri(e,0):fh|=a,Ci===Be&&(Ci=0)),rr(e)}function My(e,r){r===0&&(r=ii()),e=qs(e,r),e!==null&&($n(e,r),rr(e))}function aw(e){var r=e.memoizedState,a=0;r!==null&&(a=r.retryLane),My(e,a)}function ow(e,r){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(a=f.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(i(314))}l!==null&&l.delete(r),My(e,a)}function lw(e,r){return la(e,r)}var Pl=null,qi=null,xh=!1,Ul=!1,vh=!1,os=0;function rr(e){e!==qi&&e.next===null&&(qi===null?Pl=qi=e:qi=qi.next=e),Ul=!0,xh||(xh=!0,uw())}function Ga(e,r){if(!vh&&Ul){vh=!0;do for(var a=!1,l=Pl;l!==null;){if(e!==0){var f=l.pendingLanes;if(f===0)var p=0;else{var w=l.suspendedLanes,O=l.pingedLanes;p=(1<<31-Ht(42|e)+1)-1,p&=f&~(w&~O),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(a=!0,Ly(l,p))}else p=Be,p=js(l,l===rt?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(p&3)===0||ks(l,p)||(a=!0,Ly(l,p));l=l.next}while(a);vh=!1}}function cw(){Ry()}function Ry(){Ul=xh=!1;var e=0;os!==0&&vw()&&(e=os);for(var r=ct(),a=null,l=Pl;l!==null;){var f=l.next,p=Dy(l,r);p===0?(l.next=null,a===null?Pl=f:a.next=f,f===null&&(qi=a)):(a=l,(e!==0||(p&3)!==0)&&(Ul=!0)),l=f}Ct!==0&&Ct!==5||Ga(e),os!==0&&(os=0)}function Dy(e,r){for(var a=e.suspendedLanes,l=e.pingedLanes,f=e.expirationTimes,p=e.pendingLanes&-62914561;0<p;){var w=31-Ht(p),O=1<<w,R=f[w];R===-1?((O&a)===0||(O&l)!==0)&&(f[w]=fa(O,r)):R<=r&&(e.expiredLanes|=O),p&=~O}if(r=rt,a=Be,a=js(e,e===r?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===r&&(Qe===2||Qe===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&cr(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||ks(e,a)){if(r=a&-a,r===e.callbackPriority)return r;switch(l!==null&&cr(l),Ts(a)){case 2:case 8:a=zo;break;case 32:a=ri;break;case 268435456:a=Io;break;default:a=ri}return l=qy.bind(null,e),a=la(a,l),e.callbackPriority=r,e.callbackNode=a,r}return l!==null&&l!==null&&cr(l),e.callbackPriority=2,e.callbackNode=null,2}function qy(e,r){if(Ct!==0&&Ct!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Bl()&&e.callbackNode!==a)return null;var l=Be;return l=js(e,e===rt?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(yy(e,l,r),Dy(e,ct()),e.callbackNode!=null&&e.callbackNode===a?qy.bind(null,e):null)}function Ly(e,r){if(Bl())return null;yy(e,r,!0)}function uw(){ww(function(){(Ke&6)!==0?la(Uo,cw):Ry()})}function _h(){if(os===0){var e=vi;e===0&&(e=Ur,Ur<<=1,(Ur&261888)===0&&(Ur=256)),os=e}return os}function By(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Yo(""+e)}function Py(e,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,e.id&&a.setAttribute("form",e.id),r.parentNode.insertBefore(a,r),e=new FormData(e),a.parentNode.removeChild(a),e}function fw(e,r,a,l,f){if(r==="submit"&&a&&a.stateNode===f){var p=By((f[dt]||null).action),w=l.submitter;w&&(r=(r=w[dt]||null)?By(r.formAction):w.getAttribute("formAction"),r!==null&&(p=r,w=null));var O=new Xo("action","action",null,l,f);e.push({event:O,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(os!==0){var R=w?Py(f,w):new FormData(f);If(a,{pending:!0,data:R,method:f.method,action:p},null,R)}}else typeof p=="function"&&(O.preventDefault(),R=w?Py(f,w):new FormData(f),If(a,{pending:!0,data:R,method:f.method,action:p},p,R))},currentTarget:f}]})}}for(var wh=0;wh<rf.length;wh++){var Sh=rf[wh],hw=Sh.toLowerCase(),dw=Sh[0].toUpperCase()+Sh.slice(1);Fn(hw,"on"+dw)}Fn(p0,"onAnimationEnd"),Fn(y0,"onAnimationIteration"),Fn(g0,"onAnimationStart"),Fn("dblclick","onDoubleClick"),Fn("focusin","onFocus"),Fn("focusout","onBlur"),Fn(N_,"onTransitionRun"),Fn(T_,"onTransitionStart"),Fn(C_,"onTransitionCancel"),Fn(b0,"onTransitionEnd"),Y("onMouseEnter",["mouseout","mouseover"]),Y("onMouseLeave",["mouseout","mouseover"]),Y("onPointerEnter",["pointerout","pointerover"]),Y("onPointerLeave",["pointerout","pointerover"]),ae("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ae("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ae("onBeforeInput",["compositionend","keypress","textInput","paste"]),ae("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ae("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ae("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Va="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),mw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Va));function Uy(e,r){r=(r&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],f=l.event;l=l.listeners;e:{var p=void 0;if(r)for(var w=l.length-1;0<=w;w--){var O=l[w],R=O.instance,G=O.currentTarget;if(O=O.listener,R!==p&&f.isPropagationStopped())break e;p=O,f.currentTarget=G;try{p(f)}catch(W){el(W)}f.currentTarget=null,p=R}else for(w=0;w<l.length;w++){if(O=l[w],R=O.instance,G=O.currentTarget,O=O.listener,R!==p&&f.isPropagationStopped())break e;p=O,f.currentTarget=G;try{p(f)}catch(W){el(W)}f.currentTarget=null,p=R}}}}function Le(e,r){var a=r[Cs];a===void 0&&(a=r[Cs]=new Set);var l=e+"__bubble";a.has(l)||(zy(r,e,2,!1),a.add(l))}function Eh(e,r,a){var l=0;r&&(l|=4),zy(a,e,l,r)}var zl="_reactListening"+Math.random().toString(36).slice(2);function Oh(e){if(!e[zl]){e[zl]=!0,z.forEach(function(a){a!=="selectionchange"&&(mw.has(a)||Eh(a,!1,e),Eh(a,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[zl]||(r[zl]=!0,Eh("selectionchange",!1,r))}}function zy(e,r,a,l){switch(pg(r)){case 2:var f=$w;break;case 8:f=Hw;break;default:f=zh}a=f.bind(null,r,a,e),f=void 0,!Fu||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),l?f!==void 0?e.addEventListener(r,a,{capture:!0,passive:f}):e.addEventListener(r,a,!0):f!==void 0?e.addEventListener(r,a,{passive:f}):e.addEventListener(r,a,!1)}function Ah(e,r,a,l,f){var p=l;if((r&1)===0&&(r&2)===0&&l!==null)e:for(;;){if(l===null)return;var w=l.tag;if(w===3||w===4){var O=l.stateNode.containerInfo;if(O===f)break;if(w===4)for(w=l.return;w!==null;){var R=w.tag;if((R===3||R===4)&&w.stateNode.containerInfo===f)return;w=w.return}for(;O!==null;){if(w=A(O),w===null)return;if(R=w.tag,R===5||R===6||R===26||R===27){l=p=w;continue e}O=O.parentNode}}l=l.return}Gm(function(){var G=p,W=$u(a),se=[];e:{var V=x0.get(e);if(V!==void 0){var X=Xo,ge=e;switch(e){case"keypress":if(Jo(a)===0)break e;case"keydown":case"keyup":X=o_;break;case"focusin":ge="focus",X=Ku;break;case"focusout":ge="blur",X=Ku;break;case"beforeblur":case"afterblur":X=Ku;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":X=Km;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=Jv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=u_;break;case p0:case y0:case g0:X=Wv;break;case b0:X=h_;break;case"scroll":case"scrollend":X=Yv;break;case"wheel":X=m_;break;case"copy":case"cut":case"paste":X=e_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=Qm;break;case"toggle":case"beforetoggle":X=y_}var je=(r&4)!==0,tt=!je&&(e==="scroll"||e==="scrollend"),U=je?V!==null?V+"Capture":null:V;je=[];for(var B=G,F;B!==null;){var te=B;if(F=te.stateNode,te=te.tag,te!==5&&te!==26&&te!==27||F===null||U===null||(te=ma(B,U),te!=null&&je.push(Ya(B,te,F))),tt)break;B=B.return}0<je.length&&(V=new X(V,ge,null,a,W),se.push({event:V,listeners:je}))}}if((r&7)===0){e:{if(V=e==="mouseover"||e==="pointerover",X=e==="mouseout"||e==="pointerout",V&&a!==Iu&&(ge=a.relatedTarget||a.fromElement)&&(A(ge)||ge[on]))break e;if((X||V)&&(V=W.window===W?W:(V=W.ownerDocument)?V.defaultView||V.parentWindow:window,X?(ge=a.relatedTarget||a.toElement,X=G,ge=ge?A(ge):null,ge!==null&&(tt=c(ge),je=ge.tag,ge!==tt||je!==5&&je!==27&&je!==6)&&(ge=null)):(X=null,ge=G),X!==ge)){if(je=Km,te="onMouseLeave",U="onMouseEnter",B="mouse",(e==="pointerout"||e==="pointerover")&&(je=Qm,te="onPointerLeave",U="onPointerEnter",B="pointer"),tt=X==null?V:k(X),F=ge==null?V:k(ge),V=new je(te,B+"leave",X,a,W),V.target=tt,V.relatedTarget=F,te=null,A(W)===G&&(je=new je(U,B+"enter",ge,a,W),je.target=F,je.relatedTarget=tt,te=je),tt=te,X&&ge)t:{for(je=pw,U=X,B=ge,F=0,te=U;te;te=je(te))F++;te=0;for(var Oe=B;Oe;Oe=je(Oe))te++;for(;0<F-te;)U=je(U),F--;for(;0<te-F;)B=je(B),te--;for(;F--;){if(U===B||B!==null&&U===B.alternate){je=U;break t}U=je(U),B=je(B)}je=null}else je=null;X!==null&&Iy(se,V,X,je,!1),ge!==null&&tt!==null&&Iy(se,tt,ge,je,!0)}}e:{if(V=G?k(G):window,X=V.nodeName&&V.nodeName.toLowerCase(),X==="select"||X==="input"&&V.type==="file")var Ve=s0;else if(n0(V))if(i0)Ve=A_;else{Ve=E_;var xe=S_}else X=V.nodeName,!X||X.toLowerCase()!=="input"||V.type!=="checkbox"&&V.type!=="radio"?G&&zu(G.elementType)&&(Ve=s0):Ve=O_;if(Ve&&(Ve=Ve(e,G))){r0(se,Ve,a,W);break e}xe&&xe(e,V,G),e==="focusout"&&G&&V.type==="number"&&G.memoizedProps.value!=null&&Uu(V,"number",V.value)}switch(xe=G?k(G):window,e){case"focusin":(n0(xe)||xe.contentEditable==="true")&&(hi=xe,ef=G,wa=null);break;case"focusout":wa=ef=hi=null;break;case"mousedown":tf=!0;break;case"contextmenu":case"mouseup":case"dragend":tf=!1,d0(se,a,W);break;case"selectionchange":if(k_)break;case"keydown":case"keyup":d0(se,a,W)}var Me;if(Qu)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else fi?e0(e,a)&&(Pe="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Pe="onCompositionStart");Pe&&(Xm&&a.locale!=="ko"&&(fi||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&fi&&(Me=Vm()):(Gr=W,Gu="value"in Gr?Gr.value:Gr.textContent,fi=!0)),xe=Il(G,Pe),0<xe.length&&(Pe=new Jm(Pe,e,null,a,W),se.push({event:Pe,listeners:xe}),Me?Pe.data=Me:(Me=t0(a),Me!==null&&(Pe.data=Me)))),(Me=b_?x_(e,a):v_(e,a))&&(Pe=Il(G,"onBeforeInput"),0<Pe.length&&(xe=new Jm("onBeforeInput","beforeinput",null,a,W),se.push({event:xe,listeners:Pe}),xe.data=Me)),fw(se,e,G,a,W)}Uy(se,r)})}function Ya(e,r,a){return{instance:e,listener:r,currentTarget:a}}function Il(e,r){for(var a=r+"Capture",l=[];e!==null;){var f=e,p=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=ma(e,a),f!=null&&l.unshift(Ya(e,f,p)),f=ma(e,r),f!=null&&l.push(Ya(e,f,p))),e.tag===3)return l;e=e.return}return[]}function pw(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Iy(e,r,a,l,f){for(var p=r._reactName,w=[];a!==null&&a!==l;){var O=a,R=O.alternate,G=O.stateNode;if(O=O.tag,R!==null&&R===l)break;O!==5&&O!==26&&O!==27||G===null||(R=G,f?(G=ma(a,p),G!=null&&w.unshift(Ya(a,G,R))):f||(G=ma(a,p),G!=null&&w.push(Ya(a,G,R)))),a=a.return}w.length!==0&&e.push({event:r,listeners:w})}var yw=/\r\n?/g,gw=/\u0000|\uFFFD/g;function $y(e){return(typeof e=="string"?e:""+e).replace(yw,`
26
+ `).replace(gw,"")}function Hy(e,r){return r=$y(r),$y(e)===r}function et(e,r,a,l,f,p){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||li(e,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&li(e,""+l);break;case"className":Hn(e,"class",l);break;case"tabIndex":Hn(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Hn(e,a,l);break;case"style":Hm(e,l,p);break;case"data":if(r!=="object"){Hn(e,"data",l);break}case"src":case"href":if(l===""&&(r!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Yo(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(a==="formAction"?(r!=="input"&&et(e,r,"name",f.name,f,null),et(e,r,"formEncType",f.formEncType,f,null),et(e,r,"formMethod",f.formMethod,f,null),et(e,r,"formTarget",f.formTarget,f,null)):(et(e,r,"encType",f.encType,f,null),et(e,r,"method",f.method,f,null),et(e,r,"target",f.target,f,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=Yo(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=dr);break;case"onScroll":l!=null&&Le("scroll",e);break;case"onScrollEnd":l!=null&&Le("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=Yo(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":Le("beforetoggle",e),Le("toggle",e),Ft(e,"popover",l);break;case"xlinkActuate":hr(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":hr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":hr(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":hr(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":hr(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":hr(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":hr(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":hr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":hr(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Ft(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Gv.get(a)||a,Ft(e,a,l))}}function jh(e,r,a,l,f,p){switch(a){case"style":Hm(e,l,p);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=a}}break;case"children":typeof l=="string"?li(e,l):(typeof l=="number"||typeof l=="bigint")&&li(e,""+l);break;case"onScroll":l!=null&&Le("scroll",e);break;case"onScrollEnd":l!=null&&Le("scrollend",e);break;case"onClick":l!=null&&(e.onclick=dr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!re.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(f=a.endsWith("Capture"),r=a.slice(2,f?a.length-7:void 0),p=e[dt]||null,p=p!=null?p[a]:null,typeof p=="function"&&e.removeEventListener(r,p,f),typeof l=="function")){typeof p!="function"&&p!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(r,l,f);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):Ft(e,a,l)}}}function It(e,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Le("error",e),Le("load",e);var l=!1,f=!1,p;for(p in a)if(a.hasOwnProperty(p)){var w=a[p];if(w!=null)switch(p){case"src":l=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:et(e,r,p,w,a,null)}}f&&et(e,r,"srcSet",a.srcSet,a,null),l&&et(e,r,"src",a.src,a,null);return;case"input":Le("invalid",e);var O=p=w=f=null,R=null,G=null;for(l in a)if(a.hasOwnProperty(l)){var W=a[l];if(W!=null)switch(l){case"name":f=W;break;case"type":w=W;break;case"checked":R=W;break;case"defaultChecked":G=W;break;case"value":p=W;break;case"defaultValue":O=W;break;case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(i(137,r));break;default:et(e,r,l,W,a,null)}}Um(e,p,O,R,G,w,f,!1);return;case"select":Le("invalid",e),l=w=p=null;for(f in a)if(a.hasOwnProperty(f)&&(O=a[f],O!=null))switch(f){case"value":p=O;break;case"defaultValue":w=O;break;case"multiple":l=O;default:et(e,r,f,O,a,null)}r=p,a=w,e.multiple=!!l,r!=null?oi(e,!!l,r,!1):a!=null&&oi(e,!!l,a,!0);return;case"textarea":Le("invalid",e),p=f=l=null;for(w in a)if(a.hasOwnProperty(w)&&(O=a[w],O!=null))switch(w){case"value":l=O;break;case"defaultValue":f=O;break;case"children":p=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(i(91));break;default:et(e,r,w,O,a,null)}Im(e,l,f,p);return;case"option":for(R in a)if(a.hasOwnProperty(R)&&(l=a[R],l!=null))switch(R){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:et(e,r,R,l,a,null)}return;case"dialog":Le("beforetoggle",e),Le("toggle",e),Le("cancel",e),Le("close",e);break;case"iframe":case"object":Le("load",e);break;case"video":case"audio":for(l=0;l<Va.length;l++)Le(Va[l],e);break;case"image":Le("error",e),Le("load",e);break;case"details":Le("toggle",e);break;case"embed":case"source":case"link":Le("error",e),Le("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(G in a)if(a.hasOwnProperty(G)&&(l=a[G],l!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:et(e,r,G,l,a,null)}return;default:if(zu(r)){for(W in a)a.hasOwnProperty(W)&&(l=a[W],l!==void 0&&jh(e,r,W,l,a,void 0));return}}for(O in a)a.hasOwnProperty(O)&&(l=a[O],l!=null&&et(e,r,O,l,a,null))}function bw(e,r,a,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,w=null,O=null,R=null,G=null,W=null;for(X in a){var se=a[X];if(a.hasOwnProperty(X)&&se!=null)switch(X){case"checked":break;case"value":break;case"defaultValue":R=se;default:l.hasOwnProperty(X)||et(e,r,X,null,l,se)}}for(var V in l){var X=l[V];if(se=a[V],l.hasOwnProperty(V)&&(X!=null||se!=null))switch(V){case"type":p=X;break;case"name":f=X;break;case"checked":G=X;break;case"defaultChecked":W=X;break;case"value":w=X;break;case"defaultValue":O=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(i(137,r));break;default:X!==se&&et(e,r,V,X,l,se)}}Pu(e,w,O,R,G,W,p,f);return;case"select":X=w=O=V=null;for(p in a)if(R=a[p],a.hasOwnProperty(p)&&R!=null)switch(p){case"value":break;case"multiple":X=R;default:l.hasOwnProperty(p)||et(e,r,p,null,l,R)}for(f in l)if(p=l[f],R=a[f],l.hasOwnProperty(f)&&(p!=null||R!=null))switch(f){case"value":V=p;break;case"defaultValue":O=p;break;case"multiple":w=p;default:p!==R&&et(e,r,f,p,l,R)}r=O,a=w,l=X,V!=null?oi(e,!!a,V,!1):!!l!=!!a&&(r!=null?oi(e,!!a,r,!0):oi(e,!!a,a?[]:"",!1));return;case"textarea":X=V=null;for(O in a)if(f=a[O],a.hasOwnProperty(O)&&f!=null&&!l.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:et(e,r,O,null,l,f)}for(w in l)if(f=l[w],p=a[w],l.hasOwnProperty(w)&&(f!=null||p!=null))switch(w){case"value":V=f;break;case"defaultValue":X=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==p&&et(e,r,w,f,l,p)}zm(e,V,X);return;case"option":for(var ge in a)if(V=a[ge],a.hasOwnProperty(ge)&&V!=null&&!l.hasOwnProperty(ge))switch(ge){case"selected":e.selected=!1;break;default:et(e,r,ge,null,l,V)}for(R in l)if(V=l[R],X=a[R],l.hasOwnProperty(R)&&V!==X&&(V!=null||X!=null))switch(R){case"selected":e.selected=V&&typeof V!="function"&&typeof V!="symbol";break;default:et(e,r,R,V,l,X)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var je in a)V=a[je],a.hasOwnProperty(je)&&V!=null&&!l.hasOwnProperty(je)&&et(e,r,je,null,l,V);for(G in l)if(V=l[G],X=a[G],l.hasOwnProperty(G)&&V!==X&&(V!=null||X!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(i(137,r));break;default:et(e,r,G,V,l,X)}return;default:if(zu(r)){for(var tt in a)V=a[tt],a.hasOwnProperty(tt)&&V!==void 0&&!l.hasOwnProperty(tt)&&jh(e,r,tt,void 0,l,V);for(W in l)V=l[W],X=a[W],!l.hasOwnProperty(W)||V===X||V===void 0&&X===void 0||jh(e,r,W,V,l,X);return}}for(var U in a)V=a[U],a.hasOwnProperty(U)&&V!=null&&!l.hasOwnProperty(U)&&et(e,r,U,null,l,V);for(se in l)V=l[se],X=a[se],!l.hasOwnProperty(se)||V===X||V==null&&X==null||et(e,r,se,V,l,X)}function Fy(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function xw(){if(typeof performance.getEntriesByType=="function"){for(var e=0,r=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var f=a[l],p=f.transferSize,w=f.initiatorType,O=f.duration;if(p&&O&&Fy(w)){for(w=0,O=f.responseEnd,l+=1;l<a.length;l++){var R=a[l],G=R.startTime;if(G>O)break;var W=R.transferSize,se=R.initiatorType;W&&Fy(se)&&(R=R.responseEnd,w+=W*(R<O?1:(O-G)/(R-G)))}if(--l,r+=8*(p+w)/(f.duration/1e3),e++,10<e)break}}if(0<e)return r/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var kh=null,Nh=null;function $l(e){return e.nodeType===9?e:e.ownerDocument}function Gy(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Vy(e,r){if(e===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&r==="foreignObject"?0:e}function Th(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Ch=null;function vw(){var e=window.event;return e&&e.type==="popstate"?e===Ch?!1:(Ch=e,!0):(Ch=null,!1)}var Yy=typeof setTimeout=="function"?setTimeout:void 0,_w=typeof clearTimeout=="function"?clearTimeout:void 0,Ky=typeof Promise=="function"?Promise:void 0,ww=typeof queueMicrotask=="function"?queueMicrotask:typeof Ky<"u"?function(e){return Ky.resolve(null).then(e).catch(Sw)}:Yy;function Sw(e){setTimeout(function(){throw e})}function ls(e){return e==="head"}function Jy(e,r){var a=r,l=0;do{var f=a.nextSibling;if(e.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(f),Ui(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Ka(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Ka(a);for(var p=a.firstChild;p;){var w=p.nextSibling,O=p.nodeName;p[Tt]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&p.rel.toLowerCase()==="stylesheet"||a.removeChild(p),p=w}}else a==="body"&&Ka(e.ownerDocument.body);a=f}while(a);Ui(r)}function Qy(e,r){var a=e;e=0;do{var l=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function Mh(e){var r=e.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Mh(a),ai(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Ew(e,r,a,l){for(;e.nodeType===1;){var f=a;if(e.nodeName.toLowerCase()!==r.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[Tt])switch(r){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(p=e.getAttribute("rel"),p==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(p!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(p=e.getAttribute("src"),(p!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(r==="input"&&e.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===p)return e}else return e;if(e=Ln(e.nextSibling),e===null)break}return null}function Ow(e,r,a){if(r==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=Ln(e.nextSibling),e===null))return null;return e}function Xy(e,r){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Ln(e.nextSibling),e===null))return null;return e}function Rh(e){return e.data==="$?"||e.data==="$~"}function Dh(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Aw(e,r){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=r;else if(e.data!=="$?"||a.readyState!=="loading")r();else{var l=function(){r(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function Ln(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return e}var qh=null;function Wy(e){e=e.nextSibling;for(var r=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(r===0)return Ln(e.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}e=e.nextSibling}return null}function Zy(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return e;r--}else a!=="/$"&&a!=="/&"||r++}e=e.previousSibling}return null}function eg(e,r,a){switch(r=$l(a),e){case"html":if(e=r.documentElement,!e)throw Error(i(452));return e;case"head":if(e=r.head,!e)throw Error(i(453));return e;case"body":if(e=r.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Ka(e){for(var r=e.attributes;r.length;)e.removeAttributeNode(r[0]);ai(e)}var Bn=new Map,tg=new Set;function Hl(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Nr=Z.d;Z.d={f:jw,r:kw,D:Nw,C:Tw,L:Cw,m:Mw,X:Dw,S:Rw,M:qw};function jw(){var e=Nr.f(),r=Dl();return e||r}function kw(e){var r=N(e);r!==null&&r.tag===5&&r.type==="form"?bp(r):Nr.r(e)}var Li=typeof document>"u"?null:document;function ng(e,r,a){var l=Li;if(l&&typeof r=="string"&&r){var f=Nn(r);f='link[rel="'+e+'"][href="'+f+'"]',typeof a=="string"&&(f+='[crossorigin="'+a+'"]'),tg.has(f)||(tg.add(f),e={rel:e,crossOrigin:a,href:r},l.querySelector(f)===null&&(r=l.createElement("link"),It(r,"link",e),q(r),l.head.appendChild(r)))}}function Nw(e){Nr.D(e),ng("dns-prefetch",e,null)}function Tw(e,r){Nr.C(e,r),ng("preconnect",e,r)}function Cw(e,r,a){Nr.L(e,r,a);var l=Li;if(l&&e&&r){var f='link[rel="preload"][as="'+Nn(r)+'"]';r==="image"&&a&&a.imageSrcSet?(f+='[imagesrcset="'+Nn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(f+='[imagesizes="'+Nn(a.imageSizes)+'"]')):f+='[href="'+Nn(e)+'"]';var p=f;switch(r){case"style":p=Bi(e);break;case"script":p=Pi(e)}Bn.has(p)||(e=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:e,as:r},a),Bn.set(p,e),l.querySelector(f)!==null||r==="style"&&l.querySelector(Ja(p))||r==="script"&&l.querySelector(Qa(p))||(r=l.createElement("link"),It(r,"link",e),q(r),l.head.appendChild(r)))}}function Mw(e,r){Nr.m(e,r);var a=Li;if(a&&e){var l=r&&typeof r.as=="string"?r.as:"script",f='link[rel="modulepreload"][as="'+Nn(l)+'"][href="'+Nn(e)+'"]',p=f;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Pi(e)}if(!Bn.has(p)&&(e=b({rel:"modulepreload",href:e},r),Bn.set(p,e),a.querySelector(f)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Qa(p)))return}l=a.createElement("link"),It(l,"link",e),q(l),a.head.appendChild(l)}}}function Rw(e,r,a){Nr.S(e,r,a);var l=Li;if(l&&e){var f=T(l).hoistableStyles,p=Bi(e);r=r||"default";var w=f.get(p);if(!w){var O={loading:0,preload:null};if(w=l.querySelector(Ja(p)))O.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":r},a),(a=Bn.get(p))&&Lh(e,a);var R=w=l.createElement("link");q(R),It(R,"link",e),R._p=new Promise(function(G,W){R.onload=G,R.onerror=W}),R.addEventListener("load",function(){O.loading|=1}),R.addEventListener("error",function(){O.loading|=2}),O.loading|=4,Fl(w,r,l)}w={type:"stylesheet",instance:w,count:1,state:O},f.set(p,w)}}}function Dw(e,r){Nr.X(e,r);var a=Li;if(a&&e){var l=T(a).hoistableScripts,f=Pi(e),p=l.get(f);p||(p=a.querySelector(Qa(f)),p||(e=b({src:e,async:!0},r),(r=Bn.get(f))&&Bh(e,r),p=a.createElement("script"),q(p),It(p,"link",e),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(f,p))}}function qw(e,r){Nr.M(e,r);var a=Li;if(a&&e){var l=T(a).hoistableScripts,f=Pi(e),p=l.get(f);p||(p=a.querySelector(Qa(f)),p||(e=b({src:e,async:!0,type:"module"},r),(r=Bn.get(f))&&Bh(e,r),p=a.createElement("script"),q(p),It(p,"link",e),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(f,p))}}function rg(e,r,a,l){var f=(f=Bt.current)?Hl(f):null;if(!f)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Bi(a.href),a=T(f).hoistableStyles,l=a.get(r),l||(l={type:"style",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Bi(a.href);var p=T(f).hoistableStyles,w=p.get(e);if(w||(f=f.ownerDocument||f,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,w),(p=f.querySelector(Ja(e)))&&!p._p&&(w.instance=p,w.state.loading=5),Bn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Bn.set(e,a),p||Lw(f,e,a,w.state))),r&&l===null)throw Error(i(528,""));return w}if(r&&l!==null)throw Error(i(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Pi(a),a=T(f).hoistableScripts,l=a.get(r),l||(l={type:"script",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Bi(e){return'href="'+Nn(e)+'"'}function Ja(e){return'link[rel="stylesheet"]['+e+"]"}function sg(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Lw(e,r,a,l){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?l.loading=1:(r=e.createElement("link"),l.preload=r,r.addEventListener("load",function(){return l.loading|=1}),r.addEventListener("error",function(){return l.loading|=2}),It(r,"link",a),q(r),e.head.appendChild(r))}function Pi(e){return'[src="'+Nn(e)+'"]'}function Qa(e){return"script[async]"+e}function ig(e,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=e.querySelector('style[data-href~="'+Nn(a.href)+'"]');if(l)return r.instance=l,q(l),l;var f=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),q(l),It(l,"style",f),Fl(l,a.precedence,e),r.instance=l;case"stylesheet":f=Bi(a.href);var p=e.querySelector(Ja(f));if(p)return r.state.loading|=4,r.instance=p,q(p),p;l=sg(a),(f=Bn.get(f))&&Lh(l,f),p=(e.ownerDocument||e).createElement("link"),q(p);var w=p;return w._p=new Promise(function(O,R){w.onload=O,w.onerror=R}),It(p,"link",l),r.state.loading|=4,Fl(p,a.precedence,e),r.instance=p;case"script":return p=Pi(a.src),(f=e.querySelector(Qa(p)))?(r.instance=f,q(f),f):(l=a,(f=Bn.get(p))&&(l=b({},a),Bh(l,f)),e=e.ownerDocument||e,f=e.createElement("script"),q(f),It(f,"link",l),e.head.appendChild(f),r.instance=f);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(l=r.instance,r.state.loading|=4,Fl(l,a.precedence,e));return r.instance}function Fl(e,r,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=l.length?l[l.length-1]:null,p=f,w=0;w<l.length;w++){var O=l[w];if(O.dataset.precedence===r)p=O;else if(p!==f)break}p?p.parentNode.insertBefore(e,p.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(e,r.firstChild))}function Lh(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.title==null&&(e.title=r.title)}function Bh(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.integrity==null&&(e.integrity=r.integrity)}var Gl=null;function ag(e,r,a){if(Gl===null){var l=new Map,f=Gl=new Map;f.set(a,l)}else f=Gl,l=f.get(a),l||(l=new Map,f.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),f=0;f<a.length;f++){var p=a[f];if(!(p[Tt]||p[nt]||e==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var w=p.getAttribute(r)||"";w=e+w;var O=l.get(w);O?O.push(p):l.set(w,[p])}}return l}function og(e,r,a){e=e.ownerDocument||e,e.head.insertBefore(a,r==="title"?e.querySelector("head > title"):null)}function Bw(e,r,a){if(a===1||r.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return e=r.disabled,typeof r.precedence=="string"&&e==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function lg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Pw(e,r,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var f=Bi(l.href),p=r.querySelector(Ja(f));if(p){r=p._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=Vl.bind(e),r.then(e,e)),a.state.loading|=4,a.instance=p,q(p);return}p=r.ownerDocument||r,l=sg(l),(f=Bn.get(f))&&Lh(l,f),p=p.createElement("link"),q(p);var w=p;w._p=new Promise(function(O,R){w.onload=O,w.onerror=R}),It(p,"link",l),a.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=Vl.bind(e),r.addEventListener("load",a),r.addEventListener("error",a))}}var Ph=0;function Uw(e,r){return e.stylesheets&&e.count===0&&Kl(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&Kl(e,e.stylesheets),e.unsuspend){var p=e.unsuspend;e.unsuspend=null,p()}},6e4+r);0<e.imgBytes&&Ph===0&&(Ph=62500*xw());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Kl(e,e.stylesheets),e.unsuspend)){var p=e.unsuspend;e.unsuspend=null,p()}},(e.imgBytes>Ph?50:800)+r);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(f)}}:null}function Vl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Kl(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yl=null;function Kl(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yl=new Map,r.forEach(zw,e),Yl=null,Vl.call(e))}function zw(e,r){if(!(r.state.loading&4)){var a=Yl.get(e);if(a)var l=a.get(null);else{a=new Map,Yl.set(e,a);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var w=f[p];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(a.set(w.dataset.precedence,w),l=w)}l&&a.set(null,l)}f=r.instance,w=f.getAttribute("data-precedence"),p=a.get(w)||l,p===l&&a.set(null,f),a.set(w,f),this.count++,l=Vl.bind(this),f.addEventListener("load",l),f.addEventListener("error",l),p?p.parentNode.insertBefore(f,p.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),r.state.loading|=4}}var Xa={$$typeof:ie,Provider:null,Consumer:null,_currentValue:le,_currentValue2:le,_threadCount:0};function Iw(e,r,a,l,f,p,w,O,R){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ir(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ir(0),this.hiddenUpdates=Ir(null),this.identifierPrefix=l,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=R,this.incompleteTransitions=new Map}function cg(e,r,a,l,f,p,w,O,R,G,W,se){return e=new Iw(e,r,a,w,R,G,W,se,O),r=1,p===!0&&(r|=24),p=cn(3,null,null,r),e.current=p,p.stateNode=e,r=gf(),r.refCount++,e.pooledCache=r,r.refCount++,p.memoizedState={element:l,isDehydrated:a,cache:r},_f(p),e}function ug(e){return e?(e=pi,e):pi}function fg(e,r,a,l,f,p){f=ug(f),l.context===null?l.context=f:l.pendingContext=f,l=Xr(r),l.payload={element:a},p=p===void 0?null:p,p!==null&&(l.callback=p),a=Wr(e,l,r),a!==null&&(rn(a,e,r),Na(a,e,r))}function hg(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<r?a:r}}function Uh(e,r){hg(e,r),(e=e.alternate)&&hg(e,r)}function dg(e){if(e.tag===13||e.tag===31){var r=qs(e,67108864);r!==null&&rn(r,e,67108864),Uh(e,67108864)}}function mg(e){if(e.tag===13||e.tag===31){var r=mn();r=fr(r);var a=qs(e,r);a!==null&&rn(a,e,r),Uh(e,r)}}var Jl=!0;function $w(e,r,a,l){var f=H.T;H.T=null;var p=Z.p;try{Z.p=2,zh(e,r,a,l)}finally{Z.p=p,H.T=f}}function Hw(e,r,a,l){var f=H.T;H.T=null;var p=Z.p;try{Z.p=8,zh(e,r,a,l)}finally{Z.p=p,H.T=f}}function zh(e,r,a,l){if(Jl){var f=Ih(l);if(f===null)Ah(e,r,l,Ql,a),yg(e,l);else if(Gw(f,e,r,a,l))l.stopPropagation();else if(yg(e,l),r&4&&-1<Fw.indexOf(e)){for(;f!==null;){var p=N(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var w=In(p.pendingLanes);if(w!==0){var O=p;for(O.pendingLanes|=2,O.entangledLanes|=2;w;){var R=1<<31-Ht(w);O.entanglements[1]|=R,w&=~R}rr(p),(Ke&6)===0&&(Ml=ct()+500,Ga(0))}}break;case 31:case 13:O=qs(p,2),O!==null&&rn(O,p,2),Dl(),Uh(p,2)}if(p=Ih(l),p===null&&Ah(e,r,l,Ql,a),p===f)break;f=p}f!==null&&l.stopPropagation()}else Ah(e,r,l,null,a)}}function Ih(e){return e=$u(e),$h(e)}var Ql=null;function $h(e){if(Ql=null,e=A(e),e!==null){var r=c(e);if(r===null)e=null;else{var a=r.tag;if(a===13){if(e=d(r),e!==null)return e;e=null}else if(a===31){if(e=y(r),e!==null)return e;e=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null)}}return Ql=e,null}function pg(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Du()){case Uo:return 2;case zo:return 8;case ri:case qu:return 32;case Io:return 268435456;default:return 32}default:return 32}}var Hh=!1,cs=null,us=null,fs=null,Wa=new Map,Za=new Map,hs=[],Fw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function yg(e,r){switch(e){case"focusin":case"focusout":cs=null;break;case"dragenter":case"dragleave":us=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":Wa.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Za.delete(r.pointerId)}}function eo(e,r,a,l,f,p){return e===null||e.nativeEvent!==p?(e={blockedOn:r,domEventName:a,eventSystemFlags:l,nativeEvent:p,targetContainers:[f]},r!==null&&(r=N(r),r!==null&&dg(r)),e):(e.eventSystemFlags|=l,r=e.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),e)}function Gw(e,r,a,l,f){switch(r){case"focusin":return cs=eo(cs,e,r,a,l,f),!0;case"dragenter":return us=eo(us,e,r,a,l,f),!0;case"mouseover":return fs=eo(fs,e,r,a,l,f),!0;case"pointerover":var p=f.pointerId;return Wa.set(p,eo(Wa.get(p)||null,e,r,a,l,f)),!0;case"gotpointercapture":return p=f.pointerId,Za.set(p,eo(Za.get(p)||null,e,r,a,l,f)),!0}return!1}function gg(e){var r=A(e.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=d(a),r!==null){e.blockedOn=r,Ho(e.priority,function(){mg(a)});return}}else if(r===31){if(r=y(a),r!==null){e.blockedOn=r,Ho(e.priority,function(){mg(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Xl(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var a=Ih(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Iu=l,a.target.dispatchEvent(l),Iu=null}else return r=N(a),r!==null&&dg(r),e.blockedOn=a,!1;r.shift()}return!0}function bg(e,r,a){Xl(e)&&a.delete(r)}function Vw(){Hh=!1,cs!==null&&Xl(cs)&&(cs=null),us!==null&&Xl(us)&&(us=null),fs!==null&&Xl(fs)&&(fs=null),Wa.forEach(bg),Za.forEach(bg)}function Wl(e,r){e.blockedOn===r&&(e.blockedOn=null,Hh||(Hh=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Vw)))}var Zl=null;function xg(e){Zl!==e&&(Zl=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Zl===e&&(Zl=null);for(var r=0;r<e.length;r+=3){var a=e[r],l=e[r+1],f=e[r+2];if(typeof l!="function"){if($h(l||a)===null)continue;break}var p=N(a);p!==null&&(e.splice(r,3),r-=3,If(p,{pending:!0,data:f,method:a.method,action:l},l,f))}}))}function Ui(e){function r(R){return Wl(R,e)}cs!==null&&Wl(cs,e),us!==null&&Wl(us,e),fs!==null&&Wl(fs,e),Wa.forEach(r),Za.forEach(r);for(var a=0;a<hs.length;a++){var l=hs[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<hs.length&&(a=hs[0],a.blockedOn===null);)gg(a),a.blockedOn===null&&hs.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var f=a[l],p=a[l+1],w=f[dt]||null;if(typeof p=="function")w||xg(a);else if(w){var O=null;if(p&&p.hasAttribute("formAction")){if(f=p,w=p[dt]||null)O=w.formAction;else if($h(f)!==null)continue}else O=w.action;typeof O=="function"?a[l+1]=O:(a.splice(l,3),l-=3),xg(a)}}}function vg(){function e(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(w){return f=w})},focusReset:"manual",scroll:"manual"})}function r(){f!==null&&(f(),f=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),f!==null&&(f(),f=null)}}}function Fh(e){this._internalRoot=e}ec.prototype.render=Fh.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(i(409));var a=r.current,l=mn();fg(a,l,e,r,null,null)},ec.prototype.unmount=Fh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;fg(e.current,2,null,e,null,null),Dl(),r[on]=null}};function ec(e){this._internalRoot=e}ec.prototype.unstable_scheduleHydration=function(e){if(e){var r=ha();e={blockedOn:null,target:e,priority:r};for(var a=0;a<hs.length&&r!==0&&r<hs[a].priority;a++);hs.splice(a,0,e),a===0&&gg(e)}};var _g=t.version;if(_g!=="19.2.4")throw Error(i(527,_g,"19.2.4"));Z.findDOMNode=function(e){var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=u(r),e=e!==null?m(e):null,e=e===null?null:e.stateNode,e};var Yw={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var tc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!tc.isDisabled&&tc.supportsFiber)try{As=tc.inject(Yw),xt=tc}catch{}}return to.createRoot=function(e,r){if(!o(e))throw Error(i(299));var a=!1,l="",f=kp,p=Np,w=Tp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(l=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(p=r.onCaughtError),r.onRecoverableError!==void 0&&(w=r.onRecoverableError)),r=cg(e,1,!1,null,null,a,l,null,f,p,w,vg),e[on]=r.current,Oh(e),new Fh(r)},to.hydrateRoot=function(e,r,a){if(!o(e))throw Error(i(299));var l=!1,f="",p=kp,w=Np,O=Tp,R=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onUncaughtError!==void 0&&(p=a.onUncaughtError),a.onCaughtError!==void 0&&(w=a.onCaughtError),a.onRecoverableError!==void 0&&(O=a.onRecoverableError),a.formState!==void 0&&(R=a.formState)),r=cg(e,1,!0,r,a??null,l,f,R,p,w,O,vg),r.context=ug(null),a=r.current,l=mn(),l=fr(l),f=Xr(l),f.callback=null,Wr(a,f,l),a=l,r.current.lanes=a,$n(r,a),rr(r),e[on]=r.current,Oh(e),new ec(r)},to.version="19.2.4",to}var kg;function BS(){if(kg)return Gh.exports;kg=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(t){console.error(t)}}return n(),Gh.exports=LS(),Gh.exports}var PS=BS();const US="modulepreload",zS=function(n,t){return new URL(n,t).href},Ng={},Ae=function(t,s,i){let o=Promise.resolve();if(s&&s.length>0){let d=function(m){return Promise.all(m.map(b=>Promise.resolve(b).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};const y=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),u=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=d(s.map(m=>{if(m=zS(m,i),m in Ng)return;Ng[m]=!0;const b=m.endsWith(".css"),x=b?'[rel="stylesheet"]':"";if(!!i)for(let S=y.length-1;S>=0;S--){const C=y[S];if(C.href===m&&(!b||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${x}`))return;const _=document.createElement("link");if(_.rel=b?"stylesheet":US,b||(_.as="script"),_.crossOrigin="",_.href=m,u&&_.setAttribute("nonce",u),document.head.appendChild(_),b)return new Promise((S,C)=>{_.addEventListener("load",S),_.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${m}`)))})}))}function c(d){const y=new Event("vite:preloadError",{cancelable:!0});if(y.payload=d,window.dispatchEvent(y),!y.defaultPrevented)throw d}return o.then(d=>{for(const y of d||[])y.status==="rejected"&&c(y.reason);return t().catch(c)})};function wu(n){try{const t=n.split(".");if(t.length!==3)return null;const s=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function rx(n){const t=wu(n);return!t||typeof t.exp!="number"?null:t.exp}function em(n,t=0){const s=rx(n);return s===null?!0:Date.now()/1e3>=s-t}const $t=window.__LT_BASE__??"",pd=`${$t}/api`;class Tg extends Error{constructor(t,s,i){super(t),this.status=s,this.body=i,this.name="ApiError"}}let gs=null;function nc(n){gs=n}function sx(){return gs}const IS="X-LT-Acting-Token";let Zc=null,eu=null;function Cg(n){Zc=n}let tu=null;function Mg(n){tu=n}function Rg(n){eu=n}function $S(n){const t=n==null?void 0:n.error;return typeof t=="string"&&/acting[- ]identity/i.test(t)}async function Dg(){const n=sessionStorage.getItem("lt_credentials");if(!n)return null;try{const{username:t,password:s}=JSON.parse(n),i=await fetch(`${pd}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})});if(!i.ok)return null;const o=await i.json();return o.token&&o.user&&sessionStorage.setItem("lt_user_info",JSON.stringify({displayName:o.user.display_name,username:o.user.external_id})),o.token??null}catch{return null}}let ms=null;async function fe(n,t={}){const s={"Content-Type":"application/json",...t.headers};if(gs){if(em(gs)){ms||(ms=Dg().finally(()=>{ms=null}));const c=await ms;if(c)gs=c,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:c}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${gs}`}const i=(Zc==null?void 0:Zc())??null;i&&(s[IS]=i);let o=await fetch(`${pd}${n}`,{...t,headers:s});if(i&&(tu==null||tu(i)),o.status===401&&i){const c=await o.clone().json().catch(()=>null);if($S(c))throw eu==null||eu(),new Tg(c.error,401,c)}if(o.status===401&&gs){ms||(ms=Dg().finally(()=>{ms=null}));const c=await ms;if(c&&(gs=c,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:c}})),s.Authorization=`Bearer ${c}`,o=await fetch(`${pd}${n}`,{...t,headers:s})),o.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(o.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!o.ok){const c=await o.json().catch(()=>({error:o.statusText}));throw new Tg(c.message||c.error||o.statusText,o.status,c)}return o.json()}const HS="lt_ai_override";let rc=null;function tm(){return rc||(rc=fetch(`${$t}/api/settings`).then(n=>{if(!n.ok)throw new Error(`settings ${n.status}`);return n.json()}).catch(n=>{throw rc=null,n})),rc}function FS(){try{if(localStorage.getItem(HS)==="off")return!1}catch{}return null}function Wn(){var s;const n=Ue({queryKey:["settings"],queryFn:tm,staleTime:1/0}),t=FS();return n.data&&t===!1&&((s=n.data.ai)!=null&&s.enabled)?{...n,data:{...n.data,ai:{enabled:!1}}}:n}function GS(n){var u,m,b;const{data:t}=Wn(),s=((u=t==null?void 0:t.auth)==null?void 0:u.ssoKeepaliveSeconds)??0,i=((m=t==null?void 0:t.auth)==null?void 0:m.ssoKeepaliveIdleTimeoutSeconds)??0,o=E.useRef(Date.now()),c=E.useRef(Date.now()),d=E.useRef(!1),g=!!n&&((b=wu(n))==null?void 0:b.sso)===!0&&s>0;E.useEffect(()=>{if(!g)return;const x=()=>{o.current=Date.now()};window.addEventListener("pointerdown",x,{passive:!0}),window.addEventListener("keydown",x,{passive:!0}),window.addEventListener("wheel",x,{passive:!0});const v=async()=>{if(!d.current&&document.visibilityState==="visible"&&!(i>0&&Date.now()-o.current>i*1e3)){d.current=!0;try{const C=await fetch(`${$t}/api/auth/sso`,{method:"POST"});if(C.status===401||C.status===403){window.dispatchEvent(new CustomEvent("auth:unauthorized"));return}if(!C.ok)return;const L=await C.json().catch(()=>null);L!=null&&L.token&&(c.current=Date.now(),window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:L.token}})))}catch{}finally{d.current=!1}}},_=setInterval(v,s*1e3),S=()=>{document.visibilityState==="visible"&&Date.now()-c.current>s*1e3&&v()};return document.addEventListener("visibilitychange",S),()=>{clearInterval(_),document.removeEventListener("visibilitychange",S),window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",x),window.removeEventListener("wheel",x)}},[g,s,i])}const ix=E.createContext(null),VS=300;function Kh(n,t){if(em(n))return null;const s=wu(n);if(!s)return null;const i=t??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(i==null?void 0:i.displayName)??null,username:(i==null?void 0:i.username)??null,roles:s.roles??[]}}function YS({children:n}){const[t,s]=E.useState(()=>{const b=sessionStorage.getItem("lt_token");return b?em(b)?(sessionStorage.removeItem("lt_token"),null):(nc(b),Kh(b)):null}),i=E.useRef(void 0),o=E.useCallback(b=>{clearTimeout(i.current);const x=rx(b);if(!x)return;const v=(x-VS)*1e3-Date.now();v<=0||(i.current=setTimeout(async()=>{try{const _=wu(b);if(_!=null&&_.sso){const oe=await fetch(`${$t}/api/auth/sso`,{method:"POST"});if(!oe.ok)return;const D=await oe.json();D.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:D.token}}));return}const S=sessionStorage.getItem("lt_credentials");if(!S)return;const{username:C,password:L}=JSON.parse(S),P=await fetch(`${$t}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:L})});if(!P.ok)return;const ie=await P.json();ie.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:ie.token}}))}catch{}},v))},[]),c=E.useCallback((b,x,v)=>{const _={displayName:(v==null?void 0:v.displayName)??null,username:(v==null?void 0:v.username)??(x==null?void 0:x.username)??null},S=Kh(b,_);S&&(nc(b),sessionStorage.setItem("lt_token",b),sessionStorage.setItem("lt_user_info",JSON.stringify(_)),x&&sessionStorage.setItem("lt_credentials",JSON.stringify(x)),s(S),o(b))},[o]),d=E.useCallback(()=>{clearTimeout(i.current);const b=sessionStorage.getItem("lt_sso_logout_url");nc(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),b&&(window.location.href=b)},[]);E.useEffect(()=>{const b=()=>d(),x=v=>{var C;const _=(C=v.detail)==null?void 0:C.token;if(!_)return;const S=Kh(_);S&&(nc(_),sessionStorage.setItem("lt_token",_),s(S),o(_))};return window.addEventListener("auth:unauthorized",b),window.addEventListener("auth:refreshed",x),()=>{window.removeEventListener("auth:unauthorized",b),window.removeEventListener("auth:refreshed",x)}},[d,o]),E.useEffect(()=>{const b=sessionStorage.getItem("lt_token");return b&&t&&o(b),()=>clearTimeout(i.current)},[]);const y=(t==null?void 0:t.roles.some(b=>b.type==="superadmin"))??!1,g=E.useCallback(b=>(t==null?void 0:t.roles.some(x=>x.role===b))??!1,[t]),u=E.useCallback(b=>(t==null?void 0:t.roles.some(x=>x.type===b))??!1,[t]),m=(t==null?void 0:t.roles.map(b=>b.role))??[];return h.jsxs(ix.Provider,{value:{user:t,isAuthenticated:!!t,isSuperAdmin:y,login:c,logout:d,hasRole:g,hasRoleType:u,userRoleNames:m},children:[h.jsx(KS,{authenticated:t!==null}),n]})}function KS({authenticated:n}){return GS(n?sessionStorage.getItem("lt_token"):null),null}function Lt(){const n=E.useContext(ix);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}const Sn=new Uint8Array(0),ei=new TextEncoder,vn=new TextDecoder;function JS(...n){let t=0;for(let o=0;o<n.length;o++)t+=n[o].length;const s=new Uint8Array(t);let i=0;for(let o=0;o<n.length;o++)s.set(n[o],i),i+=n[o].length;return s}function go(...n){const t=[];for(let s=0;s<n.length;s++)t.push(ei.encode(n[s]));return t.length===0?Sn:t.length===1?t[0]:JS(...t)}function qg(n){return!n||n.length===0?"":vn.decode(n)}const Lg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",Bg=36,QS=0xcfd41b9100000,Pg=33,XS=333,Ug=22;function WS(n){for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*255)}function ZS(n){var t;(t=globalThis==null?void 0:globalThis.crypto)!=null&&t.getRandomValues?globalThis.crypto.getRandomValues(n):WS(n)}class eE{constructor(){j(this,"buf");j(this,"seq");j(this,"inc");j(this,"inited");this.buf=new Uint8Array(Ug),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*QS),this.inc=Math.floor(Math.random()*(XS-Pg)+Pg)}setPre(){const t=new Uint8Array(12);ZS(t);for(let s=0;s<12;s++){const i=t[s]%36;this.buf[s]=Lg.charCodeAt(i)}}fillSeq(){let t=this.seq;for(let s=Ug-1;s>=12;s--)this.buf[s]=Lg.charCodeAt(t%Bg),t=Math.floor(t/Bg)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}const Es=new eE;var Mr;(function(n){n.Disconnect="disconnect",n.Reconnect="reconnect",n.Update="update",n.LDM="ldm",n.Error="error"})(Mr||(Mr={}));var Yi;(function(n){n.Reconnecting="reconnecting",n.PingTimer="pingTimer",n.StaleConnection="staleConnection",n.ClientInitiatedReconnect="client initiated reconnect"})(Yi||(Yi={}));var ce;(function(n){n.ApiError="BAD API",n.BadAuthentication="BAD_AUTHENTICATION",n.BadCreds="BAD_CREDS",n.BadHeader="BAD_HEADER",n.BadJson="BAD_JSON",n.BadPayload="BAD_PAYLOAD",n.BadSubject="BAD_SUBJECT",n.Cancelled="CANCELLED",n.ConnectionClosed="CONNECTION_CLOSED",n.ConnectionDraining="CONNECTION_DRAINING",n.ConnectionRefused="CONNECTION_REFUSED",n.ConnectionTimeout="CONNECTION_TIMEOUT",n.Disconnect="DISCONNECT",n.InvalidOption="INVALID_OPTION",n.InvalidPayload="INVALID_PAYLOAD",n.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",n.NoResponders="503",n.NotFunction="NOT_FUNC",n.RequestError="REQUEST_ERROR",n.ServerOptionNotAvailable="SERVER_OPT_NA",n.SubClosed="SUB_CLOSED",n.SubDraining="SUB_DRAINING",n.Timeout="TIMEOUT",n.Tls="TLS",n.Unknown="UNKNOWN_ERROR",n.WssRequired="WSS_REQUIRED",n.JetStreamInvalidAck="JESTREAM_INVALID_ACK",n.JetStream404NoMessages="404",n.JetStream408RequestTimeout="408",n.JetStream409MaxAckPendingExceeded="409",n.JetStream409="409",n.JetStreamNotEnabled="503",n.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",n.AuthorizationViolation="AUTHORIZATION_VIOLATION",n.AuthenticationExpired="AUTHENTICATION_EXPIRED",n.ProtocolError="NATS_PROTOCOL_ERR",n.PermissionsViolation="PERMISSIONS_VIOLATION",n.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",n.AccountExpired="ACCOUNT_EXPIRED"})(ce||(ce={}));function tE(n){return typeof n.code=="string"}class ax{constructor(){j(this,"messages");this.messages=new Map,this.messages.set(ce.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(ce.BadJson,"Bad JSON"),this.messages.set(ce.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(t){return nE.getMessage(t)}getMessage(t){return this.messages.get(t)||t}}const nE=new ax;class pe extends Error{constructor(s,i,o){super(s);j(this,"name");j(this,"message");j(this,"code");j(this,"permissionContext");j(this,"chainedError");j(this,"api_error");this.name="NatsError",this.message=s,this.code=i,this.chainedError=o}static errorForCode(s,i){const o=ax.getMessage(s);return new pe(o,s,i)}isAuthError(){return this.code===ce.AuthenticationExpired||this.code===ce.AuthorizationViolation||this.code===ce.AccountExpired}isAuthTimeout(){return this.code===ce.AuthenticationTimeout}isPermissionError(){return this.code===ce.PermissionsViolation}isProtocolError(){return this.code===ce.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var gn;(function(n){n[n.Exact=0]="Exact",n[n.CanonicalMIME=1]="CanonicalMIME",n[n.IgnoreCase=2]="IgnoreCase"})(gn||(gn={}));var Qn;(function(n){n.Timer="timer",n.Count="count",n.JitterTimer="jitterTimer",n.SentinelMsg="sentinelMsg"})(Qn||(Qn={}));var bo;(function(n){n.STATS="io.nats.micro.v1.stats_response",n.INFO="io.nats.micro.v1.info_response",n.PING="io.nats.micro.v1.ping_response"})(bo||(bo={}));const cu="Nats-Service-Error",uu="Nats-Service-Error-Code";class fu extends Error{constructor(s,i){super(i);j(this,"code");this.code=s}static isServiceError(s){return fu.toServiceError(s)!==null}static toServiceError(s){var o,c;const i=((o=s==null?void 0:s.headers)==null?void 0:o.get(uu))||"";if(i!==""){const d=parseInt(i)||400,y=((c=s==null?void 0:s.headers)==null?void 0:c.get(cu))||"";return new fu(d,y.length?y:i)}return null}}function Rr(n=""){if(n=n||"_INBOX",typeof n!="string")throw new Error("prefix must be a string");return n.split(".").forEach(t=>{if(t==="*"||t===">")throw new Error(`inbox prefixes cannot have wildcards '${n}'`)}),`${n}.${Es.next()}`}const yd="127.0.0.1";var xs;(function(n){n.PING="PING",n.STATS="STATS",n.INFO="INFO"})(xs||(xs={}));function Su(n,...t){for(let s=0;s<t.length;s++){const i=t[s];Object.keys(i).forEach(function(o){n[o]=i[o]})}return n}function sc(n){return vn.decode(n).replace(/\n/g,"␊").replace(/\r/g,"␍")}function ea(n,t=!0){const s=t?pe.errorForCode(ce.Timeout):null;let i,o;const c=new Promise((d,y)=>{i={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{y(s===null?pe.errorForCode(ce.Timeout):s)},n)});return Object.assign(c,i)}function sa(n=0){let t;const s=new Promise(i=>{const o=setTimeout(()=>{i()},n);t={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,t)}function ht(){let n={};const t=new Promise((s,i)=>{n={resolve:s,reject:i}});return Object.assign(t,n)}function ox(n){for(let t=n.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[n[t],n[s]]=[n[s],n[t]]}return n}function rE(n){return n===0?0:Math.floor(n/2+Math.random()*n)}function nm(n=[0,250,250,500,500,3e3,5e3]){Array.isArray(n)||(n=[0,250,250,500,500,3e3,5e3]);const t=n.length-1;return{backoff(s){return rE(s>t?n[t]:n[s])}}}function ft(n){return n*1e6}function rm(n){return Math.floor(n/1e6)}function zg(n){let i=!0;const o=new Array(n.length);for(let c=0;c<n.length;c++){let d=n.charCodeAt(c);if(d===58||d<33||d>126)throw new pe(`'${n[c]}' is not a valid character for a header key`,ce.BadHeader);i&&97<=d&&d<=122?d-=32:!i&&65<=d&&d<=90&&(d+=32),o[c]=d,i=d==45}return String.fromCharCode(...o)}function qr(n=0,t=""){if(n===0&&t!==""||n>0&&t==="")throw new Error("setting status requires both code and description");return new vs(n,t)}const Jh="NATS/1.0";class vs{constructor(t=0,s=""){j(this,"_code");j(this,"headers");j(this,"_description");this._code=t,this._description=s,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(t){if(t&&this.headers.size===t.headers.size&&this._code===t._code){for(const[s,i]of this.headers){const o=t.values(s);if(i.length!==o.length)return!1;const c=[...i].sort(),d=[...o].sort();for(let y=0;y<c.length;y++)if(c[y]!==d[y])return!1}return!0}return!1}static decode(t){const s=new vs,o=vn.decode(t).split(`\r
27
+ `),c=o[0];if(c!==Jh){let d=c.replace(Jh,"").trim();if(d.length>0){s._code=parseInt(d,10),isNaN(s._code)&&(s._code=0);const y=s._code.toString();d=d.replace(y,""),s._description=d.trim()}}return o.length>=1&&o.slice(1).map(d=>{if(d){const y=d.indexOf(":");if(y>-1){const g=d.slice(0,y),u=d.slice(y+1).trim();s.append(g,u)}}}),s}toString(){if(this.headers.size===0&&this._code===0)return"";let t=Jh;this._code>0&&this._description!==""&&(t+=` ${this._code} ${this._description}`);for(const[s,i]of this.headers)for(let o=0;o<i.length;o++)t=`${t}\r
28
+ ${s}: ${i[o]}`;return`${t}\r
29
+ \r
30
+ `}encode(){return ei.encode(this.toString())}static validHeaderValue(t){if(/[\r\n]/.test(t))throw new pe("invalid header value - \\r and \\n are not allowed.",ce.BadHeader);return t.trim()}keys(){const t=[];for(const s of this.headers.keys())t.push(s);return t}findKeys(t,s=gn.Exact){const i=this.keys();switch(s){case gn.Exact:return i.filter(o=>o===t);case gn.CanonicalMIME:return t=zg(t),i.filter(o=>o===t);default:{const o=t.toLowerCase();return i.filter(c=>o===c.toLowerCase())}}}get(t,s=gn.Exact){const i=this.findKeys(t,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(t,s=gn.Exact){const i=this.findKeys(t,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(t,s=gn.Exact){return this.findKeys(t,s).length>0}set(t,s,i=gn.Exact){this.delete(t,i),this.append(t,s,i)}append(t,s,i=gn.Exact){const o=zg(t);i===gn.CanonicalMIME&&(t=o);const c=this.findKeys(t,i);t=c.length>0?c[0]:t;const d=vs.validHeaderValue(s);let y=this.headers.get(t);y||(y=[],this.headers.set(t,y)),y.push(d)}values(t,s=gn.Exact){const i=[];return this.findKeys(t,s).forEach(c=>{const d=this.headers.get(c);d&&i.push(...d)}),i}delete(t,s=gn.Exact){this.findKeys(t,s).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const t={};return this.keys().forEach(s=>{t[s]=this.values(s)}),t}get code(){return this._code}get description(){return this._description}static fromRecord(t){const s=new vs;for(const i in t)s.headers.set(i,t[i]);return s}}function gd(){return{encode(n){return ei.encode(n)},decode(n){return vn.decode(n)}}}function Xn(n){return{encode(t){try{return t===void 0&&(t=null),ei.encode(JSON.stringify(t))}catch(s){throw pe.errorForCode(ce.BadJson,s)}},decode(t){try{return JSON.parse(vn.decode(t),n)}catch(s){throw pe.errorForCode(ce.BadJson,s)}}}}function lx(n){var t;return n&&n.data.length===0&&((t=n.headers)==null?void 0:t.code)===503?pe.errorForCode(ce.NoResponders):null}class sm{constructor(t,s,i){j(this,"_headers");j(this,"_msg");j(this,"_rdata");j(this,"_reply");j(this,"_subject");j(this,"publisher");this._msg=t,this._rdata=s,this.publisher=i}get subject(){return this._subject?this._subject:(this._subject=vn.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=vn.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const t=this._rdata.subarray(0,this._msg.hdr);this._headers=vs.decode(t)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(t=Sn,s){return this.reply?(this.publisher.publish(this.reply,t,s),!0):!1}size(){var o;const t=this._msg.subject.length,s=((o=this._msg.reply)==null?void 0:o.length)||0,i=this._msg.size===-1?0:this._msg.size;return t+s+i}json(t){return Xn(t).decode(this.data)}string(){return vn.decode(this.data)}requestInfo(){var s;const t=(s=this.headers)==null?void 0:s.get("Nats-Request-Info");return t?JSON.parse(t,function(i,o){return(i==="start"||i==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}j(sm,"jc");function Ki(n){return Eu("durable",n)}function Yt(n){return Eu("stream",n)}function Eu(n,t=""){if(t==="")throw Error(`${n} name required`);return[".","*",">","/","\\"," "," ",`
31
+ `,"\r"].forEach(i=>{if(t.indexOf(i)!==-1){switch(i){case`
32
+ `:i="\\n";break;case"\r":i="\\r";break;case" ":i="\\t";break}throw Error(`invalid ${n} name - ${n} name cannot contain '${i}'`)}}),""}function mo(n,t=""){if(t==="")throw Error(`${n} name required`);const s=sE(t);if(s.length)throw new Error(`invalid ${n} name - ${n} name ${s}`)}function sE(n=""){if(n==="")throw Error("name required");const t=/^[-\w]+$/g;if(n.match(t)===null){for(const i of n.split(""))if(i.match(t)===null)return`cannot contain '${i}'`}return""}function bd(n){if(n.data.length>0)return!1;const t=n.headers;return t?t.code>=100&&t.code<200:!1}function xd(n){var t;return bd(n)&&((t=n.headers)==null?void 0:t.description)==="Idle Heartbeat"}function iE(n,t,s){const i=qr(n,t),o={hdr:1,sid:0,size:0},c=new sm(o,Sn,{});return c._headers=i,c._subject=s,c}function Ji(n){if(n.data.length!==0)return null;const t=n.headers;return t?cx(t.code,t.description):null}var Un;(function(n){n.MaxBatchExceeded="exceeded maxrequestbatch of",n.MaxExpiresExceeded="exceeded maxrequestexpires of",n.MaxBytesExceeded="exceeded maxrequestmaxbytes of",n.MaxMessageSizeExceeded="message size exceeds maxbytes",n.PushConsumer="consumer is push based",n.MaxWaitingExceeded="exceeded maxwaiting",n.IdleHeartbeatMissed="idle heartbeats missed",n.ConsumerDeleted="consumer deleted"})(Un||(Un={}));function aE(n){return n.code!==ce.JetStream409?!1:[Un.MaxBatchExceeded,Un.MaxExpiresExceeded,Un.MaxBytesExceeded,Un.MaxMessageSizeExceeded,Un.PushConsumer,Un.IdleHeartbeatMissed,Un.ConsumerDeleted].find(s=>n.message.indexOf(s)!==-1)!==void 0}function cx(n,t=""){if(n<300)return null;switch(t=t.toLowerCase(),n){case 404:return new pe(t,ce.JetStream404NoMessages);case 408:return new pe(t,ce.JetStream408RequestTimeout);case 409:{const s=t.startsWith(Un.IdleHeartbeatMissed)?ce.JetStreamIdleHeartBeat:ce.JetStream409;return new pe(t,s)}case 503:return pe.errorForCode(ce.JetStreamNotEnabled,new Error(t));default:return t===""&&(t=ce.Unknown),new pe(t,`${n}`)}}class qt{constructor(){j(this,"inflight");j(this,"processed");j(this,"received");j(this,"noIterator");j(this,"iterClosed");j(this,"done");j(this,"signal");j(this,"yields");j(this,"filtered");j(this,"pendingFiltered");j(this,"ingestionFilterFn");j(this,"protocolFilterFn");j(this,"dispatchedFn");j(this,"ctx");j(this,"_data");j(this,"err");j(this,"time");j(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=ht(),this.yields=[],this.iterClosed=ht(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(t){if(this.done)return;if(typeof t=="function"){this.yields.push(t),this.signal.resolve();return}const{ingest:s,protocol:i}=this.ingestionFilterFn?this.ingestionFilterFn(t,this.ctx||this):{ingest:!0,protocol:!1};s&&(i&&(this.filtered++,this.pendingFiltered++),this.yields.push(t),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new pe("unsupported iterator",ce.ApiError);if(this.yielding)throw new pe("already yielding",ce.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const t=this.yields;this.inflight=t.length,this.yields=[];for(let s=0;s<t.length;s++){if(typeof t[s]=="function"){const o=t[s];try{o()}catch(c){throw c}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(t[s]):!0){this.processed++;const o=Date.now();yield t[s],this.time=Date.now()-o,this.dispatchedFn&&t[s]&&this.dispatchedFn(t[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=ht())}}finally{this.stop()}}stop(t){this.done||(this.err=t,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(t))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class im{constructor(t,s,i={maxOut:2}){j(this,"interval");j(this,"maxOut");j(this,"cancelAfter");j(this,"timer");j(this,"autoCancelTimer");j(this,"last");j(this,"missed");j(this,"count");j(this,"callback");this.interval=t,this.maxOut=(i==null?void 0:i.maxOut)||2,this.cancelAfter=(i==null?void 0:i.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=s,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(t,s=0,i=2){this.interval=t,this.maxOut=i,this.cancelAfter=s,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(t){console.log(t)}},this.interval)}}var vd;(function(n){n.Limits="limits",n.Interest="interest",n.Workqueue="workqueue"})(vd||(vd={}));var wo;(function(n){n.Old="old",n.New="new"})(wo||(wo={}));var _d;(function(n){n.File="file",n.Memory="memory"})(_d||(_d={}));var wt;(function(n){n.All="all",n.Last="last",n.New="new",n.StartSequence="by_start_sequence",n.StartTime="by_start_time",n.LastPerSubject="last_per_subject"})(wt||(wt={}));var Dt;(function(n){n.None="none",n.All="all",n.Explicit="explicit",n.NotSet=""})(Dt||(Dt={}));var ta;(function(n){n.Instant="instant",n.Original="original"})(ta||(ta={}));var Os;(function(n){n.None="none",n.S2="s2"})(Os||(Os={}));var hu;(function(n){n.CreateOrUpdate="",n.Update="update",n.Create="create"})(hu||(hu={}));function oE(n,t={}){return Object.assign({name:n,deliver_policy:wt.All,ack_policy:Dt.Explicit,ack_wait:ft(30*1e3),replay_policy:ta.Instant},t)}var Ig;(function(n){n.API="api_audit",n.StreamAction="stream_action",n.ConsumerAction="consumer_action",n.SnapshotCreate="snapshot_create",n.SnapshotComplete="snapshot_complete",n.RestoreCreate="restore_create",n.RestoreComplete="restore_complete",n.MaxDeliver="max_deliver",n.Terminated="terminated",n.Ack="consumer_ack",n.StreamLeaderElected="stream_leader_elected",n.StreamQuorumLost="stream_quorum_lost",n.ConsumerLeaderElected="consumer_leader_elected",n.ConsumerQuorumLost="consumer_quorum_lost"})(Ig||(Ig={}));var Qt;(function(n){n.StreamSourceHdr="Nats-Stream-Source",n.LastConsumerSeqHdr="Nats-Last-Consumer",n.LastStreamSeqHdr="Nats-Last-Stream",n.ConsumerStalledHdr="Nats-Consumer-Stalled",n.MessageSizeHdr="Nats-Msg-Size",n.RollupHdr="Nats-Rollup",n.RollupValueSubject="sub",n.RollupValueAll="all",n.PendingMessagesHdr="Nats-Pending-Messages",n.PendingBytesHdr="Nats-Pending-Bytes"})(Qt||(Qt={}));var Kn;(function(n){n.LastValue="",n.AllHistory="history",n.UpdatesOnly="updates"})(Kn||(Kn={}));var Vi;(function(n){n.Stream="Nats-Stream",n.Sequence="Nats-Sequence",n.TimeStamp="Nats-Time-Stamp",n.Subject="Nats-Subject"})(Vi||(Vi={}));var $g;(function(n){n.Stream="Nats-Stream",n.Subject="Nats-Subject",n.Sequence="Nats-Sequence",n.LastSequence="Nats-Last-Sequence",n.Size="Nats-Msg-Size"})($g||($g={}));const bn="KV_";class lE{constructor(t){j(this,"config");j(this,"ordered");j(this,"mack");j(this,"stream");j(this,"callbackFn");j(this,"max");j(this,"qname");j(this,"isBind");j(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=oE("",t||{})}getOpts(){var s;const t={};if(t.config=Object.assign({},this.config),t.config.filter_subject&&(this.filterSubject(t.config.filter_subject),t.config.filter_subject=void 0),t.config.filter_subjects&&((s=t.config.filter_subjects)==null||s.forEach(i=>{this.filterSubject(i)}),t.config.filter_subjects=void 0),t.mack=this.mack,t.stream=this.stream,t.callbackFn=this.callbackFn,t.max=this.max,t.queue=this.qname,t.ordered=this.ordered,t.config.ack_policy=t.ordered?Dt.None:t.config.ack_policy,t.isBind=t.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:t.config.filter_subject=this.filters[0];break;default:t.config.filter_subjects=this.filters}return t}description(t){return this.config.description=t,this}deliverTo(t){return this.config.deliver_subject=t,this}durable(t){return Ki(t),this.config.durable_name=t,this}startSequence(t){if(t<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=wt.StartSequence,this.config.opt_start_seq=t,this}startTime(t){return this.config.deliver_policy=wt.StartTime,this.config.opt_start_time=t.toISOString(),this}deliverAll(){return this.config.deliver_policy=wt.All,this}deliverLastPerSubject(){return this.config.deliver_policy=wt.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=wt.Last,this}deliverNew(){return this.config.deliver_policy=wt.New,this}startAtTimeDelta(t){return this.startTime(new Date(Date.now()-t)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=Dt.None,this}ackAll(){return this.config.ack_policy=Dt.All,this}ackExplicit(){return this.config.ack_policy=Dt.Explicit,this}ackWait(t){return this.config.ack_wait=ft(t),this}maxDeliver(t){return this.config.max_deliver=t,this}filterSubject(t){return this.filters=this.filters||[],this.filters.push(t),this}replayInstantly(){return this.config.replay_policy=ta.Instant,this}replayOriginal(){return this.config.replay_policy=ta.Original,this}sample(t){if(t=Math.trunc(t),t<0||t>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${t}%`,this}limit(t){return this.config.rate_limit_bps=t,this}maxWaiting(t){return this.config.max_waiting=t,this}maxAckPending(t){return this.config.max_ack_pending=t,this}idleHeartbeat(t){return this.config.idle_heartbeat=ft(t),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(t){return this.queue(t),this}manualAck(){return this.mack=!0,this}maxMessages(t){return this.max=t,this}callback(t){return this.callbackFn=t,this}queue(t){return this.qname=t,this.config.deliver_group=t,this}orderedConsumer(){return this.ordered=!0,this}bind(t,s){return this.stream=t,this.config.durable_name=s,this.isBind=!0,this}bindStream(t){return this.stream=t,this}inactiveEphemeralThreshold(t){return this.config.inactive_threshold=ft(t),this}maxPullBatch(t){return this.config.max_batch=t,this}maxPullRequestExpires(t){return this.config.max_expires=ft(t),this}memory(){return this.config.mem_storage=!0,this}numReplicas(t){return this.config.num_replicas=t,this}consumerName(t){return this.config.name=t,this}}function _s(n){return new lE(n)}function Hg(n){return typeof n.getOpts=="function"}class cE{static encode(t){if(typeof t=="string")return btoa(t);const s=Array.from(t);return btoa(String.fromCharCode(...s))}static decode(t,s=!1){const i=atob(t);return s?Uint8Array.from(i,o=>o.charCodeAt(0)):i}}class Qi{static encode(t){return Qi.toB64URLEncoding(cE.encode(t))}static decode(t,s=!1){return Qi.decode(Qi.fromB64URLEncoding(t),s)}static toB64URLEncoding(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(t){return t.replace(/_/g,"/").replace(/-/g,"+")}}class na{constructor(){j(this,"buffers");j(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...t){let s=0;for(let c=0;c<t.length;c++)s+=t[c].length;const i=new Uint8Array(s);let o=0;for(let c=0;c<t.length;c++)i.set(t[c],o),o+=t[c].length;return i}static fromAscii(t){return t||(t=""),ei.encode(t)}static toAscii(t){return vn.decode(t)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const t=new Uint8Array(this.byteLength);let s=0;for(let i=0;i<this.buffers.length;i++)t.set(this.buffers[i],s),s+=this.buffers[i].length;this.buffers.length=0,this.buffers.push(t)}}shift(){if(this.buffers.length){const t=this.buffers.shift();if(t)return this.byteLength-=t.length,t}return new Uint8Array(0)}drain(t){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const i=this.byteLength;(t===void 0||t>i)&&(t=i);const o=s.subarray(0,t);return i>t&&this.buffers.push(s.subarray(t)),this.byteLength=i-t,o}}return new Uint8Array(0)}fill(t,...s){t&&(this.buffers.push(t),this.byteLength+=t.length);for(let i=0;i<s.length;i++)s[i]&&s[i].length&&(this.buffers.push(s[i]),this.byteLength+=s[i].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function uE(n,t){return t.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(i){if(i!=="default"&&!(i in n)){var o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return s[i]}})}})}),Object.freeze(n)}var fE=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},no=fE.performance||{};no.now||no.mozNow||no.msNow||no.oNow||no.webkitNow;var Fg={versions:{}},hE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dE(n){if(n.__esModule)return n;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(s){var i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return n[s]}})}),t}var Qh,Ou={exports:{}},Gg={},Vg=dE(uE({__proto__:null,default:Gg},[Gg]));Qh=Ou,(function(){var n="input is invalid type",t=typeof window=="object",s=t?window:{};s.JS_SHA256_NO_WINDOW&&(t=!1);var i=!t&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&Fg.versions&&Fg.versions.node;o?s=hE:i&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&Qh.exports,d=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",y="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],u=[24,16,8,0],m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],b=["hex","array","digest","arrayBuffer"],x=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(D){return Object.prototype.toString.call(D)==="[object Array]"}),!d||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(D){return typeof D=="object"&&D.buffer&&D.buffer.constructor===ArrayBuffer});var v=function(D,$){return function(ee){return new P($,!0).update(ee)[D]()}},_=function(D){var $=v("hex",D);o&&($=S($,D)),$.create=function(){return new P(D)},$.update=function(I){return $.create().update(I)};for(var ee=0;ee<b.length;++ee){var K=b[ee];$[K]=v(K,D)}return $},S=function(D,$){var ee,K=Vg,I=Vg.Buffer,M=$?"sha224":"sha256";return ee=I.from&&!s.JS_SHA256_NO_BUFFER_FROM?I.from:function(J){return new I(J)},function(J){if(typeof J=="string")return K.createHash(M).update(J,"utf8").digest("hex");if(J==null)throw new Error(n);return J.constructor===ArrayBuffer&&(J=new Uint8Array(J)),Array.isArray(J)||ArrayBuffer.isView(J)||J.constructor===I?K.createHash(M).update(ee(J)).digest("hex"):D(J)}},C=function(D,$){return function(ee,K){return new ie(ee,$,!0).update(K)[D]()}},L=function(D){var $=C("hex",D);$.create=function(I){return new ie(I,D)},$.update=function(I,M){return $.create(I).update(M)};for(var ee=0;ee<b.length;++ee){var K=b[ee];$[K]=C(K,D)}return $};function P(D,$){$?(x[0]=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0,this.blocks=x):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],D?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=D}function ie(D,$,ee){var K,I=typeof D;if(I==="string"){var M,J=[],Q=D.length,he=0;for(K=0;K<Q;++K)(M=D.charCodeAt(K))<128?J[he++]=M:M<2048?(J[he++]=192|M>>>6,J[he++]=128|63&M):M<55296||M>=57344?(J[he++]=224|M>>>12,J[he++]=128|M>>>6&63,J[he++]=128|63&M):(M=65536+((1023&M)<<10|1023&D.charCodeAt(++K)),J[he++]=240|M>>>18,J[he++]=128|M>>>12&63,J[he++]=128|M>>>6&63,J[he++]=128|63&M);D=J}else{if(I!=="object")throw new Error(n);if(D===null)throw new Error(n);if(d&&D.constructor===ArrayBuffer)D=new Uint8Array(D);else if(!(Array.isArray(D)||d&&ArrayBuffer.isView(D)))throw new Error(n)}D.length>64&&(D=new P($,!0).update(D).array());var be=[],we=[];for(K=0;K<64;++K){var H=D[K]||0;be[K]=92^H,we[K]=54^H}P.call(this,$,ee),this.update(we),this.oKeyPad=be,this.inner=!0,this.sharedMemory=ee}P.prototype.update=function(D){if(!this.finalized){var $,ee=typeof D;if(ee!=="string"){if(ee!=="object")throw new Error(n);if(D===null)throw new Error(n);if(d&&D.constructor===ArrayBuffer)D=new Uint8Array(D);else if(!(Array.isArray(D)||d&&ArrayBuffer.isView(D)))throw new Error(n);$=!0}for(var K,I,M=0,J=D.length,Q=this.blocks;M<J;){if(this.hashed&&(this.hashed=!1,Q[0]=this.block,this.block=Q[16]=Q[1]=Q[2]=Q[3]=Q[4]=Q[5]=Q[6]=Q[7]=Q[8]=Q[9]=Q[10]=Q[11]=Q[12]=Q[13]=Q[14]=Q[15]=0),$)for(I=this.start;M<J&&I<64;++M)Q[I>>>2]|=D[M]<<u[3&I++];else for(I=this.start;M<J&&I<64;++M)(K=D.charCodeAt(M))<128?Q[I>>>2]|=K<<u[3&I++]:K<2048?(Q[I>>>2]|=(192|K>>>6)<<u[3&I++],Q[I>>>2]|=(128|63&K)<<u[3&I++]):K<55296||K>=57344?(Q[I>>>2]|=(224|K>>>12)<<u[3&I++],Q[I>>>2]|=(128|K>>>6&63)<<u[3&I++],Q[I>>>2]|=(128|63&K)<<u[3&I++]):(K=65536+((1023&K)<<10|1023&D.charCodeAt(++M)),Q[I>>>2]|=(240|K>>>18)<<u[3&I++],Q[I>>>2]|=(128|K>>>12&63)<<u[3&I++],Q[I>>>2]|=(128|K>>>6&63)<<u[3&I++],Q[I>>>2]|=(128|63&K)<<u[3&I++]);this.lastByteIndex=I,this.bytes+=I-this.start,I>=64?(this.block=Q[16],this.start=I-64,this.hash(),this.hashed=!0):this.start=I}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},P.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var D=this.blocks,$=this.lastByteIndex;D[16]=this.block,D[$>>>2]|=g[3&$],this.block=D[16],$>=56&&(this.hashed||this.hash(),D[0]=this.block,D[16]=D[1]=D[2]=D[3]=D[4]=D[5]=D[6]=D[7]=D[8]=D[9]=D[10]=D[11]=D[12]=D[13]=D[14]=D[15]=0),D[14]=this.hBytes<<3|this.bytes>>>29,D[15]=this.bytes<<3,this.hash()}},P.prototype.hash=function(){var D,$,ee,K,I,M,J,Q,he,be=this.h0,we=this.h1,H=this.h2,Z=this.h3,le=this.h4,_e=this.h5,Ee=this.h6,Ne=this.h7,ke=this.blocks;for(D=16;D<64;++D)$=((I=ke[D-15])>>>7|I<<25)^(I>>>18|I<<14)^I>>>3,ee=((I=ke[D-2])>>>17|I<<15)^(I>>>19|I<<13)^I>>>10,ke[D]=ke[D-16]+$+ke[D-7]+ee|0;for(he=we&H,D=0;D<64;D+=4)this.first?(this.is224?(M=300032,Ne=(I=ke[0]-1413257819)-150054599|0,Z=I+24177077|0):(M=704751109,Ne=(I=ke[0]-210244248)-1521486534|0,Z=I+143694565|0),this.first=!1):($=(be>>>2|be<<30)^(be>>>13|be<<19)^(be>>>22|be<<10),K=(M=be&we)^be&H^he,Ne=Z+(I=Ne+(ee=(le>>>6|le<<26)^(le>>>11|le<<21)^(le>>>25|le<<7))+(le&_e^~le&Ee)+m[D]+ke[D])|0,Z=I+($+K)|0),$=(Z>>>2|Z<<30)^(Z>>>13|Z<<19)^(Z>>>22|Z<<10),K=(J=Z&be)^Z&we^M,Ee=H+(I=Ee+(ee=(Ne>>>6|Ne<<26)^(Ne>>>11|Ne<<21)^(Ne>>>25|Ne<<7))+(Ne&le^~Ne&_e)+m[D+1]+ke[D+1])|0,$=((H=I+($+K)|0)>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10),K=(Q=H&Z)^H&be^J,_e=we+(I=_e+(ee=(Ee>>>6|Ee<<26)^(Ee>>>11|Ee<<21)^(Ee>>>25|Ee<<7))+(Ee&Ne^~Ee&le)+m[D+2]+ke[D+2])|0,$=((we=I+($+K)|0)>>>2|we<<30)^(we>>>13|we<<19)^(we>>>22|we<<10),K=(he=we&H)^we&Z^Q,le=be+(I=le+(ee=(_e>>>6|_e<<26)^(_e>>>11|_e<<21)^(_e>>>25|_e<<7))+(_e&Ee^~_e&Ne)+m[D+3]+ke[D+3])|0,be=I+($+K)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+be|0,this.h1=this.h1+we|0,this.h2=this.h2+H|0,this.h3=this.h3+Z|0,this.h4=this.h4+le|0,this.h5=this.h5+_e|0,this.h6=this.h6+Ee|0,this.h7=this.h7+Ne|0},P.prototype.hex=function(){this.finalize();var D=this.h0,$=this.h1,ee=this.h2,K=this.h3,I=this.h4,M=this.h5,J=this.h6,Q=this.h7,he=y[D>>>28&15]+y[D>>>24&15]+y[D>>>20&15]+y[D>>>16&15]+y[D>>>12&15]+y[D>>>8&15]+y[D>>>4&15]+y[15&D]+y[$>>>28&15]+y[$>>>24&15]+y[$>>>20&15]+y[$>>>16&15]+y[$>>>12&15]+y[$>>>8&15]+y[$>>>4&15]+y[15&$]+y[ee>>>28&15]+y[ee>>>24&15]+y[ee>>>20&15]+y[ee>>>16&15]+y[ee>>>12&15]+y[ee>>>8&15]+y[ee>>>4&15]+y[15&ee]+y[K>>>28&15]+y[K>>>24&15]+y[K>>>20&15]+y[K>>>16&15]+y[K>>>12&15]+y[K>>>8&15]+y[K>>>4&15]+y[15&K]+y[I>>>28&15]+y[I>>>24&15]+y[I>>>20&15]+y[I>>>16&15]+y[I>>>12&15]+y[I>>>8&15]+y[I>>>4&15]+y[15&I]+y[M>>>28&15]+y[M>>>24&15]+y[M>>>20&15]+y[M>>>16&15]+y[M>>>12&15]+y[M>>>8&15]+y[M>>>4&15]+y[15&M]+y[J>>>28&15]+y[J>>>24&15]+y[J>>>20&15]+y[J>>>16&15]+y[J>>>12&15]+y[J>>>8&15]+y[J>>>4&15]+y[15&J];return this.is224||(he+=y[Q>>>28&15]+y[Q>>>24&15]+y[Q>>>20&15]+y[Q>>>16&15]+y[Q>>>12&15]+y[Q>>>8&15]+y[Q>>>4&15]+y[15&Q]),he},P.prototype.toString=P.prototype.hex,P.prototype.digest=function(){this.finalize();var D=this.h0,$=this.h1,ee=this.h2,K=this.h3,I=this.h4,M=this.h5,J=this.h6,Q=this.h7,he=[D>>>24&255,D>>>16&255,D>>>8&255,255&D,$>>>24&255,$>>>16&255,$>>>8&255,255&$,ee>>>24&255,ee>>>16&255,ee>>>8&255,255&ee,K>>>24&255,K>>>16&255,K>>>8&255,255&K,I>>>24&255,I>>>16&255,I>>>8&255,255&I,M>>>24&255,M>>>16&255,M>>>8&255,255&M,J>>>24&255,J>>>16&255,J>>>8&255,255&J];return this.is224||he.push(Q>>>24&255,Q>>>16&255,Q>>>8&255,255&Q),he},P.prototype.array=P.prototype.digest,P.prototype.arrayBuffer=function(){this.finalize();var D=new ArrayBuffer(this.is224?28:32),$=new DataView(D);return $.setUint32(0,this.h0),$.setUint32(4,this.h1),$.setUint32(8,this.h2),$.setUint32(12,this.h3),$.setUint32(16,this.h4),$.setUint32(20,this.h5),$.setUint32(24,this.h6),this.is224||$.setUint32(28,this.h7),D},ie.prototype=new P,ie.prototype.finalize=function(){if(P.prototype.finalize.call(this),this.inner){this.inner=!1;var D=this.array();P.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(D),P.prototype.finalize.call(this)}};var oe=_();oe.sha256=oe,oe.sha224=_(!0),oe.sha256.hmac=L(),oe.sha224.hmac=L(!0),c?Qh.exports=oe:(s.sha256=oe.sha256,s.sha224=oe.sha224)})();Ou.exports;Ou.exports.sha224;var Yg=Ou.exports.sha256;function wd(n){return xE(n)}function mE(n){if(!/^[0-9A-Fa-f]+$/.test(n))return!1;const s=/^[0-9A-F]+$/.test(n),i=/^[0-9a-f]+$/.test(n);return s||i?n.length%2===0:!1}function pE(n){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(n)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(n)}function yE(n){return mE(n)?"hex":pE(n)?"b64":""}function gE(n){if(n.length%2!==0)throw new Error("hex string must have an even length");const t=new Uint8Array(n.length/2);for(let s=0;s<n.length;s+=2)t[s/2]=parseInt(n.substring(s,s+2),16);return t}function bE(n){n=n.replace(/-/g,"+"),n=n.replace(/_/g,"/");const t=atob(n);return Uint8Array.from(t,s=>s.charCodeAt(0))}function xE(n){switch(yE(n)){case"hex":return gE(n);case"b64":return bE(n)}return null}function vE(n,t){const s=typeof n=="string"?wd(n):n,i=typeof t=="string"?wd(t):t;if(s===null||i===null||s.length!==i.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==i[o])return!1;return!0}class ux{constructor(t,s,i=!0){j(this,"token");j(this,"received");j(this,"ctx");j(this,"requestSubject");j(this,"mux");this.mux=t,this.requestSubject=s,this.received=0,this.token=Es.next(),i&&(this.ctx=new Error)}}class _E extends ux{constructor(s,i,o={maxWait:1e3}){super(s,i);j(this,"callback");j(this,"done");j(this,"timer");j(this,"max");j(this,"opts");if(this.opts=o,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof o.maxMessages=="number"&&o.maxMessages>0?o.maxMessages:-1,this.done=ht(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},o.maxWait)}cancel(s){s&&this.callback(s,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(s,i){s?(this.ctx&&(s.stack+=`
33
+
34
+ ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,i),this.opts.strategy===Qn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Qn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Qn.SentinelMsg&&i&&i.data.length===0&&this.cancel())}}class fx extends ux{constructor(s,i,o={timeout:1e3},c=!0){super(s,i,c);j(this,"deferred");j(this,"timer");this.deferred=ht(),this.timer=ea(o.timeout,c)}resolver(s,i){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
35
+
36
+ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||pe.errorForCode(ce.Cancelled))}}const wE="$JS.API";function SE(n){return n=n||{},n.domain&&(n.apiPrefix=`$JS.${n.domain}.API`,delete n.domain),Su({apiPrefix:wE,timeout:5e3},n)}class To{constructor(t,s){j(this,"nc");j(this,"opts");j(this,"prefix");j(this,"timeout");j(this,"jc");this.nc=t,this.opts=SE(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=Xn()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let t=this.opts.apiPrefix;if(!t||t.length===0)throw new Error("invalid empty prefix");t[t.length-1]==="."&&(t=t.substr(0,t.length-1)),this.opts.apiPrefix=t}async _request(t,s=null,i){i=i||{},i.timeout=this.timeout;let o=Sn;s&&(o=this.jc.encode(s));let{retries:c}=i;c=c||1,c=c===-1?Number.MAX_SAFE_INTEGER:c;const d=nm();for(let y=0;y<c;y++)try{const g=await this.nc.request(t,o,i);return this.parseJsResponse(g)}catch(g){const u=g;if((u.code==="503"||u.code===ce.Timeout)&&y+1<c)await sa(d.backoff(y));else throw g}}async findStream(t){const s={subject:t},o=await this._request(`${this.prefix}.STREAM.NAMES`,s);if(!o.streams||o.streams.length!==1)throw new Error("no stream matches subject");return o.streams[0]}getConnection(){return this.nc}parseJsResponse(t){const s=this.jc.decode(t.data),i=s;if(i.error){const o=cx(i.error.code,i.error.description);if(o!==null)throw o.api_error=i.error,o}return s}}class po{constructor(t,s,i,o){j(this,"err");j(this,"offset");j(this,"pageInfo");j(this,"subject");j(this,"jsm");j(this,"filter");j(this,"payload");if(!t)throw new Error("subject is required");this.subject=t,this.jsm=i,this.offset=0,this.pageInfo={},this.filter=s,this.payload=o||{}}async next(){if(this.err)return[];if(this.pageInfo&&this.offset>=this.pageInfo.total)return[];const t={offset:this.offset};this.payload&&Object.assign(t,this.payload);try{const s=await this.jsm._request(this.subject,t,{timeout:this.jsm.timeout});this.pageInfo=s;const i=this.countResponse(s);return i===0?[]:(this.offset+=i,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(t){var s,i,o;switch(t==null?void 0:t.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((s=t.streams)==null?void 0:s.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((i=t.consumers)==null?void 0:i.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${t==null?void 0:t.type}`),((o=t.streams)==null?void 0:o.length)||0}return 0}async*[Symbol.asyncIterator](){let t=await this.next();for(;t.length>0;){for(const s of t)yield s;t=await this.next()}}}function Zs(n=""){const t=n.match(/(\d+).(\d+).(\d+)/);if(t)return{major:parseInt(t[1]),minor:parseInt(t[2]),micro:parseInt(t[3])};throw new Error(`'${n}' is not a semver value`)}function Sd(n,t){return n.major<t.major?-1:n.major>t.major?1:n.minor<t.minor?-1:n.minor>t.minor?1:n.micro<t.micro?-1:n.micro>t.micro?1:0}var Ge;(function(n){n.JS_KV="js_kv",n.JS_OBJECTSTORE="js_objectstore",n.JS_PULL_MAX_BYTES="js_pull_max_bytes",n.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",n.JS_ALLOW_DIRECT="js_allow_direct",n.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",n.JS_SIMPLIFICATION="js_simplification",n.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",n.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",n.JS_STREAM_FIRST_SEQ="js_stream_first_seq",n.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",n.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",n.JS_STREAM_COMPRESSION="js_stream_compression",n.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",n.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Ge||(Ge={}));class EE{constructor(t){j(this,"server");j(this,"features");j(this,"disabled");this.features=new Map,this.disabled=[],this.update(t)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(t){this.disabled.push(t),this.update(this.server)}isDisabled(t){return this.disabled.indexOf(t)!==-1}update(t){typeof t=="string"&&(t=Zs(t)),this.server=t,this.set(Ge.JS_KV,"2.6.2"),this.set(Ge.JS_OBJECTSTORE,"2.6.3"),this.set(Ge.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Ge.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Ge.JS_ALLOW_DIRECT,"2.9.0"),this.set(Ge.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Ge.JS_SIMPLIFICATION,"2.9.4"),this.set(Ge.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Ge.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Ge.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Ge.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ge.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ge.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Ge.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Ge.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(s=>{this.features.delete(s)})}set(t,s){this.features.set(t,{min:s,ok:Sd(this.server,Zs(s))>=0})}get(t){return this.features.get(t)||{min:"unknown",ok:!1}}supports(t){var s;return((s=this.get(t))==null?void 0:s.ok)||!1}require(t){return typeof t=="string"&&(t=Zs(t)),Sd(this.server,t)>=0}}class du extends To{constructor(t,s){super(t,s)}async add(t,s,i=hu.Create){if(Yt(t),s.deliver_group&&s.flow_control)throw new Error("jetstream flow control is not supported with queue groups");if(s.deliver_group&&s.idle_heartbeat)throw new Error("jetstream idle heartbeat is not supported with queue groups");const o={};o.config=s,o.stream_name=t,o.action=i,o.config.durable_name&&Ki(o.config.durable_name);const c=this.nc;let{min:d,ok:y}=c.features.get(Ge.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!y)throw new Error(`consumer 'name' requires server ${d}`);if(g)try{Eu("name",g)}catch(x){const v=x.message,_=v.indexOf("cannot contain");throw _!==-1?new Error(`consumer 'name' ${v.substring(_)}`):x}let u,m="";if(Array.isArray(s.filter_subjects)){const{min:x,ok:v}=c.features.get(Ge.JS_MULTIPLE_CONSUMER_FILTER);if(!v)throw new Error(`consumer 'filter_subjects' requires server ${x}`);y=!1}if(s.metadata){const{min:x,ok:v}=c.features.get(Ge.JS_STREAM_CONSUMER_METADATA);if(!v)throw new Error(`consumer 'metadata' requires server ${x}`)}if(y&&(m=s.name??s.durable_name??""),m!==""){let x=s.filter_subject??void 0;x===">"&&(x=void 0),u=x!==void 0?`${this.prefix}.CONSUMER.CREATE.${t}.${m}.${x}`:`${this.prefix}.CONSUMER.CREATE.${t}.${m}`}else u=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${t}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${t}`;return await this._request(u,o)}async update(t,s,i){const o=await this.info(t,s),c=i;return this.add(t,Object.assign(o.config,c),hu.Update)}async info(t,s){return Yt(t),Ki(s),await this._request(`${this.prefix}.CONSUMER.INFO.${t}.${s}`)}async delete(t,s){return Yt(t),Ki(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${t}.${s}`)).success}list(t){Yt(t);const s=o=>o.consumers,i=`${this.prefix}.CONSUMER.LIST.${t}`;return new po(i,s,this)}pause(t,s,i){const o=`${this.prefix}.CONSUMER.PAUSE.${t}.${s}`,c={pause_until:i.toISOString()};return this._request(o,c)}resume(t,s){return this.pause(t,s,new Date(0))}}function zi(n,t,s=!1){if(s===!0&&!n)throw pe.errorForCode(ce.ApiError,new Error(`${t} is not a function`));if(n&&typeof n!="function")throw pe.errorForCode(ce.ApiError,new Error(`${t} is not a function`))}class OE extends qt{constructor(s,i,o){super();j(this,"sub");j(this,"adapter");j(this,"subIterDone");zi(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&zi(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&(zi(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&(zi(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&(zi(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&zi(o.cleanupFn,"cleanupFn");let c=(m,b)=>{this.callback(m,b)};if(o.callback){const m=o.callback;c=(b,x)=>{const[v,_]=this.adapter(b,x);if(v){m(v,null);return}const{ingest:S}=this.ingestionFilterFn?this.ingestionFilterFn(_,this):{ingest:!0};S&&(!this.protocolFilterFn||this.protocolFilterFn(_))&&(m(v,_),this.dispatchedFn&&_&&this.dispatchedFn(_))}}const{max:d,queue:y,timeout:g}=o,u={queue:y,timeout:g,callback:c};d&&d>0&&(u.max=d),this.sub=s.subscribe(i,u),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=ht(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async m=>{await m.closed,this.stop()})(this.sub).then().catch()}unsubscribe(s){this.sub.unsubscribe(s)}drain(){return this.sub.drain()}isDraining(){return this.sub.isDraining()}isClosed(){return this.sub.isClosed()}callback(s,i){this.sub.cancelTimeout();const[o,c]=this.adapter(s,i);o&&this.stop(o),c&&this.push(c)}getSubject(){return this.sub.getSubject()}getReceived(){return this.sub.getReceived()}getProcessed(){return this.sub.getProcessed()}getPending(){return this.sub.getPending()}getID(){return this.sub.getID()}getMax(){return this.sub.getMax()}get closed(){return this.sub.closed}}let _n;function AE(n){_n=n}function hx(){return _n!==void 0&&_n.defaultPort!==void 0?_n.defaultPort:4222}function Xh(){return _n!==void 0&&_n.urlParseFn?_n.urlParseFn:void 0}function jE(){if(!_n||typeof _n.factory!="function")throw new Error("transport fn is not set");return _n.factory()}function Ed(){return _n!==void 0&&_n.dnsResolveFn?_n.dnsResolveFn:void 0}const nu=`\r
37
+ `,mu=na.fromAscii(nu),kE=new Uint8Array(mu)[0],NE=new Uint8Array(mu)[1];function TE(n){for(let t=0;t<n.length;t++){const s=t+1;if(n.byteLength>s&&n[t]===kE&&n[s]===NE)return s+1}return 0}function CE(n){const t=TE(n);if(t>0){const i=new Uint8Array(n).slice(0,t);return vn.decode(i)}return""}const ME=4,dx=48,RE=65,DE=97;function qE(n,t,s,i){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((d,y)=>{o[y]=d}),o[12]=n,o[13]=t,o[14]=s,o[15]=i,o}function Od(n){return LE(n)!==void 0}function LE(n){for(let t=0;t<n.length;t++)switch(n[t]){case".":return mx(n);case":":return BE(n)}}function mx(n){const t=new Uint8Array(4);for(let s=0;s<4;s++){if(n.length===0)return;if(s>0){if(n[0]!==".")return;n=n.substring(1)}const{n:i,c:o,ok:c}=PE(n);if(!c||i>255)return;n=n.substring(o),t[s]=i}return qE(t[0],t[1],t[2],t[3])}function BE(n){const t=new Uint8Array(16);let s=-1;if(n.length>=2&&n[0]===":"&&n[1]===":"&&(s=0,n=n.substring(2),n.length===0))return t;let i=0;for(;i<16;){const{n:o,c,ok:d}=UE(n);if(!d||o>65535)return;if(c<n.length&&n[c]==="."){if(s<0&&i!=12||i+4>16)return;const y=mx(n);if(y===void 0)return;t[i]=y[12],t[i+1]=y[13],t[i+2]=y[14],t[i+3]=y[15],n="",i+=ME;break}if(t[i]=o>>8,t[i+1]=o,i+=2,n=n.substring(c),n.length===0)break;if(n[0]!==":"||n.length==1)return;if(n=n.substring(1),n[0]===":"){if(s>=0)return;if(s=i,n=n.substring(1),n.length===0)break}}if(n.length===0){if(i<16){if(s<0)return;const o=16-i;for(let c=i-1;c>=s;c--)t[c+o]=t[c];for(let c=s+o-1;c>=s;c--)t[c]=0}else if(s>=0)return;return t}}function PE(n){let t=0,s=0;for(t=0;t<n.length&&48<=n.charCodeAt(t)&&n.charCodeAt(t)<=57;t++)if(s=s*10+(n.charCodeAt(t)-dx),s>=16777215)return{n:16777215,c:t,ok:!1};return t===0?{n:0,c:0,ok:!1}:{n:s,c:t,ok:!0}}function UE(n){let t=0,s=0;for(s=0;s<n.length;s++){if(48<=n.charCodeAt(s)&&n.charCodeAt(s)<=57)t*=16,t+=n.charCodeAt(s)-dx;else if(97<=n.charCodeAt(s)&&n.charCodeAt(s)<=102)t*=16,t+=n.charCodeAt(s)-DE+10;else if(65<=n.charCodeAt(s)&&n.charCodeAt(s)<=70)t*=16,t+=n.charCodeAt(s)-RE+10;else break;if(t>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n:t,c:s,ok:!0}}function zE(n){return n.indexOf("[")!==-1||n.indexOf("::")!==-1?!1:n.indexOf(".")!==-1||n.split(":").length<=2}function Ad(n){return!zE(n)}function IE(n){const t="::FFFF:",s=n.toUpperCase().indexOf(t);if(s!==-1&&n.indexOf(".")!==-1){let i=n.substring(s+t.length);return i=i.replace("[",""),i.replace("]","")}return n}function $E(n){n=n.trim(),n.match(/^(.*:\/\/)(.*)/m)&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2")),n=IE(n),Ad(n)&&n.indexOf("[")===-1&&(n=`[${n}]`);const t=Ad(n)?n.match(/(]:)(\d+)/):n.match(/(:)(\d+)/),s=t&&t.length===3&&t[1]&&t[2]?parseInt(t[2]):4222,i=s===80?"https":"http",o=new URL(`${i}://${n}`);o.port=`${s}`;let c=o.hostname;return c.charAt(0)==="["&&(c=c.substring(1,c.length-1)),{listen:o.host,hostname:c,port:s}}class xo{constructor(t,s=!1){j(this,"src");j(this,"listen");j(this,"hostname");j(this,"port");j(this,"didConnect");j(this,"reconnects");j(this,"lastConnect");j(this,"gossiped");j(this,"tlsName");j(this,"resolves");this.src=t,this.tlsName="";const i=$E(t);this.listen=i.listen,this.hostname=i.hostname,this.port=i.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(t){if(!t.fn||t.resolve===!1)return[this];const s=[];if(Od(this.hostname))return[this];{const i=await t.fn(this.hostname);t.debug&&console.log(`resolve ${this.hostname} = ${i.join(",")}`);for(const o of i){const c=this.port===80?"https":"http",d=new URL(`${c}://${Ad(o)?"["+o+"]":o}`);d.port=`${this.port}`;const y=new xo(d.host,!1);y.tlsName=this.hostname,s.push(y)}}return t.randomize&&ox(s),this.resolves=s,s}}class HE{constructor(t=[],s={}){j(this,"firstSelect");j(this,"servers");j(this,"currentServer");j(this,"tlsName");j(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const i=Xh();t&&(t.forEach(o=>{o=i?i(o):o,this.servers.push(new xo(o))}),this.randomize&&(this.servers=ox(this.servers))),this.servers.length===0&&this.addServer(`${yd}:${hx()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const t=this.getCurrentServer();Od(t.hostname)||(this.tlsName=t.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(t,s=!1){const i=Xh();t=i?i(t):t;const o=new xo(t,s);Od(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const t=this.servers.shift();return t&&(this.servers.push(t),this.currentServer=t),t}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(t){if(t){const s=this.servers.indexOf(t);this.servers.splice(s,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(t,s){const i=[];let o=[];const c=Xh(),d=new Map;t.connect_urls&&t.connect_urls.length>0&&t.connect_urls.forEach(g=>{g=c?c(g,s):g;const u=new xo(g,!0);d.set(g,u)});const y=[];return this.servers.forEach((g,u)=>{const m=g.listen;g.gossiped&&this.currentServer.listen!==m&&d.get(m)===void 0&&y.push(u),d.delete(m)}),y.reverse(),y.forEach(g=>{const u=this.servers.splice(g,1);o=o.concat(u[0].listen)}),d.forEach((g,u)=>{this.servers.push(g),i.push(u)}),{added:i,deleted:o}}}class FE{constructor(){j(this,"baseInbox");j(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(t){return this.baseInbox=`${Rr(t)}.`,this.baseInbox}add(t){isNaN(t.received)||(t.received=0),this.reqs.set(t.token,t)}get(t){return this.reqs.get(t)}cancel(t){this.reqs.delete(t.token)}getToken(t){const s=t.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(t,s){if(s&&s.permissionContext){if(t)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const i=s.permissionContext;if(i.operation==="publish"){const o=this.all().find(c=>c.requestSubject===i.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(t,s)=>{const i=this.getToken(s);if(i){const o=this.get(i);o&&(t===null&&s.headers&&(t=lx(s)),o.resolver(t,s))}}}close(){const t=pe.errorForCode(ce.Timeout);this.reqs.forEach(s=>{s.resolver(t,{})})}}class GE{constructor(t,s,i){j(this,"ph");j(this,"interval");j(this,"maxOut");j(this,"timer");j(this,"pendings");this.ph=t,this.interval=s,this.maxOut=i,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(t){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),t&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:Yi.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const t=ht();this.ph.flush(t).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(t),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(t=>(t.resolve(),!1))}}class VE extends Error{constructor(t){super(t),this.name="AssertionError"}}function YE(n,t="Assertion failed."){if(!n)throw new VE(t)}const Kg=32*1024,Wh=2**32-2;function ic(n,t,s=0){const i=t.byteLength-s;return n.byteLength>i&&(n=n.subarray(0,i)),t.set(n,s),n.byteLength}class Zh{constructor(t){j(this,"_buf");j(this,"_off");if(this._off=0,t==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(t)}bytes(t={copy:!0}){return t.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(t){if(t===0){this.reset();return}if(t<0||t>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+t)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(t){const s=this._buf.byteLength;return t<=this.capacity-s?(this._reslice(s+t),s):-1}_reslice(t){YE(t<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,t)}readByte(){const t=new Uint8Array(1);return this.read(t)?t[0]:null}read(t){if(this.empty())return this.reset(),t.byteLength===0?0:null;const s=ic(this._buf.subarray(this._off),t);return this._off+=s,s}writeByte(t){return this.write(Uint8Array.of(t))}writeString(t){return this.write(ei.encode(t))}write(t){const s=this._grow(t.byteLength);return ic(t,this._buf,s)}_grow(t){const s=this.length;s===0&&this._off!==0&&this.reset();const i=this._tryGrowByReslice(t);if(i>=0)return i;const o=this.capacity;if(t<=Math.floor(o/2)-s)ic(this._buf.subarray(this._off),this._buf);else{if(o+t>Wh)throw new Error("The buffer cannot be grown beyond the maximum size.");{const c=new Uint8Array(Math.min(2*o+t,Wh));ic(this._buf.subarray(this._off),c),this._buf=c}}return this._off=0,this._reslice(Math.min(s+t,Wh)),s}grow(t){if(t<0)throw Error("Buffer._grow: negative count");const s=this._grow(t);this._reslice(s)}readFrom(t){let s=0;const i=new Uint8Array(Kg);for(;;){const o=this.capacity-this.length<Kg,c=o?i:new Uint8Array(this._buf.buffer,this.length),d=t.read(c);if(d===null)return s;o?this.write(c.subarray(0,d)):this._reslice(this.length+d),s+=d}}}var Kt;(function(n){n[n.OK=0]="OK",n[n.ERR=1]="ERR",n[n.MSG=2]="MSG",n[n.INFO=3]="INFO",n[n.PING=4]="PING",n[n.PONG=5]="PONG"})(Kt||(Kt={}));function Jg(){const n={};return n.sid=-1,n.hdr=-1,n.size=-1,n}const KE=48;class Qg{constructor(t){j(this,"dispatcher");j(this,"state");j(this,"as");j(this,"drop");j(this,"hdr");j(this,"ma");j(this,"argBuf");j(this,"msgBuf");this.dispatcher=t,this.state=de.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(t){let s;for(s=0;s<t.length;s++){const i=t[s];switch(this.state){case de.OP_START:switch(i){case me.M:case me.m:this.state=de.OP_M,this.hdr=-1,this.ma=Jg();break;case me.H:case me.h:this.state=de.OP_H,this.hdr=0,this.ma=Jg();break;case me.P:case me.p:this.state=de.OP_P;break;case me.PLUS:this.state=de.OP_PLUS;break;case me.MINUS:this.state=de.OP_MINUS;break;case me.I:case me.i:this.state=de.OP_I;break;default:throw this.fail(t.subarray(s))}break;case de.OP_H:switch(i){case me.M:case me.m:this.state=de.OP_M;break;default:throw this.fail(t.subarray(s))}break;case de.OP_M:switch(i){case me.S:case me.s:this.state=de.OP_MS;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MS:switch(i){case me.G:case me.g:this.state=de.OP_MSG;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MSG:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MSG_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MSG_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MSG_ARG,this.as=s}break;case de.MSG_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{const o=this.argBuf?this.argBuf.bytes():t.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=de.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;case de.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Kt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const c=t.length-s;c<o&&(o=c),o>0?(this.msgBuf.write(t.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(i)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Kt.MSG,msg:this.ma,data:t.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END);break;case de.MSG_END:switch(i){case me.NL:this.drop=0,this.as=s+1,this.state=de.OP_START;break;default:continue}break;case de.OP_PLUS:switch(i){case me.O:case me.o:this.state=de.OP_PLUS_O;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PLUS_O:switch(i){case me.K:case me.k:this.state=de.OP_PLUS_OK;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PLUS_OK:switch(i){case me.NL:this.dispatcher.push({kind:Kt.OK}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_MINUS:switch(i){case me.E:case me.e:this.state=de.OP_MINUS_E;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_E:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ER;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ER:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ERR;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ERR:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MINUS_ERR_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_MINUS_ERR_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MINUS_ERR_ARG,this.as=s}break;case de.MINUS_ERR_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=t.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Kt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(i))}break;case de.OP_P:switch(i){case me.I:case me.i:this.state=de.OP_PI;break;case me.O:case me.o:this.state=de.OP_PO;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PO:switch(i){case me.N:case me.n:this.state=de.OP_PON;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PON:switch(i){case me.G:case me.g:this.state=de.OP_PONG;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PONG:switch(i){case me.NL:this.dispatcher.push({kind:Kt.PONG}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_PI:switch(i){case me.N:case me.n:this.state=de.OP_PIN;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PIN:switch(i){case me.G:case me.g:this.state=de.OP_PING;break;default:throw this.fail(t.subarray(s))}break;case de.OP_PING:switch(i){case me.NL:this.dispatcher.push({kind:Kt.PING}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_I:switch(i){case me.N:case me.n:this.state=de.OP_IN;break;default:throw this.fail(t.subarray(s))}break;case de.OP_IN:switch(i){case me.F:case me.f:this.state=de.OP_INF;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INF:switch(i){case me.O:case me.o:this.state=de.OP_INFO;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INFO:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_INFO_SPC;break;default:throw this.fail(t.subarray(s))}break;case de.OP_INFO_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.INFO_ARG,this.as=s}break;case de.INFO_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=t.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Kt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;default:throw this.fail(t.subarray(s))}}(this.state===de.MSG_ARG||this.state===de.MINUS_ERR_ARG||this.state===de.INFO_ARG)&&!this.argBuf&&(this.argBuf=new Zh(t.subarray(this.as,s-this.drop))),this.state===de.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new Zh(t.subarray(this.as)))}cloneMsgArg(){const t=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,i=new Uint8Array(t+s);i.set(this.ma.subject),this.ma.reply&&i.set(this.ma.reply,t),this.argBuf=new Zh(i),this.ma.subject=i.subarray(0,t),this.ma.reply&&(this.ma.reply=i.subarray(t))}processMsgArgs(t){if(this.hdr>=0)return this.processHeaderMsgArgs(t);const s=[];let i=-1;for(let o=0;o<t.length;o++)switch(t[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(t.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(t.subarray(i)),s.length){case 3:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(s[2]);break;case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.size=this.protoParseInt(s[3]);break;default:throw this.fail(t,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(t,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(t,"processMsgArgs Bad or Missing Size Error")}fail(t,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${vn.decode(t)}`)}processHeaderMsgArgs(t){const s=[];let i=-1;for(let o=0;o<t.length;o++)switch(t[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(t.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(t.subarray(i)),s.length){case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(s[2]),this.ma.size=this.protoParseInt(s[3]);break;case 5:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.hdr=this.protoParseInt(s[3]),this.ma.size=this.protoParseInt(s[4]);break;default:throw this.fail(t,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(t,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(t){if(t.length===0)return-1;let s=0;for(let i=0;i<t.length;i++){if(t[i]<48||t[i]>57)return-1;s=s*10+(t[i]-KE)}return s}}var de;(function(n){n[n.OP_START=0]="OP_START",n[n.OP_PLUS=1]="OP_PLUS",n[n.OP_PLUS_O=2]="OP_PLUS_O",n[n.OP_PLUS_OK=3]="OP_PLUS_OK",n[n.OP_MINUS=4]="OP_MINUS",n[n.OP_MINUS_E=5]="OP_MINUS_E",n[n.OP_MINUS_ER=6]="OP_MINUS_ER",n[n.OP_MINUS_ERR=7]="OP_MINUS_ERR",n[n.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",n[n.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",n[n.OP_M=10]="OP_M",n[n.OP_MS=11]="OP_MS",n[n.OP_MSG=12]="OP_MSG",n[n.OP_MSG_SPC=13]="OP_MSG_SPC",n[n.MSG_ARG=14]="MSG_ARG",n[n.MSG_PAYLOAD=15]="MSG_PAYLOAD",n[n.MSG_END=16]="MSG_END",n[n.OP_H=17]="OP_H",n[n.OP_P=18]="OP_P",n[n.OP_PI=19]="OP_PI",n[n.OP_PIN=20]="OP_PIN",n[n.OP_PING=21]="OP_PING",n[n.OP_PO=22]="OP_PO",n[n.OP_PON=23]="OP_PON",n[n.OP_PONG=24]="OP_PONG",n[n.OP_I=25]="OP_I",n[n.OP_IN=26]="OP_IN",n[n.OP_INF=27]="OP_INF",n[n.OP_INFO=28]="OP_INFO",n[n.OP_INFO_SPC=29]="OP_INFO_SPC",n[n.INFO_ARG=30]="INFO_ARG"})(de||(de={}));var me;(function(n){n[n.CR=13]="CR",n[n.E=69]="E",n[n.e=101]="e",n[n.F=70]="F",n[n.f=102]="f",n[n.G=71]="G",n[n.g=103]="g",n[n.H=72]="H",n[n.h=104]="h",n[n.I=73]="I",n[n.i=105]="i",n[n.K=75]="K",n[n.k=107]="k",n[n.M=77]="M",n[n.m=109]="m",n[n.MINUS=45]="MINUS",n[n.N=78]="N",n[n.n=110]="n",n[n.NL=10]="NL",n[n.O=79]="O",n[n.o=111]="o",n[n.P=80]="P",n[n.p=112]="p",n[n.PLUS=43]="PLUS",n[n.R=82]="R",n[n.r=114]="r",n[n.S=83]="S",n[n.s=115]="s",n[n.SPACE=32]="SPACE",n[n.TAB=9]="TAB"})(me||(me={}));(function(n){var t=function(A,N){this.hi=A|0,this.lo=N|0},s=function(A){var N,k=new Float64Array(16);if(A)for(N=0;N<A.length;N++)k[N]=A[N];return k},i=function(){throw new Error("no PRNG")},o=new Uint8Array(16),c=new Uint8Array(32);c[0]=9;var d=s(),y=s([1]),g=s([56129,1]),u=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),x=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function _(A,N){return A<<N|A>>>32-N}function S(A,N){var k=A[N+3]&255;return k=k<<8|A[N+2]&255,k=k<<8|A[N+1]&255,k<<8|A[N+0]&255}function C(A,N){var k=A[N]<<24|A[N+1]<<16|A[N+2]<<8|A[N+3],T=A[N+4]<<24|A[N+5]<<16|A[N+6]<<8|A[N+7];return new t(k,T)}function L(A,N,k){var T;for(T=0;T<4;T++)A[N+T]=k&255,k>>>=8}function P(A,N,k){A[N]=k.hi>>24&255,A[N+1]=k.hi>>16&255,A[N+2]=k.hi>>8&255,A[N+3]=k.hi&255,A[N+4]=k.lo>>24&255,A[N+5]=k.lo>>16&255,A[N+6]=k.lo>>8&255,A[N+7]=k.lo&255}function ie(A,N,k,T,q){var z,re=0;for(z=0;z<q;z++)re|=A[N+z]^k[T+z];return(1&re-1>>>8)-1}function oe(A,N,k,T){return ie(A,N,k,T,16)}function D(A,N,k,T){return ie(A,N,k,T,32)}function $(A,N,k,T,q){var z=new Uint32Array(16),re=new Uint32Array(16),ae=new Uint32Array(16),Y=new Uint32Array(4),ne,ye,Re;for(ne=0;ne<4;ne++)re[5*ne]=S(T,4*ne),re[1+ne]=S(k,4*ne),re[6+ne]=S(N,4*ne),re[11+ne]=S(k,16+4*ne);for(ne=0;ne<16;ne++)ae[ne]=re[ne];for(ne=0;ne<20;ne++){for(ye=0;ye<4;ye++){for(Re=0;Re<4;Re++)Y[Re]=re[(5*ye+4*Re)%16];for(Y[1]^=_(Y[0]+Y[3]|0,7),Y[2]^=_(Y[1]+Y[0]|0,9),Y[3]^=_(Y[2]+Y[1]|0,13),Y[0]^=_(Y[3]+Y[2]|0,18),Re=0;Re<4;Re++)z[4*ye+(ye+Re)%4]=Y[Re]}for(Re=0;Re<16;Re++)re[Re]=z[Re]}if(q){for(ne=0;ne<16;ne++)re[ne]=re[ne]+ae[ne]|0;for(ne=0;ne<4;ne++)re[5*ne]=re[5*ne]-S(T,4*ne)|0,re[6+ne]=re[6+ne]-S(N,4*ne)|0;for(ne=0;ne<4;ne++)L(A,4*ne,re[5*ne]),L(A,16+4*ne,re[6+ne])}else for(ne=0;ne<16;ne++)L(A,4*ne,re[ne]+ae[ne]|0)}function ee(A,N,k,T){return $(A,N,k,T,!1),0}function K(A,N,k,T){return $(A,N,k,T,!0),0}var I=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function M(A,N,k,T,q,z,re){var ae=new Uint8Array(16),Y=new Uint8Array(64),ne,ye;if(!q)return 0;for(ye=0;ye<16;ye++)ae[ye]=0;for(ye=0;ye<8;ye++)ae[ye]=z[ye];for(;q>=64;){for(ee(Y,ae,re,I),ye=0;ye<64;ye++)A[N+ye]=(k?k[T+ye]:0)^Y[ye];for(ne=1,ye=8;ye<16;ye++)ne=ne+(ae[ye]&255)|0,ae[ye]=ne&255,ne>>>=8;q-=64,N+=64,k&&(T+=64)}if(q>0)for(ee(Y,ae,re,I),ye=0;ye<q;ye++)A[N+ye]=(k?k[T+ye]:0)^Y[ye];return 0}function J(A,N,k,T,q){return M(A,N,null,0,k,T,q)}function Q(A,N,k,T,q){var z=new Uint8Array(32);return K(z,T,q,I),J(A,N,k,T.subarray(16),z)}function he(A,N,k,T,q,z,re){var ae=new Uint8Array(32);return K(ae,z,re,I),M(A,N,k,T,q,z.subarray(16),ae)}function be(A,N){var k,T=0;for(k=0;k<17;k++)T=T+(A[k]+N[k]|0)|0,A[k]=T&255,T>>>=8}var we=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function H(A,N,k,T,q,z){var re,ae,Y,ne,ye=new Uint32Array(17),Re=new Uint32Array(17),it=new Uint32Array(17),Ft=new Uint32Array(17),Hn=new Uint32Array(17);for(Y=0;Y<17;Y++)Re[Y]=it[Y]=0;for(Y=0;Y<16;Y++)Re[Y]=z[Y];for(Re[3]&=15,Re[4]&=252,Re[7]&=15,Re[8]&=252,Re[11]&=15,Re[12]&=252,Re[15]&=15;q>0;){for(Y=0;Y<17;Y++)Ft[Y]=0;for(Y=0;Y<16&&Y<q;++Y)Ft[Y]=k[T+Y];for(Ft[Y]=1,T+=Y,q-=Y,be(it,Ft),ae=0;ae<17;ae++)for(ye[ae]=0,Y=0;Y<17;Y++)ye[ae]=ye[ae]+it[Y]*(Y<=ae?Re[ae-Y]:320*Re[ae+17-Y]|0)|0|0;for(ae=0;ae<17;ae++)it[ae]=ye[ae];for(ne=0,Y=0;Y<16;Y++)ne=ne+it[Y]|0,it[Y]=ne&255,ne>>>=8;for(ne=ne+it[16]|0,it[16]=ne&3,ne=5*(ne>>>2)|0,Y=0;Y<16;Y++)ne=ne+it[Y]|0,it[Y]=ne&255,ne>>>=8;ne=ne+it[16]|0,it[16]=ne}for(Y=0;Y<17;Y++)Hn[Y]=it[Y];for(be(it,we),re=-(it[16]>>>7)|0,Y=0;Y<17;Y++)it[Y]^=re&(Hn[Y]^it[Y]);for(Y=0;Y<16;Y++)Ft[Y]=z[Y+16];for(Ft[16]=0,be(it,Ft),Y=0;Y<16;Y++)A[N+Y]=it[Y];return 0}function Z(A,N,k,T,q,z){var re=new Uint8Array(16);return H(re,0,k,T,q,z),oe(A,N,re,0)}function le(A,N,k,T,q){var z;if(k<32)return-1;for(he(A,0,N,0,k,T,q),H(A,16,A,32,k-32,A),z=0;z<16;z++)A[z]=0;return 0}function _e(A,N,k,T,q){var z,re=new Uint8Array(32);if(k<32||(Q(re,0,32,T,q),Z(N,16,N,32,k-32,re)!==0))return-1;for(he(A,0,N,0,k,T,q),z=0;z<32;z++)A[z]=0;return 0}function Ee(A,N){var k;for(k=0;k<16;k++)A[k]=N[k]|0}function Ne(A){var N,k;for(k=0;k<16;k++)A[k]+=65536,N=Math.floor(A[k]/65536),A[(k+1)*(k<15?1:0)]+=N-1+37*(N-1)*(k===15?1:0),A[k]-=N*65536}function ke(A,N,k){for(var T,q=~(k-1),z=0;z<16;z++)T=q&(A[z]^N[z]),A[z]^=T,N[z]^=T}function Te(A,N){var k,T,q,z=s(),re=s();for(k=0;k<16;k++)re[k]=N[k];for(Ne(re),Ne(re),Ne(re),T=0;T<2;T++){for(z[0]=re[0]-65517,k=1;k<15;k++)z[k]=re[k]-65535-(z[k-1]>>16&1),z[k-1]&=65535;z[15]=re[15]-32767-(z[14]>>16&1),q=z[15]>>16&1,z[14]&=65535,ke(re,z,1-q)}for(k=0;k<16;k++)A[2*k]=re[k]&255,A[2*k+1]=re[k]>>8}function st(A,N){var k=new Uint8Array(32),T=new Uint8Array(32);return Te(k,A),Te(T,N),D(k,0,T,0)}function Nt(A){var N=new Uint8Array(32);return Te(N,A),N[0]&1}function Bt(A,N){var k;for(k=0;k<16;k++)A[k]=N[2*k]+(N[2*k+1]<<8);A[15]&=32767}function gt(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]+k[T]|0}function bt(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]-k[T]|0}function ue(A,N,k){var T,q,z=new Float64Array(31);for(T=0;T<31;T++)z[T]=0;for(T=0;T<16;T++)for(q=0;q<16;q++)z[T+q]+=N[T]*k[q];for(T=0;T<15;T++)z[T]+=38*z[T+16];for(T=0;T<16;T++)A[T]=z[T];Ne(A),Ne(A)}function Je(A,N){ue(A,N,N)}function jn(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=253;T>=0;T--)Je(k,k),T!==2&&T!==4&&ue(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function lr(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=250;T>=0;T--)Je(k,k),T!==1&&ue(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function ve(A,N,k){var T=new Uint8Array(32),q=new Float64Array(80),z,re,ae=s(),Y=s(),ne=s(),ye=s(),Re=s(),it=s();for(re=0;re<31;re++)T[re]=N[re];for(T[31]=N[31]&127|64,T[0]&=248,Bt(q,k),re=0;re<16;re++)Y[re]=q[re],ye[re]=ae[re]=ne[re]=0;for(ae[0]=ye[0]=1,re=254;re>=0;--re)z=T[re>>>3]>>>(re&7)&1,ke(ae,Y,z),ke(ne,ye,z),gt(Re,ae,ne),bt(ae,ae,ne),gt(ne,Y,ye),bt(Y,Y,ye),Je(ye,Re),Je(it,ae),ue(ae,ne,ae),ue(ne,Y,Re),gt(Re,ae,ne),bt(ae,ae,ne),Je(Y,ae),bt(ne,ye,it),ue(ae,ne,g),gt(ae,ae,ye),ue(ne,ne,ae),ue(ae,ye,it),ue(ye,Y,q),Je(Y,Re),ke(ae,Y,z),ke(ne,ye,z);for(re=0;re<16;re++)q[re+16]=ae[re],q[re+32]=ne[re],q[re+48]=Y[re],q[re+64]=ye[re];var Ft=q.subarray(32),Hn=q.subarray(16);return jn(Ft,Ft),ue(Hn,Hn,Ft),Te(A,Hn),0}function Fe(A,N){return ve(A,N,c)}function St(A,N){return i(N,32),Fe(A,N)}function lt(A,N,k){var T=new Uint8Array(32);return ve(T,k,N),K(A,o,T,I)}var Pr=le,Bo=_e;function oa(A,N,k,T,q,z){var re=new Uint8Array(32);return lt(re,q,z),Pr(A,N,k,T,re)}function la(A,N,k,T,q,z){var re=new Uint8Array(32);return lt(re,q,z),Bo(A,N,k,T,re)}function cr(){var A=0,N=0,k=0,T=0,q=65535,z,re,ae;for(ae=0;ae<arguments.length;ae++)z=arguments[ae].lo,re=arguments[ae].hi,A+=z&q,N+=z>>>16,k+=re&q,T+=re>>>16;return N+=A>>>16,k+=N>>>16,T+=k>>>16,new t(k&q|T<<16,A&q|N<<16)}function Po(A,N){return new t(A.hi>>>N,A.lo>>>N|A.hi<<32-N)}function ni(){var A=0,N=0,k;for(k=0;k<arguments.length;k++)A^=arguments[k].lo,N^=arguments[k].hi;return new t(N,A)}function ct(A,N){var k,T,q=32-N;return N<32?(k=A.hi>>>N|A.lo<<q,T=A.lo>>>N|A.hi<<q):N<64&&(k=A.lo>>>N|A.hi<<q,T=A.hi>>>N|A.lo<<q),new t(k,T)}function Du(A,N,k){var T=A.hi&N.hi^~A.hi&k.hi,q=A.lo&N.lo^~A.lo&k.lo;return new t(T,q)}function Uo(A,N,k){var T=A.hi&N.hi^A.hi&k.hi^N.hi&k.hi,q=A.lo&N.lo^A.lo&k.lo^N.lo&k.lo;return new t(T,q)}function zo(A){return ni(ct(A,28),ct(A,34),ct(A,39))}function ri(A){return ni(ct(A,14),ct(A,18),ct(A,41))}function qu(A){return ni(ct(A,1),ct(A,8),Po(A,7))}function Io(A){return ni(ct(A,19),ct(A,61),Po(A,6))}var Lu=[new t(1116352408,3609767458),new t(1899447441,602891725),new t(3049323471,3964484399),new t(3921009573,2173295548),new t(961987163,4081628472),new t(1508970993,3053834265),new t(2453635748,2937671579),new t(2870763221,3664609560),new t(3624381080,2734883394),new t(310598401,1164996542),new t(607225278,1323610764),new t(1426881987,3590304994),new t(1925078388,4068182383),new t(2162078206,991336113),new t(2614888103,633803317),new t(3248222580,3479774868),new t(3835390401,2666613458),new t(4022224774,944711139),new t(264347078,2341262773),new t(604807628,2007800933),new t(770255983,1495990901),new t(1249150122,1856431235),new t(1555081692,3175218132),new t(1996064986,2198950837),new t(2554220882,3999719339),new t(2821834349,766784016),new t(2952996808,2566594879),new t(3210313671,3203337956),new t(3336571891,1034457026),new t(3584528711,2466948901),new t(113926993,3758326383),new t(338241895,168717936),new t(666307205,1188179964),new t(773529912,1546045734),new t(1294757372,1522805485),new t(1396182291,2643833823),new t(1695183700,2343527390),new t(1986661051,1014477480),new t(2177026350,1206759142),new t(2456956037,344077627),new t(2730485921,1290863460),new t(2820302411,3158454273),new t(3259730800,3505952657),new t(3345764771,106217008),new t(3516065817,3606008344),new t(3600352804,1432725776),new t(4094571909,1467031594),new t(275423344,851169720),new t(430227734,3100823752),new t(506948616,1363258195),new t(659060556,3750685593),new t(883997877,3785050280),new t(958139571,3318307427),new t(1322822218,3812723403),new t(1537002063,2003034995),new t(1747873779,3602036899),new t(1955562222,1575990012),new t(2024104815,1125592928),new t(2227730452,2716904306),new t(2361852424,442776044),new t(2428436474,593698344),new t(2756734187,3733110249),new t(3204031479,2999351573),new t(3329325298,3815920427),new t(3391569614,3928383900),new t(3515267271,566280711),new t(3940187606,3454069534),new t(4118630271,4000239992),new t(116418474,1914138554),new t(174292421,2731055270),new t(289380356,3203993006),new t(460393269,320620315),new t(685471733,587496836),new t(852142971,1086792851),new t(1017036298,365543100),new t(1126000580,2618297676),new t(1288033470,3409855158),new t(1501505948,4234509866),new t(1607167915,987167468),new t(1816402316,1246189591)];function $o(A,N,k){var T=[],q=[],z=[],re=[],ae,Y,ne;for(Y=0;Y<8;Y++)T[Y]=z[Y]=C(A,8*Y);for(var ye=0;k>=128;){for(Y=0;Y<16;Y++)re[Y]=C(N,8*Y+ye);for(Y=0;Y<80;Y++){for(ne=0;ne<8;ne++)q[ne]=z[ne];for(ae=cr(z[7],ri(z[4]),Du(z[4],z[5],z[6]),Lu[Y],re[Y%16]),q[7]=cr(ae,zo(z[0]),Uo(z[0],z[1],z[2])),q[3]=cr(q[3],ae),ne=0;ne<8;ne++)z[(ne+1)%8]=q[ne];if(Y%16===15)for(ne=0;ne<16;ne++)re[ne]=cr(re[ne],re[(ne+9)%16],qu(re[(ne+1)%16]),Io(re[(ne+14)%16]))}for(Y=0;Y<8;Y++)z[Y]=cr(z[Y],T[Y]),T[Y]=z[Y];ye+=128,k-=128}for(Y=0;Y<8;Y++)P(A,8*Y,T[Y]);return k}var As=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]);function xt(A,N,k){var T=new Uint8Array(64),q=new Uint8Array(256),z,re=k;for(z=0;z<64;z++)T[z]=As[z];for($o(T,N,k),k%=128,z=0;z<256;z++)q[z]=0;for(z=0;z<k;z++)q[z]=N[re-k+z];for(q[k]=128,k=256-128*(k<112?1:0),q[k-9]=0,P(q,k-8,new t(re/536870912|0,re<<3)),$o(T,q,k),z=0;z<64;z++)A[z]=T[z];return 0}function an(A,N){var k=s(),T=s(),q=s(),z=s(),re=s(),ae=s(),Y=s(),ne=s(),ye=s();bt(k,A[1],A[0]),bt(ye,N[1],N[0]),ue(k,k,ye),gt(T,A[0],A[1]),gt(ye,N[0],N[1]),ue(T,T,ye),ue(q,A[3],N[3]),ue(q,q,m),ue(z,A[2],N[2]),gt(z,z,z),bt(re,T,k),bt(ae,z,q),gt(Y,z,q),gt(ne,T,k),ue(A[0],re,ae),ue(A[1],ne,Y),ue(A[2],Y,ae),ue(A[3],re,ne)}function Ht(A,N,k){var T;for(T=0;T<4;T++)ke(A[T],N[T],k)}function ca(A,N){var k=s(),T=s(),q=s();jn(q,N[2]),ue(k,N[0],q),ue(T,N[1],q),Te(A,T),A[31]^=Nt(k)<<7}function ua(A,N,k){var T,q;for(Ee(A[0],d),Ee(A[1],y),Ee(A[2],y),Ee(A[3],d),q=255;q>=0;--q)T=k[q/8|0]>>(q&7)&1,Ht(A,N,T),an(N,A),an(A,A),Ht(A,N,T)}function si(A,N){var k=[s(),s(),s(),s()];Ee(k[0],b),Ee(k[1],x),Ee(k[2],y),ue(k[3],b,x),ua(A,k,N)}function Ur(A,N,k){var T=new Uint8Array(64),q=[s(),s(),s(),s()],z;for(k||i(N,32),xt(T,N,32),T[0]&=248,T[31]&=127,T[31]|=64,si(q,T),ca(A,q),z=0;z<32;z++)N[z+32]=A[z];return 0}var ur=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function zr(A,N){var k,T,q,z;for(T=63;T>=32;--T){for(k=0,q=T-32,z=T-12;q<z;++q)N[q]+=k-16*N[T]*ur[q-(T-32)],k=Math.floor((N[q]+128)/256),N[q]-=k*256;N[q]+=k,N[T]=0}for(k=0,q=0;q<32;q++)N[q]+=k-(N[31]>>4)*ur[q],k=N[q]>>8,N[q]&=255;for(q=0;q<32;q++)N[q]-=k*ur[q];for(T=0;T<32;T++)N[T+1]+=N[T]>>8,A[T]=N[T]&255}function In(A){var N=new Float64Array(64),k;for(k=0;k<64;k++)N[k]=A[k];for(k=0;k<64;k++)A[k]=0;zr(A,N)}function js(A,N,k,T){var q=new Uint8Array(64),z=new Uint8Array(64),re=new Uint8Array(64),ae,Y,ne=new Float64Array(64),ye=[s(),s(),s(),s()];xt(q,T,32),q[0]&=248,q[31]&=127,q[31]|=64;var Re=k+64;for(ae=0;ae<k;ae++)A[64+ae]=N[ae];for(ae=0;ae<32;ae++)A[32+ae]=q[32+ae];for(xt(re,A.subarray(32),k+32),In(re),si(ye,re),ca(A,ye),ae=32;ae<64;ae++)A[ae]=T[ae];for(xt(z,A,k+64),In(z),ae=0;ae<64;ae++)ne[ae]=0;for(ae=0;ae<32;ae++)ne[ae]=re[ae];for(ae=0;ae<32;ae++)for(Y=0;Y<32;Y++)ne[ae+Y]+=z[ae]*q[Y];return zr(A.subarray(32),ne),Re}function ks(A,N){var k=s(),T=s(),q=s(),z=s(),re=s(),ae=s(),Y=s();return Ee(A[2],y),Bt(A[1],N),Je(q,A[1]),ue(z,q,u),bt(q,q,A[2]),gt(z,A[2],z),Je(re,z),Je(ae,re),ue(Y,ae,re),ue(k,Y,q),ue(k,k,z),lr(k,k),ue(k,k,q),ue(k,k,z),ue(k,k,z),ue(A[0],k,z),Je(T,A[0]),ue(T,T,z),st(T,q)&&ue(A[0],A[0],v),Je(T,A[0]),ue(T,T,z),st(T,q)?-1:(Nt(A[0])===N[31]>>7&&bt(A[0],d,A[0]),ue(A[3],A[0],A[1]),0)}function fa(A,N,k,T){var q,z=new Uint8Array(32),re=new Uint8Array(64),ae=[s(),s(),s(),s()],Y=[s(),s(),s(),s()];if(k<64||ks(Y,T))return-1;for(q=0;q<k;q++)A[q]=N[q];for(q=0;q<32;q++)A[q+32]=T[q];if(xt(re,A,k),In(re),ua(ae,Y,re),si(Y,N.subarray(32)),an(ae,Y),ca(z,ae),k-=64,D(N,0,z,0)){for(q=0;q<k;q++)A[q]=0;return-1}for(q=0;q<k;q++)A[q]=N[q+64];return k}var ii=32,Ir=24,$n=32,$r=16,Hr=32,Ns=32,Fr=32,fr=32,Ts=32,ha=Ir,Ho=$n,Zn=$r,nt=64,dt=32,on=64,Cs=32,da=64;n.lowlevel={crypto_core_hsalsa20:K,crypto_stream_xor:he,crypto_stream:Q,crypto_stream_salsa20_xor:M,crypto_stream_salsa20:J,crypto_onetimeauth:H,crypto_onetimeauth_verify:Z,crypto_verify_16:oe,crypto_verify_32:D,crypto_secretbox:le,crypto_secretbox_open:_e,crypto_scalarmult:ve,crypto_scalarmult_base:Fe,crypto_box_beforenm:lt,crypto_box_afternm:Pr,crypto_box:oa,crypto_box_open:la,crypto_box_keypair:St,crypto_hash:xt,crypto_sign:js,crypto_sign_keypair:Ur,crypto_sign_open:fa,crypto_secretbox_KEYBYTES:ii,crypto_secretbox_NONCEBYTES:Ir,crypto_secretbox_ZEROBYTES:$n,crypto_secretbox_BOXZEROBYTES:$r,crypto_scalarmult_BYTES:Hr,crypto_scalarmult_SCALARBYTES:Ns,crypto_box_PUBLICKEYBYTES:Fr,crypto_box_SECRETKEYBYTES:fr,crypto_box_BEFORENMBYTES:Ts,crypto_box_NONCEBYTES:ha,crypto_box_ZEROBYTES:Ho,crypto_box_BOXZEROBYTES:Zn,crypto_sign_BYTES:nt,crypto_sign_PUBLICKEYBYTES:dt,crypto_sign_SECRETKEYBYTES:on,crypto_sign_SEEDBYTES:Cs,crypto_hash_BYTES:da,gf:s,D:u,L:ur,pack25519:Te,unpack25519:Bt,M:ue,A:gt,S:Je,Z:bt,pow2523:lr,add:an,set25519:Ee,modL:zr,scalarmult:ua,scalarbase:si};function Fo(A,N){if(A.length!==ii)throw new Error("bad key size");if(N.length!==Ir)throw new Error("bad nonce size")}function Go(A,N){if(A.length!==Fr)throw new Error("bad public key size");if(N.length!==fr)throw new Error("bad secret key size")}function Tt(){for(var A=0;A<arguments.length;A++)if(!(arguments[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ai(A){for(var N=0;N<A.length;N++)A[N]=0}n.randomBytes=function(A){var N=new Uint8Array(A);return i(N,A),N},n.secretbox=function(A,N,k){Tt(A,N,k),Fo(k,N);for(var T=new Uint8Array($n+A.length),q=new Uint8Array(T.length),z=0;z<A.length;z++)T[z+$n]=A[z];return le(q,T,T.length,N,k),q.subarray($r)},n.secretbox.open=function(A,N,k){Tt(A,N,k),Fo(k,N);for(var T=new Uint8Array($r+A.length),q=new Uint8Array(T.length),z=0;z<A.length;z++)T[z+$r]=A[z];return T.length<32||_e(q,T,T.length,N,k)!==0?null:q.subarray($n)},n.secretbox.keyLength=ii,n.secretbox.nonceLength=Ir,n.secretbox.overheadLength=$r,n.scalarMult=function(A,N){if(Tt(A,N),A.length!==Ns)throw new Error("bad n size");if(N.length!==Hr)throw new Error("bad p size");var k=new Uint8Array(Hr);return ve(k,A,N),k},n.scalarMult.base=function(A){if(Tt(A),A.length!==Ns)throw new Error("bad n size");var N=new Uint8Array(Hr);return Fe(N,A),N},n.scalarMult.scalarLength=Ns,n.scalarMult.groupElementLength=Hr,n.box=function(A,N,k,T){var q=n.box.before(k,T);return n.secretbox(A,N,q)},n.box.before=function(A,N){Tt(A,N),Go(A,N);var k=new Uint8Array(Ts);return lt(k,A,N),k},n.box.after=n.secretbox,n.box.open=function(A,N,k,T){var q=n.box.before(k,T);return n.secretbox.open(A,N,q)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var A=new Uint8Array(Fr),N=new Uint8Array(fr);return St(A,N),{publicKey:A,secretKey:N}},n.box.keyPair.fromSecretKey=function(A){if(Tt(A),A.length!==fr)throw new Error("bad secret key size");var N=new Uint8Array(Fr);return Fe(N,A),{publicKey:N,secretKey:new Uint8Array(A)}},n.box.publicKeyLength=Fr,n.box.secretKeyLength=fr,n.box.sharedKeyLength=Ts,n.box.nonceLength=ha,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(A,N){if(Tt(A,N),N.length!==on)throw new Error("bad secret key size");var k=new Uint8Array(nt+A.length);return js(k,A,A.length,N),k},n.sign.open=function(A,N){if(Tt(A,N),N.length!==dt)throw new Error("bad public key size");var k=new Uint8Array(A.length),T=fa(k,A,A.length,N);if(T<0)return null;for(var q=new Uint8Array(T),z=0;z<q.length;z++)q[z]=k[z];return q},n.sign.detached=function(A,N){for(var k=n.sign(A,N),T=new Uint8Array(nt),q=0;q<T.length;q++)T[q]=k[q];return T},n.sign.detached.verify=function(A,N,k){if(Tt(A,N,k),N.length!==nt)throw new Error("bad signature size");if(k.length!==dt)throw new Error("bad public key size");var T=new Uint8Array(nt+A.length),q=new Uint8Array(nt+A.length),z;for(z=0;z<nt;z++)T[z]=N[z];for(z=0;z<A.length;z++)T[z+nt]=A[z];return fa(q,T,T.length,k)>=0},n.sign.keyPair=function(){var A=new Uint8Array(dt),N=new Uint8Array(on);return Ur(A,N),{publicKey:A,secretKey:N}},n.sign.keyPair.fromSecretKey=function(A){if(Tt(A),A.length!==on)throw new Error("bad secret key size");for(var N=new Uint8Array(dt),k=0;k<N.length;k++)N[k]=A[32+k];return{publicKey:N,secretKey:new Uint8Array(A)}},n.sign.keyPair.fromSeed=function(A){if(Tt(A),A.length!==Cs)throw new Error("bad seed size");for(var N=new Uint8Array(dt),k=new Uint8Array(on),T=0;T<32;T++)k[T]=A[T];return Ur(N,k,!0),{publicKey:N,secretKey:k}},n.sign.publicKeyLength=dt,n.sign.secretKeyLength=on,n.sign.seedLength=Cs,n.sign.signatureLength=nt,n.hash=function(A){Tt(A);var N=new Uint8Array(da);return xt(N,A,A.length),N},n.hash.hashLength=da,n.verify=function(A,N){return Tt(A,N),A.length===0||N.length===0||A.length!==N.length?!1:ie(A,0,N,0,A.length)===0},n.setPRNG=function(A){i=A},(function(){var A=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(A&&A.getRandomValues){var N=65536;n.setPRNG(function(k,T){var q,z=new Uint8Array(T);for(q=0;q<T;q+=N)A.getRandomValues(z.subarray(q,q+Math.min(T-q,N)));for(q=0;q<T;q++)k[q]=z[q];ai(z)})}else typeof require<"u"&&(A=require("crypto"),A&&A.randomBytes&&n.setPRNG(function(k,T){var q,z=A.randomBytes(T);for(q=0;q<T;q++)k[q]=z[q];ai(z)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const ac=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;ac.sign.keyPair.fromSeed,ac.sign.detached,ac.sign.detached.verify,ac.randomBytes;var Xg;(function(n){n.InvalidPrefixByte="nkeys: invalid prefix byte",n.InvalidKey="nkeys: invalid key",n.InvalidPublicKey="nkeys: invalid public key",n.InvalidSeedLen="nkeys: invalid seed length",n.InvalidSeed="nkeys: invalid seed",n.InvalidEncoding="nkeys: invalid encoded key",n.InvalidSignature="nkeys: signature verification failed",n.CannotSign="nkeys: cannot sign, no private key available",n.PublicKeyOnly="nkeys: no seed or private key available",n.InvalidChecksum="nkeys: invalid checksum",n.SerializationError="nkeys: serialization error",n.ApiError="nkeys: api error",n.ClearedPair="nkeys: pair is cleared"})(Xg||(Xg={}));var Wg;(function(n){n[n.Seed=144]="Seed",n[n.Private=120]="Private",n[n.Operator=112]="Operator",n[n.Server=104]="Server",n[n.Cluster=16]="Cluster",n[n.Account=0]="Account",n[n.User=160]="User"})(Wg||(Wg={}));function JE(n){return t=>{let s={};return n.forEach(i=>{const o=i(t)||{};s=Object.assign(s,o)}),s}}function QE(){return()=>{}}function XE(n,t){return()=>{const s=typeof n=="function"?n():n,i=typeof t=="function"?t():t;return{user:s,pass:i}}}function WE(n){return()=>({auth_token:typeof n=="function"?n():n})}const px=120*1e3,ZE=2,yx=2*1e3;function e2(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:px,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:yx,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function t2(n){const t=[];return typeof n.authenticator=="function"&&t.push(n.authenticator),Array.isArray(n.authenticator)&&t.push(...n.authenticator),n.token&&t.push(WE(n.token)),n.user&&t.push(XE(n.user,n.pass)),t.length===0?QE():JE(t)}function n2(n){const t=`${yd}:${hx()}`;if(n=n||{servers:[t]},n.servers=n.servers||[],typeof n.servers=="string"&&(n.servers=[n.servers]),n.servers.length>0&&n.port)throw new pe("port and servers options are mutually exclusive",ce.InvalidOption);n.servers.length===0&&n.port&&(n.servers=[`${yd}:${n.port}`]),n.servers&&n.servers.length===0&&(n.servers=[t]);const s=Su(e2(),n);if(s.authenticator=t2(s),["reconnectDelayHandler","authenticator"].forEach(i=>{if(s[i]&&typeof s[i]!="function")throw new pe(`${i} option should be a function`,ce.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let i=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return i&&(i++,i=Math.floor(Math.random()*i)),s.reconnectTimeWait+i}),s.inboxPrefix)try{Rr(s.inboxPrefix)}catch(i){throw new pe(i.message,ce.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Ed()=="function"),s.resolve&&typeof Ed()!="function")throw new pe("'resolve' is not supported on this client",ce.InvalidOption);return s}function r2(n,t){const{proto:s,tls_required:i,tls_available:o}=n;if((s===void 0||s<1)&&t.noEcho)throw new pe("noEcho",ce.ServerOptionNotAvailable);const c=i||o||!1;if(t.tls&&!c)throw new pe("tls",ce.ServerOptionNotAvailable)}const s2=1024*32,i2=/^INFO\s+([^\r\n]+)\r\n/i,a2=go(`PONG\r
38
+ `),Zg=go(`PING\r
39
+ `);class o2{constructor(t,s,i){j(this,"echo");j(this,"no_responders");j(this,"protocol");j(this,"verbose");j(this,"pedantic");j(this,"jwt");j(this,"nkey");j(this,"sig");j(this,"user");j(this,"pass");j(this,"auth_token");j(this,"tls_required");j(this,"name");j(this,"lang");j(this,"version");j(this,"headers");this.protocol=1,this.version=t.version,this.lang=t.lang,this.echo=s.noEcho?!1:void 0,this.verbose=s.verbose,this.pedantic=s.pedantic,this.tls_required=s.tls?!0:void 0,this.name=s.name;const o=(s&&typeof s.authenticator=="function"?s.authenticator(i):{})||{};Su(this,o)}}class gx extends qt{constructor(s,i,o={}){var d;super();j(this,"sid");j(this,"queue");j(this,"draining");j(this,"max");j(this,"subject");j(this,"drained");j(this,"protocol");j(this,"timer");j(this,"info");j(this,"cleanupFn");j(this,"closed");j(this,"requestSubject");Su(this,o),this.protocol=s,this.subject=i,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=ht();const c=!((d=s.options)!=null&&d.noAsyncTraces);o.timeout&&(this.timer=ea(o.timeout,c),this.timer.then(()=>{this.timer=void 0}).catch(y=>{this.stop(y),this.noIterator&&this.callback(y,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const i=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),c=s.protocolFilterFn?s.protocolFilterFn:()=>!0,d=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(y,g)=>{const{ingest:u}=o(g);u&&c(g)&&(i(y,g),d(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,i){this.cancelTimeout(),s?this.stop(s):this.push(i)}close(){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve()};this.noIterator?s():this.push(s)}}unsubscribe(s){this.protocol.unsubscribe(this,s)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(pe.errorForCode(ce.ConnectionClosed)):this.isClosed()?Promise.reject(pe.errorForCode(ce.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(ht()).then(()=>{this.protocol.subscriptions.cancel(this)}).catch(()=>{this.protocol.subscriptions.cancel(this)})),this.drained)}isDraining(){return this.draining}isClosed(){return this.done}getSubject(){return this.subject}getMax(){return this.max}getID(){return this.sid}}class l2{constructor(){j(this,"mux");j(this,"subs");j(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(t){return this.sidCounter++,t.sid=this.sidCounter,this.subs.set(t.sid,t),t}setMux(t){return this.mux=t,t}getMux(){return this.mux}get(t){return this.subs.get(t)}resub(t){return this.sidCounter++,this.subs.delete(t.sid),t.sid=this.sidCounter,this.subs.set(t.sid,t),t}all(){return Array.from(this.subs.values())}cancel(t){t&&(t.close(),this.subs.delete(t.sid))}handleError(t){if(t&&t.permissionContext){const s=t.permissionContext,i=this.all();let o;if(s.operation==="subscription"&&(o=i.find(c=>c.subject===s.subject&&c.queue===s.queue)),s.operation==="publish"&&(o=i.find(c=>c.requestSubject===s.subject)),o)return o.callback(t,{}),o.close(),this.subs.delete(o.sid),o!==this.mux}return!1}close(){this.subs.forEach(t=>{t.close()})}}class pu{constructor(t,s){j(this,"connected");j(this,"connectedOnce");j(this,"infoReceived");j(this,"info");j(this,"muxSubscriptions");j(this,"options");j(this,"outbound");j(this,"pongs");j(this,"subscriptions");j(this,"transport");j(this,"noMorePublishing");j(this,"connectError");j(this,"publisher");j(this,"_closed");j(this,"closed");j(this,"listeners");j(this,"heartbeats");j(this,"parser");j(this,"outMsgs");j(this,"inMsgs");j(this,"outBytes");j(this,"inBytes");j(this,"pendingLimit");j(this,"lastError");j(this,"abortReconnect");j(this,"whyClosed");j(this,"servers");j(this,"server");j(this,"features");j(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=s2,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=t,this.publisher=s,this.subscriptions=new l2,this.muxSubscriptions=new FE,this.outbound=new na,this.pongs=[],this.whyClosed="",this.pendingLimit=t.pendingLimit||this.pendingLimit,this.features=new EE({major:0,minor:0,micro:0}),this.connectPromise=null;const i=typeof t.servers=="string"?[t.servers]:t.servers;this.servers=new HE(i,{randomize:!t.noRandomize}),this.closed=ht(),this.parser=new Qg(this),this.heartbeats=new GE(this,this.options.pingInterval||px,this.options.maxPingOut||ZE)}resetOutbound(){this.outbound.reset();const t=this.pongs;this.pongs=[];const s=pe.errorForCode(ce.Disconnect);s.stack="",t.forEach(i=>{i.reject(s)}),this.parser=new Qg(this),this.infoReceived=!1}dispatchStatus(t){this.listeners.forEach(s=>{s.push(t)})}status(){const t=new qt;return this.listeners.push(t),t}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const t=ht();return t.catch(()=>{}),this.pongs.unshift(t),this.connectError=s=>{t.reject(s)},this.transport=jE(),this.transport.closed().then(async s=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),t}disconnect(){this.dispatchStatus({type:Yi.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Yi.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(t){this.dispatchStatus({type:Mr.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:Mr.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===ce.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(t)}async dial(t){const s=this.prepare();let i;try{i=ea(this.options.timeout||2e4);const o=this.transport.connect(t,this.options);await Promise.race([o,i]),(async()=>{try{for await(const c of this.transport)this.parser.parse(c)}catch(c){console.log("reader closed",c)}})().then()}catch(o){s.reject(o)}try{await Promise.race([i,s]),i&&i.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(o){throw i&&i.cancel(),await this.transport.close(o),o}}async _doDial(t){const{resolve:s}=this.options,i=await t.resolve({fn:Ed(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const c of i)try{o=null,this.dispatchStatus({type:Yi.Reconnecting,data:c.toString()}),await this.dial(c);return}catch(d){o=d}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let t;for(;;){this._closed&&this.servers.clear();const s=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():yx;let i=s;const o=this.selectServer();if(!o||this.abortReconnect)throw t||(this.lastError?this.lastError:pe.errorForCode(ce.ConnectionRefused));const c=Date.now();if(o.lastConnect===0||o.lastConnect+s<=c){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(d){if(t=d,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const y=this.options.maxReconnectAttempts||0;y!==-1&&o.reconnects>=y&&this.servers.removeCurrentServer()}}else i=Math.min(i,o.lastConnect+s-c),await sa(i)}}static async connect(t,s){const i=new pu(t,s);return await i.dialLoop(),i}static toError(t){const s=t?t.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const i=new pe(t,ce.PermissionsViolation),o=t.match(/(Publish|Subscription) to "(\S+)"/);if(o){i.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const c=t.match(/using queue "(\S+)"/);c&&(i.permissionContext.queue=c[1])}return i}else return s.indexOf("authorization violation")!==-1?new pe(t,ce.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new pe(t,ce.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new pe(t,ce.AccountExpired):s.indexOf("authentication timeout")!==-1?new pe(t,ce.AuthenticationTimeout):new pe(t,ce.ProtocolError)}processMsg(t,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const i=this.subscriptions.get(t.sid);i&&(i.received+=1,i.callback&&i.callback(null,new sm(t,s,this)),i.max!==void 0&&i.received>=i.max&&i.unsubscribe())}processError(t){const s=qg(t),i=pu.toError(s),o={type:Mr.Error,data:i.code};if(i.isPermissionError()){let c=!1;if(i.permissionContext){o.permissionContext=i.permissionContext;const d=this.subscriptions.getMux();c=(d==null?void 0:d.subject)===i.permissionContext.subject}this.subscriptions.handleError(i),this.muxSubscriptions.handleError(c,i),c&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(i)}handleError(t){t.isAuthError()?this.handleAuthError(t):t.isProtocolError()?this.lastError=t:t.isAuthTimeout()&&(this.lastError=t),t.isPermissionError()||(this.lastError=t)}handleAuthError(t){this.lastError&&t.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(t):this.disconnect()}processPing(){this.transport.send(a2)}processPong(){const t=this.pongs.shift();t&&t.resolve()}processInfo(t){const s=JSON.parse(qg(t));this.info=s;const i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(Zs(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:c,lang:d}=this.transport;try{const y=new o2({version:c,lang:d},this.options,s.nonce);s.headers&&(y.headers=!0,y.no_responders=!0);const g=JSON.stringify(y);this.transport.send(go(`CONNECT ${g}${nu}`)),this.transport.send(Zg)}catch(y){this._close(y)}}i&&this.dispatchStatus({type:Mr.Update,data:i}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:Mr.LDM,data:this.servers.getCurrentServer().toString()})}push(t){switch(t.kind){case Kt.MSG:{const{msg:s,data:i}=t;this.processMsg(s,i);break}case Kt.OK:break;case Kt.ERR:this.processError(t.data);break;case Kt.PING:this.processPing();break;case Kt.PONG:this.processPong();break;case Kt.INFO:this.processInfo(t.data);break}}sendCommand(t,...s){const i=this.outbound.length();let o;typeof t=="string"?o=go(t):o=t,this.outbound.fill(o,...s),i===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(t,s=Sn,i){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=ei.encode(s);else throw pe.errorForCode(ce.BadPayload);let c=o.length;i=i||{},i.reply=i.reply||"";let d=Sn,y=0;if(i.headers){if(this.info&&!this.info.headers)throw new pe("headers",ce.ServerOptionNotAvailable);d=i.headers.encode(),y=d.length,c=o.length+y}if(this.info&&c>this.info.max_payload)throw pe.errorForCode(ce.MaxPayloadExceeded);this.outBytes+=c,this.outMsgs++;let g;i.headers?(i.reply?g=`HPUB ${t} ${i.reply} ${y} ${c}\r
40
+ `:g=`HPUB ${t} ${y} ${c}\r
41
+ `,this.sendCommand(g,d,o,mu)):(i.reply?g=`PUB ${t} ${i.reply} ${c}\r
42
+ `:g=`PUB ${t} ${c}\r
43
+ `,this.sendCommand(g,o,mu))}request(t){return this.initMux(),this.muxSubscriptions.add(t),t}subscribe(t){return this.subscriptions.add(t),this._subunsub(t),t}_sub(t){t.queue?this.sendCommand(`SUB ${t.subject} ${t.queue} ${t.sid}\r
44
+ `):this.sendCommand(`SUB ${t.subject} ${t.sid}\r
45
+ `)}_subunsub(t){return this._sub(t),t.max&&this.unsubscribe(t,t.max),t}unsubscribe(t,s){this.unsub(t,s),(t.max===void 0||t.received>=t.max)&&this.subscriptions.cancel(t)}unsub(t,s){!t||this.isClosed()||(s?this.sendCommand(`UNSUB ${t.sid} ${s}\r
46
+ `):this.sendCommand(`UNSUB ${t.sid}\r
47
+ `),t.max=s)}resub(t,s){!t||this.isClosed()||(this.unsub(t),t.subject=s,this.subscriptions.resub(t),this._sub(t))}flush(t){return t||(t=ht()),this.pongs.push(t),this.outbound.fill(Zg),this.flushPending(),t}sendSubscriptions(){const t=[];this.subscriptions.all().forEach(s=>{const i=s;i.queue?t.push(`SUB ${i.subject} ${i.queue} ${i.sid}${nu}`):t.push(`SUB ${i.subject} ${i.sid}${nu}`)}),t.length&&this.transport.send(go(t.join("")))}async _close(t){this._closed||(this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(t),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(s=>{s.stop()}),this._closed=!0,await this.transport.close(t),await this.closed.resolve(t))}close(){return this._close()}isClosed(){return this._closed}drain(){const t=this.subscriptions.all(),s=[];return t.forEach(i=>{s.push(i.drain())}),Promise.all(s).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const t=this.outbound.drain();this.transport.send(t)}}initMux(){if(!this.subscriptions.getMux()){const s=this.muxSubscriptions.init(this.options.inboxPrefix),i=new gx(this,`${s}*`);i.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(i),this.subscribe(i)}}selectServer(){const t=this.servers.selectServer();if(t!==void 0)return this.server=t,this.server}getServer(){return this.server}}const c2="$SRV";class e1{constructor(t){j(this,"msg");this.msg=t}get data(){return this.msg.data}get sid(){return this.msg.sid}get subject(){return this.msg.subject}get reply(){return this.msg.reply||""}get headers(){return this.msg.headers}respond(t,s){return this.msg.respond(t,s)}respondError(t,s,i,o){var c,d;return o=o||{},o.headers=o.headers||qr(),(c=o.headers)==null||c.set(uu,`${t}`),(d=o.headers)==null||d.set(cu,s),this.msg.respond(i,o)}json(t){return this.msg.json(t)}string(){return this.msg.string()}}class So{constructor(t,s="",i=""){j(this,"subject");j(this,"queue");j(this,"srv");s!==""&&f2("service group",s);let o="";if(t instanceof Co)this.srv=t,o="";else if(t instanceof So){const c=t;this.srv=c.srv,i===""&&c.queue!==""&&(i=c.queue),o=c.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=i}calcSubject(t,s=""){return s===""?t:t!==""?`${t}.${s}`:s}addEndpoint(t="",s){s=s||{subject:t};const i=typeof s=="function"?{handler:s,subject:t}:s;mo("endpoint",t);let{subject:o,handler:c,metadata:d,queue:y}=i;o=o||t,y=y||this.queue,u2("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:t,subject:o,queue:y,handler:c,metadata:d};return this.srv._addEndpoint(g)}addGroup(t="",s=""){return new So(this,t,s)}}function u2(n,t){if(t==="")throw new Error(`${n} cannot be empty`);if(t.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${t}'`);const s=t.split(".");s.forEach((i,o)=>{if(i===">"&&o!==s.length-1)throw new Error(`${n} cannot have internal '>': '${t}'`)})}function f2(n,t){if(t.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${t}'`);t.split(".").forEach(i=>{if(i===">")throw new Error(`${n} name cannot contain internal '>': '${t}'`)})}class Co{constructor(t,s={name:"",version:""}){j(this,"nc");j(this,"_id");j(this,"config");j(this,"handlers");j(this,"internal");j(this,"_stopped");j(this,"_done");j(this,"started");this.nc=t,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),mo("name",this.config.name),mo("queue",this.config.queue),Zs(this.config.version),this._id=Es.next(),this.internal=[],this._done=ht(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(i=>{this.close(i).catch()})}static controlSubject(t,s="",i="",o){const c=o??c2;return s===""&&i===""?`${c}.${t}`:(mo("control subject name",s),i!==""?(mo("control subject id",i),`${c}.${t}.${s}.${i}`):`${c}.${t}.${s}`)}get subjects(){return this.handlers.filter(t=>t.internal===!1).map(t=>t.subject)}get id(){return this._id}get name(){return this.config.name}get description(){return this.config.description??""}get version(){return this.config.version}get metadata(){return this.config.metadata}errorToHeader(t){const s=qr();if(t instanceof fu){const i=t;s.set(cu,i.message),s.set(uu,`${i.code}`)}else s.set(cu,t.message),s.set(uu,"500");return s}setupHandler(t,s=!1){const i=s?"":t.queue?t.queue:this.config.queue,{name:o,subject:c,handler:d}=t,y=t;y.internal=s,s&&this.internal.push(y),y.stats=new h2(o,c,i),y.queue=i;const g=d?(u,m)=>{if(u){this.close(u);return}const b=Date.now();try{d(u,new e1(m))}catch(x){y.stats.countError(x),m==null||m.respond(Sn,{headers:this.errorToHeader(x)})}finally{y.stats.countLatency(b)}}:void 0;return y.sub=this.nc.subscribe(c,{callback:g,queue:i}),y.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${t.subject} stopped`)).catch()}).catch(u=>{if(!this._stopped){const m=new Error(`required subscription ${t.subject} errored: ${u.message}`);m.stack=u.stack,this.close(m).catch()}}),y}info(){return{type:bo.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(t=>{const{subject:s,metadata:i,name:o,queue:c}=t;return{subject:s,metadata:i,name:o,queue_group:c}})}async stats(){const t=[];for(const s of this.handlers){if(typeof this.config.statsHandler=="function")try{s.stats.data=await this.config.statsHandler(s)}catch(i){s.stats.countError(i)}t.push(s.stats.stats(s.qi))}return{type:bo.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:t}}addInternalHandler(t,s){const i=`${t}`.toUpperCase();this._doAddInternalHandler(`${i}-all`,t,s),this._doAddInternalHandler(`${i}-kind`,t,s,this.name),this._doAddInternalHandler(`${i}`,t,s,this.name,this.id)}_doAddInternalHandler(t,s,i,o="",c=""){const d={};d.name=t,d.subject=Co.controlSubject(s,o,c),d.handler=i,this.setupHandler(d,!0)}start(){const t=Xn(),s=(d,y)=>d?(this.close(d),Promise.reject(d)):this.stats().then(g=>(y==null||y.respond(t.encode(g)),Promise.resolve())),i=(d,y)=>d?(this.close(d),Promise.reject(d)):(y==null||y.respond(t.encode(this.info())),Promise.resolve()),o=t.encode(this.ping()),c=(d,y)=>d?(this.close(d).then().catch(),Promise.reject(d)):(y.respond(o),Promise.resolve());return this.addInternalHandler(xs.PING,c),this.addInternalHandler(xs.STATS,s),this.addInternalHandler(xs.INFO,i),this.handlers.forEach(d=>{const{subject:y}=d;typeof y=="string"&&d.handler!==null&&this.setupHandler(d)}),Promise.resolve(this)}close(t){if(this._stopped)return this._done;this._stopped=!0;let s=[];return this.nc.isClosed()||(s=this.handlers.concat(this.internal).map(i=>i.sub.drain())),Promise.allSettled(s).then(()=>{this._done.resolve(t||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(t){return this.close(t)}ping(){return{type:bo.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const t of this.handlers)t.stats.reset(t.qi)}addGroup(t,s){return new So(this,t,s)}addEndpoint(t,s){return new So(this).addEndpoint(t,s)}_addEndpoint(t){const s=new qt;s.noIterator=typeof t.handler=="function",s.noIterator||(t.handler=(o,c)=>{o?this.stop(o).catch():s.push(new e1(c))},s.iterClosed.then(()=>{this.close().catch()}));const i=this.setupHandler(t,!1);return i.qi=s,this.handlers.push(i),s}}class h2{constructor(t,s,i=""){j(this,"name");j(this,"subject");j(this,"average_processing_time");j(this,"num_requests");j(this,"processing_time");j(this,"num_errors");j(this,"last_error");j(this,"data");j(this,"metadata");j(this,"queue");this.name=t,this.subject=s,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=i}reset(t){this.num_requests=0,this.processing_time=0,this.average_processing_time=0,this.num_errors=0,this.last_error=void 0,this.data=void 0;const s=t;s&&(s.time=0,s.processed=0)}countLatency(t){this.num_requests++,this.processing_time+=ft(Date.now()-t),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(t){this.num_errors++,this.last_error=t.message}_stats(){const{name:t,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:d,last_error:y,data:g,queue:u}=this;return{name:t,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:d,last_error:y,data:g,queue_group:u}}stats(t){const s=t;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=ft(s.time),this.num_requests=s.processed,this.average_processing_time=this.processing_time>0&&this.num_requests>0?this.processing_time/this.num_requests:0),this._stats()}}class d2{constructor(t,s={strategy:Qn.JitterTimer,maxWait:2e3},i){j(this,"nc");j(this,"prefix");j(this,"opts");this.nc=t,this.prefix=i,this.opts=s}ping(t="",s=""){return this.q(xs.PING,t,s)}stats(t="",s=""){return this.q(xs.STATS,t,s)}info(t="",s=""){return this.q(xs.INFO,t,s)}async q(t,s="",i=""){const o=new qt,c=Xn(),d=Co.controlSubject(t,s,i,this.prefix),y=await this.nc.requestMany(d,Sn,this.opts);return(async()=>{for await(const g of y)try{const u=c.decode(g.data);o.push(u)}catch(u){o.push(()=>{o.stop(u)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function bx(){return{key:{encode(n){return n},decode(n){return n}},value:{encode(n){return n},decode(n){return n}}}}function m2(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:bx(),storage:_d.File}}const yu="KV-Operation",t1="$KV",p2=/^[-/=.\w]+$/,y2=/^[-/=.>*\w]+$/,g2=/^[-\w]+$/;function b2(n){if(n.startsWith(".")||n.endsWith(".")||!p2.test(n))throw new Error(`invalid key: ${n}`)}function x2(n){if(n.startsWith(".")||n.endsWith(".")||!y2.test(n))throw new Error(`invalid key: ${n}`)}function v2(n){if(n.startsWith(".")||n.endsWith("."))throw new Error(`invalid key: ${n}`);const t=n.split(".");let s=!1;for(let i=0;i<t.length;i++)switch(t[i]){case"*":s=!0;break;case">":if(i!==t.length-1)throw new Error(`invalid key: ${n}`);s=!0;break}return s}function ru(n){if(!g2.test(n))throw new Error(`invalid bucket name: ${n}`)}var sr;(function(n){n.MsgIdHdr="Nats-Msg-Id",n.ExpectedStreamHdr="Nats-Expected-Stream",n.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",n.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",n.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(sr||(sr={}));class Eo{constructor(t,s,i){j(this,"js");j(this,"jsm");j(this,"stream");j(this,"bucket");j(this,"direct");j(this,"codec");j(this,"prefix");j(this,"editPrefix");j(this,"useJsPrefix");j(this,"_prefixLen");j(this,"validateKey",b2);j(this,"validateSearchKey",x2);j(this,"hasWildcards",v2);ru(t),this.js=s,this.jsm=i,this.bucket=t,this.prefix=t1,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(t,s,i={}){ru(s);const o=await t.jetstreamManager(),c=new Eo(s,t,o);return await c.init(i),c}static async bind(t,s,i={}){const o=await t.jetstreamManager(),c={config:{allow_direct:i.allow_direct}};ru(s);const d=new Eo(s,t,o);return c.config.name=i.streamName??d.bucketName(),Object.assign(d,c),d.stream=c.config.name,d.codec=i.codec||bx(),d.direct=c.config.allow_direct??!1,d.initializePrefixes(c),d}async init(t={}){const s=Object.assign(m2(),t);this.codec=s.codec;const i={};this.stream=i.name=t.streamName??this.bucketName(),i.retention=vd.Limits,i.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(i.max_bytes=s.max_bytes),i.max_msg_size=s.maxValueSize,i.storage=s.storage;const o=t.placementCluster??"";if(o&&(t.placement={},t.placement.cluster=o,t.placement.tags=[]),t.placement&&(i.placement=t.placement),t.republish&&(i.republish=t.republish),t.description&&(i.description=t.description),t.mirror){const b=Object.assign({},t.mirror);b.name.startsWith(bn)||(b.name=`${bn}${b.name}`),i.mirror=b,i.mirror_direct=!0}else if(t.sources){const b=t.sources.map(x=>{const v=Object.assign({},x),_=v.name.startsWith(bn)?v.name.substring(bn.length):v.name;return v.name.startsWith(bn)||(v.name=`${bn}${v.name}`),!x.external&&_!==this.bucket&&(v.subject_transforms=[{src:`$KV.${_}.>`,dest:`$KV.${this.bucket}.>`}]),v});i.sources=b,i.subjects=[this.subjectForBucket()]}else i.subjects=[this.subjectForBucket()];t.metadata&&(i.metadata=t.metadata),typeof t.compression=="boolean"&&(i.compression=t.compression?Os.S2:Os.None);const c=this.js.nc,d=c.getServerVersion(),y=d?Sd(d,Zs("2.7.2"))>=0:!1;i.discard=y?wo.New:wo.Old;const{ok:g,min:u}=c.features.get(Ge.JS_ALLOW_DIRECT);if(!g&&t.allow_direct===!0){const b=d?`${d.major}.${d.minor}.${d.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${b} - requires ${u}`))}t.allow_direct=typeof t.allow_direct=="boolean"?t.allow_direct:g,i.allow_direct=t.allow_direct,this.direct=i.allow_direct,i.num_replicas=s.replicas,s.ttl&&(i.max_age=ft(s.ttl)),i.allow_rollup_hdrs=!0;let m;try{m=await this.jsm.streams.info(i.name),!m.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(b){if(b.message==="stream not found")m=await this.jsm.streams.add(i);else throw b}this.initializePrefixes(m)}initializePrefixes(t){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:s}=t.config;if(s){let i=s.name;if(i.startsWith(bn)&&(i=i.substring(bn.length)),s.external&&s.external.api!==""){const o=s.name.substring(bn.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${i}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${bn}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(t,s=!1){const i=[];return s?(this.useJsPrefix&&i.push(this.js.apiPrefix),this.editPrefix!==""?i.push(this.editPrefix):i.push(this.prefix)):this.prefix&&i.push(this.prefix),i.push(t),i.join(".")}fullKeyName(t){return this.prefix!==""?`${this.prefix}.${t}`:`${t1}.${this.bucket}.${t}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(t){const s=[];for(const i of t.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.encode(i));break}return s.join(".")}decodeKey(t){const s=[];for(const i of t.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.decode(i));break}return s.join(".")}close(){return Promise.resolve()}dataLen(t,s){const i=s&&s.get(Qt.MessageSizeHdr)||"";return i!==""?parseInt(i,10):t.length}smToEntry(t){return new q2(this.bucket,this.prefixLen,t)}jmToEntry(t){const s=this.decodeKey(t.subject.substring(this.prefixLen));return new L2(this.bucket,s,t)}async create(t,s){var c;let i;try{const d=await this.put(t,s,{previousSeq:0});return Promise.resolve(d)}catch(d){if(i=d,((c=d==null?void 0:d.api_error)==null?void 0:c.err_code)!==10071)return Promise.reject(d)}let o=0;try{const d=await this.get(t);return(d==null?void 0:d.operation)==="DEL"||(d==null?void 0:d.operation)==="PURGE"?(o=d!==null?d.revision:0,this.update(t,s,o)):Promise.reject(i)}catch(d){return Promise.reject(d)}}update(t,s,i){if(i<=0)throw new Error("version must be greater than 0");return this.put(t,s,{previousSeq:i})}async put(t,s,i={}){var d,y;const o=this.encodeKey(t);this.validateKey(o);const c={};if(i.previousSeq!==void 0){const g=qr();c.headers=g,g.set(sr.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,c)).seq}catch(g){const u=g;return u.isJetStreamError()?(u.message=(d=u.api_error)==null?void 0:d.description,u.code=`${(y=u.api_error)==null?void 0:y.code}`,Promise.reject(u)):Promise.reject(g)}}async get(t,s){const i=this.encodeKey(t);this.validateKey(i);let o={last_by_subj:this.subjectForKey(i)};s&&s.revision>0&&(o={seq:s.revision});let c;try{this.direct?c=await this.jsm.direct.getMessage(this.bucketName(),o):c=await this.jsm.streams.getMessage(this.bucketName(),o);const d=this.smToEntry(c);return d.key!==i?null:d}catch(d){if(d.code===ce.JetStream404NoMessages)return null;throw d}}purge(t,s){return this._deleteOrPurge(t,"PURGE",s)}delete(t,s){return this._deleteOrPurge(t,"DEL",s)}async purgeDeletes(t=1800*1e3){const s=ht(),i=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&i.push(g)})().then(),await s,o.stop();const c=Date.now()-t,d=i.map(g=>{const u=this.subjectForKey(g.key);return g.created.getTime()>=c?this.jsm.streams.purge(this.stream,{filter:u,keep:1}):this.jsm.streams.purge(this.stream,{filter:u,keep:0})}),y=await Promise.all(d);return y.unshift({success:!0,purged:0}),y.reduce((g,u)=>(g.purged+=u.purged,g))}async _deleteOrPurge(t,s,i){if(!this.hasWildcards(t))return this._doDeleteOrPurge(t,s,i);const o=await this.keys(t),c=[];for await(const d of o)c.push(this._doDeleteOrPurge(d,s)),c.length===100&&(await Promise.all(c),c.length=0);c.length>0&&await Promise.all(c)}async _doDeleteOrPurge(t,s,i){const o=this.encodeKey(t);this.validateKey(o);const c=qr();c.set(yu,s),s==="PURGE"&&c.set(Qt.RollupHdr,Qt.RollupValueSubject),i!=null&&i.previousSeq&&c.set(sr.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),Sn,{headers:c})}_buildCC(t,s,i={}){let c=(Array.isArray(t)?t:[t]).map(g=>{const u=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(u)}),d=wt.LastPerSubject;s===Kn.AllHistory&&(d=wt.All),s===Kn.UpdatesOnly&&(d=wt.New);let y;return c.length===1&&(y=c[0],c=void 0),Object.assign({deliver_policy:d,ack_policy:Dt.None,filter_subjects:c,filter_subject:y,flow_control:!0,idle_heartbeat:ft(5*1e3)},i)}remove(t){return this.purge(t)}async history(t={}){const s=t.key??">",i=new qt,o={};o.headers_only=t.headers_only||!1;let c;c=()=>{i.stop()};let d=0;const y=this._buildCC(s,Kn.AllHistory,o),g=y.filter_subject,u=_s(y);u.bindStream(this.stream),u.orderedConsumer(),u.callback((b,x)=>{if(b){i.stop(b);return}if(x){const v=this.jmToEntry(x);i.push(v),i.received++,(c&&d>0&&i.received>=d||x.info.pending===0)&&(i.push(c),c=void 0)}});const m=await this.js.subscribe(g,u);if(c){const{info:{last:b}}=m,x=b.num_pending+b.delivered.consumer_seq;if(x===0||i.received>=x)try{c()}catch(v){i.stop(v)}finally{c=void 0}else d=x}return i._data=m,i.iterClosed.then(()=>{m.unsubscribe()}),m.closed.then(()=>{i.stop()}).catch(b=>{i.stop(b)}),i}canSetWatcherName(){const s=this.js.nc,{ok:i}=s.features.get(Ge.JS_NEW_CONSUMER_CREATE_API);return i}async watch(t={}){const s=t.key??">",i=new qt,o={};o.headers_only=t.headers_only||!1;let c=Kn.LastValue;t.include===Kn.AllHistory?c=Kn.AllHistory:t.include===Kn.UpdatesOnly&&(c=Kn.UpdatesOnly);const d=t.ignoreDeletes===!0;let y=t.initializedFn,g=0;const u=this._buildCC(s,c,o),m=u.filter_subject,b=_s(u);this.canSetWatcherName()&&b.consumerName(Es.next()),b.bindStream(this.stream),t.resumeFromRevision&&t.resumeFromRevision>0&&b.startSequence(t.resumeFromRevision),b.orderedConsumer(),b.callback((v,_)=>{if(v){i.stop(v);return}if(_){const S=this.jmToEntry(_);if(d&&S.operation==="DEL")return;i.push(S),i.received++,y&&(g>0&&i.received>=g||_.info.pending===0)&&(i.push(y),y=void 0)}});const x=await this.js.subscribe(m,b);if(y){const{info:{last:v}}=x,_=v.num_pending+v.delivered.consumer_seq;if(_===0||i.received>=_)try{y()}catch(S){i.stop(S)}finally{y=void 0}else g=_}return i._data=x,i.iterClosed.then(()=>{x.unsubscribe()}),x.closed.then(()=>{i.stop()}).catch(v=>{i.stop(v)}),i}async keys(t=">"){const s=new qt,i=this._buildCC(t,Kn.LastValue,{headers_only:!0}),o=Array.isArray(t)?">":i.filter_subject,c=_s(i);c.bindStream(this.stream),c.orderedConsumer();const d=await this.js.subscribe(o,c);return(async()=>{var g;for await(const u of d){const m=(g=u.headers)==null?void 0:g.get(yu);if(m!=="DEL"&&m!=="PURGE"){const b=this.decodeKey(u.subject.substring(this.prefixLen));s.push(b)}u.info.pending===0&&d.unsubscribe()}})().then(()=>{s.stop()}).catch(g=>{s.stop(g)}),d.info.last.num_pending===0&&d.unsubscribe(),s}purgeBucket(t){return this.jsm.streams.purge(this.bucketName(),t)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var c;const s=((c=this.js.nc.info)==null?void 0:c.cluster)??"",i=this.bucketName(),o=await this.jsm.streams.info(i);return new xx(o,s)}}class xx{constructor(t,s=""){j(this,"si");j(this,"cluster");this.si=t,this.cluster=s}get bucket(){return this.si.config.name.startsWith(bn)?this.si.config.name.substring(bn.length):this.si.config.name}get values(){return this.si.state.messages}get history(){return this.si.config.max_msgs_per_subject}get ttl(){return rm(this.si.config.max_age)}get bucket_location(){return this.cluster}get backingStore(){return this.si.config.storage}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get description(){return this.si.config.description??""}get maxBucketSize(){return this.si.config.max_bytes}get maxValueSize(){return this.si.config.max_msg_size}get max_bytes(){return this.si.config.max_bytes}get placement(){return this.si.config.placement||{cluster:"",tags:[]}}get placementCluster(){var t;return((t=this.si.config.placement)==null?void 0:t.cluster)??""}get republish(){return this.si.config.republish??{src:"",dest:""}}get streamInfo(){return this.si}get size(){return this.si.state.bytes}get metadata(){return this.si.config.metadata??{}}get compression(){return this.si.config.compression?this.si.config.compression!==Os.None:!1}}const am="OBJ_",n1="SHA-256=";function _2(n){return ru(n),`${am}${n}`}function w2(n){return n.startsWith(am)?n.substring(4):n}class jd{constructor(t){j(this,"si");j(this,"backingStore");this.si=t,this.backingStore="JetStream"}get bucket(){return w2(this.si.config.name)}get description(){return this.si.config.description??""}get ttl(){return this.si.config.max_age}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get sealed(){return this.si.config.sealed}get size(){return this.si.state.bytes}get streamInfo(){return this.si}get metadata(){return this.si.config.metadata}get compression(){return this.si.config.compression?this.si.config.compression!==Os.None:!1}}function oc(n){if(n===void 0)return;const{domain:t}=n;if(t===void 0)return n;const s=Object.assign({},n);if(delete s.domain,t==="")return s;if(s.external)throw new Error("domain and external are both set");return s.external={api:`$JS.${t}.API`},s}var Pn;(function(n){n[n.Unset=-1]="Unset",n[n.Consume=0]="Consume",n[n.Fetch=1]="Fetch"})(Pn||(Pn={}));var ir;(function(n){n.HeartbeatsMissed="heartbeats_missed",n.ConsumerNotFound="consumer_not_found",n.StreamNotFound="stream_not_found",n.ConsumerDeleted="consumer_deleted",n.OrderedConsumerRecreated="ordered_consumer_recreated",n.NoResponders="no_responders"})(ir||(ir={}));var Xi;(function(n){n.DebugEvent="debug",n.Discard="discard",n.Reset="reset",n.Next="next"})(Xi||(Xi={}));const r1=Uint8Array.of(43,65,67,75),S2=Uint8Array.of(45,78,65,75),ro=Uint8Array.of(43,87,80,73),E2=Uint8Array.of(43,78,88,84),O2=Uint8Array.of(43,84,69,82,77),A2=Uint8Array.of(32);function Oo(n,t=5e3){return new H2(n,t)}class ed extends qt{constructor(s,i,o=!1){super();j(this,"consumer");j(this,"opts");j(this,"sub");j(this,"monitor");j(this,"pending");j(this,"inbox");j(this,"refilling");j(this,"pong");j(this,"callback");j(this,"timeout");j(this,"cleanupHandler");j(this,"listeners");j(this,"statusIterator");j(this,"forOrderedConsumer");j(this,"resetHandler");j(this,"abortOnMissingResource");j(this,"bind");j(this,"inBackOff");this.consumer=s;const c=i;this.opts=this.parseOptions(i,o),this.callback=c.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=o,this.timeout=null,this.inbox=Rr(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=c.abort_on_missing_resource===!0,this.bind=c.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:i,idle_heartbeat:o,threshold_bytes:c,threshold_messages:d}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:y}=this;y&&y.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,u)=>{var b,x,v,_;if(g){this.stop(g);return}if((b=this.monitor)==null||b.work(),u.subject===this.inbox){if(xd(u))return;const S=(x=u.headers)==null?void 0:x.code,C=((_=(v=u.headers)==null?void 0:v.description)==null?void 0:_.toLowerCase())||"unknown",{msgsLeft:L,bytesLeft:P}=this.parseDiscard(u.headers);if(L>0||P>0)this.pending.msgs-=L,this.pending.bytes-=P,this.pending.requests--,this.notify(Xi.Discard,{msgsLeft:L,bytesLeft:P});else if(S===400){this.stop(new pe(C,`${S}`));return}else if(S===409&&C==="consumer deleted"){if(this.notify(ir.ConsumerDeleted,`${S} ${C}`),!this.refilling||this.abortOnMissingResource){const ie=new pe(C,`${S}`);this.stop(ie);return}}else if(S===503){if(this.notify(ir.NoResponders,`${S} No Responders`),!this.refilling||this.abortOnMissingResource){const ie=new pe("no responders",`${S}`);this.stop(ie);return}}else this.notify(Xi.DebugEvent,`${S} ${C}`)}else this._push(Oo(u,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=u.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=d||i&&this.pending.bytes<=c){const S=this.pullOptions();this.pull(S)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new im(o,g=>(this.notify(ir.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var u;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const m of g)switch(m.type){case Mr.Disconnect:(u=this.monitor)==null||u.cancel();break;case Mr.Reconnect:this.resetPending().then(b=>{var x;b&&((x=this.monitor)==null||x.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const i=typeof s=="function"?s:null;try{i?i():this.callback(s)}catch(o){this.stop(o)}}}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}resetPending(){return this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo()}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){if(this.inBackOff)return!1;let s=0,i=0;const o=nm([this.opts.expires]);let c=0;for(;;){if(this.done)return!1;if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),this.inBackOff=!1,s=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(d){if(d.message==="stream not found"){if(i++,this.notify(ir.StreamNotFound,i),!this.refilling||this.abortOnMissingResource)return this.stop(d),!1}else if(d.message==="consumer not found"){if(s++,this.notify(ir.ConsumerNotFound,s),this.resetHandler)try{this.resetHandler()}catch{}if(!this.refilling||this.abortOnMissingResource)return this.stop(d),!1;if(this.forOrderedConsumer)return!1}else s=0,i=0;this.inBackOff=!0;const y=o.backoff(c),g=sa(y);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),c++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const i=this.consumer.api.nc;this._push(()=>{i.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(s),{reply:this.inbox}),this.notify(Xi.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,i=this.opts.max_bytes-this.pending.bytes,o=ft(this.opts.idle_heartbeat),c=ft(this.opts.expires);return{batch:s,max_bytes:i,idle_heartbeat:o,expires:c}}parseDiscard(s){const i={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Qt.PendingMessagesHdr);o&&(i.msgsLeft=parseInt(o));const c=s==null?void 0:s.get(Qt.PendingBytesHdr);return c&&(i.bytesLeft=parseInt(c)),i}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,i;(s=this.monitor)==null||s.cancel(),this.monitor=null,(i=this.timeout)==null||i.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var i,o;this.done||((i=this.sub)==null||i.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(c=>{c.stop()})}))}parseOptions(s,i=!1){const o=s||{};if(o.max_messages=o.max_messages||0,o.max_bytes=o.max_bytes||0,o.max_messages!==0&&o.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(o.max_messages===0&&(o.max_messages=100),o.expires=o.expires||3e4,o.expires<1e3)throw new Error("expires should be at least 1000ms");if(o.idle_heartbeat=o.idle_heartbeat||o.expires/2,o.idle_heartbeat=o.idle_heartbeat>3e4?3e4:o.idle_heartbeat,i){const c=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||c;const d=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||d}return o}status(){const s=new qt;return this.listeners.push(s),Promise.resolve(s)}}class j2 extends qt{constructor(){super();j(this,"src");j(this,"listeners");this.listeners=[]}setSource(s){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=s,this.src.setCleanupHandler(i=>{this.stop(i||void 0)}),(async()=>{const i=await this.src.status();for await(const o of i)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}stop(s){var i;this.done||((i=this.src)==null||i.stop(s),super.stop(s),this.listeners.forEach(o=>{o.stop()}))}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}status(){const s=new qt;return this.listeners.push(s),Promise.resolve(s)}}class kd{constructor(t,s){j(this,"api");j(this,"_info");j(this,"stream");j(this,"name");this.api=t,this._info=s,this.stream=s.stream_name,this.name=s.name}consume(t={max_messages:100,expires:3e4}){return Promise.resolve(new ed(this,t,!0))}fetch(t={max_messages:100,expires:3e4}){const s=new ed(this,t,!1),i=Math.round(s.opts.expires*1.05),o=ea(i);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(t={expires:3e4}){const s=ht(),i=t;i.max_messages=1;const o=new ed(this,i,!1),c=Math.round(o.opts.expires*1.05);c>=6e4&&(async()=>{for await(const y of await o.status())if(y.type===ir.HeartbeatsMissed&&y.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const y of o){s.resolve(y);break}})().catch(()=>{});const d=ea(c);return o.closed().then(y=>{y?s.reject(y):s.resolve(null)}).catch(y=>{s.reject(y)}).finally(()=>{d.cancel()}),d.catch(y=>{s.resolve(null),o.close().catch()}),o.trackTimeout(d),s}delete(){const{stream_name:t,name:s}=this._info;return this.api.delete(t,s)}info(t=!1){if(t)return Promise.resolve(this._info);const{stream_name:s,name:i}=this._info;return this.api.info(s,i).then(o=>(this._info=o,this._info))}}class k2{constructor(t,s,i={}){j(this,"api");j(this,"consumerOpts");j(this,"consumer");j(this,"opts");j(this,"cursor");j(this,"stream");j(this,"namePrefix");j(this,"serial");j(this,"currentConsumer");j(this,"userCallback");j(this,"iter");j(this,"type");j(this,"startSeq");j(this,"maxInitialReset");this.api=t,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=Es.next(),typeof i.name_prefix=="string"&&(Eu("name_prefix",i.name_prefix),this.namePrefix=i.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=Pn.Unset,this.consumerOpts=i,this.maxInitialReset=30,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(t){this.serial++;const s=`${this.namePrefix}_${this.serial}`;t=t===0?1:t;const i={name:s,deliver_policy:wt.StartSequence,opt_start_seq:t,ack_policy:Dt.None,inactive_threshold:ft(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(i.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(i.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(i.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(i.replay_policy=this.consumerOpts.replay_policy),t===this.startSeq+1&&(i.deliver_policy=this.consumerOpts.deliver_policy||wt.StartSequence,(this.consumerOpts.deliver_policy===wt.LastPerSubject||this.consumerOpts.deliver_policy===wt.New||this.consumerOpts.deliver_policy===wt.Last)&&(delete i.opt_start_seq,i.deliver_policy=this.consumerOpts.deliver_policy),i.deliver_policy===wt.LastPerSubject&&typeof i.filter_subjects>"u"&&typeof i.filter_subject>"u"&&(i.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete i.opt_start_seq,i.deliver_policy=wt.StartTime,i.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(i.inactive_threshold=ft(this.consumerOpts.inactive_threshold))),i}async resetConsumer(t=0){var d,y,g,u,m;Es.next();const s=this.serial===0;(d=this.consumer)==null||d.delete().catch(()=>{}),t=t===0?1:t,this.cursor.deliver_seq=0;const i=this.getConsumerOpts(t);i.max_deliver=1,i.mem_storage=!0;const o=nm([((y=this.opts)==null?void 0:y.expires)||3e4]);let c;for(let b=0;;b++)try{c=await this.api.add(this.stream,i),(g=this.iter)==null||g.notify(ir.OrderedConsumerRecreated,c.name);break}catch(x){if(x.message==="stream not found"&&((u=this.iter)==null||u.notify(ir.StreamNotFound,b),this.type===Pn.Fetch||this.opts.abort_on_missing_resource===!0))return(m=this.iter)==null||m.stop(x),Promise.reject(x);if(s&&b>=this.maxInitialReset)throw x;await sa(o.backoff(b+1))}return c}internalHandler(t){return s=>{var o;if(this.serial!==t)return;const i=s.info.deliverySequence;if(i!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=i,this.cursor.stream_seq=s.info.streamSequence,this.userCallback?this.userCallback(s):(o=this.iter)==null||o.push(s)}}async reset(t={max_messages:100,expires:3e4},s){var g,u;s=s||{};const i=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===Pn.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((u=this.iter)==null?void 0:u.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||i)&&(this.iter=new j2),this.consumer=new kd(this.api,this.currentConsumer);const c=t;c.callback=this.internalHandler(this.serial);let d=null;this.type===Pn.Fetch&&i?d=await this.consumer.fetch(t):this.type===Pn.Consume&&(d=await this.consumer.consume(t));const y=d;y.forOrderedConsumer=!0,y.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(y)}notifyOrderedResetAndReset(){var t;(t=this.iter)==null||t.notify(Xi.Reset,""),this.reset(this.opts,{orderedReset:!0})}async consume(t={max_messages:100,expires:3e4}){if(t.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===Pn.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===Pn.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:i}=t;return i&&(this.userCallback=i),this.type=Pn.Consume,this.opts=t,await this.reset(t),this.iter}async fetch(t={max_messages:100,expires:3e4}){var o;if(t.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===Pn.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((o=this.iter)==null?void 0:o.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:i}=t;return i&&(this.userCallback=i),this.type=Pn.Fetch,this.opts=t,await this.reset(t,{fromFetch:!0}),this.iter}async next(t={expires:3e4}){const s=t;if(s.bind)return Promise.reject(new Error("bind is not supported"));s.max_messages=1;const i=ht();return s.callback=c=>{this.userCallback=null,i.resolve(c)},(await this.fetch(s)).iterClosed.then(c=>{c&&i.reject(c),i.resolve(null)}).catch(c=>{i.reject(c)}),i}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(t=>Promise.resolve(t)).catch(t=>Promise.reject(t)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(t){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.startSeq),Promise.resolve(this.currentConsumer)):t&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}class Nd{constructor(t){j(this,"api");j(this,"notified");this.api=t,this.notified=!1}checkVersion(){const t=this.api.nc.features.get(Ge.JS_SIMPLIFICATION);return t.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${t.min} or better`))}getPullConsumerFor(t){if(t.config.deliver_subject!==void 0)throw new Error("push consumer not supported");return new kd(this.api,t)}async get(t,s={}){return typeof s=="object"?this.ordered(t,s):(await this.checkVersion(),this.api.info(t,s).then(i=>i.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new kd(this.api,i)).catch(i=>Promise.reject(i)))}async ordered(t,s){await this.checkVersion();const i=this.api;return new om(i.nc,i.opts).info(t).then(c=>Promise.resolve(new k2(this.api,t,s))).catch(c=>Promise.reject(c))}}class Au{constructor(t,s){j(this,"api");j(this,"_info");this.api=t,this._info=s}get name(){return this._info.config.name}alternates(){return this.info().then(t=>t.alternates?t.alternates:[])}async best(){if(await this.info(),this._info.alternates){const t=await this.api.info(this._info.alternates[0].name);return new Au(this.api,t)}else return this}info(t=!1,s){return t?Promise.resolve(this._info):this.api.info(this.name,s).then(i=>(this._info=i,this._info))}getConsumerFromInfo(t){return new Nd(new du(this.api.nc,this.api.opts)).getPullConsumerFor(t)}getConsumer(t){return new Nd(new du(this.api.nc,this.api.opts)).get(this.name,t)}getMessage(t){return this.api.getMessage(this.name,t)}deleteMessage(t,s){return this.api.deleteMessage(this.name,t,s)}}class om extends To{constructor(t,s){super(t,s)}checkStreamConfigVersions(t){const s=this.nc;if(t.metadata){const{min:o,ok:c}=s.features.get(Ge.JS_STREAM_CONSUMER_METADATA);if(!c)throw new Error(`stream 'metadata' requires server ${o}`)}if(t.first_seq){const{min:o,ok:c}=s.features.get(Ge.JS_STREAM_FIRST_SEQ);if(!c)throw new Error(`stream 'first_seq' requires server ${o}`)}if(t.subject_transform){const{min:o,ok:c}=s.features.get(Ge.JS_STREAM_SUBJECT_TRANSFORM);if(!c)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(t.compression){const{min:o,ok:c}=s.features.get(Ge.JS_STREAM_COMPRESSION);if(!c)throw new Error(`stream 'compression' requires server ${o}`)}if(t.consumer_limits){const{min:o,ok:c}=s.features.get(Ge.JS_DEFAULT_CONSUMER_LIMITS);if(!c)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function i(o,c){var y;if((((y=c==null?void 0:c.subject_transforms)==null?void 0:y.length)||0)>0){const{min:g,ok:u}=s.features.get(Ge.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!u)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}t.sources&&t.sources.forEach(o=>{i("stream sources",o)}),t.mirror&&i("stream mirror",t.mirror)}async add(t={}){var o;this.checkStreamConfigVersions(t),Yt(t.name),t.mirror=oc(t.mirror),t.sources=(o=t.sources)==null?void 0:o.map(oc);const i=await this._request(`${this.prefix}.STREAM.CREATE.${t.name}`,t);return this._fixInfo(i),i}async delete(t){return Yt(t),(await this._request(`${this.prefix}.STREAM.DELETE.${t}`)).success}async update(t,s={}){var y;if(typeof t=="object"){const g=t;t=g.name,s=g,console.trace("\x1B[33m >> streams.update(config: StreamConfig) api changed to streams.update(name: string, config: StreamUpdateConfig) - this shim will be removed - update your code. \x1B[0m")}this.checkStreamConfigVersions(s),Yt(t);const i=await this.info(t),o=Object.assign(i.config,s);o.mirror=oc(o.mirror),o.sources=(y=o.sources)==null?void 0:y.map(oc);const d=await this._request(`${this.prefix}.STREAM.UPDATE.${t}`,o);return this._fixInfo(d),d}async info(t,s){Yt(t);const i=`${this.prefix}.STREAM.INFO.${t}`;let c=await this._request(i,s),{total:d,limit:y}=c,g=c.state.subjects?Object.getOwnPropertyNames(c.state.subjects).length:1;if(d&&d>g){const u=[c],m=s||{};let b=0;for(;d>g;){b++,m.offset=y*b;const v=await this._request(i,m);d=v.total,u.push(v);const _=Object.getOwnPropertyNames(v.state.subjects).length;if(g+=_,_<y)break}let x={};for(let v=0;v<u.length;v++)c=u[v],c.state.subjects&&(x=Object.assign(x,c.state.subjects));c.offset=0,c.total=0,c.limit=0,c.state.subjects=x}return this._fixInfo(c),c}list(t=""){const s=t!=null&&t.length?{subject:t}:{},i=c=>{const d=c;return d.streams.forEach(y=>{this._fixInfo(y)}),d.streams},o=`${this.prefix}.STREAM.LIST`;return new po(o,i,this,s)}_fixInfo(t){t.config.sealed=t.config.sealed||!1,t.config.deny_delete=t.config.deny_delete||!1,t.config.deny_purge=t.config.deny_purge||!1,t.config.allow_rollup_hdrs=t.config.allow_rollup_hdrs||!1}async purge(t,s){if(s){const{keep:o,seq:c}=s;if(typeof o=="number"&&typeof c=="number")throw new Error("can specify one of keep or seq")}return Yt(t),await this._request(`${this.prefix}.STREAM.PURGE.${t}`,s)}async deleteMessage(t,s,i=!0){Yt(t);const o={seq:s};return i||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${t}`,o)).success}async getMessage(t,s){Yt(t);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${t}`,s);return new vx(o)}find(t){return this.findStream(t)}listKvs(){const t=i=>{var g;const c=i.streams.filter(u=>u.config.name.startsWith(bn));c.forEach(u=>{this._fixInfo(u)});let d="";return c.length&&(d=((g=this.nc.info)==null?void 0:g.cluster)??""),c.map(u=>new xx(u,d))},s=`${this.prefix}.STREAM.LIST`;return new po(s,t,this)}listObjectStores(){const t=i=>{const c=i.streams.filter(y=>y.config.name.startsWith(am));return c.forEach(y=>{this._fixInfo(y)}),c.map(y=>new jd(y))},s=`${this.prefix}.STREAM.LIST`;return new po(s,t,this)}names(t=""){const s=t!=null&&t.length?{subject:t}:{},i=c=>c.streams,o=`${this.prefix}.STREAM.NAMES`;return new po(o,i,this,s)}async get(t){const s=await this.info(t);return Promise.resolve(new Au(this,s))}}class N2 extends To{constructor(t,s){super(t,s)}async getMessage(t,s){Yt(t);let i=s;const{last_by_subj:o}=i;o&&(i=null);const c=i?this.jc.encode(i):Sn,d=this.opts.apiPrefix||"$JS.API",y=o?`${d}.DIRECT.GET.${t}.${o}`:`${d}.DIRECT.GET.${t}`,g=await this.nc.request(y,c,{timeout:this.timeout}),u=Ji(g);if(u)return Promise.reject(u);const m=new Td(g);return Promise.resolve(m)}async getBatch(t,s){Yt(t);const o=`${this.opts.apiPrefix||"$JS.API"}.DIRECT.GET.${t}`;if(!Array.isArray(s.multi_last)||s.multi_last.length===0)return Promise.reject("multi_last is required");const c=JSON.stringify(s,(g,u)=>g==="up_to_time"&&u instanceof Date?u.toISOString():u),d=new qt,y=await this.nc.requestMany(o,c,{strategy:Qn.SentinelMsg});return(async()=>{var b,x,v;let g=!1,u=!1,m;for await(const _ of y){if(!g){g=!0;const S=((b=_.headers)==null?void 0:b.code)||0;if(S!==0&&S<200||S>299){m=(x=_.headers)==null?void 0:x.description.toLowerCase();break}if(((v=_.headers)==null?void 0:v.get("Nats-Num-Pending"))===""){u=!0;break}}if(_.data.length===0)break;d.push(new Td(_))}d.push(()=>{if(u)throw new Error("batch direct get not supported by the server");if(m)throw new Error(`bad request: ${m}`);d.stop()})})(),Promise.resolve(d)}}class Td{constructor(t){j(this,"data");j(this,"header");if(!t.headers)throw new Error("headers expected");this.data=t.data,this.header=t.headers}get subject(){return this.header.last(Vi.Subject)}get seq(){const t=this.header.last(Vi.Sequence);return typeof t=="string"?parseInt(t):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(Vi.TimeStamp)}get stream(){return this.header.last(Vi.Stream)}json(t){return Xn(t).decode(this.data)}string(){return vn.decode(this.data)}}j(Td,"jc");class T2 extends To{constructor(s,i){super(s,i);j(this,"streams");j(this,"consumers");j(this,"direct");this.streams=new om(s,i),this.consumers=new du(s,i),this.direct=new N2(s,i)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new qt;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(i,o)=>{if(i)throw i;try{const c=this.parseJsResponse(o),d=c.type.split("."),y=d[d.length-1];s.push({kind:y,data:c})}catch(c){s.stop(c)}}}),s}}class vx{constructor(t){j(this,"_header");j(this,"smr");this.smr=t}get subject(){return this.smr.message.subject}get seq(){return this.smr.message.seq}get timestamp(){return this.smr.message.time}get time(){return new Date(Date.parse(this.timestamp))}get data(){return this.smr.message.data?this._parse(this.smr.message.data):Sn}get header(){if(!this._header)if(this.smr.message.hdrs){const t=this._parse(this.smr.message.hdrs);this._header=vs.decode(t)}else this._header=qr();return this._header}_parse(t){const s=atob(t),i=s.length,o=new Uint8Array(i);for(let c=0;c<i;c++)o[c]=s.charCodeAt(c);return o}json(t){return Xn(t).decode(this.data)}string(){return vn.decode(this.data)}}j(vx,"jc");class C2{constructor(t){j(this,"api");this.api=t}get(t){return this.api.info(t).then(s=>new Au(this.api,s))}}class td{constructor(t){j(this,"info");j(this,"hdrs");this.info=t}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=vs.fromRecord(this.info.headers||{})),this.hdrs}get options(){return this.info.options}get bucket(){return this.info.bucket}get chunks(){return this.info.chunks}get deleted(){return this.info.deleted??!1}get digest(){return this.info.digest}get mtime(){return this.info.mtime}get nuid(){return this.info.nuid}get size(){return this.info.size}get revision(){return this.info.revision}get metadata(){return this.info.metadata||{}}isLink(){var t,s;return((t=this.info.options)==null?void 0:t.link)!==void 0&&((s=this.info.options)==null?void 0:s.link)!==null}}function s1(n){const t={name:n.name,description:n.description??"",options:n.options,metadata:n.metadata};if(n.headers){const s=n.headers;t.headers=s.toRecord()}return t}function M2(){return new ReadableStream({pull(n){n.enqueue(new Uint8Array(0)),n.close()}})}class vo{constructor(t,s,i){j(this,"jsm");j(this,"js");j(this,"stream");j(this,"name");this.name=t,this.jsm=s,this.js=i}_checkNotEmpty(t){return!t||t.length===0?{name:t,error:new Error("name cannot be empty")}:{name:t}}async info(t){const s=await this.rawInfo(t);return s?new td(s):null}async list(){const t=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const i of s){if(i===null)break;t.push(i)}return Promise.resolve(t)}async rawInfo(t){const{name:s,error:i}=this._checkNotEmpty(t);if(i)return Promise.reject(i);const o=this._metaSubject(s);try{const c=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),y=Xn().decode(c.data);return y.revision=c.seq,y}catch(c){return c.code==="404"?null:Promise.reject(c)}}async _si(t){try{return await this.jsm.streams.info(this.stream,t)}catch(s){return s.code==="404"?null:Promise.reject(s)}}async seal(){let t=await this._si();return t===null?Promise.reject(new Error("object store not found")):(t.config.sealed=!0,t=await this.jsm.streams.update(this.stream,t.config),Promise.resolve(new jd(t)))}async status(t){const s=await this._si(t);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new jd(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(t,s,i){var oe;const o=this.js.getOptions();i=i||{timeout:o.timeout},i.timeout=i.timeout||o.timeout,i.previousRevision=i.previousRevision??void 0;const{timeout:c,previousRevision:d}=i,y=this.js.nc.info,g=(y==null?void 0:y.max_payload)||1024;t=t||{},t.options=t.options||{};let u=((oe=t.options)==null?void 0:oe.max_chunk_size)||128*1024;u=u>g?g:u,t.options.max_chunk_size=u;const m=await this.info(t.name),{name:b,error:x}=this._checkNotEmpty(t.name);if(x)return Promise.reject(x);const v=Es.next(),_=this._chunkSubject(v),S=this._metaSubject(b),C=Object.assign({bucket:this.name,nuid:v,size:0,chunks:0},s1(t)),L=ht(),P=[],ie=new na;try{const D=s?s.getReader():null,$=Yg.create();for(;;){const{done:ee,value:K}=D?await D.read():{done:!0,value:void 0};if(ee){if(ie.size()>0){const Q=ie.drain();$.update(Q),C.chunks++,C.size+=Q.length,P.push(this.js.publish(_,Q,{timeout:c}))}await Promise.all(P),P.length=0,C.mtime=new Date().toISOString();const I=Qi.encode($.digest());C.digest=`${n1}${I}`,C.deleted=!1;const M=qr();typeof d=="number"&&M.set(sr.ExpectedLastSubjectSequenceHdr,`${d}`),M.set(Qt.RollupHdr,Qt.RollupValueSubject);const J=await this.js.publish(S,Xn().encode(C),{headers:M,timeout:c});if(C.revision=J.seq,m)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${m.nuid}`})}catch{}L.resolve(new td(C));break}if(K)for(ie.fill(K);ie.size()>u;){C.chunks++,C.size+=u;const I=ie.drain(t.options.max_chunk_size);$.update(I),P.push(this.js.publish(_,I,{timeout:c}))}}}catch(D){await this.jsm.streams.purge(this.stream,{filter:_}),L.reject(D)}return L}putBlob(t,s,i){function o(c){return new ReadableStream({pull(d){d.enqueue(c),d.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(t,o(s),i)}put(t,s,i){var o;return(o=t==null?void 0:t.options)!=null&&o.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(t,s,i)}async getBlob(t){async function s(c){const d=new na,y=c.getReader();for(;;){const{done:g,value:u}=await y.read();if(g)return d.drain();u&&u.length&&d.fill(u)}}const i=await this.get(t);if(i===null)return Promise.resolve(null);const o=await Promise.all([i.error,s(i.data)]);return o[0]?Promise.reject(o[0]):Promise.resolve(o[1])}async get(t){const s=await this.rawInfo(t);if(s===null||s.deleted)return Promise.resolve(null);if(s.options&&s.options.link){const b=s.options.link.name||"";if(b==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await vo.create(this.js,s.options.link.bucket):this).get(b)}if(!s.digest.startsWith(n1))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const i=wd(s.digest.substring(8));if(i===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=ht(),c={info:new td(s),error:o};if(s.size===0)return c.data=M2(),o.resolve(null),Promise.resolve(c);let d;const y=_s();y.orderedConsumer();const g=Yg.create(),u=`$O.${this.name}.C.${s.nuid}`,m=await this.js.subscribe(u,y);return(async()=>{for await(const b of m)b.data.length>0&&(g.update(b.data),d.enqueue(b.data)),b.info.pending===0&&(vE(i,g.digest())?d.close():d.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${i}`)),m.unsubscribe())})().then(()=>{o.resolve()}).catch(b=>{d.error(b),o.reject(b)}),c.data=new ReadableStream({start(b){d=b},cancel(){m.unsubscribe()}}),c}linkStore(t,s){if(!(s instanceof vo))return Promise.reject("bucket required");const i=s,{name:o,error:c}=this._checkNotEmpty(t);if(c)return Promise.reject(c);const d={name:o,options:{link:{bucket:i.name}}};return this._put(d,null)}async link(t,s){const{name:i,error:o}=this._checkNotEmpty(t);if(o)return Promise.reject(o);if(s.deleted)return Promise.reject(new Error("src object is deleted"));if(s.isLink())return Promise.reject(new Error("src object is a link"));const c=await this.rawInfo(t);if(c!==null&&!c.deleted)return Promise.reject(new Error("an object already exists with that name"));const d={bucket:s.bucket,name:s.name},y={name:i,bucket:s.bucket,options:{link:d}};await this.js.publish(this._metaSubject(t),JSON.stringify(y));const g=await this.info(t);return Promise.resolve(g)}async delete(t){const s=await this.rawInfo(t);if(s===null)return Promise.resolve({purged:0,success:!1});s.deleted=!0,s.size=0,s.chunks=0,s.digest="";const i=Xn(),o=qr();return o.set(Qt.RollupHdr,Qt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),i.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(t,s={}){const i=await this.rawInfo(t);if(i===null)return Promise.reject(new Error("object not found"));if(i.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??i.name;const{name:o,error:c}=this._checkNotEmpty(s.name);if(c)return Promise.reject(c);if(t!==s.name){const g=await this.info(s.name);if(g&&!g.deleted)return Promise.reject(new Error("an object already exists with that name"))}s.name=o;const d=Object.assign({},i,s1(s)),y=await this.js.publish(this._metaSubject(d.name),JSON.stringify(d));return t!==s.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(t)}),Promise.resolve(y)}async watch(t={}){t.includeHistory=t.includeHistory??!1,t.ignoreDeletes=t.ignoreDeletes??!1;let s=!1;const i=new qt,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(i.push(null),s=!0):i.stop(g)}const c=Xn(),d=_s();d.orderedConsumer(),t.includeHistory?d.deliverLastPerSubject():(s=!0,d.deliverNew()),d.callback((g,u)=>{var m;if(g){i.stop(g);return}if(u!==null){const b=c.decode(u.data);b.deleted&&t.ignoreDeletes===!0||i.push(b),((m=u.info)==null?void 0:m.pending)===0&&!s&&(s=!0,i.push(null))}});const y=await this.js.subscribe(o,d);return i._data=y,i.iterClosed.then(()=>{y.unsubscribe()}),y.closed.then(()=>{i.stop()}).catch(g=>{i.stop(g)}),i}_chunkSubject(t){return`$O.${this.name}.C.${t}`}_metaSubject(t){return`$O.${this.name}.M.${Qi.encode(t)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(t={}){try{this.stream=_2(this.name)}catch(o){return Promise.reject(o)}const s=(t==null?void 0:t.ttl)||0;delete t.ttl;const i=Object.assign({max_age:s},t);i.name=this.stream,i.num_replicas=t.replicas??1,i.allow_direct=!0,i.allow_rollup_hdrs=!0,i.discard=wo.New,i.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],t.placement&&(i.placement=t.placement),t.metadata&&(i.metadata=t.metadata),typeof t.compression=="boolean"&&(i.compression=t.compression?Os.S2:Os.None);try{await this.jsm.streams.info(i.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(i)}}static async create(t,s,i={}){const o=await t.jetstreamManager(),c=new vo(s,o,t);return await c.init(i),Promise.resolve(c)}}class R2{constructor(t){j(this,"js");this.js=t}kv(t,s={}){const i=this.js,{ok:o,min:c}=i.nc.features.get(Ge.JS_KV);return o?s.bindOnly?Eo.bind(this.js,t,s):Eo.create(this.js,t,s):Promise.reject(new Error(`kv is only supported on servers ${c} or better`))}os(t,s={}){var d;if(typeof((d=crypto==null?void 0:crypto.subtle)==null?void 0:d.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const i=this.js,{ok:o,min:c}=i.nc.features.get(Ge.JS_OBJECTSTORE);return o?vo.create(this.js,t,s):Promise.reject(new Error(`objectstore is only supported on servers ${c} or better`))}}class lm extends To{constructor(s,i){super(s,i);j(this,"consumers");j(this,"streams");j(this,"consumerAPI");j(this,"streamAPI");this.consumerAPI=new du(s,i),this.streamAPI=new om(s,i),this.consumers=new Nd(this.consumerAPI),this.streams=new C2(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const i=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(i)}get apiPrefix(){return this.prefix}get views(){return new R2(this)}async publish(s,i=Sn,o){o=o||{},o.expect=o.expect||{};const c=(o==null?void 0:o.headers)||qr();o&&(o.msgID&&c.set(sr.MsgIdHdr,o.msgID),o.expect.lastMsgID&&c.set(sr.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&c.set(sr.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&c.set(sr.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&c.set(sr.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const d=o.timeout||this.timeout,y={};d&&(y.timeout=d),o&&(y.headers=c);let{retries:g,retry_delay:u}=o;g=g||1,u=u||250;let m;for(let x=0;x<g;x++)try{m=await this.nc.request(s,i,y);break}catch(v){if(v.code==="503"&&x+1<g)await sa(u);else throw v}const b=this.parseJsResponse(m);if(b.stream==="")throw pe.errorForCode(ce.JetStreamInvalidAck);return b.duplicate=b.duplicate?b.duplicate:!1,b}async pull(s,i,o=0){Yt(s),Ki(i);let c=this.timeout;o>c&&(c=o),o=o<0?0:ft(o);const d={batch:1,no_wait:o===0,expires:o},y=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(d),{noMux:!0,timeout:c}),g=Ji(y);if(g)throw g;return Oo(y,this.timeout)}fetch(s,i,o={}){Yt(s),Ki(i);let c=null;const d=(o.max_bytes??0)>0;let y=0;const g=d?o.max_bytes:0;let u=null;const m={};if(m.batch=o.batch||1,g){const P=this.nc.features.get(Ge.JS_PULL_MAX_BYTES);if(!P.ok)throw new Error(`max_bytes is only supported on servers ${P.min} or better`);m.max_bytes=g}m.no_wait=o.no_wait||!1,m.no_wait&&m.expires&&(m.expires=0);const b=o.expires||0;if(b&&(m.expires=ft(b)),b===0&&m.no_wait===!1)throw new Error("expires or no_wait is required");const x=o.idle_heartbeat||0;x&&(m.idle_heartbeat=ft(x),o.delay_heartbeat===!0&&(m.idle_heartbeat=ft(x*4)));const v=new qt,_=m.batch;let S=0;v.protocolFilterFn=(P,ie=!1)=>xd(P.msg)?(u==null||u.work(),!1):!0,v.dispatchedFn=P=>{if(P){if(d&&(y+=P.data.length),S++,c&&P.info.pending===0)return;(v.getPending()===1&&P.info.pending===0||_===S||g>0&&y>=g)&&v.stop()}};const C=Rr(this.nc.options.inboxPrefix),L=this.nc.subscribe(C,{max:o.batch,callback:(P,ie)=>{P===null&&(P=Ji(ie)),P!==null?(c&&(c.cancel(),c=null),tE(P)?v.stop(wx(P)===null?void 0:P):v.stop(P)):(u==null||u.work(),v.received++,v.push(Oo(ie,this.timeout)))}});return b&&(c=ea(b),c.catch(()=>{L.isClosed()||(L.drain().catch(()=>{}),c=null),u&&u.cancel()})),(async()=>{try{x&&(u=new im(x,P=>(v.push(()=>{v.err=new pe(`${Un.IdleHeartbeatMissed}: ${P}`,ce.JetStreamIdleHeartBeat)}),!0)))}catch{}await L.closed,c!==null&&(c.cancel(),c=null),u&&u.cancel(),v.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(m),{reply:C}),v}async pullSubscribe(s,i=_s()){const o=await this._processOptions(s,i);if(o.ordered)throw new Error("pull subscribers cannot be be ordered");if(o.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const c=o.config.ack_policy;if(c===Dt.None||c===Dt.All)throw new Error("ack policy for pull consumers must be explicit");const d=this._buildTypedSubscriptionOpts(o),y=new B2(this,o.deliver,d);y.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw y.unsubscribe(),g}return y}async subscribe(s,i=_s()){const o=await this._processOptions(s,i);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const c=this._buildTypedSubscriptionOpts(o),d=new _x(this,o.deliver,c);d.info=o;try{await this._maybeCreateConsumer(o)}catch(y){throw d.unsubscribe(),y}return d._maybeSetupHbMonitoring(),d}async _processOptions(s,i=_s()){const o=Hg(i)?i.getOpts():i;if(o.isBind=Hg(i)?i.isBind:!1,o.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},o.ordered){if(o.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},o.config.ack_policy!==Dt.NotSet&&o.config.ack_policy!==Dt.None)throw new pe("ordered consumer: ack_policy can only be set to 'none'",ce.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new pe("ordered consumer: durable_name cannot be set",ce.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new pe("ordered consumer: deliver_subject cannot be set",ce.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new pe("ordered consumer: max_deliver cannot be set",ce.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new pe("ordered consumer: deliver_group cannot be set",ce.ApiError);o.config.deliver_subject=Rr(this.nc.options.inboxPrefix),o.config.ack_policy=Dt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||ft(5e3),o.config.ack_wait=ft(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===Dt.NotSet&&(o.config.ack_policy=Dt.All),o.api=this,o.config=o.config||{},o.stream=o.stream?o.stream:await this.findStream(s),o.attached=!1,o.config.durable_name)try{const c=await this.consumerAPI.info(o.stream,o.config.durable_name);if(c){if(c.config.filter_subject&&c.config.filter_subject!==s)throw new Error("subject does not match consumer");const d=o.config.deliver_group??"";if(d===""&&c.push_bound===!0)throw new Error("duplicate subscription");const y=c.config.deliver_group??"";if(d!==y)throw y===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${y}'`);o.last=c,o.config=c.config,o.attached=!0,o.config.durable_name||(o.name=c.name)}}catch(c){if(c.code!=="404")throw c}return!o.attached&&o.config.filter_subject===void 0&&o.config.filter_subjects===void 0&&(o.config.filter_subject=s),o.deliver=o.config.deliver_subject||Rr(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const i={};return i.adapter=P2(s.callbackFn===void 0,this.timeout),i.ingestionFilterFn=lm.ingestionFn(s.ordered),i.protocolFilterFn=(o,c=!1)=>{const d=o;return bd(d.msg)?(c||d.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==Dt.None&&(i.dispatchedFn=I2),s.callbackFn&&(i.callback=s.callbackFn),i.max=s.max||0,i.queue=s.queue,i}async _maybeCreateConsumer(s){if(s.attached)return;if(s.isBind)throw new Error(`unable to bind - durable consumer ${s.config.durable_name} doesn't exist in ${s.stream}`);s.config=Object.assign({deliver_policy:wt.All,ack_policy:Dt.Explicit,ack_wait:ft(30*1e3),replay_policy:ta.Instant},s.config);const i=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(i.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=i.name,s.config=i.config,s.last=i}static ingestionFn(s){return(i,o)=>{var g;const c=o;if(!i)return{ingest:!1,protocol:!1};const d=i;if(Ji(d.msg)||(g=c.monitor)==null||g.work(),xd(d.msg)){const u=s?c._checkHbOrderConsumer(d.msg):!0;return s||c.info.flow_control.heartbeat_count++,{ingest:u,protocol:!0}}else if(bd(d.msg))return c.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?c._checkOrderedConsumer(i):!0,protocol:!1}}}}class cm{constructor(t){j(this,"options");j(this,"protocol");j(this,"draining");j(this,"listeners");j(this,"_services");this.draining=!1,this.options=n2(t),this.listeners=[]}static connect(t={}){return new Promise((s,i)=>{const o=new cm(t);pu.connect(o.options,o).then(c=>{o.protocol=c,(async function(){for await(const d of c.status())o.listeners.forEach(y=>{y.push(d)})})(),s(o)}).catch(c=>{i(c)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(t,s,i){if(this.isClosed())throw pe.errorForCode(ce.ConnectionClosed);if(s&&this.isDraining()||i&&this.protocol.noMorePublishing)throw pe.errorForCode(ce.ConnectionDraining);if(t=t||"",t.length===0)throw pe.errorForCode(ce.BadSubject)}publish(t,s,i){this._check(t,!1,!0),this.protocol.publish(t,s,i)}publishMessage(t){return this.publish(t.subject,t.data,{reply:t.reply,headers:t.headers})}respondMessage(t){return t.reply?(this.publish(t.reply,t.data,{reply:t.reply,headers:t.headers}),!0):!1}subscribe(t,s={}){this._check(t,!0,!1);const i=new gx(this.protocol,t,s);return this.protocol.subscribe(i),i}_resub(t,s,i){this._check(s,!0,!1);const o=t;o.max=i,i&&(o.max=i+o.received),this.protocol.resub(o,s)}requestMany(t,s=Sn,i={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(t,!0,!0)}catch(g){return Promise.reject(g)}if(i.strategy=i.strategy||Qn.Timer,i.maxWait=i.maxWait||1e3,i.maxWait<1)return Promise.reject(new pe("timeout",ce.InvalidOption));const c=new qt;function d(g){c.push(()=>{c.stop(g)})}function y(g,u){g||u===null?d(g===null?void 0:g):c.push(u)}if(i.noMux){const g=o?new Error().stack:null;let u=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1;const m=this.subscribe(Rr(this.options.inboxPrefix),{callback:(_,S)=>{var C,L;if(((C=S==null?void 0:S.data)==null?void 0:C.length)===0&&((L=S==null?void 0:S.headers)==null?void 0:L.status)===ce.NoResponders&&(_=pe.errorForCode(ce.NoResponders)),_){g&&(_.stack+=`
48
+
49
+ ${g}`),b(_);return}y(null,S),i.strategy===Qn.Count&&(u--,u===0&&b()),i.strategy===Qn.JitterTimer&&(v(),x=setTimeout(()=>{b()},300)),i.strategy===Qn.SentinelMsg&&S&&S.data.length===0&&b()}});m.requestSubject=t,m.closed.then(()=>{d()}).catch(_=>{c.stop(_)});const b=_=>{_&&c.push(()=>{throw _}),v(),m.drain().then(()=>{d()}).catch(S=>{d()})};c.iterClosed.then(()=>{v(),m==null||m.unsubscribe()}).catch(_=>{v(),m==null||m.unsubscribe()});try{this.publish(t,s,{reply:m.getSubject()})}catch(_){b(_)}let x=setTimeout(()=>{b()},i.maxWait);const v=()=>{x&&clearTimeout(x)}}else{const g=i;g.callback=y,c.iterClosed.then(()=>{u.cancel()}).catch(m=>{u.cancel(m)});const u=new _E(this.protocol.muxSubscriptions,t,g);this.protocol.request(u);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:i.headers})}catch(m){u.cancel(m)}}return Promise.resolve(c)}request(t,s,i={timeout:1e3,noMux:!1}){try{this._check(t,!0,!0)}catch(c){return Promise.reject(c)}const o=!this.protocol.options.noAsyncTraces;if(i.timeout=i.timeout||1e3,i.timeout<1)return Promise.reject(new pe("timeout",ce.InvalidOption));if(!i.noMux&&i.reply)return Promise.reject(new pe("reply can only be used with noMux",ce.InvalidOption));if(i.noMux){const c=i.reply?i.reply:Rr(this.options.inboxPrefix),d=ht(),y=o?new Error:null,g=this.subscribe(c,{max:1,timeout:i.timeout,callback:(u,m)=>{u?(y&&u.code!==ce.Timeout&&(u.stack+=`
50
+
51
+ ${y.stack}`),g.unsubscribe(),d.reject(u)):(u=lx(m),u?(y&&(u.stack+=`
52
+
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
+ `)[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
+ `)}})}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(`
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
+ ${m}
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]
60
+ ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
61
+ `)}
62
+ [End prior conversation]
63
+
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
+ ... (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