@hotmeshio/long-tail 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/build/api/roles.js +4 -0
  2. package/build/api/scan-codes/choice.js +6 -3
  3. package/build/api/scan-codes/context.d.ts +7 -1
  4. package/build/api/scan-codes/context.js +24 -0
  5. package/build/api/scan-codes/execute.js +4 -2
  6. package/build/api/scan-codes/present.d.ts +3 -1
  7. package/build/api/scan-codes/present.js +25 -12
  8. package/build/routes/oauth.js +9 -6
  9. package/build/services/oauth/providers/github.js +2 -1
  10. package/build/services/oauth/providers/google.js +3 -3
  11. package/build/services/oauth/providers/microsoft.js +4 -1
  12. package/build/services/oauth/providers/mock.js +1 -1
  13. package/build/services/role/scan-done.d.ts +7 -0
  14. package/build/services/role/scan-done.js +36 -0
  15. package/build/services/role/seed.js +4 -0
  16. package/build/services/role/types.d.ts +11 -0
  17. package/build/services/role/types.js +4 -0
  18. package/build/services/scan-code/validate.js +50 -0
  19. package/build/tsconfig.tsbuildinfo +1 -1
  20. package/build/types/index.d.ts +2 -2
  21. package/build/types/index.js +3 -1
  22. package/build/types/oauth.d.ts +1 -0
  23. package/build/types/scan-choice.d.ts +8 -0
  24. package/build/types/scan-code/constants.d.ts +3 -0
  25. package/build/types/scan-code/constants.js +4 -1
  26. package/build/types/scan-code/response.d.ts +14 -0
  27. package/build/types/scan-code/rule.d.ts +11 -0
  28. package/dashboard/dist/assets/{AdminDashboard-DRE0hSDS.js → AdminDashboard-Bjf_7-S6.js} +2 -2
  29. package/dashboard/dist/assets/{AdminDashboard-DRE0hSDS.js.map → AdminDashboard-Bjf_7-S6.js.map} +1 -1
  30. package/dashboard/dist/assets/{AgentConfigPage-BuflQGgy.js → AgentConfigPage-CEGk5Gbv.js} +6 -6
  31. package/dashboard/dist/assets/{AgentConfigPage-BuflQGgy.js.map → AgentConfigPage-CEGk5Gbv.js.map} +1 -1
  32. package/dashboard/dist/assets/{AgentDetailPage-BiL9FB7i.js → AgentDetailPage-C52Oi1_f.js} +3 -3
  33. package/dashboard/dist/assets/{AgentDetailPage-BiL9FB7i.js.map → AgentDetailPage-C52Oi1_f.js.map} +1 -1
  34. package/dashboard/dist/assets/{AgentsPage-C4ZxCNxt.js → AgentsPage-CohqxaWS.js} +2 -2
  35. package/dashboard/dist/assets/{AgentsPage-C4ZxCNxt.js.map → AgentsPage-CohqxaWS.js.map} +1 -1
  36. package/dashboard/dist/assets/{AvailableEscalationsPage-B5p8QJvI.js → AvailableEscalationsPage-DXpRnOVd.js} +2 -2
  37. package/dashboard/dist/assets/{AvailableEscalationsPage-B5p8QJvI.js.map → AvailableEscalationsPage-DXpRnOVd.js.map} +1 -1
  38. package/dashboard/dist/assets/{BotPicker-B7V77PnY.js → BotPicker-DPglulL6.js} +2 -2
  39. package/dashboard/dist/assets/{BotPicker-B7V77PnY.js.map → BotPicker-DPglulL6.js.map} +1 -1
  40. package/dashboard/dist/assets/{BulkAssignModal-DcGVMQqm.js → BulkAssignModal-DWNR3FJJ.js} +2 -2
  41. package/dashboard/dist/assets/{BulkAssignModal-DcGVMQqm.js.map → BulkAssignModal-DWNR3FJJ.js.map} +1 -1
  42. package/dashboard/dist/assets/{CapabilitiesPage-DmbC1pEs.js → CapabilitiesPage-ChBBD0IX.js} +2 -2
  43. package/dashboard/dist/assets/{CapabilitiesPage-DmbC1pEs.js.map → CapabilitiesPage-ChBBD0IX.js.map} +1 -1
  44. package/dashboard/dist/assets/{CollapsibleSection-C81S1qic.js → CollapsibleSection-QAXKTYc6.js} +2 -2
  45. package/dashboard/dist/assets/{CollapsibleSection-C81S1qic.js.map → CollapsibleSection-QAXKTYc6.js.map} +1 -1
  46. package/dashboard/dist/assets/{ConfirmDeleteModal-3RFyWN9Q.js → ConfirmDeleteModal-J9xc_gVZ.js} +2 -2
  47. package/dashboard/dist/assets/{ConfirmDeleteModal-3RFyWN9Q.js.map → ConfirmDeleteModal-J9xc_gVZ.js.map} +1 -1
  48. package/dashboard/dist/assets/{ConnectedAppsPage-B0D2OvTD.js → ConnectedAppsPage-BKhsc_jJ.js} +2 -2
  49. package/dashboard/dist/assets/{ConnectedAppsPage-B0D2OvTD.js.map → ConnectedAppsPage-BKhsc_jJ.js.map} +1 -1
  50. package/dashboard/dist/assets/{CountdownTimer-iAG28fzG.js → CountdownTimer-C4hP64lF.js} +2 -2
  51. package/dashboard/dist/assets/{CountdownTimer-iAG28fzG.js.map → CountdownTimer-C4hP64lF.js.map} +1 -1
  52. package/dashboard/dist/assets/{CredentialsPage-DoFwNvFv.js → CredentialsPage-DUfgsEbI.js} +2 -2
  53. package/dashboard/dist/assets/{CredentialsPage-DoFwNvFv.js.map → CredentialsPage-DUfgsEbI.js.map} +1 -1
  54. package/dashboard/dist/assets/{CronLabel-C1Bb2wo4.js → CronLabel-CBc3Tvau.js} +2 -2
  55. package/dashboard/dist/assets/{CronLabel-C1Bb2wo4.js.map → CronLabel-CBc3Tvau.js.map} +1 -1
  56. package/dashboard/dist/assets/{DropZone-Cl_Flb16.js → DropZone-DefYTYQy.js} +2 -2
  57. package/dashboard/dist/assets/{DropZone-Cl_Flb16.js.map → DropZone-DefYTYQy.js.map} +1 -1
  58. package/dashboard/dist/assets/{ElapsedCell-DZs1I1JW.js → ElapsedCell-V27Y2Ksb.js} +2 -2
  59. package/dashboard/dist/assets/{ElapsedCell-DZs1I1JW.js.map → ElapsedCell-V27Y2Ksb.js.map} +1 -1
  60. package/dashboard/dist/assets/{EntityTimelinePanel-Du1O6Oly.js → EntityTimelinePanel-BA4MWXkB.js} +2 -2
  61. package/dashboard/dist/assets/{EntityTimelinePanel-Du1O6Oly.js.map → EntityTimelinePanel-BA4MWXkB.js.map} +1 -1
  62. package/dashboard/dist/assets/{EscalationListSchemaPage-CrpBhC0e.js → EscalationListSchemaPage-B20HUAlO.js} +2 -2
  63. package/dashboard/dist/assets/{EscalationListSchemaPage-CrpBhC0e.js.map → EscalationListSchemaPage-B20HUAlO.js.map} +1 -1
  64. package/dashboard/dist/assets/{EscalationSchemaPage-Co59lcuD.js → EscalationSchemaPage-Cen9HGYG.js} +2 -2
  65. package/dashboard/dist/assets/{EscalationSchemaPage-Co59lcuD.js.map → EscalationSchemaPage-Cen9HGYG.js.map} +1 -1
  66. package/dashboard/dist/assets/{EscalationTimeline-B_fzNsX5.js → EscalationTimeline-DGNgcMm0.js} +2 -2
  67. package/dashboard/dist/assets/{EscalationTimeline-B_fzNsX5.js.map → EscalationTimeline-DGNgcMm0.js.map} +1 -1
  68. package/dashboard/dist/assets/{EscalationTitleSelect-C2Goebjo.js → EscalationTitleSelect-BhsflGiC.js} +2 -2
  69. package/dashboard/dist/assets/{EscalationTitleSelect-C2Goebjo.js.map → EscalationTitleSelect-BhsflGiC.js.map} +1 -1
  70. package/dashboard/dist/assets/{EscalationsOverview-Cgmrl8Zc.js → EscalationsOverview-C2nc-Pgv.js} +2 -2
  71. package/dashboard/dist/assets/{EscalationsOverview-Cgmrl8Zc.js.map → EscalationsOverview-C2nc-Pgv.js.map} +1 -1
  72. package/dashboard/dist/assets/{EventTable-BdEiu3Fv.js → EventTable-BvNxHKy1.js} +2 -2
  73. package/dashboard/dist/assets/{EventTable-BdEiu3Fv.js.map → EventTable-BvNxHKy1.js.map} +1 -1
  74. package/dashboard/dist/assets/{FilterBar-CzKYBOMC.js → FilterBar-22FDO0R_.js} +2 -2
  75. package/dashboard/dist/assets/{FilterBar-CzKYBOMC.js.map → FilterBar-22FDO0R_.js.map} +1 -1
  76. package/dashboard/dist/assets/{GraphInvokePage-CcDFhY53.js → GraphInvokePage-BAyfJ-PY.js} +2 -2
  77. package/dashboard/dist/assets/{GraphInvokePage-CcDFhY53.js.map → GraphInvokePage-BAyfJ-PY.js.map} +1 -1
  78. package/dashboard/dist/assets/{HomePage-Xahqcdu9.js → HomePage-CtjG2kGn.js} +2 -2
  79. package/dashboard/dist/assets/{HomePage-Xahqcdu9.js.map → HomePage-CtjG2kGn.js.map} +1 -1
  80. package/dashboard/dist/assets/{LinePage-DKwhGunp.js → LinePage-DPe-vP3-.js} +3 -3
  81. package/dashboard/dist/assets/{LinePage-DKwhGunp.js.map → LinePage-DPe-vP3-.js.map} +1 -1
  82. package/dashboard/dist/assets/{LinesPage-BXZVO4MC.js → LinesPage-BCSfYkuL.js} +2 -2
  83. package/dashboard/dist/assets/{LinesPage-BXZVO4MC.js.map → LinesPage-BCSfYkuL.js.map} +1 -1
  84. package/dashboard/dist/assets/{ListToolbar-orQsOdl_.js → ListToolbar-6siR0Hao.js} +2 -2
  85. package/dashboard/dist/assets/{ListToolbar-orQsOdl_.js.map → ListToolbar-6siR0Hao.js.map} +1 -1
  86. package/dashboard/dist/assets/{McpOverview-pSnadtSM.js → McpOverview-Cbu2CXlQ.js} +2 -2
  87. package/dashboard/dist/assets/{McpOverview-pSnadtSM.js.map → McpOverview-Cbu2CXlQ.js.map} +1 -1
  88. package/dashboard/dist/assets/{McpQueryDetailPage-BCAJ3rKO.js → McpQueryDetailPage--1FsnGuM.js} +2 -2
  89. package/dashboard/dist/assets/{McpQueryDetailPage-BCAJ3rKO.js.map → McpQueryDetailPage--1FsnGuM.js.map} +1 -1
  90. package/dashboard/dist/assets/{McpQueryPage-CRyXeRp5.js → McpQueryPage-CPUUMIiY.js} +2 -2
  91. package/dashboard/dist/assets/{McpQueryPage-CRyXeRp5.js.map → McpQueryPage-CPUUMIiY.js.map} +1 -1
  92. package/dashboard/dist/assets/{McpRunDetailPage-BHppCztI.js → McpRunDetailPage-BDCv-c1o.js} +2 -2
  93. package/dashboard/dist/assets/{McpRunDetailPage-BHppCztI.js.map → McpRunDetailPage-BDCv-c1o.js.map} +1 -1
  94. package/dashboard/dist/assets/{McpRunsPage-Cd9yCT-_.js → McpRunsPage-Df4yOclO.js} +2 -2
  95. package/dashboard/dist/assets/{McpRunsPage-Cd9yCT-_.js.map → McpRunsPage-Df4yOclO.js.map} +1 -1
  96. package/dashboard/dist/assets/{NamespacePill-OTZD2hzt.js → NamespacePill-CeSfHH-j.js} +2 -2
  97. package/dashboard/dist/assets/{NamespacePill-OTZD2hzt.js.map → NamespacePill-CeSfHH-j.js.map} +1 -1
  98. package/dashboard/dist/assets/{OperationsPage-BtnthZgj.js → OperationsPage-BYUGFgPp.js} +2 -2
  99. package/dashboard/dist/assets/{OperationsPage-BtnthZgj.js.map → OperationsPage-BYUGFgPp.js.map} +1 -1
  100. package/dashboard/dist/assets/{OperatorDashboard-B4_OBhYh.js → OperatorDashboard-Dd1EhTZe.js} +2 -2
  101. package/dashboard/dist/assets/{OperatorDashboard-B4_OBhYh.js.map → OperatorDashboard-Dd1EhTZe.js.map} +1 -1
  102. package/dashboard/dist/assets/{PageHeader-Hx8APPwE.js → PageHeader-DiGWAQlR.js} +2 -2
  103. package/dashboard/dist/assets/{PageHeader-Hx8APPwE.js.map → PageHeader-DiGWAQlR.js.map} +1 -1
  104. package/dashboard/dist/assets/{PageHeaderWithStats-BEQYYBJv.js → PageHeaderWithStats-DwnKQ06j.js} +2 -2
  105. package/dashboard/dist/assets/{PageHeaderWithStats-BEQYYBJv.js.map → PageHeaderWithStats-DwnKQ06j.js.map} +1 -1
  106. package/dashboard/dist/assets/{PersonaDetailPage-BAYjM9qf.js → PersonaDetailPage-BCx3Ey2_.js} +2 -2
  107. package/dashboard/dist/assets/{PersonaDetailPage-BAYjM9qf.js.map → PersonaDetailPage-BCx3Ey2_.js.map} +1 -1
  108. package/dashboard/dist/assets/{PersonasPage-6HsOp-1y.js → PersonasPage--Ez0YeHh.js} +2 -2
  109. package/dashboard/dist/assets/{PersonasPage-6HsOp-1y.js.map → PersonasPage--Ez0YeHh.js.map} +1 -1
  110. package/dashboard/dist/assets/{PortalPage-6OMr7KtJ.js → PortalPage-BmBmheBp.js} +2 -2
  111. package/dashboard/dist/assets/{PortalPage-6OMr7KtJ.js.map → PortalPage-BmBmheBp.js.map} +1 -1
  112. package/dashboard/dist/assets/{ProcessDetailPage-AidH_h7z.js → ProcessDetailPage-DBj4VEnP.js} +2 -2
  113. package/dashboard/dist/assets/{ProcessDetailPage-AidH_h7z.js.map → ProcessDetailPage-DBj4VEnP.js.map} +1 -1
  114. package/dashboard/dist/assets/{ProcessesListPage-BWKoKbXk.js → ProcessesListPage-CD5NRIBK.js} +2 -2
  115. package/dashboard/dist/assets/{ProcessesListPage-BWKoKbXk.js.map → ProcessesListPage-CD5NRIBK.js.map} +1 -1
  116. package/dashboard/dist/assets/{ResolverForm-BaSvhLoT.js → ResolverForm-Baxwv_IG.js} +2 -2
  117. package/dashboard/dist/assets/{ResolverForm-BaSvhLoT.js.map → ResolverForm-Baxwv_IG.js.map} +1 -1
  118. package/dashboard/dist/assets/RoleDetailPage-6ukNyycs.js +8 -0
  119. package/dashboard/dist/assets/RoleDetailPage-6ukNyycs.js.map +1 -0
  120. package/dashboard/dist/assets/{RolePill-R5_ctGFy.js → RolePill-D3hkAdKf.js} +2 -2
  121. package/dashboard/dist/assets/{RolePill-R5_ctGFy.js.map → RolePill-D3hkAdKf.js.map} +1 -1
  122. package/dashboard/dist/assets/{RolesPage-T2hH_MV5.js → RolesPage-DRs2XeSd.js} +2 -2
  123. package/dashboard/dist/assets/{RolesPage-T2hH_MV5.js.map → RolesPage-DRs2XeSd.js.map} +1 -1
  124. package/dashboard/dist/assets/{RosterWidget-DG6Rcx4P.js → RosterWidget-BPBPSa1k.js} +2 -2
  125. package/dashboard/dist/assets/{RosterWidget-DG6Rcx4P.js.map → RosterWidget-BPBPSa1k.js.map} +1 -1
  126. package/dashboard/dist/assets/{RunAsSelector-M2h9U6PP.js → RunAsSelector-Br9FiMwP.js} +2 -2
  127. package/dashboard/dist/assets/{RunAsSelector-M2h9U6PP.js.map → RunAsSelector-Br9FiMwP.js.map} +1 -1
  128. package/dashboard/dist/assets/{ScanCodesPage-lB_WxoZw.js → ScanCodesPage-BXENWoZb.js} +2 -2
  129. package/dashboard/dist/assets/{ScanCodesPage-lB_WxoZw.js.map → ScanCodesPage-BXENWoZb.js.map} +1 -1
  130. package/dashboard/dist/assets/{ScanSchemeDetailPage-C3VLg61H.js → ScanSchemeDetailPage-CaM4rUBV.js} +2 -2
  131. package/dashboard/dist/assets/{ScanSchemeDetailPage-C3VLg61H.js.map → ScanSchemeDetailPage-CaM4rUBV.js.map} +1 -1
  132. package/dashboard/dist/assets/ScanStationPage-CmJKgWy_.js +2 -0
  133. package/dashboard/dist/assets/ScanStationPage-CmJKgWy_.js.map +1 -0
  134. package/dashboard/dist/assets/{ScopeBadge-BXZ084nD.js → ScopeBadge-DGz79rmG.js} +2 -2
  135. package/dashboard/dist/assets/{ScopeBadge-BXZ084nD.js.map → ScopeBadge-DGz79rmG.js.map} +1 -1
  136. package/dashboard/dist/assets/{StickyPagination-BdjseWXr.js → StickyPagination-DX5CPgrX.js} +2 -2
  137. package/dashboard/dist/assets/{StickyPagination-BdjseWXr.js.map → StickyPagination-DX5CPgrX.js.map} +1 -1
  138. package/dashboard/dist/assets/{StreamMessageDetail-DJCBxETh.js → StreamMessageDetail-3mWw3_M5.js} +2 -2
  139. package/dashboard/dist/assets/{StreamMessageDetail-DJCBxETh.js.map → StreamMessageDetail-3mWw3_M5.js.map} +1 -1
  140. package/dashboard/dist/assets/{SwimlaneTimeline-DiXm9jIk.js → SwimlaneTimeline-C_pIcWBJ.js} +2 -2
  141. package/dashboard/dist/assets/{SwimlaneTimeline-DiXm9jIk.js.map → SwimlaneTimeline-C_pIcWBJ.js.map} +1 -1
  142. package/dashboard/dist/assets/{TagInput-DjPUDp2M.js → TagInput-DaIdhv3h.js} +2 -2
  143. package/dashboard/dist/assets/{TagInput-DjPUDp2M.js.map → TagInput-DaIdhv3h.js.map} +1 -1
  144. package/dashboard/dist/assets/{TaskDetailPage-m8CQFN4w.js → TaskDetailPage-DthMVBZO.js} +2 -2
  145. package/dashboard/dist/assets/{TaskDetailPage-m8CQFN4w.js.map → TaskDetailPage-DthMVBZO.js.map} +1 -1
  146. package/dashboard/dist/assets/{TaskQueuePill-D-4Ynf3K.js → TaskQueuePill-sUA1nZe-.js} +2 -2
  147. package/dashboard/dist/assets/{TaskQueuePill-D-4Ynf3K.js.map → TaskQueuePill-sUA1nZe-.js.map} +1 -1
  148. package/dashboard/dist/assets/{TasksListPage-DHBSUhZC.js → TasksListPage-MtawUpuU.js} +2 -2
  149. package/dashboard/dist/assets/{TasksListPage-DHBSUhZC.js.map → TasksListPage-MtawUpuU.js.map} +1 -1
  150. package/dashboard/dist/assets/{TimeAgo-Cq3bKUd-.js → TimeAgo-DIziYk-v.js} +2 -2
  151. package/dashboard/dist/assets/{TimeAgo-Cq3bKUd-.js.map → TimeAgo-DIziYk-v.js.map} +1 -1
  152. package/dashboard/dist/assets/{TimestampCell-e5gRR_FY.js → TimestampCell-Dn5M-Eey.js} +2 -2
  153. package/dashboard/dist/assets/{TimestampCell-e5gRR_FY.js.map → TimestampCell-Dn5M-Eey.js.map} +1 -1
  154. package/dashboard/dist/assets/{ToolPill-GsKQ80CO.js → ToolPill-CpBAFdEX.js} +2 -2
  155. package/dashboard/dist/assets/{ToolPill-GsKQ80CO.js.map → ToolPill-CpBAFdEX.js.map} +1 -1
  156. package/dashboard/dist/assets/{ToolTestPanel-Bg0ss9oN.js → ToolTestPanel-DaBrgPML.js} +2 -2
  157. package/dashboard/dist/assets/{ToolTestPanel-Bg0ss9oN.js.map → ToolTestPanel-DaBrgPML.js.map} +1 -1
  158. package/dashboard/dist/assets/{TopicDetailPage-DhPiCfOO.js → TopicDetailPage-zNE3EigP.js} +2 -2
  159. package/dashboard/dist/assets/{TopicDetailPage-DhPiCfOO.js.map → TopicDetailPage-zNE3EigP.js.map} +1 -1
  160. package/dashboard/dist/assets/{TopicsPage-BqZaVv3d.js → TopicsPage-Cj0ugdie.js} +2 -2
  161. package/dashboard/dist/assets/{TopicsPage-BqZaVv3d.js.map → TopicsPage-Cj0ugdie.js.map} +1 -1
  162. package/dashboard/dist/assets/{UserName-C6ZNHHKN.js → UserName-t3PbLYfd.js} +2 -2
  163. package/dashboard/dist/assets/{UserName-C6ZNHHKN.js.map → UserName-t3PbLYfd.js.map} +1 -1
  164. package/dashboard/dist/assets/{WorkflowExecutionPage-BUqIhtcr.js → WorkflowExecutionPage-CZ2c5QLL.js} +2 -2
  165. package/dashboard/dist/assets/{WorkflowExecutionPage-BUqIhtcr.js.map → WorkflowExecutionPage-CZ2c5QLL.js.map} +1 -1
  166. package/dashboard/dist/assets/{WorkflowPill-D7244fKp.js → WorkflowPill-CKHip3hH.js} +2 -2
  167. package/dashboard/dist/assets/{WorkflowPill-D7244fKp.js.map → WorkflowPill-CKHip3hH.js.map} +1 -1
  168. package/dashboard/dist/assets/{WorkflowsDashboard-BKxhC_hT.js → WorkflowsDashboard-DLb71Sa2.js} +2 -2
  169. package/dashboard/dist/assets/{WorkflowsDashboard-BKxhC_hT.js.map → WorkflowsDashboard-DLb71Sa2.js.map} +1 -1
  170. package/dashboard/dist/assets/{WorkflowsOverview-018s2q_p.js → WorkflowsOverview-Wz6RzxHJ.js} +2 -2
  171. package/dashboard/dist/assets/{WorkflowsOverview-018s2q_p.js.map → WorkflowsOverview-Wz6RzxHJ.js.map} +1 -1
  172. package/dashboard/dist/assets/{YamlWorkflowDetailPage-C2zcXDr1.js → YamlWorkflowDetailPage-CcRAN_ey.js} +2 -2
  173. package/dashboard/dist/assets/{YamlWorkflowDetailPage-C2zcXDr1.js.map → YamlWorkflowDetailPage-CcRAN_ey.js.map} +1 -1
  174. package/dashboard/dist/assets/{YamlWorkflowsPage-aVcNZNu6.js → YamlWorkflowsPage-B4C9fiYU.js} +2 -2
  175. package/dashboard/dist/assets/{YamlWorkflowsPage-aVcNZNu6.js.map → YamlWorkflowsPage-B4C9fiYU.js.map} +1 -1
  176. package/dashboard/dist/assets/{agents-DRaaJUue.js → agents-BvRjwrof.js} +2 -2
  177. package/dashboard/dist/assets/{agents-DRaaJUue.js.map → agents-BvRjwrof.js.map} +1 -1
  178. package/dashboard/dist/assets/{bots-C4N90NCj.js → bots-qx7qPwFo.js} +2 -2
  179. package/dashboard/dist/assets/{bots-C4N90NCj.js.map → bots-qx7qPwFo.js.map} +1 -1
  180. package/dashboard/dist/assets/{capabilities-BoRWifSC.js → capabilities-DJrUEeew.js} +2 -2
  181. package/dashboard/dist/assets/{capabilities-BoRWifSC.js.map → capabilities-DJrUEeew.js.map} +1 -1
  182. package/dashboard/dist/assets/{controlplane-DGZAxi7J.js → controlplane-D82a5cfq.js} +2 -2
  183. package/dashboard/dist/assets/{controlplane-DGZAxi7J.js.map → controlplane-D82a5cfq.js.map} +1 -1
  184. package/dashboard/dist/assets/{escalation-columns-DJbfsH_m.js → escalation-columns-Dmm8LY_f.js} +2 -2
  185. package/dashboard/dist/assets/{escalation-columns-DJbfsH_m.js.map → escalation-columns-Dmm8LY_f.js.map} +1 -1
  186. package/dashboard/dist/assets/{escalation-items-C8iJZEA8.js → escalation-items-C3ko1DCb.js} +2 -2
  187. package/dashboard/dist/assets/{escalation-items-C8iJZEA8.js.map → escalation-items-C3ko1DCb.js.map} +1 -1
  188. package/dashboard/dist/assets/{index-BuSUevzO.js → index-BAxEeqfF.js} +2 -2
  189. package/dashboard/dist/assets/{index-BuSUevzO.js.map → index-BAxEeqfF.js.map} +1 -1
  190. package/dashboard/dist/assets/{index-DhKGp4QK.js → index-BCSeHOZH.js} +2 -2
  191. package/dashboard/dist/assets/{index-DhKGp4QK.js.map → index-BCSeHOZH.js.map} +1 -1
  192. package/dashboard/dist/assets/{index-DeyA88jq.js → index-BJrsQM-E.js} +2 -2
  193. package/dashboard/dist/assets/{index-DeyA88jq.js.map → index-BJrsQM-E.js.map} +1 -1
  194. package/dashboard/dist/assets/{index-CXXc9sUr.js → index-BVxqddYr.js} +2 -2
  195. package/dashboard/dist/assets/{index-CXXc9sUr.js.map → index-BVxqddYr.js.map} +1 -1
  196. package/dashboard/dist/assets/{index-DIU89TX3.js → index-C59ZyWOo.js} +2 -2
  197. package/dashboard/dist/assets/{index-DIU89TX3.js.map → index-C59ZyWOo.js.map} +1 -1
  198. package/dashboard/dist/assets/{index-CyL-6CAa.js → index-CNDnGdvT.js} +2 -2
  199. package/dashboard/dist/assets/{index-CyL-6CAa.js.map → index-CNDnGdvT.js.map} +1 -1
  200. package/dashboard/dist/assets/{index-pzbGpihI.js → index-CSr5q355.js} +25 -25
  201. package/dashboard/dist/assets/index-CSr5q355.js.map +1 -0
  202. package/dashboard/dist/assets/{index-DMKLnxt8.js → index-CXnmU0TS.js} +2 -2
  203. package/dashboard/dist/assets/{index-DMKLnxt8.js.map → index-CXnmU0TS.js.map} +1 -1
  204. package/dashboard/dist/assets/{index-CjjRxpVe.js → index-C_-FoMo9.js} +2 -2
  205. package/dashboard/dist/assets/{index-CjjRxpVe.js.map → index-C_-FoMo9.js.map} +1 -1
  206. package/dashboard/dist/assets/index-C_dp4WgY.css +1 -0
  207. package/dashboard/dist/assets/{index-3HaFP00M.js → index-D-vNL8Hm.js} +2 -2
  208. package/dashboard/dist/assets/{index-3HaFP00M.js.map → index-D-vNL8Hm.js.map} +1 -1
  209. package/dashboard/dist/assets/{index-BFxHIfQ_.js → index-DOkHnsLK.js} +2 -2
  210. package/dashboard/dist/assets/{index-BFxHIfQ_.js.map → index-DOkHnsLK.js.map} +1 -1
  211. package/dashboard/dist/assets/{index-BhS9XSy8.js → index-U5gC9Xgq.js} +2 -2
  212. package/dashboard/dist/assets/{index-BhS9XSy8.js.map → index-U5gC9Xgq.js.map} +1 -1
  213. package/dashboard/dist/assets/{index-CeeSFnl-.js → index-f4-pKYcm.js} +2 -2
  214. package/dashboard/dist/assets/{index-CeeSFnl-.js.map → index-f4-pKYcm.js.map} +1 -1
  215. package/dashboard/dist/assets/{knowledge-BWo3OCJc.js → knowledge-i7_nXSbf.js} +2 -2
  216. package/dashboard/dist/assets/{knowledge-BWo3OCJc.js.map → knowledge-i7_nXSbf.js.map} +1 -1
  217. package/dashboard/dist/assets/{machines-LEYY_yar.js → machines-DfSNshLg.js} +2 -2
  218. package/dashboard/dist/assets/{machines-LEYY_yar.js.map → machines-DfSNshLg.js.map} +1 -1
  219. package/dashboard/dist/assets/{mcp-_0kFRcyT.js → mcp-dCLNwcC8.js} +2 -2
  220. package/dashboard/dist/assets/{mcp-_0kFRcyT.js.map → mcp-dCLNwcC8.js.map} +1 -1
  221. package/dashboard/dist/assets/{mcp-query-BzmN0lc5.js → mcp-query-wmbaGRYi.js} +2 -2
  222. package/dashboard/dist/assets/{mcp-query-BzmN0lc5.js.map → mcp-query-wmbaGRYi.js.map} +1 -1
  223. package/dashboard/dist/assets/{personas-kE4PMrgo.js → personas-B_cJA5UG.js} +2 -2
  224. package/dashboard/dist/assets/{personas-kE4PMrgo.js.map → personas-B_cJA5UG.js.map} +1 -1
  225. package/dashboard/dist/assets/{pipelines-DYDNaypF.js → pipelines-ClUmuwmY.js} +2 -2
  226. package/dashboard/dist/assets/{pipelines-DYDNaypF.js.map → pipelines-ClUmuwmY.js.map} +1 -1
  227. package/dashboard/dist/assets/{tasks-ClJ-mbj9.js → tasks-BE97GrLr.js} +2 -2
  228. package/dashboard/dist/assets/{tasks-ClJ-mbj9.js.map → tasks-BE97GrLr.js.map} +1 -1
  229. package/dashboard/dist/assets/{topics-oHX4vbqe.js → topics-Dk0Y3kZP.js} +2 -2
  230. package/dashboard/dist/assets/{topics-oHX4vbqe.js.map → topics-Dk0Y3kZP.js.map} +1 -1
  231. package/dashboard/dist/assets/{useDebouncedValue-C97KADrj.js → useDebouncedValue-BLGuHd_v.js} +2 -2
  232. package/dashboard/dist/assets/{useDebouncedValue-C97KADrj.js.map → useDebouncedValue-BLGuHd_v.js.map} +1 -1
  233. package/dashboard/dist/assets/{useNamespace-Kje0Rn7j.js → useNamespace-Cj7t8eQd.js} +2 -2
  234. package/dashboard/dist/assets/{useNamespace-Kje0Rn7j.js.map → useNamespace-Cj7t8eQd.js.map} +1 -1
  235. package/dashboard/dist/assets/{useYamlActivityEvents-DMz-HKFv.js → useYamlActivityEvents-C7eurSkD.js} +2 -2
  236. package/dashboard/dist/assets/{useYamlActivityEvents-DMz-HKFv.js.map → useYamlActivityEvents-C7eurSkD.js.map} +1 -1
  237. package/dashboard/dist/assets/{validate-hUqjWN63.js → validate-BypZfZ8R.js} +2 -2
  238. package/dashboard/dist/assets/{validate-hUqjWN63.js.map → validate-BypZfZ8R.js.map} +1 -1
  239. package/dashboard/dist/assets/{vendor-icons-fxBvvHBi.js → vendor-icons-en0_uSRD.js} +191 -186
  240. package/dashboard/dist/assets/vendor-icons-en0_uSRD.js.map +1 -0
  241. package/dashboard/dist/assets/{yaml-workflows-64vfmKJx.js → yaml-workflows-CnMKmznF.js} +2 -2
  242. package/dashboard/dist/assets/{yaml-workflows-64vfmKJx.js.map → yaml-workflows-CnMKmznF.js.map} +1 -1
  243. package/dashboard/dist/index.html +3 -3
  244. package/docs/api/http/roles.md +1 -1
  245. package/docs/dashboard.md +2 -2
  246. package/docs/oauth-and-delegation.md +5 -1
  247. package/docs/scan-codes.md +56 -0
  248. package/package.json +1 -1
  249. package/dashboard/dist/assets/RoleDetailPage-D_30TDVh.js +0 -8
  250. package/dashboard/dist/assets/RoleDetailPage-D_30TDVh.js.map +0 -1
  251. package/dashboard/dist/assets/ScanStationPage-CVET1_4r.js +0 -2
  252. package/dashboard/dist/assets/ScanStationPage-CVET1_4r.js.map +0 -1
  253. package/dashboard/dist/assets/index-B9uv-euR.css +0 -1
  254. package/dashboard/dist/assets/index-pzbGpihI.js.map +0 -1
  255. package/dashboard/dist/assets/vendor-icons-fxBvvHBi.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-BWKoKbXk.js","./vendor-query-DvWWuNIB.js","./tasks-ClJ-mbj9.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-C97KADrj.js","./api-path-u2Jf9QXS.js","./DataTable-FjFhx0SE.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-e5gRR_FY.js","./StickyPagination-BdjseWXr.js","./FilterBar-CzKYBOMC.js","./vendor-icons-fxBvvHBi.js","./PageHeader-Hx8APPwE.js","./ListToolbar-orQsOdl_.js","./WorkflowPill-D7244fKp.js","./ProcessDetailPage-AidH_h7z.js","./PageHeaderWithStats-BEQYYBJv.js","./StatusBadge-DHVwxre2.js","./RolePill-R5_ctGFy.js","./UserName-C6ZNHHKN.js","./McpOverview-pSnadtSM.js","./mcp-_0kFRcyT.js","./pipelines-DYDNaypF.js","./yaml-workflows-64vfmKJx.js","./controlplane-DGZAxi7J.js","./StatCard-nWY4sndl.js","./McpRunsPage-Cd9yCT-_.js","./useNamespace-Kje0Rn7j.js","./ElapsedCell-DZs1I1JW.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-BHppCztI.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-BdEiu3Fv.js","./SwimlaneTimeline-DiXm9jIk.js","./StreamMessageDetail-DJCBxETh.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-CRyXeRp5.js","./mcp-query-BzmN0lc5.js","./McpQueryDetailPage-BCAJ3rKO.js","./TagInput-DjPUDp2M.js","./CollapsibleSection-C81S1qic.js","./useYamlActivityEvents-DMz-HKFv.js","./helpers-DzO-OGPe.js","./RunAsSelector-M2h9U6PP.js","./BotPicker-B7V77PnY.js","./bots-C4N90NCj.js","./ToolPill-GsKQ80CO.js","./TimeAgo-Cq3bKUd-.js","./EscalationsOverview-Cgmrl8Zc.js","./AvailableEscalationsPage-B5p8QJvI.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-DcGVMQqm.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-C2Goebjo.js","./EscalationTimeline-B_fzNsX5.js","./escalation-items-C8iJZEA8.js","./validate-hUqjWN63.js","./escalation-columns-DJbfsH_m.js","./EntityTimelinePanel-Du1O6Oly.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-iAG28fzG.js","./OperatorDashboard-B4_OBhYh.js","./index-CjjRxpVe.js","./ResolverForm-BaSvhLoT.js","./RosterWidget-DG6Rcx4P.js","./metadata-display-B7X5hGxG.js","./WorkflowsOverview-018s2q_p.js","./index-DMKLnxt8.js","./NamespacePill-OTZD2hzt.js","./WorkflowsDashboard-BKxhC_hT.js","./YamlWorkflowsPage-aVcNZNu6.js","./GraphInvokePage-CcDFhY53.js","./YamlWorkflowDetailPage-C2zcXDr1.js","./TasksListPage-DHBSUhZC.js","./TaskDetailPage-m8CQFN4w.js","./WorkflowExecutionPage-BUqIhtcr.js","./AdminDashboard-DRE0hSDS.js","./index-DIU89TX3.js","./TaskQueuePill-D-4Ynf3K.js","./index-CXXc9sUr.js","./ConfirmDeleteModal-3RFyWN9Q.js","./index-BhS9XSy8.js","./ToolTestPanel-Bg0ss9oN.js","./index-3HaFP00M.js","./index-CyL-6CAa.js","./personas-kE4PMrgo.js","./ScopeBadge-BXZ084nD.js","./RolesPage-T2hH_MV5.js","./RoleDetailPage-D_30TDVh.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage-6HsOp-1y.js","./PersonaDetailPage-BAYjM9qf.js","./EscalationSchemaPage-Co59lcuD.js","./PortalPage-6OMr7KtJ.js","./EscalationListSchemaPage-CrpBhC0e.js","./ScanCodesPage-lB_WxoZw.js","./GrantScopeField-BzWGzBfA.js","./ScanSchemeDetailPage-C3VLg61H.js","./ScanStationPage-CVET1_4r.js","./index-BuSUevzO.js","./OperationsPage-BtnthZgj.js","./index-BFxHIfQ_.js","./index-DhKGp4QK.js","./CredentialsPage-DoFwNvFv.js","./ConnectedAppsPage-B0D2OvTD.js","./index-DeyA88jq.js","./DropZone-Cl_Flb16.js","./index-CeeSFnl-.js","./knowledge-BWo3OCJc.js","./LinesPage-BXZVO4MC.js","./machines-LEYY_yar.js","./LinePage-DKwhGunp.js","./HomePage-Xahqcdu9.js","./AgentsPage-C4ZxCNxt.js","./agents-DRaaJUue.js","./AgentDetailPage-BiL9FB7i.js","./CronLabel-C1Bb2wo4.js","./AgentConfigPage-BuflQGgy.js","./capabilities-BoRWifSC.js","./topics-oHX4vbqe.js","./CapabilitiesPage-DmbC1pEs.js","./TopicsPage-BqZaVv3d.js","./TopicDetailPage-DhPiCfOO.js"])))=>i.map(i=>d[i]);
2
- var oS=Object.defineProperty;var lS=(n,e,s)=>e in n?oS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var j=(n,e,s)=>lS(n,typeof e!="symbol"?e+"":e,s);import{r as cS,u as qe,a as E,j as h,b as Pe,c as $e,g as uS,d as fS,Q as hS,e as dS}from"./vendor-query-DvWWuNIB.js";import{r as mS,u as ni,a as en,b as sm,L as ar,N as Os,c as cn,O as vs,d as pS,R as yS}from"./vendor-react-_9U4mKFr.js";import{X as Zt,E as gS,S as bS,M as xS,a as Mo,C as im,b as vS,B as _S,c as wS,d as cx,e as gd,I as bd,U as SS,L as xd,f as ES,G as OS,T as AS,F as jS,R as ux,g as kS,Z as NS,P as Mg,h as fx,i as TS,j as Rg,k as vd,l as Dg,m as CS,W as am,n as MS,o as RS,p as DS,q as hx,r as LS,D as qS,N as PS,s as BS,t as dx,u as mx,v as px,w as US,x as zS,y as IS,z as $S,A as HS,H as FS,J as GS,K as VS,O as YS}from"./vendor-icons-fxBvvHBi.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const m of c.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();var Jh={exports:{}},ro={},Qh={exports:{}},Xh={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProcessesListPage-CD5NRIBK.js","./vendor-query-DvWWuNIB.js","./tasks-BE97GrLr.js","./useFilterParams-DBRw1Hcv.js","./vendor-react-_9U4mKFr.js","./useDebouncedValue-BLGuHd_v.js","./api-path-u2Jf9QXS.js","./DataTable-FjFhx0SE.js","./EmptyState-DgC_6njU.js","./useContainerWidth-DSLp1gEm.js","./TimestampCell-Dn5M-Eey.js","./StickyPagination-DX5CPgrX.js","./FilterBar-22FDO0R_.js","./vendor-icons-en0_uSRD.js","./PageHeader-DiGWAQlR.js","./ListToolbar-6siR0Hao.js","./WorkflowPill-CKHip3hH.js","./ProcessDetailPage-DBj4VEnP.js","./PageHeaderWithStats-DwnKQ06j.js","./StatusBadge-DHVwxre2.js","./RolePill-D3hkAdKf.js","./UserName-t3PbLYfd.js","./McpOverview-Cbu2CXlQ.js","./mcp-dCLNwcC8.js","./pipelines-ClUmuwmY.js","./yaml-workflows-CnMKmznF.js","./controlplane-D82a5cfq.js","./StatCard-nWY4sndl.js","./McpRunsPage-Df4yOclO.js","./useNamespace-Cj7t8eQd.js","./ElapsedCell-V27Y2Ksb.js","./RowActions-Bdd7z4eB.js","./McpRunDetailPage-BDCv-c1o.js","./SegmentedTabs-BpJh4Hwn.js","./EventTable-BvNxHKy1.js","./SwimlaneTimeline-C_pIcWBJ.js","./StreamMessageDetail-3mWw3_M5.js","./CopyableId-Bn02zYxt.js","./McpQueryPage-CPUUMIiY.js","./mcp-query-wmbaGRYi.js","./McpQueryDetailPage--1FsnGuM.js","./TagInput-DaIdhv3h.js","./CollapsibleSection-QAXKTYc6.js","./useYamlActivityEvents-C7eurSkD.js","./helpers-DzO-OGPe.js","./RunAsSelector-Br9FiMwP.js","./BotPicker-DPglulL6.js","./bots-qx7qPwFo.js","./ToolPill-CpBAFdEX.js","./TimeAgo-DIziYk-v.js","./EscalationsOverview-C2nc-Pgv.js","./AvailableEscalationsPage-DXpRnOVd.js","./task-queues-7-sHKPsN.js","./BulkAssignModal-DWNR3FJJ.js","./constants-CeBBTzf5.js","./EscalationTitleSelect-BhsflGiC.js","./EscalationTimeline-DGNgcMm0.js","./escalation-items-C3ko1DCb.js","./validate-BypZfZ8R.js","./escalation-columns-Dmm8LY_f.js","./EntityTimelinePanel-BA4MWXkB.js","./PriorityBadge-r33mpDju.js","./CountdownTimer-C4hP64lF.js","./OperatorDashboard-Dd1EhTZe.js","./index-C_-FoMo9.js","./ResolverForm-Baxwv_IG.js","./RosterWidget-BPBPSa1k.js","./metadata-display-B7X5hGxG.js","./WorkflowsOverview-Wz6RzxHJ.js","./index-CXnmU0TS.js","./NamespacePill-CeSfHH-j.js","./WorkflowsDashboard-DLb71Sa2.js","./YamlWorkflowsPage-B4C9fiYU.js","./GraphInvokePage-BAyfJ-PY.js","./YamlWorkflowDetailPage-CcRAN_ey.js","./TasksListPage-MtawUpuU.js","./TaskDetailPage-DthMVBZO.js","./WorkflowExecutionPage-CZ2c5QLL.js","./AdminDashboard-Bjf_7-S6.js","./index-C59ZyWOo.js","./TaskQueuePill-sUA1nZe-.js","./index-BVxqddYr.js","./ConfirmDeleteModal-J9xc_gVZ.js","./index-U5gC9Xgq.js","./ToolTestPanel-DaBrgPML.js","./index-D-vNL8Hm.js","./index-CNDnGdvT.js","./personas-B_cJA5UG.js","./ScopeBadge-DGz79rmG.js","./RolesPage-DRs2XeSd.js","./RoleDetailPage-6ukNyycs.js","./AutoGrowTextarea-7X3T9La8.js","./PersonasPage--Ez0YeHh.js","./PersonaDetailPage-BCx3Ey2_.js","./EscalationSchemaPage-Cen9HGYG.js","./PortalPage-BmBmheBp.js","./EscalationListSchemaPage-B20HUAlO.js","./ScanCodesPage-BXENWoZb.js","./GrantScopeField-BzWGzBfA.js","./ScanSchemeDetailPage-CaM4rUBV.js","./ScanStationPage-CmJKgWy_.js","./index-BAxEeqfF.js","./OperationsPage-BYUGFgPp.js","./index-DOkHnsLK.js","./index-BCSeHOZH.js","./CredentialsPage-DUfgsEbI.js","./ConnectedAppsPage-BKhsc_jJ.js","./index-BJrsQM-E.js","./DropZone-DefYTYQy.js","./index-f4-pKYcm.js","./knowledge-i7_nXSbf.js","./LinesPage-BCSfYkuL.js","./machines-DfSNshLg.js","./LinePage-DPe-vP3-.js","./HomePage-CtjG2kGn.js","./AgentsPage-CohqxaWS.js","./agents-BvRjwrof.js","./AgentDetailPage-C52Oi1_f.js","./CronLabel-CBc3Tvau.js","./AgentConfigPage-CEGk5Gbv.js","./capabilities-DJrUEeew.js","./topics-Dk0Y3kZP.js","./CapabilitiesPage-ChBBD0IX.js","./TopicsPage-Cj0ugdie.js","./TopicDetailPage-zNE3EigP.js"])))=>i.map(i=>d[i]);
2
+ var oS=Object.defineProperty;var lS=(n,e,s)=>e in n?oS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var j=(n,e,s)=>lS(n,typeof e!="symbol"?e+"":e,s);import{r as cS,u as Le,a as E,j as h,b as qe,c as Ie,g as uS,d as fS,Q as hS,e as dS}from"./vendor-query-DvWWuNIB.js";import{r as mS,u as ni,a as tn,b as sm,L as ar,N as Os,c as un,O as vs,d as pS,R as yS}from"./vendor-react-_9U4mKFr.js";import{X as en,E as gS,S as bS,M as xS,a as Mo,C as im,b as vS,B as _S,c as wS,d as cx,e as gd,I as bd,U as SS,L as xd,f as ES,G as OS,T as AS,F as jS,R as ux,g as kS,Z as NS,P as Mg,h as fx,i as TS,j as Rg,k as vd,l as Dg,m as CS,W as am,n as MS,o as RS,p as DS,q as hx,r as LS,D as qS,N as PS,s as BS,t as dx,u as mx,v as px,w as US,x as zS,y as IS,z as $S,A as HS,H as FS,J as GS,K as VS,O as YS}from"./vendor-icons-en0_uSRD.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const m of c.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();var Jh={exports:{}},so={},Qh={exports:{}},Xh={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -7,7 +7,7 @@ var oS=Object.defineProperty;var lS=(n,e,s)=>e in n?oS(n,e,{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 Lg;function KS(){return Lg||(Lg=1,(function(n){function e(H,J){var le=H.length;H.push(J);e:for(;0<le;){var pe=le-1>>>1,ye=H[pe];if(0<o(ye,J))H[pe]=J,H[le]=ye,le=pe;else break e}}function s(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var J=H[0],le=H.pop();if(le!==J){H[0]=le;e:for(var pe=0,ye=H.length,Ce=ye>>>1;pe<Ce;){var Ne=2*(pe+1)-1,Me=H[Ne],We=Ne+1,pt=H[We];if(0>o(Me,le))We<ye&&0>o(pt,Me)?(H[pe]=pt,H[We]=le,pe=We):(H[pe]=Me,H[Ne]=le,pe=Ne);else if(We<ye&&0>o(pt,le))H[pe]=pt,H[We]=le,pe=We;else break e}}return J}function o(H,J){var le=H.sortIndex-J.sortIndex;return le!==0?le:H.id-J.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var m=Date,p=m.now();n.unstable_now=function(){return m.now()-p}}var g=[],u=[],d=1,b=null,x=3,v=!1,_=!1,S=!1,C=!1,B=typeof setTimeout=="function"?setTimeout:null,q=typeof clearTimeout=="function"?clearTimeout:null,ne=typeof setImmediate<"u"?setImmediate:null;function te(H){for(var J=s(u);J!==null;){if(J.callback===null)i(u);else if(J.startTime<=H)i(u),J.sortIndex=J.expirationTime,e(g,J);else break;J=s(u)}}function M(H){if(S=!1,te(H),!_)if(s(g)!==null)_=!0,z||(z=!0,W());else{var J=s(u);J!==null&&Ae(M,J.startTime-H)}}var z=!1,ae=-1,F=5,U=-1;function D(){return C?!0:!(n.unstable_now()-U<F)}function X(){if(C=!1,z){var H=n.unstable_now();U=H;var J=!0;try{e:{_=!1,S&&(S=!1,q(ae),ae=-1),v=!0;var le=x;try{t:{for(te(H),b=s(g);b!==null&&!(b.expirationTime>H&&D());){var pe=b.callback;if(typeof pe=="function"){b.callback=null,x=b.priorityLevel;var ye=pe(b.expirationTime<=H);if(H=n.unstable_now(),typeof ye=="function"){b.callback=ye,te(H),J=!0;break t}b===s(g)&&i(g),te(H)}else i(g);b=s(g)}if(b!==null)J=!0;else{var Ce=s(u);Ce!==null&&Ae(M,Ce.startTime-H),J=!1}}break e}finally{b=null,x=le,v=!1}J=void 0}}finally{J?W():z=!1}}}var W;if(typeof ne=="function")W=function(){ne(X)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,Se=he.port2;he.port1.onmessage=X,W=function(){Se.postMessage(null)}}else W=function(){B(X,0)};function Ae(H,J){ae=B(function(){H(n.unstable_now())},J)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(H){H.callback=null},n.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<H?Math.floor(1e3/H):5},n.unstable_getCurrentPriorityLevel=function(){return x},n.unstable_next=function(H){switch(x){case 1:case 2:case 3:var J=3;break;default:J=x}var le=x;x=J;try{return H()}finally{x=le}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function(H,J){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var le=x;x=H;try{return J()}finally{x=le}},n.unstable_scheduleCallback=function(H,J,le){var pe=n.unstable_now();switch(typeof le=="object"&&le!==null?(le=le.delay,le=typeof le=="number"&&0<le?pe+le:pe):le=pe,H){case 1:var ye=-1;break;case 2:ye=250;break;case 5:ye=1073741823;break;case 4:ye=1e4;break;default:ye=5e3}return ye=le+ye,H={id:d++,callback:J,priorityLevel:H,startTime:le,expirationTime:ye,sortIndex:-1},le>pe?(H.sortIndex=le,e(u,H),s(g)===null&&H===s(u)&&(S?(q(ae),ae=-1):S=!0,Ae(M,le-pe))):(H.sortIndex=ye,e(g,H),_||v||(_=!0,z||(z=!0,W()))),H},n.unstable_shouldYield=D,n.unstable_wrapCallback=function(H){var J=x;return function(){var le=x;x=J;try{return H.apply(this,arguments)}finally{x=le}}}})(Xh)),Xh}var qg;function JS(){return qg||(qg=1,Qh.exports=KS()),Qh.exports}/**
10
+ */var Lg;function KS(){return Lg||(Lg=1,(function(n){function e(H,J){var ce=H.length;H.push(J);e:for(;0<ce;){var pe=ce-1>>>1,ge=H[pe];if(0<o(ge,J))H[pe]=J,H[ce]=ge,ce=pe;else break e}}function s(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var J=H[0],ce=H.pop();if(ce!==J){H[0]=ce;e:for(var pe=0,ge=H.length,Ce=ge>>>1;pe<Ce;){var Ne=2*(pe+1)-1,Me=H[Ne],Xe=Ne+1,pt=H[Xe];if(0>o(Me,ce))Xe<ge&&0>o(pt,Me)?(H[pe]=pt,H[Xe]=ce,pe=Xe):(H[pe]=Me,H[Ne]=ce,pe=Ne);else if(Xe<ge&&0>o(pt,ce))H[pe]=pt,H[Xe]=ce,pe=Xe;else break e}}return J}function o(H,J){var ce=H.sortIndex-J.sortIndex;return ce!==0?ce:H.id-J.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var m=Date,p=m.now();n.unstable_now=function(){return m.now()-p}}var g=[],u=[],d=1,b=null,x=3,v=!1,_=!1,S=!1,C=!1,B=typeof setTimeout=="function"?setTimeout:null,q=typeof clearTimeout=="function"?clearTimeout:null,ne=typeof setImmediate<"u"?setImmediate:null;function te(H){for(var J=s(u);J!==null;){if(J.callback===null)i(u);else if(J.startTime<=H)i(u),J.sortIndex=J.expirationTime,e(g,J);else break;J=s(u)}}function M(H){if(S=!1,te(H),!_)if(s(g)!==null)_=!0,z||(z=!0,W());else{var J=s(u);J!==null&&Ae(M,J.startTime-H)}}var z=!1,ae=-1,F=5,U=-1;function D(){return C?!0:!(n.unstable_now()-U<F)}function Q(){if(C=!1,z){var H=n.unstable_now();U=H;var J=!0;try{e:{_=!1,S&&(S=!1,q(ae),ae=-1),v=!0;var ce=x;try{t:{for(te(H),b=s(g);b!==null&&!(b.expirationTime>H&&D());){var pe=b.callback;if(typeof pe=="function"){b.callback=null,x=b.priorityLevel;var ge=pe(b.expirationTime<=H);if(H=n.unstable_now(),typeof ge=="function"){b.callback=ge,te(H),J=!0;break t}b===s(g)&&i(g),te(H)}else i(g);b=s(g)}if(b!==null)J=!0;else{var Ce=s(u);Ce!==null&&Ae(M,Ce.startTime-H),J=!1}}break e}finally{b=null,x=ce,v=!1}J=void 0}}finally{J?W():z=!1}}}var W;if(typeof ne=="function")W=function(){ne(Q)};else if(typeof MessageChannel<"u"){var he=new MessageChannel,Ee=he.port2;he.port1.onmessage=Q,W=function(){Ee.postMessage(null)}}else W=function(){B(Q,0)};function Ae(H,J){ae=B(function(){H(n.unstable_now())},J)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(H){H.callback=null},n.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<H?Math.floor(1e3/H):5},n.unstable_getCurrentPriorityLevel=function(){return x},n.unstable_next=function(H){switch(x){case 1:case 2:case 3:var J=3;break;default:J=x}var ce=x;x=J;try{return H()}finally{x=ce}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function(H,J){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var ce=x;x=H;try{return J()}finally{x=ce}},n.unstable_scheduleCallback=function(H,J,ce){var pe=n.unstable_now();switch(typeof ce=="object"&&ce!==null?(ce=ce.delay,ce=typeof ce=="number"&&0<ce?pe+ce:pe):ce=pe,H){case 1:var ge=-1;break;case 2:ge=250;break;case 5:ge=1073741823;break;case 4:ge=1e4;break;default:ge=5e3}return ge=ce+ge,H={id:d++,callback:J,priorityLevel:H,startTime:ce,expirationTime:ge,sortIndex:-1},ce>pe?(H.sortIndex=ce,e(u,H),s(g)===null&&H===s(u)&&(S?(q(ae),ae=-1):S=!0,Ae(M,ce-pe))):(H.sortIndex=ge,e(g,H),_||v||(_=!0,z||(z=!0,W()))),H},n.unstable_shouldYield=D,n.unstable_wrapCallback=function(H){var J=x;return function(){var ce=x;x=J;try{return H.apply(this,arguments)}finally{x=ce}}}})(Xh)),Xh}var qg;function JS(){return qg||(qg=1,Qh.exports=KS()),Qh.exports}/**
11
11
  * @license React
12
12
  * react-dom-client.production.js
13
13
  *
@@ -15,28 +15,28 @@ var oS=Object.defineProperty;var lS=(n,e,s)=>e in n?oS(n,e,{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 Pg;function QS(){if(Pg)return ro;Pg=1;var n=JS(),e=cS(),s=mS();function i(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function c(t){var r=t,a=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(a=r.return),t=r.return;while(t)}return r.tag===3?a:null}function m(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function p(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function g(t){if(c(t)!==t)throw Error(i(188))}function u(t){var r=t.alternate;if(!r){if(r=c(t),r===null)throw Error(i(188));return r!==t?null:t}for(var a=t,l=r;;){var f=a.return;if(f===null)break;var y=f.alternate;if(y===null){if(l=f.return,l!==null){a=l;continue}break}if(f.child===y.child){for(y=f.child;y;){if(y===a)return g(f),t;if(y===l)return g(f),r;y=y.sibling}throw Error(i(188))}if(a.return!==l.return)a=f,l=y;else{for(var w=!1,O=f.child;O;){if(O===a){w=!0,a=f,l=y;break}if(O===l){w=!0,l=f,a=y;break}O=O.sibling}if(!w){for(O=y.child;O;){if(O===a){w=!0,a=y,l=f;break}if(O===l){w=!0,l=y,a=f;break}O=O.sibling}if(!w)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?t:r}function d(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=d(t),r!==null)return r;t=t.sibling}return null}var b=Object.assign,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),ne=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),X=Symbol.iterator;function W(t){return t===null||typeof t!="object"?null:(t=X&&t[X]||t["@@iterator"],typeof t=="function"?t:null)}var he=Symbol.for("react.client.reference");function Se(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===he?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case S:return"Fragment";case B:return"Profiler";case C:return"StrictMode";case M:return"Suspense";case z:return"SuspenseList";case U:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case _:return"Portal";case ne:return t.displayName||"Context";case q:return(t._context.displayName||"Context")+".Consumer";case te:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ae:return r=t.displayName||null,r!==null?r:Se(t.type)||"Memo";case F:r=t._payload,t=t._init;try{return Se(t(r))}catch{}}return null}var Ae=Array.isArray,H=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},pe=[],ye=-1;function Ce(t){return{current:t}}function Ne(t){0>ye||(t.current=pe[ye],pe[ye]=null,ye--)}function Me(t,r){ye++,pe[ye]=t.current,t.current=r}var We=Ce(null),pt=Ce(null),Ct=Ce(null),Ee=Ce(null);function Re(t,r){switch(Me(Ct,r),Me(pt,t),Me(We,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?tg(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=tg(r),t=ng(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Ne(We),Me(We,t)}function ce(){Ne(We),Ne(pt),Ne(Ct)}function Ue(t){t.memoizedState!==null&&Me(Ee,t);var r=We.current,a=ng(r,t.type);r!==a&&(Me(pt,t),Me(We,a))}function Xe(t){pt.current===t&&(Ne(We),Ne(pt)),Ee.current===t&&(Ne(Ee),Za._currentValue=le)}var un,Mt;function be(t){if(un===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);un=r&&r[1]||"",Mt=-1<a.stack.indexOf(`
18
+ */var Pg;function QS(){if(Pg)return so;Pg=1;var n=JS(),e=cS(),s=mS();function i(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function c(t){var r=t,a=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(a=r.return),t=r.return;while(t)}return r.tag===3?a:null}function m(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function p(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function g(t){if(c(t)!==t)throw Error(i(188))}function u(t){var r=t.alternate;if(!r){if(r=c(t),r===null)throw Error(i(188));return r!==t?null:t}for(var a=t,l=r;;){var f=a.return;if(f===null)break;var y=f.alternate;if(y===null){if(l=f.return,l!==null){a=l;continue}break}if(f.child===y.child){for(y=f.child;y;){if(y===a)return g(f),t;if(y===l)return g(f),r;y=y.sibling}throw Error(i(188))}if(a.return!==l.return)a=f,l=y;else{for(var w=!1,O=f.child;O;){if(O===a){w=!0,a=f,l=y;break}if(O===l){w=!0,l=f,a=y;break}O=O.sibling}if(!w){for(O=y.child;O;){if(O===a){w=!0,a=y,l=f;break}if(O===l){w=!0,l=y,a=f;break}O=O.sibling}if(!w)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?t:r}function d(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=d(t),r!==null)return r;t=t.sibling}return null}var b=Object.assign,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),ne=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),Q=Symbol.iterator;function W(t){return t===null||typeof t!="object"?null:(t=Q&&t[Q]||t["@@iterator"],typeof t=="function"?t:null)}var he=Symbol.for("react.client.reference");function Ee(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===he?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case S:return"Fragment";case B:return"Profiler";case C:return"StrictMode";case M:return"Suspense";case z:return"SuspenseList";case U:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case _:return"Portal";case ne:return t.displayName||"Context";case q:return(t._context.displayName||"Context")+".Consumer";case te:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ae:return r=t.displayName||null,r!==null?r:Ee(t.type)||"Memo";case F:r=t._payload,t=t._init;try{return Ee(t(r))}catch{}}return null}var Ae=Array.isArray,H=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce={pending:!1,data:null,method:null,action:null},pe=[],ge=-1;function Ce(t){return{current:t}}function Ne(t){0>ge||(t.current=pe[ge],pe[ge]=null,ge--)}function Me(t,r){ge++,pe[ge]=t.current,t.current=r}var Xe=Ce(null),pt=Ce(null),Ot=Ce(null),mt=Ce(null);function _e(t,r){switch(Me(Ot,r),Me(pt,t),Me(Xe,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?tg(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=tg(r),t=ng(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Ne(Xe),Me(Xe,t)}function le(){Ne(Xe),Ne(pt),Ne(Ot)}function Pe(t){t.memoizedState!==null&&Me(mt,t);var r=Xe.current,a=ng(r,t.type);r!==a&&(Me(pt,t),Me(Xe,a))}function zt(t){pt.current===t&&(Ne(Xe),Ne(pt)),mt.current===t&&(Ne(mt),eo._currentValue=ce)}var qt,at;function ye(t){if(qt===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);qt=r&&r[1]||"",at=-1<a.stack.indexOf(`
19
19
  at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
20
- `+un+t+Mt}var it=!1;function yt(t,r){if(!t||it)return"";it=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(r){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(Q){var Y=Q}Reflect.construct(t,[],ie)}else{try{ie.call()}catch(Q){Y=Q}t.call(ie.prototype)}}else{try{throw Error()}catch(Q){Y=Q}(ie=t())&&typeof ie.catch=="function"&&ie.catch(function(){})}}catch(Q){if(Q&&Y&&typeof Q.stack=="string")return[Q.stack,Y.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=l.DetermineComponentFrameRoot(),w=y[0],O=y[1];if(w&&O){var R=w.split(`
20
+ `+qt+t+at}var Ye=!1;function yt(t,r){if(!t||Ye)return"";Ye=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(r){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(X){var Y=X}Reflect.construct(t,[],ie)}else{try{ie.call()}catch(X){Y=X}t.call(ie.prototype)}}else{try{throw Error()}catch(X){Y=X}(ie=t())&&typeof ie.catch=="function"&&ie.catch(function(){})}}catch(X){if(X&&Y&&typeof X.stack=="string")return[X.stack,Y.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=l.DetermineComponentFrameRoot(),w=y[0],O=y[1];if(w&&O){var R=w.split(`
21
21
  `),V=O.split(`
22
22
  `);for(f=l=0;l<R.length&&!R[l].includes("DetermineComponentFrameRoot");)l++;for(;f<V.length&&!V[f].includes("DetermineComponentFrameRoot");)f++;if(l===R.length||f===V.length)for(l=R.length-1,f=V.length-1;1<=l&&0<=f&&R[l]!==V[f];)f--;for(;1<=l&&0<=f;l--,f--)if(R[l]!==V[f]){if(l!==1||f!==1)do if(l--,f--,0>f||R[l]!==V[f]){var Z=`
23
- `+R[l].replace(" at new "," at ");return t.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",t.displayName)),Z}while(1<=l&&0<=f);break}}}finally{it=!1,Error.prepareStackTrace=a}return(a=t?t.displayName||t.name:"")?be(a):""}function Ot(t,r){switch(t.tag){case 26:case 27:case 5:return be(t.type);case 16:return be("Lazy");case 13:return t.child!==r&&r!==null?be("Suspense Fallback"):be("Suspense");case 19:return be("SuspenseList");case 0:case 15:return yt(t.type,!1);case 11:return yt(t.type.render,!1);case 1:return yt(t.type,!0);case 31:return be("Activity");default:return""}}function Ur(t){try{var r="",a=null;do r+=Ot(t,a),a=t,t=t.return;while(t);return r}catch(l){return`
23
+ `+R[l].replace(" at new "," at ");return t.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",t.displayName)),Z}while(1<=l&&0<=f);break}}}finally{Ye=!1,Error.prepareStackTrace=a}return(a=t?t.displayName||t.name:"")?ye(a):""}function At(t,r){switch(t.tag){case 26:case 27:case 5:return ye(t.type);case 16:return ye("Lazy");case 13:return t.child!==r&&r!==null?ye("Suspense Fallback"):ye("Suspense");case 19:return ye("SuspenseList");case 0:case 15:return yt(t.type,!1);case 11:return yt(t.type.render,!1);case 1:return yt(t.type,!0);case 31:return ye("Activity");default:return""}}function Ur(t){try{var r="",a=null;do r+=At(t,a),a=t,t=t.return;while(t);return r}catch(l){return`
24
24
  Error generating stack: `+l.message+`
25
- `+l.stack}}var ca=Object.prototype.hasOwnProperty,ua=n.unstable_scheduleCallback,hr=n.unstable_cancelCallback,zo=n.unstable_shouldYield,si=n.unstable_requestPaint,ft=n.unstable_now,Bu=n.unstable_getCurrentPriorityLevel,Io=n.unstable_ImmediatePriority,$o=n.unstable_UserBlockingPriority,ii=n.unstable_NormalPriority,Uu=n.unstable_LowPriority,Ho=n.unstable_IdlePriority,zu=n.log,Fo=n.unstable_setDisableYieldValue,Ns=null,_t=null;function fn(t){if(typeof zu=="function"&&Fo(t),_t&&typeof _t.setStrictMode=="function")try{_t.setStrictMode(Ns,t)}catch{}}var Ft=Math.clz32?Math.clz32:ai,fa=Math.log,ha=Math.LN2;function ai(t){return t>>>=0,t===0?32:31-(fa(t)/ha|0)|0}var zr=256,dr=262144,Ir=4194304;function Fn(t){var r=t&42;if(r!==0)return r;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ts(t,r,a){var l=t.pendingLanes;if(l===0)return 0;var f=0,y=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var O=l&134217727;return O!==0?(l=O&~y,l!==0?f=Fn(l):(w&=O,w!==0?f=Fn(w):a||(a=O&~t,a!==0&&(f=Fn(a))))):(O=l&~y,O!==0?f=Fn(O):w!==0?f=Fn(w):a||(a=l&~t,a!==0&&(f=Fn(a)))),f===0?0:r!==0&&r!==f&&(r&y)===0&&(y=f&-f,a=r&-r,y>=a||y===32&&(a&4194048)!==0)?r:f}function Cs(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function da(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function oi(){var t=Ir;return Ir<<=1,(Ir&62914560)===0&&(Ir=4194304),t}function $r(t){for(var r=[],a=0;31>a;a++)r.push(t);return r}function Gn(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Hr(t,r,a,l,f,y){var w=t.pendingLanes;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=a,t.entangledLanes&=a,t.errorRecoveryDisabledLanes&=a,t.shellSuspendCounter=0;var O=t.entanglements,R=t.expirationTimes,V=t.hiddenUpdates;for(a=w&~a;0<a;){var Z=31-Ft(a),ie=1<<Z;O[Z]=0,R[Z]=-1;var Y=V[Z];if(Y!==null)for(V[Z]=null,Z=0;Z<Y.length;Z++){var Q=Y[Z];Q!==null&&(Q.lane&=-536870913)}a&=~ie}l!==0&&Fr(t,l,0),y!==0&&f===0&&t.tag!==0&&(t.suspendedLanes|=y&~(w&~r))}function Fr(t,r,a){t.pendingLanes|=r,t.suspendedLanes&=~r;var l=31-Ft(r);t.entangledLanes|=r,t.entanglements[l]=t.entanglements[l]|1073741824|a&261930}function Ms(t,r){var a=t.entangledLanes|=r;for(t=t.entanglements;a;){var l=31-Ft(a),f=1<<l;f&r|t[l]&r&&(t[l]|=r),a&=~f}}function Gr(t,r){var a=r&-r;return a=(a&42)!==0?1:mr(a),(a&(t.suspendedLanes|r))!==0?0:a}function mr(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Rs(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function ma(){var t=J.p;return t!==0?t:(t=window.event,t===void 0?32:Og(t.type))}function Go(t,r){var a=J.p;try{return J.p=t,r()}finally{J.p=a}}var tr=Math.random().toString(36).slice(2),at="__reactFiber$"+tr,gt="__reactProps$"+tr,hn="__reactContainer$"+tr,Ds="__reactEvents$"+tr,pa="__reactListeners$"+tr,Vo="__reactHandles$"+tr,Yo="__reactResources$"+tr,Rt="__reactMarker$"+tr;function li(t){delete t[at],delete t[gt],delete t[Ds],delete t[pa],delete t[Vo]}function A(t){var r=t[at];if(r)return r;for(var a=t.parentNode;a;){if(r=a[hn]||a[at]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(t=cg(t);t!==null;){if(a=t[at])return a;t=cg(t)}return r}t=a,a=t.parentNode}return null}function N(t){if(t=t[at]||t[hn]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function k(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function T(t){var r=t[Yo];return r||(r=t[Yo]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function L(t){t[Rt]=!0}var $=new Set,se={};function oe(t,r){K(t,r),K(t+"Capture",r)}function K(t,r){for(se[t]=r,t=0;t<r.length;t++)$.add(r[t])}var re=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]*$"),xe={},Be={};function lt(t){return ca.call(Be,t)?!0:ca.call(xe,t)?!1:re.test(t)?Be[t]=!0:(xe[t]=!0,!1)}function Gt(t,r,a){if(lt(r))if(a===null)t.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":t.removeAttribute(r);return;case"boolean":var l=r.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){t.removeAttribute(r);return}}t.setAttribute(r,""+a)}}function Vn(t,r,a){if(a===null)t.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttribute(r,""+a)}}function pr(t,r,a,l){if(l===null)t.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttributeNS(r,a,""+l)}}function Tn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ym(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function e_(t,r,a){var l=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,y=l.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return f.call(this)},set:function(w){a=""+w,y.call(this,w)}}),Object.defineProperty(t,r,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(w){a=""+w},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Iu(t){if(!t._valueTracker){var r=Ym(t)?"checked":"value";t._valueTracker=e_(t,r,""+t[r])}}function Km(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return t&&(l=Ym(t)?t.checked?"true":"false":t.value),t=l,t!==a?(r.setValue(t),!0):!1}function Ko(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var t_=/[\n"\\]/g;function Cn(t){return t.replace(t_,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function $u(t,r,a,l,f,y,w,O){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),r!=null?w==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+Tn(r)):t.value!==""+Tn(r)&&(t.value=""+Tn(r)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),r!=null?Hu(t,w,Tn(r)):a!=null?Hu(t,w,Tn(a)):l!=null&&t.removeAttribute("value"),f==null&&y!=null&&(t.defaultChecked=!!y),f!=null&&(t.checked=f&&typeof f!="function"&&typeof f!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?t.name=""+Tn(O):t.removeAttribute("name")}function Jm(t,r,a,l,f,y,w,O){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.type=y),r!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||r!=null)){Iu(t);return}a=a!=null?""+Tn(a):"",r=r!=null?""+Tn(r):a,O||r===t.value||(t.value=r),t.defaultValue=r}l=l??f,l=typeof l!="function"&&typeof l!="symbol"&&!!l,t.checked=O?t.checked:!!l,t.defaultChecked=!!l,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),Iu(t)}function Hu(t,r,a){r==="number"&&Ko(t.ownerDocument)===t||t.defaultValue===""+a||(t.defaultValue=""+a)}function ci(t,r,a,l){if(t=t.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<t.length;a++)f=r.hasOwnProperty("$"+t[a].value),t[a].selected!==f&&(t[a].selected=f),f&&l&&(t[a].defaultSelected=!0)}else{for(a=""+Tn(a),r=null,f=0;f<t.length;f++){if(t[f].value===a){t[f].selected=!0,l&&(t[f].defaultSelected=!0);return}r!==null||t[f].disabled||(r=t[f])}r!==null&&(r.selected=!0)}}function Qm(t,r,a){if(r!=null&&(r=""+Tn(r),r!==t.value&&(t.value=r),a==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=a!=null?""+Tn(a):""}function Xm(t,r,a,l){if(r==null){if(l!=null){if(a!=null)throw Error(i(92));if(Ae(l)){if(1<l.length)throw Error(i(93));l=l[0]}a=l}a==null&&(a=""),r=a}a=Tn(r),t.defaultValue=a,l=t.textContent,l===a&&l!==""&&l!==null&&(t.value=l),Iu(t)}function ui(t,r){if(r){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=r;return}}t.textContent=r}var n_=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 Wm(t,r,a){var l=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="":l?t.setProperty(r,a):typeof a!="number"||a===0||n_.has(r)?r==="float"?t.cssFloat=a:t[r]=(""+a).trim():t[r]=a+"px"}function Zm(t,r,a){if(r!=null&&typeof r!="object")throw Error(i(62));if(t=t.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||r!=null&&r.hasOwnProperty(l)||(l.indexOf("--")===0?t.setProperty(l,""):l==="float"?t.cssFloat="":t[l]="");for(var f in r)l=r[f],r.hasOwnProperty(f)&&a[f]!==l&&Wm(t,f,l)}else for(var y in r)r.hasOwnProperty(y)&&Wm(t,y,r[y])}function Fu(t){if(t.indexOf("-")===-1)return!1;switch(t){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 r_=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"]]),s_=/^[\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 Jo(t){return s_.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function yr(){}var Gu=null;function Vu(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var fi=null,hi=null;function e0(t){var r=N(t);if(r&&(t=r.stateNode)){var a=t[gt]||null;e:switch(t=r.stateNode,r.type){case"input":if($u(t,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Cn(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==t&&l.form===t.form){var f=l[gt]||null;if(!f)throw Error(i(90));$u(l,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(r=0;r<a.length;r++)l=a[r],l.form===t.form&&Km(l)}break e;case"textarea":Qm(t,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&ci(t,!!a.multiple,r,!1)}}}var Yu=!1;function t0(t,r,a){if(Yu)return t(r,a);Yu=!0;try{var l=t(r);return l}finally{if(Yu=!1,(fi!==null||hi!==null)&&(ql(),fi&&(r=fi,t=hi,hi=fi=null,e0(r),t)))for(r=0;r<t.length;r++)e0(t[r])}}function ya(t,r){var a=t.stateNode;if(a===null)return null;var l=a[gt]||null;if(l===null)return null;a=l[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(t=t.type,l=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!l;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var gr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ku=!1;if(gr)try{var ga={};Object.defineProperty(ga,"passive",{get:function(){Ku=!0}}),window.addEventListener("test",ga,ga),window.removeEventListener("test",ga,ga)}catch{Ku=!1}var Vr=null,Ju=null,Qo=null;function n0(){if(Qo)return Qo;var t,r=Ju,a=r.length,l,f="value"in Vr?Vr.value:Vr.textContent,y=f.length;for(t=0;t<a&&r[t]===f[t];t++);var w=a-t;for(l=1;l<=w&&r[a-l]===f[y-l];l++);return Qo=f.slice(t,1<l?1-l:void 0)}function Xo(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Wo(){return!0}function r0(){return!1}function nn(t){function r(a,l,f,y,w){this._reactName=a,this._targetInst=f,this.type=l,this.nativeEvent=y,this.target=w,this.currentTarget=null;for(var O in t)t.hasOwnProperty(O)&&(a=t[O],this[O]=a?a(y):y[O]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Wo:r0,this.isPropagationStopped=r0,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Wo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Wo)},persist:function(){},isPersistent:Wo}),r}var Ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zo=nn(Ls),ba=b({},Ls,{view:0,detail:0}),i_=nn(ba),Qu,Xu,xa,el=b({},ba,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zu,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==xa&&(xa&&t.type==="mousemove"?(Qu=t.screenX-xa.screenX,Xu=t.screenY-xa.screenY):Xu=Qu=0,xa=t),Qu)},movementY:function(t){return"movementY"in t?t.movementY:Xu}}),s0=nn(el),a_=b({},el,{dataTransfer:0}),o_=nn(a_),l_=b({},ba,{relatedTarget:0}),Wu=nn(l_),c_=b({},Ls,{animationName:0,elapsedTime:0,pseudoElement:0}),u_=nn(c_),f_=b({},Ls,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),h_=nn(f_),d_=b({},Ls,{data:0}),i0=nn(d_),m_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},p_={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"},y_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function g_(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=y_[t])?!!r[t]:!1}function Zu(){return g_}var b_=b({},ba,{key:function(t){if(t.key){var r=m_[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Xo(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?p_[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zu,charCode:function(t){return t.type==="keypress"?Xo(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Xo(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),x_=nn(b_),v_=b({},el,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),a0=nn(v_),__=b({},ba,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zu}),w_=nn(__),S_=b({},Ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),E_=nn(S_),O_=b({},el,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),A_=nn(O_),j_=b({},Ls,{newState:0,oldState:0}),k_=nn(j_),N_=[9,13,27,32],ef=gr&&"CompositionEvent"in window,va=null;gr&&"documentMode"in document&&(va=document.documentMode);var T_=gr&&"TextEvent"in window&&!va,o0=gr&&(!ef||va&&8<va&&11>=va),l0=" ",c0=!1;function u0(t,r){switch(t){case"keyup":return N_.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function f0(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var di=!1;function C_(t,r){switch(t){case"compositionend":return f0(r);case"keypress":return r.which!==32?null:(c0=!0,l0);case"textInput":return t=r.data,t===l0&&c0?null:t;default:return null}}function M_(t,r){if(di)return t==="compositionend"||!ef&&u0(t,r)?(t=n0(),Qo=Ju=Vr=null,di=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return o0&&r.locale!=="ko"?null:r.data;default:return null}}var R_={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 h0(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!R_[t.type]:r==="textarea"}function d0(t,r,a,l){fi?hi?hi.push(l):hi=[l]:fi=l,r=Hl(r,"onChange"),0<r.length&&(a=new Zo("onChange","change",null,a,l),t.push({event:a,listeners:r}))}var _a=null,wa=null;function D_(t){Jy(t,0)}function tl(t){var r=k(t);if(Km(r))return t}function m0(t,r){if(t==="change")return r}var p0=!1;if(gr){var tf;if(gr){var nf="oninput"in document;if(!nf){var y0=document.createElement("div");y0.setAttribute("oninput","return;"),nf=typeof y0.oninput=="function"}tf=nf}else tf=!1;p0=tf&&(!document.documentMode||9<document.documentMode)}function g0(){_a&&(_a.detachEvent("onpropertychange",b0),wa=_a=null)}function b0(t){if(t.propertyName==="value"&&tl(wa)){var r=[];d0(r,wa,t,Vu(t)),t0(D_,r)}}function L_(t,r,a){t==="focusin"?(g0(),_a=r,wa=a,_a.attachEvent("onpropertychange",b0)):t==="focusout"&&g0()}function q_(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return tl(wa)}function P_(t,r){if(t==="click")return tl(r)}function B_(t,r){if(t==="input"||t==="change")return tl(r)}function U_(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var dn=typeof Object.is=="function"?Object.is:U_;function Sa(t,r){if(dn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var a=Object.keys(t),l=Object.keys(r);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var f=a[l];if(!ca.call(r,f)||!dn(t[f],r[f]))return!1}return!0}function x0(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function v0(t,r){var a=x0(t);t=0;for(var l;a;){if(a.nodeType===3){if(l=t+a.textContent.length,t<=r&&l>=r)return{node:a,offset:r-t};t=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=x0(a)}}function _0(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?_0(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function w0(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Ko(t.document);r instanceof t.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)t=r.contentWindow;else break;r=Ko(t.document)}return r}function rf(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var z_=gr&&"documentMode"in document&&11>=document.documentMode,mi=null,sf=null,Ea=null,af=!1;function S0(t,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;af||mi==null||mi!==Ko(l)||(l=mi,"selectionStart"in l&&rf(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}),Ea&&Sa(Ea,l)||(Ea=l,l=Hl(sf,"onSelect"),0<l.length&&(r=new Zo("onSelect","select",null,r,a),t.push({event:r,listeners:l}),r.target=mi)))}function qs(t,r){var a={};return a[t.toLowerCase()]=r.toLowerCase(),a["Webkit"+t]="webkit"+r,a["Moz"+t]="moz"+r,a}var pi={animationend:qs("Animation","AnimationEnd"),animationiteration:qs("Animation","AnimationIteration"),animationstart:qs("Animation","AnimationStart"),transitionrun:qs("Transition","TransitionRun"),transitionstart:qs("Transition","TransitionStart"),transitioncancel:qs("Transition","TransitionCancel"),transitionend:qs("Transition","TransitionEnd")},of={},E0={};gr&&(E0=document.createElement("div").style,"AnimationEvent"in window||(delete pi.animationend.animation,delete pi.animationiteration.animation,delete pi.animationstart.animation),"TransitionEvent"in window||delete pi.transitionend.transition);function Ps(t){if(of[t])return of[t];if(!pi[t])return t;var r=pi[t],a;for(a in r)if(r.hasOwnProperty(a)&&a in E0)return of[t]=r[a];return t}var O0=Ps("animationend"),A0=Ps("animationiteration"),j0=Ps("animationstart"),I_=Ps("transitionrun"),$_=Ps("transitionstart"),H_=Ps("transitioncancel"),k0=Ps("transitionend"),N0=new Map,lf="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(" ");lf.push("scrollEnd");function Yn(t,r){N0.set(t,r),oe(r,[t])}var nl=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Mn=[],yi=0,cf=0;function rl(){for(var t=yi,r=cf=yi=0;r<t;){var a=Mn[r];Mn[r++]=null;var l=Mn[r];Mn[r++]=null;var f=Mn[r];Mn[r++]=null;var y=Mn[r];if(Mn[r++]=null,l!==null&&f!==null){var w=l.pending;w===null?f.next=f:(f.next=w.next,w.next=f),l.pending=f}y!==0&&T0(a,f,y)}}function sl(t,r,a,l){Mn[yi++]=t,Mn[yi++]=r,Mn[yi++]=a,Mn[yi++]=l,cf|=l,t.lanes|=l,t=t.alternate,t!==null&&(t.lanes|=l)}function uf(t,r,a,l){return sl(t,r,a,l),il(t)}function Bs(t,r){return sl(t,null,null,r),il(t)}function T0(t,r,a){t.lanes|=a;var l=t.alternate;l!==null&&(l.lanes|=a);for(var f=!1,y=t.return;y!==null;)y.childLanes|=a,l=y.alternate,l!==null&&(l.childLanes|=a),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(f=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,f&&r!==null&&(f=31-Ft(a),t=y.hiddenUpdates,l=t[f],l===null?t[f]=[r]:l.push(r),r.lane=a|536870912),y):null}function il(t){if(50<Va)throw Va=0,xh=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var gi={};function F_(t,r,a,l){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mn(t,r,a,l){return new F_(t,r,a,l)}function ff(t){return t=t.prototype,!(!t||!t.isReactComponent)}function br(t,r){var a=t.alternate;return a===null?(a=mn(t.tag,r,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=r,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&65011712,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,r=t.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a.refCleanup=t.refCleanup,a}function C0(t,r){t.flags&=65011714;var a=t.alternate;return a===null?(t.childLanes=0,t.lanes=r,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=a.childLanes,t.lanes=a.lanes,t.child=a.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=a.memoizedProps,t.memoizedState=a.memoizedState,t.updateQueue=a.updateQueue,t.type=a.type,r=a.dependencies,t.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t}function al(t,r,a,l,f,y){var w=0;if(l=t,typeof t=="function")ff(t)&&(w=1);else if(typeof t=="string")w=Jw(t,a,We.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case U:return t=mn(31,a,r,f),t.elementType=U,t.lanes=y,t;case S:return Us(a.children,f,y,r);case C:w=8,f|=24;break;case B:return t=mn(12,a,r,f|2),t.elementType=B,t.lanes=y,t;case M:return t=mn(13,a,r,f),t.elementType=M,t.lanes=y,t;case z:return t=mn(19,a,r,f),t.elementType=z,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ne:w=10;break e;case q:w=9;break e;case te:w=11;break e;case ae:w=14;break e;case F:w=16,l=null;break e}w=29,a=Error(i(130,t===null?"null":typeof t,"")),l=null}return r=mn(w,a,r,f),r.elementType=t,r.type=l,r.lanes=y,r}function Us(t,r,a,l){return t=mn(7,t,l,r),t.lanes=a,t}function hf(t,r,a){return t=mn(6,t,null,r),t.lanes=a,t}function M0(t){var r=mn(18,null,null,0);return r.stateNode=t,r}function df(t,r,a){return r=mn(4,t.children!==null?t.children:[],t.key,r),r.lanes=a,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var R0=new WeakMap;function Rn(t,r){if(typeof t=="object"&&t!==null){var a=R0.get(t);return a!==void 0?a:(r={value:t,source:r,stack:Ur(r)},R0.set(t,r),r)}return{value:t,source:r,stack:Ur(r)}}var bi=[],xi=0,ol=null,Oa=0,Dn=[],Ln=0,Yr=null,nr=1,rr="";function xr(t,r){bi[xi++]=Oa,bi[xi++]=ol,ol=t,Oa=r}function D0(t,r,a){Dn[Ln++]=nr,Dn[Ln++]=rr,Dn[Ln++]=Yr,Yr=t;var l=nr;t=rr;var f=32-Ft(l)-1;l&=~(1<<f),a+=1;var y=32-Ft(r)+f;if(30<y){var w=f-f%5;y=(l&(1<<w)-1).toString(32),l>>=w,f-=w,nr=1<<32-Ft(r)+f|a<<f|l,rr=y+t}else nr=1<<y|a<<f|l,rr=t}function mf(t){t.return!==null&&(xr(t,1),D0(t,1,0))}function pf(t){for(;t===ol;)ol=bi[--xi],bi[xi]=null,Oa=bi[--xi],bi[xi]=null;for(;t===Yr;)Yr=Dn[--Ln],Dn[Ln]=null,rr=Dn[--Ln],Dn[Ln]=null,nr=Dn[--Ln],Dn[Ln]=null}function L0(t,r){Dn[Ln++]=nr,Dn[Ln++]=rr,Dn[Ln++]=Yr,nr=r.id,rr=r.overflow,Yr=t}var zt=null,ct=null,Ge=!1,Kr=null,qn=!1,yf=Error(i(519));function Jr(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Aa(Rn(r,t)),yf}function q0(t){var r=t.stateNode,a=t.type,l=t.memoizedProps;switch(r[at]=t,r[gt]=l,a){case"dialog":Ie("cancel",r),Ie("close",r);break;case"iframe":case"object":case"embed":Ie("load",r);break;case"video":case"audio":for(a=0;a<Ka.length;a++)Ie(Ka[a],r);break;case"source":Ie("error",r);break;case"img":case"image":case"link":Ie("error",r),Ie("load",r);break;case"details":Ie("toggle",r);break;case"input":Ie("invalid",r),Jm(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Ie("invalid",r);break;case"textarea":Ie("invalid",r),Xm(r,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||l.suppressHydrationWarning===!0||Zy(r.textContent,a)?(l.popover!=null&&(Ie("beforetoggle",r),Ie("toggle",r)),l.onScroll!=null&&Ie("scroll",r),l.onScrollEnd!=null&&Ie("scrollend",r),l.onClick!=null&&(r.onclick=yr),r=!0):r=!1,r||Jr(t,!0)}function P0(t){for(zt=t.return;zt;)switch(zt.tag){case 5:case 31:case 13:qn=!1;return;case 27:case 3:qn=!0;return;default:zt=zt.return}}function vi(t){if(t!==zt)return!1;if(!Ge)return P0(t),Ge=!0,!1;var r=t.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=t.type,a=!(a!=="form"&&a!=="button")||Dh(t.type,t.memoizedProps)),a=!a),a&&ct&&Jr(t),P0(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));ct=lg(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));ct=lg(t)}else r===27?(r=ct,cs(t.type)?(t=Uh,Uh=null,ct=t):ct=r):ct=zt?Bn(t.stateNode.nextSibling):null;return!0}function zs(){ct=zt=null,Ge=!1}function gf(){var t=Kr;return t!==null&&(on===null?on=t:on.push.apply(on,t),Kr=null),t}function Aa(t){Kr===null?Kr=[t]:Kr.push(t)}var bf=Ce(null),Is=null,vr=null;function Qr(t,r,a){Me(bf,r._currentValue),r._currentValue=a}function _r(t){t._currentValue=bf.current,Ne(bf)}function xf(t,r,a){for(;t!==null;){var l=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,l!==null&&(l.childLanes|=r)):l!==null&&(l.childLanes&r)!==r&&(l.childLanes|=r),t===a)break;t=t.return}}function vf(t,r,a,l){var f=t.child;for(f!==null&&(f.return=t);f!==null;){var y=f.dependencies;if(y!==null){var w=f.child;y=y.firstContext;e:for(;y!==null;){var O=y;y=f;for(var R=0;R<r.length;R++)if(O.context===r[R]){y.lanes|=a,O=y.alternate,O!==null&&(O.lanes|=a),xf(y.return,a,t),l||(w=null);break e}y=O.next}}else if(f.tag===18){if(w=f.return,w===null)throw Error(i(341));w.lanes|=a,y=w.alternate,y!==null&&(y.lanes|=a),xf(w,a,t),w=null}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===t){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}}function _i(t,r,a,l){t=null;for(var f=r,y=!1;f!==null;){if(!y){if((f.flags&524288)!==0)y=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var w=f.alternate;if(w===null)throw Error(i(387));if(w=w.memoizedProps,w!==null){var O=f.type;dn(f.pendingProps.value,w.value)||(t!==null?t.push(O):t=[O])}}else if(f===Ee.current){if(w=f.alternate,w===null)throw Error(i(387));w.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(t!==null?t.push(Za):t=[Za])}f=f.return}t!==null&&vf(r,t,a,l),r.flags|=262144}function ll(t){for(t=t.firstContext;t!==null;){if(!dn(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function $s(t){Is=t,vr=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function It(t){return B0(Is,t)}function cl(t,r){return Is===null&&$s(t),B0(t,r)}function B0(t,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},vr===null){if(t===null)throw Error(i(308));vr=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else vr=vr.next=r;return a}var G_=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(a,l){t.push(l)}};this.abort=function(){r.aborted=!0,t.forEach(function(a){return a()})}},V_=n.unstable_scheduleCallback,Y_=n.unstable_NormalPriority,At={$$typeof:ne,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _f(){return{controller:new G_,data:new Map,refCount:0}}function ja(t){t.refCount--,t.refCount===0&&V_(Y_,function(){t.controller.abort()})}var ka=null,wf=0,wi=0,Si=null;function K_(t,r){if(ka===null){var a=ka=[];wf=0,wi=Oh(),Si={status:"pending",value:void 0,then:function(l){a.push(l)}}}return wf++,r.then(U0,U0),r}function U0(){if(--wf===0&&ka!==null){Si!==null&&(Si.status="fulfilled");var t=ka;ka=null,wi=0,Si=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function J_(t,r){var a=[],l={status:"pending",value:null,reason:null,then:function(f){a.push(f)}};return t.then(function(){l.status="fulfilled",l.value=r;for(var f=0;f<a.length;f++)(0,a[f])(r)},function(f){for(l.status="rejected",l.reason=f,f=0;f<a.length;f++)(0,a[f])(void 0)}),l}var z0=H.S;H.S=function(t,r){Sy=ft(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&K_(t,r),z0!==null&&z0(t,r)};var Hs=Ce(null);function Sf(){var t=Hs.current;return t!==null?t:ot.pooledCache}function ul(t,r){r===null?Me(Hs,Hs.current):Me(Hs,r.pool)}function I0(){var t=Sf();return t===null?null:{parent:At._currentValue,pool:t}}var Ei=Error(i(460)),Ef=Error(i(474)),fl=Error(i(542)),hl={then:function(){}};function $0(t){return t=t.status,t==="fulfilled"||t==="rejected"}function H0(t,r,a){switch(a=t[a],a===void 0?t.push(r):a!==r&&(r.then(yr,yr),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,G0(t),t;default:if(typeof r.status=="string")r.then(yr,yr);else{if(t=ot,t!==null&&100<t.shellSuspendCounter)throw Error(i(482));t=r,t.status="pending",t.then(function(l){if(r.status==="pending"){var f=r;f.status="fulfilled",f.value=l}},function(l){if(r.status==="pending"){var f=r;f.status="rejected",f.reason=l}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,G0(t),t}throw Gs=r,Ei}}function Fs(t){try{var r=t._init;return r(t._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Gs=a,Ei):a}}var Gs=null;function F0(){if(Gs===null)throw Error(i(459));var t=Gs;return Gs=null,t}function G0(t){if(t===Ei||t===fl)throw Error(i(483))}var Oi=null,Na=0;function dl(t){var r=Na;return Na+=1,Oi===null&&(Oi=[]),H0(Oi,t,r)}function Ta(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function ml(t,r){throw r.$$typeof===x?Error(i(525)):(t=Object.prototype.toString.call(r),Error(i(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t)))}function V0(t){function r(I,P){if(t){var G=I.deletions;G===null?(I.deletions=[P],I.flags|=16):G.push(P)}}function a(I,P){if(!t)return null;for(;P!==null;)r(I,P),P=P.sibling;return null}function l(I){for(var P=new Map;I!==null;)I.key!==null?P.set(I.key,I):P.set(I.index,I),I=I.sibling;return P}function f(I,P){return I=br(I,P),I.index=0,I.sibling=null,I}function y(I,P,G){return I.index=G,t?(G=I.alternate,G!==null?(G=G.index,G<P?(I.flags|=67108866,P):G):(I.flags|=67108866,P)):(I.flags|=1048576,P)}function w(I){return t&&I.alternate===null&&(I.flags|=67108866),I}function O(I,P,G,ee){return P===null||P.tag!==6?(P=hf(G,I.mode,ee),P.return=I,P):(P=f(P,G),P.return=I,P)}function R(I,P,G,ee){var je=G.type;return je===S?Z(I,P,G.props.children,ee,G.key):P!==null&&(P.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===F&&Fs(je)===P.type)?(P=f(P,G.props),Ta(P,G),P.return=I,P):(P=al(G.type,G.key,G.props,null,I.mode,ee),Ta(P,G),P.return=I,P)}function V(I,P,G,ee){return P===null||P.tag!==4||P.stateNode.containerInfo!==G.containerInfo||P.stateNode.implementation!==G.implementation?(P=df(G,I.mode,ee),P.return=I,P):(P=f(P,G.children||[]),P.return=I,P)}function Z(I,P,G,ee,je){return P===null||P.tag!==7?(P=Us(G,I.mode,ee,je),P.return=I,P):(P=f(P,G),P.return=I,P)}function ie(I,P,G){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=hf(""+P,I.mode,G),P.return=I,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return G=al(P.type,P.key,P.props,null,I.mode,G),Ta(G,P),G.return=I,G;case _:return P=df(P,I.mode,G),P.return=I,P;case F:return P=Fs(P),ie(I,P,G)}if(Ae(P)||W(P))return P=Us(P,I.mode,G,null),P.return=I,P;if(typeof P.then=="function")return ie(I,dl(P),G);if(P.$$typeof===ne)return ie(I,cl(I,P),G);ml(I,P)}return null}function Y(I,P,G,ee){var je=P!==null?P.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return je!==null?null:O(I,P,""+G,ee);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case v:return G.key===je?R(I,P,G,ee):null;case _:return G.key===je?V(I,P,G,ee):null;case F:return G=Fs(G),Y(I,P,G,ee)}if(Ae(G)||W(G))return je!==null?null:Z(I,P,G,ee,null);if(typeof G.then=="function")return Y(I,P,dl(G),ee);if(G.$$typeof===ne)return Y(I,P,cl(I,G),ee);ml(I,G)}return null}function Q(I,P,G,ee,je){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return I=I.get(G)||null,O(P,I,""+ee,je);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case v:return I=I.get(ee.key===null?G:ee.key)||null,R(P,I,ee,je);case _:return I=I.get(ee.key===null?G:ee.key)||null,V(P,I,ee,je);case F:return ee=Fs(ee),Q(I,P,G,ee,je)}if(Ae(ee)||W(ee))return I=I.get(G)||null,Z(P,I,ee,je,null);if(typeof ee.then=="function")return Q(I,P,G,dl(ee),je);if(ee.$$typeof===ne)return Q(I,P,G,cl(P,ee),je);ml(P,ee)}return null}function ve(I,P,G,ee){for(var je=null,Ke=null,_e=P,Le=P=0,Fe=null;_e!==null&&Le<G.length;Le++){_e.index>Le?(Fe=_e,_e=null):Fe=_e.sibling;var Je=Y(I,_e,G[Le],ee);if(Je===null){_e===null&&(_e=Fe);break}t&&_e&&Je.alternate===null&&r(I,_e),P=y(Je,P,Le),Ke===null?je=Je:Ke.sibling=Je,Ke=Je,_e=Fe}if(Le===G.length)return a(I,_e),Ge&&xr(I,Le),je;if(_e===null){for(;Le<G.length;Le++)_e=ie(I,G[Le],ee),_e!==null&&(P=y(_e,P,Le),Ke===null?je=_e:Ke.sibling=_e,Ke=_e);return Ge&&xr(I,Le),je}for(_e=l(_e);Le<G.length;Le++)Fe=Q(_e,I,Le,G[Le],ee),Fe!==null&&(t&&Fe.alternate!==null&&_e.delete(Fe.key===null?Le:Fe.key),P=y(Fe,P,Le),Ke===null?je=Fe:Ke.sibling=Fe,Ke=Fe);return t&&_e.forEach(function(ms){return r(I,ms)}),Ge&&xr(I,Le),je}function Te(I,P,G,ee){if(G==null)throw Error(i(151));for(var je=null,Ke=null,_e=P,Le=P=0,Fe=null,Je=G.next();_e!==null&&!Je.done;Le++,Je=G.next()){_e.index>Le?(Fe=_e,_e=null):Fe=_e.sibling;var ms=Y(I,_e,Je.value,ee);if(ms===null){_e===null&&(_e=Fe);break}t&&_e&&ms.alternate===null&&r(I,_e),P=y(ms,P,Le),Ke===null?je=ms:Ke.sibling=ms,Ke=ms,_e=Fe}if(Je.done)return a(I,_e),Ge&&xr(I,Le),je;if(_e===null){for(;!Je.done;Le++,Je=G.next())Je=ie(I,Je.value,ee),Je!==null&&(P=y(Je,P,Le),Ke===null?je=Je:Ke.sibling=Je,Ke=Je);return Ge&&xr(I,Le),je}for(_e=l(_e);!Je.done;Le++,Je=G.next())Je=Q(_e,I,Le,Je.value,ee),Je!==null&&(t&&Je.alternate!==null&&_e.delete(Je.key===null?Le:Je.key),P=y(Je,P,Le),Ke===null?je=Je:Ke.sibling=Je,Ke=Je);return t&&_e.forEach(function(aS){return r(I,aS)}),Ge&&xr(I,Le),je}function st(I,P,G,ee){if(typeof G=="object"&&G!==null&&G.type===S&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case v:e:{for(var je=G.key;P!==null;){if(P.key===je){if(je=G.type,je===S){if(P.tag===7){a(I,P.sibling),ee=f(P,G.props.children),ee.return=I,I=ee;break e}}else if(P.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===F&&Fs(je)===P.type){a(I,P.sibling),ee=f(P,G.props),Ta(ee,G),ee.return=I,I=ee;break e}a(I,P);break}else r(I,P);P=P.sibling}G.type===S?(ee=Us(G.props.children,I.mode,ee,G.key),ee.return=I,I=ee):(ee=al(G.type,G.key,G.props,null,I.mode,ee),Ta(ee,G),ee.return=I,I=ee)}return w(I);case _:e:{for(je=G.key;P!==null;){if(P.key===je)if(P.tag===4&&P.stateNode.containerInfo===G.containerInfo&&P.stateNode.implementation===G.implementation){a(I,P.sibling),ee=f(P,G.children||[]),ee.return=I,I=ee;break e}else{a(I,P);break}else r(I,P);P=P.sibling}ee=df(G,I.mode,ee),ee.return=I,I=ee}return w(I);case F:return G=Fs(G),st(I,P,G,ee)}if(Ae(G))return ve(I,P,G,ee);if(W(G)){if(je=W(G),typeof je!="function")throw Error(i(150));return G=je.call(G),Te(I,P,G,ee)}if(typeof G.then=="function")return st(I,P,dl(G),ee);if(G.$$typeof===ne)return st(I,P,cl(I,G),ee);ml(I,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,P!==null&&P.tag===6?(a(I,P.sibling),ee=f(P,G),ee.return=I,I=ee):(a(I,P),ee=hf(G,I.mode,ee),ee.return=I,I=ee),w(I)):a(I,P)}return function(I,P,G,ee){try{Na=0;var je=st(I,P,G,ee);return Oi=null,je}catch(_e){if(_e===Ei||_e===fl)throw _e;var Ke=mn(29,_e,null,I.mode);return Ke.lanes=ee,Ke.return=I,Ke}finally{}}}var Vs=V0(!0),Y0=V0(!1),Xr=!1;function Of(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Af(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Wr(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Zr(t,r,a){var l=t.updateQueue;if(l===null)return null;if(l=l.shared,(Qe&2)!==0){var f=l.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),l.pending=r,r=il(t),T0(t,null,a),r}return sl(t,l,r,a),il(t)}function Ca(t,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var l=r.lanes;l&=t.pendingLanes,a|=l,r.lanes=a,Ms(t,a)}}function jf(t,r){var a=t.updateQueue,l=t.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var f=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var w={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?f=y=w:y=y.next=w,a=a.next}while(a!==null);y===null?f=y=r:y=y.next=r}else f=y=r;a={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:y,shared:l.shared,callbacks:l.callbacks},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=r:t.next=r,a.lastBaseUpdate=r}var kf=!1;function Ma(){if(kf){var t=Si;if(t!==null)throw t}}function Ra(t,r,a,l){kf=!1;var f=t.updateQueue;Xr=!1;var y=f.firstBaseUpdate,w=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var R=O,V=R.next;R.next=null,w===null?y=V:w.next=V,w=R;var Z=t.alternate;Z!==null&&(Z=Z.updateQueue,O=Z.lastBaseUpdate,O!==w&&(O===null?Z.firstBaseUpdate=V:O.next=V,Z.lastBaseUpdate=R))}if(y!==null){var ie=f.baseState;w=0,Z=V=R=null,O=y;do{var Y=O.lane&-536870913,Q=Y!==O.lane;if(Q?(He&Y)===Y:(l&Y)===Y){Y!==0&&Y===wi&&(kf=!0),Z!==null&&(Z=Z.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var ve=t,Te=O;Y=r;var st=a;switch(Te.tag){case 1:if(ve=Te.payload,typeof ve=="function"){ie=ve.call(st,ie,Y);break e}ie=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Te.payload,Y=typeof ve=="function"?ve.call(st,ie,Y):ve,Y==null)break e;ie=b({},ie,Y);break e;case 2:Xr=!0}}Y=O.callback,Y!==null&&(t.flags|=64,Q&&(t.flags|=8192),Q=f.callbacks,Q===null?f.callbacks=[Y]:Q.push(Y))}else Q={lane:Y,tag:O.tag,payload:O.payload,callback:O.callback,next:null},Z===null?(V=Z=Q,R=ie):Z=Z.next=Q,w|=Y;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;Q=O,O=Q.next,Q.next=null,f.lastBaseUpdate=Q,f.shared.pending=null}}while(!0);Z===null&&(R=ie),f.baseState=R,f.firstBaseUpdate=V,f.lastBaseUpdate=Z,y===null&&(f.shared.lanes=0),ss|=w,t.lanes=w,t.memoizedState=ie}}function K0(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function J0(t,r){var a=t.callbacks;if(a!==null)for(t.callbacks=null,t=0;t<a.length;t++)K0(a[t],r)}var Ai=Ce(null),pl=Ce(0);function Q0(t,r){t=Tr,Me(pl,t),Me(Ai,r),Tr=t|r.baseLanes}function Nf(){Me(pl,Tr),Me(Ai,Ai.current)}function Tf(){Tr=pl.current,Ne(Ai),Ne(pl)}var pn=Ce(null),Pn=null;function es(t){var r=t.alternate;Me(wt,wt.current&1),Me(pn,t),Pn===null&&(r===null||Ai.current!==null||r.memoizedState!==null)&&(Pn=t)}function Cf(t){Me(wt,wt.current),Me(pn,t),Pn===null&&(Pn=t)}function X0(t){t.tag===22?(Me(wt,wt.current),Me(pn,t),Pn===null&&(Pn=t)):ts()}function ts(){Me(wt,wt.current),Me(pn,pn.current)}function yn(t){Ne(pn),Pn===t&&(Pn=null),Ne(wt)}var wt=Ce(0);function yl(t){for(var r=t;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Ph(a)||Bh(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var wr=0,De=null,nt=null,jt=null,gl=!1,ji=!1,Ys=!1,bl=0,Da=0,ki=null,Q_=0;function bt(){throw Error(i(321))}function Mf(t,r){if(r===null)return!1;for(var a=0;a<r.length&&a<t.length;a++)if(!dn(t[a],r[a]))return!1;return!0}function Rf(t,r,a,l,f,y){return wr=y,De=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,H.H=t===null||t.memoizedState===null?Dp:Kf,Ys=!1,y=a(l,f),Ys=!1,ji&&(y=Z0(r,a,l,f)),W0(t),y}function W0(t){H.H=Pa;var r=nt!==null&&nt.next!==null;if(wr=0,jt=nt=De=null,gl=!1,Da=0,ki=null,r)throw Error(i(300));t===null||kt||(t=t.dependencies,t!==null&&ll(t)&&(kt=!0))}function Z0(t,r,a,l){De=t;var f=0;do{if(ji&&(ki=null),Da=0,ji=!1,25<=f)throw Error(i(301));if(f+=1,jt=nt=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}H.H=Lp,y=r(a,l)}while(ji);return y}function X_(){var t=H.H,r=t.useState()[0];return r=typeof r.then=="function"?La(r):r,t=t.useState()[0],(nt!==null?nt.memoizedState:null)!==t&&(De.flags|=1024),r}function Df(){var t=bl!==0;return bl=0,t}function Lf(t,r,a){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~a}function qf(t){if(gl){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}gl=!1}wr=0,jt=nt=De=null,ji=!1,Da=bl=0,ki=null}function Yt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?De.memoizedState=jt=t:jt=jt.next=t,jt}function St(){if(nt===null){var t=De.alternate;t=t!==null?t.memoizedState:null}else t=nt.next;var r=jt===null?De.memoizedState:jt.next;if(r!==null)jt=r,nt=t;else{if(t===null)throw De.alternate===null?Error(i(467)):Error(i(310));nt=t,t={memoizedState:nt.memoizedState,baseState:nt.baseState,baseQueue:nt.baseQueue,queue:nt.queue,next:null},jt===null?De.memoizedState=jt=t:jt=jt.next=t}return jt}function xl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function La(t){var r=Da;return Da+=1,ki===null&&(ki=[]),t=H0(ki,t,r),r=De,(jt===null?r.memoizedState:jt.next)===null&&(r=r.alternate,H.H=r===null||r.memoizedState===null?Dp:Kf),t}function vl(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return La(t);if(t.$$typeof===ne)return It(t)}throw Error(i(438,String(t)))}function Pf(t){var r=null,a=De.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=De.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(r={data:l.data.map(function(f){return f.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=xl(),De.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(t),l=0;l<t;l++)a[l]=D;return r.index++,a}function Sr(t,r){return typeof r=="function"?r(t):r}function _l(t){var r=St();return Bf(r,nt,t)}function Bf(t,r,a){var l=t.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=a;var f=t.baseQueue,y=l.pending;if(y!==null){if(f!==null){var w=f.next;f.next=y.next,y.next=w}r.baseQueue=f=y,l.pending=null}if(y=t.baseState,f===null)t.memoizedState=y;else{r=f.next;var O=w=null,R=null,V=r,Z=!1;do{var ie=V.lane&-536870913;if(ie!==V.lane?(He&ie)===ie:(wr&ie)===ie){var Y=V.revertLane;if(Y===0)R!==null&&(R=R.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),ie===wi&&(Z=!0);else if((wr&Y)===Y){V=V.next,Y===wi&&(Z=!0);continue}else ie={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},R===null?(O=R=ie,w=y):R=R.next=ie,De.lanes|=Y,ss|=Y;ie=V.action,Ys&&a(y,ie),y=V.hasEagerState?V.eagerState:a(y,ie)}else Y={lane:ie,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},R===null?(O=R=Y,w=y):R=R.next=Y,De.lanes|=ie,ss|=ie;V=V.next}while(V!==null&&V!==r);if(R===null?w=y:R.next=O,!dn(y,t.memoizedState)&&(kt=!0,Z&&(a=Si,a!==null)))throw a;t.memoizedState=y,t.baseState=w,t.baseQueue=R,l.lastRenderedState=y}return f===null&&(l.lanes=0),[t.memoizedState,l.dispatch]}function Uf(t){var r=St(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=t;var l=a.dispatch,f=a.pending,y=r.memoizedState;if(f!==null){a.pending=null;var w=f=f.next;do y=t(y,w.action),w=w.next;while(w!==f);dn(y,r.memoizedState)||(kt=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),a.lastRenderedState=y}return[y,l]}function ep(t,r,a){var l=De,f=St(),y=Ge;if(y){if(a===void 0)throw Error(i(407));a=a()}else a=r();var w=!dn((nt||f).memoizedState,a);if(w&&(f.memoizedState=a,kt=!0),f=f.queue,$f(rp.bind(null,l,f,t),[t]),f.getSnapshot!==r||w||jt!==null&&jt.memoizedState.tag&1){if(l.flags|=2048,Ni(9,{destroy:void 0},np.bind(null,l,f,a,r),null),ot===null)throw Error(i(349));y||(wr&127)!==0||tp(l,r,a)}return a}function tp(t,r,a){t.flags|=16384,t={getSnapshot:r,value:a},r=De.updateQueue,r===null?(r=xl(),De.updateQueue=r,r.stores=[t]):(a=r.stores,a===null?r.stores=[t]:a.push(t))}function np(t,r,a,l){r.value=a,r.getSnapshot=l,sp(r)&&ip(t)}function rp(t,r,a){return a(function(){sp(r)&&ip(t)})}function sp(t){var r=t.getSnapshot;t=t.value;try{var a=r();return!dn(t,a)}catch{return!0}}function ip(t){var r=Bs(t,2);r!==null&&ln(r,t,2)}function zf(t){var r=Yt();if(typeof t=="function"){var a=t;if(t=a(),Ys){fn(!0);try{a()}finally{fn(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:t},r}function ap(t,r,a,l){return t.baseState=a,Bf(t,nt,typeof l=="function"?l:Sr)}function W_(t,r,a,l,f){if(El(t))throw Error(i(485));if(t=r.action,t!==null){var y={payload:f,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){y.listeners.push(w)}};H.T!==null?a(!0):y.isTransition=!1,l(y),a=r.pending,a===null?(y.next=r.pending=y,op(r,y)):(y.next=a.next,r.pending=a.next=y)}}function op(t,r){var a=r.action,l=r.payload,f=t.state;if(r.isTransition){var y=H.T,w={};H.T=w;try{var O=a(f,l),R=H.S;R!==null&&R(w,O),lp(t,r,O)}catch(V){If(t,r,V)}finally{y!==null&&w.types!==null&&(y.types=w.types),H.T=y}}else try{y=a(f,l),lp(t,r,y)}catch(V){If(t,r,V)}}function lp(t,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){cp(t,r,l)},function(l){return If(t,r,l)}):cp(t,r,a)}function cp(t,r,a){r.status="fulfilled",r.value=a,up(r),t.state=a,r=t.pending,r!==null&&(a=r.next,a===r?t.pending=null:(a=a.next,r.next=a,op(t,a)))}function If(t,r,a){var l=t.pending;if(t.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,up(r),r=r.next;while(r!==l)}t.action=null}function up(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function fp(t,r){return r}function hp(t,r){if(Ge){var a=ot.formState;if(a!==null){e:{var l=De;if(Ge){if(ct){t:{for(var f=ct,y=qn;f.nodeType!==8;){if(!y){f=null;break t}if(f=Bn(f.nextSibling),f===null){f=null;break t}}y=f.data,f=y==="F!"||y==="F"?f:null}if(f){ct=Bn(f.nextSibling),l=f.data==="F!";break e}}Jr(l)}l=!1}l&&(r=a[0])}}return a=Yt(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fp,lastRenderedState:r},a.queue=l,a=Cp.bind(null,De,l),l.dispatch=a,l=zf(!1),y=Yf.bind(null,De,!1,l.queue),l=Yt(),f={state:r,dispatch:null,action:t,pending:null},l.queue=f,a=W_.bind(null,De,f,y,a),f.dispatch=a,l.memoizedState=t,[r,a,!1]}function dp(t){var r=St();return mp(r,nt,t)}function mp(t,r,a){if(r=Bf(t,r,fp)[0],t=_l(Sr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=La(r)}catch(w){throw w===Ei?fl:w}else l=r;r=St();var f=r.queue,y=f.dispatch;return a!==r.memoizedState&&(De.flags|=2048,Ni(9,{destroy:void 0},Z_.bind(null,f,a),null)),[l,y,t]}function Z_(t,r){t.action=r}function pp(t){var r=St(),a=nt;if(a!==null)return mp(r,a,t);St(),r=r.memoizedState,a=St();var l=a.queue.dispatch;return a.memoizedState=t,[r,l,!1]}function Ni(t,r,a,l){return t={tag:t,create:a,deps:l,inst:r,next:null},r=De.updateQueue,r===null&&(r=xl(),De.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=t.next=t:(l=a.next,a.next=t,t.next=l,r.lastEffect=t),t}function yp(){return St().memoizedState}function wl(t,r,a,l){var f=Yt();De.flags|=t,f.memoizedState=Ni(1|r,{destroy:void 0},a,l===void 0?null:l)}function Sl(t,r,a,l){var f=St();l=l===void 0?null:l;var y=f.memoizedState.inst;nt!==null&&l!==null&&Mf(l,nt.memoizedState.deps)?f.memoizedState=Ni(r,y,a,l):(De.flags|=t,f.memoizedState=Ni(1|r,y,a,l))}function gp(t,r){wl(8390656,8,t,r)}function $f(t,r){Sl(2048,8,t,r)}function ew(t){De.flags|=4;var r=De.updateQueue;if(r===null)r=xl(),De.updateQueue=r,r.events=[t];else{var a=r.events;a===null?r.events=[t]:a.push(t)}}function bp(t){var r=St().memoizedState;return ew({ref:r,nextImpl:t}),function(){if((Qe&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function xp(t,r){return Sl(4,2,t,r)}function vp(t,r){return Sl(4,4,t,r)}function _p(t,r){if(typeof r=="function"){t=t();var a=r(t);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function wp(t,r,a){a=a!=null?a.concat([t]):null,Sl(4,4,_p.bind(null,r,t),a)}function Hf(){}function Sp(t,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&Mf(r,l[1])?l[0]:(a.memoizedState=[t,r],t)}function Ep(t,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&Mf(r,l[1]))return l[0];if(l=t(),Ys){fn(!0);try{t()}finally{fn(!1)}}return a.memoizedState=[l,r],l}function Ff(t,r,a){return a===void 0||(wr&1073741824)!==0&&(He&261930)===0?t.memoizedState=r:(t.memoizedState=a,t=Oy(),De.lanes|=t,ss|=t,a)}function Op(t,r,a,l){return dn(a,r)?a:Ai.current!==null?(t=Ff(t,a,l),dn(t,r)||(kt=!0),t):(wr&42)===0||(wr&1073741824)!==0&&(He&261930)===0?(kt=!0,t.memoizedState=a):(t=Oy(),De.lanes|=t,ss|=t,r)}function Ap(t,r,a,l,f){var y=J.p;J.p=y!==0&&8>y?y:8;var w=H.T,O={};H.T=O,Yf(t,!1,r,a);try{var R=f(),V=H.S;if(V!==null&&V(O,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var Z=J_(R,l);qa(t,r,Z,xn(t))}else qa(t,r,l,xn(t))}catch(ie){qa(t,r,{then:function(){},status:"rejected",reason:ie},xn())}finally{J.p=y,w!==null&&O.types!==null&&(w.types=O.types),H.T=w}}function tw(){}function Gf(t,r,a,l){if(t.tag!==5)throw Error(i(476));var f=jp(t).queue;Ap(t,f,r,le,a===null?tw:function(){return kp(t),a(l)})}function jp(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:le},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:a},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function kp(t){var r=jp(t);r.next===null&&(r=t.alternate.memoizedState),qa(t,r.next.queue,{},xn())}function Vf(){return It(Za)}function Np(){return St().memoizedState}function Tp(){return St().memoizedState}function nw(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var a=xn();t=Wr(a);var l=Zr(r,t,a);l!==null&&(ln(l,r,a),Ca(l,r,a)),r={cache:_f()},t.payload=r;return}r=r.return}}function rw(t,r,a){var l=xn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},El(t)?Mp(r,a):(a=uf(t,r,a,l),a!==null&&(ln(a,t,l),Rp(a,r,l)))}function Cp(t,r,a){var l=xn();qa(t,r,a,l)}function qa(t,r,a,l){var f={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(El(t))Mp(r,f);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var w=r.lastRenderedState,O=y(w,a);if(f.hasEagerState=!0,f.eagerState=O,dn(O,w))return sl(t,r,f,0),ot===null&&rl(),!1}catch{}finally{}if(a=uf(t,r,f,l),a!==null)return ln(a,t,l),Rp(a,r,l),!0}return!1}function Yf(t,r,a,l){if(l={lane:2,revertLane:Oh(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},El(t)){if(r)throw Error(i(479))}else r=uf(t,a,l,2),r!==null&&ln(r,t,2)}function El(t){var r=t.alternate;return t===De||r!==null&&r===De}function Mp(t,r){ji=gl=!0;var a=t.pending;a===null?r.next=r:(r.next=a.next,a.next=r),t.pending=r}function Rp(t,r,a){if((a&4194048)!==0){var l=r.lanes;l&=t.pendingLanes,a|=l,r.lanes=a,Ms(t,a)}}var Pa={readContext:It,use:vl,useCallback:bt,useContext:bt,useEffect:bt,useImperativeHandle:bt,useLayoutEffect:bt,useInsertionEffect:bt,useMemo:bt,useReducer:bt,useRef:bt,useState:bt,useDebugValue:bt,useDeferredValue:bt,useTransition:bt,useSyncExternalStore:bt,useId:bt,useHostTransitionStatus:bt,useFormState:bt,useActionState:bt,useOptimistic:bt,useMemoCache:bt,useCacheRefresh:bt};Pa.useEffectEvent=bt;var Dp={readContext:It,use:vl,useCallback:function(t,r){return Yt().memoizedState=[t,r===void 0?null:r],t},useContext:It,useEffect:gp,useImperativeHandle:function(t,r,a){a=a!=null?a.concat([t]):null,wl(4194308,4,_p.bind(null,r,t),a)},useLayoutEffect:function(t,r){return wl(4194308,4,t,r)},useInsertionEffect:function(t,r){wl(4,2,t,r)},useMemo:function(t,r){var a=Yt();r=r===void 0?null:r;var l=t();if(Ys){fn(!0);try{t()}finally{fn(!1)}}return a.memoizedState=[l,r],l},useReducer:function(t,r,a){var l=Yt();if(a!==void 0){var f=a(r);if(Ys){fn(!0);try{a(r)}finally{fn(!1)}}}else f=r;return l.memoizedState=l.baseState=f,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:f},l.queue=t,t=t.dispatch=rw.bind(null,De,t),[l.memoizedState,t]},useRef:function(t){var r=Yt();return t={current:t},r.memoizedState=t},useState:function(t){t=zf(t);var r=t.queue,a=Cp.bind(null,De,r);return r.dispatch=a,[t.memoizedState,a]},useDebugValue:Hf,useDeferredValue:function(t,r){var a=Yt();return Ff(a,t,r)},useTransition:function(){var t=zf(!1);return t=Ap.bind(null,De,t.queue,!0,!1),Yt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,a){var l=De,f=Yt();if(Ge){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),ot===null)throw Error(i(349));(He&127)!==0||tp(l,r,a)}f.memoizedState=a;var y={value:a,getSnapshot:r};return f.queue=y,gp(rp.bind(null,l,y,t),[t]),l.flags|=2048,Ni(9,{destroy:void 0},np.bind(null,l,y,a,r),null),a},useId:function(){var t=Yt(),r=ot.identifierPrefix;if(Ge){var a=rr,l=nr;a=(l&~(1<<32-Ft(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=bl++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=Q_++,r="_"+r+"r_"+a.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Vf,useFormState:hp,useActionState:hp,useOptimistic:function(t){var r=Yt();r.memoizedState=r.baseState=t;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Yf.bind(null,De,!0,a),a.dispatch=r,[t,r]},useMemoCache:Pf,useCacheRefresh:function(){return Yt().memoizedState=nw.bind(null,De)},useEffectEvent:function(t){var r=Yt(),a={impl:t};return r.memoizedState=a,function(){if((Qe&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}},Kf={readContext:It,use:vl,useCallback:Sp,useContext:It,useEffect:$f,useImperativeHandle:wp,useInsertionEffect:xp,useLayoutEffect:vp,useMemo:Ep,useReducer:_l,useRef:yp,useState:function(){return _l(Sr)},useDebugValue:Hf,useDeferredValue:function(t,r){var a=St();return Op(a,nt.memoizedState,t,r)},useTransition:function(){var t=_l(Sr)[0],r=St().memoizedState;return[typeof t=="boolean"?t:La(t),r]},useSyncExternalStore:ep,useId:Np,useHostTransitionStatus:Vf,useFormState:dp,useActionState:dp,useOptimistic:function(t,r){var a=St();return ap(a,nt,t,r)},useMemoCache:Pf,useCacheRefresh:Tp};Kf.useEffectEvent=bp;var Lp={readContext:It,use:vl,useCallback:Sp,useContext:It,useEffect:$f,useImperativeHandle:wp,useInsertionEffect:xp,useLayoutEffect:vp,useMemo:Ep,useReducer:Uf,useRef:yp,useState:function(){return Uf(Sr)},useDebugValue:Hf,useDeferredValue:function(t,r){var a=St();return nt===null?Ff(a,t,r):Op(a,nt.memoizedState,t,r)},useTransition:function(){var t=Uf(Sr)[0],r=St().memoizedState;return[typeof t=="boolean"?t:La(t),r]},useSyncExternalStore:ep,useId:Np,useHostTransitionStatus:Vf,useFormState:pp,useActionState:pp,useOptimistic:function(t,r){var a=St();return nt!==null?ap(a,nt,t,r):(a.baseState=t,[t,a.queue.dispatch])},useMemoCache:Pf,useCacheRefresh:Tp};Lp.useEffectEvent=bp;function Jf(t,r,a,l){r=t.memoizedState,a=a(l,r),a=a==null?r:b({},r,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var Qf={enqueueSetState:function(t,r,a){t=t._reactInternals;var l=xn(),f=Wr(l);f.payload=r,a!=null&&(f.callback=a),r=Zr(t,f,l),r!==null&&(ln(r,t,l),Ca(r,t,l))},enqueueReplaceState:function(t,r,a){t=t._reactInternals;var l=xn(),f=Wr(l);f.tag=1,f.payload=r,a!=null&&(f.callback=a),r=Zr(t,f,l),r!==null&&(ln(r,t,l),Ca(r,t,l))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var a=xn(),l=Wr(a);l.tag=2,r!=null&&(l.callback=r),r=Zr(t,l,a),r!==null&&(ln(r,t,a),Ca(r,t,a))}};function qp(t,r,a,l,f,y,w){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(l,y,w):r.prototype&&r.prototype.isPureReactComponent?!Sa(a,l)||!Sa(f,y):!0}function Pp(t,r,a,l){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,l),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,l),r.state!==t&&Qf.enqueueReplaceState(r,r.state,null)}function Ks(t,r){var a=r;if("ref"in r){a={};for(var l in r)l!=="ref"&&(a[l]=r[l])}if(t=t.defaultProps){a===r&&(a=b({},a));for(var f in t)a[f]===void 0&&(a[f]=t[f])}return a}function Bp(t){nl(t)}function Up(t){console.error(t)}function zp(t){nl(t)}function Ol(t,r){try{var a=t.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function Ip(t,r,a){try{var l=t.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Xf(t,r,a){return a=Wr(a),a.tag=3,a.payload={element:null},a.callback=function(){Ol(t,r)},a}function $p(t){return t=Wr(t),t.tag=3,t}function Hp(t,r,a,l){var f=a.type.getDerivedStateFromError;if(typeof f=="function"){var y=l.value;t.payload=function(){return f(y)},t.callback=function(){Ip(r,a,l)}}var w=a.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(t.callback=function(){Ip(r,a,l),typeof f!="function"&&(is===null?is=new Set([this]):is.add(this));var O=l.stack;this.componentDidCatch(l.value,{componentStack:O!==null?O:""})})}function sw(t,r,a,l,f){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&_i(r,a,f,!0),a=pn.current,a!==null){switch(a.tag){case 31:case 13:return Pn===null?Pl():a.alternate===null&&xt===0&&(xt=3),a.flags&=-257,a.flags|=65536,a.lanes=f,l===hl?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),wh(t,l,f)),!1;case 22:return a.flags|=65536,l===hl?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([l]):a.add(l)),wh(t,l,f)),!1}throw Error(i(435,a.tag))}return wh(t,l,f),Pl(),!1}if(Ge)return r=pn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=f,l!==yf&&(t=Error(i(422),{cause:l}),Aa(Rn(t,a)))):(l!==yf&&(r=Error(i(423),{cause:l}),Aa(Rn(r,a))),t=t.current.alternate,t.flags|=65536,f&=-f,t.lanes|=f,l=Rn(l,a),f=Xf(t.stateNode,l,f),jf(t,f),xt!==4&&(xt=2)),!1;var y=Error(i(520),{cause:l});if(y=Rn(y,a),Ga===null?Ga=[y]:Ga.push(y),xt!==4&&(xt=2),r===null)return!0;l=Rn(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,t=f&-f,a.lanes|=t,t=Xf(a.stateNode,l,t),jf(a,t),!1;case 1:if(r=a.type,y=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(is===null||!is.has(y))))return a.flags|=65536,f&=-f,a.lanes|=f,f=$p(f),Hp(f,t,a,l),jf(a,f),!1}a=a.return}while(a!==null);return!1}var Wf=Error(i(461)),kt=!1;function $t(t,r,a,l){r.child=t===null?Y0(r,null,a,l):Vs(r,t.child,a,l)}function Fp(t,r,a,l,f){a=a.render;var y=r.ref;if("ref"in l){var w={};for(var O in l)O!=="ref"&&(w[O]=l[O])}else w=l;return $s(r),l=Rf(t,r,a,w,y,f),O=Df(),t!==null&&!kt?(Lf(t,r,f),Er(t,r,f)):(Ge&&O&&mf(r),r.flags|=1,$t(t,r,l,f),r.child)}function Gp(t,r,a,l,f){if(t===null){var y=a.type;return typeof y=="function"&&!ff(y)&&y.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=y,Vp(t,r,y,l,f)):(t=al(a.type,null,l,r,r.mode,f),t.ref=r.ref,t.return=r,r.child=t)}if(y=t.child,!ah(t,f)){var w=y.memoizedProps;if(a=a.compare,a=a!==null?a:Sa,a(w,l)&&t.ref===r.ref)return Er(t,r,f)}return r.flags|=1,t=br(y,l),t.ref=r.ref,t.return=r,r.child=t}function Vp(t,r,a,l,f){if(t!==null){var y=t.memoizedProps;if(Sa(y,l)&&t.ref===r.ref)if(kt=!1,r.pendingProps=l=y,ah(t,f))(t.flags&131072)!==0&&(kt=!0);else return r.lanes=t.lanes,Er(t,r,f)}return Zf(t,r,a,l,f)}function Yp(t,r,a,l){var f=l.children,y=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|a:a,t!==null){for(l=r.child=t.child,f=0;l!==null;)f=f|l.lanes|l.childLanes,l=l.sibling;l=f&~y}else l=0,r.child=null;return Kp(t,r,y,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&ul(r,y!==null?y.cachePool:null),y!==null?Q0(r,y):Nf(),X0(r);else return l=r.lanes=536870912,Kp(t,r,y!==null?y.baseLanes|a:a,a,l)}else y!==null?(ul(r,y.cachePool),Q0(r,y),ts(),r.memoizedState=null):(t!==null&&ul(r,null),Nf(),ts());return $t(t,r,f,a),r.child}function Ba(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Kp(t,r,a,l,f){var y=Sf();return y=y===null?null:{parent:At._currentValue,pool:y},r.memoizedState={baseLanes:a,cachePool:y},t!==null&&ul(r,null),Nf(),X0(r),t!==null&&_i(t,r,l,!0),r.childLanes=f,null}function Al(t,r){return r=kl({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Jp(t,r,a){return Vs(r,t.child,null,a),t=Al(r,r.pendingProps),t.flags|=2,yn(r),r.memoizedState=null,t}function iw(t,r,a){var l=r.pendingProps,f=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(Ge){if(l.mode==="hidden")return t=Al(r,l),r.lanes=536870912,Ba(null,t);if(Cf(r),(t=ct)?(t=og(t,qn),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:Yr!==null?{id:nr,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},a=M0(t),a.return=r,r.child=a,zt=r,ct=null)):t=null,t===null)throw Jr(r);return r.lanes=536870912,null}return Al(r,l)}var y=t.memoizedState;if(y!==null){var w=y.dehydrated;if(Cf(r),f)if(r.flags&256)r.flags&=-257,r=Jp(t,r,a);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(kt||_i(t,r,a,!1),f=(a&t.childLanes)!==0,kt||f){if(l=ot,l!==null&&(w=Gr(l,a),w!==0&&w!==y.retryLane))throw y.retryLane=w,Bs(t,w),ln(l,t,w),Wf;Pl(),r=Jp(t,r,a)}else t=y.treeContext,ct=Bn(w.nextSibling),zt=r,Ge=!0,Kr=null,qn=!1,t!==null&&L0(r,t),r=Al(r,l),r.flags|=4096;return r}return t=br(t.child,{mode:l.mode,children:l.children}),t.ref=r.ref,r.child=t,t.return=r,t}function jl(t,r){var a=r.ref;if(a===null)t!==null&&t.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(i(284));(t===null||t.ref!==a)&&(r.flags|=4194816)}}function Zf(t,r,a,l,f){return $s(r),a=Rf(t,r,a,l,void 0,f),l=Df(),t!==null&&!kt?(Lf(t,r,f),Er(t,r,f)):(Ge&&l&&mf(r),r.flags|=1,$t(t,r,a,f),r.child)}function Qp(t,r,a,l,f,y){return $s(r),r.updateQueue=null,a=Z0(r,l,a,f),W0(t),l=Df(),t!==null&&!kt?(Lf(t,r,y),Er(t,r,y)):(Ge&&l&&mf(r),r.flags|=1,$t(t,r,a,y),r.child)}function Xp(t,r,a,l,f){if($s(r),r.stateNode===null){var y=gi,w=a.contextType;typeof w=="object"&&w!==null&&(y=It(w)),y=new a(l,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Qf,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=l,y.state=r.memoizedState,y.refs={},Of(r),w=a.contextType,y.context=typeof w=="object"&&w!==null?It(w):gi,y.state=r.memoizedState,w=a.getDerivedStateFromProps,typeof w=="function"&&(Jf(r,a,w,l),y.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(w=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),w!==y.state&&Qf.enqueueReplaceState(y,y.state,null),Ra(r,l,y,f),Ma(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),l=!0}else if(t===null){y=r.stateNode;var O=r.memoizedProps,R=Ks(a,O);y.props=R;var V=y.context,Z=a.contextType;w=gi,typeof Z=="object"&&Z!==null&&(w=It(Z));var ie=a.getDerivedStateFromProps;Z=typeof ie=="function"||typeof y.getSnapshotBeforeUpdate=="function",O=r.pendingProps!==O,Z||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(O||V!==w)&&Pp(r,y,l,w),Xr=!1;var Y=r.memoizedState;y.state=Y,Ra(r,l,y,f),Ma(),V=r.memoizedState,O||Y!==V||Xr?(typeof ie=="function"&&(Jf(r,a,ie,l),V=r.memoizedState),(R=Xr||qp(r,a,R,l,Y,V,w))?(Z||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=l,r.memoizedState=V),y.props=l,y.state=V,y.context=w,l=R):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{y=r.stateNode,Af(t,r),w=r.memoizedProps,Z=Ks(a,w),y.props=Z,ie=r.pendingProps,Y=y.context,V=a.contextType,R=gi,typeof V=="object"&&V!==null&&(R=It(V)),O=a.getDerivedStateFromProps,(V=typeof O=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(w!==ie||Y!==R)&&Pp(r,y,l,R),Xr=!1,Y=r.memoizedState,y.state=Y,Ra(r,l,y,f),Ma();var Q=r.memoizedState;w!==ie||Y!==Q||Xr||t!==null&&t.dependencies!==null&&ll(t.dependencies)?(typeof O=="function"&&(Jf(r,a,O,l),Q=r.memoizedState),(Z=Xr||qp(r,a,Z,l,Y,Q,R)||t!==null&&t.dependencies!==null&&ll(t.dependencies))?(V||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,Q,R),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,Q,R)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=Q),y.props=l,y.state=Q,y.context=R,l=Z):(typeof y.componentDidUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=1024),l=!1)}return y=l,jl(t,r),l=(r.flags&128)!==0,y||l?(y=r.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,t!==null&&l?(r.child=Vs(r,t.child,null,f),r.child=Vs(r,null,a,f)):$t(t,r,a,f),r.memoizedState=y.state,t=r.child):t=Er(t,r,f),t}function Wp(t,r,a,l){return zs(),r.flags|=256,$t(t,r,a,l),r.child}var eh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function th(t){return{baseLanes:t,cachePool:I0()}}function nh(t,r,a){return t=t!==null?t.childLanes&~a:0,r&&(t|=bn),t}function Zp(t,r,a){var l=r.pendingProps,f=!1,y=(r.flags&128)!==0,w;if((w=y)||(w=t!==null&&t.memoizedState===null?!1:(wt.current&2)!==0),w&&(f=!0,r.flags&=-129),w=(r.flags&32)!==0,r.flags&=-33,t===null){if(Ge){if(f?es(r):ts(),(t=ct)?(t=og(t,qn),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:Yr!==null?{id:nr,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},a=M0(t),a.return=r,r.child=a,zt=r,ct=null)):t=null,t===null)throw Jr(r);return Bh(t)?r.lanes=32:r.lanes=536870912,null}var O=l.children;return l=l.fallback,f?(ts(),f=r.mode,O=kl({mode:"hidden",children:O},f),l=Us(l,f,a,null),O.return=r,l.return=r,O.sibling=l,r.child=O,l=r.child,l.memoizedState=th(a),l.childLanes=nh(t,w,a),r.memoizedState=eh,Ba(null,l)):(es(r),rh(r,O))}var R=t.memoizedState;if(R!==null&&(O=R.dehydrated,O!==null)){if(y)r.flags&256?(es(r),r.flags&=-257,r=sh(t,r,a)):r.memoizedState!==null?(ts(),r.child=t.child,r.flags|=128,r=null):(ts(),O=l.fallback,f=r.mode,l=kl({mode:"visible",children:l.children},f),O=Us(O,f,a,null),O.flags|=2,l.return=r,O.return=r,l.sibling=O,r.child=l,Vs(r,t.child,null,a),l=r.child,l.memoizedState=th(a),l.childLanes=nh(t,w,a),r.memoizedState=eh,r=Ba(null,l));else if(es(r),Bh(O)){if(w=O.nextSibling&&O.nextSibling.dataset,w)var V=w.dgst;w=V,l=Error(i(419)),l.stack="",l.digest=w,Aa({value:l,source:null,stack:null}),r=sh(t,r,a)}else if(kt||_i(t,r,a,!1),w=(a&t.childLanes)!==0,kt||w){if(w=ot,w!==null&&(l=Gr(w,a),l!==0&&l!==R.retryLane))throw R.retryLane=l,Bs(t,l),ln(w,t,l),Wf;Ph(O)||Pl(),r=sh(t,r,a)}else Ph(O)?(r.flags|=192,r.child=t.child,r=null):(t=R.treeContext,ct=Bn(O.nextSibling),zt=r,Ge=!0,Kr=null,qn=!1,t!==null&&L0(r,t),r=rh(r,l.children),r.flags|=4096);return r}return f?(ts(),O=l.fallback,f=r.mode,R=t.child,V=R.sibling,l=br(R,{mode:"hidden",children:l.children}),l.subtreeFlags=R.subtreeFlags&65011712,V!==null?O=br(V,O):(O=Us(O,f,a,null),O.flags|=2),O.return=r,l.return=r,l.sibling=O,r.child=l,Ba(null,l),l=r.child,O=t.child.memoizedState,O===null?O=th(a):(f=O.cachePool,f!==null?(R=At._currentValue,f=f.parent!==R?{parent:R,pool:R}:f):f=I0(),O={baseLanes:O.baseLanes|a,cachePool:f}),l.memoizedState=O,l.childLanes=nh(t,w,a),r.memoizedState=eh,Ba(t.child,l)):(es(r),a=t.child,t=a.sibling,a=br(a,{mode:"visible",children:l.children}),a.return=r,a.sibling=null,t!==null&&(w=r.deletions,w===null?(r.deletions=[t],r.flags|=16):w.push(t)),r.child=a,r.memoizedState=null,a)}function rh(t,r){return r=kl({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function kl(t,r){return t=mn(22,t,null,r),t.lanes=0,t}function sh(t,r,a){return Vs(r,t.child,null,a),t=rh(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function ey(t,r,a){t.lanes|=r;var l=t.alternate;l!==null&&(l.lanes|=r),xf(t.return,r,a)}function ih(t,r,a,l,f,y){var w=t.memoizedState;w===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:f,treeForkCount:y}:(w.isBackwards=r,w.rendering=null,w.renderingStartTime=0,w.last=l,w.tail=a,w.tailMode=f,w.treeForkCount=y)}function ty(t,r,a){var l=r.pendingProps,f=l.revealOrder,y=l.tail;l=l.children;var w=wt.current,O=(w&2)!==0;if(O?(w=w&1|2,r.flags|=128):w&=1,Me(wt,w),$t(t,r,l,a),l=Ge?Oa:0,!O&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&ey(t,a,r);else if(t.tag===19)ey(t,a,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(f){case"forwards":for(a=r.child,f=null;a!==null;)t=a.alternate,t!==null&&yl(t)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),ih(r,!1,f,a,y,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(t=f.alternate,t!==null&&yl(t)===null){r.child=f;break}t=f.sibling,f.sibling=a,a=f,f=t}ih(r,!0,a,null,y,l);break;case"together":ih(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function Er(t,r,a){if(t!==null&&(r.dependencies=t.dependencies),ss|=r.lanes,(a&r.childLanes)===0)if(t!==null){if(_i(t,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(t!==null&&r.child!==t.child)throw Error(i(153));if(r.child!==null){for(t=r.child,a=br(t,t.pendingProps),r.child=a,a.return=r;t.sibling!==null;)t=t.sibling,a=a.sibling=br(t,t.pendingProps),a.return=r;a.sibling=null}return r.child}function ah(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&ll(t)))}function aw(t,r,a){switch(r.tag){case 3:Re(r,r.stateNode.containerInfo),Qr(r,At,t.memoizedState.cache),zs();break;case 27:case 5:Ue(r);break;case 4:Re(r,r.stateNode.containerInfo);break;case 10:Qr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Cf(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(es(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Zp(t,r,a):(es(r),t=Er(t,r,a),t!==null?t.sibling:null);es(r);break;case 19:var f=(t.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(_i(t,r,a,!1),l=(a&r.childLanes)!==0),f){if(l)return ty(t,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Me(wt,wt.current),l)break;return null;case 22:return r.lanes=0,Yp(t,r,a,r.pendingProps);case 24:Qr(r,At,t.memoizedState.cache)}return Er(t,r,a)}function ny(t,r,a){if(t!==null)if(t.memoizedProps!==r.pendingProps)kt=!0;else{if(!ah(t,a)&&(r.flags&128)===0)return kt=!1,aw(t,r,a);kt=(t.flags&131072)!==0}else kt=!1,Ge&&(r.flags&1048576)!==0&&D0(r,Oa,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(t=Fs(r.elementType),r.type=t,typeof t=="function")ff(t)?(l=Ks(t,l),r.tag=1,r=Xp(null,r,t,l,a)):(r.tag=0,r=Zf(null,r,t,l,a));else{if(t!=null){var f=t.$$typeof;if(f===te){r.tag=11,r=Fp(null,r,t,l,a);break e}else if(f===ae){r.tag=14,r=Gp(null,r,t,l,a);break e}}throw r=Se(t)||t,Error(i(306,r,""))}}return r;case 0:return Zf(t,r,r.type,r.pendingProps,a);case 1:return l=r.type,f=Ks(l,r.pendingProps),Xp(t,r,l,f,a);case 3:e:{if(Re(r,r.stateNode.containerInfo),t===null)throw Error(i(387));l=r.pendingProps;var y=r.memoizedState;f=y.element,Af(t,r),Ra(r,l,null,a);var w=r.memoizedState;if(l=w.cache,Qr(r,At,l),l!==y.cache&&vf(r,[At],a,!0),Ma(),l=w.element,y.isDehydrated)if(y={element:l,isDehydrated:!1,cache:w.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=Wp(t,r,l,a);break e}else if(l!==f){f=Rn(Error(i(424)),r),Aa(f),r=Wp(t,r,l,a);break e}else{switch(t=r.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(ct=Bn(t.firstChild),zt=r,Ge=!0,Kr=null,qn=!0,a=Y0(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(zs(),l===f){r=Er(t,r,a);break e}$t(t,r,l,a)}r=r.child}return r;case 26:return jl(t,r),t===null?(a=dg(r.type,null,r.pendingProps,null))?r.memoizedState=a:Ge||(a=r.type,t=r.pendingProps,l=Fl(Ct.current).createElement(a),l[at]=r,l[gt]=t,Ht(l,a,t),L(l),r.stateNode=l):r.memoizedState=dg(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return Ue(r),t===null&&Ge&&(l=r.stateNode=ug(r.type,r.pendingProps,Ct.current),zt=r,qn=!0,f=ct,cs(r.type)?(Uh=f,ct=Bn(l.firstChild)):ct=f),$t(t,r,r.pendingProps.children,a),jl(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&Ge&&((f=l=ct)&&(l=qw(l,r.type,r.pendingProps,qn),l!==null?(r.stateNode=l,zt=r,ct=Bn(l.firstChild),qn=!1,f=!0):f=!1),f||Jr(r)),Ue(r),f=r.type,y=r.pendingProps,w=t!==null?t.memoizedProps:null,l=y.children,Dh(f,y)?l=null:w!==null&&Dh(f,w)&&(r.flags|=32),r.memoizedState!==null&&(f=Rf(t,r,X_,null,null,a),Za._currentValue=f),jl(t,r),$t(t,r,l,a),r.child;case 6:return t===null&&Ge&&((t=a=ct)&&(a=Pw(a,r.pendingProps,qn),a!==null?(r.stateNode=a,zt=r,ct=null,t=!0):t=!1),t||Jr(r)),null;case 13:return Zp(t,r,a);case 4:return Re(r,r.stateNode.containerInfo),l=r.pendingProps,t===null?r.child=Vs(r,null,l,a):$t(t,r,l,a),r.child;case 11:return Fp(t,r,r.type,r.pendingProps,a);case 7:return $t(t,r,r.pendingProps,a),r.child;case 8:return $t(t,r,r.pendingProps.children,a),r.child;case 12:return $t(t,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,Qr(r,r.type,l.value),$t(t,r,l.children,a),r.child;case 9:return f=r.type._context,l=r.pendingProps.children,$s(r),f=It(f),l=l(f),r.flags|=1,$t(t,r,l,a),r.child;case 14:return Gp(t,r,r.type,r.pendingProps,a);case 15:return Vp(t,r,r.type,r.pendingProps,a);case 19:return ty(t,r,a);case 31:return iw(t,r,a);case 22:return Yp(t,r,a,r.pendingProps);case 24:return $s(r),l=It(At),t===null?(f=Sf(),f===null&&(f=ot,y=_f(),f.pooledCache=y,y.refCount++,y!==null&&(f.pooledCacheLanes|=a),f=y),r.memoizedState={parent:l,cache:f},Of(r),Qr(r,At,f)):((t.lanes&a)!==0&&(Af(t,r),Ra(r,null,null,a),Ma()),f=t.memoizedState,y=r.memoizedState,f.parent!==l?(f={parent:l,cache:l},r.memoizedState=f,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=f),Qr(r,At,l)):(l=y.cache,Qr(r,At,l),l!==f.cache&&vf(r,[At],a,!0))),$t(t,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Or(t){t.flags|=4}function oh(t,r,a,l,f){if((r=(t.mode&32)!==0)&&(r=!1),r){if(t.flags|=16777216,(f&335544128)===f)if(t.stateNode.complete)t.flags|=8192;else if(Ny())t.flags|=8192;else throw Gs=hl,Ef}else t.flags&=-16777217}function ry(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!bg(r))if(Ny())t.flags|=8192;else throw Gs=hl,Ef}function Nl(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?oi():536870912,t.lanes|=r,Ri|=r)}function Ua(t,r){if(!Ge)switch(t.tailMode){case"hidden":r=t.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:l.sibling=null}}function ut(t){var r=t.alternate!==null&&t.alternate.child===t.child,a=0,l=0;if(r)for(var f=t.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags&65011712,l|=f.flags&65011712,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=l,t.childLanes=a,r}function ow(t,r,a){var l=r.pendingProps;switch(pf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(r),null;case 1:return ut(r),null;case 3:return a=r.stateNode,l=null,t!==null&&(l=t.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),_r(At),ce(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(t===null||t.child===null)&&(vi(r)?Or(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,gf())),ut(r),null;case 26:var f=r.type,y=r.memoizedState;return t===null?(Or(r),y!==null?(ut(r),ry(r,y)):(ut(r),oh(r,f,null,l,a))):y?y!==t.memoizedState?(Or(r),ut(r),ry(r,y)):(ut(r),r.flags&=-16777217):(t=t.memoizedProps,t!==l&&Or(r),ut(r),oh(r,f,t,l,a)),null;case 27:if(Xe(r),a=Ct.current,f=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==l&&Or(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ut(r),null}t=We.current,vi(r)?q0(r):(t=ug(f,l,a),r.stateNode=t,Or(r))}return ut(r),null;case 5:if(Xe(r),f=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==l&&Or(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ut(r),null}if(y=We.current,vi(r))q0(r);else{var w=Fl(Ct.current);switch(y){case 1:y=w.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:y=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":y=w.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":y=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":y=w.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof l.is=="string"?w.createElement("select",{is:l.is}):w.createElement("select"),l.multiple?y.multiple=!0:l.size&&(y.size=l.size);break;default:y=typeof l.is=="string"?w.createElement(f,{is:l.is}):w.createElement(f)}}y[at]=r,y[gt]=l;e:for(w=r.child;w!==null;){if(w.tag===5||w.tag===6)y.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===r)break e;for(;w.sibling===null;){if(w.return===null||w.return===r)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}r.stateNode=y;e:switch(Ht(y,f,l),f){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Or(r)}}return ut(r),oh(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,a),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==l&&Or(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(i(166));if(t=Ct.current,vi(r)){if(t=r.stateNode,a=r.memoizedProps,l=null,f=zt,f!==null)switch(f.tag){case 27:case 5:l=f.memoizedProps}t[at]=r,t=!!(t.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Zy(t.nodeValue,a)),t||Jr(r,!0)}else t=Fl(t).createTextNode(l),t[at]=r,r.stateNode=t}return ut(r),null;case 31:if(a=r.memoizedState,t===null||t.memoizedState!==null){if(l=vi(r),a!==null){if(t===null){if(!l)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[at]=r}else zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),t=!1}else a=gf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=a),t=!0;if(!t)return r.flags&256?(yn(r),r):(yn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ut(r),null;case 13:if(l=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(f=vi(r),l!==null&&l.dehydrated!==null){if(t===null){if(!f)throw Error(i(318));if(f=r.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[at]=r}else zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),f=!1}else f=gf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=f),f=!0;if(!f)return r.flags&256?(yn(r),r):(yn(r),null)}return yn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=l!==null,t=t!==null&&t.memoizedState!==null,a&&(l=r.child,f=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(f=l.alternate.memoizedState.cachePool.pool),y=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(y=l.memoizedState.cachePool.pool),y!==f&&(l.flags|=2048)),a!==t&&a&&(r.child.flags|=8192),Nl(r,r.updateQueue),ut(r),null);case 4:return ce(),t===null&&Nh(r.stateNode.containerInfo),ut(r),null;case 10:return _r(r.type),ut(r),null;case 19:if(Ne(wt),l=r.memoizedState,l===null)return ut(r),null;if(f=(r.flags&128)!==0,y=l.rendering,y===null)if(f)Ua(l,!1);else{if(xt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(y=yl(t),y!==null){for(r.flags|=128,Ua(l,!1),t=y.updateQueue,r.updateQueue=t,Nl(r,t),r.subtreeFlags=0,t=a,a=r.child;a!==null;)C0(a,t),a=a.sibling;return Me(wt,wt.current&1|2),Ge&&xr(r,l.treeForkCount),r.child}t=t.sibling}l.tail!==null&&ft()>Dl&&(r.flags|=128,f=!0,Ua(l,!1),r.lanes=4194304)}else{if(!f)if(t=yl(y),t!==null){if(r.flags|=128,f=!0,t=t.updateQueue,r.updateQueue=t,Nl(r,t),Ua(l,!0),l.tail===null&&l.tailMode==="hidden"&&!y.alternate&&!Ge)return ut(r),null}else 2*ft()-l.renderingStartTime>Dl&&a!==536870912&&(r.flags|=128,f=!0,Ua(l,!1),r.lanes=4194304);l.isBackwards?(y.sibling=r.child,r.child=y):(t=l.last,t!==null?t.sibling=y:r.child=y,l.last=y)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=ft(),t.sibling=null,a=wt.current,Me(wt,f?a&1|2:a&1),Ge&&xr(r,l.treeForkCount),t):(ut(r),null);case 22:case 23:return yn(r),Tf(),l=r.memoizedState!==null,t!==null?t.memoizedState!==null!==l&&(r.flags|=8192):l&&(r.flags|=8192),l?(a&536870912)!==0&&(r.flags&128)===0&&(ut(r),r.subtreeFlags&6&&(r.flags|=8192)):ut(r),a=r.updateQueue,a!==null&&Nl(r,a.retryQueue),a=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),l=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),l!==a&&(r.flags|=2048),t!==null&&Ne(Hs),null;case 24:return a=null,t!==null&&(a=t.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),_r(At),ut(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function lw(t,r){switch(pf(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return _r(At),ce(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return Xe(r),null;case 31:if(r.memoizedState!==null){if(yn(r),r.alternate===null)throw Error(i(340));zs()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(yn(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));zs()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return Ne(wt),null;case 4:return ce(),null;case 10:return _r(r.type),null;case 22:case 23:return yn(r),Tf(),t!==null&&Ne(Hs),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return _r(At),null;case 25:return null;default:return null}}function sy(t,r){switch(pf(r),r.tag){case 3:_r(At),ce();break;case 26:case 27:case 5:Xe(r);break;case 4:ce();break;case 31:r.memoizedState!==null&&yn(r);break;case 13:yn(r);break;case 19:Ne(wt);break;case 10:_r(r.type);break;case 22:case 23:yn(r),Tf(),t!==null&&Ne(Hs);break;case 24:_r(At)}}function za(t,r){try{var a=r.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var f=l.next;a=f;do{if((a.tag&t)===t){l=void 0;var y=a.create,w=a.inst;l=y(),w.destroy=l}a=a.next}while(a!==f)}}catch(O){et(r,r.return,O)}}function ns(t,r,a){try{var l=r.updateQueue,f=l!==null?l.lastEffect:null;if(f!==null){var y=f.next;l=y;do{if((l.tag&t)===t){var w=l.inst,O=w.destroy;if(O!==void 0){w.destroy=void 0,f=r;var R=a,V=O;try{V()}catch(Z){et(f,R,Z)}}}l=l.next}while(l!==y)}}catch(Z){et(r,r.return,Z)}}function iy(t){var r=t.updateQueue;if(r!==null){var a=t.stateNode;try{J0(r,a)}catch(l){et(t,t.return,l)}}}function ay(t,r,a){a.props=Ks(t.type,t.memoizedProps),a.state=t.memoizedState;try{a.componentWillUnmount()}catch(l){et(t,r,l)}}function Ia(t,r){try{var a=t.ref;if(a!==null){switch(t.tag){case 26:case 27:case 5:var l=t.stateNode;break;case 30:l=t.stateNode;break;default:l=t.stateNode}typeof a=="function"?t.refCleanup=a(l):a.current=l}}catch(f){et(t,r,f)}}function sr(t,r){var a=t.ref,l=t.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(f){et(t,r,f)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(f){et(t,r,f)}else a.current=null}function oy(t){var r=t.type,a=t.memoizedProps,l=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(f){et(t,t.return,f)}}function lh(t,r,a){try{var l=t.stateNode;Tw(l,t.type,a,r),l[gt]=r}catch(f){et(t,t.return,f)}}function ly(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&cs(t.type)||t.tag===4}function ch(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||ly(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&cs(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function uh(t,r,a){var l=t.tag;if(l===5||l===6)t=t.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(t,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(t),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=yr));else if(l!==4&&(l===27&&cs(t.type)&&(a=t.stateNode,r=null),t=t.child,t!==null))for(uh(t,r,a),t=t.sibling;t!==null;)uh(t,r,a),t=t.sibling}function Tl(t,r,a){var l=t.tag;if(l===5||l===6)t=t.stateNode,r?a.insertBefore(t,r):a.appendChild(t);else if(l!==4&&(l===27&&cs(t.type)&&(a=t.stateNode),t=t.child,t!==null))for(Tl(t,r,a),t=t.sibling;t!==null;)Tl(t,r,a),t=t.sibling}function cy(t){var r=t.stateNode,a=t.memoizedProps;try{for(var l=t.type,f=r.attributes;f.length;)r.removeAttributeNode(f[0]);Ht(r,l,a),r[at]=t,r[gt]=a}catch(y){et(t,t.return,y)}}var Ar=!1,Nt=!1,fh=!1,uy=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function cw(t,r){if(t=t.containerInfo,Mh=Xl,t=w0(t),rf(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var f=l.anchorOffset,y=l.focusNode;l=l.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var w=0,O=-1,R=-1,V=0,Z=0,ie=t,Y=null;t:for(;;){for(var Q;ie!==a||f!==0&&ie.nodeType!==3||(O=w+f),ie!==y||l!==0&&ie.nodeType!==3||(R=w+l),ie.nodeType===3&&(w+=ie.nodeValue.length),(Q=ie.firstChild)!==null;)Y=ie,ie=Q;for(;;){if(ie===t)break t;if(Y===a&&++V===f&&(O=w),Y===y&&++Z===l&&(R=w),(Q=ie.nextSibling)!==null)break;ie=Y,Y=ie.parentNode}ie=Q}a=O===-1||R===-1?null:{start:O,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(Rh={focusedElem:t,selectionRange:a},Xl=!1,Pt=r;Pt!==null;)if(r=Pt,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Pt=t;else for(;Pt!==null;){switch(r=Pt,y=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(a=0;a<t.length;a++)f=t[a],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&y!==null){t=void 0,a=r,f=y.memoizedProps,y=y.memoizedState,l=a.stateNode;try{var ve=Ks(a.type,f);t=l.getSnapshotBeforeUpdate(ve,y),l.__reactInternalSnapshotBeforeUpdate=t}catch(Te){et(a,a.return,Te)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,a=t.nodeType,a===9)qh(t);else if(a===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":qh(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(i(163))}if(t=r.sibling,t!==null){t.return=r.return,Pt=t;break}Pt=r.return}}function fy(t,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:kr(t,a),l&4&&za(5,a);break;case 1:if(kr(t,a),l&4)if(t=a.stateNode,r===null)try{t.componentDidMount()}catch(w){et(a,a.return,w)}else{var f=Ks(a.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(f,r,t.__reactInternalSnapshotBeforeUpdate)}catch(w){et(a,a.return,w)}}l&64&&iy(a),l&512&&Ia(a,a.return);break;case 3:if(kr(t,a),l&64&&(t=a.updateQueue,t!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{J0(t,r)}catch(w){et(a,a.return,w)}}break;case 27:r===null&&l&4&&cy(a);case 26:case 5:kr(t,a),r===null&&l&4&&oy(a),l&512&&Ia(a,a.return);break;case 12:kr(t,a);break;case 31:kr(t,a),l&4&&my(t,a);break;case 13:kr(t,a),l&4&&py(t,a),l&64&&(t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(a=bw.bind(null,a),Bw(t,a))));break;case 22:if(l=a.memoizedState!==null||Ar,!l){r=r!==null&&r.memoizedState!==null||Nt,f=Ar;var y=Nt;Ar=l,(Nt=r)&&!y?Nr(t,a,(a.subtreeFlags&8772)!==0):kr(t,a),Ar=f,Nt=y}break;case 30:break;default:kr(t,a)}}function hy(t){var r=t.alternate;r!==null&&(t.alternate=null,hy(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&li(r)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var ht=null,rn=!1;function jr(t,r,a){for(a=a.child;a!==null;)dy(t,r,a),a=a.sibling}function dy(t,r,a){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(Ns,a)}catch{}switch(a.tag){case 26:Nt||sr(a,r),jr(t,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Nt||sr(a,r);var l=ht,f=rn;cs(a.type)&&(ht=a.stateNode,rn=!1),jr(t,r,a),Qa(a.stateNode),ht=l,rn=f;break;case 5:Nt||sr(a,r);case 6:if(l=ht,f=rn,ht=null,jr(t,r,a),ht=l,rn=f,ht!==null)if(rn)try{(ht.nodeType===9?ht.body:ht.nodeName==="HTML"?ht.ownerDocument.body:ht).removeChild(a.stateNode)}catch(y){et(a,r,y)}else try{ht.removeChild(a.stateNode)}catch(y){et(a,r,y)}break;case 18:ht!==null&&(rn?(t=ht,ig(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,a.stateNode),Ii(t)):ig(ht,a.stateNode));break;case 4:l=ht,f=rn,ht=a.stateNode.containerInfo,rn=!0,jr(t,r,a),ht=l,rn=f;break;case 0:case 11:case 14:case 15:ns(2,a,r),Nt||ns(4,a,r),jr(t,r,a);break;case 1:Nt||(sr(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&ay(a,r,l)),jr(t,r,a);break;case 21:jr(t,r,a);break;case 22:Nt=(l=Nt)||a.memoizedState!==null,jr(t,r,a),Nt=l;break;default:jr(t,r,a)}}function my(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Ii(t)}catch(a){et(r,r.return,a)}}}function py(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Ii(t)}catch(a){et(r,r.return,a)}}function uw(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new uy),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new uy),r;default:throw Error(i(435,t.tag))}}function Cl(t,r){var a=uw(t);r.forEach(function(l){if(!a.has(l)){a.add(l);var f=xw.bind(null,t,l);l.then(f,f)}})}function sn(t,r){var a=r.deletions;if(a!==null)for(var l=0;l<a.length;l++){var f=a[l],y=t,w=r,O=w;e:for(;O!==null;){switch(O.tag){case 27:if(cs(O.type)){ht=O.stateNode,rn=!1;break e}break;case 5:ht=O.stateNode,rn=!1;break e;case 3:case 4:ht=O.stateNode.containerInfo,rn=!0;break e}O=O.return}if(ht===null)throw Error(i(160));dy(y,w,f),ht=null,rn=!1,y=f.alternate,y!==null&&(y.return=null),f.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)yy(r,t),r=r.sibling}var Kn=null;function yy(t,r){var a=t.alternate,l=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:sn(r,t),an(t),l&4&&(ns(3,t,t.return),za(3,t),ns(5,t,t.return));break;case 1:sn(r,t),an(t),l&512&&(Nt||a===null||sr(a,a.return)),l&64&&Ar&&(t=t.updateQueue,t!==null&&(l=t.callbacks,l!==null&&(a=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var f=Kn;if(sn(r,t),an(t),l&512&&(Nt||a===null||sr(a,a.return)),l&4){var y=a!==null?a.memoizedState:null;if(l=t.memoizedState,a===null)if(l===null)if(t.stateNode===null){e:{l=t.type,a=t.memoizedProps,f=f.ownerDocument||f;t:switch(l){case"title":y=f.getElementsByTagName("title")[0],(!y||y[Rt]||y[at]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=f.createElement(l),f.head.insertBefore(y,f.querySelector("head > title"))),Ht(y,l,a),y[at]=t,L(y),l=y;break e;case"link":var w=yg("link","href",f).get(l+(a.href||""));if(w){for(var O=0;O<w.length;O++)if(y=w[O],y.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&y.getAttribute("rel")===(a.rel==null?null:a.rel)&&y.getAttribute("title")===(a.title==null?null:a.title)&&y.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){w.splice(O,1);break t}}y=f.createElement(l),Ht(y,l,a),f.head.appendChild(y);break;case"meta":if(w=yg("meta","content",f).get(l+(a.content||""))){for(O=0;O<w.length;O++)if(y=w[O],y.getAttribute("content")===(a.content==null?null:""+a.content)&&y.getAttribute("name")===(a.name==null?null:a.name)&&y.getAttribute("property")===(a.property==null?null:a.property)&&y.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&y.getAttribute("charset")===(a.charSet==null?null:a.charSet)){w.splice(O,1);break t}}y=f.createElement(l),Ht(y,l,a),f.head.appendChild(y);break;default:throw Error(i(468,l))}y[at]=t,L(y),l=y}t.stateNode=l}else gg(f,t.type,t.stateNode);else t.stateNode=pg(f,l,t.memoizedProps);else y!==l?(y===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):y.count--,l===null?gg(f,t.type,t.stateNode):pg(f,l,t.memoizedProps)):l===null&&t.stateNode!==null&&lh(t,t.memoizedProps,a.memoizedProps)}break;case 27:sn(r,t),an(t),l&512&&(Nt||a===null||sr(a,a.return)),a!==null&&l&4&&lh(t,t.memoizedProps,a.memoizedProps);break;case 5:if(sn(r,t),an(t),l&512&&(Nt||a===null||sr(a,a.return)),t.flags&32){f=t.stateNode;try{ui(f,"")}catch(ve){et(t,t.return,ve)}}l&4&&t.stateNode!=null&&(f=t.memoizedProps,lh(t,f,a!==null?a.memoizedProps:f)),l&1024&&(fh=!0);break;case 6:if(sn(r,t),an(t),l&4){if(t.stateNode===null)throw Error(i(162));l=t.memoizedProps,a=t.stateNode;try{a.nodeValue=l}catch(ve){et(t,t.return,ve)}}break;case 3:if(Yl=null,f=Kn,Kn=Gl(r.containerInfo),sn(r,t),Kn=f,an(t),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Ii(r.containerInfo)}catch(ve){et(t,t.return,ve)}fh&&(fh=!1,gy(t));break;case 4:l=Kn,Kn=Gl(t.stateNode.containerInfo),sn(r,t),an(t),Kn=l;break;case 12:sn(r,t),an(t);break;case 31:sn(r,t),an(t),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,Cl(t,l)));break;case 13:sn(r,t),an(t),t.child.flags&8192&&t.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Rl=ft()),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,Cl(t,l)));break;case 22:f=t.memoizedState!==null;var R=a!==null&&a.memoizedState!==null,V=Ar,Z=Nt;if(Ar=V||f,Nt=Z||R,sn(r,t),Nt=Z,Ar=V,an(t),l&8192)e:for(r=t.stateNode,r._visibility=f?r._visibility&-2:r._visibility|1,f&&(a===null||R||Ar||Nt||Js(t)),a=null,r=t;;){if(r.tag===5||r.tag===26){if(a===null){R=a=r;try{if(y=R.stateNode,f)w=y.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none";else{O=R.stateNode;var ie=R.memoizedProps.style,Y=ie!=null&&ie.hasOwnProperty("display")?ie.display:null;O.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(ve){et(R,R.return,ve)}}}else if(r.tag===6){if(a===null){R=r;try{R.stateNode.nodeValue=f?"":R.memoizedProps}catch(ve){et(R,R.return,ve)}}}else if(r.tag===18){if(a===null){R=r;try{var Q=R.stateNode;f?ag(Q,!0):ag(R.stateNode,!1)}catch(ve){et(R,R.return,ve)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===t)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break e;for(;r.sibling===null;){if(r.return===null||r.return===t)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}l&4&&(l=t.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Cl(t,a))));break;case 19:sn(r,t),an(t),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,Cl(t,l)));break;case 30:break;case 21:break;default:sn(r,t),an(t)}}function an(t){var r=t.flags;if(r&2){try{for(var a,l=t.return;l!==null;){if(ly(l)){a=l;break}l=l.return}if(a==null)throw Error(i(160));switch(a.tag){case 27:var f=a.stateNode,y=ch(t);Tl(t,y,f);break;case 5:var w=a.stateNode;a.flags&32&&(ui(w,""),a.flags&=-33);var O=ch(t);Tl(t,O,w);break;case 3:case 4:var R=a.stateNode.containerInfo,V=ch(t);uh(t,V,R);break;default:throw Error(i(161))}}catch(Z){et(t,t.return,Z)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function gy(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;gy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function kr(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)fy(t,r.alternate,r),r=r.sibling}function Js(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:ns(4,r,r.return),Js(r);break;case 1:sr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&ay(r,r.return,a),Js(r);break;case 27:Qa(r.stateNode);case 26:case 5:sr(r,r.return),Js(r);break;case 22:r.memoizedState===null&&Js(r);break;case 30:Js(r);break;default:Js(r)}t=t.sibling}}function Nr(t,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var l=r.alternate,f=t,y=r,w=y.flags;switch(y.tag){case 0:case 11:case 15:Nr(f,y,a),za(4,y);break;case 1:if(Nr(f,y,a),l=y,f=l.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(V){et(l,l.return,V)}if(l=y,f=l.updateQueue,f!==null){var O=l.stateNode;try{var R=f.shared.hiddenCallbacks;if(R!==null)for(f.shared.hiddenCallbacks=null,f=0;f<R.length;f++)K0(R[f],O)}catch(V){et(l,l.return,V)}}a&&w&64&&iy(y),Ia(y,y.return);break;case 27:cy(y);case 26:case 5:Nr(f,y,a),a&&l===null&&w&4&&oy(y),Ia(y,y.return);break;case 12:Nr(f,y,a);break;case 31:Nr(f,y,a),a&&w&4&&my(f,y);break;case 13:Nr(f,y,a),a&&w&4&&py(f,y);break;case 22:y.memoizedState===null&&Nr(f,y,a),Ia(y,y.return);break;case 30:break;default:Nr(f,y,a)}r=r.sibling}}function hh(t,r){var a=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),t=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(t=r.memoizedState.cachePool.pool),t!==a&&(t!=null&&t.refCount++,a!=null&&ja(a))}function dh(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&ja(t))}function Jn(t,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)by(t,r,a,l),r=r.sibling}function by(t,r,a,l){var f=r.flags;switch(r.tag){case 0:case 11:case 15:Jn(t,r,a,l),f&2048&&za(9,r);break;case 1:Jn(t,r,a,l);break;case 3:Jn(t,r,a,l),f&2048&&(t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&ja(t)));break;case 12:if(f&2048){Jn(t,r,a,l),t=r.stateNode;try{var y=r.memoizedProps,w=y.id,O=y.onPostCommit;typeof O=="function"&&O(w,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(R){et(r,r.return,R)}}else Jn(t,r,a,l);break;case 31:Jn(t,r,a,l);break;case 13:Jn(t,r,a,l);break;case 23:break;case 22:y=r.stateNode,w=r.alternate,r.memoizedState!==null?y._visibility&2?Jn(t,r,a,l):$a(t,r):y._visibility&2?Jn(t,r,a,l):(y._visibility|=2,Ti(t,r,a,l,(r.subtreeFlags&10256)!==0||!1)),f&2048&&hh(w,r);break;case 24:Jn(t,r,a,l),f&2048&&dh(r.alternate,r);break;default:Jn(t,r,a,l)}}function Ti(t,r,a,l,f){for(f=f&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=t,w=r,O=a,R=l,V=w.flags;switch(w.tag){case 0:case 11:case 15:Ti(y,w,O,R,f),za(8,w);break;case 23:break;case 22:var Z=w.stateNode;w.memoizedState!==null?Z._visibility&2?Ti(y,w,O,R,f):$a(y,w):(Z._visibility|=2,Ti(y,w,O,R,f)),f&&V&2048&&hh(w.alternate,w);break;case 24:Ti(y,w,O,R,f),f&&V&2048&&dh(w.alternate,w);break;default:Ti(y,w,O,R,f)}r=r.sibling}}function $a(t,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=t,l=r,f=l.flags;switch(l.tag){case 22:$a(a,l),f&2048&&hh(l.alternate,l);break;case 24:$a(a,l),f&2048&&dh(l.alternate,l);break;default:$a(a,l)}r=r.sibling}}var Ha=8192;function Ci(t,r,a){if(t.subtreeFlags&Ha)for(t=t.child;t!==null;)xy(t,r,a),t=t.sibling}function xy(t,r,a){switch(t.tag){case 26:Ci(t,r,a),t.flags&Ha&&t.memoizedState!==null&&Qw(a,Kn,t.memoizedState,t.memoizedProps);break;case 5:Ci(t,r,a);break;case 3:case 4:var l=Kn;Kn=Gl(t.stateNode.containerInfo),Ci(t,r,a),Kn=l;break;case 22:t.memoizedState===null&&(l=t.alternate,l!==null&&l.memoizedState!==null?(l=Ha,Ha=16777216,Ci(t,r,a),Ha=l):Ci(t,r,a));break;default:Ci(t,r,a)}}function vy(t){var r=t.alternate;if(r!==null&&(t=r.child,t!==null)){r.child=null;do r=t.sibling,t.sibling=null,t=r;while(t!==null)}}function Fa(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Pt=l,wy(l,t)}vy(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)_y(t),t=t.sibling}function _y(t){switch(t.tag){case 0:case 11:case 15:Fa(t),t.flags&2048&&ns(9,t,t.return);break;case 3:Fa(t);break;case 12:Fa(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,Ml(t)):Fa(t);break;default:Fa(t)}}function Ml(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Pt=l,wy(l,t)}vy(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:ns(8,r,r.return),Ml(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Ml(r));break;default:Ml(r)}t=t.sibling}}function wy(t,r){for(;Pt!==null;){var a=Pt;switch(a.tag){case 0:case 11:case 15:ns(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:ja(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Pt=l;else e:for(a=t;Pt!==null;){l=Pt;var f=l.sibling,y=l.return;if(hy(l),l===a){Pt=null;break e}if(f!==null){f.return=y,Pt=f;break e}Pt=y}}}var fw={getCacheForType:function(t){var r=It(At),a=r.data.get(t);return a===void 0&&(a=t(),r.data.set(t,a)),a},cacheSignal:function(){return It(At).controller.signal}},hw=typeof WeakMap=="function"?WeakMap:Map,Qe=0,ot=null,ze=null,He=0,Ze=0,gn=null,rs=!1,Mi=!1,mh=!1,Tr=0,xt=0,ss=0,Qs=0,ph=0,bn=0,Ri=0,Ga=null,on=null,yh=!1,Rl=0,Sy=0,Dl=1/0,Ll=null,is=null,Dt=0,as=null,Di=null,Cr=0,gh=0,bh=null,Ey=null,Va=0,xh=null;function xn(){return(Qe&2)!==0&&He!==0?He&-He:H.T!==null?Oh():ma()}function Oy(){if(bn===0)if((He&536870912)===0||Ge){var t=dr;dr<<=1,(dr&3932160)===0&&(dr=262144),bn=t}else bn=536870912;return t=pn.current,t!==null&&(t.flags|=32),bn}function ln(t,r,a){(t===ot&&(Ze===2||Ze===9)||t.cancelPendingCommit!==null)&&(Li(t,0),os(t,He,bn,!1)),Gn(t,a),((Qe&2)===0||t!==ot)&&(t===ot&&((Qe&2)===0&&(Qs|=a),xt===4&&os(t,He,bn,!1)),ir(t))}function Ay(t,r,a){if((Qe&6)!==0)throw Error(i(327));var l=!a&&(r&127)===0&&(r&t.expiredLanes)===0||Cs(t,r),f=l?pw(t,r):_h(t,r,!0),y=l;do{if(f===0){Mi&&!l&&os(t,r,0,!1);break}else{if(a=t.current.alternate,y&&!dw(a)){f=_h(t,r,!1),y=!1;continue}if(f===2){if(y=r,t.errorRecoveryDisabledLanes&y)var w=0;else w=t.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){r=w;e:{var O=t;f=Ga;var R=O.current.memoizedState.isDehydrated;if(R&&(Li(O,w).flags|=256),w=_h(O,w,!1),w!==2){if(mh&&!R){O.errorRecoveryDisabledLanes|=y,Qs|=y,f=4;break e}y=on,on=f,y!==null&&(on===null?on=y:on.push.apply(on,y))}f=w}if(y=!1,f!==2)continue}}if(f===1){Li(t,0),os(t,r,0,!0);break}e:{switch(l=t,y=f,y){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:os(l,r,bn,!rs);break e;case 2:on=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(f=Rl+300-ft(),10<f)){if(os(l,r,bn,!rs),Ts(l,0,!0)!==0)break e;Cr=r,l.timeoutHandle=rg(jy.bind(null,l,a,on,Ll,yh,r,bn,Qs,Ri,rs,y,"Throttled",-0,0),f);break e}jy(l,a,on,Ll,yh,r,bn,Qs,Ri,rs,y,null,-0,0)}}break}while(!0);ir(t)}function jy(t,r,a,l,f,y,w,O,R,V,Z,ie,Y,Q){if(t.timeoutHandle=-1,ie=r.subtreeFlags,ie&8192||(ie&16785408)===16785408){ie={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:yr},xy(r,y,ie);var ve=(y&62914560)===y?Rl-ft():(y&4194048)===y?Sy-ft():0;if(ve=Xw(ie,ve),ve!==null){Cr=y,t.cancelPendingCommit=ve(Ly.bind(null,t,r,y,a,l,f,w,O,R,Z,ie,null,Y,Q)),os(t,y,w,!V);return}}Ly(t,r,y,a,l,f,w,O,R)}function dw(t){for(var r=t;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var f=a[l],y=f.getSnapshot;f=f.value;try{if(!dn(y(),f))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function os(t,r,a,l){r&=~ph,r&=~Qs,t.suspendedLanes|=r,t.pingedLanes&=~r,l&&(t.warmLanes|=r),l=t.expirationTimes;for(var f=r;0<f;){var y=31-Ft(f),w=1<<y;l[y]=-1,f&=~w}a!==0&&Fr(t,a,r)}function ql(){return(Qe&6)===0?(Ya(0),!1):!0}function vh(){if(ze!==null){if(Ze===0)var t=ze.return;else t=ze,vr=Is=null,qf(t),Oi=null,Na=0,t=ze;for(;t!==null;)sy(t.alternate,t),t=t.return;ze=null}}function Li(t,r){var a=t.timeoutHandle;a!==-1&&(t.timeoutHandle=-1,Rw(a)),a=t.cancelPendingCommit,a!==null&&(t.cancelPendingCommit=null,a()),Cr=0,vh(),ot=t,ze=a=br(t.current,null),He=r,Ze=0,gn=null,rs=!1,Mi=Cs(t,r),mh=!1,Ri=bn=ph=Qs=ss=xt=0,on=Ga=null,yh=!1,(r&8)!==0&&(r|=r&32);var l=t.entangledLanes;if(l!==0)for(t=t.entanglements,l&=r;0<l;){var f=31-Ft(l),y=1<<f;r|=t[f],l&=~y}return Tr=r,rl(),a}function ky(t,r){De=null,H.H=Pa,r===Ei||r===fl?(r=F0(),Ze=3):r===Ef?(r=F0(),Ze=4):Ze=r===Wf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,gn=r,ze===null&&(xt=1,Ol(t,Rn(r,t.current)))}function Ny(){var t=pn.current;return t===null?!0:(He&4194048)===He?Pn===null:(He&62914560)===He||(He&536870912)!==0?t===Pn:!1}function Ty(){var t=H.H;return H.H=Pa,t===null?Pa:t}function Cy(){var t=H.A;return H.A=fw,t}function Pl(){xt=4,rs||(He&4194048)!==He&&pn.current!==null||(Mi=!0),(ss&134217727)===0&&(Qs&134217727)===0||ot===null||os(ot,He,bn,!1)}function _h(t,r,a){var l=Qe;Qe|=2;var f=Ty(),y=Cy();(ot!==t||He!==r)&&(Ll=null,Li(t,r)),r=!1;var w=xt;e:do try{if(Ze!==0&&ze!==null){var O=ze,R=gn;switch(Ze){case 8:vh(),w=6;break e;case 3:case 2:case 9:case 6:pn.current===null&&(r=!0);var V=Ze;if(Ze=0,gn=null,qi(t,O,R,V),a&&Mi){w=0;break e}break;default:V=Ze,Ze=0,gn=null,qi(t,O,R,V)}}mw(),w=xt;break}catch(Z){ky(t,Z)}while(!0);return r&&t.shellSuspendCounter++,vr=Is=null,Qe=l,H.H=f,H.A=y,ze===null&&(ot=null,He=0,rl()),w}function mw(){for(;ze!==null;)My(ze)}function pw(t,r){var a=Qe;Qe|=2;var l=Ty(),f=Cy();ot!==t||He!==r?(Ll=null,Dl=ft()+500,Li(t,r)):Mi=Cs(t,r);e:do try{if(Ze!==0&&ze!==null){r=ze;var y=gn;t:switch(Ze){case 1:Ze=0,gn=null,qi(t,r,y,1);break;case 2:case 9:if($0(y)){Ze=0,gn=null,Ry(r);break}r=function(){Ze!==2&&Ze!==9||ot!==t||(Ze=7),ir(t)},y.then(r,r);break e;case 3:Ze=7;break e;case 4:Ze=5;break e;case 7:$0(y)?(Ze=0,gn=null,Ry(r)):(Ze=0,gn=null,qi(t,r,y,7));break;case 5:var w=null;switch(ze.tag){case 26:w=ze.memoizedState;case 5:case 27:var O=ze;if(w?bg(w):O.stateNode.complete){Ze=0,gn=null;var R=O.sibling;if(R!==null)ze=R;else{var V=O.return;V!==null?(ze=V,Bl(V)):ze=null}break t}}Ze=0,gn=null,qi(t,r,y,5);break;case 6:Ze=0,gn=null,qi(t,r,y,6);break;case 8:vh(),xt=6;break e;default:throw Error(i(462))}}yw();break}catch(Z){ky(t,Z)}while(!0);return vr=Is=null,H.H=l,H.A=f,Qe=a,ze!==null?0:(ot=null,He=0,rl(),xt)}function yw(){for(;ze!==null&&!zo();)My(ze)}function My(t){var r=ny(t.alternate,t,Tr);t.memoizedProps=t.pendingProps,r===null?Bl(t):ze=r}function Ry(t){var r=t,a=r.alternate;switch(r.tag){case 15:case 0:r=Qp(a,r,r.pendingProps,r.type,void 0,He);break;case 11:r=Qp(a,r,r.pendingProps,r.type.render,r.ref,He);break;case 5:qf(r);default:sy(a,r),r=ze=C0(r,Tr),r=ny(a,r,Tr)}t.memoizedProps=t.pendingProps,r===null?Bl(t):ze=r}function qi(t,r,a,l){vr=Is=null,qf(r),Oi=null,Na=0;var f=r.return;try{if(sw(t,f,r,a,He)){xt=1,Ol(t,Rn(a,t.current)),ze=null;return}}catch(y){if(f!==null)throw ze=f,y;xt=1,Ol(t,Rn(a,t.current)),ze=null;return}r.flags&32768?(Ge||l===1?t=!0:Mi||(He&536870912)!==0?t=!1:(rs=t=!0,(l===2||l===9||l===3||l===6)&&(l=pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),Dy(r,t)):Bl(r)}function Bl(t){var r=t;do{if((r.flags&32768)!==0){Dy(r,rs);return}t=r.return;var a=ow(r.alternate,r,Tr);if(a!==null){ze=a;return}if(r=r.sibling,r!==null){ze=r;return}ze=r=t}while(r!==null);xt===0&&(xt=5)}function Dy(t,r){do{var a=lw(t.alternate,t);if(a!==null){a.flags&=32767,ze=a;return}if(a=t.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(t=t.sibling,t!==null)){ze=t;return}ze=t=a}while(t!==null);xt=6,ze=null}function Ly(t,r,a,l,f,y,w,O,R){t.cancelPendingCommit=null;do Ul();while(Dt!==0);if((Qe&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(y=r.lanes|r.childLanes,y|=cf,Hr(t,a,y,w,O,R),t===ot&&(ze=ot=null,He=0),Di=r,as=t,Cr=a,gh=y,bh=f,Ey=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,vw(ii,function(){return zy(),null})):(t.callbackNode=null,t.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=H.T,H.T=null,f=J.p,J.p=2,w=Qe,Qe|=4;try{cw(t,r,a)}finally{Qe=w,J.p=f,H.T=l}}Dt=1,qy(),Py(),By()}}function qy(){if(Dt===1){Dt=0;var t=as,r=Di,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=H.T,H.T=null;var l=J.p;J.p=2;var f=Qe;Qe|=4;try{yy(r,t);var y=Rh,w=w0(t.containerInfo),O=y.focusedElem,R=y.selectionRange;if(w!==O&&O&&O.ownerDocument&&_0(O.ownerDocument.documentElement,O)){if(R!==null&&rf(O)){var V=R.start,Z=R.end;if(Z===void 0&&(Z=V),"selectionStart"in O)O.selectionStart=V,O.selectionEnd=Math.min(Z,O.value.length);else{var ie=O.ownerDocument||document,Y=ie&&ie.defaultView||window;if(Y.getSelection){var Q=Y.getSelection(),ve=O.textContent.length,Te=Math.min(R.start,ve),st=R.end===void 0?Te:Math.min(R.end,ve);!Q.extend&&Te>st&&(w=st,st=Te,Te=w);var I=v0(O,Te),P=v0(O,st);if(I&&P&&(Q.rangeCount!==1||Q.anchorNode!==I.node||Q.anchorOffset!==I.offset||Q.focusNode!==P.node||Q.focusOffset!==P.offset)){var G=ie.createRange();G.setStart(I.node,I.offset),Q.removeAllRanges(),Te>st?(Q.addRange(G),Q.extend(P.node,P.offset)):(G.setEnd(P.node,P.offset),Q.addRange(G))}}}}for(ie=[],Q=O;Q=Q.parentNode;)Q.nodeType===1&&ie.push({element:Q,left:Q.scrollLeft,top:Q.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<ie.length;O++){var ee=ie[O];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}Xl=!!Mh,Rh=Mh=null}finally{Qe=f,J.p=l,H.T=a}}t.current=r,Dt=2}}function Py(){if(Dt===2){Dt=0;var t=as,r=Di,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=H.T,H.T=null;var l=J.p;J.p=2;var f=Qe;Qe|=4;try{fy(t,r.alternate,r)}finally{Qe=f,J.p=l,H.T=a}}Dt=3}}function By(){if(Dt===4||Dt===3){Dt=0,si();var t=as,r=Di,a=Cr,l=Ey;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Dt=5:(Dt=0,Di=as=null,Uy(t,t.pendingLanes));var f=t.pendingLanes;if(f===0&&(is=null),Rs(a),r=r.stateNode,_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(Ns,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=H.T,f=J.p,J.p=2,H.T=null;try{for(var y=t.onRecoverableError,w=0;w<l.length;w++){var O=l[w];y(O.value,{componentStack:O.stack})}}finally{H.T=r,J.p=f}}(Cr&3)!==0&&Ul(),ir(t),f=t.pendingLanes,(a&261930)!==0&&(f&42)!==0?t===xh?Va++:(Va=0,xh=t):Va=0,Ya(0)}}function Uy(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,ja(r)))}function Ul(){return qy(),Py(),By(),zy()}function zy(){if(Dt!==5)return!1;var t=as,r=gh;gh=0;var a=Rs(Cr),l=H.T,f=J.p;try{J.p=32>a?32:a,H.T=null,a=bh,bh=null;var y=as,w=Cr;if(Dt=0,Di=as=null,Cr=0,(Qe&6)!==0)throw Error(i(331));var O=Qe;if(Qe|=4,_y(y.current),by(y,y.current,w,a),Qe=O,Ya(0,!1),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(Ns,y)}catch{}return!0}finally{J.p=f,H.T=l,Uy(t,r)}}function Iy(t,r,a){r=Rn(a,r),r=Xf(t.stateNode,r,2),t=Zr(t,r,2),t!==null&&(Gn(t,2),ir(t))}function et(t,r,a){if(t.tag===3)Iy(t,t,a);else for(;r!==null;){if(r.tag===3){Iy(r,t,a);break}else if(r.tag===1){var l=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(is===null||!is.has(l))){t=Rn(a,t),a=$p(2),l=Zr(r,a,2),l!==null&&(Hp(a,l,r,t),Gn(l,2),ir(l));break}}r=r.return}}function wh(t,r,a){var l=t.pingCache;if(l===null){l=t.pingCache=new hw;var f=new Set;l.set(r,f)}else f=l.get(r),f===void 0&&(f=new Set,l.set(r,f));f.has(a)||(mh=!0,f.add(a),t=gw.bind(null,t,r,a),r.then(t,t))}function gw(t,r,a){var l=t.pingCache;l!==null&&l.delete(r),t.pingedLanes|=t.suspendedLanes&a,t.warmLanes&=~a,ot===t&&(He&a)===a&&(xt===4||xt===3&&(He&62914560)===He&&300>ft()-Rl?(Qe&2)===0&&Li(t,0):ph|=a,Ri===He&&(Ri=0)),ir(t)}function $y(t,r){r===0&&(r=oi()),t=Bs(t,r),t!==null&&(Gn(t,r),ir(t))}function bw(t){var r=t.memoizedState,a=0;r!==null&&(a=r.retryLane),$y(t,a)}function xw(t,r){var a=0;switch(t.tag){case 31:case 13:var l=t.stateNode,f=t.memoizedState;f!==null&&(a=f.retryLane);break;case 19:l=t.stateNode;break;case 22:l=t.stateNode._retryCache;break;default:throw Error(i(314))}l!==null&&l.delete(r),$y(t,a)}function vw(t,r){return ua(t,r)}var zl=null,Pi=null,Sh=!1,Il=!1,Eh=!1,ls=0;function ir(t){t!==Pi&&t.next===null&&(Pi===null?zl=Pi=t:Pi=Pi.next=t),Il=!0,Sh||(Sh=!0,ww())}function Ya(t,r){if(!Eh&&Il){Eh=!0;do for(var a=!1,l=zl;l!==null;){if(t!==0){var f=l.pendingLanes;if(f===0)var y=0;else{var w=l.suspendedLanes,O=l.pingedLanes;y=(1<<31-Ft(42|t)+1)-1,y&=f&~(w&~O),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,Vy(l,y))}else y=He,y=Ts(l,l===ot?y:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(y&3)===0||Cs(l,y)||(a=!0,Vy(l,y));l=l.next}while(a);Eh=!1}}function _w(){Hy()}function Hy(){Il=Sh=!1;var t=0;ls!==0&&Mw()&&(t=ls);for(var r=ft(),a=null,l=zl;l!==null;){var f=l.next,y=Fy(l,r);y===0?(l.next=null,a===null?zl=f:a.next=f,f===null&&(Pi=a)):(a=l,(t!==0||(y&3)!==0)&&(Il=!0)),l=f}Dt!==0&&Dt!==5||Ya(t),ls!==0&&(ls=0)}function Fy(t,r){for(var a=t.suspendedLanes,l=t.pingedLanes,f=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var w=31-Ft(y),O=1<<w,R=f[w];R===-1?((O&a)===0||(O&l)!==0)&&(f[w]=da(O,r)):R<=r&&(t.expiredLanes|=O),y&=~O}if(r=ot,a=He,a=Ts(t,t===r?a:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),l=t.callbackNode,a===0||t===r&&(Ze===2||Ze===9)||t.cancelPendingCommit!==null)return l!==null&&l!==null&&hr(l),t.callbackNode=null,t.callbackPriority=0;if((a&3)===0||Cs(t,a)){if(r=a&-a,r===t.callbackPriority)return r;switch(l!==null&&hr(l),Rs(a)){case 2:case 8:a=$o;break;case 32:a=ii;break;case 268435456:a=Ho;break;default:a=ii}return l=Gy.bind(null,t),a=ua(a,l),t.callbackPriority=r,t.callbackNode=a,r}return l!==null&&l!==null&&hr(l),t.callbackPriority=2,t.callbackNode=null,2}function Gy(t,r){if(Dt!==0&&Dt!==5)return t.callbackNode=null,t.callbackPriority=0,null;var a=t.callbackNode;if(Ul()&&t.callbackNode!==a)return null;var l=He;return l=Ts(t,t===ot?l:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),l===0?null:(Ay(t,l,r),Fy(t,ft()),t.callbackNode!=null&&t.callbackNode===a?Gy.bind(null,t):null)}function Vy(t,r){if(Ul())return null;Ay(t,r,!0)}function ww(){Dw(function(){(Qe&6)!==0?ua(Io,_w):Hy()})}function Oh(){if(ls===0){var t=wi;t===0&&(t=zr,zr<<=1,(zr&261888)===0&&(zr=256)),ls=t}return ls}function Yy(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Jo(""+t)}function Ky(t,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,t.id&&a.setAttribute("form",t.id),r.parentNode.insertBefore(a,r),t=new FormData(t),a.parentNode.removeChild(a),t}function Sw(t,r,a,l,f){if(r==="submit"&&a&&a.stateNode===f){var y=Yy((f[gt]||null).action),w=l.submitter;w&&(r=(r=w[gt]||null)?Yy(r.formAction):w.getAttribute("formAction"),r!==null&&(y=r,w=null));var O=new Zo("action","action",null,l,f);t.push({event:O,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ls!==0){var R=w?Ky(f,w):new FormData(f);Gf(a,{pending:!0,data:R,method:f.method,action:y},null,R)}}else typeof y=="function"&&(O.preventDefault(),R=w?Ky(f,w):new FormData(f),Gf(a,{pending:!0,data:R,method:f.method,action:y},y,R))},currentTarget:f}]})}}for(var Ah=0;Ah<lf.length;Ah++){var jh=lf[Ah],Ew=jh.toLowerCase(),Ow=jh[0].toUpperCase()+jh.slice(1);Yn(Ew,"on"+Ow)}Yn(O0,"onAnimationEnd"),Yn(A0,"onAnimationIteration"),Yn(j0,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(I_,"onTransitionRun"),Yn($_,"onTransitionStart"),Yn(H_,"onTransitionCancel"),Yn(k0,"onTransitionEnd"),K("onMouseEnter",["mouseout","mouseover"]),K("onMouseLeave",["mouseout","mouseover"]),K("onPointerEnter",["pointerout","pointerover"]),K("onPointerLeave",["pointerout","pointerover"]),oe("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),oe("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),oe("onBeforeInput",["compositionend","keypress","textInput","paste"]),oe("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),oe("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),oe("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ka="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(" "),Aw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ka));function Jy(t,r){r=(r&4)!==0;for(var a=0;a<t.length;a++){var l=t[a],f=l.event;l=l.listeners;e:{var y=void 0;if(r)for(var w=l.length-1;0<=w;w--){var O=l[w],R=O.instance,V=O.currentTarget;if(O=O.listener,R!==y&&f.isPropagationStopped())break e;y=O,f.currentTarget=V;try{y(f)}catch(Z){nl(Z)}f.currentTarget=null,y=R}else for(w=0;w<l.length;w++){if(O=l[w],R=O.instance,V=O.currentTarget,O=O.listener,R!==y&&f.isPropagationStopped())break e;y=O,f.currentTarget=V;try{y(f)}catch(Z){nl(Z)}f.currentTarget=null,y=R}}}}function Ie(t,r){var a=r[Ds];a===void 0&&(a=r[Ds]=new Set);var l=t+"__bubble";a.has(l)||(Qy(r,t,2,!1),a.add(l))}function kh(t,r,a){var l=0;r&&(l|=4),Qy(a,t,l,r)}var $l="_reactListening"+Math.random().toString(36).slice(2);function Nh(t){if(!t[$l]){t[$l]=!0,$.forEach(function(a){a!=="selectionchange"&&(Aw.has(a)||kh(a,!1,t),kh(a,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[$l]||(r[$l]=!0,kh("selectionchange",!1,r))}}function Qy(t,r,a,l){switch(Og(r)){case 2:var f=eS;break;case 8:f=tS;break;default:f=Fh}a=f.bind(null,r,a,t),f=void 0,!Ku||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),l?f!==void 0?t.addEventListener(r,a,{capture:!0,passive:f}):t.addEventListener(r,a,!0):f!==void 0?t.addEventListener(r,a,{passive:f}):t.addEventListener(r,a,!1)}function Th(t,r,a,l,f){var y=l;if((r&1)===0&&(r&2)===0&&l!==null)e:for(;;){if(l===null)return;var w=l.tag;if(w===3||w===4){var O=l.stateNode.containerInfo;if(O===f)break;if(w===4)for(w=l.return;w!==null;){var R=w.tag;if((R===3||R===4)&&w.stateNode.containerInfo===f)return;w=w.return}for(;O!==null;){if(w=A(O),w===null)return;if(R=w.tag,R===5||R===6||R===26||R===27){l=y=w;continue e}O=O.parentNode}}l=l.return}t0(function(){var V=y,Z=Vu(a),ie=[];e:{var Y=N0.get(t);if(Y!==void 0){var Q=Zo,ve=t;switch(t){case"keypress":if(Xo(a)===0)break e;case"keydown":case"keyup":Q=x_;break;case"focusin":ve="focus",Q=Wu;break;case"focusout":ve="blur",Q=Wu;break;case"beforeblur":case"afterblur":Q=Wu;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Q=s0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Q=o_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Q=w_;break;case O0:case A0:case j0:Q=u_;break;case k0:Q=E_;break;case"scroll":case"scrollend":Q=i_;break;case"wheel":Q=A_;break;case"copy":case"cut":case"paste":Q=h_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Q=a0;break;case"toggle":case"beforetoggle":Q=k_}var Te=(r&4)!==0,st=!Te&&(t==="scroll"||t==="scrollend"),I=Te?Y!==null?Y+"Capture":null:Y;Te=[];for(var P=V,G;P!==null;){var ee=P;if(G=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||G===null||I===null||(ee=ya(P,I),ee!=null&&Te.push(Ja(P,ee,G))),st)break;P=P.return}0<Te.length&&(Y=new Q(Y,ve,null,a,Z),ie.push({event:Y,listeners:Te}))}}if((r&7)===0){e:{if(Y=t==="mouseover"||t==="pointerover",Q=t==="mouseout"||t==="pointerout",Y&&a!==Gu&&(ve=a.relatedTarget||a.fromElement)&&(A(ve)||ve[hn]))break e;if((Q||Y)&&(Y=Z.window===Z?Z:(Y=Z.ownerDocument)?Y.defaultView||Y.parentWindow:window,Q?(ve=a.relatedTarget||a.toElement,Q=V,ve=ve?A(ve):null,ve!==null&&(st=c(ve),Te=ve.tag,ve!==st||Te!==5&&Te!==27&&Te!==6)&&(ve=null)):(Q=null,ve=V),Q!==ve)){if(Te=s0,ee="onMouseLeave",I="onMouseEnter",P="mouse",(t==="pointerout"||t==="pointerover")&&(Te=a0,ee="onPointerLeave",I="onPointerEnter",P="pointer"),st=Q==null?Y:k(Q),G=ve==null?Y:k(ve),Y=new Te(ee,P+"leave",Q,a,Z),Y.target=st,Y.relatedTarget=G,ee=null,A(Z)===V&&(Te=new Te(I,P+"enter",ve,a,Z),Te.target=G,Te.relatedTarget=st,ee=Te),st=ee,Q&&ve)t:{for(Te=jw,I=Q,P=ve,G=0,ee=I;ee;ee=Te(ee))G++;ee=0;for(var je=P;je;je=Te(je))ee++;for(;0<G-ee;)I=Te(I),G--;for(;0<ee-G;)P=Te(P),ee--;for(;G--;){if(I===P||P!==null&&I===P.alternate){Te=I;break t}I=Te(I),P=Te(P)}Te=null}else Te=null;Q!==null&&Xy(ie,Y,Q,Te,!1),ve!==null&&st!==null&&Xy(ie,st,ve,Te,!0)}}e:{if(Y=V?k(V):window,Q=Y.nodeName&&Y.nodeName.toLowerCase(),Q==="select"||Q==="input"&&Y.type==="file")var Ke=m0;else if(h0(Y))if(p0)Ke=B_;else{Ke=q_;var _e=L_}else Q=Y.nodeName,!Q||Q.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?V&&Fu(V.elementType)&&(Ke=m0):Ke=P_;if(Ke&&(Ke=Ke(t,V))){d0(ie,Ke,a,Z);break e}_e&&_e(t,Y,V),t==="focusout"&&V&&Y.type==="number"&&V.memoizedProps.value!=null&&Hu(Y,"number",Y.value)}switch(_e=V?k(V):window,t){case"focusin":(h0(_e)||_e.contentEditable==="true")&&(mi=_e,sf=V,Ea=null);break;case"focusout":Ea=sf=mi=null;break;case"mousedown":af=!0;break;case"contextmenu":case"mouseup":case"dragend":af=!1,S0(ie,a,Z);break;case"selectionchange":if(z_)break;case"keydown":case"keyup":S0(ie,a,Z)}var Le;if(ef)e:{switch(t){case"compositionstart":var Fe="onCompositionStart";break e;case"compositionend":Fe="onCompositionEnd";break e;case"compositionupdate":Fe="onCompositionUpdate";break e}Fe=void 0}else di?u0(t,a)&&(Fe="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(Fe="onCompositionStart");Fe&&(o0&&a.locale!=="ko"&&(di||Fe!=="onCompositionStart"?Fe==="onCompositionEnd"&&di&&(Le=n0()):(Vr=Z,Ju="value"in Vr?Vr.value:Vr.textContent,di=!0)),_e=Hl(V,Fe),0<_e.length&&(Fe=new i0(Fe,t,null,a,Z),ie.push({event:Fe,listeners:_e}),Le?Fe.data=Le:(Le=f0(a),Le!==null&&(Fe.data=Le)))),(Le=T_?C_(t,a):M_(t,a))&&(Fe=Hl(V,"onBeforeInput"),0<Fe.length&&(_e=new i0("onBeforeInput","beforeinput",null,a,Z),ie.push({event:_e,listeners:Fe}),_e.data=Le)),Sw(ie,t,V,a,Z)}Jy(ie,r)})}function Ja(t,r,a){return{instance:t,listener:r,currentTarget:a}}function Hl(t,r){for(var a=r+"Capture",l=[];t!==null;){var f=t,y=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||y===null||(f=ya(t,a),f!=null&&l.unshift(Ja(t,f,y)),f=ya(t,r),f!=null&&l.push(Ja(t,f,y))),t.tag===3)return l;t=t.return}return[]}function jw(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Xy(t,r,a,l,f){for(var y=r._reactName,w=[];a!==null&&a!==l;){var O=a,R=O.alternate,V=O.stateNode;if(O=O.tag,R!==null&&R===l)break;O!==5&&O!==26&&O!==27||V===null||(R=V,f?(V=ya(a,y),V!=null&&w.unshift(Ja(a,V,R))):f||(V=ya(a,y),V!=null&&w.push(Ja(a,V,R)))),a=a.return}w.length!==0&&t.push({event:r,listeners:w})}var kw=/\r\n?/g,Nw=/\u0000|\uFFFD/g;function Wy(t){return(typeof t=="string"?t:""+t).replace(kw,`
26
- `).replace(Nw,"")}function Zy(t,r){return r=Wy(r),Wy(t)===r}function rt(t,r,a,l,f,y){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||ui(t,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&ui(t,""+l);break;case"className":Vn(t,"class",l);break;case"tabIndex":Vn(t,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Vn(t,a,l);break;case"style":Zm(t,l,y);break;case"data":if(r!=="object"){Vn(t,"data",l);break}case"src":case"href":if(l===""&&(r!=="a"||a!=="href")){t.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){t.removeAttribute(a);break}l=Jo(""+l),t.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){t.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(a==="formAction"?(r!=="input"&&rt(t,r,"name",f.name,f,null),rt(t,r,"formEncType",f.formEncType,f,null),rt(t,r,"formMethod",f.formMethod,f,null),rt(t,r,"formTarget",f.formTarget,f,null)):(rt(t,r,"encType",f.encType,f,null),rt(t,r,"method",f.method,f,null),rt(t,r,"target",f.target,f,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){t.removeAttribute(a);break}l=Jo(""+l),t.setAttribute(a,l);break;case"onClick":l!=null&&(t.onclick=yr);break;case"onScroll":l!=null&&Ie("scroll",t);break;case"onScrollEnd":l!=null&&Ie("scrollend",t);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));t.innerHTML=a}}break;case"multiple":t.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":t.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"){t.removeAttribute("xlink:href");break}a=Jo(""+l),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,""+l):t.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,""):t.removeAttribute(a);break;case"capture":case"download":l===!0?t.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,l):t.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?t.setAttribute(a,l):t.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?t.removeAttribute(a):t.setAttribute(a,l);break;case"popover":Ie("beforetoggle",t),Ie("toggle",t),Gt(t,"popover",l);break;case"xlinkActuate":pr(t,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":pr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":pr(t,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":pr(t,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":pr(t,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":pr(t,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":pr(t,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":pr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":pr(t,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Gt(t,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=r_.get(a)||a,Gt(t,a,l))}}function Ch(t,r,a,l,f,y){switch(a){case"style":Zm(t,l,y);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));t.innerHTML=a}}break;case"children":typeof l=="string"?ui(t,l):(typeof l=="number"||typeof l=="bigint")&&ui(t,""+l);break;case"onScroll":l!=null&&Ie("scroll",t);break;case"onScrollEnd":l!=null&&Ie("scrollend",t);break;case"onClick":l!=null&&(t.onclick=yr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!se.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(f=a.endsWith("Capture"),r=a.slice(2,f?a.length-7:void 0),y=t[gt]||null,y=y!=null?y[a]:null,typeof y=="function"&&t.removeEventListener(r,y,f),typeof l=="function")){typeof y!="function"&&y!==null&&(a in t?t[a]=null:t.hasAttribute(a)&&t.removeAttribute(a)),t.addEventListener(r,l,f);break e}a in t?t[a]=l:l===!0?t.setAttribute(a,""):Gt(t,a,l)}}}function Ht(t,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ie("error",t),Ie("load",t);var l=!1,f=!1,y;for(y in a)if(a.hasOwnProperty(y)){var w=a[y];if(w!=null)switch(y){case"src":l=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:rt(t,r,y,w,a,null)}}f&&rt(t,r,"srcSet",a.srcSet,a,null),l&&rt(t,r,"src",a.src,a,null);return;case"input":Ie("invalid",t);var O=y=w=f=null,R=null,V=null;for(l in a)if(a.hasOwnProperty(l)){var Z=a[l];if(Z!=null)switch(l){case"name":f=Z;break;case"type":w=Z;break;case"checked":R=Z;break;case"defaultChecked":V=Z;break;case"value":y=Z;break;case"defaultValue":O=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(i(137,r));break;default:rt(t,r,l,Z,a,null)}}Jm(t,y,O,R,V,w,f,!1);return;case"select":Ie("invalid",t),l=w=y=null;for(f in a)if(a.hasOwnProperty(f)&&(O=a[f],O!=null))switch(f){case"value":y=O;break;case"defaultValue":w=O;break;case"multiple":l=O;default:rt(t,r,f,O,a,null)}r=y,a=w,t.multiple=!!l,r!=null?ci(t,!!l,r,!1):a!=null&&ci(t,!!l,a,!0);return;case"textarea":Ie("invalid",t),y=f=l=null;for(w in a)if(a.hasOwnProperty(w)&&(O=a[w],O!=null))switch(w){case"value":l=O;break;case"defaultValue":f=O;break;case"children":y=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(i(91));break;default:rt(t,r,w,O,a,null)}Xm(t,l,f,y);return;case"option":for(R in a)if(a.hasOwnProperty(R)&&(l=a[R],l!=null))switch(R){case"selected":t.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:rt(t,r,R,l,a,null)}return;case"dialog":Ie("beforetoggle",t),Ie("toggle",t),Ie("cancel",t),Ie("close",t);break;case"iframe":case"object":Ie("load",t);break;case"video":case"audio":for(l=0;l<Ka.length;l++)Ie(Ka[l],t);break;case"image":Ie("error",t),Ie("load",t);break;case"details":Ie("toggle",t);break;case"embed":case"source":case"link":Ie("error",t),Ie("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in a)if(a.hasOwnProperty(V)&&(l=a[V],l!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:rt(t,r,V,l,a,null)}return;default:if(Fu(r)){for(Z in a)a.hasOwnProperty(Z)&&(l=a[Z],l!==void 0&&Ch(t,r,Z,l,a,void 0));return}}for(O in a)a.hasOwnProperty(O)&&(l=a[O],l!=null&&rt(t,r,O,l,a,null))}function Tw(t,r,a,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,y=null,w=null,O=null,R=null,V=null,Z=null;for(Q in a){var ie=a[Q];if(a.hasOwnProperty(Q)&&ie!=null)switch(Q){case"checked":break;case"value":break;case"defaultValue":R=ie;default:l.hasOwnProperty(Q)||rt(t,r,Q,null,l,ie)}}for(var Y in l){var Q=l[Y];if(ie=a[Y],l.hasOwnProperty(Y)&&(Q!=null||ie!=null))switch(Y){case"type":y=Q;break;case"name":f=Q;break;case"checked":V=Q;break;case"defaultChecked":Z=Q;break;case"value":w=Q;break;case"defaultValue":O=Q;break;case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(i(137,r));break;default:Q!==ie&&rt(t,r,Y,Q,l,ie)}}$u(t,w,O,R,V,Z,y,f);return;case"select":Q=w=O=Y=null;for(y in a)if(R=a[y],a.hasOwnProperty(y)&&R!=null)switch(y){case"value":break;case"multiple":Q=R;default:l.hasOwnProperty(y)||rt(t,r,y,null,l,R)}for(f in l)if(y=l[f],R=a[f],l.hasOwnProperty(f)&&(y!=null||R!=null))switch(f){case"value":Y=y;break;case"defaultValue":O=y;break;case"multiple":w=y;default:y!==R&&rt(t,r,f,y,l,R)}r=O,a=w,l=Q,Y!=null?ci(t,!!a,Y,!1):!!l!=!!a&&(r!=null?ci(t,!!a,r,!0):ci(t,!!a,a?[]:"",!1));return;case"textarea":Q=Y=null;for(O in a)if(f=a[O],a.hasOwnProperty(O)&&f!=null&&!l.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:rt(t,r,O,null,l,f)}for(w in l)if(f=l[w],y=a[w],l.hasOwnProperty(w)&&(f!=null||y!=null))switch(w){case"value":Y=f;break;case"defaultValue":Q=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==y&&rt(t,r,w,f,l,y)}Qm(t,Y,Q);return;case"option":for(var ve in a)if(Y=a[ve],a.hasOwnProperty(ve)&&Y!=null&&!l.hasOwnProperty(ve))switch(ve){case"selected":t.selected=!1;break;default:rt(t,r,ve,null,l,Y)}for(R in l)if(Y=l[R],Q=a[R],l.hasOwnProperty(R)&&Y!==Q&&(Y!=null||Q!=null))switch(R){case"selected":t.selected=Y&&typeof Y!="function"&&typeof Y!="symbol";break;default:rt(t,r,R,Y,l,Q)}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 Te in a)Y=a[Te],a.hasOwnProperty(Te)&&Y!=null&&!l.hasOwnProperty(Te)&&rt(t,r,Te,null,l,Y);for(V in l)if(Y=l[V],Q=a[V],l.hasOwnProperty(V)&&Y!==Q&&(Y!=null||Q!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(i(137,r));break;default:rt(t,r,V,Y,l,Q)}return;default:if(Fu(r)){for(var st in a)Y=a[st],a.hasOwnProperty(st)&&Y!==void 0&&!l.hasOwnProperty(st)&&Ch(t,r,st,void 0,l,Y);for(Z in l)Y=l[Z],Q=a[Z],!l.hasOwnProperty(Z)||Y===Q||Y===void 0&&Q===void 0||Ch(t,r,Z,Y,l,Q);return}}for(var I in a)Y=a[I],a.hasOwnProperty(I)&&Y!=null&&!l.hasOwnProperty(I)&&rt(t,r,I,null,l,Y);for(ie in l)Y=l[ie],Q=a[ie],!l.hasOwnProperty(ie)||Y===Q||Y==null&&Q==null||rt(t,r,ie,Y,l,Q)}function eg(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Cw(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var f=a[l],y=f.transferSize,w=f.initiatorType,O=f.duration;if(y&&O&&eg(w)){for(w=0,O=f.responseEnd,l+=1;l<a.length;l++){var R=a[l],V=R.startTime;if(V>O)break;var Z=R.transferSize,ie=R.initiatorType;Z&&eg(ie)&&(R=R.responseEnd,w+=Z*(R<O?1:(O-V)/(R-V)))}if(--l,r+=8*(y+w)/(f.duration/1e3),t++,10<t)break}}if(0<t)return r/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Mh=null,Rh=null;function Fl(t){return t.nodeType===9?t:t.ownerDocument}function tg(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ng(t,r){if(t===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&r==="foreignObject"?0:t}function Dh(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Lh=null;function Mw(){var t=window.event;return t&&t.type==="popstate"?t===Lh?!1:(Lh=t,!0):(Lh=null,!1)}var rg=typeof setTimeout=="function"?setTimeout:void 0,Rw=typeof clearTimeout=="function"?clearTimeout:void 0,sg=typeof Promise=="function"?Promise:void 0,Dw=typeof queueMicrotask=="function"?queueMicrotask:typeof sg<"u"?function(t){return sg.resolve(null).then(t).catch(Lw)}:rg;function Lw(t){setTimeout(function(){throw t})}function cs(t){return t==="head"}function ig(t,r){var a=r,l=0;do{var f=a.nextSibling;if(t.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"||a==="/&"){if(l===0){t.removeChild(f),Ii(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Qa(t.ownerDocument.documentElement);else if(a==="head"){a=t.ownerDocument.head,Qa(a);for(var y=a.firstChild;y;){var w=y.nextSibling,O=y.nodeName;y[Rt]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&y.rel.toLowerCase()==="stylesheet"||a.removeChild(y),y=w}}else a==="body"&&Qa(t.ownerDocument.body);a=f}while(a);Ii(r)}function ag(t,r){var a=t;t=0;do{var l=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(t===0)break;t--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||t++;a=l}while(a)}function qh(t){var r=t.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":qh(a),li(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}t.removeChild(a)}}function qw(t,r,a,l){for(;t.nodeType===1;){var f=a;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!l&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(l){if(!t[Rt])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(y=t.getAttribute("rel"),y==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(y!==f.rel||t.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||t.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||t.getAttribute("title")!==(f.title==null?null:f.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(y=t.getAttribute("src"),(y!==(f.src==null?null:f.src)||t.getAttribute("type")!==(f.type==null?null:f.type)||t.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&y&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var y=f.name==null?null:""+f.name;if(f.type==="hidden"&&t.getAttribute("name")===y)return t}else return t;if(t=Bn(t.nextSibling),t===null)break}return null}function Pw(t,r,a){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!a||(t=Bn(t.nextSibling),t===null))return null;return t}function og(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Bn(t.nextSibling),t===null))return null;return t}function Ph(t){return t.data==="$?"||t.data==="$~"}function Bh(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Bw(t,r){var a=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||a.readyState!=="loading")r();else{var l=function(){r(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),t._reactRetry=l}}function Bn(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return t}var Uh=null;function lg(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var a=t.data;if(a==="/$"||a==="/&"){if(r===0)return Bn(t.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}t=t.nextSibling}return null}function cg(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var a=t.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return t;r--}else a!=="/$"&&a!=="/&"||r++}t=t.previousSibling}return null}function ug(t,r,a){switch(r=Fl(a),t){case"html":if(t=r.documentElement,!t)throw Error(i(452));return t;case"head":if(t=r.head,!t)throw Error(i(453));return t;case"body":if(t=r.body,!t)throw Error(i(454));return t;default:throw Error(i(451))}}function Qa(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);li(t)}var Un=new Map,fg=new Set;function Gl(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Mr=J.d;J.d={f:Uw,r:zw,D:Iw,C:$w,L:Hw,m:Fw,X:Vw,S:Gw,M:Yw};function Uw(){var t=Mr.f(),r=ql();return t||r}function zw(t){var r=N(t);r!==null&&r.tag===5&&r.type==="form"?kp(r):Mr.r(t)}var Bi=typeof document>"u"?null:document;function hg(t,r,a){var l=Bi;if(l&&typeof r=="string"&&r){var f=Cn(r);f='link[rel="'+t+'"][href="'+f+'"]',typeof a=="string"&&(f+='[crossorigin="'+a+'"]'),fg.has(f)||(fg.add(f),t={rel:t,crossOrigin:a,href:r},l.querySelector(f)===null&&(r=l.createElement("link"),Ht(r,"link",t),L(r),l.head.appendChild(r)))}}function Iw(t){Mr.D(t),hg("dns-prefetch",t,null)}function $w(t,r){Mr.C(t,r),hg("preconnect",t,r)}function Hw(t,r,a){Mr.L(t,r,a);var l=Bi;if(l&&t&&r){var f='link[rel="preload"][as="'+Cn(r)+'"]';r==="image"&&a&&a.imageSrcSet?(f+='[imagesrcset="'+Cn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(f+='[imagesizes="'+Cn(a.imageSizes)+'"]')):f+='[href="'+Cn(t)+'"]';var y=f;switch(r){case"style":y=Ui(t);break;case"script":y=zi(t)}Un.has(y)||(t=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:t,as:r},a),Un.set(y,t),l.querySelector(f)!==null||r==="style"&&l.querySelector(Xa(y))||r==="script"&&l.querySelector(Wa(y))||(r=l.createElement("link"),Ht(r,"link",t),L(r),l.head.appendChild(r)))}}function Fw(t,r){Mr.m(t,r);var a=Bi;if(a&&t){var l=r&&typeof r.as=="string"?r.as:"script",f='link[rel="modulepreload"][as="'+Cn(l)+'"][href="'+Cn(t)+'"]',y=f;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=zi(t)}if(!Un.has(y)&&(t=b({rel:"modulepreload",href:t},r),Un.set(y,t),a.querySelector(f)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Wa(y)))return}l=a.createElement("link"),Ht(l,"link",t),L(l),a.head.appendChild(l)}}}function Gw(t,r,a){Mr.S(t,r,a);var l=Bi;if(l&&t){var f=T(l).hoistableStyles,y=Ui(t);r=r||"default";var w=f.get(y);if(!w){var O={loading:0,preload:null};if(w=l.querySelector(Xa(y)))O.loading=5;else{t=b({rel:"stylesheet",href:t,"data-precedence":r},a),(a=Un.get(y))&&zh(t,a);var R=w=l.createElement("link");L(R),Ht(R,"link",t),R._p=new Promise(function(V,Z){R.onload=V,R.onerror=Z}),R.addEventListener("load",function(){O.loading|=1}),R.addEventListener("error",function(){O.loading|=2}),O.loading|=4,Vl(w,r,l)}w={type:"stylesheet",instance:w,count:1,state:O},f.set(y,w)}}}function Vw(t,r){Mr.X(t,r);var a=Bi;if(a&&t){var l=T(a).hoistableScripts,f=zi(t),y=l.get(f);y||(y=a.querySelector(Wa(f)),y||(t=b({src:t,async:!0},r),(r=Un.get(f))&&Ih(t,r),y=a.createElement("script"),L(y),Ht(y,"link",t),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},l.set(f,y))}}function Yw(t,r){Mr.M(t,r);var a=Bi;if(a&&t){var l=T(a).hoistableScripts,f=zi(t),y=l.get(f);y||(y=a.querySelector(Wa(f)),y||(t=b({src:t,async:!0,type:"module"},r),(r=Un.get(f))&&Ih(t,r),y=a.createElement("script"),L(y),Ht(y,"link",t),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},l.set(f,y))}}function dg(t,r,a,l){var f=(f=Ct.current)?Gl(f):null;if(!f)throw Error(i(446));switch(t){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Ui(a.href),a=T(f).hoistableStyles,l=a.get(r),l||(l={type:"style",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){t=Ui(a.href);var y=T(f).hoistableStyles,w=y.get(t);if(w||(f=f.ownerDocument||f,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(t,w),(y=f.querySelector(Xa(t)))&&!y._p&&(w.instance=y,w.state.loading=5),Un.has(t)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Un.set(t,a),y||Kw(f,t,a,w.state))),r&&l===null)throw Error(i(528,""));return w}if(r&&l!==null)throw Error(i(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=zi(a),a=T(f).hoistableScripts,l=a.get(r),l||(l={type:"script",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function Ui(t){return'href="'+Cn(t)+'"'}function Xa(t){return'link[rel="stylesheet"]['+t+"]"}function mg(t){return b({},t,{"data-precedence":t.precedence,precedence:null})}function Kw(t,r,a,l){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?l.loading=1:(r=t.createElement("link"),l.preload=r,r.addEventListener("load",function(){return l.loading|=1}),r.addEventListener("error",function(){return l.loading|=2}),Ht(r,"link",a),L(r),t.head.appendChild(r))}function zi(t){return'[src="'+Cn(t)+'"]'}function Wa(t){return"script[async]"+t}function pg(t,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=t.querySelector('style[data-href~="'+Cn(a.href)+'"]');if(l)return r.instance=l,L(l),l;var f=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(t.ownerDocument||t).createElement("style"),L(l),Ht(l,"style",f),Vl(l,a.precedence,t),r.instance=l;case"stylesheet":f=Ui(a.href);var y=t.querySelector(Xa(f));if(y)return r.state.loading|=4,r.instance=y,L(y),y;l=mg(a),(f=Un.get(f))&&zh(l,f),y=(t.ownerDocument||t).createElement("link"),L(y);var w=y;return w._p=new Promise(function(O,R){w.onload=O,w.onerror=R}),Ht(y,"link",l),r.state.loading|=4,Vl(y,a.precedence,t),r.instance=y;case"script":return y=zi(a.src),(f=t.querySelector(Wa(y)))?(r.instance=f,L(f),f):(l=a,(f=Un.get(y))&&(l=b({},a),Ih(l,f)),t=t.ownerDocument||t,f=t.createElement("script"),L(f),Ht(f,"link",l),t.head.appendChild(f),r.instance=f);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(l=r.instance,r.state.loading|=4,Vl(l,a.precedence,t));return r.instance}function Vl(t,r,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=l.length?l[l.length-1]:null,y=f,w=0;w<l.length;w++){var O=l[w];if(O.dataset.precedence===r)y=O;else if(y!==f)break}y?y.parentNode.insertBefore(t,y.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(t,r.firstChild))}function zh(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Ih(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var Yl=null;function yg(t,r,a){if(Yl===null){var l=new Map,f=Yl=new Map;f.set(a,l)}else f=Yl,l=f.get(a),l||(l=new Map,f.set(a,l));if(l.has(t))return l;for(l.set(t,null),a=a.getElementsByTagName(t),f=0;f<a.length;f++){var y=a[f];if(!(y[Rt]||y[at]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var w=y.getAttribute(r)||"";w=t+w;var O=l.get(w);O?O.push(y):l.set(w,[y])}}return l}function gg(t,r,a){t=t.ownerDocument||t,t.head.insertBefore(a,r==="title"?t.querySelector("head > title"):null)}function Jw(t,r,a){if(a===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function bg(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Qw(t,r,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var f=Ui(l.href),y=r.querySelector(Xa(f));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=Kl.bind(t),r.then(t,t)),a.state.loading|=4,a.instance=y,L(y);return}y=r.ownerDocument||r,l=mg(l),(f=Un.get(f))&&zh(l,f),y=y.createElement("link"),L(y);var w=y;w._p=new Promise(function(O,R){w.onload=O,w.onerror=R}),Ht(y,"link",l),a.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(t.count++,a=Kl.bind(t),r.addEventListener("load",a),r.addEventListener("error",a))}}var $h=0;function Xw(t,r){return t.stylesheets&&t.count===0&&Ql(t,t.stylesheets),0<t.count||0<t.imgCount?function(a){var l=setTimeout(function(){if(t.stylesheets&&Ql(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+r);0<t.imgBytes&&$h===0&&($h=62500*Cw());var f=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Ql(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>$h?50:800)+r);return t.unsuspend=a,function(){t.unsuspend=null,clearTimeout(l),clearTimeout(f)}}:null}function Kl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ql(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Jl=null;function Ql(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Jl=new Map,r.forEach(Ww,t),Jl=null,Kl.call(t))}function Ww(t,r){if(!(r.state.loading&4)){var a=Jl.get(t);if(a)var l=a.get(null);else{a=new Map,Jl.set(t,a);for(var f=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<f.length;y++){var w=f[y];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(a.set(w.dataset.precedence,w),l=w)}l&&a.set(null,l)}f=r.instance,w=f.getAttribute("data-precedence"),y=a.get(w)||l,y===l&&a.set(null,f),a.set(w,f),this.count++,l=Kl.bind(this),f.addEventListener("load",l),f.addEventListener("error",l),y?y.parentNode.insertBefore(f,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(f,t.firstChild)),r.state.loading|=4}}var Za={$$typeof:ne,Provider:null,Consumer:null,_currentValue:le,_currentValue2:le,_threadCount:0};function Zw(t,r,a,l,f,y,w,O,R){this.tag=1,this.containerInfo=t,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=$r(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$r(0),this.hiddenUpdates=$r(null),this.identifierPrefix=l,this.onUncaughtError=f,this.onCaughtError=y,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=R,this.incompleteTransitions=new Map}function xg(t,r,a,l,f,y,w,O,R,V,Z,ie){return t=new Zw(t,r,a,w,R,V,Z,ie,O),r=1,y===!0&&(r|=24),y=mn(3,null,null,r),t.current=y,y.stateNode=t,r=_f(),r.refCount++,t.pooledCache=r,r.refCount++,y.memoizedState={element:l,isDehydrated:a,cache:r},Of(y),t}function vg(t){return t?(t=gi,t):gi}function _g(t,r,a,l,f,y){f=vg(f),l.context===null?l.context=f:l.pendingContext=f,l=Wr(r),l.payload={element:a},y=y===void 0?null:y,y!==null&&(l.callback=y),a=Zr(t,l,r),a!==null&&(ln(a,t,r),Ca(a,t,r))}function wg(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var a=t.retryLane;t.retryLane=a!==0&&a<r?a:r}}function Hh(t,r){wg(t,r),(t=t.alternate)&&wg(t,r)}function Sg(t){if(t.tag===13||t.tag===31){var r=Bs(t,67108864);r!==null&&ln(r,t,67108864),Hh(t,67108864)}}function Eg(t){if(t.tag===13||t.tag===31){var r=xn();r=mr(r);var a=Bs(t,r);a!==null&&ln(a,t,r),Hh(t,r)}}var Xl=!0;function eS(t,r,a,l){var f=H.T;H.T=null;var y=J.p;try{J.p=2,Fh(t,r,a,l)}finally{J.p=y,H.T=f}}function tS(t,r,a,l){var f=H.T;H.T=null;var y=J.p;try{J.p=8,Fh(t,r,a,l)}finally{J.p=y,H.T=f}}function Fh(t,r,a,l){if(Xl){var f=Gh(l);if(f===null)Th(t,r,l,Wl,a),Ag(t,l);else if(rS(f,t,r,a,l))l.stopPropagation();else if(Ag(t,l),r&4&&-1<nS.indexOf(t)){for(;f!==null;){var y=N(f);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var w=Fn(y.pendingLanes);if(w!==0){var O=y;for(O.pendingLanes|=2,O.entangledLanes|=2;w;){var R=1<<31-Ft(w);O.entanglements[1]|=R,w&=~R}ir(y),(Qe&6)===0&&(Dl=ft()+500,Ya(0))}}break;case 31:case 13:O=Bs(y,2),O!==null&&ln(O,y,2),ql(),Hh(y,2)}if(y=Gh(l),y===null&&Th(t,r,l,Wl,a),y===f)break;f=y}f!==null&&l.stopPropagation()}else Th(t,r,l,null,a)}}function Gh(t){return t=Vu(t),Vh(t)}var Wl=null;function Vh(t){if(Wl=null,t=A(t),t!==null){var r=c(t);if(r===null)t=null;else{var a=r.tag;if(a===13){if(t=m(r),t!==null)return t;t=null}else if(a===31){if(t=p(r),t!==null)return t;t=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null)}}return Wl=t,null}function Og(t){switch(t){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(Bu()){case Io:return 2;case $o:return 8;case ii:case Uu:return 32;case Ho:return 268435456;default:return 32}default:return 32}}var Yh=!1,us=null,fs=null,hs=null,eo=new Map,to=new Map,ds=[],nS="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 Ag(t,r){switch(t){case"focusin":case"focusout":us=null;break;case"dragenter":case"dragleave":fs=null;break;case"mouseover":case"mouseout":hs=null;break;case"pointerover":case"pointerout":eo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":to.delete(r.pointerId)}}function no(t,r,a,l,f,y){return t===null||t.nativeEvent!==y?(t={blockedOn:r,domEventName:a,eventSystemFlags:l,nativeEvent:y,targetContainers:[f]},r!==null&&(r=N(r),r!==null&&Sg(r)),t):(t.eventSystemFlags|=l,r=t.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),t)}function rS(t,r,a,l,f){switch(r){case"focusin":return us=no(us,t,r,a,l,f),!0;case"dragenter":return fs=no(fs,t,r,a,l,f),!0;case"mouseover":return hs=no(hs,t,r,a,l,f),!0;case"pointerover":var y=f.pointerId;return eo.set(y,no(eo.get(y)||null,t,r,a,l,f)),!0;case"gotpointercapture":return y=f.pointerId,to.set(y,no(to.get(y)||null,t,r,a,l,f)),!0}return!1}function jg(t){var r=A(t.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=m(a),r!==null){t.blockedOn=r,Go(t.priority,function(){Eg(a)});return}}else if(r===31){if(r=p(a),r!==null){t.blockedOn=r,Go(t.priority,function(){Eg(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){t.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Zl(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var a=Gh(t.nativeEvent);if(a===null){a=t.nativeEvent;var l=new a.constructor(a.type,a);Gu=l,a.target.dispatchEvent(l),Gu=null}else return r=N(a),r!==null&&Sg(r),t.blockedOn=a,!1;r.shift()}return!0}function kg(t,r,a){Zl(t)&&a.delete(r)}function sS(){Yh=!1,us!==null&&Zl(us)&&(us=null),fs!==null&&Zl(fs)&&(fs=null),hs!==null&&Zl(hs)&&(hs=null),eo.forEach(kg),to.forEach(kg)}function ec(t,r){t.blockedOn===r&&(t.blockedOn=null,Yh||(Yh=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,sS)))}var tc=null;function Ng(t){tc!==t&&(tc=t,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){tc===t&&(tc=null);for(var r=0;r<t.length;r+=3){var a=t[r],l=t[r+1],f=t[r+2];if(typeof l!="function"){if(Vh(l||a)===null)continue;break}var y=N(a);y!==null&&(t.splice(r,3),r-=3,Gf(y,{pending:!0,data:f,method:a.method,action:l},l,f))}}))}function Ii(t){function r(R){return ec(R,t)}us!==null&&ec(us,t),fs!==null&&ec(fs,t),hs!==null&&ec(hs,t),eo.forEach(r),to.forEach(r);for(var a=0;a<ds.length;a++){var l=ds[a];l.blockedOn===t&&(l.blockedOn=null)}for(;0<ds.length&&(a=ds[0],a.blockedOn===null);)jg(a),a.blockedOn===null&&ds.shift();if(a=(t.ownerDocument||t).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var f=a[l],y=a[l+1],w=f[gt]||null;if(typeof y=="function")w||Ng(a);else if(w){var O=null;if(y&&y.hasAttribute("formAction")){if(f=y,w=y[gt]||null)O=w.formAction;else if(Vh(f)!==null)continue}else O=w.action;typeof O=="function"?a[l+1]=O:(a.splice(l,3),l-=3),Ng(a)}}}function Tg(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(w){return f=w})},focusReset:"manual",scroll:"manual"})}function r(){f!==null&&(f(),f=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,f=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),f!==null&&(f(),f=null)}}}function Kh(t){this._internalRoot=t}nc.prototype.render=Kh.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var a=r.current,l=xn();_g(a,l,t,r,null,null)},nc.prototype.unmount=Kh.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;_g(t.current,2,null,t,null,null),ql(),r[hn]=null}};function nc(t){this._internalRoot=t}nc.prototype.unstable_scheduleHydration=function(t){if(t){var r=ma();t={blockedOn:null,target:t,priority:r};for(var a=0;a<ds.length&&r!==0&&r<ds[a].priority;a++);ds.splice(a,0,t),a===0&&jg(t)}};var Cg=e.version;if(Cg!=="19.2.4")throw Error(i(527,Cg,"19.2.4"));J.findDOMNode=function(t){var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(i(188)):(t=Object.keys(t).join(","),Error(i(268,t)));return t=u(r),t=t!==null?d(t):null,t=t===null?null:t.stateNode,t};var iS={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var rc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rc.isDisabled&&rc.supportsFiber)try{Ns=rc.inject(iS),_t=rc}catch{}}return ro.createRoot=function(t,r){if(!o(t))throw Error(i(299));var a=!1,l="",f=Bp,y=Up,w=zp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(l=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(w=r.onRecoverableError)),r=xg(t,1,!1,null,null,a,l,null,f,y,w,Tg),t[hn]=r.current,Nh(t),new Kh(r)},ro.hydrateRoot=function(t,r,a){if(!o(t))throw Error(i(299));var l=!1,f="",y=Bp,w=Up,O=zp,R=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onUncaughtError!==void 0&&(y=a.onUncaughtError),a.onCaughtError!==void 0&&(w=a.onCaughtError),a.onRecoverableError!==void 0&&(O=a.onRecoverableError),a.formState!==void 0&&(R=a.formState)),r=xg(t,1,!0,r,a??null,l,f,R,y,w,O,Tg),r.context=vg(null),a=r.current,l=xn(),l=mr(l),f=Wr(l),f.callback=null,Zr(a,f,l),a=l,r.current.lanes=a,Gn(r,a),ir(r),t[hn]=r.current,Nh(t),new nc(r)},ro.version="19.2.4",ro}var Bg;function XS(){if(Bg)return Jh.exports;Bg=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Jh.exports=QS(),Jh.exports}var WS=XS();const ZS="modulepreload",eE=function(n,e){return new URL(n,e).href},Ug={},Oe=function(e,s,i){let o=Promise.resolve();if(s&&s.length>0){let m=function(d){return Promise.all(d.map(b=>Promise.resolve(b).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};const p=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),u=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=m(s.map(d=>{if(d=eE(d,i),d in Ug)return;Ug[d]=!0;const b=d.endsWith(".css"),x=b?'[rel="stylesheet"]':"";if(!!i)for(let S=p.length-1;S>=0;S--){const C=p[S];if(C.href===d&&(!b||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${x}`))return;const _=document.createElement("link");if(_.rel=b?"stylesheet":ZS,b||(_.as="script"),_.crossOrigin="",_.href=d,u&&_.setAttribute("nonce",u),document.head.appendChild(_),b)return new Promise((S,C)=>{_.addEventListener("load",S),_.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${d}`)))})}))}function c(m){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=m,window.dispatchEvent(p),!p.defaultPrevented)throw m}return o.then(m=>{for(const p of m||[])p.status==="rejected"&&c(p.reason);return e().catch(c)})};function Eu(n){try{const e=n.split(".");if(e.length!==3)return null;const s=atob(e[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function yx(n){const e=Eu(n);return!e||typeof e.exp!="number"?null:e.exp}function om(n,e=0){const s=yx(n);return s===null?!0:Date.now()/1e3>=s-e}const Vt=window.__LT_BASE__??"",_d=`${Vt}/api`;class zg extends Error{constructor(e,s,i){super(e),this.status=s,this.body=i,this.name="ApiError"}}let bs=null;function sc(n){bs=n}function wd(){return bs}const tE="X-LT-Acting-Token",nE="X-LT-Acting-Remaining";let eu=null,tu=null;function Ig(n){eu=n}let nu=null;function $g(n){nu=n}function Hg(n){tu=n}function rE(n){const e=n==null?void 0:n.error;return typeof e=="string"&&/acting[- ]identity/i.test(e)}async function Fg(){const n=sessionStorage.getItem("lt_credentials");if(!n)return null;try{const{username:e,password:s}=JSON.parse(n),i=await fetch(`${_d}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:s})});if(!i.ok)return null;const o=await i.json();return o.token&&o.user&&sessionStorage.setItem("lt_user_info",JSON.stringify({displayName:o.user.display_name,username:o.user.external_id})),o.token??null}catch{return null}}let ps=null;async function ue(n,e={}){const s={"Content-Type":"application/json",...e.headers};if(bs){if(om(bs)){ps||(ps=Fg().finally(()=>{ps=null}));const p=await ps;if(p)bs=p,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:p}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${bs}`}const o=(e.method??"GET").toUpperCase()==="GET"?null:(eu==null?void 0:eu())??null;o&&(s[tE]=o);let c=await fetch(`${_d}${n}`,{...e,headers:s});const m=o?c.headers.get(nE):null;if(o&&m!==null&&(nu==null||nu(o,m==="unbounded"?null:Number(m))),c.status===401&&o){const p=await c.clone().json().catch(()=>null);if(rE(p))throw tu==null||tu(),new zg(p.error,401,p)}if(c.status===401&&bs){ps||(ps=Fg().finally(()=>{ps=null}));const p=await ps;if(p&&(bs=p,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:p}})),s.Authorization=`Bearer ${p}`,c=await fetch(`${_d}${n}`,{...e,headers:s})),c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!c.ok){const p=await c.json().catch(()=>({error:c.statusText}));throw new zg(p.message||p.error||c.statusText,c.status,p)}return c.json()}const sE="lt_ai_override";let ic=null;function lm(){return ic||(ic=fetch(`${Vt}/api/settings`).then(n=>{if(!n.ok)throw new Error(`settings ${n.status}`);return n.json()}).catch(n=>{throw ic=null,n})),ic}function iE(){try{if(localStorage.getItem(sE)==="off")return!1}catch{}return null}function Hn(){var s;const n=qe({queryKey:["settings"],queryFn:lm,staleTime:1/0}),e=iE();return n.data&&e===!1&&((s=n.data.ai)!=null&&s.enabled)?{...n,data:{...n.data,ai:{enabled:!1}}}:n}function aE(n){var u,d,b;const{data:e}=Hn(),s=((u=e==null?void 0:e.auth)==null?void 0:u.ssoKeepaliveSeconds)??0,i=((d=e==null?void 0:e.auth)==null?void 0:d.ssoKeepaliveIdleTimeoutSeconds)??0,o=E.useRef(Date.now()),c=E.useRef(Date.now()),m=E.useRef(!1),g=!!n&&((b=Eu(n))==null?void 0:b.sso)===!0&&s>0;E.useEffect(()=>{if(!g)return;const x=()=>{o.current=Date.now()};window.addEventListener("pointerdown",x,{passive:!0}),window.addEventListener("keydown",x,{passive:!0}),window.addEventListener("wheel",x,{passive:!0});const v=async()=>{if(!m.current&&document.visibilityState==="visible"&&!(i>0&&Date.now()-o.current>i*1e3)){m.current=!0;try{const C=await fetch(`${Vt}/api/auth/sso`,{method:"POST"});if(C.status===401||C.status===403){window.dispatchEvent(new CustomEvent("auth:unauthorized"));return}if(!C.ok)return;const B=await C.json().catch(()=>null);B!=null&&B.token&&(c.current=Date.now(),window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:B.token}})))}catch{}finally{m.current=!1}}},_=setInterval(v,s*1e3),S=()=>{document.visibilityState==="visible"&&Date.now()-c.current>s*1e3&&v()};return document.addEventListener("visibilitychange",S),()=>{clearInterval(_),document.removeEventListener("visibilitychange",S),window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",x),window.removeEventListener("wheel",x)}},[g,s,i])}const gx=E.createContext(null),oE=300;function Wh(n,e){if(om(n))return null;const s=Eu(n);if(!s)return null;const i=e??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(i==null?void 0:i.displayName)??null,username:(i==null?void 0:i.username)??null,roles:s.roles??[]}}function lE({children:n}){const[e,s]=E.useState(()=>{const b=sessionStorage.getItem("lt_token");return b?om(b)?(sessionStorage.removeItem("lt_token"),null):(sc(b),Wh(b)):null}),i=E.useRef(void 0),o=E.useCallback(b=>{clearTimeout(i.current);const x=yx(b);if(!x)return;const v=(x-oE)*1e3-Date.now();v<=0||(i.current=setTimeout(async()=>{try{const _=Eu(b);if(_!=null&&_.sso){const te=await fetch(`${Vt}/api/auth/sso`,{method:"POST"});if(!te.ok)return;const M=await te.json();M.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:M.token}}));return}const S=sessionStorage.getItem("lt_credentials");if(!S)return;const{username:C,password:B}=JSON.parse(S),q=await fetch(`${Vt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:B})});if(!q.ok)return;const ne=await q.json();ne.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:ne.token}}))}catch{}},v))},[]),c=E.useCallback((b,x,v)=>{const _={displayName:(v==null?void 0:v.displayName)??null,username:(v==null?void 0:v.username)??(x==null?void 0:x.username)??null},S=Wh(b,_);S&&(sc(b),sessionStorage.setItem("lt_token",b),sessionStorage.setItem("lt_user_info",JSON.stringify(_)),x&&sessionStorage.setItem("lt_credentials",JSON.stringify(x)),s(S),o(b))},[o]),m=E.useCallback(()=>{clearTimeout(i.current);const b=sessionStorage.getItem("lt_sso_logout_url");sc(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),b&&(window.location.href=b)},[]);E.useEffect(()=>{const b=()=>m(),x=v=>{var C;const _=(C=v.detail)==null?void 0:C.token;if(!_)return;const S=Wh(_);S&&(sc(_),sessionStorage.setItem("lt_token",_),s(S),o(_))};return window.addEventListener("auth:unauthorized",b),window.addEventListener("auth:refreshed",x),()=>{window.removeEventListener("auth:unauthorized",b),window.removeEventListener("auth:refreshed",x)}},[m,o]),E.useEffect(()=>{const b=sessionStorage.getItem("lt_token");return b&&e&&o(b),()=>clearTimeout(i.current)},[]);const p=(e==null?void 0:e.roles.some(b=>b.type==="superadmin"))??!1,g=E.useCallback(b=>(e==null?void 0:e.roles.some(x=>x.role===b))??!1,[e]),u=E.useCallback(b=>(e==null?void 0:e.roles.some(x=>x.type===b))??!1,[e]),d=(e==null?void 0:e.roles.map(b=>b.role))??[];return h.jsxs(gx.Provider,{value:{user:e,isAuthenticated:!!e,isSuperAdmin:p,login:c,logout:m,hasRole:g,hasRoleType:u,userRoleNames:d},children:[h.jsx(cE,{authenticated:e!==null}),n]})}function cE({authenticated:n}){return aE(n?sessionStorage.getItem("lt_token"):null),null}function qt(){const n=E.useContext(gx);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}async function uE(n){if(!wd())return{kind:"session-ended"};try{const e=await ue("/nats-credentials"),s=e.natsWsUrl??n;return s?{kind:"ok",url:s,token:e.natsToken??null}:{kind:"unavailable"}}catch{return wd()?{kind:"unavailable"}:{kind:"session-ended"}}}const yo={initialDelayMs:1e3,maxDelayMs:6e4,noticeAfterMs:3e4,spreadMs:5e3};function fE(n,e,s=Math.random){const i=Math.min(e.maxDelayMs,e.initialDelayMs*2**Math.max(0,n));return Math.round(i/2+s()*(i/2))}function Gg(n,e=Math.random){return Math.round(e()*n.spreadMs)}function Vg(n){const e=(s,i)=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:i;return{initialDelayMs:e(n==null?void 0:n.initialDelayMs,yo.initialDelayMs),maxDelayMs:e(n==null?void 0:n.maxDelayMs,yo.maxDelayMs),noticeAfterMs:e(n==null?void 0:n.noticeAfterMs,yo.noticeAfterMs),spreadMs:e(n==null?void 0:n.spreadMs,yo.spreadMs)}}const jn=new Uint8Array(0),ri=new TextEncoder,En=new TextDecoder;function hE(...n){let e=0;for(let o=0;o<n.length;o++)e+=n[o].length;const s=new Uint8Array(e);let i=0;for(let o=0;o<n.length;o++)s.set(n[o],i),i+=n[o].length;return s}function vo(...n){const e=[];for(let s=0;s<n.length;s++)e.push(ri.encode(n[s]));return e.length===0?jn:e.length===1?e[0]:hE(...e)}function Yg(n){return!n||n.length===0?"":En.decode(n)}const Kg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",Jg=36,dE=0xcfd41b9100000,Qg=33,mE=333,Xg=22;function pE(n){for(let e=0;e<n.length;e++)n[e]=Math.floor(Math.random()*255)}function yE(n){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(n):pE(n)}class gE{constructor(){j(this,"buf");j(this,"seq");j(this,"inc");j(this,"inited");this.buf=new Uint8Array(Xg),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*dE),this.inc=Math.floor(Math.random()*(mE-Qg)+Qg)}setPre(){const e=new Uint8Array(12);yE(e);for(let s=0;s<12;s++){const i=e[s]%36;this.buf[s]=Kg.charCodeAt(i)}}fillSeq(){let e=this.seq;for(let s=Xg-1;s>=12;s--)this.buf[s]=Kg.charCodeAt(e%Jg),e=Math.floor(e/Jg)}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 As=new gE;var Dr;(function(n){n.Disconnect="disconnect",n.Reconnect="reconnect",n.Update="update",n.LDM="ldm",n.Error="error"})(Dr||(Dr={}));var Qi;(function(n){n.Reconnecting="reconnecting",n.PingTimer="pingTimer",n.StaleConnection="staleConnection",n.ClientInitiatedReconnect="client initiated reconnect"})(Qi||(Qi={}));var fe;(function(n){n.ApiError="BAD API",n.BadAuthentication="BAD_AUTHENTICATION",n.BadCreds="BAD_CREDS",n.BadHeader="BAD_HEADER",n.BadJson="BAD_JSON",n.BadPayload="BAD_PAYLOAD",n.BadSubject="BAD_SUBJECT",n.Cancelled="CANCELLED",n.ConnectionClosed="CONNECTION_CLOSED",n.ConnectionDraining="CONNECTION_DRAINING",n.ConnectionRefused="CONNECTION_REFUSED",n.ConnectionTimeout="CONNECTION_TIMEOUT",n.Disconnect="DISCONNECT",n.InvalidOption="INVALID_OPTION",n.InvalidPayload="INVALID_PAYLOAD",n.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",n.NoResponders="503",n.NotFunction="NOT_FUNC",n.RequestError="REQUEST_ERROR",n.ServerOptionNotAvailable="SERVER_OPT_NA",n.SubClosed="SUB_CLOSED",n.SubDraining="SUB_DRAINING",n.Timeout="TIMEOUT",n.Tls="TLS",n.Unknown="UNKNOWN_ERROR",n.WssRequired="WSS_REQUIRED",n.JetStreamInvalidAck="JESTREAM_INVALID_ACK",n.JetStream404NoMessages="404",n.JetStream408RequestTimeout="408",n.JetStream409MaxAckPendingExceeded="409",n.JetStream409="409",n.JetStreamNotEnabled="503",n.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",n.AuthorizationViolation="AUTHORIZATION_VIOLATION",n.AuthenticationExpired="AUTHENTICATION_EXPIRED",n.ProtocolError="NATS_PROTOCOL_ERR",n.PermissionsViolation="PERMISSIONS_VIOLATION",n.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",n.AccountExpired="ACCOUNT_EXPIRED"})(fe||(fe={}));function bE(n){return typeof n.code=="string"}class bx{constructor(){j(this,"messages");this.messages=new Map,this.messages.set(fe.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(fe.BadJson,"Bad JSON"),this.messages.set(fe.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(e){return xE.getMessage(e)}getMessage(e){return this.messages.get(e)||e}}const xE=new bx;class ge extends Error{constructor(s,i,o){super(s);j(this,"name");j(this,"message");j(this,"code");j(this,"permissionContext");j(this,"chainedError");j(this,"api_error");this.name="NatsError",this.message=s,this.code=i,this.chainedError=o}static errorForCode(s,i){const o=bx.getMessage(s);return new ge(o,s,i)}isAuthError(){return this.code===fe.AuthenticationExpired||this.code===fe.AuthorizationViolation||this.code===fe.AccountExpired}isAuthTimeout(){return this.code===fe.AuthenticationTimeout}isPermissionError(){return this.code===fe.PermissionsViolation}isProtocolError(){return this.code===fe.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var wn;(function(n){n[n.Exact=0]="Exact",n[n.CanonicalMIME=1]="CanonicalMIME",n[n.IgnoreCase=2]="IgnoreCase"})(wn||(wn={}));var Zn;(function(n){n.Timer="timer",n.Count="count",n.JitterTimer="jitterTimer",n.SentinelMsg="sentinelMsg"})(Zn||(Zn={}));var _o;(function(n){n.STATS="io.nats.micro.v1.stats_response",n.INFO="io.nats.micro.v1.info_response",n.PING="io.nats.micro.v1.ping_response"})(_o||(_o={}));const uu="Nats-Service-Error",fu="Nats-Service-Error-Code";class hu extends Error{constructor(s,i){super(i);j(this,"code");this.code=s}static isServiceError(s){return hu.toServiceError(s)!==null}static toServiceError(s){var o,c;const i=((o=s==null?void 0:s.headers)==null?void 0:o.get(fu))||"";if(i!==""){const m=parseInt(i)||400,p=((c=s==null?void 0:s.headers)==null?void 0:c.get(uu))||"";return new hu(m,p.length?p:i)}return null}}function Lr(n=""){if(n=n||"_INBOX",typeof n!="string")throw new Error("prefix must be a string");return n.split(".").forEach(e=>{if(e==="*"||e===">")throw new Error(`inbox prefixes cannot have wildcards '${n}'`)}),`${n}.${As.next()}`}const Sd="127.0.0.1";var _s;(function(n){n.PING="PING",n.STATS="STATS",n.INFO="INFO"})(_s||(_s={}));function Ou(n,...e){for(let s=0;s<e.length;s++){const i=e[s];Object.keys(i).forEach(function(o){n[o]=i[o]})}return n}function ac(n){return En.decode(n).replace(/\n/g,"␊").replace(/\r/g,"␍")}function ra(n,e=!0){const s=e?ge.errorForCode(fe.Timeout):null;let i,o;const c=new Promise((m,p)=>{i={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{p(s===null?ge.errorForCode(fe.Timeout):s)},n)});return Object.assign(c,i)}function aa(n=0){let e;const s=new Promise(i=>{const o=setTimeout(()=>{i()},n);e={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,e)}function mt(){let n={};const e=new Promise((s,i)=>{n={resolve:s,reject:i}});return Object.assign(e,n)}function xx(n){for(let e=n.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[n[e],n[s]]=[n[s],n[e]]}return n}function vE(n){return n===0?0:Math.floor(n/2+Math.random()*n)}function cm(n=[0,250,250,500,500,3e3,5e3]){Array.isArray(n)||(n=[0,250,250,500,500,3e3,5e3]);const e=n.length-1;return{backoff(s){return vE(s>e?n[e]:n[s])}}}function dt(n){return n*1e6}function um(n){return Math.floor(n/1e6)}function Wg(n){let i=!0;const o=new Array(n.length);for(let c=0;c<n.length;c++){let m=n.charCodeAt(c);if(m===58||m<33||m>126)throw new ge(`'${n[c]}' is not a valid character for a header key`,fe.BadHeader);i&&97<=m&&m<=122?m-=32:!i&&65<=m&&m<=90&&(m+=32),o[c]=m,i=m==45}return String.fromCharCode(...o)}function Pr(n=0,e=""){if(n===0&&e!==""||n>0&&e==="")throw new Error("setting status requires both code and description");return new ws(n,e)}const Zh="NATS/1.0";class ws{constructor(e=0,s=""){j(this,"_code");j(this,"headers");j(this,"_description");this._code=e,this._description=s,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[s,i]of this.headers){const o=e.values(s);if(i.length!==o.length)return!1;const c=[...i].sort(),m=[...o].sort();for(let p=0;p<c.length;p++)if(c[p]!==m[p])return!1}return!0}return!1}static decode(e){const s=new ws,o=En.decode(e).split(`\r
25
+ `+l.stack}}var ua=Object.prototype.hasOwnProperty,fa=n.unstable_scheduleCallback,hr=n.unstable_cancelCallback,zo=n.unstable_shouldYield,si=n.unstable_requestPaint,ut=n.unstable_now,Bu=n.unstable_getCurrentPriorityLevel,Io=n.unstable_ImmediatePriority,$o=n.unstable_UserBlockingPriority,ii=n.unstable_NormalPriority,Uu=n.unstable_LowPriority,Ho=n.unstable_IdlePriority,zu=n.log,Fo=n.unstable_setDisableYieldValue,Ns=null,_t=null;function fn(t){if(typeof zu=="function"&&Fo(t),_t&&typeof _t.setStrictMode=="function")try{_t.setStrictMode(Ns,t)}catch{}}var Gt=Math.clz32?Math.clz32:ai,ha=Math.log,da=Math.LN2;function ai(t){return t>>>=0,t===0?32:31-(ha(t)/da|0)|0}var zr=256,dr=262144,Ir=4194304;function Fn(t){var r=t&42;if(r!==0)return r;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ts(t,r,a){var l=t.pendingLanes;if(l===0)return 0;var f=0,y=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var O=l&134217727;return O!==0?(l=O&~y,l!==0?f=Fn(l):(w&=O,w!==0?f=Fn(w):a||(a=O&~t,a!==0&&(f=Fn(a))))):(O=l&~y,O!==0?f=Fn(O):w!==0?f=Fn(w):a||(a=l&~t,a!==0&&(f=Fn(a)))),f===0?0:r!==0&&r!==f&&(r&y)===0&&(y=f&-f,a=r&-r,y>=a||y===32&&(a&4194048)!==0)?r:f}function Cs(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function ma(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function oi(){var t=Ir;return Ir<<=1,(Ir&62914560)===0&&(Ir=4194304),t}function $r(t){for(var r=[],a=0;31>a;a++)r.push(t);return r}function Gn(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Hr(t,r,a,l,f,y){var w=t.pendingLanes;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=a,t.entangledLanes&=a,t.errorRecoveryDisabledLanes&=a,t.shellSuspendCounter=0;var O=t.entanglements,R=t.expirationTimes,V=t.hiddenUpdates;for(a=w&~a;0<a;){var Z=31-Gt(a),ie=1<<Z;O[Z]=0,R[Z]=-1;var Y=V[Z];if(Y!==null)for(V[Z]=null,Z=0;Z<Y.length;Z++){var X=Y[Z];X!==null&&(X.lane&=-536870913)}a&=~ie}l!==0&&Fr(t,l,0),y!==0&&f===0&&t.tag!==0&&(t.suspendedLanes|=y&~(w&~r))}function Fr(t,r,a){t.pendingLanes|=r,t.suspendedLanes&=~r;var l=31-Gt(r);t.entangledLanes|=r,t.entanglements[l]=t.entanglements[l]|1073741824|a&261930}function Ms(t,r){var a=t.entangledLanes|=r;for(t=t.entanglements;a;){var l=31-Gt(a),f=1<<l;f&r|t[l]&r&&(t[l]|=r),a&=~f}}function Gr(t,r){var a=r&-r;return a=(a&42)!==0?1:mr(a),(a&(t.suspendedLanes|r))!==0?0:a}function mr(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=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:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Rs(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function pa(){var t=J.p;return t!==0?t:(t=window.event,t===void 0?32:Og(t.type))}function Go(t,r){var a=J.p;try{return J.p=t,r()}finally{J.p=a}}var tr=Math.random().toString(36).slice(2),st="__reactFiber$"+tr,gt="__reactProps$"+tr,hn="__reactContainer$"+tr,Ds="__reactEvents$"+tr,ya="__reactListeners$"+tr,Vo="__reactHandles$"+tr,Yo="__reactResources$"+tr,Mt="__reactMarker$"+tr;function li(t){delete t[st],delete t[gt],delete t[Ds],delete t[ya],delete t[Vo]}function A(t){var r=t[st];if(r)return r;for(var a=t.parentNode;a;){if(r=a[hn]||a[st]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(t=cg(t);t!==null;){if(a=t[st])return a;t=cg(t)}return r}t=a,a=t.parentNode}return null}function N(t){if(t=t[st]||t[hn]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function k(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function T(t){var r=t[Yo];return r||(r=t[Yo]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function L(t){t[Mt]=!0}var $=new Set,se={};function oe(t,r){K(t,r),K(t+"Capture",r)}function K(t,r){for(se[t]=r,t=0;t<r.length;t++)$.add(r[t])}var re=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]*$"),xe={},Be={};function ot(t){return ua.call(Be,t)?!0:ua.call(xe,t)?!1:re.test(t)?Be[t]=!0:(xe[t]=!0,!1)}function Vt(t,r,a){if(ot(r))if(a===null)t.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":t.removeAttribute(r);return;case"boolean":var l=r.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){t.removeAttribute(r);return}}t.setAttribute(r,""+a)}}function Vn(t,r,a){if(a===null)t.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttribute(r,""+a)}}function pr(t,r,a,l){if(l===null)t.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttributeNS(r,a,""+l)}}function Tn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ym(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function e_(t,r,a){var l=Object.getOwnPropertyDescriptor(t.constructor.prototype,r);if(!t.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,y=l.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return f.call(this)},set:function(w){a=""+w,y.call(this,w)}}),Object.defineProperty(t,r,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(w){a=""+w},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function Iu(t){if(!t._valueTracker){var r=Ym(t)?"checked":"value";t._valueTracker=e_(t,r,""+t[r])}}function Km(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var a=r.getValue(),l="";return t&&(l=Ym(t)?t.checked?"true":"false":t.value),t=l,t!==a?(r.setValue(t),!0):!1}function Ko(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var t_=/[\n"\\]/g;function Cn(t){return t.replace(t_,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function $u(t,r,a,l,f,y,w,O){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),r!=null?w==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+Tn(r)):t.value!==""+Tn(r)&&(t.value=""+Tn(r)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),r!=null?Hu(t,w,Tn(r)):a!=null?Hu(t,w,Tn(a)):l!=null&&t.removeAttribute("value"),f==null&&y!=null&&(t.defaultChecked=!!y),f!=null&&(t.checked=f&&typeof f!="function"&&typeof f!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?t.name=""+Tn(O):t.removeAttribute("name")}function Jm(t,r,a,l,f,y,w,O){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.type=y),r!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||r!=null)){Iu(t);return}a=a!=null?""+Tn(a):"",r=r!=null?""+Tn(r):a,O||r===t.value||(t.value=r),t.defaultValue=r}l=l??f,l=typeof l!="function"&&typeof l!="symbol"&&!!l,t.checked=O?t.checked:!!l,t.defaultChecked=!!l,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),Iu(t)}function Hu(t,r,a){r==="number"&&Ko(t.ownerDocument)===t||t.defaultValue===""+a||(t.defaultValue=""+a)}function ci(t,r,a,l){if(t=t.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<t.length;a++)f=r.hasOwnProperty("$"+t[a].value),t[a].selected!==f&&(t[a].selected=f),f&&l&&(t[a].defaultSelected=!0)}else{for(a=""+Tn(a),r=null,f=0;f<t.length;f++){if(t[f].value===a){t[f].selected=!0,l&&(t[f].defaultSelected=!0);return}r!==null||t[f].disabled||(r=t[f])}r!==null&&(r.selected=!0)}}function Qm(t,r,a){if(r!=null&&(r=""+Tn(r),r!==t.value&&(t.value=r),a==null)){t.defaultValue!==r&&(t.defaultValue=r);return}t.defaultValue=a!=null?""+Tn(a):""}function Xm(t,r,a,l){if(r==null){if(l!=null){if(a!=null)throw Error(i(92));if(Ae(l)){if(1<l.length)throw Error(i(93));l=l[0]}a=l}a==null&&(a=""),r=a}a=Tn(r),t.defaultValue=a,l=t.textContent,l===a&&l!==""&&l!==null&&(t.value=l),Iu(t)}function ui(t,r){if(r){var a=t.firstChild;if(a&&a===t.lastChild&&a.nodeType===3){a.nodeValue=r;return}}t.textContent=r}var n_=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 Wm(t,r,a){var l=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?t.setProperty(r,""):r==="float"?t.cssFloat="":t[r]="":l?t.setProperty(r,a):typeof a!="number"||a===0||n_.has(r)?r==="float"?t.cssFloat=a:t[r]=(""+a).trim():t[r]=a+"px"}function Zm(t,r,a){if(r!=null&&typeof r!="object")throw Error(i(62));if(t=t.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||r!=null&&r.hasOwnProperty(l)||(l.indexOf("--")===0?t.setProperty(l,""):l==="float"?t.cssFloat="":t[l]="");for(var f in r)l=r[f],r.hasOwnProperty(f)&&a[f]!==l&&Wm(t,f,l)}else for(var y in r)r.hasOwnProperty(y)&&Wm(t,y,r[y])}function Fu(t){if(t.indexOf("-")===-1)return!1;switch(t){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 r_=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"]]),s_=/^[\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 Jo(t){return s_.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function yr(){}var Gu=null;function Vu(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var fi=null,hi=null;function e0(t){var r=N(t);if(r&&(t=r.stateNode)){var a=t[gt]||null;e:switch(t=r.stateNode,r.type){case"input":if($u(t,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=t;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Cn(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var l=a[r];if(l!==t&&l.form===t.form){var f=l[gt]||null;if(!f)throw Error(i(90));$u(l,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(r=0;r<a.length;r++)l=a[r],l.form===t.form&&Km(l)}break e;case"textarea":Qm(t,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&ci(t,!!a.multiple,r,!1)}}}var Yu=!1;function t0(t,r,a){if(Yu)return t(r,a);Yu=!0;try{var l=t(r);return l}finally{if(Yu=!1,(fi!==null||hi!==null)&&(ql(),fi&&(r=fi,t=hi,hi=fi=null,e0(r),t)))for(r=0;r<t.length;r++)e0(t[r])}}function ga(t,r){var a=t.stateNode;if(a===null)return null;var l=a[gt]||null;if(l===null)return null;a=l[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(t=t.type,l=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!l;break e;default:t=!1}if(t)return null;if(a&&typeof a!="function")throw Error(i(231,r,typeof a));return a}var gr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ku=!1;if(gr)try{var ba={};Object.defineProperty(ba,"passive",{get:function(){Ku=!0}}),window.addEventListener("test",ba,ba),window.removeEventListener("test",ba,ba)}catch{Ku=!1}var Vr=null,Ju=null,Qo=null;function n0(){if(Qo)return Qo;var t,r=Ju,a=r.length,l,f="value"in Vr?Vr.value:Vr.textContent,y=f.length;for(t=0;t<a&&r[t]===f[t];t++);var w=a-t;for(l=1;l<=w&&r[a-l]===f[y-l];l++);return Qo=f.slice(t,1<l?1-l:void 0)}function Xo(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Wo(){return!0}function r0(){return!1}function rn(t){function r(a,l,f,y,w){this._reactName=a,this._targetInst=f,this.type=l,this.nativeEvent=y,this.target=w,this.currentTarget=null;for(var O in t)t.hasOwnProperty(O)&&(a=t[O],this[O]=a?a(y):y[O]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Wo:r0,this.isPropagationStopped=r0,this}return b(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Wo)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Wo)},persist:function(){},isPersistent:Wo}),r}var Ls={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zo=rn(Ls),xa=b({},Ls,{view:0,detail:0}),i_=rn(xa),Qu,Xu,va,el=b({},xa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zu,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==va&&(va&&t.type==="mousemove"?(Qu=t.screenX-va.screenX,Xu=t.screenY-va.screenY):Xu=Qu=0,va=t),Qu)},movementY:function(t){return"movementY"in t?t.movementY:Xu}}),s0=rn(el),a_=b({},el,{dataTransfer:0}),o_=rn(a_),l_=b({},xa,{relatedTarget:0}),Wu=rn(l_),c_=b({},Ls,{animationName:0,elapsedTime:0,pseudoElement:0}),u_=rn(c_),f_=b({},Ls,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),h_=rn(f_),d_=b({},Ls,{data:0}),i0=rn(d_),m_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},p_={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"},y_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function g_(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=y_[t])?!!r[t]:!1}function Zu(){return g_}var b_=b({},xa,{key:function(t){if(t.key){var r=m_[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Xo(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?p_[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zu,charCode:function(t){return t.type==="keypress"?Xo(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Xo(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),x_=rn(b_),v_=b({},el,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),a0=rn(v_),__=b({},xa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zu}),w_=rn(__),S_=b({},Ls,{propertyName:0,elapsedTime:0,pseudoElement:0}),E_=rn(S_),O_=b({},el,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),A_=rn(O_),j_=b({},Ls,{newState:0,oldState:0}),k_=rn(j_),N_=[9,13,27,32],ef=gr&&"CompositionEvent"in window,_a=null;gr&&"documentMode"in document&&(_a=document.documentMode);var T_=gr&&"TextEvent"in window&&!_a,o0=gr&&(!ef||_a&&8<_a&&11>=_a),l0=" ",c0=!1;function u0(t,r){switch(t){case"keyup":return N_.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function f0(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var di=!1;function C_(t,r){switch(t){case"compositionend":return f0(r);case"keypress":return r.which!==32?null:(c0=!0,l0);case"textInput":return t=r.data,t===l0&&c0?null:t;default:return null}}function M_(t,r){if(di)return t==="compositionend"||!ef&&u0(t,r)?(t=n0(),Qo=Ju=Vr=null,di=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return o0&&r.locale!=="ko"?null:r.data;default:return null}}var R_={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 h0(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!R_[t.type]:r==="textarea"}function d0(t,r,a,l){fi?hi?hi.push(l):hi=[l]:fi=l,r=Hl(r,"onChange"),0<r.length&&(a=new Zo("onChange","change",null,a,l),t.push({event:a,listeners:r}))}var wa=null,Sa=null;function D_(t){Jy(t,0)}function tl(t){var r=k(t);if(Km(r))return t}function m0(t,r){if(t==="change")return r}var p0=!1;if(gr){var tf;if(gr){var nf="oninput"in document;if(!nf){var y0=document.createElement("div");y0.setAttribute("oninput","return;"),nf=typeof y0.oninput=="function"}tf=nf}else tf=!1;p0=tf&&(!document.documentMode||9<document.documentMode)}function g0(){wa&&(wa.detachEvent("onpropertychange",b0),Sa=wa=null)}function b0(t){if(t.propertyName==="value"&&tl(Sa)){var r=[];d0(r,Sa,t,Vu(t)),t0(D_,r)}}function L_(t,r,a){t==="focusin"?(g0(),wa=r,Sa=a,wa.attachEvent("onpropertychange",b0)):t==="focusout"&&g0()}function q_(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return tl(Sa)}function P_(t,r){if(t==="click")return tl(r)}function B_(t,r){if(t==="input"||t==="change")return tl(r)}function U_(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var dn=typeof Object.is=="function"?Object.is:U_;function Ea(t,r){if(dn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var a=Object.keys(t),l=Object.keys(r);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var f=a[l];if(!ua.call(r,f)||!dn(t[f],r[f]))return!1}return!0}function x0(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function v0(t,r){var a=x0(t);t=0;for(var l;a;){if(a.nodeType===3){if(l=t+a.textContent.length,t<=r&&l>=r)return{node:a,offset:r-t};t=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=x0(a)}}function _0(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?_0(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function w0(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=Ko(t.document);r instanceof t.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)t=r.contentWindow;else break;r=Ko(t.document)}return r}function rf(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var z_=gr&&"documentMode"in document&&11>=document.documentMode,mi=null,sf=null,Oa=null,af=!1;function S0(t,r,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;af||mi==null||mi!==Ko(l)||(l=mi,"selectionStart"in l&&rf(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}),Oa&&Ea(Oa,l)||(Oa=l,l=Hl(sf,"onSelect"),0<l.length&&(r=new Zo("onSelect","select",null,r,a),t.push({event:r,listeners:l}),r.target=mi)))}function qs(t,r){var a={};return a[t.toLowerCase()]=r.toLowerCase(),a["Webkit"+t]="webkit"+r,a["Moz"+t]="moz"+r,a}var pi={animationend:qs("Animation","AnimationEnd"),animationiteration:qs("Animation","AnimationIteration"),animationstart:qs("Animation","AnimationStart"),transitionrun:qs("Transition","TransitionRun"),transitionstart:qs("Transition","TransitionStart"),transitioncancel:qs("Transition","TransitionCancel"),transitionend:qs("Transition","TransitionEnd")},of={},E0={};gr&&(E0=document.createElement("div").style,"AnimationEvent"in window||(delete pi.animationend.animation,delete pi.animationiteration.animation,delete pi.animationstart.animation),"TransitionEvent"in window||delete pi.transitionend.transition);function Ps(t){if(of[t])return of[t];if(!pi[t])return t;var r=pi[t],a;for(a in r)if(r.hasOwnProperty(a)&&a in E0)return of[t]=r[a];return t}var O0=Ps("animationend"),A0=Ps("animationiteration"),j0=Ps("animationstart"),I_=Ps("transitionrun"),$_=Ps("transitionstart"),H_=Ps("transitioncancel"),k0=Ps("transitionend"),N0=new Map,lf="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(" ");lf.push("scrollEnd");function Yn(t,r){N0.set(t,r),oe(r,[t])}var nl=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Mn=[],yi=0,cf=0;function rl(){for(var t=yi,r=cf=yi=0;r<t;){var a=Mn[r];Mn[r++]=null;var l=Mn[r];Mn[r++]=null;var f=Mn[r];Mn[r++]=null;var y=Mn[r];if(Mn[r++]=null,l!==null&&f!==null){var w=l.pending;w===null?f.next=f:(f.next=w.next,w.next=f),l.pending=f}y!==0&&T0(a,f,y)}}function sl(t,r,a,l){Mn[yi++]=t,Mn[yi++]=r,Mn[yi++]=a,Mn[yi++]=l,cf|=l,t.lanes|=l,t=t.alternate,t!==null&&(t.lanes|=l)}function uf(t,r,a,l){return sl(t,r,a,l),il(t)}function Bs(t,r){return sl(t,null,null,r),il(t)}function T0(t,r,a){t.lanes|=a;var l=t.alternate;l!==null&&(l.lanes|=a);for(var f=!1,y=t.return;y!==null;)y.childLanes|=a,l=y.alternate,l!==null&&(l.childLanes|=a),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(f=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,f&&r!==null&&(f=31-Gt(a),t=y.hiddenUpdates,l=t[f],l===null?t[f]=[r]:l.push(r),r.lane=a|536870912),y):null}function il(t){if(50<Ya)throw Ya=0,xh=null,Error(i(185));for(var r=t.return;r!==null;)t=r,r=t.return;return t.tag===3?t.stateNode:null}var gi={};function F_(t,r,a,l){this.tag=t,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mn(t,r,a,l){return new F_(t,r,a,l)}function ff(t){return t=t.prototype,!(!t||!t.isReactComponent)}function br(t,r){var a=t.alternate;return a===null?(a=mn(t.tag,r,t.key,t.mode),a.elementType=t.elementType,a.type=t.type,a.stateNode=t.stateNode,a.alternate=t,t.alternate=a):(a.pendingProps=r,a.type=t.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=t.flags&65011712,a.childLanes=t.childLanes,a.lanes=t.lanes,a.child=t.child,a.memoizedProps=t.memoizedProps,a.memoizedState=t.memoizedState,a.updateQueue=t.updateQueue,r=t.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=t.sibling,a.index=t.index,a.ref=t.ref,a.refCleanup=t.refCleanup,a}function C0(t,r){t.flags&=65011714;var a=t.alternate;return a===null?(t.childLanes=0,t.lanes=r,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=a.childLanes,t.lanes=a.lanes,t.child=a.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=a.memoizedProps,t.memoizedState=a.memoizedState,t.updateQueue=a.updateQueue,t.type=a.type,r=a.dependencies,t.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),t}function al(t,r,a,l,f,y){var w=0;if(l=t,typeof t=="function")ff(t)&&(w=1);else if(typeof t=="string")w=Jw(t,a,Xe.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case U:return t=mn(31,a,r,f),t.elementType=U,t.lanes=y,t;case S:return Us(a.children,f,y,r);case C:w=8,f|=24;break;case B:return t=mn(12,a,r,f|2),t.elementType=B,t.lanes=y,t;case M:return t=mn(13,a,r,f),t.elementType=M,t.lanes=y,t;case z:return t=mn(19,a,r,f),t.elementType=z,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ne:w=10;break e;case q:w=9;break e;case te:w=11;break e;case ae:w=14;break e;case F:w=16,l=null;break e}w=29,a=Error(i(130,t===null?"null":typeof t,"")),l=null}return r=mn(w,a,r,f),r.elementType=t,r.type=l,r.lanes=y,r}function Us(t,r,a,l){return t=mn(7,t,l,r),t.lanes=a,t}function hf(t,r,a){return t=mn(6,t,null,r),t.lanes=a,t}function M0(t){var r=mn(18,null,null,0);return r.stateNode=t,r}function df(t,r,a){return r=mn(4,t.children!==null?t.children:[],t.key,r),r.lanes=a,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}var R0=new WeakMap;function Rn(t,r){if(typeof t=="object"&&t!==null){var a=R0.get(t);return a!==void 0?a:(r={value:t,source:r,stack:Ur(r)},R0.set(t,r),r)}return{value:t,source:r,stack:Ur(r)}}var bi=[],xi=0,ol=null,Aa=0,Dn=[],Ln=0,Yr=null,nr=1,rr="";function xr(t,r){bi[xi++]=Aa,bi[xi++]=ol,ol=t,Aa=r}function D0(t,r,a){Dn[Ln++]=nr,Dn[Ln++]=rr,Dn[Ln++]=Yr,Yr=t;var l=nr;t=rr;var f=32-Gt(l)-1;l&=~(1<<f),a+=1;var y=32-Gt(r)+f;if(30<y){var w=f-f%5;y=(l&(1<<w)-1).toString(32),l>>=w,f-=w,nr=1<<32-Gt(r)+f|a<<f|l,rr=y+t}else nr=1<<y|a<<f|l,rr=t}function mf(t){t.return!==null&&(xr(t,1),D0(t,1,0))}function pf(t){for(;t===ol;)ol=bi[--xi],bi[xi]=null,Aa=bi[--xi],bi[xi]=null;for(;t===Yr;)Yr=Dn[--Ln],Dn[Ln]=null,rr=Dn[--Ln],Dn[Ln]=null,nr=Dn[--Ln],Dn[Ln]=null}function L0(t,r){Dn[Ln++]=nr,Dn[Ln++]=rr,Dn[Ln++]=Yr,nr=r.id,rr=r.overflow,Yr=t}var It=null,lt=null,Fe=!1,Kr=null,qn=!1,yf=Error(i(519));function Jr(t){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ja(Rn(r,t)),yf}function q0(t){var r=t.stateNode,a=t.type,l=t.memoizedProps;switch(r[st]=t,r[gt]=l,a){case"dialog":ze("cancel",r),ze("close",r);break;case"iframe":case"object":case"embed":ze("load",r);break;case"video":case"audio":for(a=0;a<Ja.length;a++)ze(Ja[a],r);break;case"source":ze("error",r);break;case"img":case"image":case"link":ze("error",r),ze("load",r);break;case"details":ze("toggle",r);break;case"input":ze("invalid",r),Jm(r,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":ze("invalid",r);break;case"textarea":ze("invalid",r),Xm(r,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||l.suppressHydrationWarning===!0||Zy(r.textContent,a)?(l.popover!=null&&(ze("beforetoggle",r),ze("toggle",r)),l.onScroll!=null&&ze("scroll",r),l.onScrollEnd!=null&&ze("scrollend",r),l.onClick!=null&&(r.onclick=yr),r=!0):r=!1,r||Jr(t,!0)}function P0(t){for(It=t.return;It;)switch(It.tag){case 5:case 31:case 13:qn=!1;return;case 27:case 3:qn=!0;return;default:It=It.return}}function vi(t){if(t!==It)return!1;if(!Fe)return P0(t),Fe=!0,!1;var r=t.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=t.type,a=!(a!=="form"&&a!=="button")||Dh(t.type,t.memoizedProps)),a=!a),a&&lt&&Jr(t),P0(t),r===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));lt=lg(t)}else if(r===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(317));lt=lg(t)}else r===27?(r=lt,cs(t.type)?(t=Uh,Uh=null,lt=t):lt=r):lt=It?Bn(t.stateNode.nextSibling):null;return!0}function zs(){lt=It=null,Fe=!1}function gf(){var t=Kr;return t!==null&&(ln===null?ln=t:ln.push.apply(ln,t),Kr=null),t}function ja(t){Kr===null?Kr=[t]:Kr.push(t)}var bf=Ce(null),Is=null,vr=null;function Qr(t,r,a){Me(bf,r._currentValue),r._currentValue=a}function _r(t){t._currentValue=bf.current,Ne(bf)}function xf(t,r,a){for(;t!==null;){var l=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,l!==null&&(l.childLanes|=r)):l!==null&&(l.childLanes&r)!==r&&(l.childLanes|=r),t===a)break;t=t.return}}function vf(t,r,a,l){var f=t.child;for(f!==null&&(f.return=t);f!==null;){var y=f.dependencies;if(y!==null){var w=f.child;y=y.firstContext;e:for(;y!==null;){var O=y;y=f;for(var R=0;R<r.length;R++)if(O.context===r[R]){y.lanes|=a,O=y.alternate,O!==null&&(O.lanes|=a),xf(y.return,a,t),l||(w=null);break e}y=O.next}}else if(f.tag===18){if(w=f.return,w===null)throw Error(i(341));w.lanes|=a,y=w.alternate,y!==null&&(y.lanes|=a),xf(w,a,t),w=null}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===t){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}}function _i(t,r,a,l){t=null;for(var f=r,y=!1;f!==null;){if(!y){if((f.flags&524288)!==0)y=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var w=f.alternate;if(w===null)throw Error(i(387));if(w=w.memoizedProps,w!==null){var O=f.type;dn(f.pendingProps.value,w.value)||(t!==null?t.push(O):t=[O])}}else if(f===mt.current){if(w=f.alternate,w===null)throw Error(i(387));w.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(t!==null?t.push(eo):t=[eo])}f=f.return}t!==null&&vf(r,t,a,l),r.flags|=262144}function ll(t){for(t=t.firstContext;t!==null;){if(!dn(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function $s(t){Is=t,vr=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function $t(t){return B0(Is,t)}function cl(t,r){return Is===null&&$s(t),B0(t,r)}function B0(t,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},vr===null){if(t===null)throw Error(i(308));vr=r,t.dependencies={lanes:0,firstContext:r},t.flags|=524288}else vr=vr.next=r;return a}var G_=typeof AbortController<"u"?AbortController:function(){var t=[],r=this.signal={aborted:!1,addEventListener:function(a,l){t.push(l)}};this.abort=function(){r.aborted=!0,t.forEach(function(a){return a()})}},V_=n.unstable_scheduleCallback,Y_=n.unstable_NormalPriority,jt={$$typeof:ne,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _f(){return{controller:new G_,data:new Map,refCount:0}}function ka(t){t.refCount--,t.refCount===0&&V_(Y_,function(){t.controller.abort()})}var Na=null,wf=0,wi=0,Si=null;function K_(t,r){if(Na===null){var a=Na=[];wf=0,wi=Oh(),Si={status:"pending",value:void 0,then:function(l){a.push(l)}}}return wf++,r.then(U0,U0),r}function U0(){if(--wf===0&&Na!==null){Si!==null&&(Si.status="fulfilled");var t=Na;Na=null,wi=0,Si=null;for(var r=0;r<t.length;r++)(0,t[r])()}}function J_(t,r){var a=[],l={status:"pending",value:null,reason:null,then:function(f){a.push(f)}};return t.then(function(){l.status="fulfilled",l.value=r;for(var f=0;f<a.length;f++)(0,a[f])(r)},function(f){for(l.status="rejected",l.reason=f,f=0;f<a.length;f++)(0,a[f])(void 0)}),l}var z0=H.S;H.S=function(t,r){Sy=ut(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&K_(t,r),z0!==null&&z0(t,r)};var Hs=Ce(null);function Sf(){var t=Hs.current;return t!==null?t:it.pooledCache}function ul(t,r){r===null?Me(Hs,Hs.current):Me(Hs,r.pool)}function I0(){var t=Sf();return t===null?null:{parent:jt._currentValue,pool:t}}var Ei=Error(i(460)),Ef=Error(i(474)),fl=Error(i(542)),hl={then:function(){}};function $0(t){return t=t.status,t==="fulfilled"||t==="rejected"}function H0(t,r,a){switch(a=t[a],a===void 0?t.push(r):a!==r&&(r.then(yr,yr),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,G0(t),t;default:if(typeof r.status=="string")r.then(yr,yr);else{if(t=it,t!==null&&100<t.shellSuspendCounter)throw Error(i(482));t=r,t.status="pending",t.then(function(l){if(r.status==="pending"){var f=r;f.status="fulfilled",f.value=l}},function(l){if(r.status==="pending"){var f=r;f.status="rejected",f.reason=l}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw t=r.reason,G0(t),t}throw Gs=r,Ei}}function Fs(t){try{var r=t._init;return r(t._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Gs=a,Ei):a}}var Gs=null;function F0(){if(Gs===null)throw Error(i(459));var t=Gs;return Gs=null,t}function G0(t){if(t===Ei||t===fl)throw Error(i(483))}var Oi=null,Ta=0;function dl(t){var r=Ta;return Ta+=1,Oi===null&&(Oi=[]),H0(Oi,t,r)}function Ca(t,r){r=r.props.ref,t.ref=r!==void 0?r:null}function ml(t,r){throw r.$$typeof===x?Error(i(525)):(t=Object.prototype.toString.call(r),Error(i(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t)))}function V0(t){function r(I,P){if(t){var G=I.deletions;G===null?(I.deletions=[P],I.flags|=16):G.push(P)}}function a(I,P){if(!t)return null;for(;P!==null;)r(I,P),P=P.sibling;return null}function l(I){for(var P=new Map;I!==null;)I.key!==null?P.set(I.key,I):P.set(I.index,I),I=I.sibling;return P}function f(I,P){return I=br(I,P),I.index=0,I.sibling=null,I}function y(I,P,G){return I.index=G,t?(G=I.alternate,G!==null?(G=G.index,G<P?(I.flags|=67108866,P):G):(I.flags|=67108866,P)):(I.flags|=1048576,P)}function w(I){return t&&I.alternate===null&&(I.flags|=67108866),I}function O(I,P,G,ee){return P===null||P.tag!==6?(P=hf(G,I.mode,ee),P.return=I,P):(P=f(P,G),P.return=I,P)}function R(I,P,G,ee){var je=G.type;return je===S?Z(I,P,G.props.children,ee,G.key):P!==null&&(P.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===F&&Fs(je)===P.type)?(P=f(P,G.props),Ca(P,G),P.return=I,P):(P=al(G.type,G.key,G.props,null,I.mode,ee),Ca(P,G),P.return=I,P)}function V(I,P,G,ee){return P===null||P.tag!==4||P.stateNode.containerInfo!==G.containerInfo||P.stateNode.implementation!==G.implementation?(P=df(G,I.mode,ee),P.return=I,P):(P=f(P,G.children||[]),P.return=I,P)}function Z(I,P,G,ee,je){return P===null||P.tag!==7?(P=Us(G,I.mode,ee,je),P.return=I,P):(P=f(P,G),P.return=I,P)}function ie(I,P,G){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=hf(""+P,I.mode,G),P.return=I,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case v:return G=al(P.type,P.key,P.props,null,I.mode,G),Ca(G,P),G.return=I,G;case _:return P=df(P,I.mode,G),P.return=I,P;case F:return P=Fs(P),ie(I,P,G)}if(Ae(P)||W(P))return P=Us(P,I.mode,G,null),P.return=I,P;if(typeof P.then=="function")return ie(I,dl(P),G);if(P.$$typeof===ne)return ie(I,cl(I,P),G);ml(I,P)}return null}function Y(I,P,G,ee){var je=P!==null?P.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return je!==null?null:O(I,P,""+G,ee);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case v:return G.key===je?R(I,P,G,ee):null;case _:return G.key===je?V(I,P,G,ee):null;case F:return G=Fs(G),Y(I,P,G,ee)}if(Ae(G)||W(G))return je!==null?null:Z(I,P,G,ee,null);if(typeof G.then=="function")return Y(I,P,dl(G),ee);if(G.$$typeof===ne)return Y(I,P,cl(I,G),ee);ml(I,G)}return null}function X(I,P,G,ee,je){if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return I=I.get(G)||null,O(P,I,""+ee,je);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case v:return I=I.get(ee.key===null?G:ee.key)||null,R(P,I,ee,je);case _:return I=I.get(ee.key===null?G:ee.key)||null,V(P,I,ee,je);case F:return ee=Fs(ee),X(I,P,G,ee,je)}if(Ae(ee)||W(ee))return I=I.get(G)||null,Z(P,I,ee,je,null);if(typeof ee.then=="function")return X(I,P,G,dl(ee),je);if(ee.$$typeof===ne)return X(I,P,G,cl(P,ee),je);ml(P,ee)}return null}function ve(I,P,G,ee){for(var je=null,Ke=null,we=P,De=P=0,He=null;we!==null&&De<G.length;De++){we.index>De?(He=we,we=null):He=we.sibling;var Je=Y(I,we,G[De],ee);if(Je===null){we===null&&(we=He);break}t&&we&&Je.alternate===null&&r(I,we),P=y(Je,P,De),Ke===null?je=Je:Ke.sibling=Je,Ke=Je,we=He}if(De===G.length)return a(I,we),Fe&&xr(I,De),je;if(we===null){for(;De<G.length;De++)we=ie(I,G[De],ee),we!==null&&(P=y(we,P,De),Ke===null?je=we:Ke.sibling=we,Ke=we);return Fe&&xr(I,De),je}for(we=l(we);De<G.length;De++)He=X(we,I,De,G[De],ee),He!==null&&(t&&He.alternate!==null&&we.delete(He.key===null?De:He.key),P=y(He,P,De),Ke===null?je=He:Ke.sibling=He,Ke=He);return t&&we.forEach(function(ms){return r(I,ms)}),Fe&&xr(I,De),je}function Te(I,P,G,ee){if(G==null)throw Error(i(151));for(var je=null,Ke=null,we=P,De=P=0,He=null,Je=G.next();we!==null&&!Je.done;De++,Je=G.next()){we.index>De?(He=we,we=null):He=we.sibling;var ms=Y(I,we,Je.value,ee);if(ms===null){we===null&&(we=He);break}t&&we&&ms.alternate===null&&r(I,we),P=y(ms,P,De),Ke===null?je=ms:Ke.sibling=ms,Ke=ms,we=He}if(Je.done)return a(I,we),Fe&&xr(I,De),je;if(we===null){for(;!Je.done;De++,Je=G.next())Je=ie(I,Je.value,ee),Je!==null&&(P=y(Je,P,De),Ke===null?je=Je:Ke.sibling=Je,Ke=Je);return Fe&&xr(I,De),je}for(we=l(we);!Je.done;De++,Je=G.next())Je=X(we,I,De,Je.value,ee),Je!==null&&(t&&Je.alternate!==null&&we.delete(Je.key===null?De:Je.key),P=y(Je,P,De),Ke===null?je=Je:Ke.sibling=Je,Ke=Je);return t&&we.forEach(function(aS){return r(I,aS)}),Fe&&xr(I,De),je}function rt(I,P,G,ee){if(typeof G=="object"&&G!==null&&G.type===S&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case v:e:{for(var je=G.key;P!==null;){if(P.key===je){if(je=G.type,je===S){if(P.tag===7){a(I,P.sibling),ee=f(P,G.props.children),ee.return=I,I=ee;break e}}else if(P.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===F&&Fs(je)===P.type){a(I,P.sibling),ee=f(P,G.props),Ca(ee,G),ee.return=I,I=ee;break e}a(I,P);break}else r(I,P);P=P.sibling}G.type===S?(ee=Us(G.props.children,I.mode,ee,G.key),ee.return=I,I=ee):(ee=al(G.type,G.key,G.props,null,I.mode,ee),Ca(ee,G),ee.return=I,I=ee)}return w(I);case _:e:{for(je=G.key;P!==null;){if(P.key===je)if(P.tag===4&&P.stateNode.containerInfo===G.containerInfo&&P.stateNode.implementation===G.implementation){a(I,P.sibling),ee=f(P,G.children||[]),ee.return=I,I=ee;break e}else{a(I,P);break}else r(I,P);P=P.sibling}ee=df(G,I.mode,ee),ee.return=I,I=ee}return w(I);case F:return G=Fs(G),rt(I,P,G,ee)}if(Ae(G))return ve(I,P,G,ee);if(W(G)){if(je=W(G),typeof je!="function")throw Error(i(150));return G=je.call(G),Te(I,P,G,ee)}if(typeof G.then=="function")return rt(I,P,dl(G),ee);if(G.$$typeof===ne)return rt(I,P,cl(I,G),ee);ml(I,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,P!==null&&P.tag===6?(a(I,P.sibling),ee=f(P,G),ee.return=I,I=ee):(a(I,P),ee=hf(G,I.mode,ee),ee.return=I,I=ee),w(I)):a(I,P)}return function(I,P,G,ee){try{Ta=0;var je=rt(I,P,G,ee);return Oi=null,je}catch(we){if(we===Ei||we===fl)throw we;var Ke=mn(29,we,null,I.mode);return Ke.lanes=ee,Ke.return=I,Ke}finally{}}}var Vs=V0(!0),Y0=V0(!1),Xr=!1;function Of(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Af(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Wr(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Zr(t,r,a){var l=t.updateQueue;if(l===null)return null;if(l=l.shared,(Qe&2)!==0){var f=l.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),l.pending=r,r=il(t),T0(t,null,a),r}return sl(t,l,r,a),il(t)}function Ma(t,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var l=r.lanes;l&=t.pendingLanes,a|=l,r.lanes=a,Ms(t,a)}}function jf(t,r){var a=t.updateQueue,l=t.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var f=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var w={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?f=y=w:y=y.next=w,a=a.next}while(a!==null);y===null?f=y=r:y=y.next=r}else f=y=r;a={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:y,shared:l.shared,callbacks:l.callbacks},t.updateQueue=a;return}t=a.lastBaseUpdate,t===null?a.firstBaseUpdate=r:t.next=r,a.lastBaseUpdate=r}var kf=!1;function Ra(){if(kf){var t=Si;if(t!==null)throw t}}function Da(t,r,a,l){kf=!1;var f=t.updateQueue;Xr=!1;var y=f.firstBaseUpdate,w=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var R=O,V=R.next;R.next=null,w===null?y=V:w.next=V,w=R;var Z=t.alternate;Z!==null&&(Z=Z.updateQueue,O=Z.lastBaseUpdate,O!==w&&(O===null?Z.firstBaseUpdate=V:O.next=V,Z.lastBaseUpdate=R))}if(y!==null){var ie=f.baseState;w=0,Z=V=R=null,O=y;do{var Y=O.lane&-536870913,X=Y!==O.lane;if(X?($e&Y)===Y:(l&Y)===Y){Y!==0&&Y===wi&&(kf=!0),Z!==null&&(Z=Z.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var ve=t,Te=O;Y=r;var rt=a;switch(Te.tag){case 1:if(ve=Te.payload,typeof ve=="function"){ie=ve.call(rt,ie,Y);break e}ie=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Te.payload,Y=typeof ve=="function"?ve.call(rt,ie,Y):ve,Y==null)break e;ie=b({},ie,Y);break e;case 2:Xr=!0}}Y=O.callback,Y!==null&&(t.flags|=64,X&&(t.flags|=8192),X=f.callbacks,X===null?f.callbacks=[Y]:X.push(Y))}else X={lane:Y,tag:O.tag,payload:O.payload,callback:O.callback,next:null},Z===null?(V=Z=X,R=ie):Z=Z.next=X,w|=Y;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;X=O,O=X.next,X.next=null,f.lastBaseUpdate=X,f.shared.pending=null}}while(!0);Z===null&&(R=ie),f.baseState=R,f.firstBaseUpdate=V,f.lastBaseUpdate=Z,y===null&&(f.shared.lanes=0),ss|=w,t.lanes=w,t.memoizedState=ie}}function K0(t,r){if(typeof t!="function")throw Error(i(191,t));t.call(r)}function J0(t,r){var a=t.callbacks;if(a!==null)for(t.callbacks=null,t=0;t<a.length;t++)K0(a[t],r)}var Ai=Ce(null),pl=Ce(0);function Q0(t,r){t=Tr,Me(pl,t),Me(Ai,r),Tr=t|r.baseLanes}function Nf(){Me(pl,Tr),Me(Ai,Ai.current)}function Tf(){Tr=pl.current,Ne(Ai),Ne(pl)}var pn=Ce(null),Pn=null;function es(t){var r=t.alternate;Me(wt,wt.current&1),Me(pn,t),Pn===null&&(r===null||Ai.current!==null||r.memoizedState!==null)&&(Pn=t)}function Cf(t){Me(wt,wt.current),Me(pn,t),Pn===null&&(Pn=t)}function X0(t){t.tag===22?(Me(wt,wt.current),Me(pn,t),Pn===null&&(Pn=t)):ts()}function ts(){Me(wt,wt.current),Me(pn,pn.current)}function yn(t){Ne(pn),Pn===t&&(Pn=null),Ne(wt)}var wt=Ce(0);function yl(t){for(var r=t;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Ph(a)||Bh(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var wr=0,Re=null,tt=null,kt=null,gl=!1,ji=!1,Ys=!1,bl=0,La=0,ki=null,Q_=0;function bt(){throw Error(i(321))}function Mf(t,r){if(r===null)return!1;for(var a=0;a<r.length&&a<t.length;a++)if(!dn(t[a],r[a]))return!1;return!0}function Rf(t,r,a,l,f,y){return wr=y,Re=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,H.H=t===null||t.memoizedState===null?Dp:Kf,Ys=!1,y=a(l,f),Ys=!1,ji&&(y=Z0(r,a,l,f)),W0(t),y}function W0(t){H.H=Ba;var r=tt!==null&&tt.next!==null;if(wr=0,kt=tt=Re=null,gl=!1,La=0,ki=null,r)throw Error(i(300));t===null||Nt||(t=t.dependencies,t!==null&&ll(t)&&(Nt=!0))}function Z0(t,r,a,l){Re=t;var f=0;do{if(ji&&(ki=null),La=0,ji=!1,25<=f)throw Error(i(301));if(f+=1,kt=tt=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}H.H=Lp,y=r(a,l)}while(ji);return y}function X_(){var t=H.H,r=t.useState()[0];return r=typeof r.then=="function"?qa(r):r,t=t.useState()[0],(tt!==null?tt.memoizedState:null)!==t&&(Re.flags|=1024),r}function Df(){var t=bl!==0;return bl=0,t}function Lf(t,r,a){r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~a}function qf(t){if(gl){for(t=t.memoizedState;t!==null;){var r=t.queue;r!==null&&(r.pending=null),t=t.next}gl=!1}wr=0,kt=tt=Re=null,ji=!1,La=bl=0,ki=null}function Kt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return kt===null?Re.memoizedState=kt=t:kt=kt.next=t,kt}function St(){if(tt===null){var t=Re.alternate;t=t!==null?t.memoizedState:null}else t=tt.next;var r=kt===null?Re.memoizedState:kt.next;if(r!==null)kt=r,tt=t;else{if(t===null)throw Re.alternate===null?Error(i(467)):Error(i(310));tt=t,t={memoizedState:tt.memoizedState,baseState:tt.baseState,baseQueue:tt.baseQueue,queue:tt.queue,next:null},kt===null?Re.memoizedState=kt=t:kt=kt.next=t}return kt}function xl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function qa(t){var r=La;return La+=1,ki===null&&(ki=[]),t=H0(ki,t,r),r=Re,(kt===null?r.memoizedState:kt.next)===null&&(r=r.alternate,H.H=r===null||r.memoizedState===null?Dp:Kf),t}function vl(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return qa(t);if(t.$$typeof===ne)return $t(t)}throw Error(i(438,String(t)))}function Pf(t){var r=null,a=Re.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var l=Re.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(r={data:l.data.map(function(f){return f.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=xl(),Re.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(t),l=0;l<t;l++)a[l]=D;return r.index++,a}function Sr(t,r){return typeof r=="function"?r(t):r}function _l(t){var r=St();return Bf(r,tt,t)}function Bf(t,r,a){var l=t.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=a;var f=t.baseQueue,y=l.pending;if(y!==null){if(f!==null){var w=f.next;f.next=y.next,y.next=w}r.baseQueue=f=y,l.pending=null}if(y=t.baseState,f===null)t.memoizedState=y;else{r=f.next;var O=w=null,R=null,V=r,Z=!1;do{var ie=V.lane&-536870913;if(ie!==V.lane?($e&ie)===ie:(wr&ie)===ie){var Y=V.revertLane;if(Y===0)R!==null&&(R=R.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),ie===wi&&(Z=!0);else if((wr&Y)===Y){V=V.next,Y===wi&&(Z=!0);continue}else ie={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},R===null?(O=R=ie,w=y):R=R.next=ie,Re.lanes|=Y,ss|=Y;ie=V.action,Ys&&a(y,ie),y=V.hasEagerState?V.eagerState:a(y,ie)}else Y={lane:ie,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},R===null?(O=R=Y,w=y):R=R.next=Y,Re.lanes|=ie,ss|=ie;V=V.next}while(V!==null&&V!==r);if(R===null?w=y:R.next=O,!dn(y,t.memoizedState)&&(Nt=!0,Z&&(a=Si,a!==null)))throw a;t.memoizedState=y,t.baseState=w,t.baseQueue=R,l.lastRenderedState=y}return f===null&&(l.lanes=0),[t.memoizedState,l.dispatch]}function Uf(t){var r=St(),a=r.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=t;var l=a.dispatch,f=a.pending,y=r.memoizedState;if(f!==null){a.pending=null;var w=f=f.next;do y=t(y,w.action),w=w.next;while(w!==f);dn(y,r.memoizedState)||(Nt=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),a.lastRenderedState=y}return[y,l]}function ep(t,r,a){var l=Re,f=St(),y=Fe;if(y){if(a===void 0)throw Error(i(407));a=a()}else a=r();var w=!dn((tt||f).memoizedState,a);if(w&&(f.memoizedState=a,Nt=!0),f=f.queue,$f(rp.bind(null,l,f,t),[t]),f.getSnapshot!==r||w||kt!==null&&kt.memoizedState.tag&1){if(l.flags|=2048,Ni(9,{destroy:void 0},np.bind(null,l,f,a,r),null),it===null)throw Error(i(349));y||(wr&127)!==0||tp(l,r,a)}return a}function tp(t,r,a){t.flags|=16384,t={getSnapshot:r,value:a},r=Re.updateQueue,r===null?(r=xl(),Re.updateQueue=r,r.stores=[t]):(a=r.stores,a===null?r.stores=[t]:a.push(t))}function np(t,r,a,l){r.value=a,r.getSnapshot=l,sp(r)&&ip(t)}function rp(t,r,a){return a(function(){sp(r)&&ip(t)})}function sp(t){var r=t.getSnapshot;t=t.value;try{var a=r();return!dn(t,a)}catch{return!0}}function ip(t){var r=Bs(t,2);r!==null&&cn(r,t,2)}function zf(t){var r=Kt();if(typeof t=="function"){var a=t;if(t=a(),Ys){fn(!0);try{a()}finally{fn(!1)}}}return r.memoizedState=r.baseState=t,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:t},r}function ap(t,r,a,l){return t.baseState=a,Bf(t,tt,typeof l=="function"?l:Sr)}function W_(t,r,a,l,f){if(El(t))throw Error(i(485));if(t=r.action,t!==null){var y={payload:f,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){y.listeners.push(w)}};H.T!==null?a(!0):y.isTransition=!1,l(y),a=r.pending,a===null?(y.next=r.pending=y,op(r,y)):(y.next=a.next,r.pending=a.next=y)}}function op(t,r){var a=r.action,l=r.payload,f=t.state;if(r.isTransition){var y=H.T,w={};H.T=w;try{var O=a(f,l),R=H.S;R!==null&&R(w,O),lp(t,r,O)}catch(V){If(t,r,V)}finally{y!==null&&w.types!==null&&(y.types=w.types),H.T=y}}else try{y=a(f,l),lp(t,r,y)}catch(V){If(t,r,V)}}function lp(t,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){cp(t,r,l)},function(l){return If(t,r,l)}):cp(t,r,a)}function cp(t,r,a){r.status="fulfilled",r.value=a,up(r),t.state=a,r=t.pending,r!==null&&(a=r.next,a===r?t.pending=null:(a=a.next,r.next=a,op(t,a)))}function If(t,r,a){var l=t.pending;if(t.pending=null,l!==null){l=l.next;do r.status="rejected",r.reason=a,up(r),r=r.next;while(r!==l)}t.action=null}function up(t){t=t.listeners;for(var r=0;r<t.length;r++)(0,t[r])()}function fp(t,r){return r}function hp(t,r){if(Fe){var a=it.formState;if(a!==null){e:{var l=Re;if(Fe){if(lt){t:{for(var f=lt,y=qn;f.nodeType!==8;){if(!y){f=null;break t}if(f=Bn(f.nextSibling),f===null){f=null;break t}}y=f.data,f=y==="F!"||y==="F"?f:null}if(f){lt=Bn(f.nextSibling),l=f.data==="F!";break e}}Jr(l)}l=!1}l&&(r=a[0])}}return a=Kt(),a.memoizedState=a.baseState=r,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fp,lastRenderedState:r},a.queue=l,a=Cp.bind(null,Re,l),l.dispatch=a,l=zf(!1),y=Yf.bind(null,Re,!1,l.queue),l=Kt(),f={state:r,dispatch:null,action:t,pending:null},l.queue=f,a=W_.bind(null,Re,f,y,a),f.dispatch=a,l.memoizedState=t,[r,a,!1]}function dp(t){var r=St();return mp(r,tt,t)}function mp(t,r,a){if(r=Bf(t,r,fp)[0],t=_l(Sr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var l=qa(r)}catch(w){throw w===Ei?fl:w}else l=r;r=St();var f=r.queue,y=f.dispatch;return a!==r.memoizedState&&(Re.flags|=2048,Ni(9,{destroy:void 0},Z_.bind(null,f,a),null)),[l,y,t]}function Z_(t,r){t.action=r}function pp(t){var r=St(),a=tt;if(a!==null)return mp(r,a,t);St(),r=r.memoizedState,a=St();var l=a.queue.dispatch;return a.memoizedState=t,[r,l,!1]}function Ni(t,r,a,l){return t={tag:t,create:a,deps:l,inst:r,next:null},r=Re.updateQueue,r===null&&(r=xl(),Re.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=t.next=t:(l=a.next,a.next=t,t.next=l,r.lastEffect=t),t}function yp(){return St().memoizedState}function wl(t,r,a,l){var f=Kt();Re.flags|=t,f.memoizedState=Ni(1|r,{destroy:void 0},a,l===void 0?null:l)}function Sl(t,r,a,l){var f=St();l=l===void 0?null:l;var y=f.memoizedState.inst;tt!==null&&l!==null&&Mf(l,tt.memoizedState.deps)?f.memoizedState=Ni(r,y,a,l):(Re.flags|=t,f.memoizedState=Ni(1|r,y,a,l))}function gp(t,r){wl(8390656,8,t,r)}function $f(t,r){Sl(2048,8,t,r)}function ew(t){Re.flags|=4;var r=Re.updateQueue;if(r===null)r=xl(),Re.updateQueue=r,r.events=[t];else{var a=r.events;a===null?r.events=[t]:a.push(t)}}function bp(t){var r=St().memoizedState;return ew({ref:r,nextImpl:t}),function(){if((Qe&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function xp(t,r){return Sl(4,2,t,r)}function vp(t,r){return Sl(4,4,t,r)}function _p(t,r){if(typeof r=="function"){t=t();var a=r(t);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function wp(t,r,a){a=a!=null?a.concat([t]):null,Sl(4,4,_p.bind(null,r,t),a)}function Hf(){}function Sp(t,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;return r!==null&&Mf(r,l[1])?l[0]:(a.memoizedState=[t,r],t)}function Ep(t,r){var a=St();r=r===void 0?null:r;var l=a.memoizedState;if(r!==null&&Mf(r,l[1]))return l[0];if(l=t(),Ys){fn(!0);try{t()}finally{fn(!1)}}return a.memoizedState=[l,r],l}function Ff(t,r,a){return a===void 0||(wr&1073741824)!==0&&($e&261930)===0?t.memoizedState=r:(t.memoizedState=a,t=Oy(),Re.lanes|=t,ss|=t,a)}function Op(t,r,a,l){return dn(a,r)?a:Ai.current!==null?(t=Ff(t,a,l),dn(t,r)||(Nt=!0),t):(wr&42)===0||(wr&1073741824)!==0&&($e&261930)===0?(Nt=!0,t.memoizedState=a):(t=Oy(),Re.lanes|=t,ss|=t,r)}function Ap(t,r,a,l,f){var y=J.p;J.p=y!==0&&8>y?y:8;var w=H.T,O={};H.T=O,Yf(t,!1,r,a);try{var R=f(),V=H.S;if(V!==null&&V(O,R),R!==null&&typeof R=="object"&&typeof R.then=="function"){var Z=J_(R,l);Pa(t,r,Z,xn(t))}else Pa(t,r,l,xn(t))}catch(ie){Pa(t,r,{then:function(){},status:"rejected",reason:ie},xn())}finally{J.p=y,w!==null&&O.types!==null&&(w.types=O.types),H.T=w}}function tw(){}function Gf(t,r,a,l){if(t.tag!==5)throw Error(i(476));var f=jp(t).queue;Ap(t,f,r,ce,a===null?tw:function(){return kp(t),a(l)})}function jp(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:ce},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sr,lastRenderedState:a},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function kp(t){var r=jp(t);r.next===null&&(r=t.alternate.memoizedState),Pa(t,r.next.queue,{},xn())}function Vf(){return $t(eo)}function Np(){return St().memoizedState}function Tp(){return St().memoizedState}function nw(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var a=xn();t=Wr(a);var l=Zr(r,t,a);l!==null&&(cn(l,r,a),Ma(l,r,a)),r={cache:_f()},t.payload=r;return}r=r.return}}function rw(t,r,a){var l=xn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},El(t)?Mp(r,a):(a=uf(t,r,a,l),a!==null&&(cn(a,t,l),Rp(a,r,l)))}function Cp(t,r,a){var l=xn();Pa(t,r,a,l)}function Pa(t,r,a,l){var f={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(El(t))Mp(r,f);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var w=r.lastRenderedState,O=y(w,a);if(f.hasEagerState=!0,f.eagerState=O,dn(O,w))return sl(t,r,f,0),it===null&&rl(),!1}catch{}finally{}if(a=uf(t,r,f,l),a!==null)return cn(a,t,l),Rp(a,r,l),!0}return!1}function Yf(t,r,a,l){if(l={lane:2,revertLane:Oh(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},El(t)){if(r)throw Error(i(479))}else r=uf(t,a,l,2),r!==null&&cn(r,t,2)}function El(t){var r=t.alternate;return t===Re||r!==null&&r===Re}function Mp(t,r){ji=gl=!0;var a=t.pending;a===null?r.next=r:(r.next=a.next,a.next=r),t.pending=r}function Rp(t,r,a){if((a&4194048)!==0){var l=r.lanes;l&=t.pendingLanes,a|=l,r.lanes=a,Ms(t,a)}}var Ba={readContext:$t,use:vl,useCallback:bt,useContext:bt,useEffect:bt,useImperativeHandle:bt,useLayoutEffect:bt,useInsertionEffect:bt,useMemo:bt,useReducer:bt,useRef:bt,useState:bt,useDebugValue:bt,useDeferredValue:bt,useTransition:bt,useSyncExternalStore:bt,useId:bt,useHostTransitionStatus:bt,useFormState:bt,useActionState:bt,useOptimistic:bt,useMemoCache:bt,useCacheRefresh:bt};Ba.useEffectEvent=bt;var Dp={readContext:$t,use:vl,useCallback:function(t,r){return Kt().memoizedState=[t,r===void 0?null:r],t},useContext:$t,useEffect:gp,useImperativeHandle:function(t,r,a){a=a!=null?a.concat([t]):null,wl(4194308,4,_p.bind(null,r,t),a)},useLayoutEffect:function(t,r){return wl(4194308,4,t,r)},useInsertionEffect:function(t,r){wl(4,2,t,r)},useMemo:function(t,r){var a=Kt();r=r===void 0?null:r;var l=t();if(Ys){fn(!0);try{t()}finally{fn(!1)}}return a.memoizedState=[l,r],l},useReducer:function(t,r,a){var l=Kt();if(a!==void 0){var f=a(r);if(Ys){fn(!0);try{a(r)}finally{fn(!1)}}}else f=r;return l.memoizedState=l.baseState=f,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:f},l.queue=t,t=t.dispatch=rw.bind(null,Re,t),[l.memoizedState,t]},useRef:function(t){var r=Kt();return t={current:t},r.memoizedState=t},useState:function(t){t=zf(t);var r=t.queue,a=Cp.bind(null,Re,r);return r.dispatch=a,[t.memoizedState,a]},useDebugValue:Hf,useDeferredValue:function(t,r){var a=Kt();return Ff(a,t,r)},useTransition:function(){var t=zf(!1);return t=Ap.bind(null,Re,t.queue,!0,!1),Kt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,a){var l=Re,f=Kt();if(Fe){if(a===void 0)throw Error(i(407));a=a()}else{if(a=r(),it===null)throw Error(i(349));($e&127)!==0||tp(l,r,a)}f.memoizedState=a;var y={value:a,getSnapshot:r};return f.queue=y,gp(rp.bind(null,l,y,t),[t]),l.flags|=2048,Ni(9,{destroy:void 0},np.bind(null,l,y,a,r),null),a},useId:function(){var t=Kt(),r=it.identifierPrefix;if(Fe){var a=rr,l=nr;a=(l&~(1<<32-Gt(l)-1)).toString(32)+a,r="_"+r+"R_"+a,a=bl++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=Q_++,r="_"+r+"r_"+a.toString(32)+"_";return t.memoizedState=r},useHostTransitionStatus:Vf,useFormState:hp,useActionState:hp,useOptimistic:function(t){var r=Kt();r.memoizedState=r.baseState=t;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Yf.bind(null,Re,!0,a),a.dispatch=r,[t,r]},useMemoCache:Pf,useCacheRefresh:function(){return Kt().memoizedState=nw.bind(null,Re)},useEffectEvent:function(t){var r=Kt(),a={impl:t};return r.memoizedState=a,function(){if((Qe&2)!==0)throw Error(i(440));return a.impl.apply(void 0,arguments)}}},Kf={readContext:$t,use:vl,useCallback:Sp,useContext:$t,useEffect:$f,useImperativeHandle:wp,useInsertionEffect:xp,useLayoutEffect:vp,useMemo:Ep,useReducer:_l,useRef:yp,useState:function(){return _l(Sr)},useDebugValue:Hf,useDeferredValue:function(t,r){var a=St();return Op(a,tt.memoizedState,t,r)},useTransition:function(){var t=_l(Sr)[0],r=St().memoizedState;return[typeof t=="boolean"?t:qa(t),r]},useSyncExternalStore:ep,useId:Np,useHostTransitionStatus:Vf,useFormState:dp,useActionState:dp,useOptimistic:function(t,r){var a=St();return ap(a,tt,t,r)},useMemoCache:Pf,useCacheRefresh:Tp};Kf.useEffectEvent=bp;var Lp={readContext:$t,use:vl,useCallback:Sp,useContext:$t,useEffect:$f,useImperativeHandle:wp,useInsertionEffect:xp,useLayoutEffect:vp,useMemo:Ep,useReducer:Uf,useRef:yp,useState:function(){return Uf(Sr)},useDebugValue:Hf,useDeferredValue:function(t,r){var a=St();return tt===null?Ff(a,t,r):Op(a,tt.memoizedState,t,r)},useTransition:function(){var t=Uf(Sr)[0],r=St().memoizedState;return[typeof t=="boolean"?t:qa(t),r]},useSyncExternalStore:ep,useId:Np,useHostTransitionStatus:Vf,useFormState:pp,useActionState:pp,useOptimistic:function(t,r){var a=St();return tt!==null?ap(a,tt,t,r):(a.baseState=t,[t,a.queue.dispatch])},useMemoCache:Pf,useCacheRefresh:Tp};Lp.useEffectEvent=bp;function Jf(t,r,a,l){r=t.memoizedState,a=a(l,r),a=a==null?r:b({},r,a),t.memoizedState=a,t.lanes===0&&(t.updateQueue.baseState=a)}var Qf={enqueueSetState:function(t,r,a){t=t._reactInternals;var l=xn(),f=Wr(l);f.payload=r,a!=null&&(f.callback=a),r=Zr(t,f,l),r!==null&&(cn(r,t,l),Ma(r,t,l))},enqueueReplaceState:function(t,r,a){t=t._reactInternals;var l=xn(),f=Wr(l);f.tag=1,f.payload=r,a!=null&&(f.callback=a),r=Zr(t,f,l),r!==null&&(cn(r,t,l),Ma(r,t,l))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var a=xn(),l=Wr(a);l.tag=2,r!=null&&(l.callback=r),r=Zr(t,l,a),r!==null&&(cn(r,t,a),Ma(r,t,a))}};function qp(t,r,a,l,f,y,w){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(l,y,w):r.prototype&&r.prototype.isPureReactComponent?!Ea(a,l)||!Ea(f,y):!0}function Pp(t,r,a,l){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,l),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,l),r.state!==t&&Qf.enqueueReplaceState(r,r.state,null)}function Ks(t,r){var a=r;if("ref"in r){a={};for(var l in r)l!=="ref"&&(a[l]=r[l])}if(t=t.defaultProps){a===r&&(a=b({},a));for(var f in t)a[f]===void 0&&(a[f]=t[f])}return a}function Bp(t){nl(t)}function Up(t){console.error(t)}function zp(t){nl(t)}function Ol(t,r){try{var a=t.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(l){setTimeout(function(){throw l})}}function Ip(t,r,a){try{var l=t.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Xf(t,r,a){return a=Wr(a),a.tag=3,a.payload={element:null},a.callback=function(){Ol(t,r)},a}function $p(t){return t=Wr(t),t.tag=3,t}function Hp(t,r,a,l){var f=a.type.getDerivedStateFromError;if(typeof f=="function"){var y=l.value;t.payload=function(){return f(y)},t.callback=function(){Ip(r,a,l)}}var w=a.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(t.callback=function(){Ip(r,a,l),typeof f!="function"&&(is===null?is=new Set([this]):is.add(this));var O=l.stack;this.componentDidCatch(l.value,{componentStack:O!==null?O:""})})}function sw(t,r,a,l,f){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(r=a.alternate,r!==null&&_i(r,a,f,!0),a=pn.current,a!==null){switch(a.tag){case 31:case 13:return Pn===null?Pl():a.alternate===null&&xt===0&&(xt=3),a.flags&=-257,a.flags|=65536,a.lanes=f,l===hl?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([l]):r.add(l),wh(t,l,f)),!1;case 22:return a.flags|=65536,l===hl?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([l]):a.add(l)),wh(t,l,f)),!1}throw Error(i(435,a.tag))}return wh(t,l,f),Pl(),!1}if(Fe)return r=pn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=f,l!==yf&&(t=Error(i(422),{cause:l}),ja(Rn(t,a)))):(l!==yf&&(r=Error(i(423),{cause:l}),ja(Rn(r,a))),t=t.current.alternate,t.flags|=65536,f&=-f,t.lanes|=f,l=Rn(l,a),f=Xf(t.stateNode,l,f),jf(t,f),xt!==4&&(xt=2)),!1;var y=Error(i(520),{cause:l});if(y=Rn(y,a),Va===null?Va=[y]:Va.push(y),xt!==4&&(xt=2),r===null)return!0;l=Rn(l,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,t=f&-f,a.lanes|=t,t=Xf(a.stateNode,l,t),jf(a,t),!1;case 1:if(r=a.type,y=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(is===null||!is.has(y))))return a.flags|=65536,f&=-f,a.lanes|=f,f=$p(f),Hp(f,t,a,l),jf(a,f),!1}a=a.return}while(a!==null);return!1}var Wf=Error(i(461)),Nt=!1;function Ht(t,r,a,l){r.child=t===null?Y0(r,null,a,l):Vs(r,t.child,a,l)}function Fp(t,r,a,l,f){a=a.render;var y=r.ref;if("ref"in l){var w={};for(var O in l)O!=="ref"&&(w[O]=l[O])}else w=l;return $s(r),l=Rf(t,r,a,w,y,f),O=Df(),t!==null&&!Nt?(Lf(t,r,f),Er(t,r,f)):(Fe&&O&&mf(r),r.flags|=1,Ht(t,r,l,f),r.child)}function Gp(t,r,a,l,f){if(t===null){var y=a.type;return typeof y=="function"&&!ff(y)&&y.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=y,Vp(t,r,y,l,f)):(t=al(a.type,null,l,r,r.mode,f),t.ref=r.ref,t.return=r,r.child=t)}if(y=t.child,!ah(t,f)){var w=y.memoizedProps;if(a=a.compare,a=a!==null?a:Ea,a(w,l)&&t.ref===r.ref)return Er(t,r,f)}return r.flags|=1,t=br(y,l),t.ref=r.ref,t.return=r,r.child=t}function Vp(t,r,a,l,f){if(t!==null){var y=t.memoizedProps;if(Ea(y,l)&&t.ref===r.ref)if(Nt=!1,r.pendingProps=l=y,ah(t,f))(t.flags&131072)!==0&&(Nt=!0);else return r.lanes=t.lanes,Er(t,r,f)}return Zf(t,r,a,l,f)}function Yp(t,r,a,l){var f=l.children,y=t!==null?t.memoizedState:null;if(t===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|a:a,t!==null){for(l=r.child=t.child,f=0;l!==null;)f=f|l.lanes|l.childLanes,l=l.sibling;l=f&~y}else l=0,r.child=null;return Kp(t,r,y,a,l)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},t!==null&&ul(r,y!==null?y.cachePool:null),y!==null?Q0(r,y):Nf(),X0(r);else return l=r.lanes=536870912,Kp(t,r,y!==null?y.baseLanes|a:a,a,l)}else y!==null?(ul(r,y.cachePool),Q0(r,y),ts(),r.memoizedState=null):(t!==null&&ul(r,null),Nf(),ts());return Ht(t,r,f,a),r.child}function Ua(t,r){return t!==null&&t.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Kp(t,r,a,l,f){var y=Sf();return y=y===null?null:{parent:jt._currentValue,pool:y},r.memoizedState={baseLanes:a,cachePool:y},t!==null&&ul(r,null),Nf(),X0(r),t!==null&&_i(t,r,l,!0),r.childLanes=f,null}function Al(t,r){return r=kl({mode:r.mode,children:r.children},t.mode),r.ref=t.ref,t.child=r,r.return=t,r}function Jp(t,r,a){return Vs(r,t.child,null,a),t=Al(r,r.pendingProps),t.flags|=2,yn(r),r.memoizedState=null,t}function iw(t,r,a){var l=r.pendingProps,f=(r.flags&128)!==0;if(r.flags&=-129,t===null){if(Fe){if(l.mode==="hidden")return t=Al(r,l),r.lanes=536870912,Ua(null,t);if(Cf(r),(t=lt)?(t=og(t,qn),t=t!==null&&t.data==="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:Yr!==null?{id:nr,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},a=M0(t),a.return=r,r.child=a,It=r,lt=null)):t=null,t===null)throw Jr(r);return r.lanes=536870912,null}return Al(r,l)}var y=t.memoizedState;if(y!==null){var w=y.dehydrated;if(Cf(r),f)if(r.flags&256)r.flags&=-257,r=Jp(t,r,a);else if(r.memoizedState!==null)r.child=t.child,r.flags|=128,r=null;else throw Error(i(558));else if(Nt||_i(t,r,a,!1),f=(a&t.childLanes)!==0,Nt||f){if(l=it,l!==null&&(w=Gr(l,a),w!==0&&w!==y.retryLane))throw y.retryLane=w,Bs(t,w),cn(l,t,w),Wf;Pl(),r=Jp(t,r,a)}else t=y.treeContext,lt=Bn(w.nextSibling),It=r,Fe=!0,Kr=null,qn=!1,t!==null&&L0(r,t),r=Al(r,l),r.flags|=4096;return r}return t=br(t.child,{mode:l.mode,children:l.children}),t.ref=r.ref,r.child=t,t.return=r,t}function jl(t,r){var a=r.ref;if(a===null)t!==null&&t.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(i(284));(t===null||t.ref!==a)&&(r.flags|=4194816)}}function Zf(t,r,a,l,f){return $s(r),a=Rf(t,r,a,l,void 0,f),l=Df(),t!==null&&!Nt?(Lf(t,r,f),Er(t,r,f)):(Fe&&l&&mf(r),r.flags|=1,Ht(t,r,a,f),r.child)}function Qp(t,r,a,l,f,y){return $s(r),r.updateQueue=null,a=Z0(r,l,a,f),W0(t),l=Df(),t!==null&&!Nt?(Lf(t,r,y),Er(t,r,y)):(Fe&&l&&mf(r),r.flags|=1,Ht(t,r,a,y),r.child)}function Xp(t,r,a,l,f){if($s(r),r.stateNode===null){var y=gi,w=a.contextType;typeof w=="object"&&w!==null&&(y=$t(w)),y=new a(l,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Qf,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=l,y.state=r.memoizedState,y.refs={},Of(r),w=a.contextType,y.context=typeof w=="object"&&w!==null?$t(w):gi,y.state=r.memoizedState,w=a.getDerivedStateFromProps,typeof w=="function"&&(Jf(r,a,w,l),y.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(w=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),w!==y.state&&Qf.enqueueReplaceState(y,y.state,null),Da(r,l,y,f),Ra(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),l=!0}else if(t===null){y=r.stateNode;var O=r.memoizedProps,R=Ks(a,O);y.props=R;var V=y.context,Z=a.contextType;w=gi,typeof Z=="object"&&Z!==null&&(w=$t(Z));var ie=a.getDerivedStateFromProps;Z=typeof ie=="function"||typeof y.getSnapshotBeforeUpdate=="function",O=r.pendingProps!==O,Z||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(O||V!==w)&&Pp(r,y,l,w),Xr=!1;var Y=r.memoizedState;y.state=Y,Da(r,l,y,f),Ra(),V=r.memoizedState,O||Y!==V||Xr?(typeof ie=="function"&&(Jf(r,a,ie,l),V=r.memoizedState),(R=Xr||qp(r,a,R,l,Y,V,w))?(Z||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=l,r.memoizedState=V),y.props=l,y.state=V,y.context=w,l=R):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),l=!1)}else{y=r.stateNode,Af(t,r),w=r.memoizedProps,Z=Ks(a,w),y.props=Z,ie=r.pendingProps,Y=y.context,V=a.contextType,R=gi,typeof V=="object"&&V!==null&&(R=$t(V)),O=a.getDerivedStateFromProps,(V=typeof O=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(w!==ie||Y!==R)&&Pp(r,y,l,R),Xr=!1,Y=r.memoizedState,y.state=Y,Da(r,l,y,f),Ra();var X=r.memoizedState;w!==ie||Y!==X||Xr||t!==null&&t.dependencies!==null&&ll(t.dependencies)?(typeof O=="function"&&(Jf(r,a,O,l),X=r.memoizedState),(Z=Xr||qp(r,a,Z,l,Y,X,R)||t!==null&&t.dependencies!==null&&ll(t.dependencies))?(V||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(l,X,R),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(l,X,R)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=1024),r.memoizedProps=l,r.memoizedState=X),y.props=l,y.state=X,y.context=R,l=Z):(typeof y.componentDidUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||w===t.memoizedProps&&Y===t.memoizedState||(r.flags|=1024),l=!1)}return y=l,jl(t,r),l=(r.flags&128)!==0,y||l?(y=r.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,t!==null&&l?(r.child=Vs(r,t.child,null,f),r.child=Vs(r,null,a,f)):Ht(t,r,a,f),r.memoizedState=y.state,t=r.child):t=Er(t,r,f),t}function Wp(t,r,a,l){return zs(),r.flags|=256,Ht(t,r,a,l),r.child}var eh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function th(t){return{baseLanes:t,cachePool:I0()}}function nh(t,r,a){return t=t!==null?t.childLanes&~a:0,r&&(t|=bn),t}function Zp(t,r,a){var l=r.pendingProps,f=!1,y=(r.flags&128)!==0,w;if((w=y)||(w=t!==null&&t.memoizedState===null?!1:(wt.current&2)!==0),w&&(f=!0,r.flags&=-129),w=(r.flags&32)!==0,r.flags&=-33,t===null){if(Fe){if(f?es(r):ts(),(t=lt)?(t=og(t,qn),t=t!==null&&t.data!=="&"?t:null,t!==null&&(r.memoizedState={dehydrated:t,treeContext:Yr!==null?{id:nr,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},a=M0(t),a.return=r,r.child=a,It=r,lt=null)):t=null,t===null)throw Jr(r);return Bh(t)?r.lanes=32:r.lanes=536870912,null}var O=l.children;return l=l.fallback,f?(ts(),f=r.mode,O=kl({mode:"hidden",children:O},f),l=Us(l,f,a,null),O.return=r,l.return=r,O.sibling=l,r.child=O,l=r.child,l.memoizedState=th(a),l.childLanes=nh(t,w,a),r.memoizedState=eh,Ua(null,l)):(es(r),rh(r,O))}var R=t.memoizedState;if(R!==null&&(O=R.dehydrated,O!==null)){if(y)r.flags&256?(es(r),r.flags&=-257,r=sh(t,r,a)):r.memoizedState!==null?(ts(),r.child=t.child,r.flags|=128,r=null):(ts(),O=l.fallback,f=r.mode,l=kl({mode:"visible",children:l.children},f),O=Us(O,f,a,null),O.flags|=2,l.return=r,O.return=r,l.sibling=O,r.child=l,Vs(r,t.child,null,a),l=r.child,l.memoizedState=th(a),l.childLanes=nh(t,w,a),r.memoizedState=eh,r=Ua(null,l));else if(es(r),Bh(O)){if(w=O.nextSibling&&O.nextSibling.dataset,w)var V=w.dgst;w=V,l=Error(i(419)),l.stack="",l.digest=w,ja({value:l,source:null,stack:null}),r=sh(t,r,a)}else if(Nt||_i(t,r,a,!1),w=(a&t.childLanes)!==0,Nt||w){if(w=it,w!==null&&(l=Gr(w,a),l!==0&&l!==R.retryLane))throw R.retryLane=l,Bs(t,l),cn(w,t,l),Wf;Ph(O)||Pl(),r=sh(t,r,a)}else Ph(O)?(r.flags|=192,r.child=t.child,r=null):(t=R.treeContext,lt=Bn(O.nextSibling),It=r,Fe=!0,Kr=null,qn=!1,t!==null&&L0(r,t),r=rh(r,l.children),r.flags|=4096);return r}return f?(ts(),O=l.fallback,f=r.mode,R=t.child,V=R.sibling,l=br(R,{mode:"hidden",children:l.children}),l.subtreeFlags=R.subtreeFlags&65011712,V!==null?O=br(V,O):(O=Us(O,f,a,null),O.flags|=2),O.return=r,l.return=r,l.sibling=O,r.child=l,Ua(null,l),l=r.child,O=t.child.memoizedState,O===null?O=th(a):(f=O.cachePool,f!==null?(R=jt._currentValue,f=f.parent!==R?{parent:R,pool:R}:f):f=I0(),O={baseLanes:O.baseLanes|a,cachePool:f}),l.memoizedState=O,l.childLanes=nh(t,w,a),r.memoizedState=eh,Ua(t.child,l)):(es(r),a=t.child,t=a.sibling,a=br(a,{mode:"visible",children:l.children}),a.return=r,a.sibling=null,t!==null&&(w=r.deletions,w===null?(r.deletions=[t],r.flags|=16):w.push(t)),r.child=a,r.memoizedState=null,a)}function rh(t,r){return r=kl({mode:"visible",children:r},t.mode),r.return=t,t.child=r}function kl(t,r){return t=mn(22,t,null,r),t.lanes=0,t}function sh(t,r,a){return Vs(r,t.child,null,a),t=rh(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function ey(t,r,a){t.lanes|=r;var l=t.alternate;l!==null&&(l.lanes|=r),xf(t.return,r,a)}function ih(t,r,a,l,f,y){var w=t.memoizedState;w===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:f,treeForkCount:y}:(w.isBackwards=r,w.rendering=null,w.renderingStartTime=0,w.last=l,w.tail=a,w.tailMode=f,w.treeForkCount=y)}function ty(t,r,a){var l=r.pendingProps,f=l.revealOrder,y=l.tail;l=l.children;var w=wt.current,O=(w&2)!==0;if(O?(w=w&1|2,r.flags|=128):w&=1,Me(wt,w),Ht(t,r,l,a),l=Fe?Aa:0,!O&&t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&ey(t,a,r);else if(t.tag===19)ey(t,a,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(f){case"forwards":for(a=r.child,f=null;a!==null;)t=a.alternate,t!==null&&yl(t)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),ih(r,!1,f,a,y,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(t=f.alternate,t!==null&&yl(t)===null){r.child=f;break}t=f.sibling,f.sibling=a,a=f,f=t}ih(r,!0,a,null,y,l);break;case"together":ih(r,!1,null,null,void 0,l);break;default:r.memoizedState=null}return r.child}function Er(t,r,a){if(t!==null&&(r.dependencies=t.dependencies),ss|=r.lanes,(a&r.childLanes)===0)if(t!==null){if(_i(t,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(t!==null&&r.child!==t.child)throw Error(i(153));if(r.child!==null){for(t=r.child,a=br(t,t.pendingProps),r.child=a,a.return=r;t.sibling!==null;)t=t.sibling,a=a.sibling=br(t,t.pendingProps),a.return=r;a.sibling=null}return r.child}function ah(t,r){return(t.lanes&r)!==0?!0:(t=t.dependencies,!!(t!==null&&ll(t)))}function aw(t,r,a){switch(r.tag){case 3:_e(r,r.stateNode.containerInfo),Qr(r,jt,t.memoizedState.cache),zs();break;case 27:case 5:Pe(r);break;case 4:_e(r,r.stateNode.containerInfo);break;case 10:Qr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Cf(r),null;break;case 13:var l=r.memoizedState;if(l!==null)return l.dehydrated!==null?(es(r),r.flags|=128,null):(a&r.child.childLanes)!==0?Zp(t,r,a):(es(r),t=Er(t,r,a),t!==null?t.sibling:null);es(r);break;case 19:var f=(t.flags&128)!==0;if(l=(a&r.childLanes)!==0,l||(_i(t,r,a,!1),l=(a&r.childLanes)!==0),f){if(l)return ty(t,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Me(wt,wt.current),l)break;return null;case 22:return r.lanes=0,Yp(t,r,a,r.pendingProps);case 24:Qr(r,jt,t.memoizedState.cache)}return Er(t,r,a)}function ny(t,r,a){if(t!==null)if(t.memoizedProps!==r.pendingProps)Nt=!0;else{if(!ah(t,a)&&(r.flags&128)===0)return Nt=!1,aw(t,r,a);Nt=(t.flags&131072)!==0}else Nt=!1,Fe&&(r.flags&1048576)!==0&&D0(r,Aa,r.index);switch(r.lanes=0,r.tag){case 16:e:{var l=r.pendingProps;if(t=Fs(r.elementType),r.type=t,typeof t=="function")ff(t)?(l=Ks(t,l),r.tag=1,r=Xp(null,r,t,l,a)):(r.tag=0,r=Zf(null,r,t,l,a));else{if(t!=null){var f=t.$$typeof;if(f===te){r.tag=11,r=Fp(null,r,t,l,a);break e}else if(f===ae){r.tag=14,r=Gp(null,r,t,l,a);break e}}throw r=Ee(t)||t,Error(i(306,r,""))}}return r;case 0:return Zf(t,r,r.type,r.pendingProps,a);case 1:return l=r.type,f=Ks(l,r.pendingProps),Xp(t,r,l,f,a);case 3:e:{if(_e(r,r.stateNode.containerInfo),t===null)throw Error(i(387));l=r.pendingProps;var y=r.memoizedState;f=y.element,Af(t,r),Da(r,l,null,a);var w=r.memoizedState;if(l=w.cache,Qr(r,jt,l),l!==y.cache&&vf(r,[jt],a,!0),Ra(),l=w.element,y.isDehydrated)if(y={element:l,isDehydrated:!1,cache:w.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=Wp(t,r,l,a);break e}else if(l!==f){f=Rn(Error(i(424)),r),ja(f),r=Wp(t,r,l,a);break e}else{switch(t=r.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(lt=Bn(t.firstChild),It=r,Fe=!0,Kr=null,qn=!0,a=Y0(r,null,l,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(zs(),l===f){r=Er(t,r,a);break e}Ht(t,r,l,a)}r=r.child}return r;case 26:return jl(t,r),t===null?(a=dg(r.type,null,r.pendingProps,null))?r.memoizedState=a:Fe||(a=r.type,t=r.pendingProps,l=Fl(Ot.current).createElement(a),l[st]=r,l[gt]=t,Ft(l,a,t),L(l),r.stateNode=l):r.memoizedState=dg(r.type,t.memoizedProps,r.pendingProps,t.memoizedState),null;case 27:return Pe(r),t===null&&Fe&&(l=r.stateNode=ug(r.type,r.pendingProps,Ot.current),It=r,qn=!0,f=lt,cs(r.type)?(Uh=f,lt=Bn(l.firstChild)):lt=f),Ht(t,r,r.pendingProps.children,a),jl(t,r),t===null&&(r.flags|=4194304),r.child;case 5:return t===null&&Fe&&((f=l=lt)&&(l=qw(l,r.type,r.pendingProps,qn),l!==null?(r.stateNode=l,It=r,lt=Bn(l.firstChild),qn=!1,f=!0):f=!1),f||Jr(r)),Pe(r),f=r.type,y=r.pendingProps,w=t!==null?t.memoizedProps:null,l=y.children,Dh(f,y)?l=null:w!==null&&Dh(f,w)&&(r.flags|=32),r.memoizedState!==null&&(f=Rf(t,r,X_,null,null,a),eo._currentValue=f),jl(t,r),Ht(t,r,l,a),r.child;case 6:return t===null&&Fe&&((t=a=lt)&&(a=Pw(a,r.pendingProps,qn),a!==null?(r.stateNode=a,It=r,lt=null,t=!0):t=!1),t||Jr(r)),null;case 13:return Zp(t,r,a);case 4:return _e(r,r.stateNode.containerInfo),l=r.pendingProps,t===null?r.child=Vs(r,null,l,a):Ht(t,r,l,a),r.child;case 11:return Fp(t,r,r.type,r.pendingProps,a);case 7:return Ht(t,r,r.pendingProps,a),r.child;case 8:return Ht(t,r,r.pendingProps.children,a),r.child;case 12:return Ht(t,r,r.pendingProps.children,a),r.child;case 10:return l=r.pendingProps,Qr(r,r.type,l.value),Ht(t,r,l.children,a),r.child;case 9:return f=r.type._context,l=r.pendingProps.children,$s(r),f=$t(f),l=l(f),r.flags|=1,Ht(t,r,l,a),r.child;case 14:return Gp(t,r,r.type,r.pendingProps,a);case 15:return Vp(t,r,r.type,r.pendingProps,a);case 19:return ty(t,r,a);case 31:return iw(t,r,a);case 22:return Yp(t,r,a,r.pendingProps);case 24:return $s(r),l=$t(jt),t===null?(f=Sf(),f===null&&(f=it,y=_f(),f.pooledCache=y,y.refCount++,y!==null&&(f.pooledCacheLanes|=a),f=y),r.memoizedState={parent:l,cache:f},Of(r),Qr(r,jt,f)):((t.lanes&a)!==0&&(Af(t,r),Da(r,null,null,a),Ra()),f=t.memoizedState,y=r.memoizedState,f.parent!==l?(f={parent:l,cache:l},r.memoizedState=f,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=f),Qr(r,jt,l)):(l=y.cache,Qr(r,jt,l),l!==f.cache&&vf(r,[jt],a,!0))),Ht(t,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Or(t){t.flags|=4}function oh(t,r,a,l,f){if((r=(t.mode&32)!==0)&&(r=!1),r){if(t.flags|=16777216,(f&335544128)===f)if(t.stateNode.complete)t.flags|=8192;else if(Ny())t.flags|=8192;else throw Gs=hl,Ef}else t.flags&=-16777217}function ry(t,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!bg(r))if(Ny())t.flags|=8192;else throw Gs=hl,Ef}function Nl(t,r){r!==null&&(t.flags|=4),t.flags&16384&&(r=t.tag!==22?oi():536870912,t.lanes|=r,Ri|=r)}function za(t,r){if(!Fe)switch(t.tailMode){case"hidden":r=t.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?t.tail=null:a.sibling=null;break;case"collapsed":a=t.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:l.sibling=null}}function ct(t){var r=t.alternate!==null&&t.alternate.child===t.child,a=0,l=0;if(r)for(var f=t.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags&65011712,l|=f.flags&65011712,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)a|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=l,t.childLanes=a,r}function ow(t,r,a){var l=r.pendingProps;switch(pf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ct(r),null;case 1:return ct(r),null;case 3:return a=r.stateNode,l=null,t!==null&&(l=t.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),_r(jt),le(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(t===null||t.child===null)&&(vi(r)?Or(r):t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,gf())),ct(r),null;case 26:var f=r.type,y=r.memoizedState;return t===null?(Or(r),y!==null?(ct(r),ry(r,y)):(ct(r),oh(r,f,null,l,a))):y?y!==t.memoizedState?(Or(r),ct(r),ry(r,y)):(ct(r),r.flags&=-16777217):(t=t.memoizedProps,t!==l&&Or(r),ct(r),oh(r,f,t,l,a)),null;case 27:if(zt(r),a=Ot.current,f=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==l&&Or(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ct(r),null}t=Xe.current,vi(r)?q0(r):(t=ug(f,l,a),r.stateNode=t,Or(r))}return ct(r),null;case 5:if(zt(r),f=r.type,t!==null&&r.stateNode!=null)t.memoizedProps!==l&&Or(r);else{if(!l){if(r.stateNode===null)throw Error(i(166));return ct(r),null}if(y=Xe.current,vi(r))q0(r);else{var w=Fl(Ot.current);switch(y){case 1:y=w.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:y=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":y=w.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":y=w.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":y=w.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof l.is=="string"?w.createElement("select",{is:l.is}):w.createElement("select"),l.multiple?y.multiple=!0:l.size&&(y.size=l.size);break;default:y=typeof l.is=="string"?w.createElement(f,{is:l.is}):w.createElement(f)}}y[st]=r,y[gt]=l;e:for(w=r.child;w!==null;){if(w.tag===5||w.tag===6)y.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===r)break e;for(;w.sibling===null;){if(w.return===null||w.return===r)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}r.stateNode=y;e:switch(Ft(y,f,l),f){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Or(r)}}return ct(r),oh(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,a),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==l&&Or(r);else{if(typeof l!="string"&&r.stateNode===null)throw Error(i(166));if(t=Ot.current,vi(r)){if(t=r.stateNode,a=r.memoizedProps,l=null,f=It,f!==null)switch(f.tag){case 27:case 5:l=f.memoizedProps}t[st]=r,t=!!(t.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Zy(t.nodeValue,a)),t||Jr(r,!0)}else t=Fl(t).createTextNode(l),t[st]=r,r.stateNode=t}return ct(r),null;case 31:if(a=r.memoizedState,t===null||t.memoizedState!==null){if(l=vi(r),a!==null){if(t===null){if(!l)throw Error(i(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[st]=r}else zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ct(r),t=!1}else a=gf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=a),t=!0;if(!t)return r.flags&256?(yn(r),r):(yn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ct(r),null;case 13:if(l=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(f=vi(r),l!==null&&l.dehydrated!==null){if(t===null){if(!f)throw Error(i(318));if(f=r.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[st]=r}else zs(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ct(r),f=!1}else f=gf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=f),f=!0;if(!f)return r.flags&256?(yn(r),r):(yn(r),null)}return yn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=l!==null,t=t!==null&&t.memoizedState!==null,a&&(l=r.child,f=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(f=l.alternate.memoizedState.cachePool.pool),y=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(y=l.memoizedState.cachePool.pool),y!==f&&(l.flags|=2048)),a!==t&&a&&(r.child.flags|=8192),Nl(r,r.updateQueue),ct(r),null);case 4:return le(),t===null&&Nh(r.stateNode.containerInfo),ct(r),null;case 10:return _r(r.type),ct(r),null;case 19:if(Ne(wt),l=r.memoizedState,l===null)return ct(r),null;if(f=(r.flags&128)!==0,y=l.rendering,y===null)if(f)za(l,!1);else{if(xt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(y=yl(t),y!==null){for(r.flags|=128,za(l,!1),t=y.updateQueue,r.updateQueue=t,Nl(r,t),r.subtreeFlags=0,t=a,a=r.child;a!==null;)C0(a,t),a=a.sibling;return Me(wt,wt.current&1|2),Fe&&xr(r,l.treeForkCount),r.child}t=t.sibling}l.tail!==null&&ut()>Dl&&(r.flags|=128,f=!0,za(l,!1),r.lanes=4194304)}else{if(!f)if(t=yl(y),t!==null){if(r.flags|=128,f=!0,t=t.updateQueue,r.updateQueue=t,Nl(r,t),za(l,!0),l.tail===null&&l.tailMode==="hidden"&&!y.alternate&&!Fe)return ct(r),null}else 2*ut()-l.renderingStartTime>Dl&&a!==536870912&&(r.flags|=128,f=!0,za(l,!1),r.lanes=4194304);l.isBackwards?(y.sibling=r.child,r.child=y):(t=l.last,t!==null?t.sibling=y:r.child=y,l.last=y)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=ut(),t.sibling=null,a=wt.current,Me(wt,f?a&1|2:a&1),Fe&&xr(r,l.treeForkCount),t):(ct(r),null);case 22:case 23:return yn(r),Tf(),l=r.memoizedState!==null,t!==null?t.memoizedState!==null!==l&&(r.flags|=8192):l&&(r.flags|=8192),l?(a&536870912)!==0&&(r.flags&128)===0&&(ct(r),r.subtreeFlags&6&&(r.flags|=8192)):ct(r),a=r.updateQueue,a!==null&&Nl(r,a.retryQueue),a=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),l=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),l!==a&&(r.flags|=2048),t!==null&&Ne(Hs),null;case 24:return a=null,t!==null&&(a=t.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),_r(jt),ct(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function lw(t,r){switch(pf(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return _r(jt),le(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return zt(r),null;case 31:if(r.memoizedState!==null){if(yn(r),r.alternate===null)throw Error(i(340));zs()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(yn(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(i(340));zs()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return Ne(wt),null;case 4:return le(),null;case 10:return _r(r.type),null;case 22:case 23:return yn(r),Tf(),t!==null&&Ne(Hs),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return _r(jt),null;case 25:return null;default:return null}}function sy(t,r){switch(pf(r),r.tag){case 3:_r(jt),le();break;case 26:case 27:case 5:zt(r);break;case 4:le();break;case 31:r.memoizedState!==null&&yn(r);break;case 13:yn(r);break;case 19:Ne(wt);break;case 10:_r(r.type);break;case 22:case 23:yn(r),Tf(),t!==null&&Ne(Hs);break;case 24:_r(jt)}}function Ia(t,r){try{var a=r.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var f=l.next;a=f;do{if((a.tag&t)===t){l=void 0;var y=a.create,w=a.inst;l=y(),w.destroy=l}a=a.next}while(a!==f)}}catch(O){Ze(r,r.return,O)}}function ns(t,r,a){try{var l=r.updateQueue,f=l!==null?l.lastEffect:null;if(f!==null){var y=f.next;l=y;do{if((l.tag&t)===t){var w=l.inst,O=w.destroy;if(O!==void 0){w.destroy=void 0,f=r;var R=a,V=O;try{V()}catch(Z){Ze(f,R,Z)}}}l=l.next}while(l!==y)}}catch(Z){Ze(r,r.return,Z)}}function iy(t){var r=t.updateQueue;if(r!==null){var a=t.stateNode;try{J0(r,a)}catch(l){Ze(t,t.return,l)}}}function ay(t,r,a){a.props=Ks(t.type,t.memoizedProps),a.state=t.memoizedState;try{a.componentWillUnmount()}catch(l){Ze(t,r,l)}}function $a(t,r){try{var a=t.ref;if(a!==null){switch(t.tag){case 26:case 27:case 5:var l=t.stateNode;break;case 30:l=t.stateNode;break;default:l=t.stateNode}typeof a=="function"?t.refCleanup=a(l):a.current=l}}catch(f){Ze(t,r,f)}}function sr(t,r){var a=t.ref,l=t.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(f){Ze(t,r,f)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(f){Ze(t,r,f)}else a.current=null}function oy(t){var r=t.type,a=t.memoizedProps,l=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(f){Ze(t,t.return,f)}}function lh(t,r,a){try{var l=t.stateNode;Tw(l,t.type,a,r),l[gt]=r}catch(f){Ze(t,t.return,f)}}function ly(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&cs(t.type)||t.tag===4}function ch(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||ly(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&cs(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function uh(t,r,a){var l=t.tag;if(l===5||l===6)t=t.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(t,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(t),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=yr));else if(l!==4&&(l===27&&cs(t.type)&&(a=t.stateNode,r=null),t=t.child,t!==null))for(uh(t,r,a),t=t.sibling;t!==null;)uh(t,r,a),t=t.sibling}function Tl(t,r,a){var l=t.tag;if(l===5||l===6)t=t.stateNode,r?a.insertBefore(t,r):a.appendChild(t);else if(l!==4&&(l===27&&cs(t.type)&&(a=t.stateNode),t=t.child,t!==null))for(Tl(t,r,a),t=t.sibling;t!==null;)Tl(t,r,a),t=t.sibling}function cy(t){var r=t.stateNode,a=t.memoizedProps;try{for(var l=t.type,f=r.attributes;f.length;)r.removeAttributeNode(f[0]);Ft(r,l,a),r[st]=t,r[gt]=a}catch(y){Ze(t,t.return,y)}}var Ar=!1,Tt=!1,fh=!1,uy=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function cw(t,r){if(t=t.containerInfo,Mh=Xl,t=w0(t),rf(t)){if("selectionStart"in t)var a={start:t.selectionStart,end:t.selectionEnd};else e:{a=(a=t.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var f=l.anchorOffset,y=l.focusNode;l=l.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var w=0,O=-1,R=-1,V=0,Z=0,ie=t,Y=null;t:for(;;){for(var X;ie!==a||f!==0&&ie.nodeType!==3||(O=w+f),ie!==y||l!==0&&ie.nodeType!==3||(R=w+l),ie.nodeType===3&&(w+=ie.nodeValue.length),(X=ie.firstChild)!==null;)Y=ie,ie=X;for(;;){if(ie===t)break t;if(Y===a&&++V===f&&(O=w),Y===y&&++Z===l&&(R=w),(X=ie.nextSibling)!==null)break;ie=Y,Y=ie.parentNode}ie=X}a=O===-1||R===-1?null:{start:O,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(Rh={focusedElem:t,selectionRange:a},Xl=!1,Pt=r;Pt!==null;)if(r=Pt,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Pt=t;else for(;Pt!==null;){switch(r=Pt,y=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(a=0;a<t.length;a++)f=t[a],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&y!==null){t=void 0,a=r,f=y.memoizedProps,y=y.memoizedState,l=a.stateNode;try{var ve=Ks(a.type,f);t=l.getSnapshotBeforeUpdate(ve,y),l.__reactInternalSnapshotBeforeUpdate=t}catch(Te){Ze(a,a.return,Te)}}break;case 3:if((t&1024)!==0){if(t=r.stateNode.containerInfo,a=t.nodeType,a===9)qh(t);else if(a===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":qh(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(i(163))}if(t=r.sibling,t!==null){t.return=r.return,Pt=t;break}Pt=r.return}}function fy(t,r,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:kr(t,a),l&4&&Ia(5,a);break;case 1:if(kr(t,a),l&4)if(t=a.stateNode,r===null)try{t.componentDidMount()}catch(w){Ze(a,a.return,w)}else{var f=Ks(a.type,r.memoizedProps);r=r.memoizedState;try{t.componentDidUpdate(f,r,t.__reactInternalSnapshotBeforeUpdate)}catch(w){Ze(a,a.return,w)}}l&64&&iy(a),l&512&&$a(a,a.return);break;case 3:if(kr(t,a),l&64&&(t=a.updateQueue,t!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{J0(t,r)}catch(w){Ze(a,a.return,w)}}break;case 27:r===null&&l&4&&cy(a);case 26:case 5:kr(t,a),r===null&&l&4&&oy(a),l&512&&$a(a,a.return);break;case 12:kr(t,a);break;case 31:kr(t,a),l&4&&my(t,a);break;case 13:kr(t,a),l&4&&py(t,a),l&64&&(t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(a=bw.bind(null,a),Bw(t,a))));break;case 22:if(l=a.memoizedState!==null||Ar,!l){r=r!==null&&r.memoizedState!==null||Tt,f=Ar;var y=Tt;Ar=l,(Tt=r)&&!y?Nr(t,a,(a.subtreeFlags&8772)!==0):kr(t,a),Ar=f,Tt=y}break;case 30:break;default:kr(t,a)}}function hy(t){var r=t.alternate;r!==null&&(t.alternate=null,hy(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&li(r)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var ft=null,sn=!1;function jr(t,r,a){for(a=a.child;a!==null;)dy(t,r,a),a=a.sibling}function dy(t,r,a){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(Ns,a)}catch{}switch(a.tag){case 26:Tt||sr(a,r),jr(t,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Tt||sr(a,r);var l=ft,f=sn;cs(a.type)&&(ft=a.stateNode,sn=!1),jr(t,r,a),Xa(a.stateNode),ft=l,sn=f;break;case 5:Tt||sr(a,r);case 6:if(l=ft,f=sn,ft=null,jr(t,r,a),ft=l,sn=f,ft!==null)if(sn)try{(ft.nodeType===9?ft.body:ft.nodeName==="HTML"?ft.ownerDocument.body:ft).removeChild(a.stateNode)}catch(y){Ze(a,r,y)}else try{ft.removeChild(a.stateNode)}catch(y){Ze(a,r,y)}break;case 18:ft!==null&&(sn?(t=ft,ig(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,a.stateNode),Ii(t)):ig(ft,a.stateNode));break;case 4:l=ft,f=sn,ft=a.stateNode.containerInfo,sn=!0,jr(t,r,a),ft=l,sn=f;break;case 0:case 11:case 14:case 15:ns(2,a,r),Tt||ns(4,a,r),jr(t,r,a);break;case 1:Tt||(sr(a,r),l=a.stateNode,typeof l.componentWillUnmount=="function"&&ay(a,r,l)),jr(t,r,a);break;case 21:jr(t,r,a);break;case 22:Tt=(l=Tt)||a.memoizedState!==null,jr(t,r,a),Tt=l;break;default:jr(t,r,a)}}function my(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Ii(t)}catch(a){Ze(r,r.return,a)}}}function py(t,r){if(r.memoizedState===null&&(t=r.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Ii(t)}catch(a){Ze(r,r.return,a)}}function uw(t){switch(t.tag){case 31:case 13:case 19:var r=t.stateNode;return r===null&&(r=t.stateNode=new uy),r;case 22:return t=t.stateNode,r=t._retryCache,r===null&&(r=t._retryCache=new uy),r;default:throw Error(i(435,t.tag))}}function Cl(t,r){var a=uw(t);r.forEach(function(l){if(!a.has(l)){a.add(l);var f=xw.bind(null,t,l);l.then(f,f)}})}function an(t,r){var a=r.deletions;if(a!==null)for(var l=0;l<a.length;l++){var f=a[l],y=t,w=r,O=w;e:for(;O!==null;){switch(O.tag){case 27:if(cs(O.type)){ft=O.stateNode,sn=!1;break e}break;case 5:ft=O.stateNode,sn=!1;break e;case 3:case 4:ft=O.stateNode.containerInfo,sn=!0;break e}O=O.return}if(ft===null)throw Error(i(160));dy(y,w,f),ft=null,sn=!1,y=f.alternate,y!==null&&(y.return=null),f.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)yy(r,t),r=r.sibling}var Kn=null;function yy(t,r){var a=t.alternate,l=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:an(r,t),on(t),l&4&&(ns(3,t,t.return),Ia(3,t),ns(5,t,t.return));break;case 1:an(r,t),on(t),l&512&&(Tt||a===null||sr(a,a.return)),l&64&&Ar&&(t=t.updateQueue,t!==null&&(l=t.callbacks,l!==null&&(a=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var f=Kn;if(an(r,t),on(t),l&512&&(Tt||a===null||sr(a,a.return)),l&4){var y=a!==null?a.memoizedState:null;if(l=t.memoizedState,a===null)if(l===null)if(t.stateNode===null){e:{l=t.type,a=t.memoizedProps,f=f.ownerDocument||f;t:switch(l){case"title":y=f.getElementsByTagName("title")[0],(!y||y[Mt]||y[st]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=f.createElement(l),f.head.insertBefore(y,f.querySelector("head > title"))),Ft(y,l,a),y[st]=t,L(y),l=y;break e;case"link":var w=yg("link","href",f).get(l+(a.href||""));if(w){for(var O=0;O<w.length;O++)if(y=w[O],y.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&y.getAttribute("rel")===(a.rel==null?null:a.rel)&&y.getAttribute("title")===(a.title==null?null:a.title)&&y.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){w.splice(O,1);break t}}y=f.createElement(l),Ft(y,l,a),f.head.appendChild(y);break;case"meta":if(w=yg("meta","content",f).get(l+(a.content||""))){for(O=0;O<w.length;O++)if(y=w[O],y.getAttribute("content")===(a.content==null?null:""+a.content)&&y.getAttribute("name")===(a.name==null?null:a.name)&&y.getAttribute("property")===(a.property==null?null:a.property)&&y.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&y.getAttribute("charset")===(a.charSet==null?null:a.charSet)){w.splice(O,1);break t}}y=f.createElement(l),Ft(y,l,a),f.head.appendChild(y);break;default:throw Error(i(468,l))}y[st]=t,L(y),l=y}t.stateNode=l}else gg(f,t.type,t.stateNode);else t.stateNode=pg(f,l,t.memoizedProps);else y!==l?(y===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):y.count--,l===null?gg(f,t.type,t.stateNode):pg(f,l,t.memoizedProps)):l===null&&t.stateNode!==null&&lh(t,t.memoizedProps,a.memoizedProps)}break;case 27:an(r,t),on(t),l&512&&(Tt||a===null||sr(a,a.return)),a!==null&&l&4&&lh(t,t.memoizedProps,a.memoizedProps);break;case 5:if(an(r,t),on(t),l&512&&(Tt||a===null||sr(a,a.return)),t.flags&32){f=t.stateNode;try{ui(f,"")}catch(ve){Ze(t,t.return,ve)}}l&4&&t.stateNode!=null&&(f=t.memoizedProps,lh(t,f,a!==null?a.memoizedProps:f)),l&1024&&(fh=!0);break;case 6:if(an(r,t),on(t),l&4){if(t.stateNode===null)throw Error(i(162));l=t.memoizedProps,a=t.stateNode;try{a.nodeValue=l}catch(ve){Ze(t,t.return,ve)}}break;case 3:if(Yl=null,f=Kn,Kn=Gl(r.containerInfo),an(r,t),Kn=f,on(t),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Ii(r.containerInfo)}catch(ve){Ze(t,t.return,ve)}fh&&(fh=!1,gy(t));break;case 4:l=Kn,Kn=Gl(t.stateNode.containerInfo),an(r,t),on(t),Kn=l;break;case 12:an(r,t),on(t);break;case 31:an(r,t),on(t),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,Cl(t,l)));break;case 13:an(r,t),on(t),t.child.flags&8192&&t.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Rl=ut()),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,Cl(t,l)));break;case 22:f=t.memoizedState!==null;var R=a!==null&&a.memoizedState!==null,V=Ar,Z=Tt;if(Ar=V||f,Tt=Z||R,an(r,t),Tt=Z,Ar=V,on(t),l&8192)e:for(r=t.stateNode,r._visibility=f?r._visibility&-2:r._visibility|1,f&&(a===null||R||Ar||Tt||Js(t)),a=null,r=t;;){if(r.tag===5||r.tag===26){if(a===null){R=a=r;try{if(y=R.stateNode,f)w=y.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none";else{O=R.stateNode;var ie=R.memoizedProps.style,Y=ie!=null&&ie.hasOwnProperty("display")?ie.display:null;O.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(ve){Ze(R,R.return,ve)}}}else if(r.tag===6){if(a===null){R=r;try{R.stateNode.nodeValue=f?"":R.memoizedProps}catch(ve){Ze(R,R.return,ve)}}}else if(r.tag===18){if(a===null){R=r;try{var X=R.stateNode;f?ag(X,!0):ag(R.stateNode,!1)}catch(ve){Ze(R,R.return,ve)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===t)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break e;for(;r.sibling===null;){if(r.return===null||r.return===t)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}l&4&&(l=t.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Cl(t,a))));break;case 19:an(r,t),on(t),l&4&&(l=t.updateQueue,l!==null&&(t.updateQueue=null,Cl(t,l)));break;case 30:break;case 21:break;default:an(r,t),on(t)}}function on(t){var r=t.flags;if(r&2){try{for(var a,l=t.return;l!==null;){if(ly(l)){a=l;break}l=l.return}if(a==null)throw Error(i(160));switch(a.tag){case 27:var f=a.stateNode,y=ch(t);Tl(t,y,f);break;case 5:var w=a.stateNode;a.flags&32&&(ui(w,""),a.flags&=-33);var O=ch(t);Tl(t,O,w);break;case 3:case 4:var R=a.stateNode.containerInfo,V=ch(t);uh(t,V,R);break;default:throw Error(i(161))}}catch(Z){Ze(t,t.return,Z)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function gy(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var r=t;gy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),t=t.sibling}}function kr(t,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)fy(t,r.alternate,r),r=r.sibling}function Js(t){for(t=t.child;t!==null;){var r=t;switch(r.tag){case 0:case 11:case 14:case 15:ns(4,r,r.return),Js(r);break;case 1:sr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&ay(r,r.return,a),Js(r);break;case 27:Xa(r.stateNode);case 26:case 5:sr(r,r.return),Js(r);break;case 22:r.memoizedState===null&&Js(r);break;case 30:Js(r);break;default:Js(r)}t=t.sibling}}function Nr(t,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var l=r.alternate,f=t,y=r,w=y.flags;switch(y.tag){case 0:case 11:case 15:Nr(f,y,a),Ia(4,y);break;case 1:if(Nr(f,y,a),l=y,f=l.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(V){Ze(l,l.return,V)}if(l=y,f=l.updateQueue,f!==null){var O=l.stateNode;try{var R=f.shared.hiddenCallbacks;if(R!==null)for(f.shared.hiddenCallbacks=null,f=0;f<R.length;f++)K0(R[f],O)}catch(V){Ze(l,l.return,V)}}a&&w&64&&iy(y),$a(y,y.return);break;case 27:cy(y);case 26:case 5:Nr(f,y,a),a&&l===null&&w&4&&oy(y),$a(y,y.return);break;case 12:Nr(f,y,a);break;case 31:Nr(f,y,a),a&&w&4&&my(f,y);break;case 13:Nr(f,y,a),a&&w&4&&py(f,y);break;case 22:y.memoizedState===null&&Nr(f,y,a),$a(y,y.return);break;case 30:break;default:Nr(f,y,a)}r=r.sibling}}function hh(t,r){var a=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),t=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(t=r.memoizedState.cachePool.pool),t!==a&&(t!=null&&t.refCount++,a!=null&&ka(a))}function dh(t,r){t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&ka(t))}function Jn(t,r,a,l){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)by(t,r,a,l),r=r.sibling}function by(t,r,a,l){var f=r.flags;switch(r.tag){case 0:case 11:case 15:Jn(t,r,a,l),f&2048&&Ia(9,r);break;case 1:Jn(t,r,a,l);break;case 3:Jn(t,r,a,l),f&2048&&(t=null,r.alternate!==null&&(t=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==t&&(r.refCount++,t!=null&&ka(t)));break;case 12:if(f&2048){Jn(t,r,a,l),t=r.stateNode;try{var y=r.memoizedProps,w=y.id,O=y.onPostCommit;typeof O=="function"&&O(w,r.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(R){Ze(r,r.return,R)}}else Jn(t,r,a,l);break;case 31:Jn(t,r,a,l);break;case 13:Jn(t,r,a,l);break;case 23:break;case 22:y=r.stateNode,w=r.alternate,r.memoizedState!==null?y._visibility&2?Jn(t,r,a,l):Ha(t,r):y._visibility&2?Jn(t,r,a,l):(y._visibility|=2,Ti(t,r,a,l,(r.subtreeFlags&10256)!==0||!1)),f&2048&&hh(w,r);break;case 24:Jn(t,r,a,l),f&2048&&dh(r.alternate,r);break;default:Jn(t,r,a,l)}}function Ti(t,r,a,l,f){for(f=f&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=t,w=r,O=a,R=l,V=w.flags;switch(w.tag){case 0:case 11:case 15:Ti(y,w,O,R,f),Ia(8,w);break;case 23:break;case 22:var Z=w.stateNode;w.memoizedState!==null?Z._visibility&2?Ti(y,w,O,R,f):Ha(y,w):(Z._visibility|=2,Ti(y,w,O,R,f)),f&&V&2048&&hh(w.alternate,w);break;case 24:Ti(y,w,O,R,f),f&&V&2048&&dh(w.alternate,w);break;default:Ti(y,w,O,R,f)}r=r.sibling}}function Ha(t,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=t,l=r,f=l.flags;switch(l.tag){case 22:Ha(a,l),f&2048&&hh(l.alternate,l);break;case 24:Ha(a,l),f&2048&&dh(l.alternate,l);break;default:Ha(a,l)}r=r.sibling}}var Fa=8192;function Ci(t,r,a){if(t.subtreeFlags&Fa)for(t=t.child;t!==null;)xy(t,r,a),t=t.sibling}function xy(t,r,a){switch(t.tag){case 26:Ci(t,r,a),t.flags&Fa&&t.memoizedState!==null&&Qw(a,Kn,t.memoizedState,t.memoizedProps);break;case 5:Ci(t,r,a);break;case 3:case 4:var l=Kn;Kn=Gl(t.stateNode.containerInfo),Ci(t,r,a),Kn=l;break;case 22:t.memoizedState===null&&(l=t.alternate,l!==null&&l.memoizedState!==null?(l=Fa,Fa=16777216,Ci(t,r,a),Fa=l):Ci(t,r,a));break;default:Ci(t,r,a)}}function vy(t){var r=t.alternate;if(r!==null&&(t=r.child,t!==null)){r.child=null;do r=t.sibling,t.sibling=null,t=r;while(t!==null)}}function Ga(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Pt=l,wy(l,t)}vy(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)_y(t),t=t.sibling}function _y(t){switch(t.tag){case 0:case 11:case 15:Ga(t),t.flags&2048&&ns(9,t,t.return);break;case 3:Ga(t);break;case 12:Ga(t);break;case 22:var r=t.stateNode;t.memoizedState!==null&&r._visibility&2&&(t.return===null||t.return.tag!==13)?(r._visibility&=-3,Ml(t)):Ga(t);break;default:Ga(t)}}function Ml(t){var r=t.deletions;if((t.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var l=r[a];Pt=l,wy(l,t)}vy(t)}for(t=t.child;t!==null;){switch(r=t,r.tag){case 0:case 11:case 15:ns(8,r,r.return),Ml(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,Ml(r));break;default:Ml(r)}t=t.sibling}}function wy(t,r){for(;Pt!==null;){var a=Pt;switch(a.tag){case 0:case 11:case 15:ns(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:ka(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Pt=l;else e:for(a=t;Pt!==null;){l=Pt;var f=l.sibling,y=l.return;if(hy(l),l===a){Pt=null;break e}if(f!==null){f.return=y,Pt=f;break e}Pt=y}}}var fw={getCacheForType:function(t){var r=$t(jt),a=r.data.get(t);return a===void 0&&(a=t(),r.data.set(t,a)),a},cacheSignal:function(){return $t(jt).controller.signal}},hw=typeof WeakMap=="function"?WeakMap:Map,Qe=0,it=null,Ue=null,$e=0,We=0,gn=null,rs=!1,Mi=!1,mh=!1,Tr=0,xt=0,ss=0,Qs=0,ph=0,bn=0,Ri=0,Va=null,ln=null,yh=!1,Rl=0,Sy=0,Dl=1/0,Ll=null,is=null,Rt=0,as=null,Di=null,Cr=0,gh=0,bh=null,Ey=null,Ya=0,xh=null;function xn(){return(Qe&2)!==0&&$e!==0?$e&-$e:H.T!==null?Oh():pa()}function Oy(){if(bn===0)if(($e&536870912)===0||Fe){var t=dr;dr<<=1,(dr&3932160)===0&&(dr=262144),bn=t}else bn=536870912;return t=pn.current,t!==null&&(t.flags|=32),bn}function cn(t,r,a){(t===it&&(We===2||We===9)||t.cancelPendingCommit!==null)&&(Li(t,0),os(t,$e,bn,!1)),Gn(t,a),((Qe&2)===0||t!==it)&&(t===it&&((Qe&2)===0&&(Qs|=a),xt===4&&os(t,$e,bn,!1)),ir(t))}function Ay(t,r,a){if((Qe&6)!==0)throw Error(i(327));var l=!a&&(r&127)===0&&(r&t.expiredLanes)===0||Cs(t,r),f=l?pw(t,r):_h(t,r,!0),y=l;do{if(f===0){Mi&&!l&&os(t,r,0,!1);break}else{if(a=t.current.alternate,y&&!dw(a)){f=_h(t,r,!1),y=!1;continue}if(f===2){if(y=r,t.errorRecoveryDisabledLanes&y)var w=0;else w=t.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){r=w;e:{var O=t;f=Va;var R=O.current.memoizedState.isDehydrated;if(R&&(Li(O,w).flags|=256),w=_h(O,w,!1),w!==2){if(mh&&!R){O.errorRecoveryDisabledLanes|=y,Qs|=y,f=4;break e}y=ln,ln=f,y!==null&&(ln===null?ln=y:ln.push.apply(ln,y))}f=w}if(y=!1,f!==2)continue}}if(f===1){Li(t,0),os(t,r,0,!0);break}e:{switch(l=t,y=f,y){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:os(l,r,bn,!rs);break e;case 2:ln=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(f=Rl+300-ut(),10<f)){if(os(l,r,bn,!rs),Ts(l,0,!0)!==0)break e;Cr=r,l.timeoutHandle=rg(jy.bind(null,l,a,ln,Ll,yh,r,bn,Qs,Ri,rs,y,"Throttled",-0,0),f);break e}jy(l,a,ln,Ll,yh,r,bn,Qs,Ri,rs,y,null,-0,0)}}break}while(!0);ir(t)}function jy(t,r,a,l,f,y,w,O,R,V,Z,ie,Y,X){if(t.timeoutHandle=-1,ie=r.subtreeFlags,ie&8192||(ie&16785408)===16785408){ie={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:yr},xy(r,y,ie);var ve=(y&62914560)===y?Rl-ut():(y&4194048)===y?Sy-ut():0;if(ve=Xw(ie,ve),ve!==null){Cr=y,t.cancelPendingCommit=ve(Ly.bind(null,t,r,y,a,l,f,w,O,R,Z,ie,null,Y,X)),os(t,y,w,!V);return}}Ly(t,r,y,a,l,f,w,O,R)}function dw(t){for(var r=t;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var f=a[l],y=f.getSnapshot;f=f.value;try{if(!dn(y(),f))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function os(t,r,a,l){r&=~ph,r&=~Qs,t.suspendedLanes|=r,t.pingedLanes&=~r,l&&(t.warmLanes|=r),l=t.expirationTimes;for(var f=r;0<f;){var y=31-Gt(f),w=1<<y;l[y]=-1,f&=~w}a!==0&&Fr(t,a,r)}function ql(){return(Qe&6)===0?(Ka(0),!1):!0}function vh(){if(Ue!==null){if(We===0)var t=Ue.return;else t=Ue,vr=Is=null,qf(t),Oi=null,Ta=0,t=Ue;for(;t!==null;)sy(t.alternate,t),t=t.return;Ue=null}}function Li(t,r){var a=t.timeoutHandle;a!==-1&&(t.timeoutHandle=-1,Rw(a)),a=t.cancelPendingCommit,a!==null&&(t.cancelPendingCommit=null,a()),Cr=0,vh(),it=t,Ue=a=br(t.current,null),$e=r,We=0,gn=null,rs=!1,Mi=Cs(t,r),mh=!1,Ri=bn=ph=Qs=ss=xt=0,ln=Va=null,yh=!1,(r&8)!==0&&(r|=r&32);var l=t.entangledLanes;if(l!==0)for(t=t.entanglements,l&=r;0<l;){var f=31-Gt(l),y=1<<f;r|=t[f],l&=~y}return Tr=r,rl(),a}function ky(t,r){Re=null,H.H=Ba,r===Ei||r===fl?(r=F0(),We=3):r===Ef?(r=F0(),We=4):We=r===Wf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,gn=r,Ue===null&&(xt=1,Ol(t,Rn(r,t.current)))}function Ny(){var t=pn.current;return t===null?!0:($e&4194048)===$e?Pn===null:($e&62914560)===$e||($e&536870912)!==0?t===Pn:!1}function Ty(){var t=H.H;return H.H=Ba,t===null?Ba:t}function Cy(){var t=H.A;return H.A=fw,t}function Pl(){xt=4,rs||($e&4194048)!==$e&&pn.current!==null||(Mi=!0),(ss&134217727)===0&&(Qs&134217727)===0||it===null||os(it,$e,bn,!1)}function _h(t,r,a){var l=Qe;Qe|=2;var f=Ty(),y=Cy();(it!==t||$e!==r)&&(Ll=null,Li(t,r)),r=!1;var w=xt;e:do try{if(We!==0&&Ue!==null){var O=Ue,R=gn;switch(We){case 8:vh(),w=6;break e;case 3:case 2:case 9:case 6:pn.current===null&&(r=!0);var V=We;if(We=0,gn=null,qi(t,O,R,V),a&&Mi){w=0;break e}break;default:V=We,We=0,gn=null,qi(t,O,R,V)}}mw(),w=xt;break}catch(Z){ky(t,Z)}while(!0);return r&&t.shellSuspendCounter++,vr=Is=null,Qe=l,H.H=f,H.A=y,Ue===null&&(it=null,$e=0,rl()),w}function mw(){for(;Ue!==null;)My(Ue)}function pw(t,r){var a=Qe;Qe|=2;var l=Ty(),f=Cy();it!==t||$e!==r?(Ll=null,Dl=ut()+500,Li(t,r)):Mi=Cs(t,r);e:do try{if(We!==0&&Ue!==null){r=Ue;var y=gn;t:switch(We){case 1:We=0,gn=null,qi(t,r,y,1);break;case 2:case 9:if($0(y)){We=0,gn=null,Ry(r);break}r=function(){We!==2&&We!==9||it!==t||(We=7),ir(t)},y.then(r,r);break e;case 3:We=7;break e;case 4:We=5;break e;case 7:$0(y)?(We=0,gn=null,Ry(r)):(We=0,gn=null,qi(t,r,y,7));break;case 5:var w=null;switch(Ue.tag){case 26:w=Ue.memoizedState;case 5:case 27:var O=Ue;if(w?bg(w):O.stateNode.complete){We=0,gn=null;var R=O.sibling;if(R!==null)Ue=R;else{var V=O.return;V!==null?(Ue=V,Bl(V)):Ue=null}break t}}We=0,gn=null,qi(t,r,y,5);break;case 6:We=0,gn=null,qi(t,r,y,6);break;case 8:vh(),xt=6;break e;default:throw Error(i(462))}}yw();break}catch(Z){ky(t,Z)}while(!0);return vr=Is=null,H.H=l,H.A=f,Qe=a,Ue!==null?0:(it=null,$e=0,rl(),xt)}function yw(){for(;Ue!==null&&!zo();)My(Ue)}function My(t){var r=ny(t.alternate,t,Tr);t.memoizedProps=t.pendingProps,r===null?Bl(t):Ue=r}function Ry(t){var r=t,a=r.alternate;switch(r.tag){case 15:case 0:r=Qp(a,r,r.pendingProps,r.type,void 0,$e);break;case 11:r=Qp(a,r,r.pendingProps,r.type.render,r.ref,$e);break;case 5:qf(r);default:sy(a,r),r=Ue=C0(r,Tr),r=ny(a,r,Tr)}t.memoizedProps=t.pendingProps,r===null?Bl(t):Ue=r}function qi(t,r,a,l){vr=Is=null,qf(r),Oi=null,Ta=0;var f=r.return;try{if(sw(t,f,r,a,$e)){xt=1,Ol(t,Rn(a,t.current)),Ue=null;return}}catch(y){if(f!==null)throw Ue=f,y;xt=1,Ol(t,Rn(a,t.current)),Ue=null;return}r.flags&32768?(Fe||l===1?t=!0:Mi||($e&536870912)!==0?t=!1:(rs=t=!0,(l===2||l===9||l===3||l===6)&&(l=pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),Dy(r,t)):Bl(r)}function Bl(t){var r=t;do{if((r.flags&32768)!==0){Dy(r,rs);return}t=r.return;var a=ow(r.alternate,r,Tr);if(a!==null){Ue=a;return}if(r=r.sibling,r!==null){Ue=r;return}Ue=r=t}while(r!==null);xt===0&&(xt=5)}function Dy(t,r){do{var a=lw(t.alternate,t);if(a!==null){a.flags&=32767,Ue=a;return}if(a=t.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(t=t.sibling,t!==null)){Ue=t;return}Ue=t=a}while(t!==null);xt=6,Ue=null}function Ly(t,r,a,l,f,y,w,O,R){t.cancelPendingCommit=null;do Ul();while(Rt!==0);if((Qe&6)!==0)throw Error(i(327));if(r!==null){if(r===t.current)throw Error(i(177));if(y=r.lanes|r.childLanes,y|=cf,Hr(t,a,y,w,O,R),t===it&&(Ue=it=null,$e=0),Di=r,as=t,Cr=a,gh=y,bh=f,Ey=l,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,vw(ii,function(){return zy(),null})):(t.callbackNode=null,t.callbackPriority=0),l=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||l){l=H.T,H.T=null,f=J.p,J.p=2,w=Qe,Qe|=4;try{cw(t,r,a)}finally{Qe=w,J.p=f,H.T=l}}Rt=1,qy(),Py(),By()}}function qy(){if(Rt===1){Rt=0;var t=as,r=Di,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=H.T,H.T=null;var l=J.p;J.p=2;var f=Qe;Qe|=4;try{yy(r,t);var y=Rh,w=w0(t.containerInfo),O=y.focusedElem,R=y.selectionRange;if(w!==O&&O&&O.ownerDocument&&_0(O.ownerDocument.documentElement,O)){if(R!==null&&rf(O)){var V=R.start,Z=R.end;if(Z===void 0&&(Z=V),"selectionStart"in O)O.selectionStart=V,O.selectionEnd=Math.min(Z,O.value.length);else{var ie=O.ownerDocument||document,Y=ie&&ie.defaultView||window;if(Y.getSelection){var X=Y.getSelection(),ve=O.textContent.length,Te=Math.min(R.start,ve),rt=R.end===void 0?Te:Math.min(R.end,ve);!X.extend&&Te>rt&&(w=rt,rt=Te,Te=w);var I=v0(O,Te),P=v0(O,rt);if(I&&P&&(X.rangeCount!==1||X.anchorNode!==I.node||X.anchorOffset!==I.offset||X.focusNode!==P.node||X.focusOffset!==P.offset)){var G=ie.createRange();G.setStart(I.node,I.offset),X.removeAllRanges(),Te>rt?(X.addRange(G),X.extend(P.node,P.offset)):(G.setEnd(P.node,P.offset),X.addRange(G))}}}}for(ie=[],X=O;X=X.parentNode;)X.nodeType===1&&ie.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<ie.length;O++){var ee=ie[O];ee.element.scrollLeft=ee.left,ee.element.scrollTop=ee.top}}Xl=!!Mh,Rh=Mh=null}finally{Qe=f,J.p=l,H.T=a}}t.current=r,Rt=2}}function Py(){if(Rt===2){Rt=0;var t=as,r=Di,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=H.T,H.T=null;var l=J.p;J.p=2;var f=Qe;Qe|=4;try{fy(t,r.alternate,r)}finally{Qe=f,J.p=l,H.T=a}}Rt=3}}function By(){if(Rt===4||Rt===3){Rt=0,si();var t=as,r=Di,a=Cr,l=Ey;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Rt=5:(Rt=0,Di=as=null,Uy(t,t.pendingLanes));var f=t.pendingLanes;if(f===0&&(is=null),Rs(a),r=r.stateNode,_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(Ns,r,void 0,(r.current.flags&128)===128)}catch{}if(l!==null){r=H.T,f=J.p,J.p=2,H.T=null;try{for(var y=t.onRecoverableError,w=0;w<l.length;w++){var O=l[w];y(O.value,{componentStack:O.stack})}}finally{H.T=r,J.p=f}}(Cr&3)!==0&&Ul(),ir(t),f=t.pendingLanes,(a&261930)!==0&&(f&42)!==0?t===xh?Ya++:(Ya=0,xh=t):Ya=0,Ka(0)}}function Uy(t,r){(t.pooledCacheLanes&=r)===0&&(r=t.pooledCache,r!=null&&(t.pooledCache=null,ka(r)))}function Ul(){return qy(),Py(),By(),zy()}function zy(){if(Rt!==5)return!1;var t=as,r=gh;gh=0;var a=Rs(Cr),l=H.T,f=J.p;try{J.p=32>a?32:a,H.T=null,a=bh,bh=null;var y=as,w=Cr;if(Rt=0,Di=as=null,Cr=0,(Qe&6)!==0)throw Error(i(331));var O=Qe;if(Qe|=4,_y(y.current),by(y,y.current,w,a),Qe=O,Ka(0,!1),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(Ns,y)}catch{}return!0}finally{J.p=f,H.T=l,Uy(t,r)}}function Iy(t,r,a){r=Rn(a,r),r=Xf(t.stateNode,r,2),t=Zr(t,r,2),t!==null&&(Gn(t,2),ir(t))}function Ze(t,r,a){if(t.tag===3)Iy(t,t,a);else for(;r!==null;){if(r.tag===3){Iy(r,t,a);break}else if(r.tag===1){var l=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(is===null||!is.has(l))){t=Rn(a,t),a=$p(2),l=Zr(r,a,2),l!==null&&(Hp(a,l,r,t),Gn(l,2),ir(l));break}}r=r.return}}function wh(t,r,a){var l=t.pingCache;if(l===null){l=t.pingCache=new hw;var f=new Set;l.set(r,f)}else f=l.get(r),f===void 0&&(f=new Set,l.set(r,f));f.has(a)||(mh=!0,f.add(a),t=gw.bind(null,t,r,a),r.then(t,t))}function gw(t,r,a){var l=t.pingCache;l!==null&&l.delete(r),t.pingedLanes|=t.suspendedLanes&a,t.warmLanes&=~a,it===t&&($e&a)===a&&(xt===4||xt===3&&($e&62914560)===$e&&300>ut()-Rl?(Qe&2)===0&&Li(t,0):ph|=a,Ri===$e&&(Ri=0)),ir(t)}function $y(t,r){r===0&&(r=oi()),t=Bs(t,r),t!==null&&(Gn(t,r),ir(t))}function bw(t){var r=t.memoizedState,a=0;r!==null&&(a=r.retryLane),$y(t,a)}function xw(t,r){var a=0;switch(t.tag){case 31:case 13:var l=t.stateNode,f=t.memoizedState;f!==null&&(a=f.retryLane);break;case 19:l=t.stateNode;break;case 22:l=t.stateNode._retryCache;break;default:throw Error(i(314))}l!==null&&l.delete(r),$y(t,a)}function vw(t,r){return fa(t,r)}var zl=null,Pi=null,Sh=!1,Il=!1,Eh=!1,ls=0;function ir(t){t!==Pi&&t.next===null&&(Pi===null?zl=Pi=t:Pi=Pi.next=t),Il=!0,Sh||(Sh=!0,ww())}function Ka(t,r){if(!Eh&&Il){Eh=!0;do for(var a=!1,l=zl;l!==null;){if(t!==0){var f=l.pendingLanes;if(f===0)var y=0;else{var w=l.suspendedLanes,O=l.pingedLanes;y=(1<<31-Gt(42|t)+1)-1,y&=f&~(w&~O),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,Vy(l,y))}else y=$e,y=Ts(l,l===it?y:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(y&3)===0||Cs(l,y)||(a=!0,Vy(l,y));l=l.next}while(a);Eh=!1}}function _w(){Hy()}function Hy(){Il=Sh=!1;var t=0;ls!==0&&Mw()&&(t=ls);for(var r=ut(),a=null,l=zl;l!==null;){var f=l.next,y=Fy(l,r);y===0?(l.next=null,a===null?zl=f:a.next=f,f===null&&(Pi=a)):(a=l,(t!==0||(y&3)!==0)&&(Il=!0)),l=f}Rt!==0&&Rt!==5||Ka(t),ls!==0&&(ls=0)}function Fy(t,r){for(var a=t.suspendedLanes,l=t.pingedLanes,f=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var w=31-Gt(y),O=1<<w,R=f[w];R===-1?((O&a)===0||(O&l)!==0)&&(f[w]=ma(O,r)):R<=r&&(t.expiredLanes|=O),y&=~O}if(r=it,a=$e,a=Ts(t,t===r?a:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),l=t.callbackNode,a===0||t===r&&(We===2||We===9)||t.cancelPendingCommit!==null)return l!==null&&l!==null&&hr(l),t.callbackNode=null,t.callbackPriority=0;if((a&3)===0||Cs(t,a)){if(r=a&-a,r===t.callbackPriority)return r;switch(l!==null&&hr(l),Rs(a)){case 2:case 8:a=$o;break;case 32:a=ii;break;case 268435456:a=Ho;break;default:a=ii}return l=Gy.bind(null,t),a=fa(a,l),t.callbackPriority=r,t.callbackNode=a,r}return l!==null&&l!==null&&hr(l),t.callbackPriority=2,t.callbackNode=null,2}function Gy(t,r){if(Rt!==0&&Rt!==5)return t.callbackNode=null,t.callbackPriority=0,null;var a=t.callbackNode;if(Ul()&&t.callbackNode!==a)return null;var l=$e;return l=Ts(t,t===it?l:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),l===0?null:(Ay(t,l,r),Fy(t,ut()),t.callbackNode!=null&&t.callbackNode===a?Gy.bind(null,t):null)}function Vy(t,r){if(Ul())return null;Ay(t,r,!0)}function ww(){Dw(function(){(Qe&6)!==0?fa(Io,_w):Hy()})}function Oh(){if(ls===0){var t=wi;t===0&&(t=zr,zr<<=1,(zr&261888)===0&&(zr=256)),ls=t}return ls}function Yy(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Jo(""+t)}function Ky(t,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,t.id&&a.setAttribute("form",t.id),r.parentNode.insertBefore(a,r),t=new FormData(t),a.parentNode.removeChild(a),t}function Sw(t,r,a,l,f){if(r==="submit"&&a&&a.stateNode===f){var y=Yy((f[gt]||null).action),w=l.submitter;w&&(r=(r=w[gt]||null)?Yy(r.formAction):w.getAttribute("formAction"),r!==null&&(y=r,w=null));var O=new Zo("action","action",null,l,f);t.push({event:O,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ls!==0){var R=w?Ky(f,w):new FormData(f);Gf(a,{pending:!0,data:R,method:f.method,action:y},null,R)}}else typeof y=="function"&&(O.preventDefault(),R=w?Ky(f,w):new FormData(f),Gf(a,{pending:!0,data:R,method:f.method,action:y},y,R))},currentTarget:f}]})}}for(var Ah=0;Ah<lf.length;Ah++){var jh=lf[Ah],Ew=jh.toLowerCase(),Ow=jh[0].toUpperCase()+jh.slice(1);Yn(Ew,"on"+Ow)}Yn(O0,"onAnimationEnd"),Yn(A0,"onAnimationIteration"),Yn(j0,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn(I_,"onTransitionRun"),Yn($_,"onTransitionStart"),Yn(H_,"onTransitionCancel"),Yn(k0,"onTransitionEnd"),K("onMouseEnter",["mouseout","mouseover"]),K("onMouseLeave",["mouseout","mouseover"]),K("onPointerEnter",["pointerout","pointerover"]),K("onPointerLeave",["pointerout","pointerover"]),oe("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),oe("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),oe("onBeforeInput",["compositionend","keypress","textInput","paste"]),oe("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),oe("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),oe("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ja="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(" "),Aw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ja));function Jy(t,r){r=(r&4)!==0;for(var a=0;a<t.length;a++){var l=t[a],f=l.event;l=l.listeners;e:{var y=void 0;if(r)for(var w=l.length-1;0<=w;w--){var O=l[w],R=O.instance,V=O.currentTarget;if(O=O.listener,R!==y&&f.isPropagationStopped())break e;y=O,f.currentTarget=V;try{y(f)}catch(Z){nl(Z)}f.currentTarget=null,y=R}else for(w=0;w<l.length;w++){if(O=l[w],R=O.instance,V=O.currentTarget,O=O.listener,R!==y&&f.isPropagationStopped())break e;y=O,f.currentTarget=V;try{y(f)}catch(Z){nl(Z)}f.currentTarget=null,y=R}}}}function ze(t,r){var a=r[Ds];a===void 0&&(a=r[Ds]=new Set);var l=t+"__bubble";a.has(l)||(Qy(r,t,2,!1),a.add(l))}function kh(t,r,a){var l=0;r&&(l|=4),Qy(a,t,l,r)}var $l="_reactListening"+Math.random().toString(36).slice(2);function Nh(t){if(!t[$l]){t[$l]=!0,$.forEach(function(a){a!=="selectionchange"&&(Aw.has(a)||kh(a,!1,t),kh(a,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[$l]||(r[$l]=!0,kh("selectionchange",!1,r))}}function Qy(t,r,a,l){switch(Og(r)){case 2:var f=eS;break;case 8:f=tS;break;default:f=Fh}a=f.bind(null,r,a,t),f=void 0,!Ku||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),l?f!==void 0?t.addEventListener(r,a,{capture:!0,passive:f}):t.addEventListener(r,a,!0):f!==void 0?t.addEventListener(r,a,{passive:f}):t.addEventListener(r,a,!1)}function Th(t,r,a,l,f){var y=l;if((r&1)===0&&(r&2)===0&&l!==null)e:for(;;){if(l===null)return;var w=l.tag;if(w===3||w===4){var O=l.stateNode.containerInfo;if(O===f)break;if(w===4)for(w=l.return;w!==null;){var R=w.tag;if((R===3||R===4)&&w.stateNode.containerInfo===f)return;w=w.return}for(;O!==null;){if(w=A(O),w===null)return;if(R=w.tag,R===5||R===6||R===26||R===27){l=y=w;continue e}O=O.parentNode}}l=l.return}t0(function(){var V=y,Z=Vu(a),ie=[];e:{var Y=N0.get(t);if(Y!==void 0){var X=Zo,ve=t;switch(t){case"keypress":if(Xo(a)===0)break e;case"keydown":case"keyup":X=x_;break;case"focusin":ve="focus",X=Wu;break;case"focusout":ve="blur",X=Wu;break;case"beforeblur":case"afterblur":X=Wu;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":X=s0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=o_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=w_;break;case O0:case A0:case j0:X=u_;break;case k0:X=E_;break;case"scroll":case"scrollend":X=i_;break;case"wheel":X=A_;break;case"copy":case"cut":case"paste":X=h_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=a0;break;case"toggle":case"beforetoggle":X=k_}var Te=(r&4)!==0,rt=!Te&&(t==="scroll"||t==="scrollend"),I=Te?Y!==null?Y+"Capture":null:Y;Te=[];for(var P=V,G;P!==null;){var ee=P;if(G=ee.stateNode,ee=ee.tag,ee!==5&&ee!==26&&ee!==27||G===null||I===null||(ee=ga(P,I),ee!=null&&Te.push(Qa(P,ee,G))),rt)break;P=P.return}0<Te.length&&(Y=new X(Y,ve,null,a,Z),ie.push({event:Y,listeners:Te}))}}if((r&7)===0){e:{if(Y=t==="mouseover"||t==="pointerover",X=t==="mouseout"||t==="pointerout",Y&&a!==Gu&&(ve=a.relatedTarget||a.fromElement)&&(A(ve)||ve[hn]))break e;if((X||Y)&&(Y=Z.window===Z?Z:(Y=Z.ownerDocument)?Y.defaultView||Y.parentWindow:window,X?(ve=a.relatedTarget||a.toElement,X=V,ve=ve?A(ve):null,ve!==null&&(rt=c(ve),Te=ve.tag,ve!==rt||Te!==5&&Te!==27&&Te!==6)&&(ve=null)):(X=null,ve=V),X!==ve)){if(Te=s0,ee="onMouseLeave",I="onMouseEnter",P="mouse",(t==="pointerout"||t==="pointerover")&&(Te=a0,ee="onPointerLeave",I="onPointerEnter",P="pointer"),rt=X==null?Y:k(X),G=ve==null?Y:k(ve),Y=new Te(ee,P+"leave",X,a,Z),Y.target=rt,Y.relatedTarget=G,ee=null,A(Z)===V&&(Te=new Te(I,P+"enter",ve,a,Z),Te.target=G,Te.relatedTarget=rt,ee=Te),rt=ee,X&&ve)t:{for(Te=jw,I=X,P=ve,G=0,ee=I;ee;ee=Te(ee))G++;ee=0;for(var je=P;je;je=Te(je))ee++;for(;0<G-ee;)I=Te(I),G--;for(;0<ee-G;)P=Te(P),ee--;for(;G--;){if(I===P||P!==null&&I===P.alternate){Te=I;break t}I=Te(I),P=Te(P)}Te=null}else Te=null;X!==null&&Xy(ie,Y,X,Te,!1),ve!==null&&rt!==null&&Xy(ie,rt,ve,Te,!0)}}e:{if(Y=V?k(V):window,X=Y.nodeName&&Y.nodeName.toLowerCase(),X==="select"||X==="input"&&Y.type==="file")var Ke=m0;else if(h0(Y))if(p0)Ke=B_;else{Ke=q_;var we=L_}else X=Y.nodeName,!X||X.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?V&&Fu(V.elementType)&&(Ke=m0):Ke=P_;if(Ke&&(Ke=Ke(t,V))){d0(ie,Ke,a,Z);break e}we&&we(t,Y,V),t==="focusout"&&V&&Y.type==="number"&&V.memoizedProps.value!=null&&Hu(Y,"number",Y.value)}switch(we=V?k(V):window,t){case"focusin":(h0(we)||we.contentEditable==="true")&&(mi=we,sf=V,Oa=null);break;case"focusout":Oa=sf=mi=null;break;case"mousedown":af=!0;break;case"contextmenu":case"mouseup":case"dragend":af=!1,S0(ie,a,Z);break;case"selectionchange":if(z_)break;case"keydown":case"keyup":S0(ie,a,Z)}var De;if(ef)e:{switch(t){case"compositionstart":var He="onCompositionStart";break e;case"compositionend":He="onCompositionEnd";break e;case"compositionupdate":He="onCompositionUpdate";break e}He=void 0}else di?u0(t,a)&&(He="onCompositionEnd"):t==="keydown"&&a.keyCode===229&&(He="onCompositionStart");He&&(o0&&a.locale!=="ko"&&(di||He!=="onCompositionStart"?He==="onCompositionEnd"&&di&&(De=n0()):(Vr=Z,Ju="value"in Vr?Vr.value:Vr.textContent,di=!0)),we=Hl(V,He),0<we.length&&(He=new i0(He,t,null,a,Z),ie.push({event:He,listeners:we}),De?He.data=De:(De=f0(a),De!==null&&(He.data=De)))),(De=T_?C_(t,a):M_(t,a))&&(He=Hl(V,"onBeforeInput"),0<He.length&&(we=new i0("onBeforeInput","beforeinput",null,a,Z),ie.push({event:we,listeners:He}),we.data=De)),Sw(ie,t,V,a,Z)}Jy(ie,r)})}function Qa(t,r,a){return{instance:t,listener:r,currentTarget:a}}function Hl(t,r){for(var a=r+"Capture",l=[];t!==null;){var f=t,y=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||y===null||(f=ga(t,a),f!=null&&l.unshift(Qa(t,f,y)),f=ga(t,r),f!=null&&l.push(Qa(t,f,y))),t.tag===3)return l;t=t.return}return[]}function jw(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Xy(t,r,a,l,f){for(var y=r._reactName,w=[];a!==null&&a!==l;){var O=a,R=O.alternate,V=O.stateNode;if(O=O.tag,R!==null&&R===l)break;O!==5&&O!==26&&O!==27||V===null||(R=V,f?(V=ga(a,y),V!=null&&w.unshift(Qa(a,V,R))):f||(V=ga(a,y),V!=null&&w.push(Qa(a,V,R)))),a=a.return}w.length!==0&&t.push({event:r,listeners:w})}var kw=/\r\n?/g,Nw=/\u0000|\uFFFD/g;function Wy(t){return(typeof t=="string"?t:""+t).replace(kw,`
26
+ `).replace(Nw,"")}function Zy(t,r){return r=Wy(r),Wy(t)===r}function nt(t,r,a,l,f,y){switch(a){case"children":typeof l=="string"?r==="body"||r==="textarea"&&l===""||ui(t,l):(typeof l=="number"||typeof l=="bigint")&&r!=="body"&&ui(t,""+l);break;case"className":Vn(t,"class",l);break;case"tabIndex":Vn(t,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Vn(t,a,l);break;case"style":Zm(t,l,y);break;case"data":if(r!=="object"){Vn(t,"data",l);break}case"src":case"href":if(l===""&&(r!=="a"||a!=="href")){t.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){t.removeAttribute(a);break}l=Jo(""+l),t.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){t.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(a==="formAction"?(r!=="input"&&nt(t,r,"name",f.name,f,null),nt(t,r,"formEncType",f.formEncType,f,null),nt(t,r,"formMethod",f.formMethod,f,null),nt(t,r,"formTarget",f.formTarget,f,null)):(nt(t,r,"encType",f.encType,f,null),nt(t,r,"method",f.method,f,null),nt(t,r,"target",f.target,f,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){t.removeAttribute(a);break}l=Jo(""+l),t.setAttribute(a,l);break;case"onClick":l!=null&&(t.onclick=yr);break;case"onScroll":l!=null&&ze("scroll",t);break;case"onScrollEnd":l!=null&&ze("scrollend",t);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));t.innerHTML=a}}break;case"multiple":t.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":t.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"){t.removeAttribute("xlink:href");break}a=Jo(""+l),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,""+l):t.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,""):t.removeAttribute(a);break;case"capture":case"download":l===!0?t.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?t.setAttribute(a,l):t.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?t.setAttribute(a,l):t.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?t.removeAttribute(a):t.setAttribute(a,l);break;case"popover":ze("beforetoggle",t),ze("toggle",t),Vt(t,"popover",l);break;case"xlinkActuate":pr(t,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":pr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":pr(t,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":pr(t,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":pr(t,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":pr(t,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":pr(t,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":pr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":pr(t,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Vt(t,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=r_.get(a)||a,Vt(t,a,l))}}function Ch(t,r,a,l,f,y){switch(a){case"style":Zm(t,l,y);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(i(61));if(a=l.__html,a!=null){if(f.children!=null)throw Error(i(60));t.innerHTML=a}}break;case"children":typeof l=="string"?ui(t,l):(typeof l=="number"||typeof l=="bigint")&&ui(t,""+l);break;case"onScroll":l!=null&&ze("scroll",t);break;case"onScrollEnd":l!=null&&ze("scrollend",t);break;case"onClick":l!=null&&(t.onclick=yr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!se.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(f=a.endsWith("Capture"),r=a.slice(2,f?a.length-7:void 0),y=t[gt]||null,y=y!=null?y[a]:null,typeof y=="function"&&t.removeEventListener(r,y,f),typeof l=="function")){typeof y!="function"&&y!==null&&(a in t?t[a]=null:t.hasAttribute(a)&&t.removeAttribute(a)),t.addEventListener(r,l,f);break e}a in t?t[a]=l:l===!0?t.setAttribute(a,""):Vt(t,a,l)}}}function Ft(t,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ze("error",t),ze("load",t);var l=!1,f=!1,y;for(y in a)if(a.hasOwnProperty(y)){var w=a[y];if(w!=null)switch(y){case"src":l=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:nt(t,r,y,w,a,null)}}f&&nt(t,r,"srcSet",a.srcSet,a,null),l&&nt(t,r,"src",a.src,a,null);return;case"input":ze("invalid",t);var O=y=w=f=null,R=null,V=null;for(l in a)if(a.hasOwnProperty(l)){var Z=a[l];if(Z!=null)switch(l){case"name":f=Z;break;case"type":w=Z;break;case"checked":R=Z;break;case"defaultChecked":V=Z;break;case"value":y=Z;break;case"defaultValue":O=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(i(137,r));break;default:nt(t,r,l,Z,a,null)}}Jm(t,y,O,R,V,w,f,!1);return;case"select":ze("invalid",t),l=w=y=null;for(f in a)if(a.hasOwnProperty(f)&&(O=a[f],O!=null))switch(f){case"value":y=O;break;case"defaultValue":w=O;break;case"multiple":l=O;default:nt(t,r,f,O,a,null)}r=y,a=w,t.multiple=!!l,r!=null?ci(t,!!l,r,!1):a!=null&&ci(t,!!l,a,!0);return;case"textarea":ze("invalid",t),y=f=l=null;for(w in a)if(a.hasOwnProperty(w)&&(O=a[w],O!=null))switch(w){case"value":l=O;break;case"defaultValue":f=O;break;case"children":y=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(i(91));break;default:nt(t,r,w,O,a,null)}Xm(t,l,f,y);return;case"option":for(R in a)if(a.hasOwnProperty(R)&&(l=a[R],l!=null))switch(R){case"selected":t.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:nt(t,r,R,l,a,null)}return;case"dialog":ze("beforetoggle",t),ze("toggle",t),ze("cancel",t),ze("close",t);break;case"iframe":case"object":ze("load",t);break;case"video":case"audio":for(l=0;l<Ja.length;l++)ze(Ja[l],t);break;case"image":ze("error",t),ze("load",t);break;case"details":ze("toggle",t);break;case"embed":case"source":case"link":ze("error",t),ze("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in a)if(a.hasOwnProperty(V)&&(l=a[V],l!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:nt(t,r,V,l,a,null)}return;default:if(Fu(r)){for(Z in a)a.hasOwnProperty(Z)&&(l=a[Z],l!==void 0&&Ch(t,r,Z,l,a,void 0));return}}for(O in a)a.hasOwnProperty(O)&&(l=a[O],l!=null&&nt(t,r,O,l,a,null))}function Tw(t,r,a,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,y=null,w=null,O=null,R=null,V=null,Z=null;for(X in a){var ie=a[X];if(a.hasOwnProperty(X)&&ie!=null)switch(X){case"checked":break;case"value":break;case"defaultValue":R=ie;default:l.hasOwnProperty(X)||nt(t,r,X,null,l,ie)}}for(var Y in l){var X=l[Y];if(ie=a[Y],l.hasOwnProperty(Y)&&(X!=null||ie!=null))switch(Y){case"type":y=X;break;case"name":f=X;break;case"checked":V=X;break;case"defaultChecked":Z=X;break;case"value":w=X;break;case"defaultValue":O=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(i(137,r));break;default:X!==ie&&nt(t,r,Y,X,l,ie)}}$u(t,w,O,R,V,Z,y,f);return;case"select":X=w=O=Y=null;for(y in a)if(R=a[y],a.hasOwnProperty(y)&&R!=null)switch(y){case"value":break;case"multiple":X=R;default:l.hasOwnProperty(y)||nt(t,r,y,null,l,R)}for(f in l)if(y=l[f],R=a[f],l.hasOwnProperty(f)&&(y!=null||R!=null))switch(f){case"value":Y=y;break;case"defaultValue":O=y;break;case"multiple":w=y;default:y!==R&&nt(t,r,f,y,l,R)}r=O,a=w,l=X,Y!=null?ci(t,!!a,Y,!1):!!l!=!!a&&(r!=null?ci(t,!!a,r,!0):ci(t,!!a,a?[]:"",!1));return;case"textarea":X=Y=null;for(O in a)if(f=a[O],a.hasOwnProperty(O)&&f!=null&&!l.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:nt(t,r,O,null,l,f)}for(w in l)if(f=l[w],y=a[w],l.hasOwnProperty(w)&&(f!=null||y!=null))switch(w){case"value":Y=f;break;case"defaultValue":X=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==y&&nt(t,r,w,f,l,y)}Qm(t,Y,X);return;case"option":for(var ve in a)if(Y=a[ve],a.hasOwnProperty(ve)&&Y!=null&&!l.hasOwnProperty(ve))switch(ve){case"selected":t.selected=!1;break;default:nt(t,r,ve,null,l,Y)}for(R in l)if(Y=l[R],X=a[R],l.hasOwnProperty(R)&&Y!==X&&(Y!=null||X!=null))switch(R){case"selected":t.selected=Y&&typeof Y!="function"&&typeof Y!="symbol";break;default:nt(t,r,R,Y,l,X)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Te in a)Y=a[Te],a.hasOwnProperty(Te)&&Y!=null&&!l.hasOwnProperty(Te)&&nt(t,r,Te,null,l,Y);for(V in l)if(Y=l[V],X=a[V],l.hasOwnProperty(V)&&Y!==X&&(Y!=null||X!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(i(137,r));break;default:nt(t,r,V,Y,l,X)}return;default:if(Fu(r)){for(var rt in a)Y=a[rt],a.hasOwnProperty(rt)&&Y!==void 0&&!l.hasOwnProperty(rt)&&Ch(t,r,rt,void 0,l,Y);for(Z in l)Y=l[Z],X=a[Z],!l.hasOwnProperty(Z)||Y===X||Y===void 0&&X===void 0||Ch(t,r,Z,Y,l,X);return}}for(var I in a)Y=a[I],a.hasOwnProperty(I)&&Y!=null&&!l.hasOwnProperty(I)&&nt(t,r,I,null,l,Y);for(ie in l)Y=l[ie],X=a[ie],!l.hasOwnProperty(ie)||Y===X||Y==null&&X==null||nt(t,r,ie,Y,l,X)}function eg(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Cw(){if(typeof performance.getEntriesByType=="function"){for(var t=0,r=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var f=a[l],y=f.transferSize,w=f.initiatorType,O=f.duration;if(y&&O&&eg(w)){for(w=0,O=f.responseEnd,l+=1;l<a.length;l++){var R=a[l],V=R.startTime;if(V>O)break;var Z=R.transferSize,ie=R.initiatorType;Z&&eg(ie)&&(R=R.responseEnd,w+=Z*(R<O?1:(O-V)/(R-V)))}if(--l,r+=8*(y+w)/(f.duration/1e3),t++,10<t)break}}if(0<t)return r/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Mh=null,Rh=null;function Fl(t){return t.nodeType===9?t:t.ownerDocument}function tg(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ng(t,r){if(t===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&r==="foreignObject"?0:t}function Dh(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Lh=null;function Mw(){var t=window.event;return t&&t.type==="popstate"?t===Lh?!1:(Lh=t,!0):(Lh=null,!1)}var rg=typeof setTimeout=="function"?setTimeout:void 0,Rw=typeof clearTimeout=="function"?clearTimeout:void 0,sg=typeof Promise=="function"?Promise:void 0,Dw=typeof queueMicrotask=="function"?queueMicrotask:typeof sg<"u"?function(t){return sg.resolve(null).then(t).catch(Lw)}:rg;function Lw(t){setTimeout(function(){throw t})}function cs(t){return t==="head"}function ig(t,r){var a=r,l=0;do{var f=a.nextSibling;if(t.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"||a==="/&"){if(l===0){t.removeChild(f),Ii(r);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Xa(t.ownerDocument.documentElement);else if(a==="head"){a=t.ownerDocument.head,Xa(a);for(var y=a.firstChild;y;){var w=y.nextSibling,O=y.nodeName;y[Mt]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&y.rel.toLowerCase()==="stylesheet"||a.removeChild(y),y=w}}else a==="body"&&Xa(t.ownerDocument.body);a=f}while(a);Ii(r)}function ag(t,r){var a=t;t=0;do{var l=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(t===0)break;t--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||t++;a=l}while(a)}function qh(t){var r=t.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":qh(a),li(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}t.removeChild(a)}}function qw(t,r,a,l){for(;t.nodeType===1;){var f=a;if(t.nodeName.toLowerCase()!==r.toLowerCase()){if(!l&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(l){if(!t[Mt])switch(r){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(y=t.getAttribute("rel"),y==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(y!==f.rel||t.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||t.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||t.getAttribute("title")!==(f.title==null?null:f.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(y=t.getAttribute("src"),(y!==(f.src==null?null:f.src)||t.getAttribute("type")!==(f.type==null?null:f.type)||t.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&y&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(r==="input"&&t.type==="hidden"){var y=f.name==null?null:""+f.name;if(f.type==="hidden"&&t.getAttribute("name")===y)return t}else return t;if(t=Bn(t.nextSibling),t===null)break}return null}function Pw(t,r,a){if(r==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!a||(t=Bn(t.nextSibling),t===null))return null;return t}function og(t,r){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Bn(t.nextSibling),t===null))return null;return t}function Ph(t){return t.data==="$?"||t.data==="$~"}function Bh(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Bw(t,r){var a=t.ownerDocument;if(t.data==="$~")t._reactRetry=r;else if(t.data!=="$?"||a.readyState!=="loading")r();else{var l=function(){r(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),t._reactRetry=l}}function Bn(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return t}var Uh=null;function lg(t){t=t.nextSibling;for(var r=0;t;){if(t.nodeType===8){var a=t.data;if(a==="/$"||a==="/&"){if(r===0)return Bn(t.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}t=t.nextSibling}return null}function cg(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var a=t.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return t;r--}else a!=="/$"&&a!=="/&"||r++}t=t.previousSibling}return null}function ug(t,r,a){switch(r=Fl(a),t){case"html":if(t=r.documentElement,!t)throw Error(i(452));return t;case"head":if(t=r.head,!t)throw Error(i(453));return t;case"body":if(t=r.body,!t)throw Error(i(454));return t;default:throw Error(i(451))}}function Xa(t){for(var r=t.attributes;r.length;)t.removeAttributeNode(r[0]);li(t)}var Un=new Map,fg=new Set;function Gl(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Mr=J.d;J.d={f:Uw,r:zw,D:Iw,C:$w,L:Hw,m:Fw,X:Vw,S:Gw,M:Yw};function Uw(){var t=Mr.f(),r=ql();return t||r}function zw(t){var r=N(t);r!==null&&r.tag===5&&r.type==="form"?kp(r):Mr.r(t)}var Bi=typeof document>"u"?null:document;function hg(t,r,a){var l=Bi;if(l&&typeof r=="string"&&r){var f=Cn(r);f='link[rel="'+t+'"][href="'+f+'"]',typeof a=="string"&&(f+='[crossorigin="'+a+'"]'),fg.has(f)||(fg.add(f),t={rel:t,crossOrigin:a,href:r},l.querySelector(f)===null&&(r=l.createElement("link"),Ft(r,"link",t),L(r),l.head.appendChild(r)))}}function Iw(t){Mr.D(t),hg("dns-prefetch",t,null)}function $w(t,r){Mr.C(t,r),hg("preconnect",t,r)}function Hw(t,r,a){Mr.L(t,r,a);var l=Bi;if(l&&t&&r){var f='link[rel="preload"][as="'+Cn(r)+'"]';r==="image"&&a&&a.imageSrcSet?(f+='[imagesrcset="'+Cn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(f+='[imagesizes="'+Cn(a.imageSizes)+'"]')):f+='[href="'+Cn(t)+'"]';var y=f;switch(r){case"style":y=Ui(t);break;case"script":y=zi(t)}Un.has(y)||(t=b({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:t,as:r},a),Un.set(y,t),l.querySelector(f)!==null||r==="style"&&l.querySelector(Wa(y))||r==="script"&&l.querySelector(Za(y))||(r=l.createElement("link"),Ft(r,"link",t),L(r),l.head.appendChild(r)))}}function Fw(t,r){Mr.m(t,r);var a=Bi;if(a&&t){var l=r&&typeof r.as=="string"?r.as:"script",f='link[rel="modulepreload"][as="'+Cn(l)+'"][href="'+Cn(t)+'"]',y=f;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=zi(t)}if(!Un.has(y)&&(t=b({rel:"modulepreload",href:t},r),Un.set(y,t),a.querySelector(f)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Za(y)))return}l=a.createElement("link"),Ft(l,"link",t),L(l),a.head.appendChild(l)}}}function Gw(t,r,a){Mr.S(t,r,a);var l=Bi;if(l&&t){var f=T(l).hoistableStyles,y=Ui(t);r=r||"default";var w=f.get(y);if(!w){var O={loading:0,preload:null};if(w=l.querySelector(Wa(y)))O.loading=5;else{t=b({rel:"stylesheet",href:t,"data-precedence":r},a),(a=Un.get(y))&&zh(t,a);var R=w=l.createElement("link");L(R),Ft(R,"link",t),R._p=new Promise(function(V,Z){R.onload=V,R.onerror=Z}),R.addEventListener("load",function(){O.loading|=1}),R.addEventListener("error",function(){O.loading|=2}),O.loading|=4,Vl(w,r,l)}w={type:"stylesheet",instance:w,count:1,state:O},f.set(y,w)}}}function Vw(t,r){Mr.X(t,r);var a=Bi;if(a&&t){var l=T(a).hoistableScripts,f=zi(t),y=l.get(f);y||(y=a.querySelector(Za(f)),y||(t=b({src:t,async:!0},r),(r=Un.get(f))&&Ih(t,r),y=a.createElement("script"),L(y),Ft(y,"link",t),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},l.set(f,y))}}function Yw(t,r){Mr.M(t,r);var a=Bi;if(a&&t){var l=T(a).hoistableScripts,f=zi(t),y=l.get(f);y||(y=a.querySelector(Za(f)),y||(t=b({src:t,async:!0,type:"module"},r),(r=Un.get(f))&&Ih(t,r),y=a.createElement("script"),L(y),Ft(y,"link",t),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},l.set(f,y))}}function dg(t,r,a,l){var f=(f=Ot.current)?Gl(f):null;if(!f)throw Error(i(446));switch(t){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=Ui(a.href),a=T(f).hoistableStyles,l=a.get(r),l||(l={type:"style",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){t=Ui(a.href);var y=T(f).hoistableStyles,w=y.get(t);if(w||(f=f.ownerDocument||f,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(t,w),(y=f.querySelector(Wa(t)))&&!y._p&&(w.instance=y,w.state.loading=5),Un.has(t)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Un.set(t,a),y||Kw(f,t,a,w.state))),r&&l===null)throw Error(i(528,""));return w}if(r&&l!==null)throw Error(i(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=zi(a),a=T(f).hoistableScripts,l=a.get(r),l||(l={type:"script",instance:null,count:0,state:null},a.set(r,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function Ui(t){return'href="'+Cn(t)+'"'}function Wa(t){return'link[rel="stylesheet"]['+t+"]"}function mg(t){return b({},t,{"data-precedence":t.precedence,precedence:null})}function Kw(t,r,a,l){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?l.loading=1:(r=t.createElement("link"),l.preload=r,r.addEventListener("load",function(){return l.loading|=1}),r.addEventListener("error",function(){return l.loading|=2}),Ft(r,"link",a),L(r),t.head.appendChild(r))}function zi(t){return'[src="'+Cn(t)+'"]'}function Za(t){return"script[async]"+t}function pg(t,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var l=t.querySelector('style[data-href~="'+Cn(a.href)+'"]');if(l)return r.instance=l,L(l),l;var f=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(t.ownerDocument||t).createElement("style"),L(l),Ft(l,"style",f),Vl(l,a.precedence,t),r.instance=l;case"stylesheet":f=Ui(a.href);var y=t.querySelector(Wa(f));if(y)return r.state.loading|=4,r.instance=y,L(y),y;l=mg(a),(f=Un.get(f))&&zh(l,f),y=(t.ownerDocument||t).createElement("link"),L(y);var w=y;return w._p=new Promise(function(O,R){w.onload=O,w.onerror=R}),Ft(y,"link",l),r.state.loading|=4,Vl(y,a.precedence,t),r.instance=y;case"script":return y=zi(a.src),(f=t.querySelector(Za(y)))?(r.instance=f,L(f),f):(l=a,(f=Un.get(y))&&(l=b({},a),Ih(l,f)),t=t.ownerDocument||t,f=t.createElement("script"),L(f),Ft(f,"link",l),t.head.appendChild(f),r.instance=f);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(l=r.instance,r.state.loading|=4,Vl(l,a.precedence,t));return r.instance}function Vl(t,r,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=l.length?l[l.length-1]:null,y=f,w=0;w<l.length;w++){var O=l[w];if(O.dataset.precedence===r)y=O;else if(y!==f)break}y?y.parentNode.insertBefore(t,y.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(t,r.firstChild))}function zh(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.title==null&&(t.title=r.title)}function Ih(t,r){t.crossOrigin==null&&(t.crossOrigin=r.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=r.referrerPolicy),t.integrity==null&&(t.integrity=r.integrity)}var Yl=null;function yg(t,r,a){if(Yl===null){var l=new Map,f=Yl=new Map;f.set(a,l)}else f=Yl,l=f.get(a),l||(l=new Map,f.set(a,l));if(l.has(t))return l;for(l.set(t,null),a=a.getElementsByTagName(t),f=0;f<a.length;f++){var y=a[f];if(!(y[Mt]||y[st]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var w=y.getAttribute(r)||"";w=t+w;var O=l.get(w);O?O.push(y):l.set(w,[y])}}return l}function gg(t,r,a){t=t.ownerDocument||t,t.head.insertBefore(a,r==="title"?t.querySelector("head > title"):null)}function Jw(t,r,a){if(a===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function bg(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Qw(t,r,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var f=Ui(l.href),y=r.querySelector(Wa(f));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=Kl.bind(t),r.then(t,t)),a.state.loading|=4,a.instance=y,L(y);return}y=r.ownerDocument||r,l=mg(l),(f=Un.get(f))&&zh(l,f),y=y.createElement("link"),L(y);var w=y;w._p=new Promise(function(O,R){w.onload=O,w.onerror=R}),Ft(y,"link",l),a.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(t.count++,a=Kl.bind(t),r.addEventListener("load",a),r.addEventListener("error",a))}}var $h=0;function Xw(t,r){return t.stylesheets&&t.count===0&&Ql(t,t.stylesheets),0<t.count||0<t.imgCount?function(a){var l=setTimeout(function(){if(t.stylesheets&&Ql(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+r);0<t.imgBytes&&$h===0&&($h=62500*Cw());var f=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Ql(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>$h?50:800)+r);return t.unsuspend=a,function(){t.unsuspend=null,clearTimeout(l),clearTimeout(f)}}:null}function Kl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ql(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Jl=null;function Ql(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Jl=new Map,r.forEach(Ww,t),Jl=null,Kl.call(t))}function Ww(t,r){if(!(r.state.loading&4)){var a=Jl.get(t);if(a)var l=a.get(null);else{a=new Map,Jl.set(t,a);for(var f=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<f.length;y++){var w=f[y];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(a.set(w.dataset.precedence,w),l=w)}l&&a.set(null,l)}f=r.instance,w=f.getAttribute("data-precedence"),y=a.get(w)||l,y===l&&a.set(null,f),a.set(w,f),this.count++,l=Kl.bind(this),f.addEventListener("load",l),f.addEventListener("error",l),y?y.parentNode.insertBefore(f,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(f,t.firstChild)),r.state.loading|=4}}var eo={$$typeof:ne,Provider:null,Consumer:null,_currentValue:ce,_currentValue2:ce,_threadCount:0};function Zw(t,r,a,l,f,y,w,O,R){this.tag=1,this.containerInfo=t,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=$r(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$r(0),this.hiddenUpdates=$r(null),this.identifierPrefix=l,this.onUncaughtError=f,this.onCaughtError=y,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=R,this.incompleteTransitions=new Map}function xg(t,r,a,l,f,y,w,O,R,V,Z,ie){return t=new Zw(t,r,a,w,R,V,Z,ie,O),r=1,y===!0&&(r|=24),y=mn(3,null,null,r),t.current=y,y.stateNode=t,r=_f(),r.refCount++,t.pooledCache=r,r.refCount++,y.memoizedState={element:l,isDehydrated:a,cache:r},Of(y),t}function vg(t){return t?(t=gi,t):gi}function _g(t,r,a,l,f,y){f=vg(f),l.context===null?l.context=f:l.pendingContext=f,l=Wr(r),l.payload={element:a},y=y===void 0?null:y,y!==null&&(l.callback=y),a=Zr(t,l,r),a!==null&&(cn(a,t,r),Ma(a,t,r))}function wg(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var a=t.retryLane;t.retryLane=a!==0&&a<r?a:r}}function Hh(t,r){wg(t,r),(t=t.alternate)&&wg(t,r)}function Sg(t){if(t.tag===13||t.tag===31){var r=Bs(t,67108864);r!==null&&cn(r,t,67108864),Hh(t,67108864)}}function Eg(t){if(t.tag===13||t.tag===31){var r=xn();r=mr(r);var a=Bs(t,r);a!==null&&cn(a,t,r),Hh(t,r)}}var Xl=!0;function eS(t,r,a,l){var f=H.T;H.T=null;var y=J.p;try{J.p=2,Fh(t,r,a,l)}finally{J.p=y,H.T=f}}function tS(t,r,a,l){var f=H.T;H.T=null;var y=J.p;try{J.p=8,Fh(t,r,a,l)}finally{J.p=y,H.T=f}}function Fh(t,r,a,l){if(Xl){var f=Gh(l);if(f===null)Th(t,r,l,Wl,a),Ag(t,l);else if(rS(f,t,r,a,l))l.stopPropagation();else if(Ag(t,l),r&4&&-1<nS.indexOf(t)){for(;f!==null;){var y=N(f);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var w=Fn(y.pendingLanes);if(w!==0){var O=y;for(O.pendingLanes|=2,O.entangledLanes|=2;w;){var R=1<<31-Gt(w);O.entanglements[1]|=R,w&=~R}ir(y),(Qe&6)===0&&(Dl=ut()+500,Ka(0))}}break;case 31:case 13:O=Bs(y,2),O!==null&&cn(O,y,2),ql(),Hh(y,2)}if(y=Gh(l),y===null&&Th(t,r,l,Wl,a),y===f)break;f=y}f!==null&&l.stopPropagation()}else Th(t,r,l,null,a)}}function Gh(t){return t=Vu(t),Vh(t)}var Wl=null;function Vh(t){if(Wl=null,t=A(t),t!==null){var r=c(t);if(r===null)t=null;else{var a=r.tag;if(a===13){if(t=m(r),t!==null)return t;t=null}else if(a===31){if(t=p(r),t!==null)return t;t=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null)}}return Wl=t,null}function Og(t){switch(t){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(Bu()){case Io:return 2;case $o:return 8;case ii:case Uu:return 32;case Ho:return 268435456;default:return 32}default:return 32}}var Yh=!1,us=null,fs=null,hs=null,to=new Map,no=new Map,ds=[],nS="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 Ag(t,r){switch(t){case"focusin":case"focusout":us=null;break;case"dragenter":case"dragleave":fs=null;break;case"mouseover":case"mouseout":hs=null;break;case"pointerover":case"pointerout":to.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":no.delete(r.pointerId)}}function ro(t,r,a,l,f,y){return t===null||t.nativeEvent!==y?(t={blockedOn:r,domEventName:a,eventSystemFlags:l,nativeEvent:y,targetContainers:[f]},r!==null&&(r=N(r),r!==null&&Sg(r)),t):(t.eventSystemFlags|=l,r=t.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),t)}function rS(t,r,a,l,f){switch(r){case"focusin":return us=ro(us,t,r,a,l,f),!0;case"dragenter":return fs=ro(fs,t,r,a,l,f),!0;case"mouseover":return hs=ro(hs,t,r,a,l,f),!0;case"pointerover":var y=f.pointerId;return to.set(y,ro(to.get(y)||null,t,r,a,l,f)),!0;case"gotpointercapture":return y=f.pointerId,no.set(y,ro(no.get(y)||null,t,r,a,l,f)),!0}return!1}function jg(t){var r=A(t.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=m(a),r!==null){t.blockedOn=r,Go(t.priority,function(){Eg(a)});return}}else if(r===31){if(r=p(a),r!==null){t.blockedOn=r,Go(t.priority,function(){Eg(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){t.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Zl(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var a=Gh(t.nativeEvent);if(a===null){a=t.nativeEvent;var l=new a.constructor(a.type,a);Gu=l,a.target.dispatchEvent(l),Gu=null}else return r=N(a),r!==null&&Sg(r),t.blockedOn=a,!1;r.shift()}return!0}function kg(t,r,a){Zl(t)&&a.delete(r)}function sS(){Yh=!1,us!==null&&Zl(us)&&(us=null),fs!==null&&Zl(fs)&&(fs=null),hs!==null&&Zl(hs)&&(hs=null),to.forEach(kg),no.forEach(kg)}function ec(t,r){t.blockedOn===r&&(t.blockedOn=null,Yh||(Yh=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,sS)))}var tc=null;function Ng(t){tc!==t&&(tc=t,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){tc===t&&(tc=null);for(var r=0;r<t.length;r+=3){var a=t[r],l=t[r+1],f=t[r+2];if(typeof l!="function"){if(Vh(l||a)===null)continue;break}var y=N(a);y!==null&&(t.splice(r,3),r-=3,Gf(y,{pending:!0,data:f,method:a.method,action:l},l,f))}}))}function Ii(t){function r(R){return ec(R,t)}us!==null&&ec(us,t),fs!==null&&ec(fs,t),hs!==null&&ec(hs,t),to.forEach(r),no.forEach(r);for(var a=0;a<ds.length;a++){var l=ds[a];l.blockedOn===t&&(l.blockedOn=null)}for(;0<ds.length&&(a=ds[0],a.blockedOn===null);)jg(a),a.blockedOn===null&&ds.shift();if(a=(t.ownerDocument||t).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var f=a[l],y=a[l+1],w=f[gt]||null;if(typeof y=="function")w||Ng(a);else if(w){var O=null;if(y&&y.hasAttribute("formAction")){if(f=y,w=y[gt]||null)O=w.formAction;else if(Vh(f)!==null)continue}else O=w.action;typeof O=="function"?a[l+1]=O:(a.splice(l,3),l-=3),Ng(a)}}}function Tg(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(w){return f=w})},focusReset:"manual",scroll:"manual"})}function r(){f!==null&&(f(),f=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,f=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),f!==null&&(f(),f=null)}}}function Kh(t){this._internalRoot=t}nc.prototype.render=Kh.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(i(409));var a=r.current,l=xn();_g(a,l,t,r,null,null)},nc.prototype.unmount=Kh.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;_g(t.current,2,null,t,null,null),ql(),r[hn]=null}};function nc(t){this._internalRoot=t}nc.prototype.unstable_scheduleHydration=function(t){if(t){var r=pa();t={blockedOn:null,target:t,priority:r};for(var a=0;a<ds.length&&r!==0&&r<ds[a].priority;a++);ds.splice(a,0,t),a===0&&jg(t)}};var Cg=e.version;if(Cg!=="19.2.4")throw Error(i(527,Cg,"19.2.4"));J.findDOMNode=function(t){var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(i(188)):(t=Object.keys(t).join(","),Error(i(268,t)));return t=u(r),t=t!==null?d(t):null,t=t===null?null:t.stateNode,t};var iS={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var rc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rc.isDisabled&&rc.supportsFiber)try{Ns=rc.inject(iS),_t=rc}catch{}}return so.createRoot=function(t,r){if(!o(t))throw Error(i(299));var a=!1,l="",f=Bp,y=Up,w=zp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(l=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(w=r.onRecoverableError)),r=xg(t,1,!1,null,null,a,l,null,f,y,w,Tg),t[hn]=r.current,Nh(t),new Kh(r)},so.hydrateRoot=function(t,r,a){if(!o(t))throw Error(i(299));var l=!1,f="",y=Bp,w=Up,O=zp,R=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(f=a.identifierPrefix),a.onUncaughtError!==void 0&&(y=a.onUncaughtError),a.onCaughtError!==void 0&&(w=a.onCaughtError),a.onRecoverableError!==void 0&&(O=a.onRecoverableError),a.formState!==void 0&&(R=a.formState)),r=xg(t,1,!0,r,a??null,l,f,R,y,w,O,Tg),r.context=vg(null),a=r.current,l=xn(),l=mr(l),f=Wr(l),f.callback=null,Zr(a,f,l),a=l,r.current.lanes=a,Gn(r,a),ir(r),t[hn]=r.current,Nh(t),new nc(r)},so.version="19.2.4",so}var Bg;function XS(){if(Bg)return Jh.exports;Bg=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Jh.exports=QS(),Jh.exports}var WS=XS();const ZS="modulepreload",eE=function(n,e){return new URL(n,e).href},Ug={},Oe=function(e,s,i){let o=Promise.resolve();if(s&&s.length>0){let m=function(d){return Promise.all(d.map(b=>Promise.resolve(b).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};const p=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),u=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));o=m(s.map(d=>{if(d=eE(d,i),d in Ug)return;Ug[d]=!0;const b=d.endsWith(".css"),x=b?'[rel="stylesheet"]':"";if(!!i)for(let S=p.length-1;S>=0;S--){const C=p[S];if(C.href===d&&(!b||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${x}`))return;const _=document.createElement("link");if(_.rel=b?"stylesheet":ZS,b||(_.as="script"),_.crossOrigin="",_.href=d,u&&_.setAttribute("nonce",u),document.head.appendChild(_),b)return new Promise((S,C)=>{_.addEventListener("load",S),_.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${d}`)))})}))}function c(m){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=m,window.dispatchEvent(p),!p.defaultPrevented)throw m}return o.then(m=>{for(const p of m||[])p.status==="rejected"&&c(p.reason);return e().catch(c)})};function Eu(n){try{const e=n.split(".");if(e.length!==3)return null;const s=atob(e[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(s)}catch{return null}}function yx(n){const e=Eu(n);return!e||typeof e.exp!="number"?null:e.exp}function om(n,e=0){const s=yx(n);return s===null?!0:Date.now()/1e3>=s-e}const Yt=window.__LT_BASE__??"",_d=`${Yt}/api`;class zg extends Error{constructor(e,s,i){super(e),this.status=s,this.body=i,this.name="ApiError"}}let bs=null;function sc(n){bs=n}function wd(){return bs}const tE="X-LT-Acting-Token",nE="X-LT-Acting-Remaining";let eu=null,tu=null;function Ig(n){eu=n}let nu=null;function $g(n){nu=n}function Hg(n){tu=n}function rE(n){const e=n==null?void 0:n.error;return typeof e=="string"&&/acting[- ]identity/i.test(e)}async function Fg(){const n=sessionStorage.getItem("lt_credentials");if(!n)return null;try{const{username:e,password:s}=JSON.parse(n),i=await fetch(`${_d}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:s})});if(!i.ok)return null;const o=await i.json();return o.token&&o.user&&sessionStorage.setItem("lt_user_info",JSON.stringify({displayName:o.user.display_name,username:o.user.external_id})),o.token??null}catch{return null}}let ps=null;async function ue(n,e={}){const s={"Content-Type":"application/json",...e.headers};if(bs){if(om(bs)){ps||(ps=Fg().finally(()=>{ps=null}));const p=await ps;if(p)bs=p,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:p}}));else throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}s.Authorization=`Bearer ${bs}`}const o=(e.method??"GET").toUpperCase()==="GET"?null:(eu==null?void 0:eu())??null;o&&(s[tE]=o);let c=await fetch(`${_d}${n}`,{...e,headers:s});const m=o?c.headers.get(nE):null;if(o&&m!==null&&(nu==null||nu(o,m==="unbounded"?null:Number(m))),c.status===401&&o){const p=await c.clone().json().catch(()=>null);if(rE(p))throw tu==null||tu(),new zg(p.error,401,p)}if(c.status===401&&bs){ps||(ps=Fg().finally(()=>{ps=null}));const p=await ps;if(p&&(bs=p,window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:p}})),s.Authorization=`Bearer ${p}`,c=await fetch(`${_d}${n}`,{...e,headers:s})),c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired")}else if(c.status===401)throw window.dispatchEvent(new CustomEvent("auth:unauthorized")),new Error("Session expired");if(!c.ok){const p=await c.json().catch(()=>({error:c.statusText}));throw new zg(p.message||p.error||c.statusText,c.status,p)}return c.json()}const sE="lt_ai_override";let ic=null;function lm(){return ic||(ic=fetch(`${Yt}/api/settings`).then(n=>{if(!n.ok)throw new Error(`settings ${n.status}`);return n.json()}).catch(n=>{throw ic=null,n})),ic}function iE(){try{if(localStorage.getItem(sE)==="off")return!1}catch{}return null}function Hn(){var s;const n=Le({queryKey:["settings"],queryFn:lm,staleTime:1/0}),e=iE();return n.data&&e===!1&&((s=n.data.ai)!=null&&s.enabled)?{...n,data:{...n.data,ai:{enabled:!1}}}:n}function aE(n){var u,d,b;const{data:e}=Hn(),s=((u=e==null?void 0:e.auth)==null?void 0:u.ssoKeepaliveSeconds)??0,i=((d=e==null?void 0:e.auth)==null?void 0:d.ssoKeepaliveIdleTimeoutSeconds)??0,o=E.useRef(Date.now()),c=E.useRef(Date.now()),m=E.useRef(!1),g=!!n&&((b=Eu(n))==null?void 0:b.sso)===!0&&s>0;E.useEffect(()=>{if(!g)return;const x=()=>{o.current=Date.now()};window.addEventListener("pointerdown",x,{passive:!0}),window.addEventListener("keydown",x,{passive:!0}),window.addEventListener("wheel",x,{passive:!0});const v=async()=>{if(!m.current&&document.visibilityState==="visible"&&!(i>0&&Date.now()-o.current>i*1e3)){m.current=!0;try{const C=await fetch(`${Yt}/api/auth/sso`,{method:"POST"});if(C.status===401||C.status===403){window.dispatchEvent(new CustomEvent("auth:unauthorized"));return}if(!C.ok)return;const B=await C.json().catch(()=>null);B!=null&&B.token&&(c.current=Date.now(),window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:B.token}})))}catch{}finally{m.current=!1}}},_=setInterval(v,s*1e3),S=()=>{document.visibilityState==="visible"&&Date.now()-c.current>s*1e3&&v()};return document.addEventListener("visibilitychange",S),()=>{clearInterval(_),document.removeEventListener("visibilitychange",S),window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",x),window.removeEventListener("wheel",x)}},[g,s,i])}const gx=E.createContext(null),oE=300;function Wh(n,e){if(om(n))return null;const s=Eu(n);if(!s)return null;const i=e??(()=>{try{const o=sessionStorage.getItem("lt_user_info");return o?JSON.parse(o):null}catch{return null}})();return{userId:s.userId,displayName:(i==null?void 0:i.displayName)??null,username:(i==null?void 0:i.username)??null,roles:s.roles??[]}}function lE({children:n}){const[e,s]=E.useState(()=>{const b=sessionStorage.getItem("lt_token");return b?om(b)?(sessionStorage.removeItem("lt_token"),null):(sc(b),Wh(b)):null}),i=E.useRef(void 0),o=E.useCallback(b=>{clearTimeout(i.current);const x=yx(b);if(!x)return;const v=(x-oE)*1e3-Date.now();v<=0||(i.current=setTimeout(async()=>{try{const _=Eu(b);if(_!=null&&_.sso){const te=await fetch(`${Yt}/api/auth/sso`,{method:"POST"});if(!te.ok)return;const M=await te.json();M.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:M.token}}));return}const S=sessionStorage.getItem("lt_credentials");if(!S)return;const{username:C,password:B}=JSON.parse(S),q=await fetch(`${Yt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:B})});if(!q.ok)return;const ne=await q.json();ne.token&&window.dispatchEvent(new CustomEvent("auth:refreshed",{detail:{token:ne.token}}))}catch{}},v))},[]),c=E.useCallback((b,x,v)=>{const _={displayName:(v==null?void 0:v.displayName)??null,username:(v==null?void 0:v.username)??(x==null?void 0:x.username)??null},S=Wh(b,_);S&&(sc(b),sessionStorage.setItem("lt_token",b),sessionStorage.setItem("lt_user_info",JSON.stringify(_)),x&&sessionStorage.setItem("lt_credentials",JSON.stringify(x)),s(S),o(b))},[o]),m=E.useCallback(()=>{clearTimeout(i.current);const b=sessionStorage.getItem("lt_sso_logout_url");sc(null),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info"),sessionStorage.removeItem("lt_sso_logout_url"),s(null),b&&(window.location.href=b)},[]);E.useEffect(()=>{const b=()=>m(),x=v=>{var C;const _=(C=v.detail)==null?void 0:C.token;if(!_)return;const S=Wh(_);S&&(sc(_),sessionStorage.setItem("lt_token",_),s(S),o(_))};return window.addEventListener("auth:unauthorized",b),window.addEventListener("auth:refreshed",x),()=>{window.removeEventListener("auth:unauthorized",b),window.removeEventListener("auth:refreshed",x)}},[m,o]),E.useEffect(()=>{const b=sessionStorage.getItem("lt_token");return b&&e&&o(b),()=>clearTimeout(i.current)},[]);const p=(e==null?void 0:e.roles.some(b=>b.type==="superadmin"))??!1,g=E.useCallback(b=>(e==null?void 0:e.roles.some(x=>x.role===b))??!1,[e]),u=E.useCallback(b=>(e==null?void 0:e.roles.some(x=>x.type===b))??!1,[e]),d=(e==null?void 0:e.roles.map(b=>b.role))??[];return h.jsxs(gx.Provider,{value:{user:e,isAuthenticated:!!e,isSuperAdmin:p,login:c,logout:m,hasRole:g,hasRoleType:u,userRoleNames:d},children:[h.jsx(cE,{authenticated:e!==null}),n]})}function cE({authenticated:n}){return aE(n?sessionStorage.getItem("lt_token"):null),null}function Lt(){const n=E.useContext(gx);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}async function uE(n){if(!wd())return{kind:"session-ended"};try{const e=await ue("/nats-credentials"),s=e.natsWsUrl??n;return s?{kind:"ok",url:s,token:e.natsToken??null}:{kind:"unavailable"}}catch{return wd()?{kind:"unavailable"}:{kind:"session-ended"}}}const go={initialDelayMs:1e3,maxDelayMs:6e4,noticeAfterMs:3e4,spreadMs:5e3};function fE(n,e,s=Math.random){const i=Math.min(e.maxDelayMs,e.initialDelayMs*2**Math.max(0,n));return Math.round(i/2+s()*(i/2))}function Gg(n,e=Math.random){return Math.round(e()*n.spreadMs)}function Vg(n){const e=(s,i)=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:i;return{initialDelayMs:e(n==null?void 0:n.initialDelayMs,go.initialDelayMs),maxDelayMs:e(n==null?void 0:n.maxDelayMs,go.maxDelayMs),noticeAfterMs:e(n==null?void 0:n.noticeAfterMs,go.noticeAfterMs),spreadMs:e(n==null?void 0:n.spreadMs,go.spreadMs)}}const jn=new Uint8Array(0),ri=new TextEncoder,En=new TextDecoder;function hE(...n){let e=0;for(let o=0;o<n.length;o++)e+=n[o].length;const s=new Uint8Array(e);let i=0;for(let o=0;o<n.length;o++)s.set(n[o],i),i+=n[o].length;return s}function _o(...n){const e=[];for(let s=0;s<n.length;s++)e.push(ri.encode(n[s]));return e.length===0?jn:e.length===1?e[0]:hE(...e)}function Yg(n){return!n||n.length===0?"":En.decode(n)}const Kg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",Jg=36,dE=0xcfd41b9100000,Qg=33,mE=333,Xg=22;function pE(n){for(let e=0;e<n.length;e++)n[e]=Math.floor(Math.random()*255)}function yE(n){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(n):pE(n)}class gE{constructor(){j(this,"buf");j(this,"seq");j(this,"inc");j(this,"inited");this.buf=new Uint8Array(Xg),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*dE),this.inc=Math.floor(Math.random()*(mE-Qg)+Qg)}setPre(){const e=new Uint8Array(12);yE(e);for(let s=0;s<12;s++){const i=e[s]%36;this.buf[s]=Kg.charCodeAt(i)}}fillSeq(){let e=this.seq;for(let s=Xg-1;s>=12;s--)this.buf[s]=Kg.charCodeAt(e%Jg),e=Math.floor(e/Jg)}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 As=new gE;var Dr;(function(n){n.Disconnect="disconnect",n.Reconnect="reconnect",n.Update="update",n.LDM="ldm",n.Error="error"})(Dr||(Dr={}));var Qi;(function(n){n.Reconnecting="reconnecting",n.PingTimer="pingTimer",n.StaleConnection="staleConnection",n.ClientInitiatedReconnect="client initiated reconnect"})(Qi||(Qi={}));var fe;(function(n){n.ApiError="BAD API",n.BadAuthentication="BAD_AUTHENTICATION",n.BadCreds="BAD_CREDS",n.BadHeader="BAD_HEADER",n.BadJson="BAD_JSON",n.BadPayload="BAD_PAYLOAD",n.BadSubject="BAD_SUBJECT",n.Cancelled="CANCELLED",n.ConnectionClosed="CONNECTION_CLOSED",n.ConnectionDraining="CONNECTION_DRAINING",n.ConnectionRefused="CONNECTION_REFUSED",n.ConnectionTimeout="CONNECTION_TIMEOUT",n.Disconnect="DISCONNECT",n.InvalidOption="INVALID_OPTION",n.InvalidPayload="INVALID_PAYLOAD",n.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",n.NoResponders="503",n.NotFunction="NOT_FUNC",n.RequestError="REQUEST_ERROR",n.ServerOptionNotAvailable="SERVER_OPT_NA",n.SubClosed="SUB_CLOSED",n.SubDraining="SUB_DRAINING",n.Timeout="TIMEOUT",n.Tls="TLS",n.Unknown="UNKNOWN_ERROR",n.WssRequired="WSS_REQUIRED",n.JetStreamInvalidAck="JESTREAM_INVALID_ACK",n.JetStream404NoMessages="404",n.JetStream408RequestTimeout="408",n.JetStream409MaxAckPendingExceeded="409",n.JetStream409="409",n.JetStreamNotEnabled="503",n.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",n.AuthorizationViolation="AUTHORIZATION_VIOLATION",n.AuthenticationExpired="AUTHENTICATION_EXPIRED",n.ProtocolError="NATS_PROTOCOL_ERR",n.PermissionsViolation="PERMISSIONS_VIOLATION",n.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",n.AccountExpired="ACCOUNT_EXPIRED"})(fe||(fe={}));function bE(n){return typeof n.code=="string"}class bx{constructor(){j(this,"messages");this.messages=new Map,this.messages.set(fe.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(fe.BadJson,"Bad JSON"),this.messages.set(fe.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(e){return xE.getMessage(e)}getMessage(e){return this.messages.get(e)||e}}const xE=new bx;class be extends Error{constructor(s,i,o){super(s);j(this,"name");j(this,"message");j(this,"code");j(this,"permissionContext");j(this,"chainedError");j(this,"api_error");this.name="NatsError",this.message=s,this.code=i,this.chainedError=o}static errorForCode(s,i){const o=bx.getMessage(s);return new be(o,s,i)}isAuthError(){return this.code===fe.AuthenticationExpired||this.code===fe.AuthorizationViolation||this.code===fe.AccountExpired}isAuthTimeout(){return this.code===fe.AuthenticationTimeout}isPermissionError(){return this.code===fe.PermissionsViolation}isProtocolError(){return this.code===fe.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var wn;(function(n){n[n.Exact=0]="Exact",n[n.CanonicalMIME=1]="CanonicalMIME",n[n.IgnoreCase=2]="IgnoreCase"})(wn||(wn={}));var Zn;(function(n){n.Timer="timer",n.Count="count",n.JitterTimer="jitterTimer",n.SentinelMsg="sentinelMsg"})(Zn||(Zn={}));var wo;(function(n){n.STATS="io.nats.micro.v1.stats_response",n.INFO="io.nats.micro.v1.info_response",n.PING="io.nats.micro.v1.ping_response"})(wo||(wo={}));const uu="Nats-Service-Error",fu="Nats-Service-Error-Code";class hu extends Error{constructor(s,i){super(i);j(this,"code");this.code=s}static isServiceError(s){return hu.toServiceError(s)!==null}static toServiceError(s){var o,c;const i=((o=s==null?void 0:s.headers)==null?void 0:o.get(fu))||"";if(i!==""){const m=parseInt(i)||400,p=((c=s==null?void 0:s.headers)==null?void 0:c.get(uu))||"";return new hu(m,p.length?p:i)}return null}}function Lr(n=""){if(n=n||"_INBOX",typeof n!="string")throw new Error("prefix must be a string");return n.split(".").forEach(e=>{if(e==="*"||e===">")throw new Error(`inbox prefixes cannot have wildcards '${n}'`)}),`${n}.${As.next()}`}const Sd="127.0.0.1";var _s;(function(n){n.PING="PING",n.STATS="STATS",n.INFO="INFO"})(_s||(_s={}));function Ou(n,...e){for(let s=0;s<e.length;s++){const i=e[s];Object.keys(i).forEach(function(o){n[o]=i[o]})}return n}function ac(n){return En.decode(n).replace(/\n/g,"␊").replace(/\r/g,"␍")}function sa(n,e=!0){const s=e?be.errorForCode(fe.Timeout):null;let i,o;const c=new Promise((m,p)=>{i={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{p(s===null?be.errorForCode(fe.Timeout):s)},n)});return Object.assign(c,i)}function oa(n=0){let e;const s=new Promise(i=>{const o=setTimeout(()=>{i()},n);e={cancel:()=>{o&&clearTimeout(o)}}});return Object.assign(s,e)}function dt(){let n={};const e=new Promise((s,i)=>{n={resolve:s,reject:i}});return Object.assign(e,n)}function xx(n){for(let e=n.length-1;e>0;e--){const s=Math.floor(Math.random()*(e+1));[n[e],n[s]]=[n[s],n[e]]}return n}function vE(n){return n===0?0:Math.floor(n/2+Math.random()*n)}function cm(n=[0,250,250,500,500,3e3,5e3]){Array.isArray(n)||(n=[0,250,250,500,500,3e3,5e3]);const e=n.length-1;return{backoff(s){return vE(s>e?n[e]:n[s])}}}function ht(n){return n*1e6}function um(n){return Math.floor(n/1e6)}function Wg(n){let i=!0;const o=new Array(n.length);for(let c=0;c<n.length;c++){let m=n.charCodeAt(c);if(m===58||m<33||m>126)throw new be(`'${n[c]}' is not a valid character for a header key`,fe.BadHeader);i&&97<=m&&m<=122?m-=32:!i&&65<=m&&m<=90&&(m+=32),o[c]=m,i=m==45}return String.fromCharCode(...o)}function Pr(n=0,e=""){if(n===0&&e!==""||n>0&&e==="")throw new Error("setting status requires both code and description");return new ws(n,e)}const Zh="NATS/1.0";class ws{constructor(e=0,s=""){j(this,"_code");j(this,"headers");j(this,"_description");this._code=e,this._description=s,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[s,i]of this.headers){const o=e.values(s);if(i.length!==o.length)return!1;const c=[...i].sort(),m=[...o].sort();for(let p=0;p<c.length;p++)if(c[p]!==m[p])return!1}return!0}return!1}static decode(e){const s=new ws,o=En.decode(e).split(`\r
27
27
  `),c=o[0];if(c!==Zh){let m=c.replace(Zh,"").trim();if(m.length>0){s._code=parseInt(m,10),isNaN(s._code)&&(s._code=0);const p=s._code.toString();m=m.replace(p,""),s._description=m.trim()}}return o.length>=1&&o.slice(1).map(m=>{if(m){const p=m.indexOf(":");if(p>-1){const g=m.slice(0,p),u=m.slice(p+1).trim();s.append(g,u)}}}),s}toString(){if(this.headers.size===0&&this._code===0)return"";let e=Zh;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[s,i]of this.headers)for(let o=0;o<i.length;o++)e=`${e}\r
28
28
  ${s}: ${i[o]}`;return`${e}\r
29
29
  \r
30
- `}encode(){return ri.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw new ge("invalid header value - \\r and \\n are not allowed.",fe.BadHeader);return e.trim()}keys(){const e=[];for(const s of this.headers.keys())e.push(s);return e}findKeys(e,s=wn.Exact){const i=this.keys();switch(s){case wn.Exact:return i.filter(o=>o===e);case wn.CanonicalMIME:return e=Wg(e),i.filter(o=>o===e);default:{const o=e.toLowerCase();return i.filter(c=>o===c.toLowerCase())}}}get(e,s=wn.Exact){const i=this.findKeys(e,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(e,s=wn.Exact){const i=this.findKeys(e,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(e,s=wn.Exact){return this.findKeys(e,s).length>0}set(e,s,i=wn.Exact){this.delete(e,i),this.append(e,s,i)}append(e,s,i=wn.Exact){const o=Wg(e);i===wn.CanonicalMIME&&(e=o);const c=this.findKeys(e,i);e=c.length>0?c[0]:e;const m=ws.validHeaderValue(s);let p=this.headers.get(e);p||(p=[],this.headers.set(e,p)),p.push(m)}values(e,s=wn.Exact){const i=[];return this.findKeys(e,s).forEach(c=>{const m=this.headers.get(c);m&&i.push(...m)}),i}delete(e,s=wn.Exact){this.findKeys(e,s).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const e={};return this.keys().forEach(s=>{e[s]=this.values(s)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(e){const s=new ws;for(const i in e)s.headers.set(i,e[i]);return s}}function Ed(){return{encode(n){return ri.encode(n)},decode(n){return En.decode(n)}}}function er(n){return{encode(e){try{return e===void 0&&(e=null),ri.encode(JSON.stringify(e))}catch(s){throw ge.errorForCode(fe.BadJson,s)}},decode(e){try{return JSON.parse(En.decode(e),n)}catch(s){throw ge.errorForCode(fe.BadJson,s)}}}}function vx(n){var e;return n&&n.data.length===0&&((e=n.headers)==null?void 0:e.code)===503?ge.errorForCode(fe.NoResponders):null}class fm{constructor(e,s,i){j(this,"_headers");j(this,"_msg");j(this,"_rdata");j(this,"_reply");j(this,"_subject");j(this,"publisher");this._msg=e,this._rdata=s,this.publisher=i}get subject(){return this._subject?this._subject:(this._subject=En.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=En.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const e=this._rdata.subarray(0,this._msg.hdr);this._headers=ws.decode(e)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(e=jn,s){return this.reply?(this.publisher.publish(this.reply,e,s),!0):!1}size(){var o;const e=this._msg.subject.length,s=((o=this._msg.reply)==null?void 0:o.length)||0,i=this._msg.size===-1?0:this._msg.size;return e+s+i}json(e){return er(e).decode(this.data)}string(){return En.decode(this.data)}requestInfo(){var s;const e=(s=this.headers)==null?void 0:s.get("Nats-Request-Info");return e?JSON.parse(e,function(i,o){return(i==="start"||i==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}j(fm,"jc");function Xi(n){return Au("durable",n)}function Jt(n){return Au("stream",n)}function Au(n,e=""){if(e==="")throw Error(`${n} name required`);return[".","*",">","/","\\"," "," ",`
30
+ `}encode(){return ri.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw new be("invalid header value - \\r and \\n are not allowed.",fe.BadHeader);return e.trim()}keys(){const e=[];for(const s of this.headers.keys())e.push(s);return e}findKeys(e,s=wn.Exact){const i=this.keys();switch(s){case wn.Exact:return i.filter(o=>o===e);case wn.CanonicalMIME:return e=Wg(e),i.filter(o=>o===e);default:{const o=e.toLowerCase();return i.filter(c=>o===c.toLowerCase())}}}get(e,s=wn.Exact){const i=this.findKeys(e,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(e,s=wn.Exact){const i=this.findKeys(e,s);if(i.length){const o=this.headers.get(i[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(e,s=wn.Exact){return this.findKeys(e,s).length>0}set(e,s,i=wn.Exact){this.delete(e,i),this.append(e,s,i)}append(e,s,i=wn.Exact){const o=Wg(e);i===wn.CanonicalMIME&&(e=o);const c=this.findKeys(e,i);e=c.length>0?c[0]:e;const m=ws.validHeaderValue(s);let p=this.headers.get(e);p||(p=[],this.headers.set(e,p)),p.push(m)}values(e,s=wn.Exact){const i=[];return this.findKeys(e,s).forEach(c=>{const m=this.headers.get(c);m&&i.push(...m)}),i}delete(e,s=wn.Exact){this.findKeys(e,s).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const e={};return this.keys().forEach(s=>{e[s]=this.values(s)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(e){const s=new ws;for(const i in e)s.headers.set(i,e[i]);return s}}function Ed(){return{encode(n){return ri.encode(n)},decode(n){return En.decode(n)}}}function er(n){return{encode(e){try{return e===void 0&&(e=null),ri.encode(JSON.stringify(e))}catch(s){throw be.errorForCode(fe.BadJson,s)}},decode(e){try{return JSON.parse(En.decode(e),n)}catch(s){throw be.errorForCode(fe.BadJson,s)}}}}function vx(n){var e;return n&&n.data.length===0&&((e=n.headers)==null?void 0:e.code)===503?be.errorForCode(fe.NoResponders):null}class fm{constructor(e,s,i){j(this,"_headers");j(this,"_msg");j(this,"_rdata");j(this,"_reply");j(this,"_subject");j(this,"publisher");this._msg=e,this._rdata=s,this.publisher=i}get subject(){return this._subject?this._subject:(this._subject=En.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=En.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const e=this._rdata.subarray(0,this._msg.hdr);this._headers=ws.decode(e)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(e=jn,s){return this.reply?(this.publisher.publish(this.reply,e,s),!0):!1}size(){var o;const e=this._msg.subject.length,s=((o=this._msg.reply)==null?void 0:o.length)||0,i=this._msg.size===-1?0:this._msg.size;return e+s+i}json(e){return er(e).decode(this.data)}string(){return En.decode(this.data)}requestInfo(){var s;const e=(s=this.headers)==null?void 0:s.get("Nats-Request-Info");return e?JSON.parse(e,function(i,o){return(i==="start"||i==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}j(fm,"jc");function Xi(n){return Au("durable",n)}function Qt(n){return Au("stream",n)}function Au(n,e=""){if(e==="")throw Error(`${n} name required`);return[".","*",">","/","\\"," "," ",`
31
31
  `,"\r"].forEach(i=>{if(e.indexOf(i)!==-1){switch(i){case`
32
- `:i="\\n";break;case"\r":i="\\r";break;case" ":i="\\t";break}throw Error(`invalid ${n} name - ${n} name cannot contain '${i}'`)}}),""}function go(n,e=""){if(e==="")throw Error(`${n} name required`);const s=_E(e);if(s.length)throw new Error(`invalid ${n} name - ${n} name ${s}`)}function _E(n=""){if(n==="")throw Error("name required");const e=/^[-\w]+$/g;if(n.match(e)===null){for(const i of n.split(""))if(i.match(e)===null)return`cannot contain '${i}'`}return""}function Od(n){if(n.data.length>0)return!1;const e=n.headers;return e?e.code>=100&&e.code<200:!1}function Ad(n){var e;return Od(n)&&((e=n.headers)==null?void 0:e.description)==="Idle Heartbeat"}function wE(n,e,s){const i=Pr(n,e),o={hdr:1,sid:0,size:0},c=new fm(o,jn,{});return c._headers=i,c._subject=s,c}function Wi(n){if(n.data.length!==0)return null;const e=n.headers;return e?_x(e.code,e.description):null}var In;(function(n){n.MaxBatchExceeded="exceeded maxrequestbatch of",n.MaxExpiresExceeded="exceeded maxrequestexpires of",n.MaxBytesExceeded="exceeded maxrequestmaxbytes of",n.MaxMessageSizeExceeded="message size exceeds maxbytes",n.PushConsumer="consumer is push based",n.MaxWaitingExceeded="exceeded maxwaiting",n.IdleHeartbeatMissed="idle heartbeats missed",n.ConsumerDeleted="consumer deleted"})(In||(In={}));function SE(n){return n.code!==fe.JetStream409?!1:[In.MaxBatchExceeded,In.MaxExpiresExceeded,In.MaxBytesExceeded,In.MaxMessageSizeExceeded,In.PushConsumer,In.IdleHeartbeatMissed,In.ConsumerDeleted].find(s=>n.message.indexOf(s)!==-1)!==void 0}function _x(n,e=""){if(n<300)return null;switch(e=e.toLowerCase(),n){case 404:return new ge(e,fe.JetStream404NoMessages);case 408:return new ge(e,fe.JetStream408RequestTimeout);case 409:{const s=e.startsWith(In.IdleHeartbeatMissed)?fe.JetStreamIdleHeartBeat:fe.JetStream409;return new ge(e,s)}case 503:return ge.errorForCode(fe.JetStreamNotEnabled,new Error(e));default:return e===""&&(e=fe.Unknown),new ge(e,`${n}`)}}class Ut{constructor(){j(this,"inflight");j(this,"processed");j(this,"received");j(this,"noIterator");j(this,"iterClosed");j(this,"done");j(this,"signal");j(this,"yields");j(this,"filtered");j(this,"pendingFiltered");j(this,"ingestionFilterFn");j(this,"protocolFilterFn");j(this,"dispatchedFn");j(this,"ctx");j(this,"_data");j(this,"err");j(this,"time");j(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=mt(),this.yields=[],this.iterClosed=mt(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(this.done)return;if(typeof e=="function"){this.yields.push(e),this.signal.resolve();return}const{ingest:s,protocol:i}=this.ingestionFilterFn?this.ingestionFilterFn(e,this.ctx||this):{ingest:!0,protocol:!1};s&&(i&&(this.filtered++,this.pendingFiltered++),this.yields.push(e),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new ge("unsupported iterator",fe.ApiError);if(this.yielding)throw new ge("already yielding",fe.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const e=this.yields;this.inflight=e.length,this.yields=[];for(let s=0;s<e.length;s++){if(typeof e[s]=="function"){const o=e[s];try{o()}catch(c){throw c}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(e[s]):!0){this.processed++;const o=Date.now();yield e[s],this.time=Date.now()-o,this.dispatchedFn&&e[s]&&this.dispatchedFn(e[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=mt())}}finally{this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(e))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class hm{constructor(e,s,i={maxOut:2}){j(this,"interval");j(this,"maxOut");j(this,"cancelAfter");j(this,"timer");j(this,"autoCancelTimer");j(this,"last");j(this,"missed");j(this,"count");j(this,"callback");this.interval=e,this.maxOut=(i==null?void 0:i.maxOut)||2,this.cancelAfter=(i==null?void 0:i.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=s,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,s=0,i=2){this.interval=e,this.maxOut=i,this.cancelAfter=s,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}var jd;(function(n){n.Limits="limits",n.Interest="interest",n.Workqueue="workqueue"})(jd||(jd={}));var Oo;(function(n){n.Old="old",n.New="new"})(Oo||(Oo={}));var kd;(function(n){n.File="file",n.Memory="memory"})(kd||(kd={}));var Et;(function(n){n.All="all",n.Last="last",n.New="new",n.StartSequence="by_start_sequence",n.StartTime="by_start_time",n.LastPerSubject="last_per_subject"})(Et||(Et={}));var Bt;(function(n){n.None="none",n.All="all",n.Explicit="explicit",n.NotSet=""})(Bt||(Bt={}));var sa;(function(n){n.Instant="instant",n.Original="original"})(sa||(sa={}));var js;(function(n){n.None="none",n.S2="s2"})(js||(js={}));var du;(function(n){n.CreateOrUpdate="",n.Update="update",n.Create="create"})(du||(du={}));function EE(n,e={}){return Object.assign({name:n,deliver_policy:Et.All,ack_policy:Bt.Explicit,ack_wait:dt(30*1e3),replay_policy:sa.Instant},e)}var Zg;(function(n){n.API="api_audit",n.StreamAction="stream_action",n.ConsumerAction="consumer_action",n.SnapshotCreate="snapshot_create",n.SnapshotComplete="snapshot_complete",n.RestoreCreate="restore_create",n.RestoreComplete="restore_complete",n.MaxDeliver="max_deliver",n.Terminated="terminated",n.Ack="consumer_ack",n.StreamLeaderElected="stream_leader_elected",n.StreamQuorumLost="stream_quorum_lost",n.ConsumerLeaderElected="consumer_leader_elected",n.ConsumerQuorumLost="consumer_quorum_lost"})(Zg||(Zg={}));var Wt;(function(n){n.StreamSourceHdr="Nats-Stream-Source",n.LastConsumerSeqHdr="Nats-Last-Consumer",n.LastStreamSeqHdr="Nats-Last-Stream",n.ConsumerStalledHdr="Nats-Consumer-Stalled",n.MessageSizeHdr="Nats-Msg-Size",n.RollupHdr="Nats-Rollup",n.RollupValueSubject="sub",n.RollupValueAll="all",n.PendingMessagesHdr="Nats-Pending-Messages",n.PendingBytesHdr="Nats-Pending-Bytes"})(Wt||(Wt={}));var Xn;(function(n){n.LastValue="",n.AllHistory="history",n.UpdatesOnly="updates"})(Xn||(Xn={}));var Ji;(function(n){n.Stream="Nats-Stream",n.Sequence="Nats-Sequence",n.TimeStamp="Nats-Time-Stamp",n.Subject="Nats-Subject"})(Ji||(Ji={}));var eb;(function(n){n.Stream="Nats-Stream",n.Subject="Nats-Subject",n.Sequence="Nats-Sequence",n.LastSequence="Nats-Last-Sequence",n.Size="Nats-Msg-Size"})(eb||(eb={}));const Sn="KV_";class OE{constructor(e){j(this,"config");j(this,"ordered");j(this,"mack");j(this,"stream");j(this,"callbackFn");j(this,"max");j(this,"qname");j(this,"isBind");j(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=EE("",e||{})}getOpts(){var s;const e={};if(e.config=Object.assign({},this.config),e.config.filter_subject&&(this.filterSubject(e.config.filter_subject),e.config.filter_subject=void 0),e.config.filter_subjects&&((s=e.config.filter_subjects)==null||s.forEach(i=>{this.filterSubject(i)}),e.config.filter_subjects=void 0),e.mack=this.mack,e.stream=this.stream,e.callbackFn=this.callbackFn,e.max=this.max,e.queue=this.qname,e.ordered=this.ordered,e.config.ack_policy=e.ordered?Bt.None:e.config.ack_policy,e.isBind=e.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:e.config.filter_subject=this.filters[0];break;default:e.config.filter_subjects=this.filters}return e}description(e){return this.config.description=e,this}deliverTo(e){return this.config.deliver_subject=e,this}durable(e){return Xi(e),this.config.durable_name=e,this}startSequence(e){if(e<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=Et.StartSequence,this.config.opt_start_seq=e,this}startTime(e){return this.config.deliver_policy=Et.StartTime,this.config.opt_start_time=e.toISOString(),this}deliverAll(){return this.config.deliver_policy=Et.All,this}deliverLastPerSubject(){return this.config.deliver_policy=Et.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=Et.Last,this}deliverNew(){return this.config.deliver_policy=Et.New,this}startAtTimeDelta(e){return this.startTime(new Date(Date.now()-e)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=Bt.None,this}ackAll(){return this.config.ack_policy=Bt.All,this}ackExplicit(){return this.config.ack_policy=Bt.Explicit,this}ackWait(e){return this.config.ack_wait=dt(e),this}maxDeliver(e){return this.config.max_deliver=e,this}filterSubject(e){return this.filters=this.filters||[],this.filters.push(e),this}replayInstantly(){return this.config.replay_policy=sa.Instant,this}replayOriginal(){return this.config.replay_policy=sa.Original,this}sample(e){if(e=Math.trunc(e),e<0||e>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${e}%`,this}limit(e){return this.config.rate_limit_bps=e,this}maxWaiting(e){return this.config.max_waiting=e,this}maxAckPending(e){return this.config.max_ack_pending=e,this}idleHeartbeat(e){return this.config.idle_heartbeat=dt(e),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(e){return this.queue(e),this}manualAck(){return this.mack=!0,this}maxMessages(e){return this.max=e,this}callback(e){return this.callbackFn=e,this}queue(e){return this.qname=e,this.config.deliver_group=e,this}orderedConsumer(){return this.ordered=!0,this}bind(e,s){return this.stream=e,this.config.durable_name=s,this.isBind=!0,this}bindStream(e){return this.stream=e,this}inactiveEphemeralThreshold(e){return this.config.inactive_threshold=dt(e),this}maxPullBatch(e){return this.config.max_batch=e,this}maxPullRequestExpires(e){return this.config.max_expires=dt(e),this}memory(){return this.config.mem_storage=!0,this}numReplicas(e){return this.config.num_replicas=e,this}consumerName(e){return this.config.name=e,this}}function Ss(n){return new OE(n)}function tb(n){return typeof n.getOpts=="function"}class AE{static encode(e){if(typeof e=="string")return btoa(e);const s=Array.from(e);return btoa(String.fromCharCode(...s))}static decode(e,s=!1){const i=atob(e);return s?Uint8Array.from(i,o=>o.charCodeAt(0)):i}}class Zi{static encode(e){return Zi.toB64URLEncoding(AE.encode(e))}static decode(e,s=!1){return Zi.decode(Zi.fromB64URLEncoding(e),s)}static toB64URLEncoding(e){return e.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(e){return e.replace(/_/g,"/").replace(/-/g,"+")}}class ia{constructor(){j(this,"buffers");j(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let s=0;for(let c=0;c<e.length;c++)s+=e[c].length;const i=new Uint8Array(s);let o=0;for(let c=0;c<e.length;c++)i.set(e[c],o),o+=e[c].length;return i}static fromAscii(e){return e||(e=""),ri.encode(e)}static toAscii(e){return En.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const e=new Uint8Array(this.byteLength);let s=0;for(let i=0;i<this.buffers.length;i++)e.set(this.buffers[i],s),s+=this.buffers[i].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const i=this.byteLength;(e===void 0||e>i)&&(e=i);const o=s.subarray(0,e);return i>e&&this.buffers.push(s.subarray(e)),this.byteLength=i-e,o}}return new Uint8Array(0)}fill(e,...s){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let i=0;i<s.length;i++)s[i]&&s[i].length&&(this.buffers.push(s[i]),this.byteLength+=s[i].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function jE(n,e){return e.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(i){if(i!=="default"&&!(i in n)){var o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return s[i]}})}})}),Object.freeze(n)}var kE=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},so=kE.performance||{};so.now||so.mozNow||so.msNow||so.oNow||so.webkitNow;var nb={versions:{}},NE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function TE(n){if(n.__esModule)return n;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(s){var i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return n[s]}})}),e}var ed,ju={exports:{}},rb={},sb=TE(jE({__proto__:null,default:rb},[rb]));ed=ju,(function(){var n="input is invalid type",e=typeof window=="object",s=e?window:{};s.JS_SHA256_NO_WINDOW&&(e=!1);var i=!e&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&nb.versions&&nb.versions.node;o?s=NE:i&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&ed.exports,m=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",p="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],u=[24,16,8,0],d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],b=["hex","array","digest","arrayBuffer"],x=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(M){return Object.prototype.toString.call(M)==="[object Array]"}),!m||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(M){return typeof M=="object"&&M.buffer&&M.buffer.constructor===ArrayBuffer});var v=function(M,z){return function(ae){return new q(z,!0).update(ae)[M]()}},_=function(M){var z=v("hex",M);o&&(z=S(z,M)),z.create=function(){return new q(M)},z.update=function(U){return z.create().update(U)};for(var ae=0;ae<b.length;++ae){var F=b[ae];z[F]=v(F,M)}return z},S=function(M,z){var ae,F=sb,U=sb.Buffer,D=z?"sha224":"sha256";return ae=U.from&&!s.JS_SHA256_NO_BUFFER_FROM?U.from:function(X){return new U(X)},function(X){if(typeof X=="string")return F.createHash(D).update(X,"utf8").digest("hex");if(X==null)throw new Error(n);return X.constructor===ArrayBuffer&&(X=new Uint8Array(X)),Array.isArray(X)||ArrayBuffer.isView(X)||X.constructor===U?F.createHash(D).update(ae(X)).digest("hex"):M(X)}},C=function(M,z){return function(ae,F){return new ne(ae,z,!0).update(F)[M]()}},B=function(M){var z=C("hex",M);z.create=function(U){return new ne(U,M)},z.update=function(U,D){return z.create(U).update(D)};for(var ae=0;ae<b.length;++ae){var F=b[ae];z[F]=C(F,M)}return z};function q(M,z){z?(x[0]=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0,this.blocks=x):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],M?(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=M}function ne(M,z,ae){var F,U=typeof M;if(U==="string"){var D,X=[],W=M.length,he=0;for(F=0;F<W;++F)(D=M.charCodeAt(F))<128?X[he++]=D:D<2048?(X[he++]=192|D>>>6,X[he++]=128|63&D):D<55296||D>=57344?(X[he++]=224|D>>>12,X[he++]=128|D>>>6&63,X[he++]=128|63&D):(D=65536+((1023&D)<<10|1023&M.charCodeAt(++F)),X[he++]=240|D>>>18,X[he++]=128|D>>>12&63,X[he++]=128|D>>>6&63,X[he++]=128|63&D);M=X}else{if(U!=="object")throw new Error(n);if(M===null)throw new Error(n);if(m&&M.constructor===ArrayBuffer)M=new Uint8Array(M);else if(!(Array.isArray(M)||m&&ArrayBuffer.isView(M)))throw new Error(n)}M.length>64&&(M=new q(z,!0).update(M).array());var Se=[],Ae=[];for(F=0;F<64;++F){var H=M[F]||0;Se[F]=92^H,Ae[F]=54^H}q.call(this,z,ae),this.update(Ae),this.oKeyPad=Se,this.inner=!0,this.sharedMemory=ae}q.prototype.update=function(M){if(!this.finalized){var z,ae=typeof M;if(ae!=="string"){if(ae!=="object")throw new Error(n);if(M===null)throw new Error(n);if(m&&M.constructor===ArrayBuffer)M=new Uint8Array(M);else if(!(Array.isArray(M)||m&&ArrayBuffer.isView(M)))throw new Error(n);z=!0}for(var F,U,D=0,X=M.length,W=this.blocks;D<X;){if(this.hashed&&(this.hashed=!1,W[0]=this.block,this.block=W[16]=W[1]=W[2]=W[3]=W[4]=W[5]=W[6]=W[7]=W[8]=W[9]=W[10]=W[11]=W[12]=W[13]=W[14]=W[15]=0),z)for(U=this.start;D<X&&U<64;++D)W[U>>>2]|=M[D]<<u[3&U++];else for(U=this.start;D<X&&U<64;++D)(F=M.charCodeAt(D))<128?W[U>>>2]|=F<<u[3&U++]:F<2048?(W[U>>>2]|=(192|F>>>6)<<u[3&U++],W[U>>>2]|=(128|63&F)<<u[3&U++]):F<55296||F>=57344?(W[U>>>2]|=(224|F>>>12)<<u[3&U++],W[U>>>2]|=(128|F>>>6&63)<<u[3&U++],W[U>>>2]|=(128|63&F)<<u[3&U++]):(F=65536+((1023&F)<<10|1023&M.charCodeAt(++D)),W[U>>>2]|=(240|F>>>18)<<u[3&U++],W[U>>>2]|=(128|F>>>12&63)<<u[3&U++],W[U>>>2]|=(128|F>>>6&63)<<u[3&U++],W[U>>>2]|=(128|63&F)<<u[3&U++]);this.lastByteIndex=U,this.bytes+=U-this.start,U>=64?(this.block=W[16],this.start=U-64,this.hash(),this.hashed=!0):this.start=U}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var M=this.blocks,z=this.lastByteIndex;M[16]=this.block,M[z>>>2]|=g[3&z],this.block=M[16],z>=56&&(this.hashed||this.hash(),M[0]=this.block,M[16]=M[1]=M[2]=M[3]=M[4]=M[5]=M[6]=M[7]=M[8]=M[9]=M[10]=M[11]=M[12]=M[13]=M[14]=M[15]=0),M[14]=this.hBytes<<3|this.bytes>>>29,M[15]=this.bytes<<3,this.hash()}},q.prototype.hash=function(){var M,z,ae,F,U,D,X,W,he,Se=this.h0,Ae=this.h1,H=this.h2,J=this.h3,le=this.h4,pe=this.h5,ye=this.h6,Ce=this.h7,Ne=this.blocks;for(M=16;M<64;++M)z=((U=Ne[M-15])>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,ae=((U=Ne[M-2])>>>17|U<<15)^(U>>>19|U<<13)^U>>>10,Ne[M]=Ne[M-16]+z+Ne[M-7]+ae|0;for(he=Ae&H,M=0;M<64;M+=4)this.first?(this.is224?(D=300032,Ce=(U=Ne[0]-1413257819)-150054599|0,J=U+24177077|0):(D=704751109,Ce=(U=Ne[0]-210244248)-1521486534|0,J=U+143694565|0),this.first=!1):(z=(Se>>>2|Se<<30)^(Se>>>13|Se<<19)^(Se>>>22|Se<<10),F=(D=Se&Ae)^Se&H^he,Ce=J+(U=Ce+(ae=(le>>>6|le<<26)^(le>>>11|le<<21)^(le>>>25|le<<7))+(le&pe^~le&ye)+d[M]+Ne[M])|0,J=U+(z+F)|0),z=(J>>>2|J<<30)^(J>>>13|J<<19)^(J>>>22|J<<10),F=(X=J&Se)^J&Ae^D,ye=H+(U=ye+(ae=(Ce>>>6|Ce<<26)^(Ce>>>11|Ce<<21)^(Ce>>>25|Ce<<7))+(Ce&le^~Ce&pe)+d[M+1]+Ne[M+1])|0,z=((H=U+(z+F)|0)>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10),F=(W=H&J)^H&Se^X,pe=Ae+(U=pe+(ae=(ye>>>6|ye<<26)^(ye>>>11|ye<<21)^(ye>>>25|ye<<7))+(ye&Ce^~ye&le)+d[M+2]+Ne[M+2])|0,z=((Ae=U+(z+F)|0)>>>2|Ae<<30)^(Ae>>>13|Ae<<19)^(Ae>>>22|Ae<<10),F=(he=Ae&H)^Ae&J^W,le=Se+(U=le+(ae=(pe>>>6|pe<<26)^(pe>>>11|pe<<21)^(pe>>>25|pe<<7))+(pe&ye^~pe&Ce)+d[M+3]+Ne[M+3])|0,Se=U+(z+F)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+Se|0,this.h1=this.h1+Ae|0,this.h2=this.h2+H|0,this.h3=this.h3+J|0,this.h4=this.h4+le|0,this.h5=this.h5+pe|0,this.h6=this.h6+ye|0,this.h7=this.h7+Ce|0},q.prototype.hex=function(){this.finalize();var M=this.h0,z=this.h1,ae=this.h2,F=this.h3,U=this.h4,D=this.h5,X=this.h6,W=this.h7,he=p[M>>>28&15]+p[M>>>24&15]+p[M>>>20&15]+p[M>>>16&15]+p[M>>>12&15]+p[M>>>8&15]+p[M>>>4&15]+p[15&M]+p[z>>>28&15]+p[z>>>24&15]+p[z>>>20&15]+p[z>>>16&15]+p[z>>>12&15]+p[z>>>8&15]+p[z>>>4&15]+p[15&z]+p[ae>>>28&15]+p[ae>>>24&15]+p[ae>>>20&15]+p[ae>>>16&15]+p[ae>>>12&15]+p[ae>>>8&15]+p[ae>>>4&15]+p[15&ae]+p[F>>>28&15]+p[F>>>24&15]+p[F>>>20&15]+p[F>>>16&15]+p[F>>>12&15]+p[F>>>8&15]+p[F>>>4&15]+p[15&F]+p[U>>>28&15]+p[U>>>24&15]+p[U>>>20&15]+p[U>>>16&15]+p[U>>>12&15]+p[U>>>8&15]+p[U>>>4&15]+p[15&U]+p[D>>>28&15]+p[D>>>24&15]+p[D>>>20&15]+p[D>>>16&15]+p[D>>>12&15]+p[D>>>8&15]+p[D>>>4&15]+p[15&D]+p[X>>>28&15]+p[X>>>24&15]+p[X>>>20&15]+p[X>>>16&15]+p[X>>>12&15]+p[X>>>8&15]+p[X>>>4&15]+p[15&X];return this.is224||(he+=p[W>>>28&15]+p[W>>>24&15]+p[W>>>20&15]+p[W>>>16&15]+p[W>>>12&15]+p[W>>>8&15]+p[W>>>4&15]+p[15&W]),he},q.prototype.toString=q.prototype.hex,q.prototype.digest=function(){this.finalize();var M=this.h0,z=this.h1,ae=this.h2,F=this.h3,U=this.h4,D=this.h5,X=this.h6,W=this.h7,he=[M>>>24&255,M>>>16&255,M>>>8&255,255&M,z>>>24&255,z>>>16&255,z>>>8&255,255&z,ae>>>24&255,ae>>>16&255,ae>>>8&255,255&ae,F>>>24&255,F>>>16&255,F>>>8&255,255&F,U>>>24&255,U>>>16&255,U>>>8&255,255&U,D>>>24&255,D>>>16&255,D>>>8&255,255&D,X>>>24&255,X>>>16&255,X>>>8&255,255&X];return this.is224||he.push(W>>>24&255,W>>>16&255,W>>>8&255,255&W),he},q.prototype.array=q.prototype.digest,q.prototype.arrayBuffer=function(){this.finalize();var M=new ArrayBuffer(this.is224?28:32),z=new DataView(M);return z.setUint32(0,this.h0),z.setUint32(4,this.h1),z.setUint32(8,this.h2),z.setUint32(12,this.h3),z.setUint32(16,this.h4),z.setUint32(20,this.h5),z.setUint32(24,this.h6),this.is224||z.setUint32(28,this.h7),M},ne.prototype=new q,ne.prototype.finalize=function(){if(q.prototype.finalize.call(this),this.inner){this.inner=!1;var M=this.array();q.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(M),q.prototype.finalize.call(this)}};var te=_();te.sha256=te,te.sha224=_(!0),te.sha256.hmac=B(),te.sha224.hmac=B(!0),c?ed.exports=te:(s.sha256=te.sha256,s.sha224=te.sha224)})();ju.exports;ju.exports.sha224;var ib=ju.exports.sha256;function Nd(n){return qE(n)}function CE(n){if(!/^[0-9A-Fa-f]+$/.test(n))return!1;const s=/^[0-9A-F]+$/.test(n),i=/^[0-9a-f]+$/.test(n);return s||i?n.length%2===0:!1}function ME(n){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(n)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(n)}function RE(n){return CE(n)?"hex":ME(n)?"b64":""}function DE(n){if(n.length%2!==0)throw new Error("hex string must have an even length");const e=new Uint8Array(n.length/2);for(let s=0;s<n.length;s+=2)e[s/2]=parseInt(n.substring(s,s+2),16);return e}function LE(n){n=n.replace(/-/g,"+"),n=n.replace(/_/g,"/");const e=atob(n);return Uint8Array.from(e,s=>s.charCodeAt(0))}function qE(n){switch(RE(n)){case"hex":return DE(n);case"b64":return LE(n)}return null}function PE(n,e){const s=typeof n=="string"?Nd(n):n,i=typeof e=="string"?Nd(e):e;if(s===null||i===null||s.length!==i.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==i[o])return!1;return!0}class wx{constructor(e,s,i=!0){j(this,"token");j(this,"received");j(this,"ctx");j(this,"requestSubject");j(this,"mux");this.mux=e,this.requestSubject=s,this.received=0,this.token=As.next(),i&&(this.ctx=new Error)}}class BE extends wx{constructor(s,i,o={maxWait:1e3}){super(s,i);j(this,"callback");j(this,"done");j(this,"timer");j(this,"max");j(this,"opts");if(this.opts=o,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof o.maxMessages=="number"&&o.maxMessages>0?o.maxMessages:-1,this.done=mt(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},o.maxWait)}cancel(s){s&&this.callback(s,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(s,i){s?(this.ctx&&(s.stack+=`
32
+ `:i="\\n";break;case"\r":i="\\r";break;case" ":i="\\t";break}throw Error(`invalid ${n} name - ${n} name cannot contain '${i}'`)}}),""}function bo(n,e=""){if(e==="")throw Error(`${n} name required`);const s=_E(e);if(s.length)throw new Error(`invalid ${n} name - ${n} name ${s}`)}function _E(n=""){if(n==="")throw Error("name required");const e=/^[-\w]+$/g;if(n.match(e)===null){for(const i of n.split(""))if(i.match(e)===null)return`cannot contain '${i}'`}return""}function Od(n){if(n.data.length>0)return!1;const e=n.headers;return e?e.code>=100&&e.code<200:!1}function Ad(n){var e;return Od(n)&&((e=n.headers)==null?void 0:e.description)==="Idle Heartbeat"}function wE(n,e,s){const i=Pr(n,e),o={hdr:1,sid:0,size:0},c=new fm(o,jn,{});return c._headers=i,c._subject=s,c}function Wi(n){if(n.data.length!==0)return null;const e=n.headers;return e?_x(e.code,e.description):null}var In;(function(n){n.MaxBatchExceeded="exceeded maxrequestbatch of",n.MaxExpiresExceeded="exceeded maxrequestexpires of",n.MaxBytesExceeded="exceeded maxrequestmaxbytes of",n.MaxMessageSizeExceeded="message size exceeds maxbytes",n.PushConsumer="consumer is push based",n.MaxWaitingExceeded="exceeded maxwaiting",n.IdleHeartbeatMissed="idle heartbeats missed",n.ConsumerDeleted="consumer deleted"})(In||(In={}));function SE(n){return n.code!==fe.JetStream409?!1:[In.MaxBatchExceeded,In.MaxExpiresExceeded,In.MaxBytesExceeded,In.MaxMessageSizeExceeded,In.PushConsumer,In.IdleHeartbeatMissed,In.ConsumerDeleted].find(s=>n.message.indexOf(s)!==-1)!==void 0}function _x(n,e=""){if(n<300)return null;switch(e=e.toLowerCase(),n){case 404:return new be(e,fe.JetStream404NoMessages);case 408:return new be(e,fe.JetStream408RequestTimeout);case 409:{const s=e.startsWith(In.IdleHeartbeatMissed)?fe.JetStreamIdleHeartBeat:fe.JetStream409;return new be(e,s)}case 503:return be.errorForCode(fe.JetStreamNotEnabled,new Error(e));default:return e===""&&(e=fe.Unknown),new be(e,`${n}`)}}class Ut{constructor(){j(this,"inflight");j(this,"processed");j(this,"received");j(this,"noIterator");j(this,"iterClosed");j(this,"done");j(this,"signal");j(this,"yields");j(this,"filtered");j(this,"pendingFiltered");j(this,"ingestionFilterFn");j(this,"protocolFilterFn");j(this,"dispatchedFn");j(this,"ctx");j(this,"_data");j(this,"err");j(this,"time");j(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=dt(),this.yields=[],this.iterClosed=dt(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(this.done)return;if(typeof e=="function"){this.yields.push(e),this.signal.resolve();return}const{ingest:s,protocol:i}=this.ingestionFilterFn?this.ingestionFilterFn(e,this.ctx||this):{ingest:!0,protocol:!1};s&&(i&&(this.filtered++,this.pendingFiltered++),this.yields.push(e),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new be("unsupported iterator",fe.ApiError);if(this.yielding)throw new be("already yielding",fe.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const e=this.yields;this.inflight=e.length,this.yields=[];for(let s=0;s<e.length;s++){if(typeof e[s]=="function"){const o=e[s];try{o()}catch(c){throw c}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(e[s]):!0){this.processed++;const o=Date.now();yield e[s],this.time=Date.now()-o,this.dispatchedFn&&e[s]&&this.dispatchedFn(e[s])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=dt())}}finally{this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(e))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}class hm{constructor(e,s,i={maxOut:2}){j(this,"interval");j(this,"maxOut");j(this,"cancelAfter");j(this,"timer");j(this,"autoCancelTimer");j(this,"last");j(this,"missed");j(this,"count");j(this,"callback");this.interval=e,this.maxOut=(i==null?void 0:i.maxOut)||2,this.cancelAfter=(i==null?void 0:i.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=s,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,s=0,i=2){this.interval=e,this.maxOut=i,this.cancelAfter=s,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}var jd;(function(n){n.Limits="limits",n.Interest="interest",n.Workqueue="workqueue"})(jd||(jd={}));var Ao;(function(n){n.Old="old",n.New="new"})(Ao||(Ao={}));var kd;(function(n){n.File="file",n.Memory="memory"})(kd||(kd={}));var Et;(function(n){n.All="all",n.Last="last",n.New="new",n.StartSequence="by_start_sequence",n.StartTime="by_start_time",n.LastPerSubject="last_per_subject"})(Et||(Et={}));var Bt;(function(n){n.None="none",n.All="all",n.Explicit="explicit",n.NotSet=""})(Bt||(Bt={}));var ia;(function(n){n.Instant="instant",n.Original="original"})(ia||(ia={}));var js;(function(n){n.None="none",n.S2="s2"})(js||(js={}));var du;(function(n){n.CreateOrUpdate="",n.Update="update",n.Create="create"})(du||(du={}));function EE(n,e={}){return Object.assign({name:n,deliver_policy:Et.All,ack_policy:Bt.Explicit,ack_wait:ht(30*1e3),replay_policy:ia.Instant},e)}var Zg;(function(n){n.API="api_audit",n.StreamAction="stream_action",n.ConsumerAction="consumer_action",n.SnapshotCreate="snapshot_create",n.SnapshotComplete="snapshot_complete",n.RestoreCreate="restore_create",n.RestoreComplete="restore_complete",n.MaxDeliver="max_deliver",n.Terminated="terminated",n.Ack="consumer_ack",n.StreamLeaderElected="stream_leader_elected",n.StreamQuorumLost="stream_quorum_lost",n.ConsumerLeaderElected="consumer_leader_elected",n.ConsumerQuorumLost="consumer_quorum_lost"})(Zg||(Zg={}));var Zt;(function(n){n.StreamSourceHdr="Nats-Stream-Source",n.LastConsumerSeqHdr="Nats-Last-Consumer",n.LastStreamSeqHdr="Nats-Last-Stream",n.ConsumerStalledHdr="Nats-Consumer-Stalled",n.MessageSizeHdr="Nats-Msg-Size",n.RollupHdr="Nats-Rollup",n.RollupValueSubject="sub",n.RollupValueAll="all",n.PendingMessagesHdr="Nats-Pending-Messages",n.PendingBytesHdr="Nats-Pending-Bytes"})(Zt||(Zt={}));var Xn;(function(n){n.LastValue="",n.AllHistory="history",n.UpdatesOnly="updates"})(Xn||(Xn={}));var Ji;(function(n){n.Stream="Nats-Stream",n.Sequence="Nats-Sequence",n.TimeStamp="Nats-Time-Stamp",n.Subject="Nats-Subject"})(Ji||(Ji={}));var eb;(function(n){n.Stream="Nats-Stream",n.Subject="Nats-Subject",n.Sequence="Nats-Sequence",n.LastSequence="Nats-Last-Sequence",n.Size="Nats-Msg-Size"})(eb||(eb={}));const Sn="KV_";class OE{constructor(e){j(this,"config");j(this,"ordered");j(this,"mack");j(this,"stream");j(this,"callbackFn");j(this,"max");j(this,"qname");j(this,"isBind");j(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=EE("",e||{})}getOpts(){var s;const e={};if(e.config=Object.assign({},this.config),e.config.filter_subject&&(this.filterSubject(e.config.filter_subject),e.config.filter_subject=void 0),e.config.filter_subjects&&((s=e.config.filter_subjects)==null||s.forEach(i=>{this.filterSubject(i)}),e.config.filter_subjects=void 0),e.mack=this.mack,e.stream=this.stream,e.callbackFn=this.callbackFn,e.max=this.max,e.queue=this.qname,e.ordered=this.ordered,e.config.ack_policy=e.ordered?Bt.None:e.config.ack_policy,e.isBind=e.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:e.config.filter_subject=this.filters[0];break;default:e.config.filter_subjects=this.filters}return e}description(e){return this.config.description=e,this}deliverTo(e){return this.config.deliver_subject=e,this}durable(e){return Xi(e),this.config.durable_name=e,this}startSequence(e){if(e<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=Et.StartSequence,this.config.opt_start_seq=e,this}startTime(e){return this.config.deliver_policy=Et.StartTime,this.config.opt_start_time=e.toISOString(),this}deliverAll(){return this.config.deliver_policy=Et.All,this}deliverLastPerSubject(){return this.config.deliver_policy=Et.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=Et.Last,this}deliverNew(){return this.config.deliver_policy=Et.New,this}startAtTimeDelta(e){return this.startTime(new Date(Date.now()-e)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=Bt.None,this}ackAll(){return this.config.ack_policy=Bt.All,this}ackExplicit(){return this.config.ack_policy=Bt.Explicit,this}ackWait(e){return this.config.ack_wait=ht(e),this}maxDeliver(e){return this.config.max_deliver=e,this}filterSubject(e){return this.filters=this.filters||[],this.filters.push(e),this}replayInstantly(){return this.config.replay_policy=ia.Instant,this}replayOriginal(){return this.config.replay_policy=ia.Original,this}sample(e){if(e=Math.trunc(e),e<0||e>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${e}%`,this}limit(e){return this.config.rate_limit_bps=e,this}maxWaiting(e){return this.config.max_waiting=e,this}maxAckPending(e){return this.config.max_ack_pending=e,this}idleHeartbeat(e){return this.config.idle_heartbeat=ht(e),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(e){return this.queue(e),this}manualAck(){return this.mack=!0,this}maxMessages(e){return this.max=e,this}callback(e){return this.callbackFn=e,this}queue(e){return this.qname=e,this.config.deliver_group=e,this}orderedConsumer(){return this.ordered=!0,this}bind(e,s){return this.stream=e,this.config.durable_name=s,this.isBind=!0,this}bindStream(e){return this.stream=e,this}inactiveEphemeralThreshold(e){return this.config.inactive_threshold=ht(e),this}maxPullBatch(e){return this.config.max_batch=e,this}maxPullRequestExpires(e){return this.config.max_expires=ht(e),this}memory(){return this.config.mem_storage=!0,this}numReplicas(e){return this.config.num_replicas=e,this}consumerName(e){return this.config.name=e,this}}function Ss(n){return new OE(n)}function tb(n){return typeof n.getOpts=="function"}class AE{static encode(e){if(typeof e=="string")return btoa(e);const s=Array.from(e);return btoa(String.fromCharCode(...s))}static decode(e,s=!1){const i=atob(e);return s?Uint8Array.from(i,o=>o.charCodeAt(0)):i}}class Zi{static encode(e){return Zi.toB64URLEncoding(AE.encode(e))}static decode(e,s=!1){return Zi.decode(Zi.fromB64URLEncoding(e),s)}static toB64URLEncoding(e){return e.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(e){return e.replace(/_/g,"/").replace(/-/g,"+")}}class aa{constructor(){j(this,"buffers");j(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let s=0;for(let c=0;c<e.length;c++)s+=e[c].length;const i=new Uint8Array(s);let o=0;for(let c=0;c<e.length;c++)i.set(e[c],o),o+=e[c].length;return i}static fromAscii(e){return e||(e=""),ri.encode(e)}static toAscii(e){return En.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const e=new Uint8Array(this.byteLength);let s=0;for(let i=0;i<this.buffers.length;i++)e.set(this.buffers[i],s),s+=this.buffers[i].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const s=this.buffers.pop();if(s){const i=this.byteLength;(e===void 0||e>i)&&(e=i);const o=s.subarray(0,e);return i>e&&this.buffers.push(s.subarray(e)),this.byteLength=i-e,o}}return new Uint8Array(0)}fill(e,...s){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let i=0;i<s.length;i++)s[i]&&s[i].length&&(this.buffers.push(s[i]),this.byteLength+=s[i].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}function jE(n,e){return e.forEach(function(s){s&&typeof s!="string"&&!Array.isArray(s)&&Object.keys(s).forEach(function(i){if(i!=="default"&&!(i in n)){var o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return s[i]}})}})}),Object.freeze(n)}var kE=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},io=kE.performance||{};io.now||io.mozNow||io.msNow||io.oNow||io.webkitNow;var nb={versions:{}},NE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function TE(n){if(n.__esModule)return n;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(n).forEach(function(s){var i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:function(){return n[s]}})}),e}var ed,ju={exports:{}},rb={},sb=TE(jE({__proto__:null,default:rb},[rb]));ed=ju,(function(){var n="input is invalid type",e=typeof window=="object",s=e?window:{};s.JS_SHA256_NO_WINDOW&&(e=!1);var i=!e&&typeof self=="object",o=!s.JS_SHA256_NO_NODE_JS&&nb.versions&&nb.versions.node;o?s=NE:i&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&ed.exports,m=!s.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",p="0123456789abcdef".split(""),g=[-2147483648,8388608,32768,128],u=[24,16,8,0],d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],b=["hex","array","digest","arrayBuffer"],x=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(M){return Object.prototype.toString.call(M)==="[object Array]"}),!m||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(M){return typeof M=="object"&&M.buffer&&M.buffer.constructor===ArrayBuffer});var v=function(M,z){return function(ae){return new q(z,!0).update(ae)[M]()}},_=function(M){var z=v("hex",M);o&&(z=S(z,M)),z.create=function(){return new q(M)},z.update=function(U){return z.create().update(U)};for(var ae=0;ae<b.length;++ae){var F=b[ae];z[F]=v(F,M)}return z},S=function(M,z){var ae,F=sb,U=sb.Buffer,D=z?"sha224":"sha256";return ae=U.from&&!s.JS_SHA256_NO_BUFFER_FROM?U.from:function(Q){return new U(Q)},function(Q){if(typeof Q=="string")return F.createHash(D).update(Q,"utf8").digest("hex");if(Q==null)throw new Error(n);return Q.constructor===ArrayBuffer&&(Q=new Uint8Array(Q)),Array.isArray(Q)||ArrayBuffer.isView(Q)||Q.constructor===U?F.createHash(D).update(ae(Q)).digest("hex"):M(Q)}},C=function(M,z){return function(ae,F){return new ne(ae,z,!0).update(F)[M]()}},B=function(M){var z=C("hex",M);z.create=function(U){return new ne(U,M)},z.update=function(U,D){return z.create(U).update(D)};for(var ae=0;ae<b.length;++ae){var F=b[ae];z[F]=C(F,M)}return z};function q(M,z){z?(x[0]=x[16]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=0,this.blocks=x):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],M?(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=M}function ne(M,z,ae){var F,U=typeof M;if(U==="string"){var D,Q=[],W=M.length,he=0;for(F=0;F<W;++F)(D=M.charCodeAt(F))<128?Q[he++]=D:D<2048?(Q[he++]=192|D>>>6,Q[he++]=128|63&D):D<55296||D>=57344?(Q[he++]=224|D>>>12,Q[he++]=128|D>>>6&63,Q[he++]=128|63&D):(D=65536+((1023&D)<<10|1023&M.charCodeAt(++F)),Q[he++]=240|D>>>18,Q[he++]=128|D>>>12&63,Q[he++]=128|D>>>6&63,Q[he++]=128|63&D);M=Q}else{if(U!=="object")throw new Error(n);if(M===null)throw new Error(n);if(m&&M.constructor===ArrayBuffer)M=new Uint8Array(M);else if(!(Array.isArray(M)||m&&ArrayBuffer.isView(M)))throw new Error(n)}M.length>64&&(M=new q(z,!0).update(M).array());var Ee=[],Ae=[];for(F=0;F<64;++F){var H=M[F]||0;Ee[F]=92^H,Ae[F]=54^H}q.call(this,z,ae),this.update(Ae),this.oKeyPad=Ee,this.inner=!0,this.sharedMemory=ae}q.prototype.update=function(M){if(!this.finalized){var z,ae=typeof M;if(ae!=="string"){if(ae!=="object")throw new Error(n);if(M===null)throw new Error(n);if(m&&M.constructor===ArrayBuffer)M=new Uint8Array(M);else if(!(Array.isArray(M)||m&&ArrayBuffer.isView(M)))throw new Error(n);z=!0}for(var F,U,D=0,Q=M.length,W=this.blocks;D<Q;){if(this.hashed&&(this.hashed=!1,W[0]=this.block,this.block=W[16]=W[1]=W[2]=W[3]=W[4]=W[5]=W[6]=W[7]=W[8]=W[9]=W[10]=W[11]=W[12]=W[13]=W[14]=W[15]=0),z)for(U=this.start;D<Q&&U<64;++D)W[U>>>2]|=M[D]<<u[3&U++];else for(U=this.start;D<Q&&U<64;++D)(F=M.charCodeAt(D))<128?W[U>>>2]|=F<<u[3&U++]:F<2048?(W[U>>>2]|=(192|F>>>6)<<u[3&U++],W[U>>>2]|=(128|63&F)<<u[3&U++]):F<55296||F>=57344?(W[U>>>2]|=(224|F>>>12)<<u[3&U++],W[U>>>2]|=(128|F>>>6&63)<<u[3&U++],W[U>>>2]|=(128|63&F)<<u[3&U++]):(F=65536+((1023&F)<<10|1023&M.charCodeAt(++D)),W[U>>>2]|=(240|F>>>18)<<u[3&U++],W[U>>>2]|=(128|F>>>12&63)<<u[3&U++],W[U>>>2]|=(128|F>>>6&63)<<u[3&U++],W[U>>>2]|=(128|63&F)<<u[3&U++]);this.lastByteIndex=U,this.bytes+=U-this.start,U>=64?(this.block=W[16],this.start=U-64,this.hash(),this.hashed=!0):this.start=U}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var M=this.blocks,z=this.lastByteIndex;M[16]=this.block,M[z>>>2]|=g[3&z],this.block=M[16],z>=56&&(this.hashed||this.hash(),M[0]=this.block,M[16]=M[1]=M[2]=M[3]=M[4]=M[5]=M[6]=M[7]=M[8]=M[9]=M[10]=M[11]=M[12]=M[13]=M[14]=M[15]=0),M[14]=this.hBytes<<3|this.bytes>>>29,M[15]=this.bytes<<3,this.hash()}},q.prototype.hash=function(){var M,z,ae,F,U,D,Q,W,he,Ee=this.h0,Ae=this.h1,H=this.h2,J=this.h3,ce=this.h4,pe=this.h5,ge=this.h6,Ce=this.h7,Ne=this.blocks;for(M=16;M<64;++M)z=((U=Ne[M-15])>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,ae=((U=Ne[M-2])>>>17|U<<15)^(U>>>19|U<<13)^U>>>10,Ne[M]=Ne[M-16]+z+Ne[M-7]+ae|0;for(he=Ae&H,M=0;M<64;M+=4)this.first?(this.is224?(D=300032,Ce=(U=Ne[0]-1413257819)-150054599|0,J=U+24177077|0):(D=704751109,Ce=(U=Ne[0]-210244248)-1521486534|0,J=U+143694565|0),this.first=!1):(z=(Ee>>>2|Ee<<30)^(Ee>>>13|Ee<<19)^(Ee>>>22|Ee<<10),F=(D=Ee&Ae)^Ee&H^he,Ce=J+(U=Ce+(ae=(ce>>>6|ce<<26)^(ce>>>11|ce<<21)^(ce>>>25|ce<<7))+(ce&pe^~ce&ge)+d[M]+Ne[M])|0,J=U+(z+F)|0),z=(J>>>2|J<<30)^(J>>>13|J<<19)^(J>>>22|J<<10),F=(Q=J&Ee)^J&Ae^D,ge=H+(U=ge+(ae=(Ce>>>6|Ce<<26)^(Ce>>>11|Ce<<21)^(Ce>>>25|Ce<<7))+(Ce&ce^~Ce&pe)+d[M+1]+Ne[M+1])|0,z=((H=U+(z+F)|0)>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10),F=(W=H&J)^H&Ee^Q,pe=Ae+(U=pe+(ae=(ge>>>6|ge<<26)^(ge>>>11|ge<<21)^(ge>>>25|ge<<7))+(ge&Ce^~ge&ce)+d[M+2]+Ne[M+2])|0,z=((Ae=U+(z+F)|0)>>>2|Ae<<30)^(Ae>>>13|Ae<<19)^(Ae>>>22|Ae<<10),F=(he=Ae&H)^Ae&J^W,ce=Ee+(U=ce+(ae=(pe>>>6|pe<<26)^(pe>>>11|pe<<21)^(pe>>>25|pe<<7))+(pe&ge^~pe&Ce)+d[M+3]+Ne[M+3])|0,Ee=U+(z+F)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+Ee|0,this.h1=this.h1+Ae|0,this.h2=this.h2+H|0,this.h3=this.h3+J|0,this.h4=this.h4+ce|0,this.h5=this.h5+pe|0,this.h6=this.h6+ge|0,this.h7=this.h7+Ce|0},q.prototype.hex=function(){this.finalize();var M=this.h0,z=this.h1,ae=this.h2,F=this.h3,U=this.h4,D=this.h5,Q=this.h6,W=this.h7,he=p[M>>>28&15]+p[M>>>24&15]+p[M>>>20&15]+p[M>>>16&15]+p[M>>>12&15]+p[M>>>8&15]+p[M>>>4&15]+p[15&M]+p[z>>>28&15]+p[z>>>24&15]+p[z>>>20&15]+p[z>>>16&15]+p[z>>>12&15]+p[z>>>8&15]+p[z>>>4&15]+p[15&z]+p[ae>>>28&15]+p[ae>>>24&15]+p[ae>>>20&15]+p[ae>>>16&15]+p[ae>>>12&15]+p[ae>>>8&15]+p[ae>>>4&15]+p[15&ae]+p[F>>>28&15]+p[F>>>24&15]+p[F>>>20&15]+p[F>>>16&15]+p[F>>>12&15]+p[F>>>8&15]+p[F>>>4&15]+p[15&F]+p[U>>>28&15]+p[U>>>24&15]+p[U>>>20&15]+p[U>>>16&15]+p[U>>>12&15]+p[U>>>8&15]+p[U>>>4&15]+p[15&U]+p[D>>>28&15]+p[D>>>24&15]+p[D>>>20&15]+p[D>>>16&15]+p[D>>>12&15]+p[D>>>8&15]+p[D>>>4&15]+p[15&D]+p[Q>>>28&15]+p[Q>>>24&15]+p[Q>>>20&15]+p[Q>>>16&15]+p[Q>>>12&15]+p[Q>>>8&15]+p[Q>>>4&15]+p[15&Q];return this.is224||(he+=p[W>>>28&15]+p[W>>>24&15]+p[W>>>20&15]+p[W>>>16&15]+p[W>>>12&15]+p[W>>>8&15]+p[W>>>4&15]+p[15&W]),he},q.prototype.toString=q.prototype.hex,q.prototype.digest=function(){this.finalize();var M=this.h0,z=this.h1,ae=this.h2,F=this.h3,U=this.h4,D=this.h5,Q=this.h6,W=this.h7,he=[M>>>24&255,M>>>16&255,M>>>8&255,255&M,z>>>24&255,z>>>16&255,z>>>8&255,255&z,ae>>>24&255,ae>>>16&255,ae>>>8&255,255&ae,F>>>24&255,F>>>16&255,F>>>8&255,255&F,U>>>24&255,U>>>16&255,U>>>8&255,255&U,D>>>24&255,D>>>16&255,D>>>8&255,255&D,Q>>>24&255,Q>>>16&255,Q>>>8&255,255&Q];return this.is224||he.push(W>>>24&255,W>>>16&255,W>>>8&255,255&W),he},q.prototype.array=q.prototype.digest,q.prototype.arrayBuffer=function(){this.finalize();var M=new ArrayBuffer(this.is224?28:32),z=new DataView(M);return z.setUint32(0,this.h0),z.setUint32(4,this.h1),z.setUint32(8,this.h2),z.setUint32(12,this.h3),z.setUint32(16,this.h4),z.setUint32(20,this.h5),z.setUint32(24,this.h6),this.is224||z.setUint32(28,this.h7),M},ne.prototype=new q,ne.prototype.finalize=function(){if(q.prototype.finalize.call(this),this.inner){this.inner=!1;var M=this.array();q.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(M),q.prototype.finalize.call(this)}};var te=_();te.sha256=te,te.sha224=_(!0),te.sha256.hmac=B(),te.sha224.hmac=B(!0),c?ed.exports=te:(s.sha256=te.sha256,s.sha224=te.sha224)})();ju.exports;ju.exports.sha224;var ib=ju.exports.sha256;function Nd(n){return qE(n)}function CE(n){if(!/^[0-9A-Fa-f]+$/.test(n))return!1;const s=/^[0-9A-F]+$/.test(n),i=/^[0-9a-f]+$/.test(n);return s||i?n.length%2===0:!1}function ME(n){return/^[A-Za-z0-9\-_]*(={0,2})?$/.test(n)||/^[A-Za-z0-9+/]*(={0,2})?$/.test(n)}function RE(n){return CE(n)?"hex":ME(n)?"b64":""}function DE(n){if(n.length%2!==0)throw new Error("hex string must have an even length");const e=new Uint8Array(n.length/2);for(let s=0;s<n.length;s+=2)e[s/2]=parseInt(n.substring(s,s+2),16);return e}function LE(n){n=n.replace(/-/g,"+"),n=n.replace(/_/g,"/");const e=atob(n);return Uint8Array.from(e,s=>s.charCodeAt(0))}function qE(n){switch(RE(n)){case"hex":return DE(n);case"b64":return LE(n)}return null}function PE(n,e){const s=typeof n=="string"?Nd(n):n,i=typeof e=="string"?Nd(e):e;if(s===null||i===null||s.length!==i.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==i[o])return!1;return!0}class wx{constructor(e,s,i=!0){j(this,"token");j(this,"received");j(this,"ctx");j(this,"requestSubject");j(this,"mux");this.mux=e,this.requestSubject=s,this.received=0,this.token=As.next(),i&&(this.ctx=new Error)}}class BE extends wx{constructor(s,i,o={maxWait:1e3}){super(s,i);j(this,"callback");j(this,"done");j(this,"timer");j(this,"max");j(this,"opts");if(this.opts=o,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof o.maxMessages=="number"&&o.maxMessages>0?o.maxMessages:-1,this.done=dt(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},o.maxWait)}cancel(s){s&&this.callback(s,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(s,i){s?(this.ctx&&(s.stack+=`
33
33
 
34
- ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,i),this.opts.strategy===Zn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Zn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Zn.SentinelMsg&&i&&i.data.length===0&&this.cancel())}}class Sx extends wx{constructor(s,i,o={timeout:1e3},c=!0){super(s,i,c);j(this,"deferred");j(this,"timer");this.deferred=mt(),this.timer=ra(o.timeout,c)}resolver(s,i){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
34
+ ${this.ctx.stack}`),this.cancel(s)):(this.callback(null,i),this.opts.strategy===Zn.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Zn.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Zn.SentinelMsg&&i&&i.data.length===0&&this.cancel())}}class Sx extends wx{constructor(s,i,o={timeout:1e3},c=!0){super(s,i,c);j(this,"deferred");j(this,"timer");this.deferred=dt(),this.timer=sa(o.timeout,c)}resolver(s,i){this.timer&&this.timer.cancel(),s?(this.ctx&&(s.stack+=`
35
35
 
36
- ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||ge.errorForCode(fe.Cancelled))}}const UE="$JS.API";function zE(n){return n=n||{},n.domain&&(n.apiPrefix=`$JS.${n.domain}.API`,delete n.domain),Ou({apiPrefix:UE,timeout:5e3},n)}class Ro{constructor(e,s){j(this,"nc");j(this,"opts");j(this,"prefix");j(this,"timeout");j(this,"jc");this.nc=e,this.opts=zE(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=er()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let e=this.opts.apiPrefix;if(!e||e.length===0)throw new Error("invalid empty prefix");e[e.length-1]==="."&&(e=e.substr(0,e.length-1)),this.opts.apiPrefix=e}async _request(e,s=null,i){i=i||{},i.timeout=this.timeout;let o=jn;s&&(o=this.jc.encode(s));let{retries:c}=i;c=c||1,c=c===-1?Number.MAX_SAFE_INTEGER:c;const m=cm();for(let p=0;p<c;p++)try{const g=await this.nc.request(e,o,i);return this.parseJsResponse(g)}catch(g){const u=g;if((u.code==="503"||u.code===fe.Timeout)&&p+1<c)await aa(m.backoff(p));else throw g}}async findStream(e){const s={subject:e},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(e){const s=this.jc.decode(e.data),i=s;if(i.error){const o=_x(i.error.code,i.error.description);if(o!==null)throw o.api_error=i.error,o}return s}}class bo{constructor(e,s,i,o){j(this,"err");j(this,"offset");j(this,"pageInfo");j(this,"subject");j(this,"jsm");j(this,"filter");j(this,"payload");if(!e)throw new Error("subject is required");this.subject=e,this.jsm=i,this.offset=0,this.pageInfo={},this.filter=s,this.payload=o||{}}async next(){if(this.err)return[];if(this.pageInfo&&this.offset>=this.pageInfo.total)return[];const e={offset:this.offset};this.payload&&Object.assign(e,this.payload);try{const s=await this.jsm._request(this.subject,e,{timeout:this.jsm.timeout});this.pageInfo=s;const i=this.countResponse(s);return i===0?[]:(this.offset+=i,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(e){var s,i,o;switch(e==null?void 0:e.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((s=e.streams)==null?void 0:s.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((i=e.consumers)==null?void 0:i.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${e==null?void 0:e.type}`),((o=e.streams)==null?void 0:o.length)||0}return 0}async*[Symbol.asyncIterator](){let e=await this.next();for(;e.length>0;){for(const s of e)yield s;e=await this.next()}}}function ti(n=""){const e=n.match(/(\d+).(\d+).(\d+)/);if(e)return{major:parseInt(e[1]),minor:parseInt(e[2]),micro:parseInt(e[3])};throw new Error(`'${n}' is not a semver value`)}function Td(n,e){return n.major<e.major?-1:n.major>e.major?1:n.minor<e.minor?-1:n.minor>e.minor?1:n.micro<e.micro?-1:n.micro>e.micro?1:0}var Ye;(function(n){n.JS_KV="js_kv",n.JS_OBJECTSTORE="js_objectstore",n.JS_PULL_MAX_BYTES="js_pull_max_bytes",n.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",n.JS_ALLOW_DIRECT="js_allow_direct",n.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",n.JS_SIMPLIFICATION="js_simplification",n.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",n.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",n.JS_STREAM_FIRST_SEQ="js_stream_first_seq",n.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",n.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",n.JS_STREAM_COMPRESSION="js_stream_compression",n.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",n.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Ye||(Ye={}));class IE{constructor(e){j(this,"server");j(this,"features");j(this,"disabled");this.features=new Map,this.disabled=[],this.update(e)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(e){this.disabled.push(e),this.update(this.server)}isDisabled(e){return this.disabled.indexOf(e)!==-1}update(e){typeof e=="string"&&(e=ti(e)),this.server=e,this.set(Ye.JS_KV,"2.6.2"),this.set(Ye.JS_OBJECTSTORE,"2.6.3"),this.set(Ye.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Ye.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Ye.JS_ALLOW_DIRECT,"2.9.0"),this.set(Ye.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Ye.JS_SIMPLIFICATION,"2.9.4"),this.set(Ye.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Ye.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Ye.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Ye.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ye.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ye.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Ye.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Ye.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(s=>{this.features.delete(s)})}set(e,s){this.features.set(e,{min:s,ok:Td(this.server,ti(s))>=0})}get(e){return this.features.get(e)||{min:"unknown",ok:!1}}supports(e){var s;return((s=this.get(e))==null?void 0:s.ok)||!1}require(e){return typeof e=="string"&&(e=ti(e)),Td(this.server,e)>=0}}class mu extends Ro{constructor(e,s){super(e,s)}async add(e,s,i=du.Create){if(Jt(e),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=e,o.action=i,o.config.durable_name&&Xi(o.config.durable_name);const c=this.nc;let{min:m,ok:p}=c.features.get(Ye.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!p)throw new Error(`consumer 'name' requires server ${m}`);if(g)try{Au("name",g)}catch(x){const v=x.message,_=v.indexOf("cannot contain");throw _!==-1?new Error(`consumer 'name' ${v.substring(_)}`):x}let u,d="";if(Array.isArray(s.filter_subjects)){const{min:x,ok:v}=c.features.get(Ye.JS_MULTIPLE_CONSUMER_FILTER);if(!v)throw new Error(`consumer 'filter_subjects' requires server ${x}`);p=!1}if(s.metadata){const{min:x,ok:v}=c.features.get(Ye.JS_STREAM_CONSUMER_METADATA);if(!v)throw new Error(`consumer 'metadata' requires server ${x}`)}if(p&&(d=s.name??s.durable_name??""),d!==""){let x=s.filter_subject??void 0;x===">"&&(x=void 0),u=x!==void 0?`${this.prefix}.CONSUMER.CREATE.${e}.${d}.${x}`:`${this.prefix}.CONSUMER.CREATE.${e}.${d}`}else u=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${e}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${e}`;return await this._request(u,o)}async update(e,s,i){const o=await this.info(e,s),c=i;return this.add(e,Object.assign(o.config,c),du.Update)}async info(e,s){return Jt(e),Xi(s),await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${s}`)}async delete(e,s){return Jt(e),Xi(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${s}`)).success}list(e){Jt(e);const s=o=>o.consumers,i=`${this.prefix}.CONSUMER.LIST.${e}`;return new bo(i,s,this)}pause(e,s,i){const o=`${this.prefix}.CONSUMER.PAUSE.${e}.${s}`,c={pause_until:i.toISOString()};return this._request(o,c)}resume(e,s){return this.pause(e,s,new Date(0))}}function $i(n,e,s=!1){if(s===!0&&!n)throw ge.errorForCode(fe.ApiError,new Error(`${e} is not a function`));if(n&&typeof n!="function")throw ge.errorForCode(fe.ApiError,new Error(`${e} is not a function`))}class $E extends Ut{constructor(s,i,o){super();j(this,"sub");j(this,"adapter");j(this,"subIterDone");$i(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&$i(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&($i(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&($i(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&($i(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&$i(o.cleanupFn,"cleanupFn");let c=(d,b)=>{this.callback(d,b)};if(o.callback){const d=o.callback;c=(b,x)=>{const[v,_]=this.adapter(b,x);if(v){d(v,null);return}const{ingest:S}=this.ingestionFilterFn?this.ingestionFilterFn(_,this):{ingest:!0};S&&(!this.protocolFilterFn||this.protocolFilterFn(_))&&(d(v,_),this.dispatchedFn&&_&&this.dispatchedFn(_))}}const{max:m,queue:p,timeout:g}=o,u={queue:p,timeout:g,callback:c};m&&m>0&&(u.max=m),this.sub=s.subscribe(i,u),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=mt(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async d=>{await d.closed,this.stop()})(this.sub).then().catch()}unsubscribe(s){this.sub.unsubscribe(s)}drain(){return this.sub.drain()}isDraining(){return this.sub.isDraining()}isClosed(){return this.sub.isClosed()}callback(s,i){this.sub.cancelTimeout();const[o,c]=this.adapter(s,i);o&&this.stop(o),c&&this.push(c)}getSubject(){return this.sub.getSubject()}getReceived(){return this.sub.getReceived()}getProcessed(){return this.sub.getProcessed()}getPending(){return this.sub.getPending()}getID(){return this.sub.getID()}getMax(){return this.sub.getMax()}get closed(){return this.sub.closed}}let On;function HE(n){On=n}function Ex(){return On!==void 0&&On.defaultPort!==void 0?On.defaultPort:4222}function td(){return On!==void 0&&On.urlParseFn?On.urlParseFn:void 0}function FE(){if(!On||typeof On.factory!="function")throw new Error("transport fn is not set");return On.factory()}function Cd(){return On!==void 0&&On.dnsResolveFn?On.dnsResolveFn:void 0}const ru=`\r
37
- `,pu=ia.fromAscii(ru),GE=new Uint8Array(pu)[0],VE=new Uint8Array(pu)[1];function YE(n){for(let e=0;e<n.length;e++){const s=e+1;if(n.byteLength>s&&n[e]===GE&&n[s]===VE)return s+1}return 0}function KE(n){const e=YE(n);if(e>0){const i=new Uint8Array(n).slice(0,e);return En.decode(i)}return""}const JE=4,Ox=48,QE=65,XE=97;function WE(n,e,s,i){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((m,p)=>{o[p]=m}),o[12]=n,o[13]=e,o[14]=s,o[15]=i,o}function Md(n){return ZE(n)!==void 0}function ZE(n){for(let e=0;e<n.length;e++)switch(n[e]){case".":return Ax(n);case":":return e2(n)}}function Ax(n){const e=new Uint8Array(4);for(let s=0;s<4;s++){if(n.length===0)return;if(s>0){if(n[0]!==".")return;n=n.substring(1)}const{n:i,c:o,ok:c}=t2(n);if(!c||i>255)return;n=n.substring(o),e[s]=i}return WE(e[0],e[1],e[2],e[3])}function e2(n){const e=new Uint8Array(16);let s=-1;if(n.length>=2&&n[0]===":"&&n[1]===":"&&(s=0,n=n.substring(2),n.length===0))return e;let i=0;for(;i<16;){const{n:o,c,ok:m}=n2(n);if(!m||o>65535)return;if(c<n.length&&n[c]==="."){if(s<0&&i!=12||i+4>16)return;const p=Ax(n);if(p===void 0)return;e[i]=p[12],e[i+1]=p[13],e[i+2]=p[14],e[i+3]=p[15],n="",i+=JE;break}if(e[i]=o>>8,e[i+1]=o,i+=2,n=n.substring(c),n.length===0)break;if(n[0]!==":"||n.length==1)return;if(n=n.substring(1),n[0]===":"){if(s>=0)return;if(s=i,n=n.substring(1),n.length===0)break}}if(n.length===0){if(i<16){if(s<0)return;const o=16-i;for(let c=i-1;c>=s;c--)e[c+o]=e[c];for(let c=s+o-1;c>=s;c--)e[c]=0}else if(s>=0)return;return e}}function t2(n){let e=0,s=0;for(e=0;e<n.length&&48<=n.charCodeAt(e)&&n.charCodeAt(e)<=57;e++)if(s=s*10+(n.charCodeAt(e)-Ox),s>=16777215)return{n:16777215,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:s,c:e,ok:!0}}function n2(n){let e=0,s=0;for(s=0;s<n.length;s++){if(48<=n.charCodeAt(s)&&n.charCodeAt(s)<=57)e*=16,e+=n.charCodeAt(s)-Ox;else if(97<=n.charCodeAt(s)&&n.charCodeAt(s)<=102)e*=16,e+=n.charCodeAt(s)-XE+10;else if(65<=n.charCodeAt(s)&&n.charCodeAt(s)<=70)e*=16,e+=n.charCodeAt(s)-QE+10;else break;if(e>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n:e,c:s,ok:!0}}function r2(n){return n.indexOf("[")!==-1||n.indexOf("::")!==-1?!1:n.indexOf(".")!==-1||n.split(":").length<=2}function Rd(n){return!r2(n)}function s2(n){const e="::FFFF:",s=n.toUpperCase().indexOf(e);if(s!==-1&&n.indexOf(".")!==-1){let i=n.substring(s+e.length);return i=i.replace("[",""),i.replace("]","")}return n}function i2(n){n=n.trim(),n.match(/^(.*:\/\/)(.*)/m)&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2")),n=s2(n),Rd(n)&&n.indexOf("[")===-1&&(n=`[${n}]`);const e=Rd(n)?n.match(/(]:)(\d+)/):n.match(/(:)(\d+)/),s=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):4222,i=s===80?"https":"http",o=new URL(`${i}://${n}`);o.port=`${s}`;let c=o.hostname;return c.charAt(0)==="["&&(c=c.substring(1,c.length-1)),{listen:o.host,hostname:c,port:s}}class wo{constructor(e,s=!1){j(this,"src");j(this,"listen");j(this,"hostname");j(this,"port");j(this,"didConnect");j(this,"reconnects");j(this,"lastConnect");j(this,"gossiped");j(this,"tlsName");j(this,"resolves");this.src=e,this.tlsName="";const i=i2(e);this.listen=i.listen,this.hostname=i.hostname,this.port=i.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(e){if(!e.fn||e.resolve===!1)return[this];const s=[];if(Md(this.hostname))return[this];{const i=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${i.join(",")}`);for(const o of i){const c=this.port===80?"https":"http",m=new URL(`${c}://${Rd(o)?"["+o+"]":o}`);m.port=`${this.port}`;const p=new wo(m.host,!1);p.tlsName=this.hostname,s.push(p)}}return e.randomize&&xx(s),this.resolves=s,s}}class a2{constructor(e=[],s={}){j(this,"firstSelect");j(this,"servers");j(this,"currentServer");j(this,"tlsName");j(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const i=td();e&&(e.forEach(o=>{o=i?i(o):o,this.servers.push(new wo(o))}),this.randomize&&(this.servers=xx(this.servers))),this.servers.length===0&&this.addServer(`${Sd}:${Ex()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();Md(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,s=!1){const i=td();e=i?i(e):e;const o=new wo(e,s);Md(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const e=this.servers.shift();return e&&(this.servers.push(e),this.currentServer=e),e}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(e){if(e){const s=this.servers.indexOf(e);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(e,s){const i=[];let o=[];const c=td(),m=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(g=>{g=c?c(g,s):g;const u=new wo(g,!0);m.set(g,u)});const p=[];return this.servers.forEach((g,u)=>{const d=g.listen;g.gossiped&&this.currentServer.listen!==d&&m.get(d)===void 0&&p.push(u),m.delete(d)}),p.reverse(),p.forEach(g=>{const u=this.servers.splice(g,1);o=o.concat(u[0].listen)}),m.forEach((g,u)=>{this.servers.push(g),i.push(u)}),{added:i,deleted:o}}}class o2{constructor(){j(this,"baseInbox");j(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${Lr(e)}.`,this.baseInbox}add(e){isNaN(e.received)||(e.received=0),this.reqs.set(e.token,e)}get(e){return this.reqs.get(e)}cancel(e){this.reqs.delete(e.token)}getToken(e){const s=e.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,s){if(s&&s.permissionContext){if(e)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const i=s.permissionContext;if(i.operation==="publish"){const o=this.all().find(c=>c.requestSubject===i.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(e,s)=>{const i=this.getToken(s);if(i){const o=this.get(i);o&&(e===null&&s.headers&&(e=vx(s)),o.resolver(e,s))}}}close(){const e=ge.errorForCode(fe.Timeout);this.reqs.forEach(s=>{s.resolver(e,{})})}}class l2{constructor(e,s,i){j(this,"ph");j(this,"interval");j(this,"maxOut");j(this,"timer");j(this,"pendings");this.ph=e,this.interval=s,this.maxOut=i,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:Qi.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=mt();this.ph.flush(e).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(e),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(e=>(e.resolve(),!1))}}class c2 extends Error{constructor(e){super(e),this.name="AssertionError"}}function u2(n,e="Assertion failed."){if(!n)throw new c2(e)}const ab=32*1024,nd=2**32-2;function oc(n,e,s=0){const i=e.byteLength-s;return n.byteLength>i&&(n=n.subarray(0,i)),e.set(n,s),n.byteLength}class rd{constructor(e){j(this,"_buf");j(this,"_off");if(this._off=0,e==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(e)}bytes(e={copy:!0}){return e.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(e){if(e===0){this.reset();return}if(e<0||e>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+e)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(e){const s=this._buf.byteLength;return e<=this.capacity-s?(this._reslice(s+e),s):-1}_reslice(e){u2(e<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,e)}readByte(){const e=new Uint8Array(1);return this.read(e)?e[0]:null}read(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;const s=oc(this._buf.subarray(this._off),e);return this._off+=s,s}writeByte(e){return this.write(Uint8Array.of(e))}writeString(e){return this.write(ri.encode(e))}write(e){const s=this._grow(e.byteLength);return oc(e,this._buf,s)}_grow(e){const s=this.length;s===0&&this._off!==0&&this.reset();const i=this._tryGrowByReslice(e);if(i>=0)return i;const o=this.capacity;if(e<=Math.floor(o/2)-s)oc(this._buf.subarray(this._off),this._buf);else{if(o+e>nd)throw new Error("The buffer cannot be grown beyond the maximum size.");{const c=new Uint8Array(Math.min(2*o+e,nd));oc(this._buf.subarray(this._off),c),this._buf=c}}return this._off=0,this._reslice(Math.min(s+e,nd)),s}grow(e){if(e<0)throw Error("Buffer._grow: negative count");const s=this._grow(e);this._reslice(s)}readFrom(e){let s=0;const i=new Uint8Array(ab);for(;;){const o=this.capacity-this.length<ab,c=o?i:new Uint8Array(this._buf.buffer,this.length),m=e.read(c);if(m===null)return s;o?this.write(c.subarray(0,m)):this._reslice(this.length+m),s+=m}}}var Qt;(function(n){n[n.OK=0]="OK",n[n.ERR=1]="ERR",n[n.MSG=2]="MSG",n[n.INFO=3]="INFO",n[n.PING=4]="PING",n[n.PONG=5]="PONG"})(Qt||(Qt={}));function ob(){const n={};return n.sid=-1,n.hdr=-1,n.size=-1,n}const f2=48;class lb{constructor(e){j(this,"dispatcher");j(this,"state");j(this,"as");j(this,"drop");j(this,"hdr");j(this,"ma");j(this,"argBuf");j(this,"msgBuf");this.dispatcher=e,this.state=de.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(e){let s;for(s=0;s<e.length;s++){const i=e[s];switch(this.state){case de.OP_START:switch(i){case me.M:case me.m:this.state=de.OP_M,this.hdr=-1,this.ma=ob();break;case me.H:case me.h:this.state=de.OP_H,this.hdr=0,this.ma=ob();break;case me.P:case me.p:this.state=de.OP_P;break;case me.PLUS:this.state=de.OP_PLUS;break;case me.MINUS:this.state=de.OP_MINUS;break;case me.I:case me.i:this.state=de.OP_I;break;default:throw this.fail(e.subarray(s))}break;case de.OP_H:switch(i){case me.M:case me.m:this.state=de.OP_M;break;default:throw this.fail(e.subarray(s))}break;case de.OP_M:switch(i){case me.S:case me.s:this.state=de.OP_MS;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MS:switch(i){case me.G:case me.g:this.state=de.OP_MSG;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MSG:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MSG_SPC;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MSG_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MSG_ARG,this.as=s}break;case de.MSG_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{const o=this.argBuf?this.argBuf.bytes():e.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=de.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;case de.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Qt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const c=e.length-s;c<o&&(o=c),o>0?(this.msgBuf.write(e.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(i)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Qt.MSG,msg:this.ma,data:e.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END);break;case de.MSG_END:switch(i){case me.NL:this.drop=0,this.as=s+1,this.state=de.OP_START;break;default:continue}break;case de.OP_PLUS:switch(i){case me.O:case me.o:this.state=de.OP_PLUS_O;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PLUS_O:switch(i){case me.K:case me.k:this.state=de.OP_PLUS_OK;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PLUS_OK:switch(i){case me.NL:this.dispatcher.push({kind:Qt.OK}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_MINUS:switch(i){case me.E:case me.e:this.state=de.OP_MINUS_E;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_E:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ER;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_ER:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ERR;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_ERR:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MINUS_ERR_SPC;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_ERR_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MINUS_ERR_ARG,this.as=s}break;case de.MINUS_ERR_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=e.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Qt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(i))}break;case de.OP_P:switch(i){case me.I:case me.i:this.state=de.OP_PI;break;case me.O:case me.o:this.state=de.OP_PO;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PO:switch(i){case me.N:case me.n:this.state=de.OP_PON;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PON:switch(i){case me.G:case me.g:this.state=de.OP_PONG;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PONG:switch(i){case me.NL:this.dispatcher.push({kind:Qt.PONG}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_PI:switch(i){case me.N:case me.n:this.state=de.OP_PIN;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PIN:switch(i){case me.G:case me.g:this.state=de.OP_PING;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PING:switch(i){case me.NL:this.dispatcher.push({kind:Qt.PING}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_I:switch(i){case me.N:case me.n:this.state=de.OP_IN;break;default:throw this.fail(e.subarray(s))}break;case de.OP_IN:switch(i){case me.F:case me.f:this.state=de.OP_INF;break;default:throw this.fail(e.subarray(s))}break;case de.OP_INF:switch(i){case me.O:case me.o:this.state=de.OP_INFO;break;default:throw this.fail(e.subarray(s))}break;case de.OP_INFO:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_INFO_SPC;break;default:throw this.fail(e.subarray(s))}break;case de.OP_INFO_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.INFO_ARG,this.as=s}break;case de.INFO_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=e.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Qt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;default:throw this.fail(e.subarray(s))}}(this.state===de.MSG_ARG||this.state===de.MINUS_ERR_ARG||this.state===de.INFO_ARG)&&!this.argBuf&&(this.argBuf=new rd(e.subarray(this.as,s-this.drop))),this.state===de.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new rd(e.subarray(this.as)))}cloneMsgArg(){const e=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,i=new Uint8Array(e+s);i.set(this.ma.subject),this.ma.reply&&i.set(this.ma.reply,e),this.argBuf=new rd(i),this.ma.subject=i.subarray(0,e),this.ma.reply&&(this.ma.reply=i.subarray(e))}processMsgArgs(e){if(this.hdr>=0)return this.processHeaderMsgArgs(e);const s=[];let i=-1;for(let o=0;o<e.length;o++)switch(e[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(e.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(e.subarray(i)),s.length){case 3:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(s[2]);break;case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.size=this.protoParseInt(s[3]);break;default:throw this.fail(e,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(e,"processMsgArgs Bad or Missing Size Error")}fail(e,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${En.decode(e)}`)}processHeaderMsgArgs(e){const s=[];let i=-1;for(let o=0;o<e.length;o++)switch(e[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(e.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(e.subarray(i)),s.length){case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(s[2]),this.ma.size=this.protoParseInt(s[3]);break;case 5:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.hdr=this.protoParseInt(s[3]),this.ma.size=this.protoParseInt(s[4]);break;default:throw this.fail(e,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(e){if(e.length===0)return-1;let s=0;for(let i=0;i<e.length;i++){if(e[i]<48||e[i]>57)return-1;s=s*10+(e[i]-f2)}return s}}var de;(function(n){n[n.OP_START=0]="OP_START",n[n.OP_PLUS=1]="OP_PLUS",n[n.OP_PLUS_O=2]="OP_PLUS_O",n[n.OP_PLUS_OK=3]="OP_PLUS_OK",n[n.OP_MINUS=4]="OP_MINUS",n[n.OP_MINUS_E=5]="OP_MINUS_E",n[n.OP_MINUS_ER=6]="OP_MINUS_ER",n[n.OP_MINUS_ERR=7]="OP_MINUS_ERR",n[n.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",n[n.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",n[n.OP_M=10]="OP_M",n[n.OP_MS=11]="OP_MS",n[n.OP_MSG=12]="OP_MSG",n[n.OP_MSG_SPC=13]="OP_MSG_SPC",n[n.MSG_ARG=14]="MSG_ARG",n[n.MSG_PAYLOAD=15]="MSG_PAYLOAD",n[n.MSG_END=16]="MSG_END",n[n.OP_H=17]="OP_H",n[n.OP_P=18]="OP_P",n[n.OP_PI=19]="OP_PI",n[n.OP_PIN=20]="OP_PIN",n[n.OP_PING=21]="OP_PING",n[n.OP_PO=22]="OP_PO",n[n.OP_PON=23]="OP_PON",n[n.OP_PONG=24]="OP_PONG",n[n.OP_I=25]="OP_I",n[n.OP_IN=26]="OP_IN",n[n.OP_INF=27]="OP_INF",n[n.OP_INFO=28]="OP_INFO",n[n.OP_INFO_SPC=29]="OP_INFO_SPC",n[n.INFO_ARG=30]="INFO_ARG"})(de||(de={}));var me;(function(n){n[n.CR=13]="CR",n[n.E=69]="E",n[n.e=101]="e",n[n.F=70]="F",n[n.f=102]="f",n[n.G=71]="G",n[n.g=103]="g",n[n.H=72]="H",n[n.h=104]="h",n[n.I=73]="I",n[n.i=105]="i",n[n.K=75]="K",n[n.k=107]="k",n[n.M=77]="M",n[n.m=109]="m",n[n.MINUS=45]="MINUS",n[n.N=78]="N",n[n.n=110]="n",n[n.NL=10]="NL",n[n.O=79]="O",n[n.o=111]="o",n[n.P=80]="P",n[n.p=112]="p",n[n.PLUS=43]="PLUS",n[n.R=82]="R",n[n.r=114]="r",n[n.S=83]="S",n[n.s=115]="s",n[n.SPACE=32]="SPACE",n[n.TAB=9]="TAB"})(me||(me={}));(function(n){var e=function(A,N){this.hi=A|0,this.lo=N|0},s=function(A){var N,k=new Float64Array(16);if(A)for(N=0;N<A.length;N++)k[N]=A[N];return k},i=function(){throw new Error("no PRNG")},o=new Uint8Array(16),c=new Uint8Array(32);c[0]=9;var m=s(),p=s([1]),g=s([56129,1]),u=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),x=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function _(A,N){return A<<N|A>>>32-N}function S(A,N){var k=A[N+3]&255;return k=k<<8|A[N+2]&255,k=k<<8|A[N+1]&255,k<<8|A[N+0]&255}function C(A,N){var k=A[N]<<24|A[N+1]<<16|A[N+2]<<8|A[N+3],T=A[N+4]<<24|A[N+5]<<16|A[N+6]<<8|A[N+7];return new e(k,T)}function B(A,N,k){var T;for(T=0;T<4;T++)A[N+T]=k&255,k>>>=8}function q(A,N,k){A[N]=k.hi>>24&255,A[N+1]=k.hi>>16&255,A[N+2]=k.hi>>8&255,A[N+3]=k.hi&255,A[N+4]=k.lo>>24&255,A[N+5]=k.lo>>16&255,A[N+6]=k.lo>>8&255,A[N+7]=k.lo&255}function ne(A,N,k,T,L){var $,se=0;for($=0;$<L;$++)se|=A[N+$]^k[T+$];return(1&se-1>>>8)-1}function te(A,N,k,T){return ne(A,N,k,T,16)}function M(A,N,k,T){return ne(A,N,k,T,32)}function z(A,N,k,T,L){var $=new Uint32Array(16),se=new Uint32Array(16),oe=new Uint32Array(16),K=new Uint32Array(4),re,xe,Be;for(re=0;re<4;re++)se[5*re]=S(T,4*re),se[1+re]=S(k,4*re),se[6+re]=S(N,4*re),se[11+re]=S(k,16+4*re);for(re=0;re<16;re++)oe[re]=se[re];for(re=0;re<20;re++){for(xe=0;xe<4;xe++){for(Be=0;Be<4;Be++)K[Be]=se[(5*xe+4*Be)%16];for(K[1]^=_(K[0]+K[3]|0,7),K[2]^=_(K[1]+K[0]|0,9),K[3]^=_(K[2]+K[1]|0,13),K[0]^=_(K[3]+K[2]|0,18),Be=0;Be<4;Be++)$[4*xe+(xe+Be)%4]=K[Be]}for(Be=0;Be<16;Be++)se[Be]=$[Be]}if(L){for(re=0;re<16;re++)se[re]=se[re]+oe[re]|0;for(re=0;re<4;re++)se[5*re]=se[5*re]-S(T,4*re)|0,se[6+re]=se[6+re]-S(N,4*re)|0;for(re=0;re<4;re++)B(A,4*re,se[5*re]),B(A,16+4*re,se[6+re])}else for(re=0;re<16;re++)B(A,4*re,se[re]+oe[re]|0)}function ae(A,N,k,T){return z(A,N,k,T,!1),0}function F(A,N,k,T){return z(A,N,k,T,!0),0}var U=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function D(A,N,k,T,L,$,se){var oe=new Uint8Array(16),K=new Uint8Array(64),re,xe;if(!L)return 0;for(xe=0;xe<16;xe++)oe[xe]=0;for(xe=0;xe<8;xe++)oe[xe]=$[xe];for(;L>=64;){for(ae(K,oe,se,U),xe=0;xe<64;xe++)A[N+xe]=(k?k[T+xe]:0)^K[xe];for(re=1,xe=8;xe<16;xe++)re=re+(oe[xe]&255)|0,oe[xe]=re&255,re>>>=8;L-=64,N+=64,k&&(T+=64)}if(L>0)for(ae(K,oe,se,U),xe=0;xe<L;xe++)A[N+xe]=(k?k[T+xe]:0)^K[xe];return 0}function X(A,N,k,T,L){return D(A,N,null,0,k,T,L)}function W(A,N,k,T,L){var $=new Uint8Array(32);return F($,T,L,U),X(A,N,k,T.subarray(16),$)}function he(A,N,k,T,L,$,se){var oe=new Uint8Array(32);return F(oe,$,se,U),D(A,N,k,T,L,$.subarray(16),oe)}function Se(A,N){var k,T=0;for(k=0;k<17;k++)T=T+(A[k]+N[k]|0)|0,A[k]=T&255,T>>>=8}var Ae=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function H(A,N,k,T,L,$){var se,oe,K,re,xe=new Uint32Array(17),Be=new Uint32Array(17),lt=new Uint32Array(17),Gt=new Uint32Array(17),Vn=new Uint32Array(17);for(K=0;K<17;K++)Be[K]=lt[K]=0;for(K=0;K<16;K++)Be[K]=$[K];for(Be[3]&=15,Be[4]&=252,Be[7]&=15,Be[8]&=252,Be[11]&=15,Be[12]&=252,Be[15]&=15;L>0;){for(K=0;K<17;K++)Gt[K]=0;for(K=0;K<16&&K<L;++K)Gt[K]=k[T+K];for(Gt[K]=1,T+=K,L-=K,Se(lt,Gt),oe=0;oe<17;oe++)for(xe[oe]=0,K=0;K<17;K++)xe[oe]=xe[oe]+lt[K]*(K<=oe?Be[oe-K]:320*Be[oe+17-K]|0)|0|0;for(oe=0;oe<17;oe++)lt[oe]=xe[oe];for(re=0,K=0;K<16;K++)re=re+lt[K]|0,lt[K]=re&255,re>>>=8;for(re=re+lt[16]|0,lt[16]=re&3,re=5*(re>>>2)|0,K=0;K<16;K++)re=re+lt[K]|0,lt[K]=re&255,re>>>=8;re=re+lt[16]|0,lt[16]=re}for(K=0;K<17;K++)Vn[K]=lt[K];for(Se(lt,Ae),se=-(lt[16]>>>7)|0,K=0;K<17;K++)lt[K]^=se&(Vn[K]^lt[K]);for(K=0;K<16;K++)Gt[K]=$[K+16];for(Gt[16]=0,Se(lt,Gt),K=0;K<16;K++)A[N+K]=lt[K];return 0}function J(A,N,k,T,L,$){var se=new Uint8Array(16);return H(se,0,k,T,L,$),te(A,N,se,0)}function le(A,N,k,T,L){var $;if(k<32)return-1;for(he(A,0,N,0,k,T,L),H(A,16,A,32,k-32,A),$=0;$<16;$++)A[$]=0;return 0}function pe(A,N,k,T,L){var $,se=new Uint8Array(32);if(k<32||(W(se,0,32,T,L),J(N,16,N,32,k-32,se)!==0))return-1;for(he(A,0,N,0,k,T,L),$=0;$<32;$++)A[$]=0;return 0}function ye(A,N){var k;for(k=0;k<16;k++)A[k]=N[k]|0}function Ce(A){var N,k;for(k=0;k<16;k++)A[k]+=65536,N=Math.floor(A[k]/65536),A[(k+1)*(k<15?1:0)]+=N-1+37*(N-1)*(k===15?1:0),A[k]-=N*65536}function Ne(A,N,k){for(var T,L=~(k-1),$=0;$<16;$++)T=L&(A[$]^N[$]),A[$]^=T,N[$]^=T}function Me(A,N){var k,T,L,$=s(),se=s();for(k=0;k<16;k++)se[k]=N[k];for(Ce(se),Ce(se),Ce(se),T=0;T<2;T++){for($[0]=se[0]-65517,k=1;k<15;k++)$[k]=se[k]-65535-($[k-1]>>16&1),$[k-1]&=65535;$[15]=se[15]-32767-($[14]>>16&1),L=$[15]>>16&1,$[14]&=65535,Ne(se,$,1-L)}for(k=0;k<16;k++)A[2*k]=se[k]&255,A[2*k+1]=se[k]>>8}function We(A,N){var k=new Uint8Array(32),T=new Uint8Array(32);return Me(k,A),Me(T,N),M(k,0,T,0)}function pt(A){var N=new Uint8Array(32);return Me(N,A),N[0]&1}function Ct(A,N){var k;for(k=0;k<16;k++)A[k]=N[2*k]+(N[2*k+1]<<8);A[15]&=32767}function Ee(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]+k[T]|0}function Re(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]-k[T]|0}function ce(A,N,k){var T,L,$=new Float64Array(31);for(T=0;T<31;T++)$[T]=0;for(T=0;T<16;T++)for(L=0;L<16;L++)$[T+L]+=N[T]*k[L];for(T=0;T<15;T++)$[T]+=38*$[T+16];for(T=0;T<16;T++)A[T]=$[T];Ce(A),Ce(A)}function Ue(A,N){ce(A,N,N)}function Xe(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=253;T>=0;T--)Ue(k,k),T!==2&&T!==4&&ce(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function un(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=250;T>=0;T--)Ue(k,k),T!==1&&ce(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function Mt(A,N,k){var T=new Uint8Array(32),L=new Float64Array(80),$,se,oe=s(),K=s(),re=s(),xe=s(),Be=s(),lt=s();for(se=0;se<31;se++)T[se]=N[se];for(T[31]=N[31]&127|64,T[0]&=248,Ct(L,k),se=0;se<16;se++)K[se]=L[se],xe[se]=oe[se]=re[se]=0;for(oe[0]=xe[0]=1,se=254;se>=0;--se)$=T[se>>>3]>>>(se&7)&1,Ne(oe,K,$),Ne(re,xe,$),Ee(Be,oe,re),Re(oe,oe,re),Ee(re,K,xe),Re(K,K,xe),Ue(xe,Be),Ue(lt,oe),ce(oe,re,oe),ce(re,K,Be),Ee(Be,oe,re),Re(oe,oe,re),Ue(K,oe),Re(re,xe,lt),ce(oe,re,g),Ee(oe,oe,xe),ce(re,re,oe),ce(oe,xe,lt),ce(xe,K,L),Ue(K,Be),Ne(oe,K,$),Ne(re,xe,$);for(se=0;se<16;se++)L[se+16]=oe[se],L[se+32]=re[se],L[se+48]=K[se],L[se+64]=xe[se];var Gt=L.subarray(32),Vn=L.subarray(16);return Xe(Gt,Gt),ce(Vn,Vn,Gt),Me(A,Vn),0}function be(A,N){return Mt(A,N,c)}function it(A,N){return i(N,32),be(A,N)}function yt(A,N,k){var T=new Uint8Array(32);return Mt(T,k,N),F(A,o,T,U)}var Ot=le,Ur=pe;function ca(A,N,k,T,L,$){var se=new Uint8Array(32);return yt(se,L,$),Ot(A,N,k,T,se)}function ua(A,N,k,T,L,$){var se=new Uint8Array(32);return yt(se,L,$),Ur(A,N,k,T,se)}function hr(){var A=0,N=0,k=0,T=0,L=65535,$,se,oe;for(oe=0;oe<arguments.length;oe++)$=arguments[oe].lo,se=arguments[oe].hi,A+=$&L,N+=$>>>16,k+=se&L,T+=se>>>16;return N+=A>>>16,k+=N>>>16,T+=k>>>16,new e(k&L|T<<16,A&L|N<<16)}function zo(A,N){return new e(A.hi>>>N,A.lo>>>N|A.hi<<32-N)}function si(){var A=0,N=0,k;for(k=0;k<arguments.length;k++)A^=arguments[k].lo,N^=arguments[k].hi;return new e(N,A)}function ft(A,N){var k,T,L=32-N;return N<32?(k=A.hi>>>N|A.lo<<L,T=A.lo>>>N|A.hi<<L):N<64&&(k=A.lo>>>N|A.hi<<L,T=A.hi>>>N|A.lo<<L),new e(k,T)}function Bu(A,N,k){var T=A.hi&N.hi^~A.hi&k.hi,L=A.lo&N.lo^~A.lo&k.lo;return new e(T,L)}function Io(A,N,k){var T=A.hi&N.hi^A.hi&k.hi^N.hi&k.hi,L=A.lo&N.lo^A.lo&k.lo^N.lo&k.lo;return new e(T,L)}function $o(A){return si(ft(A,28),ft(A,34),ft(A,39))}function ii(A){return si(ft(A,14),ft(A,18),ft(A,41))}function Uu(A){return si(ft(A,1),ft(A,8),zo(A,7))}function Ho(A){return si(ft(A,19),ft(A,61),zo(A,6))}var zu=[new e(1116352408,3609767458),new e(1899447441,602891725),new e(3049323471,3964484399),new e(3921009573,2173295548),new e(961987163,4081628472),new e(1508970993,3053834265),new e(2453635748,2937671579),new e(2870763221,3664609560),new e(3624381080,2734883394),new e(310598401,1164996542),new e(607225278,1323610764),new e(1426881987,3590304994),new e(1925078388,4068182383),new e(2162078206,991336113),new e(2614888103,633803317),new e(3248222580,3479774868),new e(3835390401,2666613458),new e(4022224774,944711139),new e(264347078,2341262773),new e(604807628,2007800933),new e(770255983,1495990901),new e(1249150122,1856431235),new e(1555081692,3175218132),new e(1996064986,2198950837),new e(2554220882,3999719339),new e(2821834349,766784016),new e(2952996808,2566594879),new e(3210313671,3203337956),new e(3336571891,1034457026),new e(3584528711,2466948901),new e(113926993,3758326383),new e(338241895,168717936),new e(666307205,1188179964),new e(773529912,1546045734),new e(1294757372,1522805485),new e(1396182291,2643833823),new e(1695183700,2343527390),new e(1986661051,1014477480),new e(2177026350,1206759142),new e(2456956037,344077627),new e(2730485921,1290863460),new e(2820302411,3158454273),new e(3259730800,3505952657),new e(3345764771,106217008),new e(3516065817,3606008344),new e(3600352804,1432725776),new e(4094571909,1467031594),new e(275423344,851169720),new e(430227734,3100823752),new e(506948616,1363258195),new e(659060556,3750685593),new e(883997877,3785050280),new e(958139571,3318307427),new e(1322822218,3812723403),new e(1537002063,2003034995),new e(1747873779,3602036899),new e(1955562222,1575990012),new e(2024104815,1125592928),new e(2227730452,2716904306),new e(2361852424,442776044),new e(2428436474,593698344),new e(2756734187,3733110249),new e(3204031479,2999351573),new e(3329325298,3815920427),new e(3391569614,3928383900),new e(3515267271,566280711),new e(3940187606,3454069534),new e(4118630271,4000239992),new e(116418474,1914138554),new e(174292421,2731055270),new e(289380356,3203993006),new e(460393269,320620315),new e(685471733,587496836),new e(852142971,1086792851),new e(1017036298,365543100),new e(1126000580,2618297676),new e(1288033470,3409855158),new e(1501505948,4234509866),new e(1607167915,987167468),new e(1816402316,1246189591)];function Fo(A,N,k){var T=[],L=[],$=[],se=[],oe,K,re;for(K=0;K<8;K++)T[K]=$[K]=C(A,8*K);for(var xe=0;k>=128;){for(K=0;K<16;K++)se[K]=C(N,8*K+xe);for(K=0;K<80;K++){for(re=0;re<8;re++)L[re]=$[re];for(oe=hr($[7],ii($[4]),Bu($[4],$[5],$[6]),zu[K],se[K%16]),L[7]=hr(oe,$o($[0]),Io($[0],$[1],$[2])),L[3]=hr(L[3],oe),re=0;re<8;re++)$[(re+1)%8]=L[re];if(K%16===15)for(re=0;re<16;re++)se[re]=hr(se[re],se[(re+9)%16],Uu(se[(re+1)%16]),Ho(se[(re+14)%16]))}for(K=0;K<8;K++)$[K]=hr($[K],T[K]),T[K]=$[K];xe+=128,k-=128}for(K=0;K<8;K++)q(A,8*K,T[K]);return k}var Ns=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 _t(A,N,k){var T=new Uint8Array(64),L=new Uint8Array(256),$,se=k;for($=0;$<64;$++)T[$]=Ns[$];for(Fo(T,N,k),k%=128,$=0;$<256;$++)L[$]=0;for($=0;$<k;$++)L[$]=N[se-k+$];for(L[k]=128,k=256-128*(k<112?1:0),L[k-9]=0,q(L,k-8,new e(se/536870912|0,se<<3)),Fo(T,L,k),$=0;$<64;$++)A[$]=T[$];return 0}function fn(A,N){var k=s(),T=s(),L=s(),$=s(),se=s(),oe=s(),K=s(),re=s(),xe=s();Re(k,A[1],A[0]),Re(xe,N[1],N[0]),ce(k,k,xe),Ee(T,A[0],A[1]),Ee(xe,N[0],N[1]),ce(T,T,xe),ce(L,A[3],N[3]),ce(L,L,d),ce($,A[2],N[2]),Ee($,$,$),Re(se,T,k),Re(oe,$,L),Ee(K,$,L),Ee(re,T,k),ce(A[0],se,oe),ce(A[1],re,K),ce(A[2],K,oe),ce(A[3],se,re)}function Ft(A,N,k){var T;for(T=0;T<4;T++)Ne(A[T],N[T],k)}function fa(A,N){var k=s(),T=s(),L=s();Xe(L,N[2]),ce(k,N[0],L),ce(T,N[1],L),Me(A,T),A[31]^=pt(k)<<7}function ha(A,N,k){var T,L;for(ye(A[0],m),ye(A[1],p),ye(A[2],p),ye(A[3],m),L=255;L>=0;--L)T=k[L/8|0]>>(L&7)&1,Ft(A,N,T),fn(N,A),fn(A,A),Ft(A,N,T)}function ai(A,N){var k=[s(),s(),s(),s()];ye(k[0],b),ye(k[1],x),ye(k[2],p),ce(k[3],b,x),ha(A,k,N)}function zr(A,N,k){var T=new Uint8Array(64),L=[s(),s(),s(),s()],$;for(k||i(N,32),_t(T,N,32),T[0]&=248,T[31]&=127,T[31]|=64,ai(L,T),fa(A,L),$=0;$<32;$++)N[$+32]=A[$];return 0}var dr=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 Ir(A,N){var k,T,L,$;for(T=63;T>=32;--T){for(k=0,L=T-32,$=T-12;L<$;++L)N[L]+=k-16*N[T]*dr[L-(T-32)],k=Math.floor((N[L]+128)/256),N[L]-=k*256;N[L]+=k,N[T]=0}for(k=0,L=0;L<32;L++)N[L]+=k-(N[31]>>4)*dr[L],k=N[L]>>8,N[L]&=255;for(L=0;L<32;L++)N[L]-=k*dr[L];for(T=0;T<32;T++)N[T+1]+=N[T]>>8,A[T]=N[T]&255}function Fn(A){var N=new Float64Array(64),k;for(k=0;k<64;k++)N[k]=A[k];for(k=0;k<64;k++)A[k]=0;Ir(A,N)}function Ts(A,N,k,T){var L=new Uint8Array(64),$=new Uint8Array(64),se=new Uint8Array(64),oe,K,re=new Float64Array(64),xe=[s(),s(),s(),s()];_t(L,T,32),L[0]&=248,L[31]&=127,L[31]|=64;var Be=k+64;for(oe=0;oe<k;oe++)A[64+oe]=N[oe];for(oe=0;oe<32;oe++)A[32+oe]=L[32+oe];for(_t(se,A.subarray(32),k+32),Fn(se),ai(xe,se),fa(A,xe),oe=32;oe<64;oe++)A[oe]=T[oe];for(_t($,A,k+64),Fn($),oe=0;oe<64;oe++)re[oe]=0;for(oe=0;oe<32;oe++)re[oe]=se[oe];for(oe=0;oe<32;oe++)for(K=0;K<32;K++)re[oe+K]+=$[oe]*L[K];return Ir(A.subarray(32),re),Be}function Cs(A,N){var k=s(),T=s(),L=s(),$=s(),se=s(),oe=s(),K=s();return ye(A[2],p),Ct(A[1],N),Ue(L,A[1]),ce($,L,u),Re(L,L,A[2]),Ee($,A[2],$),Ue(se,$),Ue(oe,se),ce(K,oe,se),ce(k,K,L),ce(k,k,$),un(k,k),ce(k,k,L),ce(k,k,$),ce(k,k,$),ce(A[0],k,$),Ue(T,A[0]),ce(T,T,$),We(T,L)&&ce(A[0],A[0],v),Ue(T,A[0]),ce(T,T,$),We(T,L)?-1:(pt(A[0])===N[31]>>7&&Re(A[0],m,A[0]),ce(A[3],A[0],A[1]),0)}function da(A,N,k,T){var L,$=new Uint8Array(32),se=new Uint8Array(64),oe=[s(),s(),s(),s()],K=[s(),s(),s(),s()];if(k<64||Cs(K,T))return-1;for(L=0;L<k;L++)A[L]=N[L];for(L=0;L<32;L++)A[L+32]=T[L];if(_t(se,A,k),Fn(se),ha(oe,K,se),ai(K,N.subarray(32)),fn(oe,K),fa($,oe),k-=64,M(N,0,$,0)){for(L=0;L<k;L++)A[L]=0;return-1}for(L=0;L<k;L++)A[L]=N[L+64];return k}var oi=32,$r=24,Gn=32,Hr=16,Fr=32,Ms=32,Gr=32,mr=32,Rs=32,ma=$r,Go=Gn,tr=Hr,at=64,gt=32,hn=64,Ds=32,pa=64;n.lowlevel={crypto_core_hsalsa20:F,crypto_stream_xor:he,crypto_stream:W,crypto_stream_salsa20_xor:D,crypto_stream_salsa20:X,crypto_onetimeauth:H,crypto_onetimeauth_verify:J,crypto_verify_16:te,crypto_verify_32:M,crypto_secretbox:le,crypto_secretbox_open:pe,crypto_scalarmult:Mt,crypto_scalarmult_base:be,crypto_box_beforenm:yt,crypto_box_afternm:Ot,crypto_box:ca,crypto_box_open:ua,crypto_box_keypair:it,crypto_hash:_t,crypto_sign:Ts,crypto_sign_keypair:zr,crypto_sign_open:da,crypto_secretbox_KEYBYTES:oi,crypto_secretbox_NONCEBYTES:$r,crypto_secretbox_ZEROBYTES:Gn,crypto_secretbox_BOXZEROBYTES:Hr,crypto_scalarmult_BYTES:Fr,crypto_scalarmult_SCALARBYTES:Ms,crypto_box_PUBLICKEYBYTES:Gr,crypto_box_SECRETKEYBYTES:mr,crypto_box_BEFORENMBYTES:Rs,crypto_box_NONCEBYTES:ma,crypto_box_ZEROBYTES:Go,crypto_box_BOXZEROBYTES:tr,crypto_sign_BYTES:at,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:hn,crypto_sign_SEEDBYTES:Ds,crypto_hash_BYTES:pa,gf:s,D:u,L:dr,pack25519:Me,unpack25519:Ct,M:ce,A:Ee,S:Ue,Z:Re,pow2523:un,add:fn,set25519:ye,modL:Ir,scalarmult:ha,scalarbase:ai};function Vo(A,N){if(A.length!==oi)throw new Error("bad key size");if(N.length!==$r)throw new Error("bad nonce size")}function Yo(A,N){if(A.length!==Gr)throw new Error("bad public key size");if(N.length!==mr)throw new Error("bad secret key size")}function Rt(){for(var A=0;A<arguments.length;A++)if(!(arguments[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function li(A){for(var N=0;N<A.length;N++)A[N]=0}n.randomBytes=function(A){var N=new Uint8Array(A);return i(N,A),N},n.secretbox=function(A,N,k){Rt(A,N,k),Vo(k,N);for(var T=new Uint8Array(Gn+A.length),L=new Uint8Array(T.length),$=0;$<A.length;$++)T[$+Gn]=A[$];return le(L,T,T.length,N,k),L.subarray(Hr)},n.secretbox.open=function(A,N,k){Rt(A,N,k),Vo(k,N);for(var T=new Uint8Array(Hr+A.length),L=new Uint8Array(T.length),$=0;$<A.length;$++)T[$+Hr]=A[$];return T.length<32||pe(L,T,T.length,N,k)!==0?null:L.subarray(Gn)},n.secretbox.keyLength=oi,n.secretbox.nonceLength=$r,n.secretbox.overheadLength=Hr,n.scalarMult=function(A,N){if(Rt(A,N),A.length!==Ms)throw new Error("bad n size");if(N.length!==Fr)throw new Error("bad p size");var k=new Uint8Array(Fr);return Mt(k,A,N),k},n.scalarMult.base=function(A){if(Rt(A),A.length!==Ms)throw new Error("bad n size");var N=new Uint8Array(Fr);return be(N,A),N},n.scalarMult.scalarLength=Ms,n.scalarMult.groupElementLength=Fr,n.box=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox(A,N,L)},n.box.before=function(A,N){Rt(A,N),Yo(A,N);var k=new Uint8Array(Rs);return yt(k,A,N),k},n.box.after=n.secretbox,n.box.open=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox.open(A,N,L)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var A=new Uint8Array(Gr),N=new Uint8Array(mr);return it(A,N),{publicKey:A,secretKey:N}},n.box.keyPair.fromSecretKey=function(A){if(Rt(A),A.length!==mr)throw new Error("bad secret key size");var N=new Uint8Array(Gr);return be(N,A),{publicKey:N,secretKey:new Uint8Array(A)}},n.box.publicKeyLength=Gr,n.box.secretKeyLength=mr,n.box.sharedKeyLength=Rs,n.box.nonceLength=ma,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(A,N){if(Rt(A,N),N.length!==hn)throw new Error("bad secret key size");var k=new Uint8Array(at+A.length);return Ts(k,A,A.length,N),k},n.sign.open=function(A,N){if(Rt(A,N),N.length!==gt)throw new Error("bad public key size");var k=new Uint8Array(A.length),T=da(k,A,A.length,N);if(T<0)return null;for(var L=new Uint8Array(T),$=0;$<L.length;$++)L[$]=k[$];return L},n.sign.detached=function(A,N){for(var k=n.sign(A,N),T=new Uint8Array(at),L=0;L<T.length;L++)T[L]=k[L];return T},n.sign.detached.verify=function(A,N,k){if(Rt(A,N,k),N.length!==at)throw new Error("bad signature size");if(k.length!==gt)throw new Error("bad public key size");var T=new Uint8Array(at+A.length),L=new Uint8Array(at+A.length),$;for($=0;$<at;$++)T[$]=N[$];for($=0;$<A.length;$++)T[$+at]=A[$];return da(L,T,T.length,k)>=0},n.sign.keyPair=function(){var A=new Uint8Array(gt),N=new Uint8Array(hn);return zr(A,N),{publicKey:A,secretKey:N}},n.sign.keyPair.fromSecretKey=function(A){if(Rt(A),A.length!==hn)throw new Error("bad secret key size");for(var N=new Uint8Array(gt),k=0;k<N.length;k++)N[k]=A[32+k];return{publicKey:N,secretKey:new Uint8Array(A)}},n.sign.keyPair.fromSeed=function(A){if(Rt(A),A.length!==Ds)throw new Error("bad seed size");for(var N=new Uint8Array(gt),k=new Uint8Array(hn),T=0;T<32;T++)k[T]=A[T];return zr(N,k,!0),{publicKey:N,secretKey:k}},n.sign.publicKeyLength=gt,n.sign.secretKeyLength=hn,n.sign.seedLength=Ds,n.sign.signatureLength=at,n.hash=function(A){Rt(A);var N=new Uint8Array(pa);return _t(N,A,A.length),N},n.hash.hashLength=pa,n.verify=function(A,N){return Rt(A,N),A.length===0||N.length===0||A.length!==N.length?!1:ne(A,0,N,0,A.length)===0},n.setPRNG=function(A){i=A},(function(){var A=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(A&&A.getRandomValues){var N=65536;n.setPRNG(function(k,T){var L,$=new Uint8Array(T);for(L=0;L<T;L+=N)A.getRandomValues($.subarray(L,L+Math.min(T-L,N)));for(L=0;L<T;L++)k[L]=$[L];li($)})}else typeof require<"u"&&(A=require("crypto"),A&&A.randomBytes&&n.setPRNG(function(k,T){var L,$=A.randomBytes(T);for(L=0;L<T;L++)k[L]=$[L];li($)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const lc=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;lc.sign.keyPair.fromSeed,lc.sign.detached,lc.sign.detached.verify,lc.randomBytes;var cb;(function(n){n.InvalidPrefixByte="nkeys: invalid prefix byte",n.InvalidKey="nkeys: invalid key",n.InvalidPublicKey="nkeys: invalid public key",n.InvalidSeedLen="nkeys: invalid seed length",n.InvalidSeed="nkeys: invalid seed",n.InvalidEncoding="nkeys: invalid encoded key",n.InvalidSignature="nkeys: signature verification failed",n.CannotSign="nkeys: cannot sign, no private key available",n.PublicKeyOnly="nkeys: no seed or private key available",n.InvalidChecksum="nkeys: invalid checksum",n.SerializationError="nkeys: serialization error",n.ApiError="nkeys: api error",n.ClearedPair="nkeys: pair is cleared"})(cb||(cb={}));var ub;(function(n){n[n.Seed=144]="Seed",n[n.Private=120]="Private",n[n.Operator=112]="Operator",n[n.Server=104]="Server",n[n.Cluster=16]="Cluster",n[n.Account=0]="Account",n[n.User=160]="User"})(ub||(ub={}));function h2(n){return e=>{let s={};return n.forEach(i=>{const o=i(e)||{};s=Object.assign(s,o)}),s}}function d2(){return()=>{}}function m2(n,e){return()=>{const s=typeof n=="function"?n():n,i=typeof e=="function"?e():e;return{user:s,pass:i}}}function p2(n){return()=>({auth_token:typeof n=="function"?n():n})}const jx=120*1e3,y2=2,kx=2*1e3;function g2(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:jx,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:kx,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function b2(n){const e=[];return typeof n.authenticator=="function"&&e.push(n.authenticator),Array.isArray(n.authenticator)&&e.push(...n.authenticator),n.token&&e.push(p2(n.token)),n.user&&e.push(m2(n.user,n.pass)),e.length===0?d2():h2(e)}function x2(n){const e=`${Sd}:${Ex()}`;if(n=n||{servers:[e]},n.servers=n.servers||[],typeof n.servers=="string"&&(n.servers=[n.servers]),n.servers.length>0&&n.port)throw new ge("port and servers options are mutually exclusive",fe.InvalidOption);n.servers.length===0&&n.port&&(n.servers=[`${Sd}:${n.port}`]),n.servers&&n.servers.length===0&&(n.servers=[e]);const s=Ou(g2(),n);if(s.authenticator=b2(s),["reconnectDelayHandler","authenticator"].forEach(i=>{if(s[i]&&typeof s[i]!="function")throw new ge(`${i} option should be a function`,fe.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let i=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return i&&(i++,i=Math.floor(Math.random()*i)),s.reconnectTimeWait+i}),s.inboxPrefix)try{Lr(s.inboxPrefix)}catch(i){throw new ge(i.message,fe.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Cd()=="function"),s.resolve&&typeof Cd()!="function")throw new ge("'resolve' is not supported on this client",fe.InvalidOption);return s}function v2(n,e){const{proto:s,tls_required:i,tls_available:o}=n;if((s===void 0||s<1)&&e.noEcho)throw new ge("noEcho",fe.ServerOptionNotAvailable);const c=i||o||!1;if(e.tls&&!c)throw new ge("tls",fe.ServerOptionNotAvailable)}const _2=1024*32,w2=/^INFO\s+([^\r\n]+)\r\n/i,S2=vo(`PONG\r
38
- `),fb=vo(`PING\r
39
- `);class E2{constructor(e,s,i){j(this,"echo");j(this,"no_responders");j(this,"protocol");j(this,"verbose");j(this,"pedantic");j(this,"jwt");j(this,"nkey");j(this,"sig");j(this,"user");j(this,"pass");j(this,"auth_token");j(this,"tls_required");j(this,"name");j(this,"lang");j(this,"version");j(this,"headers");this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=s.noEcho?!1:void 0,this.verbose=s.verbose,this.pedantic=s.pedantic,this.tls_required=s.tls?!0:void 0,this.name=s.name;const o=(s&&typeof s.authenticator=="function"?s.authenticator(i):{})||{};Ou(this,o)}}class Nx extends Ut{constructor(s,i,o={}){var m;super();j(this,"sid");j(this,"queue");j(this,"draining");j(this,"max");j(this,"subject");j(this,"drained");j(this,"protocol");j(this,"timer");j(this,"info");j(this,"cleanupFn");j(this,"closed");j(this,"requestSubject");Ou(this,o),this.protocol=s,this.subject=i,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=mt();const c=!((m=s.options)!=null&&m.noAsyncTraces);o.timeout&&(this.timer=ra(o.timeout,c),this.timer.then(()=>{this.timer=void 0}).catch(p=>{this.stop(p),this.noIterator&&this.callback(p,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const i=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),c=s.protocolFilterFn?s.protocolFilterFn:()=>!0,m=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(p,g)=>{const{ingest:u}=o(g);u&&c(g)&&(i(p,g),m(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,i){this.cancelTimeout(),s?this.stop(s):this.push(i)}close(){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve()};this.noIterator?s():this.push(s)}}unsubscribe(s){this.protocol.unsubscribe(this,s)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isClosed()?Promise.reject(ge.errorForCode(fe.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(mt()).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 O2{constructor(){j(this,"mux");j(this,"subs");j(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(e){return this.sidCounter++,e.sid=this.sidCounter,this.subs.set(e.sid,e),e}setMux(e){return this.mux=e,e}getMux(){return this.mux}get(e){return this.subs.get(e)}resub(e){return this.sidCounter++,this.subs.delete(e.sid),e.sid=this.sidCounter,this.subs.set(e.sid,e),e}all(){return Array.from(this.subs.values())}cancel(e){e&&(e.close(),this.subs.delete(e.sid))}handleError(e){if(e&&e.permissionContext){const s=e.permissionContext,i=this.all();let o;if(s.operation==="subscription"&&(o=i.find(c=>c.subject===s.subject&&c.queue===s.queue)),s.operation==="publish"&&(o=i.find(c=>c.requestSubject===s.subject)),o)return o.callback(e,{}),o.close(),this.subs.delete(o.sid),o!==this.mux}return!1}close(){this.subs.forEach(e=>{e.close()})}}class yu{constructor(e,s){j(this,"connected");j(this,"connectedOnce");j(this,"infoReceived");j(this,"info");j(this,"muxSubscriptions");j(this,"options");j(this,"outbound");j(this,"pongs");j(this,"subscriptions");j(this,"transport");j(this,"noMorePublishing");j(this,"connectError");j(this,"publisher");j(this,"_closed");j(this,"closed");j(this,"listeners");j(this,"heartbeats");j(this,"parser");j(this,"outMsgs");j(this,"inMsgs");j(this,"outBytes");j(this,"inBytes");j(this,"pendingLimit");j(this,"lastError");j(this,"abortReconnect");j(this,"whyClosed");j(this,"servers");j(this,"server");j(this,"features");j(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=_2,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=s,this.subscriptions=new O2,this.muxSubscriptions=new o2,this.outbound=new ia,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new IE({major:0,minor:0,micro:0}),this.connectPromise=null;const i=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new a2(i,{randomize:!e.noRandomize}),this.closed=mt(),this.parser=new lb(this),this.heartbeats=new l2(this,this.options.pingInterval||jx,this.options.maxPingOut||y2)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const s=ge.errorForCode(fe.Disconnect);s.stack="",e.forEach(i=>{i.reject(s)}),this.parser=new lb(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(s=>{s.push(e)})}status(){const e=new Ut;return this.listeners.push(e),e}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const e=mt();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=s=>{e.reject(s)},this.transport=FE(),this.transport.closed().then(async s=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),e}disconnect(){this.dispatchStatus({type:Qi.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Qi.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:Dr.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:Dr.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===fe.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(e)}async dial(e){const s=this.prepare();let i;try{i=ra(this.options.timeout||2e4);const o=this.transport.connect(e,this.options);await Promise.race([o,i]),(async()=>{try{for await(const c of this.transport)this.parser.parse(c)}catch(c){console.log("reader closed",c)}})().then()}catch(o){s.reject(o)}try{await Promise.race([i,s]),i&&i.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(o){throw i&&i.cancel(),await this.transport.close(o),o}}async _doDial(e){const{resolve:s}=this.options,i=await e.resolve({fn:Cd(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const c of i)try{o=null,this.dispatchStatus({type:Qi.Reconnecting,data:c.toString()}),await this.dial(c);return}catch(m){o=m}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let e;for(;;){this._closed&&this.servers.clear();const s=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():kx;let i=s;const o=this.selectServer();if(!o||this.abortReconnect)throw e||(this.lastError?this.lastError:ge.errorForCode(fe.ConnectionRefused));const c=Date.now();if(o.lastConnect===0||o.lastConnect+s<=c){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(m){if(e=m,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const p=this.options.maxReconnectAttempts||0;p!==-1&&o.reconnects>=p&&this.servers.removeCurrentServer()}}else i=Math.min(i,o.lastConnect+s-c),await aa(i)}}static async connect(e,s){const i=new yu(e,s);return await i.dialLoop(),i}static toError(e){const s=e?e.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const i=new ge(e,fe.PermissionsViolation),o=e.match(/(Publish|Subscription) to "(\S+)"/);if(o){i.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const c=e.match(/using queue "(\S+)"/);c&&(i.permissionContext.queue=c[1])}return i}else return s.indexOf("authorization violation")!==-1?new ge(e,fe.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new ge(e,fe.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new ge(e,fe.AccountExpired):s.indexOf("authentication timeout")!==-1?new ge(e,fe.AuthenticationTimeout):new ge(e,fe.ProtocolError)}processMsg(e,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const i=this.subscriptions.get(e.sid);i&&(i.received+=1,i.callback&&i.callback(null,new fm(e,s,this)),i.max!==void 0&&i.received>=i.max&&i.unsubscribe())}processError(e){const s=Yg(e),i=yu.toError(s),o={type:Dr.Error,data:i.code};if(i.isPermissionError()){let c=!1;if(i.permissionContext){o.permissionContext=i.permissionContext;const m=this.subscriptions.getMux();c=(m==null?void 0:m.subject)===i.permissionContext.subject}this.subscriptions.handleError(i),this.muxSubscriptions.handleError(c,i),c&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(i)}handleError(e){e.isAuthError()?this.handleAuthError(e):e.isProtocolError()?this.lastError=e:e.isAuthTimeout()&&(this.lastError=e),e.isPermissionError()||(this.lastError=e)}handleAuthError(e){this.lastError&&e.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(S2)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const s=JSON.parse(Yg(e));this.info=s;const i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(ti(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:c,lang:m}=this.transport;try{const p=new E2({version:c,lang:m},this.options,s.nonce);s.headers&&(p.headers=!0,p.no_responders=!0);const g=JSON.stringify(p);this.transport.send(vo(`CONNECT ${g}${ru}`)),this.transport.send(fb)}catch(p){this._close(p)}}i&&this.dispatchStatus({type:Dr.Update,data:i}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:Dr.LDM,data:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case Qt.MSG:{const{msg:s,data:i}=e;this.processMsg(s,i);break}case Qt.OK:break;case Qt.ERR:this.processError(e.data);break;case Qt.PING:this.processPing();break;case Qt.PONG:this.processPong();break;case Qt.INFO:this.processInfo(e.data);break}}sendCommand(e,...s){const i=this.outbound.length();let o;typeof e=="string"?o=vo(e):o=e,this.outbound.fill(o,...s),i===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,s=jn,i){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=ri.encode(s);else throw ge.errorForCode(fe.BadPayload);let c=o.length;i=i||{},i.reply=i.reply||"";let m=jn,p=0;if(i.headers){if(this.info&&!this.info.headers)throw new ge("headers",fe.ServerOptionNotAvailable);m=i.headers.encode(),p=m.length,c=o.length+p}if(this.info&&c>this.info.max_payload)throw ge.errorForCode(fe.MaxPayloadExceeded);this.outBytes+=c,this.outMsgs++;let g;i.headers?(i.reply?g=`HPUB ${e} ${i.reply} ${p} ${c}\r
36
+ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cancel()}cancel(s){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(s||be.errorForCode(fe.Cancelled))}}const UE="$JS.API";function zE(n){return n=n||{},n.domain&&(n.apiPrefix=`$JS.${n.domain}.API`,delete n.domain),Ou({apiPrefix:UE,timeout:5e3},n)}class Ro{constructor(e,s){j(this,"nc");j(this,"opts");j(this,"prefix");j(this,"timeout");j(this,"jc");this.nc=e,this.opts=zE(s),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=er()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let e=this.opts.apiPrefix;if(!e||e.length===0)throw new Error("invalid empty prefix");e[e.length-1]==="."&&(e=e.substr(0,e.length-1)),this.opts.apiPrefix=e}async _request(e,s=null,i){i=i||{},i.timeout=this.timeout;let o=jn;s&&(o=this.jc.encode(s));let{retries:c}=i;c=c||1,c=c===-1?Number.MAX_SAFE_INTEGER:c;const m=cm();for(let p=0;p<c;p++)try{const g=await this.nc.request(e,o,i);return this.parseJsResponse(g)}catch(g){const u=g;if((u.code==="503"||u.code===fe.Timeout)&&p+1<c)await oa(m.backoff(p));else throw g}}async findStream(e){const s={subject:e},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(e){const s=this.jc.decode(e.data),i=s;if(i.error){const o=_x(i.error.code,i.error.description);if(o!==null)throw o.api_error=i.error,o}return s}}class xo{constructor(e,s,i,o){j(this,"err");j(this,"offset");j(this,"pageInfo");j(this,"subject");j(this,"jsm");j(this,"filter");j(this,"payload");if(!e)throw new Error("subject is required");this.subject=e,this.jsm=i,this.offset=0,this.pageInfo={},this.filter=s,this.payload=o||{}}async next(){if(this.err)return[];if(this.pageInfo&&this.offset>=this.pageInfo.total)return[];const e={offset:this.offset};this.payload&&Object.assign(e,this.payload);try{const s=await this.jsm._request(this.subject,e,{timeout:this.jsm.timeout});this.pageInfo=s;const i=this.countResponse(s);return i===0?[]:(this.offset+=i,this.filter(s))}catch(s){throw this.err=s,s}}countResponse(e){var s,i,o;switch(e==null?void 0:e.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return((s=e.streams)==null?void 0:s.length)||0;case"io.nats.jetstream.api.v1.consumer_list_response":return((i=e.consumers)==null?void 0:i.length)||0;default:return console.error(`jslister.ts: unknown API response for paged output: ${e==null?void 0:e.type}`),((o=e.streams)==null?void 0:o.length)||0}return 0}async*[Symbol.asyncIterator](){let e=await this.next();for(;e.length>0;){for(const s of e)yield s;e=await this.next()}}}function ti(n=""){const e=n.match(/(\d+).(\d+).(\d+)/);if(e)return{major:parseInt(e[1]),minor:parseInt(e[2]),micro:parseInt(e[3])};throw new Error(`'${n}' is not a semver value`)}function Td(n,e){return n.major<e.major?-1:n.major>e.major?1:n.minor<e.minor?-1:n.minor>e.minor?1:n.micro<e.micro?-1:n.micro>e.micro?1:0}var Ve;(function(n){n.JS_KV="js_kv",n.JS_OBJECTSTORE="js_objectstore",n.JS_PULL_MAX_BYTES="js_pull_max_bytes",n.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",n.JS_ALLOW_DIRECT="js_allow_direct",n.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",n.JS_SIMPLIFICATION="js_simplification",n.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",n.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",n.JS_STREAM_FIRST_SEQ="js_stream_first_seq",n.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",n.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",n.JS_STREAM_COMPRESSION="js_stream_compression",n.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits",n.JS_BATCH_DIRECT_GET="js_batch_direct_get"})(Ve||(Ve={}));class IE{constructor(e){j(this,"server");j(this,"features");j(this,"disabled");this.features=new Map,this.disabled=[],this.update(e)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(e){this.disabled.push(e),this.update(this.server)}isDisabled(e){return this.disabled.indexOf(e)!==-1}update(e){typeof e=="string"&&(e=ti(e)),this.server=e,this.set(Ve.JS_KV,"2.6.2"),this.set(Ve.JS_OBJECTSTORE,"2.6.3"),this.set(Ve.JS_PULL_MAX_BYTES,"2.8.3"),this.set(Ve.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(Ve.JS_ALLOW_DIRECT,"2.9.0"),this.set(Ve.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(Ve.JS_SIMPLIFICATION,"2.9.4"),this.set(Ve.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(Ve.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(Ve.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(Ve.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ve.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(Ve.JS_STREAM_COMPRESSION,"2.10.0"),this.set(Ve.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(Ve.JS_BATCH_DIRECT_GET,"2.11.0"),this.disabled.forEach(s=>{this.features.delete(s)})}set(e,s){this.features.set(e,{min:s,ok:Td(this.server,ti(s))>=0})}get(e){return this.features.get(e)||{min:"unknown",ok:!1}}supports(e){var s;return((s=this.get(e))==null?void 0:s.ok)||!1}require(e){return typeof e=="string"&&(e=ti(e)),Td(this.server,e)>=0}}class mu extends Ro{constructor(e,s){super(e,s)}async add(e,s,i=du.Create){if(Qt(e),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=e,o.action=i,o.config.durable_name&&Xi(o.config.durable_name);const c=this.nc;let{min:m,ok:p}=c.features.get(Ve.JS_NEW_CONSUMER_CREATE_API);const g=s.name===""?void 0:s.name;if(g&&!p)throw new Error(`consumer 'name' requires server ${m}`);if(g)try{Au("name",g)}catch(x){const v=x.message,_=v.indexOf("cannot contain");throw _!==-1?new Error(`consumer 'name' ${v.substring(_)}`):x}let u,d="";if(Array.isArray(s.filter_subjects)){const{min:x,ok:v}=c.features.get(Ve.JS_MULTIPLE_CONSUMER_FILTER);if(!v)throw new Error(`consumer 'filter_subjects' requires server ${x}`);p=!1}if(s.metadata){const{min:x,ok:v}=c.features.get(Ve.JS_STREAM_CONSUMER_METADATA);if(!v)throw new Error(`consumer 'metadata' requires server ${x}`)}if(p&&(d=s.name??s.durable_name??""),d!==""){let x=s.filter_subject??void 0;x===">"&&(x=void 0),u=x!==void 0?`${this.prefix}.CONSUMER.CREATE.${e}.${d}.${x}`:`${this.prefix}.CONSUMER.CREATE.${e}.${d}`}else u=s.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${e}.${s.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${e}`;return await this._request(u,o)}async update(e,s,i){const o=await this.info(e,s),c=i;return this.add(e,Object.assign(o.config,c),du.Update)}async info(e,s){return Qt(e),Xi(s),await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${s}`)}async delete(e,s){return Qt(e),Xi(s),(await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${s}`)).success}list(e){Qt(e);const s=o=>o.consumers,i=`${this.prefix}.CONSUMER.LIST.${e}`;return new xo(i,s,this)}pause(e,s,i){const o=`${this.prefix}.CONSUMER.PAUSE.${e}.${s}`,c={pause_until:i.toISOString()};return this._request(o,c)}resume(e,s){return this.pause(e,s,new Date(0))}}function $i(n,e,s=!1){if(s===!0&&!n)throw be.errorForCode(fe.ApiError,new Error(`${e} is not a function`));if(n&&typeof n!="function")throw be.errorForCode(fe.ApiError,new Error(`${e} is not a function`))}class $E extends Ut{constructor(s,i,o){super();j(this,"sub");j(this,"adapter");j(this,"subIterDone");$i(o.adapter,"adapter",!0),this.adapter=o.adapter,o.callback&&$i(o.callback,"callback"),this.noIterator=typeof o.callback=="function",o.ingestionFilterFn&&($i(o.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=o.ingestionFilterFn),o.protocolFilterFn&&($i(o.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=o.protocolFilterFn),o.dispatchedFn&&($i(o.dispatchedFn,"dispatchedFn"),this.dispatchedFn=o.dispatchedFn),o.cleanupFn&&$i(o.cleanupFn,"cleanupFn");let c=(d,b)=>{this.callback(d,b)};if(o.callback){const d=o.callback;c=(b,x)=>{const[v,_]=this.adapter(b,x);if(v){d(v,null);return}const{ingest:S}=this.ingestionFilterFn?this.ingestionFilterFn(_,this):{ingest:!0};S&&(!this.protocolFilterFn||this.protocolFilterFn(_))&&(d(v,_),this.dispatchedFn&&_&&this.dispatchedFn(_))}}const{max:m,queue:p,timeout:g}=o,u={queue:p,timeout:g,callback:c};m&&m>0&&(u.max=m),this.sub=s.subscribe(i,u),o.cleanupFn&&(this.sub.cleanupFn=o.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=dt(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async d=>{await d.closed,this.stop()})(this.sub).then().catch()}unsubscribe(s){this.sub.unsubscribe(s)}drain(){return this.sub.drain()}isDraining(){return this.sub.isDraining()}isClosed(){return this.sub.isClosed()}callback(s,i){this.sub.cancelTimeout();const[o,c]=this.adapter(s,i);o&&this.stop(o),c&&this.push(c)}getSubject(){return this.sub.getSubject()}getReceived(){return this.sub.getReceived()}getProcessed(){return this.sub.getProcessed()}getPending(){return this.sub.getPending()}getID(){return this.sub.getID()}getMax(){return this.sub.getMax()}get closed(){return this.sub.closed}}let On;function HE(n){On=n}function Ex(){return On!==void 0&&On.defaultPort!==void 0?On.defaultPort:4222}function td(){return On!==void 0&&On.urlParseFn?On.urlParseFn:void 0}function FE(){if(!On||typeof On.factory!="function")throw new Error("transport fn is not set");return On.factory()}function Cd(){return On!==void 0&&On.dnsResolveFn?On.dnsResolveFn:void 0}const ru=`\r
37
+ `,pu=aa.fromAscii(ru),GE=new Uint8Array(pu)[0],VE=new Uint8Array(pu)[1];function YE(n){for(let e=0;e<n.length;e++){const s=e+1;if(n.byteLength>s&&n[e]===GE&&n[s]===VE)return s+1}return 0}function KE(n){const e=YE(n);if(e>0){const i=new Uint8Array(n).slice(0,e);return En.decode(i)}return""}const JE=4,Ox=48,QE=65,XE=97;function WE(n,e,s,i){const o=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((m,p)=>{o[p]=m}),o[12]=n,o[13]=e,o[14]=s,o[15]=i,o}function Md(n){return ZE(n)!==void 0}function ZE(n){for(let e=0;e<n.length;e++)switch(n[e]){case".":return Ax(n);case":":return e2(n)}}function Ax(n){const e=new Uint8Array(4);for(let s=0;s<4;s++){if(n.length===0)return;if(s>0){if(n[0]!==".")return;n=n.substring(1)}const{n:i,c:o,ok:c}=t2(n);if(!c||i>255)return;n=n.substring(o),e[s]=i}return WE(e[0],e[1],e[2],e[3])}function e2(n){const e=new Uint8Array(16);let s=-1;if(n.length>=2&&n[0]===":"&&n[1]===":"&&(s=0,n=n.substring(2),n.length===0))return e;let i=0;for(;i<16;){const{n:o,c,ok:m}=n2(n);if(!m||o>65535)return;if(c<n.length&&n[c]==="."){if(s<0&&i!=12||i+4>16)return;const p=Ax(n);if(p===void 0)return;e[i]=p[12],e[i+1]=p[13],e[i+2]=p[14],e[i+3]=p[15],n="",i+=JE;break}if(e[i]=o>>8,e[i+1]=o,i+=2,n=n.substring(c),n.length===0)break;if(n[0]!==":"||n.length==1)return;if(n=n.substring(1),n[0]===":"){if(s>=0)return;if(s=i,n=n.substring(1),n.length===0)break}}if(n.length===0){if(i<16){if(s<0)return;const o=16-i;for(let c=i-1;c>=s;c--)e[c+o]=e[c];for(let c=s+o-1;c>=s;c--)e[c]=0}else if(s>=0)return;return e}}function t2(n){let e=0,s=0;for(e=0;e<n.length&&48<=n.charCodeAt(e)&&n.charCodeAt(e)<=57;e++)if(s=s*10+(n.charCodeAt(e)-Ox),s>=16777215)return{n:16777215,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:s,c:e,ok:!0}}function n2(n){let e=0,s=0;for(s=0;s<n.length;s++){if(48<=n.charCodeAt(s)&&n.charCodeAt(s)<=57)e*=16,e+=n.charCodeAt(s)-Ox;else if(97<=n.charCodeAt(s)&&n.charCodeAt(s)<=102)e*=16,e+=n.charCodeAt(s)-XE+10;else if(65<=n.charCodeAt(s)&&n.charCodeAt(s)<=70)e*=16,e+=n.charCodeAt(s)-QE+10;else break;if(e>=16777215)return{n:0,c:s,ok:!1}}return s===0?{n:0,c:s,ok:!1}:{n:e,c:s,ok:!0}}function r2(n){return n.indexOf("[")!==-1||n.indexOf("::")!==-1?!1:n.indexOf(".")!==-1||n.split(":").length<=2}function Rd(n){return!r2(n)}function s2(n){const e="::FFFF:",s=n.toUpperCase().indexOf(e);if(s!==-1&&n.indexOf(".")!==-1){let i=n.substring(s+e.length);return i=i.replace("[",""),i.replace("]","")}return n}function i2(n){n=n.trim(),n.match(/^(.*:\/\/)(.*)/m)&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2")),n=s2(n),Rd(n)&&n.indexOf("[")===-1&&(n=`[${n}]`);const e=Rd(n)?n.match(/(]:)(\d+)/):n.match(/(:)(\d+)/),s=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):4222,i=s===80?"https":"http",o=new URL(`${i}://${n}`);o.port=`${s}`;let c=o.hostname;return c.charAt(0)==="["&&(c=c.substring(1,c.length-1)),{listen:o.host,hostname:c,port:s}}class So{constructor(e,s=!1){j(this,"src");j(this,"listen");j(this,"hostname");j(this,"port");j(this,"didConnect");j(this,"reconnects");j(this,"lastConnect");j(this,"gossiped");j(this,"tlsName");j(this,"resolves");this.src=e,this.tlsName="";const i=i2(e);this.listen=i.listen,this.hostname=i.hostname,this.port=i.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=s}toString(){return this.listen}async resolve(e){if(!e.fn||e.resolve===!1)return[this];const s=[];if(Md(this.hostname))return[this];{const i=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${i.join(",")}`);for(const o of i){const c=this.port===80?"https":"http",m=new URL(`${c}://${Rd(o)?"["+o+"]":o}`);m.port=`${this.port}`;const p=new So(m.host,!1);p.tlsName=this.hostname,s.push(p)}}return e.randomize&&xx(s),this.resolves=s,s}}class a2{constructor(e=[],s={}){j(this,"firstSelect");j(this,"servers");j(this,"currentServer");j(this,"tlsName");j(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=s.randomize||!1;const i=td();e&&(e.forEach(o=>{o=i?i(o):o,this.servers.push(new So(o))}),this.randomize&&(this.servers=xx(this.servers))),this.servers.length===0&&this.addServer(`${Sd}:${Ex()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();Md(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(s=>{s.gossiped&&(s.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,s=!1){const i=td();e=i?i(e):e;const o=new So(e,s);Md(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const e=this.servers.shift();return e&&(this.servers.push(e),this.currentServer=e),e}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(e){if(e){const s=this.servers.indexOf(e);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(e,s){const i=[];let o=[];const c=td(),m=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(g=>{g=c?c(g,s):g;const u=new So(g,!0);m.set(g,u)});const p=[];return this.servers.forEach((g,u)=>{const d=g.listen;g.gossiped&&this.currentServer.listen!==d&&m.get(d)===void 0&&p.push(u),m.delete(d)}),p.reverse(),p.forEach(g=>{const u=this.servers.splice(g,1);o=o.concat(u[0].listen)}),m.forEach((g,u)=>{this.servers.push(g),i.push(u)}),{added:i,deleted:o}}}class o2{constructor(){j(this,"baseInbox");j(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${Lr(e)}.`,this.baseInbox}add(e){isNaN(e.received)||(e.received=0),this.reqs.set(e.token,e)}get(e){return this.reqs.get(e)}cancel(e){this.reqs.delete(e.token)}getToken(e){const s=e.subject||"";return s.indexOf(this.baseInbox)===0?s.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,s){if(s&&s.permissionContext){if(e)return this.all().forEach(o=>{o.resolver(s,{})}),!0;const i=s.permissionContext;if(i.operation==="publish"){const o=this.all().find(c=>c.requestSubject===i.subject);if(o)return o.resolver(s,{}),!0}}return!1}dispatcher(){return(e,s)=>{const i=this.getToken(s);if(i){const o=this.get(i);o&&(e===null&&s.headers&&(e=vx(s)),o.resolver(e,s))}}}close(){const e=be.errorForCode(fe.Timeout);this.reqs.forEach(s=>{s.resolver(e,{})})}}class l2{constructor(e,s,i){j(this,"ph");j(this,"interval");j(this,"maxOut");j(this,"timer");j(this,"pendings");this.ph=e,this.interval=s,this.maxOut=i,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:Qi.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=dt();this.ph.flush(e).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(e),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(e=>(e.resolve(),!1))}}class c2 extends Error{constructor(e){super(e),this.name="AssertionError"}}function u2(n,e="Assertion failed."){if(!n)throw new c2(e)}const ab=32*1024,nd=2**32-2;function oc(n,e,s=0){const i=e.byteLength-s;return n.byteLength>i&&(n=n.subarray(0,i)),e.set(n,s),n.byteLength}class rd{constructor(e){j(this,"_buf");j(this,"_off");if(this._off=0,e==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(e)}bytes(e={copy:!0}){return e.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(e){if(e===0){this.reset();return}if(e<0||e>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+e)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(e){const s=this._buf.byteLength;return e<=this.capacity-s?(this._reslice(s+e),s):-1}_reslice(e){u2(e<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,e)}readByte(){const e=new Uint8Array(1);return this.read(e)?e[0]:null}read(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;const s=oc(this._buf.subarray(this._off),e);return this._off+=s,s}writeByte(e){return this.write(Uint8Array.of(e))}writeString(e){return this.write(ri.encode(e))}write(e){const s=this._grow(e.byteLength);return oc(e,this._buf,s)}_grow(e){const s=this.length;s===0&&this._off!==0&&this.reset();const i=this._tryGrowByReslice(e);if(i>=0)return i;const o=this.capacity;if(e<=Math.floor(o/2)-s)oc(this._buf.subarray(this._off),this._buf);else{if(o+e>nd)throw new Error("The buffer cannot be grown beyond the maximum size.");{const c=new Uint8Array(Math.min(2*o+e,nd));oc(this._buf.subarray(this._off),c),this._buf=c}}return this._off=0,this._reslice(Math.min(s+e,nd)),s}grow(e){if(e<0)throw Error("Buffer._grow: negative count");const s=this._grow(e);this._reslice(s)}readFrom(e){let s=0;const i=new Uint8Array(ab);for(;;){const o=this.capacity-this.length<ab,c=o?i:new Uint8Array(this._buf.buffer,this.length),m=e.read(c);if(m===null)return s;o?this.write(c.subarray(0,m)):this._reslice(this.length+m),s+=m}}}var Xt;(function(n){n[n.OK=0]="OK",n[n.ERR=1]="ERR",n[n.MSG=2]="MSG",n[n.INFO=3]="INFO",n[n.PING=4]="PING",n[n.PONG=5]="PONG"})(Xt||(Xt={}));function ob(){const n={};return n.sid=-1,n.hdr=-1,n.size=-1,n}const f2=48;class lb{constructor(e){j(this,"dispatcher");j(this,"state");j(this,"as");j(this,"drop");j(this,"hdr");j(this,"ma");j(this,"argBuf");j(this,"msgBuf");this.dispatcher=e,this.state=de.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(e){let s;for(s=0;s<e.length;s++){const i=e[s];switch(this.state){case de.OP_START:switch(i){case me.M:case me.m:this.state=de.OP_M,this.hdr=-1,this.ma=ob();break;case me.H:case me.h:this.state=de.OP_H,this.hdr=0,this.ma=ob();break;case me.P:case me.p:this.state=de.OP_P;break;case me.PLUS:this.state=de.OP_PLUS;break;case me.MINUS:this.state=de.OP_MINUS;break;case me.I:case me.i:this.state=de.OP_I;break;default:throw this.fail(e.subarray(s))}break;case de.OP_H:switch(i){case me.M:case me.m:this.state=de.OP_M;break;default:throw this.fail(e.subarray(s))}break;case de.OP_M:switch(i){case me.S:case me.s:this.state=de.OP_MS;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MS:switch(i){case me.G:case me.g:this.state=de.OP_MSG;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MSG:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MSG_SPC;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MSG_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MSG_ARG,this.as=s}break;case de.MSG_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{const o=this.argBuf?this.argBuf.bytes():e.subarray(this.as,s-this.drop);this.processMsgArgs(o),this.drop=0,this.as=s+1,this.state=de.MSG_PAYLOAD,s=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;case de.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const o=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Xt.MSG,msg:this.ma,data:o}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END}else{let o=this.ma.size-this.msgBuf.length;const c=e.length-s;c<o&&(o=c),o>0?(this.msgBuf.write(e.subarray(s,s+o)),s=s+o-1):this.msgBuf.writeByte(i)}else s-this.as>=this.ma.size&&(this.dispatcher.push({kind:Xt.MSG,msg:this.ma,data:e.subarray(this.as,s)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=de.MSG_END);break;case de.MSG_END:switch(i){case me.NL:this.drop=0,this.as=s+1,this.state=de.OP_START;break;default:continue}break;case de.OP_PLUS:switch(i){case me.O:case me.o:this.state=de.OP_PLUS_O;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PLUS_O:switch(i){case me.K:case me.k:this.state=de.OP_PLUS_OK;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PLUS_OK:switch(i){case me.NL:this.dispatcher.push({kind:Xt.OK}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_MINUS:switch(i){case me.E:case me.e:this.state=de.OP_MINUS_E;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_E:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ER;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_ER:switch(i){case me.R:case me.r:this.state=de.OP_MINUS_ERR;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_ERR:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_MINUS_ERR_SPC;break;default:throw this.fail(e.subarray(s))}break;case de.OP_MINUS_ERR_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.MINUS_ERR_ARG,this.as=s}break;case de.MINUS_ERR_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=e.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Xt.ERR,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(i))}break;case de.OP_P:switch(i){case me.I:case me.i:this.state=de.OP_PI;break;case me.O:case me.o:this.state=de.OP_PO;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PO:switch(i){case me.N:case me.n:this.state=de.OP_PON;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PON:switch(i){case me.G:case me.g:this.state=de.OP_PONG;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PONG:switch(i){case me.NL:this.dispatcher.push({kind:Xt.PONG}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_PI:switch(i){case me.N:case me.n:this.state=de.OP_PIN;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PIN:switch(i){case me.G:case me.g:this.state=de.OP_PING;break;default:throw this.fail(e.subarray(s))}break;case de.OP_PING:switch(i){case me.NL:this.dispatcher.push({kind:Xt.PING}),this.drop=0,this.state=de.OP_START;break}break;case de.OP_I:switch(i){case me.N:case me.n:this.state=de.OP_IN;break;default:throw this.fail(e.subarray(s))}break;case de.OP_IN:switch(i){case me.F:case me.f:this.state=de.OP_INF;break;default:throw this.fail(e.subarray(s))}break;case de.OP_INF:switch(i){case me.O:case me.o:this.state=de.OP_INFO;break;default:throw this.fail(e.subarray(s))}break;case de.OP_INFO:switch(i){case me.SPACE:case me.TAB:this.state=de.OP_INFO_SPC;break;default:throw this.fail(e.subarray(s))}break;case de.OP_INFO_SPC:switch(i){case me.SPACE:case me.TAB:continue;default:this.state=de.INFO_ARG,this.as=s}break;case de.INFO_ARG:switch(i){case me.CR:this.drop=1;break;case me.NL:{let o;this.argBuf?(o=this.argBuf.bytes(),this.argBuf=void 0):o=e.subarray(this.as,s-this.drop),this.dispatcher.push({kind:Xt.INFO,data:o}),this.drop=0,this.as=s+1,this.state=de.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(i)}break;default:throw this.fail(e.subarray(s))}}(this.state===de.MSG_ARG||this.state===de.MINUS_ERR_ARG||this.state===de.INFO_ARG)&&!this.argBuf&&(this.argBuf=new rd(e.subarray(this.as,s-this.drop))),this.state===de.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new rd(e.subarray(this.as)))}cloneMsgArg(){const e=this.ma.subject.length,s=this.ma.reply?this.ma.reply.length:0,i=new Uint8Array(e+s);i.set(this.ma.subject),this.ma.reply&&i.set(this.ma.reply,e),this.argBuf=new rd(i),this.ma.subject=i.subarray(0,e),this.ma.reply&&(this.ma.reply=i.subarray(e))}processMsgArgs(e){if(this.hdr>=0)return this.processHeaderMsgArgs(e);const s=[];let i=-1;for(let o=0;o<e.length;o++)switch(e[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(e.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(e.subarray(i)),s.length){case 3:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(s[2]);break;case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.size=this.protoParseInt(s[3]);break;default:throw this.fail(e,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(e,"processMsgArgs Bad or Missing Size Error")}fail(e,s=""){return s?s=`${s} [${this.state}]`:s=`parse error [${this.state}]`,new Error(`${s}: ${En.decode(e)}`)}processHeaderMsgArgs(e){const s=[];let i=-1;for(let o=0;o<e.length;o++)switch(e[o]){case me.SPACE:case me.TAB:case me.CR:case me.NL:i>=0&&(s.push(e.subarray(i,o)),i=-1);break;default:i<0&&(i=o)}switch(i>=0&&s.push(e.subarray(i)),s.length){case 4:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(s[2]),this.ma.size=this.protoParseInt(s[3]);break;case 5:this.ma.subject=s[0],this.ma.sid=this.protoParseInt(s[1]),this.ma.reply=s[2],this.ma.hdr=this.protoParseInt(s[3]),this.ma.size=this.protoParseInt(s[4]);break;default:throw this.fail(e,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(e){if(e.length===0)return-1;let s=0;for(let i=0;i<e.length;i++){if(e[i]<48||e[i]>57)return-1;s=s*10+(e[i]-f2)}return s}}var de;(function(n){n[n.OP_START=0]="OP_START",n[n.OP_PLUS=1]="OP_PLUS",n[n.OP_PLUS_O=2]="OP_PLUS_O",n[n.OP_PLUS_OK=3]="OP_PLUS_OK",n[n.OP_MINUS=4]="OP_MINUS",n[n.OP_MINUS_E=5]="OP_MINUS_E",n[n.OP_MINUS_ER=6]="OP_MINUS_ER",n[n.OP_MINUS_ERR=7]="OP_MINUS_ERR",n[n.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",n[n.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",n[n.OP_M=10]="OP_M",n[n.OP_MS=11]="OP_MS",n[n.OP_MSG=12]="OP_MSG",n[n.OP_MSG_SPC=13]="OP_MSG_SPC",n[n.MSG_ARG=14]="MSG_ARG",n[n.MSG_PAYLOAD=15]="MSG_PAYLOAD",n[n.MSG_END=16]="MSG_END",n[n.OP_H=17]="OP_H",n[n.OP_P=18]="OP_P",n[n.OP_PI=19]="OP_PI",n[n.OP_PIN=20]="OP_PIN",n[n.OP_PING=21]="OP_PING",n[n.OP_PO=22]="OP_PO",n[n.OP_PON=23]="OP_PON",n[n.OP_PONG=24]="OP_PONG",n[n.OP_I=25]="OP_I",n[n.OP_IN=26]="OP_IN",n[n.OP_INF=27]="OP_INF",n[n.OP_INFO=28]="OP_INFO",n[n.OP_INFO_SPC=29]="OP_INFO_SPC",n[n.INFO_ARG=30]="INFO_ARG"})(de||(de={}));var me;(function(n){n[n.CR=13]="CR",n[n.E=69]="E",n[n.e=101]="e",n[n.F=70]="F",n[n.f=102]="f",n[n.G=71]="G",n[n.g=103]="g",n[n.H=72]="H",n[n.h=104]="h",n[n.I=73]="I",n[n.i=105]="i",n[n.K=75]="K",n[n.k=107]="k",n[n.M=77]="M",n[n.m=109]="m",n[n.MINUS=45]="MINUS",n[n.N=78]="N",n[n.n=110]="n",n[n.NL=10]="NL",n[n.O=79]="O",n[n.o=111]="o",n[n.P=80]="P",n[n.p=112]="p",n[n.PLUS=43]="PLUS",n[n.R=82]="R",n[n.r=114]="r",n[n.S=83]="S",n[n.s=115]="s",n[n.SPACE=32]="SPACE",n[n.TAB=9]="TAB"})(me||(me={}));(function(n){var e=function(A,N){this.hi=A|0,this.lo=N|0},s=function(A){var N,k=new Float64Array(16);if(A)for(N=0;N<A.length;N++)k[N]=A[N];return k},i=function(){throw new Error("no PRNG")},o=new Uint8Array(16),c=new Uint8Array(32);c[0]=9;var m=s(),p=s([1]),g=s([56129,1]),u=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),x=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function _(A,N){return A<<N|A>>>32-N}function S(A,N){var k=A[N+3]&255;return k=k<<8|A[N+2]&255,k=k<<8|A[N+1]&255,k<<8|A[N+0]&255}function C(A,N){var k=A[N]<<24|A[N+1]<<16|A[N+2]<<8|A[N+3],T=A[N+4]<<24|A[N+5]<<16|A[N+6]<<8|A[N+7];return new e(k,T)}function B(A,N,k){var T;for(T=0;T<4;T++)A[N+T]=k&255,k>>>=8}function q(A,N,k){A[N]=k.hi>>24&255,A[N+1]=k.hi>>16&255,A[N+2]=k.hi>>8&255,A[N+3]=k.hi&255,A[N+4]=k.lo>>24&255,A[N+5]=k.lo>>16&255,A[N+6]=k.lo>>8&255,A[N+7]=k.lo&255}function ne(A,N,k,T,L){var $,se=0;for($=0;$<L;$++)se|=A[N+$]^k[T+$];return(1&se-1>>>8)-1}function te(A,N,k,T){return ne(A,N,k,T,16)}function M(A,N,k,T){return ne(A,N,k,T,32)}function z(A,N,k,T,L){var $=new Uint32Array(16),se=new Uint32Array(16),oe=new Uint32Array(16),K=new Uint32Array(4),re,xe,Be;for(re=0;re<4;re++)se[5*re]=S(T,4*re),se[1+re]=S(k,4*re),se[6+re]=S(N,4*re),se[11+re]=S(k,16+4*re);for(re=0;re<16;re++)oe[re]=se[re];for(re=0;re<20;re++){for(xe=0;xe<4;xe++){for(Be=0;Be<4;Be++)K[Be]=se[(5*xe+4*Be)%16];for(K[1]^=_(K[0]+K[3]|0,7),K[2]^=_(K[1]+K[0]|0,9),K[3]^=_(K[2]+K[1]|0,13),K[0]^=_(K[3]+K[2]|0,18),Be=0;Be<4;Be++)$[4*xe+(xe+Be)%4]=K[Be]}for(Be=0;Be<16;Be++)se[Be]=$[Be]}if(L){for(re=0;re<16;re++)se[re]=se[re]+oe[re]|0;for(re=0;re<4;re++)se[5*re]=se[5*re]-S(T,4*re)|0,se[6+re]=se[6+re]-S(N,4*re)|0;for(re=0;re<4;re++)B(A,4*re,se[5*re]),B(A,16+4*re,se[6+re])}else for(re=0;re<16;re++)B(A,4*re,se[re]+oe[re]|0)}function ae(A,N,k,T){return z(A,N,k,T,!1),0}function F(A,N,k,T){return z(A,N,k,T,!0),0}var U=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function D(A,N,k,T,L,$,se){var oe=new Uint8Array(16),K=new Uint8Array(64),re,xe;if(!L)return 0;for(xe=0;xe<16;xe++)oe[xe]=0;for(xe=0;xe<8;xe++)oe[xe]=$[xe];for(;L>=64;){for(ae(K,oe,se,U),xe=0;xe<64;xe++)A[N+xe]=(k?k[T+xe]:0)^K[xe];for(re=1,xe=8;xe<16;xe++)re=re+(oe[xe]&255)|0,oe[xe]=re&255,re>>>=8;L-=64,N+=64,k&&(T+=64)}if(L>0)for(ae(K,oe,se,U),xe=0;xe<L;xe++)A[N+xe]=(k?k[T+xe]:0)^K[xe];return 0}function Q(A,N,k,T,L){return D(A,N,null,0,k,T,L)}function W(A,N,k,T,L){var $=new Uint8Array(32);return F($,T,L,U),Q(A,N,k,T.subarray(16),$)}function he(A,N,k,T,L,$,se){var oe=new Uint8Array(32);return F(oe,$,se,U),D(A,N,k,T,L,$.subarray(16),oe)}function Ee(A,N){var k,T=0;for(k=0;k<17;k++)T=T+(A[k]+N[k]|0)|0,A[k]=T&255,T>>>=8}var Ae=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function H(A,N,k,T,L,$){var se,oe,K,re,xe=new Uint32Array(17),Be=new Uint32Array(17),ot=new Uint32Array(17),Vt=new Uint32Array(17),Vn=new Uint32Array(17);for(K=0;K<17;K++)Be[K]=ot[K]=0;for(K=0;K<16;K++)Be[K]=$[K];for(Be[3]&=15,Be[4]&=252,Be[7]&=15,Be[8]&=252,Be[11]&=15,Be[12]&=252,Be[15]&=15;L>0;){for(K=0;K<17;K++)Vt[K]=0;for(K=0;K<16&&K<L;++K)Vt[K]=k[T+K];for(Vt[K]=1,T+=K,L-=K,Ee(ot,Vt),oe=0;oe<17;oe++)for(xe[oe]=0,K=0;K<17;K++)xe[oe]=xe[oe]+ot[K]*(K<=oe?Be[oe-K]:320*Be[oe+17-K]|0)|0|0;for(oe=0;oe<17;oe++)ot[oe]=xe[oe];for(re=0,K=0;K<16;K++)re=re+ot[K]|0,ot[K]=re&255,re>>>=8;for(re=re+ot[16]|0,ot[16]=re&3,re=5*(re>>>2)|0,K=0;K<16;K++)re=re+ot[K]|0,ot[K]=re&255,re>>>=8;re=re+ot[16]|0,ot[16]=re}for(K=0;K<17;K++)Vn[K]=ot[K];for(Ee(ot,Ae),se=-(ot[16]>>>7)|0,K=0;K<17;K++)ot[K]^=se&(Vn[K]^ot[K]);for(K=0;K<16;K++)Vt[K]=$[K+16];for(Vt[16]=0,Ee(ot,Vt),K=0;K<16;K++)A[N+K]=ot[K];return 0}function J(A,N,k,T,L,$){var se=new Uint8Array(16);return H(se,0,k,T,L,$),te(A,N,se,0)}function ce(A,N,k,T,L){var $;if(k<32)return-1;for(he(A,0,N,0,k,T,L),H(A,16,A,32,k-32,A),$=0;$<16;$++)A[$]=0;return 0}function pe(A,N,k,T,L){var $,se=new Uint8Array(32);if(k<32||(W(se,0,32,T,L),J(N,16,N,32,k-32,se)!==0))return-1;for(he(A,0,N,0,k,T,L),$=0;$<32;$++)A[$]=0;return 0}function ge(A,N){var k;for(k=0;k<16;k++)A[k]=N[k]|0}function Ce(A){var N,k;for(k=0;k<16;k++)A[k]+=65536,N=Math.floor(A[k]/65536),A[(k+1)*(k<15?1:0)]+=N-1+37*(N-1)*(k===15?1:0),A[k]-=N*65536}function Ne(A,N,k){for(var T,L=~(k-1),$=0;$<16;$++)T=L&(A[$]^N[$]),A[$]^=T,N[$]^=T}function Me(A,N){var k,T,L,$=s(),se=s();for(k=0;k<16;k++)se[k]=N[k];for(Ce(se),Ce(se),Ce(se),T=0;T<2;T++){for($[0]=se[0]-65517,k=1;k<15;k++)$[k]=se[k]-65535-($[k-1]>>16&1),$[k-1]&=65535;$[15]=se[15]-32767-($[14]>>16&1),L=$[15]>>16&1,$[14]&=65535,Ne(se,$,1-L)}for(k=0;k<16;k++)A[2*k]=se[k]&255,A[2*k+1]=se[k]>>8}function Xe(A,N){var k=new Uint8Array(32),T=new Uint8Array(32);return Me(k,A),Me(T,N),M(k,0,T,0)}function pt(A){var N=new Uint8Array(32);return Me(N,A),N[0]&1}function Ot(A,N){var k;for(k=0;k<16;k++)A[k]=N[2*k]+(N[2*k+1]<<8);A[15]&=32767}function mt(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]+k[T]|0}function _e(A,N,k){var T;for(T=0;T<16;T++)A[T]=N[T]-k[T]|0}function le(A,N,k){var T,L,$=new Float64Array(31);for(T=0;T<31;T++)$[T]=0;for(T=0;T<16;T++)for(L=0;L<16;L++)$[T+L]+=N[T]*k[L];for(T=0;T<15;T++)$[T]+=38*$[T+16];for(T=0;T<16;T++)A[T]=$[T];Ce(A),Ce(A)}function Pe(A,N){le(A,N,N)}function zt(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=253;T>=0;T--)Pe(k,k),T!==2&&T!==4&&le(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function qt(A,N){var k=s(),T;for(T=0;T<16;T++)k[T]=N[T];for(T=250;T>=0;T--)Pe(k,k),T!==1&&le(k,k,N);for(T=0;T<16;T++)A[T]=k[T]}function at(A,N,k){var T=new Uint8Array(32),L=new Float64Array(80),$,se,oe=s(),K=s(),re=s(),xe=s(),Be=s(),ot=s();for(se=0;se<31;se++)T[se]=N[se];for(T[31]=N[31]&127|64,T[0]&=248,Ot(L,k),se=0;se<16;se++)K[se]=L[se],xe[se]=oe[se]=re[se]=0;for(oe[0]=xe[0]=1,se=254;se>=0;--se)$=T[se>>>3]>>>(se&7)&1,Ne(oe,K,$),Ne(re,xe,$),mt(Be,oe,re),_e(oe,oe,re),mt(re,K,xe),_e(K,K,xe),Pe(xe,Be),Pe(ot,oe),le(oe,re,oe),le(re,K,Be),mt(Be,oe,re),_e(oe,oe,re),Pe(K,oe),_e(re,xe,ot),le(oe,re,g),mt(oe,oe,xe),le(re,re,oe),le(oe,xe,ot),le(xe,K,L),Pe(K,Be),Ne(oe,K,$),Ne(re,xe,$);for(se=0;se<16;se++)L[se+16]=oe[se],L[se+32]=re[se],L[se+48]=K[se],L[se+64]=xe[se];var Vt=L.subarray(32),Vn=L.subarray(16);return zt(Vt,Vt),le(Vn,Vn,Vt),Me(A,Vn),0}function ye(A,N){return at(A,N,c)}function Ye(A,N){return i(N,32),ye(A,N)}function yt(A,N,k){var T=new Uint8Array(32);return at(T,k,N),F(A,o,T,U)}var At=ce,Ur=pe;function ua(A,N,k,T,L,$){var se=new Uint8Array(32);return yt(se,L,$),At(A,N,k,T,se)}function fa(A,N,k,T,L,$){var se=new Uint8Array(32);return yt(se,L,$),Ur(A,N,k,T,se)}function hr(){var A=0,N=0,k=0,T=0,L=65535,$,se,oe;for(oe=0;oe<arguments.length;oe++)$=arguments[oe].lo,se=arguments[oe].hi,A+=$&L,N+=$>>>16,k+=se&L,T+=se>>>16;return N+=A>>>16,k+=N>>>16,T+=k>>>16,new e(k&L|T<<16,A&L|N<<16)}function zo(A,N){return new e(A.hi>>>N,A.lo>>>N|A.hi<<32-N)}function si(){var A=0,N=0,k;for(k=0;k<arguments.length;k++)A^=arguments[k].lo,N^=arguments[k].hi;return new e(N,A)}function ut(A,N){var k,T,L=32-N;return N<32?(k=A.hi>>>N|A.lo<<L,T=A.lo>>>N|A.hi<<L):N<64&&(k=A.lo>>>N|A.hi<<L,T=A.hi>>>N|A.lo<<L),new e(k,T)}function Bu(A,N,k){var T=A.hi&N.hi^~A.hi&k.hi,L=A.lo&N.lo^~A.lo&k.lo;return new e(T,L)}function Io(A,N,k){var T=A.hi&N.hi^A.hi&k.hi^N.hi&k.hi,L=A.lo&N.lo^A.lo&k.lo^N.lo&k.lo;return new e(T,L)}function $o(A){return si(ut(A,28),ut(A,34),ut(A,39))}function ii(A){return si(ut(A,14),ut(A,18),ut(A,41))}function Uu(A){return si(ut(A,1),ut(A,8),zo(A,7))}function Ho(A){return si(ut(A,19),ut(A,61),zo(A,6))}var zu=[new e(1116352408,3609767458),new e(1899447441,602891725),new e(3049323471,3964484399),new e(3921009573,2173295548),new e(961987163,4081628472),new e(1508970993,3053834265),new e(2453635748,2937671579),new e(2870763221,3664609560),new e(3624381080,2734883394),new e(310598401,1164996542),new e(607225278,1323610764),new e(1426881987,3590304994),new e(1925078388,4068182383),new e(2162078206,991336113),new e(2614888103,633803317),new e(3248222580,3479774868),new e(3835390401,2666613458),new e(4022224774,944711139),new e(264347078,2341262773),new e(604807628,2007800933),new e(770255983,1495990901),new e(1249150122,1856431235),new e(1555081692,3175218132),new e(1996064986,2198950837),new e(2554220882,3999719339),new e(2821834349,766784016),new e(2952996808,2566594879),new e(3210313671,3203337956),new e(3336571891,1034457026),new e(3584528711,2466948901),new e(113926993,3758326383),new e(338241895,168717936),new e(666307205,1188179964),new e(773529912,1546045734),new e(1294757372,1522805485),new e(1396182291,2643833823),new e(1695183700,2343527390),new e(1986661051,1014477480),new e(2177026350,1206759142),new e(2456956037,344077627),new e(2730485921,1290863460),new e(2820302411,3158454273),new e(3259730800,3505952657),new e(3345764771,106217008),new e(3516065817,3606008344),new e(3600352804,1432725776),new e(4094571909,1467031594),new e(275423344,851169720),new e(430227734,3100823752),new e(506948616,1363258195),new e(659060556,3750685593),new e(883997877,3785050280),new e(958139571,3318307427),new e(1322822218,3812723403),new e(1537002063,2003034995),new e(1747873779,3602036899),new e(1955562222,1575990012),new e(2024104815,1125592928),new e(2227730452,2716904306),new e(2361852424,442776044),new e(2428436474,593698344),new e(2756734187,3733110249),new e(3204031479,2999351573),new e(3329325298,3815920427),new e(3391569614,3928383900),new e(3515267271,566280711),new e(3940187606,3454069534),new e(4118630271,4000239992),new e(116418474,1914138554),new e(174292421,2731055270),new e(289380356,3203993006),new e(460393269,320620315),new e(685471733,587496836),new e(852142971,1086792851),new e(1017036298,365543100),new e(1126000580,2618297676),new e(1288033470,3409855158),new e(1501505948,4234509866),new e(1607167915,987167468),new e(1816402316,1246189591)];function Fo(A,N,k){var T=[],L=[],$=[],se=[],oe,K,re;for(K=0;K<8;K++)T[K]=$[K]=C(A,8*K);for(var xe=0;k>=128;){for(K=0;K<16;K++)se[K]=C(N,8*K+xe);for(K=0;K<80;K++){for(re=0;re<8;re++)L[re]=$[re];for(oe=hr($[7],ii($[4]),Bu($[4],$[5],$[6]),zu[K],se[K%16]),L[7]=hr(oe,$o($[0]),Io($[0],$[1],$[2])),L[3]=hr(L[3],oe),re=0;re<8;re++)$[(re+1)%8]=L[re];if(K%16===15)for(re=0;re<16;re++)se[re]=hr(se[re],se[(re+9)%16],Uu(se[(re+1)%16]),Ho(se[(re+14)%16]))}for(K=0;K<8;K++)$[K]=hr($[K],T[K]),T[K]=$[K];xe+=128,k-=128}for(K=0;K<8;K++)q(A,8*K,T[K]);return k}var Ns=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 _t(A,N,k){var T=new Uint8Array(64),L=new Uint8Array(256),$,se=k;for($=0;$<64;$++)T[$]=Ns[$];for(Fo(T,N,k),k%=128,$=0;$<256;$++)L[$]=0;for($=0;$<k;$++)L[$]=N[se-k+$];for(L[k]=128,k=256-128*(k<112?1:0),L[k-9]=0,q(L,k-8,new e(se/536870912|0,se<<3)),Fo(T,L,k),$=0;$<64;$++)A[$]=T[$];return 0}function fn(A,N){var k=s(),T=s(),L=s(),$=s(),se=s(),oe=s(),K=s(),re=s(),xe=s();_e(k,A[1],A[0]),_e(xe,N[1],N[0]),le(k,k,xe),mt(T,A[0],A[1]),mt(xe,N[0],N[1]),le(T,T,xe),le(L,A[3],N[3]),le(L,L,d),le($,A[2],N[2]),mt($,$,$),_e(se,T,k),_e(oe,$,L),mt(K,$,L),mt(re,T,k),le(A[0],se,oe),le(A[1],re,K),le(A[2],K,oe),le(A[3],se,re)}function Gt(A,N,k){var T;for(T=0;T<4;T++)Ne(A[T],N[T],k)}function ha(A,N){var k=s(),T=s(),L=s();zt(L,N[2]),le(k,N[0],L),le(T,N[1],L),Me(A,T),A[31]^=pt(k)<<7}function da(A,N,k){var T,L;for(ge(A[0],m),ge(A[1],p),ge(A[2],p),ge(A[3],m),L=255;L>=0;--L)T=k[L/8|0]>>(L&7)&1,Gt(A,N,T),fn(N,A),fn(A,A),Gt(A,N,T)}function ai(A,N){var k=[s(),s(),s(),s()];ge(k[0],b),ge(k[1],x),ge(k[2],p),le(k[3],b,x),da(A,k,N)}function zr(A,N,k){var T=new Uint8Array(64),L=[s(),s(),s(),s()],$;for(k||i(N,32),_t(T,N,32),T[0]&=248,T[31]&=127,T[31]|=64,ai(L,T),ha(A,L),$=0;$<32;$++)N[$+32]=A[$];return 0}var dr=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 Ir(A,N){var k,T,L,$;for(T=63;T>=32;--T){for(k=0,L=T-32,$=T-12;L<$;++L)N[L]+=k-16*N[T]*dr[L-(T-32)],k=Math.floor((N[L]+128)/256),N[L]-=k*256;N[L]+=k,N[T]=0}for(k=0,L=0;L<32;L++)N[L]+=k-(N[31]>>4)*dr[L],k=N[L]>>8,N[L]&=255;for(L=0;L<32;L++)N[L]-=k*dr[L];for(T=0;T<32;T++)N[T+1]+=N[T]>>8,A[T]=N[T]&255}function Fn(A){var N=new Float64Array(64),k;for(k=0;k<64;k++)N[k]=A[k];for(k=0;k<64;k++)A[k]=0;Ir(A,N)}function Ts(A,N,k,T){var L=new Uint8Array(64),$=new Uint8Array(64),se=new Uint8Array(64),oe,K,re=new Float64Array(64),xe=[s(),s(),s(),s()];_t(L,T,32),L[0]&=248,L[31]&=127,L[31]|=64;var Be=k+64;for(oe=0;oe<k;oe++)A[64+oe]=N[oe];for(oe=0;oe<32;oe++)A[32+oe]=L[32+oe];for(_t(se,A.subarray(32),k+32),Fn(se),ai(xe,se),ha(A,xe),oe=32;oe<64;oe++)A[oe]=T[oe];for(_t($,A,k+64),Fn($),oe=0;oe<64;oe++)re[oe]=0;for(oe=0;oe<32;oe++)re[oe]=se[oe];for(oe=0;oe<32;oe++)for(K=0;K<32;K++)re[oe+K]+=$[oe]*L[K];return Ir(A.subarray(32),re),Be}function Cs(A,N){var k=s(),T=s(),L=s(),$=s(),se=s(),oe=s(),K=s();return ge(A[2],p),Ot(A[1],N),Pe(L,A[1]),le($,L,u),_e(L,L,A[2]),mt($,A[2],$),Pe(se,$),Pe(oe,se),le(K,oe,se),le(k,K,L),le(k,k,$),qt(k,k),le(k,k,L),le(k,k,$),le(k,k,$),le(A[0],k,$),Pe(T,A[0]),le(T,T,$),Xe(T,L)&&le(A[0],A[0],v),Pe(T,A[0]),le(T,T,$),Xe(T,L)?-1:(pt(A[0])===N[31]>>7&&_e(A[0],m,A[0]),le(A[3],A[0],A[1]),0)}function ma(A,N,k,T){var L,$=new Uint8Array(32),se=new Uint8Array(64),oe=[s(),s(),s(),s()],K=[s(),s(),s(),s()];if(k<64||Cs(K,T))return-1;for(L=0;L<k;L++)A[L]=N[L];for(L=0;L<32;L++)A[L+32]=T[L];if(_t(se,A,k),Fn(se),da(oe,K,se),ai(K,N.subarray(32)),fn(oe,K),ha($,oe),k-=64,M(N,0,$,0)){for(L=0;L<k;L++)A[L]=0;return-1}for(L=0;L<k;L++)A[L]=N[L+64];return k}var oi=32,$r=24,Gn=32,Hr=16,Fr=32,Ms=32,Gr=32,mr=32,Rs=32,pa=$r,Go=Gn,tr=Hr,st=64,gt=32,hn=64,Ds=32,ya=64;n.lowlevel={crypto_core_hsalsa20:F,crypto_stream_xor:he,crypto_stream:W,crypto_stream_salsa20_xor:D,crypto_stream_salsa20:Q,crypto_onetimeauth:H,crypto_onetimeauth_verify:J,crypto_verify_16:te,crypto_verify_32:M,crypto_secretbox:ce,crypto_secretbox_open:pe,crypto_scalarmult:at,crypto_scalarmult_base:ye,crypto_box_beforenm:yt,crypto_box_afternm:At,crypto_box:ua,crypto_box_open:fa,crypto_box_keypair:Ye,crypto_hash:_t,crypto_sign:Ts,crypto_sign_keypair:zr,crypto_sign_open:ma,crypto_secretbox_KEYBYTES:oi,crypto_secretbox_NONCEBYTES:$r,crypto_secretbox_ZEROBYTES:Gn,crypto_secretbox_BOXZEROBYTES:Hr,crypto_scalarmult_BYTES:Fr,crypto_scalarmult_SCALARBYTES:Ms,crypto_box_PUBLICKEYBYTES:Gr,crypto_box_SECRETKEYBYTES:mr,crypto_box_BEFORENMBYTES:Rs,crypto_box_NONCEBYTES:pa,crypto_box_ZEROBYTES:Go,crypto_box_BOXZEROBYTES:tr,crypto_sign_BYTES:st,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:hn,crypto_sign_SEEDBYTES:Ds,crypto_hash_BYTES:ya,gf:s,D:u,L:dr,pack25519:Me,unpack25519:Ot,M:le,A:mt,S:Pe,Z:_e,pow2523:qt,add:fn,set25519:ge,modL:Ir,scalarmult:da,scalarbase:ai};function Vo(A,N){if(A.length!==oi)throw new Error("bad key size");if(N.length!==$r)throw new Error("bad nonce size")}function Yo(A,N){if(A.length!==Gr)throw new Error("bad public key size");if(N.length!==mr)throw new Error("bad secret key size")}function Mt(){for(var A=0;A<arguments.length;A++)if(!(arguments[A]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function li(A){for(var N=0;N<A.length;N++)A[N]=0}n.randomBytes=function(A){var N=new Uint8Array(A);return i(N,A),N},n.secretbox=function(A,N,k){Mt(A,N,k),Vo(k,N);for(var T=new Uint8Array(Gn+A.length),L=new Uint8Array(T.length),$=0;$<A.length;$++)T[$+Gn]=A[$];return ce(L,T,T.length,N,k),L.subarray(Hr)},n.secretbox.open=function(A,N,k){Mt(A,N,k),Vo(k,N);for(var T=new Uint8Array(Hr+A.length),L=new Uint8Array(T.length),$=0;$<A.length;$++)T[$+Hr]=A[$];return T.length<32||pe(L,T,T.length,N,k)!==0?null:L.subarray(Gn)},n.secretbox.keyLength=oi,n.secretbox.nonceLength=$r,n.secretbox.overheadLength=Hr,n.scalarMult=function(A,N){if(Mt(A,N),A.length!==Ms)throw new Error("bad n size");if(N.length!==Fr)throw new Error("bad p size");var k=new Uint8Array(Fr);return at(k,A,N),k},n.scalarMult.base=function(A){if(Mt(A),A.length!==Ms)throw new Error("bad n size");var N=new Uint8Array(Fr);return ye(N,A),N},n.scalarMult.scalarLength=Ms,n.scalarMult.groupElementLength=Fr,n.box=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox(A,N,L)},n.box.before=function(A,N){Mt(A,N),Yo(A,N);var k=new Uint8Array(Rs);return yt(k,A,N),k},n.box.after=n.secretbox,n.box.open=function(A,N,k,T){var L=n.box.before(k,T);return n.secretbox.open(A,N,L)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var A=new Uint8Array(Gr),N=new Uint8Array(mr);return Ye(A,N),{publicKey:A,secretKey:N}},n.box.keyPair.fromSecretKey=function(A){if(Mt(A),A.length!==mr)throw new Error("bad secret key size");var N=new Uint8Array(Gr);return ye(N,A),{publicKey:N,secretKey:new Uint8Array(A)}},n.box.publicKeyLength=Gr,n.box.secretKeyLength=mr,n.box.sharedKeyLength=Rs,n.box.nonceLength=pa,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(A,N){if(Mt(A,N),N.length!==hn)throw new Error("bad secret key size");var k=new Uint8Array(st+A.length);return Ts(k,A,A.length,N),k},n.sign.open=function(A,N){if(Mt(A,N),N.length!==gt)throw new Error("bad public key size");var k=new Uint8Array(A.length),T=ma(k,A,A.length,N);if(T<0)return null;for(var L=new Uint8Array(T),$=0;$<L.length;$++)L[$]=k[$];return L},n.sign.detached=function(A,N){for(var k=n.sign(A,N),T=new Uint8Array(st),L=0;L<T.length;L++)T[L]=k[L];return T},n.sign.detached.verify=function(A,N,k){if(Mt(A,N,k),N.length!==st)throw new Error("bad signature size");if(k.length!==gt)throw new Error("bad public key size");var T=new Uint8Array(st+A.length),L=new Uint8Array(st+A.length),$;for($=0;$<st;$++)T[$]=N[$];for($=0;$<A.length;$++)T[$+st]=A[$];return ma(L,T,T.length,k)>=0},n.sign.keyPair=function(){var A=new Uint8Array(gt),N=new Uint8Array(hn);return zr(A,N),{publicKey:A,secretKey:N}},n.sign.keyPair.fromSecretKey=function(A){if(Mt(A),A.length!==hn)throw new Error("bad secret key size");for(var N=new Uint8Array(gt),k=0;k<N.length;k++)N[k]=A[32+k];return{publicKey:N,secretKey:new Uint8Array(A)}},n.sign.keyPair.fromSeed=function(A){if(Mt(A),A.length!==Ds)throw new Error("bad seed size");for(var N=new Uint8Array(gt),k=new Uint8Array(hn),T=0;T<32;T++)k[T]=A[T];return zr(N,k,!0),{publicKey:N,secretKey:k}},n.sign.publicKeyLength=gt,n.sign.secretKeyLength=hn,n.sign.seedLength=Ds,n.sign.signatureLength=st,n.hash=function(A){Mt(A);var N=new Uint8Array(ya);return _t(N,A,A.length),N},n.hash.hashLength=ya,n.verify=function(A,N){return Mt(A,N),A.length===0||N.length===0||A.length!==N.length?!1:ne(A,0,N,0,A.length)===0},n.setPRNG=function(A){i=A},(function(){var A=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(A&&A.getRandomValues){var N=65536;n.setPRNG(function(k,T){var L,$=new Uint8Array(T);for(L=0;L<T;L+=N)A.getRandomValues($.subarray(L,L+Math.min(T-L,N)));for(L=0;L<T;L++)k[L]=$[L];li($)})}else typeof require<"u"&&(A=require("crypto"),A&&A.randomBytes&&n.setPRNG(function(k,T){var L,$=A.randomBytes(T);for(L=0;L<T;L++)k[L]=$[L];li($)}))})()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const lc=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;lc.sign.keyPair.fromSeed,lc.sign.detached,lc.sign.detached.verify,lc.randomBytes;var cb;(function(n){n.InvalidPrefixByte="nkeys: invalid prefix byte",n.InvalidKey="nkeys: invalid key",n.InvalidPublicKey="nkeys: invalid public key",n.InvalidSeedLen="nkeys: invalid seed length",n.InvalidSeed="nkeys: invalid seed",n.InvalidEncoding="nkeys: invalid encoded key",n.InvalidSignature="nkeys: signature verification failed",n.CannotSign="nkeys: cannot sign, no private key available",n.PublicKeyOnly="nkeys: no seed or private key available",n.InvalidChecksum="nkeys: invalid checksum",n.SerializationError="nkeys: serialization error",n.ApiError="nkeys: api error",n.ClearedPair="nkeys: pair is cleared"})(cb||(cb={}));var ub;(function(n){n[n.Seed=144]="Seed",n[n.Private=120]="Private",n[n.Operator=112]="Operator",n[n.Server=104]="Server",n[n.Cluster=16]="Cluster",n[n.Account=0]="Account",n[n.User=160]="User"})(ub||(ub={}));function h2(n){return e=>{let s={};return n.forEach(i=>{const o=i(e)||{};s=Object.assign(s,o)}),s}}function d2(){return()=>{}}function m2(n,e){return()=>{const s=typeof n=="function"?n():n,i=typeof e=="function"?e():e;return{user:s,pass:i}}}function p2(n){return()=>({auth_token:typeof n=="function"?n():n})}const jx=120*1e3,y2=2,kx=2*1e3;function g2(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:jx,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:kx,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function b2(n){const e=[];return typeof n.authenticator=="function"&&e.push(n.authenticator),Array.isArray(n.authenticator)&&e.push(...n.authenticator),n.token&&e.push(p2(n.token)),n.user&&e.push(m2(n.user,n.pass)),e.length===0?d2():h2(e)}function x2(n){const e=`${Sd}:${Ex()}`;if(n=n||{servers:[e]},n.servers=n.servers||[],typeof n.servers=="string"&&(n.servers=[n.servers]),n.servers.length>0&&n.port)throw new be("port and servers options are mutually exclusive",fe.InvalidOption);n.servers.length===0&&n.port&&(n.servers=[`${Sd}:${n.port}`]),n.servers&&n.servers.length===0&&(n.servers=[e]);const s=Ou(g2(),n);if(s.authenticator=b2(s),["reconnectDelayHandler","authenticator"].forEach(i=>{if(s[i]&&typeof s[i]!="function")throw new be(`${i} option should be a function`,fe.NotFunction)}),s.reconnectDelayHandler||(s.reconnectDelayHandler=()=>{let i=s.tls?s.reconnectJitterTLS:s.reconnectJitter;return i&&(i++,i=Math.floor(Math.random()*i)),s.reconnectTimeWait+i}),s.inboxPrefix)try{Lr(s.inboxPrefix)}catch(i){throw new be(i.message,fe.ApiError)}if(s.resolve===void 0&&(s.resolve=typeof Cd()=="function"),s.resolve&&typeof Cd()!="function")throw new be("'resolve' is not supported on this client",fe.InvalidOption);return s}function v2(n,e){const{proto:s,tls_required:i,tls_available:o}=n;if((s===void 0||s<1)&&e.noEcho)throw new be("noEcho",fe.ServerOptionNotAvailable);const c=i||o||!1;if(e.tls&&!c)throw new be("tls",fe.ServerOptionNotAvailable)}const _2=1024*32,w2=/^INFO\s+([^\r\n]+)\r\n/i,S2=_o(`PONG\r
38
+ `),fb=_o(`PING\r
39
+ `);class E2{constructor(e,s,i){j(this,"echo");j(this,"no_responders");j(this,"protocol");j(this,"verbose");j(this,"pedantic");j(this,"jwt");j(this,"nkey");j(this,"sig");j(this,"user");j(this,"pass");j(this,"auth_token");j(this,"tls_required");j(this,"name");j(this,"lang");j(this,"version");j(this,"headers");this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=s.noEcho?!1:void 0,this.verbose=s.verbose,this.pedantic=s.pedantic,this.tls_required=s.tls?!0:void 0,this.name=s.name;const o=(s&&typeof s.authenticator=="function"?s.authenticator(i):{})||{};Ou(this,o)}}class Nx extends Ut{constructor(s,i,o={}){var m;super();j(this,"sid");j(this,"queue");j(this,"draining");j(this,"max");j(this,"subject");j(this,"drained");j(this,"protocol");j(this,"timer");j(this,"info");j(this,"cleanupFn");j(this,"closed");j(this,"requestSubject");Ou(this,o),this.protocol=s,this.subject=i,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=dt();const c=!((m=s.options)!=null&&m.noAsyncTraces);o.timeout&&(this.timer=sa(o.timeout,c),this.timer.then(()=>{this.timer=void 0}).catch(p=>{this.stop(p),this.noIterator&&this.callback(p,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(s){if(this.noIterator){const i=this.callback,o=s.ingestionFilterFn?s.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),c=s.protocolFilterFn?s.protocolFilterFn:()=>!0,m=s.dispatchedFn?s.dispatchedFn:()=>{};this.callback=(p,g)=>{const{ingest:u}=o(g);u&&c(g)&&(i(p,g),m(g))}}else this.protocolFilterFn=s.protocolFilterFn,this.dispatchedFn=s.dispatchedFn}callback(s,i){this.cancelTimeout(),s?this.stop(s):this.push(i)}close(){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve()};this.noIterator?s():this.push(s)}}unsubscribe(s){this.protocol.unsubscribe(this,s)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(be.errorForCode(fe.ConnectionClosed)):this.isClosed()?Promise.reject(be.errorForCode(fe.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(dt()).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 O2{constructor(){j(this,"mux");j(this,"subs");j(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(e){return this.sidCounter++,e.sid=this.sidCounter,this.subs.set(e.sid,e),e}setMux(e){return this.mux=e,e}getMux(){return this.mux}get(e){return this.subs.get(e)}resub(e){return this.sidCounter++,this.subs.delete(e.sid),e.sid=this.sidCounter,this.subs.set(e.sid,e),e}all(){return Array.from(this.subs.values())}cancel(e){e&&(e.close(),this.subs.delete(e.sid))}handleError(e){if(e&&e.permissionContext){const s=e.permissionContext,i=this.all();let o;if(s.operation==="subscription"&&(o=i.find(c=>c.subject===s.subject&&c.queue===s.queue)),s.operation==="publish"&&(o=i.find(c=>c.requestSubject===s.subject)),o)return o.callback(e,{}),o.close(),this.subs.delete(o.sid),o!==this.mux}return!1}close(){this.subs.forEach(e=>{e.close()})}}class yu{constructor(e,s){j(this,"connected");j(this,"connectedOnce");j(this,"infoReceived");j(this,"info");j(this,"muxSubscriptions");j(this,"options");j(this,"outbound");j(this,"pongs");j(this,"subscriptions");j(this,"transport");j(this,"noMorePublishing");j(this,"connectError");j(this,"publisher");j(this,"_closed");j(this,"closed");j(this,"listeners");j(this,"heartbeats");j(this,"parser");j(this,"outMsgs");j(this,"inMsgs");j(this,"outBytes");j(this,"inBytes");j(this,"pendingLimit");j(this,"lastError");j(this,"abortReconnect");j(this,"whyClosed");j(this,"servers");j(this,"server");j(this,"features");j(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=_2,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=s,this.subscriptions=new O2,this.muxSubscriptions=new o2,this.outbound=new aa,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new IE({major:0,minor:0,micro:0}),this.connectPromise=null;const i=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new a2(i,{randomize:!e.noRandomize}),this.closed=dt(),this.parser=new lb(this),this.heartbeats=new l2(this,this.options.pingInterval||jx,this.options.maxPingOut||y2)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const s=be.errorForCode(fe.Disconnect);s.stack="",e.forEach(i=>{i.reject(s)}),this.parser=new lb(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(s=>{s.push(e)})}status(){const e=new Ut;return this.listeners.push(e),e}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const e=dt();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=s=>{e.reject(s)},this.transport=FE(),this.transport.closed().then(async s=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),e}disconnect(){this.dispatchStatus({type:Qi.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:Qi.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:Dr.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var s;this.dispatchStatus({type:Dr.Reconnect,data:this.servers.getCurrentServer().toString()}),((s=this.lastError)==null?void 0:s.code)===fe.AuthenticationExpired&&(this.lastError=void 0)}).catch(s=>{this._close(s)}):await this._close(e)}async dial(e){const s=this.prepare();let i;try{i=sa(this.options.timeout||2e4);const o=this.transport.connect(e,this.options);await Promise.race([o,i]),(async()=>{try{for await(const c of this.transport)this.parser.parse(c)}catch(c){console.log("reader closed",c)}})().then()}catch(o){s.reject(o)}try{await Promise.race([i,s]),i&&i.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(o){throw i&&i.cancel(),await this.transport.close(o),o}}async _doDial(e){const{resolve:s}=this.options,i=await e.resolve({fn:Cd(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:s});let o=null;for(const c of i)try{o=null,this.dispatchStatus({type:Qi.Reconnecting,data:c.toString()}),await this.dial(c);return}catch(m){o=m}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let e;for(;;){this._closed&&this.servers.clear();const s=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():kx;let i=s;const o=this.selectServer();if(!o||this.abortReconnect)throw e||(this.lastError?this.lastError:be.errorForCode(fe.ConnectionRefused));const c=Date.now();if(o.lastConnect===0||o.lastConnect+s<=c){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(m){if(e=m,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const p=this.options.maxReconnectAttempts||0;p!==-1&&o.reconnects>=p&&this.servers.removeCurrentServer()}}else i=Math.min(i,o.lastConnect+s-c),await oa(i)}}static async connect(e,s){const i=new yu(e,s);return await i.dialLoop(),i}static toError(e){const s=e?e.toLowerCase():"";if(s.indexOf("permissions violation")!==-1){const i=new be(e,fe.PermissionsViolation),o=e.match(/(Publish|Subscription) to "(\S+)"/);if(o){i.permissionContext={operation:o[1].toLowerCase(),subject:o[2],queue:void 0};const c=e.match(/using queue "(\S+)"/);c&&(i.permissionContext.queue=c[1])}return i}else return s.indexOf("authorization violation")!==-1?new be(e,fe.AuthorizationViolation):s.indexOf("user authentication expired")!==-1?new be(e,fe.AuthenticationExpired):s.indexOf("account authentication expired")!=-1?new be(e,fe.AccountExpired):s.indexOf("authentication timeout")!==-1?new be(e,fe.AuthenticationTimeout):new be(e,fe.ProtocolError)}processMsg(e,s){if(this.inMsgs++,this.inBytes+=s.length,!this.subscriptions.sidCounter)return;const i=this.subscriptions.get(e.sid);i&&(i.received+=1,i.callback&&i.callback(null,new fm(e,s,this)),i.max!==void 0&&i.received>=i.max&&i.unsubscribe())}processError(e){const s=Yg(e),i=yu.toError(s),o={type:Dr.Error,data:i.code};if(i.isPermissionError()){let c=!1;if(i.permissionContext){o.permissionContext=i.permissionContext;const m=this.subscriptions.getMux();c=(m==null?void 0:m.subject)===i.permissionContext.subject}this.subscriptions.handleError(i),this.muxSubscriptions.handleError(c,i),c&&this.subscriptions.setMux(null)}this.dispatchStatus(o),this.handleError(i)}handleError(e){e.isAuthError()?this.handleAuthError(e):e.isProtocolError()?this.lastError=e:e.isAuthTimeout()&&(this.lastError=e),e.isPermissionError()||(this.lastError=e)}handleAuthError(e){this.lastError&&e.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(S2)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const s=JSON.parse(Yg(e));this.info=s;const i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(s,this.transport.isEncrypted());if(!this.infoReceived){this.features.update(ti(s.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:c,lang:m}=this.transport;try{const p=new E2({version:c,lang:m},this.options,s.nonce);s.headers&&(p.headers=!0,p.no_responders=!0);const g=JSON.stringify(p);this.transport.send(_o(`CONNECT ${g}${ru}`)),this.transport.send(fb)}catch(p){this._close(p)}}i&&this.dispatchStatus({type:Dr.Update,data:i}),(s.ldm!==void 0?s.ldm:!1)&&this.dispatchStatus({type:Dr.LDM,data:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case Xt.MSG:{const{msg:s,data:i}=e;this.processMsg(s,i);break}case Xt.OK:break;case Xt.ERR:this.processError(e.data);break;case Xt.PING:this.processPing();break;case Xt.PONG:this.processPong();break;case Xt.INFO:this.processInfo(e.data);break}}sendCommand(e,...s){const i=this.outbound.length();let o;typeof e=="string"?o=_o(e):o=e,this.outbound.fill(o,...s),i===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,s=jn,i){let o;if(s instanceof Uint8Array)o=s;else if(typeof s=="string")o=ri.encode(s);else throw be.errorForCode(fe.BadPayload);let c=o.length;i=i||{},i.reply=i.reply||"";let m=jn,p=0;if(i.headers){if(this.info&&!this.info.headers)throw new be("headers",fe.ServerOptionNotAvailable);m=i.headers.encode(),p=m.length,c=o.length+p}if(this.info&&c>this.info.max_payload)throw be.errorForCode(fe.MaxPayloadExceeded);this.outBytes+=c,this.outMsgs++;let g;i.headers?(i.reply?g=`HPUB ${e} ${i.reply} ${p} ${c}\r
40
40
  `:g=`HPUB ${e} ${p} ${c}\r
41
41
  `,this.sendCommand(g,m,o,pu)):(i.reply?g=`PUB ${e} ${i.reply} ${c}\r
42
42
  `:g=`PUB ${e} ${c}\r
@@ -44,24 +44,24 @@ ${this.ctx.stack}`),this.deferred.reject(s)):this.deferred.resolve(i),this.cance
44
44
  `):this.sendCommand(`SUB ${e.subject} ${e.sid}\r
45
45
  `)}_subunsub(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}unsubscribe(e,s){this.unsub(e,s),(e.max===void 0||e.received>=e.max)&&this.subscriptions.cancel(e)}unsub(e,s){!e||this.isClosed()||(s?this.sendCommand(`UNSUB ${e.sid} ${s}\r
46
46
  `):this.sendCommand(`UNSUB ${e.sid}\r
47
- `),e.max=s)}resub(e,s){!e||this.isClosed()||(this.unsub(e),e.subject=s,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||(e=mt()),this.pongs.push(e),this.outbound.fill(fb),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(s=>{const i=s;i.queue?e.push(`SUB ${i.subject} ${i.queue} ${i.sid}${ru}`):e.push(`SUB ${i.subject} ${i.sid}${ru}`)}),e.length&&this.transport.send(vo(e.join("")))}async _close(e){this._closed||(this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(e),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(s=>{s.stop()}),this._closed=!0,await this.transport.close(e),await this.closed.resolve(e))}close(){return this._close()}isClosed(){return this._closed}drain(){const e=this.subscriptions.all(),s=[];return e.forEach(i=>{s.push(i.drain())}),Promise.all(s).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){const s=this.muxSubscriptions.init(this.options.inboxPrefix),i=new Nx(this,`${s}*`);i.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(i),this.subscribe(i)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}const A2="$SRV";class hb{constructor(e){j(this,"msg");this.msg=e}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(e,s){return this.msg.respond(e,s)}respondError(e,s,i,o){var c,m;return o=o||{},o.headers=o.headers||Pr(),(c=o.headers)==null||c.set(fu,`${e}`),(m=o.headers)==null||m.set(uu,s),this.msg.respond(i,o)}json(e){return this.msg.json(e)}string(){return this.msg.string()}}class Ao{constructor(e,s="",i=""){j(this,"subject");j(this,"queue");j(this,"srv");s!==""&&k2("service group",s);let o="";if(e instanceof Do)this.srv=e,o="";else if(e instanceof Ao){const c=e;this.srv=c.srv,i===""&&c.queue!==""&&(i=c.queue),o=c.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=i}calcSubject(e,s=""){return s===""?e:e!==""?`${e}.${s}`:s}addEndpoint(e="",s){s=s||{subject:e};const i=typeof s=="function"?{handler:s,subject:e}:s;go("endpoint",e);let{subject:o,handler:c,metadata:m,queue:p}=i;o=o||e,p=p||this.queue,j2("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:e,subject:o,queue:p,handler:c,metadata:m};return this.srv._addEndpoint(g)}addGroup(e="",s=""){return new Ao(this,e,s)}}function j2(n,e){if(e==="")throw new Error(`${n} cannot be empty`);if(e.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${e}'`);const s=e.split(".");s.forEach((i,o)=>{if(i===">"&&o!==s.length-1)throw new Error(`${n} cannot have internal '>': '${e}'`)})}function k2(n,e){if(e.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${e}'`);e.split(".").forEach(i=>{if(i===">")throw new Error(`${n} name cannot contain internal '>': '${e}'`)})}class Do{constructor(e,s={name:"",version:""}){j(this,"nc");j(this,"_id");j(this,"config");j(this,"handlers");j(this,"internal");j(this,"_stopped");j(this,"_done");j(this,"started");this.nc=e,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),go("name",this.config.name),go("queue",this.config.queue),ti(this.config.version),this._id=As.next(),this.internal=[],this._done=mt(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(i=>{this.close(i).catch()})}static controlSubject(e,s="",i="",o){const c=o??A2;return s===""&&i===""?`${c}.${e}`:(go("control subject name",s),i!==""?(go("control subject id",i),`${c}.${e}.${s}.${i}`):`${c}.${e}.${s}`)}get subjects(){return this.handlers.filter(e=>e.internal===!1).map(e=>e.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(e){const s=Pr();if(e instanceof hu){const i=e;s.set(uu,i.message),s.set(fu,`${i.code}`)}else s.set(uu,e.message),s.set(fu,"500");return s}setupHandler(e,s=!1){const i=s?"":e.queue?e.queue:this.config.queue,{name:o,subject:c,handler:m}=e,p=e;p.internal=s,s&&this.internal.push(p),p.stats=new N2(o,c,i),p.queue=i;const g=m?(u,d)=>{if(u){this.close(u);return}const b=Date.now();try{m(u,new hb(d))}catch(x){p.stats.countError(x),d==null||d.respond(jn,{headers:this.errorToHeader(x)})}finally{p.stats.countLatency(b)}}:void 0;return p.sub=this.nc.subscribe(c,{callback:g,queue:i}),p.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${e.subject} stopped`)).catch()}).catch(u=>{if(!this._stopped){const d=new Error(`required subscription ${e.subject} errored: ${u.message}`);d.stack=u.stack,this.close(d).catch()}}),p}info(){return{type:_o.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(e=>{const{subject:s,metadata:i,name:o,queue:c}=e;return{subject:s,metadata:i,name:o,queue_group:c}})}async stats(){const e=[];for(const s of this.handlers){if(typeof this.config.statsHandler=="function")try{s.stats.data=await this.config.statsHandler(s)}catch(i){s.stats.countError(i)}e.push(s.stats.stats(s.qi))}return{type:_o.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:e}}addInternalHandler(e,s){const i=`${e}`.toUpperCase();this._doAddInternalHandler(`${i}-all`,e,s),this._doAddInternalHandler(`${i}-kind`,e,s,this.name),this._doAddInternalHandler(`${i}`,e,s,this.name,this.id)}_doAddInternalHandler(e,s,i,o="",c=""){const m={};m.name=e,m.subject=Do.controlSubject(s,o,c),m.handler=i,this.setupHandler(m,!0)}start(){const e=er(),s=(m,p)=>m?(this.close(m),Promise.reject(m)):this.stats().then(g=>(p==null||p.respond(e.encode(g)),Promise.resolve())),i=(m,p)=>m?(this.close(m),Promise.reject(m)):(p==null||p.respond(e.encode(this.info())),Promise.resolve()),o=e.encode(this.ping()),c=(m,p)=>m?(this.close(m).then().catch(),Promise.reject(m)):(p.respond(o),Promise.resolve());return this.addInternalHandler(_s.PING,c),this.addInternalHandler(_s.STATS,s),this.addInternalHandler(_s.INFO,i),this.handlers.forEach(m=>{const{subject:p}=m;typeof p=="string"&&m.handler!==null&&this.setupHandler(m)}),Promise.resolve(this)}close(e){if(this._stopped)return this._done;this._stopped=!0;let s=[];return this.nc.isClosed()||(s=this.handlers.concat(this.internal).map(i=>i.sub.drain())),Promise.allSettled(s).then(()=>{this._done.resolve(e||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(e){return this.close(e)}ping(){return{type:_o.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const e of this.handlers)e.stats.reset(e.qi)}addGroup(e,s){return new Ao(this,e,s)}addEndpoint(e,s){return new Ao(this).addEndpoint(e,s)}_addEndpoint(e){const s=new Ut;s.noIterator=typeof e.handler=="function",s.noIterator||(e.handler=(o,c)=>{o?this.stop(o).catch():s.push(new hb(c))},s.iterClosed.then(()=>{this.close().catch()}));const i=this.setupHandler(e,!1);return i.qi=s,this.handlers.push(i),s}}class N2{constructor(e,s,i=""){j(this,"name");j(this,"subject");j(this,"average_processing_time");j(this,"num_requests");j(this,"processing_time");j(this,"num_errors");j(this,"last_error");j(this,"data");j(this,"metadata");j(this,"queue");this.name=e,this.subject=s,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=i}reset(e){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=e;s&&(s.time=0,s.processed=0)}countLatency(e){this.num_requests++,this.processing_time+=dt(Date.now()-e),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(e){this.num_errors++,this.last_error=e.message}_stats(){const{name:e,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:p,data:g,queue:u}=this;return{name:e,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:p,data:g,queue_group:u}}stats(e){const s=e;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=dt(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 T2{constructor(e,s={strategy:Zn.JitterTimer,maxWait:2e3},i){j(this,"nc");j(this,"prefix");j(this,"opts");this.nc=e,this.prefix=i,this.opts=s}ping(e="",s=""){return this.q(_s.PING,e,s)}stats(e="",s=""){return this.q(_s.STATS,e,s)}info(e="",s=""){return this.q(_s.INFO,e,s)}async q(e,s="",i=""){const o=new Ut,c=er(),m=Do.controlSubject(e,s,i,this.prefix),p=await this.nc.requestMany(m,jn,this.opts);return(async()=>{for await(const g of p)try{const u=c.decode(g.data);o.push(u)}catch(u){o.push(()=>{o.stop(u)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function Tx(){return{key:{encode(n){return n},decode(n){return n}},value:{encode(n){return n},decode(n){return n}}}}function C2(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:Tx(),storage:kd.File}}const gu="KV-Operation",db="$KV",M2=/^[-/=.\w]+$/,R2=/^[-/=.>*\w]+$/,D2=/^[-\w]+$/;function L2(n){if(n.startsWith(".")||n.endsWith(".")||!M2.test(n))throw new Error(`invalid key: ${n}`)}function q2(n){if(n.startsWith(".")||n.endsWith(".")||!R2.test(n))throw new Error(`invalid key: ${n}`)}function P2(n){if(n.startsWith(".")||n.endsWith("."))throw new Error(`invalid key: ${n}`);const e=n.split(".");let s=!1;for(let i=0;i<e.length;i++)switch(e[i]){case"*":s=!0;break;case">":if(i!==e.length-1)throw new Error(`invalid key: ${n}`);s=!0;break}return s}function su(n){if(!D2.test(n))throw new Error(`invalid bucket name: ${n}`)}var or;(function(n){n.MsgIdHdr="Nats-Msg-Id",n.ExpectedStreamHdr="Nats-Expected-Stream",n.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",n.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",n.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(or||(or={}));class jo{constructor(e,s,i){j(this,"js");j(this,"jsm");j(this,"stream");j(this,"bucket");j(this,"direct");j(this,"codec");j(this,"prefix");j(this,"editPrefix");j(this,"useJsPrefix");j(this,"_prefixLen");j(this,"validateKey",L2);j(this,"validateSearchKey",q2);j(this,"hasWildcards",P2);su(e),this.js=s,this.jsm=i,this.bucket=e,this.prefix=db,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(e,s,i={}){su(s);const o=await e.jetstreamManager(),c=new jo(s,e,o);return await c.init(i),c}static async bind(e,s,i={}){const o=await e.jetstreamManager(),c={config:{allow_direct:i.allow_direct}};su(s);const m=new jo(s,e,o);return c.config.name=i.streamName??m.bucketName(),Object.assign(m,c),m.stream=c.config.name,m.codec=i.codec||Tx(),m.direct=c.config.allow_direct??!1,m.initializePrefixes(c),m}async init(e={}){const s=Object.assign(C2(),e);this.codec=s.codec;const i={};this.stream=i.name=e.streamName??this.bucketName(),i.retention=jd.Limits,i.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(i.max_bytes=s.max_bytes),i.max_msg_size=s.maxValueSize,i.storage=s.storage;const o=e.placementCluster??"";if(o&&(e.placement={},e.placement.cluster=o,e.placement.tags=[]),e.placement&&(i.placement=e.placement),e.republish&&(i.republish=e.republish),e.description&&(i.description=e.description),e.mirror){const b=Object.assign({},e.mirror);b.name.startsWith(Sn)||(b.name=`${Sn}${b.name}`),i.mirror=b,i.mirror_direct=!0}else if(e.sources){const b=e.sources.map(x=>{const v=Object.assign({},x),_=v.name.startsWith(Sn)?v.name.substring(Sn.length):v.name;return v.name.startsWith(Sn)||(v.name=`${Sn}${v.name}`),!x.external&&_!==this.bucket&&(v.subject_transforms=[{src:`$KV.${_}.>`,dest:`$KV.${this.bucket}.>`}]),v});i.sources=b,i.subjects=[this.subjectForBucket()]}else i.subjects=[this.subjectForBucket()];e.metadata&&(i.metadata=e.metadata),typeof e.compression=="boolean"&&(i.compression=e.compression?js.S2:js.None);const c=this.js.nc,m=c.getServerVersion(),p=m?Td(m,ti("2.7.2"))>=0:!1;i.discard=p?Oo.New:Oo.Old;const{ok:g,min:u}=c.features.get(Ye.JS_ALLOW_DIRECT);if(!g&&e.allow_direct===!0){const b=m?`${m.major}.${m.minor}.${m.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${b} - requires ${u}`))}e.allow_direct=typeof e.allow_direct=="boolean"?e.allow_direct:g,i.allow_direct=e.allow_direct,this.direct=i.allow_direct,i.num_replicas=s.replicas,s.ttl&&(i.max_age=dt(s.ttl)),i.allow_rollup_hdrs=!0;let d;try{d=await this.jsm.streams.info(i.name),!d.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(b){if(b.message==="stream not found")d=await this.jsm.streams.add(i);else throw b}this.initializePrefixes(d)}initializePrefixes(e){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:s}=e.config;if(s){let i=s.name;if(i.startsWith(Sn)&&(i=i.substring(Sn.length)),s.external&&s.external.api!==""){const o=s.name.substring(Sn.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${i}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${Sn}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(e,s=!1){const i=[];return s?(this.useJsPrefix&&i.push(this.js.apiPrefix),this.editPrefix!==""?i.push(this.editPrefix):i.push(this.prefix)):this.prefix&&i.push(this.prefix),i.push(e),i.join(".")}fullKeyName(e){return this.prefix!==""?`${this.prefix}.${e}`:`${db}.${this.bucket}.${e}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(e){const s=[];for(const i of e.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.encode(i));break}return s.join(".")}decodeKey(e){const s=[];for(const i of e.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.decode(i));break}return s.join(".")}close(){return Promise.resolve()}dataLen(e,s){const i=s&&s.get(Wt.MessageSizeHdr)||"";return i!==""?parseInt(i,10):e.length}smToEntry(e){return new W2(this.bucket,this.prefixLen,e)}jmToEntry(e){const s=this.decodeKey(e.subject.substring(this.prefixLen));return new Z2(this.bucket,s,e)}async create(e,s){var c;let i;try{const m=await this.put(e,s,{previousSeq:0});return Promise.resolve(m)}catch(m){if(i=m,((c=m==null?void 0:m.api_error)==null?void 0:c.err_code)!==10071)return Promise.reject(m)}let o=0;try{const m=await this.get(e);return(m==null?void 0:m.operation)==="DEL"||(m==null?void 0:m.operation)==="PURGE"?(o=m!==null?m.revision:0,this.update(e,s,o)):Promise.reject(i)}catch(m){return Promise.reject(m)}}update(e,s,i){if(i<=0)throw new Error("version must be greater than 0");return this.put(e,s,{previousSeq:i})}async put(e,s,i={}){var m,p;const o=this.encodeKey(e);this.validateKey(o);const c={};if(i.previousSeq!==void 0){const g=Pr();c.headers=g,g.set(or.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,c)).seq}catch(g){const u=g;return u.isJetStreamError()?(u.message=(m=u.api_error)==null?void 0:m.description,u.code=`${(p=u.api_error)==null?void 0:p.code}`,Promise.reject(u)):Promise.reject(g)}}async get(e,s){const i=this.encodeKey(e);this.validateKey(i);let o={last_by_subj:this.subjectForKey(i)};s&&s.revision>0&&(o={seq:s.revision});let c;try{this.direct?c=await this.jsm.direct.getMessage(this.bucketName(),o):c=await this.jsm.streams.getMessage(this.bucketName(),o);const m=this.smToEntry(c);return m.key!==i?null:m}catch(m){if(m.code===fe.JetStream404NoMessages)return null;throw m}}purge(e,s){return this._deleteOrPurge(e,"PURGE",s)}delete(e,s){return this._deleteOrPurge(e,"DEL",s)}async purgeDeletes(e=1800*1e3){const s=mt(),i=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&i.push(g)})().then(),await s,o.stop();const c=Date.now()-e,m=i.map(g=>{const u=this.subjectForKey(g.key);return g.created.getTime()>=c?this.jsm.streams.purge(this.stream,{filter:u,keep:1}):this.jsm.streams.purge(this.stream,{filter:u,keep:0})}),p=await Promise.all(m);return p.unshift({success:!0,purged:0}),p.reduce((g,u)=>(g.purged+=u.purged,g))}async _deleteOrPurge(e,s,i){if(!this.hasWildcards(e))return this._doDeleteOrPurge(e,s,i);const o=await this.keys(e),c=[];for await(const m of o)c.push(this._doDeleteOrPurge(m,s)),c.length===100&&(await Promise.all(c),c.length=0);c.length>0&&await Promise.all(c)}async _doDeleteOrPurge(e,s,i){const o=this.encodeKey(e);this.validateKey(o);const c=Pr();c.set(gu,s),s==="PURGE"&&c.set(Wt.RollupHdr,Wt.RollupValueSubject),i!=null&&i.previousSeq&&c.set(or.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),jn,{headers:c})}_buildCC(e,s,i={}){let c=(Array.isArray(e)?e:[e]).map(g=>{const u=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(u)}),m=Et.LastPerSubject;s===Xn.AllHistory&&(m=Et.All),s===Xn.UpdatesOnly&&(m=Et.New);let p;return c.length===1&&(p=c[0],c=void 0),Object.assign({deliver_policy:m,ack_policy:Bt.None,filter_subjects:c,filter_subject:p,flow_control:!0,idle_heartbeat:dt(5*1e3)},i)}remove(e){return this.purge(e)}async history(e={}){const s=e.key??">",i=new Ut,o={};o.headers_only=e.headers_only||!1;let c;c=()=>{i.stop()};let m=0;const p=this._buildCC(s,Xn.AllHistory,o),g=p.filter_subject,u=Ss(p);u.bindStream(this.stream),u.orderedConsumer(),u.callback((b,x)=>{if(b){i.stop(b);return}if(x){const v=this.jmToEntry(x);i.push(v),i.received++,(c&&m>0&&i.received>=m||x.info.pending===0)&&(i.push(c),c=void 0)}});const d=await this.js.subscribe(g,u);if(c){const{info:{last:b}}=d,x=b.num_pending+b.delivered.consumer_seq;if(x===0||i.received>=x)try{c()}catch(v){i.stop(v)}finally{c=void 0}else m=x}return i._data=d,i.iterClosed.then(()=>{d.unsubscribe()}),d.closed.then(()=>{i.stop()}).catch(b=>{i.stop(b)}),i}canSetWatcherName(){const s=this.js.nc,{ok:i}=s.features.get(Ye.JS_NEW_CONSUMER_CREATE_API);return i}async watch(e={}){const s=e.key??">",i=new Ut,o={};o.headers_only=e.headers_only||!1;let c=Xn.LastValue;e.include===Xn.AllHistory?c=Xn.AllHistory:e.include===Xn.UpdatesOnly&&(c=Xn.UpdatesOnly);const m=e.ignoreDeletes===!0;let p=e.initializedFn,g=0;const u=this._buildCC(s,c,o),d=u.filter_subject,b=Ss(u);this.canSetWatcherName()&&b.consumerName(As.next()),b.bindStream(this.stream),e.resumeFromRevision&&e.resumeFromRevision>0&&b.startSequence(e.resumeFromRevision),b.orderedConsumer(),b.callback((v,_)=>{if(v){i.stop(v);return}if(_){const S=this.jmToEntry(_);if(m&&S.operation==="DEL")return;i.push(S),i.received++,p&&(g>0&&i.received>=g||_.info.pending===0)&&(i.push(p),p=void 0)}});const x=await this.js.subscribe(d,b);if(p){const{info:{last:v}}=x,_=v.num_pending+v.delivered.consumer_seq;if(_===0||i.received>=_)try{p()}catch(S){i.stop(S)}finally{p=void 0}else g=_}return i._data=x,i.iterClosed.then(()=>{x.unsubscribe()}),x.closed.then(()=>{i.stop()}).catch(v=>{i.stop(v)}),i}async keys(e=">"){const s=new Ut,i=this._buildCC(e,Xn.LastValue,{headers_only:!0}),o=Array.isArray(e)?">":i.filter_subject,c=Ss(i);c.bindStream(this.stream),c.orderedConsumer();const m=await this.js.subscribe(o,c);return(async()=>{var g;for await(const u of m){const d=(g=u.headers)==null?void 0:g.get(gu);if(d!=="DEL"&&d!=="PURGE"){const b=this.decodeKey(u.subject.substring(this.prefixLen));s.push(b)}u.info.pending===0&&m.unsubscribe()}})().then(()=>{s.stop()}).catch(g=>{s.stop(g)}),m.info.last.num_pending===0&&m.unsubscribe(),s}purgeBucket(e){return this.jsm.streams.purge(this.bucketName(),e)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var c;const s=((c=this.js.nc.info)==null?void 0:c.cluster)??"",i=this.bucketName(),o=await this.jsm.streams.info(i);return new Cx(o,s)}}class Cx{constructor(e,s=""){j(this,"si");j(this,"cluster");this.si=e,this.cluster=s}get bucket(){return this.si.config.name.startsWith(Sn)?this.si.config.name.substring(Sn.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 um(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 e;return((e=this.si.config.placement)==null?void 0:e.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!==js.None:!1}}const dm="OBJ_",mb="SHA-256=";function B2(n){return su(n),`${dm}${n}`}function U2(n){return n.startsWith(dm)?n.substring(4):n}class Dd{constructor(e){j(this,"si");j(this,"backingStore");this.si=e,this.backingStore="JetStream"}get bucket(){return U2(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!==js.None:!1}}function cc(n){if(n===void 0)return;const{domain:e}=n;if(e===void 0)return n;const s=Object.assign({},n);if(delete s.domain,e==="")return s;if(s.external)throw new Error("domain and external are both set");return s.external={api:`$JS.${e}.API`},s}var zn;(function(n){n[n.Unset=-1]="Unset",n[n.Consume=0]="Consume",n[n.Fetch=1]="Fetch"})(zn||(zn={}));var lr;(function(n){n.HeartbeatsMissed="heartbeats_missed",n.ConsumerNotFound="consumer_not_found",n.StreamNotFound="stream_not_found",n.ConsumerDeleted="consumer_deleted",n.OrderedConsumerRecreated="ordered_consumer_recreated",n.NoResponders="no_responders"})(lr||(lr={}));var ea;(function(n){n.DebugEvent="debug",n.Discard="discard",n.Reset="reset",n.Next="next"})(ea||(ea={}));const pb=Uint8Array.of(43,65,67,75),z2=Uint8Array.of(45,78,65,75),io=Uint8Array.of(43,87,80,73),I2=Uint8Array.of(43,78,88,84),$2=Uint8Array.of(43,84,69,82,77),H2=Uint8Array.of(32);function ko(n,e=5e3){return new aO(n,e)}class sd extends Ut{constructor(s,i,o=!1){super();j(this,"consumer");j(this,"opts");j(this,"sub");j(this,"monitor");j(this,"pending");j(this,"inbox");j(this,"refilling");j(this,"pong");j(this,"callback");j(this,"timeout");j(this,"cleanupHandler");j(this,"listeners");j(this,"statusIterator");j(this,"forOrderedConsumer");j(this,"resetHandler");j(this,"abortOnMissingResource");j(this,"bind");j(this,"inBackOff");this.consumer=s;const c=i;this.opts=this.parseOptions(i,o),this.callback=c.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=o,this.timeout=null,this.inbox=Lr(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=c.abort_on_missing_resource===!0,this.bind=c.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:i,idle_heartbeat:o,threshold_bytes:c,threshold_messages:m}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:p}=this;p&&p.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,u)=>{var b,x,v,_;if(g){this.stop(g);return}if((b=this.monitor)==null||b.work(),u.subject===this.inbox){if(Ad(u))return;const S=(x=u.headers)==null?void 0:x.code,C=((_=(v=u.headers)==null?void 0:v.description)==null?void 0:_.toLowerCase())||"unknown",{msgsLeft:B,bytesLeft:q}=this.parseDiscard(u.headers);if(B>0||q>0)this.pending.msgs-=B,this.pending.bytes-=q,this.pending.requests--,this.notify(ea.Discard,{msgsLeft:B,bytesLeft:q});else if(S===400){this.stop(new ge(C,`${S}`));return}else if(S===409&&C==="consumer deleted"){if(this.notify(lr.ConsumerDeleted,`${S} ${C}`),!this.refilling||this.abortOnMissingResource){const ne=new ge(C,`${S}`);this.stop(ne);return}}else if(S===503){if(this.notify(lr.NoResponders,`${S} No Responders`),!this.refilling||this.abortOnMissingResource){const ne=new ge("no responders",`${S}`);this.stop(ne);return}}else this.notify(ea.DebugEvent,`${S} ${C}`)}else this._push(ko(u,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=u.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=m||i&&this.pending.bytes<=c){const S=this.pullOptions();this.pull(S)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new hm(o,g=>(this.notify(lr.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var u;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const d of g)switch(d.type){case Dr.Disconnect:(u=this.monitor)==null||u.cancel();break;case Dr.Reconnect:this.resetPending().then(b=>{var x;b&&((x=this.monitor)==null||x.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const i=typeof s=="function"?s:null;try{i?i():this.callback(s)}catch(o){this.stop(o)}}}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}resetPending(){return this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo()}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){if(this.inBackOff)return!1;let s=0,i=0;const o=cm([this.opts.expires]);let c=0;for(;;){if(this.done)return!1;if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),this.inBackOff=!1,s=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(m){if(m.message==="stream not found"){if(i++,this.notify(lr.StreamNotFound,i),!this.refilling||this.abortOnMissingResource)return this.stop(m),!1}else if(m.message==="consumer not found"){if(s++,this.notify(lr.ConsumerNotFound,s),this.resetHandler)try{this.resetHandler()}catch{}if(!this.refilling||this.abortOnMissingResource)return this.stop(m),!1;if(this.forOrderedConsumer)return!1}else s=0,i=0;this.inBackOff=!0;const p=o.backoff(c),g=aa(p);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),c++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const i=this.consumer.api.nc;this._push(()=>{i.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(s),{reply:this.inbox}),this.notify(ea.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,i=this.opts.max_bytes-this.pending.bytes,o=dt(this.opts.idle_heartbeat),c=dt(this.opts.expires);return{batch:s,max_bytes:i,idle_heartbeat:o,expires:c}}parseDiscard(s){const i={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Wt.PendingMessagesHdr);o&&(i.msgsLeft=parseInt(o));const c=s==null?void 0:s.get(Wt.PendingBytesHdr);return c&&(i.bytesLeft=parseInt(c)),i}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,i;(s=this.monitor)==null||s.cancel(),this.monitor=null,(i=this.timeout)==null||i.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var i,o;this.done||((i=this.sub)==null||i.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(c=>{c.stop()})}))}parseOptions(s,i=!1){const o=s||{};if(o.max_messages=o.max_messages||0,o.max_bytes=o.max_bytes||0,o.max_messages!==0&&o.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(o.max_messages===0&&(o.max_messages=100),o.expires=o.expires||3e4,o.expires<1e3)throw new Error("expires should be at least 1000ms");if(o.idle_heartbeat=o.idle_heartbeat||o.expires/2,o.idle_heartbeat=o.idle_heartbeat>3e4?3e4:o.idle_heartbeat,i){const c=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||c;const m=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||m}return o}status(){const s=new Ut;return this.listeners.push(s),Promise.resolve(s)}}class F2 extends Ut{constructor(){super();j(this,"src");j(this,"listeners");this.listeners=[]}setSource(s){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=s,this.src.setCleanupHandler(i=>{this.stop(i||void 0)}),(async()=>{const i=await this.src.status();for await(const o of i)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}stop(s){var i;this.done||((i=this.src)==null||i.stop(s),super.stop(s),this.listeners.forEach(o=>{o.stop()}))}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}status(){const s=new Ut;return this.listeners.push(s),Promise.resolve(s)}}class Ld{constructor(e,s){j(this,"api");j(this,"_info");j(this,"stream");j(this,"name");this.api=e,this._info=s,this.stream=s.stream_name,this.name=s.name}consume(e={max_messages:100,expires:3e4}){return Promise.resolve(new sd(this,e,!0))}fetch(e={max_messages:100,expires:3e4}){const s=new sd(this,e,!1),i=Math.round(s.opts.expires*1.05),o=ra(i);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(e={expires:3e4}){const s=mt(),i=e;i.max_messages=1;const o=new sd(this,i,!1),c=Math.round(o.opts.expires*1.05);c>=6e4&&(async()=>{for await(const p of await o.status())if(p.type===lr.HeartbeatsMissed&&p.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const p of o){s.resolve(p);break}})().catch(()=>{});const m=ra(c);return o.closed().then(p=>{p?s.reject(p):s.resolve(null)}).catch(p=>{s.reject(p)}).finally(()=>{m.cancel()}),m.catch(p=>{s.resolve(null),o.close().catch()}),o.trackTimeout(m),s}delete(){const{stream_name:e,name:s}=this._info;return this.api.delete(e,s)}info(e=!1){if(e)return Promise.resolve(this._info);const{stream_name:s,name:i}=this._info;return this.api.info(s,i).then(o=>(this._info=o,this._info))}}class G2{constructor(e,s,i={}){j(this,"api");j(this,"consumerOpts");j(this,"consumer");j(this,"opts");j(this,"cursor");j(this,"stream");j(this,"namePrefix");j(this,"serial");j(this,"currentConsumer");j(this,"userCallback");j(this,"iter");j(this,"type");j(this,"startSeq");j(this,"maxInitialReset");this.api=e,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=As.next(),typeof i.name_prefix=="string"&&(Au("name_prefix",i.name_prefix),this.namePrefix=i.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=zn.Unset,this.consumerOpts=i,this.maxInitialReset=30,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(e){this.serial++;const s=`${this.namePrefix}_${this.serial}`;e=e===0?1:e;const i={name:s,deliver_policy:Et.StartSequence,opt_start_seq:e,ack_policy:Bt.None,inactive_threshold:dt(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(i.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(i.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(i.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(i.replay_policy=this.consumerOpts.replay_policy),e===this.startSeq+1&&(i.deliver_policy=this.consumerOpts.deliver_policy||Et.StartSequence,(this.consumerOpts.deliver_policy===Et.LastPerSubject||this.consumerOpts.deliver_policy===Et.New||this.consumerOpts.deliver_policy===Et.Last)&&(delete i.opt_start_seq,i.deliver_policy=this.consumerOpts.deliver_policy),i.deliver_policy===Et.LastPerSubject&&typeof i.filter_subjects>"u"&&typeof i.filter_subject>"u"&&(i.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete i.opt_start_seq,i.deliver_policy=Et.StartTime,i.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(i.inactive_threshold=dt(this.consumerOpts.inactive_threshold))),i}async resetConsumer(e=0){var m,p,g,u,d;As.next();const s=this.serial===0;(m=this.consumer)==null||m.delete().catch(()=>{}),e=e===0?1:e,this.cursor.deliver_seq=0;const i=this.getConsumerOpts(e);i.max_deliver=1,i.mem_storage=!0;const o=cm([((p=this.opts)==null?void 0:p.expires)||3e4]);let c;for(let b=0;;b++)try{c=await this.api.add(this.stream,i),(g=this.iter)==null||g.notify(lr.OrderedConsumerRecreated,c.name);break}catch(x){if(x.message==="stream not found"&&((u=this.iter)==null||u.notify(lr.StreamNotFound,b),this.type===zn.Fetch||this.opts.abort_on_missing_resource===!0))return(d=this.iter)==null||d.stop(x),Promise.reject(x);if(s&&b>=this.maxInitialReset)throw x;await aa(o.backoff(b+1))}return c}internalHandler(e){return s=>{var o;if(this.serial!==e)return;const i=s.info.deliverySequence;if(i!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=i,this.cursor.stream_seq=s.info.streamSequence,this.userCallback?this.userCallback(s):(o=this.iter)==null||o.push(s)}}async reset(e={max_messages:100,expires:3e4},s){var g,u;s=s||{};const i=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===zn.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((u=this.iter)==null?void 0:u.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||i)&&(this.iter=new F2),this.consumer=new Ld(this.api,this.currentConsumer);const c=e;c.callback=this.internalHandler(this.serial);let m=null;this.type===zn.Fetch&&i?m=await this.consumer.fetch(e):this.type===zn.Consume&&(m=await this.consumer.consume(e));const p=m;p.forOrderedConsumer=!0,p.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(p)}notifyOrderedResetAndReset(){var e;(e=this.iter)==null||e.notify(ea.Reset,""),this.reset(this.opts,{orderedReset:!0})}async consume(e={max_messages:100,expires:3e4}){if(e.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===zn.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===zn.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:i}=e;return i&&(this.userCallback=i),this.type=zn.Consume,this.opts=e,await this.reset(e),this.iter}async fetch(e={max_messages:100,expires:3e4}){var o;if(e.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===zn.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((o=this.iter)==null?void 0:o.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:i}=e;return i&&(this.userCallback=i),this.type=zn.Fetch,this.opts=e,await this.reset(e,{fromFetch:!0}),this.iter}async next(e={expires:3e4}){const s=e;if(s.bind)return Promise.reject(new Error("bind is not supported"));s.max_messages=1;const i=mt();return s.callback=c=>{this.userCallback=null,i.resolve(c)},(await this.fetch(s)).iterClosed.then(c=>{c&&i.reject(c),i.resolve(null)}).catch(c=>{i.reject(c)}),i}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(e=>Promise.resolve(e)).catch(e=>Promise.reject(e)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(e){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.startSeq),Promise.resolve(this.currentConsumer)):e&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}class qd{constructor(e){j(this,"api");j(this,"notified");this.api=e,this.notified=!1}checkVersion(){const e=this.api.nc.features.get(Ye.JS_SIMPLIFICATION);return e.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${e.min} or better`))}getPullConsumerFor(e){if(e.config.deliver_subject!==void 0)throw new Error("push consumer not supported");return new Ld(this.api,e)}async get(e,s={}){return typeof s=="object"?this.ordered(e,s):(await this.checkVersion(),this.api.info(e,s).then(i=>i.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Ld(this.api,i)).catch(i=>Promise.reject(i)))}async ordered(e,s){await this.checkVersion();const i=this.api;return new mm(i.nc,i.opts).info(e).then(c=>Promise.resolve(new G2(this.api,e,s))).catch(c=>Promise.reject(c))}}class ku{constructor(e,s){j(this,"api");j(this,"_info");this.api=e,this._info=s}get name(){return this._info.config.name}alternates(){return this.info().then(e=>e.alternates?e.alternates:[])}async best(){if(await this.info(),this._info.alternates){const e=await this.api.info(this._info.alternates[0].name);return new ku(this.api,e)}else return this}info(e=!1,s){return e?Promise.resolve(this._info):this.api.info(this.name,s).then(i=>(this._info=i,this._info))}getConsumerFromInfo(e){return new qd(new mu(this.api.nc,this.api.opts)).getPullConsumerFor(e)}getConsumer(e){return new qd(new mu(this.api.nc,this.api.opts)).get(this.name,e)}getMessage(e){return this.api.getMessage(this.name,e)}deleteMessage(e,s){return this.api.deleteMessage(this.name,e,s)}}class mm extends Ro{constructor(e,s){super(e,s)}checkStreamConfigVersions(e){const s=this.nc;if(e.metadata){const{min:o,ok:c}=s.features.get(Ye.JS_STREAM_CONSUMER_METADATA);if(!c)throw new Error(`stream 'metadata' requires server ${o}`)}if(e.first_seq){const{min:o,ok:c}=s.features.get(Ye.JS_STREAM_FIRST_SEQ);if(!c)throw new Error(`stream 'first_seq' requires server ${o}`)}if(e.subject_transform){const{min:o,ok:c}=s.features.get(Ye.JS_STREAM_SUBJECT_TRANSFORM);if(!c)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(e.compression){const{min:o,ok:c}=s.features.get(Ye.JS_STREAM_COMPRESSION);if(!c)throw new Error(`stream 'compression' requires server ${o}`)}if(e.consumer_limits){const{min:o,ok:c}=s.features.get(Ye.JS_DEFAULT_CONSUMER_LIMITS);if(!c)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function i(o,c){var p;if((((p=c==null?void 0:c.subject_transforms)==null?void 0:p.length)||0)>0){const{min:g,ok:u}=s.features.get(Ye.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!u)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}e.sources&&e.sources.forEach(o=>{i("stream sources",o)}),e.mirror&&i("stream mirror",e.mirror)}async add(e={}){var o;this.checkStreamConfigVersions(e),Jt(e.name),e.mirror=cc(e.mirror),e.sources=(o=e.sources)==null?void 0:o.map(cc);const i=await this._request(`${this.prefix}.STREAM.CREATE.${e.name}`,e);return this._fixInfo(i),i}async delete(e){return Jt(e),(await this._request(`${this.prefix}.STREAM.DELETE.${e}`)).success}async update(e,s={}){var p;if(typeof e=="object"){const g=e;e=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),Jt(e);const i=await this.info(e),o=Object.assign(i.config,s);o.mirror=cc(o.mirror),o.sources=(p=o.sources)==null?void 0:p.map(cc);const m=await this._request(`${this.prefix}.STREAM.UPDATE.${e}`,o);return this._fixInfo(m),m}async info(e,s){Jt(e);const i=`${this.prefix}.STREAM.INFO.${e}`;let c=await this._request(i,s),{total:m,limit:p}=c,g=c.state.subjects?Object.getOwnPropertyNames(c.state.subjects).length:1;if(m&&m>g){const u=[c],d=s||{};let b=0;for(;m>g;){b++,d.offset=p*b;const v=await this._request(i,d);m=v.total,u.push(v);const _=Object.getOwnPropertyNames(v.state.subjects).length;if(g+=_,_<p)break}let x={};for(let v=0;v<u.length;v++)c=u[v],c.state.subjects&&(x=Object.assign(x,c.state.subjects));c.offset=0,c.total=0,c.limit=0,c.state.subjects=x}return this._fixInfo(c),c}list(e=""){const s=e!=null&&e.length?{subject:e}:{},i=c=>{const m=c;return m.streams.forEach(p=>{this._fixInfo(p)}),m.streams},o=`${this.prefix}.STREAM.LIST`;return new bo(o,i,this,s)}_fixInfo(e){e.config.sealed=e.config.sealed||!1,e.config.deny_delete=e.config.deny_delete||!1,e.config.deny_purge=e.config.deny_purge||!1,e.config.allow_rollup_hdrs=e.config.allow_rollup_hdrs||!1}async purge(e,s){if(s){const{keep:o,seq:c}=s;if(typeof o=="number"&&typeof c=="number")throw new Error("can specify one of keep or seq")}return Jt(e),await this._request(`${this.prefix}.STREAM.PURGE.${e}`,s)}async deleteMessage(e,s,i=!0){Jt(e);const o={seq:s};return i||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${e}`,o)).success}async getMessage(e,s){Jt(e);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${e}`,s);return new Mx(o)}find(e){return this.findStream(e)}listKvs(){const e=i=>{var g;const c=i.streams.filter(u=>u.config.name.startsWith(Sn));c.forEach(u=>{this._fixInfo(u)});let m="";return c.length&&(m=((g=this.nc.info)==null?void 0:g.cluster)??""),c.map(u=>new Cx(u,m))},s=`${this.prefix}.STREAM.LIST`;return new bo(s,e,this)}listObjectStores(){const e=i=>{const c=i.streams.filter(p=>p.config.name.startsWith(dm));return c.forEach(p=>{this._fixInfo(p)}),c.map(p=>new Dd(p))},s=`${this.prefix}.STREAM.LIST`;return new bo(s,e,this)}names(e=""){const s=e!=null&&e.length?{subject:e}:{},i=c=>c.streams,o=`${this.prefix}.STREAM.NAMES`;return new bo(o,i,this,s)}async get(e){const s=await this.info(e);return Promise.resolve(new ku(this,s))}}class V2 extends Ro{constructor(e,s){super(e,s)}async getMessage(e,s){Jt(e);let i=s;const{last_by_subj:o}=i;o&&(i=null);const c=i?this.jc.encode(i):jn,m=this.opts.apiPrefix||"$JS.API",p=o?`${m}.DIRECT.GET.${e}.${o}`:`${m}.DIRECT.GET.${e}`,g=await this.nc.request(p,c,{timeout:this.timeout}),u=Wi(g);if(u)return Promise.reject(u);const d=new Pd(g);return Promise.resolve(d)}async getBatch(e,s){Jt(e);const o=`${this.opts.apiPrefix||"$JS.API"}.DIRECT.GET.${e}`;if(!Array.isArray(s.multi_last)||s.multi_last.length===0)return Promise.reject("multi_last is required");const c=JSON.stringify(s,(g,u)=>g==="up_to_time"&&u instanceof Date?u.toISOString():u),m=new Ut,p=await this.nc.requestMany(o,c,{strategy:Zn.SentinelMsg});return(async()=>{var b,x,v;let g=!1,u=!1,d;for await(const _ of p){if(!g){g=!0;const S=((b=_.headers)==null?void 0:b.code)||0;if(S!==0&&S<200||S>299){d=(x=_.headers)==null?void 0:x.description.toLowerCase();break}if(((v=_.headers)==null?void 0:v.get("Nats-Num-Pending"))===""){u=!0;break}}if(_.data.length===0)break;m.push(new Pd(_))}m.push(()=>{if(u)throw new Error("batch direct get not supported by the server");if(d)throw new Error(`bad request: ${d}`);m.stop()})})(),Promise.resolve(m)}}class Pd{constructor(e){j(this,"data");j(this,"header");if(!e.headers)throw new Error("headers expected");this.data=e.data,this.header=e.headers}get subject(){return this.header.last(Ji.Subject)}get seq(){const e=this.header.last(Ji.Sequence);return typeof e=="string"?parseInt(e):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(Ji.TimeStamp)}get stream(){return this.header.last(Ji.Stream)}json(e){return er(e).decode(this.data)}string(){return En.decode(this.data)}}j(Pd,"jc");class Y2 extends Ro{constructor(s,i){super(s,i);j(this,"streams");j(this,"consumers");j(this,"direct");this.streams=new mm(s,i),this.consumers=new mu(s,i),this.direct=new V2(s,i)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new Ut;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(i,o)=>{if(i)throw i;try{const c=this.parseJsResponse(o),m=c.type.split("."),p=m[m.length-1];s.push({kind:p,data:c})}catch(c){s.stop(c)}}}),s}}class Mx{constructor(e){j(this,"_header");j(this,"smr");this.smr=e}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):jn}get header(){if(!this._header)if(this.smr.message.hdrs){const e=this._parse(this.smr.message.hdrs);this._header=ws.decode(e)}else this._header=Pr();return this._header}_parse(e){const s=atob(e),i=s.length,o=new Uint8Array(i);for(let c=0;c<i;c++)o[c]=s.charCodeAt(c);return o}json(e){return er(e).decode(this.data)}string(){return En.decode(this.data)}}j(Mx,"jc");class K2{constructor(e){j(this,"api");this.api=e}get(e){return this.api.info(e).then(s=>new ku(this.api,s))}}class id{constructor(e){j(this,"info");j(this,"hdrs");this.info=e}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=ws.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 e,s;return((e=this.info.options)==null?void 0:e.link)!==void 0&&((s=this.info.options)==null?void 0:s.link)!==null}}function yb(n){const e={name:n.name,description:n.description??"",options:n.options,metadata:n.metadata};if(n.headers){const s=n.headers;e.headers=s.toRecord()}return e}function J2(){return new ReadableStream({pull(n){n.enqueue(new Uint8Array(0)),n.close()}})}class So{constructor(e,s,i){j(this,"jsm");j(this,"js");j(this,"stream");j(this,"name");this.name=e,this.jsm=s,this.js=i}_checkNotEmpty(e){return!e||e.length===0?{name:e,error:new Error("name cannot be empty")}:{name:e}}async info(e){const s=await this.rawInfo(e);return s?new id(s):null}async list(){const e=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const i of s){if(i===null)break;e.push(i)}return Promise.resolve(e)}async rawInfo(e){const{name:s,error:i}=this._checkNotEmpty(e);if(i)return Promise.reject(i);const o=this._metaSubject(s);try{const c=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),p=er().decode(c.data);return p.revision=c.seq,p}catch(c){return c.code==="404"?null:Promise.reject(c)}}async _si(e){try{return await this.jsm.streams.info(this.stream,e)}catch(s){return s.code==="404"?null:Promise.reject(s)}}async seal(){let e=await this._si();return e===null?Promise.reject(new Error("object store not found")):(e.config.sealed=!0,e=await this.jsm.streams.update(this.stream,e.config),Promise.resolve(new Dd(e)))}async status(e){const s=await this._si(e);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new Dd(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(e,s,i){var te;const o=this.js.getOptions();i=i||{timeout:o.timeout},i.timeout=i.timeout||o.timeout,i.previousRevision=i.previousRevision??void 0;const{timeout:c,previousRevision:m}=i,p=this.js.nc.info,g=(p==null?void 0:p.max_payload)||1024;e=e||{},e.options=e.options||{};let u=((te=e.options)==null?void 0:te.max_chunk_size)||128*1024;u=u>g?g:u,e.options.max_chunk_size=u;const d=await this.info(e.name),{name:b,error:x}=this._checkNotEmpty(e.name);if(x)return Promise.reject(x);const v=As.next(),_=this._chunkSubject(v),S=this._metaSubject(b),C=Object.assign({bucket:this.name,nuid:v,size:0,chunks:0},yb(e)),B=mt(),q=[],ne=new ia;try{const M=s?s.getReader():null,z=ib.create();for(;;){const{done:ae,value:F}=M?await M.read():{done:!0,value:void 0};if(ae){if(ne.size()>0){const W=ne.drain();z.update(W),C.chunks++,C.size+=W.length,q.push(this.js.publish(_,W,{timeout:c}))}await Promise.all(q),q.length=0,C.mtime=new Date().toISOString();const U=Zi.encode(z.digest());C.digest=`${mb}${U}`,C.deleted=!1;const D=Pr();typeof m=="number"&&D.set(or.ExpectedLastSubjectSequenceHdr,`${m}`),D.set(Wt.RollupHdr,Wt.RollupValueSubject);const X=await this.js.publish(S,er().encode(C),{headers:D,timeout:c});if(C.revision=X.seq,d)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${d.nuid}`})}catch{}B.resolve(new id(C));break}if(F)for(ne.fill(F);ne.size()>u;){C.chunks++,C.size+=u;const U=ne.drain(e.options.max_chunk_size);z.update(U),q.push(this.js.publish(_,U,{timeout:c}))}}}catch(M){await this.jsm.streams.purge(this.stream,{filter:_}),B.reject(M)}return B}putBlob(e,s,i){function o(c){return new ReadableStream({pull(m){m.enqueue(c),m.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(e,o(s),i)}put(e,s,i){var o;return(o=e==null?void 0:e.options)!=null&&o.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(e,s,i)}async getBlob(e){async function s(c){const m=new ia,p=c.getReader();for(;;){const{done:g,value:u}=await p.read();if(g)return m.drain();u&&u.length&&m.fill(u)}}const i=await this.get(e);if(i===null)return Promise.resolve(null);const o=await Promise.all([i.error,s(i.data)]);return o[0]?Promise.reject(o[0]):Promise.resolve(o[1])}async get(e){const s=await this.rawInfo(e);if(s===null||s.deleted)return Promise.resolve(null);if(s.options&&s.options.link){const b=s.options.link.name||"";if(b==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await So.create(this.js,s.options.link.bucket):this).get(b)}if(!s.digest.startsWith(mb))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const i=Nd(s.digest.substring(8));if(i===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=mt(),c={info:new id(s),error:o};if(s.size===0)return c.data=J2(),o.resolve(null),Promise.resolve(c);let m;const p=Ss();p.orderedConsumer();const g=ib.create(),u=`$O.${this.name}.C.${s.nuid}`,d=await this.js.subscribe(u,p);return(async()=>{for await(const b of d)b.data.length>0&&(g.update(b.data),m.enqueue(b.data)),b.info.pending===0&&(PE(i,g.digest())?m.close():m.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${i}`)),d.unsubscribe())})().then(()=>{o.resolve()}).catch(b=>{m.error(b),o.reject(b)}),c.data=new ReadableStream({start(b){m=b},cancel(){d.unsubscribe()}}),c}linkStore(e,s){if(!(s instanceof So))return Promise.reject("bucket required");const i=s,{name:o,error:c}=this._checkNotEmpty(e);if(c)return Promise.reject(c);const m={name:o,options:{link:{bucket:i.name}}};return this._put(m,null)}async link(e,s){const{name:i,error:o}=this._checkNotEmpty(e);if(o)return Promise.reject(o);if(s.deleted)return Promise.reject(new Error("src object is deleted"));if(s.isLink())return Promise.reject(new Error("src object is a link"));const c=await this.rawInfo(e);if(c!==null&&!c.deleted)return Promise.reject(new Error("an object already exists with that name"));const m={bucket:s.bucket,name:s.name},p={name:i,bucket:s.bucket,options:{link:m}};await this.js.publish(this._metaSubject(e),JSON.stringify(p));const g=await this.info(e);return Promise.resolve(g)}async delete(e){const s=await this.rawInfo(e);if(s===null)return Promise.resolve({purged:0,success:!1});s.deleted=!0,s.size=0,s.chunks=0,s.digest="";const i=er(),o=Pr();return o.set(Wt.RollupHdr,Wt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),i.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(e,s={}){const i=await this.rawInfo(e);if(i===null)return Promise.reject(new Error("object not found"));if(i.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??i.name;const{name:o,error:c}=this._checkNotEmpty(s.name);if(c)return Promise.reject(c);if(e!==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 m=Object.assign({},i,yb(s)),p=await this.js.publish(this._metaSubject(m.name),JSON.stringify(m));return e!==s.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(e)}),Promise.resolve(p)}async watch(e={}){e.includeHistory=e.includeHistory??!1,e.ignoreDeletes=e.ignoreDeletes??!1;let s=!1;const i=new Ut,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(i.push(null),s=!0):i.stop(g)}const c=er(),m=Ss();m.orderedConsumer(),e.includeHistory?m.deliverLastPerSubject():(s=!0,m.deliverNew()),m.callback((g,u)=>{var d;if(g){i.stop(g);return}if(u!==null){const b=c.decode(u.data);b.deleted&&e.ignoreDeletes===!0||i.push(b),((d=u.info)==null?void 0:d.pending)===0&&!s&&(s=!0,i.push(null))}});const p=await this.js.subscribe(o,m);return i._data=p,i.iterClosed.then(()=>{p.unsubscribe()}),p.closed.then(()=>{i.stop()}).catch(g=>{i.stop(g)}),i}_chunkSubject(e){return`$O.${this.name}.C.${e}`}_metaSubject(e){return`$O.${this.name}.M.${Zi.encode(e)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(e={}){try{this.stream=B2(this.name)}catch(o){return Promise.reject(o)}const s=(e==null?void 0:e.ttl)||0;delete e.ttl;const i=Object.assign({max_age:s},e);i.name=this.stream,i.num_replicas=e.replicas??1,i.allow_direct=!0,i.allow_rollup_hdrs=!0,i.discard=Oo.New,i.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],e.placement&&(i.placement=e.placement),e.metadata&&(i.metadata=e.metadata),typeof e.compression=="boolean"&&(i.compression=e.compression?js.S2:js.None);try{await this.jsm.streams.info(i.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(i)}}static async create(e,s,i={}){const o=await e.jetstreamManager(),c=new So(s,o,e);return await c.init(i),Promise.resolve(c)}}class Q2{constructor(e){j(this,"js");this.js=e}kv(e,s={}){const i=this.js,{ok:o,min:c}=i.nc.features.get(Ye.JS_KV);return o?s.bindOnly?jo.bind(this.js,e,s):jo.create(this.js,e,s):Promise.reject(new Error(`kv is only supported on servers ${c} or better`))}os(e,s={}){var m;if(typeof((m=crypto==null?void 0:crypto.subtle)==null?void 0:m.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const i=this.js,{ok:o,min:c}=i.nc.features.get(Ye.JS_OBJECTSTORE);return o?So.create(this.js,e,s):Promise.reject(new Error(`objectstore is only supported on servers ${c} or better`))}}class pm extends Ro{constructor(s,i){super(s,i);j(this,"consumers");j(this,"streams");j(this,"consumerAPI");j(this,"streamAPI");this.consumerAPI=new mu(s,i),this.streamAPI=new mm(s,i),this.consumers=new qd(this.consumerAPI),this.streams=new K2(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const i=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(i)}get apiPrefix(){return this.prefix}get views(){return new Q2(this)}async publish(s,i=jn,o){o=o||{},o.expect=o.expect||{};const c=(o==null?void 0:o.headers)||Pr();o&&(o.msgID&&c.set(or.MsgIdHdr,o.msgID),o.expect.lastMsgID&&c.set(or.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&c.set(or.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&c.set(or.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&c.set(or.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const m=o.timeout||this.timeout,p={};m&&(p.timeout=m),o&&(p.headers=c);let{retries:g,retry_delay:u}=o;g=g||1,u=u||250;let d;for(let x=0;x<g;x++)try{d=await this.nc.request(s,i,p);break}catch(v){if(v.code==="503"&&x+1<g)await aa(u);else throw v}const b=this.parseJsResponse(d);if(b.stream==="")throw ge.errorForCode(fe.JetStreamInvalidAck);return b.duplicate=b.duplicate?b.duplicate:!1,b}async pull(s,i,o=0){Jt(s),Xi(i);let c=this.timeout;o>c&&(c=o),o=o<0?0:dt(o);const m={batch:1,no_wait:o===0,expires:o},p=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(m),{noMux:!0,timeout:c}),g=Wi(p);if(g)throw g;return ko(p,this.timeout)}fetch(s,i,o={}){Jt(s),Xi(i);let c=null;const m=(o.max_bytes??0)>0;let p=0;const g=m?o.max_bytes:0;let u=null;const d={};if(d.batch=o.batch||1,g){const q=this.nc.features.get(Ye.JS_PULL_MAX_BYTES);if(!q.ok)throw new Error(`max_bytes is only supported on servers ${q.min} or better`);d.max_bytes=g}d.no_wait=o.no_wait||!1,d.no_wait&&d.expires&&(d.expires=0);const b=o.expires||0;if(b&&(d.expires=dt(b)),b===0&&d.no_wait===!1)throw new Error("expires or no_wait is required");const x=o.idle_heartbeat||0;x&&(d.idle_heartbeat=dt(x),o.delay_heartbeat===!0&&(d.idle_heartbeat=dt(x*4)));const v=new Ut,_=d.batch;let S=0;v.protocolFilterFn=(q,ne=!1)=>Ad(q.msg)?(u==null||u.work(),!1):!0,v.dispatchedFn=q=>{if(q){if(m&&(p+=q.data.length),S++,c&&q.info.pending===0)return;(v.getPending()===1&&q.info.pending===0||_===S||g>0&&p>=g)&&v.stop()}};const C=Lr(this.nc.options.inboxPrefix),B=this.nc.subscribe(C,{max:o.batch,callback:(q,ne)=>{q===null&&(q=Wi(ne)),q!==null?(c&&(c.cancel(),c=null),bE(q)?v.stop(Dx(q)===null?void 0:q):v.stop(q)):(u==null||u.work(),v.received++,v.push(ko(ne,this.timeout)))}});return b&&(c=ra(b),c.catch(()=>{B.isClosed()||(B.drain().catch(()=>{}),c=null),u&&u.cancel()})),(async()=>{try{x&&(u=new hm(x,q=>(v.push(()=>{v.err=new ge(`${In.IdleHeartbeatMissed}: ${q}`,fe.JetStreamIdleHeartBeat)}),!0)))}catch{}await B.closed,c!==null&&(c.cancel(),c=null),u&&u.cancel(),v.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(d),{reply:C}),v}async pullSubscribe(s,i=Ss()){const o=await this._processOptions(s,i);if(o.ordered)throw new Error("pull subscribers cannot be be ordered");if(o.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const c=o.config.ack_policy;if(c===Bt.None||c===Bt.All)throw new Error("ack policy for pull consumers must be explicit");const m=this._buildTypedSubscriptionOpts(o),p=new eO(this,o.deliver,m);p.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw p.unsubscribe(),g}return p}async subscribe(s,i=Ss()){const o=await this._processOptions(s,i);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const c=this._buildTypedSubscriptionOpts(o),m=new Rx(this,o.deliver,c);m.info=o;try{await this._maybeCreateConsumer(o)}catch(p){throw m.unsubscribe(),p}return m._maybeSetupHbMonitoring(),m}async _processOptions(s,i=Ss()){const o=tb(i)?i.getOpts():i;if(o.isBind=tb(i)?i.isBind:!1,o.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},o.ordered){if(o.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},o.config.ack_policy!==Bt.NotSet&&o.config.ack_policy!==Bt.None)throw new ge("ordered consumer: ack_policy can only be set to 'none'",fe.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new ge("ordered consumer: durable_name cannot be set",fe.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new ge("ordered consumer: deliver_subject cannot be set",fe.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new ge("ordered consumer: max_deliver cannot be set",fe.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new ge("ordered consumer: deliver_group cannot be set",fe.ApiError);o.config.deliver_subject=Lr(this.nc.options.inboxPrefix),o.config.ack_policy=Bt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||dt(5e3),o.config.ack_wait=dt(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===Bt.NotSet&&(o.config.ack_policy=Bt.All),o.api=this,o.config=o.config||{},o.stream=o.stream?o.stream:await this.findStream(s),o.attached=!1,o.config.durable_name)try{const c=await this.consumerAPI.info(o.stream,o.config.durable_name);if(c){if(c.config.filter_subject&&c.config.filter_subject!==s)throw new Error("subject does not match consumer");const m=o.config.deliver_group??"";if(m===""&&c.push_bound===!0)throw new Error("duplicate subscription");const p=c.config.deliver_group??"";if(m!==p)throw p===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${p}'`);o.last=c,o.config=c.config,o.attached=!0,o.config.durable_name||(o.name=c.name)}}catch(c){if(c.code!=="404")throw c}return!o.attached&&o.config.filter_subject===void 0&&o.config.filter_subjects===void 0&&(o.config.filter_subject=s),o.deliver=o.config.deliver_subject||Lr(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const i={};return i.adapter=tO(s.callbackFn===void 0,this.timeout),i.ingestionFilterFn=pm.ingestionFn(s.ordered),i.protocolFilterFn=(o,c=!1)=>{const m=o;return Od(m.msg)?(c||m.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==Bt.None&&(i.dispatchedFn=sO),s.callbackFn&&(i.callback=s.callbackFn),i.max=s.max||0,i.queue=s.queue,i}async _maybeCreateConsumer(s){if(s.attached)return;if(s.isBind)throw new Error(`unable to bind - durable consumer ${s.config.durable_name} doesn't exist in ${s.stream}`);s.config=Object.assign({deliver_policy:Et.All,ack_policy:Bt.Explicit,ack_wait:dt(30*1e3),replay_policy:sa.Instant},s.config);const i=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(i.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=i.name,s.config=i.config,s.last=i}static ingestionFn(s){return(i,o)=>{var g;const c=o;if(!i)return{ingest:!1,protocol:!1};const m=i;if(Wi(m.msg)||(g=c.monitor)==null||g.work(),Ad(m.msg)){const u=s?c._checkHbOrderConsumer(m.msg):!0;return s||c.info.flow_control.heartbeat_count++,{ingest:u,protocol:!0}}else if(Od(m.msg))return c.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?c._checkOrderedConsumer(i):!0,protocol:!1}}}}class ym{constructor(e){j(this,"options");j(this,"protocol");j(this,"draining");j(this,"listeners");j(this,"_services");this.draining=!1,this.options=x2(e),this.listeners=[]}static connect(e={}){return new Promise((s,i)=>{const o=new ym(e);yu.connect(o.options,o).then(c=>{o.protocol=c,(async function(){for await(const m of c.status())o.listeners.forEach(p=>{p.push(m)})})(),s(o)}).catch(c=>{i(c)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,s,i){if(this.isClosed())throw ge.errorForCode(fe.ConnectionClosed);if(s&&this.isDraining()||i&&this.protocol.noMorePublishing)throw ge.errorForCode(fe.ConnectionDraining);if(e=e||"",e.length===0)throw ge.errorForCode(fe.BadSubject)}publish(e,s,i){this._check(e,!1,!0),this.protocol.publish(e,s,i)}publishMessage(e){return this.publish(e.subject,e.data,{reply:e.reply,headers:e.headers})}respondMessage(e){return e.reply?(this.publish(e.reply,e.data,{reply:e.reply,headers:e.headers}),!0):!1}subscribe(e,s={}){this._check(e,!0,!1);const i=new Nx(this.protocol,e,s);return this.protocol.subscribe(i),i}_resub(e,s,i){this._check(s,!0,!1);const o=e;o.max=i,i&&(o.max=i+o.received),this.protocol.resub(o,s)}requestMany(e,s=jn,i={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(g){return Promise.reject(g)}if(i.strategy=i.strategy||Zn.Timer,i.maxWait=i.maxWait||1e3,i.maxWait<1)return Promise.reject(new ge("timeout",fe.InvalidOption));const c=new Ut;function m(g){c.push(()=>{c.stop(g)})}function p(g,u){g||u===null?m(g===null?void 0:g):c.push(u)}if(i.noMux){const g=o?new Error().stack:null;let u=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1;const d=this.subscribe(Lr(this.options.inboxPrefix),{callback:(_,S)=>{var C,B;if(((C=S==null?void 0:S.data)==null?void 0:C.length)===0&&((B=S==null?void 0:S.headers)==null?void 0:B.status)===fe.NoResponders&&(_=ge.errorForCode(fe.NoResponders)),_){g&&(_.stack+=`
47
+ `),e.max=s)}resub(e,s){!e||this.isClosed()||(this.unsub(e),e.subject=s,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||(e=dt()),this.pongs.push(e),this.outbound.fill(fb),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(s=>{const i=s;i.queue?e.push(`SUB ${i.subject} ${i.queue} ${i.sid}${ru}`):e.push(`SUB ${i.subject} ${i.sid}${ru}`)}),e.length&&this.transport.send(_o(e.join("")))}async _close(e){this._closed||(this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(e),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(s=>{s.stop()}),this._closed=!0,await this.transport.close(e),await this.closed.resolve(e))}close(){return this._close()}isClosed(){return this._closed}drain(){const e=this.subscriptions.all(),s=[];return e.forEach(i=>{s.push(i.drain())}),Promise.all(s).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){const s=this.muxSubscriptions.init(this.options.inboxPrefix),i=new Nx(this,`${s}*`);i.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(i),this.subscribe(i)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}const A2="$SRV";class hb{constructor(e){j(this,"msg");this.msg=e}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(e,s){return this.msg.respond(e,s)}respondError(e,s,i,o){var c,m;return o=o||{},o.headers=o.headers||Pr(),(c=o.headers)==null||c.set(fu,`${e}`),(m=o.headers)==null||m.set(uu,s),this.msg.respond(i,o)}json(e){return this.msg.json(e)}string(){return this.msg.string()}}class jo{constructor(e,s="",i=""){j(this,"subject");j(this,"queue");j(this,"srv");s!==""&&k2("service group",s);let o="";if(e instanceof Do)this.srv=e,o="";else if(e instanceof jo){const c=e;this.srv=c.srv,i===""&&c.queue!==""&&(i=c.queue),o=c.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(o,s),this.queue=i}calcSubject(e,s=""){return s===""?e:e!==""?`${e}.${s}`:s}addEndpoint(e="",s){s=s||{subject:e};const i=typeof s=="function"?{handler:s,subject:e}:s;bo("endpoint",e);let{subject:o,handler:c,metadata:m,queue:p}=i;o=o||e,p=p||this.queue,j2("endpoint subject",o),o=this.calcSubject(this.subject,o);const g={name:e,subject:o,queue:p,handler:c,metadata:m};return this.srv._addEndpoint(g)}addGroup(e="",s=""){return new jo(this,e,s)}}function j2(n,e){if(e==="")throw new Error(`${n} cannot be empty`);if(e.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${e}'`);const s=e.split(".");s.forEach((i,o)=>{if(i===">"&&o!==s.length-1)throw new Error(`${n} cannot have internal '>': '${e}'`)})}function k2(n,e){if(e.indexOf(" ")!==-1)throw new Error(`${n} cannot contain spaces: '${e}'`);e.split(".").forEach(i=>{if(i===">")throw new Error(`${n} name cannot contain internal '>': '${e}'`)})}class Do{constructor(e,s={name:"",version:""}){j(this,"nc");j(this,"_id");j(this,"config");j(this,"handlers");j(this,"internal");j(this,"_stopped");j(this,"_done");j(this,"started");this.nc=e,this.config=Object.assign({},s),this.config.queue||(this.config.queue="q"),bo("name",this.config.name),bo("queue",this.config.queue),ti(this.config.version),this._id=As.next(),this.internal=[],this._done=dt(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(i=>{this.close(i).catch()})}static controlSubject(e,s="",i="",o){const c=o??A2;return s===""&&i===""?`${c}.${e}`:(bo("control subject name",s),i!==""?(bo("control subject id",i),`${c}.${e}.${s}.${i}`):`${c}.${e}.${s}`)}get subjects(){return this.handlers.filter(e=>e.internal===!1).map(e=>e.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(e){const s=Pr();if(e instanceof hu){const i=e;s.set(uu,i.message),s.set(fu,`${i.code}`)}else s.set(uu,e.message),s.set(fu,"500");return s}setupHandler(e,s=!1){const i=s?"":e.queue?e.queue:this.config.queue,{name:o,subject:c,handler:m}=e,p=e;p.internal=s,s&&this.internal.push(p),p.stats=new N2(o,c,i),p.queue=i;const g=m?(u,d)=>{if(u){this.close(u);return}const b=Date.now();try{m(u,new hb(d))}catch(x){p.stats.countError(x),d==null||d.respond(jn,{headers:this.errorToHeader(x)})}finally{p.stats.countLatency(b)}}:void 0;return p.sub=this.nc.subscribe(c,{callback:g,queue:i}),p.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${e.subject} stopped`)).catch()}).catch(u=>{if(!this._stopped){const d=new Error(`required subscription ${e.subject} errored: ${u.message}`);d.stack=u.stack,this.close(d).catch()}}),p}info(){return{type:wo.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(e=>{const{subject:s,metadata:i,name:o,queue:c}=e;return{subject:s,metadata:i,name:o,queue_group:c}})}async stats(){const e=[];for(const s of this.handlers){if(typeof this.config.statsHandler=="function")try{s.stats.data=await this.config.statsHandler(s)}catch(i){s.stats.countError(i)}e.push(s.stats.stats(s.qi))}return{type:wo.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:e}}addInternalHandler(e,s){const i=`${e}`.toUpperCase();this._doAddInternalHandler(`${i}-all`,e,s),this._doAddInternalHandler(`${i}-kind`,e,s,this.name),this._doAddInternalHandler(`${i}`,e,s,this.name,this.id)}_doAddInternalHandler(e,s,i,o="",c=""){const m={};m.name=e,m.subject=Do.controlSubject(s,o,c),m.handler=i,this.setupHandler(m,!0)}start(){const e=er(),s=(m,p)=>m?(this.close(m),Promise.reject(m)):this.stats().then(g=>(p==null||p.respond(e.encode(g)),Promise.resolve())),i=(m,p)=>m?(this.close(m),Promise.reject(m)):(p==null||p.respond(e.encode(this.info())),Promise.resolve()),o=e.encode(this.ping()),c=(m,p)=>m?(this.close(m).then().catch(),Promise.reject(m)):(p.respond(o),Promise.resolve());return this.addInternalHandler(_s.PING,c),this.addInternalHandler(_s.STATS,s),this.addInternalHandler(_s.INFO,i),this.handlers.forEach(m=>{const{subject:p}=m;typeof p=="string"&&m.handler!==null&&this.setupHandler(m)}),Promise.resolve(this)}close(e){if(this._stopped)return this._done;this._stopped=!0;let s=[];return this.nc.isClosed()||(s=this.handlers.concat(this.internal).map(i=>i.sub.drain())),Promise.allSettled(s).then(()=>{this._done.resolve(e||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(e){return this.close(e)}ping(){return{type:wo.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const e of this.handlers)e.stats.reset(e.qi)}addGroup(e,s){return new jo(this,e,s)}addEndpoint(e,s){return new jo(this).addEndpoint(e,s)}_addEndpoint(e){const s=new Ut;s.noIterator=typeof e.handler=="function",s.noIterator||(e.handler=(o,c)=>{o?this.stop(o).catch():s.push(new hb(c))},s.iterClosed.then(()=>{this.close().catch()}));const i=this.setupHandler(e,!1);return i.qi=s,this.handlers.push(i),s}}class N2{constructor(e,s,i=""){j(this,"name");j(this,"subject");j(this,"average_processing_time");j(this,"num_requests");j(this,"processing_time");j(this,"num_errors");j(this,"last_error");j(this,"data");j(this,"metadata");j(this,"queue");this.name=e,this.subject=s,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=i}reset(e){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=e;s&&(s.time=0,s.processed=0)}countLatency(e){this.num_requests++,this.processing_time+=ht(Date.now()-e),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(e){this.num_errors++,this.last_error=e.message}_stats(){const{name:e,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:p,data:g,queue:u}=this;return{name:e,subject:s,average_processing_time:i,num_errors:o,num_requests:c,processing_time:m,last_error:p,data:g,queue_group:u}}stats(e){const s=e;return(s==null?void 0:s.noIterator)===!1&&(this.processing_time=ht(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 T2{constructor(e,s={strategy:Zn.JitterTimer,maxWait:2e3},i){j(this,"nc");j(this,"prefix");j(this,"opts");this.nc=e,this.prefix=i,this.opts=s}ping(e="",s=""){return this.q(_s.PING,e,s)}stats(e="",s=""){return this.q(_s.STATS,e,s)}info(e="",s=""){return this.q(_s.INFO,e,s)}async q(e,s="",i=""){const o=new Ut,c=er(),m=Do.controlSubject(e,s,i,this.prefix),p=await this.nc.requestMany(m,jn,this.opts);return(async()=>{for await(const g of p)try{const u=c.decode(g.data);o.push(u)}catch(u){o.push(()=>{o.stop(u)})}o.push(()=>{o.stop()})})().catch(g=>{o.stop(g)}),o}}function Tx(){return{key:{encode(n){return n},decode(n){return n}},value:{encode(n){return n},decode(n){return n}}}}function C2(){return{replicas:1,history:1,timeout:2e3,max_bytes:-1,maxValueSize:-1,codec:Tx(),storage:kd.File}}const gu="KV-Operation",db="$KV",M2=/^[-/=.\w]+$/,R2=/^[-/=.>*\w]+$/,D2=/^[-\w]+$/;function L2(n){if(n.startsWith(".")||n.endsWith(".")||!M2.test(n))throw new Error(`invalid key: ${n}`)}function q2(n){if(n.startsWith(".")||n.endsWith(".")||!R2.test(n))throw new Error(`invalid key: ${n}`)}function P2(n){if(n.startsWith(".")||n.endsWith("."))throw new Error(`invalid key: ${n}`);const e=n.split(".");let s=!1;for(let i=0;i<e.length;i++)switch(e[i]){case"*":s=!0;break;case">":if(i!==e.length-1)throw new Error(`invalid key: ${n}`);s=!0;break}return s}function su(n){if(!D2.test(n))throw new Error(`invalid bucket name: ${n}`)}var or;(function(n){n.MsgIdHdr="Nats-Msg-Id",n.ExpectedStreamHdr="Nats-Expected-Stream",n.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",n.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",n.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(or||(or={}));class ko{constructor(e,s,i){j(this,"js");j(this,"jsm");j(this,"stream");j(this,"bucket");j(this,"direct");j(this,"codec");j(this,"prefix");j(this,"editPrefix");j(this,"useJsPrefix");j(this,"_prefixLen");j(this,"validateKey",L2);j(this,"validateSearchKey",q2);j(this,"hasWildcards",P2);su(e),this.js=s,this.jsm=i,this.bucket=e,this.prefix=db,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(e,s,i={}){su(s);const o=await e.jetstreamManager(),c=new ko(s,e,o);return await c.init(i),c}static async bind(e,s,i={}){const o=await e.jetstreamManager(),c={config:{allow_direct:i.allow_direct}};su(s);const m=new ko(s,e,o);return c.config.name=i.streamName??m.bucketName(),Object.assign(m,c),m.stream=c.config.name,m.codec=i.codec||Tx(),m.direct=c.config.allow_direct??!1,m.initializePrefixes(c),m}async init(e={}){const s=Object.assign(C2(),e);this.codec=s.codec;const i={};this.stream=i.name=e.streamName??this.bucketName(),i.retention=jd.Limits,i.max_msgs_per_subject=s.history,s.maxBucketSize&&(s.max_bytes=s.maxBucketSize),s.max_bytes&&(i.max_bytes=s.max_bytes),i.max_msg_size=s.maxValueSize,i.storage=s.storage;const o=e.placementCluster??"";if(o&&(e.placement={},e.placement.cluster=o,e.placement.tags=[]),e.placement&&(i.placement=e.placement),e.republish&&(i.republish=e.republish),e.description&&(i.description=e.description),e.mirror){const b=Object.assign({},e.mirror);b.name.startsWith(Sn)||(b.name=`${Sn}${b.name}`),i.mirror=b,i.mirror_direct=!0}else if(e.sources){const b=e.sources.map(x=>{const v=Object.assign({},x),_=v.name.startsWith(Sn)?v.name.substring(Sn.length):v.name;return v.name.startsWith(Sn)||(v.name=`${Sn}${v.name}`),!x.external&&_!==this.bucket&&(v.subject_transforms=[{src:`$KV.${_}.>`,dest:`$KV.${this.bucket}.>`}]),v});i.sources=b,i.subjects=[this.subjectForBucket()]}else i.subjects=[this.subjectForBucket()];e.metadata&&(i.metadata=e.metadata),typeof e.compression=="boolean"&&(i.compression=e.compression?js.S2:js.None);const c=this.js.nc,m=c.getServerVersion(),p=m?Td(m,ti("2.7.2"))>=0:!1;i.discard=p?Ao.New:Ao.Old;const{ok:g,min:u}=c.features.get(Ve.JS_ALLOW_DIRECT);if(!g&&e.allow_direct===!0){const b=m?`${m.major}.${m.minor}.${m.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${b} - requires ${u}`))}e.allow_direct=typeof e.allow_direct=="boolean"?e.allow_direct:g,i.allow_direct=e.allow_direct,this.direct=i.allow_direct,i.num_replicas=s.replicas,s.ttl&&(i.max_age=ht(s.ttl)),i.allow_rollup_hdrs=!0;let d;try{d=await this.jsm.streams.info(i.name),!d.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(b){if(b.message==="stream not found")d=await this.jsm.streams.add(i);else throw b}this.initializePrefixes(d)}initializePrefixes(e){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:s}=e.config;if(s){let i=s.name;if(i.startsWith(Sn)&&(i=i.substring(Sn.length)),s.external&&s.external.api!==""){const o=s.name.substring(Sn.length);this.useJsPrefix=!1,this.prefix=`$KV.${o}`,this.editPrefix=`${s.external.api}.$KV.${i}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${Sn}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(e,s=!1){const i=[];return s?(this.useJsPrefix&&i.push(this.js.apiPrefix),this.editPrefix!==""?i.push(this.editPrefix):i.push(this.prefix)):this.prefix&&i.push(this.prefix),i.push(e),i.join(".")}fullKeyName(e){return this.prefix!==""?`${this.prefix}.${e}`:`${db}.${this.bucket}.${e}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(e){const s=[];for(const i of e.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.encode(i));break}return s.join(".")}decodeKey(e){const s=[];for(const i of e.split("."))switch(i){case">":case"*":s.push(i);break;default:s.push(this.codec.key.decode(i));break}return s.join(".")}close(){return Promise.resolve()}dataLen(e,s){const i=s&&s.get(Zt.MessageSizeHdr)||"";return i!==""?parseInt(i,10):e.length}smToEntry(e){return new W2(this.bucket,this.prefixLen,e)}jmToEntry(e){const s=this.decodeKey(e.subject.substring(this.prefixLen));return new Z2(this.bucket,s,e)}async create(e,s){var c;let i;try{const m=await this.put(e,s,{previousSeq:0});return Promise.resolve(m)}catch(m){if(i=m,((c=m==null?void 0:m.api_error)==null?void 0:c.err_code)!==10071)return Promise.reject(m)}let o=0;try{const m=await this.get(e);return(m==null?void 0:m.operation)==="DEL"||(m==null?void 0:m.operation)==="PURGE"?(o=m!==null?m.revision:0,this.update(e,s,o)):Promise.reject(i)}catch(m){return Promise.reject(m)}}update(e,s,i){if(i<=0)throw new Error("version must be greater than 0");return this.put(e,s,{previousSeq:i})}async put(e,s,i={}){var m,p;const o=this.encodeKey(e);this.validateKey(o);const c={};if(i.previousSeq!==void 0){const g=Pr();c.headers=g,g.set(or.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(o,!0),s,c)).seq}catch(g){const u=g;return u.isJetStreamError()?(u.message=(m=u.api_error)==null?void 0:m.description,u.code=`${(p=u.api_error)==null?void 0:p.code}`,Promise.reject(u)):Promise.reject(g)}}async get(e,s){const i=this.encodeKey(e);this.validateKey(i);let o={last_by_subj:this.subjectForKey(i)};s&&s.revision>0&&(o={seq:s.revision});let c;try{this.direct?c=await this.jsm.direct.getMessage(this.bucketName(),o):c=await this.jsm.streams.getMessage(this.bucketName(),o);const m=this.smToEntry(c);return m.key!==i?null:m}catch(m){if(m.code===fe.JetStream404NoMessages)return null;throw m}}purge(e,s){return this._deleteOrPurge(e,"PURGE",s)}delete(e,s){return this._deleteOrPurge(e,"DEL",s)}async purgeDeletes(e=1800*1e3){const s=dt(),i=[],o=await this.watch({key:">",initializedFn:()=>{s.resolve()}});(async()=>{for await(const g of o)(g.operation==="DEL"||g.operation==="PURGE")&&i.push(g)})().then(),await s,o.stop();const c=Date.now()-e,m=i.map(g=>{const u=this.subjectForKey(g.key);return g.created.getTime()>=c?this.jsm.streams.purge(this.stream,{filter:u,keep:1}):this.jsm.streams.purge(this.stream,{filter:u,keep:0})}),p=await Promise.all(m);return p.unshift({success:!0,purged:0}),p.reduce((g,u)=>(g.purged+=u.purged,g))}async _deleteOrPurge(e,s,i){if(!this.hasWildcards(e))return this._doDeleteOrPurge(e,s,i);const o=await this.keys(e),c=[];for await(const m of o)c.push(this._doDeleteOrPurge(m,s)),c.length===100&&(await Promise.all(c),c.length=0);c.length>0&&await Promise.all(c)}async _doDeleteOrPurge(e,s,i){const o=this.encodeKey(e);this.validateKey(o);const c=Pr();c.set(gu,s),s==="PURGE"&&c.set(Zt.RollupHdr,Zt.RollupValueSubject),i!=null&&i.previousSeq&&c.set(or.ExpectedLastSubjectSequenceHdr,`${i.previousSeq}`),await this.js.publish(this.subjectForKey(o,!0),jn,{headers:c})}_buildCC(e,s,i={}){let c=(Array.isArray(e)?e:[e]).map(g=>{const u=this.encodeKey(g);return this.validateSearchKey(g),this.fullKeyName(u)}),m=Et.LastPerSubject;s===Xn.AllHistory&&(m=Et.All),s===Xn.UpdatesOnly&&(m=Et.New);let p;return c.length===1&&(p=c[0],c=void 0),Object.assign({deliver_policy:m,ack_policy:Bt.None,filter_subjects:c,filter_subject:p,flow_control:!0,idle_heartbeat:ht(5*1e3)},i)}remove(e){return this.purge(e)}async history(e={}){const s=e.key??">",i=new Ut,o={};o.headers_only=e.headers_only||!1;let c;c=()=>{i.stop()};let m=0;const p=this._buildCC(s,Xn.AllHistory,o),g=p.filter_subject,u=Ss(p);u.bindStream(this.stream),u.orderedConsumer(),u.callback((b,x)=>{if(b){i.stop(b);return}if(x){const v=this.jmToEntry(x);i.push(v),i.received++,(c&&m>0&&i.received>=m||x.info.pending===0)&&(i.push(c),c=void 0)}});const d=await this.js.subscribe(g,u);if(c){const{info:{last:b}}=d,x=b.num_pending+b.delivered.consumer_seq;if(x===0||i.received>=x)try{c()}catch(v){i.stop(v)}finally{c=void 0}else m=x}return i._data=d,i.iterClosed.then(()=>{d.unsubscribe()}),d.closed.then(()=>{i.stop()}).catch(b=>{i.stop(b)}),i}canSetWatcherName(){const s=this.js.nc,{ok:i}=s.features.get(Ve.JS_NEW_CONSUMER_CREATE_API);return i}async watch(e={}){const s=e.key??">",i=new Ut,o={};o.headers_only=e.headers_only||!1;let c=Xn.LastValue;e.include===Xn.AllHistory?c=Xn.AllHistory:e.include===Xn.UpdatesOnly&&(c=Xn.UpdatesOnly);const m=e.ignoreDeletes===!0;let p=e.initializedFn,g=0;const u=this._buildCC(s,c,o),d=u.filter_subject,b=Ss(u);this.canSetWatcherName()&&b.consumerName(As.next()),b.bindStream(this.stream),e.resumeFromRevision&&e.resumeFromRevision>0&&b.startSequence(e.resumeFromRevision),b.orderedConsumer(),b.callback((v,_)=>{if(v){i.stop(v);return}if(_){const S=this.jmToEntry(_);if(m&&S.operation==="DEL")return;i.push(S),i.received++,p&&(g>0&&i.received>=g||_.info.pending===0)&&(i.push(p),p=void 0)}});const x=await this.js.subscribe(d,b);if(p){const{info:{last:v}}=x,_=v.num_pending+v.delivered.consumer_seq;if(_===0||i.received>=_)try{p()}catch(S){i.stop(S)}finally{p=void 0}else g=_}return i._data=x,i.iterClosed.then(()=>{x.unsubscribe()}),x.closed.then(()=>{i.stop()}).catch(v=>{i.stop(v)}),i}async keys(e=">"){const s=new Ut,i=this._buildCC(e,Xn.LastValue,{headers_only:!0}),o=Array.isArray(e)?">":i.filter_subject,c=Ss(i);c.bindStream(this.stream),c.orderedConsumer();const m=await this.js.subscribe(o,c);return(async()=>{var g;for await(const u of m){const d=(g=u.headers)==null?void 0:g.get(gu);if(d!=="DEL"&&d!=="PURGE"){const b=this.decodeKey(u.subject.substring(this.prefixLen));s.push(b)}u.info.pending===0&&m.unsubscribe()}})().then(()=>{s.stop()}).catch(g=>{s.stop(g)}),m.info.last.num_pending===0&&m.unsubscribe(),s}purgeBucket(e){return this.jsm.streams.purge(this.bucketName(),e)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var c;const s=((c=this.js.nc.info)==null?void 0:c.cluster)??"",i=this.bucketName(),o=await this.jsm.streams.info(i);return new Cx(o,s)}}class Cx{constructor(e,s=""){j(this,"si");j(this,"cluster");this.si=e,this.cluster=s}get bucket(){return this.si.config.name.startsWith(Sn)?this.si.config.name.substring(Sn.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 um(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 e;return((e=this.si.config.placement)==null?void 0:e.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!==js.None:!1}}const dm="OBJ_",mb="SHA-256=";function B2(n){return su(n),`${dm}${n}`}function U2(n){return n.startsWith(dm)?n.substring(4):n}class Dd{constructor(e){j(this,"si");j(this,"backingStore");this.si=e,this.backingStore="JetStream"}get bucket(){return U2(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!==js.None:!1}}function cc(n){if(n===void 0)return;const{domain:e}=n;if(e===void 0)return n;const s=Object.assign({},n);if(delete s.domain,e==="")return s;if(s.external)throw new Error("domain and external are both set");return s.external={api:`$JS.${e}.API`},s}var zn;(function(n){n[n.Unset=-1]="Unset",n[n.Consume=0]="Consume",n[n.Fetch=1]="Fetch"})(zn||(zn={}));var lr;(function(n){n.HeartbeatsMissed="heartbeats_missed",n.ConsumerNotFound="consumer_not_found",n.StreamNotFound="stream_not_found",n.ConsumerDeleted="consumer_deleted",n.OrderedConsumerRecreated="ordered_consumer_recreated",n.NoResponders="no_responders"})(lr||(lr={}));var ea;(function(n){n.DebugEvent="debug",n.Discard="discard",n.Reset="reset",n.Next="next"})(ea||(ea={}));const pb=Uint8Array.of(43,65,67,75),z2=Uint8Array.of(45,78,65,75),ao=Uint8Array.of(43,87,80,73),I2=Uint8Array.of(43,78,88,84),$2=Uint8Array.of(43,84,69,82,77),H2=Uint8Array.of(32);function No(n,e=5e3){return new aO(n,e)}class sd extends Ut{constructor(s,i,o=!1){super();j(this,"consumer");j(this,"opts");j(this,"sub");j(this,"monitor");j(this,"pending");j(this,"inbox");j(this,"refilling");j(this,"pong");j(this,"callback");j(this,"timeout");j(this,"cleanupHandler");j(this,"listeners");j(this,"statusIterator");j(this,"forOrderedConsumer");j(this,"resetHandler");j(this,"abortOnMissingResource");j(this,"bind");j(this,"inBackOff");this.consumer=s;const c=i;this.opts=this.parseOptions(i,o),this.callback=c.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=o,this.timeout=null,this.inbox=Lr(s.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.abortOnMissingResource=c.abort_on_missing_resource===!0,this.bind=c.bind===!0,this.inBackOff=!1,this.start()}start(){const{max_messages:s,max_bytes:i,idle_heartbeat:o,threshold_bytes:c,threshold_messages:m}=this.opts;this.closed().then(g=>{if(this.cleanupHandler)try{this.cleanupHandler(g)}catch{}});const{sub:p}=this;p&&p.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(g,u)=>{var b,x,v,_;if(g){this.stop(g);return}if((b=this.monitor)==null||b.work(),u.subject===this.inbox){if(Ad(u))return;const S=(x=u.headers)==null?void 0:x.code,C=((_=(v=u.headers)==null?void 0:v.description)==null?void 0:_.toLowerCase())||"unknown",{msgsLeft:B,bytesLeft:q}=this.parseDiscard(u.headers);if(B>0||q>0)this.pending.msgs-=B,this.pending.bytes-=q,this.pending.requests--,this.notify(ea.Discard,{msgsLeft:B,bytesLeft:q});else if(S===400){this.stop(new be(C,`${S}`));return}else if(S===409&&C==="consumer deleted"){if(this.notify(lr.ConsumerDeleted,`${S} ${C}`),!this.refilling||this.abortOnMissingResource){const ne=new be(C,`${S}`);this.stop(ne);return}}else if(S===503){if(this.notify(lr.NoResponders,`${S} No Responders`),!this.refilling||this.abortOnMissingResource){const ne=new be("no responders",`${S}`);this.stop(ne);return}}else this.notify(ea.DebugEvent,`${S} ${C}`)}else this._push(No(u,this.consumer.api.timeout)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=u.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(s&&this.pending.msgs<=m||i&&this.pending.bytes<=c){const S=this.pullOptions();this.pull(S)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),o&&(this.monitor=new hm(o,g=>(this.notify(lr.HeartbeatsMissed,g),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var u;const g=this.consumer.api.nc.status();this.statusIterator=g;for await(const d of g)switch(d.type){case Dr.Disconnect:(u=this.monitor)==null||u.cancel();break;case Dr.Reconnect:this.resetPending().then(b=>{var x;b&&((x=this.monitor)==null||x.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(s){if(!this.callback)super.push(s);else{const i=typeof s=="function"?s:null;try{i?i():this.callback(s)}catch(o){this.stop(o)}}}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}resetPending(){return this.bind?this.resetPendingNoInfo():this.resetPendingWithInfo()}resetPendingNoInfo(){return this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),Promise.resolve(!0)}async resetPendingWithInfo(){if(this.inBackOff)return!1;let s=0,i=0;const o=cm([this.opts.expires]);let c=0;for(;;){if(this.done)return!1;if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),this.inBackOff=!1,s=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(m){if(m.message==="stream not found"){if(i++,this.notify(lr.StreamNotFound,i),!this.refilling||this.abortOnMissingResource)return this.stop(m),!1}else if(m.message==="consumer not found"){if(s++,this.notify(lr.ConsumerNotFound,s),this.resetHandler)try{this.resetHandler()}catch{}if(!this.refilling||this.abortOnMissingResource)return this.stop(m),!1;if(this.forOrderedConsumer)return!1}else s=0,i=0;this.inBackOff=!0;const p=o.backoff(c),g=oa(p);await Promise.race([g,this.consumer.api.nc.closed()]),g.cancel(),c++}}}pull(s){this.pending.bytes+=s.max_bytes??0,this.pending.msgs+=s.batch??0,this.pending.requests++;const i=this.consumer.api.nc;this._push(()=>{i.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(s),{reply:this.inbox}),this.notify(ea.Next,s)})}pullOptions(){const s=this.opts.max_messages-this.pending.msgs,i=this.opts.max_bytes-this.pending.bytes,o=ht(this.opts.idle_heartbeat),c=ht(this.opts.expires);return{batch:s,max_bytes:i,idle_heartbeat:o,expires:c}}parseDiscard(s){const i={msgsLeft:0,bytesLeft:0},o=s==null?void 0:s.get(Zt.PendingMessagesHdr);o&&(i.msgsLeft=parseInt(o));const c=s==null?void 0:s.get(Zt.PendingBytesHdr);return c&&(i.bytesLeft=parseInt(c)),i}trackTimeout(s){this.timeout=s}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var s,i;(s=this.monitor)==null||s.cancel(),this.monitor=null,(i=this.timeout)==null||i.cancel(),this.timeout=null}setCleanupHandler(s){this.cleanupHandler=s}stop(s){var i,o;this.done||((i=this.sub)==null||i.unsubscribe(),this.clearTimers(),(o=this.statusIterator)==null||o.stop(),this._push(()=>{super.stop(s),this.listeners.forEach(c=>{c.stop()})}))}parseOptions(s,i=!1){const o=s||{};if(o.max_messages=o.max_messages||0,o.max_bytes=o.max_bytes||0,o.max_messages!==0&&o.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(o.max_messages===0&&(o.max_messages=100),o.expires=o.expires||3e4,o.expires<1e3)throw new Error("expires should be at least 1000ms");if(o.idle_heartbeat=o.idle_heartbeat||o.expires/2,o.idle_heartbeat=o.idle_heartbeat>3e4?3e4:o.idle_heartbeat,i){const c=Math.round(o.max_messages*.75)||1;o.threshold_messages=o.threshold_messages||c;const m=Math.round(o.max_bytes*.75)||1;o.threshold_bytes=o.threshold_bytes||m}return o}status(){const s=new Ut;return this.listeners.push(s),Promise.resolve(s)}}class F2 extends Ut{constructor(){super();j(this,"src");j(this,"listeners");this.listeners=[]}setSource(s){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=s,this.src.setCleanupHandler(i=>{this.stop(i||void 0)}),(async()=>{const i=await this.src.status();for await(const o of i)this.notify(o.type,o.data)})().catch(()=>{})}notify(s,i){this.listeners.length>0&&this.listeners.forEach(o=>{o.done||o.push({type:s,data:i})})}stop(s){var i;this.done||((i=this.src)==null||i.stop(s),super.stop(s),this.listeners.forEach(o=>{o.stop()}))}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}status(){const s=new Ut;return this.listeners.push(s),Promise.resolve(s)}}class Ld{constructor(e,s){j(this,"api");j(this,"_info");j(this,"stream");j(this,"name");this.api=e,this._info=s,this.stream=s.stream_name,this.name=s.name}consume(e={max_messages:100,expires:3e4}){return Promise.resolve(new sd(this,e,!0))}fetch(e={max_messages:100,expires:3e4}){const s=new sd(this,e,!1),i=Math.round(s.opts.expires*1.05),o=sa(i);return s.closed().catch(()=>{}).finally(()=>{o.cancel()}),o.catch(()=>{s.close().catch()}),s.trackTimeout(o),Promise.resolve(s)}next(e={expires:3e4}){const s=dt(),i=e;i.max_messages=1;const o=new sd(this,i,!1),c=Math.round(o.opts.expires*1.05);c>=6e4&&(async()=>{for await(const p of await o.status())if(p.type===lr.HeartbeatsMissed&&p.data>=2){s.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const p of o){s.resolve(p);break}})().catch(()=>{});const m=sa(c);return o.closed().then(p=>{p?s.reject(p):s.resolve(null)}).catch(p=>{s.reject(p)}).finally(()=>{m.cancel()}),m.catch(p=>{s.resolve(null),o.close().catch()}),o.trackTimeout(m),s}delete(){const{stream_name:e,name:s}=this._info;return this.api.delete(e,s)}info(e=!1){if(e)return Promise.resolve(this._info);const{stream_name:s,name:i}=this._info;return this.api.info(s,i).then(o=>(this._info=o,this._info))}}class G2{constructor(e,s,i={}){j(this,"api");j(this,"consumerOpts");j(this,"consumer");j(this,"opts");j(this,"cursor");j(this,"stream");j(this,"namePrefix");j(this,"serial");j(this,"currentConsumer");j(this,"userCallback");j(this,"iter");j(this,"type");j(this,"startSeq");j(this,"maxInitialReset");this.api=e,this.stream=s,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=As.next(),typeof i.name_prefix=="string"&&(Au("name_prefix",i.name_prefix),this.namePrefix=i.name_prefix+this.namePrefix),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=zn.Unset,this.consumerOpts=i,this.maxInitialReset=30,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(e){this.serial++;const s=`${this.namePrefix}_${this.serial}`;e=e===0?1:e;const i={name:s,deliver_policy:Et.StartSequence,opt_start_seq:e,ack_policy:Bt.None,inactive_threshold:ht(300*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(i.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(i.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(i.filter_subject=this.consumerOpts.filterSubjects),this.consumerOpts.replay_policy&&(i.replay_policy=this.consumerOpts.replay_policy),e===this.startSeq+1&&(i.deliver_policy=this.consumerOpts.deliver_policy||Et.StartSequence,(this.consumerOpts.deliver_policy===Et.LastPerSubject||this.consumerOpts.deliver_policy===Et.New||this.consumerOpts.deliver_policy===Et.Last)&&(delete i.opt_start_seq,i.deliver_policy=this.consumerOpts.deliver_policy),i.deliver_policy===Et.LastPerSubject&&typeof i.filter_subjects>"u"&&typeof i.filter_subject>"u"&&(i.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete i.opt_start_seq,i.deliver_policy=Et.StartTime,i.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(i.inactive_threshold=ht(this.consumerOpts.inactive_threshold))),i}async resetConsumer(e=0){var m,p,g,u,d;As.next();const s=this.serial===0;(m=this.consumer)==null||m.delete().catch(()=>{}),e=e===0?1:e,this.cursor.deliver_seq=0;const i=this.getConsumerOpts(e);i.max_deliver=1,i.mem_storage=!0;const o=cm([((p=this.opts)==null?void 0:p.expires)||3e4]);let c;for(let b=0;;b++)try{c=await this.api.add(this.stream,i),(g=this.iter)==null||g.notify(lr.OrderedConsumerRecreated,c.name);break}catch(x){if(x.message==="stream not found"&&((u=this.iter)==null||u.notify(lr.StreamNotFound,b),this.type===zn.Fetch||this.opts.abort_on_missing_resource===!0))return(d=this.iter)==null||d.stop(x),Promise.reject(x);if(s&&b>=this.maxInitialReset)throw x;await oa(o.backoff(b+1))}return c}internalHandler(e){return s=>{var o;if(this.serial!==e)return;const i=s.info.deliverySequence;if(i!==this.cursor.deliver_seq+1){this.notifyOrderedResetAndReset();return}this.cursor.deliver_seq=i,this.cursor.stream_seq=s.info.streamSequence,this.userCallback?this.userCallback(s):(o=this.iter)==null||o.push(s)}}async reset(e={max_messages:100,expires:3e4},s){var g,u;s=s||{};const i=s.fromFetch||!1,o=s.orderedReset||!1;if(this.type===zn.Fetch&&o){(g=this.iter)==null||g.src.stop(),await((u=this.iter)==null?void 0:u.closed()),this.currentConsumer=null;return}(this.currentConsumer===null||o)&&(this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1)),(this.iter===null||i)&&(this.iter=new F2),this.consumer=new Ld(this.api,this.currentConsumer);const c=e;c.callback=this.internalHandler(this.serial);let m=null;this.type===zn.Fetch&&i?m=await this.consumer.fetch(e):this.type===zn.Consume&&(m=await this.consumer.consume(e));const p=m;p.forOrderedConsumer=!0,p.resetHandler=()=>{this.notifyOrderedResetAndReset()},this.iter.setSource(p)}notifyOrderedResetAndReset(){var e;(e=this.iter)==null||e.notify(ea.Reset,""),this.reset(this.opts,{orderedReset:!0})}async consume(e={max_messages:100,expires:3e4}){if(e.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===zn.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===zn.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:i}=e;return i&&(this.userCallback=i),this.type=zn.Consume,this.opts=e,await this.reset(e),this.iter}async fetch(e={max_messages:100,expires:3e4}){var o;if(e.bind)return Promise.reject(new Error("bind is not supported"));if(this.type===zn.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((o=this.iter)==null?void 0:o.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:i}=e;return i&&(this.userCallback=i),this.type=zn.Fetch,this.opts=e,await this.reset(e,{fromFetch:!0}),this.iter}async next(e={expires:3e4}){const s=e;if(s.bind)return Promise.reject(new Error("bind is not supported"));s.max_messages=1;const i=dt();return s.callback=c=>{this.userCallback=null,i.resolve(c)},(await this.fetch(s)).iterClosed.then(c=>{c&&i.reject(c),i.resolve(null)}).catch(c=>{i.reject(c)}),i}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(e=>Promise.resolve(e)).catch(e=>Promise.reject(e)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(e){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.startSeq),Promise.resolve(this.currentConsumer)):e&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}class qd{constructor(e){j(this,"api");j(this,"notified");this.api=e,this.notified=!1}checkVersion(){const e=this.api.nc.features.get(Ve.JS_SIMPLIFICATION);return e.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${e.min} or better`))}getPullConsumerFor(e){if(e.config.deliver_subject!==void 0)throw new Error("push consumer not supported");return new Ld(this.api,e)}async get(e,s={}){return typeof s=="object"?this.ordered(e,s):(await this.checkVersion(),this.api.info(e,s).then(i=>i.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Ld(this.api,i)).catch(i=>Promise.reject(i)))}async ordered(e,s){await this.checkVersion();const i=this.api;return new mm(i.nc,i.opts).info(e).then(c=>Promise.resolve(new G2(this.api,e,s))).catch(c=>Promise.reject(c))}}class ku{constructor(e,s){j(this,"api");j(this,"_info");this.api=e,this._info=s}get name(){return this._info.config.name}alternates(){return this.info().then(e=>e.alternates?e.alternates:[])}async best(){if(await this.info(),this._info.alternates){const e=await this.api.info(this._info.alternates[0].name);return new ku(this.api,e)}else return this}info(e=!1,s){return e?Promise.resolve(this._info):this.api.info(this.name,s).then(i=>(this._info=i,this._info))}getConsumerFromInfo(e){return new qd(new mu(this.api.nc,this.api.opts)).getPullConsumerFor(e)}getConsumer(e){return new qd(new mu(this.api.nc,this.api.opts)).get(this.name,e)}getMessage(e){return this.api.getMessage(this.name,e)}deleteMessage(e,s){return this.api.deleteMessage(this.name,e,s)}}class mm extends Ro{constructor(e,s){super(e,s)}checkStreamConfigVersions(e){const s=this.nc;if(e.metadata){const{min:o,ok:c}=s.features.get(Ve.JS_STREAM_CONSUMER_METADATA);if(!c)throw new Error(`stream 'metadata' requires server ${o}`)}if(e.first_seq){const{min:o,ok:c}=s.features.get(Ve.JS_STREAM_FIRST_SEQ);if(!c)throw new Error(`stream 'first_seq' requires server ${o}`)}if(e.subject_transform){const{min:o,ok:c}=s.features.get(Ve.JS_STREAM_SUBJECT_TRANSFORM);if(!c)throw new Error(`stream 'subject_transform' requires server ${o}`)}if(e.compression){const{min:o,ok:c}=s.features.get(Ve.JS_STREAM_COMPRESSION);if(!c)throw new Error(`stream 'compression' requires server ${o}`)}if(e.consumer_limits){const{min:o,ok:c}=s.features.get(Ve.JS_DEFAULT_CONSUMER_LIMITS);if(!c)throw new Error(`stream 'consumer_limits' requires server ${o}`)}function i(o,c){var p;if((((p=c==null?void 0:c.subject_transforms)==null?void 0:p.length)||0)>0){const{min:g,ok:u}=s.features.get(Ve.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!u)throw new Error(`${o} 'subject_transforms' requires server ${g}`)}}e.sources&&e.sources.forEach(o=>{i("stream sources",o)}),e.mirror&&i("stream mirror",e.mirror)}async add(e={}){var o;this.checkStreamConfigVersions(e),Qt(e.name),e.mirror=cc(e.mirror),e.sources=(o=e.sources)==null?void 0:o.map(cc);const i=await this._request(`${this.prefix}.STREAM.CREATE.${e.name}`,e);return this._fixInfo(i),i}async delete(e){return Qt(e),(await this._request(`${this.prefix}.STREAM.DELETE.${e}`)).success}async update(e,s={}){var p;if(typeof e=="object"){const g=e;e=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),Qt(e);const i=await this.info(e),o=Object.assign(i.config,s);o.mirror=cc(o.mirror),o.sources=(p=o.sources)==null?void 0:p.map(cc);const m=await this._request(`${this.prefix}.STREAM.UPDATE.${e}`,o);return this._fixInfo(m),m}async info(e,s){Qt(e);const i=`${this.prefix}.STREAM.INFO.${e}`;let c=await this._request(i,s),{total:m,limit:p}=c,g=c.state.subjects?Object.getOwnPropertyNames(c.state.subjects).length:1;if(m&&m>g){const u=[c],d=s||{};let b=0;for(;m>g;){b++,d.offset=p*b;const v=await this._request(i,d);m=v.total,u.push(v);const _=Object.getOwnPropertyNames(v.state.subjects).length;if(g+=_,_<p)break}let x={};for(let v=0;v<u.length;v++)c=u[v],c.state.subjects&&(x=Object.assign(x,c.state.subjects));c.offset=0,c.total=0,c.limit=0,c.state.subjects=x}return this._fixInfo(c),c}list(e=""){const s=e!=null&&e.length?{subject:e}:{},i=c=>{const m=c;return m.streams.forEach(p=>{this._fixInfo(p)}),m.streams},o=`${this.prefix}.STREAM.LIST`;return new xo(o,i,this,s)}_fixInfo(e){e.config.sealed=e.config.sealed||!1,e.config.deny_delete=e.config.deny_delete||!1,e.config.deny_purge=e.config.deny_purge||!1,e.config.allow_rollup_hdrs=e.config.allow_rollup_hdrs||!1}async purge(e,s){if(s){const{keep:o,seq:c}=s;if(typeof o=="number"&&typeof c=="number")throw new Error("can specify one of keep or seq")}return Qt(e),await this._request(`${this.prefix}.STREAM.PURGE.${e}`,s)}async deleteMessage(e,s,i=!0){Qt(e);const o={seq:s};return i||(o.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${e}`,o)).success}async getMessage(e,s){Qt(e);const o=await this._request(`${this.prefix}.STREAM.MSG.GET.${e}`,s);return new Mx(o)}find(e){return this.findStream(e)}listKvs(){const e=i=>{var g;const c=i.streams.filter(u=>u.config.name.startsWith(Sn));c.forEach(u=>{this._fixInfo(u)});let m="";return c.length&&(m=((g=this.nc.info)==null?void 0:g.cluster)??""),c.map(u=>new Cx(u,m))},s=`${this.prefix}.STREAM.LIST`;return new xo(s,e,this)}listObjectStores(){const e=i=>{const c=i.streams.filter(p=>p.config.name.startsWith(dm));return c.forEach(p=>{this._fixInfo(p)}),c.map(p=>new Dd(p))},s=`${this.prefix}.STREAM.LIST`;return new xo(s,e,this)}names(e=""){const s=e!=null&&e.length?{subject:e}:{},i=c=>c.streams,o=`${this.prefix}.STREAM.NAMES`;return new xo(o,i,this,s)}async get(e){const s=await this.info(e);return Promise.resolve(new ku(this,s))}}class V2 extends Ro{constructor(e,s){super(e,s)}async getMessage(e,s){Qt(e);let i=s;const{last_by_subj:o}=i;o&&(i=null);const c=i?this.jc.encode(i):jn,m=this.opts.apiPrefix||"$JS.API",p=o?`${m}.DIRECT.GET.${e}.${o}`:`${m}.DIRECT.GET.${e}`,g=await this.nc.request(p,c,{timeout:this.timeout}),u=Wi(g);if(u)return Promise.reject(u);const d=new Pd(g);return Promise.resolve(d)}async getBatch(e,s){Qt(e);const o=`${this.opts.apiPrefix||"$JS.API"}.DIRECT.GET.${e}`;if(!Array.isArray(s.multi_last)||s.multi_last.length===0)return Promise.reject("multi_last is required");const c=JSON.stringify(s,(g,u)=>g==="up_to_time"&&u instanceof Date?u.toISOString():u),m=new Ut,p=await this.nc.requestMany(o,c,{strategy:Zn.SentinelMsg});return(async()=>{var b,x,v;let g=!1,u=!1,d;for await(const _ of p){if(!g){g=!0;const S=((b=_.headers)==null?void 0:b.code)||0;if(S!==0&&S<200||S>299){d=(x=_.headers)==null?void 0:x.description.toLowerCase();break}if(((v=_.headers)==null?void 0:v.get("Nats-Num-Pending"))===""){u=!0;break}}if(_.data.length===0)break;m.push(new Pd(_))}m.push(()=>{if(u)throw new Error("batch direct get not supported by the server");if(d)throw new Error(`bad request: ${d}`);m.stop()})})(),Promise.resolve(m)}}class Pd{constructor(e){j(this,"data");j(this,"header");if(!e.headers)throw new Error("headers expected");this.data=e.data,this.header=e.headers}get subject(){return this.header.last(Ji.Subject)}get seq(){const e=this.header.last(Ji.Sequence);return typeof e=="string"?parseInt(e):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(Ji.TimeStamp)}get stream(){return this.header.last(Ji.Stream)}json(e){return er(e).decode(this.data)}string(){return En.decode(this.data)}}j(Pd,"jc");class Y2 extends Ro{constructor(s,i){super(s,i);j(this,"streams");j(this,"consumers");j(this,"direct");this.streams=new mm(s,i),this.consumers=new mu(s,i),this.direct=new V2(s,i)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const s=new Ut;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(i,o)=>{if(i)throw i;try{const c=this.parseJsResponse(o),m=c.type.split("."),p=m[m.length-1];s.push({kind:p,data:c})}catch(c){s.stop(c)}}}),s}}class Mx{constructor(e){j(this,"_header");j(this,"smr");this.smr=e}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):jn}get header(){if(!this._header)if(this.smr.message.hdrs){const e=this._parse(this.smr.message.hdrs);this._header=ws.decode(e)}else this._header=Pr();return this._header}_parse(e){const s=atob(e),i=s.length,o=new Uint8Array(i);for(let c=0;c<i;c++)o[c]=s.charCodeAt(c);return o}json(e){return er(e).decode(this.data)}string(){return En.decode(this.data)}}j(Mx,"jc");class K2{constructor(e){j(this,"api");this.api=e}get(e){return this.api.info(e).then(s=>new ku(this.api,s))}}class id{constructor(e){j(this,"info");j(this,"hdrs");this.info=e}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=ws.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 e,s;return((e=this.info.options)==null?void 0:e.link)!==void 0&&((s=this.info.options)==null?void 0:s.link)!==null}}function yb(n){const e={name:n.name,description:n.description??"",options:n.options,metadata:n.metadata};if(n.headers){const s=n.headers;e.headers=s.toRecord()}return e}function J2(){return new ReadableStream({pull(n){n.enqueue(new Uint8Array(0)),n.close()}})}class Eo{constructor(e,s,i){j(this,"jsm");j(this,"js");j(this,"stream");j(this,"name");this.name=e,this.jsm=s,this.js=i}_checkNotEmpty(e){return!e||e.length===0?{name:e,error:new Error("name cannot be empty")}:{name:e}}async info(e){const s=await this.rawInfo(e);return s?new id(s):null}async list(){const e=[],s=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const i of s){if(i===null)break;e.push(i)}return Promise.resolve(e)}async rawInfo(e){const{name:s,error:i}=this._checkNotEmpty(e);if(i)return Promise.reject(i);const o=this._metaSubject(s);try{const c=await this.jsm.streams.getMessage(this.stream,{last_by_subj:o}),p=er().decode(c.data);return p.revision=c.seq,p}catch(c){return c.code==="404"?null:Promise.reject(c)}}async _si(e){try{return await this.jsm.streams.info(this.stream,e)}catch(s){return s.code==="404"?null:Promise.reject(s)}}async seal(){let e=await this._si();return e===null?Promise.reject(new Error("object store not found")):(e.config.sealed=!0,e=await this.jsm.streams.update(this.stream,e.config),Promise.resolve(new Dd(e)))}async status(e){const s=await this._si(e);return s===null?Promise.reject(new Error("object store not found")):Promise.resolve(new Dd(s))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(e,s,i){var te;const o=this.js.getOptions();i=i||{timeout:o.timeout},i.timeout=i.timeout||o.timeout,i.previousRevision=i.previousRevision??void 0;const{timeout:c,previousRevision:m}=i,p=this.js.nc.info,g=(p==null?void 0:p.max_payload)||1024;e=e||{},e.options=e.options||{};let u=((te=e.options)==null?void 0:te.max_chunk_size)||128*1024;u=u>g?g:u,e.options.max_chunk_size=u;const d=await this.info(e.name),{name:b,error:x}=this._checkNotEmpty(e.name);if(x)return Promise.reject(x);const v=As.next(),_=this._chunkSubject(v),S=this._metaSubject(b),C=Object.assign({bucket:this.name,nuid:v,size:0,chunks:0},yb(e)),B=dt(),q=[],ne=new aa;try{const M=s?s.getReader():null,z=ib.create();for(;;){const{done:ae,value:F}=M?await M.read():{done:!0,value:void 0};if(ae){if(ne.size()>0){const W=ne.drain();z.update(W),C.chunks++,C.size+=W.length,q.push(this.js.publish(_,W,{timeout:c}))}await Promise.all(q),q.length=0,C.mtime=new Date().toISOString();const U=Zi.encode(z.digest());C.digest=`${mb}${U}`,C.deleted=!1;const D=Pr();typeof m=="number"&&D.set(or.ExpectedLastSubjectSequenceHdr,`${m}`),D.set(Zt.RollupHdr,Zt.RollupValueSubject);const Q=await this.js.publish(S,er().encode(C),{headers:D,timeout:c});if(C.revision=Q.seq,d)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${d.nuid}`})}catch{}B.resolve(new id(C));break}if(F)for(ne.fill(F);ne.size()>u;){C.chunks++,C.size+=u;const U=ne.drain(e.options.max_chunk_size);z.update(U),q.push(this.js.publish(_,U,{timeout:c}))}}}catch(M){await this.jsm.streams.purge(this.stream,{filter:_}),B.reject(M)}return B}putBlob(e,s,i){function o(c){return new ReadableStream({pull(m){m.enqueue(c),m.close()}})}return s===null&&(s=new Uint8Array(0)),this.put(e,o(s),i)}put(e,s,i){var o;return(o=e==null?void 0:e.options)!=null&&o.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(e,s,i)}async getBlob(e){async function s(c){const m=new aa,p=c.getReader();for(;;){const{done:g,value:u}=await p.read();if(g)return m.drain();u&&u.length&&m.fill(u)}}const i=await this.get(e);if(i===null)return Promise.resolve(null);const o=await Promise.all([i.error,s(i.data)]);return o[0]?Promise.reject(o[0]):Promise.resolve(o[1])}async get(e){const s=await this.rawInfo(e);if(s===null||s.deleted)return Promise.resolve(null);if(s.options&&s.options.link){const b=s.options.link.name||"";if(b==="")throw new Error("link is a bucket");return(s.options.link.bucket!==this.name?await Eo.create(this.js,s.options.link.bucket):this).get(b)}if(!s.digest.startsWith(mb))return Promise.reject(new Error(`unknown digest type: ${s.digest}`));const i=Nd(s.digest.substring(8));if(i===null)return Promise.reject(new Error(`unable to parse digest: ${s.digest}`));const o=dt(),c={info:new id(s),error:o};if(s.size===0)return c.data=J2(),o.resolve(null),Promise.resolve(c);let m;const p=Ss();p.orderedConsumer();const g=ib.create(),u=`$O.${this.name}.C.${s.nuid}`,d=await this.js.subscribe(u,p);return(async()=>{for await(const b of d)b.data.length>0&&(g.update(b.data),m.enqueue(b.data)),b.info.pending===0&&(PE(i,g.digest())?m.close():m.error(new Error(`received a corrupt object, digests do not match received: ${s.digest} calculated ${i}`)),d.unsubscribe())})().then(()=>{o.resolve()}).catch(b=>{m.error(b),o.reject(b)}),c.data=new ReadableStream({start(b){m=b},cancel(){d.unsubscribe()}}),c}linkStore(e,s){if(!(s instanceof Eo))return Promise.reject("bucket required");const i=s,{name:o,error:c}=this._checkNotEmpty(e);if(c)return Promise.reject(c);const m={name:o,options:{link:{bucket:i.name}}};return this._put(m,null)}async link(e,s){const{name:i,error:o}=this._checkNotEmpty(e);if(o)return Promise.reject(o);if(s.deleted)return Promise.reject(new Error("src object is deleted"));if(s.isLink())return Promise.reject(new Error("src object is a link"));const c=await this.rawInfo(e);if(c!==null&&!c.deleted)return Promise.reject(new Error("an object already exists with that name"));const m={bucket:s.bucket,name:s.name},p={name:i,bucket:s.bucket,options:{link:m}};await this.js.publish(this._metaSubject(e),JSON.stringify(p));const g=await this.info(e);return Promise.resolve(g)}async delete(e){const s=await this.rawInfo(e);if(s===null)return Promise.resolve({purged:0,success:!1});s.deleted=!0,s.size=0,s.chunks=0,s.digest="";const i=er(),o=Pr();return o.set(Zt.RollupHdr,Zt.RollupValueSubject),await this.js.publish(this._metaSubject(s.name),i.encode(s),{headers:o}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(s.nuid)})}async update(e,s={}){const i=await this.rawInfo(e);if(i===null)return Promise.reject(new Error("object not found"));if(i.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));s.name=s.name??i.name;const{name:o,error:c}=this._checkNotEmpty(s.name);if(c)return Promise.reject(c);if(e!==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 m=Object.assign({},i,yb(s)),p=await this.js.publish(this._metaSubject(m.name),JSON.stringify(m));return e!==s.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(e)}),Promise.resolve(p)}async watch(e={}){e.includeHistory=e.includeHistory??!1,e.ignoreDeletes=e.ignoreDeletes??!1;let s=!1;const i=new Ut,o=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:o})}catch(g){g.code==="404"?(i.push(null),s=!0):i.stop(g)}const c=er(),m=Ss();m.orderedConsumer(),e.includeHistory?m.deliverLastPerSubject():(s=!0,m.deliverNew()),m.callback((g,u)=>{var d;if(g){i.stop(g);return}if(u!==null){const b=c.decode(u.data);b.deleted&&e.ignoreDeletes===!0||i.push(b),((d=u.info)==null?void 0:d.pending)===0&&!s&&(s=!0,i.push(null))}});const p=await this.js.subscribe(o,m);return i._data=p,i.iterClosed.then(()=>{p.unsubscribe()}),p.closed.then(()=>{i.stop()}).catch(g=>{i.stop(g)}),i}_chunkSubject(e){return`$O.${this.name}.C.${e}`}_metaSubject(e){return`$O.${this.name}.M.${Zi.encode(e)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(e={}){try{this.stream=B2(this.name)}catch(o){return Promise.reject(o)}const s=(e==null?void 0:e.ttl)||0;delete e.ttl;const i=Object.assign({max_age:s},e);i.name=this.stream,i.num_replicas=e.replicas??1,i.allow_direct=!0,i.allow_rollup_hdrs=!0,i.discard=Ao.New,i.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],e.placement&&(i.placement=e.placement),e.metadata&&(i.metadata=e.metadata),typeof e.compression=="boolean"&&(i.compression=e.compression?js.S2:js.None);try{await this.jsm.streams.info(i.name)}catch(o){o.message==="stream not found"&&await this.jsm.streams.add(i)}}static async create(e,s,i={}){const o=await e.jetstreamManager(),c=new Eo(s,o,e);return await c.init(i),Promise.resolve(c)}}class Q2{constructor(e){j(this,"js");this.js=e}kv(e,s={}){const i=this.js,{ok:o,min:c}=i.nc.features.get(Ve.JS_KV);return o?s.bindOnly?ko.bind(this.js,e,s):ko.create(this.js,e,s):Promise.reject(new Error(`kv is only supported on servers ${c} or better`))}os(e,s={}){var m;if(typeof((m=crypto==null?void 0:crypto.subtle)==null?void 0:m.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const i=this.js,{ok:o,min:c}=i.nc.features.get(Ve.JS_OBJECTSTORE);return o?Eo.create(this.js,e,s):Promise.reject(new Error(`objectstore is only supported on servers ${c} or better`))}}class pm extends Ro{constructor(s,i){super(s,i);j(this,"consumers");j(this,"streams");j(this,"consumerAPI");j(this,"streamAPI");this.consumerAPI=new mu(s,i),this.streamAPI=new mm(s,i),this.consumers=new qd(this.consumerAPI),this.streams=new K2(this.streamAPI)}jetstreamManager(s){s===void 0&&(s=this.opts.checkAPI);const i=Object.assign({},this.opts,{checkAPI:s});return this.nc.jetstreamManager(i)}get apiPrefix(){return this.prefix}get views(){return new Q2(this)}async publish(s,i=jn,o){o=o||{},o.expect=o.expect||{};const c=(o==null?void 0:o.headers)||Pr();o&&(o.msgID&&c.set(or.MsgIdHdr,o.msgID),o.expect.lastMsgID&&c.set(or.ExpectedLastMsgIdHdr,o.expect.lastMsgID),o.expect.streamName&&c.set(or.ExpectedStreamHdr,o.expect.streamName),typeof o.expect.lastSequence=="number"&&c.set(or.ExpectedLastSeqHdr,`${o.expect.lastSequence}`),typeof o.expect.lastSubjectSequence=="number"&&c.set(or.ExpectedLastSubjectSequenceHdr,`${o.expect.lastSubjectSequence}`));const m=o.timeout||this.timeout,p={};m&&(p.timeout=m),o&&(p.headers=c);let{retries:g,retry_delay:u}=o;g=g||1,u=u||250;let d;for(let x=0;x<g;x++)try{d=await this.nc.request(s,i,p);break}catch(v){if(v.code==="503"&&x+1<g)await oa(u);else throw v}const b=this.parseJsResponse(d);if(b.stream==="")throw be.errorForCode(fe.JetStreamInvalidAck);return b.duplicate=b.duplicate?b.duplicate:!1,b}async pull(s,i,o=0){Qt(s),Xi(i);let c=this.timeout;o>c&&(c=o),o=o<0?0:ht(o);const m={batch:1,no_wait:o===0,expires:o},p=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(m),{noMux:!0,timeout:c}),g=Wi(p);if(g)throw g;return No(p,this.timeout)}fetch(s,i,o={}){Qt(s),Xi(i);let c=null;const m=(o.max_bytes??0)>0;let p=0;const g=m?o.max_bytes:0;let u=null;const d={};if(d.batch=o.batch||1,g){const q=this.nc.features.get(Ve.JS_PULL_MAX_BYTES);if(!q.ok)throw new Error(`max_bytes is only supported on servers ${q.min} or better`);d.max_bytes=g}d.no_wait=o.no_wait||!1,d.no_wait&&d.expires&&(d.expires=0);const b=o.expires||0;if(b&&(d.expires=ht(b)),b===0&&d.no_wait===!1)throw new Error("expires or no_wait is required");const x=o.idle_heartbeat||0;x&&(d.idle_heartbeat=ht(x),o.delay_heartbeat===!0&&(d.idle_heartbeat=ht(x*4)));const v=new Ut,_=d.batch;let S=0;v.protocolFilterFn=(q,ne=!1)=>Ad(q.msg)?(u==null||u.work(),!1):!0,v.dispatchedFn=q=>{if(q){if(m&&(p+=q.data.length),S++,c&&q.info.pending===0)return;(v.getPending()===1&&q.info.pending===0||_===S||g>0&&p>=g)&&v.stop()}};const C=Lr(this.nc.options.inboxPrefix),B=this.nc.subscribe(C,{max:o.batch,callback:(q,ne)=>{q===null&&(q=Wi(ne)),q!==null?(c&&(c.cancel(),c=null),bE(q)?v.stop(Dx(q)===null?void 0:q):v.stop(q)):(u==null||u.work(),v.received++,v.push(No(ne,this.timeout)))}});return b&&(c=sa(b),c.catch(()=>{B.isClosed()||(B.drain().catch(()=>{}),c=null),u&&u.cancel()})),(async()=>{try{x&&(u=new hm(x,q=>(v.push(()=>{v.err=new be(`${In.IdleHeartbeatMissed}: ${q}`,fe.JetStreamIdleHeartBeat)}),!0)))}catch{}await B.closed,c!==null&&(c.cancel(),c=null),u&&u.cancel(),v.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${s}.${i}`,this.jc.encode(d),{reply:C}),v}async pullSubscribe(s,i=Ss()){const o=await this._processOptions(s,i);if(o.ordered)throw new Error("pull subscribers cannot be be ordered");if(o.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const c=o.config.ack_policy;if(c===Bt.None||c===Bt.All)throw new Error("ack policy for pull consumers must be explicit");const m=this._buildTypedSubscriptionOpts(o),p=new eO(this,o.deliver,m);p.info=o;try{await this._maybeCreateConsumer(o)}catch(g){throw p.unsubscribe(),g}return p}async subscribe(s,i=Ss()){const o=await this._processOptions(s,i);if(!o.isBind&&!o.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const c=this._buildTypedSubscriptionOpts(o),m=new Rx(this,o.deliver,c);m.info=o;try{await this._maybeCreateConsumer(o)}catch(p){throw m.unsubscribe(),p}return m._maybeSetupHbMonitoring(),m}async _processOptions(s,i=Ss()){const o=tb(i)?i.getOpts():i;if(o.isBind=tb(i)?i.isBind:!1,o.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},o.ordered){if(o.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},o.config.ack_policy!==Bt.NotSet&&o.config.ack_policy!==Bt.None)throw new be("ordered consumer: ack_policy can only be set to 'none'",fe.ApiError);if(o.config.durable_name&&o.config.durable_name.length>0)throw new be("ordered consumer: durable_name cannot be set",fe.ApiError);if(o.config.deliver_subject&&o.config.deliver_subject.length>0)throw new be("ordered consumer: deliver_subject cannot be set",fe.ApiError);if(o.config.max_deliver!==void 0&&o.config.max_deliver>1)throw new be("ordered consumer: max_deliver cannot be set",fe.ApiError);if(o.config.deliver_group&&o.config.deliver_group.length>0)throw new be("ordered consumer: deliver_group cannot be set",fe.ApiError);o.config.deliver_subject=Lr(this.nc.options.inboxPrefix),o.config.ack_policy=Bt.None,o.config.max_deliver=1,o.config.flow_control=!0,o.config.idle_heartbeat=o.config.idle_heartbeat||ht(5e3),o.config.ack_wait=ht(1320*60*1e3),o.config.mem_storage=!0,o.config.num_replicas=1}if(o.config.ack_policy===Bt.NotSet&&(o.config.ack_policy=Bt.All),o.api=this,o.config=o.config||{},o.stream=o.stream?o.stream:await this.findStream(s),o.attached=!1,o.config.durable_name)try{const c=await this.consumerAPI.info(o.stream,o.config.durable_name);if(c){if(c.config.filter_subject&&c.config.filter_subject!==s)throw new Error("subject does not match consumer");const m=o.config.deliver_group??"";if(m===""&&c.push_bound===!0)throw new Error("duplicate subscription");const p=c.config.deliver_group??"";if(m!==p)throw p===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${p}'`);o.last=c,o.config=c.config,o.attached=!0,o.config.durable_name||(o.name=c.name)}}catch(c){if(c.code!=="404")throw c}return!o.attached&&o.config.filter_subject===void 0&&o.config.filter_subjects===void 0&&(o.config.filter_subject=s),o.deliver=o.config.deliver_subject||Lr(this.nc.options.inboxPrefix),o}_buildTypedSubscriptionOpts(s){const i={};return i.adapter=tO(s.callbackFn===void 0,this.timeout),i.ingestionFilterFn=pm.ingestionFn(s.ordered),i.protocolFilterFn=(o,c=!1)=>{const m=o;return Od(m.msg)?(c||m.msg.respond(),!1):!0},!s.mack&&s.config.ack_policy!==Bt.None&&(i.dispatchedFn=sO),s.callbackFn&&(i.callback=s.callbackFn),i.max=s.max||0,i.queue=s.queue,i}async _maybeCreateConsumer(s){if(s.attached)return;if(s.isBind)throw new Error(`unable to bind - durable consumer ${s.config.durable_name} doesn't exist in ${s.stream}`);s.config=Object.assign({deliver_policy:Et.All,ack_policy:Bt.Explicit,ack_wait:ht(30*1e3),replay_policy:ia.Instant},s.config);const i=await this.consumerAPI.add(s.stream,s.config);if(Array.isArray(s.config.filter_subjects&&!Array.isArray(i.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");s.name=i.name,s.config=i.config,s.last=i}static ingestionFn(s){return(i,o)=>{var g;const c=o;if(!i)return{ingest:!1,protocol:!1};const m=i;if(Wi(m.msg)||(g=c.monitor)==null||g.work(),Ad(m.msg)){const u=s?c._checkHbOrderConsumer(m.msg):!0;return s||c.info.flow_control.heartbeat_count++,{ingest:u,protocol:!0}}else if(Od(m.msg))return c.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:s?c._checkOrderedConsumer(i):!0,protocol:!1}}}}class ym{constructor(e){j(this,"options");j(this,"protocol");j(this,"draining");j(this,"listeners");j(this,"_services");this.draining=!1,this.options=x2(e),this.listeners=[]}static connect(e={}){return new Promise((s,i)=>{const o=new ym(e);yu.connect(o.options,o).then(c=>{o.protocol=c,(async function(){for await(const m of c.status())o.listeners.forEach(p=>{p.push(m)})})(),s(o)}).catch(c=>{i(c)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,s,i){if(this.isClosed())throw be.errorForCode(fe.ConnectionClosed);if(s&&this.isDraining()||i&&this.protocol.noMorePublishing)throw be.errorForCode(fe.ConnectionDraining);if(e=e||"",e.length===0)throw be.errorForCode(fe.BadSubject)}publish(e,s,i){this._check(e,!1,!0),this.protocol.publish(e,s,i)}publishMessage(e){return this.publish(e.subject,e.data,{reply:e.reply,headers:e.headers})}respondMessage(e){return e.reply?(this.publish(e.reply,e.data,{reply:e.reply,headers:e.headers}),!0):!1}subscribe(e,s={}){this._check(e,!0,!1);const i=new Nx(this.protocol,e,s);return this.protocol.subscribe(i),i}_resub(e,s,i){this._check(s,!0,!1);const o=e;o.max=i,i&&(o.max=i+o.received),this.protocol.resub(o,s)}requestMany(e,s=jn,i={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(g){return Promise.reject(g)}if(i.strategy=i.strategy||Zn.Timer,i.maxWait=i.maxWait||1e3,i.maxWait<1)return Promise.reject(new be("timeout",fe.InvalidOption));const c=new Ut;function m(g){c.push(()=>{c.stop(g)})}function p(g,u){g||u===null?m(g===null?void 0:g):c.push(u)}if(i.noMux){const g=o?new Error().stack:null;let u=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1;const d=this.subscribe(Lr(this.options.inboxPrefix),{callback:(_,S)=>{var C,B;if(((C=S==null?void 0:S.data)==null?void 0:C.length)===0&&((B=S==null?void 0:S.headers)==null?void 0:B.status)===fe.NoResponders&&(_=be.errorForCode(fe.NoResponders)),_){g&&(_.stack+=`
48
48
 
49
- ${g}`),b(_);return}p(null,S),i.strategy===Zn.Count&&(u--,u===0&&b()),i.strategy===Zn.JitterTimer&&(v(),x=setTimeout(()=>{b()},300)),i.strategy===Zn.SentinelMsg&&S&&S.data.length===0&&b()}});d.requestSubject=e,d.closed.then(()=>{m()}).catch(_=>{c.stop(_)});const b=_=>{_&&c.push(()=>{throw _}),v(),d.drain().then(()=>{m()}).catch(S=>{m()})};c.iterClosed.then(()=>{v(),d==null||d.unsubscribe()}).catch(_=>{v(),d==null||d.unsubscribe()});try{this.publish(e,s,{reply:d.getSubject()})}catch(_){b(_)}let x=setTimeout(()=>{b()},i.maxWait);const v=()=>{x&&clearTimeout(x)}}else{const g=i;g.callback=p,c.iterClosed.then(()=>{u.cancel()}).catch(d=>{u.cancel(d)});const u=new BE(this.protocol.muxSubscriptions,e,g);this.protocol.request(u);try{this.publish(e,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:i.headers})}catch(d){u.cancel(d)}}return Promise.resolve(c)}request(e,s,i={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(c){return Promise.reject(c)}const o=!this.protocol.options.noAsyncTraces;if(i.timeout=i.timeout||1e3,i.timeout<1)return Promise.reject(new ge("timeout",fe.InvalidOption));if(!i.noMux&&i.reply)return Promise.reject(new ge("reply can only be used with noMux",fe.InvalidOption));if(i.noMux){const c=i.reply?i.reply:Lr(this.options.inboxPrefix),m=mt(),p=o?new Error:null,g=this.subscribe(c,{max:1,timeout:i.timeout,callback:(u,d)=>{u?(p&&u.code!==fe.Timeout&&(u.stack+=`
49
+ ${g}`),b(_);return}p(null,S),i.strategy===Zn.Count&&(u--,u===0&&b()),i.strategy===Zn.JitterTimer&&(v(),x=setTimeout(()=>{b()},300)),i.strategy===Zn.SentinelMsg&&S&&S.data.length===0&&b()}});d.requestSubject=e,d.closed.then(()=>{m()}).catch(_=>{c.stop(_)});const b=_=>{_&&c.push(()=>{throw _}),v(),d.drain().then(()=>{m()}).catch(S=>{m()})};c.iterClosed.then(()=>{v(),d==null||d.unsubscribe()}).catch(_=>{v(),d==null||d.unsubscribe()});try{this.publish(e,s,{reply:d.getSubject()})}catch(_){b(_)}let x=setTimeout(()=>{b()},i.maxWait);const v=()=>{x&&clearTimeout(x)}}else{const g=i;g.callback=p,c.iterClosed.then(()=>{u.cancel()}).catch(d=>{u.cancel(d)});const u=new BE(this.protocol.muxSubscriptions,e,g);this.protocol.request(u);try{this.publish(e,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:i.headers})}catch(d){u.cancel(d)}}return Promise.resolve(c)}request(e,s,i={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(c){return Promise.reject(c)}const o=!this.protocol.options.noAsyncTraces;if(i.timeout=i.timeout||1e3,i.timeout<1)return Promise.reject(new be("timeout",fe.InvalidOption));if(!i.noMux&&i.reply)return Promise.reject(new be("reply can only be used with noMux",fe.InvalidOption));if(i.noMux){const c=i.reply?i.reply:Lr(this.options.inboxPrefix),m=dt(),p=o?new Error:null,g=this.subscribe(c,{max:1,timeout:i.timeout,callback:(u,d)=>{u?(p&&u.code!==fe.Timeout&&(u.stack+=`
50
50
 
51
51
  ${p.stack}`),g.unsubscribe(),m.reject(u)):(u=vx(d),u?(p&&(u.stack+=`
52
52
 
53
- ${p.stack}`),m.reject(u)):m.resolve(d))}});return g.requestSubject=e,this.protocol.publish(e,s,{reply:c,headers:i.headers}),m}else{const c=new Sx(this.protocol.muxSubscriptions,e,i,o);this.protocol.request(c);try{this.publish(e,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(p){c.cancel(p)}const m=Promise.race([c.timer,c.deferred]);return m.catch(()=>{c.cancel()}),m}}flush(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(ge.errorForCode(fe.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Ut;return e.iterClosed.then(()=>{const s=this.listeners.indexOf(e);this.listeners.splice(s,1)}),this.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,i)=>s==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(e={}){const s=new Y2(this,e);if(e.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===fe.NoResponders&&(o.code=fe.JetStreamNotEnabled),o}return s}jetstream(e={}){return new pm(this,e)}getServerVersion(){const e=this.info;return e?ti(e.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw ge.errorForCode(fe.Disconnect);const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}get services(){return this._services||(this._services=new X2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(ge.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(ge.errorForCode(fe.ConnectionDraining)):this.protocol.reconnect()}}class X2{constructor(e){j(this,"nc");this.nc=e}add(e){try{return new Do(this.nc,e).start()}catch(s){return Promise.reject(s)}}client(e,s){return new T2(this.nc,e,s)}}class W2{constructor(e,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=e,this.prefixLen=s,this.sm=i}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(gu)||"PUT"}get length(){const e=this.sm.header.get(Wt.MessageSizeHdr)||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Z2{constructor(e,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=e,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(um(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var e;return((e=this.sm.headers)==null?void 0:e.get(gu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const e=((s=this.sm.headers)==null?void 0:s.get(Wt.MessageSizeHdr))||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Rx extends $E{constructor(s,i,o){super(s.nc,i,o);j(this,"js");j(this,"monitor");this.js=s,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(s){this.sub.info=s}get info(){return this.sub.info}_resetOrderedConsumer(s){if(this.info===null||this.sub.isClosed())return;const i=Lr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=As.next(),c.ordered_consumer_sequence.delivery_seq=0,c.flow_control.heartbeat_count=0,c.flow_control.fc_count=0,c.flow_control.consumer_restarts++,c.deliver=i,c.config.deliver_subject=i,c.config.deliver_policy=Et.StartSequence,c.config.opt_start_seq=s;const m={};m.stream_name=this.info.stream,m.config=c.config;const p=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(p,m,{retries:-1}).then(g=>{const u=g,d=this.sub.info;d.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new ge(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,fe.RequestError,g);this.sub.callback(u,{})})}_maybeSetupHbMonitoring(){var i,o;const s=((o=(i=this.info)==null?void 0:i.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(um(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,m=p=>{var d,b,x,v;const g=wE(409,`${In.IdleHeartbeatMissed}: ${p}`,this.sub.subject);if(!((d=this.info)==null?void 0:d.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const _=((x=(b=this.info)==null?void 0:b.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(_+1),(v=this.monitor)==null||v.restart(),!1}return!c.noIterator};this.monitor=new hm(s,m,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Wt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Wt.LastConsumerSeqHdr),10),c=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==c.delivery_seq&&this._resetOrderedConsumer(c.stream_seq+1),!1}_checkOrderedConsumer(s){const i=this.info.ordered_consumer_sequence,o=s.info.streamSequence,c=s.info.deliverySequence;return c!=i.delivery_seq+1?(this._resetOrderedConsumer(i.stream_seq+1),!1):(i.delivery_seq=c,i.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${i}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${i}`,c=await s.api._request(o);return s.last=c,c}}class eO extends Rx{constructor(e,s,i){super(e,s,i)}pull(e={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,m={};if(m.batch=e.batch||1,m.no_wait=e.no_wait||!1,(e.max_bytes??0)>0){const u=this.js.nc.features.get(Ye.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);m.max_bytes=e.max_bytes}let p=0;e.expires&&e.expires>0&&(p=e.expires,m.expires=dt(p));let g=0;if(e.idle_heartbeat&&e.idle_heartbeat>0&&(g=e.idle_heartbeat,m.idle_heartbeat=dt(g)),g&&p===0)throw new Error("idle_heartbeat requires expires");if(g>p)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),p&&g&&(this.monitor?this.monitor._change(g,p):this._setupHbMonitoring(g,p));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(d,u.jc.encode(m),{reply:b})}}}function tO(n,e){return n?rO(e):nO(e)}function nO(n){return(e,s)=>e?[e,null]:(e=Wi(s),e?[e,null]:[null,ko(s,n)])}function rO(n){return(e,s)=>{if(e)return[e,null];const i=Wi(s);return i!==null?[Dx(i),null]:[null,ko(s,n)]}}function Dx(n){if(n!==null)switch(n.code){case fe.JetStream404NoMessages:case fe.JetStream408RequestTimeout:return null;case fe.JetStream409:return SE(n)?n:null;default:return n}return null}function sO(n){n&&n.ack()}function iO(n){const e=n.split(".");if(e.length===9&&e.splice(2,0,"_",""),e.length<11||e[0]!=="$JS"||e[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=e[2]==="_"?"":e[2],s.account_hash=e[3],s.stream=e[4],s.consumer=e[5],s.deliveryCount=parseInt(e[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(e[7],10),s.deliverySequence=parseInt(e[8],10),s.timestampNanos=parseInt(e[9],10),s.pending=parseInt(e[10],10),s}class aO{constructor(e,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=e,this.didAck=!1,this.timeout=s}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=iO(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===io[0]&&e[1]===io[1]&&e[2]===io[2]&&e[3]===io[3]}async ackAck(e){var i;e=e||{},e.timeout=e.timeout||this.timeout;const s=mt();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,m=!((i=c.options)!=null&&i.noAsyncTraces),p=new Sx(c.muxSubscriptions,this.msg.reply,{timeout:e.timeout},m);c.request(p);try{c.publish(this.msg.reply,pb,{reply:`${c.muxSubscriptions.baseInbox}${p.token}`})}catch(g){p.cancel(g)}try{await Promise.race([p.timer,p.deferred]),s.resolve(!0)}catch(g){p.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(pb)}nak(e){let s=z2;e&&(s=Ed().encode(`-NAK ${JSON.stringify({delay:dt(e)})}`)),this.doAck(s)}working(){this.doAck(io)}next(e,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=dt(s.expires));const o=er().encode(i),c=ia.concat(I2,H2,o),m=e?{reply:e}:void 0;this.msg.respond(c,m)}term(e=""){let s=$2;(e==null?void 0:e.length)>0&&(s=Ed().encode(`+TERM ${e}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const oO="1.30.3",lO="nats.ws";class cO{constructor(){j(this,"version");j(this,"lang");j(this,"closeError");j(this,"connected");j(this,"done");j(this,"socket");j(this,"options");j(this,"socketClosed");j(this,"encrypted");j(this,"peeked");j(this,"yields");j(this,"signal");j(this,"closedNotification");this.version=oO,this.lang=lO,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=mt(),this.closedNotification=mt()}async connect(e,s){const i=mt();if(s.tls)return i.reject(new ge("tls",fe.InvalidOption)),i;this.options=s;const o=e.src;if(s.wsFactory){const{socket:c,encrypted:m}=await s.wsFactory(e.src,s);this.socket=c,this.encrypted=m}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=c=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(c.data)),this.peeked){this.signal.resolve();return}const m=ia.concat(...this.yields),p=KE(m);if(p!==""){const g=w2.exec(p);if(!g){s.debug&&console.error("!!!",ac(m)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);v2(u,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(u){i.reject(u);return}}},this.socket.onclose=c=>{if(this.isDiscarded())return;this.socketClosed=!0;let m;this.done||(c.wasClean||(m=new Error(c.reason)),this._closed(m))},this.socket.onerror=c=>{if(this.isDiscarded())return;const m=c,p=new ge(m.message,fe.Unknown,new Error(m.error));i.reject(p)},i}disconnect(){this._closed(void 0,!0)}async _closed(e,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await aa(100);this.done=!0;try{this.socket.close(e?1002:1e3,e?e.message:void 0)}catch{}s&&this.closedNotification.resolve(e)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let s=0;s<e.length;s++)this.options.debug&&console.info(`> ${ac(e[s])}`),yield e[s];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=mt())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.isDiscarded())try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${ac(e)}`);return}catch(s){this.options.debug&&console.error(`!!! ${ac(e)}: ${s}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var e;this.done=!0;try{(e=this.socket)==null||e.close()}catch{}}}function uO(n,e){/^(.*:\/\/)(.*)/.test(n)||(typeof e=="boolean"?n=`${e===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(e=!1),o==="wss:"&&(e=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,m;const p=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":m=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":m=i.port||"443",c="wss:";break;default:m=i.port||e===!0?"443":"80",c=e===!0?"wss:":"ws:";break}return`${c}//${p}:${m}${g}${u}`}function fO(n={}){return HE({defaultPort:443,urlParseFn:uO,factory:()=>new cO}),ym.connect(n)}const hO=null,dO=null,Xt="lt.events";function Lx(n,e){const s=n.split("."),i=e.split(".");for(let o=0;o<i.length;o++){const c=i[o];if(c===">")return!0;if(o>=s.length||c!=="*"&&c!==s[o])return!1}return s.length===i.length}const oa=E.createContext({connected:!1,subscribe:()=>()=>{}});function qx(){const{connected:n}=E.useContext(oa);return{connected:n}}function An(n,e){const{subscribe:s}=E.useContext(oa),i=E.useRef(e);i.current=e,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function ks(n,e){const{subscribe:s}=E.useContext(oa),i=E.useRef(e);i.current=e;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const m=g=>i.current(g),p=c.map(g=>s(g,m));return()=>p.forEach(g=>g())},[s,c])}const Px=E.createContext({connected:!1,unavailable:!1,subscribe:()=>()=>{}});function mO(){const{connected:n,unavailable:e}=E.useContext(Px);return{connected:n,unavailable:e}}const pO=Ed();function yO({children:n,url:e,token:s,resolveCredentials:i,policy:o=yo,onReconnect:c,sessionKey:m}){const p=E.useRef(null),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(!1),_=E.useRef({url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c});_.current={url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c};const S=E.useRef(new Map),C=E.useRef(new Map),B=E.useCallback((te,M)=>{(async()=>{for await(const z of M)try{if(!Lx(z.subject,te))continue;const ae=JSON.parse(pO.decode(z.data)),F=S.current.get(te);if(!F)continue;for(const U of F)try{U(ae)}catch{}}catch{}})()},[]),q=E.useCallback(te=>{var z;const M=p.current;if(!(!M||(z=M.isClosed)!=null&&z.call(M)||C.current.has(te)))try{const ae=M.subscribe(te);C.current.set(te,ae),B(te,ae)}catch{}},[B]),ne=E.useCallback((te,M)=>{const z=S.current;return z.has(te)||z.set(te,new Set),z.get(te).add(M),q(te),()=>{const ae=z.get(te);if(ae&&(ae.delete(M),ae.size===0)){z.delete(te);const F=C.current.get(te);if(F){C.current.delete(te);try{F.unsubscribe()}catch{}}}}},[q]);return E.useEffect(()=>{let te=!1,M=!1,z=!1,ae=!1,F=0,U,D;v(!1);const X=()=>typeof document<"u"&&document.visibilityState==="hidden",W=async()=>{const{url:J,token:le,resolveCredentials:pe}=_.current;if(pe)return pe();const ye=J||hO;return ye?{kind:"ok",url:ye,token:le||dO||null}:{kind:"unavailable"}},he=(J=fE(F++,_.current.policy))=>{te||M||(U=setTimeout(Ae,J))},Se=J=>{J.closed().then(()=>{p.current===J&&(p.current=null,C.current.clear(),u(!1),he(Gg(_.current.policy)))})};async function Ae(){if(U=void 0,!(te||M||z||p.current)&&!X()){z=!0;try{const J=await W();if(te)return;if(J.kind==="session-ended"){M=!0,v(!0);return}if(J.kind==="unavailable"){he();return}const le=await fO({servers:J.url,token:J.token??void 0,reconnect:!1});if(te){le.close().catch(()=>{});return}p.current=le,F=0,u(!0),C.current.clear();for(const pe of S.current.keys())q(pe);ae&&(D=setTimeout(()=>{var pe,ye;return(ye=(pe=_.current).onReconnect)==null?void 0:ye.call(pe)},Gg(_.current.policy))),ae=!0,Se(le)}catch{te||he()}finally{z=!1}}}const H=()=>{te||M||z||p.current||X()||(U&&clearTimeout(U),F=0,Ae())};return document.addEventListener("visibilitychange",H),window.addEventListener("online",H),Ae(),()=>{te=!0,U&&clearTimeout(U),D&&clearTimeout(D),document.removeEventListener("visibilitychange",H),window.removeEventListener("online",H);for(const J of C.current.values())try{J.unsubscribe()}catch{}C.current.clear(),p.current&&(p.current.close().catch(()=>{}),p.current=null),u(!1)}},[q,m]),E.useEffect(()=>{if(g||x){b(!1);return}const te=setTimeout(()=>b(!0),o.noticeAfterMs);return()=>clearTimeout(te)},[g,x,o.noticeAfterMs]),h.jsx(Px.Provider,{value:{connected:g,unavailable:d,subscribe:ne},children:h.jsx(oa.Provider,{value:{connected:g,subscribe:ne},children:n})})}const ur=Object.create(null);ur.open="0";ur.close="1";ur.ping="2";ur.pong="3";ur.message="4";ur.upgrade="5";ur.noop="6";const iu=Object.create(null);Object.keys(ur).forEach(n=>{iu[ur[n]]=n});const Bd={type:"error",data:"parser error"},Bx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ux=typeof ArrayBuffer=="function",zx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,gm=({type:n,data:e},s,i)=>Bx&&e instanceof Blob?s?i(e):gb(e,i):Ux&&(e instanceof ArrayBuffer||zx(e))?s?i(e):gb(new Blob([e]),i):i(ur[n]+(e||"")),gb=(n,e)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];e("b"+(i||""))},s.readAsDataURL(n)};function bb(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let ad;function gO(n,e){if(Bx&&n.data instanceof Blob)return n.data.arrayBuffer().then(bb).then(e);if(Ux&&(n.data instanceof ArrayBuffer||zx(n.data)))return e(bb(n.data));gm(n,!1,s=>{ad||(ad=new TextEncoder),e(ad.encode(s))})}const xb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<xb.length;n++)xo[xb.charCodeAt(n)]=n;const bO=n=>{let e=n.length*.75,s=n.length,i,o=0,c,m,p,g;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const u=new ArrayBuffer(e),d=new Uint8Array(u);for(i=0;i<s;i+=4)c=xo[n.charCodeAt(i)],m=xo[n.charCodeAt(i+1)],p=xo[n.charCodeAt(i+2)],g=xo[n.charCodeAt(i+3)],d[o++]=c<<2|m>>4,d[o++]=(m&15)<<4|p>>2,d[o++]=(p&3)<<6|g&63;return u},xO=typeof ArrayBuffer=="function",bm=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ix(n,e)};const s=n.charAt(0);return s==="b"?{type:"message",data:vO(n.substring(1),e)}:iu[s]?n.length>1?{type:iu[s],data:n.substring(1)}:{type:iu[s]}:Bd},vO=(n,e)=>{if(xO){const s=bO(n);return Ix(s,e)}else return{base64:!0,data:n}},Ix=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},$x="",_O=(n,e)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,m)=>{gm(c,!1,p=>{i[m]=p,++o===s&&e(i.join($x))})})},wO=(n,e)=>{const s=n.split($x),i=[];for(let o=0;o<s.length;o++){const c=bm(s[o],e);if(i.push(c),c.type==="error")break}return i};function SO(){return new TransformStream({transform(n,e){gO(n,s=>{const i=s.length;let o;if(i<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,i);else if(i<65536){o=new Uint8Array(3);const c=new DataView(o.buffer);c.setUint8(0,126),c.setUint16(1,i)}else{o=new Uint8Array(9);const c=new DataView(o.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(o[0]|=128),e.enqueue(o),e.enqueue(s)})}})}let od;function uc(n){return n.reduce((e,s)=>e+s.length,0)}function fc(n,e){if(n[0].length===e)return n.shift();const s=new Uint8Array(e);let i=0;for(let o=0;o<e;o++)s[o]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),s}function EO(n,e){od||(od=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(m,p){for(s.push(m);;){if(i===0){if(uc(s)<1)break;const g=fc(s,1);c=(g[0]&128)===128,o=g[0]&127,o<126?i=3:o===126?i=1:i=2}else if(i===1){if(uc(s)<2)break;const g=fc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(uc(s)<8)break;const g=fc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){p.enqueue(Bd);break}o=d*Math.pow(2,32)+u.getUint32(4),i=3}else{if(uc(s)<o)break;const g=fc(s,o);p.enqueue(bm(c?g:od.decode(g),e)),i=0}if(o===0||o>n){p.enqueue(Bd);break}}}})}const Hx=4;function Tt(n){if(n)return OO(n)}function OO(n){for(var e in Tt.prototype)n[e]=Tt.prototype[e];return n}Tt.prototype.on=Tt.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};Tt.prototype.once=function(n,e){function s(){this.off(n,s),e.apply(this,arguments)}return s.fn=e,this.on(n,s),this};Tt.prototype.off=Tt.prototype.removeListener=Tt.prototype.removeAllListeners=Tt.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,o=0;o<s.length;o++)if(i=s[o],i===e||i.fn===e){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};Tt.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,e)}return this};Tt.prototype.emitReserved=Tt.prototype.emit;Tt.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Tt.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Nu=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,s)=>s(e,0),$n=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),AO="arraybuffer";function Fx(n,...e){return e.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const jO=$n.setTimeout,kO=$n.clearTimeout;function Tu(n,e){e.useNativeTimers?(n.setTimeoutFn=jO.bind($n),n.clearTimeoutFn=kO.bind($n)):(n.setTimeoutFn=$n.setTimeout.bind($n),n.clearTimeoutFn=$n.clearTimeout.bind($n))}const NO=1.33;function TO(n){return typeof n=="string"?CO(n):Math.ceil((n.byteLength||n.size)*NO)}function CO(n){let e=0,s=0;for(let i=0,o=n.length;i<o;i++)e=n.charCodeAt(i),e<128?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(i++,s+=4);return s}function Gx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function MO(n){let e="";for(let s in n)n.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return e}function RO(n){let e={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");e[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return e}class DO extends Error{constructor(e,s,i){super(e),this.description=s,this.context=i,this.type="TransportError"}}class xm extends Tt{constructor(e){super(),this.writable=!1,Tu(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,s,i){return super.emitReserved("error",new DO(e,s,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const s=bm(e,this.socket.binaryType);this.onPacket(s)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,s={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const s=MO(e);return s.length?"?"+s:""}}class LO extends xm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const s=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||s()})),this.writable||(i++,this.once("drain",function(){--i||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const s=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};wO(e,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,_O(e,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Gx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(e,s)}}let Vx=!1;try{Vx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const qO=Vx;function PO(){}class BO extends LO{constructor(e){if(super(e),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,s){const i=this.request({method:"POST",data:e});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=e}}class cr extends Tt{constructor(e,s,i){super(),this.createRequest=e,Tu(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var e;const s=Fx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&i.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var o;i.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=cr.requestsCount++,cr.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=PO,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete cr.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}cr.requestsCount=0;cr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",vb);else if(typeof addEventListener=="function"){const n="onpagehide"in $n?"pagehide":"unload";addEventListener(n,vb,!1)}}function vb(){for(let n in cr.requests)cr.requests.hasOwnProperty(n)&&cr.requests[n].abort()}const UO=(function(){const n=Yx({xdomain:!1});return n&&n.responseType!==null})();class zO extends BO{constructor(e){super(e);const s=e&&e.forceBase64;this.supportsBinary=UO&&!s}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new cr(Yx,this.uri(),e)}}function Yx(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||qO))return new XMLHttpRequest}catch{}if(!e)try{return new $n[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Kx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class IO extends xm{get name(){return"websocket"}doOpen(){const e=this.uri(),s=this.opts.protocols,i=Kx?{}:Fx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,s,i)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;gm(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Gx()),this.supportsBinary||(s.b64=1),this.createUri(e,s)}}const ld=$n.WebSocket||$n.MozWebSocket;class $O extends IO{createSocket(e,s,i){return Kx?new ld(e,s,i):s?new ld(e,s):new ld(e)}doWrite(e,s){this.ws.send(s)}}class HO extends xm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const s=EO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(s).getReader(),o=SO();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:p,value:g})=>{p||(this.onPacket(g),c())}).catch(p=>{})};c();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;this._writer.write(i).then(()=>{o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const FO={websocket:$O,webtransport:HO,polling:zO},GO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,VO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ud(n){if(n.length>8e3)throw"URI too long";const e=n,s=n.indexOf("["),i=n.indexOf("]");s!=-1&&i!=-1&&(n=n.substring(0,s)+n.substring(s,i).replace(/:/g,";")+n.substring(i,n.length));let o=GO.exec(n||""),c={},m=14;for(;m--;)c[VO[m]]=o[m]||"";return s!=-1&&i!=-1&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=YO(c,c.path),c.queryKey=KO(c,c.query),c}function YO(n,e){const s=/\/{2,9}/g,i=e.replace(s,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function KO(n,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const zd=typeof addEventListener=="function"&&typeof removeEventListener=="function",au=[];zd&&addEventListener("offline",()=>{au.forEach(n=>n())},!1);class Es extends Tt{constructor(e,s){if(super(),this.binaryType=AO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(s=e,e=null),e){const i=Ud(e);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=Ud(s.host).host);Tu(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(i=>{const o=i.prototype.name;this.transports.push(o),this._transportsByName[o]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=RO(this.opts.query)),zd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},au.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const s=Object.assign({},this.opts.query);s.EIO=Hx,s.transport=e,this.id&&(s.sid=this.id);const i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Es.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(e);s.open(),this.setTransport(s)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",Es.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const s=new Error("server error");s.code=e.data,this._onError(s);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){const o=this.writeBuffer[i].data;if(o&&(s+=TO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Nu(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,s,i){return this._sendPacket("message",e,s,i),this}send(e,s,i){return this._sendPacket("message",e,s,i),this}_sendPacket(e,s,i,o){if(typeof s=="function"&&(o=s,s=void 0),typeof i=="function"&&(o=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const c={type:e,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),e()},i=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(Es.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),zd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=au.indexOf(this._offlineEventListener);i!==-1&&au.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,s),this.writeBuffer=[],this._prevBufferLen=0}}}Es.protocol=Hx;class JO extends Es{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let s=this.createTransport(e),i=!1;Es.priorWebsocketSuccess=!1;const o=()=>{i||(s.send([{type:"ping",data:"probe"}]),s.once("packet",b=>{if(!i)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Es.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(d(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=s.name,this.emitReserved("upgradeError",x)}}))};function c(){i||(i=!0,d(),s.close(),s=null)}const m=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function p(){m("transport closed")}function g(){m("socket closed")}function u(b){s&&b.name!==s.name&&c()}const d=()=>{s.removeListener("open",o),s.removeListener("error",m),s.removeListener("close",p),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",m),s.once("close",p),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const s=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&s.push(e[i]);return s}}let QO=class extends JO{constructor(e,s={}){const i=typeof e=="object"?e:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>FO[o]).filter(o=>!!o)),super(e,i)}};function XO(n,e="",s){let i=n;s=s||typeof location<"u"&&location,n==null&&(n=s.protocol+"//"+s.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=s.protocol+n:n=s.host+n),/^(https?|wss?):\/\//.test(n)||(typeof s<"u"?n=s.protocol+"//"+n:n="https://"+n),i=Ud(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const c=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+c+":"+i.port+e,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const WO=typeof ArrayBuffer=="function",ZO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Jx=Object.prototype.toString,eA=typeof Blob=="function"||typeof Blob<"u"&&Jx.call(Blob)==="[object BlobConstructor]",tA=typeof File=="function"||typeof File<"u"&&Jx.call(File)==="[object FileConstructor]";function vm(n){return WO&&(n instanceof ArrayBuffer||ZO(n))||eA&&n instanceof Blob||tA&&n instanceof File}function ou(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(ou(n[s]))return!0;return!1}if(vm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return ou(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&ou(n[s]))return!0;return!1}function nA(n){const e=[],s=n.data,i=n;return i.data=Id(s,e),i.attachments=e.length,{packet:i,buffers:e}}function Id(n,e){if(!n)return n;if(vm(n)){const s={_placeholder:!0,num:e.length};return e.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Id(n[i],e);return s}else if(typeof n=="object"&&!(n instanceof Date)){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=Id(n[i],e));return s}return n}function rA(n,e){return n.data=$d(n.data,e),delete n.attachments,n}function $d(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=$d(n[s],e);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=$d(n[s],e));return n}const sA=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ve;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ve||(Ve={}));class iA{constructor(e){this.replacer=e}encode(e){return(e.type===Ve.EVENT||e.type===Ve.ACK)&&ou(e)?this.encodeAsBinary({type:e.type===Ve.EVENT?Ve.BINARY_EVENT:Ve.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let s=""+e.type;return(e.type===Ve.BINARY_EVENT||e.type===Ve.BINARY_ACK)&&(s+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(s+=e.nsp+","),e.id!=null&&(s+=e.id),e.data!=null&&(s+=JSON.stringify(e.data,this.replacer)),s}encodeAsBinary(e){const s=nA(e),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class _m extends Tt{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let s;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(e);const i=s.type===Ve.BINARY_EVENT;i||s.type===Ve.BINARY_ACK?(s.type=i?Ve.EVENT:Ve.ACK,this.reconstructor=new aA(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(vm(e)||e.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(e),s&&(this.reconstructor=null,super.emitReserved("decoded",s));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let s=0;const i={type:Number(e.charAt(0))};if(Ve[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Ve.BINARY_EVENT||i.type===Ve.BINARY_ACK){const c=s+1;for(;e.charAt(++s)!=="-"&&s!=e.length;);const m=e.substring(c,s);if(m!=Number(m)||e.charAt(s)!=="-")throw new Error("Illegal attachments");const p=Number(m);if(!oA(p)||p<0)throw new Error("Illegal attachments");if(p>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=p}if(e.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(e.charAt(s)===","||s===e.length););i.nsp=e.substring(c,s)}else i.nsp="/";const o=e.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const m=e.charAt(s);if(m==null||Number(m)!=m){--s;break}if(s===e.length)break}i.id=Number(e.substring(c,s+1))}if(e.charAt(++s)){const c=this.tryParse(e.substr(s));if(_m.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,s){switch(e){case Ve.CONNECT:return _b(s);case Ve.DISCONNECT:return s===void 0;case Ve.CONNECT_ERROR:return typeof s=="string"||_b(s);case Ve.EVENT:case Ve.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&sA.indexOf(s[0])===-1);case Ve.ACK:case Ve.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class aA{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const s=rA(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const oA=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function _b(n){return Object.prototype.toString.call(n)==="[object Object]"}const lA=Object.freeze(Object.defineProperty({__proto__:null,Decoder:_m,Encoder:iA,get PacketType(){return Ve}},Symbol.toStringTag,{value:"Module"}));function Wn(n,e,s){return n.on(e,s),function(){n.off(e,s)}}const cA=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Qx extends Tt{constructor(e,s,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Wn(e,"open",this.onopen.bind(this)),Wn(e,"packet",this.onpacket.bind(this)),Wn(e,"error",this.onerror.bind(this)),Wn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...s){var i,o,c;if(cA.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(s.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const m={type:Ve.EVENT,data:s};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const d=this.ids++,b=s.pop();this._registerAckCallback(d,b),m.id=d}const p=(o=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!p||(g?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(e,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[e]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===e&&this.sendBuffer.splice(p,1);s.call(this,new Error("operation has timed out"))},o),m=(...p)=>{this.io.clearTimeoutFn(c),s.apply(this,p)};m.withError=!0,this.acks[e]=m}emitWithAck(e,...s){return new Promise((i,o)=>{const c=(m,p)=>m?o(m):i(p);c.withError=!0,s.push(c),this.emit(e,...s)})}_addToQueue(e){let s;typeof e[e.length-1]=="function"&&(s=e.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...c)=>(this._queue[0],o!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!e||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Ve.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(i=>String(i.id)===e)){const i=this.acks[e];delete this.acks[e],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Ve.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ve.EVENT:case Ve.BINARY_EVENT:this.onevent(e);break;case Ve.ACK:case Ve.BINARY_ACK:this.onack(e);break;case Ve.DISCONNECT:this.ondisconnect();break;case Ve.CONNECT_ERROR:this.destroy();const i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){const s=e.data||[];e.id!=null&&s.push(this.ack(e.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:Ve.ACK,id:e,data:o}))}}onack(e){const s=this.acks[e.id];typeof s=="function"&&(delete this.acks[e.id],s.withError&&e.data.unshift(null),s.apply(this,e.data))}onconnect(e,s){this.id=e,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ve.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,e.data)}}}function la(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}la.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};la.prototype.reset=function(){this.attempts=0};la.prototype.setMin=function(n){this.ms=n};la.prototype.setMax=function(n){this.max=n};la.prototype.setJitter=function(n){this.jitter=n};class Hd extends Tt{constructor(e,s){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(s=e,e=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,Tu(this,s),this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor((i=s.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new la({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=e;const o=s.parser||lA;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var s;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(s=this.backoff)===null||s===void 0||s.setMin(e),this)}randomizationFactor(e){var s;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(s=this.backoff)===null||s===void 0||s.setJitter(e),this)}reconnectionDelayMax(e){var s;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(s=this.backoff)===null||s===void 0||s.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new QO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Wn(s,"open",function(){i.onopen(),e&&e()}),c=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),e?e(p):this.maybeReconnectOnOpen()},m=Wn(s,"error",c);if(this._timeout!==!1){const p=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},p);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(m),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Wn(e,"ping",this.onping.bind(this)),Wn(e,"data",this.ondata.bind(this)),Wn(e,"error",this.onerror.bind(this)),Wn(e,"close",this.onclose.bind(this)),Wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(s){this.onclose("parse error",s)}}ondecoded(e){Nu(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,s){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new Qx(this,e,s),this.nsps[e]=i),i}_destroy(e){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(e){const s=this.encoder.encode(e);for(let i=0;i<s.length;i++)this.engine.write(s[i],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const s=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const ao={};function lu(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const s=XO(n,e.path||"/socket.io"),i=s.source,o=s.id,c=s.path,m=ao[o]&&c in ao[o].nsps,p=e.forceNew||e["force new connection"]||e.multiplex===!1||m;let g;return p?g=new Hd(i,e):(ao[o]||(ao[o]=new Hd(i,e)),g=ao[o]),s.query&&!e.query&&(e.query=s.queryKey),g.socket(s.path,e)}Object.assign(lu,{Manager:Hd,Socket:Qx,io:lu,connect:lu});const uA=E.createContext({connected:!1,subscribe:()=>()=>{}});function fA({children:n}){const{isAuthenticated:e}=qt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),m=E.useCallback((g,u)=>{var b;const d=c.current;return d.has(g)||(d.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),d.get(g).add(u),()=>{var v;const x=d.get(g);x&&(x.delete(u),x.size===0&&(d.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),p=E.useCallback((g,u)=>{for(const[d,b]of c.current)if(Lx(g,d))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!e)return;const g=lu({path:`${Vt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const d=wd();u(d?{token:d}:{})}});return s.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),o(!0);for(const u of c.current.keys())g.emit("lt.subscribe",u)}),g.on("disconnect",u=>{console.log("[lt-socketio] disconnected:",u),o(!1)}),g.on("connect_error",u=>{console.warn("[lt-socketio] connect error:",u.message),o(!1)}),g.onAny((u,d)=>{if(u.startsWith("lt."))try{const b=typeof d=="string"?JSON.parse(d):d;p(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[p,e]),h.jsx(uA.Provider,{value:{connected:i,subscribe:m},children:h.jsx(oa.Provider,{value:{connected:i,subscribe:m},children:n})})}function hA({children:n}){const{isAuthenticated:e}=qt(),s=Pe(),[i,o]=E.useState(null),[c,m]=E.useState({url:null,policy:Vg(null)});E.useEffect(()=>{let u=!1;async function d(){var b;try{console.log("[lt-transport] detecting event transport...");const x=await lm(),v=(b=x==null?void 0:x.events)==null?void 0:b.transport;console.log("[lt-transport] server reports:",v),u||(v==="nats"&&m({url:x.events.natsWsUrl??null,policy:Vg(x.events.reconnect)}),o(v==="nats"?"nats":"socketio"))}catch(x){console.warn("[lt-transport] settings fetch error, falling back to socketio",x),u||o("socketio")}}return d(),()=>{u=!0}},[e]);const p=E.useCallback(()=>uE(c.url),[c.url]),g=E.useCallback(()=>{s.invalidateQueries({refetchType:"active"})},[s]);return i==="nats"?h.jsx(yO,{resolveCredentials:p,policy:c.policy,onReconnect:g,sessionKey:e,children:n}):i==="socketio"?h.jsx(fA,{children:n}):h.jsx(h.Fragment,{children:n})}const wm="lt_view_as",Sm="lt_ai_override",Fd="lt_graph_enabled",Gd="lt_infrastructure_enabled",Em="lt_scan_override";function Xx(){try{const n=localStorage.getItem(Sm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function dA(n){try{localStorage.setItem(Sm,String(n))}catch{}}function mA(){try{localStorage.removeItem(Sm)}catch{}}function Om(){try{const n=localStorage.getItem(wm);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function pA(n){try{localStorage.setItem(wm,n)}catch{}window.location.reload()}function Vd(){try{localStorage.removeItem(wm)}catch{}window.location.reload()}function Wx(){try{return localStorage.getItem(Fd)==="true"}catch{return!1}}function yA(n){try{n?localStorage.setItem(Fd,"true"):localStorage.removeItem(Fd)}catch{}}function Zx(){try{return localStorage.getItem(Gd)==="true"}catch{return!1}}function gA(n){try{n?localStorage.setItem(Gd,"true"):localStorage.removeItem(Gd)}catch{}}function ev(){try{const n=localStorage.getItem(Em);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function bA(n){try{localStorage.setItem(Em,String(n))}catch{}}function xA(){try{localStorage.removeItem(Em)}catch{}}function tv(){const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=qt(),i=Om(),o=n||s("engineer"),c=e("admin"),m=n||e("admin"),p=i?!1:o,g=i?i==="admin"||i==="engineer":c,u=i?i==="admin":m;return{isBuilder:p,isOps:g,canBulk:u,canAdminister:u,viewAs:i,realIsBuilder:o}}function nv(){var u;const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=qt(),{data:i}=Hn(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":e("admin")?"admin":s("engineer")?"engineer":"operator",m=Om(),p=m==="admin"||m==="engineer"||m==="operator"?m:null,g=p??c;return{tier:g,realTier:c,viewAs:p,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}const Am=E.createContext(null);function Cu(){const n=E.useContext(Am);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function vA(){var n;return((n=E.useContext(Am))==null?void 0:n.identity)??null}function _A({children:n}){const[e,s]=E.useState(null),i=E.useRef(e);i.current=e,E.useEffect(()=>{if(!(e!=null&&e.expiresAt))return;const d=new Date(e.expiresAt).getTime()-Date.now();if(d<=0){s(null);return}const b=setTimeout(()=>s(null),d);return()=>clearTimeout(b)},[e]);const o=E.useCallback(d=>{var x;if(!d.actingToken||!d.actor)return null;const b=((x=i.current)==null?void 0:x.actingToken)??null;return s({actingToken:d.actingToken,actorId:d.actor.id,displayName:d.actor.displayName,expiresAt:d.expiresAt??null,subjectScoped:d.grantScope==="subject"}),b},[]),c=E.useCallback(()=>s(null),[]),m=E.useCallback((d,b)=>{const x=i.current;b===0&&(x==null?void 0:x.actingToken)===d&&s(null)},[]),p=E.useCallback((d,b)=>{const x=i.current;if(!x||x.actingToken!==d||!b.acting)return;const{consumed:v,remaining:_,bound:S}=b.acting;(v&&_===0||S&&b.clearSubject)&&s(null)},[]);E.useEffect(()=>(Ig(()=>{var d;return((d=i.current)==null?void 0:d.actingToken)??null}),Hg(c),$g(m),()=>{Ig(null),Hg(null),$g(null)}),[c,m]);const g=E.useCallback(()=>{var b;const d=(b=i.current)==null?void 0:b.expiresAt;return d?Math.max(0,Math.floor((new Date(d).getTime()-Date.now())/1e3)):0},[]),u=E.useMemo(()=>({identity:e,prime:o,clear:c,settle:p,remainingSeconds:g}),[e,o,c,p,g]);return h.jsx(Am.Provider,{value:u,children:n})}function wA(){const{user:n}=qt(),{identity:e}=Cu(),s=n==null?void 0:n.userId,i=e==null?void 0:e.actorId,o=E.useCallback(c=>!!c&&(c===i||c===s),[i,s]);return{viewerId:i??s,isViewer:o}}function rv(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function fr(n={}){const e=n.role?rv(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Xt}.system.escalation.${e}.${s}.${i}`}function Yd(n){return n.verbs.map(e=>fr({role:n.role,verb:e}))}function jm(n){const{user:e,isSuperAdmin:s,hasRoleType:i}=qt(),o=s||i("admin"),c=((e==null?void 0:e.roles)??[]).map(p=>p.role).sort().join(","),m=(n??[]).join(",");return E.useMemo(()=>{const p=m?m.split(","):null;return o||!c?p?Yd({verbs:p}):[fr({})]:c.split(",").flatMap(g=>p?Yd({role:g,verbs:p}):[fr({role:g})])},[o,c,m])}const Kd="/escalations/detail/";function SA(n){return n.startsWith(Kd)&&n.slice(Kd.length).split("/")[0]||void 0}function EA(){const{isViewer:n}=wA(),e=ni(),s=en(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n);o.current=n;const c=E.useCallback(m=>{var b,x,v;if((m==null?void 0:m.assignedAtCreation)!==!0)return;const p=(m==null?void 0:m.escalationId)??((b=m==null?void 0:m.data)==null?void 0:b.id),g=(x=m==null?void 0:m.data)==null?void 0:x.assigned_to,u=(v=m==null?void 0:m.data)==null?void 0:v.parent_id;if(!p||!o.current(g)||!u||u!==SA(i.current))return;const d=`${Kd}${p}`;i.current!==d&&e(d)},[e]);ks(jm(["claimed"]),c)}const sv=6048e5,OA=864e5,wb=6e4,Sb=525600,Eb=43200,Ob=1440,Ab=Symbol.for("constructDateFrom");function Br(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&Ab in n?n[Ab](e):n instanceof Date?new n.constructor(e):new Date(e)}function kn(n,e){return Br(e||n,n)}let AA={};function Lo(){return AA}function No(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.weekStartsOn)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=kn(n,e==null?void 0:e.in),c=o.getDay(),m=(c<i?7:0)+c-i;return o.setDate(o.getDate()-m),o.setHours(0,0,0,0),o}function bu(n,e){return No(n,{...e,weekStartsOn:1})}function iv(n,e){const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),m=Br(s,0);m.setFullYear(i,0,4),m.setHours(0,0,0,0);const p=bu(m);return s.getTime()>=c.getTime()?i+1:s.getTime()>=p.getTime()?i:i-1}function xu(n){const e=kn(n),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+n-+s}function av(n,...e){const s=Br.bind(null,n||e.find(i=>typeof i=="object"));return e.map(s)}function jb(n,e){const s=kn(n,e==null?void 0:e.in);return s.setHours(0,0,0,0),s}function jA(n,e,s){const[i,o]=av(s==null?void 0:s.in,n,e),c=jb(i),m=jb(o),p=+c-xu(c),g=+m-xu(m);return Math.round((p-g)/OA)}function kA(n,e){const s=iv(n,e),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function NA(n,e){const s=+kn(n)-+kn(e);return s<0?-1:s>0?1:s}function TA(n){return Br(n,Date.now())}function CA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function MA(n){return!(!CA(n)&&typeof n!="number"||isNaN(+kn(n)))}function RA(n){return e=>{const i=(n?Math[n]:Math.trunc)(e);return i===0?0:i}}function DA(n,e){const s=kn(n,e==null?void 0:e.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const LA={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"}},qA=(n,e,s)=>{let i;const o=LA[n];return typeof o=="string"?i=o:e===1?i=o.one:i=o.other.replace("{{count}}",e.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function cd(n){return(e={})=>{const s=e.width?String(e.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const PA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},BA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},UA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zA={date:cd({formats:PA,defaultWidth:"full"}),time:cd({formats:BA,defaultWidth:"full"}),dateTime:cd({formats:UA,defaultWidth:"full"})},IA={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$A=(n,e,s,i)=>IA[n];function oo(n){return(e,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const m=n.defaultFormattingWidth||n.defaultWidth,p=s!=null&&s.width?String(s.width):m;o=n.formattingValues[p]||n.formattingValues[m]}else{const m=n.defaultWidth,p=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[p]||n.values[m]}const c=n.argumentCallback?n.argumentCallback(e):e;return o[c]}}const HA={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},FA={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},GA={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"]},VA={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"]},YA={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"}},KA={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"}},JA=(n,e)=>{const s=Number(n),i=s%100;if(i>20||i<10)switch(i%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},QA={ordinalNumber:JA,era:oo({values:HA,defaultWidth:"wide"}),quarter:oo({values:FA,defaultWidth:"wide",argumentCallback:n=>n-1}),month:oo({values:GA,defaultWidth:"wide"}),day:oo({values:VA,defaultWidth:"wide"}),dayPeriod:oo({values:YA,defaultWidth:"wide",formattingValues:KA,defaultFormattingWidth:"wide"})};function lo(n){return(e,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=e.match(o);if(!c)return null;const m=c[0],p=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(p)?WA(p,b=>b.test(m)):XA(p,b=>b.test(m));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const d=e.slice(m.length);return{value:u,rest:d}}}function XA(n,e){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&e(n[s]))return s}function WA(n,e){for(let s=0;s<n.length;s++)if(e(n[s]))return s}function ZA(n){return(e,s={})=>{const i=e.match(n.matchPattern);if(!i)return null;const o=i[0],c=e.match(n.parsePattern);if(!c)return null;let m=n.valueCallback?n.valueCallback(c[0]):c[0];m=s.valueCallback?s.valueCallback(m):m;const p=e.slice(o.length);return{value:m,rest:p}}}const ej=/^(\d+)(th|st|nd|rd)?/i,tj=/\d+/i,nj={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},rj={any:[/^b/i,/^(a|c)/i]},sj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ij={any:[/1/i,/2/i,/3/i,/4/i]},aj={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},oj={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]},lj={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},cj={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]},uj={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},fj={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}},hj={ordinalNumber:ZA({matchPattern:ej,parsePattern:tj,valueCallback:n=>parseInt(n,10)}),era:lo({matchPatterns:nj,defaultMatchWidth:"wide",parsePatterns:rj,defaultParseWidth:"any"}),quarter:lo({matchPatterns:sj,defaultMatchWidth:"wide",parsePatterns:ij,defaultParseWidth:"any",valueCallback:n=>n+1}),month:lo({matchPatterns:aj,defaultMatchWidth:"wide",parsePatterns:oj,defaultParseWidth:"any"}),day:lo({matchPatterns:lj,defaultMatchWidth:"wide",parsePatterns:cj,defaultParseWidth:"any"}),dayPeriod:lo({matchPatterns:uj,defaultMatchWidth:"any",parsePatterns:fj,defaultParseWidth:"any"})},ov={code:"en-US",formatDistance:qA,formatLong:zA,formatRelative:$A,localize:QA,match:hj,options:{weekStartsOn:0,firstWeekContainsDate:1}};function dj(n,e){const s=kn(n,e==null?void 0:e.in);return jA(s,DA(s))+1}function mj(n,e){const s=kn(n,e==null?void 0:e.in),i=+bu(s)-+kA(s);return Math.round(i/sv)+1}function lv(n,e){var d,b,x,v;const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Lo(),c=(e==null?void 0:e.firstWeekContainsDate)??((b=(d=e==null?void 0:e.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,m=Br((e==null?void 0:e.in)||n,0);m.setFullYear(i+1,0,c),m.setHours(0,0,0,0);const p=No(m,e),g=Br((e==null?void 0:e.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=No(g,e);return+s>=+p?i+1:+s>=+u?i:i-1}function pj(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.firstWeekContainsDate)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=lv(n,e),c=Br((e==null?void 0:e.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),No(c,e)}function yj(n,e){const s=kn(n,e==null?void 0:e.in),i=+No(s,e)-+pj(s,e);return Math.round(i/sv)+1}function tt(n,e){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(e,"0");return s+i}const ys={y(n,e){const s=n.getFullYear(),i=s>0?s:1-s;return tt(e==="yy"?i%100:i,e.length)},M(n,e){const s=n.getMonth();return e==="M"?String(s+1):tt(s+1,2)},d(n,e){return tt(n.getDate(),e.length)},a(n,e){const s=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(n,e){return tt(n.getHours()%12||12,e.length)},H(n,e){return tt(n.getHours(),e.length)},m(n,e){return tt(n.getMinutes(),e.length)},s(n,e){return tt(n.getSeconds(),e.length)},S(n,e){const s=e.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return tt(o,e.length)}},Hi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},kb={G:function(n,e,s){const i=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return s.era(i,{width:"abbreviated"});case"GGGGG":return s.era(i,{width:"narrow"});case"GGGG":default:return s.era(i,{width:"wide"})}},y:function(n,e,s){if(e==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ys.y(n,e)},Y:function(n,e,s,i){const o=lv(n,i),c=o>0?o:1-o;if(e==="YY"){const m=c%100;return tt(m,2)}return e==="Yo"?s.ordinalNumber(c,{unit:"year"}):tt(c,e.length)},R:function(n,e){const s=iv(n);return tt(s,e.length)},u:function(n,e){const s=n.getFullYear();return tt(s,e.length)},Q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(i);case"QQ":return tt(i,2);case"Qo":return s.ordinalNumber(i,{unit:"quarter"});case"QQQ":return s.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(i,{width:"wide",context:"formatting"})}},q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(i);case"qq":return tt(i,2);case"qo":return s.ordinalNumber(i,{unit:"quarter"});case"qqq":return s.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(i,{width:"wide",context:"standalone"})}},M:function(n,e,s){const i=n.getMonth();switch(e){case"M":case"MM":return ys.M(n,e);case"Mo":return s.ordinalNumber(i+1,{unit:"month"});case"MMM":return s.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(i,{width:"wide",context:"formatting"})}},L:function(n,e,s){const i=n.getMonth();switch(e){case"L":return String(i+1);case"LL":return tt(i+1,2);case"Lo":return s.ordinalNumber(i+1,{unit:"month"});case"LLL":return s.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(i,{width:"wide",context:"standalone"})}},w:function(n,e,s,i){const o=yj(n,i);return e==="wo"?s.ordinalNumber(o,{unit:"week"}):tt(o,e.length)},I:function(n,e,s){const i=mj(n);return e==="Io"?s.ordinalNumber(i,{unit:"week"}):tt(i,e.length)},d:function(n,e,s){return e==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ys.d(n,e)},D:function(n,e,s){const i=dj(n);return e==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):tt(i,e.length)},E:function(n,e,s){const i=n.getDay();switch(e){case"E":case"EE":case"EEE":return s.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(i,{width:"short",context:"formatting"});case"EEEE":default:return s.day(i,{width:"wide",context:"formatting"})}},e:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"e":return String(c);case"ee":return tt(c,2);case"eo":return s.ordinalNumber(c,{unit:"day"});case"eee":return s.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(o,{width:"short",context:"formatting"});case"eeee":default:return s.day(o,{width:"wide",context:"formatting"})}},c:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"c":return String(c);case"cc":return tt(c,e.length);case"co":return s.ordinalNumber(c,{unit:"day"});case"ccc":return s.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(o,{width:"narrow",context:"standalone"});case"cccccc":return s.day(o,{width:"short",context:"standalone"});case"cccc":default:return s.day(o,{width:"wide",context:"standalone"})}},i:function(n,e,s){const i=n.getDay(),o=i===0?7:i;switch(e){case"i":return String(o);case"ii":return tt(o,e.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(i,{width:"short",context:"formatting"});case"iiii":default:return s.day(i,{width:"wide",context:"formatting"})}},a:function(n,e,s){const o=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(n,e,s){const i=n.getHours();let o;switch(i===12?o=Hi.noon:i===0?o=Hi.midnight:o=i/12>=1?"pm":"am",e){case"b":case"bb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(n,e,s){const i=n.getHours();let o;switch(i>=17?o=Hi.evening:i>=12?o=Hi.afternoon:i>=4?o=Hi.morning:o=Hi.night,e){case"B":case"BB":case"BBB":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(n,e,s){if(e==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ys.h(n,e)},H:function(n,e,s){return e==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ys.H(n,e)},K:function(n,e,s){const i=n.getHours()%12;return e==="Ko"?s.ordinalNumber(i,{unit:"hour"}):tt(i,e.length)},k:function(n,e,s){let i=n.getHours();return i===0&&(i=24),e==="ko"?s.ordinalNumber(i,{unit:"hour"}):tt(i,e.length)},m:function(n,e,s){return e==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ys.m(n,e)},s:function(n,e,s){return e==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ys.s(n,e)},S:function(n,e){return ys.S(n,e)},X:function(n,e,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(e){case"X":return Tb(i);case"XXXX":case"XX":return Zs(i);case"XXXXX":case"XXX":default:return Zs(i,":")}},x:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"x":return Tb(i);case"xxxx":case"xx":return Zs(i);case"xxxxx":case"xxx":default:return Zs(i,":")}},O:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Nb(i,":");case"OOOO":default:return"GMT"+Zs(i,":")}},z:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Nb(i,":");case"zzzz":default:return"GMT"+Zs(i,":")}},t:function(n,e,s){const i=Math.trunc(+n/1e3);return tt(i,e.length)},T:function(n,e,s){return tt(+n,e.length)}};function Nb(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=Math.trunc(i/60),c=i%60;return c===0?s+String(o):s+String(o)+e+tt(c,2)}function Tb(n,e){return n%60===0?(n>0?"-":"+")+tt(Math.abs(n)/60,2):Zs(n,e)}function Zs(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=tt(Math.trunc(i/60),2),c=tt(i%60,2);return s+o+e+c}const Cb=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},cv=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},gj=(n,e)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return Cb(n,e);let c;switch(i){case"P":c=e.dateTime({width:"short"});break;case"PP":c=e.dateTime({width:"medium"});break;case"PPP":c=e.dateTime({width:"long"});break;case"PPPP":default:c=e.dateTime({width:"full"});break}return c.replace("{{date}}",Cb(i,e)).replace("{{time}}",cv(o,e))},bj={p:cv,P:gj},xj=/^D+$/,vj=/^Y+$/,_j=["D","DD","YY","YYYY"];function wj(n){return xj.test(n)}function Sj(n){return vj.test(n)}function Ej(n,e,s){const i=Oj(n,e,s);if(console.warn(i),_j.includes(n))throw new RangeError(i)}function Oj(n,e,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Aj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,jj=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,kj=/^'([^]*?)'?$/,Nj=/''/g,Tj=/[a-zA-Z]/;function Cj(n,e,s){var d,b,x,v;const i=Lo(),o=i.locale??ov,c=i.firstWeekContainsDate??((b=(d=i.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??1,m=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,p=kn(n,s==null?void 0:s.in);if(!MA(p))throw new RangeError("Invalid time value");let g=e.match(jj).map(_=>{const S=_[0];if(S==="p"||S==="P"){const C=bj[S];return C(_,o.formatLong)}return _}).join("").match(Aj).map(_=>{if(_==="''")return{isToken:!1,value:"'"};const S=_[0];if(S==="'")return{isToken:!1,value:Mj(_)};if(kb[S])return{isToken:!0,value:_};if(S.match(Tj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:_}});o.localize.preprocessor&&(g=o.localize.preprocessor(p,g));const u={firstWeekContainsDate:c,weekStartsOn:m,locale:o};return g.map(_=>{if(!_.isToken)return _.value;const S=_.value;(Sj(S)||wj(S))&&Ej(S,e,String(n));const C=kb[S[0]];return C(p,S,o.localize,u)}).join("")}function Mj(n){const e=n.match(kj);return e?e[1].replace(Nj,"'"):n}function Rj(n,e,s){const i=Lo(),o=(s==null?void 0:s.locale)??i.locale??ov,c=NA(n,e);if(isNaN(c))throw new RangeError("Invalid time value");const m=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[p,g]=av(s==null?void 0:s.in,...c>0?[e,n]:[n,e]),u=RA((s==null?void 0:s.roundingMethod)??"round"),d=g.getTime()-p.getTime(),b=d/wb,x=xu(g)-xu(p),v=(d-x)/wb,_=s==null?void 0:s.unit;let S;if(_?S=_:b<1?S="second":b<60?S="minute":b<Ob?S="hour":v<Eb?S="day":v<Sb?S="month":S="year",S==="second"){const C=u(d/1e3);return o.formatDistance("xSeconds",C,m)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,m)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,m)}else if(S==="day"){const C=u(v/Ob);return o.formatDistance("xDays",C,m)}else if(S==="month"){const C=u(v/Eb);return C===12&&_!=="month"?o.formatDistance("xYears",1,m):o.formatDistance("xMonths",C,m)}else{const C=u(v/Sb);return o.formatDistance("xYears",C,m)}}function Dj(n,e){return Rj(n,TA(n),e)}let vu=null;function Lj(n){vu=n||null}function qj(){return vu}function Pj(n,e,s){const i=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...s?{second:"2-digit"}:{},hour12:!0}).formatToParts(n);return Object.fromEntries(i.map(o=>[o.type,o.value]))}function km(n,e=!1){const s=typeof n=="string"?new Date(n):n;if(Number.isNaN(s.getTime()))return String(n);if(!vu)return Cj(s,e?"MMM d, yyyy h:mm:ss a":"MMM d, yyyy h:mm a");const i=Pj(s,vu,e),o=`${i.hour}:${i.minute}${e?`:${i.second}`:""}`;return`${i.month} ${i.day}, ${i.year} ${o} ${i.dayPeriod}`}function uv(n){const e=n??[];return e.length>0&&e.every(s=>s.type==="member"&&s.write_scope==="none")}function v5(n,e,s){return!e||!uv(n)?!0:!!s&&!s.subjectScoped}const Nm={staleTime:5*6e4,refetchOnWindowFocus:!1};function _5(n={},e={}){const s=new URLSearchParams;return n.role&&s.set("role",n.role),n.roleType&&s.set("roleType",n.roleType),n.status&&s.set("status",n.status),n.search&&s.set("search",n.search),n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),qe({queryKey:["users",n],queryFn:()=>ue(`/users?${s}`),enabled:e.enabled??!0,...Nm})}const Mb=200;async function Bj(n){const e=[];for(let s=0;s<n.length;s+=Mb){const i=await ue("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+Mb)})});e.push(...i.users??[])}return e}let Jd=[],Qd=new Map,Xd=!1;function Uj(){const n=Jd,e=Qd;Jd=[],Qd=new Map,Xd=!1,Bj(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of e)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of e.values())i.reject(s)})}function zj(n){return new Promise((e,s)=>{Jd.push(n),Qd.set(n,{resolve:e,reject:s}),Xd||(Xd=!0,setTimeout(Uj,0))})}function w5(n){return qe({queryKey:["user-name",n],queryFn:()=>zj(n),enabled:!!n,...Nm})}function Ij(n){return qe({queryKey:["users",n,"roles"],queryFn:async()=>(await ue(`/users/${n}/roles`)).roles??[],enabled:!!n,...Nm})}function S5(){const n=Pe();return $e({mutationFn:e=>ue("/users",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function E5(){const n=Pe();return $e({mutationFn:({id:e,...s})=>ue(`/users/${e}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function O5(){const n=Pe();return $e({mutationFn:({id:e,ops:s})=>ue(`/users/${e}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function A5(){return qe({queryKey:["users","system-property-keys"],queryFn:()=>ue("/users/system-property-keys")})}function j5(){const n=Pe();return $e({mutationFn:e=>ue(`/users/${e}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function k5(){const n=Pe();return $e({mutationFn:({userId:e,role:s,type:i,read_scope:o,write_scope:c})=>ue(`/users/${e}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function N5(){const n=Pe();return $e({mutationFn:({userId:e,role:s})=>ue(`/users/${e}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const T5={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function $j(){return qe({queryKey:["roles"],queryFn:()=>ue("/roles")})}function Mu(n){return qe({queryKey:["roles","details"],queryFn:()=>ue("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function C5(n,e,s=!0){return qe({queryKey:["roles",n,"schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function M5(n){return qe({queryKey:["roles",n,"schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function R5(n,e,s=!0){return qe({queryKey:["roles",n,"list-schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function D5(n){return qe({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function L5(){const n=Pe();return $e({mutationFn:e=>ue("/roles",{method:"POST",body:JSON.stringify({role:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function q5(){const n=Pe();return $e({mutationFn:({role:e,...s})=>ue(`/roles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:e,...s})=>{await n.cancelQueries({queryKey:["roles","details"]});const i=n.getQueryData(["roles","details"]);return i&&n.setQueryData(["roles","details"],{roles:i.roles.map(o=>o.role===e?{...o,...s}:o)}),{previous:i}},onError:(e,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function P5(){const n=Pe();return $e({mutationFn:e=>ue(`/roles/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const fv="lt:station:kiosk-role:";function Wd(n){return`${fv}${n}`}const Zd=new Set;function Hj(){for(const n of Zd)n()}function Fj(n){try{return localStorage.getItem(Wd(n))}catch{return null}}function Gj(n,e){try{e===null?localStorage.removeItem(Wd(n)):localStorage.setItem(Wd(n),e)}catch{}Hj()}function Vj(n){Zd.add(n);const e=s=>{(s.key===null||s.key.startsWith(fv))&&n()};try{window.addEventListener("storage",e)}catch{}return()=>{Zd.delete(n);try{window.removeEventListener("storage",e)}catch{}}}function Yj(n){return E.useSyncExternalStore(Vj,()=>n?Fj(n):null)}const _u="/portal";function Kj(n){return n===_u||n.startsWith(`${_u}/`)}function Tm(n,e){const s=`${_u}/${encodeURIComponent(n)}`;return e?`${s}/${encodeURIComponent(e)}`:s}function ta(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function Jj(n){return ta(n).length>0}function B5(n,e){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(e);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function hv(n,e){return e.length>0?Tm(n,e[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Cm(){const{user:n}=qt(),e=(n==null?void 0:n.userId)??null,{data:s}=Ij(e),{data:i}=Mu(),o=Yj(e),c=E.useCallback(m=>{e&&Gj(e,m)},[e]);return E.useMemo(()=>{const m={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},p=s??[];if(p.length===0||p.some(v=>v.type!=="member"))return m;const g=v=>{var _;return(_=i==null?void 0:i.roles)==null?void 0:_.find(S=>S.role===v)},u=v=>{var _,S;return((S=(_=g(v))==null?void 0:_.properties)==null?void 0:S.kiosk)===!0},d=p.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:hv(v,ta(g(v))),targets:d,selectable:d.length>=2,selectRole:c});if(p.length===1)return d.length===1?b(d[0]):m;if(!uv(p)||d.length===0)return m;const x=o&&d.includes(o)?o:d.length===1?d[0]:null;return x?b(x):{...m,targets:d,selectable:!0}},[s,i,o,c])}const Qj="/escalations/available",Xj=["/escalations",_u,"/scan","/login"];function Wj(n,e=""){if(n===Qj){const s=new URLSearchParams(e);if(!s.get("role")&&!s.get("facets"))return!1}return Xj.some(s=>n===s||n.startsWith(`${s}/`)||n.startsWith(`${s}?`))}const Mm=E.createContext(null),ud="lt_sidebar_collapsed",dv="(max-width: 1023px)";function Zj(){try{return window.matchMedia(dv).matches}catch{return!1}}function ek({children:n}){const[e,s]=E.useState(()=>{if(Zj())return!0;try{return localStorage.getItem(ud)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(dv)}catch{return}const c=m=>{if(m.matches)s(!0);else try{s(localStorage.getItem(ud)==="true")}catch{s(!1)}};return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[]);const i=E.useCallback(()=>{s(o=>{const c=!o;try{localStorage.setItem(ud,String(c))}catch{}return c})},[]);return h.jsx(Mm.Provider,{value:{collapsed:e,toggle:i},children:n})}function tk({children:n}){return h.jsx(Mm.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Rm(){const n=E.useContext(Mm);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const Rb=380,Dm=E.createContext(null);function nk({children:n}){const[e,s]=E.useState({node:null,width:Rb,open:!1,ownerKey:null}),i=en(),o=E.useRef(i.pathname),c=E.useCallback((p,g)=>{s({node:p,width:(g==null?void 0:g.width)??Rb,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),m=E.useCallback(p=>{s(g=>typeof p=="string"&&g.ownerKey!==p?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(p=>p.open||p.node?{...p,node:null,open:!1,ownerKey:null}:p))},[i.pathname]),h.jsx(Dm.Provider,{value:{...e,setPanel:c,closePanel:m},children:n})}function Lm(){const n=E.useContext(Dm);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function U5(){return E.useContext(Dm)}function rk({open:n,width:e=380,children:s,className:i=""}){const[o,c]=E.useState(n);return E.useEffect(()=>{n&&c(!0)},[n]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${i}`,style:{width:n?e:0,maxWidth:"50%"},onTransitionEnd:m=>{!n&&m.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:e},className:"h-full",children:o?s:null})})}function z5({label:n,children:e}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:n}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:e})]})}function I5({views:n,activeId:e,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:m}){const p=n.find(g=>g.id===e)??n[0];return p?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${c??"sticky top-0 z-10 max-h-[calc(100vh-3.5rem)]"}`,children:[h.jsxs("div",{className:`flex items-center justify-between pl-4 pr-3 shrink-0 ${m?"pt-10 pb-2":"pt-3"}`,children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1 shrink-0",role:"radiogroup","aria-label":"Panel view",children:n.map(g=>{const u=g.icon,d=g.id===p.id;return h.jsx("button",{role:"radio","aria-checked":d,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${d?"bg-accent/10 text-accent":"text-accent/60 hover:text-accent hover:bg-surface-hover"}`,children:h.jsx(u,{className:"w-3.5 h-3.5"})},g.id)})}),m&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:p.label})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o,i&&h.jsx("button",{onClick:i,title:"Close panel",className:"p-1 rounded text-accent/60 hover:text-accent hover:bg-surface-hover transition-colors",children:h.jsx(Zt,{className:"w-3.5 h-3.5"})})]})]}),!m&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:p.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${m?"pt-4 pb-8":"pb-5 pt-1"}`,children:p.content})]})}):null}function mv(n,e){var s,i,o,c,m;e.facets&&Object.keys(e.facets).length&&n.set("facets",JSON.stringify(e.facets)),(s=e.block)!=null&&s.length&&n.set("block",JSON.stringify(e.block)),(i=e.range)!=null&&i.length&&n.set("range",JSON.stringify(e.range)),(o=e.exists)!=null&&o.length&&n.set("exists",JSON.stringify(e.exists)),(c=e.roles)!=null&&c.length&&n.set("roles",JSON.stringify(e.roles)),(m=e.orderBy)!=null&&m.length&&n.set("orderBy",JSON.stringify(e.orderBy)),e.available!==void 0&&n.set("available",String(e.available)),e.jeopardy===!0&&n.set("jeopardy","1"),e.include&&n.set("include",e.include),e.groupBy&&n.set("groupBy",e.groupBy)}function $5(n,e,s){const i=n??"24h",o=e&&Object.keys(e).length?JSON.stringify(e):null;return qe({queryKey:["stationMetrics",i,o],queryFn:()=>ue(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function H5(n){const e=n?`?period=${n}`:"";return qe({queryKey:["escalationStats",n],queryFn:()=>ue(`/escalations/stats${e}`)})}function F5(){return qe({queryKey:["escalationTypes"],queryFn:()=>ue("/escalations/types")})}function G5(n=!0){return qe({queryKey:["escalationFacetKeys"],queryFn:()=>ue("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function sk(n){return qe({queryKey:["escalationFacetValues",n],queryFn:()=>ue(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function ik(n){const e=new URLSearchParams;return n.status&&e.set("status",n.status),n.role&&e.set("role",n.role),n.type&&e.set("type",n.type),n.subtype&&e.set("subtype",n.subtype),n.assigned_to&&e.set("assigned_to",n.assigned_to),n.parent_id&&e.set("parent_id",n.parent_id),n.claimed&&e.set("claimed","true"),n.priority&&e.set("priority",String(n.priority)),n.limit&&e.set("limit",String(n.limit)),n.offset!==void 0&&e.set("offset",String(n.offset)),n.sort_by&&e.set("sort_by",n.sort_by),n.order&&e.set("order",n.order),n.search&&e.set("search",n.search),mv(e,n),e}function ak(n){return{queryKey:["escalations",n],queryFn:()=>ue(`/escalations?${ik(n)}`)}}function pv(n){const{enabled:e=!0,staleTime:s,...i}=n;return qe({...ak(i),enabled:e,...s!==void 0?{staleTime:s}:{}})}function yv(n){const{enabled:e=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),mv(o,i),qe({queryKey:["escalations","available",i],queryFn:()=>ue(`/escalations/available?${o}`),enabled:e,...s!==void 0?{staleTime:s}:{}})}function V5(n){return qe({queryKey:["escalations","by-workflow",n],queryFn:()=>ue(`/escalations/by-workflow/${n}`),enabled:!!n})}function Y5(n){return qe({queryKey:["escalations",n],queryFn:()=>ue(`/escalations/${n}`),enabled:!!n})}function K5(n,e){return qe({queryKey:["escalations",n,"lookups"],queryFn:()=>ue(`/escalations/${n}/lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function J5(){const n=Pe();return $e({mutationFn:({id:e,durationMinutes:s})=>ue(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function Q5(){const n=Pe();return $e({mutationFn:e=>ue(`/escalations/${e}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function X5(){const n=Pe();return $e({mutationFn:({id:e,resolverPayload:s})=>ue(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),n.resetQueries({queryKey:["tasks"]}),n.resetQueries({queryKey:["jobs"]})}})}const W5={NEEDS_BADGE:"needs_badge",ROLE_REFUSED:"role_refused"};function Z5(){const n=Pe();return $e({mutationFn:({id:e,...s})=>ue(`/escalations/${e}/roster-action`,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]}),n.invalidateQueries({queryKey:["escalationStats"]})}})}function eM(){const n=Pe();return $e({mutationFn:({id:e,itemKey:s,payload:i})=>ue(`/escalations/${e}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function tM(){const n=Pe();return $e({mutationFn:({id:e,itemKey:s})=>ue(`/escalations/${e}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function nM(){const n=Pe();return $e({mutationFn:({id:e,targetRole:s})=>ue(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function rM(){const n=Pe();return $e({mutationFn:({ids:e,priority:s})=>ue("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:e,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function sM(){const n=Pe();return $e({mutationFn:({ids:e,durationMinutes:s})=>ue("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:e,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function iM(){const n=Pe();return $e({mutationFn:({ids:e,targetUserId:s,durationMinutes:i,reassign:o})=>ue("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:e,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function aM(){const n=Pe();return $e({mutationFn:({ids:e})=>ue("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function oM(){const n=Pe();return $e({mutationFn:({ids:e,hint:s})=>ue("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:e,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function lM(){const n=Pe();return $e({mutationFn:e=>ue(`/escalations/${e}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function cM(){const n=Pe();return $e({mutationFn:({ids:e})=>ue("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function qm(n){const e=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":e.push(["tasks"]),e.push(["jobs"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),n.originId&&e.push(["processes",n.originId]);break;case"escalation":e.push(["escalations"]),e.push(["escalationStats"]),e.push(["stationMetrics"]),n.workflowId&&e.push(["workflowExecution",n.workflowId]);break;case"workflow":e.push(["jobs"]),e.push(["tasks"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId]),e.push(["mcpQueryResult",n.workflowId]),e.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&e.push(["mcpRunExecution",n.workflowId]),e.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),e.push(["tasks"]);break;case"knowledge":e.push(["knowledge"]);break;case"file":e.push(["files"]);break;case"agent":e.push(["agents"]);break;default:e.push(["jobs"]),e.push(["tasks"]);break}return e}const ok={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},uM=300,Db={DETAIL:0,LIST:1,SUMMARY:2};function lk(n){const e=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function m(d){delete s[d],i[d]=Date.now();const b=[];for(const[v,_]of e)_===d&&b.push(v);for(const v of b)e.delete(v);if(b.length===0)return;const x=c();x&&(o=!0);for(const v of b)n.invalidateQueries({queryKey:JSON.parse(v),...x?{refetchType:"none"}:{}})}function p(d){if(s[d])return;const{coalesceMs:b,minIntervalMs:x}=ok[d],v=i[d],_=v===void 0?0:v+x-Date.now(),S=Math.max(b,_);s[d]=setTimeout(()=>m(d),S)}function g(d,b){for(const x of b){const v=JSON.stringify(x),_=e.get(v);(_===void 0||Db[d]<Db[_])&&e.set(v,d)}p(d)}const u=()=>{typeof document>"u"||document.visibilityState==="visible"&&o&&(o=!1,n.refetchQueries({type:"active",stale:!0}))};return typeof document<"u"&&document.addEventListener("visibilitychange",u),{request:g,dispose(){for(const d of Object.keys(s)){const b=s[d];b&&clearTimeout(b),delete s[d]}e.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const Lb=new WeakMap;function ck(n){let e=Lb.get(n);return e||(e=lk(n),Lb.set(n,e)),e}function tn(n){const e=Pe();return E.useCallback(s=>{ck(e).request(n,s)},[e,n])}function Pm(n){return n?[`${Xt}.system.workflow.>`,`${Xt}.system.activity.>`,`${Xt}.system.milestone.>`,`${Xt}.system.task.>`,`${Xt}.system.escalation.>`]:[]}function fM(){const n=tn("LIST");An(`${Xt}.system.task.>`,()=>{n([["jobs"]])}),An(`${Xt}.system.workflow.>`,()=>{n([["jobs"]])})}function hM(n){const e=tn("DETAIL");ks(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function dM(n){const e=tn("DETAIL");ks(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function mM(n){const e=tn("DETAIL");ks(Pm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=qm(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),e(o)})}function pM(n){const e=tn("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||e([["processes",n]]))},[n,e]);An(`${Xt}.system.task.>`,s),An(`${Xt}.system.workflow.>`,s),An(`${Xt}.system.escalation.>`,s)}function yM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["escalationStats"]])})}function gM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["stationMetrics"]])})}function bM(){const n=tn("SUMMARY");An(fr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function xM(n){const e=tn("LIST"),s=(n==null?void 0:n.role)??null,i=((n==null?void 0:n.verbs)??[]).join(","),o=E.useMemo(()=>{const c=i?i.split(","):null;return c?Yd({role:s,verbs:c}):[fr({role:s})]},[s,i]);ks(o,()=>{e([["escalations"]])})}const uk=[["escalations","related"],["escalations","related-rows"]];function vM(n){const e=tn("LIST"),s=[...new Set(n)].sort().join(","),i=E.useMemo(()=>s?s.split(",").map(o=>fr({role:o})):[],[s]);ks(i,()=>{e(uk)})}function _M(n){const e=tn("DETAIL");An(fr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||e([["escalations",n]])})}function wM(){const n=tn("LIST");An(`${Xt}.system.agent.>`,()=>{n([["agents"]])})}function SM(){const n=tn("LIST");An(`${Xt}.system.task.>`,()=>{n([["processes"]])}),An(`${Xt}.system.workflow.>`,()=>{n([["processes"]])})}function fk(){const{user:n}=qt(),e=n==null?void 0:n.userId,s=tn("SUMMARY");ks(jm(),()=>{s([["escalations"]])});const{data:i}=yv({limit:1}),{data:o}=pv({assigned_to:e,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function Ru({size:n="sm",hideLabel:e=!1,className:s="",appName:i="LongTail",variant:o="full"}){const c=n==="lg";if(o==="comet")return h.jsx("div",{className:`relative overflow-visible ${s}`,style:{width:"2.5rem",height:"2.5rem",flexShrink:0},children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Vt}/logo512.png)`,width:"82px",height:"82px",top:"-12px",left:"-80px",transform:"rotate(232deg)",zIndex:-1,opacity:.55}})});if(o==="mark")return h.jsx("div",{className:`flex items-center ${s}`,children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Vt}/logo512.png)`}})});const m=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",p=c?"text-[44px] font-normal text-text-primary tracking-[0.15em] -ml-[12.5rem]":"text-[36px] font-normal text-text-primary tracking-[0.15em] -ml-[9.75rem]";return h.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[h.jsx("span",{role:"img","aria-label":i,className:`logo-mark shrink-0 z-0 ${m}`,style:{"--logo-url":`url(${Vt}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${p} ${e?"opacity-0":""}`,children:i})]})}const hk="system.surfaces.dashboard",dk=`${Xt}.${hk}`;function gv(n=!0){return qe({queryKey:["announcements"],queryFn:()=>ue("/announcements"),enabled:n,staleTime:3e4})}function mk(){const n=Pe();return $e({mutationFn:e=>ue("/announcements",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function pk(){const n=Pe();return $e({mutationFn:e=>ue(`/announcements/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function EM(n){return n.toLocaleString()}function OM(n){return n>=1e9?`${(n/1e9).toFixed(1).replace(/\.0$/,"")}B`:n>=1e6?`${(n/1e6).toFixed(1).replace(/\.0$/,"")}M`:n>=1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}K`:n.toLocaleString()}function yk(n){const e=new Date(n);return e.getTime()>Date.now()?"just now":Dj(e,{addSuffix:!0})}function AM(n){const e=Date.now()-new Date(n).getTime();if(e<0)return"now";const s=Math.floor(e/1e3);if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const o=Math.floor(i/60);if(o<24)return`${o}h`;const c=Math.floor(o/24);return c<7?`${c}d`:c<30?`${Math.floor(c/7)}w`:c<365?`${Math.floor(c/30)}mo`:`${Math.floor(c/365)}y`}function jM(n){return n<=0?"Expired":Bm(n)}function gk(n){return n==null?"--":Bm(n)}function kM(n){return n?km(n):"--"}function Bm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const m=n/1e3;return Number.isInteger(m)?`${m}s`:`${m.toFixed(1)}s`}const e=Math.floor(n/1e3),s=Math.floor(e/86400),i=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),c=e%60;return s>0?i>0?`${s}d ${i}h`:`${s}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:c>0?`${o}m ${c}s`:`${o}m`}function NM(n,e){const s=new Date(n).getTime(),i=e?new Date(e).getTime():Date.now();return Bm(i-s)}function bv({options:n,children:e,className:s=""}){const[i,o]=E.useState(!1),[c,m]=E.useState(null),[p,g]=E.useState(null),u=E.useRef(null),d=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const B=u.current.getBoundingClientRect(),q=window.innerWidth-x-8,ne=Math.max(8,Math.min(B.left,q));g({top:B.bottom+4,left:ne})},[]),_=E.useCallback(async(B,q)=>{try{await navigator.clipboard.writeText(B),m(q),clearTimeout(d.current),d.current=setTimeout(()=>m(null),1200)}catch{}},[]),S=E.useCallback(()=>{clearTimeout(b.current),v(),o(!0)},[v]),C=E.useCallback(()=>{b.current=setTimeout(()=>o(!1),150)},[]);return E.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[e,i&&p&&sm.createPortal(h.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:p.top,left:p.left},onMouseEnter:S,onMouseLeave:C,children:n.map(B=>h.jsxs("button",{onClick:q=>{q.stopPropagation(),_(B.value,B.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:B.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===B.label?"✓":B.value})]},B.label))}),document.body)]})}function bk(n,e){const s=new Date(n);switch(e){case"relative":return yk(n);case"datetime":return km(s);case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:qj()??void 0})}}function xk(n){const e=new Date(n);return[{label:"ms",value:String(e.getTime())},{label:"utc",value:e.toISOString()},{label:"local",value:km(e,!0)}]}function xv({date:n,format:e="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(e!=="relative")return;const c=setInterval(()=>i(m=>m+1),3e4);return()=>clearInterval(c)},[e]);const o=E.useMemo(()=>xk(n),[n]);return h.jsx(bv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:bk(n,e)})})}function vk({values:n,options:e,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const m=e.filter(p=>!n.includes(p));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(p=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==p)),className:"inline-flex items-center gap-1 text-2xs font-mono text-text-primary border border-surface-border px-1.5 py-0.5 hover:text-status-error hover:border-status-error/50 transition-colors",title:`Remove ${p}`,children:[p,h.jsx(Zt,{className:"w-3 h-3",strokeWidth:1.5})]},p)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),m.length>0&&h.jsxs("select",{value:"",onChange:p=>p.target.value&&s([...n,p.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),m.map(p=>h.jsx("option",{value:p,children:p},p))]})]})}const _k=[{minutes:1,label:"1 minute"},{minutes:15,label:"15 minutes"},{minutes:30,label:"30 minutes"},{minutes:60,label:"1 hour"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:4320,label:"3 days"},{minutes:10080,label:"7 days"}];function wk(){const{data:n}=gv(),{data:e}=$j(),s=mk(),i=pk(),[o,c]=E.useState(""),[m,p]=E.useState(""),[g,u]=E.useState(1440),[d,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{m.trim()&&s.mutate({body:m.trim(),...o.trim()?{title:o.trim()}:{},...d.length?{roles:d}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),p(""),b([])}})};return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Alerts"}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Title"}),h.jsx("input",{type:"text",value:o,onChange:_=>c(_.target.value),placeholder:"Optional headline",className:"input text-xs w-full"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Summary"}),h.jsx("textarea",{value:m,onChange:_=>p(_.target.value),placeholder:"What everyone should know (markdown supported)",rows:3,className:"input text-xs w-full resize-y"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible for"}),h.jsx("select",{value:g,onChange:_=>u(Number(_.target.value)),className:"select text-xs w-full",children:_k.map(_=>h.jsx("option",{value:_.minutes,children:_.label},_.minutes))})]}),h.jsxs("div",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible to"}),h.jsx(vk,{values:d,options:(e==null?void 0:e.roles)??[],onChange:b,addLabel:"Add a role…",emptyText:"Everyone",ariaLabel:"Add a role"})]}),s.error&&h.jsx("p",{className:"text-xs text-status-error",children:s.error.message}),h.jsx("button",{onClick:v,disabled:!m.trim()||s.isPending,className:"btn-primary text-xs w-full disabled:opacity-50",children:s.isPending?"Publishing…":"Publish alert"})]}),x.length>0&&h.jsxs("div",{className:"mt-6",children:[h.jsx("p",{className:"text-2xs text-text-tertiary mb-2",children:"Active now — stacked as banner rows, newest first"}),h.jsx("div",{className:"space-y-1",children:x.map(_=>h.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-surface-border/40 last:border-b-0",children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block text-xs text-text-primary truncate",children:_.title??_.body.split(`
54
- `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(xv,{date:_.expires_at,format:"relative"})]})]}),h.jsx("button",{onClick:()=>i.mutate(_.id),disabled:i.isPending,className:"icon-link shrink-0 mt-0.5",title:"Remove for everyone","aria-label":`Remove ${_.title??"announcement"}`,children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},_.id))})]})]})}const Sk=[{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"}],Ek=["operator","engineer","admin","superadmin"];function qb(n){return Ek.indexOf(n)}function Ok(n,e){return qb(n)>=qb(e)}function Ak({onClose:n}){var Ne,Me,We,pt,Ct,Ee,Re;const{isSuperAdmin:e,hasRoleType:s,hasRole:i}=qt(),{data:o}=Hn(),c=Om(),m=!!((Ne=o==null?void 0:o.ai)!=null&&Ne.enabled),p=Xx(),g=p!==null?p:m,[u,d]=E.useState(g),b=(Me=o==null?void 0:o.features)==null?void 0:Me.graphWorkflows,x=b==null,[v,_]=E.useState(b===!0||x&&Wx()),S=e||i("engineer"),[C,B]=E.useState(Zx()),q=!!((We=o==null?void 0:o.features)!=null&&We.scanCodes),ne=ev(),[te,M]=E.useState(ne!==null?ne:q),z=e?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ae=((pt=o==null?void 0:o.branding)==null?void 0:pt.appName)??"LongTail",F=(Ct=o==null?void 0:o.environment)==null?void 0:Ct.longTailVersion,U=(Ee=o==null?void 0:o.environment)==null?void 0:Ee.hotmeshVersion,D=(Re=o==null?void 0:o.environment)==null?void 0:Re.nodeEnv;E.useEffect(()=>{const ce=Ue=>{Ue.key==="Escape"&&n()};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[n]);const X=Sk.filter(ce=>Ok(z,ce.minTier)),W=X.length>1,he=z!=="operator",Se=[...W?[{id:"viewas",label:"View As",icon:gS}]:[],{id:"features",label:"Features",icon:bS},...he?[{id:"alerts",label:"Alerts",icon:xS}]:[]],[Ae,H]=E.useState(Se[0].id),J=ce=>{ce===null?Vd():pA(ce)},le=()=>{const ce=!u;d(ce),ce===m?mA():dA(ce),window.location.reload()},pe=()=>{const ce=!v;_(ce),yA(ce),window.location.reload()},ye=()=>{const ce=!C;B(ce),gA(ce),window.location.reload()},Ce=()=>{const ce=!te;M(ce),ce===q?xA():bA(ce),window.location.reload()};return h.jsx("div",{className:"fixed inset-0 z-[100] bg-surface-sunken/75 backdrop-blur-sm flex items-center justify-center",onClick:n,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:ce=>ce.stopPropagation(),children:[h.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(Zt,{className:"w-4 h-4",strokeWidth:1.5})}),h.jsxs("div",{className:"flex flex-col items-center gap-3 pb-8",children:[h.jsx("span",{className:"logo-mark block w-20 h-20 opacity-50",style:{"--logo-url":`url(${Vt}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ae}),F&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",F,U&&h.jsxs(h.Fragment,{children:[" · HotMesh v",U]}),D&&D!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:D})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),Se.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:Se.map(ce=>{const Ue=Ae===ce.id;return h.jsxs("button",{role:"tab","aria-selected":Ue,onClick:()=>H(ce.id),title:ce.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Ue?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(ce.icon,{className:"w-5 h-5",strokeWidth:1.5,...Ue?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:ce.label})]},ce.id)})}),Ae==="viewas"&&W&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"View As"}),X.map(ce=>{const Ue=c===ce.id,Xe=ce.id===null?`Your view · ${z}`:ce.label;return h.jsxs("button",{onClick:()=>J(ce.id),className:"w-full text-left flex items-start gap-3 py-2.5 px-1 group",children:[h.jsx("span",{className:`mt-0.5 w-4 h-4 rounded-full border shrink-0 flex items-center justify-center transition-colors ${Ue?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Ue&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"})}),h.jsxs("span",{children:[h.jsx("span",{className:`block text-sm font-medium transition-colors ${Ue?"text-accent":"text-text-primary group-hover:text-accent"}`,children:Xe}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:ce.description})]})]},String(ce.id))})]}),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:le,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"AI features"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:u?"Enabled — AI assist, agent labels, bulk AI actions":"Hidden — automation labels, no AI surfaces"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${u?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${u?"translate-x-4":"translate-x-0"}`})})]}),x&&h.jsxs("button",{onClick:pe,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Graph workflows"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:v?"Visible — Graph section shown in Orchestrate sidebar":"Hidden — use Procedural workflows instead"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${v?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${v?"translate-x-4":"translate-x-0"}`})})]}),S&&h.jsxs("button",{onClick:ye,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group","data-testid":"feature-infrastructure",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Infrastructure"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:C?"Visible — Routers, Messages, and DB Maintenance in the sidebar":"Hidden — routers, message streams, and database maintenance"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${C?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${C?"translate-x-4":"translate-x-0"}`})})]}),h.jsxs("button",{onClick:Ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Scan input"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:te?"Enabled — header scan affordance, panel, and keyboard-wedge capture":"Hidden — the deployment opts in with features.scanCodes"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${te?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${te?"translate-x-4":"translate-x-0"}`})})]})]}),Ae==="alerts"&&he&&h.jsx(wk,{}),h.jsx("hr",{className:"border-surface-border/50 mt-8"}),h.jsx("p",{className:"mt-4 text-2xs text-text-quaternary text-center",children:"Esc or click outside to close"})]})})}const vv=[{id:"violet",label:"Violet",swatch:"#7B3BE0"},{id:"red",label:"Brick",swatch:"#DC382D"},{id:"green",label:"Emerald",swatch:"#059669"},{id:"blue",label:"Electric",swatch:"#2563EB"},{id:"rose",label:"Raspberry",swatch:"#D6246E"},{id:"orange",label:"Harvest",swatch:"#E85D04"}],Pb="blue",_v="lt.theme";let wv=[];function jk(n){const e=new Set(vv.map(i=>i.id)),s=new Set;wv=n.filter(i=>!(i!=null&&i.id)||e.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function kk(){return[...vv,...wv]}function Sv(){try{return localStorage.getItem(_v)||Pb}catch{return Pb}}function Ev(n){document.documentElement.dataset.theme=n}function Nk(n){try{localStorage.setItem(_v,n)}catch{}Ev(n)}const Tk=[8,12,13,14];function Ck(n){if(!/^[0-9]+$/.test(n)||!Tk.includes(n.length))return!1;const e=n.split("").map(Number),s=e.pop();let i=0;for(let o=e.length-1,c=3;o>=0;o--,c=c===3?1:3)i+=e[o]*c;return(10-i%10)%10===s}function TM(n){return n.padStart(14,"0")}const cu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},Ov="lt_scan_wedge_config";function Av(){try{const n=localStorage.getItem(Ov);return n?{...cu,...JSON.parse(n)}:cu}catch{return cu}}function Mk(n){const e={...Av(),...n};return localStorage.setItem(Ov,JSON.stringify(e)),e}const Um=[{pattern:/(?:^|[^0-9])([1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+)$/,digitsOnly:!1},{pattern:/(?:^|[^0-9])([1-9][0-9]{7,})$/,digitsOnly:!0}];function Rk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dk(n){const e=[];for(const s of n.filter(i=>i.enabled))if(s.encoding==="delimited"){const i=Rk(s.delimiter);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}${i}[0-9]${i}[a-zA-Z0-9._-]+)$`),digitsOnly:!1})}else if(s.encoding==="fixed"){const i=1+(s.target_length??0);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}[0-9]{${i},${i+1}})$`),digitsOnly:!0})}else s.encoding==="gtin"&&e.push({pattern:/(?:^|[^0-9])([0-9]{8}|[0-9]{12,14})$/,digitsOnly:!0,accept:Ck});return e.length?e:Um}function Lk(n,e=Um){var i;let s=null;for(const o of e){const c=(i=n.match(o.pattern))==null?void 0:i[1];!c||o.accept&&!o.accept(c)||(!s||c.length>s.code.length)&&(s={code:c,shape:o})}return s}const qk=new Set(["Shift","CapsLock"]),hc={suppress:!1,emit:null};function Pk(n=cu,e=Um){let s={buffer:"",times:[],lastKeyMs:0};function i(u){const d=s.times.slice(-u.length);return d.length<2?!1:(d[d.length-1]-d[0])/(d.length-1)<=n.autoFireMaxAvgKeyMs}function o(){const u=Lk(s.buffer,e);return!u||u.code.length<n.minLength||u.shape.digitsOnly&&!i(u.code)?null:u.code}function c(){s={buffer:"",times:[],lastKeyMs:0}}function m(u){const{key:d,timeMs:b,hasModifier:x,isRepeat:v}=u;if(qk.has(d))return hc;if(n.terminators.includes(d)){const q=o();return c(),q?{suppress:!0,emit:q,consumedLength:q.length}:hc}if(x||v||d.length!==1)return c(),hc;const _=b-s.lastKeyMs,S=s.lastKeyMs>0&&_<=n.maxKeyGapMs,C=(S?s.buffer+d:d).slice(-128),B=(S?[...s.times,b]:[b]).slice(-128);return s={buffer:C,times:B,lastKeyMs:b},hc}function p(){return{buffer:s.buffer}}function g(){const u=o();return!u||!i(u)?null:{code:u,consumedLength:u.length}}return{step:m,reset:c,snapshot:p,pendingAutoFire:g}}function Bk(){const n=document.activeElement;return n instanceof HTMLInputElement?["text","search","tel","url","email","password","number"].includes(n.type)?n:null:n instanceof HTMLTextAreaElement?n:null}function Uk(n,e,s){var c;const i=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,o=(c=Object.getOwnPropertyDescriptor(i,"value"))==null?void 0:c.set;o?o.call(n,e):n.value=e;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function Bb(n){if(n<=0)return;const e=Bk();if(!e)return;const s=e.selectionStart??e.value.length,i=Math.max(0,s-n);Uk(e,e.value.slice(0,i)+e.value.slice(s),i)}const To={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar"},zk="data-lt-scan-capture",Ik="off";function $k(n){return n instanceof Element&&!!n.closest(`[${zk}="${Ik}"]`)}function Hk({active:n,wedgeConfig:e,tailShapes:s,diagnosticsOn:i,onScan:o,onDiag:c}){const m=E.useRef({diagnosticsOn:i,onScan:o,onDiag:c});m.current={diagnosticsOn:i,onScan:o,onDiag:c};const p=E.useRef(0),g=E.useRef(0);E.useEffect(()=>{if(!n)return;const u=Pk(e,s);let d=null;const b=()=>{d&&(clearTimeout(d),d=null)},x=(S,C,B)=>{C&&Bb(C),m.current.diagnosticsOn&&(console.debug("[scan]",B),m.current.onDiag({seq:++p.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:B})),m.current.onScan(S)},v=()=>{b(),u.pendingAutoFire()&&(d=setTimeout(()=>{d=null;const S=u.pendingAutoFire();S&&(u.reset(),x(S.code,S.consumedLength,`capture → ${S.code} (quiet period — no suffix)`))},e.autoFireQuietMs))},_=S=>{if($k(S.target)){u.reset(),b();return}const C=u.snapshot().buffer,{suppress:B,emit:q,consumedLength:ne}=u.step({key:S.key,timeMs:S.timeStamp,hasModifier:S.ctrlKey||S.metaKey||S.altKey,isRepeat:S.repeat});if(B&&(S.preventDefault(),S.stopPropagation()),m.current.diagnosticsOn){const te=u.snapshot().buffer,M=e.terminators.includes(S.key),z=q?`capture → ${q}`:M?`terminator — no code tail in "${C.slice(-24)}"`:te===C?C?"neutral (chord key)":"ignored":te===""?"reset (edit/chord/non-printable)":te.length<=1&&C.length>1?"gap — new episode":"accumulate",ae=g.current?Math.round(S.timeStamp-g.current):0,F={seq:++p.current,key:S.key,code:S.code!==S.key?S.code:"",deltaMs:ae,buffer:te.slice(-24),note:z};console.debug("[scan]",F.key,F.code,`${F.deltaMs}ms`,F.note),m.current.onDiag(F)}g.current=S.timeStamp,q?(b(),ne&&Bb(ne),m.current.onScan(q)):v()};return window.addEventListener("keydown",_,{capture:!0}),()=>{b(),window.removeEventListener("keydown",_,{capture:!0})}},[n,e,s])}const ke={EXECUTED:"executed",MATCHED_LIST:"matched_list",CONFIRM_REQUIRED:"confirm_required",NO_MATCH_FALLBACK:"no_match_fallback",UNCONFIGURED:"unconfigured",INVALID_CODE:"invalid_code",FORBIDDEN:"forbidden",CONFLICT:"conflict",IDENTITY_PRIMED:"identity_primed",IDENTITY_UNKNOWN:"identity_unknown",NOT_PRIMED:"not_primed",CHOICES:"choices",NO_OPEN_CONTAINER:"no_open_container",HELD:"held",REFUSED:"refused",SUBJECT_STALE:"subject_stale"},dc={SHOW_DETAIL:"show-detail",SHOW_LIST:"show-list",CLAIM:"claim",CLAIM_SHOW_DETAIL:"claim-show-detail",RELEASE:"release",RESOLVE:"resolve",ESCALATE:"escalate",CANCEL:"cancel",ACCUMULATE:"accumulate",PRESENT:"present",HOLD:"hold",FILL:"fill"},Fk={ACTION:"action",IDENTITY:"identity"};function Gk(n,e){return ue("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...e!=null&&e.actingToken?{actingToken:e.actingToken}:{},...e!=null&&e.previousActingToken?{previousActingToken:e.previousActingToken}:{},...e!=null&&e.subject?{subject:e.subject}:{},...e!=null&&e.stationRole?{stationRole:e.stationRole}:{}})})}function CM(n){return ue("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function jv(n){return qe({queryKey:["scan-schemes"],queryFn:()=>ue("/scan-codes/schemes"),...n})}function MM(n){return qe({queryKey:["scan-schemes",n],queryFn:()=>ue(`/scan-codes/schemes/${n}`),enabled:n!=null})}function RM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.version}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function DM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function LM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function qM(){const n=Pe();return $e({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"DELETE"}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const Vk=3e4;function Yk(n,e=Date.now()){if(!(!n||Date.parse(n.expiresAt)<=e))return{code:n.code,escalationId:n.escalationId}}function Ub(n,e,s=Date.now()){if(e.outcome===ke.HELD&&e.subject){const i=Math.max(0,Date.parse(e.subject.expiresAt)-s);return{...e.subject,ttlMs:i}}return e.clearSubject||!n?null:e.outcome===ke.EXECUTED&&e.progress&&e.progress.remaining>0?{...n,expiresAt:new Date(s+n.ttlMs).toISOString()}:n}function zb(n){return n.outcome===ke.NOT_PRIMED&&n.replayable===!0}function Kk(n,e=Date.now()){return n&&e-n.at<=Vk?n:null}const Jk=[ke.HELD,ke.REFUSED,ke.SUBJECT_STALE],Fi=n=>{if(n)try{return JSON.parse(n)}catch{return}},ei=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function Qk(n){const e={},s=Fi(n.get("facets"));ei(s)||(e.facets=s);const i=Fi(n.get("block"));ei(i)||(e.block=i);const o=Fi(n.get("range"));ei(o)||(e.range=o);const c=Fi(n.get("exists"));ei(c)||(e.exists=c);const m=Fi(n.get("roles"));ei(m)||(e.roles=m);const p=Fi(n.get("orderBy"));ei(p)||(e.orderBy=p),n.get("available")!=null&&(e.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(e.jeopardy=!0),e}function PM(n,e){const s=(i,o)=>ei(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",e.facets),s("block",e.block),s("range",e.range),s("exists",e.exists),s("roles",e.roles),s("orderBy",e.orderBy),e.available==null?n.delete("available"):n.set("available",String(e.available)),e.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const Ib=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function kv(n,e){const s={};for(const[o,c]of Object.entries(n))s[o]=typeof c=="object"&&c!==null?JSON.stringify(c):c;const i=encodeURIComponent(JSON.stringify(s));return e?`/escalations/available?role=${encodeURIComponent(e)}&facets=${i}${Ib}`:`/escalations/available?facets=${i}${Ib}`}function Xk(n,e,s){return kv({[n]:e},s)}function BM(n){var e,s,i;return Object.keys(n.facets??{}).length+(((e=n.block)==null?void 0:e.length)??0)+(((s=n.range)==null?void 0:s.length)??0)+(((i=n.exists)==null?void 0:i.length)??0)+(n.available!=null?1:0)+(n.jeopardy===!0?1:0)}function zm(){var s;const{data:n}=Hn(),e=ev();return e!==null?e:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const Im=E.createContext(null);function $m(){const n=E.useContext(Im);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}function UM(){return E.useContext(Im)}const Wk="scanPendingAction",Zk="scanChoices",fd="/scan/station";function eN({children:n}){const{user:e}=qt(),s=zm(),i=ni(),o=en(),{identity:c,prime:m,clear:p,settle:g}=Cu(),[u,d]=E.useState(null),[b,x]=E.useState(null),[v,_]=E.useState(null),{data:S}=jv({enabled:!!e&&s,staleTime:6e4}),C=E.useRef(null);C.current=Cm().role;const B=E.useMemo(()=>Dk((S==null?void 0:S.schemes)??[]),[S]),[q,ne]=E.useState(!1),[te,M]=E.useState(()=>Av()),[z,ae]=E.useState([]),[F,U]=E.useState(!1),D=E.useCallback(Ee=>{var Ue;const{outcome:Re}=Ee;if(Re===ke.CONFIRM_REQUIRED&&Ee.pendingAction)return i(`/escalations/detail/${Ee.pendingAction.escalationId}`,{state:{[Wk]:Ee.pendingAction}}),!0;const ce=Re===ke.EXECUTED&&!!H.current;if(Jk.includes(Re)||zb(Ee)||ce)return le.current!==fd&&i(fd),!0;if(Re===ke.EXECUTED&&Ee.escalation){const Xe=[dc.SHOW_DETAIL,dc.CLAIM_SHOW_DETAIL,dc.CLAIM,dc.ESCALATE];return Ee.verb&&Xe.includes(Ee.verb)?(i(`/escalations/detail/${Ee.escalation.id}`),!0):!1}if(Re===ke.MATCHED_LIST&&Ee.listQuery){const{targetFacet:Xe,target:un,roles:Mt}=Ee.listQuery;return i(kv({[Xe]:un},(Mt==null?void 0:Mt[0])??null)),!0}return Re===ke.CHOICES&&Ee.choices?(i(fd,{state:{[Zk]:Ee}}),!0):Re===ke.NO_MATCH_FALLBACK&&((Ue=Ee.fallback)!=null&&Ue.route)?(i(Ee.fallback.route),!0):!1},[i]),X=E.useRef(null);X.current=(c==null?void 0:c.actingToken)??null;const W=E.useRef(null),he=E.useRef([]),Se=E.useCallback(Ee=>(he.current=[Ee,...he.current],()=>{he.current=he.current.filter(Re=>Re!==Ee)}),[]),Ae=E.useRef(null);Ae.current=b;const H=E.useRef(void 0),J=E.useRef(null);J.current=v;const le=E.useRef(o.pathname);le.current=o.pathname,E.useEffect(()=>{if(!b)return;const Ee=Date.parse(b.expiresAt)-Date.now();if(Ee<=0){x(null);return}const Re=setTimeout(()=>x(null),Ee);return()=>clearTimeout(Re)},[b]);const pe=E.useCallback(async(Ee,Re,ce)=>{ne(!0);const Ue=Date.now();try{H.current=Yk(Ae.current);const Xe=await Gk(Ee,{actingToken:ce??void 0,previousActingToken:W.current??void 0,subject:H.current,stationRole:C.current??void 0});if(ce&&g(ce,Xe),x(Mt=>Ub(Mt,Xe)),Xe.outcome===ke.IDENTITY_PRIMED){W.current=m(Xe);const Mt=Kk(J.current);if(_(null),Mt&&Xe.actingToken){d({code:Ee,source:Re,at:Ue,response:Xe,error:null,navigated:!1}),await pe(Mt.code,Re,Xe.actingToken);return}}else zb(Xe)?_({code:Ee,at:Ue}):_(null);Xe.outcome===ke.NOT_PRIMED&&ce&&p();const un=D(Xe);d({code:Ee,source:Re,at:Ue,response:Xe,error:null,navigated:un})}catch(Xe){d({code:Ee,source:Re,at:Ue,response:null,error:Xe.message,navigated:!1})}finally{ne(!1)}},[D,m,p,g]),ye=E.useCallback(async(Ee,Re=To.MANUAL)=>{for(const ce of he.current)if(ce(Ee))return;await pe(Ee,Re,X.current)},[pe]),Ce=E.useCallback(()=>x(null),[]),Ne=E.useCallback(Ee=>{x(Re=>Ub(Re,Ee))},[]),Me=E.useCallback(()=>_(null),[]),We=E.useRef(ye);We.current=ye,Hk({active:!!e&&s,wedgeConfig:te,tailShapes:B,diagnosticsOn:F,onScan:Ee=>void We.current(Ee,To.KEYBOARD_WEDGE),onDiag:Ee=>ae(Re=>[...Re.slice(-29),Ee])});const pt=E.useCallback(Ee=>{M(Mk(Ee))},[]),Ct=E.useMemo(()=>({submitCode:ye,pushCodeInterceptor:Se,lastResult:u,subject:b,dropSubject:Ce,adoptResponse:Ne,pendingScan:v,dropPendingScan:Me,busy:q,wedgeConfig:te,updateWedgeConfig:pt,diagnostics:z,diagnosticsOn:F,setDiagnosticsOn:U}),[ye,Se,u,b,Ce,Ne,v,Me,q,te,pt,z,F]);return h.jsx(Im.Provider,{value:Ct,children:n})}var mc={},co={},pc={},$b;function Nn(){if($b)return pc;$b=1,Object.defineProperty(pc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var e=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return pc.default=e,pc}var Hb;function tN(){if(Hb)return co;Hb=1,Object.defineProperty(co,"__esModule",{value:!0}),co.CODE39=void 0;var n=(function(){function S(C,B){for(var q=0;q<B.length;q++){var ne=B[q];ne.enumerable=ne.enumerable||!1,ne.configurable=!0,"value"in ne&&(ne.writable=!0),Object.defineProperty(C,ne.key,ne)}}return function(C,B,q){return B&&S(C.prototype,B),q&&S(C,q),C}})(),e=Nn(),s=i(e);function i(S){return S&&S.__esModule?S:{default:S}}function o(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function c(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function m(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var p=(function(S){m(C,S);function C(B,q){return o(this,C),B=B.toUpperCase(),q.mod43&&(B+=x(_(B))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,B,q))}return n(C,[{key:"encode",value:function(){for(var q=d("*"),ne=0;ne<this.data.length;ne++)q+=d(this.data[ne])+"0";return q+=d("*"),{data:q,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),C})(s.default),g=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],u=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(S){return b(v(S))}function b(S){return u[S].toString(2)}function x(S){return g[S]}function v(S){return g.indexOf(S)}function _(S){for(var C=0,B=0;B<S.length;B++)C+=v(S[B]);return C=C%43,C}return co.CODE39=p,co}var Qn={},yc={},gc={},vt={},Fb;function qo(){if(Fb)return vt;Fb=1,Object.defineProperty(vt,"__esModule",{value:!0});var n;function e(g,u,d){return u in g?Object.defineProperty(g,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):g[u]=d,g}var s=vt.SET_A=0,i=vt.SET_B=1,o=vt.SET_C=2;vt.SHIFT=98;var c=vt.START_A=103,m=vt.START_B=104,p=vt.START_C=105;return vt.MODULO=103,vt.STOP=106,vt.FNC1=207,vt.SET_BY_CODE=(n={},e(n,c,s),e(n,m,i),e(n,p,o),n),vt.SWAP={101:s,100:i,99:o},vt.A_START_CHAR="Ð",vt.B_START_CHAR="Ñ",vt.C_START_CHAR="Ò",vt.A_CHARS="[\0-_È-Ï]",vt.B_CHARS="[ -È-Ï]",vt.C_CHARS="(Ï*[0-9]{2}Ï*)",vt.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],vt}var Gb;function Du(){if(Gb)return gc;Gb=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){c(this,d);var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(_){return _.charCodeAt(0)}),v}return n(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.bytes,v=x.shift()-105,_=i.SET_BY_CODE[v];if(_===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&x.unshift(i.FNC1);var S=d.next(x,1,_);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(v)+S.result+d.getBar((S.checksum+v)%i.MODULO)+d.getBar(i.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var x=this.options.ean128||!1;return typeof x=="string"&&(x=x.toLowerCase()==="true"),x}}],[{key:"getBar",value:function(x){return i.BARS[x]?i.BARS[x].toString():""}},{key:"correctIndex",value:function(x,v){if(v===i.SET_A){var _=x.shift();return _<32?_+64:_-32}else return v===i.SET_B?x.shift()-32:(x.shift()-48)*10+x.shift()-48}},{key:"next",value:function(x,v,_){if(!x.length)return{result:"",checksum:0};var S=void 0,C=void 0;if(x[0]>=200){C=x.shift()-105;var B=i.SWAP[C];B!==void 0?S=d.next(x,v+1,B):((_===i.SET_A||_===i.SET_B)&&C===i.SHIFT&&(x[0]=_===i.SET_A?x[0]>95?x[0]-96:x[0]:x[0]<32?x[0]+96:x[0]),S=d.next(x,v+1,_))}else C=d.correctIndex(x,_),S=d.next(x,v+1,_);var q=d.getBar(C),ne=C*v;return{result:q+S.result,checksum:ne+S.checksum}}}]),d})(s.default);return gc.default=g,gc}var bc={},Vb;function nN(){if(Vb)return bc;Vb=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=qo(),e=function(p){return p.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(p){return p.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(p){return p.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(m,p){var g=p?n.A_CHARS:n.B_CHARS,u=m.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(m.substring(u[1].length));var d=m.match(new RegExp("^"+g+"+"))[0];return d.length===m.length?m:d+String.fromCharCode(p?205:206)+o(m.substring(d.length),!p)}function c(m){var p=i(m),g=p.length;if(g===m.length)return m;m=m.substring(g);var u=e(m)>=s(m);return p+String.fromCharCode(u?206:205)+o(m,u)}return bc.default=function(m){var p=void 0,g=i(m).length;if(g>=2)p=n.C_START_CHAR+c(m);else{var u=e(m)>s(m);p=(u?n.A_START_CHAR:n.B_START_CHAR)+o(m,u)}return p.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,b){return"Ë"+b})},bc}var Yb;function rN(){if(Yb)return yc;Yb=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Du(),e=o(n),s=nN(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){if(c(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,i.default)(b),x));else var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x));return m(v)}return d})(e.default);return yc.default=g,yc}var xc={},Kb;function sN(){if(Kb)return xc;Kb=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.A_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),d})(s.default);return xc.default=g,xc}var vc={},Jb;function iN(){if(Jb)return vc;Jb=1,Object.defineProperty(vc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.B_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),d})(s.default);return vc.default=g,vc}var _c={},Qb;function aN(){if(Qb)return _c;Qb=1,Object.defineProperty(_c,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.C_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),d})(s.default);return _c.default=g,_c}var Xb;function oN(){if(Xb)return Qn;Xb=1,Object.defineProperty(Qn,"__esModule",{value:!0}),Qn.CODE128C=Qn.CODE128B=Qn.CODE128A=Qn.CODE128=void 0;var n=rN(),e=g(n),s=sN(),i=g(s),o=iN(),c=g(o),m=aN(),p=g(m);function g(u){return u&&u.__esModule?u:{default:u}}return Qn.CODE128=e.default,Qn.CODE128A=i.default,Qn.CODE128B=c.default,Qn.CODE128C=p.default,Qn}var Kt={},wc={},Rr={},Wb;function Po(){return Wb||(Wb=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.SIDE_BIN="101",Rr.MIDDLE_BIN="01010",Rr.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},Rr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Rr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Rr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Rr}var Sc={},Ec={},Zb;function Bo(){if(Zb)return Ec;Zb=1,Object.defineProperty(Ec,"__esModule",{value:!0});var n=Po(),e=function(i,o,c){var m=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var p=i.length-1;m=m.map(function(g,u){return u<p?g+c:g})}return m.join("")};return Ec.default=e,Ec}var e1;function Nv(){if(e1)return Sc;e1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){p(this,x);var S=g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.fontSize=!_.flat&&_.fontSize>_.width*10?_.width*10:_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(_,S){return this.text.substr(_,S)}},{key:"leftEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"rightText",value:function(_,S){return this.text.substr(_,S)}},{key:"rightEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"encodeGuarded",value:function(){var _={fontSize:this.fontSize},S={height:this.guardHeight};return[{data:e.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:_},{data:e.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:_},{data:e.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var _=[e.SIDE_BIN,this.leftEncode(),e.MIDDLE_BIN,this.rightEncode(),e.SIDE_BIN];return{data:_.join(""),text:this.text}}}]),x})(c.default);return Sc.default=d,Sc}var t1;function lN(){if(t1)return wc;t1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=function b(x,v,_){x===null&&(x=Function.prototype);var S=Object.getOwnPropertyDescriptor(x,v);if(S===void 0){var C=Object.getPrototypeOf(x);return C===null?void 0:b(C,v,_)}else{if("value"in S)return S.value;var B=S.get;return B===void 0?void 0:B.call(_)}},s=Po(),i=Nv(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=function(x){var v=x.substr(0,12).split("").map(function(_){return+_}).reduce(function(_,S,C){return C%2?_+S*3:_+S},0);return(10-v%10)%10},d=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.lastChar=_.lastChar,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===u(this.data)}},{key:"leftText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var _=this.data.substr(1,6),S=s.EAN13_STRUCTURE[this.data[0]];return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,_,S)}},{key:"rightText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var _=this.data.substr(7,6);return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,_,"RRRRRR")}},{key:"encodeGuarded",value:function(){var _=e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(_.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(_.push({data:"00"}),_.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),_}}]),x})(o.default);return wc.default=d,wc}var Oc={},n1;function cN(){if(n1)return Oc;n1=1,Object.defineProperty(Oc,"__esModule",{value:!0});var n=(function(){function d(b,x){for(var v=0;v<x.length;v++){var _=x[v];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,x,v){return x&&d(b.prototype,x),v&&d(b,v),b}})(),e=function d(b,x,v){b===null&&(b=Function.prototype);var _=Object.getOwnPropertyDescriptor(b,x);if(_===void 0){var S=Object.getPrototypeOf(b);return S===null?void 0:d(S,x,v)}else{if("value"in _)return _.value;var C=_.get;return C===void 0?void 0:C.call(v)}},s=Nv(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d,b){if(!(d instanceof b))throw new TypeError("Cannot call a class as a function")}function m(d,b){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:d}function p(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);d.prototype=Object.create(b&&b.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(d,b):d.__proto__=b)}var g=function(b){var x=b.substr(0,7).split("").map(function(v){return+v}).reduce(function(v,_,S){return S%2?v+_:v+_*3},0);return(10-x%10)%10},u=(function(d){p(b,d);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),m(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,x,v))}return n(b,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===g(this.data)}},{key:"leftText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var v=this.data.substr(0,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var v=this.data.substr(4,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Oc.default=u,Oc}var Ac={},r1;function uN(){if(r1)return Ac;r1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function x(v,_){for(var S=0;S<_.length;S++){var C=_[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}return function(v,_,S){return _&&x(v.prototype,_),S&&x(v,S),v}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(x){return x&&x.__esModule?x:{default:x}}function p(x,v){if(!(x instanceof v))throw new TypeError("Cannot call a class as a function")}function g(x,v){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:x}function u(x,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);x.prototype=Object.create(v&&v.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(x,v):x.__proto__=v)}var d=function(v){var _=v.split("").map(function(S){return+S}).reduce(function(S,C,B){return B%2?S+C*9:S+C*3},0);return _%10},b=(function(x){u(v,x);function v(_,S){return p(this,v),g(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,_,S))}return n(v,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var S=e.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ac.default=b,Ac}var jc={},s1;function fN(){if(s1)return jc;s1=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){return p(this,x),g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_))}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var _=e.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,_,"01"),text:this.text}}}]),x})(c.default);return jc.default=d,jc}var uo={},i1;function Tv(){if(i1)return uo;i1=1,Object.defineProperty(uo,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})();uo.checksum=d;var e=Bo(),s=c(e),i=Nn(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=d(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.displayValue=_.displayValue,_.fontSize>_.width*10?S.fontSize=_.width*10:S.fontSize=_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var _="";return _+="101",_+=(0,s.default)(this.data.substr(0,6),"LLLLLL"),_+="01010",_+=(0,s.default)(this.data.substr(6,6),"RRRRRR"),_+="101",{data:_,text:this.text}}},{key:"guardedEncoding",value:function(){var _=[];return this.displayValue&&_.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),_.push({data:"101"+(0,s.default)(this.data[0],"L"),options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),_.push({data:"01010",options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),_.push({data:(0,s.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&_.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),_}}]),x})(o.default);function d(b){var x=0,v;for(v=1;v<11;v+=2)x+=parseInt(b[v]);for(v=0;v<11;v+=2)x+=parseInt(b[v])*3;return(10-x%10)%10}return uo.default=u,uo}var kc={},a1;function hN(){if(a1)return kc;a1=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function _(S,C){for(var B=0;B<C.length;B++){var q=C[B];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(S,q.key,q)}}return function(S,C,B){return C&&_(S.prototype,C),B&&_(S,B),S}})(),e=Bo(),s=m(e),i=Nn(),o=m(i),c=Tv();function m(_){return _&&_.__esModule?_:{default:_}}function p(_,S){if(!(_ instanceof S))throw new TypeError("Cannot call a class as a function")}function g(_,S){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:_}function u(_,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);_.prototype=Object.create(S&&S.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(_,S):_.__proto__=S)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],b=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],x=(function(_){u(S,_);function S(C,B){p(this,S);var q=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,B));if(q.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)q.middleDigits=C,q.upcA=v(C,"0"),q.text=B.text||""+q.upcA[0]+C+q.upcA[q.upcA.length-1],q.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(q.middleDigits=C.substring(1,C.length-1),q.upcA=v(q.middleDigits,C[0]),q.upcA[q.upcA.length-1]===C[C.length-1])q.isValid=!0;else return g(q);else return g(q);return q.displayValue=B.displayValue,B.fontSize>B.width*10?q.fontSize=B.width*10:q.fontSize=B.fontSize,q.guardHeight=B.height+q.fontSize/2+B.textMargin,q}return n(S,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var B="";return B+="101",B+=this.encodeMiddleDigits(),B+="010101",{data:B,text:this.text}}},{key:"guardedEncoding",value:function(){var B=[];return this.displayValue&&B.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),B.push({data:"101",options:{height:this.guardHeight}}),B.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),B.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&B.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),B}},{key:"encodeMiddleDigits",value:function(){var B=this.upcA[0],q=this.upcA[this.upcA.length-1],ne=b[parseInt(q)][parseInt(B)];return(0,s.default)(this.middleDigits,ne)}}]),S})(o.default);function v(_,S){for(var C=parseInt(_[_.length-1]),B=d[C],q="",ne=0,te=0;te<B.length;te++){var M=B[te];M==="X"?q+=_[ne++]:q+=M}return q=""+S+q,""+q+(0,c.checksum)(q)}return kc.default=x,kc}var o1;function dN(){if(o1)return Kt;o1=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.UPCE=Kt.UPC=Kt.EAN2=Kt.EAN5=Kt.EAN8=Kt.EAN13=void 0;var n=lN(),e=x(n),s=cN(),i=x(s),o=uN(),c=x(o),m=fN(),p=x(m),g=Tv(),u=x(g),d=hN(),b=x(d);function x(v){return v&&v.__esModule?v:{default:v}}return Kt.EAN13=e.default,Kt.EAN8=i.default,Kt.EAN5=c.default,Kt.EAN2=p.default,Kt.UPC=u.default,Kt.UPCE=b.default,Kt}var Xs={},Nc={},Gi={},l1;function mN(){return l1||(l1=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.START_BIN="1010",Gi.END_BIN="11101",Gi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Gi}var c1;function Cv(){if(c1)return Nc;c1=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=mN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return n(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var x=this,v=this.data.match(/.{2}/g).map(function(_){return x.encodePair(_)}).join("");return{data:e.START_BIN+v+e.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=e.BINARIES[x[1]];return e.BINARIES[x[0]].split("").map(function(_,S){return(_==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),d})(i.default);return Nc.default=g,Nc}var Tc={},u1;function pN(){if(u1)return Tc;u1=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Cv(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=function(d){var b=d.substr(0,13).split("").map(function(x){return parseInt(x,10)}).reduce(function(x,v,_){return x+v*(3-_%2*2)},0);return Math.ceil(b/10)*10-b},g=(function(u){m(d,u);function d(b,x){return o(this,d),b.search(/^[0-9]{13}$/)!==-1&&(b+=p(b)),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===p(this.data)}}]),d})(s.default);return Tc.default=g,Tc}var f1;function yN(){if(f1)return Xs;f1=1,Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.ITF14=Xs.ITF=void 0;var n=Cv(),e=o(n),s=pN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Xs.ITF=e.default,Xs.ITF14=i.default,Xs}var vn={},Cc={},h1;function Uo(){if(h1)return Cc;h1=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=(function(u){m(d,u);function d(b,x){return o(this,d),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"encode",value:function(){for(var x="110",v=0;v<this.data.length;v++){var _=parseInt(this.data[v]),S=_.toString(2);S=g(S,4-S.length);for(var C=0;C<S.length;C++)x+=S[C]=="0"?"100":"110"}return x+="1001",{data:x,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(s.default);function g(u,d){for(var b=0;b<d;b++)u="0"+u;return u}return Cc.default=p,Cc}var Mc={},fo={},d1;function Lu(){if(d1)return fo;d1=1,Object.defineProperty(fo,"__esModule",{value:!0}),fo.mod10=n,fo.mod11=e;function n(s){for(var i=0,o=0;o<s.length;o++){var c=parseInt(s[o]);(o+s.length)%2===0?i+=c:i+=c*2%10+Math.floor(c*2/10)}return(10-i%10)%10}function e(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var m=parseInt(s[s.length-1-c]);i+=o[c%o.length]*m}return(11-i%11)%11}return fo}var m1;function gN(){if(m1)return Mc;m1=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod10)(d),b))}return u})(e.default);return Mc.default=p,Mc}var Rc={},p1;function bN(){if(p1)return Rc;p1=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod11)(d),b))}return u})(e.default);return Rc.default=p,Rc}var Dc={},y1;function xN(){if(y1)return Dc;y1=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod10)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Dc.default=p,Dc}var Lc={},g1;function vN(){if(g1)return Lc;g1=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod11)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Lc.default=p,Lc}var b1;function _N(){if(b1)return vn;b1=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.MSI1110=vn.MSI1010=vn.MSI11=vn.MSI10=vn.MSI=void 0;var n=Uo(),e=d(n),s=gN(),i=d(s),o=bN(),c=d(o),m=xN(),p=d(m),g=vN(),u=d(g);function d(b){return b&&b.__esModule?b:{default:b}}return vn.MSI=e.default,vn.MSI10=i.default,vn.MSI11=c.default,vn.MSI1010=p.default,vn.MSI1110=u.default,vn}var ho={},x1;function wN(){if(x1)return ho;x1=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.pharmacode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b));return x.number=parseInt(d,10),x}return n(u,[{key:"encode",value:function(){for(var b=this.number,x="";!isNaN(b)&&b!=0;)b%2===0?(x="11100"+x,b=(b-2)/2):(x="100"+x,b=(b-1)/2);return x=x.slice(0,-2),{data:x,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),u})(s.default);return ho.pharmacode=p,ho}var mo={},v1;function SN(){if(v1)return mo;v1=1,Object.defineProperty(mo,"__esModule",{value:!0}),mo.codabar=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d.toUpperCase(),b));return x.text=x.options.text||x.text.replace(/[A-D]/g,""),x}return n(u,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var b=[],x=this.getEncodings(),v=0;v<this.data.length;v++)b.push(x[this.data.charAt(v)]),v!==this.data.length-1&&b.push("0");return{text:this.text,data:b.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),u})(s.default);return mo.codabar=p,mo}var Ws={},qc={},Vi={},_1;function EN(){return _1||(_1=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Vi.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],Vi.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),Vi}var w1;function Mv(){if(w1)return qc;w1=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=EN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return e.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return d.getEncoding(C)}).join(""),_=d.checksum(x,20),S=d.checksum(x.concat(_),15);return{text:this.text,data:d.getEncoding("ÿ")+v+d.getEncoding(_)+d.getEncoding(S)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return e.BINARIES[d.symbolValue(x)]}},{key:"getSymbol",value:function(x){return e.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return e.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var _=x.slice().reverse().reduce(function(S,C,B){var q=B%v+1;return S+d.symbolValue(C)*q},0);return d.getSymbol(_%47)}}]),d})(i.default);return qc.default=g,qc}var Pc={},S1;function ON(){if(S1)return Pc;S1=1,Object.defineProperty(Pc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Mv(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return Pc.default=p,Pc}var E1;function AN(){if(E1)return Ws;E1=1,Object.defineProperty(Ws,"__esModule",{value:!0}),Ws.CODE93FullASCII=Ws.CODE93=void 0;var n=Mv(),e=o(n),s=ON(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Ws.CODE93=e.default,Ws.CODE93FullASCII=i.default,Ws}var po={},O1;function jN(){if(O1)return po;O1=1,Object.defineProperty(po,"__esModule",{value:!0}),po.GenericBarcode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return po.GenericBarcode=p,po}var A1;function kN(){if(A1)return mc;A1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=tN(),e=oN(),s=dN(),i=yN(),o=_N(),c=wN(),m=SN(),p=AN(),g=jN();return mc.default={CODE39:n.CODE39,CODE128:e.CODE128,CODE128A:e.CODE128A,CODE128B:e.CODE128B,CODE128C:e.CODE128C,EAN13:s.EAN13,EAN8:s.EAN8,EAN5:s.EAN5,EAN2:s.EAN2,UPC:s.UPC,UPCE:s.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:c.pharmacode,codabar:m.codabar,CODE93:p.CODE93,CODE93FullASCII:p.CODE93FullASCII,GenericBarcode:g.GenericBarcode},mc}var Bc={},j1;function qu(){if(j1)return Bc;j1=1,Object.defineProperty(Bc,"__esModule",{value:!0});var n=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e};return Bc.default=function(e,s){return n({},e,s)},Bc}var Uc={},k1;function NN(){if(k1)return Uc;k1=1,Object.defineProperty(Uc,"__esModule",{value:!0}),Uc.default=n;function n(e){var s=[];function i(o){if(Array.isArray(o))for(var c=0;c<o.length;c++)i(o[c]);else o.text=o.text||"",o.data=o.data||"",s.push(o)}return i(e),s}return Uc}var zc={},N1;function TN(){if(N1)return zc;N1=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.default=n;function n(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}return zc}var Ic={},$c={},Hc={},T1;function Rv(){if(T1)return Hc;T1=1,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.default=n;function n(e){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof e[i]=="string"&&(e[i]=parseInt(e[i],10)));return typeof e.displayValue=="string"&&(e.displayValue=e.displayValue!="false"),e}return Hc}var Fc={},C1;function Dv(){if(C1)return Fc;C1=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Fc.default=n,Fc}var M1;function CN(){if(M1)return $c;M1=1,Object.defineProperty($c,"__esModule",{value:!0});var n=Rv(),e=o(n),s=Dv(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m){var p={};for(var g in i.default)i.default.hasOwnProperty(g)&&(m.hasAttribute("jsbarcode-"+g.toLowerCase())&&(p[g]=m.getAttribute("jsbarcode-"+g.toLowerCase())),m.hasAttribute("data-"+g.toLowerCase())&&(p[g]=m.getAttribute("data-"+g.toLowerCase())));return p.value=m.getAttribute("jsbarcode-value")||m.getAttribute("data-value"),p=(0,e.default)(p),p}return $c.default=c,$c}var Gc={},Vc={},_n={},R1;function Lv(){if(R1)return _n;R1=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.getTotalWidthOfEncodings=_n.calculateEncodingAttributes=_n.getBarcodePadding=_n.getEncodingHeight=_n.getMaximumHeightOfEncodings=void 0;var n=qu(),e=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,d){return d.height+(d.displayValue&&u.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(u,d,b){if(b.displayValue&&d<u){if(b.textAlign=="center")return Math.floor((u-d)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-d)}return 0}function c(u,d,b){for(var x=0;x<u.length;x++){var v=u[x],_=(0,e.default)(d,v.options),S;_.displayValue?S=g(v.text,_,b):S=0;var C=v.data.length*_.width;v.width=Math.ceil(Math.max(S,C)),v.height=i(v,_),v.barcodePadding=o(S,C,_)}}function m(u){for(var d=0,b=0;b<u.length;b++)d+=u[b].width;return d}function p(u){for(var d=0,b=0;b<u.length;b++)u[b].height>d&&(d=u[b].height);return d}function g(u,d,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var v=x.measureText(u);if(!v)return 0;var _=v.width;return _}return _n.getMaximumHeightOfEncodings=p,_n.getEncodingHeight=i,_n.getBarcodePadding=o,_n.calculateEncodingAttributes=c,_n.getTotalWidthOfEncodings=m,_n}var D1;function MN(){if(D1)return Vc;D1=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function p(g,u){for(var d=0;d<u.length;d++){var b=u[d];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,d){return u&&p(g.prototype,u),d&&p(g,d),g}})(),e=qu(),s=o(e),i=Lv();function o(p){return p&&p.__esModule?p:{default:p}}function c(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var m=(function(){function p(g,u,d){c(this,p),this.canvas=g,this.encodings=u,this.options=d}return n(p,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var u=0;u<this.encodings.length;u++){var d=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(d,this.encodings[u]),this.drawCanvasText(d,this.encodings[u]),this.moveCanvasDrawing(this.encodings[u])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var u=this.canvas.getContext("2d");u.save(),(0,i.calculateEncodingAttributes)(this.encodings,this.options,u);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=b,u.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(u.fillStyle=this.options.background,u.fillRect(0,0,this.canvas.width,this.canvas.height)),u.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(u,d){var b=this.canvas.getContext("2d"),x=d.data,v;u.textPosition=="top"?v=u.marginTop+u.fontSize+u.textMargin:v=u.marginTop,b.fillStyle=u.lineColor;for(var _=0;_<x.length;_++){var S=_*u.width+d.barcodePadding;x[_]==="1"?b.fillRect(S,v,u.width,u.height):x[_]&&b.fillRect(S,v,u.width,u.height*x[_])}}},{key:"drawCanvasText",value:function(u,d){var b=this.canvas.getContext("2d"),x=u.fontOptions+" "+u.fontSize+"px "+u.font;if(u.displayValue){var v,_;u.textPosition=="top"?_=u.marginTop+u.fontSize-u.textMargin:_=u.height+u.textMargin+u.marginTop+u.fontSize,b.font=x,u.textAlign=="left"||d.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=d.width-1,b.textAlign="right"):(v=d.width/2,b.textAlign="center"),b.fillText(d.text,v,_)}}},{key:"moveCanvasDrawing",value:function(u){var d=this.canvas.getContext("2d");d.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),p})();return Vc.default=m,Vc}var Yc={},L1;function RN(){if(L1)return Yc;L1=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=qu(),s=o(e),i=Lv();function o(g){return g&&g.__esModule?g:{default:g}}function c(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}var m="http://www.w3.org/2000/svg",p=(function(){function g(u,d,b){c(this,g),this.svg=u,this.encodings=d,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var b=0;b<this.encodings.length;b++){var x=this.encodings[b],v=(0,s.default)(this.options,x.options),_=this.createGroup(d,v.marginTop,this.svg);this.setGroupOptions(_,v),this.drawSvgBarcode(_,v,x),this.drawSVGText(_,v,x),d+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(x,b),this.options.background&&this.drawRect(0,0,x,b,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,b,x){var v=x.data,_;b.textPosition=="top"?_=b.fontSize+b.textMargin:_=0;for(var S=0,C=0,B=0;B<v.length;B++)C=B*b.width+x.barcodePadding,v[B]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,_,b.width*S,b.height,d),S=0);S>0&&this.drawRect(C-b.width*(S-1),_,b.width*S,b.height,d)}},{key:"drawSVGText",value:function(d,b,x){var v=this.document.createElementNS(m,"text");if(b.displayValue){var _,S;v.setAttribute("font-family",b.font),v.setAttribute("font-size",b.fontSize),b.fontOptions.includes("bold")&&v.setAttribute("font-weight","bold"),b.fontOptions.includes("italic")&&v.setAttribute("font-style","italic"),b.textPosition=="top"?S=b.fontSize-b.textMargin:S=b.height+b.textMargin+b.fontSize,b.textAlign=="left"||x.barcodePadding>0?(_=0,v.setAttribute("text-anchor","start")):b.textAlign=="right"?(_=x.width-1,v.setAttribute("text-anchor","end")):(_=x.width/2,v.setAttribute("text-anchor","middle")),v.setAttribute("x",_),v.setAttribute("y",S),v.appendChild(this.document.createTextNode(x.text)),d.appendChild(v)}}},{key:"setSvgAttributes",value:function(d,b){var x=this.svg;x.setAttribute("width",d+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+d+" "+b),x.setAttribute("xmlns",m),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,b,x){var v=this.document.createElementNS(m,"g");return v.setAttribute("transform","translate("+d+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(d,b){d.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(d,b,x,v,_){var S=this.document.createElementNS(m,"rect");return S.setAttribute("x",d),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),_.appendChild(S),S}}]),g})();return Yc.default=p,Yc}var Kc={},q1;function DN(){if(q1)return Kc;q1=1,Object.defineProperty(Kc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,m){e(this,i),this.object=o,this.encodings=c,this.options=m}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Kc.default=s,Kc}var P1;function LN(){if(P1)return Gc;P1=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=MN(),e=m(n),s=RN(),i=m(s),o=DN(),c=m(o);function m(p){return p&&p.__esModule?p:{default:p}}return Gc.default={CanvasRenderer:e.default,SVGRenderer:i.default,ObjectRenderer:c.default},Gc}var Yi={},B1;function qv(){if(B1)return Yi;B1=1,Object.defineProperty(Yi,"__esModule",{value:!0});function n(m,p){if(!(m instanceof p))throw new TypeError("Cannot call a class as a function")}function e(m,p){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:m}function s(m,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);m.prototype=Object.create(p&&p.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(m,p):m.__proto__=p)}var i=(function(m){s(p,m);function p(g,u){n(this,p);var d=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return d.name="InvalidInputException",d.symbology=g,d.input=u,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return p})(Error),o=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return p})(Error),c=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return p})(Error);return Yi.InvalidInputException=i,Yi.InvalidElementException=o,Yi.NoElementException=c,Yi}var U1;function qN(){if(U1)return Ic;U1=1,Object.defineProperty(Ic,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e=CN(),s=m(e),i=LN(),o=m(i),c=qv();function m(d){return d&&d.__esModule?d:{default:d}}function p(d){if(typeof d=="string")return g(d);if(Array.isArray(d)){for(var b=[],x=0;x<d.length;x++)b.push(p(d[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return u(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,s.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,s.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":n(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(d){var b=document.querySelectorAll(d);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(p(b[v]));return x}}function u(d){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",b.toDataURL())}}}return Ic.default=p,Ic}var Jc={},z1;function PN(){if(z1)return Jc;z1=1,Object.defineProperty(Jc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){e(this,i),this.api=o}return n(i,[{key:"handleCatch",value:function(c){if(c.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw c.message;else throw c;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(c){try{var m=c.apply(void 0,arguments);return this.api._options.valid(!0),m}catch(p){return this.handleCatch(p),this.api}}}]),i})();return Jc.default=s,Jc}var hd,I1;function BN(){if(I1)return hd;I1=1;var n=kN(),e=B(n),s=qu(),i=B(s),o=NN(),c=B(o),m=TN(),p=B(m),g=qN(),u=B(g),d=Rv(),b=B(d),x=PN(),v=B(x),_=qv(),S=Dv(),C=B(S);function B(U){return U&&U.__esModule?U:{default:U}}var q=function(){},ne=function(D,X,W){var he=new q;if(typeof D>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(D),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof X<"u"&&(W=W||{},W.format||(W.format=ae()),he.options(W)[W.format](X,W).render()),he};ne.getModule=function(U){return e.default[U]};for(var te in e.default)e.default.hasOwnProperty(te)&&M(e.default,te);function M(U,D){q.prototype[D]=q.prototype[D.toUpperCase()]=q.prototype[D.toLowerCase()]=function(X,W){var he=this;return he._errorHandler.wrapBarcodeCall(function(){W.text=typeof W.text>"u"?void 0:""+W.text;var Se=(0,i.default)(he._options,W);Se=(0,b.default)(Se);var Ae=U[D],H=z(X,Ae,Se);return he._encodings.push(H),he})}}function z(U,D,X){U=""+U;var W=new D(U,X);if(!W.valid())throw new _.InvalidInputException(W.constructor.name,U);var he=W.encode();he=(0,c.default)(he);for(var Se=0;Se<he.length;Se++)he[Se].options=(0,i.default)(X,he[Se].options);return he}function ae(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}q.prototype.options=function(U){return this._options=(0,i.default)(this._options,U),this},q.prototype.blank=function(U){var D=new Array(U+1).join("0");return this._encodings.push({data:D}),this},q.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var U;for(var D in this._renderProperties){U=this._renderProperties[D];var X=(0,i.default)(this._options,U.options);X.format=="auto"&&(X.format=ae()),this._errorHandler.wrapBarcodeCall(function(){var W=X.value,he=e.default[X.format.toUpperCase()],Se=z(W,he,X);F(U,Se,X)})}}},q.prototype.render=function(){if(!this._renderProperties)throw new _.NoElementException;if(Array.isArray(this._renderProperties))for(var U=0;U<this._renderProperties.length;U++)F(this._renderProperties[U],this._encodings,this._options);else F(this._renderProperties,this._encodings,this._options);return this},q.prototype._defaults=C.default;function F(U,D,X){D=(0,c.default)(D);for(var W=0;W<D.length;W++)D[W].options=(0,i.default)(X,D[W].options),(0,p.default)(D[W].options);(0,p.default)(X);var he=U.renderer,Se=new he(U.element,D,X);Se.render(),U.afterRender&&U.afterRender()}return typeof window<"u"&&(window.JsBarcode=ne),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(U,D){var X=[];return jQuery(this).each(function(){X.push(this)}),ne(X,U,D)}),hd=ne,hd}var UN=BN();const zN=uS(UN),IN={[ke.EXECUTED]:"Executed",[ke.MATCHED_LIST]:"Matched list",[ke.CONFIRM_REQUIRED]:"Awaiting confirmation",[ke.NO_MATCH_FALLBACK]:"No match",[ke.UNCONFIGURED]:"Not configured",[ke.INVALID_CODE]:"Invalid code",[ke.FORBIDDEN]:"Not permitted",[ke.CONFLICT]:"Conflict",[ke.IDENTITY_PRIMED]:"Identity primed",[ke.IDENTITY_UNKNOWN]:"Badge not recognized",[ke.NOT_PRIMED]:"Badge required",[ke.CHOICES]:"Choices presented",[ke.NO_OPEN_CONTAINER]:"Container closing, scan again",[ke.HELD]:"Holding",[ke.REFUSED]:"Not placed",[ke.SUBJECT_STALE]:"Scan it again"},$N={[ke.EXECUTED]:"text-status-success",[ke.MATCHED_LIST]:"text-status-success",[ke.CONFIRM_REQUIRED]:"text-status-warning",[ke.NO_MATCH_FALLBACK]:"text-text-secondary",[ke.UNCONFIGURED]:"text-status-warning",[ke.INVALID_CODE]:"text-status-error",[ke.FORBIDDEN]:"text-status-error",[ke.CONFLICT]:"text-status-warning",[ke.IDENTITY_PRIMED]:"text-status-success",[ke.IDENTITY_UNKNOWN]:"text-status-warning",[ke.NOT_PRIMED]:"text-status-warning",[ke.CHOICES]:"text-status-success",[ke.NO_OPEN_CONTAINER]:"text-status-warning",[ke.HELD]:"text-status-success",[ke.REFUSED]:"text-status-error",[ke.SUBJECT_STALE]:"text-status-warning"};function HN(n){return n.outcome===ke.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${IN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function FN(n){var e,s,i,o,c,m,p;return n.outcome===ke.NO_MATCH_FALLBACK?((e=n.fallback)==null?void 0:e.markdown)??null:n.outcome===ke.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===ke.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===ke.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:n.outcome===ke.REFUSED?((c=n.refusal)==null?void 0:c.markdown)??n.error??null:n.outcome===ke.HELD?((p=(m=n.subject)==null?void 0:m.expect)==null?void 0:p.prompt)??null:n.outcome===ke.SUBJECT_STALE?n.error??null:null}function gs(n){return n.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function GN({content:n,compact:e,inherit:s}){const i=[],o=/^```(\w*)\n([\s\S]*?)^```$/gm;let c=0,m;for(;(m=o.exec(n))!==null;)m.index>c&&i.push({type:"text",text:n.slice(c,m.index)}),i.push({type:"code",lang:m[1],code:m[2].replace(/\n$/,"")}),c=m.index+m[0].length;c<n.length&&i.push({type:"text",text:n.slice(c)});const p=s?{text:"",heading:"",list:"",code:"text-[0.85em]",tone:""}:e?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs",tone:"text-text-secondary"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs",tone:"text-text-secondary"},g=[];for(const u of i){if(u.type==="code"){const d=u.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");g.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${p.code} font-mono text-text-secondary leading-relaxed">${d}</code></pre>`);continue}g.push(...VN(u.text,p))}return h.jsx("div",{className:s?void 0:"prose-sm",dangerouslySetInnerHTML:{__html:g.join(`
53
+ ${p.stack}`),m.reject(u)):m.resolve(d))}});return g.requestSubject=e,this.protocol.publish(e,s,{reply:c,headers:i.headers}),m}else{const c=new Sx(this.protocol.muxSubscriptions,e,i,o);this.protocol.request(c);try{this.publish(e,s,{reply:`${this.protocol.muxSubscriptions.baseInbox}${c.token}`,headers:i.headers})}catch(p){c.cancel(p)}const m=Promise.race([c.timer,c.deferred]);return m.catch(()=>{c.cancel()}),m}}flush(){return this.isClosed()?Promise.reject(be.errorForCode(fe.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(be.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(be.errorForCode(fe.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Ut;return e.iterClosed.then(()=>{const s=this.listeners.indexOf(e);this.listeners.splice(s,1)}),this.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((s,i)=>s==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(e={}){const s=new Y2(this,e);if(e.checkAPI!==!1)try{await s.getAccountInfo()}catch(i){const o=i;throw o.code===fe.NoResponders&&(o.code=fe.JetStreamNotEnabled),o}return s}jetstream(e={}){return new pm(this,e)}getServerVersion(){const e=this.info;return e?ti(e.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw be.errorForCode(fe.Disconnect);const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}get services(){return this._services||(this._services=new X2(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(be.errorForCode(fe.ConnectionClosed)):this.isDraining()?Promise.reject(be.errorForCode(fe.ConnectionDraining)):this.protocol.reconnect()}}class X2{constructor(e){j(this,"nc");this.nc=e}add(e){try{return new Do(this.nc,e).start()}catch(s){return Promise.reject(s)}}client(e,s){return new T2(this.nc,e,s)}}class W2{constructor(e,s,i){j(this,"bucket");j(this,"sm");j(this,"prefixLen");this.bucket=e,this.prefixLen=s,this.sm=i}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(gu)||"PUT"}get length(){const e=this.sm.header.get(Zt.MessageSizeHdr)||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Z2{constructor(e,s,i){j(this,"bucket");j(this,"key");j(this,"sm");this.bucket=e,this.key=s,this.sm=i}get value(){return this.sm.data}get created(){return new Date(um(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var e;return((e=this.sm.headers)==null?void 0:e.get(gu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var s;const e=((s=this.sm.headers)==null?void 0:s.get(Zt.MessageSizeHdr))||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Rx extends $E{constructor(s,i,o){super(s.nc,i,o);j(this,"js");j(this,"monitor");this.js=s,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(s){this.sub.info=s}get info(){return this.sub.info}_resetOrderedConsumer(s){if(this.info===null||this.sub.isClosed())return;const i=Lr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,i);const c=this.info;c.config.name=As.next(),c.ordered_consumer_sequence.delivery_seq=0,c.flow_control.heartbeat_count=0,c.flow_control.fc_count=0,c.flow_control.consumer_restarts++,c.deliver=i,c.config.deliver_subject=i,c.config.deliver_policy=Et.StartSequence,c.config.opt_start_seq=s;const m={};m.stream_name=this.info.stream,m.config=c.config;const p=`${c.api.prefix}.CONSUMER.CREATE.${c.stream}`;this.js._request(p,m,{retries:-1}).then(g=>{const u=g,d=this.sub.info;d.last=u,this.info.config=u.config,this.info.name=u.name}).catch(g=>{const u=new be(`unable to recreate ordered consumer ${c.stream} at seq ${s}`,fe.RequestError,g);this.sub.callback(u,{})})}_maybeSetupHbMonitoring(){var i,o;const s=((o=(i=this.info)==null?void 0:i.config)==null?void 0:o.idle_heartbeat)||0;s&&this._setupHbMonitoring(um(s))}_setupHbMonitoring(s,i=0){const o={cancelAfter:0,maxOut:2};i&&(o.cancelAfter=i);const c=this.sub,m=p=>{var d,b,x,v;const g=wE(409,`${In.IdleHeartbeatMissed}: ${p}`,this.sub.subject);if(!((d=this.info)==null?void 0:d.ordered))this.sub.callback(null,g);else{if(!this.js.nc.protocol.connected)return!1;const _=((x=(b=this.info)==null?void 0:b.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(_+1),(v=this.monitor)==null||v.restart(),!1}return!c.noIterator};this.monitor=new hm(s,m,o)}_checkHbOrderConsumer(s){const i=s.headers.get(Zt.ConsumerStalledHdr);i!==""&&this.js.nc.publish(i);const o=parseInt(s.headers.get(Zt.LastConsumerSeqHdr),10),c=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,o!==c.delivery_seq&&this._resetOrderedConsumer(c.stream_seq+1),!1}_checkOrderedConsumer(s){const i=this.info.ordered_consumer_sequence,o=s.info.streamSequence,c=s.info.deliverySequence;return c!=i.delivery_seq+1?(this._resetOrderedConsumer(i.stream_seq+1),!1):(i.delivery_seq=c,i.stream_seq=o,!0)}async destroy(){this.isClosed()||await this.drain();const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.DELETE.${s.stream}.${i}`;await s.api._request(o)}async consumerInfo(){const s=this.sub.info,i=s.config.durable_name||s.name,o=`${s.api.prefix}.CONSUMER.INFO.${s.stream}.${i}`,c=await s.api._request(o);return s.last=c,c}}class eO extends Rx{constructor(e,s,i){super(e,s,i)}pull(e={batch:1}){const{stream:s,config:i,name:o}=this.sub.info,c=i.durable_name??o,m={};if(m.batch=e.batch||1,m.no_wait=e.no_wait||!1,(e.max_bytes??0)>0){const u=this.js.nc.features.get(Ve.JS_PULL_MAX_BYTES);if(!u.ok)throw new Error(`max_bytes is only supported on servers ${u.min} or better`);m.max_bytes=e.max_bytes}let p=0;e.expires&&e.expires>0&&(p=e.expires,m.expires=ht(p));let g=0;if(e.idle_heartbeat&&e.idle_heartbeat>0&&(g=e.idle_heartbeat,m.idle_heartbeat=ht(g)),g&&p===0)throw new Error("idle_heartbeat requires expires");if(g>p)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),p&&g&&(this.monitor?this.monitor._change(g,p):this._setupHbMonitoring(g,p));const u=this.info.api,d=`${u.prefix}.CONSUMER.MSG.NEXT.${s}.${c}`,b=this.sub.subject;u.nc.publish(d,u.jc.encode(m),{reply:b})}}}function tO(n,e){return n?rO(e):nO(e)}function nO(n){return(e,s)=>e?[e,null]:(e=Wi(s),e?[e,null]:[null,No(s,n)])}function rO(n){return(e,s)=>{if(e)return[e,null];const i=Wi(s);return i!==null?[Dx(i),null]:[null,No(s,n)]}}function Dx(n){if(n!==null)switch(n.code){case fe.JetStream404NoMessages:case fe.JetStream408RequestTimeout:return null;case fe.JetStream409:return SE(n)?n:null;default:return n}return null}function sO(n){n&&n.ack()}function iO(n){const e=n.split(".");if(e.length===9&&e.splice(2,0,"_",""),e.length<11||e[0]!=="$JS"||e[1]!=="ACK")throw new Error("not js message");const s={};return s.domain=e[2]==="_"?"":e[2],s.account_hash=e[3],s.stream=e[4],s.consumer=e[5],s.deliveryCount=parseInt(e[6],10),s.redeliveryCount=s.deliveryCount,s.redelivered=s.deliveryCount>1,s.streamSequence=parseInt(e[7],10),s.deliverySequence=parseInt(e[8],10),s.timestampNanos=parseInt(e[9],10),s.pending=parseInt(e[10],10),s}class aO{constructor(e,s){j(this,"msg");j(this,"di");j(this,"didAck");j(this,"timeout");this.msg=e,this.didAck=!1,this.timeout=s}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=iO(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===ao[0]&&e[1]===ao[1]&&e[2]===ao[2]&&e[3]===ao[3]}async ackAck(e){var i;e=e||{},e.timeout=e.timeout||this.timeout;const s=dt();if(this.didAck)s.resolve(!1);else if(this.didAck=!0,this.msg.reply){const c=this.msg.publisher,m=!((i=c.options)!=null&&i.noAsyncTraces),p=new Sx(c.muxSubscriptions,this.msg.reply,{timeout:e.timeout},m);c.request(p);try{c.publish(this.msg.reply,pb,{reply:`${c.muxSubscriptions.baseInbox}${p.token}`})}catch(g){p.cancel(g)}try{await Promise.race([p.timer,p.deferred]),s.resolve(!0)}catch(g){p.cancel(g),s.reject(g)}}else s.resolve(!1);return s}ack(){this.doAck(pb)}nak(e){let s=z2;e&&(s=Ed().encode(`-NAK ${JSON.stringify({delay:ht(e)})}`)),this.doAck(s)}working(){this.doAck(ao)}next(e,s={batch:1}){const i={};i.batch=s.batch||1,i.no_wait=s.no_wait||!1,s.expires&&s.expires>0&&(i.expires=ht(s.expires));const o=er().encode(i),c=aa.concat(I2,H2,o),m=e?{reply:e}:void 0;this.msg.respond(c,m)}term(e=""){let s=$2;(e==null?void 0:e.length)>0&&(s=Ed().encode(`+TERM ${e}`)),this.doAck(s)}json(){return this.msg.json()}string(){return this.msg.string()}}const oO="1.30.3",lO="nats.ws";class cO{constructor(){j(this,"version");j(this,"lang");j(this,"closeError");j(this,"connected");j(this,"done");j(this,"socket");j(this,"options");j(this,"socketClosed");j(this,"encrypted");j(this,"peeked");j(this,"yields");j(this,"signal");j(this,"closedNotification");this.version=oO,this.lang=lO,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=dt(),this.closedNotification=dt()}async connect(e,s){const i=dt();if(s.tls)return i.reject(new be("tls",fe.InvalidOption)),i;this.options=s;const o=e.src;if(s.wsFactory){const{socket:c,encrypted:m}=await s.wsFactory(e.src,s);this.socket=c,this.encrypted=m}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=c=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(c.data)),this.peeked){this.signal.resolve();return}const m=aa.concat(...this.yields),p=KE(m);if(p!==""){const g=w2.exec(p);if(!g){s.debug&&console.error("!!!",ac(m)),i.reject(new Error("unexpected response from server"));return}try{const u=JSON.parse(g[1]);v2(u,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(u){i.reject(u);return}}},this.socket.onclose=c=>{if(this.isDiscarded())return;this.socketClosed=!0;let m;this.done||(c.wasClean||(m=new Error(c.reason)),this._closed(m))},this.socket.onerror=c=>{if(this.isDiscarded())return;const m=c,p=new be(m.message,fe.Unknown,new Error(m.error));i.reject(p)},i}disconnect(){this._closed(void 0,!0)}async _closed(e,s=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await oa(100);this.done=!0;try{this.socket.close(e?1002:1e3,e?e.message:void 0)}catch{}s&&this.closedNotification.resolve(e)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let s=0;s<e.length;s++)this.options.debug&&console.info(`> ${ac(e[s])}`),yield e[s];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=dt())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.isDiscarded())try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${ac(e)}`);return}catch(s){this.options.debug&&console.error(`!!! ${ac(e)}: ${s}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var e;this.done=!0;try{(e=this.socket)==null||e.close()}catch{}}}function uO(n,e){/^(.*:\/\/)(.*)/.test(n)||(typeof e=="boolean"?n=`${e===!0?"https":"http"}://${n}`:n=`https://${n}`);let i=new URL(n);const o=i.protocol.toLowerCase();o==="ws:"&&(e=!1),o==="wss:"&&(e=!0),o!=="https:"&&o!=="http"&&(n=n.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${n}`));let c,m;const p=i.hostname,g=i.pathname,u=i.search||"";switch(o){case"http:":case"ws:":case"nats:":m=i.port||"80",c="ws:";break;case"https:":case"wss:":case"tls:":m=i.port||"443",c="wss:";break;default:m=i.port||e===!0?"443":"80",c=e===!0?"wss:":"ws:";break}return`${c}//${p}:${m}${g}${u}`}function fO(n={}){return HE({defaultPort:443,urlParseFn:uO,factory:()=>new cO}),ym.connect(n)}const hO=null,dO=null,Wt="lt.events";function Lx(n,e){const s=n.split("."),i=e.split(".");for(let o=0;o<i.length;o++){const c=i[o];if(c===">")return!0;if(o>=s.length||c!=="*"&&c!==s[o])return!1}return s.length===i.length}const la=E.createContext({connected:!1,subscribe:()=>()=>{}});function qx(){const{connected:n}=E.useContext(la);return{connected:n}}function An(n,e){const{subscribe:s}=E.useContext(la),i=E.useRef(e);i.current=e,E.useEffect(()=>s(n,c=>i.current(c)),[s,n])}function ks(n,e){const{subscribe:s}=E.useContext(la),i=E.useRef(e);i.current=e;const o=n.join(","),c=E.useMemo(()=>o.split(",").filter(Boolean),[o]);E.useEffect(()=>{const m=g=>i.current(g),p=c.map(g=>s(g,m));return()=>p.forEach(g=>g())},[s,c])}const Px=E.createContext({connected:!1,unavailable:!1,subscribe:()=>()=>{}});function mO(){const{connected:n,unavailable:e}=E.useContext(Px);return{connected:n,unavailable:e}}const pO=Ed();function yO({children:n,url:e,token:s,resolveCredentials:i,policy:o=go,onReconnect:c,sessionKey:m}){const p=E.useRef(null),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(!1),_=E.useRef({url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c});_.current={url:e,token:s,resolveCredentials:i,policy:o,onReconnect:c};const S=E.useRef(new Map),C=E.useRef(new Map),B=E.useCallback((te,M)=>{(async()=>{for await(const z of M)try{if(!Lx(z.subject,te))continue;const ae=JSON.parse(pO.decode(z.data)),F=S.current.get(te);if(!F)continue;for(const U of F)try{U(ae)}catch{}}catch{}})()},[]),q=E.useCallback(te=>{var z;const M=p.current;if(!(!M||(z=M.isClosed)!=null&&z.call(M)||C.current.has(te)))try{const ae=M.subscribe(te);C.current.set(te,ae),B(te,ae)}catch{}},[B]),ne=E.useCallback((te,M)=>{const z=S.current;return z.has(te)||z.set(te,new Set),z.get(te).add(M),q(te),()=>{const ae=z.get(te);if(ae&&(ae.delete(M),ae.size===0)){z.delete(te);const F=C.current.get(te);if(F){C.current.delete(te);try{F.unsubscribe()}catch{}}}}},[q]);return E.useEffect(()=>{let te=!1,M=!1,z=!1,ae=!1,F=0,U,D;v(!1);const Q=()=>typeof document<"u"&&document.visibilityState==="hidden",W=async()=>{const{url:J,token:ce,resolveCredentials:pe}=_.current;if(pe)return pe();const ge=J||hO;return ge?{kind:"ok",url:ge,token:ce||dO||null}:{kind:"unavailable"}},he=(J=fE(F++,_.current.policy))=>{te||M||(U=setTimeout(Ae,J))},Ee=J=>{J.closed().then(()=>{p.current===J&&(p.current=null,C.current.clear(),u(!1),he(Gg(_.current.policy)))})};async function Ae(){if(U=void 0,!(te||M||z||p.current)&&!Q()){z=!0;try{const J=await W();if(te)return;if(J.kind==="session-ended"){M=!0,v(!0);return}if(J.kind==="unavailable"){he();return}const ce=await fO({servers:J.url,token:J.token??void 0,reconnect:!1});if(te){ce.close().catch(()=>{});return}p.current=ce,F=0,u(!0),C.current.clear();for(const pe of S.current.keys())q(pe);ae&&(D=setTimeout(()=>{var pe,ge;return(ge=(pe=_.current).onReconnect)==null?void 0:ge.call(pe)},Gg(_.current.policy))),ae=!0,Ee(ce)}catch{te||he()}finally{z=!1}}}const H=()=>{te||M||z||p.current||Q()||(U&&clearTimeout(U),F=0,Ae())};return document.addEventListener("visibilitychange",H),window.addEventListener("online",H),Ae(),()=>{te=!0,U&&clearTimeout(U),D&&clearTimeout(D),document.removeEventListener("visibilitychange",H),window.removeEventListener("online",H);for(const J of C.current.values())try{J.unsubscribe()}catch{}C.current.clear(),p.current&&(p.current.close().catch(()=>{}),p.current=null),u(!1)}},[q,m]),E.useEffect(()=>{if(g||x){b(!1);return}const te=setTimeout(()=>b(!0),o.noticeAfterMs);return()=>clearTimeout(te)},[g,x,o.noticeAfterMs]),h.jsx(Px.Provider,{value:{connected:g,unavailable:d,subscribe:ne},children:h.jsx(la.Provider,{value:{connected:g,subscribe:ne},children:n})})}const ur=Object.create(null);ur.open="0";ur.close="1";ur.ping="2";ur.pong="3";ur.message="4";ur.upgrade="5";ur.noop="6";const iu=Object.create(null);Object.keys(ur).forEach(n=>{iu[ur[n]]=n});const Bd={type:"error",data:"parser error"},Bx=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Ux=typeof ArrayBuffer=="function",zx=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,gm=({type:n,data:e},s,i)=>Bx&&e instanceof Blob?s?i(e):gb(e,i):Ux&&(e instanceof ArrayBuffer||zx(e))?s?i(e):gb(new Blob([e]),i):i(ur[n]+(e||"")),gb=(n,e)=>{const s=new FileReader;return s.onload=function(){const i=s.result.split(",")[1];e("b"+(i||""))},s.readAsDataURL(n)};function bb(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let ad;function gO(n,e){if(Bx&&n.data instanceof Blob)return n.data.arrayBuffer().then(bb).then(e);if(Ux&&(n.data instanceof ArrayBuffer||zx(n.data)))return e(bb(n.data));gm(n,!1,s=>{ad||(ad=new TextEncoder),e(ad.encode(s))})}const xb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vo=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<xb.length;n++)vo[xb.charCodeAt(n)]=n;const bO=n=>{let e=n.length*.75,s=n.length,i,o=0,c,m,p,g;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const u=new ArrayBuffer(e),d=new Uint8Array(u);for(i=0;i<s;i+=4)c=vo[n.charCodeAt(i)],m=vo[n.charCodeAt(i+1)],p=vo[n.charCodeAt(i+2)],g=vo[n.charCodeAt(i+3)],d[o++]=c<<2|m>>4,d[o++]=(m&15)<<4|p>>2,d[o++]=(p&3)<<6|g&63;return u},xO=typeof ArrayBuffer=="function",bm=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ix(n,e)};const s=n.charAt(0);return s==="b"?{type:"message",data:vO(n.substring(1),e)}:iu[s]?n.length>1?{type:iu[s],data:n.substring(1)}:{type:iu[s]}:Bd},vO=(n,e)=>{if(xO){const s=bO(n);return Ix(s,e)}else return{base64:!0,data:n}},Ix=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},$x="",_O=(n,e)=>{const s=n.length,i=new Array(s);let o=0;n.forEach((c,m)=>{gm(c,!1,p=>{i[m]=p,++o===s&&e(i.join($x))})})},wO=(n,e)=>{const s=n.split($x),i=[];for(let o=0;o<s.length;o++){const c=bm(s[o],e);if(i.push(c),c.type==="error")break}return i};function SO(){return new TransformStream({transform(n,e){gO(n,s=>{const i=s.length;let o;if(i<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,i);else if(i<65536){o=new Uint8Array(3);const c=new DataView(o.buffer);c.setUint8(0,126),c.setUint16(1,i)}else{o=new Uint8Array(9);const c=new DataView(o.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(o[0]|=128),e.enqueue(o),e.enqueue(s)})}})}let od;function uc(n){return n.reduce((e,s)=>e+s.length,0)}function fc(n,e){if(n[0].length===e)return n.shift();const s=new Uint8Array(e);let i=0;for(let o=0;o<e;o++)s[o]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),s}function EO(n,e){od||(od=new TextDecoder);const s=[];let i=0,o=-1,c=!1;return new TransformStream({transform(m,p){for(s.push(m);;){if(i===0){if(uc(s)<1)break;const g=fc(s,1);c=(g[0]&128)===128,o=g[0]&127,o<126?i=3:o===126?i=1:i=2}else if(i===1){if(uc(s)<2)break;const g=fc(s,2);o=new DataView(g.buffer,g.byteOffset,g.length).getUint16(0),i=3}else if(i===2){if(uc(s)<8)break;const g=fc(s,8),u=new DataView(g.buffer,g.byteOffset,g.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){p.enqueue(Bd);break}o=d*Math.pow(2,32)+u.getUint32(4),i=3}else{if(uc(s)<o)break;const g=fc(s,o);p.enqueue(bm(c?g:od.decode(g),e)),i=0}if(o===0||o>n){p.enqueue(Bd);break}}}})}const Hx=4;function Ct(n){if(n)return OO(n)}function OO(n){for(var e in Ct.prototype)n[e]=Ct.prototype[e];return n}Ct.prototype.on=Ct.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};Ct.prototype.once=function(n,e){function s(){this.off(n,s),e.apply(this,arguments)}return s.fn=e,this.on(n,s),this};Ct.prototype.off=Ct.prototype.removeListener=Ct.prototype.removeAllListeners=Ct.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,o=0;o<s.length;o++)if(i=s[o],i===e||i.fn===e){s.splice(o,1);break}return s.length===0&&delete this._callbacks["$"+n],this};Ct.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(s){s=s.slice(0);for(var i=0,o=s.length;i<o;++i)s[i].apply(this,e)}return this};Ct.prototype.emitReserved=Ct.prototype.emit;Ct.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};Ct.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Nu=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,s)=>s(e,0),$n=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),AO="arraybuffer";function Fx(n,...e){return e.reduce((s,i)=>(n.hasOwnProperty(i)&&(s[i]=n[i]),s),{})}const jO=$n.setTimeout,kO=$n.clearTimeout;function Tu(n,e){e.useNativeTimers?(n.setTimeoutFn=jO.bind($n),n.clearTimeoutFn=kO.bind($n)):(n.setTimeoutFn=$n.setTimeout.bind($n),n.clearTimeoutFn=$n.clearTimeout.bind($n))}const NO=1.33;function TO(n){return typeof n=="string"?CO(n):Math.ceil((n.byteLength||n.size)*NO)}function CO(n){let e=0,s=0;for(let i=0,o=n.length;i<o;i++)e=n.charCodeAt(i),e<128?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(i++,s+=4);return s}function Gx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function MO(n){let e="";for(let s in n)n.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(n[s]));return e}function RO(n){let e={},s=n.split("&");for(let i=0,o=s.length;i<o;i++){let c=s[i].split("=");e[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return e}class DO extends Error{constructor(e,s,i){super(e),this.description=s,this.context=i,this.type="TransportError"}}class xm extends Ct{constructor(e){super(),this.writable=!1,Tu(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,s,i){return super.emitReserved("error",new DO(e,s,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const s=bm(e,this.socket.binaryType);this.onPacket(s)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,s={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(s)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const s=MO(e);return s.length?"?"+s:""}}class LO extends xm{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const s=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||s()})),this.writable||(i++,this.once("drain",function(){--i||s()}))}else s()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const s=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};wO(e,this.socket.binaryType).forEach(s),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,_O(e,s=>{this.doWrite(s,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",s=this.query||{};return this.opts.timestampRequests!==!1&&(s[this.opts.timestampParam]=Gx()),!this.supportsBinary&&!s.sid&&(s.b64=1),this.createUri(e,s)}}let Vx=!1;try{Vx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const qO=Vx;function PO(){}class BO extends LO{constructor(e){if(super(e),typeof location<"u"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,s){const i=this.request({method:"POST",data:e});i.on("success",s),i.on("error",(o,c)=>{this.onError("xhr post error",o,c)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(s,i)=>{this.onError("xhr poll error",s,i)}),this.pollXhr=e}}class cr extends Ct{constructor(e,s,i){super(),this.createRequest=e,Tu(this,i),this._opts=i,this._method=i.method||"GET",this._uri=s,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var e;const s=Fx(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(s);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&i.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var o;i.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=cr.requestsCount++,cr.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=PO,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete cr.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}cr.requestsCount=0;cr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",vb);else if(typeof addEventListener=="function"){const n="onpagehide"in $n?"pagehide":"unload";addEventListener(n,vb,!1)}}function vb(){for(let n in cr.requests)cr.requests.hasOwnProperty(n)&&cr.requests[n].abort()}const UO=(function(){const n=Yx({xdomain:!1});return n&&n.responseType!==null})();class zO extends BO{constructor(e){super(e);const s=e&&e.forceBase64;this.supportsBinary=UO&&!s}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new cr(Yx,this.uri(),e)}}function Yx(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||qO))return new XMLHttpRequest}catch{}if(!e)try{return new $n[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Kx=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class IO extends xm{get name(){return"websocket"}doOpen(){const e=this.uri(),s=this.opts.protocols,i=Kx?{}:Fx(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,s,i)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;gm(i,this.supportsBinary,c=>{try{this.doWrite(i,c)}catch{}o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=Gx()),this.supportsBinary||(s.b64=1),this.createUri(e,s)}}const ld=$n.WebSocket||$n.MozWebSocket;class $O extends IO{createSocket(e,s,i){return Kx?new ld(e,s,i):s?new ld(e,s):new ld(e)}doWrite(e,s){this.ws.send(s)}}class HO extends xm{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const s=EO(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(s).getReader(),o=SO();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();const c=()=>{i.read().then(({done:p,value:g})=>{p||(this.onPacket(g),c())}).catch(p=>{})};c();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let s=0;s<e.length;s++){const i=e[s],o=s===e.length-1;this._writer.write(i).then(()=>{o&&Nu(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const FO={websocket:$O,webtransport:HO,polling:zO},GO=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,VO=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ud(n){if(n.length>8e3)throw"URI too long";const e=n,s=n.indexOf("["),i=n.indexOf("]");s!=-1&&i!=-1&&(n=n.substring(0,s)+n.substring(s,i).replace(/:/g,";")+n.substring(i,n.length));let o=GO.exec(n||""),c={},m=14;for(;m--;)c[VO[m]]=o[m]||"";return s!=-1&&i!=-1&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=YO(c,c.path),c.queryKey=KO(c,c.query),c}function YO(n,e){const s=/\/{2,9}/g,i=e.replace(s,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function KO(n,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,o,c){o&&(s[o]=c)}),s}const zd=typeof addEventListener=="function"&&typeof removeEventListener=="function",au=[];zd&&addEventListener("offline",()=>{au.forEach(n=>n())},!1);class Es extends Ct{constructor(e,s){if(super(),this.binaryType=AO,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(s=e,e=null),e){const i=Ud(e);s.hostname=i.host,s.secure=i.protocol==="https"||i.protocol==="wss",s.port=i.port,i.query&&(s.query=i.query)}else s.host&&(s.hostname=Ud(s.host).host);Tu(this,s),this.secure=s.secure!=null?s.secure:typeof location<"u"&&location.protocol==="https:",s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=s.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},s.transports.forEach(i=>{const o=i.prototype.name;this.transports.push(o),this._transportsByName[o]=i}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=RO(this.opts.query)),zd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},au.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const s=Object.assign({},this.opts.query);s.EIO=Hx,s.transport=e,this.id&&(s.sid=this.id);const i=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Es.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(e);s.open(),this.setTransport(s)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",s=>this._onClose("transport close",s))}onOpen(){this.readyState="open",Es.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const s=new Error("server error");s.code=e.data,this._onError(s);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let s=1;for(let i=0;i<this.writeBuffer.length;i++){const o=this.writeBuffer[i].data;if(o&&(s+=TO(o)),i>0&&s>this._maxPayload)return this.writeBuffer.slice(0,i);s+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Nu(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,s,i){return this._sendPacket("message",e,s,i),this}send(e,s,i){return this._sendPacket("message",e,s,i),this}_sendPacket(e,s,i,o){if(typeof s=="function"&&(o=s,s=void 0),typeof i=="function"&&(o=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const c={type:e,data:s,options:i};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),o&&this.once("flush",o),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),e()},i=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(Es.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,s){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),zd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const i=au.indexOf(this._offlineEventListener);i!==-1&&au.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,s),this.writeBuffer=[],this._prevBufferLen=0}}}Es.protocol=Hx;class JO extends Es{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let s=this.createTransport(e),i=!1;Es.priorWebsocketSuccess=!1;const o=()=>{i||(s.send([{type:"ping",data:"probe"}]),s.once("packet",b=>{if(!i)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Es.priorWebsocketSuccess=s.name==="websocket",this.transport.pause(()=>{i||this.readyState!=="closed"&&(d(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())})}else{const x=new Error("probe error");x.transport=s.name,this.emitReserved("upgradeError",x)}}))};function c(){i||(i=!0,d(),s.close(),s=null)}const m=b=>{const x=new Error("probe error: "+b);x.transport=s.name,c(),this.emitReserved("upgradeError",x)};function p(){m("transport closed")}function g(){m("socket closed")}function u(b){s&&b.name!==s.name&&c()}const d=()=>{s.removeListener("open",o),s.removeListener("error",m),s.removeListener("close",p),this.off("close",g),this.off("upgrading",u)};s.once("open",o),s.once("error",m),s.once("close",p),this.once("close",g),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||s.open()},200):s.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const s=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&s.push(e[i]);return s}}let QO=class extends JO{constructor(e,s={}){const i=typeof e=="object"?e:s;(!i.transports||i.transports&&typeof i.transports[0]=="string")&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map(o=>FO[o]).filter(o=>!!o)),super(e,i)}};function XO(n,e="",s){let i=n;s=s||typeof location<"u"&&location,n==null&&(n=s.protocol+"//"+s.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=s.protocol+n:n=s.host+n),/^(https?|wss?):\/\//.test(n)||(typeof s<"u"?n=s.protocol+"//"+n:n="https://"+n),i=Ud(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const c=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+c+":"+i.port+e,i.href=i.protocol+"://"+c+(s&&s.port===i.port?"":":"+i.port),i}const WO=typeof ArrayBuffer=="function",ZO=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Jx=Object.prototype.toString,eA=typeof Blob=="function"||typeof Blob<"u"&&Jx.call(Blob)==="[object BlobConstructor]",tA=typeof File=="function"||typeof File<"u"&&Jx.call(File)==="[object FileConstructor]";function vm(n){return WO&&(n instanceof ArrayBuffer||ZO(n))||eA&&n instanceof Blob||tA&&n instanceof File}function ou(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let s=0,i=n.length;s<i;s++)if(ou(n[s]))return!0;return!1}if(vm(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return ou(n.toJSON(),!0);for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&ou(n[s]))return!0;return!1}function nA(n){const e=[],s=n.data,i=n;return i.data=Id(s,e),i.attachments=e.length,{packet:i,buffers:e}}function Id(n,e){if(!n)return n;if(vm(n)){const s={_placeholder:!0,num:e.length};return e.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=Id(n[i],e);return s}else if(typeof n=="object"&&!(n instanceof Date)){const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=Id(n[i],e));return s}return n}function rA(n,e){return n.data=$d(n.data,e),delete n.attachments,n}function $d(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let s=0;s<n.length;s++)n[s]=$d(n[s],e);else if(typeof n=="object")for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=$d(n[s],e));return n}const sA=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Ge;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(Ge||(Ge={}));class iA{constructor(e){this.replacer=e}encode(e){return(e.type===Ge.EVENT||e.type===Ge.ACK)&&ou(e)?this.encodeAsBinary({type:e.type===Ge.EVENT?Ge.BINARY_EVENT:Ge.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let s=""+e.type;return(e.type===Ge.BINARY_EVENT||e.type===Ge.BINARY_ACK)&&(s+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(s+=e.nsp+","),e.id!=null&&(s+=e.id),e.data!=null&&(s+=JSON.stringify(e.data,this.replacer)),s}encodeAsBinary(e){const s=nA(e),i=this.encodeAsString(s.packet),o=s.buffers;return o.unshift(i),o}}class _m extends Ct{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let s;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");s=this.decodeString(e);const i=s.type===Ge.BINARY_EVENT;i||s.type===Ge.BINARY_ACK?(s.type=i?Ge.EVENT:Ge.ACK,this.reconstructor=new aA(s),s.attachments===0&&super.emitReserved("decoded",s)):super.emitReserved("decoded",s)}else if(vm(e)||e.base64)if(this.reconstructor)s=this.reconstructor.takeBinaryData(e),s&&(this.reconstructor=null,super.emitReserved("decoded",s));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let s=0;const i={type:Number(e.charAt(0))};if(Ge[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===Ge.BINARY_EVENT||i.type===Ge.BINARY_ACK){const c=s+1;for(;e.charAt(++s)!=="-"&&s!=e.length;);const m=e.substring(c,s);if(m!=Number(m)||e.charAt(s)!=="-")throw new Error("Illegal attachments");const p=Number(m);if(!oA(p)||p<0)throw new Error("Illegal attachments");if(p>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=p}if(e.charAt(s+1)==="/"){const c=s+1;for(;++s&&!(e.charAt(s)===","||s===e.length););i.nsp=e.substring(c,s)}else i.nsp="/";const o=e.charAt(s+1);if(o!==""&&Number(o)==o){const c=s+1;for(;++s;){const m=e.charAt(s);if(m==null||Number(m)!=m){--s;break}if(s===e.length)break}i.id=Number(e.substring(c,s+1))}if(e.charAt(++s)){const c=this.tryParse(e.substr(s));if(_m.isPayloadValid(i.type,c))i.data=c;else throw new Error("invalid payload")}return i}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,s){switch(e){case Ge.CONNECT:return _b(s);case Ge.DISCONNECT:return s===void 0;case Ge.CONNECT_ERROR:return typeof s=="string"||_b(s);case Ge.EVENT:case Ge.BINARY_EVENT:return Array.isArray(s)&&(typeof s[0]=="number"||typeof s[0]=="string"&&sA.indexOf(s[0])===-1);case Ge.ACK:case Ge.BINARY_ACK:return Array.isArray(s)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class aA{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const s=rA(this.reconPack,this.buffers);return this.finishedReconstruction(),s}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const oA=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function _b(n){return Object.prototype.toString.call(n)==="[object Object]"}const lA=Object.freeze(Object.defineProperty({__proto__:null,Decoder:_m,Encoder:iA,get PacketType(){return Ge}},Symbol.toStringTag,{value:"Module"}));function Wn(n,e,s){return n.on(e,s),function(){n.off(e,s)}}const cA=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Qx extends Ct{constructor(e,s,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Wn(e,"open",this.onopen.bind(this)),Wn(e,"packet",this.onpacket.bind(this)),Wn(e,"error",this.onerror.bind(this)),Wn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...s){var i,o,c;if(cA.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(s.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const m={type:Ge.EVENT,data:s};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const d=this.ids++,b=s.pop();this._registerAckCallback(d,b),m.id=d}const p=(o=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||o===void 0?void 0:o.writable,g=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!p||(g?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(e,s){var i;const o=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(o===void 0){this.acks[e]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let p=0;p<this.sendBuffer.length;p++)this.sendBuffer[p].id===e&&this.sendBuffer.splice(p,1);s.call(this,new Error("operation has timed out"))},o),m=(...p)=>{this.io.clearTimeoutFn(c),s.apply(this,p)};m.withError=!0,this.acks[e]=m}emitWithAck(e,...s){return new Promise((i,o)=>{const c=(m,p)=>m?o(m):i(p);c.withError=!0,s.push(c),this.emit(e,...s)})}_addToQueue(e){let s;typeof e[e.length-1]=="function"&&(s=e.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...c)=>(this._queue[0],o!==null?i.tryCount>this._opts.retries&&(this._queue.shift(),s&&s(o)):(this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const s=this._queue[0];s.pending&&!e||(s.pending=!0,s.tryCount++,this.flags=s.flags,this.emit.apply(this,s.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Ge.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,s){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(i=>String(i.id)===e)){const i=this.acks[e];delete this.acks[e],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Ge.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ge.EVENT:case Ge.BINARY_EVENT:this.onevent(e);break;case Ge.ACK:case Ge.BINARY_ACK:this.onack(e);break;case Ge.DISCONNECT:this.ondisconnect();break;case Ge.CONNECT_ERROR:this.destroy();const i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){const s=e.data||[];e.id!=null&&s.push(this.ack(e.id)),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const s=this;let i=!1;return function(...o){i||(i=!0,s.packet({type:Ge.ACK,id:e,data:o}))}}onack(e){const s=this.acks[e.id];typeof s=="function"&&(delete this.acks[e.id],s.withError&&e.data.unshift(null),s.apply(this,e.data))}onconnect(e,s){this.id=e,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ge.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,e.data)}}}function ca(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}ca.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-s:n+s}return Math.min(n,this.max)|0};ca.prototype.reset=function(){this.attempts=0};ca.prototype.setMin=function(n){this.ms=n};ca.prototype.setMax=function(n){this.max=n};ca.prototype.setJitter=function(n){this.jitter=n};class Hd extends Ct{constructor(e,s){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(s=e,e=void 0),s=s||{},s.path=s.path||"/socket.io",this.opts=s,Tu(this,s),this.reconnection(s.reconnection!==!1),this.reconnectionAttempts(s.reconnectionAttempts||1/0),this.reconnectionDelay(s.reconnectionDelay||1e3),this.reconnectionDelayMax(s.reconnectionDelayMax||5e3),this.randomizationFactor((i=s.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new ca({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(s.timeout==null?2e4:s.timeout),this._readyState="closed",this.uri=e;const o=s.parser||lA;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=s.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var s;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(s=this.backoff)===null||s===void 0||s.setMin(e),this)}randomizationFactor(e){var s;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(s=this.backoff)===null||s===void 0||s.setJitter(e),this)}reconnectionDelayMax(e){var s;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(s=this.backoff)===null||s===void 0||s.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new QO(this.uri,this.opts);const s=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const o=Wn(s,"open",function(){i.onopen(),e&&e()}),c=p=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",p),e?e(p):this.maybeReconnectOnOpen()},m=Wn(s,"error",c);if(this._timeout!==!1){const p=this._timeout,g=this.setTimeoutFn(()=>{o(),c(new Error("timeout")),s.close()},p);this.opts.autoUnref&&g.unref(),this.subs.push(()=>{this.clearTimeoutFn(g)})}return this.subs.push(o),this.subs.push(m),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Wn(e,"ping",this.onping.bind(this)),Wn(e,"data",this.ondata.bind(this)),Wn(e,"error",this.onerror.bind(this)),Wn(e,"close",this.onclose.bind(this)),Wn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(s){this.onclose("parse error",s)}}ondecoded(e){Nu(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,s){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new Qx(this,e,s),this.nsps[e]=i),i}_destroy(e){const s=Object.keys(this.nsps);for(const i of s)if(this.nsps[i].active)return;this._close()}_packet(e){const s=this.encoder.encode(e);for(let i=0;i<s.length;i++)this.engine.write(s[i],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,s){var i;this.cleanup(),(i=this.engine)===null||i===void 0||i.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,s),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const s=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},s);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const oo={};function lu(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const s=XO(n,e.path||"/socket.io"),i=s.source,o=s.id,c=s.path,m=oo[o]&&c in oo[o].nsps,p=e.forceNew||e["force new connection"]||e.multiplex===!1||m;let g;return p?g=new Hd(i,e):(oo[o]||(oo[o]=new Hd(i,e)),g=oo[o]),s.query&&!e.query&&(e.query=s.queryKey),g.socket(s.path,e)}Object.assign(lu,{Manager:Hd,Socket:Qx,io:lu,connect:lu});const uA=E.createContext({connected:!1,subscribe:()=>()=>{}});function fA({children:n}){const{isAuthenticated:e}=Lt(),s=E.useRef(null),[i,o]=E.useState(!1),c=E.useRef(new Map),m=E.useCallback((g,u)=>{var b;const d=c.current;return d.has(g)||(d.set(g,new Set),(b=s.current)==null||b.emit("lt.subscribe",g)),d.get(g).add(u),()=>{var v;const x=d.get(g);x&&(x.delete(u),x.size===0&&(d.delete(g),(v=s.current)==null||v.emit("lt.unsubscribe",g)))}},[]),p=E.useCallback((g,u)=>{for(const[d,b]of c.current)if(Lx(g,d))for(const x of b)try{x(u)}catch{}},[]);return E.useEffect(()=>{if(!e)return;const g=lu({path:`${Yt}/socket.io`,transports:["polling","websocket"],upgrade:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:2e3,auth:u=>{const d=wd();u(d?{token:d}:{})}});return s.current=g,console.log("[lt-socketio] connecting..."),g.on("connect",()=>{console.log("[lt-socketio] connected, id:",g.id),o(!0);for(const u of c.current.keys())g.emit("lt.subscribe",u)}),g.on("disconnect",u=>{console.log("[lt-socketio] disconnected:",u),o(!1)}),g.on("connect_error",u=>{console.warn("[lt-socketio] connect error:",u.message),o(!1)}),g.onAny((u,d)=>{if(u.startsWith("lt."))try{const b=typeof d=="string"?JSON.parse(d):d;p(u,b)}catch{}}),()=>{g.removeAllListeners(),g.disconnect(),s.current=null,o(!1)}},[p,e]),h.jsx(uA.Provider,{value:{connected:i,subscribe:m},children:h.jsx(la.Provider,{value:{connected:i,subscribe:m},children:n})})}function hA({children:n}){const{isAuthenticated:e}=Lt(),s=qe(),[i,o]=E.useState(null),[c,m]=E.useState({url:null,policy:Vg(null)});E.useEffect(()=>{let u=!1;async function d(){var b;try{console.log("[lt-transport] detecting event transport...");const x=await lm(),v=(b=x==null?void 0:x.events)==null?void 0:b.transport;console.log("[lt-transport] server reports:",v),u||(v==="nats"&&m({url:x.events.natsWsUrl??null,policy:Vg(x.events.reconnect)}),o(v==="nats"?"nats":"socketio"))}catch(x){console.warn("[lt-transport] settings fetch error, falling back to socketio",x),u||o("socketio")}}return d(),()=>{u=!0}},[e]);const p=E.useCallback(()=>uE(c.url),[c.url]),g=E.useCallback(()=>{s.invalidateQueries({refetchType:"active"})},[s]);return i==="nats"?h.jsx(yO,{resolveCredentials:p,policy:c.policy,onReconnect:g,sessionKey:e,children:n}):i==="socketio"?h.jsx(fA,{children:n}):h.jsx(h.Fragment,{children:n})}const wm="lt_view_as",Sm="lt_ai_override",Fd="lt_graph_enabled",Gd="lt_infrastructure_enabled",Em="lt_scan_override";function Xx(){try{const n=localStorage.getItem(Sm);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function dA(n){try{localStorage.setItem(Sm,String(n))}catch{}}function mA(){try{localStorage.removeItem(Sm)}catch{}}function Om(){try{const n=localStorage.getItem(wm);if(n==="admin"||n==="engineer"||n==="operator")return n}catch{}return null}function pA(n){try{localStorage.setItem(wm,n)}catch{}window.location.reload()}function Vd(){try{localStorage.removeItem(wm)}catch{}window.location.reload()}function Wx(){try{return localStorage.getItem(Fd)==="true"}catch{return!1}}function yA(n){try{n?localStorage.setItem(Fd,"true"):localStorage.removeItem(Fd)}catch{}}function Zx(){try{return localStorage.getItem(Gd)==="true"}catch{return!1}}function gA(n){try{n?localStorage.setItem(Gd,"true"):localStorage.removeItem(Gd)}catch{}}function ev(){try{const n=localStorage.getItem(Em);if(n==="true")return!0;if(n==="false")return!1}catch{}return null}function bA(n){try{localStorage.setItem(Em,String(n))}catch{}}function xA(){try{localStorage.removeItem(Em)}catch{}}function tv(){const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=Lt(),i=Om(),o=n||s("engineer"),c=e("admin"),m=n||e("admin"),p=i?!1:o,g=i?i==="admin"||i==="engineer":c,u=i?i==="admin":m;return{isBuilder:p,isOps:g,canBulk:u,canAdminister:u,viewAs:i,realIsBuilder:o}}function nv(){var u;const{isSuperAdmin:n,hasRoleType:e,hasRole:s}=Lt(),{data:i}=Hn(),o=((u=i==null?void 0:i.features)==null?void 0:u.publicPaceBoard)!==!1,c=n?"superadmin":e("admin")?"admin":s("engineer")?"engineer":"operator",m=Om(),p=m==="admin"||m==="engineer"||m==="operator"?m:null,g=p??c;return{tier:g,realTier:c,viewAs:p,canSeePaceBoard:o||g==="superadmin"||g==="admin",canSeeWorkflows:g==="superadmin"||g==="engineer",showTaskQueueCards:g==="operator"&&!o}}const Am=E.createContext(null);function Cu(){const n=E.useContext(Am);if(!n)throw new Error("useActingIdentity must be used within ActingIdentityProvider");return n}function vA(){var n;return((n=E.useContext(Am))==null?void 0:n.identity)??null}function _A({children:n}){const[e,s]=E.useState(null),i=E.useRef(e);i.current=e,E.useEffect(()=>{if(!(e!=null&&e.expiresAt))return;const d=new Date(e.expiresAt).getTime()-Date.now();if(d<=0){s(null);return}const b=setTimeout(()=>s(null),d);return()=>clearTimeout(b)},[e]);const o=E.useCallback(d=>{var x;if(!d.actingToken||!d.actor)return null;const b=((x=i.current)==null?void 0:x.actingToken)??null;return s({actingToken:d.actingToken,actorId:d.actor.id,displayName:d.actor.displayName,expiresAt:d.expiresAt??null,subjectScoped:d.grantScope==="subject"}),b},[]),c=E.useCallback(()=>s(null),[]),m=E.useCallback((d,b)=>{const x=i.current;b===0&&(x==null?void 0:x.actingToken)===d&&s(null)},[]),p=E.useCallback((d,b)=>{const x=i.current;if(!x||x.actingToken!==d||!b.acting)return;const{consumed:v,remaining:_,bound:S}=b.acting;(v&&_===0||S&&b.clearSubject)&&s(null)},[]);E.useEffect(()=>(Ig(()=>{var d;return((d=i.current)==null?void 0:d.actingToken)??null}),Hg(c),$g(m),()=>{Ig(null),Hg(null),$g(null)}),[c,m]);const g=E.useCallback(()=>{var b;const d=(b=i.current)==null?void 0:b.expiresAt;return d?Math.max(0,Math.floor((new Date(d).getTime()-Date.now())/1e3)):0},[]),u=E.useMemo(()=>({identity:e,prime:o,clear:c,settle:p,remainingSeconds:g}),[e,o,c,p,g]);return h.jsx(Am.Provider,{value:u,children:n})}function wA(){const{user:n}=Lt(),{identity:e}=Cu(),s=n==null?void 0:n.userId,i=e==null?void 0:e.actorId,o=E.useCallback(c=>!!c&&(c===i||c===s),[i,s]);return{viewerId:i??s,isViewer:o}}function rv(n){return(n??"").replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"none"}function fr(n={}){const e=n.role?rv(n.role):"*",s=n.id??"*",i=n.verb??">";return`${Wt}.system.escalation.${e}.${s}.${i}`}function Yd(n){return n.verbs.map(e=>fr({role:n.role,verb:e}))}function jm(n){const{user:e,isSuperAdmin:s,hasRoleType:i}=Lt(),o=s||i("admin"),c=((e==null?void 0:e.roles)??[]).map(p=>p.role).sort().join(","),m=(n??[]).join(",");return E.useMemo(()=>{const p=m?m.split(","):null;return o||!c?p?Yd({verbs:p}):[fr({})]:c.split(",").flatMap(g=>p?Yd({role:g,verbs:p}):[fr({role:g})])},[o,c,m])}const Kd="/escalations/detail/";function SA(n){return n.startsWith(Kd)&&n.slice(Kd.length).split("/")[0]||void 0}function EA(){const{isViewer:n}=wA(),e=ni(),s=tn(),i=E.useRef(s.pathname);i.current=s.pathname;const o=E.useRef(n);o.current=n;const c=E.useCallback(m=>{var b,x,v;if((m==null?void 0:m.assignedAtCreation)!==!0)return;const p=(m==null?void 0:m.escalationId)??((b=m==null?void 0:m.data)==null?void 0:b.id),g=(x=m==null?void 0:m.data)==null?void 0:x.assigned_to,u=(v=m==null?void 0:m.data)==null?void 0:v.parent_id;if(!p||!o.current(g)||!u||u!==SA(i.current))return;const d=`${Kd}${p}`;i.current!==d&&e(d)},[e]);ks(jm(["claimed"]),c)}const sv=6048e5,OA=864e5,wb=6e4,Sb=525600,Eb=43200,Ob=1440,Ab=Symbol.for("constructDateFrom");function Br(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&Ab in n?n[Ab](e):n instanceof Date?new n.constructor(e):new Date(e)}function kn(n,e){return Br(e||n,n)}let AA={};function Lo(){return AA}function To(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.weekStartsOn)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.weekStartsOn)??s.weekStartsOn??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=kn(n,e==null?void 0:e.in),c=o.getDay(),m=(c<i?7:0)+c-i;return o.setDate(o.getDate()-m),o.setHours(0,0,0,0),o}function bu(n,e){return To(n,{...e,weekStartsOn:1})}function iv(n,e){const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Br(s,0);o.setFullYear(i+1,0,4),o.setHours(0,0,0,0);const c=bu(o),m=Br(s,0);m.setFullYear(i,0,4),m.setHours(0,0,0,0);const p=bu(m);return s.getTime()>=c.getTime()?i+1:s.getTime()>=p.getTime()?i:i-1}function xu(n){const e=kn(n),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+n-+s}function av(n,...e){const s=Br.bind(null,n||e.find(i=>typeof i=="object"));return e.map(s)}function jb(n,e){const s=kn(n,e==null?void 0:e.in);return s.setHours(0,0,0,0),s}function jA(n,e,s){const[i,o]=av(s==null?void 0:s.in,n,e),c=jb(i),m=jb(o),p=+c-xu(c),g=+m-xu(m);return Math.round((p-g)/OA)}function kA(n,e){const s=iv(n,e),i=Br(n,0);return i.setFullYear(s,0,4),i.setHours(0,0,0,0),bu(i)}function NA(n,e){const s=+kn(n)-+kn(e);return s<0?-1:s>0?1:s}function TA(n){return Br(n,Date.now())}function CA(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function MA(n){return!(!CA(n)&&typeof n!="number"||isNaN(+kn(n)))}function RA(n){return e=>{const i=(n?Math[n]:Math.trunc)(e);return i===0?0:i}}function DA(n,e){const s=kn(n,e==null?void 0:e.in);return s.setFullYear(s.getFullYear(),0,1),s.setHours(0,0,0,0),s}const LA={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"}},qA=(n,e,s)=>{let i;const o=LA[n];return typeof o=="string"?i=o:e===1?i=o.one:i=o.other.replace("{{count}}",e.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+i:i+" ago":i};function cd(n){return(e={})=>{const s=e.width?String(e.width):n.defaultWidth;return n.formats[s]||n.formats[n.defaultWidth]}}const PA={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},BA={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},UA={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zA={date:cd({formats:PA,defaultWidth:"full"}),time:cd({formats:BA,defaultWidth:"full"}),dateTime:cd({formats:UA,defaultWidth:"full"})},IA={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$A=(n,e,s,i)=>IA[n];function lo(n){return(e,s)=>{const i=s!=null&&s.context?String(s.context):"standalone";let o;if(i==="formatting"&&n.formattingValues){const m=n.defaultFormattingWidth||n.defaultWidth,p=s!=null&&s.width?String(s.width):m;o=n.formattingValues[p]||n.formattingValues[m]}else{const m=n.defaultWidth,p=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[p]||n.values[m]}const c=n.argumentCallback?n.argumentCallback(e):e;return o[c]}}const HA={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},FA={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},GA={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"]},VA={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"]},YA={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"}},KA={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"}},JA=(n,e)=>{const s=Number(n),i=s%100;if(i>20||i<10)switch(i%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},QA={ordinalNumber:JA,era:lo({values:HA,defaultWidth:"wide"}),quarter:lo({values:FA,defaultWidth:"wide",argumentCallback:n=>n-1}),month:lo({values:GA,defaultWidth:"wide"}),day:lo({values:VA,defaultWidth:"wide"}),dayPeriod:lo({values:YA,defaultWidth:"wide",formattingValues:KA,defaultFormattingWidth:"wide"})};function co(n){return(e,s={})=>{const i=s.width,o=i&&n.matchPatterns[i]||n.matchPatterns[n.defaultMatchWidth],c=e.match(o);if(!c)return null;const m=c[0],p=i&&n.parsePatterns[i]||n.parsePatterns[n.defaultParseWidth],g=Array.isArray(p)?WA(p,b=>b.test(m)):XA(p,b=>b.test(m));let u;u=n.valueCallback?n.valueCallback(g):g,u=s.valueCallback?s.valueCallback(u):u;const d=e.slice(m.length);return{value:u,rest:d}}}function XA(n,e){for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)&&e(n[s]))return s}function WA(n,e){for(let s=0;s<n.length;s++)if(e(n[s]))return s}function ZA(n){return(e,s={})=>{const i=e.match(n.matchPattern);if(!i)return null;const o=i[0],c=e.match(n.parsePattern);if(!c)return null;let m=n.valueCallback?n.valueCallback(c[0]):c[0];m=s.valueCallback?s.valueCallback(m):m;const p=e.slice(o.length);return{value:m,rest:p}}}const ej=/^(\d+)(th|st|nd|rd)?/i,tj=/\d+/i,nj={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},rj={any:[/^b/i,/^(a|c)/i]},sj={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ij={any:[/1/i,/2/i,/3/i,/4/i]},aj={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},oj={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]},lj={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},cj={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]},uj={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},fj={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}},hj={ordinalNumber:ZA({matchPattern:ej,parsePattern:tj,valueCallback:n=>parseInt(n,10)}),era:co({matchPatterns:nj,defaultMatchWidth:"wide",parsePatterns:rj,defaultParseWidth:"any"}),quarter:co({matchPatterns:sj,defaultMatchWidth:"wide",parsePatterns:ij,defaultParseWidth:"any",valueCallback:n=>n+1}),month:co({matchPatterns:aj,defaultMatchWidth:"wide",parsePatterns:oj,defaultParseWidth:"any"}),day:co({matchPatterns:lj,defaultMatchWidth:"wide",parsePatterns:cj,defaultParseWidth:"any"}),dayPeriod:co({matchPatterns:uj,defaultMatchWidth:"any",parsePatterns:fj,defaultParseWidth:"any"})},ov={code:"en-US",formatDistance:qA,formatLong:zA,formatRelative:$A,localize:QA,match:hj,options:{weekStartsOn:0,firstWeekContainsDate:1}};function dj(n,e){const s=kn(n,e==null?void 0:e.in);return jA(s,DA(s))+1}function mj(n,e){const s=kn(n,e==null?void 0:e.in),i=+bu(s)-+kA(s);return Math.round(i/sv)+1}function lv(n,e){var d,b,x,v;const s=kn(n,e==null?void 0:e.in),i=s.getFullYear(),o=Lo(),c=(e==null?void 0:e.firstWeekContainsDate)??((b=(d=e==null?void 0:e.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??o.firstWeekContainsDate??((v=(x=o.locale)==null?void 0:x.options)==null?void 0:v.firstWeekContainsDate)??1,m=Br((e==null?void 0:e.in)||n,0);m.setFullYear(i+1,0,c),m.setHours(0,0,0,0);const p=To(m,e),g=Br((e==null?void 0:e.in)||n,0);g.setFullYear(i,0,c),g.setHours(0,0,0,0);const u=To(g,e);return+s>=+p?i+1:+s>=+u?i:i-1}function pj(n,e){var p,g,u,d;const s=Lo(),i=(e==null?void 0:e.firstWeekContainsDate)??((g=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??s.firstWeekContainsDate??((d=(u=s.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=lv(n,e),c=Br((e==null?void 0:e.in)||n,0);return c.setFullYear(o,0,i),c.setHours(0,0,0,0),To(c,e)}function yj(n,e){const s=kn(n,e==null?void 0:e.in),i=+To(s,e)-+pj(s,e);return Math.round(i/sv)+1}function et(n,e){const s=n<0?"-":"",i=Math.abs(n).toString().padStart(e,"0");return s+i}const ys={y(n,e){const s=n.getFullYear(),i=s>0?s:1-s;return et(e==="yy"?i%100:i,e.length)},M(n,e){const s=n.getMonth();return e==="M"?String(s+1):et(s+1,2)},d(n,e){return et(n.getDate(),e.length)},a(n,e){const s=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(n,e){return et(n.getHours()%12||12,e.length)},H(n,e){return et(n.getHours(),e.length)},m(n,e){return et(n.getMinutes(),e.length)},s(n,e){return et(n.getSeconds(),e.length)},S(n,e){const s=e.length,i=n.getMilliseconds(),o=Math.trunc(i*Math.pow(10,s-3));return et(o,e.length)}},Hi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},kb={G:function(n,e,s){const i=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return s.era(i,{width:"abbreviated"});case"GGGGG":return s.era(i,{width:"narrow"});case"GGGG":default:return s.era(i,{width:"wide"})}},y:function(n,e,s){if(e==="yo"){const i=n.getFullYear(),o=i>0?i:1-i;return s.ordinalNumber(o,{unit:"year"})}return ys.y(n,e)},Y:function(n,e,s,i){const o=lv(n,i),c=o>0?o:1-o;if(e==="YY"){const m=c%100;return et(m,2)}return e==="Yo"?s.ordinalNumber(c,{unit:"year"}):et(c,e.length)},R:function(n,e){const s=iv(n);return et(s,e.length)},u:function(n,e){const s=n.getFullYear();return et(s,e.length)},Q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(i);case"QQ":return et(i,2);case"Qo":return s.ordinalNumber(i,{unit:"quarter"});case"QQQ":return s.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(i,{width:"wide",context:"formatting"})}},q:function(n,e,s){const i=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(i);case"qq":return et(i,2);case"qo":return s.ordinalNumber(i,{unit:"quarter"});case"qqq":return s.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(i,{width:"wide",context:"standalone"})}},M:function(n,e,s){const i=n.getMonth();switch(e){case"M":case"MM":return ys.M(n,e);case"Mo":return s.ordinalNumber(i+1,{unit:"month"});case"MMM":return s.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(i,{width:"wide",context:"formatting"})}},L:function(n,e,s){const i=n.getMonth();switch(e){case"L":return String(i+1);case"LL":return et(i+1,2);case"Lo":return s.ordinalNumber(i+1,{unit:"month"});case"LLL":return s.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(i,{width:"wide",context:"standalone"})}},w:function(n,e,s,i){const o=yj(n,i);return e==="wo"?s.ordinalNumber(o,{unit:"week"}):et(o,e.length)},I:function(n,e,s){const i=mj(n);return e==="Io"?s.ordinalNumber(i,{unit:"week"}):et(i,e.length)},d:function(n,e,s){return e==="do"?s.ordinalNumber(n.getDate(),{unit:"date"}):ys.d(n,e)},D:function(n,e,s){const i=dj(n);return e==="Do"?s.ordinalNumber(i,{unit:"dayOfYear"}):et(i,e.length)},E:function(n,e,s){const i=n.getDay();switch(e){case"E":case"EE":case"EEE":return s.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(i,{width:"short",context:"formatting"});case"EEEE":default:return s.day(i,{width:"wide",context:"formatting"})}},e:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"e":return String(c);case"ee":return et(c,2);case"eo":return s.ordinalNumber(c,{unit:"day"});case"eee":return s.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(o,{width:"short",context:"formatting"});case"eeee":default:return s.day(o,{width:"wide",context:"formatting"})}},c:function(n,e,s,i){const o=n.getDay(),c=(o-i.weekStartsOn+8)%7||7;switch(e){case"c":return String(c);case"cc":return et(c,e.length);case"co":return s.ordinalNumber(c,{unit:"day"});case"ccc":return s.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(o,{width:"narrow",context:"standalone"});case"cccccc":return s.day(o,{width:"short",context:"standalone"});case"cccc":default:return s.day(o,{width:"wide",context:"standalone"})}},i:function(n,e,s){const i=n.getDay(),o=i===0?7:i;switch(e){case"i":return String(o);case"ii":return et(o,e.length);case"io":return s.ordinalNumber(o,{unit:"day"});case"iii":return s.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(i,{width:"short",context:"formatting"});case"iiii":default:return s.day(i,{width:"wide",context:"formatting"})}},a:function(n,e,s){const o=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(n,e,s){const i=n.getHours();let o;switch(i===12?o=Hi.noon:i===0?o=Hi.midnight:o=i/12>=1?"pm":"am",e){case"b":case"bb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(n,e,s){const i=n.getHours();let o;switch(i>=17?o=Hi.evening:i>=12?o=Hi.afternoon:i>=4?o=Hi.morning:o=Hi.night,e){case"B":case"BB":case"BBB":return s.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(n,e,s){if(e==="ho"){let i=n.getHours()%12;return i===0&&(i=12),s.ordinalNumber(i,{unit:"hour"})}return ys.h(n,e)},H:function(n,e,s){return e==="Ho"?s.ordinalNumber(n.getHours(),{unit:"hour"}):ys.H(n,e)},K:function(n,e,s){const i=n.getHours()%12;return e==="Ko"?s.ordinalNumber(i,{unit:"hour"}):et(i,e.length)},k:function(n,e,s){let i=n.getHours();return i===0&&(i=24),e==="ko"?s.ordinalNumber(i,{unit:"hour"}):et(i,e.length)},m:function(n,e,s){return e==="mo"?s.ordinalNumber(n.getMinutes(),{unit:"minute"}):ys.m(n,e)},s:function(n,e,s){return e==="so"?s.ordinalNumber(n.getSeconds(),{unit:"second"}):ys.s(n,e)},S:function(n,e){return ys.S(n,e)},X:function(n,e,s){const i=n.getTimezoneOffset();if(i===0)return"Z";switch(e){case"X":return Tb(i);case"XXXX":case"XX":return Zs(i);case"XXXXX":case"XXX":default:return Zs(i,":")}},x:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"x":return Tb(i);case"xxxx":case"xx":return Zs(i);case"xxxxx":case"xxx":default:return Zs(i,":")}},O:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Nb(i,":");case"OOOO":default:return"GMT"+Zs(i,":")}},z:function(n,e,s){const i=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Nb(i,":");case"zzzz":default:return"GMT"+Zs(i,":")}},t:function(n,e,s){const i=Math.trunc(+n/1e3);return et(i,e.length)},T:function(n,e,s){return et(+n,e.length)}};function Nb(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=Math.trunc(i/60),c=i%60;return c===0?s+String(o):s+String(o)+e+et(c,2)}function Tb(n,e){return n%60===0?(n>0?"-":"+")+et(Math.abs(n)/60,2):Zs(n,e)}function Zs(n,e=""){const s=n>0?"-":"+",i=Math.abs(n),o=et(Math.trunc(i/60),2),c=et(i%60,2);return s+o+e+c}const Cb=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},cv=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},gj=(n,e)=>{const s=n.match(/(P+)(p+)?/)||[],i=s[1],o=s[2];if(!o)return Cb(n,e);let c;switch(i){case"P":c=e.dateTime({width:"short"});break;case"PP":c=e.dateTime({width:"medium"});break;case"PPP":c=e.dateTime({width:"long"});break;case"PPPP":default:c=e.dateTime({width:"full"});break}return c.replace("{{date}}",Cb(i,e)).replace("{{time}}",cv(o,e))},bj={p:cv,P:gj},xj=/^D+$/,vj=/^Y+$/,_j=["D","DD","YY","YYYY"];function wj(n){return xj.test(n)}function Sj(n){return vj.test(n)}function Ej(n,e,s){const i=Oj(n,e,s);if(console.warn(i),_j.includes(n))throw new RangeError(i)}function Oj(n,e,s){const i=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${i} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Aj=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,jj=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,kj=/^'([^]*?)'?$/,Nj=/''/g,Tj=/[a-zA-Z]/;function Cj(n,e,s){var d,b,x,v;const i=Lo(),o=i.locale??ov,c=i.firstWeekContainsDate??((b=(d=i.locale)==null?void 0:d.options)==null?void 0:b.firstWeekContainsDate)??1,m=i.weekStartsOn??((v=(x=i.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??0,p=kn(n,s==null?void 0:s.in);if(!MA(p))throw new RangeError("Invalid time value");let g=e.match(jj).map(_=>{const S=_[0];if(S==="p"||S==="P"){const C=bj[S];return C(_,o.formatLong)}return _}).join("").match(Aj).map(_=>{if(_==="''")return{isToken:!1,value:"'"};const S=_[0];if(S==="'")return{isToken:!1,value:Mj(_)};if(kb[S])return{isToken:!0,value:_};if(S.match(Tj))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:_}});o.localize.preprocessor&&(g=o.localize.preprocessor(p,g));const u={firstWeekContainsDate:c,weekStartsOn:m,locale:o};return g.map(_=>{if(!_.isToken)return _.value;const S=_.value;(Sj(S)||wj(S))&&Ej(S,e,String(n));const C=kb[S[0]];return C(p,S,o.localize,u)}).join("")}function Mj(n){const e=n.match(kj);return e?e[1].replace(Nj,"'"):n}function Rj(n,e,s){const i=Lo(),o=(s==null?void 0:s.locale)??i.locale??ov,c=NA(n,e);if(isNaN(c))throw new RangeError("Invalid time value");const m=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:c}),[p,g]=av(s==null?void 0:s.in,...c>0?[e,n]:[n,e]),u=RA((s==null?void 0:s.roundingMethod)??"round"),d=g.getTime()-p.getTime(),b=d/wb,x=xu(g)-xu(p),v=(d-x)/wb,_=s==null?void 0:s.unit;let S;if(_?S=_:b<1?S="second":b<60?S="minute":b<Ob?S="hour":v<Eb?S="day":v<Sb?S="month":S="year",S==="second"){const C=u(d/1e3);return o.formatDistance("xSeconds",C,m)}else if(S==="minute"){const C=u(b);return o.formatDistance("xMinutes",C,m)}else if(S==="hour"){const C=u(b/60);return o.formatDistance("xHours",C,m)}else if(S==="day"){const C=u(v/Ob);return o.formatDistance("xDays",C,m)}else if(S==="month"){const C=u(v/Eb);return C===12&&_!=="month"?o.formatDistance("xYears",1,m):o.formatDistance("xMonths",C,m)}else{const C=u(v/Sb);return o.formatDistance("xYears",C,m)}}function Dj(n,e){return Rj(n,TA(n),e)}let vu=null;function Lj(n){vu=n||null}function qj(){return vu}function Pj(n,e,s){const i=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...s?{second:"2-digit"}:{},hour12:!0}).formatToParts(n);return Object.fromEntries(i.map(o=>[o.type,o.value]))}function km(n,e=!1){const s=typeof n=="string"?new Date(n):n;if(Number.isNaN(s.getTime()))return String(n);if(!vu)return Cj(s,e?"MMM d, yyyy h:mm:ss a":"MMM d, yyyy h:mm a");const i=Pj(s,vu,e),o=`${i.hour}:${i.minute}${e?`:${i.second}`:""}`;return`${i.month} ${i.day}, ${i.year} ${o} ${i.dayPeriod}`}function uv(n){const e=n??[];return e.length>0&&e.every(s=>s.type==="member"&&s.write_scope==="none")}function v5(n,e,s){return!e||!uv(n)?!0:!!s&&!s.subjectScoped}const Nm={staleTime:5*6e4,refetchOnWindowFocus:!1};function _5(n={},e={}){const s=new URLSearchParams;return n.role&&s.set("role",n.role),n.roleType&&s.set("roleType",n.roleType),n.status&&s.set("status",n.status),n.search&&s.set("search",n.search),n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),Le({queryKey:["users",n],queryFn:()=>ue(`/users?${s}`),enabled:e.enabled??!0,...Nm})}const Mb=200;async function Bj(n){const e=[];for(let s=0;s<n.length;s+=Mb){const i=await ue("/users/names",{method:"POST",body:JSON.stringify({ids:n.slice(s,s+Mb)})});e.push(...i.users??[])}return e}let Jd=[],Qd=new Map,Xd=!1;function Uj(){const n=Jd,e=Qd;Jd=[],Qd=new Map,Xd=!1,Bj(n).then(s=>{const i=new Map(s.map(o=>[o.id,o]));for(const[o,c]of e)c.resolve(i.get(o)??null)}).catch(s=>{for(const i of e.values())i.reject(s)})}function zj(n){return new Promise((e,s)=>{Jd.push(n),Qd.set(n,{resolve:e,reject:s}),Xd||(Xd=!0,setTimeout(Uj,0))})}function w5(n){return Le({queryKey:["user-name",n],queryFn:()=>zj(n),enabled:!!n,...Nm})}function Ij(n){return Le({queryKey:["users",n,"roles"],queryFn:async()=>(await ue(`/users/${n}/roles`)).roles??[],enabled:!!n,...Nm})}function S5(){const n=qe();return Ie({mutationFn:e=>ue("/users",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function E5(){const n=qe();return Ie({mutationFn:({id:e,...s})=>ue(`/users/${e}`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function O5(){const n=qe();return Ie({mutationFn:({id:e,ops:s})=>ue(`/users/${e}/properties`,{method:"PATCH",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function A5(){return Le({queryKey:["users","system-property-keys"],queryFn:()=>ue("/users/system-property-keys")})}function j5(){const n=qe();return Ie({mutationFn:e=>ue(`/users/${e}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function k5(){const n=qe();return Ie({mutationFn:({userId:e,role:s,type:i,read_scope:o,write_scope:c})=>ue(`/users/${e}/roles`,{method:"POST",body:JSON.stringify({role:s,type:i,read_scope:o,write_scope:c})}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}function N5(){const n=qe();return Ie({mutationFn:({userId:e,role:s})=>ue(`/users/${e}/roles/${encodeURIComponent(s)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["users"]})}})}const T5={MAX_PORTALS:12,MAX_ROWS:4,MAX_COLS:6,MAX_COUNTS:8};function $j(){return Le({queryKey:["roles"],queryFn:()=>ue("/roles")})}function Mu(n){return Le({queryKey:["roles","details"],queryFn:()=>ue("/roles/details"),enabled:(n==null?void 0:n.enabled)??!0})}function C5(n,e,s=!0){return Le({queryKey:["roles",n,"schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function M5(n){return Le({queryKey:["roles",n,"schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/schema/versions`),enabled:!!n})}function R5(n,e,s=!0){return Le({queryKey:["roles",n,"list-schema",e??"latest"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema${e!=null?`?version=${e}`:""}`),enabled:s&&!!n})}function D5(n){return Le({queryKey:["roles",n,"list-schema-versions"],queryFn:()=>ue(`/roles/${encodeURIComponent(n)}/list-schema/versions`),enabled:!!n})}function L5(){const n=qe();return Ie({mutationFn:e=>ue("/roles",{method:"POST",body:JSON.stringify({role:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function q5(){const n=qe();return Ie({mutationFn:({role:e,...s})=>ue(`/roles/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(s)}),onMutate:async({role:e,...s})=>{await n.cancelQueries({queryKey:["roles","details"]});const i=n.getQueryData(["roles","details"]);return i&&n.setQueryData(["roles","details"],{roles:i.roles.map(o=>o.role===e?{...o,...s}:o)}),{previous:i}},onError:(e,s,i)=>{i!=null&&i.previous&&n.setQueryData(["roles","details"],i.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}function P5(){const n=qe();return Ie({mutationFn:e=>ue(`/roles/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["roles"]})}})}const fv="lt:station:kiosk-role:";function Wd(n){return`${fv}${n}`}const Zd=new Set;function Hj(){for(const n of Zd)n()}function Fj(n){try{return localStorage.getItem(Wd(n))}catch{return null}}function Gj(n,e){try{e===null?localStorage.removeItem(Wd(n)):localStorage.setItem(Wd(n),e)}catch{}Hj()}function Vj(n){Zd.add(n);const e=s=>{(s.key===null||s.key.startsWith(fv))&&n()};try{window.addEventListener("storage",e)}catch{}return()=>{Zd.delete(n);try{window.removeEventListener("storage",e)}catch{}}}function Yj(n){return E.useSyncExternalStore(Vj,()=>n?Fj(n):null)}const _u="/portal";function Kj(n){return n===_u||n.startsWith(`${_u}/`)}function Tm(n,e){const s=`${_u}/${encodeURIComponent(n)}`;return e?`${s}/${encodeURIComponent(e)}`:s}function ta(n){return Array.isArray(n==null?void 0:n.portals)?n.portals:[]}function Jj(n){return ta(n).length>0}function B5(n,e){const s=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"portal",i=new Set(e);if(!i.has(s))return s;let o=2;for(;i.has(`${s}-${o}`);)o+=1;return`${s}-${o}`}function hv(n,e){return e.length>0?Tm(n,e[0].key):`/escalations/available?role=${encodeURIComponent(n)}&status=available`}function Cm(){const{user:n}=Lt(),e=(n==null?void 0:n.userId)??null,{data:s}=Ij(e),{data:i}=Mu(),o=Yj(e),c=E.useCallback(m=>{e&&Gj(e,m)},[e]);return E.useMemo(()=>{const m={kiosk:!1,role:null,homePath:null,targets:[],selectable:!1,selectRole:c},p=s??[];if(p.length===0||p.some(v=>v.type!=="member"))return m;const g=v=>{var _;return(_=i==null?void 0:i.roles)==null?void 0:_.find(S=>S.role===v)},u=v=>{var _,S;return((S=(_=g(v))==null?void 0:_.properties)==null?void 0:S.kiosk)===!0},d=p.map(v=>v.role).filter(u),b=v=>({kiosk:!0,role:v,homePath:hv(v,ta(g(v))),targets:d,selectable:d.length>=2,selectRole:c});if(p.length===1)return d.length===1?b(d[0]):m;if(!uv(p)||d.length===0)return m;const x=o&&d.includes(o)?o:d.length===1?d[0]:null;return x?b(x):{...m,targets:d,selectable:!0}},[s,i,o,c])}const Qj="/escalations/available",Xj=["/escalations",_u,"/scan","/login"];function Wj(n,e=""){if(n===Qj){const s=new URLSearchParams(e);if(!s.get("role")&&!s.get("facets"))return!1}return Xj.some(s=>n===s||n.startsWith(`${s}/`)||n.startsWith(`${s}?`))}const Mm=E.createContext(null),ud="lt_sidebar_collapsed",dv="(max-width: 1023px)";function Zj(){try{return window.matchMedia(dv).matches}catch{return!1}}function ek({children:n}){const[e,s]=E.useState(()=>{if(Zj())return!0;try{return localStorage.getItem(ud)==="true"}catch{return!1}});E.useEffect(()=>{let o;try{o=window.matchMedia(dv)}catch{return}const c=m=>{if(m.matches)s(!0);else try{s(localStorage.getItem(ud)==="true")}catch{s(!1)}};return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[]);const i=E.useCallback(()=>{s(o=>{const c=!o;try{localStorage.setItem(ud,String(c))}catch{}return c})},[]);return h.jsx(Mm.Provider,{value:{collapsed:e,toggle:i},children:n})}function tk({children:n}){return h.jsx(Mm.Provider,{value:{collapsed:!1,toggle:()=>{}},children:n})}function Rm(){const n=E.useContext(Mm);if(!n)throw new Error("useSidebar must be used within SidebarProvider");return n}const Rb=380,Dm=E.createContext(null);function nk({children:n}){const[e,s]=E.useState({node:null,width:Rb,open:!1,ownerKey:null}),i=tn(),o=E.useRef(i.pathname),c=E.useCallback((p,g)=>{s({node:p,width:(g==null?void 0:g.width)??Rb,open:!0,ownerKey:(g==null?void 0:g.key)??null})},[]),m=E.useCallback(p=>{s(g=>typeof p=="string"&&g.ownerKey!==p?g:{...g,open:!1})},[]);return E.useEffect(()=>{i.pathname!==o.current&&(o.current=i.pathname,s(p=>p.open||p.node?{...p,node:null,open:!1,ownerKey:null}:p))},[i.pathname]),h.jsx(Dm.Provider,{value:{...e,setPanel:c,closePanel:m},children:n})}function Lm(){const n=E.useContext(Dm);if(!n)throw new Error("useShellPanel must be used within ShellPanelProvider");return n}function U5(){return E.useContext(Dm)}function rk({open:n,width:e=380,children:s,className:i=""}){const[o,c]=E.useState(n);return E.useEffect(()=>{n&&c(!0)},[n]),h.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${i}`,style:{width:n?e:0,maxWidth:"50%"},onTransitionEnd:m=>{!n&&m.propertyName==="width"&&c(!1)},children:h.jsx("div",{style:{width:e},className:"h-full",children:o?s:null})})}function z5({label:n,children:e}){return h.jsxs("div",{children:[h.jsx("dt",{className:"text-2xs font-medium text-text-secondary uppercase tracking-wide",children:n}),h.jsx("dd",{className:"text-xs text-text-primary mt-0.5",children:e})]})}function I5({views:n,activeId:e,onViewChange:s,onClose:i,headerActions:o,stickyClassName:c,labelInline:m}){const p=n.find(g=>g.id===e)??n[0];return p?h.jsx("div",{className:"h-full bg-surface-hover",children:h.jsxs("div",{className:`flex flex-col ${c??"sticky top-0 z-10 max-h-[calc(100vh-3.5rem)]"}`,children:[h.jsxs("div",{className:`flex items-center justify-between pl-4 pr-3 shrink-0 ${m?"pt-10 pb-2":"pt-3"}`,children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1 shrink-0",role:"radiogroup","aria-label":"Panel view",children:n.map(g=>{const u=g.icon,d=g.id===p.id;return h.jsx("button",{role:"radio","aria-checked":d,onClick:()=>s(g.id),title:g.label,className:`p-1.5 rounded-md transition-colors ${d?"bg-accent/10 text-accent":"text-accent/60 hover:text-accent hover:bg-surface-hover"}`,children:h.jsx(u,{className:"w-3.5 h-3.5"})},g.id)})}),m&&h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-secondary truncate",children:p.label})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o,i&&h.jsx("button",{onClick:i,title:"Close panel",className:"p-1 rounded text-accent/60 hover:text-accent hover:bg-surface-hover transition-colors",children:h.jsx(en,{className:"w-3.5 h-3.5"})})]})]}),!m&&h.jsx("p",{className:"px-5 pt-2 pb-1 text-2xs font-semibold uppercase tracking-widest text-text-secondary shrink-0",children:p.label}),h.jsx("div",{className:`flex-1 overflow-y-auto px-5 ${m?"pt-4 pb-8":"pb-5 pt-1"}`,children:p.content})]})}):null}function mv(n,e){var s,i,o,c,m;e.facets&&Object.keys(e.facets).length&&n.set("facets",JSON.stringify(e.facets)),(s=e.block)!=null&&s.length&&n.set("block",JSON.stringify(e.block)),(i=e.range)!=null&&i.length&&n.set("range",JSON.stringify(e.range)),(o=e.exists)!=null&&o.length&&n.set("exists",JSON.stringify(e.exists)),(c=e.roles)!=null&&c.length&&n.set("roles",JSON.stringify(e.roles)),(m=e.orderBy)!=null&&m.length&&n.set("orderBy",JSON.stringify(e.orderBy)),e.available!==void 0&&n.set("available",String(e.available)),e.jeopardy===!0&&n.set("jeopardy","1"),e.include&&n.set("include",e.include),e.groupBy&&n.set("groupBy",e.groupBy)}function $5(n,e,s){const i=n??"24h",o=e&&Object.keys(e).length?JSON.stringify(e):null;return Le({queryKey:["stationMetrics",i,o],queryFn:()=>ue(`/escalations/station-metrics?period=${i}${o?`&facets=${encodeURIComponent(o)}`:""}`),staleTime:5e3,enabled:(s==null?void 0:s.enabled)??!0})}function H5(n){const e=n?`?period=${n}`:"";return Le({queryKey:["escalationStats",n],queryFn:()=>ue(`/escalations/stats${e}`)})}function F5(){return Le({queryKey:["escalationTypes"],queryFn:()=>ue("/escalations/types")})}function G5(n=!0){return Le({queryKey:["escalationFacetKeys"],queryFn:()=>ue("/escalations/facet-keys"),enabled:n,staleTime:6e4})}function sk(n){return Le({queryKey:["escalationFacetValues",n],queryFn:()=>ue(`/escalations/facet-values?key=${encodeURIComponent(n)}`),enabled:!!n,staleTime:6e4})}function ik(n){const e=new URLSearchParams;return n.status&&e.set("status",n.status),n.role&&e.set("role",n.role),n.type&&e.set("type",n.type),n.subtype&&e.set("subtype",n.subtype),n.assigned_to&&e.set("assigned_to",n.assigned_to),n.parent_id&&e.set("parent_id",n.parent_id),n.claimed&&e.set("claimed","true"),n.priority&&e.set("priority",String(n.priority)),n.limit&&e.set("limit",String(n.limit)),n.offset!==void 0&&e.set("offset",String(n.offset)),n.sort_by&&e.set("sort_by",n.sort_by),n.order&&e.set("order",n.order),n.search&&e.set("search",n.search),mv(e,n),e}function ak(n){return{queryKey:["escalations",n],queryFn:()=>ue(`/escalations?${ik(n)}`)}}function pv(n){const{enabled:e=!0,staleTime:s,...i}=n;return Le({...ak(i),enabled:e,...s!==void 0?{staleTime:s}:{}})}function yv(n){const{enabled:e=!0,staleTime:s,...i}=n,o=new URLSearchParams;return i.role&&o.set("role",i.role),i.type&&o.set("type",i.type),i.subtype&&o.set("subtype",i.subtype),i.priority&&o.set("priority",String(i.priority)),i.limit&&o.set("limit",String(i.limit)),i.offset!==void 0&&o.set("offset",String(i.offset)),i.sort_by&&o.set("sort_by",i.sort_by),i.order&&o.set("order",i.order),i.search&&o.set("search",i.search),mv(o,i),Le({queryKey:["escalations","available",i],queryFn:()=>ue(`/escalations/available?${o}`),enabled:e,...s!==void 0?{staleTime:s}:{}})}function V5(n){return Le({queryKey:["escalations","by-workflow",n],queryFn:()=>ue(`/escalations/by-workflow/${n}`),enabled:!!n})}function Y5(n){return Le({queryKey:["escalations",n],queryFn:()=>ue(`/escalations/${n}`),enabled:!!n})}function K5(n,e){return Le({queryKey:["escalations",n,"lookups"],queryFn:()=>ue(`/escalations/${n}/lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function J5(){const n=qe();return Ie({mutationFn:({id:e,durationMinutes:s})=>ue(`/escalations/${e}/claim`,{method:"POST",body:JSON.stringify({durationMinutes:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function Q5(){const n=qe();return Ie({mutationFn:e=>ue(`/escalations/${e}/release`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function X5(){const n=qe();return Ie({mutationFn:({id:e,resolverPayload:s})=>ue(`/escalations/${e}/resolve`,{method:"POST",body:JSON.stringify({resolverPayload:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),n.resetQueries({queryKey:["tasks"]}),n.resetQueries({queryKey:["jobs"]})}})}const W5={NEEDS_BADGE:"needs_badge",ROLE_REFUSED:"role_refused"};function Z5(){const n=qe();return Ie({mutationFn:({id:e,...s})=>ue(`/escalations/${e}/roster-action`,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]}),n.invalidateQueries({queryKey:["escalationStats"]})}})}function eM(){const n=qe();return Ie({mutationFn:({id:e,itemKey:s,payload:i})=>ue(`/escalations/${e}/accumulate`,{method:"POST",body:JSON.stringify({itemKey:s,...i?{payload:i}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function tM(){const n=qe();return Ie({mutationFn:({id:e,itemKey:s})=>ue(`/escalations/${e}/remove-item`,{method:"POST",body:JSON.stringify({itemKey:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"]})}})}function nM(){const n=qe();return Ie({mutationFn:({id:e,targetRole:s})=>ue(`/escalations/${e}/escalate`,{method:"PATCH",body:JSON.stringify({targetRole:s})}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function rM(){const n=qe();return Ie({mutationFn:({ids:e,priority:s})=>ue("/escalations/priority",{method:"PATCH",body:JSON.stringify({ids:e,priority:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function sM(){const n=qe();return Ie({mutationFn:({ids:e,durationMinutes:s})=>ue("/escalations/bulk-claim",{method:"POST",body:JSON.stringify({ids:e,durationMinutes:s})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function iM(){const n=qe();return Ie({mutationFn:({ids:e,targetUserId:s,durationMinutes:i,reassign:o})=>ue("/escalations/bulk-assign",{method:"POST",body:JSON.stringify({ids:e,targetUserId:s,durationMinutes:i,...o?{reassign:!0}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function aM(){const n=qe();return Ie({mutationFn:({ids:e})=>ue("/escalations/bulk-unassign",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function oM(){const n=qe();return Ie({mutationFn:({ids:e,hint:s})=>ue("/escalations/bulk-triage",{method:"POST",body:JSON.stringify({ids:e,...s?{hint:s}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function lM(){const n=qe();return Ie({mutationFn:e=>ue(`/escalations/${e}/cancel`,{method:"POST"}),onSuccess:()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]})}})}function cM(){const n=qe();return Ie({mutationFn:({ids:e})=>ue("/escalations/bulk-cancel",{method:"POST",body:JSON.stringify({ids:e})}),onSuccess:()=>{n.invalidateQueries({queryKey:["escalations"],refetchType:"all"}),n.invalidateQueries({queryKey:["escalationStats"],refetchType:"all"})}})}function qm(n){const e=[],s=n.type.split(".");switch(s[0]==="system"?s[1]:s[0]){case"task":e.push(["tasks"]),e.push(["jobs"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),n.originId&&e.push(["processes",n.originId]);break;case"escalation":e.push(["escalations"]),e.push(["escalationStats"]),e.push(["stationMetrics"]),n.workflowId&&e.push(["workflowExecution",n.workflowId]);break;case"workflow":e.push(["jobs"]),e.push(["tasks"]),e.push(["processes"]),n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["workflowState",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId]),e.push(["mcpQueryResult",n.workflowId]),e.push(["builderResult",n.workflowId]));break;case"activity":n.workflowId&&e.push(["mcpRunExecution",n.workflowId]),e.push(["mcpRuns"]);break;case"milestone":n.workflowId&&(e.push(["workflowExecution",n.workflowId]),e.push(["mcpQueryExecution",n.workflowId])),e.push(["tasks"]);break;case"knowledge":e.push(["knowledge"]);break;case"file":e.push(["files"]);break;case"agent":e.push(["agents"]);break;default:e.push(["jobs"]),e.push(["tasks"]);break}return e}const ok={DETAIL:{coalesceMs:300,minIntervalMs:2e3},LIST:{coalesceMs:500,minIntervalMs:3e3},SUMMARY:{coalesceMs:1e3,minIntervalMs:1e4}},uM=300,Db={DETAIL:0,LIST:1,SUMMARY:2};function lk(n){const e=new Map,s={},i={};let o=!1;const c=()=>typeof document<"u"&&document.visibilityState==="hidden";function m(d){delete s[d],i[d]=Date.now();const b=[];for(const[v,_]of e)_===d&&b.push(v);for(const v of b)e.delete(v);if(b.length===0)return;const x=c();x&&(o=!0);for(const v of b)n.invalidateQueries({queryKey:JSON.parse(v),...x?{refetchType:"none"}:{}})}function p(d){if(s[d])return;const{coalesceMs:b,minIntervalMs:x}=ok[d],v=i[d],_=v===void 0?0:v+x-Date.now(),S=Math.max(b,_);s[d]=setTimeout(()=>m(d),S)}function g(d,b){for(const x of b){const v=JSON.stringify(x),_=e.get(v);(_===void 0||Db[d]<Db[_])&&e.set(v,d)}p(d)}const u=()=>{typeof document>"u"||document.visibilityState==="visible"&&o&&(o=!1,n.refetchQueries({type:"active",stale:!0}))};return typeof document<"u"&&document.addEventListener("visibilitychange",u),{request:g,dispose(){for(const d of Object.keys(s)){const b=s[d];b&&clearTimeout(b),delete s[d]}e.clear(),typeof document<"u"&&document.removeEventListener("visibilitychange",u)}}}const Lb=new WeakMap;function ck(n){let e=Lb.get(n);return e||(e=lk(n),Lb.set(n,e)),e}function nn(n){const e=qe();return E.useCallback(s=>{ck(e).request(n,s)},[e,n])}function Pm(n){return n?[`${Wt}.system.workflow.>`,`${Wt}.system.activity.>`,`${Wt}.system.milestone.>`,`${Wt}.system.task.>`,`${Wt}.system.escalation.>`]:[]}function fM(){const n=nn("LIST");An(`${Wt}.system.task.>`,()=>{n([["jobs"]])}),An(`${Wt}.system.workflow.>`,()=>{n([["jobs"]])})}function hM(n){const e=nn("DETAIL");ks(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function dM(n){const e=nn("DETAIL");ks(Pm(n),s=>{var p;if(!n||!(s.workflowId===n||((p=s.workflowId)==null?void 0:p.includes(n))))return;const o=s.type.split("."),c=o[0]==="system"?o[1]:o[0],m=qm(s);c==="escalation"&&m.push(["escalations","by-workflow",n]),e(m)})}function mM(n){const e=nn("DETAIL");ks(Pm(n),s=>{var c;if(!n||!(s.workflowId===n||((c=s.workflowId)==null?void 0:c.includes(n))))return;const o=qm(s);o.push(["workflowSets"]),o.push(["yamlWorkflows"]),e(o)})}function pM(n){const e=nn("DETAIL"),s=E.useCallback(i=>{n&&(i.originId!==n&&i.workflowId!==n||e([["processes",n]]))},[n,e]);An(`${Wt}.system.task.>`,s),An(`${Wt}.system.workflow.>`,s),An(`${Wt}.system.escalation.>`,s)}function yM(){const n=nn("SUMMARY");An(fr({}),()=>{n([["escalationStats"]])})}function gM(){const n=nn("SUMMARY");An(fr({}),()=>{n([["stationMetrics"]])})}function bM(){const n=nn("SUMMARY");An(fr({}),()=>{n([["escAggregate"],["escTimeline"]])})}function xM(n){const e=nn("LIST"),s=(n==null?void 0:n.role)??null,i=((n==null?void 0:n.verbs)??[]).join(","),o=E.useMemo(()=>{const c=i?i.split(","):null;return c?Yd({role:s,verbs:c}):[fr({role:s})]},[s,i]);ks(o,()=>{e([["escalations"]])})}const uk=[["escalations","related"],["escalations","related-rows"]];function vM(n){const e=nn("LIST"),s=[...new Set(n)].sort().join(","),i=E.useMemo(()=>s?s.split(",").map(o=>fr({role:o})):[],[s]);ks(i,()=>{e(uk)})}function _M(n){const e=nn("DETAIL");An(fr(n?{id:n}:{id:"__none__"}),s=>{!n||s.escalationId!==n||e([["escalations",n]])})}function wM(){const n=nn("LIST");An(`${Wt}.system.agent.>`,()=>{n([["agents"]])})}function SM(){const n=nn("LIST");An(`${Wt}.system.task.>`,()=>{n([["processes"]])}),An(`${Wt}.system.workflow.>`,()=>{n([["processes"]])})}function fk(){const{user:n}=Lt(),e=n==null?void 0:n.userId,s=nn("SUMMARY");ks(jm(),()=>{s([["escalations"]])});const{data:i}=yv({limit:1}),{data:o}=pv({assigned_to:e,status:"pending",limit:1});return{available:(i==null?void 0:i.total)??0,mine:(o==null?void 0:o.total)??0}}function Ru({size:n="sm",hideLabel:e=!1,className:s="",appName:i="LongTail",variant:o="full"}){const c=n==="lg";if(o==="comet")return h.jsx("div",{className:`relative overflow-visible ${s}`,style:{width:"2.5rem",height:"2.5rem",flexShrink:0},children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark absolute pointer-events-none select-none",style:{"--logo-url":`url(${Yt}/logo512.png)`,width:"82px",height:"82px",top:"-12px",left:"-80px",transform:"rotate(232deg)",zIndex:-1,opacity:.55}})});if(o==="mark")return h.jsx("div",{className:`flex items-center ${s}`,children:h.jsx("span",{role:"img","aria-label":i,className:"logo-mark shrink-0 w-7 h-7",style:{"--logo-url":`url(${Yt}/logo512.png)`}})});const m=c?"w-[16rem] h-[16rem] -rotate-[120deg] opacity-55 -ml-10":"w-[12.5rem] h-[12.5rem] -rotate-[120deg] opacity-55 -ml-8",p=c?"text-[44px] font-normal text-text-primary tracking-[0.15em] -ml-[12.5rem]":"text-[36px] font-normal text-text-primary tracking-[0.15em] -ml-[9.75rem]";return h.jsxs("div",{className:`flex items-center ${s}`,style:{height:"50px"},children:[h.jsx("span",{role:"img","aria-label":i,className:`logo-mark shrink-0 z-0 ${m}`,style:{"--logo-url":`url(${Yt}/logo512.png)`}}),h.jsx("span",{className:`z-[1] transition-opacity duration-300 ${p} ${e?"opacity-0":""}`,children:i})]})}const hk="system.surfaces.dashboard",dk=`${Wt}.${hk}`;function gv(n=!0){return Le({queryKey:["announcements"],queryFn:()=>ue("/announcements"),enabled:n,staleTime:3e4})}function mk(){const n=qe();return Ie({mutationFn:e=>ue("/announcements",{method:"POST",body:JSON.stringify(e)}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function pk(){const n=qe();return Ie({mutationFn:e=>ue(`/announcements/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["announcements"]})}})}function EM(n){return n.toLocaleString()}function OM(n){return n>=1e9?`${(n/1e9).toFixed(1).replace(/\.0$/,"")}B`:n>=1e6?`${(n/1e6).toFixed(1).replace(/\.0$/,"")}M`:n>=1e4?`${(n/1e3).toFixed(1).replace(/\.0$/,"")}K`:n.toLocaleString()}function yk(n){const e=new Date(n);return e.getTime()>Date.now()?"just now":Dj(e,{addSuffix:!0})}function AM(n){const e=Date.now()-new Date(n).getTime();if(e<0)return"now";const s=Math.floor(e/1e3);if(s<60)return`${s}s`;const i=Math.floor(s/60);if(i<60)return`${i}m`;const o=Math.floor(i/60);if(o<24)return`${o}h`;const c=Math.floor(o/24);return c<7?`${c}d`:c<30?`${Math.floor(c/7)}w`:c<365?`${Math.floor(c/30)}mo`:`${Math.floor(c/365)}y`}function jM(n){return n<=0?"Expired":Bm(n)}function gk(n){return n==null?"--":Bm(n)}function kM(n){return n?km(n):"--"}function Bm(n){if(n<1e3)return`${Math.round(n)}ms`;if(n<6e4){const m=n/1e3;return Number.isInteger(m)?`${m}s`:`${m.toFixed(1)}s`}const e=Math.floor(n/1e3),s=Math.floor(e/86400),i=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),c=e%60;return s>0?i>0?`${s}d ${i}h`:`${s}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:c>0?`${o}m ${c}s`:`${o}m`}function NM(n,e){const s=new Date(n).getTime(),i=e?new Date(e).getTime():Date.now();return Bm(i-s)}function bv({options:n,children:e,className:s=""}){const[i,o]=E.useState(!1),[c,m]=E.useState(null),[p,g]=E.useState(null),u=E.useRef(null),d=E.useRef(void 0),b=E.useRef(void 0),x=220,v=E.useCallback(()=>{if(!u.current)return;const B=u.current.getBoundingClientRect(),q=window.innerWidth-x-8,ne=Math.max(8,Math.min(B.left,q));g({top:B.bottom+4,left:ne})},[]),_=E.useCallback(async(B,q)=>{try{await navigator.clipboard.writeText(B),m(q),clearTimeout(d.current),d.current=setTimeout(()=>m(null),1200)}catch{}},[]),S=E.useCallback(()=>{clearTimeout(b.current),v(),o(!0)},[v]),C=E.useCallback(()=>{b.current=setTimeout(()=>o(!1),150)},[]);return E.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(b.current)},[]),h.jsxs("span",{ref:u,className:`inline-flex items-center cursor-default ${s}`,onMouseEnter:S,onMouseLeave:C,children:[e,i&&p&&sm.createPortal(h.jsx("span",{className:"fixed z-[9999] bg-surface-raised border border-surface-border rounded shadow-lg py-1 min-w-[180px]",style:{top:p.top,left:p.left},onMouseEnter:S,onMouseLeave:C,children:n.map(B=>h.jsxs("button",{onClick:q=>{q.stopPropagation(),_(B.value,B.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:B.label}),h.jsx("span",{className:"text-2xs font-mono text-text-secondary truncate ml-2",children:c===B.label?"✓":B.value})]},B.label))}),document.body)]})}function bk(n,e){const s=new Date(n);switch(e){case"relative":return yk(n);case"datetime":return km(s);case"time":return s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:qj()??void 0})}}function xk(n){const e=new Date(n);return[{label:"ms",value:String(e.getTime())},{label:"utc",value:e.toISOString()},{label:"local",value:km(e,!0)}]}function xv({date:n,format:e="relative",className:s=""}){const[,i]=E.useState(0);E.useEffect(()=>{if(e!=="relative")return;const c=setInterval(()=>i(m=>m+1),3e4);return()=>clearInterval(c)},[e]);const o=E.useMemo(()=>xk(n),[n]);return h.jsx(bv,{options:o,children:h.jsx("time",{dateTime:n,className:`text-xs text-text-tertiary ${s}`,children:bk(n,e)})})}function vk({values:n,options:e,onChange:s,addLabel:i,emptyText:o,ariaLabel:c}){const m=e.filter(p=>!n.includes(p));return h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.map(p=>h.jsxs("button",{type:"button",onClick:()=>s(n.filter(g=>g!==p)),className:"inline-flex items-center gap-1 text-2xs font-mono text-text-primary border border-surface-border px-1.5 py-0.5 hover:text-status-error hover:border-status-error/50 transition-colors",title:`Remove ${p}`,children:[p,h.jsx(en,{className:"w-3 h-3",strokeWidth:1.5})]},p)),n.length===0&&o&&h.jsx("span",{className:"text-2xs text-text-tertiary italic",children:o}),m.length>0&&h.jsxs("select",{value:"",onChange:p=>p.target.value&&s([...n,p.target.value]),className:"select font-mono","aria-label":c??i,children:[h.jsx("option",{value:"",children:i}),m.map(p=>h.jsx("option",{value:p,children:p},p))]})]})}const _k=[{minutes:1,label:"1 minute"},{minutes:15,label:"15 minutes"},{minutes:30,label:"30 minutes"},{minutes:60,label:"1 hour"},{minutes:240,label:"4 hours"},{minutes:1440,label:"24 hours"},{minutes:4320,label:"3 days"},{minutes:10080,label:"7 days"}];function wk(){const{data:n}=gv(),{data:e}=$j(),s=mk(),i=pk(),[o,c]=E.useState(""),[m,p]=E.useState(""),[g,u]=E.useState(1440),[d,b]=E.useState([]),x=(n==null?void 0:n.announcements)??[],v=()=>{m.trim()&&s.mutate({body:m.trim(),...o.trim()?{title:o.trim()}:{},...d.length?{roles:d}:{},expiresAt:new Date(Date.now()+g*6e4).toISOString()},{onSuccess:()=>{c(""),p(""),b([])}})};return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"Alerts"}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Title"}),h.jsx("input",{type:"text",value:o,onChange:_=>c(_.target.value),placeholder:"Optional headline",className:"input text-xs w-full"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Summary"}),h.jsx("textarea",{value:m,onChange:_=>p(_.target.value),placeholder:"What everyone should know (markdown supported)",rows:3,className:"input text-xs w-full resize-y"})]}),h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible for"}),h.jsx("select",{value:g,onChange:_=>u(Number(_.target.value)),className:"select text-xs w-full",children:_k.map(_=>h.jsx("option",{value:_.minutes,children:_.label},_.minutes))})]}),h.jsxs("div",{className:"block",children:[h.jsx("span",{className:"block text-2xs text-text-tertiary mb-1",children:"Visible to"}),h.jsx(vk,{values:d,options:(e==null?void 0:e.roles)??[],onChange:b,addLabel:"Add a role…",emptyText:"Everyone",ariaLabel:"Add a role"})]}),s.error&&h.jsx("p",{className:"text-xs text-status-error",children:s.error.message}),h.jsx("button",{onClick:v,disabled:!m.trim()||s.isPending,className:"btn-primary text-xs w-full disabled:opacity-50",children:s.isPending?"Publishing…":"Publish alert"})]}),x.length>0&&h.jsxs("div",{className:"mt-6",children:[h.jsx("p",{className:"text-2xs text-text-tertiary mb-2",children:"Active now — stacked as banner rows, newest first"}),h.jsx("div",{className:"space-y-1",children:x.map(_=>h.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-surface-border/40 last:border-b-0",children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"block text-xs text-text-primary truncate",children:_.title??_.body.split(`
54
+ `)[0]}),h.jsxs("span",{className:"block text-2xs text-text-tertiary",children:["expires ",h.jsx(xv,{date:_.expires_at,format:"relative"})]})]}),h.jsx("button",{onClick:()=>i.mutate(_.id),disabled:i.isPending,className:"icon-link shrink-0 mt-0.5",title:"Remove for everyone","aria-label":`Remove ${_.title??"announcement"}`,children:h.jsx(en,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]},_.id))})]})]})}const Sk=[{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"}],Ek=["operator","engineer","admin","superadmin"];function qb(n){return Ek.indexOf(n)}function Ok(n,e){return qb(n)>=qb(e)}function Ak({onClose:n}){var Ne,Me,Xe,pt,Ot,mt,_e;const{isSuperAdmin:e,hasRoleType:s,hasRole:i}=Lt(),{data:o}=Hn(),c=Om(),m=!!((Ne=o==null?void 0:o.ai)!=null&&Ne.enabled),p=Xx(),g=p!==null?p:m,[u,d]=E.useState(g),b=(Me=o==null?void 0:o.features)==null?void 0:Me.graphWorkflows,x=b==null,[v,_]=E.useState(b===!0||x&&Wx()),S=e||i("engineer"),[C,B]=E.useState(Zx()),q=!!((Xe=o==null?void 0:o.features)!=null&&Xe.scanCodes),ne=ev(),[te,M]=E.useState(ne!==null?ne:q),z=e?"superadmin":s("admin")?"admin":i("engineer")?"engineer":"operator",ae=((pt=o==null?void 0:o.branding)==null?void 0:pt.appName)??"LongTail",F=(Ot=o==null?void 0:o.environment)==null?void 0:Ot.longTailVersion,U=(mt=o==null?void 0:o.environment)==null?void 0:mt.hotmeshVersion,D=(_e=o==null?void 0:o.environment)==null?void 0:_e.nodeEnv;E.useEffect(()=>{const le=Pe=>{Pe.key==="Escape"&&n()};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[n]);const Q=Sk.filter(le=>Ok(z,le.minTier)),W=Q.length>1,he=z!=="operator",Ee=[...W?[{id:"viewas",label:"View As",icon:gS}]:[],{id:"features",label:"Features",icon:bS},...he?[{id:"alerts",label:"Alerts",icon:xS}]:[]],[Ae,H]=E.useState(Ee[0].id),J=le=>{le===null?Vd():pA(le)},ce=()=>{const le=!u;d(le),le===m?mA():dA(le),window.location.reload()},pe=()=>{const le=!v;_(le),yA(le),window.location.reload()},ge=()=>{const le=!C;B(le),gA(le),window.location.reload()},Ce=()=>{const le=!te;M(le),le===q?xA():bA(le),window.location.reload()};return h.jsx("div",{className:"fixed inset-0 z-[100] bg-surface-sunken/75 backdrop-blur-sm flex items-center justify-center",onClick:n,children:h.jsxs("div",{className:"relative w-[440px] max-h-[85vh] overflow-y-auto bg-surface-raised px-12 py-10",onClick:le=>le.stopPropagation(),children:[h.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-text-quaternary hover:text-text-secondary transition-colors p-1","aria-label":"Close",children:h.jsx(en,{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(${Yt}/logo512.png)`}}),h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-2xl font-light text-text-primary tracking-[0.12em]",children:ae}),F&&h.jsxs("p",{className:"mt-1 text-2xs text-text-tertiary",children:["v",F,U&&h.jsxs(h.Fragment,{children:[" · HotMesh v",U]}),D&&D!=="production"&&h.jsx("span",{className:"ml-1 text-status-warning",children:D})]})]})]}),h.jsx("hr",{className:"border-surface-border/50 mb-6"}),Ee.length>1&&h.jsx("div",{className:"flex items-center justify-center gap-2 mb-8",role:"tablist",children:Ee.map(le=>{const Pe=Ae===le.id;return h.jsxs("button",{role:"tab","aria-selected":Pe,onClick:()=>H(le.id),title:le.label,className:`flex flex-col items-center gap-1.5 px-5 py-2.5 rounded-lg transition-colors ${Pe?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[h.jsx(le.icon,{className:"w-5 h-5",strokeWidth:1.5,...Pe?{fill:"currentColor",fillOpacity:.15}:{}}),h.jsx("span",{className:"text-2xs font-medium",children:le.label})]},le.id)})}),Ae==="viewas"&&W&&h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-4",children:"View As"}),Q.map(le=>{const Pe=c===le.id,zt=le.id===null?`Your view · ${z}`:le.label;return h.jsxs("button",{onClick:()=>J(le.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 ${Pe?"border-accent bg-accent":"border-surface-border group-hover:border-accent/60"}`,children:Pe&&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 ${Pe?"text-accent":"text-text-primary group-hover:text-accent"}`,children:zt}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:le.description})]})]},String(le.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:ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"AI features"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:u?"Enabled — AI assist, agent labels, bulk AI actions":"Hidden — automation labels, no AI surfaces"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${u?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${u?"translate-x-4":"translate-x-0"}`})})]}),x&&h.jsxs("button",{onClick:pe,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Graph workflows"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:v?"Visible — Graph section shown in Orchestrate sidebar":"Hidden — use Procedural workflows instead"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${v?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${v?"translate-x-4":"translate-x-0"}`})})]}),S&&h.jsxs("button",{onClick:ge,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group","data-testid":"feature-infrastructure",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Infrastructure"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:C?"Visible — Routers, Messages, and DB Maintenance in the sidebar":"Hidden — routers, message streams, and database maintenance"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${C?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${C?"translate-x-4":"translate-x-0"}`})})]}),h.jsxs("button",{onClick:Ce,className:"w-full text-left flex items-center justify-between py-2.5 px-1 group",children:[h.jsxs("span",{children:[h.jsx("span",{className:"block text-sm font-medium text-text-primary group-hover:text-accent transition-colors",children:"Scan input"}),h.jsx("span",{className:"block text-xs text-text-secondary mt-0.5",children:te?"Enabled — header scan affordance, panel, and keyboard-wedge capture":"Hidden — the deployment opts in with features.scanCodes"})]}),h.jsx("span",{className:`shrink-0 ml-4 w-9 h-5 rounded-full transition-colors flex items-center px-0.5 ${te?"bg-accent":"bg-surface-border"}`,children:h.jsx("span",{className:`w-4 h-4 rounded-full bg-text-inverse shadow-sm transition-transform ${te?"translate-x-4":"translate-x-0"}`})})]})]}),Ae==="alerts"&&he&&h.jsx(wk,{}),h.jsx("hr",{className:"border-surface-border/50 mt-8"}),h.jsx("p",{className:"mt-4 text-2xs text-text-quaternary text-center",children:"Esc or click outside to close"})]})})}const vv=[{id:"violet",label:"Violet",swatch:"#7B3BE0"},{id:"red",label:"Brick",swatch:"#DC382D"},{id:"green",label:"Emerald",swatch:"#059669"},{id:"blue",label:"Electric",swatch:"#2563EB"},{id:"rose",label:"Raspberry",swatch:"#D6246E"},{id:"orange",label:"Harvest",swatch:"#E85D04"}],Pb="blue",_v="lt.theme";let wv=[];function jk(n){const e=new Set(vv.map(i=>i.id)),s=new Set;wv=n.filter(i=>!(i!=null&&i.id)||e.has(i.id)||s.has(i.id)?!1:(s.add(i.id),!0))}function kk(){return[...vv,...wv]}function Sv(){try{return localStorage.getItem(_v)||Pb}catch{return Pb}}function Ev(n){document.documentElement.dataset.theme=n}function Nk(n){try{localStorage.setItem(_v,n)}catch{}Ev(n)}const Tk=[8,12,13,14];function Ck(n){if(!/^[0-9]+$/.test(n)||!Tk.includes(n.length))return!1;const e=n.split("").map(Number),s=e.pop();let i=0;for(let o=e.length-1,c=3;o>=0;o--,c=c===3?1:3)i+=e[o]*c;return(10-i%10)%10===s}function TM(n){return n.padStart(14,"0")}const cu={maxKeyGapMs:500,terminators:["Enter","Tab"],minLength:6,autoFireQuietMs:300,autoFireMaxAvgKeyMs:50},Ov="lt_scan_wedge_config";function Av(){try{const n=localStorage.getItem(Ov);return n?{...cu,...JSON.parse(n)}:cu}catch{return cu}}function Mk(n){const e={...Av(),...n};return localStorage.setItem(Ov,JSON.stringify(e)),e}const Um=[{pattern:/(?:^|[^0-9])([1-9][0-9]:[0-9]:[a-zA-Z0-9._-]+)$/,digitsOnly:!1},{pattern:/(?:^|[^0-9])([1-9][0-9]{7,})$/,digitsOnly:!0}];function Rk(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dk(n){const e=[];for(const s of n.filter(i=>i.enabled))if(s.encoding==="delimited"){const i=Rk(s.delimiter);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}${i}[0-9]${i}[a-zA-Z0-9._-]+)$`),digitsOnly:!1})}else if(s.encoding==="fixed"){const i=1+(s.target_length??0);e.push({pattern:new RegExp(`(?:^|[^0-9])(${s.version}[0-9]{${i},${i+1}})$`),digitsOnly:!0})}else s.encoding==="gtin"&&e.push({pattern:/(?:^|[^0-9])([0-9]{8}|[0-9]{12,14})$/,digitsOnly:!0,accept:Ck});return e.length?e:Um}function Lk(n,e=Um){var i;let s=null;for(const o of e){const c=(i=n.match(o.pattern))==null?void 0:i[1];!c||o.accept&&!o.accept(c)||(!s||c.length>s.code.length)&&(s={code:c,shape:o})}return s}const qk=new Set(["Shift","CapsLock"]),hc={suppress:!1,emit:null};function Pk(n=cu,e=Um){let s={buffer:"",times:[],lastKeyMs:0};function i(u){const d=s.times.slice(-u.length);return d.length<2?!1:(d[d.length-1]-d[0])/(d.length-1)<=n.autoFireMaxAvgKeyMs}function o(){const u=Lk(s.buffer,e);return!u||u.code.length<n.minLength||u.shape.digitsOnly&&!i(u.code)?null:u.code}function c(){s={buffer:"",times:[],lastKeyMs:0}}function m(u){const{key:d,timeMs:b,hasModifier:x,isRepeat:v}=u;if(qk.has(d))return hc;if(n.terminators.includes(d)){const q=o();return c(),q?{suppress:!0,emit:q,consumedLength:q.length}:hc}if(x||v||d.length!==1)return c(),hc;const _=b-s.lastKeyMs,S=s.lastKeyMs>0&&_<=n.maxKeyGapMs,C=(S?s.buffer+d:d).slice(-128),B=(S?[...s.times,b]:[b]).slice(-128);return s={buffer:C,times:B,lastKeyMs:b},hc}function p(){return{buffer:s.buffer}}function g(){const u=o();return!u||!i(u)?null:{code:u,consumedLength:u.length}}return{step:m,reset:c,snapshot:p,pendingAutoFire:g}}function Bk(){const n=document.activeElement;return n instanceof HTMLInputElement?["text","search","tel","url","email","password","number"].includes(n.type)?n:null:n instanceof HTMLTextAreaElement?n:null}function Uk(n,e,s){var c;const i=n instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,o=(c=Object.getOwnPropertyDescriptor(i,"value"))==null?void 0:c.set;o?o.call(n,e):n.value=e;try{n.setSelectionRange(s,s)}catch{}n.dispatchEvent(new Event("input",{bubbles:!0}))}function Bb(n){if(n<=0)return;const e=Bk();if(!e)return;const s=e.selectionStart??e.value.length,i=Math.max(0,s-n);Uk(e,e.value.slice(0,i)+e.value.slice(s),i)}const na={KEYBOARD_WEDGE:"keyboard-wedge",MANUAL:"manual",TOOLBAR:"toolbar",FOLLOW:"follow"},zk="data-lt-scan-capture",Ik="off";function $k(n){return n instanceof Element&&!!n.closest(`[${zk}="${Ik}"]`)}function Hk({active:n,wedgeConfig:e,tailShapes:s,diagnosticsOn:i,onScan:o,onDiag:c}){const m=E.useRef({diagnosticsOn:i,onScan:o,onDiag:c});m.current={diagnosticsOn:i,onScan:o,onDiag:c};const p=E.useRef(0),g=E.useRef(0);E.useEffect(()=>{if(!n)return;const u=Pk(e,s);let d=null;const b=()=>{d&&(clearTimeout(d),d=null)},x=(S,C,B)=>{C&&Bb(C),m.current.diagnosticsOn&&(console.debug("[scan]",B),m.current.onDiag({seq:++p.current,key:"(quiet)",code:"",deltaMs:0,buffer:"",note:B})),m.current.onScan(S)},v=()=>{b(),u.pendingAutoFire()&&(d=setTimeout(()=>{d=null;const S=u.pendingAutoFire();S&&(u.reset(),x(S.code,S.consumedLength,`capture → ${S.code} (quiet period — no suffix)`))},e.autoFireQuietMs))},_=S=>{if($k(S.target)){u.reset(),b();return}const C=u.snapshot().buffer,{suppress:B,emit:q,consumedLength:ne}=u.step({key:S.key,timeMs:S.timeStamp,hasModifier:S.ctrlKey||S.metaKey||S.altKey,isRepeat:S.repeat});if(B&&(S.preventDefault(),S.stopPropagation()),m.current.diagnosticsOn){const te=u.snapshot().buffer,M=e.terminators.includes(S.key),z=q?`capture → ${q}`:M?`terminator — no code tail in "${C.slice(-24)}"`:te===C?C?"neutral (chord key)":"ignored":te===""?"reset (edit/chord/non-printable)":te.length<=1&&C.length>1?"gap — new episode":"accumulate",ae=g.current?Math.round(S.timeStamp-g.current):0,F={seq:++p.current,key:S.key,code:S.code!==S.key?S.code:"",deltaMs:ae,buffer:te.slice(-24),note:z};console.debug("[scan]",F.key,F.code,`${F.deltaMs}ms`,F.note),m.current.onDiag(F)}g.current=S.timeStamp,q?(b(),ne&&Bb(ne),m.current.onScan(q)):v()};return window.addEventListener("keydown",_,{capture:!0}),()=>{b(),window.removeEventListener("keydown",_,{capture:!0})}},[n,e,s])}const ke={EXECUTED:"executed",MATCHED_LIST:"matched_list",CONFIRM_REQUIRED:"confirm_required",NO_MATCH_FALLBACK:"no_match_fallback",UNCONFIGURED:"unconfigured",INVALID_CODE:"invalid_code",FORBIDDEN:"forbidden",CONFLICT:"conflict",IDENTITY_PRIMED:"identity_primed",IDENTITY_UNKNOWN:"identity_unknown",NOT_PRIMED:"not_primed",CHOICES:"choices",NO_OPEN_CONTAINER:"no_open_container",HELD:"held",REFUSED:"refused",SUBJECT_STALE:"subject_stale"},dc={SHOW_DETAIL:"show-detail",SHOW_LIST:"show-list",CLAIM:"claim",CLAIM_SHOW_DETAIL:"claim-show-detail",RELEASE:"release",RESOLVE:"resolve",ESCALATE:"escalate",CANCEL:"cancel",ACCUMULATE:"accumulate",PRESENT:"present",HOLD:"hold",FILL:"fill"},Fk={ACTION:"action",IDENTITY:"identity"};function Gk(n,e){return ue("/scan-codes/execute",{method:"POST",body:JSON.stringify({code:n,...e!=null&&e.actingToken?{actingToken:e.actingToken}:{},...e!=null&&e.previousActingToken?{previousActingToken:e.previousActingToken}:{},...e!=null&&e.subject?{subject:e.subject}:{},...e!=null&&e.stationRole?{stationRole:e.stationRole}:{}})})}function CM(n){return ue("/scan-codes/execute-choice",{method:"POST",body:JSON.stringify(n)})}function jv(n){return Le({queryKey:["scan-schemes"],queryFn:()=>ue("/scan-codes/schemes"),...n})}function MM(n){return Le({queryKey:["scan-schemes",n],queryFn:()=>ue(`/scan-codes/schemes/${n}`),enabled:n!=null})}function RM(){const n=qe();return Ie({mutationFn:e=>ue(`/scan-codes/schemes/${e.version}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function DM(){const n=qe();return Ie({mutationFn:e=>ue(`/scan-codes/schemes/${e}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["scan-schemes"]})})}function LM(){const n=qe();return Ie({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"PUT",body:JSON.stringify(e)}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}function qM(){const n=qe();return Ie({mutationFn:e=>ue(`/scan-codes/schemes/${e.scheme_version}/actions/${e.category}`,{method:"DELETE"}),onSuccess:(e,s)=>n.invalidateQueries({queryKey:["scan-schemes",s.scheme_version]})})}const Vk=3e4;function Yk(n,e=Date.now()){if(!(!n||Date.parse(n.expiresAt)<=e))return{code:n.code,escalationId:n.escalationId}}function Ub(n,e,s=Date.now()){if(e.outcome===ke.HELD&&e.subject){const i=Math.max(0,Date.parse(e.subject.expiresAt)-s);return{...e.subject,ttlMs:i}}return e.clearSubject||!n?null:e.outcome===ke.EXECUTED&&e.progress&&e.progress.remaining>0?{...n,expiresAt:new Date(s+n.ttlMs).toISOString()}:n}function zb(n){return n.outcome===ke.NOT_PRIMED&&n.replayable===!0}function Kk(n,e=Date.now()){return n&&e-n.at<=Vk?n:null}const Jk=[ke.HELD,ke.REFUSED,ke.SUBJECT_STALE],Fi=n=>{if(n)try{return JSON.parse(n)}catch{return}},ei=n=>n==null||Array.isArray(n)&&n.length===0||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0;function Qk(n){const e={},s=Fi(n.get("facets"));ei(s)||(e.facets=s);const i=Fi(n.get("block"));ei(i)||(e.block=i);const o=Fi(n.get("range"));ei(o)||(e.range=o);const c=Fi(n.get("exists"));ei(c)||(e.exists=c);const m=Fi(n.get("roles"));ei(m)||(e.roles=m);const p=Fi(n.get("orderBy"));ei(p)||(e.orderBy=p),n.get("available")!=null&&(e.available=n.get("available")==="true");const g=n.get("jeopardy");return(g==="1"||g==="true")&&(e.jeopardy=!0),e}function PM(n,e){const s=(i,o)=>ei(o)?n.delete(i):n.set(i,JSON.stringify(o));s("facets",e.facets),s("block",e.block),s("range",e.range),s("exists",e.exists),s("roles",e.roles),s("orderBy",e.orderBy),e.available==null?n.delete("available"):n.set("available",String(e.available)),e.jeopardy===!0?n.set("jeopardy","1"):n.delete("jeopardy")}const Ib=`&status=all&view=table&orderBy=${encodeURIComponent(JSON.stringify([{field:"created_at",direction:"desc"}]))}`;function kv(n,e){const s={};for(const[o,c]of Object.entries(n))s[o]=typeof c=="object"&&c!==null?JSON.stringify(c):c;const i=encodeURIComponent(JSON.stringify(s));return e?`/escalations/available?role=${encodeURIComponent(e)}&facets=${i}${Ib}`:`/escalations/available?facets=${i}${Ib}`}function Xk(n,e,s){return kv({[n]:e},s)}function BM(n){var e,s,i;return Object.keys(n.facets??{}).length+(((e=n.block)==null?void 0:e.length)??0)+(((s=n.range)==null?void 0:s.length)??0)+(((i=n.exists)==null?void 0:i.length)??0)+(n.available!=null?1:0)+(n.jeopardy===!0?1:0)}function zm(){var s;const{data:n}=Hn(),e=ev();return e!==null?e:!!((s=n==null?void 0:n.features)!=null&&s.scanCodes)}const Im=E.createContext(null);function $m(){const n=E.useContext(Im);if(!n)throw new Error("useScanInput must be used within ScanInputProvider");return n}function UM(){return E.useContext(Im)}const Wk="scanPendingAction",Zk="scanChoices",fd="/scan/station";function eN({children:n}){const{user:e}=Lt(),s=zm(),i=ni(),o=tn(),{identity:c,prime:m,clear:p,settle:g}=Cu(),[u,d]=E.useState(null),[b,x]=E.useState(null),[v,_]=E.useState(null),{data:S}=jv({enabled:!!e&&s,staleTime:6e4}),C=E.useRef(null);C.current=Cm().role;const B=E.useMemo(()=>Dk((S==null?void 0:S.schemes)??[]),[S]),[q,ne]=E.useState(!1),[te,M]=E.useState(()=>Av()),[z,ae]=E.useState([]),[F,U]=E.useState(!1),D=E.useCallback(_e=>{var zt;const{outcome:le}=_e;if(le===ke.CONFIRM_REQUIRED&&_e.pendingAction)return i(`/escalations/detail/${_e.pendingAction.escalationId}`,{state:{[Wk]:_e.pendingAction}}),!0;const Pe=le===ke.EXECUTED&&!!H.current;if(Jk.includes(le)||zb(_e)||Pe)return ce.current!==fd&&i(fd),!0;if(le===ke.EXECUTED&&_e.escalation){const qt=[dc.SHOW_DETAIL,dc.CLAIM_SHOW_DETAIL,dc.CLAIM,dc.ESCALATE];return _e.verb&&qt.includes(_e.verb)?(i(`/escalations/detail/${_e.escalation.id}`),!0):!1}if(le===ke.MATCHED_LIST&&_e.listQuery){const{targetFacet:qt,target:at,roles:ye}=_e.listQuery;return i(kv({[qt]:at},(ye==null?void 0:ye[0])??null)),!0}return le===ke.CHOICES&&_e.choices?(i(fd,{state:{[Zk]:_e}}),!0):le===ke.NO_MATCH_FALLBACK&&((zt=_e.fallback)!=null&&zt.route)?(i(_e.fallback.route),!0):!1},[i]),Q=E.useRef(null);Q.current=(c==null?void 0:c.actingToken)??null;const W=E.useRef(null),he=E.useRef([]),Ee=E.useCallback(_e=>(he.current=[_e,...he.current],()=>{he.current=he.current.filter(le=>le!==_e)}),[]),Ae=E.useRef(null);Ae.current=b;const H=E.useRef(void 0),J=E.useRef(null);J.current=v;const ce=E.useRef(o.pathname);ce.current=o.pathname,E.useEffect(()=>{if(!b)return;const _e=Date.parse(b.expiresAt)-Date.now();if(_e<=0){x(null);return}const le=setTimeout(()=>x(null),_e);return()=>clearTimeout(le)},[b]);const pe=E.useCallback(async(_e,le,Pe,zt=!1)=>{ne(!0);const qt=Date.now();try{H.current=Yk(Ae.current);const at=await Gk(_e,{actingToken:Pe??void 0,previousActingToken:W.current??void 0,subject:H.current,stationRole:C.current??void 0});if(Pe&&g(Pe,at),x(Ye=>Ub(Ye,at)),at.outcome===ke.IDENTITY_PRIMED){W.current=m(at);const Ye=Kk(J.current);if(_(null),Ye&&at.actingToken){d({code:_e,source:le,at:qt,response:at,error:null,navigated:!1}),await pe(Ye.code,le,at.actingToken);return}}else zb(at)?_({code:_e,at:qt}):_(null);at.outcome===ke.NOT_PRIMED&&Pe&&p();const ye=zt||D(at);d({code:_e,source:le,at:qt,response:at,error:null,navigated:ye})}catch(at){d({code:_e,source:le,at:qt,response:null,error:at.message,navigated:!1})}finally{ne(!1)}},[D,m,p,g]),ge=E.useCallback(async(_e,le=na.MANUAL)=>{for(const Pe of he.current)if(Pe(_e))return;await pe(_e,le,Q.current)},[pe]),Ce=E.useCallback(async _e=>{await pe(_e,na.FOLLOW,Q.current,!0)},[pe]),Ne=E.useCallback(()=>x(null),[]),Me=E.useCallback(_e=>{x(le=>Ub(le,_e))},[]),Xe=E.useCallback(()=>_(null),[]),pt=E.useRef(ge);pt.current=ge,Hk({active:!!e&&s,wedgeConfig:te,tailShapes:B,diagnosticsOn:F,onScan:_e=>void pt.current(_e,na.KEYBOARD_WEDGE),onDiag:_e=>ae(le=>[...le.slice(-29),_e])});const Ot=E.useCallback(_e=>{M(Mk(_e))},[]),mt=E.useMemo(()=>({submitCode:ge,pushCodeInterceptor:Ee,lastResult:u,subject:b,dropSubject:Ne,adoptResponse:Me,followCode:Ce,pendingScan:v,dropPendingScan:Xe,busy:q,wedgeConfig:te,updateWedgeConfig:Ot,diagnostics:z,diagnosticsOn:F,setDiagnosticsOn:U}),[ge,Ee,u,b,Ne,Me,Ce,v,Xe,q,te,Ot,z,F]);return h.jsx(Im.Provider,{value:mt,children:n})}var mc={},uo={},pc={},$b;function Nn(){if($b)return pc;$b=1,Object.defineProperty(pc,"__esModule",{value:!0});function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}var e=function s(i,o){n(this,s),this.data=i,this.text=o.text||i,this.options=o};return pc.default=e,pc}var Hb;function tN(){if(Hb)return uo;Hb=1,Object.defineProperty(uo,"__esModule",{value:!0}),uo.CODE39=void 0;var n=(function(){function S(C,B){for(var q=0;q<B.length;q++){var ne=B[q];ne.enumerable=ne.enumerable||!1,ne.configurable=!0,"value"in ne&&(ne.writable=!0),Object.defineProperty(C,ne.key,ne)}}return function(C,B,q){return B&&S(C.prototype,B),q&&S(C,q),C}})(),e=Nn(),s=i(e);function i(S){return S&&S.__esModule?S:{default:S}}function o(S,C){if(!(S instanceof C))throw new TypeError("Cannot call a class as a function")}function c(S,C){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return C&&(typeof C=="object"||typeof C=="function")?C:S}function m(S,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof C);S.prototype=Object.create(C&&C.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),C&&(Object.setPrototypeOf?Object.setPrototypeOf(S,C):S.__proto__=C)}var p=(function(S){m(C,S);function C(B,q){return o(this,C),B=B.toUpperCase(),q.mod43&&(B+=x(_(B))),c(this,(C.__proto__||Object.getPrototypeOf(C)).call(this,B,q))}return n(C,[{key:"encode",value:function(){for(var q=d("*"),ne=0;ne<this.data.length;ne++)q+=d(this.data[ne])+"0";return q+=d("*"),{data:q,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),C})(s.default),g=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],u=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(S){return b(v(S))}function b(S){return u[S].toString(2)}function x(S){return g[S]}function v(S){return g.indexOf(S)}function _(S){for(var C=0,B=0;B<S.length;B++)C+=v(S[B]);return C=C%43,C}return uo.CODE39=p,uo}var Qn={},yc={},gc={},vt={},Fb;function qo(){if(Fb)return vt;Fb=1,Object.defineProperty(vt,"__esModule",{value:!0});var n;function e(g,u,d){return u in g?Object.defineProperty(g,u,{value:d,enumerable:!0,configurable:!0,writable:!0}):g[u]=d,g}var s=vt.SET_A=0,i=vt.SET_B=1,o=vt.SET_C=2;vt.SHIFT=98;var c=vt.START_A=103,m=vt.START_B=104,p=vt.START_C=105;return vt.MODULO=103,vt.STOP=106,vt.FNC1=207,vt.SET_BY_CODE=(n={},e(n,c,s),e(n,m,i),e(n,p,o),n),vt.SWAP={101:s,100:i,99:o},vt.A_START_CHAR="Ð",vt.B_START_CHAR="Ñ",vt.C_START_CHAR="Ò",vt.A_CHARS="[\0-_È-Ï]",vt.B_CHARS="[ -È-Ï]",vt.C_CHARS="(Ï*[0-9]{2}Ï*)",vt.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],vt}var Gb;function Du(){if(Gb)return gc;Gb=1,Object.defineProperty(gc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){c(this,d);var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b.substring(1),x));return v.bytes=b.split("").map(function(_){return _.charCodeAt(0)}),v}return n(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.bytes,v=x.shift()-105,_=i.SET_BY_CODE[v];if(_===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&x.unshift(i.FNC1);var S=d.next(x,1,_);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(v)+S.result+d.getBar((S.checksum+v)%i.MODULO)+d.getBar(i.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var x=this.options.ean128||!1;return typeof x=="string"&&(x=x.toLowerCase()==="true"),x}}],[{key:"getBar",value:function(x){return i.BARS[x]?i.BARS[x].toString():""}},{key:"correctIndex",value:function(x,v){if(v===i.SET_A){var _=x.shift();return _<32?_+64:_-32}else return v===i.SET_B?x.shift()-32:(x.shift()-48)*10+x.shift()-48}},{key:"next",value:function(x,v,_){if(!x.length)return{result:"",checksum:0};var S=void 0,C=void 0;if(x[0]>=200){C=x.shift()-105;var B=i.SWAP[C];B!==void 0?S=d.next(x,v+1,B):((_===i.SET_A||_===i.SET_B)&&C===i.SHIFT&&(x[0]=_===i.SET_A?x[0]>95?x[0]-96:x[0]:x[0]<32?x[0]+96:x[0]),S=d.next(x,v+1,_))}else C=d.correctIndex(x,_),S=d.next(x,v+1,_);var q=d.getBar(C),ne=C*v;return{result:q+S.result,checksum:ne+S.checksum}}}]),d})(s.default);return gc.default=g,gc}var bc={},Vb;function nN(){if(Vb)return bc;Vb=1,Object.defineProperty(bc,"__esModule",{value:!0});var n=qo(),e=function(p){return p.match(new RegExp("^"+n.A_CHARS+"*"))[0].length},s=function(p){return p.match(new RegExp("^"+n.B_CHARS+"*"))[0].length},i=function(p){return p.match(new RegExp("^"+n.C_CHARS+"*"))[0]};function o(m,p){var g=p?n.A_CHARS:n.B_CHARS,u=m.match(new RegExp("^("+g+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+c(m.substring(u[1].length));var d=m.match(new RegExp("^"+g+"+"))[0];return d.length===m.length?m:d+String.fromCharCode(p?205:206)+o(m.substring(d.length),!p)}function c(m){var p=i(m),g=p.length;if(g===m.length)return m;m=m.substring(g);var u=e(m)>=s(m);return p+String.fromCharCode(u?206:205)+o(m,u)}return bc.default=function(m){var p=void 0,g=i(m).length;if(g>=2)p=n.C_START_CHAR+c(m);else{var u=e(m)>s(m);p=(u?n.A_START_CHAR:n.B_START_CHAR)+o(m,u)}return p.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,b){return"Ë"+b})},bc}var Yb;function rN(){if(Yb)return yc;Yb=1,Object.defineProperty(yc,"__esModule",{value:!0});var n=Du(),e=o(n),s=nN(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){if(c(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(b))var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,i.default)(b),x));else var v=m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x));return m(v)}return d})(e.default);return yc.default=g,yc}var xc={},Kb;function sN(){if(Kb)return xc;Kb=1,Object.defineProperty(xc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.A_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.A_CHARS+"+$").test(this.data)}}]),d})(s.default);return xc.default=g,xc}var vc={},Jb;function iN(){if(Jb)return vc;Jb=1,Object.defineProperty(vc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.B_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.B_CHARS+"+$").test(this.data)}}]),d})(s.default);return vc.default=g,vc}var _c={},Qb;function aN(){if(Qb)return _c;Qb=1,Object.defineProperty(_c,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Du(),s=o(e),i=qo();function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,i.C_START_CHAR+b,x))}return n(d,[{key:"valid",value:function(){return new RegExp("^"+i.C_CHARS+"+$").test(this.data)}}]),d})(s.default);return _c.default=g,_c}var Xb;function oN(){if(Xb)return Qn;Xb=1,Object.defineProperty(Qn,"__esModule",{value:!0}),Qn.CODE128C=Qn.CODE128B=Qn.CODE128A=Qn.CODE128=void 0;var n=rN(),e=g(n),s=sN(),i=g(s),o=iN(),c=g(o),m=aN(),p=g(m);function g(u){return u&&u.__esModule?u:{default:u}}return Qn.CODE128=e.default,Qn.CODE128A=i.default,Qn.CODE128B=c.default,Qn.CODE128C=p.default,Qn}var Jt={},wc={},Rr={},Wb;function Po(){return Wb||(Wb=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.SIDE_BIN="101",Rr.MIDDLE_BIN="01010",Rr.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},Rr.EAN2_STRUCTURE=["LL","LG","GL","GG"],Rr.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Rr.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Rr}var Sc={},Ec={},Zb;function Bo(){if(Zb)return Ec;Zb=1,Object.defineProperty(Ec,"__esModule",{value:!0});var n=Po(),e=function(i,o,c){var m=i.split("").map(function(g,u){return n.BINARIES[o[u]]}).map(function(g,u){return g?g[i[u]]:""});if(c){var p=i.length-1;m=m.map(function(g,u){return u<p?g+c:g})}return m.join("")};return Ec.default=e,Ec}var e1;function Nv(){if(e1)return Sc;e1=1,Object.defineProperty(Sc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){p(this,x);var S=g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.fontSize=!_.flat&&_.fontSize>_.width*10?_.width*10:_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(_,S){return this.text.substr(_,S)}},{key:"leftEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"rightText",value:function(_,S){return this.text.substr(_,S)}},{key:"rightEncode",value:function(_,S){return(0,i.default)(_,S)}},{key:"encodeGuarded",value:function(){var _={fontSize:this.fontSize},S={height:this.guardHeight};return[{data:e.SIDE_BIN,options:S},{data:this.leftEncode(),text:this.leftText(),options:_},{data:e.MIDDLE_BIN,options:S},{data:this.rightEncode(),text:this.rightText(),options:_},{data:e.SIDE_BIN,options:S}]}},{key:"encodeFlat",value:function(){var _=[e.SIDE_BIN,this.leftEncode(),e.MIDDLE_BIN,this.rightEncode(),e.SIDE_BIN];return{data:_.join(""),text:this.text}}}]),x})(c.default);return Sc.default=d,Sc}var t1;function lN(){if(t1)return wc;t1=1,Object.defineProperty(wc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=function b(x,v,_){x===null&&(x=Function.prototype);var S=Object.getOwnPropertyDescriptor(x,v);if(S===void 0){var C=Object.getPrototypeOf(x);return C===null?void 0:b(C,v,_)}else{if("value"in S)return S.value;var B=S.get;return B===void 0?void 0:B.call(_)}},s=Po(),i=Nv(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=function(x){var v=x.substr(0,12).split("").map(function(_){return+_}).reduce(function(_,S,C){return C%2?_+S*3:_+S},0);return(10-v%10)%10},d=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{12}$/)!==-1&&(v+=u(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.lastChar=_.lastChar,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===u(this.data)}},{key:"leftText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var _=this.data.substr(1,6),S=s.EAN13_STRUCTURE[this.data[0]];return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"leftEncode",this).call(this,_,S)}},{key:"rightText",value:function(){return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var _=this.data.substr(7,6);return e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"rightEncode",this).call(this,_,"RRRRRR")}},{key:"encodeGuarded",value:function(){var _=e(x.prototype.__proto__||Object.getPrototypeOf(x.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(_.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(_.push({data:"00"}),_.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),_}}]),x})(o.default);return wc.default=d,wc}var Oc={},n1;function cN(){if(n1)return Oc;n1=1,Object.defineProperty(Oc,"__esModule",{value:!0});var n=(function(){function d(b,x){for(var v=0;v<x.length;v++){var _=x[v];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,x,v){return x&&d(b.prototype,x),v&&d(b,v),b}})(),e=function d(b,x,v){b===null&&(b=Function.prototype);var _=Object.getOwnPropertyDescriptor(b,x);if(_===void 0){var S=Object.getPrototypeOf(b);return S===null?void 0:d(S,x,v)}else{if("value"in _)return _.value;var C=_.get;return C===void 0?void 0:C.call(v)}},s=Nv(),i=o(s);function o(d){return d&&d.__esModule?d:{default:d}}function c(d,b){if(!(d instanceof b))throw new TypeError("Cannot call a class as a function")}function m(d,b){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:d}function p(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);d.prototype=Object.create(b&&b.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(d,b):d.__proto__=b)}var g=function(b){var x=b.substr(0,7).split("").map(function(v){return+v}).reduce(function(v,_,S){return S%2?v+_:v+_*3},0);return(10-x%10)%10},u=(function(d){p(b,d);function b(x,v){return c(this,b),x.search(/^[0-9]{7}$/)!==-1&&(x+=g(x)),m(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,x,v))}return n(b,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===g(this.data)}},{key:"leftText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var v=this.data.substr(0,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"leftEncode",this).call(this,v,"LLLL")}},{key:"rightText",value:function(){return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var v=this.data.substr(4,4);return e(b.prototype.__proto__||Object.getPrototypeOf(b.prototype),"rightEncode",this).call(this,v,"RRRR")}}]),b})(i.default);return Oc.default=u,Oc}var Ac={},r1;function uN(){if(r1)return Ac;r1=1,Object.defineProperty(Ac,"__esModule",{value:!0});var n=(function(){function x(v,_){for(var S=0;S<_.length;S++){var C=_[S];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(v,C.key,C)}}return function(v,_,S){return _&&x(v.prototype,_),S&&x(v,S),v}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(x){return x&&x.__esModule?x:{default:x}}function p(x,v){if(!(x instanceof v))throw new TypeError("Cannot call a class as a function")}function g(x,v){if(!x)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:x}function u(x,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);x.prototype=Object.create(v&&v.prototype,{constructor:{value:x,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(x,v):x.__proto__=v)}var d=function(v){var _=v.split("").map(function(S){return+S}).reduce(function(S,C,B){return B%2?S+C*9:S+C*3},0);return _%10},b=(function(x){u(v,x);function v(_,S){return p(this,v),g(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,_,S))}return n(v,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var S=e.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,i.default)(this.data,S,"01"),text:this.text}}}]),v})(c.default);return Ac.default=b,Ac}var jc={},s1;function fN(){if(s1)return jc;s1=1,Object.defineProperty(jc,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})(),e=Po(),s=Bo(),i=m(s),o=Nn(),c=m(o);function m(b){return b&&b.__esModule?b:{default:b}}function p(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function g(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function u(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var d=(function(b){u(x,b);function x(v,_){return p(this,x),g(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_))}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var _=e.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,i.default)(this.data,_,"01"),text:this.text}}}]),x})(c.default);return jc.default=d,jc}var fo={},i1;function Tv(){if(i1)return fo;i1=1,Object.defineProperty(fo,"__esModule",{value:!0});var n=(function(){function b(x,v){for(var _=0;_<v.length;_++){var S=v[_];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(x,S.key,S)}}return function(x,v,_){return v&&b(x.prototype,v),_&&b(x,_),x}})();fo.checksum=d;var e=Bo(),s=c(e),i=Nn(),o=c(i);function c(b){return b&&b.__esModule?b:{default:b}}function m(b,x){if(!(b instanceof x))throw new TypeError("Cannot call a class as a function")}function p(b,x){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:b}function g(b,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);b.prototype=Object.create(x&&x.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(b,x):b.__proto__=x)}var u=(function(b){g(x,b);function x(v,_){m(this,x),v.search(/^[0-9]{11}$/)!==-1&&(v+=d(v));var S=p(this,(x.__proto__||Object.getPrototypeOf(x)).call(this,v,_));return S.displayValue=_.displayValue,_.fontSize>_.width*10?S.fontSize=_.width*10:S.fontSize=_.fontSize,S.guardHeight=_.height+S.fontSize/2+_.textMargin,S}return n(x,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var _="";return _+="101",_+=(0,s.default)(this.data.substr(0,6),"LLLLLL"),_+="01010",_+=(0,s.default)(this.data.substr(6,6),"RRRRRR"),_+="101",{data:_,text:this.text}}},{key:"guardedEncoding",value:function(){var _=[];return this.displayValue&&_.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),_.push({data:"101"+(0,s.default)(this.data[0],"L"),options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),_.push({data:"01010",options:{height:this.guardHeight}}),_.push({data:(0,s.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),_.push({data:(0,s.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&_.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),_}}]),x})(o.default);function d(b){var x=0,v;for(v=1;v<11;v+=2)x+=parseInt(b[v]);for(v=0;v<11;v+=2)x+=parseInt(b[v])*3;return(10-x%10)%10}return fo.default=u,fo}var kc={},a1;function hN(){if(a1)return kc;a1=1,Object.defineProperty(kc,"__esModule",{value:!0});var n=(function(){function _(S,C){for(var B=0;B<C.length;B++){var q=C[B];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(S,q.key,q)}}return function(S,C,B){return C&&_(S.prototype,C),B&&_(S,B),S}})(),e=Bo(),s=m(e),i=Nn(),o=m(i),c=Tv();function m(_){return _&&_.__esModule?_:{default:_}}function p(_,S){if(!(_ instanceof S))throw new TypeError("Cannot call a class as a function")}function g(_,S){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:_}function u(_,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);_.prototype=Object.create(S&&S.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(_,S):_.__proto__=S)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],b=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],x=(function(_){u(S,_);function S(C,B){p(this,S);var q=g(this,(S.__proto__||Object.getPrototypeOf(S)).call(this,C,B));if(q.isValid=!1,C.search(/^[0-9]{6}$/)!==-1)q.middleDigits=C,q.upcA=v(C,"0"),q.text=B.text||""+q.upcA[0]+C+q.upcA[q.upcA.length-1],q.isValid=!0;else if(C.search(/^[01][0-9]{7}$/)!==-1)if(q.middleDigits=C.substring(1,C.length-1),q.upcA=v(q.middleDigits,C[0]),q.upcA[q.upcA.length-1]===C[C.length-1])q.isValid=!0;else return g(q);else return g(q);return q.displayValue=B.displayValue,B.fontSize>B.width*10?q.fontSize=B.width*10:q.fontSize=B.fontSize,q.guardHeight=B.height+q.fontSize/2+B.textMargin,q}return n(S,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var B="";return B+="101",B+=this.encodeMiddleDigits(),B+="010101",{data:B,text:this.text}}},{key:"guardedEncoding",value:function(){var B=[];return this.displayValue&&B.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),B.push({data:"101",options:{height:this.guardHeight}}),B.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),B.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&B.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),B}},{key:"encodeMiddleDigits",value:function(){var B=this.upcA[0],q=this.upcA[this.upcA.length-1],ne=b[parseInt(q)][parseInt(B)];return(0,s.default)(this.middleDigits,ne)}}]),S})(o.default);function v(_,S){for(var C=parseInt(_[_.length-1]),B=d[C],q="",ne=0,te=0;te<B.length;te++){var M=B[te];M==="X"?q+=_[ne++]:q+=M}return q=""+S+q,""+q+(0,c.checksum)(q)}return kc.default=x,kc}var o1;function dN(){if(o1)return Jt;o1=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.UPCE=Jt.UPC=Jt.EAN2=Jt.EAN5=Jt.EAN8=Jt.EAN13=void 0;var n=lN(),e=x(n),s=cN(),i=x(s),o=uN(),c=x(o),m=fN(),p=x(m),g=Tv(),u=x(g),d=hN(),b=x(d);function x(v){return v&&v.__esModule?v:{default:v}}return Jt.EAN13=e.default,Jt.EAN8=i.default,Jt.EAN5=c.default,Jt.EAN2=p.default,Jt.UPC=u.default,Jt.UPCE=b.default,Jt}var Xs={},Nc={},Gi={},l1;function mN(){return l1||(l1=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.START_BIN="1010",Gi.END_BIN="11101",Gi.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Gi}var c1;function Cv(){if(c1)return Nc;c1=1,Object.defineProperty(Nc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=mN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return n(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var x=this,v=this.data.match(/.{2}/g).map(function(_){return x.encodePair(_)}).join("");return{data:e.START_BIN+v+e.END_BIN,text:this.text}}},{key:"encodePair",value:function(x){var v=e.BINARIES[x[1]];return e.BINARIES[x[0]].split("").map(function(_,S){return(_==="1"?"111":"1")+(v[S]==="1"?"000":"0")}).join("")}}]),d})(i.default);return Nc.default=g,Nc}var Tc={},u1;function pN(){if(u1)return Tc;u1=1,Object.defineProperty(Tc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Cv(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=function(d){var b=d.substr(0,13).split("").map(function(x){return parseInt(x,10)}).reduce(function(x,v,_){return x+v*(3-_%2*2)},0);return Math.ceil(b/10)*10-b},g=(function(u){m(d,u);function d(b,x){return o(this,d),b.search(/^[0-9]{13}$/)!==-1&&(b+=p(b)),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===p(this.data)}}]),d})(s.default);return Tc.default=g,Tc}var f1;function yN(){if(f1)return Xs;f1=1,Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.ITF14=Xs.ITF=void 0;var n=Cv(),e=o(n),s=pN(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Xs.ITF=e.default,Xs.ITF14=i.default,Xs}var vn={},Cc={},h1;function Uo(){if(h1)return Cc;h1=1,Object.defineProperty(Cc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=Nn(),s=i(e);function i(u){return u&&u.__esModule?u:{default:u}}function o(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function c(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function m(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var p=(function(u){m(d,u);function d(b,x){return o(this,d),c(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"encode",value:function(){for(var x="110",v=0;v<this.data.length;v++){var _=parseInt(this.data[v]),S=_.toString(2);S=g(S,4-S.length);for(var C=0;C<S.length;C++)x+=S[C]=="0"?"100":"110"}return x+="1001",{data:x,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(s.default);function g(u,d){for(var b=0;b<d;b++)u="0"+u;return u}return Cc.default=p,Cc}var Mc={},ho={},d1;function Lu(){if(d1)return ho;d1=1,Object.defineProperty(ho,"__esModule",{value:!0}),ho.mod10=n,ho.mod11=e;function n(s){for(var i=0,o=0;o<s.length;o++){var c=parseInt(s[o]);(o+s.length)%2===0?i+=c:i+=c*2%10+Math.floor(c*2/10)}return(10-i%10)%10}function e(s){for(var i=0,o=[2,3,4,5,6,7],c=0;c<s.length;c++){var m=parseInt(s[s.length-1-c]);i+=o[c%o.length]*m}return(11-i%11)%11}return ho}var m1;function gN(){if(m1)return Mc;m1=1,Object.defineProperty(Mc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod10)(d),b))}return u})(e.default);return Mc.default=p,Mc}var Rc={},p1;function bN(){if(p1)return Rc;p1=1,Object.defineProperty(Rc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d+(0,s.mod11)(d),b))}return u})(e.default);return Rc.default=p,Rc}var Dc={},y1;function xN(){if(y1)return Dc;y1=1,Object.defineProperty(Dc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod10)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Dc.default=p,Dc}var Lc={},g1;function vN(){if(g1)return Lc;g1=1,Object.defineProperty(Lc,"__esModule",{value:!0});var n=Uo(),e=i(n),s=Lu();function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),d+=(0,s.mod11)(d),d+=(0,s.mod10)(d),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return u})(e.default);return Lc.default=p,Lc}var b1;function _N(){if(b1)return vn;b1=1,Object.defineProperty(vn,"__esModule",{value:!0}),vn.MSI1110=vn.MSI1010=vn.MSI11=vn.MSI10=vn.MSI=void 0;var n=Uo(),e=d(n),s=gN(),i=d(s),o=bN(),c=d(o),m=xN(),p=d(m),g=vN(),u=d(g);function d(b){return b&&b.__esModule?b:{default:b}}return vn.MSI=e.default,vn.MSI10=i.default,vn.MSI11=c.default,vn.MSI1010=p.default,vn.MSI1110=u.default,vn}var mo={},x1;function wN(){if(x1)return mo;x1=1,Object.defineProperty(mo,"__esModule",{value:!0}),mo.pharmacode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u);var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b));return x.number=parseInt(d,10),x}return n(u,[{key:"encode",value:function(){for(var b=this.number,x="";!isNaN(b)&&b!=0;)b%2===0?(x="11100"+x,b=(b-2)/2):(x="100"+x,b=(b-1)/2);return x=x.slice(0,-2),{data:x,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),u})(s.default);return mo.pharmacode=p,mo}var po={},v1;function SN(){if(v1)return po;v1=1,Object.defineProperty(po,"__esModule",{value:!0}),po.codabar=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){o(this,u),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var x=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d.toUpperCase(),b));return x.text=x.options.text||x.text.replace(/[A-D]/g,""),x}return n(u,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var b=[],x=this.getEncodings(),v=0;v<this.data.length;v++)b.push(x[this.data.charAt(v)]),v!==this.data.length-1&&b.push("0");return{text:this.text,data:b.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),u})(s.default);return po.codabar=p,po}var Ws={},qc={},Vi={},_1;function EN(){return _1||(_1=1,Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Vi.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],Vi.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),Vi}var w1;function Mv(){if(w1)return qc;w1=1,Object.defineProperty(qc,"__esModule",{value:!0});var n=(function(){function u(d,b){for(var x=0;x<b.length;x++){var v=b[x];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,v.key,v)}}return function(d,b,x){return b&&u(d.prototype,b),x&&u(d,x),d}})(),e=EN(),s=Nn(),i=o(s);function o(u){return u&&u.__esModule?u:{default:u}}function c(u,d){if(!(u instanceof d))throw new TypeError("Cannot call a class as a function")}function m(u,d){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:u}function p(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);u.prototype=Object.create(d&&d.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(u,d):u.__proto__=d)}var g=(function(u){p(d,u);function d(b,x){return c(this,d),m(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,b,x))}return n(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var x=this.data.split("").flatMap(function(C){return e.MULTI_SYMBOLS[C]||C}),v=x.map(function(C){return d.getEncoding(C)}).join(""),_=d.checksum(x,20),S=d.checksum(x.concat(_),15);return{text:this.text,data:d.getEncoding("ÿ")+v+d.getEncoding(_)+d.getEncoding(S)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(x){return e.BINARIES[d.symbolValue(x)]}},{key:"getSymbol",value:function(x){return e.SYMBOLS[x]}},{key:"symbolValue",value:function(x){return e.SYMBOLS.indexOf(x)}},{key:"checksum",value:function(x,v){var _=x.slice().reverse().reduce(function(S,C,B){var q=B%v+1;return S+d.symbolValue(C)*q},0);return d.getSymbol(_%47)}}]),d})(i.default);return qc.default=g,qc}var Pc={},S1;function ON(){if(S1)return Pc;S1=1,Object.defineProperty(Pc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Mv(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),u})(s.default);return Pc.default=p,Pc}var E1;function AN(){if(E1)return Ws;E1=1,Object.defineProperty(Ws,"__esModule",{value:!0}),Ws.CODE93FullASCII=Ws.CODE93=void 0;var n=Mv(),e=o(n),s=ON(),i=o(s);function o(c){return c&&c.__esModule?c:{default:c}}return Ws.CODE93=e.default,Ws.CODE93FullASCII=i.default,Ws}var yo={},O1;function jN(){if(O1)return yo;O1=1,Object.defineProperty(yo,"__esModule",{value:!0}),yo.GenericBarcode=void 0;var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=Nn(),s=i(e);function i(g){return g&&g.__esModule?g:{default:g}}function o(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}function c(g,u){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:g}function m(g,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);g.prototype=Object.create(u&&u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(g,u):g.__proto__=u)}var p=(function(g){m(u,g);function u(d,b){return o(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,d,b))}return n(u,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),u})(s.default);return yo.GenericBarcode=p,yo}var A1;function kN(){if(A1)return mc;A1=1,Object.defineProperty(mc,"__esModule",{value:!0});var n=tN(),e=oN(),s=dN(),i=yN(),o=_N(),c=wN(),m=SN(),p=AN(),g=jN();return mc.default={CODE39:n.CODE39,CODE128:e.CODE128,CODE128A:e.CODE128A,CODE128B:e.CODE128B,CODE128C:e.CODE128C,EAN13:s.EAN13,EAN8:s.EAN8,EAN5:s.EAN5,EAN2:s.EAN2,UPC:s.UPC,UPCE:s.UPCE,ITF14:i.ITF14,ITF:i.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:c.pharmacode,codabar:m.codabar,CODE93:p.CODE93,CODE93FullASCII:p.CODE93FullASCII,GenericBarcode:g.GenericBarcode},mc}var Bc={},j1;function qu(){if(j1)return Bc;j1=1,Object.defineProperty(Bc,"__esModule",{value:!0});var n=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e};return Bc.default=function(e,s){return n({},e,s)},Bc}var Uc={},k1;function NN(){if(k1)return Uc;k1=1,Object.defineProperty(Uc,"__esModule",{value:!0}),Uc.default=n;function n(e){var s=[];function i(o){if(Array.isArray(o))for(var c=0;c<o.length;c++)i(o[c]);else o.text=o.text||"",o.data=o.data||"",s.push(o)}return i(e),s}return Uc}var zc={},N1;function TN(){if(N1)return zc;N1=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.default=n;function n(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}return zc}var Ic={},$c={},Hc={},T1;function Rv(){if(T1)return Hc;T1=1,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.default=n;function n(e){var s=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var i in s)s.hasOwnProperty(i)&&(i=s[i],typeof e[i]=="string"&&(e[i]=parseInt(e[i],10)));return typeof e.displayValue=="string"&&(e.displayValue=e.displayValue!="false"),e}return Hc}var Fc={},C1;function Dv(){if(C1)return Fc;C1=1,Object.defineProperty(Fc,"__esModule",{value:!0});var n={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Fc.default=n,Fc}var M1;function CN(){if(M1)return $c;M1=1,Object.defineProperty($c,"__esModule",{value:!0});var n=Rv(),e=o(n),s=Dv(),i=o(s);function o(m){return m&&m.__esModule?m:{default:m}}function c(m){var p={};for(var g in i.default)i.default.hasOwnProperty(g)&&(m.hasAttribute("jsbarcode-"+g.toLowerCase())&&(p[g]=m.getAttribute("jsbarcode-"+g.toLowerCase())),m.hasAttribute("data-"+g.toLowerCase())&&(p[g]=m.getAttribute("data-"+g.toLowerCase())));return p.value=m.getAttribute("jsbarcode-value")||m.getAttribute("data-value"),p=(0,e.default)(p),p}return $c.default=c,$c}var Gc={},Vc={},_n={},R1;function Lv(){if(R1)return _n;R1=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.getTotalWidthOfEncodings=_n.calculateEncodingAttributes=_n.getBarcodePadding=_n.getEncodingHeight=_n.getMaximumHeightOfEncodings=void 0;var n=qu(),e=s(n);function s(u){return u&&u.__esModule?u:{default:u}}function i(u,d){return d.height+(d.displayValue&&u.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(u,d,b){if(b.displayValue&&d<u){if(b.textAlign=="center")return Math.floor((u-d)/2);if(b.textAlign=="left")return 0;if(b.textAlign=="right")return Math.floor(u-d)}return 0}function c(u,d,b){for(var x=0;x<u.length;x++){var v=u[x],_=(0,e.default)(d,v.options),S;_.displayValue?S=g(v.text,_,b):S=0;var C=v.data.length*_.width;v.width=Math.ceil(Math.max(S,C)),v.height=i(v,_),v.barcodePadding=o(S,C,_)}}function m(u){for(var d=0,b=0;b<u.length;b++)d+=u[b].width;return d}function p(u){for(var d=0,b=0;b<u.length;b++)u[b].height>d&&(d=u[b].height);return d}function g(u,d,b){var x;if(b)x=b;else if(typeof document<"u")x=document.createElement("canvas").getContext("2d");else return 0;x.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var v=x.measureText(u);if(!v)return 0;var _=v.width;return _}return _n.getMaximumHeightOfEncodings=p,_n.getEncodingHeight=i,_n.getBarcodePadding=o,_n.calculateEncodingAttributes=c,_n.getTotalWidthOfEncodings=m,_n}var D1;function MN(){if(D1)return Vc;D1=1,Object.defineProperty(Vc,"__esModule",{value:!0});var n=(function(){function p(g,u){for(var d=0;d<u.length;d++){var b=u[d];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}return function(g,u,d){return u&&p(g.prototype,u),d&&p(g,d),g}})(),e=qu(),s=o(e),i=Lv();function o(p){return p&&p.__esModule?p:{default:p}}function c(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var m=(function(){function p(g,u,d){c(this,p),this.canvas=g,this.encodings=u,this.options=d}return n(p,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var u=0;u<this.encodings.length;u++){var d=(0,s.default)(this.options,this.encodings[u].options);this.drawCanvasBarcode(d,this.encodings[u]),this.drawCanvasText(d,this.encodings[u]),this.moveCanvasDrawing(this.encodings[u])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var u=this.canvas.getContext("2d");u.save(),(0,i.calculateEncodingAttributes)(this.encodings,this.options,u);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=b,u.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(u.fillStyle=this.options.background,u.fillRect(0,0,this.canvas.width,this.canvas.height)),u.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(u,d){var b=this.canvas.getContext("2d"),x=d.data,v;u.textPosition=="top"?v=u.marginTop+u.fontSize+u.textMargin:v=u.marginTop,b.fillStyle=u.lineColor;for(var _=0;_<x.length;_++){var S=_*u.width+d.barcodePadding;x[_]==="1"?b.fillRect(S,v,u.width,u.height):x[_]&&b.fillRect(S,v,u.width,u.height*x[_])}}},{key:"drawCanvasText",value:function(u,d){var b=this.canvas.getContext("2d"),x=u.fontOptions+" "+u.fontSize+"px "+u.font;if(u.displayValue){var v,_;u.textPosition=="top"?_=u.marginTop+u.fontSize-u.textMargin:_=u.height+u.textMargin+u.marginTop+u.fontSize,b.font=x,u.textAlign=="left"||d.barcodePadding>0?(v=0,b.textAlign="left"):u.textAlign=="right"?(v=d.width-1,b.textAlign="right"):(v=d.width/2,b.textAlign="center"),b.fillText(d.text,v,_)}}},{key:"moveCanvasDrawing",value:function(u){var d=this.canvas.getContext("2d");d.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),p})();return Vc.default=m,Vc}var Yc={},L1;function RN(){if(L1)return Yc;L1=1,Object.defineProperty(Yc,"__esModule",{value:!0});var n=(function(){function g(u,d){for(var b=0;b<d.length;b++){var x=d[b];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(u,x.key,x)}}return function(u,d,b){return d&&g(u.prototype,d),b&&g(u,b),u}})(),e=qu(),s=o(e),i=Lv();function o(g){return g&&g.__esModule?g:{default:g}}function c(g,u){if(!(g instanceof u))throw new TypeError("Cannot call a class as a function")}var m="http://www.w3.org/2000/svg",p=(function(){function g(u,d,b){c(this,g),this.svg=u,this.encodings=d,this.options=b,this.document=b.xmlDocument||document}return n(g,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var b=0;b<this.encodings.length;b++){var x=this.encodings[b],v=(0,s.default)(this.options,x.options),_=this.createGroup(d,v.marginTop,this.svg);this.setGroupOptions(_,v),this.drawSvgBarcode(_,v,x),this.drawSVGText(_,v,x),d+=x.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,i.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,i.getTotalWidthOfEncodings)(this.encodings),b=(0,i.getMaximumHeightOfEncodings)(this.encodings),x=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(x,b),this.options.background&&this.drawRect(0,0,x,b,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,b,x){var v=x.data,_;b.textPosition=="top"?_=b.fontSize+b.textMargin:_=0;for(var S=0,C=0,B=0;B<v.length;B++)C=B*b.width+x.barcodePadding,v[B]==="1"?S++:S>0&&(this.drawRect(C-b.width*S,_,b.width*S,b.height,d),S=0);S>0&&this.drawRect(C-b.width*(S-1),_,b.width*S,b.height,d)}},{key:"drawSVGText",value:function(d,b,x){var v=this.document.createElementNS(m,"text");if(b.displayValue){var _,S;v.setAttribute("font-family",b.font),v.setAttribute("font-size",b.fontSize),b.fontOptions.includes("bold")&&v.setAttribute("font-weight","bold"),b.fontOptions.includes("italic")&&v.setAttribute("font-style","italic"),b.textPosition=="top"?S=b.fontSize-b.textMargin:S=b.height+b.textMargin+b.fontSize,b.textAlign=="left"||x.barcodePadding>0?(_=0,v.setAttribute("text-anchor","start")):b.textAlign=="right"?(_=x.width-1,v.setAttribute("text-anchor","end")):(_=x.width/2,v.setAttribute("text-anchor","middle")),v.setAttribute("x",_),v.setAttribute("y",S),v.appendChild(this.document.createTextNode(x.text)),d.appendChild(v)}}},{key:"setSvgAttributes",value:function(d,b){var x=this.svg;x.setAttribute("width",d+"px"),x.setAttribute("height",b+"px"),x.setAttribute("x","0px"),x.setAttribute("y","0px"),x.setAttribute("viewBox","0 0 "+d+" "+b),x.setAttribute("xmlns",m),x.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,b,x){var v=this.document.createElementNS(m,"g");return v.setAttribute("transform","translate("+d+", "+b+")"),x.appendChild(v),v}},{key:"setGroupOptions",value:function(d,b){d.setAttribute("fill",b.lineColor)}},{key:"drawRect",value:function(d,b,x,v,_){var S=this.document.createElementNS(m,"rect");return S.setAttribute("x",d),S.setAttribute("y",b),S.setAttribute("width",x),S.setAttribute("height",v),_.appendChild(S),S}}]),g})();return Yc.default=p,Yc}var Kc={},q1;function DN(){if(q1)return Kc;q1=1,Object.defineProperty(Kc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o,c,m){e(this,i),this.object=o,this.encodings=c,this.options=m}return n(i,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),i})();return Kc.default=s,Kc}var P1;function LN(){if(P1)return Gc;P1=1,Object.defineProperty(Gc,"__esModule",{value:!0});var n=MN(),e=m(n),s=RN(),i=m(s),o=DN(),c=m(o);function m(p){return p&&p.__esModule?p:{default:p}}return Gc.default={CanvasRenderer:e.default,SVGRenderer:i.default,ObjectRenderer:c.default},Gc}var Yi={},B1;function qv(){if(B1)return Yi;B1=1,Object.defineProperty(Yi,"__esModule",{value:!0});function n(m,p){if(!(m instanceof p))throw new TypeError("Cannot call a class as a function")}function e(m,p){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:m}function s(m,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);m.prototype=Object.create(p&&p.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(m,p):m.__proto__=p)}var i=(function(m){s(p,m);function p(g,u){n(this,p);var d=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return d.name="InvalidInputException",d.symbology=g,d.input=u,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return p})(Error),o=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="InvalidElementException",g.message="Not supported type to render on",g}return p})(Error),c=(function(m){s(p,m);function p(){n(this,p);var g=e(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return g.name="NoElementException",g.message="No element to render on.",g}return p})(Error);return Yi.InvalidInputException=i,Yi.InvalidElementException=o,Yi.NoElementException=c,Yi}var U1;function qN(){if(U1)return Ic;U1=1,Object.defineProperty(Ic,"__esModule",{value:!0});var n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e=CN(),s=m(e),i=LN(),o=m(i),c=qv();function m(d){return d&&d.__esModule?d:{default:d}}function p(d){if(typeof d=="string")return g(d);if(Array.isArray(d)){for(var b=[],x=0;x<d.length;x++)b.push(p(d[x]));return b}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return u(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,s.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,s.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":n(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new c.InvalidElementException}}function g(d){var b=document.querySelectorAll(d);if(b.length!==0){for(var x=[],v=0;v<b.length;v++)x.push(p(b[v]));return x}}function u(d){var b=document.createElement("canvas");return{element:b,options:(0,s.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",b.toDataURL())}}}return Ic.default=p,Ic}var Jc={},z1;function PN(){if(z1)return Jc;z1=1,Object.defineProperty(Jc,"__esModule",{value:!0});var n=(function(){function i(o,c){for(var m=0;m<c.length;m++){var p=c[m];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(o,p.key,p)}}return function(o,c,m){return c&&i(o.prototype,c),m&&i(o,m),o}})();function e(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}var s=(function(){function i(o){e(this,i),this.api=o}return n(i,[{key:"handleCatch",value:function(c){if(c.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw c.message;else throw c;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(c){try{var m=c.apply(void 0,arguments);return this.api._options.valid(!0),m}catch(p){return this.handleCatch(p),this.api}}}]),i})();return Jc.default=s,Jc}var hd,I1;function BN(){if(I1)return hd;I1=1;var n=kN(),e=B(n),s=qu(),i=B(s),o=NN(),c=B(o),m=TN(),p=B(m),g=qN(),u=B(g),d=Rv(),b=B(d),x=PN(),v=B(x),_=qv(),S=Dv(),C=B(S);function B(U){return U&&U.__esModule?U:{default:U}}var q=function(){},ne=function(D,Q,W){var he=new q;if(typeof D>"u")throw Error("No element to render on was provided.");return he._renderProperties=(0,u.default)(D),he._encodings=[],he._options=C.default,he._errorHandler=new v.default(he),typeof Q<"u"&&(W=W||{},W.format||(W.format=ae()),he.options(W)[W.format](Q,W).render()),he};ne.getModule=function(U){return e.default[U]};for(var te in e.default)e.default.hasOwnProperty(te)&&M(e.default,te);function M(U,D){q.prototype[D]=q.prototype[D.toUpperCase()]=q.prototype[D.toLowerCase()]=function(Q,W){var he=this;return he._errorHandler.wrapBarcodeCall(function(){W.text=typeof W.text>"u"?void 0:""+W.text;var Ee=(0,i.default)(he._options,W);Ee=(0,b.default)(Ee);var Ae=U[D],H=z(Q,Ae,Ee);return he._encodings.push(H),he})}}function z(U,D,Q){U=""+U;var W=new D(U,Q);if(!W.valid())throw new _.InvalidInputException(W.constructor.name,U);var he=W.encode();he=(0,c.default)(he);for(var Ee=0;Ee<he.length;Ee++)he[Ee].options=(0,i.default)(Q,he[Ee].options);return he}function ae(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}q.prototype.options=function(U){return this._options=(0,i.default)(this._options,U),this},q.prototype.blank=function(U){var D=new Array(U+1).join("0");return this._encodings.push({data:D}),this},q.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var U;for(var D in this._renderProperties){U=this._renderProperties[D];var Q=(0,i.default)(this._options,U.options);Q.format=="auto"&&(Q.format=ae()),this._errorHandler.wrapBarcodeCall(function(){var W=Q.value,he=e.default[Q.format.toUpperCase()],Ee=z(W,he,Q);F(U,Ee,Q)})}}},q.prototype.render=function(){if(!this._renderProperties)throw new _.NoElementException;if(Array.isArray(this._renderProperties))for(var U=0;U<this._renderProperties.length;U++)F(this._renderProperties[U],this._encodings,this._options);else F(this._renderProperties,this._encodings,this._options);return this},q.prototype._defaults=C.default;function F(U,D,Q){D=(0,c.default)(D);for(var W=0;W<D.length;W++)D[W].options=(0,i.default)(Q,D[W].options),(0,p.default)(D[W].options);(0,p.default)(Q);var he=U.renderer,Ee=new he(U.element,D,Q);Ee.render(),U.afterRender&&U.afterRender()}return typeof window<"u"&&(window.JsBarcode=ne),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(U,D){var Q=[];return jQuery(this).each(function(){Q.push(this)}),ne(Q,U,D)}),hd=ne,hd}var UN=BN();const zN=uS(UN),IN={[ke.EXECUTED]:"Executed",[ke.MATCHED_LIST]:"Matched list",[ke.CONFIRM_REQUIRED]:"Awaiting confirmation",[ke.NO_MATCH_FALLBACK]:"No match",[ke.UNCONFIGURED]:"Not configured",[ke.INVALID_CODE]:"Invalid code",[ke.FORBIDDEN]:"Not permitted",[ke.CONFLICT]:"Conflict",[ke.IDENTITY_PRIMED]:"Identity primed",[ke.IDENTITY_UNKNOWN]:"Badge not recognized",[ke.NOT_PRIMED]:"Badge required",[ke.CHOICES]:"Choices presented",[ke.NO_OPEN_CONTAINER]:"Container closing, scan again",[ke.HELD]:"Holding",[ke.REFUSED]:"Not placed",[ke.SUBJECT_STALE]:"Scan it again"},$N={[ke.EXECUTED]:"text-status-success",[ke.MATCHED_LIST]:"text-status-success",[ke.CONFIRM_REQUIRED]:"text-status-warning",[ke.NO_MATCH_FALLBACK]:"text-text-secondary",[ke.UNCONFIGURED]:"text-status-warning",[ke.INVALID_CODE]:"text-status-error",[ke.FORBIDDEN]:"text-status-error",[ke.CONFLICT]:"text-status-warning",[ke.IDENTITY_PRIMED]:"text-status-success",[ke.IDENTITY_UNKNOWN]:"text-status-warning",[ke.NOT_PRIMED]:"text-status-warning",[ke.CHOICES]:"text-status-success",[ke.NO_OPEN_CONTAINER]:"text-status-warning",[ke.HELD]:"text-status-success",[ke.REFUSED]:"text-status-error",[ke.SUBJECT_STALE]:"text-status-warning"};function HN(n){return n.outcome===ke.IDENTITY_PRIMED&&n.actor?`Hi ${n.actor.displayName}`:`${IN[n.outcome]}${n.rule?` — ${n.rule.name}`:""}`}function FN(n){var e,s,i,o,c,m,p;return n.outcome===ke.NO_MATCH_FALLBACK?((e=n.fallback)==null?void 0:e.markdown)??null:n.outcome===ke.IDENTITY_UNKNOWN?((s=n.fallback)==null?void 0:s.markdown)??null:n.outcome===ke.NOT_PRIMED?((i=n.notPrimed)==null?void 0:i.markdown)??null:n.outcome===ke.NO_OPEN_CONTAINER?((o=n.fallback)==null?void 0:o.markdown)??null:n.outcome===ke.REFUSED?((c=n.refusal)==null?void 0:c.markdown)??n.error??null:n.outcome===ke.HELD?((p=(m=n.subject)==null?void 0:m.expect)==null?void 0:p.prompt)??null:n.outcome===ke.SUBJECT_STALE?n.error??null:null}function gs(n){return n.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function GN({content:n,compact:e,inherit:s}){const i=[],o=/^```(\w*)\n([\s\S]*?)^```$/gm;let c=0,m;for(;(m=o.exec(n))!==null;)m.index>c&&i.push({type:"text",text:n.slice(c,m.index)}),i.push({type:"code",lang:m[1],code:m[2].replace(/\n$/,"")}),c=m.index+m[0].length;c<n.length&&i.push({type:"text",text:n.slice(c)});const p=s?{text:"",heading:"",list:"",code:"text-[0.85em]",tone:""}:e?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-2xs",tone:"text-text-secondary"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs",tone:"text-text-secondary"},g=[];for(const u of i){if(u.type==="code"){const d=u.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");g.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${p.code} font-mono text-text-secondary leading-relaxed">${d}</code></pre>`);continue}g.push(...VN(u.text,p))}return h.jsx("div",{className:s?void 0:"prose-sm",dangerouslySetInnerHTML:{__html:g.join(`
55
55
  `)}})}function VN(n,e){const s=n.split(`
56
- `),i=[];let o=!1,c=!1,m=[];for(const p of s){const g=p.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(d=>d.trim());if(u.every(d=>/^[-:]+$/.test(d)))continue;c||(c=!0,m=[]),m.push(u);continue}if(c){c=!1;const[u,...d]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const b of u)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of d){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),m=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(g)){o&&(i.push("</ul>"),o=!1),i.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(g)){o||(i.push('<ul class="space-y-1 my-1">'),o=!0),i.push(`<li class="${e.list} ${e.tone} flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${gs(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${e.text} ${e.tone} my-1">${gs(g)}</p>`)}if(c&&m.length){const[p,...g]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of p)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const d of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(d)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Hm({result:n,compact:e=!1}){const{response:s}=n,i=e?"text-xs":"text-sm",o=s?FN(s):null,c=s!=null&&s.error&&s.error!==o?s.error:null;return h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:`${i} font-mono text-text-secondary truncate`,children:n.code}),s?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`${i} font-medium ${$N[s.outcome]}`,children:HN(s)}),c&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:c}),o&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(GN,{content:o,compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Pv(n){return n.replace(/[\u2010-\u2015\u2212]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\x00-\x1F\x7F]/g,"").trim()}function YN(n){const e=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&e.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...e]}function KN({value:n}){const e=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!e.current||!n))try{zN(e.current,n,{format:"CODE128",width:2,height:88,margin:12,displayValue:!0,fontSize:13,background:"#ffffff",lineColor:"#000000"}),i(!1)}catch{i(!0)}},[n]),n?h.jsxs("div",{children:[h.jsx("span",{className:"block text-xs uppercase tracking-wide text-text-tertiary mb-1",children:"Barcode"}),s?h.jsxs("p",{className:"text-xs text-status-error",children:["This value has characters Code 128 cannot carry:"," ",h.jsx("span",{className:"font-mono",children:YN(n).join(", ")||"unknown"})]}):h.jsx("div",{className:"bg-white rounded p-1 inline-block max-w-full overflow-hidden",children:h.jsx("svg",{ref:e,className:"max-w-full"})})]}):null}function JN({onClose:n}){const{submitCode:e,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:m,diagnosticsOn:p,setDiagnosticsOn:g}=$m(),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=_=>{_.preventDefault();const S=u.trim();S&&(d(""),e(S))};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[h.jsx(Mo,{className:"w-4 h-4"}),"Scan"]}),h.jsx("button",{type:"button",onClick:n,className:"text-text-tertiary hover:text-text-primary",title:"Close",children:h.jsx(Zt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",children:[h.jsxs("form",{onSubmit:v,className:"space-y-2",children:[h.jsx("label",{className:"block text-xs uppercase tracking-wide text-text-tertiary",children:"Enter a code"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:u,onChange:_=>d(Pv(_.target.value)),placeholder:"10:1:SN-12345",className:"flex-1 px-2 py-1.5 text-sm bg-surface-raised border border-surface-border rounded text-text-primary","data-scan-manual-entry":!0}),h.jsx("button",{type:"submit",disabled:i||!u.trim(),className:"px-3 py-1.5 text-sm rounded bg-accent text-text-inverse disabled:opacity-50",children:"Go"})]}),h.jsx("p",{className:"text-xs text-text-tertiary",children:"Scanning with a connected scanner works from any page — this entry exists for testing and for codes you can read but not scan. Typing here also draws the code below; point the scanner at the screen to fire it for real."})]}),h.jsx(KN,{value:u.trim()}),s&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs uppercase tracking-wide text-text-tertiary",children:"Last scan"}),h.jsx(Hm,{result:s})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{type:"button",onClick:()=>x(_=>!_),className:"text-xs uppercase tracking-wide text-text-tertiary hover:text-text-primary",children:["Capture settings ",b?"▾":"▸"]}),b&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block text-sm text-text-primary",children:[h.jsx("span",{className:"block text-xs text-text-tertiary mb-1",children:"Key gap limit (ms) — a longer pause between keys starts a new capture; raise it for scanners that pace slowly"}),h.jsx("input",{type:"number",min:100,max:2e3,step:50,value:o.maxKeyGapMs,onChange:_=>c({maxKeyGapMs:Number(_.target.value)}),className:"w-24 px-2 py-1 text-sm bg-surface-raised border border-surface-border rounded"})]}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-primary",children:[h.jsx("input",{type:"checkbox",checked:p,onChange:_=>g(_.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),p&&h.jsxs("div",{className:"border border-surface-border rounded",children:[h.jsx("div",{className:"px-2 py-1.5 text-2xs uppercase tracking-wide text-text-tertiary border-b border-surface-border",children:"Keydown trace — scan now, newest last"}),h.jsxs("div",{className:"max-h-64 overflow-y-auto font-mono text-2xs leading-5 px-2 py-1",children:[m.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),m.map(_=>h.jsxs("div",{className:"whitespace-nowrap overflow-hidden text-ellipsis",title:`buffer: ${_.buffer}`,children:[h.jsxs("span",{className:"text-text-tertiary",children:[String(_.deltaMs).padStart(4),"ms "]}),h.jsx("span",{className:"text",children:JSON.stringify(_.key)}),_.code&&h.jsxs("span",{className:"text-text-tertiary",children:[" (",_.code,")"]}),h.jsxs("span",{className:"text-text-tertiary",children:[" — ",_.note]})]},_.seq))]}),h.jsxs("div",{className:"px-2 py-1.5 text-2xs text-text-tertiary border-t border-surface-border",children:["Read it like this: a scan should end with an"," ",h.jsx("span",{className:"font-mono",children:'"Enter"'})," row saying"," ",h.jsx("span",{className:"font-mono",children:"capture → …"}),'. An Enter row saying "no code tail" means the buffer split (raise the gap limit, or a key arrived as something other than one character). No Enter row at all means the scanner sends no suffix — program its Enter/CR suffix. Keys named'," ",h.jsx("span",{className:"font-mono",children:'"Unidentified"'})," mean the decode arrives outside the keydown path."]})]})]})]})]})]})}const Bv=/^\{lt:([A-Za-z0-9_]+)\}$/,$1="me";function zM(n){return`{lt:${n}}`}const Uv="lt:station:link-vars:";function em(n){return`${Uv}${n}`}const tm=new Set;function QN(){for(const n of tm)n()}let wu,Qc={};function zv(n){let e=null;try{e=localStorage.getItem(em(n))}catch{e=null}if(e===wu)return Qc;wu=e;try{const s=e?JSON.parse(e):{};Qc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Qc={}}return Qc}function XN(n,e,s){const i={...zv(n)};s===null||s===""?delete i[e]:i[e]=s;try{Object.keys(i).length===0?localStorage.removeItem(em(n)):localStorage.setItem(em(n),JSON.stringify(i))}catch{}wu=void 0,QN()}function WN(n){tm.add(n);const e=s=>{(s.key===null||s.key.startsWith(Uv))&&(wu=void 0,n())};try{window.addEventListener("storage",e)}catch{}return()=>{tm.delete(n);try{window.removeEventListener("storage",e)}catch{}}}const ZN={};function eT(n){return E.useSyncExternalStore(WN,()=>n?zv(n):ZN)}function tT(n,e,s,i={}){let o;try{o=new URL(n,"http://local")}catch{return n}const c=o.searchParams.get("facets");if(!c)return n;let m;try{const g=JSON.parse(c);if(!g||typeof g!="object"||Array.isArray(g))return n;m=g}catch{return n}let p=!1;for(const[g,u]of Object.entries(m)){if(typeof u!="string")continue;const d=Bv.exec(u);if(!d)continue;const b=i[d[1]]??e[d[1]]??s[d[1]];typeof b=="string"&&b!==""?m[g]=b:delete m[g],p=!0}return p?(Object.keys(m).length===0?o.searchParams.delete("facets"):o.searchParams.set("facets",JSON.stringify(m)),o.pathname+o.search):n}function IM(n){let e;try{e=new URL(n,"http://local")}catch{return[]}const s=e.searchParams.get("facets");if(!s)return[];try{const i=JSON.parse(s);if(!i||typeof i!="object"||Array.isArray(i))return[];const o=[];for(const c of Object.values(i)){if(typeof c!="string")continue;const m=Bv.exec(c);m&&!o.includes(m[1])&&o.push(m[1])}return o}catch{return[]}}function Fm(){var v;const{user:n,isSuperAdmin:e,hasRoleType:s}=qt(),i=(n==null?void 0:n.userId)??null,o=e||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(_=>_.role)),[n]),{data:m}=Mu({enabled:o||c.size>0}),p=eT(i),g=((v=vA())==null?void 0:v.actorId)??i,u=E.useMemo(()=>{var C;const _=[],S=new Set;for(const B of(m==null?void 0:m.roles)??[]){if(!o&&!c.has(B.role))continue;const q=(C=B.properties)==null?void 0:C.link_variables;if(Array.isArray(q))for(const ne of q){const te=ne==null?void 0:ne.name;if(typeof te!="string"||te===""||te===$1||S.has(te))continue;S.add(te);const M=ne.label,z=ne.default;_.push({name:te,...typeof M=="string"&&M!==""?{label:M}:{},...typeof z=="string"&&z!==""?{default:z}:{},fromRole:B.role})}}return _},[m,c,o]),d=E.useMemo(()=>{const _={};for(const S of u)S.default!==void 0&&(_[S.name]=S.default);return _},[u]),b=E.useCallback(_=>tT(_,p,d,g?{[$1]:g}:{}),[p,d,g]),x=E.useCallback((_,S)=>{i&&XN(i,_,S)},[i]);return{declarations:u,values:p,defaults:d,resolveUrl:b,setValue:x}}function nT({open:n,onClose:e,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const m=p=>{p.key==="Escape"&&e()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,e]),n?sm.createPortal(h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:c?e:void 0}),h.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"lt-modal-title",className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${o??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[h.jsx("h2",{id:"lt-modal-title",className:"text-sm font-medium text-text-primary",children:s}),h.jsx("button",{onClick:e,"aria-label":"Close dialog",className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}function rT({open:n,onClose:e}){const{declarations:s,values:i,setValue:o}=Fm();return h.jsxs(nT,{open:n,onClose:e,title:"Link Variables",maxWidth:"max-w-lg",children:[h.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed mb-4",children:"Values bound on this device. Pinned links and the Pace Board open scoped to the value applied; an unbound variable falls back to the role's default, or applies no filter at all."}),h.jsx("div",{className:"divide-y divide-surface-border",children:s.map((c,m)=>h.jsx(sT,{declaration:c,value:i[c.name]??"",autoFocus:m===0,onChange:p=>o(c.name,p),onClear:()=>o(c.name,null),onEnter:e},c.name))}),s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary",children:"Your roles declare no link variables."}),s.length>0&&h.jsx("div",{className:"flex justify-end pt-4",children:h.jsx("button",{onClick:e,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function sT({declaration:n,value:e,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const m=E.useId(),{data:p}=sk(n.name),g=(p==null?void 0:p.values)??[];return h.jsxs("div",{className:"py-3 flex items-center gap-3","data-testid":"link-var-row",children:[h.jsxs("div",{className:"w-40 shrink-0 min-w-0",children:[h.jsx("p",{className:"text-xs font-mono text-text-primary truncate",title:n.name,children:n.name}),h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:`declared by ${n.fromRole}`,children:n.label??n.fromRole})]}),h.jsx("input",{type:"text",list:m,autoFocus:s,value:e,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:n.default?`${n.default} (default)`:"no filter","aria-label":`Value for ${n.name}`,className:"input text-xs font-mono flex-1 min-w-0"}),h.jsx("datalist",{id:m,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:e==="",title:`Clear ${n.name}`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors disabled:opacity-30 disabled:cursor-not-allowed shrink-0",children:"×"})]})}const H1=["escalationId","workflowId"],iT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Iv="lt:search:mode",aT="lt:search:facet",Lt={FACET:"facet",COMMAND:"command"};function oT(n,e){return{version:n.version,category:e.category,name:e.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function Co(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function lT(n,e){if(n.encoding==="delimited")return cT(n,e)?{code:e}:{code:`${Co(n)}${e}`};if(!/^[0-9]+$/.test(e))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&e.length!==s&&e.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${Co(n)}${e}`}}function cT(n,e){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(e)}function uT(n,e){return n==="escalationId"||n==="workflowId"?null:Xk(n,e)}function fT(n){return n.kind===Lt.FACET?n.facet:n.command.name}function hT(n){return n.kind===Lt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function dT(n){return n.kind===Lt.FACET?{kind:Lt.FACET,facet:n.facet}:{kind:Lt.COMMAND,version:n.command.version,category:n.command.category}}function mT(n,e,s){if((n==null?void 0:n.kind)===Lt.FACET&&e.includes(n.facet))return{kind:Lt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Lt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Lt.COMMAND,command:i}}return e.length>0?{kind:Lt.FACET,facet:e[0]}:s.length>0?{kind:Lt.COMMAND,command:s[0]}:null}function pT(){try{const n=localStorage.getItem(Iv);if(n){const s=JSON.parse(n);if(s.kind===Lt.FACET&&typeof s.facet=="string"||s.kind===Lt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const e=localStorage.getItem(aT);return e?{kind:Lt.FACET,facet:e}:null}catch{return null}}function yT(n){try{localStorage.setItem(Iv,JSON.stringify(n))}catch{}}const F1=5*6e4,gT=n=>({rules:n.map(e=>{var s;return((s=e.data)==null?void 0:s.rules)??null}),loading:n.some(e=>e.isLoading)});function bT(n){const e=jv({enabled:n,staleTime:F1}),s=E.useMemo(()=>{var m;return(((m=e.data)==null?void 0:m.schemes)??[]).filter(p=>p.enabled&&p.kind===Fk.ACTION).sort((p,g)=>p.version-g.version)},[e.data]),{rules:i,loading:o}=fS({queries:s.map(m=>({queryKey:["scan-schemes",m.version,"actions"],queryFn:()=>ue(`/scan-codes/schemes/${m.version}/actions`),enabled:n,staleTime:F1})),combine:gT});return{commands:E.useMemo(()=>s.flatMap((m,p)=>(i[p]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>oT(m,g))),[s,i]),loading:e.isLoading||o}}const xT={escalationId:"opens the item",workflowId:"opens the run"};function vT({mode:n,facets:e,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,m]=E.useState(!1),p=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=_=>{p.current&&!p.current.contains(_.target)&&m(!1)},v=_=>{_.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Lt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${Co(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,d=_T(s),b=x=>{i(x),m(!1)};return h.jsxs("div",{ref:p,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>m(x=>!x),"aria-expanded":c,"aria-haspopup":"listbox","aria-label":"Search or run as",title:u,className:"group flex items-center gap-1 h-full pl-2.5 pr-2 border-l border-surface-field-border hover:bg-surface-hover transition-colors rounded-r-[var(--lt-radius-field)]","data-testid":"search-mode",children:[h.jsx("span",{className:`text-2xs whitespace-nowrap truncate max-w-[9rem] ${g?"font-medium text-accent":"font-mono text-text-tertiary"}`,children:fT(n)}),h.jsx(im,{className:`w-3 h-3 shrink-0 text-text-quaternary group-hover:text-accent transition-transform ${c?"rotate-180":""}`,strokeWidth:1.5})]}),c&&h.jsxs("div",{role:"listbox","aria-label":"Search or run as",className:"absolute z-50 top-full right-0 mt-1.5 min-w-[17rem] max-w-[24rem] max-h-[70vh] overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[e.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(G1,{children:"Find"}),e.map(x=>h.jsx(V1,{label:x,mono:!0,note:xT[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Lt.FACET,facet:x})},x))]}),d.map(({schemeName:x,targetFacet:v,items:_})=>h.jsxs("div",{children:[h.jsxs(G1,{note:v,children:["Run · ",x]}),_.map(S=>h.jsx(V1,{label:S.name,note:Co(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Lt.COMMAND,command:S})},`${S.version}:${S.category}`))]},x)),o&&h.jsxs(h.Fragment,{children:[h.jsx("hr",{className:"border-surface-border/60 my-1"}),h.jsxs("button",{type:"button",onClick:()=>{m(!1),o()},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-accent hover:bg-surface-hover","data-testid":"search-mode-scan-panel",children:[h.jsx(Mo,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function _T(n){const e=[];for(const s of n){const i=e.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):e.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return e}function G1({children:n,note:e}){return h.jsxs("p",{className:"px-3 pt-2 pb-1 flex items-baseline gap-2 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:[h.jsx("span",{className:"truncate",children:n}),e&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:e})]})}function V1({label:n,note:e,active:s,mono:i,noteMono:o,onClick:c}){return h.jsxs("button",{type:"button",role:"option","aria-selected":s,onClick:c,className:`w-full text-left pl-3 pr-3 py-1.5 flex items-baseline gap-3 border-l-2 transition-colors ${s?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[h.jsx("span",{className:`text-xs font-medium truncate ${i?"font-mono":""}`,children:n}),h.jsx("span",{className:`ml-auto text-2xs shrink-0 ${o?"font-mono tabular-nums":""} ${s?"text-accent/70":"text-text-quaternary"}`,children:e})]})}const wT=6e3;function ST({onOpenScanPanel:n}){const e=ni(),{data:s}=Hn(),i=zm(),{submitCode:o,busy:c,lastResult:m}=$m(),{commands:p}=bT(i),[g,u]=E.useState(""),[d,b]=E.useState(!1),[x,v]=E.useState(null),[_,S]=E.useState(null),[C,B]=E.useState(""),[q,ne]=E.useState(null),[te,M]=E.useState(pT),z=E.useRef(null),ae=E.useMemo(()=>{var le;if(!((le=s==null?void 0:s.search)!=null&&le.enabled))return[];const J=(s.search.facets??[]).filter(pe=>!H1.includes(pe));return[...H1,...J]},[s]),F=E.useMemo(()=>mT(te,ae,p),[te,ae,p]),U=(m==null?void 0:m.source)===To.TOOLBAR&&!m.navigated&&q!==m.at?m:null;E.useEffect(()=>{if(!U)return;const J=setTimeout(()=>ne(U.at),wT);return()=>clearTimeout(J)},[U]);const D=()=>{v(null),S(null),m&&ne(m.at)},X=J=>{var pe;const le=dT(J);M(le),yT(le),D(),(pe=z.current)==null||pe.focus()},W=(J,le)=>{const pe=lT(J.command,Pv(le));if("error"in pe){v(pe.error);return}u(""),o(pe.code,To.TOOLBAR)},he=async(J,le)=>{const pe=uT(J,le);if(pe){u(""),e(pe);return}if(J==="escalationId"&&!iT.test(le)){v("That is not a valid escalation id");return}b(!0);try{if(J==="escalationId")await ue(`/escalations/${encodeURIComponent(le)}`),u(""),e(`/escalations/detail/${encodeURIComponent(le)}`);else{const ye=await ue(`/escalations/by-workflow/${encodeURIComponent(le)}`),Ce=(ye==null?void 0:ye.escalations)??[];Ce.length===1?(u(""),e(`/escalations/detail/${Ce[0].id}`)):(B(le),S(Ce))}}catch{v(`No ${J==="escalationId"?"escalation":"workflow"} found for "${le}"`)}finally{b(!1)}},Se=()=>{const J=g.trim();!J||d||c||!F||(D(),F.kind===Lt.COMMAND?W(F,J):he(F.facet,J))};if(!F)return null;const Ae=F.kind===Lt.COMMAND,H=d||c;return h.jsxs("div",{className:"relative w-full max-w-[28rem]","data-testid":"global-search",children:[h.jsxs("div",{className:"flex items-center h-8 bg-surface-field border border-surface-field-border rounded-[var(--lt-radius-field)] focus-within:border-accent focus-within:bg-surface-field-focus transition-colors",children:[h.jsxs("label",{htmlFor:"global-search-input",className:"flex items-center gap-1.5 pl-2.5 shrink-0 cursor-text",children:[Ae?h.jsx(Mo,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(vS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),Ae&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:Co(F.command)})]}),h.jsx("input",{ref:z,id:"global-search-input",type:"text",value:g,onChange:J=>{u(J.target.value),D()},onKeyDown:J=>{J.key==="Enter"&&Se(),J.key==="Escape"&&(u(""),D())},placeholder:hT(F),"aria-label":Ae?"Run target":"Global search",autoComplete:"off",spellCheck:!1,className:`flex-1 min-w-0 h-full bg-transparent text-xs text-text-primary placeholder:text-text-quaternary focus:outline-none ${Ae?"pl-0.5 pr-2 font-mono":"px-2"}`}),H&&h.jsx("span",{className:"w-1.5 h-1.5 mr-2 rounded-full bg-accent animate-pulse shrink-0","aria-label":"Working"}),h.jsx(vT,{mode:F,facets:ae,commands:p,onSelect:X,onOpenScanPanel:n})]}),x&&h.jsx("p",{className:"absolute top-full left-0 mt-1 text-2xs text-status-error whitespace-nowrap",role:"alert",children:x}),U&&h.jsx("div",{role:"status",className:"absolute top-full left-0 mt-1.5 z-50 w-full max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg px-3 py-2 animate-fade-in","data-testid":"search-run-outcome",children:h.jsx(Hm,{result:U,compact:!0})}),_!==null&&h.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 min-w-72 max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1","data-testid":"search-workflow-results",children:[_.map(J=>h.jsxs(ar,{to:`/escalations/detail/${J.id}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover truncate",children:[h.jsx("span",{className:"font-medium text-text-primary",children:J.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),J.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:J.type})]},J.id)),_.length===0&&h.jsx("p",{className:"px-3 py-1.5 text-2xs text-text-tertiary",children:"No escalations for this workflow."}),h.jsx("hr",{className:"border-surface-border/60 my-0.5"}),h.jsx(ar,{to:`/workflows/executions/${encodeURIComponent(C)}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-accent hover:bg-surface-hover",children:"Workflow execution →"})]})]})}function ET(){const{identity:n,remainingSeconds:e}=Cu(),[,s]=E.useState(0);return E.useEffect(()=>{if(!(n!=null&&n.expiresAt))return;const i=setInterval(()=>s(o=>o+1),1e3);return()=>clearInterval(i)},[n]),e()}function OT(n){return n>=60?`${Math.floor(n/60)} min`:`${n} s`}function AT(){const{identity:n}=Cu(),e=ET();return n?h.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-secondary whitespace-nowrap min-w-0",title:`Scans act as ${n.displayName}`,"data-testid":"badge-grant-indicator",children:[h.jsx(_S,{className:"w-4 h-4 text-status-success shrink-0",strokeWidth:1.5}),h.jsx("span",{className:"hidden sm:inline",children:"Badged:"}),h.jsx("span",{className:"font-medium text-text-primary truncate max-w-[10rem]",children:n.displayName}),n.expiresAt&&h.jsxs("span",{className:"tabular-nums text-text-tertiary","data-testid":"badge-grant-remaining",children:["· ",OT(e)]})]}):null}function jT(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function nm(n){var e;return((e=n.title)==null?void 0:e.trim())||jT(n.role)}const $v="lt:bookmarks",Xc="scan";function kT(){try{const n=localStorage.getItem($v);if(!n)return[];const e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function Y1(n){try{localStorage.setItem($v,JSON.stringify(n))}catch{}}function NT({onToggleEventFeed:n,onToggleDocs:e,onToggleNav:s}){var Ue,Xe,un,Mt;const i=ni(),{user:o,logout:c,isSuperAdmin:m,hasRoleType:p}=qt(),{viewAs:g,realIsBuilder:u}=tv(),{available:d,mine:b}=fk();nv();const{connected:x}=qx(),{data:v}=Hn(),{role:_,targets:S,selectable:C,selectRole:B}=Cm(),{declarations:q,values:ne}=Fm(),[te,M]=E.useState(!1),{data:z}=Mu(),ae=E.useMemo(()=>{const be=(z==null?void 0:z.roles)??[],it=new Set(((o==null?void 0:o.roles)??[]).map(Ot=>Ot.role)),yt=m||p("admin");return be.filter(Ot=>ta(Ot).length>0&&(yt||it.has(Ot.role))).map(Ot=>({role:Ot.role,title:nm(Ot),portals:ta(Ot)}))},[z,o,m,p]),{setPanel:F,closePanel:U,open:D,ownerKey:X}=Lm(),W=zm(),he=en(),Se=()=>{D&&X===Xc?U(Xc):F(h.jsx(JN,{onClose:()=>U(Xc)}),{width:360,key:Xc})},[Ae,H]=E.useState(!1),[J,le]=E.useState(!1),[pe,ye]=E.useState(Sv),[Ce,Ne]=E.useState(kT),Me=E.useRef(null),We=(Ue=v==null?void 0:v.branding)==null?void 0:Ue.appName,pt=(Xe=v==null?void 0:v.branding)==null?void 0:Xe.themes,Ct=E.useMemo(()=>(jk(pt??[]),kk()),[pt]),Ee=be=>{Nk(be),ye(be)},Re=()=>{const be=window.prompt("Bookmark label:");if(!(be!=null&&be.trim()))return;const it=he.pathname+he.search,yt=[...Ce,{label:be.trim(),url:it}].sort((Ot,Ur)=>Ot.label.localeCompare(Ur.label));Ne(yt),Y1(yt),H(!1)},ce=be=>{const it=Ce.filter(yt=>!(yt.label===be.label&&yt.url===be.url));Ne(it),Y1(it)};return E.useEffect(()=>{if(!Ae)return;const be=it=>{Me.current&&!Me.current.contains(it.target)&&H(!1)};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[Ae]),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 ${Ae?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s&&h.jsx("button",{onClick:s,className:"lg:hidden p-2 text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open navigation",children:h.jsx(wS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(ar,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:be=>{(be.ctrlKey||be.metaKey)&&(be.preventDefault(),le(!0))},children:h.jsx(Ru,{appName:We,className:"flex"})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>i(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(cx,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>i(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(gd,{className:"w-5 h-5",strokeWidth:2})})]}),(((un=v==null?void 0:v.search)==null?void 0:un.enabled)||W)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx(ST,{onOpenScanPanel:W?Se:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsx(AT,{}),h.jsxs(ar,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${d>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),d>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:d})]}),h.jsxs(ar,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${b>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),b>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:b})]}),g&&h.jsx(h.Fragment,{children:h.jsxs("span",{className:"hidden lg:flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-accent/10 border border-accent/25 text-2xs text-accent select-none",children:[h.jsxs("span",{className:"capitalize font-medium tracking-wide",children:[g," View"]}),h.jsx("button",{onClick:Vd,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(Zt,{className:"w-2.5 h-2.5"})})]})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),o&&h.jsxs("div",{className:"relative",ref:Me,children:[h.jsxs("button",{onClick:()=>H(be=>!be),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(SS,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),g&&h.jsx("span",{className:"lg:hidden absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"hidden lg:inline whitespace-nowrap",children:o.displayName||o.username||o.userId}),h.jsx("svg",{className:"hidden lg:block w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),Ae&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100]",children:[h.jsx(ar,{to:"/credentials",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),((Mt=v==null?void 0:v.auth)==null?void 0:Mt.oauthServer)&&h.jsx(ar,{to:"/connected-apps",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Connected apps"}),W&&h.jsx("button",{onClick:()=>{H(!1),Se()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-scan",children:"Scan a code"}),h.jsx("button",{onClick:()=>{H(!1),x?n==null||n():window.location.reload()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:x?"Events":"Reconnect events"}),u&&h.jsx("button",{onClick:()=>{H(!1),e==null||e()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-docs",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{H(!1),Vd()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",g," view"]}),h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),h.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ct.map(be=>h.jsx("button",{type:"button",onClick:()=>Ee(be.id),title:be.label,"aria-label":`${be.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${pe===be.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:be.swatch}},be.id))})]}),C&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Station queue"}),h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("button",{type:"button",onClick:()=>{H(!1),B(null),i("/")},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${_?"text-text-secondary":"text-accent"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_?"bg-surface-border":"bg-accent"}`}),h.jsx("span",{className:"truncate",children:"Full dashboard"})]}),S.map(be=>{var Ot;const it=(Ot=z==null?void 0:z.roles)==null?void 0:Ot.find(Ur=>Ur.role===be),yt=be===_;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),B(be),i(hv(be,ta(it)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${yt?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${yt?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:nm({role:be,title:it==null?void 0:it.title})})]},be)})]})]}),ae.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60","data-testid":"menu-portals",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Portals"}),h.jsx("div",{className:"flex flex-col gap-1.5",children:ae.map(be=>h.jsxs("div",{children:[ae.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:be.role,children:be.title}),be.portals.map(it=>{const yt=Tm(be.role,it.key),Ot=he.pathname===yt;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),i(yt)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${Ot?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${be.role}-${it.key}`,children:[h.jsx(xd,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:it.label})]},it.key)})]},be.role))})]}),q.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Link variables"}),h.jsxs("button",{type:"button",onClick:()=>{H(!1),M(!0)},className:"flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded text-text-secondary hover:bg-surface-hover","data-testid":"link-vars-menu-entry",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Object.keys(ne).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ne).length>0?Object.entries(ne).map(([be,it])=>`${be} = ${it}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{H(!1),c()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"}),h.jsxs("div",{className:"border-t border-surface-border/60 pt-1",children:[Ce.map(be=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(ar,{to:be.url,onClick:()=>H(!1),title:be.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:be.label}),h.jsx("button",{type:"button",onClick:()=>ce(be),title:`Remove "${be.label}"`,className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1 p-0.5 shrink-0 text-text-quaternary hover:text-status-error",children:h.jsx(Zt,{className:"w-3 h-3"})})]},`${be.label}::${be.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:Re,className:"flex items-center gap-1.5 w-full px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:[h.jsx(ES,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),J&&h.jsx(Ak,{onClose:()=>le(!1)}),h.jsx(rT,{open:te,onClose:()=>M(!1)})]})}function Gm({open:n,children:e}){const[s,i]=E.useState(n);return E.useEffect(()=>{n&&i(!0)},[n]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${n?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{n||i(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?e:null})})}function rm(n){return({isActive:e})=>{const s="flex items-center rounded-md transition-colors duration-150",i="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return n?`${s} justify-center w-10 h-10 mx-auto ${e?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${e?i:o}`}}function TT(){return({isActive:n})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${n?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function CT({group:n,collapsed:e}){const{pathname:s}=en(),i=n.matchPaths.some(p=>s.startsWith(p)),[o,c]=E.useState(i),m=o||i;return e?h.jsx(h.Fragment,{children:n.items.map(p=>h.jsx(Os,{to:p.to,className:rm(!0),title:p.label,children:p.icon&&h.jsx(p.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},p.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(p=>!p),className:"w-full flex items-center justify-between px-4 py-2 text-sm rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",children:[h.jsxs("span",{className:"flex items-center gap-3",children:[n.icon&&h.jsx(n.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:n.label})]}),h.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${m?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),h.jsx(Gm,{open:m,children:n.items.map(p=>h.jsxs(Os,{to:p.to,end:p.end,className:TT(),children:[p.icon&&h.jsx(p.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:p.label})]},p.to))})]})}function MT(n){return n.kind==="group"}function RT({entry:n,collapsed:e}){const{pathname:s,search:i}=en(),o=n.to.includes("?"),c=n.icon&&h.jsx(n.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${n.iconClassName??""}`,strokeWidth:1.5,...n.solid?{fill:"currentColor"}:{}});if(o){const[m,p]=n.to.split("?"),g=s===m&&i===`?${p}`,u=rm(e)({isActive:g});return h.jsxs(Os,{to:n.to,className:u,title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}return h.jsxs(Os,{to:n.to,end:n.end,className:rm(e),title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}function qr({heading:n,entries:e}){const{collapsed:s}=Rm();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:n}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:n}),e.map(i=>MT(i)?h.jsx(CT,{group:i,collapsed:s},i.label):h.jsx(RT,{entry:i,collapsed:s},i.to))]})}function DT({aiEnabled:n=!1,isBuilder:e=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1,showLines:c=!1}){const m=[{to:"/pace",label:"Pace Board",icon:OS},{to:"/trends",label:"Trend Board",icon:AS}],p=c?[{to:"/lines",label:"Lines",icon:jS}]:[];if(!e&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(qr,{heading:"Monitor",entries:m}):null;if(!e)return h.jsx(qr,{heading:"Monitor",entries:[...o?m:[],...p]});const g=[...o?m:[],...p,{to:"/topics",label:"Event Topics",icon:ux},{to:"/agents",label:n?"Agents":"Automations",icon:kS},{to:"/capabilities",label:"Capabilities",icon:NS}];return h.jsx(qr,{heading:"Monitor",entries:g})}function LT(){return qe({queryKey:["me","preferences"],queryFn:()=>ue("/me/preferences"),staleTime:6e4})}function qT(){const n=Pe();return $e({mutationFn:e=>ue("/me/preferences",{method:"PATCH",body:JSON.stringify(e)}),onSuccess:e=>{n.setQueryData(["me","preferences"],e)}})}const xs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},K1={COMPACT:"compact",CARDS:"cards"},dd={AVAILABLE:"/escalations/available",ALL:"/escalations"},na={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},PT={[na.RESOLVED]:"resolved",[na.CANCELLED]:"cancelled",[na.EXPIRED]:"expired"};function BT(n){const e=n===na.CLAIMED;return{available:n===na.AVAILABLE,claimed:e,apiStatus:e?"pending":PT[n]}}function UT(n){return n===xs.TABLE||n===xs.RICH||n===xs.TIMELINE}function zT(n){return n===K1.COMPACT||n===K1.CARDS}function IT(n,e=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||e,role:n.get("role")||void 0,type:n.get("type")||void 0,subtype:n.get("subtype")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:Qk(n),view:UT(i)?i:null,layout:zT(o)?o:null}}function $T(n){let e;try{e=new URL(n,"http://local")}catch{return null}if(e.pathname!==dd.AVAILABLE&&e.pathname!==dd.ALL)return null;const s=e.pathname===dd.AVAILABLE?na.AVAILABLE:"";return IT(e.searchParams,s)}function $M(n){var e;return n.role||(((e=n.facets.roles)==null?void 0:e.length)===1?n.facets.roles[0]:null)}function HM(n,e){return n===xs.TIMELINE?xs.TIMELINE:e&&(!n||n===xs.RICH)?xs.RICH:xs.TABLE}function HT(n,e){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(p=>p.label)),c=[...s],m=new Set;for(const{role:p,pins:g}of e)for(const u of g)o.has(u.label)||i.has(u.label)||m.has(u.label)||(m.add(u.label),c.push({...u,id:`role:${p}:${u.label}`,fromRole:p}));return c}function FT(n){const e=$T(n);if(!e)return null;const{available:s,claimed:i,apiStatus:o}=BT(e.statusFilter);return{available:s,params:{...e.facets,role:e.role,type:e.type,subtype:e.subtype,priority:e.priority,status:o,...i?{claimed:!0}:{},search:e.search}}}function GT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function VT(){var U;const{collapsed:n}=Rm(),{user:e}=qt(),s=LT(),i=qT(),o=E.useMemo(()=>new Set(((e==null?void 0:e.roles)??[]).map(D=>D.role)),[e]),{data:c}=Mu({enabled:o.size>0}),m=tn("SUMMARY");ks(jm(),()=>{m([["escalations"]])});const p=(U=s.data)==null?void 0:U.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Array.isArray(D.default_pins)&&D.default_pins.length>0).map(D=>({role:D.role,pins:D.default_pins})),[c,o]),{resolveUrl:u}=Fm(),d=E.useMemo(()=>HT(p,g),[p,g]),b=E.useMemo(()=>new Map(d.map(D=>[D.id,D.url])),[d]),x=E.useMemo(()=>d.map(D=>({...D,url:u(D.url)})),[d,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(D=>[D.role,nm(D)])),[c]),_=E.useMemo(()=>x.filter(D=>!D.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Jj(D)).map(D=>D.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>S.has(D.role)||g.some(X=>X.role===D.role)).map(D=>({role:D.role,title:v.get(D.role)??D.role,portals:S.has(D.role)?ta(D):[],pins:x.filter(X=>X.fromRole===D.role)})).filter(D=>D.portals.length>0||D.pins.length>0),[c,g,S,v,x]),B=(p==null?void 0:p.pinnedViews)??[],q=E.useRef(null),ne=D=>i.mutate({pinnedViews:D}),te=D=>ne(B.filter(X=>X.id!==D)),M=D=>ne([...B,{id:GT(),label:D.label,url:b.get(D.id)??D.url,badge:D.badge}]),z=D=>i.mutate({hiddenRolePins:[...(p==null?void 0:p.hiddenRolePins)??[],D]}),ae=(D,X)=>{if(D===X)return;const W=[...B],[he]=W.splice(D,1);W.splice(X,0,he),ne(W)};if(x.length===0&&S.size===0)return null;const F="px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary truncate";return h.jsxs("div",{className:"space-y-1",children:[n&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!n&&_.length>0&&h.jsx("p",{className:F,children:"Pinned"}),_.map(D=>{const X=B.findIndex(W=>W.id===D.id);return h.jsx(J1,{pin:D,collapsed:n,draggable:X!==-1,onDragStart:()=>{q.current=X},onDropOn:()=>{q.current!==null&&X!==-1&&ae(q.current,X),q.current=null},onRemove:()=>te(D.id)},D.id)}),C.map(D=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:F,title:`${D.title} — pins from the ${D.role} role`,"data-testid":"pin-group-label",children:D.title}),D.portals.map(X=>h.jsx(YT,{role:D.role,portal:X,collapsed:n},X.key)),D.pins.map(X=>h.jsx(J1,{pin:X,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>M(X),onHide:()=>z(X.label)},X.id))]},D.role))]})}function YT({role:n,portal:e,collapsed:s}){const i=Tm(n,e.key),o="flex items-center rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",c=`portal-link-${n}-${e.key}`;return s?h.jsx(Os,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:e.label,"data-testid":c,children:h.jsx(xd,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Os,{to:i,title:e.label,className:({isActive:m})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${m?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(xd,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:e.label})]})}function J1({pin:n,collapsed:e,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:m,onHide:p}){const{pathname:g,search:u}=en(),[d,b=""]=n.url.split("?"),x=g===d&&u===(b?`?${b}`:""),v="group flex items-center rounded-md transition-colors duration-150",_=x?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return e?h.jsx(Os,{to:n.url,className:`${v} ${_} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(Mg,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${v} ${_} relative`,draggable:s,onDragStart:i,onDragOver:S=>S.preventDefault(),onDrop:o,children:[h.jsxs(Os,{to:n.url,title:n.label,className:"flex items-center gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] flex-1 min-w-0",children:[h.jsx(Mg,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...n.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:n.label}),n.badge&&h.jsx(KT,{url:n.url})]}),h.jsxs("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 rounded px-0.5 bg-surface-hover opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity",children:[m&&h.jsx("button",{onClick:m,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(fx,{className:"w-3 h-3"})}),p&&h.jsx("button",{onClick:p,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(TS,{className:"w-3 h-3"})}),c&&h.jsx("button",{onClick:c,title:`Remove "${n.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(Zt,{className:"w-3 h-3"})})]})]})}function KT({url:n}){var m;const e=E.useMemo(()=>FT(n),[n]),s={limit:1,staleTime:15e3},i=yv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&e.available}),o=pv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&!e.available});if(!e)return null;const c=e.available?i:o;return c.isError||((m=c.data)==null?void 0:m.total)===void 0?null:h.jsx("span",{className:"shrink-0 text-right text-2xs leading-none tabular-nums text-accent/80 relative -top-[0.35em]",title:`${c.data.total} matching now`,children:c.data.total})}function JT(){var c;const{data:n}=Hn(),e=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=e===!0||e!==!1&&Wx(),i=[{to:"/workflows/registry",label:"Registry",icon:Rg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd},{to:"/workflows/executions",label:"Executions",icon:Dg}],o=s?[{kind:"group",label:"Procedural",icon:CS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:am,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:Rg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:vd},{to:"/mcp/executions",label:"Executions",icon:Dg}]}]:i;return h.jsx(qr,{heading:"Orchestrate",entries:o})}function FM(){return qe({queryKey:["activeWorkers"],queryFn:async()=>(await ue("/workflows/workers")).workers})}function GM(){return qe({queryKey:["discoveredWorkflows"],queryFn:async()=>(await ue("/workflows/discovered")).workflows})}function VM(){return qe({queryKey:["workflowConfigs"],queryFn:async()=>(await ue("/workflows/config")).workflows})}function Hv(){return qe({queryKey:["invocableWorkflows"],queryFn:async()=>(await ue("/workflows/invocable")).workflows})}function YM(n){return Object.fromEntries(n.filter(e=>!e.missing).map(e=>[e.as??e.key,e.data]))}function KM(n,e){return qe({queryKey:["workflows",n,"input-lookups"],queryFn:()=>ue(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function JM(){return qe({queryKey:["cronStatus"],queryFn:async()=>(await ue("/workflows/cron/status")).schedules})}function QM(n){return qe({queryKey:["workflowExecution",n],queryFn:()=>ue(`/workflow-states/${n}/execution`),enabled:!!n})}function XM(n,e){const s=new URLSearchParams;return n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.entity&&s.set("entity",n.entity),n.search&&s.set("search",n.search),n.status&&s.set("status",n.status),n.sort_by&&s.set("sort_by",n.sort_by),n.order&&s.set("order",n.order),n.registered&&s.set("registered",n.registered),n.namespace&&s.set("namespace",n.namespace),qe({queryKey:["jobs",n],queryFn:()=>ue(`/workflow-states/jobs?${s}`),enabled:(e==null?void 0:e.enabled)??!0})}function WM(){const n=Pe();return $e({mutationFn:e=>ue(`/workflows/${e}/terminate`,{method:"POST"}),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function ZM(){const n=Pe();return $e({mutationFn:({workflow_type:e,...s})=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function eR(){const n=Pe();return $e({mutationFn:e=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function tR(){const n=Pe();return $e({mutationFn:({workflowType:e,data:s,metadata:i,execute_as:o})=>ue(`/workflows/${e}/invoke`,{method:"POST",body:JSON.stringify({data:s,metadata:i,...o?{execute_as:o}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function QT(){const{data:n}=Hv();return n!=null&&n.length?h.jsx(qr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd}]}):null}const XT=[{to:"/mcp/queries",label:"Designer",icon:MS},{to:"/mcp/servers",label:"Servers & Tools",icon:RS}];function WT(){return h.jsx(qr,{heading:"Design",entries:XT})}const ZT=[{to:"/files",label:"Files",icon:DS},{to:"/knowledge",label:"Knowledge Base",icon:hx}];function eC(){return h.jsx(qr,{heading:"Storage",entries:ZT})}function tC({isBuilder:n=!1,isOps:e=!1}){var m;const{data:s}=Hn(),i=((m=s==null?void 0:s.features)==null?void 0:m.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:LS},...n||e?[{to:"/admin/roles",label:"Roles",icon:bd},{to:"/admin/personas",label:"Personas",icon:qS},{to:"/admin/scan-codes",label:"Scan Codes",icon:Mo}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:PS},{to:"/admin/streams",label:"Messages",icon:hx},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:BS}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(qr,{heading:"Identity & Access",entries:o}),n&&Zx()&&h.jsx(qr,{heading:"Infrastructure",entries:c})]})}function Fv({aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o,showLines:c}){return h.jsxs(h.Fragment,{children:[h.jsx(DT,{aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o,showLines:c}),h.jsx(VT,{}),!e&&h.jsx(QT,{}),e&&h.jsx(JT,{}),e&&n&&h.jsx(WT,{}),e&&h.jsx(eC,{}),(e||s)&&h.jsx(tC,{isBuilder:e,isOps:s})]})}function nC({open:n,onClose:e,...s}){const i=en();return E.useEffect(()=>{e()},[i.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${n?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:e,"aria-hidden":!0}),h.jsxs("div",{className:`relative w-72 max-w-[85vw] h-full bg-surface-raised border-r border-surface-border shadow-xl flex flex-col transition-transform duration-200 ease-out ${n?"translate-x-0":"-translate-x-full"}`,children:[h.jsx("div",{className:"flex items-center justify-end px-3 pt-3 shrink-0",children:h.jsx("button",{onClick:e,className:"p-1.5 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors","aria-label":"Close navigation",children:h.jsx(Zt,{className:"w-4 h-4"})})}),h.jsx("nav",{className:"flex-1 px-3 pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(tk,{children:h.jsx(Fv,{...s})})})]})]})}const Gv="lt_event_feed_patterns";function rC(n,e){if(n.startsWith("/topics/")){const m=decodeURIComponent(n.replace("/topics/",""));if(m&&!m.includes("/"))return`lt.events.${m}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const m=new URLSearchParams(e).get("role");return m?`lt.events.system.escalation.${rv(m)}.>`:"lt.events.system.escalation.>"}const i=n.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(i)return`lt.events.system.workflow.${i[1]}.>`;if(n.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=n.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(n.startsWith("/agents"))return"lt.events.system.agent.>";if(n.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(n.startsWith("/files"))return"lt.events.system.file.>";if(n==="/")return"lt.events.system.>";const c=n.match(/^\/mcp\/executions\/(.+)/);return c?`lt.events.system.*.${c[1]}.>`:(n.startsWith("/mcp"),"lt.events.system.>")}function sC(){try{const n=localStorage.getItem(Gv);return n?JSON.parse(n):[]}catch{return[]}}function md(n){try{localStorage.setItem(Gv,JSON.stringify(n))}catch{}}function iC(){const{pathname:n,search:e}=en(),[s,i]=E.useState(sC),o=E.useMemo(()=>rC(n,e),[n,e]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),m=E.useCallback(u=>{const d=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(d))return b;const x=[...b,d];return md(x),x})},[]),p=E.useCallback(u=>{i(d=>{const b=d.filter(x=>x!==u);return md(b),b})},[]),g=E.useCallback(()=>{i([]),md([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:m,removePattern:p,clearUserPatterns:g}}function aC({children:n,className:e=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${e}`,children:n})}const pd=280,Q1="cubic-bezier(0.4, 0, 0.2, 1)",Wc=40;function oC(n){if(!n)return"scale(0.92)";const e=window.innerWidth,s=window.innerHeight,i=e-Wc*2,o=s-Wc*2,c=n.width/i,m=n.height/o,p=n.left+n.width/2-(Wc+i/2),g=n.top+n.height/2-(Wc+o/2);return`translate(${p}px, ${g}px) scale(${c}, ${m})`}function Vv({open:n,onClose:e,sourceRef:s,children:i}){const[o,c]=E.useState(null),m=E.useRef(null),p=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!p.current?(m.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&p.current&&o==="open"&&(m.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),p.current=n},[n,s,o]),E.useEffect(()=>{if(o!=="entering")return;const x=requestAnimationFrame(()=>{requestAnimationFrame(()=>c("open"))});return()=>cancelAnimationFrame(x)},[o]),E.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),E.useEffect(()=>{if(!o)return;const x=v=>{v.key==="Escape"&&e()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,e]);const g=E.useCallback(x=>{x.propertyName==="transform"&&o==="exiting"&&c(null)},[o]);if(E.useEffect(()=>{if(o!=="exiting")return;const x=setTimeout(()=>c(null),pd+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",d=u?oC(m.current):"none",b=u?0:1;return sm.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${pd}ms ${Q1}, opacity ${pd}ms ${Q1}`,transform:d,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function lC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function cC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function uC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"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 fC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function hC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"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 dC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}function mC(n){const e=n.trim().split(`
56
+ `),i=[];let o=!1,c=!1,m=[];for(const p of s){const g=p.trim();if(g.startsWith("|")&&g.endsWith("|")){const u=g.slice(1,-1).split("|").map(d=>d.trim());if(u.every(d=>/^[-:]+$/.test(d)))continue;c||(c=!0,m=[]),m.push(u);continue}if(c){c=!1;const[u,...d]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const b of u)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(b)}</th>`);i.push("</tr></thead><tbody>");for(const b of d){i.push("<tr>");for(const x of b)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(x)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>"),m=[]}if(!g){o&&(i.push("</ul>"),o=!1);continue}if(g.startsWith("### ")){o&&(i.push("</ul>"),o=!1),i.push(`<h4 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(4))}</h4>`);continue}if(g.startsWith("## ")){o&&(i.push("</ul>"),o=!1),i.push(`<h3 class="${e.heading} font-semibold text-text-primary mt-3 mb-1">${gs(g.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(g)){o&&(i.push("</ul>"),o=!1),i.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(g)){o||(i.push('<ul class="space-y-1 my-1">'),o=!0),i.push(`<li class="${e.list} ${e.tone} flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${gs(g.slice(2))}</span></li>`);continue}o&&(i.push("</ul>"),o=!1),i.push(`<p class="${e.text} ${e.tone} my-1">${gs(g)}</p>`)}if(c&&m.length){const[p,...g]=m;i.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const u of p)i.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${gs(u)}</th>`);i.push("</tr></thead><tbody>");for(const u of g){i.push("<tr>");for(const d of u)i.push(`<td class="py-1 px-2 border-b border-border/50">${gs(d)}</td>`);i.push("</tr>")}i.push("</tbody></table></div>")}return o&&i.push("</ul>"),i}function Hm({result:n,compact:e=!1}){const{response:s}=n,i=e?"text-xs":"text-sm",o=s?FN(s):null,c=s!=null&&s.error&&s.error!==o?s.error:null;return h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:`${i} font-mono text-text-secondary truncate`,children:n.code}),s?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`${i} font-medium ${$N[s.outcome]}`,children:HN(s)}),c&&h.jsx("div",{className:"text-xs text-text-tertiary mt-0.5",children:c}),o&&h.jsx("div",{className:"text-xs text-text-secondary mt-1.5",children:h.jsx(GN,{content:o,compact:!0})})]}):h.jsx("div",{className:`${i} text-status-error`,children:n.error})]})}function Pv(n){return n.replace(/[\u2010-\u2015\u2212]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\x00-\x1F\x7F]/g,"").trim()}function YN(n){const e=new Set;for(const s of n){const i=s.codePointAt(0);(i>127||i<32)&&e.add(`"${i<32?"\\x"+i.toString(16).padStart(2,"0"):s}" U+${i.toString(16).toUpperCase().padStart(4,"0")}`)}return[...e]}function KN({value:n}){const e=E.useRef(null),[s,i]=E.useState(!1);return E.useEffect(()=>{if(!(!e.current||!n))try{zN(e.current,n,{format:"CODE128",width:2,height:88,margin:12,displayValue:!0,fontSize:13,background:"#ffffff",lineColor:"#000000"}),i(!1)}catch{i(!0)}},[n]),n?h.jsxs("div",{children:[h.jsx("span",{className:"block text-xs uppercase tracking-wide text-text-tertiary mb-1",children:"Barcode"}),s?h.jsxs("p",{className:"text-xs text-status-error",children:["This value has characters Code 128 cannot carry:"," ",h.jsx("span",{className:"font-mono",children:YN(n).join(", ")||"unknown"})]}):h.jsx("div",{className:"bg-white rounded p-1 inline-block max-w-full overflow-hidden",children:h.jsx("svg",{ref:e,className:"max-w-full"})})]}):null}function JN({onClose:n}){const{submitCode:e,lastResult:s,busy:i,wedgeConfig:o,updateWedgeConfig:c,diagnostics:m,diagnosticsOn:p,setDiagnosticsOn:g}=$m(),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=_=>{_.preventDefault();const S=u.trim();S&&(d(""),e(S))};return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-text-primary",children:[h.jsx(Mo,{className:"w-4 h-4"}),"Scan"]}),h.jsx("button",{type:"button",onClick:n,className:"text-text-tertiary hover:text-text-primary",title:"Close",children:h.jsx(en,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6",children:[h.jsxs("form",{onSubmit:v,className:"space-y-2",children:[h.jsx("label",{className:"block text-xs uppercase tracking-wide text-text-tertiary",children:"Enter a code"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{value:u,onChange:_=>d(Pv(_.target.value)),placeholder:"10:1:SN-12345",className:"flex-1 px-2 py-1.5 text-sm bg-surface-raised border border-surface-border rounded text-text-primary","data-scan-manual-entry":!0}),h.jsx("button",{type:"submit",disabled:i||!u.trim(),className:"px-3 py-1.5 text-sm rounded bg-accent text-text-inverse disabled:opacity-50",children:"Go"})]}),h.jsx("p",{className:"text-xs text-text-tertiary",children:"Scanning with a connected scanner works from any page — this entry exists for testing and for codes you can read but not scan. Typing here also draws the code below; point the scanner at the screen to fire it for real."})]}),h.jsx(KN,{value:u.trim()}),s&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs uppercase tracking-wide text-text-tertiary",children:"Last scan"}),h.jsx(Hm,{result:s})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("button",{type:"button",onClick:()=>x(_=>!_),className:"text-xs uppercase tracking-wide text-text-tertiary hover:text-text-primary",children:["Capture settings ",b?"▾":"▸"]}),b&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block text-sm text-text-primary",children:[h.jsx("span",{className:"block text-xs text-text-tertiary mb-1",children:"Key gap limit (ms) — a longer pause between keys starts a new capture; raise it for scanners that pace slowly"}),h.jsx("input",{type:"number",min:100,max:2e3,step:50,value:o.maxKeyGapMs,onChange:_=>c({maxKeyGapMs:Number(_.target.value)}),className:"w-24 px-2 py-1 text-sm bg-surface-raised border border-surface-border rounded"})]}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-text-primary",children:[h.jsx("input",{type:"checkbox",checked:p,onChange:_=>g(_.target.checked)}),h.jsx("span",{children:"Diagnostics — trace every keydown the capture sees (also logged to the console)"})]}),p&&h.jsxs("div",{className:"border border-surface-border rounded",children:[h.jsx("div",{className:"px-2 py-1.5 text-2xs uppercase tracking-wide text-text-tertiary border-b border-surface-border",children:"Keydown trace — scan now, newest last"}),h.jsxs("div",{className:"max-h-64 overflow-y-auto font-mono text-2xs leading-5 px-2 py-1",children:[m.length===0&&h.jsx("div",{className:"text-text-tertiary",children:"Waiting for keys…"}),m.map(_=>h.jsxs("div",{className:"whitespace-nowrap overflow-hidden text-ellipsis",title:`buffer: ${_.buffer}`,children:[h.jsxs("span",{className:"text-text-tertiary",children:[String(_.deltaMs).padStart(4),"ms "]}),h.jsx("span",{className:"text",children:JSON.stringify(_.key)}),_.code&&h.jsxs("span",{className:"text-text-tertiary",children:[" (",_.code,")"]}),h.jsxs("span",{className:"text-text-tertiary",children:[" — ",_.note]})]},_.seq))]}),h.jsxs("div",{className:"px-2 py-1.5 text-2xs text-text-tertiary border-t border-surface-border",children:["Read it like this: a scan should end with an"," ",h.jsx("span",{className:"font-mono",children:'"Enter"'})," row saying"," ",h.jsx("span",{className:"font-mono",children:"capture → …"}),'. An Enter row saying "no code tail" means the buffer split (raise the gap limit, or a key arrived as something other than one character). No Enter row at all means the scanner sends no suffix — program its Enter/CR suffix. Keys named'," ",h.jsx("span",{className:"font-mono",children:'"Unidentified"'})," mean the decode arrives outside the keydown path."]})]})]})]})]})]})}const Bv=/^\{lt:([A-Za-z0-9_]+)\}$/,$1="me";function zM(n){return`{lt:${n}}`}const Uv="lt:station:link-vars:";function em(n){return`${Uv}${n}`}const tm=new Set;function QN(){for(const n of tm)n()}let wu,Qc={};function zv(n){let e=null;try{e=localStorage.getItem(em(n))}catch{e=null}if(e===wu)return Qc;wu=e;try{const s=e?JSON.parse(e):{};Qc=s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(([,i])=>typeof i=="string")):{}}catch{Qc={}}return Qc}function XN(n,e,s){const i={...zv(n)};s===null||s===""?delete i[e]:i[e]=s;try{Object.keys(i).length===0?localStorage.removeItem(em(n)):localStorage.setItem(em(n),JSON.stringify(i))}catch{}wu=void 0,QN()}function WN(n){tm.add(n);const e=s=>{(s.key===null||s.key.startsWith(Uv))&&(wu=void 0,n())};try{window.addEventListener("storage",e)}catch{}return()=>{tm.delete(n);try{window.removeEventListener("storage",e)}catch{}}}const ZN={};function eT(n){return E.useSyncExternalStore(WN,()=>n?zv(n):ZN)}function tT(n,e,s,i={}){let o;try{o=new URL(n,"http://local")}catch{return n}const c=o.searchParams.get("facets");if(!c)return n;let m;try{const g=JSON.parse(c);if(!g||typeof g!="object"||Array.isArray(g))return n;m=g}catch{return n}let p=!1;for(const[g,u]of Object.entries(m)){if(typeof u!="string")continue;const d=Bv.exec(u);if(!d)continue;const b=i[d[1]]??e[d[1]]??s[d[1]];typeof b=="string"&&b!==""?m[g]=b:delete m[g],p=!0}return p?(Object.keys(m).length===0?o.searchParams.delete("facets"):o.searchParams.set("facets",JSON.stringify(m)),o.pathname+o.search):n}function IM(n){let e;try{e=new URL(n,"http://local")}catch{return[]}const s=e.searchParams.get("facets");if(!s)return[];try{const i=JSON.parse(s);if(!i||typeof i!="object"||Array.isArray(i))return[];const o=[];for(const c of Object.values(i)){if(typeof c!="string")continue;const m=Bv.exec(c);m&&!o.includes(m[1])&&o.push(m[1])}return o}catch{return[]}}function Fm(){var v;const{user:n,isSuperAdmin:e,hasRoleType:s}=Lt(),i=(n==null?void 0:n.userId)??null,o=e||s("admin"),c=E.useMemo(()=>new Set(((n==null?void 0:n.roles)??[]).map(_=>_.role)),[n]),{data:m}=Mu({enabled:o||c.size>0}),p=eT(i),g=((v=vA())==null?void 0:v.actorId)??i,u=E.useMemo(()=>{var C;const _=[],S=new Set;for(const B of(m==null?void 0:m.roles)??[]){if(!o&&!c.has(B.role))continue;const q=(C=B.properties)==null?void 0:C.link_variables;if(Array.isArray(q))for(const ne of q){const te=ne==null?void 0:ne.name;if(typeof te!="string"||te===""||te===$1||S.has(te))continue;S.add(te);const M=ne.label,z=ne.default;_.push({name:te,...typeof M=="string"&&M!==""?{label:M}:{},...typeof z=="string"&&z!==""?{default:z}:{},fromRole:B.role})}}return _},[m,c,o]),d=E.useMemo(()=>{const _={};for(const S of u)S.default!==void 0&&(_[S.name]=S.default);return _},[u]),b=E.useCallback(_=>tT(_,p,d,g?{[$1]:g}:{}),[p,d,g]),x=E.useCallback((_,S)=>{i&&XN(i,_,S)},[i]);return{declarations:u,values:p,defaults:d,resolveUrl:b,setValue:x}}function nT({open:n,onClose:e,title:s,children:i,maxWidth:o,closeOnBackdrop:c=!0}){return E.useEffect(()=>{if(!n)return;const m=p=>{p.key==="Escape"&&e()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n,e]),n?sm.createPortal(h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:c?e:void 0}),h.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"lt-modal-title",className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${o??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[h.jsx("h2",{id:"lt-modal-title",className:"text-sm font-medium text-text-primary",children:s}),h.jsx("button",{onClick:e,"aria-label":"Close dialog",className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}function rT({open:n,onClose:e}){const{declarations:s,values:i,setValue:o}=Fm();return h.jsxs(nT,{open:n,onClose:e,title:"Link Variables",maxWidth:"max-w-lg",children:[h.jsx("p",{className:"text-2xs text-text-tertiary leading-relaxed mb-4",children:"Values bound on this device. Pinned links and the Pace Board open scoped to the value applied; an unbound variable falls back to the role's default, or applies no filter at all."}),h.jsx("div",{className:"divide-y divide-surface-border",children:s.map((c,m)=>h.jsx(sT,{declaration:c,value:i[c.name]??"",autoFocus:m===0,onChange:p=>o(c.name,p),onClear:()=>o(c.name,null),onEnter:e},c.name))}),s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary",children:"Your roles declare no link variables."}),s.length>0&&h.jsx("div",{className:"flex justify-end pt-4",children:h.jsx("button",{onClick:e,className:"px-3 py-1.5 text-xs rounded bg-accent text-text-inverse hover:bg-accent-hover transition-colors",children:"OK"})})]})}function sT({declaration:n,value:e,autoFocus:s,onChange:i,onClear:o,onEnter:c}){const m=E.useId(),{data:p}=sk(n.name),g=(p==null?void 0:p.values)??[];return h.jsxs("div",{className:"py-3 flex items-center gap-3","data-testid":"link-var-row",children:[h.jsxs("div",{className:"w-40 shrink-0 min-w-0",children:[h.jsx("p",{className:"text-xs font-mono text-text-primary truncate",title:n.name,children:n.name}),h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:`declared by ${n.fromRole}`,children:n.label??n.fromRole})]}),h.jsx("input",{type:"text",list:m,autoFocus:s,value:e,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:n.default?`${n.default} (default)`:"no filter","aria-label":`Value for ${n.name}`,className:"input text-xs font-mono flex-1 min-w-0"}),h.jsx("datalist",{id:m,children:g.map(u=>h.jsx("option",{value:u},u))}),h.jsx("button",{onClick:o,disabled:e==="",title:`Clear ${n.name}`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors disabled:opacity-30 disabled:cursor-not-allowed shrink-0",children:"×"})]})}const H1=["escalationId","workflowId"],iT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Iv="lt:search:mode",aT="lt:search:facet",Dt={FACET:"facet",COMMAND:"command"};function oT(n,e){return{version:n.version,category:e.category,name:e.name,schemeName:n.name,targetFacet:n.target_facet,encoding:n.encoding,delimiter:n.delimiter,targetLength:n.target_length}}function Co(n){return n.encoding==="delimited"?`${n.version}${n.delimiter}${n.category}${n.delimiter}`:`${n.version}${n.category}`}function lT(n,e){if(n.encoding==="delimited")return cT(n,e)?{code:e}:{code:`${Co(n)}${e}`};if(!/^[0-9]+$/.test(e))return{error:`${n.name} takes digits only`};const s=n.targetLength;return s&&e.length!==s&&e.length!==s+1?{error:`${n.name} takes ${s} digits`}:{code:`${Co(n)}${e}`}}function cT(n,e){const s=n.delimiter.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^[1-9][0-9]${s}[0-9]${s}.+$`).test(e)}function uT(n,e){return n==="escalationId"||n==="workflowId"?null:Xk(n,e)}function fT(n){return n.kind===Dt.FACET?n.facet:n.command.name}function hT(n){return n.kind===Dt.COMMAND?n.command.targetFacet:n.facet==="escalationId"?"Escalation id":n.facet==="workflowId"?"Workflow id":n.facet}function dT(n){return n.kind===Dt.FACET?{kind:Dt.FACET,facet:n.facet}:{kind:Dt.COMMAND,version:n.command.version,category:n.command.category}}function mT(n,e,s){if((n==null?void 0:n.kind)===Dt.FACET&&e.includes(n.facet))return{kind:Dt.FACET,facet:n.facet};if((n==null?void 0:n.kind)===Dt.COMMAND){const i=s.find(o=>o.version===n.version&&o.category===n.category);if(i)return{kind:Dt.COMMAND,command:i}}return e.length>0?{kind:Dt.FACET,facet:e[0]}:s.length>0?{kind:Dt.COMMAND,command:s[0]}:null}function pT(){try{const n=localStorage.getItem(Iv);if(n){const s=JSON.parse(n);if(s.kind===Dt.FACET&&typeof s.facet=="string"||s.kind===Dt.COMMAND&&typeof s.version=="number"&&typeof s.category=="string")return s}const e=localStorage.getItem(aT);return e?{kind:Dt.FACET,facet:e}:null}catch{return null}}function yT(n){try{localStorage.setItem(Iv,JSON.stringify(n))}catch{}}const F1=5*6e4,gT=n=>({rules:n.map(e=>{var s;return((s=e.data)==null?void 0:s.rules)??null}),loading:n.some(e=>e.isLoading)});function bT(n){const e=jv({enabled:n,staleTime:F1}),s=E.useMemo(()=>{var m;return(((m=e.data)==null?void 0:m.schemes)??[]).filter(p=>p.enabled&&p.kind===Fk.ACTION).sort((p,g)=>p.version-g.version)},[e.data]),{rules:i,loading:o}=fS({queries:s.map(m=>({queryKey:["scan-schemes",m.version,"actions"],queryFn:()=>ue(`/scan-codes/schemes/${m.version}/actions`),enabled:n,staleTime:F1})),combine:gT});return{commands:E.useMemo(()=>s.flatMap((m,p)=>(i[p]??[]).filter(g=>g.enabled).sort((g,u)=>g.category.localeCompare(u.category)).map(g=>oT(m,g))),[s,i]),loading:e.isLoading||o}}const xT={escalationId:"opens the item",workflowId:"opens the run"};function vT({mode:n,facets:e,commands:s,onSelect:i,onOpenScanPanel:o}){const[c,m]=E.useState(!1),p=E.useRef(null);E.useEffect(()=>{if(!c)return;const x=_=>{p.current&&!p.current.contains(_.target)&&m(!1)},v=_=>{_.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[c]);const g=n.kind===Dt.COMMAND,u=g?`${n.command.schemeName} · ${n.command.name} — ${Co(n.command)}<${n.command.targetFacet}>`:`Search by ${n.facet}`,d=_T(s),b=x=>{i(x),m(!1)};return h.jsxs("div",{ref:p,className:"relative h-full shrink-0",children:[h.jsxs("button",{type:"button",onClick:()=>m(x=>!x),"aria-expanded":c,"aria-haspopup":"listbox","aria-label":"Search or run as",title:u,className:"group flex items-center gap-1 h-full pl-2.5 pr-2 border-l border-surface-field-border hover:bg-surface-hover transition-colors rounded-r-[var(--lt-radius-field)]","data-testid":"search-mode",children:[h.jsx("span",{className:`text-2xs whitespace-nowrap truncate max-w-[9rem] ${g?"font-medium text-accent":"font-mono text-text-tertiary"}`,children:fT(n)}),h.jsx(im,{className:`w-3 h-3 shrink-0 text-text-quaternary group-hover:text-accent transition-transform ${c?"rotate-180":""}`,strokeWidth:1.5})]}),c&&h.jsxs("div",{role:"listbox","aria-label":"Search or run as",className:"absolute z-50 top-full right-0 mt-1.5 min-w-[17rem] max-w-[24rem] max-h-[70vh] overflow-y-auto bg-surface-raised border border-surface-border rounded-md shadow-lg py-1",children:[e.length>0&&h.jsxs(h.Fragment,{children:[h.jsx(G1,{children:"Find"}),e.map(x=>h.jsx(V1,{label:x,mono:!0,note:xT[x]??"filters the list",active:!g&&n.facet===x,onClick:()=>b({kind:Dt.FACET,facet:x})},x))]}),d.map(({schemeName:x,targetFacet:v,items:_})=>h.jsxs("div",{children:[h.jsxs(G1,{note:v,children:["Run · ",x]}),_.map(S=>h.jsx(V1,{label:S.name,note:Co(S),noteMono:!0,active:g&&n.command.version===S.version&&n.command.category===S.category,onClick:()=>b({kind:Dt.COMMAND,command:S})},`${S.version}:${S.category}`))]},x)),o&&h.jsxs(h.Fragment,{children:[h.jsx("hr",{className:"border-surface-border/60 my-1"}),h.jsxs("button",{type:"button",onClick:()=>{m(!1),o()},className:"w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs text-accent hover:bg-surface-hover","data-testid":"search-mode-scan-panel",children:[h.jsx(Mo,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Scanner settings and barcode preview"]})]})]})]})}function _T(n){const e=[];for(const s of n){const i=e.find(o=>o.schemeName===s.schemeName);i?i.items.push(s):e.push({schemeName:s.schemeName,targetFacet:s.targetFacet,items:[s]})}return e}function G1({children:n,note:e}){return h.jsxs("p",{className:"px-3 pt-2 pb-1 flex items-baseline gap-2 text-2xs font-semibold uppercase tracking-widest text-text-quaternary first:pt-1",children:[h.jsx("span",{className:"truncate",children:n}),e&&h.jsx("span",{className:"ml-auto font-mono font-normal normal-case tracking-normal shrink-0",children:e})]})}function V1({label:n,note:e,active:s,mono:i,noteMono:o,onClick:c}){return h.jsxs("button",{type:"button",role:"option","aria-selected":s,onClick:c,className:`w-full text-left pl-3 pr-3 py-1.5 flex items-baseline gap-3 border-l-2 transition-colors ${s?"border-accent bg-accent/10 text-accent":"border-transparent text-text-primary hover:bg-surface-hover"}`,children:[h.jsx("span",{className:`text-xs font-medium truncate ${i?"font-mono":""}`,children:n}),h.jsx("span",{className:`ml-auto text-2xs shrink-0 ${o?"font-mono tabular-nums":""} ${s?"text-accent/70":"text-text-quaternary"}`,children:e})]})}const wT=6e3;function ST({onOpenScanPanel:n}){const e=ni(),{data:s}=Hn(),i=zm(),{submitCode:o,busy:c,lastResult:m}=$m(),{commands:p}=bT(i),[g,u]=E.useState(""),[d,b]=E.useState(!1),[x,v]=E.useState(null),[_,S]=E.useState(null),[C,B]=E.useState(""),[q,ne]=E.useState(null),[te,M]=E.useState(pT),z=E.useRef(null),ae=E.useMemo(()=>{var ce;if(!((ce=s==null?void 0:s.search)!=null&&ce.enabled))return[];const J=(s.search.facets??[]).filter(pe=>!H1.includes(pe));return[...H1,...J]},[s]),F=E.useMemo(()=>mT(te,ae,p),[te,ae,p]),U=(m==null?void 0:m.source)===na.TOOLBAR&&!m.navigated&&q!==m.at?m:null;E.useEffect(()=>{if(!U)return;const J=setTimeout(()=>ne(U.at),wT);return()=>clearTimeout(J)},[U]);const D=()=>{v(null),S(null),m&&ne(m.at)},Q=J=>{var pe;const ce=dT(J);M(ce),yT(ce),D(),(pe=z.current)==null||pe.focus()},W=(J,ce)=>{const pe=lT(J.command,Pv(ce));if("error"in pe){v(pe.error);return}u(""),o(pe.code,na.TOOLBAR)},he=async(J,ce)=>{const pe=uT(J,ce);if(pe){u(""),e(pe);return}if(J==="escalationId"&&!iT.test(ce)){v("That is not a valid escalation id");return}b(!0);try{if(J==="escalationId")await ue(`/escalations/${encodeURIComponent(ce)}`),u(""),e(`/escalations/detail/${encodeURIComponent(ce)}`);else{const ge=await ue(`/escalations/by-workflow/${encodeURIComponent(ce)}`),Ce=(ge==null?void 0:ge.escalations)??[];Ce.length===1?(u(""),e(`/escalations/detail/${Ce[0].id}`)):(B(ce),S(Ce))}}catch{v(`No ${J==="escalationId"?"escalation":"workflow"} found for "${ce}"`)}finally{b(!1)}},Ee=()=>{const J=g.trim();!J||d||c||!F||(D(),F.kind===Dt.COMMAND?W(F,J):he(F.facet,J))};if(!F)return null;const Ae=F.kind===Dt.COMMAND,H=d||c;return h.jsxs("div",{className:"relative w-full max-w-[28rem]","data-testid":"global-search",children:[h.jsxs("div",{className:"flex items-center h-8 bg-surface-field border border-surface-field-border rounded-[var(--lt-radius-field)] focus-within:border-accent focus-within:bg-surface-field-focus transition-colors",children:[h.jsxs("label",{htmlFor:"global-search-input",className:"flex items-center gap-1.5 pl-2.5 shrink-0 cursor-text",children:[Ae?h.jsx(Mo,{className:"w-3.5 h-3.5 text-accent/65",strokeWidth:1.5}):h.jsx(vS,{className:"w-3.5 h-3.5 text-text-quaternary",strokeWidth:1.5}),Ae&&h.jsx("span",{className:"font-mono text-xs tabular-nums text-text-tertiary select-none","data-testid":"search-command-prefix",children:Co(F.command)})]}),h.jsx("input",{ref:z,id:"global-search-input",type:"text",value:g,onChange:J=>{u(J.target.value),D()},onKeyDown:J=>{J.key==="Enter"&&Ee(),J.key==="Escape"&&(u(""),D())},placeholder:hT(F),"aria-label":Ae?"Run target":"Global search",autoComplete:"off",spellCheck:!1,className:`flex-1 min-w-0 h-full bg-transparent text-xs text-text-primary placeholder:text-text-quaternary focus:outline-none ${Ae?"pl-0.5 pr-2 font-mono":"px-2"}`}),H&&h.jsx("span",{className:"w-1.5 h-1.5 mr-2 rounded-full bg-accent animate-pulse shrink-0","aria-label":"Working"}),h.jsx(vT,{mode:F,facets:ae,commands:p,onSelect:Q,onOpenScanPanel:n})]}),x&&h.jsx("p",{className:"absolute top-full left-0 mt-1 text-2xs text-status-error whitespace-nowrap",role:"alert",children:x}),U&&h.jsx("div",{role:"status",className:"absolute top-full left-0 mt-1.5 z-50 w-full max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg px-3 py-2 animate-fade-in","data-testid":"search-run-outcome",children:h.jsx(Hm,{result:U,compact:!0})}),_!==null&&h.jsxs("div",{className:"absolute top-full left-0 mt-1.5 z-50 min-w-72 max-w-96 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1","data-testid":"search-workflow-results",children:[_.map(J=>h.jsxs(ar,{to:`/escalations/detail/${J.id}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-hover truncate",children:[h.jsx("span",{className:"font-medium text-text-primary",children:J.role}),h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),J.status,h.jsx("span",{className:"mx-1.5 text-text-quaternary",children:"·"}),h.jsx("span",{className:"text-text-tertiary",children:J.type})]},J.id)),_.length===0&&h.jsx("p",{className:"px-3 py-1.5 text-2xs text-text-tertiary",children:"No escalations for this workflow."}),h.jsx("hr",{className:"border-surface-border/60 my-0.5"}),h.jsx(ar,{to:`/workflows/executions/${encodeURIComponent(C)}`,onClick:()=>{S(null),u("")},className:"block px-3 py-1.5 text-xs text-accent hover:bg-surface-hover",children:"Workflow execution →"})]})]})}function ET(){const{identity:n,remainingSeconds:e}=Cu(),[,s]=E.useState(0);return E.useEffect(()=>{if(!(n!=null&&n.expiresAt))return;const i=setInterval(()=>s(o=>o+1),1e3);return()=>clearInterval(i)},[n]),e()}function OT(n){return n>=60?`${Math.floor(n/60)} min`:`${n} s`}function AT(){const{identity:n}=Cu(),e=ET();return n?h.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-secondary whitespace-nowrap min-w-0",title:`Scans act as ${n.displayName}`,"data-testid":"badge-grant-indicator",children:[h.jsx(_S,{className:"w-4 h-4 text-status-success shrink-0",strokeWidth:1.5}),h.jsx("span",{className:"hidden sm:inline",children:"Badged:"}),h.jsx("span",{className:"font-medium text-text-primary truncate max-w-[10rem]",children:n.displayName}),n.expiresAt&&h.jsxs("span",{className:"tabular-nums text-text-tertiary","data-testid":"badge-grant-remaining",children:["· ",OT(e)]})]}):null}function jT(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function nm(n){var e;return((e=n.title)==null?void 0:e.trim())||jT(n.role)}const $v="lt:bookmarks",Xc="scan";function kT(){try{const n=localStorage.getItem($v);if(!n)return[];const e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function Y1(n){try{localStorage.setItem($v,JSON.stringify(n))}catch{}}function NT({onToggleEventFeed:n,onToggleDocs:e,onToggleNav:s}){var Pe,zt,qt,at;const i=ni(),{user:o,logout:c,isSuperAdmin:m,hasRoleType:p}=Lt(),{viewAs:g,realIsBuilder:u}=tv(),{available:d,mine:b}=fk();nv();const{connected:x}=qx(),{data:v}=Hn(),{role:_,targets:S,selectable:C,selectRole:B}=Cm(),{declarations:q,values:ne}=Fm(),[te,M]=E.useState(!1),{data:z}=Mu(),ae=E.useMemo(()=>{const ye=(z==null?void 0:z.roles)??[],Ye=new Set(((o==null?void 0:o.roles)??[]).map(At=>At.role)),yt=m||p("admin");return ye.filter(At=>ta(At).length>0&&(yt||Ye.has(At.role))).map(At=>({role:At.role,title:nm(At),portals:ta(At)}))},[z,o,m,p]),{setPanel:F,closePanel:U,open:D,ownerKey:Q}=Lm(),W=zm(),he=tn(),Ee=()=>{D&&Q===Xc?U(Xc):F(h.jsx(JN,{onClose:()=>U(Xc)}),{width:360,key:Xc})},[Ae,H]=E.useState(!1),[J,ce]=E.useState(!1),[pe,ge]=E.useState(Sv),[Ce,Ne]=E.useState(kT),Me=E.useRef(null),Xe=(Pe=v==null?void 0:v.branding)==null?void 0:Pe.appName,pt=(zt=v==null?void 0:v.branding)==null?void 0:zt.themes,Ot=E.useMemo(()=>(jk(pt??[]),kk()),[pt]),mt=ye=>{Nk(ye),ge(ye)},_e=()=>{const ye=window.prompt("Bookmark label:");if(!(ye!=null&&ye.trim()))return;const Ye=he.pathname+he.search,yt=[...Ce,{label:ye.trim(),url:Ye}].sort((At,Ur)=>At.label.localeCompare(Ur.label));Ne(yt),Y1(yt),H(!1)},le=ye=>{const Ye=Ce.filter(yt=>!(yt.label===ye.label&&yt.url===ye.url));Ne(Ye),Y1(Ye)};return E.useEffect(()=>{if(!Ae)return;const ye=Ye=>{Me.current&&!Me.current.contains(Ye.target)&&H(!1)};return document.addEventListener("mousedown",ye),()=>document.removeEventListener("mousedown",ye)},[Ae]),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 ${Ae?"z-[100]":"z-30"}`,children:[h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s&&h.jsx("button",{onClick:s,className:"lg:hidden p-2 text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open navigation",children:h.jsx(wS,{className:"w-5 h-5",strokeWidth:1.5})}),h.jsx(ar,{to:"/","aria-label":"Home",className:"shrink-0 hidden lg:block",onClick:ye=>{(ye.ctrlKey||ye.metaKey)&&(ye.preventDefault(),ce(!0))},children:h.jsx(Ru,{appName:Xe,className:"flex"})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border mx-1"}),h.jsx("button",{onClick:()=>i(-1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go back",children:h.jsx(cx,{className:"w-5 h-5",strokeWidth:2})}),h.jsx("button",{onClick:()=>i(1),className:"p-2 text-accent/60 hover:text-accent transition-colors","aria-label":"Go forward",children:h.jsx(gd,{className:"w-5 h-5",strokeWidth:2})})]}),(((qt=v==null?void 0:v.search)==null?void 0:qt.enabled)||W)&&h.jsx("div",{className:"hidden md:flex flex-1 min-w-0 justify-center px-4 lg:px-8",children:h.jsx(ST,{onOpenScanPanel:W?Ee:void 0})}),h.jsxs("div",{className:"flex items-center gap-5 shrink-0",children:[h.jsx(AT,{}),h.jsxs(ar,{to:"/escalations/available",className:`flex items-center gap-1.5 text-xs transition-colors ${d>0?"text-status-queued":"text-text-quaternary hover:text-text-secondary"}`,title:"All escalations",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"all"}),d>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:d})]}),h.jsxs(ar,{to:"/escalations/queue",className:`flex items-center gap-1.5 text-xs transition-colors ${b>0?"text-status-claimed":"text-text-quaternary hover:text-text-secondary"}`,title:"My escalation queue",children:[h.jsx(bd,{className:"w-4 h-4",strokeWidth:1.5}),h.jsx("span",{className:"hidden lg:inline",children:"mine"}),b>0&&h.jsx("sup",{className:"tabular-nums font-medium text-[0.5em]",children:b})]}),g&&h.jsx(h.Fragment,{children:h.jsxs("span",{className:"hidden lg:flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-accent/10 border border-accent/25 text-2xs text-accent select-none",children:[h.jsxs("span",{className:"capitalize font-medium tracking-wide",children:[g," View"]}),h.jsx("button",{onClick:Vd,title:"Restore your real view",className:"ml-0.5 rounded-full p-0.5 hover:bg-accent/20 transition-colors",children:h.jsx(en,{className:"w-2.5 h-2.5"})})]})}),h.jsx("div",{className:"hidden lg:block w-px h-4 bg-surface-border"}),o&&h.jsxs("div",{className:"relative",ref:Me,children:[h.jsxs("button",{onClick:()=>H(ye=>!ye),className:"btn-ghost flex items-center gap-1",children:[h.jsxs("span",{className:"relative",children:[h.jsx(SS,{className:"w-4 h-4 text-accent/75",strokeWidth:1.5}),g&&h.jsx("span",{className:"lg:hidden absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-accent"})]}),h.jsx("span",{className:"hidden lg:inline whitespace-nowrap",children:o.displayName||o.username||o.userId}),h.jsx("svg",{className:"hidden lg:block w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),Ae&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 bg-surface-raised border border-surface-border rounded-md shadow-lg py-1 z-[100]",children:[h.jsx(ar,{to:"/credentials",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Credentials"}),((at=v==null?void 0:v.auth)==null?void 0:at.oauthServer)&&h.jsx(ar,{to:"/connected-apps",onClick:()=>H(!1),className:"block px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Connected apps"}),W&&h.jsx("button",{onClick:()=>{H(!1),Ee()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-scan",children:"Scan a code"}),h.jsx("button",{onClick:()=>{H(!1),x?n==null||n():window.location.reload()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:x?"Events":"Reconnect events"}),u&&h.jsx("button",{onClick:()=>{H(!1),e==null||e()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover","data-testid":"menu-docs",children:"Docs"}),g&&h.jsxs("button",{onClick:()=>{H(!1),Vd()},className:"lg:hidden block w-full text-left px-3 py-2 text-xs text-accent hover:bg-surface-hover capitalize",children:["Exit ",g," view"]}),h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Theme"}),h.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ot.map(ye=>h.jsx("button",{type:"button",onClick:()=>mt(ye.id),title:ye.label,"aria-label":`${ye.label} theme`,className:`w-4 h-4 rounded-full transition-transform hover:scale-110 ${pe===ye.id?"ring-2 ring-offset-1 ring-surface-border":""}`,style:{backgroundColor:ye.swatch}},ye.id))})]}),C&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Station queue"}),h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("button",{type:"button",onClick:()=>{H(!1),B(null),i("/")},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${_?"text-text-secondary":"text-accent"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${_?"bg-surface-border":"bg-accent"}`}),h.jsx("span",{className:"truncate",children:"Full dashboard"})]}),S.map(ye=>{var At;const Ye=(At=z==null?void 0:z.roles)==null?void 0:At.find(Ur=>Ur.role===ye),yt=ye===_;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),B(ye),i(hv(ye,ta(Ye)))},className:`flex items-center gap-2 -mx-1 px-1 py-1 text-xs text-left rounded hover:bg-surface-hover ${yt?"text-accent":"text-text-secondary"}`,children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${yt?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:nm({role:ye,title:Ye==null?void 0:Ye.title})})]},ye)})]})]}),ae.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60","data-testid":"menu-portals",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Portals"}),h.jsx("div",{className:"flex flex-col gap-1.5",children:ae.map(ye=>h.jsxs("div",{children:[ae.length>1&&h.jsx("p",{className:"text-2xs text-text-quaternary truncate",title:ye.role,children:ye.title}),ye.portals.map(Ye=>{const yt=Tm(ye.role,Ye.key),At=he.pathname===yt;return h.jsxs("button",{type:"button",onClick:()=>{H(!1),i(yt)},className:`flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded hover:bg-surface-hover ${At?"text-accent":"text-text-secondary"}`,"data-testid":`menu-portal-${ye.role}-${Ye.key}`,children:[h.jsx(xd,{className:"w-3.5 h-3.5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate",children:Ye.label})]},Ye.key)})]},ye.role))})]}),q.length>0&&h.jsxs("div",{className:"px-3 py-2 border-t border-surface-border/60",children:[h.jsx("p",{className:"text-2xs font-medium uppercase tracking-widest text-text-tertiary mb-1.5",children:"Link variables"}),h.jsxs("button",{type:"button",onClick:()=>{H(!1),M(!0)},className:"flex items-center gap-2 -mx-1 px-1 py-1 w-full text-xs text-left rounded text-text-secondary hover:bg-surface-hover","data-testid":"link-vars-menu-entry",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Object.keys(ne).length>0?"bg-accent":"bg-surface-border"}`}),h.jsx("span",{className:"truncate",children:Object.keys(ne).length>0?Object.entries(ne).map(([ye,Ye])=>`${ye} = ${Ye}`).join(", "):"Set values for this device"})]})]}),h.jsx("button",{onClick:()=>{H(!1),c()},className:"block w-full text-left px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:"Sign Out"}),h.jsxs("div",{className:"border-t border-surface-border/60 pt-1",children:[Ce.map(ye=>h.jsxs("div",{className:"flex items-center group px-3 py-1.5 hover:bg-surface-hover",children:[h.jsx(ar,{to:ye.url,onClick:()=>H(!1),title:ye.url,className:"flex-1 min-w-0 text-xs text-text-secondary hover:text-text-primary truncate",children:ye.label}),h.jsx("button",{type:"button",onClick:()=>le(ye),title:`Remove "${ye.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(en,{className:"w-3 h-3"})})]},`${ye.label}::${ye.url}`)),h.jsx("hr",{className:"border-surface-border/60 mx-3 my-0.5"}),h.jsxs("button",{type:"button",onClick:_e,className:"flex items-center gap-1.5 w-full px-3 py-2 text-xs text-text-secondary hover:bg-surface-hover",children:[h.jsx(ES,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),"Add Bookmark"]})]})]})]})]})]}),J&&h.jsx(Ak,{onClose:()=>ce(!1)}),h.jsx(rT,{open:te,onClose:()=>M(!1)})]})}function Gm({open:n,children:e}){const[s,i]=E.useState(n);return E.useEffect(()=>{n&&i(!0)},[n]),h.jsx("div",{className:`grid transition-[grid-template-rows] duration-300 ease-out ${n?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,onTransitionEnd:()=>{n||i(!1)},children:h.jsx("div",{className:"overflow-hidden",children:s?e:null})})}function rm(n){return({isActive:e})=>{const s="flex items-center rounded-md transition-colors duration-150",i="bg-surface-hover text-text-primary font-medium",o="text-text-secondary hover:text-text-primary hover:bg-surface-hover";return n?`${s} justify-center w-10 h-10 mx-auto ${e?i:o}`:`${s} gap-3 px-4 py-2 text-sm ${e?i:o}`}}function TT(){return({isActive:n})=>`flex items-center gap-3 pl-11 pr-4 py-1.5 text-xs rounded-md transition-colors duration-150 ${n?"text-text-primary font-medium":"text-text-secondary hover:text-text-primary"}`}function CT({group:n,collapsed:e}){const{pathname:s}=tn(),i=n.matchPaths.some(p=>s.startsWith(p)),[o,c]=E.useState(i),m=o||i;return e?h.jsx(h.Fragment,{children:n.items.map(p=>h.jsx(Os,{to:p.to,className:rm(!0),title:p.label,children:p.icon&&h.jsx(p.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})},p.to))}):h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>c(p=>!p),className:"w-full flex items-center justify-between px-4 py-2 text-sm rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",children:[h.jsxs("span",{className:"flex items-center gap-3",children:[n.icon&&h.jsx(n.icon,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:n.label})]}),h.jsx("svg",{className:`w-3.5 h-3.5 text-text-tertiary transition-transform duration-150 ${m?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),h.jsx(Gm,{open:m,children:n.items.map(p=>h.jsxs(Os,{to:p.to,end:p.end,className:TT(),children:[p.icon&&h.jsx(p.icon,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{children:p.label})]},p.to))})]})}function MT(n){return n.kind==="group"}function RT({entry:n,collapsed:e}){const{pathname:s,search:i}=tn(),o=n.to.includes("?"),c=n.icon&&h.jsx(n.icon,{className:`w-5 h-5 shrink-0 text-accent/75 ${n.iconClassName??""}`,strokeWidth:1.5,...n.solid?{fill:"currentColor"}:{}});if(o){const[m,p]=n.to.split("?"),g=s===m&&i===`?${p}`,u=rm(e)({isActive:g});return h.jsxs(Os,{to:n.to,className:u,title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}return h.jsxs(Os,{to:n.to,end:n.end,className:rm(e),title:e?n.label:void 0,children:[c,!e&&h.jsx("span",{children:n.label})]})}function qr({heading:n,entries:e}){const{collapsed:s}=Rm();return h.jsxs("div",{className:"space-y-1",children:[s?h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:n}):h.jsx("p",{className:"px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary",children:n}),e.map(i=>MT(i)?h.jsx(CT,{group:i,collapsed:s},i.label):h.jsx(RT,{entry:i,collapsed:s},i.to))]})}function DT({aiEnabled:n=!1,isBuilder:e=!1,isOps:s=!1,viewAs:i=null,canSeePaceBoard:o=!1,showLines:c=!1}){const m=[{to:"/pace",label:"Pace Board",icon:OS},{to:"/trends",label:"Trend Board",icon:AS}],p=c?[{to:"/lines",label:"Lines",icon:jS}]:[];if(!e&&(!s||i==="engineer"||i==="operator"))return o?h.jsx(qr,{heading:"Monitor",entries:m}):null;if(!e)return h.jsx(qr,{heading:"Monitor",entries:[...o?m:[],...p]});const g=[...o?m:[],...p,{to:"/topics",label:"Event Topics",icon:ux},{to:"/agents",label:n?"Agents":"Automations",icon:kS},{to:"/capabilities",label:"Capabilities",icon:NS}];return h.jsx(qr,{heading:"Monitor",entries:g})}function LT(){return Le({queryKey:["me","preferences"],queryFn:()=>ue("/me/preferences"),staleTime:6e4})}function qT(){const n=qe();return Ie({mutationFn:e=>ue("/me/preferences",{method:"PATCH",body:JSON.stringify(e)}),onSuccess:e=>{n.setQueryData(["me","preferences"],e)}})}const xs={TABLE:"table",RICH:"rich",TIMELINE:"timeline"},K1={COMPACT:"compact",CARDS:"cards"},dd={AVAILABLE:"/escalations/available",ALL:"/escalations"},ra={AVAILABLE:"available",CLAIMED:"claimed",RESOLVED:"resolved",CANCELLED:"cancelled",EXPIRED:"expired"},PT={[ra.RESOLVED]:"resolved",[ra.CANCELLED]:"cancelled",[ra.EXPIRED]:"expired"};function BT(n){const e=n===ra.CLAIMED;return{available:n===ra.AVAILABLE,claimed:e,apiStatus:e?"pending":PT[n]}}function UT(n){return n===xs.TABLE||n===xs.RICH||n===xs.TIMELINE}function zT(n){return n===K1.COMPACT||n===K1.CARDS}function IT(n,e=""){const s=n.get("priority"),i=n.get("view"),o=n.get("layout");return{statusFilter:n.get("status")||e,role:n.get("role")||void 0,type:n.get("type")||void 0,subtype:n.get("subtype")||void 0,priority:s?parseInt(s,10):void 0,search:n.get("search")||void 0,facets:Qk(n),view:UT(i)?i:null,layout:zT(o)?o:null}}function $T(n){let e;try{e=new URL(n,"http://local")}catch{return null}if(e.pathname!==dd.AVAILABLE&&e.pathname!==dd.ALL)return null;const s=e.pathname===dd.AVAILABLE?ra.AVAILABLE:"";return IT(e.searchParams,s)}function $M(n){var e;return n.role||(((e=n.facets.roles)==null?void 0:e.length)===1?n.facets.roles[0]:null)}function HM(n,e){return n===xs.TIMELINE?xs.TIMELINE:e&&(!n||n===xs.RICH)?xs.RICH:xs.TABLE}function HT(n,e){const s=(n==null?void 0:n.pinnedViews)??[],i=new Set((n==null?void 0:n.hiddenRolePins)??[]),o=new Set(s.map(p=>p.label)),c=[...s],m=new Set;for(const{role:p,pins:g}of e)for(const u of g)o.has(u.label)||i.has(u.label)||m.has(u.label)||(m.add(u.label),c.push({...u,id:`role:${p}:${u.label}`,fromRole:p}));return c}function FT(n){const e=$T(n);if(!e)return null;const{available:s,claimed:i,apiStatus:o}=BT(e.statusFilter);return{available:s,params:{...e.facets,role:e.role,type:e.type,subtype:e.subtype,priority:e.priority,status:o,...i?{claimed:!0}:{},search:e.search}}}function GT(){return`pin-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function VT(){var U;const{collapsed:n}=Rm(),{user:e}=Lt(),s=LT(),i=qT(),o=E.useMemo(()=>new Set(((e==null?void 0:e.roles)??[]).map(D=>D.role)),[e]),{data:c}=Mu({enabled:o.size>0}),m=nn("SUMMARY");ks(jm(),()=>{m([["escalations"]])});const p=(U=s.data)==null?void 0:U.preferences,g=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Array.isArray(D.default_pins)&&D.default_pins.length>0).map(D=>({role:D.role,pins:D.default_pins})),[c,o]),{resolveUrl:u}=Fm(),d=E.useMemo(()=>HT(p,g),[p,g]),b=E.useMemo(()=>new Map(d.map(D=>[D.id,D.url])),[d]),x=E.useMemo(()=>d.map(D=>({...D,url:u(D.url)})),[d,u]),v=E.useMemo(()=>new Map(((c==null?void 0:c.roles)??[]).map(D=>[D.role,nm(D)])),[c]),_=E.useMemo(()=>x.filter(D=>!D.fromRole),[x]),S=E.useMemo(()=>new Set(((c==null?void 0:c.roles)??[]).filter(D=>o.has(D.role)&&Jj(D)).map(D=>D.role)),[c,o]),C=E.useMemo(()=>((c==null?void 0:c.roles)??[]).filter(D=>S.has(D.role)||g.some(Q=>Q.role===D.role)).map(D=>({role:D.role,title:v.get(D.role)??D.role,portals:S.has(D.role)?ta(D):[],pins:x.filter(Q=>Q.fromRole===D.role)})).filter(D=>D.portals.length>0||D.pins.length>0),[c,g,S,v,x]),B=(p==null?void 0:p.pinnedViews)??[],q=E.useRef(null),ne=D=>i.mutate({pinnedViews:D}),te=D=>ne(B.filter(Q=>Q.id!==D)),M=D=>ne([...B,{id:GT(),label:D.label,url:b.get(D.id)??D.url,badge:D.badge}]),z=D=>i.mutate({hiddenRolePins:[...(p==null?void 0:p.hiddenRolePins)??[],D]}),ae=(D,Q)=>{if(D===Q)return;const W=[...B],[he]=W.splice(D,1);W.splice(Q,0,he),ne(W)};if(x.length===0&&S.size===0)return null;const F="px-4 pt-5 pb-2 text-xs font-semibold uppercase tracking-wider text-text-tertiary truncate";return h.jsxs("div",{className:"space-y-1",children:[n&&h.jsx("div",{className:"h-px bg-surface-border mx-3 my-2",title:"Pinned"}),!n&&_.length>0&&h.jsx("p",{className:F,children:"Pinned"}),_.map(D=>{const Q=B.findIndex(W=>W.id===D.id);return h.jsx(J1,{pin:D,collapsed:n,draggable:Q!==-1,onDragStart:()=>{q.current=Q},onDropOn:()=>{q.current!==null&&Q!==-1&&ae(q.current,Q),q.current=null},onRemove:()=>te(D.id)},D.id)}),C.map(D=>h.jsxs("div",{children:[!n&&h.jsx("p",{className:F,title:`${D.title} — pins from the ${D.role} role`,"data-testid":"pin-group-label",children:D.title}),D.portals.map(Q=>h.jsx(YT,{role:D.role,portal:Q,collapsed:n},Q.key)),D.pins.map(Q=>h.jsx(J1,{pin:Q,collapsed:n,draggable:!1,onDragStart:()=>{},onDropOn:()=>{},onPromote:()=>M(Q),onHide:()=>z(Q.label)},Q.id))]},D.role))]})}function YT({role:n,portal:e,collapsed:s}){const i=Tm(n,e.key),o="flex items-center rounded-md transition-colors duration-150 text-text-secondary hover:text-text-primary hover:bg-surface-hover",c=`portal-link-${n}-${e.key}`;return s?h.jsx(Os,{to:i,className:`${o} justify-center w-10 h-10 mx-auto`,title:e.label,"data-testid":c,children:h.jsx(xd,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs(Os,{to:i,title:e.label,className:({isActive:m})=>`${o} gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] ${m?"bg-surface-hover text-text-primary font-medium":""}`,"data-testid":c,children:[h.jsx(xd,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:e.label})]})}function J1({pin:n,collapsed:e,draggable:s,onDragStart:i,onDropOn:o,onRemove:c,onPromote:m,onHide:p}){const{pathname:g,search:u}=tn(),[d,b=""]=n.url.split("?"),x=g===d&&u===(b?`?${b}`:""),v="group flex items-center rounded-md transition-colors duration-150",_=x?"bg-surface-hover text-text-primary font-medium":"text-text-secondary hover:text-text-primary hover:bg-surface-hover";return e?h.jsx(Os,{to:n.url,className:`${v} ${_} justify-center w-10 h-10 mx-auto`,title:n.label,children:h.jsx(Mg,{className:"w-5 h-5 shrink-0 text-accent/75",strokeWidth:1.5})}):h.jsxs("div",{className:`${v} ${_} relative`,draggable:s,onDragStart:i,onDragOver:S=>S.preventDefault(),onDrop:o,children:[h.jsxs(Os,{to:n.url,title:n.label,className:"flex items-center gap-2.5 pl-4 pr-3 py-1.5 text-[0.7875rem] flex-1 min-w-0",children:[h.jsx(Mg,{className:"w-4 h-4 shrink-0 text-accent/75",strokeWidth:1.5,...n.fromRole?{}:{fill:"currentColor",fillOpacity:.15}}),h.jsx("span",{className:"truncate flex-1 min-w-0",children:n.label}),n.badge&&h.jsx(KT,{url:n.url})]}),h.jsxs("span",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5 rounded px-0.5 bg-surface-hover opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity",children:[m&&h.jsx("button",{onClick:m,title:"Make mine — copy into my pins",className:"p-1 text-text-quaternary hover:text-accent transition-colors",children:h.jsx(fx,{className:"w-3 h-3"})}),p&&h.jsx("button",{onClick:p,title:"Hide this role pin",className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(TS,{className:"w-3 h-3"})}),c&&h.jsx("button",{onClick:c,title:`Remove "${n.label}"`,className:"p-1 text-text-quaternary hover:text-status-error transition-colors",children:h.jsx(en,{className:"w-3 h-3"})})]})]})}function KT({url:n}){var m;const e=E.useMemo(()=>FT(n),[n]),s={limit:1,staleTime:15e3},i=yv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&e.available}),o=pv({...(e==null?void 0:e.params)??{},...s,enabled:!!e&&!e.available});if(!e)return null;const c=e.available?i:o;return c.isError||((m=c.data)==null?void 0:m.total)===void 0?null:h.jsx("span",{className:"shrink-0 text-right text-2xs leading-none tabular-nums text-accent/80 relative -top-[0.35em]",title:`${c.data.total} matching now`,children:c.data.total})}function JT(){var c;const{data:n}=Hn(),e=(c=n==null?void 0:n.features)==null?void 0:c.graphWorkflows,s=e===!0||e!==!1&&Wx(),i=[{to:"/workflows/registry",label:"Registry",icon:Rg},{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd},{to:"/workflows/executions",label:"Executions",icon:Dg}],o=s?[{kind:"group",label:"Procedural",icon:CS,matchPaths:["/workflows/registry","/workflows/durable/invoke","/workflows/executions","/workflows/durable/executions","/workflows/start","/workflows/workers","/workflows/tasks"],items:i},{kind:"group",label:"Graph",icon:am,matchPaths:["/mcp/workflows","/mcp/executions"],items:[{to:"/mcp/workflows",label:"Configure",icon:Rg,end:!0},{to:"/mcp/workflows/invoke",label:"Invoke",icon:vd},{to:"/mcp/executions",label:"Executions",icon:Dg}]}]:i;return h.jsx(qr,{heading:"Orchestrate",entries:o})}function FM(){return Le({queryKey:["activeWorkers"],queryFn:async()=>(await ue("/workflows/workers")).workers})}function GM(){return Le({queryKey:["discoveredWorkflows"],queryFn:async()=>(await ue("/workflows/discovered")).workflows})}function VM(){return Le({queryKey:["workflowConfigs"],queryFn:async()=>(await ue("/workflows/config")).workflows})}function Hv(){return Le({queryKey:["invocableWorkflows"],queryFn:async()=>(await ue("/workflows/invocable")).workflows})}function YM(n){return Object.fromEntries(n.filter(e=>!e.missing).map(e=>[e.as??e.key,e.data]))}function KM(n,e){return Le({queryKey:["workflows",n,"input-lookups"],queryFn:()=>ue(`/workflows/${encodeURIComponent(n)}/input-lookups`),enabled:!!n&&e,staleTime:0,refetchOnWindowFocus:!1})}function JM(){return Le({queryKey:["cronStatus"],queryFn:async()=>(await ue("/workflows/cron/status")).schedules})}function QM(n){return Le({queryKey:["workflowExecution",n],queryFn:()=>ue(`/workflow-states/${n}/execution`),enabled:!!n})}function XM(n,e){const s=new URLSearchParams;return n.limit&&s.set("limit",String(n.limit)),n.offset!==void 0&&s.set("offset",String(n.offset)),n.entity&&s.set("entity",n.entity),n.search&&s.set("search",n.search),n.status&&s.set("status",n.status),n.sort_by&&s.set("sort_by",n.sort_by),n.order&&s.set("order",n.order),n.registered&&s.set("registered",n.registered),n.namespace&&s.set("namespace",n.namespace),Le({queryKey:["jobs",n],queryFn:()=>ue(`/workflow-states/jobs?${s}`),enabled:(e==null?void 0:e.enabled)??!0})}function WM(){const n=qe();return Ie({mutationFn:e=>ue(`/workflows/${e}/terminate`,{method:"POST"}),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["workflowExecution",s],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function ZM(){const n=qe();return Ie({mutationFn:({workflow_type:e,...s})=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"PUT",body:JSON.stringify(s)}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function eR(){const n=qe();return Ie({mutationFn:e=>ue(`/workflows/${encodeURIComponent(e)}/config`,{method:"DELETE"}),onSuccess:()=>{n.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function tR(){const n=qe();return Ie({mutationFn:({workflowType:e,data:s,metadata:i,execute_as:o})=>ue(`/workflows/${e}/invoke`,{method:"POST",body:JSON.stringify({data:s,metadata:i,...o?{execute_as:o}:{}})}),onSuccess:()=>{n.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),n.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function QT(){const{data:n}=Hv();return n!=null&&n.length?h.jsx(qr,{heading:"Tools",entries:[{to:"/workflows/durable/invoke",label:"Invoke Tool",icon:vd}]}):null}const XT=[{to:"/mcp/queries",label:"Designer",icon:MS},{to:"/mcp/servers",label:"Servers & Tools",icon:RS}];function WT(){return h.jsx(qr,{heading:"Design",entries:XT})}const ZT=[{to:"/files",label:"Files",icon:DS},{to:"/knowledge",label:"Knowledge Base",icon:hx}];function eC(){return h.jsx(qr,{heading:"Storage",entries:ZT})}function tC({isBuilder:n=!1,isOps:e=!1}){var m;const{data:s}=Hn(),i=((m=s==null?void 0:s.features)==null?void 0:m.dbMaintenance)!==!1,o=[{to:"/admin/users",label:"Accounts",icon:LS},...n||e?[{to:"/admin/roles",label:"Roles",icon:bd},{to:"/admin/personas",label:"Personas",icon:qS},{to:"/admin/scan-codes",label:"Scan Codes",icon:Mo}]:[]],c=[{to:"/admin/controlplane",label:"Routers",icon:PS},{to:"/admin/streams",label:"Messages",icon:hx},...i?[{to:"/admin/maintenance",label:"DB Maintenance",icon:BS}]:[]];return h.jsxs(h.Fragment,{children:[h.jsx(qr,{heading:"Identity & Access",entries:o}),n&&Zx()&&h.jsx(qr,{heading:"Infrastructure",entries:c})]})}function Fv({aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o,showLines:c}){return h.jsxs(h.Fragment,{children:[h.jsx(DT,{aiEnabled:n,isBuilder:e,isOps:s,viewAs:i,canSeePaceBoard:o,showLines:c}),h.jsx(VT,{}),!e&&h.jsx(QT,{}),e&&h.jsx(JT,{}),e&&n&&h.jsx(WT,{}),e&&h.jsx(eC,{}),(e||s)&&h.jsx(tC,{isBuilder:e,isOps:s})]})}function nC({open:n,onClose:e,...s}){const i=tn();return E.useEffect(()=>{e()},[i.pathname]),h.jsxs("div",{className:`lg:hidden fixed inset-y-0 left-0 z-40 flex ${n?"":"pointer-events-none"}`,children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${n?"opacity-100":"opacity-0"}`,onClick:e,"aria-hidden":!0}),h.jsxs("div",{className:`relative w-72 max-w-[85vw] h-full bg-surface-raised border-r border-surface-border shadow-xl flex flex-col transition-transform duration-200 ease-out ${n?"translate-x-0":"-translate-x-full"}`,children:[h.jsx("div",{className:"flex items-center justify-end px-3 pt-3 shrink-0",children:h.jsx("button",{onClick:e,className:"p-1.5 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-hover transition-colors","aria-label":"Close navigation",children:h.jsx(en,{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(tk,{children:h.jsx(Fv,{...s})})})]})]})}const Gv="lt_event_feed_patterns";function rC(n,e){if(n.startsWith("/topics/")){const m=decodeURIComponent(n.replace("/topics/",""));if(m&&!m.includes("/"))return`lt.events.${m}`}const s=n.match(/^\/escalations\/detail\/(.+)/);if(s)return`lt.events.system.escalation.*.${s[1]}.>`;if(n.startsWith("/escalations")){const m=new URLSearchParams(e).get("role");return m?`lt.events.system.escalation.${rv(m)}.>`:"lt.events.system.escalation.>"}const i=n.match(/^\/workflows\/(?:durable\/)?executions\/(.+)/);if(i)return`lt.events.system.workflow.${i[1]}.>`;if(n.startsWith("/workflows"))return"lt.events.system.workflow.>";const o=n.match(/^\/agents\/([^/]+)$/);if(o&&o[1]!=="new")return`lt.events.system.agent.${o[1]}.>`;if(n.startsWith("/agents"))return"lt.events.system.agent.>";if(n.startsWith("/knowledge"))return"lt.events.system.knowledge.>";if(n.startsWith("/files"))return"lt.events.system.file.>";if(n==="/")return"lt.events.system.>";const c=n.match(/^\/mcp\/executions\/(.+)/);return c?`lt.events.system.*.${c[1]}.>`:(n.startsWith("/mcp"),"lt.events.system.>")}function sC(){try{const n=localStorage.getItem(Gv);return n?JSON.parse(n):[]}catch{return[]}}function md(n){try{localStorage.setItem(Gv,JSON.stringify(n))}catch{}}function iC(){const{pathname:n,search:e}=tn(),[s,i]=E.useState(sC),o=E.useMemo(()=>rC(n,e),[n,e]),c=E.useMemo(()=>{const u=new Set([o,...s]);return Array.from(u)},[o,s]),m=E.useCallback(u=>{const d=u.startsWith("lt.events.")?u:`lt.events.${u}`;i(b=>{if(b.includes(d))return b;const x=[...b,d];return md(x),x})},[]),p=E.useCallback(u=>{i(d=>{const b=d.filter(x=>x!==u);return md(b),b})},[]),g=E.useCallback(()=>{i([]),md([])},[]);return{patterns:c,pagePattern:o,userPatterns:s,addPattern:m,removePattern:p,clearUserPatterns:g}}function aC({children:n,className:e=""}){return h.jsx("p",{className:`text-2xs font-semibold uppercase tracking-widest text-text-tertiary ${e}`,children:n})}const pd=280,Q1="cubic-bezier(0.4, 0, 0.2, 1)",Wc=40;function oC(n){if(!n)return"scale(0.92)";const e=window.innerWidth,s=window.innerHeight,i=e-Wc*2,o=s-Wc*2,c=n.width/i,m=n.height/o,p=n.left+n.width/2-(Wc+i/2),g=n.top+n.height/2-(Wc+o/2);return`translate(${p}px, ${g}px) scale(${c}, ${m})`}function Vv({open:n,onClose:e,sourceRef:s,children:i}){const[o,c]=E.useState(null),m=E.useRef(null),p=E.useRef(!1);E.useEffect(()=>{var x,v;n&&!p.current?(m.current=((x=s==null?void 0:s.current)==null?void 0:x.getBoundingClientRect())??null,c("entering")):!n&&p.current&&o==="open"&&(m.current=((v=s==null?void 0:s.current)==null?void 0:v.getBoundingClientRect())??null,c("exiting")),p.current=n},[n,s,o]),E.useEffect(()=>{if(o!=="entering")return;const x=requestAnimationFrame(()=>{requestAnimationFrame(()=>c("open"))});return()=>cancelAnimationFrame(x)},[o]),E.useEffect(()=>{if(o)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o]),E.useEffect(()=>{if(!o)return;const x=v=>{v.key==="Escape"&&e()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[o,e]);const g=E.useCallback(x=>{x.propertyName==="transform"&&o==="exiting"&&c(null)},[o]);if(E.useEffect(()=>{if(o!=="exiting")return;const x=setTimeout(()=>c(null),pd+50);return()=>clearTimeout(x)},[o]),!o)return null;const u=o==="entering"||o==="exiting",d=u?oC(m.current):"none",b=u?0:1;return sm.createPortal(h.jsx("div",{className:"fixed inset-0 z-50 overflow-auto p-10",style:{transformOrigin:"center center",transition:`transform ${pd}ms ${Q1}, opacity ${pd}ms ${Q1}`,transform:d,opacity:b,backgroundColor:"rgb(var(--lt-surface))"},onTransitionEnd:g,children:i}),document.body)}function lC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h8M4 18h12"})})}function cC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7l-5 5 5 5M16 7l5 5-5 5"})})}function uC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"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 fC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}function hC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"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 dC({className:n}){return h.jsx("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}function mC(n){const e=n.trim().split(`
57
57
  `);if(e.length<2)return n;const s=p=>p.split("|").map(g=>g.trim()).filter(Boolean),i=s(e[0]),o=e.slice(2),c=i.map(p=>`<th class="px-3 py-1.5 text-left text-2xs font-semibold uppercase tracking-wider text-text-tertiary">${p}</th>`).join(""),m=o.map(p=>`<tr class="border-t border-surface-border">${s(p).map(d=>`<td class="px-3 py-1.5 text-xs text-text-secondary">${d}</td>`).join("")}</tr>`).join("");return`<table class="w-full my-3 text-xs"><thead><tr class="border-b border-surface-border">${c}</tr></thead><tbody>${m}</tbody></table>`}function Zc(n){return n.toLowerCase().replace(/<[^>]+>/g,"").replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").trim()}function pC(n){const e=[];let s=n.replace(/```(\w*)\n([\s\S]*?)```/g,(g,u,d)=>{const b=e.length;return e.push(`<pre class="bg-surface-sunken rounded p-3 my-2 overflow-x-auto text-2xs leading-relaxed"><code>${d}</code></pre>`),`\0CODE${b}\0`});const i=/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm;s=s.replace(i,(g,u,d,b)=>mC(`${u}
58
58
  ${d}
59
- ${b.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-2xs">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,u)=>`<h4 id="${Zc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Zc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Zc(u)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${u}</h2>`).replace(/^# (.+)$/gm,(g,u)=>`<h1 id="${Zc(u)}" class="text-lg font-bold text-text-primary mb-3">${u}</h1>`),s=s.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(#([^)]+)\)/g,'<a data-anchor="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]*\.md(?:#[^)]*)?)\)/g,'<a data-doc-link="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent hover:underline">$1</a>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^- (.+)$/gm,'<li class="ml-4 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^---+$/gm,'<hr class="border-surface-border my-4" />').replace(/(?:^> (.+)$\n?)+/gm,g=>{const u=g.replace(/^> /gm,"").trim(),d=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${d?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${d?"border-status-warning":b?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${u}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(c('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,u)=>e[parseInt(u,10)]);const m="text-xs leading-relaxed text-text-secondary mb-2",p=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const u=g.trim();if(!u)return"";const d=[];let b=u,x;for(;(x=p.exec(b))!==null;){const v=x.index+x[0].length;d.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),p.lastIndex=0}return b&&d.push(b),d.map(v=>{const _=v.trim();return _?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(_)?_:`<p class="${m}">${_}</p>`:""}).join("")}).join(""),s}const yC=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function gC(n){return yC.test(n)}function Pu({content:n,className:e,onClick:s}){const i=E.useMemo(()=>pC(n),[n]);return h.jsx("div",{className:e,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function Su({data:n,depth:e=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:e>0,[c,m]=E.useState(o),[p,g]=E.useState(s);if(s!==void 0&&s!==p&&(g(s),m(s%2===0&&e>0)),n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',n,'"']});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:n.map((u,d)=>h.jsxs("div",{children:[h.jsx(Su,{data:u,depth:e+1,generation:s}),d<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof n=="object"){const u=Object.entries(n);return u.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:u.map(([d,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:d}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(Su,{data:b,depth:e+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function Eo({data:n,depth:e=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&gC(n)?h.jsx(Pu,{content:n}):h.jsx("span",{className:"text-text-primary",children:n});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:n.map((s,i)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[i+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(Eo,{data:s,depth:e+1})})]},i))});if(typeof n=="object"){const s=Object.entries(n);return s.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):h.jsx("div",{className:e>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([i,o])=>{const c=o===null||typeof o!="object";return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:i.replace(/[_-]/g," ")}),c?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(Eo,{data:o,depth:e+1})}):h.jsx(Eo,{data:o,depth:e+1})]},i)})})}return h.jsx("span",{children:String(n)})}function X1({mode:n,setMode:e,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:m,onClose:p,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",d=`${g?"p-2":"p-1.5"} rounded text-accent/60 hover:text-accent hover:bg-surface-raised transition-colors duration-150`;return h.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[n==="json"&&h.jsx("button",{onClick:i,className:d,title:s?"Expand all":"Collapse all",children:s?h.jsx(dC,{className:u}):h.jsx(hC,{className:u})}),h.jsx("button",{onClick:()=>e(n==="json"?"tree":"json"),className:d,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(lC,{className:u}):h.jsx(cC,{className:u})}),h.jsx("button",{onClick:o,className:d,title:"Copy to clipboard",children:c?h.jsx(fC,{className:`${u} text-status-success`}):h.jsx(uC,{className:u})}),m&&h.jsx("button",{onClick:m,className:d,title:"Fullscreen",children:h.jsx(dx,{className:u})}),p&&h.jsx("button",{onClick:p,className:d,title:"Close (Esc)",children:h.jsx(mx,{className:u})})]})}function bC({data:n,label:e,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[m,p]=E.useState(o??"json"),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[_,S]=E.useState(1),C=x%2===0,B=_%2===0,q=E.useCallback(()=>v(D=>D+1),[]),ne=E.useCallback(()=>S(D=>D+1),[]);let te=n;if(typeof n=="string")try{te=JSON.parse(n)}catch{}const M=async()=>{const D=typeof n=="string"?n:JSON.stringify(te,null,2);await navigator.clipboard.writeText(D),u(!0),setTimeout(()=>u(!1),2e3)},z=E.useCallback(()=>{S(1),b(!0)},[]),ae=s==="panel",F=ae?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",U=ae?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken border border-surface-border rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:F,children:[e&&h.jsx(aC,{children:e}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:C,onToggleCollapse:q,onCopy:M,copied:g,onFullscreen:z})}),h.jsx("div",{className:U,children:m==="json"?h.jsx(Su,{data:te,generation:x}):h.jsx(Eo,{data:te})})]}),h.jsxs(Vv,{open:d,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:B,onToggleCollapse:ne,onCopy:M,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:m==="json"?h.jsx(Su,{data:te,generation:_}):h.jsx(Eo,{data:te})})]})]})}const xC=100,W1=500;let vC=0;const Yv={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function Kv(n){const e=n.split(".");return e[0]==="system"&&e.length>=3?`${e[1]}.${e[e.length-1]}`:n}function Z1({event:n,forceExpanded:e=!1}){var x,v;const[s,i]=E.useState(e),o=Yv[Kv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(e)},[e]);const c=e,m=c?"text-xs":"text-2xs",p=c?"text-xs":"text-2xs",g=c?"text-xs":"text-2xs",u=c?"w-3.5 h-3.5":"w-2.5 h-2.5",d=c?"py-2 px-4":"py-1 px-3",b=c?"pb-4 px-4":"pb-2 px-3";return h.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[h.jsxs("button",{onClick:()=>i(!s),className:`flex items-center gap-2 ${d} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${m} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${p} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:n.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(x=n.data)!=null&&x.workflowId?String(n.data.workflowId):"",(v=n.data)!=null&&v.escalationId?` esc:${String(n.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${u} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),h.jsx(Gm,{open:s,children:h.jsx("div",{className:b,children:h.jsx(bC,{data:n.data})})})]})}function _C({open:n,onToggle:e,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[m,p]=E.useState(!1),[g,u]=E.useState(""),d=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(oa),{connected:v}=qx(),{patterns:_,pagePattern:S,userPatterns:C,addPattern:B,removePattern:q}=iC(),ne=E.useCallback(z=>{const ae=String(z.type||"unknown");if(ae.startsWith("mesh."))return;const F=`${ae}:${z.timestamp||""}:${z.escalationId||z.workflowId||z.taskId||""}`,U=Date.now(),D=b.current.get(F);if(!(D&&U-D<W1)){if(b.current.set(F,U),b.current.size>200)for(const[X,W]of b.current)U-W>W1*2&&b.current.delete(X);c(X=>[{id:++vC,type:ae,timestamp:z.timestamp||new Date().toISOString(),data:z},...X].slice(0,xC))}},[]),te=E.useRef(ne);te.current=ne;const M=n||m||s;return E.useEffect(()=>{if(!M)return;const z=_.map(ae=>x(ae,F=>te.current(F)));return()=>z.forEach(ae=>ae())},[x,_.join(","),M]),E.useEffect(()=>{n&&d.current&&(d.current.scrollTop=0)},[o.length,n]),h.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[h.jsxs("button",{onClick:e,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[n?h.jsx(im,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(px,{className:"w-3 h-3 text-text-tertiary"}),h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&h.jsxs("span",{className:"text-2xs text-text-tertiary",children:[o.length," events"]}),o.length>0&&!n&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Yv[Kv(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx("span",{className:`p-0.5 ${v?"text-status-success":"text-status-warning hover:text-text-primary cursor-pointer"}`,title:v?"Live events connected":"Events disconnected — click to reconnect",onClick:z=>{z.stopPropagation(),v||window.location.reload()},children:h.jsx(ux,{className:"w-3 h-3"})}),h.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:z=>{z.stopPropagation(),i()},children:h.jsx(US,{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:z=>{z.stopPropagation(),p(!0)},children:h.jsx(dx,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:z=>{z.stopPropagation(),c([])},children:h.jsx(zS,{className:"w-3 h-3"})})]})]})]}),s&&h.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[h.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),h.jsx("span",{className:"text-2xs font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:S.replace("lt.events.","")}),C.map(z=>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:[z.replace("lt.events.",""),h.jsx("button",{onClick:()=>q(z),className:"text-text-quaternary hover:text-status-error",children:h.jsx(Zt,{className:"w-2 h-2"})})]},z))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:z=>u(z.target.value),onKeyDown:z=>{z.key==="Enter"&&g.trim()&&(B(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(B(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(fx,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Gm,{open:n,children:h.jsx("div",{ref:d,className:"h-48 overflow-y-auto",children:o.length===0?h.jsx("p",{className:"text-2xs text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map(z=>h.jsx(Z1,{event:z},z.id))})}),h.jsxs(Vv,{open:m,onClose:()=>p(!1),sourceRef:d,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>p(!1),className:"p-2 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150 bg-surface-sunken/80 backdrop-blur-sm",title:"Close (Esc)",children:h.jsx(mx,{className:"w-5 h-5"})})}),o.length===0?h.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map(z=>h.jsx(Z1,{event:z,forceExpanded:!0},z.id))]})]})}function wC(){return qe({queryKey:["docs"],queryFn:()=>ue("/docs"),staleTime:5*6e4})}function SC(n){return qe({queryKey:["docs",n],queryFn:()=>ue(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function EC(){const[n,e]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),m=E.useRef(o),p=E.useRef(n),g=E.useRef(s);m.current=o,p.current=n,g.current=s;const u=E.useCallback((_,S)=>{var B;const C=m.current;if(C){const q=((B=S==null?void 0:S.current)==null?void 0:B.scrollTop)??0;e([...p.current,{...C,scrollTop:q}])}i([]),c({path:_,scrollTop:0})},[]),d=E.useCallback(_=>{var q;const S=p.current;if(S.length===0)return;const C=S[S.length-1],B=m.current;if(B){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;i([...g.current,{...B,scrollTop:ne}])}e(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(_=>{var q;const S=g.current;if(S.length===0)return;const C=S[S.length-1],B=m.current;if(B){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;e([...p.current,{...B,scrollTop:ne}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(_=>{var B,q;const S=m.current;if(!S)return;const C=((B=_==null?void 0:_.current)==null?void 0:B.scrollTop)??0;e([...p.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0})},[]),v=E.useCallback(()=>{e([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:d,goForward:b,pushScrollPosition:x,reset:v}}function OC(n,e){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const m=((e?e.replace(/[^/]+$/,""):"")+o).split("/"),p=[];for(const g of m)g===".."?p.pop():g&&g!=="."&&p.push(g);o=p.join("/")}return{path:o,anchor:i}}function AC(n){if(!n.startsWith("#docs"))return null;const e=n.slice(1).split(":"),s=e[1]||"README.md",i=e[2]||void 0;return{path:s,anchor:i}}function jC(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function kC({content:n,currentPath:e,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const m=c.target,p=m.closest("[data-anchor]");if(p){c.preventDefault(),i();const d=p.dataset.anchor,b=(u=p.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(d)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=m.closest("[data-doc-link]");if(g){c.preventDefault();const{path:d,anchor:b}=OC(g.dataset.docLink,e);s(d,b);return}};return h.jsx(Pu,{content:n,className:"docs-content",onClick:o})}function NC(n){const e=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){e.push(i);continue}let c=s;for(let m=0;m<o.length-1;m++){const p=o[m];c.has(p)||c.set(p,{label:p,children:[],subdirs:new Map});const g=c.get(p);m===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:e,dirs:s}}function TC({docs:n,selected:e,onSelect:s}){const{topLevel:i,dirs:o}=NC(n),c=p=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${e===p?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function m(p,g){return h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[h.jsx(IS,{className:"w-3 h-3",strokeWidth:1.5}),p.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...p.subdirs.values()].map(u=>m(u)),p.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},p.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(p=>h.jsx("button",{className:c(p.path),onClick:()=>s(p.path),children:p.title},p.path)),[...o.values()].map(p=>m(p))]})}function CC({open:n,onClose:e}){var ae,F,U;const[s,i]=E.useState(!1),{data:o}=wC(),c=EC(),{data:m,isLoading:p}=SC(((ae=c.current)==null?void 0:ae.path)??null),g=E.useRef(null),[u,d]=E.useState(null);E.useEffect(()=>{u&&(m!=null&&m.content)&&g.current&&requestAnimationFrame(()=>{var X;const D=(X=g.current)==null?void 0:X.querySelector(`#${CSS.escape(u)}`);D==null||D.scrollIntoView({behavior:"smooth",block:"start"}),d(null)})},[u,m]);const b=E.useCallback(()=>{var W;const D=AC(window.location.hash),X=(D==null?void 0:D.path)??"README.md";((W=c.current)==null?void 0:W.path)!==X&&c.navigate(X,g),D!=null&&D.anchor&&d(D.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const D=jC(c.current.path);window.location.hash!==D&&window.history.replaceState(null,"",window.location.pathname+window.location.search+D)},[n,(F=c.current)==null?void 0:F.path]),E.useEffect(()=>{if(!n)return;const D=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[n,b]);const v=E.useCallback((D,X)=>{X&&d(X),c.navigate(D,g)},[c]),_=E.useCallback(D=>{c.navigate(D,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),B=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const D=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(D)}},[n]),!(n||s))return null;const ne=()=>{i(!1),setTimeout(()=>{e(),c.reset()},200)},te=((U=c.current)==null?void 0:U.path)??null,M=c.backStack.length>0,z=c.forwardStack.length>0;return h.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&n?"opacity-100":"opacity-0"}`,onClick:ne}),h.jsxs("div",{className:`relative ml-auto w-[40vw] min-w-[800px] max-w-[90vw] h-full bg-surface-raised border-l border-surface-border flex flex-col shadow-xl transition-transform duration-200 ease-out ${s&&n?"translate-x-0":"translate-x-full"}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:S,disabled:!M,className:`p-0.5 transition-colors ${M?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(cx,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!z,className:`p-0.5 transition-colors ${z?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(gd,{className:"w-4 h-4"})}),h.jsx($S,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),h.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),h.jsx("button",{onClick:ne,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(Zt,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[h.jsx("div",{className:"w-48 shrink-0 border-r border-surface-border overflow-y-auto py-2",children:o!=null&&o.docs?h.jsx(TC,{docs:o.docs,selected:te,onSelect:_}):h.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),h.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:te?p?h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):m!=null&&m.content?h.jsx(kC,{content:m.content,currentPath:te,onNavigate:v,onAnchorClick:B}):h.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[h.jsx(gd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function MC(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const ex=2e3;function RC(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
59
+ ${b.trimEnd()}`)),s=s.replace(/`([^`]+)`/g,'<code class="bg-surface-sunken px-1 py-0.5 rounded text-2xs">$1</code>'),s=s.replace(/^#### (.+)$/gm,(g,u)=>`<h4 id="${Zc(u)}" class="text-xs font-semibold text-text-primary mt-4 mb-1">${u}</h4>`).replace(/^### (.+)$/gm,(g,u)=>`<h3 id="${Zc(u)}" class="text-sm font-semibold text-text-primary mt-5 mb-1.5">${u}</h3>`).replace(/^## (.+)$/gm,(g,u)=>`<h2 id="${Zc(u)}" class="text-base font-semibold text-text-primary mt-6 mb-2 pb-1 border-b border-surface-border">${u}</h2>`).replace(/^# (.+)$/gm,(g,u)=>`<h1 id="${Zc(u)}" class="text-lg font-bold text-text-primary mb-3">${u}</h1>`),s=s.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(#([^)]+)\)/g,'<a data-anchor="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]*\.md(?:#[^)]*)?)\)/g,'<a data-doc-link="$2" class="text-accent hover:underline cursor-pointer">$1</a>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent hover:underline">$1</a>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^ - (.+)$/gm,'<li class="ml-8 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^- (.+)$/gm,'<li class="ml-4 list-disc text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal text-xs -my-1" style="line-height:1.1">$1</li>').replace(/^---+$/gm,'<hr class="border-surface-border my-4" />').replace(/(?:^> (.+)$\n?)+/gm,g=>{const u=g.replace(/^> /gm,"").trim(),d=/⚠️|warning|caution/i.test(u),b=/note:|ℹ️|info/i.test(u);return`<div class="${d?"bg-status-warning/5":b?"bg-accent/5":"bg-surface-sunken/50"} ${d?"border-status-warning":b?"border-accent":"border-text-tertiary"} border-l-2 rounded-r-md px-3 py-2 my-3 text-xs text-text-secondary leading-relaxed">${u}</div>`}).replace(/\n\n/g,"\0PARA\0").replace(/\n/g,"<br/>");const o=g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=g=>new RegExp(`(${o(g)}[\\s\\S]*?<\\/li>(?:<br\\/>)?)+`,"g");s=s.replace(c('<li class="ml-8 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-disc'),g=>`<ul class="mb-3">${g}</ul>`),s=s.replace(c('<li class="ml-4 list-decimal'),g=>`<ol class="list-decimal mb-3">${g}</ol>`),s=s.replace(/\x00CODE(\d+)\x00/g,(g,u)=>e[parseInt(u,10)]);const m="text-xs leading-relaxed text-text-secondary mb-2",p=/<\/(h[1-4]|pre|table|ul|ol|hr|div)>/;return s=s.split("\0PARA\0").map(g=>{const u=g.trim();if(!u)return"";const d=[];let b=u,x;for(;(x=p.exec(b))!==null;){const v=x.index+x[0].length;d.push(b.slice(0,v)),b=b.slice(v).replace(/^<br\/>/,"").trim(),p.lastIndex=0}return b&&d.push(b),d.map(v=>{const _=v.trim();return _?/^\s*<(h[1-4]|pre|table|ul|ol|hr|div)/.test(_)?_:`<p class="${m}">${_}</p>`:""}).join("")}).join(""),s}const yC=/(\*\*|^#{1,4}\s|^- |^\d+\.\s|```|^\|.*\|$|\[.+\]\(.+\))/m;function gC(n){return yC.test(n)}function Pu({content:n,className:e,onClick:s}){const i=E.useMemo(()=>pC(n),[n]);return h.jsx("div",{className:e,onClick:s,dangerouslySetInnerHTML:{__html:i}})}function Su({data:n,depth:e=0,generation:s}){const o=s!==void 0&&s>0&&s%2===1?!1:e>0,[c,m]=E.useState(o),[p,g]=E.useState(s);if(s!==void 0&&s!==p&&(g(s),m(s%2===0&&e>0)),n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return h.jsxs("span",{className:"text-text-primary",children:['"',n,'"']});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary",children:"[]"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["[",n.length," items]"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"["}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:n.map((u,d)=>h.jsxs("div",{children:[h.jsx(Su,{data:u,depth:e+1,generation:s}),d<n.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"]"})]});if(typeof n=="object"){const u=Object.entries(n);return u.length===0?h.jsx("span",{className:"text-text-tertiary",children:"{}"}):c?h.jsxs("button",{onClick:()=>m(!1),className:"text-text-secondary hover:text-text-primary",children:["{","...","}"]}):h.jsxs("span",{children:[h.jsx("button",{onClick:()=>m(!0),className:"text-text-tertiary hover:text-text-primary",children:"{"}),h.jsx("div",{className:"pl-4 border-l border-surface-border ml-1",children:u.map(([d,b],x)=>h.jsxs("div",{children:[h.jsx("span",{className:"text-text-secondary",children:d}),h.jsx("span",{className:"text-text-tertiary",children:": "}),h.jsx(Su,{data:b,depth:e+1,generation:s}),x<u.length-1&&h.jsx("span",{className:"text-text-tertiary",children:","})]},d))}),h.jsx("span",{className:"text-text-tertiary",children:"}"})]})}return h.jsx("span",{children:String(n)})}function Oo({data:n,depth:e=0}){if(n==null)return h.jsx("span",{className:"text-text-tertiary italic",children:"null"});if(typeof n=="string")return n.length>40&&gC(n)?h.jsx(Pu,{content:n}):h.jsx("span",{className:"text-text-primary",children:n});if(typeof n=="number"||typeof n=="boolean")return h.jsx("span",{className:"text-text-primary font-medium",children:String(n)});if(Array.isArray(n))return n.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty list"}):h.jsx("div",{className:"space-y-2",children:n.map((s,i)=>h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsxs("span",{className:"text-text-tertiary text-2xs shrink-0",children:[i+1,"."]}),h.jsx("div",{className:"flex-1",children:h.jsx(Oo,{data:s,depth:e+1})})]},i))});if(typeof n=="object"){const s=Object.entries(n);return s.length===0?h.jsx("span",{className:"text-text-tertiary italic",children:"empty"}):h.jsx("div",{className:e>0?"pl-4 border-l border-surface-border space-y-3":"space-y-3",children:s.map(([i,o])=>{const c=o===null||typeof o!="object";return h.jsxs("div",{children:[h.jsx("p",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:i.replace(/[_-]/g," ")}),c?h.jsx("p",{className:"text-sm text-text-primary",children:h.jsx(Oo,{data:o,depth:e+1})}):h.jsx(Oo,{data:o,depth:e+1})]},i)})})}return h.jsx("span",{children:String(n)})}function X1({mode:n,setMode:e,isCollapsed:s,onToggleCollapse:i,onCopy:o,copied:c,onFullscreen:m,onClose:p,large:g}){const u=g?"w-5 h-5":"w-3.5 h-3.5",d=`${g?"p-2":"p-1.5"} rounded text-accent/60 hover:text-accent hover:bg-surface-raised transition-colors duration-150`;return h.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[n==="json"&&h.jsx("button",{onClick:i,className:d,title:s?"Expand all":"Collapse all",children:s?h.jsx(dC,{className:u}):h.jsx(hC,{className:u})}),h.jsx("button",{onClick:()=>e(n==="json"?"tree":"json"),className:d,title:n==="json"?"Outline view":"JSON view",children:n==="json"?h.jsx(lC,{className:u}):h.jsx(cC,{className:u})}),h.jsx("button",{onClick:o,className:d,title:"Copy to clipboard",children:c?h.jsx(fC,{className:`${u} text-status-success`}):h.jsx(uC,{className:u})}),m&&h.jsx("button",{onClick:m,className:d,title:"Fullscreen",children:h.jsx(dx,{className:u})}),p&&h.jsx("button",{onClick:p,className:d,title:"Close (Esc)",children:h.jsx(mx,{className:u})})]})}function bC({data:n,label:e,variant:s,defaultCollapsed:i=!1,defaultMode:o}){const c=E.useRef(null),[m,p]=E.useState(o??"json"),[g,u]=E.useState(!1),[d,b]=E.useState(!1),[x,v]=E.useState(i?0:1),[_,S]=E.useState(1),C=x%2===0,B=_%2===0,q=E.useCallback(()=>v(D=>D+1),[]),ne=E.useCallback(()=>S(D=>D+1),[]);let te=n;if(typeof n=="string")try{te=JSON.parse(n)}catch{}const M=async()=>{const D=typeof n=="string"?n:JSON.stringify(te,null,2);await navigator.clipboard.writeText(D),u(!0),setTimeout(()=>u(!1),2e3)},z=E.useCallback(()=>{S(1),b(!0)},[]),ae=s==="panel",F=ae?"border border-accent-muted/40 rounded-lg p-3 bg-surface-hover/30":"",U=ae?"font-mono text-xs leading-relaxed bg-surface-raised rounded-md p-4 overflow-x-auto break-all":"font-mono text-xs leading-relaxed bg-surface-sunken border border-surface-border rounded-md p-4 overflow-x-auto break-all";return h.jsxs("div",{className:F,children:[e&&h.jsx(aC,{children:e}),h.jsxs("div",{ref:c,className:"relative",children:[h.jsx("div",{className:"absolute top-2 right-2 z-[5]",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:C,onToggleCollapse:q,onCopy:M,copied:g,onFullscreen:z})}),h.jsx("div",{className:U,children:m==="json"?h.jsx(Su,{data:te,generation:x}):h.jsx(Oo,{data:te})})]}),h.jsxs(Vv,{open:d,onClose:()=>b(!1),sourceRef:c,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx(X1,{mode:m,setMode:p,isCollapsed:B,onToggleCollapse:ne,onCopy:M,copied:g,onClose:()=>b(!1),large:!0})}),h.jsx("div",{className:"font-mono text-sm leading-relaxed",children:m==="json"?h.jsx(Su,{data:te,generation:_}):h.jsx(Oo,{data:te})})]})]})}const xC=100,W1=500;let vC=0;const Yv={"escalation.created":"text-status-active","escalation.claimed":"text-status-warning","escalation.released":"text-text-tertiary","escalation.resolved":"text-status-success","task.created":"text-accent","task.completed":"text-status-success","task.failed":"text-status-error","task.escalated":"text-status-warning","workflow.started":"text-accent","workflow.completed":"text-status-success","workflow.failed":"text-status-error","activity.started":"text-status-active","activity.completed":"text-status-success","activity.failed":"text-status-error","knowledge.stored":"text-accent","knowledge.deleted":"text-text-tertiary","agent.started":"text-accent","agent.completed":"text-status-success","agent.failed":"text-status-error","agent.status_changed":"text-status-active",milestone:"text-accent"};function Kv(n){const e=n.split(".");return e[0]==="system"&&e.length>=3?`${e[1]}.${e[e.length-1]}`:n}function Z1({event:n,forceExpanded:e=!1}){var x,v;const[s,i]=E.useState(e),o=Yv[Kv(n.type)]||"text-text-tertiary";E.useEffect(()=>{i(e)},[e]);const c=e,m=c?"text-xs":"text-2xs",p=c?"text-xs":"text-2xs",g=c?"text-xs":"text-2xs",u=c?"w-3.5 h-3.5":"w-2.5 h-2.5",d=c?"py-2 px-4":"py-1 px-3",b=c?"pb-4 px-4":"pb-2 px-3";return h.jsxs("div",{className:"border-b border-surface-border/30 last:border-b-0",children:[h.jsxs("button",{onClick:()=>i(!s),className:`flex items-center gap-2 ${d} w-full text-left hover:bg-surface-hover/50 transition-colors`,children:[h.jsx("span",{className:`${m} font-mono text-text-tertiary whitespace-nowrap tabular-nums shrink-0`,children:new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),h.jsx("span",{className:`${p} font-medium px-1 py-0.5 rounded ${o} bg-surface-sunken whitespace-nowrap shrink-0`,children:n.type}),h.jsxs("span",{className:`${g} text-text-tertiary font-mono flex-1 min-w-0 truncate`,children:[(x=n.data)!=null&&x.workflowId?String(n.data.workflowId):"",(v=n.data)!=null&&v.escalationId?` esc:${String(n.data.escalationId).slice(0,12)}`:""]}),h.jsx("svg",{className:`${u} text-text-tertiary shrink-0 transition-transform duration-150 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),h.jsx(Gm,{open:s,children:h.jsx("div",{className:b,children:h.jsx(bC,{data:n.data})})})]})}function _C({open:n,onToggle:e,configOpen:s,onToggleConfig:i}){const[o,c]=E.useState([]),[m,p]=E.useState(!1),[g,u]=E.useState(""),d=E.useRef(null),b=E.useRef(new Map),{subscribe:x}=E.useContext(la),{connected:v}=qx(),{patterns:_,pagePattern:S,userPatterns:C,addPattern:B,removePattern:q}=iC(),ne=E.useCallback(z=>{const ae=String(z.type||"unknown");if(ae.startsWith("mesh."))return;const F=`${ae}:${z.timestamp||""}:${z.escalationId||z.workflowId||z.taskId||""}`,U=Date.now(),D=b.current.get(F);if(!(D&&U-D<W1)){if(b.current.set(F,U),b.current.size>200)for(const[Q,W]of b.current)U-W>W1*2&&b.current.delete(Q);c(Q=>[{id:++vC,type:ae,timestamp:z.timestamp||new Date().toISOString(),data:z},...Q].slice(0,xC))}},[]),te=E.useRef(ne);te.current=ne;const M=n||m||s;return E.useEffect(()=>{if(!M)return;const z=_.map(ae=>x(ae,F=>te.current(F)));return()=>z.forEach(ae=>ae())},[x,_.join(","),M]),E.useEffect(()=>{n&&d.current&&(d.current.scrollTop=0)},[o.length,n]),h.jsxs("div",{className:"shrink-0 border-t border-surface-border bg-surface-raised",children:[h.jsxs("button",{onClick:e,className:"flex items-center gap-2 w-full px-4 py-1.5 text-left hover:bg-surface-hover transition-colors",children:[n?h.jsx(im,{className:"w-3 h-3 text-text-tertiary"}):h.jsx(px,{className:"w-3 h-3 text-text-tertiary"}),h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-text-tertiary",children:"Event Stream"}),o.length>0&&h.jsxs("span",{className:"text-2xs text-text-tertiary",children:[o.length," events"]}),o.length>0&&!n&&h.jsx("span",{className:`text-2xs font-medium px-1 py-0.5 rounded ${Yv[Kv(o[0].type)]||"text-text-tertiary"} bg-surface-sunken`,children:o[0].type}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx("span",{className:`p-0.5 ${v?"text-status-success":"text-status-warning hover:text-text-primary cursor-pointer"}`,title:v?"Live events connected":"Events disconnected — click to reconnect",onClick:z=>{z.stopPropagation(),v||window.location.reload()},children:h.jsx(ux,{className:"w-3 h-3"})}),h.jsx("span",{className:`p-0.5 cursor-pointer ${s?"text-accent":"text-text-tertiary hover:text-text-primary"}`,title:"Subscription config",onClick:z=>{z.stopPropagation(),i()},children:h.jsx(US,{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:z=>{z.stopPropagation(),p(!0)},children:h.jsx(dx,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-text-tertiary hover:text-text-primary p-0.5 cursor-pointer",title:"Clear events",onClick:z=>{z.stopPropagation(),c([])},children:h.jsx(zS,{className:"w-3 h-3"})})]})]})]}),s&&h.jsxs("div",{className:"px-4 py-2 border-t border-surface-border/50 bg-surface-sunken/30",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[h.jsx("span",{className:"text-2xs text-text-quaternary uppercase tracking-wider shrink-0",children:"Subscribed:"}),h.jsx("span",{className:"text-2xs font-mono text-accent px-1.5 py-0.5 bg-accent/10 rounded",children:S.replace("lt.events.","")}),C.map(z=>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:[z.replace("lt.events.",""),h.jsx("button",{onClick:()=>q(z),className:"text-text-quaternary hover:text-status-error",children:h.jsx(en,{className:"w-2 h-2"})})]},z))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",value:g,onChange:z=>u(z.target.value),onKeyDown:z=>{z.key==="Enter"&&g.trim()&&(B(g.trim()),u(""))},placeholder:"task.> or file.stored",className:"input text-2xs font-mono flex-1 py-1"}),h.jsxs("button",{onClick:()=>{g.trim()&&(B(g.trim()),u(""))},className:"text-2xs text-accent hover:text-accent-hover flex items-center gap-0.5",children:[h.jsx(fx,{className:"w-2.5 h-2.5"})," Add"]})]})]}),h.jsx(Gm,{open:n,children:h.jsx("div",{ref:d,className:"h-48 overflow-y-auto",children:o.length===0?h.jsx("p",{className:"text-2xs text-text-tertiary py-4 text-center",children:"Waiting for events..."}):o.map(z=>h.jsx(Z1,{event:z},z.id))})}),h.jsxs(Vv,{open:m,onClose:()=>p(!1),sourceRef:d,children:[h.jsx("div",{className:"sticky top-0 float-right z-10",children:h.jsx("button",{onClick:()=>p(!1),className:"p-2 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150 bg-surface-sunken/80 backdrop-blur-sm",title:"Close (Esc)",children:h.jsx(mx,{className:"w-5 h-5"})})}),o.length===0?h.jsx("p",{className:"text-sm text-text-tertiary py-8",children:"No events captured"}):o.map(z=>h.jsx(Z1,{event:z,forceExpanded:!0},z.id))]})]})}function wC(){return Le({queryKey:["docs"],queryFn:()=>ue("/docs"),staleTime:5*6e4})}function SC(n){return Le({queryKey:["docs",n],queryFn:()=>ue(`/docs/read?path=${encodeURIComponent(n)}`),enabled:!!n,staleTime:5*6e4})}function EC(){const[n,e]=E.useState([]),[s,i]=E.useState([]),[o,c]=E.useState(null),m=E.useRef(o),p=E.useRef(n),g=E.useRef(s);m.current=o,p.current=n,g.current=s;const u=E.useCallback((_,S)=>{var B;const C=m.current;if(C){const q=((B=S==null?void 0:S.current)==null?void 0:B.scrollTop)??0;e([...p.current,{...C,scrollTop:q}])}i([]),c({path:_,scrollTop:0})},[]),d=E.useCallback(_=>{var q;const S=p.current;if(S.length===0)return;const C=S[S.length-1],B=m.current;if(B){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;i([...g.current,{...B,scrollTop:ne}])}e(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),b=E.useCallback(_=>{var q;const S=g.current;if(S.length===0)return;const C=S[S.length-1],B=m.current;if(B){const ne=((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0;e([...p.current,{...B,scrollTop:ne}])}i(S.slice(0,-1)),c(C),requestAnimationFrame(()=>{_!=null&&_.current&&(_.current.scrollTop=C.scrollTop)})},[]),x=E.useCallback(_=>{var B,q;const S=m.current;if(!S)return;const C=((B=_==null?void 0:_.current)==null?void 0:B.scrollTop)??0;e([...p.current,{...S,scrollTop:C}]),i([]),c({...S,scrollTop:((q=_==null?void 0:_.current)==null?void 0:q.scrollTop)??0})},[]),v=E.useCallback(()=>{e([]),i([]),c(null)},[]);return{current:o,backStack:n,forwardStack:s,navigate:u,goBack:d,goForward:b,pushScrollPosition:x,reset:v}}function OC(n,e){const[s,i]=n.split("#");let o=s;if(o.startsWith("./")||o.startsWith("../")){const m=((e?e.replace(/[^/]+$/,""):"")+o).split("/"),p=[];for(const g of m)g===".."?p.pop():g&&g!=="."&&p.push(g);o=p.join("/")}return{path:o,anchor:i}}function AC(n){if(!n.startsWith("#docs"))return null;const e=n.slice(1).split(":"),s=e[1]||"README.md",i=e[2]||void 0;return{path:s,anchor:i}}function jC(n){return!n||n==="README.md"?"#docs":`#docs:${n}`}function kC({content:n,currentPath:e,onNavigate:s,onAnchorClick:i}){const o=c=>{var u;const m=c.target,p=m.closest("[data-anchor]");if(p){c.preventDefault(),i();const d=p.dataset.anchor,b=(u=p.closest(".docs-content"))==null?void 0:u.querySelector(`#${CSS.escape(d)}`);b==null||b.scrollIntoView({behavior:"smooth",block:"start"});return}const g=m.closest("[data-doc-link]");if(g){c.preventDefault();const{path:d,anchor:b}=OC(g.dataset.docLink,e);s(d,b);return}};return h.jsx(Pu,{content:n,className:"docs-content",onClick:o})}function NC(n){const e=[],s=new Map;for(const i of n){const o=i.path.split("/");if(o.length===1){e.push(i);continue}let c=s;for(let m=0;m<o.length-1;m++){const p=o[m];c.has(p)||c.set(p,{label:p,children:[],subdirs:new Map});const g=c.get(p);m===o.length-2?g.children.push(i):c=g.subdirs}}return{topLevel:e,dirs:s}}function TC({docs:n,selected:e,onSelect:s}){const{topLevel:i,dirs:o}=NC(n),c=p=>`block w-full text-left px-3 py-1 text-xs rounded truncate transition-colors ${e===p?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-hover"}`;function m(p,g){return h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-1.5 px-3 py-1 text-2xs font-semibold uppercase tracking-widest text-text-tertiary cursor-pointer",children:[h.jsx(IS,{className:"w-3 h-3",strokeWidth:1.5}),p.label]}),h.jsxs("div",{className:"pl-2 space-y-0.5",children:[[...p.subdirs.values()].map(u=>m(u)),p.children.map(u=>h.jsx("button",{className:c(u.path),onClick:()=>s(u.path),children:u.title},u.path))]})]},p.label)}return h.jsxs("div",{className:"space-y-0.5",children:[i.map(p=>h.jsx("button",{className:c(p.path),onClick:()=>s(p.path),children:p.title},p.path)),[...o.values()].map(p=>m(p))]})}function CC({open:n,onClose:e}){var ae,F,U;const[s,i]=E.useState(!1),{data:o}=wC(),c=EC(),{data:m,isLoading:p}=SC(((ae=c.current)==null?void 0:ae.path)??null),g=E.useRef(null),[u,d]=E.useState(null);E.useEffect(()=>{u&&(m!=null&&m.content)&&g.current&&requestAnimationFrame(()=>{var Q;const D=(Q=g.current)==null?void 0:Q.querySelector(`#${CSS.escape(u)}`);D==null||D.scrollIntoView({behavior:"smooth",block:"start"}),d(null)})},[u,m]);const b=E.useCallback(()=>{var W;const D=AC(window.location.hash),Q=(D==null?void 0:D.path)??"README.md";((W=c.current)==null?void 0:W.path)!==Q&&c.navigate(Q,g),D!=null&&D.anchor&&d(D.anchor)},[c]),x=E.useRef(!0);E.useEffect(()=>{if(!n||!c.current)return;if(x.current){x.current=!1;return}const D=jC(c.current.path);window.location.hash!==D&&window.history.replaceState(null,"",window.location.pathname+window.location.search+D)},[n,(F=c.current)==null?void 0:F.path]),E.useEffect(()=>{if(!n)return;const D=()=>{window.location.hash.startsWith("#docs")&&b()};return window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[n,b]);const v=E.useCallback((D,Q)=>{Q&&d(Q),c.navigate(D,g)},[c]),_=E.useCallback(D=>{c.navigate(D,g)},[c]),S=E.useCallback(()=>{c.goBack(g)},[c]),C=E.useCallback(()=>{c.goForward(g)},[c]),B=E.useCallback(()=>{c.pushScrollPosition(g)},[c]);if(E.useEffect(()=>{if(n){x.current=!0,b();const D=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(D)}},[n]),!(n||s))return null;const ne=()=>{i(!1),setTimeout(()=>{e(),c.reset()},200)},te=((U=c.current)==null?void 0:U.path)??null,M=c.backStack.length>0,z=c.forwardStack.length>0;return h.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 flex",children:[h.jsx("div",{className:`fixed inset-0 bg-black/20 transition-opacity duration-200 ${s&&n?"opacity-100":"opacity-0"}`,onClick:ne}),h.jsxs("div",{className:`relative ml-auto w-[40vw] min-w-[800px] max-w-[90vw] h-full bg-surface-raised border-l border-surface-border flex flex-col shadow-xl transition-transform duration-200 ease-out ${s&&n?"translate-x-0":"translate-x-full"}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:S,disabled:!M,className:`p-0.5 transition-colors ${M?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Back",children:h.jsx(cx,{className:"w-4 h-4"})}),h.jsx("button",{onClick:C,disabled:!z,className:`p-0.5 transition-colors ${z?"text-text-tertiary hover:text-text-primary":"text-surface-border cursor-default"}`,title:"Forward",children:h.jsx(gd,{className:"w-4 h-4"})}),h.jsx($S,{className:"w-4 h-4 text-accent ml-1",strokeWidth:1.5}),h.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Documentation"})]}),h.jsx("button",{onClick:ne,className:"p-1 text-text-tertiary hover:text-text-primary",children:h.jsx(en,{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(TC,{docs:o.docs,selected:te,onSelect:_}):h.jsx("div",{className:"px-3 py-2 text-xs text-text-tertiary",children:"Loading..."})}),h.jsx("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4",children:te?p?h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-6 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-sunken rounded w-3/4"})]}):m!=null&&m.content?h.jsx(kC,{content:m.content,currentPath:te,onNavigate:v,onAnchorClick:B}):h.jsx("p",{className:"text-xs text-text-tertiary",children:"Document not found."}):h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-tertiary",children:[h.jsx(gd,{className:"w-5 h-5 mb-2"}),h.jsx("p",{className:"text-xs",children:"Select a document"})]})})]})]})]})}function MC(n){if(n.includes("/escalations"))return["escalation","human-queue"]}const ex=2e3;function RC(n){const s=n.filter(o=>!o.pending).slice(-8);return s.length===0?"":`[Prior conversation]
60
60
  ${s.map(o=>`${o.role==="user"?"User":"Assistant"}: ${o.content}`).join(`
61
61
  `)}
62
62
  [End prior conversation]
63
63
 
64
- `}function DC(n){const e=n.summary,s=n.title;if(e){const i=e.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?e.slice(0,i).trim():e}return s||(typeof n=="string"?n:"Query completed.")}const Jv=E.createContext(null);function LC({children:n}){const e=en(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[m,p]=E.useState(null),[g,u]=E.useState({}),d=E.useRef(null),b={page:e.pathname.split("/").filter(Boolean).join("-")||"home",route:e.pathname,params:{},...g,suggestedTags:g.suggestedTags??MC(e.pathname)};E.useEffect(()=>()=>{d.current&&clearInterval(d.current)},[]);const x=E.useCallback(()=>i(B=>!B),[]),v=E.useCallback(B=>{u(B)},[]),_=E.useCallback(()=>{c([]),p(null)},[]),S=E.useCallback(async B=>{var F;const q=new Date().toISOString(),ne={id:`user-${Date.now()}`,role:"user",content:B,timestamp:q},te={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:q,pending:!0};c(U=>[...U,ne,te]);const M={...b};(F=M.entities)!=null&&F.yamlContent&&M.entities.yamlContent.length>ex&&(M.entities={...M.entities,yamlContent:M.entities.yamlContent.slice(0,ex)+`
65
- ... (truncated)`});const ae=`${RC(o.concat(ne))}${B}`;try{const D=(await ue("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ae,tags:M.suggestedTags,context:M,wait:!1,direct:!0})})).workflow_id;p(D),c(X=>X.map(W=>W.id===te.id?{...W,workflowId:D}:W)),d.current&&clearInterval(d.current),d.current=setInterval(async()=>{var X;try{const W=await ue(`/workflows/${D}/result`),he=(X=W==null?void 0:W.result)==null?void 0:X.data;if(he){d.current&&clearInterval(d.current),d.current=null,p(null);const Se=DC(he);let Ae;try{Ae=(await ue(`/workflow-states/${D}/execution`)).duration_ms}catch{}c(H=>H.map(J=>J.id===te.id?{...J,content:Se,timestamp:new Date().toISOString(),pending:!1,durationMs:Ae}:J))}}catch{}},3e3)}catch{c(U=>U.map(D=>D.id===te.id?{...D,content:"Failed to submit query. Please try again.",pending:!1}:D))}},[o,b]),C=E.useCallback(async B=>{const q=o.find(M=>M.id===B);if(!(q!=null&&q.workflowId)||q.compilationStatus==="compiling"||q.compilationStatus==="done")return;const ne=o.indexOf(q),te=o.slice(0,ne).reverse().find(M=>M.role==="user");if(te){c(M=>M.map(z=>z.id===B?{...z,compilationStatus:"compiling"}:z));try{const M=await ue("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:te.content,summary:q.content})}),z=await ue("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:q.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:M.tool_name,description:M.description,tags:M.tags,app_id:""})});await ue(`/yaml-workflows/${z.id}/deploy`,{method:"POST"}),c(ae=>ae.map(F=>F.id===B?{...F,compilationStatus:"done"}:F))}catch(M){const z=M instanceof Error?M.message:"Compilation failed";c(ae=>ae.map(F=>F.id===B?{...F,compilationStatus:"error",compilationError:z}:F))}}},[o]);return h.jsx(Jv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:m,clearMessages:_,compileMessage:C},children:n})}function Qv(){const n=E.useContext(Jv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function qC(){const{helpOpen:n,toggleHelp:e}=Qv();return h.jsx("button",{onClick:e,className:"fixed right-3 z-[45] flex items-center justify-center w-10 h-10 rounded-full bg-surface-raised shadow-lg hover:scale-110 transition-transform duration-150 border border-accent/30",style:{bottom:"44px"},"aria-label":n?"Close help":"Ask for help",children:n?h.jsx(Zt,{className:"w-5 h-5 text-text-tertiary",strokeWidth:1.5}):h.jsx("span",{role:"img","aria-label":"Help",className:"logo-mark w-8 h-8 -rotate-[120deg]",style:{"--logo-url":`url(${Vt}/logo512.png)`}})})}function PC({ms:n,className:e=""}){const s=gk(n),i=E.useMemo(()=>n==null?[]:[{label:"ms",value:String(n)},{label:"sec",value:`${(n/1e3).toFixed(3)}s`},{label:"text",value:s}],[n,s]);return n==null?h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:"--"}):h.jsx(bv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:s})})}const BC=["sm","md","lg","full"],tx={sm:"w-[28rem] max-h-[40vh]",md:"w-[36rem] max-h-[60vh]",lg:"w-[48rem] max-h-[80vh]",full:"inset-4 w-auto max-h-none"},nx={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function UC({which:n}){const e="stroke-current";switch(n){case"sm":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:e,strokeWidth:"1.5"})});case"md":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:e,strokeWidth:"1.5"})});case"lg":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:e,strokeWidth:"1.5"})});case"full":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:e,strokeWidth:"1.5"})})}}function zC({msg:n}){const[e,s]=E.useState(0);E.useEffect(()=>{const m=new Date(n.timestamp).getTime(),p=()=>s(Math.floor((Date.now()-m)/1e3));p();const g=setInterval(p,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(e/60),o=e%60,c=i>0?`${i}m ${o}s`:`${o}s`;return h.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),h.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:c})]}),n.workflowId&&h.jsxs(ar,{to:`/workflows/executions/${n.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function IC({msg:n,compileMessage:e}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(xv,{date:n.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),n.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(PC,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(ar,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>e(n.id),disabled:n.compilationStatus==="compiling"||n.compilationStatus==="done",className:"transition-colors",title:n.compilationStatus==="done"?"Compiled — future queries will match this pipeline":n.compilationStatus==="error"?n.compilationError??"Compilation failed":n.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx(HS,{className:`w-2.5 h-2.5 ${n.compilationStatus==="done"?"text-status-success":n.compilationStatus==="error"?"text-status-error":n.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function $C(){const{helpOpen:n,setHelpOpen:e,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:m,compileMessage:p}=Qv(),[g,u]=E.useState(""),[d,b]=E.useState("md"),[x,v]=E.useState(!0),_=E.useRef(null),S=E.useRef(null);if(E.useEffect(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[s]),E.useEffect(()=>{n&&S.current&&S.current.focus()},[n]),E.useEffect(()=>{if(!n)return;const M=z=>{z.key==="Escape"&&(d==="full"?b("lg"):d==="lg"?b("md"):d==="md"?b("sm"):e(!1))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n,d,e]),!n)return null;const C=()=>{const M=g.trim();!M||c||(i(M),u(""),S.current&&(S.current.style.height="auto"))},B=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),C())},q=d==="full",ne=o.page.replace(/-/g," "),te=q?{}:{bottom:"108px"};return h.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${q?tx.full:`right-6 ${tx[d]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:te,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[h.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),h.jsx("p",{className:"text-2xs text-text-tertiary truncate",children:ne})]}),h.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[h.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:BC.map(M=>h.jsx("button",{onClick:()=>b(M),className:`p-1 rounded transition-colors ${M===d?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":M===d,"aria-label":nx[M],title:nx[M],children:h.jsx(UC,{which:M})},M))}),s.length>0&&h.jsx("button",{onClick:m,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(FS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>e(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:_,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(M=>h.jsxs("div",{className:`text-xs leading-relaxed ${M.role==="user"?"text-right":"text-left"}`,children:[h.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${M.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:M.pending?h.jsx(zC,{msg:M}):M.role==="assistant"?h.jsx(Pu,{content:M.content}):M.content}),!M.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(IC,{msg:M,compileMessage:p})})]},M.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:S,value:g,onChange:M=>{u(M.target.value);const z=M.target;z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,120)}px`},onKeyDown:B,placeholder:"Ask a question...",rows:2,className:"flex-1 resize-none bg-surface text-xs text-text-primary placeholder:text-text-tertiary rounded px-2.5 py-1.5 border border-surface-border focus:outline-none focus:border-accent",style:{minHeight:"2.5rem"},disabled:!!c}),h.jsx("button",{onClick:C,disabled:!g.trim()||!!c,className:"px-2.5 py-1.5 text-accent hover:text-accent-hover disabled:text-text-muted transition-colors self-end","aria-label":"Send",children:h.jsx(GS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const HC=6e3,FC="scan";function GC(){const{lastResult:n}=$m(),{open:e,ownerKey:s}=Lm(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),HC);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||e&&s===FC||n.source===To.TOOLBAR?null:h.jsx("div",{role:"status",className:"fixed bottom-14 right-4 z-[60] w-80 max-w-[calc(100vw-2rem)] bg-surface-raised border border-surface-border shadow-lg rounded-md animate-page-in",children:h.jsxs("div",{className:"flex items-start gap-2.5 px-3.5 py-3",children:[h.jsx(Mo,{className:"w-4 h-4 mt-0.5 text-accent-muted shrink-0",strokeWidth:1.5}),h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx(Hm,{result:n})}),h.jsx("button",{type:"button",onClick:()=>o(n.at),className:"text-text-tertiary hover:text-text-primary shrink-0",title:"Dismiss",children:h.jsx(Zt,{className:"w-3.5 h-3.5"})})]})})}const Xv="lt-announcement-dismissed:",VC="Live updates unavailable. Reconnecting… Refresh if this persists.";function YC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function KC(n){try{return localStorage.getItem(`${Xv}${n}`)==="1"}catch{return!1}}function JC(){const{isAuthenticated:n,userRoleNames:e}=qt(),{data:s}=gv(n),i=Pe(),[o,c]=E.useState(null),[m,p]=E.useState(0),{unavailable:g}=mO();An(dk,()=>{i.invalidateQueries({queryKey:["announcements"]})});const u=Date.now(),d=((s==null?void 0:s.announcements)??[]).filter(x=>!KC(x.id)&&new Date(x.expires_at).getTime()>u&&(x.roles.length===0||x.roles.some(v=>e.includes(v))));if(E.useEffect(()=>{const x=((s==null?void 0:s.announcements)??[]).map(_=>new Date(_.expires_at).getTime()-Date.now()).filter(_=>_>0);if(x.length===0)return;const v=setTimeout(()=>p(_=>_+1),Math.min(...x)+250);return()=>clearTimeout(v)},[s,m]),d.length===0&&!g)return null;const b=x=>{try{localStorage.setItem(`${Xv}${x}`,"1")}catch{}p(v=>v+1)};return h.jsxs("div",{"data-testid":"announcement-banner",className:"relative z-40",children:[g&&h.jsx("div",{"data-testid":"live-updates-notice",role:"status",className:"border-b border-status-warning/25 bg-status-warning/10",children:h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-status-warning",children:"Notice"}),h.jsx("span",{className:"truncate text-xs text-text-primary",children:VC})]})}),d.map(x=>{const v=o===x.id,_=x.title??x.body.split(`
66
- `)[0];return h.jsxs("div",{className:"border-b border-accent/25 bg-accent/10",children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-accent",children:"Notice"}),h.jsxs("button",{type:"button",onClick:()=>c(v?null:x.id),className:"flex items-center gap-1.5 text-xs text-text-primary hover:text-accent transition-colors min-w-0",children:[h.jsx("span",{className:"truncate",children:_}),v?h.jsx(px,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(im,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>b(x.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${_}`,children:h.jsx(Zt,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),v&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Pu,{content:YC(x.body)})})]},x.id)})]})}function QC(){var ae,F;const{isBuilder:n,isOps:e,viewAs:s}=tv(),{canSeePaceBoard:i}=nv();EA();const{data:o}=Hn();Lj((ae=o==null?void 0:o.display)==null?void 0:ae.timeZone);const c=Xx(),m=c!==null?c:!!((F=o==null?void 0:o.ai)!=null&&F.enabled),p=!!(o!=null&&o.machines),{collapsed:g,toggle:u}=Rm(),[d,b]=E.useState(!1),[x,v]=E.useState(!1),[_,S]=E.useState(!1),[C,B]=E.useState(()=>window.location.hash.startsWith("#docs")),q=en(),ne=E.useRef(null),{kiosk:te,homePath:M}=Cm(),z=te||Kj(q.pathname);return E.useEffect(()=>{const U=ne.current;U&&(U.classList.remove("animate-page-in"),U.offsetWidth,U.classList.add("animate-page-in"))},[q.pathname]),E.useEffect(()=>{const U=()=>{window.location.hash.startsWith("#docs")&&B(!0)};return window.addEventListener("hashchange",U),()=>window.removeEventListener("hashchange",U)},[]),te&&M&&!Wj(q.pathname,q.search)?h.jsx(cn,{to:M,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(NT,{onToggleEventFeed:()=>b(U=>!U),onToggleDocs:()=>B(U=>!U),onToggleNav:z?void 0:()=>v(U=>!U)}),h.jsx(JC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!z&&h.jsxs("aside",{className:`${g?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border hidden lg:flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[h.jsx("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(Fv,{aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i,showLines:p})}),h.jsx("button",{onClick:u,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${g?"flex justify-center":"flex items-center px-7"}`,"aria-label":g?"Expand sidebar":"Collapse sidebar",children:g?h.jsx(VS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(YS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!g&&(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:ne,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(vs,{})})}),h.jsx(XC,{})]}),!z&&h.jsx(nC,{open:x,onClose:()=>v(!1),aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i,showLines:p}),h.jsx(_C,{open:d,onToggle:()=>b(U=>!U),configOpen:_,onToggleConfig:()=>S(U=>!U)}),h.jsx(CC,{open:C,onClose:()=>{B(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),m&&h.jsx(qC,{}),m&&h.jsx($C,{}),h.jsx(GC,{})]})}function XC(){const{node:n,width:e,open:s}=Lm();return h.jsx(rk,{open:s,width:e,className:"border-l border-surface-border bg-surface-raised",children:n})}function WC(){const{isAuthenticated:n}=qt(),e=en();return n?h.jsx(ek,{children:h.jsx(nk,{children:h.jsx(LC,{children:h.jsx(_A,{children:h.jsx(eN,{children:h.jsx(QC,{})})})})})}):h.jsx(cn,{to:"/login",state:{from:e.pathname},replace:!0})}function Wv({provider:n,className:e="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),h.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),h.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),h.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]});case"github":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})});case"microsoft":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),h.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),h.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),h.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M13.827 3.52h3.603L24 20.48h-3.603l-6.57-16.96zm-7.258 0h3.767L16.906 20.48h-3.674l-1.343-3.461H6.396l-1.34 3.461H1.5l5.07-16.96zm2.327 5.14l-2.065 5.326h4.108l-2.043-5.326z"})});default:return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M12 8v4l3 3"})]})}}async function ZC(){return ue("/auth/oauth/providers")}async function e3(n,e){const s=e?`?label=${encodeURIComponent(e)}`:"";return ue(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function nR(){return qe({queryKey:["oauth-connections"],queryFn:()=>ue("/auth/oauth/connections")})}function rR(){const n=Pe();return $e({mutationFn:({provider:e,label:s})=>e3(e,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function t3(){var ae;const{login:n,isAuthenticated:e}=qt(),s=ni(),i=en(),o=new URLSearchParams(i.search),c=o.get("token"),m=o.get("error"),p=((ae=i.state)==null?void 0:ae.from)??o.get("returnTo")??"/",g=E.useRef(!1);c&&!g.current&&(g.current=!0,n(c,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[u,d]=E.useState(""),[b,x]=E.useState(""),[v,_]=E.useState(m||""),[S,C]=E.useState(!1),[B,q]=E.useState(!!c),[ne,te]=E.useState([]),M=E.useRef(!1);if(E.useEffect(()=>{c||M.current||(M.current=!0,(async()=>{var F,U,D,X;try{const W=await lm().catch(()=>null);if(!((F=W==null?void 0:W.auth)!=null&&F.sso))return;const he=await fetch(`${Vt}/api/auth/sso`,{method:"POST"});if(!he.ok){_("Host authentication required — please log in to your organization first");return}const Se=await he.json();Se.token&&((U=W.auth)!=null&&U.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",W.auth.ssoLogoutUrl),q(!0),n(Se.token,void 0,{displayName:(D=Se.user)==null?void 0:D.display_name,username:(X=Se.user)==null?void 0:X.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||ZC().then(te).catch(()=>{})},[]),E.useEffect(()=>{if(!B)return;const F=setTimeout(()=>s(p,{replace:!0}),1500);return()=>clearTimeout(F)},[B]),e&&!B)return h.jsx(cn,{to:p,replace:!0});const z=async F=>{var U,D;if(F.preventDefault(),_(""),!u.trim()||!b){_("Username and password are required");return}C(!0);try{const X=await fetch(`${Vt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),W=await X.json();if(!X.ok){_(W.error||"Login failed");return}q(!0),n(W.token,{username:u.trim(),password:b},{displayName:(U=W.user)==null?void 0:U.display_name,username:(D=W.user)==null?void 0:D.external_id})}catch{_("Unable to connect to server")}finally{C(!1)}};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${B?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Ru,{size:"lg",hideLabel:B})}),h.jsxs("form",{onSubmit:z,className:`space-y-5 transition-opacity duration-300 ${B?"opacity-0":""}`,children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),h.jsx("input",{id:"username",type:"text",value:u,onChange:F=>d(F.target.value),className:"input",placeholder:"Enter your username",autoFocus:!B,autoComplete:"username"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:b,onChange:F=>x(F.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),v&&h.jsx("p",{className:"text-sm text-status-error",children:v}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:S||B,children:S?"Signing in...":"Sign In"}),ne.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[h.jsx("div",{className:"flex-1 h-px bg-border"}),h.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),h.jsx("div",{className:"flex-1 h-px bg-border"})]}),h.jsx("div",{className:"space-y-2",children:ne.filter(F=>F.provider!=="anthropic").map(F=>h.jsxs("a",{href:`${Vt}/api/auth/oauth/${F.provider}?returnTo=${encodeURIComponent(p)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Wv,{provider:F.provider}),"Sign in with ",F.name]},F.provider))})]})]})]})})}function rx(){const{isAuthenticated:n}=qt(),e=ni(),s=en(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||e(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,m]=E.useState(""),[p,g]=E.useState(i.get("label")||"default"),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=c.trim().startsWith("sk-ant-oat"),_=c.trim().startsWith("sk-ant-api"),S=C=>{C.preventDefault();const B=c.trim();if(!B){d("A token or API key is required");return}if(!B.startsWith("sk-ant-")){d('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),d("");const q=`${Vt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(B)}&state=${encodeURIComponent(o)}`;window.location.href=q};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Wv,{provider:"anthropic",className:"w-6 h-6"}),h.jsx("h2",{className:"heading-3",children:"Connect Anthropic"})]}),h.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Connect your Anthropic account so Claude Code tasks run under your credentials. Your token is encrypted at rest."}),h.jsxs("form",{onSubmit:S,className:"space-y-5",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),h.jsx("input",{id:"token",type:"password",value:c,onChange:C=>m(C.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),v&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),_&&h.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),h.jsx("input",{id:"label",type:"text",value:p,onChange:C=>g(C.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),h.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:'A name for this credential. Use different labels to store multiple credentials (e.g., "subscription", "api-batch").'})]}),u&&h.jsx("p",{className:"text-sm text-status-error",children:u}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:b,children:b?"Validating...":"Connect"}),h.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),h.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",h.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-2xs",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",h.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent-secondary hover:underline",children:"console.anthropic.com"})," ","(billed per-token)."]})]})]})})}function n3({items:n,columns:e=1}){if(n.length===0)return null;const s=e>=2&&n.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return h.jsx("div",{className:"@container",children:h.jsx("dl",{className:`grid ${s} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:n.map(({key:i,label:o,value:c})=>h.jsxs(E.Fragment,{children:[h.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:o}),h.jsx("dd",{className:"text-sm text-text-primary break-words whitespace-pre-wrap min-w-0","data-field-key":i,children:r3(c)})]},i))})})}function r3(n){return n==null||n===""?"—":typeof n=="boolean"?n?"Yes":"No":typeof n=="object"?JSON.stringify(n):String(n)}function s3(n){return qe({queryKey:["oauth-client",n],queryFn:()=>ue(`/oauth/clients/${encodeURIComponent(n)}`),enabled:!!n,retry:!1})}function i3(n){return qe({queryKey:["oauth-presets"],queryFn:()=>ue("/oauth/presets"),enabled:n})}function a3(){return $e({mutationFn:n=>ue(n.preset?"/oauth/authorize":"/oauth/deny",{method:"POST",body:JSON.stringify(n.preset?{...n.request,preset:n.preset}:n.request)})})}function sR(){return qe({queryKey:["oauth-grants"],queryFn:()=>ue("/oauth/grants")})}function iR(){const n=Pe();return $e({mutationFn:e=>ue(`/oauth/grants/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["oauth-grants"]})})}const o3=["client_id","redirect_uri","code_challenge","code_challenge_method","response_type","state","scope","resource"],yd={read_only:{action:"Allow read-only",effect:"Reads what you can read and runs workflows marked read-safe."},just_me:{action:"Allow as me",effect:"Acts with your full rights: claims, resolves, invokes, and administers wherever you may."}};function l3(n){const e=new URLSearchParams(n),s=o3.map(o=>[o,e.get(o)??void 0]),i=Object.fromEntries(s);return!i.client_id||!i.redirect_uri||!i.code_challenge?null:i}function c3(n){try{return new URL(n).host}catch{return n}}function u3(){var b,x,v;const{isAuthenticated:n,user:e}=qt(),s=ni(),i=en(),o=E.useMemo(()=>l3(i.search),[i.search]);E.useEffect(()=>{n||s(`/login?returnTo=${encodeURIComponent(i.pathname+i.search)}`,{replace:!0})},[n]);const c=s3(n&&o?o.client_id:null),m=i3(n&&!!o),p=a3(),g=_=>{o&&p.mutate({request:o,preset:_},{onSuccess:({redirect:S})=>window.location.assign(S)})};if(!n)return null;const u=!o||c.isError,d=((b=c.data)==null?void 0:b.client_name)||"An app";return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-lg p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),u?h.jsxs("div",{role:"alert",children:[h.jsx("h2",{className:"heading-3 mb-3",children:"Sign-in link not valid"}),h.jsx("p",{className:"text-sm text-text-secondary",children:"Start the connection again from the app."})]}):h.jsxs(h.Fragment,{children:[h.jsxs("h2",{className:"heading-2 mb-2",children:["Connect ",d]}),h.jsxs("p",{className:"text-sm text-text-secondary mb-6",children:["Pick how much ",d," may do as you. Disconnect it any time under Connected apps."]}),h.jsx("div",{className:"mb-8",children:h.jsx(n3,{items:[{key:"app",label:"App",value:d},{key:"account",label:"Account",value:(e==null?void 0:e.displayName)||(e==null?void 0:e.username)||(e==null?void 0:e.userId)||null},{key:"returns-to",label:"Returns to",value:c3(o.redirect_uri)},{key:"deployment",label:"Deployment",value:window.location.host}]})}),h.jsx("dl",{className:"space-y-3 mb-8",children:(((x=m.data)==null?void 0:x.presets)??[]).map(_=>h.jsxs("div",{children:[h.jsx("dt",{className:"text-sm font-medium text-text-primary",children:yd[_].action}),h.jsx("dd",{className:"text-sm text-text-secondary",children:yd[_].effect})]},_))}),p.isError&&h.jsx("p",{className:"text-sm text-status-error mb-4",role:"alert",children:p.error.message}),h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[(((v=m.data)==null?void 0:v.presets)??[]).map(_=>h.jsx("button",{type:"button",className:_==="read_only"?"btn-primary":"btn-secondary",disabled:p.isPending||c.isLoading,onClick:()=>g(_),children:yd[_].action},_)),h.jsx("button",{type:"button",className:"btn-ghost",disabled:p.isPending,onClick:()=>g(null),children:"Deny"})]})]})]})})}function Ki({roleTypes:n,roleNames:e,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=qt();return i?h.jsx(vs,{}):n&&n.some(m=>c(m))?h.jsx(vs,{}):e&&e.some(m=>o(m))?h.jsx(vs,{}):h.jsx(cn,{to:s,replace:!0})}function f3(){const{data:n,isSuccess:e}=Hv();return e&&n.length===0?h.jsx(cn,{to:"/",replace:!0}):h.jsx(vs,{})}function h3({redirectTo:n="/"}){var i;const{data:e,isLoading:s}=Hn();return s||!e?null:(i=e.ai)!=null&&i.enabled?h.jsx(vs,{}):h.jsx(cn,{to:n,replace:!0})}function d3({flag:n,redirectTo:e="/"}){var o;const{data:s,isLoading:i}=Hn();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(cn,{to:e,replace:!0}):h.jsx(vs,{})}function m3({redirectTo:n="/"}){const{data:e,isLoading:s}=Hn();return s||!e?null:e.machines?h.jsx(vs,{}):h.jsx(cn,{to:n,replace:!0})}const p3=E.lazy(()=>Oe(()=>import("./ProcessesListPage-BWKoKbXk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url).then(n=>({default:n.ProcessesListPage}))),y3=E.lazy(()=>Oe(()=>import("./ProcessDetailPage-AidH_h7z.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),g3=E.lazy(()=>Oe(()=>import("./McpOverview-pSnadtSM.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),b3=E.lazy(()=>Oe(()=>import("./McpRunsPage-Cd9yCT-_.js"),__vite__mapDeps([28,1,24,25,3,4,29,26,6,7,8,9,16,13,30,14,12,11,15,31]),import.meta.url).then(n=>({default:n.McpRunsPage}))),x3=E.lazy(()=>Oe(()=>import("./McpRunDetailPage-BHppCztI.js"),__vite__mapDeps([32,1,24,14,13,33,34,12,35,19,4,36,15,37]),import.meta.url).then(n=>({default:n.McpRunDetailPage}))),v3=E.lazy(()=>Oe(()=>import("./McpQueryPage-CRyXeRp5.js"),__vite__mapDeps([38,1,14,13,7,8,9,12,11,15,6,10,30,16,31,3,4,39]),import.meta.url).then(n=>({default:n.McpQueryPage}))),_3=E.lazy(()=>Oe(()=>import("./McpQueryDetailPage-BCAJ3rKO.js"),__vite__mapDeps([40,1,14,13,19,39,4,25,41,42,24,2,43,44,45,46,47,48,37,49,35,36]),import.meta.url).then(n=>({default:n.McpQueryDetailPage}))),w3=E.lazy(()=>Oe(()=>import("./EscalationsOverview-Cgmrl8Zc.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),S3=E.lazy(()=>Oe(()=>import("./AvailableEscalationsPage-B5p8QJvI.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,21,58,19,7,8,9,59,11,60,12,61,20,16,62,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),E3=E.lazy(()=>Oe(()=>import("./OperatorDashboard-B4_OBhYh.js"),__vite__mapDeps([63,1,3,4,5,6,52,7,8,9,11,31,59,57,21,13,58,19,60,12,61,20,16,62,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),O3=E.lazy(()=>Oe(()=>import("./index-CjjRxpVe.js"),__vite__mapDeps([64,1,65,13,66,4,57,21,58,19,54,16,53,5,14,15,20,62,37,67]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),A3=E.lazy(()=>Oe(()=>import("./WorkflowsOverview-018s2q_p.js"),__vite__mapDeps([68,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),j3=E.lazy(()=>Oe(()=>import("./index-DMKLnxt8.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),k3=E.lazy(()=>Oe(()=>import("./index-DMKLnxt8.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),N3=E.lazy(()=>Oe(()=>import("./WorkflowsDashboard-BKxhC_hT.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"durable"})}))),T3=E.lazy(()=>Oe(()=>import("./WorkflowsDashboard-BKxhC_hT.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"all"})}))),C3=E.lazy(()=>Oe(()=>import("./YamlWorkflowsPage-aVcNZNu6.js"),__vite__mapDeps([72,1,25,3,4,14,13,12,8,48,70,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),M3=E.lazy(()=>Oe(()=>import("./GraphInvokePage-CcDFhY53.js"),__vite__mapDeps([73,1,25,14,13,43,45,46,47,44,4,48,70]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),R3=E.lazy(()=>Oe(()=>import("./YamlWorkflowDetailPage-C2zcXDr1.js"),__vite__mapDeps([74,1,25,19,70,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),D3=E.lazy(()=>Oe(()=>import("./TasksListPage-DHBSUhZC.js"),__vite__mapDeps([75,1,2,3,4,7,8,9,19,61,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),L3=E.lazy(()=>Oe(()=>import("./TaskDetailPage-m8CQFN4w.js"),__vite__mapDeps([76,1,2,19,61,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),sx=E.lazy(()=>Oe(()=>import("./WorkflowExecutionPage-BUqIhtcr.js"),__vite__mapDeps([77,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),q3=E.lazy(()=>Oe(()=>import("./AdminDashboard-DRE0hSDS.js"),__vite__mapDeps([78,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),P3=E.lazy(()=>Oe(()=>import("./index-DIU89TX3.js"),__vite__mapDeps([79,1,7,8,9,12,13,31,3,4,14,80,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),B3=E.lazy(()=>Oe(()=>import("./index-CXXc9sUr.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),ix=E.lazy(()=>Oe(()=>import("./index-CXXc9sUr.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),U3=E.lazy(()=>Oe(()=>import("./index-BhS9XSy8.js"),__vite__mapDeps([83,1,23,8,82,14,13,12,11,3,4,84,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),ax=E.lazy(()=>Oe(()=>import("./index-3HaFP00M.js"),__vite__mapDeps([85,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),z3=E.lazy(()=>Oe(()=>import("./index-CyL-6CAa.js"),__vite__mapDeps([86,1,3,4,7,8,9,11,12,13,82,31,14,20,47,49,87,88,33]),import.meta.url).then(n=>({default:n.UsersPage}))),I3=E.lazy(()=>Oe(()=>import("./RolesPage-T2hH_MV5.js"),__vite__mapDeps([89,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),$3=E.lazy(()=>Oe(()=>import("./RoleDetailPage-D_30TDVh.js"),__vite__mapDeps([90,1,91,82,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),H3=E.lazy(()=>Oe(()=>import("./PersonasPage-6HsOp-1y.js"),__vite__mapDeps([92,1,87,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),F3=E.lazy(()=>Oe(()=>import("./PersonaDetailPage-BAYjM9qf.js"),__vite__mapDeps([93,1,87,20,13,88,91,82,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),G3=E.lazy(()=>Oe(()=>import("./EscalationSchemaPage-Co59lcuD.js"),__vite__mapDeps([94,1,65,13,66,4,57,21,58,19,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),V3=E.lazy(()=>Oe(()=>import("./PortalPage-6OMr7KtJ.js"),__vite__mapDeps([95,1,9,56,13,57,21,58,19,4,7,8,59,11,60,12,61,20,16,62]),import.meta.url).then(n=>({default:n.PortalPage}))),Y3=E.lazy(()=>Oe(()=>import("./EscalationListSchemaPage-CrpBhC0e.js"),__vite__mapDeps([96,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),K3=E.lazy(()=>Oe(()=>import("./ScanCodesPage-lB_WxoZw.js"),__vite__mapDeps([97,1,98,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),J3=E.lazy(()=>Oe(()=>import("./ScanSchemeDetailPage-C3VLg61H.js"),__vite__mapDeps([99,1,82,14,13,98,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),Q3=E.lazy(()=>Oe(()=>import("./ScanStationPage-CVET1_4r.js"),__vite__mapDeps([100,1,13,67,57,21,66,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),X3=E.lazy(()=>Oe(()=>import("./index-BuSUevzO.js"),__vite__mapDeps([101,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),ox=E.lazy(()=>Oe(()=>import("./OperationsPage-BtnthZgj.js").then(n=>n.O),__vite__mapDeps([102,1,60,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),W3=E.lazy(()=>Oe(()=>import("./index-BFxHIfQ_.js"),__vite__mapDeps([103,1,18,13,12,3,4,29,26,42,80,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),Z3=E.lazy(()=>Oe(()=>import("./index-DhKGp4QK.js"),__vite__mapDeps([104,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),e5=E.lazy(()=>Oe(()=>import("./CredentialsPage-DoFwNvFv.js"),__vite__mapDeps([105,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),t5=E.lazy(()=>Oe(()=>import("./ConnectedAppsPage-B0D2OvTD.js"),__vite__mapDeps([106,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.ConnectedAppsPage}))),n5=E.lazy(()=>Oe(()=>import("./index-DeyA88jq.js"),__vite__mapDeps([107,1,4,14,13,12,15,6,8,108,49]),import.meta.url).then(n=>({default:n.FilesPage}))),r5=E.lazy(()=>Oe(()=>import("./index-CeeSFnl-.js"),__vite__mapDeps([109,1,14,13,12,15,11,8,108,49,110,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),s5=E.lazy(()=>Oe(()=>import("./LinesPage-BXZVO4MC.js"),__vite__mapDeps([111,1,112,7,8,9,12,13,11,14,5,3,4]),import.meta.url).then(n=>({default:n.LinesPage}))),i5=E.lazy(()=>Oe(()=>import("./LinePage-DKwhGunp.js"),__vite__mapDeps([113,1,112,14,13,60,4,12]),import.meta.url).then(n=>({default:n.LinePage}))),a5=E.lazy(()=>Oe(()=>import("./HomePage-Xahqcdu9.js"),__vite__mapDeps([114,1,24,26,20,13,16,15,102,60,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),o5=E.lazy(()=>Oe(()=>import("./AgentsPage-C4ZxCNxt.js"),__vite__mapDeps([115,1,116,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),l5=E.lazy(()=>Oe(()=>import("./AgentDetailPage-BiL9FB7i.js"),__vite__mapDeps([117,1,116,118,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),lx=E.lazy(()=>Oe(()=>import("./AgentConfigPage-BuflQGgy.js"),__vite__mapDeps([119,1,116,118,13,14,110,45,46,47,25,120,121,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),c5=E.lazy(()=>Oe(()=>import("./CapabilitiesPage-DmbC1pEs.js"),__vite__mapDeps([122,1,120,84,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),u5=E.lazy(()=>Oe(()=>import("./TopicsPage-BqZaVv3d.js"),__vite__mapDeps([123,1,121,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),f5=E.lazy(()=>Oe(()=>import("./TopicDetailPage-DhPiCfOO.js"),__vite__mapDeps([124,1,121,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function h5(){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 we({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(h5,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Zv=new hS({defaultOptions:{queries:{staleTime:1e4,retry:(n,e)=>e instanceof Error&&e.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Zv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",e=`${n}/login`;if(window.location.pathname!==e){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${e}?returnTo=${encodeURIComponent(i)}`}});const d5=pS([{path:"/login",element:h.jsx(t3,{})},{path:"/connect/anthropic",element:h.jsx(rx,{})},{path:"/connect/:provider",element:h.jsx(rx,{})},{path:"/oauth/consent",element:h.jsx(u3,{})},{path:"/",element:h.jsx(WC,{}),children:[{index:!0,element:h.jsx(we,{children:h.jsx(a5,{})})},{path:"processes/all",element:h.jsx(we,{children:h.jsx(p3,{})})},{path:"processes/detail/:originId",element:h.jsx(we,{children:h.jsx(y3,{})})},{path:"credentials",element:h.jsx(we,{children:h.jsx(e5,{})})},{path:"connected-apps",element:h.jsx(we,{children:h.jsx(t5,{})})},{path:"connections",element:h.jsx(cn,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(we,{children:h.jsx(w3,{})})},{path:"escalations/available",element:h.jsx(we,{children:h.jsx(S3,{})})},{path:"escalations/queue",element:h.jsx(we,{children:h.jsx(E3,{})})},{path:"escalations/detail/:id",element:h.jsx(we,{children:h.jsx(O3,{})})},{path:"portal/:role/:portal?",element:h.jsx(we,{children:h.jsx(V3,{})})},{path:"scan/station",element:h.jsx(we,{children:h.jsx(Q3,{})})},{path:"capabilities",element:h.jsx(we,{children:h.jsx(c5,{})})},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"agents",element:h.jsx(we,{children:h.jsx(o5,{})})},{path:"agents/new",element:h.jsx(we,{children:h.jsx(lx,{})})},{path:"agents/:id",element:h.jsx(we,{children:h.jsx(l5,{})})},{path:"agents/:id/edit",element:h.jsx(we,{children:h.jsx(lx,{})})},{path:"topics",element:h.jsx(we,{children:h.jsx(u5,{})})},{path:"topics/:topic",element:h.jsx(we,{children:h.jsx(f5,{})})}]},{element:h.jsx(f3,{}),children:[{path:"workflows/start",element:h.jsx(we,{children:h.jsx(j3,{})})},{path:"workflows/durable/invoke",element:h.jsx(we,{children:h.jsx(k3,{})})}]},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(we,{children:h.jsx(A3,{})})},{path:"workflows/executions",element:h.jsx(we,{children:h.jsx(T3,{})})},{path:"workflows/durable/executions",element:h.jsx(we,{children:h.jsx(N3,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(we,{children:h.jsx(sx,{})})},{path:"workflows/tasks",element:h.jsx(we,{children:h.jsx(D3,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(we,{children:h.jsx(L3,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(we,{children:h.jsx(sx,{})})},{path:"workflows/cron",element:h.jsx(cn,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(we,{children:h.jsx(P3,{})})},{path:"workflows/registry",element:h.jsx(we,{children:h.jsx(B3,{})})},{path:"workflows/registry/new",element:h.jsx(we,{children:h.jsx(ix,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(we,{children:h.jsx(ix,{})})}]},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(we,{children:h.jsx(C3,{})})},{path:"mcp/workflows/invoke",element:h.jsx(we,{children:h.jsx(M3,{})})},{path:"mcp/workflows/:id",element:h.jsx(we,{children:h.jsx(R3,{})})},{path:"mcp/executions",element:h.jsx(we,{children:h.jsx(b3,{})})},{path:"mcp/executions/:jobId",element:h.jsx(we,{children:h.jsx(x3,{})})},{path:"files",element:h.jsx(we,{children:h.jsx(n5,{})})},{path:"knowledge",element:h.jsx(we,{children:h.jsx(r5,{})})},{element:h.jsx(h3,{}),children:[{path:"mcp",element:h.jsx(we,{children:h.jsx(g3,{})})},{path:"mcp/queries",element:h.jsx(we,{children:h.jsx(v3,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(we,{children:h.jsx(_3,{})})},{path:"mcp/tools",element:h.jsx(cn,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(we,{children:h.jsx(U3,{})})},{path:"mcp/servers/new",element:h.jsx(we,{children:h.jsx(ax,{})})},{path:"mcp/servers/:serverId",element:h.jsx(we,{children:h.jsx(ax,{})})}]}]},{path:"pace",element:h.jsx(we,{children:h.jsx(ox,{})})},{path:"trends",element:h.jsx(we,{children:h.jsx(ox,{})})},{path:"operations",element:h.jsx(cn,{to:"/pace",replace:!0})},{element:h.jsx(Ki,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{element:h.jsx(m3,{}),children:[{path:"lines",element:h.jsx(we,{children:h.jsx(s5,{})})},{path:"lines/:siteId/:lineId",element:h.jsx(we,{children:h.jsx(i5,{})})}]}]},{element:h.jsx(Ki,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(we,{children:h.jsx(q3,{})})},{path:"admin/users",element:h.jsx(we,{children:h.jsx(z3,{})})},{path:"admin/escalation-chains",element:h.jsx(cn,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(we,{children:h.jsx(I3,{})})},{path:"admin/roles/:role",element:h.jsx(we,{children:h.jsx($3,{})})},{path:"admin/roles/:role/schema",element:h.jsx(we,{children:h.jsx(G3,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(we,{children:h.jsx(Y3,{})})},{path:"admin/scan-codes",element:h.jsx(we,{children:h.jsx(K3,{})})},{path:"admin/scan-codes/:version",element:h.jsx(we,{children:h.jsx(J3,{})})},{path:"admin/personas",element:h.jsx(we,{children:h.jsx(H3,{})})},{path:"admin/personas/:key",element:h.jsx(we,{children:h.jsx(F3,{})})}]},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(cn,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(d3,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(we,{children:h.jsx(X3,{})})}]},{path:"admin/controlplane",element:h.jsx(we,{children:h.jsx(W3,{})})},{path:"admin/streams",element:h.jsx(we,{children:h.jsx(Z3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function m5(){return h.jsx(dS,{client:Zv,children:h.jsx(lE,{children:h.jsx(hA,{children:h.jsx(yS,{router:d5})})})})}Ev(Sv());const Vm=document.createElement("link");Vm.rel="stylesheet";Vm.href=`${Vt}/api/settings/custom.css`;document.head.appendChild(Vm);WS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(m5,{})}));export{qt as $,Qk as A,PM as B,Gm as C,PC as D,G5 as E,Vv as F,BM as G,Lm as H,LT as I,bC as J,qT as K,GT as L,nT as M,Xt as N,tv as O,z5 as P,Cm as Q,rM as R,aC as S,sM as T,iM as U,aM as V,oM as W,cM as X,$j as Y,Mu as Z,F5 as _,VM as a,M5 as a$,nm as a0,IT as a1,C5 as a2,HM as a3,Bm as a4,na as a5,xs as a6,Q5 as a7,R5 as a8,pv as a9,KM as aA,YM as aB,Hv as aC,JM as aD,GM as aE,bv as aF,hM as aG,WM as aH,FM as aI,eR as aJ,ZM as aK,S5 as aL,E5 as aM,k5 as aN,N5 as aO,O5 as aP,A5 as aQ,j5 as aR,L5 as aS,P5 as aT,q5 as aU,zM as aV,T5 as aW,Tm as aX,B5 as aY,$T as aZ,U5 as a_,jT as aa,Ck as ab,TM as ac,Wk as ad,dc as ae,eM as af,tM as ag,Pu as ah,Xk as ai,GN as aj,UM as ak,jv as al,Cu as am,zm as an,Ij as ao,wA as ap,Y5 as aq,_M as ar,K5 as as,nM as at,lM as au,uv as av,v5 as aw,zg as ax,_5 as ay,XM as az,pM as b,AM as b0,ks as b1,Eo as b2,tR as b3,qx as b4,n3 as b5,EM as b6,Vt as b7,wd as b8,w5 as b9,MM as bA,DM as bB,ET as bC,$m as bD,yk as bE,Zk as bF,ke as bG,CM as bH,$5 as bI,gM as bJ,rT as bK,nR as bL,rR as bM,Wv as bN,sR as bO,iR as bP,qj as bQ,iC as bR,jm as bS,nv as bT,wM as bU,BT as ba,$M as bb,yv as bc,K1 as bd,kv as be,vM as bf,km as bg,bM as bh,kM as bi,Cj as bj,jM as bk,Ik as bl,zk as bm,ak as bn,Z5 as bo,W5 as bp,fr as bq,rv as br,OM as bs,ta as bt,D5 as bu,Fk as bv,RM as bw,vk as bx,LM as by,qM as bz,Hn as c,NM as d,uM as e,gk as f,xv as g,rk as h,I5 as i,tn as j,An as k,fM as l,ue as m,QM as n,dM as o,mM as p,V5 as q,J5 as r,X5 as s,yM as t,SM as u,H5 as v,Fm as w,IM as x,Xx as y,xM as z};
67
- //# sourceMappingURL=index-pzbGpihI.js.map
64
+ `}function DC(n){const e=n.summary,s=n.title;if(e){const i=e.search(/\n\s*\{[\s\S]*"title"\s*:/);return i>0?e.slice(0,i).trim():e}return s||(typeof n=="string"?n:"Query completed.")}const Jv=E.createContext(null);function LC({children:n}){const e=tn(),[s,i]=E.useState(!1),[o,c]=E.useState([]),[m,p]=E.useState(null),[g,u]=E.useState({}),d=E.useRef(null),b={page:e.pathname.split("/").filter(Boolean).join("-")||"home",route:e.pathname,params:{},...g,suggestedTags:g.suggestedTags??MC(e.pathname)};E.useEffect(()=>()=>{d.current&&clearInterval(d.current)},[]);const x=E.useCallback(()=>i(B=>!B),[]),v=E.useCallback(B=>{u(B)},[]),_=E.useCallback(()=>{c([]),p(null)},[]),S=E.useCallback(async B=>{var F;const q=new Date().toISOString(),ne={id:`user-${Date.now()}`,role:"user",content:B,timestamp:q},te={id:`pending-${Date.now()}`,role:"assistant",content:"",timestamp:q,pending:!0};c(U=>[...U,ne,te]);const M={...b};(F=M.entities)!=null&&F.yamlContent&&M.entities.yamlContent.length>ex&&(M.entities={...M.entities,yamlContent:M.entities.yamlContent.slice(0,ex)+`
65
+ ... (truncated)`});const ae=`${RC(o.concat(ne))}${B}`;try{const D=(await ue("/insight/mcp-query",{method:"POST",body:JSON.stringify({prompt:ae,tags:M.suggestedTags,context:M,wait:!1,direct:!0})})).workflow_id;p(D),c(Q=>Q.map(W=>W.id===te.id?{...W,workflowId:D}:W)),d.current&&clearInterval(d.current),d.current=setInterval(async()=>{var Q;try{const W=await ue(`/workflows/${D}/result`),he=(Q=W==null?void 0:W.result)==null?void 0:Q.data;if(he){d.current&&clearInterval(d.current),d.current=null,p(null);const Ee=DC(he);let Ae;try{Ae=(await ue(`/workflow-states/${D}/execution`)).duration_ms}catch{}c(H=>H.map(J=>J.id===te.id?{...J,content:Ee,timestamp:new Date().toISOString(),pending:!1,durationMs:Ae}:J))}}catch{}},3e3)}catch{c(U=>U.map(D=>D.id===te.id?{...D,content:"Failed to submit query. Please try again.",pending:!1}:D))}},[o,b]),C=E.useCallback(async B=>{const q=o.find(M=>M.id===B);if(!(q!=null&&q.workflowId)||q.compilationStatus==="compiling"||q.compilationStatus==="done")return;const ne=o.indexOf(q),te=o.slice(0,ne).reverse().find(M=>M.role==="user");if(te){c(M=>M.map(z=>z.id===B?{...z,compilationStatus:"compiling"}:z));try{const M=await ue("/insight/mcp-query/describe",{method:"POST",body:JSON.stringify({prompt:te.content,summary:q.content})}),z=await ue("/yaml-workflows",{method:"POST",body:JSON.stringify({workflow_id:q.workflowId,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:M.tool_name,description:M.description,tags:M.tags,app_id:""})});await ue(`/yaml-workflows/${z.id}/deploy`,{method:"POST"}),c(ae=>ae.map(F=>F.id===B?{...F,compilationStatus:"done"}:F))}catch(M){const z=M instanceof Error?M.message:"Compilation failed";c(ae=>ae.map(F=>F.id===B?{...F,compilationStatus:"error",compilationError:z}:F))}}},[o]);return h.jsx(Jv.Provider,{value:{helpOpen:s,setHelpOpen:i,toggleHelp:x,messages:o,sendMessage:S,pageContext:b,setPageContext:v,activeWorkflowId:m,clearMessages:_,compileMessage:C},children:n})}function Qv(){const n=E.useContext(Jv);if(!n)throw new Error("useHelpAssistant must be used within HelpAssistantProvider");return n}function qC(){const{helpOpen:n,toggleHelp:e}=Qv();return h.jsx("button",{onClick:e,className:"fixed right-3 z-[45] flex items-center justify-center w-10 h-10 rounded-full bg-surface-raised shadow-lg hover:scale-110 transition-transform duration-150 border border-accent/30",style:{bottom:"44px"},"aria-label":n?"Close help":"Ask for help",children:n?h.jsx(en,{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(${Yt}/logo512.png)`}})})}function PC({ms:n,className:e=""}){const s=gk(n),i=E.useMemo(()=>n==null?[]:[{label:"ms",value:String(n)},{label:"sec",value:`${(n/1e3).toFixed(3)}s`},{label:"text",value:s}],[n,s]);return n==null?h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:"--"}):h.jsx(bv,{options:i,children:h.jsx("span",{className:`text-xs text-text-tertiary ${e}`,children:s})})}const BC=["sm","md","lg","full"],tx={sm:"w-[28rem] max-h-[40vh]",md:"w-[36rem] max-h-[60vh]",lg:"w-[48rem] max-h-[80vh]",full:"inset-4 w-auto max-h-none"},nx={sm:"Small",md:"Medium",lg:"Large",full:"Fullscreen"};function UC({which:n}){const e="stroke-current";switch(n){case"sm":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"5",y:"5",width:"7",height:"7",rx:"1.5",className:e,strokeWidth:"1.5"})});case"md":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"3",y:"3",width:"9",height:"9",rx:"1.5",className:e,strokeWidth:"1.5"})});case"lg":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"1.5",y:"1.5",width:"11",height:"11",rx:"1.5",className:e,strokeWidth:"1.5"})});case"full":return h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:h.jsx("rect",{x:"0.75",y:"0.75",width:"12.5",height:"12.5",rx:"1.5",className:e,strokeWidth:"1.5"})})}}function zC({msg:n}){const[e,s]=E.useState(0);E.useEffect(()=>{const m=new Date(n.timestamp).getTime(),p=()=>s(Math.floor((Date.now()-m)/1e3));p();const g=setInterval(p,1e3);return()=>clearInterval(g)},[n.timestamp]);const i=Math.floor(e/60),o=e%60,c=i>0?`${i}m ${o}s`:`${o}s`;return h.jsxs("span",{className:"inline-flex flex-col gap-1.5",children:[h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx("span",{className:"text-text-tertiary",children:"Thinking"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:150ms]"}),h.jsx("span",{className:"inline-block w-1 h-1 rounded-full bg-text-tertiary animate-pulse [animation-delay:300ms]"}),h.jsx("span",{className:"text-text-muted ml-1 tabular-nums",children:c})]}),n.workflowId&&h.jsxs(ar,{to:`/workflows/executions/${n.workflowId}`,className:"inline-flex items-center gap-1 text-2xs text-accent/70 hover:text-accent transition-colors",children:[h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5}),"watch execution"]})]})}function IC({msg:n,compileMessage:e}){const s=n.role==="assistant";return h.jsxs("div",{className:`flex items-center gap-1.5 ${s?"justify-start":"justify-end"}`,children:[h.jsx(xv,{date:n.timestamp,format:"time",className:"!text-2xs text-text-muted/50"}),n.durationMs!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-muted/30 text-2xs",children:"·"}),h.jsx(PC,{ms:n.durationMs,className:"!text-2xs text-text-muted/50"})]}),n.workflowId&&h.jsx(ar,{to:`/workflows/executions/${n.workflowId}`,className:"text-text-muted/40 hover:text-accent transition-colors",title:"View workflow execution",children:h.jsx(am,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),s&&n.workflowId&&!n.pending&&h.jsx("button",{onClick:()=>e(n.id),disabled:n.compilationStatus==="compiling"||n.compilationStatus==="done",className:"transition-colors",title:n.compilationStatus==="done"?"Compiled — future queries will match this pipeline":n.compilationStatus==="error"?n.compilationError??"Compilation failed":n.compilationStatus==="compiling"?"Compiling...":"Compile to fast pipeline",children:h.jsx(HS,{className:`w-2.5 h-2.5 ${n.compilationStatus==="done"?"text-status-success":n.compilationStatus==="error"?"text-status-error":n.compilationStatus==="compiling"?"text-accent/40 animate-pulse":"text-text-muted/40 hover:text-accent"}`,strokeWidth:1.5})})]})}function $C(){const{helpOpen:n,setHelpOpen:e,messages:s,sendMessage:i,pageContext:o,activeWorkflowId:c,clearMessages:m,compileMessage:p}=Qv(),[g,u]=E.useState(""),[d,b]=E.useState("md"),[x,v]=E.useState(!0),_=E.useRef(null),S=E.useRef(null);if(E.useEffect(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[s]),E.useEffect(()=>{n&&S.current&&S.current.focus()},[n]),E.useEffect(()=>{if(!n)return;const M=z=>{z.key==="Escape"&&(d==="full"?b("lg"):d==="lg"?b("md"):d==="md"?b("sm"):e(!1))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n,d,e]),!n)return null;const C=()=>{const M=g.trim();!M||c||(i(M),u(""),S.current&&(S.current.style.height="auto"))},B=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),C())},q=d==="full",ne=o.page.replace(/-/g," "),te=q?{}:{bottom:"108px"};return h.jsxs("div",{className:`fixed z-[45] flex flex-col border border-surface-border rounded-lg overflow-hidden transition-all duration-300 ${q?tx.full:`right-6 ${tx[d]}`} ${x?"bg-surface-raised shadow-xl":"bg-surface-raised/[0.03] shadow-lg shadow-black/5"}`,style:te,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[h.jsxs("div",{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-border shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:"Help Assistant"}),h.jsx("p",{className:"text-2xs text-text-tertiary truncate",children:ne})]}),h.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[h.jsx("div",{className:"flex items-center gap-0.5 border border-surface-border rounded p-0.5",role:"radiogroup","aria-label":"Panel size",children:BC.map(M=>h.jsx("button",{onClick:()=>b(M),className:`p-1 rounded transition-colors ${M===d?"bg-accent/15 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface-hover"}`,role:"radio","aria-checked":M===d,"aria-label":nx[M],title:nx[M],children:h.jsx(UC,{which:M})},M))}),s.length>0&&h.jsx("button",{onClick:m,className:"p-1 text-text-tertiary hover:text-text-secondary transition-colors","aria-label":"Clear conversation",title:"Clear conversation",children:h.jsx(FS,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),h.jsx("button",{onClick:()=>e(!1),className:"p-1 text-text-tertiary hover:text-text-primary transition-colors","aria-label":"Close",title:"Close",children:h.jsx(en,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})]}),h.jsxs("div",{ref:_,className:`flex-1 overflow-y-auto px-4 py-3 space-y-3 min-h-[120px] transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[s.length===0&&h.jsx("p",{className:"text-xs text-text-tertiary text-center py-6",children:"Ask anything about what you're viewing."}),s.map(M=>h.jsxs("div",{className:`text-xs leading-relaxed ${M.role==="user"?"text-right":"text-left"}`,children:[h.jsx("div",{className:`inline-block max-w-[85%] px-3 py-2 rounded-md whitespace-pre-wrap ${M.role==="user"?"bg-accent/10 text-text-primary":"bg-surface-sunken text-text-secondary"}`,children:M.pending?h.jsx(zC,{msg:M}):M.role==="assistant"?h.jsx(Pu,{content:M.content}):M.content}),!M.pending&&h.jsx("div",{className:"mt-0.5",children:h.jsx(IC,{msg:M,compileMessage:p})})]},M.id))]}),h.jsxs("div",{className:`border-t border-surface-border px-3 py-2.5 flex gap-2 shrink-0 transition-all duration-300 ${x?"opacity-100":"opacity-50 grayscale brightness-150"}`,children:[h.jsx("textarea",{ref:S,value:g,onChange:M=>{u(M.target.value);const z=M.target;z.style.height="auto",z.style.height=`${Math.min(z.scrollHeight,120)}px`},onKeyDown:B,placeholder:"Ask a question...",rows:2,className:"flex-1 resize-none bg-surface text-xs text-text-primary placeholder:text-text-tertiary rounded px-2.5 py-1.5 border border-surface-border focus:outline-none focus:border-accent",style:{minHeight:"2.5rem"},disabled:!!c}),h.jsx("button",{onClick:C,disabled:!g.trim()||!!c,className:"px-2.5 py-1.5 text-accent hover:text-accent-hover disabled:text-text-muted transition-colors self-end","aria-label":"Send",children:h.jsx(GS,{className:"w-4 h-4",strokeWidth:1.5})})]})]})}const HC=6e3,FC="scan";function GC(){const{lastResult:n}=$m(),{open:e,ownerKey:s}=Lm(),[i,o]=E.useState(null);return E.useEffect(()=>{if(!n)return;const c=setTimeout(()=>o(n.at),HC);return()=>clearTimeout(c)},[n]),!n||n.navigated||i===n.at||e&&s===FC||n.source===na.TOOLBAR?null:h.jsx("div",{role:"status",className:"fixed bottom-14 right-4 z-[60] w-80 max-w-[calc(100vw-2rem)] bg-surface-raised border border-surface-border shadow-lg rounded-md animate-page-in",children:h.jsxs("div",{className:"flex items-start gap-2.5 px-3.5 py-3",children:[h.jsx(Mo,{className:"w-4 h-4 mt-0.5 text-accent-muted shrink-0",strokeWidth:1.5}),h.jsx("div",{className:"flex-1 min-w-0",children:h.jsx(Hm,{result:n})}),h.jsx("button",{type:"button",onClick:()=>o(n.at),className:"text-text-tertiary hover:text-text-primary shrink-0",title:"Dismiss",children:h.jsx(en,{className:"w-3.5 h-3.5"})})]})})}const Xv="lt-announcement-dismissed:",VC="Live updates unavailable. Reconnecting… Refresh if this persists.";function YC(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function KC(n){try{return localStorage.getItem(`${Xv}${n}`)==="1"}catch{return!1}}function JC(){const{isAuthenticated:n,userRoleNames:e}=Lt(),{data:s}=gv(n),i=qe(),[o,c]=E.useState(null),[m,p]=E.useState(0),{unavailable:g}=mO();An(dk,()=>{i.invalidateQueries({queryKey:["announcements"]})});const u=Date.now(),d=((s==null?void 0:s.announcements)??[]).filter(x=>!KC(x.id)&&new Date(x.expires_at).getTime()>u&&(x.roles.length===0||x.roles.some(v=>e.includes(v))));if(E.useEffect(()=>{const x=((s==null?void 0:s.announcements)??[]).map(_=>new Date(_.expires_at).getTime()-Date.now()).filter(_=>_>0);if(x.length===0)return;const v=setTimeout(()=>p(_=>_+1),Math.min(...x)+250);return()=>clearTimeout(v)},[s,m]),d.length===0&&!g)return null;const b=x=>{try{localStorage.setItem(`${Xv}${x}`,"1")}catch{}p(v=>v+1)};return h.jsxs("div",{"data-testid":"announcement-banner",className:"relative z-40",children:[g&&h.jsx("div",{"data-testid":"live-updates-notice",role:"status",className:"border-b border-status-warning/25 bg-status-warning/10",children:h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-status-warning",children:"Notice"}),h.jsx("span",{className:"truncate text-xs text-text-primary",children:VC})]})}),d.map(x=>{const v=o===x.id,_=x.title??x.body.split(`
66
+ `)[0];return h.jsxs("div",{className:"border-b border-accent/25 bg-accent/10",children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[h.jsx("span",{className:"text-2xs font-semibold uppercase tracking-widest text-accent",children:"Notice"}),h.jsxs("button",{type:"button",onClick:()=>c(v?null:x.id),className:"flex items-center gap-1.5 text-xs text-text-primary hover:text-accent transition-colors min-w-0",children:[h.jsx("span",{className:"truncate",children:_}),v?h.jsx(px,{className:"w-3 h-3 shrink-0",strokeWidth:1.5}):h.jsx(im,{className:"w-3 h-3 shrink-0",strokeWidth:1.5})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{type:"button",onClick:()=>b(x.id),className:"icon-link",title:"Dismiss","aria-label":`Dismiss ${_}`,children:h.jsx(en,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}),v&&h.jsx("div",{className:"px-4 pb-3 text-sm text-text-secondary max-w-measure",children:h.jsx(Pu,{content:YC(x.body)})})]},x.id)})]})}function QC(){var ae,F;const{isBuilder:n,isOps:e,viewAs:s}=tv(),{canSeePaceBoard:i}=nv();EA();const{data:o}=Hn();Lj((ae=o==null?void 0:o.display)==null?void 0:ae.timeZone);const c=Xx(),m=c!==null?c:!!((F=o==null?void 0:o.ai)!=null&&F.enabled),p=!!(o!=null&&o.machines),{collapsed:g,toggle:u}=Rm(),[d,b]=E.useState(!1),[x,v]=E.useState(!1),[_,S]=E.useState(!1),[C,B]=E.useState(()=>window.location.hash.startsWith("#docs")),q=tn(),ne=E.useRef(null),{kiosk:te,homePath:M}=Cm(),z=te||Kj(q.pathname);return E.useEffect(()=>{const U=ne.current;U&&(U.classList.remove("animate-page-in"),U.offsetWidth,U.classList.add("animate-page-in"))},[q.pathname]),E.useEffect(()=>{const U=()=>{window.location.hash.startsWith("#docs")&&B(!0)};return window.addEventListener("hashchange",U),()=>window.removeEventListener("hashchange",U)},[]),te&&M&&!Wj(q.pathname,q.search)?h.jsx(un,{to:M,replace:!0}):h.jsxs("div",{className:"h-screen bg-surface flex flex-col",children:[h.jsx(NT,{onToggleEventFeed:()=>b(U=>!U),onToggleDocs:()=>B(U=>!U),onToggleNav:z?void 0:()=>v(U=>!U)}),h.jsx(JC,{}),h.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!z&&h.jsxs("aside",{className:`${g?"w-16":"w-60"} shrink-0 bg-surface-raised border-r border-surface-border hidden lg:flex flex-col transition-[width] duration-200 ease-out overflow-hidden relative z-20`,children:[h.jsx("nav",{className:"flex-1 px-3 pt-[36px] pb-4 space-y-2 overflow-y-auto overflow-x-hidden",children:h.jsx(Fv,{aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i,showLines:p})}),h.jsx("button",{onClick:u,className:`shrink-0 py-3 text-text-tertiary hover:text-text-secondary transition-colors duration-150 ${g?"flex justify-center":"flex items-center px-7"}`,"aria-label":g?"Expand sidebar":"Collapse sidebar",children:g?h.jsx(VS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5}):h.jsx(YS,{className:"w-4 h-4 text-accent-muted",strokeWidth:1.5})}),!g&&(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:ne,className:"w-full px-page-x py-8 pb-16 animate-page-in h-full flex flex-col @container",children:h.jsx(vs,{})})}),h.jsx(XC,{})]}),!z&&h.jsx(nC,{open:x,onClose:()=>v(!1),aiEnabled:m,isBuilder:n,isOps:e,viewAs:s,canSeePaceBoard:i,showLines:p}),h.jsx(_C,{open:d,onToggle:()=>b(U=>!U),configOpen:_,onToggleConfig:()=>S(U=>!U)}),h.jsx(CC,{open:C,onClose:()=>{B(!1),history.replaceState(null,"",window.location.pathname+window.location.search)}}),m&&h.jsx(qC,{}),m&&h.jsx($C,{}),h.jsx(GC,{})]})}function XC(){const{node:n,width:e,open:s}=Lm();return h.jsx(rk,{open:s,width:e,className:"border-l border-surface-border bg-surface-raised",children:n})}function WC(){const{isAuthenticated:n}=Lt(),e=tn();return n?h.jsx(ek,{children:h.jsx(nk,{children:h.jsx(LC,{children:h.jsx(_A,{children:h.jsx(eN,{children:h.jsx(QC,{})})})})})}):h.jsx(un,{to:"/login",state:{from:e.pathname},replace:!0})}function Wv({provider:n,className:e="w-5 h-5"}){switch(n){case"google":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),h.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),h.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),h.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]});case"github":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})});case"microsoft":return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("path",{d:"M3 3h8.5v8.5H3z",fill:"#F25022"}),h.jsx("path",{d:"M12.5 3H21v8.5h-8.5z",fill:"#7FBA00"}),h.jsx("path",{d:"M3 12.5h8.5V21H3z",fill:"#00A4EF"}),h.jsx("path",{d:"M12.5 12.5H21V21h-8.5z",fill:"#FFB900"})]});case"anthropic":return h.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M13.827 3.52h3.603L24 20.48h-3.603l-6.57-16.96zm-7.258 0h3.767L16.906 20.48h-3.674l-1.343-3.461H6.396l-1.34 3.461H1.5l5.07-16.96zm2.327 5.14l-2.065 5.326h4.108l-2.043-5.326z"})});default:return h.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M12 8v4l3 3"})]})}}async function ZC(){return ue("/auth/oauth/providers")}async function e3(n,e){const s=e?`?label=${encodeURIComponent(e)}`:"";return ue(`/auth/oauth/connections/${n}${s}`,{method:"DELETE"})}function nR(){return Le({queryKey:["oauth-connections"],queryFn:()=>ue("/auth/oauth/connections")})}function rR(){const n=qe();return Ie({mutationFn:({provider:e,label:s})=>e3(e,s),onSuccess:()=>{n.invalidateQueries({queryKey:["oauth-connections"]})}})}function t3(){var ae;const{login:n,isAuthenticated:e}=Lt(),s=ni(),i=tn(),o=new URLSearchParams(i.search),c=o.get("token"),m=o.get("error"),p=((ae=i.state)==null?void 0:ae.from)??o.get("returnTo")??"/",g=E.useRef(!1);c&&!g.current&&(g.current=!0,n(c,void 0,{displayName:o.get("displayName"),username:o.get("username")}));const[u,d]=E.useState(""),[b,x]=E.useState(""),[v,_]=E.useState(m||""),[S,C]=E.useState(!1),[B,q]=E.useState(!!c),[ne,te]=E.useState([]),M=E.useRef(!1);if(E.useEffect(()=>{c||M.current||(M.current=!0,(async()=>{var F,U,D,Q;try{const W=await lm().catch(()=>null);if(!((F=W==null?void 0:W.auth)!=null&&F.sso))return;const he=await fetch(`${Yt}/api/auth/sso`,{method:"POST"});if(!he.ok){_("Host authentication required — please log in to your organization first");return}const Ee=await he.json();Ee.token&&((U=W.auth)!=null&&U.ssoLogoutUrl&&sessionStorage.setItem("lt_sso_logout_url",W.auth.ssoLogoutUrl),q(!0),n(Ee.token,void 0,{displayName:(D=Ee.user)==null?void 0:D.display_name,username:(Q=Ee.user)==null?void 0:Q.external_id}))}catch{}})())},[]),E.useEffect(()=>{c||ZC().then(te).catch(()=>{})},[]),E.useEffect(()=>{if(!B)return;const F=setTimeout(()=>s(p,{replace:!0}),1500);return()=>clearTimeout(F)},[B]),e&&!B)return h.jsx(un,{to:p,replace:!0});const z=async F=>{var U,D;if(F.preventDefault(),_(""),!u.trim()||!b){_("Username and password are required");return}C(!0);try{const Q=await fetch(`${Yt}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:u.trim(),password:b})}),W=await Q.json();if(!Q.ok){_(W.error||"Login failed");return}q(!0),n(W.token,{username:u.trim(),password:b},{displayName:(U=W.user)==null?void 0:U.display_name,username:(D=W.user)==null?void 0:D.external_id})}catch{_("Unable to connect to server")}finally{C(!1)}};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center overflow-hidden",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:`mb-10 transition-all duration-[1500ms] ease-in ${B?"translate-x-[120vw] -translate-y-[60vh] scale-[3] opacity-0":""}`,children:h.jsx(Ru,{size:"lg",hideLabel:B})}),h.jsxs("form",{onSubmit:z,className:`space-y-5 transition-opacity duration-300 ${B?"opacity-0":""}`,children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text-secondary mb-2",children:"Username"}),h.jsx("input",{id:"username",type:"text",value:u,onChange:F=>d(F.target.value),className:"input",placeholder:"Enter your username",autoFocus:!B,autoComplete:"username"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-text-secondary mb-2",children:"Password"}),h.jsx("input",{id:"password",type:"password",value:b,onChange:F=>x(F.target.value),className:"input",placeholder:"Enter your password",autoComplete:"current-password"})]}),v&&h.jsx("p",{className:"text-sm text-status-error",children:v}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:S||B,children:S?"Signing in...":"Sign In"}),ne.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[h.jsx("div",{className:"flex-1 h-px bg-border"}),h.jsx("span",{className:"text-xs text-text-tertiary",children:"or continue with"}),h.jsx("div",{className:"flex-1 h-px bg-border"})]}),h.jsx("div",{className:"space-y-2",children:ne.filter(F=>F.provider!=="anthropic").map(F=>h.jsxs("a",{href:`${Yt}/api/auth/oauth/${F.provider}?returnTo=${encodeURIComponent(p)}`,className:"btn-secondary w-full flex items-center justify-center gap-2",children:[h.jsx(Wv,{provider:F.provider}),"Sign in with ",F.name]},F.provider))})]})]})]})})}function rx(){const{isAuthenticated:n}=Lt(),e=ni(),s=tn(),i=new URLSearchParams(s.search),o=i.get("state")||"";E.useEffect(()=>{n||e(`/login?returnTo=${encodeURIComponent(s.pathname+s.search)}`)},[n]);const[c,m]=E.useState(""),[p,g]=E.useState(i.get("label")||"default"),[u,d]=E.useState(""),[b,x]=E.useState(!1),v=c.trim().startsWith("sk-ant-oat"),_=c.trim().startsWith("sk-ant-api"),S=C=>{C.preventDefault();const B=c.trim();if(!B){d("A token or API key is required");return}if(!B.startsWith("sk-ant-")){d('Invalid format. Must start with "sk-ant-oat" (OAuth token) or "sk-ant-api" (API key)');return}x(!0),d("");const q=`${Yt}/api/auth/oauth/anthropic/callback?code=${encodeURIComponent(B)}&state=${encodeURIComponent(o)}`;window.location.href=q};return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-md p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),h.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[h.jsx(Wv,{provider:"anthropic",className:"w-6 h-6"}),h.jsx("h2",{className:"heading-3",children:"Connect Anthropic"})]}),h.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"Connect your Anthropic account so Claude Code tasks run under your credentials. Your token is encrypted at rest."}),h.jsxs("form",{onSubmit:S,className:"space-y-5",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-text-secondary mb-2",children:"OAuth Token or API Key"}),h.jsx("input",{id:"token",type:"password",value:c,onChange:C=>m(C.target.value),className:"input",placeholder:"sk-ant-oat01-... or sk-ant-api03-...",autoFocus:!0,autoComplete:"off"}),v&&h.jsx("p",{className:"text-xs text-status-success mt-1",children:"OAuth token detected — uses your Claude subscription (flat rate)"}),_&&h.jsx("p",{className:"text-xs text-status-warning mt-1",children:"API key detected — billed per-token from your Anthropic API account"})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"label",className:"block text-sm font-medium text-text-secondary mb-2",children:"Label"}),h.jsx("input",{id:"label",type:"text",value:p,onChange:C=>g(C.target.value.replace(/\s+/g,"-").toLowerCase()),className:"input",placeholder:"default",autoComplete:"off"}),h.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:'A name for this credential. Use different labels to store multiple credentials (e.g., "subscription", "api-batch").'})]}),u&&h.jsx("p",{className:"text-sm text-status-error",children:u}),h.jsx("button",{type:"submit",className:"btn-primary w-full",disabled:b,children:b?"Validating...":"Connect"}),h.jsx("a",{href:"/",className:"block text-center text-sm text-text-tertiary hover:text-text-secondary",children:"Cancel"})]}),h.jsxs("div",{className:"mt-6 space-y-3 text-xs text-text-tertiary",children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Recommended:"})," ","Run"," ",h.jsx("code",{className:"px-1 py-0.5 bg-surface-sunken rounded text-2xs",children:"claude setup-token"})," ","in your terminal to generate an OAuth token that uses your subscription."]}),h.jsxs("div",{children:[h.jsx("span",{className:"font-medium text-text-secondary",children:"Alternative:"})," ","Use an API key from"," ",h.jsx("a",{href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent-secondary hover:underline",children:"console.anthropic.com"})," ","(billed per-token)."]})]})]})})}function n3({items:n,columns:e=1}){if(n.length===0)return null;const s=e>=2&&n.length>1?"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr] @dict-pairs:grid-cols-[max-content_1fr_max-content_1fr]":"grid-cols-1 @dict-inline:grid-cols-[max-content_1fr]";return h.jsx("div",{className:"@container",children:h.jsx("dl",{className:`grid ${s} items-baseline gap-x-6 @dict-pairs:gap-x-8 gap-y-1.5`,children:n.map(({key:i,label:o,value:c})=>h.jsxs(E.Fragment,{children:[h.jsx("dt",{className:"text-2xs font-semibold uppercase tracking-wide text-text-secondary mt-2 first:mt-0 @dict-inline:mt-0",children:o}),h.jsx("dd",{className:"text-sm text-text-primary break-words whitespace-pre-wrap min-w-0","data-field-key":i,children:r3(c)})]},i))})})}function r3(n){return n==null||n===""?"—":typeof n=="boolean"?n?"Yes":"No":typeof n=="object"?JSON.stringify(n):String(n)}function s3(n){return Le({queryKey:["oauth-client",n],queryFn:()=>ue(`/oauth/clients/${encodeURIComponent(n)}`),enabled:!!n,retry:!1})}function i3(n){return Le({queryKey:["oauth-presets"],queryFn:()=>ue("/oauth/presets"),enabled:n})}function a3(){return Ie({mutationFn:n=>ue(n.preset?"/oauth/authorize":"/oauth/deny",{method:"POST",body:JSON.stringify(n.preset?{...n.request,preset:n.preset}:n.request)})})}function sR(){return Le({queryKey:["oauth-grants"],queryFn:()=>ue("/oauth/grants")})}function iR(){const n=qe();return Ie({mutationFn:e=>ue(`/oauth/grants/${encodeURIComponent(e)}`,{method:"DELETE"}),onSuccess:()=>n.invalidateQueries({queryKey:["oauth-grants"]})})}const o3=["client_id","redirect_uri","code_challenge","code_challenge_method","response_type","state","scope","resource"],yd={read_only:{action:"Allow read-only",effect:"Reads what you can read and runs workflows marked read-safe."},just_me:{action:"Allow as me",effect:"Acts with your full rights: claims, resolves, invokes, and administers wherever you may."}};function l3(n){const e=new URLSearchParams(n),s=o3.map(o=>[o,e.get(o)??void 0]),i=Object.fromEntries(s);return!i.client_id||!i.redirect_uri||!i.code_challenge?null:i}function c3(n){try{return new URL(n).host}catch{return n}}function u3(){var b,x,v;const{isAuthenticated:n,user:e}=Lt(),s=ni(),i=tn(),o=E.useMemo(()=>l3(i.search),[i.search]);E.useEffect(()=>{n||s(`/login?returnTo=${encodeURIComponent(i.pathname+i.search)}`,{replace:!0})},[n]);const c=s3(n&&o?o.client_id:null),m=i3(n&&!!o),p=a3(),g=_=>{o&&p.mutate({request:o,preset:_},{onSuccess:({redirect:S})=>window.location.assign(S)})};if(!n)return null;const u=!o||c.isError,d=((b=c.data)==null?void 0:b.client_name)||"An app";return h.jsx("div",{className:"min-h-screen bg-surface flex items-center justify-center",children:h.jsxs("div",{className:"w-full max-w-lg p-10",children:[h.jsx("div",{className:"mb-10",children:h.jsx(Ru,{size:"lg"})}),u?h.jsxs("div",{role:"alert",children:[h.jsx("h2",{className:"heading-3 mb-3",children:"Sign-in link not valid"}),h.jsx("p",{className:"text-sm text-text-secondary",children:"Start the connection again from the app."})]}):h.jsxs(h.Fragment,{children:[h.jsxs("h2",{className:"heading-2 mb-2",children:["Connect ",d]}),h.jsxs("p",{className:"text-sm text-text-secondary mb-6",children:["Pick how much ",d," may do as you. Disconnect it any time under Connected apps."]}),h.jsx("div",{className:"mb-8",children:h.jsx(n3,{items:[{key:"app",label:"App",value:d},{key:"account",label:"Account",value:(e==null?void 0:e.displayName)||(e==null?void 0:e.username)||(e==null?void 0:e.userId)||null},{key:"returns-to",label:"Returns to",value:c3(o.redirect_uri)},{key:"deployment",label:"Deployment",value:window.location.host}]})}),h.jsx("dl",{className:"space-y-3 mb-8",children:(((x=m.data)==null?void 0:x.presets)??[]).map(_=>h.jsxs("div",{children:[h.jsx("dt",{className:"text-sm font-medium text-text-primary",children:yd[_].action}),h.jsx("dd",{className:"text-sm text-text-secondary",children:yd[_].effect})]},_))}),p.isError&&h.jsx("p",{className:"text-sm text-status-error mb-4",role:"alert",children:p.error.message}),h.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[(((v=m.data)==null?void 0:v.presets)??[]).map(_=>h.jsx("button",{type:"button",className:_==="read_only"?"btn-primary":"btn-secondary",disabled:p.isPending||c.isLoading,onClick:()=>g(_),children:yd[_].action},_)),h.jsx("button",{type:"button",className:"btn-ghost",disabled:p.isPending,onClick:()=>g(null),children:"Deny"})]})]})]})})}function Ki({roleTypes:n,roleNames:e,redirectTo:s="/"}){const{isSuperAdmin:i,hasRole:o,hasRoleType:c}=Lt();return i?h.jsx(vs,{}):n&&n.some(m=>c(m))?h.jsx(vs,{}):e&&e.some(m=>o(m))?h.jsx(vs,{}):h.jsx(un,{to:s,replace:!0})}function f3(){const{data:n,isSuccess:e}=Hv();return e&&n.length===0?h.jsx(un,{to:"/",replace:!0}):h.jsx(vs,{})}function h3({redirectTo:n="/"}){var i;const{data:e,isLoading:s}=Hn();return s||!e?null:(i=e.ai)!=null&&i.enabled?h.jsx(vs,{}):h.jsx(un,{to:n,replace:!0})}function d3({flag:n,redirectTo:e="/"}){var o;const{data:s,isLoading:i}=Hn();return i||!s?null:((o=s.features)==null?void 0:o[n])===!1?h.jsx(un,{to:e,replace:!0}):h.jsx(vs,{})}function m3({redirectTo:n="/"}){const{data:e,isLoading:s}=Hn();return s||!e?null:e.machines?h.jsx(vs,{}):h.jsx(un,{to:n,replace:!0})}const p3=E.lazy(()=>Oe(()=>import("./ProcessesListPage-CD5NRIBK.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url).then(n=>({default:n.ProcessesListPage}))),y3=E.lazy(()=>Oe(()=>import("./ProcessDetailPage-DBj4VEnP.js"),__vite__mapDeps([17,1,2,18,13,19,16,10,4,20,21]),import.meta.url).then(n=>({default:n.ProcessDetailPage}))),g3=E.lazy(()=>Oe(()=>import("./McpOverview-Cbu2CXlQ.js"),__vite__mapDeps([22,1,23,24,25,26,14,13,27,4]),import.meta.url).then(n=>({default:n.McpOverview}))),b3=E.lazy(()=>Oe(()=>import("./McpRunsPage-Df4yOclO.js"),__vite__mapDeps([28,1,24,25,3,4,29,26,6,7,8,9,16,13,30,14,12,11,15,31]),import.meta.url).then(n=>({default:n.McpRunsPage}))),x3=E.lazy(()=>Oe(()=>import("./McpRunDetailPage-BDCv-c1o.js"),__vite__mapDeps([32,1,24,14,13,33,34,12,35,19,4,36,15,37]),import.meta.url).then(n=>({default:n.McpRunDetailPage}))),v3=E.lazy(()=>Oe(()=>import("./McpQueryPage-CPUUMIiY.js"),__vite__mapDeps([38,1,14,13,7,8,9,12,11,15,6,10,30,16,31,3,4,39]),import.meta.url).then(n=>({default:n.McpQueryPage}))),_3=E.lazy(()=>Oe(()=>import("./McpQueryDetailPage--1FsnGuM.js"),__vite__mapDeps([40,1,14,13,19,39,4,25,41,42,24,2,43,44,45,46,47,48,37,49,35,36]),import.meta.url).then(n=>({default:n.McpQueryDetailPage}))),w3=E.lazy(()=>Oe(()=>import("./EscalationsOverview-C2nc-Pgv.js"),__vite__mapDeps([50,1,14,13,27,4]),import.meta.url).then(n=>({default:n.EscalationsOverview}))),S3=E.lazy(()=>Oe(()=>import("./AvailableEscalationsPage-DXpRnOVd.js"),__vite__mapDeps([51,1,4,52,13,53,54,5,55,56,57,21,58,19,7,8,9,59,11,60,12,61,20,16,62,3,31]),import.meta.url).then(n=>({default:n.AvailableEscalationsPage}))),E3=E.lazy(()=>Oe(()=>import("./OperatorDashboard-Dd1EhTZe.js"),__vite__mapDeps([63,1,3,4,5,6,52,7,8,9,11,31,59,57,21,13,58,19,60,12,61,20,16,62,55,15]),import.meta.url).then(n=>({default:n.OperatorDashboard}))),O3=E.lazy(()=>Oe(()=>import("./index-C_-FoMo9.js"),__vite__mapDeps([64,1,65,13,66,4,57,21,58,19,54,16,53,5,14,15,20,62,37,67]),import.meta.url).then(n=>({default:n.EscalationDetailPage}))),A3=E.lazy(()=>Oe(()=>import("./WorkflowsOverview-Wz6RzxHJ.js"),__vite__mapDeps([68,1,14,13,27,4]),import.meta.url).then(n=>({default:n.WorkflowsOverview}))),j3=E.lazy(()=>Oe(()=>import("./index-CXnmU0TS.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.StartWorkflowPage}))),k3=E.lazy(()=>Oe(()=>import("./index-CXnmU0TS.js"),__vite__mapDeps([69,1,14,13,12,16,65,66,4,57,21,58,19,54,70,46,47]),import.meta.url).then(n=>({default:n.DurableInvokePage}))),N3=E.lazy(()=>Oe(()=>import("./WorkflowsDashboard-DLb71Sa2.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"durable"})}))),T3=E.lazy(()=>Oe(()=>import("./WorkflowsDashboard-DLb71Sa2.js"),__vite__mapDeps([71,1,30,29,26,4,3,6,7,8,9,16,13,14,12,11,15,31]),import.meta.url).then(n=>({default:()=>n.WorkflowsDashboard({tier:"all"})}))),C3=E.lazy(()=>Oe(()=>import("./YamlWorkflowsPage-B4C9fiYU.js"),__vite__mapDeps([72,1,25,3,4,14,13,12,8,48,70,19]),import.meta.url).then(n=>({default:n.YamlWorkflowsPage}))),M3=E.lazy(()=>Oe(()=>import("./GraphInvokePage-BAyfJ-PY.js"),__vite__mapDeps([73,1,25,14,13,43,45,46,47,44,4,48,70]),import.meta.url).then(n=>({default:n.GraphInvokePage}))),R3=E.lazy(()=>Oe(()=>import("./YamlWorkflowDetailPage-CcRAN_ey.js"),__vite__mapDeps([74,1,25,19,70,13,4]),import.meta.url).then(n=>({default:n.YamlWorkflowDetailPage}))),D3=E.lazy(()=>Oe(()=>import("./TasksListPage-MtawUpuU.js"),__vite__mapDeps([75,1,2,3,4,7,8,9,19,61,49,11,12,13,14,16]),import.meta.url).then(n=>({default:n.TasksListPage}))),L3=E.lazy(()=>Oe(()=>import("./TaskDetailPage-DthMVBZO.js"),__vite__mapDeps([76,1,2,19,61,14,13,4]),import.meta.url).then(n=>({default:n.TaskDetailPage}))),sx=E.lazy(()=>Oe(()=>import("./WorkflowExecutionPage-CZ2c5QLL.js"),__vite__mapDeps([77,1,34,12,13,35,19,4,36,2,14,33,15,37]),import.meta.url).then(n=>({default:n.WorkflowExecutionPage}))),q3=E.lazy(()=>Oe(()=>import("./AdminDashboard-Bjf_7-S6.js"),__vite__mapDeps([78,1,2,23,18,13,4]),import.meta.url).then(n=>({default:n.AdminDashboard}))),P3=E.lazy(()=>Oe(()=>import("./index-C59ZyWOo.js"),__vite__mapDeps([79,1,7,8,9,12,13,31,3,4,14,80,16]),import.meta.url).then(n=>({default:n.WorkersPage}))),B3=E.lazy(()=>Oe(()=>import("./index-BVxqddYr.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigsPage}))),ix=E.lazy(()=>Oe(()=>import("./index-BVxqddYr.js"),__vite__mapDeps([81,1,12,13,82,20,16,14,4,46,47,70,65,66,57,21,58,19,54]),import.meta.url).then(n=>({default:n.WorkflowConfigDetailPage}))),U3=E.lazy(()=>Oe(()=>import("./index-U5gC9Xgq.js"),__vite__mapDeps([83,1,23,8,82,14,13,12,11,3,4,84,45,46,47,48,44,31,19]),import.meta.url).then(n=>({default:n.McpServersPage}))),ax=E.lazy(()=>Oe(()=>import("./index-D-vNL8Hm.js"),__vite__mapDeps([85,1,23,14,13,41,4]),import.meta.url).then(n=>({default:n.McpServerDetailPage}))),z3=E.lazy(()=>Oe(()=>import("./index-CNDnGdvT.js"),__vite__mapDeps([86,1,3,4,7,8,9,11,12,13,82,31,14,20,47,49,87,88,33]),import.meta.url).then(n=>({default:n.UsersPage}))),I3=E.lazy(()=>Oe(()=>import("./RolesPage-DRs2XeSd.js"),__vite__mapDeps([89,1,12,13,14,20,4]),import.meta.url).then(n=>({default:n.RolesPage}))),$3=E.lazy(()=>Oe(()=>import("./RoleDetailPage-6ukNyycs.js"),__vite__mapDeps([90,1,91,82,13,4]),import.meta.url).then(n=>({default:n.RoleDetailPage}))),H3=E.lazy(()=>Oe(()=>import("./PersonasPage--Ez0YeHh.js"),__vite__mapDeps([92,1,87,12,13,14,20,4,5]),import.meta.url).then(n=>({default:n.PersonasPage}))),F3=E.lazy(()=>Oe(()=>import("./PersonaDetailPage-BCx3Ey2_.js"),__vite__mapDeps([93,1,87,20,13,88,91,82,4]),import.meta.url).then(n=>({default:n.PersonaDetailPage}))),G3=E.lazy(()=>Oe(()=>import("./EscalationSchemaPage-Cen9HGYG.js"),__vite__mapDeps([94,1,65,13,66,4,57,21,58,19,54,16]),import.meta.url).then(n=>({default:n.EscalationSchemaPage}))),V3=E.lazy(()=>Oe(()=>import("./PortalPage-BmBmheBp.js"),__vite__mapDeps([95,1,9,56,13,57,21,58,19,4,7,8,59,11,60,12,61,20,16,62]),import.meta.url).then(n=>({default:n.PortalPage}))),Y3=E.lazy(()=>Oe(()=>import("./EscalationListSchemaPage-B20HUAlO.js"),__vite__mapDeps([96,1,13,4]),import.meta.url).then(n=>({default:n.EscalationListSchemaPage}))),K3=E.lazy(()=>Oe(()=>import("./ScanCodesPage-BXENWoZb.js"),__vite__mapDeps([97,1,98,14,13,4]),import.meta.url).then(n=>({default:n.ScanCodesPage}))),J3=E.lazy(()=>Oe(()=>import("./ScanSchemeDetailPage-CaM4rUBV.js"),__vite__mapDeps([99,1,82,14,13,98,4]),import.meta.url).then(n=>({default:n.ScanSchemeDetailPage}))),Q3=E.lazy(()=>Oe(()=>import("./ScanStationPage-CmJKgWy_.js"),__vite__mapDeps([100,1,13,67,57,21,66,4]),import.meta.url).then(n=>({default:n.ScanStationPage}))),X3=E.lazy(()=>Oe(()=>import("./index-BAxEeqfF.js"),__vite__mapDeps([101,1,14,13,54,4]),import.meta.url).then(n=>({default:n.MaintenancePage}))),ox=E.lazy(()=>Oe(()=>import("./OperationsPage-BYUGFgPp.js").then(n=>n.O),__vite__mapDeps([102,1,60,13,4,14,9]),import.meta.url).then(n=>({default:n.OperationsPage}))),W3=E.lazy(()=>Oe(()=>import("./index-DOkHnsLK.js"),__vite__mapDeps([103,1,18,13,12,3,4,29,26,42,80,7,8,9,31]),import.meta.url).then(n=>({default:n.ControlPlanePage}))),Z3=E.lazy(()=>Oe(()=>import("./index-BCSeHOZH.js"),__vite__mapDeps([104,1,36,13,3,4,29,26,6,7,8,9,11,12,14,15]),import.meta.url).then(n=>({default:n.StreamMessagesPage}))),e5=E.lazy(()=>Oe(()=>import("./CredentialsPage-DUfgsEbI.js"),__vite__mapDeps([105,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.CredentialsPage}))),t5=E.lazy(()=>Oe(()=>import("./ConnectedAppsPage-BKhsc_jJ.js"),__vite__mapDeps([106,1,14,13,49,82,4]),import.meta.url).then(n=>({default:n.ConnectedAppsPage}))),n5=E.lazy(()=>Oe(()=>import("./index-BJrsQM-E.js"),__vite__mapDeps([107,1,4,14,13,12,15,6,8,108,49]),import.meta.url).then(n=>({default:n.FilesPage}))),r5=E.lazy(()=>Oe(()=>import("./index-f4-pKYcm.js"),__vite__mapDeps([109,1,14,13,12,15,11,8,108,49,110,41,4]),import.meta.url).then(n=>({default:n.KnowledgePage}))),s5=E.lazy(()=>Oe(()=>import("./LinesPage-BCSfYkuL.js"),__vite__mapDeps([111,1,112,7,8,9,12,13,11,14,5,3,4]),import.meta.url).then(n=>({default:n.LinesPage}))),i5=E.lazy(()=>Oe(()=>import("./LinePage-DPe-vP3-.js"),__vite__mapDeps([113,1,112,14,13,60,4,12]),import.meta.url).then(n=>({default:n.LinePage}))),a5=E.lazy(()=>Oe(()=>import("./HomePage-CtjG2kGn.js"),__vite__mapDeps([114,1,24,26,20,13,16,15,102,60,4,14,9,52]),import.meta.url).then(n=>({default:n.HomePage}))),o5=E.lazy(()=>Oe(()=>import("./AgentsPage-CohqxaWS.js"),__vite__mapDeps([115,1,116,3,4,6,7,8,9,11,12,13,14,15]),import.meta.url).then(n=>({default:n.AgentsPage}))),l5=E.lazy(()=>Oe(()=>import("./AgentDetailPage-C52Oi1_f.js"),__vite__mapDeps([117,1,116,118,13,16,4]),import.meta.url).then(n=>({default:n.AgentDetailPage}))),lx=E.lazy(()=>Oe(()=>import("./AgentConfigPage-CEGk5Gbv.js"),__vite__mapDeps([119,1,116,118,13,14,110,45,46,47,25,120,121,16,4]),import.meta.url).then(n=>({default:n.AgentConfigPage}))),c5=E.lazy(()=>Oe(()=>import("./CapabilitiesPage-ChBBD0IX.js"),__vite__mapDeps([122,1,120,84,23,45,46,47,13,48,4,44,14,12]),import.meta.url).then(n=>({default:n.CapabilitiesPage}))),u5=E.lazy(()=>Oe(()=>import("./TopicsPage-Cj0ugdie.js"),__vite__mapDeps([123,1,121,14,13,12,4]),import.meta.url).then(n=>({default:n.TopicsPage}))),f5=E.lazy(()=>Oe(()=>import("./TopicDetailPage-zNE3EigP.js"),__vite__mapDeps([124,1,121,15,13,4]),import.meta.url).then(n=>({default:n.TopicDetailPage})));function h5(){return h.jsxs("div",{className:"animate-pulse space-y-4",children:[h.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),h.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]})}function Se({children:n}){return h.jsx(E.Suspense,{fallback:h.jsx(h5,{}),children:h.jsx("div",{className:"animate-page-enter flex flex-col flex-1 min-h-0",children:n})})}const Zv=new hS({defaultOptions:{queries:{staleTime:1e4,retry:(n,e)=>e instanceof Error&&e.message==="Session expired"?!1:n<1}}});window.addEventListener("auth:unauthorized",()=>{Zv.clear(),sessionStorage.removeItem("lt_token"),sessionStorage.removeItem("lt_credentials"),sessionStorage.removeItem("lt_user_info");const n=window.__LT_BASE__||"",e=`${n}/login`;if(window.location.pathname!==e){const s=window.location.pathname+window.location.search,i=n&&s.startsWith(n)?s.slice(n.length)||"/":s;window.location.href=`${e}?returnTo=${encodeURIComponent(i)}`}});const d5=pS([{path:"/login",element:h.jsx(t3,{})},{path:"/connect/anthropic",element:h.jsx(rx,{})},{path:"/connect/:provider",element:h.jsx(rx,{})},{path:"/oauth/consent",element:h.jsx(u3,{})},{path:"/",element:h.jsx(WC,{}),children:[{index:!0,element:h.jsx(Se,{children:h.jsx(a5,{})})},{path:"processes/all",element:h.jsx(Se,{children:h.jsx(p3,{})})},{path:"processes/detail/:originId",element:h.jsx(Se,{children:h.jsx(y3,{})})},{path:"credentials",element:h.jsx(Se,{children:h.jsx(e5,{})})},{path:"connected-apps",element:h.jsx(Se,{children:h.jsx(t5,{})})},{path:"connections",element:h.jsx(un,{to:"/credentials",replace:!0})},{path:"escalations",element:h.jsx(Se,{children:h.jsx(w3,{})})},{path:"escalations/available",element:h.jsx(Se,{children:h.jsx(S3,{})})},{path:"escalations/queue",element:h.jsx(Se,{children:h.jsx(E3,{})})},{path:"escalations/detail/:id",element:h.jsx(Se,{children:h.jsx(O3,{})})},{path:"portal/:role/:portal?",element:h.jsx(Se,{children:h.jsx(V3,{})})},{path:"scan/station",element:h.jsx(Se,{children:h.jsx(Q3,{})})},{path:"capabilities",element:h.jsx(Se,{children:h.jsx(c5,{})})},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"agents",element:h.jsx(Se,{children:h.jsx(o5,{})})},{path:"agents/new",element:h.jsx(Se,{children:h.jsx(lx,{})})},{path:"agents/:id",element:h.jsx(Se,{children:h.jsx(l5,{})})},{path:"agents/:id/edit",element:h.jsx(Se,{children:h.jsx(lx,{})})},{path:"topics",element:h.jsx(Se,{children:h.jsx(u5,{})})},{path:"topics/:topic",element:h.jsx(Se,{children:h.jsx(f5,{})})}]},{element:h.jsx(f3,{}),children:[{path:"workflows/start",element:h.jsx(Se,{children:h.jsx(j3,{})})},{path:"workflows/durable/invoke",element:h.jsx(Se,{children:h.jsx(k3,{})})}]},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"workflows",element:h.jsx(Se,{children:h.jsx(A3,{})})},{path:"workflows/executions",element:h.jsx(Se,{children:h.jsx(T3,{})})},{path:"workflows/durable/executions",element:h.jsx(Se,{children:h.jsx(N3,{})})},{path:"workflows/durable/executions/:workflowId",element:h.jsx(Se,{children:h.jsx(sx,{})})},{path:"workflows/tasks",element:h.jsx(Se,{children:h.jsx(D3,{})})},{path:"workflows/tasks/detail/:id",element:h.jsx(Se,{children:h.jsx(L3,{})})},{path:"workflows/executions/:workflowId",element:h.jsx(Se,{children:h.jsx(sx,{})})},{path:"workflows/cron",element:h.jsx(un,{to:"/workflows/start?mode=schedule",replace:!0})},{path:"workflows/workers",element:h.jsx(Se,{children:h.jsx(P3,{})})},{path:"workflows/registry",element:h.jsx(Se,{children:h.jsx(B3,{})})},{path:"workflows/registry/new",element:h.jsx(Se,{children:h.jsx(ix,{})})},{path:"workflows/registry/:workflowType",element:h.jsx(Se,{children:h.jsx(ix,{})})}]},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"mcp/workflows",element:h.jsx(Se,{children:h.jsx(C3,{})})},{path:"mcp/workflows/invoke",element:h.jsx(Se,{children:h.jsx(M3,{})})},{path:"mcp/workflows/:id",element:h.jsx(Se,{children:h.jsx(R3,{})})},{path:"mcp/executions",element:h.jsx(Se,{children:h.jsx(b3,{})})},{path:"mcp/executions/:jobId",element:h.jsx(Se,{children:h.jsx(x3,{})})},{path:"files",element:h.jsx(Se,{children:h.jsx(n5,{})})},{path:"knowledge",element:h.jsx(Se,{children:h.jsx(r5,{})})},{element:h.jsx(h3,{}),children:[{path:"mcp",element:h.jsx(Se,{children:h.jsx(g3,{})})},{path:"mcp/queries",element:h.jsx(Se,{children:h.jsx(v3,{})})},{path:"mcp/queries/:workflowId",element:h.jsx(Se,{children:h.jsx(_3,{})})},{path:"mcp/tools",element:h.jsx(un,{to:"/mcp/servers",replace:!0})},{path:"mcp/servers",element:h.jsx(Se,{children:h.jsx(U3,{})})},{path:"mcp/servers/new",element:h.jsx(Se,{children:h.jsx(ax,{})})},{path:"mcp/servers/:serverId",element:h.jsx(Se,{children:h.jsx(ax,{})})}]}]},{path:"pace",element:h.jsx(Se,{children:h.jsx(ox,{})})},{path:"trends",element:h.jsx(Se,{children:h.jsx(ox,{})})},{path:"operations",element:h.jsx(un,{to:"/pace",replace:!0})},{element:h.jsx(Ki,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{element:h.jsx(m3,{}),children:[{path:"lines",element:h.jsx(Se,{children:h.jsx(s5,{})})},{path:"lines/:siteId/:lineId",element:h.jsx(Se,{children:h.jsx(i5,{})})}]}]},{element:h.jsx(Ki,{roleTypes:["admin","superadmin"],roleNames:["engineer"]}),children:[{path:"admin",element:h.jsx(Se,{children:h.jsx(q3,{})})},{path:"admin/users",element:h.jsx(Se,{children:h.jsx(z3,{})})},{path:"admin/escalation-chains",element:h.jsx(un,{to:"/admin/roles",replace:!0})},{path:"admin/roles",element:h.jsx(Se,{children:h.jsx(I3,{})})},{path:"admin/roles/:role",element:h.jsx(Se,{children:h.jsx($3,{})})},{path:"admin/roles/:role/schema",element:h.jsx(Se,{children:h.jsx(G3,{})})},{path:"admin/roles/:role/list-schema",element:h.jsx(Se,{children:h.jsx(Y3,{})})},{path:"admin/scan-codes",element:h.jsx(Se,{children:h.jsx(K3,{})})},{path:"admin/scan-codes/:version",element:h.jsx(Se,{children:h.jsx(J3,{})})},{path:"admin/personas",element:h.jsx(Se,{children:h.jsx(H3,{})})},{path:"admin/personas/:key",element:h.jsx(Se,{children:h.jsx(F3,{})})}]},{element:h.jsx(Ki,{roleTypes:["superadmin"],roleNames:["engineer"]}),children:[{path:"admin/bots",element:h.jsx(un,{to:"/admin/users?tab=service-accounts",replace:!0})},{element:h.jsx(d3,{flag:"dbMaintenance"}),children:[{path:"admin/maintenance",element:h.jsx(Se,{children:h.jsx(X3,{})})}]},{path:"admin/controlplane",element:h.jsx(Se,{children:h.jsx(W3,{})})},{path:"admin/streams",element:h.jsx(Se,{children:h.jsx(Z3,{})})}]}]}],{basename:window.__LT_BASE__||"/"});function m5(){return h.jsx(dS,{client:Zv,children:h.jsx(lE,{children:h.jsx(hA,{children:h.jsx(yS,{router:d5})})})})}Ev(Sv());const Vm=document.createElement("link");Vm.rel="stylesheet";Vm.href=`${Yt}/api/settings/custom.css`;document.head.appendChild(Vm);WS.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(m5,{})}));export{Lt as $,Qk as A,PM as B,Gm as C,PC as D,G5 as E,Vv as F,BM as G,Lm as H,LT as I,bC as J,qT as K,GT as L,nT as M,Wt as N,tv as O,z5 as P,Cm as Q,rM as R,aC as S,sM as T,iM as U,aM as V,oM as W,cM as X,$j as Y,Mu as Z,F5 as _,VM as a,M5 as a$,nm as a0,IT as a1,C5 as a2,HM as a3,Bm as a4,ra as a5,xs as a6,Q5 as a7,R5 as a8,pv as a9,KM as aA,YM as aB,Hv as aC,JM as aD,GM as aE,bv as aF,hM as aG,WM as aH,FM as aI,eR as aJ,ZM as aK,S5 as aL,E5 as aM,k5 as aN,N5 as aO,O5 as aP,A5 as aQ,j5 as aR,L5 as aS,P5 as aT,q5 as aU,zM as aV,T5 as aW,Tm as aX,B5 as aY,$T as aZ,U5 as a_,jT as aa,Ck as ab,TM as ac,Wk as ad,dc as ae,eM as af,tM as ag,Pu as ah,Xk as ai,GN as aj,UM as ak,jv as al,Cu as am,zm as an,Ij as ao,wA as ap,Y5 as aq,_M as ar,K5 as as,nM as at,lM as au,uv as av,v5 as aw,zg as ax,_5 as ay,XM as az,pM as b,AM as b0,ks as b1,Oo as b2,tR as b3,qx as b4,n3 as b5,EM as b6,Yt as b7,wd as b8,w5 as b9,MM as bA,DM as bB,ET as bC,$m as bD,yk as bE,Zk as bF,ke as bG,Yd as bH,CM as bI,$5 as bJ,gM as bK,rT as bL,nR as bM,rR as bN,Wv as bO,sR as bP,iR as bQ,qj as bR,iC as bS,jm as bT,nv as bU,wM as bV,BT as ba,$M as bb,yv as bc,K1 as bd,kv as be,vM as bf,km as bg,bM as bh,kM as bi,Cj as bj,jM as bk,Ik as bl,zk as bm,ak as bn,Z5 as bo,W5 as bp,fr as bq,rv as br,OM as bs,ta as bt,D5 as bu,Fk as bv,RM as bw,vk as bx,LM as by,qM as bz,Hn as c,NM as d,uM as e,gk as f,xv as g,rk as h,I5 as i,nn as j,An as k,fM as l,ue as m,QM as n,dM as o,mM as p,V5 as q,J5 as r,X5 as s,yM as t,SM as u,H5 as v,Fm as w,IM as x,Xx as y,xM as z};
67
+ //# sourceMappingURL=index-CSr5q355.js.map