@objectstack/console 9.10.0 → 10.0.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 (208) hide show
  1. package/dist/assets/AdapterProvider-497l4p4y.js +1 -0
  2. package/dist/assets/{AiPendingActionsPage-BDYUc-T8.js → AiPendingActionsPage-ux0cUuun.js} +1 -1
  3. package/dist/assets/{ApiConsolePage-BJB9Xho6.js → ApiConsolePage-uUkhblGX.js} +1 -1
  4. package/dist/assets/{AppDocsIndex-Cj0DpA3d.js → AppDocsIndex-BSiJIyVl.js} +1 -1
  5. package/dist/assets/{AppManagementPage-BzjUDLx3.js → AppManagementPage-COxgYP-L.js} +1 -1
  6. package/dist/assets/ApprovalsInboxPage-Dfa8zdNx.js +1 -0
  7. package/dist/assets/{AuditLogPage-BJh3wy1L.js → AuditLogPage-DD_8Xcar.js} +1 -1
  8. package/dist/assets/{ComponentNavView-BFSklq8D.js → ComponentNavView-BxuZYn-k.js} +1 -1
  9. package/dist/assets/ConsoleFloatingChatbot-DEn_10k3.js +1 -0
  10. package/dist/assets/DashboardView-Ca89ME-z.js +1 -0
  11. package/dist/assets/DashboardWidgetInspector-DKZkel6E.js +1 -0
  12. package/dist/assets/{DeveloperHubPage-CB5nkyun.js → DeveloperHubPage-fRcSSqZS.js} +1 -1
  13. package/dist/assets/{ExpressionProvider-DKFCgLsJ.js → ExpressionProvider-CHhp2xGN.js} +1 -1
  14. package/dist/assets/FlowRunsPage-dkCyzr_z.js +1 -0
  15. package/dist/assets/{IntegrationsPage-8M_88h2y.js → IntegrationsPage-BsKw9532.js} +2 -2
  16. package/dist/assets/InterfaceListPage-BChUfRxQ.js +1 -0
  17. package/dist/assets/{ManagedByBadge-Bmg77Q4v.js → ManagedByBadge-By7dMA5p.js} +1 -1
  18. package/dist/assets/MarketplaceAccessDenied-BfvByBjR.js +1 -0
  19. package/dist/assets/{MarketplaceInstalledPage-BYXiUCpz.js → MarketplaceInstalledPage-DvncMfVp.js} +1 -1
  20. package/dist/assets/MarketplacePackagePage-BLKOlOvZ.js +4 -0
  21. package/dist/assets/MarketplacePage-Dkjj-Z_o.js +1 -0
  22. package/dist/assets/MetadataInspector-DXNojk_m.js +1 -0
  23. package/dist/assets/MetadataProvider-0eg8cMSY.js +1 -0
  24. package/dist/assets/{MonacoImpl-BsJjT9SV.js → MonacoImpl-VsaaS7Wx.js} +1 -1
  25. package/dist/assets/PageView-DCLMAUNP.js +1 -0
  26. package/dist/assets/{ProfilePage-SXmEEOn3.js → ProfilePage-D4gJzhqR.js} +1 -1
  27. package/dist/assets/{PublicFormsPage-aXes2XrW.js → PublicFormsPage-C46q0LJ_.js} +1 -1
  28. package/dist/assets/RecordDetailView-B11-8-pz.js +9 -0
  29. package/dist/assets/{RecordFormPage-C052nJig.js → RecordFormPage-CmfCTKov.js} +1 -1
  30. package/dist/assets/ReportDefaultInspector-CRLMz2jp.js +7 -0
  31. package/dist/assets/ReportView-B4fZ9FuM.js +2 -0
  32. package/dist/assets/{SearchResultsPage-DGuFKZit.js → SearchResultsPage-BjfVk8_a.js} +1 -1
  33. package/dist/assets/{SettingsHub-eYWWi8O5.js → SettingsHub-C_eMjvQA.js} +1 -1
  34. package/dist/assets/{SettingsView-Cq3IKOhI.js → SettingsView-BRVJ5Qgf.js} +1 -1
  35. package/dist/assets/SystemHubPage-X9aTvTMd.js +1 -0
  36. package/dist/assets/architecture-7EHR7CIX-X1S5OWmc.js +1 -0
  37. package/dist/assets/{architectureDiagram-3BPJPVTR-SscyJlk0.js → architectureDiagram-3BPJPVTR-MvRuEgzs.js} +1 -1
  38. package/dist/assets/assistantBus-BMrg1uLy.js +1 -0
  39. package/dist/assets/blockDiagram-GPEHLZMM-Bv7ki00F.js +132 -0
  40. package/dist/assets/{c4Diagram-AAUBKEIU-VLeNt7tD.js → c4Diagram-AAUBKEIU-BRUAUvfZ.js} +1 -1
  41. package/dist/assets/channel-BqPJ7J2_.js +1 -0
  42. package/dist/assets/{chunk-2J33WTMH-DyXQVMuc.js → chunk-2J33WTMH-DTuZqhEo.js} +1 -1
  43. package/dist/assets/{chunk-3OPIFGDE-3g0dk_di.js → chunk-3OPIFGDE-C_qRhnNp.js} +1 -1
  44. package/dist/assets/{chunk-4BX2VUAB-BpAZJ7ZC.js → chunk-4BX2VUAB-Curilu76.js} +1 -1
  45. package/dist/assets/chunk-55IACEB6-ClqERWh2.js +1 -0
  46. package/dist/assets/chunk-5ZQYHXKU-NIbfS0Mi.js +2 -0
  47. package/dist/assets/{chunk-727SXJPM-DwSFE_v-.js → chunk-727SXJPM-C9Y2Btvf.js} +1 -1
  48. package/dist/assets/{chunk-AQP2D5EJ-DWgSztUW.js → chunk-AQP2D5EJ-CtIyrl6v.js} +1 -1
  49. package/dist/assets/{chunk-BSJP7CBP-okvguKD4.js → chunk-BSJP7CBP-DjJyEH0K.js} +1 -1
  50. package/dist/assets/chunk-CSCIHK7Q-DbAqhmGo.js +124 -0
  51. package/dist/assets/{chunk-FMBD7UC4-CZzqt4RW.js → chunk-FMBD7UC4-DZ7XVMi3.js} +1 -1
  52. package/dist/assets/{chunk-KSCS5N6A-IxEh4Ag5.js → chunk-KSCS5N6A-DHHPqSRu.js} +2 -2
  53. package/dist/assets/{chunk-L5ZTLDWV-DW1lPBoG.js → chunk-L5ZTLDWV-Cm-9mVS5.js} +1 -1
  54. package/dist/assets/{chunk-LZXEDZCA-C_-aaYcd.js → chunk-LZXEDZCA-DNmRzWTq.js} +1 -1
  55. package/dist/assets/{chunk-ND2GUHAM-C1toj0H3.js → chunk-ND2GUHAM-D-GBTiNx.js} +1 -1
  56. package/dist/assets/{chunk-NZK2D7GU-H2MwBqQV.js → chunk-NZK2D7GU-CtXqakqk.js} +1 -1
  57. package/dist/assets/{chunk-O5CBEL6O-BzyWPZhZ.js → chunk-O5CBEL6O-B7H8dfmV.js} +3 -3
  58. package/dist/assets/chunk-QZHKN3VN-WFr5OVn5.js +1 -0
  59. package/dist/assets/chunk-WU5MYG2G-DKJgGIni.js +1 -0
  60. package/dist/assets/{chunk-XPW4576I-DPNxFY7Q.js → chunk-XPW4576I-BnrxXe1_.js} +1 -1
  61. package/dist/assets/classDiagram-4FO5ZUOK-WH7-26qH.js +1 -0
  62. package/dist/assets/classDiagram-v2-Q7XG4LA2-WH7-26qH.js +1 -0
  63. package/dist/assets/{cose-bilkent-S5V4N54A-HKJWDQRL.js → cose-bilkent-S5V4N54A-DhuYtQPb.js} +1 -1
  64. package/dist/assets/{dagre-BM42HDAG-CU8nx02l.js → dagre-BM42HDAG-Dnyz2UIF.js} +1 -1
  65. package/dist/assets/{data-adapter-CCidkDs3.js → data-adapter-DISUVKTH.js} +1 -1
  66. package/dist/assets/{diagram-2AECGRRQ-CormMz8j.js → diagram-2AECGRRQ-sHfykK_1.js} +1 -1
  67. package/dist/assets/{diagram-5GNKFQAL-Dh1SagBx.js → diagram-5GNKFQAL-CQPF5SyR.js} +1 -1
  68. package/dist/assets/{diagram-KO2AKTUF-DcG6Z05V.js → diagram-KO2AKTUF-DG_jPd_S.js} +1 -1
  69. package/dist/assets/{diagram-LMA3HP47-DrVLZ6ZE.js → diagram-LMA3HP47-eeIrBazE.js} +1 -1
  70. package/dist/assets/{diagram-OG6HWLK6-C4_MMUc2.js → diagram-OG6HWLK6-aTF20BV0.js} +1 -1
  71. package/dist/assets/{dist-DYcwLEm6.js → dist-D80kLFC3.js} +1 -1
  72. package/dist/assets/{erDiagram-TEJ5UH35-BZH_OrBL.js → erDiagram-TEJ5UH35-CZG8EC14.js} +1 -1
  73. package/dist/assets/eventmodeling-FCH6USID-y9LH0zSr.js +1 -0
  74. package/dist/assets/{flowDiagram-I6XJVG4X-CnjHQUK0.js → flowDiagram-I6XJVG4X-Dy6yH4qt.js} +1 -1
  75. package/dist/assets/framework-DI54pxGD.js +34 -0
  76. package/dist/assets/{ganttDiagram-6RSMTGT7-rVbHlqzo.js → ganttDiagram-6RSMTGT7-BbnAVyeg.js} +2 -2
  77. package/dist/assets/{gitGraph-WXDBUCRP-9vsQCBlr.js → gitGraph-WXDBUCRP-CWBdNpUZ.js} +1 -1
  78. package/dist/assets/{gitGraphDiagram-PVQCEYII-CH2LgClA.js → gitGraphDiagram-PVQCEYII-DQzVZDx1.js} +1 -1
  79. package/dist/assets/{highlighted-body-OFNGDK62-CKMBhexn.js → highlighted-body-OFNGDK62-13WB1hjG.js} +1 -1
  80. package/dist/assets/index-BnskSwad.css +2 -0
  81. package/dist/assets/index-Nsh10i14.js +4 -0
  82. package/dist/assets/{info-J43DQDTF-CfWeH1Bg.js → info-J43DQDTF-BT1tFy_c.js} +1 -1
  83. package/dist/assets/{infoDiagram-5YYISTIA-CRC7ojj-.js → infoDiagram-5YYISTIA-CL6j94aA.js} +1 -1
  84. package/dist/assets/infrastructure-BsIvKvpW.js +3 -0
  85. package/dist/assets/{ishikawaDiagram-YF4QCWOH-8v73fBR1.js → ishikawaDiagram-YF4QCWOH-B2te-ZRn.js} +1 -1
  86. package/dist/assets/{journeyDiagram-JHISSGLW-DbRK-WaU.js → journeyDiagram-JHISSGLW-lZExleN9.js} +1 -1
  87. package/dist/assets/{kanban-definition-UN3LZRKU-BggLxHvZ.js → kanban-definition-UN3LZRKU-C9AtY5D5.js} +1 -1
  88. package/dist/assets/{marketplaceApi-CucX7DD9.js → marketplaceApi-DL8PegzV.js} +1 -1
  89. package/dist/assets/mermaid-GHXKKRXX-CnMh6H1N.js +1 -0
  90. package/dist/assets/{mermaid-parser.core-iuxcj-n_.js → mermaid-parser.core-Fbhy6q19.js} +1 -1
  91. package/dist/assets/mermaid.core-X9A0zXAG.js +8 -0
  92. package/dist/assets/metadata-admin-BI5ITi-1.js +21 -0
  93. package/dist/assets/{mindmap-definition-RKZ34NQL-kqhi9XCR.js → mindmap-definition-RKZ34NQL-BLNposyO.js} +1 -1
  94. package/dist/assets/{packet-YPE3B663-C0xexAqH.js → packet-YPE3B663-2eu0wHWY.js} +1 -1
  95. package/dist/assets/{pie-LRSECV5Y-DbQVOiyX.js → pie-LRSECV5Y-BA_jHDuN.js} +1 -1
  96. package/dist/assets/{pieDiagram-4H26LBE5-9fHcPmFE.js → pieDiagram-4H26LBE5-B_jWIggY.js} +3 -3
  97. package/dist/assets/plugin-calendar--KxXPKcZ.js +1 -0
  98. package/dist/assets/plugin-charts-BtGgj50F.js +7 -0
  99. package/dist/assets/{plugin-chatbot-BpAQS7-q.js → plugin-chatbot-BnXRjqnw.js} +53 -53
  100. package/dist/assets/plugin-dashboard-BJU4e4Lc.js +6 -0
  101. package/dist/assets/plugin-form-CfWEBrxU.js +1 -0
  102. package/dist/assets/plugin-gantt-DWE_Yo3S.js +39 -0
  103. package/dist/assets/plugin-grid-MJIEbrKE.js +6 -0
  104. package/dist/assets/plugin-kanban-CuXc4XOR.js +1 -0
  105. package/dist/assets/{plugin-map-DG62gl97.js → plugin-map-BJaiEhqS.js} +1 -1
  106. package/dist/assets/{plugin-markdown-BL0QvMCD.js → plugin-markdown-5mHDCnjJ.js} +1 -1
  107. package/dist/assets/plugin-report-DXVbwZO1.js +59 -0
  108. package/dist/assets/{plugin-timeline-dBrX3lS3.js → plugin-timeline-CRg278ig.js} +1 -1
  109. package/dist/assets/plugin-tree-D3iB5Xsc.js +1 -0
  110. package/dist/assets/plugin-view-DuycwTEq.js +1 -0
  111. package/dist/assets/plugins-views-FDlQfg4L.js +4 -0
  112. package/dist/assets/{quadrantDiagram-W4KKPZXB-CaMxia_k.js → quadrantDiagram-W4KKPZXB-DuQbsXa3.js} +1 -1
  113. package/dist/assets/{radar-GUYGQ44K-DapGfmwo.js → radar-GUYGQ44K-BdSwem6Q.js} +1 -1
  114. package/dist/assets/{requirementDiagram-4Y6WPE33-CXwY4Gdd.js → requirementDiagram-4Y6WPE33-BS1D5lNA.js} +1 -1
  115. package/dist/assets/{sankeyDiagram-5OEKKPKP-KEb3hSPZ.js → sankeyDiagram-5OEKKPKP-DGvgs5mF.js} +2 -2
  116. package/dist/assets/{sequenceDiagram-3UESZ5HK-BfbOOh3M.js → sequenceDiagram-3UESZ5HK-CoXT3Sa8.js} +1 -1
  117. package/dist/assets/{skeletons-BK7w4pLE.js → skeletons-CCMkzfAg.js} +1 -1
  118. package/dist/assets/{src-Czx03pos.js → src-BTw3UGh8.js} +1 -1
  119. package/dist/assets/{src-CVz7aDdY.js → src-B_91OByQ.js} +1 -1
  120. package/dist/assets/src-KdhDBRhc.js +2 -0
  121. package/dist/assets/{stateDiagram-AJRCARHV-BLJI6xj_.js → stateDiagram-AJRCARHV-CGBlOS6N.js} +1 -1
  122. package/dist/assets/stateDiagram-v2-BHNVJYJU-B7qRtpsa.js +1 -0
  123. package/dist/assets/{timeline-definition-PNZ67QCA-aiklZXLq.js → timeline-definition-PNZ67QCA-C3SxX0_p.js} +1 -1
  124. package/dist/assets/{treeView-BLDUP644-Byr_7ESV.js → treeView-BLDUP644-LYooC8jV.js} +1 -1
  125. package/dist/assets/{treemap-LRROVOQU-B6DiJnlo.js → treemap-LRROVOQU-DRMY684K.js} +1 -1
  126. package/dist/assets/{types-C2_UYDEK.js → types-BXXHtG0t.js} +1 -1
  127. package/dist/assets/ui-components-BecTKcFn.js +42 -0
  128. package/dist/assets/ui-layout-BG3TnLjr.js +1 -0
  129. package/dist/assets/useActionModal-DezoqP6c.js +1 -0
  130. package/dist/assets/useOpenRecordList-DjbGsO2B.js +1 -0
  131. package/dist/assets/{usePackageL10n-shLsxEAx.js → usePackageL10n-DIEe85Ot.js} +1 -1
  132. package/dist/assets/useReconcileOnError-Df2Wf71r.js +1 -0
  133. package/dist/assets/vendor-charts-BMpO4zwC.js +39 -0
  134. package/dist/assets/{vendor-dndkit-DMFEUxSy.js → vendor-dndkit-CJ-mJJuO.js} +1 -1
  135. package/dist/assets/{vendor-i18n-Bz5UncqE.js → vendor-i18n-DA5MKfC_.js} +1 -1
  136. package/dist/assets/{vendor-icons-core-C_yMA5lO.js → vendor-icons-core-y1IwBwLD.js} +1 -1
  137. package/dist/assets/{vendor-markdown-CyAGIM8D.js → vendor-markdown-BhPWU2N7.js} +1 -1
  138. package/dist/assets/vendor-objectstack-CMEER4tu.js +96 -0
  139. package/dist/assets/vendor-radix-90T7eS-d.js +46 -0
  140. package/dist/assets/vendor-react-ClIa1CJA.js +11 -0
  141. package/dist/assets/vendor-sentry-DUcsR3Vf.js +501 -0
  142. package/dist/assets/{vendor-ui-utils-rQOI1gAo.js → vendor-ui-utils-C92Fl7BT.js} +1 -1
  143. package/dist/assets/{vennDiagram-CIIHVFJN-DsKC4yvC.js → vennDiagram-CIIHVFJN-BWIbAw03.js} +1 -1
  144. package/dist/assets/{wardley-L42UT6IY-f1iiSYpj.js → wardley-L42UT6IY-zPLhQ1bd.js} +1 -1
  145. package/dist/assets/{wardleyDiagram-YWT4CUSO-DbrUmWlY.js → wardleyDiagram-YWT4CUSO-Ck_J2TTN.js} +1 -1
  146. package/dist/assets/{xychartDiagram-2RQKCTM6-B4biX1Sz.js → xychartDiagram-2RQKCTM6-CDqp4wV0.js} +2 -2
  147. package/dist/index.html +6 -6
  148. package/package.json +1 -1
  149. package/dist/assets/AdapterProvider-DJb3ZVmJ.js +0 -1
  150. package/dist/assets/ApprovalsInboxPage-Dym3zM3t.js +0 -1
  151. package/dist/assets/ConsoleFloatingChatbot-_UeVODsx.js +0 -1
  152. package/dist/assets/DashboardView-kL9_gMzd.js +0 -1
  153. package/dist/assets/DashboardWidgetInspector-BN8Yy27Q.js +0 -1
  154. package/dist/assets/FlowRunsPage-65yB_BWO.js +0 -1
  155. package/dist/assets/InterfaceListPage-CBomrdcf.js +0 -1
  156. package/dist/assets/MarketplaceAccessDenied-CX0RbkOJ.js +0 -1
  157. package/dist/assets/MarketplacePackagePage-C8yVjW5r.js +0 -4
  158. package/dist/assets/MarketplacePage-pVW-NfrG.js +0 -1
  159. package/dist/assets/MetadataInspector-CACgSTc7.js +0 -1
  160. package/dist/assets/MetadataProvider-Dh20h6BN.js +0 -1
  161. package/dist/assets/PageView-D388xYQA.js +0 -1
  162. package/dist/assets/RecentItemsProvider-B76qldBH.js +0 -1
  163. package/dist/assets/RecordDetailView-DIiHv2mR.js +0 -1
  164. package/dist/assets/ReportDefaultInspector-CjR-PcBn.js +0 -1
  165. package/dist/assets/ReportView-M_mx8mgW.js +0 -2
  166. package/dist/assets/RuntimeDraftBar-DTf-DIfT.js +0 -1
  167. package/dist/assets/SystemHubPage-6FccxnKY.js +0 -1
  168. package/dist/assets/architecture-7EHR7CIX-BdMnUPE0.js +0 -1
  169. package/dist/assets/blockDiagram-GPEHLZMM-D6-9deBJ.js +0 -132
  170. package/dist/assets/channel-ByUUDCyR.js +0 -1
  171. package/dist/assets/chunk-55IACEB6-BhOjfCrn.js +0 -1
  172. package/dist/assets/chunk-5ZQYHXKU-DG12s6lW.js +0 -2
  173. package/dist/assets/chunk-CSCIHK7Q-DfSAlgJl.js +0 -124
  174. package/dist/assets/chunk-QZHKN3VN-ujroCBCz.js +0 -1
  175. package/dist/assets/chunk-WU5MYG2G-DwQt8tuZ.js +0 -1
  176. package/dist/assets/classDiagram-4FO5ZUOK-B7mTyEXp.js +0 -1
  177. package/dist/assets/classDiagram-v2-Q7XG4LA2-B7mTyEXp.js +0 -1
  178. package/dist/assets/eventmodeling-FCH6USID-CFiyy8DS.js +0 -1
  179. package/dist/assets/framework-BLEk-ou3.js +0 -34
  180. package/dist/assets/index-A8r_lURn.js +0 -4
  181. package/dist/assets/index-BGyrRTzt.css +0 -2
  182. package/dist/assets/infrastructure-CJNwTVno.js +0 -3
  183. package/dist/assets/mergeServerFields-CMIOI8QD.js +0 -7
  184. package/dist/assets/mermaid-GHXKKRXX-C3g3SOag.js +0 -1
  185. package/dist/assets/mermaid.core-C41Aiku8.js +0 -8
  186. package/dist/assets/metadata-admin-ORqaeHUJ.js +0 -19
  187. package/dist/assets/plugin-calendar-Czocnijo.js +0 -1
  188. package/dist/assets/plugin-charts-dCyWH9k8.js +0 -7
  189. package/dist/assets/plugin-dashboard-CjtE0zwv.js +0 -5
  190. package/dist/assets/plugin-form-Dzz6GAZM.js +0 -1
  191. package/dist/assets/plugin-gantt-BedjcmIc.js +0 -23
  192. package/dist/assets/plugin-grid-BqmF7p-H.js +0 -6
  193. package/dist/assets/plugin-kanban-Dq0xJjXt.js +0 -1
  194. package/dist/assets/plugin-report-DckNGNq6.js +0 -59
  195. package/dist/assets/plugin-view-DCPYomdU.js +0 -1
  196. package/dist/assets/plugins-views-B-EGcBP2.js +0 -4
  197. package/dist/assets/resolveActionParams-B_7wSkli.js +0 -9
  198. package/dist/assets/src-9qM7N8MR.js +0 -2
  199. package/dist/assets/stateDiagram-v2-BHNVJYJU-DPQJ1_JB.js +0 -1
  200. package/dist/assets/ui-components-NS_7__gn.js +0 -42
  201. package/dist/assets/ui-layout-BdKOzi1L.js +0 -1
  202. package/dist/assets/useActionModal-BE61500N.js +0 -1
  203. package/dist/assets/useReconcileOnError-Cvd01WQv.js +0 -1
  204. package/dist/assets/vendor-charts-fo4ZbB_t.js +0 -39
  205. package/dist/assets/vendor-objectstack-BNd856rx.js +0 -96
  206. package/dist/assets/vendor-radix-CSVEhP0L.js +0 -56
  207. package/dist/assets/vendor-react-DR370ovB.js +0 -11
  208. package/dist/assets/vendor-sentry-BIOhD5Kg.js +0 -501
@@ -1,46 +1,46 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as a,g as o,m as s,t as c}from"./vendor-react-DR370ovB.js";import{B as l,ht as u,r as d}from"./framework-BLEk-ou3.js";import{A as f,C as p,D as m,E as h,F as g,I as _,L as v,M as y,N as b,R as x,S,T as C,b as w,j as T,k as E,w as D,x as ee,y as O}from"./vendor-objectstack-BNd856rx.js";import{$n as te,At as ne,B as re,Cr as ie,Ds as ae,Fi as oe,Ft as se,Gn as ce,Gt as le,H as ue,It as de,Jn as fe,Jo as pe,Js as me,Kt as he,Lt as ge,Ma as _e,Mt as ve,Os as ye,Ot as be,Po as xe,Pt as Se,Qi as Ce,R as we,Rr as Te,Rt as Ee,Sr as De,Ta as Oe,Ui as ke,Un as Ae,Us as je,V as Me,Wn as Ne,Xa as Pe,Xn as k,Ya as Fe,Yn as Ie,Yo as Le,Zn as Re,_s as ze,ac as Be,an as Ve,at as He,ba as Ue,cc as We,cn as Ge,co as Ke,cs as qe,ct as Je,dt as Ye,er as Xe,gi as Ze,gn as Qe,gs as $e,hr as A,ii as et,in as tt,ir as nt,is as rt,it,ji as at,jt as ot,kt as st,lt as ct,nn as lt,nr as ut,nt as dt,on as ft,ot as pt,pc as j,qn as mt,qs as ht,rn as gt,rr as _t,rs as vt,sn as yt,ss as bt,st as xt,tr as St,tt as Ct,un as wt,ut as Tt,xi as Et,ys as Dt,z as Ot,zt as kt}from"./ui-components-NS_7__gn.js";import{a as At,i as jt,o as Mt}from"./vendor-ui-utils-rQOI1gAo.js";import{Tn as Nt}from"./vendor-radix-CSVEhP0L.js";import{t as M}from"./vendor-zod-BzP-Jkm3.js";import{_ as Pt,b as Ft,c as It,d as Lt,f as Rt,g as zt,h as Bt,l as Vt,m as Ht,p as Ut,s as Wt,u as Gt,v as Kt,y as qt}from"./vendor-markdown-CyAGIM8D.js";var Jt=`vercel.ai.error`,Yt=Symbol.for(Jt),Xt,Zt,Qt=class e extends (Zt=Error,Xt=Yt,Zt){constructor({name:e,message:t,cause:n}){super(t),this[Xt]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Jt)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};function $t(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var en=`AI_InvalidArgumentError`,tn=`vercel.ai.error.${en}`,nn=Symbol.for(tn),rn,an,on=class extends (an=Qt,rn=nn,an){constructor({message:e,cause:t,argument:n}){super({name:en,message:e,cause:t}),this[rn]=!0,this.argument=n}static isInstance(e){return Qt.hasMarker(e,tn)}},sn=`AI_JSONParseError`,cn=`vercel.ai.error.${sn}`,ln=Symbol.for(cn),un,dn,fn=class extends (dn=Qt,un=ln,dn){constructor({text:e,cause:t}){super({name:sn,message:`JSON parsing failed: Text: ${e}.
2
- Error message: ${$t(t)}`,cause:t}),this[un]=!0,this.text=e}static isInstance(e){return Qt.hasMarker(e,cn)}},pn=`AI_TypeValidationError`,mn=`vercel.ai.error.${pn}`,hn=Symbol.for(mn),gn,_n,vn=class e extends (_n=Qt,gn=hn,_n){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:pn,message:`${r}: Value: ${JSON.stringify(e)}.
3
- Error message: ${$t(t)}`,cause:t}),this[gn]=!0,this.value=e,this.context=n}static isInstance(e){return Qt.hasMarker(e,mn)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},yn=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},bn=10,xn=13,Sn=32;function Cn(e){}function wn(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Cn,onError:n=Cn,onRetry:r=Cn,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
4
- `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new yn(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
1
+ import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as a,g as o,m as s,t as c}from"./vendor-react-ClIa1CJA.js";import{Ct as l,H as u,i as d}from"./framework-DI54pxGD.js";import{A as f,C as p,D as m,E as h,F as g,I as _,L as v,M as y,N as b,R as x,S,T as C,b as w,j as T,k as E,w as D,x as ee,y as O}from"./vendor-objectstack-CMEER4tu.js";import{$a as te,$i as ne,$o as re,$r as ie,$s as ae,At as oe,B as se,Br as ce,Cr as le,Da as ue,Ft as de,Gn as fe,Gt as pe,H as me,Ii as he,It as ge,Jn as _e,Js as ve,Kn as ye,Kt as be,Lt as xe,Mi as Se,Ms as Ce,Mt as we,Ns as Te,Ot as Ee,Pa as De,Pt as Oe,Qn as ke,Qs as Ae,R as je,Ro as Me,Rt as Ne,Si as Pe,Ss as Fe,V as Ie,Wi as Le,Wn as Re,Xn as ze,Yn as Be,Zn as Ve,_i as He,ai as Ue,an as We,ar as Ge,at as Ke,cn as qe,cs as Je,ct as k,dc as Ye,ds as Xe,dt as Ze,er as Qe,es as $e,fo as et,fs as tt,gn as nt,gr as A,gs as rt,in as it,ir as at,it as ot,jt as st,kt as ct,ls as lt,lt as ut,mc as dt,nn as ft,nr as pt,nt as mt,on as ht,ot as gt,ps as _t,rn as vt,rr as yt,sn as bt,st as xt,to as St,tr as Ct,tt as wt,un as Tt,ut as Et,wr as Dt,ws as Ot,xa as kt,xs as At,yc as j,z as jt,zt as Mt}from"./ui-components-BecTKcFn.js";import{a as Nt,i as Pt,o as Ft}from"./vendor-ui-utils-C92Fl7BT.js";import{Tn as It}from"./vendor-radix-90T7eS-d.js";import{t as M}from"./vendor-zod-BzP-Jkm3.js";import{_ as Lt,b as Rt,c as zt,d as Bt,f as Vt,g as Ht,h as Ut,l as Wt,m as Gt,p as Kt,s as qt,u as Jt,v as Yt,y as Xt}from"./vendor-markdown-BhPWU2N7.js";var Zt=`vercel.ai.error`,Qt=Symbol.for(Zt),$t,en,tn=class e extends (en=Error,$t=Qt,en){constructor({name:e,message:t,cause:n}){super(t),this[$t]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Zt)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};function nn(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var rn=`AI_InvalidArgumentError`,an=`vercel.ai.error.${rn}`,on=Symbol.for(an),sn,cn,ln=class extends (cn=tn,sn=on,cn){constructor({message:e,cause:t,argument:n}){super({name:rn,message:e,cause:t}),this[sn]=!0,this.argument=n}static isInstance(e){return tn.hasMarker(e,an)}},un=`AI_JSONParseError`,dn=`vercel.ai.error.${un}`,fn=Symbol.for(dn),pn,mn,hn=class extends (mn=tn,pn=fn,mn){constructor({text:e,cause:t}){super({name:un,message:`JSON parsing failed: Text: ${e}.
2
+ Error message: ${nn(t)}`,cause:t}),this[pn]=!0,this.text=e}static isInstance(e){return tn.hasMarker(e,dn)}},gn=`AI_TypeValidationError`,_n=`vercel.ai.error.${gn}`,vn=Symbol.for(_n),yn,bn,xn=class e extends (bn=tn,yn=vn,bn){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:gn,message:`${r}: Value: ${JSON.stringify(e)}.
3
+ Error message: ${nn(t)}`,cause:t}),this[yn]=!0,this.value=e,this.context=n}static isInstance(e){return tn.hasMarker(e,_n)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},Sn=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},Cn=10,wn=13,Tn=32;function En(e){}function Dn(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=En,onError:n=En,onRetry:r=En,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
4
+ `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new Sn(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
5
5
  `,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
6
- `,n);continue}let i=e.charCodeAt(n);if(Tn(e,n,i)){let i=e.charCodeAt(n+5)===Sn?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===bn){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
6
+ `,n);continue}let i=e.charCodeAt(n);if(On(e,n,i)){let i=e.charCodeAt(n+5)===Tn?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===Cn){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
7
7
  `,n);continue}u=d===0?a:`${u}
8
- ${a}`,d++}else En(e,n,i)?f=e.slice(e.charCodeAt(n+6)===Sn?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
8
+ ${a}`,d++}else kn(e,n,i)?f=e.slice(e.charCodeAt(n+6)===Tn?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
9
9
  `,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
10
- `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===xn&&e.charCodeAt(n)===bn&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(Tn(e,t,r)){let r=e.charCodeAt(t+5)===Sn?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
11
- ${i}`,d++;return}if(En(e,t,r)){f=e.slice(e.charCodeAt(t+6)===Sn?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===Sn?t+4:t+3,n);l=r.includes(`\0`)?void 0:r;return}if(r===58){i&&i(e.slice(t,n).slice(e.charCodeAt(t+1)===Sn?2:1));return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===Sn?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
12
- ${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new yn(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new yn(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function Tn(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function En(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Dn=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=wn({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}},{btoa:On,atob:kn}=globalThis,An=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new on({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},jn=An();function Mn(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var Nn=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Pn=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Fn(e){let t=JSON.parse(e);return typeof t!=`object`||!t||Nn.test(e)===!1&&Pn.test(e)===!1?t:In(t)}function In(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function Ln(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Fn(e)}try{return Fn(e)}finally{Error.stackTraceLimit=t}}function Rn(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){e.additionalProperties=!1;let{properties:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=zn(t[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(zn):zn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(zn)),e.allOf!=null&&(e.allOf=e.allOf.map(zn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(zn));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=zn(t[e]);return e}function zn(e){return typeof e==`boolean`?e:Rn(e)}var Bn=Symbol(`Let zodToJsonSchema decide on which parser to use`),Vn={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},Hn=e=>typeof e==`string`?{...Vn,name:e}:{...Vn,...e};function Un(){return{}}function Wn(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==M.ZodAny&&(n.items=N(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function Gn(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function Kn(){return{type:`boolean`}}function qn(e,t){return N(e.type._def,t)}var Jn=(e,t)=>N(e.innerType._def,t);function Yn(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Yn(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Xn(e)}}var Xn=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value;break}return t};function Zn(e,t){return{...N(e.innerType._def,t),default:e.defaultValue()}}function Qn(e,t){return t.effectStrategy===`input`?N(e.schema._def,t):Un()}function $n(e){return{type:`string`,enum:Array.from(e.values)}}var er=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function tr(e,t){let n=[N(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),N(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(er(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function nr(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var rr=void 0,ir={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(rr===void 0&&(rr=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),rr),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ar(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:lr(n,`email`,r.message,t);break;case`format:idn-email`:lr(n,`idn-email`,r.message,t);break;case`pattern:zod`:ur(n,ir.email,r.message,t);break}break;case`url`:lr(n,`uri`,r.message,t);break;case`uuid`:lr(n,`uuid`,r.message,t);break;case`regex`:ur(n,r.regex,r.message,t);break;case`cuid`:ur(n,ir.cuid,r.message,t);break;case`cuid2`:ur(n,ir.cuid2,r.message,t);break;case`startsWith`:ur(n,RegExp(`^${or(r.value,t)}`),r.message,t);break;case`endsWith`:ur(n,RegExp(`${or(r.value,t)}$`),r.message,t);break;case`datetime`:lr(n,`date-time`,r.message,t);break;case`date`:lr(n,`date`,r.message,t);break;case`time`:lr(n,`time`,r.message,t);break;case`duration`:lr(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:ur(n,RegExp(or(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&lr(n,`ipv4`,r.message,t),r.version!==`v4`&&lr(n,`ipv6`,r.message,t);break;case`base64url`:ur(n,ir.base64url,r.message,t);break;case`jwt`:ur(n,ir.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&ur(n,ir.ipv4Cidr,r.message,t),r.version!==`v4`&&ur(n,ir.ipv6Cidr,r.message,t);break;case`emoji`:ur(n,ir.emoji(),r.message,t);break;case`ulid`:ur(n,ir.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:lr(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:ur(n,ir.base64,r.message,t);break}break;case`nanoid`:ur(n,ir.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:}return n}function or(e,t){return t.patternStrategy===`escape`?cr(e):e}var sr=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function cr(e){let t=``;for(let n=0;n<e.length;n++)sr.has(e[n])||(t+=`\\`),t+=e[n];return t}function lr(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function ur(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:dr(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=dr(t,r)}function dr(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
10
+ `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===wn&&e.charCodeAt(n)===Cn&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(On(e,t,r)){let r=e.charCodeAt(t+5)===Tn?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
11
+ ${i}`,d++;return}if(kn(e,t,r)){f=e.slice(e.charCodeAt(t+6)===Tn?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===Tn?t+4:t+3,n);l=r.includes(`\0`)?void 0:r;return}if(r===58){i&&i(e.slice(t,n).slice(e.charCodeAt(t+1)===Tn?2:1));return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===Tn?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
12
+ ${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Sn(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Sn(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function On(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function kn(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var An=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=Dn({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}},{btoa:jn,atob:Mn}=globalThis,Nn=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new ln({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},Pn=Nn();function Fn(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var In=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Ln=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Rn(e){let t=JSON.parse(e);return typeof t!=`object`||!t||In.test(e)===!1&&Ln.test(e)===!1?t:zn(t)}function zn(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function Bn(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Rn(e)}try{return Rn(e)}finally{Error.stackTraceLimit=t}}function Vn(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){e.additionalProperties=!1;let{properties:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Hn(t[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Hn):Hn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Hn)),e.allOf!=null&&(e.allOf=e.allOf.map(Hn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Hn));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Hn(t[e]);return e}function Hn(e){return typeof e==`boolean`?e:Vn(e)}var Un=Symbol(`Let zodToJsonSchema decide on which parser to use`),Wn={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},Gn=e=>typeof e==`string`?{...Wn,name:e}:{...Wn,...e};function Kn(){return{}}function qn(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==M.ZodAny&&(n.items=N(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function Jn(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function Yn(){return{type:`boolean`}}function Xn(e,t){return N(e.type._def,t)}var Zn=(e,t)=>N(e.innerType._def,t);function Qn(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Qn(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return $n(e)}}var $n=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value;break}return t};function er(e,t){return{...N(e.innerType._def,t),default:e.defaultValue()}}function tr(e,t){return t.effectStrategy===`input`?N(e.schema._def,t):Kn()}function nr(e){return{type:`string`,enum:Array.from(e.values)}}var rr=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function ir(e,t){let n=[N(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),N(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(rr(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function ar(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var or=void 0,sr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(or===void 0&&(or=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),or),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function cr(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:fr(n,`email`,r.message,t);break;case`format:idn-email`:fr(n,`idn-email`,r.message,t);break;case`pattern:zod`:pr(n,sr.email,r.message,t);break}break;case`url`:fr(n,`uri`,r.message,t);break;case`uuid`:fr(n,`uuid`,r.message,t);break;case`regex`:pr(n,r.regex,r.message,t);break;case`cuid`:pr(n,sr.cuid,r.message,t);break;case`cuid2`:pr(n,sr.cuid2,r.message,t);break;case`startsWith`:pr(n,RegExp(`^${lr(r.value,t)}`),r.message,t);break;case`endsWith`:pr(n,RegExp(`${lr(r.value,t)}$`),r.message,t);break;case`datetime`:fr(n,`date-time`,r.message,t);break;case`date`:fr(n,`date`,r.message,t);break;case`time`:fr(n,`time`,r.message,t);break;case`duration`:fr(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:pr(n,RegExp(lr(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&fr(n,`ipv4`,r.message,t),r.version!==`v4`&&fr(n,`ipv6`,r.message,t);break;case`base64url`:pr(n,sr.base64url,r.message,t);break;case`jwt`:pr(n,sr.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&pr(n,sr.ipv4Cidr,r.message,t),r.version!==`v4`&&pr(n,sr.ipv6Cidr,r.message,t);break;case`emoji`:pr(n,sr.emoji(),r.message,t);break;case`ulid`:pr(n,sr.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:fr(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:pr(n,sr.base64,r.message,t);break}break;case`nanoid`:pr(n,sr.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:}return n}function lr(e,t){return t.patternStrategy===`escape`?dr(e):e}var ur=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function dr(e){let t=``;for(let n=0;n<e.length;n++)ur.has(e[n])||(t+=`\\`),t+=e[n];return t}function fr(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function pr(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:mr(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=mr(t,r)}function mr(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
13
13
  ]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
14
14
  ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r
15
15
  `:`[${r[e]}\r
16
- ]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function fr(e,t){let n={type:`object`,additionalProperties:N(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===M.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=ar(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===M.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===M.ZodBranded&&e.keyType._def.type._def.typeName===M.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=qn(e.keyType._def,t);return{...n,propertyNames:i}}return n}function pr(e,t){return t.mapStrategy===`record`?fr(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[N(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Un(),N(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Un()],minItems:2,maxItems:2}}}function mr(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function hr(){return{not:Un()}}function gr(){return{type:`null`}}var _r={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function vr(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in _r&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=_r[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return yr(e,t)}var yr=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>N(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function br(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[_r[e.innerType._def.typeName],`null`]};let n=N(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function xr(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function Sr(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=wr(a),s=N(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=Cr(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Cr(e,t){if(e.catchall._def.typeName!==`ZodNever`)return N(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function wr(e){try{return e.isOptional()}catch{return!0}}var Tr=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return N(e.innerType._def,t);let n=N(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Un()},n]}:Un()},Er=(e,t)=>{if(t.pipeStrategy===`input`)return N(e.in._def,t);if(t.pipeStrategy===`output`)return N(e.out._def,t);let n=N(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,N(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Dr(e,t){return N(e.type._def,t)}function Or(e,t){let n={type:`array`,uniqueItems:!0,items:N(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function kr(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>N(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:N(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>N(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Ar(){return{not:Un()}}function jr(){return Un()}var Mr=(e,t)=>N(e.innerType._def,t),Nr=(e,t,n)=>{switch(t){case M.ZodString:return ar(e,n);case M.ZodNumber:return xr(e);case M.ZodObject:return Sr(e,n);case M.ZodBigInt:return Gn(e);case M.ZodBoolean:return Kn();case M.ZodDate:return Yn(e,n);case M.ZodUndefined:return Ar();case M.ZodNull:return gr();case M.ZodArray:return Wn(e,n);case M.ZodUnion:case M.ZodDiscriminatedUnion:return vr(e,n);case M.ZodIntersection:return tr(e,n);case M.ZodTuple:return kr(e,n);case M.ZodRecord:return fr(e,n);case M.ZodLiteral:return nr(e);case M.ZodEnum:return $n(e);case M.ZodNativeEnum:return mr(e);case M.ZodNullable:return br(e,n);case M.ZodOptional:return Tr(e,n);case M.ZodMap:return pr(e,n);case M.ZodSet:return Or(e,n);case M.ZodLazy:return()=>e.getter()._def;case M.ZodPromise:return Dr(e,n);case M.ZodNaN:case M.ZodNever:return hr();case M.ZodEffects:return Qn(e,n);case M.ZodAny:return Un();case M.ZodUnknown:return jr();case M.ZodDefault:return Zn(e,n);case M.ZodBranded:return qn(e,n);case M.ZodReadonly:return Mr(e,n);case M.ZodCatch:return Jn(e,n);case M.ZodPipeline:return Er(e,n);case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:return;default:return(e=>void 0)(t)}},Pr=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function N(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==Bn)return i}if(r&&!n){let e=Fr(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Nr(e,e.typeName,t),o=typeof a==`function`?N(a(),t):a;if(o&&Ir(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Fr=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Pr(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Un()):t.$refStrategy===`seen`?Un():void 0}},Ir=(e,t,n)=>(e.description&&(n.description=e.description),n),Lr=e=>{let t=Hn(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Rr=(e,t)=>{let n=Lr(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:N(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Un()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=N(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Un(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},zr=Symbol.for(`vercel.ai.schema`);function Br(e){let t;return()=>(t??=e(),t)}function Vr(e,{validate:t}={}){return{[zr]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Hr(e){return typeof e==`object`&&!!e&&zr in e&&e[zr]===!0&&`jsonSchema`in e&&`validate`in e}function Ur(e){return e==null?Vr({properties:{},additionalProperties:!1}):Hr(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?Jr(e):Wr(e):e()}function Wr(e){return Vr(()=>Rn(e[`~standard`].jsonSchema.input({target:`draft-07`})),{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new vn({value:t,cause:n.issues})}}})}function Gr(e,t){let n=t?.useReferences??!1;return Vr(()=>Rr(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Kr(e,t){let n=t?.useReferences??!1;return Vr(()=>Rn(x(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await v(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function qr(e){return`_zod`in e}function Jr(e,t){return qr(e)?Kr(e,t):Gr(e,t)}async function Yr({value:e,schema:t,context:n}){let r=await Xr({value:e,schema:t,context:n});if(!r.success)throw vn.wrap({value:e,cause:r.error,context:n});return r.value}async function Xr({value:e,schema:t,context:n}){let r=Ur(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:vn.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:vn.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function Zr({text:e,schema:t}){try{let n=Ln(e);return t==null?{success:!0,value:n,rawValue:n}:await Xr({value:n,schema:t})}catch(t){return{success:!1,error:fn.isInstance(t)?t:new fn({text:e,cause:t}),rawValue:void 0}}}function Qr({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Dn).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await Zr({text:e,schema:t}))}}))}async function $r(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var ei=Object.defineProperty,ti=(e,t)=>{for(var n in t)ei(e,n,{get:t[n],enumerable:!0})},ni=`AI_NoObjectGeneratedError`,ri=`vercel.ai.error.${ni}`,ii=Symbol.for(ri),ai,oi=class extends Qt{constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:ni,message:e,cause:t}),this[ai]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return Qt.hasMarker(e,ri)}};ai=ii;var si=`AI_UIMessageStreamError`,ci=`vercel.ai.error.${si}`,li=Symbol.for(ci),ui,di=class extends Qt{constructor({chunkType:e,chunkId:t,message:n}){super({name:si,message:n}),this[ui]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Qt.hasMarker(e,ci)}};ui=li;var fi=g([b(),w(Uint8Array),w(ArrayBuffer),D(e=>globalThis.Buffer?.isBuffer(e)??!1,{message:`Must be a Buffer`})]),pi=h(()=>g([ee(),b(),E(),p(),T(b(),pi.optional()),S(pi)])),P=T(b(),T(b(),pi.optional())),mi=f({type:m(`text`),text:b(),providerOptions:P.optional()}),hi=f({type:m(`image`),image:g([fi,w(URL)]),mediaType:b().optional(),providerOptions:P.optional()}),gi=f({type:m(`file`),data:g([fi,w(URL)]),filename:b().optional(),mediaType:b(),providerOptions:P.optional()}),_i=f({type:m(`reasoning`),text:b(),providerOptions:P.optional()}),vi=f({type:m(`tool-call`),toolCallId:b(),toolName:b(),input:_(),providerOptions:P.optional(),providerExecuted:p().optional()}),yi=C(`type`,[f({type:m(`text`),value:b(),providerOptions:P.optional()}),f({type:m(`json`),value:pi,providerOptions:P.optional()}),f({type:m(`execution-denied`),reason:b().optional(),providerOptions:P.optional()}),f({type:m(`error-text`),value:b(),providerOptions:P.optional()}),f({type:m(`error-json`),value:pi,providerOptions:P.optional()}),f({type:m(`content`),value:S(g([f({type:m(`text`),text:b(),providerOptions:P.optional()}),f({type:m(`media`),data:b(),mediaType:b()}),f({type:m(`file-data`),data:b(),mediaType:b(),filename:b().optional(),providerOptions:P.optional()}),f({type:m(`file-url`),url:b(),providerOptions:P.optional()}),f({type:m(`file-id`),fileId:g([b(),T(b(),b())]),providerOptions:P.optional()}),f({type:m(`image-data`),data:b(),mediaType:b(),providerOptions:P.optional()}),f({type:m(`image-url`),url:b(),providerOptions:P.optional()}),f({type:m(`image-file-id`),fileId:g([b(),T(b(),b())]),providerOptions:P.optional()}),f({type:m(`custom`),providerOptions:P.optional()})]))})]),bi=f({type:m(`tool-result`),toolCallId:b(),toolName:b(),output:yi,providerOptions:P.optional()}),xi=f({type:m(`tool-approval-request`),approvalId:b(),toolCallId:b()}),Si=f({type:m(`tool-approval-response`),approvalId:b(),approved:p(),reason:b().optional()});g([f({role:m(`system`),content:b(),providerOptions:P.optional()}),f({role:m(`user`),content:g([b(),S(g([mi,hi,gi]))]),providerOptions:P.optional()}),f({role:m(`assistant`),content:g([b(),S(g([mi,gi,_i,vi,bi,xi]))]),providerOptions:P.optional()}),f({role:m(`tool`),content:S(g([bi,Si])),providerOptions:P.optional()})]);function Ci(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=Ci(a,i):n[r]=i}return n}new TextEncoder,ti({},{array:()=>Oi,choice:()=>ki,json:()=>Ai,object:()=>Di,text:()=>Ei});function wi(e){let t=[`ROOT`],n=-1,r=null;function i(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`);break}}function a(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop();break}}function o(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop();break}}for(let s=0;s<e.length;s++){let c=e[s];switch(t[t.length-1]){case`ROOT`:i(c,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=s,t.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break}break;case`INSIDE_OBJECT_KEY`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(c){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:i(c,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:a(c,s);break;case`INSIDE_STRING`:switch(c){case`"`:t.pop(),n=s;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(c){case`]`:n=s,t.pop();break;default:n=s,i(c,s,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(c){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=s,t.pop();break;default:n=s;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:i(c,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),n=s;break;case`INSIDE_NUMBER`:switch(c){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&a(c,s);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&a(c,s);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s);break;default:t.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?a(c,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s)):n=s;break}}}let s=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:s+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:s+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:s+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?s+=`true`.slice(t.length):`false`.startsWith(t)?s+=`false`.slice(t.length):`null`.startsWith(t)&&(s+=`null`.slice(t.length))}}return s}async function Ti(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await Zr({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await Zr({text:wi(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}var Ei=()=>({name:`text`,responseFormat:Promise.resolve({type:`text`}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),Di=({schema:e,name:t,description:n})=>{let r=Ur(e);return{name:`object`,responseFormat:$r(r.jsonSchema).then(e=>({type:`json`,schema:e,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:e},t){let n=await Zr({text:e});if(!n.success)throw new oi({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=await Xr({value:n.value,schema:r});if(!i.success)throw new oi({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return i.value},async parsePartialOutput({text:e}){let t=await Ti(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value}}},createElementStreamTransform(){}}},Oi=({element:e,name:t,description:n})=>{let r=Ur(e);return{name:`array`,responseFormat:$r(r.jsonSchema).then(e=>{let{$schema:r,...i}=e;return{type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{elements:{type:`array`,items:i}},required:[`elements`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:e},t){let n=await Zr({text:e});if(!n.success)throw new oi({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=n.value;if(typeof i!=`object`||!i||!(`elements`in i)||!Array.isArray(i.elements))throw new oi({message:`No object generated: response did not match schema.`,cause:new vn({value:i,cause:`response must be an object with an elements array`}),text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});for(let n of i.elements){let i=await Xr({value:n,schema:r});if(!i.success)throw new oi({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason})}return i.elements},async parsePartialOutput({text:e}){let t=await Ti(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let e=t.value;if(typeof e!=`object`||!e||!(`elements`in e)||!Array.isArray(e.elements))return;let n=t.state===`repaired-parse`&&e.elements.length>0?e.elements.slice(0,-1):e.elements,i=[];for(let e of n){let t=await Xr({value:e,schema:r});t.success&&i.push(t.value)}return{partial:i}}}},createElementStreamTransform(){let e=0;return new TransformStream({transform({partialOutput:t},n){if(t!=null)for(;e<t.length;e++)n.enqueue(t[e])}})}}},ki=({options:e,name:t,description:n})=>({name:`choice`,responseFormat:Promise.resolve({type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{result:{type:`string`,enum:e}},required:[`result`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:t},n){let r=await Zr({text:t});if(!r.success)throw new oi({message:`No object generated: could not parse the response.`,cause:r.error,text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=r.value;if(typeof i!=`object`||!i||!(`result`in i)||typeof i.result!=`string`||!e.includes(i.result))throw new oi({message:`No object generated: response did not match schema.`,cause:new vn({value:i,cause:`response must be an object that contains a choice value.`}),text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.result},async parsePartialOutput({text:t}){let n=await Ti(t);switch(n.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let t=n.value;if(typeof t!=`object`||!t||!(`result`in t)||typeof t.result!=`string`)return;let r=e.filter(e=>e.startsWith(t.result));return n.state===`successful-parse`?r.includes(t.result)?{partial:t.result}:void 0:r.length===1?{partial:r[0]}:void 0}}},createElementStreamTransform(){}}),Ai=({name:e,description:t}={})=>({name:`json`,responseFormat:Promise.resolve({type:`json`,...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:e},t){let n=await Zr({text:e});if(!n.success)throw new oi({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return n.value},async parsePartialOutput({text:e}){let t=await Ti(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return t.value===void 0?void 0:{partial:t.value}}},createElementStreamTransform(){}});An({prefix:`aitxt`,size:24}),TransformStream;var ji=T(b(),pi.optional()),Mi=Br(()=>Jr(g([y({type:m(`text-start`),id:b(),providerMetadata:P.optional()}),y({type:m(`text-delta`),id:b(),delta:b(),providerMetadata:P.optional()}),y({type:m(`text-end`),id:b(),providerMetadata:P.optional()}),y({type:m(`error`),errorText:b()}),y({type:m(`tool-input-start`),toolCallId:b(),toolName:b(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:ji.optional(),dynamic:p().optional(),title:b().optional()}),y({type:m(`tool-input-delta`),toolCallId:b(),inputTextDelta:b()}),y({type:m(`tool-input-available`),toolCallId:b(),toolName:b(),input:_(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:ji.optional(),dynamic:p().optional(),title:b().optional()}),y({type:m(`tool-input-error`),toolCallId:b(),toolName:b(),input:_(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:ji.optional(),dynamic:p().optional(),errorText:b(),title:b().optional()}),y({type:m(`tool-approval-request`),approvalId:b(),toolCallId:b(),signature:b().optional()}),y({type:m(`tool-output-available`),toolCallId:b(),output:_(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:ji.optional(),dynamic:p().optional(),preliminary:p().optional()}),y({type:m(`tool-output-error`),toolCallId:b(),errorText:b(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:ji.optional(),dynamic:p().optional()}),y({type:m(`tool-output-denied`),toolCallId:b()}),y({type:m(`reasoning-start`),id:b(),providerMetadata:P.optional()}),y({type:m(`reasoning-delta`),id:b(),delta:b(),providerMetadata:P.optional()}),y({type:m(`reasoning-end`),id:b(),providerMetadata:P.optional()}),y({type:m(`source-url`),sourceId:b(),url:b(),title:b().optional(),providerMetadata:P.optional()}),y({type:m(`source-document`),sourceId:b(),mediaType:b(),title:b(),filename:b().optional(),providerMetadata:P.optional()}),y({type:m(`file`),url:b(),mediaType:b(),providerMetadata:P.optional()}),y({type:D(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:b().optional(),data:_(),transient:p().optional()}),y({type:m(`start-step`)}),y({type:m(`finish-step`)}),y({type:m(`start`),messageId:b().optional(),messageMetadata:_().optional()}),y({type:m(`finish`),finishReason:O([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`]).optional(),messageMetadata:_().optional()}),y({type:m(`abort`),reason:b().optional()}),y({type:m(`message-metadata`),messageMetadata:_()})])));function Ni(e){return e.type.startsWith(`data-`)}function Pi(){return Object.create(null)}function Fi(e){return e.type.startsWith(`tool-`)}function Ii(e){return e.type===`dynamic-tool`}function Li(e){return Fi(e)||Ii(e)}function Ri(e){return e.type.split(`-`).slice(1).join(`-`)}function zi({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:Pi(),activeReasoningParts:Pi(),partialToolCalls:Pi()}}function Bi({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{function l(e){let t=r.message.parts.filter(Li).find(t=>t.toolCallId===e);if(t==null)throw new di({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function u(e){let t=r.message.parts.find(t=>Fi(t)&&t.toolCallId===e.toolCallId),n=e,i=t;if(t!=null){t.state=e.state,i.input=n.input,i.output=n.output,i.errorText=n.errorText,i.rawInput=n.rawInput,i.preliminary=n.preliminary,e.title!==void 0&&(i.title=e.title),e.toolMetadata!==void 0&&(i.toolMetadata=e.toolMetadata),i.providerExecuted=n.providerExecuted??t.providerExecuted;let r=n.providerMetadata;if(r!=null)if(e.state===`output-available`||e.state===`output-error`){let e=t;e.resultProviderMetadata=r}else t.callProviderMetadata=r}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:n.input,output:n.output,rawInput:n.rawInput,errorText:n.errorText,providerExecuted:n.providerExecuted,preliminary:n.preliminary,...n.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:n.providerMetadata}:{},...n.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:n.providerMetadata}:{}})}function d(e){let t=r.message.parts.find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),n=e,i=t;if(t!=null){t.state=e.state,i.toolName=e.toolName,i.input=n.input,i.output=n.output,i.errorText=n.errorText,i.rawInput=n.rawInput??i.rawInput,i.preliminary=n.preliminary,e.title!==void 0&&(i.title=e.title),e.toolMetadata!==void 0&&(i.toolMetadata=e.toolMetadata),i.providerExecuted=n.providerExecuted??t.providerExecuted;let r=n.providerMetadata;if(r!=null)if(e.state===`output-available`||e.state===`output-error`){let e=t;e.resultProviderMetadata=r}else t.callProviderMetadata=r}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:n.input,output:n.output,errorText:n.errorText,preliminary:n.preliminary,providerExecuted:n.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...n.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:n.providerMetadata}:{},...n.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:n.providerMetadata}:{}})}async function f(e){if(e!=null){let n=r.message.metadata==null?e:Ci(r.message.metadata,e);t!=null&&await Yr({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new di({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new di({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`reasoning-start`:{let t={type:`reasoning`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new di({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new di({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:r.message.parts.push({type:`file`,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=r.message.parts.filter(Fi);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new di({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let{value:n}=await Ti(t.text);t.dynamic?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-input-available`:e.dynamic?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=r.message.parts.filter(Li).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),c();break}case`tool-approval-request`:{let t=l(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.signature==null?{}:{signature:e.signature}},c();break}case`tool-output-denied`:{let t=l(e.toolCallId);t.state=`output-denied`,c();break}case`tool-output-available`:{let t=l(e.toolCallId);t.type===`dynamic-tool`?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:Ri(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-output-error`:{let t=l(e.toolCallId);t.type===`dynamic-tool`?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:Ri(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:r.activeTextParts=Pi(),r.activeReasoningParts=Pi();break;case`start`:e.messageId!=null&&(r.message.id=e.messageId),await f(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c();break;case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await f(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await f(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(Ni(e)){if(n?.[e.type]!=null){let t=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=t>=0?t:r.message.parts.length;await Yr({value:e.data,schema:n[e.type],context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}async function Vi({stream:e,onError:t}){let n=e.getReader();try{for(;;){let{done:e}=await n.read();if(e)break}}catch(e){t?.(e)}finally{n.releaseLock()}}An({prefix:`aitxt`,size:24}),T(b(),pi.optional()),An({prefix:`aiobj`,size:24});var Hi=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}};An({prefix:`aiobj`,size:24});async function Ui(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw Error(`FileList is not supported in the current environment`);return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}var Wi=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await $r(this.body),r=await $r(this.headers),i=await $r(this.credentials),a={...Mn(r),...Mn(t.headers)},o=await this.prepareSendMessagesRequest?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Mn(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"Content-Type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw Error(await d.text()??`Failed to fetch the chat response.`);if(!d.body)throw Error(`The response body is empty.`);return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await $r(this.body),n=await $r(this.headers),r=await $r(this.credentials),i={...Mn(n),...Mn(e.headers)},a=await this.prepareReconnectToStreamRequest?.call(this,{api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api??`${this.api}/${e.chatId}/stream`,s=a?.headers===void 0?i:Mn(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c});if(l.status===204)return null;if(!l.ok)throw Error(await l.text()??`Failed to fetch the chat response.`);if(!l.body)throw Error(`The response body is empty.`);return this.processResponseStream(l.body)}},Gi=class extends Wi{constructor(e={}){super(e)}processResponseStream(e){return Qr({stream:e,schema:Mi}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Ki=class{constructor({generateId:e=jn,id:t=e(),transport:n=new Gi,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.activeResponse=void 0,this.jobExecutor=new Hi,this.sendMessage=async(e,t)=>{if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...t});return}let n;if(n=`text`in e||`files`in e?{parts:[...Array.isArray(e.files)?e.files:await Ui(e.files),...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}:e,e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw Error(`message with id ${e.messageId} not found`);if(this.state.messages[t].role!==`user`)throw Error(`message with id ${e.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{...n,id:e.messageId,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw Error(`message ${e} not found`);this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.state.messages,a=i[i.length-1],o=r=>Li(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{id:e,approved:t,reason:n}}:r;this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(o)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...r})})}),this.addToolOutput=async({state:e=`output-available`,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.state.messages,o=a[a.length-1],s=i=>Li(i)&&i.toolCallId===t?{...i,state:e,output:n,errorText:r}:i;this.state.replaceMessage(a.length-1,{...o,parts:o.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...i})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.status!==`streaming`&&this.status!==`submitted`||this.activeResponse?.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e==`object`&&`then`in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a;let o;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(e==null)return;o=e}catch(e){this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e});return}this.setStatus({status:`submitted`,error:void 0});let s=this.lastMessage,c=!1,l=!1,u=!1;try{let a={state:zi({lastMessage:this.state.snapshot(s),messageId:this.generateId()}),abortController:new AbortController};a.abortController.signal.addEventListener(`abort`,()=>{c=!0}),this.activeResponse=a;let l;l=e===`resume-stream`?o:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Vi({stream:Bi({stream:l,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>e({state:a.state,write:()=>{this.setStatus({status:`streaming`}),a.state.message.id===this.lastMessage?.id?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message)}})),onError:e=>{throw e}}),onError:e=>{throw e}}),this.setStatus({status:`ready`})}catch(e){if(c||e.name===`AbortError`)return c=!0,this.setStatus({status:`ready`}),null;u=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(l=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:l,isError:u,finishReason:this.activeResponse?.state.finishReason})}catch(e){console.error(e)}this.activeResponse=void 0}!u&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r})}},qi=i(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n})),F=n(a(),1),Ji=n(qi(),1),Yi=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},I=(e,t,n)=>(Yi(e,t,`read from private field`),n?n.call(e):t.get(e)),Xi=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},Zi=(e,t,n,r)=>(Yi(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function Qi(e,t){return t==null?e:(0,Ji.default)(e,t)}var $i,ea,ta,na,ra,ia,aa,oa,sa,ca=class{constructor(e=[]){Xi(this,$i,void 0),Xi(this,ea,`ready`),Xi(this,ta,void 0),Xi(this,na,new Set),Xi(this,ra,new Set),Xi(this,ia,new Set),this.pushMessage=e=>{Zi(this,$i,I(this,$i).concat(e)),I(this,aa).call(this)},this.popMessage=()=>{Zi(this,$i,I(this,$i).slice(0,-1)),I(this,aa).call(this)},this.replaceMessage=(e,t)=>{Zi(this,$i,[...I(this,$i).slice(0,e),this.snapshot(t),...I(this,$i).slice(e+1)]),I(this,aa).call(this)},this.snapshot=e=>structuredClone(e),this[`~registerMessagesCallback`]=(e,t)=>{let n=t?Qi(e,t):e;return I(this,na).add(n),()=>{I(this,na).delete(n)}},this[`~registerStatusCallback`]=e=>(I(this,ra).add(e),()=>{I(this,ra).delete(e)}),this[`~registerErrorCallback`]=e=>(I(this,ia).add(e),()=>{I(this,ia).delete(e)}),Xi(this,aa,()=>{I(this,na).forEach(e=>e())}),Xi(this,oa,()=>{I(this,ra).forEach(e=>e())}),Xi(this,sa,()=>{I(this,ia).forEach(e=>e())}),Zi(this,$i,e)}get status(){return I(this,ea)}set status(e){Zi(this,ea,e),I(this,oa).call(this)}get error(){return I(this,ta)}set error(e){Zi(this,ta,e),I(this,sa).call(this)}get messages(){return I(this,$i)}set messages(e){Zi(this,$i,[...e]),I(this,aa).call(this)}};$i=new WeakMap,ea=new WeakMap,ta=new WeakMap,na=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=new WeakMap,oa=new WeakMap,sa=new WeakMap;var la,ua=class extends Ki{constructor({messages:e,...t}){let n=new ca(e);super({...t,state:n}),Xi(this,la,void 0),this[`~registerMessagesCallback`]=(e,t)=>I(this,la)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>I(this,la)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>I(this,la)[`~registerErrorCallback`](e),Zi(this,la,n)}};la=new WeakMap;function da({experimental_throttle:e,resume:t=!1,...n}={}){let r=(0,F.useRef)(`chat`in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});`chat`in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});let i={...n,onToolCall:e=>{var t;return(t=r.current).onToolCall?.call(t,e)},onData:e=>{var t;return(t=r.current).onData?.call(t,e)},onFinish:e=>{var t;return(t=r.current).onFinish?.call(t,e)},onError:e=>{var t;return(t=r.current).onError?.call(t,e)},sendAutomaticallyWhen:e=>{var t;return(t=r.current).sendAutomaticallyWhen?.call(t,e)??!1}},a=(0,F.useRef)(`chat`in n?n.chat:new ua(i));(`chat`in n&&n.chat!==a.current||`id`in n&&a.current.id!==n.id)&&(a.current=`chat`in n?n.chat:new ua(i));let o=(0,F.useSyncExternalStore)((0,F.useCallback)(t=>a.current[`~registerMessagesCallback`](t,e),[e,a.current.id]),()=>a.current.messages,()=>a.current.messages),s=(0,F.useSyncExternalStore)(a.current[`~registerStatusCallback`],()=>a.current.status,()=>a.current.status),c=(0,F.useSyncExternalStore)(a.current[`~registerErrorCallback`],()=>a.current.error,()=>a.current.error),l=(0,F.useCallback)(e=>{typeof e==`function`&&(e=e(a.current.messages)),a.current.messages=e},[a]);return(0,F.useEffect)(()=>{t&&a.current.resumeStream()},[t,a]),{id:a.current.id,messages:o,setMessages:l,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:c,resumeStream:a.current.resumeStream,status:s,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}function fa(e=`msg`){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function pa(e,t){return typeof e.content==`string`?e.content:t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``)}function ma(e){let t=e.filter(e=>e.type===`reasoning`||e.type===`reasoning-delta`).map(e=>e.text??``).join(`
17
- `).trim();return t.length>0?t:void 0}function ha(e){let t=e=>{if(e&&typeof e==`object`)return e;if(typeof e!=`string`)return;let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);return e&&typeof e==`object`?e:void 0}catch{return}},n=[e];e&&typeof e==`object`&&`value`in e&&n.push(e.value);let r;for(let e of n){let n=t(e);if(n){if(typeof n.status==`string`)return n;r??=n}}return r}function ga(e){let t=ha(e);if(!t)return;let n=t.pendingActionId;if(t.status===`pending_approval`&&typeof n==`string`&&n.length>0)return{pendingActionId:n,raw:t}}function _a(e){let t=ha(e);if(!t||t.status!==`drafted`)return;let n=[];if(Array.isArray(t.drafted)){for(let e of t.drafted)if(e&&typeof e==`object`){let{type:t,name:r}=e;typeof t==`string`&&typeof r==`string`&&n.push({type:t,name:r})}}else typeof t.type==`string`&&typeof t.name==`string`&&n.push({type:t.type,name:t.name});if(n.length===0)return;let r=Array.isArray(t.failed)?t.failed.length:0,i=t.verification,a=i&&typeof i==`object`&&typeof i.errors==`number`&&typeof i.warnings==`number`?{errors:i.errors,warnings:i.warnings}:void 0,o=t.issues,s=Array.isArray(o)?o.flatMap(e=>{let t=e;return typeof t?.message!=`string`||!t.message?[]:[{severity:t.severity===`error`?`error`:`warning`,code:typeof t.code==`string`?t.code:`issue`,message:t.message,...typeof t.fix==`string`&&t.fix?{fix:t.fix}:{}}]}):[];return{items:n,summary:typeof t.summary==`string`?t.summary:void 0,...typeof t.packageId==`string`&&t.packageId?{packageId:t.packageId}:{},...t.autoPublishable===!0?{autoPublishable:!0}:{},...r>0?{failedCount:r}:{},...t.materialized===!0?{materialized:!0}:{},...a?{verification:a}:{},...s.length?{issues:s}:{}}}function va(e){return e.replace(/[._-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase())}function ya(e){if(!e||!Array.isArray(e.items)||e.items.length===0)return;let t=e.items.find(e=>e.type===`app`);if(t)return{phase:`done`,appLabel:va(t.name),items:e.items,done:e.items.length,total:e.items.length}}function ba(e,t={}){return e.filter(e=>e.type===`dynamic-tool`?!0:typeof e.type==`string`&&e.type.startsWith(`tool-`)).map(e=>{let n=e.type===`dynamic-tool`?e.toolName??`tool`:typeof e.type==`string`?e.type.replace(/^tool-/,``):`tool`,r=e.output??e.result,i=ga(r),a=_a(r),o=e.state,s=(o===`input-available`||o===`input-streaming`)&&(r!==void 0||!t.liveTail)?`output-available`:o,c=i&&s!==`output-error`?`approval-requested`:s;return{toolCallId:e.toolCallId??e.id??`${e.type??`tool`}-${Math.random().toString(36).slice(2,8)}`,toolName:n,args:e.input??e.args,result:r,errorText:e.errorText,state:c,pendingActionId:i?.pendingActionId,draftReview:a}})}function xa(e){let t=e.filter(e=>e.type===`source-url`||e.type===`source`).map(e=>({id:e.id,title:e.title,url:e.url??e.href})).filter(e=>!!e.url);return t.length>0?t:void 0}function Sa(e){let t=e.filter(e=>e.type===`data-build-progress`).pop()?.data;if(!t||typeof t!=`object`)return;let n=t,r=Array.isArray(n.items)?n.items.filter(e=>typeof e?.type==`string`&&typeof e?.name==`string`).map(e=>({type:e.type,name:e.name})):[];return{phase:n.phase===`data`||n.phase===`done`?n.phase:`structure`,...typeof n.appLabel==`string`?{appLabel:n.appLabel}:{},items:r,done:typeof n.done==`number`?n.done:r.length,total:typeof n.total==`number`?n.total:r.length,...typeof n.seq==`number`?{seq:n.seq}:{}}}function Ca(e){let t=[];for(let n of e){if(n.type!==`data-chart`)continue;let e=n.data;if(!e||typeof e!=`object`)continue;let r=e,i=Array.isArray(r.data)?r.data:[],a=Array.isArray(r.series)?r.series.filter(e=>e&&typeof e.dataKey==`string`).map(e=>({dataKey:e.dataKey,...typeof e.label==`string`?{label:e.label}:{}})):[];a.length!==0&&t.push({...typeof r.chartType==`string`?{chartType:r.chartType}:{},...typeof r.title==`string`?{title:r.title}:{},data:i,...typeof r.xAxisKey==`string`?{xAxisKey:r.xAxisKey}:{},series:a})}return t.length>0?t:void 0}function wa(e,t={}){let n=Array.isArray(e.parts)?e.parts:[],r=ba(n,{liveTail:t.streaming}),i=Array.isArray(e.toolInvocations)?e.toolInvocations:[],a=r.length>0?r:i,o=Sa(n)??a.map(e=>ya(e.draftReview)).find(e=>!!e);return{id:e.id??`msg-${Math.random().toString(36).slice(2,8)}`,role:e.role??`assistant`,content:pa(e,n),reasoning:ma(n),toolInvocations:a,sources:xa(n),buildProgress:o,charts:Ca(n),streaming:t.streaming}}function Ta(e,t={}){if(!Array.isArray(e)||e.length===0)return[];let n=e.length-1;return e.map((e,r)=>wa(e,{streaming:!!t.isStreaming&&r===n&&e.role===`assistant`}))}function Ea(e){let t=[...e.messages].reverse().find(e=>e.role===`user`);return{body:{...e.body??{},id:e.id,messages:e.messages,trigger:e.trigger,messageId:e.messageId,...t?{turnId:t.id}:{}}}}function Da(e){return(e??[]).map((e,t)=>({id:e.id||`msg-${t}`,role:e.role||`user`,content:e.content||``,timestamp:typeof e.timestamp==`string`?e.timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():void 0,metadata:e.metadata,streaming:e.streaming,toolInvocations:e.toolInvocations}))}function Oa(e={}){let{api:t,initialMessages:n,conversationId:r,systemPrompt:i,model:a,streamingEnabled:o=!0,headers:s,body:c,maxToolRoundtrips:l=5,onError:u,showTimestamp:d,autoResponse:f,autoResponseText:p,autoResponseDelay:m=1e3,onSend:h}=e,g=(0,F.useRef)(t?`api`:`local`).current===`api`,_=(0,F.useMemo)(()=>(n??[]).map((e,t)=>{if(Array.isArray(e.parts)&&e.parts.length>0)return{id:e.id||`msg-${t}`,role:e.role||`user`,parts:e.parts};let n=Da([e])[0],r=[];n.content&&r.push({type:`text`,text:n.content}),e.reasoning&&r.push({type:`reasoning`,text:e.reasoning});for(let e of n.toolInvocations??[])r.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.args,output:e.result,errorText:e.errorText,state:e.state});return{id:n.id||`msg-${t}`,role:n.role,parts:r.length>0?r:[{type:`text`,text:``}]}}),[]),v=da({transport:(0,F.useMemo)(()=>{if(g)return new Gi({api:t,headers:{...s},body:{...c,...r?{conversationId:r}:{},...a?{model:a}:{},...i?{systemPrompt:i}:{},...o===void 0?{}:{stream:o}},prepareSendMessagesRequest:({id:e,body:t,messages:n,trigger:r,messageId:i})=>Ea({id:e,body:t,messages:n,trigger:r,messageId:i})})},[g,t,s,c,a,i,o,r]),messages:g&&_.length>0?_:void 0,onError:g?e=>{u?.(e)}:void 0}),[y,b]=(0,F.useState)(()=>Da(n)),[x,S]=(0,F.useState)(!1),[C,w]=(0,F.useState)(``),[T,E]=(0,F.useState)(``),D=(0,F.useRef)(null);if((0,F.useEffect)(()=>()=>{D.current&&=(clearTimeout(D.current),null)},[]),g){let{messages:e,status:t,error:n,sendMessage:r,regenerate:i,stop:a,setMessages:o}=v,s=t===`submitted`||t===`streaming`,c=Ta(e,{isStreaming:s}).map((t,n)=>({...t,metadata:e[n]?.metadata}));return{messages:c,isLoading:s,error:n,sendMessage:(0,F.useCallback)(e=>{let t=e.trim();if(!t)return;let n=[...c,{id:fa(`msg`),role:`user`,content:t}];r({text:t}),E(``),h?.(t,n)},[r,h,c]),stop:a,reload:i,clear:(0,F.useCallback)(()=>{o([])},[o]),setMessages:o,isApiMode:!0,input:T,setInput:E,handleInputChange:(0,F.useCallback)(e=>{E(e.target.value)},[])}}let ee=(0,F.useCallback)(()=>{D.current&&=(clearTimeout(D.current),null),S(!1)},[]);return{messages:y,isLoading:x,error:void 0,sendMessage:(0,F.useCallback)(e=>{if(!e.trim())return;let t={id:fa(`msg`),role:`user`,content:e.trim(),timestamp:d?new Date().toLocaleTimeString():void 0};b(n=>{let r=[...n,t];return h?.(e.trim(),r),r}),w(``),f&&(S(!0),D.current=setTimeout(()=>{let e={id:fa(`msg`),role:`assistant`,content:p||`Thank you for your message!`,timestamp:d?new Date().toLocaleTimeString():void 0};b(t=>[...t,e]),S(!1)},m))},[d,f,p,m,h]),stop:ee,reload:(0,F.useCallback)(()=>{},[]),clear:(0,F.useCallback)(()=>{ee(),b([])},[ee]),isApiMode:!1,input:C,setInput:w,handleInputChange:(0,F.useCallback)(e=>{w(e.target.value)},[])}}var ka=`data_chat`;function Aa(e,t){if(e.length===0)return;if(t){let n=e.find(e=>e.name===t);if(n)return n.name}let n=e.find(e=>e.name===ka);return n?n.name:e[0].name}function ja(e){return e.filter(e=>typeof e?.name==`string`&&e.name.length>0).map(e=>({name:e.name,label:e.label||e.name,description:e.description,role:e.role,active:e.active!==!1}))}function Ma(e={}){let{apiBase:t,headers:n,enabled:r=!0,fallback:i=[]}=e,[a,o]=(0,F.useState)(i),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(void 0),[d,f]=(0,F.useState)(0),p=(0,F.useRef)(n);return p.current=n,(0,F.useEffect)(()=>{if(!r||!t)return;let e=new AbortController,n=!1;c(!0),u(void 0);let a=`${t.replace(/\/$/,``)}/agents`;return fetch(a,{method:`GET`,headers:{Accept:`application/json`,...p.current??{}},credentials:`include`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Failed to load agents (${e.status})`);return e.json()}).then(e=>{if(n)return;let t=ja(Array.isArray(e)?e:e?.agents??[]);o(t.length>0?t:i)}).catch(e=>{n||e.name===`AbortError`||(u(e),o(i))}).finally(()=>{n||c(!1)}),()=>{n=!0,e.abort()}},[t,r,d]),{agents:a,isLoading:s,error:l,refetch:(0,F.useCallback)(()=>f(e=>e+1),[])}}var L=c(),Na=F.createContext(null);function Pa({defaultOpen:e=!1,children:t}){let[n,r]=F.useState(e),[i,a]=F.useState(!1),o=F.useMemo(()=>({isOpen:n,isFullscreen:i,open:()=>r(!0),close:()=>{r(!1),a(!1)},toggle:()=>r(e=>!e),toggleFullscreen:()=>a(e=>!e)}),[n,i]);return(0,L.jsx)(Na.Provider,{value:o,children:t})}function Fa(){let e=F.useContext(Na);if(!e)throw Error(`useFloatingChatbot must be used within a <FloatingChatbotProvider>`);return e}function Ia(){try{let{t:e}=d();return(t,n)=>{let r=e(`common.${t}`);return!r||r===`common.${t}`?n:r}}catch{return(e,t)=>t}}var La={32:`size-8`,36:`size-9`,40:`size-10`,44:`size-11`,48:`size-12`,52:`size-[52px]`,56:`size-14`,60:`size-[60px]`,64:`size-16`,72:`size-[72px]`,80:`size-20`};function Ra(e,t){return t.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t)}function za(e){return La[e]??La[Ra(e,Object.keys(La).map(Number))]}function Ba({position:e=`bottom-right`,size:t=56,className:n}){let{isOpen:r,toggle:i}=Fa(),a=Ia();return(0,L.jsx)(A,{onClick:i,className:j(`fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105`,za(t),r&&`hidden`,e===`bottom-right`?`right-6 bottom-20 sm:bottom-6`:`left-6 bottom-20 sm:bottom-6`,n),size:`icon`,"aria-label":r?a(`closeChat`,`Close chat`):a(`openChat`,`Open chat`),"data-testid":`floating-chatbot-trigger`,children:r?(0,L.jsx)(De,{className:`h-6 w-6`}):(0,L.jsx)(ht,{className:`h-6 w-6`})})}var Va={300:`sm:w-[300px]`,320:`sm:w-[320px]`,340:`sm:w-[340px]`,360:`sm:w-[360px]`,380:`sm:w-[380px]`,400:`sm:w-[400px]`,420:`sm:w-[420px]`,440:`sm:w-[440px]`,450:`sm:w-[450px]`,460:`sm:w-[460px]`,480:`sm:w-[480px]`,500:`sm:w-[500px]`,520:`sm:w-[520px]`,560:`sm:w-[560px]`,600:`sm:w-[600px]`,640:`sm:w-[640px]`,720:`sm:w-[720px]`,800:`sm:w-[800px]`},Ha={360:`h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]`,400:`h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]`,420:`h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]`,440:`h-[min(440px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[440px]`,480:`h-[min(480px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[480px]`,500:`h-[min(500px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[500px]`,520:`h-[min(520px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[520px]`,560:`h-[min(560px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[560px]`,600:`h-[min(600px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[600px]`,640:`h-[min(640px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[640px]`,720:`h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]`,800:`h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]`};function Ua(e,t){return t.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t)}function Wa(e){return Va[e]??Va[Ua(e,Object.keys(Va).map(Number))]}function Ga(e){return Ha[e]??Ha[Ua(e,Object.keys(Ha).map(Number))]}function Ka({title:e=`Chat`,position:t=`bottom-right`,width:n=400,height:r=520,children:i,className:a,headerExtra:o,headerActions:s}){let{isOpen:c,isFullscreen:l,close:u,toggleFullscreen:d}=Fa();return c?(0,L.jsxs)(`div`,{className:j(`fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all`,l?`inset-0 h-svh w-screen rounded-none`:t===`bottom-right`?j(`left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg`,`sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]`,Wa(n),Ga(r)):j(`left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg`,`sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]`,Wa(n),Ga(r)),a),role:`dialog`,"aria-label":e,"data-testid":`floating-chatbot-panel`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-2 border-b bg-muted/40 px-4 py-2`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e}),o?(0,L.jsx)(`div`,{className:`mr-1 flex min-w-0 items-center justify-end`,"data-testid":`floating-chatbot-header-extra`,children:o}):null,(0,L.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[s,(0,L.jsx)(A,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:d,"aria-label":l?`Exit fullscreen`:`Fullscreen`,"data-testid":`floating-chatbot-fullscreen`,children:l?(0,L.jsx)(Ue,{className:`h-4 w-4`}):(0,L.jsx)(Oe,{className:`h-4 w-4`})}),(0,L.jsx)(A,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:u,"aria-label":`Close chat`,"data-testid":`floating-chatbot-close`,children:(0,L.jsx)(De,{className:`h-4 w-4`})})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:i})]}):null}var qa={ai:`AI`,api:`API`,crm:`CRM`,hitl:`HITL`,id:`ID`,ids:`IDs`,rag:`RAG`,sql:`SQL`,url:`URL`,utc:`UTC`};function Ja(e){if(!e)return``;let t=String(e).trim();if(!t)return``;let n=t.replace(/[_-]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).split(/\s+/).filter(Boolean);return n.length===0?t:n.map((e,t)=>{let n=e.toLowerCase();return qa[n]?qa[n]:t===0?n.charAt(0).toUpperCase()+n.slice(1):n}).join(` `)}function Ya(e){if(e==null)return e;let t=e;for(let e=0;e<2;e++){if(typeof t==`object`&&t&&!Array.isArray(t)&&t.type===`text`&&typeof t.value==`string`){t=t.value;continue}break}if(typeof t==`string`){let e=t.trim();if(e.startsWith(`{`)&&e.endsWith(`}`)||e.startsWith(`[`)&&e.endsWith(`]`))try{return JSON.parse(e)}catch{}}return t}function Xa(e){let t=(e instanceof Error?e.message:String(e??``)).replace(/\s+/g,` `).trim();if(!t)return{summary:`Something went wrong. Please try again.`};let n=t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i,``),r=n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim()??n,i=r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim()??r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim()??(r.length>140?`${r.slice(0,137).trimEnd()}…`:r);return{summary:i.replace(/:$/,``),details:n.length>i.length?n:void 0}}var Za=new Set([`ai_design_quota_exhausted`,`ai_data_chat_trial_exhausted`,`ai_allowance_exhausted`]);function Qa(e){let t=e instanceof Error?e.message:String(e??``);if(!t)return null;let n=t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i,``).replace(/^Invalid error response format:\s*/i,``).trim(),r=n.indexOf(`{`),i=n.lastIndexOf(`}`);if(r<0||i<=r)return null;let a;try{a=JSON.parse(n.slice(r,i+1))}catch{return null}return!a||typeof a.error!=`string`||!Za.has(a.error)?null:{code:a.error,message:typeof a.message==`string`?a.message:``,messageEn:typeof a.messageEn==`string`?a.messageEn:void 0,upgrade:a.upgrade===!0,topUp:a.topUp===!0}}var $a={damping:.7,stiffness:.05,mass:1.25},eo=70,to=1e3/60,no=350,ro=!1;globalThis.document?.addEventListener(`mousedown`,()=>{ro=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{ro=!1}),globalThis.document?.addEventListener(`click`,()=>{ro=!1});var io=(e={})=>{let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(e.initial!==!1),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null);s.current=e;let c=(0,F.useCallback)(()=>{if(!ro)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,F.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,F.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,F.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=eo}}},[]),f=(0,F.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=so(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/to;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:so(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,F.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,F.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,F.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=ao(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=ao(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=so(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:no})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function ao(e,t){let n=(0,F.useCallback)(t=>(n.current=t,e(t)),t);return n}var oo=new Map;function so(...e){let t={...$a},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return oo.has(r)||oo.set(r,Object.freeze(t)),n?`instant`:oo.get(r)}var co=(0,F.createContext)(null),lo=typeof window<`u`?F.useLayoutEffect:F.useEffect;function uo({instance:e,children:t,resize:n,initial:r,mass:i,damping:a,stiffness:o,targetScrollTop:s,contextRef:c,...l}){let u=(0,F.useRef)(null),d=io({mass:i,damping:a,stiffness:o,resize:n,initial:r,targetScrollTop:F.useCallback((e,t)=>(y?.targetScrollTop??s)?.(e,t)??e,[s])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:h,isAtBottom:g,escapedFromLock:_,state:v}=e??d,y=(0,F.useMemo)(()=>({scrollToBottom:m,stopScroll:h,scrollRef:f,isAtBottom:g,escapedFromLock:_,contentRef:p,state:v,get targetScrollTop(){return u.current},set targetScrollTop(e){u.current=e}}),[m,g,p,f,h,_,v]);return(0,F.useImperativeHandle)(c,()=>y,[y]),lo(()=>{f.current&&getComputedStyle(f.current).overflow===`visible`&&(f.current.style.overflow=`auto`)},[]),F.createElement(co.Provider,{value:y},F.createElement(`div`,{...l},typeof t==`function`?t(y):t))}(function(e){function t({children:e,scrollClassName:t,...n}){let r=fo();return F.createElement(`div`,{ref:r.scrollRef,style:{height:`100%`,width:`100%`,scrollbarGutter:`stable both-edges`},className:t},F.createElement(`div`,{...n,ref:r.contentRef},typeof e==`function`?e(r):e))}e.Content=t})(uo||={});function fo(){let e=(0,F.useContext)(co);if(!e)throw Error(`use-stick-to-bottom component context must be used within a StickToBottom component`);return e}var po=({className:e,...t})=>(0,L.jsx)(uo,{className:j(`relative flex-1 overflow-y-hidden`,e),initial:`smooth`,resize:`smooth`,role:`log`,...t}),mo=({className:e,...t})=>(0,L.jsx)(uo.Content,{className:j(`flex flex-col gap-8 p-4`,e),...t}),ho=({className:e,title:t=`No messages yet`,description:n=`Start a conversation to see messages here`,icon:r,children:i,...a})=>(0,L.jsx)(`div`,{className:j(`flex size-full flex-col items-center justify-center gap-3 p-8 text-center`,e),...a,children:i??(0,L.jsxs)(L.Fragment,{children:[r&&(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:r}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`font-medium text-sm`,children:t}),n&&(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n})]})]})}),go=({className:e,...t})=>{let{isAtBottom:n,scrollToBottom:r}=fo(),i=(0,F.useCallback)(()=>{r()},[r]);return!n&&(0,L.jsx)(A,{className:j(`absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full`,e),onClick:i,size:`icon`,type:`button`,variant:`outline`,...t,children:(0,L.jsx)(We,{className:`size-4`})})};jt(`flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none`}},defaultVariants:{orientation:`horizontal`}});var _o=Object.defineProperty,vo=Object.defineProperties,yo=Object.getOwnPropertyDescriptors,bo=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable,Co=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wo=(e,t)=>{for(var n in t||={})xo.call(t,n)&&Co(e,n,t[n]);if(bo)for(var n of bo(t))So.call(t,n)&&Co(e,n,t[n]);return e},To=(e,t)=>vo(e,yo(t)),Eo=(e,t)=>{let n=!1,r=!1;for(let i=0;i<t;i+=1){if(e[i]===`\\`&&i+1<e.length&&e[i+1]==="`"){i+=1;continue}if(e.substring(i,i+3)==="```"){r=!r,i+=2;continue}!r&&e[i]==="`"&&(n=!n)}return n||r},Do=(e,t)=>{let n=e.substring(t,t+3)==="```",r=t>0&&e.substring(t-1,t+2)==="```",i=t>1&&e.substring(t-2,t+1)==="```";return n||r||i},Oo=e=>{let t=0;for(let n=0;n<e.length;n+=1){if(e[n]===`\\`&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!Do(e,n)&&(t+=1)}return t},ko=(e,t)=>{let n=!1,r=!1,i=-1;for(let a=0;a<e.length;a+=1){if(e[a]===`\\`&&a+1<e.length&&e[a+1]==="`"){a+=1;continue}if(e.substring(a,a+3)==="```"){r=!r,a+=2;continue}if(!r&&e[a]==="`")if(n){if(i<t&&t<a)return!0;n=!1,i=-1}else n=!0,i=a}return!1},Ao=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,jo=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(Ao,(t,n,r,i)=>Eo(e,i)?t:`${n}\\>${r}`),Mo=/(\*\*)([^*]*\*?)$/,No=/(__)([^_]*?)$/,Po=/(\*\*\*)([^*]*?)$/,Fo=/(\*)([^*]*?)$/,Io=/(_)([^_]*?)$/,Lo=/(`)([^`]*?)$/,Ro=/(~~)([^~]*?)$/,zo=/^[\s_~*`]*$/,Bo=/^[\s]*[-*+][\s]+$/,Vo=/[\p{L}\p{N}_]/u,Ho=/^```[^`\n]*```?$/,Uo=/^\*{4,}$/,Wo=/(__)([^_]+)_$/,Go=/(~~)([^~]+)~$/,Ko=/~~/g,qo=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?!0:Vo.test(e)},Jo=(e,t)=>{let n=1;for(let r=t-1;r>=0;--r)if(e[r]===`]`)n+=1;else if(e[r]===`[`&&(--n,n===0))return r;return-1},Yo=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r+=1)if(e[r]===`[`)n+=1;else if(e[r]===`]`&&(--n,n===0))return r;return-1},Xo=(e,t)=>{let n=!1,r=!1;for(let i=0;i<e.length&&i<t;i+=1){if(e[i]===`\\`&&e[i+1]===`$`){i+=1;continue}e[i]===`$`&&(e[i+1]===`$`?(r=!r,i+=1,n=!1):r||(n=!n))}return n||r},Zo=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
18
- `)return!1}return!1},Qo=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`)`)return!1;if(e[n]===`(`)return n>0&&e[n-1]===`]`?Zo(e,t):!1;if(e[n]===`
19
- `)return!1}return!1},$o=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`>`)return!1;if(e[n]===`<`){let t=n+1<e.length?e[n+1]:``;return t>=`a`&&t<=`z`||t>=`A`&&t<=`Z`||t===`/`}if(e[n]===`
20
- `)return!1}return!1},es=(e,t,n)=>{let r=0;for(let n=t-1;n>=0;--n)if(e[n]===`
16
+ ]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function hr(e,t){let n={type:`object`,additionalProperties:N(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===M.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=cr(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===M.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===M.ZodBranded&&e.keyType._def.type._def.typeName===M.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Xn(e.keyType._def,t);return{...n,propertyNames:i}}return n}function gr(e,t){return t.mapStrategy===`record`?hr(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[N(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Kn(),N(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Kn()],minItems:2,maxItems:2}}}function _r(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function vr(){return{not:Kn()}}function yr(){return{type:`null`}}var br={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function xr(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in br&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=br[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Sr(e,t)}var Sr=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>N(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Cr(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[br[e.innerType._def.typeName],`null`]};let n=N(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function wr(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function Tr(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Dr(a),s=N(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=Er(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Er(e,t){if(e.catchall._def.typeName!==`ZodNever`)return N(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Dr(e){try{return e.isOptional()}catch{return!0}}var Or=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return N(e.innerType._def,t);let n=N(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Kn()},n]}:Kn()},kr=(e,t)=>{if(t.pipeStrategy===`input`)return N(e.in._def,t);if(t.pipeStrategy===`output`)return N(e.out._def,t);let n=N(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,N(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Ar(e,t){return N(e.type._def,t)}function jr(e,t){let n={type:`array`,uniqueItems:!0,items:N(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function Mr(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>N(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:N(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>N(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Nr(){return{not:Kn()}}function Pr(){return Kn()}var Fr=(e,t)=>N(e.innerType._def,t),Ir=(e,t,n)=>{switch(t){case M.ZodString:return cr(e,n);case M.ZodNumber:return wr(e);case M.ZodObject:return Tr(e,n);case M.ZodBigInt:return Jn(e);case M.ZodBoolean:return Yn();case M.ZodDate:return Qn(e,n);case M.ZodUndefined:return Nr();case M.ZodNull:return yr();case M.ZodArray:return qn(e,n);case M.ZodUnion:case M.ZodDiscriminatedUnion:return xr(e,n);case M.ZodIntersection:return ir(e,n);case M.ZodTuple:return Mr(e,n);case M.ZodRecord:return hr(e,n);case M.ZodLiteral:return ar(e);case M.ZodEnum:return nr(e);case M.ZodNativeEnum:return _r(e);case M.ZodNullable:return Cr(e,n);case M.ZodOptional:return Or(e,n);case M.ZodMap:return gr(e,n);case M.ZodSet:return jr(e,n);case M.ZodLazy:return()=>e.getter()._def;case M.ZodPromise:return Ar(e,n);case M.ZodNaN:case M.ZodNever:return vr();case M.ZodEffects:return tr(e,n);case M.ZodAny:return Kn();case M.ZodUnknown:return Pr();case M.ZodDefault:return er(e,n);case M.ZodBranded:return Xn(e,n);case M.ZodReadonly:return Fr(e,n);case M.ZodCatch:return Zn(e,n);case M.ZodPipeline:return kr(e,n);case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:return;default:return(e=>void 0)(t)}},Lr=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function N(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==Un)return i}if(r&&!n){let e=Rr(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Ir(e,e.typeName,t),o=typeof a==`function`?N(a(),t):a;if(o&&zr(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Rr=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Lr(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Kn()):t.$refStrategy===`seen`?Kn():void 0}},zr=(e,t,n)=>(e.description&&(n.description=e.description),n),Br=e=>{let t=Gn(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Vr=(e,t)=>{let n=Br(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:N(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Kn()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=N(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Kn(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Hr=Symbol.for(`vercel.ai.schema`);function Ur(e){let t;return()=>(t??=e(),t)}function Wr(e,{validate:t}={}){return{[Hr]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Gr(e){return typeof e==`object`&&!!e&&Hr in e&&e[Hr]===!0&&`jsonSchema`in e&&`validate`in e}function Kr(e){return e==null?Wr({properties:{},additionalProperties:!1}):Gr(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?Zr(e):qr(e):e()}function qr(e){return Wr(()=>Vn(e[`~standard`].jsonSchema.input({target:`draft-07`})),{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new xn({value:t,cause:n.issues})}}})}function Jr(e,t){let n=t?.useReferences??!1;return Wr(()=>Vr(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Yr(e,t){let n=t?.useReferences??!1;return Wr(()=>Vn(x(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await v(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Xr(e){return`_zod`in e}function Zr(e,t){return Xr(e)?Yr(e,t):Jr(e,t)}async function Qr({value:e,schema:t,context:n}){let r=await $r({value:e,schema:t,context:n});if(!r.success)throw xn.wrap({value:e,cause:r.error,context:n});return r.value}async function $r({value:e,schema:t,context:n}){let r=Kr(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:xn.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:xn.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function ei({text:e,schema:t}){try{let n=Bn(e);return t==null?{success:!0,value:n,rawValue:n}:await $r({value:n,schema:t})}catch(t){return{success:!1,error:hn.isInstance(t)?t:new hn({text:e,cause:t}),rawValue:void 0}}}function ti({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new An).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await ei({text:e,schema:t}))}}))}async function ni(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var ri=Object.defineProperty,ii=(e,t)=>{for(var n in t)ri(e,n,{get:t[n],enumerable:!0})},ai=`AI_NoObjectGeneratedError`,oi=`vercel.ai.error.${ai}`,si=Symbol.for(oi),ci,li=class extends tn{constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:ai,message:e,cause:t}),this[ci]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return tn.hasMarker(e,oi)}};ci=si;var ui=`AI_UIMessageStreamError`,di=`vercel.ai.error.${ui}`,fi=Symbol.for(di),pi,mi=class extends tn{constructor({chunkType:e,chunkId:t,message:n}){super({name:ui,message:n}),this[pi]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return tn.hasMarker(e,di)}};pi=fi;var hi=g([b(),w(Uint8Array),w(ArrayBuffer),D(e=>globalThis.Buffer?.isBuffer(e)??!1,{message:`Must be a Buffer`})]),gi=h(()=>g([ee(),b(),E(),p(),T(b(),gi.optional()),S(gi)])),P=T(b(),T(b(),gi.optional())),_i=f({type:m(`text`),text:b(),providerOptions:P.optional()}),vi=f({type:m(`image`),image:g([hi,w(URL)]),mediaType:b().optional(),providerOptions:P.optional()}),yi=f({type:m(`file`),data:g([hi,w(URL)]),filename:b().optional(),mediaType:b(),providerOptions:P.optional()}),bi=f({type:m(`reasoning`),text:b(),providerOptions:P.optional()}),xi=f({type:m(`tool-call`),toolCallId:b(),toolName:b(),input:_(),providerOptions:P.optional(),providerExecuted:p().optional()}),Si=C(`type`,[f({type:m(`text`),value:b(),providerOptions:P.optional()}),f({type:m(`json`),value:gi,providerOptions:P.optional()}),f({type:m(`execution-denied`),reason:b().optional(),providerOptions:P.optional()}),f({type:m(`error-text`),value:b(),providerOptions:P.optional()}),f({type:m(`error-json`),value:gi,providerOptions:P.optional()}),f({type:m(`content`),value:S(g([f({type:m(`text`),text:b(),providerOptions:P.optional()}),f({type:m(`media`),data:b(),mediaType:b()}),f({type:m(`file-data`),data:b(),mediaType:b(),filename:b().optional(),providerOptions:P.optional()}),f({type:m(`file-url`),url:b(),providerOptions:P.optional()}),f({type:m(`file-id`),fileId:g([b(),T(b(),b())]),providerOptions:P.optional()}),f({type:m(`image-data`),data:b(),mediaType:b(),providerOptions:P.optional()}),f({type:m(`image-url`),url:b(),providerOptions:P.optional()}),f({type:m(`image-file-id`),fileId:g([b(),T(b(),b())]),providerOptions:P.optional()}),f({type:m(`custom`),providerOptions:P.optional()})]))})]),Ci=f({type:m(`tool-result`),toolCallId:b(),toolName:b(),output:Si,providerOptions:P.optional()}),wi=f({type:m(`tool-approval-request`),approvalId:b(),toolCallId:b()}),Ti=f({type:m(`tool-approval-response`),approvalId:b(),approved:p(),reason:b().optional()});g([f({role:m(`system`),content:b(),providerOptions:P.optional()}),f({role:m(`user`),content:g([b(),S(g([_i,vi,yi]))]),providerOptions:P.optional()}),f({role:m(`assistant`),content:g([b(),S(g([_i,yi,bi,xi,Ci,wi]))]),providerOptions:P.optional()}),f({role:m(`tool`),content:S(g([Ci,Ti])),providerOptions:P.optional()})]);function Ei(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=Ei(a,i):n[r]=i}return n}new TextEncoder,ii({},{array:()=>ji,choice:()=>Mi,json:()=>Ni,object:()=>Ai,text:()=>ki});function Di(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`);break}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop();break}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop();break}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:n=l,o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function Oi(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await ei({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await ei({text:Di(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}var ki=()=>({name:`text`,responseFormat:Promise.resolve({type:`text`}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),Ai=({schema:e,name:t,description:n})=>{let r=Kr(e);return{name:`object`,responseFormat:ni(r.jsonSchema).then(e=>({type:`json`,schema:e,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:e},t){let n=await ei({text:e});if(!n.success)throw new li({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=await $r({value:n.value,schema:r});if(!i.success)throw new li({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return i.value},async parsePartialOutput({text:e}){let t=await Oi(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value}}},createElementStreamTransform(){}}},ji=({element:e,name:t,description:n})=>{let r=Kr(e);return{name:`array`,responseFormat:ni(r.jsonSchema).then(e=>{let{$schema:r,...i}=e;return{type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{elements:{type:`array`,items:i}},required:[`elements`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:e},t){let n=await ei({text:e});if(!n.success)throw new li({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=n.value;if(typeof i!=`object`||!i||!(`elements`in i)||!Array.isArray(i.elements))throw new li({message:`No object generated: response did not match schema.`,cause:new xn({value:i,cause:`response must be an object with an elements array`}),text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});for(let n of i.elements){let i=await $r({value:n,schema:r});if(!i.success)throw new li({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason})}return i.elements},async parsePartialOutput({text:e}){let t=await Oi(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let e=t.value;if(typeof e!=`object`||!e||!(`elements`in e)||!Array.isArray(e.elements))return;let n=t.state===`repaired-parse`&&e.elements.length>0?e.elements.slice(0,-1):e.elements,i=[];for(let e of n){let t=await $r({value:e,schema:r});t.success&&i.push(t.value)}return{partial:i}}}},createElementStreamTransform(){let e=0;return new TransformStream({transform({partialOutput:t},n){if(t!=null)for(;e<t.length;e++)n.enqueue(t[e])}})}}},Mi=({options:e,name:t,description:n})=>({name:`choice`,responseFormat:Promise.resolve({type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{result:{type:`string`,enum:e}},required:[`result`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:t},n){let r=await ei({text:t});if(!r.success)throw new li({message:`No object generated: could not parse the response.`,cause:r.error,text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=r.value;if(typeof i!=`object`||!i||!(`result`in i)||typeof i.result!=`string`||!e.includes(i.result))throw new li({message:`No object generated: response did not match schema.`,cause:new xn({value:i,cause:`response must be an object that contains a choice value.`}),text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.result},async parsePartialOutput({text:t}){let n=await Oi(t);switch(n.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let t=n.value;if(typeof t!=`object`||!t||!(`result`in t)||typeof t.result!=`string`)return;let r=e.filter(e=>e.startsWith(t.result));return n.state===`successful-parse`?r.includes(t.result)?{partial:t.result}:void 0:r.length===1?{partial:r[0]}:void 0}}},createElementStreamTransform(){}}),Ni=({name:e,description:t}={})=>({name:`json`,responseFormat:Promise.resolve({type:`json`,...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:e},t){let n=await ei({text:e});if(!n.success)throw new li({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return n.value},async parsePartialOutput({text:e}){let t=await Oi(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return t.value===void 0?void 0:{partial:t.value}}},createElementStreamTransform(){}});Nn({prefix:`aitxt`,size:24}),TransformStream;var Pi=T(b(),gi.optional()),Fi=Ur(()=>Zr(g([y({type:m(`text-start`),id:b(),providerMetadata:P.optional()}),y({type:m(`text-delta`),id:b(),delta:b(),providerMetadata:P.optional()}),y({type:m(`text-end`),id:b(),providerMetadata:P.optional()}),y({type:m(`error`),errorText:b()}),y({type:m(`tool-input-start`),toolCallId:b(),toolName:b(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:Pi.optional(),dynamic:p().optional(),title:b().optional()}),y({type:m(`tool-input-delta`),toolCallId:b(),inputTextDelta:b()}),y({type:m(`tool-input-available`),toolCallId:b(),toolName:b(),input:_(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:Pi.optional(),dynamic:p().optional(),title:b().optional()}),y({type:m(`tool-input-error`),toolCallId:b(),toolName:b(),input:_(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:Pi.optional(),dynamic:p().optional(),errorText:b(),title:b().optional()}),y({type:m(`tool-approval-request`),approvalId:b(),toolCallId:b(),signature:b().optional()}),y({type:m(`tool-output-available`),toolCallId:b(),output:_(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:Pi.optional(),dynamic:p().optional(),preliminary:p().optional()}),y({type:m(`tool-output-error`),toolCallId:b(),errorText:b(),providerExecuted:p().optional(),providerMetadata:P.optional(),toolMetadata:Pi.optional(),dynamic:p().optional()}),y({type:m(`tool-output-denied`),toolCallId:b()}),y({type:m(`reasoning-start`),id:b(),providerMetadata:P.optional()}),y({type:m(`reasoning-delta`),id:b(),delta:b(),providerMetadata:P.optional()}),y({type:m(`reasoning-end`),id:b(),providerMetadata:P.optional()}),y({type:m(`source-url`),sourceId:b(),url:b(),title:b().optional(),providerMetadata:P.optional()}),y({type:m(`source-document`),sourceId:b(),mediaType:b(),title:b(),filename:b().optional(),providerMetadata:P.optional()}),y({type:m(`file`),url:b(),mediaType:b(),providerMetadata:P.optional()}),y({type:D(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:b().optional(),data:_(),transient:p().optional()}),y({type:m(`start-step`)}),y({type:m(`finish-step`)}),y({type:m(`start`),messageId:b().optional(),messageMetadata:_().optional()}),y({type:m(`finish`),finishReason:O([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`]).optional(),messageMetadata:_().optional()}),y({type:m(`abort`),reason:b().optional()}),y({type:m(`message-metadata`),messageMetadata:_()})])));function Ii(e){return e.type.startsWith(`data-`)}function Li(){return Object.create(null)}function Ri(e){return e.type.startsWith(`tool-`)}function zi(e){return e.type===`dynamic-tool`}function Bi(e){return Ri(e)||zi(e)}function Vi(e){return e.type.split(`-`).slice(1).join(`-`)}function Hi({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:Li(),activeReasoningParts:Li(),partialToolCalls:Li()}}function Ui({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{function l(e){let t=r.message.parts.filter(Bi).find(t=>t.toolCallId===e);if(t==null)throw new mi({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function u(e){let t=r.message.parts.find(t=>Ri(t)&&t.toolCallId===e.toolCallId),n=e,i=t;if(t!=null){t.state=e.state,i.input=n.input,i.output=n.output,i.errorText=n.errorText,i.rawInput=n.rawInput,i.preliminary=n.preliminary,e.title!==void 0&&(i.title=e.title),e.toolMetadata!==void 0&&(i.toolMetadata=e.toolMetadata),i.providerExecuted=n.providerExecuted??t.providerExecuted;let r=n.providerMetadata;if(r!=null)if(e.state===`output-available`||e.state===`output-error`){let e=t;e.resultProviderMetadata=r}else t.callProviderMetadata=r}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:n.input,output:n.output,rawInput:n.rawInput,errorText:n.errorText,providerExecuted:n.providerExecuted,preliminary:n.preliminary,...n.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:n.providerMetadata}:{},...n.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:n.providerMetadata}:{}})}function d(e){let t=r.message.parts.find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),n=e,i=t;if(t!=null){t.state=e.state,i.toolName=e.toolName,i.input=n.input,i.output=n.output,i.errorText=n.errorText,i.rawInput=n.rawInput??i.rawInput,i.preliminary=n.preliminary,e.title!==void 0&&(i.title=e.title),e.toolMetadata!==void 0&&(i.toolMetadata=e.toolMetadata),i.providerExecuted=n.providerExecuted??t.providerExecuted;let r=n.providerMetadata;if(r!=null)if(e.state===`output-available`||e.state===`output-error`){let e=t;e.resultProviderMetadata=r}else t.callProviderMetadata=r}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:n.input,output:n.output,errorText:n.errorText,preliminary:n.preliminary,providerExecuted:n.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...n.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:n.providerMetadata}:{},...n.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:n.providerMetadata}:{}})}async function f(e){if(e!=null){let n=r.message.metadata==null?e:Ei(r.message.metadata,e);t!=null&&await Qr({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new mi({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new mi({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`reasoning-start`:{let t={type:`reasoning`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new mi({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new mi({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:r.message.parts.push({type:`file`,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=r.message.parts.filter(Ri);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new mi({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let{value:n}=await Oi(t.text);t.dynamic?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-input-available`:e.dynamic?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=r.message.parts.filter(Bi).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),c();break}case`tool-approval-request`:{let t=l(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.signature==null?{}:{signature:e.signature}},c();break}case`tool-output-denied`:{let t=l(e.toolCallId);t.state=`output-denied`,c();break}case`tool-output-available`:{let t=l(e.toolCallId);t.type===`dynamic-tool`?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:Vi(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-output-error`:{let t=l(e.toolCallId);t.type===`dynamic-tool`?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:Vi(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:r.activeTextParts=Li(),r.activeReasoningParts=Li();break;case`start`:e.messageId!=null&&(r.message.id=e.messageId),await f(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c();break;case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await f(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await f(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(Ii(e)){if(n?.[e.type]!=null){let t=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=t>=0?t:r.message.parts.length;await Qr({value:e.data,schema:n[e.type],context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}async function Wi({stream:e,onError:t}){let n=e.getReader();try{for(;;){let{done:e}=await n.read();if(e)break}}catch(e){t?.(e)}finally{n.releaseLock()}}Nn({prefix:`aitxt`,size:24}),T(b(),gi.optional()),Nn({prefix:`aiobj`,size:24});var Gi=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}};Nn({prefix:`aiobj`,size:24});async function Ki(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw Error(`FileList is not supported in the current environment`);return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}var qi=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await ni(this.body),r=await ni(this.headers),i=await ni(this.credentials),a={...Fn(r),...Fn(t.headers)},o=await this.prepareSendMessagesRequest?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Fn(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"Content-Type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw Error(await d.text()??`Failed to fetch the chat response.`);if(!d.body)throw Error(`The response body is empty.`);return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await ni(this.body),n=await ni(this.headers),r=await ni(this.credentials),i={...Fn(n),...Fn(e.headers)},a=await this.prepareReconnectToStreamRequest?.call(this,{api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api??`${this.api}/${e.chatId}/stream`,s=a?.headers===void 0?i:Fn(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c});if(l.status===204)return null;if(!l.ok)throw Error(await l.text()??`Failed to fetch the chat response.`);if(!l.body)throw Error(`The response body is empty.`);return this.processResponseStream(l.body)}},Ji=class extends qi{constructor(e={}){super(e)}processResponseStream(e){return ti({stream:e,schema:Fi}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Yi=class{constructor({generateId:e=Pn,id:t=e(),transport:n=new Ji,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.activeResponse=void 0,this.jobExecutor=new Gi,this.sendMessage=async(e,t)=>{if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...t});return}let n;if(n=`text`in e||`files`in e?{parts:[...Array.isArray(e.files)?e.files:await Ki(e.files),...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}:e,e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw Error(`message with id ${e.messageId} not found`);if(this.state.messages[t].role!==`user`)throw Error(`message with id ${e.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{...n,id:e.messageId,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw Error(`message ${e} not found`);this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.state.messages,a=i[i.length-1],o=r=>Bi(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{id:e,approved:t,reason:n}}:r;this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(o)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...r})})}),this.addToolOutput=async({state:e=`output-available`,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.state.messages,o=a[a.length-1],s=i=>Bi(i)&&i.toolCallId===t?{...i,state:e,output:n,errorText:r}:i;this.state.replaceMessage(a.length-1,{...o,parts:o.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...i})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.status!==`streaming`&&this.status!==`submitted`||this.activeResponse?.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e==`object`&&`then`in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a;let o;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(e==null)return;o=e}catch(e){this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e});return}this.setStatus({status:`submitted`,error:void 0});let s=this.lastMessage,c=!1,l=!1,u=!1;try{let a={state:Hi({lastMessage:this.state.snapshot(s),messageId:this.generateId()}),abortController:new AbortController};a.abortController.signal.addEventListener(`abort`,()=>{c=!0}),this.activeResponse=a;let l;l=e===`resume-stream`?o:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Wi({stream:Ui({stream:l,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>e({state:a.state,write:()=>{this.setStatus({status:`streaming`}),a.state.message.id===this.lastMessage?.id?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message)}})),onError:e=>{throw e}}),onError:e=>{throw e}}),this.setStatus({status:`ready`})}catch(e){if(c||e.name===`AbortError`)return c=!0,this.setStatus({status:`ready`}),null;u=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(l=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:l,isError:u,finishReason:this.activeResponse?.state.finishReason})}catch(e){console.error(e)}this.activeResponse=void 0}!u&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r})}},Xi=i(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n})),F=n(a(),1),Zi=n(Xi(),1),Qi=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},I=(e,t,n)=>(Qi(e,t,`read from private field`),n?n.call(e):t.get(e)),$i=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},ea=(e,t,n,r)=>(Qi(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function ta(e,t){return t==null?e:(0,Zi.default)(e,t)}var na,ra,ia,aa,oa,sa,ca,la,ua,da=class{constructor(e=[]){$i(this,na,void 0),$i(this,ra,`ready`),$i(this,ia,void 0),$i(this,aa,new Set),$i(this,oa,new Set),$i(this,sa,new Set),this.pushMessage=e=>{ea(this,na,I(this,na).concat(e)),I(this,ca).call(this)},this.popMessage=()=>{ea(this,na,I(this,na).slice(0,-1)),I(this,ca).call(this)},this.replaceMessage=(e,t)=>{ea(this,na,[...I(this,na).slice(0,e),this.snapshot(t),...I(this,na).slice(e+1)]),I(this,ca).call(this)},this.snapshot=e=>structuredClone(e),this[`~registerMessagesCallback`]=(e,t)=>{let n=t?ta(e,t):e;return I(this,aa).add(n),()=>{I(this,aa).delete(n)}},this[`~registerStatusCallback`]=e=>(I(this,oa).add(e),()=>{I(this,oa).delete(e)}),this[`~registerErrorCallback`]=e=>(I(this,sa).add(e),()=>{I(this,sa).delete(e)}),$i(this,ca,()=>{I(this,aa).forEach(e=>e())}),$i(this,la,()=>{I(this,oa).forEach(e=>e())}),$i(this,ua,()=>{I(this,sa).forEach(e=>e())}),ea(this,na,e)}get status(){return I(this,ra)}set status(e){ea(this,ra,e),I(this,la).call(this)}get error(){return I(this,ia)}set error(e){ea(this,ia,e),I(this,ua).call(this)}get messages(){return I(this,na)}set messages(e){ea(this,na,[...e]),I(this,ca).call(this)}};na=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=new WeakMap,oa=new WeakMap,sa=new WeakMap,ca=new WeakMap,la=new WeakMap,ua=new WeakMap;var fa,pa=class extends Yi{constructor({messages:e,...t}){let n=new da(e);super({...t,state:n}),$i(this,fa,void 0),this[`~registerMessagesCallback`]=(e,t)=>I(this,fa)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>I(this,fa)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>I(this,fa)[`~registerErrorCallback`](e),ea(this,fa,n)}};fa=new WeakMap;function ma({experimental_throttle:e,resume:t=!1,...n}={}){let r=(0,F.useRef)(`chat`in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});`chat`in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});let i={...n,onToolCall:e=>{var t;return(t=r.current).onToolCall?.call(t,e)},onData:e=>{var t;return(t=r.current).onData?.call(t,e)},onFinish:e=>{var t;return(t=r.current).onFinish?.call(t,e)},onError:e=>{var t;return(t=r.current).onError?.call(t,e)},sendAutomaticallyWhen:e=>{var t;return(t=r.current).sendAutomaticallyWhen?.call(t,e)??!1}},a=(0,F.useRef)(`chat`in n?n.chat:new pa(i));(`chat`in n&&n.chat!==a.current||`id`in n&&a.current.id!==n.id)&&(a.current=`chat`in n?n.chat:new pa(i));let o=(0,F.useSyncExternalStore)((0,F.useCallback)(t=>a.current[`~registerMessagesCallback`](t,e),[e,a.current.id]),()=>a.current.messages,()=>a.current.messages),s=(0,F.useSyncExternalStore)(a.current[`~registerStatusCallback`],()=>a.current.status,()=>a.current.status),c=(0,F.useSyncExternalStore)(a.current[`~registerErrorCallback`],()=>a.current.error,()=>a.current.error),l=(0,F.useCallback)(e=>{typeof e==`function`&&(e=e(a.current.messages)),a.current.messages=e},[a]);return(0,F.useEffect)(()=>{t&&a.current.resumeStream()},[t,a]),{id:a.current.id,messages:o,setMessages:l,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:c,resumeStream:a.current.resumeStream,status:s,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}function ha(e=`msg`){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function ga(e,t){return typeof e.content==`string`?e.content:t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``)}function _a(e){let t=e.filter(e=>e.type===`reasoning`||e.type===`reasoning-delta`).map(e=>e.text??``).join(`
17
+ `).trim();return t.length>0?t:void 0}function va(e){let t=e=>{if(e&&typeof e==`object`)return e;if(typeof e!=`string`)return;let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);return e&&typeof e==`object`?e:void 0}catch{return}},n=[e];e&&typeof e==`object`&&`value`in e&&n.push(e.value);let r;for(let e of n){let n=t(e);if(n){if(typeof n.status==`string`)return n;r??=n}}return r}function ya(e){let t=va(e);if(!t)return;let n=t.pendingActionId;if(t.status===`pending_approval`&&typeof n==`string`&&n.length>0)return{pendingActionId:n,raw:t}}function ba(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function xa(e){let t=va(e);if(!t||t.status!==`blueprint_proposed`)return;let n=t.blueprint,r=n&&typeof n==`object`?n:{},i=(Array.isArray(r.objects)?r.objects:[]).flatMap(e=>{let t=e;return typeof t?.name!=`string`||!t.name?[]:[{name:t.name,...typeof t.label==`string`&&t.label?{label:t.label}:{},fieldCount:Array.isArray(t.fields)?t.fields.length:0}]});if(i.length===0)return;let a=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,o=t.counts??{},s={objects:a(o.objects,i.length),views:a(o.views,Array.isArray(r.views)?r.views.length:0),dashboards:a(o.dashboards,Array.isArray(r.dashboards)?r.dashboards.length:0),seedData:a(o.seedData,Array.isArray(r.seedData)?r.seedData.length:0)},c=ba(t.questions),l=t.questionChoices,u=Array.isArray(l)?l.flatMap(e=>{let t=e;if(typeof t?.text!=`string`||!t.text)return[];let n=Array.isArray(t.options)?t.options.filter(e=>typeof e==`string`&&e.trim().length>0):[];return n.length>=2?[{text:t.text,options:n}]:[]}):[],d=typeof t.summary==`string`&&t.summary?t.summary:typeof r.summary==`string`&&r.summary?r.summary:void 0,f=t.targetApp;return{...d?{summary:d}:{},objects:i,counts:s,questions:c.length?c:ba(r.questions),...u.length?{questionChoices:u}:{},assumptions:ba(r.assumptions),...typeof f==`string`&&f?{targetApp:f}:{}}}function Sa(e){let t=va(e);if(!t||t.status!==`drafted`)return;let n=[];if(Array.isArray(t.drafted)){for(let e of t.drafted)if(e&&typeof e==`object`){let{type:t,name:r}=e;typeof t==`string`&&typeof r==`string`&&n.push({type:t,name:r})}}else typeof t.type==`string`&&typeof t.name==`string`&&n.push({type:t.type,name:t.name});if(n.length===0)return;let r=Array.isArray(t.failed)?t.failed.length:0,i=t.verification,a=i&&typeof i==`object`&&typeof i.errors==`number`&&typeof i.warnings==`number`?{errors:i.errors,warnings:i.warnings}:void 0,o=t.issues,s=Array.isArray(o)?o.flatMap(e=>{let t=e;return typeof t?.message!=`string`||!t.message?[]:[{severity:t.severity===`error`?`error`:`warning`,code:typeof t.code==`string`?t.code:`issue`,message:t.message,...typeof t.fix==`string`&&t.fix?{fix:t.fix}:{}}]}):[],c=t.nextSteps,l=Array.isArray(c)?c.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{items:n,summary:typeof t.summary==`string`?t.summary:void 0,...typeof t.packageId==`string`&&t.packageId?{packageId:t.packageId}:{},...t.autoPublishable===!0?{autoPublishable:!0}:{},...r>0?{failedCount:r}:{},...l.length?{nextSteps:l}:{},...t.materialized===!0?{materialized:!0}:{},...a?{verification:a}:{},...s.length?{issues:s}:{}}}function Ca(e){return e.replace(/[._-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase())}function wa(e){if(!e||!Array.isArray(e.items)||e.items.length===0)return;let t=e.items.find(e=>e.type===`app`);if(t)return{phase:`done`,appLabel:Ca(t.name),items:e.items,done:e.items.length,total:e.items.length}}function Ta(e,t={}){return e.filter(e=>e.type===`dynamic-tool`?!0:typeof e.type==`string`&&e.type.startsWith(`tool-`)).map(e=>{let n=e.type===`dynamic-tool`?e.toolName??`tool`:typeof e.type==`string`?e.type.replace(/^tool-/,``):`tool`,r=e.output??e.result,i=ya(r),a=Sa(r),o=xa(r),s=e.state,c=(s===`input-available`||s===`input-streaming`)&&(r!==void 0||!t.liveTail)?`output-available`:s,l=i&&c!==`output-error`?`approval-requested`:c;return{toolCallId:e.toolCallId??e.id??`${e.type??`tool`}-${Math.random().toString(36).slice(2,8)}`,toolName:n,args:e.input??e.args,result:r,errorText:e.errorText,state:l,pendingActionId:i?.pendingActionId,draftReview:a,proposedPlan:o}})}function Ea(e){let t=e.filter(e=>e.type===`source-url`||e.type===`source`).map(e=>({id:e.id,title:e.title,url:e.url??e.href})).filter(e=>!!e.url);return t.length>0?t:void 0}function Da(e){let t=e.filter(e=>e.type===`data-build-progress`).pop()?.data;if(!t||typeof t!=`object`)return;let n=t,r=Array.isArray(n.items)?n.items.filter(e=>typeof e?.type==`string`&&typeof e?.name==`string`).map(e=>({type:e.type,name:e.name})):[];return{phase:n.phase===`data`||n.phase===`done`?n.phase:`structure`,...typeof n.appLabel==`string`?{appLabel:n.appLabel}:{},items:r,done:typeof n.done==`number`?n.done:r.length,total:typeof n.total==`number`?n.total:r.length,...typeof n.seq==`number`?{seq:n.seq}:{}}}function Oa(e){let t=[];for(let n of e){if(n.type!==`data-chart`)continue;let e=n.data;if(!e||typeof e!=`object`)continue;let r=e,i=Array.isArray(r.data)?r.data:[],a=Array.isArray(r.series)?r.series.filter(e=>e&&typeof e.dataKey==`string`).map(e=>({dataKey:e.dataKey,...typeof e.label==`string`?{label:e.label}:{}})):[];a.length!==0&&t.push({...typeof r.chartType==`string`?{chartType:r.chartType}:{},...typeof r.title==`string`?{title:r.title}:{},data:i,...typeof r.xAxisKey==`string`?{xAxisKey:r.xAxisKey}:{},series:a})}return t.length>0?t:void 0}function ka(e,t={}){let n=Array.isArray(e.parts)?e.parts:[],r=Ta(n,{liveTail:t.streaming}),i=Array.isArray(e.toolInvocations)?e.toolInvocations:[],a=r.length>0?r:i,o=Da(n)??a.map(e=>wa(e.draftReview)).find(e=>!!e);return{id:e.id??`msg-${Math.random().toString(36).slice(2,8)}`,role:e.role??`assistant`,content:ga(e,n),reasoning:_a(n),toolInvocations:a,sources:Ea(n),buildProgress:o,charts:Oa(n),streaming:t.streaming}}function Aa(e,t={}){if(!Array.isArray(e)||e.length===0)return[];let n=e.length-1;return e.map((e,r)=>ka(e,{streaming:!!t.isStreaming&&r===n&&e.role===`assistant`}))}function ja(e){let t=[...e.messages].reverse().find(e=>e.role===`user`);return{body:{...e.body??{},id:e.id,messages:e.messages,trigger:e.trigger,messageId:e.messageId,...t?{turnId:t.id}:{}}}}function Ma(e){return(e??[]).map((e,t)=>({id:e.id||`msg-${t}`,role:e.role||`user`,content:e.content||``,timestamp:typeof e.timestamp==`string`?e.timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():void 0,metadata:e.metadata,streaming:e.streaming,toolInvocations:e.toolInvocations}))}function Na(e={}){let{api:t,initialMessages:n,conversationId:r,systemPrompt:i,model:a,streamingEnabled:o=!0,headers:s,body:c,maxToolRoundtrips:l=5,onError:u,showTimestamp:d,autoResponse:f,autoResponseText:p,autoResponseDelay:m=1e3,onSend:h}=e,g=(0,F.useRef)(t?`api`:`local`).current===`api`,_=(0,F.useMemo)(()=>(n??[]).map((e,t)=>{if(Array.isArray(e.parts)&&e.parts.length>0)return{id:e.id||`msg-${t}`,role:e.role||`user`,parts:e.parts};let n=Ma([e])[0],r=[];n.content&&r.push({type:`text`,text:n.content}),e.reasoning&&r.push({type:`reasoning`,text:e.reasoning});for(let e of n.toolInvocations??[])r.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.args,output:e.result,errorText:e.errorText,state:e.state});return{id:n.id||`msg-${t}`,role:n.role,parts:r.length>0?r:[{type:`text`,text:``}]}}),[]),v=ma({transport:(0,F.useMemo)(()=>{if(g)return new Ji({api:t,headers:{...s},body:{...c,...r?{conversationId:r}:{},...a?{model:a}:{},...i?{systemPrompt:i}:{},...o===void 0?{}:{stream:o}},prepareSendMessagesRequest:({id:e,body:t,messages:n,trigger:r,messageId:i})=>ja({id:e,body:t,messages:n,trigger:r,messageId:i})})},[g,t,s,c,a,i,o,r]),messages:g&&_.length>0?_:void 0,onError:g?e=>{u?.(e)}:void 0}),[y,b]=(0,F.useState)(()=>Ma(n)),[x,S]=(0,F.useState)(!1),[C,w]=(0,F.useState)(``),[T,E]=(0,F.useState)(``),D=(0,F.useRef)(null);if((0,F.useEffect)(()=>()=>{D.current&&=(clearTimeout(D.current),null)},[]),g){let{messages:e,status:t,error:n,sendMessage:r,regenerate:i,stop:a,setMessages:o}=v,s=t===`submitted`||t===`streaming`,c=Aa(e,{isStreaming:s}).map((t,n)=>({...t,metadata:e[n]?.metadata}));return{messages:c,isLoading:s,error:n,sendMessage:(0,F.useCallback)(e=>{let t=e.trim();if(!t)return;let n=[...c,{id:ha(`msg`),role:`user`,content:t}];r({text:t}),E(``),h?.(t,n)},[r,h,c]),stop:a,reload:i,clear:(0,F.useCallback)(()=>{o([])},[o]),setMessages:o,isApiMode:!0,input:T,setInput:E,handleInputChange:(0,F.useCallback)(e=>{E(e.target.value)},[])}}let ee=(0,F.useCallback)(()=>{D.current&&=(clearTimeout(D.current),null),S(!1)},[]);return{messages:y,isLoading:x,error:void 0,sendMessage:(0,F.useCallback)(e=>{if(!e.trim())return;let t={id:ha(`msg`),role:`user`,content:e.trim(),timestamp:d?new Date().toLocaleTimeString():void 0};b(n=>{let r=[...n,t];return h?.(e.trim(),r),r}),w(``),f&&(S(!0),D.current=setTimeout(()=>{let e={id:ha(`msg`),role:`assistant`,content:p||`Thank you for your message!`,timestamp:d?new Date().toLocaleTimeString():void 0};b(t=>[...t,e]),S(!1)},m))},[d,f,p,m,h]),stop:ee,reload:(0,F.useCallback)(()=>{},[]),clear:(0,F.useCallback)(()=>{ee(),b([])},[ee]),isApiMode:!1,input:C,setInput:w,handleInputChange:(0,F.useCallback)(e=>{w(e.target.value)},[])}}var Pa=[[`build`,`metadata_assistant`],[`ask`,`data_chat`]];function Fa(e){return Pa.find(t=>t.includes(e))??[e]}function Ia(e){return Fa(e)[0]}function La(e,t){if(e){if(t.includes(e))return e;for(let n of Fa(e))if(t.includes(n))return n}}function Ra(e){return e!=null&&Pa.some(t=>t.includes(e))}function za(e){return e!=null&&Ia(e)===`build`}function Ba(e){return e!=null&&Ia(e)===`ask`}function Va(e,t){if(e.length===0)return;let n=e.map(e=>e.name);if(t){let e=La(t,n);if(e)return e}return La(`ask`,n)||e[0].name}function Ha(e){return e.filter(e=>typeof e?.name==`string`&&e.name.length>0).map(e=>({name:e.name,label:e.label||e.name,description:e.description,role:e.role,active:e.active!==!1}))}function Ua(e={}){let{apiBase:t,headers:n,enabled:r=!0,fallback:i=[]}=e,[a,o]=(0,F.useState)(i),[s,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(void 0),[d,f]=(0,F.useState)(0),p=(0,F.useRef)(n);return p.current=n,(0,F.useEffect)(()=>{if(!r||!t)return;let e=new AbortController,n=!1;c(!0),u(void 0);let a=`${t.replace(/\/$/,``)}/agents`;return fetch(a,{method:`GET`,headers:{Accept:`application/json`,...p.current??{}},credentials:`include`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Failed to load agents (${e.status})`);return e.json()}).then(e=>{if(n)return;let t=Ha(Array.isArray(e)?e:e?.agents??[]);o(t.length>0?t:i)}).catch(e=>{n||e.name===`AbortError`||(u(e),o(i))}).finally(()=>{n||c(!1)}),()=>{n=!0,e.abort()}},[t,r,d]),{agents:a,isLoading:s,error:l,refetch:(0,F.useCallback)(()=>f(e=>e+1),[])}}var L=c(),Wa=F.createContext(null);function Ga({defaultOpen:e=!1,children:t}){let[n,r]=F.useState(e),[i,a]=F.useState(!1),o=F.useMemo(()=>({isOpen:n,isFullscreen:i,open:()=>r(!0),close:()=>{r(!1),a(!1)},toggle:()=>r(e=>!e),toggleFullscreen:()=>a(e=>!e)}),[n,i]);return(0,L.jsx)(Wa.Provider,{value:o,children:t})}function Ka(){let e=F.useContext(Wa);if(!e)throw Error(`useFloatingChatbot must be used within a <FloatingChatbotProvider>`);return e}function qa(){try{let{t:e}=d();return(t,n)=>{let r=e(`common.${t}`);return!r||r===`common.${t}`?n:r}}catch{return(e,t)=>t}}var Ja={32:`size-8`,36:`size-9`,40:`size-10`,44:`size-11`,48:`size-12`,52:`size-[52px]`,56:`size-14`,60:`size-[60px]`,64:`size-16`,72:`size-[72px]`,80:`size-20`};function Ya(e,t){return t.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t)}function Xa(e){return Ja[e]??Ja[Ya(e,Object.keys(Ja).map(Number))]}function Za({position:e=`bottom-right`,size:t=56,className:n}){let{isOpen:r,toggle:i}=Ka(),a=qa();return(0,L.jsx)(A,{onClick:i,className:j(`fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105`,Xa(t),r&&`hidden`,e===`bottom-right`?`right-6 bottom-20 sm:bottom-6`:`left-6 bottom-20 sm:bottom-6`,n),size:`icon`,"aria-label":r?a(`closeChat`,`Close chat`):a(`openChat`,`Open chat`),"data-testid":`floating-chatbot-trigger`,children:r?(0,L.jsx)(le,{className:`h-6 w-6`}):(0,L.jsx)(Ae,{className:`h-6 w-6`})})}var Qa={300:`sm:w-[300px]`,320:`sm:w-[320px]`,340:`sm:w-[340px]`,360:`sm:w-[360px]`,380:`sm:w-[380px]`,400:`sm:w-[400px]`,420:`sm:w-[420px]`,440:`sm:w-[440px]`,450:`sm:w-[450px]`,460:`sm:w-[460px]`,480:`sm:w-[480px]`,500:`sm:w-[500px]`,520:`sm:w-[520px]`,560:`sm:w-[560px]`,600:`sm:w-[600px]`,640:`sm:w-[640px]`,720:`sm:w-[720px]`,800:`sm:w-[800px]`},$a={360:`h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]`,400:`h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]`,420:`h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]`,440:`h-[min(440px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[440px]`,480:`h-[min(480px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[480px]`,500:`h-[min(500px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[500px]`,520:`h-[min(520px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[520px]`,560:`h-[min(560px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[560px]`,600:`h-[min(600px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[600px]`,640:`h-[min(640px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[640px]`,720:`h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]`,800:`h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]`};function eo(e,t){return t.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t)}function to(e){return Qa[e]??Qa[eo(e,Object.keys(Qa).map(Number))]}function no(e){return $a[e]??$a[eo(e,Object.keys($a).map(Number))]}function ro({title:e=`Chat`,position:t=`bottom-right`,width:n=400,height:r=520,children:i,className:a,headerExtra:o,headerActions:s}){let{isOpen:c,isFullscreen:l,close:u,toggleFullscreen:d}=Ka();return c?(0,L.jsxs)(`div`,{className:j(`fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all`,l?`inset-0 h-svh w-screen rounded-none`:t===`bottom-right`?j(`left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg`,`sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]`,to(n),no(r)):j(`left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg`,`sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]`,to(n),no(r)),a),role:`dialog`,"aria-label":e,"data-testid":`floating-chatbot-panel`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-2 border-b bg-muted/40 px-4 py-2`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e}),o?(0,L.jsx)(`div`,{className:`mr-1 flex min-w-0 items-center justify-end`,"data-testid":`floating-chatbot-header-extra`,children:o}):null,(0,L.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[s,(0,L.jsx)(A,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:d,"aria-label":l?`Exit fullscreen`:`Fullscreen`,"data-testid":`floating-chatbot-fullscreen`,children:l?(0,L.jsx)(kt,{className:`h-4 w-4`}):(0,L.jsx)(ue,{className:`h-4 w-4`})}),(0,L.jsx)(A,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:u,"aria-label":`Close chat`,"data-testid":`floating-chatbot-close`,children:(0,L.jsx)(le,{className:`h-4 w-4`})})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:i})]}):null}var io={ai:`AI`,api:`API`,crm:`CRM`,hitl:`HITL`,id:`ID`,ids:`IDs`,rag:`RAG`,sql:`SQL`,url:`URL`,utc:`UTC`};function ao(e){if(!e)return``;let t=String(e).trim();if(!t)return``;let n=t.replace(/[_-]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).split(/\s+/).filter(Boolean);return n.length===0?t:n.map((e,t)=>{let n=e.toLowerCase();return io[n]?io[n]:t===0?n.charAt(0).toUpperCase()+n.slice(1):n}).join(` `)}function oo(e){if(e==null)return e;let t=e;for(let e=0;e<2;e++){if(typeof t==`object`&&t&&!Array.isArray(t)&&t.type===`text`&&typeof t.value==`string`){t=t.value;continue}break}if(typeof t==`string`){let e=t.trim();if(e.startsWith(`{`)&&e.endsWith(`}`)||e.startsWith(`[`)&&e.endsWith(`]`))try{return JSON.parse(e)}catch{}}return t}function so(e){let t=(e instanceof Error?e.message:String(e??``)).replace(/\s+/g,` `).trim();if(!t)return{summary:`Something went wrong. Please try again.`};let n=t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i,``),r=n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim()??n,i=r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim()??r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim()??(r.length>140?`${r.slice(0,137).trimEnd()}…`:r);return{summary:i.replace(/:$/,``),details:n.length>i.length?n:void 0}}var co=new Set([`ai_design_quota_exhausted`,`ai_data_chat_trial_exhausted`,`ai_allowance_exhausted`]);function lo(e){let t=e instanceof Error?e.message:String(e??``);if(!t)return null;let n=t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i,``).replace(/^Invalid error response format:\s*/i,``).trim(),r=n.indexOf(`{`),i=n.lastIndexOf(`}`);if(r<0||i<=r)return null;let a;try{a=JSON.parse(n.slice(r,i+1))}catch{return null}return!a||typeof a.error!=`string`||!co.has(a.error)?null:{code:a.error,message:typeof a.message==`string`?a.message:``,messageEn:typeof a.messageEn==`string`?a.messageEn:void 0,upgrade:a.upgrade===!0,topUp:a.topUp===!0}}var uo={damping:.7,stiffness:.05,mass:1.25},fo=70,po=1e3/60,mo=350,ho=!1;globalThis.document?.addEventListener(`mousedown`,()=>{ho=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{ho=!1}),globalThis.document?.addEventListener(`click`,()=>{ho=!1});var go=(e={})=>{let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(e.initial!==!1),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null);s.current=e;let c=(0,F.useCallback)(()=>{if(!ho)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,F.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,F.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,F.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=fo}}},[]),f=(0,F.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=yo(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/po;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:yo(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,F.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,F.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,F.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=_o(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=_o(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=yo(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:mo})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function _o(e,t){let n=(0,F.useCallback)(t=>(n.current=t,e(t)),t);return n}var vo=new Map;function yo(...e){let t={...uo},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return vo.has(r)||vo.set(r,Object.freeze(t)),n?`instant`:vo.get(r)}var bo=(0,F.createContext)(null),xo=typeof window<`u`?F.useLayoutEffect:F.useEffect;function So({instance:e,children:t,resize:n,initial:r,mass:i,damping:a,stiffness:o,targetScrollTop:s,contextRef:c,...l}){let u=(0,F.useRef)(null),d=go({mass:i,damping:a,stiffness:o,resize:n,initial:r,targetScrollTop:F.useCallback((e,t)=>(y?.targetScrollTop??s)?.(e,t)??e,[s])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:h,isAtBottom:g,escapedFromLock:_,state:v}=e??d,y=(0,F.useMemo)(()=>({scrollToBottom:m,stopScroll:h,scrollRef:f,isAtBottom:g,escapedFromLock:_,contentRef:p,state:v,get targetScrollTop(){return u.current},set targetScrollTop(e){u.current=e}}),[m,g,p,f,h,_,v]);return(0,F.useImperativeHandle)(c,()=>y,[y]),xo(()=>{f.current&&getComputedStyle(f.current).overflow===`visible`&&(f.current.style.overflow=`auto`)},[]),F.createElement(bo.Provider,{value:y},F.createElement(`div`,{...l},typeof t==`function`?t(y):t))}(function(e){function t({children:e,scrollClassName:t,...n}){let r=Co();return F.createElement(`div`,{ref:r.scrollRef,style:{height:`100%`,width:`100%`,scrollbarGutter:`stable both-edges`},className:t},F.createElement(`div`,{...n,ref:r.contentRef},typeof e==`function`?e(r):e))}e.Content=t})(So||={});function Co(){let e=(0,F.useContext)(bo);if(!e)throw Error(`use-stick-to-bottom component context must be used within a StickToBottom component`);return e}var wo=({className:e,...t})=>(0,L.jsx)(So,{className:j(`relative flex-1 overflow-y-hidden`,e),initial:`smooth`,resize:`smooth`,role:`log`,...t}),To=({className:e,...t})=>(0,L.jsx)(So.Content,{className:j(`flex flex-col gap-8 p-4`,e),...t}),Eo=({className:e,title:t=`No messages yet`,description:n=`Start a conversation to see messages here`,icon:r,children:i,...a})=>(0,L.jsx)(`div`,{className:j(`flex size-full flex-col items-center justify-center gap-3 p-8 text-center`,e),...a,children:i??(0,L.jsxs)(L.Fragment,{children:[r&&(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:r}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`font-medium text-sm`,children:t}),n&&(0,L.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n})]})]})}),Do=({className:e,...t})=>{let{isAtBottom:n,scrollToBottom:r}=Co(),i=(0,F.useCallback)(()=>{r()},[r]);return!n&&(0,L.jsx)(A,{className:j(`absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full`,e),onClick:i,size:`icon`,type:`button`,variant:`outline`,...t,children:(0,L.jsx)(dt,{className:`size-4`})})};Pt(`flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none`}},defaultVariants:{orientation:`horizontal`}});var Oo=Object.defineProperty,ko=Object.defineProperties,Ao=Object.getOwnPropertyDescriptors,jo=Object.getOwnPropertySymbols,Mo=Object.prototype.hasOwnProperty,No=Object.prototype.propertyIsEnumerable,Po=(e,t,n)=>t in e?Oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fo=(e,t)=>{for(var n in t||={})Mo.call(t,n)&&Po(e,n,t[n]);if(jo)for(var n of jo(t))No.call(t,n)&&Po(e,n,t[n]);return e},Io=(e,t)=>ko(e,Ao(t)),Lo=(e,t)=>{let n=!1,r=!1;for(let i=0;i<t;i+=1){if(e[i]===`\\`&&i+1<e.length&&e[i+1]==="`"){i+=1;continue}if(e.substring(i,i+3)==="```"){r=!r,i+=2;continue}!r&&e[i]==="`"&&(n=!n)}return n||r},Ro=(e,t)=>{let n=e.substring(t,t+3)==="```",r=t>0&&e.substring(t-1,t+2)==="```",i=t>1&&e.substring(t-2,t+1)==="```";return n||r||i},zo=e=>{let t=0;for(let n=0;n<e.length;n+=1){if(e[n]===`\\`&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!Ro(e,n)&&(t+=1)}return t},Bo=(e,t)=>{let n=!1,r=!1,i=-1;for(let a=0;a<e.length;a+=1){if(e[a]===`\\`&&a+1<e.length&&e[a+1]==="`"){a+=1;continue}if(e.substring(a,a+3)==="```"){r=!r,a+=2;continue}if(!r&&e[a]==="`")if(n){if(i<t&&t<a)return!0;n=!1,i=-1}else n=!0,i=a}return!1},Vo=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,Ho=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(Vo,(t,n,r,i)=>Lo(e,i)?t:`${n}\\>${r}`),Uo=/(\*\*)([^*]*\*?)$/,Wo=/(__)([^_]*?)$/,Go=/(\*\*\*)([^*]*?)$/,Ko=/(\*)([^*]*?)$/,qo=/(_)([^_]*?)$/,Jo=/(`)([^`]*?)$/,Yo=/(~~)([^~]*?)$/,Xo=/^[\s_~*`]*$/,Zo=/^[\s]*[-*+][\s]+$/,Qo=/[\p{L}\p{N}_]/u,$o=/^```[^`\n]*```?$/,es=/^\*{4,}$/,ts=/(__)([^_]+)_$/,ns=/(~~)([^~]+)~$/,rs=/~~/g,is=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95?!0:Qo.test(e)},as=(e,t)=>{let n=1;for(let r=t-1;r>=0;--r)if(e[r]===`]`)n+=1;else if(e[r]===`[`&&(--n,n===0))return r;return-1},os=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r+=1)if(e[r]===`[`)n+=1;else if(e[r]===`]`&&(--n,n===0))return r;return-1},ss=(e,t)=>{let n=!1,r=!1;for(let i=0;i<e.length&&i<t;i+=1){if(e[i]===`\\`&&e[i+1]===`$`){i+=1;continue}e[i]===`$`&&(e[i+1]===`$`?(r=!r,i+=1,n=!1):r||(n=!n))}return n||r},cs=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
18
+ `)return!1}return!1},ls=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`)`)return!1;if(e[n]===`(`)return n>0&&e[n-1]===`]`?cs(e,t):!1;if(e[n]===`
19
+ `)return!1}return!1},us=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`>`)return!1;if(e[n]===`<`){let t=n+1<e.length?e[n+1]:``;return t>=`a`&&t<=`z`||t>=`A`&&t<=`Z`||t===`/`}if(e[n]===`
20
+ `)return!1}return!1},ds=(e,t,n)=>{let r=0;for(let n=t-1;n>=0;--n)if(e[n]===`
21
21
  `){r=n+1;break}let i=e.length;for(let n=t;n<e.length;n+=1)if(e[n]===`
22
- `){i=n;break}let a=e.substring(r,i),o=0,s=!1;for(let e of a)if(e===n)o+=1;else if(e!==` `&&e!==` `){s=!0;break}return o>=3&&!s},ts=(e,t,n,r)=>n===`\\`||e.includes(`$`)&&Xo(e,t)?!0:n!==`*`&&r===`*`?(t<e.length-2?e[t+2]:``)!==`*`:!!(n===`*`||n&&r&&qo(n)&&qo(r)||(!n||n===` `||n===` `||n===`
22
+ `){i=n;break}let a=e.substring(r,i),o=0,s=!1;for(let e of a)if(e===n)o+=1;else if(e!==` `&&e!==` `){s=!0;break}return o>=3&&!s},fs=(e,t,n,r)=>n===`\\`||e.includes(`$`)&&ss(e,t)?!0:n!==`*`&&r===`*`?(t<e.length-2?e[t+2]:``)!==`*`:!!(n===`*`||n&&r&&is(n)&&is(r)||(!n||n===` `||n===` `||n===`
23
23
  `)&&(!r||r===` `||r===` `||r===`
24
- `)),ns=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`*`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;ts(e,i,a,o)||(t+=1)}return t},rs=(e,t,n,r)=>!!(n===`\\`||e.includes(`$`)&&Xo(e,t)||Qo(e,t)||$o(e,t)||n===`_`||r===`_`||n&&r&&qo(n)&&qo(r)),is=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`_`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;rs(e,i,a,o)||(t+=1)}return t},as=e=>{let t=0,n=0,r=!1;for(let i=0;i<e.length;i+=1){if(e[i]==="`"&&i+2<e.length&&e[i+1]==="`"&&e[i+2]==="`"){n>=3&&(t+=Math.floor(n/3)),n=0,r=!r,i+=2;continue}r||(e[i]===`*`?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0))}return n>=3&&(t+=Math.floor(n/3)),t},os=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`*`&&r+1<e.length&&e[r+1]===`*`&&(t+=1,r+=1)}return t},ss=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`_`&&r+1<e.length&&e[r+1]===`_`&&(t+=1,r+=1)}return t},cs=(e,t,n)=>{if(!t||zo.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
25
- `),i=r===-1?0:r+1,a=e.substring(i,n);return Bo.test(a)&&t.includes(`
26
- `)?!0:es(e,n,`*`)},ls=e=>{let t=e.match(Mo);if(!t)return e;let n=t[2],r=e.lastIndexOf(t[1]);return Eo(e,r)||ko(e,r)||cs(e,n,r)?e:os(e)%2==1?n.endsWith(`*`)?`${e}*`:`${e}**`:e},us=(e,t,n)=>{if(!t||zo.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
27
- `),i=r===-1?0:r+1,a=e.substring(i,n);return Bo.test(a)&&t.includes(`
28
- `)?!0:es(e,n,`_`)},ds=e=>{let t=e.match(No);if(!t){let t=e.match(Wo);if(t){let n=e.lastIndexOf(t[1]);if(!(Eo(e,n)||ko(e,n))&&ss(e)%2==1)return`${e}_`}return e}let n=t[2],r=e.lastIndexOf(t[1]);return Eo(e,r)||ko(e,r)||us(e,n,r)?e:ss(e)%2==1?`${e}__`:e},fs=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`*`&&e[n-1]!==`*`&&e[n+1]!==`*`&&e[n-1]!==`\\`&&!Xo(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if((!t||t===` `||t===` `||t===`
24
+ `)),ps=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`*`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;fs(e,i,a,o)||(t+=1)}return t},ms=(e,t,n,r)=>!!(n===`\\`||e.includes(`$`)&&ss(e,t)||ls(e,t)||us(e,t)||n===`_`||r===`_`||n&&r&&is(n)&&is(r)),hs=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`_`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;ms(e,i,a,o)||(t+=1)}return t},gs=e=>{let t=0,n=0,r=!1;for(let i=0;i<e.length;i+=1){if(e[i]==="`"&&i+2<e.length&&e[i+1]==="`"&&e[i+2]==="`"){n>=3&&(t+=Math.floor(n/3)),n=0,r=!r,i+=2;continue}r||(e[i]===`*`?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0))}return n>=3&&(t+=Math.floor(n/3)),t},_s=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`*`&&r+1<e.length&&e[r+1]===`*`&&(t+=1,r+=1)}return t},vs=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`_`&&r+1<e.length&&e[r+1]===`_`&&(t+=1,r+=1)}return t},ys=(e,t,n)=>{if(!t||Xo.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
25
+ `),i=r===-1?0:r+1,a=e.substring(i,n);return Zo.test(a)&&t.includes(`
26
+ `)?!0:ds(e,n,`*`)},bs=e=>{let t=e.match(Uo);if(!t)return e;let n=t[2],r=e.lastIndexOf(t[1]);return Lo(e,r)||Bo(e,r)||ys(e,n,r)?e:_s(e)%2==1?n.endsWith(`*`)?`${e}*`:`${e}**`:e},xs=(e,t,n)=>{if(!t||Xo.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
27
+ `),i=r===-1?0:r+1,a=e.substring(i,n);return Zo.test(a)&&t.includes(`
28
+ `)?!0:ds(e,n,`_`)},Ss=e=>{let t=e.match(Wo);if(!t){let t=e.match(ts);if(t){let n=e.lastIndexOf(t[1]);if(!(Lo(e,n)||Bo(e,n))&&vs(e)%2==1)return`${e}_`}return e}let n=t[2],r=e.lastIndexOf(t[1]);return Lo(e,r)||Bo(e,r)||xs(e,n,r)?e:vs(e)%2==1?`${e}__`:e},Cs=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`*`&&e[n-1]!==`*`&&e[n+1]!==`*`&&e[n-1]!==`\\`&&!ss(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if((!t||t===` `||t===` `||t===`
29
29
  `)&&(!r||r===` `||r===` `||r===`
30
- `)||t&&r&&qo(t)&&qo(r))continue;return n}}return-1},ps=e=>{if(!e.match(Fo))return e;let t=fs(e);if(t===-1||Eo(e,t)||ko(e,t))return e;let n=e.substring(t+1);return!n||zo.test(n)?e:ns(e)%2==1?`${e}*`:e},ms=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`_`&&e[n-1]!==`_`&&e[n+1]!==`_`&&e[n-1]!==`\\`&&!Xo(e,n)&&!Qo(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if(t&&r&&qo(t)&&qo(r))continue;return n}}return-1},hs=e=>{let t=e.length;for(;t>0&&e[t-1]===`
31
- `;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},gs=e=>{if(!e.endsWith(`**`))return null;let t=e.slice(0,-2);if(os(t)%2!=1)return null;let n=t.indexOf(`**`),r=ms(t);return n!==-1&&r!==-1&&n<r?`${t}_**`:null},_s=e=>{if(!e.match(Io))return e;let t=ms(e);if(t===-1)return e;let n=e.substring(t+1);if(!n||zo.test(n)||Eo(e,t)||ko(e,t))return e;if(is(e)%2==1){let t=gs(e);return t===null?hs(e):t}return e},vs=e=>{let t=os(e),n=ns(e);return t%2==0&&n%2==0},ys=(e,t,n)=>!t||zo.test(t)||Eo(e,n)||ko(e,n)?!0:es(e,n,`*`),bs=e=>{if(Uo.test(e))return e;let t=e.match(Po);if(!t)return e;let n=t[2];return ys(e,n,e.lastIndexOf(t[1]))?e:as(e)%2==1?vs(e)?e:`${e}***`:e},xs=/<[a-zA-Z/][^>]*$/,Ss=e=>{let t=e.match(xs);return!t||t.index===void 0||Eo(e,t.index)?e:e.substring(0,t.index).trimEnd()},Cs=e=>!e.match(Ho)||e.includes(`
32
- `)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,ws=e=>(e.match(/```/g)||[]).length%2==1,Ts=e=>{let t=Cs(e);if(t!==null)return t;let n=e.match(Lo);if(n&&!ws(e)){let t=n[2];if(!t||zo.test(t))return e;if(Oo(e)%2==1)return`${e}\``}return e},Es=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",Ds=e=>{let t=0,n=!1;for(let r=0;r<e.length-1;r+=1)e[r]==="`"&&!Es(e,r)&&(n=!n),!n&&e[r]===`$`&&e[r+1]===`$`&&(t+=1,r+=1);return t},Os=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]==="`"&&!Es(e,r)){n=!n;continue}!n&&e[r]===`$`&&(r+1<e.length&&e[r+1]===`$`?r+=1:t+=1)}return t},ks=e=>{if(e.endsWith(`$`)&&!e.endsWith(`$$`))return`${e}$`;let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
30
+ `)||t&&r&&is(t)&&is(r))continue;return n}}return-1},ws=e=>{if(!e.match(Ko))return e;let t=Cs(e);if(t===-1||Lo(e,t)||Bo(e,t))return e;let n=e.substring(t+1);return!n||Xo.test(n)?e:ps(e)%2==1?`${e}*`:e},Ts=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`_`&&e[n-1]!==`_`&&e[n+1]!==`_`&&e[n-1]!==`\\`&&!ss(e,n)&&!ls(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if(t&&r&&is(t)&&is(r))continue;return n}}return-1},Es=e=>{let t=e.length;for(;t>0&&e[t-1]===`
31
+ `;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},Ds=e=>{if(!e.endsWith(`**`))return null;let t=e.slice(0,-2);if(_s(t)%2!=1)return null;let n=t.indexOf(`**`),r=Ts(t);return n!==-1&&r!==-1&&n<r?`${t}_**`:null},Os=e=>{if(!e.match(qo))return e;let t=Ts(e);if(t===-1)return e;let n=e.substring(t+1);if(!n||Xo.test(n)||Lo(e,t)||Bo(e,t))return e;if(hs(e)%2==1){let t=Ds(e);return t===null?Es(e):t}return e},ks=e=>{let t=_s(e),n=ps(e);return t%2==0&&n%2==0},As=(e,t,n)=>!t||Xo.test(t)||Lo(e,n)||Bo(e,n)?!0:ds(e,n,`*`),js=e=>{if(es.test(e))return e;let t=e.match(Go);if(!t)return e;let n=t[2];return As(e,n,e.lastIndexOf(t[1]))?e:gs(e)%2==1?ks(e)?e:`${e}***`:e},Ms=/<[a-zA-Z/][^>]*$/,Ns=e=>{let t=e.match(Ms);return!t||t.index===void 0||Lo(e,t.index)?e:e.substring(0,t.index).trimEnd()},Ps=e=>!e.match($o)||e.includes(`
32
+ `)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,Fs=e=>(e.match(/```/g)||[]).length%2==1,Is=e=>{let t=Ps(e);if(t!==null)return t;let n=e.match(Jo);if(n&&!Fs(e)){let t=n[2];if(!t||Xo.test(t))return e;if(zo(e)%2==1)return`${e}\``}return e},Ls=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",Rs=e=>{let t=0,n=!1;for(let r=0;r<e.length-1;r+=1)e[r]==="`"&&!Ls(e,r)&&(n=!n),!n&&e[r]===`$`&&e[r+1]===`$`&&(t+=1,r+=1);return t},zs=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]==="`"&&!Ls(e,r)){n=!n;continue}!n&&e[r]===`$`&&(r+1<e.length&&e[r+1]===`$`?r+=1:t+=1)}return t},Bs=e=>{if(e.endsWith(`$`)&&!e.endsWith(`$$`))return`${e}$`;let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
33
33
  `,t)!==-1&&!e.endsWith(`
34
34
  `)?`${e}
35
- $$`:`${e}$$`},As=e=>Ds(e)%2==0?e:ks(e),js=e=>Os(e)%2==1?`${e}$`:e,Ms=(e,t,n)=>{if(e.substring(t+2).includes(`)`))return null;let r=Jo(e,t);if(r===-1||Eo(e,r))return null;let i=r>0&&e[r-1]===`!`,a=i?r-1:r,o=e.substring(0,a);if(i)return o;let s=e.substring(r+1,t);return n===`text-only`?`${o}${s}`:`${o}[${s}](streamdown:incomplete-link)`},Ns=(e,t)=>{for(let n=0;n<t;n++)if(e[n]===`[`&&!Eo(e,n)){if(n>0&&e[n-1]===`!`)continue;let t=Yo(e,n);if(t===-1)return n;if(t+1<e.length&&e[t+1]===`(`){let r=e.indexOf(`)`,t+2);r!==-1&&(n=r)}}return t},Ps=(e,t,n)=>{let r=t>0&&e[t-1]===`!`,i=r?t-1:t;if(!e.substring(t+1).includes(`]`)){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=Ns(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}if(Yo(e,t)===-1){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=Ns(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}return null},Fs=(e,t=`protocol`)=>{let n=e.lastIndexOf(`](`);if(n!==-1&&!Eo(e,n)){let r=Ms(e,n,t);if(r!==null)return r}for(let n=e.length-1;n>=0;--n)if(e[n]===`[`&&!Eo(e,n)){let r=Ps(e,n,t);if(r!==null)return r}return e},Is=/^-{1,2}$/,Ls=/^[\s]*-{1,2}[\s]+$/,Rs=/^={1,2}$/,zs=/^[\s]*={1,2}[\s]+$/,Bs=e=>{if(!e||typeof e!=`string`)return e;let t=e.lastIndexOf(`
36
- `);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(Is.test(i)&&!n.match(Ls)){let t=r.split(`
37
- `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(Rs.test(i)&&!n.match(zs)){let t=r.split(`
38
- `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},Vs=RegExp(`(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])`,`gu`),Hs=e=>!e||typeof e!=`string`||!e.includes(`~`)?e:e.replace(Vs,(t,n)=>Eo(e,n)?t:`\\~`),Us=e=>{let t=e.match(Ro);if(t){let n=t[2];if(!n||zo.test(n))return e;let r=e.lastIndexOf(t[1]);if(Eo(e,r)||ko(e,r))return e;if(e.match(Ko)?.length%2==1)return`${e}~~`}else{let t=e.match(Go);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(Eo(e,n)||ko(e,n))return e;if(e.match(Ko)?.length%2==1)return`${e}~`}}return e},Ws=e=>e!==!1,Gs=e=>e===!0,Ks={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},qs=[{handler:{name:`singleTilde`,handle:Hs,priority:Ks.SINGLE_TILDE},optionKey:`singleTilde`},{handler:{name:`comparisonOperators`,handle:jo,priority:Ks.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:Ss,priority:Ks.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:Bs,priority:Ks.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:Fs,priority:Ks.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:bs,priority:Ks.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:ls,priority:Ks.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:ds,priority:Ks.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:ps,priority:Ks.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:_s,priority:Ks.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:Ts,priority:Ks.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:Us,priority:Ks.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:As,priority:Ks.KATEX},optionKey:`katex`},{handler:{name:`inlineKatex`,handle:js,priority:Ks.INLINE_KATEX},optionKey:`inlineKatex`}],Js=e=>{let t=e?.linkMode??`protocol`;return qs.filter(({handler:t,optionKey:n})=>t.name===`links`?Ws(e?.links)||Ws(e?.images):t.name===`inlineKatex`?Gs(e?.inlineKatex):Ws(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:To(wo({},e),{handle:e=>Fs(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},Ys=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=Js(t),i=(t?.handlers??[]).map(e=>({handler:To(wo({},e),{priority:e.priority??Ks.DEFAULT}),earlyReturn:void 0})),a=[...r,...i].sort((e,t)=>(e.handler.priority??0)-(t.handler.priority??0));for(let{handler:e,earlyReturn:t}of a)if(n=e.handle(n),t!=null&&t(n))return n;return n};function Xs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Zs=Xs();function Qs(e){Zs=e}var $s={exec:()=>null};function R(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(tc.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ec=(()=>{try{return!0}catch{return!1}})(),tc={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},nc=/^(?:[ \t]*(?:\n|$))+/,rc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ic=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ac=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,oc=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,sc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,cc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,lc=R(cc).replace(/bull/g,sc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),uc=R(cc).replace(/bull/g,sc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),dc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fc=/^[^\n]+/,pc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,mc=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,pc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hc=R(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,sc).getRegex(),gc=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,_c=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vc=R(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,_c).replace(`tag`,gc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yc=R(dc).replace(`hr`,ac).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gc).getRegex(),bc={blockquote:R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,yc).getRegex(),code:rc,def:mc,fences:ic,heading:oc,hr:ac,html:vc,lheading:lc,list:hc,newline:nc,paragraph:yc,table:$s,text:fc},xc=R(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,ac).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gc).getRegex(),Sc={...bc,lheading:uc,table:xc,paragraph:R(dc).replace(`hr`,ac).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,xc).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gc).getRegex()},Cc={...bc,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,_c).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:$s,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(dc).replace(`hr`,ac).replace(`heading`,` *#{1,6} *[^
39
- ]`).replace(`lheading`,lc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},wc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tc=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ec=/^( {2,}|\\)\n(?!\s*$)/,Dc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Oc=/[\p{P}\p{S}]/u,kc=/[\s\p{P}\p{S}]/u,Ac=/[^\s\p{P}\p{S}]/u,jc=R(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,kc).getRegex(),Mc=/(?!~)[\p{P}\p{S}]/u,Nc=/(?!~)[\s\p{P}\p{S}]/u,Pc=/(?:[^\s\p{P}\p{S}]|~)/u,Fc=R(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ec?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Ic=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Lc=R(Ic,`u`).replace(/punct/g,Oc).getRegex(),Rc=R(Ic,`u`).replace(/punct/g,Mc).getRegex(),zc=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Bc=R(zc,`gu`).replace(/notPunctSpace/g,Ac).replace(/punctSpace/g,kc).replace(/punct/g,Oc).getRegex(),Vc=R(zc,`gu`).replace(/notPunctSpace/g,Pc).replace(/punctSpace/g,Nc).replace(/punct/g,Mc).getRegex(),Hc=R(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Ac).replace(/punctSpace/g,kc).replace(/punct/g,Oc).getRegex(),Uc=R(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Oc).getRegex(),Wc=R(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Ac).replace(/punctSpace/g,kc).replace(/punct/g,Oc).getRegex(),Gc=R(/\\(punct)/,`gu`).replace(/punct/g,Oc).getRegex(),Kc=R(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),qc=R(_c).replace(`(?:-->|$)`,`-->`).getRegex(),Jc=R(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,qc).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Yc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Xc=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Yc).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Zc=R(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Yc).replace(`ref`,pc).getRegex(),Qc=R(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,pc).getRegex(),$c=R(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Zc).replace(`nolink`,Qc).getRegex(),el=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,tl={_backpedal:$s,anyPunctuation:Gc,autolink:Kc,blockSkip:Fc,br:Ec,code:Tc,del:$s,delLDelim:$s,delRDelim:$s,emStrongLDelim:Lc,emStrongRDelimAst:Bc,emStrongRDelimUnd:Hc,escape:wc,link:Xc,nolink:Qc,punctuation:jc,reflink:Zc,reflinkSearch:$c,tag:Jc,text:Dc,url:$s},nl={...tl,link:R(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Yc).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Yc).getRegex()},rl={...tl,emStrongRDelimAst:Vc,emStrongLDelim:Rc,delLDelim:Uc,delRDelim:Wc,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,el).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,el).getRegex()},il={...rl,br:R(Ec).replace(`{2,}`,`*`).getRegex(),text:R(rl.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},al={normal:bc,gfm:Sc,pedantic:Cc},ol={normal:tl,gfm:rl,breaks:il,pedantic:nl},sl={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},cl=e=>sl[e];function ll(e,t){if(t){if(tc.escapeTest.test(e))return e.replace(tc.escapeReplace,cl)}else if(tc.escapeTestNoEncode.test(e))return e.replace(tc.escapeReplaceNoEncode,cl);return e}function ul(e){try{e=encodeURI(e).replace(tc.percentDecode,`%`)}catch{return null}return e}function dl(e,t){let n=e.replace(tc.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(tc.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(tc.slashPipe,`|`);return n}function fl(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function pl(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function ml(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function hl(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function gl(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
35
+ $$`:`${e}$$`},Vs=e=>Rs(e)%2==0?e:Bs(e),Hs=e=>zs(e)%2==1?`${e}$`:e,Us=(e,t,n)=>{if(e.substring(t+2).includes(`)`))return null;let r=as(e,t);if(r===-1||Lo(e,r))return null;let i=r>0&&e[r-1]===`!`,a=i?r-1:r,o=e.substring(0,a);if(i)return o;let s=e.substring(r+1,t);return n===`text-only`?`${o}${s}`:`${o}[${s}](streamdown:incomplete-link)`},Ws=(e,t)=>{for(let n=0;n<t;n++)if(e[n]===`[`&&!Lo(e,n)){if(n>0&&e[n-1]===`!`)continue;let t=os(e,n);if(t===-1)return n;if(t+1<e.length&&e[t+1]===`(`){let r=e.indexOf(`)`,t+2);r!==-1&&(n=r)}}return t},Gs=(e,t,n)=>{let r=t>0&&e[t-1]===`!`,i=r?t-1:t;if(!e.substring(t+1).includes(`]`)){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=Ws(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}if(os(e,t)===-1){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=Ws(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}return null},Ks=(e,t=`protocol`)=>{let n=e.lastIndexOf(`](`);if(n!==-1&&!Lo(e,n)){let r=Us(e,n,t);if(r!==null)return r}for(let n=e.length-1;n>=0;--n)if(e[n]===`[`&&!Lo(e,n)){let r=Gs(e,n,t);if(r!==null)return r}return e},qs=/^-{1,2}$/,Js=/^[\s]*-{1,2}[\s]+$/,Ys=/^={1,2}$/,Xs=/^[\s]*={1,2}[\s]+$/,Zs=e=>{if(!e||typeof e!=`string`)return e;let t=e.lastIndexOf(`
36
+ `);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(qs.test(i)&&!n.match(Js)){let t=r.split(`
37
+ `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(Ys.test(i)&&!n.match(Xs)){let t=r.split(`
38
+ `).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},Qs=RegExp(`(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])`,`gu`),$s=e=>!e||typeof e!=`string`||!e.includes(`~`)?e:e.replace(Qs,(t,n)=>Lo(e,n)?t:`\\~`),ec=e=>{let t=e.match(Yo);if(t){let n=t[2];if(!n||Xo.test(n))return e;let r=e.lastIndexOf(t[1]);if(Lo(e,r)||Bo(e,r))return e;if(e.match(rs)?.length%2==1)return`${e}~~`}else{let t=e.match(ns);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(Lo(e,n)||Bo(e,n))return e;if(e.match(rs)?.length%2==1)return`${e}~`}}return e},tc=e=>e!==!1,nc=e=>e===!0,rc={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},ic=[{handler:{name:`singleTilde`,handle:$s,priority:rc.SINGLE_TILDE},optionKey:`singleTilde`},{handler:{name:`comparisonOperators`,handle:Ho,priority:rc.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:Ns,priority:rc.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:Zs,priority:rc.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:Ks,priority:rc.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:js,priority:rc.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:bs,priority:rc.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:Ss,priority:rc.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:ws,priority:rc.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:Os,priority:rc.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:Is,priority:rc.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:ec,priority:rc.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:Vs,priority:rc.KATEX},optionKey:`katex`},{handler:{name:`inlineKatex`,handle:Hs,priority:rc.INLINE_KATEX},optionKey:`inlineKatex`}],ac=e=>{let t=e?.linkMode??`protocol`;return ic.filter(({handler:t,optionKey:n})=>t.name===`links`?tc(e?.links)||tc(e?.images):t.name===`inlineKatex`?nc(e?.inlineKatex):tc(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:Io(Fo({},e),{handle:e=>Ks(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},oc=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=ac(t),i=(t?.handlers??[]).map(e=>({handler:Io(Fo({},e),{priority:e.priority??rc.DEFAULT}),earlyReturn:void 0})),a=[...r,...i].sort((e,t)=>(e.handler.priority??0)-(t.handler.priority??0));for(let{handler:e,earlyReturn:t}of a)if(n=e.handle(n),t!=null&&t(n))return n;return n};function sc(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var cc=sc();function lc(e){cc=e}var uc={exec:()=>null};function R(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(fc.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var dc=(()=>{try{return!0}catch{return!1}})(),fc={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},pc=/^(?:[ \t]*(?:\n|$))+/,mc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,gc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_c=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vc=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,yc=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bc=R(yc).replace(/bull/g,vc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),xc=R(yc).replace(/bull/g,vc).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Sc=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Cc=/^[^\n]+/,wc=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Tc=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,wc).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ec=R(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vc).getRegex(),Dc=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Oc=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,kc=R(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Oc).replace(`tag`,Dc).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ac=R(Sc).replace(`hr`,gc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Dc).getRegex(),jc={blockquote:R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ac).getRegex(),code:mc,def:Tc,fences:hc,heading:_c,hr:gc,html:kc,lheading:bc,list:Ec,newline:pc,paragraph:Ac,table:uc,text:Cc},Mc=R(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,gc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Dc).getRegex(),Nc={...jc,lheading:xc,table:Mc,paragraph:R(Sc).replace(`hr`,gc).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Mc).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Dc).getRegex()},Pc={...jc,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Oc).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:uc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(Sc).replace(`hr`,gc).replace(`heading`,` *#{1,6} *[^
39
+ ]`).replace(`lheading`,bc).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Fc=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ic=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Lc=/^( {2,}|\\)\n(?!\s*$)/,Rc=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,zc=/[\p{P}\p{S}]/u,Bc=/[\s\p{P}\p{S}]/u,Vc=/[^\s\p{P}\p{S}]/u,Hc=R(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Bc).getRegex(),Uc=/(?!~)[\p{P}\p{S}]/u,Wc=/(?!~)[\s\p{P}\p{S}]/u,Gc=/(?:[^\s\p{P}\p{S}]|~)/u,Kc=R(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,dc?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),qc=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Jc=R(qc,`u`).replace(/punct/g,zc).getRegex(),Yc=R(qc,`u`).replace(/punct/g,Uc).getRegex(),Xc=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Zc=R(Xc,`gu`).replace(/notPunctSpace/g,Vc).replace(/punctSpace/g,Bc).replace(/punct/g,zc).getRegex(),Qc=R(Xc,`gu`).replace(/notPunctSpace/g,Gc).replace(/punctSpace/g,Wc).replace(/punct/g,Uc).getRegex(),$c=R(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Vc).replace(/punctSpace/g,Bc).replace(/punct/g,zc).getRegex(),el=R(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,zc).getRegex(),tl=R(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Vc).replace(/punctSpace/g,Bc).replace(/punct/g,zc).getRegex(),nl=R(/\\(punct)/,`gu`).replace(/punct/g,zc).getRegex(),rl=R(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),il=R(Oc).replace(`(?:-->|$)`,`-->`).getRegex(),al=R(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,il).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ol=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,sl=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,ol).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),cl=R(/^!?\[(label)\]\[(ref)\]/).replace(`label`,ol).replace(`ref`,wc).getRegex(),ll=R(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,wc).getRegex(),ul=R(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,cl).replace(`nolink`,ll).getRegex(),dl=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,fl={_backpedal:uc,anyPunctuation:nl,autolink:rl,blockSkip:Kc,br:Lc,code:Ic,del:uc,delLDelim:uc,delRDelim:uc,emStrongLDelim:Jc,emStrongRDelimAst:Zc,emStrongRDelimUnd:$c,escape:Fc,link:sl,nolink:ll,punctuation:Hc,reflink:cl,reflinkSearch:ul,tag:al,text:Rc,url:uc},pl={...fl,link:R(/^!?\[(label)\]\((.*?)\)/).replace(`label`,ol).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,ol).getRegex()},ml={...fl,emStrongRDelimAst:Qc,emStrongLDelim:Yc,delLDelim:el,delRDelim:tl,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,dl).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,dl).getRegex()},hl={...ml,br:R(Lc).replace(`{2,}`,`*`).getRegex(),text:R(ml.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},gl={normal:jc,gfm:Nc,pedantic:Pc},_l={normal:fl,gfm:ml,breaks:hl,pedantic:pl},vl={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},yl=e=>vl[e];function bl(e,t){if(t){if(fc.escapeTest.test(e))return e.replace(fc.escapeReplace,yl)}else if(fc.escapeTestNoEncode.test(e))return e.replace(fc.escapeReplaceNoEncode,yl);return e}function xl(e){try{e=encodeURI(e).replace(fc.percentDecode,`%`)}catch{return null}return e}function Sl(e,t){let n=e.replace(fc.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(fc.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(fc.slashPipe,`|`);return n}function Cl(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function wl(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Tl(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function El(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Dl(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
40
40
  `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
41
- `)}var _l=class{options;rules;lexer;constructor(e){this.options=e||Zs}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:fl(e,`
42
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=gl(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=fl(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:fl(t[0],`
43
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=fl(t[0],`
41
+ `)}var Ol=class{options;rules;lexer;constructor(e){this.options=e||cc}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:Cl(e,`
42
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Dl(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Cl(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Cl(t[0],`
43
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Cl(t[0],`
44
44
  `).split(`
45
45
  `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
46
46
  `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
@@ -51,17 +51,17 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
51
51
  `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
52
52
  `+e.join(`
53
53
  `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
54
- `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=ml(t[2].split(`
54
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Tl(t[2].split(`
55
55
  `,1)[0],t[1].length),l=e.split(`
56
56
  `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
57
57
  `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
58
58
  `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
59
59
  `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
60
60
  `+l}u=!l.trim(),r+=p+`
61
- `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=dl(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
62
- `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(dl(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
63
- `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=fl(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=pl(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),hl(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return hl(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},vl=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Zs,this.options.tokenizer=this.options.tokenizer||new _l,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:tc,block:al.normal,inline:ol.normal};this.options.pedantic?(t.block=al.pedantic,t.inline=ol.pedantic):this.options.gfm&&(t.block=al.gfm,this.options.breaks?t.inline=ol.breaks:t.inline=ol.gfm),this.tokenizer.rules=t}static get rules(){return{block:al,inline:ol}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(tc.carriageReturn,`
64
- `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(tc.tabCharGlobal,` `).replace(tc.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
61
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Sl(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
62
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Sl(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
63
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Cl(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=wl(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),El(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return El(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},kl=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||cc,this.options.tokenizer=this.options.tokenizer||new Ol,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:fc,block:gl.normal,inline:_l.normal};this.options.pedantic?(t.block=gl.pedantic,t.inline=_l.pedantic):this.options.gfm&&(t.block=gl.gfm,this.options.breaks?t.inline=_l.breaks:t.inline=_l.gfm),this.tokenizer.rules=t}static get rules(){return{block:gl,inline:_l}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(fc.carriageReturn,`
64
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(fc.tabCharGlobal,` `).replace(fc.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
65
65
  `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
66
66
  `)?``:`
67
67
  `)+r.raw,n.text+=`
@@ -74,9 +74,9 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
74
74
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
75
75
  `)?``:`
76
76
  `)+r.raw,n.text+=`
77
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},yl=class{options;parser;constructor(e){this.options=e||Zs}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(tc.notSpaceStart)?.[0],i=e.replace(tc.endingNewline,``)+`
78
- `;return r?`<pre><code class="language-`+ll(r)+`">`+(n?i:ll(i,!0))+`</code></pre>
79
- `:`<pre><code>`+(n?i:ll(i,!0))+`</code></pre>
77
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},Al=class{options;parser;constructor(e){this.options=e||cc}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(fc.notSpaceStart)?.[0],i=e.replace(fc.endingNewline,``)+`
78
+ `;return r?`<pre><code class="language-`+bl(r)+`">`+(n?i:bl(i,!0))+`</code></pre>
79
+ `:`<pre><code>`+(n?i:bl(i,!0))+`</code></pre>
80
80
  `}blockquote({tokens:e}){return`<blockquote>
81
81
  ${this.parser.parse(e)}</blockquote>
82
82
  `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -92,19 +92,19 @@ ${this.parser.parse(e)}</blockquote>
92
92
  `}tablerow({text:e}){return`<tr>
93
93
  ${e}</tr>
94
94
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
95
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ll(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ul(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+ll(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ul(e);if(i===null)return ll(n);e=i;let a=`<img src="${e}" alt="${ll(n)}"`;return t&&(a+=` title="${ll(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:ll(e.text)}},bl=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},xl=class e{options;renderer;textRenderer;constructor(e){this.options=e||Zs,this.options.renderer=this.options.renderer||new yl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bl}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Sl=class{options;block;constructor(e){this.options=e||Zs}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?vl.lex:vl.lexInline}provideParser(e=this.block){return e?xl.parse:xl.parseInline}},Cl=new class{defaults=Xs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=xl;Renderer=yl;TextRenderer=bl;Lexer=vl;Tokenizer=_l;Hooks=Sl;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new yl(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new _l(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Sl;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Sl.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Sl.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return vl.lex(e,t??this.defaults)}parser(e,t){return xl.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?vl.lex:vl.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?xl.parse:xl.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?vl.lex:vl.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?xl.parse:xl.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
96
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+ll(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function z(e,t){return Cl.parse(e,t)}z.options=z.setOptions=function(e){return Cl.setOptions(e),z.defaults=Cl.defaults,Qs(z.defaults),z},z.getDefaults=Xs,z.defaults=Zs,z.use=function(...e){return Cl.use(...e),z.defaults=Cl.defaults,Qs(z.defaults),z},z.walkTokens=function(e,t){return Cl.walkTokens(e,t)},z.parseInline=Cl.parseInline,z.Parser=xl,z.parser=xl.parse,z.Renderer=yl,z.TextRenderer=bl,z.Lexer=vl,z.lexer=vl.lex,z.Tokenizer=_l,z.Hooks=Sl,z.parse=z,z.options,z.setOptions,z.use,z.walkTokens,z.parseInline,xl.parse,vl.lex;var wl=n(o(),1),Tl=300,El=`300px`,Dl=500;function Ol(e={}){let{immediate:t=!1,debounceDelay:n=Tl,rootMargin:r=El,idleTimeout:i=Dl}=e,[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,F.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,F.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,F.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var kl=/\s/,Al=/^\s+$/,jl=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),Ml=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,Nl=e=>e.some(e=>Ml(e)&&jl.has(e.tagName)),Pl=e=>{let t=[],n=``,r=!1;for(let i of e){let e=kl.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},Fl=e=>{let t=[],n=``;for(let r of e)kl.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},Il=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},Ll=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(Nl(t))return qt;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?Fl(c):Pl(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,Al.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return Il(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},Rl=0;function zl(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=Rl++,i=()=>e=>{let r={count:0,newIndex:0};Ft(e,`text`,(e,i)=>Ll(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,"name",{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}zl();var Bl=(0,F.createContext)(!1),Vl=()=>(0,F.useContext)(Bl),Hl=(...e)=>At(Mt(e)),Ul=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},Wl=e=>e?(...t)=>Ul(e,At(Mt(t))):Hl,Gl=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},Kl=(0,F.createContext)(Hl),B=()=>(0,F.useContext)(Kl),ql=Hl(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),Jl=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},Yl=(0,F.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=B(),c=(0,F.useMemo)(()=>s(ql),[s]),l=(0,F.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,Jl(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,L.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,L.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,L.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,L.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
97
- `:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,L.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),Xl=({className:e,language:t,style:n,isIncomplete:r,...i})=>(0,L.jsx)(`div`,{className:B()(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i}),Zl=(0,F.createContext)({code:``}),Ql=()=>(0,F.useContext)(Zl),$l=({language:e})=>{let t=B();return(0,L.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,L.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},eu=e=>{let t=e.length;for(;t>0&&e[t-1]===`
98
- `;)t--;return e.slice(0,t)},tu=(0,F.lazy)(()=>s(()=>import(`./highlighted-body-OFNGDK62-CKMBhexn.js`).then(e=>({default:e.HighlightedCodeBlockBody})),[],import.meta.url)),nu=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=B(),l=(0,F.useMemo)(()=>eu(e),[e]),u=(0,F.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
99
- `).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,L.jsx)(Zl.Provider,{value:{code:e},children:(0,L.jsxs)(Xl,{isIncomplete:i,language:t,children:[(0,L.jsx)($l,{language:t}),r?(0,L.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(Yl,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,L.jsx)(tu,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},ru={CheckIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,L.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,L.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},iu=(0,F.createContext)(ru),au=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>e[n]===t[n]):!1},ou=({icons:e,children:t})=>{let n=(0,F.useRef)(e),r=(0,F.useRef)(e?{...ru,...e}:ru);au(n.current,e)||(n.current=e,r.current=e?{...ru,...e}:ru);let i=r.current;return(0,L.jsx)(iu.Provider,{value:i,children:t})},su=()=>(0,F.useContext)(iu),cu={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},lu=(0,F.createContext)(cu),uu=()=>(0,F.useContext)(lu),du=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=B(),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(0),{code:d}=Ql(),{isAnimating:f}=(0,F.useContext)(_f),p=uu(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,F.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=su(),_=c?g.CheckIcon:g.CopyIcon;return(0,L.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,L.jsx)(_,{size:14})})},fu={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},pu=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=B(),{code:c}=Ql(),{isAnimating:l}=(0,F.useContext)(_f),u=uu(),d=su(),f=a??c,p=`file.${n&&n in fu?fu[n]:`txt`}`;return(0,L.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{Gl(p,f,`text/plain`),e?.()}catch(e){t?.(e)}},title:u.downloadFile,type:`button`,...o,children:r??(0,L.jsx)(d.DownloadIcon,{size:14})})},mu=()=>{let{Loader2Icon:e}=su(),t=B();return(0,L.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,L.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,L.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,L.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},hu=/\.[^/.]+$/,gu=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=su(),c=B(),l=(0,F.useRef)(null),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=uu(),h=o.width!=null||o.height!=null,g=(u||h)&&!f,_=f&&!h;(0,F.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;d(t),p(!t)}},[]);let v=(0,F.useCallback)(e=>{d(!0),p(!1),i?.(e)},[i]),y=(0,F.useCallback)(e=>{d(!1),p(!0),a?.(e)},[a]),b=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(hu,``)}.${i}`}Gl(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,L.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,L.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,_&&`hidden`,t),"data-streamdown":`image`,onError:y,onLoad:v,ref:l,src:n,...o}),_&&(0,L.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:m.imageNotAvailable}),(0,L.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),g&&(0,L.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:b,title:m.downloadImage,type:`button`,children:(0,L.jsx)(s,{size:14})})]}):null},_u=0,vu=()=>{_u+=1,_u===1&&(document.body.style.overflow=`hidden`)},yu=()=>{_u=Math.max(0,_u-1),_u===0&&(document.body.style.overflow=``)},bu=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=su(),c=B(),[l,u]=(0,F.useState)(!1),d=uu(),f=(0,F.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,F.useCallback)(()=>{r(),n()},[r,n]);return(0,F.useEffect)(()=>{if(t){vu();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),yu()}}},[t,n]),t?(0,L.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,L.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,L.jsx)(s,{size:16})}),(0,L.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,L.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,L.jsx)(o,{size:20}),(0,L.jsx)(`span`,{children:d.openExternalLink})]}),(0,L.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,L.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,L.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,L.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(i,{size:14}),(0,L.jsx)(`span`,{children:d.copied})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(a,{size:14}),(0,L.jsx)(`span`,{children:d.copyLink})]})}),(0,L.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,L.jsx)(o,{size:14}),(0,L.jsx)(`span`,{children:d.openLink})]})]})]})}):null},xu=(0,F.createContext)(null),Su=()=>(0,F.useContext)(xu),Cu=()=>Su()?.code??null,wu=()=>Su()?.mermaid??null,Tu=e=>{var t;let n=Su();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},Eu=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),Du=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=B(),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(null),{isAnimating:u}=(0,F.useContext)(_f),d=su(),f=wu(),p=uu(),m=async t=>{try{if(t===`mmd`){Gl(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!f){a?.(Error(`Mermaid plugin not available`));return}let n=f.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){Gl(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){Gl(`diagram.png`,await Eu(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,F.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:p.downloadDiagram,type:`button`,children:t??(0,L.jsx)(d.DownloadIcon,{size:14})}),s?(0,L.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`svg`),title:p.downloadDiagramAsSvg,type:`button`,children:p.mermaidFormatSvg}),(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`png`),title:p.downloadDiagramAsPng,type:`button`,children:p.mermaidFormatPng}),(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`mmd`),title:p.downloadDiagramAsMmd,type:`button`,children:p.mermaidFormatMmd})]}):null]})},Ou=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=su(),c=B(),[l,u]=(0,F.useState)(!1),{isAnimating:d,controls:f}=(0,F.useContext)(_f),p=uu(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0?!0:e.panZoom!==!1})(),h=()=>{u(!l)};return(0,F.useEffect)(()=>{if(l){vu();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),yu()}}},[l]),(0,F.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:h,title:p.viewFullscreen,type:`button`,...a,children:(0,L.jsx)(o,{size:14})}),l?(0,wl.createPortal)((0,L.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:h,onKeyDown:e=>{e.key===`Escape`&&h()},role:`button`,tabIndex:0,children:[(0,L.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:h,title:p.exitFullscreen,type:`button`,children:(0,L.jsx)(s,{size:20})}),(0,L.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,L.jsx)(xf,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},ku=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},Au=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
95
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${bl(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=xl(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+bl(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=xl(e);if(i===null)return bl(n);e=i;let a=`<img src="${e}" alt="${bl(n)}"`;return t&&(a+=` title="${bl(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:bl(e.text)}},jl=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Ml=class e{options;renderer;textRenderer;constructor(e){this.options=e||cc,this.options.renderer=this.options.renderer||new Al,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new jl}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Nl=class{options;block;constructor(e){this.options=e||cc}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?kl.lex:kl.lexInline}provideParser(e=this.block){return e?Ml.parse:Ml.parseInline}},Pl=new class{defaults=sc();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ml;Renderer=Al;TextRenderer=jl;Lexer=kl;Tokenizer=Ol;Hooks=Nl;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Al(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Ol(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Nl;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Nl.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Nl.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return kl.lex(e,t??this.defaults)}parser(e,t){return Ml.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?kl.lex:kl.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Ml.parse:Ml.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?kl.lex:kl.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Ml.parse:Ml.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
96
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+bl(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function z(e,t){return Pl.parse(e,t)}z.options=z.setOptions=function(e){return Pl.setOptions(e),z.defaults=Pl.defaults,lc(z.defaults),z},z.getDefaults=sc,z.defaults=cc,z.use=function(...e){return Pl.use(...e),z.defaults=Pl.defaults,lc(z.defaults),z},z.walkTokens=function(e,t){return Pl.walkTokens(e,t)},z.parseInline=Pl.parseInline,z.Parser=Ml,z.parser=Ml.parse,z.Renderer=Al,z.TextRenderer=jl,z.Lexer=kl,z.lexer=kl.lex,z.Tokenizer=Ol,z.Hooks=Nl,z.parse=z,z.options,z.setOptions,z.use,z.walkTokens,z.parseInline,Ml.parse,kl.lex;var Fl=n(o(),1),Il=300,Ll=`300px`,Rl=500;function zl(e={}){let{immediate:t=!1,debounceDelay:n=Il,rootMargin:r=Ll,idleTimeout:i=Rl}=e,[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,F.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,F.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,F.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var Bl=/\s/,Vl=/^\s+$/,Hl=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),Ul=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,Wl=e=>e.some(e=>Ul(e)&&Hl.has(e.tagName)),Gl=e=>{let t=[],n=``,r=!1;for(let i of e){let e=Bl.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},Kl=e=>{let t=[],n=``;for(let r of e)Bl.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},ql=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},Jl=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(Wl(t))return Xt;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?Kl(c):Gl(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,Vl.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return ql(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},Yl=0;function Xl(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=Yl++,i=()=>e=>{let r={count:0,newIndex:0};Rt(e,`text`,(e,i)=>Jl(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,"name",{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}Xl();var Zl=(0,F.createContext)(!1),Ql=()=>(0,F.useContext)(Zl),$l=(...e)=>Nt(Ft(e)),eu=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},tu=e=>e?(...t)=>eu(e,Nt(Ft(t))):$l,nu=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},ru=(0,F.createContext)($l),B=()=>(0,F.useContext)(ru),iu=$l(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),au=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},ou=(0,F.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=B(),c=(0,F.useMemo)(()=>s(iu),[s]),l=(0,F.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,au(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,L.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,L.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,L.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,L.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
97
+ `:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,L.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),su=({className:e,language:t,style:n,isIncomplete:r,...i})=>(0,L.jsx)(`div`,{className:B()(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i}),cu=(0,F.createContext)({code:``}),lu=()=>(0,F.useContext)(cu),uu=({language:e})=>{let t=B();return(0,L.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,L.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},du=e=>{let t=e.length;for(;t>0&&e[t-1]===`
98
+ `;)t--;return e.slice(0,t)},fu=(0,F.lazy)(()=>s(()=>import(`./highlighted-body-OFNGDK62-13WB1hjG.js`).then(e=>({default:e.HighlightedCodeBlockBody})),[],import.meta.url)),pu=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=B(),l=(0,F.useMemo)(()=>du(e),[e]),u=(0,F.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
99
+ `).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,L.jsx)(cu.Provider,{value:{code:e},children:(0,L.jsxs)(su,{isIncomplete:i,language:t,children:[(0,L.jsx)(uu,{language:t}),r?(0,L.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(ou,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,L.jsx)(fu,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},mu={CheckIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,L.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,L.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},hu=(0,F.createContext)(mu),gu=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>e[n]===t[n]):!1},_u=({icons:e,children:t})=>{let n=(0,F.useRef)(e),r=(0,F.useRef)(e?{...mu,...e}:mu);gu(n.current,e)||(n.current=e,r.current=e?{...mu,...e}:mu);let i=r.current;return(0,L.jsx)(hu.Provider,{value:i,children:t})},vu=()=>(0,F.useContext)(hu),yu={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},bu=(0,F.createContext)(yu),xu=()=>(0,F.useContext)(bu),Su=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=B(),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(0),{code:d}=lu(),{isAnimating:f}=(0,F.useContext)(Of),p=xu(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,F.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=vu(),_=c?g.CheckIcon:g.CopyIcon;return(0,L.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,L.jsx)(_,{size:14})})},Cu={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},wu=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=B(),{code:c}=lu(),{isAnimating:l}=(0,F.useContext)(Of),u=xu(),d=vu(),f=a??c,p=`file.${n&&n in Cu?Cu[n]:`txt`}`;return(0,L.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{nu(p,f,`text/plain`),e?.()}catch(e){t?.(e)}},title:u.downloadFile,type:`button`,...o,children:r??(0,L.jsx)(d.DownloadIcon,{size:14})})},Tu=()=>{let{Loader2Icon:e}=vu(),t=B();return(0,L.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,L.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,L.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,L.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},Eu=/\.[^/.]+$/,Du=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=vu(),c=B(),l=(0,F.useRef)(null),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),m=xu(),h=o.width!=null||o.height!=null,g=(u||h)&&!f,_=f&&!h;(0,F.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;d(t),p(!t)}},[]);let v=(0,F.useCallback)(e=>{d(!0),p(!1),i?.(e)},[i]),y=(0,F.useCallback)(e=>{d(!1),p(!0),a?.(e)},[a]),b=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(Eu,``)}.${i}`}nu(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,L.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,L.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,_&&`hidden`,t),"data-streamdown":`image`,onError:y,onLoad:v,ref:l,src:n,...o}),_&&(0,L.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:m.imageNotAvailable}),(0,L.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),g&&(0,L.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:b,title:m.downloadImage,type:`button`,children:(0,L.jsx)(s,{size:14})})]}):null},Ou=0,ku=()=>{Ou+=1,Ou===1&&(document.body.style.overflow=`hidden`)},Au=()=>{Ou=Math.max(0,Ou-1),Ou===0&&(document.body.style.overflow=``)},ju=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=vu(),c=B(),[l,u]=(0,F.useState)(!1),d=xu(),f=(0,F.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,F.useCallback)(()=>{r(),n()},[r,n]);return(0,F.useEffect)(()=>{if(t){ku();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Au()}}},[t,n]),t?(0,L.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,L.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,L.jsx)(s,{size:16})}),(0,L.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,L.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,L.jsx)(o,{size:20}),(0,L.jsx)(`span`,{children:d.openExternalLink})]}),(0,L.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,L.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,L.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,L.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(i,{size:14}),(0,L.jsx)(`span`,{children:d.copied})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(a,{size:14}),(0,L.jsx)(`span`,{children:d.copyLink})]})}),(0,L.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,L.jsx)(o,{size:14}),(0,L.jsx)(`span`,{children:d.openLink})]})]})]})}):null},Mu=(0,F.createContext)(null),Nu=()=>(0,F.useContext)(Mu),Pu=()=>Nu()?.code??null,Fu=()=>Nu()?.mermaid??null,Iu=e=>{var t;let n=Nu();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},Lu=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),Ru=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=B(),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(null),{isAnimating:u}=(0,F.useContext)(Of),d=vu(),f=Fu(),p=xu(),m=async t=>{try{if(t===`mmd`){nu(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!f){a?.(Error(`Mermaid plugin not available`));return}let n=f.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){nu(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){nu(`diagram.png`,await Lu(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,F.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:p.downloadDiagram,type:`button`,children:t??(0,L.jsx)(d.DownloadIcon,{size:14})}),s?(0,L.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`svg`),title:p.downloadDiagramAsSvg,type:`button`,children:p.mermaidFormatSvg}),(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`png`),title:p.downloadDiagramAsPng,type:`button`,children:p.mermaidFormatPng}),(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`mmd`),title:p.downloadDiagramAsMmd,type:`button`,children:p.mermaidFormatMmd})]}):null]})},zu=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=vu(),c=B(),[l,u]=(0,F.useState)(!1),{isAnimating:d,controls:f}=(0,F.useContext)(Of),p=xu(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0?!0:e.panZoom!==!1})(),h=()=>{u(!l)};return(0,F.useEffect)(()=>{if(l){ku();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Au()}}},[l]),(0,F.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:h,title:p.viewFullscreen,type:`button`,...a,children:(0,L.jsx)(o,{size:14})}),l?(0,Fl.createPortal)((0,L.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:h,onKeyDown:e=>{e.key===`Escape`&&h()},role:`button`,tabIndex:0,children:[(0,L.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:h,title:p.exitFullscreen,type:`button`,children:(0,L.jsx)(s,{size:20})}),(0,L.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,L.jsx)(Mf,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},Bu=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},Vu=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
100
100
  `)&&(t=!0)}return t?n?`"${e.replace(/"/g,`""`)}"`:`"${e}"`:e},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(`,`),o+=1);for(let e of n)a[o]=e.map(r).join(`,`),o+=1;return a.join(`
101
- `)},ju=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
101
+ `)},Hu=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
102
102
  `||n===`\r`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===` `?n.push(`\\t`):t===`
103
103
  `?n.push(`\\n`):t===`\r`?n.push(`\\r`):n.push(t);return n.join(``)},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(` `),o+=1);for(let e of n)a[o]=e.map(r).join(` `),o+=1;return a.join(`
104
- `)},Mu=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},Nu=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0;r[i]=`| ${t.map(e=>Mu(e)).join(` | `)} |`,i+=1;let a=Array(t.length);for(let e=0;e<t.length;e+=1)a[e]=`---`;r[i]=`| ${a.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?Mu(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>Mu(e)).join(` | `)} |`,i+=1;return r.join(`
105
- `)},Pu=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=B(),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(null),d=(0,F.useRef)(0),{isAnimating:f}=(0,F.useContext)(_f),p=uu(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=ku(t),o=({csv:Au,tsv:ju,md:Nu}[e]||Nu)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,F.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=su(),g=c?h.CheckIcon:h.CopyIcon;return(0,L.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,L.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,L.jsx)(g,{height:14,width:14})}),o?(0,L.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},Fu=({children:e,className:t,onDownload:n,onError:r})=>{let i=B(),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),{isAnimating:c}=(0,F.useContext)(_f),l=uu(),u=su(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=ku(t),a=e===`csv`?Au(i):Nu(i);Gl(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,F.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,L.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,L.jsx)(u.DownloadIcon,{size:14})}),a?(0,L.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},Iu=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=su(),o=B(),[s,c]=(0,F.useState)(!1),{isAnimating:l}=(0,F.useContext)(_f),u=uu(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,F.useEffect)(()=>{if(s){vu();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),yu()}}},[s]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,L.jsx)(i,{size:14})}),s?(0,wl.createPortal)((0,L.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,L.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,L.jsx)(Pu,{}):null,r?(0,L.jsx)(Fu,{}):null,(0,L.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,L.jsx)(a,{size:20})})]}),(0,L.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,L.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},Lu=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=B(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,L.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,L.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,L.jsx)(Pu,{}):null,l?(0,L.jsx)(Fu,{}):null,u?(0,L.jsx)(Iu,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,L.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,L.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},Ru=/startLine=(\d+)/,zu=/\bnoLineNumbers\b/,Bu=(0,F.lazy)(()=>s(()=>import(`./mermaid-GHXKKRXX-C3g3SOag.js`).then(e=>({default:e.Mermaid})),[],import.meta.url)),Vu=/language-([^\s]+)/;function Hu(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function V(e,t){return e.className===t.className&&Hu(e.node,t.node)}var Uu=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,Wu=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},Gu=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},Ku=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},qu=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ol`,{className:B()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>V(e,t));qu.displayName=`MarkdownOl`;var Ju=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`li`,{className:B()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Hu(e.node,t.node));Ju.displayName=`MarkdownLi`;var Yu=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ul`,{className:B()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>V(e,t));Yu.displayName=`MarkdownUl`;var Xu=(0,F.memo)(({className:e,node:t,...n})=>(0,L.jsx)(`hr`,{className:B()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>V(e,t));Xu.displayName=`MarkdownHr`;var Zu=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`span`,{className:B()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>V(e,t));Zu.displayName=`MarkdownStrong`;var Qu=(0,F.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=B(),{linkSafety:o}=(0,F.useContext)(_f),[s,c]=(0,F.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,F.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,F.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,F.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,L.jsx)(bu,{...p})]}):(0,L.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>V(e,t)&&e.href===t.href);Qu.displayName=`MarkdownA`;var $u=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h1`,{className:B()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>V(e,t));$u.displayName=`MarkdownH1`;var ed=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h2`,{className:B()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>V(e,t));ed.displayName=`MarkdownH2`;var td=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h3`,{className:B()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>V(e,t));td.displayName=`MarkdownH3`;var nd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h4`,{className:B()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>V(e,t));nd.displayName=`MarkdownH4`;var rd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h5`,{className:B()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>V(e,t));rd.displayName=`MarkdownH5`;var id=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h6`,{className:B()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>V(e,t));id.displayName=`MarkdownH6`;var ad=(0,F.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,F.useContext)(_f);return(0,L.jsx)(Lu,{className:t,showControls:Uu(i,`table`),showCopy:Wu(i,`copy`),showDownload:Wu(i,`download`),showFullscreen:Wu(i,`fullscreen`),...r,children:e})},(e,t)=>V(e,t));ad.displayName=`MarkdownTable`;var od=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`thead`,{className:B()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>V(e,t));od.displayName=`MarkdownThead`;var sd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tbody`,{className:B()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>V(e,t));sd.displayName=`MarkdownTbody`;var cd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tr`,{className:B()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>V(e,t));cd.displayName=`MarkdownTr`;var ld=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`th`,{className:B()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>V(e,t));ld.displayName=`MarkdownTh`;var ud=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`td`,{className:B()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>V(e,t));ud.displayName=`MarkdownTd`;var dd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`blockquote`,{className:B()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>V(e,t));dd.displayName=`MarkdownBlockquote`;var fd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sup`,{className:B()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>V(e,t));fd.displayName=`MarkdownSup`;var pd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sub`,{className:B()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>V(e,t));pd.displayName=`MarkdownSub`;var md=(0,F.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,F.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,F.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,F.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,F.isValidElement)(e))return e;if(e.type===qu){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,L.jsx)(`section`,{className:t,...r,children:i}):null}return(0,L.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>V(e,t));md.displayName=`MarkdownSection`;var hd=(0,F.memo)(({node:e,className:t,children:n,...r})=>{let i=B(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,F.useContext)(_f),l=wu(),u=Vl(),d=(t?.match(Vu))?.at(1)??``,f=Tu(d);if(a)return(0,L.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(Ru),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&zu.test(p))&&c!==!1,v=``;if((0,F.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(mu,{}),children:(0,L.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Uu(s,`mermaid`),n=Ku(s,`download`),r=Ku(s,`copy`),a=Ku(s,`fullscreen`),c=Ku(s,`panZoom`),l=e&&(n||r||a);return(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(mu,{}),children:(0,L.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,L.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,L.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,L.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,L.jsx)(Du,{chart:v,config:o?.config}):null,r?(0,L.jsx)(du,{code:v}):null,a?(0,L.jsx)(Ou,{chart:v,config:o?.config}):null]})}):null,(0,L.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,L.jsx)(Bu,{chart:v,config:o?.config,showControls:c})})]})})}let y=Uu(s,`code`),b=Gu(s,`download`),x=Gu(s,`copy`);return(0,L.jsx)(nu,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,L.jsxs)(L.Fragment,{children:[b?(0,L.jsx)(pu,{code:v,language:d}):null,x?(0,L.jsx)(du,{}):null]}):null})},(e,t)=>e.className===t.className&&Hu(e.node,t.node));hd.displayName=`MarkdownCode`;var gd=(0,F.memo)(gu,(e,t)=>e.className===t.className&&Hu(e.node,t.node));gd.displayName=`MarkdownImg`;var _d=(0,F.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,F.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,L.jsx)(L.Fragment,{children:e})}return(0,L.jsx)(`p`,{...n,children:e})},(e,t)=>V(e,t));_d.displayName=`MarkdownParagraph`;var vd={ol:qu,li:Ju,ul:Yu,hr:Xu,strong:Zu,a:Qu,h1:$u,h2:ed,h3:td,h4:nd,h5:rd,h6:id,table:ad,thead:od,tbody:sd,tr:cd,th:ld,td:ud,blockquote:dd,code:hd,img:gd,pre:({children:e})=>(0,F.isValidElement)(e)?(0,F.cloneElement)(e,{"data-block":`true`}):e,sup:fd,sub:pd,p:_d,section:md},yd=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,bd=/\p{L}/u;function xd(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(yd.test(e))return`rtl`;if(bd.test(e))return`ltr`}return`ltr`}var Sd=/^[ \t]{0,3}(`{3,}|~{3,})/,Cd=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,wd=e=>{let t=e.split(`
106
- `),n=null,r=0;for(let e of t){let t=Sd.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},Td=e=>{let t=e.split(`
107
- `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&Cd.test(t))return!0}return!1},Ed=()=>e=>{Kt(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},Dd=[],Od={allowDangerousHtml:!0},kd=new WeakMap,Ad=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=kd.get(e);n||(n=e.name,kd.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=kd.get(r);e||(e=r.name,kd.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},jd=e=>{let t=Md(e),n=e.children||``;return zd(t.runSync(t.parse(n),n),e)},Md=e=>{let t=Ad.get(e);if(t)return t;let n=Pd(e);return Ad.set(e,n),n},Nd=e=>e.some(e=>Array.isArray(e)?e[0]===zt:e===zt),Pd=e=>{let t=e.rehypePlugins||Dd,n=e.remarkPlugins||Dd,r=Nd(t)?n:[...n,Ed],i=e.remarkRehypeOptions?{...Od,...e.remarkRehypeOptions}:Od;return It().use(Gt).use(r).use(Vt,i).use(t)},Fd=e=>e,Id=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},Ld=(e,t)=>{for(let n in Lt)if(Object.hasOwn(Lt,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Lt[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},Rd=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},zd=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||Fd;Kt(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return Id(c,s,a,e.value),s;if(e.type===`element`&&(Ld(e,t),Rd(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return Rt(e,{Fragment:L.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:L.jsx,jsxs:L.jsxs,passKeys:!0,passNode:!0})},Bd=/\[\^[\w-]{1,200}\](?!:)/,Vd=/\[\^[\w-]{1,200}\]:/,Hd=/<(\w+)[\s>]/,Ud=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Wd=new Map,Gd=new Map,Kd=e=>{let t=e.toLowerCase(),n=Wd.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return Wd.set(t,r),r},qd=e=>{let t=e.toLowerCase(),n=Gd.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return Gd.set(t,r),r},Jd=(e,t)=>{if(Ud.has(t.toLowerCase()))return 0;let n=e.match(Kd(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},Yd=(e,t)=>{let n=e.match(qd(t));return n?n.length:0},Xd=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},Zd=e=>{let t=Bd.test(e),n=Vd.test(e);if(t||n)return[e];let r=vl.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=Jd(t,e),o=Yd(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(Hd);if(e){let n=e[1];Jd(t,n)>Yd(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(Xd(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},Qd=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
104
+ `)},Uu=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},Wu=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0;r[i]=`| ${t.map(e=>Uu(e)).join(` | `)} |`,i+=1;let a=Array(t.length);for(let e=0;e<t.length;e+=1)a[e]=`---`;r[i]=`| ${a.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?Uu(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>Uu(e)).join(` | `)} |`,i+=1;return r.join(`
105
+ `)},Gu=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=B(),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),u=(0,F.useRef)(null),d=(0,F.useRef)(0),{isAnimating:f}=(0,F.useContext)(Of),p=xu(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=Bu(t),o=({csv:Vu,tsv:Hu,md:Wu}[e]||Wu)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,F.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=vu(),g=c?h.CheckIcon:h.CopyIcon;return(0,L.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,L.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,L.jsx)(g,{height:14,width:14})}),o?(0,L.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},Ku=({children:e,className:t,onDownload:n,onError:r})=>{let i=B(),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(null),{isAnimating:c}=(0,F.useContext)(Of),l=xu(),u=vu(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=Bu(t),a=e===`csv`?Vu(i):Wu(i);nu(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,F.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,L.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,L.jsx)(u.DownloadIcon,{size:14})}),a?(0,L.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},qu=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=vu(),o=B(),[s,c]=(0,F.useState)(!1),{isAnimating:l}=(0,F.useContext)(Of),u=xu(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,F.useEffect)(()=>{if(s){ku();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Au()}}},[s]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,L.jsx)(i,{size:14})}),s?(0,Fl.createPortal)((0,L.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,L.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,L.jsx)(Gu,{}):null,r?(0,L.jsx)(Ku,{}):null,(0,L.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,L.jsx)(a,{size:20})})]}),(0,L.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,L.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},Ju=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=B(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,L.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,L.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,L.jsx)(Gu,{}):null,l?(0,L.jsx)(Ku,{}):null,u?(0,L.jsx)(qu,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,L.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,L.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},Yu=/startLine=(\d+)/,Xu=/\bnoLineNumbers\b/,Zu=(0,F.lazy)(()=>s(()=>import(`./mermaid-GHXKKRXX-CnMh6H1N.js`).then(e=>({default:e.Mermaid})),[],import.meta.url)),Qu=/language-([^\s]+)/;function $u(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function V(e,t){return e.className===t.className&&$u(e.node,t.node)}var ed=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,td=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},nd=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},rd=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},id=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ol`,{className:B()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>V(e,t));id.displayName=`MarkdownOl`;var ad=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`li`,{className:B()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&$u(e.node,t.node));ad.displayName=`MarkdownLi`;var od=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ul`,{className:B()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>V(e,t));od.displayName=`MarkdownUl`;var sd=(0,F.memo)(({className:e,node:t,...n})=>(0,L.jsx)(`hr`,{className:B()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>V(e,t));sd.displayName=`MarkdownHr`;var cd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`span`,{className:B()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>V(e,t));cd.displayName=`MarkdownStrong`;var ld=(0,F.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=B(),{linkSafety:o}=(0,F.useContext)(Of),[s,c]=(0,F.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,F.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,F.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,F.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,L.jsx)(ju,{...p})]}):(0,L.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>V(e,t)&&e.href===t.href);ld.displayName=`MarkdownA`;var ud=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h1`,{className:B()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>V(e,t));ud.displayName=`MarkdownH1`;var dd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h2`,{className:B()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>V(e,t));dd.displayName=`MarkdownH2`;var fd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h3`,{className:B()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>V(e,t));fd.displayName=`MarkdownH3`;var pd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h4`,{className:B()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>V(e,t));pd.displayName=`MarkdownH4`;var md=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h5`,{className:B()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>V(e,t));md.displayName=`MarkdownH5`;var hd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h6`,{className:B()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>V(e,t));hd.displayName=`MarkdownH6`;var gd=(0,F.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,F.useContext)(Of);return(0,L.jsx)(Ju,{className:t,showControls:ed(i,`table`),showCopy:td(i,`copy`),showDownload:td(i,`download`),showFullscreen:td(i,`fullscreen`),...r,children:e})},(e,t)=>V(e,t));gd.displayName=`MarkdownTable`;var _d=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`thead`,{className:B()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>V(e,t));_d.displayName=`MarkdownThead`;var vd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tbody`,{className:B()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>V(e,t));vd.displayName=`MarkdownTbody`;var yd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tr`,{className:B()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>V(e,t));yd.displayName=`MarkdownTr`;var bd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`th`,{className:B()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>V(e,t));bd.displayName=`MarkdownTh`;var xd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`td`,{className:B()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>V(e,t));xd.displayName=`MarkdownTd`;var Sd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`blockquote`,{className:B()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>V(e,t));Sd.displayName=`MarkdownBlockquote`;var Cd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sup`,{className:B()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>V(e,t));Cd.displayName=`MarkdownSup`;var wd=(0,F.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sub`,{className:B()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>V(e,t));wd.displayName=`MarkdownSub`;var Td=(0,F.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,F.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,F.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,F.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,F.isValidElement)(e))return e;if(e.type===id){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,L.jsx)(`section`,{className:t,...r,children:i}):null}return(0,L.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>V(e,t));Td.displayName=`MarkdownSection`;var Ed=(0,F.memo)(({node:e,className:t,children:n,...r})=>{let i=B(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,F.useContext)(Of),l=Fu(),u=Ql(),d=(t?.match(Qu))?.at(1)??``,f=Iu(d);if(a)return(0,L.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(Yu),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&Xu.test(p))&&c!==!1,v=``;if((0,F.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(Tu,{}),children:(0,L.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=ed(s,`mermaid`),n=rd(s,`download`),r=rd(s,`copy`),a=rd(s,`fullscreen`),c=rd(s,`panZoom`),l=e&&(n||r||a);return(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(Tu,{}),children:(0,L.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,L.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,L.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,L.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,L.jsx)(Ru,{chart:v,config:o?.config}):null,r?(0,L.jsx)(Su,{code:v}):null,a?(0,L.jsx)(zu,{chart:v,config:o?.config}):null]})}):null,(0,L.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,L.jsx)(Zu,{chart:v,config:o?.config,showControls:c})})]})})}let y=ed(s,`code`),b=nd(s,`download`),x=nd(s,`copy`);return(0,L.jsx)(pu,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,L.jsxs)(L.Fragment,{children:[b?(0,L.jsx)(wu,{code:v,language:d}):null,x?(0,L.jsx)(Su,{}):null]}):null})},(e,t)=>e.className===t.className&&$u(e.node,t.node));Ed.displayName=`MarkdownCode`;var Dd=(0,F.memo)(Du,(e,t)=>e.className===t.className&&$u(e.node,t.node));Dd.displayName=`MarkdownImg`;var Od=(0,F.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,F.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,L.jsx)(L.Fragment,{children:e})}return(0,L.jsx)(`p`,{...n,children:e})},(e,t)=>V(e,t));Od.displayName=`MarkdownParagraph`;var kd={ol:id,li:ad,ul:od,hr:sd,strong:cd,a:ld,h1:ud,h2:dd,h3:fd,h4:pd,h5:md,h6:hd,table:gd,thead:_d,tbody:vd,tr:yd,th:bd,td:xd,blockquote:Sd,code:Ed,img:Dd,pre:({children:e})=>(0,F.isValidElement)(e)?(0,F.cloneElement)(e,{"data-block":`true`}):e,sup:Cd,sub:wd,p:Od,section:Td},Ad=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,jd=/\p{L}/u;function Md(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(Ad.test(e))return`rtl`;if(jd.test(e))return`ltr`}return`ltr`}var Nd=/^[ \t]{0,3}(`{3,}|~{3,})/,Pd=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,Fd=e=>{let t=e.split(`
106
+ `),n=null,r=0;for(let e of t){let t=Nd.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},Id=e=>{let t=e.split(`
107
+ `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&Pd.test(t))return!0}return!1},Ld=()=>e=>{Yt(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},Rd=[],zd={allowDangerousHtml:!0},Bd=new WeakMap,Vd=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=Bd.get(e);n||(n=e.name,Bd.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=Bd.get(r);e||(e=r.name,Bd.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},Hd=e=>{let t=Ud(e),n=e.children||``;return Xd(t.runSync(t.parse(n),n),e)},Ud=e=>{let t=Vd.get(e);if(t)return t;let n=Gd(e);return Vd.set(e,n),n},Wd=e=>e.some(e=>Array.isArray(e)?e[0]===Ht:e===Ht),Gd=e=>{let t=e.rehypePlugins||Rd,n=e.remarkPlugins||Rd,r=Wd(t)?n:[...n,Ld],i=e.remarkRehypeOptions?{...zd,...e.remarkRehypeOptions}:zd;return zt().use(Jt).use(r).use(Wt,i).use(t)},Kd=e=>e,qd=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},Jd=(e,t)=>{for(let n in Bt)if(Object.hasOwn(Bt,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Bt[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},Yd=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},Xd=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||Kd;Yt(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return qd(c,s,a,e.value),s;if(e.type===`element`&&(Jd(e,t),Yd(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return Vt(e,{Fragment:L.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:L.jsx,jsxs:L.jsxs,passKeys:!0,passNode:!0})},Zd=/\[\^[\w-]{1,200}\](?!:)/,Qd=/\[\^[\w-]{1,200}\]:/,$d=/<(\w+)[\s>]/,ef=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),tf=new Map,nf=new Map,rf=e=>{let t=e.toLowerCase(),n=tf.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return tf.set(t,r),r},af=e=>{let t=e.toLowerCase(),n=nf.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return nf.set(t,r),r},of=(e,t)=>{if(ef.has(t.toLowerCase()))return 0;let n=e.match(rf(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},sf=(e,t)=>{let n=e.match(af(t));return n?n.length:0},cf=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},lf=e=>{let t=Zd.test(e),n=Qd.test(e);if(t||n)return[e];let r=kl.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=of(t,e),o=sf(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match($d);if(e){let n=e[1];of(t,n)>sf(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(cf(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},uf=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
108
108
 
109
109
  `))return t+n+r;let i=n.replace(/\n\n/g,`
110
110
  <!---->
@@ -114,7 +114,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
114
114
  `)?``:`
115
115
  `)}${r}
116
116
 
117
- `})}return n},$d=/([\\`*_~[\]|])/g,ef=e=>e.replace($d,`\\$1`),tf=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>t+ef(n).replace(/\n\n/g,`&#10;&#10;`)+r)}return n},nf=e=>e.type===`text`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(nf).join(``):``,rf=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(e=>e.toLowerCase()));Kt(t,`element`,e=>{if(n.has(e.tagName.toLowerCase())){let t=nf(e);e.children=t?[{type:`text`,value:t}]:[]}})},af=()=>e=>{Kt(e,`code`,e=>{e.meta&&(e.data=e.data??{},e.data.hProperties={...e.data.hProperties??{},metastring:e.meta})})},of=/^[ \t]*<[\w!/?-]/,sf=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,cf=e=>typeof e!=`string`||e.length===0||!of.test(e)?e:e.replace(sf,`$1`),lf={...Bt,protocols:{...Bt.protocols,href:[...Bt.protocols?.href??[],`tel`]},attributes:{...Bt.attributes,code:[...Bt.attributes?.code??[],`metastring`]}},uf={raw:zt,sanitize:[Ht,lf],harden:[Pt,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],allowedProtocols:[`*`],defaultOrigin:void 0,allowDataImages:!0}]},df={gfm:[Ut,{}],codeMeta:af},ff=Object.values(uf),pf=Object.values(df),mf={block:` ▋`,circle:` ●`},hf=[`github-light`,`github-dark`],gf={enabled:!0},_f=(0,F.createContext)({shikiTheme:hf,controls:!0,isAnimating:!1,lineNumbers:!0,mode:`streaming`,mermaid:void 0,linkSafety:gf}),vf=(0,F.memo)(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:r,isIncomplete:i,dir:a,animatePlugin:o,...s})=>{if(o){let e=o.getLastRenderCharCount();o.setPrevContentLength(e)}let c=typeof e==`string`&&n?cf(e):e,l=(0,L.jsx)(jd,{...s,children:c});return(0,L.jsx)(Bl.Provider,{value:i,children:a?(0,L.jsx)(`div`,{dir:a,style:{display:`contents`},children:l}):l})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),r=Object.keys(t.components||{});if(n.length!==r.length||n.some(n=>e.components?.[n]!==t.components?.[n]))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});vf.displayName=`Block`;var yf=(0,F.memo)(({children:e,mode:t=`streaming`,dir:n,parseIncompleteMarkdown:r=!0,normalizeHtmlIndentation:i=!1,components:a,rehypePlugins:o=ff,remarkPlugins:s=pf,className:c,shikiTheme:l=hf,mermaid:u,controls:d=!0,isAnimating:f=!1,animated:p,BlockComponent:m=vf,parseMarkdownIntoBlocksFn:h=Zd,caret:g,plugins:_,remend:v,linkSafety:y=gf,lineNumbers:b=!0,allowedTags:x,literalTagContent:S,translations:C,icons:w,prefix:T,onAnimationStart:E,onAnimationEnd:D,...ee})=>{let O=(0,F.useId)(),[te,ne]=(0,F.useTransition)(),re=(0,F.useMemo)(()=>Wl(T),[T]),ie=(0,F.useRef)(null),ae=(0,F.useRef)(E),oe=(0,F.useRef)(D);ae.current=E,oe.current=D,(0,F.useEffect)(()=>{var e,n,r;if(t===`static`)return;let i=ie.current;if(ie.current=f,i===null){f&&((e=ae.current)==null||e.call(ae));return}f&&!i?(n=ae.current)==null||n.call(ae):!f&&i&&((r=oe.current)==null||r.call(oe))},[f,t]);let se=(0,F.useMemo)(()=>x?Object.keys(x):[],[x]),ce=(0,F.useMemo)(()=>{if(typeof e!=`string`)return``;let n=t===`streaming`&&r?Ys(e,v):e;return S&&S.length>0&&(n=tf(n,S)),se.length>0&&(n=Qd(n,se)),n},[e,t,r,v,se,S]),le=(0,F.useMemo)(()=>h(ce),[ce,h]),[ue,de]=(0,F.useState)(le);(0,F.useEffect)(()=>{t===`streaming`&&!ge?ne(()=>{de(le)}):de(le)},[le,t]);let fe=t===`streaming`?ue:le,pe=(0,F.useMemo)(()=>n===`auto`?fe.map(xd):void 0,[fe,n]),me=(0,F.useMemo)(()=>fe.map((e,t)=>`${O}-${t}`),[fe.length,O]),he=(0,F.useMemo)(()=>p===!0?`true`:p?JSON.stringify(p):``,[p]),ge=(0,F.useMemo)(()=>he?he===`true`?zl():zl(p):null,[he]),_e=(0,F.useMemo)(()=>({shikiTheme:(_?.code)?.getThemes()??l,controls:d,isAnimating:f,lineNumbers:b,mode:t,mermaid:u,linkSafety:y}),[l,d,f,b,t,u,y,_?.code]),ve=(0,F.useMemo)(()=>({...cu,...C}),[(0,F.useMemo)(()=>C?JSON.stringify(C):``,[C])]),ye=(0,F.useMemo)(()=>{let{inlineCode:e,...t}=a??{},n={...vd,...t};if(e){let t=n.code;n.code=n=>`data-block`in n?t?(0,F.createElement)(t,n):null:(0,F.createElement)(e,n)}return n},[a]),be=(0,F.useMemo)(()=>{let e=[];return _!=null&&_.cjk&&(e=[...e,..._.cjk.remarkPluginsBefore]),e=[...e,...s],_!=null&&_.cjk&&(e=[...e,..._.cjk.remarkPluginsAfter]),_!=null&&_.math&&(e=[...e,_.math.remarkPlugin]),e},[s,_?.math,_?.cjk]),xe=(0,F.useMemo)(()=>{let e=o;if(x&&Object.keys(x).length>0&&o===ff){let t={...lf,tagNames:[...lf.tagNames??[],...Object.keys(x)],attributes:{...lf.attributes,...x}};e=[uf.raw,[Ht,t],uf.harden]}return S&&S.length>0&&(e=[...e,[rf,S]]),_!=null&&_.math&&(e=[...e,_.math.rehypePlugin]),ge&&f&&(e=[...e,ge.rehypePlugin]),e},[o,_?.math,ge,f,x,S]),Se=(0,F.useMemo)(()=>{if(!f||fe.length===0)return!1;let e=fe.at(-1);return wd(e)||Td(e)},[f,fe]),Ce=(0,F.useMemo)(()=>g&&f&&!Se?{"--streamdown-caret":`"${mf[g]}"`}:void 0,[g,f,Se]);return t===`static`?(0,L.jsx)(lu.Provider,{value:ve,children:(0,L.jsx)(xu.Provider,{value:_??null,children:(0,L.jsx)(_f.Provider,{value:_e,children:(0,L.jsx)(ou,{icons:w,children:(0,L.jsx)(Kl.Provider,{value:re,children:(0,L.jsx)(`div`,{className:re(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,c),dir:n===`auto`?xd(ce):n,children:(0,L.jsx)(jd,{components:ye,rehypePlugins:xe,remarkPlugins:be,...ee,children:ce})})})})})})}):(0,L.jsx)(lu.Provider,{value:ve,children:(0,L.jsx)(xu.Provider,{value:_??null,children:(0,L.jsx)(_f.Provider,{value:_e,children:(0,L.jsx)(ou,{icons:w,children:(0,L.jsx)(Kl.Provider,{value:re,children:(0,L.jsxs)(`div`,{className:re(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,g&&!Se?`[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]`:null,c),style:Ce,children:[fe.length===0&&g&&f&&(0,L.jsx)(`span`,{}),fe.map((e,t)=>{let a=t===fe.length-1,o=f&&a&&wd(e);return(0,L.jsx)(m,{animatePlugin:ge,components:ye,content:e,dir:pe?.[t]??(n===`auto`?void 0:n),index:t,isIncomplete:o,rehypePlugins:xe,remarkPlugins:be,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:r,...ee},me[t])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);yf.displayName=`Streamdown`;var bf=({children:e,className:t,minZoom:n=.5,maxZoom:r=3,zoomStep:i=.1,showControls:a=!0,initialZoom:o=1,fullscreen:s=!1})=>{let{RotateCcwIcon:c,ZoomInIcon:l,ZoomOutIcon:u}=su(),d=B(),f=(0,F.useRef)(null),p=(0,F.useRef)(null),[m,h]=(0,F.useState)(o),[g,_]=(0,F.useState)({x:0,y:0}),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)({x:0,y:0}),[S,C]=(0,F.useState)({x:0,y:0}),w=(0,F.useCallback)(e=>{h(t=>Math.max(n,Math.min(r,t+e)))},[n,r]),T=(0,F.useCallback)(()=>{w(i)},[w,i]),E=(0,F.useCallback)(()=>{w(-i)},[w,i]),D=(0,F.useCallback)(()=>{h(o),_({x:0,y:0})},[o]),ee=(0,F.useCallback)(e=>{e.preventDefault(),w(e.deltaY>0?-i:i)},[w,i]),O=(0,F.useCallback)(e=>{if(e.button!==0||e.isPrimary===!1)return;y(!0),x({x:e.clientX,y:e.clientY}),C(g);let t=e.currentTarget;t instanceof HTMLElement&&t.setPointerCapture(e.pointerId)},[g]),te=(0,F.useCallback)(e=>{if(!v)return;e.preventDefault();let t=e.clientX-b.x,n=e.clientY-b.y;_({x:S.x+t,y:S.y+n})},[v,b,S]),ne=(0,F.useCallback)(e=>{y(!1);let t=e.currentTarget;t instanceof HTMLElement&&t.releasePointerCapture(e.pointerId)},[]);return(0,F.useEffect)(()=>{let e=f.current;if(e)return e.addEventListener(`wheel`,ee,{passive:!1}),()=>{e.removeEventListener(`wheel`,ee)}},[ee]),(0,F.useEffect)(()=>{let e=p.current;if(e&&v)return document.body.style.userSelect=`none`,e.addEventListener(`pointermove`,te,{passive:!1}),e.addEventListener(`pointerup`,ne),e.addEventListener(`pointercancel`,ne),()=>{document.body.style.userSelect=``,e.removeEventListener(`pointermove`,te),e.removeEventListener(`pointerup`,ne),e.removeEventListener(`pointercancel`,ne)}},[v,te,ne]),(0,L.jsxs)(`div`,{className:d(`relative flex flex-col`,s?`h-full w-full`:`min-h-28 w-full`,t),ref:f,style:{cursor:v?`grabbing`:`grab`},children:[a?(0,L.jsxs)(`div`,{className:d(`absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm`,s?`bottom-4 left-4`:`bottom-2 left-2`),children:[(0,L.jsx)(`button`,{className:d(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:m>=r,onClick:T,title:`Zoom in`,type:`button`,children:(0,L.jsx)(l,{size:16})}),(0,L.jsx)(`button`,{className:d(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:m<=n,onClick:E,title:`Zoom out`,type:`button`,children:(0,L.jsx)(u,{size:16})}),(0,L.jsx)(`button`,{className:d(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`),onClick:D,title:`Reset zoom and pan`,type:`button`,children:(0,L.jsx)(c,{size:16})})]}):null,(0,L.jsx)(`div`,{className:d(`flex-1 origin-center transition-transform duration-150 ease-out`,s?`flex h-full w-full items-center justify-center`:`flex w-full items-center justify-center`),onPointerDown:O,ref:p,role:`application`,style:{transform:`translate(${g.x}px, ${g.y}px) scale(${m})`,transformOrigin:`center center`,touchAction:`none`,willChange:`transform`},children:e})]})},xf=({chart:e,className:t,config:n,fullscreen:r=!1,showControls:i=!0})=>{let a=B(),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(0),{mermaid:g}=(0,F.useContext)(_f),_=wu(),v=g?.errorComponent,{shouldRender:y,containerRef:b}=Ol({immediate:r});if((0,F.useEffect)(()=>{if(y){if(!_){s(`Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.`);return}(async()=>{try{s(null),l(!0);let t=_.getMermaid(n),r=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),i=`mermaid-${Math.abs(r)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:a}=await t.render(i,e);d(a),p(a)}catch(e){f||u||s(e instanceof Error?e.message:`Failed to render Mermaid chart`)}finally{l(!1)}})()}},[e,n,m,y,_]),!(y||u||f))return(0,L.jsx)(`div`,{className:a(`my-4 min-h-[200px]`,t),ref:b});if(c&&!u&&!f)return(0,L.jsx)(`div`,{className:a(`my-4 flex justify-center p-4`,t),ref:b,children:(0,L.jsxs)(`div`,{className:a(`flex items-center space-x-2 text-muted-foreground`),children:[(0,L.jsx)(`div`,{className:a(`h-4 w-4 animate-spin rounded-full border-current border-b-2`)}),(0,L.jsx)(`span`,{className:a(`text-sm`),children:`Loading diagram...`})]})});if(o&&!u&&!f)return v?(0,L.jsx)(`div`,{ref:b,children:(0,L.jsx)(v,{chart:e,error:o,retry:()=>h(e=>e+1)})}):(0,L.jsxs)(`div`,{className:a(`rounded-md bg-red-50 p-4`,t),ref:b,children:[(0,L.jsxs)(`p`,{className:a(`font-mono text-red-700 text-sm`),children:[`Mermaid Error: `,o]}),(0,L.jsxs)(`details`,{className:a(`mt-2`),children:[(0,L.jsx)(`summary`,{className:a(`cursor-pointer text-red-600 text-xs`),children:`Show Code`}),(0,L.jsx)(`pre`,{className:a(`mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs`),children:e})]})]});let x=u||f;return(0,L.jsx)(`div`,{className:a(`size-full`,t),"data-streamdown":`mermaid`,ref:b,children:(0,L.jsx)(bf,{className:a(r?`size-full overflow-hidden`:`overflow-hidden`,t),fullscreen:r,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:(0,L.jsx)(`div`,{"aria-label":`Mermaid chart`,className:a(`flex justify-center`,r?`size-full items-center`:null),dangerouslySetInnerHTML:{__html:x},role:`img`})})})},Sf=({className:e,from:t,...n})=>(0,L.jsx)(`div`,{className:j(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...n}),Cf=({children:e,className:t,...n})=>(0,L.jsx)(`div`,{className:j(`is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm`,`group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground`,`group-[.is-assistant]:text-foreground`,t),...n,children:e}),wf=({className:e,children:t,...n})=>(0,L.jsx)(`div`,{className:j(`flex items-center gap-1`,e),...n,children:t}),Tf=({tooltip:e,children:t,label:n,variant:r=`ghost`,size:i=`icon`,...a})=>{let o=(0,L.jsxs)(A,{size:i,type:`button`,variant:r,...a,children:[t,(0,L.jsx)(`span`,{className:`sr-only`,children:n||e})]});return e?(0,L.jsx)(ne,{children:(0,L.jsxs)(be,{children:[(0,L.jsx)(ot,{asChild:!0,children:o}),(0,L.jsx)(st,{children:(0,L.jsx)(`p`,{children:e})})]})}):o};(0,F.createContext)(null);var Ef=(0,F.memo)(({className:e,...t})=>(0,L.jsx)(yf,{className:j(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);Ef.displayName=`MessageResponse`;function Df({className:e,...t}){return(0,L.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:j(`group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30`,`h-9 min-w-0 has-[>textarea]:h-auto`,`has-[>[data-align=inline-start]]:[&>input]:pl-2`,`has-[>[data-align=inline-end]]:[&>input]:pr-2`,`has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3`,`has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3`,`has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50`,`has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40`,e),...t})}var Of=jt(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]`,"inline-end":`order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]`,"block-start":`order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3`,"block-end":`order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3`}},defaultVariants:{align:`inline-start`}});function kf({className:e,align:t=`inline-start`,...n}){return(0,L.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:j(Of({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var Af=jt(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5`,sm:`h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5`,"icon-xs":`size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function jf({className:e,type:t=`button`,variant:n=`ghost`,size:r=`xs`,...i}){return(0,L.jsx)(A,{type:t,"data-size":r,variant:n,className:j(Af({size:r}),e),...i})}function Mf({className:e,...t}){return(0,L.jsx)(Ct,{"data-slot":`input-group-control`,className:j(`flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent`,e),...t})}var Nf=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,Pf=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Nf[n[e]&63];return t},Ff=(0,F.createContext)(null),If=(0,F.createContext)(null),Lf=()=>(0,F.useContext)(Ff),Rf=()=>(0,F.useContext)(If),zf=(0,F.createContext)(null),Bf=()=>{let e=Rf(),t=(0,F.useContext)(zf),n=e??t;if(!n)throw Error(`usePromptInputAttachments must be used within a PromptInput or PromptInputProvider`);return n};function Vf({data:e,className:t,...n}){let r=Bf(),i=e.filename||``,a=(e.mediaType?.startsWith(`image/`)&&e.url?`image`:`file`)==`image`,o=i||(a?`Image`:`Attachment`);return(0,L.jsxs)(ep,{children:[(0,L.jsx)(Ve,{asChild:!0,children:(0,L.jsxs)(`div`,{className:j(`group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,t),...n,children:[(0,L.jsxs)(`div`,{className:`relative size-5 shrink-0`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0`,children:a?(0,L.jsx)(`img`,{alt:i||`attachment`,className:`size-5 object-cover`,height:20,src:e.url,width:20}):(0,L.jsx)(`div`,{className:`flex size-5 items-center justify-center text-muted-foreground`,children:(0,L.jsx)(Ce,{className:`size-3`})})}),(0,L.jsxs)(A,{"aria-label":`Remove attachment`,className:`absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5`,onClick:t=>{t.stopPropagation(),r.remove(e.id)},type:`button`,variant:`ghost`,children:[(0,L.jsx)(De,{}),(0,L.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]}),(0,L.jsx)(`span`,{className:`flex-1 truncate`,children:o})]},e.id)}),(0,L.jsx)(tp,{className:`w-auto p-2`,children:(0,L.jsxs)(`div`,{className:`w-auto space-y-3`,children:[a&&(0,L.jsx)(`div`,{className:`flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border`,children:(0,L.jsx)(`img`,{alt:i||`attachment preview`,className:`max-h-full max-w-full object-contain`,height:384,src:e.url,width:448})}),(0,L.jsx)(`div`,{className:`flex items-center gap-2.5`,children:(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 px-0.5`,children:[(0,L.jsx)(`h4`,{className:`truncate font-semibold text-sm leading-none`,children:i||(a?`Image`:`Attachment`)}),e.mediaType&&(0,L.jsx)(`p`,{className:`truncate font-mono text-muted-foreground text-xs`,children:e.mediaType})]})})]})})]})}function Hf({children:e,className:t,...n}){let r=Bf();return r.files.length?(0,L.jsx)(`div`,{className:j(`flex flex-wrap items-center gap-2 p-3 w-full`,t),...n,children:r.files.map(t=>(0,L.jsx)(F.Fragment,{children:e(t)},t.id))}):null}var Uf=({label:e=`Add photos or files`,...t})=>{let n=Bf();return(0,L.jsxs)(wt,{...t,onSelect:e=>{e.preventDefault(),n.openFileDialog()},children:[(0,L.jsx)(Pe,{className:`mr-2 size-4`}),` `,e]})},Wf=({className:e,accept:t,multiple:n,fileInputLabel:r=`Upload files`,globalDrop:i,syncHiddenInput:a,maxFiles:o,maxFileSize:s,onError:c,onSubmit:l,children:u,...d})=>{let f=Lf(),p=!!f,m=(0,F.useRef)(null),h=(0,F.useRef)(null),[g,_]=(0,F.useState)([]),v=p?f.attachments.files:g,y=(0,F.useRef)(v);y.current=v;let b=(0,F.useCallback)(()=>{m.current?.click()},[]),x=(0,F.useCallback)(e=>!t||t.trim()===``?!0:t.split(`,`).map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith(`/*`)){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t}),[t]),S=(0,F.useCallback)(e=>{let t=Array.from(e),n=t.filter(e=>x(e));if(t.length&&n.length===0){c?.({code:`accept`,message:`No files match the accepted types.`});return}let r=n.filter(e=>s?e.size<=s:!0);if(n.length>0&&r.length===0){c?.({code:`max_file_size`,message:`All files exceed the maximum size.`});return}_(e=>{let t=typeof o==`number`?Math.max(0,o-e.length):void 0,n=typeof t==`number`?r.slice(0,t):r;typeof t==`number`&&r.length>t&&c?.({code:`max_files`,message:`Too many files. Some were not added.`});let i=[];for(let e of n)i.push({id:Pf(),type:`file`,url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(i)})},[x,o,s,c]),C=(0,F.useCallback)(e=>_(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)}),[]),w=(0,F.useCallback)(()=>_(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]}),[]),T=p?f.attachments.add:S,E=p?f.attachments.remove:C,D=p?f.attachments.clear:w,ee=p?f.attachments.openFileDialog:b;(0,F.useEffect)(()=>{p&&f.__registerFileInput(m,()=>m.current?.click())},[p,f]),(0,F.useEffect)(()=>{a&&m.current&&v.length===0&&(m.current.value=``)},[v,a]),(0,F.useEffect)(()=>{let e=h.current;if(!e||i)return;let t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},n=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&T(e.dataTransfer.files)};return e.addEventListener(`dragover`,t),e.addEventListener(`drop`,n),()=>{e.removeEventListener(`dragover`,t),e.removeEventListener(`drop`,n)}},[T,i]),(0,F.useEffect)(()=>{if(!i)return;let e=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&T(e.dataTransfer.files)};return document.addEventListener(`dragover`,e),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`dragover`,e),document.removeEventListener(`drop`,t)}},[T,i]),(0,F.useEffect)(()=>()=>{if(!p)for(let e of y.current)e.url&&URL.revokeObjectURL(e.url)},[p]);let O=e=>{e.currentTarget.files&&T(e.currentTarget.files),e.currentTarget.value=``},te=async e=>{try{let t=await(await fetch(e)).blob();return new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.onerror=()=>e(null),n.readAsDataURL(t)})}catch{return null}},ne=(0,F.useMemo)(()=>({files:v.map(e=>({...e,id:e.id})),add:T,remove:E,clear:D,openFileDialog:ee,fileInputRef:m}),[v,T,E,D,ee]),re=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{accept:t,"aria-label":r,className:`hidden`,multiple:n,onChange:O,ref:m,title:r,type:`file`}),(0,L.jsx)(`form`,{className:j(`w-full`,e),onSubmit:e=>{e.preventDefault();let t=e.currentTarget,n=p?f.textInput.value:new FormData(t).get(`message`)||``;p||t.reset(),Promise.all(v.map(async({id:e,...t})=>{if(t.url&&t.url.startsWith(`blob:`)){let e=await te(t.url);return{...t,url:e??t.url}}return t})).then(t=>{try{let r=l({text:n,files:t},e);r instanceof Promise?r.then(()=>{D(),p&&f.textInput.clear()}).catch(()=>{}):(D(),p&&f.textInput.clear())}catch{}}).catch(()=>{})},ref:h,...d,children:(0,L.jsx)(Df,{className:`overflow-hidden`,children:u})})]});return p?re:(0,L.jsx)(zf.Provider,{value:ne,children:re})},Gf=({className:e,...t})=>(0,L.jsx)(`div`,{className:j(`contents`,e),...t}),Kf=({onChange:e,className:t,placeholder:n=`What would you like to know?`,...r})=>{let i=Lf(),a=Bf(),[o,s]=(0,F.useState)(!1),c=e=>{if(e.key===`Enter`){if(o||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let t=e.currentTarget.form;if(t?.querySelector(`button[type="submit"]`)?.disabled)return;t?.requestSubmit()}if(e.key===`Backspace`&&e.currentTarget.value===``&&a.files.length>0){e.preventDefault();let t=a.files[a.files.length-1];t&&a.remove(t.id)}},l=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),a.add(n))},u=i?{value:i.textInput.value,onChange:t=>{i.textInput.setInput(t.currentTarget.value),e?.(t)}}:{onChange:e};return(0,L.jsx)(Mf,{className:j(`field-sizing-content max-h-48 min-h-16`,t),name:`message`,onCompositionEnd:()=>s(!1),onCompositionStart:()=>s(!0),onKeyDown:c,onPaste:l,placeholder:n,...r,...u})},qf=({className:e,...t})=>(0,L.jsx)(kf,{align:`block-end`,className:j(`justify-between gap-1`,e),...t}),Jf=({className:e,...t})=>(0,L.jsx)(`div`,{className:j(`flex items-center gap-1`,e),...t}),Yf=({variant:e=`ghost`,className:t,size:n,...r})=>{let i=n??(F.Children.count(r.children)>1?`sm`:`icon-sm`);return(0,L.jsx)(jf,{className:j(t),size:i,type:`button`,variant:e,...r})},Xf=e=>(0,L.jsx)(yt,{...e}),Zf=({className:e,children:t,...n})=>(0,L.jsx)(Qe,{asChild:!0,children:(0,L.jsx)(Yf,{className:e,...n,children:t??(0,L.jsx)(ke,{className:`size-4`})})}),Qf=({className:e,...t})=>(0,L.jsx)(Ge,{align:`start`,className:j(e),...t}),$f=({className:e,variant:t=`default`,size:n=`icon-sm`,status:r,children:i,...a})=>{let o=(0,L.jsx)(pe,{className:`size-4`});return r===`submitted`?o=(0,L.jsx)(_e,{className:`size-4 animate-spin`}):r===`streaming`?o=(0,L.jsx)(et,{className:`size-4`}):r===`error`&&(o=(0,L.jsx)(De,{className:`size-4`})),(0,L.jsx)(jf,{"aria-label":`Submit`,className:j(e),size:n,type:`submit`,variant:t,...a,children:i??o})},ep=({openDelay:e=0,closeDelay:t=0,...n})=>(0,L.jsx)(gt,{closeDelay:t,openDelay:e,...n}),tp=({align:e=`start`,...t})=>(0,L.jsx)(tt,{align:e,...t}),np=({className:e,children:t,...n})=>(0,L.jsxs)(le,{className:`w-full overflow-x-auto whitespace-nowrap`,...n,children:[(0,L.jsx)(`div`,{className:j(`flex w-max flex-nowrap items-center gap-2`,e),children:t}),(0,L.jsx)(he,{className:`hidden`,orientation:`horizontal`})]}),rp=({suggestion:e,onClick:t,className:n,variant:r=`outline`,size:i=`sm`,children:a,...o})=>(0,L.jsx)(A,{className:j(`cursor-pointer rounded-full px-4`,n),onClick:()=>{t?.(e)},size:i,type:`button`,variant:r,...o,children:a||e}),ip=Object.defineProperty,ap=Object.getOwnPropertyDescriptor,op=Object.getOwnPropertyNames,sp=Object.prototype.hasOwnProperty,cp=(e,t)=>{let n={};for(var r in e)ip(n,r,{get:e[r],enumerable:!0});return t||ip(n,Symbol.toStringTag,{value:`Module`}),n},lp=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=op(t),a=0,o=i.length,s;a<o;a++)s=i[a],!sp.call(e,s)&&s!==n&&ip(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ap(t,s))||r.enumerable});return e},up=(e,t,n)=>(lp(e,t,`default`),n&&lp(n,t,`default`)),dp=[{id:`abap`,name:`ABAP`,import:(()=>s(()=>import(`./abap-CLvhMVsD.js`),[],import.meta.url))},{id:`actionscript-3`,name:`ActionScript`,import:(()=>s(()=>import(`./actionscript-3--17pq3dv.js`),[],import.meta.url))},{id:`ada`,name:`Ada`,import:(()=>s(()=>import(`./ada-C5qYipkI.js`),[],import.meta.url))},{id:`angular-html`,name:`Angular HTML`,import:(()=>s(()=>import(`./angular-html-B9s24XBK.js`).then(e=>e.n),[],import.meta.url))},{id:`angular-ts`,name:`Angular TypeScript`,import:(()=>s(()=>import(`./angular-ts-C7DCn4N7.js`),[],import.meta.url))},{id:`apache`,name:`Apache Conf`,import:(()=>s(()=>import(`./apache-U0d_L8uA.js`),[],import.meta.url))},{id:`apex`,name:`Apex`,import:(()=>s(()=>import(`./apex-VAyPSnFM.js`),[],import.meta.url))},{id:`apl`,name:`APL`,import:(()=>s(()=>import(`./apl-BFSpAsVe.js`),[],import.meta.url))},{id:`applescript`,name:`AppleScript`,import:(()=>s(()=>import(`./applescript-CCn79oCD.js`),[],import.meta.url))},{id:`ara`,name:`Ara`,import:(()=>s(()=>import(`./ara-4CJ0cIlV.js`),[],import.meta.url))},{id:`asciidoc`,name:`AsciiDoc`,aliases:[`adoc`],import:(()=>s(()=>import(`./asciidoc-DE70LPWp.js`),[],import.meta.url))},{id:`asm`,name:`Assembly`,import:(()=>s(()=>import(`./asm-Cmm7eHzH.js`),[],import.meta.url))},{id:`astro`,name:`Astro`,import:(()=>s(()=>import(`./astro-By5nmri_.js`),[],import.meta.url))},{id:`awk`,name:`AWK`,import:(()=>s(()=>import(`./awk-BWXHIvNe.js`),[],import.meta.url))},{id:`ballerina`,name:`Ballerina`,import:(()=>s(()=>import(`./ballerina-B7ZEbQpA.js`),[],import.meta.url))},{id:`bat`,name:`Batch File`,aliases:[`batch`],import:(()=>s(()=>import(`./bat-Bo4NYOV-.js`),[],import.meta.url))},{id:`beancount`,name:`Beancount`,import:(()=>s(()=>import(`./beancount-D-usSTwE.js`),[],import.meta.url))},{id:`berry`,name:`Berry`,aliases:[`be`],import:(()=>s(()=>import(`./berry-DKpUyyne.js`),[],import.meta.url))},{id:`bibtex`,name:`BibTeX`,import:(()=>s(()=>import(`./bibtex-Ci_nEsc7.js`),[],import.meta.url))},{id:`bicep`,name:`Bicep`,import:(()=>s(()=>import(`./bicep-CUHmPFLl.js`),[],import.meta.url))},{id:`bird2`,name:`BIRD2 Configuration`,aliases:[`bird`],import:(()=>s(()=>import(`./bird2-C6vDhewU.js`),[],import.meta.url))},{id:`blade`,name:`Blade`,import:(()=>s(()=>import(`./blade-BEsyb4Es.js`),[],import.meta.url))},{id:`bsl`,name:`1C (Enterprise)`,aliases:[`1c`],import:(()=>s(()=>import(`./bsl-BkkzgIyY.js`),[],import.meta.url))},{id:`c`,name:`C`,import:(()=>s(()=>import(`./c-CwKsiqWD.js`).then(e=>e.n),[],import.meta.url))},{id:`c3`,name:`C3`,import:(()=>s(()=>import(`./c3-BFHwR3_K.js`),[],import.meta.url))},{id:`cadence`,name:`Cadence`,aliases:[`cdc`],import:(()=>s(()=>import(`./cadence-CQ2zXKGN.js`),[],import.meta.url))},{id:`cairo`,name:`Cairo`,import:(()=>s(()=>import(`./cairo-DLTphjLi.js`),[],import.meta.url))},{id:`clarity`,name:`Clarity`,import:(()=>s(()=>import(`./clarity-SemFz856.js`),[],import.meta.url))},{id:`clojure`,name:`Clojure`,aliases:[`clj`],import:(()=>s(()=>import(`./clojure-DqKBuwfJ.js`),[],import.meta.url))},{id:`cmake`,name:`CMake`,import:(()=>s(()=>import(`./cmake-Bj61d0ZC.js`),[],import.meta.url))},{id:`cobol`,name:`COBOL`,import:(()=>s(()=>import(`./cobol-AtgRrYrD.js`),[],import.meta.url))},{id:`codeowners`,name:`CODEOWNERS`,import:(()=>s(()=>import(`./codeowners-C8r90Shi.js`),[],import.meta.url))},{id:`codeql`,name:`CodeQL`,aliases:[`ql`],import:(()=>s(()=>import(`./codeql-oeQT6MSM.js`),[],import.meta.url))},{id:`coffee`,name:`CoffeeScript`,aliases:[`coffeescript`],import:(()=>s(()=>import(`./coffee-Dx9BrBX9.js`),[],import.meta.url))},{id:`common-lisp`,name:`Common Lisp`,aliases:[`lisp`],import:(()=>s(()=>import(`./common-lisp-Cv5bFMCO.js`),[],import.meta.url))},{id:`coq`,name:`Coq`,import:(()=>s(()=>import(`./coq-BrsZFFmf.js`),[],import.meta.url))},{id:`cpp`,name:`C++`,aliases:[`c++`],import:(()=>s(()=>import(`./cpp-DNQ-Fj9i.js`).then(e=>e.n),[],import.meta.url))},{id:`crystal`,name:`Crystal`,import:(()=>s(()=>import(`./crystal-BFAqiLnY.js`),[],import.meta.url))},{id:`csharp`,name:`C#`,aliases:[`c#`,`cs`],import:(()=>s(()=>import(`./csharp-oqKa8noW.js`),[],import.meta.url))},{id:`css`,name:`CSS`,import:(()=>s(()=>import(`./css-76WQuunA.js`).then(e=>e.n),[],import.meta.url))},{id:`csv`,name:`CSV`,import:(()=>s(()=>import(`./csv-Dx-8-gkx.js`),[],import.meta.url))},{id:`cue`,name:`CUE`,import:(()=>s(()=>import(`./cue-CE9AQfxI.js`),[],import.meta.url))},{id:`cypher`,name:`Cypher`,aliases:[`cql`],import:(()=>s(()=>import(`./cypher-ClKdZ_lG.js`),[],import.meta.url))},{id:`d`,name:`D`,import:(()=>s(()=>import(`./d-qD-0Kul2.js`),[],import.meta.url))},{id:`dart`,name:`Dart`,import:(()=>s(()=>import(`./dart-CnvKMtbv.js`),[],import.meta.url))},{id:`dax`,name:`DAX`,import:(()=>s(()=>import(`./dax-BkyTk9wS.js`),[],import.meta.url))},{id:`desktop`,name:`Desktop`,import:(()=>s(()=>import(`./desktop-Dlh5hvp9.js`),[],import.meta.url))},{id:`diff`,name:`Diff`,import:(()=>s(()=>import(`./diff-woXpYk--.js`),[],import.meta.url))},{id:`docker`,name:`Dockerfile`,aliases:[`dockerfile`],import:(()=>s(()=>import(`./docker-IyjqRm3v.js`),[],import.meta.url))},{id:`dotenv`,name:`dotEnv`,import:(()=>s(()=>import(`./dotenv-_5a1GRtc.js`),[],import.meta.url))},{id:`dream-maker`,name:`Dream Maker`,import:(()=>s(()=>import(`./dream-maker-DW3nJb8Q.js`),[],import.meta.url))},{id:`edge`,name:`Edge`,import:(()=>s(()=>import(`./edge-BEfBxc5h.js`),[],import.meta.url))},{id:`elixir`,name:`Elixir`,import:(()=>s(()=>import(`./elixir-Bi1LyDCo.js`),[],import.meta.url))},{id:`elm`,name:`Elm`,import:(()=>s(()=>import(`./elm-BMPZeG5i.js`),[],import.meta.url))},{id:`emacs-lisp`,name:`Emacs Lisp`,aliases:[`elisp`],import:(()=>s(()=>import(`./emacs-lisp-B4R74twV.js`),[],import.meta.url))},{id:`erb`,name:`ERB`,import:(()=>s(()=>import(`./erb-Pmcx6TTx.js`),[],import.meta.url))},{id:`erlang`,name:`Erlang`,aliases:[`erl`],import:(()=>s(()=>import(`./erlang-Cphh6RMH.js`),[],import.meta.url))},{id:`fennel`,name:`Fennel`,import:(()=>s(()=>import(`./fennel-DQxkIbk2.js`),[],import.meta.url))},{id:`fish`,name:`Fish`,import:(()=>s(()=>import(`./fish-BJitypiv.js`),[],import.meta.url))},{id:`fluent`,name:`Fluent`,aliases:[`ftl`],import:(()=>s(()=>import(`./fluent-C03EYrpw.js`),[],import.meta.url))},{id:`fortran-fixed-form`,name:`Fortran (Fixed Form)`,aliases:[`f`,`for`,`f77`],import:(()=>s(()=>import(`./fortran-fixed-form-DEKoE2YW.js`),[],import.meta.url))},{id:`fortran-free-form`,name:`Fortran (Free Form)`,aliases:[`f90`,`f95`,`f03`,`f08`,`f18`],import:(()=>s(()=>import(`./fortran-free-form-CYNrtFtB.js`),[],import.meta.url))},{id:`fsharp`,name:`F#`,aliases:[`f#`,`fs`],import:(()=>s(()=>import(`./fsharp-D13ZGOAj.js`),[],import.meta.url))},{id:`gdresource`,name:`GDResource`,aliases:[`tscn`,`tres`],import:(()=>s(()=>import(`./gdresource-C0sCabJj.js`),[],import.meta.url))},{id:`gdscript`,name:`GDScript`,aliases:[`gd`],import:(()=>s(()=>import(`./gdscript-Cp2uCuqX.js`),[],import.meta.url))},{id:`gdshader`,name:`GDShader`,import:(()=>s(()=>import(`./gdshader-CBce3t8t.js`),[],import.meta.url))},{id:`genie`,name:`Genie`,import:(()=>s(()=>import(`./genie-CV2tkWYe.js`),[],import.meta.url))},{id:`gherkin`,name:`Gherkin`,import:(()=>s(()=>import(`./gherkin-DExj1W_8.js`),[],import.meta.url))},{id:`git-commit`,name:`Git Commit Message`,import:(()=>s(()=>import(`./git-commit-BSykSTBG.js`),[],import.meta.url))},{id:`git-rebase`,name:`Git Rebase Message`,import:(()=>s(()=>import(`./git-rebase-Dj7t0bix.js`),[],import.meta.url))},{id:`gleam`,name:`Gleam`,import:(()=>s(()=>import(`./gleam-CSRkHgEL.js`),[],import.meta.url))},{id:`glimmer-js`,name:`Glimmer JS`,aliases:[`gjs`],import:(()=>s(()=>import(`./glimmer-js-DTpMHWUo.js`),[],import.meta.url))},{id:`glimmer-ts`,name:`Glimmer TS`,aliases:[`gts`],import:(()=>s(()=>import(`./glimmer-ts-BKOVQU61.js`),[],import.meta.url))},{id:`glsl`,name:`GLSL`,import:(()=>s(()=>import(`./glsl-DDNdYp2B.js`).then(e=>e.n),[],import.meta.url))},{id:`gn`,name:`GN`,import:(()=>s(()=>import(`./gn-ilITqXS6.js`),[],import.meta.url))},{id:`gnuplot`,name:`Gnuplot`,import:(()=>s(()=>import(`./gnuplot-7GGW24-e.js`),[],import.meta.url))},{id:`go`,name:`Go`,import:(()=>s(()=>import(`./go-rLFTqkRN.js`),[],import.meta.url))},{id:`graphql`,name:`GraphQL`,aliases:[`gql`],import:(()=>s(()=>import(`./graphql-C-akFyqE.js`).then(e=>e.n),[],import.meta.url))},{id:`groovy`,name:`Groovy`,import:(()=>s(()=>import(`./groovy-CacY0gHj.js`),[],import.meta.url))},{id:`hack`,name:`Hack`,import:(()=>s(()=>import(`./hack-Z382E4IB.js`),[],import.meta.url))},{id:`haml`,name:`Ruby Haml`,import:(()=>s(()=>import(`./haml-DCWQJgln.js`).then(e=>e.n),[],import.meta.url))},{id:`handlebars`,name:`Handlebars`,aliases:[`hbs`],import:(()=>s(()=>import(`./handlebars-D_RRtkV5.js`),[],import.meta.url))},{id:`haskell`,name:`Haskell`,aliases:[`hs`],import:(()=>s(()=>import(`./haskell-D8IpX4py.js`),[],import.meta.url))},{id:`haxe`,name:`Haxe`,import:(()=>s(()=>import(`./haxe-OTjmBuCE.js`),[],import.meta.url))},{id:`hcl`,name:`HashiCorp HCL`,import:(()=>s(()=>import(`./hcl-Dh228itO.js`),[],import.meta.url))},{id:`hjson`,name:`Hjson`,import:(()=>s(()=>import(`./hjson-CxZEssPk.js`),[],import.meta.url))},{id:`hlsl`,name:`HLSL`,import:(()=>s(()=>import(`./hlsl-Cvrh5tZx.js`),[],import.meta.url))},{id:`html`,name:`HTML`,import:(()=>s(()=>import(`./html-BqDo3pKb.js`).then(e=>e.n),[],import.meta.url))},{id:`html-derivative`,name:`HTML (Derivative)`,import:(()=>s(()=>import(`./html-derivative-DncxUXSH.js`),[],import.meta.url))},{id:`http`,name:`HTTP`,import:(()=>s(()=>import(`./http-CrTHj6_t.js`),[],import.meta.url))},{id:`hurl`,name:`Hurl`,import:(()=>s(()=>import(`./hurl-BdeVL_ga.js`),[],import.meta.url))},{id:`hxml`,name:`HXML`,import:(()=>s(()=>import(`./hxml-B0Qn7Nwc.js`),[],import.meta.url))},{id:`hy`,name:`Hy`,import:(()=>s(()=>import(`./hy-CZbG8q4J.js`),[],import.meta.url))},{id:`imba`,name:`Imba`,import:(()=>s(()=>import(`./imba-DsUTQ-LC.js`),[],import.meta.url))},{id:`ini`,name:`INI`,aliases:[`properties`],import:(()=>s(()=>import(`./ini-B5eOa1yu.js`),[],import.meta.url))},{id:`java`,name:`Java`,import:(()=>s(()=>import(`./java-DKFHmTAg.js`).then(e=>e.n),[],import.meta.url))},{id:`javascript`,name:`JavaScript`,aliases:[`js`,`cjs`,`mjs`],import:(()=>s(()=>import(`./javascript-Jx16aUBb.js`).then(e=>e.n),[],import.meta.url))},{id:`jinja`,name:`Jinja`,import:(()=>s(()=>import(`./jinja-CQEVrK23.js`),[],import.meta.url))},{id:`jison`,name:`Jison`,import:(()=>s(()=>import(`./jison-BJRgvE0A.js`),[],import.meta.url))},{id:`json`,name:`JSON`,import:(()=>s(()=>import(`./json-DlFP2GYa.js`).then(e=>e.n),[],import.meta.url))},{id:`json5`,name:`JSON5`,import:(()=>s(()=>import(`./json5-BR5RXkoi.js`),[],import.meta.url))},{id:`jsonc`,name:`JSON with Comments`,import:(()=>s(()=>import(`./jsonc-CYpm1nAK.js`),[],import.meta.url))},{id:`jsonl`,name:`JSON Lines`,import:(()=>s(()=>import(`./jsonl-CmCQp5Yx.js`),[],import.meta.url))},{id:`jsonnet`,name:`Jsonnet`,import:(()=>s(()=>import(`./jsonnet-CJTPZ8u_.js`),[],import.meta.url))},{id:`jssm`,name:`JSSM`,aliases:[`fsl`],import:(()=>s(()=>import(`./jssm-DXw9l8Rf.js`),[],import.meta.url))},{id:`jsx`,name:`JSX`,import:(()=>s(()=>import(`./jsx-CIwpwN-u.js`).then(e=>e.n),[],import.meta.url))},{id:`julia`,name:`Julia`,aliases:[`jl`],import:(()=>s(()=>import(`./julia-D4zLZb0D.js`),[],import.meta.url))},{id:`just`,name:`Just`,import:(()=>s(()=>import(`./just-BbmgE3ZP.js`),[],import.meta.url))},{id:`kdl`,name:`KDL`,import:(()=>s(()=>import(`./kdl-CsD5j6eV.js`),[],import.meta.url))},{id:`kotlin`,name:`Kotlin`,aliases:[`kt`,`kts`],import:(()=>s(()=>import(`./kotlin-DhhofPvG.js`),[],import.meta.url))},{id:`kusto`,name:`Kusto`,aliases:[`kql`],import:(()=>s(()=>import(`./kusto-C7mF5XQf.js`),[],import.meta.url))},{id:`latex`,name:`LaTeX`,import:(()=>s(()=>import(`./latex-BUDs7Dcl.js`),[],import.meta.url))},{id:`lean`,name:`Lean 4`,aliases:[`lean4`],import:(()=>s(()=>import(`./lean-CewbzKMR.js`),[],import.meta.url))},{id:`less`,name:`Less`,import:(()=>s(()=>import(`./less-DVTAwKKz.js`),[],import.meta.url))},{id:`liquid`,name:`Liquid`,import:(()=>s(()=>import(`./liquid-Bc0s0G9S.js`),[],import.meta.url))},{id:`llvm`,name:`LLVM IR`,import:(()=>s(()=>import(`./llvm-Cm23YOpf.js`),[],import.meta.url))},{id:`log`,name:`Log file`,import:(()=>s(()=>import(`./log-BNLmms1o.js`),[],import.meta.url))},{id:`logo`,name:`Logo`,import:(()=>s(()=>import(`./logo-Cluzi2Zq.js`),[],import.meta.url))},{id:`lua`,name:`Lua`,import:(()=>s(()=>import(`./lua-dQaszIi_.js`).then(e=>e.n),[],import.meta.url))},{id:`luau`,name:`Luau`,import:(()=>s(()=>import(`./luau-FMPmPwt6.js`),[],import.meta.url))},{id:`make`,name:`Makefile`,aliases:[`makefile`],import:(()=>s(()=>import(`./make-Dixweg8N.js`),[],import.meta.url))},{id:`markdown`,name:`Markdown`,aliases:[`md`],import:(()=>s(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url))},{id:`marko`,name:`Marko`,import:(()=>s(()=>import(`./marko-B5Uea28G.js`),[],import.meta.url))},{id:`matlab`,name:`MATLAB`,import:(()=>s(()=>import(`./matlab-D7qyCx1q.js`),[],import.meta.url))},{id:`mdc`,name:`MDC`,import:(()=>s(()=>import(`./mdc-CwQcy7BI.js`),[],import.meta.url))},{id:`mdx`,name:`MDX`,import:(()=>s(()=>import(`./mdx-DQZ5AkYe.js`),[],import.meta.url))},{id:`mermaid`,name:`Mermaid`,aliases:[`mmd`],import:(()=>s(()=>import(`./mermaid-Bk4SNUv9.js`),[],import.meta.url))},{id:`mipsasm`,name:`MIPS Assembly`,aliases:[`mips`],import:(()=>s(()=>import(`./mipsasm-BMqwQI7S.js`),[],import.meta.url))},{id:`mojo`,name:`Mojo`,import:(()=>s(()=>import(`./mojo-BgCJLMeH.js`),[],import.meta.url))},{id:`moonbit`,name:`MoonBit`,aliases:[`mbt`,`mbti`],import:(()=>s(()=>import(`./moonbit-CaWjb8XO.js`),[],import.meta.url))},{id:`move`,name:`Move`,import:(()=>s(()=>import(`./move-B1IS1UjX.js`),[],import.meta.url))},{id:`narrat`,name:`Narrat Language`,aliases:[`nar`],import:(()=>s(()=>import(`./narrat-_X_XdTYD.js`),[],import.meta.url))},{id:`nextflow`,name:`Nextflow`,aliases:[`nf`],import:(()=>s(()=>import(`./nextflow-BJtWHP5T.js`),[],import.meta.url))},{id:`nextflow-groovy`,name:`Nextflow Groovy`,import:(()=>s(()=>import(`./nextflow-groovy-DJMQeKeT.js`),[],import.meta.url))},{id:`nginx`,name:`Nginx`,import:(()=>s(()=>import(`./nginx-SzmDaWuK.js`),[],import.meta.url))},{id:`nim`,name:`Nim`,import:(()=>s(()=>import(`./nim-CO_A6I25.js`),[],import.meta.url))},{id:`nix`,name:`Nix`,import:(()=>s(()=>import(`./nix-IvuFDN5E.js`),[],import.meta.url))},{id:`nushell`,name:`nushell`,aliases:[`nu`],import:(()=>s(()=>import(`./nushell-DcLAeLz5.js`),[],import.meta.url))},{id:`objective-c`,name:`Objective-C`,aliases:[`objc`],import:(()=>s(()=>import(`./objective-c-D1A_Heim.js`),[],import.meta.url))},{id:`objective-cpp`,name:`Objective-C++`,import:(()=>s(()=>import(`./objective-cpp-BsSzOQcm.js`),[],import.meta.url))},{id:`ocaml`,name:`OCaml`,import:(()=>s(()=>import(`./ocaml-O90oeIOV.js`),[],import.meta.url))},{id:`odin`,name:`Odin`,import:(()=>s(()=>import(`./odin-B1RWQWA5.js`),[],import.meta.url))},{id:`openscad`,name:`OpenSCAD`,aliases:[`scad`],import:(()=>s(()=>import(`./openscad-BUDT5pXO.js`),[],import.meta.url))},{id:`pascal`,name:`Pascal`,import:(()=>s(()=>import(`./pascal-4ZHwLPI5.js`),[],import.meta.url))},{id:`perl`,name:`Perl`,import:(()=>s(()=>import(`./perl-DXgLsVg8.js`),[],import.meta.url))},{id:`php`,name:`PHP`,import:(()=>s(()=>import(`./php-C4KCWpl8.js`),[],import.meta.url))},{id:`pkl`,name:`Pkl`,import:(()=>s(()=>import(`./pkl-ot-7Btpt.js`),[],import.meta.url))},{id:`plsql`,name:`PL/SQL`,import:(()=>s(()=>import(`./plsql-DGHpHOYJ.js`),[],import.meta.url))},{id:`po`,name:`Gettext PO`,aliases:[`pot`,`potx`],import:(()=>s(()=>import(`./po-BiJDBrnU.js`),[],import.meta.url))},{id:`polar`,name:`Polar`,import:(()=>s(()=>import(`./polar-C7UOKdEL.js`),[],import.meta.url))},{id:`postcss`,name:`PostCSS`,import:(()=>s(()=>import(`./postcss-BXeXVLqQ.js`),[],import.meta.url))},{id:`powerquery`,name:`PowerQuery`,import:(()=>s(()=>import(`./powerquery-DNMTfnFr.js`),[],import.meta.url))},{id:`powershell`,name:`PowerShell`,aliases:[`ps`,`ps1`],import:(()=>s(()=>import(`./powershell-DshXNtvi.js`),[],import.meta.url))},{id:`prisma`,name:`Prisma`,import:(()=>s(()=>import(`./prisma-BsRQq5mF.js`),[],import.meta.url))},{id:`prolog`,name:`Prolog`,import:(()=>s(()=>import(`./prolog-iXnhIJG7.js`),[],import.meta.url))},{id:`proto`,name:`Protocol Buffer 3`,aliases:[`protobuf`],import:(()=>s(()=>import(`./proto-DB4EqR-F.js`),[],import.meta.url))},{id:`pug`,name:`Pug`,aliases:[`jade`],import:(()=>s(()=>import(`./pug-bpEG1CVZ.js`),[],import.meta.url))},{id:`puppet`,name:`Puppet`,import:(()=>s(()=>import(`./puppet-CDv2pdJW.js`),[],import.meta.url))},{id:`purescript`,name:`PureScript`,import:(()=>s(()=>import(`./purescript-9MfHhQsQ.js`),[],import.meta.url))},{id:`python`,name:`Python`,aliases:[`py`],import:(()=>s(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url))},{id:`qml`,name:`QML`,import:(()=>s(()=>import(`./qml-DGJzHzg9.js`),[],import.meta.url))},{id:`qmldir`,name:`QML Directory`,import:(()=>s(()=>import(`./qmldir-DCQb3MpD.js`),[],import.meta.url))},{id:`qss`,name:`Qt Style Sheets`,import:(()=>s(()=>import(`./qss-Fe1Jh2GI.js`),[],import.meta.url))},{id:`r`,name:`R`,import:(()=>s(()=>import(`./r-CZt9UGEb.js`).then(e=>e.n),[],import.meta.url))},{id:`racket`,name:`Racket`,import:(()=>s(()=>import(`./racket-DcIDlBhZ.js`),[],import.meta.url))},{id:`raku`,name:`Raku`,aliases:[`perl6`],import:(()=>s(()=>import(`./raku-B3gFvitq.js`),[],import.meta.url))},{id:`razor`,name:`ASP.NET Razor`,import:(()=>s(()=>import(`./razor-mTLK-dma.js`),[],import.meta.url))},{id:`reg`,name:`Windows Registry Script`,import:(()=>s(()=>import(`./reg-CRGYupPL.js`),[],import.meta.url))},{id:`regexp`,name:`RegExp`,aliases:[`regex`],import:(()=>s(()=>import(`./regexp-DX5QhPdx.js`).then(e=>e.n),[],import.meta.url))},{id:`rel`,name:`Rel`,import:(()=>s(()=>import(`./rel-BtDbiS_P.js`),[],import.meta.url))},{id:`riscv`,name:`RISC-V`,import:(()=>s(()=>import(`./riscv-Ckw8ddFX.js`),[],import.meta.url))},{id:`ron`,name:`RON`,import:(()=>s(()=>import(`./ron-VUp2lXgN.js`),[],import.meta.url))},{id:`rosmsg`,name:`ROS Interface`,import:(()=>s(()=>import(`./rosmsg-CAekHB0j.js`),[],import.meta.url))},{id:`rst`,name:`reStructuredText`,import:(()=>s(()=>import(`./rst-t-F-oATV.js`),[],import.meta.url))},{id:`ruby`,name:`Ruby`,aliases:[`rb`],import:(()=>s(()=>import(`./ruby-D9DDGNv3.js`),[],import.meta.url))},{id:`rust`,name:`Rust`,aliases:[`rs`],import:(()=>s(()=>import(`./rust-Cfkwpbl8.js`),[],import.meta.url))},{id:`sas`,name:`SAS`,import:(()=>s(()=>import(`./sas-BAEs8TsV.js`),[],import.meta.url))},{id:`sass`,name:`Sass`,import:(()=>s(()=>import(`./sass-DXrisJhu.js`),[],import.meta.url))},{id:`scala`,name:`Scala`,import:(()=>s(()=>import(`./scala-DKOlJaKm.js`),[],import.meta.url))},{id:`scheme`,name:`Scheme`,import:(()=>s(()=>import(`./scheme-DQCgrYNe.js`),[],import.meta.url))},{id:`scss`,name:`SCSS`,import:(()=>s(()=>import(`./scss-B6B5DSWC.js`).then(e=>e.n),[],import.meta.url))},{id:`sdbl`,name:`1C (Query)`,aliases:[`1c-query`],import:(()=>s(()=>import(`./sdbl-bTVj8UrX.js`),[],import.meta.url))},{id:`shaderlab`,name:`ShaderLab`,aliases:[`shader`],import:(()=>s(()=>import(`./shaderlab-TOUzSsQk.js`),[],import.meta.url))},{id:`shellscript`,name:`Shell`,aliases:[`bash`,`sh`,`shell`,`zsh`],import:(()=>s(()=>import(`./shellscript-DXt7nqYk.js`).then(e=>e.n),[],import.meta.url))},{id:`shellsession`,name:`Shell Session`,aliases:[`console`],import:(()=>s(()=>import(`./shellsession-DQ4guRhR.js`),[],import.meta.url))},{id:`smalltalk`,name:`Smalltalk`,import:(()=>s(()=>import(`./smalltalk-B16xEiuN.js`),[],import.meta.url))},{id:`solidity`,name:`Solidity`,import:(()=>s(()=>import(`./solidity-CKzVLygQ.js`),[],import.meta.url))},{id:`soy`,name:`Closure Templates`,aliases:[`closure-templates`],import:(()=>s(()=>import(`./soy-DtwGS8Y2.js`),[],import.meta.url))},{id:`sparql`,name:`SPARQL`,import:(()=>s(()=>import(`./sparql-D_iOobhT.js`),[],import.meta.url))},{id:`splunk`,name:`Splunk Query Language`,aliases:[`spl`],import:(()=>s(()=>import(`./splunk-BC2Px7Mm.js`),[],import.meta.url))},{id:`sql`,name:`SQL`,import:(()=>s(()=>import(`./sql-ArzG0FT1.js`).then(e=>e.n),[],import.meta.url))},{id:`ssh-config`,name:`SSH Config`,import:(()=>s(()=>import(`./ssh-config-BgfXC-Er.js`),[],import.meta.url))},{id:`stata`,name:`Stata`,import:(()=>s(()=>import(`./stata-CdQ318yb.js`),[],import.meta.url))},{id:`stylus`,name:`Stylus`,aliases:[`styl`],import:(()=>s(()=>import(`./stylus-B6D30XZt.js`),[],import.meta.url))},{id:`surrealql`,name:`SurrealQL`,aliases:[`surql`],import:(()=>s(()=>import(`./surrealql-RyXJ8VfM.js`),[],import.meta.url))},{id:`svelte`,name:`Svelte`,import:(()=>s(()=>import(`./svelte-CXkGIk7i.js`),[],import.meta.url))},{id:`swift`,name:`Swift`,import:(()=>s(()=>import(`./swift-DonLKvLd.js`),[],import.meta.url))},{id:`system-verilog`,name:`SystemVerilog`,import:(()=>s(()=>import(`./system-verilog-DJ5XKQeo.js`),[],import.meta.url))},{id:`systemd`,name:`Systemd Units`,import:(()=>s(()=>import(`./systemd-BxMlprV5.js`),[],import.meta.url))},{id:`talonscript`,name:`TalonScript`,aliases:[`talon`],import:(()=>s(()=>import(`./talonscript-CohzipZa.js`),[],import.meta.url))},{id:`tasl`,name:`Tasl`,import:(()=>s(()=>import(`./tasl-DMoTqEGO.js`),[],import.meta.url))},{id:`tcl`,name:`Tcl`,import:(()=>s(()=>import(`./tcl-CZd0xW_V.js`),[],import.meta.url))},{id:`templ`,name:`Templ`,import:(()=>s(()=>import(`./templ-CJz86NIj.js`),[],import.meta.url))},{id:`terraform`,name:`Terraform`,aliases:[`tf`,`tfvars`],import:(()=>s(()=>import(`./terraform-DswuEJGm.js`),[],import.meta.url))},{id:`tex`,name:`TeX`,import:(()=>s(()=>import(`./tex-C71esTKh.js`),[],import.meta.url))},{id:`toml`,name:`TOML`,import:(()=>s(()=>import(`./toml-CcmNWLt0.js`),[],import.meta.url))},{id:`ts-tags`,name:`TypeScript with Tags`,aliases:[`lit`],import:(()=>s(()=>import(`./ts-tags-Qszjvpax.js`),[],import.meta.url))},{id:`tsv`,name:`TSV`,import:(()=>s(()=>import(`./tsv-sltzmVWM.js`),[],import.meta.url))},{id:`tsx`,name:`TSX`,import:(()=>s(()=>import(`./tsx-BEhriTf8.js`).then(e=>e.n),[],import.meta.url))},{id:`turtle`,name:`Turtle`,import:(()=>s(()=>import(`./turtle-ByJddavk.js`),[],import.meta.url))},{id:`twig`,name:`Twig`,import:(()=>s(()=>import(`./twig-CbaWuFm3.js`),[],import.meta.url))},{id:`typescript`,name:`TypeScript`,aliases:[`ts`,`cts`,`mts`],import:(()=>s(()=>import(`./typescript-CBu4i5lG.js`).then(e=>e.n),[],import.meta.url))},{id:`typespec`,name:`TypeSpec`,aliases:[`tsp`],import:(()=>s(()=>import(`./typespec-BRdr0IET.js`),[],import.meta.url))},{id:`typst`,name:`Typst`,aliases:[`typ`],import:(()=>s(()=>import(`./typst-DI99ib-x.js`),[],import.meta.url))},{id:`v`,name:`V`,import:(()=>s(()=>import(`./v-DETTlOr0.js`),[],import.meta.url))},{id:`vala`,name:`Vala`,import:(()=>s(()=>import(`./vala-zf12oZj6.js`),[],import.meta.url))},{id:`vb`,name:`Visual Basic`,aliases:[`cmd`],import:(()=>s(()=>import(`./vb-Djn5o6TS.js`),[],import.meta.url))},{id:`verilog`,name:`Verilog`,import:(()=>s(()=>import(`./verilog-CiiDBU1e.js`),[],import.meta.url))},{id:`vhdl`,name:`VHDL`,import:(()=>s(()=>import(`./vhdl-BroJfC0k.js`),[],import.meta.url))},{id:`viml`,name:`Vim Script`,aliases:[`vim`,`vimscript`],import:(()=>s(()=>import(`./viml-DvXPmvsu.js`),[],import.meta.url))},{id:`vue`,name:`Vue`,import:(()=>s(()=>import(`./vue-Bruwzb-A.js`),[],import.meta.url))},{id:`vue-html`,name:`Vue HTML`,import:(()=>s(()=>import(`./vue-html-C-3Ma2tD.js`),[],import.meta.url))},{id:`vue-vine`,name:`Vue Vine`,import:(()=>s(()=>import(`./vue-vine-DQAt9DTg.js`),[],import.meta.url))},{id:`vyper`,name:`Vyper`,aliases:[`vy`],import:(()=>s(()=>import(`./vyper-CgoNMtux.js`),[],import.meta.url))},{id:`wasm`,name:`WebAssembly`,import:(()=>s(()=>import(`./wasm-ByWQv1Qj.js`),[],import.meta.url))},{id:`wenyan`,name:`Wenyan`,aliases:[`文言`],import:(()=>s(()=>import(`./wenyan-C8pVoKbM.js`),[],import.meta.url))},{id:`wgsl`,name:`WGSL`,import:(()=>s(()=>import(`./wgsl-BsKzXJz4.js`),[],import.meta.url))},{id:`wikitext`,name:`Wikitext`,aliases:[`mediawiki`,`wiki`],import:(()=>s(()=>import(`./wikitext-ClFFjSW2.js`),[],import.meta.url))},{id:`wit`,name:`WebAssembly Interface Types`,import:(()=>s(()=>import(`./wit-DdvCle-K.js`),[],import.meta.url))},{id:`wolfram`,name:`Wolfram`,aliases:[`wl`],import:(()=>s(()=>import(`./wolfram-DLL8P-h_.js`),[],import.meta.url))},{id:`xml`,name:`XML`,import:(()=>s(()=>import(`./xml-BS2GSQw_.js`).then(e=>e.n),[],import.meta.url))},{id:`xsl`,name:`XSL`,import:(()=>s(()=>import(`./xsl-CCmfIdf4.js`),[],import.meta.url))},{id:`yaml`,name:`YAML`,aliases:[`yml`],import:(()=>s(()=>import(`./yaml-C1LY7x4K.js`).then(e=>e.n),[],import.meta.url))},{id:`zenscript`,name:`ZenScript`,import:(()=>s(()=>import(`./zenscript-BnlCZFoB.js`),[],import.meta.url))},{id:`zig`,name:`Zig`,import:(()=>s(()=>import(`./zig-CMLA9XwU.js`),[],import.meta.url))}],fp=Object.fromEntries(dp.map(e=>[e.id,e.import])),pp=Object.fromEntries(dp.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),mp={...fp,...pp},hp=Object.fromEntries([{id:`andromeeda`,displayName:`Andromeeda`,type:`dark`,import:(()=>s(()=>import(`./andromeeda-vGVdxbeo.js`),[],import.meta.url))},{id:`aurora-x`,displayName:`Aurora X`,type:`dark`,import:(()=>s(()=>import(`./aurora-x-CDeNXAV0.js`),[],import.meta.url))},{id:`ayu-dark`,displayName:`Ayu Dark`,type:`dark`,import:(()=>s(()=>import(`./ayu-dark-DluEY0Gj.js`),[],import.meta.url))},{id:`ayu-light`,displayName:`Ayu Light`,type:`light`,import:(()=>s(()=>import(`./ayu-light-C3h-C4tm.js`),[],import.meta.url))},{id:`ayu-mirage`,displayName:`Ayu Mirage`,type:`dark`,import:(()=>s(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[],import.meta.url))},{id:`catppuccin-frappe`,displayName:`Catppuccin Frappé`,type:`dark`,import:(()=>s(()=>import(`./catppuccin-frappe-3VR1Za6u.js`),[],import.meta.url))},{id:`catppuccin-latte`,displayName:`Catppuccin Latte`,type:`light`,import:(()=>s(()=>import(`./catppuccin-latte-DwIHMF0Q.js`),[],import.meta.url))},{id:`catppuccin-macchiato`,displayName:`Catppuccin Macchiato`,type:`dark`,import:(()=>s(()=>import(`./catppuccin-macchiato-DYnBP6_5.js`),[],import.meta.url))},{id:`catppuccin-mocha`,displayName:`Catppuccin Mocha`,type:`dark`,import:(()=>s(()=>import(`./catppuccin-mocha-DYhrFGRu.js`),[],import.meta.url))},{id:`dark-plus`,displayName:`Dark Plus`,type:`dark`,import:(()=>s(()=>import(`./dark-plus-Cs2F2srj.js`),[],import.meta.url))},{id:`dracula`,displayName:`Dracula Theme`,type:`dark`,import:(()=>s(()=>import(`./dracula-BHWKrbxM.js`),[],import.meta.url))},{id:`dracula-soft`,displayName:`Dracula Theme Soft`,type:`dark`,import:(()=>s(()=>import(`./dracula-soft-5eyTD99u.js`),[],import.meta.url))},{id:`everforest-dark`,displayName:`Everforest Dark`,type:`dark`,import:(()=>s(()=>import(`./everforest-dark-sB-x3p7T.js`),[],import.meta.url))},{id:`everforest-light`,displayName:`Everforest Light`,type:`light`,import:(()=>s(()=>import(`./everforest-light-Df2xbC6M.js`),[],import.meta.url))},{id:`github-dark`,displayName:`GitHub Dark`,type:`dark`,import:(()=>s(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url))},{id:`github-dark-default`,displayName:`GitHub Dark Default`,type:`dark`,import:(()=>s(()=>import(`./github-dark-default-DXG-b-1a.js`),[],import.meta.url))},{id:`github-dark-dimmed`,displayName:`GitHub Dark Dimmed`,type:`dark`,import:(()=>s(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[],import.meta.url))},{id:`github-dark-high-contrast`,displayName:`GitHub Dark High Contrast`,type:`dark`,import:(()=>s(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[],import.meta.url))},{id:`github-light`,displayName:`GitHub Light`,type:`light`,import:(()=>s(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url))},{id:`github-light-default`,displayName:`GitHub Light Default`,type:`light`,import:(()=>s(()=>import(`./github-light-default-BXViO-2h.js`),[],import.meta.url))},{id:`github-light-high-contrast`,displayName:`GitHub Light High Contrast`,type:`light`,import:(()=>s(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[],import.meta.url))},{id:`gruvbox-dark-hard`,displayName:`Gruvbox Dark Hard`,type:`dark`,import:(()=>s(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[],import.meta.url))},{id:`gruvbox-dark-medium`,displayName:`Gruvbox Dark Medium`,type:`dark`,import:(()=>s(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[],import.meta.url))},{id:`gruvbox-dark-soft`,displayName:`Gruvbox Dark Soft`,type:`dark`,import:(()=>s(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[],import.meta.url))},{id:`gruvbox-light-hard`,displayName:`Gruvbox Light Hard`,type:`light`,import:(()=>s(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[],import.meta.url))},{id:`gruvbox-light-medium`,displayName:`Gruvbox Light Medium`,type:`light`,import:(()=>s(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[],import.meta.url))},{id:`gruvbox-light-soft`,displayName:`Gruvbox Light Soft`,type:`light`,import:(()=>s(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[],import.meta.url))},{id:`horizon`,displayName:`Horizon`,type:`dark`,import:(()=>s(()=>import(`./horizon-CE9ld1lL.js`),[],import.meta.url))},{id:`horizon-bright`,displayName:`Horizon Bright`,type:`light`,import:(()=>s(()=>import(`./horizon-bright-DSNQnXHK.js`),[],import.meta.url))},{id:`houston`,displayName:`Houston`,type:`dark`,import:(()=>s(()=>import(`./houston-CsvMBhTu.js`),[],import.meta.url))},{id:`kanagawa-dragon`,displayName:`Kanagawa Dragon`,type:`dark`,import:(()=>s(()=>import(`./kanagawa-dragon-CXtmUGW6.js`),[],import.meta.url))},{id:`kanagawa-lotus`,displayName:`Kanagawa Lotus`,type:`light`,import:(()=>s(()=>import(`./kanagawa-lotus-BN08jTvb.js`),[],import.meta.url))},{id:`kanagawa-wave`,displayName:`Kanagawa Wave`,type:`dark`,import:(()=>s(()=>import(`./kanagawa-wave-CTweb8Dz.js`),[],import.meta.url))},{id:`laserwave`,displayName:`LaserWave`,type:`dark`,import:(()=>s(()=>import(`./laserwave-C_8bwKvT.js`),[],import.meta.url))},{id:`light-plus`,displayName:`Light Plus`,type:`light`,import:(()=>s(()=>import(`./light-plus-DVQuIRkW.js`),[],import.meta.url))},{id:`material-theme`,displayName:`Material Theme`,type:`dark`,import:(()=>s(()=>import(`./material-theme-Bm3Qr25_.js`),[],import.meta.url))},{id:`material-theme-darker`,displayName:`Material Theme Darker`,type:`dark`,import:(()=>s(()=>import(`./material-theme-darker-2IIEA8gg.js`),[],import.meta.url))},{id:`material-theme-lighter`,displayName:`Material Theme Lighter`,type:`light`,import:(()=>s(()=>import(`./material-theme-lighter-uhdI0v04.js`),[],import.meta.url))},{id:`material-theme-ocean`,displayName:`Material Theme Ocean`,type:`dark`,import:(()=>s(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[],import.meta.url))},{id:`material-theme-palenight`,displayName:`Material Theme Palenight`,type:`dark`,import:(()=>s(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[],import.meta.url))},{id:`min-dark`,displayName:`Min Dark`,type:`dark`,import:(()=>s(()=>import(`./min-dark-BSWPekZh.js`),[],import.meta.url))},{id:`min-light`,displayName:`Min Light`,type:`light`,import:(()=>s(()=>import(`./min-light-DDpmG2fV.js`),[],import.meta.url))},{id:`monokai`,displayName:`Monokai`,type:`dark`,import:(()=>s(()=>import(`./monokai-CdkpiU2Y.js`),[],import.meta.url))},{id:`night-owl`,displayName:`Night Owl`,type:`dark`,import:(()=>s(()=>import(`./night-owl-DhmEMT88.js`),[],import.meta.url))},{id:`night-owl-light`,displayName:`Night Owl Light`,type:`light`,import:(()=>s(()=>import(`./night-owl-light-eJ-hLW7d.js`),[],import.meta.url))},{id:`nord`,displayName:`Nord`,type:`dark`,import:(()=>s(()=>import(`./nord-Cb4Vim4T.js`),[],import.meta.url))},{id:`one-dark-pro`,displayName:`One Dark Pro`,type:`dark`,import:(()=>s(()=>import(`./one-dark-pro-CLwyXe_n.js`),[],import.meta.url))},{id:`one-light`,displayName:`One Light`,type:`light`,import:(()=>s(()=>import(`./one-light-D7Lr4KcI.js`),[],import.meta.url))},{id:`plastic`,displayName:`Plastic`,type:`dark`,import:(()=>s(()=>import(`./plastic-DQwYfKfQ.js`),[],import.meta.url))},{id:`poimandres`,displayName:`Poimandres`,type:`dark`,import:(()=>s(()=>import(`./poimandres-DRFjx7u4.js`),[],import.meta.url))},{id:`red`,displayName:`Red`,type:`dark`,import:(()=>s(()=>import(`./red-CJ3rzSJv.js`),[],import.meta.url))},{id:`rose-pine`,displayName:`Rosé Pine`,type:`dark`,import:(()=>s(()=>import(`./rose-pine-BthvhNj6.js`),[],import.meta.url))},{id:`rose-pine-dawn`,displayName:`Rosé Pine Dawn`,type:`light`,import:(()=>s(()=>import(`./rose-pine-dawn-Dg85fqjY.js`),[],import.meta.url))},{id:`rose-pine-moon`,displayName:`Rosé Pine Moon`,type:`dark`,import:(()=>s(()=>import(`./rose-pine-moon-hon4tzzS.js`),[],import.meta.url))},{id:`slack-dark`,displayName:`Slack Dark`,type:`dark`,import:(()=>s(()=>import(`./slack-dark-DnToyrRv.js`),[],import.meta.url))},{id:`slack-ochin`,displayName:`Slack Ochin`,type:`light`,import:(()=>s(()=>import(`./slack-ochin-B2OO5cIa.js`),[],import.meta.url))},{id:`snazzy-light`,displayName:`Snazzy Light`,type:`light`,import:(()=>s(()=>import(`./snazzy-light-4G7pJPwS.js`),[],import.meta.url))},{id:`solarized-dark`,displayName:`Solarized Dark`,type:`dark`,import:(()=>s(()=>import(`./solarized-dark-DV17i1UV.js`),[],import.meta.url))},{id:`solarized-light`,displayName:`Solarized Light`,type:`light`,import:(()=>s(()=>import(`./solarized-light-DSh2HLQt.js`),[],import.meta.url))},{id:`synthwave-84`,displayName:`Synthwave '84`,type:`dark`,import:(()=>s(()=>import(`./synthwave-84-nFMaYfgc.js`),[],import.meta.url))},{id:`tokyo-night`,displayName:`Tokyo Night`,type:`dark`,import:(()=>s(()=>import(`./tokyo-night-oM2G3aXe.js`),[],import.meta.url))},{id:`vesper`,displayName:`Vesper`,type:`dark`,import:(()=>s(()=>import(`./vesper-DdrHHSXu.js`),[],import.meta.url))},{id:`vitesse-black`,displayName:`Vitesse Black`,type:`dark`,import:(()=>s(()=>import(`./vitesse-black-fwtXNY1n.js`),[],import.meta.url))},{id:`vitesse-dark`,displayName:`Vitesse Dark`,type:`dark`,import:(()=>s(()=>import(`./vitesse-dark-BZCL-v6S.js`),[],import.meta.url))},{id:`vitesse-light`,displayName:`Vitesse Light`,type:`light`,import:(()=>s(()=>import(`./vitesse-light-VbXTXTou.js`),[],import.meta.url))}].map(e=>[e.id,e.import])),gp=r({createOnigurumaEngine:()=>Hp,getDefaultWasmLoader:()=>Vp,loadWasm:()=>Fp,setDefaultWasmLoader:()=>Bp}),_p=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function vp(){return 2147483648}function yp(){return typeof performance<`u`?performance.now():Date.now()}var bp=(e,t)=>e+(t-e%t)%t;async function xp(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=vp();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,bp(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:yp,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var Sp=Object.defineProperty,Cp=(e,t,n)=>t in e?Sp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,H=(e,t,n)=>Cp(e,typeof t==`symbol`?t:t+``,n),U=null;function wp(e){throw new _p(e.UTF8ToString(e.getLastOnigError()))}var Tp=class e{constructor(t){H(this,`utf16Length`),H(this,`utf8Length`),H(this,`utf16Value`),H(this,`utf8Value`),H(this,`utf16OffsetToUtf8`),H(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}a<=127?t+=1:a<=2047?t+=2:a<=65535?t+=3:t+=4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},Ep=class e{constructor(t){if(H(this,`id`,++e.LAST_ID),H(this,`_onigBinding`),H(this,`content`),H(this,`utf16Length`),H(this,`utf8Length`),H(this,`utf16OffsetToUtf8`),H(this,`utf8OffsetToUtf16`),H(this,`ptr`),!U)throw new _p(`Must invoke loadWasm first.`);this._onigBinding=U,this.content=t;let n=new Tp(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=U.omalloc(1e4),e._sharedPtrInUse=!0,U.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString(U)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};H(Ep,`LAST_ID`,0),H(Ep,`_sharedPtr`,0),H(Ep,`_sharedPtrInUse`,!1);var Dp=Ep,Op=class{constructor(e){if(H(this,`_onigBinding`),H(this,`_ptr`),!U)throw new _p(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new Tp(e[r]);t[r]=i.createString(U),n[r]=i.utf8Length}let r=U.omalloc(4*e.length);U.HEAPU32.set(t,r/4);let i=U.omalloc(4*e.length);U.HEAPU32.set(n,i/4);let a=U.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)U.ofree(t[n]);U.ofree(i),U.ofree(r),a===0&&wp(U),this._onigBinding=U,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new Dp(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function kp(e){return typeof e.instantiator==`function`}function Ap(e){return typeof e.default==`function`}function jp(e){return e.data!==void 0}function Mp(e){return typeof Response<`u`&&e instanceof Response}function Np(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var Pp;function Fp(e){if(Pp)return Pp;async function t(){U=await xp(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),kp(n)?n=await n.instantiator(t):Ap(n)?n=await n.default(t):(jp(n)&&(n=n.data),Mp(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await Lp(n)(t):await Rp(n)(t):Np(n)||n instanceof WebAssembly.Module?n=await Ip(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await Ip(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return Pp=t(),Pp}function Ip(e){return t=>WebAssembly.instantiate(e,t)}function Lp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Rp(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var zp;function Bp(e){zp=e}function Vp(){return zp}async function Hp(e){return e&&await Fp(e),{createScanner(e){return new Op(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new Dp(e)}}}var Up=cp({});up(Up,gp);var W=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Wp(e){return Gp(e)}function Gp(e){return Array.isArray(e)?Kp(e):e instanceof RegExp?e:typeof e==`object`?qp(e):e}function Kp(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Gp(e[n]);return t}function qp(e){let t={};for(let n in e)t[n]=Gp(e[n]);return t}function Jp(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Yp(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Yp(e.substring(0,e.length-1)):e.substr(~t+1)}var Xp=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Zp=class{static hasCaptures(e){return e===null?!1:(Xp.lastIndex=0,Xp.test(e))}static replaceCaptures(e,t,n){return e.replace(Xp,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function Qp(e,t){return e<t?-1:+(e>t)}function $p(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=Qp(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function em(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function tm(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var nm=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},rm=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(cm(e),t)}static createFromParsedTheme(e,t){return um(e,t)}_cachedMatchRoot=new nm(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>am(e.parent,t.parentScopes));return n?new sm(n.fontStyle,n.foreground,n.background):null}},im=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function am(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!om(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function om(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var sm=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function cm(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&em(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&em(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new lm(l,u,e,o,s,c)}}return n}var lm=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},G=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(G||{});function um(e,t){e.sort((e,t)=>{let n=Qp(e.scope,t.scope);return n!==0||(n=$p(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new dm(t),o=new sm(n,a.getId(r),a.getId(i)),s=new mm(new pm(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new rm(a,o,s)}var dm=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},fm=Object.freeze([]),pm=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||fm,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},mm=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),pm.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if($p(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new pm(e,t,n,r,i))}},hm=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=_m(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function gm(e){return e}function _m(e){return e}function vm(e,t){let n=[],r=bm(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(ym(i)){let e=[];do e.push(i),i=r.next();while(ym(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function ym(e){return!!e&&!!e.match(/[\w\.:]+/)}function bm(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function xm(e){typeof e.dispose==`function`&&e.dispose()}var Sm=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Cm=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},wm=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Tm=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Sm(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new wm;for(let n of e)Em(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof Sm){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Em(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof Sm?Om({baseGrammar:a,selfGrammar:i},r):Dm(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new Sm(e))}function Dm(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];km([r],t,n)}}function Om(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&km(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&km(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function km(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Jp({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&km(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Fm(i);switch(a.kind){case 0:Om({...t,selfGrammar:t.baseGrammar},n);break;case 1:Om(t,n);break;case 2:Dm(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?Dm(a.ruleName,i,n):Om(i,n)}else a.kind===4?n.add(new Cm(a.scopeName,a.ruleName)):n.add(new Sm(a.scopeName));break}}}var Am=class{kind=0},jm=class{kind=1},Mm=class{constructor(e){this.ruleName=e}kind=2},Nm=class{constructor(e){this.scopeName=e}kind=3},Pm=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Fm(e){if(e===`$base`)return new Am;if(e===`$self`)return new jm;let t=e.indexOf(`#`);return t===-1?new Nm(e):t===0?new Mm(e.substring(1)):new Pm(e.substring(0,t),e.substring(t+1))}var Im=/\\(\d+)/,Lm=/\\(\d+)/g,Rm=-1,zm=-2;function Bm(e){return e}function Vm(e){return e}var Hm=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Zp.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Zp.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Yp(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Zp.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Zp.replaceCaptures(this._contentName,e,t)}},Um=class extends Hm{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Wm=class extends Hm{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Ym(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Xm,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gm=class extends Hm{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Xm,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Km=class extends Hm{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Ym(i,this.id),this.beginCaptures=a,this._end=new Ym(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Xm;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},qm=class extends Hm{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Ym(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Ym(o,zm),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Xm;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Xm,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},Jm=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Um(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Wm(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Jp({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new Gm(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new qm(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Km(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Fm(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof Gm||e instanceof Km||e instanceof qm)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Ym=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Im.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Lm.lastIndex=0,this.source.replace(Lm,(e,t)=>tm(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Xm=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new Zm(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new Zm(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Zm=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
118
- `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Qm=class{constructor(e,t){this.languageId=e,this.tokenType=t}},$m=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Qm(e,8),this._embeddedLanguagesMatcher=new eh(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Qm(0,0);_getBasicScopeAttributes=new nm(e=>new Qm(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},eh=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>tm(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var th=!1,nh=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function rh(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=ih(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new nh(i,!0);f()}return new nh(i,!1);function f(){let o=ah(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Rm){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),dh(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof Km){let r=o;dh(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof qm){let r=o;dh(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(dh(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function ih(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof qm&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=lh(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==zm){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),dh(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function ah(e,t,n,r,i,a){let o=oh(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=sh(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function oh(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=ch(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function sh(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=ch(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function ch(e,t,n,r,i){return th?{ruleScanner:e.compile(t,n),findOptions:uh(r,i)}:{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function lh(e,t,n,r,i){return th?{ruleScanner:e.compileWhile(t,n),findOptions:uh(r,i)}:{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function uh(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function dh(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));rh(e,p,n&&d.start===0,d.start,f,i,!1,0),xm(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new fh(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var fh=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function ph(e,t,n,r,i,a,o,s){return new _h(e,t,n,r,i,a,o,s)}function mh(e,t,n,r,i){let a=vm(t,hh),o=Jm.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function hh(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(gh(t[r],e))return n=r+1,!0;return!1})}function gh(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var _h=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new $m(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=vh(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=vm(e,hh);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)mh(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&mh(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(Bm(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Vm(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=vh(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=Jm.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===bh.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=hm.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?yh.createRootAndLookUpScopeName(a,r,this):yh.createRoot(`unknown`,r),t=new bh(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
119
- `;let a=this.createOnigString(e),o=a.content.length,s=new Sh(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=rh(this,a,i,0,t,s,!0,r);return xm(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function vh(e,t){return e=Wp(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var yh=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=im.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new im(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new im(null,t),o=r.themeProvider.themeMatch(a);return new e(null,a,e.mergeAttributes(n,i,o))}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),hm.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a);return new e(t,a,e.mergeAttributes(t.tokenAttributes,i,o))}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},bh=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?yh.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Vm(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=yh.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Bm(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,yh.fromExtension(r,n.contentNameScopesList))}},xh=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):vm(e,hh).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>vm(e,hh).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Sh=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=hm.set(n,0,gm(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=hm.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},Ch=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,ph(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},wh=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Ch(rm.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(rm.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new xh(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new Tm(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},Th=bh.NULL;function Eh(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function Dh(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Oh(e){return Array.isArray(e)?e:[e]}async function kh(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Ah(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function jh(e){return e===`ansi`||Ah(e)}function Mh(e){return e===`none`}function Nh(e){return Mh(e)}var Ph=/(\r?\n)/g;function Fh(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(Ph),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var Ih={light:`#333333`,dark:`#bbbbbb`},Lh={light:`#fffffe`,dark:`#1e1e1e`},Rh=`__shiki_resolved`;function zh(e){if(e?.[Rh])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?Ih.light:Ih.dark,n||=t.type===`light`?Lh.light:Lh.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Rh,{enumerable:!1,writable:!1,value:!0}),t}async function Bh(e){return[...new Set((await Promise.all(e.filter(e=>!jh(e)).map(async e=>await kh(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Vh(e){return(await Promise.all(e.map(async e=>Nh(e)?null:zh(await kh(e))))).filter(e=>!!e)}function Hh(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new W(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var Uh=class extends wh{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=zh(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=rm.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Hh(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new W(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Wh=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Gh=0;function Kh(e){Gh+=1,e.warnings!==!1&&Gh>=10&&Gh%10==0&&console.warn(`[Shiki] ${Gh} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new W("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(zh),i=new Uh(new Wh(e.engine,n),r,n,e.langAlias),a;function o(t){return Hh(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new W(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new W(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await Bh(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Vh(e))}function g(){if(t)throw new W(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Gh)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function qh(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Vh(e.themes||[]),Bh(e.langs||[]),e.engine]);return Kh({...e,themes:t,langs:n,engine:r})}var Jh=new WeakMap;function Yh(e,t){Jh.set(e,t)}function Xh(e){return Jh.get(e)}var Zh=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(Oh(n).map(e=>[e,Th])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Qh(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Qh(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function $h(e,t){if(!(e instanceof Zh))throw new W(`Invalid grammar state`);return e.getInternalStack(t)}var eg=/,/,tg=/ /;function ng(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Ah(e.resolveLangAlias(n.lang||`text`))||Mh(r))return Fh(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new W(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new W(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return ig(t,o,i,a,n)}function rg(...e){if(e.length===2)return Xh(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Ah(i)||Mh(a))throw new W(`Plain language does not have grammar state`);if(i===`ansi`)throw new W(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Zh(ag(n,c,o,s,r).stateStack,c.name,o.name)}function ig(e,t,n,r,i){let a=ag(e,t,n,r,i),o=new Zh(a.stateStack,t.name,n.name);return Yh(a.tokens,o),a.tokens}function ag(e,t,n,r,i){let a=Eh(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500}=i,c=Fh(e),l=i.grammarState?$h(i.grammarState,n.name)??Th:i.grammarContextCode==null?Th:ag(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,u=[],d=[];for(let e=0,f=c.length;e<f;e++){let[f,p]=c[e];if(f===``){u=[],d.push([]);continue}if(o>0&&f.length>=o){u=[],d.push([{content:f,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;i.includeExplanation&&(m=t.tokenizeLine(f,l,s),h=m.tokens,g=0);let _=t.tokenizeLine2(f,l,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:f.length;if(t===o)continue;let s=_.tokens[2*e+1],c=Dh(r[hm.getForeground(s)],a),l=hm.getFontStyle(s),d={content:f.substring(t,o),offset:p+t,color:c,fontStyle:l};if(i.includeExplanation){let e=[];if(i.includeExplanation!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(eg).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(tg))})}d.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=f.substring(t.startIndex,t.endIndex);r+=n.length,d.explanation.push({content:n,scopes:i.includeExplanation===`scopeName`?og(t.scopes):sg(e,t.scopes)}),g+=1}}u.push(d)}d.push(u),u=[],l=_.ruleStack}return{tokens:d,stateStack:l}}function og(e){return e.map(e=>({scopeName:e}))}function sg(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:ug(e,i,t.slice(0,r))}}return n}function cg(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function lg(e,t,n){if(!cg(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)cg(e[r],n[i])&&--r,--i;return r===-1}function ug(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(lg(e,t,n)){r.push(a);break}return r}function dg(e,t,n,r=ng){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:Xh(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=fg(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Zh(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Yh(s,c),s}function fg(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var pg=/\s+/g;function mg(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(pg)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(pg);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}var hg=/:?lang=["']([^"']+)["']/g,gg=/(?:```|~~~)([\w-]+)/g,_g=/\\begin\{([\w-]+)\}/g,vg=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function yg(e){let t=Fh(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t.at(-1).length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}function bg(e,t,n){let r=new Set;for(let t of e.matchAll(hg)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(gg)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(_g)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(vg)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(!n)return[...r];let i=n.getBundledLanguages();return[...r].filter(e=>e&&i[e])}var xg=[`color`,`background-color`];function Sg(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Cg(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?Sg(e,t):e})):e}function wg(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Tg(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&xg.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new W('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[a]=`light-dark(${o[e][a]||`inherit`}, ${o[r][a]||`inherit`})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function Tg(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&G.Italic&&(t[`font-style`]=`italic`),e.fontStyle&G.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&G.Underline&&n.push(`underline`),e.fontStyle&G.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Eg(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Dg(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=yg(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new W(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new W(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new W(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));Og(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return Cg(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new W(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=kg(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new W(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new W(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&mg(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function Og(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new W(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new W(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function kg(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(kg).join(``):``}var Ag=[Dg()];function jg(e){let t=Mg(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Ag]}function Mg(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Ng=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Pg={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Fg(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function Ig(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Lg(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Pg[r]&&t.push({type:`setDecoration`,value:Pg[r]});else if(r<=29){let e=Pg[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Ng[r-30]}});else if(r===38){let n=Ig(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Ng[r-40]}});else if(r===48){let n=Ig(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Ng[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Ng[r-100+8]}})}return t}function Rg(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Fg(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Lg(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var zg={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function Bg(e=zg){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Ng.length;e++)r.push(t(Ng[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Vg=/#([0-9a-f]{3,8})/i,Hg=/var\((--[\w-]+-ansi-[\w-]+)\)/,Ug={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function Wg(e,t,n){let r=Eh(e,n),i=Fh(t),a=Bg(Object.fromEntries(Ng.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||Ug[t]]}))),o=Rg();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=Dh(i,r),o=Dh(o,r),n.decorations.has(`dim`)&&(i=Gg(i));let s=G.None;return n.decorations.has(`bold`)&&(s|=G.Bold),n.decorations.has(`italic`)&&(s|=G.Italic),n.decorations.has(`underline`)&&(s|=G.Underline),n.decorations.has(`strikethrough`)&&(s|=G.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function Gg(e){let t=e.match(Vg);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(Hg);return n?`var(${n[1]}-dim)`:e}function Kg(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!Ah(r)&&!Mh(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return Wg(r,t,n)}return ng(e,t,n)}function qg(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new W("`themes` option must not be empty");let p=dg(e,t,n,Kg);if(c=Xh(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new W(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>wg(e,h,u,l,d))),c&&Yh(a,c);let g=f.map(e=>Eh(e.theme,n));i=Jg(f,m,g,u,l,`fg`,d),r=Jg(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=Eh(n.theme,n);a=Kg(e,t,n);let l=e.getTheme(n.theme);r=Dh(l.bg,s),i=Dh(l.fg,s),o=l.name,c=Xh(a)}else throw new W("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function Jg(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=Dh(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new W('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Dh(t[r][a],n[r])||`inherit`}, ${Dh(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var Yg=/^\s+$/,Xg=/^(\s*)(.*?)(\s*)$/;function Zg(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>Zg(e,t,n),codeToTokens:(t,n)=>qg(e,t,n)}){let i=t;for(let e of jg(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=qg(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=$g(a):d===`never`&&(a=e_(a)),f&&(a=t_(a));let p={...r,get source(){return i}};for(let e of jg(n))a=e.tokens?.call(p,a)||a;return Qg(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function Qg(e,t,n,r=Xh(e)){let i=jg(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:mg,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
120
- `}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Eg(a.htmlStyle||Tg(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&Yh(m,r),m}function $g(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&G.Underline||i.fontStyle&G.Strikethrough));o&&Yg.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function e_(e){return e.map(e=>e.flatMap(e=>{if(Yg.test(e.content))return e;let t=e.content.match(Xg);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function t_(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Eg(e.htmlStyle||Tg(e)),i=Eg(n.htmlStyle||Tg(n)),a=e.fontStyle&&(e.fontStyle&G.Underline||e.fontStyle&G.Strikethrough),o=n.fontStyle&&(n.fontStyle&G.Underline||n.fontStyle&G.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var n_=Wt;function r_(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>Zg(e,t,n),codeToTokens:(t,n)=>qg(e,t,n)},i=n_(Zg(e,t,n,r));for(let e of jg(n))i=e.postprocess?.call(r,i,n)||i;return i}async function i_(e){let t=await qh(e);return{getLastGrammarState:(...e)=>rg(t,...e),codeToTokensBase:(e,n)=>Kg(t,e,n),codeToTokensWithThemes:(e,n)=>dg(t,e,n),codeToTokens:(e,n)=>qg(t,e,n),codeToHast:(e,n)=>Zg(t,e,n),codeToHtml:(e,n)=>r_(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function a_(e){let t=e.langs,n=e.themes,r=e.engine;async function i(e){function i(n){if(typeof n==`string`){if(n=e.langAlias?.[n]||n,jh(n))return[];let r=t[n];if(!r)throw new W(`Language \`${n}\` is not included in this bundle. You may want to load it from external source.`);return r}return n}function a(e){if(Nh(e))return`none`;if(typeof e==`string`){let t=n[e];if(!t)throw new W(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);return t}return e}let o=(e.themes??[]).map(e=>a(e)),s=(e.langs??[]).map(e=>i(e)),c=await i_({engine:e.engine??r(),...e,themes:o,langs:s});return{...c,loadLanguage(...e){return c.loadLanguage(...e.map(i))},loadTheme(...e){return c.loadTheme(...e.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function o_(e){let t;async function n(n={}){if(t){let e=await t;return await Promise.all([e.loadTheme(...n.themes||[]),e.loadLanguage(...n.langs||[])]),e}else{t=e({...n,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...n.themes||[]),r.loadLanguage(...n.langs||[])]),r}}return n}function s_(e,t){let n=o_(e);async function r(e,r){let i=await n({langs:[r.lang],themes:`theme`in r?[r.theme]:Object.values(r.themes)}),a=await t?.guessEmbeddedLanguages?.(e,r.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(e){return n(e)},async codeToHtml(e,t){return(await r(e,t)).codeToHtml(e,t)},async codeToHast(e,t){return(await r(e,t)).codeToHast(e,t)},async codeToTokens(e,t){return(await r(e,t)).codeToTokens(e,t)},async codeToTokensBase(e,t){return(await r(e,t)).codeToTokensBase(e,t)},async codeToTokensWithThemes(e,t){return(await r(e,t)).codeToTokensWithThemes(e,t)},async getLastGrammarState(e,t){return(await n({langs:[t.lang],themes:[t.theme]})).getLastGrammarState(e,t)}}}var{codeToHtml:c_,codeToHast:l_,codeToTokens:u_,codeToTokensBase:d_,codeToTokensWithThemes:f_,getSingletonHighlighter:p_,getLastGrammarState:m_}=s_(a_({langs:mp,themes:hp,engine:()=>(0,Up.createOnigurumaEngine)(s(()=>import(`./wasm-BnjxR4X6.js`),[],import.meta.url))}),{guessEmbeddedLanguages:bg}),h_=(0,F.createContext)({code:``}),g_={name:`line-numbers`,line(e,t){e.children.unshift({type:`element`,tagName:`span`,properties:{className:[`inline-block`,`min-w-10`,`mr-4`,`text-right`,`select-none`,`text-muted-foreground`]},children:[{type:`text`,value:String(t)}]})}};async function __(e,t,n=!1){let r=n?[g_]:[];return await Promise.all([c_(e,{lang:t,theme:`one-light`,transformers:r}),c_(e,{lang:t,theme:`one-dark-pro`,transformers:r})])}var v_=({code:e,language:t,showLineNumbers:n=!1,className:r,children:i,...a})=>{let[o,s]=(0,F.useState)(``),[c,l]=(0,F.useState)(``),u=(0,F.useRef)(!1);return(0,F.useEffect)(()=>(__(e,t,n).then(([e,t])=>{u.current||=(s(e),l(t),!0)}),()=>{u.current=!1}),[e,t,n]),(0,L.jsx)(h_.Provider,{value:{code:e},children:(0,L.jsx)(`div`,{className:j(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,r),...a,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`div`,{className:`overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:o}}),(0,L.jsx)(`div`,{className:`hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:c}}),i&&(0,L.jsx)(`div`,{className:`absolute top-2 right-2 flex items-center gap-2`,children:i})]})})})},y_=({className:e,...t})=>(0,L.jsx)(Ae,{className:j(`not-prose mb-4 w-full rounded-md border`,e),...t}),b_=e=>(0,L.jsxs)(te,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,L.jsx)(bt,{className:`size-4`}),"input-available":(0,L.jsx)(vt,{className:`size-4 animate-pulse`}),"approval-requested":(0,L.jsx)(vt,{className:`size-4 text-yellow-600`}),"approval-responded":(0,L.jsx)(ze,{className:`size-4 text-blue-600`}),"output-available":(0,L.jsx)(ze,{className:`size-4 text-green-600`}),"output-error":(0,L.jsx)(qe,{className:`size-4 text-red-600`}),"output-denied":(0,L.jsx)(qe,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),x_=({className:e,title:t,type:n,state:r,...i})=>(0,L.jsxs)(ce,{className:j(`flex w-full items-center justify-between gap-4 p-3`,e),...i,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ie,{className:`size-4 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`font-medium text-sm`,children:t??n.split(`-`).slice(1).join(`-`)}),b_(r)]}),(0,L.jsx)(ae,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),S_=({className:e,...t})=>(0,L.jsx)(Ne,{className:j(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),C_=({className:e,input:t,...n})=>(0,L.jsxs)(`div`,{className:j(`space-y-2 overflow-hidden p-4`,e),...n,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,L.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,L.jsx)(v_,{code:JSON.stringify(t,null,2),language:`json`})})]}),w_=({className:e,output:t,errorText:n,...r})=>{if(!(t||n))return null;let i=(0,L.jsx)(`div`,{children:t});return typeof t==`object`&&!(0,F.isValidElement)(t)?i=(0,L.jsx)(v_,{code:JSON.stringify(t,null,2),language:`json`}):typeof t==`string`&&(i=(0,L.jsx)(v_,{code:t,language:`json`})),(0,L.jsxs)(`div`,{className:j(`space-y-2 p-4`,e),...r,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:n?`Error`:`Result`}),(0,L.jsxs)(`div`,{className:j(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,n?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`),children:[n&&(0,L.jsx)(`div`,{children:n}),i]})]})},T_=(0,F.createContext)({});function E_(e){let t=(0,F.useRef)(null);return t.current===null&&(t.current=e()),t.current}var D_=typeof window<`u`?F.useLayoutEffect:F.useEffect,O_=(0,F.createContext)(null);function k_(e,t){e.indexOf(t)===-1&&e.push(t)}function A_(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var j_=(e,t,n)=>n>t?t:n<e?e:n,M_={},N_=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),P_=e=>typeof e==`object`&&!!e,F_=e=>/^0[^.\s]+$/u.test(e);function I_(e){let t;return()=>(t===void 0&&(t=e()),t)}var L_=e=>e,R_=(...e)=>e.reduce((e,t)=>n=>t(e(n))),z_=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},B_=class{constructor(){this.subscriptions=[]}add(e){return k_(this.subscriptions,e),()=>A_(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},V_=e=>e*1e3,H_=e=>e/1e3,U_=(e,t)=>t?1e3/t*e:0,W_=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,G_=1e-7,K_=12;function q_(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=W_(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>G_&&++s<K_);return o}function J_(e,t,n,r){if(e===t&&n===r)return L_;let i=t=>q_(t,0,1,e,n);return e=>e===0||e===1?e:W_(i(e),t,r)}var Y_=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,X_=e=>t=>1-e(1-t),Z_=J_(.33,1.53,.69,.99),Q_=X_(Z_),$_=Y_(Q_),ev=e=>e>=1?1:(e*=2)<1?.5*Q_(e):.5*(2-2**(-10*(e-1))),tv=e=>1-Math.sin(Math.acos(e)),nv=X_(tv),rv=Y_(tv),iv=J_(.42,0,1,1),av=J_(0,0,.58,1),ov=J_(.42,0,.58,1),sv=e=>Array.isArray(e)&&typeof e[0]!=`number`,cv=e=>Array.isArray(e)&&typeof e[0]==`number`,lv={linear:L_,easeIn:iv,easeInOut:ov,easeOut:av,circIn:tv,circInOut:rv,circOut:nv,backIn:Q_,backInOut:$_,backOut:Z_,anticipate:ev},uv=e=>typeof e==`string`,dv=e=>{if(cv(e)){e.length;let[t,n,r,i]=e;return J_(t,n,r,i)}else if(uv(e))return lv[e],`${e}`,lv[e];return e},fv=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],pv={value:null,addProjectionMetrics:null};function mv(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&pv.value&&pv.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var hv=40;function gv(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=fv.reduce((e,n)=>(e[n]=mv(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=M_.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,hv),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:fv.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<fv.length;t++)o[fv[t]].cancel(e)},state:i,steps:o}}var{schedule:K,cancel:_v,state:q,steps:vv}=gv(typeof requestAnimationFrame<`u`?requestAnimationFrame:L_,!0),yv;function bv(){yv=void 0}var xv={now:()=>(yv===void 0&&xv.set(q.isProcessing||M_.useManualTiming?q.timestamp:performance.now()),yv),set:e=>{yv=e,queueMicrotask(bv)}},Sv={layout:0,mainThread:0,waapi:0},Cv=e=>t=>typeof t==`string`&&t.startsWith(e),wv=Cv(`--`),Tv=Cv(`var(--`),Ev=e=>Tv(e)?Dv.test(e.split(`/*`)[0].trim()):!1,Dv=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ov(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var kv={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Av={...kv,transform:e=>j_(0,1,e)},jv={...kv,default:1},Mv=e=>Math.round(e*1e5)/1e5,Nv=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Pv(e){return e==null}var Fv=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Iv=(e,t)=>n=>!!(typeof n==`string`&&Fv.test(n)&&n.startsWith(e)||t&&!Pv(n)&&Object.prototype.hasOwnProperty.call(n,t)),Lv=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Nv);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Rv=e=>j_(0,255,e),zv={...kv,transform:e=>Math.round(Rv(e))},Bv={test:Iv(`rgb`,`red`),parse:Lv(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+zv.transform(e)+`, `+zv.transform(t)+`, `+zv.transform(n)+`, `+Mv(Av.transform(r))+`)`};function Vv(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var Hv={test:Iv(`#`),parse:Vv,transform:Bv.transform},Uv=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Wv=Uv(`deg`),Gv=Uv(`%`),J=Uv(`px`),Kv=Uv(`vh`),qv=Uv(`vw`),Jv={...Gv,parse:e=>Gv.parse(e)/100,transform:e=>Gv.transform(e*100)},Yv={test:Iv(`hsl`,`hue`),parse:Lv(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Gv.transform(Mv(t))+`, `+Gv.transform(Mv(n))+`, `+Mv(Av.transform(r))+`)`},Y={test:e=>Bv.test(e)||Hv.test(e)||Yv.test(e),parse:e=>Bv.test(e)?Bv.parse(e):Yv.test(e)?Yv.parse(e):Hv.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Bv.transform(e):Yv.transform(e),getAnimatableNone:e=>{let t=Y.parse(e);return t.alpha=0,Y.transform(t)}},Xv=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Zv(e){return isNaN(e)&&typeof e==`string`&&(e.match(Nv)?.length||0)+(e.match(Xv)?.length||0)>0}var Qv=`number`,$v=`color`,ey=`var`,ty=`var(`,ny="${}",ry=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function iy(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(ry,e=>(Y.test(e)?(r.color.push(a),i.push($v),n.push(Y.parse(e))):e.startsWith(ty)?(r.var.push(a),i.push(ey),n.push(e)):(r.number.push(a),i.push(Qv),n.push(parseFloat(e))),++a,ny)).split(ny),indexes:r,types:i}}function ay(e){return iy(e).values}function oy({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===Qv?i+=Mv(r[a]):e===$v?i+=Y.transform(r[a]):i+=r[a]}return i}}function sy(e){return oy(iy(e))}var cy=e=>typeof e==`number`?0:Y.test(e)?Y.getAnimatableNone(e):e,ly=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:cy(e);function uy(e){let t=iy(e);return oy(t)(t.values.map((e,n)=>ly(e,t.split[n])))}var dy={test:Zv,parse:ay,createTransformer:sy,getAnimatableNone:uy};function fy(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function py({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=fy(s,r,e+1/3),a=fy(s,r,e),o=fy(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function my(e,t){return n=>n>0?t:e}var X=(e,t,n)=>e+(t-e)*n,hy=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},gy=[Hv,Bv,Yv],_y=e=>gy.find(t=>t.test(e));function vy(e){let t=_y(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===Yv&&(n=py(n)),n}var yy=(e,t)=>{let n=vy(e),r=vy(t);if(!n||!r)return my(e,t);let i={...n};return e=>(i.red=hy(n.red,r.red,e),i.green=hy(n.green,r.green,e),i.blue=hy(n.blue,r.blue,e),i.alpha=X(n.alpha,r.alpha,e),Bv.transform(i))},by=new Set([`none`,`hidden`]);function xy(e,t){return by.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Sy(e,t){return n=>X(e,t,n)}function Cy(e){return typeof e==`number`?Sy:typeof e==`string`?Ev(e)?my:Y.test(e)?yy:Dy:Array.isArray(e)?wy:typeof e==`object`?Y.test(e)?yy:Ty:my}function wy(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Cy(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Ty(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Cy(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Ey(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Dy=(e,t)=>{let n=dy.createTransformer(t),r=iy(e),i=iy(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?by.has(e)&&!i.values.length||by.has(t)&&!r.values.length?xy(e,t):R_(wy(Ey(r,i),i.values),n):(`${e}${t}`,my(e,t))};function Oy(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?X(e,t,n):Cy(e)(e,t)}var ky=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>K.update(t,e),stop:()=>_v(t),now:()=>q.isProcessing?q.timestamp:xv.now()}},Ay=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},jy=2e4;function My(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Ny(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(My(r),jy);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:H_(i)}}var Z={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Py(e,t){return e*Math.sqrt(1-t*t)}var Fy=12;function Iy(e,t,n){let r=n;for(let n=1;n<Fy;n++)r-=e(r)/t(r);return r}var Ly=.001;function Ry({duration:e=Z.duration,bounce:t=Z.bounce,velocity:n=Z.velocity,mass:r=Z.mass}){let i,a;Z.maxDuration;let o=1-t;o=j_(Z.minDamping,Z.maxDamping,o),e=j_(Z.minDuration,Z.maxDuration,H_(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Py(t,o),c=Math.exp(-i);return Ly-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Py(t**2,o);return(-i(t)+Ly>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Iy(i,a,s);if(e=V_(e),isNaN(c))return{stiffness:Z.stiffness,damping:Z.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var zy=[`duration`,`bounce`],By=[`stiffness`,`damping`,`mass`];function Vy(e,t){return t.some(t=>e[t]!==void 0)}function Hy(e){let t={velocity:Z.velocity,stiffness:Z.stiffness,damping:Z.damping,mass:Z.mass,isResolvedFromDuration:!1,...e};if(!Vy(e,By)&&Vy(e,zy))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*j_(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Z.mass,stiffness:i,damping:a}}else{let n=Ry({...e,velocity:0});t={...t,...n,mass:Z.mass},t.isResolvedFromDuration=!0}return t}function Uy(e=Z.visualDuration,t=Z.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=Hy({...n,velocity:-H_(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=H_(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Z.restSpeed.granular:Z.restSpeed.default,i||=v?Z.restDelta.granular:Z.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Py(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>V_(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=V_(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=V_(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(My(T),jy),t=Ay(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}Uy.applyToOptions=e=>{let t=Ny(e,100,Uy);return e.ease=t.ease,e.duration=V_(t.duration),e.type=`keyframes`,e};var Wy=5;function Gy(e,t,n){let r=Math.max(t-Wy,0);return U_(n-e(r),t-r)}function Ky({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=Uy({keyframes:[f.value,m(f.value)],velocity:Gy(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function qy(e,t,n){let r=[],i=n||M_.mix||Oy,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=R_(Array.isArray(t)?t[n]||L_:t,a)),r.push(a)}return r}function Jy(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=qy(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=z_(e[r],e[r+1],n);return s[r](i)};return n?t=>l(j_(e[0],e[a-1],t)):l}function Yy(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=z_(0,t,r);e.push(X(n,1,i))}}function Xy(e){let t=[0];return Yy(t,e.length-1),t}function Zy(e,t){return e.map(e=>e*t)}function Qy(e,t){return e.map(()=>t||ov).splice(0,e.length-1)}function $y({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=sv(r)?r.map(dv):dv(r),a={done:!1,value:t[0]},o=Jy(Zy(n&&n.length===t.length?n:Xy(t),e),t,{ease:Array.isArray(i)?i:Qy(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var eb=e=>e!==null;function tb(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(eb),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var nb={decay:Ky,inertia:Ky,tween:$y,keyframes:$y,spring:Uy};function rb(e){typeof e.type==`string`&&(e.type=nb[e.type])}var ib=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},ab=e=>e/100,ob=class extends ib{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==xv.now()&&this.tick(xv.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Sv.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;rb(e);let{type:t=$y,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||$y;s!==$y&&typeof o[0]!=`number`&&(this.mixKeyframes=R_(ab,Oy(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=My(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=j_(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==Ky&&(b.value=tb(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return H_(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+H_(e)}get time(){return H_(this.currentTime)}set time(e){e=V_(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return Gy(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(xv.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=H_(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=ky,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(xv.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,Sv.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function sb(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var cb=e=>e*180/Math.PI,lb=e=>db(cb(Math.atan2(e[1],e[0]))),ub={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:lb,rotateZ:lb,skewX:e=>cb(Math.atan(e[1])),skewY:e=>cb(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},db=e=>(e%=360,e<0&&(e+=360),e),fb=lb,pb=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),mb=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),hb={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:pb,scaleY:mb,scale:e=>(pb(e)+mb(e))/2,rotateX:e=>db(cb(Math.atan2(e[6],e[5]))),rotateY:e=>db(cb(Math.atan2(-e[2],e[0]))),rotateZ:fb,rotate:fb,skewX:e=>cb(Math.atan(e[4])),skewY:e=>cb(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function gb(e){return+!!e.includes(`scale`)}function _b(e,t){if(!e||e===`none`)return gb(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=hb,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=ub,i=t}if(!i)return gb(t);let a=r[t],o=i[1].split(`,`).map(yb);return typeof a==`function`?a(o):o[a]}var vb=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return _b(n,t)};function yb(e){return parseFloat(e.trim())}var bb=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],xb=new Set([...bb,`pathRotation`]),Sb=e=>e===kv||e===J,Cb=new Set([`x`,`y`,`z`]),wb=bb.filter(e=>!Cb.has(e));function Tb(e){let t=[];return wb.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var Eb={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>_b(t,`x`),y:(e,{transform:t})=>_b(t,`y`)};Eb.translateX=Eb.x,Eb.translateY=Eb.y;var Db=new Set,Ob=!1,kb=!1,Ab=!1;function jb(){if(kb){let e=Array.from(Db).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Tb(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}kb=!1,Ob=!1,Db.forEach(e=>e.complete(Ab)),Db.clear()}function Mb(){Db.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(kb=!0)})}function Nb(){Ab=!0,Mb(),jb(),Ab=!1}var Pb=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Db.add(this),Ob||(Ob=!0,K.read(Mb),K.resolveKeyframes(jb))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}sb(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Db.delete(this)}cancel(){this.state===`scheduled`&&(Db.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Fb=e=>e.startsWith(`--`);function Ib(e,t,n){Fb(t)?e.style.setProperty(t,n):e.style[t]=n}var Lb={};function Rb(e,t){let n=I_(e);return()=>Lb[t]??n()}var zb=Rb(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Bb=Rb(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Vb=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Hb={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Vb([0,.65,.55,1]),circOut:Vb([.55,0,1,.45]),backIn:Vb([.31,.01,.66,-.59]),backOut:Vb([.33,1.53,.69,.99])};function Ub(e,t){if(e)return typeof e==`function`?Bb()?Ay(e,t):`ease-out`:cv(e)?Vb(e):Array.isArray(e)?e.map(e=>Ub(e,t)||Hb.easeOut):Hb[e]}function Wb(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Ub(s,i);Array.isArray(d)&&(u.easing=d),pv.value&&Sv.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return pv.value&&p.finished.finally(()=>{Sv.waapi--}),p}function Gb(e){return typeof e==`function`&&`applyToOptions`in e}function Kb({type:e,...t}){return Gb(e)&&Bb()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var qb=class extends ib{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=Kb(e);this.animation=Wb(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=tb(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Ib(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return H_(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+H_(e)}get time(){return H_(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=V_(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&zb()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),L_):r(this)}},Jb={anticipate:ev,backInOut:$_,circInOut:rv};function Yb(e){return e in Jb}function Xb(e){typeof e.ease==`string`&&Yb(e.ease)&&(e.ease=Jb[e.ease])}var Zb=10,Qb=class extends qb{constructor(e){Xb(e),rb(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new ob({...a,autoplay:!1}),s=Math.max(Zb,xv.now()-this.startTime),c=j_(0,Zb,s-Zb),l=o.sample(s).value,{name:u}=this.options;i&&u&&Ib(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},$b=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(dy.test(e)||e===`0`)&&!e.startsWith(`url(`));function ex(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function tx(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=$b(i,t),s=$b(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:ex(e)||(n===`spring`||Gb(n))&&r}function nx(e){e.duration=0,e.type=`keyframes`}var rx=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ix=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ax(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ix.test(e[t]))return!0;return!1}var ox=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),sx=I_(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function cx(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return sx()&&n&&(rx.has(n)||ox.has(n)&&ax(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var lx=40,ux=class extends ib{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=xv.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||Pb;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=xv.now();let u=!0;tx(e,i,a,o)||(u=!1,(M_.instantAnimations||!s)&&l?.(tb(e,n,t)),e[0]=e[e.length-1],nx(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>lx?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&cx(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new Qb({...d,element:p})}catch{m=new ob(d)}else m=new ob(d);m.finished.then(()=>{this.notifyFinished()}).catch(L_),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Nb()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function dx(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var fx=30,px=e=>!isNaN(parseFloat(e)),mx={current:void 0},hx=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=xv.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=xv.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=px(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new B_);let n=this.events[e].add(t);return e===`change`?()=>{n(),K.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return mx.current&&mx.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=xv.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>fx)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,fx);return U_(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function gx(e,t){return new hx(e,t)}function _x(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function vx(e,t){let n=e?.[t]??e?.default??e;return n===e?n:_x(n,e)}var yx={type:`spring`,stiffness:500,damping:25,restSpeed:10},bx=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),xx={type:`keyframes`,duration:.8},Sx={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Cx=(e,{keyframes:t})=>t.length>2?xx:xb.has(e)?e.startsWith(`scale`)?bx(t[1]):yx:Sx,wx=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Tx(e){for(let t in e)if(!wx.has(t))return!0;return!1}var Ex=(e,t,n,r={},i,a)=>o=>{let s=vx(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=V_(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Tx(s)||Object.assign(u,Cx(e,u)),u.duration&&=V_(u.duration),u.repeatDelay&&=V_(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(nx(u),u.delay===0&&(d=!0)),(M_.instantAnimations||M_.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,nx(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=tb(u.keyframes,s);if(e!==void 0){K.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new ob(u):new ux(u)},Dx=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ox(e){let t=Dx.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function kx(e,t,n=1){`${e}`;let[r,i]=Ox(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return N_(e)?parseFloat(e):e}return Ev(i)?kx(i,t,n+1):i}function Ax(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function jx(e,t,n,r){if(typeof t==`function`){let[i,a]=Ax(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Ax(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Mx(e,t,n){let r=e.getProps();return jx(r,t,n===void 0?r.custom:n,e)}var Nx=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...bb]),Px=e=>Array.isArray(e);function Fx(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,gx(n))}function Ix(e){return Px(e)?e[e.length-1]||0:e}function Lx(e,t){let{transitionEnd:n={},transition:r={},...i}=Mx(e,t)||{};i={...i,...n};for(let t in i)Fx(e,t,Ix(i[t]))}var Q=e=>!!(e&&e.getVelocity);function Rx(e){return!!(Q(e)&&e.add)}function zx(e,t){let n=e.getValue(`willChange`);if(Rx(n))return n.add(t);if(!n&&M_.WillChange){let n=new M_.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Bx(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Vx=`data-`+Bx(`framerAppearId`);function Hx(e){return e.props[Vx]}function Ux({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Wx(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?_x(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Ux(f,t))continue;let o={delay:n,...vx(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){K.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=Hx(e);if(n){let e=window.MotionHandoffAnimation(n,t,K);e!==null&&(o.startTime=e,p=!0)}}zx(e,t);let m=l??e.shouldReduceMotion;r.start(Ex(t,r,i,m&&Nx.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>K.update(()=>{o&&Lx(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Gx(e,t,n={}){let r=Mx(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(Wx(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return Kx(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function Kx(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(Gx(c,t,{...o,delay:n+(typeof r==`function`?0:r)+dx(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function qx(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>Gx(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=Gx(e,t,n);else{let i=typeof t==`function`?Mx(e,t,n.custom):t;r=Promise.all(Wx(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var Jx={test:e=>e===`auto`,parse:e=>e},Yx=e=>t=>t.test(e),Xx=[kv,J,Gv,Wv,qv,Kv,Jx],Zx=e=>Xx.find(Yx(e));function Qx(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||F_(e)}var $x=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function eS(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Nv)||[];if(!r)return e;let i=n.replace(r,``),a=+!!$x.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var tS=/\b([a-z-]*)\(.*?\)/gu,nS={...dy,getAnimatableNone:e=>{let t=e.match(tS);return t?t.map(eS).join(` `):e}},rS={...dy,getAnimatableNone:e=>{let t=dy.parse(e);return dy.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},iS={...kv,transform:Math.round},aS={borderWidth:J,borderTopWidth:J,borderRightWidth:J,borderBottomWidth:J,borderLeftWidth:J,borderRadius:J,borderTopLeftRadius:J,borderTopRightRadius:J,borderBottomRightRadius:J,borderBottomLeftRadius:J,width:J,maxWidth:J,height:J,maxHeight:J,top:J,right:J,bottom:J,left:J,inset:J,insetBlock:J,insetBlockStart:J,insetBlockEnd:J,insetInline:J,insetInlineStart:J,insetInlineEnd:J,padding:J,paddingTop:J,paddingRight:J,paddingBottom:J,paddingLeft:J,paddingBlock:J,paddingBlockStart:J,paddingBlockEnd:J,paddingInline:J,paddingInlineStart:J,paddingInlineEnd:J,margin:J,marginTop:J,marginRight:J,marginBottom:J,marginLeft:J,marginBlock:J,marginBlockStart:J,marginBlockEnd:J,marginInline:J,marginInlineStart:J,marginInlineEnd:J,fontSize:J,backgroundPositionX:J,backgroundPositionY:J,rotate:Wv,pathRotation:Wv,rotateX:Wv,rotateY:Wv,rotateZ:Wv,scale:jv,scaleX:jv,scaleY:jv,scaleZ:jv,skew:Wv,skewX:Wv,skewY:Wv,distance:J,translateX:J,translateY:J,translateZ:J,x:J,y:J,z:J,perspective:J,transformPerspective:J,opacity:Av,originX:Jv,originY:Jv,originZ:J,zIndex:iS,fillOpacity:Av,strokeOpacity:Av,numOctaves:iS},oS={...aS,color:Y,backgroundColor:Y,outlineColor:Y,fill:Y,stroke:Y,borderColor:Y,borderTopColor:Y,borderRightColor:Y,borderBottomColor:Y,borderLeftColor:Y,filter:nS,WebkitFilter:nS,mask:rS,WebkitMask:rS},sS=e=>oS[e],cS=new Set([nS,rS]);function lS(e,t){let n=sS(e);return cS.has(n)||(n=dy),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var uS=new Set([`auto`,`none`,`0`]);function dS(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!uS.has(t)&&iy(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=lS(n,i)}var fS=class extends Pb{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Ev(r))){let i=kx(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Nx.has(n)||e.length!==2)return;let[r,i]=e,a=Zx(r),o=Zx(i);if(Ov(r)!==Ov(i)&&Eb[n]){this.needsMeasurement=!0;return}if(a!==o)if(Sb(a)&&Sb(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Eb[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||Qx(e[t]))&&n.push(t);n.length&&dS(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Eb[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=Eb[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function pS(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var mS=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function hS(e){return P_(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:gS,cancel:_S}=gv(queueMicrotask,!1),vS={x:!1,y:!1};function yS(){return vS.x||vS.y}function bS(e){return e===`x`||e===`y`?vS[e]?null:(vS[e]=!0,()=>{vS[e]=!1}):vS.x||vS.y?null:(vS.x=vS.y=!0,()=>{vS.x=vS.y=!1})}function xS(e,t){let n=pS(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function SS(e){return!(e.pointerType===`touch`||yS())}function CS(e,t,n={}){let[r,i,a]=xS(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!SS(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var wS=(e,t)=>t?e===t?!0:wS(e,t.parentElement):!1,TS=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,ES=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function DS(e){return ES.has(e.tagName)||e.isContentEditable===!0}var OS=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function kS(e){return OS.has(e.tagName)||e.isContentEditable===!0}var AS=new WeakSet;function jS(e){return t=>{t.key===`Enter`&&e(t)}}function MS(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var NS=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=jS(()=>{if(AS.has(n))return;MS(n,`down`);let e=jS(()=>{MS(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>MS(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function PS(e){return TS(e)&&!yS()}var FS=new WeakSet;function IS(e,t,n={}){let[r,i,a]=xS(e,n),o=e=>{let r=e.currentTarget;if(!PS(e)||FS.has(e))return;AS.add(r),n.stopPropagation&&FS.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),AS.has(r)&&AS.delete(r),PS(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||wS(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),hS(e)&&(e.addEventListener(`focus`,e=>NS(e,i)),!DS(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function LS(e){return P_(e)&&`ownerSVGElement`in e}var RS=new WeakMap,zS,BS=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:LS(r)&&`getBBox`in r?r.getBBox()[t]:r[n],VS=BS(`inline`,`width`,`offsetWidth`),HS=BS(`block`,`height`,`offsetHeight`);function US({target:e,borderBoxSize:t}){RS.get(e)?.forEach(n=>{n(e,{get width(){return VS(e,t)},get height(){return HS(e,t)}})})}function WS(e){e.forEach(US)}function GS(){typeof ResizeObserver>`u`||(zS=new ResizeObserver(WS))}function KS(e,t){zS||GS();let n=pS(e);return n.forEach(e=>{let n=RS.get(e);n||(n=new Set,RS.set(e,n)),n.add(t),zS?.observe(e)}),()=>{n.forEach(e=>{let n=RS.get(e);n?.delete(t),n?.size||zS?.unobserve(e)})}}var qS=new Set,JS;function YS(){JS=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};qS.forEach(t=>t(e))},window.addEventListener(`resize`,JS)}function XS(e){return qS.add(e),JS||YS(),()=>{qS.delete(e),!qS.size&&typeof JS==`function`&&(window.removeEventListener(`resize`,JS),JS=void 0)}}function ZS(e,t){return typeof e==`function`?XS(e):KS(e,t)}function QS(e){return LS(e)&&e.tagName===`svg`}var $S=[...Xx,Y,dy],eC=e=>$S.find(Yx(e)),tC=()=>({translate:0,scale:1,origin:0,originPoint:0}),nC=()=>({x:tC(),y:tC()}),rC=()=>({min:0,max:0}),$=()=>({x:rC(),y:rC()}),iC=new WeakMap;function aC(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function oC(e){return typeof e==`string`||Array.isArray(e)}var sC=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],cC=[`initial`,...sC];function lC(e){return aC(e.animate)||cC.some(t=>oC(e[t]))}function uC(e){return!!(lC(e)||e.variants)}function dC(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Q(i))e.addValue(r,i);else if(Q(a))e.addValue(r,gx(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,gx(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var fC={current:null},pC={current:!1},mC=typeof window<`u`;function hC(){if(pC.current=!0,mC)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>fC.current=e.matches;e.addEventListener(`change`,t),t()}else fC.current=!1}var gC=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],_C={};function vC(e){_C=e}function yC(){return _C}var bC=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Pb,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=xv.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,K.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=lC(t),this.isVariantNode=uC(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Q(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,iC.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(pC.current||hC(),this.shouldReduceMotion=fC.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),_v(this.notifyUpdate),_v(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&rx.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new qb({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:V_(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=xb.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&K.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in _C){let t=_C[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):$()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<gC.length;t++){let n=gC[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=dC(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=gx(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(N_(n)||F_(n))?n=parseFloat(n):!eC(n)&&dy.test(t)&&(n=lS(e,t)),this.setBaseTarget(e,Q(n)?n.get():n)),Q(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=jx(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Q(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new B_),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){gS.render(this.render)}},xC=class extends bC{constructor(){super(...arguments),this.KeyframeResolver=fS}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Q(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},SC=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function CC({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function wC({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function TC(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function EC(e){return e===void 0||e===1}function DC({scale:e,scaleX:t,scaleY:n}){return!EC(e)||!EC(t)||!EC(n)}function OC(e){return DC(e)||kC(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function kC(e){return AC(e.x)||AC(e.y)}function AC(e){return e&&e!==`0%`}function jC(e,t,n){return n+t*(e-n)}function MC(e,t,n,r,i){return i!==void 0&&(e=jC(e,i,r)),jC(e,n,r)+t}function NC(e,t=0,n=1,r,i){e.min=MC(e.min,t,n,r,i),e.max=MC(e.max,t,n,r,i)}function PC(e,{x:t,y:n}){NC(e.x,t.translate,t.scale,t.originPoint),NC(e.y,n.translate,n.scale,n.originPoint)}var FC=.999999999999,IC=1.0000000000001;function LC(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(RC(e.x,-a.scroll.offset.x),RC(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,PC(e,o)),r&&OC(a.latestValues)&&VC(e,a.latestValues,a.layout?.layoutBox))}t.x<IC&&t.x>FC&&(t.x=1),t.y<IC&&t.y>FC&&(t.y=1)}function RC(e,t){e.min+=t,e.max+=t}function zC(e,t,n,r,i=.5){NC(e,t,n,X(e.min,e.max,i),r)}function BC(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function VC(e,t,n){let r=n??e;zC(e.x,BC(t.x,r.x),t.scaleX,t.scale,t.originX),zC(e.y,BC(t.y,r.y),t.scaleY,t.scale,t.originY)}function HC(e,t){return CC(TC(e.getBoundingClientRect(),t))}function UC(e,t,n){let r=HC(e,n),{scroll:i}=t;return i&&(RC(r.x,i.offset.x),RC(r.y,i.offset.y)),r}var WC={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},GC=bb.length;function KC(e,t,n){let r=``,i=!0;for(let a=0;a<GC;a++){let o=bb[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=mS(s,aS[o]);if(!c){i=!1;let t=WC[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${mS(a,aS.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function qC(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(xb.has(e)){o=!0;continue}else if(wv(e)){i[e]=n;continue}else{let t=mS(n,aS[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=KC(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function JC(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function YC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var XC={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(J.test(e))e=parseFloat(e);else return e;return`${YC(e,t.target.x)}% ${YC(e,t.target.y)}%`}},ZC={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=dy.parse(e);if(i.length>5)return r;let a=dy.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=X(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},QC={borderRadius:{...XC,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:XC,borderTopRightRadius:XC,borderBottomLeftRadius:XC,borderBottomRightRadius:XC,boxShadow:ZC};function $C(e,{layout:t,layoutId:n}){return xb.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!QC[e]||e===`opacity`)}function ew(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Q(r[t])||i&&Q(i[t])||$C(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function tw(e){return window.getComputedStyle(e)}var nw=class extends xC{constructor(){super(...arguments),this.type=`html`,this.renderInstance=JC}readValueFromInstance(e,t){if(xb.has(t))return this.projection?.isProjecting?gb(t):vb(e,t);{let n=tw(e),r=(wv(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return HC(e,t)}build(e,t,n){qC(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return ew(e,t,n)}},rw={offset:`stroke-dashoffset`,array:`stroke-dasharray`},iw={offset:`strokeDashoffset`,array:`strokeDasharray`};function aw(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?rw:iw;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var ow=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function sw(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(qC(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of ow)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&aw(d,i,a,o,!1)}var cw=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),lw=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function uw(e,t,n,r){JC(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(cw.has(n)?n:Bx(n),t.attrs[n])}function dw(e,t,n){let r=ew(e,t,n);for(let n in e)if(Q(e[n])||Q(t[n])){let t=bb.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var fw=class extends xC{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=$}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(xb.has(t)){let e=sS(t);return e&&e.default||0}return t=cw.has(t)?t:Bx(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return dw(e,t,n)}build(e,t,n){sw(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){uw(e,t,n,r)}mount(e){this.isSVGTag=lw(e.tagName),super.mount(e)}},pw=cC.length;function mw(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&mw(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<pw;n++){let r=cC[n],i=e.props[r];(oC(i)||i===!1)&&(t[r]=i)}return t}function hw(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var gw=[...sC].reverse(),_w=sC.length;function vw(e){return t=>Promise.all(t.map(({animation:t,options:n})=>qx(e,t,n)))}function yw(e){let t=vw(e),n=Sw(),r=!0,i=!1,a=t=>(n,r)=>{let i=Mx(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=mw(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<_w;t++){let p=gw[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=oC(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||aC(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=bw(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Px(t)&&Px(n)?!hw(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Mx(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=dx(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Mx(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Sw(),i=!0}}}function bw(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!hw(t,e):!1}function xw(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Sw(){return{animate:xw(!0),whileInView:xw(),whileHover:xw(),whileTap:xw(),whileDrag:xw(),whileFocus:xw(),exit:xw()}}function Cw(e,t){e.min=t.min,e.max=t.max}function ww(e,t){Cw(e.x,t.x),Cw(e.y,t.y)}function Tw(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Ew=.9999,Dw=1.0001,Ow=-.01,kw=.01;function Aw(e){return e.max-e.min}function jw(e,t,n){return Math.abs(e-t)<=n}function Mw(e,t,n,r=.5){e.origin=r,e.originPoint=X(t.min,t.max,e.origin),e.scale=Aw(n)/Aw(t),e.translate=X(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Ew&&e.scale<=Dw||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ow&&e.translate<=kw||isNaN(e.translate))&&(e.translate=0)}function Nw(e,t,n,r){Mw(e.x,t.x,n.x,r?r.originX:void 0),Mw(e.y,t.y,n.y,r?r.originY:void 0)}function Pw(e,t,n,r=0){e.min=(r?X(n.min,n.max,r):n.min)+t.min,e.max=e.min+Aw(t)}function Fw(e,t,n,r){Pw(e.x,t.x,n.x,r?.x),Pw(e.y,t.y,n.y,r?.y)}function Iw(e,t,n,r=0){let i=r?X(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Aw(t)}function Lw(e,t,n,r){Iw(e.x,t.x,n.x,r?.x),Iw(e.y,t.y,n.y,r?.y)}function Rw(e,t,n,r,i){return e-=t,e=jC(e,1/n,r),i!==void 0&&(e=jC(e,1/i,r)),e}function zw(e,t=0,n=1,r=.5,i,a=e,o=e){if(Gv.test(t)&&(t=parseFloat(t),t=X(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=X(a.min,a.max,r);e===a&&(s-=t),e.min=Rw(e.min,t,n,s,i),e.max=Rw(e.max,t,n,s,i)}function Bw(e,t,[n,r,i],a,o){zw(e,t[n],t[r],t[i],t.scale,a,o)}var Vw=[`x`,`scaleX`,`originX`],Hw=[`y`,`scaleY`,`originY`];function Uw(e,t,n,r){Bw(e.x,t,Vw,n?n.x:void 0,r?r.x:void 0),Bw(e.y,t,Hw,n?n.y:void 0,r?r.y:void 0)}function Ww(e){return e.translate===0&&e.scale===1}function Gw(e){return Ww(e.x)&&Ww(e.y)}function Kw(e,t){return e.min===t.min&&e.max===t.max}function qw(e,t){return Kw(e.x,t.x)&&Kw(e.y,t.y)}function Jw(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Yw(e,t){return Jw(e.x,t.x)&&Jw(e.y,t.y)}function Xw(e){return Aw(e.x)/Aw(e.y)}function Zw(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Qw(e){return[e(`x`),e(`y`)]}function $w(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var eT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],tT=eT.length,nT=e=>typeof e==`string`?parseFloat(e):e,rT=e=>typeof e==`number`||J.test(e);function iT(e,t,n,r,i,a){i?(e.opacity=X(0,n.opacity??1,oT(r)),e.opacityExit=X(t.opacity??1,0,sT(r))):a&&(e.opacity=X(t.opacity??1,n.opacity??1,r));for(let i=0;i<tT;i++){let a=eT[i],o=aT(t,a),s=aT(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||rT(o)===rT(s)?(e[a]=Math.max(X(nT(o),nT(s),r),0),(Gv.test(s)||Gv.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=X(t.rotate||0,n.rotate||0,r))}function aT(e,t){return e[t]===void 0?e.borderRadius:e[t]}var oT=cT(0,.5,nv),sT=cT(.5,.95,L_);function cT(e,t,n){return r=>r<e?0:r>t?1:n(z_(e,t,r))}function lT(e,t,n){let r=Q(e)?e:gx(e);return r.start(Ex(``,r,t,n)),r.animation}function uT(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var dT=(e,t)=>e.depth-t.depth,fT=class{constructor(){this.children=[],this.isDirty=!1}add(e){k_(this.children,e),this.isDirty=!0}remove(e){A_(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(dT),this.isDirty=!1,this.children.forEach(e)}};function pT(e,t){let n=xv.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(_v(r),e(a-t))};return K.setup(r,!0),()=>_v(r)}function mT(e){return Q(e)?e.get():e}var hT=class{constructor(){this.members=[]}add(e){k_(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(A_(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(A_(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},gT={hasAnimatedSinceResize:!0,hasEverUpdated:!1},_T={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},vT=[``,`X`,`Y`,`Z`],yT=1e3,bT=0;function xT(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function ST(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Hx(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,K,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&ST(r)}function CT({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=bT++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,pv.value&&(_T.nodes=_T.calculatedTargetDeltas=_T.calculatedProjections=0),this.nodes.forEach(ET),this.nodes.forEach(FT),this.nodes.forEach(IT),this.nodes.forEach(DT),pv.addProjectionMetrics&&pv.addProjectionMetrics(_T)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new fT)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new B_),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=LS(t)&&!QS(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;K.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=pT(i,250),gT.hasAnimatedSinceResize&&(gT.hasAnimatedSinceResize=!1,this.nodes.forEach(PT)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||UT,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Yw(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...vx(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||PT(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),_v(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(LT),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ST(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(AT),this.nodes.forEach(kT);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(jT);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(MT),this.nodes.forEach(NT),this.nodes.forEach(wT),this.nodes.forEach(TT)):this.nodes.forEach(jT),this.clearAllSnapshots();let e=xv.now();q.delta=j_(0,1e3/60,e-q.timestamp),q.timestamp=e,q.isProcessing=!0,vv.update.process(q),vv.preRender.process(q),vv.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,gS.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(OT),this.sharedNodes.forEach(RT)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,K.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){K.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Aw(this.snapshot.measuredBox.x)&&!Aw(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=$(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Gw(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||OC(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),qT(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return $();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(YT))){let{scroll:e}=this.root;e&&(RC(t.x,e.offset.x),RC(t.y,e.offset.y))}return t}removeElementScroll(e){let t=$();if(ww(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&ww(t,e),RC(t.x,i.offset.x),RC(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||$();ww(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(RC(r.x,-n.scroll.offset.x),RC(r.y,-n.scroll.offset.y)),OC(n.latestValues)&&VC(r,n.latestValues,n.layout?.layoutBox)}return OC(this.latestValues)&&VC(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=$();ww(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!OC(n.latestValues))continue;let r;n.instance&&(DC(n.latestValues)&&n.updateSnapshot(),r=$(),ww(r,n.measurePageBox())),Uw(t,n.latestValues,n.snapshot?.layoutBox,r)}return OC(this.latestValues)&&Uw(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=q.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=$(),this.targetWithTransforms=$()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Fw(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):ww(this.target,this.layout.layoutBox),PC(this.target,this.targetDelta)):ww(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),pv.value&&_T.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||DC(this.parent.latestValues)||kC(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=$(),this.relativeTargetOrigin=$(),Lw(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),ww(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===q.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;ww(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;LC(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=$());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Tw(this.prevProjectionDelta.x,this.projectionDelta.x),Tw(this.prevProjectionDelta.y,this.projectionDelta.y)),Nw(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!Zw(this.projectionDelta.x,this.prevProjectionDelta.x)||!Zw(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),pv.value&&_T.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=nC(),this.projectionDelta=nC(),this.projectionDeltaWithTransform=nC()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=nC();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=$(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(HT));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=X(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=X(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(zT(o.x,e.x,n),zT(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Lw(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),VT(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&qw(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=$(),ww(f,this.relativeTarget)),c&&(this.animationValues=a,iT(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(_v(this.pendingAnimation),void 0),this.pendingAnimation=K.update(()=>{gT.hasAnimatedSinceResize=!0,Sv.layout++,this.motionValue||=gx(0),this.motionValue.jump(0,!1),this.currentAnimation=lT(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Sv.layout--},onComplete:()=>{Sv.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(yT),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&JT(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||$();let t=Aw(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Aw(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}ww(t,n),VC(t,i),Nw(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new hT),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&xT(`z`,e,r,this.animationValues);for(let t=0;t<vT.length;t++)xT(`rotate${vT[t]}`,e,r,this.animationValues),xT(`skew${vT[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=mT(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=mT(t?.pointerEvents)||``),this.hasProjected&&!OC(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=$w(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in QC){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=QC[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?mT(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(kT),this.root.sharedNodes.clear()}}}function wT(e){e.updateLayout()}function TT(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)Qw(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Aw(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Cw(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else JT(i,t.layoutBox,n)&&Qw(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Aw(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=nC();Nw(o,n,t.layoutBox);let s=nC();a?Nw(s,e.applyTransform(r,!0),t.measuredBox):Nw(s,n,t.layoutBox);let c=!Gw(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=$();Lw(s,t.layoutBox,i.layoutBox,o);let c=$();Lw(c,n,a.layoutBox,o),Yw(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function ET(e){pv.value&&_T.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function DT(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function OT(e){e.clearSnapshot()}function kT(e){e.clearMeasurements()}function AT(e){e.isLayoutDirty=!0,e.updateLayout()}function jT(e){e.isLayoutDirty=!1}function MT(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function NT(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function PT(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function FT(e){e.resolveTargetDelta()}function IT(e){e.calcProjection()}function LT(e){e.resetSkewAndRotation()}function RT(e){e.removeLeadSnapshot()}function zT(e,t,n){e.translate=X(t.translate,0,n),e.scale=X(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function BT(e,t,n,r){e.min=X(t.min,n.min,r),e.max=X(t.max,n.max,r)}function VT(e,t,n,r){BT(e.x,t.x,n.x,r),BT(e.y,t.y,n.y,r)}function HT(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var UT={duration:.45,ease:[.4,0,.1,1]},WT=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),GT=WT(`applewebkit/`)&&!WT(`chrome/`)?Math.round:L_;function KT(e){e.min=GT(e.min),e.max=GT(e.max)}function qT(e){KT(e.x),KT(e.y)}function JT(e,t,n){return e===`position`||e===`preserve-aspect`&&!jw(Xw(t),Xw(n),.2)}function YT(e){return e!==e.root&&e.scroll?.wasRoot}var XT=CT({attachResizeListener:(e,t)=>uT(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),ZT={current:void 0},QT=CT({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ZT.current){let e=new XT({});e.mount(window),e.setOptions({layoutScroll:!0}),ZT.current=e}return ZT.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),$T=(0,F.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function eE(e=!0){let t=(0,F.useContext)(O_);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,F.useId)();(0,F.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,F.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var tE=(0,F.createContext)({strict:!1}),nE={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},rE=!1;function iE(){if(rE)return;let e={};for(let t in nE)e[t]={isEnabled:e=>nE[t].some(t=>!!e[t])};vC(e),rE=!0}function aE(){return iE(),yC()}function oE(e){let t=aE();for(let n in e)t[n]={...t[n],...e[n]};vC(t)}var sE=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function cE(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||sE.has(e)}var lE=r({default:()=>uE}),uE,dE=t((()=>{throw uE={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),fE=e=>!cE(e);function pE(e){typeof e==`function`&&(fE=t=>t.startsWith(`on`)?!cE(t):e(t))}try{pE((dE(),e(lE)).default)}catch{}function mE(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Q(e[i])||(fE(i)||n===!0&&cE(i)||!t&&!cE(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var hE=(0,F.createContext)({});function gE(e,t){if(lC(e)){let{initial:t,animate:n}=e;return{initial:t===!1||oC(t)?t:void 0,animate:oC(n)?n:void 0}}return e.inherit===!1?{}:t}function _E(e){let{initial:t,animate:n}=gE(e,(0,F.useContext)(hE));return(0,F.useMemo)(()=>({initial:t,animate:n}),[vE(t),vE(n)])}function vE(e){return Array.isArray(e)?e.join(` `):e}var yE=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function bE(e,t,n){for(let r in t)!Q(t[r])&&!$C(r,n)&&(e[r]=t[r])}function xE({transformTemplate:e},t){return(0,F.useMemo)(()=>{let n=yE();return qC(n,t,e),Object.assign({},n.vars,n.style)},[t])}function SE(e,t){let n=e.style||{},r={};return bE(r,n,e),Object.assign(r,xE(e,t)),r}function CE(e,t){let n={},r=SE(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var wE=()=>({...yE(),attrs:{}});function TE(e,t,n,r){let i=(0,F.useMemo)(()=>{let n=wE();return sw(n,t,lw(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};bE(t,e.style,e),i.style={...t,...i.style}}return i}var EE=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function DE(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(EE.indexOf(e)>-1||/[A-Z]/u.test(e))}function OE(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??DE(e)?TE:CE)(t,r,i,e),c=mE(t,typeof e==`string`,a),l=e===F.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,F.useMemo)(()=>Q(u)?u.get():u,[u]);return(0,F.createElement)(e,{...l,children:d})}function kE({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:AE(n,r,i,e),renderState:t()}}function AE(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=mT(a[e]);let{initial:o,animate:s}=e,c=lC(e),l=uC(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!aC(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=jx(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var jE=e=>(t,n)=>{let r=(0,F.useContext)(hE),i=(0,F.useContext)(O_),a=()=>kE(e,t,r,i);return n?a():E_(a)},ME=jE({scrapeMotionValuesFromProps:ew,createRenderState:yE}),NE=jE({scrapeMotionValuesFromProps:dw,createRenderState:wE}),PE=Symbol.for(`motionComponentSymbol`);function FE(e,t,n){let r=(0,F.useRef)(n);(0,F.useInsertionEffect)(()=>{r.current=n});let i=(0,F.useRef)(null);return(0,F.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var IE=(0,F.createContext)({});function LE(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function RE(e,t,n,r,i,a){let{visualElement:o}=(0,F.useContext)(hE),s=(0,F.useContext)(tE),c=(0,F.useContext)(O_),l=(0,F.useContext)($T),u=l.reducedMotion,d=l.skipAnimations,f=(0,F.useRef)(null),p=(0,F.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,F.useContext)(IE);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&zE(f.current,n,i,h);let g=(0,F.useRef)(!1);(0,F.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[Vx],v=(0,F.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return D_(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,F.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function zE(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:BE(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&LE(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function BE(e){if(e)return e.options.allowProjection===!1?BE(e.parent):e.projection}function VE(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&oE(r);let a=n?n===`svg`:DE(e),o=a?NE:ME;function s(n,s){let c,l={...(0,F.useContext)($T),...n,layoutId:HE(n)},{isStatic:u}=l,d=_E(n),f=o(n,u);if(!u&&typeof window<`u`){UE(l,r);let t=WE(l);c=t.MeasureLayout,d.visualElement=RE(e,f,l,i,t.ProjectionNode,a)}return(0,L.jsxs)(hE.Provider,{value:d,children:[c&&d.visualElement?(0,L.jsx)(c,{visualElement:d.visualElement,...l}):null,OE(e,n,FE(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,F.forwardRef)(s);return c[PE]=e,c}function HE({layoutId:e}){let t=(0,F.useContext)(T_).id;return t&&e!==void 0?t+`-`+e:e}function UE(e,t){(0,F.useContext)(tE).strict}function WE(e){let{drag:t,layout:n}=aE();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function GE(e,t){if(typeof Proxy>`u`)return VE;let n=new Map,r=(n,r)=>VE(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,VE(a,void 0,e,t)),n.get(a))})}var KE=(e,t)=>t.isSVG??DE(e)?new fw(t):new nw(t,{allowProjection:e!==F.Fragment}),qE=class extends SC{constructor(e){super(e),e.animationState||=yw(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();aC(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},JE=0,YE={animation:{Feature:qE},exit:{Feature:class extends SC{constructor(){super(...arguments),this.id=JE++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Mx(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function XE(e){return{point:{x:e.pageX,y:e.pageY}}}var ZE=e=>t=>TS(t)&&e(t,XE(t));function QE(e,t,n,r){return uT(e,t,ZE(n),r)}var $E=({current:e})=>e?e.ownerDocument.defaultView:null,eD=(e,t)=>Math.abs(e-t);function tD(e,t){let n=eD(e.x,t.x),r=eD(e.y,t.y);return Math.sqrt(n**2+r**2)}var nD=new Set([`auto`,`scroll`]),rD=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=iD(this.lastRawMoveEventInfo,this.transformPagePoint));let e=oD(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=tD(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=q;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=iD(t,this.transformPagePoint),K.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=oD(e.type===`pointercancel`?this.lastMoveEventInfo:iD(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!TS(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=iD(XE(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=q;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,oD(s,this.history)),this.removeListeners=R_(QE(this.contextWindow,`pointermove`,this.handlePointerMove),QE(this.contextWindow,`pointerup`,this.handlePointerUp),QE(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(nD.has(e.overflowX)||nD.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),K.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),_v(this.updatePoint)}};function iD(e,t){return t?{point:t(e.point)}:e}function aD(e,t){return{x:e.x-t.x,y:e.y-t.y}}function oD({point:e},t){return{point:e,delta:aD(e,cD(t)),offset:aD(e,sD(t)),velocity:lD(t,.1)}}function sD(e){return e[0]}function cD(e){return e[e.length-1]}function lD(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=cD(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>V_(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>V_(t)*2&&(r=e[1]);let a=H_(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function uD(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?X(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?X(n,e,r.max):Math.min(e,n)),e}function dD(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function fD(e,{top:t,left:n,bottom:r,right:i}){return{x:dD(e.x,n,i),y:dD(e.y,t,r)}}function pD(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function mD(e,t){return{x:pD(e.x,t.x),y:pD(e.y,t.y)}}function hD(e,t){let n=.5,r=Aw(e),i=Aw(t);return i>r?n=z_(t.min,t.max-r,e.min):r>i&&(n=z_(e.min,e.max-i,t.min)),j_(0,1,n)}function gD(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var _D=.35;function vD(e=_D){return e===!1?e=0:e===!0&&(e=_D),{x:yD(e,`left`,`right`),y:yD(e,`top`,`bottom`)}}function yD(e,t,n){return{min:bD(e,t),max:bD(e,n)}}function bD(e,t){return typeof e==`number`?e:e[t]||0}var xD=new WeakMap,SD=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=$(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(XE(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=bS(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Qw(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Gv.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Aw(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&K.update(()=>i(e,t),!1,!0),zx(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=ED(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&K.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new rD(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:$E(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&K.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!TD(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=uD(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&LE(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=fD(n.layoutBox,e):this.constraints=!1,this.elastic=vD(t),r!==this.constraints&&!LE(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Qw(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=gD(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!LE(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=UC(n,r.root,this.visualElement.getTransformPagePoint()),a=mD(r.layout.layoutBox,i);if(t){let e=t(wC(a));this.hasMutatedConstraints=!!e,e&&(a=CC(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=Qw(o=>{if(!TD(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return zx(this.visualElement,e),n.start(Ex(e,n,0,t,this.visualElement,!1))}stopAnimation(){Qw(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){Qw(t=>{let{drag:n}=this.getProps();if(!TD(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-X(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!LE(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Qw(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=hD({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Qw(t=>{if(!TD(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(X(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;xD.set(this.visualElement,this);let e=this.visualElement.current,t=QE(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&kS(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();LE(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=wD(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),K.read(r);let o=uT(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Qw(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=_D,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function CD(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function wD(e,t,n){let r=ZS(e,CD(n)),i=ZS(t,CD(n));return()=>{r(),i()}}function TD(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function ED(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var DD=class extends SC{constructor(e){super(e),this.removeGroupControls=L_,this.removeListeners=L_,this.controls=new SD(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||L_}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},OD=e=>(t,n)=>{e&&K.update(()=>e(t,n),!1,!0)},kD=class extends SC{constructor(){super(...arguments),this.removePointerDownListener=L_}onPointerDown(e){this.session=new rD(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:$E(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:OD(e),onStart:OD(t),onMove:OD(n),onEnd:(e,t)=>{delete this.session,r&&K.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=QE(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},AD=!1,jD=class extends F.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),AD&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),gT.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),AD=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||K.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),gS.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;AD=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function MD(e){let[t,n]=eE(),r=(0,F.useContext)(T_);return(0,L.jsx)(jD,{...e,layoutGroup:r,switchLayoutGroup:(0,F.useContext)(IE),isPresent:t,safeToRemove:n})}var ND={pan:{Feature:kD},drag:{Feature:DD,ProjectionNode:QT,MeasureLayout:MD}};function PD(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&K.postRender(()=>i(t,XE(t)))}var FD=class extends SC{mount(){let{current:e}=this.node;e&&(this.unmount=CS(e,(e,t)=>(PD(this.node,t,`Start`),e=>PD(this.node,e,`End`))))}unmount(){}},ID=class extends SC{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=R_(uT(this.node.current,`focus`,()=>this.onFocus()),uT(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function LD(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&K.postRender(()=>i(t,XE(t)))}var RD=class extends SC{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=IS(e,(e,t)=>(LD(this.node,t,`Start`),(e,{success:t})=>LD(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},zD=new WeakMap,BD=new WeakMap,VD=e=>{let t=zD.get(e.target);t&&t(e)},HD=e=>{e.forEach(VD)};function UD({root:e,...t}){let n=e||document;BD.has(n)||BD.set(n,{});let r=BD.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(HD,{root:e,...t})),r[i]}function WD(e,t,n){let r=UD(t);return zD.set(e,n),r.observe(e),()=>{zD.delete(e),r.unobserve(e)}}var GD={some:0,all:1},KD=class extends SC{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:GD[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=WD(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(qD(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function qD({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var JD={inView:{Feature:KD},tap:{Feature:RD},focus:{Feature:ID},hover:{Feature:FD}},YD={layout:{ProjectionNode:QT,MeasureLayout:MD}},XD=GE({...YE,...JD,...ND,...YD},KE),ZD=(0,F.memo)(({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2})=>{let a=XD.create(t),o=(0,F.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,L.jsx)(a,{animate:{backgroundPosition:`0% center`},className:j(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,n),initial:{backgroundPosition:`100% center`},style:{"--spread":`${o}px`,backgroundImage:`var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))`},transition:{repeat:1/0,duration:r,ease:`linear`},children:e})}),QD=(0,F.createContext)(null),$D=()=>{let e=(0,F.useContext)(QD);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},eO=1e3,tO=1e3,nO=(0,F.memo)(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:i,duration:a,children:o,...s})=>{let[c,l]=Nt({prop:n,defaultProp:r,onChange:i}),[u,d]=Nt({prop:a,defaultProp:void 0}),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(null);return(0,F.useEffect)(()=>{t?m===null&&h(Date.now()):m!==null&&(d(Math.ceil((Date.now()-m)/tO)),h(null))},[t,m,d]),(0,F.useEffect)(()=>{if(r&&!t&&c&&!f){let e=setTimeout(()=>{l(!1),p(!0)},eO);return()=>clearTimeout(e)}},[t,c,r,l,f]),(0,L.jsx)(QD.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:l,duration:u},children:(0,L.jsx)(Ae,{className:j(`not-prose mb-4`,e),onOpenChange:e=>{l(e)},open:c,...s,children:o})})}),rO=(e,t)=>e||t===0?(0,L.jsx)(ZD,{duration:1,children:`Thinking...`}):t===void 0?(0,L.jsx)(`p`,{children:`Thought for a few seconds`}):(0,L.jsxs)(`p`,{children:[`Thought for `,t,` seconds`]}),iO=(0,F.memo)(({className:e,children:t,getThinkingMessage:n=rO,...r})=>{let{isStreaming:i,isOpen:a,duration:o}=$D();return(0,L.jsx)(ce,{className:j(`flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,e),...r,children:t??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(je,{className:`size-4`}),n(i,o),(0,L.jsx)(ae,{className:j(`size-4 transition-transform`,a?`rotate-180`:`rotate-0`)})]})})}),aO=(0,F.memo)(({className:e,children:t,...n})=>(0,L.jsx)(Ne,{className:j(`mt-4 text-sm`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...n,children:(0,L.jsx)(yf,{children:t})}));nO.displayName=`Reasoning`,iO.displayName=`ReasoningTrigger`,aO.displayName=`ReasoningContent`;var oO=({className:e,...t})=>(0,L.jsx)(Ae,{className:j(`not-prose mb-4 text-primary text-xs`,e),...t}),sO=({className:e,count:t,children:n,...r})=>(0,L.jsx)(ce,{className:j(`flex items-center gap-2`,e),...r,children:n??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`font-medium`,children:[`Used `,t,` sources`]}),(0,L.jsx)(ae,{className:`h-4 w-4`})]})}),cO=({className:e,...t})=>(0,L.jsx)(Ne,{className:j(`mt-3 flex w-fit flex-col gap-2`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),lO=({href:e,title:t,children:n,...r})=>(0,L.jsx)(`a`,{className:`flex items-center gap-2`,href:e,rel:`noreferrer`,target:`_blank`,...r,children:n??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(me,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{className:`block font-medium`,children:t})]})});function uO(e){let t=e??{},n=t.data&&typeof t.data==`object`?t.data:t,r=n.seedApplied,i=n.probes;if(!r&&!i)return;let a={};return r&&(r.success===!1?a.seedError=r.error??(Array.isArray(r.errors)&&r.errors.length?String(r.errors[0]):`Sample data failed to load.`):a.seededRows=(r.inserted??0)+(r.updated??0)),i&&(a.checked={seeds:i.checked?.seeds??0,views:i.checked?.views??0,widgets:i.checked?.widgets??0},a.issues=(i.issues??[]).filter(e=>e&&typeof e.message==`string`).map(e=>({severity:e.severity===`error`?`error`:`warning`,code:String(e.code??`runtime_issue`),message:String(e.message)}))),a}function dO(e){return e===`user`?`user`:`assistant`}function fO(e){let t=e.trim();if(t.length<2||!(t.startsWith(`{`)||t.startsWith(`[`))||!(t.endsWith(`}`)||t.endsWith(`]`)))return!1;try{return JSON.parse(t),!0}catch{return!1}}function pO(e){let t=e.state??(e.errorText?`output-error`:e.result===void 0?`input-available`:`output-available`);return t===`output-error`||t===`output-denied`?`failed`:t===`approval-requested`||t===`approval-responded`?`awaiting`:t===`output-available`?`completed`:`running`}function mO(e){let t=pO(e);return t===`awaiting`||t===`failed`||!!e.pendingActionId||!!e.draftReview?.items.length}function hO(e){switch(e){case`failed`:return 4;case`awaiting`:return 3;case`running`:return 2;case`completed`:return 1}}function gO(e){let t=new Map;for(let n of e){let e=pO(n),r=`${n.toolName}:${e}`,i=t.get(r);if(i){i.count+=1,i.errorText=i.errorText??n.errorText;continue}t.set(r,{key:r,title:Ja(n.toolName)||n.toolName,rawName:n.toolName,count:1,state:e,errorText:n.errorText})}return Array.from(t.values()).sort((e,t)=>{let n=hO(t.state)-hO(e.state);return n===0?e.title.localeCompare(t.title):n})}function _O({health:e}){if(!e)return null;let t=e.issues??[],n=t.filter(e=>e.severity===`error`),r=t.filter(e=>e.severity!==`error`),i=e.checked,a=!!i&&i.seeds+i.views+i.widgets>0,o=[];if(typeof e.seededRows==`number`&&e.seededRows>0&&!e.seedError&&o.push(`${e.seededRows} sample row${e.seededRows===1?``:`s`} live`),a&&n.length===0){let e=[];i.views>0&&e.push(`${i.views} view${i.views===1?``:`s`}`),i.widgets>0&&e.push(`${i.widgets} widget${i.widgets===1?``:`s`}`),i.seeds>0&&e.push(`${i.seeds} seed${i.seeds===1?``:`s`}`),e.length&&o.push(`${e.join(` · `)} verified`)}return o.length===0&&!e.seedError&&t.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 border-t bg-muted/20 px-3 py-2`,"data-testid":`publish-health`,children:[o.length>0?(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-emerald-700`,children:[(0,L.jsx)($e,{className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:o.join(` · `)})]}):null,e.seedError?(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-600`,children:[(0,L.jsx)(qe,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.seedError})]}):null,n.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-600`,children:[(0,L.jsx)(qe,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.message})]},`e${t}`)),r.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-amber-600`,children:[(0,L.jsx)(Dt,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.message})]},`w${t}`))]})}var vO=F.forwardRef(({className:e,messages:t=[],placeholder:n=`Type your message...`,onSendMessage:r,onClear:i,onStop:a,onReload:o,onUpgrade:s,disabled:c=!1,isLoading:u=!1,error:d,showTimestamp:f=!1,showAvatars:p=!1,userAvatarUrl:m,userAvatarFallback:h=`You`,assistantAvatarUrl:g,assistantAvatarFallback:_=`AI`,hideClearBar:v=!1,maxHeight:y=`500px`,enableMarkdown:b=!0,enableFileUpload:x=!1,acceptedFileTypes:S=`image/*,.pdf,.doc,.docx,.txt`,maxFileSize:C=10*1024*1024,suggestions:w,labels:T,models:E,selectedModelId:D,onModelChange:ee,headerSlot:O,promptOverlaySlot:te,onInputChange:ne,onToolApprove:re,toolApproveLabel:ie=`Approve`,toolDenyLabel:ae=`Deny`,toolDenyReason:se=`User denied the operation`,toolDecisions:ce,onReviewDraft:le,toolReviewLabel:ue=e=>`Review ${e} change${e===1?``:`s`}`,onPublishDrafts:de,onOpenBuiltApp:fe,openBuiltAppLabel:me=`Open app`,onPreviewDraftApp:he,previewDraftLabel:ge=`Preview`,onDraftArtifacts:_e,onBuildMaterialized:ve,publishDraftsLabel:be=`Publish`,publishedLabel:Se=`Published`,verifiedLabel:Ce=`Verified`,fetchPendingDraftCount:we,autoPublishDrafts:Ee=!1,processVisibility:De=`summary`,surface:Oe=`card`,...ke},Ae)=>{let je=u?`streaming`:`ready`,Me=Oe===`plain`,[Ne,Pe]=F.useState(null),k=F.useMemo(()=>({emptyTitle:T?.emptyTitle??`Start a conversation`,emptyDescription:T?.emptyDescription??`Ask anything — the assistant has access to your current app context.`,clear:T?.clear??`Clear`,sendHint:T?.sendHint??`to send`,agentActivity:T?.agentActivity??`Agent activity`,toolCompleted:T?.toolCompleted??`Completed`,toolRunning:T?.toolRunning??`Running`,toolAwaitingApproval:T?.toolAwaitingApproval??`Awaiting approval`,toolFailed:T?.toolFailed??`Failed`,toolDetailsHidden:T?.toolDetailsHidden??`Detailed tool inputs and outputs are hidden in this view.`,copy:T?.copy??`Copy`,copied:T?.copied??`Copied`,regenerate:T?.regenerate??`Regenerate`,model:T?.model??`Model`,submit:T?.submit??`Submit`,uploadFiles:T?.uploadFiles??`Upload files`,stopResponse:T?.stopResponse??`Stop response`,trace:T?.trace??`trace`,viewTrace:T?.viewTrace??`View trace`,connectionWaiting:T?.connectionWaiting??`Waiting for server…`}),[T]),[Fe,Ie]=F.useState(()=>new Set),[Re,ze]=F.useState(()=>new Map),[Be,Ve]=F.useState(()=>new Map),He=F.useRef(new Set),Ue=F.useCallback(async e=>{if(we)try{let t=await we(e);Ve(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}catch{}},[we]);F.useEffect(()=>{if(!we||u)return;let e=new Set;for(let n of t)for(let t of n.toolInvocations??[]){let n=t.draftReview?.packageId,r=t.toolCallId;n&&r&&!He.current.has(r)&&(He.current.add(r),e.add(n))}for(let t of e)Ue(t)},[t,u,we,Ue]);let We=F.useCallback(async e=>{if(!de)return;let n=[];for(let r of t)for(let t of r.toolInvocations??[])t.draftReview?.packageId===e&&t.toolCallId&&n.push(t.toolCallId);let r=await de(e),i=r&&typeof r==`object`?r:void 0;if((i?i.ok!==!1:r!==!1)&&n.length>0){Ie(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});let e=i?.health;e&&ze(t=>{let r=new Map(t);for(let t of n)r.set(t,e);return r})}Ue(e)},[de,t,Ue]),Ge=F.useRef(new Set),Je=F.useRef(!1);F.useEffect(()=>{let e=[];for(let n of t)for(let t of n.toolInvocations??[]){let n=t.draftReview;n?.autoPublishable&&n.packageId&&t.toolCallId&&n.items.length>0&&e.push({key:t.toolCallId,packageId:n.packageId})}if(!Je.current){Je.current=!0;for(let t of e)Ge.current.add(t.key);return}if(!Ee||!de||u)return;let n=e.filter(e=>!Ge.current.has(e.key));if(n.length!==0){for(let e of n)Ge.current.add(e.key);for(let e of[...new Set(n.map(e=>e.packageId))])We(e)}},[t,u,Ee,de,We]);let Ye=F.useRef(new Set);F.useEffect(()=>{if(!_e)return;let e=new Map;for(let n of t){for(let t of n.buildProgress?.items??[])t?.type&&t?.name&&e.set(`${t.type}:${t.name}`,t);for(let t of n.toolInvocations??[])for(let n of t.draftReview?.items??[])n?.type&&n?.name&&e.set(`${n.type}:${n.name}`,n)}let n=Ye.current,r=!1;for(let t of e.keys())n.has(t)||(n.add(t),r=!0);r&&_e([...e.values()])},[t,_e]);let Xe=F.useRef(new Set);F.useEffect(()=>{if(ve)for(let e of t)for(let t of e.toolInvocations??[]){let e=t.draftReview;if(!e?.materialized||!t.toolCallId)continue;let n=e.items.find(e=>e.type===`app`);!n||Xe.current.has(t.toolCallId)||(Xe.current.add(t.toolCallId),ve(n.name))}},[t,ve]);let Qe=F.useCallback(e=>{let t=!!e.text?.trim(),n=e.files?.map(e=>e.file).filter(Boolean),i=!!(n&&n.length>0);(t||i)&&r?.(e.text?.trim()??``,n)},[r]),A=F.useCallback(e=>{r?.(e)},[r]),et=F.useCallback(e=>{navigator.clipboard?.writeText(e.content),Pe(e.id),window.setTimeout(()=>Pe(t=>t===e.id?null:t),1500)},[]),tt=e=>{let t=e.state??(e.errorText?`output-error`:e.result===void 0?`input-available`:`output-available`),n=`tool-${e.toolName}`,r=ce?.[e.toolCallId],i=t===`approval-requested`&&!!re&&!r,a=t===`approval-requested`&&!!e.pendingActionId,o=Ja(e.toolName),s=Ya(e.result),c=De===`debug`&&o&&o.toLowerCase()!==e.toolName.toLowerCase(),l=De===`debug`||i,u=e.draftReview?.packageId,d=u===void 0?void 0:Be.get(u),f=d===void 0?Fe.has(e.toolCallId):d===0,p=(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(`span`,{children:o||e.toolName}),c?(0,L.jsx)(`code`,{className:`rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground`,children:e.toolName}):null]});return(0,L.jsxs)(y_,{defaultOpen:t===`output-error`||t===`approval-requested`||!!(e.draftReview&&e.draftReview.items.length>0),children:[(0,L.jsx)(x_,{type:n,state:t,title:p}),(0,L.jsxs)(S_,{children:[l&&e.args!==void 0?(0,L.jsx)(C_,{input:e.args}):null,a?null:l||t===`output-error`?(0,L.jsx)(NO,{output:s,errorText:e.errorText}):null,r?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-t text-xs `+(r.state===`error`?`bg-destructive/10 text-destructive`:r.state===`success`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`:`bg-muted/30 text-muted-foreground`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:r.state===`pending`?`...`:r.state===`success`?`OK`:`X`}),(0,L.jsx)(`span`,{children:r.message??(r.state===`pending`?`Submitting decision...`:r.state===`success`?`Action approved and executed.`:`Decision failed.`)})]}):null,i?(0,L.jsxs)(`div`,{className:`flex gap-2 p-3 border-t bg-muted/30`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>re?.(e.toolCallId,!0),className:`inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:ie}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>re?.(e.toolCallId,!1,se),className:`inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent`,children:ae})]}):null,e.draftReview&&e.draftReview.items.length>0&&(le||de&&e.draftReview.packageId)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-t bg-muted/30`,children:[de&&e.draftReview.packageId?f?(0,L.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700`,children:[(0,L.jsx)($e,{className:`size-3.5`}),Se,e.draftReview.failedCount?` · ${e.draftReview.failedCount} need${e.draftReview.failedCount===1?`s`:``} attention`:``]}):(0,L.jsxs)(`button`,{type:`button`,onClick:()=>void We(e.draftReview.packageId),className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`draft-publish`,children:[(0,L.jsx)(at,{className:`size-3.5`}),be,typeof d==`number`&&d>0?` (${d})`:``]}):null,le?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>le(e.draftReview.items),className:de&&e.draftReview.packageId?`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted`:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[(0,L.jsx)(Ke,{className:`size-3.5`}),ue(e.draftReview.items.length)]}):null,he&&!f?(()=>{let t=e.draftReview.items.find(e=>e.type===`app`);return t?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>he(t.name,{materialized:e.draftReview.materialized===!0}),className:`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted`,"data-testid":`draft-preview-app`,children:[(0,L.jsx)(xe,{className:`size-3.5`}),ge]}):null})():null,e.draftReview.verification?e.draftReview.verification.errors>0?(0,L.jsxs)(`span`,{className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700`,"data-testid":`draft-verification-chip`,children:[(0,L.jsx)(Te,{className:`size-3.5`}),`${e.draftReview.verification.errors} issue${e.draftReview.verification.errors===1?``:`s`}`]}):(0,L.jsxs)(`span`,{className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-2.5 text-xs font-medium text-emerald-700`,"data-testid":`draft-verification-chip`,children:[(0,L.jsx)(Ze,{className:`size-3.5`}),Ce]}):null,e.draftReview.summary?(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.draftReview.summary}):null]}),e.draftReview.issues&&e.draftReview.issues.length>0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 border-t bg-muted/20 px-3 py-2`,"data-testid":`draft-issues`,children:[e.draftReview.issues.filter(e=>e.severity===`error`).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-600`,children:[(0,L.jsx)(qe,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.fix?`${e.message} — ${e.fix}`:e.message})]},`e${t}`)),e.draftReview.issues.filter(e=>e.severity!==`error`).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-amber-600`,children:[(0,L.jsx)(Dt,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.message})]},`w${t}`))]}):null,Fe.has(e.toolCallId)?(0,L.jsx)(_O,{health:Re.get(e.toolCallId)}):null]}):null]})]},e.toolCallId)};return(0,L.jsxs)(`div`,{ref:Ae,className:j(Me?`flex min-h-0 flex-col overflow-hidden bg-background`:`flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background`,e),style:{maxHeight:y},...ke,children:[i&&!v&&t.length>0&&(0,L.jsx)(`div`,{className:j(`flex items-center justify-end px-4 py-2`,Me?`bg-background`:`border-b bg-muted/30`),children:(0,L.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:k.clear})}),O?(0,L.jsx)(`div`,{className:j(`shrink-0`,!Me&&`border-b bg-background/50`),children:O}):null,(0,L.jsxs)(po,{className:`flex-1 min-h-0`,children:[(0,L.jsxs)(mo,{className:j(`space-y-4`,Me?`mx-auto w-full max-w-2xl px-4 py-8 sm:px-0`:`px-4 py-3`),children:[t.length===0?(0,L.jsxs)(ho,{className:`gap-3 px-0 py-8`,children:[(0,L.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-md bg-muted/70 text-muted-foreground`,children:g?(0,L.jsx)(`img`,{src:g,alt:``,className:`size-full rounded-md object-cover`}):(0,L.jsx)(ht,{className:`size-4`})}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:k.emptyTitle}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k.emptyDescription})]}),w&&w.length>0?(0,L.jsx)(np,{className:`justify-center gap-2`,children:w.map(e=>(0,L.jsx)(rp,{className:`h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60`,suggestion:e,onClick:A},e))}):null]}):t.map(e=>{let t=e.role===`user`,n=e.toolInvocations??[],r=e.reasoning?.trim(),i=e.sources??[],a=t?void 0:e.buildProgress,s=!t&&!!e.streaming&&!e.content&&n.length===0&&!r&&!a,c=!t&&De===`summary`?n.filter(e=>!mO(e)):[],u=!t&&De===`debug`?n:!t&&De!==`debug`?n.filter(mO):[];return(0,L.jsx)(Sf,{from:dO(e.role),children:(0,L.jsxs)(`div`,{className:j(`flex w-full gap-2.5`,p?t?`flex-row-reverse items-start`:`flex-row items-start`:`flex-col`),children:[p?(0,L.jsx)(yO,{isUser:t,url:t?m:g,fallback:t?h:_}):null,(0,L.jsxs)(`div`,{className:j(`flex min-w-0 flex-col gap-2`,p&&!t&&`flex-1`),children:[(0,L.jsxs)(Cf,{children:[a?(0,L.jsx)(OO,{progress:a,onOpenBuiltApp:fe,openBuiltAppLabel:me,onPreviewDraftApp:he,previewDraftLabel:ge,waitingLabel:k.connectionWaiting}):null,!t&&De===`debug`&&r?(0,L.jsxs)(nO,{isStreaming:!!e.streaming&&!e.content,className:`mb-2`,children:[(0,L.jsx)(iO,{}),(0,L.jsx)(aO,{children:r})]}):null,!t&&De===`summary`&&c.length>0?(0,L.jsx)(kO,{groups:gO(c),labels:k}):null,!t&&u.length>0?u.map(tt):null,t?e.content?(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content}):null:s?(0,L.jsx)(xO,{}):e.content?(0,L.jsx)(Ef,{children:e.content}):null,e.streaming&&!s?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse`}):null,!t&&(e.charts?.length??0)>0?(0,L.jsx)(`div`,{className:`mt-2 flex flex-col gap-3`,"data-testid":`chat-charts`,children:e.charts.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-lg border bg-background p-3`,style:{width:`min(520px, 80vw)`},"data-testid":`chat-chart`,children:[e.title?(0,L.jsx)(`div`,{className:`mb-2 text-sm font-medium text-foreground`,children:e.title}):null,(0,L.jsx)(l,{schema:{type:`chart`,chartType:e.chartType??`bar`,data:e.data,xAxisKey:e.xAxisKey,series:e.series}})]},t))}):null,!t&&i.length>0?(0,L.jsxs)(oO,{children:[(0,L.jsx)(sO,{count:i.length}),(0,L.jsx)(cO,{children:i.map((e,t)=>(0,L.jsx)(lO,{href:e.url,title:e.title??e.url},e.id??e.url??t))})]}):null,f&&e.timestamp?(0,L.jsx)(`div`,{className:`text-[10px] opacity-70 mt-1`,children:e.timestamp}):null]}),!t&&!s?(0,L.jsxs)(wf,{className:`opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[(0,L.jsx)(Tf,{label:Ne===e.id?k.copied:k.copy,tooltip:Ne===e.id?k.copied:k.copy,onClick:()=>et(e),children:Ne===e.id?(0,L.jsx)(ye,{className:`size-3.5`}):(0,L.jsx)(Le,{className:`size-3.5`})}),o?(0,L.jsx)(Tf,{label:k.regenerate,tooltip:k.regenerate,onClick:o,children:(0,L.jsx)(oe,{className:`size-3.5`})}):null,De===`debug`&&e.traceId?(0,L.jsx)(`a`,{href:`#trace/${e.traceId}`,"data-trace-id":e.traceId,className:`text-[10px] text-muted-foreground hover:text-foreground ml-1 underline`,title:k.viewTrace,children:k.trace}):null]}):null]})]})},e.id)}),u&&!t.some(e=>e.streaming)?(0,L.jsx)(bO,{showAvatar:p,assistantAvatarUrl:g,assistantAvatarFallback:_,waitingLabel:k.connectionWaiting}):null]}),(0,L.jsx)(go,{})]}),d?(0,L.jsx)(MO,{error:d,onReload:o,onUpgrade:s}):null,(0,L.jsxs)(`div`,{className:j(`relative`,Me&&`mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0`),children:[te?(0,L.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 z-10 px-3 pb-1`,children:te}):null,(0,L.jsxs)(Wf,{accept:S,fileInputLabel:k.uploadFiles,maxFileSize:C,onSubmit:Qe,onError:e=>{console.warn(`[plugin-chatbot] prompt-input error`,e)},children:[x?(0,L.jsx)(Gf,{children:(0,L.jsx)(Hf,{children:e=>(0,L.jsx)(Vf,{data:e})})}):null,(0,L.jsx)(Kf,{placeholder:n,disabled:c||je===`streaming`,onChange:ne?e=>ne(e.currentTarget.value):void 0}),(0,L.jsxs)(qf,{children:[(0,L.jsxs)(Jf,{children:[x?(0,L.jsxs)(Xf,{children:[(0,L.jsx)(Zf,{}),(0,L.jsx)(Qf,{children:(0,L.jsx)(Uf,{})})]}):null,E&&E.length>0?(0,L.jsx)(`select`,{"aria-label":k.model,value:D??E[0].id,onChange:e=>ee?.(e.target.value),className:`h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:E.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.label??e.id,e.provider?` · ${e.provider}`:``]},e.id))}):null,(0,L.jsxs)(`span`,{className:`hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex`,"aria-hidden":`true`,children:[(0,L.jsx)(`kbd`,{className:`inline-flex h-4 items-center rounded border bg-muted px-1 font-mono text-[10px] leading-none`,children:`⌘`}),(0,L.jsx)(pe,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{className:`opacity-70`,children:k.sendHint})]})]}),(0,L.jsx)($f,{"aria-label":je===`streaming`?k.stopResponse:k.submit,status:je,disabled:c,onClick:je===`streaming`?a:void 0,type:je===`streaming`?`button`:`submit`})]})]})]})]})});vO.displayName=`ChatbotEnhanced`;function yO({isUser:e,url:t,fallback:n}){return(0,L.jsx)(`div`,{className:j(`mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium`,e?`bg-secondary text-secondary-foreground`:`bg-primary/10 text-primary`),"aria-hidden":`true`,children:t?(0,L.jsx)(`img`,{src:t,alt:``,className:`size-full object-cover`}):e?n?.trim()?.charAt(0)?.toUpperCase()||`U`:(0,L.jsx)(ht,{className:`size-4`})})}function bO({showAvatar:e,assistantAvatarUrl:t,assistantAvatarFallback:n,waitingLabel:r}){return(0,L.jsx)(Sf,{from:`assistant`,"aria-live":`polite`,children:(0,L.jsxs)(`div`,{className:j(`flex w-full gap-2.5`,e?`flex-row items-start`:`flex-col`),children:[e?(0,L.jsx)(yO,{isUser:!1,url:t,fallback:n}):null,(0,L.jsx)(Cf,{className:`rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(xO,{}),(0,L.jsx)(TO,{active:!0,pending:!0,activityKey:0,waitingLabel:r})]})})]})})}function xO(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`Assistant is responding`}),(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current animate-pulse`}),(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current animate-pulse`}),(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current animate-pulse`})]})]})}function SO(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}var CO=6;function wO(e,t){let n=F.useRef(0),r=F.useRef(0),[i,a]=F.useState({elapsed:0,quiet:0});return F.useEffect(()=>{let e=Date.now();n.current=e,r.current=e},[]),F.useEffect(()=>{let e=Date.now();r.current=e,a({elapsed:Math.floor((e-n.current)/1e3),quiet:0})},[t]),F.useEffect(()=>{if(!e)return;let t=()=>{let e=Date.now();a({elapsed:Math.floor((e-n.current)/1e3),quiet:Math.floor((e-r.current)/1e3)})};t();let i=setInterval(t,1e3);return()=>clearInterval(i)},[e]),{elapsedSeconds:i.elapsed,quietSeconds:i.quiet,live:i.quiet<CO}}function TO({active:e,activityKey:t,pending:n=!1,waitingLabel:r}){let{elapsedSeconds:i,quietSeconds:a,live:o}=wO(e,t),s=o?n?`waiting`:`receiving`:`stalled`;return(0,L.jsxs)(`span`,{className:j(`inline-flex items-center gap-1.5 text-xs font-normal tabular-nums`,s===`stalled`?`text-amber-600`:`text-muted-foreground`),"aria-live":`polite`,title:s===`receiving`?`Receiving from server · ${SO(i)} elapsed`:s===`waiting`?`${r} · ${SO(i)} elapsed`:`${r} (${a}s with no response)`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:j(`size-1.5 shrink-0 rounded-full`,s===`receiving`?`bg-emerald-500 animate-pulse`:s===`waiting`?`bg-muted-foreground/50 animate-pulse`:`bg-amber-500`)}),s===`receiving`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(rt,{className:`size-3 shrink-0`,"aria-hidden":!0}),SO(i)]}):s===`waiting`?(0,L.jsx)(`span`,{children:r}):(0,L.jsxs)(`span`,{children:[r,` `,a,`s`]})]})}var EO=[`object`,`view`,`dashboard`,`app`,`seed`],DO={object:`Objects`,view:`Views`,dashboard:`Dashboards`,app:`App`,seed:`Sample data`};function OO({progress:e,onOpenBuiltApp:t,openBuiltAppLabel:n=`Open app`,onPreviewDraftApp:r,previewDraftLabel:i=`Preview`,waitingLabel:a=`Waiting for server…`}){let{phase:o,appLabel:s,items:c,done:l,total:u,seq:d}=e,f=o===`done`,p=d??`${o}:${l}:${c.length}`,m=c.find(e=>e.type===`app`),h=u>0?Math.min(100,Math.round(l/u*100)):f?100:6,g=new Map;for(let e of c){let t=g.get(e.type)??[];t.push(e.name.replace(/_sample$/,``)),g.set(e.type,t)}let _=[...EO.filter(e=>g.has(e)),...[...g.keys()].filter(e=>!EO.includes(e))];return(0,L.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-3 text-sm`,"data-testid":`build-progress`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[f?(0,L.jsx)($e,{className:`size-4 shrink-0 text-emerald-600`}):(0,L.jsx)(_e,{className:`size-4 shrink-0 animate-spin text-primary`}),(0,L.jsx)(`span`,{children:f?`Built ${s??`your app`}`:`Building ${s??`your app`}…`}),!f&&o===`data`?(0,L.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`adding sample data`}):null,f?null:(0,L.jsx)(`span`,{className:`ml-auto`,children:(0,L.jsx)(TO,{active:!0,activityKey:p,waitingLabel:a})})]}),(0,L.jsx)(`div`,{className:`mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,L.jsx)(`div`,{className:j(`h-full rounded-full transition-all duration-500`,f?`bg-emerald-500`:`bg-primary`),style:{width:`${h}%`}})}),(0,L.jsx)(`ul`,{className:`space-y-1`,children:_.map(e=>{let t=g.get(e);return(0,L.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,L.jsx)($e,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600`}),(0,L.jsxs)(`span`,{className:`min-w-0 text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:DO[e]??e}),` `,t.slice(0,6).join(`, `),t.length>6?` +${t.length-6} more`:``]})]},e)})}),f&&m&&(t||r)?(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[t?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(m.name),className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`build-progress-open-app`,children:[n,(0,L.jsx)(Be,{className:`size-3.5`})]}):null,r?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(m.name),className:`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted`,"data-testid":`build-progress-preview-app`,children:[(0,L.jsx)(xe,{className:`size-3.5`}),i]}):null]}):null]})}function kO({groups:e,labels:t}){return e.length===0?null:(0,L.jsx)(`div`,{className:`not-prose mb-2 border-l border-border/70 pl-3`,children:(0,L.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`flex min-h-6 items-center justify-between gap-3 text-xs`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(AO,{state:e.state}),(0,L.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.title}),e.count>1?(0,L.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:[`x`,e.count]}):null]}),(0,L.jsx)(`span`,{className:j(`shrink-0 text-[10px] font-medium`,e.state===`failed`?`text-destructive`:e.state===`completed`?`text-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),children:jO(e.state,t)})]},e.key))})})}function AO({state:e}){return e===`failed`?(0,L.jsx)(qe,{className:`size-3.5 shrink-0 text-destructive`}):e===`completed`?(0,L.jsx)($e,{className:`size-3.5 shrink-0 text-emerald-600`}):(0,L.jsx)(rt,{className:`size-3.5 shrink-0 text-muted-foreground`})}function jO(e,t){switch(e){case`failed`:return t.toolFailed;case`awaiting`:return t.toolAwaitingApproval;case`running`:return t.toolRunning;case`completed`:return t.toolCompleted}}function MO({error:e,onReload:t,onUpgrade:n}){let r=F.useMemo(()=>Qa(e),[e]),{summary:i,details:a}=F.useMemo(()=>Xa(e),[e]),[o,s]=F.useState(!1);if(r){let e=typeof navigator<`u`&&!!navigator.language?.toLowerCase().startsWith(`zh`),t=(e?r.message:r.messageEn??r.message)||(e?`AI 额度已用完。`:`You have reached your AI quota.`),i=r.topUp?e?`购买额度包`:`Buy a credit pack`:e?`升级方案`:`Upgrade plan`;return(0,L.jsx)(`div`,{className:`border-t bg-background px-3 py-2 text-sm`,role:`alert`,children:(0,L.jsx)(`div`,{className:`rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`font-medium leading-snug text-foreground`,children:e?`需要升级`:`Upgrade needed`}),(0,L.jsx)(`div`,{className:`mt-0.5 break-words leading-snug text-muted-foreground`,children:t})]}),n?(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex h-7 shrink-0 items-center rounded-md border border-amber-400/50 bg-background px-2 text-xs font-medium text-amber-700 hover:bg-amber-100/60 dark:text-amber-300`,children:i}):null]})})})}return(0,L.jsx)(`div`,{className:`border-t bg-background px-3 py-2 text-sm`,role:`alert`,children:(0,L.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-foreground`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(Dt,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`font-medium leading-snug text-destructive`,children:`Response failed`}),(0,L.jsx)(`div`,{className:`mt-0.5 break-words leading-snug text-muted-foreground`,children:i||`Something went wrong. Please try again.`})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[a?(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`inline-flex h-7 items-center rounded-md px-2 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-foreground`,"aria-expanded":o,children:o?`Hide`:`Details`}):null,t?(0,L.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex h-7 items-center rounded-md border border-destructive/30 bg-background px-2 text-xs font-medium text-destructive hover:bg-destructive/10`,children:[(0,L.jsx)(oe,{className:`mr-1 h-3 w-3`}),`Retry`]}):null]})]}),o&&a?(0,L.jsx)(`pre`,{className:`mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border bg-background px-2 py-1 font-mono text-[11px] leading-snug text-muted-foreground`,children:a}):null]})})}function NO({output:e,errorText:t}){return t?(0,L.jsx)(w_,{output:void 0,errorText:t}):e==null||e===``?null:typeof e==`string`&&!fO(e)?(0,L.jsxs)(`div`,{className:`space-y-2 p-4`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Result`}),(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground`,children:(0,L.jsx)(Ef,{children:e})})]}):(0,L.jsx)(w_,{output:e,errorText:void 0})}function PO({floatingConfig:e,headerExtra:t,headerActions:n,...r}){let{position:i=`bottom-right`,defaultOpen:a=!1,panelWidth:o=400,panelHeight:s=520,title:c=`Chat`,triggerSize:l=56}=e??{},[u,d]=F.useState(null);F.useEffect(()=>{let e=document.getElementById(`floating-chatbot-portal`);return e||(e=document.createElement(`div`),e.id=`floating-chatbot-portal`,document.body.appendChild(e)),d(e),()=>{e&&e.parentNode&&!e.hasChildNodes()&&e.parentNode.removeChild(e)}},[]);let f=(0,L.jsxs)(Pa,{defaultOpen:a,children:[(0,L.jsx)(Ba,{position:i,size:l}),(0,L.jsx)(Ka,{title:c,position:i,width:o,height:s,headerExtra:t,headerActions:n,children:(0,L.jsx)(vO,{...r,maxHeight:`100%`,className:`h-full border-0 rounded-none`})})]});return u?wl.createPortal(f,u):f}u.register(`chatbot`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:i,sendMessage:a}=Oa({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,L.jsx)(QO,{messages:r,placeholder:e.placeholder,onSendMessage:e=>{a(e)},disabled:e.disabled||i,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`,description:`Array of message objects with id, role, content, and optional timestamp`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`,description:`URL of the user avatar image`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`,description:`Fallback text shown when user avatar image is not available`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`,description:`URL of the assistant avatar image`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`,description:`Fallback text shown when assistant avatar image is not available`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint (e.g., /api/v1/ai/chat). When set, enables streaming AI mode.`},{name:`conversationId`,type:`string`,label:`Conversation ID`,description:`Multi-turn conversation identifier`},{name:`systemPrompt`,type:`string`,label:`System Prompt`,description:`System prompt to configure assistant behavior`},{name:`model`,type:`string`,label:`AI Model`,description:`AI model identifier (e.g., gpt-4o)`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1,description:`Automatically send a response after user message (for demo purposes, ignored when API is set)`},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),u.register(`chatbot-enhanced`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:i,error:a,sendMessage:o,stop:s,reload:c,clear:l,isApiMode:u}=Oa({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,L.jsx)(vO,{messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{o(e,t)},onClear:()=>{l(),e.onClear?.()},onStop:u&&i?s:void 0,onReload:u?c:void 0,disabled:e.disabled,isLoading:i,error:a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,processVisibility:e.processVisibility,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Enhanced)`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`processVisibility`,type:`enum`,label:`Agent Process Visibility`,defaultValue:`summary`},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,enableMarkdown:!0,enableFileUpload:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),u.register(`chatbot-floating`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:i,error:a,sendMessage:o,stop:s,reload:c,clear:l,isApiMode:u}=Oa({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,L.jsx)(PO,{floatingConfig:e.floatingConfig,messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{o(e,t)},onClear:()=>{l(),e.onClear?.()},onStop:u&&i?s:void 0,onReload:u?c:void 0,disabled:e.disabled,isLoading:i,error:a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Floating)`,inputs:[{name:`displayMode`,type:`string`,label:`Display Mode`,defaultValue:`floating`,description:`Set to "floating" for FAB widget`},{name:`floatingConfig.position`,type:`string`,label:`FAB Position`,defaultValue:`bottom-right`,description:`bottom-right or bottom-left`},{name:`floatingConfig.defaultOpen`,type:`boolean`,label:`Default Open`,defaultValue:!1},{name:`floatingConfig.panelWidth`,type:`number`,label:`Panel Width`,defaultValue:400},{name:`floatingConfig.panelHeight`,type:`number`,label:`Panel Height`,defaultValue:520},{name:`floatingConfig.title`,type:`string`,label:`Panel Title`,defaultValue:`Chat`},{name:`floatingConfig.triggerSize`,type:`number`,label:`Trigger Size`,defaultValue:56},{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{displayMode:`floating`,floatingConfig:{position:`bottom-right`,defaultOpen:!1,panelWidth:400,panelHeight:520,title:`Chat`,triggerSize:56},messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,enableMarkdown:!0,enableFileUpload:!1,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3}});var FO=`/api/v1/ai`;function IO(e,t,n){let r=e.replace(/\/$/,``),i=new URLSearchParams;if(n)for(let[e,t]of Object.entries(n))t==null||t===``||i.set(e,String(t));let a=i.toString();return`${r}${t}${a?`?${a}`:``}`}async function LO(e,t,n){let r=await fetch(e,{credentials:`include`,...t,headers:{Accept:`application/json`,"Content-Type":`application/json`,...n??{},...t.headers??{}}}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.error?.message??i?.message??i?.error??`${r.status} ${r.statusText}`,t=Error(typeof e==`string`?e:JSON.stringify(e));throw t.status=r.status,t.body=i,t}return i}function RO(e={}){let{apiBase:t=FO,status:n=`pending`,conversationId:r,limit:i,headers:a,pollInterval:o=5e3,enabled:s=!0}=e,[c,l]=F.useState([]),[u,d]=F.useState(0),[f,p]=F.useState(!1),[m,h]=F.useState(void 0),g=F.useRef({apiBase:t,status:n,conversationId:r,limit:i,headers:a});g.current={apiBase:t,status:n,conversationId:r,limit:i,headers:a};let _=F.useCallback(async()=>{let{apiBase:e,status:t,conversationId:n,limit:r,headers:i}=g.current;p(!0),h(void 0);try{let a=await LO(IO(e,`/pending-actions`,{status:t&&t!==`all`?t:void 0,conversationId:n,limit:r}),{method:`GET`},i);l(Array.isArray(a.items)?a.items:[]),d(typeof a.total==`number`?a.total:a.items?.length??0)}catch(e){h(e instanceof Error?e:Error(String(e)))}finally{p(!1)}},[]),v=F.useCallback(async e=>{let{apiBase:t,headers:n}=g.current,r=IO(t,`/pending-actions/${encodeURIComponent(e)}/approve`);try{return await LO(r,{method:`POST`,body:`{}`},n)}finally{_()}},[_]),y=F.useCallback(async(e,t)=>{let{apiBase:n,headers:r}=g.current,i=IO(n,`/pending-actions/${encodeURIComponent(e)}/reject`);try{return await LO(i,{method:`POST`,body:JSON.stringify(t?{reason:t}:{})},r)}finally{_()}},[_]);return F.useEffect(()=>{if(!s||(_(),!o||o<=0))return;let e=setInterval(()=>{_()},o);return()=>clearInterval(e)},[s,o,_,t,n,r,i]),{items:c,total:u,isLoading:f,error:m,refresh:_,approve:v,reject:y}}var zO={pending:{variant:`secondary`,label:`Pending`},approved:{variant:`default`,label:`Approved`},executed:{variant:`default`,label:`Executed`},failed:{variant:`destructive`,label:`Failed`},rejected:{variant:`outline`,label:`Rejected`}};function BO({status:e}){let t=zO[e]??{variant:`outline`,label:e};return(0,L.jsx)(te,{variant:t.variant,children:t.label})}function VO(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Date.now()-t,r=Math.round(n/1e3);if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);if(a<24)return`${a}h ago`;let o=Math.round(a/24);if(o<30)return`${o}d ago`;try{return new Date(e).toLocaleDateString()}catch{return e}}function HO(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function UO({value:e,max:t=320}){let n=typeof e==`string`?e:JSON.stringify(e,null,2);return n==null||n===``?(0,L.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`—`}):(0,L.jsx)(`pre`,{className:`bg-muted/40 rounded text-xs p-2 overflow-auto whitespace-pre-wrap break-all`,style:{maxHeight:t},children:n})}function WO(e){switch(e){case`pending`:return`pending`;case`all`:return`all`;case`decided`:return`all`}}function GO({apiBase:e,headers:t,pollInterval:n=5e3,conversationId:r,variant:i=`card`,title:a=`AI Approvals`,description:o=`Actions an AI agent proposed that need a human review before execution.`,className:s}){let[c,l]=F.useState(`pending`),[u,d]=F.useState(null),[f,p]=F.useState(null),[m,h]=F.useState(``),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(null),{items:S,isLoading:C,error:w,refresh:T,approve:E,reject:D}=RO({apiBase:e,headers:t,pollInterval:n,conversationId:r,status:WO(c)}),ee=F.useMemo(()=>c===`decided`?S.filter(e=>e.status!==`pending`):S,[S,c]),O=F.useMemo(()=>u?S.find(e=>e.id===u)??null:null,[u,S]),te=F.useCallback(async e=>{_(e),y(null);try{let t=await E(e),n=t.status===`executed`;x({id:e,kind:`approve`,ok:n,message:n?`Executed`:t.error??`Action failed during execution`})}catch(t){let n=t instanceof Error?t.message:String(t);y(n),x({id:e,kind:`approve`,ok:!1,message:n})}finally{_(null)}},[E]),ne=F.useCallback(async(e,t)=>{_(e),y(null);try{await D(e,t.trim()||void 0),x({id:e,kind:`reject`,ok:!0,message:`Rejected`}),p(null),h(``)}catch(t){let n=t instanceof Error?t.message:String(t);y(n),x({id:e,kind:`reject`,ok:!1,message:n})}finally{_(null)}},[D]),ie=(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(dt,{value:c,onValueChange:e=>l(e),children:(0,L.jsxs)(it,{children:[(0,L.jsx)(He,{value:`pending`,children:`Pending`}),(0,L.jsx)(He,{value:`decided`,children:`Decided`}),(0,L.jsx)(He,{value:`all`,children:`All`})]})}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:C,"data-testid":`ai-inbox-refresh`,children:[(0,L.jsx)(oe,{className:`h-3.5 w-3.5 mr-1.5 ${C?`animate-spin`:``}`}),`Refresh`]})]}),w?(0,L.jsxs)(_t,{variant:`destructive`,children:[(0,L.jsx)(Dt,{className:`h-4 w-4`}),(0,L.jsx)(nt,{children:w.message})]}):null,v?(0,L.jsxs)(_t,{variant:`destructive`,children:[(0,L.jsx)(Dt,{className:`h-4 w-4`}),(0,L.jsx)(nt,{children:v})]}):null,b&&!v?(0,L.jsxs)(_t,{variant:b.ok?`default`:`destructive`,children:[b.ok?(0,L.jsx)($e,{className:`h-4 w-4`}):(0,L.jsx)(qe,{className:`h-4 w-4`}),(0,L.jsxs)(nt,{children:[b.kind===`approve`?`Approve`:`Reject`,` for`,` `,(0,L.jsxs)(`code`,{className:`text-xs`,children:[b.id.slice(0,8),`…`]}),`:`,` `,b.message??(b.ok?`OK`:`Failed`)]})]}):null,C&&ee.length===0?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(ve,{className:`h-10 w-full`}),(0,L.jsx)(ve,{className:`h-10 w-full`}),(0,L.jsx)(ve,{className:`h-10 w-full`})]}):ee.length===0?(0,L.jsx)(we,{children:(0,L.jsxs)(re,{children:[(0,L.jsx)(Me,{children:(0,L.jsx)(Fe,{className:`h-8 w-8 text-muted-foreground`})}),(0,L.jsx)(ue,{children:`No actions waiting`}),(0,L.jsx)(Ot,{children:`When the AI proposes a sensitive action it will appear here for review.`})]})}):(0,L.jsx)(`div`,{className:`rounded-md border`,children:(0,L.jsxs)(pt,{children:[(0,L.jsx)(Tt,{children:(0,L.jsxs)(Ye,{children:[(0,L.jsx)(ct,{className:`w-[140px]`,children:`Tool`}),(0,L.jsx)(ct,{className:`w-[140px]`,children:`Action`}),(0,L.jsx)(ct,{className:`w-[120px]`,children:`Object`}),(0,L.jsx)(ct,{className:`w-[110px]`,children:`Status`}),(0,L.jsx)(ct,{className:`w-[110px]`,children:`Proposed`}),(0,L.jsx)(ct,{className:`w-[260px] text-right`,children:`Decision`})]})}),(0,L.jsx)(xt,{children:ee.map(e=>{let t=e.status===`pending`,n=g===e.id;return(0,L.jsxs)(Ye,{children:[(0,L.jsx)(Je,{className:`font-mono text-xs`,children:e.tool_name}),(0,L.jsx)(Je,{className:`text-sm`,children:e.action_name}),(0,L.jsx)(Je,{className:`text-sm`,children:e.object_name}),(0,L.jsx)(Je,{children:(0,L.jsx)(BO,{status:e.status})}),(0,L.jsx)(Je,{className:`text-xs text-muted-foreground`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(vt,{className:`h-3 w-3`}),` `,VO(e.proposed_at)]})}),(0,L.jsx)(Je,{className:`text-right`,children:(0,L.jsxs)(`div`,{className:`inline-flex gap-1.5`,children:[(0,L.jsxs)(A,{size:`sm`,variant:`ghost`,onClick:()=>d(e.id),"data-testid":`ai-inbox-view-${e.id}`,children:[(0,L.jsx)(xe,{className:`h-3.5 w-3.5 mr-1`}),` View`]}),t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(A,{size:`sm`,variant:`default`,disabled:n,onClick:()=>void te(e.id),"data-testid":`ai-inbox-approve-${e.id}`,children:[(0,L.jsx)($e,{className:`h-3.5 w-3.5 mr-1`}),n?`Working…`:`Approve`]}),(0,L.jsxs)(A,{size:`sm`,variant:`destructive`,disabled:n,onClick:()=>{p(e.id),h(``)},"data-testid":`ai-inbox-reject-${e.id}`,children:[(0,L.jsx)(qe,{className:`h-3.5 w-3.5 mr-1`}),`Reject`]})]}):null]})})]},e.id)})})]})})]});return(0,L.jsxs)(L.Fragment,{children:[i===`card`?(0,L.jsxs)(mt,{className:s,children:[(0,L.jsxs)(k,{className:`pb-3`,children:[(0,L.jsxs)(Re,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ht,{className:`h-4 w-4`}),` `,a]}),o?(0,L.jsx)(Ie,{children:o}):null]}),(0,L.jsx)(fe,{children:ie})]}):(0,L.jsx)(`div`,{className:s,children:ie}),(0,L.jsx)(Se,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,L.jsxs)(se,{className:`sm:max-w-[560px] overflow-y-auto`,children:[(0,L.jsxs)(ge,{children:[(0,L.jsxs)(Ee,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ht,{className:`h-4 w-4`}),O?O.action_name:`Pending action`]}),(0,L.jsx)(de,{children:O?(0,L.jsxs)(L.Fragment,{children:[`Tool `,(0,L.jsx)(`code`,{className:`text-xs`,children:O.tool_name}),` on`,` `,(0,L.jsx)(`code`,{className:`text-xs`,children:O.object_name})]}):`Loading…`})]}),O?(0,L.jsxs)(`div`,{className:`px-4 space-y-4 mt-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs text-muted-foreground`,children:`Status`}),(0,L.jsx)(`div`,{className:`mt-1`,children:(0,L.jsx)(BO,{status:O.status})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs text-muted-foreground`,children:`Proposed`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs`,children:VO(O.proposed_at)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs text-muted-foreground`,children:`Proposed by`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs font-mono break-all`,children:O.proposed_by??`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs text-muted-foreground`,children:`Decided by`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs font-mono break-all`,children:O.decided_by??`—`})]}),O.conversation_id?(0,L.jsxs)(`div`,{className:`col-span-2`,children:[(0,L.jsx)(ft,{className:`text-xs text-muted-foreground`,children:`Conversation`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs font-mono break-all`,children:O.conversation_id})]}):null]}),(0,L.jsx)(kt,{}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs`,children:`Tool input`}),(0,L.jsx)(`div`,{className:`mt-1.5`,children:(0,L.jsx)(UO,{value:HO(O.tool_input)})})]}),O.result?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs`,children:`Result`}),(0,L.jsx)(`div`,{className:`mt-1.5`,children:(0,L.jsx)(UO,{value:HO(O.result)})})]}):null,O.error?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs text-destructive`,children:`Error`}),(0,L.jsx)(`div`,{className:`mt-1.5`,children:(0,L.jsx)(UO,{value:O.error})})]}):null,O.rejection_reason?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ft,{className:`text-xs`,children:`Rejection reason`}),(0,L.jsx)(`div`,{className:`mt-1.5 text-sm`,children:O.rejection_reason})]}):null,O.status===`pending`?(0,L.jsxs)(`div`,{className:`pt-2 flex gap-2`,children:[(0,L.jsxs)(A,{size:`sm`,onClick:()=>void te(O.id),disabled:g===O.id,children:[(0,L.jsx)($e,{className:`h-3.5 w-3.5 mr-1`}),`Approve & Execute`]}),(0,L.jsxs)(A,{size:`sm`,variant:`destructive`,onClick:()=>{p(O.id),h(``)},disabled:g===O.id,children:[(0,L.jsx)(qe,{className:`h-3.5 w-3.5 mr-1`}),`Reject`]})]}):null]}):null]})}),(0,L.jsx)(Se,{open:!!f,onOpenChange:e=>{e||(p(null),h(``))},children:(0,L.jsxs)(se,{side:`bottom`,className:`max-h-[40vh]`,children:[(0,L.jsxs)(ge,{children:[(0,L.jsx)(Ee,{children:`Reject this action?`}),(0,L.jsx)(de,{children:`The reason is shown back to the AI so it can adjust its next response.`})]}),(0,L.jsxs)(`div`,{className:`px-4 mt-3 space-y-3`,children:[(0,L.jsx)(Ct,{value:m,onChange:e=>h(e.target.value),placeholder:`Optional reason (e.g. 'Wrong record id — please confirm with the user first.')`,rows:4,"data-testid":`ai-inbox-reject-reason`}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>{p(null),h(``)},children:`Cancel`}),(0,L.jsxs)(A,{variant:`destructive`,size:`sm`,onClick:()=>f&&void ne(f,m),disabled:!f||g===f,"data-testid":`ai-inbox-reject-confirm`,children:[(0,L.jsx)(qe,{className:`h-3.5 w-3.5 mr-1`}),`Reject`]})]})]})]})})]})}function KO(e){return!e||e.length===0?`/api/v1/ai`:e.endsWith(`/`)?e.slice(0,-1):e}function qO(e,t){let n={...e??{}};return t&&(n[`Content-Type`]=`application/json`),n}async function JO(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return{raw:t}}}function YO(e){let{messages:t,apiBase:n,headers:r,onDecided:i,continueConversation:a}=e,o=KO(n),s=F.useMemo(()=>{let e=new Map;for(let n of t){let t=n.toolInvocations??[];for(let n of t)n.pendingActionId&&n.toolCallId&&e.set(n.toolCallId,{pendingActionId:n.pendingActionId,toolName:n.toolName})}return e},[t]),[c,l]=F.useState({}),u=F.useRef(0),[d,f]=F.useState(!1),p=F.useCallback((e,t)=>{l(n=>{if(!t){if(!(e in n))return n;let{[e]:t,...r}=n;return r}return{...n,[e]:t}})},[]);return{decisions:c,decide:F.useCallback(async(e,t,n)=>{let c=s.get(e);if(!c){p(e,{state:`error`,message:`No pending-action id found for this tool call. The tool result may not be a HITL proposal.`});return}let{pendingActionId:l,toolName:d}=c;p(e,{state:`pending`,message:t?`Approving…`:`Rejecting…`}),u.current+=1,f(!0);try{let s=`${o}/pending-actions/${encodeURIComponent(l)}/${t?`approve`:`reject`}`,c=t?`{}`:JSON.stringify({reason:n??``}),u=await fetch(s,{method:`POST`,credentials:`include`,headers:qO(r,!0),body:c}),f=await JO(u)??{};if(!u.ok){let t=typeof f.error==`string`?f.error:`Approval failed: HTTP ${u.status}`;p(e,{state:`error`,message:t}),i?.(e,{id:l,status:`failed`,error:t});return}let m=f.status??(t?`executed`:`rejected`),h=!1;if(m===`executed`?(p(e,{state:`success`,message:`Approved — action executed.`}),h=!0):m===`rejected`?(p(e,{state:`success`,message:n?`Rejected: ${n}`:`Rejected.`}),h=!0):m===`failed`?p(e,{state:`error`,message:f.error??`Action approved but execution failed.`}):(p(e,{state:`success`,message:`Status: ${m}`}),h=!0),i?.(e,f),h&&a){let r=XO({approved:t,status:m,toolName:d,pendingActionId:l,outcome:f,reason:n});r&&a(r,{toolCallId:e,pendingActionId:l,decision:t?`approved`:`rejected`,outcome:f,toolName:d})}}catch(t){p(e,{state:`error`,message:t instanceof Error?t.message:String(t)})}finally{--u.current,u.current<=0&&(u.current=0,f(!1))}},[o,r,s,i,a,p]),isDeciding:d}}function XO(e){let{approved:t,status:n,toolName:r,pendingActionId:i,outcome:a,reason:o}=e,s=`[HITL ${i}]`;if(t&&n===`executed`){let e=a.result;return`${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e==null?`(no payload)`:typeof e==`string`?e:ZO(JSON.stringify(e),800)}. Acknowledge the outcome concisely and continue the user's task.`}if(!t&&n===`rejected`)return`${s} The operator rejected the \`${r}\` call.${o&&o.trim().length>0?` Reason: ${o}.`:``} Acknowledge the rejection and ask whether to try a different approach.`;if(n===`failed`){let e=a.error;return`${s} The \`${r}\` call was approved but execution failed: ${typeof e==`string`?e:ZO(JSON.stringify(e??{}),400)}. Apologize concisely and offer alternatives.`}}function ZO(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var QO=F.forwardRef(({className:e,messages:t=[],placeholder:n=`Type your message...`,onSendMessage:r,disabled:i=!1,showTimestamp:a=!1,userAvatarUrl:o,userAvatarFallback:s=`You`,assistantAvatarUrl:c,assistantAvatarFallback:l=`AI`,maxHeight:u=`500px`,...d},f)=>{let[p,m]=F.useState(``),h=F.useRef(null),g=F.useRef(null);F.useEffect(()=>{if(h.current){let e=h.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[t]);let _=()=>{p.trim()&&r&&(r(p.trim()),m(``),g.current?.focus())},v=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),_())};return(0,L.jsxs)(`div`,{ref:f,className:j(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:u},...d,children:[(0,L.jsx)(le,{ref:h,className:`flex-1 p-4`,children:(0,L.jsx)(`div`,{className:`space-y-4`,children:t.length===0?(0,L.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No messages yet. Start a conversation!`}):t.map(e=>(0,L.jsx)($O,{message:e,showTimestamp:a,userAvatarUrl:o,userAvatarFallback:s,assistantAvatarUrl:c,assistantAvatarFallback:l},e.id))})}),(0,L.jsx)(`div`,{className:`border-t p-4`,children:(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(lt,{ref:g,value:p,onChange:e=>m(e.target.value),onKeyDown:v,placeholder:n,disabled:i,className:`flex-1`}),(0,L.jsx)(A,{onClick:_,disabled:i||!p.trim(),size:`icon`,children:(0,L.jsx)(Et,{className:`h-4 w-4`})})]})})]})});QO.displayName=`Chatbot`;var $O=({message:e,showTimestamp:t,userAvatarUrl:n,userAvatarFallback:r,assistantAvatarUrl:i,assistantAvatarFallback:a})=>{let o=e.role===`user`;if(e.role===`system`)return(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full`,children:e.content})});let s=o?e.avatar||n:e.avatar||i,c=o?e.avatarFallback||r:e.avatarFallback||a;return(0,L.jsxs)(`div`,{className:j(`flex gap-3`,o?`flex-row-reverse`:`flex-row`),children:[(0,L.jsxs)(Xe,{className:`h-8 w-8`,children:[(0,L.jsx)(ut,{src:s}),(0,L.jsx)(St,{className:`text-xs`,children:c})]}),(0,L.jsxs)(`div`,{className:j(`flex flex-col gap-1`,o?`items-end`:`items-start`),children:[(0,L.jsx)(`div`,{className:j(`rounded-lg px-4 py-2 max-w-[70%] break-words`,o?`bg-primary text-primary-foreground`:`bg-muted`),children:(0,L.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.content})}),t&&e.timestamp&&(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.timestamp})]})]})},ek=F.forwardRef(({className:e,avatarSrc:t,avatarFallback:n=`AI`,...r},i)=>(0,L.jsxs)(`div`,{ref:i,className:j(`flex gap-3`,e),...r,children:[(0,L.jsxs)(Xe,{className:`h-8 w-8`,children:[(0,L.jsx)(ut,{src:t}),(0,L.jsx)(St,{className:`text-xs`,children:n})]}),(0,L.jsx)(`div`,{className:`flex items-center bg-muted rounded-lg px-4 py-2`,children:(0,L.jsxs)(`div`,{className:`flex gap-1`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]`}),(0,L.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]`}),(0,L.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce`})]})})]}));ek.displayName=`TypingIndicator`;export{uO as a,_f as c,Ma as d,Oa as f,Ta as h,vO as i,xf as l,_a as m,GO as n,Yl as o,ya as p,PO as r,Cu as s,YO as t,Aa as u};
117
+ `})}return n},df=/([\\`*_~[\]|])/g,ff=e=>e.replace(df,`\\$1`),pf=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>t+ff(n).replace(/\n\n/g,`&#10;&#10;`)+r)}return n},mf=e=>e.type===`text`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(mf).join(``):``,hf=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(e=>e.toLowerCase()));Yt(t,`element`,e=>{if(n.has(e.tagName.toLowerCase())){let t=mf(e);e.children=t?[{type:`text`,value:t}]:[]}})},gf=()=>e=>{Yt(e,`code`,e=>{e.meta&&(e.data=e.data??{},e.data.hProperties={...e.data.hProperties??{},metastring:e.meta})})},_f=/^[ \t]*<[\w!/?-]/,vf=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,yf=e=>typeof e!=`string`||e.length===0||!_f.test(e)?e:e.replace(vf,`$1`),bf={...Ut,protocols:{...Ut.protocols,href:[...Ut.protocols?.href??[],`tel`]},attributes:{...Ut.attributes,code:[...Ut.attributes?.code??[],`metastring`]}},xf={raw:Ht,sanitize:[Gt,bf],harden:[Lt,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],allowedProtocols:[`*`],defaultOrigin:void 0,allowDataImages:!0}]},Sf={gfm:[Kt,{}],codeMeta:gf},Cf=Object.values(xf),wf=Object.values(Sf),Tf={block:` ▋`,circle:` ●`},Ef=[`github-light`,`github-dark`],Df={enabled:!0},Of=(0,F.createContext)({shikiTheme:Ef,controls:!0,isAnimating:!1,lineNumbers:!0,mode:`streaming`,mermaid:void 0,linkSafety:Df}),kf=(0,F.memo)(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:r,isIncomplete:i,dir:a,animatePlugin:o,...s})=>{if(o){let e=o.getLastRenderCharCount();o.setPrevContentLength(e)}let c=typeof e==`string`&&n?yf(e):e,l=(0,L.jsx)(Hd,{...s,children:c});return(0,L.jsx)(Zl.Provider,{value:i,children:a?(0,L.jsx)(`div`,{dir:a,style:{display:`contents`},children:l}):l})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),r=Object.keys(t.components||{});if(n.length!==r.length||n.some(n=>e.components?.[n]!==t.components?.[n]))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});kf.displayName=`Block`;var Af=(0,F.memo)(({children:e,mode:t=`streaming`,dir:n,parseIncompleteMarkdown:r=!0,normalizeHtmlIndentation:i=!1,components:a,rehypePlugins:o=Cf,remarkPlugins:s=wf,className:c,shikiTheme:l=Ef,mermaid:u,controls:d=!0,isAnimating:f=!1,animated:p,BlockComponent:m=kf,parseMarkdownIntoBlocksFn:h=lf,caret:g,plugins:_,remend:v,linkSafety:y=Df,lineNumbers:b=!0,allowedTags:x,literalTagContent:S,translations:C,icons:w,prefix:T,onAnimationStart:E,onAnimationEnd:D,...ee})=>{let O=(0,F.useId)(),[te,ne]=(0,F.useTransition)(),re=(0,F.useMemo)(()=>tu(T),[T]),ie=(0,F.useRef)(null),ae=(0,F.useRef)(E),oe=(0,F.useRef)(D);ae.current=E,oe.current=D,(0,F.useEffect)(()=>{var e,n,r;if(t===`static`)return;let i=ie.current;if(ie.current=f,i===null){f&&((e=ae.current)==null||e.call(ae));return}f&&!i?(n=ae.current)==null||n.call(ae):!f&&i&&((r=oe.current)==null||r.call(oe))},[f,t]);let se=(0,F.useMemo)(()=>x?Object.keys(x):[],[x]),ce=(0,F.useMemo)(()=>{if(typeof e!=`string`)return``;let n=t===`streaming`&&r?oc(e,v):e;return S&&S.length>0&&(n=pf(n,S)),se.length>0&&(n=uf(n,se)),n},[e,t,r,v,se,S]),le=(0,F.useMemo)(()=>h(ce),[ce,h]),[ue,de]=(0,F.useState)(le);(0,F.useEffect)(()=>{t===`streaming`&&!ge?ne(()=>{de(le)}):de(le)},[le,t]);let fe=t===`streaming`?ue:le,pe=(0,F.useMemo)(()=>n===`auto`?fe.map(Md):void 0,[fe,n]),me=(0,F.useMemo)(()=>fe.map((e,t)=>`${O}-${t}`),[fe.length,O]),he=(0,F.useMemo)(()=>p===!0?`true`:p?JSON.stringify(p):``,[p]),ge=(0,F.useMemo)(()=>he?he===`true`?Xl():Xl(p):null,[he]),_e=(0,F.useMemo)(()=>({shikiTheme:(_?.code)?.getThemes()??l,controls:d,isAnimating:f,lineNumbers:b,mode:t,mermaid:u,linkSafety:y}),[l,d,f,b,t,u,y,_?.code]),ve=(0,F.useMemo)(()=>({...yu,...C}),[(0,F.useMemo)(()=>C?JSON.stringify(C):``,[C])]),ye=(0,F.useMemo)(()=>{let{inlineCode:e,...t}=a??{},n={...kd,...t};if(e){let t=n.code;n.code=n=>`data-block`in n?t?(0,F.createElement)(t,n):null:(0,F.createElement)(e,n)}return n},[a]),be=(0,F.useMemo)(()=>{let e=[];return _!=null&&_.cjk&&(e=[...e,..._.cjk.remarkPluginsBefore]),e=[...e,...s],_!=null&&_.cjk&&(e=[...e,..._.cjk.remarkPluginsAfter]),_!=null&&_.math&&(e=[...e,_.math.remarkPlugin]),e},[s,_?.math,_?.cjk]),xe=(0,F.useMemo)(()=>{let e=o;if(x&&Object.keys(x).length>0&&o===Cf){let t={...bf,tagNames:[...bf.tagNames??[],...Object.keys(x)],attributes:{...bf.attributes,...x}};e=[xf.raw,[Gt,t],xf.harden]}return S&&S.length>0&&(e=[...e,[hf,S]]),_!=null&&_.math&&(e=[...e,_.math.rehypePlugin]),ge&&f&&(e=[...e,ge.rehypePlugin]),e},[o,_?.math,ge,f,x,S]),Se=(0,F.useMemo)(()=>{if(!f||fe.length===0)return!1;let e=fe.at(-1);return Fd(e)||Id(e)},[f,fe]),Ce=(0,F.useMemo)(()=>g&&f&&!Se?{"--streamdown-caret":`"${Tf[g]}"`}:void 0,[g,f,Se]);return t===`static`?(0,L.jsx)(bu.Provider,{value:ve,children:(0,L.jsx)(Mu.Provider,{value:_??null,children:(0,L.jsx)(Of.Provider,{value:_e,children:(0,L.jsx)(_u,{icons:w,children:(0,L.jsx)(ru.Provider,{value:re,children:(0,L.jsx)(`div`,{className:re(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,c),dir:n===`auto`?Md(ce):n,children:(0,L.jsx)(Hd,{components:ye,rehypePlugins:xe,remarkPlugins:be,...ee,children:ce})})})})})})}):(0,L.jsx)(bu.Provider,{value:ve,children:(0,L.jsx)(Mu.Provider,{value:_??null,children:(0,L.jsx)(Of.Provider,{value:_e,children:(0,L.jsx)(_u,{icons:w,children:(0,L.jsx)(ru.Provider,{value:re,children:(0,L.jsxs)(`div`,{className:re(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,g&&!Se?`[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]`:null,c),style:Ce,children:[fe.length===0&&g&&f&&(0,L.jsx)(`span`,{}),fe.map((e,t)=>{let a=t===fe.length-1,o=f&&a&&Fd(e);return(0,L.jsx)(m,{animatePlugin:ge,components:ye,content:e,dir:pe?.[t]??(n===`auto`?void 0:n),index:t,isIncomplete:o,rehypePlugins:xe,remarkPlugins:be,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:r,...ee},me[t])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Af.displayName=`Streamdown`;var jf=({children:e,className:t,minZoom:n=.5,maxZoom:r=3,zoomStep:i=.1,showControls:a=!0,initialZoom:o=1,fullscreen:s=!1})=>{let{RotateCcwIcon:c,ZoomInIcon:l,ZoomOutIcon:u}=vu(),d=B(),f=(0,F.useRef)(null),p=(0,F.useRef)(null),[m,h]=(0,F.useState)(o),[g,_]=(0,F.useState)({x:0,y:0}),[v,y]=(0,F.useState)(!1),[b,x]=(0,F.useState)({x:0,y:0}),[S,C]=(0,F.useState)({x:0,y:0}),w=(0,F.useCallback)(e=>{h(t=>Math.max(n,Math.min(r,t+e)))},[n,r]),T=(0,F.useCallback)(()=>{w(i)},[w,i]),E=(0,F.useCallback)(()=>{w(-i)},[w,i]),D=(0,F.useCallback)(()=>{h(o),_({x:0,y:0})},[o]),ee=(0,F.useCallback)(e=>{e.preventDefault(),w(e.deltaY>0?-i:i)},[w,i]),O=(0,F.useCallback)(e=>{if(e.button!==0||e.isPrimary===!1)return;y(!0),x({x:e.clientX,y:e.clientY}),C(g);let t=e.currentTarget;t instanceof HTMLElement&&t.setPointerCapture(e.pointerId)},[g]),te=(0,F.useCallback)(e=>{if(!v)return;e.preventDefault();let t=e.clientX-b.x,n=e.clientY-b.y;_({x:S.x+t,y:S.y+n})},[v,b,S]),ne=(0,F.useCallback)(e=>{y(!1);let t=e.currentTarget;t instanceof HTMLElement&&t.releasePointerCapture(e.pointerId)},[]);return(0,F.useEffect)(()=>{let e=f.current;if(e)return e.addEventListener(`wheel`,ee,{passive:!1}),()=>{e.removeEventListener(`wheel`,ee)}},[ee]),(0,F.useEffect)(()=>{let e=p.current;if(e&&v)return document.body.style.userSelect=`none`,e.addEventListener(`pointermove`,te,{passive:!1}),e.addEventListener(`pointerup`,ne),e.addEventListener(`pointercancel`,ne),()=>{document.body.style.userSelect=``,e.removeEventListener(`pointermove`,te),e.removeEventListener(`pointerup`,ne),e.removeEventListener(`pointercancel`,ne)}},[v,te,ne]),(0,L.jsxs)(`div`,{className:d(`relative flex flex-col`,s?`h-full w-full`:`min-h-28 w-full`,t),ref:f,style:{cursor:v?`grabbing`:`grab`},children:[a?(0,L.jsxs)(`div`,{className:d(`absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm`,s?`bottom-4 left-4`:`bottom-2 left-2`),children:[(0,L.jsx)(`button`,{className:d(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:m>=r,onClick:T,title:`Zoom in`,type:`button`,children:(0,L.jsx)(l,{size:16})}),(0,L.jsx)(`button`,{className:d(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:m<=n,onClick:E,title:`Zoom out`,type:`button`,children:(0,L.jsx)(u,{size:16})}),(0,L.jsx)(`button`,{className:d(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`),onClick:D,title:`Reset zoom and pan`,type:`button`,children:(0,L.jsx)(c,{size:16})})]}):null,(0,L.jsx)(`div`,{className:d(`flex-1 origin-center transition-transform duration-150 ease-out`,s?`flex h-full w-full items-center justify-center`:`flex w-full items-center justify-center`),onPointerDown:O,ref:p,role:`application`,style:{transform:`translate(${g.x}px, ${g.y}px) scale(${m})`,transformOrigin:`center center`,touchAction:`none`,willChange:`transform`},children:e})]})},Mf=({chart:e,className:t,config:n,fullscreen:r=!1,showControls:i=!0})=>{let a=B(),[o,s]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(0),{mermaid:g}=(0,F.useContext)(Of),_=Fu(),v=g?.errorComponent,{shouldRender:y,containerRef:b}=zl({immediate:r});if((0,F.useEffect)(()=>{if(y){if(!_){s(`Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.`);return}(async()=>{try{s(null),l(!0);let t=_.getMermaid(n),r=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),i=`mermaid-${Math.abs(r)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:a}=await t.render(i,e);d(a),p(a)}catch(e){f||u||s(e instanceof Error?e.message:`Failed to render Mermaid chart`)}finally{l(!1)}})()}},[e,n,m,y,_]),!(y||u||f))return(0,L.jsx)(`div`,{className:a(`my-4 min-h-[200px]`,t),ref:b});if(c&&!u&&!f)return(0,L.jsx)(`div`,{className:a(`my-4 flex justify-center p-4`,t),ref:b,children:(0,L.jsxs)(`div`,{className:a(`flex items-center space-x-2 text-muted-foreground`),children:[(0,L.jsx)(`div`,{className:a(`h-4 w-4 animate-spin rounded-full border-current border-b-2`)}),(0,L.jsx)(`span`,{className:a(`text-sm`),children:`Loading diagram...`})]})});if(o&&!u&&!f)return v?(0,L.jsx)(`div`,{ref:b,children:(0,L.jsx)(v,{chart:e,error:o,retry:()=>h(e=>e+1)})}):(0,L.jsxs)(`div`,{className:a(`rounded-md bg-red-50 p-4`,t),ref:b,children:[(0,L.jsxs)(`p`,{className:a(`font-mono text-red-700 text-sm`),children:[`Mermaid Error: `,o]}),(0,L.jsxs)(`details`,{className:a(`mt-2`),children:[(0,L.jsx)(`summary`,{className:a(`cursor-pointer text-red-600 text-xs`),children:`Show Code`}),(0,L.jsx)(`pre`,{className:a(`mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs`),children:e})]})]});let x=u||f;return(0,L.jsx)(`div`,{className:a(`size-full`,t),"data-streamdown":`mermaid`,ref:b,children:(0,L.jsx)(jf,{className:a(r?`size-full overflow-hidden`:`overflow-hidden`,t),fullscreen:r,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:(0,L.jsx)(`div`,{"aria-label":`Mermaid chart`,className:a(`flex justify-center`,r?`size-full items-center`:null),dangerouslySetInnerHTML:{__html:x},role:`img`})})})},Nf=({className:e,from:t,...n})=>(0,L.jsx)(`div`,{className:j(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...n}),Pf=({children:e,className:t,...n})=>(0,L.jsx)(`div`,{className:j(`is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm`,`group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground`,`group-[.is-assistant]:text-foreground`,t),...n,children:e}),Ff=({className:e,children:t,...n})=>(0,L.jsx)(`div`,{className:j(`flex items-center gap-1`,e),...n,children:t}),If=({tooltip:e,children:t,label:n,variant:r=`ghost`,size:i=`icon`,...a})=>{let o=(0,L.jsxs)(A,{size:i,type:`button`,variant:r,...a,children:[t,(0,L.jsx)(`span`,{className:`sr-only`,children:n||e})]});return e?(0,L.jsx)(oe,{children:(0,L.jsxs)(Ee,{children:[(0,L.jsx)(st,{asChild:!0,children:o}),(0,L.jsx)(ct,{children:(0,L.jsx)(`p`,{children:e})})]})}):o};(0,F.createContext)(null);var Lf=(0,F.memo)(({className:e,...t})=>(0,L.jsx)(Af,{className:j(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);Lf.displayName=`MessageResponse`;function Rf({className:e,...t}){return(0,L.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:j(`group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30`,`h-9 min-w-0 has-[>textarea]:h-auto`,`has-[>[data-align=inline-start]]:[&>input]:pl-2`,`has-[>[data-align=inline-end]]:[&>input]:pr-2`,`has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3`,`has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3`,`has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50`,`has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40`,e),...t})}var zf=Pt(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]`,"inline-end":`order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]`,"block-start":`order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3`,"block-end":`order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3`}},defaultVariants:{align:`inline-start`}});function Bf({className:e,align:t=`inline-start`,...n}){return(0,L.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:j(zf({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var Vf=Pt(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5`,sm:`h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5`,"icon-xs":`size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function Hf({className:e,type:t=`button`,variant:n=`ghost`,size:r=`xs`,...i}){return(0,L.jsx)(A,{type:t,"data-size":r,variant:n,className:j(Vf({size:r}),e),...i})}function Uf({className:e,...t}){return(0,L.jsx)(wt,{"data-slot":`input-group-control`,className:j(`flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent`,e),...t})}var Wf=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,Gf=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Wf[n[e]&63];return t},Kf=(0,F.createContext)(null),qf=(0,F.createContext)(null),Jf=()=>(0,F.useContext)(Kf),Yf=()=>(0,F.useContext)(qf),Xf=(0,F.createContext)(null),Zf=()=>{let e=Yf(),t=(0,F.useContext)(Xf),n=e??t;if(!n)throw Error(`usePromptInputAttachments must be used within a PromptInput or PromptInputProvider`);return n};function Qf({data:e,className:t,...n}){let r=Zf(),i=e.filename||``,a=(e.mediaType?.startsWith(`image/`)&&e.url?`image`:`file`)==`image`,o=i||(a?`Image`:`Attachment`);return(0,L.jsxs)(dp,{children:[(0,L.jsx)(We,{asChild:!0,children:(0,L.jsxs)(`div`,{className:j(`group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,t),...n,children:[(0,L.jsxs)(`div`,{className:`relative size-5 shrink-0`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0`,children:a?(0,L.jsx)(`img`,{alt:i||`attachment`,className:`size-5 object-cover`,height:20,src:e.url,width:20}):(0,L.jsx)(`div`,{className:`flex size-5 items-center justify-center text-muted-foreground`,children:(0,L.jsx)(ne,{className:`size-3`})})}),(0,L.jsxs)(A,{"aria-label":`Remove attachment`,className:`absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5`,onClick:t=>{t.stopPropagation(),r.remove(e.id)},type:`button`,variant:`ghost`,children:[(0,L.jsx)(le,{}),(0,L.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]}),(0,L.jsx)(`span`,{className:`flex-1 truncate`,children:o})]},e.id)}),(0,L.jsx)(fp,{className:`w-auto p-2`,children:(0,L.jsxs)(`div`,{className:`w-auto space-y-3`,children:[a&&(0,L.jsx)(`div`,{className:`flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border`,children:(0,L.jsx)(`img`,{alt:i||`attachment preview`,className:`max-h-full max-w-full object-contain`,height:384,src:e.url,width:448})}),(0,L.jsx)(`div`,{className:`flex items-center gap-2.5`,children:(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 px-0.5`,children:[(0,L.jsx)(`h4`,{className:`truncate font-semibold text-sm leading-none`,children:i||(a?`Image`:`Attachment`)}),e.mediaType&&(0,L.jsx)(`p`,{className:`truncate font-mono text-muted-foreground text-xs`,children:e.mediaType})]})})]})})]})}function $f({children:e,className:t,...n}){let r=Zf();return r.files.length?(0,L.jsx)(`div`,{className:j(`flex flex-wrap items-center gap-2 p-3 w-full`,t),...n,children:r.files.map(t=>(0,L.jsx)(F.Fragment,{children:e(t)},t.id))}):null}var ep=({label:e=`Add photos or files`,...t})=>{let n=Zf();return(0,L.jsxs)(Tt,{...t,onSelect:e=>{e.preventDefault(),n.openFileDialog()},children:[(0,L.jsx)(St,{className:`mr-2 size-4`}),` `,e]})},tp=({className:e,accept:t,multiple:n,fileInputLabel:r=`Upload files`,globalDrop:i,syncHiddenInput:a,maxFiles:o,maxFileSize:s,onError:c,onSubmit:l,children:u,...d})=>{let f=Jf(),p=!!f,m=(0,F.useRef)(null),h=(0,F.useRef)(null),[g,_]=(0,F.useState)([]),v=p?f.attachments.files:g,y=(0,F.useRef)(v);y.current=v;let b=(0,F.useCallback)(()=>{m.current?.click()},[]),x=(0,F.useCallback)(e=>!t||t.trim()===``?!0:t.split(`,`).map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith(`/*`)){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t}),[t]),S=(0,F.useCallback)(e=>{let t=Array.from(e),n=t.filter(e=>x(e));if(t.length&&n.length===0){c?.({code:`accept`,message:`No files match the accepted types.`});return}let r=n.filter(e=>s?e.size<=s:!0);if(n.length>0&&r.length===0){c?.({code:`max_file_size`,message:`All files exceed the maximum size.`});return}_(e=>{let t=typeof o==`number`?Math.max(0,o-e.length):void 0,n=typeof t==`number`?r.slice(0,t):r;typeof t==`number`&&r.length>t&&c?.({code:`max_files`,message:`Too many files. Some were not added.`});let i=[];for(let e of n)i.push({id:Gf(),type:`file`,url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(i)})},[x,o,s,c]),C=(0,F.useCallback)(e=>_(t=>{let n=t.find(t=>t.id===e);return n?.url&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)}),[]),w=(0,F.useCallback)(()=>_(e=>{for(let t of e)t.url&&URL.revokeObjectURL(t.url);return[]}),[]),T=p?f.attachments.add:S,E=p?f.attachments.remove:C,D=p?f.attachments.clear:w,ee=p?f.attachments.openFileDialog:b;(0,F.useEffect)(()=>{p&&f.__registerFileInput(m,()=>m.current?.click())},[p,f]),(0,F.useEffect)(()=>{a&&m.current&&v.length===0&&(m.current.value=``)},[v,a]),(0,F.useEffect)(()=>{let e=h.current;if(!e||i)return;let t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},n=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&T(e.dataTransfer.files)};return e.addEventListener(`dragover`,t),e.addEventListener(`drop`,n),()=>{e.removeEventListener(`dragover`,t),e.removeEventListener(`drop`,n)}},[T,i]),(0,F.useEffect)(()=>{if(!i)return;let e=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&T(e.dataTransfer.files)};return document.addEventListener(`dragover`,e),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`dragover`,e),document.removeEventListener(`drop`,t)}},[T,i]),(0,F.useEffect)(()=>()=>{if(!p)for(let e of y.current)e.url&&URL.revokeObjectURL(e.url)},[p]);let O=e=>{e.currentTarget.files&&T(e.currentTarget.files),e.currentTarget.value=``},te=async e=>{try{let t=await(await fetch(e)).blob();return new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.onerror=()=>e(null),n.readAsDataURL(t)})}catch{return null}},ne=(0,F.useMemo)(()=>({files:v.map(e=>({...e,id:e.id})),add:T,remove:E,clear:D,openFileDialog:ee,fileInputRef:m}),[v,T,E,D,ee]),re=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{accept:t,"aria-label":r,className:`hidden`,multiple:n,onChange:O,ref:m,title:r,type:`file`}),(0,L.jsx)(`form`,{className:j(`w-full`,e),onSubmit:e=>{e.preventDefault();let t=e.currentTarget,n=p?f.textInput.value:new FormData(t).get(`message`)||``;p||t.reset(),Promise.all(v.map(async({id:e,...t})=>{if(t.url&&t.url.startsWith(`blob:`)){let e=await te(t.url);return{...t,url:e??t.url}}return t})).then(t=>{try{let r=l({text:n,files:t},e);r instanceof Promise?r.then(()=>{D(),p&&f.textInput.clear()}).catch(()=>{}):(D(),p&&f.textInput.clear())}catch{}}).catch(()=>{})},ref:h,...d,children:(0,L.jsx)(Rf,{className:`overflow-hidden`,children:u})})]});return p?re:(0,L.jsx)(Xf.Provider,{value:ne,children:re})},np=({className:e,...t})=>(0,L.jsx)(`div`,{className:j(`contents`,e),...t}),rp=({onChange:e,className:t,placeholder:n=`What would you like to know?`,...r})=>{let i=Jf(),a=Zf(),[o,s]=(0,F.useState)(!1),c=e=>{if(e.key===`Enter`){if(o||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let t=e.currentTarget.form;if(t?.querySelector(`button[type="submit"]`)?.disabled)return;t?.requestSubmit()}if(e.key===`Backspace`&&e.currentTarget.value===``&&a.files.length>0){e.preventDefault();let t=a.files[a.files.length-1];t&&a.remove(t.id)}},l=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),a.add(n))},u=i?{value:i.textInput.value,onChange:t=>{i.textInput.setInput(t.currentTarget.value),e?.(t)}}:{onChange:e};return(0,L.jsx)(Uf,{className:j(`field-sizing-content max-h-48 min-h-16`,t),name:`message`,onCompositionEnd:()=>s(!1),onCompositionStart:()=>s(!0),onKeyDown:c,onPaste:l,placeholder:n,...r,...u})},ip=({className:e,...t})=>(0,L.jsx)(Bf,{align:`block-end`,className:j(`justify-between gap-1`,e),...t}),ap=({className:e,...t})=>(0,L.jsx)(`div`,{className:j(`flex items-center gap-1`,e),...t}),op=({variant:e=`ghost`,className:t,size:n,...r})=>{let i=n??(F.Children.count(r.children)>1?`sm`:`icon-sm`);return(0,L.jsx)(Hf,{className:j(t),size:i,type:`button`,variant:e,...r})},sp=e=>(0,L.jsx)(bt,{...e}),cp=({className:e,children:t,...n})=>(0,L.jsx)(nt,{asChild:!0,children:(0,L.jsx)(op,{className:e,...n,children:t??(0,L.jsx)(Le,{className:`size-4`})})}),lp=({className:e,...t})=>(0,L.jsx)(qe,{align:`start`,className:j(e),...t}),up=({className:e,variant:t=`default`,size:n=`icon-sm`,status:r,children:i,...a})=>{let o=(0,L.jsx)(re,{className:`size-4`});return r===`submitted`?o=(0,L.jsx)(De,{className:`size-4 animate-spin`}):r===`streaming`?o=(0,L.jsx)(Ue,{className:`size-4`}):r===`error`&&(o=(0,L.jsx)(le,{className:`size-4`})),(0,L.jsx)(Hf,{"aria-label":`Submit`,className:j(e),size:n,type:`submit`,variant:t,...a,children:i??o})},dp=({openDelay:e=0,closeDelay:t=0,...n})=>(0,L.jsx)(vt,{closeDelay:t,openDelay:e,...n}),fp=({align:e=`start`,...t})=>(0,L.jsx)(it,{align:e,...t}),pp=({className:e,children:t,...n})=>(0,L.jsxs)(pe,{className:`w-full overflow-x-auto whitespace-nowrap`,...n,children:[(0,L.jsx)(`div`,{className:j(`flex w-max flex-nowrap items-center gap-2`,e),children:t}),(0,L.jsx)(be,{className:`hidden`,orientation:`horizontal`})]}),mp=({suggestion:e,onClick:t,className:n,variant:r=`outline`,size:i=`sm`,children:a,...o})=>(0,L.jsx)(A,{className:j(`cursor-pointer rounded-full px-4`,n),onClick:()=>{t?.(e)},size:i,type:`button`,variant:r,...o,children:a||e}),hp=Object.defineProperty,gp=Object.getOwnPropertyDescriptor,_p=Object.getOwnPropertyNames,vp=Object.prototype.hasOwnProperty,yp=(e,t)=>{let n={};for(var r in e)hp(n,r,{get:e[r],enumerable:!0});return t||hp(n,Symbol.toStringTag,{value:`Module`}),n},bp=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_p(t),a=0,o=i.length,s;a<o;a++)s=i[a],!vp.call(e,s)&&s!==n&&hp(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=gp(t,s))||r.enumerable});return e},xp=(e,t,n)=>(bp(e,t,`default`),n&&bp(n,t,`default`)),Sp=[{id:`abap`,name:`ABAP`,import:(()=>s(()=>import(`./abap-CLvhMVsD.js`),[],import.meta.url))},{id:`actionscript-3`,name:`ActionScript`,import:(()=>s(()=>import(`./actionscript-3--17pq3dv.js`),[],import.meta.url))},{id:`ada`,name:`Ada`,import:(()=>s(()=>import(`./ada-C5qYipkI.js`),[],import.meta.url))},{id:`angular-html`,name:`Angular HTML`,import:(()=>s(()=>import(`./angular-html-B9s24XBK.js`).then(e=>e.n),[],import.meta.url))},{id:`angular-ts`,name:`Angular TypeScript`,import:(()=>s(()=>import(`./angular-ts-C7DCn4N7.js`),[],import.meta.url))},{id:`apache`,name:`Apache Conf`,import:(()=>s(()=>import(`./apache-U0d_L8uA.js`),[],import.meta.url))},{id:`apex`,name:`Apex`,import:(()=>s(()=>import(`./apex-VAyPSnFM.js`),[],import.meta.url))},{id:`apl`,name:`APL`,import:(()=>s(()=>import(`./apl-BFSpAsVe.js`),[],import.meta.url))},{id:`applescript`,name:`AppleScript`,import:(()=>s(()=>import(`./applescript-CCn79oCD.js`),[],import.meta.url))},{id:`ara`,name:`Ara`,import:(()=>s(()=>import(`./ara-4CJ0cIlV.js`),[],import.meta.url))},{id:`asciidoc`,name:`AsciiDoc`,aliases:[`adoc`],import:(()=>s(()=>import(`./asciidoc-DE70LPWp.js`),[],import.meta.url))},{id:`asm`,name:`Assembly`,import:(()=>s(()=>import(`./asm-Cmm7eHzH.js`),[],import.meta.url))},{id:`astro`,name:`Astro`,import:(()=>s(()=>import(`./astro-By5nmri_.js`),[],import.meta.url))},{id:`awk`,name:`AWK`,import:(()=>s(()=>import(`./awk-BWXHIvNe.js`),[],import.meta.url))},{id:`ballerina`,name:`Ballerina`,import:(()=>s(()=>import(`./ballerina-B7ZEbQpA.js`),[],import.meta.url))},{id:`bat`,name:`Batch File`,aliases:[`batch`],import:(()=>s(()=>import(`./bat-Bo4NYOV-.js`),[],import.meta.url))},{id:`beancount`,name:`Beancount`,import:(()=>s(()=>import(`./beancount-D-usSTwE.js`),[],import.meta.url))},{id:`berry`,name:`Berry`,aliases:[`be`],import:(()=>s(()=>import(`./berry-DKpUyyne.js`),[],import.meta.url))},{id:`bibtex`,name:`BibTeX`,import:(()=>s(()=>import(`./bibtex-Ci_nEsc7.js`),[],import.meta.url))},{id:`bicep`,name:`Bicep`,import:(()=>s(()=>import(`./bicep-CUHmPFLl.js`),[],import.meta.url))},{id:`bird2`,name:`BIRD2 Configuration`,aliases:[`bird`],import:(()=>s(()=>import(`./bird2-C6vDhewU.js`),[],import.meta.url))},{id:`blade`,name:`Blade`,import:(()=>s(()=>import(`./blade-BEsyb4Es.js`),[],import.meta.url))},{id:`bsl`,name:`1C (Enterprise)`,aliases:[`1c`],import:(()=>s(()=>import(`./bsl-BkkzgIyY.js`),[],import.meta.url))},{id:`c`,name:`C`,import:(()=>s(()=>import(`./c-CwKsiqWD.js`).then(e=>e.n),[],import.meta.url))},{id:`c3`,name:`C3`,import:(()=>s(()=>import(`./c3-BFHwR3_K.js`),[],import.meta.url))},{id:`cadence`,name:`Cadence`,aliases:[`cdc`],import:(()=>s(()=>import(`./cadence-CQ2zXKGN.js`),[],import.meta.url))},{id:`cairo`,name:`Cairo`,import:(()=>s(()=>import(`./cairo-DLTphjLi.js`),[],import.meta.url))},{id:`clarity`,name:`Clarity`,import:(()=>s(()=>import(`./clarity-SemFz856.js`),[],import.meta.url))},{id:`clojure`,name:`Clojure`,aliases:[`clj`],import:(()=>s(()=>import(`./clojure-DqKBuwfJ.js`),[],import.meta.url))},{id:`cmake`,name:`CMake`,import:(()=>s(()=>import(`./cmake-Bj61d0ZC.js`),[],import.meta.url))},{id:`cobol`,name:`COBOL`,import:(()=>s(()=>import(`./cobol-AtgRrYrD.js`),[],import.meta.url))},{id:`codeowners`,name:`CODEOWNERS`,import:(()=>s(()=>import(`./codeowners-C8r90Shi.js`),[],import.meta.url))},{id:`codeql`,name:`CodeQL`,aliases:[`ql`],import:(()=>s(()=>import(`./codeql-oeQT6MSM.js`),[],import.meta.url))},{id:`coffee`,name:`CoffeeScript`,aliases:[`coffeescript`],import:(()=>s(()=>import(`./coffee-Dx9BrBX9.js`),[],import.meta.url))},{id:`common-lisp`,name:`Common Lisp`,aliases:[`lisp`],import:(()=>s(()=>import(`./common-lisp-Cv5bFMCO.js`),[],import.meta.url))},{id:`coq`,name:`Coq`,import:(()=>s(()=>import(`./coq-BrsZFFmf.js`),[],import.meta.url))},{id:`cpp`,name:`C++`,aliases:[`c++`],import:(()=>s(()=>import(`./cpp-DNQ-Fj9i.js`).then(e=>e.n),[],import.meta.url))},{id:`crystal`,name:`Crystal`,import:(()=>s(()=>import(`./crystal-BFAqiLnY.js`),[],import.meta.url))},{id:`csharp`,name:`C#`,aliases:[`c#`,`cs`],import:(()=>s(()=>import(`./csharp-oqKa8noW.js`),[],import.meta.url))},{id:`css`,name:`CSS`,import:(()=>s(()=>import(`./css-76WQuunA.js`).then(e=>e.n),[],import.meta.url))},{id:`csv`,name:`CSV`,import:(()=>s(()=>import(`./csv-Dx-8-gkx.js`),[],import.meta.url))},{id:`cue`,name:`CUE`,import:(()=>s(()=>import(`./cue-CE9AQfxI.js`),[],import.meta.url))},{id:`cypher`,name:`Cypher`,aliases:[`cql`],import:(()=>s(()=>import(`./cypher-ClKdZ_lG.js`),[],import.meta.url))},{id:`d`,name:`D`,import:(()=>s(()=>import(`./d-qD-0Kul2.js`),[],import.meta.url))},{id:`dart`,name:`Dart`,import:(()=>s(()=>import(`./dart-CnvKMtbv.js`),[],import.meta.url))},{id:`dax`,name:`DAX`,import:(()=>s(()=>import(`./dax-BkyTk9wS.js`),[],import.meta.url))},{id:`desktop`,name:`Desktop`,import:(()=>s(()=>import(`./desktop-Dlh5hvp9.js`),[],import.meta.url))},{id:`diff`,name:`Diff`,import:(()=>s(()=>import(`./diff-woXpYk--.js`),[],import.meta.url))},{id:`docker`,name:`Dockerfile`,aliases:[`dockerfile`],import:(()=>s(()=>import(`./docker-IyjqRm3v.js`),[],import.meta.url))},{id:`dotenv`,name:`dotEnv`,import:(()=>s(()=>import(`./dotenv-_5a1GRtc.js`),[],import.meta.url))},{id:`dream-maker`,name:`Dream Maker`,import:(()=>s(()=>import(`./dream-maker-DW3nJb8Q.js`),[],import.meta.url))},{id:`edge`,name:`Edge`,import:(()=>s(()=>import(`./edge-BEfBxc5h.js`),[],import.meta.url))},{id:`elixir`,name:`Elixir`,import:(()=>s(()=>import(`./elixir-Bi1LyDCo.js`),[],import.meta.url))},{id:`elm`,name:`Elm`,import:(()=>s(()=>import(`./elm-BMPZeG5i.js`),[],import.meta.url))},{id:`emacs-lisp`,name:`Emacs Lisp`,aliases:[`elisp`],import:(()=>s(()=>import(`./emacs-lisp-B4R74twV.js`),[],import.meta.url))},{id:`erb`,name:`ERB`,import:(()=>s(()=>import(`./erb-Pmcx6TTx.js`),[],import.meta.url))},{id:`erlang`,name:`Erlang`,aliases:[`erl`],import:(()=>s(()=>import(`./erlang-Cphh6RMH.js`),[],import.meta.url))},{id:`fennel`,name:`Fennel`,import:(()=>s(()=>import(`./fennel-DQxkIbk2.js`),[],import.meta.url))},{id:`fish`,name:`Fish`,import:(()=>s(()=>import(`./fish-BJitypiv.js`),[],import.meta.url))},{id:`fluent`,name:`Fluent`,aliases:[`ftl`],import:(()=>s(()=>import(`./fluent-C03EYrpw.js`),[],import.meta.url))},{id:`fortran-fixed-form`,name:`Fortran (Fixed Form)`,aliases:[`f`,`for`,`f77`],import:(()=>s(()=>import(`./fortran-fixed-form-DEKoE2YW.js`),[],import.meta.url))},{id:`fortran-free-form`,name:`Fortran (Free Form)`,aliases:[`f90`,`f95`,`f03`,`f08`,`f18`],import:(()=>s(()=>import(`./fortran-free-form-CYNrtFtB.js`),[],import.meta.url))},{id:`fsharp`,name:`F#`,aliases:[`f#`,`fs`],import:(()=>s(()=>import(`./fsharp-D13ZGOAj.js`),[],import.meta.url))},{id:`gdresource`,name:`GDResource`,aliases:[`tscn`,`tres`],import:(()=>s(()=>import(`./gdresource-C0sCabJj.js`),[],import.meta.url))},{id:`gdscript`,name:`GDScript`,aliases:[`gd`],import:(()=>s(()=>import(`./gdscript-Cp2uCuqX.js`),[],import.meta.url))},{id:`gdshader`,name:`GDShader`,import:(()=>s(()=>import(`./gdshader-CBce3t8t.js`),[],import.meta.url))},{id:`genie`,name:`Genie`,import:(()=>s(()=>import(`./genie-CV2tkWYe.js`),[],import.meta.url))},{id:`gherkin`,name:`Gherkin`,import:(()=>s(()=>import(`./gherkin-DExj1W_8.js`),[],import.meta.url))},{id:`git-commit`,name:`Git Commit Message`,import:(()=>s(()=>import(`./git-commit-BSykSTBG.js`),[],import.meta.url))},{id:`git-rebase`,name:`Git Rebase Message`,import:(()=>s(()=>import(`./git-rebase-Dj7t0bix.js`),[],import.meta.url))},{id:`gleam`,name:`Gleam`,import:(()=>s(()=>import(`./gleam-CSRkHgEL.js`),[],import.meta.url))},{id:`glimmer-js`,name:`Glimmer JS`,aliases:[`gjs`],import:(()=>s(()=>import(`./glimmer-js-DTpMHWUo.js`),[],import.meta.url))},{id:`glimmer-ts`,name:`Glimmer TS`,aliases:[`gts`],import:(()=>s(()=>import(`./glimmer-ts-BKOVQU61.js`),[],import.meta.url))},{id:`glsl`,name:`GLSL`,import:(()=>s(()=>import(`./glsl-DDNdYp2B.js`).then(e=>e.n),[],import.meta.url))},{id:`gn`,name:`GN`,import:(()=>s(()=>import(`./gn-ilITqXS6.js`),[],import.meta.url))},{id:`gnuplot`,name:`Gnuplot`,import:(()=>s(()=>import(`./gnuplot-7GGW24-e.js`),[],import.meta.url))},{id:`go`,name:`Go`,import:(()=>s(()=>import(`./go-rLFTqkRN.js`),[],import.meta.url))},{id:`graphql`,name:`GraphQL`,aliases:[`gql`],import:(()=>s(()=>import(`./graphql-C-akFyqE.js`).then(e=>e.n),[],import.meta.url))},{id:`groovy`,name:`Groovy`,import:(()=>s(()=>import(`./groovy-CacY0gHj.js`),[],import.meta.url))},{id:`hack`,name:`Hack`,import:(()=>s(()=>import(`./hack-Z382E4IB.js`),[],import.meta.url))},{id:`haml`,name:`Ruby Haml`,import:(()=>s(()=>import(`./haml-DCWQJgln.js`).then(e=>e.n),[],import.meta.url))},{id:`handlebars`,name:`Handlebars`,aliases:[`hbs`],import:(()=>s(()=>import(`./handlebars-D_RRtkV5.js`),[],import.meta.url))},{id:`haskell`,name:`Haskell`,aliases:[`hs`],import:(()=>s(()=>import(`./haskell-D8IpX4py.js`),[],import.meta.url))},{id:`haxe`,name:`Haxe`,import:(()=>s(()=>import(`./haxe-OTjmBuCE.js`),[],import.meta.url))},{id:`hcl`,name:`HashiCorp HCL`,import:(()=>s(()=>import(`./hcl-Dh228itO.js`),[],import.meta.url))},{id:`hjson`,name:`Hjson`,import:(()=>s(()=>import(`./hjson-CxZEssPk.js`),[],import.meta.url))},{id:`hlsl`,name:`HLSL`,import:(()=>s(()=>import(`./hlsl-Cvrh5tZx.js`),[],import.meta.url))},{id:`html`,name:`HTML`,import:(()=>s(()=>import(`./html-BqDo3pKb.js`).then(e=>e.n),[],import.meta.url))},{id:`html-derivative`,name:`HTML (Derivative)`,import:(()=>s(()=>import(`./html-derivative-DncxUXSH.js`),[],import.meta.url))},{id:`http`,name:`HTTP`,import:(()=>s(()=>import(`./http-CrTHj6_t.js`),[],import.meta.url))},{id:`hurl`,name:`Hurl`,import:(()=>s(()=>import(`./hurl-BdeVL_ga.js`),[],import.meta.url))},{id:`hxml`,name:`HXML`,import:(()=>s(()=>import(`./hxml-B0Qn7Nwc.js`),[],import.meta.url))},{id:`hy`,name:`Hy`,import:(()=>s(()=>import(`./hy-CZbG8q4J.js`),[],import.meta.url))},{id:`imba`,name:`Imba`,import:(()=>s(()=>import(`./imba-DsUTQ-LC.js`),[],import.meta.url))},{id:`ini`,name:`INI`,aliases:[`properties`],import:(()=>s(()=>import(`./ini-B5eOa1yu.js`),[],import.meta.url))},{id:`java`,name:`Java`,import:(()=>s(()=>import(`./java-DKFHmTAg.js`).then(e=>e.n),[],import.meta.url))},{id:`javascript`,name:`JavaScript`,aliases:[`js`,`cjs`,`mjs`],import:(()=>s(()=>import(`./javascript-Jx16aUBb.js`).then(e=>e.n),[],import.meta.url))},{id:`jinja`,name:`Jinja`,import:(()=>s(()=>import(`./jinja-CQEVrK23.js`),[],import.meta.url))},{id:`jison`,name:`Jison`,import:(()=>s(()=>import(`./jison-BJRgvE0A.js`),[],import.meta.url))},{id:`json`,name:`JSON`,import:(()=>s(()=>import(`./json-DlFP2GYa.js`).then(e=>e.n),[],import.meta.url))},{id:`json5`,name:`JSON5`,import:(()=>s(()=>import(`./json5-BR5RXkoi.js`),[],import.meta.url))},{id:`jsonc`,name:`JSON with Comments`,import:(()=>s(()=>import(`./jsonc-CYpm1nAK.js`),[],import.meta.url))},{id:`jsonl`,name:`JSON Lines`,import:(()=>s(()=>import(`./jsonl-CmCQp5Yx.js`),[],import.meta.url))},{id:`jsonnet`,name:`Jsonnet`,import:(()=>s(()=>import(`./jsonnet-CJTPZ8u_.js`),[],import.meta.url))},{id:`jssm`,name:`JSSM`,aliases:[`fsl`],import:(()=>s(()=>import(`./jssm-DXw9l8Rf.js`),[],import.meta.url))},{id:`jsx`,name:`JSX`,import:(()=>s(()=>import(`./jsx-CIwpwN-u.js`).then(e=>e.n),[],import.meta.url))},{id:`julia`,name:`Julia`,aliases:[`jl`],import:(()=>s(()=>import(`./julia-D4zLZb0D.js`),[],import.meta.url))},{id:`just`,name:`Just`,import:(()=>s(()=>import(`./just-BbmgE3ZP.js`),[],import.meta.url))},{id:`kdl`,name:`KDL`,import:(()=>s(()=>import(`./kdl-CsD5j6eV.js`),[],import.meta.url))},{id:`kotlin`,name:`Kotlin`,aliases:[`kt`,`kts`],import:(()=>s(()=>import(`./kotlin-DhhofPvG.js`),[],import.meta.url))},{id:`kusto`,name:`Kusto`,aliases:[`kql`],import:(()=>s(()=>import(`./kusto-C7mF5XQf.js`),[],import.meta.url))},{id:`latex`,name:`LaTeX`,import:(()=>s(()=>import(`./latex-BUDs7Dcl.js`),[],import.meta.url))},{id:`lean`,name:`Lean 4`,aliases:[`lean4`],import:(()=>s(()=>import(`./lean-CewbzKMR.js`),[],import.meta.url))},{id:`less`,name:`Less`,import:(()=>s(()=>import(`./less-DVTAwKKz.js`),[],import.meta.url))},{id:`liquid`,name:`Liquid`,import:(()=>s(()=>import(`./liquid-Bc0s0G9S.js`),[],import.meta.url))},{id:`llvm`,name:`LLVM IR`,import:(()=>s(()=>import(`./llvm-Cm23YOpf.js`),[],import.meta.url))},{id:`log`,name:`Log file`,import:(()=>s(()=>import(`./log-BNLmms1o.js`),[],import.meta.url))},{id:`logo`,name:`Logo`,import:(()=>s(()=>import(`./logo-Cluzi2Zq.js`),[],import.meta.url))},{id:`lua`,name:`Lua`,import:(()=>s(()=>import(`./lua-dQaszIi_.js`).then(e=>e.n),[],import.meta.url))},{id:`luau`,name:`Luau`,import:(()=>s(()=>import(`./luau-FMPmPwt6.js`),[],import.meta.url))},{id:`make`,name:`Makefile`,aliases:[`makefile`],import:(()=>s(()=>import(`./make-Dixweg8N.js`),[],import.meta.url))},{id:`markdown`,name:`Markdown`,aliases:[`md`],import:(()=>s(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url))},{id:`marko`,name:`Marko`,import:(()=>s(()=>import(`./marko-B5Uea28G.js`),[],import.meta.url))},{id:`matlab`,name:`MATLAB`,import:(()=>s(()=>import(`./matlab-D7qyCx1q.js`),[],import.meta.url))},{id:`mdc`,name:`MDC`,import:(()=>s(()=>import(`./mdc-CwQcy7BI.js`),[],import.meta.url))},{id:`mdx`,name:`MDX`,import:(()=>s(()=>import(`./mdx-DQZ5AkYe.js`),[],import.meta.url))},{id:`mermaid`,name:`Mermaid`,aliases:[`mmd`],import:(()=>s(()=>import(`./mermaid-Bk4SNUv9.js`),[],import.meta.url))},{id:`mipsasm`,name:`MIPS Assembly`,aliases:[`mips`],import:(()=>s(()=>import(`./mipsasm-BMqwQI7S.js`),[],import.meta.url))},{id:`mojo`,name:`Mojo`,import:(()=>s(()=>import(`./mojo-BgCJLMeH.js`),[],import.meta.url))},{id:`moonbit`,name:`MoonBit`,aliases:[`mbt`,`mbti`],import:(()=>s(()=>import(`./moonbit-CaWjb8XO.js`),[],import.meta.url))},{id:`move`,name:`Move`,import:(()=>s(()=>import(`./move-B1IS1UjX.js`),[],import.meta.url))},{id:`narrat`,name:`Narrat Language`,aliases:[`nar`],import:(()=>s(()=>import(`./narrat-_X_XdTYD.js`),[],import.meta.url))},{id:`nextflow`,name:`Nextflow`,aliases:[`nf`],import:(()=>s(()=>import(`./nextflow-BJtWHP5T.js`),[],import.meta.url))},{id:`nextflow-groovy`,name:`Nextflow Groovy`,import:(()=>s(()=>import(`./nextflow-groovy-DJMQeKeT.js`),[],import.meta.url))},{id:`nginx`,name:`Nginx`,import:(()=>s(()=>import(`./nginx-SzmDaWuK.js`),[],import.meta.url))},{id:`nim`,name:`Nim`,import:(()=>s(()=>import(`./nim-CO_A6I25.js`),[],import.meta.url))},{id:`nix`,name:`Nix`,import:(()=>s(()=>import(`./nix-IvuFDN5E.js`),[],import.meta.url))},{id:`nushell`,name:`nushell`,aliases:[`nu`],import:(()=>s(()=>import(`./nushell-DcLAeLz5.js`),[],import.meta.url))},{id:`objective-c`,name:`Objective-C`,aliases:[`objc`],import:(()=>s(()=>import(`./objective-c-D1A_Heim.js`),[],import.meta.url))},{id:`objective-cpp`,name:`Objective-C++`,import:(()=>s(()=>import(`./objective-cpp-BsSzOQcm.js`),[],import.meta.url))},{id:`ocaml`,name:`OCaml`,import:(()=>s(()=>import(`./ocaml-O90oeIOV.js`),[],import.meta.url))},{id:`odin`,name:`Odin`,import:(()=>s(()=>import(`./odin-B1RWQWA5.js`),[],import.meta.url))},{id:`openscad`,name:`OpenSCAD`,aliases:[`scad`],import:(()=>s(()=>import(`./openscad-BUDT5pXO.js`),[],import.meta.url))},{id:`pascal`,name:`Pascal`,import:(()=>s(()=>import(`./pascal-4ZHwLPI5.js`),[],import.meta.url))},{id:`perl`,name:`Perl`,import:(()=>s(()=>import(`./perl-DXgLsVg8.js`),[],import.meta.url))},{id:`php`,name:`PHP`,import:(()=>s(()=>import(`./php-C4KCWpl8.js`),[],import.meta.url))},{id:`pkl`,name:`Pkl`,import:(()=>s(()=>import(`./pkl-ot-7Btpt.js`),[],import.meta.url))},{id:`plsql`,name:`PL/SQL`,import:(()=>s(()=>import(`./plsql-DGHpHOYJ.js`),[],import.meta.url))},{id:`po`,name:`Gettext PO`,aliases:[`pot`,`potx`],import:(()=>s(()=>import(`./po-BiJDBrnU.js`),[],import.meta.url))},{id:`polar`,name:`Polar`,import:(()=>s(()=>import(`./polar-C7UOKdEL.js`),[],import.meta.url))},{id:`postcss`,name:`PostCSS`,import:(()=>s(()=>import(`./postcss-BXeXVLqQ.js`),[],import.meta.url))},{id:`powerquery`,name:`PowerQuery`,import:(()=>s(()=>import(`./powerquery-DNMTfnFr.js`),[],import.meta.url))},{id:`powershell`,name:`PowerShell`,aliases:[`ps`,`ps1`],import:(()=>s(()=>import(`./powershell-DshXNtvi.js`),[],import.meta.url))},{id:`prisma`,name:`Prisma`,import:(()=>s(()=>import(`./prisma-BsRQq5mF.js`),[],import.meta.url))},{id:`prolog`,name:`Prolog`,import:(()=>s(()=>import(`./prolog-iXnhIJG7.js`),[],import.meta.url))},{id:`proto`,name:`Protocol Buffer 3`,aliases:[`protobuf`],import:(()=>s(()=>import(`./proto-DB4EqR-F.js`),[],import.meta.url))},{id:`pug`,name:`Pug`,aliases:[`jade`],import:(()=>s(()=>import(`./pug-bpEG1CVZ.js`),[],import.meta.url))},{id:`puppet`,name:`Puppet`,import:(()=>s(()=>import(`./puppet-CDv2pdJW.js`),[],import.meta.url))},{id:`purescript`,name:`PureScript`,import:(()=>s(()=>import(`./purescript-9MfHhQsQ.js`),[],import.meta.url))},{id:`python`,name:`Python`,aliases:[`py`],import:(()=>s(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url))},{id:`qml`,name:`QML`,import:(()=>s(()=>import(`./qml-DGJzHzg9.js`),[],import.meta.url))},{id:`qmldir`,name:`QML Directory`,import:(()=>s(()=>import(`./qmldir-DCQb3MpD.js`),[],import.meta.url))},{id:`qss`,name:`Qt Style Sheets`,import:(()=>s(()=>import(`./qss-Fe1Jh2GI.js`),[],import.meta.url))},{id:`r`,name:`R`,import:(()=>s(()=>import(`./r-CZt9UGEb.js`).then(e=>e.n),[],import.meta.url))},{id:`racket`,name:`Racket`,import:(()=>s(()=>import(`./racket-DcIDlBhZ.js`),[],import.meta.url))},{id:`raku`,name:`Raku`,aliases:[`perl6`],import:(()=>s(()=>import(`./raku-B3gFvitq.js`),[],import.meta.url))},{id:`razor`,name:`ASP.NET Razor`,import:(()=>s(()=>import(`./razor-mTLK-dma.js`),[],import.meta.url))},{id:`reg`,name:`Windows Registry Script`,import:(()=>s(()=>import(`./reg-CRGYupPL.js`),[],import.meta.url))},{id:`regexp`,name:`RegExp`,aliases:[`regex`],import:(()=>s(()=>import(`./regexp-DX5QhPdx.js`).then(e=>e.n),[],import.meta.url))},{id:`rel`,name:`Rel`,import:(()=>s(()=>import(`./rel-BtDbiS_P.js`),[],import.meta.url))},{id:`riscv`,name:`RISC-V`,import:(()=>s(()=>import(`./riscv-Ckw8ddFX.js`),[],import.meta.url))},{id:`ron`,name:`RON`,import:(()=>s(()=>import(`./ron-VUp2lXgN.js`),[],import.meta.url))},{id:`rosmsg`,name:`ROS Interface`,import:(()=>s(()=>import(`./rosmsg-CAekHB0j.js`),[],import.meta.url))},{id:`rst`,name:`reStructuredText`,import:(()=>s(()=>import(`./rst-t-F-oATV.js`),[],import.meta.url))},{id:`ruby`,name:`Ruby`,aliases:[`rb`],import:(()=>s(()=>import(`./ruby-D9DDGNv3.js`),[],import.meta.url))},{id:`rust`,name:`Rust`,aliases:[`rs`],import:(()=>s(()=>import(`./rust-Cfkwpbl8.js`),[],import.meta.url))},{id:`sas`,name:`SAS`,import:(()=>s(()=>import(`./sas-BAEs8TsV.js`),[],import.meta.url))},{id:`sass`,name:`Sass`,import:(()=>s(()=>import(`./sass-DXrisJhu.js`),[],import.meta.url))},{id:`scala`,name:`Scala`,import:(()=>s(()=>import(`./scala-DKOlJaKm.js`),[],import.meta.url))},{id:`scheme`,name:`Scheme`,import:(()=>s(()=>import(`./scheme-DQCgrYNe.js`),[],import.meta.url))},{id:`scss`,name:`SCSS`,import:(()=>s(()=>import(`./scss-B6B5DSWC.js`).then(e=>e.n),[],import.meta.url))},{id:`sdbl`,name:`1C (Query)`,aliases:[`1c-query`],import:(()=>s(()=>import(`./sdbl-bTVj8UrX.js`),[],import.meta.url))},{id:`shaderlab`,name:`ShaderLab`,aliases:[`shader`],import:(()=>s(()=>import(`./shaderlab-TOUzSsQk.js`),[],import.meta.url))},{id:`shellscript`,name:`Shell`,aliases:[`bash`,`sh`,`shell`,`zsh`],import:(()=>s(()=>import(`./shellscript-DXt7nqYk.js`).then(e=>e.n),[],import.meta.url))},{id:`shellsession`,name:`Shell Session`,aliases:[`console`],import:(()=>s(()=>import(`./shellsession-DQ4guRhR.js`),[],import.meta.url))},{id:`smalltalk`,name:`Smalltalk`,import:(()=>s(()=>import(`./smalltalk-B16xEiuN.js`),[],import.meta.url))},{id:`solidity`,name:`Solidity`,import:(()=>s(()=>import(`./solidity-CKzVLygQ.js`),[],import.meta.url))},{id:`soy`,name:`Closure Templates`,aliases:[`closure-templates`],import:(()=>s(()=>import(`./soy-DtwGS8Y2.js`),[],import.meta.url))},{id:`sparql`,name:`SPARQL`,import:(()=>s(()=>import(`./sparql-D_iOobhT.js`),[],import.meta.url))},{id:`splunk`,name:`Splunk Query Language`,aliases:[`spl`],import:(()=>s(()=>import(`./splunk-BC2Px7Mm.js`),[],import.meta.url))},{id:`sql`,name:`SQL`,import:(()=>s(()=>import(`./sql-ArzG0FT1.js`).then(e=>e.n),[],import.meta.url))},{id:`ssh-config`,name:`SSH Config`,import:(()=>s(()=>import(`./ssh-config-BgfXC-Er.js`),[],import.meta.url))},{id:`stata`,name:`Stata`,import:(()=>s(()=>import(`./stata-CdQ318yb.js`),[],import.meta.url))},{id:`stylus`,name:`Stylus`,aliases:[`styl`],import:(()=>s(()=>import(`./stylus-B6D30XZt.js`),[],import.meta.url))},{id:`surrealql`,name:`SurrealQL`,aliases:[`surql`],import:(()=>s(()=>import(`./surrealql-RyXJ8VfM.js`),[],import.meta.url))},{id:`svelte`,name:`Svelte`,import:(()=>s(()=>import(`./svelte-CXkGIk7i.js`),[],import.meta.url))},{id:`swift`,name:`Swift`,import:(()=>s(()=>import(`./swift-DonLKvLd.js`),[],import.meta.url))},{id:`system-verilog`,name:`SystemVerilog`,import:(()=>s(()=>import(`./system-verilog-DJ5XKQeo.js`),[],import.meta.url))},{id:`systemd`,name:`Systemd Units`,import:(()=>s(()=>import(`./systemd-BxMlprV5.js`),[],import.meta.url))},{id:`talonscript`,name:`TalonScript`,aliases:[`talon`],import:(()=>s(()=>import(`./talonscript-CohzipZa.js`),[],import.meta.url))},{id:`tasl`,name:`Tasl`,import:(()=>s(()=>import(`./tasl-DMoTqEGO.js`),[],import.meta.url))},{id:`tcl`,name:`Tcl`,import:(()=>s(()=>import(`./tcl-CZd0xW_V.js`),[],import.meta.url))},{id:`templ`,name:`Templ`,import:(()=>s(()=>import(`./templ-CJz86NIj.js`),[],import.meta.url))},{id:`terraform`,name:`Terraform`,aliases:[`tf`,`tfvars`],import:(()=>s(()=>import(`./terraform-DswuEJGm.js`),[],import.meta.url))},{id:`tex`,name:`TeX`,import:(()=>s(()=>import(`./tex-C71esTKh.js`),[],import.meta.url))},{id:`toml`,name:`TOML`,import:(()=>s(()=>import(`./toml-CcmNWLt0.js`),[],import.meta.url))},{id:`ts-tags`,name:`TypeScript with Tags`,aliases:[`lit`],import:(()=>s(()=>import(`./ts-tags-Qszjvpax.js`),[],import.meta.url))},{id:`tsv`,name:`TSV`,import:(()=>s(()=>import(`./tsv-sltzmVWM.js`),[],import.meta.url))},{id:`tsx`,name:`TSX`,import:(()=>s(()=>import(`./tsx-BEhriTf8.js`).then(e=>e.n),[],import.meta.url))},{id:`turtle`,name:`Turtle`,import:(()=>s(()=>import(`./turtle-ByJddavk.js`),[],import.meta.url))},{id:`twig`,name:`Twig`,import:(()=>s(()=>import(`./twig-CbaWuFm3.js`),[],import.meta.url))},{id:`typescript`,name:`TypeScript`,aliases:[`ts`,`cts`,`mts`],import:(()=>s(()=>import(`./typescript-CBu4i5lG.js`).then(e=>e.n),[],import.meta.url))},{id:`typespec`,name:`TypeSpec`,aliases:[`tsp`],import:(()=>s(()=>import(`./typespec-BRdr0IET.js`),[],import.meta.url))},{id:`typst`,name:`Typst`,aliases:[`typ`],import:(()=>s(()=>import(`./typst-DI99ib-x.js`),[],import.meta.url))},{id:`v`,name:`V`,import:(()=>s(()=>import(`./v-DETTlOr0.js`),[],import.meta.url))},{id:`vala`,name:`Vala`,import:(()=>s(()=>import(`./vala-zf12oZj6.js`),[],import.meta.url))},{id:`vb`,name:`Visual Basic`,aliases:[`cmd`],import:(()=>s(()=>import(`./vb-Djn5o6TS.js`),[],import.meta.url))},{id:`verilog`,name:`Verilog`,import:(()=>s(()=>import(`./verilog-CiiDBU1e.js`),[],import.meta.url))},{id:`vhdl`,name:`VHDL`,import:(()=>s(()=>import(`./vhdl-BroJfC0k.js`),[],import.meta.url))},{id:`viml`,name:`Vim Script`,aliases:[`vim`,`vimscript`],import:(()=>s(()=>import(`./viml-DvXPmvsu.js`),[],import.meta.url))},{id:`vue`,name:`Vue`,import:(()=>s(()=>import(`./vue-Bruwzb-A.js`),[],import.meta.url))},{id:`vue-html`,name:`Vue HTML`,import:(()=>s(()=>import(`./vue-html-C-3Ma2tD.js`),[],import.meta.url))},{id:`vue-vine`,name:`Vue Vine`,import:(()=>s(()=>import(`./vue-vine-DQAt9DTg.js`),[],import.meta.url))},{id:`vyper`,name:`Vyper`,aliases:[`vy`],import:(()=>s(()=>import(`./vyper-CgoNMtux.js`),[],import.meta.url))},{id:`wasm`,name:`WebAssembly`,import:(()=>s(()=>import(`./wasm-ByWQv1Qj.js`),[],import.meta.url))},{id:`wenyan`,name:`Wenyan`,aliases:[`文言`],import:(()=>s(()=>import(`./wenyan-C8pVoKbM.js`),[],import.meta.url))},{id:`wgsl`,name:`WGSL`,import:(()=>s(()=>import(`./wgsl-BsKzXJz4.js`),[],import.meta.url))},{id:`wikitext`,name:`Wikitext`,aliases:[`mediawiki`,`wiki`],import:(()=>s(()=>import(`./wikitext-ClFFjSW2.js`),[],import.meta.url))},{id:`wit`,name:`WebAssembly Interface Types`,import:(()=>s(()=>import(`./wit-DdvCle-K.js`),[],import.meta.url))},{id:`wolfram`,name:`Wolfram`,aliases:[`wl`],import:(()=>s(()=>import(`./wolfram-DLL8P-h_.js`),[],import.meta.url))},{id:`xml`,name:`XML`,import:(()=>s(()=>import(`./xml-BS2GSQw_.js`).then(e=>e.n),[],import.meta.url))},{id:`xsl`,name:`XSL`,import:(()=>s(()=>import(`./xsl-CCmfIdf4.js`),[],import.meta.url))},{id:`yaml`,name:`YAML`,aliases:[`yml`],import:(()=>s(()=>import(`./yaml-C1LY7x4K.js`).then(e=>e.n),[],import.meta.url))},{id:`zenscript`,name:`ZenScript`,import:(()=>s(()=>import(`./zenscript-BnlCZFoB.js`),[],import.meta.url))},{id:`zig`,name:`Zig`,import:(()=>s(()=>import(`./zig-CMLA9XwU.js`),[],import.meta.url))}],Cp=Object.fromEntries(Sp.map(e=>[e.id,e.import])),wp=Object.fromEntries(Sp.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Tp={...Cp,...wp},Ep=Object.fromEntries([{id:`andromeeda`,displayName:`Andromeeda`,type:`dark`,import:(()=>s(()=>import(`./andromeeda-vGVdxbeo.js`),[],import.meta.url))},{id:`aurora-x`,displayName:`Aurora X`,type:`dark`,import:(()=>s(()=>import(`./aurora-x-CDeNXAV0.js`),[],import.meta.url))},{id:`ayu-dark`,displayName:`Ayu Dark`,type:`dark`,import:(()=>s(()=>import(`./ayu-dark-DluEY0Gj.js`),[],import.meta.url))},{id:`ayu-light`,displayName:`Ayu Light`,type:`light`,import:(()=>s(()=>import(`./ayu-light-C3h-C4tm.js`),[],import.meta.url))},{id:`ayu-mirage`,displayName:`Ayu Mirage`,type:`dark`,import:(()=>s(()=>import(`./ayu-mirage-Bqwy1Gya.js`),[],import.meta.url))},{id:`catppuccin-frappe`,displayName:`Catppuccin Frappé`,type:`dark`,import:(()=>s(()=>import(`./catppuccin-frappe-3VR1Za6u.js`),[],import.meta.url))},{id:`catppuccin-latte`,displayName:`Catppuccin Latte`,type:`light`,import:(()=>s(()=>import(`./catppuccin-latte-DwIHMF0Q.js`),[],import.meta.url))},{id:`catppuccin-macchiato`,displayName:`Catppuccin Macchiato`,type:`dark`,import:(()=>s(()=>import(`./catppuccin-macchiato-DYnBP6_5.js`),[],import.meta.url))},{id:`catppuccin-mocha`,displayName:`Catppuccin Mocha`,type:`dark`,import:(()=>s(()=>import(`./catppuccin-mocha-DYhrFGRu.js`),[],import.meta.url))},{id:`dark-plus`,displayName:`Dark Plus`,type:`dark`,import:(()=>s(()=>import(`./dark-plus-Cs2F2srj.js`),[],import.meta.url))},{id:`dracula`,displayName:`Dracula Theme`,type:`dark`,import:(()=>s(()=>import(`./dracula-BHWKrbxM.js`),[],import.meta.url))},{id:`dracula-soft`,displayName:`Dracula Theme Soft`,type:`dark`,import:(()=>s(()=>import(`./dracula-soft-5eyTD99u.js`),[],import.meta.url))},{id:`everforest-dark`,displayName:`Everforest Dark`,type:`dark`,import:(()=>s(()=>import(`./everforest-dark-sB-x3p7T.js`),[],import.meta.url))},{id:`everforest-light`,displayName:`Everforest Light`,type:`light`,import:(()=>s(()=>import(`./everforest-light-Df2xbC6M.js`),[],import.meta.url))},{id:`github-dark`,displayName:`GitHub Dark`,type:`dark`,import:(()=>s(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url))},{id:`github-dark-default`,displayName:`GitHub Dark Default`,type:`dark`,import:(()=>s(()=>import(`./github-dark-default-DXG-b-1a.js`),[],import.meta.url))},{id:`github-dark-dimmed`,displayName:`GitHub Dark Dimmed`,type:`dark`,import:(()=>s(()=>import(`./github-dark-dimmed-Bx1FflLF.js`),[],import.meta.url))},{id:`github-dark-high-contrast`,displayName:`GitHub Dark High Contrast`,type:`dark`,import:(()=>s(()=>import(`./github-dark-high-contrast-B_tTalzw.js`),[],import.meta.url))},{id:`github-light`,displayName:`GitHub Light`,type:`light`,import:(()=>s(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url))},{id:`github-light-default`,displayName:`GitHub Light Default`,type:`light`,import:(()=>s(()=>import(`./github-light-default-BXViO-2h.js`),[],import.meta.url))},{id:`github-light-high-contrast`,displayName:`GitHub Light High Contrast`,type:`light`,import:(()=>s(()=>import(`./github-light-high-contrast-B68TUdTA.js`),[],import.meta.url))},{id:`gruvbox-dark-hard`,displayName:`Gruvbox Dark Hard`,type:`dark`,import:(()=>s(()=>import(`./gruvbox-dark-hard-C820rvS2.js`),[],import.meta.url))},{id:`gruvbox-dark-medium`,displayName:`Gruvbox Dark Medium`,type:`dark`,import:(()=>s(()=>import(`./gruvbox-dark-medium-BPjhmG05.js`),[],import.meta.url))},{id:`gruvbox-dark-soft`,displayName:`Gruvbox Dark Soft`,type:`dark`,import:(()=>s(()=>import(`./gruvbox-dark-soft-MrdJrrXF.js`),[],import.meta.url))},{id:`gruvbox-light-hard`,displayName:`Gruvbox Light Hard`,type:`light`,import:(()=>s(()=>import(`./gruvbox-light-hard-BC_s9l72.js`),[],import.meta.url))},{id:`gruvbox-light-medium`,displayName:`Gruvbox Light Medium`,type:`light`,import:(()=>s(()=>import(`./gruvbox-light-medium-BAWPOn9u.js`),[],import.meta.url))},{id:`gruvbox-light-soft`,displayName:`Gruvbox Light Soft`,type:`light`,import:(()=>s(()=>import(`./gruvbox-light-soft-BSMLrYjP.js`),[],import.meta.url))},{id:`horizon`,displayName:`Horizon`,type:`dark`,import:(()=>s(()=>import(`./horizon-CE9ld1lL.js`),[],import.meta.url))},{id:`horizon-bright`,displayName:`Horizon Bright`,type:`light`,import:(()=>s(()=>import(`./horizon-bright-DSNQnXHK.js`),[],import.meta.url))},{id:`houston`,displayName:`Houston`,type:`dark`,import:(()=>s(()=>import(`./houston-CsvMBhTu.js`),[],import.meta.url))},{id:`kanagawa-dragon`,displayName:`Kanagawa Dragon`,type:`dark`,import:(()=>s(()=>import(`./kanagawa-dragon-CXtmUGW6.js`),[],import.meta.url))},{id:`kanagawa-lotus`,displayName:`Kanagawa Lotus`,type:`light`,import:(()=>s(()=>import(`./kanagawa-lotus-BN08jTvb.js`),[],import.meta.url))},{id:`kanagawa-wave`,displayName:`Kanagawa Wave`,type:`dark`,import:(()=>s(()=>import(`./kanagawa-wave-CTweb8Dz.js`),[],import.meta.url))},{id:`laserwave`,displayName:`LaserWave`,type:`dark`,import:(()=>s(()=>import(`./laserwave-C_8bwKvT.js`),[],import.meta.url))},{id:`light-plus`,displayName:`Light Plus`,type:`light`,import:(()=>s(()=>import(`./light-plus-DVQuIRkW.js`),[],import.meta.url))},{id:`material-theme`,displayName:`Material Theme`,type:`dark`,import:(()=>s(()=>import(`./material-theme-Bm3Qr25_.js`),[],import.meta.url))},{id:`material-theme-darker`,displayName:`Material Theme Darker`,type:`dark`,import:(()=>s(()=>import(`./material-theme-darker-2IIEA8gg.js`),[],import.meta.url))},{id:`material-theme-lighter`,displayName:`Material Theme Lighter`,type:`light`,import:(()=>s(()=>import(`./material-theme-lighter-uhdI0v04.js`),[],import.meta.url))},{id:`material-theme-ocean`,displayName:`Material Theme Ocean`,type:`dark`,import:(()=>s(()=>import(`./material-theme-ocean-CHQ94UKr.js`),[],import.meta.url))},{id:`material-theme-palenight`,displayName:`Material Theme Palenight`,type:`dark`,import:(()=>s(()=>import(`./material-theme-palenight-B5W6OYN7.js`),[],import.meta.url))},{id:`min-dark`,displayName:`Min Dark`,type:`dark`,import:(()=>s(()=>import(`./min-dark-BSWPekZh.js`),[],import.meta.url))},{id:`min-light`,displayName:`Min Light`,type:`light`,import:(()=>s(()=>import(`./min-light-DDpmG2fV.js`),[],import.meta.url))},{id:`monokai`,displayName:`Monokai`,type:`dark`,import:(()=>s(()=>import(`./monokai-CdkpiU2Y.js`),[],import.meta.url))},{id:`night-owl`,displayName:`Night Owl`,type:`dark`,import:(()=>s(()=>import(`./night-owl-DhmEMT88.js`),[],import.meta.url))},{id:`night-owl-light`,displayName:`Night Owl Light`,type:`light`,import:(()=>s(()=>import(`./night-owl-light-eJ-hLW7d.js`),[],import.meta.url))},{id:`nord`,displayName:`Nord`,type:`dark`,import:(()=>s(()=>import(`./nord-Cb4Vim4T.js`),[],import.meta.url))},{id:`one-dark-pro`,displayName:`One Dark Pro`,type:`dark`,import:(()=>s(()=>import(`./one-dark-pro-CLwyXe_n.js`),[],import.meta.url))},{id:`one-light`,displayName:`One Light`,type:`light`,import:(()=>s(()=>import(`./one-light-D7Lr4KcI.js`),[],import.meta.url))},{id:`plastic`,displayName:`Plastic`,type:`dark`,import:(()=>s(()=>import(`./plastic-DQwYfKfQ.js`),[],import.meta.url))},{id:`poimandres`,displayName:`Poimandres`,type:`dark`,import:(()=>s(()=>import(`./poimandres-DRFjx7u4.js`),[],import.meta.url))},{id:`red`,displayName:`Red`,type:`dark`,import:(()=>s(()=>import(`./red-CJ3rzSJv.js`),[],import.meta.url))},{id:`rose-pine`,displayName:`Rosé Pine`,type:`dark`,import:(()=>s(()=>import(`./rose-pine-BthvhNj6.js`),[],import.meta.url))},{id:`rose-pine-dawn`,displayName:`Rosé Pine Dawn`,type:`light`,import:(()=>s(()=>import(`./rose-pine-dawn-Dg85fqjY.js`),[],import.meta.url))},{id:`rose-pine-moon`,displayName:`Rosé Pine Moon`,type:`dark`,import:(()=>s(()=>import(`./rose-pine-moon-hon4tzzS.js`),[],import.meta.url))},{id:`slack-dark`,displayName:`Slack Dark`,type:`dark`,import:(()=>s(()=>import(`./slack-dark-DnToyrRv.js`),[],import.meta.url))},{id:`slack-ochin`,displayName:`Slack Ochin`,type:`light`,import:(()=>s(()=>import(`./slack-ochin-B2OO5cIa.js`),[],import.meta.url))},{id:`snazzy-light`,displayName:`Snazzy Light`,type:`light`,import:(()=>s(()=>import(`./snazzy-light-4G7pJPwS.js`),[],import.meta.url))},{id:`solarized-dark`,displayName:`Solarized Dark`,type:`dark`,import:(()=>s(()=>import(`./solarized-dark-DV17i1UV.js`),[],import.meta.url))},{id:`solarized-light`,displayName:`Solarized Light`,type:`light`,import:(()=>s(()=>import(`./solarized-light-DSh2HLQt.js`),[],import.meta.url))},{id:`synthwave-84`,displayName:`Synthwave '84`,type:`dark`,import:(()=>s(()=>import(`./synthwave-84-nFMaYfgc.js`),[],import.meta.url))},{id:`tokyo-night`,displayName:`Tokyo Night`,type:`dark`,import:(()=>s(()=>import(`./tokyo-night-oM2G3aXe.js`),[],import.meta.url))},{id:`vesper`,displayName:`Vesper`,type:`dark`,import:(()=>s(()=>import(`./vesper-DdrHHSXu.js`),[],import.meta.url))},{id:`vitesse-black`,displayName:`Vitesse Black`,type:`dark`,import:(()=>s(()=>import(`./vitesse-black-fwtXNY1n.js`),[],import.meta.url))},{id:`vitesse-dark`,displayName:`Vitesse Dark`,type:`dark`,import:(()=>s(()=>import(`./vitesse-dark-BZCL-v6S.js`),[],import.meta.url))},{id:`vitesse-light`,displayName:`Vitesse Light`,type:`light`,import:(()=>s(()=>import(`./vitesse-light-VbXTXTou.js`),[],import.meta.url))}].map(e=>[e.id,e.import])),Dp=r({createOnigurumaEngine:()=>$p,getDefaultWasmLoader:()=>Qp,loadWasm:()=>Kp,setDefaultWasmLoader:()=>Zp}),Op=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function kp(){return 2147483648}function Ap(){return typeof performance<`u`?performance.now():Date.now()}var jp=(e,t)=>e+(t-e%t)%t;async function Mp(e){let t,n,r={};function i(e){n=e,r.HEAPU8=new Uint8Array(e),r.HEAPU32=new Uint32Array(e)}function a(e,t,n){r.HEAPU8.copyWithin(e,t,t+n)}function o(e){try{return t.grow(e-n.byteLength+65535>>>16),i(t.buffer),1}catch{}}function s(e){let t=r.HEAPU8.length;e>>>=0;let n=kp();if(e>n)return!1;for(let r=1;r<=4;r*=2){let i=t*(1+.2/r);if(i=Math.min(i,e+100663296),o(Math.min(n,jp(Math.max(e,i),65536))))return!0}return!1}let c=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0;function l(e,t,n=1024){let r=t+n,i=t;for(;e[i]&&!(i>=r);)++i;if(i-t>16&&e.buffer&&c)return c.decode(e.subarray(t,i));let a=``;for(;t<i;){let n=e[t++];if(!(n&128)){a+=String.fromCharCode(n);continue}let r=e[t++]&63;if((n&224)==192){a+=String.fromCharCode((n&31)<<6|r);continue}let i=e[t++]&63;if(n=(n&240)==224?(n&15)<<12|r<<6|i:(n&7)<<18|r<<12|i<<6|e[t++]&63,n<65536)a+=String.fromCharCode(n);else{let e=n-65536;a+=String.fromCharCode(55296|e>>10,56320|e&1023)}}return a}function u(e,t){return e?l(r.HEAPU8,e,t):``}let d={emscripten_get_now:Ap,emscripten_memcpy_big:a,emscripten_resize_heap:s,fd_write:()=>0};async function f(){let n=await e({env:d,wasi_snapshot_preview1:d});t=n.memory,i(t.buffer),Object.assign(r,n),r.UTF8ToString=u}return await f(),r}var Np=Object.defineProperty,Pp=(e,t,n)=>t in e?Np(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,H=(e,t,n)=>Pp(e,typeof t==`symbol`?t:t+``,n),U=null;function Fp(e){throw new Op(e.UTF8ToString(e.getLastOnigError()))}var Ip=class e{constructor(t){H(this,`utf16Length`),H(this,`utf8Length`),H(this,`utf16Value`),H(this,`utf8Value`),H(this,`utf16OffsetToUtf8`),H(this,`utf8OffsetToUtf16`);let n=t.length,r=e._utf8ByteLength(t),i=r!==n,a=i?new Uint32Array(n+1):null;i&&(a[n]=r);let o=i?new Uint32Array(r+1):null;i&&(o[r]=n);let s=new Uint8Array(r),c=0;for(let e=0;e<n;e++){let r=t.charCodeAt(e),l=r,u=!1;if(r>=55296&&r<=56319&&e+1<n){let n=t.charCodeAt(e+1);n>=56320&&n<=57343&&(l=(r-55296<<10)+65536|n-56320,u=!0)}i&&(a[e]=c,u&&(a[e+1]=c),l<=127?o[c+0]=e:l<=2047?(o[c+0]=e,o[c+1]=e):l<=65535?(o[c+0]=e,o[c+1]=e,o[c+2]=e):(o[c+0]=e,o[c+1]=e,o[c+2]=e,o[c+3]=e)),l<=127?s[c++]=l:l<=2047?(s[c++]=192|(l&1984)>>>6,s[c++]=128|(l&63)>>>0):l<=65535?(s[c++]=224|(l&61440)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0):(s[c++]=240|(l&1835008)>>>18,s[c++]=128|(l&258048)>>>12,s[c++]=128|(l&4032)>>>6,s[c++]=128|(l&63)>>>0),u&&e++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=s,this.utf16OffsetToUtf8=a,this.utf8OffsetToUtf16=o}static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n<r;n++){let i=e.charCodeAt(n),a=i,o=!1;if(i>=55296&&i<=56319&&n+1<r){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,o=!0)}a<=127?t+=1:a<=2047?t+=2:a<=65535?t+=3:t+=4,o&&n++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}},Lp=class e{constructor(t){if(H(this,`id`,++e.LAST_ID),H(this,`_onigBinding`),H(this,`content`),H(this,`utf16Length`),H(this,`utf8Length`),H(this,`utf16OffsetToUtf8`),H(this,`utf8OffsetToUtf16`),H(this,`ptr`),!U)throw new Op(`Must invoke loadWasm first.`);this._onigBinding=U,this.content=t;let n=new Ip(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||=U.omalloc(1e4),e._sharedPtrInUse=!0,U.HEAPU8.set(n.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=n.createString(U)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};H(Lp,`LAST_ID`,0),H(Lp,`_sharedPtr`,0),H(Lp,`_sharedPtrInUse`,!1);var Rp=Lp,zp=class{constructor(e){if(H(this,`_onigBinding`),H(this,`_ptr`),!U)throw new Op(`Must invoke loadWasm first.`);let t=[],n=[];for(let r=0,i=e.length;r<i;r++){let i=new Ip(e[r]);t[r]=i.createString(U),n[r]=i.utf8Length}let r=U.omalloc(4*e.length);U.HEAPU32.set(t,r/4);let i=U.omalloc(4*e.length);U.HEAPU32.set(n,i/4);let a=U.createOnigScanner(r,i,e.length);for(let n=0,r=e.length;n<r;n++)U.ofree(t[n]);U.ofree(i),U.ofree(r),a===0&&Fp(U),this._onigBinding=U,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,n){let r=0;if(typeof n==`number`&&(r=n),typeof e==`string`){e=new Rp(e);let n=this._findNextMatchSync(e,t,!1,r);return e.dispose(),n}return this._findNextMatchSync(e,t,!1,r)}_findNextMatchSync(e,t,n,r){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),r);if(a===0)return null;let o=i.HEAPU32,s=a/4,c=o[s++],l=o[s++],u=[];for(let t=0;t<l;t++){let n=e.convertUtf8OffsetToUtf16(o[s++]),r=e.convertUtf8OffsetToUtf16(o[s++]);u[t]={start:n,end:r,length:r-n}}return{index:c,captureIndices:u}}};function Bp(e){return typeof e.instantiator==`function`}function Vp(e){return typeof e.default==`function`}function Hp(e){return e.data!==void 0}function Up(e){return typeof Response<`u`&&e instanceof Response}function Wp(e){return typeof ArrayBuffer<`u`&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<`u`&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||typeof Uint32Array<`u`&&e instanceof Uint32Array}var Gp;function Kp(e){if(Gp)return Gp;async function t(){U=await Mp(async t=>{let n=e;return n=await n,typeof n==`function`&&(n=await n(t)),typeof n==`function`&&(n=await n(t)),Bp(n)?n=await n.instantiator(t):Vp(n)?n=await n.default(t):(Hp(n)&&(n=n.data),Up(n)?n=typeof WebAssembly.instantiateStreaming==`function`?await Jp(n)(t):await Yp(n)(t):Wp(n)||n instanceof WebAssembly.Module?n=await qp(n)(t):`default`in n&&n.default instanceof WebAssembly.Module&&(n=await qp(n.default)(t))),`instance`in n&&(n=n.instance),`exports`in n&&(n=n.exports),n})}return Gp=t(),Gp}function qp(e){return t=>WebAssembly.instantiate(e,t)}function Jp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Yp(e){return async t=>{let n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}var Xp;function Zp(e){Xp=e}function Qp(){return Xp}async function $p(e){return e&&await Kp(e),{createScanner(e){return new zp(e.map(e=>typeof e==`string`?e:e.source))},createString(e){return new Rp(e)}}}var em=yp({});xp(em,Dp);var W=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function tm(e){return nm(e)}function nm(e){return Array.isArray(e)?rm(e):e instanceof RegExp?e:typeof e==`object`?im(e):e}function rm(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=nm(e[n]);return t}function im(e){let t={};for(let n in e)t[n]=nm(e[n]);return t}function am(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function om(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?om(e.substring(0,e.length-1)):e.substr(~t+1)}var sm=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,cm=class{static hasCaptures(e){return e===null?!1:(sm.lastIndex=0,sm.test(e))}static replaceCaptures(e,t,n){return e.replace(sm,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function lm(e,t){return e<t?-1:+(e>t)}function um(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=lm(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function dm(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function fm(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var pm=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},mm=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(ym(e),t)}static createFromParsedTheme(e,t){return xm(e,t)}_cachedMatchRoot=new pm(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>gm(e.parent,t.parentScopes));return n?new vm(n.fontStyle,n.foreground,n.background):null}},hm=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function gm(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!_m(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function _m(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var vm=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function ym(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&dm(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&dm(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new bm(l,u,e,o,s,c)}}return n}var bm=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}},G=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(G||{});function xm(e,t){e.sort((e,t)=>{let n=lm(e.scope,t.scope);return n!==0||(n=um(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new Sm(t),o=new vm(n,a.getId(r),a.getId(i)),s=new Tm(new wm(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new mm(a,o,s)}var Sm=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Cm=Object.freeze([]),wm=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||Cm,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},Tm=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),wm.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(um(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new wm(e,t,n,r,i))}},Em=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=Om(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function Dm(e){return e}function Om(e){return e}function km(e,t){let n=[],r=jm(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(Am(i)){let e=[];do e.push(i),i=r.next();while(Am(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function Am(e){return!!e&&!!e.match(/[\w\.:]+/)}function jm(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Mm(e){typeof e.dispose==`function`&&e.dispose()}var Nm=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Pm=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Fm=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Im=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Nm(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Fm;for(let n of e)Lm(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof Nm){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function Lm(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof Nm?zm({baseGrammar:a,selfGrammar:i},r):Rm(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new Nm(e))}function Rm(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Bm([r],t,n)}}function zm(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Bm(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Bm(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Bm(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?am({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Bm(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Km(i);switch(a.kind){case 0:zm({...t,selfGrammar:t.baseGrammar},n);break;case 1:zm(t,n);break;case 2:Rm(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?Rm(a.ruleName,i,n):zm(i,n)}else a.kind===4?n.add(new Pm(a.scopeName,a.ruleName)):n.add(new Nm(a.scopeName));break}}}var Vm=class{kind=0},Hm=class{kind=1},Um=class{constructor(e){this.ruleName=e}kind=2},Wm=class{constructor(e){this.scopeName=e}kind=3},Gm=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Km(e){if(e===`$base`)return new Vm;if(e===`$self`)return new Hm;let t=e.indexOf(`#`);return t===-1?new Wm(e):t===0?new Um(e.substring(1)):new Gm(e.substring(0,t),e.substring(t+1))}var qm=/\\(\d+)/,Jm=/\\(\d+)/g,Ym=-1,Xm=-2;function Zm(e){return e}function Qm(e){return e}var $m=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=cm.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=cm.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${om(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:cm.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:cm.replaceCaptures(this._contentName,e,t)}},eh=class extends $m{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},th=class extends $m{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new oh(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new sh,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},nh=class extends $m{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new sh,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},rh=class extends $m{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new oh(i,this.id),this.beginCaptures=a,this._end=new oh(o||`￿`,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new sh;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},ih=class extends $m{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new oh(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new oh(o,Xm),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new sh;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new sh,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||`￿`),this._cachedCompiledWhilePatterns}},ah=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new eh(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new th(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=am({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new nh(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new ih(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new rh(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Km(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof nh||e instanceof rh||e instanceof ih)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},oh=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=qm.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return Jm.lastIndex=0,this.source.replace(Jm,(e,t)=>fm(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=`￿`,t[i+1]=`￿`,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=`￿`,t[i+1]=`G`,n[i+1]=`￿`,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},sh=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new ch(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new ch(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},ch=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
118
+ `)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},lh=class{constructor(e,t){this.languageId=e,this.tokenType=t}},uh=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new lh(e,8),this._embeddedLanguagesMatcher=new dh(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new lh(0,0);_getBasicScopeAttributes=new pm(e=>new lh(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},dh=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>fm(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var fh=!1,ph=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function mh(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=hh(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new ph(i,!0);f()}return new ph(i,!1);function f(){let o=gh(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Ym){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),Sh(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof rh){let r=o;Sh(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof ih){let r=o;Sh(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(Sh(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function hh(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof ih&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=bh(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Xm){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),Sh(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function gh(e,t,n,r,i,a){let o=_h(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=vh(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function _h(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=yh(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function vh(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=yh(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function yh(e,t,n,r,i){return fh?{ruleScanner:e.compile(t,n),findOptions:xh(r,i)}:{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function bh(e,t,n,r,i){return fh?{ruleScanner:e.compileWhile(t,n),findOptions:xh(r,i)}:{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function xh(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function Sh(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));mh(e,p,n&&d.start===0,d.start,f,i,!1,0),Mm(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new Ch(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Ch=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function wh(e,t,n,r,i,a,o,s){return new Oh(e,t,n,r,i,a,o,s)}function Th(e,t,n,r,i){let a=km(t,Eh),o=ah.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function Eh(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(Dh(t[r],e))return n=r+1,!0;return!1})}function Dh(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var Oh=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new uh(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=kh(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=km(e,Eh);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)Th(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&Th(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(Zm(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Qm(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=kh(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=ah.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===jh.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=Em.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?Ah.createRootAndLookUpScopeName(a,r,this):Ah.createRoot(`unknown`,r),t=new jh(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
119
+ `;let a=this.createOnigString(e),o=a.content.length,s=new Nh(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=mh(this,a,i,0,t,s,!0,r);return Mm(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function kh(e,t){return e=tm(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Ah=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=hm.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new hm(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new hm(null,t),o=r.themeProvider.themeMatch(a);return new e(null,a,e.mergeAttributes(n,i,o))}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),Em.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a);return new e(t,a,e.mergeAttributes(t.tokenAttributes,i,o))}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},jh=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?Ah.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Qm(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=Ah.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Zm(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Ah.fromExtension(r,n.contentNameScopesList))}},Mh=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):km(e,Eh).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>km(e,Eh).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Nh=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=Em.set(n,0,Dm(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=Em.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},Ph=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,wh(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},Fh=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Ph(mm.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(mm.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new Mh(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new Im(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},Ih=jh.NULL;function Lh(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function Rh(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function zh(e){return Array.isArray(e)?e:[e]}async function Bh(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Vh(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function Hh(e){return e===`ansi`||Vh(e)}function Uh(e){return e===`none`}function Wh(e){return Uh(e)}var Gh=/(\r?\n)/g;function Kh(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(Gh),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var qh={light:`#333333`,dark:`#bbbbbb`},Jh={light:`#fffffe`,dark:`#1e1e1e`},Yh=`__shiki_resolved`;function Xh(e){if(e?.[Yh])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?qh.light:qh.dark,n||=t.type===`light`?Jh.light:Jh.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Yh,{enumerable:!1,writable:!1,value:!0}),t}async function Zh(e){return[...new Set((await Promise.all(e.filter(e=>!Hh(e)).map(async e=>await Bh(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Qh(e){return(await Promise.all(e.map(async e=>Wh(e)?null:Xh(await Bh(e))))).filter(e=>!!e)}function $h(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new W(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var eg=class extends Fh{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=Xh(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=mm.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=$h(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new W(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},tg=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},ng=0;function rg(e){ng+=1,e.warnings!==!1&&ng>=10&&ng%10==0&&console.warn(`[Shiki] ${ng} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new W("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Xh),i=new eg(new tg(e.engine,n),r,n,e.langAlias),a;function o(t){return $h(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new W(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new W(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await Zh(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Qh(e))}function g(){if(t)throw new W(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--ng)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function ig(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Qh(e.themes||[]),Zh(e.langs||[]),e.engine]);return rg({...e,themes:t,langs:n,engine:r})}var ag=new WeakMap;function og(e,t){ag.set(e,t)}function sg(e){return ag.get(e)}var cg=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(zh(n).map(e=>[e,Ih])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return lg(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function lg(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function ug(e,t){if(!(e instanceof cg))throw new W(`Invalid grammar state`);return e.getInternalStack(t)}var dg=/,/,fg=/ /;function pg(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Vh(e.resolveLangAlias(n.lang||`text`))||Uh(r))return Kh(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new W(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new W(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return hg(t,o,i,a,n)}function mg(...e){if(e.length===2)return sg(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Vh(i)||Uh(a))throw new W(`Plain language does not have grammar state`);if(i===`ansi`)throw new W(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new cg(gg(n,c,o,s,r).stateStack,c.name,o.name)}function hg(e,t,n,r,i){let a=gg(e,t,n,r,i),o=new cg(a.stateStack,t.name,n.name);return og(a.tokens,o),a.tokens}function gg(e,t,n,r,i){let a=Lh(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500}=i,c=Kh(e),l=i.grammarState?ug(i.grammarState,n.name)??Ih:i.grammarContextCode==null?Ih:gg(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,u=[],d=[];for(let e=0,f=c.length;e<f;e++){let[f,p]=c[e];if(f===``){u=[],d.push([]);continue}if(o>0&&f.length>=o){u=[],d.push([{content:f,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;i.includeExplanation&&(m=t.tokenizeLine(f,l,s),h=m.tokens,g=0);let _=t.tokenizeLine2(f,l,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:f.length;if(t===o)continue;let s=_.tokens[2*e+1],c=Rh(r[Em.getForeground(s)],a),l=Em.getFontStyle(s),d={content:f.substring(t,o),offset:p+t,color:c,fontStyle:l};if(i.includeExplanation){let e=[];if(i.includeExplanation!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(dg).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(fg))})}d.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=f.substring(t.startIndex,t.endIndex);r+=n.length,d.explanation.push({content:n,scopes:i.includeExplanation===`scopeName`?_g(t.scopes):vg(e,t.scopes)}),g+=1}}u.push(d)}d.push(u),u=[],l=_.ruleStack}return{tokens:d,stateStack:l}}function _g(e){return e.map(e=>({scopeName:e}))}function vg(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:xg(e,i,t.slice(0,r))}}return n}function yg(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function bg(e,t,n){if(!yg(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)yg(e[r],n[i])&&--r,--i;return r===-1}function xg(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(bg(e,t,n)){r.push(a);break}return r}function Sg(e,t,n,r=pg){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:sg(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=Cg(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new cg(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&og(s,c),s}function Cg(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var wg=/\s+/g;function Tg(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(wg)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(wg);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}var Eg=/:?lang=["']([^"']+)["']/g,Dg=/(?:```|~~~)([\w-]+)/g,Og=/\\begin\{([\w-]+)\}/g,kg=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function Ag(e){let t=Kh(e,!0).map(([e])=>e);function n(n){if(n===e.length)return{line:t.length-1,character:t.at(-1).length};let r=n,i=0;for(let e of t){if(r<e.length)break;r-=e.length,i++}return{line:i,character:r}}function r(e,n){let r=0;for(let n=0;n<e;n++)r+=t[n].length;return r+=n,r}return{lines:t,indexToPos:n,posToIndex:r}}function jg(e,t,n){let r=new Set;for(let t of e.matchAll(Eg)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(Dg)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(Og)){let e=t[1].toLowerCase().trim();e&&r.add(e)}for(let t of e.matchAll(kg)){let e=t[1].toLowerCase().trim(),n=e.includes(`/`)?e.split(`/`).pop():e;n&&r.add(n)}if(!n)return[...r];let i=n.getBundledLanguages();return[...r].filter(e=>e&&i[e])}var Mg=[`color`,`background-color`];function Ng(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Pg(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=n.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);return t.length?Ng(e,t):e})):e}function Fg(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Ig(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&Mg.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new W('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');c[a]=`light-dark(${o[e][a]||`inherit`}, ${o[r][a]||`inherit`})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function Ig(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&G.Italic&&(t[`font-style`]=`italic`),e.fontStyle&G.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&G.Underline&&n.push(`underline`),e.fontStyle&G.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Lg(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Rg(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=Ag(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new W(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new W(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new W(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));zg(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return Pg(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new W(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=Bg(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new W(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new W(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&Tg(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.unshift(()=>a(r,e));i(n.line,0,n.character,e)}}s.forEach(e=>e())}}}function zg(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new W(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new W(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Bg(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(Bg).join(``):``}var Vg=[Rg()];function Hg(e){let t=Ug(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Vg]}function Ug(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Wg=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Gg={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Kg(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function qg(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function Jg(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Gg[r]&&t.push({type:`setDecoration`,value:Gg[r]});else if(r<=29){let e=Gg[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Wg[r-30]}});else if(r===38){let n=qg(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Wg[r-40]}});else if(r===48){let n=qg(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Wg[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Wg[r-100+8]}})}return t}function Yg(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Kg(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=Jg(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var Xg={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function Zg(e=Xg){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Wg.length;e++)r.push(t(Wg[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var Qg=/#([0-9a-f]{3,8})/i,$g=/var\((--[\w-]+-ansi-[\w-]+)\)/,e_={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function t_(e,t,n){let r=Lh(e,n),i=Kh(t),a=Zg(Object.fromEntries(Wg.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||e_[t]]}))),o=Yg();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=Rh(i,r),o=Rh(o,r),n.decorations.has(`dim`)&&(i=n_(i));let s=G.None;return n.decorations.has(`bold`)&&(s|=G.Bold),n.decorations.has(`italic`)&&(s|=G.Italic),n.decorations.has(`underline`)&&(s|=G.Underline),n.decorations.has(`strikethrough`)&&(s|=G.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function n_(e){let t=e.match(Qg);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match($g);return n?`var(${n[1]}-dim)`:e}function r_(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!Vh(r)&&!Uh(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return t_(r,t,n)}return pg(e,t,n)}function i_(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new W("`themes` option must not be empty");let p=Sg(e,t,n,r_);if(c=sg(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new W(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>Fg(e,h,u,l,d))),c&&og(a,c);let g=f.map(e=>Lh(e.theme,n));i=a_(f,m,g,u,l,`fg`,d),r=a_(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=Lh(n.theme,n);a=r_(e,t,n);let l=e.getTheme(n.theme);r=Rh(l.bg,s),i=Rh(l.fg,s),o=l.name,c=sg(a)}else throw new W("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function a_(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=Rh(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new W('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Rh(t[r][a],n[r])||`inherit`}, ${Rh(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var o_=/^\s+$/,s_=/^(\s*)(.*?)(\s*)$/;function c_(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>c_(e,t,n),codeToTokens:(t,n)=>i_(e,t,n)}){let i=t;for(let e of Hg(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=i_(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=u_(a):d===`never`&&(a=d_(a)),f&&(a=f_(a));let p={...r,get source(){return i}};for(let e of Hg(n))a=e.tokens?.call(p,a)||a;return l_(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function l_(e,t,n,r=sg(e)){let i=Hg(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:Tg,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
120
+ `}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Lg(a.htmlStyle||Ig(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&og(m,r),m}function u_(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&G.Underline||i.fontStyle&G.Strikethrough));o&&o_.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function d_(e){return e.map(e=>e.flatMap(e=>{if(o_.test(e.content))return e;let t=e.content.match(s_);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function f_(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Lg(e.htmlStyle||Ig(e)),i=Lg(n.htmlStyle||Ig(n)),a=e.fontStyle&&(e.fontStyle&G.Underline||e.fontStyle&G.Strikethrough),o=n.fontStyle&&(n.fontStyle&G.Underline||n.fontStyle&G.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var p_=qt;function m_(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>c_(e,t,n),codeToTokens:(t,n)=>i_(e,t,n)},i=p_(c_(e,t,n,r));for(let e of Hg(n))i=e.postprocess?.call(r,i,n)||i;return i}async function h_(e){let t=await ig(e);return{getLastGrammarState:(...e)=>mg(t,...e),codeToTokensBase:(e,n)=>r_(t,e,n),codeToTokensWithThemes:(e,n)=>Sg(t,e,n),codeToTokens:(e,n)=>i_(t,e,n),codeToHast:(e,n)=>c_(t,e,n),codeToHtml:(e,n)=>m_(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function g_(e){let t=e.langs,n=e.themes,r=e.engine;async function i(e){function i(n){if(typeof n==`string`){if(n=e.langAlias?.[n]||n,Hh(n))return[];let r=t[n];if(!r)throw new W(`Language \`${n}\` is not included in this bundle. You may want to load it from external source.`);return r}return n}function a(e){if(Wh(e))return`none`;if(typeof e==`string`){let t=n[e];if(!t)throw new W(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);return t}return e}let o=(e.themes??[]).map(e=>a(e)),s=(e.langs??[]).map(e=>i(e)),c=await h_({engine:e.engine??r(),...e,themes:o,langs:s});return{...c,loadLanguage(...e){return c.loadLanguage(...e.map(i))},loadTheme(...e){return c.loadTheme(...e.map(a))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return i}function __(e){let t;async function n(n={}){if(t){let e=await t;return await Promise.all([e.loadTheme(...n.themes||[]),e.loadLanguage(...n.langs||[])]),e}else{t=e({...n,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...n.themes||[]),r.loadLanguage(...n.langs||[])]),r}}return n}function v_(e,t){let n=__(e);async function r(e,r){let i=await n({langs:[r.lang],themes:`theme`in r?[r.theme]:Object.values(r.themes)}),a=await t?.guessEmbeddedLanguages?.(e,r.lang,i);return a&&await i.loadLanguage(...a),i}return{getSingletonHighlighter(e){return n(e)},async codeToHtml(e,t){return(await r(e,t)).codeToHtml(e,t)},async codeToHast(e,t){return(await r(e,t)).codeToHast(e,t)},async codeToTokens(e,t){return(await r(e,t)).codeToTokens(e,t)},async codeToTokensBase(e,t){return(await r(e,t)).codeToTokensBase(e,t)},async codeToTokensWithThemes(e,t){return(await r(e,t)).codeToTokensWithThemes(e,t)},async getLastGrammarState(e,t){return(await n({langs:[t.lang],themes:[t.theme]})).getLastGrammarState(e,t)}}}var{codeToHtml:y_,codeToHast:b_,codeToTokens:x_,codeToTokensBase:S_,codeToTokensWithThemes:C_,getSingletonHighlighter:w_,getLastGrammarState:T_}=v_(g_({langs:Tp,themes:Ep,engine:()=>(0,em.createOnigurumaEngine)(s(()=>import(`./wasm-BnjxR4X6.js`),[],import.meta.url))}),{guessEmbeddedLanguages:jg}),E_=(0,F.createContext)({code:``}),D_={name:`line-numbers`,line(e,t){e.children.unshift({type:`element`,tagName:`span`,properties:{className:[`inline-block`,`min-w-10`,`mr-4`,`text-right`,`select-none`,`text-muted-foreground`]},children:[{type:`text`,value:String(t)}]})}};async function O_(e,t,n=!1){let r=n?[D_]:[];return await Promise.all([y_(e,{lang:t,theme:`one-light`,transformers:r}),y_(e,{lang:t,theme:`one-dark-pro`,transformers:r})])}var k_=({code:e,language:t,showLineNumbers:n=!1,className:r,children:i,...a})=>{let[o,s]=(0,F.useState)(``),[c,l]=(0,F.useState)(``),u=(0,F.useRef)(!1);return(0,F.useEffect)(()=>(O_(e,t,n).then(([e,t])=>{u.current||=(s(e),l(t),!0)}),()=>{u.current=!1}),[e,t,n]),(0,L.jsx)(E_.Provider,{value:{code:e},children:(0,L.jsx)(`div`,{className:j(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,r),...a,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`div`,{className:`overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:o}}),(0,L.jsx)(`div`,{className:`hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:c}}),i&&(0,L.jsx)(`div`,{className:`absolute top-2 right-2 flex items-center gap-2`,children:i})]})})})},A_=({className:e,...t})=>(0,L.jsx)(Re,{className:j(`not-prose mb-4 w-full rounded-md border`,e),...t}),j_=e=>(0,L.jsxs)(Qe,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,L.jsx)(tt,{className:`size-4`}),"input-available":(0,L.jsx)(Je,{className:`size-4 animate-pulse`}),"approval-requested":(0,L.jsx)(Je,{className:`size-4 text-yellow-600`}),"approval-responded":(0,L.jsx)(Fe,{className:`size-4 text-blue-600`}),"output-available":(0,L.jsx)(Fe,{className:`size-4 text-green-600`}),"output-error":(0,L.jsx)(_t,{className:`size-4 text-red-600`}),"output-denied":(0,L.jsx)(_t,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),M_=({className:e,title:t,type:n,state:r,...i})=>(0,L.jsxs)(ye,{className:j(`flex w-full items-center justify-between gap-4 p-3`,e),...i,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Dt,{className:`size-4 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`font-medium text-sm`,children:t??n.split(`-`).slice(1).join(`-`)}),j_(r)]}),(0,L.jsx)(Ce,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),N_=({className:e,...t})=>(0,L.jsx)(fe,{className:j(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),P_=({className:e,input:t,...n})=>(0,L.jsxs)(`div`,{className:j(`space-y-2 overflow-hidden p-4`,e),...n,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,L.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,L.jsx)(k_,{code:JSON.stringify(t,null,2),language:`json`})})]}),F_=({className:e,output:t,errorText:n,...r})=>{if(!(t||n))return null;let i=(0,L.jsx)(`div`,{children:t});return typeof t==`object`&&!(0,F.isValidElement)(t)?i=(0,L.jsx)(k_,{code:JSON.stringify(t,null,2),language:`json`}):typeof t==`string`&&(i=(0,L.jsx)(k_,{code:t,language:`json`})),(0,L.jsxs)(`div`,{className:j(`space-y-2 p-4`,e),...r,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:n?`Error`:`Result`}),(0,L.jsxs)(`div`,{className:j(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,n?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`),children:[n&&(0,L.jsx)(`div`,{children:n}),i]})]})},I_=(0,F.createContext)({});function L_(e){let t=(0,F.useRef)(null);return t.current===null&&(t.current=e()),t.current}var R_=typeof window<`u`?F.useLayoutEffect:F.useEffect,z_=(0,F.createContext)(null);function B_(e,t){e.indexOf(t)===-1&&e.push(t)}function V_(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var H_=(e,t,n)=>n>t?t:n<e?e:n,U_={},W_=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),G_=e=>typeof e==`object`&&!!e,K_=e=>/^0[^.\s]+$/u.test(e);function q_(e){let t;return()=>(t===void 0&&(t=e()),t)}var J_=e=>e,Y_=(...e)=>e.reduce((e,t)=>n=>t(e(n))),X_=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},Z_=class{constructor(){this.subscriptions=[]}add(e){return B_(this.subscriptions,e),()=>V_(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Q_=e=>e*1e3,$_=e=>e/1e3,ev=(e,t)=>t?1e3/t*e:0,tv=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,nv=1e-7,rv=12;function iv(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=tv(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>nv&&++s<rv);return o}function av(e,t,n,r){if(e===t&&n===r)return J_;let i=t=>iv(t,0,1,e,n);return e=>e===0||e===1?e:tv(i(e),t,r)}var ov=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,sv=e=>t=>1-e(1-t),cv=av(.33,1.53,.69,.99),lv=sv(cv),uv=ov(lv),dv=e=>e>=1?1:(e*=2)<1?.5*lv(e):.5*(2-2**(-10*(e-1))),fv=e=>1-Math.sin(Math.acos(e)),pv=sv(fv),mv=ov(fv),hv=av(.42,0,1,1),gv=av(0,0,.58,1),_v=av(.42,0,.58,1),vv=e=>Array.isArray(e)&&typeof e[0]!=`number`,yv=e=>Array.isArray(e)&&typeof e[0]==`number`,bv={linear:J_,easeIn:hv,easeInOut:_v,easeOut:gv,circIn:fv,circInOut:mv,circOut:pv,backIn:lv,backInOut:uv,backOut:cv,anticipate:dv},xv=e=>typeof e==`string`,Sv=e=>{if(yv(e)){e.length;let[t,n,r,i]=e;return av(t,n,r,i)}else if(xv(e))return bv[e],`${e}`,bv[e];return e},Cv=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],wv={value:null,addProjectionMetrics:null};function Tv(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&wv.value&&wv.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var Ev=40;function Dv(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Cv.reduce((e,n)=>(e[n]=Tv(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=U_.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Ev),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Cv.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Cv.length;t++)o[Cv[t]].cancel(e)},state:i,steps:o}}var{schedule:K,cancel:Ov,state:q,steps:kv}=Dv(typeof requestAnimationFrame<`u`?requestAnimationFrame:J_,!0),Av;function jv(){Av=void 0}var Mv={now:()=>(Av===void 0&&Mv.set(q.isProcessing||U_.useManualTiming?q.timestamp:performance.now()),Av),set:e=>{Av=e,queueMicrotask(jv)}},Nv={layout:0,mainThread:0,waapi:0},Pv=e=>t=>typeof t==`string`&&t.startsWith(e),Fv=Pv(`--`),Iv=Pv(`var(--`),Lv=e=>Iv(e)?Rv.test(e.split(`/*`)[0].trim()):!1,Rv=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function zv(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Bv={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Vv={...Bv,transform:e=>H_(0,1,e)},Hv={...Bv,default:1},Uv=e=>Math.round(e*1e5)/1e5,Wv=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Gv(e){return e==null}var Kv=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,qv=(e,t)=>n=>!!(typeof n==`string`&&Kv.test(n)&&n.startsWith(e)||t&&!Gv(n)&&Object.prototype.hasOwnProperty.call(n,t)),Jv=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Wv);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Yv=e=>H_(0,255,e),Xv={...Bv,transform:e=>Math.round(Yv(e))},Zv={test:qv(`rgb`,`red`),parse:Jv(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Xv.transform(e)+`, `+Xv.transform(t)+`, `+Xv.transform(n)+`, `+Uv(Vv.transform(r))+`)`};function Qv(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var $v={test:qv(`#`),parse:Qv,transform:Zv.transform},ey=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ty=ey(`deg`),ny=ey(`%`),J=ey(`px`),ry=ey(`vh`),iy=ey(`vw`),ay={...ny,parse:e=>ny.parse(e)/100,transform:e=>ny.transform(e*100)},oy={test:qv(`hsl`,`hue`),parse:Jv(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ny.transform(Uv(t))+`, `+ny.transform(Uv(n))+`, `+Uv(Vv.transform(r))+`)`},Y={test:e=>Zv.test(e)||$v.test(e)||oy.test(e),parse:e=>Zv.test(e)?Zv.parse(e):oy.test(e)?oy.parse(e):$v.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Zv.transform(e):oy.transform(e),getAnimatableNone:e=>{let t=Y.parse(e);return t.alpha=0,Y.transform(t)}},sy=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function cy(e){return isNaN(e)&&typeof e==`string`&&(e.match(Wv)?.length||0)+(e.match(sy)?.length||0)>0}var ly=`number`,uy=`color`,dy=`var`,fy=`var(`,py="${}",my=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function hy(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(my,e=>(Y.test(e)?(r.color.push(a),i.push(uy),n.push(Y.parse(e))):e.startsWith(fy)?(r.var.push(a),i.push(dy),n.push(e)):(r.number.push(a),i.push(ly),n.push(parseFloat(e))),++a,py)).split(py),indexes:r,types:i}}function gy(e){return hy(e).values}function _y({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===ly?i+=Uv(r[a]):e===uy?i+=Y.transform(r[a]):i+=r[a]}return i}}function vy(e){return _y(hy(e))}var yy=e=>typeof e==`number`?0:Y.test(e)?Y.getAnimatableNone(e):e,by=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:yy(e);function xy(e){let t=hy(e);return _y(t)(t.values.map((e,n)=>by(e,t.split[n])))}var Sy={test:cy,parse:gy,createTransformer:vy,getAnimatableNone:xy};function Cy(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function wy({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Cy(s,r,e+1/3),a=Cy(s,r,e),o=Cy(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Ty(e,t){return n=>n>0?t:e}var X=(e,t,n)=>e+(t-e)*n,Ey=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Dy=[$v,Zv,oy],Oy=e=>Dy.find(t=>t.test(e));function ky(e){let t=Oy(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===oy&&(n=wy(n)),n}var Ay=(e,t)=>{let n=ky(e),r=ky(t);if(!n||!r)return Ty(e,t);let i={...n};return e=>(i.red=Ey(n.red,r.red,e),i.green=Ey(n.green,r.green,e),i.blue=Ey(n.blue,r.blue,e),i.alpha=X(n.alpha,r.alpha,e),Zv.transform(i))},jy=new Set([`none`,`hidden`]);function My(e,t){return jy.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ny(e,t){return n=>X(e,t,n)}function Py(e){return typeof e==`number`?Ny:typeof e==`string`?Lv(e)?Ty:Y.test(e)?Ay:Ry:Array.isArray(e)?Fy:typeof e==`object`?Y.test(e)?Ay:Iy:Ty}function Fy(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Py(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Iy(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Py(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Ly(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Ry=(e,t)=>{let n=Sy.createTransformer(t),r=hy(e),i=hy(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?jy.has(e)&&!i.values.length||jy.has(t)&&!r.values.length?My(e,t):Y_(Fy(Ly(r,i),i.values),n):(`${e}${t}`,Ty(e,t))};function zy(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?X(e,t,n):Py(e)(e,t)}var By=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>K.update(t,e),stop:()=>Ov(t),now:()=>q.isProcessing?q.timestamp:Mv.now()}},Vy=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Hy=2e4;function Uy(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Wy(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Uy(r),Hy);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:$_(i)}}var Z={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Gy(e,t){return e*Math.sqrt(1-t*t)}var Ky=12;function qy(e,t,n){let r=n;for(let n=1;n<Ky;n++)r-=e(r)/t(r);return r}var Jy=.001;function Yy({duration:e=Z.duration,bounce:t=Z.bounce,velocity:n=Z.velocity,mass:r=Z.mass}){let i,a;Z.maxDuration;let o=1-t;o=H_(Z.minDamping,Z.maxDamping,o),e=H_(Z.minDuration,Z.maxDuration,$_(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Gy(t,o),c=Math.exp(-i);return Jy-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Gy(t**2,o);return(-i(t)+Jy>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=qy(i,a,s);if(e=Q_(e),isNaN(c))return{stiffness:Z.stiffness,damping:Z.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Xy=[`duration`,`bounce`],Zy=[`stiffness`,`damping`,`mass`];function Qy(e,t){return t.some(t=>e[t]!==void 0)}function $y(e){let t={velocity:Z.velocity,stiffness:Z.stiffness,damping:Z.damping,mass:Z.mass,isResolvedFromDuration:!1,...e};if(!Qy(e,Zy)&&Qy(e,Xy))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*H_(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Z.mass,stiffness:i,damping:a}}else{let n=Yy({...e,velocity:0});t={...t,...n,mass:Z.mass},t.isResolvedFromDuration=!0}return t}function eb(e=Z.visualDuration,t=Z.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=$y({...n,velocity:-$_(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=$_(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Z.restSpeed.granular:Z.restSpeed.default,i||=v?Z.restDelta.granular:Z.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Gy(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>Q_(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=Q_(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=Q_(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(Uy(T),Hy),t=Vy(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}eb.applyToOptions=e=>{let t=Wy(e,100,eb);return e.ease=t.ease,e.duration=Q_(t.duration),e.type=`keyframes`,e};var tb=5;function nb(e,t,n){let r=Math.max(t-tb,0);return ev(n-e(r),t-r)}function rb({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=eb({keyframes:[f.value,m(f.value)],velocity:nb(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function ib(e,t,n){let r=[],i=n||U_.mix||zy,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Y_(Array.isArray(t)?t[n]||J_:t,a)),r.push(a)}return r}function ab(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=ib(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=X_(e[r],e[r+1],n);return s[r](i)};return n?t=>l(H_(e[0],e[a-1],t)):l}function ob(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=X_(0,t,r);e.push(X(n,1,i))}}function sb(e){let t=[0];return ob(t,e.length-1),t}function cb(e,t){return e.map(e=>e*t)}function lb(e,t){return e.map(()=>t||_v).splice(0,e.length-1)}function ub({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=vv(r)?r.map(Sv):Sv(r),a={done:!1,value:t[0]},o=ab(cb(n&&n.length===t.length?n:sb(t),e),t,{ease:Array.isArray(i)?i:lb(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var db=e=>e!==null;function fb(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(db),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var pb={decay:rb,inertia:rb,tween:ub,keyframes:ub,spring:eb};function mb(e){typeof e.type==`string`&&(e.type=pb[e.type])}var hb=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},gb=e=>e/100,_b=class extends hb{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Mv.now()&&this.tick(Mv.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Nv.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;mb(e);let{type:t=ub,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||ub;s!==ub&&typeof o[0]!=`number`&&(this.mixKeyframes=Y_(gb,zy(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Uy(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=H_(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==rb&&(b.value=fb(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return $_(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+$_(e)}get time(){return $_(this.currentTime)}set time(e){e=Q_(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return nb(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Mv.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=$_(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=By,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Mv.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,Nv.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function vb(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var yb=e=>e*180/Math.PI,bb=e=>Sb(yb(Math.atan2(e[1],e[0]))),xb={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:bb,rotateZ:bb,skewX:e=>yb(Math.atan(e[1])),skewY:e=>yb(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Sb=e=>(e%=360,e<0&&(e+=360),e),Cb=bb,wb=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Tb=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Eb={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:wb,scaleY:Tb,scale:e=>(wb(e)+Tb(e))/2,rotateX:e=>Sb(yb(Math.atan2(e[6],e[5]))),rotateY:e=>Sb(yb(Math.atan2(-e[2],e[0]))),rotateZ:Cb,rotate:Cb,skewX:e=>yb(Math.atan(e[4])),skewY:e=>yb(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Db(e){return+!!e.includes(`scale`)}function Ob(e,t){if(!e||e===`none`)return Db(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=Eb,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=xb,i=t}if(!i)return Db(t);let a=r[t],o=i[1].split(`,`).map(Ab);return typeof a==`function`?a(o):o[a]}var kb=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return Ob(n,t)};function Ab(e){return parseFloat(e.trim())}var jb=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Mb=new Set([...jb,`pathRotation`]),Nb=e=>e===Bv||e===J,Pb=new Set([`x`,`y`,`z`]),Fb=jb.filter(e=>!Pb.has(e));function Ib(e){let t=[];return Fb.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var Lb={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Ob(t,`x`),y:(e,{transform:t})=>Ob(t,`y`)};Lb.translateX=Lb.x,Lb.translateY=Lb.y;var Rb=new Set,zb=!1,Bb=!1,Vb=!1;function Hb(){if(Bb){let e=Array.from(Rb).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Ib(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Bb=!1,zb=!1,Rb.forEach(e=>e.complete(Vb)),Rb.clear()}function Ub(){Rb.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Bb=!0)})}function Wb(){Vb=!0,Ub(),Hb(),Vb=!1}var Gb=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Rb.add(this),zb||(zb=!0,K.read(Ub),K.resolveKeyframes(Hb))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}vb(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Rb.delete(this)}cancel(){this.state===`scheduled`&&(Rb.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Kb=e=>e.startsWith(`--`);function qb(e,t,n){Kb(t)?e.style.setProperty(t,n):e.style[t]=n}var Jb={};function Yb(e,t){let n=q_(e);return()=>Jb[t]??n()}var Xb=Yb(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Zb=Yb(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Qb=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,$b={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Qb([0,.65,.55,1]),circOut:Qb([.55,0,1,.45]),backIn:Qb([.31,.01,.66,-.59]),backOut:Qb([.33,1.53,.69,.99])};function ex(e,t){if(e)return typeof e==`function`?Zb()?Vy(e,t):`ease-out`:yv(e)?Qb(e):Array.isArray(e)?e.map(e=>ex(e,t)||$b.easeOut):$b[e]}function tx(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=ex(s,i);Array.isArray(d)&&(u.easing=d),wv.value&&Nv.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return wv.value&&p.finished.finally(()=>{Nv.waapi--}),p}function nx(e){return typeof e==`function`&&`applyToOptions`in e}function rx({type:e,...t}){return nx(e)&&Zb()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var ix=class extends hb{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=rx(e);this.animation=tx(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=fb(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),qb(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return $_(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+$_(e)}get time(){return $_(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Q_(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&Xb()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),J_):r(this)}},ax={anticipate:dv,backInOut:uv,circInOut:mv};function ox(e){return e in ax}function sx(e){typeof e.ease==`string`&&ox(e.ease)&&(e.ease=ax[e.ease])}var cx=10,lx=class extends ix{constructor(e){sx(e),mb(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new _b({...a,autoplay:!1}),s=Math.max(cx,Mv.now()-this.startTime),c=H_(0,cx,s-cx),l=o.sample(s).value,{name:u}=this.options;i&&u&&qb(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},ux=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Sy.test(e)||e===`0`)&&!e.startsWith(`url(`));function dx(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function fx(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=ux(i,t),s=ux(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:dx(e)||(n===`spring`||nx(n))&&r}function px(e){e.duration=0,e.type=`keyframes`}var mx=new Set([`opacity`,`clipPath`,`filter`,`transform`]),hx=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function gx(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&hx.test(e[t]))return!0;return!1}var _x=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),vx=q_(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function yx(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return vx()&&n&&(mx.has(n)||_x.has(n)&&gx(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var bx=40,xx=class extends hb{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Mv.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||Gb;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Mv.now();let u=!0;fx(e,i,a,o)||(u=!1,(U_.instantAnimations||!s)&&l?.(fb(e,n,t)),e[0]=e[e.length-1],px(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>bx?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&yx(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new lx({...d,element:p})}catch{m=new _b(d)}else m=new _b(d);m.finished.then(()=>{this.notifyFinished()}).catch(J_),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Wb()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Sx(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Cx=30,wx=e=>!isNaN(parseFloat(e)),Tx={current:void 0},Ex=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Mv.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Mv.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=wx(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new Z_);let n=this.events[e].add(t);return e===`change`?()=>{n(),K.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Tx.current&&Tx.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Mv.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Cx)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Cx);return ev(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Dx(e,t){return new Ex(e,t)}function Ox(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function kx(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Ox(n,e)}var Ax={type:`spring`,stiffness:500,damping:25,restSpeed:10},jx=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Mx={type:`keyframes`,duration:.8},Nx={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Px=(e,{keyframes:t})=>t.length>2?Mx:Mb.has(e)?e.startsWith(`scale`)?jx(t[1]):Ax:Nx,Fx=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Ix(e){for(let t in e)if(!Fx.has(t))return!0;return!1}var Lx=(e,t,n,r={},i,a)=>o=>{let s=kx(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Q_(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Ix(s)||Object.assign(u,Px(e,u)),u.duration&&=Q_(u.duration),u.repeatDelay&&=Q_(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(px(u),u.delay===0&&(d=!0)),(U_.instantAnimations||U_.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,px(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=fb(u.keyframes,s);if(e!==void 0){K.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new _b(u):new xx(u)},Rx=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function zx(e){let t=Rx.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Bx(e,t,n=1){`${e}`;let[r,i]=zx(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return W_(e)?parseFloat(e):e}return Lv(i)?Bx(i,t,n+1):i}function Vx(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Hx(e,t,n,r){if(typeof t==`function`){let[i,a]=Vx(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Vx(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Ux(e,t,n){let r=e.getProps();return Hx(r,t,n===void 0?r.custom:n,e)}var Wx=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...jb]),Gx=e=>Array.isArray(e);function Kx(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Dx(n))}function qx(e){return Gx(e)?e[e.length-1]||0:e}function Jx(e,t){let{transitionEnd:n={},transition:r={},...i}=Ux(e,t)||{};i={...i,...n};for(let t in i)Kx(e,t,qx(i[t]))}var Q=e=>!!(e&&e.getVelocity);function Yx(e){return!!(Q(e)&&e.add)}function Xx(e,t){let n=e.getValue(`willChange`);if(Yx(n))return n.add(t);if(!n&&U_.WillChange){let n=new U_.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Zx(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Qx=`data-`+Zx(`framerAppearId`);function $x(e){return e.props[Qx]}function eS({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function tS(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Ox(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&eS(f,t))continue;let o={delay:n,...kx(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){K.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=$x(e);if(n){let e=window.MotionHandoffAnimation(n,t,K);e!==null&&(o.startTime=e,p=!0)}}Xx(e,t);let m=l??e.shouldReduceMotion;r.start(Lx(t,r,i,m&&Wx.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>K.update(()=>{o&&Jx(e,o)});d.length?Promise.all(d).then(t):t()}return d}function nS(e,t,n={}){let r=Ux(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(tS(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return rS(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function rS(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(nS(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Sx(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function iS(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>nS(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=nS(e,t,n);else{let i=typeof t==`function`?Ux(e,t,n.custom):t;r=Promise.all(tS(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var aS={test:e=>e===`auto`,parse:e=>e},oS=e=>t=>t.test(e),sS=[Bv,J,ny,ty,iy,ry,aS],cS=e=>sS.find(oS(e));function lS(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||K_(e)}var uS=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function dS(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Wv)||[];if(!r)return e;let i=n.replace(r,``),a=+!!uS.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var fS=/\b([a-z-]*)\(.*?\)/gu,pS={...Sy,getAnimatableNone:e=>{let t=e.match(fS);return t?t.map(dS).join(` `):e}},mS={...Sy,getAnimatableNone:e=>{let t=Sy.parse(e);return Sy.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},hS={...Bv,transform:Math.round},gS={borderWidth:J,borderTopWidth:J,borderRightWidth:J,borderBottomWidth:J,borderLeftWidth:J,borderRadius:J,borderTopLeftRadius:J,borderTopRightRadius:J,borderBottomRightRadius:J,borderBottomLeftRadius:J,width:J,maxWidth:J,height:J,maxHeight:J,top:J,right:J,bottom:J,left:J,inset:J,insetBlock:J,insetBlockStart:J,insetBlockEnd:J,insetInline:J,insetInlineStart:J,insetInlineEnd:J,padding:J,paddingTop:J,paddingRight:J,paddingBottom:J,paddingLeft:J,paddingBlock:J,paddingBlockStart:J,paddingBlockEnd:J,paddingInline:J,paddingInlineStart:J,paddingInlineEnd:J,margin:J,marginTop:J,marginRight:J,marginBottom:J,marginLeft:J,marginBlock:J,marginBlockStart:J,marginBlockEnd:J,marginInline:J,marginInlineStart:J,marginInlineEnd:J,fontSize:J,backgroundPositionX:J,backgroundPositionY:J,rotate:ty,pathRotation:ty,rotateX:ty,rotateY:ty,rotateZ:ty,scale:Hv,scaleX:Hv,scaleY:Hv,scaleZ:Hv,skew:ty,skewX:ty,skewY:ty,distance:J,translateX:J,translateY:J,translateZ:J,x:J,y:J,z:J,perspective:J,transformPerspective:J,opacity:Vv,originX:ay,originY:ay,originZ:J,zIndex:hS,fillOpacity:Vv,strokeOpacity:Vv,numOctaves:hS},_S={...gS,color:Y,backgroundColor:Y,outlineColor:Y,fill:Y,stroke:Y,borderColor:Y,borderTopColor:Y,borderRightColor:Y,borderBottomColor:Y,borderLeftColor:Y,filter:pS,WebkitFilter:pS,mask:mS,WebkitMask:mS},vS=e=>_S[e],yS=new Set([pS,mS]);function bS(e,t){let n=vS(e);return yS.has(n)||(n=Sy),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var xS=new Set([`auto`,`none`,`0`]);function SS(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!xS.has(t)&&hy(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=bS(n,i)}var CS=class extends Gb{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Lv(r))){let i=Bx(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Wx.has(n)||e.length!==2)return;let[r,i]=e,a=cS(r),o=cS(i);if(zv(r)!==zv(i)&&Lb[n]){this.needsMeasurement=!0;return}if(a!==o)if(Nb(a)&&Nb(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Lb[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||lS(e[t]))&&n.push(t);n.length&&SS(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Lb[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=Lb[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function wS(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var TS=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function ES(e){return G_(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:DS,cancel:OS}=Dv(queueMicrotask,!1),kS={x:!1,y:!1};function AS(){return kS.x||kS.y}function jS(e){return e===`x`||e===`y`?kS[e]?null:(kS[e]=!0,()=>{kS[e]=!1}):kS.x||kS.y?null:(kS.x=kS.y=!0,()=>{kS.x=kS.y=!1})}function MS(e,t){let n=wS(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function NS(e){return!(e.pointerType===`touch`||AS())}function PS(e,t,n={}){let[r,i,a]=MS(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!NS(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var FS=(e,t)=>t?e===t?!0:FS(e,t.parentElement):!1,IS=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,LS=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function RS(e){return LS.has(e.tagName)||e.isContentEditable===!0}var zS=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function BS(e){return zS.has(e.tagName)||e.isContentEditable===!0}var VS=new WeakSet;function HS(e){return t=>{t.key===`Enter`&&e(t)}}function US(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var WS=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=HS(()=>{if(VS.has(n))return;US(n,`down`);let e=HS(()=>{US(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>US(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function GS(e){return IS(e)&&!AS()}var KS=new WeakSet;function qS(e,t,n={}){let[r,i,a]=MS(e,n),o=e=>{let r=e.currentTarget;if(!GS(e)||KS.has(e))return;VS.add(r),n.stopPropagation&&KS.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),VS.has(r)&&VS.delete(r),GS(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||FS(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),ES(e)&&(e.addEventListener(`focus`,e=>WS(e,i)),!RS(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function JS(e){return G_(e)&&`ownerSVGElement`in e}var YS=new WeakMap,XS,ZS=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:JS(r)&&`getBBox`in r?r.getBBox()[t]:r[n],QS=ZS(`inline`,`width`,`offsetWidth`),$S=ZS(`block`,`height`,`offsetHeight`);function eC({target:e,borderBoxSize:t}){YS.get(e)?.forEach(n=>{n(e,{get width(){return QS(e,t)},get height(){return $S(e,t)}})})}function tC(e){e.forEach(eC)}function nC(){typeof ResizeObserver>`u`||(XS=new ResizeObserver(tC))}function rC(e,t){XS||nC();let n=wS(e);return n.forEach(e=>{let n=YS.get(e);n||(n=new Set,YS.set(e,n)),n.add(t),XS?.observe(e)}),()=>{n.forEach(e=>{let n=YS.get(e);n?.delete(t),n?.size||XS?.unobserve(e)})}}var iC=new Set,aC;function oC(){aC=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};iC.forEach(t=>t(e))},window.addEventListener(`resize`,aC)}function sC(e){return iC.add(e),aC||oC(),()=>{iC.delete(e),!iC.size&&typeof aC==`function`&&(window.removeEventListener(`resize`,aC),aC=void 0)}}function cC(e,t){return typeof e==`function`?sC(e):rC(e,t)}function lC(e){return JS(e)&&e.tagName===`svg`}var uC=[...sS,Y,Sy],dC=e=>uC.find(oS(e)),fC=()=>({translate:0,scale:1,origin:0,originPoint:0}),pC=()=>({x:fC(),y:fC()}),mC=()=>({min:0,max:0}),$=()=>({x:mC(),y:mC()}),hC=new WeakMap;function gC(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function _C(e){return typeof e==`string`||Array.isArray(e)}var vC=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],yC=[`initial`,...vC];function bC(e){return gC(e.animate)||yC.some(t=>_C(e[t]))}function xC(e){return!!(bC(e)||e.variants)}function SC(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Q(i))e.addValue(r,i);else if(Q(a))e.addValue(r,Dx(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Dx(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var CC={current:null},wC={current:!1},TC=typeof window<`u`;function EC(){if(wC.current=!0,TC)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>CC.current=e.matches;e.addEventListener(`change`,t),t()}else CC.current=!1}var DC=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],OC={};function kC(e){OC=e}function AC(){return OC}var jC=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Gb,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Mv.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,K.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=bC(t),this.isVariantNode=xC(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Q(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,hC.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(wC.current||EC(),this.shouldReduceMotion=CC.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Ov(this.notifyUpdate),Ov(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&mx.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new ix({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Q_(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Mb.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&K.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in OC){let t=OC[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):$()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<DC.length;t++){let n=DC[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=SC(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Dx(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(W_(n)||K_(n))?n=parseFloat(n):!dC(n)&&Sy.test(t)&&(n=bS(e,t)),this.setBaseTarget(e,Q(n)?n.get():n)),Q(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Hx(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Q(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new Z_),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){DS.render(this.render)}},MC=class extends jC{constructor(){super(...arguments),this.KeyframeResolver=CS}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Q(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},NC=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function PC({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function FC({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function IC(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function LC(e){return e===void 0||e===1}function RC({scale:e,scaleX:t,scaleY:n}){return!LC(e)||!LC(t)||!LC(n)}function zC(e){return RC(e)||BC(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function BC(e){return VC(e.x)||VC(e.y)}function VC(e){return e&&e!==`0%`}function HC(e,t,n){return n+t*(e-n)}function UC(e,t,n,r,i){return i!==void 0&&(e=HC(e,i,r)),HC(e,n,r)+t}function WC(e,t=0,n=1,r,i){e.min=UC(e.min,t,n,r,i),e.max=UC(e.max,t,n,r,i)}function GC(e,{x:t,y:n}){WC(e.x,t.translate,t.scale,t.originPoint),WC(e.y,n.translate,n.scale,n.originPoint)}var KC=.999999999999,qC=1.0000000000001;function JC(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(YC(e.x,-a.scroll.offset.x),YC(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,GC(e,o)),r&&zC(a.latestValues)&&QC(e,a.latestValues,a.layout?.layoutBox))}t.x<qC&&t.x>KC&&(t.x=1),t.y<qC&&t.y>KC&&(t.y=1)}function YC(e,t){e.min+=t,e.max+=t}function XC(e,t,n,r,i=.5){WC(e,t,n,X(e.min,e.max,i),r)}function ZC(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function QC(e,t,n){let r=n??e;XC(e.x,ZC(t.x,r.x),t.scaleX,t.scale,t.originX),XC(e.y,ZC(t.y,r.y),t.scaleY,t.scale,t.originY)}function $C(e,t){return PC(IC(e.getBoundingClientRect(),t))}function ew(e,t,n){let r=$C(e,n),{scroll:i}=t;return i&&(YC(r.x,i.offset.x),YC(r.y,i.offset.y)),r}var tw={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},nw=jb.length;function rw(e,t,n){let r=``,i=!0;for(let a=0;a<nw;a++){let o=jb[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=TS(s,gS[o]);if(!c){i=!1;let t=tw[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${TS(a,gS.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function iw(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Mb.has(e)){o=!0;continue}else if(Fv(e)){i[e]=n;continue}else{let t=TS(n,gS[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=rw(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function aw(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function ow(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var sw={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(J.test(e))e=parseFloat(e);else return e;return`${ow(e,t.target.x)}% ${ow(e,t.target.y)}%`}},cw={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Sy.parse(e);if(i.length>5)return r;let a=Sy.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=X(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},lw={borderRadius:{...sw,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:sw,borderTopRightRadius:sw,borderBottomLeftRadius:sw,borderBottomRightRadius:sw,boxShadow:cw};function uw(e,{layout:t,layoutId:n}){return Mb.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!lw[e]||e===`opacity`)}function dw(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Q(r[t])||i&&Q(i[t])||uw(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function fw(e){return window.getComputedStyle(e)}var pw=class extends MC{constructor(){super(...arguments),this.type=`html`,this.renderInstance=aw}readValueFromInstance(e,t){if(Mb.has(t))return this.projection?.isProjecting?Db(t):kb(e,t);{let n=fw(e),r=(Fv(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return $C(e,t)}build(e,t,n){iw(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return dw(e,t,n)}},mw={offset:`stroke-dashoffset`,array:`stroke-dasharray`},hw={offset:`strokeDashoffset`,array:`strokeDasharray`};function gw(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?mw:hw;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var _w=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function vw(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(iw(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of _w)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&gw(d,i,a,o,!1)}var yw=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),bw=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function xw(e,t,n,r){aw(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(yw.has(n)?n:Zx(n),t.attrs[n])}function Sw(e,t,n){let r=dw(e,t,n);for(let n in e)if(Q(e[n])||Q(t[n])){let t=jb.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Cw=class extends MC{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=$}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Mb.has(t)){let e=vS(t);return e&&e.default||0}return t=yw.has(t)?t:Zx(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Sw(e,t,n)}build(e,t,n){vw(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){xw(e,t,n,r)}mount(e){this.isSVGTag=bw(e.tagName),super.mount(e)}},ww=yC.length;function Tw(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Tw(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<ww;n++){let r=yC[n],i=e.props[r];(_C(i)||i===!1)&&(t[r]=i)}return t}function Ew(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Dw=[...vC].reverse(),Ow=vC.length;function kw(e){return t=>Promise.all(t.map(({animation:t,options:n})=>iS(e,t,n)))}function Aw(e){let t=kw(e),n=Nw(),r=!0,i=!1,a=t=>(n,r)=>{let i=Ux(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=Tw(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<Ow;t++){let p=Dw[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=_C(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||gC(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=jw(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Gx(t)&&Gx(n)?!Ew(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Ux(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Sx(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Ux(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Nw(),i=!0}}}function jw(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Ew(t,e):!1}function Mw(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Nw(){return{animate:Mw(!0),whileInView:Mw(),whileHover:Mw(),whileTap:Mw(),whileDrag:Mw(),whileFocus:Mw(),exit:Mw()}}function Pw(e,t){e.min=t.min,e.max=t.max}function Fw(e,t){Pw(e.x,t.x),Pw(e.y,t.y)}function Iw(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Lw=.9999,Rw=1.0001,zw=-.01,Bw=.01;function Vw(e){return e.max-e.min}function Hw(e,t,n){return Math.abs(e-t)<=n}function Uw(e,t,n,r=.5){e.origin=r,e.originPoint=X(t.min,t.max,e.origin),e.scale=Vw(n)/Vw(t),e.translate=X(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Lw&&e.scale<=Rw||isNaN(e.scale))&&(e.scale=1),(e.translate>=zw&&e.translate<=Bw||isNaN(e.translate))&&(e.translate=0)}function Ww(e,t,n,r){Uw(e.x,t.x,n.x,r?r.originX:void 0),Uw(e.y,t.y,n.y,r?r.originY:void 0)}function Gw(e,t,n,r=0){e.min=(r?X(n.min,n.max,r):n.min)+t.min,e.max=e.min+Vw(t)}function Kw(e,t,n,r){Gw(e.x,t.x,n.x,r?.x),Gw(e.y,t.y,n.y,r?.y)}function qw(e,t,n,r=0){let i=r?X(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Vw(t)}function Jw(e,t,n,r){qw(e.x,t.x,n.x,r?.x),qw(e.y,t.y,n.y,r?.y)}function Yw(e,t,n,r,i){return e-=t,e=HC(e,1/n,r),i!==void 0&&(e=HC(e,1/i,r)),e}function Xw(e,t=0,n=1,r=.5,i,a=e,o=e){if(ny.test(t)&&(t=parseFloat(t),t=X(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=X(a.min,a.max,r);e===a&&(s-=t),e.min=Yw(e.min,t,n,s,i),e.max=Yw(e.max,t,n,s,i)}function Zw(e,t,[n,r,i],a,o){Xw(e,t[n],t[r],t[i],t.scale,a,o)}var Qw=[`x`,`scaleX`,`originX`],$w=[`y`,`scaleY`,`originY`];function eT(e,t,n,r){Zw(e.x,t,Qw,n?n.x:void 0,r?r.x:void 0),Zw(e.y,t,$w,n?n.y:void 0,r?r.y:void 0)}function tT(e){return e.translate===0&&e.scale===1}function nT(e){return tT(e.x)&&tT(e.y)}function rT(e,t){return e.min===t.min&&e.max===t.max}function iT(e,t){return rT(e.x,t.x)&&rT(e.y,t.y)}function aT(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function oT(e,t){return aT(e.x,t.x)&&aT(e.y,t.y)}function sT(e){return Vw(e.x)/Vw(e.y)}function cT(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function lT(e){return[e(`x`),e(`y`)]}function uT(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var dT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],fT=dT.length,pT=e=>typeof e==`string`?parseFloat(e):e,mT=e=>typeof e==`number`||J.test(e);function hT(e,t,n,r,i,a){i?(e.opacity=X(0,n.opacity??1,_T(r)),e.opacityExit=X(t.opacity??1,0,vT(r))):a&&(e.opacity=X(t.opacity??1,n.opacity??1,r));for(let i=0;i<fT;i++){let a=dT[i],o=gT(t,a),s=gT(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||mT(o)===mT(s)?(e[a]=Math.max(X(pT(o),pT(s),r),0),(ny.test(s)||ny.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=X(t.rotate||0,n.rotate||0,r))}function gT(e,t){return e[t]===void 0?e.borderRadius:e[t]}var _T=yT(0,.5,pv),vT=yT(.5,.95,J_);function yT(e,t,n){return r=>r<e?0:r>t?1:n(X_(e,t,r))}function bT(e,t,n){let r=Q(e)?e:Dx(e);return r.start(Lx(``,r,t,n)),r.animation}function xT(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var ST=(e,t)=>e.depth-t.depth,CT=class{constructor(){this.children=[],this.isDirty=!1}add(e){B_(this.children,e),this.isDirty=!0}remove(e){V_(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ST),this.isDirty=!1,this.children.forEach(e)}};function wT(e,t){let n=Mv.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Ov(r),e(a-t))};return K.setup(r,!0),()=>Ov(r)}function TT(e){return Q(e)?e.get():e}var ET=class{constructor(){this.members=[]}add(e){B_(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(V_(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(V_(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},DT={hasAnimatedSinceResize:!0,hasEverUpdated:!1},OT={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},kT=[``,`X`,`Y`,`Z`],AT=1e3,jT=0;function MT(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function NT(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=$x(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,K,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&NT(r)}function PT({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=jT++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,wv.value&&(OT.nodes=OT.calculatedTargetDeltas=OT.calculatedProjections=0),this.nodes.forEach(LT),this.nodes.forEach(KT),this.nodes.forEach(qT),this.nodes.forEach(RT),wv.addProjectionMetrics&&wv.addProjectionMetrics(OT)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new CT)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Z_),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=JS(t)&&!lC(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;K.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=wT(i,250),DT.hasAnimatedSinceResize&&(DT.hasAnimatedSinceResize=!1,this.nodes.forEach(GT)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||eE,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!oT(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...kx(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||GT(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ov(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(JT),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&NT(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(VT),this.nodes.forEach(BT);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(HT);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(UT),this.nodes.forEach(WT),this.nodes.forEach(FT),this.nodes.forEach(IT)):this.nodes.forEach(HT),this.clearAllSnapshots();let e=Mv.now();q.delta=H_(0,1e3/60,e-q.timestamp),q.timestamp=e,q.isProcessing=!0,kv.update.process(q),kv.preRender.process(q),kv.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,DS.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(zT),this.sharedNodes.forEach(YT)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,K.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){K.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Vw(this.snapshot.measuredBox.x)&&!Vw(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=$(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!nT(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||zC(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),iE(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return $();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(oE))){let{scroll:e}=this.root;e&&(YC(t.x,e.offset.x),YC(t.y,e.offset.y))}return t}removeElementScroll(e){let t=$();if(Fw(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Fw(t,e),YC(t.x,i.offset.x),YC(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||$();Fw(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(YC(r.x,-n.scroll.offset.x),YC(r.y,-n.scroll.offset.y)),zC(n.latestValues)&&QC(r,n.latestValues,n.layout?.layoutBox)}return zC(this.latestValues)&&QC(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=$();Fw(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!zC(n.latestValues))continue;let r;n.instance&&(RC(n.latestValues)&&n.updateSnapshot(),r=$(),Fw(r,n.measurePageBox())),eT(t,n.latestValues,n.snapshot?.layoutBox,r)}return zC(this.latestValues)&&eT(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=q.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=$(),this.targetWithTransforms=$()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Kw(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Fw(this.target,this.layout.layoutBox),GC(this.target,this.targetDelta)):Fw(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),wv.value&&OT.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||RC(this.parent.latestValues)||BC(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=$(),this.relativeTargetOrigin=$(),Jw(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Fw(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===q.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Fw(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;JC(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=$());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Iw(this.prevProjectionDelta.x,this.projectionDelta.x),Iw(this.prevProjectionDelta.y,this.projectionDelta.y)),Ww(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!cT(this.projectionDelta.x,this.prevProjectionDelta.x)||!cT(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),wv.value&&OT.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=pC(),this.projectionDelta=pC(),this.projectionDeltaWithTransform=pC()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=pC();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=$(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some($T));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=X(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=X(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(XT(o.x,e.x,n),XT(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Jw(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),QT(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&iT(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=$(),Fw(f,this.relativeTarget)),c&&(this.animationValues=a,hT(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Ov(this.pendingAnimation),void 0),this.pendingAnimation=K.update(()=>{DT.hasAnimatedSinceResize=!0,Nv.layout++,this.motionValue||=Dx(0),this.motionValue.jump(0,!1),this.currentAnimation=bT(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Nv.layout--},onComplete:()=>{Nv.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(AT),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&aE(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||$();let t=Vw(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Vw(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Fw(t,n),QC(t,i),Ww(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new ET),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&MT(`z`,e,r,this.animationValues);for(let t=0;t<kT.length;t++)MT(`rotate${kT[t]}`,e,r,this.animationValues),MT(`skew${kT[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=TT(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=TT(t?.pointerEvents)||``),this.hasProjected&&!zC(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=uT(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in lw){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=lw[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?TT(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(BT),this.root.sharedNodes.clear()}}}function FT(e){e.updateLayout()}function IT(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)lT(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Vw(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Pw(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else aE(i,t.layoutBox,n)&&lT(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Vw(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=pC();Ww(o,n,t.layoutBox);let s=pC();a?Ww(s,e.applyTransform(r,!0),t.measuredBox):Ww(s,n,t.layoutBox);let c=!nT(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=$();Jw(s,t.layoutBox,i.layoutBox,o);let c=$();Jw(c,n,a.layoutBox,o),oT(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function LT(e){wv.value&&OT.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function RT(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function zT(e){e.clearSnapshot()}function BT(e){e.clearMeasurements()}function VT(e){e.isLayoutDirty=!0,e.updateLayout()}function HT(e){e.isLayoutDirty=!1}function UT(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function WT(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function GT(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function KT(e){e.resolveTargetDelta()}function qT(e){e.calcProjection()}function JT(e){e.resetSkewAndRotation()}function YT(e){e.removeLeadSnapshot()}function XT(e,t,n){e.translate=X(t.translate,0,n),e.scale=X(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ZT(e,t,n,r){e.min=X(t.min,n.min,r),e.max=X(t.max,n.max,r)}function QT(e,t,n,r){ZT(e.x,t.x,n.x,r),ZT(e.y,t.y,n.y,r)}function $T(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var eE={duration:.45,ease:[.4,0,.1,1]},tE=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),nE=tE(`applewebkit/`)&&!tE(`chrome/`)?Math.round:J_;function rE(e){e.min=nE(e.min),e.max=nE(e.max)}function iE(e){rE(e.x),rE(e.y)}function aE(e,t,n){return e===`position`||e===`preserve-aspect`&&!Hw(sT(t),sT(n),.2)}function oE(e){return e!==e.root&&e.scroll?.wasRoot}var sE=PT({attachResizeListener:(e,t)=>xT(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),cE={current:void 0},lE=PT({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!cE.current){let e=new sE({});e.mount(window),e.setOptions({layoutScroll:!0}),cE.current=e}return cE.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),uE=(0,F.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function dE(e=!0){let t=(0,F.useContext)(z_);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,F.useId)();(0,F.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,F.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var fE=(0,F.createContext)({strict:!1}),pE={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},mE=!1;function hE(){if(mE)return;let e={};for(let t in pE)e[t]={isEnabled:e=>pE[t].some(t=>!!e[t])};kC(e),mE=!0}function gE(){return hE(),AC()}function _E(e){let t=gE();for(let n in e)t[n]={...t[n],...e[n]};kC(t)}var vE=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function yE(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||vE.has(e)}var bE=r({default:()=>xE}),xE,SE=t((()=>{throw xE={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),CE=e=>!yE(e);function wE(e){typeof e==`function`&&(CE=t=>t.startsWith(`on`)?!yE(t):e(t))}try{wE((SE(),e(bE)).default)}catch{}function TE(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Q(e[i])||(CE(i)||n===!0&&yE(i)||!t&&!yE(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var EE=(0,F.createContext)({});function DE(e,t){if(bC(e)){let{initial:t,animate:n}=e;return{initial:t===!1||_C(t)?t:void 0,animate:_C(n)?n:void 0}}return e.inherit===!1?{}:t}function OE(e){let{initial:t,animate:n}=DE(e,(0,F.useContext)(EE));return(0,F.useMemo)(()=>({initial:t,animate:n}),[kE(t),kE(n)])}function kE(e){return Array.isArray(e)?e.join(` `):e}var AE=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function jE(e,t,n){for(let r in t)!Q(t[r])&&!uw(r,n)&&(e[r]=t[r])}function ME({transformTemplate:e},t){return(0,F.useMemo)(()=>{let n=AE();return iw(n,t,e),Object.assign({},n.vars,n.style)},[t])}function NE(e,t){let n=e.style||{},r={};return jE(r,n,e),Object.assign(r,ME(e,t)),r}function PE(e,t){let n={},r=NE(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var FE=()=>({...AE(),attrs:{}});function IE(e,t,n,r){let i=(0,F.useMemo)(()=>{let n=FE();return vw(n,t,bw(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};jE(t,e.style,e),i.style={...t,...i.style}}return i}var LE=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function RE(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(LE.indexOf(e)>-1||/[A-Z]/u.test(e))}function zE(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??RE(e)?IE:PE)(t,r,i,e),c=TE(t,typeof e==`string`,a),l=e===F.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,F.useMemo)(()=>Q(u)?u.get():u,[u]);return(0,F.createElement)(e,{...l,children:d})}function BE({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:VE(n,r,i,e),renderState:t()}}function VE(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=TT(a[e]);let{initial:o,animate:s}=e,c=bC(e),l=xC(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!gC(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Hx(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var HE=e=>(t,n)=>{let r=(0,F.useContext)(EE),i=(0,F.useContext)(z_),a=()=>BE(e,t,r,i);return n?a():L_(a)},UE=HE({scrapeMotionValuesFromProps:dw,createRenderState:AE}),WE=HE({scrapeMotionValuesFromProps:Sw,createRenderState:FE}),GE=Symbol.for(`motionComponentSymbol`);function KE(e,t,n){let r=(0,F.useRef)(n);(0,F.useInsertionEffect)(()=>{r.current=n});let i=(0,F.useRef)(null);return(0,F.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var qE=(0,F.createContext)({});function JE(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function YE(e,t,n,r,i,a){let{visualElement:o}=(0,F.useContext)(EE),s=(0,F.useContext)(fE),c=(0,F.useContext)(z_),l=(0,F.useContext)(uE),u=l.reducedMotion,d=l.skipAnimations,f=(0,F.useRef)(null),p=(0,F.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,F.useContext)(qE);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&XE(f.current,n,i,h);let g=(0,F.useRef)(!1);(0,F.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[Qx],v=(0,F.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return R_(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,F.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function XE(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:ZE(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&JE(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function ZE(e){if(e)return e.options.allowProjection===!1?ZE(e.parent):e.projection}function QE(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&_E(r);let a=n?n===`svg`:RE(e),o=a?WE:UE;function s(n,s){let c,l={...(0,F.useContext)(uE),...n,layoutId:$E(n)},{isStatic:u}=l,d=OE(n),f=o(n,u);if(!u&&typeof window<`u`){eD(l,r);let t=tD(l);c=t.MeasureLayout,d.visualElement=YE(e,f,l,i,t.ProjectionNode,a)}return(0,L.jsxs)(EE.Provider,{value:d,children:[c&&d.visualElement?(0,L.jsx)(c,{visualElement:d.visualElement,...l}):null,zE(e,n,KE(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,F.forwardRef)(s);return c[GE]=e,c}function $E({layoutId:e}){let t=(0,F.useContext)(I_).id;return t&&e!==void 0?t+`-`+e:e}function eD(e,t){(0,F.useContext)(fE).strict}function tD(e){let{drag:t,layout:n}=gE();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function nD(e,t){if(typeof Proxy>`u`)return QE;let n=new Map,r=(n,r)=>QE(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,QE(a,void 0,e,t)),n.get(a))})}var rD=(e,t)=>t.isSVG??RE(e)?new Cw(t):new pw(t,{allowProjection:e!==F.Fragment}),iD=class extends NC{constructor(e){super(e),e.animationState||=Aw(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();gC(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},aD=0,oD={animation:{Feature:iD},exit:{Feature:class extends NC{constructor(){super(...arguments),this.id=aD++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Ux(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function sD(e){return{point:{x:e.pageX,y:e.pageY}}}var cD=e=>t=>IS(t)&&e(t,sD(t));function lD(e,t,n,r){return xT(e,t,cD(n),r)}var uD=({current:e})=>e?e.ownerDocument.defaultView:null,dD=(e,t)=>Math.abs(e-t);function fD(e,t){let n=dD(e.x,t.x),r=dD(e.y,t.y);return Math.sqrt(n**2+r**2)}var pD=new Set([`auto`,`scroll`]),mD=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=hD(this.lastRawMoveEventInfo,this.transformPagePoint));let e=_D(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=fD(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=q;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=hD(t,this.transformPagePoint),K.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=_D(e.type===`pointercancel`?this.lastMoveEventInfo:hD(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!IS(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=hD(sD(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=q;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,_D(s,this.history)),this.removeListeners=Y_(lD(this.contextWindow,`pointermove`,this.handlePointerMove),lD(this.contextWindow,`pointerup`,this.handlePointerUp),lD(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(pD.has(e.overflowX)||pD.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),K.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ov(this.updatePoint)}};function hD(e,t){return t?{point:t(e.point)}:e}function gD(e,t){return{x:e.x-t.x,y:e.y-t.y}}function _D({point:e},t){return{point:e,delta:gD(e,yD(t)),offset:gD(e,vD(t)),velocity:bD(t,.1)}}function vD(e){return e[0]}function yD(e){return e[e.length-1]}function bD(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=yD(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Q_(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Q_(t)*2&&(r=e[1]);let a=$_(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function xD(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?X(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?X(n,e,r.max):Math.min(e,n)),e}function SD(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function CD(e,{top:t,left:n,bottom:r,right:i}){return{x:SD(e.x,n,i),y:SD(e.y,t,r)}}function wD(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function TD(e,t){return{x:wD(e.x,t.x),y:wD(e.y,t.y)}}function ED(e,t){let n=.5,r=Vw(e),i=Vw(t);return i>r?n=X_(t.min,t.max-r,e.min):r>i&&(n=X_(e.min,e.max-i,t.min)),H_(0,1,n)}function DD(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var OD=.35;function kD(e=OD){return e===!1?e=0:e===!0&&(e=OD),{x:AD(e,`left`,`right`),y:AD(e,`top`,`bottom`)}}function AD(e,t,n){return{min:jD(e,t),max:jD(e,n)}}function jD(e,t){return typeof e==`number`?e:e[t]||0}var MD=new WeakMap,ND=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=$(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(sD(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=jS(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),lT(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ny.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Vw(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&K.update(()=>i(e,t),!1,!0),Xx(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=LD(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&K.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new mD(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:uD(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&K.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!ID(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=xD(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&JE(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=CD(n.layoutBox,e):this.constraints=!1,this.elastic=kD(t),r!==this.constraints&&!JE(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&lT(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=DD(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!JE(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=ew(n,r.root,this.visualElement.getTransformPagePoint()),a=TD(r.layout.layoutBox,i);if(t){let e=t(FC(a));this.hasMutatedConstraints=!!e,e&&(a=PC(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=lT(o=>{if(!ID(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Xx(this.visualElement,e),n.start(Lx(e,n,0,t,this.visualElement,!1))}stopAnimation(){lT(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){lT(t=>{let{drag:n}=this.getProps();if(!ID(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-X(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!JE(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};lT(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=ED({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),lT(t=>{if(!ID(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(X(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;MD.set(this.visualElement,this);let e=this.visualElement.current,t=lD(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&BS(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();JE(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=FD(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),K.read(r);let o=xT(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(lT(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=OD,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function PD(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function FD(e,t,n){let r=cC(e,PD(n)),i=cC(t,PD(n));return()=>{r(),i()}}function ID(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function LD(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var RD=class extends NC{constructor(e){super(e),this.removeGroupControls=J_,this.removeListeners=J_,this.controls=new ND(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||J_}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},zD=e=>(t,n)=>{e&&K.update(()=>e(t,n),!1,!0)},BD=class extends NC{constructor(){super(...arguments),this.removePointerDownListener=J_}onPointerDown(e){this.session=new mD(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:uD(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:zD(e),onStart:zD(t),onMove:zD(n),onEnd:(e,t)=>{delete this.session,r&&K.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=lD(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},VD=!1,HD=class extends F.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),VD&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),DT.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),VD=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||K.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),DS.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;VD=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function UD(e){let[t,n]=dE(),r=(0,F.useContext)(I_);return(0,L.jsx)(HD,{...e,layoutGroup:r,switchLayoutGroup:(0,F.useContext)(qE),isPresent:t,safeToRemove:n})}var WD={pan:{Feature:BD},drag:{Feature:RD,ProjectionNode:lE,MeasureLayout:UD}};function GD(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&K.postRender(()=>i(t,sD(t)))}var KD=class extends NC{mount(){let{current:e}=this.node;e&&(this.unmount=PS(e,(e,t)=>(GD(this.node,t,`Start`),e=>GD(this.node,e,`End`))))}unmount(){}},qD=class extends NC{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Y_(xT(this.node.current,`focus`,()=>this.onFocus()),xT(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function JD(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&K.postRender(()=>i(t,sD(t)))}var YD=class extends NC{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=qS(e,(e,t)=>(JD(this.node,t,`Start`),(e,{success:t})=>JD(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},XD=new WeakMap,ZD=new WeakMap,QD=e=>{let t=XD.get(e.target);t&&t(e)},$D=e=>{e.forEach(QD)};function eO({root:e,...t}){let n=e||document;ZD.has(n)||ZD.set(n,{});let r=ZD.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver($D,{root:e,...t})),r[i]}function tO(e,t,n){let r=eO(t);return XD.set(e,n),r.observe(e),()=>{XD.delete(e),r.unobserve(e)}}var nO={some:0,all:1},rO=class extends NC{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:nO[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=tO(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(iO(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function iO({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var aO={inView:{Feature:rO},tap:{Feature:YD},focus:{Feature:qD},hover:{Feature:KD}},oO={layout:{ProjectionNode:lE,MeasureLayout:UD}},sO=nD({...oD,...aO,...WD,...oO},rD),cO=(0,F.memo)(({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2})=>{let a=sO.create(t),o=(0,F.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,L.jsx)(a,{animate:{backgroundPosition:`0% center`},className:j(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,n),initial:{backgroundPosition:`100% center`},style:{"--spread":`${o}px`,backgroundImage:`var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))`},transition:{repeat:1/0,duration:r,ease:`linear`},children:e})}),lO=(0,F.createContext)(null),uO=()=>{let e=(0,F.useContext)(lO);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},dO=1e3,fO=1e3,pO=(0,F.memo)(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:i,duration:a,children:o,...s})=>{let[c,l]=It({prop:n,defaultProp:r,onChange:i}),[u,d]=It({prop:a,defaultProp:void 0}),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(null);return(0,F.useEffect)(()=>{t?m===null&&h(Date.now()):m!==null&&(d(Math.ceil((Date.now()-m)/fO)),h(null))},[t,m,d]),(0,F.useEffect)(()=>{if(r&&!t&&c&&!f){let e=setTimeout(()=>{l(!1),p(!0)},dO);return()=>clearTimeout(e)}},[t,c,r,l,f]),(0,L.jsx)(lO.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:l,duration:u},children:(0,L.jsx)(Re,{className:j(`not-prose mb-4`,e),onOpenChange:e=>{l(e)},open:c,...s,children:o})})}),mO=(e,t)=>e||t===0?(0,L.jsx)(cO,{duration:1,children:`Thinking...`}):t===void 0?(0,L.jsx)(`p`,{children:`Thought for a few seconds`}):(0,L.jsxs)(`p`,{children:[`Thought for `,t,` seconds`]}),hO=(0,F.memo)(({className:e,children:t,getThinkingMessage:n=mO,...r})=>{let{isStreaming:i,isOpen:a,duration:o}=uO();return(0,L.jsx)(ye,{className:j(`flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,e),...r,children:t??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ve,{className:`size-4`}),n(i,o),(0,L.jsx)(Ce,{className:j(`size-4 transition-transform`,a?`rotate-180`:`rotate-0`)})]})})}),gO=(0,F.memo)(({className:e,children:t,...n})=>(0,L.jsx)(fe,{className:j(`mt-4 text-sm`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...n,children:(0,L.jsx)(Af,{children:t})}));pO.displayName=`Reasoning`,hO.displayName=`ReasoningTrigger`,gO.displayName=`ReasoningContent`;var _O=({className:e,...t})=>(0,L.jsx)(Re,{className:j(`not-prose mb-4 text-primary text-xs`,e),...t}),vO=({className:e,count:t,children:n,...r})=>(0,L.jsx)(ye,{className:j(`flex items-center gap-2`,e),...r,children:n??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`font-medium`,children:[`Used `,t,` sources`]}),(0,L.jsx)(Ce,{className:`h-4 w-4`})]})}),yO=({className:e,...t})=>(0,L.jsx)(fe,{className:j(`mt-3 flex w-fit flex-col gap-2`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),bO=({href:e,title:t,children:n,...r})=>(0,L.jsx)(`a`,{className:`flex items-center gap-2`,href:e,rel:`noreferrer`,target:`_blank`,...r,children:n??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ae,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{className:`block font-medium`,children:t})]})});function xO(e){let t=e??{},n=t.data&&typeof t.data==`object`?t.data:t,r=n.seedApplied,i=n.probes;if(!r&&!i)return;let a={};return r&&(r.success===!1?a.seedError=r.error??(Array.isArray(r.errors)&&r.errors.length?String(r.errors[0]):`Sample data failed to load.`):a.seededRows=(r.inserted??0)+(r.updated??0)),i&&(a.checked={seeds:i.checked?.seeds??0,views:i.checked?.views??0,widgets:i.checked?.widgets??0},a.issues=(i.issues??[]).filter(e=>e&&typeof e.message==`string`).map(e=>({severity:e.severity===`error`?`error`:`warning`,code:String(e.code??`runtime_issue`),message:String(e.message)}))),a}function SO(e){return e===`user`?`user`:`assistant`}function CO(e){let t=e.trim();if(t.length<2||!(t.startsWith(`{`)||t.startsWith(`[`))||!(t.endsWith(`}`)||t.endsWith(`]`)))return!1;try{return JSON.parse(t),!0}catch{return!1}}function wO(e){let t=e.state??(e.errorText?`output-error`:e.result===void 0?`input-available`:`output-available`);return t===`output-error`||t===`output-denied`?`failed`:t===`approval-requested`||t===`approval-responded`?`awaiting`:t===`output-available`?`completed`:`running`}function TO(e){let t=wO(e);return t===`awaiting`||t===`failed`||!!e.pendingActionId||!!e.draftReview?.items.length||!!e.proposedPlan}function EO(e){switch(e){case`failed`:return 4;case`awaiting`:return 3;case`running`:return 2;case`completed`:return 1}}function DO(e){let t=new Map;for(let n of e){let e=wO(n),r=`${n.toolName}:${e}`,i=t.get(r);if(i){i.count+=1,i.errorText=i.errorText??n.errorText;continue}t.set(r,{key:r,title:ao(n.toolName)||n.toolName,rawName:n.toolName,count:1,state:e,errorText:n.errorText})}return Array.from(t.values()).sort((e,t)=>{let n=EO(t.state)-EO(e.state);return n===0?e.title.localeCompare(t.title):n})}function OO({health:e}){if(!e)return null;let t=e.issues??[],n=t.filter(e=>e.severity===`error`),r=t.filter(e=>e.severity!==`error`),i=e.checked,a=!!i&&i.seeds+i.views+i.widgets>0,o=[];if(typeof e.seededRows==`number`&&e.seededRows>0&&!e.seedError&&o.push(`${e.seededRows} sample row${e.seededRows===1?``:`s`} live`),a&&n.length===0){let e=[];i.views>0&&e.push(`${i.views} view${i.views===1?``:`s`}`),i.widgets>0&&e.push(`${i.widgets} widget${i.widgets===1?``:`s`}`),i.seeds>0&&e.push(`${i.seeds} seed${i.seeds===1?``:`s`}`),e.length&&o.push(`${e.join(` · `)} verified`)}return o.length===0&&!e.seedError&&t.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 border-t bg-muted/20 px-3 py-2`,"data-testid":`publish-health`,children:[o.length>0?(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-emerald-700`,children:[(0,L.jsx)(At,{className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:o.join(` · `)})]}):null,e.seedError?(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-600`,children:[(0,L.jsx)(_t,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.seedError})]}):null,n.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-600`,children:[(0,L.jsx)(_t,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.message})]},`e${t}`)),r.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-amber-600`,children:[(0,L.jsx)(Ot,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.message})]},`w${t}`))]})}var kO=F.forwardRef(({className:e,messages:t=[],placeholder:n=`Type your message...`,onSendMessage:r,onClear:i,onStop:a,onReload:o,onUpgrade:s,disabled:c=!1,isLoading:l=!1,error:d,showTimestamp:f=!1,showAvatars:p=!1,userAvatarUrl:m,userAvatarFallback:h=`You`,assistantAvatarUrl:g,assistantAvatarFallback:_=`AI`,hideClearBar:v=!1,maxHeight:y=`500px`,enableMarkdown:b=!0,enableFileUpload:x=!1,acceptedFileTypes:S=`image/*,.pdf,.doc,.docx,.txt`,maxFileSize:C=10*1024*1024,suggestions:w,labels:T,models:E,selectedModelId:D,onModelChange:ee,headerSlot:O,promptOverlaySlot:te,onInputChange:ne,onToolApprove:ae,toolApproveLabel:oe=`Approve`,toolDenyLabel:se=`Deny`,toolDenyReason:le=`User denied the operation`,toolDecisions:ue,onReviewDraft:de,toolReviewLabel:fe=e=>`Review ${e} change${e===1?``:`s`}`,onPublishDrafts:pe,onOpenBuiltApp:me,openBuiltAppLabel:ge=`Open app`,onPreviewDraftApp:_e,previewDraftLabel:ve=`Preview`,onDraftArtifacts:ye,onBuildMaterialized:be,publishDraftsLabel:xe=`Publish`,publishedLabel:Ce=`Published`,verifiedLabel:we=`Verified`,nextStepsLabel:Ee=`What's next`,planTitleLabel:De=`Proposed plan`,planQuestionsLabel:Oe=`Confirm before building`,planAssumptionsLabel:ke=`Assumptions`,planApproveHintLabel:je=`Reply to approve or adjust this plan.`,planApproveLabel:Ne=`Build it`,planAdjustLabel:Pe=`Adjust`,planApproveMessage:Fe=`Looks good — build it as proposed.`,planApproveDefaultsMessage:Ie=`Build it with your best assumptions; use sensible defaults for the open questions.`,planAnswerMessage:Le=(e,t)=>`For "${e}", go with: ${t}.`,fetchPendingDraftCount:Re,autoPublishDrafts:ze=!1,processVisibility:Be=`summary`,surface:Ve=`card`,...Ue},We)=>{let Ge=l?`streaming`:`ready`,Ke=Ve===`plain`,[qe,Je]=F.useState(null),k=F.useMemo(()=>({emptyTitle:T?.emptyTitle??`Start a conversation`,emptyDescription:T?.emptyDescription??`Ask anything — the assistant has access to your current app context.`,clear:T?.clear??`Clear`,sendHint:T?.sendHint??`to send`,agentActivity:T?.agentActivity??`Agent activity`,toolCompleted:T?.toolCompleted??`Completed`,toolRunning:T?.toolRunning??`Running`,toolAwaitingApproval:T?.toolAwaitingApproval??`Awaiting approval`,toolFailed:T?.toolFailed??`Failed`,toolDetailsHidden:T?.toolDetailsHidden??`Detailed tool inputs and outputs are hidden in this view.`,copy:T?.copy??`Copy`,copied:T?.copied??`Copied`,regenerate:T?.regenerate??`Regenerate`,model:T?.model??`Model`,submit:T?.submit??`Submit`,uploadFiles:T?.uploadFiles??`Upload files`,stopResponse:T?.stopResponse??`Stop response`,trace:T?.trace??`trace`,viewTrace:T?.viewTrace??`View trace`,connectionWaiting:T?.connectionWaiting??`Waiting for server…`}),[T]),[Ye,Ze]=F.useState(()=>new Set),[Qe,tt]=F.useState(()=>new Map),[nt,A]=F.useState(()=>new Map),it=F.useRef(new Set),at=F.useCallback(async e=>{if(Re)try{let t=await Re(e);A(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}catch{}},[Re]);F.useEffect(()=>{if(!Re||l)return;let e=new Set;for(let n of t)for(let t of n.toolInvocations??[]){let n=t.draftReview?.packageId,r=t.toolCallId;n&&r&&!it.current.has(r)&&(it.current.add(r),e.add(n))}for(let t of e)at(t)},[t,l,Re,at]);let ot=F.useCallback(async e=>{if(!pe)return;let n=[];for(let r of t)for(let t of r.toolInvocations??[])t.draftReview?.packageId===e&&t.toolCallId&&n.push(t.toolCallId);let r=await pe(e),i=r&&typeof r==`object`?r:void 0;if((i?i.ok!==!1:r!==!1)&&n.length>0){Ze(e=>{let t=new Set(e);for(let e of n)t.add(e);return t});let e=i?.health;e&&tt(t=>{let r=new Map(t);for(let t of n)r.set(t,e);return r})}at(e)},[pe,t,at]),st=F.useRef(new Set),ct=F.useRef(!1);F.useEffect(()=>{let e=[];for(let n of t)for(let t of n.toolInvocations??[]){let n=t.draftReview;n?.autoPublishable&&n.packageId&&t.toolCallId&&n.items.length>0&&e.push({key:t.toolCallId,packageId:n.packageId})}if(!ct.current){ct.current=!0;for(let t of e)st.current.add(t.key);return}if(!ze||!pe||l)return;let n=e.filter(e=>!st.current.has(e.key));if(n.length!==0){for(let e of n)st.current.add(e.key);for(let e of[...new Set(n.map(e=>e.packageId))])ot(e)}},[t,l,ze,pe,ot]);let lt=F.useRef(new Set);F.useEffect(()=>{if(!ye)return;let e=new Map;for(let n of t){for(let t of n.buildProgress?.items??[])t?.type&&t?.name&&e.set(`${t.type}:${t.name}`,t);for(let t of n.toolInvocations??[])for(let n of t.draftReview?.items??[])n?.type&&n?.name&&e.set(`${n.type}:${n.name}`,n)}let n=lt.current,r=!1;for(let t of e.keys())n.has(t)||(n.add(t),r=!0);r&&ye([...e.values()])},[t,ye]);let ut=F.useRef(new Set);F.useEffect(()=>{if(be)for(let e of t)for(let t of e.toolInvocations??[]){let e=t.draftReview;if(!e?.materialized||!t.toolCallId)continue;let n=e.items.find(e=>e.type===`app`);!n||ut.current.has(t.toolCallId)||(ut.current.add(t.toolCallId),be(n.name))}},[t,be]);let dt=F.useCallback(e=>{let t=!!e.text?.trim(),n=e.files?.map(e=>e.file).filter(Boolean),i=!!(n&&n.length>0);(t||i)&&r?.(e.text?.trim()??``,n)},[r]),ft=F.useCallback(e=>{r?.(e)},[r]),pt=F.useRef(null),mt=F.useCallback(e=>{r?.(e?Ie:Fe)},[r,Fe,Ie]),ht=F.useCallback(()=>{let e=pt.current?.querySelector(`textarea`);e&&(e.focus(),e.scrollIntoView({block:`nearest`}))},[]),gt=F.useCallback(e=>{navigator.clipboard?.writeText(e.content),Je(e.id),window.setTimeout(()=>Je(t=>t===e.id?null:t),1500)},[]),vt=e=>{let t=e.state??(e.errorText?`output-error`:e.result===void 0?`input-available`:`output-available`),n=`tool-${e.toolName}`,i=ue?.[e.toolCallId],a=t===`approval-requested`&&!!ae&&!i,o=t===`approval-requested`&&!!e.pendingActionId,s=ao(e.toolName),c=oo(e.result),l=Be===`debug`&&s&&s.toLowerCase()!==e.toolName.toLowerCase(),u=Be===`debug`||a,d=e.draftReview?.packageId,f=d===void 0?void 0:nt.get(d),p=f===void 0?Ye.has(e.toolCallId):f===0,m=(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(`span`,{children:s||e.toolName}),l?(0,L.jsx)(`code`,{className:`rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground`,children:e.toolName}):null]});return(0,L.jsxs)(A_,{defaultOpen:t===`output-error`||t===`approval-requested`||!!(e.draftReview&&e.draftReview.items.length>0)||!!e.proposedPlan,children:[(0,L.jsx)(M_,{type:n,state:t,title:m}),(0,L.jsxs)(N_,{children:[u&&e.args!==void 0?(0,L.jsx)(P_,{input:e.args}):null,o?null:u||t===`output-error`?(0,L.jsx)(WO,{output:c,errorText:e.errorText}):null,i?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-t text-xs `+(i.state===`error`?`bg-destructive/10 text-destructive`:i.state===`success`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`:`bg-muted/30 text-muted-foreground`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:i.state===`pending`?`...`:i.state===`success`?`OK`:`X`}),(0,L.jsx)(`span`,{children:i.message??(i.state===`pending`?`Submitting decision...`:i.state===`success`?`Action approved and executed.`:`Decision failed.`)})]}):null,a?(0,L.jsxs)(`div`,{className:`flex gap-2 p-3 border-t bg-muted/30`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>ae?.(e.toolCallId,!0),className:`inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:oe}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>ae?.(e.toolCallId,!1,le),className:`inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent`,children:se})]}):null,e.draftReview&&e.draftReview.items.length>0&&(de||pe&&e.draftReview.packageId)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-t bg-muted/30`,children:[pe&&e.draftReview.packageId?p?(0,L.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700`,children:[(0,L.jsx)(At,{className:`size-3.5`}),Ce,e.draftReview.failedCount?` · ${e.draftReview.failedCount} need${e.draftReview.failedCount===1?`s`:``} attention`:``]}):(0,L.jsxs)(`button`,{type:`button`,onClick:()=>void ot(e.draftReview.packageId),className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`draft-publish`,children:[(0,L.jsx)(Se,{className:`size-3.5`}),xe,typeof f==`number`&&f>0?` (${f})`:``]}):null,de?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>de(e.draftReview.items),className:pe&&e.draftReview.packageId?`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted`:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[(0,L.jsx)(et,{className:`size-3.5`}),fe(e.draftReview.items.length)]}):null,_e&&!p?(()=>{let t=e.draftReview.items.find(e=>e.type===`app`);return t?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>_e(t.name,{materialized:e.draftReview.materialized===!0}),className:`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted`,"data-testid":`draft-preview-app`,children:[(0,L.jsx)(Me,{className:`size-3.5`}),ve]}):null})():null,e.draftReview.verification?e.draftReview.verification.errors>0?(0,L.jsxs)(`span`,{className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700`,"data-testid":`draft-verification-chip`,children:[(0,L.jsx)(ce,{className:`size-3.5`}),`${e.draftReview.verification.errors} issue${e.draftReview.verification.errors===1?``:`s`}`]}):(0,L.jsxs)(`span`,{className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-2.5 text-xs font-medium text-emerald-700`,"data-testid":`draft-verification-chip`,children:[(0,L.jsx)(He,{className:`size-3.5`}),we]}):null,e.draftReview.summary?(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.draftReview.summary}):null]}),e.draftReview.issues&&e.draftReview.issues.length>0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 border-t bg-muted/20 px-3 py-2`,"data-testid":`draft-issues`,children:[e.draftReview.issues.filter(e=>e.severity===`error`).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-red-600`,children:[(0,L.jsx)(_t,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.fix?`${e.message} — ${e.fix}`:e.message})]},`e${t}`)),e.draftReview.issues.filter(e=>e.severity!==`error`).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-amber-600`,children:[(0,L.jsx)(Ot,{className:`mt-0.5 size-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.message})]},`w${t}`))]}):null,Ye.has(e.toolCallId)?(0,L.jsx)(OO,{health:Qe.get(e.toolCallId)}):null,e.draftReview.nextSteps&&e.draftReview.nextSteps.length>0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 border-t bg-muted/20 px-3 py-2`,"data-testid":`draft-next-steps`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-foreground/80`,children:Ee}),e.draftReview.nextSteps.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`mt-px shrink-0 text-foreground/40`,children:`→`}),(0,L.jsx)(`span`,{children:e})]},t))]}):null]}):null,e.proposedPlan?(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5`,"data-testid":`proposed-plan`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80`,children:[(0,L.jsx)(Xe,{className:`size-3.5`}),De]}),e.proposedPlan.summary?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.proposedPlan.summary}):null,e.proposedPlan.objects.length>0?(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.proposedPlan.objects.map(e=>(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80`,title:e.name,children:[(0,L.jsx)(ie,{className:`size-3 text-foreground/40`}),e.label||e.name,e.fieldCount>0?(0,L.jsxs)(`span`,{className:`text-foreground/40`,children:[`· `,e.fieldCount]}):null]},e.name))}):null,(()=>{let t=e.proposedPlan.counts,n=[];return t.objects&&n.push(`${t.objects} object${t.objects===1?``:`s`}`),t.views&&n.push(`${t.views} view${t.views===1?``:`s`}`),t.dashboards&&n.push(`${t.dashboards} dashboard${t.dashboards===1?``:`s`}`),t.seedData&&n.push(`sample data`),n.length?(0,L.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n.join(` · `)}):null})(),e.proposedPlan.assumptions.length>0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-[11px] font-medium text-foreground/70`,children:ke}),e.proposedPlan.assumptions.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`mt-px shrink-0 text-foreground/40`,children:`·`}),(0,L.jsx)(`span`,{children:e})]},t))]}):null,e.proposedPlan.questions.length>0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-900/50 dark:bg-amber-950/30`,"data-testid":`proposed-plan-questions`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300`,children:[(0,L.jsx)(rt,{className:`size-3.5`}),Oe]}),e.proposedPlan.questions.map((t,n)=>{let i=e.proposedPlan.questionChoices?.find(e=>e.text===t);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] text-amber-900/90 dark:text-amber-200/90`,children:[(0,L.jsx)(`span`,{className:`mt-px shrink-0`,children:`?`}),(0,L.jsx)(`span`,{children:t})]}),r&&i&&i.options.length>0?(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1 pl-3.5`,"data-testid":`proposed-plan-choice`,children:i.options.map((e,n)=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(Le(t,e)),className:`inline-flex h-6 items-center rounded-full border border-amber-300 bg-background px-2 text-[11px] font-medium text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-200 dark:hover:bg-amber-900/40`,children:e},n))}):null]},n)})]}):null,r?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-0.5`,"data-testid":`proposed-plan-actions`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>mt(e.proposedPlan.questions.length>0),className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`proposed-plan-approve`,children:[(0,L.jsx)(Se,{className:`size-3.5`}),Ne]}),(0,L.jsx)(`button`,{type:`button`,onClick:ht,className:`inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent`,"data-testid":`proposed-plan-adjust`,children:Pe})]}):(0,L.jsx)(`span`,{className:`text-[11px] italic text-muted-foreground/80`,children:je})]}):null]})]},e.toolCallId)};return(0,L.jsxs)(`div`,{ref:We,className:j(Ke?`flex min-h-0 flex-col overflow-hidden bg-background`:`flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background`,e),style:{maxHeight:y},...Ue,children:[i&&!v&&t.length>0&&(0,L.jsx)(`div`,{className:j(`flex items-center justify-end px-4 py-2`,Ke?`bg-background`:`border-b bg-muted/30`),children:(0,L.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:k.clear})}),O?(0,L.jsx)(`div`,{className:j(`shrink-0`,!Ke&&`border-b bg-background/50`),children:O}):null,(0,L.jsxs)(wo,{className:`flex-1 min-h-0`,children:[(0,L.jsxs)(To,{className:j(`space-y-4`,Ke?`mx-auto w-full max-w-2xl px-4 py-8 sm:px-0`:`px-4 py-3`),children:[t.length===0?(0,L.jsxs)(Eo,{className:`gap-3 px-0 py-8`,children:[(0,L.jsx)(`div`,{className:`flex size-9 items-center justify-center rounded-md bg-muted/70 text-muted-foreground`,children:g?(0,L.jsx)(`img`,{src:g,alt:``,className:`size-full rounded-md object-cover`}):(0,L.jsx)(Ae,{className:`size-4`})}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:k.emptyTitle}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:k.emptyDescription})]}),w&&w.length>0?(0,L.jsx)(pp,{className:`justify-center gap-2`,children:w.map(e=>(0,L.jsx)(mp,{className:`h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60`,suggestion:e,onClick:ft},e))}):null]}):t.map(e=>{let t=e.role===`user`,n=e.toolInvocations??[],r=e.reasoning?.trim(),i=e.sources??[],a=t?void 0:e.buildProgress,s=!t&&!!e.streaming&&!e.content&&n.length===0&&!r&&!a,c=!t&&Be===`summary`?n.filter(e=>!TO(e)):[],l=!t&&Be===`debug`?n:!t&&Be!==`debug`?n.filter(TO):[];return(0,L.jsx)(Nf,{from:SO(e.role),children:(0,L.jsxs)(`div`,{className:j(`flex w-full gap-2.5`,p?t?`flex-row-reverse items-start`:`flex-row items-start`:`flex-col`),children:[p?(0,L.jsx)(AO,{isUser:t,url:t?m:g,fallback:t?h:_}):null,(0,L.jsxs)(`div`,{className:j(`flex min-w-0 flex-col gap-2`,p&&!t&&`flex-1`),children:[(0,L.jsxs)(Pf,{children:[a?(0,L.jsx)(zO,{progress:a,onOpenBuiltApp:me,openBuiltAppLabel:ge,onPreviewDraftApp:_e,previewDraftLabel:ve,waitingLabel:k.connectionWaiting}):null,!t&&Be===`debug`&&r?(0,L.jsxs)(pO,{isStreaming:!!e.streaming&&!e.content,className:`mb-2`,children:[(0,L.jsx)(hO,{}),(0,L.jsx)(gO,{children:r})]}):null,!t&&Be===`summary`&&c.length>0?(0,L.jsx)(BO,{groups:DO(c),labels:k}):null,!t&&l.length>0?l.map(vt):null,t?e.content?(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content}):null:s?(0,L.jsx)(MO,{}):e.content?(0,L.jsx)(Lf,{children:e.content}):null,e.streaming&&!s?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse`}):null,!t&&(e.charts?.length??0)>0?(0,L.jsx)(`div`,{className:`mt-2 flex flex-col gap-3`,"data-testid":`chat-charts`,children:e.charts.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-lg border bg-background p-3`,style:{width:`min(520px, 80vw)`},"data-testid":`chat-chart`,children:[e.title?(0,L.jsx)(`div`,{className:`mb-2 text-sm font-medium text-foreground`,children:e.title}):null,(0,L.jsx)(u,{schema:{type:`chart`,chartType:e.chartType??`bar`,data:e.data,xAxisKey:e.xAxisKey,series:e.series}})]},t))}):null,!t&&i.length>0?(0,L.jsxs)(_O,{children:[(0,L.jsx)(vO,{count:i.length}),(0,L.jsx)(yO,{children:i.map((e,t)=>(0,L.jsx)(bO,{href:e.url,title:e.title??e.url},e.id??e.url??t))})]}):null,f&&e.timestamp?(0,L.jsx)(`div`,{className:`text-[10px] opacity-70 mt-1`,children:e.timestamp}):null]}),!t&&!s?(0,L.jsxs)(Ff,{className:`opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[(0,L.jsx)(If,{label:qe===e.id?k.copied:k.copy,tooltip:qe===e.id?k.copied:k.copy,onClick:()=>gt(e),children:qe===e.id?(0,L.jsx)(Te,{className:`size-3.5`}):(0,L.jsx)($e,{className:`size-3.5`})}),o?(0,L.jsx)(If,{label:k.regenerate,tooltip:k.regenerate,onClick:o,children:(0,L.jsx)(he,{className:`size-3.5`})}):null,Be===`debug`&&e.traceId?(0,L.jsx)(`a`,{href:`#trace/${e.traceId}`,"data-trace-id":e.traceId,className:`text-[10px] text-muted-foreground hover:text-foreground ml-1 underline`,title:k.viewTrace,children:k.trace}):null]}):null]})]})},e.id)}),l&&!t.some(e=>e.streaming)?(0,L.jsx)(jO,{showAvatar:p,assistantAvatarUrl:g,assistantAvatarFallback:_,waitingLabel:k.connectionWaiting}):null]}),(0,L.jsx)(Do,{})]}),d?(0,L.jsx)(UO,{error:d,onReload:o,onUpgrade:s}):null,(0,L.jsxs)(`div`,{ref:pt,className:j(`relative`,Ke&&`mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0`),children:[te?(0,L.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 z-10 px-3 pb-1`,children:te}):null,(0,L.jsxs)(tp,{accept:S,fileInputLabel:k.uploadFiles,maxFileSize:C,onSubmit:dt,onError:e=>{console.warn(`[plugin-chatbot] prompt-input error`,e)},children:[x?(0,L.jsx)(np,{children:(0,L.jsx)($f,{children:e=>(0,L.jsx)(Qf,{data:e})})}):null,(0,L.jsx)(rp,{placeholder:n,disabled:c||Ge===`streaming`,onChange:ne?e=>ne(e.currentTarget.value):void 0}),(0,L.jsxs)(ip,{children:[(0,L.jsxs)(ap,{children:[x?(0,L.jsxs)(sp,{children:[(0,L.jsx)(cp,{}),(0,L.jsx)(lp,{children:(0,L.jsx)(ep,{})})]}):null,E&&E.length>0?(0,L.jsx)(`select`,{"aria-label":k.model,value:D??E[0].id,onChange:e=>ee?.(e.target.value),className:`h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:E.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.label??e.id,e.provider?` · ${e.provider}`:``]},e.id))}):null,(0,L.jsxs)(`span`,{className:`hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex`,"aria-hidden":`true`,children:[(0,L.jsx)(`kbd`,{className:`inline-flex h-4 items-center rounded border bg-muted px-1 font-mono text-[10px] leading-none`,children:`⌘`}),(0,L.jsx)(re,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{className:`opacity-70`,children:k.sendHint})]})]}),(0,L.jsx)(up,{"aria-label":Ge===`streaming`?k.stopResponse:k.submit,status:Ge,disabled:c,onClick:Ge===`streaming`?a:void 0,type:Ge===`streaming`?`button`:`submit`})]})]})]})]})});kO.displayName=`ChatbotEnhanced`;function AO({isUser:e,url:t,fallback:n}){return(0,L.jsx)(`div`,{className:j(`mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium`,e?`bg-secondary text-secondary-foreground`:`bg-primary/10 text-primary`),"aria-hidden":`true`,children:t?(0,L.jsx)(`img`,{src:t,alt:``,className:`size-full object-cover`}):e?n?.trim()?.charAt(0)?.toUpperCase()||`U`:(0,L.jsx)(Ae,{className:`size-4`})})}function jO({showAvatar:e,assistantAvatarUrl:t,assistantAvatarFallback:n,waitingLabel:r}){return(0,L.jsx)(Nf,{from:`assistant`,"aria-live":`polite`,children:(0,L.jsxs)(`div`,{className:j(`flex w-full gap-2.5`,e?`flex-row items-start`:`flex-col`),children:[e?(0,L.jsx)(AO,{isUser:!1,url:t,fallback:n}):null,(0,L.jsx)(Pf,{className:`rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(MO,{}),(0,L.jsx)(IO,{active:!0,pending:!0,activityKey:0,waitingLabel:r})]})})]})})}function MO(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`sr-only`,children:`Assistant is responding`}),(0,L.jsxs)(`span`,{"aria-hidden":`true`,className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current animate-pulse`}),(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current animate-pulse`}),(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current animate-pulse`})]})]})}function NO(e){let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`}var PO=6;function FO(e,t){let n=F.useRef(0),r=F.useRef(0),[i,a]=F.useState({elapsed:0,quiet:0});return F.useEffect(()=>{let e=Date.now();n.current=e,r.current=e},[]),F.useEffect(()=>{let e=Date.now();r.current=e,a({elapsed:Math.floor((e-n.current)/1e3),quiet:0})},[t]),F.useEffect(()=>{if(!e)return;let t=()=>{let e=Date.now();a({elapsed:Math.floor((e-n.current)/1e3),quiet:Math.floor((e-r.current)/1e3)})};t();let i=setInterval(t,1e3);return()=>clearInterval(i)},[e]),{elapsedSeconds:i.elapsed,quietSeconds:i.quiet,live:i.quiet<PO}}function IO({active:e,activityKey:t,pending:n=!1,waitingLabel:r}){let{elapsedSeconds:i,quietSeconds:a,live:o}=FO(e,t),s=o?n?`waiting`:`receiving`:`stalled`;return(0,L.jsxs)(`span`,{className:j(`inline-flex items-center gap-1.5 text-xs font-normal tabular-nums`,s===`stalled`?`text-amber-600`:`text-muted-foreground`),"aria-live":`polite`,title:s===`receiving`?`Receiving from server · ${NO(i)} elapsed`:s===`waiting`?`${r} · ${NO(i)} elapsed`:`${r} (${a}s with no response)`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:j(`size-1.5 shrink-0 rounded-full`,s===`receiving`?`bg-emerald-500 animate-pulse`:s===`waiting`?`bg-muted-foreground/50 animate-pulse`:`bg-amber-500`)}),s===`receiving`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(lt,{className:`size-3 shrink-0`,"aria-hidden":!0}),NO(i)]}):s===`waiting`?(0,L.jsx)(`span`,{children:r}):(0,L.jsxs)(`span`,{children:[r,` `,a,`s`]})]})}var LO=[`object`,`view`,`dashboard`,`app`,`seed`],RO={object:`Objects`,view:`Views`,dashboard:`Dashboards`,app:`App`,seed:`Sample data`};function zO({progress:e,onOpenBuiltApp:t,openBuiltAppLabel:n=`Open app`,onPreviewDraftApp:r,previewDraftLabel:i=`Preview`,waitingLabel:a=`Waiting for server…`}){let{phase:o,appLabel:s,items:c,done:l,total:u,seq:d}=e,f=o===`done`,p=d??`${o}:${l}:${c.length}`,m=c.find(e=>e.type===`app`),h=u>0?Math.min(100,Math.round(l/u*100)):f?100:6,g=new Map;for(let e of c){let t=g.get(e.type)??[];t.push(e.name.replace(/_sample$/,``)),g.set(e.type,t)}let _=[...LO.filter(e=>g.has(e)),...[...g.keys()].filter(e=>!LO.includes(e))];return(0,L.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-3 text-sm`,"data-testid":`build-progress`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[f?(0,L.jsx)(At,{className:`size-4 shrink-0 text-emerald-600`}):(0,L.jsx)(De,{className:`size-4 shrink-0 animate-spin text-primary`}),(0,L.jsx)(`span`,{children:f?`Built ${s??`your app`}`:`Building ${s??`your app`}…`}),!f&&o===`data`?(0,L.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`adding sample data`}):null,f?null:(0,L.jsx)(`span`,{className:`ml-auto`,children:(0,L.jsx)(IO,{active:!0,activityKey:p,waitingLabel:a})})]}),(0,L.jsx)(`div`,{className:`mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,L.jsx)(`div`,{className:j(`h-full rounded-full transition-all duration-500`,f?`bg-emerald-500`:`bg-primary`),style:{width:`${h}%`}})}),(0,L.jsx)(`ul`,{className:`space-y-1`,children:_.map(e=>{let t=g.get(e);return(0,L.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(At,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600`}),(0,L.jsxs)(`span`,{className:`min-w-0 text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:RO[e]??e}),` `,t.slice(0,6).join(`, `),t.length>6?` +${t.length-6} more`:``]})]},e)})}),f&&m&&(t||r)?(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[t?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(m.name),className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`build-progress-open-app`,children:[n,(0,L.jsx)(Ye,{className:`size-3.5`})]}):null,r?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(m.name),className:`inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted`,"data-testid":`build-progress-preview-app`,children:[(0,L.jsx)(Me,{className:`size-3.5`}),i]}):null]}):null]})}function BO({groups:e,labels:t}){return e.length===0?null:(0,L.jsx)(`div`,{className:`not-prose mb-2 border-l border-border/70 pl-3`,children:(0,L.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`flex min-h-6 items-center justify-between gap-3 text-xs`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(VO,{state:e.state}),(0,L.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.title}),e.count>1?(0,L.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:[`x`,e.count]}):null]}),(0,L.jsx)(`span`,{className:j(`shrink-0 text-[10px] font-medium`,e.state===`failed`?`text-destructive`:e.state===`completed`?`text-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),children:HO(e.state,t)})]},e.key))})})}function VO({state:e}){return e===`failed`?(0,L.jsx)(_t,{className:`size-3.5 shrink-0 text-destructive`}):e===`completed`?(0,L.jsx)(At,{className:`size-3.5 shrink-0 text-emerald-600`}):(0,L.jsx)(lt,{className:`size-3.5 shrink-0 text-muted-foreground`})}function HO(e,t){switch(e){case`failed`:return t.toolFailed;case`awaiting`:return t.toolAwaitingApproval;case`running`:return t.toolRunning;case`completed`:return t.toolCompleted}}function UO({error:e,onReload:t,onUpgrade:n}){let r=F.useMemo(()=>lo(e),[e]),{summary:i,details:a}=F.useMemo(()=>so(e),[e]),[o,s]=F.useState(!1);if(r){let e=typeof navigator<`u`&&!!navigator.language?.toLowerCase().startsWith(`zh`),t=(e?r.message:r.messageEn??r.message)||(e?`AI 额度已用完。`:`You have reached your AI quota.`),i=r.topUp?e?`购买额度包`:`Buy a credit pack`:e?`升级方案`:`Upgrade plan`;return(0,L.jsx)(`div`,{className:`border-t bg-background px-3 py-2 text-sm`,role:`alert`,children:(0,L.jsx)(`div`,{className:`rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`font-medium leading-snug text-foreground`,children:e?`需要升级`:`Upgrade needed`}),(0,L.jsx)(`div`,{className:`mt-0.5 break-words leading-snug text-muted-foreground`,children:t})]}),n?(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex h-7 shrink-0 items-center rounded-md border border-amber-400/50 bg-background px-2 text-xs font-medium text-amber-700 hover:bg-amber-100/60 dark:text-amber-300`,children:i}):null]})})})}return(0,L.jsx)(`div`,{className:`border-t bg-background px-3 py-2 text-sm`,role:`alert`,children:(0,L.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-foreground`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(Ot,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`font-medium leading-snug text-destructive`,children:`Response failed`}),(0,L.jsx)(`div`,{className:`mt-0.5 break-words leading-snug text-muted-foreground`,children:i||`Something went wrong. Please try again.`})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[a?(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`inline-flex h-7 items-center rounded-md px-2 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-foreground`,"aria-expanded":o,children:o?`Hide`:`Details`}):null,t?(0,L.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex h-7 items-center rounded-md border border-destructive/30 bg-background px-2 text-xs font-medium text-destructive hover:bg-destructive/10`,children:[(0,L.jsx)(he,{className:`mr-1 h-3 w-3`}),`Retry`]}):null]})]}),o&&a?(0,L.jsx)(`pre`,{className:`mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words rounded border bg-background px-2 py-1 font-mono text-[11px] leading-snug text-muted-foreground`,children:a}):null]})})}function WO({output:e,errorText:t}){return t?(0,L.jsx)(F_,{output:void 0,errorText:t}):e==null||e===``?null:typeof e==`string`&&!CO(e)?(0,L.jsxs)(`div`,{className:`space-y-2 p-4`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Result`}),(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground`,children:(0,L.jsx)(Lf,{children:e})})]}):(0,L.jsx)(F_,{output:e,errorText:void 0})}function GO({floatingConfig:e,headerExtra:t,headerActions:n,...r}){let{position:i=`bottom-right`,defaultOpen:a=!1,panelWidth:o=400,panelHeight:s=520,title:c=`Chat`,triggerSize:l=56}=e??{},[u,d]=F.useState(null);F.useEffect(()=>{let e=document.getElementById(`floating-chatbot-portal`);return e||(e=document.createElement(`div`),e.id=`floating-chatbot-portal`,document.body.appendChild(e)),d(e),()=>{e&&e.parentNode&&!e.hasChildNodes()&&e.parentNode.removeChild(e)}},[]);let f=(0,L.jsxs)(Ga,{defaultOpen:a,children:[(0,L.jsx)(Za,{position:i,size:l}),(0,L.jsx)(ro,{title:c,position:i,width:o,height:s,headerExtra:t,headerActions:n,children:(0,L.jsx)(kO,{...r,maxHeight:`100%`,className:`h-full border-0 rounded-none`})})]});return u?Fl.createPortal(f,u):f}l.register(`chatbot`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:i,sendMessage:a}=Na({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,L.jsx)(lk,{messages:r,placeholder:e.placeholder,onSendMessage:e=>{a(e)},disabled:e.disabled||i,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`,description:`Array of message objects with id, role, content, and optional timestamp`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`,description:`URL of the user avatar image`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`,description:`Fallback text shown when user avatar image is not available`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`,description:`URL of the assistant avatar image`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`,description:`Fallback text shown when assistant avatar image is not available`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint (e.g., /api/v1/ai/chat). When set, enables streaming AI mode.`},{name:`conversationId`,type:`string`,label:`Conversation ID`,description:`Multi-turn conversation identifier`},{name:`systemPrompt`,type:`string`,label:`System Prompt`,description:`System prompt to configure assistant behavior`},{name:`model`,type:`string`,label:`AI Model`,description:`AI model identifier (e.g., gpt-4o)`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1,description:`Automatically send a response after user message (for demo purposes, ignored when API is set)`},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),l.register(`chatbot-enhanced`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:i,error:a,sendMessage:o,stop:s,reload:c,clear:l,isApiMode:u}=Na({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,L.jsx)(kO,{messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{o(e,t)},onClear:()=>{l(),e.onClear?.()},onStop:u&&i?s:void 0,onReload:u?c:void 0,disabled:e.disabled,isLoading:i,error:a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,maxHeight:e.maxHeight,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,processVisibility:e.processVisibility,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Enhanced)`,inputs:[{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`showTimestamp`,type:`boolean`,label:`Show Timestamps`,defaultValue:!1},{name:`disabled`,type:`boolean`,label:`Disabled`,defaultValue:!1},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`processVisibility`,type:`enum`,label:`Agent Process Visibility`,defaultValue:`summary`},{name:`userAvatarUrl`,type:`string`,label:`User Avatar URL`},{name:`userAvatarFallback`,type:`string`,label:`User Avatar Fallback`,defaultValue:`You`},{name:`assistantAvatarUrl`,type:`string`,label:`Assistant Avatar URL`},{name:`assistantAvatarFallback`,type:`string`,label:`Assistant Avatar Fallback`,defaultValue:`AI`},{name:`maxHeight`,type:`string`,label:`Max Height`,defaultValue:`500px`},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,showTimestamp:!1,disabled:!1,enableMarkdown:!0,enableFileUpload:!1,userAvatarFallback:`You`,assistantAvatarFallback:`AI`,maxHeight:`500px`,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3,className:`w-full max-w-2xl`}}),l.register(`chatbot-floating`,({schema:e,className:t,...n})=>{let{messages:r,isLoading:i,error:a,sendMessage:o,stop:s,reload:c,clear:l,isApiMode:u}=Na({api:e.api,initialMessages:e.messages,conversationId:e.conversationId,systemPrompt:e.systemPrompt,model:e.model,streamingEnabled:e.streamingEnabled,headers:e.headers,body:e.requestBody,maxToolRoundtrips:e.maxToolRoundtrips,onError:e.onError,showTimestamp:e.showTimestamp,autoResponse:e.autoResponse,autoResponseText:e.autoResponseText,autoResponseDelay:e.autoResponseDelay,onSend:e.onSend});return(0,L.jsx)(GO,{floatingConfig:e.floatingConfig,messages:r,placeholder:e.placeholder,onSendMessage:(e,t)=>{o(e,t)},onClear:()=>{l(),e.onClear?.()},onStop:u&&i?s:void 0,onReload:u?c:void 0,disabled:e.disabled,isLoading:i,error:a,showTimestamp:e.showTimestamp,userAvatarUrl:e.userAvatarUrl,userAvatarFallback:e.userAvatarFallback,assistantAvatarUrl:e.assistantAvatarUrl,assistantAvatarFallback:e.assistantAvatarFallback,enableMarkdown:e.enableMarkdown??!0,enableFileUpload:e.enableFileUpload??!1,className:t,...n})},{namespace:`plugin-chatbot`,label:`Chatbot (Floating)`,inputs:[{name:`displayMode`,type:`string`,label:`Display Mode`,defaultValue:`floating`,description:`Set to "floating" for FAB widget`},{name:`floatingConfig.position`,type:`string`,label:`FAB Position`,defaultValue:`bottom-right`,description:`bottom-right or bottom-left`},{name:`floatingConfig.defaultOpen`,type:`boolean`,label:`Default Open`,defaultValue:!1},{name:`floatingConfig.panelWidth`,type:`number`,label:`Panel Width`,defaultValue:400},{name:`floatingConfig.panelHeight`,type:`number`,label:`Panel Height`,defaultValue:520},{name:`floatingConfig.title`,type:`string`,label:`Panel Title`,defaultValue:`Chat`},{name:`floatingConfig.triggerSize`,type:`number`,label:`Trigger Size`,defaultValue:56},{name:`messages`,type:`array`,label:`Initial Messages`},{name:`placeholder`,type:`string`,label:`Input Placeholder`,defaultValue:`Type your message...`},{name:`enableMarkdown`,type:`boolean`,label:`Enable Markdown`,defaultValue:!0},{name:`enableFileUpload`,type:`boolean`,label:`Enable File Upload`,defaultValue:!1},{name:`api`,type:`string`,label:`API Endpoint`,description:`Backend SSE endpoint for streaming AI mode`},{name:`conversationId`,type:`string`,label:`Conversation ID`},{name:`systemPrompt`,type:`string`,label:`System Prompt`},{name:`model`,type:`string`,label:`AI Model`},{name:`streamingEnabled`,type:`boolean`,label:`Enable Streaming`,defaultValue:!0},{name:`autoResponse`,type:`boolean`,label:`Enable Auto Response (Demo)`,defaultValue:!1},{name:`autoResponseText`,type:`string`,label:`Auto Response Text`,defaultValue:`Thank you for your message!`},{name:`autoResponseDelay`,type:`number`,label:`Auto Response Delay (ms)`,defaultValue:1e3},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{displayMode:`floating`,floatingConfig:{position:`bottom-right`,defaultOpen:!1,panelWidth:400,panelHeight:520,title:`Chat`,triggerSize:56},messages:[{id:`welcome`,role:`assistant`,content:`Hello! How can I help you today?`}],placeholder:`Type your message...`,enableMarkdown:!0,enableFileUpload:!1,autoResponse:!0,autoResponseText:`Thank you for your message! This is an automated response.`,autoResponseDelay:1e3}});var KO=`/api/v1/ai`;function qO(e,t,n){let r=e.replace(/\/$/,``),i=new URLSearchParams;if(n)for(let[e,t]of Object.entries(n))t==null||t===``||i.set(e,String(t));let a=i.toString();return`${r}${t}${a?`?${a}`:``}`}async function JO(e,t,n){let r=await fetch(e,{credentials:`include`,...t,headers:{Accept:`application/json`,"Content-Type":`application/json`,...n??{},...t.headers??{}}}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.error?.message??i?.message??i?.error??`${r.status} ${r.statusText}`,t=Error(typeof e==`string`?e:JSON.stringify(e));throw t.status=r.status,t.body=i,t}return i}function YO(e={}){let{apiBase:t=KO,status:n=`pending`,conversationId:r,limit:i,headers:a,pollInterval:o=5e3,enabled:s=!0}=e,[c,l]=F.useState([]),[u,d]=F.useState(0),[f,p]=F.useState(!1),[m,h]=F.useState(void 0),g=F.useRef({apiBase:t,status:n,conversationId:r,limit:i,headers:a});g.current={apiBase:t,status:n,conversationId:r,limit:i,headers:a};let _=F.useCallback(async()=>{let{apiBase:e,status:t,conversationId:n,limit:r,headers:i}=g.current;p(!0),h(void 0);try{let a=await JO(qO(e,`/pending-actions`,{status:t&&t!==`all`?t:void 0,conversationId:n,limit:r}),{method:`GET`},i);l(Array.isArray(a.items)?a.items:[]),d(typeof a.total==`number`?a.total:a.items?.length??0)}catch(e){h(e instanceof Error?e:Error(String(e)))}finally{p(!1)}},[]),v=F.useCallback(async e=>{let{apiBase:t,headers:n}=g.current,r=qO(t,`/pending-actions/${encodeURIComponent(e)}/approve`);try{return await JO(r,{method:`POST`,body:`{}`},n)}finally{_()}},[_]),y=F.useCallback(async(e,t)=>{let{apiBase:n,headers:r}=g.current,i=qO(n,`/pending-actions/${encodeURIComponent(e)}/reject`);try{return await JO(i,{method:`POST`,body:JSON.stringify(t?{reason:t}:{})},r)}finally{_()}},[_]);return F.useEffect(()=>{if(!s||(_(),!o||o<=0))return;let e=setInterval(()=>{_()},o);return()=>clearInterval(e)},[s,o,_,t,n,r,i]),{items:c,total:u,isLoading:f,error:m,refresh:_,approve:v,reject:y}}var XO={pending:{variant:`secondary`,label:`Pending`},approved:{variant:`default`,label:`Approved`},executed:{variant:`default`,label:`Executed`},failed:{variant:`destructive`,label:`Failed`},rejected:{variant:`outline`,label:`Rejected`}};function ZO({status:e}){let t=XO[e]??{variant:`outline`,label:e};return(0,L.jsx)(Qe,{variant:t.variant,children:t.label})}function QO(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Date.now()-t,r=Math.round(n/1e3);if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);if(a<24)return`${a}h ago`;let o=Math.round(a/24);if(o<30)return`${o}d ago`;try{return new Date(e).toLocaleDateString()}catch{return e}}function $O(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function ek({value:e,max:t=320}){let n=typeof e==`string`?e:JSON.stringify(e,null,2);return n==null||n===``?(0,L.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`—`}):(0,L.jsx)(`pre`,{className:`bg-muted/40 rounded text-xs p-2 overflow-auto whitespace-pre-wrap break-all`,style:{maxHeight:t},children:n})}function tk(e){switch(e){case`pending`:return`pending`;case`all`:return`all`;case`decided`:return`all`}}function nk({apiBase:e,headers:t,pollInterval:n=5e3,conversationId:r,variant:i=`card`,title:a=`AI Approvals`,description:o=`Actions an AI agent proposed that need a human review before execution.`,className:s}){let[c,l]=F.useState(`pending`),[u,d]=F.useState(null),[f,p]=F.useState(null),[m,h]=F.useState(``),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(null),{items:S,isLoading:C,error:w,refresh:T,approve:E,reject:D}=YO({apiBase:e,headers:t,pollInterval:n,conversationId:r,status:tk(c)}),ee=F.useMemo(()=>c===`decided`?S.filter(e=>e.status!==`pending`):S,[S,c]),O=F.useMemo(()=>u?S.find(e=>e.id===u)??null:null,[u,S]),ne=F.useCallback(async e=>{_(e),y(null);try{let t=await E(e),n=t.status===`executed`;x({id:e,kind:`approve`,ok:n,message:n?`Executed`:t.error??`Action failed during execution`})}catch(t){let n=t instanceof Error?t.message:String(t);y(n),x({id:e,kind:`approve`,ok:!1,message:n})}finally{_(null)}},[E]),re=F.useCallback(async(e,t)=>{_(e),y(null);try{await D(e,t.trim()||void 0),x({id:e,kind:`reject`,ok:!0,message:`Rejected`}),p(null),h(``)}catch(t){let n=t instanceof Error?t.message:String(t);y(n),x({id:e,kind:`reject`,ok:!1,message:n})}finally{_(null)}},[D]),ie=(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(mt,{value:c,onValueChange:e=>l(e),children:(0,L.jsxs)(ot,{children:[(0,L.jsx)(Ke,{value:`pending`,children:`Pending`}),(0,L.jsx)(Ke,{value:`decided`,children:`Decided`}),(0,L.jsx)(Ke,{value:`all`,children:`All`})]})}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:C,"data-testid":`ai-inbox-refresh`,children:[(0,L.jsx)(he,{className:`h-3.5 w-3.5 mr-1.5 ${C?`animate-spin`:``}`}),`Refresh`]})]}),w?(0,L.jsxs)(at,{variant:`destructive`,children:[(0,L.jsx)(Ot,{className:`h-4 w-4`}),(0,L.jsx)(Ge,{children:w.message})]}):null,v?(0,L.jsxs)(at,{variant:`destructive`,children:[(0,L.jsx)(Ot,{className:`h-4 w-4`}),(0,L.jsx)(Ge,{children:v})]}):null,b&&!v?(0,L.jsxs)(at,{variant:b.ok?`default`:`destructive`,children:[b.ok?(0,L.jsx)(At,{className:`h-4 w-4`}):(0,L.jsx)(_t,{className:`h-4 w-4`}),(0,L.jsxs)(Ge,{children:[b.kind===`approve`?`Approve`:`Reject`,` for`,` `,(0,L.jsxs)(`code`,{className:`text-xs`,children:[b.id.slice(0,8),`…`]}),`:`,` `,b.message??(b.ok?`OK`:`Failed`)]})]}):null,C&&ee.length===0?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(we,{className:`h-10 w-full`}),(0,L.jsx)(we,{className:`h-10 w-full`}),(0,L.jsx)(we,{className:`h-10 w-full`})]}):ee.length===0?(0,L.jsx)(je,{children:(0,L.jsxs)(se,{children:[(0,L.jsx)(Ie,{children:(0,L.jsx)(te,{className:`h-8 w-8 text-muted-foreground`})}),(0,L.jsx)(me,{children:`No actions waiting`}),(0,L.jsx)(jt,{children:`When the AI proposes a sensitive action it will appear here for review.`})]})}):(0,L.jsx)(`div`,{className:`rounded-md border`,children:(0,L.jsxs)(gt,{children:[(0,L.jsx)(Et,{children:(0,L.jsxs)(Ze,{children:[(0,L.jsx)(ut,{className:`w-[140px]`,children:`Tool`}),(0,L.jsx)(ut,{className:`w-[140px]`,children:`Action`}),(0,L.jsx)(ut,{className:`w-[120px]`,children:`Object`}),(0,L.jsx)(ut,{className:`w-[110px]`,children:`Status`}),(0,L.jsx)(ut,{className:`w-[110px]`,children:`Proposed`}),(0,L.jsx)(ut,{className:`w-[260px] text-right`,children:`Decision`})]})}),(0,L.jsx)(xt,{children:ee.map(e=>{let t=e.status===`pending`,n=g===e.id;return(0,L.jsxs)(Ze,{children:[(0,L.jsx)(k,{className:`font-mono text-xs`,children:e.tool_name}),(0,L.jsx)(k,{className:`text-sm`,children:e.action_name}),(0,L.jsx)(k,{className:`text-sm`,children:e.object_name}),(0,L.jsx)(k,{children:(0,L.jsx)(ZO,{status:e.status})}),(0,L.jsx)(k,{className:`text-xs text-muted-foreground`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(Je,{className:`h-3 w-3`}),` `,QO(e.proposed_at)]})}),(0,L.jsx)(k,{className:`text-right`,children:(0,L.jsxs)(`div`,{className:`inline-flex gap-1.5`,children:[(0,L.jsxs)(A,{size:`sm`,variant:`ghost`,onClick:()=>d(e.id),"data-testid":`ai-inbox-view-${e.id}`,children:[(0,L.jsx)(Me,{className:`h-3.5 w-3.5 mr-1`}),` View`]}),t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(A,{size:`sm`,variant:`default`,disabled:n,onClick:()=>void ne(e.id),"data-testid":`ai-inbox-approve-${e.id}`,children:[(0,L.jsx)(At,{className:`h-3.5 w-3.5 mr-1`}),n?`Working…`:`Approve`]}),(0,L.jsxs)(A,{size:`sm`,variant:`destructive`,disabled:n,onClick:()=>{p(e.id),h(``)},"data-testid":`ai-inbox-reject-${e.id}`,children:[(0,L.jsx)(_t,{className:`h-3.5 w-3.5 mr-1`}),`Reject`]})]}):null]})})]},e.id)})})]})})]});return(0,L.jsxs)(L.Fragment,{children:[i===`card`?(0,L.jsxs)(_e,{className:s,children:[(0,L.jsxs)(Ve,{className:`pb-3`,children:[(0,L.jsxs)(ke,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Ae,{className:`h-4 w-4`}),` `,a]}),o?(0,L.jsx)(ze,{children:o}):null]}),(0,L.jsx)(Be,{children:ie})]}):(0,L.jsx)(`div`,{className:s,children:ie}),(0,L.jsx)(Oe,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,L.jsxs)(de,{className:`sm:max-w-[560px] overflow-y-auto`,children:[(0,L.jsxs)(xe,{children:[(0,L.jsxs)(Ne,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Ae,{className:`h-4 w-4`}),O?O.action_name:`Pending action`]}),(0,L.jsx)(ge,{children:O?(0,L.jsxs)(L.Fragment,{children:[`Tool `,(0,L.jsx)(`code`,{className:`text-xs`,children:O.tool_name}),` on`,` `,(0,L.jsx)(`code`,{className:`text-xs`,children:O.object_name})]}):`Loading…`})]}),O?(0,L.jsxs)(`div`,{className:`px-4 space-y-4 mt-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs text-muted-foreground`,children:`Status`}),(0,L.jsx)(`div`,{className:`mt-1`,children:(0,L.jsx)(ZO,{status:O.status})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs text-muted-foreground`,children:`Proposed`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs`,children:QO(O.proposed_at)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs text-muted-foreground`,children:`Proposed by`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs font-mono break-all`,children:O.proposed_by??`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs text-muted-foreground`,children:`Decided by`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs font-mono break-all`,children:O.decided_by??`—`})]}),O.conversation_id?(0,L.jsxs)(`div`,{className:`col-span-2`,children:[(0,L.jsx)(ht,{className:`text-xs text-muted-foreground`,children:`Conversation`}),(0,L.jsx)(`div`,{className:`mt-1 text-xs font-mono break-all`,children:O.conversation_id})]}):null]}),(0,L.jsx)(Mt,{}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs`,children:`Tool input`}),(0,L.jsx)(`div`,{className:`mt-1.5`,children:(0,L.jsx)(ek,{value:$O(O.tool_input)})})]}),O.result?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs`,children:`Result`}),(0,L.jsx)(`div`,{className:`mt-1.5`,children:(0,L.jsx)(ek,{value:$O(O.result)})})]}):null,O.error?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs text-destructive`,children:`Error`}),(0,L.jsx)(`div`,{className:`mt-1.5`,children:(0,L.jsx)(ek,{value:O.error})})]}):null,O.rejection_reason?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(ht,{className:`text-xs`,children:`Rejection reason`}),(0,L.jsx)(`div`,{className:`mt-1.5 text-sm`,children:O.rejection_reason})]}):null,O.status===`pending`?(0,L.jsxs)(`div`,{className:`pt-2 flex gap-2`,children:[(0,L.jsxs)(A,{size:`sm`,onClick:()=>void ne(O.id),disabled:g===O.id,children:[(0,L.jsx)(At,{className:`h-3.5 w-3.5 mr-1`}),`Approve & Execute`]}),(0,L.jsxs)(A,{size:`sm`,variant:`destructive`,onClick:()=>{p(O.id),h(``)},disabled:g===O.id,children:[(0,L.jsx)(_t,{className:`h-3.5 w-3.5 mr-1`}),`Reject`]})]}):null]}):null]})}),(0,L.jsx)(Oe,{open:!!f,onOpenChange:e=>{e||(p(null),h(``))},children:(0,L.jsxs)(de,{side:`bottom`,className:`max-h-[40vh]`,children:[(0,L.jsxs)(xe,{children:[(0,L.jsx)(Ne,{children:`Reject this action?`}),(0,L.jsx)(ge,{children:`The reason is shown back to the AI so it can adjust its next response.`})]}),(0,L.jsxs)(`div`,{className:`px-4 mt-3 space-y-3`,children:[(0,L.jsx)(wt,{value:m,onChange:e=>h(e.target.value),placeholder:`Optional reason (e.g. 'Wrong record id — please confirm with the user first.')`,rows:4,"data-testid":`ai-inbox-reject-reason`}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>{p(null),h(``)},children:`Cancel`}),(0,L.jsxs)(A,{variant:`destructive`,size:`sm`,onClick:()=>f&&void re(f,m),disabled:!f||g===f,"data-testid":`ai-inbox-reject-confirm`,children:[(0,L.jsx)(_t,{className:`h-3.5 w-3.5 mr-1`}),`Reject`]})]})]})]})})]})}function rk(e){return!e||e.length===0?`/api/v1/ai`:e.endsWith(`/`)?e.slice(0,-1):e}function ik(e,t){let n={...e??{}};return t&&(n[`Content-Type`]=`application/json`),n}async function ak(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return{raw:t}}}function ok(e){let{messages:t,apiBase:n,headers:r,onDecided:i,continueConversation:a}=e,o=rk(n),s=F.useMemo(()=>{let e=new Map;for(let n of t){let t=n.toolInvocations??[];for(let n of t)n.pendingActionId&&n.toolCallId&&e.set(n.toolCallId,{pendingActionId:n.pendingActionId,toolName:n.toolName})}return e},[t]),[c,l]=F.useState({}),u=F.useRef(0),[d,f]=F.useState(!1),p=F.useCallback((e,t)=>{l(n=>{if(!t){if(!(e in n))return n;let{[e]:t,...r}=n;return r}return{...n,[e]:t}})},[]);return{decisions:c,decide:F.useCallback(async(e,t,n)=>{let c=s.get(e);if(!c){p(e,{state:`error`,message:`No pending-action id found for this tool call. The tool result may not be a HITL proposal.`});return}let{pendingActionId:l,toolName:d}=c;p(e,{state:`pending`,message:t?`Approving…`:`Rejecting…`}),u.current+=1,f(!0);try{let s=`${o}/pending-actions/${encodeURIComponent(l)}/${t?`approve`:`reject`}`,c=t?`{}`:JSON.stringify({reason:n??``}),u=await fetch(s,{method:`POST`,credentials:`include`,headers:ik(r,!0),body:c}),f=await ak(u)??{};if(!u.ok){let t=typeof f.error==`string`?f.error:`Approval failed: HTTP ${u.status}`;p(e,{state:`error`,message:t}),i?.(e,{id:l,status:`failed`,error:t});return}let m=f.status??(t?`executed`:`rejected`),h=!1;if(m===`executed`?(p(e,{state:`success`,message:`Approved — action executed.`}),h=!0):m===`rejected`?(p(e,{state:`success`,message:n?`Rejected: ${n}`:`Rejected.`}),h=!0):m===`failed`?p(e,{state:`error`,message:f.error??`Action approved but execution failed.`}):(p(e,{state:`success`,message:`Status: ${m}`}),h=!0),i?.(e,f),h&&a){let r=sk({approved:t,status:m,toolName:d,pendingActionId:l,outcome:f,reason:n});r&&a(r,{toolCallId:e,pendingActionId:l,decision:t?`approved`:`rejected`,outcome:f,toolName:d})}}catch(t){p(e,{state:`error`,message:t instanceof Error?t.message:String(t)})}finally{--u.current,u.current<=0&&(u.current=0,f(!1))}},[o,r,s,i,a,p]),isDeciding:d}}function sk(e){let{approved:t,status:n,toolName:r,pendingActionId:i,outcome:a,reason:o}=e,s=`[HITL ${i}]`;if(t&&n===`executed`){let e=a.result;return`${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e==null?`(no payload)`:typeof e==`string`?e:ck(JSON.stringify(e),800)}. Acknowledge the outcome concisely and continue the user's task.`}if(!t&&n===`rejected`)return`${s} The operator rejected the \`${r}\` call.${o&&o.trim().length>0?` Reason: ${o}.`:``} Acknowledge the rejection and ask whether to try a different approach.`;if(n===`failed`){let e=a.error;return`${s} The \`${r}\` call was approved but execution failed: ${typeof e==`string`?e:ck(JSON.stringify(e??{}),400)}. Apologize concisely and offer alternatives.`}}function ck(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var lk=F.forwardRef(({className:e,messages:t=[],placeholder:n=`Type your message...`,onSendMessage:r,disabled:i=!1,showTimestamp:a=!1,userAvatarUrl:o,userAvatarFallback:s=`You`,assistantAvatarUrl:c,assistantAvatarFallback:l=`AI`,maxHeight:u=`500px`,...d},f)=>{let[p,m]=F.useState(``),h=F.useRef(null),g=F.useRef(null);F.useEffect(()=>{if(h.current){let e=h.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[t]);let _=()=>{p.trim()&&r&&(r(p.trim()),m(``),g.current?.focus())},v=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),_())};return(0,L.jsxs)(`div`,{ref:f,className:j(`flex flex-col border rounded-lg bg-background overflow-hidden`,e),style:{maxHeight:u},...d,children:[(0,L.jsx)(pe,{ref:h,className:`flex-1 p-4`,children:(0,L.jsx)(`div`,{className:`space-y-4`,children:t.length===0?(0,L.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground text-sm`,children:`No messages yet. Start a conversation!`}):t.map(e=>(0,L.jsx)(uk,{message:e,showTimestamp:a,userAvatarUrl:o,userAvatarFallback:s,assistantAvatarUrl:c,assistantAvatarFallback:l},e.id))})}),(0,L.jsx)(`div`,{className:`border-t p-4`,children:(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(ft,{ref:g,value:p,onChange:e=>m(e.target.value),onKeyDown:v,placeholder:n,disabled:i,className:`flex-1`}),(0,L.jsx)(A,{onClick:_,disabled:i||!p.trim(),size:`icon`,children:(0,L.jsx)(Pe,{className:`h-4 w-4`})})]})})]})});lk.displayName=`Chatbot`;var uk=({message:e,showTimestamp:t,userAvatarUrl:n,userAvatarFallback:r,assistantAvatarUrl:i,assistantAvatarFallback:a})=>{let o=e.role===`user`;if(e.role===`system`)return(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full`,children:e.content})});let s=o?e.avatar||n:e.avatar||i,c=o?e.avatarFallback||r:e.avatarFallback||a;return(0,L.jsxs)(`div`,{className:j(`flex gap-3`,o?`flex-row-reverse`:`flex-row`),children:[(0,L.jsxs)(Ct,{className:`h-8 w-8`,children:[(0,L.jsx)(yt,{src:s}),(0,L.jsx)(pt,{className:`text-xs`,children:c})]}),(0,L.jsxs)(`div`,{className:j(`flex flex-col gap-1`,o?`items-end`:`items-start`),children:[(0,L.jsx)(`div`,{className:j(`rounded-lg px-4 py-2 max-w-[70%] break-words`,o?`bg-primary text-primary-foreground`:`bg-muted`),children:(0,L.jsx)(`p`,{className:`text-sm whitespace-pre-wrap`,children:e.content})}),t&&e.timestamp&&(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.timestamp})]})]})},dk=F.forwardRef(({className:e,avatarSrc:t,avatarFallback:n=`AI`,...r},i)=>(0,L.jsxs)(`div`,{ref:i,className:j(`flex gap-3`,e),...r,children:[(0,L.jsxs)(Ct,{className:`h-8 w-8`,children:[(0,L.jsx)(yt,{src:t}),(0,L.jsx)(pt,{className:`text-xs`,children:n})]}),(0,L.jsx)(`div`,{className:`flex items-center bg-muted rounded-lg px-4 py-2`,children:(0,L.jsxs)(`div`,{className:`flex gap-1`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]`}),(0,L.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]`}),(0,L.jsx)(`span`,{className:`w-2 h-2 bg-muted-foreground rounded-full animate-bounce`})]})})]}));dk.displayName=`TypingIndicator`;export{Aa as S,La as _,xO as a,Sa as b,Of as c,Ua as d,Fa as f,Ra as g,za as h,kO as i,Mf as l,Ba as m,nk as n,ou as o,Ia as p,GO as r,Pu as s,ok as t,Va as u,Na as v,xa as x,wa as y};