@hotmeshio/long-tail 0.10.9 → 0.10.11

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 (301) hide show
  1. package/build/api/escalations/list.js +11 -4
  2. package/build/api/index.d.ts +1 -0
  3. package/build/api/index.js +2 -1
  4. package/build/api/personas.d.ts +121 -0
  5. package/build/api/personas.js +341 -0
  6. package/build/api/roles.d.ts +2 -0
  7. package/build/api/roles.js +4 -0
  8. package/build/bin/ltc.js +23 -0
  9. package/build/lib/cli/commands/personas.d.ts +16 -0
  10. package/build/lib/cli/commands/personas.js +42 -0
  11. package/build/lib/db/schemas/024_personas.sql +53 -0
  12. package/build/lib/db/schemas/025_ops_home_default.sql +11 -0
  13. package/build/modules/features.d.ts +9 -0
  14. package/build/modules/features.js +1 -0
  15. package/build/routes/index.js +2 -0
  16. package/build/routes/personas.d.ts +2 -0
  17. package/build/routes/personas.js +118 -0
  18. package/build/routes/users.js +35 -0
  19. package/build/sdk/index.d.ts +15 -0
  20. package/build/sdk/index.js +16 -0
  21. package/build/services/persona/index.d.ts +92 -0
  22. package/build/services/persona/index.js +217 -0
  23. package/build/services/persona/sql.d.ts +24 -0
  24. package/build/services/persona/sql.js +158 -0
  25. package/build/services/persona/types.d.ts +23 -0
  26. package/build/services/persona/types.js +33 -0
  27. package/build/services/role/index.js +1 -0
  28. package/build/services/role/sql.d.ts +6 -2
  29. package/build/services/role/sql.js +11 -2
  30. package/build/services/role/types.d.ts +9 -0
  31. package/build/services/user/sql.d.ts +8 -5
  32. package/build/services/user/sql.js +15 -5
  33. package/build/system/mcp-servers/admin/index.d.ts +1 -0
  34. package/build/system/mcp-servers/admin/index.js +5 -2
  35. package/build/system/mcp-servers/admin/personas.d.ts +8 -0
  36. package/build/system/mcp-servers/admin/personas.js +186 -0
  37. package/build/system/mcp-servers/admin/schemas.d.ts +94 -0
  38. package/build/system/mcp-servers/admin/schemas.js +43 -2
  39. package/build/system/mcp-servers/admin/users.js +1 -0
  40. package/build/system/seed/tool-manifests-admin.d.ts +1057 -0
  41. package/build/system/seed/tool-manifests-admin.js +12 -1
  42. package/build/tsconfig.tsbuildinfo +1 -1
  43. package/build/types/index.d.ts +1 -0
  44. package/build/types/persona.d.ts +56 -0
  45. package/build/types/persona.js +2 -0
  46. package/build/types/startup.d.ts +8 -0
  47. package/build/types/user.d.ts +2 -0
  48. package/dashboard/dist/assets/{AdminDashboard-DWSYdAeW.js → AdminDashboard-CkTbRfY9.js} +2 -2
  49. package/dashboard/dist/assets/{AdminDashboard-DWSYdAeW.js.map → AdminDashboard-CkTbRfY9.js.map} +1 -1
  50. package/dashboard/dist/assets/{AgentConfigPage-Dm6gL76m.js → AgentConfigPage-Cm8FRpXi.js} +2 -2
  51. package/dashboard/dist/assets/{AgentConfigPage-Dm6gL76m.js.map → AgentConfigPage-Cm8FRpXi.js.map} +1 -1
  52. package/dashboard/dist/assets/AgentDetailPage-sQ1-UT46.js +4 -0
  53. package/dashboard/dist/assets/AgentDetailPage-sQ1-UT46.js.map +1 -0
  54. package/dashboard/dist/assets/{AgentsPage-DKaDRk-Y.js → AgentsPage-bSx_mdae.js} +2 -2
  55. package/dashboard/dist/assets/{AgentsPage-DKaDRk-Y.js.map → AgentsPage-bSx_mdae.js.map} +1 -1
  56. package/dashboard/dist/assets/AutoGrowTextarea-y-oNY51_.js +2 -0
  57. package/dashboard/dist/assets/AutoGrowTextarea-y-oNY51_.js.map +1 -0
  58. package/dashboard/dist/assets/AvailableEscalationsPage-8pMC7Xv6.js +2 -0
  59. package/dashboard/dist/assets/AvailableEscalationsPage-8pMC7Xv6.js.map +1 -0
  60. package/dashboard/dist/assets/{BotPicker-DRv_orzI.js → BotPicker-C4uGH2x9.js} +2 -2
  61. package/dashboard/dist/assets/{BotPicker-DRv_orzI.js.map → BotPicker-C4uGH2x9.js.map} +1 -1
  62. package/dashboard/dist/assets/{CapabilitiesPage-DqRVzMol.js → CapabilitiesPage-BRoOeKcc.js} +2 -2
  63. package/dashboard/dist/assets/{CapabilitiesPage-DqRVzMol.js.map → CapabilitiesPage-BRoOeKcc.js.map} +1 -1
  64. package/dashboard/dist/assets/{CollapsibleSection-D0psvw8i.js → CollapsibleSection-CIj8Adc9.js} +2 -2
  65. package/dashboard/dist/assets/{CollapsibleSection-D0psvw8i.js.map → CollapsibleSection-CIj8Adc9.js.map} +1 -1
  66. package/dashboard/dist/assets/{ConfirmDeleteModal-DD7SEMeX.js → ConfirmDeleteModal-Ugi_9Ukq.js} +2 -2
  67. package/dashboard/dist/assets/{ConfirmDeleteModal-DD7SEMeX.js.map → ConfirmDeleteModal-Ugi_9Ukq.js.map} +1 -1
  68. package/dashboard/dist/assets/{CopyableId-BpB-NvDh.js → CopyableId-GUEdiiL5.js} +2 -2
  69. package/dashboard/dist/assets/{CopyableId-BpB-NvDh.js.map → CopyableId-GUEdiiL5.js.map} +1 -1
  70. package/dashboard/dist/assets/CountdownTimer-D3t0XMhE.js +2 -0
  71. package/dashboard/dist/assets/CountdownTimer-D3t0XMhE.js.map +1 -0
  72. package/dashboard/dist/assets/{CredentialsPage-Axdci1z-.js → CredentialsPage-B73Si6K1.js} +2 -2
  73. package/dashboard/dist/assets/{CredentialsPage-Axdci1z-.js.map → CredentialsPage-B73Si6K1.js.map} +1 -1
  74. package/dashboard/dist/assets/{CronLabel-BjZ_wZA8.js → CronLabel-Ca1aHolt.js} +2 -2
  75. package/dashboard/dist/assets/{CronLabel-BjZ_wZA8.js.map → CronLabel-Ca1aHolt.js.map} +1 -1
  76. package/dashboard/dist/assets/{CustomDurationPicker-CkUCMUfk.js → CustomDurationPicker-_9E9x1YN.js} +2 -2
  77. package/dashboard/dist/assets/{CustomDurationPicker-CkUCMUfk.js.map → CustomDurationPicker-_9E9x1YN.js.map} +1 -1
  78. package/dashboard/dist/assets/{DropZone-_tmC3jEe.js → DropZone-NYn6TWHz.js} +2 -2
  79. package/dashboard/dist/assets/{DropZone-_tmC3jEe.js.map → DropZone-NYn6TWHz.js.map} +1 -1
  80. package/dashboard/dist/assets/ElapsedCell-karxia93.js +2 -0
  81. package/dashboard/dist/assets/{ElapsedCell-BE_CN5sP.js.map → ElapsedCell-karxia93.js.map} +1 -1
  82. package/dashboard/dist/assets/{EscalationListSchemaPage-CgcVIiYR.js → EscalationListSchemaPage-CDaNmbUA.js} +3 -3
  83. package/dashboard/dist/assets/{EscalationListSchemaPage-CgcVIiYR.js.map → EscalationListSchemaPage-CDaNmbUA.js.map} +1 -1
  84. package/dashboard/dist/assets/{EscalationSchemaPage-BaAn1Hcr.js → EscalationSchemaPage-k-2hFT2t.js} +3 -3
  85. package/dashboard/dist/assets/{EscalationSchemaPage-BaAn1Hcr.js.map → EscalationSchemaPage-k-2hFT2t.js.map} +1 -1
  86. package/dashboard/dist/assets/{EscalationsOverview-Dbq7tKzr.js → EscalationsOverview-C1e7IPn_.js} +2 -2
  87. package/dashboard/dist/assets/{EscalationsOverview-Dbq7tKzr.js.map → EscalationsOverview-C1e7IPn_.js.map} +1 -1
  88. package/dashboard/dist/assets/{EventTable-0RUK9jqt.js → EventTable-CIrrtL7_.js} +2 -2
  89. package/dashboard/dist/assets/{EventTable-0RUK9jqt.js.map → EventTable-CIrrtL7_.js.map} +1 -1
  90. package/dashboard/dist/assets/{FilterBar-B_dy2Jhj.js → FilterBar-CzjtH74v.js} +2 -2
  91. package/dashboard/dist/assets/{FilterBar-B_dy2Jhj.js.map → FilterBar-CzjtH74v.js.map} +1 -1
  92. package/dashboard/dist/assets/{GraphInvokePage-CvLYp1nL.js → GraphInvokePage-LMpWw8z1.js} +2 -2
  93. package/dashboard/dist/assets/{GraphInvokePage-CvLYp1nL.js.map → GraphInvokePage-LMpWw8z1.js.map} +1 -1
  94. package/dashboard/dist/assets/HomePage-Kl2DBG6l.js +2 -0
  95. package/dashboard/dist/assets/HomePage-Kl2DBG6l.js.map +1 -0
  96. package/dashboard/dist/assets/ListToolbar-B2fub0DY.js +2 -0
  97. package/dashboard/dist/assets/ListToolbar-B2fub0DY.js.map +1 -0
  98. package/dashboard/dist/assets/{McpOverview-Ca8cpc8g.js → McpOverview-odYnCZCC.js} +2 -2
  99. package/dashboard/dist/assets/{McpOverview-Ca8cpc8g.js.map → McpOverview-odYnCZCC.js.map} +1 -1
  100. package/dashboard/dist/assets/McpQueryDetailPage-BtqwHUAg.js +5 -0
  101. package/dashboard/dist/assets/McpQueryDetailPage-BtqwHUAg.js.map +1 -0
  102. package/dashboard/dist/assets/McpQueryPage-CPkVwNIK.js +2 -0
  103. package/dashboard/dist/assets/McpQueryPage-CPkVwNIK.js.map +1 -0
  104. package/dashboard/dist/assets/{McpRunDetailPage-C76mfUtG.js → McpRunDetailPage-D-Rz9MRw.js} +2 -2
  105. package/dashboard/dist/assets/{McpRunDetailPage-C76mfUtG.js.map → McpRunDetailPage-D-Rz9MRw.js.map} +1 -1
  106. package/dashboard/dist/assets/{McpRunsPage-B43BqEyw.js → McpRunsPage-rdpZ2yMh.js} +2 -2
  107. package/dashboard/dist/assets/{McpRunsPage-B43BqEyw.js.map → McpRunsPage-rdpZ2yMh.js.map} +1 -1
  108. package/dashboard/dist/assets/{Modal-CA2Iv02H.js → Modal-Dr1Xy0j0.js} +2 -2
  109. package/dashboard/dist/assets/{Modal-CA2Iv02H.js.map → Modal-Dr1Xy0j0.js.map} +1 -1
  110. package/dashboard/dist/assets/{NamespacePill-B5gHotsd.js → NamespacePill-GwO-WfhX.js} +2 -2
  111. package/dashboard/dist/assets/{NamespacePill-B5gHotsd.js.map → NamespacePill-GwO-WfhX.js.map} +1 -1
  112. package/dashboard/dist/assets/OperationsPage-DlyGLPAs.js +2 -0
  113. package/dashboard/dist/assets/OperationsPage-DlyGLPAs.js.map +1 -0
  114. package/dashboard/dist/assets/OperatorDashboard-Csei5vj-.js +2 -0
  115. package/dashboard/dist/assets/OperatorDashboard-Csei5vj-.js.map +1 -0
  116. package/dashboard/dist/assets/{PageHeader-DrbNMGxm.js → PageHeader-Bo9BU9pK.js} +2 -2
  117. package/dashboard/dist/assets/{PageHeader-DrbNMGxm.js.map → PageHeader-Bo9BU9pK.js.map} +1 -1
  118. package/dashboard/dist/assets/{PageHeaderWithStats-SbQkaQLG.js → PageHeaderWithStats-8_5cOSKL.js} +2 -2
  119. package/dashboard/dist/assets/{PageHeaderWithStats-SbQkaQLG.js.map → PageHeaderWithStats-8_5cOSKL.js.map} +1 -1
  120. package/dashboard/dist/assets/PersonaDetailPage--ZL6Or6v.js +2 -0
  121. package/dashboard/dist/assets/PersonaDetailPage--ZL6Or6v.js.map +1 -0
  122. package/dashboard/dist/assets/PersonasPage-Bdcoay3P.js +2 -0
  123. package/dashboard/dist/assets/PersonasPage-Bdcoay3P.js.map +1 -0
  124. package/dashboard/dist/assets/ProcessDetailPage-HrmVQq7S.js +2 -0
  125. package/dashboard/dist/assets/ProcessDetailPage-HrmVQq7S.js.map +1 -0
  126. package/dashboard/dist/assets/{ProcessesListPage-Di0n8TR4.js → ProcessesListPage-_xmj6Bo-.js} +2 -2
  127. package/dashboard/dist/assets/{ProcessesListPage-Di0n8TR4.js.map → ProcessesListPage-_xmj6Bo-.js.map} +1 -1
  128. package/dashboard/dist/assets/RoleDetailPage-C0ju2-4K.js +8 -0
  129. package/dashboard/dist/assets/RoleDetailPage-C0ju2-4K.js.map +1 -0
  130. package/dashboard/dist/assets/{RolePill-Cz-AAWqA.js → RolePill-CQlnEWkK.js} +2 -2
  131. package/dashboard/dist/assets/{RolePill-Cz-AAWqA.js.map → RolePill-CQlnEWkK.js.map} +1 -1
  132. package/dashboard/dist/assets/RolesPage-CKluVSpB.js +2 -0
  133. package/dashboard/dist/assets/RolesPage-CKluVSpB.js.map +1 -0
  134. package/dashboard/dist/assets/{RunAsSelector-DFv0VNVZ.js → RunAsSelector-DdfecQ1U.js} +2 -2
  135. package/dashboard/dist/assets/{RunAsSelector-DFv0VNVZ.js.map → RunAsSelector-DdfecQ1U.js.map} +1 -1
  136. package/dashboard/dist/assets/ScopeBadge-BBYkevuR.js +2 -0
  137. package/dashboard/dist/assets/ScopeBadge-BBYkevuR.js.map +1 -0
  138. package/dashboard/dist/assets/StatCard-Ca-ngCaD.js +2 -0
  139. package/dashboard/dist/assets/StatCard-Ca-ngCaD.js.map +1 -0
  140. package/dashboard/dist/assets/{StatusBadge-BbqghFMi.js → StatusBadge-BwUvykDo.js} +2 -2
  141. package/dashboard/dist/assets/{StatusBadge-BbqghFMi.js.map → StatusBadge-BwUvykDo.js.map} +1 -1
  142. package/dashboard/dist/assets/{StickyPagination-D5zxe_l9.js → StickyPagination-cLddIdtT.js} +2 -2
  143. package/dashboard/dist/assets/{StickyPagination-D5zxe_l9.js.map → StickyPagination-cLddIdtT.js.map} +1 -1
  144. package/dashboard/dist/assets/{StreamMessageDetail-BmBfNSEr.js → StreamMessageDetail-CZXWDawC.js} +2 -2
  145. package/dashboard/dist/assets/StreamMessageDetail-CZXWDawC.js.map +1 -0
  146. package/dashboard/dist/assets/{SwimlaneTimeline-CA0TKDIi.js → SwimlaneTimeline-fWY0gaf3.js} +2 -2
  147. package/dashboard/dist/assets/{SwimlaneTimeline-CA0TKDIi.js.map → SwimlaneTimeline-fWY0gaf3.js.map} +1 -1
  148. package/dashboard/dist/assets/{TagInput-Bf9dZSG6.js → TagInput-CDKbslLx.js} +2 -2
  149. package/dashboard/dist/assets/{TagInput-Bf9dZSG6.js.map → TagInput-CDKbslLx.js.map} +1 -1
  150. package/dashboard/dist/assets/{TaskDetailPage-C15nADUW.js → TaskDetailPage-BjE4G2yn.js} +2 -2
  151. package/dashboard/dist/assets/{TaskDetailPage-C15nADUW.js.map → TaskDetailPage-BjE4G2yn.js.map} +1 -1
  152. package/dashboard/dist/assets/{TaskQueuePill-DfiBYQy2.js → TaskQueuePill-G3RuYRNZ.js} +2 -2
  153. package/dashboard/dist/assets/{TaskQueuePill-DfiBYQy2.js.map → TaskQueuePill-G3RuYRNZ.js.map} +1 -1
  154. package/dashboard/dist/assets/{TasksListPage-DQdAayqc.js → TasksListPage-KAhmCWB2.js} +2 -2
  155. package/dashboard/dist/assets/{TasksListPage-DQdAayqc.js.map → TasksListPage-KAhmCWB2.js.map} +1 -1
  156. package/dashboard/dist/assets/{TimeAgo-CvslqTB7.js → TimeAgo-C_H2TyZw.js} +2 -2
  157. package/dashboard/dist/assets/{TimeAgo-CvslqTB7.js.map → TimeAgo-C_H2TyZw.js.map} +1 -1
  158. package/dashboard/dist/assets/{TimestampCell-BZCQQONl.js → TimestampCell-COG_4Flg.js} +2 -2
  159. package/dashboard/dist/assets/{TimestampCell-BZCQQONl.js.map → TimestampCell-COG_4Flg.js.map} +1 -1
  160. package/dashboard/dist/assets/{ToolPill-gA4sXukc.js → ToolPill-ChSyRJZC.js} +2 -2
  161. package/dashboard/dist/assets/{ToolPill-gA4sXukc.js.map → ToolPill-ChSyRJZC.js.map} +1 -1
  162. package/dashboard/dist/assets/{ToolTestPanel-BgLVc6R5.js → ToolTestPanel-BPdJECW0.js} +2 -2
  163. package/dashboard/dist/assets/{ToolTestPanel-BgLVc6R5.js.map → ToolTestPanel-BPdJECW0.js.map} +1 -1
  164. package/dashboard/dist/assets/{TopicDetailPage-9A0aPb4t.js → TopicDetailPage-DAqx5JqA.js} +3 -3
  165. package/dashboard/dist/assets/{TopicDetailPage-9A0aPb4t.js.map → TopicDetailPage-DAqx5JqA.js.map} +1 -1
  166. package/dashboard/dist/assets/{TopicsPage-o0EZxKbR.js → TopicsPage-DoGqAdPm.js} +2 -2
  167. package/dashboard/dist/assets/{TopicsPage-o0EZxKbR.js.map → TopicsPage-DoGqAdPm.js.map} +1 -1
  168. package/dashboard/dist/assets/{UserName-DKMLxBJ5.js → UserName-CKO_rk1R.js} +2 -2
  169. package/dashboard/dist/assets/{UserName-DKMLxBJ5.js.map → UserName-CKO_rk1R.js.map} +1 -1
  170. package/dashboard/dist/assets/{WorkflowExecutionPage-C-snB_dD.js → WorkflowExecutionPage-D3VQ9iQV.js} +2 -2
  171. package/dashboard/dist/assets/{WorkflowExecutionPage-C-snB_dD.js.map → WorkflowExecutionPage-D3VQ9iQV.js.map} +1 -1
  172. package/dashboard/dist/assets/{WorkflowPill-Djt2AtZk.js → WorkflowPill-CNbwug5p.js} +2 -2
  173. package/dashboard/dist/assets/{WorkflowPill-Djt2AtZk.js.map → WorkflowPill-CNbwug5p.js.map} +1 -1
  174. package/dashboard/dist/assets/{WorkflowsDashboard-BRQmgsLR.js → WorkflowsDashboard-DdJ86We6.js} +2 -2
  175. package/dashboard/dist/assets/{WorkflowsDashboard-BRQmgsLR.js.map → WorkflowsDashboard-DdJ86We6.js.map} +1 -1
  176. package/dashboard/dist/assets/{WorkflowsOverview-DmMdIRHQ.js → WorkflowsOverview-ZfFBzePp.js} +2 -2
  177. package/dashboard/dist/assets/{WorkflowsOverview-DmMdIRHQ.js.map → WorkflowsOverview-ZfFBzePp.js.map} +1 -1
  178. package/dashboard/dist/assets/{YamlWorkflowDetailPage-Bj7QkCry.js → YamlWorkflowDetailPage-4bd5yXdA.js} +2 -2
  179. package/dashboard/dist/assets/{YamlWorkflowDetailPage-Bj7QkCry.js.map → YamlWorkflowDetailPage-4bd5yXdA.js.map} +1 -1
  180. package/dashboard/dist/assets/{YamlWorkflowsPage-BIi77mE0.js → YamlWorkflowsPage-iHPNXjQj.js} +2 -2
  181. package/dashboard/dist/assets/{YamlWorkflowsPage-BIi77mE0.js.map → YamlWorkflowsPage-iHPNXjQj.js.map} +1 -1
  182. package/dashboard/dist/assets/{agents-EBIsjLCr.js → agents-DjD5U3Wb.js} +2 -2
  183. package/dashboard/dist/assets/{agents-EBIsjLCr.js.map → agents-DjD5U3Wb.js.map} +1 -1
  184. package/dashboard/dist/assets/{bots-BXzxybS6.js → bots-DiljVapH.js} +2 -2
  185. package/dashboard/dist/assets/{bots-BXzxybS6.js.map → bots-DiljVapH.js.map} +1 -1
  186. package/dashboard/dist/assets/{capabilities-CnprG6q_.js → capabilities-DV_5ghHT.js} +2 -2
  187. package/dashboard/dist/assets/{capabilities-CnprG6q_.js.map → capabilities-DV_5ghHT.js.map} +1 -1
  188. package/dashboard/dist/assets/{controlplane-DiC0xtNq.js → controlplane-BKMvfWCB.js} +2 -2
  189. package/dashboard/dist/assets/{controlplane-DiC0xtNq.js.map → controlplane-BKMvfWCB.js.map} +1 -1
  190. package/dashboard/dist/assets/escalation-columns-BQpCaJId.js +2 -0
  191. package/dashboard/dist/assets/escalation-columns-BQpCaJId.js.map +1 -0
  192. package/dashboard/dist/assets/{index-BzRXMicE.js → index-B-WkiNRN.js} +2 -2
  193. package/dashboard/dist/assets/{index-BzRXMicE.js.map → index-B-WkiNRN.js.map} +1 -1
  194. package/dashboard/dist/assets/index-BO-7S9Xw.js +2 -0
  195. package/dashboard/dist/assets/index-BO-7S9Xw.js.map +1 -0
  196. package/dashboard/dist/assets/{index-C7KY8GTF.js → index-BaV3l0UE.js} +2 -2
  197. package/dashboard/dist/assets/{index-C7KY8GTF.js.map → index-BaV3l0UE.js.map} +1 -1
  198. package/dashboard/dist/assets/{index-B6ldRx_s.js → index-BsOxMMmb.js} +2 -2
  199. package/dashboard/dist/assets/{index-B6ldRx_s.js.map → index-BsOxMMmb.js.map} +1 -1
  200. package/dashboard/dist/assets/index-CI8rrKjx.js +2 -0
  201. package/dashboard/dist/assets/{index-CjBdB8Ht.js.map → index-CI8rrKjx.js.map} +1 -1
  202. package/dashboard/dist/assets/index-CItsikDw.js +2 -0
  203. package/dashboard/dist/assets/index-CItsikDw.js.map +1 -0
  204. package/dashboard/dist/assets/{index-CcMIca5t.js → index-CStR4uIU.js} +2 -2
  205. package/dashboard/dist/assets/{index-CcMIca5t.js.map → index-CStR4uIU.js.map} +1 -1
  206. package/dashboard/dist/assets/{index-CSTwyrwu.js → index-DbTD-dio.js} +26 -26
  207. package/dashboard/dist/assets/index-DbTD-dio.js.map +1 -0
  208. package/dashboard/dist/assets/{index-gBnGEubX.js → index-DhATO1cS.js} +2 -2
  209. package/dashboard/dist/assets/{index-gBnGEubX.js.map → index-DhATO1cS.js.map} +1 -1
  210. package/dashboard/dist/assets/index-DnlsDaAw.css +1 -0
  211. package/dashboard/dist/assets/{index-ovFEZ9SV.js → index-Tx_ETzcH.js} +2 -2
  212. package/dashboard/dist/assets/{index-ovFEZ9SV.js.map → index-Tx_ETzcH.js.map} +1 -1
  213. package/dashboard/dist/assets/{index-DVmC_UfQ.js → index-kzIIeVbx.js} +4 -4
  214. package/dashboard/dist/assets/{index-DVmC_UfQ.js.map → index-kzIIeVbx.js.map} +1 -1
  215. package/dashboard/dist/assets/{index-BHAjQoOy.js → index-nIrYejxe.js} +3 -3
  216. package/dashboard/dist/assets/{index-BHAjQoOy.js.map → index-nIrYejxe.js.map} +1 -1
  217. package/dashboard/dist/assets/{index-Dht0ihGT.js → index-xZqQxqu2.js} +2 -2
  218. package/dashboard/dist/assets/{index-Dht0ihGT.js.map → index-xZqQxqu2.js.map} +1 -1
  219. package/dashboard/dist/assets/{knowledge-W5QSKkYQ.js → knowledge-BocTnSiA.js} +2 -2
  220. package/dashboard/dist/assets/{knowledge-W5QSKkYQ.js.map → knowledge-BocTnSiA.js.map} +1 -1
  221. package/dashboard/dist/assets/{mcp-n877HyOj.js → mcp-C1KBjKQ_.js} +2 -2
  222. package/dashboard/dist/assets/{mcp-n877HyOj.js.map → mcp-C1KBjKQ_.js.map} +1 -1
  223. package/dashboard/dist/assets/{mcp-query-C9kV4sUm.js → mcp-query-B3cjukkA.js} +2 -2
  224. package/dashboard/dist/assets/{mcp-query-C9kV4sUm.js.map → mcp-query-B3cjukkA.js.map} +1 -1
  225. package/dashboard/dist/assets/personas-DiA2bJaX.js +2 -0
  226. package/dashboard/dist/assets/personas-DiA2bJaX.js.map +1 -0
  227. package/dashboard/dist/assets/{pipelines-CBR68T8R.js → pipelines-Dt2d2EFR.js} +2 -2
  228. package/dashboard/dist/assets/{pipelines-CBR68T8R.js.map → pipelines-Dt2d2EFR.js.map} +1 -1
  229. package/dashboard/dist/assets/{tasks-DHpWqKMk.js → tasks-cDh2hNml.js} +2 -2
  230. package/dashboard/dist/assets/{tasks-DHpWqKMk.js.map → tasks-cDh2hNml.js.map} +1 -1
  231. package/dashboard/dist/assets/{topics-CaLtyqSh.js → topics-yFlGF-u1.js} +2 -2
  232. package/dashboard/dist/assets/{topics-CaLtyqSh.js.map → topics-yFlGF-u1.js.map} +1 -1
  233. package/dashboard/dist/assets/{useEventHooks-B8p56JlB.js → useEventHooks-D2R_ckS8.js} +2 -2
  234. package/dashboard/dist/assets/{useEventHooks-B8p56JlB.js.map → useEventHooks-D2R_ckS8.js.map} +1 -1
  235. package/dashboard/dist/assets/{useFilterParams-CvRyYHJN.js → useFilterParams-B7suPsIK.js} +2 -2
  236. package/dashboard/dist/assets/{useFilterParams-CvRyYHJN.js.map → useFilterParams-B7suPsIK.js.map} +1 -1
  237. package/dashboard/dist/assets/{useNamespace-ej71FCvu.js → useNamespace-u-V1GVUD.js} +2 -2
  238. package/dashboard/dist/assets/{useNamespace-ej71FCvu.js.map → useNamespace-u-V1GVUD.js.map} +1 -1
  239. package/dashboard/dist/assets/{useYamlActivityEvents-DgpiFXib.js → useYamlActivityEvents-BhOZeqgE.js} +2 -2
  240. package/dashboard/dist/assets/{useYamlActivityEvents-DgpiFXib.js.map → useYamlActivityEvents-BhOZeqgE.js.map} +1 -1
  241. package/dashboard/dist/assets/{users-CHnjI_Ca.js → users-BoXPwdee.js} +2 -2
  242. package/dashboard/dist/assets/{users-CHnjI_Ca.js.map → users-BoXPwdee.js.map} +1 -1
  243. package/dashboard/dist/assets/{vendor-icons-Bg6eJX4Z.js → vendor-icons-D71XjkNy.js} +133 -128
  244. package/dashboard/dist/assets/vendor-icons-D71XjkNy.js.map +1 -0
  245. package/dashboard/dist/assets/{vendor-react-BpdAFEQc.js → vendor-react-C1YOyCSV.js} +2 -2
  246. package/dashboard/dist/assets/{vendor-react-BpdAFEQc.js.map → vendor-react-C1YOyCSV.js.map} +1 -1
  247. package/dashboard/dist/assets/{workflows-DtnXUL0U.js → workflows-mCoyKuLZ.js} +2 -2
  248. package/dashboard/dist/assets/{workflows-DtnXUL0U.js.map → workflows-mCoyKuLZ.js.map} +1 -1
  249. package/dashboard/dist/assets/{yaml-workflows-DDclYAID.js → yaml-workflows-CWxXGDpn.js} +2 -2
  250. package/dashboard/dist/assets/{yaml-workflows-DDclYAID.js.map → yaml-workflows-CWxXGDpn.js.map} +1 -1
  251. package/dashboard/dist/index.html +4 -4
  252. package/docs/api/http/personas.md +160 -0
  253. package/docs/cli.md +12 -0
  254. package/docs/dashboard.md +25 -3
  255. package/docs/design-principles.md +13 -5
  256. package/docs/hitl/pinned-views.md +3 -3
  257. package/docs/hitl/x-lt-list-schema.md +2 -3
  258. package/docs/iam.md +47 -0
  259. package/docs/operations.md +1 -1
  260. package/docs/sdk.md +1 -0
  261. package/package.json +1 -1
  262. package/dashboard/dist/assets/AgentDetailPage-D-Xbyrb6.js +0 -4
  263. package/dashboard/dist/assets/AgentDetailPage-D-Xbyrb6.js.map +0 -1
  264. package/dashboard/dist/assets/AvailableEscalationsPage-B-aHvGKD.js +0 -2
  265. package/dashboard/dist/assets/AvailableEscalationsPage-B-aHvGKD.js.map +0 -1
  266. package/dashboard/dist/assets/CountdownTimer-BhF3oqS8.js +0 -2
  267. package/dashboard/dist/assets/CountdownTimer-BhF3oqS8.js.map +0 -1
  268. package/dashboard/dist/assets/ElapsedCell-BE_CN5sP.js +0 -2
  269. package/dashboard/dist/assets/HomePage-B6s1ZeyA.js +0 -2
  270. package/dashboard/dist/assets/HomePage-B6s1ZeyA.js.map +0 -1
  271. package/dashboard/dist/assets/ListToolbar-DVhlAKZ3.js +0 -2
  272. package/dashboard/dist/assets/ListToolbar-DVhlAKZ3.js.map +0 -1
  273. package/dashboard/dist/assets/McpQueryDetailPage-D0r2lyZg.js +0 -5
  274. package/dashboard/dist/assets/McpQueryDetailPage-D0r2lyZg.js.map +0 -1
  275. package/dashboard/dist/assets/McpQueryPage-DPP6BB3d.js +0 -2
  276. package/dashboard/dist/assets/McpQueryPage-DPP6BB3d.js.map +0 -1
  277. package/dashboard/dist/assets/OperationsPage-DbHzQCuE.js +0 -2
  278. package/dashboard/dist/assets/OperationsPage-DbHzQCuE.js.map +0 -1
  279. package/dashboard/dist/assets/OperatorDashboard-B70nS_Ah.js +0 -2
  280. package/dashboard/dist/assets/OperatorDashboard-B70nS_Ah.js.map +0 -1
  281. package/dashboard/dist/assets/ProcessDetailPage-eLLUCWFf.js +0 -2
  282. package/dashboard/dist/assets/ProcessDetailPage-eLLUCWFf.js.map +0 -1
  283. package/dashboard/dist/assets/RoleDetailPage-Dhn9zU5l.js +0 -8
  284. package/dashboard/dist/assets/RoleDetailPage-Dhn9zU5l.js.map +0 -1
  285. package/dashboard/dist/assets/RolesPage-BnAwjUiG.js +0 -2
  286. package/dashboard/dist/assets/RolesPage-BnAwjUiG.js.map +0 -1
  287. package/dashboard/dist/assets/StatCard-DBANWIss.js +0 -2
  288. package/dashboard/dist/assets/StatCard-DBANWIss.js.map +0 -1
  289. package/dashboard/dist/assets/StreamMessageDetail-BmBfNSEr.js.map +0 -1
  290. package/dashboard/dist/assets/escalation-columns-D0aYpJkF.js +0 -2
  291. package/dashboard/dist/assets/escalation-columns-D0aYpJkF.js.map +0 -1
  292. package/dashboard/dist/assets/index-B2iZG_HP.css +0 -1
  293. package/dashboard/dist/assets/index-CSTwyrwu.js.map +0 -1
  294. package/dashboard/dist/assets/index-CjBdB8Ht.js +0 -2
  295. package/dashboard/dist/assets/index-D-7mT0ew.js +0 -2
  296. package/dashboard/dist/assets/index-D-7mT0ew.js.map +0 -1
  297. package/dashboard/dist/assets/index-DDA7FvqT.js +0 -2
  298. package/dashboard/dist/assets/index-DDA7FvqT.js.map +0 -1
  299. package/dashboard/dist/assets/role-display-Dvo2lDpU.js +0 -2
  300. package/dashboard/dist/assets/role-display-Dvo2lDpU.js.map +0 -1
  301. package/dashboard/dist/assets/vendor-icons-Bg6eJX4Z.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-Di0n8TR4.js","./vendor-query-B2UbickB.js","./tasks-DHpWqKMk.js","./workflows-DtnXUL0U.js","./useEventHooks-B8p56JlB.js","./useFilterParams-CvRyYHJN.js","./vendor-react-BpdAFEQc.js","./useDebouncedValue-BA5S7V54.js","./api-path-u2Jf9QXS.js","./DataTable-BTu2AaEl.js","./EmptyState-BcsfPq9T.js","./TimestampCell-BZCQQONl.js","./StickyPagination-D5zxe_l9.js","./FilterBar-B_dy2Jhj.js","./vendor-icons-Bg6eJX4Z.js","./PageHeader-DrbNMGxm.js","./ListToolbar-DVhlAKZ3.js","./WorkflowPill-Djt2AtZk.js","./ProcessDetailPage-eLLUCWFf.js","./PageHeaderWithStats-SbQkaQLG.js","./StatusBadge-BbqghFMi.js","./RolePill-Cz-AAWqA.js","./UserName-DKMLxBJ5.js","./users-CHnjI_Ca.js","./McpOverview-Ca8cpc8g.js","./mcp-n877HyOj.js","./pipelines-CBR68T8R.js","./yaml-workflows-DDclYAID.js","./controlplane-DiC0xtNq.js","./StatCard-DBANWIss.js","./McpRunsPage-B43BqEyw.js","./useNamespace-ej71FCvu.js","./ElapsedCell-BE_CN5sP.js","./RowActions-BA9L9djf.js","./McpRunDetailPage-C76mfUtG.js","./CopyableId-BpB-NvDh.js","./CollapsibleSection-D0psvw8i.js","./EventTable-0RUK9jqt.js","./SwimlaneTimeline-CA0TKDIi.js","./StreamMessageDetail-BmBfNSEr.js","./McpQueryPage-DPP6BB3d.js","./mcp-query-C9kV4sUm.js","./McpQueryDetailPage-D0r2lyZg.js","./TagInput-Bf9dZSG6.js","./useYamlActivityEvents-DgpiFXib.js","./helpers-DzO-OGPe.js","./RunAsSelector-DFv0VNVZ.js","./BotPicker-DRv_orzI.js","./bots-BXzxybS6.js","./ToolPill-gA4sXukc.js","./TimeAgo-CvslqTB7.js","./EscalationsOverview-Dbq7tKzr.js","./AvailableEscalationsPage-B-aHvGKD.js","./task-queues-7-sHKPsN.js","./CustomDurationPicker-CkUCMUfk.js","./Modal-CA2Iv02H.js","./constants-BHkpVaqx.js","./role-display-Dvo2lDpU.js","./CountdownTimer-BhF3oqS8.js","./escalation-columns-D0aYpJkF.js","./PriorityBadge-CCERr9vQ.js","./OperatorDashboard-B70nS_Ah.js","./index-DVmC_UfQ.js","./WorkflowsOverview-DmMdIRHQ.js","./index-BzRXMicE.js","./NamespacePill-B5gHotsd.js","./WorkflowsDashboard-BRQmgsLR.js","./YamlWorkflowsPage-BIi77mE0.js","./GraphInvokePage-CvLYp1nL.js","./YamlWorkflowDetailPage-Bj7QkCry.js","./TasksListPage-DQdAayqc.js","./TaskDetailPage-C15nADUW.js","./WorkflowExecutionPage-C-snB_dD.js","./AdminDashboard-DWSYdAeW.js","./index-B6ldRx_s.js","./TaskQueuePill-DfiBYQy2.js","./index-BHAjQoOy.js","./ConfirmDeleteModal-DD7SEMeX.js","./index-C7KY8GTF.js","./ToolTestPanel-BgLVc6R5.js","./index-CjBdB8Ht.js","./index-D-7mT0ew.js","./RolesPage-BnAwjUiG.js","./RoleDetailPage-Dhn9zU5l.js","./EscalationSchemaPage-BaAn1Hcr.js","./EscalationListSchemaPage-CgcVIiYR.js","./index-CcMIca5t.js","./OperationsPage-DbHzQCuE.js","./index-DDA7FvqT.js","./index-gBnGEubX.js","./CredentialsPage-Axdci1z-.js","./index-ovFEZ9SV.js","./DropZone-_tmC3jEe.js","./index-Dht0ihGT.js","./knowledge-W5QSKkYQ.js","./HomePage-B6s1ZeyA.js","./AgentsPage-DKaDRk-Y.js","./agents-EBIsjLCr.js","./AgentDetailPage-D-Xbyrb6.js","./CronLabel-BjZ_wZA8.js","./AgentConfigPage-Dm6gL76m.js","./capabilities-CnprG6q_.js","./topics-CaLtyqSh.js","./CapabilitiesPage-DqRVzMol.js","./TopicsPage-o0EZxKbR.js","./TopicDetailPage-9A0aPb4t.js"])))=>i.map(i=>d[i]);
2
- var Wx=Object.defineProperty;var ev=(i,t,s)=>t in i?Wx(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var v=(i,t,s)=>ev(i,typeof t!="symbol"?t+"":t,s);import{r as tv,a as A,j as h,u as ht,b as bt,c as Et,Q as nv,d as sv}from"./vendor-query-B2UbickB.js";import{r as iv,u as Sn,a as nh,L as Ni,N as Tr,b as jg,c as Pn,O as Sr,d as rv,R as av}from"./vendor-react-BpdAFEQc.js";import{X as Gn,E as lv,S as ov,M as cv,C as Ag,a as Nf,I as Tf,R as Og,B as Ng,U as uv,b as fv,L as hv,c as dv,Z as mv,P as m0,d as Tg,e as pv,f as p0,g as g0,h as y0,i as gv,W as sh,j as yv,k as bv,F as xv,l as vv,m as _v,N as wv,n as Sv,D as Ev,o as kg,p as Cg,q as jv,r as Av,s as Ov,t as Nv,u as Tv,G as kv,T as Cv,v as Mv,w as Rv,x as Dv}from"./vendor-icons-Bg6eJX4Z.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"]'))a(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function s(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(o){if(o.ep)return;o.ep=!0;const u=s(o);fetch(o.href,u)}})();var uf={exports:{}},ka={},ff={exports:{}},hf={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-_xmj6Bo-.js","./vendor-query-B2UbickB.js","./tasks-cDh2hNml.js","./workflows-mCoyKuLZ.js","./useEventHooks-D2R_ckS8.js","./useFilterParams-B7suPsIK.js","./vendor-react-C1YOyCSV.js","./useDebouncedValue-BA5S7V54.js","./api-path-u2Jf9QXS.js","./DataTable-BTu2AaEl.js","./EmptyState-BcsfPq9T.js","./TimestampCell-COG_4Flg.js","./StickyPagination-cLddIdtT.js","./FilterBar-CzjtH74v.js","./vendor-icons-D71XjkNy.js","./PageHeader-Bo9BU9pK.js","./ListToolbar-B2fub0DY.js","./WorkflowPill-CNbwug5p.js","./ProcessDetailPage-HrmVQq7S.js","./PageHeaderWithStats-8_5cOSKL.js","./StatusBadge-BwUvykDo.js","./RolePill-CQlnEWkK.js","./UserName-CKO_rk1R.js","./users-BoXPwdee.js","./McpOverview-odYnCZCC.js","./mcp-C1KBjKQ_.js","./pipelines-Dt2d2EFR.js","./yaml-workflows-CWxXGDpn.js","./controlplane-BKMvfWCB.js","./StatCard-Ca-ngCaD.js","./McpRunsPage-rdpZ2yMh.js","./useNamespace-u-V1GVUD.js","./ElapsedCell-karxia93.js","./RowActions-BA9L9djf.js","./McpRunDetailPage-D-Rz9MRw.js","./CopyableId-GUEdiiL5.js","./CollapsibleSection-CIj8Adc9.js","./EventTable-CIrrtL7_.js","./SwimlaneTimeline-fWY0gaf3.js","./StreamMessageDetail-CZXWDawC.js","./McpQueryPage-CPkVwNIK.js","./mcp-query-B3cjukkA.js","./McpQueryDetailPage-BtqwHUAg.js","./TagInput-CDKbslLx.js","./useYamlActivityEvents-BhOZeqgE.js","./helpers-DzO-OGPe.js","./RunAsSelector-DdfecQ1U.js","./BotPicker-C4uGH2x9.js","./bots-DiljVapH.js","./ToolPill-ChSyRJZC.js","./TimeAgo-C_H2TyZw.js","./EscalationsOverview-C1e7IPn_.js","./AvailableEscalationsPage-8pMC7Xv6.js","./task-queues-7-sHKPsN.js","./CustomDurationPicker-_9E9x1YN.js","./Modal-Dr1Xy0j0.js","./constants-BHkpVaqx.js","./escalation-columns-BQpCaJId.js","./PriorityBadge-CCERr9vQ.js","./CountdownTimer-D3t0XMhE.js","./OperatorDashboard-Csei5vj-.js","./index-kzIIeVbx.js","./WorkflowsOverview-ZfFBzePp.js","./index-B-WkiNRN.js","./NamespacePill-GwO-WfhX.js","./WorkflowsDashboard-DdJ86We6.js","./YamlWorkflowsPage-iHPNXjQj.js","./GraphInvokePage-LMpWw8z1.js","./YamlWorkflowDetailPage-4bd5yXdA.js","./TasksListPage-KAhmCWB2.js","./TaskDetailPage-BjE4G2yn.js","./WorkflowExecutionPage-D3VQ9iQV.js","./AdminDashboard-CkTbRfY9.js","./index-BsOxMMmb.js","./TaskQueuePill-G3RuYRNZ.js","./index-nIrYejxe.js","./ConfirmDeleteModal-Ugi_9Ukq.js","./index-BaV3l0UE.js","./ToolTestPanel-BPdJECW0.js","./index-CI8rrKjx.js","./index-CItsikDw.js","./personas-DiA2bJaX.js","./ScopeBadge-BBYkevuR.js","./RolesPage-CKluVSpB.js","./RoleDetailPage-C0ju2-4K.js","./AutoGrowTextarea-y-oNY51_.js","./PersonasPage-Bdcoay3P.js","./PersonaDetailPage--ZL6Or6v.js","./EscalationSchemaPage-k-2hFT2t.js","./EscalationListSchemaPage-CDaNmbUA.js","./index-CStR4uIU.js","./OperationsPage-DlyGLPAs.js","./index-BO-7S9Xw.js","./index-DhATO1cS.js","./CredentialsPage-B73Si6K1.js","./index-Tx_ETzcH.js","./DropZone-NYn6TWHz.js","./index-xZqQxqu2.js","./knowledge-BocTnSiA.js","./HomePage-Kl2DBG6l.js","./AgentsPage-bSx_mdae.js","./agents-DjD5U3Wb.js","./AgentDetailPage-sQ1-UT46.js","./CronLabel-Ca1aHolt.js","./AgentConfigPage-Cm8FRpXi.js","./capabilities-DV_5ghHT.js","./topics-yFlGF-u1.js","./CapabilitiesPage-BRoOeKcc.js","./TopicsPage-DoGqAdPm.js","./TopicDetailPage-DAqx5JqA.js"])))=>i.map(i=>d[i]);
2
+ var tv=Object.defineProperty;var nv=(i,t,s)=>t in i?tv(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var v=(i,t,s)=>nv(i,typeof t!="symbol"?t+"":t,s);import{r as sv,a as j,j as h,u as ht,b as bt,c as Et,Q as iv,d as rv}from"./vendor-query-B2UbickB.js";import{r as av,u as Fo,a as on,L as ki,N as Tr,b as Tg,c as Pn,O as Sr,d as lv,R as ov}from"./vendor-react-C1YOyCSV.js";import{X as Gn,E as cv,S as uv,M as fv,C as kg,a as Tf,I as kf,R as Cg,B as Mg,U as hv,b as dv,L as mv,c as pv,Z as gv,P as g0,d as Rg,e as yv,f as y0,g as b0,h as x0,i as bv,W as sh,j as xv,k as vv,F as _v,l as wv,m as Sv,D as Ev,N as jv,n as Av,o as Ov,p as Dg,q as qg,r as Nv,s as Tv,t as kv,u as Cv,v as Mv,G as Rv,T as Dv,w as qv,x as zv,y as Uv}from"./vendor-icons-D71XjkNy.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"]'))a(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function s(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(o){if(o.ep)return;o.ep=!0;const u=s(o);fetch(o.href,u)}})();var ff={exports:{}},ka={},hf={exports:{}},df={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -7,7 +7,7 @@ var Wx=Object.defineProperty;var ev=(i,t,s)=>t in i?Wx(i,t,{enumerable:!0,config
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var b0;function qv(){return b0||(b0=1,(function(i){function t(z,ne){var se=z.length;z.push(ne);e:for(;0<se;){var ge=se-1>>>1,be=z[ge];if(0<o(be,ne))z[ge]=ne,z[se]=be,se=ge;else break e}}function s(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var ne=z[0],se=z.pop();if(se!==ne){z[0]=se;e:for(var ge=0,be=z.length,Ce=be>>>1;ge<Ce;){var Ee=2*(ge+1)-1,Me=z[Ee],lt=Ee+1,Vt=z[lt];if(0>o(Me,se))lt<be&&0>o(Vt,Me)?(z[ge]=Vt,z[lt]=se,ge=lt):(z[ge]=Me,z[Ee]=se,ge=Ee);else if(lt<be&&0>o(Vt,se))z[ge]=Vt,z[lt]=se,ge=lt;else break e}}return ne}function o(z,ne){var se=z.sortIndex-ne.sortIndex;return se!==0?se:z.id-ne.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;i.unstable_now=function(){return u.now()}}else{var d=Date,m=d.now();i.unstable_now=function(){return d.now()-m}}var g=[],y=[],E=1,_=null,N=3,R=!1,M=!1,D=!1,G=!1,te=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,ce=typeof setImmediate<"u"?setImmediate:null;function oe(z){for(var ne=s(y);ne!==null;){if(ne.callback===null)a(y);else if(ne.startTime<=z)a(y),ne.sortIndex=ne.expirationTime,t(g,ne);else break;ne=s(y)}}function O(z){if(D=!1,oe(z),!M)if(s(g)!==null)M=!0,J||(J=!0,ie());else{var ne=s(y);ne!==null&&Se(O,ne.startTime-z)}}var J=!1,ae=-1,I=5,F=-1;function Z(){return G?!0:!(i.unstable_now()-F<I)}function re(){if(G=!1,J){var z=i.unstable_now();F=z;var ne=!0;try{e:{M=!1,D&&(D=!1,$(ae),ae=-1),R=!0;var se=N;try{t:{for(oe(z),_=s(g);_!==null&&!(_.expirationTime>z&&Z());){var ge=_.callback;if(typeof ge=="function"){_.callback=null,N=_.priorityLevel;var be=ge(_.expirationTime<=z);if(z=i.unstable_now(),typeof be=="function"){_.callback=be,oe(z),ne=!0;break t}_===s(g)&&a(g),oe(z)}else a(g);_=s(g)}if(_!==null)ne=!0;else{var Ce=s(y);Ce!==null&&Se(O,Ce.startTime-z),ne=!1}}break e}finally{_=null,N=se,R=!1}ne=void 0}}finally{ne?ie():J=!1}}}var ie;if(typeof ce=="function")ie=function(){ce(re)};else if(typeof MessageChannel<"u"){var Oe=new MessageChannel,ke=Oe.port2;Oe.port1.onmessage=re,ie=function(){ke.postMessage(null)}}else ie=function(){te(re,0)};function Se(z,ne){ae=te(function(){z(i.unstable_now())},ne)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(z){z.callback=null},i.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<z?Math.floor(1e3/z):5},i.unstable_getCurrentPriorityLevel=function(){return N},i.unstable_next=function(z){switch(N){case 1:case 2:case 3:var ne=3;break;default:ne=N}var se=N;N=ne;try{return z()}finally{N=se}},i.unstable_requestPaint=function(){G=!0},i.unstable_runWithPriority=function(z,ne){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var se=N;N=z;try{return ne()}finally{N=se}},i.unstable_scheduleCallback=function(z,ne,se){var ge=i.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?ge+se:ge):se=ge,z){case 1:var be=-1;break;case 2:be=250;break;case 5:be=1073741823;break;case 4:be=1e4;break;default:be=5e3}return be=se+be,z={id:E++,callback:ne,priorityLevel:z,startTime:se,expirationTime:be,sortIndex:-1},se>ge?(z.sortIndex=se,t(y,z),s(g)===null&&z===s(y)&&(D?($(ae),ae=-1):D=!0,Se(O,se-ge))):(z.sortIndex=be,t(g,z),M||R||(M=!0,J||(J=!0,ie()))),z},i.unstable_shouldYield=Z,i.unstable_wrapCallback=function(z){var ne=N;return function(){var se=N;N=ne;try{return z.apply(this,arguments)}finally{N=se}}}})(hf)),hf}var x0;function zv(){return x0||(x0=1,ff.exports=qv()),ff.exports}/**
10
+ */var v0;function Bv(){return v0||(v0=1,(function(i){function t($,se){var ie=$.length;$.push(se);e:for(;0<ie;){var be=ie-1>>>1,ve=$[be];if(0<o(ve,se))$[be]=se,$[ie]=ve,ie=be;else break e}}function s($){return $.length===0?null:$[0]}function a($){if($.length===0)return null;var se=$[0],ie=$.pop();if(ie!==se){$[0]=ie;e:for(var be=0,ve=$.length,Ce=ve>>>1;be<Ce;){var Ae=2*(be+1)-1,Me=$[Ae],lt=Ae+1,Vt=$[lt];if(0>o(Me,ie))lt<ve&&0>o(Vt,Me)?($[be]=Vt,$[lt]=ie,be=lt):($[be]=Me,$[Ae]=ie,be=Ae);else if(lt<ve&&0>o(Vt,ie))$[be]=Vt,$[lt]=ie,be=lt;else break e}}return se}function o($,se){var ie=$.sortIndex-se.sortIndex;return ie!==0?ie:$.id-se.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;i.unstable_now=function(){return u.now()}}else{var d=Date,m=d.now();i.unstable_now=function(){return d.now()-m}}var g=[],y=[],E=1,_=null,T=3,R=!1,C=!1,D=!1,F=!1,te=typeof setTimeout=="function"?setTimeout:null,X=typeof clearTimeout=="function"?clearTimeout:null,fe=typeof setImmediate<"u"?setImmediate:null;function oe($){for(var se=s(y);se!==null;){if(se.callback===null)a(y);else if(se.startTime<=$)a(y),se.sortIndex=se.expirationTime,t(g,se);else break;se=s(y)}}function O($){if(D=!1,oe($),!C)if(s(g)!==null)C=!0,U||(U=!0,re());else{var se=s(y);se!==null&&Se(O,se.startTime-$)}}var U=!1,ne=-1,G=5,I=-1;function Z(){return F?!0:!(i.unstable_now()-I<G)}function ae(){if(F=!1,U){var $=i.unstable_now();I=$;var se=!0;try{e:{C=!1,D&&(D=!1,X(ne),ne=-1),R=!0;var ie=T;try{t:{for(oe($),_=s(g);_!==null&&!(_.expirationTime>$&&Z());){var be=_.callback;if(typeof be=="function"){_.callback=null,T=_.priorityLevel;var ve=be(_.expirationTime<=$);if($=i.unstable_now(),typeof ve=="function"){_.callback=ve,oe($),se=!0;break t}_===s(g)&&a(g),oe($)}else a(g);_=s(g)}if(_!==null)se=!0;else{var Ce=s(y);Ce!==null&&Se(O,Ce.startTime-$),se=!1}}break e}finally{_=null,T=ie,R=!1}se=void 0}}finally{se?re():U=!1}}}var re;if(typeof fe=="function")re=function(){fe(ae)};else if(typeof MessageChannel<"u"){var je=new MessageChannel,he=je.port2;je.port1.onmessage=ae,re=function(){he.postMessage(null)}}else re=function(){te(ae,0)};function Se($,se){ne=te(function(){$(i.unstable_now())},se)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function($){$.callback=null},i.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<$?Math.floor(1e3/$):5},i.unstable_getCurrentPriorityLevel=function(){return T},i.unstable_next=function($){switch(T){case 1:case 2:case 3:var se=3;break;default:se=T}var ie=T;T=se;try{return $()}finally{T=ie}},i.unstable_requestPaint=function(){F=!0},i.unstable_runWithPriority=function($,se){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var ie=T;T=$;try{return se()}finally{T=ie}},i.unstable_scheduleCallback=function($,se,ie){var be=i.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0<ie?be+ie:be):ie=be,$){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ie+ve,$={id:E++,callback:se,priorityLevel:$,startTime:ie,expirationTime:ve,sortIndex:-1},ie>be?($.sortIndex=ie,t(y,$),s(g)===null&&$===s(y)&&(D?(X(ne),ne=-1):D=!0,Se(O,ie-be))):($.sortIndex=ve,t(g,$),C||R||(C=!0,U||(U=!0,re()))),$},i.unstable_shouldYield=Z,i.unstable_wrapCallback=function($){var se=T;return function(){var ie=T;T=se;try{return $.apply(this,arguments)}finally{T=ie}}}})(df)),df}var _0;function Lv(){return _0||(_0=1,hf.exports=Bv()),hf.exports}/**
11
11
  * @license React
12
12
  * react-dom-client.production.js
13
13
  *
@@ -15,28 +15,28 @@ var Wx=Object.defineProperty;var ev=(i,t,s)=>t in i?Wx(i,t,{enumerable:!0,config
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var v0;function Uv(){if(v0)return ka;v0=1;var i=zv(),t=tv(),s=iv();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+e+"; visit "+n+" 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 u(e){var n=e,r=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(r=n.return),e=n.return;while(e)}return n.tag===3?r:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function m(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(a(188))}function y(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(a(188));return n!==e?null:e}for(var r=e,l=n;;){var c=r.return;if(c===null)break;var f=c.alternate;if(f===null){if(l=c.return,l!==null){r=l;continue}break}if(c.child===f.child){for(f=c.child;f;){if(f===r)return g(c),e;if(f===l)return g(c),n;f=f.sibling}throw Error(a(188))}if(r.return!==l.return)r=c,l=f;else{for(var p=!1,b=c.child;b;){if(b===r){p=!0,r=c,l=f;break}if(b===l){p=!0,l=c,r=f;break}b=b.sibling}if(!p){for(b=f.child;b;){if(b===r){p=!0,r=f,l=c;break}if(b===l){p=!0,l=f,r=c;break}b=b.sibling}if(!p)throw Error(a(189))}}if(r.alternate!==l)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?e:n}function E(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=E(e),n!==null)return n;e=e.sibling}return null}var _=Object.assign,N=Symbol.for("react.element"),R=Symbol.for("react.transitional.element"),M=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),te=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),ce=Symbol.for("react.context"),oe=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),Z=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function ie(e){return e===null||typeof e!="object"?null:(e=re&&e[re]||e["@@iterator"],typeof e=="function"?e:null)}var Oe=Symbol.for("react.client.reference");function ke(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case D:return"Fragment";case te:return"Profiler";case G:return"StrictMode";case O:return"Suspense";case J:return"SuspenseList";case F:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case M:return"Portal";case ce:return e.displayName||"Context";case $:return(e._context.displayName||"Context")+".Consumer";case oe:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return n=e.displayName||null,n!==null?n:ke(e.type)||"Memo";case I:n=e._payload,e=e._init;try{return ke(e(n))}catch{}}return null}var Se=Array.isArray,z=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ge=[],be=-1;function Ce(e){return{current:e}}function Ee(e){0>be||(e.current=ge[be],ge[be]=null,be--)}function Me(e,n){be++,ge[be]=e.current,e.current=n}var lt=Ce(null),Vt=Ce(null),on=Ce(null),kt=Ce(null);function Ct(e,n){switch(Me(on,n),Me(Vt,e),Me(lt,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Up(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Up(n),e=Bp(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Ee(lt),Me(lt,e)}function je(){Ee(lt),Ee(Vt),Ee(on)}function Mt(e){e.memoizedState!==null&&Me(kt,e);var n=lt.current,r=Bp(n,e.type);n!==r&&(Me(Vt,e),Me(lt,r))}function ni(e){Vt.current===e&&(Ee(lt),Ee(Vt)),kt.current===e&&(Ee(kt),Aa._currentValue=se)}var Ri,si;function cn(e){if(Ri===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Ri=n&&n[1]||"",si=-1<r.stack.indexOf(`
18
+ */var w0;function Pv(){if(w0)return ka;w0=1;var i=Lv(),t=sv(),s=av();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+e+"; visit "+n+" 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 u(e){var n=e,r=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(r=n.return),e=n.return;while(e)}return n.tag===3?r:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function m(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(a(188))}function y(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(a(188));return n!==e?null:e}for(var r=e,l=n;;){var c=r.return;if(c===null)break;var f=c.alternate;if(f===null){if(l=c.return,l!==null){r=l;continue}break}if(c.child===f.child){for(f=c.child;f;){if(f===r)return g(c),e;if(f===l)return g(c),n;f=f.sibling}throw Error(a(188))}if(r.return!==l.return)r=c,l=f;else{for(var p=!1,b=c.child;b;){if(b===r){p=!0,r=c,l=f;break}if(b===l){p=!0,l=c,r=f;break}b=b.sibling}if(!p){for(b=f.child;b;){if(b===r){p=!0,r=f,l=c;break}if(b===l){p=!0,l=f,r=c;break}b=b.sibling}if(!p)throw Error(a(189))}}if(r.alternate!==l)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?e:n}function E(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=E(e),n!==null)return n;e=e.sibling}return null}var _=Object.assign,T=Symbol.for("react.element"),R=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),te=Symbol.for("react.profiler"),X=Symbol.for("react.consumer"),fe=Symbol.for("react.context"),oe=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),Z=Symbol.for("react.memo_cache_sentinel"),ae=Symbol.iterator;function re(e){return e===null||typeof e!="object"?null:(e=ae&&e[ae]||e["@@iterator"],typeof e=="function"?e:null)}var je=Symbol.for("react.client.reference");function he(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===je?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case D:return"Fragment";case te:return"Profiler";case F:return"StrictMode";case O:return"Suspense";case U:return"SuspenseList";case I:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case fe:return e.displayName||"Context";case X:return(e._context.displayName||"Context")+".Consumer";case oe:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ne:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case G:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}var Se=Array.isArray,$=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},be=[],ve=-1;function Ce(e){return{current:e}}function Ae(e){0>ve||(e.current=be[ve],be[ve]=null,ve--)}function Me(e,n){ve++,be[ve]=e.current,e.current=n}var lt=Ce(null),Vt=Ce(null),cn=Ce(null),kt=Ce(null);function Ct(e,n){switch(Me(cn,n),Me(Vt,e),Me(lt,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Lp(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Lp(n),e=Pp(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Ae(lt),Me(lt,e)}function Oe(){Ae(lt),Ae(Vt),Ae(cn)}function Mt(e){e.memoizedState!==null&&Me(kt,e);var n=lt.current,r=Pp(n,e.type);n!==r&&(Me(Vt,e),Me(lt,r))}function ii(e){Vt.current===e&&(Ae(lt),Ae(Vt)),kt.current===e&&(Ae(kt),Aa._currentValue=ie)}var Ri,ri;function un(e){if(Ri===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Ri=n&&n[1]||"",ri=-1<r.stack.indexOf(`
19
19
  at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
20
- `+Ri+e+si}var Di=!1;function ys(e,n){if(!e||Di)return"";Di=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var W=function(){throw Error()};if(Object.defineProperty(W.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(W,[])}catch(Y){var P=Y}Reflect.construct(e,[],W)}else{try{W.call()}catch(Y){P=Y}e.call(W.prototype)}}else{try{throw Error()}catch(Y){P=Y}(W=e())&&typeof W.catch=="function"&&W.catch(function(){})}}catch(Y){if(Y&&P&&typeof Y.stack=="string")return[Y.stack,P.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=l.DetermineComponentFrameRoot(),p=f[0],b=f[1];if(p&&b){var T=p.split(`
20
+ `+Ri+e+ri}var Di=!1;function ys(e,n){if(!e||Di)return"";Di=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var W=function(){throw Error()};if(Object.defineProperty(W.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(W,[])}catch(Y){var P=Y}Reflect.construct(e,[],W)}else{try{W.call()}catch(Y){P=Y}e.call(W.prototype)}}else{try{throw Error()}catch(Y){P=Y}(W=e())&&typeof W.catch=="function"&&W.catch(function(){})}}catch(Y){if(Y&&P&&typeof Y.stack=="string")return[Y.stack,P.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=l.DetermineComponentFrameRoot(),p=f[0],b=f[1];if(p&&b){var N=p.split(`
21
21
  `),L=b.split(`
22
- `);for(c=l=0;l<T.length&&!T[l].includes("DetermineComponentFrameRoot");)l++;for(;c<L.length&&!L[c].includes("DetermineComponentFrameRoot");)c++;if(l===T.length||c===L.length)for(l=T.length-1,c=L.length-1;1<=l&&0<=c&&T[l]!==L[c];)c--;for(;1<=l&&0<=c;l--,c--)if(T[l]!==L[c]){if(l!==1||c!==1)do if(l--,c--,0>c||T[l]!==L[c]){var V=`
23
- `+T[l].replace(" at new "," at ");return e.displayName&&V.includes("<anonymous>")&&(V=V.replace("<anonymous>",e.displayName)),V}while(1<=l&&0<=c);break}}}finally{Di=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?cn(r):""}function Wa(e,n){switch(e.tag){case 26:case 27:case 5:return cn(e.type);case 16:return cn("Lazy");case 13:return e.child!==n&&n!==null?cn("Suspense Fallback"):cn("Suspense");case 19:return cn("SuspenseList");case 0:case 15:return ys(e.type,!1);case 11:return ys(e.type.render,!1);case 1:return ys(e.type,!0);case 31:return cn("Activity");default:return""}}function el(e){try{var n="",r=null;do n+=Wa(e,r),r=e,e=e.return;while(e);return n}catch(l){return`
22
+ `);for(c=l=0;l<N.length&&!N[l].includes("DetermineComponentFrameRoot");)l++;for(;c<L.length&&!L[c].includes("DetermineComponentFrameRoot");)c++;if(l===N.length||c===L.length)for(l=N.length-1,c=L.length-1;1<=l&&0<=c&&N[l]!==L[c];)c--;for(;1<=l&&0<=c;l--,c--)if(N[l]!==L[c]){if(l!==1||c!==1)do if(l--,c--,0>c||N[l]!==L[c]){var V=`
23
+ `+N[l].replace(" at new "," at ");return e.displayName&&V.includes("<anonymous>")&&(V=V.replace("<anonymous>",e.displayName)),V}while(1<=l&&0<=c);break}}}finally{Di=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?un(r):""}function Za(e,n){switch(e.tag){case 26:case 27:case 5:return un(e.type);case 16:return un("Lazy");case 13:return e.child!==n&&n!==null?un("Suspense Fallback"):un("Suspense");case 19:return un("SuspenseList");case 0:case 15:return ys(e.type,!1);case 11:return ys(e.type.render,!1);case 1:return ys(e.type,!0);case 31:return un("Activity");default:return""}}function Wa(e){try{var n="",r=null;do n+=Za(e,r),r=e,e=e.return;while(e);return n}catch(l){return`
24
24
  Error generating stack: `+l.message+`
25
- `+l.stack}}var zr=Object.prototype.hasOwnProperty,Ur=i.unstable_scheduleCallback,In=i.unstable_cancelCallback,tl=i.unstable_shouldYield,qi=i.unstable_requestPaint,et=i.unstable_now,Wo=i.unstable_getCurrentPriorityLevel,nl=i.unstable_ImmediatePriority,sl=i.unstable_UserBlockingPriority,zi=i.unstable_NormalPriority,ec=i.unstable_LowPriority,il=i.unstable_IdlePriority,tc=i.log,rl=i.unstable_setDisableYieldValue,ii=null,ot=null;function It(e){if(typeof tc=="function"&&rl(e),ot&&typeof ot.setStrictMode=="function")try{ot.setStrictMode(ii,e)}catch{}}var Rt=Math.clz32?Math.clz32:Ui,Br=Math.log,Lr=Math.LN2;function Ui(e){return e>>>=0,e===0?32:31-(Br(e)/Lr|0)|0}var bs=256,Fn=262144,xs=4194304;function En(e){var n=e&42;if(n!==0)return n;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 ri(e,n,r){var l=e.pendingLanes;if(l===0)return 0;var c=0,f=e.suspendedLanes,p=e.pingedLanes;e=e.warmLanes;var b=l&134217727;return b!==0?(l=b&~f,l!==0?c=En(l):(p&=b,p!==0?c=En(p):r||(r=b&~e,r!==0&&(c=En(r))))):(b=l&~f,b!==0?c=En(b):p!==0?c=En(p):r||(r=l&~e,r!==0&&(c=En(r)))),c===0?0:n!==0&&n!==c&&(n&f)===0&&(f=c&-c,r=n&-n,f>=r||f===32&&(r&4194048)!==0)?n:c}function ai(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Pr(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 Bi(){var e=xs;return xs<<=1,(xs&62914560)===0&&(xs=4194304),e}function vs(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function jn(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function _s(e,n,r,l,c,f){var p=e.pendingLanes;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=r,e.entangledLanes&=r,e.errorRecoveryDisabledLanes&=r,e.shellSuspendCounter=0;var b=e.entanglements,T=e.expirationTimes,L=e.hiddenUpdates;for(r=p&~r;0<r;){var V=31-Rt(r),W=1<<V;b[V]=0,T[V]=-1;var P=L[V];if(P!==null)for(L[V]=null,V=0;V<P.length;V++){var Y=P[V];Y!==null&&(Y.lane&=-536870913)}r&=~W}l!==0&&ws(e,l,0),f!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=f&~(p&~n))}function ws(e,n,r){e.pendingLanes|=n,e.suspendedLanes&=~n;var l=31-Rt(n);e.entangledLanes|=n,e.entanglements[l]=e.entanglements[l]|1073741824|r&261930}function li(e,n){var r=e.entangledLanes|=n;for(e=e.entanglements;r;){var l=31-Rt(r),c=1<<l;c&n|e[l]&n&&(e[l]|=n),r&=~c}}function Ss(e,n){var r=n&-n;return r=(r&42)!==0?1:Jn(r),(r&(e.suspendedLanes|n))!==0?0:r}function Jn(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 oi(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Hr(){var e=ne.p;return e!==0?e:(e=window.event,e===void 0?32:l0(e.type))}function al(e,n){var r=ne.p;try{return ne.p=e,n()}finally{ne.p=r}}var qn=Math.random().toString(36).slice(2),Qe="__reactFiber$"+qn,it="__reactProps$"+qn,Ft="__reactContainer$"+qn,ci="__reactEvents$"+qn,$r="__reactListeners$"+qn,ll="__reactHandles$"+qn,ol="__reactResources$"+qn,xt="__reactMarker$"+qn;function Li(e){delete e[Qe],delete e[it],delete e[ci],delete e[$r],delete e[ll]}function x(e){var n=e[Qe];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Ft]||r[Qe]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=Vp(e);e!==null;){if(r=e[Qe])return r;e=Vp(e)}return n}e=r,r=e.parentNode}return null}function S(e){if(e=e[Qe]||e[Ft]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function w(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function j(e){var n=e[ol];return n||(n=e[ol]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function k(e){e[xt]=!0}var U=new Set,X={};function ee(e,n){H(e,n),H(e+"Capture",n)}function H(e,n){for(X[e]=n,e=0;e<n.length;e++)U.add(n[e])}var K=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]*$"),de={},Te={};function Xe(e){return zr.call(Te,e)?!0:zr.call(de,e)?!1:K.test(e)?Te[e]=!0:(de[e]=!0,!1)}function Dt(e,n,r){if(Xe(n))if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+r)}}function An(e,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+r)}}function Qn(e,n,r,l){if(l===null)e.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttributeNS(n,r,""+l)}}function un(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Th(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Iy(e,n,r){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var c=l.get,f=l.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return c.call(this)},set:function(p){r=""+p,f.call(this,p)}}),Object.defineProperty(e,n,{enumerable:l.enumerable}),{getValue:function(){return r},setValue:function(p){r=""+p},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function nc(e){if(!e._valueTracker){var n=Th(e)?"checked":"value";e._valueTracker=Iy(e,n,""+e[n])}}function kh(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),l="";return e&&(l=Th(e)?e.checked?"true":"false":e.value),e=l,e!==r?(n.setValue(e),!0):!1}function cl(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 Fy=/[\n"\\]/g;function fn(e){return e.replace(Fy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function sc(e,n,r,l,c,f,p,b){e.name="",p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"?e.type=p:e.removeAttribute("type"),n!=null?p==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+un(n)):e.value!==""+un(n)&&(e.value=""+un(n)):p!=="submit"&&p!=="reset"||e.removeAttribute("value"),n!=null?ic(e,p,un(n)):r!=null?ic(e,p,un(r)):l!=null&&e.removeAttribute("value"),c==null&&f!=null&&(e.defaultChecked=!!f),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.name=""+un(b):e.removeAttribute("name")}function Ch(e,n,r,l,c,f,p,b){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(e.type=f),n!=null||r!=null){if(!(f!=="submit"&&f!=="reset"||n!=null)){nc(e);return}r=r!=null?""+un(r):"",n=n!=null?""+un(n):r,b||n===e.value||(e.value=n),e.defaultValue=n}l=l??c,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=b?e.checked:!!l,e.defaultChecked=!!l,p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.name=p),nc(e)}function ic(e,n,r){n==="number"&&cl(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Pi(e,n,r,l){if(e=e.options,n){n={};for(var c=0;c<r.length;c++)n["$"+r[c]]=!0;for(r=0;r<e.length;r++)c=n.hasOwnProperty("$"+e[r].value),e[r].selected!==c&&(e[r].selected=c),c&&l&&(e[r].defaultSelected=!0)}else{for(r=""+un(r),n=null,c=0;c<e.length;c++){if(e[c].value===r){e[c].selected=!0,l&&(e[c].defaultSelected=!0);return}n!==null||e[c].disabled||(n=e[c])}n!==null&&(n.selected=!0)}}function Mh(e,n,r){if(n!=null&&(n=""+un(n),n!==e.value&&(e.value=n),r==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=r!=null?""+un(r):""}function Rh(e,n,r,l){if(n==null){if(l!=null){if(r!=null)throw Error(a(92));if(Se(l)){if(1<l.length)throw Error(a(93));l=l[0]}r=l}r==null&&(r=""),n=r}r=un(n),e.defaultValue=r,l=e.textContent,l===r&&l!==""&&l!==null&&(e.value=l),nc(e)}function Hi(e,n){if(n){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=n;return}}e.textContent=n}var Jy=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 Dh(e,n,r){var l=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?l?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":l?e.setProperty(n,r):typeof r!="number"||r===0||Jy.has(n)?n==="float"?e.cssFloat=r:e[n]=(""+r).trim():e[n]=r+"px"}function qh(e,n,r){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,r!=null){for(var l in r)!r.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var c in n)l=n[c],n.hasOwnProperty(c)&&r[c]!==l&&Dh(e,c,l)}else for(var f in n)n.hasOwnProperty(f)&&Dh(e,f,n[f])}function rc(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 Qy=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"]]),Ky=/^[\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 ul(e){return Ky.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Kn(){}var ac=null;function lc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $i=null,Yi=null;function zh(e){var n=S(e);if(n&&(e=n.stateNode)){var r=e[it]||null;e:switch(e=n.stateNode,n.type){case"input":if(sc(e,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+fn(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var l=r[n];if(l!==e&&l.form===e.form){var c=l[it]||null;if(!c)throw Error(a(90));sc(l,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(n=0;n<r.length;n++)l=r[n],l.form===e.form&&kh(l)}break e;case"textarea":Mh(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Pi(e,!!r.multiple,n,!1)}}}var oc=!1;function Uh(e,n,r){if(oc)return e(n,r);oc=!0;try{var l=e(n);return l}finally{if(oc=!1,($i!==null||Yi!==null)&&(Xl(),$i&&(n=$i,e=Yi,Yi=$i=null,zh(n),e)))for(n=0;n<e.length;n++)zh(e[n])}}function Yr(e,n){var r=e.stateNode;if(r===null)return null;var l=r[it]||null;if(l===null)return null;r=l[n];e:switch(n){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(r&&typeof r!="function")throw Error(a(231,n,typeof r));return r}var Xn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cc=!1;if(Xn)try{var Gr={};Object.defineProperty(Gr,"passive",{get:function(){cc=!0}}),window.addEventListener("test",Gr,Gr),window.removeEventListener("test",Gr,Gr)}catch{cc=!1}var Es=null,uc=null,fl=null;function Bh(){if(fl)return fl;var e,n=uc,r=n.length,l,c="value"in Es?Es.value:Es.textContent,f=c.length;for(e=0;e<r&&n[e]===c[e];e++);var p=r-e;for(l=1;l<=p&&n[r-l]===c[f-l];l++);return fl=c.slice(e,1<l?1-l:void 0)}function hl(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function dl(){return!0}function Lh(){return!1}function Lt(e){function n(r,l,c,f,p){this._reactName=r,this._targetInst=c,this.type=l,this.nativeEvent=f,this.target=p,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(r=e[b],this[b]=r?r(f):f[b]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?dl:Lh,this.isPropagationStopped=Lh,this}return _(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=dl)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=dl)},persist:function(){},isPersistent:dl}),n}var ui={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ml=Lt(ui),Vr=_({},ui,{view:0,detail:0}),Xy=Lt(Vr),fc,hc,Ir,pl=_({},Vr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mc,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!==Ir&&(Ir&&e.type==="mousemove"?(fc=e.screenX-Ir.screenX,hc=e.screenY-Ir.screenY):hc=fc=0,Ir=e),fc)},movementY:function(e){return"movementY"in e?e.movementY:hc}}),Ph=Lt(pl),Zy=_({},pl,{dataTransfer:0}),Wy=Lt(Zy),eb=_({},Vr,{relatedTarget:0}),dc=Lt(eb),tb=_({},ui,{animationName:0,elapsedTime:0,pseudoElement:0}),nb=Lt(tb),sb=_({},ui,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ib=Lt(sb),rb=_({},ui,{data:0}),Hh=Lt(rb),ab={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lb={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"},ob={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=ob[e])?!!n[e]:!1}function mc(){return cb}var ub=_({},Vr,{key:function(e){if(e.key){var n=ab[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=hl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?lb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mc,charCode:function(e){return e.type==="keypress"?hl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?hl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),fb=Lt(ub),hb=_({},pl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$h=Lt(hb),db=_({},Vr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mc}),mb=Lt(db),pb=_({},ui,{propertyName:0,elapsedTime:0,pseudoElement:0}),gb=Lt(pb),yb=_({},pl,{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}),bb=Lt(yb),xb=_({},ui,{newState:0,oldState:0}),vb=Lt(xb),_b=[9,13,27,32],pc=Xn&&"CompositionEvent"in window,Fr=null;Xn&&"documentMode"in document&&(Fr=document.documentMode);var wb=Xn&&"TextEvent"in window&&!Fr,Yh=Xn&&(!pc||Fr&&8<Fr&&11>=Fr),Gh=" ",Vh=!1;function Ih(e,n){switch(e){case"keyup":return _b.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gi=!1;function Sb(e,n){switch(e){case"compositionend":return Fh(n);case"keypress":return n.which!==32?null:(Vh=!0,Gh);case"textInput":return e=n.data,e===Gh&&Vh?null:e;default:return null}}function Eb(e,n){if(Gi)return e==="compositionend"||!pc&&Ih(e,n)?(e=Bh(),fl=uc=Es=null,Gi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Yh&&n.locale!=="ko"?null:n.data;default:return null}}var jb={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 Jh(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!jb[e.type]:n==="textarea"}function Qh(e,n,r,l){$i?Yi?Yi.push(l):Yi=[l]:$i=l,n=io(n,"onChange"),0<n.length&&(r=new ml("onChange","change",null,r,l),e.push({event:r,listeners:n}))}var Jr=null,Qr=null;function Ab(e){Cp(e,0)}function gl(e){var n=w(e);if(kh(n))return e}function Kh(e,n){if(e==="change")return n}var Xh=!1;if(Xn){var gc;if(Xn){var yc="oninput"in document;if(!yc){var Zh=document.createElement("div");Zh.setAttribute("oninput","return;"),yc=typeof Zh.oninput=="function"}gc=yc}else gc=!1;Xh=gc&&(!document.documentMode||9<document.documentMode)}function Wh(){Jr&&(Jr.detachEvent("onpropertychange",ed),Qr=Jr=null)}function ed(e){if(e.propertyName==="value"&&gl(Qr)){var n=[];Qh(n,Qr,e,lc(e)),Uh(Ab,n)}}function Ob(e,n,r){e==="focusin"?(Wh(),Jr=n,Qr=r,Jr.attachEvent("onpropertychange",ed)):e==="focusout"&&Wh()}function Nb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return gl(Qr)}function Tb(e,n){if(e==="click")return gl(n)}function kb(e,n){if(e==="input"||e==="change")return gl(n)}function Cb(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Jt=typeof Object.is=="function"?Object.is:Cb;function Kr(e,n){if(Jt(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var r=Object.keys(e),l=Object.keys(n);if(r.length!==l.length)return!1;for(l=0;l<r.length;l++){var c=r[l];if(!zr.call(n,c)||!Jt(e[c],n[c]))return!1}return!0}function td(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nd(e,n){var r=td(e);e=0;for(var l;r;){if(r.nodeType===3){if(l=e+r.textContent.length,e<=n&&l>=n)return{node:r,offset:n-e};e=l}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=td(r)}}function sd(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?sd(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function id(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=cl(e.document);n instanceof e.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)e=n.contentWindow;else break;n=cl(e.document)}return n}function bc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var Mb=Xn&&"documentMode"in document&&11>=document.documentMode,Vi=null,xc=null,Xr=null,vc=!1;function rd(e,n,r){var l=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;vc||Vi==null||Vi!==cl(l)||(l=Vi,"selectionStart"in l&&bc(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}),Xr&&Kr(Xr,l)||(Xr=l,l=io(xc,"onSelect"),0<l.length&&(n=new ml("onSelect","select",null,n,r),e.push({event:n,listeners:l}),n.target=Vi)))}function fi(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var Ii={animationend:fi("Animation","AnimationEnd"),animationiteration:fi("Animation","AnimationIteration"),animationstart:fi("Animation","AnimationStart"),transitionrun:fi("Transition","TransitionRun"),transitionstart:fi("Transition","TransitionStart"),transitioncancel:fi("Transition","TransitionCancel"),transitionend:fi("Transition","TransitionEnd")},_c={},ad={};Xn&&(ad=document.createElement("div").style,"AnimationEvent"in window||(delete Ii.animationend.animation,delete Ii.animationiteration.animation,delete Ii.animationstart.animation),"TransitionEvent"in window||delete Ii.transitionend.transition);function hi(e){if(_c[e])return _c[e];if(!Ii[e])return e;var n=Ii[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in ad)return _c[e]=n[r];return e}var ld=hi("animationend"),od=hi("animationiteration"),cd=hi("animationstart"),Rb=hi("transitionrun"),Db=hi("transitionstart"),qb=hi("transitioncancel"),ud=hi("transitionend"),fd=new Map,wc="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(" ");wc.push("scrollEnd");function On(e,n){fd.set(e,n),ee(n,[e])}var yl=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=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(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},hn=[],Fi=0,Sc=0;function bl(){for(var e=Fi,n=Sc=Fi=0;n<e;){var r=hn[n];hn[n++]=null;var l=hn[n];hn[n++]=null;var c=hn[n];hn[n++]=null;var f=hn[n];if(hn[n++]=null,l!==null&&c!==null){var p=l.pending;p===null?c.next=c:(c.next=p.next,p.next=c),l.pending=c}f!==0&&hd(r,c,f)}}function xl(e,n,r,l){hn[Fi++]=e,hn[Fi++]=n,hn[Fi++]=r,hn[Fi++]=l,Sc|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function Ec(e,n,r,l){return xl(e,n,r,l),vl(e)}function di(e,n){return xl(e,null,null,n),vl(e)}function hd(e,n,r){e.lanes|=r;var l=e.alternate;l!==null&&(l.lanes|=r);for(var c=!1,f=e.return;f!==null;)f.childLanes|=r,l=f.alternate,l!==null&&(l.childLanes|=r),f.tag===22&&(e=f.stateNode,e===null||e._visibility&1||(c=!0)),e=f,f=f.return;return e.tag===3?(f=e.stateNode,c&&n!==null&&(c=31-Rt(r),e=f.hiddenUpdates,l=e[c],l===null?e[c]=[n]:l.push(n),n.lane=r|536870912),f):null}function vl(e){if(50<xa)throw xa=0,Ru=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Ji={};function zb(e,n,r,l){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,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 Qt(e,n,r,l){return new zb(e,n,r,l)}function jc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zn(e,n){var r=e.alternate;return r===null?(r=Qt(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function dd(e,n){e.flags&=65011714;var r=e.alternate;return r===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=r.childLanes,e.lanes=r.lanes,e.child=r.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=r.memoizedProps,e.memoizedState=r.memoizedState,e.updateQueue=r.updateQueue,e.type=r.type,n=r.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function _l(e,n,r,l,c,f){var p=0;if(l=e,typeof e=="function")jc(e)&&(p=1);else if(typeof e=="string")p=Hx(e,r,lt.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case F:return e=Qt(31,r,n,c),e.elementType=F,e.lanes=f,e;case D:return mi(r.children,c,f,n);case G:p=8,c|=24;break;case te:return e=Qt(12,r,n,c|2),e.elementType=te,e.lanes=f,e;case O:return e=Qt(13,r,n,c),e.elementType=O,e.lanes=f,e;case J:return e=Qt(19,r,n,c),e.elementType=J,e.lanes=f,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ce:p=10;break e;case $:p=9;break e;case oe:p=11;break e;case ae:p=14;break e;case I:p=16,l=null;break e}p=29,r=Error(a(130,e===null?"null":typeof e,"")),l=null}return n=Qt(p,r,n,c),n.elementType=e,n.type=l,n.lanes=f,n}function mi(e,n,r,l){return e=Qt(7,e,l,n),e.lanes=r,e}function Ac(e,n,r){return e=Qt(6,e,null,n),e.lanes=r,e}function md(e){var n=Qt(18,null,null,0);return n.stateNode=e,n}function Oc(e,n,r){return n=Qt(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var pd=new WeakMap;function dn(e,n){if(typeof e=="object"&&e!==null){var r=pd.get(e);return r!==void 0?r:(n={value:e,source:n,stack:el(n)},pd.set(e,n),n)}return{value:e,source:n,stack:el(n)}}var Qi=[],Ki=0,wl=null,Zr=0,mn=[],pn=0,js=null,zn=1,Un="";function Wn(e,n){Qi[Ki++]=Zr,Qi[Ki++]=wl,wl=e,Zr=n}function gd(e,n,r){mn[pn++]=zn,mn[pn++]=Un,mn[pn++]=js,js=e;var l=zn;e=Un;var c=32-Rt(l)-1;l&=~(1<<c),r+=1;var f=32-Rt(n)+c;if(30<f){var p=c-c%5;f=(l&(1<<p)-1).toString(32),l>>=p,c-=p,zn=1<<32-Rt(n)+c|r<<c|l,Un=f+e}else zn=1<<f|r<<c|l,Un=e}function Nc(e){e.return!==null&&(Wn(e,1),gd(e,1,0))}function Tc(e){for(;e===wl;)wl=Qi[--Ki],Qi[Ki]=null,Zr=Qi[--Ki],Qi[Ki]=null;for(;e===js;)js=mn[--pn],mn[pn]=null,Un=mn[--pn],mn[pn]=null,zn=mn[--pn],mn[pn]=null}function yd(e,n){mn[pn++]=zn,mn[pn++]=Un,mn[pn++]=js,zn=n.id,Un=n.overflow,js=e}var jt=null,Ze=null,Ue=!1,As=null,gn=!1,kc=Error(a(519));function Os(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Wr(dn(n,e)),kc}function bd(e){var n=e.stateNode,r=e.type,l=e.memoizedProps;switch(n[Qe]=e,n[it]=l,r){case"dialog":De("cancel",n),De("close",n);break;case"iframe":case"object":case"embed":De("load",n);break;case"video":case"audio":for(r=0;r<_a.length;r++)De(_a[r],n);break;case"source":De("error",n);break;case"img":case"image":case"link":De("error",n),De("load",n);break;case"details":De("toggle",n);break;case"input":De("invalid",n),Ch(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":De("invalid",n);break;case"textarea":De("invalid",n),Rh(n,l.value,l.defaultValue,l.children)}r=l.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||l.suppressHydrationWarning===!0||qp(n.textContent,r)?(l.popover!=null&&(De("beforetoggle",n),De("toggle",n)),l.onScroll!=null&&De("scroll",n),l.onScrollEnd!=null&&De("scrollend",n),l.onClick!=null&&(n.onclick=Kn),n=!0):n=!1,n||Os(e,!0)}function xd(e){for(jt=e.return;jt;)switch(jt.tag){case 5:case 31:case 13:gn=!1;return;case 27:case 3:gn=!0;return;default:jt=jt.return}}function Xi(e){if(e!==jt)return!1;if(!Ue)return xd(e),Ue=!0,!1;var n=e.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=e.type,r=!(r!=="form"&&r!=="button")||Ju(e.type,e.memoizedProps)),r=!r),r&&Ze&&Os(e),xd(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Ze=Gp(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Ze=Gp(e)}else n===27?(n=Ze,Hs(e.type)?(e=Wu,Wu=null,Ze=e):Ze=n):Ze=jt?bn(e.stateNode.nextSibling):null;return!0}function pi(){Ze=jt=null,Ue=!1}function Cc(){var e=As;return e!==null&&(Yt===null?Yt=e:Yt.push.apply(Yt,e),As=null),e}function Wr(e){As===null?As=[e]:As.push(e)}var Mc=Ce(null),gi=null,es=null;function Ns(e,n,r){Me(Mc,n._currentValue),n._currentValue=r}function ts(e){e._currentValue=Mc.current,Ee(Mc)}function Rc(e,n,r){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===r)break;e=e.return}}function Dc(e,n,r,l){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var f=c.dependencies;if(f!==null){var p=c.child;f=f.firstContext;e:for(;f!==null;){var b=f;f=c;for(var T=0;T<n.length;T++)if(b.context===n[T]){f.lanes|=r,b=f.alternate,b!==null&&(b.lanes|=r),Rc(f.return,r,e),l||(p=null);break e}f=b.next}}else if(c.tag===18){if(p=c.return,p===null)throw Error(a(341));p.lanes|=r,f=p.alternate,f!==null&&(f.lanes|=r),Rc(p,r,e),p=null}else p=c.child;if(p!==null)p.return=c;else for(p=c;p!==null;){if(p===e){p=null;break}if(c=p.sibling,c!==null){c.return=p.return,p=c;break}p=p.return}c=p}}function Zi(e,n,r,l){e=null;for(var c=n,f=!1;c!==null;){if(!f){if((c.flags&524288)!==0)f=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var p=c.alternate;if(p===null)throw Error(a(387));if(p=p.memoizedProps,p!==null){var b=c.type;Jt(c.pendingProps.value,p.value)||(e!==null?e.push(b):e=[b])}}else if(c===kt.current){if(p=c.alternate,p===null)throw Error(a(387));p.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Aa):e=[Aa])}c=c.return}e!==null&&Dc(n,e,r,l),n.flags|=262144}function Sl(e){for(e=e.firstContext;e!==null;){if(!Jt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function yi(e){gi=e,es=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function At(e){return vd(gi,e)}function El(e,n){return gi===null&&yi(e),vd(e,n)}function vd(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},es===null){if(e===null)throw Error(a(308));es=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else es=es.next=n;return r}var Ub=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(r,l){e.push(l)}};this.abort=function(){n.aborted=!0,e.forEach(function(r){return r()})}},Bb=i.unstable_scheduleCallback,Lb=i.unstable_NormalPriority,dt={$$typeof:ce,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qc(){return{controller:new Ub,data:new Map,refCount:0}}function ea(e){e.refCount--,e.refCount===0&&Bb(Lb,function(){e.controller.abort()})}var ta=null,zc=0,Wi=0,er=null;function Pb(e,n){if(ta===null){var r=ta=[];zc=0,Wi=Lu(),er={status:"pending",value:void 0,then:function(l){r.push(l)}}}return zc++,n.then(_d,_d),n}function _d(){if(--zc===0&&ta!==null){er!==null&&(er.status="fulfilled");var e=ta;ta=null,Wi=0,er=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Hb(e,n){var r=[],l={status:"pending",value:null,reason:null,then:function(c){r.push(c)}};return e.then(function(){l.status="fulfilled",l.value=n;for(var c=0;c<r.length;c++)(0,r[c])(n)},function(c){for(l.status="rejected",l.reason=c,c=0;c<r.length;c++)(0,r[c])(void 0)}),l}var wd=z.S;z.S=function(e,n){rp=et(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Pb(e,n),wd!==null&&wd(e,n)};var bi=Ce(null);function Uc(){var e=bi.current;return e!==null?e:Ke.pooledCache}function jl(e,n){n===null?Me(bi,bi.current):Me(bi,n.pool)}function Sd(){var e=Uc();return e===null?null:{parent:dt._currentValue,pool:e}}var tr=Error(a(460)),Bc=Error(a(474)),Al=Error(a(542)),Ol={then:function(){}};function Ed(e){return e=e.status,e==="fulfilled"||e==="rejected"}function jd(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(Kn,Kn),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Od(e),e;default:if(typeof n.status=="string")n.then(Kn,Kn);else{if(e=Ke,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(l){if(n.status==="pending"){var c=n;c.status="fulfilled",c.value=l}},function(l){if(n.status==="pending"){var c=n;c.status="rejected",c.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Od(e),e}throw vi=n,tr}}function xi(e){try{var n=e._init;return n(e._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(vi=r,tr):r}}var vi=null;function Ad(){if(vi===null)throw Error(a(459));var e=vi;return vi=null,e}function Od(e){if(e===tr||e===Al)throw Error(a(483))}var nr=null,na=0;function Nl(e){var n=na;return na+=1,nr===null&&(nr=[]),jd(nr,e,n)}function sa(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Tl(e,n){throw n.$$typeof===N?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Nd(e){function n(q,C){if(e){var B=q.deletions;B===null?(q.deletions=[C],q.flags|=16):B.push(C)}}function r(q,C){if(!e)return null;for(;C!==null;)n(q,C),C=C.sibling;return null}function l(q){for(var C=new Map;q!==null;)q.key!==null?C.set(q.key,q):C.set(q.index,q),q=q.sibling;return C}function c(q,C){return q=Zn(q,C),q.index=0,q.sibling=null,q}function f(q,C,B){return q.index=B,e?(B=q.alternate,B!==null?(B=B.index,B<C?(q.flags|=67108866,C):B):(q.flags|=67108866,C)):(q.flags|=1048576,C)}function p(q){return e&&q.alternate===null&&(q.flags|=67108866),q}function b(q,C,B,Q){return C===null||C.tag!==6?(C=Ac(B,q.mode,Q),C.return=q,C):(C=c(C,B),C.return=q,C)}function T(q,C,B,Q){var ye=B.type;return ye===D?V(q,C,B.props.children,Q,B.key):C!==null&&(C.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===I&&xi(ye)===C.type)?(C=c(C,B.props),sa(C,B),C.return=q,C):(C=_l(B.type,B.key,B.props,null,q.mode,Q),sa(C,B),C.return=q,C)}function L(q,C,B,Q){return C===null||C.tag!==4||C.stateNode.containerInfo!==B.containerInfo||C.stateNode.implementation!==B.implementation?(C=Oc(B,q.mode,Q),C.return=q,C):(C=c(C,B.children||[]),C.return=q,C)}function V(q,C,B,Q,ye){return C===null||C.tag!==7?(C=mi(B,q.mode,Q,ye),C.return=q,C):(C=c(C,B),C.return=q,C)}function W(q,C,B){if(typeof C=="string"&&C!==""||typeof C=="number"||typeof C=="bigint")return C=Ac(""+C,q.mode,B),C.return=q,C;if(typeof C=="object"&&C!==null){switch(C.$$typeof){case R:return B=_l(C.type,C.key,C.props,null,q.mode,B),sa(B,C),B.return=q,B;case M:return C=Oc(C,q.mode,B),C.return=q,C;case I:return C=xi(C),W(q,C,B)}if(Se(C)||ie(C))return C=mi(C,q.mode,B,null),C.return=q,C;if(typeof C.then=="function")return W(q,Nl(C),B);if(C.$$typeof===ce)return W(q,El(q,C),B);Tl(q,C)}return null}function P(q,C,B,Q){var ye=C!==null?C.key:null;if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return ye!==null?null:b(q,C,""+B,Q);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case R:return B.key===ye?T(q,C,B,Q):null;case M:return B.key===ye?L(q,C,B,Q):null;case I:return B=xi(B),P(q,C,B,Q)}if(Se(B)||ie(B))return ye!==null?null:V(q,C,B,Q,null);if(typeof B.then=="function")return P(q,C,Nl(B),Q);if(B.$$typeof===ce)return P(q,C,El(q,B),Q);Tl(q,B)}return null}function Y(q,C,B,Q,ye){if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return q=q.get(B)||null,b(C,q,""+Q,ye);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case R:return q=q.get(Q.key===null?B:Q.key)||null,T(C,q,Q,ye);case M:return q=q.get(Q.key===null?B:Q.key)||null,L(C,q,Q,ye);case I:return Q=xi(Q),Y(q,C,B,Q,ye)}if(Se(Q)||ie(Q))return q=q.get(B)||null,V(C,q,Q,ye,null);if(typeof Q.then=="function")return Y(q,C,B,Nl(Q),ye);if(Q.$$typeof===ce)return Y(q,C,B,El(C,Q),ye);Tl(C,Q)}return null}function me(q,C,B,Q){for(var ye=null,Pe=null,pe=C,Ne=C=0,ze=null;pe!==null&&Ne<B.length;Ne++){pe.index>Ne?(ze=pe,pe=null):ze=pe.sibling;var He=P(q,pe,B[Ne],Q);if(He===null){pe===null&&(pe=ze);break}e&&pe&&He.alternate===null&&n(q,pe),C=f(He,C,Ne),Pe===null?ye=He:Pe.sibling=He,Pe=He,pe=ze}if(Ne===B.length)return r(q,pe),Ue&&Wn(q,Ne),ye;if(pe===null){for(;Ne<B.length;Ne++)pe=W(q,B[Ne],Q),pe!==null&&(C=f(pe,C,Ne),Pe===null?ye=pe:Pe.sibling=pe,Pe=pe);return Ue&&Wn(q,Ne),ye}for(pe=l(pe);Ne<B.length;Ne++)ze=Y(pe,q,Ne,B[Ne],Q),ze!==null&&(e&&ze.alternate!==null&&pe.delete(ze.key===null?Ne:ze.key),C=f(ze,C,Ne),Pe===null?ye=ze:Pe.sibling=ze,Pe=ze);return e&&pe.forEach(function(Is){return n(q,Is)}),Ue&&Wn(q,Ne),ye}function xe(q,C,B,Q){if(B==null)throw Error(a(151));for(var ye=null,Pe=null,pe=C,Ne=C=0,ze=null,He=B.next();pe!==null&&!He.done;Ne++,He=B.next()){pe.index>Ne?(ze=pe,pe=null):ze=pe.sibling;var Is=P(q,pe,He.value,Q);if(Is===null){pe===null&&(pe=ze);break}e&&pe&&Is.alternate===null&&n(q,pe),C=f(Is,C,Ne),Pe===null?ye=Is:Pe.sibling=Is,Pe=Is,pe=ze}if(He.done)return r(q,pe),Ue&&Wn(q,Ne),ye;if(pe===null){for(;!He.done;Ne++,He=B.next())He=W(q,He.value,Q),He!==null&&(C=f(He,C,Ne),Pe===null?ye=He:Pe.sibling=He,Pe=He);return Ue&&Wn(q,Ne),ye}for(pe=l(pe);!He.done;Ne++,He=B.next())He=Y(pe,q,Ne,He.value,Q),He!==null&&(e&&He.alternate!==null&&pe.delete(He.key===null?Ne:He.key),C=f(He,C,Ne),Pe===null?ye=He:Pe.sibling=He,Pe=He);return e&&pe.forEach(function(Zx){return n(q,Zx)}),Ue&&Wn(q,Ne),ye}function Je(q,C,B,Q){if(typeof B=="object"&&B!==null&&B.type===D&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case R:e:{for(var ye=B.key;C!==null;){if(C.key===ye){if(ye=B.type,ye===D){if(C.tag===7){r(q,C.sibling),Q=c(C,B.props.children),Q.return=q,q=Q;break e}}else if(C.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===I&&xi(ye)===C.type){r(q,C.sibling),Q=c(C,B.props),sa(Q,B),Q.return=q,q=Q;break e}r(q,C);break}else n(q,C);C=C.sibling}B.type===D?(Q=mi(B.props.children,q.mode,Q,B.key),Q.return=q,q=Q):(Q=_l(B.type,B.key,B.props,null,q.mode,Q),sa(Q,B),Q.return=q,q=Q)}return p(q);case M:e:{for(ye=B.key;C!==null;){if(C.key===ye)if(C.tag===4&&C.stateNode.containerInfo===B.containerInfo&&C.stateNode.implementation===B.implementation){r(q,C.sibling),Q=c(C,B.children||[]),Q.return=q,q=Q;break e}else{r(q,C);break}else n(q,C);C=C.sibling}Q=Oc(B,q.mode,Q),Q.return=q,q=Q}return p(q);case I:return B=xi(B),Je(q,C,B,Q)}if(Se(B))return me(q,C,B,Q);if(ie(B)){if(ye=ie(B),typeof ye!="function")throw Error(a(150));return B=ye.call(B),xe(q,C,B,Q)}if(typeof B.then=="function")return Je(q,C,Nl(B),Q);if(B.$$typeof===ce)return Je(q,C,El(q,B),Q);Tl(q,B)}return typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint"?(B=""+B,C!==null&&C.tag===6?(r(q,C.sibling),Q=c(C,B),Q.return=q,q=Q):(r(q,C),Q=Ac(B,q.mode,Q),Q.return=q,q=Q),p(q)):r(q,C)}return function(q,C,B,Q){try{na=0;var ye=Je(q,C,B,Q);return nr=null,ye}catch(pe){if(pe===tr||pe===Al)throw pe;var Pe=Qt(29,pe,null,q.mode);return Pe.lanes=Q,Pe.return=q,Pe}finally{}}}var _i=Nd(!0),Td=Nd(!1),Ts=!1;function Lc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ks(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Cs(e,n,r){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var c=l.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),l.pending=n,n=vl(e),hd(e,null,r),n}return xl(e,l,n,r),vl(e)}function ia(e,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var l=n.lanes;l&=e.pendingLanes,r|=l,n.lanes=r,li(e,r)}}function Hc(e,n){var r=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,r===l)){var c=null,f=null;if(r=r.firstBaseUpdate,r!==null){do{var p={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};f===null?c=f=p:f=f.next=p,r=r.next}while(r!==null);f===null?c=f=n:f=f.next=n}else c=f=n;r={baseState:l.baseState,firstBaseUpdate:c,lastBaseUpdate:f,shared:l.shared,callbacks:l.callbacks},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=n:e.next=n,r.lastBaseUpdate=n}var $c=!1;function ra(){if($c){var e=er;if(e!==null)throw e}}function aa(e,n,r,l){$c=!1;var c=e.updateQueue;Ts=!1;var f=c.firstBaseUpdate,p=c.lastBaseUpdate,b=c.shared.pending;if(b!==null){c.shared.pending=null;var T=b,L=T.next;T.next=null,p===null?f=L:p.next=L,p=T;var V=e.alternate;V!==null&&(V=V.updateQueue,b=V.lastBaseUpdate,b!==p&&(b===null?V.firstBaseUpdate=L:b.next=L,V.lastBaseUpdate=T))}if(f!==null){var W=c.baseState;p=0,V=L=T=null,b=f;do{var P=b.lane&-536870913,Y=P!==b.lane;if(Y?(qe&P)===P:(l&P)===P){P!==0&&P===Wi&&($c=!0),V!==null&&(V=V.next={lane:0,tag:b.tag,payload:b.payload,callback:null,next:null});e:{var me=e,xe=b;P=n;var Je=r;switch(xe.tag){case 1:if(me=xe.payload,typeof me=="function"){W=me.call(Je,W,P);break e}W=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=xe.payload,P=typeof me=="function"?me.call(Je,W,P):me,P==null)break e;W=_({},W,P);break e;case 2:Ts=!0}}P=b.callback,P!==null&&(e.flags|=64,Y&&(e.flags|=8192),Y=c.callbacks,Y===null?c.callbacks=[P]:Y.push(P))}else Y={lane:P,tag:b.tag,payload:b.payload,callback:b.callback,next:null},V===null?(L=V=Y,T=W):V=V.next=Y,p|=P;if(b=b.next,b===null){if(b=c.shared.pending,b===null)break;Y=b,b=Y.next,Y.next=null,c.lastBaseUpdate=Y,c.shared.pending=null}}while(!0);V===null&&(T=W),c.baseState=T,c.firstBaseUpdate=L,c.lastBaseUpdate=V,f===null&&(c.shared.lanes=0),zs|=p,e.lanes=p,e.memoizedState=W}}function kd(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Cd(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)kd(r[e],n)}var sr=Ce(null),kl=Ce(0);function Md(e,n){e=us,Me(kl,e),Me(sr,n),us=e|n.baseLanes}function Yc(){Me(kl,us),Me(sr,sr.current)}function Gc(){us=kl.current,Ee(sr),Ee(kl)}var Kt=Ce(null),yn=null;function Ms(e){var n=e.alternate;Me(ct,ct.current&1),Me(Kt,e),yn===null&&(n===null||sr.current!==null||n.memoizedState!==null)&&(yn=e)}function Vc(e){Me(ct,ct.current),Me(Kt,e),yn===null&&(yn=e)}function Rd(e){e.tag===22?(Me(ct,ct.current),Me(Kt,e),yn===null&&(yn=e)):Rs()}function Rs(){Me(ct,ct.current),Me(Kt,Kt.current)}function Xt(e){Ee(Kt),yn===e&&(yn=null),Ee(ct)}var ct=Ce(0);function Cl(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||Xu(r)||Zu(r)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var ns=0,Ae=null,Ie=null,mt=null,Ml=!1,ir=!1,wi=!1,Rl=0,la=0,rr=null,$b=0;function rt(){throw Error(a(321))}function Ic(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!Jt(e[r],n[r]))return!1;return!0}function Fc(e,n,r,l,c,f){return ns=f,Ae=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,z.H=e===null||e.memoizedState===null?gm:ou,wi=!1,f=r(l,c),wi=!1,ir&&(f=qd(n,r,l,c)),Dd(e),f}function Dd(e){z.H=ua;var n=Ie!==null&&Ie.next!==null;if(ns=0,mt=Ie=Ae=null,Ml=!1,la=0,rr=null,n)throw Error(a(300));e===null||pt||(e=e.dependencies,e!==null&&Sl(e)&&(pt=!0))}function qd(e,n,r,l){Ae=e;var c=0;do{if(ir&&(rr=null),la=0,ir=!1,25<=c)throw Error(a(301));if(c+=1,mt=Ie=null,e.updateQueue!=null){var f=e.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}z.H=ym,f=n(r,l)}while(ir);return f}function Yb(){var e=z.H,n=e.useState()[0];return n=typeof n.then=="function"?oa(n):n,e=e.useState()[0],(Ie!==null?Ie.memoizedState:null)!==e&&(Ae.flags|=1024),n}function Jc(){var e=Rl!==0;return Rl=0,e}function Qc(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function Kc(e){if(Ml){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ml=!1}ns=0,mt=Ie=Ae=null,ir=!1,la=Rl=0,rr=null}function qt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mt===null?Ae.memoizedState=mt=e:mt=mt.next=e,mt}function ut(){if(Ie===null){var e=Ae.alternate;e=e!==null?e.memoizedState:null}else e=Ie.next;var n=mt===null?Ae.memoizedState:mt.next;if(n!==null)mt=n,Ie=e;else{if(e===null)throw Ae.alternate===null?Error(a(467)):Error(a(310));Ie=e,e={memoizedState:Ie.memoizedState,baseState:Ie.baseState,baseQueue:Ie.baseQueue,queue:Ie.queue,next:null},mt===null?Ae.memoizedState=mt=e:mt=mt.next=e}return mt}function Dl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function oa(e){var n=la;return la+=1,rr===null&&(rr=[]),e=jd(rr,e,n),n=Ae,(mt===null?n.memoizedState:mt.next)===null&&(n=n.alternate,z.H=n===null||n.memoizedState===null?gm:ou),e}function ql(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return oa(e);if(e.$$typeof===ce)return At(e)}throw Error(a(438,String(e)))}function Xc(e){var n=null,r=Ae.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var l=Ae.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(c){return c.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=Dl(),Ae.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(e),l=0;l<e;l++)r[l]=Z;return n.index++,r}function ss(e,n){return typeof n=="function"?n(e):n}function zl(e){var n=ut();return Zc(n,Ie,e)}function Zc(e,n,r){var l=e.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=r;var c=e.baseQueue,f=l.pending;if(f!==null){if(c!==null){var p=c.next;c.next=f.next,f.next=p}n.baseQueue=c=f,l.pending=null}if(f=e.baseState,c===null)e.memoizedState=f;else{n=c.next;var b=p=null,T=null,L=n,V=!1;do{var W=L.lane&-536870913;if(W!==L.lane?(qe&W)===W:(ns&W)===W){var P=L.revertLane;if(P===0)T!==null&&(T=T.next={lane:0,revertLane:0,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),W===Wi&&(V=!0);else if((ns&P)===P){L=L.next,P===Wi&&(V=!0);continue}else W={lane:0,revertLane:L.revertLane,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},T===null?(b=T=W,p=f):T=T.next=W,Ae.lanes|=P,zs|=P;W=L.action,wi&&r(f,W),f=L.hasEagerState?L.eagerState:r(f,W)}else P={lane:W,revertLane:L.revertLane,gesture:L.gesture,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},T===null?(b=T=P,p=f):T=T.next=P,Ae.lanes|=W,zs|=W;L=L.next}while(L!==null&&L!==n);if(T===null?p=f:T.next=b,!Jt(f,e.memoizedState)&&(pt=!0,V&&(r=er,r!==null)))throw r;e.memoizedState=f,e.baseState=p,e.baseQueue=T,l.lastRenderedState=f}return c===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function Wc(e){var n=ut(),r=n.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=e;var l=r.dispatch,c=r.pending,f=n.memoizedState;if(c!==null){r.pending=null;var p=c=c.next;do f=e(f,p.action),p=p.next;while(p!==c);Jt(f,n.memoizedState)||(pt=!0),n.memoizedState=f,n.baseQueue===null&&(n.baseState=f),r.lastRenderedState=f}return[f,l]}function zd(e,n,r){var l=Ae,c=ut(),f=Ue;if(f){if(r===void 0)throw Error(a(407));r=r()}else r=n();var p=!Jt((Ie||c).memoizedState,r);if(p&&(c.memoizedState=r,pt=!0),c=c.queue,nu(Ld.bind(null,l,c,e),[e]),c.getSnapshot!==n||p||mt!==null&&mt.memoizedState.tag&1){if(l.flags|=2048,ar(9,{destroy:void 0},Bd.bind(null,l,c,r,n),null),Ke===null)throw Error(a(349));f||(ns&127)!==0||Ud(l,n,r)}return r}function Ud(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=Ae.updateQueue,n===null?(n=Dl(),Ae.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function Bd(e,n,r,l){n.value=r,n.getSnapshot=l,Pd(n)&&Hd(e)}function Ld(e,n,r){return r(function(){Pd(n)&&Hd(e)})}function Pd(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!Jt(e,r)}catch{return!0}}function Hd(e){var n=di(e,2);n!==null&&Gt(n,e,2)}function eu(e){var n=qt();if(typeof e=="function"){var r=e;if(e=r(),wi){It(!0);try{r()}finally{It(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:e},n}function $d(e,n,r,l){return e.baseState=r,Zc(e,Ie,typeof l=="function"?l:ss)}function Gb(e,n,r,l,c){if(Ll(e))throw Error(a(485));if(e=n.action,e!==null){var f={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(p){f.listeners.push(p)}};z.T!==null?r(!0):f.isTransition=!1,l(f),r=n.pending,r===null?(f.next=n.pending=f,Yd(n,f)):(f.next=r.next,n.pending=r.next=f)}}function Yd(e,n){var r=n.action,l=n.payload,c=e.state;if(n.isTransition){var f=z.T,p={};z.T=p;try{var b=r(c,l),T=z.S;T!==null&&T(p,b),Gd(e,n,b)}catch(L){tu(e,n,L)}finally{f!==null&&p.types!==null&&(f.types=p.types),z.T=f}}else try{f=r(c,l),Gd(e,n,f)}catch(L){tu(e,n,L)}}function Gd(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(l){Vd(e,n,l)},function(l){return tu(e,n,l)}):Vd(e,n,r)}function Vd(e,n,r){n.status="fulfilled",n.value=r,Id(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,Yd(e,r)))}function tu(e,n,r){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=r,Id(n),n=n.next;while(n!==l)}e.action=null}function Id(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function Fd(e,n){return n}function Jd(e,n){if(Ue){var r=Ke.formState;if(r!==null){e:{var l=Ae;if(Ue){if(Ze){t:{for(var c=Ze,f=gn;c.nodeType!==8;){if(!f){c=null;break t}if(c=bn(c.nextSibling),c===null){c=null;break t}}f=c.data,c=f==="F!"||f==="F"?c:null}if(c){Ze=bn(c.nextSibling),l=c.data==="F!";break e}}Os(l)}l=!1}l&&(n=r[0])}}return r=qt(),r.memoizedState=r.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fd,lastRenderedState:n},r.queue=l,r=dm.bind(null,Ae,l),l.dispatch=r,l=eu(!1),f=lu.bind(null,Ae,!1,l.queue),l=qt(),c={state:n,dispatch:null,action:e,pending:null},l.queue=c,r=Gb.bind(null,Ae,c,f,r),c.dispatch=r,l.memoizedState=e,[n,r,!1]}function Qd(e){var n=ut();return Kd(n,Ie,e)}function Kd(e,n,r){if(n=Zc(e,n,Fd)[0],e=zl(ss)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=oa(n)}catch(p){throw p===tr?Al:p}else l=n;n=ut();var c=n.queue,f=c.dispatch;return r!==n.memoizedState&&(Ae.flags|=2048,ar(9,{destroy:void 0},Vb.bind(null,c,r),null)),[l,f,e]}function Vb(e,n){e.action=n}function Xd(e){var n=ut(),r=Ie;if(r!==null)return Kd(n,r,e);ut(),n=n.memoizedState,r=ut();var l=r.queue.dispatch;return r.memoizedState=e,[n,l,!1]}function ar(e,n,r,l){return e={tag:e,create:r,deps:l,inst:n,next:null},n=Ae.updateQueue,n===null&&(n=Dl(),Ae.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=e.next=e:(l=r.next,r.next=e,e.next=l,n.lastEffect=e),e}function Zd(){return ut().memoizedState}function Ul(e,n,r,l){var c=qt();Ae.flags|=e,c.memoizedState=ar(1|n,{destroy:void 0},r,l===void 0?null:l)}function Bl(e,n,r,l){var c=ut();l=l===void 0?null:l;var f=c.memoizedState.inst;Ie!==null&&l!==null&&Ic(l,Ie.memoizedState.deps)?c.memoizedState=ar(n,f,r,l):(Ae.flags|=e,c.memoizedState=ar(1|n,f,r,l))}function Wd(e,n){Ul(8390656,8,e,n)}function nu(e,n){Bl(2048,8,e,n)}function Ib(e){Ae.flags|=4;var n=Ae.updateQueue;if(n===null)n=Dl(),Ae.updateQueue=n,n.events=[e];else{var r=n.events;r===null?n.events=[e]:r.push(e)}}function em(e){var n=ut().memoizedState;return Ib({ref:n,nextImpl:e}),function(){if(($e&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function tm(e,n){return Bl(4,2,e,n)}function nm(e,n){return Bl(4,4,e,n)}function sm(e,n){if(typeof n=="function"){e=e();var r=n(e);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function im(e,n,r){r=r!=null?r.concat([e]):null,Bl(4,4,sm.bind(null,n,e),r)}function su(){}function rm(e,n){var r=ut();n=n===void 0?null:n;var l=r.memoizedState;return n!==null&&Ic(n,l[1])?l[0]:(r.memoizedState=[e,n],e)}function am(e,n){var r=ut();n=n===void 0?null:n;var l=r.memoizedState;if(n!==null&&Ic(n,l[1]))return l[0];if(l=e(),wi){It(!0);try{e()}finally{It(!1)}}return r.memoizedState=[l,n],l}function iu(e,n,r){return r===void 0||(ns&1073741824)!==0&&(qe&261930)===0?e.memoizedState=n:(e.memoizedState=r,e=lp(),Ae.lanes|=e,zs|=e,r)}function lm(e,n,r,l){return Jt(r,n)?r:sr.current!==null?(e=iu(e,r,l),Jt(e,n)||(pt=!0),e):(ns&42)===0||(ns&1073741824)!==0&&(qe&261930)===0?(pt=!0,e.memoizedState=r):(e=lp(),Ae.lanes|=e,zs|=e,n)}function om(e,n,r,l,c){var f=ne.p;ne.p=f!==0&&8>f?f:8;var p=z.T,b={};z.T=b,lu(e,!1,n,r);try{var T=c(),L=z.S;if(L!==null&&L(b,T),T!==null&&typeof T=="object"&&typeof T.then=="function"){var V=Hb(T,l);ca(e,n,V,en(e))}else ca(e,n,l,en(e))}catch(W){ca(e,n,{then:function(){},status:"rejected",reason:W},en())}finally{ne.p=f,p!==null&&b.types!==null&&(p.types=b.types),z.T=p}}function Fb(){}function ru(e,n,r,l){if(e.tag!==5)throw Error(a(476));var c=cm(e).queue;om(e,c,n,se,r===null?Fb:function(){return um(e),r(l)})}function cm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:se},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function um(e){var n=cm(e);n.next===null&&(n=e.alternate.memoizedState),ca(e,n.next.queue,{},en())}function au(){return At(Aa)}function fm(){return ut().memoizedState}function hm(){return ut().memoizedState}function Jb(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=en();e=ks(r);var l=Cs(n,e,r);l!==null&&(Gt(l,n,r),ia(l,n,r)),n={cache:qc()},e.payload=n;return}n=n.return}}function Qb(e,n,r){var l=en();r={lane:l,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ll(e)?mm(n,r):(r=Ec(e,n,r,l),r!==null&&(Gt(r,e,l),pm(r,n,l)))}function dm(e,n,r){var l=en();ca(e,n,r,l)}function ca(e,n,r,l){var c={lane:l,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(Ll(e))mm(n,c);else{var f=e.alternate;if(e.lanes===0&&(f===null||f.lanes===0)&&(f=n.lastRenderedReducer,f!==null))try{var p=n.lastRenderedState,b=f(p,r);if(c.hasEagerState=!0,c.eagerState=b,Jt(b,p))return xl(e,n,c,0),Ke===null&&bl(),!1}catch{}finally{}if(r=Ec(e,n,c,l),r!==null)return Gt(r,e,l),pm(r,n,l),!0}return!1}function lu(e,n,r,l){if(l={lane:2,revertLane:Lu(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ll(e)){if(n)throw Error(a(479))}else n=Ec(e,r,l,2),n!==null&&Gt(n,e,2)}function Ll(e){var n=e.alternate;return e===Ae||n!==null&&n===Ae}function mm(e,n){ir=Ml=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function pm(e,n,r){if((r&4194048)!==0){var l=n.lanes;l&=e.pendingLanes,r|=l,n.lanes=r,li(e,r)}}var ua={readContext:At,use:ql,useCallback:rt,useContext:rt,useEffect:rt,useImperativeHandle:rt,useLayoutEffect:rt,useInsertionEffect:rt,useMemo:rt,useReducer:rt,useRef:rt,useState:rt,useDebugValue:rt,useDeferredValue:rt,useTransition:rt,useSyncExternalStore:rt,useId:rt,useHostTransitionStatus:rt,useFormState:rt,useActionState:rt,useOptimistic:rt,useMemoCache:rt,useCacheRefresh:rt};ua.useEffectEvent=rt;var gm={readContext:At,use:ql,useCallback:function(e,n){return qt().memoizedState=[e,n===void 0?null:n],e},useContext:At,useEffect:Wd,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,Ul(4194308,4,sm.bind(null,n,e),r)},useLayoutEffect:function(e,n){return Ul(4194308,4,e,n)},useInsertionEffect:function(e,n){Ul(4,2,e,n)},useMemo:function(e,n){var r=qt();n=n===void 0?null:n;var l=e();if(wi){It(!0);try{e()}finally{It(!1)}}return r.memoizedState=[l,n],l},useReducer:function(e,n,r){var l=qt();if(r!==void 0){var c=r(n);if(wi){It(!0);try{r(n)}finally{It(!1)}}}else c=n;return l.memoizedState=l.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},l.queue=e,e=e.dispatch=Qb.bind(null,Ae,e),[l.memoizedState,e]},useRef:function(e){var n=qt();return e={current:e},n.memoizedState=e},useState:function(e){e=eu(e);var n=e.queue,r=dm.bind(null,Ae,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:su,useDeferredValue:function(e,n){var r=qt();return iu(r,e,n)},useTransition:function(){var e=eu(!1);return e=om.bind(null,Ae,e.queue,!0,!1),qt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var l=Ae,c=qt();if(Ue){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),Ke===null)throw Error(a(349));(qe&127)!==0||Ud(l,n,r)}c.memoizedState=r;var f={value:r,getSnapshot:n};return c.queue=f,Wd(Ld.bind(null,l,f,e),[e]),l.flags|=2048,ar(9,{destroy:void 0},Bd.bind(null,l,f,r,n),null),r},useId:function(){var e=qt(),n=Ke.identifierPrefix;if(Ue){var r=Un,l=zn;r=(l&~(1<<32-Rt(l)-1)).toString(32)+r,n="_"+n+"R_"+r,r=Rl++,0<r&&(n+="H"+r.toString(32)),n+="_"}else r=$b++,n="_"+n+"r_"+r.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:au,useFormState:Jd,useActionState:Jd,useOptimistic:function(e){var n=qt();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=lu.bind(null,Ae,!0,r),r.dispatch=n,[e,n]},useMemoCache:Xc,useCacheRefresh:function(){return qt().memoizedState=Jb.bind(null,Ae)},useEffectEvent:function(e){var n=qt(),r={impl:e};return n.memoizedState=r,function(){if(($e&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}},ou={readContext:At,use:ql,useCallback:rm,useContext:At,useEffect:nu,useImperativeHandle:im,useInsertionEffect:tm,useLayoutEffect:nm,useMemo:am,useReducer:zl,useRef:Zd,useState:function(){return zl(ss)},useDebugValue:su,useDeferredValue:function(e,n){var r=ut();return lm(r,Ie.memoizedState,e,n)},useTransition:function(){var e=zl(ss)[0],n=ut().memoizedState;return[typeof e=="boolean"?e:oa(e),n]},useSyncExternalStore:zd,useId:fm,useHostTransitionStatus:au,useFormState:Qd,useActionState:Qd,useOptimistic:function(e,n){var r=ut();return $d(r,Ie,e,n)},useMemoCache:Xc,useCacheRefresh:hm};ou.useEffectEvent=em;var ym={readContext:At,use:ql,useCallback:rm,useContext:At,useEffect:nu,useImperativeHandle:im,useInsertionEffect:tm,useLayoutEffect:nm,useMemo:am,useReducer:Wc,useRef:Zd,useState:function(){return Wc(ss)},useDebugValue:su,useDeferredValue:function(e,n){var r=ut();return Ie===null?iu(r,e,n):lm(r,Ie.memoizedState,e,n)},useTransition:function(){var e=Wc(ss)[0],n=ut().memoizedState;return[typeof e=="boolean"?e:oa(e),n]},useSyncExternalStore:zd,useId:fm,useHostTransitionStatus:au,useFormState:Xd,useActionState:Xd,useOptimistic:function(e,n){var r=ut();return Ie!==null?$d(r,Ie,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:Xc,useCacheRefresh:hm};ym.useEffectEvent=em;function cu(e,n,r,l){n=e.memoizedState,r=r(l,n),r=r==null?n:_({},n,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var uu={enqueueSetState:function(e,n,r){e=e._reactInternals;var l=en(),c=ks(l);c.payload=n,r!=null&&(c.callback=r),n=Cs(e,c,l),n!==null&&(Gt(n,e,l),ia(n,e,l))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var l=en(),c=ks(l);c.tag=1,c.payload=n,r!=null&&(c.callback=r),n=Cs(e,c,l),n!==null&&(Gt(n,e,l),ia(n,e,l))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=en(),l=ks(r);l.tag=2,n!=null&&(l.callback=n),n=Cs(e,l,r),n!==null&&(Gt(n,e,r),ia(n,e,r))}};function bm(e,n,r,l,c,f,p){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,f,p):n.prototype&&n.prototype.isPureReactComponent?!Kr(r,l)||!Kr(c,f):!0}function xm(e,n,r,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,l),n.state!==e&&uu.enqueueReplaceState(n,n.state,null)}function Si(e,n){var r=n;if("ref"in n){r={};for(var l in n)l!=="ref"&&(r[l]=n[l])}if(e=e.defaultProps){r===n&&(r=_({},r));for(var c in e)r[c]===void 0&&(r[c]=e[c])}return r}function vm(e){yl(e)}function _m(e){console.error(e)}function wm(e){yl(e)}function Pl(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function Sm(e,n,r){try{var l=e.onCaughtError;l(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function fu(e,n,r){return r=ks(r),r.tag=3,r.payload={element:null},r.callback=function(){Pl(e,n)},r}function Em(e){return e=ks(e),e.tag=3,e}function jm(e,n,r,l){var c=r.type.getDerivedStateFromError;if(typeof c=="function"){var f=l.value;e.payload=function(){return c(f)},e.callback=function(){Sm(n,r,l)}}var p=r.stateNode;p!==null&&typeof p.componentDidCatch=="function"&&(e.callback=function(){Sm(n,r,l),typeof c!="function"&&(Us===null?Us=new Set([this]):Us.add(this));var b=l.stack;this.componentDidCatch(l.value,{componentStack:b!==null?b:""})})}function Kb(e,n,r,l,c){if(r.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=r.alternate,n!==null&&Zi(n,r,c,!0),r=Kt.current,r!==null){switch(r.tag){case 31:case 13:return yn===null?Zl():r.alternate===null&&at===0&&(at=3),r.flags&=-257,r.flags|=65536,r.lanes=c,l===Ol?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([l]):n.add(l),zu(e,l,c)),!1;case 22:return r.flags|=65536,l===Ol?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([l]):r.add(l)),zu(e,l,c)),!1}throw Error(a(435,r.tag))}return zu(e,l,c),Zl(),!1}if(Ue)return n=Kt.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=c,l!==kc&&(e=Error(a(422),{cause:l}),Wr(dn(e,r)))):(l!==kc&&(n=Error(a(423),{cause:l}),Wr(dn(n,r))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,l=dn(l,r),c=fu(e.stateNode,l,c),Hc(e,c),at!==4&&(at=2)),!1;var f=Error(a(520),{cause:l});if(f=dn(f,r),ba===null?ba=[f]:ba.push(f),at!==4&&(at=2),n===null)return!0;l=dn(l,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=c&-c,r.lanes|=e,e=fu(r.stateNode,l,e),Hc(r,e),!1;case 1:if(n=r.type,f=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(Us===null||!Us.has(f))))return r.flags|=65536,c&=-c,r.lanes|=c,c=Em(c),jm(c,e,r,l),Hc(r,c),!1}r=r.return}while(r!==null);return!1}var hu=Error(a(461)),pt=!1;function Ot(e,n,r,l){n.child=e===null?Td(n,null,r,l):_i(n,e.child,r,l)}function Am(e,n,r,l,c){r=r.render;var f=n.ref;if("ref"in l){var p={};for(var b in l)b!=="ref"&&(p[b]=l[b])}else p=l;return yi(n),l=Fc(e,n,r,p,f,c),b=Jc(),e!==null&&!pt?(Qc(e,n,c),is(e,n,c)):(Ue&&b&&Nc(n),n.flags|=1,Ot(e,n,l,c),n.child)}function Om(e,n,r,l,c){if(e===null){var f=r.type;return typeof f=="function"&&!jc(f)&&f.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=f,Nm(e,n,f,l,c)):(e=_l(r.type,null,l,n,n.mode,c),e.ref=n.ref,e.return=n,n.child=e)}if(f=e.child,!vu(e,c)){var p=f.memoizedProps;if(r=r.compare,r=r!==null?r:Kr,r(p,l)&&e.ref===n.ref)return is(e,n,c)}return n.flags|=1,e=Zn(f,l),e.ref=n.ref,e.return=n,n.child=e}function Nm(e,n,r,l,c){if(e!==null){var f=e.memoizedProps;if(Kr(f,l)&&e.ref===n.ref)if(pt=!1,n.pendingProps=l=f,vu(e,c))(e.flags&131072)!==0&&(pt=!0);else return n.lanes=e.lanes,is(e,n,c)}return du(e,n,r,l,c)}function Tm(e,n,r,l){var c=l.children,f=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(f=f!==null?f.baseLanes|r:r,e!==null){for(l=n.child=e.child,c=0;l!==null;)c=c|l.lanes|l.childLanes,l=l.sibling;l=c&~f}else l=0,n.child=null;return km(e,n,f,r,l)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&jl(n,f!==null?f.cachePool:null),f!==null?Md(n,f):Yc(),Rd(n);else return l=n.lanes=536870912,km(e,n,f!==null?f.baseLanes|r:r,r,l)}else f!==null?(jl(n,f.cachePool),Md(n,f),Rs(),n.memoizedState=null):(e!==null&&jl(n,null),Yc(),Rs());return Ot(e,n,c,r),n.child}function fa(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function km(e,n,r,l,c){var f=Uc();return f=f===null?null:{parent:dt._currentValue,pool:f},n.memoizedState={baseLanes:r,cachePool:f},e!==null&&jl(n,null),Yc(),Rd(n),e!==null&&Zi(e,n,l,!0),n.childLanes=c,null}function Hl(e,n){return n=Yl({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Cm(e,n,r){return _i(n,e.child,null,r),e=Hl(n,n.pendingProps),e.flags|=2,Xt(n),n.memoizedState=null,e}function Xb(e,n,r){var l=n.pendingProps,c=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Ue){if(l.mode==="hidden")return e=Hl(n,l),n.lanes=536870912,fa(null,e);if(Vc(n),(e=Ze)?(e=Yp(e,gn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:js!==null?{id:zn,overflow:Un}:null,retryLane:536870912,hydrationErrors:null},r=md(e),r.return=n,n.child=r,jt=n,Ze=null)):e=null,e===null)throw Os(n);return n.lanes=536870912,null}return Hl(n,l)}var f=e.memoizedState;if(f!==null){var p=f.dehydrated;if(Vc(n),c)if(n.flags&256)n.flags&=-257,n=Cm(e,n,r);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(pt||Zi(e,n,r,!1),c=(r&e.childLanes)!==0,pt||c){if(l=Ke,l!==null&&(p=Ss(l,r),p!==0&&p!==f.retryLane))throw f.retryLane=p,di(e,p),Gt(l,e,p),hu;Zl(),n=Cm(e,n,r)}else e=f.treeContext,Ze=bn(p.nextSibling),jt=n,Ue=!0,As=null,gn=!1,e!==null&&yd(n,e),n=Hl(n,l),n.flags|=4096;return n}return e=Zn(e.child,{mode:l.mode,children:l.children}),e.ref=n.ref,n.child=e,e.return=n,e}function $l(e,n){var r=n.ref;if(r===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(a(284));(e===null||e.ref!==r)&&(n.flags|=4194816)}}function du(e,n,r,l,c){return yi(n),r=Fc(e,n,r,l,void 0,c),l=Jc(),e!==null&&!pt?(Qc(e,n,c),is(e,n,c)):(Ue&&l&&Nc(n),n.flags|=1,Ot(e,n,r,c),n.child)}function Mm(e,n,r,l,c,f){return yi(n),n.updateQueue=null,r=qd(n,l,r,c),Dd(e),l=Jc(),e!==null&&!pt?(Qc(e,n,f),is(e,n,f)):(Ue&&l&&Nc(n),n.flags|=1,Ot(e,n,r,f),n.child)}function Rm(e,n,r,l,c){if(yi(n),n.stateNode===null){var f=Ji,p=r.contextType;typeof p=="object"&&p!==null&&(f=At(p)),f=new r(l,f),n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=uu,n.stateNode=f,f._reactInternals=n,f=n.stateNode,f.props=l,f.state=n.memoizedState,f.refs={},Lc(n),p=r.contextType,f.context=typeof p=="object"&&p!==null?At(p):Ji,f.state=n.memoizedState,p=r.getDerivedStateFromProps,typeof p=="function"&&(cu(n,r,p,l),f.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(p=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),p!==f.state&&uu.enqueueReplaceState(f,f.state,null),aa(n,l,f,c),ra(),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(e===null){f=n.stateNode;var b=n.memoizedProps,T=Si(r,b);f.props=T;var L=f.context,V=r.contextType;p=Ji,typeof V=="object"&&V!==null&&(p=At(V));var W=r.getDerivedStateFromProps;V=typeof W=="function"||typeof f.getSnapshotBeforeUpdate=="function",b=n.pendingProps!==b,V||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(b||L!==p)&&xm(n,f,l,p),Ts=!1;var P=n.memoizedState;f.state=P,aa(n,l,f,c),ra(),L=n.memoizedState,b||P!==L||Ts?(typeof W=="function"&&(cu(n,r,W,l),L=n.memoizedState),(T=Ts||bm(n,r,T,l,P,L,p))?(V||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(n.flags|=4194308)):(typeof f.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=L),f.props=l,f.state=L,f.context=p,l=T):(typeof f.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{f=n.stateNode,Pc(e,n),p=n.memoizedProps,V=Si(r,p),f.props=V,W=n.pendingProps,P=f.context,L=r.contextType,T=Ji,typeof L=="object"&&L!==null&&(T=At(L)),b=r.getDerivedStateFromProps,(L=typeof b=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(p!==W||P!==T)&&xm(n,f,l,T),Ts=!1,P=n.memoizedState,f.state=P,aa(n,l,f,c),ra();var Y=n.memoizedState;p!==W||P!==Y||Ts||e!==null&&e.dependencies!==null&&Sl(e.dependencies)?(typeof b=="function"&&(cu(n,r,b,l),Y=n.memoizedState),(V=Ts||bm(n,r,V,l,P,Y,T)||e!==null&&e.dependencies!==null&&Sl(e.dependencies))?(L||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(l,Y,T),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(l,Y,T)),typeof f.componentDidUpdate=="function"&&(n.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof f.componentDidUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=Y),f.props=l,f.state=Y,f.context=T,l=V):(typeof f.componentDidUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=1024),l=!1)}return f=l,$l(e,n),l=(n.flags&128)!==0,f||l?(f=n.stateNode,r=l&&typeof r.getDerivedStateFromError!="function"?null:f.render(),n.flags|=1,e!==null&&l?(n.child=_i(n,e.child,null,c),n.child=_i(n,null,r,c)):Ot(e,n,r,c),n.memoizedState=f.state,e=n.child):e=is(e,n,c),e}function Dm(e,n,r,l){return pi(),n.flags|=256,Ot(e,n,r,l),n.child}var mu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function pu(e){return{baseLanes:e,cachePool:Sd()}}function gu(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=Wt),e}function qm(e,n,r){var l=n.pendingProps,c=!1,f=(n.flags&128)!==0,p;if((p=f)||(p=e!==null&&e.memoizedState===null?!1:(ct.current&2)!==0),p&&(c=!0,n.flags&=-129),p=(n.flags&32)!==0,n.flags&=-33,e===null){if(Ue){if(c?Ms(n):Rs(),(e=Ze)?(e=Yp(e,gn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:js!==null?{id:zn,overflow:Un}:null,retryLane:536870912,hydrationErrors:null},r=md(e),r.return=n,n.child=r,jt=n,Ze=null)):e=null,e===null)throw Os(n);return Zu(e)?n.lanes=32:n.lanes=536870912,null}var b=l.children;return l=l.fallback,c?(Rs(),c=n.mode,b=Yl({mode:"hidden",children:b},c),l=mi(l,c,r,null),b.return=n,l.return=n,b.sibling=l,n.child=b,l=n.child,l.memoizedState=pu(r),l.childLanes=gu(e,p,r),n.memoizedState=mu,fa(null,l)):(Ms(n),yu(n,b))}var T=e.memoizedState;if(T!==null&&(b=T.dehydrated,b!==null)){if(f)n.flags&256?(Ms(n),n.flags&=-257,n=bu(e,n,r)):n.memoizedState!==null?(Rs(),n.child=e.child,n.flags|=128,n=null):(Rs(),b=l.fallback,c=n.mode,l=Yl({mode:"visible",children:l.children},c),b=mi(b,c,r,null),b.flags|=2,l.return=n,b.return=n,l.sibling=b,n.child=l,_i(n,e.child,null,r),l=n.child,l.memoizedState=pu(r),l.childLanes=gu(e,p,r),n.memoizedState=mu,n=fa(null,l));else if(Ms(n),Zu(b)){if(p=b.nextSibling&&b.nextSibling.dataset,p)var L=p.dgst;p=L,l=Error(a(419)),l.stack="",l.digest=p,Wr({value:l,source:null,stack:null}),n=bu(e,n,r)}else if(pt||Zi(e,n,r,!1),p=(r&e.childLanes)!==0,pt||p){if(p=Ke,p!==null&&(l=Ss(p,r),l!==0&&l!==T.retryLane))throw T.retryLane=l,di(e,l),Gt(p,e,l),hu;Xu(b)||Zl(),n=bu(e,n,r)}else Xu(b)?(n.flags|=192,n.child=e.child,n=null):(e=T.treeContext,Ze=bn(b.nextSibling),jt=n,Ue=!0,As=null,gn=!1,e!==null&&yd(n,e),n=yu(n,l.children),n.flags|=4096);return n}return c?(Rs(),b=l.fallback,c=n.mode,T=e.child,L=T.sibling,l=Zn(T,{mode:"hidden",children:l.children}),l.subtreeFlags=T.subtreeFlags&65011712,L!==null?b=Zn(L,b):(b=mi(b,c,r,null),b.flags|=2),b.return=n,l.return=n,l.sibling=b,n.child=l,fa(null,l),l=n.child,b=e.child.memoizedState,b===null?b=pu(r):(c=b.cachePool,c!==null?(T=dt._currentValue,c=c.parent!==T?{parent:T,pool:T}:c):c=Sd(),b={baseLanes:b.baseLanes|r,cachePool:c}),l.memoizedState=b,l.childLanes=gu(e,p,r),n.memoizedState=mu,fa(e.child,l)):(Ms(n),r=e.child,e=r.sibling,r=Zn(r,{mode:"visible",children:l.children}),r.return=n,r.sibling=null,e!==null&&(p=n.deletions,p===null?(n.deletions=[e],n.flags|=16):p.push(e)),n.child=r,n.memoizedState=null,r)}function yu(e,n){return n=Yl({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Yl(e,n){return e=Qt(22,e,null,n),e.lanes=0,e}function bu(e,n,r){return _i(n,e.child,null,r),e=yu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function zm(e,n,r){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Rc(e.return,n,r)}function xu(e,n,r,l,c,f){var p=e.memoizedState;p===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:r,tailMode:c,treeForkCount:f}:(p.isBackwards=n,p.rendering=null,p.renderingStartTime=0,p.last=l,p.tail=r,p.tailMode=c,p.treeForkCount=f)}function Um(e,n,r){var l=n.pendingProps,c=l.revealOrder,f=l.tail;l=l.children;var p=ct.current,b=(p&2)!==0;if(b?(p=p&1|2,n.flags|=128):p&=1,Me(ct,p),Ot(e,n,l,r),l=Ue?Zr:0,!b&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&zm(e,r,n);else if(e.tag===19)zm(e,r,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(r=n.child,c=null;r!==null;)e=r.alternate,e!==null&&Cl(e)===null&&(c=r),r=r.sibling;r=c,r===null?(c=n.child,n.child=null):(c=r.sibling,r.sibling=null),xu(n,!1,c,r,f,l);break;case"backwards":case"unstable_legacy-backwards":for(r=null,c=n.child,n.child=null;c!==null;){if(e=c.alternate,e!==null&&Cl(e)===null){n.child=c;break}e=c.sibling,c.sibling=r,r=c,c=e}xu(n,!0,r,null,f,l);break;case"together":xu(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function is(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),zs|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(Zi(e,n,r,!1),(r&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,r=Zn(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=Zn(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function vu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&Sl(e)))}function Zb(e,n,r){switch(n.tag){case 3:Ct(n,n.stateNode.containerInfo),Ns(n,dt,e.memoizedState.cache),pi();break;case 27:case 5:Mt(n);break;case 4:Ct(n,n.stateNode.containerInfo);break;case 10:Ns(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Vc(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(Ms(n),n.flags|=128,null):(r&n.child.childLanes)!==0?qm(e,n,r):(Ms(n),e=is(e,n,r),e!==null?e.sibling:null);Ms(n);break;case 19:var c=(e.flags&128)!==0;if(l=(r&n.childLanes)!==0,l||(Zi(e,n,r,!1),l=(r&n.childLanes)!==0),c){if(l)return Um(e,n,r);n.flags|=128}if(c=n.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),Me(ct,ct.current),l)break;return null;case 22:return n.lanes=0,Tm(e,n,r,n.pendingProps);case 24:Ns(n,dt,e.memoizedState.cache)}return is(e,n,r)}function Bm(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)pt=!0;else{if(!vu(e,r)&&(n.flags&128)===0)return pt=!1,Zb(e,n,r);pt=(e.flags&131072)!==0}else pt=!1,Ue&&(n.flags&1048576)!==0&&gd(n,Zr,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(e=xi(n.elementType),n.type=e,typeof e=="function")jc(e)?(l=Si(e,l),n.tag=1,n=Rm(null,n,e,l,r)):(n.tag=0,n=du(null,n,e,l,r));else{if(e!=null){var c=e.$$typeof;if(c===oe){n.tag=11,n=Am(null,n,e,l,r);break e}else if(c===ae){n.tag=14,n=Om(null,n,e,l,r);break e}}throw n=ke(e)||e,Error(a(306,n,""))}}return n;case 0:return du(e,n,n.type,n.pendingProps,r);case 1:return l=n.type,c=Si(l,n.pendingProps),Rm(e,n,l,c,r);case 3:e:{if(Ct(n,n.stateNode.containerInfo),e===null)throw Error(a(387));l=n.pendingProps;var f=n.memoizedState;c=f.element,Pc(e,n),aa(n,l,null,r);var p=n.memoizedState;if(l=p.cache,Ns(n,dt,l),l!==f.cache&&Dc(n,[dt],r,!0),ra(),l=p.element,f.isDehydrated)if(f={element:l,isDehydrated:!1,cache:p.cache},n.updateQueue.baseState=f,n.memoizedState=f,n.flags&256){n=Dm(e,n,l,r);break e}else if(l!==c){c=dn(Error(a(424)),n),Wr(c),n=Dm(e,n,l,r);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Ze=bn(e.firstChild),jt=n,Ue=!0,As=null,gn=!0,r=Td(n,null,l,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling}else{if(pi(),l===c){n=is(e,n,r);break e}Ot(e,n,l,r)}n=n.child}return n;case 26:return $l(e,n),e===null?(r=Qp(n.type,null,n.pendingProps,null))?n.memoizedState=r:Ue||(r=n.type,e=n.pendingProps,l=ro(on.current).createElement(r),l[Qe]=n,l[it]=e,Nt(l,r,e),k(l),n.stateNode=l):n.memoizedState=Qp(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Mt(n),e===null&&Ue&&(l=n.stateNode=Ip(n.type,n.pendingProps,on.current),jt=n,gn=!0,c=Ze,Hs(n.type)?(Wu=c,Ze=bn(l.firstChild)):Ze=c),Ot(e,n,n.pendingProps.children,r),$l(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Ue&&((c=l=Ze)&&(l=Nx(l,n.type,n.pendingProps,gn),l!==null?(n.stateNode=l,jt=n,Ze=bn(l.firstChild),gn=!1,c=!0):c=!1),c||Os(n)),Mt(n),c=n.type,f=n.pendingProps,p=e!==null?e.memoizedProps:null,l=f.children,Ju(c,f)?l=null:p!==null&&Ju(c,p)&&(n.flags|=32),n.memoizedState!==null&&(c=Fc(e,n,Yb,null,null,r),Aa._currentValue=c),$l(e,n),Ot(e,n,l,r),n.child;case 6:return e===null&&Ue&&((e=r=Ze)&&(r=Tx(r,n.pendingProps,gn),r!==null?(n.stateNode=r,jt=n,Ze=null,e=!0):e=!1),e||Os(n)),null;case 13:return qm(e,n,r);case 4:return Ct(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=_i(n,null,l,r):Ot(e,n,l,r),n.child;case 11:return Am(e,n,n.type,n.pendingProps,r);case 7:return Ot(e,n,n.pendingProps,r),n.child;case 8:return Ot(e,n,n.pendingProps.children,r),n.child;case 12:return Ot(e,n,n.pendingProps.children,r),n.child;case 10:return l=n.pendingProps,Ns(n,n.type,l.value),Ot(e,n,l.children,r),n.child;case 9:return c=n.type._context,l=n.pendingProps.children,yi(n),c=At(c),l=l(c),n.flags|=1,Ot(e,n,l,r),n.child;case 14:return Om(e,n,n.type,n.pendingProps,r);case 15:return Nm(e,n,n.type,n.pendingProps,r);case 19:return Um(e,n,r);case 31:return Xb(e,n,r);case 22:return Tm(e,n,r,n.pendingProps);case 24:return yi(n),l=At(dt),e===null?(c=Uc(),c===null&&(c=Ke,f=qc(),c.pooledCache=f,f.refCount++,f!==null&&(c.pooledCacheLanes|=r),c=f),n.memoizedState={parent:l,cache:c},Lc(n),Ns(n,dt,c)):((e.lanes&r)!==0&&(Pc(e,n),aa(n,null,null,r),ra()),c=e.memoizedState,f=n.memoizedState,c.parent!==l?(c={parent:l,cache:l},n.memoizedState=c,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=c),Ns(n,dt,l)):(l=f.cache,Ns(n,dt,l),l!==c.cache&&Dc(n,[dt],r,!0))),Ot(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function rs(e){e.flags|=4}function _u(e,n,r,l,c){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(fp())e.flags|=8192;else throw vi=Ol,Bc}else e.flags&=-16777217}function Lm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!e0(n))if(fp())e.flags|=8192;else throw vi=Ol,Bc}function Gl(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?Bi():536870912,e.lanes|=n,ur|=n)}function ha(e,n){if(!Ue)switch(e.tailMode){case"hidden":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function We(e){var n=e.alternate!==null&&e.alternate.child===e.child,r=0,l=0;if(n)for(var c=e.child;c!==null;)r|=c.lanes|c.childLanes,l|=c.subtreeFlags&65011712,l|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)r|=c.lanes|c.childLanes,l|=c.subtreeFlags,l|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=l,e.childLanes=r,n}function Wb(e,n,r){var l=n.pendingProps;switch(Tc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return We(n),null;case 1:return We(n),null;case 3:return r=n.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),ts(dt),je(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Xi(n)?rs(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Cc())),We(n),null;case 26:var c=n.type,f=n.memoizedState;return e===null?(rs(n),f!==null?(We(n),Lm(n,f)):(We(n),_u(n,c,null,l,r))):f?f!==e.memoizedState?(rs(n),We(n),Lm(n,f)):(We(n),n.flags&=-16777217):(e=e.memoizedProps,e!==l&&rs(n),We(n),_u(n,c,e,l,r)),null;case 27:if(ni(n),r=on.current,c=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==l&&rs(n);else{if(!l){if(n.stateNode===null)throw Error(a(166));return We(n),null}e=lt.current,Xi(n)?bd(n):(e=Ip(c,l,r),n.stateNode=e,rs(n))}return We(n),null;case 5:if(ni(n),c=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==l&&rs(n);else{if(!l){if(n.stateNode===null)throw Error(a(166));return We(n),null}if(f=lt.current,Xi(n))bd(n);else{var p=ro(on.current);switch(f){case 1:f=p.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:f=p.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":f=p.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":f=p.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":f=p.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof l.is=="string"?p.createElement("select",{is:l.is}):p.createElement("select"),l.multiple?f.multiple=!0:l.size&&(f.size=l.size);break;default:f=typeof l.is=="string"?p.createElement(c,{is:l.is}):p.createElement(c)}}f[Qe]=n,f[it]=l;e:for(p=n.child;p!==null;){if(p.tag===5||p.tag===6)f.appendChild(p.stateNode);else if(p.tag!==4&&p.tag!==27&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===n)break e;for(;p.sibling===null;){if(p.return===null||p.return===n)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}n.stateNode=f;e:switch(Nt(f,c,l),c){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&rs(n)}}return We(n),_u(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,r),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==l&&rs(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(a(166));if(e=on.current,Xi(n)){if(e=n.stateNode,r=n.memoizedProps,l=null,c=jt,c!==null)switch(c.tag){case 27:case 5:l=c.memoizedProps}e[Qe]=n,e=!!(e.nodeValue===r||l!==null&&l.suppressHydrationWarning===!0||qp(e.nodeValue,r)),e||Os(n,!0)}else e=ro(e).createTextNode(l),e[Qe]=n,n.stateNode=e}return We(n),null;case 31:if(r=n.memoizedState,e===null||e.memoizedState!==null){if(l=Xi(n),r!==null){if(e===null){if(!l)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Qe]=n}else pi(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;We(n),e=!1}else r=Cc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),e=!0;if(!e)return n.flags&256?(Xt(n),n):(Xt(n),null);if((n.flags&128)!==0)throw Error(a(558))}return We(n),null;case 13:if(l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=Xi(n),l!==null&&l.dehydrated!==null){if(e===null){if(!c)throw Error(a(318));if(c=n.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(a(317));c[Qe]=n}else pi(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;We(n),c=!1}else c=Cc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return n.flags&256?(Xt(n),n):(Xt(n),null)}return Xt(n),(n.flags&128)!==0?(n.lanes=r,n):(r=l!==null,e=e!==null&&e.memoizedState!==null,r&&(l=n.child,c=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(c=l.alternate.memoizedState.cachePool.pool),f=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(f=l.memoizedState.cachePool.pool),f!==c&&(l.flags|=2048)),r!==e&&r&&(n.child.flags|=8192),Gl(n,n.updateQueue),We(n),null);case 4:return je(),e===null&&Yu(n.stateNode.containerInfo),We(n),null;case 10:return ts(n.type),We(n),null;case 19:if(Ee(ct),l=n.memoizedState,l===null)return We(n),null;if(c=(n.flags&128)!==0,f=l.rendering,f===null)if(c)ha(l,!1);else{if(at!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(f=Cl(e),f!==null){for(n.flags|=128,ha(l,!1),e=f.updateQueue,n.updateQueue=e,Gl(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)dd(r,e),r=r.sibling;return Me(ct,ct.current&1|2),Ue&&Wn(n,l.treeForkCount),n.child}e=e.sibling}l.tail!==null&&et()>Ql&&(n.flags|=128,c=!0,ha(l,!1),n.lanes=4194304)}else{if(!c)if(e=Cl(f),e!==null){if(n.flags|=128,c=!0,e=e.updateQueue,n.updateQueue=e,Gl(n,e),ha(l,!0),l.tail===null&&l.tailMode==="hidden"&&!f.alternate&&!Ue)return We(n),null}else 2*et()-l.renderingStartTime>Ql&&r!==536870912&&(n.flags|=128,c=!0,ha(l,!1),n.lanes=4194304);l.isBackwards?(f.sibling=n.child,n.child=f):(e=l.last,e!==null?e.sibling=f:n.child=f,l.last=f)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=et(),e.sibling=null,r=ct.current,Me(ct,c?r&1|2:r&1),Ue&&Wn(n,l.treeForkCount),e):(We(n),null);case 22:case 23:return Xt(n),Gc(),l=n.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(r&536870912)!==0&&(n.flags&128)===0&&(We(n),n.subtreeFlags&6&&(n.flags|=8192)):We(n),r=n.updateQueue,r!==null&&Gl(n,r.retryQueue),r=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==r&&(n.flags|=2048),e!==null&&Ee(bi),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),ts(dt),We(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function ex(e,n){switch(Tc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ts(dt),je(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return ni(n),null;case 31:if(n.memoizedState!==null){if(Xt(n),n.alternate===null)throw Error(a(340));pi()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Xt(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));pi()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ee(ct),null;case 4:return je(),null;case 10:return ts(n.type),null;case 22:case 23:return Xt(n),Gc(),e!==null&&Ee(bi),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ts(dt),null;case 25:return null;default:return null}}function Pm(e,n){switch(Tc(n),n.tag){case 3:ts(dt),je();break;case 26:case 27:case 5:ni(n);break;case 4:je();break;case 31:n.memoizedState!==null&&Xt(n);break;case 13:Xt(n);break;case 19:Ee(ct);break;case 10:ts(n.type);break;case 22:case 23:Xt(n),Gc(),e!==null&&Ee(bi);break;case 24:ts(dt)}}function da(e,n){try{var r=n.updateQueue,l=r!==null?r.lastEffect:null;if(l!==null){var c=l.next;r=c;do{if((r.tag&e)===e){l=void 0;var f=r.create,p=r.inst;l=f(),p.destroy=l}r=r.next}while(r!==c)}}catch(b){Ge(n,n.return,b)}}function Ds(e,n,r){try{var l=n.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var f=c.next;l=f;do{if((l.tag&e)===e){var p=l.inst,b=p.destroy;if(b!==void 0){p.destroy=void 0,c=n;var T=r,L=b;try{L()}catch(V){Ge(c,T,V)}}}l=l.next}while(l!==f)}}catch(V){Ge(n,n.return,V)}}function Hm(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{Cd(n,r)}catch(l){Ge(e,e.return,l)}}}function $m(e,n,r){r.props=Si(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(l){Ge(e,n,l)}}function ma(e,n){try{var r=e.ref;if(r!==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 r=="function"?e.refCleanup=r(l):r.current=l}}catch(c){Ge(e,n,c)}}function Bn(e,n){var r=e.ref,l=e.refCleanup;if(r!==null)if(typeof l=="function")try{l()}catch(c){Ge(e,n,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(c){Ge(e,n,c)}else r.current=null}function Ym(e){var n=e.type,r=e.memoizedProps,l=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&l.focus();break e;case"img":r.src?l.src=r.src:r.srcSet&&(l.srcset=r.srcSet)}}catch(c){Ge(e,e.return,c)}}function wu(e,n,r){try{var l=e.stateNode;wx(l,e.type,r,n),l[it]=n}catch(c){Ge(e,e.return,c)}}function Gm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Hs(e.type)||e.tag===4}function Su(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gm(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&&Hs(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 Eu(e,n,r){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(e,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(e),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=Kn));else if(l!==4&&(l===27&&Hs(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(Eu(e,n,r),e=e.sibling;e!==null;)Eu(e,n,r),e=e.sibling}function Vl(e,n,r){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?r.insertBefore(e,n):r.appendChild(e);else if(l!==4&&(l===27&&Hs(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(Vl(e,n,r),e=e.sibling;e!==null;)Vl(e,n,r),e=e.sibling}function Vm(e){var n=e.stateNode,r=e.memoizedProps;try{for(var l=e.type,c=n.attributes;c.length;)n.removeAttributeNode(c[0]);Nt(n,l,r),n[Qe]=e,n[it]=r}catch(f){Ge(e,e.return,f)}}var as=!1,gt=!1,ju=!1,Im=typeof WeakSet=="function"?WeakSet:Set,_t=null;function tx(e,n){if(e=e.containerInfo,Iu=ho,e=id(e),bc(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var l=r.getSelection&&r.getSelection();if(l&&l.rangeCount!==0){r=l.anchorNode;var c=l.anchorOffset,f=l.focusNode;l=l.focusOffset;try{r.nodeType,f.nodeType}catch{r=null;break e}var p=0,b=-1,T=-1,L=0,V=0,W=e,P=null;t:for(;;){for(var Y;W!==r||c!==0&&W.nodeType!==3||(b=p+c),W!==f||l!==0&&W.nodeType!==3||(T=p+l),W.nodeType===3&&(p+=W.nodeValue.length),(Y=W.firstChild)!==null;)P=W,W=Y;for(;;){if(W===e)break t;if(P===r&&++L===c&&(b=p),P===f&&++V===l&&(T=p),(Y=W.nextSibling)!==null)break;W=P,P=W.parentNode}W=Y}r=b===-1||T===-1?null:{start:b,end:T}}else r=null}r=r||{start:0,end:0}}else r=null;for(Fu={focusedElem:e,selectionRange:r},ho=!1,_t=n;_t!==null;)if(n=_t,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,_t=e;else for(;_t!==null;){switch(n=_t,f=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(r=0;r<e.length;r++)c=e[r],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&f!==null){e=void 0,r=n,c=f.memoizedProps,f=f.memoizedState,l=r.stateNode;try{var me=Si(r.type,c);e=l.getSnapshotBeforeUpdate(me,f),l.__reactInternalSnapshotBeforeUpdate=e}catch(xe){Ge(r,r.return,xe)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)Ku(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ku(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(a(163))}if(e=n.sibling,e!==null){e.return=n.return,_t=e;break}_t=n.return}}function Fm(e,n,r){var l=r.flags;switch(r.tag){case 0:case 11:case 15:os(e,r),l&4&&da(5,r);break;case 1:if(os(e,r),l&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(p){Ge(r,r.return,p)}else{var c=Si(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(c,n,e.__reactInternalSnapshotBeforeUpdate)}catch(p){Ge(r,r.return,p)}}l&64&&Hm(r),l&512&&ma(r,r.return);break;case 3:if(os(e,r),l&64&&(e=r.updateQueue,e!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{Cd(e,n)}catch(p){Ge(r,r.return,p)}}break;case 27:n===null&&l&4&&Vm(r);case 26:case 5:os(e,r),n===null&&l&4&&Ym(r),l&512&&ma(r,r.return);break;case 12:os(e,r);break;case 31:os(e,r),l&4&&Km(e,r);break;case 13:os(e,r),l&4&&Xm(e,r),l&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=ux.bind(null,r),kx(e,r))));break;case 22:if(l=r.memoizedState!==null||as,!l){n=n!==null&&n.memoizedState!==null||gt,c=as;var f=gt;as=l,(gt=n)&&!f?cs(e,r,(r.subtreeFlags&8772)!==0):os(e,r),as=c,gt=f}break;case 30:break;default:os(e,r)}}function Jm(e){var n=e.alternate;n!==null&&(e.alternate=null,Jm(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Li(n)),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 tt=null,Pt=!1;function ls(e,n,r){for(r=r.child;r!==null;)Qm(e,n,r),r=r.sibling}function Qm(e,n,r){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(ii,r)}catch{}switch(r.tag){case 26:gt||Bn(r,n),ls(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:gt||Bn(r,n);var l=tt,c=Pt;Hs(r.type)&&(tt=r.stateNode,Pt=!1),ls(e,n,r),Sa(r.stateNode),tt=l,Pt=c;break;case 5:gt||Bn(r,n);case 6:if(l=tt,c=Pt,tt=null,ls(e,n,r),tt=l,Pt=c,tt!==null)if(Pt)try{(tt.nodeType===9?tt.body:tt.nodeName==="HTML"?tt.ownerDocument.body:tt).removeChild(r.stateNode)}catch(f){Ge(r,n,f)}else try{tt.removeChild(r.stateNode)}catch(f){Ge(r,n,f)}break;case 18:tt!==null&&(Pt?(e=tt,Hp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),br(e)):Hp(tt,r.stateNode));break;case 4:l=tt,c=Pt,tt=r.stateNode.containerInfo,Pt=!0,ls(e,n,r),tt=l,Pt=c;break;case 0:case 11:case 14:case 15:Ds(2,r,n),gt||Ds(4,r,n),ls(e,n,r);break;case 1:gt||(Bn(r,n),l=r.stateNode,typeof l.componentWillUnmount=="function"&&$m(r,n,l)),ls(e,n,r);break;case 21:ls(e,n,r);break;case 22:gt=(l=gt)||r.memoizedState!==null,ls(e,n,r),gt=l;break;default:ls(e,n,r)}}function Km(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{br(e)}catch(r){Ge(n,n.return,r)}}}function Xm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{br(e)}catch(r){Ge(n,n.return,r)}}function nx(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new Im),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new Im),n;default:throw Error(a(435,e.tag))}}function Il(e,n){var r=nx(e);n.forEach(function(l){if(!r.has(l)){r.add(l);var c=fx.bind(null,e,l);l.then(c,c)}})}function Ht(e,n){var r=n.deletions;if(r!==null)for(var l=0;l<r.length;l++){var c=r[l],f=e,p=n,b=p;e:for(;b!==null;){switch(b.tag){case 27:if(Hs(b.type)){tt=b.stateNode,Pt=!1;break e}break;case 5:tt=b.stateNode,Pt=!1;break e;case 3:case 4:tt=b.stateNode.containerInfo,Pt=!0;break e}b=b.return}if(tt===null)throw Error(a(160));Qm(f,p,c),tt=null,Pt=!1,f=c.alternate,f!==null&&(f.return=null),c.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Zm(n,e),n=n.sibling}var Nn=null;function Zm(e,n){var r=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ht(n,e),$t(e),l&4&&(Ds(3,e,e.return),da(3,e),Ds(5,e,e.return));break;case 1:Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),l&64&&as&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(r=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=r===null?l:r.concat(l))));break;case 26:var c=Nn;if(Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),l&4){var f=r!==null?r.memoizedState:null;if(l=e.memoizedState,r===null)if(l===null)if(e.stateNode===null){e:{l=e.type,r=e.memoizedProps,c=c.ownerDocument||c;t:switch(l){case"title":f=c.getElementsByTagName("title")[0],(!f||f[xt]||f[Qe]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=c.createElement(l),c.head.insertBefore(f,c.querySelector("head > title"))),Nt(f,l,r),f[Qe]=e,k(f),l=f;break e;case"link":var p=Zp("link","href",c).get(l+(r.href||""));if(p){for(var b=0;b<p.length;b++)if(f=p[b],f.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&f.getAttribute("rel")===(r.rel==null?null:r.rel)&&f.getAttribute("title")===(r.title==null?null:r.title)&&f.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){p.splice(b,1);break t}}f=c.createElement(l),Nt(f,l,r),c.head.appendChild(f);break;case"meta":if(p=Zp("meta","content",c).get(l+(r.content||""))){for(b=0;b<p.length;b++)if(f=p[b],f.getAttribute("content")===(r.content==null?null:""+r.content)&&f.getAttribute("name")===(r.name==null?null:r.name)&&f.getAttribute("property")===(r.property==null?null:r.property)&&f.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&f.getAttribute("charset")===(r.charSet==null?null:r.charSet)){p.splice(b,1);break t}}f=c.createElement(l),Nt(f,l,r),c.head.appendChild(f);break;default:throw Error(a(468,l))}f[Qe]=e,k(f),l=f}e.stateNode=l}else Wp(c,e.type,e.stateNode);else e.stateNode=Xp(c,l,e.memoizedProps);else f!==l?(f===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):f.count--,l===null?Wp(c,e.type,e.stateNode):Xp(c,l,e.memoizedProps)):l===null&&e.stateNode!==null&&wu(e,e.memoizedProps,r.memoizedProps)}break;case 27:Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),r!==null&&l&4&&wu(e,e.memoizedProps,r.memoizedProps);break;case 5:if(Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),e.flags&32){c=e.stateNode;try{Hi(c,"")}catch(me){Ge(e,e.return,me)}}l&4&&e.stateNode!=null&&(c=e.memoizedProps,wu(e,c,r!==null?r.memoizedProps:c)),l&1024&&(ju=!0);break;case 6:if(Ht(n,e),$t(e),l&4){if(e.stateNode===null)throw Error(a(162));l=e.memoizedProps,r=e.stateNode;try{r.nodeValue=l}catch(me){Ge(e,e.return,me)}}break;case 3:if(oo=null,c=Nn,Nn=ao(n.containerInfo),Ht(n,e),Nn=c,$t(e),l&4&&r!==null&&r.memoizedState.isDehydrated)try{br(n.containerInfo)}catch(me){Ge(e,e.return,me)}ju&&(ju=!1,Wm(e));break;case 4:l=Nn,Nn=ao(e.stateNode.containerInfo),Ht(n,e),$t(e),Nn=l;break;case 12:Ht(n,e),$t(e);break;case 31:Ht(n,e),$t(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Il(e,l)));break;case 13:Ht(n,e),$t(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Jl=et()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Il(e,l)));break;case 22:c=e.memoizedState!==null;var T=r!==null&&r.memoizedState!==null,L=as,V=gt;if(as=L||c,gt=V||T,Ht(n,e),gt=V,as=L,$t(e),l&8192)e:for(n=e.stateNode,n._visibility=c?n._visibility&-2:n._visibility|1,c&&(r===null||T||as||gt||Ei(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){T=r=n;try{if(f=T.stateNode,c)p=f.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none";else{b=T.stateNode;var W=T.memoizedProps.style,P=W!=null&&W.hasOwnProperty("display")?W.display:null;b.style.display=P==null||typeof P=="boolean"?"":(""+P).trim()}}catch(me){Ge(T,T.return,me)}}}else if(n.tag===6){if(r===null){T=n;try{T.stateNode.nodeValue=c?"":T.memoizedProps}catch(me){Ge(T,T.return,me)}}}else if(n.tag===18){if(r===null){T=n;try{var Y=T.stateNode;c?$p(Y,!0):$p(T.stateNode,!1)}catch(me){Ge(T,T.return,me)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}l&4&&(l=e.updateQueue,l!==null&&(r=l.retryQueue,r!==null&&(l.retryQueue=null,Il(e,r))));break;case 19:Ht(n,e),$t(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Il(e,l)));break;case 30:break;case 21:break;default:Ht(n,e),$t(e)}}function $t(e){var n=e.flags;if(n&2){try{for(var r,l=e.return;l!==null;){if(Gm(l)){r=l;break}l=l.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var c=r.stateNode,f=Su(e);Vl(e,f,c);break;case 5:var p=r.stateNode;r.flags&32&&(Hi(p,""),r.flags&=-33);var b=Su(e);Vl(e,b,p);break;case 3:case 4:var T=r.stateNode.containerInfo,L=Su(e);Eu(e,L,T);break;default:throw Error(a(161))}}catch(V){Ge(e,e.return,V)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Wm(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;Wm(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function os(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Fm(e,n.alternate,n),n=n.sibling}function Ei(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Ds(4,n,n.return),Ei(n);break;case 1:Bn(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&$m(n,n.return,r),Ei(n);break;case 27:Sa(n.stateNode);case 26:case 5:Bn(n,n.return),Ei(n);break;case 22:n.memoizedState===null&&Ei(n);break;case 30:Ei(n);break;default:Ei(n)}e=e.sibling}}function cs(e,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,c=e,f=n,p=f.flags;switch(f.tag){case 0:case 11:case 15:cs(c,f,r),da(4,f);break;case 1:if(cs(c,f,r),l=f,c=l.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(L){Ge(l,l.return,L)}if(l=f,c=l.updateQueue,c!==null){var b=l.stateNode;try{var T=c.shared.hiddenCallbacks;if(T!==null)for(c.shared.hiddenCallbacks=null,c=0;c<T.length;c++)kd(T[c],b)}catch(L){Ge(l,l.return,L)}}r&&p&64&&Hm(f),ma(f,f.return);break;case 27:Vm(f);case 26:case 5:cs(c,f,r),r&&l===null&&p&4&&Ym(f),ma(f,f.return);break;case 12:cs(c,f,r);break;case 31:cs(c,f,r),r&&p&4&&Km(c,f);break;case 13:cs(c,f,r),r&&p&4&&Xm(c,f);break;case 22:f.memoizedState===null&&cs(c,f,r),ma(f,f.return);break;case 30:break;default:cs(c,f,r)}n=n.sibling}}function Au(e,n){var r=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==r&&(e!=null&&e.refCount++,r!=null&&ea(r))}function Ou(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ea(e))}function Tn(e,n,r,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)ep(e,n,r,l),n=n.sibling}function ep(e,n,r,l){var c=n.flags;switch(n.tag){case 0:case 11:case 15:Tn(e,n,r,l),c&2048&&da(9,n);break;case 1:Tn(e,n,r,l);break;case 3:Tn(e,n,r,l),c&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ea(e)));break;case 12:if(c&2048){Tn(e,n,r,l),e=n.stateNode;try{var f=n.memoizedProps,p=f.id,b=f.onPostCommit;typeof b=="function"&&b(p,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(T){Ge(n,n.return,T)}}else Tn(e,n,r,l);break;case 31:Tn(e,n,r,l);break;case 13:Tn(e,n,r,l);break;case 23:break;case 22:f=n.stateNode,p=n.alternate,n.memoizedState!==null?f._visibility&2?Tn(e,n,r,l):pa(e,n):f._visibility&2?Tn(e,n,r,l):(f._visibility|=2,lr(e,n,r,l,(n.subtreeFlags&10256)!==0||!1)),c&2048&&Au(p,n);break;case 24:Tn(e,n,r,l),c&2048&&Ou(n.alternate,n);break;default:Tn(e,n,r,l)}}function lr(e,n,r,l,c){for(c=c&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var f=e,p=n,b=r,T=l,L=p.flags;switch(p.tag){case 0:case 11:case 15:lr(f,p,b,T,c),da(8,p);break;case 23:break;case 22:var V=p.stateNode;p.memoizedState!==null?V._visibility&2?lr(f,p,b,T,c):pa(f,p):(V._visibility|=2,lr(f,p,b,T,c)),c&&L&2048&&Au(p.alternate,p);break;case 24:lr(f,p,b,T,c),c&&L&2048&&Ou(p.alternate,p);break;default:lr(f,p,b,T,c)}n=n.sibling}}function pa(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=e,l=n,c=l.flags;switch(l.tag){case 22:pa(r,l),c&2048&&Au(l.alternate,l);break;case 24:pa(r,l),c&2048&&Ou(l.alternate,l);break;default:pa(r,l)}n=n.sibling}}var ga=8192;function or(e,n,r){if(e.subtreeFlags&ga)for(e=e.child;e!==null;)tp(e,n,r),e=e.sibling}function tp(e,n,r){switch(e.tag){case 26:or(e,n,r),e.flags&ga&&e.memoizedState!==null&&$x(r,Nn,e.memoizedState,e.memoizedProps);break;case 5:or(e,n,r);break;case 3:case 4:var l=Nn;Nn=ao(e.stateNode.containerInfo),or(e,n,r),Nn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=ga,ga=16777216,or(e,n,r),ga=l):or(e,n,r));break;default:or(e,n,r)}}function np(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function ya(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var l=n[r];_t=l,ip(l,e)}np(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)sp(e),e=e.sibling}function sp(e){switch(e.tag){case 0:case 11:case 15:ya(e),e.flags&2048&&Ds(9,e,e.return);break;case 3:ya(e);break;case 12:ya(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Fl(e)):ya(e);break;default:ya(e)}}function Fl(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var l=n[r];_t=l,ip(l,e)}np(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Ds(8,n,n.return),Fl(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,Fl(n));break;default:Fl(n)}e=e.sibling}}function ip(e,n){for(;_t!==null;){var r=_t;switch(r.tag){case 0:case 11:case 15:Ds(8,r,n);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var l=r.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:ea(r.memoizedState.cache)}if(l=r.child,l!==null)l.return=r,_t=l;else e:for(r=e;_t!==null;){l=_t;var c=l.sibling,f=l.return;if(Jm(l),l===r){_t=null;break e}if(c!==null){c.return=f,_t=c;break e}_t=f}}}var sx={getCacheForType:function(e){var n=At(dt),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r},cacheSignal:function(){return At(dt).controller.signal}},ix=typeof WeakMap=="function"?WeakMap:Map,$e=0,Ke=null,Re=null,qe=0,Ye=0,Zt=null,qs=!1,cr=!1,Nu=!1,us=0,at=0,zs=0,ji=0,Tu=0,Wt=0,ur=0,ba=null,Yt=null,ku=!1,Jl=0,rp=0,Ql=1/0,Kl=null,Us=null,vt=0,Bs=null,fr=null,fs=0,Cu=0,Mu=null,ap=null,xa=0,Ru=null;function en(){return($e&2)!==0&&qe!==0?qe&-qe:z.T!==null?Lu():Hr()}function lp(){if(Wt===0)if((qe&536870912)===0||Ue){var e=Fn;Fn<<=1,(Fn&3932160)===0&&(Fn=262144),Wt=e}else Wt=536870912;return e=Kt.current,e!==null&&(e.flags|=32),Wt}function Gt(e,n,r){(e===Ke&&(Ye===2||Ye===9)||e.cancelPendingCommit!==null)&&(hr(e,0),Ls(e,qe,Wt,!1)),jn(e,r),(($e&2)===0||e!==Ke)&&(e===Ke&&(($e&2)===0&&(ji|=r),at===4&&Ls(e,qe,Wt,!1)),Ln(e))}function op(e,n,r){if(($e&6)!==0)throw Error(a(327));var l=!r&&(n&127)===0&&(n&e.expiredLanes)===0||ai(e,n),c=l?lx(e,n):qu(e,n,!0),f=l;do{if(c===0){cr&&!l&&Ls(e,n,0,!1);break}else{if(r=e.current.alternate,f&&!rx(r)){c=qu(e,n,!1),f=!1;continue}if(c===2){if(f=n,e.errorRecoveryDisabledLanes&f)var p=0;else p=e.pendingLanes&-536870913,p=p!==0?p:p&536870912?536870912:0;if(p!==0){n=p;e:{var b=e;c=ba;var T=b.current.memoizedState.isDehydrated;if(T&&(hr(b,p).flags|=256),p=qu(b,p,!1),p!==2){if(Nu&&!T){b.errorRecoveryDisabledLanes|=f,ji|=f,c=4;break e}f=Yt,Yt=c,f!==null&&(Yt===null?Yt=f:Yt.push.apply(Yt,f))}c=p}if(f=!1,c!==2)continue}}if(c===1){hr(e,0),Ls(e,n,0,!0);break}e:{switch(l=e,f=c,f){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:Ls(l,n,Wt,!qs);break e;case 2:Yt=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(c=Jl+300-et(),10<c)){if(Ls(l,n,Wt,!qs),ri(l,0,!0)!==0)break e;fs=n,l.timeoutHandle=Lp(cp.bind(null,l,r,Yt,Kl,ku,n,Wt,ji,ur,qs,f,"Throttled",-0,0),c);break e}cp(l,r,Yt,Kl,ku,n,Wt,ji,ur,qs,f,null,-0,0)}}break}while(!0);Ln(e)}function cp(e,n,r,l,c,f,p,b,T,L,V,W,P,Y){if(e.timeoutHandle=-1,W=n.subtreeFlags,W&8192||(W&16785408)===16785408){W={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Kn},tp(n,f,W);var me=(f&62914560)===f?Jl-et():(f&4194048)===f?rp-et():0;if(me=Yx(W,me),me!==null){fs=f,e.cancelPendingCommit=me(yp.bind(null,e,n,f,r,l,c,p,b,T,V,W,null,P,Y)),Ls(e,f,p,!L);return}}yp(e,n,f,r,l,c,p,b,T)}function rx(e){for(var n=e;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var l=0;l<r.length;l++){var c=r[l],f=c.getSnapshot;c=c.value;try{if(!Jt(f(),c))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Ls(e,n,r,l){n&=~Tu,n&=~ji,e.suspendedLanes|=n,e.pingedLanes&=~n,l&&(e.warmLanes|=n),l=e.expirationTimes;for(var c=n;0<c;){var f=31-Rt(c),p=1<<f;l[f]=-1,c&=~p}r!==0&&ws(e,r,n)}function Xl(){return($e&6)===0?(va(0),!1):!0}function Du(){if(Re!==null){if(Ye===0)var e=Re.return;else e=Re,es=gi=null,Kc(e),nr=null,na=0,e=Re;for(;e!==null;)Pm(e.alternate,e),e=e.return;Re=null}}function hr(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,jx(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),fs=0,Du(),Ke=e,Re=r=Zn(e.current,null),qe=n,Ye=0,Zt=null,qs=!1,cr=ai(e,n),Nu=!1,ur=Wt=Tu=ji=zs=at=0,Yt=ba=null,ku=!1,(n&8)!==0&&(n|=n&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=n;0<l;){var c=31-Rt(l),f=1<<c;n|=e[c],l&=~f}return us=n,bl(),r}function up(e,n){Ae=null,z.H=ua,n===tr||n===Al?(n=Ad(),Ye=3):n===Bc?(n=Ad(),Ye=4):Ye=n===hu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Zt=n,Re===null&&(at=1,Pl(e,dn(n,e.current)))}function fp(){var e=Kt.current;return e===null?!0:(qe&4194048)===qe?yn===null:(qe&62914560)===qe||(qe&536870912)!==0?e===yn:!1}function hp(){var e=z.H;return z.H=ua,e===null?ua:e}function dp(){var e=z.A;return z.A=sx,e}function Zl(){at=4,qs||(qe&4194048)!==qe&&Kt.current!==null||(cr=!0),(zs&134217727)===0&&(ji&134217727)===0||Ke===null||Ls(Ke,qe,Wt,!1)}function qu(e,n,r){var l=$e;$e|=2;var c=hp(),f=dp();(Ke!==e||qe!==n)&&(Kl=null,hr(e,n)),n=!1;var p=at;e:do try{if(Ye!==0&&Re!==null){var b=Re,T=Zt;switch(Ye){case 8:Du(),p=6;break e;case 3:case 2:case 9:case 6:Kt.current===null&&(n=!0);var L=Ye;if(Ye=0,Zt=null,dr(e,b,T,L),r&&cr){p=0;break e}break;default:L=Ye,Ye=0,Zt=null,dr(e,b,T,L)}}ax(),p=at;break}catch(V){up(e,V)}while(!0);return n&&e.shellSuspendCounter++,es=gi=null,$e=l,z.H=c,z.A=f,Re===null&&(Ke=null,qe=0,bl()),p}function ax(){for(;Re!==null;)mp(Re)}function lx(e,n){var r=$e;$e|=2;var l=hp(),c=dp();Ke!==e||qe!==n?(Kl=null,Ql=et()+500,hr(e,n)):cr=ai(e,n);e:do try{if(Ye!==0&&Re!==null){n=Re;var f=Zt;t:switch(Ye){case 1:Ye=0,Zt=null,dr(e,n,f,1);break;case 2:case 9:if(Ed(f)){Ye=0,Zt=null,pp(n);break}n=function(){Ye!==2&&Ye!==9||Ke!==e||(Ye=7),Ln(e)},f.then(n,n);break e;case 3:Ye=7;break e;case 4:Ye=5;break e;case 7:Ed(f)?(Ye=0,Zt=null,pp(n)):(Ye=0,Zt=null,dr(e,n,f,7));break;case 5:var p=null;switch(Re.tag){case 26:p=Re.memoizedState;case 5:case 27:var b=Re;if(p?e0(p):b.stateNode.complete){Ye=0,Zt=null;var T=b.sibling;if(T!==null)Re=T;else{var L=b.return;L!==null?(Re=L,Wl(L)):Re=null}break t}}Ye=0,Zt=null,dr(e,n,f,5);break;case 6:Ye=0,Zt=null,dr(e,n,f,6);break;case 8:Du(),at=6;break e;default:throw Error(a(462))}}ox();break}catch(V){up(e,V)}while(!0);return es=gi=null,z.H=l,z.A=c,$e=r,Re!==null?0:(Ke=null,qe=0,bl(),at)}function ox(){for(;Re!==null&&!tl();)mp(Re)}function mp(e){var n=Bm(e.alternate,e,us);e.memoizedProps=e.pendingProps,n===null?Wl(e):Re=n}function pp(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=Mm(r,n,n.pendingProps,n.type,void 0,qe);break;case 11:n=Mm(r,n,n.pendingProps,n.type.render,n.ref,qe);break;case 5:Kc(n);default:Pm(r,n),n=Re=dd(n,us),n=Bm(r,n,us)}e.memoizedProps=e.pendingProps,n===null?Wl(e):Re=n}function dr(e,n,r,l){es=gi=null,Kc(n),nr=null,na=0;var c=n.return;try{if(Kb(e,c,n,r,qe)){at=1,Pl(e,dn(r,e.current)),Re=null;return}}catch(f){if(c!==null)throw Re=c,f;at=1,Pl(e,dn(r,e.current)),Re=null;return}n.flags&32768?(Ue||l===1?e=!0:cr||(qe&536870912)!==0?e=!1:(qs=e=!0,(l===2||l===9||l===3||l===6)&&(l=Kt.current,l!==null&&l.tag===13&&(l.flags|=16384))),gp(n,e)):Wl(n)}function Wl(e){var n=e;do{if((n.flags&32768)!==0){gp(n,qs);return}e=n.return;var r=Wb(n.alternate,n,us);if(r!==null){Re=r;return}if(n=n.sibling,n!==null){Re=n;return}Re=n=e}while(n!==null);at===0&&(at=5)}function gp(e,n){do{var r=ex(e.alternate,e);if(r!==null){r.flags&=32767,Re=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Re=e;return}Re=e=r}while(e!==null);at=6,Re=null}function yp(e,n,r,l,c,f,p,b,T){e.cancelPendingCommit=null;do eo();while(vt!==0);if(($e&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(f=n.lanes|n.childLanes,f|=Sc,_s(e,r,f,p,b,T),e===Ke&&(Re=Ke=null,qe=0),fr=n,Bs=e,fs=r,Cu=f,Mu=c,ap=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,hx(zi,function(){return wp(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=z.T,z.T=null,c=ne.p,ne.p=2,p=$e,$e|=4;try{tx(e,n,r)}finally{$e=p,ne.p=c,z.T=l}}vt=1,bp(),xp(),vp()}}function bp(){if(vt===1){vt=0;var e=Bs,n=fr,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=z.T,z.T=null;var l=ne.p;ne.p=2;var c=$e;$e|=4;try{Zm(n,e);var f=Fu,p=id(e.containerInfo),b=f.focusedElem,T=f.selectionRange;if(p!==b&&b&&b.ownerDocument&&sd(b.ownerDocument.documentElement,b)){if(T!==null&&bc(b)){var L=T.start,V=T.end;if(V===void 0&&(V=L),"selectionStart"in b)b.selectionStart=L,b.selectionEnd=Math.min(V,b.value.length);else{var W=b.ownerDocument||document,P=W&&W.defaultView||window;if(P.getSelection){var Y=P.getSelection(),me=b.textContent.length,xe=Math.min(T.start,me),Je=T.end===void 0?xe:Math.min(T.end,me);!Y.extend&&xe>Je&&(p=Je,Je=xe,xe=p);var q=nd(b,xe),C=nd(b,Je);if(q&&C&&(Y.rangeCount!==1||Y.anchorNode!==q.node||Y.anchorOffset!==q.offset||Y.focusNode!==C.node||Y.focusOffset!==C.offset)){var B=W.createRange();B.setStart(q.node,q.offset),Y.removeAllRanges(),xe>Je?(Y.addRange(B),Y.extend(C.node,C.offset)):(B.setEnd(C.node,C.offset),Y.addRange(B))}}}}for(W=[],Y=b;Y=Y.parentNode;)Y.nodeType===1&&W.push({element:Y,left:Y.scrollLeft,top:Y.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b<W.length;b++){var Q=W[b];Q.element.scrollLeft=Q.left,Q.element.scrollTop=Q.top}}ho=!!Iu,Fu=Iu=null}finally{$e=c,ne.p=l,z.T=r}}e.current=n,vt=2}}function xp(){if(vt===2){vt=0;var e=Bs,n=fr,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=z.T,z.T=null;var l=ne.p;ne.p=2;var c=$e;$e|=4;try{Fm(e,n.alternate,n)}finally{$e=c,ne.p=l,z.T=r}}vt=3}}function vp(){if(vt===4||vt===3){vt=0,qi();var e=Bs,n=fr,r=fs,l=ap;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?vt=5:(vt=0,fr=Bs=null,_p(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(Us=null),oi(r),n=n.stateNode,ot&&typeof ot.onCommitFiberRoot=="function")try{ot.onCommitFiberRoot(ii,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=z.T,c=ne.p,ne.p=2,z.T=null;try{for(var f=e.onRecoverableError,p=0;p<l.length;p++){var b=l[p];f(b.value,{componentStack:b.stack})}}finally{z.T=n,ne.p=c}}(fs&3)!==0&&eo(),Ln(e),c=e.pendingLanes,(r&261930)!==0&&(c&42)!==0?e===Ru?xa++:(xa=0,Ru=e):xa=0,va(0)}}function _p(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,ea(n)))}function eo(){return bp(),xp(),vp(),wp()}function wp(){if(vt!==5)return!1;var e=Bs,n=Cu;Cu=0;var r=oi(fs),l=z.T,c=ne.p;try{ne.p=32>r?32:r,z.T=null,r=Mu,Mu=null;var f=Bs,p=fs;if(vt=0,fr=Bs=null,fs=0,($e&6)!==0)throw Error(a(331));var b=$e;if($e|=4,sp(f.current),ep(f,f.current,p,r),$e=b,va(0,!1),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(ii,f)}catch{}return!0}finally{ne.p=c,z.T=l,_p(e,n)}}function Sp(e,n,r){n=dn(r,n),n=fu(e.stateNode,n,2),e=Cs(e,n,2),e!==null&&(jn(e,2),Ln(e))}function Ge(e,n,r){if(e.tag===3)Sp(e,e,r);else for(;n!==null;){if(n.tag===3){Sp(n,e,r);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Us===null||!Us.has(l))){e=dn(r,e),r=Em(2),l=Cs(n,r,2),l!==null&&(jm(r,l,n,e),jn(l,2),Ln(l));break}}n=n.return}}function zu(e,n,r){var l=e.pingCache;if(l===null){l=e.pingCache=new ix;var c=new Set;l.set(n,c)}else c=l.get(n),c===void 0&&(c=new Set,l.set(n,c));c.has(r)||(Nu=!0,c.add(r),e=cx.bind(null,e,n,r),n.then(e,e))}function cx(e,n,r){var l=e.pingCache;l!==null&&l.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,Ke===e&&(qe&r)===r&&(at===4||at===3&&(qe&62914560)===qe&&300>et()-Jl?($e&2)===0&&hr(e,0):Tu|=r,ur===qe&&(ur=0)),Ln(e)}function Ep(e,n){n===0&&(n=Bi()),e=di(e,n),e!==null&&(jn(e,n),Ln(e))}function ux(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),Ep(e,r)}function fx(e,n){var r=0;switch(e.tag){case 31:case 13:var l=e.stateNode,c=e.memoizedState;c!==null&&(r=c.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(a(314))}l!==null&&l.delete(n),Ep(e,r)}function hx(e,n){return Ur(e,n)}var to=null,mr=null,Uu=!1,no=!1,Bu=!1,Ps=0;function Ln(e){e!==mr&&e.next===null&&(mr===null?to=mr=e:mr=mr.next=e),no=!0,Uu||(Uu=!0,mx())}function va(e,n){if(!Bu&&no){Bu=!0;do for(var r=!1,l=to;l!==null;){if(e!==0){var c=l.pendingLanes;if(c===0)var f=0;else{var p=l.suspendedLanes,b=l.pingedLanes;f=(1<<31-Rt(42|e)+1)-1,f&=c&~(p&~b),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(r=!0,Np(l,f))}else f=qe,f=ri(l,l===Ke?f:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(f&3)===0||ai(l,f)||(r=!0,Np(l,f));l=l.next}while(r);Bu=!1}}function dx(){jp()}function jp(){no=Uu=!1;var e=0;Ps!==0&&Ex()&&(e=Ps);for(var n=et(),r=null,l=to;l!==null;){var c=l.next,f=Ap(l,n);f===0?(l.next=null,r===null?to=c:r.next=c,c===null&&(mr=r)):(r=l,(e!==0||(f&3)!==0)&&(no=!0)),l=c}vt!==0&&vt!==5||va(e),Ps!==0&&(Ps=0)}function Ap(e,n){for(var r=e.suspendedLanes,l=e.pingedLanes,c=e.expirationTimes,f=e.pendingLanes&-62914561;0<f;){var p=31-Rt(f),b=1<<p,T=c[p];T===-1?((b&r)===0||(b&l)!==0)&&(c[p]=Pr(b,n)):T<=n&&(e.expiredLanes|=b),f&=~b}if(n=Ke,r=qe,r=ri(e,e===n?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,r===0||e===n&&(Ye===2||Ye===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&In(l),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||ai(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(l!==null&&In(l),oi(r)){case 2:case 8:r=sl;break;case 32:r=zi;break;case 268435456:r=il;break;default:r=zi}return l=Op.bind(null,e),r=Ur(r,l),e.callbackPriority=n,e.callbackNode=r,n}return l!==null&&l!==null&&In(l),e.callbackPriority=2,e.callbackNode=null,2}function Op(e,n){if(vt!==0&&vt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(eo()&&e.callbackNode!==r)return null;var l=qe;return l=ri(e,e===Ke?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(op(e,l,n),Ap(e,et()),e.callbackNode!=null&&e.callbackNode===r?Op.bind(null,e):null)}function Np(e,n){if(eo())return null;op(e,n,!0)}function mx(){Ax(function(){($e&6)!==0?Ur(nl,dx):jp()})}function Lu(){if(Ps===0){var e=Wi;e===0&&(e=bs,bs<<=1,(bs&261888)===0&&(bs=256)),Ps=e}return Ps}function Tp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ul(""+e)}function kp(e,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,e.id&&r.setAttribute("form",e.id),n.parentNode.insertBefore(r,n),e=new FormData(e),r.parentNode.removeChild(r),e}function px(e,n,r,l,c){if(n==="submit"&&r&&r.stateNode===c){var f=Tp((c[it]||null).action),p=l.submitter;p&&(n=(n=p[it]||null)?Tp(n.formAction):p.getAttribute("formAction"),n!==null&&(f=n,p=null));var b=new ml("action","action",null,l,c);e.push({event:b,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ps!==0){var T=p?kp(c,p):new FormData(c);ru(r,{pending:!0,data:T,method:c.method,action:f},null,T)}}else typeof f=="function"&&(b.preventDefault(),T=p?kp(c,p):new FormData(c),ru(r,{pending:!0,data:T,method:c.method,action:f},f,T))},currentTarget:c}]})}}for(var Pu=0;Pu<wc.length;Pu++){var Hu=wc[Pu],gx=Hu.toLowerCase(),yx=Hu[0].toUpperCase()+Hu.slice(1);On(gx,"on"+yx)}On(ld,"onAnimationEnd"),On(od,"onAnimationIteration"),On(cd,"onAnimationStart"),On("dblclick","onDoubleClick"),On("focusin","onFocus"),On("focusout","onBlur"),On(Rb,"onTransitionRun"),On(Db,"onTransitionStart"),On(qb,"onTransitionCancel"),On(ud,"onTransitionEnd"),H("onMouseEnter",["mouseout","mouseover"]),H("onMouseLeave",["mouseout","mouseover"]),H("onPointerEnter",["pointerout","pointerover"]),H("onPointerLeave",["pointerout","pointerover"]),ee("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ee("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ee("onBeforeInput",["compositionend","keypress","textInput","paste"]),ee("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ee("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ee("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _a="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(" "),bx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(_a));function Cp(e,n){n=(n&4)!==0;for(var r=0;r<e.length;r++){var l=e[r],c=l.event;l=l.listeners;e:{var f=void 0;if(n)for(var p=l.length-1;0<=p;p--){var b=l[p],T=b.instance,L=b.currentTarget;if(b=b.listener,T!==f&&c.isPropagationStopped())break e;f=b,c.currentTarget=L;try{f(c)}catch(V){yl(V)}c.currentTarget=null,f=T}else for(p=0;p<l.length;p++){if(b=l[p],T=b.instance,L=b.currentTarget,b=b.listener,T!==f&&c.isPropagationStopped())break e;f=b,c.currentTarget=L;try{f(c)}catch(V){yl(V)}c.currentTarget=null,f=T}}}}function De(e,n){var r=n[ci];r===void 0&&(r=n[ci]=new Set);var l=e+"__bubble";r.has(l)||(Mp(n,e,2,!1),r.add(l))}function $u(e,n,r){var l=0;n&&(l|=4),Mp(r,e,l,n)}var so="_reactListening"+Math.random().toString(36).slice(2);function Yu(e){if(!e[so]){e[so]=!0,U.forEach(function(r){r!=="selectionchange"&&(bx.has(r)||$u(r,!1,e),$u(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[so]||(n[so]=!0,$u("selectionchange",!1,n))}}function Mp(e,n,r,l){switch(l0(n)){case 2:var c=Ix;break;case 8:c=Fx;break;default:c=rf}r=c.bind(null,n,r,e),c=void 0,!cc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(c=!0),l?c!==void 0?e.addEventListener(n,r,{capture:!0,passive:c}):e.addEventListener(n,r,!0):c!==void 0?e.addEventListener(n,r,{passive:c}):e.addEventListener(n,r,!1)}function Gu(e,n,r,l,c){var f=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var p=l.tag;if(p===3||p===4){var b=l.stateNode.containerInfo;if(b===c)break;if(p===4)for(p=l.return;p!==null;){var T=p.tag;if((T===3||T===4)&&p.stateNode.containerInfo===c)return;p=p.return}for(;b!==null;){if(p=x(b),p===null)return;if(T=p.tag,T===5||T===6||T===26||T===27){l=f=p;continue e}b=b.parentNode}}l=l.return}Uh(function(){var L=f,V=lc(r),W=[];e:{var P=fd.get(e);if(P!==void 0){var Y=ml,me=e;switch(e){case"keypress":if(hl(r)===0)break e;case"keydown":case"keyup":Y=fb;break;case"focusin":me="focus",Y=dc;break;case"focusout":me="blur",Y=dc;break;case"beforeblur":case"afterblur":Y=dc;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Y=Ph;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Y=Wy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Y=mb;break;case ld:case od:case cd:Y=nb;break;case ud:Y=gb;break;case"scroll":case"scrollend":Y=Xy;break;case"wheel":Y=bb;break;case"copy":case"cut":case"paste":Y=ib;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Y=$h;break;case"toggle":case"beforetoggle":Y=vb}var xe=(n&4)!==0,Je=!xe&&(e==="scroll"||e==="scrollend"),q=xe?P!==null?P+"Capture":null:P;xe=[];for(var C=L,B;C!==null;){var Q=C;if(B=Q.stateNode,Q=Q.tag,Q!==5&&Q!==26&&Q!==27||B===null||q===null||(Q=Yr(C,q),Q!=null&&xe.push(wa(C,Q,B))),Je)break;C=C.return}0<xe.length&&(P=new Y(P,me,null,r,V),W.push({event:P,listeners:xe}))}}if((n&7)===0){e:{if(P=e==="mouseover"||e==="pointerover",Y=e==="mouseout"||e==="pointerout",P&&r!==ac&&(me=r.relatedTarget||r.fromElement)&&(x(me)||me[Ft]))break e;if((Y||P)&&(P=V.window===V?V:(P=V.ownerDocument)?P.defaultView||P.parentWindow:window,Y?(me=r.relatedTarget||r.toElement,Y=L,me=me?x(me):null,me!==null&&(Je=u(me),xe=me.tag,me!==Je||xe!==5&&xe!==27&&xe!==6)&&(me=null)):(Y=null,me=L),Y!==me)){if(xe=Ph,Q="onMouseLeave",q="onMouseEnter",C="mouse",(e==="pointerout"||e==="pointerover")&&(xe=$h,Q="onPointerLeave",q="onPointerEnter",C="pointer"),Je=Y==null?P:w(Y),B=me==null?P:w(me),P=new xe(Q,C+"leave",Y,r,V),P.target=Je,P.relatedTarget=B,Q=null,x(V)===L&&(xe=new xe(q,C+"enter",me,r,V),xe.target=B,xe.relatedTarget=Je,Q=xe),Je=Q,Y&&me)t:{for(xe=xx,q=Y,C=me,B=0,Q=q;Q;Q=xe(Q))B++;Q=0;for(var ye=C;ye;ye=xe(ye))Q++;for(;0<B-Q;)q=xe(q),B--;for(;0<Q-B;)C=xe(C),Q--;for(;B--;){if(q===C||C!==null&&q===C.alternate){xe=q;break t}q=xe(q),C=xe(C)}xe=null}else xe=null;Y!==null&&Rp(W,P,Y,xe,!1),me!==null&&Je!==null&&Rp(W,Je,me,xe,!0)}}e:{if(P=L?w(L):window,Y=P.nodeName&&P.nodeName.toLowerCase(),Y==="select"||Y==="input"&&P.type==="file")var Pe=Kh;else if(Jh(P))if(Xh)Pe=kb;else{Pe=Nb;var pe=Ob}else Y=P.nodeName,!Y||Y.toLowerCase()!=="input"||P.type!=="checkbox"&&P.type!=="radio"?L&&rc(L.elementType)&&(Pe=Kh):Pe=Tb;if(Pe&&(Pe=Pe(e,L))){Qh(W,Pe,r,V);break e}pe&&pe(e,P,L),e==="focusout"&&L&&P.type==="number"&&L.memoizedProps.value!=null&&ic(P,"number",P.value)}switch(pe=L?w(L):window,e){case"focusin":(Jh(pe)||pe.contentEditable==="true")&&(Vi=pe,xc=L,Xr=null);break;case"focusout":Xr=xc=Vi=null;break;case"mousedown":vc=!0;break;case"contextmenu":case"mouseup":case"dragend":vc=!1,rd(W,r,V);break;case"selectionchange":if(Mb)break;case"keydown":case"keyup":rd(W,r,V)}var Ne;if(pc)e:{switch(e){case"compositionstart":var ze="onCompositionStart";break e;case"compositionend":ze="onCompositionEnd";break e;case"compositionupdate":ze="onCompositionUpdate";break e}ze=void 0}else Gi?Ih(e,r)&&(ze="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(ze="onCompositionStart");ze&&(Yh&&r.locale!=="ko"&&(Gi||ze!=="onCompositionStart"?ze==="onCompositionEnd"&&Gi&&(Ne=Bh()):(Es=V,uc="value"in Es?Es.value:Es.textContent,Gi=!0)),pe=io(L,ze),0<pe.length&&(ze=new Hh(ze,e,null,r,V),W.push({event:ze,listeners:pe}),Ne?ze.data=Ne:(Ne=Fh(r),Ne!==null&&(ze.data=Ne)))),(Ne=wb?Sb(e,r):Eb(e,r))&&(ze=io(L,"onBeforeInput"),0<ze.length&&(pe=new Hh("onBeforeInput","beforeinput",null,r,V),W.push({event:pe,listeners:ze}),pe.data=Ne)),px(W,e,L,r,V)}Cp(W,n)})}function wa(e,n,r){return{instance:e,listener:n,currentTarget:r}}function io(e,n){for(var r=n+"Capture",l=[];e!==null;){var c=e,f=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||f===null||(c=Yr(e,r),c!=null&&l.unshift(wa(e,c,f)),c=Yr(e,n),c!=null&&l.push(wa(e,c,f))),e.tag===3)return l;e=e.return}return[]}function xx(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Rp(e,n,r,l,c){for(var f=n._reactName,p=[];r!==null&&r!==l;){var b=r,T=b.alternate,L=b.stateNode;if(b=b.tag,T!==null&&T===l)break;b!==5&&b!==26&&b!==27||L===null||(T=L,c?(L=Yr(r,f),L!=null&&p.unshift(wa(r,L,T))):c||(L=Yr(r,f),L!=null&&p.push(wa(r,L,T)))),r=r.return}p.length!==0&&e.push({event:n,listeners:p})}var vx=/\r\n?/g,_x=/\u0000|\uFFFD/g;function Dp(e){return(typeof e=="string"?e:""+e).replace(vx,`
26
- `).replace(_x,"")}function qp(e,n){return n=Dp(n),Dp(e)===n}function Fe(e,n,r,l,c,f){switch(r){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||Hi(e,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&Hi(e,""+l);break;case"className":An(e,"class",l);break;case"tabIndex":An(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":An(e,r,l);break;case"style":qh(e,l,f);break;case"data":if(n!=="object"){An(e,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||r!=="href")){e.removeAttribute(r);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(r);break}l=ul(""+l),e.setAttribute(r,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(r,"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 f=="function"&&(r==="formAction"?(n!=="input"&&Fe(e,n,"name",c.name,c,null),Fe(e,n,"formEncType",c.formEncType,c,null),Fe(e,n,"formMethod",c.formMethod,c,null),Fe(e,n,"formTarget",c.formTarget,c,null)):(Fe(e,n,"encType",c.encType,c,null),Fe(e,n,"method",c.method,c,null),Fe(e,n,"target",c.target,c,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(r);break}l=ul(""+l),e.setAttribute(r,l);break;case"onClick":l!=null&&(e.onclick=Kn);break;case"onScroll":l!=null&&De("scroll",e);break;case"onScrollEnd":l!=null&&De("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(a(61));if(r=l.__html,r!=null){if(c.children!=null)throw Error(a(60));e.innerHTML=r}}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}r=ul(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);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(r,""+l):e.removeAttribute(r);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(r,""):e.removeAttribute(r);break;case"capture":case"download":l===!0?e.setAttribute(r,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(r,l):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(r,l):e.removeAttribute(r);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(r):e.setAttribute(r,l);break;case"popover":De("beforetoggle",e),De("toggle",e),Dt(e,"popover",l);break;case"xlinkActuate":Qn(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Qn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Qn(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Qn(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Qn(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Qn(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Qn(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Qn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Qn(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Dt(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=Qy.get(r)||r,Dt(e,r,l))}}function Vu(e,n,r,l,c,f){switch(r){case"style":qh(e,l,f);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(a(61));if(r=l.__html,r!=null){if(c.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"children":typeof l=="string"?Hi(e,l):(typeof l=="number"||typeof l=="bigint")&&Hi(e,""+l);break;case"onScroll":l!=null&&De("scroll",e);break;case"onScrollEnd":l!=null&&De("scrollend",e);break;case"onClick":l!=null&&(e.onclick=Kn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!X.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(c=r.endsWith("Capture"),n=r.slice(2,c?r.length-7:void 0),f=e[it]||null,f=f!=null?f[r]:null,typeof f=="function"&&e.removeEventListener(n,f,c),typeof l=="function")){typeof f!="function"&&f!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(n,l,c);break e}r in e?e[r]=l:l===!0?e.setAttribute(r,""):Dt(e,r,l)}}}function Nt(e,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":De("error",e),De("load",e);var l=!1,c=!1,f;for(f in r)if(r.hasOwnProperty(f)){var p=r[f];if(p!=null)switch(f){case"src":l=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:Fe(e,n,f,p,r,null)}}c&&Fe(e,n,"srcSet",r.srcSet,r,null),l&&Fe(e,n,"src",r.src,r,null);return;case"input":De("invalid",e);var b=f=p=c=null,T=null,L=null;for(l in r)if(r.hasOwnProperty(l)){var V=r[l];if(V!=null)switch(l){case"name":c=V;break;case"type":p=V;break;case"checked":T=V;break;case"defaultChecked":L=V;break;case"value":f=V;break;case"defaultValue":b=V;break;case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(a(137,n));break;default:Fe(e,n,l,V,r,null)}}Ch(e,f,b,T,L,p,c,!1);return;case"select":De("invalid",e),l=p=f=null;for(c in r)if(r.hasOwnProperty(c)&&(b=r[c],b!=null))switch(c){case"value":f=b;break;case"defaultValue":p=b;break;case"multiple":l=b;default:Fe(e,n,c,b,r,null)}n=f,r=p,e.multiple=!!l,n!=null?Pi(e,!!l,n,!1):r!=null&&Pi(e,!!l,r,!0);return;case"textarea":De("invalid",e),f=c=l=null;for(p in r)if(r.hasOwnProperty(p)&&(b=r[p],b!=null))switch(p){case"value":l=b;break;case"defaultValue":c=b;break;case"children":f=b;break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(a(91));break;default:Fe(e,n,p,b,r,null)}Rh(e,l,c,f);return;case"option":for(T in r)if(r.hasOwnProperty(T)&&(l=r[T],l!=null))switch(T){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Fe(e,n,T,l,r,null)}return;case"dialog":De("beforetoggle",e),De("toggle",e),De("cancel",e),De("close",e);break;case"iframe":case"object":De("load",e);break;case"video":case"audio":for(l=0;l<_a.length;l++)De(_a[l],e);break;case"image":De("error",e),De("load",e);break;case"details":De("toggle",e);break;case"embed":case"source":case"link":De("error",e),De("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(L in r)if(r.hasOwnProperty(L)&&(l=r[L],l!=null))switch(L){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:Fe(e,n,L,l,r,null)}return;default:if(rc(n)){for(V in r)r.hasOwnProperty(V)&&(l=r[V],l!==void 0&&Vu(e,n,V,l,r,void 0));return}}for(b in r)r.hasOwnProperty(b)&&(l=r[b],l!=null&&Fe(e,n,b,l,r,null))}function wx(e,n,r,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,f=null,p=null,b=null,T=null,L=null,V=null;for(Y in r){var W=r[Y];if(r.hasOwnProperty(Y)&&W!=null)switch(Y){case"checked":break;case"value":break;case"defaultValue":T=W;default:l.hasOwnProperty(Y)||Fe(e,n,Y,null,l,W)}}for(var P in l){var Y=l[P];if(W=r[P],l.hasOwnProperty(P)&&(Y!=null||W!=null))switch(P){case"type":f=Y;break;case"name":c=Y;break;case"checked":L=Y;break;case"defaultChecked":V=Y;break;case"value":p=Y;break;case"defaultValue":b=Y;break;case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(a(137,n));break;default:Y!==W&&Fe(e,n,P,Y,l,W)}}sc(e,p,b,T,L,V,f,c);return;case"select":Y=p=b=P=null;for(f in r)if(T=r[f],r.hasOwnProperty(f)&&T!=null)switch(f){case"value":break;case"multiple":Y=T;default:l.hasOwnProperty(f)||Fe(e,n,f,null,l,T)}for(c in l)if(f=l[c],T=r[c],l.hasOwnProperty(c)&&(f!=null||T!=null))switch(c){case"value":P=f;break;case"defaultValue":b=f;break;case"multiple":p=f;default:f!==T&&Fe(e,n,c,f,l,T)}n=b,r=p,l=Y,P!=null?Pi(e,!!r,P,!1):!!l!=!!r&&(n!=null?Pi(e,!!r,n,!0):Pi(e,!!r,r?[]:"",!1));return;case"textarea":Y=P=null;for(b in r)if(c=r[b],r.hasOwnProperty(b)&&c!=null&&!l.hasOwnProperty(b))switch(b){case"value":break;case"children":break;default:Fe(e,n,b,null,l,c)}for(p in l)if(c=l[p],f=r[p],l.hasOwnProperty(p)&&(c!=null||f!=null))switch(p){case"value":P=c;break;case"defaultValue":Y=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(a(91));break;default:c!==f&&Fe(e,n,p,c,l,f)}Mh(e,P,Y);return;case"option":for(var me in r)if(P=r[me],r.hasOwnProperty(me)&&P!=null&&!l.hasOwnProperty(me))switch(me){case"selected":e.selected=!1;break;default:Fe(e,n,me,null,l,P)}for(T in l)if(P=l[T],Y=r[T],l.hasOwnProperty(T)&&P!==Y&&(P!=null||Y!=null))switch(T){case"selected":e.selected=P&&typeof P!="function"&&typeof P!="symbol";break;default:Fe(e,n,T,P,l,Y)}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 xe in r)P=r[xe],r.hasOwnProperty(xe)&&P!=null&&!l.hasOwnProperty(xe)&&Fe(e,n,xe,null,l,P);for(L in l)if(P=l[L],Y=r[L],l.hasOwnProperty(L)&&P!==Y&&(P!=null||Y!=null))switch(L){case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(a(137,n));break;default:Fe(e,n,L,P,l,Y)}return;default:if(rc(n)){for(var Je in r)P=r[Je],r.hasOwnProperty(Je)&&P!==void 0&&!l.hasOwnProperty(Je)&&Vu(e,n,Je,void 0,l,P);for(V in l)P=l[V],Y=r[V],!l.hasOwnProperty(V)||P===Y||P===void 0&&Y===void 0||Vu(e,n,V,P,l,Y);return}}for(var q in r)P=r[q],r.hasOwnProperty(q)&&P!=null&&!l.hasOwnProperty(q)&&Fe(e,n,q,null,l,P);for(W in l)P=l[W],Y=r[W],!l.hasOwnProperty(W)||P===Y||P==null&&Y==null||Fe(e,n,W,P,l,Y)}function zp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sx(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,r=performance.getEntriesByType("resource"),l=0;l<r.length;l++){var c=r[l],f=c.transferSize,p=c.initiatorType,b=c.duration;if(f&&b&&zp(p)){for(p=0,b=c.responseEnd,l+=1;l<r.length;l++){var T=r[l],L=T.startTime;if(L>b)break;var V=T.transferSize,W=T.initiatorType;V&&zp(W)&&(T=T.responseEnd,p+=V*(T<b?1:(b-L)/(T-L)))}if(--l,n+=8*(f+p)/(c.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Iu=null,Fu=null;function ro(e){return e.nodeType===9?e:e.ownerDocument}function Up(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 Bp(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function Ju(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Qu=null;function Ex(){var e=window.event;return e&&e.type==="popstate"?e===Qu?!1:(Qu=e,!0):(Qu=null,!1)}var Lp=typeof setTimeout=="function"?setTimeout:void 0,jx=typeof clearTimeout=="function"?clearTimeout:void 0,Pp=typeof Promise=="function"?Promise:void 0,Ax=typeof queueMicrotask=="function"?queueMicrotask:typeof Pp<"u"?function(e){return Pp.resolve(null).then(e).catch(Ox)}:Lp;function Ox(e){setTimeout(function(){throw e})}function Hs(e){return e==="head"}function Hp(e,n){var r=n,l=0;do{var c=r.nextSibling;if(e.removeChild(r),c&&c.nodeType===8)if(r=c.data,r==="/$"||r==="/&"){if(l===0){e.removeChild(c),br(n);return}l--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")l++;else if(r==="html")Sa(e.ownerDocument.documentElement);else if(r==="head"){r=e.ownerDocument.head,Sa(r);for(var f=r.firstChild;f;){var p=f.nextSibling,b=f.nodeName;f[xt]||b==="SCRIPT"||b==="STYLE"||b==="LINK"&&f.rel.toLowerCase()==="stylesheet"||r.removeChild(f),f=p}}else r==="body"&&Sa(e.ownerDocument.body);r=c}while(r);br(n)}function $p(e,n){var r=e;e=0;do{var l=r.nextSibling;if(r.nodeType===1?n?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(n?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),l&&l.nodeType===8)if(r=l.data,r==="/$"){if(e===0)break;e--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||e++;r=l}while(r)}function Ku(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":Ku(r),Li(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function Nx(e,n,r,l){for(;e.nodeType===1;){var c=r;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[xt])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(f=e.getAttribute("rel"),f==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(f!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(f=e.getAttribute("src"),(f!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&f&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var f=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===f)return e}else return e;if(e=bn(e.nextSibling),e===null)break}return null}function Tx(e,n,r){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=bn(e.nextSibling),e===null))return null;return e}function Yp(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=bn(e.nextSibling),e===null))return null;return e}function Xu(e){return e.data==="$?"||e.data==="$~"}function Zu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function kx(e,n){var r=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||r.readyState!=="loading")n();else{var l=function(){n(),r.removeEventListener("DOMContentLoaded",l)};r.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function bn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var Wu=null;function Gp(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"||r==="/&"){if(n===0)return bn(e.nextSibling);n--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||n++}e=e.nextSibling}return null}function Vp(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(n===0)return e;n--}else r!=="/$"&&r!=="/&"||n++}e=e.previousSibling}return null}function Ip(e,n,r){switch(n=ro(r),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function Sa(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Li(e)}var xn=new Map,Fp=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var hs=ne.d;ne.d={f:Cx,r:Mx,D:Rx,C:Dx,L:qx,m:zx,X:Bx,S:Ux,M:Lx};function Cx(){var e=hs.f(),n=Xl();return e||n}function Mx(e){var n=S(e);n!==null&&n.tag===5&&n.type==="form"?um(n):hs.r(e)}var pr=typeof document>"u"?null:document;function Jp(e,n,r){var l=pr;if(l&&typeof n=="string"&&n){var c=fn(n);c='link[rel="'+e+'"][href="'+c+'"]',typeof r=="string"&&(c+='[crossorigin="'+r+'"]'),Fp.has(c)||(Fp.add(c),e={rel:e,crossOrigin:r,href:n},l.querySelector(c)===null&&(n=l.createElement("link"),Nt(n,"link",e),k(n),l.head.appendChild(n)))}}function Rx(e){hs.D(e),Jp("dns-prefetch",e,null)}function Dx(e,n){hs.C(e,n),Jp("preconnect",e,n)}function qx(e,n,r){hs.L(e,n,r);var l=pr;if(l&&e&&n){var c='link[rel="preload"][as="'+fn(n)+'"]';n==="image"&&r&&r.imageSrcSet?(c+='[imagesrcset="'+fn(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(c+='[imagesizes="'+fn(r.imageSizes)+'"]')):c+='[href="'+fn(e)+'"]';var f=c;switch(n){case"style":f=gr(e);break;case"script":f=yr(e)}xn.has(f)||(e=_({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:e,as:n},r),xn.set(f,e),l.querySelector(c)!==null||n==="style"&&l.querySelector(Ea(f))||n==="script"&&l.querySelector(ja(f))||(n=l.createElement("link"),Nt(n,"link",e),k(n),l.head.appendChild(n)))}}function zx(e,n){hs.m(e,n);var r=pr;if(r&&e){var l=n&&typeof n.as=="string"?n.as:"script",c='link[rel="modulepreload"][as="'+fn(l)+'"][href="'+fn(e)+'"]',f=c;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=yr(e)}if(!xn.has(f)&&(e=_({rel:"modulepreload",href:e},n),xn.set(f,e),r.querySelector(c)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(ja(f)))return}l=r.createElement("link"),Nt(l,"link",e),k(l),r.head.appendChild(l)}}}function Ux(e,n,r){hs.S(e,n,r);var l=pr;if(l&&e){var c=j(l).hoistableStyles,f=gr(e);n=n||"default";var p=c.get(f);if(!p){var b={loading:0,preload:null};if(p=l.querySelector(Ea(f)))b.loading=5;else{e=_({rel:"stylesheet",href:e,"data-precedence":n},r),(r=xn.get(f))&&ef(e,r);var T=p=l.createElement("link");k(T),Nt(T,"link",e),T._p=new Promise(function(L,V){T.onload=L,T.onerror=V}),T.addEventListener("load",function(){b.loading|=1}),T.addEventListener("error",function(){b.loading|=2}),b.loading|=4,lo(p,n,l)}p={type:"stylesheet",instance:p,count:1,state:b},c.set(f,p)}}}function Bx(e,n){hs.X(e,n);var r=pr;if(r&&e){var l=j(r).hoistableScripts,c=yr(e),f=l.get(c);f||(f=r.querySelector(ja(c)),f||(e=_({src:e,async:!0},n),(n=xn.get(c))&&tf(e,n),f=r.createElement("script"),k(f),Nt(f,"link",e),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},l.set(c,f))}}function Lx(e,n){hs.M(e,n);var r=pr;if(r&&e){var l=j(r).hoistableScripts,c=yr(e),f=l.get(c);f||(f=r.querySelector(ja(c)),f||(e=_({src:e,async:!0,type:"module"},n),(n=xn.get(c))&&tf(e,n),f=r.createElement("script"),k(f),Nt(f,"link",e),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},l.set(c,f))}}function Qp(e,n,r,l){var c=(c=on.current)?ao(c):null;if(!c)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=gr(r.href),r=j(c).hoistableStyles,l=r.get(n),l||(l={type:"style",instance:null,count:0,state:null},r.set(n,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=gr(r.href);var f=j(c).hoistableStyles,p=f.get(e);if(p||(c=c.ownerDocument||c,p={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(e,p),(f=c.querySelector(Ea(e)))&&!f._p&&(p.instance=f,p.state.loading=5),xn.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},xn.set(e,r),f||Px(c,e,r,p.state))),n&&l===null)throw Error(a(528,""));return p}if(n&&l!==null)throw Error(a(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=yr(r),r=j(c).hoistableScripts,l=r.get(n),l||(l={type:"script",instance:null,count:0,state:null},r.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function gr(e){return'href="'+fn(e)+'"'}function Ea(e){return'link[rel="stylesheet"]['+e+"]"}function Kp(e){return _({},e,{"data-precedence":e.precedence,precedence:null})}function Px(e,n,r,l){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=e.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),Nt(n,"link",r),k(n),e.head.appendChild(n))}function yr(e){return'[src="'+fn(e)+'"]'}function ja(e){return"script[async]"+e}function Xp(e,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var l=e.querySelector('style[data-href~="'+fn(r.href)+'"]');if(l)return n.instance=l,k(l),l;var c=_({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),k(l),Nt(l,"style",c),lo(l,r.precedence,e),n.instance=l;case"stylesheet":c=gr(r.href);var f=e.querySelector(Ea(c));if(f)return n.state.loading|=4,n.instance=f,k(f),f;l=Kp(r),(c=xn.get(c))&&ef(l,c),f=(e.ownerDocument||e).createElement("link"),k(f);var p=f;return p._p=new Promise(function(b,T){p.onload=b,p.onerror=T}),Nt(f,"link",l),n.state.loading|=4,lo(f,r.precedence,e),n.instance=f;case"script":return f=yr(r.src),(c=e.querySelector(ja(f)))?(n.instance=c,k(c),c):(l=r,(c=xn.get(f))&&(l=_({},r),tf(l,c)),e=e.ownerDocument||e,c=e.createElement("script"),k(c),Nt(c,"link",l),e.head.appendChild(c),n.instance=c);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,lo(l,r.precedence,e));return n.instance}function lo(e,n,r){for(var l=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=l.length?l[l.length-1]:null,f=c,p=0;p<l.length;p++){var b=l[p];if(b.dataset.precedence===n)f=b;else if(f!==c)break}f?f.parentNode.insertBefore(e,f.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(e,n.firstChild))}function ef(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function tf(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var oo=null;function Zp(e,n,r){if(oo===null){var l=new Map,c=oo=new Map;c.set(r,l)}else c=oo,l=c.get(r),l||(l=new Map,c.set(r,l));if(l.has(e))return l;for(l.set(e,null),r=r.getElementsByTagName(e),c=0;c<r.length;c++){var f=r[c];if(!(f[xt]||f[Qe]||e==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var p=f.getAttribute(n)||"";p=e+p;var b=l.get(p);b?b.push(f):l.set(p,[f])}}return l}function Wp(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function Hx(e,n,r){if(r===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function e0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function $x(e,n,r,l){if(r.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var c=gr(l.href),f=n.querySelector(Ea(c));if(f){n=f._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=co.bind(e),n.then(e,e)),r.state.loading|=4,r.instance=f,k(f);return}f=n.ownerDocument||n,l=Kp(l),(c=xn.get(c))&&ef(l,c),f=f.createElement("link"),k(f);var p=f;p._p=new Promise(function(b,T){p.onload=b,p.onerror=T}),Nt(f,"link",l),r.instance=f}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(r,n),(n=r.state.preload)&&(r.state.loading&3)===0&&(e.count++,r=co.bind(e),n.addEventListener("load",r),n.addEventListener("error",r))}}var nf=0;function Yx(e,n){return e.stylesheets&&e.count===0&&fo(e,e.stylesheets),0<e.count||0<e.imgCount?function(r){var l=setTimeout(function(){if(e.stylesheets&&fo(e,e.stylesheets),e.unsuspend){var f=e.unsuspend;e.unsuspend=null,f()}},6e4+n);0<e.imgBytes&&nf===0&&(nf=62500*Sx());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&fo(e,e.stylesheets),e.unsuspend)){var f=e.unsuspend;e.unsuspend=null,f()}},(e.imgBytes>nf?50:800)+n);return e.unsuspend=r,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(c)}}:null}function co(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var uo=null;function fo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,uo=new Map,n.forEach(Gx,e),uo=null,co.call(e))}function Gx(e,n){if(!(n.state.loading&4)){var r=uo.get(e);if(r)var l=r.get(null);else{r=new Map,uo.set(e,r);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<c.length;f++){var p=c[f];(p.nodeName==="LINK"||p.getAttribute("media")!=="not all")&&(r.set(p.dataset.precedence,p),l=p)}l&&r.set(null,l)}c=n.instance,p=c.getAttribute("data-precedence"),f=r.get(p)||l,f===l&&r.set(null,c),r.set(p,c),this.count++,l=co.bind(this),c.addEventListener("load",l),c.addEventListener("error",l),f?f.parentNode.insertBefore(c,f.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),n.state.loading|=4}}var Aa={$$typeof:ce,Provider:null,Consumer:null,_currentValue:se,_currentValue2:se,_threadCount:0};function Vx(e,n,r,l,c,f,p,b,T){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=vs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vs(0),this.hiddenUpdates=vs(null),this.identifierPrefix=l,this.onUncaughtError=c,this.onCaughtError=f,this.onRecoverableError=p,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=T,this.incompleteTransitions=new Map}function t0(e,n,r,l,c,f,p,b,T,L,V,W){return e=new Vx(e,n,r,p,T,L,V,W,b),n=1,f===!0&&(n|=24),f=Qt(3,null,null,n),e.current=f,f.stateNode=e,n=qc(),n.refCount++,e.pooledCache=n,n.refCount++,f.memoizedState={element:l,isDehydrated:r,cache:n},Lc(f),e}function n0(e){return e?(e=Ji,e):Ji}function s0(e,n,r,l,c,f){c=n0(c),l.context===null?l.context=c:l.pendingContext=c,l=ks(n),l.payload={element:r},f=f===void 0?null:f,f!==null&&(l.callback=f),r=Cs(e,l,n),r!==null&&(Gt(r,e,n),ia(r,e,n))}function i0(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function sf(e,n){i0(e,n),(e=e.alternate)&&i0(e,n)}function r0(e){if(e.tag===13||e.tag===31){var n=di(e,67108864);n!==null&&Gt(n,e,67108864),sf(e,67108864)}}function a0(e){if(e.tag===13||e.tag===31){var n=en();n=Jn(n);var r=di(e,n);r!==null&&Gt(r,e,n),sf(e,n)}}var ho=!0;function Ix(e,n,r,l){var c=z.T;z.T=null;var f=ne.p;try{ne.p=2,rf(e,n,r,l)}finally{ne.p=f,z.T=c}}function Fx(e,n,r,l){var c=z.T;z.T=null;var f=ne.p;try{ne.p=8,rf(e,n,r,l)}finally{ne.p=f,z.T=c}}function rf(e,n,r,l){if(ho){var c=af(l);if(c===null)Gu(e,n,l,mo,r),o0(e,l);else if(Qx(c,e,n,r,l))l.stopPropagation();else if(o0(e,l),n&4&&-1<Jx.indexOf(e)){for(;c!==null;){var f=S(c);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var p=En(f.pendingLanes);if(p!==0){var b=f;for(b.pendingLanes|=2,b.entangledLanes|=2;p;){var T=1<<31-Rt(p);b.entanglements[1]|=T,p&=~T}Ln(f),($e&6)===0&&(Ql=et()+500,va(0))}}break;case 31:case 13:b=di(f,2),b!==null&&Gt(b,f,2),Xl(),sf(f,2)}if(f=af(l),f===null&&Gu(e,n,l,mo,r),f===c)break;c=f}c!==null&&l.stopPropagation()}else Gu(e,n,l,null,r)}}function af(e){return e=lc(e),lf(e)}var mo=null;function lf(e){if(mo=null,e=x(e),e!==null){var n=u(e);if(n===null)e=null;else{var r=n.tag;if(r===13){if(e=d(n),e!==null)return e;e=null}else if(r===31){if(e=m(n),e!==null)return e;e=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return mo=e,null}function l0(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(Wo()){case nl:return 2;case sl:return 8;case zi:case ec:return 32;case il:return 268435456;default:return 32}default:return 32}}var of=!1,$s=null,Ys=null,Gs=null,Oa=new Map,Na=new Map,Vs=[],Jx="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 o0(e,n){switch(e){case"focusin":case"focusout":$s=null;break;case"dragenter":case"dragleave":Ys=null;break;case"mouseover":case"mouseout":Gs=null;break;case"pointerover":case"pointerout":Oa.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Na.delete(n.pointerId)}}function Ta(e,n,r,l,c,f){return e===null||e.nativeEvent!==f?(e={blockedOn:n,domEventName:r,eventSystemFlags:l,nativeEvent:f,targetContainers:[c]},n!==null&&(n=S(n),n!==null&&r0(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,c!==null&&n.indexOf(c)===-1&&n.push(c),e)}function Qx(e,n,r,l,c){switch(n){case"focusin":return $s=Ta($s,e,n,r,l,c),!0;case"dragenter":return Ys=Ta(Ys,e,n,r,l,c),!0;case"mouseover":return Gs=Ta(Gs,e,n,r,l,c),!0;case"pointerover":var f=c.pointerId;return Oa.set(f,Ta(Oa.get(f)||null,e,n,r,l,c)),!0;case"gotpointercapture":return f=c.pointerId,Na.set(f,Ta(Na.get(f)||null,e,n,r,l,c)),!0}return!1}function c0(e){var n=x(e.target);if(n!==null){var r=u(n);if(r!==null){if(n=r.tag,n===13){if(n=d(r),n!==null){e.blockedOn=n,al(e.priority,function(){a0(r)});return}}else if(n===31){if(n=m(r),n!==null){e.blockedOn=n,al(e.priority,function(){a0(r)});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function po(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=af(e.nativeEvent);if(r===null){r=e.nativeEvent;var l=new r.constructor(r.type,r);ac=l,r.target.dispatchEvent(l),ac=null}else return n=S(r),n!==null&&r0(n),e.blockedOn=r,!1;n.shift()}return!0}function u0(e,n,r){po(e)&&r.delete(n)}function Kx(){of=!1,$s!==null&&po($s)&&($s=null),Ys!==null&&po(Ys)&&(Ys=null),Gs!==null&&po(Gs)&&(Gs=null),Oa.forEach(u0),Na.forEach(u0)}function go(e,n){e.blockedOn===n&&(e.blockedOn=null,of||(of=!0,i.unstable_scheduleCallback(i.unstable_NormalPriority,Kx)))}var yo=null;function f0(e){yo!==e&&(yo=e,i.unstable_scheduleCallback(i.unstable_NormalPriority,function(){yo===e&&(yo=null);for(var n=0;n<e.length;n+=3){var r=e[n],l=e[n+1],c=e[n+2];if(typeof l!="function"){if(lf(l||r)===null)continue;break}var f=S(r);f!==null&&(e.splice(n,3),n-=3,ru(f,{pending:!0,data:c,method:r.method,action:l},l,c))}}))}function br(e){function n(T){return go(T,e)}$s!==null&&go($s,e),Ys!==null&&go(Ys,e),Gs!==null&&go(Gs,e),Oa.forEach(n),Na.forEach(n);for(var r=0;r<Vs.length;r++){var l=Vs[r];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Vs.length&&(r=Vs[0],r.blockedOn===null);)c0(r),r.blockedOn===null&&Vs.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(l=0;l<r.length;l+=3){var c=r[l],f=r[l+1],p=c[it]||null;if(typeof f=="function")p||f0(r);else if(p){var b=null;if(f&&f.hasAttribute("formAction")){if(c=f,p=f[it]||null)b=p.formAction;else if(lf(c)!==null)continue}else b=p.action;typeof b=="function"?r[l+1]=b:(r.splice(l,3),l-=3),f0(r)}}}function h0(){function e(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(p){return c=p})},focusReset:"manual",scroll:"manual"})}function n(){c!==null&&(c(),c=null),l||setTimeout(r,20)}function r(){if(!l&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(r,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),c!==null&&(c(),c=null)}}}function cf(e){this._internalRoot=e}bo.prototype.render=cf.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,l=en();s0(r,l,e,n,null,null)},bo.prototype.unmount=cf.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;s0(e.current,2,null,e,null,null),Xl(),n[Ft]=null}};function bo(e){this._internalRoot=e}bo.prototype.unstable_scheduleHydration=function(e){if(e){var n=Hr();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Vs.length&&n!==0&&n<Vs[r].priority;r++);Vs.splice(r,0,e),r===0&&c0(e)}};var d0=t.version;if(d0!=="19.2.4")throw Error(a(527,d0,"19.2.4"));ne.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=y(n),e=e!==null?E(e):null,e=e===null?null:e.stateNode,e};var Xx={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var xo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xo.isDisabled&&xo.supportsFiber)try{ii=xo.inject(Xx),ot=xo}catch{}}return ka.createRoot=function(e,n){if(!o(e))throw Error(a(299));var r=!1,l="",c=vm,f=_m,p=wm;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(c=n.onUncaughtError),n.onCaughtError!==void 0&&(f=n.onCaughtError),n.onRecoverableError!==void 0&&(p=n.onRecoverableError)),n=t0(e,1,!1,null,null,r,l,null,c,f,p,h0),e[Ft]=n.current,Yu(e),new cf(n)},ka.hydrateRoot=function(e,n,r){if(!o(e))throw Error(a(299));var l=!1,c="",f=vm,p=_m,b=wm,T=null;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(p=r.onCaughtError),r.onRecoverableError!==void 0&&(b=r.onRecoverableError),r.formState!==void 0&&(T=r.formState)),n=t0(e,1,!0,n,r??null,l,c,T,f,p,b,h0),n.context=n0(null),r=n.current,l=en(),l=Jn(l),c=ks(l),c.callback=null,Cs(r,c,l),r=l,n.current.lanes=r,jn(n,r),Ln(n),e[Ft]=n.current,Yu(e),new bo(n)},ka.version="19.2.4",ka}var _0;function Bv(){if(_0)return uf.exports;_0=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),uf.exports=Uv(),uf.exports}var Lv=Bv();const Pv="modulepreload",Hv=function(i,t){return new URL(i,t).href},w0={},_e=function(t,s,a){let o=Promise.resolve();if(s&&s.length>0){let d=function(E){return Promise.all(E.map(_=>Promise.resolve(_).then(N=>({status:"fulfilled",value:N}),N=>({status:"rejected",reason:N}))))};const m=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=d(s.map(E=>{if(E=Hv(E,a),E in w0)return;w0[E]=!0;const _=E.endsWith(".css"),N=_?'[rel="stylesheet"]':"";if(!!a)for(let D=m.length-1;D>=0;D--){const G=m[D];if(G.href===E&&(!_||G.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${E}"]${N}`))return;const M=document.createElement("link");if(M.rel=_?"stylesheet":Pv,_||(M.as="script"),M.crossOrigin="",M.href=E,y&&M.setAttribute("nonce",y),document.head.appendChild(M),_)return new Promise((D,G)=>{M.addEventListener("load",D),M.addEventListener("error",()=>G(new Error(`Unable to preload CSS for ${E}`)))})}))}function u(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return o.then(d=>{for(const m of d||[])m.status==="rejected"&&u(m.reason);return t().catch(u)})};function ih(i){try{const t=i.split(".");if(t.length!==3)return null;const s=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function Mg(i){const t=ih(i);return!t||typeof t.exp!="number"?null:t.exp}function rh(i,t=0){const s=Mg(i);return s===null?!0:Date.now()/1e3>=s-t}const Tt=window.__LT_BASE__??"",kf=`${Tt}/api`;class $v extends Error{constructor(t,s,a){super(t),this.status=s,this.body=a,this.name="ApiError"}}let Qs=null;function vo(i){Qs=i}function Rg(){return Qs}async function S0(){const i=sessionStorage.getItem("lt_credentials");if(!i)return null;try{const{username:t,password:s}=JSON.parse(i),a=await fetch(`${kf}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})});if(!a.ok)return null;const o=await a.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 Fs=null;async function we(i,t={}){const s={"Content-Type":"application/json",...t.headers};if(Qs){if(rh(Qs)){Fs||(Fs=S0().finally(()=>{Fs=null}));const o=await Fs;if(o)Qs=o,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:o}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${Qs}`}let a=await fetch(`${kf}${i}`,{...t,headers:s});if(a.status===401&&Qs){Fs||(Fs=S0().finally(()=>{Fs=null}));const o=await Fs;if(o&&(Qs=o,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:o}})),s.Authorization=`Bearer ${o}`,a=await fetch(`${kf}${i}`,{...t,headers:s})),a.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(a.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!a.ok){const o=await a.json().catch(()=>({error:a.statusText}));throw new $v(o.message||o.error||a.statusText,a.status,o)}return a.json()}const Dg=A.createContext(null),Yv=300;function df(i,t){if(rh(i))return null;const s=ih(i);if(!s)return null;const a=t??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(a==null?void 0:a.displayName)??null,username:(a==null?void 0:a.username)??null,roles:s.roles??[]}}function Gv({children:i}){const[t,s]=A.useState(()=>{const _=sessionStorage.getItem("lt_token");return _?rh(_)?(sessionStorage.removeItem("lt_token"),null):(vo(_),df(_)):null}),a=A.useRef(void 0),o=A.useCallback(_=>{clearTimeout(a.current);const N=Mg(_);if(!N)return;const R=(N-Yv)*1e3-Date.now();R<=0||(a.current=setTimeout(async()=>{try{const M=ih(_);if(M!=null&&M.sso){const oe=await fetch(`${Tt}/api/auth/sso`,{method:"POST"});if(!oe.ok)return;const O=await oe.json();O.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:O.token}}));return}const D=sessionStorage.getItem("lt_credentials");if(!D)return;const{username:G,password:te}=JSON.parse(D),$=await fetch(`${Tt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:G,password:te})});if(!$.ok)return;const ce=await $.json();ce.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:ce.token}}))}catch{}},R))},[]),u=A.useCallback((_,N,R)=>{const M={displayName:(R==null?void 0:R.displayName)??null,username:(R==null?void 0:R.username)??(N==null?void 0:N.username)??null},D=df(_,M);D&&(vo(_),sessionStorage.setItem("lt_token",_),sessionStorage.setItem("lt_user_info",JSON.stringify(M)),N&&sessionStorage.setItem("lt_credentials",JSON.stringify(N)),s(D),o(_))},[o]),d=A.useCallback(()=>{clearTimeout(a.current);const _=sessionStorage.getItem("lt_sso_logout_url");vo(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),_&&(window.location.href=_)},[]);A.useEffect(()=>{const _=()=>d(),N=R=>{var G;const M=(G=R.detail)==null?void 0:G.token;if(!M)return;const D=df(M);D&&(vo(M),sessionStorage.setItem("lt_token",M),s(D),o(M))};return window.addEventListener("auth:unauthorized",_),window.addEventListener("auth:refreshed",N),()=>{window.removeEventListener("auth:unauthorized",_),window.removeEventListener("auth:refreshed",N)}},[d,o]),A.useEffect(()=>{const _=sessionStorage.getItem("lt_token");return _&&t&&o(_),()=>clearTimeout(a.current)},[]);const m=(t==null?void 0:t.roles.some(_=>_.type==="superadmin"))??!1,g=A.useCallback(_=>(t==null?void 0:t.roles.some(N=>N.role===_))??!1,[t]),y=A.useCallback(_=>(t==null?void 0:t.roles.some(N=>N.type===_))??!1,[t]),E=(t==null?void 0:t.roles.map(_=>_.role))??[];return h.jsx(Dg.Provider,{value:{user:t,isAuthenticated:!!t,isSuperAdmin:m,login:u,logout:d,hasRole:g,hasRoleType:y,userRoleNames:E},children:i})}function Dn(){const i=A.useContext(Dg);if(!i)throw new Error("useAuth must be used within AuthProvider");return i}const an=new Uint8Array(0),Ci=new TextEncoder,sn=new TextDecoder;function Vv(...i){let t=0;for(let o=0;o<i.length;o++)t+=i[o].length;const s=new Uint8Array(t);let a=0;for(let o=0;o<i.length;o++)s.set(i[o],a),a+=i[o].length;return s}function Pa(...i){const t=[];for(let s=0;s<i.length;s++)t.push(Ci.encode(i[s]));return t.length===0?an:t.length===1?t[0]:Vv(...t)}function E0(i){return!i||i.length===0?"":sn.decode(i)}const j0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",A0=36,Iv=0xcfd41b9100000,O0=33,Fv=333,N0=22;function Jv(i){for(let t=0;t<i.length;t++)i[t]=Math.floor(Math.random()*255)}function Qv(i){var t;(t=globalThis==null?void 0:globalThis.crypto)!=null&&t.getRandomValues?globalThis.crypto.getRandomValues(i):Jv(i)}class Kv{constructor(){v(this,"buf");v(this,"seq");v(this,"inc");v(this,"inited");this.buf=new Uint8Array(N0),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*Iv),this.inc=Math.floor(Math.random()*(Fv-O0)+O0)}setPre(){const t=new Uint8Array(12);Qv(t);for(let s=0;s<12;s++){const a=t[s]%36;this.buf[s]=j0.charCodeAt(a)}}fillSeq(){let t=this.seq;for(let s=N0-1;s>=12;s--)this.buf[s]=j0.charCodeAt(t%A0),t=Math.floor(t/A0)}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 ei=new Kv;var ds;(function(i){i.Disconnect="disconnect",i.Reconnect="reconnect",i.Update="update",i.LDM="ldm",i.Error="error"})(ds||(ds={}));var Er;(function(i){i.Reconnecting="reconnecting",i.PingTimer="pingTimer",i.StaleConnection="staleConnection",i.ClientInitiatedReconnect="client initiated reconnect"})(Er||(Er={}));var le;(function(i){i.ApiError="BAD API",i.BadAuthentication="BAD_AUTHENTICATION",i.BadCreds="BAD_CREDS",i.BadHeader="BAD_HEADER",i.BadJson="BAD_JSON",i.BadPayload="BAD_PAYLOAD",i.BadSubject="BAD_SUBJECT",i.Cancelled="CANCELLED",i.ConnectionClosed="CONNECTION_CLOSED",i.ConnectionDraining="CONNECTION_DRAINING",i.ConnectionRefused="CONNECTION_REFUSED",i.ConnectionTimeout="CONNECTION_TIMEOUT",i.Disconnect="DISCONNECT",i.InvalidOption="INVALID_OPTION",i.InvalidPayload="INVALID_PAYLOAD",i.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",i.NoResponders="503",i.NotFunction="NOT_FUNC",i.RequestError="REQUEST_ERROR",i.ServerOptionNotAvailable="SERVER_OPT_NA",i.SubClosed="SUB_CLOSED",i.SubDraining="SUB_DRAINING",i.Timeout="TIMEOUT",i.Tls="TLS",i.Unknown="UNKNOWN_ERROR",i.WssRequired="WSS_REQUIRED",i.JetStreamInvalidAck="JESTREAM_INVALID_ACK",i.JetStream404NoMessages="404",i.JetStream408RequestTimeout="408",i.JetStream409MaxAckPendingExceeded="409",i.JetStream409="409",i.JetStreamNotEnabled="503",i.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",i.AuthorizationViolation="AUTHORIZATION_VIOLATION",i.AuthenticationExpired="AUTHENTICATION_EXPIRED",i.ProtocolError="NATS_PROTOCOL_ERR",i.PermissionsViolation="PERMISSIONS_VIOLATION",i.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",i.AccountExpired="ACCOUNT_EXPIRED"})(le||(le={}));function Xv(i){return typeof i.code=="string"}class qg{constructor(){v(this,"messages");this.messages=new Map,this.messages.set(le.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(le.BadJson,"Bad JSON"),this.messages.set(le.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(t){return Zv.getMessage(t)}getMessage(t){return this.messages.get(t)||t}}const Zv=new qg;class he extends Error{constructor(s,a,o){super(s);v(this,"name");v(this,"message");v(this,"code");v(this,"permissionContext");v(this,"chainedError");v(this,"api_error");this.name="NatsError",this.message=s,this.code=a,this.chainedError=o}static errorForCode(s,a){const o=qg.getMessage(s);return new he(o,s,a)}isAuthError(){return this.code===le.AuthenticationExpired||this.code===le.AuthorizationViolation||this.code===le.AccountExpired}isAuthTimeout(){return this.code===le.AuthenticationTimeout}isPermissionError(){return this.code===le.PermissionsViolation}isProtocolError(){return this.code===le.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var tn;(function(i){i[i.Exact=0]="Exact",i[i.CanonicalMIME=1]="CanonicalMIME",i[i.IgnoreCase=2]="IgnoreCase"})(tn||(tn={}));var Mn;(function(i){i.Timer="timer",i.Count="count",i.JitterTimer="jitterTimer",i.SentinelMsg="sentinelMsg"})(Mn||(Mn={}));var Ha;(function(i){i.STATS="io.nats.micro.v1.stats_response",i.INFO="io.nats.micro.v1.info_response",i.PING="io.nats.micro.v1.ping_response"})(Ha||(Ha={}));const qo="Nats-Service-Error",zo="Nats-Service-Error-Code";class Uo extends Error{constructor(s,a){super(a);v(this,"code");this.code=s}static isServiceError(s){return Uo.toServiceError(s)!==null}static toServiceError(s){var o,u;const a=((o=s==null?void 0:s.headers)==null?void 0:o.get(zo))||"";if(a!==""){const d=parseInt(a)||400,m=((u=s==null?void 0:s.headers)==null?void 0:u.get(qo))||"";return new Uo(d,m.length?m:a)}return null}}function ms(i=""){if(i=i||"_INBOX",typeof i!="string")throw new Error("prefix must be a string");return i.split(".").forEach(t=>{if(t==="*"||t===">")throw new Error(`inbox prefixes cannot have wildcards '${i}'`)}),`${i}.${ei.next()}`}const Cf="127.0.0.1";var Ks;(function(i){i.PING="PING",i.STATS="STATS",i.INFO="INFO"})(Ks||(Ks={}));function Fo(i,...t){for(let s=0;s<t.length;s++){const a=t[s];Object.keys(a).forEach(function(o){i[o]=a[o]})}return i}function _o(i){return sn.decode(i).replace(/\n/g,"␊").replace(/\r/g,"␍")}function kr(i,t=!0){const s=t?he.errorForCode(le.Timeout):null;let a,o;const u=new Promise((d,m)=>{a={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{m(s===null?he.errorForCode(le.Timeout):s)},i)});return Object.assign(u,a)}function Rr(i=0){let t;const s=new Promise(a=>{const o=setTimeout(()=>{a()},i);t={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,t)}function st(){let i={};const t=new Promise((s,a)=>{i={resolve:s,reject:a}});return Object.assign(t,i)}function zg(i){for(let t=i.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[i[t],i[s]]=[i[s],i[t]]}return i}function Wv(i){return i===0?0:Math.floor(i/2+Math.random()*i)}function ah(i=[0,250,250,500,500,3e3,5e3]){Array.isArray(i)||(i=[0,250,250,500,500,3e3,5e3]);const t=i.length-1;return{backoff(s){return Wv(s>t?i[t]:i[s])}}}function nt(i){return i*1e6}function lh(i){return Math.floor(i/1e6)}function T0(i){let a=!0;const o=new Array(i.length);for(let u=0;u<i.length;u++){let d=i.charCodeAt(u);if(d===58||d<33||d>126)throw new he(`'${i[u]}' is not a valid character for a header key`,le.BadHeader);a&&97<=d&&d<=122?d-=32:!a&&65<=d&&d<=90&&(d+=32),o[u]=d,a=d==45}return String.fromCharCode(...o)}function ps(i=0,t=""){if(i===0&&t!==""||i>0&&t==="")throw new Error("setting status requires both code and description");return new Xs(i,t)}const mf="NATS/1.0";class Xs{constructor(t=0,s=""){v(this,"_code");v(this,"headers");v(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,a]of this.headers){const o=t.values(s);if(a.length!==o.length)return!1;const u=[...a].sort(),d=[...o].sort();for(let m=0;m<u.length;m++)if(u[m]!==d[m])return!1}return!0}return!1}static decode(t){const s=new Xs,o=sn.decode(t).split(`\r
27
- `),u=o[0];if(u!==mf){let d=u.replace(mf,"").trim();if(d.length>0){s._code=parseInt(d,10),isNaN(s._code)&&(s._code=0);const m=s._code.toString();d=d.replace(m,""),s._description=d.trim()}}return o.length>=1&&o.slice(1).map(d=>{if(d){const m=d.indexOf(":");if(m>-1){const g=d.slice(0,m),y=d.slice(m+1).trim();s.append(g,y)}}}),s}toString(){if(this.headers.size===0&&this._code===0)return"";let t=mf;this._code>0&&this._description!==""&&(t+=` ${this._code} ${this._description}`);for(const[s,a]of this.headers)for(let o=0;o<a.length;o++)t=`${t}\r
25
+ `+l.stack}}var zr=Object.prototype.hasOwnProperty,Ur=i.unstable_scheduleCallback,In=i.unstable_cancelCallback,el=i.unstable_shouldYield,qi=i.unstable_requestPaint,et=i.unstable_now,ec=i.unstable_getCurrentPriorityLevel,tl=i.unstable_ImmediatePriority,nl=i.unstable_UserBlockingPriority,zi=i.unstable_NormalPriority,tc=i.unstable_LowPriority,sl=i.unstable_IdlePriority,nc=i.log,il=i.unstable_setDisableYieldValue,ai=null,ot=null;function It(e){if(typeof nc=="function"&&il(e),ot&&typeof ot.setStrictMode=="function")try{ot.setStrictMode(ai,e)}catch{}}var Rt=Math.clz32?Math.clz32:Ui,Br=Math.log,Lr=Math.LN2;function Ui(e){return e>>>=0,e===0?32:31-(Br(e)/Lr|0)|0}var bs=256,Fn=262144,xs=4194304;function jn(e){var n=e&42;if(n!==0)return n;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 li(e,n,r){var l=e.pendingLanes;if(l===0)return 0;var c=0,f=e.suspendedLanes,p=e.pingedLanes;e=e.warmLanes;var b=l&134217727;return b!==0?(l=b&~f,l!==0?c=jn(l):(p&=b,p!==0?c=jn(p):r||(r=b&~e,r!==0&&(c=jn(r))))):(b=l&~f,b!==0?c=jn(b):p!==0?c=jn(p):r||(r=l&~e,r!==0&&(c=jn(r)))),c===0?0:n!==0&&n!==c&&(n&f)===0&&(f=c&-c,r=n&-n,f>=r||f===32&&(r&4194048)!==0)?n:c}function oi(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Pr(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 Bi(){var e=xs;return xs<<=1,(xs&62914560)===0&&(xs=4194304),e}function vs(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function An(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function _s(e,n,r,l,c,f){var p=e.pendingLanes;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=r,e.entangledLanes&=r,e.errorRecoveryDisabledLanes&=r,e.shellSuspendCounter=0;var b=e.entanglements,N=e.expirationTimes,L=e.hiddenUpdates;for(r=p&~r;0<r;){var V=31-Rt(r),W=1<<V;b[V]=0,N[V]=-1;var P=L[V];if(P!==null)for(L[V]=null,V=0;V<P.length;V++){var Y=P[V];Y!==null&&(Y.lane&=-536870913)}r&=~W}l!==0&&ws(e,l,0),f!==0&&c===0&&e.tag!==0&&(e.suspendedLanes|=f&~(p&~n))}function ws(e,n,r){e.pendingLanes|=n,e.suspendedLanes&=~n;var l=31-Rt(n);e.entangledLanes|=n,e.entanglements[l]=e.entanglements[l]|1073741824|r&261930}function ci(e,n){var r=e.entangledLanes|=n;for(e=e.entanglements;r;){var l=31-Rt(r),c=1<<l;c&n|e[l]&n&&(e[l]|=n),r&=~c}}function Ss(e,n){var r=n&-n;return r=(r&42)!==0?1:Jn(r),(r&(e.suspendedLanes|n))!==0?0:r}function Jn(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 ui(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Hr(){var e=se.p;return e!==0?e:(e=window.event,e===void 0?32:c0(e.type))}function rl(e,n){var r=se.p;try{return se.p=e,n()}finally{se.p=r}}var qn=Math.random().toString(36).slice(2),Qe="__reactFiber$"+qn,it="__reactProps$"+qn,Ft="__reactContainer$"+qn,fi="__reactEvents$"+qn,$r="__reactListeners$"+qn,al="__reactHandles$"+qn,ll="__reactResources$"+qn,xt="__reactMarker$"+qn;function Li(e){delete e[Qe],delete e[it],delete e[fi],delete e[$r],delete e[al]}function x(e){var n=e[Qe];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Ft]||r[Qe]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=Fp(e);e!==null;){if(r=e[Qe])return r;e=Fp(e)}return n}e=r,r=e.parentNode}return null}function S(e){if(e=e[Qe]||e[Ft]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function w(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function A(e){var n=e[ll];return n||(n=e[ll]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function k(e){e[xt]=!0}var z=new Set,K={};function ee(e,n){H(e,n),H(e+"Capture",n)}function H(e,n){for(K[e]=n,e=0;e<n.length;e++)z.add(n[e])}var Q=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]*$"),me={},ke={};function Xe(e){return zr.call(ke,e)?!0:zr.call(me,e)?!1:Q.test(e)?ke[e]=!0:(me[e]=!0,!1)}function Dt(e,n,r){if(Xe(n))if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+r)}}function On(e,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+r)}}function Qn(e,n,r,l){if(l===null)e.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttributeNS(n,r,""+l)}}function fn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ch(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Jy(e,n,r){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var c=l.get,f=l.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return c.call(this)},set:function(p){r=""+p,f.call(this,p)}}),Object.defineProperty(e,n,{enumerable:l.enumerable}),{getValue:function(){return r},setValue:function(p){r=""+p},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function sc(e){if(!e._valueTracker){var n=Ch(e)?"checked":"value";e._valueTracker=Jy(e,n,""+e[n])}}function Mh(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),l="";return e&&(l=Ch(e)?e.checked?"true":"false":e.value),e=l,e!==r?(n.setValue(e),!0):!1}function ol(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 Qy=/[\n"\\]/g;function hn(e){return e.replace(Qy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function ic(e,n,r,l,c,f,p,b){e.name="",p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"?e.type=p:e.removeAttribute("type"),n!=null?p==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+fn(n)):e.value!==""+fn(n)&&(e.value=""+fn(n)):p!=="submit"&&p!=="reset"||e.removeAttribute("value"),n!=null?rc(e,p,fn(n)):r!=null?rc(e,p,fn(r)):l!=null&&e.removeAttribute("value"),c==null&&f!=null&&(e.defaultChecked=!!f),c!=null&&(e.checked=c&&typeof c!="function"&&typeof c!="symbol"),b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.name=""+fn(b):e.removeAttribute("name")}function Rh(e,n,r,l,c,f,p,b){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(e.type=f),n!=null||r!=null){if(!(f!=="submit"&&f!=="reset"||n!=null)){sc(e);return}r=r!=null?""+fn(r):"",n=n!=null?""+fn(n):r,b||n===e.value||(e.value=n),e.defaultValue=n}l=l??c,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=b?e.checked:!!l,e.defaultChecked=!!l,p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.name=p),sc(e)}function rc(e,n,r){n==="number"&&ol(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Pi(e,n,r,l){if(e=e.options,n){n={};for(var c=0;c<r.length;c++)n["$"+r[c]]=!0;for(r=0;r<e.length;r++)c=n.hasOwnProperty("$"+e[r].value),e[r].selected!==c&&(e[r].selected=c),c&&l&&(e[r].defaultSelected=!0)}else{for(r=""+fn(r),n=null,c=0;c<e.length;c++){if(e[c].value===r){e[c].selected=!0,l&&(e[c].defaultSelected=!0);return}n!==null||e[c].disabled||(n=e[c])}n!==null&&(n.selected=!0)}}function Dh(e,n,r){if(n!=null&&(n=""+fn(n),n!==e.value&&(e.value=n),r==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=r!=null?""+fn(r):""}function qh(e,n,r,l){if(n==null){if(l!=null){if(r!=null)throw Error(a(92));if(Se(l)){if(1<l.length)throw Error(a(93));l=l[0]}r=l}r==null&&(r=""),n=r}r=fn(n),e.defaultValue=r,l=e.textContent,l===r&&l!==""&&l!==null&&(e.value=l),sc(e)}function Hi(e,n){if(n){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=n;return}}e.textContent=n}var Ky=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 zh(e,n,r){var l=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?l?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":l?e.setProperty(n,r):typeof r!="number"||r===0||Ky.has(n)?n==="float"?e.cssFloat=r:e[n]=(""+r).trim():e[n]=r+"px"}function Uh(e,n,r){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,r!=null){for(var l in r)!r.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var c in n)l=n[c],n.hasOwnProperty(c)&&r[c]!==l&&zh(e,c,l)}else for(var f in n)n.hasOwnProperty(f)&&zh(e,f,n[f])}function ac(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 Xy=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"]]),Zy=/^[\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 cl(e){return Zy.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Kn(){}var lc=null;function oc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $i=null,Yi=null;function Bh(e){var n=S(e);if(n&&(e=n.stateNode)){var r=e[it]||null;e:switch(e=n.stateNode,n.type){case"input":if(ic(e,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+hn(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var l=r[n];if(l!==e&&l.form===e.form){var c=l[it]||null;if(!c)throw Error(a(90));ic(l,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(n=0;n<r.length;n++)l=r[n],l.form===e.form&&Mh(l)}break e;case"textarea":Dh(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Pi(e,!!r.multiple,n,!1)}}}var cc=!1;function Lh(e,n,r){if(cc)return e(n,r);cc=!0;try{var l=e(n);return l}finally{if(cc=!1,($i!==null||Yi!==null)&&(Kl(),$i&&(n=$i,e=Yi,Yi=$i=null,Bh(n),e)))for(n=0;n<e.length;n++)Bh(e[n])}}function Yr(e,n){var r=e.stateNode;if(r===null)return null;var l=r[it]||null;if(l===null)return null;r=l[n];e:switch(n){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(r&&typeof r!="function")throw Error(a(231,n,typeof r));return r}var Xn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uc=!1;if(Xn)try{var Gr={};Object.defineProperty(Gr,"passive",{get:function(){uc=!0}}),window.addEventListener("test",Gr,Gr),window.removeEventListener("test",Gr,Gr)}catch{uc=!1}var Es=null,fc=null,ul=null;function Ph(){if(ul)return ul;var e,n=fc,r=n.length,l,c="value"in Es?Es.value:Es.textContent,f=c.length;for(e=0;e<r&&n[e]===c[e];e++);var p=r-e;for(l=1;l<=p&&n[r-l]===c[f-l];l++);return ul=c.slice(e,1<l?1-l:void 0)}function fl(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function hl(){return!0}function Hh(){return!1}function Lt(e){function n(r,l,c,f,p){this._reactName=r,this._targetInst=c,this.type=l,this.nativeEvent=f,this.target=p,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(r=e[b],this[b]=r?r(f):f[b]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?hl:Hh,this.isPropagationStopped=Hh,this}return _(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=hl)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=hl)},persist:function(){},isPersistent:hl}),n}var hi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},dl=Lt(hi),Vr=_({},hi,{view:0,detail:0}),Wy=Lt(Vr),hc,dc,Ir,ml=_({},Vr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pc,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!==Ir&&(Ir&&e.type==="mousemove"?(hc=e.screenX-Ir.screenX,dc=e.screenY-Ir.screenY):dc=hc=0,Ir=e),hc)},movementY:function(e){return"movementY"in e?e.movementY:dc}}),$h=Lt(ml),eb=_({},ml,{dataTransfer:0}),tb=Lt(eb),nb=_({},Vr,{relatedTarget:0}),mc=Lt(nb),sb=_({},hi,{animationName:0,elapsedTime:0,pseudoElement:0}),ib=Lt(sb),rb=_({},hi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ab=Lt(rb),lb=_({},hi,{data:0}),Yh=Lt(lb),ob={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},cb={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"},ub={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=ub[e])?!!n[e]:!1}function pc(){return fb}var hb=_({},Vr,{key:function(e){if(e.key){var n=ob[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=fl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?cb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pc,charCode:function(e){return e.type==="keypress"?fl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?fl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),db=Lt(hb),mb=_({},ml,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gh=Lt(mb),pb=_({},Vr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pc}),gb=Lt(pb),yb=_({},hi,{propertyName:0,elapsedTime:0,pseudoElement:0}),bb=Lt(yb),xb=_({},ml,{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}),vb=Lt(xb),_b=_({},hi,{newState:0,oldState:0}),wb=Lt(_b),Sb=[9,13,27,32],gc=Xn&&"CompositionEvent"in window,Fr=null;Xn&&"documentMode"in document&&(Fr=document.documentMode);var Eb=Xn&&"TextEvent"in window&&!Fr,Vh=Xn&&(!gc||Fr&&8<Fr&&11>=Fr),Ih=" ",Fh=!1;function Jh(e,n){switch(e){case"keyup":return Sb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gi=!1;function jb(e,n){switch(e){case"compositionend":return Qh(n);case"keypress":return n.which!==32?null:(Fh=!0,Ih);case"textInput":return e=n.data,e===Ih&&Fh?null:e;default:return null}}function Ab(e,n){if(Gi)return e==="compositionend"||!gc&&Jh(e,n)?(e=Ph(),ul=fc=Es=null,Gi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Vh&&n.locale!=="ko"?null:n.data;default:return null}}var Ob={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 Kh(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Ob[e.type]:n==="textarea"}function Xh(e,n,r,l){$i?Yi?Yi.push(l):Yi=[l]:$i=l,n=so(n,"onChange"),0<n.length&&(r=new dl("onChange","change",null,r,l),e.push({event:r,listeners:n}))}var Jr=null,Qr=null;function Nb(e){Rp(e,0)}function pl(e){var n=w(e);if(Mh(n))return e}function Zh(e,n){if(e==="change")return n}var Wh=!1;if(Xn){var yc;if(Xn){var bc="oninput"in document;if(!bc){var ed=document.createElement("div");ed.setAttribute("oninput","return;"),bc=typeof ed.oninput=="function"}yc=bc}else yc=!1;Wh=yc&&(!document.documentMode||9<document.documentMode)}function td(){Jr&&(Jr.detachEvent("onpropertychange",nd),Qr=Jr=null)}function nd(e){if(e.propertyName==="value"&&pl(Qr)){var n=[];Xh(n,Qr,e,oc(e)),Lh(Nb,n)}}function Tb(e,n,r){e==="focusin"?(td(),Jr=n,Qr=r,Jr.attachEvent("onpropertychange",nd)):e==="focusout"&&td()}function kb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return pl(Qr)}function Cb(e,n){if(e==="click")return pl(n)}function Mb(e,n){if(e==="input"||e==="change")return pl(n)}function Rb(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Jt=typeof Object.is=="function"?Object.is:Rb;function Kr(e,n){if(Jt(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var r=Object.keys(e),l=Object.keys(n);if(r.length!==l.length)return!1;for(l=0;l<r.length;l++){var c=r[l];if(!zr.call(n,c)||!Jt(e[c],n[c]))return!1}return!0}function sd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function id(e,n){var r=sd(e);e=0;for(var l;r;){if(r.nodeType===3){if(l=e+r.textContent.length,e<=n&&l>=n)return{node:r,offset:n-e};e=l}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=sd(r)}}function rd(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?rd(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ad(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=ol(e.document);n instanceof e.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)e=n.contentWindow;else break;n=ol(e.document)}return n}function xc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var Db=Xn&&"documentMode"in document&&11>=document.documentMode,Vi=null,vc=null,Xr=null,_c=!1;function ld(e,n,r){var l=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;_c||Vi==null||Vi!==ol(l)||(l=Vi,"selectionStart"in l&&xc(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}),Xr&&Kr(Xr,l)||(Xr=l,l=so(vc,"onSelect"),0<l.length&&(n=new dl("onSelect","select",null,n,r),e.push({event:n,listeners:l}),n.target=Vi)))}function di(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var Ii={animationend:di("Animation","AnimationEnd"),animationiteration:di("Animation","AnimationIteration"),animationstart:di("Animation","AnimationStart"),transitionrun:di("Transition","TransitionRun"),transitionstart:di("Transition","TransitionStart"),transitioncancel:di("Transition","TransitionCancel"),transitionend:di("Transition","TransitionEnd")},wc={},od={};Xn&&(od=document.createElement("div").style,"AnimationEvent"in window||(delete Ii.animationend.animation,delete Ii.animationiteration.animation,delete Ii.animationstart.animation),"TransitionEvent"in window||delete Ii.transitionend.transition);function mi(e){if(wc[e])return wc[e];if(!Ii[e])return e;var n=Ii[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in od)return wc[e]=n[r];return e}var cd=mi("animationend"),ud=mi("animationiteration"),fd=mi("animationstart"),qb=mi("transitionrun"),zb=mi("transitionstart"),Ub=mi("transitioncancel"),hd=mi("transitionend"),dd=new Map,Sc="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(" ");Sc.push("scrollEnd");function Nn(e,n){dd.set(e,n),ee(n,[e])}var gl=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=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(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},dn=[],Fi=0,Ec=0;function yl(){for(var e=Fi,n=Ec=Fi=0;n<e;){var r=dn[n];dn[n++]=null;var l=dn[n];dn[n++]=null;var c=dn[n];dn[n++]=null;var f=dn[n];if(dn[n++]=null,l!==null&&c!==null){var p=l.pending;p===null?c.next=c:(c.next=p.next,p.next=c),l.pending=c}f!==0&&md(r,c,f)}}function bl(e,n,r,l){dn[Fi++]=e,dn[Fi++]=n,dn[Fi++]=r,dn[Fi++]=l,Ec|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function jc(e,n,r,l){return bl(e,n,r,l),xl(e)}function pi(e,n){return bl(e,null,null,n),xl(e)}function md(e,n,r){e.lanes|=r;var l=e.alternate;l!==null&&(l.lanes|=r);for(var c=!1,f=e.return;f!==null;)f.childLanes|=r,l=f.alternate,l!==null&&(l.childLanes|=r),f.tag===22&&(e=f.stateNode,e===null||e._visibility&1||(c=!0)),e=f,f=f.return;return e.tag===3?(f=e.stateNode,c&&n!==null&&(c=31-Rt(r),e=f.hiddenUpdates,l=e[c],l===null?e[c]=[n]:l.push(n),n.lane=r|536870912),f):null}function xl(e){if(50<xa)throw xa=0,Du=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Ji={};function Bb(e,n,r,l){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,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 Qt(e,n,r,l){return new Bb(e,n,r,l)}function Ac(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zn(e,n){var r=e.alternate;return r===null?(r=Qt(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function pd(e,n){e.flags&=65011714;var r=e.alternate;return r===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=r.childLanes,e.lanes=r.lanes,e.child=r.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=r.memoizedProps,e.memoizedState=r.memoizedState,e.updateQueue=r.updateQueue,e.type=r.type,n=r.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function vl(e,n,r,l,c,f){var p=0;if(l=e,typeof e=="function")Ac(e)&&(p=1);else if(typeof e=="string")p=Yx(e,r,lt.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case I:return e=Qt(31,r,n,c),e.elementType=I,e.lanes=f,e;case D:return gi(r.children,c,f,n);case F:p=8,c|=24;break;case te:return e=Qt(12,r,n,c|2),e.elementType=te,e.lanes=f,e;case O:return e=Qt(13,r,n,c),e.elementType=O,e.lanes=f,e;case U:return e=Qt(19,r,n,c),e.elementType=U,e.lanes=f,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case fe:p=10;break e;case X:p=9;break e;case oe:p=11;break e;case ne:p=14;break e;case G:p=16,l=null;break e}p=29,r=Error(a(130,e===null?"null":typeof e,"")),l=null}return n=Qt(p,r,n,c),n.elementType=e,n.type=l,n.lanes=f,n}function gi(e,n,r,l){return e=Qt(7,e,l,n),e.lanes=r,e}function Oc(e,n,r){return e=Qt(6,e,null,n),e.lanes=r,e}function gd(e){var n=Qt(18,null,null,0);return n.stateNode=e,n}function Nc(e,n,r){return n=Qt(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var yd=new WeakMap;function mn(e,n){if(typeof e=="object"&&e!==null){var r=yd.get(e);return r!==void 0?r:(n={value:e,source:n,stack:Wa(n)},yd.set(e,n),n)}return{value:e,source:n,stack:Wa(n)}}var Qi=[],Ki=0,_l=null,Zr=0,pn=[],gn=0,js=null,zn=1,Un="";function Wn(e,n){Qi[Ki++]=Zr,Qi[Ki++]=_l,_l=e,Zr=n}function bd(e,n,r){pn[gn++]=zn,pn[gn++]=Un,pn[gn++]=js,js=e;var l=zn;e=Un;var c=32-Rt(l)-1;l&=~(1<<c),r+=1;var f=32-Rt(n)+c;if(30<f){var p=c-c%5;f=(l&(1<<p)-1).toString(32),l>>=p,c-=p,zn=1<<32-Rt(n)+c|r<<c|l,Un=f+e}else zn=1<<f|r<<c|l,Un=e}function Tc(e){e.return!==null&&(Wn(e,1),bd(e,1,0))}function kc(e){for(;e===_l;)_l=Qi[--Ki],Qi[Ki]=null,Zr=Qi[--Ki],Qi[Ki]=null;for(;e===js;)js=pn[--gn],pn[gn]=null,Un=pn[--gn],pn[gn]=null,zn=pn[--gn],pn[gn]=null}function xd(e,n){pn[gn++]=zn,pn[gn++]=Un,pn[gn++]=js,zn=n.id,Un=n.overflow,js=e}var jt=null,Ze=null,Ue=!1,As=null,yn=!1,Cc=Error(a(519));function Os(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Wr(mn(n,e)),Cc}function vd(e){var n=e.stateNode,r=e.type,l=e.memoizedProps;switch(n[Qe]=e,n[it]=l,r){case"dialog":De("cancel",n),De("close",n);break;case"iframe":case"object":case"embed":De("load",n);break;case"video":case"audio":for(r=0;r<_a.length;r++)De(_a[r],n);break;case"source":De("error",n);break;case"img":case"image":case"link":De("error",n),De("load",n);break;case"details":De("toggle",n);break;case"input":De("invalid",n),Rh(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":De("invalid",n);break;case"textarea":De("invalid",n),qh(n,l.value,l.defaultValue,l.children)}r=l.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||l.suppressHydrationWarning===!0||Up(n.textContent,r)?(l.popover!=null&&(De("beforetoggle",n),De("toggle",n)),l.onScroll!=null&&De("scroll",n),l.onScrollEnd!=null&&De("scrollend",n),l.onClick!=null&&(n.onclick=Kn),n=!0):n=!1,n||Os(e,!0)}function _d(e){for(jt=e.return;jt;)switch(jt.tag){case 5:case 31:case 13:yn=!1;return;case 27:case 3:yn=!0;return;default:jt=jt.return}}function Xi(e){if(e!==jt)return!1;if(!Ue)return _d(e),Ue=!0,!1;var n=e.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=e.type,r=!(r!=="form"&&r!=="button")||Qu(e.type,e.memoizedProps)),r=!r),r&&Ze&&Os(e),_d(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Ze=Ip(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Ze=Ip(e)}else n===27?(n=Ze,Hs(e.type)?(e=ef,ef=null,Ze=e):Ze=n):Ze=jt?xn(e.stateNode.nextSibling):null;return!0}function yi(){Ze=jt=null,Ue=!1}function Mc(){var e=As;return e!==null&&(Yt===null?Yt=e:Yt.push.apply(Yt,e),As=null),e}function Wr(e){As===null?As=[e]:As.push(e)}var Rc=Ce(null),bi=null,es=null;function Ns(e,n,r){Me(Rc,n._currentValue),n._currentValue=r}function ts(e){e._currentValue=Rc.current,Ae(Rc)}function Dc(e,n,r){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===r)break;e=e.return}}function qc(e,n,r,l){var c=e.child;for(c!==null&&(c.return=e);c!==null;){var f=c.dependencies;if(f!==null){var p=c.child;f=f.firstContext;e:for(;f!==null;){var b=f;f=c;for(var N=0;N<n.length;N++)if(b.context===n[N]){f.lanes|=r,b=f.alternate,b!==null&&(b.lanes|=r),Dc(f.return,r,e),l||(p=null);break e}f=b.next}}else if(c.tag===18){if(p=c.return,p===null)throw Error(a(341));p.lanes|=r,f=p.alternate,f!==null&&(f.lanes|=r),Dc(p,r,e),p=null}else p=c.child;if(p!==null)p.return=c;else for(p=c;p!==null;){if(p===e){p=null;break}if(c=p.sibling,c!==null){c.return=p.return,p=c;break}p=p.return}c=p}}function Zi(e,n,r,l){e=null;for(var c=n,f=!1;c!==null;){if(!f){if((c.flags&524288)!==0)f=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var p=c.alternate;if(p===null)throw Error(a(387));if(p=p.memoizedProps,p!==null){var b=c.type;Jt(c.pendingProps.value,p.value)||(e!==null?e.push(b):e=[b])}}else if(c===kt.current){if(p=c.alternate,p===null)throw Error(a(387));p.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(e!==null?e.push(Aa):e=[Aa])}c=c.return}e!==null&&qc(n,e,r,l),n.flags|=262144}function wl(e){for(e=e.firstContext;e!==null;){if(!Jt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function xi(e){bi=e,es=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function At(e){return wd(bi,e)}function Sl(e,n){return bi===null&&xi(e),wd(e,n)}function wd(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},es===null){if(e===null)throw Error(a(308));es=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else es=es.next=n;return r}var Lb=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(r,l){e.push(l)}};this.abort=function(){n.aborted=!0,e.forEach(function(r){return r()})}},Pb=i.unstable_scheduleCallback,Hb=i.unstable_NormalPriority,dt={$$typeof:fe,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function zc(){return{controller:new Lb,data:new Map,refCount:0}}function ea(e){e.refCount--,e.refCount===0&&Pb(Hb,function(){e.controller.abort()})}var ta=null,Uc=0,Wi=0,er=null;function $b(e,n){if(ta===null){var r=ta=[];Uc=0,Wi=Pu(),er={status:"pending",value:void 0,then:function(l){r.push(l)}}}return Uc++,n.then(Sd,Sd),n}function Sd(){if(--Uc===0&&ta!==null){er!==null&&(er.status="fulfilled");var e=ta;ta=null,Wi=0,er=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Yb(e,n){var r=[],l={status:"pending",value:null,reason:null,then:function(c){r.push(c)}};return e.then(function(){l.status="fulfilled",l.value=n;for(var c=0;c<r.length;c++)(0,r[c])(n)},function(c){for(l.status="rejected",l.reason=c,c=0;c<r.length;c++)(0,r[c])(void 0)}),l}var Ed=$.S;$.S=function(e,n){lp=et(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&$b(e,n),Ed!==null&&Ed(e,n)};var vi=Ce(null);function Bc(){var e=vi.current;return e!==null?e:Ke.pooledCache}function El(e,n){n===null?Me(vi,vi.current):Me(vi,n.pool)}function jd(){var e=Bc();return e===null?null:{parent:dt._currentValue,pool:e}}var tr=Error(a(460)),Lc=Error(a(474)),jl=Error(a(542)),Al={then:function(){}};function Ad(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Od(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(Kn,Kn),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Td(e),e;default:if(typeof n.status=="string")n.then(Kn,Kn);else{if(e=Ke,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(l){if(n.status==="pending"){var c=n;c.status="fulfilled",c.value=l}},function(l){if(n.status==="pending"){var c=n;c.status="rejected",c.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Td(e),e}throw wi=n,tr}}function _i(e){try{var n=e._init;return n(e._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(wi=r,tr):r}}var wi=null;function Nd(){if(wi===null)throw Error(a(459));var e=wi;return wi=null,e}function Td(e){if(e===tr||e===jl)throw Error(a(483))}var nr=null,na=0;function Ol(e){var n=na;return na+=1,nr===null&&(nr=[]),Od(nr,e,n)}function sa(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Nl(e,n){throw n.$$typeof===T?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function kd(e){function n(q,M){if(e){var B=q.deletions;B===null?(q.deletions=[M],q.flags|=16):B.push(M)}}function r(q,M){if(!e)return null;for(;M!==null;)n(q,M),M=M.sibling;return null}function l(q){for(var M=new Map;q!==null;)q.key!==null?M.set(q.key,q):M.set(q.index,q),q=q.sibling;return M}function c(q,M){return q=Zn(q,M),q.index=0,q.sibling=null,q}function f(q,M,B){return q.index=B,e?(B=q.alternate,B!==null?(B=B.index,B<M?(q.flags|=67108866,M):B):(q.flags|=67108866,M)):(q.flags|=1048576,M)}function p(q){return e&&q.alternate===null&&(q.flags|=67108866),q}function b(q,M,B,J){return M===null||M.tag!==6?(M=Oc(B,q.mode,J),M.return=q,M):(M=c(M,B),M.return=q,M)}function N(q,M,B,J){var ye=B.type;return ye===D?V(q,M,B.props.children,J,B.key):M!==null&&(M.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===G&&_i(ye)===M.type)?(M=c(M,B.props),sa(M,B),M.return=q,M):(M=vl(B.type,B.key,B.props,null,q.mode,J),sa(M,B),M.return=q,M)}function L(q,M,B,J){return M===null||M.tag!==4||M.stateNode.containerInfo!==B.containerInfo||M.stateNode.implementation!==B.implementation?(M=Nc(B,q.mode,J),M.return=q,M):(M=c(M,B.children||[]),M.return=q,M)}function V(q,M,B,J,ye){return M===null||M.tag!==7?(M=gi(B,q.mode,J,ye),M.return=q,M):(M=c(M,B),M.return=q,M)}function W(q,M,B){if(typeof M=="string"&&M!==""||typeof M=="number"||typeof M=="bigint")return M=Oc(""+M,q.mode,B),M.return=q,M;if(typeof M=="object"&&M!==null){switch(M.$$typeof){case R:return B=vl(M.type,M.key,M.props,null,q.mode,B),sa(B,M),B.return=q,B;case C:return M=Nc(M,q.mode,B),M.return=q,M;case G:return M=_i(M),W(q,M,B)}if(Se(M)||re(M))return M=gi(M,q.mode,B,null),M.return=q,M;if(typeof M.then=="function")return W(q,Ol(M),B);if(M.$$typeof===fe)return W(q,Sl(q,M),B);Nl(q,M)}return null}function P(q,M,B,J){var ye=M!==null?M.key:null;if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return ye!==null?null:b(q,M,""+B,J);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case R:return B.key===ye?N(q,M,B,J):null;case C:return B.key===ye?L(q,M,B,J):null;case G:return B=_i(B),P(q,M,B,J)}if(Se(B)||re(B))return ye!==null?null:V(q,M,B,J,null);if(typeof B.then=="function")return P(q,M,Ol(B),J);if(B.$$typeof===fe)return P(q,M,Sl(q,B),J);Nl(q,B)}return null}function Y(q,M,B,J,ye){if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return q=q.get(B)||null,b(M,q,""+J,ye);if(typeof J=="object"&&J!==null){switch(J.$$typeof){case R:return q=q.get(J.key===null?B:J.key)||null,N(M,q,J,ye);case C:return q=q.get(J.key===null?B:J.key)||null,L(M,q,J,ye);case G:return J=_i(J),Y(q,M,B,J,ye)}if(Se(J)||re(J))return q=q.get(B)||null,V(M,q,J,ye,null);if(typeof J.then=="function")return Y(q,M,B,Ol(J),ye);if(J.$$typeof===fe)return Y(q,M,B,Sl(M,J),ye);Nl(M,J)}return null}function pe(q,M,B,J){for(var ye=null,Pe=null,ge=M,Te=M=0,ze=null;ge!==null&&Te<B.length;Te++){ge.index>Te?(ze=ge,ge=null):ze=ge.sibling;var He=P(q,ge,B[Te],J);if(He===null){ge===null&&(ge=ze);break}e&&ge&&He.alternate===null&&n(q,ge),M=f(He,M,Te),Pe===null?ye=He:Pe.sibling=He,Pe=He,ge=ze}if(Te===B.length)return r(q,ge),Ue&&Wn(q,Te),ye;if(ge===null){for(;Te<B.length;Te++)ge=W(q,B[Te],J),ge!==null&&(M=f(ge,M,Te),Pe===null?ye=ge:Pe.sibling=ge,Pe=ge);return Ue&&Wn(q,Te),ye}for(ge=l(ge);Te<B.length;Te++)ze=Y(ge,q,Te,B[Te],J),ze!==null&&(e&&ze.alternate!==null&&ge.delete(ze.key===null?Te:ze.key),M=f(ze,M,Te),Pe===null?ye=ze:Pe.sibling=ze,Pe=ze);return e&&ge.forEach(function(Is){return n(q,Is)}),Ue&&Wn(q,Te),ye}function _e(q,M,B,J){if(B==null)throw Error(a(151));for(var ye=null,Pe=null,ge=M,Te=M=0,ze=null,He=B.next();ge!==null&&!He.done;Te++,He=B.next()){ge.index>Te?(ze=ge,ge=null):ze=ge.sibling;var Is=P(q,ge,He.value,J);if(Is===null){ge===null&&(ge=ze);break}e&&ge&&Is.alternate===null&&n(q,ge),M=f(Is,M,Te),Pe===null?ye=Is:Pe.sibling=Is,Pe=Is,ge=ze}if(He.done)return r(q,ge),Ue&&Wn(q,Te),ye;if(ge===null){for(;!He.done;Te++,He=B.next())He=W(q,He.value,J),He!==null&&(M=f(He,M,Te),Pe===null?ye=He:Pe.sibling=He,Pe=He);return Ue&&Wn(q,Te),ye}for(ge=l(ge);!He.done;Te++,He=B.next())He=Y(ge,q,Te,He.value,J),He!==null&&(e&&He.alternate!==null&&ge.delete(He.key===null?Te:He.key),M=f(He,M,Te),Pe===null?ye=He:Pe.sibling=He,Pe=He);return e&&ge.forEach(function(ev){return n(q,ev)}),Ue&&Wn(q,Te),ye}function Je(q,M,B,J){if(typeof B=="object"&&B!==null&&B.type===D&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case R:e:{for(var ye=B.key;M!==null;){if(M.key===ye){if(ye=B.type,ye===D){if(M.tag===7){r(q,M.sibling),J=c(M,B.props.children),J.return=q,q=J;break e}}else if(M.elementType===ye||typeof ye=="object"&&ye!==null&&ye.$$typeof===G&&_i(ye)===M.type){r(q,M.sibling),J=c(M,B.props),sa(J,B),J.return=q,q=J;break e}r(q,M);break}else n(q,M);M=M.sibling}B.type===D?(J=gi(B.props.children,q.mode,J,B.key),J.return=q,q=J):(J=vl(B.type,B.key,B.props,null,q.mode,J),sa(J,B),J.return=q,q=J)}return p(q);case C:e:{for(ye=B.key;M!==null;){if(M.key===ye)if(M.tag===4&&M.stateNode.containerInfo===B.containerInfo&&M.stateNode.implementation===B.implementation){r(q,M.sibling),J=c(M,B.children||[]),J.return=q,q=J;break e}else{r(q,M);break}else n(q,M);M=M.sibling}J=Nc(B,q.mode,J),J.return=q,q=J}return p(q);case G:return B=_i(B),Je(q,M,B,J)}if(Se(B))return pe(q,M,B,J);if(re(B)){if(ye=re(B),typeof ye!="function")throw Error(a(150));return B=ye.call(B),_e(q,M,B,J)}if(typeof B.then=="function")return Je(q,M,Ol(B),J);if(B.$$typeof===fe)return Je(q,M,Sl(q,B),J);Nl(q,B)}return typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint"?(B=""+B,M!==null&&M.tag===6?(r(q,M.sibling),J=c(M,B),J.return=q,q=J):(r(q,M),J=Oc(B,q.mode,J),J.return=q,q=J),p(q)):r(q,M)}return function(q,M,B,J){try{na=0;var ye=Je(q,M,B,J);return nr=null,ye}catch(ge){if(ge===tr||ge===jl)throw ge;var Pe=Qt(29,ge,null,q.mode);return Pe.lanes=J,Pe.return=q,Pe}finally{}}}var Si=kd(!0),Cd=kd(!1),Ts=!1;function Pc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ks(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Cs(e,n,r){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var c=l.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),l.pending=n,n=xl(e),md(e,null,r),n}return bl(e,l,n,r),xl(e)}function ia(e,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var l=n.lanes;l&=e.pendingLanes,r|=l,n.lanes=r,ci(e,r)}}function $c(e,n){var r=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,r===l)){var c=null,f=null;if(r=r.firstBaseUpdate,r!==null){do{var p={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};f===null?c=f=p:f=f.next=p,r=r.next}while(r!==null);f===null?c=f=n:f=f.next=n}else c=f=n;r={baseState:l.baseState,firstBaseUpdate:c,lastBaseUpdate:f,shared:l.shared,callbacks:l.callbacks},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=n:e.next=n,r.lastBaseUpdate=n}var Yc=!1;function ra(){if(Yc){var e=er;if(e!==null)throw e}}function aa(e,n,r,l){Yc=!1;var c=e.updateQueue;Ts=!1;var f=c.firstBaseUpdate,p=c.lastBaseUpdate,b=c.shared.pending;if(b!==null){c.shared.pending=null;var N=b,L=N.next;N.next=null,p===null?f=L:p.next=L,p=N;var V=e.alternate;V!==null&&(V=V.updateQueue,b=V.lastBaseUpdate,b!==p&&(b===null?V.firstBaseUpdate=L:b.next=L,V.lastBaseUpdate=N))}if(f!==null){var W=c.baseState;p=0,V=L=N=null,b=f;do{var P=b.lane&-536870913,Y=P!==b.lane;if(Y?(qe&P)===P:(l&P)===P){P!==0&&P===Wi&&(Yc=!0),V!==null&&(V=V.next={lane:0,tag:b.tag,payload:b.payload,callback:null,next:null});e:{var pe=e,_e=b;P=n;var Je=r;switch(_e.tag){case 1:if(pe=_e.payload,typeof pe=="function"){W=pe.call(Je,W,P);break e}W=pe;break e;case 3:pe.flags=pe.flags&-65537|128;case 0:if(pe=_e.payload,P=typeof pe=="function"?pe.call(Je,W,P):pe,P==null)break e;W=_({},W,P);break e;case 2:Ts=!0}}P=b.callback,P!==null&&(e.flags|=64,Y&&(e.flags|=8192),Y=c.callbacks,Y===null?c.callbacks=[P]:Y.push(P))}else Y={lane:P,tag:b.tag,payload:b.payload,callback:b.callback,next:null},V===null?(L=V=Y,N=W):V=V.next=Y,p|=P;if(b=b.next,b===null){if(b=c.shared.pending,b===null)break;Y=b,b=Y.next,Y.next=null,c.lastBaseUpdate=Y,c.shared.pending=null}}while(!0);V===null&&(N=W),c.baseState=N,c.firstBaseUpdate=L,c.lastBaseUpdate=V,f===null&&(c.shared.lanes=0),zs|=p,e.lanes=p,e.memoizedState=W}}function Md(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Rd(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)Md(r[e],n)}var sr=Ce(null),Tl=Ce(0);function Dd(e,n){e=us,Me(Tl,e),Me(sr,n),us=e|n.baseLanes}function Gc(){Me(Tl,us),Me(sr,sr.current)}function Vc(){us=Tl.current,Ae(sr),Ae(Tl)}var Kt=Ce(null),bn=null;function Ms(e){var n=e.alternate;Me(ct,ct.current&1),Me(Kt,e),bn===null&&(n===null||sr.current!==null||n.memoizedState!==null)&&(bn=e)}function Ic(e){Me(ct,ct.current),Me(Kt,e),bn===null&&(bn=e)}function qd(e){e.tag===22?(Me(ct,ct.current),Me(Kt,e),bn===null&&(bn=e)):Rs()}function Rs(){Me(ct,ct.current),Me(Kt,Kt.current)}function Xt(e){Ae(Kt),bn===e&&(bn=null),Ae(ct)}var ct=Ce(0);function kl(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||Zu(r)||Wu(r)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var ns=0,Ne=null,Ie=null,mt=null,Cl=!1,ir=!1,Ei=!1,Ml=0,la=0,rr=null,Gb=0;function rt(){throw Error(a(321))}function Fc(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!Jt(e[r],n[r]))return!1;return!0}function Jc(e,n,r,l,c,f){return ns=f,Ne=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,$.H=e===null||e.memoizedState===null?bm:cu,Ei=!1,f=r(l,c),Ei=!1,ir&&(f=Ud(n,r,l,c)),zd(e),f}function zd(e){$.H=ua;var n=Ie!==null&&Ie.next!==null;if(ns=0,mt=Ie=Ne=null,Cl=!1,la=0,rr=null,n)throw Error(a(300));e===null||pt||(e=e.dependencies,e!==null&&wl(e)&&(pt=!0))}function Ud(e,n,r,l){Ne=e;var c=0;do{if(ir&&(rr=null),la=0,ir=!1,25<=c)throw Error(a(301));if(c+=1,mt=Ie=null,e.updateQueue!=null){var f=e.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}$.H=xm,f=n(r,l)}while(ir);return f}function Vb(){var e=$.H,n=e.useState()[0];return n=typeof n.then=="function"?oa(n):n,e=e.useState()[0],(Ie!==null?Ie.memoizedState:null)!==e&&(Ne.flags|=1024),n}function Qc(){var e=Ml!==0;return Ml=0,e}function Kc(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function Xc(e){if(Cl){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Cl=!1}ns=0,mt=Ie=Ne=null,ir=!1,la=Ml=0,rr=null}function qt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mt===null?Ne.memoizedState=mt=e:mt=mt.next=e,mt}function ut(){if(Ie===null){var e=Ne.alternate;e=e!==null?e.memoizedState:null}else e=Ie.next;var n=mt===null?Ne.memoizedState:mt.next;if(n!==null)mt=n,Ie=e;else{if(e===null)throw Ne.alternate===null?Error(a(467)):Error(a(310));Ie=e,e={memoizedState:Ie.memoizedState,baseState:Ie.baseState,baseQueue:Ie.baseQueue,queue:Ie.queue,next:null},mt===null?Ne.memoizedState=mt=e:mt=mt.next=e}return mt}function Rl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function oa(e){var n=la;return la+=1,rr===null&&(rr=[]),e=Od(rr,e,n),n=Ne,(mt===null?n.memoizedState:mt.next)===null&&(n=n.alternate,$.H=n===null||n.memoizedState===null?bm:cu),e}function Dl(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return oa(e);if(e.$$typeof===fe)return At(e)}throw Error(a(438,String(e)))}function Zc(e){var n=null,r=Ne.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var l=Ne.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(c){return c.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=Rl(),Ne.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(e),l=0;l<e;l++)r[l]=Z;return n.index++,r}function ss(e,n){return typeof n=="function"?n(e):n}function ql(e){var n=ut();return Wc(n,Ie,e)}function Wc(e,n,r){var l=e.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=r;var c=e.baseQueue,f=l.pending;if(f!==null){if(c!==null){var p=c.next;c.next=f.next,f.next=p}n.baseQueue=c=f,l.pending=null}if(f=e.baseState,c===null)e.memoizedState=f;else{n=c.next;var b=p=null,N=null,L=n,V=!1;do{var W=L.lane&-536870913;if(W!==L.lane?(qe&W)===W:(ns&W)===W){var P=L.revertLane;if(P===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),W===Wi&&(V=!0);else if((ns&P)===P){L=L.next,P===Wi&&(V=!0);continue}else W={lane:0,revertLane:L.revertLane,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},N===null?(b=N=W,p=f):N=N.next=W,Ne.lanes|=P,zs|=P;W=L.action,Ei&&r(f,W),f=L.hasEagerState?L.eagerState:r(f,W)}else P={lane:W,revertLane:L.revertLane,gesture:L.gesture,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},N===null?(b=N=P,p=f):N=N.next=P,Ne.lanes|=W,zs|=W;L=L.next}while(L!==null&&L!==n);if(N===null?p=f:N.next=b,!Jt(f,e.memoizedState)&&(pt=!0,V&&(r=er,r!==null)))throw r;e.memoizedState=f,e.baseState=p,e.baseQueue=N,l.lastRenderedState=f}return c===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function eu(e){var n=ut(),r=n.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=e;var l=r.dispatch,c=r.pending,f=n.memoizedState;if(c!==null){r.pending=null;var p=c=c.next;do f=e(f,p.action),p=p.next;while(p!==c);Jt(f,n.memoizedState)||(pt=!0),n.memoizedState=f,n.baseQueue===null&&(n.baseState=f),r.lastRenderedState=f}return[f,l]}function Bd(e,n,r){var l=Ne,c=ut(),f=Ue;if(f){if(r===void 0)throw Error(a(407));r=r()}else r=n();var p=!Jt((Ie||c).memoizedState,r);if(p&&(c.memoizedState=r,pt=!0),c=c.queue,su(Hd.bind(null,l,c,e),[e]),c.getSnapshot!==n||p||mt!==null&&mt.memoizedState.tag&1){if(l.flags|=2048,ar(9,{destroy:void 0},Pd.bind(null,l,c,r,n),null),Ke===null)throw Error(a(349));f||(ns&127)!==0||Ld(l,n,r)}return r}function Ld(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=Ne.updateQueue,n===null?(n=Rl(),Ne.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function Pd(e,n,r,l){n.value=r,n.getSnapshot=l,$d(n)&&Yd(e)}function Hd(e,n,r){return r(function(){$d(n)&&Yd(e)})}function $d(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!Jt(e,r)}catch{return!0}}function Yd(e){var n=pi(e,2);n!==null&&Gt(n,e,2)}function tu(e){var n=qt();if(typeof e=="function"){var r=e;if(e=r(),Ei){It(!0);try{r()}finally{It(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:e},n}function Gd(e,n,r,l){return e.baseState=r,Wc(e,Ie,typeof l=="function"?l:ss)}function Ib(e,n,r,l,c){if(Bl(e))throw Error(a(485));if(e=n.action,e!==null){var f={payload:c,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(p){f.listeners.push(p)}};$.T!==null?r(!0):f.isTransition=!1,l(f),r=n.pending,r===null?(f.next=n.pending=f,Vd(n,f)):(f.next=r.next,n.pending=r.next=f)}}function Vd(e,n){var r=n.action,l=n.payload,c=e.state;if(n.isTransition){var f=$.T,p={};$.T=p;try{var b=r(c,l),N=$.S;N!==null&&N(p,b),Id(e,n,b)}catch(L){nu(e,n,L)}finally{f!==null&&p.types!==null&&(f.types=p.types),$.T=f}}else try{f=r(c,l),Id(e,n,f)}catch(L){nu(e,n,L)}}function Id(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(l){Fd(e,n,l)},function(l){return nu(e,n,l)}):Fd(e,n,r)}function Fd(e,n,r){n.status="fulfilled",n.value=r,Jd(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,Vd(e,r)))}function nu(e,n,r){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=r,Jd(n),n=n.next;while(n!==l)}e.action=null}function Jd(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function Qd(e,n){return n}function Kd(e,n){if(Ue){var r=Ke.formState;if(r!==null){e:{var l=Ne;if(Ue){if(Ze){t:{for(var c=Ze,f=yn;c.nodeType!==8;){if(!f){c=null;break t}if(c=xn(c.nextSibling),c===null){c=null;break t}}f=c.data,c=f==="F!"||f==="F"?c:null}if(c){Ze=xn(c.nextSibling),l=c.data==="F!";break e}}Os(l)}l=!1}l&&(n=r[0])}}return r=qt(),r.memoizedState=r.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qd,lastRenderedState:n},r.queue=l,r=pm.bind(null,Ne,l),l.dispatch=r,l=tu(!1),f=ou.bind(null,Ne,!1,l.queue),l=qt(),c={state:n,dispatch:null,action:e,pending:null},l.queue=c,r=Ib.bind(null,Ne,c,f,r),c.dispatch=r,l.memoizedState=e,[n,r,!1]}function Xd(e){var n=ut();return Zd(n,Ie,e)}function Zd(e,n,r){if(n=Wc(e,n,Qd)[0],e=ql(ss)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=oa(n)}catch(p){throw p===tr?jl:p}else l=n;n=ut();var c=n.queue,f=c.dispatch;return r!==n.memoizedState&&(Ne.flags|=2048,ar(9,{destroy:void 0},Fb.bind(null,c,r),null)),[l,f,e]}function Fb(e,n){e.action=n}function Wd(e){var n=ut(),r=Ie;if(r!==null)return Zd(n,r,e);ut(),n=n.memoizedState,r=ut();var l=r.queue.dispatch;return r.memoizedState=e,[n,l,!1]}function ar(e,n,r,l){return e={tag:e,create:r,deps:l,inst:n,next:null},n=Ne.updateQueue,n===null&&(n=Rl(),Ne.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=e.next=e:(l=r.next,r.next=e,e.next=l,n.lastEffect=e),e}function em(){return ut().memoizedState}function zl(e,n,r,l){var c=qt();Ne.flags|=e,c.memoizedState=ar(1|n,{destroy:void 0},r,l===void 0?null:l)}function Ul(e,n,r,l){var c=ut();l=l===void 0?null:l;var f=c.memoizedState.inst;Ie!==null&&l!==null&&Fc(l,Ie.memoizedState.deps)?c.memoizedState=ar(n,f,r,l):(Ne.flags|=e,c.memoizedState=ar(1|n,f,r,l))}function tm(e,n){zl(8390656,8,e,n)}function su(e,n){Ul(2048,8,e,n)}function Jb(e){Ne.flags|=4;var n=Ne.updateQueue;if(n===null)n=Rl(),Ne.updateQueue=n,n.events=[e];else{var r=n.events;r===null?n.events=[e]:r.push(e)}}function nm(e){var n=ut().memoizedState;return Jb({ref:n,nextImpl:e}),function(){if(($e&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function sm(e,n){return Ul(4,2,e,n)}function im(e,n){return Ul(4,4,e,n)}function rm(e,n){if(typeof n=="function"){e=e();var r=n(e);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function am(e,n,r){r=r!=null?r.concat([e]):null,Ul(4,4,rm.bind(null,n,e),r)}function iu(){}function lm(e,n){var r=ut();n=n===void 0?null:n;var l=r.memoizedState;return n!==null&&Fc(n,l[1])?l[0]:(r.memoizedState=[e,n],e)}function om(e,n){var r=ut();n=n===void 0?null:n;var l=r.memoizedState;if(n!==null&&Fc(n,l[1]))return l[0];if(l=e(),Ei){It(!0);try{e()}finally{It(!1)}}return r.memoizedState=[l,n],l}function ru(e,n,r){return r===void 0||(ns&1073741824)!==0&&(qe&261930)===0?e.memoizedState=n:(e.memoizedState=r,e=cp(),Ne.lanes|=e,zs|=e,r)}function cm(e,n,r,l){return Jt(r,n)?r:sr.current!==null?(e=ru(e,r,l),Jt(e,n)||(pt=!0),e):(ns&42)===0||(ns&1073741824)!==0&&(qe&261930)===0?(pt=!0,e.memoizedState=r):(e=cp(),Ne.lanes|=e,zs|=e,n)}function um(e,n,r,l,c){var f=se.p;se.p=f!==0&&8>f?f:8;var p=$.T,b={};$.T=b,ou(e,!1,n,r);try{var N=c(),L=$.S;if(L!==null&&L(b,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var V=Yb(N,l);ca(e,n,V,en(e))}else ca(e,n,l,en(e))}catch(W){ca(e,n,{then:function(){},status:"rejected",reason:W},en())}finally{se.p=f,p!==null&&b.types!==null&&(p.types=b.types),$.T=p}}function Qb(){}function au(e,n,r,l){if(e.tag!==5)throw Error(a(476));var c=fm(e).queue;um(e,c,n,ie,r===null?Qb:function(){return hm(e),r(l)})}function fm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:ie},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function hm(e){var n=fm(e);n.next===null&&(n=e.alternate.memoizedState),ca(e,n.next.queue,{},en())}function lu(){return At(Aa)}function dm(){return ut().memoizedState}function mm(){return ut().memoizedState}function Kb(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=en();e=ks(r);var l=Cs(n,e,r);l!==null&&(Gt(l,n,r),ia(l,n,r)),n={cache:zc()},e.payload=n;return}n=n.return}}function Xb(e,n,r){var l=en();r={lane:l,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Bl(e)?gm(n,r):(r=jc(e,n,r,l),r!==null&&(Gt(r,e,l),ym(r,n,l)))}function pm(e,n,r){var l=en();ca(e,n,r,l)}function ca(e,n,r,l){var c={lane:l,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(Bl(e))gm(n,c);else{var f=e.alternate;if(e.lanes===0&&(f===null||f.lanes===0)&&(f=n.lastRenderedReducer,f!==null))try{var p=n.lastRenderedState,b=f(p,r);if(c.hasEagerState=!0,c.eagerState=b,Jt(b,p))return bl(e,n,c,0),Ke===null&&yl(),!1}catch{}finally{}if(r=jc(e,n,c,l),r!==null)return Gt(r,e,l),ym(r,n,l),!0}return!1}function ou(e,n,r,l){if(l={lane:2,revertLane:Pu(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Bl(e)){if(n)throw Error(a(479))}else n=jc(e,r,l,2),n!==null&&Gt(n,e,2)}function Bl(e){var n=e.alternate;return e===Ne||n!==null&&n===Ne}function gm(e,n){ir=Cl=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function ym(e,n,r){if((r&4194048)!==0){var l=n.lanes;l&=e.pendingLanes,r|=l,n.lanes=r,ci(e,r)}}var ua={readContext:At,use:Dl,useCallback:rt,useContext:rt,useEffect:rt,useImperativeHandle:rt,useLayoutEffect:rt,useInsertionEffect:rt,useMemo:rt,useReducer:rt,useRef:rt,useState:rt,useDebugValue:rt,useDeferredValue:rt,useTransition:rt,useSyncExternalStore:rt,useId:rt,useHostTransitionStatus:rt,useFormState:rt,useActionState:rt,useOptimistic:rt,useMemoCache:rt,useCacheRefresh:rt};ua.useEffectEvent=rt;var bm={readContext:At,use:Dl,useCallback:function(e,n){return qt().memoizedState=[e,n===void 0?null:n],e},useContext:At,useEffect:tm,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,zl(4194308,4,rm.bind(null,n,e),r)},useLayoutEffect:function(e,n){return zl(4194308,4,e,n)},useInsertionEffect:function(e,n){zl(4,2,e,n)},useMemo:function(e,n){var r=qt();n=n===void 0?null:n;var l=e();if(Ei){It(!0);try{e()}finally{It(!1)}}return r.memoizedState=[l,n],l},useReducer:function(e,n,r){var l=qt();if(r!==void 0){var c=r(n);if(Ei){It(!0);try{r(n)}finally{It(!1)}}}else c=n;return l.memoizedState=l.baseState=c,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:c},l.queue=e,e=e.dispatch=Xb.bind(null,Ne,e),[l.memoizedState,e]},useRef:function(e){var n=qt();return e={current:e},n.memoizedState=e},useState:function(e){e=tu(e);var n=e.queue,r=pm.bind(null,Ne,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:iu,useDeferredValue:function(e,n){var r=qt();return ru(r,e,n)},useTransition:function(){var e=tu(!1);return e=um.bind(null,Ne,e.queue,!0,!1),qt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var l=Ne,c=qt();if(Ue){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),Ke===null)throw Error(a(349));(qe&127)!==0||Ld(l,n,r)}c.memoizedState=r;var f={value:r,getSnapshot:n};return c.queue=f,tm(Hd.bind(null,l,f,e),[e]),l.flags|=2048,ar(9,{destroy:void 0},Pd.bind(null,l,f,r,n),null),r},useId:function(){var e=qt(),n=Ke.identifierPrefix;if(Ue){var r=Un,l=zn;r=(l&~(1<<32-Rt(l)-1)).toString(32)+r,n="_"+n+"R_"+r,r=Ml++,0<r&&(n+="H"+r.toString(32)),n+="_"}else r=Gb++,n="_"+n+"r_"+r.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:lu,useFormState:Kd,useActionState:Kd,useOptimistic:function(e){var n=qt();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=ou.bind(null,Ne,!0,r),r.dispatch=n,[e,n]},useMemoCache:Zc,useCacheRefresh:function(){return qt().memoizedState=Kb.bind(null,Ne)},useEffectEvent:function(e){var n=qt(),r={impl:e};return n.memoizedState=r,function(){if(($e&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}},cu={readContext:At,use:Dl,useCallback:lm,useContext:At,useEffect:su,useImperativeHandle:am,useInsertionEffect:sm,useLayoutEffect:im,useMemo:om,useReducer:ql,useRef:em,useState:function(){return ql(ss)},useDebugValue:iu,useDeferredValue:function(e,n){var r=ut();return cm(r,Ie.memoizedState,e,n)},useTransition:function(){var e=ql(ss)[0],n=ut().memoizedState;return[typeof e=="boolean"?e:oa(e),n]},useSyncExternalStore:Bd,useId:dm,useHostTransitionStatus:lu,useFormState:Xd,useActionState:Xd,useOptimistic:function(e,n){var r=ut();return Gd(r,Ie,e,n)},useMemoCache:Zc,useCacheRefresh:mm};cu.useEffectEvent=nm;var xm={readContext:At,use:Dl,useCallback:lm,useContext:At,useEffect:su,useImperativeHandle:am,useInsertionEffect:sm,useLayoutEffect:im,useMemo:om,useReducer:eu,useRef:em,useState:function(){return eu(ss)},useDebugValue:iu,useDeferredValue:function(e,n){var r=ut();return Ie===null?ru(r,e,n):cm(r,Ie.memoizedState,e,n)},useTransition:function(){var e=eu(ss)[0],n=ut().memoizedState;return[typeof e=="boolean"?e:oa(e),n]},useSyncExternalStore:Bd,useId:dm,useHostTransitionStatus:lu,useFormState:Wd,useActionState:Wd,useOptimistic:function(e,n){var r=ut();return Ie!==null?Gd(r,Ie,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:Zc,useCacheRefresh:mm};xm.useEffectEvent=nm;function uu(e,n,r,l){n=e.memoizedState,r=r(l,n),r=r==null?n:_({},n,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var fu={enqueueSetState:function(e,n,r){e=e._reactInternals;var l=en(),c=ks(l);c.payload=n,r!=null&&(c.callback=r),n=Cs(e,c,l),n!==null&&(Gt(n,e,l),ia(n,e,l))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var l=en(),c=ks(l);c.tag=1,c.payload=n,r!=null&&(c.callback=r),n=Cs(e,c,l),n!==null&&(Gt(n,e,l),ia(n,e,l))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=en(),l=ks(r);l.tag=2,n!=null&&(l.callback=n),n=Cs(e,l,r),n!==null&&(Gt(n,e,r),ia(n,e,r))}};function vm(e,n,r,l,c,f,p){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,f,p):n.prototype&&n.prototype.isPureReactComponent?!Kr(r,l)||!Kr(c,f):!0}function _m(e,n,r,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,l),n.state!==e&&fu.enqueueReplaceState(n,n.state,null)}function ji(e,n){var r=n;if("ref"in n){r={};for(var l in n)l!=="ref"&&(r[l]=n[l])}if(e=e.defaultProps){r===n&&(r=_({},r));for(var c in e)r[c]===void 0&&(r[c]=e[c])}return r}function wm(e){gl(e)}function Sm(e){console.error(e)}function Em(e){gl(e)}function Ll(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function jm(e,n,r){try{var l=e.onCaughtError;l(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function hu(e,n,r){return r=ks(r),r.tag=3,r.payload={element:null},r.callback=function(){Ll(e,n)},r}function Am(e){return e=ks(e),e.tag=3,e}function Om(e,n,r,l){var c=r.type.getDerivedStateFromError;if(typeof c=="function"){var f=l.value;e.payload=function(){return c(f)},e.callback=function(){jm(n,r,l)}}var p=r.stateNode;p!==null&&typeof p.componentDidCatch=="function"&&(e.callback=function(){jm(n,r,l),typeof c!="function"&&(Us===null?Us=new Set([this]):Us.add(this));var b=l.stack;this.componentDidCatch(l.value,{componentStack:b!==null?b:""})})}function Zb(e,n,r,l,c){if(r.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=r.alternate,n!==null&&Zi(n,r,c,!0),r=Kt.current,r!==null){switch(r.tag){case 31:case 13:return bn===null?Xl():r.alternate===null&&at===0&&(at=3),r.flags&=-257,r.flags|=65536,r.lanes=c,l===Al?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([l]):n.add(l),Uu(e,l,c)),!1;case 22:return r.flags|=65536,l===Al?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([l]):r.add(l)),Uu(e,l,c)),!1}throw Error(a(435,r.tag))}return Uu(e,l,c),Xl(),!1}if(Ue)return n=Kt.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=c,l!==Cc&&(e=Error(a(422),{cause:l}),Wr(mn(e,r)))):(l!==Cc&&(n=Error(a(423),{cause:l}),Wr(mn(n,r))),e=e.current.alternate,e.flags|=65536,c&=-c,e.lanes|=c,l=mn(l,r),c=hu(e.stateNode,l,c),$c(e,c),at!==4&&(at=2)),!1;var f=Error(a(520),{cause:l});if(f=mn(f,r),ba===null?ba=[f]:ba.push(f),at!==4&&(at=2),n===null)return!0;l=mn(l,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=c&-c,r.lanes|=e,e=hu(r.stateNode,l,e),$c(r,e),!1;case 1:if(n=r.type,f=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(Us===null||!Us.has(f))))return r.flags|=65536,c&=-c,r.lanes|=c,c=Am(c),Om(c,e,r,l),$c(r,c),!1}r=r.return}while(r!==null);return!1}var du=Error(a(461)),pt=!1;function Ot(e,n,r,l){n.child=e===null?Cd(n,null,r,l):Si(n,e.child,r,l)}function Nm(e,n,r,l,c){r=r.render;var f=n.ref;if("ref"in l){var p={};for(var b in l)b!=="ref"&&(p[b]=l[b])}else p=l;return xi(n),l=Jc(e,n,r,p,f,c),b=Qc(),e!==null&&!pt?(Kc(e,n,c),is(e,n,c)):(Ue&&b&&Tc(n),n.flags|=1,Ot(e,n,l,c),n.child)}function Tm(e,n,r,l,c){if(e===null){var f=r.type;return typeof f=="function"&&!Ac(f)&&f.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=f,km(e,n,f,l,c)):(e=vl(r.type,null,l,n,n.mode,c),e.ref=n.ref,e.return=n,n.child=e)}if(f=e.child,!_u(e,c)){var p=f.memoizedProps;if(r=r.compare,r=r!==null?r:Kr,r(p,l)&&e.ref===n.ref)return is(e,n,c)}return n.flags|=1,e=Zn(f,l),e.ref=n.ref,e.return=n,n.child=e}function km(e,n,r,l,c){if(e!==null){var f=e.memoizedProps;if(Kr(f,l)&&e.ref===n.ref)if(pt=!1,n.pendingProps=l=f,_u(e,c))(e.flags&131072)!==0&&(pt=!0);else return n.lanes=e.lanes,is(e,n,c)}return mu(e,n,r,l,c)}function Cm(e,n,r,l){var c=l.children,f=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(f=f!==null?f.baseLanes|r:r,e!==null){for(l=n.child=e.child,c=0;l!==null;)c=c|l.lanes|l.childLanes,l=l.sibling;l=c&~f}else l=0,n.child=null;return Mm(e,n,f,r,l)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&El(n,f!==null?f.cachePool:null),f!==null?Dd(n,f):Gc(),qd(n);else return l=n.lanes=536870912,Mm(e,n,f!==null?f.baseLanes|r:r,r,l)}else f!==null?(El(n,f.cachePool),Dd(n,f),Rs(),n.memoizedState=null):(e!==null&&El(n,null),Gc(),Rs());return Ot(e,n,c,r),n.child}function fa(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Mm(e,n,r,l,c){var f=Bc();return f=f===null?null:{parent:dt._currentValue,pool:f},n.memoizedState={baseLanes:r,cachePool:f},e!==null&&El(n,null),Gc(),qd(n),e!==null&&Zi(e,n,l,!0),n.childLanes=c,null}function Pl(e,n){return n=$l({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Rm(e,n,r){return Si(n,e.child,null,r),e=Pl(n,n.pendingProps),e.flags|=2,Xt(n),n.memoizedState=null,e}function Wb(e,n,r){var l=n.pendingProps,c=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Ue){if(l.mode==="hidden")return e=Pl(n,l),n.lanes=536870912,fa(null,e);if(Ic(n),(e=Ze)?(e=Vp(e,yn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:js!==null?{id:zn,overflow:Un}:null,retryLane:536870912,hydrationErrors:null},r=gd(e),r.return=n,n.child=r,jt=n,Ze=null)):e=null,e===null)throw Os(n);return n.lanes=536870912,null}return Pl(n,l)}var f=e.memoizedState;if(f!==null){var p=f.dehydrated;if(Ic(n),c)if(n.flags&256)n.flags&=-257,n=Rm(e,n,r);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(pt||Zi(e,n,r,!1),c=(r&e.childLanes)!==0,pt||c){if(l=Ke,l!==null&&(p=Ss(l,r),p!==0&&p!==f.retryLane))throw f.retryLane=p,pi(e,p),Gt(l,e,p),du;Xl(),n=Rm(e,n,r)}else e=f.treeContext,Ze=xn(p.nextSibling),jt=n,Ue=!0,As=null,yn=!1,e!==null&&xd(n,e),n=Pl(n,l),n.flags|=4096;return n}return e=Zn(e.child,{mode:l.mode,children:l.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Hl(e,n){var r=n.ref;if(r===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(a(284));(e===null||e.ref!==r)&&(n.flags|=4194816)}}function mu(e,n,r,l,c){return xi(n),r=Jc(e,n,r,l,void 0,c),l=Qc(),e!==null&&!pt?(Kc(e,n,c),is(e,n,c)):(Ue&&l&&Tc(n),n.flags|=1,Ot(e,n,r,c),n.child)}function Dm(e,n,r,l,c,f){return xi(n),n.updateQueue=null,r=Ud(n,l,r,c),zd(e),l=Qc(),e!==null&&!pt?(Kc(e,n,f),is(e,n,f)):(Ue&&l&&Tc(n),n.flags|=1,Ot(e,n,r,f),n.child)}function qm(e,n,r,l,c){if(xi(n),n.stateNode===null){var f=Ji,p=r.contextType;typeof p=="object"&&p!==null&&(f=At(p)),f=new r(l,f),n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=fu,n.stateNode=f,f._reactInternals=n,f=n.stateNode,f.props=l,f.state=n.memoizedState,f.refs={},Pc(n),p=r.contextType,f.context=typeof p=="object"&&p!==null?At(p):Ji,f.state=n.memoizedState,p=r.getDerivedStateFromProps,typeof p=="function"&&(uu(n,r,p,l),f.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(p=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),p!==f.state&&fu.enqueueReplaceState(f,f.state,null),aa(n,l,f,c),ra(),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(e===null){f=n.stateNode;var b=n.memoizedProps,N=ji(r,b);f.props=N;var L=f.context,V=r.contextType;p=Ji,typeof V=="object"&&V!==null&&(p=At(V));var W=r.getDerivedStateFromProps;V=typeof W=="function"||typeof f.getSnapshotBeforeUpdate=="function",b=n.pendingProps!==b,V||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(b||L!==p)&&_m(n,f,l,p),Ts=!1;var P=n.memoizedState;f.state=P,aa(n,l,f,c),ra(),L=n.memoizedState,b||P!==L||Ts?(typeof W=="function"&&(uu(n,r,W,l),L=n.memoizedState),(N=Ts||vm(n,r,N,l,P,L,p))?(V||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(n.flags|=4194308)):(typeof f.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=L),f.props=l,f.state=L,f.context=p,l=N):(typeof f.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{f=n.stateNode,Hc(e,n),p=n.memoizedProps,V=ji(r,p),f.props=V,W=n.pendingProps,P=f.context,L=r.contextType,N=Ji,typeof L=="object"&&L!==null&&(N=At(L)),b=r.getDerivedStateFromProps,(L=typeof b=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(p!==W||P!==N)&&_m(n,f,l,N),Ts=!1,P=n.memoizedState,f.state=P,aa(n,l,f,c),ra();var Y=n.memoizedState;p!==W||P!==Y||Ts||e!==null&&e.dependencies!==null&&wl(e.dependencies)?(typeof b=="function"&&(uu(n,r,b,l),Y=n.memoizedState),(V=Ts||vm(n,r,V,l,P,Y,N)||e!==null&&e.dependencies!==null&&wl(e.dependencies))?(L||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(l,Y,N),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(l,Y,N)),typeof f.componentDidUpdate=="function"&&(n.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof f.componentDidUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=Y),f.props=l,f.state=Y,f.context=N,l=V):(typeof f.componentDidUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||p===e.memoizedProps&&P===e.memoizedState||(n.flags|=1024),l=!1)}return f=l,Hl(e,n),l=(n.flags&128)!==0,f||l?(f=n.stateNode,r=l&&typeof r.getDerivedStateFromError!="function"?null:f.render(),n.flags|=1,e!==null&&l?(n.child=Si(n,e.child,null,c),n.child=Si(n,null,r,c)):Ot(e,n,r,c),n.memoizedState=f.state,e=n.child):e=is(e,n,c),e}function zm(e,n,r,l){return yi(),n.flags|=256,Ot(e,n,r,l),n.child}var pu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function gu(e){return{baseLanes:e,cachePool:jd()}}function yu(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=Wt),e}function Um(e,n,r){var l=n.pendingProps,c=!1,f=(n.flags&128)!==0,p;if((p=f)||(p=e!==null&&e.memoizedState===null?!1:(ct.current&2)!==0),p&&(c=!0,n.flags&=-129),p=(n.flags&32)!==0,n.flags&=-33,e===null){if(Ue){if(c?Ms(n):Rs(),(e=Ze)?(e=Vp(e,yn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:js!==null?{id:zn,overflow:Un}:null,retryLane:536870912,hydrationErrors:null},r=gd(e),r.return=n,n.child=r,jt=n,Ze=null)):e=null,e===null)throw Os(n);return Wu(e)?n.lanes=32:n.lanes=536870912,null}var b=l.children;return l=l.fallback,c?(Rs(),c=n.mode,b=$l({mode:"hidden",children:b},c),l=gi(l,c,r,null),b.return=n,l.return=n,b.sibling=l,n.child=b,l=n.child,l.memoizedState=gu(r),l.childLanes=yu(e,p,r),n.memoizedState=pu,fa(null,l)):(Ms(n),bu(n,b))}var N=e.memoizedState;if(N!==null&&(b=N.dehydrated,b!==null)){if(f)n.flags&256?(Ms(n),n.flags&=-257,n=xu(e,n,r)):n.memoizedState!==null?(Rs(),n.child=e.child,n.flags|=128,n=null):(Rs(),b=l.fallback,c=n.mode,l=$l({mode:"visible",children:l.children},c),b=gi(b,c,r,null),b.flags|=2,l.return=n,b.return=n,l.sibling=b,n.child=l,Si(n,e.child,null,r),l=n.child,l.memoizedState=gu(r),l.childLanes=yu(e,p,r),n.memoizedState=pu,n=fa(null,l));else if(Ms(n),Wu(b)){if(p=b.nextSibling&&b.nextSibling.dataset,p)var L=p.dgst;p=L,l=Error(a(419)),l.stack="",l.digest=p,Wr({value:l,source:null,stack:null}),n=xu(e,n,r)}else if(pt||Zi(e,n,r,!1),p=(r&e.childLanes)!==0,pt||p){if(p=Ke,p!==null&&(l=Ss(p,r),l!==0&&l!==N.retryLane))throw N.retryLane=l,pi(e,l),Gt(p,e,l),du;Zu(b)||Xl(),n=xu(e,n,r)}else Zu(b)?(n.flags|=192,n.child=e.child,n=null):(e=N.treeContext,Ze=xn(b.nextSibling),jt=n,Ue=!0,As=null,yn=!1,e!==null&&xd(n,e),n=bu(n,l.children),n.flags|=4096);return n}return c?(Rs(),b=l.fallback,c=n.mode,N=e.child,L=N.sibling,l=Zn(N,{mode:"hidden",children:l.children}),l.subtreeFlags=N.subtreeFlags&65011712,L!==null?b=Zn(L,b):(b=gi(b,c,r,null),b.flags|=2),b.return=n,l.return=n,l.sibling=b,n.child=l,fa(null,l),l=n.child,b=e.child.memoizedState,b===null?b=gu(r):(c=b.cachePool,c!==null?(N=dt._currentValue,c=c.parent!==N?{parent:N,pool:N}:c):c=jd(),b={baseLanes:b.baseLanes|r,cachePool:c}),l.memoizedState=b,l.childLanes=yu(e,p,r),n.memoizedState=pu,fa(e.child,l)):(Ms(n),r=e.child,e=r.sibling,r=Zn(r,{mode:"visible",children:l.children}),r.return=n,r.sibling=null,e!==null&&(p=n.deletions,p===null?(n.deletions=[e],n.flags|=16):p.push(e)),n.child=r,n.memoizedState=null,r)}function bu(e,n){return n=$l({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function $l(e,n){return e=Qt(22,e,null,n),e.lanes=0,e}function xu(e,n,r){return Si(n,e.child,null,r),e=bu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Bm(e,n,r){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Dc(e.return,n,r)}function vu(e,n,r,l,c,f){var p=e.memoizedState;p===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:r,tailMode:c,treeForkCount:f}:(p.isBackwards=n,p.rendering=null,p.renderingStartTime=0,p.last=l,p.tail=r,p.tailMode=c,p.treeForkCount=f)}function Lm(e,n,r){var l=n.pendingProps,c=l.revealOrder,f=l.tail;l=l.children;var p=ct.current,b=(p&2)!==0;if(b?(p=p&1|2,n.flags|=128):p&=1,Me(ct,p),Ot(e,n,l,r),l=Ue?Zr:0,!b&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Bm(e,r,n);else if(e.tag===19)Bm(e,r,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(c){case"forwards":for(r=n.child,c=null;r!==null;)e=r.alternate,e!==null&&kl(e)===null&&(c=r),r=r.sibling;r=c,r===null?(c=n.child,n.child=null):(c=r.sibling,r.sibling=null),vu(n,!1,c,r,f,l);break;case"backwards":case"unstable_legacy-backwards":for(r=null,c=n.child,n.child=null;c!==null;){if(e=c.alternate,e!==null&&kl(e)===null){n.child=c;break}e=c.sibling,c.sibling=r,r=c,c=e}vu(n,!0,r,null,f,l);break;case"together":vu(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function is(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),zs|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(Zi(e,n,r,!1),(r&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,r=Zn(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=Zn(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function _u(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&wl(e)))}function ex(e,n,r){switch(n.tag){case 3:Ct(n,n.stateNode.containerInfo),Ns(n,dt,e.memoizedState.cache),yi();break;case 27:case 5:Mt(n);break;case 4:Ct(n,n.stateNode.containerInfo);break;case 10:Ns(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Ic(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(Ms(n),n.flags|=128,null):(r&n.child.childLanes)!==0?Um(e,n,r):(Ms(n),e=is(e,n,r),e!==null?e.sibling:null);Ms(n);break;case 19:var c=(e.flags&128)!==0;if(l=(r&n.childLanes)!==0,l||(Zi(e,n,r,!1),l=(r&n.childLanes)!==0),c){if(l)return Lm(e,n,r);n.flags|=128}if(c=n.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),Me(ct,ct.current),l)break;return null;case 22:return n.lanes=0,Cm(e,n,r,n.pendingProps);case 24:Ns(n,dt,e.memoizedState.cache)}return is(e,n,r)}function Pm(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)pt=!0;else{if(!_u(e,r)&&(n.flags&128)===0)return pt=!1,ex(e,n,r);pt=(e.flags&131072)!==0}else pt=!1,Ue&&(n.flags&1048576)!==0&&bd(n,Zr,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(e=_i(n.elementType),n.type=e,typeof e=="function")Ac(e)?(l=ji(e,l),n.tag=1,n=qm(null,n,e,l,r)):(n.tag=0,n=mu(null,n,e,l,r));else{if(e!=null){var c=e.$$typeof;if(c===oe){n.tag=11,n=Nm(null,n,e,l,r);break e}else if(c===ne){n.tag=14,n=Tm(null,n,e,l,r);break e}}throw n=he(e)||e,Error(a(306,n,""))}}return n;case 0:return mu(e,n,n.type,n.pendingProps,r);case 1:return l=n.type,c=ji(l,n.pendingProps),qm(e,n,l,c,r);case 3:e:{if(Ct(n,n.stateNode.containerInfo),e===null)throw Error(a(387));l=n.pendingProps;var f=n.memoizedState;c=f.element,Hc(e,n),aa(n,l,null,r);var p=n.memoizedState;if(l=p.cache,Ns(n,dt,l),l!==f.cache&&qc(n,[dt],r,!0),ra(),l=p.element,f.isDehydrated)if(f={element:l,isDehydrated:!1,cache:p.cache},n.updateQueue.baseState=f,n.memoizedState=f,n.flags&256){n=zm(e,n,l,r);break e}else if(l!==c){c=mn(Error(a(424)),n),Wr(c),n=zm(e,n,l,r);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Ze=xn(e.firstChild),jt=n,Ue=!0,As=null,yn=!0,r=Cd(n,null,l,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling}else{if(yi(),l===c){n=is(e,n,r);break e}Ot(e,n,l,r)}n=n.child}return n;case 26:return Hl(e,n),e===null?(r=Xp(n.type,null,n.pendingProps,null))?n.memoizedState=r:Ue||(r=n.type,e=n.pendingProps,l=io(cn.current).createElement(r),l[Qe]=n,l[it]=e,Nt(l,r,e),k(l),n.stateNode=l):n.memoizedState=Xp(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Mt(n),e===null&&Ue&&(l=n.stateNode=Jp(n.type,n.pendingProps,cn.current),jt=n,yn=!0,c=Ze,Hs(n.type)?(ef=c,Ze=xn(l.firstChild)):Ze=c),Ot(e,n,n.pendingProps.children,r),Hl(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Ue&&((c=l=Ze)&&(l=kx(l,n.type,n.pendingProps,yn),l!==null?(n.stateNode=l,jt=n,Ze=xn(l.firstChild),yn=!1,c=!0):c=!1),c||Os(n)),Mt(n),c=n.type,f=n.pendingProps,p=e!==null?e.memoizedProps:null,l=f.children,Qu(c,f)?l=null:p!==null&&Qu(c,p)&&(n.flags|=32),n.memoizedState!==null&&(c=Jc(e,n,Vb,null,null,r),Aa._currentValue=c),Hl(e,n),Ot(e,n,l,r),n.child;case 6:return e===null&&Ue&&((e=r=Ze)&&(r=Cx(r,n.pendingProps,yn),r!==null?(n.stateNode=r,jt=n,Ze=null,e=!0):e=!1),e||Os(n)),null;case 13:return Um(e,n,r);case 4:return Ct(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Si(n,null,l,r):Ot(e,n,l,r),n.child;case 11:return Nm(e,n,n.type,n.pendingProps,r);case 7:return Ot(e,n,n.pendingProps,r),n.child;case 8:return Ot(e,n,n.pendingProps.children,r),n.child;case 12:return Ot(e,n,n.pendingProps.children,r),n.child;case 10:return l=n.pendingProps,Ns(n,n.type,l.value),Ot(e,n,l.children,r),n.child;case 9:return c=n.type._context,l=n.pendingProps.children,xi(n),c=At(c),l=l(c),n.flags|=1,Ot(e,n,l,r),n.child;case 14:return Tm(e,n,n.type,n.pendingProps,r);case 15:return km(e,n,n.type,n.pendingProps,r);case 19:return Lm(e,n,r);case 31:return Wb(e,n,r);case 22:return Cm(e,n,r,n.pendingProps);case 24:return xi(n),l=At(dt),e===null?(c=Bc(),c===null&&(c=Ke,f=zc(),c.pooledCache=f,f.refCount++,f!==null&&(c.pooledCacheLanes|=r),c=f),n.memoizedState={parent:l,cache:c},Pc(n),Ns(n,dt,c)):((e.lanes&r)!==0&&(Hc(e,n),aa(n,null,null,r),ra()),c=e.memoizedState,f=n.memoizedState,c.parent!==l?(c={parent:l,cache:l},n.memoizedState=c,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=c),Ns(n,dt,l)):(l=f.cache,Ns(n,dt,l),l!==c.cache&&qc(n,[dt],r,!0))),Ot(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function rs(e){e.flags|=4}function wu(e,n,r,l,c){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(c&335544128)===c)if(e.stateNode.complete)e.flags|=8192;else if(dp())e.flags|=8192;else throw wi=Al,Lc}else e.flags&=-16777217}function Hm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!n0(n))if(dp())e.flags|=8192;else throw wi=Al,Lc}function Yl(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?Bi():536870912,e.lanes|=n,ur|=n)}function ha(e,n){if(!Ue)switch(e.tailMode){case"hidden":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function We(e){var n=e.alternate!==null&&e.alternate.child===e.child,r=0,l=0;if(n)for(var c=e.child;c!==null;)r|=c.lanes|c.childLanes,l|=c.subtreeFlags&65011712,l|=c.flags&65011712,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)r|=c.lanes|c.childLanes,l|=c.subtreeFlags,l|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=l,e.childLanes=r,n}function tx(e,n,r){var l=n.pendingProps;switch(kc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return We(n),null;case 1:return We(n),null;case 3:return r=n.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),ts(dt),Oe(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Xi(n)?rs(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Mc())),We(n),null;case 26:var c=n.type,f=n.memoizedState;return e===null?(rs(n),f!==null?(We(n),Hm(n,f)):(We(n),wu(n,c,null,l,r))):f?f!==e.memoizedState?(rs(n),We(n),Hm(n,f)):(We(n),n.flags&=-16777217):(e=e.memoizedProps,e!==l&&rs(n),We(n),wu(n,c,e,l,r)),null;case 27:if(ii(n),r=cn.current,c=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==l&&rs(n);else{if(!l){if(n.stateNode===null)throw Error(a(166));return We(n),null}e=lt.current,Xi(n)?vd(n):(e=Jp(c,l,r),n.stateNode=e,rs(n))}return We(n),null;case 5:if(ii(n),c=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==l&&rs(n);else{if(!l){if(n.stateNode===null)throw Error(a(166));return We(n),null}if(f=lt.current,Xi(n))vd(n);else{var p=io(cn.current);switch(f){case 1:f=p.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:f=p.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":f=p.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":f=p.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":f=p.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof l.is=="string"?p.createElement("select",{is:l.is}):p.createElement("select"),l.multiple?f.multiple=!0:l.size&&(f.size=l.size);break;default:f=typeof l.is=="string"?p.createElement(c,{is:l.is}):p.createElement(c)}}f[Qe]=n,f[it]=l;e:for(p=n.child;p!==null;){if(p.tag===5||p.tag===6)f.appendChild(p.stateNode);else if(p.tag!==4&&p.tag!==27&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===n)break e;for(;p.sibling===null;){if(p.return===null||p.return===n)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}n.stateNode=f;e:switch(Nt(f,c,l),c){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&rs(n)}}return We(n),wu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,r),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==l&&rs(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(a(166));if(e=cn.current,Xi(n)){if(e=n.stateNode,r=n.memoizedProps,l=null,c=jt,c!==null)switch(c.tag){case 27:case 5:l=c.memoizedProps}e[Qe]=n,e=!!(e.nodeValue===r||l!==null&&l.suppressHydrationWarning===!0||Up(e.nodeValue,r)),e||Os(n,!0)}else e=io(e).createTextNode(l),e[Qe]=n,n.stateNode=e}return We(n),null;case 31:if(r=n.memoizedState,e===null||e.memoizedState!==null){if(l=Xi(n),r!==null){if(e===null){if(!l)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Qe]=n}else yi(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;We(n),e=!1}else r=Mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),e=!0;if(!e)return n.flags&256?(Xt(n),n):(Xt(n),null);if((n.flags&128)!==0)throw Error(a(558))}return We(n),null;case 13:if(l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(c=Xi(n),l!==null&&l.dehydrated!==null){if(e===null){if(!c)throw Error(a(318));if(c=n.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(a(317));c[Qe]=n}else yi(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;We(n),c=!1}else c=Mc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=c),c=!0;if(!c)return n.flags&256?(Xt(n),n):(Xt(n),null)}return Xt(n),(n.flags&128)!==0?(n.lanes=r,n):(r=l!==null,e=e!==null&&e.memoizedState!==null,r&&(l=n.child,c=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(c=l.alternate.memoizedState.cachePool.pool),f=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(f=l.memoizedState.cachePool.pool),f!==c&&(l.flags|=2048)),r!==e&&r&&(n.child.flags|=8192),Yl(n,n.updateQueue),We(n),null);case 4:return Oe(),e===null&&Gu(n.stateNode.containerInfo),We(n),null;case 10:return ts(n.type),We(n),null;case 19:if(Ae(ct),l=n.memoizedState,l===null)return We(n),null;if(c=(n.flags&128)!==0,f=l.rendering,f===null)if(c)ha(l,!1);else{if(at!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(f=kl(e),f!==null){for(n.flags|=128,ha(l,!1),e=f.updateQueue,n.updateQueue=e,Yl(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)pd(r,e),r=r.sibling;return Me(ct,ct.current&1|2),Ue&&Wn(n,l.treeForkCount),n.child}e=e.sibling}l.tail!==null&&et()>Jl&&(n.flags|=128,c=!0,ha(l,!1),n.lanes=4194304)}else{if(!c)if(e=kl(f),e!==null){if(n.flags|=128,c=!0,e=e.updateQueue,n.updateQueue=e,Yl(n,e),ha(l,!0),l.tail===null&&l.tailMode==="hidden"&&!f.alternate&&!Ue)return We(n),null}else 2*et()-l.renderingStartTime>Jl&&r!==536870912&&(n.flags|=128,c=!0,ha(l,!1),n.lanes=4194304);l.isBackwards?(f.sibling=n.child,n.child=f):(e=l.last,e!==null?e.sibling=f:n.child=f,l.last=f)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=et(),e.sibling=null,r=ct.current,Me(ct,c?r&1|2:r&1),Ue&&Wn(n,l.treeForkCount),e):(We(n),null);case 22:case 23:return Xt(n),Vc(),l=n.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(r&536870912)!==0&&(n.flags&128)===0&&(We(n),n.subtreeFlags&6&&(n.flags|=8192)):We(n),r=n.updateQueue,r!==null&&Yl(n,r.retryQueue),r=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==r&&(n.flags|=2048),e!==null&&Ae(vi),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),ts(dt),We(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function nx(e,n){switch(kc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ts(dt),Oe(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return ii(n),null;case 31:if(n.memoizedState!==null){if(Xt(n),n.alternate===null)throw Error(a(340));yi()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Xt(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));yi()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ae(ct),null;case 4:return Oe(),null;case 10:return ts(n.type),null;case 22:case 23:return Xt(n),Vc(),e!==null&&Ae(vi),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ts(dt),null;case 25:return null;default:return null}}function $m(e,n){switch(kc(n),n.tag){case 3:ts(dt),Oe();break;case 26:case 27:case 5:ii(n);break;case 4:Oe();break;case 31:n.memoizedState!==null&&Xt(n);break;case 13:Xt(n);break;case 19:Ae(ct);break;case 10:ts(n.type);break;case 22:case 23:Xt(n),Vc(),e!==null&&Ae(vi);break;case 24:ts(dt)}}function da(e,n){try{var r=n.updateQueue,l=r!==null?r.lastEffect:null;if(l!==null){var c=l.next;r=c;do{if((r.tag&e)===e){l=void 0;var f=r.create,p=r.inst;l=f(),p.destroy=l}r=r.next}while(r!==c)}}catch(b){Ge(n,n.return,b)}}function Ds(e,n,r){try{var l=n.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var f=c.next;l=f;do{if((l.tag&e)===e){var p=l.inst,b=p.destroy;if(b!==void 0){p.destroy=void 0,c=n;var N=r,L=b;try{L()}catch(V){Ge(c,N,V)}}}l=l.next}while(l!==f)}}catch(V){Ge(n,n.return,V)}}function Ym(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{Rd(n,r)}catch(l){Ge(e,e.return,l)}}}function Gm(e,n,r){r.props=ji(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(l){Ge(e,n,l)}}function ma(e,n){try{var r=e.ref;if(r!==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 r=="function"?e.refCleanup=r(l):r.current=l}}catch(c){Ge(e,n,c)}}function Bn(e,n){var r=e.ref,l=e.refCleanup;if(r!==null)if(typeof l=="function")try{l()}catch(c){Ge(e,n,c)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(c){Ge(e,n,c)}else r.current=null}function Vm(e){var n=e.type,r=e.memoizedProps,l=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&l.focus();break e;case"img":r.src?l.src=r.src:r.srcSet&&(l.srcset=r.srcSet)}}catch(c){Ge(e,e.return,c)}}function Su(e,n,r){try{var l=e.stateNode;Ex(l,e.type,r,n),l[it]=n}catch(c){Ge(e,e.return,c)}}function Im(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Hs(e.type)||e.tag===4}function Eu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Im(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&&Hs(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 ju(e,n,r){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(e,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(e),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=Kn));else if(l!==4&&(l===27&&Hs(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(ju(e,n,r),e=e.sibling;e!==null;)ju(e,n,r),e=e.sibling}function Gl(e,n,r){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?r.insertBefore(e,n):r.appendChild(e);else if(l!==4&&(l===27&&Hs(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(Gl(e,n,r),e=e.sibling;e!==null;)Gl(e,n,r),e=e.sibling}function Fm(e){var n=e.stateNode,r=e.memoizedProps;try{for(var l=e.type,c=n.attributes;c.length;)n.removeAttributeNode(c[0]);Nt(n,l,r),n[Qe]=e,n[it]=r}catch(f){Ge(e,e.return,f)}}var as=!1,gt=!1,Au=!1,Jm=typeof WeakSet=="function"?WeakSet:Set,_t=null;function sx(e,n){if(e=e.containerInfo,Fu=fo,e=ad(e),xc(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var l=r.getSelection&&r.getSelection();if(l&&l.rangeCount!==0){r=l.anchorNode;var c=l.anchorOffset,f=l.focusNode;l=l.focusOffset;try{r.nodeType,f.nodeType}catch{r=null;break e}var p=0,b=-1,N=-1,L=0,V=0,W=e,P=null;t:for(;;){for(var Y;W!==r||c!==0&&W.nodeType!==3||(b=p+c),W!==f||l!==0&&W.nodeType!==3||(N=p+l),W.nodeType===3&&(p+=W.nodeValue.length),(Y=W.firstChild)!==null;)P=W,W=Y;for(;;){if(W===e)break t;if(P===r&&++L===c&&(b=p),P===f&&++V===l&&(N=p),(Y=W.nextSibling)!==null)break;W=P,P=W.parentNode}W=Y}r=b===-1||N===-1?null:{start:b,end:N}}else r=null}r=r||{start:0,end:0}}else r=null;for(Ju={focusedElem:e,selectionRange:r},fo=!1,_t=n;_t!==null;)if(n=_t,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,_t=e;else for(;_t!==null;){switch(n=_t,f=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(r=0;r<e.length;r++)c=e[r],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&f!==null){e=void 0,r=n,c=f.memoizedProps,f=f.memoizedState,l=r.stateNode;try{var pe=ji(r.type,c);e=l.getSnapshotBeforeUpdate(pe,f),l.__reactInternalSnapshotBeforeUpdate=e}catch(_e){Ge(r,r.return,_e)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)Xu(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Xu(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(a(163))}if(e=n.sibling,e!==null){e.return=n.return,_t=e;break}_t=n.return}}function Qm(e,n,r){var l=r.flags;switch(r.tag){case 0:case 11:case 15:os(e,r),l&4&&da(5,r);break;case 1:if(os(e,r),l&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(p){Ge(r,r.return,p)}else{var c=ji(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(c,n,e.__reactInternalSnapshotBeforeUpdate)}catch(p){Ge(r,r.return,p)}}l&64&&Ym(r),l&512&&ma(r,r.return);break;case 3:if(os(e,r),l&64&&(e=r.updateQueue,e!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{Rd(e,n)}catch(p){Ge(r,r.return,p)}}break;case 27:n===null&&l&4&&Fm(r);case 26:case 5:os(e,r),n===null&&l&4&&Vm(r),l&512&&ma(r,r.return);break;case 12:os(e,r);break;case 31:os(e,r),l&4&&Zm(e,r);break;case 13:os(e,r),l&4&&Wm(e,r),l&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=hx.bind(null,r),Mx(e,r))));break;case 22:if(l=r.memoizedState!==null||as,!l){n=n!==null&&n.memoizedState!==null||gt,c=as;var f=gt;as=l,(gt=n)&&!f?cs(e,r,(r.subtreeFlags&8772)!==0):os(e,r),as=c,gt=f}break;case 30:break;default:os(e,r)}}function Km(e){var n=e.alternate;n!==null&&(e.alternate=null,Km(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Li(n)),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 tt=null,Pt=!1;function ls(e,n,r){for(r=r.child;r!==null;)Xm(e,n,r),r=r.sibling}function Xm(e,n,r){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(ai,r)}catch{}switch(r.tag){case 26:gt||Bn(r,n),ls(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:gt||Bn(r,n);var l=tt,c=Pt;Hs(r.type)&&(tt=r.stateNode,Pt=!1),ls(e,n,r),Sa(r.stateNode),tt=l,Pt=c;break;case 5:gt||Bn(r,n);case 6:if(l=tt,c=Pt,tt=null,ls(e,n,r),tt=l,Pt=c,tt!==null)if(Pt)try{(tt.nodeType===9?tt.body:tt.nodeName==="HTML"?tt.ownerDocument.body:tt).removeChild(r.stateNode)}catch(f){Ge(r,n,f)}else try{tt.removeChild(r.stateNode)}catch(f){Ge(r,n,f)}break;case 18:tt!==null&&(Pt?(e=tt,Yp(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),br(e)):Yp(tt,r.stateNode));break;case 4:l=tt,c=Pt,tt=r.stateNode.containerInfo,Pt=!0,ls(e,n,r),tt=l,Pt=c;break;case 0:case 11:case 14:case 15:Ds(2,r,n),gt||Ds(4,r,n),ls(e,n,r);break;case 1:gt||(Bn(r,n),l=r.stateNode,typeof l.componentWillUnmount=="function"&&Gm(r,n,l)),ls(e,n,r);break;case 21:ls(e,n,r);break;case 22:gt=(l=gt)||r.memoizedState!==null,ls(e,n,r),gt=l;break;default:ls(e,n,r)}}function Zm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{br(e)}catch(r){Ge(n,n.return,r)}}}function Wm(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{br(e)}catch(r){Ge(n,n.return,r)}}function ix(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new Jm),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new Jm),n;default:throw Error(a(435,e.tag))}}function Vl(e,n){var r=ix(e);n.forEach(function(l){if(!r.has(l)){r.add(l);var c=dx.bind(null,e,l);l.then(c,c)}})}function Ht(e,n){var r=n.deletions;if(r!==null)for(var l=0;l<r.length;l++){var c=r[l],f=e,p=n,b=p;e:for(;b!==null;){switch(b.tag){case 27:if(Hs(b.type)){tt=b.stateNode,Pt=!1;break e}break;case 5:tt=b.stateNode,Pt=!1;break e;case 3:case 4:tt=b.stateNode.containerInfo,Pt=!0;break e}b=b.return}if(tt===null)throw Error(a(160));Xm(f,p,c),tt=null,Pt=!1,f=c.alternate,f!==null&&(f.return=null),c.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)ep(n,e),n=n.sibling}var Tn=null;function ep(e,n){var r=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ht(n,e),$t(e),l&4&&(Ds(3,e,e.return),da(3,e),Ds(5,e,e.return));break;case 1:Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),l&64&&as&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(r=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=r===null?l:r.concat(l))));break;case 26:var c=Tn;if(Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),l&4){var f=r!==null?r.memoizedState:null;if(l=e.memoizedState,r===null)if(l===null)if(e.stateNode===null){e:{l=e.type,r=e.memoizedProps,c=c.ownerDocument||c;t:switch(l){case"title":f=c.getElementsByTagName("title")[0],(!f||f[xt]||f[Qe]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=c.createElement(l),c.head.insertBefore(f,c.querySelector("head > title"))),Nt(f,l,r),f[Qe]=e,k(f),l=f;break e;case"link":var p=e0("link","href",c).get(l+(r.href||""));if(p){for(var b=0;b<p.length;b++)if(f=p[b],f.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&f.getAttribute("rel")===(r.rel==null?null:r.rel)&&f.getAttribute("title")===(r.title==null?null:r.title)&&f.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){p.splice(b,1);break t}}f=c.createElement(l),Nt(f,l,r),c.head.appendChild(f);break;case"meta":if(p=e0("meta","content",c).get(l+(r.content||""))){for(b=0;b<p.length;b++)if(f=p[b],f.getAttribute("content")===(r.content==null?null:""+r.content)&&f.getAttribute("name")===(r.name==null?null:r.name)&&f.getAttribute("property")===(r.property==null?null:r.property)&&f.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&f.getAttribute("charset")===(r.charSet==null?null:r.charSet)){p.splice(b,1);break t}}f=c.createElement(l),Nt(f,l,r),c.head.appendChild(f);break;default:throw Error(a(468,l))}f[Qe]=e,k(f),l=f}e.stateNode=l}else t0(c,e.type,e.stateNode);else e.stateNode=Wp(c,l,e.memoizedProps);else f!==l?(f===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):f.count--,l===null?t0(c,e.type,e.stateNode):Wp(c,l,e.memoizedProps)):l===null&&e.stateNode!==null&&Su(e,e.memoizedProps,r.memoizedProps)}break;case 27:Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),r!==null&&l&4&&Su(e,e.memoizedProps,r.memoizedProps);break;case 5:if(Ht(n,e),$t(e),l&512&&(gt||r===null||Bn(r,r.return)),e.flags&32){c=e.stateNode;try{Hi(c,"")}catch(pe){Ge(e,e.return,pe)}}l&4&&e.stateNode!=null&&(c=e.memoizedProps,Su(e,c,r!==null?r.memoizedProps:c)),l&1024&&(Au=!0);break;case 6:if(Ht(n,e),$t(e),l&4){if(e.stateNode===null)throw Error(a(162));l=e.memoizedProps,r=e.stateNode;try{r.nodeValue=l}catch(pe){Ge(e,e.return,pe)}}break;case 3:if(lo=null,c=Tn,Tn=ro(n.containerInfo),Ht(n,e),Tn=c,$t(e),l&4&&r!==null&&r.memoizedState.isDehydrated)try{br(n.containerInfo)}catch(pe){Ge(e,e.return,pe)}Au&&(Au=!1,tp(e));break;case 4:l=Tn,Tn=ro(e.stateNode.containerInfo),Ht(n,e),$t(e),Tn=l;break;case 12:Ht(n,e),$t(e);break;case 31:Ht(n,e),$t(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Vl(e,l)));break;case 13:Ht(n,e),$t(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Fl=et()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Vl(e,l)));break;case 22:c=e.memoizedState!==null;var N=r!==null&&r.memoizedState!==null,L=as,V=gt;if(as=L||c,gt=V||N,Ht(n,e),gt=V,as=L,$t(e),l&8192)e:for(n=e.stateNode,n._visibility=c?n._visibility&-2:n._visibility|1,c&&(r===null||N||as||gt||Ai(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){N=r=n;try{if(f=N.stateNode,c)p=f.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none";else{b=N.stateNode;var W=N.memoizedProps.style,P=W!=null&&W.hasOwnProperty("display")?W.display:null;b.style.display=P==null||typeof P=="boolean"?"":(""+P).trim()}}catch(pe){Ge(N,N.return,pe)}}}else if(n.tag===6){if(r===null){N=n;try{N.stateNode.nodeValue=c?"":N.memoizedProps}catch(pe){Ge(N,N.return,pe)}}}else if(n.tag===18){if(r===null){N=n;try{var Y=N.stateNode;c?Gp(Y,!0):Gp(N.stateNode,!1)}catch(pe){Ge(N,N.return,pe)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}l&4&&(l=e.updateQueue,l!==null&&(r=l.retryQueue,r!==null&&(l.retryQueue=null,Vl(e,r))));break;case 19:Ht(n,e),$t(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Vl(e,l)));break;case 30:break;case 21:break;default:Ht(n,e),$t(e)}}function $t(e){var n=e.flags;if(n&2){try{for(var r,l=e.return;l!==null;){if(Im(l)){r=l;break}l=l.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var c=r.stateNode,f=Eu(e);Gl(e,f,c);break;case 5:var p=r.stateNode;r.flags&32&&(Hi(p,""),r.flags&=-33);var b=Eu(e);Gl(e,b,p);break;case 3:case 4:var N=r.stateNode.containerInfo,L=Eu(e);ju(e,L,N);break;default:throw Error(a(161))}}catch(V){Ge(e,e.return,V)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function tp(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;tp(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function os(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Qm(e,n.alternate,n),n=n.sibling}function Ai(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Ds(4,n,n.return),Ai(n);break;case 1:Bn(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&Gm(n,n.return,r),Ai(n);break;case 27:Sa(n.stateNode);case 26:case 5:Bn(n,n.return),Ai(n);break;case 22:n.memoizedState===null&&Ai(n);break;case 30:Ai(n);break;default:Ai(n)}e=e.sibling}}function cs(e,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,c=e,f=n,p=f.flags;switch(f.tag){case 0:case 11:case 15:cs(c,f,r),da(4,f);break;case 1:if(cs(c,f,r),l=f,c=l.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(L){Ge(l,l.return,L)}if(l=f,c=l.updateQueue,c!==null){var b=l.stateNode;try{var N=c.shared.hiddenCallbacks;if(N!==null)for(c.shared.hiddenCallbacks=null,c=0;c<N.length;c++)Md(N[c],b)}catch(L){Ge(l,l.return,L)}}r&&p&64&&Ym(f),ma(f,f.return);break;case 27:Fm(f);case 26:case 5:cs(c,f,r),r&&l===null&&p&4&&Vm(f),ma(f,f.return);break;case 12:cs(c,f,r);break;case 31:cs(c,f,r),r&&p&4&&Zm(c,f);break;case 13:cs(c,f,r),r&&p&4&&Wm(c,f);break;case 22:f.memoizedState===null&&cs(c,f,r),ma(f,f.return);break;case 30:break;default:cs(c,f,r)}n=n.sibling}}function Ou(e,n){var r=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==r&&(e!=null&&e.refCount++,r!=null&&ea(r))}function Nu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ea(e))}function kn(e,n,r,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)np(e,n,r,l),n=n.sibling}function np(e,n,r,l){var c=n.flags;switch(n.tag){case 0:case 11:case 15:kn(e,n,r,l),c&2048&&da(9,n);break;case 1:kn(e,n,r,l);break;case 3:kn(e,n,r,l),c&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ea(e)));break;case 12:if(c&2048){kn(e,n,r,l),e=n.stateNode;try{var f=n.memoizedProps,p=f.id,b=f.onPostCommit;typeof b=="function"&&b(p,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(N){Ge(n,n.return,N)}}else kn(e,n,r,l);break;case 31:kn(e,n,r,l);break;case 13:kn(e,n,r,l);break;case 23:break;case 22:f=n.stateNode,p=n.alternate,n.memoizedState!==null?f._visibility&2?kn(e,n,r,l):pa(e,n):f._visibility&2?kn(e,n,r,l):(f._visibility|=2,lr(e,n,r,l,(n.subtreeFlags&10256)!==0||!1)),c&2048&&Ou(p,n);break;case 24:kn(e,n,r,l),c&2048&&Nu(n.alternate,n);break;default:kn(e,n,r,l)}}function lr(e,n,r,l,c){for(c=c&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var f=e,p=n,b=r,N=l,L=p.flags;switch(p.tag){case 0:case 11:case 15:lr(f,p,b,N,c),da(8,p);break;case 23:break;case 22:var V=p.stateNode;p.memoizedState!==null?V._visibility&2?lr(f,p,b,N,c):pa(f,p):(V._visibility|=2,lr(f,p,b,N,c)),c&&L&2048&&Ou(p.alternate,p);break;case 24:lr(f,p,b,N,c),c&&L&2048&&Nu(p.alternate,p);break;default:lr(f,p,b,N,c)}n=n.sibling}}function pa(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=e,l=n,c=l.flags;switch(l.tag){case 22:pa(r,l),c&2048&&Ou(l.alternate,l);break;case 24:pa(r,l),c&2048&&Nu(l.alternate,l);break;default:pa(r,l)}n=n.sibling}}var ga=8192;function or(e,n,r){if(e.subtreeFlags&ga)for(e=e.child;e!==null;)sp(e,n,r),e=e.sibling}function sp(e,n,r){switch(e.tag){case 26:or(e,n,r),e.flags&ga&&e.memoizedState!==null&&Gx(r,Tn,e.memoizedState,e.memoizedProps);break;case 5:or(e,n,r);break;case 3:case 4:var l=Tn;Tn=ro(e.stateNode.containerInfo),or(e,n,r),Tn=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=ga,ga=16777216,or(e,n,r),ga=l):or(e,n,r));break;default:or(e,n,r)}}function ip(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function ya(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var l=n[r];_t=l,ap(l,e)}ip(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)rp(e),e=e.sibling}function rp(e){switch(e.tag){case 0:case 11:case 15:ya(e),e.flags&2048&&Ds(9,e,e.return);break;case 3:ya(e);break;case 12:ya(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Il(e)):ya(e);break;default:ya(e)}}function Il(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var l=n[r];_t=l,ap(l,e)}ip(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Ds(8,n,n.return),Il(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,Il(n));break;default:Il(n)}e=e.sibling}}function ap(e,n){for(;_t!==null;){var r=_t;switch(r.tag){case 0:case 11:case 15:Ds(8,r,n);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var l=r.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:ea(r.memoizedState.cache)}if(l=r.child,l!==null)l.return=r,_t=l;else e:for(r=e;_t!==null;){l=_t;var c=l.sibling,f=l.return;if(Km(l),l===r){_t=null;break e}if(c!==null){c.return=f,_t=c;break e}_t=f}}}var rx={getCacheForType:function(e){var n=At(dt),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r},cacheSignal:function(){return At(dt).controller.signal}},ax=typeof WeakMap=="function"?WeakMap:Map,$e=0,Ke=null,Re=null,qe=0,Ye=0,Zt=null,qs=!1,cr=!1,Tu=!1,us=0,at=0,zs=0,Oi=0,ku=0,Wt=0,ur=0,ba=null,Yt=null,Cu=!1,Fl=0,lp=0,Jl=1/0,Ql=null,Us=null,vt=0,Bs=null,fr=null,fs=0,Mu=0,Ru=null,op=null,xa=0,Du=null;function en(){return($e&2)!==0&&qe!==0?qe&-qe:$.T!==null?Pu():Hr()}function cp(){if(Wt===0)if((qe&536870912)===0||Ue){var e=Fn;Fn<<=1,(Fn&3932160)===0&&(Fn=262144),Wt=e}else Wt=536870912;return e=Kt.current,e!==null&&(e.flags|=32),Wt}function Gt(e,n,r){(e===Ke&&(Ye===2||Ye===9)||e.cancelPendingCommit!==null)&&(hr(e,0),Ls(e,qe,Wt,!1)),An(e,r),(($e&2)===0||e!==Ke)&&(e===Ke&&(($e&2)===0&&(Oi|=r),at===4&&Ls(e,qe,Wt,!1)),Ln(e))}function up(e,n,r){if(($e&6)!==0)throw Error(a(327));var l=!r&&(n&127)===0&&(n&e.expiredLanes)===0||oi(e,n),c=l?cx(e,n):zu(e,n,!0),f=l;do{if(c===0){cr&&!l&&Ls(e,n,0,!1);break}else{if(r=e.current.alternate,f&&!lx(r)){c=zu(e,n,!1),f=!1;continue}if(c===2){if(f=n,e.errorRecoveryDisabledLanes&f)var p=0;else p=e.pendingLanes&-536870913,p=p!==0?p:p&536870912?536870912:0;if(p!==0){n=p;e:{var b=e;c=ba;var N=b.current.memoizedState.isDehydrated;if(N&&(hr(b,p).flags|=256),p=zu(b,p,!1),p!==2){if(Tu&&!N){b.errorRecoveryDisabledLanes|=f,Oi|=f,c=4;break e}f=Yt,Yt=c,f!==null&&(Yt===null?Yt=f:Yt.push.apply(Yt,f))}c=p}if(f=!1,c!==2)continue}}if(c===1){hr(e,0),Ls(e,n,0,!0);break}e:{switch(l=e,f=c,f){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:Ls(l,n,Wt,!qs);break e;case 2:Yt=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(c=Fl+300-et(),10<c)){if(Ls(l,n,Wt,!qs),li(l,0,!0)!==0)break e;fs=n,l.timeoutHandle=Hp(fp.bind(null,l,r,Yt,Ql,Cu,n,Wt,Oi,ur,qs,f,"Throttled",-0,0),c);break e}fp(l,r,Yt,Ql,Cu,n,Wt,Oi,ur,qs,f,null,-0,0)}}break}while(!0);Ln(e)}function fp(e,n,r,l,c,f,p,b,N,L,V,W,P,Y){if(e.timeoutHandle=-1,W=n.subtreeFlags,W&8192||(W&16785408)===16785408){W={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Kn},sp(n,f,W);var pe=(f&62914560)===f?Fl-et():(f&4194048)===f?lp-et():0;if(pe=Vx(W,pe),pe!==null){fs=f,e.cancelPendingCommit=pe(xp.bind(null,e,n,f,r,l,c,p,b,N,V,W,null,P,Y)),Ls(e,f,p,!L);return}}xp(e,n,f,r,l,c,p,b,N)}function lx(e){for(var n=e;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var l=0;l<r.length;l++){var c=r[l],f=c.getSnapshot;c=c.value;try{if(!Jt(f(),c))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Ls(e,n,r,l){n&=~ku,n&=~Oi,e.suspendedLanes|=n,e.pingedLanes&=~n,l&&(e.warmLanes|=n),l=e.expirationTimes;for(var c=n;0<c;){var f=31-Rt(c),p=1<<f;l[f]=-1,c&=~p}r!==0&&ws(e,r,n)}function Kl(){return($e&6)===0?(va(0),!1):!0}function qu(){if(Re!==null){if(Ye===0)var e=Re.return;else e=Re,es=bi=null,Xc(e),nr=null,na=0,e=Re;for(;e!==null;)$m(e.alternate,e),e=e.return;Re=null}}function hr(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,Ox(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),fs=0,qu(),Ke=e,Re=r=Zn(e.current,null),qe=n,Ye=0,Zt=null,qs=!1,cr=oi(e,n),Tu=!1,ur=Wt=ku=Oi=zs=at=0,Yt=ba=null,Cu=!1,(n&8)!==0&&(n|=n&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=n;0<l;){var c=31-Rt(l),f=1<<c;n|=e[c],l&=~f}return us=n,yl(),r}function hp(e,n){Ne=null,$.H=ua,n===tr||n===jl?(n=Nd(),Ye=3):n===Lc?(n=Nd(),Ye=4):Ye=n===du?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Zt=n,Re===null&&(at=1,Ll(e,mn(n,e.current)))}function dp(){var e=Kt.current;return e===null?!0:(qe&4194048)===qe?bn===null:(qe&62914560)===qe||(qe&536870912)!==0?e===bn:!1}function mp(){var e=$.H;return $.H=ua,e===null?ua:e}function pp(){var e=$.A;return $.A=rx,e}function Xl(){at=4,qs||(qe&4194048)!==qe&&Kt.current!==null||(cr=!0),(zs&134217727)===0&&(Oi&134217727)===0||Ke===null||Ls(Ke,qe,Wt,!1)}function zu(e,n,r){var l=$e;$e|=2;var c=mp(),f=pp();(Ke!==e||qe!==n)&&(Ql=null,hr(e,n)),n=!1;var p=at;e:do try{if(Ye!==0&&Re!==null){var b=Re,N=Zt;switch(Ye){case 8:qu(),p=6;break e;case 3:case 2:case 9:case 6:Kt.current===null&&(n=!0);var L=Ye;if(Ye=0,Zt=null,dr(e,b,N,L),r&&cr){p=0;break e}break;default:L=Ye,Ye=0,Zt=null,dr(e,b,N,L)}}ox(),p=at;break}catch(V){hp(e,V)}while(!0);return n&&e.shellSuspendCounter++,es=bi=null,$e=l,$.H=c,$.A=f,Re===null&&(Ke=null,qe=0,yl()),p}function ox(){for(;Re!==null;)gp(Re)}function cx(e,n){var r=$e;$e|=2;var l=mp(),c=pp();Ke!==e||qe!==n?(Ql=null,Jl=et()+500,hr(e,n)):cr=oi(e,n);e:do try{if(Ye!==0&&Re!==null){n=Re;var f=Zt;t:switch(Ye){case 1:Ye=0,Zt=null,dr(e,n,f,1);break;case 2:case 9:if(Ad(f)){Ye=0,Zt=null,yp(n);break}n=function(){Ye!==2&&Ye!==9||Ke!==e||(Ye=7),Ln(e)},f.then(n,n);break e;case 3:Ye=7;break e;case 4:Ye=5;break e;case 7:Ad(f)?(Ye=0,Zt=null,yp(n)):(Ye=0,Zt=null,dr(e,n,f,7));break;case 5:var p=null;switch(Re.tag){case 26:p=Re.memoizedState;case 5:case 27:var b=Re;if(p?n0(p):b.stateNode.complete){Ye=0,Zt=null;var N=b.sibling;if(N!==null)Re=N;else{var L=b.return;L!==null?(Re=L,Zl(L)):Re=null}break t}}Ye=0,Zt=null,dr(e,n,f,5);break;case 6:Ye=0,Zt=null,dr(e,n,f,6);break;case 8:qu(),at=6;break e;default:throw Error(a(462))}}ux();break}catch(V){hp(e,V)}while(!0);return es=bi=null,$.H=l,$.A=c,$e=r,Re!==null?0:(Ke=null,qe=0,yl(),at)}function ux(){for(;Re!==null&&!el();)gp(Re)}function gp(e){var n=Pm(e.alternate,e,us);e.memoizedProps=e.pendingProps,n===null?Zl(e):Re=n}function yp(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=Dm(r,n,n.pendingProps,n.type,void 0,qe);break;case 11:n=Dm(r,n,n.pendingProps,n.type.render,n.ref,qe);break;case 5:Xc(n);default:$m(r,n),n=Re=pd(n,us),n=Pm(r,n,us)}e.memoizedProps=e.pendingProps,n===null?Zl(e):Re=n}function dr(e,n,r,l){es=bi=null,Xc(n),nr=null,na=0;var c=n.return;try{if(Zb(e,c,n,r,qe)){at=1,Ll(e,mn(r,e.current)),Re=null;return}}catch(f){if(c!==null)throw Re=c,f;at=1,Ll(e,mn(r,e.current)),Re=null;return}n.flags&32768?(Ue||l===1?e=!0:cr||(qe&536870912)!==0?e=!1:(qs=e=!0,(l===2||l===9||l===3||l===6)&&(l=Kt.current,l!==null&&l.tag===13&&(l.flags|=16384))),bp(n,e)):Zl(n)}function Zl(e){var n=e;do{if((n.flags&32768)!==0){bp(n,qs);return}e=n.return;var r=tx(n.alternate,n,us);if(r!==null){Re=r;return}if(n=n.sibling,n!==null){Re=n;return}Re=n=e}while(n!==null);at===0&&(at=5)}function bp(e,n){do{var r=nx(e.alternate,e);if(r!==null){r.flags&=32767,Re=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Re=e;return}Re=e=r}while(e!==null);at=6,Re=null}function xp(e,n,r,l,c,f,p,b,N){e.cancelPendingCommit=null;do Wl();while(vt!==0);if(($e&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(f=n.lanes|n.childLanes,f|=Ec,_s(e,r,f,p,b,N),e===Ke&&(Re=Ke=null,qe=0),fr=n,Bs=e,fs=r,Mu=f,Ru=c,op=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,mx(zi,function(){return Ep(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=$.T,$.T=null,c=se.p,se.p=2,p=$e,$e|=4;try{sx(e,n,r)}finally{$e=p,se.p=c,$.T=l}}vt=1,vp(),_p(),wp()}}function vp(){if(vt===1){vt=0;var e=Bs,n=fr,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=$.T,$.T=null;var l=se.p;se.p=2;var c=$e;$e|=4;try{ep(n,e);var f=Ju,p=ad(e.containerInfo),b=f.focusedElem,N=f.selectionRange;if(p!==b&&b&&b.ownerDocument&&rd(b.ownerDocument.documentElement,b)){if(N!==null&&xc(b)){var L=N.start,V=N.end;if(V===void 0&&(V=L),"selectionStart"in b)b.selectionStart=L,b.selectionEnd=Math.min(V,b.value.length);else{var W=b.ownerDocument||document,P=W&&W.defaultView||window;if(P.getSelection){var Y=P.getSelection(),pe=b.textContent.length,_e=Math.min(N.start,pe),Je=N.end===void 0?_e:Math.min(N.end,pe);!Y.extend&&_e>Je&&(p=Je,Je=_e,_e=p);var q=id(b,_e),M=id(b,Je);if(q&&M&&(Y.rangeCount!==1||Y.anchorNode!==q.node||Y.anchorOffset!==q.offset||Y.focusNode!==M.node||Y.focusOffset!==M.offset)){var B=W.createRange();B.setStart(q.node,q.offset),Y.removeAllRanges(),_e>Je?(Y.addRange(B),Y.extend(M.node,M.offset)):(B.setEnd(M.node,M.offset),Y.addRange(B))}}}}for(W=[],Y=b;Y=Y.parentNode;)Y.nodeType===1&&W.push({element:Y,left:Y.scrollLeft,top:Y.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b<W.length;b++){var J=W[b];J.element.scrollLeft=J.left,J.element.scrollTop=J.top}}fo=!!Fu,Ju=Fu=null}finally{$e=c,se.p=l,$.T=r}}e.current=n,vt=2}}function _p(){if(vt===2){vt=0;var e=Bs,n=fr,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=$.T,$.T=null;var l=se.p;se.p=2;var c=$e;$e|=4;try{Qm(e,n.alternate,n)}finally{$e=c,se.p=l,$.T=r}}vt=3}}function wp(){if(vt===4||vt===3){vt=0,qi();var e=Bs,n=fr,r=fs,l=op;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?vt=5:(vt=0,fr=Bs=null,Sp(e,e.pendingLanes));var c=e.pendingLanes;if(c===0&&(Us=null),ui(r),n=n.stateNode,ot&&typeof ot.onCommitFiberRoot=="function")try{ot.onCommitFiberRoot(ai,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=$.T,c=se.p,se.p=2,$.T=null;try{for(var f=e.onRecoverableError,p=0;p<l.length;p++){var b=l[p];f(b.value,{componentStack:b.stack})}}finally{$.T=n,se.p=c}}(fs&3)!==0&&Wl(),Ln(e),c=e.pendingLanes,(r&261930)!==0&&(c&42)!==0?e===Du?xa++:(xa=0,Du=e):xa=0,va(0)}}function Sp(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,ea(n)))}function Wl(){return vp(),_p(),wp(),Ep()}function Ep(){if(vt!==5)return!1;var e=Bs,n=Mu;Mu=0;var r=ui(fs),l=$.T,c=se.p;try{se.p=32>r?32:r,$.T=null,r=Ru,Ru=null;var f=Bs,p=fs;if(vt=0,fr=Bs=null,fs=0,($e&6)!==0)throw Error(a(331));var b=$e;if($e|=4,rp(f.current),np(f,f.current,p,r),$e=b,va(0,!1),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(ai,f)}catch{}return!0}finally{se.p=c,$.T=l,Sp(e,n)}}function jp(e,n,r){n=mn(r,n),n=hu(e.stateNode,n,2),e=Cs(e,n,2),e!==null&&(An(e,2),Ln(e))}function Ge(e,n,r){if(e.tag===3)jp(e,e,r);else for(;n!==null;){if(n.tag===3){jp(n,e,r);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Us===null||!Us.has(l))){e=mn(r,e),r=Am(2),l=Cs(n,r,2),l!==null&&(Om(r,l,n,e),An(l,2),Ln(l));break}}n=n.return}}function Uu(e,n,r){var l=e.pingCache;if(l===null){l=e.pingCache=new ax;var c=new Set;l.set(n,c)}else c=l.get(n),c===void 0&&(c=new Set,l.set(n,c));c.has(r)||(Tu=!0,c.add(r),e=fx.bind(null,e,n,r),n.then(e,e))}function fx(e,n,r){var l=e.pingCache;l!==null&&l.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,Ke===e&&(qe&r)===r&&(at===4||at===3&&(qe&62914560)===qe&&300>et()-Fl?($e&2)===0&&hr(e,0):ku|=r,ur===qe&&(ur=0)),Ln(e)}function Ap(e,n){n===0&&(n=Bi()),e=pi(e,n),e!==null&&(An(e,n),Ln(e))}function hx(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),Ap(e,r)}function dx(e,n){var r=0;switch(e.tag){case 31:case 13:var l=e.stateNode,c=e.memoizedState;c!==null&&(r=c.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(a(314))}l!==null&&l.delete(n),Ap(e,r)}function mx(e,n){return Ur(e,n)}var eo=null,mr=null,Bu=!1,to=!1,Lu=!1,Ps=0;function Ln(e){e!==mr&&e.next===null&&(mr===null?eo=mr=e:mr=mr.next=e),to=!0,Bu||(Bu=!0,gx())}function va(e,n){if(!Lu&&to){Lu=!0;do for(var r=!1,l=eo;l!==null;){if(e!==0){var c=l.pendingLanes;if(c===0)var f=0;else{var p=l.suspendedLanes,b=l.pingedLanes;f=(1<<31-Rt(42|e)+1)-1,f&=c&~(p&~b),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(r=!0,kp(l,f))}else f=qe,f=li(l,l===Ke?f:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(f&3)===0||oi(l,f)||(r=!0,kp(l,f));l=l.next}while(r);Lu=!1}}function px(){Op()}function Op(){to=Bu=!1;var e=0;Ps!==0&&Ax()&&(e=Ps);for(var n=et(),r=null,l=eo;l!==null;){var c=l.next,f=Np(l,n);f===0?(l.next=null,r===null?eo=c:r.next=c,c===null&&(mr=r)):(r=l,(e!==0||(f&3)!==0)&&(to=!0)),l=c}vt!==0&&vt!==5||va(e),Ps!==0&&(Ps=0)}function Np(e,n){for(var r=e.suspendedLanes,l=e.pingedLanes,c=e.expirationTimes,f=e.pendingLanes&-62914561;0<f;){var p=31-Rt(f),b=1<<p,N=c[p];N===-1?((b&r)===0||(b&l)!==0)&&(c[p]=Pr(b,n)):N<=n&&(e.expiredLanes|=b),f&=~b}if(n=Ke,r=qe,r=li(e,e===n?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,r===0||e===n&&(Ye===2||Ye===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&In(l),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||oi(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(l!==null&&In(l),ui(r)){case 2:case 8:r=nl;break;case 32:r=zi;break;case 268435456:r=sl;break;default:r=zi}return l=Tp.bind(null,e),r=Ur(r,l),e.callbackPriority=n,e.callbackNode=r,n}return l!==null&&l!==null&&In(l),e.callbackPriority=2,e.callbackNode=null,2}function Tp(e,n){if(vt!==0&&vt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(Wl()&&e.callbackNode!==r)return null;var l=qe;return l=li(e,e===Ke?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(up(e,l,n),Np(e,et()),e.callbackNode!=null&&e.callbackNode===r?Tp.bind(null,e):null)}function kp(e,n){if(Wl())return null;up(e,n,!0)}function gx(){Nx(function(){($e&6)!==0?Ur(tl,px):Op()})}function Pu(){if(Ps===0){var e=Wi;e===0&&(e=bs,bs<<=1,(bs&261888)===0&&(bs=256)),Ps=e}return Ps}function Cp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:cl(""+e)}function Mp(e,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,e.id&&r.setAttribute("form",e.id),n.parentNode.insertBefore(r,n),e=new FormData(e),r.parentNode.removeChild(r),e}function yx(e,n,r,l,c){if(n==="submit"&&r&&r.stateNode===c){var f=Cp((c[it]||null).action),p=l.submitter;p&&(n=(n=p[it]||null)?Cp(n.formAction):p.getAttribute("formAction"),n!==null&&(f=n,p=null));var b=new dl("action","action",null,l,c);e.push({event:b,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ps!==0){var N=p?Mp(c,p):new FormData(c);au(r,{pending:!0,data:N,method:c.method,action:f},null,N)}}else typeof f=="function"&&(b.preventDefault(),N=p?Mp(c,p):new FormData(c),au(r,{pending:!0,data:N,method:c.method,action:f},f,N))},currentTarget:c}]})}}for(var Hu=0;Hu<Sc.length;Hu++){var $u=Sc[Hu],bx=$u.toLowerCase(),xx=$u[0].toUpperCase()+$u.slice(1);Nn(bx,"on"+xx)}Nn(cd,"onAnimationEnd"),Nn(ud,"onAnimationIteration"),Nn(fd,"onAnimationStart"),Nn("dblclick","onDoubleClick"),Nn("focusin","onFocus"),Nn("focusout","onBlur"),Nn(qb,"onTransitionRun"),Nn(zb,"onTransitionStart"),Nn(Ub,"onTransitionCancel"),Nn(hd,"onTransitionEnd"),H("onMouseEnter",["mouseout","mouseover"]),H("onMouseLeave",["mouseout","mouseover"]),H("onPointerEnter",["pointerout","pointerover"]),H("onPointerLeave",["pointerout","pointerover"]),ee("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ee("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ee("onBeforeInput",["compositionend","keypress","textInput","paste"]),ee("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ee("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ee("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _a="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(" "),vx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(_a));function Rp(e,n){n=(n&4)!==0;for(var r=0;r<e.length;r++){var l=e[r],c=l.event;l=l.listeners;e:{var f=void 0;if(n)for(var p=l.length-1;0<=p;p--){var b=l[p],N=b.instance,L=b.currentTarget;if(b=b.listener,N!==f&&c.isPropagationStopped())break e;f=b,c.currentTarget=L;try{f(c)}catch(V){gl(V)}c.currentTarget=null,f=N}else for(p=0;p<l.length;p++){if(b=l[p],N=b.instance,L=b.currentTarget,b=b.listener,N!==f&&c.isPropagationStopped())break e;f=b,c.currentTarget=L;try{f(c)}catch(V){gl(V)}c.currentTarget=null,f=N}}}}function De(e,n){var r=n[fi];r===void 0&&(r=n[fi]=new Set);var l=e+"__bubble";r.has(l)||(Dp(n,e,2,!1),r.add(l))}function Yu(e,n,r){var l=0;n&&(l|=4),Dp(r,e,l,n)}var no="_reactListening"+Math.random().toString(36).slice(2);function Gu(e){if(!e[no]){e[no]=!0,z.forEach(function(r){r!=="selectionchange"&&(vx.has(r)||Yu(r,!1,e),Yu(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[no]||(n[no]=!0,Yu("selectionchange",!1,n))}}function Dp(e,n,r,l){switch(c0(n)){case 2:var c=Jx;break;case 8:c=Qx;break;default:c=af}r=c.bind(null,n,r,e),c=void 0,!uc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(c=!0),l?c!==void 0?e.addEventListener(n,r,{capture:!0,passive:c}):e.addEventListener(n,r,!0):c!==void 0?e.addEventListener(n,r,{passive:c}):e.addEventListener(n,r,!1)}function Vu(e,n,r,l,c){var f=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var p=l.tag;if(p===3||p===4){var b=l.stateNode.containerInfo;if(b===c)break;if(p===4)for(p=l.return;p!==null;){var N=p.tag;if((N===3||N===4)&&p.stateNode.containerInfo===c)return;p=p.return}for(;b!==null;){if(p=x(b),p===null)return;if(N=p.tag,N===5||N===6||N===26||N===27){l=f=p;continue e}b=b.parentNode}}l=l.return}Lh(function(){var L=f,V=oc(r),W=[];e:{var P=dd.get(e);if(P!==void 0){var Y=dl,pe=e;switch(e){case"keypress":if(fl(r)===0)break e;case"keydown":case"keyup":Y=db;break;case"focusin":pe="focus",Y=mc;break;case"focusout":pe="blur",Y=mc;break;case"beforeblur":case"afterblur":Y=mc;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Y=$h;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Y=tb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Y=gb;break;case cd:case ud:case fd:Y=ib;break;case hd:Y=bb;break;case"scroll":case"scrollend":Y=Wy;break;case"wheel":Y=vb;break;case"copy":case"cut":case"paste":Y=ab;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Y=Gh;break;case"toggle":case"beforetoggle":Y=wb}var _e=(n&4)!==0,Je=!_e&&(e==="scroll"||e==="scrollend"),q=_e?P!==null?P+"Capture":null:P;_e=[];for(var M=L,B;M!==null;){var J=M;if(B=J.stateNode,J=J.tag,J!==5&&J!==26&&J!==27||B===null||q===null||(J=Yr(M,q),J!=null&&_e.push(wa(M,J,B))),Je)break;M=M.return}0<_e.length&&(P=new Y(P,pe,null,r,V),W.push({event:P,listeners:_e}))}}if((n&7)===0){e:{if(P=e==="mouseover"||e==="pointerover",Y=e==="mouseout"||e==="pointerout",P&&r!==lc&&(pe=r.relatedTarget||r.fromElement)&&(x(pe)||pe[Ft]))break e;if((Y||P)&&(P=V.window===V?V:(P=V.ownerDocument)?P.defaultView||P.parentWindow:window,Y?(pe=r.relatedTarget||r.toElement,Y=L,pe=pe?x(pe):null,pe!==null&&(Je=u(pe),_e=pe.tag,pe!==Je||_e!==5&&_e!==27&&_e!==6)&&(pe=null)):(Y=null,pe=L),Y!==pe)){if(_e=$h,J="onMouseLeave",q="onMouseEnter",M="mouse",(e==="pointerout"||e==="pointerover")&&(_e=Gh,J="onPointerLeave",q="onPointerEnter",M="pointer"),Je=Y==null?P:w(Y),B=pe==null?P:w(pe),P=new _e(J,M+"leave",Y,r,V),P.target=Je,P.relatedTarget=B,J=null,x(V)===L&&(_e=new _e(q,M+"enter",pe,r,V),_e.target=B,_e.relatedTarget=Je,J=_e),Je=J,Y&&pe)t:{for(_e=_x,q=Y,M=pe,B=0,J=q;J;J=_e(J))B++;J=0;for(var ye=M;ye;ye=_e(ye))J++;for(;0<B-J;)q=_e(q),B--;for(;0<J-B;)M=_e(M),J--;for(;B--;){if(q===M||M!==null&&q===M.alternate){_e=q;break t}q=_e(q),M=_e(M)}_e=null}else _e=null;Y!==null&&qp(W,P,Y,_e,!1),pe!==null&&Je!==null&&qp(W,Je,pe,_e,!0)}}e:{if(P=L?w(L):window,Y=P.nodeName&&P.nodeName.toLowerCase(),Y==="select"||Y==="input"&&P.type==="file")var Pe=Zh;else if(Kh(P))if(Wh)Pe=Mb;else{Pe=kb;var ge=Tb}else Y=P.nodeName,!Y||Y.toLowerCase()!=="input"||P.type!=="checkbox"&&P.type!=="radio"?L&&ac(L.elementType)&&(Pe=Zh):Pe=Cb;if(Pe&&(Pe=Pe(e,L))){Xh(W,Pe,r,V);break e}ge&&ge(e,P,L),e==="focusout"&&L&&P.type==="number"&&L.memoizedProps.value!=null&&rc(P,"number",P.value)}switch(ge=L?w(L):window,e){case"focusin":(Kh(ge)||ge.contentEditable==="true")&&(Vi=ge,vc=L,Xr=null);break;case"focusout":Xr=vc=Vi=null;break;case"mousedown":_c=!0;break;case"contextmenu":case"mouseup":case"dragend":_c=!1,ld(W,r,V);break;case"selectionchange":if(Db)break;case"keydown":case"keyup":ld(W,r,V)}var Te;if(gc)e:{switch(e){case"compositionstart":var ze="onCompositionStart";break e;case"compositionend":ze="onCompositionEnd";break e;case"compositionupdate":ze="onCompositionUpdate";break e}ze=void 0}else Gi?Jh(e,r)&&(ze="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(ze="onCompositionStart");ze&&(Vh&&r.locale!=="ko"&&(Gi||ze!=="onCompositionStart"?ze==="onCompositionEnd"&&Gi&&(Te=Ph()):(Es=V,fc="value"in Es?Es.value:Es.textContent,Gi=!0)),ge=so(L,ze),0<ge.length&&(ze=new Yh(ze,e,null,r,V),W.push({event:ze,listeners:ge}),Te?ze.data=Te:(Te=Qh(r),Te!==null&&(ze.data=Te)))),(Te=Eb?jb(e,r):Ab(e,r))&&(ze=so(L,"onBeforeInput"),0<ze.length&&(ge=new Yh("onBeforeInput","beforeinput",null,r,V),W.push({event:ge,listeners:ze}),ge.data=Te)),yx(W,e,L,r,V)}Rp(W,n)})}function wa(e,n,r){return{instance:e,listener:n,currentTarget:r}}function so(e,n){for(var r=n+"Capture",l=[];e!==null;){var c=e,f=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||f===null||(c=Yr(e,r),c!=null&&l.unshift(wa(e,c,f)),c=Yr(e,n),c!=null&&l.push(wa(e,c,f))),e.tag===3)return l;e=e.return}return[]}function _x(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function qp(e,n,r,l,c){for(var f=n._reactName,p=[];r!==null&&r!==l;){var b=r,N=b.alternate,L=b.stateNode;if(b=b.tag,N!==null&&N===l)break;b!==5&&b!==26&&b!==27||L===null||(N=L,c?(L=Yr(r,f),L!=null&&p.unshift(wa(r,L,N))):c||(L=Yr(r,f),L!=null&&p.push(wa(r,L,N)))),r=r.return}p.length!==0&&e.push({event:n,listeners:p})}var wx=/\r\n?/g,Sx=/\u0000|\uFFFD/g;function zp(e){return(typeof e=="string"?e:""+e).replace(wx,`
26
+ `).replace(Sx,"")}function Up(e,n){return n=zp(n),zp(e)===n}function Fe(e,n,r,l,c,f){switch(r){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||Hi(e,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&Hi(e,""+l);break;case"className":On(e,"class",l);break;case"tabIndex":On(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":On(e,r,l);break;case"style":Uh(e,l,f);break;case"data":if(n!=="object"){On(e,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||r!=="href")){e.removeAttribute(r);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(r);break}l=cl(""+l),e.setAttribute(r,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(r,"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 f=="function"&&(r==="formAction"?(n!=="input"&&Fe(e,n,"name",c.name,c,null),Fe(e,n,"formEncType",c.formEncType,c,null),Fe(e,n,"formMethod",c.formMethod,c,null),Fe(e,n,"formTarget",c.formTarget,c,null)):(Fe(e,n,"encType",c.encType,c,null),Fe(e,n,"method",c.method,c,null),Fe(e,n,"target",c.target,c,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(r);break}l=cl(""+l),e.setAttribute(r,l);break;case"onClick":l!=null&&(e.onclick=Kn);break;case"onScroll":l!=null&&De("scroll",e);break;case"onScrollEnd":l!=null&&De("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(a(61));if(r=l.__html,r!=null){if(c.children!=null)throw Error(a(60));e.innerHTML=r}}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}r=cl(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);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(r,""+l):e.removeAttribute(r);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(r,""):e.removeAttribute(r);break;case"capture":case"download":l===!0?e.setAttribute(r,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(r,l):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(r,l):e.removeAttribute(r);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(r):e.setAttribute(r,l);break;case"popover":De("beforetoggle",e),De("toggle",e),Dt(e,"popover",l);break;case"xlinkActuate":Qn(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Qn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Qn(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Qn(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Qn(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Qn(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Qn(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Qn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Qn(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Dt(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=Xy.get(r)||r,Dt(e,r,l))}}function Iu(e,n,r,l,c,f){switch(r){case"style":Uh(e,l,f);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(a(61));if(r=l.__html,r!=null){if(c.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"children":typeof l=="string"?Hi(e,l):(typeof l=="number"||typeof l=="bigint")&&Hi(e,""+l);break;case"onScroll":l!=null&&De("scroll",e);break;case"onScrollEnd":l!=null&&De("scrollend",e);break;case"onClick":l!=null&&(e.onclick=Kn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!K.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(c=r.endsWith("Capture"),n=r.slice(2,c?r.length-7:void 0),f=e[it]||null,f=f!=null?f[r]:null,typeof f=="function"&&e.removeEventListener(n,f,c),typeof l=="function")){typeof f!="function"&&f!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(n,l,c);break e}r in e?e[r]=l:l===!0?e.setAttribute(r,""):Dt(e,r,l)}}}function Nt(e,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":De("error",e),De("load",e);var l=!1,c=!1,f;for(f in r)if(r.hasOwnProperty(f)){var p=r[f];if(p!=null)switch(f){case"src":l=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:Fe(e,n,f,p,r,null)}}c&&Fe(e,n,"srcSet",r.srcSet,r,null),l&&Fe(e,n,"src",r.src,r,null);return;case"input":De("invalid",e);var b=f=p=c=null,N=null,L=null;for(l in r)if(r.hasOwnProperty(l)){var V=r[l];if(V!=null)switch(l){case"name":c=V;break;case"type":p=V;break;case"checked":N=V;break;case"defaultChecked":L=V;break;case"value":f=V;break;case"defaultValue":b=V;break;case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(a(137,n));break;default:Fe(e,n,l,V,r,null)}}Rh(e,f,b,N,L,p,c,!1);return;case"select":De("invalid",e),l=p=f=null;for(c in r)if(r.hasOwnProperty(c)&&(b=r[c],b!=null))switch(c){case"value":f=b;break;case"defaultValue":p=b;break;case"multiple":l=b;default:Fe(e,n,c,b,r,null)}n=f,r=p,e.multiple=!!l,n!=null?Pi(e,!!l,n,!1):r!=null&&Pi(e,!!l,r,!0);return;case"textarea":De("invalid",e),f=c=l=null;for(p in r)if(r.hasOwnProperty(p)&&(b=r[p],b!=null))switch(p){case"value":l=b;break;case"defaultValue":c=b;break;case"children":f=b;break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(a(91));break;default:Fe(e,n,p,b,r,null)}qh(e,l,c,f);return;case"option":for(N in r)if(r.hasOwnProperty(N)&&(l=r[N],l!=null))switch(N){case"selected":e.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Fe(e,n,N,l,r,null)}return;case"dialog":De("beforetoggle",e),De("toggle",e),De("cancel",e),De("close",e);break;case"iframe":case"object":De("load",e);break;case"video":case"audio":for(l=0;l<_a.length;l++)De(_a[l],e);break;case"image":De("error",e),De("load",e);break;case"details":De("toggle",e);break;case"embed":case"source":case"link":De("error",e),De("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(L in r)if(r.hasOwnProperty(L)&&(l=r[L],l!=null))switch(L){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:Fe(e,n,L,l,r,null)}return;default:if(ac(n)){for(V in r)r.hasOwnProperty(V)&&(l=r[V],l!==void 0&&Iu(e,n,V,l,r,void 0));return}}for(b in r)r.hasOwnProperty(b)&&(l=r[b],l!=null&&Fe(e,n,b,l,r,null))}function Ex(e,n,r,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,f=null,p=null,b=null,N=null,L=null,V=null;for(Y in r){var W=r[Y];if(r.hasOwnProperty(Y)&&W!=null)switch(Y){case"checked":break;case"value":break;case"defaultValue":N=W;default:l.hasOwnProperty(Y)||Fe(e,n,Y,null,l,W)}}for(var P in l){var Y=l[P];if(W=r[P],l.hasOwnProperty(P)&&(Y!=null||W!=null))switch(P){case"type":f=Y;break;case"name":c=Y;break;case"checked":L=Y;break;case"defaultChecked":V=Y;break;case"value":p=Y;break;case"defaultValue":b=Y;break;case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(a(137,n));break;default:Y!==W&&Fe(e,n,P,Y,l,W)}}ic(e,p,b,N,L,V,f,c);return;case"select":Y=p=b=P=null;for(f in r)if(N=r[f],r.hasOwnProperty(f)&&N!=null)switch(f){case"value":break;case"multiple":Y=N;default:l.hasOwnProperty(f)||Fe(e,n,f,null,l,N)}for(c in l)if(f=l[c],N=r[c],l.hasOwnProperty(c)&&(f!=null||N!=null))switch(c){case"value":P=f;break;case"defaultValue":b=f;break;case"multiple":p=f;default:f!==N&&Fe(e,n,c,f,l,N)}n=b,r=p,l=Y,P!=null?Pi(e,!!r,P,!1):!!l!=!!r&&(n!=null?Pi(e,!!r,n,!0):Pi(e,!!r,r?[]:"",!1));return;case"textarea":Y=P=null;for(b in r)if(c=r[b],r.hasOwnProperty(b)&&c!=null&&!l.hasOwnProperty(b))switch(b){case"value":break;case"children":break;default:Fe(e,n,b,null,l,c)}for(p in l)if(c=l[p],f=r[p],l.hasOwnProperty(p)&&(c!=null||f!=null))switch(p){case"value":P=c;break;case"defaultValue":Y=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(a(91));break;default:c!==f&&Fe(e,n,p,c,l,f)}Dh(e,P,Y);return;case"option":for(var pe in r)if(P=r[pe],r.hasOwnProperty(pe)&&P!=null&&!l.hasOwnProperty(pe))switch(pe){case"selected":e.selected=!1;break;default:Fe(e,n,pe,null,l,P)}for(N in l)if(P=l[N],Y=r[N],l.hasOwnProperty(N)&&P!==Y&&(P!=null||Y!=null))switch(N){case"selected":e.selected=P&&typeof P!="function"&&typeof P!="symbol";break;default:Fe(e,n,N,P,l,Y)}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 _e in r)P=r[_e],r.hasOwnProperty(_e)&&P!=null&&!l.hasOwnProperty(_e)&&Fe(e,n,_e,null,l,P);for(L in l)if(P=l[L],Y=r[L],l.hasOwnProperty(L)&&P!==Y&&(P!=null||Y!=null))switch(L){case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(a(137,n));break;default:Fe(e,n,L,P,l,Y)}return;default:if(ac(n)){for(var Je in r)P=r[Je],r.hasOwnProperty(Je)&&P!==void 0&&!l.hasOwnProperty(Je)&&Iu(e,n,Je,void 0,l,P);for(V in l)P=l[V],Y=r[V],!l.hasOwnProperty(V)||P===Y||P===void 0&&Y===void 0||Iu(e,n,V,P,l,Y);return}}for(var q in r)P=r[q],r.hasOwnProperty(q)&&P!=null&&!l.hasOwnProperty(q)&&Fe(e,n,q,null,l,P);for(W in l)P=l[W],Y=r[W],!l.hasOwnProperty(W)||P===Y||P==null&&Y==null||Fe(e,n,W,P,l,Y)}function Bp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function jx(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,r=performance.getEntriesByType("resource"),l=0;l<r.length;l++){var c=r[l],f=c.transferSize,p=c.initiatorType,b=c.duration;if(f&&b&&Bp(p)){for(p=0,b=c.responseEnd,l+=1;l<r.length;l++){var N=r[l],L=N.startTime;if(L>b)break;var V=N.transferSize,W=N.initiatorType;V&&Bp(W)&&(N=N.responseEnd,p+=V*(N<b?1:(b-L)/(N-L)))}if(--l,n+=8*(f+p)/(c.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Fu=null,Ju=null;function io(e){return e.nodeType===9?e:e.ownerDocument}function Lp(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 Pp(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function Qu(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Ku=null;function Ax(){var e=window.event;return e&&e.type==="popstate"?e===Ku?!1:(Ku=e,!0):(Ku=null,!1)}var Hp=typeof setTimeout=="function"?setTimeout:void 0,Ox=typeof clearTimeout=="function"?clearTimeout:void 0,$p=typeof Promise=="function"?Promise:void 0,Nx=typeof queueMicrotask=="function"?queueMicrotask:typeof $p<"u"?function(e){return $p.resolve(null).then(e).catch(Tx)}:Hp;function Tx(e){setTimeout(function(){throw e})}function Hs(e){return e==="head"}function Yp(e,n){var r=n,l=0;do{var c=r.nextSibling;if(e.removeChild(r),c&&c.nodeType===8)if(r=c.data,r==="/$"||r==="/&"){if(l===0){e.removeChild(c),br(n);return}l--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")l++;else if(r==="html")Sa(e.ownerDocument.documentElement);else if(r==="head"){r=e.ownerDocument.head,Sa(r);for(var f=r.firstChild;f;){var p=f.nextSibling,b=f.nodeName;f[xt]||b==="SCRIPT"||b==="STYLE"||b==="LINK"&&f.rel.toLowerCase()==="stylesheet"||r.removeChild(f),f=p}}else r==="body"&&Sa(e.ownerDocument.body);r=c}while(r);br(n)}function Gp(e,n){var r=e;e=0;do{var l=r.nextSibling;if(r.nodeType===1?n?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(n?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),l&&l.nodeType===8)if(r=l.data,r==="/$"){if(e===0)break;e--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||e++;r=l}while(r)}function Xu(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":Xu(r),Li(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function kx(e,n,r,l){for(;e.nodeType===1;){var c=r;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[xt])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(f=e.getAttribute("rel"),f==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(f!==c.rel||e.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||e.getAttribute("title")!==(c.title==null?null:c.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(f=e.getAttribute("src"),(f!==(c.src==null?null:c.src)||e.getAttribute("type")!==(c.type==null?null:c.type)||e.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&f&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var f=c.name==null?null:""+c.name;if(c.type==="hidden"&&e.getAttribute("name")===f)return e}else return e;if(e=xn(e.nextSibling),e===null)break}return null}function Cx(e,n,r){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=xn(e.nextSibling),e===null))return null;return e}function Vp(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=xn(e.nextSibling),e===null))return null;return e}function Zu(e){return e.data==="$?"||e.data==="$~"}function Wu(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Mx(e,n){var r=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||r.readyState!=="loading")n();else{var l=function(){n(),r.removeEventListener("DOMContentLoaded",l)};r.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function xn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var ef=null;function Ip(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"||r==="/&"){if(n===0)return xn(e.nextSibling);n--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||n++}e=e.nextSibling}return null}function Fp(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(n===0)return e;n--}else r!=="/$"&&r!=="/&"||n++}e=e.previousSibling}return null}function Jp(e,n,r){switch(n=io(r),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function Sa(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Li(e)}var vn=new Map,Qp=new Set;function ro(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var hs=se.d;se.d={f:Rx,r:Dx,D:qx,C:zx,L:Ux,m:Bx,X:Px,S:Lx,M:Hx};function Rx(){var e=hs.f(),n=Kl();return e||n}function Dx(e){var n=S(e);n!==null&&n.tag===5&&n.type==="form"?hm(n):hs.r(e)}var pr=typeof document>"u"?null:document;function Kp(e,n,r){var l=pr;if(l&&typeof n=="string"&&n){var c=hn(n);c='link[rel="'+e+'"][href="'+c+'"]',typeof r=="string"&&(c+='[crossorigin="'+r+'"]'),Qp.has(c)||(Qp.add(c),e={rel:e,crossOrigin:r,href:n},l.querySelector(c)===null&&(n=l.createElement("link"),Nt(n,"link",e),k(n),l.head.appendChild(n)))}}function qx(e){hs.D(e),Kp("dns-prefetch",e,null)}function zx(e,n){hs.C(e,n),Kp("preconnect",e,n)}function Ux(e,n,r){hs.L(e,n,r);var l=pr;if(l&&e&&n){var c='link[rel="preload"][as="'+hn(n)+'"]';n==="image"&&r&&r.imageSrcSet?(c+='[imagesrcset="'+hn(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(c+='[imagesizes="'+hn(r.imageSizes)+'"]')):c+='[href="'+hn(e)+'"]';var f=c;switch(n){case"style":f=gr(e);break;case"script":f=yr(e)}vn.has(f)||(e=_({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:e,as:n},r),vn.set(f,e),l.querySelector(c)!==null||n==="style"&&l.querySelector(Ea(f))||n==="script"&&l.querySelector(ja(f))||(n=l.createElement("link"),Nt(n,"link",e),k(n),l.head.appendChild(n)))}}function Bx(e,n){hs.m(e,n);var r=pr;if(r&&e){var l=n&&typeof n.as=="string"?n.as:"script",c='link[rel="modulepreload"][as="'+hn(l)+'"][href="'+hn(e)+'"]',f=c;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=yr(e)}if(!vn.has(f)&&(e=_({rel:"modulepreload",href:e},n),vn.set(f,e),r.querySelector(c)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(ja(f)))return}l=r.createElement("link"),Nt(l,"link",e),k(l),r.head.appendChild(l)}}}function Lx(e,n,r){hs.S(e,n,r);var l=pr;if(l&&e){var c=A(l).hoistableStyles,f=gr(e);n=n||"default";var p=c.get(f);if(!p){var b={loading:0,preload:null};if(p=l.querySelector(Ea(f)))b.loading=5;else{e=_({rel:"stylesheet",href:e,"data-precedence":n},r),(r=vn.get(f))&&tf(e,r);var N=p=l.createElement("link");k(N),Nt(N,"link",e),N._p=new Promise(function(L,V){N.onload=L,N.onerror=V}),N.addEventListener("load",function(){b.loading|=1}),N.addEventListener("error",function(){b.loading|=2}),b.loading|=4,ao(p,n,l)}p={type:"stylesheet",instance:p,count:1,state:b},c.set(f,p)}}}function Px(e,n){hs.X(e,n);var r=pr;if(r&&e){var l=A(r).hoistableScripts,c=yr(e),f=l.get(c);f||(f=r.querySelector(ja(c)),f||(e=_({src:e,async:!0},n),(n=vn.get(c))&&nf(e,n),f=r.createElement("script"),k(f),Nt(f,"link",e),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},l.set(c,f))}}function Hx(e,n){hs.M(e,n);var r=pr;if(r&&e){var l=A(r).hoistableScripts,c=yr(e),f=l.get(c);f||(f=r.querySelector(ja(c)),f||(e=_({src:e,async:!0,type:"module"},n),(n=vn.get(c))&&nf(e,n),f=r.createElement("script"),k(f),Nt(f,"link",e),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},l.set(c,f))}}function Xp(e,n,r,l){var c=(c=cn.current)?ro(c):null;if(!c)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=gr(r.href),r=A(c).hoistableStyles,l=r.get(n),l||(l={type:"style",instance:null,count:0,state:null},r.set(n,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=gr(r.href);var f=A(c).hoistableStyles,p=f.get(e);if(p||(c=c.ownerDocument||c,p={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(e,p),(f=c.querySelector(Ea(e)))&&!f._p&&(p.instance=f,p.state.loading=5),vn.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},vn.set(e,r),f||$x(c,e,r,p.state))),n&&l===null)throw Error(a(528,""));return p}if(n&&l!==null)throw Error(a(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=yr(r),r=A(c).hoistableScripts,l=r.get(n),l||(l={type:"script",instance:null,count:0,state:null},r.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function gr(e){return'href="'+hn(e)+'"'}function Ea(e){return'link[rel="stylesheet"]['+e+"]"}function Zp(e){return _({},e,{"data-precedence":e.precedence,precedence:null})}function $x(e,n,r,l){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=e.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),Nt(n,"link",r),k(n),e.head.appendChild(n))}function yr(e){return'[src="'+hn(e)+'"]'}function ja(e){return"script[async]"+e}function Wp(e,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var l=e.querySelector('style[data-href~="'+hn(r.href)+'"]');if(l)return n.instance=l,k(l),l;var c=_({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),k(l),Nt(l,"style",c),ao(l,r.precedence,e),n.instance=l;case"stylesheet":c=gr(r.href);var f=e.querySelector(Ea(c));if(f)return n.state.loading|=4,n.instance=f,k(f),f;l=Zp(r),(c=vn.get(c))&&tf(l,c),f=(e.ownerDocument||e).createElement("link"),k(f);var p=f;return p._p=new Promise(function(b,N){p.onload=b,p.onerror=N}),Nt(f,"link",l),n.state.loading|=4,ao(f,r.precedence,e),n.instance=f;case"script":return f=yr(r.src),(c=e.querySelector(ja(f)))?(n.instance=c,k(c),c):(l=r,(c=vn.get(f))&&(l=_({},r),nf(l,c)),e=e.ownerDocument||e,c=e.createElement("script"),k(c),Nt(c,"link",l),e.head.appendChild(c),n.instance=c);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,ao(l,r.precedence,e));return n.instance}function ao(e,n,r){for(var l=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=l.length?l[l.length-1]:null,f=c,p=0;p<l.length;p++){var b=l[p];if(b.dataset.precedence===n)f=b;else if(f!==c)break}f?f.parentNode.insertBefore(e,f.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(e,n.firstChild))}function tf(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function nf(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var lo=null;function e0(e,n,r){if(lo===null){var l=new Map,c=lo=new Map;c.set(r,l)}else c=lo,l=c.get(r),l||(l=new Map,c.set(r,l));if(l.has(e))return l;for(l.set(e,null),r=r.getElementsByTagName(e),c=0;c<r.length;c++){var f=r[c];if(!(f[xt]||f[Qe]||e==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var p=f.getAttribute(n)||"";p=e+p;var b=l.get(p);b?b.push(f):l.set(p,[f])}}return l}function t0(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function Yx(e,n,r){if(r===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function n0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Gx(e,n,r,l){if(r.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var c=gr(l.href),f=n.querySelector(Ea(c));if(f){n=f._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=oo.bind(e),n.then(e,e)),r.state.loading|=4,r.instance=f,k(f);return}f=n.ownerDocument||n,l=Zp(l),(c=vn.get(c))&&tf(l,c),f=f.createElement("link"),k(f);var p=f;p._p=new Promise(function(b,N){p.onload=b,p.onerror=N}),Nt(f,"link",l),r.instance=f}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(r,n),(n=r.state.preload)&&(r.state.loading&3)===0&&(e.count++,r=oo.bind(e),n.addEventListener("load",r),n.addEventListener("error",r))}}var sf=0;function Vx(e,n){return e.stylesheets&&e.count===0&&uo(e,e.stylesheets),0<e.count||0<e.imgCount?function(r){var l=setTimeout(function(){if(e.stylesheets&&uo(e,e.stylesheets),e.unsuspend){var f=e.unsuspend;e.unsuspend=null,f()}},6e4+n);0<e.imgBytes&&sf===0&&(sf=62500*jx());var c=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&uo(e,e.stylesheets),e.unsuspend)){var f=e.unsuspend;e.unsuspend=null,f()}},(e.imgBytes>sf?50:800)+n);return e.unsuspend=r,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(c)}}:null}function oo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)uo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var co=null;function uo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,co=new Map,n.forEach(Ix,e),co=null,oo.call(e))}function Ix(e,n){if(!(n.state.loading&4)){var r=co.get(e);if(r)var l=r.get(null);else{r=new Map,co.set(e,r);for(var c=e.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<c.length;f++){var p=c[f];(p.nodeName==="LINK"||p.getAttribute("media")!=="not all")&&(r.set(p.dataset.precedence,p),l=p)}l&&r.set(null,l)}c=n.instance,p=c.getAttribute("data-precedence"),f=r.get(p)||l,f===l&&r.set(null,c),r.set(p,c),this.count++,l=oo.bind(this),c.addEventListener("load",l),c.addEventListener("error",l),f?f.parentNode.insertBefore(c,f.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(c,e.firstChild)),n.state.loading|=4}}var Aa={$$typeof:fe,Provider:null,Consumer:null,_currentValue:ie,_currentValue2:ie,_threadCount:0};function Fx(e,n,r,l,c,f,p,b,N){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=vs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vs(0),this.hiddenUpdates=vs(null),this.identifierPrefix=l,this.onUncaughtError=c,this.onCaughtError=f,this.onRecoverableError=p,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function s0(e,n,r,l,c,f,p,b,N,L,V,W){return e=new Fx(e,n,r,p,N,L,V,W,b),n=1,f===!0&&(n|=24),f=Qt(3,null,null,n),e.current=f,f.stateNode=e,n=zc(),n.refCount++,e.pooledCache=n,n.refCount++,f.memoizedState={element:l,isDehydrated:r,cache:n},Pc(f),e}function i0(e){return e?(e=Ji,e):Ji}function r0(e,n,r,l,c,f){c=i0(c),l.context===null?l.context=c:l.pendingContext=c,l=ks(n),l.payload={element:r},f=f===void 0?null:f,f!==null&&(l.callback=f),r=Cs(e,l,n),r!==null&&(Gt(r,e,n),ia(r,e,n))}function a0(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function rf(e,n){a0(e,n),(e=e.alternate)&&a0(e,n)}function l0(e){if(e.tag===13||e.tag===31){var n=pi(e,67108864);n!==null&&Gt(n,e,67108864),rf(e,67108864)}}function o0(e){if(e.tag===13||e.tag===31){var n=en();n=Jn(n);var r=pi(e,n);r!==null&&Gt(r,e,n),rf(e,n)}}var fo=!0;function Jx(e,n,r,l){var c=$.T;$.T=null;var f=se.p;try{se.p=2,af(e,n,r,l)}finally{se.p=f,$.T=c}}function Qx(e,n,r,l){var c=$.T;$.T=null;var f=se.p;try{se.p=8,af(e,n,r,l)}finally{se.p=f,$.T=c}}function af(e,n,r,l){if(fo){var c=lf(l);if(c===null)Vu(e,n,l,ho,r),u0(e,l);else if(Xx(c,e,n,r,l))l.stopPropagation();else if(u0(e,l),n&4&&-1<Kx.indexOf(e)){for(;c!==null;){var f=S(c);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var p=jn(f.pendingLanes);if(p!==0){var b=f;for(b.pendingLanes|=2,b.entangledLanes|=2;p;){var N=1<<31-Rt(p);b.entanglements[1]|=N,p&=~N}Ln(f),($e&6)===0&&(Jl=et()+500,va(0))}}break;case 31:case 13:b=pi(f,2),b!==null&&Gt(b,f,2),Kl(),rf(f,2)}if(f=lf(l),f===null&&Vu(e,n,l,ho,r),f===c)break;c=f}c!==null&&l.stopPropagation()}else Vu(e,n,l,null,r)}}function lf(e){return e=oc(e),of(e)}var ho=null;function of(e){if(ho=null,e=x(e),e!==null){var n=u(e);if(n===null)e=null;else{var r=n.tag;if(r===13){if(e=d(n),e!==null)return e;e=null}else if(r===31){if(e=m(n),e!==null)return e;e=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return ho=e,null}function c0(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(ec()){case tl:return 2;case nl:return 8;case zi:case tc:return 32;case sl:return 268435456;default:return 32}default:return 32}}var cf=!1,$s=null,Ys=null,Gs=null,Oa=new Map,Na=new Map,Vs=[],Kx="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 u0(e,n){switch(e){case"focusin":case"focusout":$s=null;break;case"dragenter":case"dragleave":Ys=null;break;case"mouseover":case"mouseout":Gs=null;break;case"pointerover":case"pointerout":Oa.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Na.delete(n.pointerId)}}function Ta(e,n,r,l,c,f){return e===null||e.nativeEvent!==f?(e={blockedOn:n,domEventName:r,eventSystemFlags:l,nativeEvent:f,targetContainers:[c]},n!==null&&(n=S(n),n!==null&&l0(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,c!==null&&n.indexOf(c)===-1&&n.push(c),e)}function Xx(e,n,r,l,c){switch(n){case"focusin":return $s=Ta($s,e,n,r,l,c),!0;case"dragenter":return Ys=Ta(Ys,e,n,r,l,c),!0;case"mouseover":return Gs=Ta(Gs,e,n,r,l,c),!0;case"pointerover":var f=c.pointerId;return Oa.set(f,Ta(Oa.get(f)||null,e,n,r,l,c)),!0;case"gotpointercapture":return f=c.pointerId,Na.set(f,Ta(Na.get(f)||null,e,n,r,l,c)),!0}return!1}function f0(e){var n=x(e.target);if(n!==null){var r=u(n);if(r!==null){if(n=r.tag,n===13){if(n=d(r),n!==null){e.blockedOn=n,rl(e.priority,function(){o0(r)});return}}else if(n===31){if(n=m(r),n!==null){e.blockedOn=n,rl(e.priority,function(){o0(r)});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function mo(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=lf(e.nativeEvent);if(r===null){r=e.nativeEvent;var l=new r.constructor(r.type,r);lc=l,r.target.dispatchEvent(l),lc=null}else return n=S(r),n!==null&&l0(n),e.blockedOn=r,!1;n.shift()}return!0}function h0(e,n,r){mo(e)&&r.delete(n)}function Zx(){cf=!1,$s!==null&&mo($s)&&($s=null),Ys!==null&&mo(Ys)&&(Ys=null),Gs!==null&&mo(Gs)&&(Gs=null),Oa.forEach(h0),Na.forEach(h0)}function po(e,n){e.blockedOn===n&&(e.blockedOn=null,cf||(cf=!0,i.unstable_scheduleCallback(i.unstable_NormalPriority,Zx)))}var go=null;function d0(e){go!==e&&(go=e,i.unstable_scheduleCallback(i.unstable_NormalPriority,function(){go===e&&(go=null);for(var n=0;n<e.length;n+=3){var r=e[n],l=e[n+1],c=e[n+2];if(typeof l!="function"){if(of(l||r)===null)continue;break}var f=S(r);f!==null&&(e.splice(n,3),n-=3,au(f,{pending:!0,data:c,method:r.method,action:l},l,c))}}))}function br(e){function n(N){return po(N,e)}$s!==null&&po($s,e),Ys!==null&&po(Ys,e),Gs!==null&&po(Gs,e),Oa.forEach(n),Na.forEach(n);for(var r=0;r<Vs.length;r++){var l=Vs[r];l.blockedOn===e&&(l.blockedOn=null)}for(;0<Vs.length&&(r=Vs[0],r.blockedOn===null);)f0(r),r.blockedOn===null&&Vs.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(l=0;l<r.length;l+=3){var c=r[l],f=r[l+1],p=c[it]||null;if(typeof f=="function")p||d0(r);else if(p){var b=null;if(f&&f.hasAttribute("formAction")){if(c=f,p=f[it]||null)b=p.formAction;else if(of(c)!==null)continue}else b=p.action;typeof b=="function"?r[l+1]=b:(r.splice(l,3),l-=3),d0(r)}}}function m0(){function e(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(p){return c=p})},focusReset:"manual",scroll:"manual"})}function n(){c!==null&&(c(),c=null),l||setTimeout(r,20)}function r(){if(!l&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,c=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(r,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),c!==null&&(c(),c=null)}}}function uf(e){this._internalRoot=e}yo.prototype.render=uf.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,l=en();r0(r,l,e,n,null,null)},yo.prototype.unmount=uf.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;r0(e.current,2,null,e,null,null),Kl(),n[Ft]=null}};function yo(e){this._internalRoot=e}yo.prototype.unstable_scheduleHydration=function(e){if(e){var n=Hr();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Vs.length&&n!==0&&n<Vs[r].priority;r++);Vs.splice(r,0,e),r===0&&f0(e)}};var p0=t.version;if(p0!=="19.2.4")throw Error(a(527,p0,"19.2.4"));se.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=y(n),e=e!==null?E(e):null,e=e===null?null:e.stateNode,e};var Wx={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var bo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bo.isDisabled&&bo.supportsFiber)try{ai=bo.inject(Wx),ot=bo}catch{}}return ka.createRoot=function(e,n){if(!o(e))throw Error(a(299));var r=!1,l="",c=wm,f=Sm,p=Em;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(c=n.onUncaughtError),n.onCaughtError!==void 0&&(f=n.onCaughtError),n.onRecoverableError!==void 0&&(p=n.onRecoverableError)),n=s0(e,1,!1,null,null,r,l,null,c,f,p,m0),e[Ft]=n.current,Gu(e),new uf(n)},ka.hydrateRoot=function(e,n,r){if(!o(e))throw Error(a(299));var l=!1,c="",f=wm,p=Sm,b=Em,N=null;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(p=r.onCaughtError),r.onRecoverableError!==void 0&&(b=r.onRecoverableError),r.formState!==void 0&&(N=r.formState)),n=s0(e,1,!0,n,r??null,l,c,N,f,p,b,m0),n.context=i0(null),r=n.current,l=en(),l=Jn(l),c=ks(l),c.callback=null,Cs(r,c,l),r=l,n.current.lanes=r,An(n,r),Ln(n),e[Ft]=n.current,Gu(e),new yo(n)},ka.version="19.2.4",ka}var S0;function Hv(){if(S0)return ff.exports;S0=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),ff.exports=Pv(),ff.exports}var $v=Hv();const Yv="modulepreload",Gv=function(i,t){return new URL(i,t).href},E0={},we=function(t,s,a){let o=Promise.resolve();if(s&&s.length>0){let d=function(E){return Promise.all(E.map(_=>Promise.resolve(_).then(T=>({status:"fulfilled",value:T}),T=>({status:"rejected",reason:T}))))};const m=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=d(s.map(E=>{if(E=Gv(E,a),E in E0)return;E0[E]=!0;const _=E.endsWith(".css"),T=_?'[rel="stylesheet"]':"";if(!!a)for(let D=m.length-1;D>=0;D--){const F=m[D];if(F.href===E&&(!_||F.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${E}"]${T}`))return;const C=document.createElement("link");if(C.rel=_?"stylesheet":Yv,_||(C.as="script"),C.crossOrigin="",C.href=E,y&&C.setAttribute("nonce",y),document.head.appendChild(C),_)return new Promise((D,F)=>{C.addEventListener("load",D),C.addEventListener("error",()=>F(new Error(`Unable to preload CSS for ${E}`)))})}))}function u(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return o.then(d=>{for(const m of d||[])m.status==="rejected"&&u(m.reason);return t().catch(u)})};function ih(i){try{const t=i.split(".");if(t.length!==3)return null;const s=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function zg(i){const t=ih(i);return!t||typeof t.exp!="number"?null:t.exp}function rh(i,t=0){const s=zg(i);return s===null?!0:Date.now()/1e3>=s-t}const Tt=window.__LT_BASE__??"",Cf=`${Tt}/api`;class Vv extends Error{constructor(t,s,a){super(t),this.status=s,this.body=a,this.name="ApiError"}}let Qs=null;function xo(i){Qs=i}function Ug(){return Qs}async function j0(){const i=sessionStorage.getItem("lt_credentials");if(!i)return null;try{const{username:t,password:s}=JSON.parse(i),a=await fetch(`${Cf}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})});if(!a.ok)return null;const o=await a.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 Fs=null;async function Ee(i,t={}){const s={"Content-Type":"application/json",...t.headers};if(Qs){if(rh(Qs)){Fs||(Fs=j0().finally(()=>{Fs=null}));const o=await Fs;if(o)Qs=o,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:o}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${Qs}`}let a=await fetch(`${Cf}${i}`,{...t,headers:s});if(a.status===401&&Qs){Fs||(Fs=j0().finally(()=>{Fs=null}));const o=await Fs;if(o&&(Qs=o,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:o}})),s.Authorization=`Bearer ${o}`,a=await fetch(`${Cf}${i}`,{...t,headers:s})),a.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(a.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!a.ok){const o=await a.json().catch(()=>({error:a.statusText}));throw new Vv(o.message||o.error||a.statusText,a.status,o)}return a.json()}const Bg=j.createContext(null),Iv=300;function mf(i,t){if(rh(i))return null;const s=ih(i);if(!s)return null;const a=t??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(a==null?void 0:a.displayName)??null,username:(a==null?void 0:a.username)??null,roles:s.roles??[]}}function Fv({children:i}){const[t,s]=j.useState(()=>{const _=sessionStorage.getItem("lt_token");return _?rh(_)?(sessionStorage.removeItem("lt_token"),null):(xo(_),mf(_)):null}),a=j.useRef(void 0),o=j.useCallback(_=>{clearTimeout(a.current);const T=zg(_);if(!T)return;const R=(T-Iv)*1e3-Date.now();R<=0||(a.current=setTimeout(async()=>{try{const C=ih(_);if(C!=null&&C.sso){const oe=await fetch(`${Tt}/api/auth/sso`,{method:"POST"});if(!oe.ok)return;const O=await oe.json();O.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:O.token}}));return}const D=sessionStorage.getItem("lt_credentials");if(!D)return;const{username:F,password:te}=JSON.parse(D),X=await fetch(`${Tt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:F,password:te})});if(!X.ok)return;const fe=await X.json();fe.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:fe.token}}))}catch{}},R))},[]),u=j.useCallback((_,T,R)=>{const C={displayName:(R==null?void 0:R.displayName)??null,username:(R==null?void 0:R.username)??(T==null?void 0:T.username)??null},D=mf(_,C);D&&(xo(_),sessionStorage.setItem("lt_token",_),sessionStorage.setItem("lt_user_info",JSON.stringify(C)),T&&sessionStorage.setItem("lt_credentials",JSON.stringify(T)),s(D),o(_))},[o]),d=j.useCallback(()=>{clearTimeout(a.current);const _=sessionStorage.getItem("lt_sso_logout_url");xo(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),_&&(window.location.href=_)},[]);j.useEffect(()=>{const _=()=>d(),T=R=>{var F;const C=(F=R.detail)==null?void 0:F.token;if(!C)return;const D=mf(C);D&&(xo(C),sessionStorage.setItem("lt_token",C),s(D),o(C))};return window.addEventListener("auth:unauthorized",_),window.addEventListener("auth:refreshed",T),()=>{window.removeEventListener("auth:unauthorized",_),window.removeEventListener("auth:refreshed",T)}},[d,o]),j.useEffect(()=>{const _=sessionStorage.getItem("lt_token");return _&&t&&o(_),()=>clearTimeout(a.current)},[]);const m=(t==null?void 0:t.roles.some(_=>_.type==="superadmin"))??!1,g=j.useCallback(_=>(t==null?void 0:t.roles.some(T=>T.role===_))??!1,[t]),y=j.useCallback(_=>(t==null?void 0:t.roles.some(T=>T.type===_))??!1,[t]),E=(t==null?void 0:t.roles.map(_=>_.role))??[];return h.jsx(Bg.Provider,{value:{user:t,isAuthenticated:!!t,isSuperAdmin:m,login:u,logout:d,hasRole:g,hasRoleType:y,userRoleNames:E},children:i})}function En(){const i=j.useContext(Bg);if(!i)throw new Error("useAuth must be used within AuthProvider");return i}const an=new Uint8Array(0),Mi=new TextEncoder,sn=new TextDecoder;function Jv(...i){let t=0;for(let o=0;o<i.length;o++)t+=i[o].length;const s=new Uint8Array(t);let a=0;for(let o=0;o<i.length;o++)s.set(i[o],a),a+=i[o].length;return s}function La(...i){const t=[];for(let s=0;s<i.length;s++)t.push(Mi.encode(i[s]));return t.length===0?an:t.length===1?t[0]:Jv(...t)}function A0(i){return!i||i.length===0?"":sn.decode(i)}const O0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",N0=36,Qv=0xcfd41b9100000,T0=33,Kv=333,k0=22;function Xv(i){for(let t=0;t<i.length;t++)i[t]=Math.floor(Math.random()*255)}function Zv(i){var t;(t=globalThis==null?void 0:globalThis.crypto)!=null&&t.getRandomValues?globalThis.crypto.getRandomValues(i):Xv(i)}class Wv{constructor(){v(this,"buf");v(this,"seq");v(this,"inc");v(this,"inited");this.buf=new Uint8Array(k0),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*Qv),this.inc=Math.floor(Math.random()*(Kv-T0)+T0)}setPre(){const t=new Uint8Array(12);Zv(t);for(let s=0;s<12;s++){const a=t[s]%36;this.buf[s]=O0.charCodeAt(a)}}fillSeq(){let t=this.seq;for(let s=k0-1;s>=12;s--)this.buf[s]=O0.charCodeAt(t%N0),t=Math.floor(t/N0)}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 ti=new Wv;var ds;(function(i){i.Disconnect="disconnect",i.Reconnect="reconnect",i.Update="update",i.LDM="ldm",i.Error="error"})(ds||(ds={}));var Er;(function(i){i.Reconnecting="reconnecting",i.PingTimer="pingTimer",i.StaleConnection="staleConnection",i.ClientInitiatedReconnect="client initiated reconnect"})(Er||(Er={}));var le;(function(i){i.ApiError="BAD API",i.BadAuthentication="BAD_AUTHENTICATION",i.BadCreds="BAD_CREDS",i.BadHeader="BAD_HEADER",i.BadJson="BAD_JSON",i.BadPayload="BAD_PAYLOAD",i.BadSubject="BAD_SUBJECT",i.Cancelled="CANCELLED",i.ConnectionClosed="CONNECTION_CLOSED",i.ConnectionDraining="CONNECTION_DRAINING",i.ConnectionRefused="CONNECTION_REFUSED",i.ConnectionTimeout="CONNECTION_TIMEOUT",i.Disconnect="DISCONNECT",i.InvalidOption="INVALID_OPTION",i.InvalidPayload="INVALID_PAYLOAD",i.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",i.NoResponders="503",i.NotFunction="NOT_FUNC",i.RequestError="REQUEST_ERROR",i.ServerOptionNotAvailable="SERVER_OPT_NA",i.SubClosed="SUB_CLOSED",i.SubDraining="SUB_DRAINING",i.Timeout="TIMEOUT",i.Tls="TLS",i.Unknown="UNKNOWN_ERROR",i.WssRequired="WSS_REQUIRED",i.JetStreamInvalidAck="JESTREAM_INVALID_ACK",i.JetStream404NoMessages="404",i.JetStream408RequestTimeout="408",i.JetStream409MaxAckPendingExceeded="409",i.JetStream409="409",i.JetStreamNotEnabled="503",i.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",i.AuthorizationViolation="AUTHORIZATION_VIOLATION",i.AuthenticationExpired="AUTHENTICATION_EXPIRED",i.ProtocolError="NATS_PROTOCOL_ERR",i.PermissionsViolation="PERMISSIONS_VIOLATION",i.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",i.AccountExpired="ACCOUNT_EXPIRED"})(le||(le={}));function e1(i){return typeof i.code=="string"}class Lg{constructor(){v(this,"messages");this.messages=new Map,this.messages.set(le.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(le.BadJson,"Bad JSON"),this.messages.set(le.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(t){return t1.getMessage(t)}getMessage(t){return this.messages.get(t)||t}}const t1=new Lg;class de extends Error{constructor(s,a,o){super(s);v(this,"name");v(this,"message");v(this,"code");v(this,"permissionContext");v(this,"chainedError");v(this,"api_error");this.name="NatsError",this.message=s,this.code=a,this.chainedError=o}static errorForCode(s,a){const o=Lg.getMessage(s);return new de(o,s,a)}isAuthError(){return this.code===le.AuthenticationExpired||this.code===le.AuthorizationViolation||this.code===le.AccountExpired}isAuthTimeout(){return this.code===le.AuthenticationTimeout}isPermissionError(){return this.code===le.PermissionsViolation}isProtocolError(){return this.code===le.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var tn;(function(i){i[i.Exact=0]="Exact",i[i.CanonicalMIME=1]="CanonicalMIME",i[i.IgnoreCase=2]="IgnoreCase"})(tn||(tn={}));var Rn;(function(i){i.Timer="timer",i.Count="count",i.JitterTimer="jitterTimer",i.SentinelMsg="sentinelMsg"})(Rn||(Rn={}));var Pa;(function(i){i.STATS="io.nats.micro.v1.stats_response",i.INFO="io.nats.micro.v1.info_response",i.PING="io.nats.micro.v1.ping_response"})(Pa||(Pa={}));const qo="Nats-Service-Error",zo="Nats-Service-Error-Code";class Uo extends Error{constructor(s,a){super(a);v(this,"code");this.code=s}static isServiceError(s){return Uo.toServiceError(s)!==null}static toServiceError(s){var o,u;const a=((o=s==null?void 0:s.headers)==null?void 0:o.get(zo))||"";if(a!==""){const d=parseInt(a)||400,m=((u=s==null?void 0:s.headers)==null?void 0:u.get(qo))||"";return new Uo(d,m.length?m:a)}return null}}function ms(i=""){if(i=i||"_INBOX",typeof i!="string")throw new Error("prefix must be a string");return i.split(".").forEach(t=>{if(t==="*"||t===">")throw new Error(`inbox prefixes cannot have wildcards '${i}'`)}),`${i}.${ti.next()}`}const Mf="127.0.0.1";var Ks;(function(i){i.PING="PING",i.STATS="STATS",i.INFO="INFO"})(Ks||(Ks={}));function Jo(i,...t){for(let s=0;s<t.length;s++){const a=t[s];Object.keys(a).forEach(function(o){i[o]=a[o]})}return i}function vo(i){return sn.decode(i).replace(/\n/g,"␊").replace(/\r/g,"␍")}function kr(i,t=!0){const s=t?de.errorForCode(le.Timeout):null;let a,o;const u=new Promise((d,m)=>{a={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{m(s===null?de.errorForCode(le.Timeout):s)},i)});return Object.assign(u,a)}function Rr(i=0){let t;const s=new Promise(a=>{const o=setTimeout(()=>{a()},i);t={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,t)}function st(){let i={};const t=new Promise((s,a)=>{i={resolve:s,reject:a}});return Object.assign(t,i)}function Pg(i){for(let t=i.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1));[i[t],i[s]]=[i[s],i[t]]}return i}function n1(i){return i===0?0:Math.floor(i/2+Math.random()*i)}function ah(i=[0,250,250,500,500,3e3,5e3]){Array.isArray(i)||(i=[0,250,250,500,500,3e3,5e3]);const t=i.length-1;return{backoff(s){return n1(s>t?i[t]:i[s])}}}function nt(i){return i*1e6}function lh(i){return Math.floor(i/1e6)}function C0(i){let a=!0;const o=new Array(i.length);for(let u=0;u<i.length;u++){let d=i.charCodeAt(u);if(d===58||d<33||d>126)throw new de(`'${i[u]}' is not a valid character for a header key`,le.BadHeader);a&&97<=d&&d<=122?d-=32:!a&&65<=d&&d<=90&&(d+=32),o[u]=d,a=d==45}return String.fromCharCode(...o)}function ps(i=0,t=""){if(i===0&&t!==""||i>0&&t==="")throw new Error("setting status requires both code and description");return new Xs(i,t)}const pf="NATS/1.0";class Xs{constructor(t=0,s=""){v(this,"_code");v(this,"headers");v(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,a]of this.headers){const o=t.values(s);if(a.length!==o.length)return!1;const u=[...a].sort(),d=[...o].sort();for(let m=0;m<u.length;m++)if(u[m]!==d[m])return!1}return!0}return!1}static decode(t){const s=new Xs,o=sn.decode(t).split(`\r
27
+ `),u=o[0];if(u!==pf){let d=u.replace(pf,"").trim();if(d.length>0){s._code=parseInt(d,10),isNaN(s._code)&&(s._code=0);const m=s._code.toString();d=d.replace(m,""),s._description=d.trim()}}return o.length>=1&&o.slice(1).map(d=>{if(d){const m=d.indexOf(":");if(m>-1){const g=d.slice(0,m),y=d.slice(m+1).trim();s.append(g,y)}}}),s}toString(){if(this.headers.size===0&&this._code===0)return"";let t=pf;this._code>0&&this._description!==""&&(t+=` ${this._code} ${this._description}`);for(const[s,a]of this.headers)for(let o=0;o<a.length;o++)t=`${t}\r
28
28
  ${s}: ${a[o]}`;return`${t}\r
29
29
  \r
30
- `}encode(){return Ci.encode(this.toString())}static validHeaderValue(t){if(/[\r\n]/.test(t))throw new he("invalid header value - \\r and \\n are not allowed.",le.BadHeader);return t.trim()}keys(){const t=[];for(const s of this.headers.keys())t.push(s);return t}findKeys(t,s=tn.Exact){const a=this.keys();switch(s){case tn.Exact:return a.filter(o=>o===t);case tn.CanonicalMIME:return t=T0(t),a.filter(o=>o===t);default:{const o=t.toLowerCase();return a.filter(u=>o===u.toLowerCase())}}}get(t,s=tn.Exact){const a=this.findKeys(t,s);if(a.length){const o=this.headers.get(a[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(t,s=tn.Exact){const a=this.findKeys(t,s);if(a.length){const o=this.headers.get(a[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(t,s=tn.Exact){return this.findKeys(t,s).length>0}set(t,s,a=tn.Exact){this.delete(t,a),this.append(t,s,a)}append(t,s,a=tn.Exact){const o=T0(t);a===tn.CanonicalMIME&&(t=o);const u=this.findKeys(t,a);t=u.length>0?u[0]:t;const d=Xs.validHeaderValue(s);let m=this.headers.get(t);m||(m=[],this.headers.set(t,m)),m.push(d)}values(t,s=tn.Exact){const a=[];return this.findKeys(t,s).forEach(u=>{const d=this.headers.get(u);d&&a.push(...d)}),a}delete(t,s=tn.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 Xs;for(const a in t)s.headers.set(a,t[a]);return s}}function Mf(){return{encode(i){return Ci.encode(i)},decode(i){return sn.decode(i)}}}function Rn(i){return{encode(t){try{return t===void 0&&(t=null),Ci.encode(JSON.stringify(t))}catch(s){throw he.errorForCode(le.BadJson,s)}},decode(t){try{return JSON.parse(sn.decode(t),i)}catch(s){throw he.errorForCode(le.BadJson,s)}}}}function Ug(i){var t;return i&&i.data.length===0&&((t=i.headers)==null?void 0:t.code)===503?he.errorForCode(le.NoResponders):null}class oh{constructor(t,s,a){v(this,"_headers");v(this,"_msg");v(this,"_rdata");v(this,"_reply");v(this,"_subject");v(this,"publisher");this._msg=t,this._rdata=s,this.publisher=a}get subject(){return this._subject?this._subject:(this._subject=sn.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=sn.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=Xs.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=an,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,a=this._msg.size===-1?0:this._msg.size;return t+s+a}json(t){return Rn(t).decode(this.data)}string(){return sn.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(a,o){return(a==="start"||a==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}v(oh,"jc");function jr(i){return Jo("durable",i)}function zt(i){return Jo("stream",i)}function Jo(i,t=""){if(t==="")throw Error(`${i} name required`);return[".","*",">","/","\\"," "," ",`
30
+ `}encode(){return Mi.encode(this.toString())}static validHeaderValue(t){if(/[\r\n]/.test(t))throw new de("invalid header value - \\r and \\n are not allowed.",le.BadHeader);return t.trim()}keys(){const t=[];for(const s of this.headers.keys())t.push(s);return t}findKeys(t,s=tn.Exact){const a=this.keys();switch(s){case tn.Exact:return a.filter(o=>o===t);case tn.CanonicalMIME:return t=C0(t),a.filter(o=>o===t);default:{const o=t.toLowerCase();return a.filter(u=>o===u.toLowerCase())}}}get(t,s=tn.Exact){const a=this.findKeys(t,s);if(a.length){const o=this.headers.get(a[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(t,s=tn.Exact){const a=this.findKeys(t,s);if(a.length){const o=this.headers.get(a[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(t,s=tn.Exact){return this.findKeys(t,s).length>0}set(t,s,a=tn.Exact){this.delete(t,a),this.append(t,s,a)}append(t,s,a=tn.Exact){const o=C0(t);a===tn.CanonicalMIME&&(t=o);const u=this.findKeys(t,a);t=u.length>0?u[0]:t;const d=Xs.validHeaderValue(s);let m=this.headers.get(t);m||(m=[],this.headers.set(t,m)),m.push(d)}values(t,s=tn.Exact){const a=[];return this.findKeys(t,s).forEach(u=>{const d=this.headers.get(u);d&&a.push(...d)}),a}delete(t,s=tn.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 Xs;for(const a in t)s.headers.set(a,t[a]);return s}}function Rf(){return{encode(i){return Mi.encode(i)},decode(i){return sn.decode(i)}}}function Dn(i){return{encode(t){try{return t===void 0&&(t=null),Mi.encode(JSON.stringify(t))}catch(s){throw de.errorForCode(le.BadJson,s)}},decode(t){try{return JSON.parse(sn.decode(t),i)}catch(s){throw de.errorForCode(le.BadJson,s)}}}}function Hg(i){var t;return i&&i.data.length===0&&((t=i.headers)==null?void 0:t.code)===503?de.errorForCode(le.NoResponders):null}class oh{constructor(t,s,a){v(this,"_headers");v(this,"_msg");v(this,"_rdata");v(this,"_reply");v(this,"_subject");v(this,"publisher");this._msg=t,this._rdata=s,this.publisher=a}get subject(){return this._subject?this._subject:(this._subject=sn.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=sn.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=Xs.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=an,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,a=this._msg.size===-1?0:this._msg.size;return t+s+a}json(t){return Dn(t).decode(this.data)}string(){return sn.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(a,o){return(a==="start"||a==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}v(oh,"jc");function jr(i){return Qo("durable",i)}function zt(i){return Qo("stream",i)}function Qo(i,t=""){if(t==="")throw Error(`${i} name required`);return[".","*",">","/","\\"," "," ",`
31
31
  `,"\r"].forEach(a=>{if(t.indexOf(a)!==-1){switch(a){case`
32
- `:a="\\n";break;case"\r":a="\\r";break;case" ":a="\\t";break}throw Error(`invalid ${i} name - ${i} name cannot contain '${a}'`)}}),""}function Ua(i,t=""){if(t==="")throw Error(`${i} name required`);const s=e1(t);if(s.length)throw new Error(`invalid ${i} name - ${i} name ${s}`)}function e1(i=""){if(i==="")throw Error("name required");const t=/^[-\w]+$/g;if(i.match(t)===null){for(const a of i.split(""))if(a.match(t)===null)return`cannot contain '${a}'`}return""}function Rf(i){if(i.data.length>0)return!1;const t=i.headers;return t?t.code>=100&&t.code<200:!1}function Df(i){var t;return Rf(i)&&((t=i.headers)==null?void 0:t.description)==="Idle Heartbeat"}function t1(i,t,s){const a=ps(i,t),o={hdr:1,sid:0,size:0},u=new oh(o,an,{});return u._headers=a,u._subject=s,u}function Ar(i){if(i.data.length!==0)return null;const t=i.headers;return t?Bg(t.code,t.description):null}var _n;(function(i){i.MaxBatchExceeded="exceeded maxrequestbatch of",i.MaxExpiresExceeded="exceeded maxrequestexpires of",i.MaxBytesExceeded="exceeded maxrequestmaxbytes of",i.MaxMessageSizeExceeded="message size exceeds maxbytes",i.PushConsumer="consumer is push based",i.MaxWaitingExceeded="exceeded maxwaiting",i.IdleHeartbeatMissed="idle heartbeats missed",i.ConsumerDeleted="consumer deleted"})(_n||(_n={}));function n1(i){return i.code!==le.JetStream409?!1:[_n.MaxBatchExceeded,_n.MaxExpiresExceeded,_n.MaxBytesExceeded,_n.MaxMessageSizeExceeded,_n.PushConsumer,_n.IdleHeartbeatMissed,_n.ConsumerDeleted].find(s=>i.message.indexOf(s)!==-1)!==void 0}function Bg(i,t=""){if(i<300)return null;switch(t=t.toLowerCase(),i){case 404:return new he(t,le.JetStream404NoMessages);case 408:return new he(t,le.JetStream408RequestTimeout);case 409:{const s=t.startsWith(_n.IdleHeartbeatMissed)?le.JetStreamIdleHeartBeat:le.JetStream409;return new he(t,s)}case 503:return he.errorForCode(le.JetStreamNotEnabled,new Error(t));default:return t===""&&(t=le.Unknown),new he(t,`${i}`)}}class St{constructor(){v(this,"inflight");v(this,"processed");v(this,"received");v(this,"noIterator");v(this,"iterClosed");v(this,"done");v(this,"signal");v(this,"yields");v(this,"filtered");v(this,"pendingFiltered");v(this,"ingestionFilterFn");v(this,"protocolFilterFn");v(this,"dispatchedFn");v(this,"ctx");v(this,"_data");v(this,"err");v(this,"time");v(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=st(),this.yields=[],this.iterClosed=st(),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:a}=this.ingestionFilterFn?this.ingestionFilterFn(t,this.ctx||this):{ingest:!0,protocol:!1};s&&(a&&(this.filtered++,this.pendingFiltered++),this.yields.push(t),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new he("unsupported iterator",le.ApiError);if(this.yielding)throw new he("already yielding",le.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(u){throw u}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=st())}}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 ch{constructor(t,s,a={maxOut:2}){v(this,"interval");v(this,"maxOut");v(this,"cancelAfter");v(this,"timer");v(this,"autoCancelTimer");v(this,"last");v(this,"missed");v(this,"count");v(this,"callback");this.interval=t,this.maxOut=(a==null?void 0:a.maxOut)||2,this.cancelAfter=(a==null?void 0:a.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,a=2){this.interval=t,this.maxOut=a,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 qf;(function(i){i.Limits="limits",i.Interest="interest",i.Workqueue="workqueue"})(qf||(qf={}));var Va;(function(i){i.Old="old",i.New="new"})(Va||(Va={}));var zf;(function(i){i.File="file",i.Memory="memory"})(zf||(zf={}));var ft;(function(i){i.All="all",i.Last="last",i.New="new",i.StartSequence="by_start_sequence",i.StartTime="by_start_time",i.LastPerSubject="last_per_subject"})(ft||(ft={}));var wt;(function(i){i.None="none",i.All="all",i.Explicit="explicit",i.NotSet=""})(wt||(wt={}));var Cr;(function(i){i.Instant="instant",i.Original="original"})(Cr||(Cr={}));var ti;(function(i){i.None="none",i.S2="s2"})(ti||(ti={}));var Bo;(function(i){i.CreateOrUpdate="",i.Update="update",i.Create="create"})(Bo||(Bo={}));function s1(i,t={}){return Object.assign({name:i,deliver_policy:ft.All,ack_policy:wt.Explicit,ack_wait:nt(30*1e3),replay_policy:Cr.Instant},t)}var k0;(function(i){i.API="api_audit",i.StreamAction="stream_action",i.ConsumerAction="consumer_action",i.SnapshotCreate="snapshot_create",i.SnapshotComplete="snapshot_complete",i.RestoreCreate="restore_create",i.RestoreComplete="restore_complete",i.MaxDeliver="max_deliver",i.Terminated="terminated",i.Ack="consumer_ack",i.StreamLeaderElected="stream_leader_elected",i.StreamQuorumLost="stream_quorum_lost",i.ConsumerLeaderElected="consumer_leader_elected",i.ConsumerQuorumLost="consumer_quorum_lost"})(k0||(k0={}));var Bt;(function(i){i.StreamSourceHdr="Nats-Stream-Source",i.LastConsumerSeqHdr="Nats-Last-Consumer",i.LastStreamSeqHdr="Nats-Last-Stream",i.ConsumerStalledHdr="Nats-Consumer-Stalled",i.MessageSizeHdr="Nats-Msg-Size",i.RollupHdr="Nats-Rollup",i.RollupValueSubject="sub",i.RollupValueAll="all",i.PendingMessagesHdr="Nats-Pending-Messages",i.PendingBytesHdr="Nats-Pending-Bytes"})(Bt||(Bt={}));var kn;(function(i){i.LastValue="",i.AllHistory="history",i.UpdatesOnly="updates"})(kn||(kn={}));var wr;(function(i){i.Stream="Nats-Stream",i.Sequence="Nats-Sequence",i.TimeStamp="Nats-Time-Stamp",i.Subject="Nats-Subject"})(wr||(wr={}));var C0;(function(i){i.Stream="Nats-Stream",i.Subject="Nats-Subject",i.Sequence="Nats-Sequence",i.LastSequence="Nats-Last-Sequence",i.Size="Nats-Msg-Size"})(C0||(C0={}));const nn="KV_";class i1{constructor(t){v(this,"config");v(this,"ordered");v(this,"mack");v(this,"stream");v(this,"callbackFn");v(this,"max");v(this,"qname");v(this,"isBind");v(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=s1("",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(a=>{this.filterSubject(a)}),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?wt.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 jr(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=ft.StartSequence,this.config.opt_start_seq=t,this}startTime(t){return this.config.deliver_policy=ft.StartTime,this.config.opt_start_time=t.toISOString(),this}deliverAll(){return this.config.deliver_policy=ft.All,this}deliverLastPerSubject(){return this.config.deliver_policy=ft.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=ft.Last,this}deliverNew(){return this.config.deliver_policy=ft.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=wt.None,this}ackAll(){return this.config.ack_policy=wt.All,this}ackExplicit(){return this.config.ack_policy=wt.Explicit,this}ackWait(t){return this.config.ack_wait=nt(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=Cr.Instant,this}replayOriginal(){return this.config.replay_policy=Cr.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=nt(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=nt(t),this}maxPullBatch(t){return this.config.max_batch=t,this}maxPullRequestExpires(t){return this.config.max_expires=nt(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 Zs(i){return new i1(i)}function M0(i){return typeof i.getOpts=="function"}class r1{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 a=atob(t);return s?Uint8Array.from(a,o=>o.charCodeAt(0)):a}}class Or{static encode(t){return Or.toB64URLEncoding(r1.encode(t))}static decode(t,s=!1){return Or.decode(Or.fromB64URLEncoding(t),s)}static toB64URLEncoding(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(t){return t.replace(/_/g,"/").replace(/-/g,"+")}}class Mr{constructor(){v(this,"buffers");v(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...t){let s=0;for(let u=0;u<t.length;u++)s+=t[u].length;const a=new Uint8Array(s);let o=0;for(let u=0;u<t.length;u++)a.set(t[u],o),o+=t[u].length;return a}static fromAscii(t){return t||(t=""),Ci.encode(t)}static toAscii(t){return sn.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 a=0;a<this.buffers.length;a++)t.set(this.buffers[a],s),s+=this.buffers[a].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 a=this.byteLength;(t===void 0||t>a)&&(t=a);const o=s.subarray(0,t);return a>t&&this.buffers.push(s.subarray(t)),this.byteLength=a-t,o}}return new Uint8Array(0)}fill(t,...s){t&&(this.buffers.push(t),this.byteLength+=t.length);for(let a=0;a<s.length;a++)s[a]&&s[a].length&&(this.buffers.push(s[a]),this.byteLength+=s[a].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function a1(i,t){return t.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(a){if(a!=="default"&&!(a in i)){var o=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(i,a,o.get?o:{enumerable:!0,get:function(){return s[a]}})}})}),Object.freeze(i)}var l1=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Ca=l1.performance||{};Ca.now||Ca.mozNow||Ca.msNow||Ca.oNow||Ca.webkitNow;var R0={versions:{}},o1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function c1(i){if(i.__esModule)return i;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(i).forEach(function(s){var a=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return i[s]}})}),t}var pf,Qo={exports:{}},D0={},q0=c1(a1({__proto__:null,default:D0},[D0]));pf=Qo,(function(){var i="input is invalid type",t=typeof window=="object",s=t?window:{};s.JS_SHA256_NO_WINDOW&&(t=!1);var a=!t&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&R0.versions&&R0.versions.node;o?s=o1:a&&(s=self);var u=!s.JS_SHA256_NO_COMMON_JS&&pf.exports,d=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",m="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],y=[24,16,8,0],E=[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],_=["hex","array","digest","arrayBuffer"],N=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(O){return Object.prototype.toString.call(O)==="[object Array]"}),!d||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(O){return typeof O=="object"&&O.buffer&&O.buffer.constructor===ArrayBuffer});var R=function(O,J){return function(ae){return new $(J,!0).update(ae)[O]()}},M=function(O){var J=R("hex",O);o&&(J=D(J,O)),J.create=function(){return new $(O)},J.update=function(F){return J.create().update(F)};for(var ae=0;ae<_.length;++ae){var I=_[ae];J[I]=R(I,O)}return J},D=function(O,J){var ae,I=q0,F=q0.Buffer,Z=J?"sha224":"sha256";return ae=F.from&&!s.JS_SHA256_NO_BUFFER_FROM?F.from:function(re){return new F(re)},function(re){if(typeof re=="string")return I.createHash(Z).update(re,"utf8").digest("hex");if(re==null)throw new Error(i);return re.constructor===ArrayBuffer&&(re=new Uint8Array(re)),Array.isArray(re)||ArrayBuffer.isView(re)||re.constructor===F?I.createHash(Z).update(ae(re)).digest("hex"):O(re)}},G=function(O,J){return function(ae,I){return new ce(ae,J,!0).update(I)[O]()}},te=function(O){var J=G("hex",O);J.create=function(F){return new ce(F,O)},J.update=function(F,Z){return J.create(F).update(Z)};for(var ae=0;ae<_.length;++ae){var I=_[ae];J[I]=G(I,O)}return J};function $(O,J){J?(N[0]=N[16]=N[1]=N[2]=N[3]=N[4]=N[5]=N[6]=N[7]=N[8]=N[9]=N[10]=N[11]=N[12]=N[13]=N[14]=N[15]=0,this.blocks=N):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],O?(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=O}function ce(O,J,ae){var I,F=typeof O;if(F==="string"){var Z,re=[],ie=O.length,Oe=0;for(I=0;I<ie;++I)(Z=O.charCodeAt(I))<128?re[Oe++]=Z:Z<2048?(re[Oe++]=192|Z>>>6,re[Oe++]=128|63&Z):Z<55296||Z>=57344?(re[Oe++]=224|Z>>>12,re[Oe++]=128|Z>>>6&63,re[Oe++]=128|63&Z):(Z=65536+((1023&Z)<<10|1023&O.charCodeAt(++I)),re[Oe++]=240|Z>>>18,re[Oe++]=128|Z>>>12&63,re[Oe++]=128|Z>>>6&63,re[Oe++]=128|63&Z);O=re}else{if(F!=="object")throw new Error(i);if(O===null)throw new Error(i);if(d&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!(Array.isArray(O)||d&&ArrayBuffer.isView(O)))throw new Error(i)}O.length>64&&(O=new $(J,!0).update(O).array());var ke=[],Se=[];for(I=0;I<64;++I){var z=O[I]||0;ke[I]=92^z,Se[I]=54^z}$.call(this,J,ae),this.update(Se),this.oKeyPad=ke,this.inner=!0,this.sharedMemory=ae}$.prototype.update=function(O){if(!this.finalized){var J,ae=typeof O;if(ae!=="string"){if(ae!=="object")throw new Error(i);if(O===null)throw new Error(i);if(d&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!(Array.isArray(O)||d&&ArrayBuffer.isView(O)))throw new Error(i);J=!0}for(var I,F,Z=0,re=O.length,ie=this.blocks;Z<re;){if(this.hashed&&(this.hashed=!1,ie[0]=this.block,this.block=ie[16]=ie[1]=ie[2]=ie[3]=ie[4]=ie[5]=ie[6]=ie[7]=ie[8]=ie[9]=ie[10]=ie[11]=ie[12]=ie[13]=ie[14]=ie[15]=0),J)for(F=this.start;Z<re&&F<64;++Z)ie[F>>>2]|=O[Z]<<y[3&F++];else for(F=this.start;Z<re&&F<64;++Z)(I=O.charCodeAt(Z))<128?ie[F>>>2]|=I<<y[3&F++]:I<2048?(ie[F>>>2]|=(192|I>>>6)<<y[3&F++],ie[F>>>2]|=(128|63&I)<<y[3&F++]):I<55296||I>=57344?(ie[F>>>2]|=(224|I>>>12)<<y[3&F++],ie[F>>>2]|=(128|I>>>6&63)<<y[3&F++],ie[F>>>2]|=(128|63&I)<<y[3&F++]):(I=65536+((1023&I)<<10|1023&O.charCodeAt(++Z)),ie[F>>>2]|=(240|I>>>18)<<y[3&F++],ie[F>>>2]|=(128|I>>>12&63)<<y[3&F++],ie[F>>>2]|=(128|I>>>6&63)<<y[3&F++],ie[F>>>2]|=(128|63&I)<<y[3&F++]);this.lastByteIndex=F,this.bytes+=F-this.start,F>=64?(this.block=ie[16],this.start=F-64,this.hash(),this.hashed=!0):this.start=F}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},$.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var O=this.blocks,J=this.lastByteIndex;O[16]=this.block,O[J>>>2]|=g[3&J],this.block=O[16],J>=56&&(this.hashed||this.hash(),O[0]=this.block,O[16]=O[1]=O[2]=O[3]=O[4]=O[5]=O[6]=O[7]=O[8]=O[9]=O[10]=O[11]=O[12]=O[13]=O[14]=O[15]=0),O[14]=this.hBytes<<3|this.bytes>>>29,O[15]=this.bytes<<3,this.hash()}},$.prototype.hash=function(){var O,J,ae,I,F,Z,re,ie,Oe,ke=this.h0,Se=this.h1,z=this.h2,ne=this.h3,se=this.h4,ge=this.h5,be=this.h6,Ce=this.h7,Ee=this.blocks;for(O=16;O<64;++O)J=((F=Ee[O-15])>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,ae=((F=Ee[O-2])>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,Ee[O]=Ee[O-16]+J+Ee[O-7]+ae|0;for(Oe=Se&z,O=0;O<64;O+=4)this.first?(this.is224?(Z=300032,Ce=(F=Ee[0]-1413257819)-150054599|0,ne=F+24177077|0):(Z=704751109,Ce=(F=Ee[0]-210244248)-1521486534|0,ne=F+143694565|0),this.first=!1):(J=(ke>>>2|ke<<30)^(ke>>>13|ke<<19)^(ke>>>22|ke<<10),I=(Z=ke&Se)^ke&z^Oe,Ce=ne+(F=Ce+(ae=(se>>>6|se<<26)^(se>>>11|se<<21)^(se>>>25|se<<7))+(se&ge^~se&be)+E[O]+Ee[O])|0,ne=F+(J+I)|0),J=(ne>>>2|ne<<30)^(ne>>>13|ne<<19)^(ne>>>22|ne<<10),I=(re=ne&ke)^ne&Se^Z,be=z+(F=be+(ae=(Ce>>>6|Ce<<26)^(Ce>>>11|Ce<<21)^(Ce>>>25|Ce<<7))+(Ce&se^~Ce&ge)+E[O+1]+Ee[O+1])|0,J=((z=F+(J+I)|0)>>>2|z<<30)^(z>>>13|z<<19)^(z>>>22|z<<10),I=(ie=z&ne)^z&ke^re,ge=Se+(F=ge+(ae=(be>>>6|be<<26)^(be>>>11|be<<21)^(be>>>25|be<<7))+(be&Ce^~be&se)+E[O+2]+Ee[O+2])|0,J=((Se=F+(J+I)|0)>>>2|Se<<30)^(Se>>>13|Se<<19)^(Se>>>22|Se<<10),I=(Oe=Se&z)^Se&ne^ie,se=ke+(F=se+(ae=(ge>>>6|ge<<26)^(ge>>>11|ge<<21)^(ge>>>25|ge<<7))+(ge&be^~ge&Ce)+E[O+3]+Ee[O+3])|0,ke=F+(J+I)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+ke|0,this.h1=this.h1+Se|0,this.h2=this.h2+z|0,this.h3=this.h3+ne|0,this.h4=this.h4+se|0,this.h5=this.h5+ge|0,this.h6=this.h6+be|0,this.h7=this.h7+Ce|0},$.prototype.hex=function(){this.finalize();var O=this.h0,J=this.h1,ae=this.h2,I=this.h3,F=this.h4,Z=this.h5,re=this.h6,ie=this.h7,Oe=m[O>>>28&15]+m[O>>>24&15]+m[O>>>20&15]+m[O>>>16&15]+m[O>>>12&15]+m[O>>>8&15]+m[O>>>4&15]+m[15&O]+m[J>>>28&15]+m[J>>>24&15]+m[J>>>20&15]+m[J>>>16&15]+m[J>>>12&15]+m[J>>>8&15]+m[J>>>4&15]+m[15&J]+m[ae>>>28&15]+m[ae>>>24&15]+m[ae>>>20&15]+m[ae>>>16&15]+m[ae>>>12&15]+m[ae>>>8&15]+m[ae>>>4&15]+m[15&ae]+m[I>>>28&15]+m[I>>>24&15]+m[I>>>20&15]+m[I>>>16&15]+m[I>>>12&15]+m[I>>>8&15]+m[I>>>4&15]+m[15&I]+m[F>>>28&15]+m[F>>>24&15]+m[F>>>20&15]+m[F>>>16&15]+m[F>>>12&15]+m[F>>>8&15]+m[F>>>4&15]+m[15&F]+m[Z>>>28&15]+m[Z>>>24&15]+m[Z>>>20&15]+m[Z>>>16&15]+m[Z>>>12&15]+m[Z>>>8&15]+m[Z>>>4&15]+m[15&Z]+m[re>>>28&15]+m[re>>>24&15]+m[re>>>20&15]+m[re>>>16&15]+m[re>>>12&15]+m[re>>>8&15]+m[re>>>4&15]+m[15&re];return this.is224||(Oe+=m[ie>>>28&15]+m[ie>>>24&15]+m[ie>>>20&15]+m[ie>>>16&15]+m[ie>>>12&15]+m[ie>>>8&15]+m[ie>>>4&15]+m[15&ie]),Oe},$.prototype.toString=$.prototype.hex,$.prototype.digest=function(){this.finalize();var O=this.h0,J=this.h1,ae=this.h2,I=this.h3,F=this.h4,Z=this.h5,re=this.h6,ie=this.h7,Oe=[O>>>24&255,O>>>16&255,O>>>8&255,255&O,J>>>24&255,J>>>16&255,J>>>8&255,255&J,ae>>>24&255,ae>>>16&255,ae>>>8&255,255&ae,I>>>24&255,I>>>16&255,I>>>8&255,255&I,F>>>24&255,F>>>16&255,F>>>8&255,255&F,Z>>>24&255,Z>>>16&255,Z>>>8&255,255&Z,re>>>24&255,re>>>16&255,re>>>8&255,255&re];return this.is224||Oe.push(ie>>>24&255,ie>>>16&255,ie>>>8&255,255&ie),Oe},$.prototype.array=$.prototype.digest,$.prototype.arrayBuffer=function(){this.finalize();var O=new ArrayBuffer(this.is224?28:32),J=new DataView(O);return J.setUint32(0,this.h0),J.setUint32(4,this.h1),J.setUint32(8,this.h2),J.setUint32(12,this.h3),J.setUint32(16,this.h4),J.setUint32(20,this.h5),J.setUint32(24,this.h6),this.is224||J.setUint32(28,this.h7),O},ce.prototype=new $,ce.prototype.finalize=function(){if($.prototype.finalize.call(this),this.inner){this.inner=!1;var O=this.array();$.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(O),$.prototype.finalize.call(this)}};var oe=M();oe.sha256=oe,oe.sha224=M(!0),oe.sha256.hmac=te(),oe.sha224.hmac=te(!0),u?pf.exports=oe:(s.sha256=oe.sha256,s.sha224=oe.sha224)})();Qo.exports;Qo.exports.sha224;var z0=Qo.exports.sha256;function Uf(i){return p1(i)}function u1(i){if(!/^[0-9A-Fa-f]+$/.test(i))return!1;const s=/^[0-9A-F]+$/.test(i),a=/^[0-9a-f]+$/.test(i);return s||a?i.length%2===0:!1}function f1(i){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(i)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(i)}function h1(i){return u1(i)?"hex":f1(i)?"b64":""}function d1(i){if(i.length%2!==0)throw new Error("hex string must have an even length");const t=new Uint8Array(i.length/2);for(let s=0;s<i.length;s+=2)t[s/2]=parseInt(i.substring(s,s+2),16);return t}function m1(i){i=i.replace(/-/g,"+"),i=i.replace(/_/g,"/");const t=atob(i);return Uint8Array.from(t,s=>s.charCodeAt(0))}function p1(i){switch(h1(i)){case"hex":return d1(i);case"b64":return m1(i)}return null}function g1(i,t){const s=typeof i=="string"?Uf(i):i,a=typeof t=="string"?Uf(t):t;if(s===null||a===null||s.length!==a.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==a[o])return!1;return!0}class Lg{constructor(t,s,a=!0){v(this,"token");v(this,"received");v(this,"ctx");v(this,"requestSubject");v(this,"mux");this.mux=t,this.requestSubject=s,this.received=0,this.token=ei.next(),a&&(this.ctx=new Error)}}class y1 extends Lg{constructor(s,a,o={maxWait:1e3}){super(s,a);v(this,"callback");v(this,"done");v(this,"timer");v(this,"max");v(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=st(),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,a){s?(this.ctx&&(s.stack+=`
32
+ `:a="\\n";break;case"\r":a="\\r";break;case" ":a="\\t";break}throw Error(`invalid ${i} name - ${i} name cannot contain '${a}'`)}}),""}function za(i,t=""){if(t==="")throw Error(`${i} name required`);const s=s1(t);if(s.length)throw new Error(`invalid ${i} name - ${i} name ${s}`)}function s1(i=""){if(i==="")throw Error("name required");const t=/^[-\w]+$/g;if(i.match(t)===null){for(const a of i.split(""))if(a.match(t)===null)return`cannot contain '${a}'`}return""}function Df(i){if(i.data.length>0)return!1;const t=i.headers;return t?t.code>=100&&t.code<200:!1}function qf(i){var t;return Df(i)&&((t=i.headers)==null?void 0:t.description)==="Idle Heartbeat"}function i1(i,t,s){const a=ps(i,t),o={hdr:1,sid:0,size:0},u=new oh(o,an,{});return u._headers=a,u._subject=s,u}function Ar(i){if(i.data.length!==0)return null;const t=i.headers;return t?$g(t.code,t.description):null}var wn;(function(i){i.MaxBatchExceeded="exceeded maxrequestbatch of",i.MaxExpiresExceeded="exceeded maxrequestexpires of",i.MaxBytesExceeded="exceeded maxrequestmaxbytes of",i.MaxMessageSizeExceeded="message size exceeds maxbytes",i.PushConsumer="consumer is push based",i.MaxWaitingExceeded="exceeded maxwaiting",i.IdleHeartbeatMissed="idle heartbeats missed",i.ConsumerDeleted="consumer deleted"})(wn||(wn={}));function r1(i){return i.code!==le.JetStream409?!1:[wn.MaxBatchExceeded,wn.MaxExpiresExceeded,wn.MaxBytesExceeded,wn.MaxMessageSizeExceeded,wn.PushConsumer,wn.IdleHeartbeatMissed,wn.ConsumerDeleted].find(s=>i.message.indexOf(s)!==-1)!==void 0}function $g(i,t=""){if(i<300)return null;switch(t=t.toLowerCase(),i){case 404:return new de(t,le.JetStream404NoMessages);case 408:return new de(t,le.JetStream408RequestTimeout);case 409:{const s=t.startsWith(wn.IdleHeartbeatMissed)?le.JetStreamIdleHeartBeat:le.JetStream409;return new de(t,s)}case 503:return de.errorForCode(le.JetStreamNotEnabled,new Error(t));default:return t===""&&(t=le.Unknown),new de(t,`${i}`)}}class St{constructor(){v(this,"inflight");v(this,"processed");v(this,"received");v(this,"noIterator");v(this,"iterClosed");v(this,"done");v(this,"signal");v(this,"yields");v(this,"filtered");v(this,"pendingFiltered");v(this,"ingestionFilterFn");v(this,"protocolFilterFn");v(this,"dispatchedFn");v(this,"ctx");v(this,"_data");v(this,"err");v(this,"time");v(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=st(),this.yields=[],this.iterClosed=st(),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:a}=this.ingestionFilterFn?this.ingestionFilterFn(t,this.ctx||this):{ingest:!0,protocol:!1};s&&(a&&(this.filtered++,this.pendingFiltered++),this.yields.push(t),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new de("unsupported iterator",le.ApiError);if(this.yielding)throw new de("already yielding",le.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(u){throw u}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=st())}}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 ch{constructor(t,s,a={maxOut:2}){v(this,"interval");v(this,"maxOut");v(this,"cancelAfter");v(this,"timer");v(this,"autoCancelTimer");v(this,"last");v(this,"missed");v(this,"count");v(this,"callback");this.interval=t,this.maxOut=(a==null?void 0:a.maxOut)||2,this.cancelAfter=(a==null?void 0:a.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,a=2){this.interval=t,this.maxOut=a,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 zf;(function(i){i.Limits="limits",i.Interest="interest",i.Workqueue="workqueue"})(zf||(zf={}));var Ga;(function(i){i.Old="old",i.New="new"})(Ga||(Ga={}));var Uf;(function(i){i.File="file",i.Memory="memory"})(Uf||(Uf={}));var ft;(function(i){i.All="all",i.Last="last",i.New="new",i.StartSequence="by_start_sequence",i.StartTime="by_start_time",i.LastPerSubject="last_per_subject"})(ft||(ft={}));var wt;(function(i){i.None="none",i.All="all",i.Explicit="explicit",i.NotSet=""})(wt||(wt={}));var Cr;(function(i){i.Instant="instant",i.Original="original"})(Cr||(Cr={}));var ni;(function(i){i.None="none",i.S2="s2"})(ni||(ni={}));var Bo;(function(i){i.CreateOrUpdate="",i.Update="update",i.Create="create"})(Bo||(Bo={}));function a1(i,t={}){return Object.assign({name:i,deliver_policy:ft.All,ack_policy:wt.Explicit,ack_wait:nt(30*1e3),replay_policy:Cr.Instant},t)}var M0;(function(i){i.API="api_audit",i.StreamAction="stream_action",i.ConsumerAction="consumer_action",i.SnapshotCreate="snapshot_create",i.SnapshotComplete="snapshot_complete",i.RestoreCreate="restore_create",i.RestoreComplete="restore_complete",i.MaxDeliver="max_deliver",i.Terminated="terminated",i.Ack="consumer_ack",i.StreamLeaderElected="stream_leader_elected",i.StreamQuorumLost="stream_quorum_lost",i.ConsumerLeaderElected="consumer_leader_elected",i.ConsumerQuorumLost="consumer_quorum_lost"})(M0||(M0={}));var Bt;(function(i){i.StreamSourceHdr="Nats-Stream-Source",i.LastConsumerSeqHdr="Nats-Last-Consumer",i.LastStreamSeqHdr="Nats-Last-Stream",i.ConsumerStalledHdr="Nats-Consumer-Stalled",i.MessageSizeHdr="Nats-Msg-Size",i.RollupHdr="Nats-Rollup",i.RollupValueSubject="sub",i.RollupValueAll="all",i.PendingMessagesHdr="Nats-Pending-Messages",i.PendingBytesHdr="Nats-Pending-Bytes"})(Bt||(Bt={}));var Cn;(function(i){i.LastValue="",i.AllHistory="history",i.UpdatesOnly="updates"})(Cn||(Cn={}));var wr;(function(i){i.Stream="Nats-Stream",i.Sequence="Nats-Sequence",i.TimeStamp="Nats-Time-Stamp",i.Subject="Nats-Subject"})(wr||(wr={}));var R0;(function(i){i.Stream="Nats-Stream",i.Subject="Nats-Subject",i.Sequence="Nats-Sequence",i.LastSequence="Nats-Last-Sequence",i.Size="Nats-Msg-Size"})(R0||(R0={}));const nn="KV_";class l1{constructor(t){v(this,"config");v(this,"ordered");v(this,"mack");v(this,"stream");v(this,"callbackFn");v(this,"max");v(this,"qname");v(this,"isBind");v(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=a1("",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(a=>{this.filterSubject(a)}),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?wt.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 jr(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=ft.StartSequence,this.config.opt_start_seq=t,this}startTime(t){return this.config.deliver_policy=ft.StartTime,this.config.opt_start_time=t.toISOString(),this}deliverAll(){return this.config.deliver_policy=ft.All,this}deliverLastPerSubject(){return this.config.deliver_policy=ft.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=ft.Last,this}deliverNew(){return this.config.deliver_policy=ft.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=wt.None,this}ackAll(){return this.config.ack_policy=wt.All,this}ackExplicit(){return this.config.ack_policy=wt.Explicit,this}ackWait(t){return this.config.ack_wait=nt(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=Cr.Instant,this}replayOriginal(){return this.config.replay_policy=Cr.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=nt(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=nt(t),this}maxPullBatch(t){return this.config.max_batch=t,this}maxPullRequestExpires(t){return this.config.max_expires=nt(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 Zs(i){return new l1(i)}function D0(i){return typeof i.getOpts=="function"}class o1{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 a=atob(t);return s?Uint8Array.from(a,o=>o.charCodeAt(0)):a}}class Or{static encode(t){return Or.toB64URLEncoding(o1.encode(t))}static decode(t,s=!1){return Or.decode(Or.fromB64URLEncoding(t),s)}static toB64URLEncoding(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(t){return t.replace(/_/g,"/").replace(/-/g,"+")}}class Mr{constructor(){v(this,"buffers");v(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...t){let s=0;for(let u=0;u<t.length;u++)s+=t[u].length;const a=new Uint8Array(s);let o=0;for(let u=0;u<t.length;u++)a.set(t[u],o),o+=t[u].length;return a}static fromAscii(t){return t||(t=""),Mi.encode(t)}static toAscii(t){return sn.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 a=0;a<this.buffers.length;a++)t.set(this.buffers[a],s),s+=this.buffers[a].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 a=this.byteLength;(t===void 0||t>a)&&(t=a);const o=s.subarray(0,t);return a>t&&this.buffers.push(s.subarray(t)),this.byteLength=a-t,o}}return new Uint8Array(0)}fill(t,...s){t&&(this.buffers.push(t),this.byteLength+=t.length);for(let a=0;a<s.length;a++)s[a]&&s[a].length&&(this.buffers.push(s[a]),this.byteLength+=s[a].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function c1(i,t){return t.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(a){if(a!=="default"&&!(a in i)){var o=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(i,a,o.get?o:{enumerable:!0,get:function(){return s[a]}})}})}),Object.freeze(i)}var u1=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Ca=u1.performance||{};Ca.now||Ca.mozNow||Ca.msNow||Ca.oNow||Ca.webkitNow;var q0={versions:{}},f1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function h1(i){if(i.__esModule)return i;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(i).forEach(function(s){var a=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return i[s]}})}),t}var gf,Ko={exports:{}},z0={},U0=h1(c1({__proto__:null,default:z0},[z0]));gf=Ko,(function(){var i="input is invalid type",t=typeof window=="object",s=t?window:{};s.JS_SHA256_NO_WINDOW&&(t=!1);var a=!t&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&q0.versions&&q0.versions.node;o?s=f1:a&&(s=self);var u=!s.JS_SHA256_NO_COMMON_JS&&gf.exports,d=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",m="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],y=[24,16,8,0],E=[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],_=["hex","array","digest","arrayBuffer"],T=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(O){return Object.prototype.toString.call(O)==="[object Array]"}),!d||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(O){return typeof O=="object"&&O.buffer&&O.buffer.constructor===ArrayBuffer});var R=function(O,U){return function(ne){return new X(U,!0).update(ne)[O]()}},C=function(O){var U=R("hex",O);o&&(U=D(U,O)),U.create=function(){return new X(O)},U.update=function(I){return U.create().update(I)};for(var ne=0;ne<_.length;++ne){var G=_[ne];U[G]=R(G,O)}return U},D=function(O,U){var ne,G=U0,I=U0.Buffer,Z=U?"sha224":"sha256";return ne=I.from&&!s.JS_SHA256_NO_BUFFER_FROM?I.from:function(ae){return new I(ae)},function(ae){if(typeof ae=="string")return G.createHash(Z).update(ae,"utf8").digest("hex");if(ae==null)throw new Error(i);return ae.constructor===ArrayBuffer&&(ae=new Uint8Array(ae)),Array.isArray(ae)||ArrayBuffer.isView(ae)||ae.constructor===I?G.createHash(Z).update(ne(ae)).digest("hex"):O(ae)}},F=function(O,U){return function(ne,G){return new fe(ne,U,!0).update(G)[O]()}},te=function(O){var U=F("hex",O);U.create=function(I){return new fe(I,O)},U.update=function(I,Z){return U.create(I).update(Z)};for(var ne=0;ne<_.length;++ne){var G=_[ne];U[G]=F(G,O)}return U};function X(O,U){U?(T[0]=T[16]=T[1]=T[2]=T[3]=T[4]=T[5]=T[6]=T[7]=T[8]=T[9]=T[10]=T[11]=T[12]=T[13]=T[14]=T[15]=0,this.blocks=T):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],O?(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=O}function fe(O,U,ne){var G,I=typeof O;if(I==="string"){var Z,ae=[],re=O.length,je=0;for(G=0;G<re;++G)(Z=O.charCodeAt(G))<128?ae[je++]=Z:Z<2048?(ae[je++]=192|Z>>>6,ae[je++]=128|63&Z):Z<55296||Z>=57344?(ae[je++]=224|Z>>>12,ae[je++]=128|Z>>>6&63,ae[je++]=128|63&Z):(Z=65536+((1023&Z)<<10|1023&O.charCodeAt(++G)),ae[je++]=240|Z>>>18,ae[je++]=128|Z>>>12&63,ae[je++]=128|Z>>>6&63,ae[je++]=128|63&Z);O=ae}else{if(I!=="object")throw new Error(i);if(O===null)throw new Error(i);if(d&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!(Array.isArray(O)||d&&ArrayBuffer.isView(O)))throw new Error(i)}O.length>64&&(O=new X(U,!0).update(O).array());var he=[],Se=[];for(G=0;G<64;++G){var $=O[G]||0;he[G]=92^$,Se[G]=54^$}X.call(this,U,ne),this.update(Se),this.oKeyPad=he,this.inner=!0,this.sharedMemory=ne}X.prototype.update=function(O){if(!this.finalized){var U,ne=typeof O;if(ne!=="string"){if(ne!=="object")throw new Error(i);if(O===null)throw new Error(i);if(d&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!(Array.isArray(O)||d&&ArrayBuffer.isView(O)))throw new Error(i);U=!0}for(var G,I,Z=0,ae=O.length,re=this.blocks;Z<ae;){if(this.hashed&&(this.hashed=!1,re[0]=this.block,this.block=re[16]=re[1]=re[2]=re[3]=re[4]=re[5]=re[6]=re[7]=re[8]=re[9]=re[10]=re[11]=re[12]=re[13]=re[14]=re[15]=0),U)for(I=this.start;Z<ae&&I<64;++Z)re[I>>>2]|=O[Z]<<y[3&I++];else for(I=this.start;Z<ae&&I<64;++Z)(G=O.charCodeAt(Z))<128?re[I>>>2]|=G<<y[3&I++]:G<2048?(re[I>>>2]|=(192|G>>>6)<<y[3&I++],re[I>>>2]|=(128|63&G)<<y[3&I++]):G<55296||G>=57344?(re[I>>>2]|=(224|G>>>12)<<y[3&I++],re[I>>>2]|=(128|G>>>6&63)<<y[3&I++],re[I>>>2]|=(128|63&G)<<y[3&I++]):(G=65536+((1023&G)<<10|1023&O.charCodeAt(++Z)),re[I>>>2]|=(240|G>>>18)<<y[3&I++],re[I>>>2]|=(128|G>>>12&63)<<y[3&I++],re[I>>>2]|=(128|G>>>6&63)<<y[3&I++],re[I>>>2]|=(128|63&G)<<y[3&I++]);this.lastByteIndex=I,this.bytes+=I-this.start,I>=64?(this.block=re[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}},X.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var O=this.blocks,U=this.lastByteIndex;O[16]=this.block,O[U>>>2]|=g[3&U],this.block=O[16],U>=56&&(this.hashed||this.hash(),O[0]=this.block,O[16]=O[1]=O[2]=O[3]=O[4]=O[5]=O[6]=O[7]=O[8]=O[9]=O[10]=O[11]=O[12]=O[13]=O[14]=O[15]=0),O[14]=this.hBytes<<3|this.bytes>>>29,O[15]=this.bytes<<3,this.hash()}},X.prototype.hash=function(){var O,U,ne,G,I,Z,ae,re,je,he=this.h0,Se=this.h1,$=this.h2,se=this.h3,ie=this.h4,be=this.h5,ve=this.h6,Ce=this.h7,Ae=this.blocks;for(O=16;O<64;++O)U=((I=Ae[O-15])>>>7|I<<25)^(I>>>18|I<<14)^I>>>3,ne=((I=Ae[O-2])>>>17|I<<15)^(I>>>19|I<<13)^I>>>10,Ae[O]=Ae[O-16]+U+Ae[O-7]+ne|0;for(je=Se&$,O=0;O<64;O+=4)this.first?(this.is224?(Z=300032,Ce=(I=Ae[0]-1413257819)-150054599|0,se=I+24177077|0):(Z=704751109,Ce=(I=Ae[0]-210244248)-1521486534|0,se=I+143694565|0),this.first=!1):(U=(he>>>2|he<<30)^(he>>>13|he<<19)^(he>>>22|he<<10),G=(Z=he&Se)^he&$^je,Ce=se+(I=Ce+(ne=(ie>>>6|ie<<26)^(ie>>>11|ie<<21)^(ie>>>25|ie<<7))+(ie&be^~ie&ve)+E[O]+Ae[O])|0,se=I+(U+G)|0),U=(se>>>2|se<<30)^(se>>>13|se<<19)^(se>>>22|se<<10),G=(ae=se&he)^se&Se^Z,ve=$+(I=ve+(ne=(Ce>>>6|Ce<<26)^(Ce>>>11|Ce<<21)^(Ce>>>25|Ce<<7))+(Ce&ie^~Ce&be)+E[O+1]+Ae[O+1])|0,U=(($=I+(U+G)|0)>>>2|$<<30)^($>>>13|$<<19)^($>>>22|$<<10),G=(re=$&se)^$&he^ae,be=Se+(I=be+(ne=(ve>>>6|ve<<26)^(ve>>>11|ve<<21)^(ve>>>25|ve<<7))+(ve&Ce^~ve&ie)+E[O+2]+Ae[O+2])|0,U=((Se=I+(U+G)|0)>>>2|Se<<30)^(Se>>>13|Se<<19)^(Se>>>22|Se<<10),G=(je=Se&$)^Se&se^re,ie=he+(I=ie+(ne=(be>>>6|be<<26)^(be>>>11|be<<21)^(be>>>25|be<<7))+(be&ve^~be&Ce)+E[O+3]+Ae[O+3])|0,he=I+(U+G)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+he|0,this.h1=this.h1+Se|0,this.h2=this.h2+$|0,this.h3=this.h3+se|0,this.h4=this.h4+ie|0,this.h5=this.h5+be|0,this.h6=this.h6+ve|0,this.h7=this.h7+Ce|0},X.prototype.hex=function(){this.finalize();var O=this.h0,U=this.h1,ne=this.h2,G=this.h3,I=this.h4,Z=this.h5,ae=this.h6,re=this.h7,je=m[O>>>28&15]+m[O>>>24&15]+m[O>>>20&15]+m[O>>>16&15]+m[O>>>12&15]+m[O>>>8&15]+m[O>>>4&15]+m[15&O]+m[U>>>28&15]+m[U>>>24&15]+m[U>>>20&15]+m[U>>>16&15]+m[U>>>12&15]+m[U>>>8&15]+m[U>>>4&15]+m[15&U]+m[ne>>>28&15]+m[ne>>>24&15]+m[ne>>>20&15]+m[ne>>>16&15]+m[ne>>>12&15]+m[ne>>>8&15]+m[ne>>>4&15]+m[15&ne]+m[G>>>28&15]+m[G>>>24&15]+m[G>>>20&15]+m[G>>>16&15]+m[G>>>12&15]+m[G>>>8&15]+m[G>>>4&15]+m[15&G]+m[I>>>28&15]+m[I>>>24&15]+m[I>>>20&15]+m[I>>>16&15]+m[I>>>12&15]+m[I>>>8&15]+m[I>>>4&15]+m[15&I]+m[Z>>>28&15]+m[Z>>>24&15]+m[Z>>>20&15]+m[Z>>>16&15]+m[Z>>>12&15]+m[Z>>>8&15]+m[Z>>>4&15]+m[15&Z]+m[ae>>>28&15]+m[ae>>>24&15]+m[ae>>>20&15]+m[ae>>>16&15]+m[ae>>>12&15]+m[ae>>>8&15]+m[ae>>>4&15]+m[15&ae];return this.is224||(je+=m[re>>>28&15]+m[re>>>24&15]+m[re>>>20&15]+m[re>>>16&15]+m[re>>>12&15]+m[re>>>8&15]+m[re>>>4&15]+m[15&re]),je},X.prototype.toString=X.prototype.hex,X.prototype.digest=function(){this.finalize();var O=this.h0,U=this.h1,ne=this.h2,G=this.h3,I=this.h4,Z=this.h5,ae=this.h6,re=this.h7,je=[O>>>24&255,O>>>16&255,O>>>8&255,255&O,U>>>24&255,U>>>16&255,U>>>8&255,255&U,ne>>>24&255,ne>>>16&255,ne>>>8&255,255&ne,G>>>24&255,G>>>16&255,G>>>8&255,255&G,I>>>24&255,I>>>16&255,I>>>8&255,255&I,Z>>>24&255,Z>>>16&255,Z>>>8&255,255&Z,ae>>>24&255,ae>>>16&255,ae>>>8&255,255&ae];return this.is224||je.push(re>>>24&255,re>>>16&255,re>>>8&255,255&re),je},X.prototype.array=X.prototype.digest,X.prototype.arrayBuffer=function(){this.finalize();var O=new ArrayBuffer(this.is224?28:32),U=new DataView(O);return U.setUint32(0,this.h0),U.setUint32(4,this.h1),U.setUint32(8,this.h2),U.setUint32(12,this.h3),U.setUint32(16,this.h4),U.setUint32(20,this.h5),U.setUint32(24,this.h6),this.is224||U.setUint32(28,this.h7),O},fe.prototype=new X,fe.prototype.finalize=function(){if(X.prototype.finalize.call(this),this.inner){this.inner=!1;var O=this.array();X.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(O),X.prototype.finalize.call(this)}};var oe=C();oe.sha256=oe,oe.sha224=C(!0),oe.sha256.hmac=te(),oe.sha224.hmac=te(!0),u?gf.exports=oe:(s.sha256=oe.sha256,s.sha224=oe.sha224)})();Ko.exports;Ko.exports.sha224;var B0=Ko.exports.sha256;function Bf(i){return b1(i)}function d1(i){if(!/^[0-9A-Fa-f]+$/.test(i))return!1;const s=/^[0-9A-F]+$/.test(i),a=/^[0-9a-f]+$/.test(i);return s||a?i.length%2===0:!1}function m1(i){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(i)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(i)}function p1(i){return d1(i)?"hex":m1(i)?"b64":""}function g1(i){if(i.length%2!==0)throw new Error("hex string must have an even length");const t=new Uint8Array(i.length/2);for(let s=0;s<i.length;s+=2)t[s/2]=parseInt(i.substring(s,s+2),16);return t}function y1(i){i=i.replace(/-/g,"+"),i=i.replace(/_/g,"/");const t=atob(i);return Uint8Array.from(t,s=>s.charCodeAt(0))}function b1(i){switch(p1(i)){case"hex":return g1(i);case"b64":return y1(i)}return null}function x1(i,t){const s=typeof i=="string"?Bf(i):i,a=typeof t=="string"?Bf(t):t;if(s===null||a===null||s.length!==a.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==a[o])return!1;return!0}class Yg{constructor(t,s,a=!0){v(this,"token");v(this,"received");v(this,"ctx");v(this,"requestSubject");v(this,"mux");this.mux=t,this.requestSubject=s,this.received=0,this.token=ti.next(),a&&(this.ctx=new Error)}}class v1 extends Yg{constructor(s,a,o={maxWait:1e3}){super(s,a);v(this,"callback");v(this,"done");v(this,"timer");v(this,"max");v(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=st(),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,a){s?(this.ctx&&(s.stack+=`
33
33
 
34
- ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,a),this.opts.strategy===Mn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Mn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Mn.SentinelMsg&&a&&a.data.length===0&&this.cancel())}}class Pg extends Lg{constructor(s,a,o={timeout:1e3},u=!0){super(s,a,u);v(this,"deferred");v(this,"timer");this.deferred=st(),this.timer=kr(o.timeout,u)}resolver(s,a){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
34
+ ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,a),this.opts.strategy===Rn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Rn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Rn.SentinelMsg&&a&&a.data.length===0&&this.cancel())}}class Gg extends Yg{constructor(s,a,o={timeout:1e3},u=!0){super(s,a,u);v(this,"deferred");v(this,"timer");this.deferred=st(),this.timer=kr(o.timeout,u)}resolver(s,a){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
35
35
 
36
- ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(a),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||he.errorForCode(le.Cancelled))}}const b1="$JS.API";function x1(i){return i=i||{},i.domain&&(i.apiPrefix=`$JS.${i.domain}.API`,delete i.domain),Fo({apiPrefix:b1,timeout:5e3},i)}class Ka{constructor(t,s){v(this,"nc");v(this,"opts");v(this,"prefix");v(this,"timeout");v(this,"jc");this.nc=t,this.opts=x1(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=Rn()}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,a){a=a||{},a.timeout=this.timeout;let o=an;s&&(o=this.jc.encode(s));let{retries:u}=a;u=u||1,u=u===-1?Number.MAX_SAFE_INTEGER:u;const d=ah();for(let m=0;m<u;m++)try{const g=await this.nc.request(t,o,a);return this.parseJsResponse(g)}catch(g){const y=g;if((y.code==="503"||y.code===le.Timeout)&&m+1<u)await Rr(d.backoff(m));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),a=s;if(a.error){const o=Bg(a.error.code,a.error.description);if(o!==null)throw o.api_error=a.error,o}return s}}class Ba{constructor(t,s,a,o){v(this,"err");v(this,"offset");v(this,"pageInfo");v(this,"subject");v(this,"jsm");v(this,"filter");v(this,"payload");if(!t)throw new Error("subject is required");this.subject=t,this.jsm=a,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 a=this.countResponse(s);return a===0?[]:(this.offset+=a,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(t){var s,a,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((a=t.consumers)==null?void 0:a.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 Ti(i=""){const t=i.match(/(\d+).(\d+).(\d+)/);if(t)return{major:parseInt(t[1]),minor:parseInt(t[2]),micro:parseInt(t[3])};throw new Error(`'${i}' is not a semver value`)}function Bf(i,t){return i.major<t.major?-1:i.major>t.major?1:i.minor<t.minor?-1:i.minor>t.minor?1:i.micro<t.micro?-1:i.micro>t.micro?1:0}var Le;(function(i){i.JS_KV="js_kv",i.JS_OBJECTSTORE="js_objectstore",i.JS_PULL_MAX_BYTES="js_pull_max_bytes",i.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",i.JS_ALLOW_DIRECT="js_allow_direct",i.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",i.JS_SIMPLIFICATION="js_simplification",i.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",i.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",i.JS_STREAM_FIRST_SEQ="js_stream_first_seq",i.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",i.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",i.JS_STREAM_COMPRESSION="js_stream_compression",i.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",i.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Le||(Le={}));class v1{constructor(t){v(this,"server");v(this,"features");v(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=Ti(t)),this.server=t,this.set(Le.JS_KV,"2.6.2"),this.set(Le.JS_OBJECTSTORE,"2.6.3"),this.set(Le.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Le.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Le.JS_ALLOW_DIRECT,"2.9.0"),this.set(Le.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Le.JS_SIMPLIFICATION,"2.9.4"),this.set(Le.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Le.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Le.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Le.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Le.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Le.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Le.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Le.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:Bf(this.server,Ti(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=Ti(t)),Bf(this.server,t)>=0}}class Lo extends Ka{constructor(t,s){super(t,s)}async add(t,s,a=Bo.Create){if(zt(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=a,o.config.durable_name&&jr(o.config.durable_name);const u=this.nc;let{min:d,ok:m}=u.features.get(Le.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!m)throw new Error(`consumer 'name' requires server ${d}`);if(g)try{Jo("name",g)}catch(N){const R=N.message,M=R.indexOf("cannot contain");throw M!==-1?new Error(`consumer 'name' ${R.substring(M)}`):N}let y,E="";if(Array.isArray(s.filter_subjects)){const{min:N,ok:R}=u.features.get(Le.JS_MULTIPLE_CONSUMER_FILTER);if(!R)throw new Error(`consumer 'filter_subjects' requires server ${N}`);m=!1}if(s.metadata){const{min:N,ok:R}=u.features.get(Le.JS_STREAM_CONSUMER_METADATA);if(!R)throw new Error(`consumer 'metadata' requires server ${N}`)}if(m&&(E=s.name??s.durable_name??""),E!==""){let N=s.filter_subject??void 0;N===">"&&(N=void 0),y=N!==void 0?`${this.prefix}.CONSUMER.CREATE.${t}.${E}.${N}`:`${this.prefix}.CONSUMER.CREATE.${t}.${E}`}else y=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${t}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${t}`;return await this._request(y,o)}async update(t,s,a){const o=await this.info(t,s),u=a;return this.add(t,Object.assign(o.config,u),Bo.Update)}async info(t,s){return zt(t),jr(s),await this._request(`${this.prefix}.CONSUMER.INFO.${t}.${s}`)}async delete(t,s){return zt(t),jr(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${t}.${s}`)).success}list(t){zt(t);const s=o=>o.consumers,a=`${this.prefix}.CONSUMER.LIST.${t}`;return new Ba(a,s,this)}pause(t,s,a){const o=`${this.prefix}.CONSUMER.PAUSE.${t}.${s}`,u={pause_until:a.toISOString()};return this._request(o,u)}resume(t,s){return this.pause(t,s,new Date(0))}}function xr(i,t,s=!1){if(s===!0&&!i)throw he.errorForCode(le.ApiError,new Error(`${t} is not a function`));if(i&&typeof i!="function")throw he.errorForCode(le.ApiError,new Error(`${t} is not a function`))}class _1 extends St{constructor(s,a,o){super();v(this,"sub");v(this,"adapter");v(this,"subIterDone");xr(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&xr(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&(xr(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&(xr(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&(xr(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&xr(o.cleanupFn,"cleanupFn");let u=(E,_)=>{this.callback(E,_)};if(o.callback){const E=o.callback;u=(_,N)=>{const[R,M]=this.adapter(_,N);if(R){E(R,null);return}const{ingest:D}=this.ingestionFilterFn?this.ingestionFilterFn(M,this):{ingest:!0};D&&(!this.protocolFilterFn||this.protocolFilterFn(M))&&(E(R,M),this.dispatchedFn&&M&&this.dispatchedFn(M))}}const{max:d,queue:m,timeout:g}=o,y={queue:m,timeout:g,callback:u};d&&d>0&&(y.max=d),this.sub=s.subscribe(a,y),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=st(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async E=>{await E.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,a){this.sub.cancelTimeout();const[o,u]=this.adapter(s,a);o&&this.stop(o),u&&this.push(u)}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 rn;function w1(i){rn=i}function Hg(){return rn!==void 0&&rn.defaultPort!==void 0?rn.defaultPort:4222}function gf(){return rn!==void 0&&rn.urlParseFn?rn.urlParseFn:void 0}function S1(){if(!rn||typeof rn.factory!="function")throw new Error("transport fn is not set");return rn.factory()}function Lf(){return rn!==void 0&&rn.dnsResolveFn?rn.dnsResolveFn:void 0}const To=`\r
37
- `,Po=Mr.fromAscii(To),E1=new Uint8Array(Po)[0],j1=new Uint8Array(Po)[1];function A1(i){for(let t=0;t<i.length;t++){const s=t+1;if(i.byteLength>s&&i[t]===E1&&i[s]===j1)return s+1}return 0}function O1(i){const t=A1(i);if(t>0){const a=new Uint8Array(i).slice(0,t);return sn.decode(a)}return""}const N1=4,$g=48,T1=65,k1=97;function C1(i,t,s,a){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((d,m)=>{o[m]=d}),o[12]=i,o[13]=t,o[14]=s,o[15]=a,o}function Pf(i){return M1(i)!==void 0}function M1(i){for(let t=0;t<i.length;t++)switch(i[t]){case".":return Yg(i);case":":return R1(i)}}function Yg(i){const t=new Uint8Array(4);for(let s=0;s<4;s++){if(i.length===0)return;if(s>0){if(i[0]!==".")return;i=i.substring(1)}const{n:a,c:o,ok:u}=D1(i);if(!u||a>255)return;i=i.substring(o),t[s]=a}return C1(t[0],t[1],t[2],t[3])}function R1(i){const t=new Uint8Array(16);let s=-1;if(i.length>=2&&i[0]===":"&&i[1]===":"&&(s=0,i=i.substring(2),i.length===0))return t;let a=0;for(;a<16;){const{n:o,c:u,ok:d}=q1(i);if(!d||o>65535)return;if(u<i.length&&i[u]==="."){if(s<0&&a!=12||a+4>16)return;const m=Yg(i);if(m===void 0)return;t[a]=m[12],t[a+1]=m[13],t[a+2]=m[14],t[a+3]=m[15],i="",a+=N1;break}if(t[a]=o>>8,t[a+1]=o,a+=2,i=i.substring(u),i.length===0)break;if(i[0]!==":"||i.length==1)return;if(i=i.substring(1),i[0]===":"){if(s>=0)return;if(s=a,i=i.substring(1),i.length===0)break}}if(i.length===0){if(a<16){if(s<0)return;const o=16-a;for(let u=a-1;u>=s;u--)t[u+o]=t[u];for(let u=s+o-1;u>=s;u--)t[u]=0}else if(s>=0)return;return t}}function D1(i){let t=0,s=0;for(t=0;t<i.length&&48<=i.charCodeAt(t)&&i.charCodeAt(t)<=57;t++)if(s=s*10+(i.charCodeAt(t)-$g),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 q1(i){let t=0,s=0;for(s=0;s<i.length;s++){if(48<=i.charCodeAt(s)&&i.charCodeAt(s)<=57)t*=16,t+=i.charCodeAt(s)-$g;else if(97<=i.charCodeAt(s)&&i.charCodeAt(s)<=102)t*=16,t+=i.charCodeAt(s)-k1+10;else if(65<=i.charCodeAt(s)&&i.charCodeAt(s)<=70)t*=16,t+=i.charCodeAt(s)-T1+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 z1(i){return i.indexOf("[")!==-1||i.indexOf("::")!==-1?!1:i.indexOf(".")!==-1||i.split(":").length<=2}function Hf(i){return!z1(i)}function U1(i){const t="::FFFF:",s=i.toUpperCase().indexOf(t);if(s!==-1&&i.indexOf(".")!==-1){let a=i.substring(s+t.length);return a=a.replace("[",""),a.replace("]","")}return i}function B1(i){i=i.trim(),i.match(/^(.*:\/\/)(.*)/m)&&(i=i.replace(/^(.*:\/\/)(.*)/gm,"$2")),i=U1(i),Hf(i)&&i.indexOf("[")===-1&&(i=`[${i}]`);const t=Hf(i)?i.match(/(]:)(\d+)/):i.match(/(:)(\d+)/),s=t&&t.length===3&&t[1]&&t[2]?parseInt(t[2]):4222,a=s===80?"https":"http",o=new URL(`${a}://${i}`);o.port=`${s}`;let u=o.hostname;return u.charAt(0)==="["&&(u=u.substring(1,u.length-1)),{listen:o.host,hostname:u,port:s}}class $a{constructor(t,s=!1){v(this,"src");v(this,"listen");v(this,"hostname");v(this,"port");v(this,"didConnect");v(this,"reconnects");v(this,"lastConnect");v(this,"gossiped");v(this,"tlsName");v(this,"resolves");this.src=t,this.tlsName="";const a=B1(t);this.listen=a.listen,this.hostname=a.hostname,this.port=a.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(Pf(this.hostname))return[this];{const a=await t.fn(this.hostname);t.debug&&console.log(`resolve ${this.hostname} = ${a.join(",")}`);for(const o of a){const u=this.port===80?"https":"http",d=new URL(`${u}://${Hf(o)?"["+o+"]":o}`);d.port=`${this.port}`;const m=new $a(d.host,!1);m.tlsName=this.hostname,s.push(m)}}return t.randomize&&zg(s),this.resolves=s,s}}class L1{constructor(t=[],s={}){v(this,"firstSelect");v(this,"servers");v(this,"currentServer");v(this,"tlsName");v(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const a=gf();t&&(t.forEach(o=>{o=a?a(o):o,this.servers.push(new $a(o))}),this.randomize&&(this.servers=zg(this.servers))),this.servers.length===0&&this.addServer(`${Cf}:${Hg()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const t=this.getCurrentServer();Pf(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 a=gf();t=a?a(t):t;const o=new $a(t,s);Pf(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 a=[];let o=[];const u=gf(),d=new Map;t.connect_urls&&t.connect_urls.length>0&&t.connect_urls.forEach(g=>{g=u?u(g,s):g;const y=new $a(g,!0);d.set(g,y)});const m=[];return this.servers.forEach((g,y)=>{const E=g.listen;g.gossiped&&this.currentServer.listen!==E&&d.get(E)===void 0&&m.push(y),d.delete(E)}),m.reverse(),m.forEach(g=>{const y=this.servers.splice(g,1);o=o.concat(y[0].listen)}),d.forEach((g,y)=>{this.servers.push(g),a.push(y)}),{added:a,deleted:o}}}class P1{constructor(){v(this,"baseInbox");v(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(t){return this.baseInbox=`${ms(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 a=s.permissionContext;if(a.operation==="publish"){const o=this.all().find(u=>u.requestSubject===a.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(t,s)=>{const a=this.getToken(s);if(a){const o=this.get(a);o&&(t===null&&s.headers&&(t=Ug(s)),o.resolver(t,s))}}}close(){const t=he.errorForCode(le.Timeout);this.reqs.forEach(s=>{s.resolver(t,{})})}}class H1{constructor(t,s,a){v(this,"ph");v(this,"interval");v(this,"maxOut");v(this,"timer");v(this,"pendings");this.ph=t,this.interval=s,this.maxOut=a,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:Er.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const t=st();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 $1 extends Error{constructor(t){super(t),this.name="AssertionError"}}function Y1(i,t="Assertion failed."){if(!i)throw new $1(t)}const U0=32*1024,yf=2**32-2;function wo(i,t,s=0){const a=t.byteLength-s;return i.byteLength>a&&(i=i.subarray(0,a)),t.set(i,s),i.byteLength}class bf{constructor(t){v(this,"_buf");v(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){Y1(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=wo(this._buf.subarray(this._off),t);return this._off+=s,s}writeByte(t){return this.write(Uint8Array.of(t))}writeString(t){return this.write(Ci.encode(t))}write(t){const s=this._grow(t.byteLength);return wo(t,this._buf,s)}_grow(t){const s=this.length;s===0&&this._off!==0&&this.reset();const a=this._tryGrowByReslice(t);if(a>=0)return a;const o=this.capacity;if(t<=Math.floor(o/2)-s)wo(this._buf.subarray(this._off),this._buf);else{if(o+t>yf)throw new Error("The buffer cannot be grown beyond the maximum size.");{const u=new Uint8Array(Math.min(2*o+t,yf));wo(this._buf.subarray(this._off),u),this._buf=u}}return this._off=0,this._reslice(Math.min(s+t,yf)),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 a=new Uint8Array(U0);for(;;){const o=this.capacity-this.length<U0,u=o?a:new Uint8Array(this._buf.buffer,this.length),d=t.read(u);if(d===null)return s;o?this.write(u.subarray(0,d)):this._reslice(this.length+d),s+=d}}}var Ut;(function(i){i[i.OK=0]="OK",i[i.ERR=1]="ERR",i[i.MSG=2]="MSG",i[i.INFO=3]="INFO",i[i.PING=4]="PING",i[i.PONG=5]="PONG"})(Ut||(Ut={}));function B0(){const i={};return i.sid=-1,i.hdr=-1,i.size=-1,i}const G1=48;class L0{constructor(t){v(this,"dispatcher");v(this,"state");v(this,"as");v(this,"drop");v(this,"hdr");v(this,"ma");v(this,"argBuf");v(this,"msgBuf");this.dispatcher=t,this.state=ue.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(t){let s;for(s=0;s<t.length;s++){const a=t[s];switch(this.state){case ue.OP_START:switch(a){case fe.M:case fe.m:this.state=ue.OP_M,this.hdr=-1,this.ma=B0();break;case fe.H:case fe.h:this.state=ue.OP_H,this.hdr=0,this.ma=B0();break;case fe.P:case fe.p:this.state=ue.OP_P;break;case fe.PLUS:this.state=ue.OP_PLUS;break;case fe.MINUS:this.state=ue.OP_MINUS;break;case fe.I:case fe.i:this.state=ue.OP_I;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_H:switch(a){case fe.M:case fe.m:this.state=ue.OP_M;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_M:switch(a){case fe.S:case fe.s:this.state=ue.OP_MS;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MS:switch(a){case fe.G:case fe.g:this.state=ue.OP_MSG;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MSG:switch(a){case fe.SPACE:case fe.TAB:this.state=ue.OP_MSG_SPC;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MSG_SPC:switch(a){case fe.SPACE:case fe.TAB:continue;default:this.state=ue.MSG_ARG,this.as=s}break;case ue.MSG_ARG:switch(a){case fe.CR:this.drop=1;break;case fe.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=ue.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;case ue.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Ut.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=ue.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const u=t.length-s;u<o&&(o=u),o>0?(this.msgBuf.write(t.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(a)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Ut.MSG,msg:this.ma,data:t.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=ue.MSG_END);break;case ue.MSG_END:switch(a){case fe.NL:this.drop=0,this.as=s+1,this.state=ue.OP_START;break;default:continue}break;case ue.OP_PLUS:switch(a){case fe.O:case fe.o:this.state=ue.OP_PLUS_O;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PLUS_O:switch(a){case fe.K:case fe.k:this.state=ue.OP_PLUS_OK;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PLUS_OK:switch(a){case fe.NL:this.dispatcher.push({kind:Ut.OK}),this.drop=0,this.state=ue.OP_START;break}break;case ue.OP_MINUS:switch(a){case fe.E:case fe.e:this.state=ue.OP_MINUS_E;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MINUS_E:switch(a){case fe.R:case fe.r:this.state=ue.OP_MINUS_ER;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MINUS_ER:switch(a){case fe.R:case fe.r:this.state=ue.OP_MINUS_ERR;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MINUS_ERR:switch(a){case fe.SPACE:case fe.TAB:this.state=ue.OP_MINUS_ERR_SPC;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_MINUS_ERR_SPC:switch(a){case fe.SPACE:case fe.TAB:continue;default:this.state=ue.MINUS_ERR_ARG,this.as=s}break;case ue.MINUS_ERR_ARG:switch(a){case fe.CR:this.drop=1;break;case fe.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:Ut.ERR,data:o}),this.drop=0,this.as=s+1,this.state=ue.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(a))}break;case ue.OP_P:switch(a){case fe.I:case fe.i:this.state=ue.OP_PI;break;case fe.O:case fe.o:this.state=ue.OP_PO;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PO:switch(a){case fe.N:case fe.n:this.state=ue.OP_PON;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PON:switch(a){case fe.G:case fe.g:this.state=ue.OP_PONG;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PONG:switch(a){case fe.NL:this.dispatcher.push({kind:Ut.PONG}),this.drop=0,this.state=ue.OP_START;break}break;case ue.OP_PI:switch(a){case fe.N:case fe.n:this.state=ue.OP_PIN;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PIN:switch(a){case fe.G:case fe.g:this.state=ue.OP_PING;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_PING:switch(a){case fe.NL:this.dispatcher.push({kind:Ut.PING}),this.drop=0,this.state=ue.OP_START;break}break;case ue.OP_I:switch(a){case fe.N:case fe.n:this.state=ue.OP_IN;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_IN:switch(a){case fe.F:case fe.f:this.state=ue.OP_INF;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_INF:switch(a){case fe.O:case fe.o:this.state=ue.OP_INFO;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_INFO:switch(a){case fe.SPACE:case fe.TAB:this.state=ue.OP_INFO_SPC;break;default:throw this.fail(t.subarray(s))}break;case ue.OP_INFO_SPC:switch(a){case fe.SPACE:case fe.TAB:continue;default:this.state=ue.INFO_ARG,this.as=s}break;case ue.INFO_ARG:switch(a){case fe.CR:this.drop=1;break;case fe.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:Ut.INFO,data:o}),this.drop=0,this.as=s+1,this.state=ue.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;default:throw this.fail(t.subarray(s))}}(this.state===ue.MSG_ARG||this.state===ue.MINUS_ERR_ARG||this.state===ue.INFO_ARG)&&!this.argBuf&&(this.argBuf=new bf(t.subarray(this.as,s-this.drop))),this.state===ue.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new bf(t.subarray(this.as)))}cloneMsgArg(){const t=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,a=new Uint8Array(t+s);a.set(this.ma.subject),this.ma.reply&&a.set(this.ma.reply,t),this.argBuf=new bf(a),this.ma.subject=a.subarray(0,t),this.ma.reply&&(this.ma.reply=a.subarray(t))}processMsgArgs(t){if(this.hdr>=0)return this.processHeaderMsgArgs(t);const s=[];let a=-1;for(let o=0;o<t.length;o++)switch(t[o]){case fe.SPACE:case fe.TAB:case fe.CR:case fe.NL:a>=0&&(s.push(t.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(t.subarray(a)),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}: ${sn.decode(t)}`)}processHeaderMsgArgs(t){const s=[];let a=-1;for(let o=0;o<t.length;o++)switch(t[o]){case fe.SPACE:case fe.TAB:case fe.CR:case fe.NL:a>=0&&(s.push(t.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(t.subarray(a)),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 a=0;a<t.length;a++){if(t[a]<48||t[a]>57)return-1;s=s*10+(t[a]-G1)}return s}}var ue;(function(i){i[i.OP_START=0]="OP_START",i[i.OP_PLUS=1]="OP_PLUS",i[i.OP_PLUS_O=2]="OP_PLUS_O",i[i.OP_PLUS_OK=3]="OP_PLUS_OK",i[i.OP_MINUS=4]="OP_MINUS",i[i.OP_MINUS_E=5]="OP_MINUS_E",i[i.OP_MINUS_ER=6]="OP_MINUS_ER",i[i.OP_MINUS_ERR=7]="OP_MINUS_ERR",i[i.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",i[i.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",i[i.OP_M=10]="OP_M",i[i.OP_MS=11]="OP_MS",i[i.OP_MSG=12]="OP_MSG",i[i.OP_MSG_SPC=13]="OP_MSG_SPC",i[i.MSG_ARG=14]="MSG_ARG",i[i.MSG_PAYLOAD=15]="MSG_PAYLOAD",i[i.MSG_END=16]="MSG_END",i[i.OP_H=17]="OP_H",i[i.OP_P=18]="OP_P",i[i.OP_PI=19]="OP_PI",i[i.OP_PIN=20]="OP_PIN",i[i.OP_PING=21]="OP_PING",i[i.OP_PO=22]="OP_PO",i[i.OP_PON=23]="OP_PON",i[i.OP_PONG=24]="OP_PONG",i[i.OP_I=25]="OP_I",i[i.OP_IN=26]="OP_IN",i[i.OP_INF=27]="OP_INF",i[i.OP_INFO=28]="OP_INFO",i[i.OP_INFO_SPC=29]="OP_INFO_SPC",i[i.INFO_ARG=30]="INFO_ARG"})(ue||(ue={}));var fe;(function(i){i[i.CR=13]="CR",i[i.E=69]="E",i[i.e=101]="e",i[i.F=70]="F",i[i.f=102]="f",i[i.G=71]="G",i[i.g=103]="g",i[i.H=72]="H",i[i.h=104]="h",i[i.I=73]="I",i[i.i=105]="i",i[i.K=75]="K",i[i.k=107]="k",i[i.M=77]="M",i[i.m=109]="m",i[i.MINUS=45]="MINUS",i[i.N=78]="N",i[i.n=110]="n",i[i.NL=10]="NL",i[i.O=79]="O",i[i.o=111]="o",i[i.P=80]="P",i[i.p=112]="p",i[i.PLUS=43]="PLUS",i[i.R=82]="R",i[i.r=114]="r",i[i.S=83]="S",i[i.s=115]="s",i[i.SPACE=32]="SPACE",i[i.TAB=9]="TAB"})(fe||(fe={}));(function(i){var t=function(x,S){this.hi=x|0,this.lo=S|0},s=function(x){var S,w=new Float64Array(16);if(x)for(S=0;S<x.length;S++)w[S]=x[S];return w},a=function(){throw new Error("no PRNG")},o=new Uint8Array(16),u=new Uint8Array(32);u[0]=9;var d=s(),m=s([1]),g=s([56129,1]),y=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),E=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),_=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),N=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),R=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function M(x,S){return x<<S|x>>>32-S}function D(x,S){var w=x[S+3]&255;return w=w<<8|x[S+2]&255,w=w<<8|x[S+1]&255,w<<8|x[S+0]&255}function G(x,S){var w=x[S]<<24|x[S+1]<<16|x[S+2]<<8|x[S+3],j=x[S+4]<<24|x[S+5]<<16|x[S+6]<<8|x[S+7];return new t(w,j)}function te(x,S,w){var j;for(j=0;j<4;j++)x[S+j]=w&255,w>>>=8}function $(x,S,w){x[S]=w.hi>>24&255,x[S+1]=w.hi>>16&255,x[S+2]=w.hi>>8&255,x[S+3]=w.hi&255,x[S+4]=w.lo>>24&255,x[S+5]=w.lo>>16&255,x[S+6]=w.lo>>8&255,x[S+7]=w.lo&255}function ce(x,S,w,j,k){var U,X=0;for(U=0;U<k;U++)X|=x[S+U]^w[j+U];return(1&X-1>>>8)-1}function oe(x,S,w,j){return ce(x,S,w,j,16)}function O(x,S,w,j){return ce(x,S,w,j,32)}function J(x,S,w,j,k){var U=new Uint32Array(16),X=new Uint32Array(16),ee=new Uint32Array(16),H=new Uint32Array(4),K,de,Te;for(K=0;K<4;K++)X[5*K]=D(j,4*K),X[1+K]=D(w,4*K),X[6+K]=D(S,4*K),X[11+K]=D(w,16+4*K);for(K=0;K<16;K++)ee[K]=X[K];for(K=0;K<20;K++){for(de=0;de<4;de++){for(Te=0;Te<4;Te++)H[Te]=X[(5*de+4*Te)%16];for(H[1]^=M(H[0]+H[3]|0,7),H[2]^=M(H[1]+H[0]|0,9),H[3]^=M(H[2]+H[1]|0,13),H[0]^=M(H[3]+H[2]|0,18),Te=0;Te<4;Te++)U[4*de+(de+Te)%4]=H[Te]}for(Te=0;Te<16;Te++)X[Te]=U[Te]}if(k){for(K=0;K<16;K++)X[K]=X[K]+ee[K]|0;for(K=0;K<4;K++)X[5*K]=X[5*K]-D(j,4*K)|0,X[6+K]=X[6+K]-D(S,4*K)|0;for(K=0;K<4;K++)te(x,4*K,X[5*K]),te(x,16+4*K,X[6+K])}else for(K=0;K<16;K++)te(x,4*K,X[K]+ee[K]|0)}function ae(x,S,w,j){return J(x,S,w,j,!1),0}function I(x,S,w,j){return J(x,S,w,j,!0),0}var F=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Z(x,S,w,j,k,U,X){var ee=new Uint8Array(16),H=new Uint8Array(64),K,de;if(!k)return 0;for(de=0;de<16;de++)ee[de]=0;for(de=0;de<8;de++)ee[de]=U[de];for(;k>=64;){for(ae(H,ee,X,F),de=0;de<64;de++)x[S+de]=(w?w[j+de]:0)^H[de];for(K=1,de=8;de<16;de++)K=K+(ee[de]&255)|0,ee[de]=K&255,K>>>=8;k-=64,S+=64,w&&(j+=64)}if(k>0)for(ae(H,ee,X,F),de=0;de<k;de++)x[S+de]=(w?w[j+de]:0)^H[de];return 0}function re(x,S,w,j,k){return Z(x,S,null,0,w,j,k)}function ie(x,S,w,j,k){var U=new Uint8Array(32);return I(U,j,k,F),re(x,S,w,j.subarray(16),U)}function Oe(x,S,w,j,k,U,X){var ee=new Uint8Array(32);return I(ee,U,X,F),Z(x,S,w,j,k,U.subarray(16),ee)}function ke(x,S){var w,j=0;for(w=0;w<17;w++)j=j+(x[w]+S[w]|0)|0,x[w]=j&255,j>>>=8}var Se=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function z(x,S,w,j,k,U){var X,ee,H,K,de=new Uint32Array(17),Te=new Uint32Array(17),Xe=new Uint32Array(17),Dt=new Uint32Array(17),An=new Uint32Array(17);for(H=0;H<17;H++)Te[H]=Xe[H]=0;for(H=0;H<16;H++)Te[H]=U[H];for(Te[3]&=15,Te[4]&=252,Te[7]&=15,Te[8]&=252,Te[11]&=15,Te[12]&=252,Te[15]&=15;k>0;){for(H=0;H<17;H++)Dt[H]=0;for(H=0;H<16&&H<k;++H)Dt[H]=w[j+H];for(Dt[H]=1,j+=H,k-=H,ke(Xe,Dt),ee=0;ee<17;ee++)for(de[ee]=0,H=0;H<17;H++)de[ee]=de[ee]+Xe[H]*(H<=ee?Te[ee-H]:320*Te[ee+17-H]|0)|0|0;for(ee=0;ee<17;ee++)Xe[ee]=de[ee];for(K=0,H=0;H<16;H++)K=K+Xe[H]|0,Xe[H]=K&255,K>>>=8;for(K=K+Xe[16]|0,Xe[16]=K&3,K=5*(K>>>2)|0,H=0;H<16;H++)K=K+Xe[H]|0,Xe[H]=K&255,K>>>=8;K=K+Xe[16]|0,Xe[16]=K}for(H=0;H<17;H++)An[H]=Xe[H];for(ke(Xe,Se),X=-(Xe[16]>>>7)|0,H=0;H<17;H++)Xe[H]^=X&(An[H]^Xe[H]);for(H=0;H<16;H++)Dt[H]=U[H+16];for(Dt[16]=0,ke(Xe,Dt),H=0;H<16;H++)x[S+H]=Xe[H];return 0}function ne(x,S,w,j,k,U){var X=new Uint8Array(16);return z(X,0,w,j,k,U),oe(x,S,X,0)}function se(x,S,w,j,k){var U;if(w<32)return-1;for(Oe(x,0,S,0,w,j,k),z(x,16,x,32,w-32,x),U=0;U<16;U++)x[U]=0;return 0}function ge(x,S,w,j,k){var U,X=new Uint8Array(32);if(w<32||(ie(X,0,32,j,k),ne(S,16,S,32,w-32,X)!==0))return-1;for(Oe(x,0,S,0,w,j,k),U=0;U<32;U++)x[U]=0;return 0}function be(x,S){var w;for(w=0;w<16;w++)x[w]=S[w]|0}function Ce(x){var S,w;for(w=0;w<16;w++)x[w]+=65536,S=Math.floor(x[w]/65536),x[(w+1)*(w<15?1:0)]+=S-1+37*(S-1)*(w===15?1:0),x[w]-=S*65536}function Ee(x,S,w){for(var j,k=~(w-1),U=0;U<16;U++)j=k&(x[U]^S[U]),x[U]^=j,S[U]^=j}function Me(x,S){var w,j,k,U=s(),X=s();for(w=0;w<16;w++)X[w]=S[w];for(Ce(X),Ce(X),Ce(X),j=0;j<2;j++){for(U[0]=X[0]-65517,w=1;w<15;w++)U[w]=X[w]-65535-(U[w-1]>>16&1),U[w-1]&=65535;U[15]=X[15]-32767-(U[14]>>16&1),k=U[15]>>16&1,U[14]&=65535,Ee(X,U,1-k)}for(w=0;w<16;w++)x[2*w]=X[w]&255,x[2*w+1]=X[w]>>8}function lt(x,S){var w=new Uint8Array(32),j=new Uint8Array(32);return Me(w,x),Me(j,S),O(w,0,j,0)}function Vt(x){var S=new Uint8Array(32);return Me(S,x),S[0]&1}function on(x,S){var w;for(w=0;w<16;w++)x[w]=S[2*w]+(S[2*w+1]<<8);x[15]&=32767}function kt(x,S,w){var j;for(j=0;j<16;j++)x[j]=S[j]+w[j]|0}function Ct(x,S,w){var j;for(j=0;j<16;j++)x[j]=S[j]-w[j]|0}function je(x,S,w){var j,k,U=new Float64Array(31);for(j=0;j<31;j++)U[j]=0;for(j=0;j<16;j++)for(k=0;k<16;k++)U[j+k]+=S[j]*w[k];for(j=0;j<15;j++)U[j]+=38*U[j+16];for(j=0;j<16;j++)x[j]=U[j];Ce(x),Ce(x)}function Mt(x,S){je(x,S,S)}function ni(x,S){var w=s(),j;for(j=0;j<16;j++)w[j]=S[j];for(j=253;j>=0;j--)Mt(w,w),j!==2&&j!==4&&je(w,w,S);for(j=0;j<16;j++)x[j]=w[j]}function Ri(x,S){var w=s(),j;for(j=0;j<16;j++)w[j]=S[j];for(j=250;j>=0;j--)Mt(w,w),j!==1&&je(w,w,S);for(j=0;j<16;j++)x[j]=w[j]}function si(x,S,w){var j=new Uint8Array(32),k=new Float64Array(80),U,X,ee=s(),H=s(),K=s(),de=s(),Te=s(),Xe=s();for(X=0;X<31;X++)j[X]=S[X];for(j[31]=S[31]&127|64,j[0]&=248,on(k,w),X=0;X<16;X++)H[X]=k[X],de[X]=ee[X]=K[X]=0;for(ee[0]=de[0]=1,X=254;X>=0;--X)U=j[X>>>3]>>>(X&7)&1,Ee(ee,H,U),Ee(K,de,U),kt(Te,ee,K),Ct(ee,ee,K),kt(K,H,de),Ct(H,H,de),Mt(de,Te),Mt(Xe,ee),je(ee,K,ee),je(K,H,Te),kt(Te,ee,K),Ct(ee,ee,K),Mt(H,ee),Ct(K,de,Xe),je(ee,K,g),kt(ee,ee,de),je(K,K,ee),je(ee,de,Xe),je(de,H,k),Mt(H,Te),Ee(ee,H,U),Ee(K,de,U);for(X=0;X<16;X++)k[X+16]=ee[X],k[X+32]=K[X],k[X+48]=H[X],k[X+64]=de[X];var Dt=k.subarray(32),An=k.subarray(16);return ni(Dt,Dt),je(An,An,Dt),Me(x,An),0}function cn(x,S){return si(x,S,u)}function Di(x,S){return a(S,32),cn(x,S)}function ys(x,S,w){var j=new Uint8Array(32);return si(j,w,S),I(x,o,j,F)}var Wa=se,el=ge;function zr(x,S,w,j,k,U){var X=new Uint8Array(32);return ys(X,k,U),Wa(x,S,w,j,X)}function Ur(x,S,w,j,k,U){var X=new Uint8Array(32);return ys(X,k,U),el(x,S,w,j,X)}function In(){var x=0,S=0,w=0,j=0,k=65535,U,X,ee;for(ee=0;ee<arguments.length;ee++)U=arguments[ee].lo,X=arguments[ee].hi,x+=U&k,S+=U>>>16,w+=X&k,j+=X>>>16;return S+=x>>>16,w+=S>>>16,j+=w>>>16,new t(w&k|j<<16,x&k|S<<16)}function tl(x,S){return new t(x.hi>>>S,x.lo>>>S|x.hi<<32-S)}function qi(){var x=0,S=0,w;for(w=0;w<arguments.length;w++)x^=arguments[w].lo,S^=arguments[w].hi;return new t(S,x)}function et(x,S){var w,j,k=32-S;return S<32?(w=x.hi>>>S|x.lo<<k,j=x.lo>>>S|x.hi<<k):S<64&&(w=x.lo>>>S|x.hi<<k,j=x.hi>>>S|x.lo<<k),new t(w,j)}function Wo(x,S,w){var j=x.hi&S.hi^~x.hi&w.hi,k=x.lo&S.lo^~x.lo&w.lo;return new t(j,k)}function nl(x,S,w){var j=x.hi&S.hi^x.hi&w.hi^S.hi&w.hi,k=x.lo&S.lo^x.lo&w.lo^S.lo&w.lo;return new t(j,k)}function sl(x){return qi(et(x,28),et(x,34),et(x,39))}function zi(x){return qi(et(x,14),et(x,18),et(x,41))}function ec(x){return qi(et(x,1),et(x,8),tl(x,7))}function il(x){return qi(et(x,19),et(x,61),tl(x,6))}var tc=[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 rl(x,S,w){var j=[],k=[],U=[],X=[],ee,H,K;for(H=0;H<8;H++)j[H]=U[H]=G(x,8*H);for(var de=0;w>=128;){for(H=0;H<16;H++)X[H]=G(S,8*H+de);for(H=0;H<80;H++){for(K=0;K<8;K++)k[K]=U[K];for(ee=In(U[7],zi(U[4]),Wo(U[4],U[5],U[6]),tc[H],X[H%16]),k[7]=In(ee,sl(U[0]),nl(U[0],U[1],U[2])),k[3]=In(k[3],ee),K=0;K<8;K++)U[(K+1)%8]=k[K];if(H%16===15)for(K=0;K<16;K++)X[K]=In(X[K],X[(K+9)%16],ec(X[(K+1)%16]),il(X[(K+14)%16]))}for(H=0;H<8;H++)U[H]=In(U[H],j[H]),j[H]=U[H];de+=128,w-=128}for(H=0;H<8;H++)$(x,8*H,j[H]);return w}var ii=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 ot(x,S,w){var j=new Uint8Array(64),k=new Uint8Array(256),U,X=w;for(U=0;U<64;U++)j[U]=ii[U];for(rl(j,S,w),w%=128,U=0;U<256;U++)k[U]=0;for(U=0;U<w;U++)k[U]=S[X-w+U];for(k[w]=128,w=256-128*(w<112?1:0),k[w-9]=0,$(k,w-8,new t(X/536870912|0,X<<3)),rl(j,k,w),U=0;U<64;U++)x[U]=j[U];return 0}function It(x,S){var w=s(),j=s(),k=s(),U=s(),X=s(),ee=s(),H=s(),K=s(),de=s();Ct(w,x[1],x[0]),Ct(de,S[1],S[0]),je(w,w,de),kt(j,x[0],x[1]),kt(de,S[0],S[1]),je(j,j,de),je(k,x[3],S[3]),je(k,k,E),je(U,x[2],S[2]),kt(U,U,U),Ct(X,j,w),Ct(ee,U,k),kt(H,U,k),kt(K,j,w),je(x[0],X,ee),je(x[1],K,H),je(x[2],H,ee),je(x[3],X,K)}function Rt(x,S,w){var j;for(j=0;j<4;j++)Ee(x[j],S[j],w)}function Br(x,S){var w=s(),j=s(),k=s();ni(k,S[2]),je(w,S[0],k),je(j,S[1],k),Me(x,j),x[31]^=Vt(w)<<7}function Lr(x,S,w){var j,k;for(be(x[0],d),be(x[1],m),be(x[2],m),be(x[3],d),k=255;k>=0;--k)j=w[k/8|0]>>(k&7)&1,Rt(x,S,j),It(S,x),It(x,x),Rt(x,S,j)}function Ui(x,S){var w=[s(),s(),s(),s()];be(w[0],_),be(w[1],N),be(w[2],m),je(w[3],_,N),Lr(x,w,S)}function bs(x,S,w){var j=new Uint8Array(64),k=[s(),s(),s(),s()],U;for(w||a(S,32),ot(j,S,32),j[0]&=248,j[31]&=127,j[31]|=64,Ui(k,j),Br(x,k),U=0;U<32;U++)S[U+32]=x[U];return 0}var Fn=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 xs(x,S){var w,j,k,U;for(j=63;j>=32;--j){for(w=0,k=j-32,U=j-12;k<U;++k)S[k]+=w-16*S[j]*Fn[k-(j-32)],w=Math.floor((S[k]+128)/256),S[k]-=w*256;S[k]+=w,S[j]=0}for(w=0,k=0;k<32;k++)S[k]+=w-(S[31]>>4)*Fn[k],w=S[k]>>8,S[k]&=255;for(k=0;k<32;k++)S[k]-=w*Fn[k];for(j=0;j<32;j++)S[j+1]+=S[j]>>8,x[j]=S[j]&255}function En(x){var S=new Float64Array(64),w;for(w=0;w<64;w++)S[w]=x[w];for(w=0;w<64;w++)x[w]=0;xs(x,S)}function ri(x,S,w,j){var k=new Uint8Array(64),U=new Uint8Array(64),X=new Uint8Array(64),ee,H,K=new Float64Array(64),de=[s(),s(),s(),s()];ot(k,j,32),k[0]&=248,k[31]&=127,k[31]|=64;var Te=w+64;for(ee=0;ee<w;ee++)x[64+ee]=S[ee];for(ee=0;ee<32;ee++)x[32+ee]=k[32+ee];for(ot(X,x.subarray(32),w+32),En(X),Ui(de,X),Br(x,de),ee=32;ee<64;ee++)x[ee]=j[ee];for(ot(U,x,w+64),En(U),ee=0;ee<64;ee++)K[ee]=0;for(ee=0;ee<32;ee++)K[ee]=X[ee];for(ee=0;ee<32;ee++)for(H=0;H<32;H++)K[ee+H]+=U[ee]*k[H];return xs(x.subarray(32),K),Te}function ai(x,S){var w=s(),j=s(),k=s(),U=s(),X=s(),ee=s(),H=s();return be(x[2],m),on(x[1],S),Mt(k,x[1]),je(U,k,y),Ct(k,k,x[2]),kt(U,x[2],U),Mt(X,U),Mt(ee,X),je(H,ee,X),je(w,H,k),je(w,w,U),Ri(w,w),je(w,w,k),je(w,w,U),je(w,w,U),je(x[0],w,U),Mt(j,x[0]),je(j,j,U),lt(j,k)&&je(x[0],x[0],R),Mt(j,x[0]),je(j,j,U),lt(j,k)?-1:(Vt(x[0])===S[31]>>7&&Ct(x[0],d,x[0]),je(x[3],x[0],x[1]),0)}function Pr(x,S,w,j){var k,U=new Uint8Array(32),X=new Uint8Array(64),ee=[s(),s(),s(),s()],H=[s(),s(),s(),s()];if(w<64||ai(H,j))return-1;for(k=0;k<w;k++)x[k]=S[k];for(k=0;k<32;k++)x[k+32]=j[k];if(ot(X,x,w),En(X),Lr(ee,H,X),Ui(H,S.subarray(32)),It(ee,H),Br(U,ee),w-=64,O(S,0,U,0)){for(k=0;k<w;k++)x[k]=0;return-1}for(k=0;k<w;k++)x[k]=S[k+64];return w}var Bi=32,vs=24,jn=32,_s=16,ws=32,li=32,Ss=32,Jn=32,oi=32,Hr=vs,al=jn,qn=_s,Qe=64,it=32,Ft=64,ci=32,$r=64;i.lowlevel={crypto_core_hsalsa20:I,crypto_stream_xor:Oe,crypto_stream:ie,crypto_stream_salsa20_xor:Z,crypto_stream_salsa20:re,crypto_onetimeauth:z,crypto_onetimeauth_verify:ne,crypto_verify_16:oe,crypto_verify_32:O,crypto_secretbox:se,crypto_secretbox_open:ge,crypto_scalarmult:si,crypto_scalarmult_base:cn,crypto_box_beforenm:ys,crypto_box_afternm:Wa,crypto_box:zr,crypto_box_open:Ur,crypto_box_keypair:Di,crypto_hash:ot,crypto_sign:ri,crypto_sign_keypair:bs,crypto_sign_open:Pr,crypto_secretbox_KEYBYTES:Bi,crypto_secretbox_NONCEBYTES:vs,crypto_secretbox_ZEROBYTES:jn,crypto_secretbox_BOXZEROBYTES:_s,crypto_scalarmult_BYTES:ws,crypto_scalarmult_SCALARBYTES:li,crypto_box_PUBLICKEYBYTES:Ss,crypto_box_SECRETKEYBYTES:Jn,crypto_box_BEFORENMBYTES:oi,crypto_box_NONCEBYTES:Hr,crypto_box_ZEROBYTES:al,crypto_box_BOXZEROBYTES:qn,crypto_sign_BYTES:Qe,crypto_sign_PUBLICKEYBYTES:it,crypto_sign_SECRETKEYBYTES:Ft,crypto_sign_SEEDBYTES:ci,crypto_hash_BYTES:$r,gf:s,D:y,L:Fn,pack25519:Me,unpack25519:on,M:je,A:kt,S:Mt,Z:Ct,pow2523:Ri,add:It,set25519:be,modL:xs,scalarmult:Lr,scalarbase:Ui};function ll(x,S){if(x.length!==Bi)throw new Error("bad key size");if(S.length!==vs)throw new Error("bad nonce size")}function ol(x,S){if(x.length!==Ss)throw new Error("bad public key size");if(S.length!==Jn)throw new Error("bad secret key size")}function xt(){for(var x=0;x<arguments.length;x++)if(!(arguments[x]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Li(x){for(var S=0;S<x.length;S++)x[S]=0}i.randomBytes=function(x){var S=new Uint8Array(x);return a(S,x),S},i.secretbox=function(x,S,w){xt(x,S,w),ll(w,S);for(var j=new Uint8Array(jn+x.length),k=new Uint8Array(j.length),U=0;U<x.length;U++)j[U+jn]=x[U];return se(k,j,j.length,S,w),k.subarray(_s)},i.secretbox.open=function(x,S,w){xt(x,S,w),ll(w,S);for(var j=new Uint8Array(_s+x.length),k=new Uint8Array(j.length),U=0;U<x.length;U++)j[U+_s]=x[U];return j.length<32||ge(k,j,j.length,S,w)!==0?null:k.subarray(jn)},i.secretbox.keyLength=Bi,i.secretbox.nonceLength=vs,i.secretbox.overheadLength=_s,i.scalarMult=function(x,S){if(xt(x,S),x.length!==li)throw new Error("bad n size");if(S.length!==ws)throw new Error("bad p size");var w=new Uint8Array(ws);return si(w,x,S),w},i.scalarMult.base=function(x){if(xt(x),x.length!==li)throw new Error("bad n size");var S=new Uint8Array(ws);return cn(S,x),S},i.scalarMult.scalarLength=li,i.scalarMult.groupElementLength=ws,i.box=function(x,S,w,j){var k=i.box.before(w,j);return i.secretbox(x,S,k)},i.box.before=function(x,S){xt(x,S),ol(x,S);var w=new Uint8Array(oi);return ys(w,x,S),w},i.box.after=i.secretbox,i.box.open=function(x,S,w,j){var k=i.box.before(w,j);return i.secretbox.open(x,S,k)},i.box.open.after=i.secretbox.open,i.box.keyPair=function(){var x=new Uint8Array(Ss),S=new Uint8Array(Jn);return Di(x,S),{publicKey:x,secretKey:S}},i.box.keyPair.fromSecretKey=function(x){if(xt(x),x.length!==Jn)throw new Error("bad secret key size");var S=new Uint8Array(Ss);return cn(S,x),{publicKey:S,secretKey:new Uint8Array(x)}},i.box.publicKeyLength=Ss,i.box.secretKeyLength=Jn,i.box.sharedKeyLength=oi,i.box.nonceLength=Hr,i.box.overheadLength=i.secretbox.overheadLength,i.sign=function(x,S){if(xt(x,S),S.length!==Ft)throw new Error("bad secret key size");var w=new Uint8Array(Qe+x.length);return ri(w,x,x.length,S),w},i.sign.open=function(x,S){if(xt(x,S),S.length!==it)throw new Error("bad public key size");var w=new Uint8Array(x.length),j=Pr(w,x,x.length,S);if(j<0)return null;for(var k=new Uint8Array(j),U=0;U<k.length;U++)k[U]=w[U];return k},i.sign.detached=function(x,S){for(var w=i.sign(x,S),j=new Uint8Array(Qe),k=0;k<j.length;k++)j[k]=w[k];return j},i.sign.detached.verify=function(x,S,w){if(xt(x,S,w),S.length!==Qe)throw new Error("bad signature size");if(w.length!==it)throw new Error("bad public key size");var j=new Uint8Array(Qe+x.length),k=new Uint8Array(Qe+x.length),U;for(U=0;U<Qe;U++)j[U]=S[U];for(U=0;U<x.length;U++)j[U+Qe]=x[U];return Pr(k,j,j.length,w)>=0},i.sign.keyPair=function(){var x=new Uint8Array(it),S=new Uint8Array(Ft);return bs(x,S),{publicKey:x,secretKey:S}},i.sign.keyPair.fromSecretKey=function(x){if(xt(x),x.length!==Ft)throw new Error("bad secret key size");for(var S=new Uint8Array(it),w=0;w<S.length;w++)S[w]=x[32+w];return{publicKey:S,secretKey:new Uint8Array(x)}},i.sign.keyPair.fromSeed=function(x){if(xt(x),x.length!==ci)throw new Error("bad seed size");for(var S=new Uint8Array(it),w=new Uint8Array(Ft),j=0;j<32;j++)w[j]=x[j];return bs(S,w,!0),{publicKey:S,secretKey:w}},i.sign.publicKeyLength=it,i.sign.secretKeyLength=Ft,i.sign.seedLength=ci,i.sign.signatureLength=Qe,i.hash=function(x){xt(x);var S=new Uint8Array($r);return ot(S,x,x.length),S},i.hash.hashLength=$r,i.verify=function(x,S){return xt(x,S),x.length===0||S.length===0||x.length!==S.length?!1:ce(x,0,S,0,x.length)===0},i.setPRNG=function(x){a=x},(function(){var x=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(x&&x.getRandomValues){var S=65536;i.setPRNG(function(w,j){var k,U=new Uint8Array(j);for(k=0;k<j;k+=S)x.getRandomValues(U.subarray(k,k+Math.min(j-k,S)));for(k=0;k<j;k++)w[k]=U[k];Li(U)})}else typeof require<"u"&&(x=require("crypto"),x&&x.randomBytes&&i.setPRNG(function(w,j){var k,U=x.randomBytes(j);for(k=0;k<j;k++)w[k]=U[k];Li(U)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const So=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;So.sign.keyPair.fromSeed,So.sign.detached,So.sign.detached.verify,So.randomBytes;var P0;(function(i){i.InvalidPrefixByte="nkeys: invalid prefix byte",i.InvalidKey="nkeys: invalid key",i.InvalidPublicKey="nkeys: invalid public key",i.InvalidSeedLen="nkeys: invalid seed length",i.InvalidSeed="nkeys: invalid seed",i.InvalidEncoding="nkeys: invalid encoded key",i.InvalidSignature="nkeys: signature verification failed",i.CannotSign="nkeys: cannot sign, no private key available",i.PublicKeyOnly="nkeys: no seed or private key available",i.InvalidChecksum="nkeys: invalid checksum",i.SerializationError="nkeys: serialization error",i.ApiError="nkeys: api error",i.ClearedPair="nkeys: pair is cleared"})(P0||(P0={}));var H0;(function(i){i[i.Seed=144]="Seed",i[i.Private=120]="Private",i[i.Operator=112]="Operator",i[i.Server=104]="Server",i[i.Cluster=16]="Cluster",i[i.Account=0]="Account",i[i.User=160]="User"})(H0||(H0={}));function V1(i){return t=>{let s={};return i.forEach(a=>{const o=a(t)||{};s=Object.assign(s,o)}),s}}function I1(){return()=>{}}function F1(i,t){return()=>{const s=typeof i=="function"?i():i,a=typeof t=="function"?t():t;return{user:s,pass:a}}}function J1(i){return()=>({auth_token:typeof i=="function"?i():i})}const Gg=120*1e3,Q1=2,Vg=2*1e3;function K1(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:Gg,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:Vg,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function X1(i){const t=[];return typeof i.authenticator=="function"&&t.push(i.authenticator),Array.isArray(i.authenticator)&&t.push(...i.authenticator),i.token&&t.push(J1(i.token)),i.user&&t.push(F1(i.user,i.pass)),t.length===0?I1():V1(t)}function Z1(i){const t=`${Cf}:${Hg()}`;if(i=i||{servers:[t]},i.servers=i.servers||[],typeof i.servers=="string"&&(i.servers=[i.servers]),i.servers.length>0&&i.port)throw new he("port and servers options are mutually exclusive",le.InvalidOption);i.servers.length===0&&i.port&&(i.servers=[`${Cf}:${i.port}`]),i.servers&&i.servers.length===0&&(i.servers=[t]);const s=Fo(K1(),i);if(s.authenticator=X1(s),["reconnectDelayHandler","authenticator"].forEach(a=>{if(s[a]&&typeof s[a]!="function")throw new he(`${a} option should be a function`,le.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let a=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return a&&(a++,a=Math.floor(Math.random()*a)),s.reconnectTimeWait+a}),s.inboxPrefix)try{ms(s.inboxPrefix)}catch(a){throw new he(a.message,le.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Lf()=="function"),s.resolve&&typeof Lf()!="function")throw new he("'resolve' is not supported on this client",le.InvalidOption);return s}function W1(i,t){const{proto:s,tls_required:a,tls_available:o}=i;if((s===void 0||s<1)&&t.noEcho)throw new he("noEcho",le.ServerOptionNotAvailable);const u=a||o||!1;if(t.tls&&!u)throw new he("tls",le.ServerOptionNotAvailable)}const e_=1024*32,t_=/^INFO\s+([^\r\n]+)\r\n/i,n_=Pa(`PONG\r
38
- `),$0=Pa(`PING\r
39
- `);class s_{constructor(t,s,a){v(this,"echo");v(this,"no_responders");v(this,"protocol");v(this,"verbose");v(this,"pedantic");v(this,"jwt");v(this,"nkey");v(this,"sig");v(this,"user");v(this,"pass");v(this,"auth_token");v(this,"tls_required");v(this,"name");v(this,"lang");v(this,"version");v(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(a):{})||{};Fo(this,o)}}class Ig extends St{constructor(s,a,o={}){var d;super();v(this,"sid");v(this,"queue");v(this,"draining");v(this,"max");v(this,"subject");v(this,"drained");v(this,"protocol");v(this,"timer");v(this,"info");v(this,"cleanupFn");v(this,"closed");v(this,"requestSubject");Fo(this,o),this.protocol=s,this.subject=a,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=st();const u=!((d=s.options)!=null&&d.noAsyncTraces);o.timeout&&(this.timer=kr(o.timeout,u),this.timer.then(()=>{this.timer=void 0}).catch(m=>{this.stop(m),this.noIterator&&this.callback(m,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const a=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),u=s.protocolFilterFn?s.protocolFilterFn:()=>!0,d=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(m,g)=>{const{ingest:y}=o(g);y&&u(g)&&(a(m,g),d(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,a){this.cancelTimeout(),s?this.stop(s):this.push(a)}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(he.errorForCode(le.ConnectionClosed)):this.isClosed()?Promise.reject(he.errorForCode(le.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(st()).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 i_{constructor(){v(this,"mux");v(this,"subs");v(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,a=this.all();let o;if(s.operation==="subscription"&&(o=a.find(u=>u.subject===s.subject&&u.queue===s.queue)),s.operation==="publish"&&(o=a.find(u=>u.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 Ho{constructor(t,s){v(this,"connected");v(this,"connectedOnce");v(this,"infoReceived");v(this,"info");v(this,"muxSubscriptions");v(this,"options");v(this,"outbound");v(this,"pongs");v(this,"subscriptions");v(this,"transport");v(this,"noMorePublishing");v(this,"connectError");v(this,"publisher");v(this,"_closed");v(this,"closed");v(this,"listeners");v(this,"heartbeats");v(this,"parser");v(this,"outMsgs");v(this,"inMsgs");v(this,"outBytes");v(this,"inBytes");v(this,"pendingLimit");v(this,"lastError");v(this,"abortReconnect");v(this,"whyClosed");v(this,"servers");v(this,"server");v(this,"features");v(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=e_,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=t,this.publisher=s,this.subscriptions=new i_,this.muxSubscriptions=new P1,this.outbound=new Mr,this.pongs=[],this.whyClosed="",this.pendingLimit=t.pendingLimit||this.pendingLimit,this.features=new v1({major:0,minor:0,micro:0}),this.connectPromise=null;const a=typeof t.servers=="string"?[t.servers]:t.servers;this.servers=new L1(a,{randomize:!t.noRandomize}),this.closed=st(),this.parser=new L0(this),this.heartbeats=new H1(this,this.options.pingInterval||Gg,this.options.maxPingOut||Q1)}resetOutbound(){this.outbound.reset();const t=this.pongs;this.pongs=[];const s=he.errorForCode(le.Disconnect);s.stack="",t.forEach(a=>{a.reject(s)}),this.parser=new L0(this),this.infoReceived=!1}dispatchStatus(t){this.listeners.forEach(s=>{s.push(t)})}status(){const t=new St;return this.listeners.push(t),t}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const t=st();return t.catch(()=>{}),this.pongs.unshift(t),this.connectError=s=>{t.reject(s)},this.transport=S1(),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:Er.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Er.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(t){this.dispatchStatus({type:ds.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:ds.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===le.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(t)}async dial(t){const s=this.prepare();let a;try{a=kr(this.options.timeout||2e4);const o=this.transport.connect(t,this.options);await Promise.race([o,a]),(async()=>{try{for await(const u of this.transport)this.parser.parse(u)}catch(u){console.log("reader closed",u)}})().then()}catch(o){s.reject(o)}try{await Promise.race([a,s]),a&&a.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 a&&a.cancel(),await this.transport.close(o),o}}async _doDial(t){const{resolve:s}=this.options,a=await t.resolve({fn:Lf(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const u of a)try{o=null,this.dispatchStatus({type:Er.Reconnecting,data:u.toString()}),await this.dial(u);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():Vg;let a=s;const o=this.selectServer();if(!o||this.abortReconnect)throw t||(this.lastError?this.lastError:he.errorForCode(le.ConnectionRefused));const u=Date.now();if(o.lastConnect===0||o.lastConnect+s<=u){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 m=this.options.maxReconnectAttempts||0;m!==-1&&o.reconnects>=m&&this.servers.removeCurrentServer()}}else a=Math.min(a,o.lastConnect+s-u),await Rr(a)}}static async connect(t,s){const a=new Ho(t,s);return await a.dialLoop(),a}static toError(t){const s=t?t.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const a=new he(t,le.PermissionsViolation),o=t.match(/(Publish|Subscription) to "(\S+)"/);if(o){a.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const u=t.match(/using queue "(\S+)"/);u&&(a.permissionContext.queue=u[1])}return a}else return s.indexOf("authorization violation")!==-1?new he(t,le.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new he(t,le.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new he(t,le.AccountExpired):s.indexOf("authentication timeout")!==-1?new he(t,le.AuthenticationTimeout):new he(t,le.ProtocolError)}processMsg(t,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const a=this.subscriptions.get(t.sid);a&&(a.received+=1,a.callback&&a.callback(null,new oh(t,s,this)),a.max!==void 0&&a.received>=a.max&&a.unsubscribe())}processError(t){const s=E0(t),a=Ho.toError(s),o={type:ds.Error,data:a.code};if(a.isPermissionError()){let u=!1;if(a.permissionContext){o.permissionContext=a.permissionContext;const d=this.subscriptions.getMux();u=(d==null?void 0:d.subject)===a.permissionContext.subject}this.subscriptions.handleError(a),this.muxSubscriptions.handleError(u,a),u&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(a)}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(n_)}processPong(){const t=this.pongs.shift();t&&t.resolve()}processInfo(t){const s=JSON.parse(E0(t));this.info=s;const a=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(Ti(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:u,lang:d}=this.transport;try{const m=new s_({version:u,lang:d},this.options,s.nonce);s.headers&&(m.headers=!0,m.no_responders=!0);const g=JSON.stringify(m);this.transport.send(Pa(`CONNECT ${g}${To}`)),this.transport.send($0)}catch(m){this._close(m)}}a&&this.dispatchStatus({type:ds.Update,data:a}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:ds.LDM,data:this.servers.getCurrentServer().toString()})}push(t){switch(t.kind){case Ut.MSG:{const{msg:s,data:a}=t;this.processMsg(s,a);break}case Ut.OK:break;case Ut.ERR:this.processError(t.data);break;case Ut.PING:this.processPing();break;case Ut.PONG:this.processPong();break;case Ut.INFO:this.processInfo(t.data);break}}sendCommand(t,...s){const a=this.outbound.length();let o;typeof t=="string"?o=Pa(t):o=t,this.outbound.fill(o,...s),a===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(t,s=an,a){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=Ci.encode(s);else throw he.errorForCode(le.BadPayload);let u=o.length;a=a||{},a.reply=a.reply||"";let d=an,m=0;if(a.headers){if(this.info&&!this.info.headers)throw new he("headers",le.ServerOptionNotAvailable);d=a.headers.encode(),m=d.length,u=o.length+m}if(this.info&&u>this.info.max_payload)throw he.errorForCode(le.MaxPayloadExceeded);this.outBytes+=u,this.outMsgs++;let g;a.headers?(a.reply?g=`HPUB ${t} ${a.reply} ${m} ${u}\r
36
+ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(a),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||de.errorForCode(le.Cancelled))}}const _1="$JS.API";function w1(i){return i=i||{},i.domain&&(i.apiPrefix=`$JS.${i.domain}.API`,delete i.domain),Jo({apiPrefix:_1,timeout:5e3},i)}class Qa{constructor(t,s){v(this,"nc");v(this,"opts");v(this,"prefix");v(this,"timeout");v(this,"jc");this.nc=t,this.opts=w1(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=Dn()}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,a){a=a||{},a.timeout=this.timeout;let o=an;s&&(o=this.jc.encode(s));let{retries:u}=a;u=u||1,u=u===-1?Number.MAX_SAFE_INTEGER:u;const d=ah();for(let m=0;m<u;m++)try{const g=await this.nc.request(t,o,a);return this.parseJsResponse(g)}catch(g){const y=g;if((y.code==="503"||y.code===le.Timeout)&&m+1<u)await Rr(d.backoff(m));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),a=s;if(a.error){const o=$g(a.error.code,a.error.description);if(o!==null)throw o.api_error=a.error,o}return s}}class Ua{constructor(t,s,a,o){v(this,"err");v(this,"offset");v(this,"pageInfo");v(this,"subject");v(this,"jsm");v(this,"filter");v(this,"payload");if(!t)throw new Error("subject is required");this.subject=t,this.jsm=a,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 a=this.countResponse(s);return a===0?[]:(this.offset+=a,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(t){var s,a,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((a=t.consumers)==null?void 0:a.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 Ci(i=""){const t=i.match(/(\d+).(\d+).(\d+)/);if(t)return{major:parseInt(t[1]),minor:parseInt(t[2]),micro:parseInt(t[3])};throw new Error(`'${i}' is not a semver value`)}function Lf(i,t){return i.major<t.major?-1:i.major>t.major?1:i.minor<t.minor?-1:i.minor>t.minor?1:i.micro<t.micro?-1:i.micro>t.micro?1:0}var Le;(function(i){i.JS_KV="js_kv",i.JS_OBJECTSTORE="js_objectstore",i.JS_PULL_MAX_BYTES="js_pull_max_bytes",i.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",i.JS_ALLOW_DIRECT="js_allow_direct",i.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",i.JS_SIMPLIFICATION="js_simplification",i.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",i.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",i.JS_STREAM_FIRST_SEQ="js_stream_first_seq",i.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",i.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",i.JS_STREAM_COMPRESSION="js_stream_compression",i.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",i.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Le||(Le={}));class S1{constructor(t){v(this,"server");v(this,"features");v(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=Ci(t)),this.server=t,this.set(Le.JS_KV,"2.6.2"),this.set(Le.JS_OBJECTSTORE,"2.6.3"),this.set(Le.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Le.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Le.JS_ALLOW_DIRECT,"2.9.0"),this.set(Le.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Le.JS_SIMPLIFICATION,"2.9.4"),this.set(Le.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Le.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Le.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Le.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Le.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Le.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Le.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Le.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:Lf(this.server,Ci(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=Ci(t)),Lf(this.server,t)>=0}}class Lo extends Qa{constructor(t,s){super(t,s)}async add(t,s,a=Bo.Create){if(zt(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=a,o.config.durable_name&&jr(o.config.durable_name);const u=this.nc;let{min:d,ok:m}=u.features.get(Le.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!m)throw new Error(`consumer 'name' requires server ${d}`);if(g)try{Qo("name",g)}catch(T){const R=T.message,C=R.indexOf("cannot contain");throw C!==-1?new Error(`consumer 'name' ${R.substring(C)}`):T}let y,E="";if(Array.isArray(s.filter_subjects)){const{min:T,ok:R}=u.features.get(Le.JS_MULTIPLE_CONSUMER_FILTER);if(!R)throw new Error(`consumer 'filter_subjects' requires server ${T}`);m=!1}if(s.metadata){const{min:T,ok:R}=u.features.get(Le.JS_STREAM_CONSUMER_METADATA);if(!R)throw new Error(`consumer 'metadata' requires server ${T}`)}if(m&&(E=s.name??s.durable_name??""),E!==""){let T=s.filter_subject??void 0;T===">"&&(T=void 0),y=T!==void 0?`${this.prefix}.CONSUMER.CREATE.${t}.${E}.${T}`:`${this.prefix}.CONSUMER.CREATE.${t}.${E}`}else y=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${t}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${t}`;return await this._request(y,o)}async update(t,s,a){const o=await this.info(t,s),u=a;return this.add(t,Object.assign(o.config,u),Bo.Update)}async info(t,s){return zt(t),jr(s),await this._request(`${this.prefix}.CONSUMER.INFO.${t}.${s}`)}async delete(t,s){return zt(t),jr(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${t}.${s}`)).success}list(t){zt(t);const s=o=>o.consumers,a=`${this.prefix}.CONSUMER.LIST.${t}`;return new Ua(a,s,this)}pause(t,s,a){const o=`${this.prefix}.CONSUMER.PAUSE.${t}.${s}`,u={pause_until:a.toISOString()};return this._request(o,u)}resume(t,s){return this.pause(t,s,new Date(0))}}function xr(i,t,s=!1){if(s===!0&&!i)throw de.errorForCode(le.ApiError,new Error(`${t} is not a function`));if(i&&typeof i!="function")throw de.errorForCode(le.ApiError,new Error(`${t} is not a function`))}class E1 extends St{constructor(s,a,o){super();v(this,"sub");v(this,"adapter");v(this,"subIterDone");xr(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&xr(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&(xr(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&(xr(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&(xr(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&xr(o.cleanupFn,"cleanupFn");let u=(E,_)=>{this.callback(E,_)};if(o.callback){const E=o.callback;u=(_,T)=>{const[R,C]=this.adapter(_,T);if(R){E(R,null);return}const{ingest:D}=this.ingestionFilterFn?this.ingestionFilterFn(C,this):{ingest:!0};D&&(!this.protocolFilterFn||this.protocolFilterFn(C))&&(E(R,C),this.dispatchedFn&&C&&this.dispatchedFn(C))}}const{max:d,queue:m,timeout:g}=o,y={queue:m,timeout:g,callback:u};d&&d>0&&(y.max=d),this.sub=s.subscribe(a,y),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=st(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async E=>{await E.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,a){this.sub.cancelTimeout();const[o,u]=this.adapter(s,a);o&&this.stop(o),u&&this.push(u)}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 rn;function j1(i){rn=i}function Vg(){return rn!==void 0&&rn.defaultPort!==void 0?rn.defaultPort:4222}function yf(){return rn!==void 0&&rn.urlParseFn?rn.urlParseFn:void 0}function A1(){if(!rn||typeof rn.factory!="function")throw new Error("transport fn is not set");return rn.factory()}function Pf(){return rn!==void 0&&rn.dnsResolveFn?rn.dnsResolveFn:void 0}const To=`\r
37
+ `,Po=Mr.fromAscii(To),O1=new Uint8Array(Po)[0],N1=new Uint8Array(Po)[1];function T1(i){for(let t=0;t<i.length;t++){const s=t+1;if(i.byteLength>s&&i[t]===O1&&i[s]===N1)return s+1}return 0}function k1(i){const t=T1(i);if(t>0){const a=new Uint8Array(i).slice(0,t);return sn.decode(a)}return""}const C1=4,Ig=48,M1=65,R1=97;function D1(i,t,s,a){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((d,m)=>{o[m]=d}),o[12]=i,o[13]=t,o[14]=s,o[15]=a,o}function Hf(i){return q1(i)!==void 0}function q1(i){for(let t=0;t<i.length;t++)switch(i[t]){case".":return Fg(i);case":":return z1(i)}}function Fg(i){const t=new Uint8Array(4);for(let s=0;s<4;s++){if(i.length===0)return;if(s>0){if(i[0]!==".")return;i=i.substring(1)}const{n:a,c:o,ok:u}=U1(i);if(!u||a>255)return;i=i.substring(o),t[s]=a}return D1(t[0],t[1],t[2],t[3])}function z1(i){const t=new Uint8Array(16);let s=-1;if(i.length>=2&&i[0]===":"&&i[1]===":"&&(s=0,i=i.substring(2),i.length===0))return t;let a=0;for(;a<16;){const{n:o,c:u,ok:d}=B1(i);if(!d||o>65535)return;if(u<i.length&&i[u]==="."){if(s<0&&a!=12||a+4>16)return;const m=Fg(i);if(m===void 0)return;t[a]=m[12],t[a+1]=m[13],t[a+2]=m[14],t[a+3]=m[15],i="",a+=C1;break}if(t[a]=o>>8,t[a+1]=o,a+=2,i=i.substring(u),i.length===0)break;if(i[0]!==":"||i.length==1)return;if(i=i.substring(1),i[0]===":"){if(s>=0)return;if(s=a,i=i.substring(1),i.length===0)break}}if(i.length===0){if(a<16){if(s<0)return;const o=16-a;for(let u=a-1;u>=s;u--)t[u+o]=t[u];for(let u=s+o-1;u>=s;u--)t[u]=0}else if(s>=0)return;return t}}function U1(i){let t=0,s=0;for(t=0;t<i.length&&48<=i.charCodeAt(t)&&i.charCodeAt(t)<=57;t++)if(s=s*10+(i.charCodeAt(t)-Ig),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 B1(i){let t=0,s=0;for(s=0;s<i.length;s++){if(48<=i.charCodeAt(s)&&i.charCodeAt(s)<=57)t*=16,t+=i.charCodeAt(s)-Ig;else if(97<=i.charCodeAt(s)&&i.charCodeAt(s)<=102)t*=16,t+=i.charCodeAt(s)-R1+10;else if(65<=i.charCodeAt(s)&&i.charCodeAt(s)<=70)t*=16,t+=i.charCodeAt(s)-M1+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 L1(i){return i.indexOf("[")!==-1||i.indexOf("::")!==-1?!1:i.indexOf(".")!==-1||i.split(":").length<=2}function $f(i){return!L1(i)}function P1(i){const t="::FFFF:",s=i.toUpperCase().indexOf(t);if(s!==-1&&i.indexOf(".")!==-1){let a=i.substring(s+t.length);return a=a.replace("[",""),a.replace("]","")}return i}function H1(i){i=i.trim(),i.match(/^(.*:\/\/)(.*)/m)&&(i=i.replace(/^(.*:\/\/)(.*)/gm,"$2")),i=P1(i),$f(i)&&i.indexOf("[")===-1&&(i=`[${i}]`);const t=$f(i)?i.match(/(]:)(\d+)/):i.match(/(:)(\d+)/),s=t&&t.length===3&&t[1]&&t[2]?parseInt(t[2]):4222,a=s===80?"https":"http",o=new URL(`${a}://${i}`);o.port=`${s}`;let u=o.hostname;return u.charAt(0)==="["&&(u=u.substring(1,u.length-1)),{listen:o.host,hostname:u,port:s}}class Ha{constructor(t,s=!1){v(this,"src");v(this,"listen");v(this,"hostname");v(this,"port");v(this,"didConnect");v(this,"reconnects");v(this,"lastConnect");v(this,"gossiped");v(this,"tlsName");v(this,"resolves");this.src=t,this.tlsName="";const a=H1(t);this.listen=a.listen,this.hostname=a.hostname,this.port=a.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(Hf(this.hostname))return[this];{const a=await t.fn(this.hostname);t.debug&&console.log(`resolve ${this.hostname} = ${a.join(",")}`);for(const o of a){const u=this.port===80?"https":"http",d=new URL(`${u}://${$f(o)?"["+o+"]":o}`);d.port=`${this.port}`;const m=new Ha(d.host,!1);m.tlsName=this.hostname,s.push(m)}}return t.randomize&&Pg(s),this.resolves=s,s}}class $1{constructor(t=[],s={}){v(this,"firstSelect");v(this,"servers");v(this,"currentServer");v(this,"tlsName");v(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const a=yf();t&&(t.forEach(o=>{o=a?a(o):o,this.servers.push(new Ha(o))}),this.randomize&&(this.servers=Pg(this.servers))),this.servers.length===0&&this.addServer(`${Mf}:${Vg()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const t=this.getCurrentServer();Hf(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 a=yf();t=a?a(t):t;const o=new Ha(t,s);Hf(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 a=[];let o=[];const u=yf(),d=new Map;t.connect_urls&&t.connect_urls.length>0&&t.connect_urls.forEach(g=>{g=u?u(g,s):g;const y=new Ha(g,!0);d.set(g,y)});const m=[];return this.servers.forEach((g,y)=>{const E=g.listen;g.gossiped&&this.currentServer.listen!==E&&d.get(E)===void 0&&m.push(y),d.delete(E)}),m.reverse(),m.forEach(g=>{const y=this.servers.splice(g,1);o=o.concat(y[0].listen)}),d.forEach((g,y)=>{this.servers.push(g),a.push(y)}),{added:a,deleted:o}}}class Y1{constructor(){v(this,"baseInbox");v(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(t){return this.baseInbox=`${ms(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 a=s.permissionContext;if(a.operation==="publish"){const o=this.all().find(u=>u.requestSubject===a.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(t,s)=>{const a=this.getToken(s);if(a){const o=this.get(a);o&&(t===null&&s.headers&&(t=Hg(s)),o.resolver(t,s))}}}close(){const t=de.errorForCode(le.Timeout);this.reqs.forEach(s=>{s.resolver(t,{})})}}class G1{constructor(t,s,a){v(this,"ph");v(this,"interval");v(this,"maxOut");v(this,"timer");v(this,"pendings");this.ph=t,this.interval=s,this.maxOut=a,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:Er.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const t=st();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 V1 extends Error{constructor(t){super(t),this.name="AssertionError"}}function I1(i,t="Assertion failed."){if(!i)throw new V1(t)}const L0=32*1024,bf=2**32-2;function _o(i,t,s=0){const a=t.byteLength-s;return i.byteLength>a&&(i=i.subarray(0,a)),t.set(i,s),i.byteLength}class xf{constructor(t){v(this,"_buf");v(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){I1(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=_o(this._buf.subarray(this._off),t);return this._off+=s,s}writeByte(t){return this.write(Uint8Array.of(t))}writeString(t){return this.write(Mi.encode(t))}write(t){const s=this._grow(t.byteLength);return _o(t,this._buf,s)}_grow(t){const s=this.length;s===0&&this._off!==0&&this.reset();const a=this._tryGrowByReslice(t);if(a>=0)return a;const o=this.capacity;if(t<=Math.floor(o/2)-s)_o(this._buf.subarray(this._off),this._buf);else{if(o+t>bf)throw new Error("The buffer cannot be grown beyond the maximum size.");{const u=new Uint8Array(Math.min(2*o+t,bf));_o(this._buf.subarray(this._off),u),this._buf=u}}return this._off=0,this._reslice(Math.min(s+t,bf)),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 a=new Uint8Array(L0);for(;;){const o=this.capacity-this.length<L0,u=o?a:new Uint8Array(this._buf.buffer,this.length),d=t.read(u);if(d===null)return s;o?this.write(u.subarray(0,d)):this._reslice(this.length+d),s+=d}}}var Ut;(function(i){i[i.OK=0]="OK",i[i.ERR=1]="ERR",i[i.MSG=2]="MSG",i[i.INFO=3]="INFO",i[i.PING=4]="PING",i[i.PONG=5]="PONG"})(Ut||(Ut={}));function P0(){const i={};return i.sid=-1,i.hdr=-1,i.size=-1,i}const F1=48;class H0{constructor(t){v(this,"dispatcher");v(this,"state");v(this,"as");v(this,"drop");v(this,"hdr");v(this,"ma");v(this,"argBuf");v(this,"msgBuf");this.dispatcher=t,this.state=ce.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(t){let s;for(s=0;s<t.length;s++){const a=t[s];switch(this.state){case ce.OP_START:switch(a){case ue.M:case ue.m:this.state=ce.OP_M,this.hdr=-1,this.ma=P0();break;case ue.H:case ue.h:this.state=ce.OP_H,this.hdr=0,this.ma=P0();break;case ue.P:case ue.p:this.state=ce.OP_P;break;case ue.PLUS:this.state=ce.OP_PLUS;break;case ue.MINUS:this.state=ce.OP_MINUS;break;case ue.I:case ue.i:this.state=ce.OP_I;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_H:switch(a){case ue.M:case ue.m:this.state=ce.OP_M;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_M:switch(a){case ue.S:case ue.s:this.state=ce.OP_MS;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MS:switch(a){case ue.G:case ue.g:this.state=ce.OP_MSG;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MSG:switch(a){case ue.SPACE:case ue.TAB:this.state=ce.OP_MSG_SPC;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MSG_SPC:switch(a){case ue.SPACE:case ue.TAB:continue;default:this.state=ce.MSG_ARG,this.as=s}break;case ce.MSG_ARG:switch(a){case ue.CR:this.drop=1;break;case ue.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=ce.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;case ce.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Ut.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=ce.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const u=t.length-s;u<o&&(o=u),o>0?(this.msgBuf.write(t.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(a)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Ut.MSG,msg:this.ma,data:t.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=ce.MSG_END);break;case ce.MSG_END:switch(a){case ue.NL:this.drop=0,this.as=s+1,this.state=ce.OP_START;break;default:continue}break;case ce.OP_PLUS:switch(a){case ue.O:case ue.o:this.state=ce.OP_PLUS_O;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PLUS_O:switch(a){case ue.K:case ue.k:this.state=ce.OP_PLUS_OK;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PLUS_OK:switch(a){case ue.NL:this.dispatcher.push({kind:Ut.OK}),this.drop=0,this.state=ce.OP_START;break}break;case ce.OP_MINUS:switch(a){case ue.E:case ue.e:this.state=ce.OP_MINUS_E;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MINUS_E:switch(a){case ue.R:case ue.r:this.state=ce.OP_MINUS_ER;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MINUS_ER:switch(a){case ue.R:case ue.r:this.state=ce.OP_MINUS_ERR;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MINUS_ERR:switch(a){case ue.SPACE:case ue.TAB:this.state=ce.OP_MINUS_ERR_SPC;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_MINUS_ERR_SPC:switch(a){case ue.SPACE:case ue.TAB:continue;default:this.state=ce.MINUS_ERR_ARG,this.as=s}break;case ce.MINUS_ERR_ARG:switch(a){case ue.CR:this.drop=1;break;case ue.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:Ut.ERR,data:o}),this.drop=0,this.as=s+1,this.state=ce.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(a))}break;case ce.OP_P:switch(a){case ue.I:case ue.i:this.state=ce.OP_PI;break;case ue.O:case ue.o:this.state=ce.OP_PO;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PO:switch(a){case ue.N:case ue.n:this.state=ce.OP_PON;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PON:switch(a){case ue.G:case ue.g:this.state=ce.OP_PONG;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PONG:switch(a){case ue.NL:this.dispatcher.push({kind:Ut.PONG}),this.drop=0,this.state=ce.OP_START;break}break;case ce.OP_PI:switch(a){case ue.N:case ue.n:this.state=ce.OP_PIN;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PIN:switch(a){case ue.G:case ue.g:this.state=ce.OP_PING;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_PING:switch(a){case ue.NL:this.dispatcher.push({kind:Ut.PING}),this.drop=0,this.state=ce.OP_START;break}break;case ce.OP_I:switch(a){case ue.N:case ue.n:this.state=ce.OP_IN;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_IN:switch(a){case ue.F:case ue.f:this.state=ce.OP_INF;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_INF:switch(a){case ue.O:case ue.o:this.state=ce.OP_INFO;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_INFO:switch(a){case ue.SPACE:case ue.TAB:this.state=ce.OP_INFO_SPC;break;default:throw this.fail(t.subarray(s))}break;case ce.OP_INFO_SPC:switch(a){case ue.SPACE:case ue.TAB:continue;default:this.state=ce.INFO_ARG,this.as=s}break;case ce.INFO_ARG:switch(a){case ue.CR:this.drop=1;break;case ue.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:Ut.INFO,data:o}),this.drop=0,this.as=s+1,this.state=ce.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(a)}break;default:throw this.fail(t.subarray(s))}}(this.state===ce.MSG_ARG||this.state===ce.MINUS_ERR_ARG||this.state===ce.INFO_ARG)&&!this.argBuf&&(this.argBuf=new xf(t.subarray(this.as,s-this.drop))),this.state===ce.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new xf(t.subarray(this.as)))}cloneMsgArg(){const t=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,a=new Uint8Array(t+s);a.set(this.ma.subject),this.ma.reply&&a.set(this.ma.reply,t),this.argBuf=new xf(a),this.ma.subject=a.subarray(0,t),this.ma.reply&&(this.ma.reply=a.subarray(t))}processMsgArgs(t){if(this.hdr>=0)return this.processHeaderMsgArgs(t);const s=[];let a=-1;for(let o=0;o<t.length;o++)switch(t[o]){case ue.SPACE:case ue.TAB:case ue.CR:case ue.NL:a>=0&&(s.push(t.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(t.subarray(a)),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}: ${sn.decode(t)}`)}processHeaderMsgArgs(t){const s=[];let a=-1;for(let o=0;o<t.length;o++)switch(t[o]){case ue.SPACE:case ue.TAB:case ue.CR:case ue.NL:a>=0&&(s.push(t.subarray(a,o)),a=-1);break;default:a<0&&(a=o)}switch(a>=0&&s.push(t.subarray(a)),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 a=0;a<t.length;a++){if(t[a]<48||t[a]>57)return-1;s=s*10+(t[a]-F1)}return s}}var ce;(function(i){i[i.OP_START=0]="OP_START",i[i.OP_PLUS=1]="OP_PLUS",i[i.OP_PLUS_O=2]="OP_PLUS_O",i[i.OP_PLUS_OK=3]="OP_PLUS_OK",i[i.OP_MINUS=4]="OP_MINUS",i[i.OP_MINUS_E=5]="OP_MINUS_E",i[i.OP_MINUS_ER=6]="OP_MINUS_ER",i[i.OP_MINUS_ERR=7]="OP_MINUS_ERR",i[i.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",i[i.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",i[i.OP_M=10]="OP_M",i[i.OP_MS=11]="OP_MS",i[i.OP_MSG=12]="OP_MSG",i[i.OP_MSG_SPC=13]="OP_MSG_SPC",i[i.MSG_ARG=14]="MSG_ARG",i[i.MSG_PAYLOAD=15]="MSG_PAYLOAD",i[i.MSG_END=16]="MSG_END",i[i.OP_H=17]="OP_H",i[i.OP_P=18]="OP_P",i[i.OP_PI=19]="OP_PI",i[i.OP_PIN=20]="OP_PIN",i[i.OP_PING=21]="OP_PING",i[i.OP_PO=22]="OP_PO",i[i.OP_PON=23]="OP_PON",i[i.OP_PONG=24]="OP_PONG",i[i.OP_I=25]="OP_I",i[i.OP_IN=26]="OP_IN",i[i.OP_INF=27]="OP_INF",i[i.OP_INFO=28]="OP_INFO",i[i.OP_INFO_SPC=29]="OP_INFO_SPC",i[i.INFO_ARG=30]="INFO_ARG"})(ce||(ce={}));var ue;(function(i){i[i.CR=13]="CR",i[i.E=69]="E",i[i.e=101]="e",i[i.F=70]="F",i[i.f=102]="f",i[i.G=71]="G",i[i.g=103]="g",i[i.H=72]="H",i[i.h=104]="h",i[i.I=73]="I",i[i.i=105]="i",i[i.K=75]="K",i[i.k=107]="k",i[i.M=77]="M",i[i.m=109]="m",i[i.MINUS=45]="MINUS",i[i.N=78]="N",i[i.n=110]="n",i[i.NL=10]="NL",i[i.O=79]="O",i[i.o=111]="o",i[i.P=80]="P",i[i.p=112]="p",i[i.PLUS=43]="PLUS",i[i.R=82]="R",i[i.r=114]="r",i[i.S=83]="S",i[i.s=115]="s",i[i.SPACE=32]="SPACE",i[i.TAB=9]="TAB"})(ue||(ue={}));(function(i){var t=function(x,S){this.hi=x|0,this.lo=S|0},s=function(x){var S,w=new Float64Array(16);if(x)for(S=0;S<x.length;S++)w[S]=x[S];return w},a=function(){throw new Error("no PRNG")},o=new Uint8Array(16),u=new Uint8Array(32);u[0]=9;var d=s(),m=s([1]),g=s([56129,1]),y=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),E=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),_=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),T=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),R=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function C(x,S){return x<<S|x>>>32-S}function D(x,S){var w=x[S+3]&255;return w=w<<8|x[S+2]&255,w=w<<8|x[S+1]&255,w<<8|x[S+0]&255}function F(x,S){var w=x[S]<<24|x[S+1]<<16|x[S+2]<<8|x[S+3],A=x[S+4]<<24|x[S+5]<<16|x[S+6]<<8|x[S+7];return new t(w,A)}function te(x,S,w){var A;for(A=0;A<4;A++)x[S+A]=w&255,w>>>=8}function X(x,S,w){x[S]=w.hi>>24&255,x[S+1]=w.hi>>16&255,x[S+2]=w.hi>>8&255,x[S+3]=w.hi&255,x[S+4]=w.lo>>24&255,x[S+5]=w.lo>>16&255,x[S+6]=w.lo>>8&255,x[S+7]=w.lo&255}function fe(x,S,w,A,k){var z,K=0;for(z=0;z<k;z++)K|=x[S+z]^w[A+z];return(1&K-1>>>8)-1}function oe(x,S,w,A){return fe(x,S,w,A,16)}function O(x,S,w,A){return fe(x,S,w,A,32)}function U(x,S,w,A,k){var z=new Uint32Array(16),K=new Uint32Array(16),ee=new Uint32Array(16),H=new Uint32Array(4),Q,me,ke;for(Q=0;Q<4;Q++)K[5*Q]=D(A,4*Q),K[1+Q]=D(w,4*Q),K[6+Q]=D(S,4*Q),K[11+Q]=D(w,16+4*Q);for(Q=0;Q<16;Q++)ee[Q]=K[Q];for(Q=0;Q<20;Q++){for(me=0;me<4;me++){for(ke=0;ke<4;ke++)H[ke]=K[(5*me+4*ke)%16];for(H[1]^=C(H[0]+H[3]|0,7),H[2]^=C(H[1]+H[0]|0,9),H[3]^=C(H[2]+H[1]|0,13),H[0]^=C(H[3]+H[2]|0,18),ke=0;ke<4;ke++)z[4*me+(me+ke)%4]=H[ke]}for(ke=0;ke<16;ke++)K[ke]=z[ke]}if(k){for(Q=0;Q<16;Q++)K[Q]=K[Q]+ee[Q]|0;for(Q=0;Q<4;Q++)K[5*Q]=K[5*Q]-D(A,4*Q)|0,K[6+Q]=K[6+Q]-D(S,4*Q)|0;for(Q=0;Q<4;Q++)te(x,4*Q,K[5*Q]),te(x,16+4*Q,K[6+Q])}else for(Q=0;Q<16;Q++)te(x,4*Q,K[Q]+ee[Q]|0)}function ne(x,S,w,A){return U(x,S,w,A,!1),0}function G(x,S,w,A){return U(x,S,w,A,!0),0}var I=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Z(x,S,w,A,k,z,K){var ee=new Uint8Array(16),H=new Uint8Array(64),Q,me;if(!k)return 0;for(me=0;me<16;me++)ee[me]=0;for(me=0;me<8;me++)ee[me]=z[me];for(;k>=64;){for(ne(H,ee,K,I),me=0;me<64;me++)x[S+me]=(w?w[A+me]:0)^H[me];for(Q=1,me=8;me<16;me++)Q=Q+(ee[me]&255)|0,ee[me]=Q&255,Q>>>=8;k-=64,S+=64,w&&(A+=64)}if(k>0)for(ne(H,ee,K,I),me=0;me<k;me++)x[S+me]=(w?w[A+me]:0)^H[me];return 0}function ae(x,S,w,A,k){return Z(x,S,null,0,w,A,k)}function re(x,S,w,A,k){var z=new Uint8Array(32);return G(z,A,k,I),ae(x,S,w,A.subarray(16),z)}function je(x,S,w,A,k,z,K){var ee=new Uint8Array(32);return G(ee,z,K,I),Z(x,S,w,A,k,z.subarray(16),ee)}function he(x,S){var w,A=0;for(w=0;w<17;w++)A=A+(x[w]+S[w]|0)|0,x[w]=A&255,A>>>=8}var Se=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function $(x,S,w,A,k,z){var K,ee,H,Q,me=new Uint32Array(17),ke=new Uint32Array(17),Xe=new Uint32Array(17),Dt=new Uint32Array(17),On=new Uint32Array(17);for(H=0;H<17;H++)ke[H]=Xe[H]=0;for(H=0;H<16;H++)ke[H]=z[H];for(ke[3]&=15,ke[4]&=252,ke[7]&=15,ke[8]&=252,ke[11]&=15,ke[12]&=252,ke[15]&=15;k>0;){for(H=0;H<17;H++)Dt[H]=0;for(H=0;H<16&&H<k;++H)Dt[H]=w[A+H];for(Dt[H]=1,A+=H,k-=H,he(Xe,Dt),ee=0;ee<17;ee++)for(me[ee]=0,H=0;H<17;H++)me[ee]=me[ee]+Xe[H]*(H<=ee?ke[ee-H]:320*ke[ee+17-H]|0)|0|0;for(ee=0;ee<17;ee++)Xe[ee]=me[ee];for(Q=0,H=0;H<16;H++)Q=Q+Xe[H]|0,Xe[H]=Q&255,Q>>>=8;for(Q=Q+Xe[16]|0,Xe[16]=Q&3,Q=5*(Q>>>2)|0,H=0;H<16;H++)Q=Q+Xe[H]|0,Xe[H]=Q&255,Q>>>=8;Q=Q+Xe[16]|0,Xe[16]=Q}for(H=0;H<17;H++)On[H]=Xe[H];for(he(Xe,Se),K=-(Xe[16]>>>7)|0,H=0;H<17;H++)Xe[H]^=K&(On[H]^Xe[H]);for(H=0;H<16;H++)Dt[H]=z[H+16];for(Dt[16]=0,he(Xe,Dt),H=0;H<16;H++)x[S+H]=Xe[H];return 0}function se(x,S,w,A,k,z){var K=new Uint8Array(16);return $(K,0,w,A,k,z),oe(x,S,K,0)}function ie(x,S,w,A,k){var z;if(w<32)return-1;for(je(x,0,S,0,w,A,k),$(x,16,x,32,w-32,x),z=0;z<16;z++)x[z]=0;return 0}function be(x,S,w,A,k){var z,K=new Uint8Array(32);if(w<32||(re(K,0,32,A,k),se(S,16,S,32,w-32,K)!==0))return-1;for(je(x,0,S,0,w,A,k),z=0;z<32;z++)x[z]=0;return 0}function ve(x,S){var w;for(w=0;w<16;w++)x[w]=S[w]|0}function Ce(x){var S,w;for(w=0;w<16;w++)x[w]+=65536,S=Math.floor(x[w]/65536),x[(w+1)*(w<15?1:0)]+=S-1+37*(S-1)*(w===15?1:0),x[w]-=S*65536}function Ae(x,S,w){for(var A,k=~(w-1),z=0;z<16;z++)A=k&(x[z]^S[z]),x[z]^=A,S[z]^=A}function Me(x,S){var w,A,k,z=s(),K=s();for(w=0;w<16;w++)K[w]=S[w];for(Ce(K),Ce(K),Ce(K),A=0;A<2;A++){for(z[0]=K[0]-65517,w=1;w<15;w++)z[w]=K[w]-65535-(z[w-1]>>16&1),z[w-1]&=65535;z[15]=K[15]-32767-(z[14]>>16&1),k=z[15]>>16&1,z[14]&=65535,Ae(K,z,1-k)}for(w=0;w<16;w++)x[2*w]=K[w]&255,x[2*w+1]=K[w]>>8}function lt(x,S){var w=new Uint8Array(32),A=new Uint8Array(32);return Me(w,x),Me(A,S),O(w,0,A,0)}function Vt(x){var S=new Uint8Array(32);return Me(S,x),S[0]&1}function cn(x,S){var w;for(w=0;w<16;w++)x[w]=S[2*w]+(S[2*w+1]<<8);x[15]&=32767}function kt(x,S,w){var A;for(A=0;A<16;A++)x[A]=S[A]+w[A]|0}function Ct(x,S,w){var A;for(A=0;A<16;A++)x[A]=S[A]-w[A]|0}function Oe(x,S,w){var A,k,z=new Float64Array(31);for(A=0;A<31;A++)z[A]=0;for(A=0;A<16;A++)for(k=0;k<16;k++)z[A+k]+=S[A]*w[k];for(A=0;A<15;A++)z[A]+=38*z[A+16];for(A=0;A<16;A++)x[A]=z[A];Ce(x),Ce(x)}function Mt(x,S){Oe(x,S,S)}function ii(x,S){var w=s(),A;for(A=0;A<16;A++)w[A]=S[A];for(A=253;A>=0;A--)Mt(w,w),A!==2&&A!==4&&Oe(w,w,S);for(A=0;A<16;A++)x[A]=w[A]}function Ri(x,S){var w=s(),A;for(A=0;A<16;A++)w[A]=S[A];for(A=250;A>=0;A--)Mt(w,w),A!==1&&Oe(w,w,S);for(A=0;A<16;A++)x[A]=w[A]}function ri(x,S,w){var A=new Uint8Array(32),k=new Float64Array(80),z,K,ee=s(),H=s(),Q=s(),me=s(),ke=s(),Xe=s();for(K=0;K<31;K++)A[K]=S[K];for(A[31]=S[31]&127|64,A[0]&=248,cn(k,w),K=0;K<16;K++)H[K]=k[K],me[K]=ee[K]=Q[K]=0;for(ee[0]=me[0]=1,K=254;K>=0;--K)z=A[K>>>3]>>>(K&7)&1,Ae(ee,H,z),Ae(Q,me,z),kt(ke,ee,Q),Ct(ee,ee,Q),kt(Q,H,me),Ct(H,H,me),Mt(me,ke),Mt(Xe,ee),Oe(ee,Q,ee),Oe(Q,H,ke),kt(ke,ee,Q),Ct(ee,ee,Q),Mt(H,ee),Ct(Q,me,Xe),Oe(ee,Q,g),kt(ee,ee,me),Oe(Q,Q,ee),Oe(ee,me,Xe),Oe(me,H,k),Mt(H,ke),Ae(ee,H,z),Ae(Q,me,z);for(K=0;K<16;K++)k[K+16]=ee[K],k[K+32]=Q[K],k[K+48]=H[K],k[K+64]=me[K];var Dt=k.subarray(32),On=k.subarray(16);return ii(Dt,Dt),Oe(On,On,Dt),Me(x,On),0}function un(x,S){return ri(x,S,u)}function Di(x,S){return a(S,32),un(x,S)}function ys(x,S,w){var A=new Uint8Array(32);return ri(A,w,S),G(x,o,A,I)}var Za=ie,Wa=be;function zr(x,S,w,A,k,z){var K=new Uint8Array(32);return ys(K,k,z),Za(x,S,w,A,K)}function Ur(x,S,w,A,k,z){var K=new Uint8Array(32);return ys(K,k,z),Wa(x,S,w,A,K)}function In(){var x=0,S=0,w=0,A=0,k=65535,z,K,ee;for(ee=0;ee<arguments.length;ee++)z=arguments[ee].lo,K=arguments[ee].hi,x+=z&k,S+=z>>>16,w+=K&k,A+=K>>>16;return S+=x>>>16,w+=S>>>16,A+=w>>>16,new t(w&k|A<<16,x&k|S<<16)}function el(x,S){return new t(x.hi>>>S,x.lo>>>S|x.hi<<32-S)}function qi(){var x=0,S=0,w;for(w=0;w<arguments.length;w++)x^=arguments[w].lo,S^=arguments[w].hi;return new t(S,x)}function et(x,S){var w,A,k=32-S;return S<32?(w=x.hi>>>S|x.lo<<k,A=x.lo>>>S|x.hi<<k):S<64&&(w=x.lo>>>S|x.hi<<k,A=x.hi>>>S|x.lo<<k),new t(w,A)}function ec(x,S,w){var A=x.hi&S.hi^~x.hi&w.hi,k=x.lo&S.lo^~x.lo&w.lo;return new t(A,k)}function tl(x,S,w){var A=x.hi&S.hi^x.hi&w.hi^S.hi&w.hi,k=x.lo&S.lo^x.lo&w.lo^S.lo&w.lo;return new t(A,k)}function nl(x){return qi(et(x,28),et(x,34),et(x,39))}function zi(x){return qi(et(x,14),et(x,18),et(x,41))}function tc(x){return qi(et(x,1),et(x,8),el(x,7))}function sl(x){return qi(et(x,19),et(x,61),el(x,6))}var nc=[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 il(x,S,w){var A=[],k=[],z=[],K=[],ee,H,Q;for(H=0;H<8;H++)A[H]=z[H]=F(x,8*H);for(var me=0;w>=128;){for(H=0;H<16;H++)K[H]=F(S,8*H+me);for(H=0;H<80;H++){for(Q=0;Q<8;Q++)k[Q]=z[Q];for(ee=In(z[7],zi(z[4]),ec(z[4],z[5],z[6]),nc[H],K[H%16]),k[7]=In(ee,nl(z[0]),tl(z[0],z[1],z[2])),k[3]=In(k[3],ee),Q=0;Q<8;Q++)z[(Q+1)%8]=k[Q];if(H%16===15)for(Q=0;Q<16;Q++)K[Q]=In(K[Q],K[(Q+9)%16],tc(K[(Q+1)%16]),sl(K[(Q+14)%16]))}for(H=0;H<8;H++)z[H]=In(z[H],A[H]),A[H]=z[H];me+=128,w-=128}for(H=0;H<8;H++)X(x,8*H,A[H]);return w}var ai=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 ot(x,S,w){var A=new Uint8Array(64),k=new Uint8Array(256),z,K=w;for(z=0;z<64;z++)A[z]=ai[z];for(il(A,S,w),w%=128,z=0;z<256;z++)k[z]=0;for(z=0;z<w;z++)k[z]=S[K-w+z];for(k[w]=128,w=256-128*(w<112?1:0),k[w-9]=0,X(k,w-8,new t(K/536870912|0,K<<3)),il(A,k,w),z=0;z<64;z++)x[z]=A[z];return 0}function It(x,S){var w=s(),A=s(),k=s(),z=s(),K=s(),ee=s(),H=s(),Q=s(),me=s();Ct(w,x[1],x[0]),Ct(me,S[1],S[0]),Oe(w,w,me),kt(A,x[0],x[1]),kt(me,S[0],S[1]),Oe(A,A,me),Oe(k,x[3],S[3]),Oe(k,k,E),Oe(z,x[2],S[2]),kt(z,z,z),Ct(K,A,w),Ct(ee,z,k),kt(H,z,k),kt(Q,A,w),Oe(x[0],K,ee),Oe(x[1],Q,H),Oe(x[2],H,ee),Oe(x[3],K,Q)}function Rt(x,S,w){var A;for(A=0;A<4;A++)Ae(x[A],S[A],w)}function Br(x,S){var w=s(),A=s(),k=s();ii(k,S[2]),Oe(w,S[0],k),Oe(A,S[1],k),Me(x,A),x[31]^=Vt(w)<<7}function Lr(x,S,w){var A,k;for(ve(x[0],d),ve(x[1],m),ve(x[2],m),ve(x[3],d),k=255;k>=0;--k)A=w[k/8|0]>>(k&7)&1,Rt(x,S,A),It(S,x),It(x,x),Rt(x,S,A)}function Ui(x,S){var w=[s(),s(),s(),s()];ve(w[0],_),ve(w[1],T),ve(w[2],m),Oe(w[3],_,T),Lr(x,w,S)}function bs(x,S,w){var A=new Uint8Array(64),k=[s(),s(),s(),s()],z;for(w||a(S,32),ot(A,S,32),A[0]&=248,A[31]&=127,A[31]|=64,Ui(k,A),Br(x,k),z=0;z<32;z++)S[z+32]=x[z];return 0}var Fn=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 xs(x,S){var w,A,k,z;for(A=63;A>=32;--A){for(w=0,k=A-32,z=A-12;k<z;++k)S[k]+=w-16*S[A]*Fn[k-(A-32)],w=Math.floor((S[k]+128)/256),S[k]-=w*256;S[k]+=w,S[A]=0}for(w=0,k=0;k<32;k++)S[k]+=w-(S[31]>>4)*Fn[k],w=S[k]>>8,S[k]&=255;for(k=0;k<32;k++)S[k]-=w*Fn[k];for(A=0;A<32;A++)S[A+1]+=S[A]>>8,x[A]=S[A]&255}function jn(x){var S=new Float64Array(64),w;for(w=0;w<64;w++)S[w]=x[w];for(w=0;w<64;w++)x[w]=0;xs(x,S)}function li(x,S,w,A){var k=new Uint8Array(64),z=new Uint8Array(64),K=new Uint8Array(64),ee,H,Q=new Float64Array(64),me=[s(),s(),s(),s()];ot(k,A,32),k[0]&=248,k[31]&=127,k[31]|=64;var ke=w+64;for(ee=0;ee<w;ee++)x[64+ee]=S[ee];for(ee=0;ee<32;ee++)x[32+ee]=k[32+ee];for(ot(K,x.subarray(32),w+32),jn(K),Ui(me,K),Br(x,me),ee=32;ee<64;ee++)x[ee]=A[ee];for(ot(z,x,w+64),jn(z),ee=0;ee<64;ee++)Q[ee]=0;for(ee=0;ee<32;ee++)Q[ee]=K[ee];for(ee=0;ee<32;ee++)for(H=0;H<32;H++)Q[ee+H]+=z[ee]*k[H];return xs(x.subarray(32),Q),ke}function oi(x,S){var w=s(),A=s(),k=s(),z=s(),K=s(),ee=s(),H=s();return ve(x[2],m),cn(x[1],S),Mt(k,x[1]),Oe(z,k,y),Ct(k,k,x[2]),kt(z,x[2],z),Mt(K,z),Mt(ee,K),Oe(H,ee,K),Oe(w,H,k),Oe(w,w,z),Ri(w,w),Oe(w,w,k),Oe(w,w,z),Oe(w,w,z),Oe(x[0],w,z),Mt(A,x[0]),Oe(A,A,z),lt(A,k)&&Oe(x[0],x[0],R),Mt(A,x[0]),Oe(A,A,z),lt(A,k)?-1:(Vt(x[0])===S[31]>>7&&Ct(x[0],d,x[0]),Oe(x[3],x[0],x[1]),0)}function Pr(x,S,w,A){var k,z=new Uint8Array(32),K=new Uint8Array(64),ee=[s(),s(),s(),s()],H=[s(),s(),s(),s()];if(w<64||oi(H,A))return-1;for(k=0;k<w;k++)x[k]=S[k];for(k=0;k<32;k++)x[k+32]=A[k];if(ot(K,x,w),jn(K),Lr(ee,H,K),Ui(H,S.subarray(32)),It(ee,H),Br(z,ee),w-=64,O(S,0,z,0)){for(k=0;k<w;k++)x[k]=0;return-1}for(k=0;k<w;k++)x[k]=S[k+64];return w}var Bi=32,vs=24,An=32,_s=16,ws=32,ci=32,Ss=32,Jn=32,ui=32,Hr=vs,rl=An,qn=_s,Qe=64,it=32,Ft=64,fi=32,$r=64;i.lowlevel={crypto_core_hsalsa20:G,crypto_stream_xor:je,crypto_stream:re,crypto_stream_salsa20_xor:Z,crypto_stream_salsa20:ae,crypto_onetimeauth:$,crypto_onetimeauth_verify:se,crypto_verify_16:oe,crypto_verify_32:O,crypto_secretbox:ie,crypto_secretbox_open:be,crypto_scalarmult:ri,crypto_scalarmult_base:un,crypto_box_beforenm:ys,crypto_box_afternm:Za,crypto_box:zr,crypto_box_open:Ur,crypto_box_keypair:Di,crypto_hash:ot,crypto_sign:li,crypto_sign_keypair:bs,crypto_sign_open:Pr,crypto_secretbox_KEYBYTES:Bi,crypto_secretbox_NONCEBYTES:vs,crypto_secretbox_ZEROBYTES:An,crypto_secretbox_BOXZEROBYTES:_s,crypto_scalarmult_BYTES:ws,crypto_scalarmult_SCALARBYTES:ci,crypto_box_PUBLICKEYBYTES:Ss,crypto_box_SECRETKEYBYTES:Jn,crypto_box_BEFORENMBYTES:ui,crypto_box_NONCEBYTES:Hr,crypto_box_ZEROBYTES:rl,crypto_box_BOXZEROBYTES:qn,crypto_sign_BYTES:Qe,crypto_sign_PUBLICKEYBYTES:it,crypto_sign_SECRETKEYBYTES:Ft,crypto_sign_SEEDBYTES:fi,crypto_hash_BYTES:$r,gf:s,D:y,L:Fn,pack25519:Me,unpack25519:cn,M:Oe,A:kt,S:Mt,Z:Ct,pow2523:Ri,add:It,set25519:ve,modL:xs,scalarmult:Lr,scalarbase:Ui};function al(x,S){if(x.length!==Bi)throw new Error("bad key size");if(S.length!==vs)throw new Error("bad nonce size")}function ll(x,S){if(x.length!==Ss)throw new Error("bad public key size");if(S.length!==Jn)throw new Error("bad secret key size")}function xt(){for(var x=0;x<arguments.length;x++)if(!(arguments[x]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Li(x){for(var S=0;S<x.length;S++)x[S]=0}i.randomBytes=function(x){var S=new Uint8Array(x);return a(S,x),S},i.secretbox=function(x,S,w){xt(x,S,w),al(w,S);for(var A=new Uint8Array(An+x.length),k=new Uint8Array(A.length),z=0;z<x.length;z++)A[z+An]=x[z];return ie(k,A,A.length,S,w),k.subarray(_s)},i.secretbox.open=function(x,S,w){xt(x,S,w),al(w,S);for(var A=new Uint8Array(_s+x.length),k=new Uint8Array(A.length),z=0;z<x.length;z++)A[z+_s]=x[z];return A.length<32||be(k,A,A.length,S,w)!==0?null:k.subarray(An)},i.secretbox.keyLength=Bi,i.secretbox.nonceLength=vs,i.secretbox.overheadLength=_s,i.scalarMult=function(x,S){if(xt(x,S),x.length!==ci)throw new Error("bad n size");if(S.length!==ws)throw new Error("bad p size");var w=new Uint8Array(ws);return ri(w,x,S),w},i.scalarMult.base=function(x){if(xt(x),x.length!==ci)throw new Error("bad n size");var S=new Uint8Array(ws);return un(S,x),S},i.scalarMult.scalarLength=ci,i.scalarMult.groupElementLength=ws,i.box=function(x,S,w,A){var k=i.box.before(w,A);return i.secretbox(x,S,k)},i.box.before=function(x,S){xt(x,S),ll(x,S);var w=new Uint8Array(ui);return ys(w,x,S),w},i.box.after=i.secretbox,i.box.open=function(x,S,w,A){var k=i.box.before(w,A);return i.secretbox.open(x,S,k)},i.box.open.after=i.secretbox.open,i.box.keyPair=function(){var x=new Uint8Array(Ss),S=new Uint8Array(Jn);return Di(x,S),{publicKey:x,secretKey:S}},i.box.keyPair.fromSecretKey=function(x){if(xt(x),x.length!==Jn)throw new Error("bad secret key size");var S=new Uint8Array(Ss);return un(S,x),{publicKey:S,secretKey:new Uint8Array(x)}},i.box.publicKeyLength=Ss,i.box.secretKeyLength=Jn,i.box.sharedKeyLength=ui,i.box.nonceLength=Hr,i.box.overheadLength=i.secretbox.overheadLength,i.sign=function(x,S){if(xt(x,S),S.length!==Ft)throw new Error("bad secret key size");var w=new Uint8Array(Qe+x.length);return li(w,x,x.length,S),w},i.sign.open=function(x,S){if(xt(x,S),S.length!==it)throw new Error("bad public key size");var w=new Uint8Array(x.length),A=Pr(w,x,x.length,S);if(A<0)return null;for(var k=new Uint8Array(A),z=0;z<k.length;z++)k[z]=w[z];return k},i.sign.detached=function(x,S){for(var w=i.sign(x,S),A=new Uint8Array(Qe),k=0;k<A.length;k++)A[k]=w[k];return A},i.sign.detached.verify=function(x,S,w){if(xt(x,S,w),S.length!==Qe)throw new Error("bad signature size");if(w.length!==it)throw new Error("bad public key size");var A=new Uint8Array(Qe+x.length),k=new Uint8Array(Qe+x.length),z;for(z=0;z<Qe;z++)A[z]=S[z];for(z=0;z<x.length;z++)A[z+Qe]=x[z];return Pr(k,A,A.length,w)>=0},i.sign.keyPair=function(){var x=new Uint8Array(it),S=new Uint8Array(Ft);return bs(x,S),{publicKey:x,secretKey:S}},i.sign.keyPair.fromSecretKey=function(x){if(xt(x),x.length!==Ft)throw new Error("bad secret key size");for(var S=new Uint8Array(it),w=0;w<S.length;w++)S[w]=x[32+w];return{publicKey:S,secretKey:new Uint8Array(x)}},i.sign.keyPair.fromSeed=function(x){if(xt(x),x.length!==fi)throw new Error("bad seed size");for(var S=new Uint8Array(it),w=new Uint8Array(Ft),A=0;A<32;A++)w[A]=x[A];return bs(S,w,!0),{publicKey:S,secretKey:w}},i.sign.publicKeyLength=it,i.sign.secretKeyLength=Ft,i.sign.seedLength=fi,i.sign.signatureLength=Qe,i.hash=function(x){xt(x);var S=new Uint8Array($r);return ot(S,x,x.length),S},i.hash.hashLength=$r,i.verify=function(x,S){return xt(x,S),x.length===0||S.length===0||x.length!==S.length?!1:fe(x,0,S,0,x.length)===0},i.setPRNG=function(x){a=x},(function(){var x=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(x&&x.getRandomValues){var S=65536;i.setPRNG(function(w,A){var k,z=new Uint8Array(A);for(k=0;k<A;k+=S)x.getRandomValues(z.subarray(k,k+Math.min(A-k,S)));for(k=0;k<A;k++)w[k]=z[k];Li(z)})}else typeof require<"u"&&(x=require("crypto"),x&&x.randomBytes&&i.setPRNG(function(w,A){var k,z=x.randomBytes(A);for(k=0;k<A;k++)w[k]=z[k];Li(z)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const wo=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;wo.sign.keyPair.fromSeed,wo.sign.detached,wo.sign.detached.verify,wo.randomBytes;var $0;(function(i){i.InvalidPrefixByte="nkeys: invalid prefix byte",i.InvalidKey="nkeys: invalid key",i.InvalidPublicKey="nkeys: invalid public key",i.InvalidSeedLen="nkeys: invalid seed length",i.InvalidSeed="nkeys: invalid seed",i.InvalidEncoding="nkeys: invalid encoded key",i.InvalidSignature="nkeys: signature verification failed",i.CannotSign="nkeys: cannot sign, no private key available",i.PublicKeyOnly="nkeys: no seed or private key available",i.InvalidChecksum="nkeys: invalid checksum",i.SerializationError="nkeys: serialization error",i.ApiError="nkeys: api error",i.ClearedPair="nkeys: pair is cleared"})($0||($0={}));var Y0;(function(i){i[i.Seed=144]="Seed",i[i.Private=120]="Private",i[i.Operator=112]="Operator",i[i.Server=104]="Server",i[i.Cluster=16]="Cluster",i[i.Account=0]="Account",i[i.User=160]="User"})(Y0||(Y0={}));function J1(i){return t=>{let s={};return i.forEach(a=>{const o=a(t)||{};s=Object.assign(s,o)}),s}}function Q1(){return()=>{}}function K1(i,t){return()=>{const s=typeof i=="function"?i():i,a=typeof t=="function"?t():t;return{user:s,pass:a}}}function X1(i){return()=>({auth_token:typeof i=="function"?i():i})}const Jg=120*1e3,Z1=2,Qg=2*1e3;function W1(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:Jg,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:Qg,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function e_(i){const t=[];return typeof i.authenticator=="function"&&t.push(i.authenticator),Array.isArray(i.authenticator)&&t.push(...i.authenticator),i.token&&t.push(X1(i.token)),i.user&&t.push(K1(i.user,i.pass)),t.length===0?Q1():J1(t)}function t_(i){const t=`${Mf}:${Vg()}`;if(i=i||{servers:[t]},i.servers=i.servers||[],typeof i.servers=="string"&&(i.servers=[i.servers]),i.servers.length>0&&i.port)throw new de("port and servers options are mutually exclusive",le.InvalidOption);i.servers.length===0&&i.port&&(i.servers=[`${Mf}:${i.port}`]),i.servers&&i.servers.length===0&&(i.servers=[t]);const s=Jo(W1(),i);if(s.authenticator=e_(s),["reconnectDelayHandler","authenticator"].forEach(a=>{if(s[a]&&typeof s[a]!="function")throw new de(`${a} option should be a function`,le.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let a=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return a&&(a++,a=Math.floor(Math.random()*a)),s.reconnectTimeWait+a}),s.inboxPrefix)try{ms(s.inboxPrefix)}catch(a){throw new de(a.message,le.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Pf()=="function"),s.resolve&&typeof Pf()!="function")throw new de("'resolve' is not supported on this client",le.InvalidOption);return s}function n_(i,t){const{proto:s,tls_required:a,tls_available:o}=i;if((s===void 0||s<1)&&t.noEcho)throw new de("noEcho",le.ServerOptionNotAvailable);const u=a||o||!1;if(t.tls&&!u)throw new de("tls",le.ServerOptionNotAvailable)}const s_=1024*32,i_=/^INFO\s+([^\r\n]+)\r\n/i,r_=La(`PONG\r
38
+ `),G0=La(`PING\r
39
+ `);class a_{constructor(t,s,a){v(this,"echo");v(this,"no_responders");v(this,"protocol");v(this,"verbose");v(this,"pedantic");v(this,"jwt");v(this,"nkey");v(this,"sig");v(this,"user");v(this,"pass");v(this,"auth_token");v(this,"tls_required");v(this,"name");v(this,"lang");v(this,"version");v(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(a):{})||{};Jo(this,o)}}class Kg extends St{constructor(s,a,o={}){var d;super();v(this,"sid");v(this,"queue");v(this,"draining");v(this,"max");v(this,"subject");v(this,"drained");v(this,"protocol");v(this,"timer");v(this,"info");v(this,"cleanupFn");v(this,"closed");v(this,"requestSubject");Jo(this,o),this.protocol=s,this.subject=a,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=st();const u=!((d=s.options)!=null&&d.noAsyncTraces);o.timeout&&(this.timer=kr(o.timeout,u),this.timer.then(()=>{this.timer=void 0}).catch(m=>{this.stop(m),this.noIterator&&this.callback(m,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const a=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),u=s.protocolFilterFn?s.protocolFilterFn:()=>!0,d=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(m,g)=>{const{ingest:y}=o(g);y&&u(g)&&(a(m,g),d(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,a){this.cancelTimeout(),s?this.stop(s):this.push(a)}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(de.errorForCode(le.ConnectionClosed)):this.isClosed()?Promise.reject(de.errorForCode(le.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(st()).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 l_{constructor(){v(this,"mux");v(this,"subs");v(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,a=this.all();let o;if(s.operation==="subscription"&&(o=a.find(u=>u.subject===s.subject&&u.queue===s.queue)),s.operation==="publish"&&(o=a.find(u=>u.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 Ho{constructor(t,s){v(this,"connected");v(this,"connectedOnce");v(this,"infoReceived");v(this,"info");v(this,"muxSubscriptions");v(this,"options");v(this,"outbound");v(this,"pongs");v(this,"subscriptions");v(this,"transport");v(this,"noMorePublishing");v(this,"connectError");v(this,"publisher");v(this,"_closed");v(this,"closed");v(this,"listeners");v(this,"heartbeats");v(this,"parser");v(this,"outMsgs");v(this,"inMsgs");v(this,"outBytes");v(this,"inBytes");v(this,"pendingLimit");v(this,"lastError");v(this,"abortReconnect");v(this,"whyClosed");v(this,"servers");v(this,"server");v(this,"features");v(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=s_,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=t,this.publisher=s,this.subscriptions=new l_,this.muxSubscriptions=new Y1,this.outbound=new Mr,this.pongs=[],this.whyClosed="",this.pendingLimit=t.pendingLimit||this.pendingLimit,this.features=new S1({major:0,minor:0,micro:0}),this.connectPromise=null;const a=typeof t.servers=="string"?[t.servers]:t.servers;this.servers=new $1(a,{randomize:!t.noRandomize}),this.closed=st(),this.parser=new H0(this),this.heartbeats=new G1(this,this.options.pingInterval||Jg,this.options.maxPingOut||Z1)}resetOutbound(){this.outbound.reset();const t=this.pongs;this.pongs=[];const s=de.errorForCode(le.Disconnect);s.stack="",t.forEach(a=>{a.reject(s)}),this.parser=new H0(this),this.infoReceived=!1}dispatchStatus(t){this.listeners.forEach(s=>{s.push(t)})}status(){const t=new St;return this.listeners.push(t),t}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const t=st();return t.catch(()=>{}),this.pongs.unshift(t),this.connectError=s=>{t.reject(s)},this.transport=A1(),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:Er.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Er.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(t){this.dispatchStatus({type:ds.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:ds.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===le.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(t)}async dial(t){const s=this.prepare();let a;try{a=kr(this.options.timeout||2e4);const o=this.transport.connect(t,this.options);await Promise.race([o,a]),(async()=>{try{for await(const u of this.transport)this.parser.parse(u)}catch(u){console.log("reader closed",u)}})().then()}catch(o){s.reject(o)}try{await Promise.race([a,s]),a&&a.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 a&&a.cancel(),await this.transport.close(o),o}}async _doDial(t){const{resolve:s}=this.options,a=await t.resolve({fn:Pf(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const u of a)try{o=null,this.dispatchStatus({type:Er.Reconnecting,data:u.toString()}),await this.dial(u);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():Qg;let a=s;const o=this.selectServer();if(!o||this.abortReconnect)throw t||(this.lastError?this.lastError:de.errorForCode(le.ConnectionRefused));const u=Date.now();if(o.lastConnect===0||o.lastConnect+s<=u){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 m=this.options.maxReconnectAttempts||0;m!==-1&&o.reconnects>=m&&this.servers.removeCurrentServer()}}else a=Math.min(a,o.lastConnect+s-u),await Rr(a)}}static async connect(t,s){const a=new Ho(t,s);return await a.dialLoop(),a}static toError(t){const s=t?t.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const a=new de(t,le.PermissionsViolation),o=t.match(/(Publish|Subscription) to "(\S+)"/);if(o){a.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const u=t.match(/using queue "(\S+)"/);u&&(a.permissionContext.queue=u[1])}return a}else return s.indexOf("authorization violation")!==-1?new de(t,le.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new de(t,le.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new de(t,le.AccountExpired):s.indexOf("authentication timeout")!==-1?new de(t,le.AuthenticationTimeout):new de(t,le.ProtocolError)}processMsg(t,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const a=this.subscriptions.get(t.sid);a&&(a.received+=1,a.callback&&a.callback(null,new oh(t,s,this)),a.max!==void 0&&a.received>=a.max&&a.unsubscribe())}processError(t){const s=A0(t),a=Ho.toError(s),o={type:ds.Error,data:a.code};if(a.isPermissionError()){let u=!1;if(a.permissionContext){o.permissionContext=a.permissionContext;const d=this.subscriptions.getMux();u=(d==null?void 0:d.subject)===a.permissionContext.subject}this.subscriptions.handleError(a),this.muxSubscriptions.handleError(u,a),u&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(a)}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(r_)}processPong(){const t=this.pongs.shift();t&&t.resolve()}processInfo(t){const s=JSON.parse(A0(t));this.info=s;const a=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(Ci(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:u,lang:d}=this.transport;try{const m=new a_({version:u,lang:d},this.options,s.nonce);s.headers&&(m.headers=!0,m.no_responders=!0);const g=JSON.stringify(m);this.transport.send(La(`CONNECT ${g}${To}`)),this.transport.send(G0)}catch(m){this._close(m)}}a&&this.dispatchStatus({type:ds.Update,data:a}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:ds.LDM,data:this.servers.getCurrentServer().toString()})}push(t){switch(t.kind){case Ut.MSG:{const{msg:s,data:a}=t;this.processMsg(s,a);break}case Ut.OK:break;case Ut.ERR:this.processError(t.data);break;case Ut.PING:this.processPing();break;case Ut.PONG:this.processPong();break;case Ut.INFO:this.processInfo(t.data);break}}sendCommand(t,...s){const a=this.outbound.length();let o;typeof t=="string"?o=La(t):o=t,this.outbound.fill(o,...s),a===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(t,s=an,a){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=Mi.encode(s);else throw de.errorForCode(le.BadPayload);let u=o.length;a=a||{},a.reply=a.reply||"";let d=an,m=0;if(a.headers){if(this.info&&!this.info.headers)throw new de("headers",le.ServerOptionNotAvailable);d=a.headers.encode(),m=d.length,u=o.length+m}if(this.info&&u>this.info.max_payload)throw de.errorForCode(le.MaxPayloadExceeded);this.outBytes+=u,this.outMsgs++;let g;a.headers?(a.reply?g=`HPUB ${t} ${a.reply} ${m} ${u}\r
40
40
  `:g=`HPUB ${t} ${m} ${u}\r
41
41
  `,this.sendCommand(g,d,o,Po)):(a.reply?g=`PUB ${t} ${a.reply} ${u}\r
42
42
  `:g=`PUB ${t} ${u}\r
@@ -44,20 +44,20 @@ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(a),this.cance
44
44
  `):this.sendCommand(`SUB ${t.subject} ${t.sid}\r
45
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
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=st()),this.pongs.push(t),this.outbound.fill($0),this.flushPending(),t}sendSubscriptions(){const t=[];this.subscriptions.all().forEach(s=>{const a=s;a.queue?t.push(`SUB ${a.subject} ${a.queue} ${a.sid}${To}`):t.push(`SUB ${a.subject} ${a.sid}${To}`)}),t.length&&this.transport.send(Pa(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(a=>{s.push(a.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),a=new Ig(this,`${s}*`);a.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(a),this.subscribe(a)}}selectServer(){const t=this.servers.selectServer();if(t!==void 0)return this.server=t,this.server}getServer(){return this.server}}const r_="$SRV";class Y0{constructor(t){v(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,a,o){var u,d;return o=o||{},o.headers=o.headers||ps(),(u=o.headers)==null||u.set(zo,`${t}`),(d=o.headers)==null||d.set(qo,s),this.msg.respond(a,o)}json(t){return this.msg.json(t)}string(){return this.msg.string()}}class Ia{constructor(t,s="",a=""){v(this,"subject");v(this,"queue");v(this,"srv");s!==""&&l_("service group",s);let o="";if(t instanceof Xa)this.srv=t,o="";else if(t instanceof Ia){const u=t;this.srv=u.srv,a===""&&u.queue!==""&&(a=u.queue),o=u.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=a}calcSubject(t,s=""){return s===""?t:t!==""?`${t}.${s}`:s}addEndpoint(t="",s){s=s||{subject:t};const a=typeof s=="function"?{handler:s,subject:t}:s;Ua("endpoint",t);let{subject:o,handler:u,metadata:d,queue:m}=a;o=o||t,m=m||this.queue,a_("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:t,subject:o,queue:m,handler:u,metadata:d};return this.srv._addEndpoint(g)}addGroup(t="",s=""){return new Ia(this,t,s)}}function a_(i,t){if(t==="")throw new Error(`${i} cannot be empty`);if(t.indexOf(" ")!==-1)throw new Error(`${i} cannot contain spaces: '${t}'`);const s=t.split(".");s.forEach((a,o)=>{if(a===">"&&o!==s.length-1)throw new Error(`${i} cannot have internal '>': '${t}'`)})}function l_(i,t){if(t.indexOf(" ")!==-1)throw new Error(`${i} cannot contain spaces: '${t}'`);t.split(".").forEach(a=>{if(a===">")throw new Error(`${i} name cannot contain internal '>': '${t}'`)})}class Xa{constructor(t,s={name:"",version:""}){v(this,"nc");v(this,"_id");v(this,"config");v(this,"handlers");v(this,"internal");v(this,"_stopped");v(this,"_done");v(this,"started");this.nc=t,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),Ua("name",this.config.name),Ua("queue",this.config.queue),Ti(this.config.version),this._id=ei.next(),this.internal=[],this._done=st(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(a=>{this.close(a).catch()})}static controlSubject(t,s="",a="",o){const u=o??r_;return s===""&&a===""?`${u}.${t}`:(Ua("control subject name",s),a!==""?(Ua("control subject id",a),`${u}.${t}.${s}.${a}`):`${u}.${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=ps();if(t instanceof Uo){const a=t;s.set(qo,a.message),s.set(zo,`${a.code}`)}else s.set(qo,t.message),s.set(zo,"500");return s}setupHandler(t,s=!1){const a=s?"":t.queue?t.queue:this.config.queue,{name:o,subject:u,handler:d}=t,m=t;m.internal=s,s&&this.internal.push(m),m.stats=new o_(o,u,a),m.queue=a;const g=d?(y,E)=>{if(y){this.close(y);return}const _=Date.now();try{d(y,new Y0(E))}catch(N){m.stats.countError(N),E==null||E.respond(an,{headers:this.errorToHeader(N)})}finally{m.stats.countLatency(_)}}:void 0;return m.sub=this.nc.subscribe(u,{callback:g,queue:a}),m.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${t.subject} stopped`)).catch()}).catch(y=>{if(!this._stopped){const E=new Error(`required subscription ${t.subject} errored: ${y.message}`);E.stack=y.stack,this.close(E).catch()}}),m}info(){return{type:Ha.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:a,name:o,queue:u}=t;return{subject:s,metadata:a,name:o,queue_group:u}})}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(a){s.stats.countError(a)}t.push(s.stats.stats(s.qi))}return{type:Ha.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:t}}addInternalHandler(t,s){const a=`${t}`.toUpperCase();this._doAddInternalHandler(`${a}-all`,t,s),this._doAddInternalHandler(`${a}-kind`,t,s,this.name),this._doAddInternalHandler(`${a}`,t,s,this.name,this.id)}_doAddInternalHandler(t,s,a,o="",u=""){const d={};d.name=t,d.subject=Xa.controlSubject(s,o,u),d.handler=a,this.setupHandler(d,!0)}start(){const t=Rn(),s=(d,m)=>d?(this.close(d),Promise.reject(d)):this.stats().then(g=>(m==null||m.respond(t.encode(g)),Promise.resolve())),a=(d,m)=>d?(this.close(d),Promise.reject(d)):(m==null||m.respond(t.encode(this.info())),Promise.resolve()),o=t.encode(this.ping()),u=(d,m)=>d?(this.close(d).then().catch(),Promise.reject(d)):(m.respond(o),Promise.resolve());return this.addInternalHandler(Ks.PING,u),this.addInternalHandler(Ks.STATS,s),this.addInternalHandler(Ks.INFO,a),this.handlers.forEach(d=>{const{subject:m}=d;typeof m=="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(a=>a.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:Ha.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 Ia(this,t,s)}addEndpoint(t,s){return new Ia(this).addEndpoint(t,s)}_addEndpoint(t){const s=new St;s.noIterator=typeof t.handler=="function",s.noIterator||(t.handler=(o,u)=>{o?this.stop(o).catch():s.push(new Y0(u))},s.iterClosed.then(()=>{this.close().catch()}));const a=this.setupHandler(t,!1);return a.qi=s,this.handlers.push(a),s}}class o_{constructor(t,s,a=""){v(this,"name");v(this,"subject");v(this,"average_processing_time");v(this,"num_requests");v(this,"processing_time");v(this,"num_errors");v(this,"last_error");v(this,"data");v(this,"metadata");v(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=a}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+=nt(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:a,num_errors:o,num_requests:u,processing_time:d,last_error:m,data:g,queue:y}=this;return{name:t,subject:s,average_processing_time:a,num_errors:o,num_requests:u,processing_time:d,last_error:m,data:g,queue_group:y}}stats(t){const s=t;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=nt(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 c_{constructor(t,s={strategy:Mn.JitterTimer,maxWait:2e3},a){v(this,"nc");v(this,"prefix");v(this,"opts");this.nc=t,this.prefix=a,this.opts=s}ping(t="",s=""){return this.q(Ks.PING,t,s)}stats(t="",s=""){return this.q(Ks.STATS,t,s)}info(t="",s=""){return this.q(Ks.INFO,t,s)}async q(t,s="",a=""){const o=new St,u=Rn(),d=Xa.controlSubject(t,s,a,this.prefix),m=await this.nc.requestMany(d,an,this.opts);return(async()=>{for await(const g of m)try{const y=u.decode(g.data);o.push(y)}catch(y){o.push(()=>{o.stop(y)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function Fg(){return{key:{encode(i){return i},decode(i){return i}},value:{encode(i){return i},decode(i){return i}}}}function u_(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:Fg(),storage:zf.File}}const $o="KV-Operation",G0="$KV",f_=/^[-/=.\w]+$/,h_=/^[-/=.>*\w]+$/,d_=/^[-\w]+$/;function m_(i){if(i.startsWith(".")||i.endsWith(".")||!f_.test(i))throw new Error(`invalid key: ${i}`)}function p_(i){if(i.startsWith(".")||i.endsWith(".")||!h_.test(i))throw new Error(`invalid key: ${i}`)}function g_(i){if(i.startsWith(".")||i.endsWith("."))throw new Error(`invalid key: ${i}`);const t=i.split(".");let s=!1;for(let a=0;a<t.length;a++)switch(t[a]){case"*":s=!0;break;case">":if(a!==t.length-1)throw new Error(`invalid key: ${i}`);s=!0;break}return s}function ko(i){if(!d_.test(i))throw new Error(`invalid bucket name: ${i}`)}var Hn;(function(i){i.MsgIdHdr="Nats-Msg-Id",i.ExpectedStreamHdr="Nats-Expected-Stream",i.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",i.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",i.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(Hn||(Hn={}));class Fa{constructor(t,s,a){v(this,"js");v(this,"jsm");v(this,"stream");v(this,"bucket");v(this,"direct");v(this,"codec");v(this,"prefix");v(this,"editPrefix");v(this,"useJsPrefix");v(this,"_prefixLen");v(this,"validateKey",m_);v(this,"validateSearchKey",p_);v(this,"hasWildcards",g_);ko(t),this.js=s,this.jsm=a,this.bucket=t,this.prefix=G0,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(t,s,a={}){ko(s);const o=await t.jetstreamManager(),u=new Fa(s,t,o);return await u.init(a),u}static async bind(t,s,a={}){const o=await t.jetstreamManager(),u={config:{allow_direct:a.allow_direct}};ko(s);const d=new Fa(s,t,o);return u.config.name=a.streamName??d.bucketName(),Object.assign(d,u),d.stream=u.config.name,d.codec=a.codec||Fg(),d.direct=u.config.allow_direct??!1,d.initializePrefixes(u),d}async init(t={}){const s=Object.assign(u_(),t);this.codec=s.codec;const a={};this.stream=a.name=t.streamName??this.bucketName(),a.retention=qf.Limits,a.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(a.max_bytes=s.max_bytes),a.max_msg_size=s.maxValueSize,a.storage=s.storage;const o=t.placementCluster??"";if(o&&(t.placement={},t.placement.cluster=o,t.placement.tags=[]),t.placement&&(a.placement=t.placement),t.republish&&(a.republish=t.republish),t.description&&(a.description=t.description),t.mirror){const _=Object.assign({},t.mirror);_.name.startsWith(nn)||(_.name=`${nn}${_.name}`),a.mirror=_,a.mirror_direct=!0}else if(t.sources){const _=t.sources.map(N=>{const R=Object.assign({},N),M=R.name.startsWith(nn)?R.name.substring(nn.length):R.name;return R.name.startsWith(nn)||(R.name=`${nn}${R.name}`),!N.external&&M!==this.bucket&&(R.subject_transforms=[{src:`$KV.${M}.>`,dest:`$KV.${this.bucket}.>`}]),R});a.sources=_,a.subjects=[this.subjectForBucket()]}else a.subjects=[this.subjectForBucket()];t.metadata&&(a.metadata=t.metadata),typeof t.compression=="boolean"&&(a.compression=t.compression?ti.S2:ti.None);const u=this.js.nc,d=u.getServerVersion(),m=d?Bf(d,Ti("2.7.2"))>=0:!1;a.discard=m?Va.New:Va.Old;const{ok:g,min:y}=u.features.get(Le.JS_ALLOW_DIRECT);if(!g&&t.allow_direct===!0){const _=d?`${d.major}.${d.minor}.${d.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${_} - requires ${y}`))}t.allow_direct=typeof t.allow_direct=="boolean"?t.allow_direct:g,a.allow_direct=t.allow_direct,this.direct=a.allow_direct,a.num_replicas=s.replicas,s.ttl&&(a.max_age=nt(s.ttl)),a.allow_rollup_hdrs=!0;let E;try{E=await this.jsm.streams.info(a.name),!E.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(_){if(_.message==="stream not found")E=await this.jsm.streams.add(a);else throw _}this.initializePrefixes(E)}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 a=s.name;if(a.startsWith(nn)&&(a=a.substring(nn.length)),s.external&&s.external.api!==""){const o=s.name.substring(nn.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${a}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${nn}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(t,s=!1){const a=[];return s?(this.useJsPrefix&&a.push(this.js.apiPrefix),this.editPrefix!==""?a.push(this.editPrefix):a.push(this.prefix)):this.prefix&&a.push(this.prefix),a.push(t),a.join(".")}fullKeyName(t){return this.prefix!==""?`${this.prefix}.${t}`:`${G0}.${this.bucket}.${t}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(t){const s=[];for(const a of t.split("."))switch(a){case">":case"*":s.push(a);break;default:s.push(this.codec.key.encode(a));break}return s.join(".")}decodeKey(t){const s=[];for(const a of t.split("."))switch(a){case">":case"*":s.push(a);break;default:s.push(this.codec.key.decode(a));break}return s.join(".")}close(){return Promise.resolve()}dataLen(t,s){const a=s&&s.get(Bt.MessageSizeHdr)||"";return a!==""?parseInt(a,10):t.length}smToEntry(t){return new C_(this.bucket,this.prefixLen,t)}jmToEntry(t){const s=this.decodeKey(t.subject.substring(this.prefixLen));return new M_(this.bucket,s,t)}async create(t,s){var u;let a;try{const d=await this.put(t,s,{previousSeq:0});return Promise.resolve(d)}catch(d){if(a=d,((u=d==null?void 0:d.api_error)==null?void 0:u.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(a)}catch(d){return Promise.reject(d)}}update(t,s,a){if(a<=0)throw new Error("version must be greater than 0");return this.put(t,s,{previousSeq:a})}async put(t,s,a={}){var d,m;const o=this.encodeKey(t);this.validateKey(o);const u={};if(a.previousSeq!==void 0){const g=ps();u.headers=g,g.set(Hn.ExpectedLastSubjectSequenceHdr,`${a.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,u)).seq}catch(g){const y=g;return y.isJetStreamError()?(y.message=(d=y.api_error)==null?void 0:d.description,y.code=`${(m=y.api_error)==null?void 0:m.code}`,Promise.reject(y)):Promise.reject(g)}}async get(t,s){const a=this.encodeKey(t);this.validateKey(a);let o={last_by_subj:this.subjectForKey(a)};s&&s.revision>0&&(o={seq:s.revision});let u;try{this.direct?u=await this.jsm.direct.getMessage(this.bucketName(),o):u=await this.jsm.streams.getMessage(this.bucketName(),o);const d=this.smToEntry(u);return d.key!==a?null:d}catch(d){if(d.code===le.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=st(),a=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&a.push(g)})().then(),await s,o.stop();const u=Date.now()-t,d=a.map(g=>{const y=this.subjectForKey(g.key);return g.created.getTime()>=u?this.jsm.streams.purge(this.stream,{filter:y,keep:1}):this.jsm.streams.purge(this.stream,{filter:y,keep:0})}),m=await Promise.all(d);return m.unshift({success:!0,purged:0}),m.reduce((g,y)=>(g.purged+=y.purged,g))}async _deleteOrPurge(t,s,a){if(!this.hasWildcards(t))return this._doDeleteOrPurge(t,s,a);const o=await this.keys(t),u=[];for await(const d of o)u.push(this._doDeleteOrPurge(d,s)),u.length===100&&(await Promise.all(u),u.length=0);u.length>0&&await Promise.all(u)}async _doDeleteOrPurge(t,s,a){const o=this.encodeKey(t);this.validateKey(o);const u=ps();u.set($o,s),s==="PURGE"&&u.set(Bt.RollupHdr,Bt.RollupValueSubject),a!=null&&a.previousSeq&&u.set(Hn.ExpectedLastSubjectSequenceHdr,`${a.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),an,{headers:u})}_buildCC(t,s,a={}){let u=(Array.isArray(t)?t:[t]).map(g=>{const y=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(y)}),d=ft.LastPerSubject;s===kn.AllHistory&&(d=ft.All),s===kn.UpdatesOnly&&(d=ft.New);let m;return u.length===1&&(m=u[0],u=void 0),Object.assign({deliver_policy:d,ack_policy:wt.None,filter_subjects:u,filter_subject:m,flow_control:!0,idle_heartbeat:nt(5*1e3)},a)}remove(t){return this.purge(t)}async history(t={}){const s=t.key??">",a=new St,o={};o.headers_only=t.headers_only||!1;let u;u=()=>{a.stop()};let d=0;const m=this._buildCC(s,kn.AllHistory,o),g=m.filter_subject,y=Zs(m);y.bindStream(this.stream),y.orderedConsumer(),y.callback((_,N)=>{if(_){a.stop(_);return}if(N){const R=this.jmToEntry(N);a.push(R),a.received++,(u&&d>0&&a.received>=d||N.info.pending===0)&&(a.push(u),u=void 0)}});const E=await this.js.subscribe(g,y);if(u){const{info:{last:_}}=E,N=_.num_pending+_.delivered.consumer_seq;if(N===0||a.received>=N)try{u()}catch(R){a.stop(R)}finally{u=void 0}else d=N}return a._data=E,a.iterClosed.then(()=>{E.unsubscribe()}),E.closed.then(()=>{a.stop()}).catch(_=>{a.stop(_)}),a}canSetWatcherName(){const s=this.js.nc,{ok:a}=s.features.get(Le.JS_NEW_CONSUMER_CREATE_API);return a}async watch(t={}){const s=t.key??">",a=new St,o={};o.headers_only=t.headers_only||!1;let u=kn.LastValue;t.include===kn.AllHistory?u=kn.AllHistory:t.include===kn.UpdatesOnly&&(u=kn.UpdatesOnly);const d=t.ignoreDeletes===!0;let m=t.initializedFn,g=0;const y=this._buildCC(s,u,o),E=y.filter_subject,_=Zs(y);this.canSetWatcherName()&&_.consumerName(ei.next()),_.bindStream(this.stream),t.resumeFromRevision&&t.resumeFromRevision>0&&_.startSequence(t.resumeFromRevision),_.orderedConsumer(),_.callback((R,M)=>{if(R){a.stop(R);return}if(M){const D=this.jmToEntry(M);if(d&&D.operation==="DEL")return;a.push(D),a.received++,m&&(g>0&&a.received>=g||M.info.pending===0)&&(a.push(m),m=void 0)}});const N=await this.js.subscribe(E,_);if(m){const{info:{last:R}}=N,M=R.num_pending+R.delivered.consumer_seq;if(M===0||a.received>=M)try{m()}catch(D){a.stop(D)}finally{m=void 0}else g=M}return a._data=N,a.iterClosed.then(()=>{N.unsubscribe()}),N.closed.then(()=>{a.stop()}).catch(R=>{a.stop(R)}),a}async keys(t=">"){const s=new St,a=this._buildCC(t,kn.LastValue,{headers_only:!0}),o=Array.isArray(t)?">":a.filter_subject,u=Zs(a);u.bindStream(this.stream),u.orderedConsumer();const d=await this.js.subscribe(o,u);return(async()=>{var g;for await(const y of d){const E=(g=y.headers)==null?void 0:g.get($o);if(E!=="DEL"&&E!=="PURGE"){const _=this.decodeKey(y.subject.substring(this.prefixLen));s.push(_)}y.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 u;const s=((u=this.js.nc.info)==null?void 0:u.cluster)??"",a=this.bucketName(),o=await this.jsm.streams.info(a);return new Jg(o,s)}}class Jg{constructor(t,s=""){v(this,"si");v(this,"cluster");this.si=t,this.cluster=s}get bucket(){return this.si.config.name.startsWith(nn)?this.si.config.name.substring(nn.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 lh(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!==ti.None:!1}}const uh="OBJ_",V0="SHA-256=";function y_(i){return ko(i),`${uh}${i}`}function b_(i){return i.startsWith(uh)?i.substring(4):i}class $f{constructor(t){v(this,"si");v(this,"backingStore");this.si=t,this.backingStore="JetStream"}get bucket(){return b_(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!==ti.None:!1}}function Eo(i){if(i===void 0)return;const{domain:t}=i;if(t===void 0)return i;const s=Object.assign({},i);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 vn;(function(i){i[i.Unset=-1]="Unset",i[i.Consume=0]="Consume",i[i.Fetch=1]="Fetch"})(vn||(vn={}));var $n;(function(i){i.HeartbeatsMissed="heartbeats_missed",i.ConsumerNotFound="consumer_not_found",i.StreamNotFound="stream_not_found",i.ConsumerDeleted="consumer_deleted",i.OrderedConsumerRecreated="ordered_consumer_recreated",i.NoResponders="no_responders"})($n||($n={}));var Nr;(function(i){i.DebugEvent="debug",i.Discard="discard",i.Reset="reset",i.Next="next"})(Nr||(Nr={}));const I0=Uint8Array.of(43,65,67,75),x_=Uint8Array.of(45,78,65,75),Ma=Uint8Array.of(43,87,80,73),v_=Uint8Array.of(43,78,88,84),__=Uint8Array.of(43,84,69,82,77),w_=Uint8Array.of(32);function Ja(i,t=5e3){return new L_(i,t)}class xf extends St{constructor(s,a,o=!1){super();v(this,"consumer");v(this,"opts");v(this,"sub");v(this,"monitor");v(this,"pending");v(this,"inbox");v(this,"refilling");v(this,"pong");v(this,"callback");v(this,"timeout");v(this,"cleanupHandler");v(this,"listeners");v(this,"statusIterator");v(this,"forOrderedConsumer");v(this,"resetHandler");v(this,"abortOnMissingResource");v(this,"bind");v(this,"inBackOff");this.consumer=s;const u=a;this.opts=this.parseOptions(a,o),this.callback=u.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=ms(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=u.abort_on_missing_resource===!0,this.bind=u.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:a,idle_heartbeat:o,threshold_bytes:u,threshold_messages:d}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:m}=this;m&&m.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,y)=>{var _,N,R,M;if(g){this.stop(g);return}if((_=this.monitor)==null||_.work(),y.subject===this.inbox){if(Df(y))return;const D=(N=y.headers)==null?void 0:N.code,G=((M=(R=y.headers)==null?void 0:R.description)==null?void 0:M.toLowerCase())||"unknown",{msgsLeft:te,bytesLeft:$}=this.parseDiscard(y.headers);if(te>0||$>0)this.pending.msgs-=te,this.pending.bytes-=$,this.pending.requests--,this.notify(Nr.Discard,{msgsLeft:te,bytesLeft:$});else if(D===400){this.stop(new he(G,`${D}`));return}else if(D===409&&G==="consumer deleted"){if(this.notify($n.ConsumerDeleted,`${D} ${G}`),!this.refilling||this.abortOnMissingResource){const ce=new he(G,`${D}`);this.stop(ce);return}}else if(D===503){if(this.notify($n.NoResponders,`${D} No Responders`),!this.refilling||this.abortOnMissingResource){const ce=new he("no responders",`${D}`);this.stop(ce);return}}else this.notify(Nr.DebugEvent,`${D} ${G}`)}else this._push(Ja(y,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=y.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=d||a&&this.pending.bytes<=u){const D=this.pullOptions();this.pull(D)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new ch(o,g=>(this.notify($n.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var y;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const E of g)switch(E.type){case ds.Disconnect:(y=this.monitor)==null||y.cancel();break;case ds.Reconnect:this.resetPending().then(_=>{var N;_&&((N=this.monitor)==null||N.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const a=typeof s=="function"?s:null;try{a?a():this.callback(s)}catch(o){this.stop(o)}}}notify(s,a){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:a})})}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,a=0;const o=ah([this.opts.expires]);let u=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(a++,this.notify($n.StreamNotFound,a),!this.refilling||this.abortOnMissingResource)return this.stop(d),!1}else if(d.message==="consumer not found"){if(s++,this.notify($n.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,a=0;this.inBackOff=!0;const m=o.backoff(u),g=Rr(m);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),u++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const a=this.consumer.api.nc;this._push(()=>{a.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(Nr.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,a=this.opts.max_bytes-this.pending.bytes,o=nt(this.opts.idle_heartbeat),u=nt(this.opts.expires);return{batch:s,max_bytes:a,idle_heartbeat:o,expires:u}}parseDiscard(s){const a={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Bt.PendingMessagesHdr);o&&(a.msgsLeft=parseInt(o));const u=s==null?void 0:s.get(Bt.PendingBytesHdr);return u&&(a.bytesLeft=parseInt(u)),a}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,a;(s=this.monitor)==null||s.cancel(),this.monitor=null,(a=this.timeout)==null||a.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var a,o;this.done||((a=this.sub)==null||a.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(u=>{u.stop()})}))}parseOptions(s,a=!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,a){const u=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||u;const d=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||d}return o}status(){const s=new St;return this.listeners.push(s),Promise.resolve(s)}}class S_ extends St{constructor(){super();v(this,"src");v(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(a=>{this.stop(a||void 0)}),(async()=>{const a=await this.src.status();for await(const o of a)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,a){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:a})})}stop(s){var a;this.done||((a=this.src)==null||a.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 St;return this.listeners.push(s),Promise.resolve(s)}}class Yf{constructor(t,s){v(this,"api");v(this,"_info");v(this,"stream");v(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 xf(this,t,!0))}fetch(t={max_messages:100,expires:3e4}){const s=new xf(this,t,!1),a=Math.round(s.opts.expires*1.05),o=kr(a);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(t={expires:3e4}){const s=st(),a=t;a.max_messages=1;const o=new xf(this,a,!1),u=Math.round(o.opts.expires*1.05);u>=6e4&&(async()=>{for await(const m of await o.status())if(m.type===$n.HeartbeatsMissed&&m.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const m of o){s.resolve(m);break}})().catch(()=>{});const d=kr(u);return o.closed().then(m=>{m?s.reject(m):s.resolve(null)}).catch(m=>{s.reject(m)}).finally(()=>{d.cancel()}),d.catch(m=>{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:a}=this._info;return this.api.info(s,a).then(o=>(this._info=o,this._info))}}class E_{constructor(t,s,a={}){v(this,"api");v(this,"consumerOpts");v(this,"consumer");v(this,"opts");v(this,"cursor");v(this,"stream");v(this,"namePrefix");v(this,"serial");v(this,"currentConsumer");v(this,"userCallback");v(this,"iter");v(this,"type");v(this,"startSeq");v(this,"maxInitialReset");this.api=t,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=ei.next(),typeof a.name_prefix=="string"&&(Jo("name_prefix",a.name_prefix),this.namePrefix=a.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=vn.Unset,this.consumerOpts=a,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 a={name:s,deliver_policy:ft.StartSequence,opt_start_seq:t,ack_policy:wt.None,inactive_threshold:nt(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(a.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(a.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(a.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(a.replay_policy=this.consumerOpts.replay_policy),t===this.startSeq+1&&(a.deliver_policy=this.consumerOpts.deliver_policy||ft.StartSequence,(this.consumerOpts.deliver_policy===ft.LastPerSubject||this.consumerOpts.deliver_policy===ft.New||this.consumerOpts.deliver_policy===ft.Last)&&(delete a.opt_start_seq,a.deliver_policy=this.consumerOpts.deliver_policy),a.deliver_policy===ft.LastPerSubject&&typeof a.filter_subjects>"u"&&typeof a.filter_subject>"u"&&(a.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete a.opt_start_seq,a.deliver_policy=ft.StartTime,a.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(a.inactive_threshold=nt(this.consumerOpts.inactive_threshold))),a}async resetConsumer(t=0){var d,m,g,y,E;ei.next();const s=this.serial===0;(d=this.consumer)==null||d.delete().catch(()=>{}),t=t===0?1:t,this.cursor.deliver_seq=0;const a=this.getConsumerOpts(t);a.max_deliver=1,a.mem_storage=!0;const o=ah([((m=this.opts)==null?void 0:m.expires)||3e4]);let u;for(let _=0;;_++)try{u=await this.api.add(this.stream,a),(g=this.iter)==null||g.notify($n.OrderedConsumerRecreated,u.name);break}catch(N){if(N.message==="stream not found"&&((y=this.iter)==null||y.notify($n.StreamNotFound,_),this.type===vn.Fetch||this.opts.abort_on_missing_resource===!0))return(E=this.iter)==null||E.stop(N),Promise.reject(N);if(s&&_>=this.maxInitialReset)throw N;await Rr(o.backoff(_+1))}return u}internalHandler(t){return s=>{var o;if(this.serial!==t)return;const a=s.info.deliverySequence;if(a!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=a,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,y;s=s||{};const a=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===vn.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((y=this.iter)==null?void 0:y.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||a)&&(this.iter=new S_),this.consumer=new Yf(this.api,this.currentConsumer);const u=t;u.callback=this.internalHandler(this.serial);let d=null;this.type===vn.Fetch&&a?d=await this.consumer.fetch(t):this.type===vn.Consume&&(d=await this.consumer.consume(t));const m=d;m.forOrderedConsumer=!0,m.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(m)}notifyOrderedResetAndReset(){var t;(t=this.iter)==null||t.notify(Nr.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===vn.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===vn.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:a}=t;return a&&(this.userCallback=a),this.type=vn.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===vn.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:a}=t;return a&&(this.userCallback=a),this.type=vn.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 a=st();return s.callback=u=>{this.userCallback=null,a.resolve(u)},(await this.fetch(s)).iterClosed.then(u=>{u&&a.reject(u),a.resolve(null)}).catch(u=>{a.reject(u)}),a}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 Gf{constructor(t){v(this,"api");v(this,"notified");this.api=t,this.notified=!1}checkVersion(){const t=this.api.nc.features.get(Le.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 Yf(this.api,t)}async get(t,s={}){return typeof s=="object"?this.ordered(t,s):(await this.checkVersion(),this.api.info(t,s).then(a=>a.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Yf(this.api,a)).catch(a=>Promise.reject(a)))}async ordered(t,s){await this.checkVersion();const a=this.api;return new fh(a.nc,a.opts).info(t).then(u=>Promise.resolve(new E_(this.api,t,s))).catch(u=>Promise.reject(u))}}class Ko{constructor(t,s){v(this,"api");v(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 Ko(this.api,t)}else return this}info(t=!1,s){return t?Promise.resolve(this._info):this.api.info(this.name,s).then(a=>(this._info=a,this._info))}getConsumerFromInfo(t){return new Gf(new Lo(this.api.nc,this.api.opts)).getPullConsumerFor(t)}getConsumer(t){return new Gf(new Lo(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 fh extends Ka{constructor(t,s){super(t,s)}checkStreamConfigVersions(t){const s=this.nc;if(t.metadata){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_CONSUMER_METADATA);if(!u)throw new Error(`stream 'metadata' requires server ${o}`)}if(t.first_seq){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_FIRST_SEQ);if(!u)throw new Error(`stream 'first_seq' requires server ${o}`)}if(t.subject_transform){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_SUBJECT_TRANSFORM);if(!u)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(t.compression){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_COMPRESSION);if(!u)throw new Error(`stream 'compression' requires server ${o}`)}if(t.consumer_limits){const{min:o,ok:u}=s.features.get(Le.JS_DEFAULT_CONSUMER_LIMITS);if(!u)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function a(o,u){var m;if((((m=u==null?void 0:u.subject_transforms)==null?void 0:m.length)||0)>0){const{min:g,ok:y}=s.features.get(Le.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!y)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}t.sources&&t.sources.forEach(o=>{a("stream sources",o)}),t.mirror&&a("stream mirror",t.mirror)}async add(t={}){var o;this.checkStreamConfigVersions(t),zt(t.name),t.mirror=Eo(t.mirror),t.sources=(o=t.sources)==null?void 0:o.map(Eo);const a=await this._request(`${this.prefix}.STREAM.CREATE.${t.name}`,t);return this._fixInfo(a),a}async delete(t){return zt(t),(await this._request(`${this.prefix}.STREAM.DELETE.${t}`)).success}async update(t,s={}){var m;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),zt(t);const a=await this.info(t),o=Object.assign(a.config,s);o.mirror=Eo(o.mirror),o.sources=(m=o.sources)==null?void 0:m.map(Eo);const d=await this._request(`${this.prefix}.STREAM.UPDATE.${t}`,o);return this._fixInfo(d),d}async info(t,s){zt(t);const a=`${this.prefix}.STREAM.INFO.${t}`;let u=await this._request(a,s),{total:d,limit:m}=u,g=u.state.subjects?Object.getOwnPropertyNames(u.state.subjects).length:1;if(d&&d>g){const y=[u],E=s||{};let _=0;for(;d>g;){_++,E.offset=m*_;const R=await this._request(a,E);d=R.total,y.push(R);const M=Object.getOwnPropertyNames(R.state.subjects).length;if(g+=M,M<m)break}let N={};for(let R=0;R<y.length;R++)u=y[R],u.state.subjects&&(N=Object.assign(N,u.state.subjects));u.offset=0,u.total=0,u.limit=0,u.state.subjects=N}return this._fixInfo(u),u}list(t=""){const s=t!=null&&t.length?{subject:t}:{},a=u=>{const d=u;return d.streams.forEach(m=>{this._fixInfo(m)}),d.streams},o=`${this.prefix}.STREAM.LIST`;return new Ba(o,a,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:u}=s;if(typeof o=="number"&&typeof u=="number")throw new Error("can specify one of keep or seq")}return zt(t),await this._request(`${this.prefix}.STREAM.PURGE.${t}`,s)}async deleteMessage(t,s,a=!0){zt(t);const o={seq:s};return a||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${t}`,o)).success}async getMessage(t,s){zt(t);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${t}`,s);return new Qg(o)}find(t){return this.findStream(t)}listKvs(){const t=a=>{var g;const u=a.streams.filter(y=>y.config.name.startsWith(nn));u.forEach(y=>{this._fixInfo(y)});let d="";return u.length&&(d=((g=this.nc.info)==null?void 0:g.cluster)??""),u.map(y=>new Jg(y,d))},s=`${this.prefix}.STREAM.LIST`;return new Ba(s,t,this)}listObjectStores(){const t=a=>{const u=a.streams.filter(m=>m.config.name.startsWith(uh));return u.forEach(m=>{this._fixInfo(m)}),u.map(m=>new $f(m))},s=`${this.prefix}.STREAM.LIST`;return new Ba(s,t,this)}names(t=""){const s=t!=null&&t.length?{subject:t}:{},a=u=>u.streams,o=`${this.prefix}.STREAM.NAMES`;return new Ba(o,a,this,s)}async get(t){const s=await this.info(t);return Promise.resolve(new Ko(this,s))}}class j_ extends Ka{constructor(t,s){super(t,s)}async getMessage(t,s){zt(t);let a=s;const{last_by_subj:o}=a;o&&(a=null);const u=a?this.jc.encode(a):an,d=this.opts.apiPrefix||"$JS.API",m=o?`${d}.DIRECT.GET.${t}.${o}`:`${d}.DIRECT.GET.${t}`,g=await this.nc.request(m,u,{timeout:this.timeout}),y=Ar(g);if(y)return Promise.reject(y);const E=new Vf(g);return Promise.resolve(E)}async getBatch(t,s){zt(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 u=JSON.stringify(s,(g,y)=>g==="up_to_time"&&y instanceof Date?y.toISOString():y),d=new St,m=await this.nc.requestMany(o,u,{strategy:Mn.SentinelMsg});return(async()=>{var _,N,R;let g=!1,y=!1,E;for await(const M of m){if(!g){g=!0;const D=((_=M.headers)==null?void 0:_.code)||0;if(D!==0&&D<200||D>299){E=(N=M.headers)==null?void 0:N.description.toLowerCase();break}if(((R=M.headers)==null?void 0:R.get("Nats-Num-Pending"))===""){y=!0;break}}if(M.data.length===0)break;d.push(new Vf(M))}d.push(()=>{if(y)throw new Error("batch direct get not supported by the server");if(E)throw new Error(`bad request: ${E}`);d.stop()})})(),Promise.resolve(d)}}class Vf{constructor(t){v(this,"data");v(this,"header");if(!t.headers)throw new Error("headers expected");this.data=t.data,this.header=t.headers}get subject(){return this.header.last(wr.Subject)}get seq(){const t=this.header.last(wr.Sequence);return typeof t=="string"?parseInt(t):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(wr.TimeStamp)}get stream(){return this.header.last(wr.Stream)}json(t){return Rn(t).decode(this.data)}string(){return sn.decode(this.data)}}v(Vf,"jc");class A_ extends Ka{constructor(s,a){super(s,a);v(this,"streams");v(this,"consumers");v(this,"direct");this.streams=new fh(s,a),this.consumers=new Lo(s,a),this.direct=new j_(s,a)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new St;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(a,o)=>{if(a)throw a;try{const u=this.parseJsResponse(o),d=u.type.split("."),m=d[d.length-1];s.push({kind:m,data:u})}catch(u){s.stop(u)}}}),s}}class Qg{constructor(t){v(this,"_header");v(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):an}get header(){if(!this._header)if(this.smr.message.hdrs){const t=this._parse(this.smr.message.hdrs);this._header=Xs.decode(t)}else this._header=ps();return this._header}_parse(t){const s=atob(t),a=s.length,o=new Uint8Array(a);for(let u=0;u<a;u++)o[u]=s.charCodeAt(u);return o}json(t){return Rn(t).decode(this.data)}string(){return sn.decode(this.data)}}v(Qg,"jc");class O_{constructor(t){v(this,"api");this.api=t}get(t){return this.api.info(t).then(s=>new Ko(this.api,s))}}class vf{constructor(t){v(this,"info");v(this,"hdrs");this.info=t}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=Xs.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 F0(i){const t={name:i.name,description:i.description??"",options:i.options,metadata:i.metadata};if(i.headers){const s=i.headers;t.headers=s.toRecord()}return t}function N_(){return new ReadableStream({pull(i){i.enqueue(new Uint8Array(0)),i.close()}})}class Ya{constructor(t,s,a){v(this,"jsm");v(this,"js");v(this,"stream");v(this,"name");this.name=t,this.jsm=s,this.js=a}_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 vf(s):null}async list(){const t=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const a of s){if(a===null)break;t.push(a)}return Promise.resolve(t)}async rawInfo(t){const{name:s,error:a}=this._checkNotEmpty(t);if(a)return Promise.reject(a);const o=this._metaSubject(s);try{const u=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),m=Rn().decode(u.data);return m.revision=u.seq,m}catch(u){return u.code==="404"?null:Promise.reject(u)}}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 $f(t)))}async status(t){const s=await this._si(t);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new $f(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(t,s,a){var oe;const o=this.js.getOptions();a=a||{timeout:o.timeout},a.timeout=a.timeout||o.timeout,a.previousRevision=a.previousRevision??void 0;const{timeout:u,previousRevision:d}=a,m=this.js.nc.info,g=(m==null?void 0:m.max_payload)||1024;t=t||{},t.options=t.options||{};let y=((oe=t.options)==null?void 0:oe.max_chunk_size)||128*1024;y=y>g?g:y,t.options.max_chunk_size=y;const E=await this.info(t.name),{name:_,error:N}=this._checkNotEmpty(t.name);if(N)return Promise.reject(N);const R=ei.next(),M=this._chunkSubject(R),D=this._metaSubject(_),G=Object.assign({bucket:this.name,nuid:R,size:0,chunks:0},F0(t)),te=st(),$=[],ce=new Mr;try{const O=s?s.getReader():null,J=z0.create();for(;;){const{done:ae,value:I}=O?await O.read():{done:!0,value:void 0};if(ae){if(ce.size()>0){const ie=ce.drain();J.update(ie),G.chunks++,G.size+=ie.length,$.push(this.js.publish(M,ie,{timeout:u}))}await Promise.all($),$.length=0,G.mtime=new Date().toISOString();const F=Or.encode(J.digest());G.digest=`${V0}${F}`,G.deleted=!1;const Z=ps();typeof d=="number"&&Z.set(Hn.ExpectedLastSubjectSequenceHdr,`${d}`),Z.set(Bt.RollupHdr,Bt.RollupValueSubject);const re=await this.js.publish(D,Rn().encode(G),{headers:Z,timeout:u});if(G.revision=re.seq,E)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${E.nuid}`})}catch{}te.resolve(new vf(G));break}if(I)for(ce.fill(I);ce.size()>y;){G.chunks++,G.size+=y;const F=ce.drain(t.options.max_chunk_size);J.update(F),$.push(this.js.publish(M,F,{timeout:u}))}}}catch(O){await this.jsm.streams.purge(this.stream,{filter:M}),te.reject(O)}return te}putBlob(t,s,a){function o(u){return new ReadableStream({pull(d){d.enqueue(u),d.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(t,o(s),a)}put(t,s,a){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,a)}async getBlob(t){async function s(u){const d=new Mr,m=u.getReader();for(;;){const{done:g,value:y}=await m.read();if(g)return d.drain();y&&y.length&&d.fill(y)}}const a=await this.get(t);if(a===null)return Promise.resolve(null);const o=await Promise.all([a.error,s(a.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 _=s.options.link.name||"";if(_==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await Ya.create(this.js,s.options.link.bucket):this).get(_)}if(!s.digest.startsWith(V0))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const a=Uf(s.digest.substring(8));if(a===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=st(),u={info:new vf(s),error:o};if(s.size===0)return u.data=N_(),o.resolve(null),Promise.resolve(u);let d;const m=Zs();m.orderedConsumer();const g=z0.create(),y=`$O.${this.name}.C.${s.nuid}`,E=await this.js.subscribe(y,m);return(async()=>{for await(const _ of E)_.data.length>0&&(g.update(_.data),d.enqueue(_.data)),_.info.pending===0&&(g1(a,g.digest())?d.close():d.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${a}`)),E.unsubscribe())})().then(()=>{o.resolve()}).catch(_=>{d.error(_),o.reject(_)}),u.data=new ReadableStream({start(_){d=_},cancel(){E.unsubscribe()}}),u}linkStore(t,s){if(!(s instanceof Ya))return Promise.reject("bucket required");const a=s,{name:o,error:u}=this._checkNotEmpty(t);if(u)return Promise.reject(u);const d={name:o,options:{link:{bucket:a.name}}};return this._put(d,null)}async link(t,s){const{name:a,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 u=await this.rawInfo(t);if(u!==null&&!u.deleted)return Promise.reject(new Error("an object already exists with that name"));const d={bucket:s.bucket,name:s.name},m={name:a,bucket:s.bucket,options:{link:d}};await this.js.publish(this._metaSubject(t),JSON.stringify(m));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 a=Rn(),o=ps();return o.set(Bt.RollupHdr,Bt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),a.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(t,s={}){const a=await this.rawInfo(t);if(a===null)return Promise.reject(new Error("object not found"));if(a.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??a.name;const{name:o,error:u}=this._checkNotEmpty(s.name);if(u)return Promise.reject(u);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({},a,F0(s)),m=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(m)}async watch(t={}){t.includeHistory=t.includeHistory??!1,t.ignoreDeletes=t.ignoreDeletes??!1;let s=!1;const a=new St,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(a.push(null),s=!0):a.stop(g)}const u=Rn(),d=Zs();d.orderedConsumer(),t.includeHistory?d.deliverLastPerSubject():(s=!0,d.deliverNew()),d.callback((g,y)=>{var E;if(g){a.stop(g);return}if(y!==null){const _=u.decode(y.data);_.deleted&&t.ignoreDeletes===!0||a.push(_),((E=y.info)==null?void 0:E.pending)===0&&!s&&(s=!0,a.push(null))}});const m=await this.js.subscribe(o,d);return a._data=m,a.iterClosed.then(()=>{m.unsubscribe()}),m.closed.then(()=>{a.stop()}).catch(g=>{a.stop(g)}),a}_chunkSubject(t){return`$O.${this.name}.C.${t}`}_metaSubject(t){return`$O.${this.name}.M.${Or.encode(t)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(t={}){try{this.stream=y_(this.name)}catch(o){return Promise.reject(o)}const s=(t==null?void 0:t.ttl)||0;delete t.ttl;const a=Object.assign({max_age:s},t);a.name=this.stream,a.num_replicas=t.replicas??1,a.allow_direct=!0,a.allow_rollup_hdrs=!0,a.discard=Va.New,a.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],t.placement&&(a.placement=t.placement),t.metadata&&(a.metadata=t.metadata),typeof t.compression=="boolean"&&(a.compression=t.compression?ti.S2:ti.None);try{await this.jsm.streams.info(a.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(a)}}static async create(t,s,a={}){const o=await t.jetstreamManager(),u=new Ya(s,o,t);return await u.init(a),Promise.resolve(u)}}class T_{constructor(t){v(this,"js");this.js=t}kv(t,s={}){const a=this.js,{ok:o,min:u}=a.nc.features.get(Le.JS_KV);return o?s.bindOnly?Fa.bind(this.js,t,s):Fa.create(this.js,t,s):Promise.reject(new Error(`kv is only supported on servers ${u} 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 a=this.js,{ok:o,min:u}=a.nc.features.get(Le.JS_OBJECTSTORE);return o?Ya.create(this.js,t,s):Promise.reject(new Error(`objectstore is only supported on servers ${u} or better`))}}class hh extends Ka{constructor(s,a){super(s,a);v(this,"consumers");v(this,"streams");v(this,"consumerAPI");v(this,"streamAPI");this.consumerAPI=new Lo(s,a),this.streamAPI=new fh(s,a),this.consumers=new Gf(this.consumerAPI),this.streams=new O_(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const a=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(a)}get apiPrefix(){return this.prefix}get views(){return new T_(this)}async publish(s,a=an,o){o=o||{},o.expect=o.expect||{};const u=(o==null?void 0:o.headers)||ps();o&&(o.msgID&&u.set(Hn.MsgIdHdr,o.msgID),o.expect.lastMsgID&&u.set(Hn.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&u.set(Hn.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&u.set(Hn.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&u.set(Hn.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const d=o.timeout||this.timeout,m={};d&&(m.timeout=d),o&&(m.headers=u);let{retries:g,retry_delay:y}=o;g=g||1,y=y||250;let E;for(let N=0;N<g;N++)try{E=await this.nc.request(s,a,m);break}catch(R){if(R.code==="503"&&N+1<g)await Rr(y);else throw R}const _=this.parseJsResponse(E);if(_.stream==="")throw he.errorForCode(le.JetStreamInvalidAck);return _.duplicate=_.duplicate?_.duplicate:!1,_}async pull(s,a,o=0){zt(s),jr(a);let u=this.timeout;o>u&&(u=o),o=o<0?0:nt(o);const d={batch:1,no_wait:o===0,expires:o},m=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${a}`,this.jc.encode(d),{noMux:!0,timeout:u}),g=Ar(m);if(g)throw g;return Ja(m,this.timeout)}fetch(s,a,o={}){zt(s),jr(a);let u=null;const d=(o.max_bytes??0)>0;let m=0;const g=d?o.max_bytes:0;let y=null;const E={};if(E.batch=o.batch||1,g){const $=this.nc.features.get(Le.JS_PULL_MAX_BYTES);if(!$.ok)throw new Error(`max_bytes is only supported on servers ${$.min} or better`);E.max_bytes=g}E.no_wait=o.no_wait||!1,E.no_wait&&E.expires&&(E.expires=0);const _=o.expires||0;if(_&&(E.expires=nt(_)),_===0&&E.no_wait===!1)throw new Error("expires or no_wait is required");const N=o.idle_heartbeat||0;N&&(E.idle_heartbeat=nt(N),o.delay_heartbeat===!0&&(E.idle_heartbeat=nt(N*4)));const R=new St,M=E.batch;let D=0;R.protocolFilterFn=($,ce=!1)=>Df($.msg)?(y==null||y.work(),!1):!0,R.dispatchedFn=$=>{if($){if(d&&(m+=$.data.length),D++,u&&$.info.pending===0)return;(R.getPending()===1&&$.info.pending===0||M===D||g>0&&m>=g)&&R.stop()}};const G=ms(this.nc.options.inboxPrefix),te=this.nc.subscribe(G,{max:o.batch,callback:($,ce)=>{$===null&&($=Ar(ce)),$!==null?(u&&(u.cancel(),u=null),Xv($)?R.stop(Xg($)===null?void 0:$):R.stop($)):(y==null||y.work(),R.received++,R.push(Ja(ce,this.timeout)))}});return _&&(u=kr(_),u.catch(()=>{te.isClosed()||(te.drain().catch(()=>{}),u=null),y&&y.cancel()})),(async()=>{try{N&&(y=new ch(N,$=>(R.push(()=>{R.err=new he(`${_n.IdleHeartbeatMissed}: ${$}`,le.JetStreamIdleHeartBeat)}),!0)))}catch{}await te.closed,u!==null&&(u.cancel(),u=null),y&&y.cancel(),R.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${a}`,this.jc.encode(E),{reply:G}),R}async pullSubscribe(s,a=Zs()){const o=await this._processOptions(s,a);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 u=o.config.ack_policy;if(u===wt.None||u===wt.All)throw new Error("ack policy for pull consumers must be explicit");const d=this._buildTypedSubscriptionOpts(o),m=new R_(this,o.deliver,d);m.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw m.unsubscribe(),g}return m}async subscribe(s,a=Zs()){const o=await this._processOptions(s,a);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const u=this._buildTypedSubscriptionOpts(o),d=new Kg(this,o.deliver,u);d.info=o;try{await this._maybeCreateConsumer(o)}catch(m){throw d.unsubscribe(),m}return d._maybeSetupHbMonitoring(),d}async _processOptions(s,a=Zs()){const o=M0(a)?a.getOpts():a;if(o.isBind=M0(a)?a.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!==wt.NotSet&&o.config.ack_policy!==wt.None)throw new he("ordered consumer: ack_policy can only be set to 'none'",le.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new he("ordered consumer: durable_name cannot be set",le.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new he("ordered consumer: deliver_subject cannot be set",le.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new he("ordered consumer: max_deliver cannot be set",le.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new he("ordered consumer: deliver_group cannot be set",le.ApiError);o.config.deliver_subject=ms(this.nc.options.inboxPrefix),o.config.ack_policy=wt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||nt(5e3),o.config.ack_wait=nt(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===wt.NotSet&&(o.config.ack_policy=wt.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 u=await this.consumerAPI.info(o.stream,o.config.durable_name);if(u){if(u.config.filter_subject&&u.config.filter_subject!==s)throw new Error("subject does not match consumer");const d=o.config.deliver_group??"";if(d===""&&u.push_bound===!0)throw new Error("duplicate subscription");const m=u.config.deliver_group??"";if(d!==m)throw m===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${m}'`);o.last=u,o.config=u.config,o.attached=!0,o.config.durable_name||(o.name=u.name)}}catch(u){if(u.code!=="404")throw u}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||ms(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const a={};return a.adapter=D_(s.callbackFn===void 0,this.timeout),a.ingestionFilterFn=hh.ingestionFn(s.ordered),a.protocolFilterFn=(o,u=!1)=>{const d=o;return Rf(d.msg)?(u||d.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==wt.None&&(a.dispatchedFn=U_),s.callbackFn&&(a.callback=s.callbackFn),a.max=s.max||0,a.queue=s.queue,a}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:ft.All,ack_policy:wt.Explicit,ack_wait:nt(30*1e3),replay_policy:Cr.Instant},s.config);const a=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(a.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=a.name,s.config=a.config,s.last=a}static ingestionFn(s){return(a,o)=>{var g;const u=o;if(!a)return{ingest:!1,protocol:!1};const d=a;if(Ar(d.msg)||(g=u.monitor)==null||g.work(),Df(d.msg)){const y=s?u._checkHbOrderConsumer(d.msg):!0;return s||u.info.flow_control.heartbeat_count++,{ingest:y,protocol:!0}}else if(Rf(d.msg))return u.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?u._checkOrderedConsumer(a):!0,protocol:!1}}}}class dh{constructor(t){v(this,"options");v(this,"protocol");v(this,"draining");v(this,"listeners");v(this,"_services");this.draining=!1,this.options=Z1(t),this.listeners=[]}static connect(t={}){return new Promise((s,a)=>{const o=new dh(t);Ho.connect(o.options,o).then(u=>{o.protocol=u,(async function(){for await(const d of u.status())o.listeners.forEach(m=>{m.push(d)})})(),s(o)}).catch(u=>{a(u)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(t,s,a){if(this.isClosed())throw he.errorForCode(le.ConnectionClosed);if(s&&this.isDraining()||a&&this.protocol.noMorePublishing)throw he.errorForCode(le.ConnectionDraining);if(t=t||"",t.length===0)throw he.errorForCode(le.BadSubject)}publish(t,s,a){this._check(t,!1,!0),this.protocol.publish(t,s,a)}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 a=new Ig(this.protocol,t,s);return this.protocol.subscribe(a),a}_resub(t,s,a){this._check(s,!0,!1);const o=t;o.max=a,a&&(o.max=a+o.received),this.protocol.resub(o,s)}requestMany(t,s=an,a={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(t,!0,!0)}catch(g){return Promise.reject(g)}if(a.strategy=a.strategy||Mn.Timer,a.maxWait=a.maxWait||1e3,a.maxWait<1)return Promise.reject(new he("timeout",le.InvalidOption));const u=new St;function d(g){u.push(()=>{u.stop(g)})}function m(g,y){g||y===null?d(g===null?void 0:g):u.push(y)}if(a.noMux){const g=o?new Error().stack:null;let y=typeof a.maxMessages=="number"&&a.maxMessages>0?a.maxMessages:-1;const E=this.subscribe(ms(this.options.inboxPrefix),{callback:(M,D)=>{var G,te;if(((G=D==null?void 0:D.data)==null?void 0:G.length)===0&&((te=D==null?void 0:D.headers)==null?void 0:te.status)===le.NoResponders&&(M=he.errorForCode(le.NoResponders)),M){g&&(M.stack+=`
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=st()),this.pongs.push(t),this.outbound.fill(G0),this.flushPending(),t}sendSubscriptions(){const t=[];this.subscriptions.all().forEach(s=>{const a=s;a.queue?t.push(`SUB ${a.subject} ${a.queue} ${a.sid}${To}`):t.push(`SUB ${a.subject} ${a.sid}${To}`)}),t.length&&this.transport.send(La(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(a=>{s.push(a.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),a=new Kg(this,`${s}*`);a.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(a),this.subscribe(a)}}selectServer(){const t=this.servers.selectServer();if(t!==void 0)return this.server=t,this.server}getServer(){return this.server}}const o_="$SRV";class V0{constructor(t){v(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,a,o){var u,d;return o=o||{},o.headers=o.headers||ps(),(u=o.headers)==null||u.set(zo,`${t}`),(d=o.headers)==null||d.set(qo,s),this.msg.respond(a,o)}json(t){return this.msg.json(t)}string(){return this.msg.string()}}class Va{constructor(t,s="",a=""){v(this,"subject");v(this,"queue");v(this,"srv");s!==""&&u_("service group",s);let o="";if(t instanceof Ka)this.srv=t,o="";else if(t instanceof Va){const u=t;this.srv=u.srv,a===""&&u.queue!==""&&(a=u.queue),o=u.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=a}calcSubject(t,s=""){return s===""?t:t!==""?`${t}.${s}`:s}addEndpoint(t="",s){s=s||{subject:t};const a=typeof s=="function"?{handler:s,subject:t}:s;za("endpoint",t);let{subject:o,handler:u,metadata:d,queue:m}=a;o=o||t,m=m||this.queue,c_("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:t,subject:o,queue:m,handler:u,metadata:d};return this.srv._addEndpoint(g)}addGroup(t="",s=""){return new Va(this,t,s)}}function c_(i,t){if(t==="")throw new Error(`${i} cannot be empty`);if(t.indexOf(" ")!==-1)throw new Error(`${i} cannot contain spaces: '${t}'`);const s=t.split(".");s.forEach((a,o)=>{if(a===">"&&o!==s.length-1)throw new Error(`${i} cannot have internal '>': '${t}'`)})}function u_(i,t){if(t.indexOf(" ")!==-1)throw new Error(`${i} cannot contain spaces: '${t}'`);t.split(".").forEach(a=>{if(a===">")throw new Error(`${i} name cannot contain internal '>': '${t}'`)})}class Ka{constructor(t,s={name:"",version:""}){v(this,"nc");v(this,"_id");v(this,"config");v(this,"handlers");v(this,"internal");v(this,"_stopped");v(this,"_done");v(this,"started");this.nc=t,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),za("name",this.config.name),za("queue",this.config.queue),Ci(this.config.version),this._id=ti.next(),this.internal=[],this._done=st(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(a=>{this.close(a).catch()})}static controlSubject(t,s="",a="",o){const u=o??o_;return s===""&&a===""?`${u}.${t}`:(za("control subject name",s),a!==""?(za("control subject id",a),`${u}.${t}.${s}.${a}`):`${u}.${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=ps();if(t instanceof Uo){const a=t;s.set(qo,a.message),s.set(zo,`${a.code}`)}else s.set(qo,t.message),s.set(zo,"500");return s}setupHandler(t,s=!1){const a=s?"":t.queue?t.queue:this.config.queue,{name:o,subject:u,handler:d}=t,m=t;m.internal=s,s&&this.internal.push(m),m.stats=new f_(o,u,a),m.queue=a;const g=d?(y,E)=>{if(y){this.close(y);return}const _=Date.now();try{d(y,new V0(E))}catch(T){m.stats.countError(T),E==null||E.respond(an,{headers:this.errorToHeader(T)})}finally{m.stats.countLatency(_)}}:void 0;return m.sub=this.nc.subscribe(u,{callback:g,queue:a}),m.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${t.subject} stopped`)).catch()}).catch(y=>{if(!this._stopped){const E=new Error(`required subscription ${t.subject} errored: ${y.message}`);E.stack=y.stack,this.close(E).catch()}}),m}info(){return{type:Pa.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:a,name:o,queue:u}=t;return{subject:s,metadata:a,name:o,queue_group:u}})}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(a){s.stats.countError(a)}t.push(s.stats.stats(s.qi))}return{type:Pa.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:t}}addInternalHandler(t,s){const a=`${t}`.toUpperCase();this._doAddInternalHandler(`${a}-all`,t,s),this._doAddInternalHandler(`${a}-kind`,t,s,this.name),this._doAddInternalHandler(`${a}`,t,s,this.name,this.id)}_doAddInternalHandler(t,s,a,o="",u=""){const d={};d.name=t,d.subject=Ka.controlSubject(s,o,u),d.handler=a,this.setupHandler(d,!0)}start(){const t=Dn(),s=(d,m)=>d?(this.close(d),Promise.reject(d)):this.stats().then(g=>(m==null||m.respond(t.encode(g)),Promise.resolve())),a=(d,m)=>d?(this.close(d),Promise.reject(d)):(m==null||m.respond(t.encode(this.info())),Promise.resolve()),o=t.encode(this.ping()),u=(d,m)=>d?(this.close(d).then().catch(),Promise.reject(d)):(m.respond(o),Promise.resolve());return this.addInternalHandler(Ks.PING,u),this.addInternalHandler(Ks.STATS,s),this.addInternalHandler(Ks.INFO,a),this.handlers.forEach(d=>{const{subject:m}=d;typeof m=="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(a=>a.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:Pa.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 Va(this,t,s)}addEndpoint(t,s){return new Va(this).addEndpoint(t,s)}_addEndpoint(t){const s=new St;s.noIterator=typeof t.handler=="function",s.noIterator||(t.handler=(o,u)=>{o?this.stop(o).catch():s.push(new V0(u))},s.iterClosed.then(()=>{this.close().catch()}));const a=this.setupHandler(t,!1);return a.qi=s,this.handlers.push(a),s}}class f_{constructor(t,s,a=""){v(this,"name");v(this,"subject");v(this,"average_processing_time");v(this,"num_requests");v(this,"processing_time");v(this,"num_errors");v(this,"last_error");v(this,"data");v(this,"metadata");v(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=a}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+=nt(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:a,num_errors:o,num_requests:u,processing_time:d,last_error:m,data:g,queue:y}=this;return{name:t,subject:s,average_processing_time:a,num_errors:o,num_requests:u,processing_time:d,last_error:m,data:g,queue_group:y}}stats(t){const s=t;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=nt(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 h_{constructor(t,s={strategy:Rn.JitterTimer,maxWait:2e3},a){v(this,"nc");v(this,"prefix");v(this,"opts");this.nc=t,this.prefix=a,this.opts=s}ping(t="",s=""){return this.q(Ks.PING,t,s)}stats(t="",s=""){return this.q(Ks.STATS,t,s)}info(t="",s=""){return this.q(Ks.INFO,t,s)}async q(t,s="",a=""){const o=new St,u=Dn(),d=Ka.controlSubject(t,s,a,this.prefix),m=await this.nc.requestMany(d,an,this.opts);return(async()=>{for await(const g of m)try{const y=u.decode(g.data);o.push(y)}catch(y){o.push(()=>{o.stop(y)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function Xg(){return{key:{encode(i){return i},decode(i){return i}},value:{encode(i){return i},decode(i){return i}}}}function d_(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:Xg(),storage:Uf.File}}const $o="KV-Operation",I0="$KV",m_=/^[-/=.\w]+$/,p_=/^[-/=.>*\w]+$/,g_=/^[-\w]+$/;function y_(i){if(i.startsWith(".")||i.endsWith(".")||!m_.test(i))throw new Error(`invalid key: ${i}`)}function b_(i){if(i.startsWith(".")||i.endsWith(".")||!p_.test(i))throw new Error(`invalid key: ${i}`)}function x_(i){if(i.startsWith(".")||i.endsWith("."))throw new Error(`invalid key: ${i}`);const t=i.split(".");let s=!1;for(let a=0;a<t.length;a++)switch(t[a]){case"*":s=!0;break;case">":if(a!==t.length-1)throw new Error(`invalid key: ${i}`);s=!0;break}return s}function ko(i){if(!g_.test(i))throw new Error(`invalid bucket name: ${i}`)}var Hn;(function(i){i.MsgIdHdr="Nats-Msg-Id",i.ExpectedStreamHdr="Nats-Expected-Stream",i.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",i.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",i.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(Hn||(Hn={}));class Ia{constructor(t,s,a){v(this,"js");v(this,"jsm");v(this,"stream");v(this,"bucket");v(this,"direct");v(this,"codec");v(this,"prefix");v(this,"editPrefix");v(this,"useJsPrefix");v(this,"_prefixLen");v(this,"validateKey",y_);v(this,"validateSearchKey",b_);v(this,"hasWildcards",x_);ko(t),this.js=s,this.jsm=a,this.bucket=t,this.prefix=I0,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(t,s,a={}){ko(s);const o=await t.jetstreamManager(),u=new Ia(s,t,o);return await u.init(a),u}static async bind(t,s,a={}){const o=await t.jetstreamManager(),u={config:{allow_direct:a.allow_direct}};ko(s);const d=new Ia(s,t,o);return u.config.name=a.streamName??d.bucketName(),Object.assign(d,u),d.stream=u.config.name,d.codec=a.codec||Xg(),d.direct=u.config.allow_direct??!1,d.initializePrefixes(u),d}async init(t={}){const s=Object.assign(d_(),t);this.codec=s.codec;const a={};this.stream=a.name=t.streamName??this.bucketName(),a.retention=zf.Limits,a.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(a.max_bytes=s.max_bytes),a.max_msg_size=s.maxValueSize,a.storage=s.storage;const o=t.placementCluster??"";if(o&&(t.placement={},t.placement.cluster=o,t.placement.tags=[]),t.placement&&(a.placement=t.placement),t.republish&&(a.republish=t.republish),t.description&&(a.description=t.description),t.mirror){const _=Object.assign({},t.mirror);_.name.startsWith(nn)||(_.name=`${nn}${_.name}`),a.mirror=_,a.mirror_direct=!0}else if(t.sources){const _=t.sources.map(T=>{const R=Object.assign({},T),C=R.name.startsWith(nn)?R.name.substring(nn.length):R.name;return R.name.startsWith(nn)||(R.name=`${nn}${R.name}`),!T.external&&C!==this.bucket&&(R.subject_transforms=[{src:`$KV.${C}.>`,dest:`$KV.${this.bucket}.>`}]),R});a.sources=_,a.subjects=[this.subjectForBucket()]}else a.subjects=[this.subjectForBucket()];t.metadata&&(a.metadata=t.metadata),typeof t.compression=="boolean"&&(a.compression=t.compression?ni.S2:ni.None);const u=this.js.nc,d=u.getServerVersion(),m=d?Lf(d,Ci("2.7.2"))>=0:!1;a.discard=m?Ga.New:Ga.Old;const{ok:g,min:y}=u.features.get(Le.JS_ALLOW_DIRECT);if(!g&&t.allow_direct===!0){const _=d?`${d.major}.${d.minor}.${d.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${_} - requires ${y}`))}t.allow_direct=typeof t.allow_direct=="boolean"?t.allow_direct:g,a.allow_direct=t.allow_direct,this.direct=a.allow_direct,a.num_replicas=s.replicas,s.ttl&&(a.max_age=nt(s.ttl)),a.allow_rollup_hdrs=!0;let E;try{E=await this.jsm.streams.info(a.name),!E.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(_){if(_.message==="stream not found")E=await this.jsm.streams.add(a);else throw _}this.initializePrefixes(E)}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 a=s.name;if(a.startsWith(nn)&&(a=a.substring(nn.length)),s.external&&s.external.api!==""){const o=s.name.substring(nn.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${a}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${nn}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(t,s=!1){const a=[];return s?(this.useJsPrefix&&a.push(this.js.apiPrefix),this.editPrefix!==""?a.push(this.editPrefix):a.push(this.prefix)):this.prefix&&a.push(this.prefix),a.push(t),a.join(".")}fullKeyName(t){return this.prefix!==""?`${this.prefix}.${t}`:`${I0}.${this.bucket}.${t}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(t){const s=[];for(const a of t.split("."))switch(a){case">":case"*":s.push(a);break;default:s.push(this.codec.key.encode(a));break}return s.join(".")}decodeKey(t){const s=[];for(const a of t.split("."))switch(a){case">":case"*":s.push(a);break;default:s.push(this.codec.key.decode(a));break}return s.join(".")}close(){return Promise.resolve()}dataLen(t,s){const a=s&&s.get(Bt.MessageSizeHdr)||"";return a!==""?parseInt(a,10):t.length}smToEntry(t){return new D_(this.bucket,this.prefixLen,t)}jmToEntry(t){const s=this.decodeKey(t.subject.substring(this.prefixLen));return new q_(this.bucket,s,t)}async create(t,s){var u;let a;try{const d=await this.put(t,s,{previousSeq:0});return Promise.resolve(d)}catch(d){if(a=d,((u=d==null?void 0:d.api_error)==null?void 0:u.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(a)}catch(d){return Promise.reject(d)}}update(t,s,a){if(a<=0)throw new Error("version must be greater than 0");return this.put(t,s,{previousSeq:a})}async put(t,s,a={}){var d,m;const o=this.encodeKey(t);this.validateKey(o);const u={};if(a.previousSeq!==void 0){const g=ps();u.headers=g,g.set(Hn.ExpectedLastSubjectSequenceHdr,`${a.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,u)).seq}catch(g){const y=g;return y.isJetStreamError()?(y.message=(d=y.api_error)==null?void 0:d.description,y.code=`${(m=y.api_error)==null?void 0:m.code}`,Promise.reject(y)):Promise.reject(g)}}async get(t,s){const a=this.encodeKey(t);this.validateKey(a);let o={last_by_subj:this.subjectForKey(a)};s&&s.revision>0&&(o={seq:s.revision});let u;try{this.direct?u=await this.jsm.direct.getMessage(this.bucketName(),o):u=await this.jsm.streams.getMessage(this.bucketName(),o);const d=this.smToEntry(u);return d.key!==a?null:d}catch(d){if(d.code===le.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=st(),a=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&a.push(g)})().then(),await s,o.stop();const u=Date.now()-t,d=a.map(g=>{const y=this.subjectForKey(g.key);return g.created.getTime()>=u?this.jsm.streams.purge(this.stream,{filter:y,keep:1}):this.jsm.streams.purge(this.stream,{filter:y,keep:0})}),m=await Promise.all(d);return m.unshift({success:!0,purged:0}),m.reduce((g,y)=>(g.purged+=y.purged,g))}async _deleteOrPurge(t,s,a){if(!this.hasWildcards(t))return this._doDeleteOrPurge(t,s,a);const o=await this.keys(t),u=[];for await(const d of o)u.push(this._doDeleteOrPurge(d,s)),u.length===100&&(await Promise.all(u),u.length=0);u.length>0&&await Promise.all(u)}async _doDeleteOrPurge(t,s,a){const o=this.encodeKey(t);this.validateKey(o);const u=ps();u.set($o,s),s==="PURGE"&&u.set(Bt.RollupHdr,Bt.RollupValueSubject),a!=null&&a.previousSeq&&u.set(Hn.ExpectedLastSubjectSequenceHdr,`${a.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),an,{headers:u})}_buildCC(t,s,a={}){let u=(Array.isArray(t)?t:[t]).map(g=>{const y=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(y)}),d=ft.LastPerSubject;s===Cn.AllHistory&&(d=ft.All),s===Cn.UpdatesOnly&&(d=ft.New);let m;return u.length===1&&(m=u[0],u=void 0),Object.assign({deliver_policy:d,ack_policy:wt.None,filter_subjects:u,filter_subject:m,flow_control:!0,idle_heartbeat:nt(5*1e3)},a)}remove(t){return this.purge(t)}async history(t={}){const s=t.key??">",a=new St,o={};o.headers_only=t.headers_only||!1;let u;u=()=>{a.stop()};let d=0;const m=this._buildCC(s,Cn.AllHistory,o),g=m.filter_subject,y=Zs(m);y.bindStream(this.stream),y.orderedConsumer(),y.callback((_,T)=>{if(_){a.stop(_);return}if(T){const R=this.jmToEntry(T);a.push(R),a.received++,(u&&d>0&&a.received>=d||T.info.pending===0)&&(a.push(u),u=void 0)}});const E=await this.js.subscribe(g,y);if(u){const{info:{last:_}}=E,T=_.num_pending+_.delivered.consumer_seq;if(T===0||a.received>=T)try{u()}catch(R){a.stop(R)}finally{u=void 0}else d=T}return a._data=E,a.iterClosed.then(()=>{E.unsubscribe()}),E.closed.then(()=>{a.stop()}).catch(_=>{a.stop(_)}),a}canSetWatcherName(){const s=this.js.nc,{ok:a}=s.features.get(Le.JS_NEW_CONSUMER_CREATE_API);return a}async watch(t={}){const s=t.key??">",a=new St,o={};o.headers_only=t.headers_only||!1;let u=Cn.LastValue;t.include===Cn.AllHistory?u=Cn.AllHistory:t.include===Cn.UpdatesOnly&&(u=Cn.UpdatesOnly);const d=t.ignoreDeletes===!0;let m=t.initializedFn,g=0;const y=this._buildCC(s,u,o),E=y.filter_subject,_=Zs(y);this.canSetWatcherName()&&_.consumerName(ti.next()),_.bindStream(this.stream),t.resumeFromRevision&&t.resumeFromRevision>0&&_.startSequence(t.resumeFromRevision),_.orderedConsumer(),_.callback((R,C)=>{if(R){a.stop(R);return}if(C){const D=this.jmToEntry(C);if(d&&D.operation==="DEL")return;a.push(D),a.received++,m&&(g>0&&a.received>=g||C.info.pending===0)&&(a.push(m),m=void 0)}});const T=await this.js.subscribe(E,_);if(m){const{info:{last:R}}=T,C=R.num_pending+R.delivered.consumer_seq;if(C===0||a.received>=C)try{m()}catch(D){a.stop(D)}finally{m=void 0}else g=C}return a._data=T,a.iterClosed.then(()=>{T.unsubscribe()}),T.closed.then(()=>{a.stop()}).catch(R=>{a.stop(R)}),a}async keys(t=">"){const s=new St,a=this._buildCC(t,Cn.LastValue,{headers_only:!0}),o=Array.isArray(t)?">":a.filter_subject,u=Zs(a);u.bindStream(this.stream),u.orderedConsumer();const d=await this.js.subscribe(o,u);return(async()=>{var g;for await(const y of d){const E=(g=y.headers)==null?void 0:g.get($o);if(E!=="DEL"&&E!=="PURGE"){const _=this.decodeKey(y.subject.substring(this.prefixLen));s.push(_)}y.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 u;const s=((u=this.js.nc.info)==null?void 0:u.cluster)??"",a=this.bucketName(),o=await this.jsm.streams.info(a);return new Zg(o,s)}}class Zg{constructor(t,s=""){v(this,"si");v(this,"cluster");this.si=t,this.cluster=s}get bucket(){return this.si.config.name.startsWith(nn)?this.si.config.name.substring(nn.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 lh(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!==ni.None:!1}}const uh="OBJ_",F0="SHA-256=";function v_(i){return ko(i),`${uh}${i}`}function __(i){return i.startsWith(uh)?i.substring(4):i}class Yf{constructor(t){v(this,"si");v(this,"backingStore");this.si=t,this.backingStore="JetStream"}get bucket(){return __(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!==ni.None:!1}}function So(i){if(i===void 0)return;const{domain:t}=i;if(t===void 0)return i;const s=Object.assign({},i);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 _n;(function(i){i[i.Unset=-1]="Unset",i[i.Consume=0]="Consume",i[i.Fetch=1]="Fetch"})(_n||(_n={}));var $n;(function(i){i.HeartbeatsMissed="heartbeats_missed",i.ConsumerNotFound="consumer_not_found",i.StreamNotFound="stream_not_found",i.ConsumerDeleted="consumer_deleted",i.OrderedConsumerRecreated="ordered_consumer_recreated",i.NoResponders="no_responders"})($n||($n={}));var Nr;(function(i){i.DebugEvent="debug",i.Discard="discard",i.Reset="reset",i.Next="next"})(Nr||(Nr={}));const J0=Uint8Array.of(43,65,67,75),w_=Uint8Array.of(45,78,65,75),Ma=Uint8Array.of(43,87,80,73),S_=Uint8Array.of(43,78,88,84),E_=Uint8Array.of(43,84,69,82,77),j_=Uint8Array.of(32);function Fa(i,t=5e3){return new $_(i,t)}class vf extends St{constructor(s,a,o=!1){super();v(this,"consumer");v(this,"opts");v(this,"sub");v(this,"monitor");v(this,"pending");v(this,"inbox");v(this,"refilling");v(this,"pong");v(this,"callback");v(this,"timeout");v(this,"cleanupHandler");v(this,"listeners");v(this,"statusIterator");v(this,"forOrderedConsumer");v(this,"resetHandler");v(this,"abortOnMissingResource");v(this,"bind");v(this,"inBackOff");this.consumer=s;const u=a;this.opts=this.parseOptions(a,o),this.callback=u.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=ms(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=u.abort_on_missing_resource===!0,this.bind=u.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:a,idle_heartbeat:o,threshold_bytes:u,threshold_messages:d}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:m}=this;m&&m.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,y)=>{var _,T,R,C;if(g){this.stop(g);return}if((_=this.monitor)==null||_.work(),y.subject===this.inbox){if(qf(y))return;const D=(T=y.headers)==null?void 0:T.code,F=((C=(R=y.headers)==null?void 0:R.description)==null?void 0:C.toLowerCase())||"unknown",{msgsLeft:te,bytesLeft:X}=this.parseDiscard(y.headers);if(te>0||X>0)this.pending.msgs-=te,this.pending.bytes-=X,this.pending.requests--,this.notify(Nr.Discard,{msgsLeft:te,bytesLeft:X});else if(D===400){this.stop(new de(F,`${D}`));return}else if(D===409&&F==="consumer deleted"){if(this.notify($n.ConsumerDeleted,`${D} ${F}`),!this.refilling||this.abortOnMissingResource){const fe=new de(F,`${D}`);this.stop(fe);return}}else if(D===503){if(this.notify($n.NoResponders,`${D} No Responders`),!this.refilling||this.abortOnMissingResource){const fe=new de("no responders",`${D}`);this.stop(fe);return}}else this.notify(Nr.DebugEvent,`${D} ${F}`)}else this._push(Fa(y,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=y.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=d||a&&this.pending.bytes<=u){const D=this.pullOptions();this.pull(D)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new ch(o,g=>(this.notify($n.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var y;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const E of g)switch(E.type){case ds.Disconnect:(y=this.monitor)==null||y.cancel();break;case ds.Reconnect:this.resetPending().then(_=>{var T;_&&((T=this.monitor)==null||T.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const a=typeof s=="function"?s:null;try{a?a():this.callback(s)}catch(o){this.stop(o)}}}notify(s,a){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:a})})}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,a=0;const o=ah([this.opts.expires]);let u=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(a++,this.notify($n.StreamNotFound,a),!this.refilling||this.abortOnMissingResource)return this.stop(d),!1}else if(d.message==="consumer not found"){if(s++,this.notify($n.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,a=0;this.inBackOff=!0;const m=o.backoff(u),g=Rr(m);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),u++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const a=this.consumer.api.nc;this._push(()=>{a.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(Nr.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,a=this.opts.max_bytes-this.pending.bytes,o=nt(this.opts.idle_heartbeat),u=nt(this.opts.expires);return{batch:s,max_bytes:a,idle_heartbeat:o,expires:u}}parseDiscard(s){const a={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Bt.PendingMessagesHdr);o&&(a.msgsLeft=parseInt(o));const u=s==null?void 0:s.get(Bt.PendingBytesHdr);return u&&(a.bytesLeft=parseInt(u)),a}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,a;(s=this.monitor)==null||s.cancel(),this.monitor=null,(a=this.timeout)==null||a.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var a,o;this.done||((a=this.sub)==null||a.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(u=>{u.stop()})}))}parseOptions(s,a=!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,a){const u=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||u;const d=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||d}return o}status(){const s=new St;return this.listeners.push(s),Promise.resolve(s)}}class A_ extends St{constructor(){super();v(this,"src");v(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(a=>{this.stop(a||void 0)}),(async()=>{const a=await this.src.status();for await(const o of a)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,a){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:a})})}stop(s){var a;this.done||((a=this.src)==null||a.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 St;return this.listeners.push(s),Promise.resolve(s)}}class Gf{constructor(t,s){v(this,"api");v(this,"_info");v(this,"stream");v(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 vf(this,t,!0))}fetch(t={max_messages:100,expires:3e4}){const s=new vf(this,t,!1),a=Math.round(s.opts.expires*1.05),o=kr(a);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(t={expires:3e4}){const s=st(),a=t;a.max_messages=1;const o=new vf(this,a,!1),u=Math.round(o.opts.expires*1.05);u>=6e4&&(async()=>{for await(const m of await o.status())if(m.type===$n.HeartbeatsMissed&&m.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const m of o){s.resolve(m);break}})().catch(()=>{});const d=kr(u);return o.closed().then(m=>{m?s.reject(m):s.resolve(null)}).catch(m=>{s.reject(m)}).finally(()=>{d.cancel()}),d.catch(m=>{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:a}=this._info;return this.api.info(s,a).then(o=>(this._info=o,this._info))}}class O_{constructor(t,s,a={}){v(this,"api");v(this,"consumerOpts");v(this,"consumer");v(this,"opts");v(this,"cursor");v(this,"stream");v(this,"namePrefix");v(this,"serial");v(this,"currentConsumer");v(this,"userCallback");v(this,"iter");v(this,"type");v(this,"startSeq");v(this,"maxInitialReset");this.api=t,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=ti.next(),typeof a.name_prefix=="string"&&(Qo("name_prefix",a.name_prefix),this.namePrefix=a.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=_n.Unset,this.consumerOpts=a,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 a={name:s,deliver_policy:ft.StartSequence,opt_start_seq:t,ack_policy:wt.None,inactive_threshold:nt(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(a.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(a.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(a.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(a.replay_policy=this.consumerOpts.replay_policy),t===this.startSeq+1&&(a.deliver_policy=this.consumerOpts.deliver_policy||ft.StartSequence,(this.consumerOpts.deliver_policy===ft.LastPerSubject||this.consumerOpts.deliver_policy===ft.New||this.consumerOpts.deliver_policy===ft.Last)&&(delete a.opt_start_seq,a.deliver_policy=this.consumerOpts.deliver_policy),a.deliver_policy===ft.LastPerSubject&&typeof a.filter_subjects>"u"&&typeof a.filter_subject>"u"&&(a.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete a.opt_start_seq,a.deliver_policy=ft.StartTime,a.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(a.inactive_threshold=nt(this.consumerOpts.inactive_threshold))),a}async resetConsumer(t=0){var d,m,g,y,E;ti.next();const s=this.serial===0;(d=this.consumer)==null||d.delete().catch(()=>{}),t=t===0?1:t,this.cursor.deliver_seq=0;const a=this.getConsumerOpts(t);a.max_deliver=1,a.mem_storage=!0;const o=ah([((m=this.opts)==null?void 0:m.expires)||3e4]);let u;for(let _=0;;_++)try{u=await this.api.add(this.stream,a),(g=this.iter)==null||g.notify($n.OrderedConsumerRecreated,u.name);break}catch(T){if(T.message==="stream not found"&&((y=this.iter)==null||y.notify($n.StreamNotFound,_),this.type===_n.Fetch||this.opts.abort_on_missing_resource===!0))return(E=this.iter)==null||E.stop(T),Promise.reject(T);if(s&&_>=this.maxInitialReset)throw T;await Rr(o.backoff(_+1))}return u}internalHandler(t){return s=>{var o;if(this.serial!==t)return;const a=s.info.deliverySequence;if(a!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=a,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,y;s=s||{};const a=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===_n.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((y=this.iter)==null?void 0:y.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||a)&&(this.iter=new A_),this.consumer=new Gf(this.api,this.currentConsumer);const u=t;u.callback=this.internalHandler(this.serial);let d=null;this.type===_n.Fetch&&a?d=await this.consumer.fetch(t):this.type===_n.Consume&&(d=await this.consumer.consume(t));const m=d;m.forOrderedConsumer=!0,m.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(m)}notifyOrderedResetAndReset(){var t;(t=this.iter)==null||t.notify(Nr.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===_n.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===_n.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:a}=t;return a&&(this.userCallback=a),this.type=_n.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===_n.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:a}=t;return a&&(this.userCallback=a),this.type=_n.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 a=st();return s.callback=u=>{this.userCallback=null,a.resolve(u)},(await this.fetch(s)).iterClosed.then(u=>{u&&a.reject(u),a.resolve(null)}).catch(u=>{a.reject(u)}),a}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 Vf{constructor(t){v(this,"api");v(this,"notified");this.api=t,this.notified=!1}checkVersion(){const t=this.api.nc.features.get(Le.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 Gf(this.api,t)}async get(t,s={}){return typeof s=="object"?this.ordered(t,s):(await this.checkVersion(),this.api.info(t,s).then(a=>a.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Gf(this.api,a)).catch(a=>Promise.reject(a)))}async ordered(t,s){await this.checkVersion();const a=this.api;return new fh(a.nc,a.opts).info(t).then(u=>Promise.resolve(new O_(this.api,t,s))).catch(u=>Promise.reject(u))}}class Xo{constructor(t,s){v(this,"api");v(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 Xo(this.api,t)}else return this}info(t=!1,s){return t?Promise.resolve(this._info):this.api.info(this.name,s).then(a=>(this._info=a,this._info))}getConsumerFromInfo(t){return new Vf(new Lo(this.api.nc,this.api.opts)).getPullConsumerFor(t)}getConsumer(t){return new Vf(new Lo(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 fh extends Qa{constructor(t,s){super(t,s)}checkStreamConfigVersions(t){const s=this.nc;if(t.metadata){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_CONSUMER_METADATA);if(!u)throw new Error(`stream 'metadata' requires server ${o}`)}if(t.first_seq){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_FIRST_SEQ);if(!u)throw new Error(`stream 'first_seq' requires server ${o}`)}if(t.subject_transform){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_SUBJECT_TRANSFORM);if(!u)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(t.compression){const{min:o,ok:u}=s.features.get(Le.JS_STREAM_COMPRESSION);if(!u)throw new Error(`stream 'compression' requires server ${o}`)}if(t.consumer_limits){const{min:o,ok:u}=s.features.get(Le.JS_DEFAULT_CONSUMER_LIMITS);if(!u)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function a(o,u){var m;if((((m=u==null?void 0:u.subject_transforms)==null?void 0:m.length)||0)>0){const{min:g,ok:y}=s.features.get(Le.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!y)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}t.sources&&t.sources.forEach(o=>{a("stream sources",o)}),t.mirror&&a("stream mirror",t.mirror)}async add(t={}){var o;this.checkStreamConfigVersions(t),zt(t.name),t.mirror=So(t.mirror),t.sources=(o=t.sources)==null?void 0:o.map(So);const a=await this._request(`${this.prefix}.STREAM.CREATE.${t.name}`,t);return this._fixInfo(a),a}async delete(t){return zt(t),(await this._request(`${this.prefix}.STREAM.DELETE.${t}`)).success}async update(t,s={}){var m;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),zt(t);const a=await this.info(t),o=Object.assign(a.config,s);o.mirror=So(o.mirror),o.sources=(m=o.sources)==null?void 0:m.map(So);const d=await this._request(`${this.prefix}.STREAM.UPDATE.${t}`,o);return this._fixInfo(d),d}async info(t,s){zt(t);const a=`${this.prefix}.STREAM.INFO.${t}`;let u=await this._request(a,s),{total:d,limit:m}=u,g=u.state.subjects?Object.getOwnPropertyNames(u.state.subjects).length:1;if(d&&d>g){const y=[u],E=s||{};let _=0;for(;d>g;){_++,E.offset=m*_;const R=await this._request(a,E);d=R.total,y.push(R);const C=Object.getOwnPropertyNames(R.state.subjects).length;if(g+=C,C<m)break}let T={};for(let R=0;R<y.length;R++)u=y[R],u.state.subjects&&(T=Object.assign(T,u.state.subjects));u.offset=0,u.total=0,u.limit=0,u.state.subjects=T}return this._fixInfo(u),u}list(t=""){const s=t!=null&&t.length?{subject:t}:{},a=u=>{const d=u;return d.streams.forEach(m=>{this._fixInfo(m)}),d.streams},o=`${this.prefix}.STREAM.LIST`;return new Ua(o,a,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:u}=s;if(typeof o=="number"&&typeof u=="number")throw new Error("can specify one of keep or seq")}return zt(t),await this._request(`${this.prefix}.STREAM.PURGE.${t}`,s)}async deleteMessage(t,s,a=!0){zt(t);const o={seq:s};return a||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${t}`,o)).success}async getMessage(t,s){zt(t);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${t}`,s);return new Wg(o)}find(t){return this.findStream(t)}listKvs(){const t=a=>{var g;const u=a.streams.filter(y=>y.config.name.startsWith(nn));u.forEach(y=>{this._fixInfo(y)});let d="";return u.length&&(d=((g=this.nc.info)==null?void 0:g.cluster)??""),u.map(y=>new Zg(y,d))},s=`${this.prefix}.STREAM.LIST`;return new Ua(s,t,this)}listObjectStores(){const t=a=>{const u=a.streams.filter(m=>m.config.name.startsWith(uh));return u.forEach(m=>{this._fixInfo(m)}),u.map(m=>new Yf(m))},s=`${this.prefix}.STREAM.LIST`;return new Ua(s,t,this)}names(t=""){const s=t!=null&&t.length?{subject:t}:{},a=u=>u.streams,o=`${this.prefix}.STREAM.NAMES`;return new Ua(o,a,this,s)}async get(t){const s=await this.info(t);return Promise.resolve(new Xo(this,s))}}class N_ extends Qa{constructor(t,s){super(t,s)}async getMessage(t,s){zt(t);let a=s;const{last_by_subj:o}=a;o&&(a=null);const u=a?this.jc.encode(a):an,d=this.opts.apiPrefix||"$JS.API",m=o?`${d}.DIRECT.GET.${t}.${o}`:`${d}.DIRECT.GET.${t}`,g=await this.nc.request(m,u,{timeout:this.timeout}),y=Ar(g);if(y)return Promise.reject(y);const E=new If(g);return Promise.resolve(E)}async getBatch(t,s){zt(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 u=JSON.stringify(s,(g,y)=>g==="up_to_time"&&y instanceof Date?y.toISOString():y),d=new St,m=await this.nc.requestMany(o,u,{strategy:Rn.SentinelMsg});return(async()=>{var _,T,R;let g=!1,y=!1,E;for await(const C of m){if(!g){g=!0;const D=((_=C.headers)==null?void 0:_.code)||0;if(D!==0&&D<200||D>299){E=(T=C.headers)==null?void 0:T.description.toLowerCase();break}if(((R=C.headers)==null?void 0:R.get("Nats-Num-Pending"))===""){y=!0;break}}if(C.data.length===0)break;d.push(new If(C))}d.push(()=>{if(y)throw new Error("batch direct get not supported by the server");if(E)throw new Error(`bad request: ${E}`);d.stop()})})(),Promise.resolve(d)}}class If{constructor(t){v(this,"data");v(this,"header");if(!t.headers)throw new Error("headers expected");this.data=t.data,this.header=t.headers}get subject(){return this.header.last(wr.Subject)}get seq(){const t=this.header.last(wr.Sequence);return typeof t=="string"?parseInt(t):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(wr.TimeStamp)}get stream(){return this.header.last(wr.Stream)}json(t){return Dn(t).decode(this.data)}string(){return sn.decode(this.data)}}v(If,"jc");class T_ extends Qa{constructor(s,a){super(s,a);v(this,"streams");v(this,"consumers");v(this,"direct");this.streams=new fh(s,a),this.consumers=new Lo(s,a),this.direct=new N_(s,a)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new St;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(a,o)=>{if(a)throw a;try{const u=this.parseJsResponse(o),d=u.type.split("."),m=d[d.length-1];s.push({kind:m,data:u})}catch(u){s.stop(u)}}}),s}}class Wg{constructor(t){v(this,"_header");v(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):an}get header(){if(!this._header)if(this.smr.message.hdrs){const t=this._parse(this.smr.message.hdrs);this._header=Xs.decode(t)}else this._header=ps();return this._header}_parse(t){const s=atob(t),a=s.length,o=new Uint8Array(a);for(let u=0;u<a;u++)o[u]=s.charCodeAt(u);return o}json(t){return Dn(t).decode(this.data)}string(){return sn.decode(this.data)}}v(Wg,"jc");class k_{constructor(t){v(this,"api");this.api=t}get(t){return this.api.info(t).then(s=>new Xo(this.api,s))}}class _f{constructor(t){v(this,"info");v(this,"hdrs");this.info=t}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=Xs.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 Q0(i){const t={name:i.name,description:i.description??"",options:i.options,metadata:i.metadata};if(i.headers){const s=i.headers;t.headers=s.toRecord()}return t}function C_(){return new ReadableStream({pull(i){i.enqueue(new Uint8Array(0)),i.close()}})}class $a{constructor(t,s,a){v(this,"jsm");v(this,"js");v(this,"stream");v(this,"name");this.name=t,this.jsm=s,this.js=a}_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 _f(s):null}async list(){const t=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const a of s){if(a===null)break;t.push(a)}return Promise.resolve(t)}async rawInfo(t){const{name:s,error:a}=this._checkNotEmpty(t);if(a)return Promise.reject(a);const o=this._metaSubject(s);try{const u=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),m=Dn().decode(u.data);return m.revision=u.seq,m}catch(u){return u.code==="404"?null:Promise.reject(u)}}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 Yf(t)))}async status(t){const s=await this._si(t);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new Yf(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(t,s,a){var oe;const o=this.js.getOptions();a=a||{timeout:o.timeout},a.timeout=a.timeout||o.timeout,a.previousRevision=a.previousRevision??void 0;const{timeout:u,previousRevision:d}=a,m=this.js.nc.info,g=(m==null?void 0:m.max_payload)||1024;t=t||{},t.options=t.options||{};let y=((oe=t.options)==null?void 0:oe.max_chunk_size)||128*1024;y=y>g?g:y,t.options.max_chunk_size=y;const E=await this.info(t.name),{name:_,error:T}=this._checkNotEmpty(t.name);if(T)return Promise.reject(T);const R=ti.next(),C=this._chunkSubject(R),D=this._metaSubject(_),F=Object.assign({bucket:this.name,nuid:R,size:0,chunks:0},Q0(t)),te=st(),X=[],fe=new Mr;try{const O=s?s.getReader():null,U=B0.create();for(;;){const{done:ne,value:G}=O?await O.read():{done:!0,value:void 0};if(ne){if(fe.size()>0){const re=fe.drain();U.update(re),F.chunks++,F.size+=re.length,X.push(this.js.publish(C,re,{timeout:u}))}await Promise.all(X),X.length=0,F.mtime=new Date().toISOString();const I=Or.encode(U.digest());F.digest=`${F0}${I}`,F.deleted=!1;const Z=ps();typeof d=="number"&&Z.set(Hn.ExpectedLastSubjectSequenceHdr,`${d}`),Z.set(Bt.RollupHdr,Bt.RollupValueSubject);const ae=await this.js.publish(D,Dn().encode(F),{headers:Z,timeout:u});if(F.revision=ae.seq,E)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${E.nuid}`})}catch{}te.resolve(new _f(F));break}if(G)for(fe.fill(G);fe.size()>y;){F.chunks++,F.size+=y;const I=fe.drain(t.options.max_chunk_size);U.update(I),X.push(this.js.publish(C,I,{timeout:u}))}}}catch(O){await this.jsm.streams.purge(this.stream,{filter:C}),te.reject(O)}return te}putBlob(t,s,a){function o(u){return new ReadableStream({pull(d){d.enqueue(u),d.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(t,o(s),a)}put(t,s,a){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,a)}async getBlob(t){async function s(u){const d=new Mr,m=u.getReader();for(;;){const{done:g,value:y}=await m.read();if(g)return d.drain();y&&y.length&&d.fill(y)}}const a=await this.get(t);if(a===null)return Promise.resolve(null);const o=await Promise.all([a.error,s(a.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 _=s.options.link.name||"";if(_==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await $a.create(this.js,s.options.link.bucket):this).get(_)}if(!s.digest.startsWith(F0))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const a=Bf(s.digest.substring(8));if(a===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=st(),u={info:new _f(s),error:o};if(s.size===0)return u.data=C_(),o.resolve(null),Promise.resolve(u);let d;const m=Zs();m.orderedConsumer();const g=B0.create(),y=`$O.${this.name}.C.${s.nuid}`,E=await this.js.subscribe(y,m);return(async()=>{for await(const _ of E)_.data.length>0&&(g.update(_.data),d.enqueue(_.data)),_.info.pending===0&&(x1(a,g.digest())?d.close():d.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${a}`)),E.unsubscribe())})().then(()=>{o.resolve()}).catch(_=>{d.error(_),o.reject(_)}),u.data=new ReadableStream({start(_){d=_},cancel(){E.unsubscribe()}}),u}linkStore(t,s){if(!(s instanceof $a))return Promise.reject("bucket required");const a=s,{name:o,error:u}=this._checkNotEmpty(t);if(u)return Promise.reject(u);const d={name:o,options:{link:{bucket:a.name}}};return this._put(d,null)}async link(t,s){const{name:a,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 u=await this.rawInfo(t);if(u!==null&&!u.deleted)return Promise.reject(new Error("an object already exists with that name"));const d={bucket:s.bucket,name:s.name},m={name:a,bucket:s.bucket,options:{link:d}};await this.js.publish(this._metaSubject(t),JSON.stringify(m));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 a=Dn(),o=ps();return o.set(Bt.RollupHdr,Bt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),a.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(t,s={}){const a=await this.rawInfo(t);if(a===null)return Promise.reject(new Error("object not found"));if(a.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??a.name;const{name:o,error:u}=this._checkNotEmpty(s.name);if(u)return Promise.reject(u);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({},a,Q0(s)),m=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(m)}async watch(t={}){t.includeHistory=t.includeHistory??!1,t.ignoreDeletes=t.ignoreDeletes??!1;let s=!1;const a=new St,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(a.push(null),s=!0):a.stop(g)}const u=Dn(),d=Zs();d.orderedConsumer(),t.includeHistory?d.deliverLastPerSubject():(s=!0,d.deliverNew()),d.callback((g,y)=>{var E;if(g){a.stop(g);return}if(y!==null){const _=u.decode(y.data);_.deleted&&t.ignoreDeletes===!0||a.push(_),((E=y.info)==null?void 0:E.pending)===0&&!s&&(s=!0,a.push(null))}});const m=await this.js.subscribe(o,d);return a._data=m,a.iterClosed.then(()=>{m.unsubscribe()}),m.closed.then(()=>{a.stop()}).catch(g=>{a.stop(g)}),a}_chunkSubject(t){return`$O.${this.name}.C.${t}`}_metaSubject(t){return`$O.${this.name}.M.${Or.encode(t)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(t={}){try{this.stream=v_(this.name)}catch(o){return Promise.reject(o)}const s=(t==null?void 0:t.ttl)||0;delete t.ttl;const a=Object.assign({max_age:s},t);a.name=this.stream,a.num_replicas=t.replicas??1,a.allow_direct=!0,a.allow_rollup_hdrs=!0,a.discard=Ga.New,a.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],t.placement&&(a.placement=t.placement),t.metadata&&(a.metadata=t.metadata),typeof t.compression=="boolean"&&(a.compression=t.compression?ni.S2:ni.None);try{await this.jsm.streams.info(a.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(a)}}static async create(t,s,a={}){const o=await t.jetstreamManager(),u=new $a(s,o,t);return await u.init(a),Promise.resolve(u)}}class M_{constructor(t){v(this,"js");this.js=t}kv(t,s={}){const a=this.js,{ok:o,min:u}=a.nc.features.get(Le.JS_KV);return o?s.bindOnly?Ia.bind(this.js,t,s):Ia.create(this.js,t,s):Promise.reject(new Error(`kv is only supported on servers ${u} 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 a=this.js,{ok:o,min:u}=a.nc.features.get(Le.JS_OBJECTSTORE);return o?$a.create(this.js,t,s):Promise.reject(new Error(`objectstore is only supported on servers ${u} or better`))}}class hh extends Qa{constructor(s,a){super(s,a);v(this,"consumers");v(this,"streams");v(this,"consumerAPI");v(this,"streamAPI");this.consumerAPI=new Lo(s,a),this.streamAPI=new fh(s,a),this.consumers=new Vf(this.consumerAPI),this.streams=new k_(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const a=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(a)}get apiPrefix(){return this.prefix}get views(){return new M_(this)}async publish(s,a=an,o){o=o||{},o.expect=o.expect||{};const u=(o==null?void 0:o.headers)||ps();o&&(o.msgID&&u.set(Hn.MsgIdHdr,o.msgID),o.expect.lastMsgID&&u.set(Hn.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&u.set(Hn.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&u.set(Hn.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&u.set(Hn.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const d=o.timeout||this.timeout,m={};d&&(m.timeout=d),o&&(m.headers=u);let{retries:g,retry_delay:y}=o;g=g||1,y=y||250;let E;for(let T=0;T<g;T++)try{E=await this.nc.request(s,a,m);break}catch(R){if(R.code==="503"&&T+1<g)await Rr(y);else throw R}const _=this.parseJsResponse(E);if(_.stream==="")throw de.errorForCode(le.JetStreamInvalidAck);return _.duplicate=_.duplicate?_.duplicate:!1,_}async pull(s,a,o=0){zt(s),jr(a);let u=this.timeout;o>u&&(u=o),o=o<0?0:nt(o);const d={batch:1,no_wait:o===0,expires:o},m=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${a}`,this.jc.encode(d),{noMux:!0,timeout:u}),g=Ar(m);if(g)throw g;return Fa(m,this.timeout)}fetch(s,a,o={}){zt(s),jr(a);let u=null;const d=(o.max_bytes??0)>0;let m=0;const g=d?o.max_bytes:0;let y=null;const E={};if(E.batch=o.batch||1,g){const X=this.nc.features.get(Le.JS_PULL_MAX_BYTES);if(!X.ok)throw new Error(`max_bytes is only supported on servers ${X.min} or better`);E.max_bytes=g}E.no_wait=o.no_wait||!1,E.no_wait&&E.expires&&(E.expires=0);const _=o.expires||0;if(_&&(E.expires=nt(_)),_===0&&E.no_wait===!1)throw new Error("expires or no_wait is required");const T=o.idle_heartbeat||0;T&&(E.idle_heartbeat=nt(T),o.delay_heartbeat===!0&&(E.idle_heartbeat=nt(T*4)));const R=new St,C=E.batch;let D=0;R.protocolFilterFn=(X,fe=!1)=>qf(X.msg)?(y==null||y.work(),!1):!0,R.dispatchedFn=X=>{if(X){if(d&&(m+=X.data.length),D++,u&&X.info.pending===0)return;(R.getPending()===1&&X.info.pending===0||C===D||g>0&&m>=g)&&R.stop()}};const F=ms(this.nc.options.inboxPrefix),te=this.nc.subscribe(F,{max:o.batch,callback:(X,fe)=>{X===null&&(X=Ar(fe)),X!==null?(u&&(u.cancel(),u=null),e1(X)?R.stop(ty(X)===null?void 0:X):R.stop(X)):(y==null||y.work(),R.received++,R.push(Fa(fe,this.timeout)))}});return _&&(u=kr(_),u.catch(()=>{te.isClosed()||(te.drain().catch(()=>{}),u=null),y&&y.cancel()})),(async()=>{try{T&&(y=new ch(T,X=>(R.push(()=>{R.err=new de(`${wn.IdleHeartbeatMissed}: ${X}`,le.JetStreamIdleHeartBeat)}),!0)))}catch{}await te.closed,u!==null&&(u.cancel(),u=null),y&&y.cancel(),R.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${a}`,this.jc.encode(E),{reply:F}),R}async pullSubscribe(s,a=Zs()){const o=await this._processOptions(s,a);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 u=o.config.ack_policy;if(u===wt.None||u===wt.All)throw new Error("ack policy for pull consumers must be explicit");const d=this._buildTypedSubscriptionOpts(o),m=new z_(this,o.deliver,d);m.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw m.unsubscribe(),g}return m}async subscribe(s,a=Zs()){const o=await this._processOptions(s,a);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const u=this._buildTypedSubscriptionOpts(o),d=new ey(this,o.deliver,u);d.info=o;try{await this._maybeCreateConsumer(o)}catch(m){throw d.unsubscribe(),m}return d._maybeSetupHbMonitoring(),d}async _processOptions(s,a=Zs()){const o=D0(a)?a.getOpts():a;if(o.isBind=D0(a)?a.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!==wt.NotSet&&o.config.ack_policy!==wt.None)throw new de("ordered consumer: ack_policy can only be set to 'none'",le.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new de("ordered consumer: durable_name cannot be set",le.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new de("ordered consumer: deliver_subject cannot be set",le.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new de("ordered consumer: max_deliver cannot be set",le.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new de("ordered consumer: deliver_group cannot be set",le.ApiError);o.config.deliver_subject=ms(this.nc.options.inboxPrefix),o.config.ack_policy=wt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||nt(5e3),o.config.ack_wait=nt(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===wt.NotSet&&(o.config.ack_policy=wt.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 u=await this.consumerAPI.info(o.stream,o.config.durable_name);if(u){if(u.config.filter_subject&&u.config.filter_subject!==s)throw new Error("subject does not match consumer");const d=o.config.deliver_group??"";if(d===""&&u.push_bound===!0)throw new Error("duplicate subscription");const m=u.config.deliver_group??"";if(d!==m)throw m===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${m}'`);o.last=u,o.config=u.config,o.attached=!0,o.config.durable_name||(o.name=u.name)}}catch(u){if(u.code!=="404")throw u}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||ms(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const a={};return a.adapter=U_(s.callbackFn===void 0,this.timeout),a.ingestionFilterFn=hh.ingestionFn(s.ordered),a.protocolFilterFn=(o,u=!1)=>{const d=o;return Df(d.msg)?(u||d.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==wt.None&&(a.dispatchedFn=P_),s.callbackFn&&(a.callback=s.callbackFn),a.max=s.max||0,a.queue=s.queue,a}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:ft.All,ack_policy:wt.Explicit,ack_wait:nt(30*1e3),replay_policy:Cr.Instant},s.config);const a=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(a.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=a.name,s.config=a.config,s.last=a}static ingestionFn(s){return(a,o)=>{var g;const u=o;if(!a)return{ingest:!1,protocol:!1};const d=a;if(Ar(d.msg)||(g=u.monitor)==null||g.work(),qf(d.msg)){const y=s?u._checkHbOrderConsumer(d.msg):!0;return s||u.info.flow_control.heartbeat_count++,{ingest:y,protocol:!0}}else if(Df(d.msg))return u.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?u._checkOrderedConsumer(a):!0,protocol:!1}}}}class dh{constructor(t){v(this,"options");v(this,"protocol");v(this,"draining");v(this,"listeners");v(this,"_services");this.draining=!1,this.options=t_(t),this.listeners=[]}static connect(t={}){return new Promise((s,a)=>{const o=new dh(t);Ho.connect(o.options,o).then(u=>{o.protocol=u,(async function(){for await(const d of u.status())o.listeners.forEach(m=>{m.push(d)})})(),s(o)}).catch(u=>{a(u)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(t,s,a){if(this.isClosed())throw de.errorForCode(le.ConnectionClosed);if(s&&this.isDraining()||a&&this.protocol.noMorePublishing)throw de.errorForCode(le.ConnectionDraining);if(t=t||"",t.length===0)throw de.errorForCode(le.BadSubject)}publish(t,s,a){this._check(t,!1,!0),this.protocol.publish(t,s,a)}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 a=new Kg(this.protocol,t,s);return this.protocol.subscribe(a),a}_resub(t,s,a){this._check(s,!0,!1);const o=t;o.max=a,a&&(o.max=a+o.received),this.protocol.resub(o,s)}requestMany(t,s=an,a={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(t,!0,!0)}catch(g){return Promise.reject(g)}if(a.strategy=a.strategy||Rn.Timer,a.maxWait=a.maxWait||1e3,a.maxWait<1)return Promise.reject(new de("timeout",le.InvalidOption));const u=new St;function d(g){u.push(()=>{u.stop(g)})}function m(g,y){g||y===null?d(g===null?void 0:g):u.push(y)}if(a.noMux){const g=o?new Error().stack:null;let y=typeof a.maxMessages=="number"&&a.maxMessages>0?a.maxMessages:-1;const E=this.subscribe(ms(this.options.inboxPrefix),{callback:(C,D)=>{var F,te;if(((F=D==null?void 0:D.data)==null?void 0:F.length)===0&&((te=D==null?void 0:D.headers)==null?void 0:te.status)===le.NoResponders&&(C=de.errorForCode(le.NoResponders)),C){g&&(C.stack+=`
48
48
 
49
- ${g}`),_(M);return}m(null,D),a.strategy===Mn.Count&&(y--,y===0&&_()),a.strategy===Mn.JitterTimer&&(R(),N=setTimeout(()=>{_()},300)),a.strategy===Mn.SentinelMsg&&D&&D.data.length===0&&_()}});E.requestSubject=t,E.closed.then(()=>{d()}).catch(M=>{u.stop(M)});const _=M=>{M&&u.push(()=>{throw M}),R(),E.drain().then(()=>{d()}).catch(D=>{d()})};u.iterClosed.then(()=>{R(),E==null||E.unsubscribe()}).catch(M=>{R(),E==null||E.unsubscribe()});try{this.publish(t,s,{reply:E.getSubject()})}catch(M){_(M)}let N=setTimeout(()=>{_()},a.maxWait);const R=()=>{N&&clearTimeout(N)}}else{const g=a;g.callback=m,u.iterClosed.then(()=>{y.cancel()}).catch(E=>{y.cancel(E)});const y=new y1(this.protocol.muxSubscriptions,t,g);this.protocol.request(y);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${y.token}`,headers:a.headers})}catch(E){y.cancel(E)}}return Promise.resolve(u)}request(t,s,a={timeout:1e3,noMux:!1}){try{this._check(t,!0,!0)}catch(u){return Promise.reject(u)}const o=!this.protocol.options.noAsyncTraces;if(a.timeout=a.timeout||1e3,a.timeout<1)return Promise.reject(new he("timeout",le.InvalidOption));if(!a.noMux&&a.reply)return Promise.reject(new he("reply can only be used with noMux",le.InvalidOption));if(a.noMux){const u=a.reply?a.reply:ms(this.options.inboxPrefix),d=st(),m=o?new Error:null,g=this.subscribe(u,{max:1,timeout:a.timeout,callback:(y,E)=>{y?(m&&y.code!==le.Timeout&&(y.stack+=`
49
+ ${g}`),_(C);return}m(null,D),a.strategy===Rn.Count&&(y--,y===0&&_()),a.strategy===Rn.JitterTimer&&(R(),T=setTimeout(()=>{_()},300)),a.strategy===Rn.SentinelMsg&&D&&D.data.length===0&&_()}});E.requestSubject=t,E.closed.then(()=>{d()}).catch(C=>{u.stop(C)});const _=C=>{C&&u.push(()=>{throw C}),R(),E.drain().then(()=>{d()}).catch(D=>{d()})};u.iterClosed.then(()=>{R(),E==null||E.unsubscribe()}).catch(C=>{R(),E==null||E.unsubscribe()});try{this.publish(t,s,{reply:E.getSubject()})}catch(C){_(C)}let T=setTimeout(()=>{_()},a.maxWait);const R=()=>{T&&clearTimeout(T)}}else{const g=a;g.callback=m,u.iterClosed.then(()=>{y.cancel()}).catch(E=>{y.cancel(E)});const y=new v1(this.protocol.muxSubscriptions,t,g);this.protocol.request(y);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${y.token}`,headers:a.headers})}catch(E){y.cancel(E)}}return Promise.resolve(u)}request(t,s,a={timeout:1e3,noMux:!1}){try{this._check(t,!0,!0)}catch(u){return Promise.reject(u)}const o=!this.protocol.options.noAsyncTraces;if(a.timeout=a.timeout||1e3,a.timeout<1)return Promise.reject(new de("timeout",le.InvalidOption));if(!a.noMux&&a.reply)return Promise.reject(new de("reply can only be used with noMux",le.InvalidOption));if(a.noMux){const u=a.reply?a.reply:ms(this.options.inboxPrefix),d=st(),m=o?new Error:null,g=this.subscribe(u,{max:1,timeout:a.timeout,callback:(y,E)=>{y?(m&&y.code!==le.Timeout&&(y.stack+=`
50
50
 
51
- ${m.stack}`),g.unsubscribe(),d.reject(y)):(y=Ug(E),y?(m&&(y.stack+=`
51
+ ${m.stack}`),g.unsubscribe(),d.reject(y)):(y=Hg(E),y?(m&&(y.stack+=`
52
52
 
53
- ${m.stack}`),d.reject(y)):d.resolve(E))}});return g.requestSubject=t,this.protocol.publish(t,s,{reply:u,headers:a.headers}),d}else{const u=new Pg(this.protocol.muxSubscriptions,t,a,o);this.protocol.request(u);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:a.headers})}catch(m){u.cancel(m)}const d=Promise.race([u.timer,u.deferred]);return d.catch(()=>{u.cancel()}),d}}flush(){return this.isClosed()?Promise.reject(he.errorForCode(le.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(he.errorForCode(le.ConnectionClosed)):this.isDraining()?Promise.reject(he.errorForCode(le.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 St;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,a)=>s==="time"?new Date(Date.parse(a)):a)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(t={}){const s=new A_(this,t);if(t.checkAPI!==!1)try{await s.getAccountInfo()}catch(a){const o=a;throw o.code===le.NoResponders&&(o.code=le.JetStreamNotEnabled),o}return s}jetstream(t={}){return new hh(this,t)}getServerVersion(){const t=this.info;return t?Ti(t.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw he.errorForCode(le.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 k_(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(he.errorForCode(le.ConnectionClosed)):this.isDraining()?Promise.reject(he.errorForCode(le.ConnectionDraining)):this.protocol.reconnect()}}class k_{constructor(t){v(this,"nc");this.nc=t}add(t){try{return new Xa(this.nc,t).start()}catch(s){return Promise.reject(s)}}client(t,s){return new c_(this.nc,t,s)}}class C_{constructor(t,s,a){v(this,"bucket");v(this,"sm");v(this,"prefixLen");this.bucket=t,this.prefixLen=s,this.sm=a}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($o)||"PUT"}get length(){const t=this.sm.header.get(Bt.MessageSizeHdr)||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class M_{constructor(t,s,a){v(this,"bucket");v(this,"key");v(this,"sm");this.bucket=t,this.key=s,this.sm=a}get value(){return this.sm.data}get created(){return new Date(lh(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var t;return((t=this.sm.headers)==null?void 0:t.get($o))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const t=((s=this.sm.headers)==null?void 0:s.get(Bt.MessageSizeHdr))||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Kg extends _1{constructor(s,a,o){super(s.nc,a,o);v(this,"js");v(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 a=ms(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,a);const u=this.info;u.config.name=ei.next(),u.ordered_consumer_sequence.delivery_seq=0,u.flow_control.heartbeat_count=0,u.flow_control.fc_count=0,u.flow_control.consumer_restarts++,u.deliver=a,u.config.deliver_subject=a,u.config.deliver_policy=ft.StartSequence,u.config.opt_start_seq=s;const d={};d.stream_name=this.info.stream,d.config=u.config;const m=`${u.api.prefix}.CONSUMER.CREATE.${u.stream}`;this.js._request(m,d,{retries:-1}).then(g=>{const y=g,E=this.sub.info;E.last=y,this.info.config=y.config,this.info.name=y.name}).catch(g=>{const y=new he(`unable to recreate ordered consumer ${u.stream} at seq ${s}`,le.RequestError,g);this.sub.callback(y,{})})}_maybeSetupHbMonitoring(){var a,o;const s=((o=(a=this.info)==null?void 0:a.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(lh(s))}_setupHbMonitoring(s,a=0){const o={cancelAfter:0,maxOut:2};a&&(o.cancelAfter=a);const u=this.sub,d=m=>{var E,_,N,R;const g=t1(409,`${_n.IdleHeartbeatMissed}: ${m}`,this.sub.subject);if(!((E=this.info)==null?void 0:E.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const M=((N=(_=this.info)==null?void 0:_.ordered_consumer_sequence)==null?void 0:N.stream_seq)||0;return this._resetOrderedConsumer(M+1),(R=this.monitor)==null||R.restart(),!1}return!u.noIterator};this.monitor=new ch(s,d,o)}_checkHbOrderConsumer(s){const a=s.headers.get(Bt.ConsumerStalledHdr);a!==""&&this.js.nc.publish(a);const o=parseInt(s.headers.get(Bt.LastConsumerSeqHdr),10),u=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==u.delivery_seq&&this._resetOrderedConsumer(u.stream_seq+1),!1}_checkOrderedConsumer(s){const a=this.info.ordered_consumer_sequence,o=s.info.streamSequence,u=s.info.deliverySequence;return u!=a.delivery_seq+1?(this._resetOrderedConsumer(a.stream_seq+1),!1):(a.delivery_seq=u,a.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${a}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${a}`,u=await s.api._request(o);return s.last=u,u}}class R_ extends Kg{constructor(t,s,a){super(t,s,a)}pull(t={batch:1}){const{stream:s,config:a,name:o}=this.sub.info,u=a.durable_name??o,d={};if(d.batch=t.batch||1,d.no_wait=t.no_wait||!1,(t.max_bytes??0)>0){const y=this.js.nc.features.get(Le.JS_PULL_MAX_BYTES);if(!y.ok)throw new Error(`max_bytes is only supported on servers ${y.min} or better`);d.max_bytes=t.max_bytes}let m=0;t.expires&&t.expires>0&&(m=t.expires,d.expires=nt(m));let g=0;if(t.idle_heartbeat&&t.idle_heartbeat>0&&(g=t.idle_heartbeat,d.idle_heartbeat=nt(g)),g&&m===0)throw new Error("idle_heartbeat requires expires");if(g>m)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),m&&g&&(this.monitor?this.monitor._change(g,m):this._setupHbMonitoring(g,m));const y=this.info.api,E=`${y.prefix}.CONSUMER.MSG.NEXT.${s}.${u}`,_=this.sub.subject;y.nc.publish(E,y.jc.encode(d),{reply:_})}}}function D_(i,t){return i?z_(t):q_(t)}function q_(i){return(t,s)=>t?[t,null]:(t=Ar(s),t?[t,null]:[null,Ja(s,i)])}function z_(i){return(t,s)=>{if(t)return[t,null];const a=Ar(s);return a!==null?[Xg(a),null]:[null,Ja(s,i)]}}function Xg(i){if(i!==null)switch(i.code){case le.JetStream404NoMessages:case le.JetStream408RequestTimeout:return null;case le.JetStream409:return n1(i)?i:null;default:return i}return null}function U_(i){i&&i.ack()}function B_(i){const t=i.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 L_{constructor(t,s){v(this,"msg");v(this,"di");v(this,"didAck");v(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=B_(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]===Ma[0]&&t[1]===Ma[1]&&t[2]===Ma[2]&&t[3]===Ma[3]}async ackAck(t){var a;t=t||{},t.timeout=t.timeout||this.timeout;const s=st();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const u=this.msg.publisher,d=!((a=u.options)!=null&&a.noAsyncTraces),m=new Pg(u.muxSubscriptions,this.msg.reply,{timeout:t.timeout},d);u.request(m);try{u.publish(this.msg.reply,I0,{reply:`${u.muxSubscriptions.baseInbox}${m.token}`})}catch(g){m.cancel(g)}try{await Promise.race([m.timer,m.deferred]),s.resolve(!0)}catch(g){m.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(I0)}nak(t){let s=x_;t&&(s=Mf().encode(`-NAK ${JSON.stringify({delay:nt(t)})}`)),this.doAck(s)}working(){this.doAck(Ma)}next(t,s={batch:1}){const a={};a.batch=s.batch||1,a.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(a.expires=nt(s.expires));const o=Rn().encode(a),u=Mr.concat(v_,w_,o),d=t?{reply:t}:void 0;this.msg.respond(u,d)}term(t=""){let s=__;(t==null?void 0:t.length)>0&&(s=Mf().encode(`+TERM ${t}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const P_="1.30.3",H_="nats.ws";class $_{constructor(){v(this,"version");v(this,"lang");v(this,"closeError");v(this,"connected");v(this,"done");v(this,"socket");v(this,"options");v(this,"socketClosed");v(this,"encrypted");v(this,"peeked");v(this,"yields");v(this,"signal");v(this,"closedNotification");this.version=P_,this.lang=H_,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=st(),this.closedNotification=st()}async connect(t,s){const a=st();if(s.tls)return a.reject(new he("tls",le.InvalidOption)),a;this.options=s;const o=t.src;if(s.wsFactory){const{socket:u,encrypted:d}=await s.wsFactory(t.src,s);this.socket=u,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=u=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(u.data)),this.peeked){this.signal.resolve();return}const d=Mr.concat(...this.yields),m=O1(d);if(m!==""){const g=t_.exec(m);if(!g){s.debug&&console.error("!!!",_o(d)),a.reject(new Error("unexpected response from server"));return}try{const y=JSON.parse(g[1]);W1(y,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),a.resolve()}catch(y){a.reject(y);return}}},this.socket.onclose=u=>{if(this.isDiscarded())return;this.socketClosed=!0;let d;this.done||(u.wasClean||(d=new Error(u.reason)),this._closed(d))},this.socket.onerror=u=>{if(this.isDiscarded())return;const d=u,m=new he(d.message,le.Unknown,new Error(d.error));a.reject(m)},a}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 Rr(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(`> ${_o(t[s])}`),yield t[s];if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=st())}}isEncrypted(){return this.connected&&this.encrypted}send(t){if(!this.isDiscarded())try{this.socket.send(t.buffer),this.options.debug&&console.info(`< ${_o(t)}`);return}catch(s){this.options.debug&&console.error(`!!! ${_o(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 Y_(i,t){/^(.*:\/\/)(.*)/.test(i)||(typeof t=="boolean"?i=`${t===!0?"https":"http"}://${i}`:i=`https://${i}`);let a=new URL(i);const o=a.protocol.toLowerCase();o==="ws:"&&(t=!1),o==="wss:"&&(t=!0),o!=="https:"&&o!=="http"&&(i=i.replace(/^(.*:\/\/)(.*)/gm,"$2"),a=new URL(`http://${i}`));let u,d;const m=a.hostname,g=a.pathname,y=a.search||"";switch(o){case"http:":case"ws:":case"nats:":d=a.port||"80",u="ws:";break;case"https:":case"wss:":case"tls:":d=a.port||"443",u="wss:";break;default:d=a.port||t===!0?"443":"80",u=t===!0?"wss:":"ws:";break}return`${u}//${m}:${d}${g}${y}`}function G_(i={}){return w1({defaultPort:443,urlParseFn:Y_,factory:()=>new $_}),dh.connect(i)}const V_=null,I_=null,F_="lt.events";function Zg(i,t){const s=i.split("."),a=t.split(".");for(let o=0;o<a.length;o++){const u=a[o];if(u===">")return!0;if(o>=s.length||u!=="*"&&u!==s[o])return!1}return s.length===a.length}const Dr=A.createContext({connected:!1,subscribe:()=>()=>{}});function J_(){const{connected:i}=A.useContext(Dr);return{connected:i}}function Yj(i,t){const{subscribe:s}=A.useContext(Dr),a=A.useRef(t);a.current=t,A.useEffect(()=>s(i,u=>a.current(u)),[s,i])}function Wg(i,t){const{subscribe:s}=A.useContext(Dr),a=A.useRef(t);a.current=t;const o=i.join(","),u=A.useMemo(()=>o.split(",").filter(Boolean),[o]);A.useEffect(()=>{const d=g=>a.current(g),m=u.map(g=>s(g,d));return()=>m.forEach(g=>g())},[s,u])}const Q_=A.createContext({connected:!1,subscribe:()=>()=>{}}),K_=Mf();function X_({children:i,url:t,token:s}){const a=A.useRef(null),[o,u]=A.useState(!1),d=A.useRef(null),m=A.useRef(new Map),g=A.useRef(new Map),y=A.useCallback((R,M)=>{(async()=>{for await(const D of M)try{if(!Zg(D.subject,R))continue;const G=JSON.parse(K_.decode(D.data)),te=m.current.get(R);if(!te)continue;for(const $ of te)try{$(G)}catch{}}catch{}})()},[]),E=A.useCallback(R=>{var D;const M=a.current;if(!(!M||(D=M.isClosed)!=null&&D.call(M)||g.current.has(R)))try{const G=M.subscribe(R);g.current.set(R,G),y(R,G)}catch{}},[y]),_=A.useCallback((R,M)=>{const D=m.current;return D.has(R)||D.set(R,new Set),D.get(R).add(M),E(R),()=>{const G=D.get(R);if(G&&(G.delete(M),G.size===0)){D.delete(R);const te=g.current.get(R);if(te){g.current.delete(R);try{te.unsubscribe()}catch{}}}}},[E]),N=A.useCallback(async()=>{try{if(a.current)return;const R=t||V_;if(!R){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const M=await G_({servers:R,token:s||I_||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});a.current=M,u(!0);for(const D of m.current.keys())E(D);(async()=>{for await(const D of M.status())D.type==="disconnect"||D.type==="error"?u(!1):D.type==="reconnect"&&u(!0)})()}catch{u(!1),d.current=setTimeout(N,3e3)}},[E]);return A.useEffect(()=>(N(),()=>{d.current&&clearTimeout(d.current);for(const R of g.current.values())try{R.unsubscribe()}catch{}g.current.clear(),a.current&&(a.current.close().catch(()=>{}),a.current=null),u(!1)}),[N]),h.jsx(Q_.Provider,{value:{connected:o,subscribe:_},children:h.jsx(Dr.Provider,{value:{connected:o,subscribe:_},children:i})})}const Vn=Object.create(null);Vn.open="0";Vn.close="1";Vn.ping="2";Vn.pong="3";Vn.message="4";Vn.upgrade="5";Vn.noop="6";const Co=Object.create(null);Object.keys(Vn).forEach(i=>{Co[Vn[i]]=i});const If={type:"error",data:"parser error"},ey=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ty=typeof ArrayBuffer=="function",ny=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,mh=({type:i,data:t},s,a)=>ey&&t instanceof Blob?s?a(t):J0(t,a):ty&&(t instanceof ArrayBuffer||ny(t))?s?a(t):J0(new Blob([t]),a):a(Vn[i]+(t||"")),J0=(i,t)=>{const s=new FileReader;return s.onload=function(){const a=s.result.split(",")[1];t("b"+(a||""))},s.readAsDataURL(i)};function Q0(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let _f;function Z_(i,t){if(ey&&i.data instanceof Blob)return i.data.arrayBuffer().then(Q0).then(t);if(ty&&(i.data instanceof ArrayBuffer||ny(i.data)))return t(Q0(i.data));mh(i,!1,s=>{_f||(_f=new TextEncoder),t(_f.encode(s))})}const K0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",La=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<K0.length;i++)La[K0.charCodeAt(i)]=i;const W_=i=>{let t=i.length*.75,s=i.length,a,o=0,u,d,m,g;i[i.length-1]==="="&&(t--,i[i.length-2]==="="&&t--);const y=new ArrayBuffer(t),E=new Uint8Array(y);for(a=0;a<s;a+=4)u=La[i.charCodeAt(a)],d=La[i.charCodeAt(a+1)],m=La[i.charCodeAt(a+2)],g=La[i.charCodeAt(a+3)],E[o++]=u<<2|d>>4,E[o++]=(d&15)<<4|m>>2,E[o++]=(m&3)<<6|g&63;return y},ew=typeof ArrayBuffer=="function",ph=(i,t)=>{if(typeof i!="string")return{type:"message",data:sy(i,t)};const s=i.charAt(0);return s==="b"?{type:"message",data:tw(i.substring(1),t)}:Co[s]?i.length>1?{type:Co[s],data:i.substring(1)}:{type:Co[s]}:If},tw=(i,t)=>{if(ew){const s=W_(i);return sy(s,t)}else return{base64:!0,data:i}},sy=(i,t)=>{switch(t){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},iy="",nw=(i,t)=>{const s=i.length,a=new Array(s);let o=0;i.forEach((u,d)=>{mh(u,!1,m=>{a[d]=m,++o===s&&t(a.join(iy))})})},sw=(i,t)=>{const s=i.split(iy),a=[];for(let o=0;o<s.length;o++){const u=ph(s[o],t);if(a.push(u),u.type==="error")break}return a};function iw(){return new TransformStream({transform(i,t){Z_(i,s=>{const a=s.length;let o;if(a<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,a);else if(a<65536){o=new Uint8Array(3);const u=new DataView(o.buffer);u.setUint8(0,126),u.setUint16(1,a)}else{o=new Uint8Array(9);const u=new DataView(o.buffer);u.setUint8(0,127),u.setBigUint64(1,BigInt(a))}i.data&&typeof i.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(s)})}})}let wf;function jo(i){return i.reduce((t,s)=>t+s.length,0)}function Ao(i,t){if(i[0].length===t)return i.shift();const s=new Uint8Array(t);let a=0;for(let o=0;o<t;o++)s[o]=i[0][a++],a===i[0].length&&(i.shift(),a=0);return i.length&&a<i[0].length&&(i[0]=i[0].slice(a)),s}function rw(i,t){wf||(wf=new TextDecoder);const s=[];let a=0,o=-1,u=!1;return new TransformStream({transform(d,m){for(s.push(d);;){if(a===0){if(jo(s)<1)break;const g=Ao(s,1);u=(g[0]&128)===128,o=g[0]&127,o<126?a=3:o===126?a=1:a=2}else if(a===1){if(jo(s)<2)break;const g=Ao(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),a=3}else if(a===2){if(jo(s)<8)break;const g=Ao(s,8),y=new DataView(g.buffer,g.byteOffset,g.length),E=y.getUint32(0);if(E>Math.pow(2,21)-1){m.enqueue(If);break}o=E*Math.pow(2,32)+y.getUint32(4),a=3}else{if(jo(s)<o)break;const g=Ao(s,o);m.enqueue(ph(u?g:wf.decode(g),t)),a=0}if(o===0||o>i){m.enqueue(If);break}}}})}const ry=4;function yt(i){if(i)return aw(i)}function aw(i){for(var t in yt.prototype)i[t]=yt.prototype[t];return i}yt.prototype.on=yt.prototype.addEventListener=function(i,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(t),this};yt.prototype.once=function(i,t){function s(){this.off(i,s),t.apply(this,arguments)}return s.fn=t,this.on(i,s),this};yt.prototype.off=yt.prototype.removeListener=yt.prototype.removeAllListeners=yt.prototype.removeEventListener=function(i,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+i];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var a,o=0;o<s.length;o++)if(a=s[o],a===t||a.fn===t){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+i],this};yt.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),s=this._callbacks["$"+i],a=1;a<arguments.length;a++)t[a-1]=arguments[a];if(s){s=s.slice(0);for(var a=0,o=s.length;a<o;++a)s[a].apply(this,t)}return this};yt.prototype.emitReserved=yt.prototype.emit;yt.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};yt.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Xo=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,s)=>s(t,0),wn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),lw="arraybuffer";function ay(i,...t){return t.reduce((s,a)=>(i.hasOwnProperty(a)&&(s[a]=i[a]),s),{})}const ow=wn.setTimeout,cw=wn.clearTimeout;function Zo(i,t){t.useNativeTimers?(i.setTimeoutFn=ow.bind(wn),i.clearTimeoutFn=cw.bind(wn)):(i.setTimeoutFn=wn.setTimeout.bind(wn),i.clearTimeoutFn=wn.clearTimeout.bind(wn))}const uw=1.33;function fw(i){return typeof i=="string"?hw(i):Math.ceil((i.byteLength||i.size)*uw)}function hw(i){let t=0,s=0;for(let a=0,o=i.length;a<o;a++)t=i.charCodeAt(a),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(a++,s+=4);return s}function ly(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dw(i){let t="";for(let s in i)i.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(i[s]));return t}function mw(i){let t={},s=i.split("&");for(let a=0,o=s.length;a<o;a++){let u=s[a].split("=");t[decodeURIComponent(u[0])]=decodeURIComponent(u[1])}return t}class pw extends Error{constructor(t,s,a){super(t),this.description=s,this.context=a,this.type="TransportError"}}class gh extends yt{constructor(t){super(),this.writable=!1,Zo(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,s,a){return super.emitReserved("error",new pw(t,s,a)),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=ph(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=dw(t);return s.length?"?"+s:""}}class gw extends gh{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 a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||s()})),this.writable||(a++,this.once("drain",function(){--a||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const s=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};sw(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,nw(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]=ly()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(t,s)}}let oy=!1;try{oy=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const yw=oy;function bw(){}class xw extends gw{constructor(t){if(super(t),typeof location<"u"){const s=location.protocol==="https:";let a=location.port;a||(a=s?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||a!==t.port}}doWrite(t,s){const a=this.request({method:"POST",data:t});a.on("success",s),a.on("error",(o,u)=>{this.onError("xhr post error",o,u)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(s,a)=>{this.onError("xhr poll error",s,a)}),this.pollXhr=t}}class Yn extends yt{constructor(t,s,a){super(),this.createRequest=t,Zo(this,a),this._opts=a,this._method=a.method||"GET",this._uri=s,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var t;const s=ay(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(s);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&a.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var o;a.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Yn.requestsCount++,Yn.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=bw,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Yn.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()}}Yn.requestsCount=0;Yn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",X0);else if(typeof addEventListener=="function"){const i="onpagehide"in wn?"pagehide":"unload";addEventListener(i,X0,!1)}}function X0(){for(let i in Yn.requests)Yn.requests.hasOwnProperty(i)&&Yn.requests[i].abort()}const vw=(function(){const i=cy({xdomain:!1});return i&&i.responseType!==null})();class _w extends xw{constructor(t){super(t);const s=t&&t.forceBase64;this.supportsBinary=vw&&!s}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Yn(cy,this.uri(),t)}}function cy(i){const t=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||yw))return new XMLHttpRequest}catch{}if(!t)try{return new wn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const uy=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class ww extends gh{get name(){return"websocket"}doOpen(){const t=this.uri(),s=this.opts.protocols,a=uy?{}:ay(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,s,a)}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 a=t[s],o=s===t.length-1;mh(a,this.supportsBinary,u=>{try{this.doWrite(a,u)}catch{}o&&Xo(()=>{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]=ly()),this.supportsBinary||(s.b64=1),this.createUri(t,s)}}const Sf=wn.WebSocket||wn.MozWebSocket;class Sw extends ww{createSocket(t,s,a){return uy?new Sf(t,s,a):s?new Sf(t,s):new Sf(t)}doWrite(t,s){this.ws.send(s)}}class Ew extends gh{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=rw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=t.readable.pipeThrough(s).getReader(),o=iw();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const u=()=>{a.read().then(({done:m,value:g})=>{m||(this.onPacket(g),u())}).catch(m=>{})};u();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 a=t[s],o=s===t.length-1;this._writer.write(a).then(()=>{o&&Xo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const jw={websocket:Sw,webtransport:Ew,polling:_w},Aw=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ow=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ff(i){if(i.length>8e3)throw"URI too long";const t=i,s=i.indexOf("["),a=i.indexOf("]");s!=-1&&a!=-1&&(i=i.substring(0,s)+i.substring(s,a).replace(/:/g,";")+i.substring(a,i.length));let o=Aw.exec(i||""),u={},d=14;for(;d--;)u[Ow[d]]=o[d]||"";return s!=-1&&a!=-1&&(u.source=t,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=Nw(u,u.path),u.queryKey=Tw(u,u.query),u}function Nw(i,t){const s=/\/{2,9}/g,a=t.replace(s,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&a.splice(0,1),t.slice(-1)=="/"&&a.splice(a.length-1,1),a}function Tw(i,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,o,u){o&&(s[o]=u)}),s}const Jf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Mo=[];Jf&&addEventListener("offline",()=>{Mo.forEach(i=>i())},!1);class Ws extends yt{constructor(t,s){if(super(),this.binaryType=lw,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 a=Ff(t);s.hostname=a.host,s.secure=a.protocol==="https"||a.protocol==="wss",s.port=a.port,a.query&&(s.query=a.query)}else s.host&&(s.hostname=Ff(s.host).host);Zo(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(a=>{const o=a.prototype.name;this.transports.push(o),this._transportsByName[o]=a}),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=mw(this.opts.query)),Jf&&(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"})},Mo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const s=Object.assign({},this.opts.query);s.EIO=ry,s.transport=t,this.id&&(s.sid=this.id);const a=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](a)}_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 a=0;a<this.writeBuffer.length;a++){const o=this.writeBuffer[a].data;if(o&&(s+=fw(o)),a>0&&s>this._maxPayload)return this.writeBuffer.slice(0,a);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Xo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,a){return this._sendPacket("message",t,s,a),this}send(t,s,a){return this._sendPacket("message",t,s,a),this}_sendPacket(t,s,a,o){if(typeof s=="function"&&(o=s,s=void 0),typeof a=="function"&&(o=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const u={type:t,data:s,options:a};this.emitReserved("packetCreate",u),this.writeBuffer.push(u),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()},a=()=>{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?a():t()}):this.upgrading?a():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(),Jf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=Mo.indexOf(this._offlineEventListener);a!==-1&&Mo.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}Ws.protocol=ry;class kw 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),a=!1;Ws.priorWebsocketSuccess=!1;const o=()=>{a||(s.send([{type:"ping",data:"probe"}]),s.once("packet",_=>{if(!a)if(_.type==="pong"&&_.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Ws.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(E(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const N=new Error("probe error");N.transport=s.name,this.emitReserved("upgradeError",N)}}))};function u(){a||(a=!0,E(),s.close(),s=null)}const d=_=>{const N=new Error("probe error: "+_);N.transport=s.name,u(),this.emitReserved("upgradeError",N)};function m(){d("transport closed")}function g(){d("socket closed")}function y(_){s&&_.name!==s.name&&u()}const E=()=>{s.removeListener("open",o),s.removeListener("error",d),s.removeListener("close",m),this.off("close",g),this.off("upgrading",y)};s.once("open",o),s.once("error",d),s.once("close",m),this.once("close",g),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{a||s.open()},200):s.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const s=[];for(let a=0;a<t.length;a++)~this.transports.indexOf(t[a])&&s.push(t[a]);return s}}let Cw=class extends kw{constructor(t,s={}){const a=typeof t=="object"?t:s;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(o=>jw[o]).filter(o=>!!o)),super(t,a)}};function Mw(i,t="",s){let a=i;s=s||typeof location<"u"&&location,i==null&&(i=s.protocol+"//"+s.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=s.protocol+i:i=s.host+i),/^(https?|wss?):\/\//.test(i)||(typeof s<"u"?i=s.protocol+"//"+i:i="https://"+i),a=Ff(i)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const u=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+u+":"+a.port+t,a.href=a.protocol+"://"+u+(s&&s.port===a.port?"":":"+a.port),a}const Rw=typeof ArrayBuffer=="function",Dw=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,fy=Object.prototype.toString,qw=typeof Blob=="function"||typeof Blob<"u"&&fy.call(Blob)==="[object BlobConstructor]",zw=typeof File=="function"||typeof File<"u"&&fy.call(File)==="[object FileConstructor]";function yh(i){return Rw&&(i instanceof ArrayBuffer||Dw(i))||qw&&i instanceof Blob||zw&&i instanceof File}function Ro(i,t){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let s=0,a=i.length;s<a;s++)if(Ro(i[s]))return!0;return!1}if(yh(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ro(i.toJSON(),!0);for(const s in i)if(Object.prototype.hasOwnProperty.call(i,s)&&Ro(i[s]))return!0;return!1}function Uw(i){const t=[],s=i.data,a=i;return a.data=Qf(s,t),a.attachments=t.length,{packet:a,buffers:t}}function Qf(i,t){if(!i)return i;if(yh(i)){const s={_placeholder:!0,num:t.length};return t.push(i),s}else if(Array.isArray(i)){const s=new Array(i.length);for(let a=0;a<i.length;a++)s[a]=Qf(i[a],t);return s}else if(typeof i=="object"&&!(i instanceof Date)){const s={};for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&(s[a]=Qf(i[a],t));return s}return i}function Bw(i,t){return i.data=Kf(i.data,t),delete i.attachments,i}function Kf(i,t){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<t.length)return t[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let s=0;s<i.length;s++)i[s]=Kf(i[s],t);else if(typeof i=="object")for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&(i[s]=Kf(i[s],t));return i}const Lw=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Be;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(Be||(Be={}));class Pw{constructor(t){this.replacer=t}encode(t){return(t.type===Be.EVENT||t.type===Be.ACK)&&Ro(t)?this.encodeAsBinary({type:t.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let s=""+t.type;return(t.type===Be.BINARY_EVENT||t.type===Be.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=Uw(t),a=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(a),o}}class bh extends yt{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 a=s.type===Be.BINARY_EVENT;a||s.type===Be.BINARY_ACK?(s.type=a?Be.EVENT:Be.ACK,this.reconstructor=new Hw(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(yh(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 a={type:Number(t.charAt(0))};if(Be[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===Be.BINARY_EVENT||a.type===Be.BINARY_ACK){const u=s+1;for(;t.charAt(++s)!=="-"&&s!=t.length;);const d=t.substring(u,s);if(d!=Number(d)||t.charAt(s)!=="-")throw new Error("Illegal attachments");const m=Number(d);if(!$w(m)||m<0)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");a.attachments=m}if(t.charAt(s+1)==="/"){const u=s+1;for(;++s&&!(t.charAt(s)===","||s===t.length););a.nsp=t.substring(u,s)}else a.nsp="/";const o=t.charAt(s+1);if(o!==""&&Number(o)==o){const u=s+1;for(;++s;){const d=t.charAt(s);if(d==null||Number(d)!=d){--s;break}if(s===t.length)break}a.id=Number(t.substring(u,s+1))}if(t.charAt(++s)){const u=this.tryParse(t.substr(s));if(bh.isPayloadValid(a.type,u))a.data=u;else throw new Error("invalid payload")}return a}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,s){switch(t){case Be.CONNECT:return Z0(s);case Be.DISCONNECT:return s===void 0;case Be.CONNECT_ERROR:return typeof s=="string"||Z0(s);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&Lw.indexOf(s[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Hw{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=Bw(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const $w=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function Z0(i){return Object.prototype.toString.call(i)==="[object Object]"}const Yw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:bh,Encoder:Pw,get PacketType(){return Be}},Symbol.toStringTag,{value:"Module"}));function Cn(i,t,s){return i.on(t,s),function(){i.off(t,s)}}const Gw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class hy extends yt{constructor(t,s,a){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,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Cn(t,"open",this.onopen.bind(this)),Cn(t,"packet",this.onpacket.bind(this)),Cn(t,"error",this.onerror.bind(this)),Cn(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 a,o,u;if(Gw.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:Be.EVENT,data:s};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const E=this.ids++,_=s.pop();this._registerAckCallback(E,_),d.id=E}const m=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((u=this.io.engine)===null||u===void 0)&&u._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(t,s){var a;const o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[t]=s;return}const u=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===t&&this.sendBuffer.splice(m,1);s.call(this,new Error("operation has timed out"))},o),d=(...m)=>{this.io.clearTimeoutFn(u),s.apply(this,m)};d.withError=!0,this.acks[t]=d}emitWithAck(t,...s){return new Promise((a,o)=>{const u=(d,m)=>d?o(d):a(m);u.withError=!0,s.push(u),this.emit(t,...s)})}_addToQueue(t){let s;typeof t[t.length-1]=="function"&&(s=t.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...u)=>(this._queue[0],o!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...u)),a.pending=!1,this._drainQueue())),this._queue.push(a),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:Be.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(a=>String(a.id)===t)){const a=this.acks[t];delete this.acks[t],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Be.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 Be.EVENT:case Be.BINARY_EVENT:this.onevent(t);break;case Be.ACK:case Be.BINARY_ACK:this.onack(t);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.CONNECT_ERROR:this.destroy();const a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);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 a of s)a.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 a=!1;return function(...o){a||(a=!0,s.packet({type:Be.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:Be.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 a=0;a<s.length;a++)if(t===s[a])return s.splice(a,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 a=0;a<s.length;a++)if(t===s[a])return s.splice(a,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 a of s)a.apply(this,t.data)}}}function qr(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}qr.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*i);i=(Math.floor(t*10)&1)==0?i-s:i+s}return Math.min(i,this.max)|0};qr.prototype.reset=function(){this.attempts=0};qr.prototype.setMin=function(i){this.ms=i};qr.prototype.setMax=function(i){this.max=i};qr.prototype.setJitter=function(i){this.jitter=i};class Xf extends yt{constructor(t,s){var a;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,Zo(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((a=s.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new qr({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||Yw;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 Cw(this.uri,this.opts);const s=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const o=Cn(s,"open",function(){a.onopen(),t&&t()}),u=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),t?t(m):this.maybeReconnectOnOpen()},d=Cn(s,"error",u);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{o(),u(new Error("timeout")),s.close()},m);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(Cn(t,"ping",this.onping.bind(this)),Cn(t,"data",this.ondata.bind(this)),Cn(t,"error",this.onerror.bind(this)),Cn(t,"close",this.onclose.bind(this)),Cn(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){Xo(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,s){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new hy(this,t,s),this.nsps[t]=a),a}_destroy(t){const s=Object.keys(this.nsps);for(const a of s)if(this.nsps[a].active)return;this._close()}_packet(t){const s=this.encoder.encode(t);for(let a=0;a<s.length;a++)this.engine.write(s[a],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 a;this.cleanup(),(a=this.engine)===null||a===void 0||a.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 a=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&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Ra={};function Do(i,t){typeof i=="object"&&(t=i,i=void 0),t=t||{};const s=Mw(i,t.path||"/socket.io"),a=s.source,o=s.id,u=s.path,d=Ra[o]&&u in Ra[o].nsps,m=t.forceNew||t["force new connection"]||t.multiplex===!1||d;let g;return m?g=new Xf(a,t):(Ra[o]||(Ra[o]=new Xf(a,t)),g=Ra[o]),s.query&&!t.query&&(t.query=s.queryKey),g.socket(s.path,t)}Object.assign(Do,{Manager:Xf,Socket:hy,io:Do,connect:Do});const Vw=A.createContext({connected:!1,subscribe:()=>()=>{}});function Iw({children:i}){const t=A.useRef(null),[s,a]=A.useState(!1),o=A.useRef(new Map),u=A.useCallback((m,g)=>{var E;const y=o.current;return y.has(m)||(y.set(m,new Set),(E=t.current)==null||E.emit("lt.subscribe",m)),y.get(m).add(g),()=>{var N;const _=y.get(m);_&&(_.delete(g),_.size===0&&(y.delete(m),(N=t.current)==null||N.emit("lt.unsubscribe",m)))}},[]),d=A.useCallback((m,g)=>{for(const[y,E]of o.current)if(Zg(m,y))for(const _ of E)try{_(g)}catch{}},[]);return A.useEffect(()=>{const m=Rg(),g=Do({path:`${Tt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,...m?{auth:{token:m}}:{}});return t.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),a(!0);for(const y of o.current.keys())g.emit("lt.subscribe",y)}),g.on("disconnect",y=>{console.log("[lt-socketio] disconnected:",y),a(!1)}),g.on("connect_error",y=>{console.warn("[lt-socketio] connect error:",y.message),a(!1)}),g.onAny((y,E)=>{if(y.startsWith("lt."))try{const _=typeof E=="string"?JSON.parse(E):E;d(y,_)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),t.current=null,a(!1)}},[d]),h.jsx(Vw.Provider,{value:{connected:s,subscribe:u},children:h.jsx(Dr.Provider,{value:{connected:s,subscribe:u},children:i})})}function Fw({children:i}){const[t,s]=A.useState(null),[a,o]=A.useState({url:null,token:null});return A.useEffect(()=>{let u=!1;async function d(){var m;try{console.log("[lt-transport] detecting event transport...");const g=await fetch(`${Tt}/api/settings`);if(!g.ok){console.warn("[lt-transport] settings fetch failed, falling back to socketio"),u||s("socketio");return}const y=await g.json(),E=(m=y==null?void 0:y.events)==null?void 0:m.transport;if(console.log("[lt-transport] server reports:",E),!u){if(E==="nats"){let _=y.events.natsWsUrl??null,N=null;const R=Rg();if(R)try{const M=await fetch(`${Tt}/api/nats-credentials`,{headers:{Authorization:`Bearer ${R}`}});if(M.ok){const D=await M.json();_=D.natsWsUrl??_,N=D.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}o({url:_,token:N})}s(E==="nats"?"nats":"socketio")}}catch(g){console.warn("[lt-transport] settings fetch error, falling back to socketio",g),u||s("socketio")}}return d(),()=>{u=!0}},[]),t==="nats"?h.jsx(X_,{url:a.url,token:a.token,children:i}):t==="socketio"?h.jsx(Iw,{children:i}):h.jsx(h.Fragment,{children:i})}const xh="lt_view_as",vh="lt_ai_override",Zf="lt_graph_enabled";function dy(){try{const i=localStorage.getItem(vh);if(i==="true")return!0;if(i==="false")return!1}catch{}return null}function Jw(i){try{localStorage.setItem(vh,String(i))}catch{}}function Qw(){try{localStorage.removeItem(vh)}catch{}}function _h(){try{const i=localStorage.getItem(xh);if(i==="admin"||i==="engineer"||i==="operator")return i}catch{}return null}function Kw(i){try{localStorage.setItem(xh,i)}catch{}window.location.reload()}function Wf(){try{localStorage.removeItem(xh)}catch{}window.location.reload()}function my(){try{return localStorage.getItem(Zf)==="true"}catch{return!1}}function Xw(i){try{i?localStorage.setItem(Zf,"true"):localStorage.removeItem(Zf)}catch{}}function py(){const{isSuperAdmin:i,hasRoleType:t,hasRole:s}=Dn(),a=_h(),o=i||s("engineer"),u=t("admin"),d=i||t("admin");return{isBuilder:a?!1:o,isOps:a?a==="admin"||a==="engineer":u,canBulk:a?a==="admin":d,viewAs:a,realIsBuilder:o}}function gy(){const{isSuperAdmin:i,hasRoleType:t,hasRole:s}=Dn(),a=i?"superadmin":t("admin")?"admin":s("engineer")?"engineer":"operator",o=_h(),u=o==="admin"||o==="engineer"||o==="operator"?o:null,d=u??a;return{tier:d,realTier:a,viewAs:u,canSeePaceBoard:d==="superadmin"||d==="admin",canSeeWorkflows:d==="superadmin"||d==="engineer",showTaskQueueCards:d==="operator"}}const Zw="lt_ai_override";function Ww(){return we("/settings")}function eS(){try{if(localStorage.getItem(Zw)==="off")return!1}catch{}return null}function Mi(){var s;const i=ht({queryKey:["settings"],queryFn:Ww,staleTime:1/0}),t=eS();return i.data&&t===!1&&((s=i.data.ai)!=null&&s.enabled)?{...i,data:{...i.data,ai:{enabled:!1}}}:i}const wh=A.createContext(null),Ef="lt_sidebar_collapsed",yy="(max-width: 1023px)";function tS(){try{return window.matchMedia(yy).matches}catch{return!1}}function nS({children:i}){const[t,s]=A.useState(()=>{if(tS())return!0;try{return localStorage.getItem(Ef)==="true"}catch{return!1}});A.useEffect(()=>{let o;try{o=window.matchMedia(yy)}catch{return}const u=d=>{if(d.matches)s(!0);else try{s(localStorage.getItem(Ef)==="true")}catch{s(!1)}};return o.addEventListener("change",u),()=>o.removeEventListener("change",u)},[]);const a=A.useCallback(()=>{s(o=>{const u=!o;try{localStorage.setItem(Ef,String(u))}catch{}return u})},[]);return h.jsx(wh.Provider,{value:{collapsed:t,toggle:a},children:i})}function sS({children:i}){return h.jsx(wh.Provider,{value:{collapsed:!1,toggle:()=>{}},children:i})}function Sh(){const i=A.useContext(wh);if(!i)throw new Error("useSidebar must be used within SidebarProvider");return i}const W0=380,Eh=A.createContext(null);function iS({children:i}){const[t,s]=A.useState({node:null,width:W0,open:!1,ownerKey:null}),a=Sn(),o=A.useRef(a.pathname),u=A.useCallback((m,g)=>{s({node:m,width:(g==null?void 0:g.width)??W0,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),d=A.useCallback(m=>{s(g=>typeof m=="string"&&g.ownerKey!==m?g:{...g,open:!1})},[]);return A.useEffect(()=>{a.pathname!==o.current&&(o.current=a.pathname,s(m=>m.open||m.node?{...m,node:null,open:!1,ownerKey:null}:m))},[a.pathname]),h.jsx(Eh.Provider,{value:{...t,setPanel:u,closePanel:d},children:i})}function rS(){const i=A.useContext(Eh);if(!i)throw new Error("useShellPanel must be used within ShellPanelProvider");return i}function Vj(){return A.useContext(Eh)}function aS({open:i,width:t=380,children:s,className:a=""}){const[o,u]=A.useState(i);return A.useEffect(()=>{i&&u(!0)},[i]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${a}`,style:{width:i?t:0,maxWidth:"50%"},onTransitionEnd:d=>{!i&&d.propertyName==="width"&&u(!1)},children:h.jsx("div",{style:{width:t},className:"h-full",children:o?s:null})})}function Ij({label:i,children:t}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:i}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:t})]})}function Fj({views:i,activeId:t,onViewChange:s,onClose:a,headerActions:o,stickyClassName:u}){const d=i.find(m=>m.id===t)??i[0];return d?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${u??"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 pt-3 shrink-0",children:[h.jsx("div",{className:"flex items-center gap-1",role:"radiogroup","aria-label":"Panel view",children:i.map(m=>{const g=m.icon,y=m.id===d.id;return h.jsx("button",{role:"radio","aria-checked":y,onClick:()=>s(m.id),title:m.label,className:`p-1.5 rounded-md transition-colors ${y?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:h.jsx(g,{className:"w-3.5 h-3.5"})},m.id)})}),h.jsxs("div",{className:"flex items-center gap-1",children:[o,a&&h.jsx("button",{onClick:a,title:"Close panel",className:"p-1 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors",children:h.jsx(Gn,{className:"w-3.5 h-3.5"})})]})]}),h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:d.label}),h.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5 pt-1",children:d.content})]})}):null}function by(i,t){var s,a,o,u,d;t.facets&&Object.keys(t.facets).length&&i.set("facets",JSON.stringify(t.facets)),(s=t.block)!=null&&s.length&&i.set("block",JSON.stringify(t.block)),(a=t.range)!=null&&a.length&&i.set("range",JSON.stringify(t.range)),(o=t.exists)!=null&&o.length&&i.set("exists",JSON.stringify(t.exists)),(u=t.roles)!=null&&u.length&&i.set("roles",JSON.stringify(t.roles)),(d=t.orderBy)!=null&&d.length&&i.set("orderBy",JSON.stringify(t.orderBy)),t.available!==void 0&&i.set("available",String(t.available)),t.jeopardy===!0&&i.set("jeopardy","1")}function Jj(i,t){const s=i??"24h";return ht({queryKey:["stationMetrics",s],queryFn:()=>we(`/escalations/station-metrics?period=${s}`),staleTime:5e3,enabled:(t==null?void 0:t.enabled)??!0})}function Qj(i){const t=i?`?period=${i}`:"";return ht({queryKey:["escalationStats",i],queryFn:()=>we(`/escalations/stats${t}`)})}function Kj(){return ht({queryKey:["escalationTypes"],queryFn:()=>we("/escalations/types")})}function Xj(i=!0){return ht({queryKey:["escalationFacetKeys"],queryFn:()=>we("/escalations/facet-keys"),enabled:i,staleTime:6e4})}function xy(i){const{enabled:t=!0,staleTime:s,...a}=i,o=new URLSearchParams;return a.status&&o.set("status",a.status),a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.assigned_to&&o.set("assigned_to",a.assigned_to),a.claimed&&o.set("claimed","true"),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),by(o,a),ht({queryKey:["escalations",a],queryFn:()=>we(`/escalations?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function vy(i){const{enabled:t=!0,staleTime:s,...a}=i,o=new URLSearchParams;return a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),by(o,a),ht({queryKey:["escalations","available",a],queryFn:()=>we(`/escalations/available?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function Zj(i){return ht({queryKey:["escalations","by-workflow",i],queryFn:()=>we(`/escalations/by-workflow/${i}`),enabled:!!i})}function Wj(i){return ht({queryKey:["escalations",i],queryFn:()=>we(`/escalations/${i}`),enabled:!!i})}function eA(){const i=bt();return Et({mutationFn:({id:t,durationMinutes:s})=>we(`/escalations/${t}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function tA(){const i=bt();return Et({mutationFn:t=>we(`/escalations/${t}/release`,{method:"POST"}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function nA(){const i=bt();return Et({mutationFn:({id:t,resolverPayload:s})=>we(`/escalations/${t}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]}),i.resetQueries({queryKey:["tasks"]}),i.resetQueries({queryKey:["jobs"]})}})}function sA(){const i=bt();return Et({mutationFn:({id:t,targetRole:s})=>we(`/escalations/${t}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function iA(){const i=bt();return Et({mutationFn:({ids:t,priority:s})=>we("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:t,priority:s})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function rA(){const i=bt();return Et({mutationFn:({ids:t,durationMinutes:s})=>we("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:t,durationMinutes:s})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function aA(){const i=bt();return Et({mutationFn:({ids:t,targetUserId:s,durationMinutes:a})=>we("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:t,targetUserId:s,durationMinutes:a})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function lA(){const i=bt();return Et({mutationFn:({ids:t,targetRole:s})=>we("/escalations/bulk-escalate",{method:"PATCH",body:JSON.stringify({ids:t,targetRole:s})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function oA(){const i=bt();return Et({mutationFn:({ids:t,hint:s})=>we("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:t,...s?{hint:s}:{}})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function cA(){const i=bt();return Et({mutationFn:t=>we(`/escalations/${t}/cancel`,{method:"POST"}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function uA(){const i=bt();return Et({mutationFn:({ids:t})=>we("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function _y(i){return(i??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function eh(i={}){const t=i.role?_y(i.role):"*",s=i.id??"*",a=i.verb??">";return`${F_}.system.escalation.${t}.${s}.${a}`}function fA(i){return i.verbs.map(t=>eh({role:i.role,verb:t}))}function wy(){const{user:i,isSuperAdmin:t,hasRoleType:s}=Dn(),a=t||s("admin"),o=((i==null?void 0:i.roles)??[]).map(u=>u.role).sort().join(",");return A.useMemo(()=>a||!o?[eh({})]:o.split(",").map(u=>eh({role:u})),[a,o])}function lS(){const{user:i}=Dn(),t=i==null?void 0:i.userId,s=bt(),a=A.useRef(null),o=A.useCallback(()=>{a.current||(a.current=setTimeout(()=>{a.current=null,s.invalidateQueries({queryKey:["escalations"]})},15e3))},[s]);Wg(wy(),o);const{data:u}=vy({limit:1}),{data:d}=xy({assigned_to:t,status:"pending",limit:1});return{available:(u==null?void 0:u.total)??0,mine:(d==null?void 0:d.total)??0}}function Yo({size:i="sm",hideLabel:t=!1,className:s="",appName:a="LongTail",variant:o="full"}){const u=i==="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":a,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Tt}/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":a,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Tt}/logo512.png)`}})});const d=u?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-40 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-40 -ml-8",m=u?"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":a,className:`logo-mark shrink-0 z-0 ${d}`,style:{"--logo-url":`url(${Tt}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${m} ${t?"opacity-0":""}`,children:a})]})}const oS=[{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"}],cS=["operator","engineer","admin","superadmin"];function eg(i){return cS.indexOf(i)}function uS(i,t){return eg(i)>=eg(t)}function fS({onClose:i}){var ie,Oe,ke,Se,z,ne;const{isSuperAdmin:t,hasRoleType:s,hasRole:a}=Dn(),{data:o}=Mi(),u=_h(),d=!!((ie=o==null?void 0:o.ai)!=null&&ie.enabled),m=dy(),g=m!==null?m:d,[y,E]=A.useState(g),_=(Oe=o==null?void 0:o.features)==null?void 0:Oe.graphWorkflows,N=_==null,[R,M]=A.useState(_===!0||N&&my()),D=t?"superadmin":s("admin")?"admin":a("engineer")?"engineer":"operator",G=((ke=o==null?void 0:o.branding)==null?void 0:ke.appName)??"LongTail",te=(Se=o==null?void 0:o.environment)==null?void 0:Se.longTailVersion,$=(z=o==null?void 0:o.environment)==null?void 0:z.hotmeshVersion,ce=(ne=o==null?void 0:o.environment)==null?void 0:ne.nodeEnv;A.useEffect(()=>{const se=ge=>{ge.key==="Escape"&&i()};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[i]);const oe=oS.filter(se=>uS(D,se.minTier)),O=oe.length>1,J=[...O?[{id:"viewas",label:"View As",icon:lv}]:[],{id:"features",label:"Features",icon:ov}],[ae,I]=A.useState(J[0].id),F=se=>{se===null?Wf():Kw(se)},Z=()=>{const se=!y;E(se),se===d?Qw():Jw(se),window.location.reload()},re=()=>{const se=!R;M(se),Xw(se),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:i,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:se=>se.stopPropagation(),children:[h.jsx("button",{onClick:i,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Gn,{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(${Tt}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:G}),te&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",te,$&&h.jsxs(h.Fragment,{children:[" · HotMesh v",$]}),ce&&ce!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:ce})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),J.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:J.map(se=>{const ge=ae===se.id;return h.jsxs("button",{role:"tab","aria-selected":ge,onClick:()=>I(se.id),title:se.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${ge?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(se.icon,{className:"w-5 h-5",strokeWidth:1.5,...ge?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:se.label})]},se.id)})}),ae==="viewas"&&O&&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"}),oe.map(se=>{const ge=u===se.id,be=se.id===null?`Your view · ${D}`:se.label;return h.jsxs("button",{onClick:()=>F(se.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 ${ge?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:ge&&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 ${ge?"text-accent":"text-text-primary group-hover:text-accent"}`,children:be}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:se.description})]})]},String(se.id))})]}),ae==="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:Z,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:y?"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 ${y?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${y?"translate-x-4":"translate-x-0"}`})})]}),N&&h.jsxs("button",{onClick:re,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:R?"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 ${R?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${R?"translate-x-4":"translate-x-0"}`})})]})]}),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 Sy=[{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"}],tg="blue",Ey="lt.theme";let jy=[];function hS(i){const t=new Set(Sy.map(a=>a.id)),s=new Set;jy=i.filter(a=>!(a!=null&&a.id)||t.has(a.id)||s.has(a.id)?!1:(s.add(a.id),!0))}function dS(){return[...Sy,...jy]}function Ay(){try{return localStorage.getItem(Ey)||tg}catch{return tg}}function Oy(i){document.documentElement.dataset.theme=i}function mS(i){try{localStorage.setItem(Ey,i)}catch{}Oy(i)}const Ny="lt:bookmarks";function pS(){try{const i=localStorage.getItem(Ny);if(!i)return[];const t=JSON.parse(i);return Array.isArray(t)?t:[]}catch{return[]}}function ng(i){try{localStorage.setItem(Ny,JSON.stringify(i))}catch{}}function gS({onToggleEventFeed:i,onToggleDocs:t,onToggleNav:s}){var ke,Se;const a=nh(),{user:o,logout:u}=Dn(),{isBuilder:d,isOps:m,viewAs:g,realIsBuilder:y}=py(),{available:E,mine:_}=lS();gy();const{connected:N}=J_(),{data:R}=Mi(),M=Sn(),[D,G]=A.useState(!1),[te,$]=A.useState(!1),[ce,oe]=A.useState(Ay),[O,J]=A.useState(pS),ae=A.useRef(null),I=(ke=R==null?void 0:R.branding)==null?void 0:ke.appName,F=(Se=R==null?void 0:R.branding)==null?void 0:Se.themes,Z=A.useMemo(()=>(hS(F??[]),dS()),[F]),re=z=>{mS(z),oe(z)},ie=()=>{const z=window.prompt("Bookmark label:");if(!(z!=null&&z.trim()))return;const ne=M.pathname+M.search,se=[...O,{label:z.trim(),url:ne}].sort((ge,be)=>ge.label.localeCompare(be.label));J(se),ng(se),G(!1)},Oe=z=>{const ne=O.filter(se=>!(se.label===z.label&&se.url===z.url));J(ne),ng(ne)};return A.useEffect(()=>{if(!D)return;const z=ne=>{ae.current&&!ae.current.contains(ne.target)&&G(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[D]),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 ${D?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 min-w-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(cv,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsxs(Ni,{to:"/","aria-label":"Home",className:"shrink-0",onClick:z=>{(z.ctrlKey||z.metaKey)&&(z.preventDefault(),$(!0))},children:[h.jsx(Yo,{appName:I,className:"hidden lg:flex"}),h.jsx(Yo,{appName:I,variant:"comet",className:"flex lg:hidden"})]}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>a(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(Ag,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>a(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(Nf,{className:"w-5 h-5",strokeWidth:2})})]}),h.jsxs("div",{className:"flex items-center gap-5",children:[h.jsxs(Ni,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${E>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(Tf,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),E>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:E})]}),h.jsxs(Ni,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${_>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(Tf,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),_>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:_})]}),(d||m)&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),h.jsxs("button",{type:"button",onClick:()=>{N?i==null||i():window.location.reload()},className:`hidden lg:flex items-center gap-1.5 text-xs transition-colors ${N?"text-status-success hover:text-status-success/80":"text-text-quaternary hover:text-text-secondary"}`,title:N?"Live events — click to toggle feed":"Events disconnected — click to reconnect",children:[h.jsx(Og,{className:"w-4 h-4",strokeWidth:1.5}),"events"]})]}),y&&h.jsx(h.Fragment,{children:h.jsxs("button",{onClick:t,className:"hidden lg:flex items-center gap-1.5 text-xs text-text-quaternary hover:text-text-secondary transition-colors",title:"Documentation",children:[h.jsx(Ng,{className:"w-4 h-4",strokeWidth:1.5}),"docs"]})}),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:Wf,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Gn,{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:ae,children:[h.jsxs("button",{onClick:()=>G(z=>!z),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(uv,{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"})})]}),D&&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(Ni,{to:"/credentials",onClick:()=>G(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),(d||m)&&h.jsx("button",{onClick:()=>{G(!1),N?i==null||i():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:N?"Events":"Reconnect events"}),y&&h.jsx("button",{onClick:()=>{G(!1),t==null||t()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{G(!1),Wf()},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:Z.map(z=>h.jsx("button",{type:"button",onClick:()=>re(z.id),title:z.label,"aria-label":`${z.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${ce===z.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:z.swatch}},z.id))})]}),h.jsx("button",{onClick:()=>{G(!1),u()},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:[O.map(z=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(Ni,{to:z.url,onClick:()=>G(!1),title:z.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:z.label}),h.jsx("button",{type:"button",onClick:()=>Oe(z),title:`Remove "${z.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(Gn,{className:"w-3 h-3"})})]},`${z.label}::${z.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:ie,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(fv,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),te&&h.jsx(fS,{onClose:()=>$(!1)})]})}function jh({open:i,children:t}){const[s,a]=A.useState(i);return A.useEffect(()=>{i&&a(!0)},[i]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${i?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{i||a(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?t:null})})}function th(i){return({isActive:t})=>{const s="flex items-center rounded-md transition-colors duration-150",a="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return i?`${s} justify-center w-10 h-10 mx-auto ${t?a:o}`:`${s} gap-3 px-4 py-2 text-sm ${t?a:o}`}}function yS(){return({isActive:i})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${i?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function bS({group:i,collapsed:t}){const{pathname:s}=Sn(),a=i.matchPaths.some(m=>s.startsWith(m)),[o,u]=A.useState(a),d=o||a;return t?h.jsx(h.Fragment,{children:i.items.map(m=>h.jsx(Tr,{to:m.to,className:th(!0),title:m.label,children:m.icon&&h.jsx(m.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},m.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>u(m=>!m),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:[i.icon&&h.jsx(i.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:i.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(jh,{open:d,children:i.items.map(m=>h.jsxs(Tr,{to:m.to,end:m.end,className:yS(),children:[m.icon&&h.jsx(m.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:m.label})]},m.to))})]})}function xS(i){return i.kind==="group"}function vS({entry:i,collapsed:t}){const{pathname:s,search:a}=Sn(),o=i.to.includes("?"),u=i.icon&&h.jsx(i.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${i.iconClassName??""}`,strokeWidth:1.5,...i.solid?{fill:"currentColor"}:{}});if(o){const[d,m]=i.to.split("?"),g=s===d&&a===`?${m}`,y=th(t)({isActive:g});return h.jsxs(Tr,{to:i.to,className:y,title:t?i.label:void 0,children:[u,!t&&h.jsx("span",{children:i.label})]})}return h.jsxs(Tr,{to:i.to,end:i.end,className:th(t),title:t?i.label:void 0,children:[u,!t&&h.jsx("span",{children:i.label})]})}function ki({heading:i,entries:t}){const{collapsed:s}=Sh();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:i}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:i}),t.map(a=>xS(a)?h.jsx(bS,{group:a,collapsed:s},a.label):h.jsx(vS,{entry:a,collapsed:s},a.to))]})}function _S({aiEnabled:i=!1,isBuilder:t=!1,isOps:s=!1,viewAs:a=null,canSeePaceBoard:o=!1}){const u={to:"/operations",label:"Pace Board",icon:hv};if(!t&&(!s||a==="engineer"||a==="operator"))return null;if(!t)return h.jsx(ki,{heading:"Monitor",entries:o?[u]:[]});const d=[...o?[u]:[],{to:"/topics",label:"Event Topics",icon:Og},{to:"/agents",label:i?"Agents":"Automations",icon:dv},{to:"/capabilities",label:"Capabilities",icon:mv}];return h.jsx(ki,{heading:"Monitor",entries:d})}function hA(){return ht({queryKey:["roles"],queryFn:()=>we("/roles")})}function dA(){return ht({queryKey:["roles","escalation-chains"],queryFn:()=>we("/roles/escalation-chains")})}function mA(i){return ht({queryKey:["roles",i,"escalation-targets"],queryFn:()=>we(`/roles/${encodeURIComponent(i)}/escalation-targets`),enabled:!!i})}function pA(){const i=bt();return Et({mutationFn:t=>we("/roles/escalation-chains",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function gA(){const i=bt();return Et({mutationFn:t=>we("/roles/escalation-chains",{method:"DELETE",body:JSON.stringify(t)}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function wS(i){return ht({queryKey:["roles","details"],queryFn:()=>we("/roles/details"),enabled:(i==null?void 0:i.enabled)??!0})}function yA(i,t,s=!0){return ht({queryKey:["roles",i,"schema",t??"latest"],queryFn:()=>we(`/roles/${encodeURIComponent(i)}/schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!i})}function bA(i){return ht({queryKey:["roles",i,"schema-versions"],queryFn:()=>we(`/roles/${encodeURIComponent(i)}/schema/versions`),enabled:!!i})}function xA(i,t,s=!0){return ht({queryKey:["roles",i,"list-schema",t??"latest"],queryFn:()=>we(`/roles/${encodeURIComponent(i)}/list-schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!i})}function vA(i){return ht({queryKey:["roles",i,"list-schema-versions"],queryFn:()=>we(`/roles/${encodeURIComponent(i)}/list-schema/versions`),enabled:!!i})}function _A(){const i=bt();return Et({mutationFn:t=>we("/roles",{method:"POST",body:JSON.stringify({role:t})}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function wA(){const i=bt();return Et({mutationFn:({role:t,...s})=>we(`/roles/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:t,...s})=>{await i.cancelQueries({queryKey:["roles","details"]});const a=i.getQueryData(["roles","details"]);return a&&i.setQueryData(["roles","details"],{roles:a.roles.map(o=>o.role===t?{...o,...s}:o)}),{previous:a}},onError:(t,s,a)=>{a!=null&&a.previous&&i.setQueryData(["roles","details"],a.previous)},onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function SA(){const i=bt();return Et({mutationFn:t=>we(`/roles/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function SS(){return ht({queryKey:["me","preferences"],queryFn:()=>we("/me/preferences"),staleTime:6e4})}function ES(){const i=bt();return Et({mutationFn:t=>we("/me/preferences",{method:"PATCH",body:JSON.stringify(t)}),onSuccess:t=>{i.setQueryData(["me","preferences"],t)}})}const vr=i=>{if(i)try{return JSON.parse(i)}catch{return}},Ai=i=>i==null||Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0;function jS(i){const t={},s=vr(i.get("facets"));Ai(s)||(t.facets=s);const a=vr(i.get("block"));Ai(a)||(t.block=a);const o=vr(i.get("range"));Ai(o)||(t.range=o);const u=vr(i.get("exists"));Ai(u)||(t.exists=u);const d=vr(i.get("roles"));Ai(d)||(t.roles=d);const m=vr(i.get("orderBy"));Ai(m)||(t.orderBy=m),i.get("available")!=null&&(t.available=i.get("available")==="true");const g=i.get("jeopardy");return(g==="1"||g==="true")&&(t.jeopardy=!0),t}function EA(i,t){const s=(a,o)=>Ai(o)?i.delete(a):i.set(a,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?i.delete("available"):i.set("available",String(t.available)),t.jeopardy===!0?i.set("jeopardy","1"):i.delete("jeopardy")}function jA(i,t,s){const a=typeof t=="object"&&t!==null?JSON.stringify(t):t,o=encodeURIComponent(JSON.stringify({[i]:a}));return s?`/escalations/available?role=${encodeURIComponent(s)}&facets=${o}&status=all`:`/escalations/available?facets=${o}&status=all`}function AA(i){var t,s,a;return Object.keys(i.facets??{}).length+(((t=i.block)==null?void 0:t.length)??0)+(((s=i.range)==null?void 0:s.length)??0)+(((a=i.exists)==null?void 0:a.length)??0)+(i.available!=null?1:0)+(i.jeopardy===!0?1:0)}function AS(i,t){const s=(i==null?void 0:i.pinnedViews)??[],a=new Set((i==null?void 0:i.hiddenRolePins)??[]),o=new Set(s.map(m=>m.label)),u=[...s],d=new Set;for(const{role:m,pins:g}of t)for(const y of g)o.has(y.label)||a.has(y.label)||d.has(y.label)||(d.add(y.label),u.push({...y,id:`role:${m}:${y.label}`,fromRole:m}));return u}function OS(i){let t;try{t=new URL(i,"http://local")}catch{return null}if(t.pathname!=="/escalations/available"&&t.pathname!=="/escalations")return null;const s=t.searchParams,a=jS(s),o=s.get("status")||void 0,u=t.pathname==="/escalations/available"&&(o===void 0||o==="available");return{available:u,params:{...a,role:s.get("role")||void 0,type:s.get("type")||void 0,priority:s.get("priority")?parseInt(s.get("priority"),10):void 0,status:u||o==="all"?void 0:o,search:s.get("search")||void 0}}}function NS(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function TS(){var te;const{collapsed:i}=Sh(),{user:t}=Dn(),s=SS(),a=ES(),o=A.useMemo(()=>new Set(((t==null?void 0:t.roles)??[]).map($=>$.role)),[t]),{data:u}=wS({enabled:o.size>0}),d=bt();Wg(wy(),()=>{d.invalidateQueries({queryKey:["escalations"]})});const m=(te=s.data)==null?void 0:te.preferences,g=A.useMemo(()=>((u==null?void 0:u.roles)??[]).filter($=>o.has($.role)&&Array.isArray($.default_pins)&&$.default_pins.length>0).map($=>({role:$.role,pins:$.default_pins})),[u,o]),y=A.useMemo(()=>AS(m,g),[m,g]),E=(m==null?void 0:m.pinnedViews)??[],_=A.useRef(null),N=$=>a.mutate({pinnedViews:$}),R=$=>N(E.filter(ce=>ce.id!==$)),M=$=>N([...E,{id:NS(),label:$.label,url:$.url,badge:$.badge}]),D=$=>a.mutate({hiddenRolePins:[...(m==null?void 0:m.hiddenRolePins)??[],$]}),G=($,ce)=>{if($===ce)return;const oe=[...E],[O]=oe.splice($,1);oe.splice(ce,0,O),N(oe)};return y.length===0?null:h.jsxs("div",{className:"space-y-1",children:[i?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-accent/80",children:"Pinned"}),y.map($=>{const ce=$.fromRole?-1:E.findIndex(oe=>oe.id===$.id);return h.jsx(kS,{pin:$,collapsed:i,draggable:ce!==-1,onDragStart:()=>{_.current=ce},onDropOn:()=>{_.current!==null&&ce!==-1&&G(_.current,ce),_.current=null},onRemove:$.fromRole?void 0:()=>R($.id),onPromote:$.fromRole?()=>M($):void 0,onHide:$.fromRole?()=>D($.label):void 0},$.id)})]})}function kS({pin:i,collapsed:t,draggable:s,onDragStart:a,onDropOn:o,onRemove:u,onPromote:d,onHide:m}){const{pathname:g,search:y}=Sn(),[E,_=""]=i.url.split("?"),N=g===E&&y===(_?`?${_}`:""),R="group flex items-center rounded-md transition-colors duration-150",M=N?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return t?h.jsx(Tr,{to:i.url,className:`${R} ${M} justify-center w-10 h-10 mx-auto`,title:i.label,children:h.jsx(m0,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${R} ${M}`,draggable:s,onDragStart:a,onDragOver:D=>D.preventDefault(),onDrop:o,children:[h.jsxs(Tr,{to:i.url,className:"flex items-center gap-3 pl-4 py-2 text-sm flex-1 min-w-0",children:[h.jsx(m0,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5,...i.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate",children:i.label}),i.badge&&h.jsx(CS,{url:i.url}),i.fromRole&&h.jsx("span",{className:"shrink-0 text-2xs uppercase tracking-wider text-text-quaternary",title:`Provided by the ${i.fromRole} role`,children:"role"})]}),h.jsxs("span",{className:"flex items-center pr-2 gap-0.5 opacity-0 group-hover:opacity-100 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(Tg,{className:"w-3 h-3"})}),m&&h.jsx("button",{onClick:m,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(pv,{className:"w-3 h-3"})}),u&&h.jsx("button",{onClick:u,title:`Remove "${i.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Gn,{className:"w-3 h-3"})})]})]})}function CS({url:i}){var d;const t=A.useMemo(()=>OS(i),[i]),s={limit:1,staleTime:15e3},a=vy({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&t.available}),o=xy({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&!t.available});if(!t)return null;const u=t.available?a:o;return u.isError||((d=u.data)==null?void 0:d.total)===void 0?null:h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-full bg-accent/10 text-accent text-2xs font-semibold tabular-nums",children:u.data.total})}function MS(){var u;const{data:i}=Mi(),t=(u=i==null?void 0:i.features)==null?void 0:u.graphWorkflows,s=t===!0||t!==!1&&my(),a=[{to:"/workflows/registry",label:"Registry",icon:p0},{to:"/workflows/durable/invoke",label:"Invoke",icon:g0},{to:"/workflows/executions",label:"Executions",icon:y0}],o=s?[{kind:"group",label:"Procedural",icon:gv,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:a},{kind:"group",label:"Graph",icon:sh,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:p0,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:g0},{to:"/mcp/executions",label:"Executions",icon:y0}]}]:a;return h.jsx(ki,{heading:"Orchestrate",entries:o})}const RS=[{to:"/mcp/queries",label:"Designer",icon:yv},{to:"/mcp/servers",label:"Servers & Tools",icon:bv}];function DS(){return h.jsx(ki,{heading:"Design",entries:RS})}const qS=[{to:"/files",label:"Files",icon:xv},{to:"/knowledge",label:"Knowledge",icon:vv}];function zS(){return h.jsx(ki,{heading:"Storage",entries:qS})}function US({isBuilder:i=!1,isOps:t=!1}){var d;const{data:s}=Mi(),a=((d=s==null?void 0:s.features)==null?void 0:d.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:_v},...i||t?[{to:"/admin/roles",label:"Roles",icon:Tf}]:[]],u=[{to:"/admin/controlplane",label:"Routers",icon:wv},{to:"/admin/streams",label:"Messages",icon:Sv},...a?[{to:"/admin/maintenance",label:"DB Maintenance",icon:Ev}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(ki,{heading:"Identity & Access",entries:o}),i&&h.jsx(ki,{heading:"Infrastructure",entries:u})]})}function Ty({aiEnabled:i,isBuilder:t,isOps:s,viewAs:a,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(_S,{aiEnabled:i,isBuilder:t,isOps:s,viewAs:a,canSeePaceBoard:o}),h.jsx(TS,{}),t&&h.jsx(MS,{}),t&&i&&h.jsx(DS,{}),t&&h.jsx(zS,{}),(t||s)&&h.jsx(US,{isBuilder:t,isOps:s})]})}function BS({open:i,onClose:t,...s}){const a=Sn();return A.useEffect(()=>{t()},[a.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${i?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${i?"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 ${i?"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(Gn,{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(sS,{children:h.jsx(Ty,{...s})})})]})]})}const ky="lt_event_feed_patterns";function LS(i,t){if(i.startsWith("/topics/")){const d=decodeURIComponent(i.replace("/topics/",""));if(d&&!d.includes("/"))return`lt.events.${d}`}const s=i.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(i.startsWith("/escalations")){const d=new URLSearchParams(t).get("role");return d?`lt.events.system.escalation.${_y(d)}.>`:"lt.events.system.escalation.>"}const a=i.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(a)return`lt.events.system.workflow.${a[1]}.>`;if(i.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=i.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(i.startsWith("/agents"))return"lt.events.system.agent.>";if(i.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(i.startsWith("/files"))return"lt.events.system.file.>";if(i==="/")return"lt.events.system.>";const u=i.match(/^\/mcp\/executions\/(.+)/);return u?`lt.events.system.*.${u[1]}.>`:(i.startsWith("/mcp"),"lt.events.system.>")}function PS(){try{const i=localStorage.getItem(ky);return i?JSON.parse(i):[]}catch{return[]}}function jf(i){try{localStorage.setItem(ky,JSON.stringify(i))}catch{}}function HS(){const{pathname:i,search:t}=Sn(),[s,a]=A.useState(PS),o=A.useMemo(()=>LS(i,t),[i,t]),u=A.useMemo(()=>{const y=new Set([o,...s]);return Array.from(y)},[o,s]),d=A.useCallback(y=>{const E=y.startsWith("lt.events.")?y:`lt.events.${y}`;a(_=>{if(_.includes(E))return _;const N=[..._,E];return jf(N),N})},[]),m=A.useCallback(y=>{a(E=>{const _=E.filter(N=>N!==y);return jf(_),_})},[]),g=A.useCallback(()=>{a([]),jf([])},[]);return{patterns:u,pagePattern:o,userPatterns:s,addPattern:d,removePattern:m,clearUserPatterns:g}}function $S({children:i,className:t=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${t}`,children:i})}const Af=280,sg="cubic-bezier(0.4, 0, 0.2, 1)",Oo=40;function YS(i){if(!i)return"scale(0.92)";const t=window.innerWidth,s=window.innerHeight,a=t-Oo*2,o=s-Oo*2,u=i.width/a,d=i.height/o,m=i.left+i.width/2-(Oo+a/2),g=i.top+i.height/2-(Oo+o/2);return`translate(${m}px, ${g}px) scale(${u}, ${d})`}function Cy({open:i,onClose:t,sourceRef:s,children:a}){const[o,u]=A.useState(null),d=A.useRef(null),m=A.useRef(!1);A.useEffect(()=>{var N,R;i&&!m.current?(d.current=((N=s==null?void 0:s.current)==null?void 0:N.getBoundingClientRect())??null,u("entering")):!i&&m.current&&o==="open"&&(d.current=((R=s==null?void 0:s.current)==null?void 0:R.getBoundingClientRect())??null,u("exiting")),m.current=i},[i,s,o]),A.useEffect(()=>{if(o!=="entering")return;const N=requestAnimationFrame(()=>{requestAnimationFrame(()=>u("open"))});return()=>cancelAnimationFrame(N)},[o]),A.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),A.useEffect(()=>{if(!o)return;const N=R=>{R.key==="Escape"&&t()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[o,t]);const g=A.useCallback(N=>{N.propertyName==="transform"&&o==="exiting"&&u(null)},[o]);if(A.useEffect(()=>{if(o!=="exiting")return;const N=setTimeout(()=>u(null),Af+50);return()=>clearTimeout(N)},[o]),!o)return null;const y=o==="entering"||o==="exiting",E=y?YS(d.current):"none",_=y?0:1;return jg.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${Af}ms ${sg}, opacity ${Af}ms ${sg}`,transform:E,opacity:_,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:a}),document.body)}function GS({className:i}){return h.jsx("svg",{className:i,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 VS({className:i}){return h.jsx("svg",{className:i,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 IS({className:i}){return h.jsx("svg",{className:i,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 FS({className:i}){return h.jsx("svg",{className:i,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 JS({className:i}){return h.jsx("svg",{className:i,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 QS({className:i}){return h.jsx("svg",{className:i,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 KS(i){const t=i.trim().split(`
54
- `);if(t.length<2)return i;const s=m=>m.split("|").map(g=>g.trim()).filter(Boolean),a=s(t[0]),o=t.slice(2),u=a.map(m=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${m}</th>`).join(""),d=o.map(m=>`<tr class="border-t border-surface-border">${s(m).map(E=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${E}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${u}</tr></thead><tbody>${d}</tbody></table>`}function No(i){return i.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function XS(i){const t=[];let s=i.replace(/```(\w*)\n([\s\S]*?)```/g,(g,y,E)=>{const _=t.length;return t.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${E}</code></pre>`),`\0CODE${_}\0`});const a=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(a,(g,y,E,_)=>KS(`${y}
53
+ ${m.stack}`),d.reject(y)):d.resolve(E))}});return g.requestSubject=t,this.protocol.publish(t,s,{reply:u,headers:a.headers}),d}else{const u=new Gg(this.protocol.muxSubscriptions,t,a,o);this.protocol.request(u);try{this.publish(t,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:a.headers})}catch(m){u.cancel(m)}const d=Promise.race([u.timer,u.deferred]);return d.catch(()=>{u.cancel()}),d}}flush(){return this.isClosed()?Promise.reject(de.errorForCode(le.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(de.errorForCode(le.ConnectionClosed)):this.isDraining()?Promise.reject(de.errorForCode(le.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 St;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,a)=>s==="time"?new Date(Date.parse(a)):a)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(t={}){const s=new T_(this,t);if(t.checkAPI!==!1)try{await s.getAccountInfo()}catch(a){const o=a;throw o.code===le.NoResponders&&(o.code=le.JetStreamNotEnabled),o}return s}jetstream(t={}){return new hh(this,t)}getServerVersion(){const t=this.info;return t?Ci(t.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw de.errorForCode(le.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 R_(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(de.errorForCode(le.ConnectionClosed)):this.isDraining()?Promise.reject(de.errorForCode(le.ConnectionDraining)):this.protocol.reconnect()}}class R_{constructor(t){v(this,"nc");this.nc=t}add(t){try{return new Ka(this.nc,t).start()}catch(s){return Promise.reject(s)}}client(t,s){return new h_(this.nc,t,s)}}class D_{constructor(t,s,a){v(this,"bucket");v(this,"sm");v(this,"prefixLen");this.bucket=t,this.prefixLen=s,this.sm=a}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($o)||"PUT"}get length(){const t=this.sm.header.get(Bt.MessageSizeHdr)||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class q_{constructor(t,s,a){v(this,"bucket");v(this,"key");v(this,"sm");this.bucket=t,this.key=s,this.sm=a}get value(){return this.sm.data}get created(){return new Date(lh(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var t;return((t=this.sm.headers)==null?void 0:t.get($o))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const t=((s=this.sm.headers)==null?void 0:s.get(Bt.MessageSizeHdr))||"";return t!==""?parseInt(t,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class ey extends E1{constructor(s,a,o){super(s.nc,a,o);v(this,"js");v(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 a=ms(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,a);const u=this.info;u.config.name=ti.next(),u.ordered_consumer_sequence.delivery_seq=0,u.flow_control.heartbeat_count=0,u.flow_control.fc_count=0,u.flow_control.consumer_restarts++,u.deliver=a,u.config.deliver_subject=a,u.config.deliver_policy=ft.StartSequence,u.config.opt_start_seq=s;const d={};d.stream_name=this.info.stream,d.config=u.config;const m=`${u.api.prefix}.CONSUMER.CREATE.${u.stream}`;this.js._request(m,d,{retries:-1}).then(g=>{const y=g,E=this.sub.info;E.last=y,this.info.config=y.config,this.info.name=y.name}).catch(g=>{const y=new de(`unable to recreate ordered consumer ${u.stream} at seq ${s}`,le.RequestError,g);this.sub.callback(y,{})})}_maybeSetupHbMonitoring(){var a,o;const s=((o=(a=this.info)==null?void 0:a.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(lh(s))}_setupHbMonitoring(s,a=0){const o={cancelAfter:0,maxOut:2};a&&(o.cancelAfter=a);const u=this.sub,d=m=>{var E,_,T,R;const g=i1(409,`${wn.IdleHeartbeatMissed}: ${m}`,this.sub.subject);if(!((E=this.info)==null?void 0:E.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const C=((T=(_=this.info)==null?void 0:_.ordered_consumer_sequence)==null?void 0:T.stream_seq)||0;return this._resetOrderedConsumer(C+1),(R=this.monitor)==null||R.restart(),!1}return!u.noIterator};this.monitor=new ch(s,d,o)}_checkHbOrderConsumer(s){const a=s.headers.get(Bt.ConsumerStalledHdr);a!==""&&this.js.nc.publish(a);const o=parseInt(s.headers.get(Bt.LastConsumerSeqHdr),10),u=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==u.delivery_seq&&this._resetOrderedConsumer(u.stream_seq+1),!1}_checkOrderedConsumer(s){const a=this.info.ordered_consumer_sequence,o=s.info.streamSequence,u=s.info.deliverySequence;return u!=a.delivery_seq+1?(this._resetOrderedConsumer(a.stream_seq+1),!1):(a.delivery_seq=u,a.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${a}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,a=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${a}`,u=await s.api._request(o);return s.last=u,u}}class z_ extends ey{constructor(t,s,a){super(t,s,a)}pull(t={batch:1}){const{stream:s,config:a,name:o}=this.sub.info,u=a.durable_name??o,d={};if(d.batch=t.batch||1,d.no_wait=t.no_wait||!1,(t.max_bytes??0)>0){const y=this.js.nc.features.get(Le.JS_PULL_MAX_BYTES);if(!y.ok)throw new Error(`max_bytes is only supported on servers ${y.min} or better`);d.max_bytes=t.max_bytes}let m=0;t.expires&&t.expires>0&&(m=t.expires,d.expires=nt(m));let g=0;if(t.idle_heartbeat&&t.idle_heartbeat>0&&(g=t.idle_heartbeat,d.idle_heartbeat=nt(g)),g&&m===0)throw new Error("idle_heartbeat requires expires");if(g>m)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),m&&g&&(this.monitor?this.monitor._change(g,m):this._setupHbMonitoring(g,m));const y=this.info.api,E=`${y.prefix}.CONSUMER.MSG.NEXT.${s}.${u}`,_=this.sub.subject;y.nc.publish(E,y.jc.encode(d),{reply:_})}}}function U_(i,t){return i?L_(t):B_(t)}function B_(i){return(t,s)=>t?[t,null]:(t=Ar(s),t?[t,null]:[null,Fa(s,i)])}function L_(i){return(t,s)=>{if(t)return[t,null];const a=Ar(s);return a!==null?[ty(a),null]:[null,Fa(s,i)]}}function ty(i){if(i!==null)switch(i.code){case le.JetStream404NoMessages:case le.JetStream408RequestTimeout:return null;case le.JetStream409:return r1(i)?i:null;default:return i}return null}function P_(i){i&&i.ack()}function H_(i){const t=i.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 $_{constructor(t,s){v(this,"msg");v(this,"di");v(this,"didAck");v(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=H_(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]===Ma[0]&&t[1]===Ma[1]&&t[2]===Ma[2]&&t[3]===Ma[3]}async ackAck(t){var a;t=t||{},t.timeout=t.timeout||this.timeout;const s=st();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const u=this.msg.publisher,d=!((a=u.options)!=null&&a.noAsyncTraces),m=new Gg(u.muxSubscriptions,this.msg.reply,{timeout:t.timeout},d);u.request(m);try{u.publish(this.msg.reply,J0,{reply:`${u.muxSubscriptions.baseInbox}${m.token}`})}catch(g){m.cancel(g)}try{await Promise.race([m.timer,m.deferred]),s.resolve(!0)}catch(g){m.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(J0)}nak(t){let s=w_;t&&(s=Rf().encode(`-NAK ${JSON.stringify({delay:nt(t)})}`)),this.doAck(s)}working(){this.doAck(Ma)}next(t,s={batch:1}){const a={};a.batch=s.batch||1,a.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(a.expires=nt(s.expires));const o=Dn().encode(a),u=Mr.concat(S_,j_,o),d=t?{reply:t}:void 0;this.msg.respond(u,d)}term(t=""){let s=E_;(t==null?void 0:t.length)>0&&(s=Rf().encode(`+TERM ${t}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const Y_="1.30.3",G_="nats.ws";class V_{constructor(){v(this,"version");v(this,"lang");v(this,"closeError");v(this,"connected");v(this,"done");v(this,"socket");v(this,"options");v(this,"socketClosed");v(this,"encrypted");v(this,"peeked");v(this,"yields");v(this,"signal");v(this,"closedNotification");this.version=Y_,this.lang=G_,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=st(),this.closedNotification=st()}async connect(t,s){const a=st();if(s.tls)return a.reject(new de("tls",le.InvalidOption)),a;this.options=s;const o=t.src;if(s.wsFactory){const{socket:u,encrypted:d}=await s.wsFactory(t.src,s);this.socket=u,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=u=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(u.data)),this.peeked){this.signal.resolve();return}const d=Mr.concat(...this.yields),m=k1(d);if(m!==""){const g=i_.exec(m);if(!g){s.debug&&console.error("!!!",vo(d)),a.reject(new Error("unexpected response from server"));return}try{const y=JSON.parse(g[1]);n_(y,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),a.resolve()}catch(y){a.reject(y);return}}},this.socket.onclose=u=>{if(this.isDiscarded())return;this.socketClosed=!0;let d;this.done||(u.wasClean||(d=new Error(u.reason)),this._closed(d))},this.socket.onerror=u=>{if(this.isDiscarded())return;const d=u,m=new de(d.message,le.Unknown,new Error(d.error));a.reject(m)},a}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 Rr(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(`> ${vo(t[s])}`),yield t[s];if(this.done)break;this.yields.length===0&&(t.length=0,this.yields=t,this.signal=st())}}isEncrypted(){return this.connected&&this.encrypted}send(t){if(!this.isDiscarded())try{this.socket.send(t.buffer),this.options.debug&&console.info(`< ${vo(t)}`);return}catch(s){this.options.debug&&console.error(`!!! ${vo(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 I_(i,t){/^(.*:\/\/)(.*)/.test(i)||(typeof t=="boolean"?i=`${t===!0?"https":"http"}://${i}`:i=`https://${i}`);let a=new URL(i);const o=a.protocol.toLowerCase();o==="ws:"&&(t=!1),o==="wss:"&&(t=!0),o!=="https:"&&o!=="http"&&(i=i.replace(/^(.*:\/\/)(.*)/gm,"$2"),a=new URL(`http://${i}`));let u,d;const m=a.hostname,g=a.pathname,y=a.search||"";switch(o){case"http:":case"ws:":case"nats:":d=a.port||"80",u="ws:";break;case"https:":case"wss:":case"tls:":d=a.port||"443",u="wss:";break;default:d=a.port||t===!0?"443":"80",u=t===!0?"wss:":"ws:";break}return`${u}//${m}:${d}${g}${y}`}function F_(i={}){return j1({defaultPort:443,urlParseFn:I_,factory:()=>new V_}),dh.connect(i)}const J_=null,Q_=null,K_="lt.events";function ny(i,t){const s=i.split("."),a=t.split(".");for(let o=0;o<a.length;o++){const u=a[o];if(u===">")return!0;if(o>=s.length||u!=="*"&&u!==s[o])return!1}return s.length===a.length}const Dr=j.createContext({connected:!1,subscribe:()=>()=>{}});function X_(){const{connected:i}=j.useContext(Dr);return{connected:i}}function Xj(i,t){const{subscribe:s}=j.useContext(Dr),a=j.useRef(t);a.current=t,j.useEffect(()=>s(i,u=>a.current(u)),[s,i])}function mh(i,t){const{subscribe:s}=j.useContext(Dr),a=j.useRef(t);a.current=t;const o=i.join(","),u=j.useMemo(()=>o.split(",").filter(Boolean),[o]);j.useEffect(()=>{const d=g=>a.current(g),m=u.map(g=>s(g,d));return()=>m.forEach(g=>g())},[s,u])}const Z_=j.createContext({connected:!1,subscribe:()=>()=>{}}),W_=Rf();function ew({children:i,url:t,token:s}){const a=j.useRef(null),[o,u]=j.useState(!1),d=j.useRef(null),m=j.useRef(new Map),g=j.useRef(new Map),y=j.useCallback((R,C)=>{(async()=>{for await(const D of C)try{if(!ny(D.subject,R))continue;const F=JSON.parse(W_.decode(D.data)),te=m.current.get(R);if(!te)continue;for(const X of te)try{X(F)}catch{}}catch{}})()},[]),E=j.useCallback(R=>{var D;const C=a.current;if(!(!C||(D=C.isClosed)!=null&&D.call(C)||g.current.has(R)))try{const F=C.subscribe(R);g.current.set(R,F),y(R,F)}catch{}},[y]),_=j.useCallback((R,C)=>{const D=m.current;return D.has(R)||D.set(R,new Set),D.get(R).add(C),E(R),()=>{const F=D.get(R);if(F&&(F.delete(C),F.size===0)){D.delete(R);const te=g.current.get(R);if(te){g.current.delete(R);try{te.unsubscribe()}catch{}}}}},[E]),T=j.useCallback(async()=>{try{if(a.current)return;const R=t||J_;if(!R){console.error("[lt-nats] no NATS WebSocket URL configured — set NATS_WS_URL on the server");return}const C=await F_({servers:R,token:s||Q_||void 0,reconnect:!0,maxReconnectAttempts:-1,reconnectTimeWait:2e3});a.current=C,u(!0);for(const D of m.current.keys())E(D);(async()=>{for await(const D of C.status())D.type==="disconnect"||D.type==="error"?u(!1):D.type==="reconnect"&&u(!0)})()}catch{u(!1),d.current=setTimeout(T,3e3)}},[E]);return j.useEffect(()=>(T(),()=>{d.current&&clearTimeout(d.current);for(const R of g.current.values())try{R.unsubscribe()}catch{}g.current.clear(),a.current&&(a.current.close().catch(()=>{}),a.current=null),u(!1)}),[T]),h.jsx(Z_.Provider,{value:{connected:o,subscribe:_},children:h.jsx(Dr.Provider,{value:{connected:o,subscribe:_},children:i})})}const Vn=Object.create(null);Vn.open="0";Vn.close="1";Vn.ping="2";Vn.pong="3";Vn.message="4";Vn.upgrade="5";Vn.noop="6";const Co=Object.create(null);Object.keys(Vn).forEach(i=>{Co[Vn[i]]=i});const Ff={type:"error",data:"parser error"},sy=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",iy=typeof ArrayBuffer=="function",ry=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,ph=({type:i,data:t},s,a)=>sy&&t instanceof Blob?s?a(t):K0(t,a):iy&&(t instanceof ArrayBuffer||ry(t))?s?a(t):K0(new Blob([t]),a):a(Vn[i]+(t||"")),K0=(i,t)=>{const s=new FileReader;return s.onload=function(){const a=s.result.split(",")[1];t("b"+(a||""))},s.readAsDataURL(i)};function X0(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let wf;function tw(i,t){if(sy&&i.data instanceof Blob)return i.data.arrayBuffer().then(X0).then(t);if(iy&&(i.data instanceof ArrayBuffer||ry(i.data)))return t(X0(i.data));ph(i,!1,s=>{wf||(wf=new TextEncoder),t(wf.encode(s))})}const Z0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ba=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<Z0.length;i++)Ba[Z0.charCodeAt(i)]=i;const nw=i=>{let t=i.length*.75,s=i.length,a,o=0,u,d,m,g;i[i.length-1]==="="&&(t--,i[i.length-2]==="="&&t--);const y=new ArrayBuffer(t),E=new Uint8Array(y);for(a=0;a<s;a+=4)u=Ba[i.charCodeAt(a)],d=Ba[i.charCodeAt(a+1)],m=Ba[i.charCodeAt(a+2)],g=Ba[i.charCodeAt(a+3)],E[o++]=u<<2|d>>4,E[o++]=(d&15)<<4|m>>2,E[o++]=(m&3)<<6|g&63;return y},sw=typeof ArrayBuffer=="function",gh=(i,t)=>{if(typeof i!="string")return{type:"message",data:ay(i,t)};const s=i.charAt(0);return s==="b"?{type:"message",data:iw(i.substring(1),t)}:Co[s]?i.length>1?{type:Co[s],data:i.substring(1)}:{type:Co[s]}:Ff},iw=(i,t)=>{if(sw){const s=nw(i);return ay(s,t)}else return{base64:!0,data:i}},ay=(i,t)=>{switch(t){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},ly="",rw=(i,t)=>{const s=i.length,a=new Array(s);let o=0;i.forEach((u,d)=>{ph(u,!1,m=>{a[d]=m,++o===s&&t(a.join(ly))})})},aw=(i,t)=>{const s=i.split(ly),a=[];for(let o=0;o<s.length;o++){const u=gh(s[o],t);if(a.push(u),u.type==="error")break}return a};function lw(){return new TransformStream({transform(i,t){tw(i,s=>{const a=s.length;let o;if(a<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,a);else if(a<65536){o=new Uint8Array(3);const u=new DataView(o.buffer);u.setUint8(0,126),u.setUint16(1,a)}else{o=new Uint8Array(9);const u=new DataView(o.buffer);u.setUint8(0,127),u.setBigUint64(1,BigInt(a))}i.data&&typeof i.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(s)})}})}let Sf;function Eo(i){return i.reduce((t,s)=>t+s.length,0)}function jo(i,t){if(i[0].length===t)return i.shift();const s=new Uint8Array(t);let a=0;for(let o=0;o<t;o++)s[o]=i[0][a++],a===i[0].length&&(i.shift(),a=0);return i.length&&a<i[0].length&&(i[0]=i[0].slice(a)),s}function ow(i,t){Sf||(Sf=new TextDecoder);const s=[];let a=0,o=-1,u=!1;return new TransformStream({transform(d,m){for(s.push(d);;){if(a===0){if(Eo(s)<1)break;const g=jo(s,1);u=(g[0]&128)===128,o=g[0]&127,o<126?a=3:o===126?a=1:a=2}else if(a===1){if(Eo(s)<2)break;const g=jo(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),a=3}else if(a===2){if(Eo(s)<8)break;const g=jo(s,8),y=new DataView(g.buffer,g.byteOffset,g.length),E=y.getUint32(0);if(E>Math.pow(2,21)-1){m.enqueue(Ff);break}o=E*Math.pow(2,32)+y.getUint32(4),a=3}else{if(Eo(s)<o)break;const g=jo(s,o);m.enqueue(gh(u?g:Sf.decode(g),t)),a=0}if(o===0||o>i){m.enqueue(Ff);break}}}})}const oy=4;function yt(i){if(i)return cw(i)}function cw(i){for(var t in yt.prototype)i[t]=yt.prototype[t];return i}yt.prototype.on=yt.prototype.addEventListener=function(i,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(t),this};yt.prototype.once=function(i,t){function s(){this.off(i,s),t.apply(this,arguments)}return s.fn=t,this.on(i,s),this};yt.prototype.off=yt.prototype.removeListener=yt.prototype.removeAllListeners=yt.prototype.removeEventListener=function(i,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+i];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var a,o=0;o<s.length;o++)if(a=s[o],a===t||a.fn===t){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+i],this};yt.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),s=this._callbacks["$"+i],a=1;a<arguments.length;a++)t[a-1]=arguments[a];if(s){s=s.slice(0);for(var a=0,o=s.length;a<o;++a)s[a].apply(this,t)}return this};yt.prototype.emitReserved=yt.prototype.emit;yt.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};yt.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Zo=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,s)=>s(t,0),Sn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),uw="arraybuffer";function cy(i,...t){return t.reduce((s,a)=>(i.hasOwnProperty(a)&&(s[a]=i[a]),s),{})}const fw=Sn.setTimeout,hw=Sn.clearTimeout;function Wo(i,t){t.useNativeTimers?(i.setTimeoutFn=fw.bind(Sn),i.clearTimeoutFn=hw.bind(Sn)):(i.setTimeoutFn=Sn.setTimeout.bind(Sn),i.clearTimeoutFn=Sn.clearTimeout.bind(Sn))}const dw=1.33;function mw(i){return typeof i=="string"?pw(i):Math.ceil((i.byteLength||i.size)*dw)}function pw(i){let t=0,s=0;for(let a=0,o=i.length;a<o;a++)t=i.charCodeAt(a),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(a++,s+=4);return s}function uy(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function gw(i){let t="";for(let s in i)i.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(i[s]));return t}function yw(i){let t={},s=i.split("&");for(let a=0,o=s.length;a<o;a++){let u=s[a].split("=");t[decodeURIComponent(u[0])]=decodeURIComponent(u[1])}return t}class bw extends Error{constructor(t,s,a){super(t),this.description=s,this.context=a,this.type="TransportError"}}class yh extends yt{constructor(t){super(),this.writable=!1,Wo(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,s,a){return super.emitReserved("error",new bw(t,s,a)),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=gh(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=gw(t);return s.length?"?"+s:""}}class xw extends yh{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 a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||s()})),this.writable||(a++,this.once("drain",function(){--a||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const s=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};aw(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,rw(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]=uy()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(t,s)}}let fy=!1;try{fy=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const vw=fy;function _w(){}class ww extends xw{constructor(t){if(super(t),typeof location<"u"){const s=location.protocol==="https:";let a=location.port;a||(a=s?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||a!==t.port}}doWrite(t,s){const a=this.request({method:"POST",data:t});a.on("success",s),a.on("error",(o,u)=>{this.onError("xhr post error",o,u)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(s,a)=>{this.onError("xhr poll error",s,a)}),this.pollXhr=t}}class Yn extends yt{constructor(t,s,a){super(),this.createRequest=t,Wo(this,a),this._opts=a,this._method=a.method||"GET",this._uri=s,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var t;const s=cy(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(s);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&a.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var o;a.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Yn.requestsCount++,Yn.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=_w,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Yn.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()}}Yn.requestsCount=0;Yn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",W0);else if(typeof addEventListener=="function"){const i="onpagehide"in Sn?"pagehide":"unload";addEventListener(i,W0,!1)}}function W0(){for(let i in Yn.requests)Yn.requests.hasOwnProperty(i)&&Yn.requests[i].abort()}const Sw=(function(){const i=hy({xdomain:!1});return i&&i.responseType!==null})();class Ew extends ww{constructor(t){super(t);const s=t&&t.forceBase64;this.supportsBinary=Sw&&!s}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Yn(hy,this.uri(),t)}}function hy(i){const t=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||vw))return new XMLHttpRequest}catch{}if(!t)try{return new Sn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const dy=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class jw extends yh{get name(){return"websocket"}doOpen(){const t=this.uri(),s=this.opts.protocols,a=dy?{}:cy(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,s,a)}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 a=t[s],o=s===t.length-1;ph(a,this.supportsBinary,u=>{try{this.doWrite(a,u)}catch{}o&&Zo(()=>{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]=uy()),this.supportsBinary||(s.b64=1),this.createUri(t,s)}}const Ef=Sn.WebSocket||Sn.MozWebSocket;class Aw extends jw{createSocket(t,s,a){return dy?new Ef(t,s,a):s?new Ef(t,s):new Ef(t)}doWrite(t,s){this.ws.send(s)}}class Ow extends yh{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=ow(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=t.readable.pipeThrough(s).getReader(),o=lw();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const u=()=>{a.read().then(({done:m,value:g})=>{m||(this.onPacket(g),u())}).catch(m=>{})};u();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 a=t[s],o=s===t.length-1;this._writer.write(a).then(()=>{o&&Zo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Nw={websocket:Aw,webtransport:Ow,polling:Ew},Tw=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,kw=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Jf(i){if(i.length>8e3)throw"URI too long";const t=i,s=i.indexOf("["),a=i.indexOf("]");s!=-1&&a!=-1&&(i=i.substring(0,s)+i.substring(s,a).replace(/:/g,";")+i.substring(a,i.length));let o=Tw.exec(i||""),u={},d=14;for(;d--;)u[kw[d]]=o[d]||"";return s!=-1&&a!=-1&&(u.source=t,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=Cw(u,u.path),u.queryKey=Mw(u,u.query),u}function Cw(i,t){const s=/\/{2,9}/g,a=t.replace(s,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&a.splice(0,1),t.slice(-1)=="/"&&a.splice(a.length-1,1),a}function Mw(i,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,o,u){o&&(s[o]=u)}),s}const Qf=typeof addEventListener=="function"&&typeof removeEventListener=="function",Mo=[];Qf&&addEventListener("offline",()=>{Mo.forEach(i=>i())},!1);class Ws extends yt{constructor(t,s){if(super(),this.binaryType=uw,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 a=Jf(t);s.hostname=a.host,s.secure=a.protocol==="https"||a.protocol==="wss",s.port=a.port,a.query&&(s.query=a.query)}else s.host&&(s.hostname=Jf(s.host).host);Wo(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(a=>{const o=a.prototype.name;this.transports.push(o),this._transportsByName[o]=a}),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=yw(this.opts.query)),Qf&&(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"})},Mo.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const s=Object.assign({},this.opts.query);s.EIO=oy,s.transport=t,this.id&&(s.sid=this.id);const a=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](a)}_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 a=0;a<this.writeBuffer.length;a++){const o=this.writeBuffer[a].data;if(o&&(s+=mw(o)),a>0&&s>this._maxPayload)return this.writeBuffer.slice(0,a);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Zo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,s,a){return this._sendPacket("message",t,s,a),this}send(t,s,a){return this._sendPacket("message",t,s,a),this}_sendPacket(t,s,a,o){if(typeof s=="function"&&(o=s,s=void 0),typeof a=="function"&&(o=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const u={type:t,data:s,options:a};this.emitReserved("packetCreate",u),this.writeBuffer.push(u),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()},a=()=>{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?a():t()}):this.upgrading?a():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(),Qf&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=Mo.indexOf(this._offlineEventListener);a!==-1&&Mo.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this._prevBufferLen=0}}}Ws.protocol=oy;class Rw 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),a=!1;Ws.priorWebsocketSuccess=!1;const o=()=>{a||(s.send([{type:"ping",data:"probe"}]),s.once("packet",_=>{if(!a)if(_.type==="pong"&&_.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Ws.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(E(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const T=new Error("probe error");T.transport=s.name,this.emitReserved("upgradeError",T)}}))};function u(){a||(a=!0,E(),s.close(),s=null)}const d=_=>{const T=new Error("probe error: "+_);T.transport=s.name,u(),this.emitReserved("upgradeError",T)};function m(){d("transport closed")}function g(){d("socket closed")}function y(_){s&&_.name!==s.name&&u()}const E=()=>{s.removeListener("open",o),s.removeListener("error",d),s.removeListener("close",m),this.off("close",g),this.off("upgrading",y)};s.once("open",o),s.once("error",d),s.once("close",m),this.once("close",g),this.once("upgrading",y),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{a||s.open()},200):s.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const s=[];for(let a=0;a<t.length;a++)~this.transports.indexOf(t[a])&&s.push(t[a]);return s}}let Dw=class extends Rw{constructor(t,s={}){const a=typeof t=="object"?t:s;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(o=>Nw[o]).filter(o=>!!o)),super(t,a)}};function qw(i,t="",s){let a=i;s=s||typeof location<"u"&&location,i==null&&(i=s.protocol+"//"+s.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=s.protocol+i:i=s.host+i),/^(https?|wss?):\/\//.test(i)||(typeof s<"u"?i=s.protocol+"//"+i:i="https://"+i),a=Jf(i)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const u=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+u+":"+a.port+t,a.href=a.protocol+"://"+u+(s&&s.port===a.port?"":":"+a.port),a}const zw=typeof ArrayBuffer=="function",Uw=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,my=Object.prototype.toString,Bw=typeof Blob=="function"||typeof Blob<"u"&&my.call(Blob)==="[object BlobConstructor]",Lw=typeof File=="function"||typeof File<"u"&&my.call(File)==="[object FileConstructor]";function bh(i){return zw&&(i instanceof ArrayBuffer||Uw(i))||Bw&&i instanceof Blob||Lw&&i instanceof File}function Ro(i,t){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let s=0,a=i.length;s<a;s++)if(Ro(i[s]))return!0;return!1}if(bh(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ro(i.toJSON(),!0);for(const s in i)if(Object.prototype.hasOwnProperty.call(i,s)&&Ro(i[s]))return!0;return!1}function Pw(i){const t=[],s=i.data,a=i;return a.data=Kf(s,t),a.attachments=t.length,{packet:a,buffers:t}}function Kf(i,t){if(!i)return i;if(bh(i)){const s={_placeholder:!0,num:t.length};return t.push(i),s}else if(Array.isArray(i)){const s=new Array(i.length);for(let a=0;a<i.length;a++)s[a]=Kf(i[a],t);return s}else if(typeof i=="object"&&!(i instanceof Date)){const s={};for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&(s[a]=Kf(i[a],t));return s}return i}function Hw(i,t){return i.data=Xf(i.data,t),delete i.attachments,i}function Xf(i,t){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<t.length)return t[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let s=0;s<i.length;s++)i[s]=Xf(i[s],t);else if(typeof i=="object")for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&(i[s]=Xf(i[s],t));return i}const $w=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Be;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(Be||(Be={}));class Yw{constructor(t){this.replacer=t}encode(t){return(t.type===Be.EVENT||t.type===Be.ACK)&&Ro(t)?this.encodeAsBinary({type:t.type===Be.EVENT?Be.BINARY_EVENT:Be.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let s=""+t.type;return(t.type===Be.BINARY_EVENT||t.type===Be.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=Pw(t),a=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(a),o}}class xh extends yt{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 a=s.type===Be.BINARY_EVENT;a||s.type===Be.BINARY_ACK?(s.type=a?Be.EVENT:Be.ACK,this.reconstructor=new Gw(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(bh(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 a={type:Number(t.charAt(0))};if(Be[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===Be.BINARY_EVENT||a.type===Be.BINARY_ACK){const u=s+1;for(;t.charAt(++s)!=="-"&&s!=t.length;);const d=t.substring(u,s);if(d!=Number(d)||t.charAt(s)!=="-")throw new Error("Illegal attachments");const m=Number(d);if(!Vw(m)||m<0)throw new Error("Illegal attachments");if(m>this.opts.maxAttachments)throw new Error("too many attachments");a.attachments=m}if(t.charAt(s+1)==="/"){const u=s+1;for(;++s&&!(t.charAt(s)===","||s===t.length););a.nsp=t.substring(u,s)}else a.nsp="/";const o=t.charAt(s+1);if(o!==""&&Number(o)==o){const u=s+1;for(;++s;){const d=t.charAt(s);if(d==null||Number(d)!=d){--s;break}if(s===t.length)break}a.id=Number(t.substring(u,s+1))}if(t.charAt(++s)){const u=this.tryParse(t.substr(s));if(xh.isPayloadValid(a.type,u))a.data=u;else throw new Error("invalid payload")}return a}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,s){switch(t){case Be.CONNECT:return eg(s);case Be.DISCONNECT:return s===void 0;case Be.CONNECT_ERROR:return typeof s=="string"||eg(s);case Be.EVENT:case Be.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&$w.indexOf(s[0])===-1);case Be.ACK:case Be.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Gw{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=Hw(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Vw=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function eg(i){return Object.prototype.toString.call(i)==="[object Object]"}const Iw=Object.freeze(Object.defineProperty({__proto__:null,Decoder:xh,Encoder:Yw,get PacketType(){return Be}},Symbol.toStringTag,{value:"Module"}));function Mn(i,t,s){return i.on(t,s),function(){i.off(t,s)}}const Fw=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class py extends yt{constructor(t,s,a){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,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Mn(t,"open",this.onopen.bind(this)),Mn(t,"packet",this.onpacket.bind(this)),Mn(t,"error",this.onerror.bind(this)),Mn(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 a,o,u;if(Fw.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:Be.EVENT,data:s};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const E=this.ids++,_=s.pop();this._registerAckCallback(E,_),d.id=E}const m=(o=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((u=this.io.engine)===null||u===void 0)&&u._hasPingExpired());return this.flags.volatile&&!m||(g?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),this.flags={},this}_registerAckCallback(t,s){var a;const o=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(o===void 0){this.acks[t]=s;return}const u=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let m=0;m<this.sendBuffer.length;m++)this.sendBuffer[m].id===t&&this.sendBuffer.splice(m,1);s.call(this,new Error("operation has timed out"))},o),d=(...m)=>{this.io.clearTimeoutFn(u),s.apply(this,m)};d.withError=!0,this.acks[t]=d}emitWithAck(t,...s){return new Promise((a,o)=>{const u=(d,m)=>d?o(d):a(m);u.withError=!0,s.push(u),this.emit(t,...s)})}_addToQueue(t){let s;typeof t[t.length-1]=="function"&&(s=t.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...u)=>(this._queue[0],o!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...u)),a.pending=!1,this._drainQueue())),this._queue.push(a),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:Be.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(a=>String(a.id)===t)){const a=this.acks[t];delete this.acks[t],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Be.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 Be.EVENT:case Be.BINARY_EVENT:this.onevent(t);break;case Be.ACK:case Be.BINARY_ACK:this.onack(t);break;case Be.DISCONNECT:this.ondisconnect();break;case Be.CONNECT_ERROR:this.destroy();const a=new Error(t.data.message);a.data=t.data.data,this.emitReserved("connect_error",a);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 a of s)a.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 a=!1;return function(...o){a||(a=!0,s.packet({type:Be.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:Be.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 a=0;a<s.length;a++)if(t===s[a])return s.splice(a,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 a=0;a<s.length;a++)if(t===s[a])return s.splice(a,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 a of s)a.apply(this,t.data)}}}function qr(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}qr.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*i);i=(Math.floor(t*10)&1)==0?i-s:i+s}return Math.min(i,this.max)|0};qr.prototype.reset=function(){this.attempts=0};qr.prototype.setMin=function(i){this.ms=i};qr.prototype.setMax=function(i){this.max=i};qr.prototype.setJitter=function(i){this.jitter=i};class Zf extends yt{constructor(t,s){var a;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,Wo(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((a=s.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new qr({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||Iw;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 Dw(this.uri,this.opts);const s=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const o=Mn(s,"open",function(){a.onopen(),t&&t()}),u=m=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",m),t?t(m):this.maybeReconnectOnOpen()},d=Mn(s,"error",u);if(this._timeout!==!1){const m=this._timeout,g=this.setTimeoutFn(()=>{o(),u(new Error("timeout")),s.close()},m);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(Mn(t,"ping",this.onping.bind(this)),Mn(t,"data",this.ondata.bind(this)),Mn(t,"error",this.onerror.bind(this)),Mn(t,"close",this.onclose.bind(this)),Mn(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){Zo(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,s){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new py(this,t,s),this.nsps[t]=a),a}_destroy(t){const s=Object.keys(this.nsps);for(const a of s)if(this.nsps[a].active)return;this._close()}_packet(t){const s=this.encoder.encode(t);for(let a=0;a<s.length;a++)this.engine.write(s[a],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 a;this.cleanup(),(a=this.engine)===null||a===void 0||a.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 a=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&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Ra={};function Do(i,t){typeof i=="object"&&(t=i,i=void 0),t=t||{};const s=qw(i,t.path||"/socket.io"),a=s.source,o=s.id,u=s.path,d=Ra[o]&&u in Ra[o].nsps,m=t.forceNew||t["force new connection"]||t.multiplex===!1||d;let g;return m?g=new Zf(a,t):(Ra[o]||(Ra[o]=new Zf(a,t)),g=Ra[o]),s.query&&!t.query&&(t.query=s.queryKey),g.socket(s.path,t)}Object.assign(Do,{Manager:Zf,Socket:py,io:Do,connect:Do});const Jw=j.createContext({connected:!1,subscribe:()=>()=>{}});function Qw({children:i}){const t=j.useRef(null),[s,a]=j.useState(!1),o=j.useRef(new Map),u=j.useCallback((m,g)=>{var E;const y=o.current;return y.has(m)||(y.set(m,new Set),(E=t.current)==null||E.emit("lt.subscribe",m)),y.get(m).add(g),()=>{var T;const _=y.get(m);_&&(_.delete(g),_.size===0&&(y.delete(m),(T=t.current)==null||T.emit("lt.unsubscribe",m)))}},[]),d=j.useCallback((m,g)=>{for(const[y,E]of o.current)if(ny(m,y))for(const _ of E)try{_(g)}catch{}},[]);return j.useEffect(()=>{const m=Ug(),g=Do({path:`${Tt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,...m?{auth:{token:m}}:{}});return t.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),a(!0);for(const y of o.current.keys())g.emit("lt.subscribe",y)}),g.on("disconnect",y=>{console.log("[lt-socketio] disconnected:",y),a(!1)}),g.on("connect_error",y=>{console.warn("[lt-socketio] connect error:",y.message),a(!1)}),g.onAny((y,E)=>{if(y.startsWith("lt."))try{const _=typeof E=="string"?JSON.parse(E):E;d(y,_)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),t.current=null,a(!1)}},[d]),h.jsx(Jw.Provider,{value:{connected:s,subscribe:u},children:h.jsx(Dr.Provider,{value:{connected:s,subscribe:u},children:i})})}function Kw({children:i}){const[t,s]=j.useState(null),[a,o]=j.useState({url:null,token:null});return j.useEffect(()=>{let u=!1;async function d(){var m;try{console.log("[lt-transport] detecting event transport...");const g=await fetch(`${Tt}/api/settings`);if(!g.ok){console.warn("[lt-transport] settings fetch failed, falling back to socketio"),u||s("socketio");return}const y=await g.json(),E=(m=y==null?void 0:y.events)==null?void 0:m.transport;if(console.log("[lt-transport] server reports:",E),!u){if(E==="nats"){let _=y.events.natsWsUrl??null,T=null;const R=Ug();if(R)try{const C=await fetch(`${Tt}/api/nats-credentials`,{headers:{Authorization:`Bearer ${R}`}});if(C.ok){const D=await C.json();_=D.natsWsUrl??_,T=D.natsToken??null}}catch{console.warn("[lt-transport] failed to fetch NATS credentials")}o({url:_,token:T})}s(E==="nats"?"nats":"socketio")}}catch(g){console.warn("[lt-transport] settings fetch error, falling back to socketio",g),u||s("socketio")}}return d(),()=>{u=!0}},[]),t==="nats"?h.jsx(ew,{url:a.url,token:a.token,children:i}):t==="socketio"?h.jsx(Qw,{children:i}):h.jsx(h.Fragment,{children:i})}const vh="lt_view_as",_h="lt_ai_override",Wf="lt_graph_enabled";function gy(){try{const i=localStorage.getItem(_h);if(i==="true")return!0;if(i==="false")return!1}catch{}return null}function Xw(i){try{localStorage.setItem(_h,String(i))}catch{}}function Zw(){try{localStorage.removeItem(_h)}catch{}}function wh(){try{const i=localStorage.getItem(vh);if(i==="admin"||i==="engineer"||i==="operator")return i}catch{}return null}function Ww(i){try{localStorage.setItem(vh,i)}catch{}window.location.reload()}function eh(){try{localStorage.removeItem(vh)}catch{}window.location.reload()}function yy(){try{return localStorage.getItem(Wf)==="true"}catch{return!1}}function eS(i){try{i?localStorage.setItem(Wf,"true"):localStorage.removeItem(Wf)}catch{}}function by(){const{isSuperAdmin:i,hasRoleType:t,hasRole:s}=En(),a=wh(),o=i||s("engineer"),u=t("admin"),d=i||t("admin");return{isBuilder:a?!1:o,isOps:a?a==="admin"||a==="engineer":u,canBulk:a?a==="admin":d,viewAs:a,realIsBuilder:o}}const tS="lt_ai_override";function nS(){return Ee("/settings")}function sS(){try{if(localStorage.getItem(tS)==="off")return!1}catch{}return null}function si(){var s;const i=ht({queryKey:["settings"],queryFn:nS,staleTime:1/0}),t=sS();return i.data&&t===!1&&((s=i.data.ai)!=null&&s.enabled)?{...i,data:{...i.data,ai:{enabled:!1}}}:i}function xy(){var y;const{isSuperAdmin:i,hasRoleType:t,hasRole:s}=En(),{data:a}=si(),o=((y=a==null?void 0:a.features)==null?void 0:y.publicPaceBoard)!==!1,u=i?"superadmin":t("admin")?"admin":s("engineer")?"engineer":"operator",d=wh(),m=d==="admin"||d==="engineer"||d==="operator"?d:null,g=m??u;return{tier:g,realTier:u,viewAs:m,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}function vy(i){return(i??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function th(i={}){const t=i.role?vy(i.role):"*",s=i.id??"*",a=i.verb??">";return`${K_}.system.escalation.${t}.${s}.${a}`}function tg(i){return i.verbs.map(t=>th({role:i.role,verb:t}))}function Sh(i){const{user:t,isSuperAdmin:s,hasRoleType:a}=En(),o=s||a("admin"),u=((t==null?void 0:t.roles)??[]).map(m=>m.role).sort().join(","),d=(i??[]).join(",");return j.useMemo(()=>{const m=d?d.split(","):null;return o||!u?m?tg({verbs:m}):[th({})]:u.split(",").flatMap(g=>m?tg({role:g,verbs:m}):[th({role:g})])},[o,u,d])}function iS(){const{user:i}=En(),t=Fo(),s=on(),a=j.useRef(s.pathname);a.current=s.pathname;const o=j.useRef(i==null?void 0:i.userId);o.current=i==null?void 0:i.userId;const u=j.useCallback(d=>{var E;const m=d==null?void 0:d.escalationId,g=(E=d==null?void 0:d.data)==null?void 0:E.assigned_to;if(!m||!g||g!==o.current)return;const y=`/escalations/detail/${m}`;a.current!==y&&t(y)},[t]);mh(Sh(["claimed"]),u)}const Eh=j.createContext(null),jf="lt_sidebar_collapsed",_y="(max-width: 1023px)";function rS(){try{return window.matchMedia(_y).matches}catch{return!1}}function aS({children:i}){const[t,s]=j.useState(()=>{if(rS())return!0;try{return localStorage.getItem(jf)==="true"}catch{return!1}});j.useEffect(()=>{let o;try{o=window.matchMedia(_y)}catch{return}const u=d=>{if(d.matches)s(!0);else try{s(localStorage.getItem(jf)==="true")}catch{s(!1)}};return o.addEventListener("change",u),()=>o.removeEventListener("change",u)},[]);const a=j.useCallback(()=>{s(o=>{const u=!o;try{localStorage.setItem(jf,String(u))}catch{}return u})},[]);return h.jsx(Eh.Provider,{value:{collapsed:t,toggle:a},children:i})}function lS({children:i}){return h.jsx(Eh.Provider,{value:{collapsed:!1,toggle:()=>{}},children:i})}function jh(){const i=j.useContext(Eh);if(!i)throw new Error("useSidebar must be used within SidebarProvider");return i}const ng=380,Ah=j.createContext(null);function oS({children:i}){const[t,s]=j.useState({node:null,width:ng,open:!1,ownerKey:null}),a=on(),o=j.useRef(a.pathname),u=j.useCallback((m,g)=>{s({node:m,width:(g==null?void 0:g.width)??ng,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),d=j.useCallback(m=>{s(g=>typeof m=="string"&&g.ownerKey!==m?g:{...g,open:!1})},[]);return j.useEffect(()=>{a.pathname!==o.current&&(o.current=a.pathname,s(m=>m.open||m.node?{...m,node:null,open:!1,ownerKey:null}:m))},[a.pathname]),h.jsx(Ah.Provider,{value:{...t,setPanel:u,closePanel:d},children:i})}function cS(){const i=j.useContext(Ah);if(!i)throw new Error("useShellPanel must be used within ShellPanelProvider");return i}function Wj(){return j.useContext(Ah)}function uS({open:i,width:t=380,children:s,className:a=""}){const[o,u]=j.useState(i);return j.useEffect(()=>{i&&u(!0)},[i]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${a}`,style:{width:i?t:0,maxWidth:"50%"},onTransitionEnd:d=>{!i&&d.propertyName==="width"&&u(!1)},children:h.jsx("div",{style:{width:t},className:"h-full",children:o?s:null})})}function eA({label:i,children:t}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:i}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:t})]})}function tA({views:i,activeId:t,onViewChange:s,onClose:a,headerActions:o,stickyClassName:u}){const d=i.find(m=>m.id===t)??i[0];return d?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${u??"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 pt-3 shrink-0",children:[h.jsx("div",{className:"flex items-center gap-1",role:"radiogroup","aria-label":"Panel view",children:i.map(m=>{const g=m.icon,y=m.id===d.id;return h.jsx("button",{role:"radio","aria-checked":y,onClick:()=>s(m.id),title:m.label,className:`p-1.5 rounded-md transition-colors ${y?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:h.jsx(g,{className:"w-3.5 h-3.5"})},m.id)})}),h.jsxs("div",{className:"flex items-center gap-1",children:[o,a&&h.jsx("button",{onClick:a,title:"Close panel",className:"p-1 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors",children:h.jsx(Gn,{className:"w-3.5 h-3.5"})})]})]}),h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:d.label}),h.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5 pt-1",children:d.content})]})}):null}function wy(i,t){var s,a,o,u,d;t.facets&&Object.keys(t.facets).length&&i.set("facets",JSON.stringify(t.facets)),(s=t.block)!=null&&s.length&&i.set("block",JSON.stringify(t.block)),(a=t.range)!=null&&a.length&&i.set("range",JSON.stringify(t.range)),(o=t.exists)!=null&&o.length&&i.set("exists",JSON.stringify(t.exists)),(u=t.roles)!=null&&u.length&&i.set("roles",JSON.stringify(t.roles)),(d=t.orderBy)!=null&&d.length&&i.set("orderBy",JSON.stringify(t.orderBy)),t.available!==void 0&&i.set("available",String(t.available)),t.jeopardy===!0&&i.set("jeopardy","1")}function nA(i,t){const s=i??"24h";return ht({queryKey:["stationMetrics",s],queryFn:()=>Ee(`/escalations/station-metrics?period=${s}`),staleTime:5e3,enabled:(t==null?void 0:t.enabled)??!0})}function sA(i){const t=i?`?period=${i}`:"";return ht({queryKey:["escalationStats",i],queryFn:()=>Ee(`/escalations/stats${t}`)})}function iA(){return ht({queryKey:["escalationTypes"],queryFn:()=>Ee("/escalations/types")})}function rA(i=!0){return ht({queryKey:["escalationFacetKeys"],queryFn:()=>Ee("/escalations/facet-keys"),enabled:i,staleTime:6e4})}function Sy(i){const{enabled:t=!0,staleTime:s,...a}=i,o=new URLSearchParams;return a.status&&o.set("status",a.status),a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.assigned_to&&o.set("assigned_to",a.assigned_to),a.claimed&&o.set("claimed","true"),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),wy(o,a),ht({queryKey:["escalations",a],queryFn:()=>Ee(`/escalations?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function Ey(i){const{enabled:t=!0,staleTime:s,...a}=i,o=new URLSearchParams;return a.role&&o.set("role",a.role),a.type&&o.set("type",a.type),a.subtype&&o.set("subtype",a.subtype),a.priority&&o.set("priority",String(a.priority)),a.limit&&o.set("limit",String(a.limit)),a.offset!==void 0&&o.set("offset",String(a.offset)),a.sort_by&&o.set("sort_by",a.sort_by),a.order&&o.set("order",a.order),a.search&&o.set("search",a.search),wy(o,a),ht({queryKey:["escalations","available",a],queryFn:()=>Ee(`/escalations/available?${o}`),enabled:t,...s!==void 0?{staleTime:s}:{}})}function aA(i){return ht({queryKey:["escalations","by-workflow",i],queryFn:()=>Ee(`/escalations/by-workflow/${i}`),enabled:!!i})}function lA(i){return ht({queryKey:["escalations",i],queryFn:()=>Ee(`/escalations/${i}`),enabled:!!i})}function oA(){const i=bt();return Et({mutationFn:({id:t,durationMinutes:s})=>Ee(`/escalations/${t}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function cA(){const i=bt();return Et({mutationFn:t=>Ee(`/escalations/${t}/release`,{method:"POST"}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function uA(){const i=bt();return Et({mutationFn:({id:t,resolverPayload:s})=>Ee(`/escalations/${t}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]}),i.resetQueries({queryKey:["tasks"]}),i.resetQueries({queryKey:["jobs"]})}})}function fA(){const i=bt();return Et({mutationFn:({id:t,targetRole:s})=>Ee(`/escalations/${t}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function hA(){const i=bt();return Et({mutationFn:({ids:t,priority:s})=>Ee("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:t,priority:s})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function dA(){const i=bt();return Et({mutationFn:({ids:t,durationMinutes:s})=>Ee("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:t,durationMinutes:s})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function mA(){const i=bt();return Et({mutationFn:({ids:t,targetUserId:s,durationMinutes:a})=>Ee("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:t,targetUserId:s,durationMinutes:a})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function pA(){const i=bt();return Et({mutationFn:({ids:t,targetRole:s})=>Ee("/escalations/bulk-escalate",{method:"PATCH",body:JSON.stringify({ids:t,targetRole:s})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function gA(){const i=bt();return Et({mutationFn:({ids:t,hint:s})=>Ee("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:t,...s?{hint:s}:{}})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function yA(){const i=bt();return Et({mutationFn:t=>Ee(`/escalations/${t}/cancel`,{method:"POST"}),onSuccess:()=>{i.resetQueries({queryKey:["escalations"]}),i.resetQueries({queryKey:["escalationStats"]})}})}function bA(){const i=bt();return Et({mutationFn:({ids:t})=>Ee("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:t})}),onSuccess:()=>{i.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),i.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function fS(){const{user:i}=En(),t=i==null?void 0:i.userId,s=bt(),a=j.useRef(null),o=j.useCallback(()=>{a.current||(a.current=setTimeout(()=>{a.current=null,s.invalidateQueries({queryKey:["escalations"]})},15e3))},[s]);mh(Sh(),o);const{data:u}=Ey({limit:1}),{data:d}=Sy({assigned_to:t,status:"pending",limit:1});return{available:(u==null?void 0:u.total)??0,mine:(d==null?void 0:d.total)??0}}function Yo({size:i="sm",hideLabel:t=!1,className:s="",appName:a="LongTail",variant:o="full"}){const u=i==="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":a,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Tt}/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":a,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Tt}/logo512.png)`}})});const d=u?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-40 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-40 -ml-8",m=u?"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":a,className:`logo-mark shrink-0 z-0 ${d}`,style:{"--logo-url":`url(${Tt}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${m} ${t?"opacity-0":""}`,children:a})]})}const hS=[{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"}],dS=["operator","engineer","admin","superadmin"];function sg(i){return dS.indexOf(i)}function mS(i,t){return sg(i)>=sg(t)}function pS({onClose:i}){var re,je,he,Se,$,se;const{isSuperAdmin:t,hasRoleType:s,hasRole:a}=En(),{data:o}=si(),u=wh(),d=!!((re=o==null?void 0:o.ai)!=null&&re.enabled),m=gy(),g=m!==null?m:d,[y,E]=j.useState(g),_=(je=o==null?void 0:o.features)==null?void 0:je.graphWorkflows,T=_==null,[R,C]=j.useState(_===!0||T&&yy()),D=t?"superadmin":s("admin")?"admin":a("engineer")?"engineer":"operator",F=((he=o==null?void 0:o.branding)==null?void 0:he.appName)??"LongTail",te=(Se=o==null?void 0:o.environment)==null?void 0:Se.longTailVersion,X=($=o==null?void 0:o.environment)==null?void 0:$.hotmeshVersion,fe=(se=o==null?void 0:o.environment)==null?void 0:se.nodeEnv;j.useEffect(()=>{const ie=be=>{be.key==="Escape"&&i()};return document.addEventListener("keydown",ie),()=>document.removeEventListener("keydown",ie)},[i]);const oe=hS.filter(ie=>mS(D,ie.minTier)),O=oe.length>1,U=[...O?[{id:"viewas",label:"View As",icon:cv}]:[],{id:"features",label:"Features",icon:uv}],[ne,G]=j.useState(U[0].id),I=ie=>{ie===null?eh():Ww(ie)},Z=()=>{const ie=!y;E(ie),ie===d?Zw():Xw(ie),window.location.reload()},ae=()=>{const ie=!R;C(ie),eS(ie),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:i,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:ie=>ie.stopPropagation(),children:[h.jsx("button",{onClick:i,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Gn,{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(${Tt}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:F}),te&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",te,X&&h.jsxs(h.Fragment,{children:[" · HotMesh v",X]}),fe&&fe!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:fe})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),U.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:U.map(ie=>{const be=ne===ie.id;return h.jsxs("button",{role:"tab","aria-selected":be,onClick:()=>G(ie.id),title:ie.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${be?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(ie.icon,{className:"w-5 h-5",strokeWidth:1.5,...be?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:ie.label})]},ie.id)})}),ne==="viewas"&&O&&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"}),oe.map(ie=>{const be=u===ie.id,ve=ie.id===null?`Your view · ${D}`:ie.label;return h.jsxs("button",{onClick:()=>I(ie.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 ${be?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:be&&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 ${be?"text-accent":"text-text-primary group-hover:text-accent"}`,children:ve}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:ie.description})]})]},String(ie.id))})]}),ne==="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:Z,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:y?"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 ${y?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${y?"translate-x-4":"translate-x-0"}`})})]}),T&&h.jsxs("button",{onClick:ae,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:R?"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 ${R?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${R?"translate-x-4":"translate-x-0"}`})})]})]}),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 jy=[{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"}],ig="blue",Ay="lt.theme";let Oy=[];function gS(i){const t=new Set(jy.map(a=>a.id)),s=new Set;Oy=i.filter(a=>!(a!=null&&a.id)||t.has(a.id)||s.has(a.id)?!1:(s.add(a.id),!0))}function yS(){return[...jy,...Oy]}function Ny(){try{return localStorage.getItem(Ay)||ig}catch{return ig}}function Ty(i){document.documentElement.dataset.theme=i}function bS(i){try{localStorage.setItem(Ay,i)}catch{}Ty(i)}const ky="lt:bookmarks";function xS(){try{const i=localStorage.getItem(ky);if(!i)return[];const t=JSON.parse(i);return Array.isArray(t)?t:[]}catch{return[]}}function rg(i){try{localStorage.setItem(ky,JSON.stringify(i))}catch{}}function vS({onToggleEventFeed:i,onToggleDocs:t,onToggleNav:s}){var re,je;const a=Fo(),{user:o,logout:u}=En(),{viewAs:d,realIsBuilder:m}=by(),{available:g,mine:y}=fS();xy();const{connected:E}=X_(),{data:_}=si(),T=on(),[R,C]=j.useState(!1),[D,F]=j.useState(!1),[te,X]=j.useState(Ny),[fe,oe]=j.useState(xS),O=j.useRef(null),U=(re=_==null?void 0:_.branding)==null?void 0:re.appName,ne=(je=_==null?void 0:_.branding)==null?void 0:je.themes,G=j.useMemo(()=>(gS(ne??[]),yS()),[ne]),I=he=>{bS(he),X(he)},Z=()=>{const he=window.prompt("Bookmark label:");if(!(he!=null&&he.trim()))return;const Se=T.pathname+T.search,$=[...fe,{label:he.trim(),url:Se}].sort((se,ie)=>se.label.localeCompare(ie.label));oe($),rg($),C(!1)},ae=he=>{const Se=fe.filter($=>!($.label===he.label&&$.url===he.url));oe(Se),rg(Se)};return j.useEffect(()=>{if(!R)return;const he=Se=>{O.current&&!O.current.contains(Se.target)&&C(!1)};return document.addEventListener("mousedown",he),()=>document.removeEventListener("mousedown",he)},[R]),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 ${R?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 min-w-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(fv,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsxs(ki,{to:"/","aria-label":"Home",className:"shrink-0",onClick:he=>{(he.ctrlKey||he.metaKey)&&(he.preventDefault(),F(!0))},children:[h.jsx(Yo,{appName:U,className:"hidden lg:flex"}),h.jsx(Yo,{appName:U,variant:"comet",className:"flex lg:hidden"})]}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>a(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(kg,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>a(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(Tf,{className:"w-5 h-5",strokeWidth:2})})]}),h.jsxs("div",{className:"flex items-center gap-5",children:[h.jsxs(ki,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${g>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(kf,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),g>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:g})]}),h.jsxs(ki,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${y>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(kf,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),y>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:y})]}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),h.jsxs("button",{type:"button",onClick:()=>{E?i==null||i():window.location.reload()},className:`hidden lg:flex items-center gap-1.5 text-xs transition-colors ${E?"text-status-success hover:text-status-success/80":"text-text-quaternary hover:text-text-secondary"}`,title:E?"Live events — click to toggle feed":"Events disconnected — click to reconnect",children:[h.jsx(Cg,{className:"w-4 h-4",strokeWidth:1.5}),"events"]}),m&&h.jsx(h.Fragment,{children:h.jsxs("button",{onClick:t,className:"hidden lg:flex items-center gap-1.5 text-xs text-text-quaternary hover:text-text-secondary transition-colors",title:"Documentation",children:[h.jsx(Mg,{className:"w-4 h-4",strokeWidth:1.5}),"docs"]})}),d&&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:[d," View"]}),h.jsx("button",{onClick:eh,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Gn,{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:O,children:[h.jsxs("button",{onClick:()=>C(he=>!he),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(hv,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),d&&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"})})]}),R&&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(ki,{to:"/credentials",onClick:()=>C(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),h.jsx("button",{onClick:()=>{C(!1),E?i==null||i():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:E?"Events":"Reconnect events"}),m&&h.jsx("button",{onClick:()=>{C(!1),t==null||t()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Docs"}),d&&h.jsxs("button",{onClick:()=>{C(!1),eh()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",d," 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:G.map(he=>h.jsx("button",{type:"button",onClick:()=>I(he.id),title:he.label,"aria-label":`${he.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${te===he.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:he.swatch}},he.id))})]}),h.jsx("button",{onClick:()=>{C(!1),u()},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:[fe.map(he=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(ki,{to:he.url,onClick:()=>C(!1),title:he.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:he.label}),h.jsx("button",{type:"button",onClick:()=>ae(he),title:`Remove "${he.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(Gn,{className:"w-3 h-3"})})]},`${he.label}::${he.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:Z,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(dv,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),D&&h.jsx(pS,{onClose:()=>F(!1)})]})}function Oh({open:i,children:t}){const[s,a]=j.useState(i);return j.useEffect(()=>{i&&a(!0)},[i]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${i?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{i||a(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?t:null})})}function nh(i){return({isActive:t})=>{const s="flex items-center rounded-md transition-colors duration-150",a="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return i?`${s} justify-center w-10 h-10 mx-auto ${t?a:o}`:`${s} gap-3 px-4 py-2 text-sm ${t?a:o}`}}function _S(){return({isActive:i})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${i?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function wS({group:i,collapsed:t}){const{pathname:s}=on(),a=i.matchPaths.some(m=>s.startsWith(m)),[o,u]=j.useState(a),d=o||a;return t?h.jsx(h.Fragment,{children:i.items.map(m=>h.jsx(Tr,{to:m.to,className:nh(!0),title:m.label,children:m.icon&&h.jsx(m.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},m.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>u(m=>!m),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:[i.icon&&h.jsx(i.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:i.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(Oh,{open:d,children:i.items.map(m=>h.jsxs(Tr,{to:m.to,end:m.end,className:_S(),children:[m.icon&&h.jsx(m.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:m.label})]},m.to))})]})}function SS(i){return i.kind==="group"}function ES({entry:i,collapsed:t}){const{pathname:s,search:a}=on(),o=i.to.includes("?"),u=i.icon&&h.jsx(i.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${i.iconClassName??""}`,strokeWidth:1.5,...i.solid?{fill:"currentColor"}:{}});if(o){const[d,m]=i.to.split("?"),g=s===d&&a===`?${m}`,y=nh(t)({isActive:g});return h.jsxs(Tr,{to:i.to,className:y,title:t?i.label:void 0,children:[u,!t&&h.jsx("span",{children:i.label})]})}return h.jsxs(Tr,{to:i.to,end:i.end,className:nh(t),title:t?i.label:void 0,children:[u,!t&&h.jsx("span",{children:i.label})]})}function ei({heading:i,entries:t}){const{collapsed:s}=jh();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:i}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:i}),t.map(a=>SS(a)?h.jsx(wS,{group:a,collapsed:s},a.label):h.jsx(ES,{entry:a,collapsed:s},a.to))]})}function jS({aiEnabled:i=!1,isBuilder:t=!1,isOps:s=!1,viewAs:a=null,canSeePaceBoard:o=!1}){const u={to:"/operations",label:"Pace Board",icon:mv};if(!t&&(!s||a==="engineer"||a==="operator"))return o?h.jsx(ei,{heading:"Monitor",entries:[u]}):null;if(!t)return h.jsx(ei,{heading:"Monitor",entries:o?[u]:[]});const d=[...o?[u]:[],{to:"/topics",label:"Event Topics",icon:Cg},{to:"/agents",label:i?"Agents":"Automations",icon:pv},{to:"/capabilities",label:"Capabilities",icon:gv}];return h.jsx(ei,{heading:"Monitor",entries:d})}function xA(){return ht({queryKey:["roles"],queryFn:()=>Ee("/roles")})}function vA(){return ht({queryKey:["roles","escalation-chains"],queryFn:()=>Ee("/roles/escalation-chains")})}function _A(i){return ht({queryKey:["roles",i,"escalation-targets"],queryFn:()=>Ee(`/roles/${encodeURIComponent(i)}/escalation-targets`),enabled:!!i})}function wA(){const i=bt();return Et({mutationFn:t=>Ee("/roles/escalation-chains",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function SA(){const i=bt();return Et({mutationFn:t=>Ee("/roles/escalation-chains",{method:"DELETE",body:JSON.stringify(t)}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function AS(i){return ht({queryKey:["roles","details"],queryFn:()=>Ee("/roles/details"),enabled:(i==null?void 0:i.enabled)??!0})}function EA(i,t,s=!0){return ht({queryKey:["roles",i,"schema",t??"latest"],queryFn:()=>Ee(`/roles/${encodeURIComponent(i)}/schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!i})}function jA(i){return ht({queryKey:["roles",i,"schema-versions"],queryFn:()=>Ee(`/roles/${encodeURIComponent(i)}/schema/versions`),enabled:!!i})}function AA(i,t,s=!0){return ht({queryKey:["roles",i,"list-schema",t??"latest"],queryFn:()=>Ee(`/roles/${encodeURIComponent(i)}/list-schema${t!=null?`?version=${t}`:""}`),enabled:s&&!!i})}function OA(i){return ht({queryKey:["roles",i,"list-schema-versions"],queryFn:()=>Ee(`/roles/${encodeURIComponent(i)}/list-schema/versions`),enabled:!!i})}function NA(){const i=bt();return Et({mutationFn:t=>Ee("/roles",{method:"POST",body:JSON.stringify({role:t})}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function TA(){const i=bt();return Et({mutationFn:({role:t,...s})=>Ee(`/roles/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:t,...s})=>{await i.cancelQueries({queryKey:["roles","details"]});const a=i.getQueryData(["roles","details"]);return a&&i.setQueryData(["roles","details"],{roles:a.roles.map(o=>o.role===t?{...o,...s}:o)}),{previous:a}},onError:(t,s,a)=>{a!=null&&a.previous&&i.setQueryData(["roles","details"],a.previous)},onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function kA(){const i=bt();return Et({mutationFn:t=>Ee(`/roles/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{i.invalidateQueries({queryKey:["roles"]})}})}function OS(){return ht({queryKey:["me","preferences"],queryFn:()=>Ee("/me/preferences"),staleTime:6e4})}function NS(){const i=bt();return Et({mutationFn:t=>Ee("/me/preferences",{method:"PATCH",body:JSON.stringify(t)}),onSuccess:t=>{i.setQueryData(["me","preferences"],t)}})}function TS(i){return i.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 kS(i){var t;return((t=i.title)==null?void 0:t.trim())||TS(i.role)}const vr=i=>{if(i)try{return JSON.parse(i)}catch{return}},Ni=i=>i==null||Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0;function CS(i){const t={},s=vr(i.get("facets"));Ni(s)||(t.facets=s);const a=vr(i.get("block"));Ni(a)||(t.block=a);const o=vr(i.get("range"));Ni(o)||(t.range=o);const u=vr(i.get("exists"));Ni(u)||(t.exists=u);const d=vr(i.get("roles"));Ni(d)||(t.roles=d);const m=vr(i.get("orderBy"));Ni(m)||(t.orderBy=m),i.get("available")!=null&&(t.available=i.get("available")==="true");const g=i.get("jeopardy");return(g==="1"||g==="true")&&(t.jeopardy=!0),t}function CA(i,t){const s=(a,o)=>Ni(o)?i.delete(a):i.set(a,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?i.delete("available"):i.set("available",String(t.available)),t.jeopardy===!0?i.set("jeopardy","1"):i.delete("jeopardy")}function MS(i,t){const s={};for(const[o,u]of Object.entries(i))s[o]=typeof u=="object"&&u!==null?JSON.stringify(u):u;const a=encodeURIComponent(JSON.stringify(s));return t?`/escalations/available?role=${encodeURIComponent(t)}&facets=${a}&status=all`:`/escalations/available?facets=${a}&status=all`}function MA(i,t,s){return MS({[i]:t},s)}function RA(i){var t,s,a;return Object.keys(i.facets??{}).length+(((t=i.block)==null?void 0:t.length)??0)+(((s=i.range)==null?void 0:s.length)??0)+(((a=i.exists)==null?void 0:a.length)??0)+(i.available!=null?1:0)+(i.jeopardy===!0?1:0)}function RS(i,t){const s=(i==null?void 0:i.pinnedViews)??[],a=new Set((i==null?void 0:i.hiddenRolePins)??[]),o=new Set(s.map(m=>m.label)),u=[...s],d=new Set;for(const{role:m,pins:g}of t)for(const y of g)o.has(y.label)||a.has(y.label)||d.has(y.label)||(d.add(y.label),u.push({...y,id:`role:${m}:${y.label}`,fromRole:m}));return u}function DS(i){let t;try{t=new URL(i,"http://local")}catch{return null}if(t.pathname!=="/escalations/available"&&t.pathname!=="/escalations")return null;const s=t.searchParams,a=CS(s),o=s.get("status")||void 0,u=t.pathname==="/escalations/available"&&(o===void 0||o==="available");return{available:u,params:{...a,role:s.get("role")||void 0,type:s.get("type")||void 0,priority:s.get("priority")?parseInt(s.get("priority"),10):void 0,status:u||o==="all"?void 0:o,search:s.get("search")||void 0}}}function qS(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function zS(){var O;const{collapsed:i}=jh(),{user:t}=En(),s=OS(),a=NS(),o=j.useMemo(()=>new Set(((t==null?void 0:t.roles)??[]).map(U=>U.role)),[t]),{data:u}=AS({enabled:o.size>0}),d=bt();mh(Sh(),()=>{d.invalidateQueries({queryKey:["escalations"]})});const m=(O=s.data)==null?void 0:O.preferences,g=j.useMemo(()=>((u==null?void 0:u.roles)??[]).filter(U=>o.has(U.role)&&Array.isArray(U.default_pins)&&U.default_pins.length>0).map(U=>({role:U.role,pins:U.default_pins})),[u,o]),y=j.useMemo(()=>RS(m,g),[m,g]),E=j.useMemo(()=>new Map(((u==null?void 0:u.roles)??[]).map(U=>[U.role,kS(U)])),[u]),_=j.useMemo(()=>y.filter(U=>!U.fromRole),[y]),T=j.useMemo(()=>g.map(({role:U})=>({role:U,title:E.get(U)??U,pins:y.filter(ne=>ne.fromRole===U)})).filter(U=>U.pins.length>0),[g,E,y]),R=(m==null?void 0:m.pinnedViews)??[],C=j.useRef(null),D=U=>a.mutate({pinnedViews:U}),F=U=>D(R.filter(ne=>ne.id!==U)),te=U=>D([...R,{id:qS(),label:U.label,url:U.url,badge:U.badge}]),X=U=>a.mutate({hiddenRolePins:[...(m==null?void 0:m.hiddenRolePins)??[],U]}),fe=(U,ne)=>{if(U===ne)return;const G=[...R],[I]=G.splice(U,1);G.splice(ne,0,I),D(G)};if(y.length===0)return null;const oe="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:[i&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!i&&_.length>0&&h.jsx("p",{className:oe,children:"Pinned"}),_.map(U=>{const ne=R.findIndex(G=>G.id===U.id);return h.jsx(ag,{pin:U,collapsed:i,draggable:ne!==-1,onDragStart:()=>{C.current=ne},onDropOn:()=>{C.current!==null&&ne!==-1&&fe(C.current,ne),C.current=null},onRemove:()=>F(U.id)},U.id)}),T.map(U=>h.jsxs("div",{children:[!i&&h.jsx("p",{className:oe,title:`${U.title} — pins from the ${U.role} role`,"data-testid":"pin-group-label",children:U.title}),U.pins.map(ne=>h.jsx(ag,{pin:ne,collapsed:i,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>te(ne),onHide:()=>X(ne.label)},ne.id))]},U.role))]})}function ag({pin:i,collapsed:t,draggable:s,onDragStart:a,onDropOn:o,onRemove:u,onPromote:d,onHide:m}){const{pathname:g,search:y}=on(),[E,_=""]=i.url.split("?"),T=g===E&&y===(_?`?${_}`:""),R="group flex items-center rounded-md transition-colors duration-150",C=T?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return t?h.jsx(Tr,{to:i.url,className:`${R} ${C} justify-center w-10 h-10 mx-auto`,title:i.label,children:h.jsx(g0,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${R} ${C} relative`,draggable:s,onDragStart:a,onDragOver:D=>D.preventDefault(),onDrop:o,children:[h.jsxs(Tr,{to:i.url,title:i.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(g0,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...i.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:i.label}),i.badge&&h.jsx(US,{url:i.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(Rg,{className:"w-3 h-3"})}),m&&h.jsx("button",{onClick:m,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(yv,{className:"w-3 h-3"})}),u&&h.jsx("button",{onClick:u,title:`Remove "${i.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Gn,{className:"w-3 h-3"})})]})]})}function US({url:i}){var d;const t=j.useMemo(()=>DS(i),[i]),s={limit:1,staleTime:15e3},a=Ey({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&t.available}),o=Sy({...(t==null?void 0:t.params)??{},...s,enabled:!!t&&!t.available});if(!t)return null;const u=t.available?a:o;return u.isError||((d=u.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:`${u.data.total} matching now`,children:u.data.total})}function BS(){var u;const{data:i}=si(),t=(u=i==null?void 0:i.features)==null?void 0:u.graphWorkflows,s=t===!0||t!==!1&&yy(),a=[{to:"/workflows/registry",label:"Registry",icon:y0},{to:"/workflows/durable/invoke",label:"Invoke",icon:b0},{to:"/workflows/executions",label:"Executions",icon:x0}],o=s?[{kind:"group",label:"Procedural",icon:bv,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:a},{kind:"group",label:"Graph",icon:sh,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:y0,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:b0},{to:"/mcp/executions",label:"Executions",icon:x0}]}]:a;return h.jsx(ei,{heading:"Orchestrate",entries:o})}const LS=[{to:"/mcp/queries",label:"Designer",icon:xv},{to:"/mcp/servers",label:"Servers & Tools",icon:vv}];function PS(){return h.jsx(ei,{heading:"Design",entries:LS})}const HS=[{to:"/files",label:"Files",icon:_v},{to:"/knowledge",label:"Knowledge",icon:wv}];function $S(){return h.jsx(ei,{heading:"Storage",entries:HS})}function YS({isBuilder:i=!1,isOps:t=!1}){var d;const{data:s}=si(),a=((d=s==null?void 0:s.features)==null?void 0:d.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:Sv},...i||t?[{to:"/admin/roles",label:"Roles",icon:kf},{to:"/admin/personas",label:"Personas",icon:Ev}]:[]],u=[{to:"/admin/controlplane",label:"Routers",icon:jv},{to:"/admin/streams",label:"Messages",icon:Av},...a?[{to:"/admin/maintenance",label:"DB Maintenance",icon:Ov}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(ei,{heading:"Identity & Access",entries:o}),i&&h.jsx(ei,{heading:"Infrastructure",entries:u})]})}function Cy({aiEnabled:i,isBuilder:t,isOps:s,viewAs:a,canSeePaceBoard:o}){return h.jsxs(h.Fragment,{children:[h.jsx(jS,{aiEnabled:i,isBuilder:t,isOps:s,viewAs:a,canSeePaceBoard:o}),h.jsx(zS,{}),t&&h.jsx(BS,{}),t&&i&&h.jsx(PS,{}),t&&h.jsx($S,{}),(t||s)&&h.jsx(YS,{isBuilder:t,isOps:s})]})}function GS({open:i,onClose:t,...s}){const a=on();return j.useEffect(()=>{t()},[a.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${i?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${i?"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 ${i?"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(Gn,{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(lS,{children:h.jsx(Cy,{...s})})})]})]})}const My="lt_event_feed_patterns";function VS(i,t){if(i.startsWith("/topics/")){const d=decodeURIComponent(i.replace("/topics/",""));if(d&&!d.includes("/"))return`lt.events.${d}`}const s=i.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(i.startsWith("/escalations")){const d=new URLSearchParams(t).get("role");return d?`lt.events.system.escalation.${vy(d)}.>`:"lt.events.system.escalation.>"}const a=i.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(a)return`lt.events.system.workflow.${a[1]}.>`;if(i.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=i.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(i.startsWith("/agents"))return"lt.events.system.agent.>";if(i.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(i.startsWith("/files"))return"lt.events.system.file.>";if(i==="/")return"lt.events.system.>";const u=i.match(/^\/mcp\/executions\/(.+)/);return u?`lt.events.system.*.${u[1]}.>`:(i.startsWith("/mcp"),"lt.events.system.>")}function IS(){try{const i=localStorage.getItem(My);return i?JSON.parse(i):[]}catch{return[]}}function Af(i){try{localStorage.setItem(My,JSON.stringify(i))}catch{}}function FS(){const{pathname:i,search:t}=on(),[s,a]=j.useState(IS),o=j.useMemo(()=>VS(i,t),[i,t]),u=j.useMemo(()=>{const y=new Set([o,...s]);return Array.from(y)},[o,s]),d=j.useCallback(y=>{const E=y.startsWith("lt.events.")?y:`lt.events.${y}`;a(_=>{if(_.includes(E))return _;const T=[..._,E];return Af(T),T})},[]),m=j.useCallback(y=>{a(E=>{const _=E.filter(T=>T!==y);return Af(_),_})},[]),g=j.useCallback(()=>{a([]),Af([])},[]);return{patterns:u,pagePattern:o,userPatterns:s,addPattern:d,removePattern:m,clearUserPatterns:g}}function JS({children:i,className:t=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${t}`,children:i})}const Of=280,lg="cubic-bezier(0.4, 0, 0.2, 1)",Ao=40;function QS(i){if(!i)return"scale(0.92)";const t=window.innerWidth,s=window.innerHeight,a=t-Ao*2,o=s-Ao*2,u=i.width/a,d=i.height/o,m=i.left+i.width/2-(Ao+a/2),g=i.top+i.height/2-(Ao+o/2);return`translate(${m}px, ${g}px) scale(${u}, ${d})`}function Ry({open:i,onClose:t,sourceRef:s,children:a}){const[o,u]=j.useState(null),d=j.useRef(null),m=j.useRef(!1);j.useEffect(()=>{var T,R;i&&!m.current?(d.current=((T=s==null?void 0:s.current)==null?void 0:T.getBoundingClientRect())??null,u("entering")):!i&&m.current&&o==="open"&&(d.current=((R=s==null?void 0:s.current)==null?void 0:R.getBoundingClientRect())??null,u("exiting")),m.current=i},[i,s,o]),j.useEffect(()=>{if(o!=="entering")return;const T=requestAnimationFrame(()=>{requestAnimationFrame(()=>u("open"))});return()=>cancelAnimationFrame(T)},[o]),j.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),j.useEffect(()=>{if(!o)return;const T=R=>{R.key==="Escape"&&t()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[o,t]);const g=j.useCallback(T=>{T.propertyName==="transform"&&o==="exiting"&&u(null)},[o]);if(j.useEffect(()=>{if(o!=="exiting")return;const T=setTimeout(()=>u(null),Of+50);return()=>clearTimeout(T)},[o]),!o)return null;const y=o==="entering"||o==="exiting",E=y?QS(d.current):"none",_=y?0:1;return Tg.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${Of}ms ${lg}, opacity ${Of}ms ${lg}`,transform:E,opacity:_,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:a}),document.body)}function KS({className:i}){return h.jsx("svg",{className:i,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 XS({className:i}){return h.jsx("svg",{className:i,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 ZS({className:i}){return h.jsx("svg",{className:i,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 WS({className:i}){return h.jsx("svg",{className:i,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 e2({className:i}){return h.jsx("svg",{className:i,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 t2({className:i}){return h.jsx("svg",{className:i,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 n2(i){const t=i.trim().split(`
54
+ `);if(t.length<2)return i;const s=m=>m.split("|").map(g=>g.trim()).filter(Boolean),a=s(t[0]),o=t.slice(2),u=a.map(m=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${m}</th>`).join(""),d=o.map(m=>`<tr class="border-t border-surface-border">${s(m).map(E=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${E}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${u}</tr></thead><tbody>${d}</tbody></table>`}function Oo(i){return i.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function s2(i){const t=[];let s=i.replace(/```(\w*)\n([\s\S]*?)```/g,(g,y,E)=>{const _=t.length;return t.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${E}</code></pre>`),`\0CODE${_}\0`});const a=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(a,(g,y,E,_)=>n2(`${y}
55
55
  ${E}
56
- ${_.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,y)=>`<h4 id="${No(y)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${y}</h4>`).replace(/^### (.+)$/gm,(g,y)=>`<h3 id="${No(y)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${y}</h3>`).replace(/^## (.+)$/gm,(g,y)=>`<h2 id="${No(y)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${y}</h2>`).replace(/^# (.+)$/gm,(g,y)=>`<h1 id="${No(y)}" class="text-lg font-bold text-text-primary mb-3">${y}</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 y=g.replace(/^> /gm,"").trim(),E=/⚠️|warning|caution/i.test(y),_=/note:|ℹ️|info/i.test(y);return`<div class="${E?"bg-status-warning/5":_?"bg-accent/5":"bg-surface-sunken/50"} ${E?"border-status-warning":_?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${y}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(u('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(u('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(u('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,y)=>t[parseInt(y,10)]);const d="text-xs leading-relaxed text-text-secondary mb-2",m=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const y=g.trim();if(!y)return"";const E=[];let _=y,N;for(;(N=m.exec(_))!==null;){const R=N.index+N[0].length;E.push(_.slice(0,R)),_=_.slice(R).replace(/^<br\/>/,"").trim(),m.lastIndex=0}return _&&E.push(_),E.map(R=>{const M=R.trim();return M?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(M)?M:`<p class="${d}">${M}</p>`:""}).join("")}).join(""),s}const ZS=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function WS(i){return ZS.test(i)}function Ah({content:i,className:t,onClick:s}){const a=A.useMemo(()=>XS(i),[i]);return h.jsx("div",{className:t,onClick:s,dangerouslySetInnerHTML:{__html:a}})}function Go({data:i,depth:t=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:t>0,[u,d]=A.useState(o),[m,g]=A.useState(s);if(s!==void 0&&s!==m&&(g(s),d(s%2===0&&t>0)),i==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof i=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',i,'"']});if(typeof i=="number"||typeof i=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(i)});if(Array.isArray(i))return i.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):u?h.jsxs("button",{onClick:()=>d(!1),className:"text-text-secondary hover:text-text-primary",children:["[",i.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:i.map((y,E)=>h.jsxs("div",{children:[h.jsx(Go,{data:y,depth:t+1,generation:s}),E<i.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},E))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof i=="object"){const y=Object.entries(i);return y.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):u?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:y.map(([E,_],N)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:E}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(Go,{data:_,depth:t+1,generation:s}),N<y.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},E))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(i)})}function Ga({data:i,depth:t=0}){if(i==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof i=="string")return i.length>40&&WS(i)?h.jsx(Ah,{content:i}):h.jsx("span",{className:"text-text-primary",children:i});if(typeof i=="number"||typeof i=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(i)});if(Array.isArray(i))return i.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:i.map((s,a)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[a+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(Ga,{data:s,depth:t+1})})]},a))});if(typeof i=="object"){const s=Object.entries(i);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(([a,o])=>{const u=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:a.replace(/[_-]/g," ")}),u?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(Ga,{data:o,depth:t+1})}):h.jsx(Ga,{data:o,depth:t+1})]},a)})})}return h.jsx("span",{children:String(i)})}function ig({mode:i,setMode:t,isCollapsed:s,onToggleCollapse:a,onCopy:o,copied:u,onFullscreen:d,onClose:m,large:g}){const y=g?"w-5 h-5":"w-3.5 h-3.5",E=`${g?"p-2":"p-1.5"} rounded text-text-tertiary hover:text-text-primary 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:[i==="json"&&h.jsx("button",{onClick:a,className:E,title:s?"Expand all":"Collapse all",children:s?h.jsx(QS,{className:y}):h.jsx(JS,{className:y})}),h.jsx("button",{onClick:()=>t(i==="json"?"tree":"json"),className:E,title:i==="json"?"Outline view":"JSON view",children:i==="json"?h.jsx(GS,{className:y}):h.jsx(VS,{className:y})}),h.jsx("button",{onClick:o,className:E,title:"Copy to clipboard",children:u?h.jsx(FS,{className:`${y} text-status-success`}):h.jsx(IS,{className:y})}),d&&h.jsx("button",{onClick:d,className:E,title:"Fullscreen",children:h.jsx(kg,{className:y})}),m&&h.jsx("button",{onClick:m,className:E,title:"Close (Esc)",children:h.jsx(Cg,{className:y})})]})}function e2({data:i,label:t,variant:s,defaultCollapsed:a=!1,defaultMode:o}){const u=A.useRef(null),[d,m]=A.useState(o??"json"),[g,y]=A.useState(!1),[E,_]=A.useState(!1),[N,R]=A.useState(a?0:1),[M,D]=A.useState(1),G=N%2===0,te=M%2===0,$=A.useCallback(()=>R(Z=>Z+1),[]),ce=A.useCallback(()=>D(Z=>Z+1),[]);let oe=i;if(typeof i=="string")try{oe=JSON.parse(i)}catch{}const O=async()=>{const Z=typeof i=="string"?i:JSON.stringify(oe,null,2);await navigator.clipboard.writeText(Z),y(!0),setTimeout(()=>y(!1),2e3)},J=A.useCallback(()=>{D(1),_(!0)},[]),ae=s==="panel",I=ae?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",F=ae?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:I,children:[t&&h.jsx($S,{children:t}),h.jsxs("div",{ref:u,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(ig,{mode:d,setMode:m,isCollapsed:G,onToggleCollapse:$,onCopy:O,copied:g,onFullscreen:J})}),h.jsx("div",{className:F,children:d==="json"?h.jsx(Go,{data:oe,generation:N}):h.jsx(Ga,{data:oe})})]}),h.jsxs(Cy,{open:E,onClose:()=>_(!1),sourceRef:u,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(ig,{mode:d,setMode:m,isCollapsed:te,onToggleCollapse:ce,onCopy:O,copied:g,onClose:()=>_(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:d==="json"?h.jsx(Go,{data:oe,generation:M}):h.jsx(Ga,{data:oe})})]})]})}const t2=100,rg=500;let n2=0;const My={"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 Ry(i){const t=i.split(".");return t[0]==="system"&&t.length>=3?`${t[1]}.${t[t.length-1]}`:i}function ag({event:i,forceExpanded:t=!1}){var N,R;const[s,a]=A.useState(t),o=My[Ry(i.type)]||"text-text-tertiary";A.useEffect(()=>{a(t)},[t]);const u=t,d=u?"text-xs":"text-2xs",m=u?"text-xs":"text-2xs",g=u?"text-xs":"text-2xs",y=u?"w-3.5 h-3.5":"w-2.5 h-2.5",E=u?"py-2 px-4":"py-1 px-3",_=u?"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:()=>a(!s),className:`flex items-center gap-2 ${E} 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(i.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${m} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:i.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(N=i.data)!=null&&N.workflowId?String(i.data.workflowId):"",(R=i.data)!=null&&R.escalationId?` esc:${String(i.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${y} 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(jh,{open:s,children:h.jsx("div",{className:_,children:h.jsx(e2,{data:i.data})})})]})}function s2({open:i,onToggle:t,configOpen:s,onToggleConfig:a}){const[o,u]=A.useState([]),[d,m]=A.useState(!1),[g,y]=A.useState(""),E=A.useRef(null),_=A.useRef(new Map),{subscribe:N}=A.useContext(Dr),{patterns:R,pagePattern:M,userPatterns:D,addPattern:G,removePattern:te}=HS(),$=A.useCallback(O=>{const J=String(O.type||"unknown");if(J.startsWith("mesh."))return;const ae=`${J}:${O.timestamp||""}:${O.escalationId||O.workflowId||O.taskId||""}`,I=Date.now(),F=_.current.get(ae);if(!(F&&I-F<rg)){if(_.current.set(ae,I),_.current.size>200)for(const[Z,re]of _.current)I-re>rg*2&&_.current.delete(Z);u(Z=>[{id:++n2,type:J,timestamp:O.timestamp||new Date().toISOString(),data:O},...Z].slice(0,t2))}},[]),ce=A.useRef($);ce.current=$;const oe=i||d||s;return A.useEffect(()=>{if(!oe)return;const O=R.map(J=>N(J,ae=>ce.current(ae)));return()=>O.forEach(J=>J())},[N,R.join(","),oe]),A.useEffect(()=>{i&&E.current&&(E.current.scrollTop=0)},[o.length,i]),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:[i?h.jsx(jv,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(Av,{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&&!i&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${My[Ry(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 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:O=>{O.stopPropagation(),a()},children:h.jsx(Ov,{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:O=>{O.stopPropagation(),m(!0)},children:h.jsx(kg,{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:O=>{O.stopPropagation(),u([])},children:h.jsx(Nv,{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:M.replace("lt.events.","")}),D.map(O=>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:[O.replace("lt.events.",""),h.jsx("button",{onClick:()=>te(O),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Gn,{className:"w-2 h-2"})})]},O))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:O=>y(O.target.value),onKeyDown:O=>{O.key==="Enter"&&g.trim()&&(G(g.trim()),y(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(G(g.trim()),y(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(Tg,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(jh,{open:i,children:h.jsx("div",{ref:E,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(O=>h.jsx(ag,{event:O},O.id))})}),h.jsxs(Cy,{open:d,onClose:()=>m(!1),sourceRef:E,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>m(!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(Cg,{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(O=>h.jsx(ag,{event:O,forceExpanded:!0},O.id))]})]})}function i2(){return ht({queryKey:["docs"],queryFn:()=>we("/docs"),staleTime:5*6e4})}function r2(i){return ht({queryKey:["docs",i],queryFn:()=>we(`/docs/read?path=${encodeURIComponent(i)}`),enabled:!!i,staleTime:5*6e4})}function a2(){const[i,t]=A.useState([]),[s,a]=A.useState([]),[o,u]=A.useState(null),d=A.useRef(o),m=A.useRef(i),g=A.useRef(s);d.current=o,m.current=i,g.current=s;const y=A.useCallback((M,D)=>{var te;const G=d.current;if(G){const $=((te=D==null?void 0:D.current)==null?void 0:te.scrollTop)??0;t([...m.current,{...G,scrollTop:$}])}a([]),u({path:M,scrollTop:0})},[]),E=A.useCallback(M=>{var $;const D=m.current;if(D.length===0)return;const G=D[D.length-1],te=d.current;if(te){const ce=(($=M==null?void 0:M.current)==null?void 0:$.scrollTop)??0;a([...g.current,{...te,scrollTop:ce}])}t(D.slice(0,-1)),u(G),requestAnimationFrame(()=>{M!=null&&M.current&&(M.current.scrollTop=G.scrollTop)})},[]),_=A.useCallback(M=>{var $;const D=g.current;if(D.length===0)return;const G=D[D.length-1],te=d.current;if(te){const ce=(($=M==null?void 0:M.current)==null?void 0:$.scrollTop)??0;t([...m.current,{...te,scrollTop:ce}])}a(D.slice(0,-1)),u(G),requestAnimationFrame(()=>{M!=null&&M.current&&(M.current.scrollTop=G.scrollTop)})},[]),N=A.useCallback(M=>{var te,$;const D=d.current;if(!D)return;const G=((te=M==null?void 0:M.current)==null?void 0:te.scrollTop)??0;t([...m.current,{...D,scrollTop:G}]),a([]),u({...D,scrollTop:(($=M==null?void 0:M.current)==null?void 0:$.scrollTop)??0})},[]),R=A.useCallback(()=>{t([]),a([]),u(null)},[]);return{current:o,backStack:i,forwardStack:s,navigate:y,goBack:E,goForward:_,pushScrollPosition:N,reset:R}}function l2(i,t){const[s,a]=i.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const d=((t?t.replace(/[^/]+$/,""):"")+o).split("/"),m=[];for(const g of d)g===".."?m.pop():g&&g!=="."&&m.push(g);o=m.join("/")}return{path:o,anchor:a}}function o2(i){if(!i.startsWith("#docs"))return null;const t=i.slice(1).split(":"),s=t[1]||"README.md",a=t[2]||void 0;return{path:s,anchor:a}}function c2(i){return!i||i==="README.md"?"#docs":`#docs:${i}`}function u2({content:i,currentPath:t,onNavigate:s,onAnchorClick:a}){const o=u=>{var y;const d=u.target,m=d.closest("[data-anchor]");if(m){u.preventDefault(),a();const E=m.dataset.anchor,_=(y=m.closest(".docs-content"))==null?void 0:y.querySelector(`#${CSS.escape(E)}`);_==null||_.scrollIntoView({behavior:"smooth",block:"start"});return}const g=d.closest("[data-doc-link]");if(g){u.preventDefault();const{path:E,anchor:_}=l2(g.dataset.docLink,t);s(E,_);return}};return h.jsx(Ah,{content:i,className:"docs-content",onClick:o})}function f2(i){const t=[],s=new Map;for(const a of i){const o=a.path.split("/");if(o.length===1){t.push(a);continue}let u=s;for(let d=0;d<o.length-1;d++){const m=o[d];u.has(m)||u.set(m,{label:m,children:[],subdirs:new Map});const g=u.get(m);d===o.length-2?g.children.push(a):u=g.subdirs}}return{topLevel:t,dirs:s}}function h2({docs:i,selected:t,onSelect:s}){const{topLevel:a,dirs:o}=f2(i),u=m=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${t===m?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function d(m,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(Tv,{className:"w-3 h-3",strokeWidth:1.5}),m.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...m.subdirs.values()].map(y=>d(y)),m.children.map(y=>h.jsx("button",{className:u(y.path),onClick:()=>s(y.path),children:y.title},y.path))]})]},m.label)}return h.jsxs("div",{className:"space-y-0.5",children:[a.map(m=>h.jsx("button",{className:u(m.path),onClick:()=>s(m.path),children:m.title},m.path)),[...o.values()].map(m=>d(m))]})}function d2({open:i,onClose:t}){var ae,I,F;const[s,a]=A.useState(!1),{data:o}=i2(),u=a2(),{data:d,isLoading:m}=r2(((ae=u.current)==null?void 0:ae.path)??null),g=A.useRef(null),[y,E]=A.useState(null);A.useEffect(()=>{y&&(d!=null&&d.content)&&g.current&&requestAnimationFrame(()=>{var re;const Z=(re=g.current)==null?void 0:re.querySelector(`#${CSS.escape(y)}`);Z==null||Z.scrollIntoView({behavior:"smooth",block:"start"}),E(null)})},[y,d]);const _=A.useCallback(()=>{var ie;const Z=o2(window.location.hash),re=(Z==null?void 0:Z.path)??"README.md";((ie=u.current)==null?void 0:ie.path)!==re&&u.navigate(re,g),Z!=null&&Z.anchor&&E(Z.anchor)},[u]),N=A.useRef(!0);A.useEffect(()=>{if(!i||!u.current)return;if(N.current){N.current=!1;return}const Z=c2(u.current.path);window.location.hash!==Z&&window.history.replaceState(null,"",window.location.pathname+window.location.search+Z)},[i,(I=u.current)==null?void 0:I.path]),A.useEffect(()=>{if(!i)return;const Z=()=>{window.location.hash.startsWith("#docs")&&_()};return window.addEventListener("hashchange",Z),()=>window.removeEventListener("hashchange",Z)},[i,_]);const R=A.useCallback((Z,re)=>{re&&E(re),u.navigate(Z,g)},[u]),M=A.useCallback(Z=>{u.navigate(Z,g)},[u]),D=A.useCallback(()=>{u.goBack(g)},[u]),G=A.useCallback(()=>{u.goForward(g)},[u]),te=A.useCallback(()=>{u.pushScrollPosition(g)},[u]);if(A.useEffect(()=>{if(i){N.current=!0,_();const Z=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(Z)}},[i]),!(i||s))return null;const ce=()=>{a(!1),setTimeout(()=>{t(),u.reset()},200)},oe=((F=u.current)==null?void 0:F.path)??null,O=u.backStack.length>0,J=u.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&&i?"opacity-100":"opacity-0"}`,onClick:ce}),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&&i?"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:D,disabled:!O,className:`p-0.5 transition-colors ${O?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(Ag,{className:"w-4 h-4"})}),h.jsx("button",{onClick:G,disabled:!J,className:`p-0.5 transition-colors ${J?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(Nf,{className:"w-4 h-4"})}),h.jsx(Ng,{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:ce,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Gn,{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(h2,{docs:o.docs,selected:oe,onSelect:M}):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?m?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(u2,{content:d.content,currentPath:oe,onNavigate:R,onAnchorClick:te}):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(Nf,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function m2(i){if(i.includes("/escalations"))return["escalation","human-queue"]}const lg=2e3;function p2(i){const s=i.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
56
+ ${_.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,y)=>`<h4 id="${Oo(y)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${y}</h4>`).replace(/^### (.+)$/gm,(g,y)=>`<h3 id="${Oo(y)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${y}</h3>`).replace(/^## (.+)$/gm,(g,y)=>`<h2 id="${Oo(y)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${y}</h2>`).replace(/^# (.+)$/gm,(g,y)=>`<h1 id="${Oo(y)}" class="text-lg font-bold text-text-primary mb-3">${y}</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 y=g.replace(/^> /gm,"").trim(),E=/⚠️|warning|caution/i.test(y),_=/note:|ℹ️|info/i.test(y);return`<div class="${E?"bg-status-warning/5":_?"bg-accent/5":"bg-surface-sunken/50"} ${E?"border-status-warning":_?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${y}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(u('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(u('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(u('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,y)=>t[parseInt(y,10)]);const d="text-xs leading-relaxed text-text-secondary mb-2",m=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const y=g.trim();if(!y)return"";const E=[];let _=y,T;for(;(T=m.exec(_))!==null;){const R=T.index+T[0].length;E.push(_.slice(0,R)),_=_.slice(R).replace(/^<br\/>/,"").trim(),m.lastIndex=0}return _&&E.push(_),E.map(R=>{const C=R.trim();return C?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(C)?C:`<p class="${d}">${C}</p>`:""}).join("")}).join(""),s}const i2=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function r2(i){return i2.test(i)}function Nh({content:i,className:t,onClick:s}){const a=j.useMemo(()=>s2(i),[i]);return h.jsx("div",{className:t,onClick:s,dangerouslySetInnerHTML:{__html:a}})}function Go({data:i,depth:t=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:t>0,[u,d]=j.useState(o),[m,g]=j.useState(s);if(s!==void 0&&s!==m&&(g(s),d(s%2===0&&t>0)),i==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof i=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',i,'"']});if(typeof i=="number"||typeof i=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(i)});if(Array.isArray(i))return i.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):u?h.jsxs("button",{onClick:()=>d(!1),className:"text-text-secondary hover:text-text-primary",children:["[",i.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:i.map((y,E)=>h.jsxs("div",{children:[h.jsx(Go,{data:y,depth:t+1,generation:s}),E<i.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},E))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof i=="object"){const y=Object.entries(i);return y.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):u?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:y.map(([E,_],T)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:E}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(Go,{data:_,depth:t+1,generation:s}),T<y.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},E))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(i)})}function Ya({data:i,depth:t=0}){if(i==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof i=="string")return i.length>40&&r2(i)?h.jsx(Nh,{content:i}):h.jsx("span",{className:"text-text-primary",children:i});if(typeof i=="number"||typeof i=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(i)});if(Array.isArray(i))return i.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:i.map((s,a)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[a+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(Ya,{data:s,depth:t+1})})]},a))});if(typeof i=="object"){const s=Object.entries(i);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(([a,o])=>{const u=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:a.replace(/[_-]/g," ")}),u?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(Ya,{data:o,depth:t+1})}):h.jsx(Ya,{data:o,depth:t+1})]},a)})})}return h.jsx("span",{children:String(i)})}function og({mode:i,setMode:t,isCollapsed:s,onToggleCollapse:a,onCopy:o,copied:u,onFullscreen:d,onClose:m,large:g}){const y=g?"w-5 h-5":"w-3.5 h-3.5",E=`${g?"p-2":"p-1.5"} rounded text-text-tertiary hover:text-text-primary 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:[i==="json"&&h.jsx("button",{onClick:a,className:E,title:s?"Expand all":"Collapse all",children:s?h.jsx(t2,{className:y}):h.jsx(e2,{className:y})}),h.jsx("button",{onClick:()=>t(i==="json"?"tree":"json"),className:E,title:i==="json"?"Outline view":"JSON view",children:i==="json"?h.jsx(KS,{className:y}):h.jsx(XS,{className:y})}),h.jsx("button",{onClick:o,className:E,title:"Copy to clipboard",children:u?h.jsx(WS,{className:`${y} text-status-success`}):h.jsx(ZS,{className:y})}),d&&h.jsx("button",{onClick:d,className:E,title:"Fullscreen",children:h.jsx(Dg,{className:y})}),m&&h.jsx("button",{onClick:m,className:E,title:"Close (Esc)",children:h.jsx(qg,{className:y})})]})}function a2({data:i,label:t,variant:s,defaultCollapsed:a=!1,defaultMode:o}){const u=j.useRef(null),[d,m]=j.useState(o??"json"),[g,y]=j.useState(!1),[E,_]=j.useState(!1),[T,R]=j.useState(a?0:1),[C,D]=j.useState(1),F=T%2===0,te=C%2===0,X=j.useCallback(()=>R(Z=>Z+1),[]),fe=j.useCallback(()=>D(Z=>Z+1),[]);let oe=i;if(typeof i=="string")try{oe=JSON.parse(i)}catch{}const O=async()=>{const Z=typeof i=="string"?i:JSON.stringify(oe,null,2);await navigator.clipboard.writeText(Z),y(!0),setTimeout(()=>y(!1),2e3)},U=j.useCallback(()=>{D(1),_(!0)},[]),ne=s==="panel",G=ne?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",I=ne?"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 rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:G,children:[t&&h.jsx(JS,{children:t}),h.jsxs("div",{ref:u,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(og,{mode:d,setMode:m,isCollapsed:F,onToggleCollapse:X,onCopy:O,copied:g,onFullscreen:U})}),h.jsx("div",{className:I,children:d==="json"?h.jsx(Go,{data:oe,generation:T}):h.jsx(Ya,{data:oe})})]}),h.jsxs(Ry,{open:E,onClose:()=>_(!1),sourceRef:u,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(og,{mode:d,setMode:m,isCollapsed:te,onToggleCollapse:fe,onCopy:O,copied:g,onClose:()=>_(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:d==="json"?h.jsx(Go,{data:oe,generation:C}):h.jsx(Ya,{data:oe})})]})]})}const l2=100,cg=500;let o2=0;const Dy={"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 qy(i){const t=i.split(".");return t[0]==="system"&&t.length>=3?`${t[1]}.${t[t.length-1]}`:i}function ug({event:i,forceExpanded:t=!1}){var T,R;const[s,a]=j.useState(t),o=Dy[qy(i.type)]||"text-text-tertiary";j.useEffect(()=>{a(t)},[t]);const u=t,d=u?"text-xs":"text-2xs",m=u?"text-xs":"text-2xs",g=u?"text-xs":"text-2xs",y=u?"w-3.5 h-3.5":"w-2.5 h-2.5",E=u?"py-2 px-4":"py-1 px-3",_=u?"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:()=>a(!s),className:`flex items-center gap-2 ${E} 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(i.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${m} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:i.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(T=i.data)!=null&&T.workflowId?String(i.data.workflowId):"",(R=i.data)!=null&&R.escalationId?` esc:${String(i.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${y} 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(Oh,{open:s,children:h.jsx("div",{className:_,children:h.jsx(a2,{data:i.data})})})]})}function c2({open:i,onToggle:t,configOpen:s,onToggleConfig:a}){const[o,u]=j.useState([]),[d,m]=j.useState(!1),[g,y]=j.useState(""),E=j.useRef(null),_=j.useRef(new Map),{subscribe:T}=j.useContext(Dr),{patterns:R,pagePattern:C,userPatterns:D,addPattern:F,removePattern:te}=FS(),X=j.useCallback(O=>{const U=String(O.type||"unknown");if(U.startsWith("mesh."))return;const ne=`${U}:${O.timestamp||""}:${O.escalationId||O.workflowId||O.taskId||""}`,G=Date.now(),I=_.current.get(ne);if(!(I&&G-I<cg)){if(_.current.set(ne,G),_.current.size>200)for(const[Z,ae]of _.current)G-ae>cg*2&&_.current.delete(Z);u(Z=>[{id:++o2,type:U,timestamp:O.timestamp||new Date().toISOString(),data:O},...Z].slice(0,l2))}},[]),fe=j.useRef(X);fe.current=X;const oe=i||d||s;return j.useEffect(()=>{if(!oe)return;const O=R.map(U=>T(U,ne=>fe.current(ne)));return()=>O.forEach(U=>U())},[T,R.join(","),oe]),j.useEffect(()=>{i&&E.current&&(E.current.scrollTop=0)},[o.length,i]),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:[i?h.jsx(Nv,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(Tv,{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&&!i&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Dy[qy(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 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:O=>{O.stopPropagation(),a()},children:h.jsx(kv,{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:O=>{O.stopPropagation(),m(!0)},children:h.jsx(Dg,{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:O=>{O.stopPropagation(),u([])},children:h.jsx(Cv,{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:C.replace("lt.events.","")}),D.map(O=>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:[O.replace("lt.events.",""),h.jsx("button",{onClick:()=>te(O),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Gn,{className:"w-2 h-2"})})]},O))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:O=>y(O.target.value),onKeyDown:O=>{O.key==="Enter"&&g.trim()&&(F(g.trim()),y(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(F(g.trim()),y(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(Rg,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Oh,{open:i,children:h.jsx("div",{ref:E,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(O=>h.jsx(ug,{event:O},O.id))})}),h.jsxs(Ry,{open:d,onClose:()=>m(!1),sourceRef:E,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>m(!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(qg,{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(O=>h.jsx(ug,{event:O,forceExpanded:!0},O.id))]})]})}function u2(){return ht({queryKey:["docs"],queryFn:()=>Ee("/docs"),staleTime:5*6e4})}function f2(i){return ht({queryKey:["docs",i],queryFn:()=>Ee(`/docs/read?path=${encodeURIComponent(i)}`),enabled:!!i,staleTime:5*6e4})}function h2(){const[i,t]=j.useState([]),[s,a]=j.useState([]),[o,u]=j.useState(null),d=j.useRef(o),m=j.useRef(i),g=j.useRef(s);d.current=o,m.current=i,g.current=s;const y=j.useCallback((C,D)=>{var te;const F=d.current;if(F){const X=((te=D==null?void 0:D.current)==null?void 0:te.scrollTop)??0;t([...m.current,{...F,scrollTop:X}])}a([]),u({path:C,scrollTop:0})},[]),E=j.useCallback(C=>{var X;const D=m.current;if(D.length===0)return;const F=D[D.length-1],te=d.current;if(te){const fe=((X=C==null?void 0:C.current)==null?void 0:X.scrollTop)??0;a([...g.current,{...te,scrollTop:fe}])}t(D.slice(0,-1)),u(F),requestAnimationFrame(()=>{C!=null&&C.current&&(C.current.scrollTop=F.scrollTop)})},[]),_=j.useCallback(C=>{var X;const D=g.current;if(D.length===0)return;const F=D[D.length-1],te=d.current;if(te){const fe=((X=C==null?void 0:C.current)==null?void 0:X.scrollTop)??0;t([...m.current,{...te,scrollTop:fe}])}a(D.slice(0,-1)),u(F),requestAnimationFrame(()=>{C!=null&&C.current&&(C.current.scrollTop=F.scrollTop)})},[]),T=j.useCallback(C=>{var te,X;const D=d.current;if(!D)return;const F=((te=C==null?void 0:C.current)==null?void 0:te.scrollTop)??0;t([...m.current,{...D,scrollTop:F}]),a([]),u({...D,scrollTop:((X=C==null?void 0:C.current)==null?void 0:X.scrollTop)??0})},[]),R=j.useCallback(()=>{t([]),a([]),u(null)},[]);return{current:o,backStack:i,forwardStack:s,navigate:y,goBack:E,goForward:_,pushScrollPosition:T,reset:R}}function d2(i,t){const[s,a]=i.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const d=((t?t.replace(/[^/]+$/,""):"")+o).split("/"),m=[];for(const g of d)g===".."?m.pop():g&&g!=="."&&m.push(g);o=m.join("/")}return{path:o,anchor:a}}function m2(i){if(!i.startsWith("#docs"))return null;const t=i.slice(1).split(":"),s=t[1]||"README.md",a=t[2]||void 0;return{path:s,anchor:a}}function p2(i){return!i||i==="README.md"?"#docs":`#docs:${i}`}function g2({content:i,currentPath:t,onNavigate:s,onAnchorClick:a}){const o=u=>{var y;const d=u.target,m=d.closest("[data-anchor]");if(m){u.preventDefault(),a();const E=m.dataset.anchor,_=(y=m.closest(".docs-content"))==null?void 0:y.querySelector(`#${CSS.escape(E)}`);_==null||_.scrollIntoView({behavior:"smooth",block:"start"});return}const g=d.closest("[data-doc-link]");if(g){u.preventDefault();const{path:E,anchor:_}=d2(g.dataset.docLink,t);s(E,_);return}};return h.jsx(Nh,{content:i,className:"docs-content",onClick:o})}function y2(i){const t=[],s=new Map;for(const a of i){const o=a.path.split("/");if(o.length===1){t.push(a);continue}let u=s;for(let d=0;d<o.length-1;d++){const m=o[d];u.has(m)||u.set(m,{label:m,children:[],subdirs:new Map});const g=u.get(m);d===o.length-2?g.children.push(a):u=g.subdirs}}return{topLevel:t,dirs:s}}function b2({docs:i,selected:t,onSelect:s}){const{topLevel:a,dirs:o}=y2(i),u=m=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${t===m?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function d(m,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(Mv,{className:"w-3 h-3",strokeWidth:1.5}),m.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...m.subdirs.values()].map(y=>d(y)),m.children.map(y=>h.jsx("button",{className:u(y.path),onClick:()=>s(y.path),children:y.title},y.path))]})]},m.label)}return h.jsxs("div",{className:"space-y-0.5",children:[a.map(m=>h.jsx("button",{className:u(m.path),onClick:()=>s(m.path),children:m.title},m.path)),[...o.values()].map(m=>d(m))]})}function x2({open:i,onClose:t}){var ne,G,I;const[s,a]=j.useState(!1),{data:o}=u2(),u=h2(),{data:d,isLoading:m}=f2(((ne=u.current)==null?void 0:ne.path)??null),g=j.useRef(null),[y,E]=j.useState(null);j.useEffect(()=>{y&&(d!=null&&d.content)&&g.current&&requestAnimationFrame(()=>{var ae;const Z=(ae=g.current)==null?void 0:ae.querySelector(`#${CSS.escape(y)}`);Z==null||Z.scrollIntoView({behavior:"smooth",block:"start"}),E(null)})},[y,d]);const _=j.useCallback(()=>{var re;const Z=m2(window.location.hash),ae=(Z==null?void 0:Z.path)??"README.md";((re=u.current)==null?void 0:re.path)!==ae&&u.navigate(ae,g),Z!=null&&Z.anchor&&E(Z.anchor)},[u]),T=j.useRef(!0);j.useEffect(()=>{if(!i||!u.current)return;if(T.current){T.current=!1;return}const Z=p2(u.current.path);window.location.hash!==Z&&window.history.replaceState(null,"",window.location.pathname+window.location.search+Z)},[i,(G=u.current)==null?void 0:G.path]),j.useEffect(()=>{if(!i)return;const Z=()=>{window.location.hash.startsWith("#docs")&&_()};return window.addEventListener("hashchange",Z),()=>window.removeEventListener("hashchange",Z)},[i,_]);const R=j.useCallback((Z,ae)=>{ae&&E(ae),u.navigate(Z,g)},[u]),C=j.useCallback(Z=>{u.navigate(Z,g)},[u]),D=j.useCallback(()=>{u.goBack(g)},[u]),F=j.useCallback(()=>{u.goForward(g)},[u]),te=j.useCallback(()=>{u.pushScrollPosition(g)},[u]);if(j.useEffect(()=>{if(i){T.current=!0,_();const Z=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(Z)}},[i]),!(i||s))return null;const fe=()=>{a(!1),setTimeout(()=>{t(),u.reset()},200)},oe=((I=u.current)==null?void 0:I.path)??null,O=u.backStack.length>0,U=u.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&&i?"opacity-100":"opacity-0"}`,onClick:fe}),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&&i?"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:D,disabled:!O,className:`p-0.5 transition-colors ${O?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(kg,{className:"w-4 h-4"})}),h.jsx("button",{onClick:F,disabled:!U,className:`p-0.5 transition-colors ${U?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(Tf,{className:"w-4 h-4"})}),h.jsx(Mg,{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:fe,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Gn,{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(b2,{docs:o.docs,selected:oe,onSelect:C}):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?m?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(g2,{content:d.content,currentPath:oe,onNavigate:R,onAnchorClick:te}):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(Tf,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function v2(i){if(i.includes("/escalations"))return["escalation","human-queue"]}const fg=2e3;function _2(i){const s=i.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
57
57
  ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
58
58
  `)}
59
59
  [End prior conversation]
60
60
 
61
- `}function g2(i){const t=i.summary,s=i.title;if(t){const a=t.search(/\n\s*\{[\s\S]*"title"\s*:/);return a>0?t.slice(0,a).trim():t}return s||(typeof i=="string"?i:"Query completed.")}const Dy=A.createContext(null);function y2({children:i}){const t=Sn(),[s,a]=A.useState(!1),[o,u]=A.useState([]),[d,m]=A.useState(null),[g,y]=A.useState({}),E=A.useRef(null),_={page:t.pathname.split("/").filter(Boolean).join("-")||"home",route:t.pathname,params:{},...g,suggestedTags:g.suggestedTags??m2(t.pathname)};A.useEffect(()=>()=>{E.current&&clearInterval(E.current)},[]);const N=A.useCallback(()=>a(te=>!te),[]),R=A.useCallback(te=>{y(te)},[]),M=A.useCallback(()=>{u([]),m(null)},[]),D=A.useCallback(async te=>{var I;const $=new Date().toISOString(),ce={id:`user-${Date.now()}`,role:"user",content:te,timestamp:$},oe={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:$,pending:!0};u(F=>[...F,ce,oe]);const O={..._};(I=O.entities)!=null&&I.yamlContent&&O.entities.yamlContent.length>lg&&(O.entities={...O.entities,yamlContent:O.entities.yamlContent.slice(0,lg)+`
62
- ... (truncated)`});const ae=`${p2(o.concat(ce))}${te}`;try{const Z=(await we("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ae,tags:O.suggestedTags,context:O,wait:!1,direct:!0})})).workflow_id;m(Z),u(re=>re.map(ie=>ie.id===oe.id?{...ie,workflowId:Z}:ie)),E.current&&clearInterval(E.current),E.current=setInterval(async()=>{var re;try{const ie=await we(`/workflows/${Z}/result`),Oe=(re=ie==null?void 0:ie.result)==null?void 0:re.data;if(Oe){E.current&&clearInterval(E.current),E.current=null,m(null);const ke=g2(Oe);let Se;try{Se=(await we(`/workflow-states/${Z}/execution`)).duration_ms}catch{}u(z=>z.map(ne=>ne.id===oe.id?{...ne,content:ke,timestamp:new Date().toISOString(),pending:!1,durationMs:Se}:ne))}}catch{}},3e3)}catch{u(F=>F.map(Z=>Z.id===oe.id?{...Z,content:"Failed to submit query. Please try again.",pending:!1}:Z))}},[o,_]),G=A.useCallback(async te=>{const $=o.find(O=>O.id===te);if(!($!=null&&$.workflowId)||$.compilationStatus==="compiling"||$.compilationStatus==="done")return;const ce=o.indexOf($),oe=o.slice(0,ce).reverse().find(O=>O.role==="user");if(oe){u(O=>O.map(J=>J.id===te?{...J,compilationStatus:"compiling"}:J));try{const O=await we("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:oe.content,summary:$.content})}),J=await we("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:$.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:O.tool_name,description:O.description,tags:O.tags,app_id:""})});await we(`/yaml-workflows/${J.id}/deploy`,{method:"POST"}),u(ae=>ae.map(I=>I.id===te?{...I,compilationStatus:"done"}:I))}catch(O){const J=O instanceof Error?O.message:"Compilation failed";u(ae=>ae.map(I=>I.id===te?{...I,compilationStatus:"error",compilationError:J}:I))}}},[o]);return h.jsx(Dy.Provider,{value:{helpOpen:s,setHelpOpen:a,toggleHelp:N,messages:o,sendMessage:D,pageContext:_,setPageContext:R,activeWorkflowId:d,clearMessages:M,compileMessage:G},children:i})}function qy(){const i=A.useContext(Dy);if(!i)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return i}function b2(){const{helpOpen:i,toggleHelp:t}=qy();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":i?"Close help":"Ask for help",children:i?h.jsx(Gn,{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(${Tt}/logo512.png)`}})})}const zy=6048e5,x2=864e5,og=6e4,cg=525600,ug=43200,fg=1440,hg=Symbol.for("constructDateFrom");function gs(i,t){return typeof i=="function"?i(t):i&&typeof i=="object"&&hg in i?i[hg](t):i instanceof Date?new i.constructor(t):new Date(t)}function ln(i,t){return gs(t||i,i)}let v2={};function Za(){return v2}function Qa(i,t){var m,g,y,E;const s=Za(),a=(t==null?void 0:t.weekStartsOn)??((g=(m=t==null?void 0:t.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.weekStartsOn)??0,o=ln(i,t==null?void 0:t.in),u=o.getDay(),d=(u<a?7:0)+u-a;return o.setDate(o.getDate()-d),o.setHours(0,0,0,0),o}function Vo(i,t){return Qa(i,{...t,weekStartsOn:1})}function Uy(i,t){const s=ln(i,t==null?void 0:t.in),a=s.getFullYear(),o=gs(s,0);o.setFullYear(a+1,0,4),o.setHours(0,0,0,0);const u=Vo(o),d=gs(s,0);d.setFullYear(a,0,4),d.setHours(0,0,0,0);const m=Vo(d);return s.getTime()>=u.getTime()?a+1:s.getTime()>=m.getTime()?a:a-1}function Io(i){const t=ln(i),s=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return s.setUTCFullYear(t.getFullYear()),+i-+s}function By(i,...t){const s=gs.bind(null,i||t.find(a=>typeof a=="object"));return t.map(s)}function dg(i,t){const s=ln(i,t==null?void 0:t.in);return s.setHours(0,0,0,0),s}function _2(i,t,s){const[a,o]=By(s==null?void 0:s.in,i,t),u=dg(a),d=dg(o),m=+u-Io(u),g=+d-Io(d);return Math.round((m-g)/x2)}function w2(i,t){const s=Uy(i,t),a=gs(i,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),Vo(a)}function S2(i,t){const s=+ln(i)-+ln(t);return s<0?-1:s>0?1:s}function E2(i){return gs(i,Date.now())}function j2(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function A2(i){return!(!j2(i)&&typeof i!="number"||isNaN(+ln(i)))}function O2(i){return t=>{const a=(i?Math[i]:Math.trunc)(t);return a===0?0:a}}function N2(i,t){const s=ln(i,t==null?void 0:t.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const T2={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"}},k2=(i,t,s)=>{let a;const o=T2[i];return typeof o=="string"?a=o:t===1?a=o.one:a=o.other.replace("{{count}}",t.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+a:a+" ago":a};function Of(i){return(t={})=>{const s=t.width?String(t.width):i.defaultWidth;return i.formats[s]||i.formats[i.defaultWidth]}}const C2={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},M2={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},R2={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},D2={date:Of({formats:C2,defaultWidth:"full"}),time:Of({formats:M2,defaultWidth:"full"}),dateTime:Of({formats:R2,defaultWidth:"full"})},q2={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},z2=(i,t,s,a)=>q2[i];function Da(i){return(t,s)=>{const a=s!=null&&s.context?String(s.context):"standalone";let o;if(a==="formatting"&&i.formattingValues){const d=i.defaultFormattingWidth||i.defaultWidth,m=s!=null&&s.width?String(s.width):d;o=i.formattingValues[m]||i.formattingValues[d]}else{const d=i.defaultWidth,m=s!=null&&s.width?String(s.width):i.defaultWidth;o=i.values[m]||i.values[d]}const u=i.argumentCallback?i.argumentCallback(t):t;return o[u]}}const U2={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},B2={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},L2={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"]},P2={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"]},H2={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"}},$2={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"}},Y2=(i,t)=>{const s=Number(i),a=s%100;if(a>20||a<10)switch(a%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},G2={ordinalNumber:Y2,era:Da({values:U2,defaultWidth:"wide"}),quarter:Da({values:B2,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Da({values:L2,defaultWidth:"wide"}),day:Da({values:P2,defaultWidth:"wide"}),dayPeriod:Da({values:H2,defaultWidth:"wide",formattingValues:$2,defaultFormattingWidth:"wide"})};function qa(i){return(t,s={})=>{const a=s.width,o=a&&i.matchPatterns[a]||i.matchPatterns[i.defaultMatchWidth],u=t.match(o);if(!u)return null;const d=u[0],m=a&&i.parsePatterns[a]||i.parsePatterns[i.defaultParseWidth],g=Array.isArray(m)?I2(m,_=>_.test(d)):V2(m,_=>_.test(d));let y;y=i.valueCallback?i.valueCallback(g):g,y=s.valueCallback?s.valueCallback(y):y;const E=t.slice(d.length);return{value:y,rest:E}}}function V2(i,t){for(const s in i)if(Object.prototype.hasOwnProperty.call(i,s)&&t(i[s]))return s}function I2(i,t){for(let s=0;s<i.length;s++)if(t(i[s]))return s}function F2(i){return(t,s={})=>{const a=t.match(i.matchPattern);if(!a)return null;const o=a[0],u=t.match(i.parsePattern);if(!u)return null;let d=i.valueCallback?i.valueCallback(u[0]):u[0];d=s.valueCallback?s.valueCallback(d):d;const m=t.slice(o.length);return{value:d,rest:m}}}const J2=/^(\d+)(th|st|nd|rd)?/i,Q2=/\d+/i,K2={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},X2={any:[/^b/i,/^(a|c)/i]},Z2={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},W2={any:[/1/i,/2/i,/3/i,/4/i]},eE={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},tE={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]},nE={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},sE={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]},iE={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},rE={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}},aE={ordinalNumber:F2({matchPattern:J2,parsePattern:Q2,valueCallback:i=>parseInt(i,10)}),era:qa({matchPatterns:K2,defaultMatchWidth:"wide",parsePatterns:X2,defaultParseWidth:"any"}),quarter:qa({matchPatterns:Z2,defaultMatchWidth:"wide",parsePatterns:W2,defaultParseWidth:"any",valueCallback:i=>i+1}),month:qa({matchPatterns:eE,defaultMatchWidth:"wide",parsePatterns:tE,defaultParseWidth:"any"}),day:qa({matchPatterns:nE,defaultMatchWidth:"wide",parsePatterns:sE,defaultParseWidth:"any"}),dayPeriod:qa({matchPatterns:iE,defaultMatchWidth:"any",parsePatterns:rE,defaultParseWidth:"any"})},Ly={code:"en-US",formatDistance:k2,formatLong:D2,formatRelative:z2,localize:G2,match:aE,options:{weekStartsOn:0,firstWeekContainsDate:1}};function lE(i,t){const s=ln(i,t==null?void 0:t.in);return _2(s,N2(s))+1}function oE(i,t){const s=ln(i,t==null?void 0:t.in),a=+Vo(s)-+w2(s);return Math.round(a/zy)+1}function Py(i,t){var E,_,N,R;const s=ln(i,t==null?void 0:t.in),a=s.getFullYear(),o=Za(),u=(t==null?void 0:t.firstWeekContainsDate)??((_=(E=t==null?void 0:t.locale)==null?void 0:E.options)==null?void 0:_.firstWeekContainsDate)??o.firstWeekContainsDate??((R=(N=o.locale)==null?void 0:N.options)==null?void 0:R.firstWeekContainsDate)??1,d=gs((t==null?void 0:t.in)||i,0);d.setFullYear(a+1,0,u),d.setHours(0,0,0,0);const m=Qa(d,t),g=gs((t==null?void 0:t.in)||i,0);g.setFullYear(a,0,u),g.setHours(0,0,0,0);const y=Qa(g,t);return+s>=+m?a+1:+s>=+y?a:a-1}function cE(i,t){var m,g,y,E;const s=Za(),a=(t==null?void 0:t.firstWeekContainsDate)??((g=(m=t==null?void 0:t.locale)==null?void 0:m.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.firstWeekContainsDate)??1,o=Py(i,t),u=gs((t==null?void 0:t.in)||i,0);return u.setFullYear(o,0,a),u.setHours(0,0,0,0),Qa(u,t)}function uE(i,t){const s=ln(i,t==null?void 0:t.in),a=+Qa(s,t)-+cE(s,t);return Math.round(a/zy)+1}function Ve(i,t){const s=i<0?"-":"",a=Math.abs(i).toString().padStart(t,"0");return s+a}const Js={y(i,t){const s=i.getFullYear(),a=s>0?s:1-s;return Ve(t==="yy"?a%100:a,t.length)},M(i,t){const s=i.getMonth();return t==="M"?String(s+1):Ve(s+1,2)},d(i,t){return Ve(i.getDate(),t.length)},a(i,t){const s=i.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(i,t){return Ve(i.getHours()%12||12,t.length)},H(i,t){return Ve(i.getHours(),t.length)},m(i,t){return Ve(i.getMinutes(),t.length)},s(i,t){return Ve(i.getSeconds(),t.length)},S(i,t){const s=t.length,a=i.getMilliseconds(),o=Math.trunc(a*Math.pow(10,s-3));return Ve(o,t.length)}},_r={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},mg={G:function(i,t,s){const a=i.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return s.era(a,{width:"abbreviated"});case"GGGGG":return s.era(a,{width:"narrow"});case"GGGG":default:return s.era(a,{width:"wide"})}},y:function(i,t,s){if(t==="yo"){const a=i.getFullYear(),o=a>0?a:1-a;return s.ordinalNumber(o,{unit:"year"})}return Js.y(i,t)},Y:function(i,t,s,a){const o=Py(i,a),u=o>0?o:1-o;if(t==="YY"){const d=u%100;return Ve(d,2)}return t==="Yo"?s.ordinalNumber(u,{unit:"year"}):Ve(u,t.length)},R:function(i,t){const s=Uy(i);return Ve(s,t.length)},u:function(i,t){const s=i.getFullYear();return Ve(s,t.length)},Q:function(i,t,s){const a=Math.ceil((i.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return Ve(a,2);case"Qo":return s.ordinalNumber(a,{unit:"quarter"});case"QQQ":return s.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(a,{width:"wide",context:"formatting"})}},q:function(i,t,s){const a=Math.ceil((i.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return Ve(a,2);case"qo":return s.ordinalNumber(a,{unit:"quarter"});case"qqq":return s.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(a,{width:"wide",context:"standalone"})}},M:function(i,t,s){const a=i.getMonth();switch(t){case"M":case"MM":return Js.M(i,t);case"Mo":return s.ordinalNumber(a+1,{unit:"month"});case"MMM":return s.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(a,{width:"wide",context:"formatting"})}},L:function(i,t,s){const a=i.getMonth();switch(t){case"L":return String(a+1);case"LL":return Ve(a+1,2);case"Lo":return s.ordinalNumber(a+1,{unit:"month"});case"LLL":return s.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(a,{width:"wide",context:"standalone"})}},w:function(i,t,s,a){const o=uE(i,a);return t==="wo"?s.ordinalNumber(o,{unit:"week"}):Ve(o,t.length)},I:function(i,t,s){const a=oE(i);return t==="Io"?s.ordinalNumber(a,{unit:"week"}):Ve(a,t.length)},d:function(i,t,s){return t==="do"?s.ordinalNumber(i.getDate(),{unit:"date"}):Js.d(i,t)},D:function(i,t,s){const a=lE(i);return t==="Do"?s.ordinalNumber(a,{unit:"dayOfYear"}):Ve(a,t.length)},E:function(i,t,s){const a=i.getDay();switch(t){case"E":case"EE":case"EEE":return s.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(a,{width:"short",context:"formatting"});case"EEEE":default:return s.day(a,{width:"wide",context:"formatting"})}},e:function(i,t,s,a){const o=i.getDay(),u=(o-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(u);case"ee":return Ve(u,2);case"eo":return s.ordinalNumber(u,{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(i,t,s,a){const o=i.getDay(),u=(o-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(u);case"cc":return Ve(u,t.length);case"co":return s.ordinalNumber(u,{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(i,t,s){const a=i.getDay(),o=a===0?7:a;switch(t){case"i":return String(o);case"ii":return Ve(o,t.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(a,{width:"short",context:"formatting"});case"iiii":default:return s.day(a,{width:"wide",context:"formatting"})}},a:function(i,t,s){const o=i.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(i,t,s){const a=i.getHours();let o;switch(a===12?o=_r.noon:a===0?o=_r.midnight:o=a/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(i,t,s){const a=i.getHours();let o;switch(a>=17?o=_r.evening:a>=12?o=_r.afternoon:a>=4?o=_r.morning:o=_r.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(i,t,s){if(t==="ho"){let a=i.getHours()%12;return a===0&&(a=12),s.ordinalNumber(a,{unit:"hour"})}return Js.h(i,t)},H:function(i,t,s){return t==="Ho"?s.ordinalNumber(i.getHours(),{unit:"hour"}):Js.H(i,t)},K:function(i,t,s){const a=i.getHours()%12;return t==="Ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,t.length)},k:function(i,t,s){let a=i.getHours();return a===0&&(a=24),t==="ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,t.length)},m:function(i,t,s){return t==="mo"?s.ordinalNumber(i.getMinutes(),{unit:"minute"}):Js.m(i,t)},s:function(i,t,s){return t==="so"?s.ordinalNumber(i.getSeconds(),{unit:"second"}):Js.s(i,t)},S:function(i,t){return Js.S(i,t)},X:function(i,t,s){const a=i.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return gg(a);case"XXXX":case"XX":return Oi(a);case"XXXXX":case"XXX":default:return Oi(a,":")}},x:function(i,t,s){const a=i.getTimezoneOffset();switch(t){case"x":return gg(a);case"xxxx":case"xx":return Oi(a);case"xxxxx":case"xxx":default:return Oi(a,":")}},O:function(i,t,s){const a=i.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+pg(a,":");case"OOOO":default:return"GMT"+Oi(a,":")}},z:function(i,t,s){const a=i.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+pg(a,":");case"zzzz":default:return"GMT"+Oi(a,":")}},t:function(i,t,s){const a=Math.trunc(+i/1e3);return Ve(a,t.length)},T:function(i,t,s){return Ve(+i,t.length)}};function pg(i,t=""){const s=i>0?"-":"+",a=Math.abs(i),o=Math.trunc(a/60),u=a%60;return u===0?s+String(o):s+String(o)+t+Ve(u,2)}function gg(i,t){return i%60===0?(i>0?"-":"+")+Ve(Math.abs(i)/60,2):Oi(i,t)}function Oi(i,t=""){const s=i>0?"-":"+",a=Math.abs(i),o=Ve(Math.trunc(a/60),2),u=Ve(a%60,2);return s+o+t+u}const yg=(i,t)=>{switch(i){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"})}},Hy=(i,t)=>{switch(i){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"})}},fE=(i,t)=>{const s=i.match(/(P+)(p+)?/)||[],a=s[1],o=s[2];if(!o)return yg(i,t);let u;switch(a){case"P":u=t.dateTime({width:"short"});break;case"PP":u=t.dateTime({width:"medium"});break;case"PPP":u=t.dateTime({width:"long"});break;case"PPPP":default:u=t.dateTime({width:"full"});break}return u.replace("{{date}}",yg(a,t)).replace("{{time}}",Hy(o,t))},hE={p:Hy,P:fE},dE=/^D+$/,mE=/^Y+$/,pE=["D","DD","YY","YYYY"];function gE(i){return dE.test(i)}function yE(i){return mE.test(i)}function bE(i,t,s){const a=xE(i,t,s);if(console.warn(a),pE.includes(i))throw new RangeError(a)}function xE(i,t,s){const a=i[0]==="Y"?"years":"days of the month";return`Use \`${i.toLowerCase()}\` instead of \`${i}\` (in \`${t}\`) for formatting ${a} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const vE=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,_E=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,wE=/^'([^]*?)'?$/,SE=/''/g,EE=/[a-zA-Z]/;function $y(i,t,s){var E,_,N,R;const a=Za(),o=a.locale??Ly,u=a.firstWeekContainsDate??((_=(E=a.locale)==null?void 0:E.options)==null?void 0:_.firstWeekContainsDate)??1,d=a.weekStartsOn??((R=(N=a.locale)==null?void 0:N.options)==null?void 0:R.weekStartsOn)??0,m=ln(i,s==null?void 0:s.in);if(!A2(m))throw new RangeError("Invalid time value");let g=t.match(_E).map(M=>{const D=M[0];if(D==="p"||D==="P"){const G=hE[D];return G(M,o.formatLong)}return M}).join("").match(vE).map(M=>{if(M==="''")return{isToken:!1,value:"'"};const D=M[0];if(D==="'")return{isToken:!1,value:jE(M)};if(mg[D])return{isToken:!0,value:M};if(D.match(EE))throw new RangeError("Format string contains an unescaped latin alphabet character `"+D+"`");return{isToken:!1,value:M}});o.localize.preprocessor&&(g=o.localize.preprocessor(m,g));const y={firstWeekContainsDate:u,weekStartsOn:d,locale:o};return g.map(M=>{if(!M.isToken)return M.value;const D=M.value;(yE(D)||gE(D))&&bE(D,t,String(i));const G=mg[D[0]];return G(m,D,o.localize,y)}).join("")}function jE(i){const t=i.match(wE);return t?t[1].replace(SE,"'"):i}function AE(i,t,s){const a=Za(),o=(s==null?void 0:s.locale)??a.locale??Ly,u=S2(i,t);if(isNaN(u))throw new RangeError("Invalid time value");const d=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:u}),[m,g]=By(s==null?void 0:s.in,...u>0?[t,i]:[i,t]),y=O2((s==null?void 0:s.roundingMethod)??"round"),E=g.getTime()-m.getTime(),_=E/og,N=Io(g)-Io(m),R=(E-N)/og,M=s==null?void 0:s.unit;let D;if(M?D=M:_<1?D="second":_<60?D="minute":_<fg?D="hour":R<ug?D="day":R<cg?D="month":D="year",D==="second"){const G=y(E/1e3);return o.formatDistance("xSeconds",G,d)}else if(D==="minute"){const G=y(_);return o.formatDistance("xMinutes",G,d)}else if(D==="hour"){const G=y(_/60);return o.formatDistance("xHours",G,d)}else if(D==="day"){const G=y(R/fg);return o.formatDistance("xDays",G,d)}else if(D==="month"){const G=y(R/ug);return G===12&&M!=="month"?o.formatDistance("xYears",1,d):o.formatDistance("xMonths",G,d)}else{const G=y(R/cg);return o.formatDistance("xYears",G,d)}}function OE(i,t){return AE(i,E2(i),t)}function OA(i){return i.toLocaleString()}function NA(i){return i>=1e9?`${(i/1e9).toFixed(1).replace(/\.0$/,"")}B`:i>=1e6?`${(i/1e6).toFixed(1).replace(/\.0$/,"")}M`:i>=1e4?`${(i/1e3).toFixed(1).replace(/\.0$/,"")}K`:i.toLocaleString()}function NE(i){const t=new Date(i);return t.getTime()>Date.now()?"just now":OE(t,{addSuffix:!0})}function TA(i){const t=Date.now()-new Date(i).getTime();if(t<0)return"now";const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const a=Math.floor(s/60);if(a<60)return`${a}m`;const o=Math.floor(a/60);if(o<24)return`${o}h`;const u=Math.floor(o/24);return u<7?`${u}d`:u<30?`${Math.floor(u/7)}w`:u<365?`${Math.floor(u/30)}mo`:`${Math.floor(u/365)}y`}function kA(i){return i<=0?"Expired":Oh(i)}function TE(i){return i==null?"--":Oh(i)}function Oh(i){if(i<1e3)return`${Math.round(i)}ms`;if(i<6e4){const d=i/1e3;return Number.isInteger(d)?`${d}s`:`${d.toFixed(1)}s`}const t=Math.floor(i/1e3),s=Math.floor(t/86400),a=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),u=t%60;return s>0?a>0?`${s}d ${a}h`:`${s}d`:a>0?o>0?`${a}h ${o}m`:`${a}h`:u>0?`${o}m ${u}s`:`${o}m`}function CA(i,t){const s=new Date(i).getTime(),a=t?new Date(t).getTime():Date.now();return Oh(a-s)}function Yy({options:i,children:t,className:s=""}){const[a,o]=A.useState(!1),[u,d]=A.useState(null),[m,g]=A.useState(null),y=A.useRef(null),E=A.useRef(void 0),_=A.useRef(void 0),N=220,R=A.useCallback(()=>{if(!y.current)return;const te=y.current.getBoundingClientRect(),$=window.innerWidth-N-8,ce=Math.max(8,Math.min(te.left,$));g({top:te.bottom+4,left:ce})},[]),M=A.useCallback(async(te,$)=>{try{await navigator.clipboard.writeText(te),d($),clearTimeout(E.current),E.current=setTimeout(()=>d(null),1200)}catch{}},[]),D=A.useCallback(()=>{clearTimeout(_.current),R(),o(!0)},[R]),G=A.useCallback(()=>{_.current=setTimeout(()=>o(!1),150)},[]);return A.useEffect(()=>()=>{clearTimeout(E.current),clearTimeout(_.current)},[]),h.jsxs("span",{ref:y,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:D,onMouseLeave:G,children:[t,a&&m&&jg.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:m.top,left:m.left},onMouseEnter:D,onMouseLeave:G,children:i.map(te=>h.jsxs("button",{onClick:$=>{$.stopPropagation(),M(te.value,te.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:te.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:u===te.label?"✓":te.value})]},te.label))}),document.body)]})}function kE(i,t){const s=new Date(i);switch(t){case"relative":return NE(i);case"datetime":return $y(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function CE(i){const t=new Date(i);return[{label:"ms",value:String(t.getTime())},{label:"utc",value:t.toISOString()},{label:"local",value:$y(t,"MMM d, yyyy h:mm:ss a")}]}function ME({date:i,format:t="relative",className:s=""}){const[,a]=A.useState(0);A.useEffect(()=>{if(t!=="relative")return;const u=setInterval(()=>a(d=>d+1),3e4);return()=>clearInterval(u)},[t]);const o=A.useMemo(()=>CE(i),[i]);return h.jsx(Yy,{options:o,children:h.jsx("time",{dateTime:i,className:`text-xs text-text-tertiary ${s}`,children:kE(i,t)})})}function RE({ms:i,className:t=""}){const s=TE(i),a=A.useMemo(()=>i==null?[]:[{label:"ms",value:String(i)},{label:"sec",value:`${(i/1e3).toFixed(3)}s`},{label:"text",value:s}],[i,s]);return i==null?h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:"--"}):h.jsx(Yy,{options:a,children:h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:s})})}const DE=["sm","md","lg","full"],bg={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"},xg={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function qE({which:i}){const t="stroke-current";switch(i){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 zE({msg:i}){const[t,s]=A.useState(0);A.useEffect(()=>{const d=new Date(i.timestamp).getTime(),m=()=>s(Math.floor((Date.now()-d)/1e3));m();const g=setInterval(m,1e3);return()=>clearInterval(g)},[i.timestamp]);const a=Math.floor(t/60),o=t%60,u=a>0?`${a}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:u})]}),i.workflowId&&h.jsxs(Ni,{to:`/workflows/executions/${i.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(sh,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function UE({msg:i,compileMessage:t}){const s=i.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(ME,{date:i.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),i.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(RE,{ms:i.durationMs,className:"!text-2xs text-text-muted/50"})]}),i.workflowId&&h.jsx(Ni,{to:`/workflows/executions/${i.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(sh,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&i.workflowId&&!i.pending&&h.jsx("button",{onClick:()=>t(i.id),disabled:i.compilationStatus==="compiling"||i.compilationStatus==="done",className:"transition-colors",title:i.compilationStatus==="done"?"Compiled — future queries will match this pipeline":i.compilationStatus==="error"?i.compilationError??"Compilation failed":i.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx(kv,{className:`w-2.5 h-2.5 ${i.compilationStatus==="done"?"text-status-success":i.compilationStatus==="error"?"text-status-error":i.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function BE(){const{helpOpen:i,setHelpOpen:t,messages:s,sendMessage:a,pageContext:o,activeWorkflowId:u,clearMessages:d,compileMessage:m}=qy(),[g,y]=A.useState(""),[E,_]=A.useState("md"),[N,R]=A.useState(!0),M=A.useRef(null),D=A.useRef(null);if(A.useEffect(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[s]),A.useEffect(()=>{i&&D.current&&D.current.focus()},[i]),A.useEffect(()=>{if(!i)return;const O=J=>{J.key==="Escape"&&(E==="full"?_("lg"):E==="lg"?_("md"):E==="md"?_("sm"):t(!1))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[i,E,t]),!i)return null;const G=()=>{const O=g.trim();!O||u||(a(O),y(""),D.current&&(D.current.style.height="auto"))},te=O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),G())},$=E==="full",ce=o.page.replace(/-/g," "),oe=$?{}:{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 ${$?bg.full:`right-6 ${bg[E]}`} ${N?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:oe,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!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 ${N?"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:ce})]}),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:DE.map(O=>h.jsx("button",{onClick:()=>_(O),className:`p-1 rounded transition-colors ${O===E?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":O===E,"aria-label":xg[O],title:xg[O],children:h.jsx(qE,{which:O})},O))}),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(Cv,{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(Gn,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:M,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${N?"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(O=>h.jsxs("div",{className:`text-xs leading-relaxed ${O.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 ${O.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:O.pending?h.jsx(zE,{msg:O}):O.role==="assistant"?h.jsx(Ah,{content:O.content}):O.content}),!O.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(UE,{msg:O,compileMessage:m})})]},O.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${N?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:D,value:g,onChange:O=>{y(O.target.value);const J=O.target;J.style.height="auto",J.style.height=`${Math.min(J.scrollHeight,120)}px`},onKeyDown:te,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:!!u}),h.jsx("button",{onClick:G,disabled:!g.trim()||!!u,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(Mv,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}function LE(){var ce;const{isBuilder:i,isOps:t,viewAs:s}=py(),{canSeePaceBoard:a}=gy(),{data:o}=Mi(),u=dy(),d=u!==null?u:!!((ce=o==null?void 0:o.ai)!=null&&ce.enabled),{collapsed:m,toggle:g}=Sh(),[y,E]=A.useState(!1),[_,N]=A.useState(!1),[R,M]=A.useState(!1),[D,G]=A.useState(()=>window.location.hash.startsWith("#docs")),te=Sn(),$=A.useRef(null);return A.useEffect(()=>{const oe=$.current;oe&&(oe.classList.remove("animate-page-in"),oe.offsetWidth,oe.classList.add("animate-page-in"))},[te.pathname]),A.useEffect(()=>{const oe=()=>{window.location.hash.startsWith("#docs")&&G(!0)};return window.addEventListener("hashchange",oe),()=>window.removeEventListener("hashchange",oe)},[]),h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(gS,{onToggleEventFeed:()=>E(oe=>!oe),onToggleDocs:()=>G(oe=>!oe),onToggleNav:()=>N(oe=>!oe)}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsxs("aside",{className:`${m?"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(Ty,{aiEnabled:d,isBuilder:i,isOps:t,viewAs:s,canSeePaceBoard:a})}),h.jsx("button",{onClick:g,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${m?"flex justify-center":"flex items-center px-7"}`,"aria-label":m?"Expand sidebar":"Collapse sidebar",children:m?h.jsx(Rv,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(Dv,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!m&&(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:$,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(Sr,{})})}),h.jsx(PE,{})]}),h.jsx(BS,{open:_,onClose:()=>N(!1),aiEnabled:d,isBuilder:i,isOps:t,viewAs:s,canSeePaceBoard:a}),h.jsx(s2,{open:y,onToggle:()=>E(oe=>!oe),configOpen:R,onToggleConfig:()=>M(oe=>!oe)}),h.jsx(d2,{open:D,onClose:()=>{G(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),d&&h.jsx(b2,{}),d&&h.jsx(BE,{})]})}function PE(){const{node:i,width:t,open:s}=rS();return h.jsx(aS,{open:s,width:t,className:"border-l border-surface-border bg-surface-raised",children:i})}function HE(){const{isAuthenticated:i}=Dn(),t=Sn();return i?h.jsx(nS,{children:h.jsx(iS,{children:h.jsx(y2,{children:h.jsx(LE,{})})})}):h.jsx(Pn,{to:"/login",state:{from:t.pathname},replace:!0})}function Gy({provider:i,className:t="w-5 h-5"}){switch(i){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 $E(){return we("/auth/oauth/providers")}async function YE(i,t){const s=t?`?label=${encodeURIComponent(t)}`:"";return we(`/auth/oauth/connections/${i}${s}`,{method:"DELETE"})}function MA(){return ht({queryKey:["oauth-connections"],queryFn:()=>we("/auth/oauth/connections")})}function RA(){const i=bt();return Et({mutationFn:({provider:t,label:s})=>YE(t,s),onSuccess:()=>{i.invalidateQueries({queryKey:["oauth-connections"]})}})}function GE(){var ae;const{login:i,isAuthenticated:t}=Dn(),s=nh(),a=Sn(),o=new URLSearchParams(a.search),u=o.get("token"),d=o.get("error"),m=((ae=a.state)==null?void 0:ae.from)??o.get("returnTo")??"/",g=A.useRef(!1);u&&!g.current&&(g.current=!0,i(u,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[y,E]=A.useState(""),[_,N]=A.useState(""),[R,M]=A.useState(d||""),[D,G]=A.useState(!1),[te,$]=A.useState(!!u),[ce,oe]=A.useState([]),O=A.useRef(!1);if(A.useEffect(()=>{u||O.current||(O.current=!0,(async()=>{var I,F,Z,re;try{const ie=await fetch(`${Tt}/api/settings`);if(!ie.ok)return;const Oe=await ie.json();if(!((I=Oe.auth)!=null&&I.sso))return;const ke=await fetch(`${Tt}/api/auth/sso`,{method:"POST"});if(!ke.ok){M("Host authentication required — please log in to your organization first");return}const Se=await ke.json();Se.token&&((F=Oe.auth)!=null&&F.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",Oe.auth.ssoLogoutUrl),$(!0),i(Se.token,void 0,{displayName:(Z=Se.user)==null?void 0:Z.display_name,username:(re=Se.user)==null?void 0:re.external_id}))}catch{}})())},[]),A.useEffect(()=>{u||$E().then(oe).catch(()=>{})},[]),A.useEffect(()=>{if(!te)return;const I=setTimeout(()=>s(m,{replace:!0}),1500);return()=>clearTimeout(I)},[te]),t&&!te)return h.jsx(Pn,{to:m,replace:!0});const J=async I=>{var F,Z;if(I.preventDefault(),M(""),!y.trim()||!_){M("Username and password are required");return}G(!0);try{const re=await fetch(`${Tt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:y.trim(),password:_})}),ie=await re.json();if(!re.ok){M(ie.error||"Login failed");return}$(!0),i(ie.token,{username:y.trim(),password:_},{displayName:(F=ie.user)==null?void 0:F.display_name,username:(Z=ie.user)==null?void 0:Z.external_id})}catch{M("Unable to connect to server")}finally{G(!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 ${te?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Yo,{size:"lg",hideLabel:te})}),h.jsxs("form",{onSubmit:J,className:`space-y-5 transition-opacity duration-300 ${te?"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:y,onChange:I=>E(I.target.value),className:"input",placeholder:"Enter your username",autoFocus:!te,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:_,onChange:I=>N(I.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),R&&h.jsx("p",{className:"text-sm text-status-error",children:R}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:D||te,children:D?"Signing in...":"Sign In"}),ce.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:ce.filter(I=>I.provider!=="anthropic").map(I=>h.jsxs("a",{href:`${Tt}/api/auth/oauth/${I.provider}?returnTo=${encodeURIComponent(m)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Gy,{provider:I.provider}),"Sign in with ",I.name]},I.provider))})]})]})]})})}function vg(){const{isAuthenticated:i}=Dn(),t=nh(),s=Sn(),a=new URLSearchParams(s.search),o=a.get("state")||"";A.useEffect(()=>{i||t(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[i]);const[u,d]=A.useState(""),[m,g]=A.useState(a.get("label")||"default"),[y,E]=A.useState(""),[_,N]=A.useState(!1),R=u.trim().startsWith("sk-ant-oat"),M=u.trim().startsWith("sk-ant-api"),D=G=>{G.preventDefault();const te=u.trim();if(!te){E("A token or API key is required");return}if(!te.startsWith("sk-ant-")){E('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}N(!0),E("");const $=`${Tt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(te)}&state=${encodeURIComponent(o)}`;window.location.href=$};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(Yo,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Gy,{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:D,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:u,onChange:G=>d(G.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),R&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),M&&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:m,onChange:G=>g(G.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").'})]}),y&&h.jsx("p",{className:"text-sm text-status-error",children:y}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:_,children:_?"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 za({roleTypes:i,roleNames:t,redirectTo:s="/"}){const{isSuperAdmin:a,hasRole:o,hasRoleType:u}=Dn();return a?h.jsx(Sr,{}):i&&i.some(d=>u(d))?h.jsx(Sr,{}):t&&t.some(d=>o(d))?h.jsx(Sr,{}):h.jsx(Pn,{to:s,replace:!0})}function VE({redirectTo:i="/"}){var a;const{data:t,isLoading:s}=Mi();return s||!t?null:(a=t.ai)!=null&&a.enabled?h.jsx(Sr,{}):h.jsx(Pn,{to:i,replace:!0})}function IE({flag:i,redirectTo:t="/"}){var o;const{data:s,isLoading:a}=Mi();return a||!s?null:((o=s.features)==null?void 0:o[i])===!1?h.jsx(Pn,{to:t,replace:!0}):h.jsx(Sr,{})}const FE=A.lazy(()=>_e(()=>import("./ProcessesListPage-Di0n8TR4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),import.meta.url).then(i=>({default:i.ProcessesListPage}))),JE=A.lazy(()=>_e(()=>import("./ProcessDetailPage-eLLUCWFf.js"),__vite__mapDeps([18,1,2,4,19,14,20,17,11,6,21,22,23]),import.meta.url).then(i=>({default:i.ProcessDetailPage}))),QE=A.lazy(()=>_e(()=>import("./McpOverview-Ca8cpc8g.js"),__vite__mapDeps([24,1,25,26,27,28,15,14,29,6]),import.meta.url).then(i=>({default:i.McpOverview}))),KE=A.lazy(()=>_e(()=>import("./McpRunsPage-B43BqEyw.js"),__vite__mapDeps([30,1,26,27,5,6,31,28,8,9,10,17,14,32,15,13,12,16,33]),import.meta.url).then(i=>({default:i.McpRunsPage}))),XE=A.lazy(()=>_e(()=>import("./McpRunDetailPage-C76mfUtG.js"),__vite__mapDeps([34,1,26,20,15,14,35,6,36,37,13,38,39,16]),import.meta.url).then(i=>({default:i.McpRunDetailPage}))),ZE=A.lazy(()=>_e(()=>import("./McpQueryPage-DPP6BB3d.js"),__vite__mapDeps([40,1,15,14,9,10,13,12,16,8,11,32,17,33,5,6,4,41]),import.meta.url).then(i=>({default:i.McpQueryPage}))),WE=A.lazy(()=>_e(()=>import("./McpQueryDetailPage-D0r2lyZg.js"),__vite__mapDeps([42,1,15,14,20,41,6,27,4,43,36,26,3,2,44,45,46,47,48,49,35,50,38,39]),import.meta.url).then(i=>({default:i.McpQueryDetailPage}))),ej=A.lazy(()=>_e(()=>import("./EscalationsOverview-Dbq7tKzr.js"),__vite__mapDeps([51,1,4,15,14,29,6]),import.meta.url).then(i=>({default:i.EscalationsOverview}))),tj=A.lazy(()=>_e(()=>import("./AvailableEscalationsPage-B-aHvGKD.js"),__vite__mapDeps([52,1,53,4,14,54,55,6,56,57,58,9,10,20,12,5,7,8,23,59,13,60,21,17,33,16]),import.meta.url).then(i=>({default:i.AvailableEscalationsPage}))),nj=A.lazy(()=>_e(()=>import("./OperatorDashboard-B70nS_Ah.js"),__vite__mapDeps([61,1,4,5,6,7,8,9,10,15,14,12,33,59,13,60,21,17,58,20,16]),import.meta.url).then(i=>({default:i.OperatorDashboard}))),sj=A.lazy(()=>_e(()=>import("./index-DVmC_UfQ.js"),__vite__mapDeps([62,1,54,55,6,56,15,14,16,58,9,10,20,12,3,4,21,35,22,23]),import.meta.url).then(i=>({default:i.EscalationDetailPage}))),ij=A.lazy(()=>_e(()=>import("./WorkflowsOverview-DmMdIRHQ.js"),__vite__mapDeps([63,1,3,4,15,14,29,6]),import.meta.url).then(i=>({default:i.WorkflowsOverview}))),rj=A.lazy(()=>_e(()=>import("./index-BzRXMicE.js"),__vite__mapDeps([64,1,3,15,14,13,17,65,47,48,6]),import.meta.url).then(i=>({default:i.StartWorkflowPage}))),aj=A.lazy(()=>_e(()=>import("./index-BzRXMicE.js"),__vite__mapDeps([64,1,3,15,14,13,17,65,47,48,6]),import.meta.url).then(i=>({default:i.DurableInvokePage}))),lj=A.lazy(()=>_e(()=>import("./WorkflowsDashboard-BRQmgsLR.js"),__vite__mapDeps([66,1,32,3,31,28,6,4,5,8,9,10,17,14,15,13,12,16,33]),import.meta.url).then(i=>({default:()=>i.WorkflowsDashboard({tier:"durable"})}))),oj=A.lazy(()=>_e(()=>import("./WorkflowsDashboard-BRQmgsLR.js"),__vite__mapDeps([66,1,32,3,31,28,6,4,5,8,9,10,17,14,15,13,12,16,33]),import.meta.url).then(i=>({default:()=>i.WorkflowsDashboard({tier:"all"})}))),cj=A.lazy(()=>_e(()=>import("./YamlWorkflowsPage-BIi77mE0.js"),__vite__mapDeps([67,1,27,5,6,15,14,13,10,49,65,20]),import.meta.url).then(i=>({default:i.YamlWorkflowsPage}))),uj=A.lazy(()=>_e(()=>import("./GraphInvokePage-CvLYp1nL.js"),__vite__mapDeps([68,1,27,15,14,44,46,47,48,45,6,49,65]),import.meta.url).then(i=>({default:i.GraphInvokePage}))),fj=A.lazy(()=>_e(()=>import("./YamlWorkflowDetailPage-Bj7QkCry.js"),__vite__mapDeps([69,1,27,20,65,14,6]),import.meta.url).then(i=>({default:i.YamlWorkflowDetailPage}))),hj=A.lazy(()=>_e(()=>import("./TasksListPage-DQdAayqc.js"),__vite__mapDeps([70,1,2,3,5,6,9,10,20,60,50,12,13,14,15,17]),import.meta.url).then(i=>({default:i.TasksListPage}))),dj=A.lazy(()=>_e(()=>import("./TaskDetailPage-C15nADUW.js"),__vite__mapDeps([71,1,2,20,60,15,14,6]),import.meta.url).then(i=>({default:i.TaskDetailPage}))),_g=A.lazy(()=>_e(()=>import("./WorkflowExecutionPage-C-snB_dD.js"),__vite__mapDeps([72,1,3,4,37,13,14,38,20,6,39,2,15,36,16,35]),import.meta.url).then(i=>({default:i.WorkflowExecutionPage}))),mj=A.lazy(()=>_e(()=>import("./AdminDashboard-DWSYdAeW.js"),__vite__mapDeps([73,1,2,4,25,19,14,6]),import.meta.url).then(i=>({default:i.AdminDashboard}))),pj=A.lazy(()=>_e(()=>import("./index-B6ldRx_s.js"),__vite__mapDeps([74,1,3,9,10,13,14,33,5,6,15,75,17]),import.meta.url).then(i=>({default:i.WorkersPage}))),gj=A.lazy(()=>_e(()=>import("./index-BHAjQoOy.js"),__vite__mapDeps([76,1,3,13,14,77,55,6,21,17,15,47,48,65]),import.meta.url).then(i=>({default:i.WorkflowConfigsPage}))),wg=A.lazy(()=>_e(()=>import("./index-BHAjQoOy.js"),__vite__mapDeps([76,1,3,13,14,77,55,6,21,17,15,47,48,65]),import.meta.url).then(i=>({default:i.WorkflowConfigDetailPage}))),yj=A.lazy(()=>_e(()=>import("./index-C7KY8GTF.js"),__vite__mapDeps([78,1,25,10,77,55,6,15,14,13,12,5,79,46,47,48,49,45,33,20]),import.meta.url).then(i=>({default:i.McpServersPage}))),Sg=A.lazy(()=>_e(()=>import("./index-CjBdB8Ht.js"),__vite__mapDeps([80,1,25,15,14,43,6]),import.meta.url).then(i=>({default:i.McpServerDetailPage}))),bj=A.lazy(()=>_e(()=>import("./index-D-7mT0ew.js"),__vite__mapDeps([81,1,23,5,6,9,10,12,13,14,77,55,33,15,21,48,50]),import.meta.url).then(i=>({default:i.UsersPage}))),xj=A.lazy(()=>_e(()=>import("./RolesPage-BnAwjUiG.js"),__vite__mapDeps([82,1,15,14,21,57,55,6]),import.meta.url).then(i=>({default:i.RolesPage}))),vj=A.lazy(()=>_e(()=>import("./RoleDetailPage-Dhn9zU5l.js"),__vite__mapDeps([83,1,77,55,6,23,14]),import.meta.url).then(i=>({default:i.RoleDetailPage}))),_j=A.lazy(()=>_e(()=>import("./EscalationSchemaPage-BaAn1Hcr.js"),__vite__mapDeps([84,1,14,6]),import.meta.url).then(i=>({default:i.EscalationSchemaPage}))),wj=A.lazy(()=>_e(()=>import("./EscalationListSchemaPage-CgcVIiYR.js"),__vite__mapDeps([85,1,14,6]),import.meta.url).then(i=>({default:i.EscalationListSchemaPage}))),Sj=A.lazy(()=>_e(()=>import("./index-CcMIca5t.js"),__vite__mapDeps([86,1,15,14,55,6,56]),import.meta.url).then(i=>({default:i.MaintenancePage}))),Ej=A.lazy(()=>_e(()=>import("./OperationsPage-DbHzQCuE.js").then(i=>i.O),__vite__mapDeps([87,1,4,15,14,57,6]),import.meta.url).then(i=>({default:i.OperationsPage}))),jj=A.lazy(()=>_e(()=>import("./index-DDA7FvqT.js"),__vite__mapDeps([88,1,19,14,13,5,6,31,28,55,36,75,9,10,33]),import.meta.url).then(i=>({default:i.ControlPlanePage}))),Aj=A.lazy(()=>_e(()=>import("./index-gBnGEubX.js"),__vite__mapDeps([89,1,39,14,5,6,31,28,8,9,10,12,13,15,16]),import.meta.url).then(i=>({default:i.StreamMessagesPage}))),Oj=A.lazy(()=>_e(()=>import("./CredentialsPage-Axdci1z-.js"),__vite__mapDeps([90,1,15,14,50,77,55,6]),import.meta.url).then(i=>({default:i.CredentialsPage}))),Nj=A.lazy(()=>_e(()=>import("./index-ovFEZ9SV.js"),__vite__mapDeps([91,1,6,15,14,13,16,8,10,92,50]),import.meta.url).then(i=>({default:i.FilesPage}))),Tj=A.lazy(()=>_e(()=>import("./index-Dht0ihGT.js"),__vite__mapDeps([93,1,15,14,13,16,12,10,92,50,94,43,6]),import.meta.url).then(i=>({default:i.KnowledgePage}))),kj=A.lazy(()=>_e(()=>import("./HomePage-B6s1ZeyA.js"),__vite__mapDeps([95,1,3,26,28,4,21,14,17,16,87,15,57,6,53]),import.meta.url).then(i=>({default:i.HomePage}))),Cj=A.lazy(()=>_e(()=>import("./AgentsPage-DKaDRk-Y.js"),__vite__mapDeps([96,1,97,4,5,6,8,9,10,12,13,14,15,16]),import.meta.url).then(i=>({default:i.AgentsPage}))),Mj=A.lazy(()=>_e(()=>import("./AgentDetailPage-D-Xbyrb6.js"),__vite__mapDeps([98,1,97,99,14,4,17,6]),import.meta.url).then(i=>({default:i.AgentDetailPage}))),Eg=A.lazy(()=>_e(()=>import("./AgentConfigPage-Dm6gL76m.js"),__vite__mapDeps([100,1,97,99,14,15,94,46,47,48,3,27,101,102,17,6]),import.meta.url).then(i=>({default:i.AgentConfigPage}))),Rj=A.lazy(()=>_e(()=>import("./CapabilitiesPage-DqRVzMol.js"),__vite__mapDeps([103,1,101,79,25,46,47,48,14,49,6,45,15,13]),import.meta.url).then(i=>({default:i.CapabilitiesPage}))),Dj=A.lazy(()=>_e(()=>import("./TopicsPage-o0EZxKbR.js"),__vite__mapDeps([104,1,102,15,14,13,6]),import.meta.url).then(i=>({default:i.TopicsPage}))),qj=A.lazy(()=>_e(()=>import("./TopicDetailPage-9A0aPb4t.js"),__vite__mapDeps([105,1,102,16,14,6]),import.meta.url).then(i=>({default:i.TopicDetailPage})));function zj(){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 ve({children:i}){return h.jsx(A.Suspense,{fallback:h.jsx(zj,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:i})})}const Vy=new nv({defaultOptions:{queries:{staleTime:1e4,retry:(i,t)=>t instanceof Error&&t.message==="Session expired"?!1:i<1}}});window.addEventListener("auth:unauthorized",()=>{Vy.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const i=window.__LT_BASE__||"",t=`${i}/login`;if(window.location.pathname!==t){const s=window.location.pathname+window.location.search,a=i&&s.startsWith(i)?s.slice(i.length)||"/":s;window.location.href=`${t}?returnTo=${encodeURIComponent(a)}`}});const Uj=rv([{path:"/login",element:h.jsx(GE,{})},{path:"/connect/anthropic",element:h.jsx(vg,{})},{path:"/connect/:provider",element:h.jsx(vg,{})},{path:"/",element:h.jsx(HE,{}),children:[{index:!0,element:h.jsx(ve,{children:h.jsx(kj,{})})},{path:"processes/all",element:h.jsx(ve,{children:h.jsx(FE,{})})},{path:"processes/detail/:originId",element:h.jsx(ve,{children:h.jsx(JE,{})})},{path:"credentials",element:h.jsx(ve,{children:h.jsx(Oj,{})})},{path:"connections",element:h.jsx(Pn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(ve,{children:h.jsx(ej,{})})},{path:"escalations/available",element:h.jsx(ve,{children:h.jsx(tj,{})})},{path:"escalations/queue",element:h.jsx(ve,{children:h.jsx(nj,{})})},{path:"escalations/detail/:id",element:h.jsx(ve,{children:h.jsx(sj,{})})},{path:"capabilities",element:h.jsx(ve,{children:h.jsx(Rj,{})})},{path:"agents",element:h.jsx(ve,{children:h.jsx(Cj,{})})},{path:"agents/new",element:h.jsx(ve,{children:h.jsx(Eg,{})})},{path:"agents/:id",element:h.jsx(ve,{children:h.jsx(Mj,{})})},{path:"agents/:id/edit",element:h.jsx(ve,{children:h.jsx(Eg,{})})},{path:"topics",element:h.jsx(ve,{children:h.jsx(Dj,{})})},{path:"topics/:topic",element:h.jsx(ve,{children:h.jsx(qj,{})})},{element:h.jsx(za,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(ve,{children:h.jsx(ij,{})})},{path:"workflows/executions",element:h.jsx(ve,{children:h.jsx(oj,{})})},{path:"workflows/durable/executions",element:h.jsx(ve,{children:h.jsx(lj,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(ve,{children:h.jsx(_g,{})})},{path:"workflows/tasks",element:h.jsx(ve,{children:h.jsx(hj,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(ve,{children:h.jsx(dj,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(ve,{children:h.jsx(_g,{})})},{path:"workflows/start",element:h.jsx(ve,{children:h.jsx(rj,{})})},{path:"workflows/durable/invoke",element:h.jsx(ve,{children:h.jsx(aj,{})})},{path:"workflows/cron",element:h.jsx(Pn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(ve,{children:h.jsx(pj,{})})},{path:"workflows/registry",element:h.jsx(ve,{children:h.jsx(gj,{})})},{path:"workflows/registry/new",element:h.jsx(ve,{children:h.jsx(wg,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(ve,{children:h.jsx(wg,{})})}]},{element:h.jsx(za,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(ve,{children:h.jsx(cj,{})})},{path:"mcp/workflows/invoke",element:h.jsx(ve,{children:h.jsx(uj,{})})},{path:"mcp/workflows/:id",element:h.jsx(ve,{children:h.jsx(fj,{})})},{path:"mcp/executions",element:h.jsx(ve,{children:h.jsx(KE,{})})},{path:"mcp/executions/:jobId",element:h.jsx(ve,{children:h.jsx(XE,{})})},{path:"files",element:h.jsx(ve,{children:h.jsx(Nj,{})})},{path:"knowledge",element:h.jsx(ve,{children:h.jsx(Tj,{})})},{element:h.jsx(VE,{}),children:[{path:"mcp",element:h.jsx(ve,{children:h.jsx(QE,{})})},{path:"mcp/queries",element:h.jsx(ve,{children:h.jsx(ZE,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(ve,{children:h.jsx(WE,{})})},{path:"mcp/tools",element:h.jsx(Pn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(ve,{children:h.jsx(yj,{})})},{path:"mcp/servers/new",element:h.jsx(ve,{children:h.jsx(Sg,{})})},{path:"mcp/servers/:serverId",element:h.jsx(ve,{children:h.jsx(Sg,{})})}]}]},{element:h.jsx(za,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"operations",element:h.jsx(ve,{children:h.jsx(Ej,{})})}]},{element:h.jsx(za,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(ve,{children:h.jsx(mj,{})})},{path:"admin/users",element:h.jsx(ve,{children:h.jsx(bj,{})})},{path:"admin/escalation-chains",element:h.jsx(Pn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(ve,{children:h.jsx(xj,{})})},{path:"admin/roles/:role",element:h.jsx(ve,{children:h.jsx(vj,{})})},{path:"admin/roles/:role/schema",element:h.jsx(ve,{children:h.jsx(_j,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(ve,{children:h.jsx(wj,{})})}]},{element:h.jsx(za,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(Pn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(IE,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(ve,{children:h.jsx(Sj,{})})}]},{path:"admin/controlplane",element:h.jsx(ve,{children:h.jsx(jj,{})})},{path:"admin/streams",element:h.jsx(ve,{children:h.jsx(Aj,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function Bj(){return h.jsx(sv,{client:Vy,children:h.jsx(Gv,{children:h.jsx(Fw,{children:h.jsx(av,{router:Uj})})})})}Oy(Ay());const Nh=document.createElement("link");Nh.rel="stylesheet";Nh.href=`${Tt}/api/settings/custom.css`;document.head.appendChild(Nh);Lv.createRoot(document.getElementById("root")).render(h.jsx(A.StrictMode,{children:h.jsx(Bj,{})}));export{Yy as $,oA as A,uA as B,jh as C,RE as D,hA as E,Cy as F,wS as G,Kj as H,vy as I,e2 as J,xy as K,xA as L,Oh as M,F_ as N,tA as O,TA as P,Ah as Q,aS as R,$S as S,Fj as T,Ij as U,Wj as V,sA as W,cA as X,mA as Y,$v as Z,$y as _,CA as a,kA as a0,_A as a1,dA as a2,wA as a3,SA as a4,pA as a5,gA as a6,bA as a7,yA as a8,vA as a9,eh as aa,fA as ab,Wg as ac,OA as ad,Vj as ae,Tt as af,Rg as ag,Jj as ah,MA as ai,RA as aj,Gy as ak,wy as al,gy as am,NA as an,ME as b,Yj as c,we as d,Zj as e,TE as f,eA as g,nA as h,Qj as i,dy as j,Dn as k,Xj as l,jA as m,AA as n,rS as o,jS as p,SS as q,ES as r,NS as s,py as t,Mi as u,iA as v,EA as w,rA as x,aA as y,lA as z};
63
- //# sourceMappingURL=index-CSTwyrwu.js.map
61
+ `}function w2(i){const t=i.summary,s=i.title;if(t){const a=t.search(/\n\s*\{[\s\S]*"title"\s*:/);return a>0?t.slice(0,a).trim():t}return s||(typeof i=="string"?i:"Query completed.")}const zy=j.createContext(null);function S2({children:i}){const t=on(),[s,a]=j.useState(!1),[o,u]=j.useState([]),[d,m]=j.useState(null),[g,y]=j.useState({}),E=j.useRef(null),_={page:t.pathname.split("/").filter(Boolean).join("-")||"home",route:t.pathname,params:{},...g,suggestedTags:g.suggestedTags??v2(t.pathname)};j.useEffect(()=>()=>{E.current&&clearInterval(E.current)},[]);const T=j.useCallback(()=>a(te=>!te),[]),R=j.useCallback(te=>{y(te)},[]),C=j.useCallback(()=>{u([]),m(null)},[]),D=j.useCallback(async te=>{var G;const X=new Date().toISOString(),fe={id:`user-${Date.now()}`,role:"user",content:te,timestamp:X},oe={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:X,pending:!0};u(I=>[...I,fe,oe]);const O={..._};(G=O.entities)!=null&&G.yamlContent&&O.entities.yamlContent.length>fg&&(O.entities={...O.entities,yamlContent:O.entities.yamlContent.slice(0,fg)+`
62
+ ... (truncated)`});const ne=`${_2(o.concat(fe))}${te}`;try{const Z=(await Ee("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ne,tags:O.suggestedTags,context:O,wait:!1,direct:!0})})).workflow_id;m(Z),u(ae=>ae.map(re=>re.id===oe.id?{...re,workflowId:Z}:re)),E.current&&clearInterval(E.current),E.current=setInterval(async()=>{var ae;try{const re=await Ee(`/workflows/${Z}/result`),je=(ae=re==null?void 0:re.result)==null?void 0:ae.data;if(je){E.current&&clearInterval(E.current),E.current=null,m(null);const he=w2(je);let Se;try{Se=(await Ee(`/workflow-states/${Z}/execution`)).duration_ms}catch{}u($=>$.map(se=>se.id===oe.id?{...se,content:he,timestamp:new Date().toISOString(),pending:!1,durationMs:Se}:se))}}catch{}},3e3)}catch{u(I=>I.map(Z=>Z.id===oe.id?{...Z,content:"Failed to submit query. Please try again.",pending:!1}:Z))}},[o,_]),F=j.useCallback(async te=>{const X=o.find(O=>O.id===te);if(!(X!=null&&X.workflowId)||X.compilationStatus==="compiling"||X.compilationStatus==="done")return;const fe=o.indexOf(X),oe=o.slice(0,fe).reverse().find(O=>O.role==="user");if(oe){u(O=>O.map(U=>U.id===te?{...U,compilationStatus:"compiling"}:U));try{const O=await Ee("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:oe.content,summary:X.content})}),U=await Ee("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:X.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:O.tool_name,description:O.description,tags:O.tags,app_id:""})});await Ee(`/yaml-workflows/${U.id}/deploy`,{method:"POST"}),u(ne=>ne.map(G=>G.id===te?{...G,compilationStatus:"done"}:G))}catch(O){const U=O instanceof Error?O.message:"Compilation failed";u(ne=>ne.map(G=>G.id===te?{...G,compilationStatus:"error",compilationError:U}:G))}}},[o]);return h.jsx(zy.Provider,{value:{helpOpen:s,setHelpOpen:a,toggleHelp:T,messages:o,sendMessage:D,pageContext:_,setPageContext:R,activeWorkflowId:d,clearMessages:C,compileMessage:F},children:i})}function Uy(){const i=j.useContext(zy);if(!i)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return i}function E2(){const{helpOpen:i,toggleHelp:t}=Uy();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":i?"Close help":"Ask for help",children:i?h.jsx(Gn,{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(${Tt}/logo512.png)`}})})}const By=6048e5,j2=864e5,hg=6e4,dg=525600,mg=43200,pg=1440,gg=Symbol.for("constructDateFrom");function gs(i,t){return typeof i=="function"?i(t):i&&typeof i=="object"&&gg in i?i[gg](t):i instanceof Date?new i.constructor(t):new Date(t)}function ln(i,t){return gs(t||i,i)}let A2={};function Xa(){return A2}function Ja(i,t){var m,g,y,E;const s=Xa(),a=(t==null?void 0:t.weekStartsOn)??((g=(m=t==null?void 0:t.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.weekStartsOn)??0,o=ln(i,t==null?void 0:t.in),u=o.getDay(),d=(u<a?7:0)+u-a;return o.setDate(o.getDate()-d),o.setHours(0,0,0,0),o}function Vo(i,t){return Ja(i,{...t,weekStartsOn:1})}function Ly(i,t){const s=ln(i,t==null?void 0:t.in),a=s.getFullYear(),o=gs(s,0);o.setFullYear(a+1,0,4),o.setHours(0,0,0,0);const u=Vo(o),d=gs(s,0);d.setFullYear(a,0,4),d.setHours(0,0,0,0);const m=Vo(d);return s.getTime()>=u.getTime()?a+1:s.getTime()>=m.getTime()?a:a-1}function Io(i){const t=ln(i),s=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return s.setUTCFullYear(t.getFullYear()),+i-+s}function Py(i,...t){const s=gs.bind(null,i||t.find(a=>typeof a=="object"));return t.map(s)}function yg(i,t){const s=ln(i,t==null?void 0:t.in);return s.setHours(0,0,0,0),s}function O2(i,t,s){const[a,o]=Py(s==null?void 0:s.in,i,t),u=yg(a),d=yg(o),m=+u-Io(u),g=+d-Io(d);return Math.round((m-g)/j2)}function N2(i,t){const s=Ly(i,t),a=gs(i,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),Vo(a)}function T2(i,t){const s=+ln(i)-+ln(t);return s<0?-1:s>0?1:s}function k2(i){return gs(i,Date.now())}function C2(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function M2(i){return!(!C2(i)&&typeof i!="number"||isNaN(+ln(i)))}function R2(i){return t=>{const a=(i?Math[i]:Math.trunc)(t);return a===0?0:a}}function D2(i,t){const s=ln(i,t==null?void 0:t.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const q2={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"}},z2=(i,t,s)=>{let a;const o=q2[i];return typeof o=="string"?a=o:t===1?a=o.one:a=o.other.replace("{{count}}",t.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+a:a+" ago":a};function Nf(i){return(t={})=>{const s=t.width?String(t.width):i.defaultWidth;return i.formats[s]||i.formats[i.defaultWidth]}}const U2={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},B2={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},L2={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},P2={date:Nf({formats:U2,defaultWidth:"full"}),time:Nf({formats:B2,defaultWidth:"full"}),dateTime:Nf({formats:L2,defaultWidth:"full"})},H2={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$2=(i,t,s,a)=>H2[i];function Da(i){return(t,s)=>{const a=s!=null&&s.context?String(s.context):"standalone";let o;if(a==="formatting"&&i.formattingValues){const d=i.defaultFormattingWidth||i.defaultWidth,m=s!=null&&s.width?String(s.width):d;o=i.formattingValues[m]||i.formattingValues[d]}else{const d=i.defaultWidth,m=s!=null&&s.width?String(s.width):i.defaultWidth;o=i.values[m]||i.values[d]}const u=i.argumentCallback?i.argumentCallback(t):t;return o[u]}}const Y2={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},G2={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},V2={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"]},I2={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"]},F2={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"}},J2={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"}},Q2=(i,t)=>{const s=Number(i),a=s%100;if(a>20||a<10)switch(a%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},K2={ordinalNumber:Q2,era:Da({values:Y2,defaultWidth:"wide"}),quarter:Da({values:G2,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Da({values:V2,defaultWidth:"wide"}),day:Da({values:I2,defaultWidth:"wide"}),dayPeriod:Da({values:F2,defaultWidth:"wide",formattingValues:J2,defaultFormattingWidth:"wide"})};function qa(i){return(t,s={})=>{const a=s.width,o=a&&i.matchPatterns[a]||i.matchPatterns[i.defaultMatchWidth],u=t.match(o);if(!u)return null;const d=u[0],m=a&&i.parsePatterns[a]||i.parsePatterns[i.defaultParseWidth],g=Array.isArray(m)?Z2(m,_=>_.test(d)):X2(m,_=>_.test(d));let y;y=i.valueCallback?i.valueCallback(g):g,y=s.valueCallback?s.valueCallback(y):y;const E=t.slice(d.length);return{value:y,rest:E}}}function X2(i,t){for(const s in i)if(Object.prototype.hasOwnProperty.call(i,s)&&t(i[s]))return s}function Z2(i,t){for(let s=0;s<i.length;s++)if(t(i[s]))return s}function W2(i){return(t,s={})=>{const a=t.match(i.matchPattern);if(!a)return null;const o=a[0],u=t.match(i.parsePattern);if(!u)return null;let d=i.valueCallback?i.valueCallback(u[0]):u[0];d=s.valueCallback?s.valueCallback(d):d;const m=t.slice(o.length);return{value:d,rest:m}}}const eE=/^(\d+)(th|st|nd|rd)?/i,tE=/\d+/i,nE={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},sE={any:[/^b/i,/^(a|c)/i]},iE={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},rE={any:[/1/i,/2/i,/3/i,/4/i]},aE={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},lE={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]},oE={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},cE={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]},uE={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},fE={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}},hE={ordinalNumber:W2({matchPattern:eE,parsePattern:tE,valueCallback:i=>parseInt(i,10)}),era:qa({matchPatterns:nE,defaultMatchWidth:"wide",parsePatterns:sE,defaultParseWidth:"any"}),quarter:qa({matchPatterns:iE,defaultMatchWidth:"wide",parsePatterns:rE,defaultParseWidth:"any",valueCallback:i=>i+1}),month:qa({matchPatterns:aE,defaultMatchWidth:"wide",parsePatterns:lE,defaultParseWidth:"any"}),day:qa({matchPatterns:oE,defaultMatchWidth:"wide",parsePatterns:cE,defaultParseWidth:"any"}),dayPeriod:qa({matchPatterns:uE,defaultMatchWidth:"any",parsePatterns:fE,defaultParseWidth:"any"})},Hy={code:"en-US",formatDistance:z2,formatLong:P2,formatRelative:$2,localize:K2,match:hE,options:{weekStartsOn:0,firstWeekContainsDate:1}};function dE(i,t){const s=ln(i,t==null?void 0:t.in);return O2(s,D2(s))+1}function mE(i,t){const s=ln(i,t==null?void 0:t.in),a=+Vo(s)-+N2(s);return Math.round(a/By)+1}function $y(i,t){var E,_,T,R;const s=ln(i,t==null?void 0:t.in),a=s.getFullYear(),o=Xa(),u=(t==null?void 0:t.firstWeekContainsDate)??((_=(E=t==null?void 0:t.locale)==null?void 0:E.options)==null?void 0:_.firstWeekContainsDate)??o.firstWeekContainsDate??((R=(T=o.locale)==null?void 0:T.options)==null?void 0:R.firstWeekContainsDate)??1,d=gs((t==null?void 0:t.in)||i,0);d.setFullYear(a+1,0,u),d.setHours(0,0,0,0);const m=Ja(d,t),g=gs((t==null?void 0:t.in)||i,0);g.setFullYear(a,0,u),g.setHours(0,0,0,0);const y=Ja(g,t);return+s>=+m?a+1:+s>=+y?a:a-1}function pE(i,t){var m,g,y,E;const s=Xa(),a=(t==null?void 0:t.firstWeekContainsDate)??((g=(m=t==null?void 0:t.locale)==null?void 0:m.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((E=(y=s.locale)==null?void 0:y.options)==null?void 0:E.firstWeekContainsDate)??1,o=$y(i,t),u=gs((t==null?void 0:t.in)||i,0);return u.setFullYear(o,0,a),u.setHours(0,0,0,0),Ja(u,t)}function gE(i,t){const s=ln(i,t==null?void 0:t.in),a=+Ja(s,t)-+pE(s,t);return Math.round(a/By)+1}function Ve(i,t){const s=i<0?"-":"",a=Math.abs(i).toString().padStart(t,"0");return s+a}const Js={y(i,t){const s=i.getFullYear(),a=s>0?s:1-s;return Ve(t==="yy"?a%100:a,t.length)},M(i,t){const s=i.getMonth();return t==="M"?String(s+1):Ve(s+1,2)},d(i,t){return Ve(i.getDate(),t.length)},a(i,t){const s=i.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(i,t){return Ve(i.getHours()%12||12,t.length)},H(i,t){return Ve(i.getHours(),t.length)},m(i,t){return Ve(i.getMinutes(),t.length)},s(i,t){return Ve(i.getSeconds(),t.length)},S(i,t){const s=t.length,a=i.getMilliseconds(),o=Math.trunc(a*Math.pow(10,s-3));return Ve(o,t.length)}},_r={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},bg={G:function(i,t,s){const a=i.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return s.era(a,{width:"abbreviated"});case"GGGGG":return s.era(a,{width:"narrow"});case"GGGG":default:return s.era(a,{width:"wide"})}},y:function(i,t,s){if(t==="yo"){const a=i.getFullYear(),o=a>0?a:1-a;return s.ordinalNumber(o,{unit:"year"})}return Js.y(i,t)},Y:function(i,t,s,a){const o=$y(i,a),u=o>0?o:1-o;if(t==="YY"){const d=u%100;return Ve(d,2)}return t==="Yo"?s.ordinalNumber(u,{unit:"year"}):Ve(u,t.length)},R:function(i,t){const s=Ly(i);return Ve(s,t.length)},u:function(i,t){const s=i.getFullYear();return Ve(s,t.length)},Q:function(i,t,s){const a=Math.ceil((i.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return Ve(a,2);case"Qo":return s.ordinalNumber(a,{unit:"quarter"});case"QQQ":return s.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(a,{width:"wide",context:"formatting"})}},q:function(i,t,s){const a=Math.ceil((i.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return Ve(a,2);case"qo":return s.ordinalNumber(a,{unit:"quarter"});case"qqq":return s.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(a,{width:"wide",context:"standalone"})}},M:function(i,t,s){const a=i.getMonth();switch(t){case"M":case"MM":return Js.M(i,t);case"Mo":return s.ordinalNumber(a+1,{unit:"month"});case"MMM":return s.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(a,{width:"wide",context:"formatting"})}},L:function(i,t,s){const a=i.getMonth();switch(t){case"L":return String(a+1);case"LL":return Ve(a+1,2);case"Lo":return s.ordinalNumber(a+1,{unit:"month"});case"LLL":return s.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(a,{width:"wide",context:"standalone"})}},w:function(i,t,s,a){const o=gE(i,a);return t==="wo"?s.ordinalNumber(o,{unit:"week"}):Ve(o,t.length)},I:function(i,t,s){const a=mE(i);return t==="Io"?s.ordinalNumber(a,{unit:"week"}):Ve(a,t.length)},d:function(i,t,s){return t==="do"?s.ordinalNumber(i.getDate(),{unit:"date"}):Js.d(i,t)},D:function(i,t,s){const a=dE(i);return t==="Do"?s.ordinalNumber(a,{unit:"dayOfYear"}):Ve(a,t.length)},E:function(i,t,s){const a=i.getDay();switch(t){case"E":case"EE":case"EEE":return s.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(a,{width:"short",context:"formatting"});case"EEEE":default:return s.day(a,{width:"wide",context:"formatting"})}},e:function(i,t,s,a){const o=i.getDay(),u=(o-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(u);case"ee":return Ve(u,2);case"eo":return s.ordinalNumber(u,{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(i,t,s,a){const o=i.getDay(),u=(o-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(u);case"cc":return Ve(u,t.length);case"co":return s.ordinalNumber(u,{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(i,t,s){const a=i.getDay(),o=a===0?7:a;switch(t){case"i":return String(o);case"ii":return Ve(o,t.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(a,{width:"short",context:"formatting"});case"iiii":default:return s.day(a,{width:"wide",context:"formatting"})}},a:function(i,t,s){const o=i.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(i,t,s){const a=i.getHours();let o;switch(a===12?o=_r.noon:a===0?o=_r.midnight:o=a/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(i,t,s){const a=i.getHours();let o;switch(a>=17?o=_r.evening:a>=12?o=_r.afternoon:a>=4?o=_r.morning:o=_r.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(i,t,s){if(t==="ho"){let a=i.getHours()%12;return a===0&&(a=12),s.ordinalNumber(a,{unit:"hour"})}return Js.h(i,t)},H:function(i,t,s){return t==="Ho"?s.ordinalNumber(i.getHours(),{unit:"hour"}):Js.H(i,t)},K:function(i,t,s){const a=i.getHours()%12;return t==="Ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,t.length)},k:function(i,t,s){let a=i.getHours();return a===0&&(a=24),t==="ko"?s.ordinalNumber(a,{unit:"hour"}):Ve(a,t.length)},m:function(i,t,s){return t==="mo"?s.ordinalNumber(i.getMinutes(),{unit:"minute"}):Js.m(i,t)},s:function(i,t,s){return t==="so"?s.ordinalNumber(i.getSeconds(),{unit:"second"}):Js.s(i,t)},S:function(i,t){return Js.S(i,t)},X:function(i,t,s){const a=i.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return vg(a);case"XXXX":case"XX":return Ti(a);case"XXXXX":case"XXX":default:return Ti(a,":")}},x:function(i,t,s){const a=i.getTimezoneOffset();switch(t){case"x":return vg(a);case"xxxx":case"xx":return Ti(a);case"xxxxx":case"xxx":default:return Ti(a,":")}},O:function(i,t,s){const a=i.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+xg(a,":");case"OOOO":default:return"GMT"+Ti(a,":")}},z:function(i,t,s){const a=i.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+xg(a,":");case"zzzz":default:return"GMT"+Ti(a,":")}},t:function(i,t,s){const a=Math.trunc(+i/1e3);return Ve(a,t.length)},T:function(i,t,s){return Ve(+i,t.length)}};function xg(i,t=""){const s=i>0?"-":"+",a=Math.abs(i),o=Math.trunc(a/60),u=a%60;return u===0?s+String(o):s+String(o)+t+Ve(u,2)}function vg(i,t){return i%60===0?(i>0?"-":"+")+Ve(Math.abs(i)/60,2):Ti(i,t)}function Ti(i,t=""){const s=i>0?"-":"+",a=Math.abs(i),o=Ve(Math.trunc(a/60),2),u=Ve(a%60,2);return s+o+t+u}const _g=(i,t)=>{switch(i){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"})}},Yy=(i,t)=>{switch(i){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"})}},yE=(i,t)=>{const s=i.match(/(P+)(p+)?/)||[],a=s[1],o=s[2];if(!o)return _g(i,t);let u;switch(a){case"P":u=t.dateTime({width:"short"});break;case"PP":u=t.dateTime({width:"medium"});break;case"PPP":u=t.dateTime({width:"long"});break;case"PPPP":default:u=t.dateTime({width:"full"});break}return u.replace("{{date}}",_g(a,t)).replace("{{time}}",Yy(o,t))},bE={p:Yy,P:yE},xE=/^D+$/,vE=/^Y+$/,_E=["D","DD","YY","YYYY"];function wE(i){return xE.test(i)}function SE(i){return vE.test(i)}function EE(i,t,s){const a=jE(i,t,s);if(console.warn(a),_E.includes(i))throw new RangeError(a)}function jE(i,t,s){const a=i[0]==="Y"?"years":"days of the month";return`Use \`${i.toLowerCase()}\` instead of \`${i}\` (in \`${t}\`) for formatting ${a} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const AE=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,OE=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,NE=/^'([^]*?)'?$/,TE=/''/g,kE=/[a-zA-Z]/;function Gy(i,t,s){var E,_,T,R;const a=Xa(),o=a.locale??Hy,u=a.firstWeekContainsDate??((_=(E=a.locale)==null?void 0:E.options)==null?void 0:_.firstWeekContainsDate)??1,d=a.weekStartsOn??((R=(T=a.locale)==null?void 0:T.options)==null?void 0:R.weekStartsOn)??0,m=ln(i,s==null?void 0:s.in);if(!M2(m))throw new RangeError("Invalid time value");let g=t.match(OE).map(C=>{const D=C[0];if(D==="p"||D==="P"){const F=bE[D];return F(C,o.formatLong)}return C}).join("").match(AE).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const D=C[0];if(D==="'")return{isToken:!1,value:CE(C)};if(bg[D])return{isToken:!0,value:C};if(D.match(kE))throw new RangeError("Format string contains an unescaped latin alphabet character `"+D+"`");return{isToken:!1,value:C}});o.localize.preprocessor&&(g=o.localize.preprocessor(m,g));const y={firstWeekContainsDate:u,weekStartsOn:d,locale:o};return g.map(C=>{if(!C.isToken)return C.value;const D=C.value;(SE(D)||wE(D))&&EE(D,t,String(i));const F=bg[D[0]];return F(m,D,o.localize,y)}).join("")}function CE(i){const t=i.match(NE);return t?t[1].replace(TE,"'"):i}function ME(i,t,s){const a=Xa(),o=(s==null?void 0:s.locale)??a.locale??Hy,u=T2(i,t);if(isNaN(u))throw new RangeError("Invalid time value");const d=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:u}),[m,g]=Py(s==null?void 0:s.in,...u>0?[t,i]:[i,t]),y=R2((s==null?void 0:s.roundingMethod)??"round"),E=g.getTime()-m.getTime(),_=E/hg,T=Io(g)-Io(m),R=(E-T)/hg,C=s==null?void 0:s.unit;let D;if(C?D=C:_<1?D="second":_<60?D="minute":_<pg?D="hour":R<mg?D="day":R<dg?D="month":D="year",D==="second"){const F=y(E/1e3);return o.formatDistance("xSeconds",F,d)}else if(D==="minute"){const F=y(_);return o.formatDistance("xMinutes",F,d)}else if(D==="hour"){const F=y(_/60);return o.formatDistance("xHours",F,d)}else if(D==="day"){const F=y(R/pg);return o.formatDistance("xDays",F,d)}else if(D==="month"){const F=y(R/mg);return F===12&&C!=="month"?o.formatDistance("xYears",1,d):o.formatDistance("xMonths",F,d)}else{const F=y(R/dg);return o.formatDistance("xYears",F,d)}}function RE(i,t){return ME(i,k2(i),t)}function DA(i){return i.toLocaleString()}function qA(i){return i>=1e9?`${(i/1e9).toFixed(1).replace(/\.0$/,"")}B`:i>=1e6?`${(i/1e6).toFixed(1).replace(/\.0$/,"")}M`:i>=1e4?`${(i/1e3).toFixed(1).replace(/\.0$/,"")}K`:i.toLocaleString()}function DE(i){const t=new Date(i);return t.getTime()>Date.now()?"just now":RE(t,{addSuffix:!0})}function zA(i){const t=Date.now()-new Date(i).getTime();if(t<0)return"now";const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const a=Math.floor(s/60);if(a<60)return`${a}m`;const o=Math.floor(a/60);if(o<24)return`${o}h`;const u=Math.floor(o/24);return u<7?`${u}d`:u<30?`${Math.floor(u/7)}w`:u<365?`${Math.floor(u/30)}mo`:`${Math.floor(u/365)}y`}function UA(i){return i<=0?"Expired":Th(i)}function qE(i){return i==null?"--":Th(i)}function Th(i){if(i<1e3)return`${Math.round(i)}ms`;if(i<6e4){const d=i/1e3;return Number.isInteger(d)?`${d}s`:`${d.toFixed(1)}s`}const t=Math.floor(i/1e3),s=Math.floor(t/86400),a=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),u=t%60;return s>0?a>0?`${s}d ${a}h`:`${s}d`:a>0?o>0?`${a}h ${o}m`:`${a}h`:u>0?`${o}m ${u}s`:`${o}m`}function BA(i,t){const s=new Date(i).getTime(),a=t?new Date(t).getTime():Date.now();return Th(a-s)}function Vy({options:i,children:t,className:s=""}){const[a,o]=j.useState(!1),[u,d]=j.useState(null),[m,g]=j.useState(null),y=j.useRef(null),E=j.useRef(void 0),_=j.useRef(void 0),T=220,R=j.useCallback(()=>{if(!y.current)return;const te=y.current.getBoundingClientRect(),X=window.innerWidth-T-8,fe=Math.max(8,Math.min(te.left,X));g({top:te.bottom+4,left:fe})},[]),C=j.useCallback(async(te,X)=>{try{await navigator.clipboard.writeText(te),d(X),clearTimeout(E.current),E.current=setTimeout(()=>d(null),1200)}catch{}},[]),D=j.useCallback(()=>{clearTimeout(_.current),R(),o(!0)},[R]),F=j.useCallback(()=>{_.current=setTimeout(()=>o(!1),150)},[]);return j.useEffect(()=>()=>{clearTimeout(E.current),clearTimeout(_.current)},[]),h.jsxs("span",{ref:y,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:D,onMouseLeave:F,children:[t,a&&m&&Tg.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:m.top,left:m.left},onMouseEnter:D,onMouseLeave:F,children:i.map(te=>h.jsxs("button",{onClick:X=>{X.stopPropagation(),C(te.value,te.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:te.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:u===te.label?"✓":te.value})]},te.label))}),document.body)]})}function zE(i,t){const s=new Date(i);switch(t){case"relative":return DE(i);case"datetime":return Gy(s,"MMM d, yyyy h:mm a");case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function UE(i){const t=new Date(i);return[{label:"ms",value:String(t.getTime())},{label:"utc",value:t.toISOString()},{label:"local",value:Gy(t,"MMM d, yyyy h:mm:ss a")}]}function BE({date:i,format:t="relative",className:s=""}){const[,a]=j.useState(0);j.useEffect(()=>{if(t!=="relative")return;const u=setInterval(()=>a(d=>d+1),3e4);return()=>clearInterval(u)},[t]);const o=j.useMemo(()=>UE(i),[i]);return h.jsx(Vy,{options:o,children:h.jsx("time",{dateTime:i,className:`text-xs text-text-tertiary ${s}`,children:zE(i,t)})})}function LE({ms:i,className:t=""}){const s=qE(i),a=j.useMemo(()=>i==null?[]:[{label:"ms",value:String(i)},{label:"sec",value:`${(i/1e3).toFixed(3)}s`},{label:"text",value:s}],[i,s]);return i==null?h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:"--"}):h.jsx(Vy,{options:a,children:h.jsx("span",{className:`text-xs text-text-tertiary ${t}`,children:s})})}const PE=["sm","md","lg","full"],wg={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"},Sg={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function HE({which:i}){const t="stroke-current";switch(i){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 $E({msg:i}){const[t,s]=j.useState(0);j.useEffect(()=>{const d=new Date(i.timestamp).getTime(),m=()=>s(Math.floor((Date.now()-d)/1e3));m();const g=setInterval(m,1e3);return()=>clearInterval(g)},[i.timestamp]);const a=Math.floor(t/60),o=t%60,u=a>0?`${a}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:u})]}),i.workflowId&&h.jsxs(ki,{to:`/workflows/executions/${i.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(sh,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function YE({msg:i,compileMessage:t}){const s=i.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(BE,{date:i.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),i.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(LE,{ms:i.durationMs,className:"!text-2xs text-text-muted/50"})]}),i.workflowId&&h.jsx(ki,{to:`/workflows/executions/${i.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(sh,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&i.workflowId&&!i.pending&&h.jsx("button",{onClick:()=>t(i.id),disabled:i.compilationStatus==="compiling"||i.compilationStatus==="done",className:"transition-colors",title:i.compilationStatus==="done"?"Compiled — future queries will match this pipeline":i.compilationStatus==="error"?i.compilationError??"Compilation failed":i.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx(Rv,{className:`w-2.5 h-2.5 ${i.compilationStatus==="done"?"text-status-success":i.compilationStatus==="error"?"text-status-error":i.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function GE(){const{helpOpen:i,setHelpOpen:t,messages:s,sendMessage:a,pageContext:o,activeWorkflowId:u,clearMessages:d,compileMessage:m}=Uy(),[g,y]=j.useState(""),[E,_]=j.useState("md"),[T,R]=j.useState(!0),C=j.useRef(null),D=j.useRef(null);if(j.useEffect(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[s]),j.useEffect(()=>{i&&D.current&&D.current.focus()},[i]),j.useEffect(()=>{if(!i)return;const O=U=>{U.key==="Escape"&&(E==="full"?_("lg"):E==="lg"?_("md"):E==="md"?_("sm"):t(!1))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[i,E,t]),!i)return null;const F=()=>{const O=g.trim();!O||u||(a(O),y(""),D.current&&(D.current.style.height="auto"))},te=O=>{O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),F())},X=E==="full",fe=o.page.replace(/-/g," "),oe=X?{}:{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 ${X?wg.full:`right-6 ${wg[E]}`} ${T?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:oe,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!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 ${T?"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:fe})]}),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:PE.map(O=>h.jsx("button",{onClick:()=>_(O),className:`p-1 rounded transition-colors ${O===E?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":O===E,"aria-label":Sg[O],title:Sg[O],children:h.jsx(HE,{which:O})},O))}),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(Dv,{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(Gn,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:C,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${T?"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(O=>h.jsxs("div",{className:`text-xs leading-relaxed ${O.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 ${O.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:O.pending?h.jsx($E,{msg:O}):O.role==="assistant"?h.jsx(Nh,{content:O.content}):O.content}),!O.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(YE,{msg:O,compileMessage:m})})]},O.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${T?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:D,value:g,onChange:O=>{y(O.target.value);const U=O.target;U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,120)}px`},onKeyDown:te,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:!!u}),h.jsx("button",{onClick:F,disabled:!g.trim()||!!u,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(qv,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}function VE(){var fe;const{isBuilder:i,isOps:t,viewAs:s}=by(),{canSeePaceBoard:a}=xy();iS();const{data:o}=si(),u=gy(),d=u!==null?u:!!((fe=o==null?void 0:o.ai)!=null&&fe.enabled),{collapsed:m,toggle:g}=jh(),[y,E]=j.useState(!1),[_,T]=j.useState(!1),[R,C]=j.useState(!1),[D,F]=j.useState(()=>window.location.hash.startsWith("#docs")),te=on(),X=j.useRef(null);return j.useEffect(()=>{const oe=X.current;oe&&(oe.classList.remove("animate-page-in"),oe.offsetWidth,oe.classList.add("animate-page-in"))},[te.pathname]),j.useEffect(()=>{const oe=()=>{window.location.hash.startsWith("#docs")&&F(!0)};return window.addEventListener("hashchange",oe),()=>window.removeEventListener("hashchange",oe)},[]),h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(vS,{onToggleEventFeed:()=>E(oe=>!oe),onToggleDocs:()=>F(oe=>!oe),onToggleNav:()=>T(oe=>!oe)}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsxs("aside",{className:`${m?"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(Cy,{aiEnabled:d,isBuilder:i,isOps:t,viewAs:s,canSeePaceBoard:a})}),h.jsx("button",{onClick:g,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${m?"flex justify-center":"flex items-center px-7"}`,"aria-label":m?"Expand sidebar":"Collapse sidebar",children:m?h.jsx(zv,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(Uv,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!m&&(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:X,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(Sr,{})})}),h.jsx(IE,{})]}),h.jsx(GS,{open:_,onClose:()=>T(!1),aiEnabled:d,isBuilder:i,isOps:t,viewAs:s,canSeePaceBoard:a}),h.jsx(c2,{open:y,onToggle:()=>E(oe=>!oe),configOpen:R,onToggleConfig:()=>C(oe=>!oe)}),h.jsx(x2,{open:D,onClose:()=>{F(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),d&&h.jsx(E2,{}),d&&h.jsx(GE,{})]})}function IE(){const{node:i,width:t,open:s}=cS();return h.jsx(uS,{open:s,width:t,className:"border-l border-surface-border bg-surface-raised",children:i})}function FE(){const{isAuthenticated:i}=En(),t=on();return i?h.jsx(aS,{children:h.jsx(oS,{children:h.jsx(S2,{children:h.jsx(VE,{})})})}):h.jsx(Pn,{to:"/login",state:{from:t.pathname},replace:!0})}function Iy({provider:i,className:t="w-5 h-5"}){switch(i){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 JE(){return Ee("/auth/oauth/providers")}async function QE(i,t){const s=t?`?label=${encodeURIComponent(t)}`:"";return Ee(`/auth/oauth/connections/${i}${s}`,{method:"DELETE"})}function LA(){return ht({queryKey:["oauth-connections"],queryFn:()=>Ee("/auth/oauth/connections")})}function PA(){const i=bt();return Et({mutationFn:({provider:t,label:s})=>QE(t,s),onSuccess:()=>{i.invalidateQueries({queryKey:["oauth-connections"]})}})}function KE(){var ne;const{login:i,isAuthenticated:t}=En(),s=Fo(),a=on(),o=new URLSearchParams(a.search),u=o.get("token"),d=o.get("error"),m=((ne=a.state)==null?void 0:ne.from)??o.get("returnTo")??"/",g=j.useRef(!1);u&&!g.current&&(g.current=!0,i(u,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[y,E]=j.useState(""),[_,T]=j.useState(""),[R,C]=j.useState(d||""),[D,F]=j.useState(!1),[te,X]=j.useState(!!u),[fe,oe]=j.useState([]),O=j.useRef(!1);if(j.useEffect(()=>{u||O.current||(O.current=!0,(async()=>{var G,I,Z,ae;try{const re=await fetch(`${Tt}/api/settings`);if(!re.ok)return;const je=await re.json();if(!((G=je.auth)!=null&&G.sso))return;const he=await fetch(`${Tt}/api/auth/sso`,{method:"POST"});if(!he.ok){C("Host authentication required — please log in to your organization first");return}const Se=await he.json();Se.token&&((I=je.auth)!=null&&I.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",je.auth.ssoLogoutUrl),X(!0),i(Se.token,void 0,{displayName:(Z=Se.user)==null?void 0:Z.display_name,username:(ae=Se.user)==null?void 0:ae.external_id}))}catch{}})())},[]),j.useEffect(()=>{u||JE().then(oe).catch(()=>{})},[]),j.useEffect(()=>{if(!te)return;const G=setTimeout(()=>s(m,{replace:!0}),1500);return()=>clearTimeout(G)},[te]),t&&!te)return h.jsx(Pn,{to:m,replace:!0});const U=async G=>{var I,Z;if(G.preventDefault(),C(""),!y.trim()||!_){C("Username and password are required");return}F(!0);try{const ae=await fetch(`${Tt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:y.trim(),password:_})}),re=await ae.json();if(!ae.ok){C(re.error||"Login failed");return}X(!0),i(re.token,{username:y.trim(),password:_},{displayName:(I=re.user)==null?void 0:I.display_name,username:(Z=re.user)==null?void 0:Z.external_id})}catch{C("Unable to connect to server")}finally{F(!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 ${te?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Yo,{size:"lg",hideLabel:te})}),h.jsxs("form",{onSubmit:U,className:`space-y-5 transition-opacity duration-300 ${te?"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:y,onChange:G=>E(G.target.value),className:"input",placeholder:"Enter your username",autoFocus:!te,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:_,onChange:G=>T(G.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),R&&h.jsx("p",{className:"text-sm text-status-error",children:R}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:D||te,children:D?"Signing in...":"Sign In"}),fe.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:fe.filter(G=>G.provider!=="anthropic").map(G=>h.jsxs("a",{href:`${Tt}/api/auth/oauth/${G.provider}?returnTo=${encodeURIComponent(m)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Iy,{provider:G.provider}),"Sign in with ",G.name]},G.provider))})]})]})]})})}function Eg(){const{isAuthenticated:i}=En(),t=Fo(),s=on(),a=new URLSearchParams(s.search),o=a.get("state")||"";j.useEffect(()=>{i||t(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[i]);const[u,d]=j.useState(""),[m,g]=j.useState(a.get("label")||"default"),[y,E]=j.useState(""),[_,T]=j.useState(!1),R=u.trim().startsWith("sk-ant-oat"),C=u.trim().startsWith("sk-ant-api"),D=F=>{F.preventDefault();const te=u.trim();if(!te){E("A token or API key is required");return}if(!te.startsWith("sk-ant-")){E('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}T(!0),E("");const X=`${Tt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(te)}&state=${encodeURIComponent(o)}`;window.location.href=X};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(Yo,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Iy,{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:D,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:u,onChange:F=>d(F.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),R&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),C&&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:m,onChange:F=>g(F.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").'})]}),y&&h.jsx("p",{className:"text-sm text-status-error",children:y}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:_,children:_?"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 No({roleTypes:i,roleNames:t,redirectTo:s="/"}){const{isSuperAdmin:a,hasRole:o,hasRoleType:u}=En();return a?h.jsx(Sr,{}):i&&i.some(d=>u(d))?h.jsx(Sr,{}):t&&t.some(d=>o(d))?h.jsx(Sr,{}):h.jsx(Pn,{to:s,replace:!0})}function XE({redirectTo:i="/"}){var a;const{data:t,isLoading:s}=si();return s||!t?null:(a=t.ai)!=null&&a.enabled?h.jsx(Sr,{}):h.jsx(Pn,{to:i,replace:!0})}function ZE({flag:i,redirectTo:t="/"}){var o;const{data:s,isLoading:a}=si();return a||!s?null:((o=s.features)==null?void 0:o[i])===!1?h.jsx(Pn,{to:t,replace:!0}):h.jsx(Sr,{})}const WE=j.lazy(()=>we(()=>import("./ProcessesListPage-_xmj6Bo-.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),import.meta.url).then(i=>({default:i.ProcessesListPage}))),ej=j.lazy(()=>we(()=>import("./ProcessDetailPage-HrmVQq7S.js"),__vite__mapDeps([18,1,2,4,19,14,20,17,11,6,21,22,23]),import.meta.url).then(i=>({default:i.ProcessDetailPage}))),tj=j.lazy(()=>we(()=>import("./McpOverview-odYnCZCC.js"),__vite__mapDeps([24,1,25,26,27,28,15,14,29,6]),import.meta.url).then(i=>({default:i.McpOverview}))),nj=j.lazy(()=>we(()=>import("./McpRunsPage-rdpZ2yMh.js"),__vite__mapDeps([30,1,26,27,5,6,31,28,8,9,10,17,14,32,15,13,12,16,33]),import.meta.url).then(i=>({default:i.McpRunsPage}))),sj=j.lazy(()=>we(()=>import("./McpRunDetailPage-D-Rz9MRw.js"),__vite__mapDeps([34,1,26,20,15,14,35,6,36,37,13,38,39,16]),import.meta.url).then(i=>({default:i.McpRunDetailPage}))),ij=j.lazy(()=>we(()=>import("./McpQueryPage-CPkVwNIK.js"),__vite__mapDeps([40,1,15,14,9,10,13,12,16,8,11,32,17,33,5,6,4,41]),import.meta.url).then(i=>({default:i.McpQueryPage}))),rj=j.lazy(()=>we(()=>import("./McpQueryDetailPage-BtqwHUAg.js"),__vite__mapDeps([42,1,15,14,20,41,6,27,4,43,36,26,3,2,44,45,46,47,48,49,35,50,38,39]),import.meta.url).then(i=>({default:i.McpQueryDetailPage}))),aj=j.lazy(()=>we(()=>import("./EscalationsOverview-C1e7IPn_.js"),__vite__mapDeps([51,1,4,15,14,29,6]),import.meta.url).then(i=>({default:i.EscalationsOverview}))),lj=j.lazy(()=>we(()=>import("./AvailableEscalationsPage-8pMC7Xv6.js"),__vite__mapDeps([52,1,53,4,14,54,55,6,56,57,13,58,21,17,59,9,10,20,12,5,7,8,23,33,16]),import.meta.url).then(i=>({default:i.AvailableEscalationsPage}))),oj=j.lazy(()=>we(()=>import("./OperatorDashboard-Csei5vj-.js"),__vite__mapDeps([60,1,4,5,6,7,8,53,9,10,12,33,57,14,13,58,21,17,59,20,55,16]),import.meta.url).then(i=>({default:i.OperatorDashboard}))),cj=j.lazy(()=>we(()=>import("./index-kzIIeVbx.js"),__vite__mapDeps([61,1,54,55,6,56,15,14,16,59,9,10,20,12,3,4,21,35,22,23]),import.meta.url).then(i=>({default:i.EscalationDetailPage}))),uj=j.lazy(()=>we(()=>import("./WorkflowsOverview-ZfFBzePp.js"),__vite__mapDeps([62,1,3,4,15,14,29,6]),import.meta.url).then(i=>({default:i.WorkflowsOverview}))),fj=j.lazy(()=>we(()=>import("./index-B-WkiNRN.js"),__vite__mapDeps([63,1,3,15,14,13,17,64,47,48,6]),import.meta.url).then(i=>({default:i.StartWorkflowPage}))),hj=j.lazy(()=>we(()=>import("./index-B-WkiNRN.js"),__vite__mapDeps([63,1,3,15,14,13,17,64,47,48,6]),import.meta.url).then(i=>({default:i.DurableInvokePage}))),dj=j.lazy(()=>we(()=>import("./WorkflowsDashboard-DdJ86We6.js"),__vite__mapDeps([65,1,32,3,31,28,6,4,5,8,9,10,17,14,15,13,12,16,33]),import.meta.url).then(i=>({default:()=>i.WorkflowsDashboard({tier:"durable"})}))),mj=j.lazy(()=>we(()=>import("./WorkflowsDashboard-DdJ86We6.js"),__vite__mapDeps([65,1,32,3,31,28,6,4,5,8,9,10,17,14,15,13,12,16,33]),import.meta.url).then(i=>({default:()=>i.WorkflowsDashboard({tier:"all"})}))),pj=j.lazy(()=>we(()=>import("./YamlWorkflowsPage-iHPNXjQj.js"),__vite__mapDeps([66,1,27,5,6,15,14,13,10,49,64,20]),import.meta.url).then(i=>({default:i.YamlWorkflowsPage}))),gj=j.lazy(()=>we(()=>import("./GraphInvokePage-LMpWw8z1.js"),__vite__mapDeps([67,1,27,15,14,44,46,47,48,45,6,49,64]),import.meta.url).then(i=>({default:i.GraphInvokePage}))),yj=j.lazy(()=>we(()=>import("./YamlWorkflowDetailPage-4bd5yXdA.js"),__vite__mapDeps([68,1,27,20,64,14,6]),import.meta.url).then(i=>({default:i.YamlWorkflowDetailPage}))),bj=j.lazy(()=>we(()=>import("./TasksListPage-KAhmCWB2.js"),__vite__mapDeps([69,1,2,3,5,6,9,10,20,58,50,12,13,14,15,17]),import.meta.url).then(i=>({default:i.TasksListPage}))),xj=j.lazy(()=>we(()=>import("./TaskDetailPage-BjE4G2yn.js"),__vite__mapDeps([70,1,2,20,58,15,14,6]),import.meta.url).then(i=>({default:i.TaskDetailPage}))),jg=j.lazy(()=>we(()=>import("./WorkflowExecutionPage-D3VQ9iQV.js"),__vite__mapDeps([71,1,3,4,37,13,14,38,20,6,39,2,15,36,16,35]),import.meta.url).then(i=>({default:i.WorkflowExecutionPage}))),vj=j.lazy(()=>we(()=>import("./AdminDashboard-CkTbRfY9.js"),__vite__mapDeps([72,1,2,4,25,19,14,6]),import.meta.url).then(i=>({default:i.AdminDashboard}))),_j=j.lazy(()=>we(()=>import("./index-BsOxMMmb.js"),__vite__mapDeps([73,1,3,9,10,13,14,33,5,6,15,74,17]),import.meta.url).then(i=>({default:i.WorkersPage}))),wj=j.lazy(()=>we(()=>import("./index-nIrYejxe.js"),__vite__mapDeps([75,1,3,13,14,76,55,6,21,17,15,47,48,64]),import.meta.url).then(i=>({default:i.WorkflowConfigsPage}))),Ag=j.lazy(()=>we(()=>import("./index-nIrYejxe.js"),__vite__mapDeps([75,1,3,13,14,76,55,6,21,17,15,47,48,64]),import.meta.url).then(i=>({default:i.WorkflowConfigDetailPage}))),Sj=j.lazy(()=>we(()=>import("./index-BaV3l0UE.js"),__vite__mapDeps([77,1,25,10,76,55,6,15,14,13,12,5,78,46,47,48,49,45,33,20]),import.meta.url).then(i=>({default:i.McpServersPage}))),Og=j.lazy(()=>we(()=>import("./index-CI8rrKjx.js"),__vite__mapDeps([79,1,25,15,14,43,6]),import.meta.url).then(i=>({default:i.McpServerDetailPage}))),Ej=j.lazy(()=>we(()=>import("./index-CItsikDw.js"),__vite__mapDeps([80,1,23,5,6,9,10,12,13,14,76,55,33,15,21,48,50,81,82]),import.meta.url).then(i=>({default:i.UsersPage}))),jj=j.lazy(()=>we(()=>import("./RolesPage-CKluVSpB.js"),__vite__mapDeps([83,1,15,14,21,55,6]),import.meta.url).then(i=>({default:i.RolesPage}))),Aj=j.lazy(()=>we(()=>import("./RoleDetailPage-C0ju2-4K.js"),__vite__mapDeps([84,1,76,55,6,85,23,14]),import.meta.url).then(i=>({default:i.RoleDetailPage}))),Oj=j.lazy(()=>we(()=>import("./PersonasPage-Bdcoay3P.js"),__vite__mapDeps([86,1,81,15,14,21,55,6,23,7]),import.meta.url).then(i=>({default:i.PersonasPage}))),Nj=j.lazy(()=>we(()=>import("./PersonaDetailPage--ZL6Or6v.js"),__vite__mapDeps([87,1,81,21,14,82,85,76,55,6]),import.meta.url).then(i=>({default:i.PersonaDetailPage}))),Tj=j.lazy(()=>we(()=>import("./EscalationSchemaPage-k-2hFT2t.js"),__vite__mapDeps([88,1,14,6]),import.meta.url).then(i=>({default:i.EscalationSchemaPage}))),kj=j.lazy(()=>we(()=>import("./EscalationListSchemaPage-CDaNmbUA.js"),__vite__mapDeps([89,1,14,6]),import.meta.url).then(i=>({default:i.EscalationListSchemaPage}))),Cj=j.lazy(()=>we(()=>import("./index-CStR4uIU.js"),__vite__mapDeps([90,1,15,14,55,6,56]),import.meta.url).then(i=>({default:i.MaintenancePage}))),Mj=j.lazy(()=>we(()=>import("./OperationsPage-DlyGLPAs.js").then(i=>i.O),__vite__mapDeps([91,1,4,15,14,6]),import.meta.url).then(i=>({default:i.OperationsPage}))),Rj=j.lazy(()=>we(()=>import("./index-BO-7S9Xw.js"),__vite__mapDeps([92,1,19,14,13,5,6,31,28,55,36,74,9,10,33]),import.meta.url).then(i=>({default:i.ControlPlanePage}))),Dj=j.lazy(()=>we(()=>import("./index-DhATO1cS.js"),__vite__mapDeps([93,1,39,14,5,6,31,28,8,9,10,12,13,15,16]),import.meta.url).then(i=>({default:i.StreamMessagesPage}))),qj=j.lazy(()=>we(()=>import("./CredentialsPage-B73Si6K1.js"),__vite__mapDeps([94,1,15,14,50,76,55,6]),import.meta.url).then(i=>({default:i.CredentialsPage}))),zj=j.lazy(()=>we(()=>import("./index-Tx_ETzcH.js"),__vite__mapDeps([95,1,6,15,14,13,16,8,10,96,50]),import.meta.url).then(i=>({default:i.FilesPage}))),Uj=j.lazy(()=>we(()=>import("./index-xZqQxqu2.js"),__vite__mapDeps([97,1,15,14,13,16,12,10,96,50,98,43,6]),import.meta.url).then(i=>({default:i.KnowledgePage}))),Bj=j.lazy(()=>we(()=>import("./HomePage-Kl2DBG6l.js"),__vite__mapDeps([99,1,3,26,28,4,21,14,17,16,91,15,6,53]),import.meta.url).then(i=>({default:i.HomePage}))),Lj=j.lazy(()=>we(()=>import("./AgentsPage-bSx_mdae.js"),__vite__mapDeps([100,1,101,4,5,6,8,9,10,12,13,14,15,16]),import.meta.url).then(i=>({default:i.AgentsPage}))),Pj=j.lazy(()=>we(()=>import("./AgentDetailPage-sQ1-UT46.js"),__vite__mapDeps([102,1,101,103,14,4,17,6]),import.meta.url).then(i=>({default:i.AgentDetailPage}))),Ng=j.lazy(()=>we(()=>import("./AgentConfigPage-Cm8FRpXi.js"),__vite__mapDeps([104,1,101,103,14,15,98,46,47,48,3,27,105,106,17,6]),import.meta.url).then(i=>({default:i.AgentConfigPage}))),Hj=j.lazy(()=>we(()=>import("./CapabilitiesPage-BRoOeKcc.js"),__vite__mapDeps([107,1,105,78,25,46,47,48,14,49,6,45,15,13]),import.meta.url).then(i=>({default:i.CapabilitiesPage}))),$j=j.lazy(()=>we(()=>import("./TopicsPage-DoGqAdPm.js"),__vite__mapDeps([108,1,106,15,14,13,6]),import.meta.url).then(i=>({default:i.TopicsPage}))),Yj=j.lazy(()=>we(()=>import("./TopicDetailPage-DAqx5JqA.js"),__vite__mapDeps([109,1,106,16,14,6]),import.meta.url).then(i=>({default:i.TopicDetailPage})));function Gj(){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 xe({children:i}){return h.jsx(j.Suspense,{fallback:h.jsx(Gj,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:i})})}const Fy=new iv({defaultOptions:{queries:{staleTime:1e4,retry:(i,t)=>t instanceof Error&&t.message==="Session expired"?!1:i<1}}});window.addEventListener("auth:unauthorized",()=>{Fy.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const i=window.__LT_BASE__||"",t=`${i}/login`;if(window.location.pathname!==t){const s=window.location.pathname+window.location.search,a=i&&s.startsWith(i)?s.slice(i.length)||"/":s;window.location.href=`${t}?returnTo=${encodeURIComponent(a)}`}});const Vj=lv([{path:"/login",element:h.jsx(KE,{})},{path:"/connect/anthropic",element:h.jsx(Eg,{})},{path:"/connect/:provider",element:h.jsx(Eg,{})},{path:"/",element:h.jsx(FE,{}),children:[{index:!0,element:h.jsx(xe,{children:h.jsx(Bj,{})})},{path:"processes/all",element:h.jsx(xe,{children:h.jsx(WE,{})})},{path:"processes/detail/:originId",element:h.jsx(xe,{children:h.jsx(ej,{})})},{path:"credentials",element:h.jsx(xe,{children:h.jsx(qj,{})})},{path:"connections",element:h.jsx(Pn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(xe,{children:h.jsx(aj,{})})},{path:"escalations/available",element:h.jsx(xe,{children:h.jsx(lj,{})})},{path:"escalations/queue",element:h.jsx(xe,{children:h.jsx(oj,{})})},{path:"escalations/detail/:id",element:h.jsx(xe,{children:h.jsx(cj,{})})},{path:"capabilities",element:h.jsx(xe,{children:h.jsx(Hj,{})})},{path:"agents",element:h.jsx(xe,{children:h.jsx(Lj,{})})},{path:"agents/new",element:h.jsx(xe,{children:h.jsx(Ng,{})})},{path:"agents/:id",element:h.jsx(xe,{children:h.jsx(Pj,{})})},{path:"agents/:id/edit",element:h.jsx(xe,{children:h.jsx(Ng,{})})},{path:"topics",element:h.jsx(xe,{children:h.jsx($j,{})})},{path:"topics/:topic",element:h.jsx(xe,{children:h.jsx(Yj,{})})},{element:h.jsx(No,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(xe,{children:h.jsx(uj,{})})},{path:"workflows/executions",element:h.jsx(xe,{children:h.jsx(mj,{})})},{path:"workflows/durable/executions",element:h.jsx(xe,{children:h.jsx(dj,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(xe,{children:h.jsx(jg,{})})},{path:"workflows/tasks",element:h.jsx(xe,{children:h.jsx(bj,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(xe,{children:h.jsx(xj,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(xe,{children:h.jsx(jg,{})})},{path:"workflows/start",element:h.jsx(xe,{children:h.jsx(fj,{})})},{path:"workflows/durable/invoke",element:h.jsx(xe,{children:h.jsx(hj,{})})},{path:"workflows/cron",element:h.jsx(Pn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(xe,{children:h.jsx(_j,{})})},{path:"workflows/registry",element:h.jsx(xe,{children:h.jsx(wj,{})})},{path:"workflows/registry/new",element:h.jsx(xe,{children:h.jsx(Ag,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(xe,{children:h.jsx(Ag,{})})}]},{element:h.jsx(No,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(xe,{children:h.jsx(pj,{})})},{path:"mcp/workflows/invoke",element:h.jsx(xe,{children:h.jsx(gj,{})})},{path:"mcp/workflows/:id",element:h.jsx(xe,{children:h.jsx(yj,{})})},{path:"mcp/executions",element:h.jsx(xe,{children:h.jsx(nj,{})})},{path:"mcp/executions/:jobId",element:h.jsx(xe,{children:h.jsx(sj,{})})},{path:"files",element:h.jsx(xe,{children:h.jsx(zj,{})})},{path:"knowledge",element:h.jsx(xe,{children:h.jsx(Uj,{})})},{element:h.jsx(XE,{}),children:[{path:"mcp",element:h.jsx(xe,{children:h.jsx(tj,{})})},{path:"mcp/queries",element:h.jsx(xe,{children:h.jsx(ij,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(xe,{children:h.jsx(rj,{})})},{path:"mcp/tools",element:h.jsx(Pn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(xe,{children:h.jsx(Sj,{})})},{path:"mcp/servers/new",element:h.jsx(xe,{children:h.jsx(Og,{})})},{path:"mcp/servers/:serverId",element:h.jsx(xe,{children:h.jsx(Og,{})})}]}]},{path:"operations",element:h.jsx(xe,{children:h.jsx(Mj,{})})},{element:h.jsx(No,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(xe,{children:h.jsx(vj,{})})},{path:"admin/users",element:h.jsx(xe,{children:h.jsx(Ej,{})})},{path:"admin/escalation-chains",element:h.jsx(Pn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(xe,{children:h.jsx(jj,{})})},{path:"admin/roles/:role",element:h.jsx(xe,{children:h.jsx(Aj,{})})},{path:"admin/roles/:role/schema",element:h.jsx(xe,{children:h.jsx(Tj,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(xe,{children:h.jsx(kj,{})})},{path:"admin/personas",element:h.jsx(xe,{children:h.jsx(Oj,{})})},{path:"admin/personas/:key",element:h.jsx(xe,{children:h.jsx(Nj,{})})}]},{element:h.jsx(No,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(Pn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(ZE,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(xe,{children:h.jsx(Cj,{})})}]},{path:"admin/controlplane",element:h.jsx(xe,{children:h.jsx(Rj,{})})},{path:"admin/streams",element:h.jsx(xe,{children:h.jsx(Dj,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function Ij(){return h.jsx(rv,{client:Fy,children:h.jsx(Fv,{children:h.jsx(Kw,{children:h.jsx(ov,{router:Vj})})})})}Ty(Ny());const kh=document.createElement("link");kh.rel="stylesheet";kh.href=`${Tt}/api/settings/custom.css`;document.head.appendChild(kh);$v.createRoot(document.getElementById("root")).render(h.jsx(j.StrictMode,{children:h.jsx(Ij,{})}));export{Vv as $,gA as A,bA as B,Oh as C,LE as D,xA as E,Ry as F,AS as G,iA as H,kS as I,a2 as J,Ey as K,Sy as L,AA as M,K_ as N,Th as O,cA as P,TS as Q,zA as R,JS as S,Nh as T,uS as U,tA as V,eA as W,lA as X,fA as Y,yA as Z,_A as _,BA as a,MS as a0,Gy as a1,Vy as a2,UA as a3,NA as a4,vA as a5,TA as a6,kA as a7,wA as a8,SA as a9,jA as aa,EA as ab,th as ac,tg as ad,mh as ae,DA as af,Wj as ag,Tt as ah,Ug as ai,OA as aj,nA as ak,LA as al,PA as am,Iy as an,Sh as ao,xy as ap,qA as aq,BE as b,Xj as c,Ee as d,aA as e,qE as f,oA as g,uA as h,sA as i,gy as j,En as k,rA as l,MA as m,RA as n,cS as o,CS as p,OS as q,NS as r,qS as s,by as t,si as u,hA as v,CA as w,dA as x,mA as y,pA as z};
63
+ //# sourceMappingURL=index-DbTD-dio.js.map