@truefoundry/trueforge 0.186.0-rc.2 → 0.186.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 (215) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-D2J3IH37-CQZZoOBC.js → AgentCodeSnippets-D2J3IH37-DD3K7eq2.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-DD3K7eq2.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-DD3K7eq2.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-TCZEIIUV-5Rtf3TvY.js → AgentMetricChart-TCZEIIUV-DlkbLiqX.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-TCZEIIUV-DlkbLiqX.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-TCZEIIUV-DlkbLiqX.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-ZSZENAFZ-D0HM5BSW.js → AgentOverview-ZSZENAFZ-MH2qXo-8.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-MH2qXo-8.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-MH2qXo-8.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-26TTGY3F-6FMUgy7r.js → AgentSessionEventTimeline-26TTGY3F-B3RffNd5.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-26TTGY3F-B3RffNd5.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-26TTGY3F-B3RffNd5.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-SV6ZYNU2-CNDMPnla.js → AgentSessionEventTimelineChart-SV6ZYNU2-BJDI4-l_.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-BJDI4-l_.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-BJDI4-l_.js.gz +0 -0
  16. package/dist/_frontend/assets/{AgentSessions-W2EDVBCS-lqR7dkcO.js → AgentSessions-W2EDVBCS-DJ_2ids3.js} +1 -1
  17. package/dist/_frontend/assets/AgentSessions-W2EDVBCS-DJ_2ids3.js.br +0 -0
  18. package/dist/_frontend/assets/{AgentSessions-W2EDVBCS-lqR7dkcO.js.gz → AgentSessions-W2EDVBCS-DJ_2ids3.js.gz} +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-E3KBW7HI-CMwC3bcI.js → ConnectorSettings-E3KBW7HI-CgqlO4He.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-CgqlO4He.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-CgqlO4He.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-OYD7YJSD-CqCN5TbW.js → DockLayout-OYD7YJSD-BsU6EkTC.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-IGDKPIOC-CF0zSf6U.js → DrawerLayout-IGDKPIOC-B-eU-MHF.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-B-eU-MHF.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-B-eU-MHF.js.gz +0 -0
  26. package/dist/_frontend/assets/{EnvironmentsPage-BUA2EGXE-Dt-L2w8t.js → EnvironmentsPage-BUA2EGXE-hn2BUGZI.js} +1 -1
  27. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-hn2BUGZI.js.br +0 -0
  28. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-hn2BUGZI.js.gz +0 -0
  29. package/dist/_frontend/assets/{MemorySettings-Y6HNEYIW-DL6nR8e0.js → MemorySettings-Y6HNEYIW-BvmnIQUU.js} +1 -1
  30. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-BvmnIQUU.js.br +0 -0
  31. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-BvmnIQUU.js.gz +0 -0
  32. package/dist/_frontend/assets/{ModelSettings-3RSWQ5WD-YyI5xGN4.js → ModelSettings-3RSWQ5WD-Paas2H98.js} +1 -1
  33. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-Paas2H98.js.br +0 -0
  34. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-Paas2H98.js.gz +0 -0
  35. package/dist/_frontend/assets/{SandboxSettings-YIEGCYQO-Bn_-fbRJ.js → SandboxSettings-YIEGCYQO-BVmGo8qk.js} +1 -1
  36. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-BVmGo8qk.js.br +0 -0
  37. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-BVmGo8qk.js.gz +0 -0
  38. package/dist/_frontend/assets/{SchedulesPage-OVDMYD6Q-DWmVgOrq.js → SchedulesPage-OVDMYD6Q-O2hNR1RH.js} +1 -1
  39. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-O2hNR1RH.js.br +0 -0
  40. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-O2hNR1RH.js.gz +0 -0
  41. package/dist/_frontend/assets/{SettingsBuilder-6WNST3GI-CQudqTjg.js → SettingsBuilder-6WNST3GI-BYDGxx4W.js} +2 -2
  42. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-BYDGxx4W.js.br +0 -0
  43. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-BYDGxx4W.js.gz +0 -0
  44. package/dist/_frontend/assets/{ShellRouteSync-4T763MWC-BOFQkqAR.js → ShellRouteSync-4T763MWC-CPxzGJDG.js} +1 -1
  45. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-CPxzGJDG.js.br +0 -0
  46. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-CPxzGJDG.js.gz +0 -0
  47. package/dist/_frontend/assets/{SidebarLayout-YWA6PPZM-CFjD1Kmo.js → SidebarLayout-YWA6PPZM-DrVGRycR.js} +2 -2
  48. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-DrVGRycR.js.br +0 -0
  49. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-DrVGRycR.js.gz +0 -0
  50. package/dist/_frontend/assets/{SkillSettings-XLK6REIA-CJVGKalf.js → SkillSettings-XLK6REIA-C2qKonlV.js} +1 -1
  51. package/dist/_frontend/assets/SkillSettings-XLK6REIA-C2qKonlV.js.br +0 -0
  52. package/dist/_frontend/assets/SkillSettings-XLK6REIA-C2qKonlV.js.gz +0 -0
  53. package/dist/_frontend/assets/{TrueForgeUIWithRouter-LFJ4E5VL-o7uC8O0Z.js → TrueForgeUIWithRouter-LFJ4E5VL-BNRfP9iQ.js} +1 -1
  54. package/dist/_frontend/assets/{WebSearchSettings-PKYKXD26-Ccfvu3fp.js → WebSearchSettings-PKYKXD26-BfSq82qT.js} +1 -1
  55. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-BfSq82qT.js.br +0 -0
  56. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-BfSq82qT.js.gz +0 -0
  57. package/dist/_frontend/assets/{WidgetLayout-HQZFWVZ2-CW9j2zi5.js → WidgetLayout-HQZFWVZ2-msxsQ6JO.js} +1 -1
  58. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-msxsQ6JO.js.br +0 -0
  59. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-msxsQ6JO.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-HED32BFK-CHoNWtNi.js → chunk-HED32BFK-BkmeeYL6.js} +2 -2
  61. package/dist/_frontend/assets/chunk-HED32BFK-BkmeeYL6.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-HED32BFK-BkmeeYL6.js.gz +0 -0
  63. package/dist/_frontend/assets/{chunk-HK4WITDD-Dk6A8b9_.js → chunk-HK4WITDD-D1KPKrkR.js} +1 -1
  64. package/dist/_frontend/assets/chunk-HK4WITDD-D1KPKrkR.js.br +0 -0
  65. package/dist/_frontend/assets/chunk-HK4WITDD-D1KPKrkR.js.gz +0 -0
  66. package/dist/_frontend/assets/{chunk-HWOHXUGH-IwYpHY-Y.js → chunk-HWOHXUGH-D40fkGd6.js} +1 -1
  67. package/dist/_frontend/assets/chunk-HWOHXUGH-D40fkGd6.js.br +0 -0
  68. package/dist/_frontend/assets/chunk-HWOHXUGH-D40fkGd6.js.gz +0 -0
  69. package/dist/_frontend/assets/{chunk-LFIIKLPG-gJeIso6M.js → chunk-LFIIKLPG-BuBZiX6x.js} +1 -1
  70. package/dist/_frontend/assets/{chunk-OB3PAWPO-B6HZEUGp.js → chunk-OB3PAWPO-D2qyrrLN.js} +1 -1
  71. package/dist/_frontend/assets/chunk-OB3PAWPO-D2qyrrLN.js.br +0 -0
  72. package/dist/_frontend/assets/chunk-OB3PAWPO-D2qyrrLN.js.gz +0 -0
  73. package/dist/_frontend/assets/{chunk-OXW7TUTC-moy4-cpX.js → chunk-OXW7TUTC-BkKsXYNx.js} +1 -1
  74. package/dist/_frontend/assets/chunk-OXW7TUTC-BkKsXYNx.js.br +0 -0
  75. package/dist/_frontend/assets/chunk-OXW7TUTC-BkKsXYNx.js.gz +0 -0
  76. package/dist/_frontend/assets/{cssMode-BHHgzHoT.js → cssMode-DAJWek1h.js} +1 -1
  77. package/dist/_frontend/assets/cssMode-DAJWek1h.js.br +0 -0
  78. package/dist/_frontend/assets/cssMode-DAJWek1h.js.gz +0 -0
  79. package/dist/_frontend/assets/{freemarker2-tWNHna9o.js → freemarker2-C3VYFHZk.js} +1 -1
  80. package/dist/_frontend/assets/freemarker2-C3VYFHZk.js.br +0 -0
  81. package/dist/_frontend/assets/freemarker2-C3VYFHZk.js.gz +0 -0
  82. package/dist/_frontend/assets/{handlebars-YCt9F20a.js → handlebars-DrTOvLpk.js} +1 -1
  83. package/dist/_frontend/assets/handlebars-DrTOvLpk.js.br +0 -0
  84. package/dist/_frontend/assets/handlebars-DrTOvLpk.js.gz +0 -0
  85. package/dist/_frontend/assets/{html-Vo6CgJvZ.js → html-umn8rfcJ.js} +1 -1
  86. package/dist/_frontend/assets/html-umn8rfcJ.js.br +0 -0
  87. package/dist/_frontend/assets/html-umn8rfcJ.js.gz +0 -0
  88. package/dist/_frontend/assets/{htmlMode-BkGzSsp7.js → htmlMode-BwjJPvJ4.js} +1 -1
  89. package/dist/_frontend/assets/htmlMode-BwjJPvJ4.js.br +0 -0
  90. package/dist/_frontend/assets/htmlMode-BwjJPvJ4.js.gz +0 -0
  91. package/dist/_frontend/assets/{index-CdSOK6zy.js → index-D8_qdDll.js} +3 -3
  92. package/dist/_frontend/assets/index-D8_qdDll.js.br +0 -0
  93. package/dist/_frontend/assets/index-D8_qdDll.js.gz +0 -0
  94. package/dist/_frontend/assets/{index-DY4Vt5qS.js → index-DI-2ihen.js} +5 -5
  95. package/dist/_frontend/assets/index-DI-2ihen.js.br +0 -0
  96. package/dist/_frontend/assets/index-DI-2ihen.js.gz +0 -0
  97. package/dist/_frontend/assets/{javascript-hhlexC1d.js → javascript-B9RVFfNV.js} +1 -1
  98. package/dist/_frontend/assets/{jsonMode-CmaZrTmo.js → jsonMode-655bgWeR.js} +1 -1
  99. package/dist/_frontend/assets/jsonMode-655bgWeR.js.br +0 -0
  100. package/dist/_frontend/assets/jsonMode-655bgWeR.js.gz +0 -0
  101. package/dist/_frontend/assets/{liquid-B12Ow-wY.js → liquid-BPQ02tbR.js} +1 -1
  102. package/dist/_frontend/assets/liquid-BPQ02tbR.js.br +0 -0
  103. package/dist/_frontend/assets/liquid-BPQ02tbR.js.gz +0 -0
  104. package/dist/_frontend/assets/{lspLanguageFeatures-BAdtNMdy.js → lspLanguageFeatures-D7mmajvL.js} +1 -1
  105. package/dist/_frontend/assets/lspLanguageFeatures-D7mmajvL.js.br +0 -0
  106. package/dist/_frontend/assets/lspLanguageFeatures-D7mmajvL.js.gz +0 -0
  107. package/dist/_frontend/assets/{mdx-DnqsUsp9.js → mdx-Cpfj7mcA.js} +1 -1
  108. package/dist/_frontend/assets/mdx-Cpfj7mcA.js.br +0 -0
  109. package/dist/_frontend/assets/mdx-Cpfj7mcA.js.gz +0 -0
  110. package/dist/_frontend/assets/{python-zclzTpCV.js → python-6qMVDAkn.js} +1 -1
  111. package/dist/_frontend/assets/python-6qMVDAkn.js.br +0 -0
  112. package/dist/_frontend/assets/python-6qMVDAkn.js.gz +0 -0
  113. package/dist/_frontend/assets/{razor-DXCJzDhT.js → razor-CDVJhBJx.js} +1 -1
  114. package/dist/_frontend/assets/razor-CDVJhBJx.js.br +0 -0
  115. package/dist/_frontend/assets/razor-CDVJhBJx.js.gz +0 -0
  116. package/dist/_frontend/assets/{tsMode-ba0WSSwR.js → tsMode-BD95mnis.js} +1 -1
  117. package/dist/_frontend/assets/tsMode-BD95mnis.js.br +0 -0
  118. package/dist/_frontend/assets/tsMode-BD95mnis.js.gz +0 -0
  119. package/dist/_frontend/assets/{typescript-Cxw8coCj.js → typescript-Cl_WwffN.js} +1 -1
  120. package/dist/_frontend/assets/typescript-Cl_WwffN.js.br +0 -0
  121. package/dist/_frontend/assets/typescript-Cl_WwffN.js.gz +0 -0
  122. package/dist/_frontend/assets/{workers-RQlmz_Lv.js → workers-BkZ9mYyz.js} +1 -1
  123. package/dist/_frontend/assets/workers-BkZ9mYyz.js.br +4 -0
  124. package/dist/_frontend/assets/workers-BkZ9mYyz.js.gz +0 -0
  125. package/dist/_frontend/assets/{xml-Bb7-oq8W.js → xml-ZjkbYz_J.js} +1 -1
  126. package/dist/_frontend/assets/xml-ZjkbYz_J.js.br +0 -0
  127. package/dist/_frontend/assets/xml-ZjkbYz_J.js.gz +0 -0
  128. package/dist/_frontend/assets/{yaml-DqJHVcwV.js → yaml-Dt0lBr1i.js} +1 -1
  129. package/dist/_frontend/assets/yaml-Dt0lBr1i.js.br +0 -0
  130. package/dist/_frontend/assets/yaml-Dt0lBr1i.js.gz +0 -0
  131. package/dist/_frontend/index.html +1 -1
  132. package/package.json +3 -3
  133. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-CQZZoOBC.js.br +0 -0
  134. package/dist/_frontend/assets/AgentCodeSnippets-D2J3IH37-CQZZoOBC.js.gz +0 -0
  135. package/dist/_frontend/assets/AgentMetricChart-TCZEIIUV-5Rtf3TvY.js.br +0 -0
  136. package/dist/_frontend/assets/AgentMetricChart-TCZEIIUV-5Rtf3TvY.js.gz +0 -0
  137. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-D0HM5BSW.js.br +0 -0
  138. package/dist/_frontend/assets/AgentOverview-ZSZENAFZ-D0HM5BSW.js.gz +0 -0
  139. package/dist/_frontend/assets/AgentSessionEventTimeline-26TTGY3F-6FMUgy7r.js.br +0 -0
  140. package/dist/_frontend/assets/AgentSessionEventTimeline-26TTGY3F-6FMUgy7r.js.gz +0 -0
  141. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-CNDMPnla.js.br +0 -0
  142. package/dist/_frontend/assets/AgentSessionEventTimelineChart-SV6ZYNU2-CNDMPnla.js.gz +0 -0
  143. package/dist/_frontend/assets/AgentSessions-W2EDVBCS-lqR7dkcO.js.br +0 -0
  144. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-CMwC3bcI.js.br +0 -0
  145. package/dist/_frontend/assets/ConnectorSettings-E3KBW7HI-CMwC3bcI.js.gz +0 -0
  146. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-CF0zSf6U.js.br +0 -0
  147. package/dist/_frontend/assets/DrawerLayout-IGDKPIOC-CF0zSf6U.js.gz +0 -0
  148. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-Dt-L2w8t.js.br +0 -0
  149. package/dist/_frontend/assets/EnvironmentsPage-BUA2EGXE-Dt-L2w8t.js.gz +0 -0
  150. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-DL6nR8e0.js.br +0 -0
  151. package/dist/_frontend/assets/MemorySettings-Y6HNEYIW-DL6nR8e0.js.gz +0 -0
  152. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-YyI5xGN4.js.br +0 -0
  153. package/dist/_frontend/assets/ModelSettings-3RSWQ5WD-YyI5xGN4.js.gz +0 -0
  154. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-Bn_-fbRJ.js.br +0 -0
  155. package/dist/_frontend/assets/SandboxSettings-YIEGCYQO-Bn_-fbRJ.js.gz +0 -0
  156. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-DWmVgOrq.js.br +0 -0
  157. package/dist/_frontend/assets/SchedulesPage-OVDMYD6Q-DWmVgOrq.js.gz +0 -0
  158. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-CQudqTjg.js.br +0 -0
  159. package/dist/_frontend/assets/SettingsBuilder-6WNST3GI-CQudqTjg.js.gz +0 -0
  160. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-BOFQkqAR.js.br +0 -0
  161. package/dist/_frontend/assets/ShellRouteSync-4T763MWC-BOFQkqAR.js.gz +0 -0
  162. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-CFjD1Kmo.js.br +0 -0
  163. package/dist/_frontend/assets/SidebarLayout-YWA6PPZM-CFjD1Kmo.js.gz +0 -0
  164. package/dist/_frontend/assets/SkillSettings-XLK6REIA-CJVGKalf.js.br +0 -0
  165. package/dist/_frontend/assets/SkillSettings-XLK6REIA-CJVGKalf.js.gz +0 -0
  166. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-Ccfvu3fp.js.br +0 -0
  167. package/dist/_frontend/assets/WebSearchSettings-PKYKXD26-Ccfvu3fp.js.gz +0 -0
  168. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-CW9j2zi5.js.br +0 -0
  169. package/dist/_frontend/assets/WidgetLayout-HQZFWVZ2-CW9j2zi5.js.gz +0 -0
  170. package/dist/_frontend/assets/chunk-HED32BFK-CHoNWtNi.js.br +0 -0
  171. package/dist/_frontend/assets/chunk-HED32BFK-CHoNWtNi.js.gz +0 -0
  172. package/dist/_frontend/assets/chunk-HK4WITDD-Dk6A8b9_.js.br +0 -0
  173. package/dist/_frontend/assets/chunk-HK4WITDD-Dk6A8b9_.js.gz +0 -0
  174. package/dist/_frontend/assets/chunk-HWOHXUGH-IwYpHY-Y.js.br +0 -0
  175. package/dist/_frontend/assets/chunk-HWOHXUGH-IwYpHY-Y.js.gz +0 -0
  176. package/dist/_frontend/assets/chunk-OB3PAWPO-B6HZEUGp.js.br +0 -0
  177. package/dist/_frontend/assets/chunk-OB3PAWPO-B6HZEUGp.js.gz +0 -0
  178. package/dist/_frontend/assets/chunk-OXW7TUTC-moy4-cpX.js.br +0 -0
  179. package/dist/_frontend/assets/chunk-OXW7TUTC-moy4-cpX.js.gz +0 -0
  180. package/dist/_frontend/assets/cssMode-BHHgzHoT.js.br +0 -0
  181. package/dist/_frontend/assets/cssMode-BHHgzHoT.js.gz +0 -0
  182. package/dist/_frontend/assets/freemarker2-tWNHna9o.js.br +0 -0
  183. package/dist/_frontend/assets/freemarker2-tWNHna9o.js.gz +0 -0
  184. package/dist/_frontend/assets/handlebars-YCt9F20a.js.br +0 -0
  185. package/dist/_frontend/assets/handlebars-YCt9F20a.js.gz +0 -0
  186. package/dist/_frontend/assets/html-Vo6CgJvZ.js.br +0 -0
  187. package/dist/_frontend/assets/html-Vo6CgJvZ.js.gz +0 -0
  188. package/dist/_frontend/assets/htmlMode-BkGzSsp7.js.br +0 -0
  189. package/dist/_frontend/assets/htmlMode-BkGzSsp7.js.gz +0 -0
  190. package/dist/_frontend/assets/index-CdSOK6zy.js.br +0 -0
  191. package/dist/_frontend/assets/index-CdSOK6zy.js.gz +0 -0
  192. package/dist/_frontend/assets/index-DY4Vt5qS.js.br +0 -0
  193. package/dist/_frontend/assets/index-DY4Vt5qS.js.gz +0 -0
  194. package/dist/_frontend/assets/jsonMode-CmaZrTmo.js.br +0 -0
  195. package/dist/_frontend/assets/jsonMode-CmaZrTmo.js.gz +0 -0
  196. package/dist/_frontend/assets/liquid-B12Ow-wY.js.br +0 -0
  197. package/dist/_frontend/assets/liquid-B12Ow-wY.js.gz +0 -0
  198. package/dist/_frontend/assets/lspLanguageFeatures-BAdtNMdy.js.br +0 -0
  199. package/dist/_frontend/assets/lspLanguageFeatures-BAdtNMdy.js.gz +0 -0
  200. package/dist/_frontend/assets/mdx-DnqsUsp9.js.br +0 -0
  201. package/dist/_frontend/assets/mdx-DnqsUsp9.js.gz +0 -0
  202. package/dist/_frontend/assets/python-zclzTpCV.js.br +0 -0
  203. package/dist/_frontend/assets/python-zclzTpCV.js.gz +0 -0
  204. package/dist/_frontend/assets/razor-DXCJzDhT.js.br +0 -0
  205. package/dist/_frontend/assets/razor-DXCJzDhT.js.gz +0 -0
  206. package/dist/_frontend/assets/tsMode-ba0WSSwR.js.br +0 -0
  207. package/dist/_frontend/assets/tsMode-ba0WSSwR.js.gz +0 -0
  208. package/dist/_frontend/assets/typescript-Cxw8coCj.js.br +0 -0
  209. package/dist/_frontend/assets/typescript-Cxw8coCj.js.gz +0 -0
  210. package/dist/_frontend/assets/workers-RQlmz_Lv.js.br +0 -0
  211. package/dist/_frontend/assets/workers-RQlmz_Lv.js.gz +0 -0
  212. package/dist/_frontend/assets/xml-Bb7-oq8W.js.br +0 -0
  213. package/dist/_frontend/assets/xml-Bb7-oq8W.js.gz +0 -0
  214. package/dist/_frontend/assets/yaml-DqJHVcwV.js.br +0 -0
  215. package/dist/_frontend/assets/yaml-DqJHVcwV.js.gz +0 -0
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CdSOK6zy.js","./index-CX3ij07K.css","./AgentSessions-W2EDVBCS-lqR7dkcO.js","./chunk-HK4WITDD-Dk6A8b9_.js","./SchedulesPage-OVDMYD6Q-DWmVgOrq.js","./chunk-HWOHXUGH-IwYpHY-Y.js","./EnvironmentsPage-BUA2EGXE-Dt-L2w8t.js","./chunk-LFIIKLPG-gJeIso6M.js","./SidebarLayout-YWA6PPZM-CFjD1Kmo.js","./chunk-OXW7TUTC-moy4-cpX.js","./DrawerLayout-IGDKPIOC-CF0zSf6U.js","./DockLayout-OYD7YJSD-CqCN5TbW.js","./chunk-HED32BFK-CHoNWtNi.js","./WidgetLayout-HQZFWVZ2-CW9j2zi5.js","./ShellRouteSync-4T763MWC-BOFQkqAR.js","./chunk-OB3PAWPO-B6HZEUGp.js","./TrueForgeUIWithRouter-LFJ4E5VL-o7uC8O0Z.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-D8_qdDll.js","./index-CX3ij07K.css","./AgentSessions-W2EDVBCS-DJ_2ids3.js","./chunk-HK4WITDD-D1KPKrkR.js","./SchedulesPage-OVDMYD6Q-O2hNR1RH.js","./chunk-HWOHXUGH-D40fkGd6.js","./EnvironmentsPage-BUA2EGXE-hn2BUGZI.js","./chunk-LFIIKLPG-BuBZiX6x.js","./SidebarLayout-YWA6PPZM-DrVGRycR.js","./chunk-OXW7TUTC-BkKsXYNx.js","./DrawerLayout-IGDKPIOC-B-eU-MHF.js","./DockLayout-OYD7YJSD-BsU6EkTC.js","./chunk-HED32BFK-BkmeeYL6.js","./WidgetLayout-HQZFWVZ2-msxsQ6JO.js","./ShellRouteSync-4T763MWC-CPxzGJDG.js","./chunk-OB3PAWPO-D2qyrrLN.js","./TrueForgeUIWithRouter-LFJ4E5VL-BNRfP9iQ.js"])))=>i.map(i=>d[i]);
2
2
  var wHe=Object.defineProperty;var gae=e=>{throw TypeError(e)};var _He=(e,t,n)=>t in e?wHe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Q=(e,t,n)=>_He(e,typeof t!="symbol"?t+"":t,n),mae=(e,t,n)=>t.has(e)||gae("Cannot "+n);var ti=(e,t,n)=>(mae(e,t,"read from private field"),n?n.call(e):t.get(e)),bae=(e,t,n)=>t.has(e)?gae("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gj=(e,t,n,r)=>(mae(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function SHe(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const a=Object.getOwnPropertyDescriptor(r,o);a&&Object.defineProperty(e,o,a.get?a:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();self.MonacoEnvironment=(function(e){return{globalAPI:!1,getWorkerUrl:function(t,n){var r=e[n];if(/^((http:)|(https:)|(file:)|(\/\/))/.test(r)){var o=String(window.location),a=o.substr(0,o.length-window.location.hash.length-window.location.search.length-window.location.pathname.length);if(r.substring(0,a.length)!==a){var i="/*"+n+'*/importScripts("'+r+'");',s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}}return r}}})({editorWorkerService:"./monacoeditorwork/editor.worker.bundle.js",css:"./monacoeditorwork/css.worker.bundle.js",html:"./monacoeditorwork/html.worker.bundle.js",json:"./monacoeditorwork/json.worker.bundle.js",typescript:"./monacoeditorwork/ts.worker.bundle.js",javascript:"./monacoeditorwork/ts.worker.bundle.js",less:"./monacoeditorwork/css.worker.bundle.js",scss:"./monacoeditorwork/css.worker.bundle.js",handlebars:"./monacoeditorwork/html.worker.bundle.js",razor:"./monacoeditorwork/html.worker.bundle.js"});var DT=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mj={exports:{}},fw={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -1090,7 +1090,7 @@ ${l.children}`})})]})})]})}),oje=({language:e,codeString:t,theme:n})=>{const[r,o
1090
1090
  `))}function l(g,b,v,y){const w=v.enter("tableCell"),S=v.enter("phrasing"),E=v.containerPhrasing(g,{...y,before:a,after:a});return S(),w(),E}function c(g,b){return AZt(g,{align:b,alignDelimiters:r,padding:n,stringLength:o})}function u(g,b,v){const y=g.children;let w=-1;const S=[],E=b.enter("table");for(;++w<y.length;)S[w]=d(y[w],b,v);return E(),S}function d(g,b,v){const y=g.children;let w=-1;const S=[],E=b.enter("tableRow");for(;++w<y.length;)S[w]=l(y[w],g,b,v);return E(),S}function f(g,b,v){let y=ALe.inlineCode(g,b,v);return v.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function hXt(){return{exit:{taskListCheckValueChecked:U0e,taskListCheckValueUnchecked:U0e,paragraph:mXt}}}function gXt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:bXt}}}function U0e(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function mXt(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let a=-1,i;for(;++a<o.length;){const s=o[a];if(s.type==="paragraph"){i=s;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function bXt(e,t,n,r){const o=e.children[0],a=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(i);let l=ALe.listItem(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+i}}function vXt(){return[XYt(),bZt(),wZt(),sXt(),hXt()]}function yXt(e){return{extensions:[qYt(),vZt(e),_Zt(),fXt(e),gXt()]}}const xXt={tokenize:TXt,partial:!0},CLe={tokenize:AXt,partial:!0},RLe={tokenize:CXt,partial:!0},ILe={tokenize:RXt,partial:!0},wXt={tokenize:IXt,partial:!0},NLe={name:"wwwAutolink",tokenize:kXt,previous:OLe},MLe={name:"protocolAutolink",tokenize:EXt,previous:PLe},kp={name:"emailAutolink",tokenize:SXt,previous:jLe},Hu={};function _Xt(){return{text:Hu}}let tg=48;for(;tg<123;)Hu[tg]=kp,tg++,tg===58?tg=65:tg===91&&(tg=97);Hu[43]=kp;Hu[45]=kp;Hu[46]=kp;Hu[95]=kp;Hu[72]=[kp,MLe];Hu[104]=[kp,MLe];Hu[87]=[kp,NLe];Hu[119]=[kp,NLe];function SXt(e,t,n){const r=this;let o,a;return i;function i(d){return!W7(d)||!jLe.call(r,r.previous)||RJ(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return W7(d)?(e.consume(d),s):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(wXt,u,c)(d):d===45||d===95||li(d)?(a=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),o=!0,l}function u(d){return a&&o&&Ni(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function kXt(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!OLe.call(r,r.previous)||RJ(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(xXt,e.attempt(CLe,e.attempt(RLe,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function EXt(e,t,n){const r=this;let o="",a=!1;return i;function i(d){return(d===72||d===104)&&PLe.call(r,r.previous)&&!RJ(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(Ni(d)&&o.length<5)return o+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=o.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),a?c:(a=!0,l)):n(d)}function c(d){return d===null||_R(d)||Qr(d)||lm(d)||MM(d)?n(d):e.attempt(CLe,e.attempt(RLe,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function TXt(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function AXt(e,t,n){let r,o,a;return i;function i(c){return c===46||c===95?e.check(ILe,l,s)(c):c===null||Qr(c)||lm(c)||c!==45&&MM(c)?l(c):(a=!0,e.consume(c),i)}function s(c){return c===95?r=!0:(o=r,r=void 0),e.consume(c),i}function l(c){return o||r||!a?n(c):t(c)}}function CXt(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(ILe,t,a)(i):i===null||Qr(i)||lm(i)?t(i):(e.consume(i),o)}function a(i){return i===41&&r++,e.consume(i),o}}function RXt(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),o):s===60||s===null||Qr(s)||lm(s)?t(s):n(s)}function o(s){return s===null||s===40||s===91||Qr(s)||lm(s)?t(s):r(s)}function a(s){return Ni(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),r):Ni(s)?(e.consume(s),i):n(s)}}function IXt(e,t,n){return r;function r(a){return e.consume(a),o}function o(a){return li(a)?n(a):t(a)}}function OLe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Qr(e)}function PLe(e){return!Ni(e)}function jLe(e){return!(e===47||W7(e))}function W7(e){return e===43||e===45||e===46||e===95||li(e)}function RJ(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const NXt={tokenize:$Xt,partial:!0};function MXt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:DXt,continuation:{tokenize:LXt},exit:zXt}},text:{91:{name:"gfmFootnoteCall",tokenize:jXt},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:OXt,resolveTo:PXt}}}}function OXt(e,t,n){const r=this;let o=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const l=r.events[o][1];if(l.type==="labelImage"){i=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!i||!i._balanced)return n(l);const c=fc(r.sliceSerialize({start:i.end,end:r.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function PXt(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function jXt(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,i;return s;function s(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(a>999||d===93&&!i||d===null||d===91||Qr(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return o.includes(fc(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Qr(d)||(i=!0),a++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),a++,c):c(d)}}function DXt(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,i=0,s;return l;function l(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(b)}function u(b){if(i>999||b===93&&!s||b===null||b===91||Qr(b))return n(b);if(b===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return a=fc(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Qr(b)||(s=!0),i++,e.consume(b),b===92?d:u}function d(b){return b===91||b===92||b===93?(e.consume(b),i++,u):u(b)}function f(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),o.includes(a)||o.push(a),ic(e,g,"gfmFootnoteDefinitionWhitespace")):n(b)}function g(b){return t(b)}}function LXt(e,t,n){return e.check(Ek,t,e.attempt(NXt,t,n))}function zXt(e){e.exit("gfmFootnoteDefinition")}function $Xt(e,t,n){const r=this;return ic(e,o,"gfmFootnoteDefinitionIndent",5);function o(a){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function UXt(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,s){let l=-1;for(;++l<i.length;)if(i[l][0]==="enter"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._close){let c=l;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[l][1].end.offset-i[l][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[l][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},d={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},f=[["enter",u,s],["enter",i[c][1],s],["exit",i[c][1],s],["enter",d,s]],g=s.parser.constructs.insideSpan.null;g&&Us(f,f.length,0,OM(g,i.slice(c+1,l),s)),Us(f,f.length,0,[["exit",d,s],["enter",i[l][1],s],["exit",i[l][1],s],["exit",u,s]]),Us(i,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<i.length;)i[l][1].type==="strikethroughSequenceTemporary"&&(i[l][1].type="data");return i}function a(i,s,l){const c=this.previous,u=this.events;let d=0;return f;function f(b){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(b):(i.enter("strikethroughSequenceTemporary"),g(b))}function g(b){const v=Ay(c);if(b===126)return d>1?l(b):(i.consume(b),d++,g);if(d<2&&!n)return l(b);const y=i.exit("strikethroughSequenceTemporary"),w=Ay(b);return y._open=!w||w===2&&!!v,y._close=!v||v===2&&!!w,s(b)}}}class FXt{constructor(){this.map=[]}add(t,n,r){BXt(this,t,n,r)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const a of o)t.push(a);o=r.pop()}this.map.length=0}}function BXt(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function HXt(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function VXt(){return{flow:{null:{name:"table",tokenize:GXt,resolveAll:WXt}}}}function GXt(e,t,n){const r=this;let o=0,a=0,i;return s;function s(P){let j=r.events.length-1;for(;j>-1;){const L=r.events[j][1].type;if(L==="lineEnding"||L==="linePrefix")j--;else break}const D=j>-1?r.events[j][1].type:null,z=D==="tableHead"||D==="tableRow"?C:l;return z===C&&r.parser.lazy[r.now().line]?n(P):z(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(i=!0,a+=1),u(P)}function u(P){return P===null?n(P):ln(P)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),g):n(P):$n(P)?ic(e,u,"whitespace")(P):(a+=1,i&&(i=!1,o+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||Qr(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function g(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),i=!1,$n(P)?ic(e,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):b(P))}function b(P){return P===45||P===58?y(P):P===124?(i=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):T(P)}function v(P){return $n(P)?ic(e,y,"whitespace")(P):y(P)}function y(P){return P===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),w):P===45?(a+=1,w(P)):P===null||ln(P)?A(P):T(P)}function w(P){return P===45?(e.enter("tableDelimiterFiller"),S(P)):T(P)}function S(P){return P===45?(e.consume(P),S):P===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(P))}function E(P){return $n(P)?ic(e,A,"whitespace")(P):A(P)}function A(P){return P===124?b(P):P===null||ln(P)?!i||o!==a?T(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):T(P)}function T(P){return n(P)}function C(P){return e.enter("tableRow"),R(P)}function R(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),R):P===null||ln(P)?(e.exit("tableRow"),t(P)):$n(P)?ic(e,R,"whitespace")(P):(e.enter("data"),N(P))}function N(P){return P===null||P===124||Qr(P)?(e.exit("data"),R(P)):(e.consume(P),P===92?O:N)}function O(P){return P===92||P===124?(e.consume(P),N):N(P)}}function WXt(e,t){let n=-1,r=!0,o=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,l=0,c,u,d;const f=new FXt;for(;++n<e.length;){const g=e[n],b=g[1];g[0]==="enter"?b.type==="tableHead"?(s=!1,l!==0&&(F0e(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",c,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",u,t]])),o=b.type==="tableDelimiterRow"?2:u?3:1):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],d=qA(f,t,a,o,void 0,d),a=[0,0,0,0]),i[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(i[0]=i[1],d=qA(f,t,a,o,void 0,d)),a=i,i=[a[1],n,0,0])):b.type==="tableHead"?(s=!0,l=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(l=n,a[1]!==0?(i[0]=i[1],d=qA(f,t,a,o,n,d)):i[1]!==0&&(d=qA(f,t,i,o,n,d)),o=0):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(i[3]=n)}for(l!==0&&F0e(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=HXt(t.events,n))}return e}function qA(e,t,n,r,o,a){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Tv(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=Tv(t.events,n[1]);if(a={type:i,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const c=Tv(t.events,n[2]),u=Tv(t.events,n[3]),d={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],g=t.events[n[3]];if(f[1].end=Object.assign({},g[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,v=n[3]-n[2]-1;e.add(b,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return o!==void 0&&(a.end=Object.assign({},Tv(t.events,o)),e.add(o,0,[["exit",a,t]]),a=void 0),a}function F0e(e,t,n,r,o){const a=[],i=Tv(t.events,n);o&&(o.end=Object.assign({},i),a.push(["exit",o,t])),r.end=Object.assign({},i),a.push(["exit",r,t]),e.add(n+1,0,a)}function Tv(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const KXt={name:"tasklistCheck",tokenize:ZXt};function YXt(){return{text:{91:KXt}}}function ZXt(e,t,n){const r=this;return o;function o(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),a)}function a(l){return Qr(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),i):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),i):n(l)}function i(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(l)}function s(l){return ln(l)?t(l):$n(l)?e.check({tokenize:XXt},t,n)(l):n(l)}}function XXt(e,t,n){return ic(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function qXt(e){return XNe([_Xt(),MXt(),UXt(e),VXt(),YXt()])}const QXt={};function JXt(e){const t=this,n=e||QXt,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(qXt(n)),a.push(vXt()),i.push(yXt(n))}function r$(e,t,n){return e+(t-e)*n}function DLe(e){return e-Math.floor(e)}function o$(e,t){const n=Math.floor(e),r=Math.floor(t);let o=e-n,a=t-r;o=o*o*(3-2*o),a=a*a*(3-2*a);const i=wl(n,r),s=wl(n+1,r),l=wl(n,r+1),c=wl(n+1,r+1);return i+(s-i)*o+(l-i)*a+(i-s-l+c)*o*a}function wl(e,t){const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)}function IJ(e,t){const n=Math.PI*(3-Math.sqrt(5)),r=1-2*(e+.5)/t,o=Math.sqrt(1-r*r),a=e*n;return[o*Math.cos(a),r,o*Math.sin(a)]}function eqt(e,t){return Math.atan2(Math.sin(e-t),Math.cos(e-t))}function Ym(e,t,n,r,o){const a=Math.sin(t),i=Math.cos(t),s=Math.sin(e),l=Math.cos(e);return(c,u,d)=>{const f=c*l+d*s,g=-c*s+d*l,b=u*i-g*a,v=u*a+g*i;return[n+f*o,r-b*o,v]}}function LLe(e,t,n,r){if(!r){const a=Math.round((n?1-e:e)*255);return`rgba(${a},${a},${a},${t})`}const o=a=>Math.round(n?a*(1-e):a+(255-a)*e);return`rgba(${o(r.r)},${o(r.g)},${o(r.b)},${t})`}function tqt(e,t,n,r=.3,o){for(const a of t){const i=a.a??1,s=Math.min(1,Math.max(0,a.white));e.fillStyle=LLe(s,i,n,o),e.beginPath(),e.arc(a.x,a.y,a.r,0,Math.PI*2),e.fill()}}function nqt(e,t,n,r){for(const o of t){const a=o.a??1,i=Math.min(1,Math.max(0,o.white));e.strokeStyle=LLe(i,a,n,r),e.lineWidth=o.w,e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.stroke()}}function xh(e,t,n=.3){const r=[];for(const o of e)(o.a??1)<.02||(o.r=Math.max(n,o.r),r.push(o));return r.sort((o,a)=>o.z-a.z),{dots:r,lines:t.filter(o=>(o.a??1)>=.02)}}function zLe(e,t,n,r){t.lines.length&&nqt(e,t.lines,n,r),tqt(e,t.dots,n,.3,r)}function Zm(e,t){return(e/300)**t}const rqt=[["latRings","lonDensity"],["rings","lonDensity"],["lanes","segs"]],oqt=["orbitN","ghostN","nodeN","strandN","signals"],aqt=["iconD"],iqt=["rBase","rDepth","rActive","rDot","ghostR","partR","partRDepth","nodeR","nodeRDepth"];function $Le(e,t){const n={...e},r=new Set,o=Math.sqrt(t);for(const[a,i]of rqt){const s=n[a],l=n[i];s!=null&&l!=null&&!r.has(a)&&!r.has(i)&&(n[a]=Math.max(2,Math.round(s*o)),n[i]=Math.max(2,Math.round(l*o)),r.add(a),r.add(i))}for(const a of oqt){const i=n[a];i!=null&&i!==0&&!r.has(a)&&(n[a]=Math.max(1,Math.round(i*t)))}for(const a of aqt){const i=n[a];i!=null&&(n[a]=Math.max(.02,i*t))}return n}function ULe(e,t){const n={...e};for(const r of iqt){const o=n[r];o!=null&&(n[r]=o*t)}return n.rSizeMul=(n.rSizeMul??1)*t,n}const sqt={globe:{latRings:17,lonDensity:44,rBase:.6,rDepth:1.7,rBoost:1,inkFar:.62,inkSpan:.54,rsPow:.6,rMin:.3},orbits:{orbitN:12,ghostN:40,ghostR:.9,ghostA:.5,particles:3,partR:1.2,partRDepth:1.6,rsPow:.6,rMin:.3},rubik:{latRings:15,lonDensity:40,moveCount:14,rBase:.6,rDepth:1.7,rActive:.3,inkFar:.62,inkSpan:.54,rsPow:.6,rMin:.3},wave:{rings:15,lonDensity:40,rBase:.6,rDepth:1.7,rsPow:.6,rMin:.3},web:{nodeN:30,thr:.72,signals:5,nodeR:1.4,nodeRDepth:1.8,lineW:.8,rsPow:.6,rMin:.3},braid:{strandN:52,turns:3,ghostN:150,rBase:1.2,rDepth:1.8,rsPow:.6,rMin:.3},ribbon:{lanes:5,segs:88,ghostN:150,rBase:1.1,rDepth:1.7,rsPow:.6,rMin:.3},ring:{lanes:5,segs:88,ghostN:0,faceOn:1,rBase:1.1,rDepth:1.7,rsPow:.6,rMin:.3},morph:{rDot:.021,iconD:1,rMin:.25}},lqt=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.76,i=Ym(t*.4,.3,r,o,1),s=Zm(e,n.rsPow??.6),l=[],c=n.ghostN??150;for(let f=0;f<c;f++){const g=IJ(f,c),[b,v,y]=i(g[0]*a,g[1]*a,g[2]*a),w=(y/a+1)/2;l.push({x:b,y:v,z:y,r:.8*s,white:.78,a:.1+.22*w})}const u=n.strandN??52,d=n.turns??3;for(let f=0;f<3;f++){const g=f/3*2*Math.PI;for(let b=0;b<u;b++){const v=(DLe(b/u+t*.045)*2-1)*.96,y=Math.sqrt(Math.max(0,1-v*v)),w=Math.min(1,(1-Math.abs(v))/.1),S=v*Math.PI*d+g,E=1+.075*Math.sin(v*Math.PI*d*2+g*2+t*.8),A=y*a*E,[T,C,R]=i(Math.cos(S)*A,v*a*E,Math.sin(S)*A),N=(R/a+1)/2;l.push({x:T,y:C,z:R,r:((n.rBase??1.2)+(n.rDepth??1.8)*N)*s,white:.55-.45*N,a:w*(.45+.55*N)})}}return xh(l,[],n.rMin)};function cqt(e,t,n,r){const o=2*t*n+r,a=e%o,i=new Array(t).fill(0);let s=-1;if(a<2*t*n){const l=Math.floor(a/n),c=(a-l*n)/n,d=1-(1-Math.min(1,c/.7))**3;if(l<t){for(let f=0;f<l;f++)i[f]=1;i[l]=d,s=l}else{const f=2*t-1-l;for(let g=0;g<f;g++)i[g]=1;i[f]=1-d,s=f}}return{amount:i,active:s}}function uqt(e,t,n){let[r,o,a]=e,i=!1;for(let s=0;s<t.length;s++){if(n.amount[s]<=0)continue;const l=t[s],c=l.axis===0?r:l.axis===1?o:a;if(c<l.lo||c>=l.hi)continue;s===n.active&&(i=!0);const u=l.ang*n.amount[s],d=Math.cos(u),f=Math.sin(u);if(l.axis===0){const g=o*d-a*f;a=o*f+a*d,o=g}else if(l.axis===1){const g=r*d+a*f;a=-r*f+a*d,r=g}else{const g=r*d-o*f;o=r*f+o*d,r=g}}return[r,o,a,i]}function dqt(e){const t=[];for(let n=0;n<e;n++){const r=Math.min(2,Math.floor(wl(n,2.3)*3)),o=-1+.5*Math.min(3,Math.floor(wl(n,5.9)*4)),a=wl(n,7.7)<.5?1:-1;t.push({axis:r,lo:o,hi:o+.5,ang:a*Math.PI/2})}return t}const pqt=(e,t,n)=>{const o=e/2,a=e/2,i=e/2*.82,s=.4+.06*Math.sin(t*.35),l=Ym(t*.5,s,o,a,i),c=t*(.5+(1.7-.5)*(n.scanMul??1)),u=Zm(e,n.rsPow??.6),d=n.dimBase??1,f=[],g=n.latRings??17,b=n.lonDensity??44;for(let v=0;v<=g;v++){const y=-Math.PI/2+v/g*Math.PI,w=Math.cos(y),S=Math.sin(y),E=Math.max(1,Math.round(Math.abs(w)*b));for(let A=0;A<E;A++){const T=A/E*2*Math.PI,[C,R,N]=l(w*Math.cos(T),S,w*Math.sin(T)),O=(N+1)/2,P=eqt(T+t*.5,c),j=Math.exp(-(P*P)/.18)*Math.max(0,N);f.push({x:C,y:R,z:N,r:((n.rBase??.6)+(n.rDepth??1.7)*O+(n.rBoost??1)*j)*u,white:(n.inkFar??.62)-(n.inkSpan??.54)*O,a:d+(1-d)*Math.min(1,j)})}}return xh(f,[],n.rMin)},fqt=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.82,i=Ym(t*.55,.35+.1*Math.sin(t*.9),r,o,a),s=Zm(e,n.rsPow??.6),l=n.moveCount??14,c=dqt(l),u=cqt(t,l,.42,1.2),d=[],f=n.latRings??15,g=n.lonDensity??40;for(let b=0;b<=f;b++){const v=-Math.PI/2+b/f*Math.PI,y=Math.cos(v),w=Math.sin(v),S=Math.max(1,Math.round(Math.abs(y)*g));for(let E=0;E<S;E++){const A=E/S*2*Math.PI,[T,C,R,N]=uqt([y*Math.cos(A),w,y*Math.sin(A)],c,u),[O,P,j]=i(T,C,R),D=(j+1)/2;d.push({x:O,y:P,z:j,r:((n.rBase??.6)+(n.rDepth??1.7)*D+(N?n.rActive??.3:0))*s,white:(n.inkFar??.62)-(n.inkSpan??.54)*D-(N?.14:0)})}}return xh(d,[],n.rMin)},hqt=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.874,i=Ym(t*.18,.38,r,o,1),s=Zm(e,n.rsPow??.6),l=[],c=n.rings??15,u=n.lonDensity??40;for(let d=0;d<=c;d++){const f=-Math.PI/2+d/c*Math.PI,g=Math.cos(f),b=Math.sin(f),v=.62*Math.sin(t*2.1-d*.52)+.38*Math.sin(t*1.27+d*.83),y=a*(.88+.105*v),w=Math.max(1,Math.round(Math.abs(g)*u));for(let S=0;S<w;S++){const E=S/w*2*Math.PI,[A,T,C]=i(g*Math.cos(E)*y,b*y,g*Math.sin(E)*y),R=(C/a+1)/2,N=Math.max(0,v);l.push({x:A,y:T,z:C,r:((n.rBase??.6)+(n.rDepth??1.7)*R)*(1+.4*N)*s,white:.66-.56*R-.1*N})}}return xh(l,[],n.rMin)};function gqt(e){return e*e*(3-2*e)}function FLe(e){const t=e.length,n=[];let r=0;for(let o=0;o<t;o++){const a=e[o],i=e[(o+1)%t],s=Math.hypot(i[0]-a[0],i[1]-a[1]);n.push(s),r+=s}return o=>{let a=o*r,i=0;for(;a>n[i]&&i<t-1;)a-=n[i],i++;const s=e[i],l=e[(i+1)%t],c=n[i]?Math.min(1,a/n[i]):0;return[s[0]+(l[0]-s[0])*c,s[1]+(l[1]-s[1])*c]}}const mqt=e=>{const t=-Math.PI/2+e*2*Math.PI;return[Math.cos(t)*.24,Math.sin(t)*.24]},bqt=FLe([[0,-.26],[.24,.16],[-.24,.16]]),vqt=FLe([[0,-.2],[.2,-.2],[.2,.2],[-.2,.2],[-.2,-.2]]),a$=[mqt,bqt,vqt];function yqt(e){return Math.max(6,Math.round(34*e))}const K7=1.4,BLe=.9,QA=K7+BLe,xqt=(e,t,n)=>{const r=a$.length,o=t%(QA*r),a=n.shape!=null&&n.shape>=0&&n.shape<r?Math.floor(n.shape):-1,i=a>=0?a:Math.floor(o/QA),s=a>=0?t%QA:o-i*QA,l=a>=0?0:s>K7?gqt((s-K7)/BLe):0,c=n.spread??1,u=a$[i],d=a>=0?u:a$[(i+1)%r],f=160,g=[];for(let R=0;R<f;R++){const N=R/f,O=u(N),P=d(N);g.push([(O[0]+(P[0]-O[0])*l)*c,(O[1]+(P[1]-O[1])*l)*c])}const b=[];let v=0;for(let R=0;R<f;R++){const N=g[R],O=g[(R+1)%f],P=Math.hypot(O[0]-N[0],O[1]-N[1]);b.push(P),v+=P}const y=yqt(n.iconD??1),w=(n.rDot??.021)*1.35*c,S=1+.02*Math.sin(s*3.1),E=[],A=e/2;let T=0,C=0;for(let R=0;R<y;R++){const N=R/y*v;for(;C+b[T]<N&&T<f-1;)C+=b[T],T++;const O=g[T],P=g[(T+1)%f],j=b[T]?Math.min(1,(N-C)/b[T]):0,D=(O[0]+(P[0]-O[0])*j)*S,z=(O[1]+(P[1]-O[1])*j)*S;E.push({x:A+D*e,y:A+z*e,z:0,r:Math.max(.35,w*e),white:.1})}return xh(E,[],n.rMin)},wqt=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.82,i=Ym(t*.12,.3,r,o,1),s=Zm(e,n.rsPow??.6),l=[],c=n.orbitN??12,u=n.ghostN??40,d=n.particles??3;for(let f=0;f<c;f++){const g=wl(f,1.7),b=wl(f,5.2),v=wl(f,8.9),y=a*(.45+.52*g),w=g*2*Math.PI,S=Math.acos(2*b-1),E=Math.sin(S)*Math.cos(w),A=Math.cos(S),T=Math.sin(S)*Math.sin(w);let C=-A,R=E;const N=0,O=Math.max(1e-6,Math.sqrt(C*C+R*R));C/=O,R/=O;const P=A*N-T*R,j=T*C-E*N,D=E*R-A*C,z=(.25+.55*v)*(v>.5?1:-1);for(let L=0;L<u;L++){const $=L/u*2*Math.PI,[U,B,V]=i((C*Math.cos($)+P*Math.sin($))*y,(R*Math.cos($)+j*Math.sin($))*y,(N*Math.cos($)+D*Math.sin($))*y),G=(V/y+1)/2;l.push({x:U,y:B,z:V,r:(n.ghostR??.9)*s,white:.72,a:(n.ghostA??.5)*(.4+.6*G)})}for(let L=0;L<d;L++){const $=t*z+L/d*2*Math.PI+b*6,[U,B,V]=i((C*Math.cos($)+P*Math.sin($))*y,(R*Math.cos($)+j*Math.sin($))*y,(N*Math.cos($)+D*Math.sin($))*y),G=(V/y+1)/2;l.push({x:U,y:B,z:V,r:((n.partR??1.2)+(n.partRDepth??1.6)*G)*s,white:.3-.22*G})}}return xh(l,[],n.rMin)},B0e=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.78,i=n.spin??1,s=.3,l=Ym(t*.1*i,s,r,o,1),c=Zm(e,n.rsPow??.6),u=[],d=n.ghostN??150;for(let D=0;D<d;D++){const z=IJ(D,d),[L,$,U]=l(z[0]*a,z[1]*a,z[2]*a),B=(U/a+1)/2;u.push({x:L,y:$,z:U,r:.8*c,white:.78,a:.1+.22*B})}const f=t*.24*i,g=n.faceOn?-s:.55+.3*Math.sin(t*.18)*i,b=Math.cos(f),v=0,y=Math.sin(f),w=-y*Math.sin(g),S=Math.cos(g),E=b*Math.sin(g),A=v*E-y*S,T=y*w-b*E,C=b*S-v*w,R=.23*(n.wobMul??1),N=n.faceOn?a/(1+.85*R):a,O=n.lanes??5,P=n.segs??88,j=Math.max(1,Math.round(O*(n.bandMul??1)));for(let D=0;D<j;D++){const z=(D-(j-1)/2)*.075,L=Math.abs(D-(j-1)/2)/Math.max(1,(j-1)/2);for(let $=0;$<P;$++){const U=$/P*2*Math.PI,B=(.16*Math.sin(U*3-t*1.7+D*.22)+.07*Math.sin(U*5+t*1.1))*(n.wobMul??1),V=n.faceOn?1+B:1,G=n.faceOn?z:z+B,F=b*Math.cos(U)+w*Math.sin(U)+A*G,Z=v*Math.cos(U)+S*Math.sin(U)+T*G,J=y*Math.cos(U)+E*Math.sin(U)+C*G,W=Math.sqrt(F*F+Z*Z+J*J),Y=N*V,[q,ne,he]=l(F/W*Y,Z/W*Y,J/W*Y),se=(he/a+1)/2;u.push({x:q,y:ne,z:he,r:((n.rBase??1.1)+(n.rDepth??1.7)*se)*(1-.25*L)*c,white:.52-.44*se+.18*L,a:.4+.6*se})}}return xh(u,[],n.rMin)},_qt=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.8*(n.spread??1),i=Ym(t*.12,.32,r,o,a),s=Zm(e,n.rsPow??.6),l=n.nodeN??30,c=n.thr??.72,u=n.nodeR??1.4,d=n.nodeRDepth??1.8,f=[];for(let y=0;y<l;y++){const w=IJ(y,l),S=w[0]+.3*(o$(y*.31+9,t*.24)-.5)*2,E=w[1]+.3*(o$(y*.53+27,t*.21)-.5)*2,A=w[2]+.3*(o$(y*.77+55,t*.27)-.5)*2,T=Math.sqrt(S*S+E*E+A*A);f.push([S/T,E/T,A/T])}const g=[],b=[];for(let y=0;y<l;y++)for(let w=y+1;w<l;w++){const S=f[y][0]-f[w][0],E=f[y][1]-f[w][1],A=f[y][2]-f[w][2],T=Math.sqrt(S*S+E*E+A*A);if(T>=c)continue;const[C,R,N]=i(f[y][0],f[y][1],f[y][2]),[O,P,j]=i(f[w][0],f[w][1],f[w][2]),D=((N+j)/2+1)/2;g.push({x1:C,y1:R,x2:O,y2:P,white:.42,a:(1-T/c)*(.3+.55*D),w:Math.max(.6,(n.lineW??.8)*s)})}for(let y=0;y<l;y++){const[w,S,E]=i(f[y][0],f[y][1],f[y][2]),A=(E+1)/2,T=1+.25*Math.sin(t*1.4+y*2.7);b.push({x:w,y:S,z:E,r:(u+d*A)*T*s,white:.55-.45*A})}const v=n.signals??5;for(let y=0;y<v;y++){const w=Math.floor(t*.55+y*7.31),S=Math.floor(wl(w,y*3.1+1.7)*l),E=Math.floor(wl(w,y*5.7+4.2)*l);if(S===E)continue;const A=DLe(t*.55+y*7.31),T=r$(f[S][0],f[E][0],A),C=r$(f[S][1],f[E][1],A),R=r$(f[S][2],f[E][2],A),N=Math.max(1e-6,Math.sqrt(T*T+C*C+R*R)),[O,P,j]=i(T/N,C/N,R/N),D=(j+1)/2;b.push({x:O,y:P,z:j,r:(u*1.5+d*D)*s,white:.05,a:.5+.5*D})}return xh(b,g,n.rMin)},HLe={orbits:wqt,globe:pqt,rubik:fqt,wave:hqt,web:_qt,braid:lqt,ribbon:B0e,ring:B0e,morph:xqt};Object.fromEntries(Object.entries(HLe).map(([e,t])=>[e,(n,r,o,a,i)=>zLe(n,t(r,o,i),a)]));const Sqt={working:"orbits",searching:"globe",solving:"rubik",listening:"wave",connecting:"web",weaving:"braid",composing:"ribbon",breathing:"ring",shaping:"morph"},kqt={orbits:{64:{speed:1.885,count:1,size:1},32:{speed:2.9072,count:.4251,size:1.6849},20:{speed:3.9,count:.238,size:2.4}},globe:{64:{speed:2.015,count:.42,size:1.15,extra:{scanMul:4.08,dimBase:.45}},32:{speed:2.3803,count:.1839,size:1.4769,extra:{scanMul:4.2301,dimBase:.45}},20:{speed:2.665,count:.105,size:1.75,extra:{scanMul:4.335,dimBase:.45}}},rubik:{64:{speed:1.82,count:.35,size:1.05},32:{speed:1.8964,count:.1537,size:1.4951},20:{speed:1.95,count:.088,size:1.9}},wave:{64:{speed:4.388,count:.341,size:1},32:{speed:4.1512,count:.169,size:1.3232},20:{speed:3.998,count:.105,size:1.6}},web:{64:{speed:3.315,count:1.35,size:.95},32:{speed:5.0104,count:.4942,size:1.2571},20:{speed:6.63,count:.25,size:1.52}},braid:{64:{speed:1.625,count:.5,size:1},32:{speed:2.2234,count:.2056,size:1.2011},20:{speed:2.75,count:.1125,size:1.36}},ribbon:{64:{speed:2.34,count:.25,size:.85,extra:{spin:0,bandMul:3.9,wobMul:1}},32:{speed:2.7776,count:.0969,size:.9766,extra:{spin:0,bandMul:4.49,wobMul:1}},20:{speed:3.12,count:.051,size:1.073,extra:{spin:0,bandMul:4.94,wobMul:1}}},ring:{64:{speed:3.24,count:.25,size:.956,extra:{spin:0,bandMul:3.627,wobMul:.368}},32:{speed:3.5517,count:.0678,size:1.31,extra:{spin:0,bandMul:3.8265,wobMul:.4751}},20:{speed:3.78,count:.028,size:1.622,extra:{spin:0,bandMul:3.968,wobMul:.565}}},morph:{64:{speed:2.405,count:.702,size:.395,extra:{spread:1.45}},32:{speed:2.2057,count:.5937,size:.6916,extra:{spread:1.45}},20:{speed:2.08,count:.53,size:1.011,extra:{spread:1.45}}}},H0e=new Map;function Eqt(e,t){const n=`${e}-${t}`,r=H0e.get(n);if(r)return r;const o=Sqt[e],a=kqt[o][t];let i={...sqt[o]};a.count!==1&&(i=$Le(i,a.count)),a.size!==1&&(i=ULe(i,a.size)),a.extra&&(i={...i,...a.extra});const s={mode:o,speed:a.speed,opts:i};return H0e.set(n,s),s}function Tqt(e){let t=e;for(;t;){const n=t.getAttribute("data-theme");if(n==="dark")return!0;if(n==="light")return!1;if(t.classList.contains("dark"))return!0;if(t.classList.contains("light"))return!1;t=t.parentElement}return null}function Aqt(){return typeof matchMedia>"u"||matchMedia("(prefers-color-scheme: dark)").matches}function Cqt(e,t){const[n,r]=_.useState(!0);return _.useEffect(()=>{if(e==="dark"){r(!0);return}if(e==="light"){r(!1);return}const o=()=>{const l=Tqt(t.current);r(l??Aqt())};o();const a=typeof matchMedia<"u"?matchMedia("(prefers-color-scheme: dark)"):null,i=()=>o();a==null||a.addEventListener("change",i);let s=null;return typeof MutationObserver<"u"&&t.current&&(s=new MutationObserver(o),s.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"],subtree:!0})),()=>{a==null||a.removeEventListener("change",i),s==null||s.disconnect()}},[e,t]),n}function Rqt(){const[e,t]=_.useState(!1);return _.useEffect(()=>{if(typeof matchMedia>"u")return;const n=matchMedia("(prefers-reduced-motion: reduce)");t(n.matches);const r=o=>t(o.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const hl=Object.freeze({reach:160,strength:11,deform:19,taper:1.95,curve:2.8,falloff:24,smoothing:.3,handover:.6,squash:1.2,blur:1,fadeMs:180});let lc=null,mm=null,py=null,V0e=0,VLe=0,Q_=!1,Y7="",Z7=0;function Iqt(e){if(e===lc||(lc=e,mm=null,py=null,Q_=!1,Z7=0,VLe=typeof window<"u"&&window.devicePixelRatio||1,bm(),!e||typeof Image>"u"))return;const t=new Image;t.decoding="async",t.onload=()=>{lc===e&&(mm=t,x3())},t.src=e.src}const zv=new Set;let h0=!1,Ff=0,X7=0,Jl=Number.NaN,Tg=Number.NaN,q7=0,Q7=0,pf=0,As=null,e2=!0,J_=!1;function Nqt(e,t=!0){const n=t===!0?{}:t;n.sprite&&Iqt(n.sprite);const r={el:e,opts:{reach:Math.max(1,n.reach??hl.reach),strength:Math.max(0,Math.min(64,n.strength??hl.strength)),deform:Math.max(0,Math.min(32,n.deform??hl.deform)),taper:Math.max(1,Math.min(4,n.taper??hl.taper)),curve:Math.max(1,Math.min(4,n.curve??hl.curve)),falloff:Math.max(2,Math.min(200,n.falloff??hl.falloff)),smoothing:G0e(n.smoothing??hl.smoothing),handover:G0e(n.handover??hl.handover),squash:Math.max(0,Math.min(3,n.squash??hl.squash)),blur:Math.max(0,Math.min(24,n.blur??hl.blur)),fadeMs:Math.max(1,n.fadeMs??hl.fadeMs)}};return zv.add(r),Pqt(),x3(),()=>{zv.delete(r),As===r&&(As=null),zv.size===0&&queueMicrotask(()=>{zv.size===0&&jqt()})}}const G0e=e=>Math.max(0,Math.min(1,e)),t2=e=>e.opts,x_=e=>typeof window.matchMedia=="function"&&window.matchMedia(e).matches;function Mqt(){if(Q_)return Y7||"disabled by a fail-safe";if(!lc)return"no pointer sprite set";if(!mm)return"pointer sprite still loading";if(x_("(prefers-reduced-motion: reduce)"))return"prefers-reduced-motion is on";if(x_("(forced-colors: active)"))return"forced colours are active";if(!x_("(pointer: fine)")||!x_("(hover: hover)"))return"no fine pointer";if((window.devicePixelRatio||1)!==VLe)return"display scale changed since the sprite was set — reload";const e=window.visualViewport;return e&&Math.abs(e.scale-1)>.001?"page is zoomed":null}function Oqt(){return Mqt()===null}function Pqt(){h0||zv.size===0||typeof document>"u"||x_("(pointer: fine)")&&(h0=!0,document.addEventListener("pointermove",GLe,{passive:!0}),document.addEventListener("pointerleave",If),document.addEventListener("pointercancel",If),document.addEventListener("keydown",WLe,{passive:!0}),document.addEventListener("visibilitychange",If),window.addEventListener("blur",If))}function jqt(){h0&&(h0=!1,document.removeEventListener("pointermove",GLe),document.removeEventListener("pointerleave",If),document.removeEventListener("pointercancel",If),document.removeEventListener("keydown",WLe),document.removeEventListener("visibilitychange",If),window.removeEventListener("blur",If),Ff!==0&&(cancelAnimationFrame(Ff),Ff=0),As=null,pf=0,bm(),Su&&(Su.remove(),Su=null,Sd=null,JI=null),Pg&&(Pg.remove(),Pg=null))}function GLe(e){e2=e.pointerType==="mouse"||e.pointerType==="",J_=!1,NJ++,Jl=q7=e.clientX,Tg=Q7=e.clientY,VS&&(VS=!1,e1(),t1=0,n1=0,Ag=$v=Number.NaN),x3()}function WLe(){J_=!0,bm()}function If(){Jl=Tg=Number.NaN,x3()}function x3(){!h0||Ff!==0||(X7=performance.now(),Ff=requestAnimationFrame(tB))}let Su=null,Sd=null,JI=null,g0=!1;const Kg="thinking-orb-gravity-hide";let Pg=null,HS=!1;const W0e=new WeakMap;let NJ=0,MJ=-1,J7=0,KLe=-1;function Dqt(){if(Su)return!0;const e=document.createElement("div");e.className="thinking-orb-gravity-cursor",e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;left:0;top:0;pointer-events:none;z-index:2147483001;will-change:transform;display:none";const t=document.createElement("canvas");t.style.display="block",e.appendChild(t),document.body.appendChild(e);const n=t.getContext("2d");return n?(Su=e,Sd=t,JI=n,eB=0,!0):(e.remove(),!1)}function Lqt(){Pg||(Pg=document.createElement("style"),Pg.textContent=`html.${Kg}, html.${Kg} * { cursor: none !important; }`,document.head.appendChild(Pg))}function zqt(e){const t=W0e.get(e);if(t)return t;const n=document.documentElement,r=n.classList.contains(Kg);r&&n.classList.remove(Kg);const o=getComputedStyle(e).cursor;return r&&n.classList.add(Kg),W0e.set(e,o),o}function K0e(e,t){const n=document.elementFromPoint(e,t);if(!n)return!1;const r=zqt(n);return r!=="auto"&&r!=="default"?(OJ(),!1):(HS||(Lqt(),document.documentElement.classList.add(Kg),HS=!0,MJ=NJ,KLe=J7),!0)}function OJ(){HS&&(document.documentElement.classList.remove(Kg),HS=!1,MJ=-1)}function e1(){Su&&g0&&(Su.style.display="none",g0=!1)}const $qt=500;let Y0e=Number.NEGATIVE_INFINITY,VS=!1;function bm(){VS=!1,OJ(),e1(),t1=0,n1=0,Ag=$v=Number.NaN}const jg={cx:0,cy:0,r:0};let t1=0,n1=0,Ag=Number.NaN,$v=Number.NaN;const ng=48,Z0e=10;let av=null,i$=null,rg=null,og=null,Uv=null,eB=0,X0e=0,q0e=0;function Uqt(e){if(!mm||!lc)return null;const t=document.createElement("canvas");t.width=Math.ceil(lc.width*e),t.height=Math.ceil(lc.height*e);const n=t.getContext("2d",{willReadFrequently:!0});return n?(n.scale(e,e),n.drawImage(mm,0,0,lc.width,lc.height),n.getImageData(0,0,t.width,t.height)):null}function Fqt(e,t,n,r,o,a,i){if(!py||!Uv)return;const s=Uv.width,l=Uv.height,c=py,u=c.width,d=c.height,f=c.data,g=Uv.data;g.fill(0);const b=Math.max(1,Math.hypot(u,d)),v=a-r,y=i-o,w=Math.hypot(v,y)||1,S=v/w,E=y/w,A=Math.max(0,Math.floor(n+Math.min(0,e*S)-3)),T=Math.min(s,Math.ceil(n+u+Math.max(0,e*S)+3)),C=Math.max(0,Math.floor(n+Math.min(0,e*E)-3)),R=Math.min(l,Math.ceil(n+d+Math.max(0,e*E)+3));for(let N=C;N<R;N++)for(let O=A;O<T;O++){const P=(N*s+O)*4;let j=O-n,D=N-n;if(e>.01){let Z=O,J=N,W=0,Y=0,q=0,ne=1;for(let ie=0;ie<7;ie++){const ue=Math.hypot(Z-r,J-o)/b;W=e*Math.pow(Math.min(1,ue),t),Y=a-Z,q=i-J,ne=Math.hypot(Y,q)||1,Z+=(O-W*Y/ne-Z)*.5,J+=(N-W*q/ne-J)*.5}const he=Z+W*Y/ne-O,se=J+W*q/ne-N;if(he*he+se*se>2.25){g[P]=g[P+1]=g[P+2]=g[P+3]=0;continue}j=Z-n,D=J-n}const z=Math.floor(j),L=Math.floor(D);if(z<-1||L<-1||z>=u||L>=d){g[P]=g[P+1]=g[P+2]=g[P+3]=0;continue}const $=j-z,U=D-L;let B=0,V=0,G=0,F=0;for(let Z=0;Z<4;Z++){const J=z+(Z&1),W=L+(Z>>1);if(J<0||W<0||J>=u||W>=d)continue;const Y=(Z&1?$:1-$)*(Z>>1?U:1-U),q=(W*u+J)*4,ne=Y*f[q+3];B+=f[q]*ne,V+=f[q+1]*ne,G+=f[q+2]*ne,F+=ne}F>0?(g[P]=B/F,g[P+1]=V/F,g[P+2]=G/F,g[P+3]=F):g[P]=g[P+1]=g[P+2]=g[P+3]=0}}function Q0e(e,t,n){if(!JI||!Sd||!Su||!lc||!mm)return;const r=lc,o=t2(e),a=Math.min(3,window.devicePixelRatio||1);if(av||(av=document.createElement("canvas"),i$=av.getContext("2d")),rg||(rg=document.createElement("canvas"),og=rg.getContext("2d")),!i$||!og||((!py||V0e!==a)&&(py=Uqt(a),V0e=a),!py))return;if(a!==eB||r.width!==X0e||r.height!==q0e){eB=a,X0e=r.width,q0e=r.height;const U=Math.ceil((r.width+2*ng)*a),B=Math.ceil((r.height+2*ng)*a);Sd.width=av.width=rg.width=U,Sd.height=av.height=rg.height=B,Sd.style.width=`${r.width+2*ng}px`,Sd.style.height=`${r.height+2*ng}px`,Uv=og.createImageData(U,B)}const i=Sd.width,s=Sd.height,l=Math.pow(t,o.curve),c=1-Math.exp(-n/(.012+o.smoothing*.14));t1+=(o.strength*l-t1)*c,n1+=(o.deform*l-n1)*c;let u=t1*a,d=n1*a;if(Number.isNaN(Ag))Ag=jg.cx,$v=jg.cy;else{const U=1-Math.exp(-n/(.05+o.handover*.6));Ag+=(jg.cx-Ag)*U,$v+=(jg.cy-$v)*U}const f=ng*a,g=f+r.hotX*a,b=f+r.hotY*a,v=g+(Ag-q7)*a,y=b+($v-Q7)*a,w=Math.hypot(v-g,y-b)||1,S=(v-g)/w,E=(y-b)/w,A=o.falloff*a;if(o.squash>0){const U=Math.hypot(r.width*.5-r.hotX,r.height-r.hotY)||1,B=(r.width*.5-r.hotX)/U,V=(r.height-r.hotY)/U,G=Math.max(0,-(S*B+E*V)),F=1+o.squash*G;u*=F,d*=F}const T=Math.ceil(Math.max(d,1))+4,C=Math.floor(Math.min(f,f+S*u)-T),R=Math.floor(Math.min(f,f+E*u)-T),N=Math.ceil(Math.max(f,f+S*u)+r.width*a+T),O=Math.ceil(Math.max(f,f+E*u)+r.height*a+T),P=Math.max(0,C),j=Math.max(0,R),D=Math.min(i,N)-P,z=Math.min(s,O)-j;d>.01?(Fqt(d,o.taper,f,g,b,v,y),og.putImageData(Uv,0,0,P,j,D,z)):(og.setTransform(1,0,0,1,0,0),og.clearRect(0,0,i,s),og.drawImage(mm,f,f,r.width*a,r.height*a));const L=JI,$=i$;if(L.setTransform(1,0,0,1,0,0),L.clearRect(0,0,i,s),L.globalAlpha=1,L.globalCompositeOperation="source-over",L.drawImage(rg,0,0),u>.5){const U=f+r.width*a*.42,B=f+r.height*a*.5,V=A/2,G=$.createLinearGradient(U-S*V,B-E*V,U+S*V,B+E*V);G.addColorStop(0,"rgba(0,0,0,0)"),G.addColorStop(1,"rgba(0,0,0,1)");for(let F=Z0e;F>=1;F--){const Z=F/Z0e;$.setTransform(1,0,0,1,0,0),$.globalCompositeOperation="source-over",$.globalAlpha=1,$.clearRect(P,j,D,z),$.drawImage(rg,P,j,D,z,P+S*u*Z,j+E*u*Z,D,z),$.globalCompositeOperation="destination-in",$.fillStyle=G,$.fillRect(P,j,D,z),L.globalCompositeOperation="destination-over",L.globalAlpha=Math.pow(1-Z,1.6)*.9,o.blur>0&&(L.filter=`blur(${(o.blur*Math.sqrt(Z)*a).toFixed(2)}px)`),L.drawImage(av,P,j,D,z,P,j,D,z)}L.filter="none",L.globalAlpha=1,L.globalCompositeOperation="source-over"}Su.style.transform=`translate3d(${(q7-r.hotX-ng).toFixed(2)}px,${(Q7-r.hotY-ng).toFixed(2)}px,0)`,g0||(Su.style.display="",g0=!0)}function tB(e){if(Ff=0,!h0)return;const t=performance.now();try{Bqt(e)}catch(r){Q_=!0,Y7=`disabled after an error (${r instanceof Error?r.message:String(r)})`,bm(),As=null,typeof console<"u"&&console.warn("thinking-orbs: gravity disabled after error",r);return}const n=performance.now()-t;n>12?++Z7>=30&&!Q_&&(Q_=!0,Y7=`disabled after slow frames (~${Math.round(n)}ms each)`,bm()):Z7=0}function Bqt(e){const t=Math.min(.05,Math.max(.001,(e-X7)/1e3));X7=e,J7++;let n=null,r=0;if(!Number.isNaN(Jl)&&Oqt()){let s=Number.POSITIVE_INFINITY;for(const l of zv){if(!l.el.isConnected)continue;const c=l.el.getBoundingClientRect();if(c.width<=0)continue;const u=c.left+c.width/2,d=c.top+c.height/2,f=Math.min(c.width,c.height)/2,g=t2(l).reach;if(Jl<u-f-g||Jl>u+f+g||Tg<d-f-g||Tg>d+f+g)continue;const b=Math.hypot(Jl-u,Tg-d)-f;b<=g&&b<s&&(s=b,n=l,jg.cx=u,jg.cy=d,jg.r=f)}if(n){const l=1-Math.max(0,s)/t2(n).reach;r=l*l*(3-2*l),Y0e=e}}const o=As??n,a=o?t2(o).fadeMs:hl.fadeMs,i=1-Math.exp(-(t*1e3)/(a/3));if(pf+=(r-pf)*i,n&&n!==As&&(As=n),!n&&pf<.002){if(pf=0,As&&HS&&!VS&&e2&&!J_&&!Number.isNaN(Jl)){if(e-Y0e<$qt){K0e(Jl,Tg)?Q0e(As,0,t):e1(),Ff=requestAnimationFrame(tB);return}if(g0){OJ(),VS=!0,As=null;return}}As=null,bm();return}As&&(pf>.002&&e2&&!J_&&!Number.isNaN(Jl)&&Dqt()&&K0e(Jl,Tg)?MJ===NJ&&J7-KLe<2&&!g0?e1():Q0e(As,pf,t):pf>.002&&!Number.isNaN(Jl)&&e2&&!J_?e1():bm(),Ff=requestAnimationFrame(tB))}function Hqt(e){if(!e)return;const t=e.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(t){let r=t[1];r.length===3&&(r=r.replace(/./g,a=>a+a));const o=parseInt(r,16);return{r:o>>16&255,g:o>>8&255,b:o&255}}const n=e.trim().match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(n)return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3])}}const Vqt={working:"Working…",searching:"Searching…",solving:"Solving…",listening:"Listening…",connecting:"Connecting…",weaving:"Weaving…",composing:"Composing…",breathing:"Thinking…",shaping:"Shaping…"};function PJ({state:e="working",size:t=64,theme:n="auto",speed:r=1,paused:o=!1,color:a,dots:i=1,dotSize:s=1,opts:l,frame:c,gravity:u,style:d,"aria-label":f,...g}){const b=_.useRef(null),v=l?JSON.stringify(l):"",y=Cqt(n,b),w=u?JSON.stringify(u):"";_.useEffect(()=>{const E=b.current;if(!(!E||!u))return Nqt(E,u===!0?!0:u)},[w]);const S=Rqt();return _.useEffect(()=>{const E=b.current;if(!E)return;const A=Math.min(2,typeof devicePixelRatio<"u"&&devicePixelRatio||1);E.width=Math.round(t*A),E.height=Math.round(t*A);const T=E.getContext("2d");if(!T)return;const{mode:C,speed:R,opts:N}=Eqt(e,t);let O=i!==1?$Le(N,Math.max(.1,i)):N;s!==1&&(O=ULe(O,Math.max(.1,s))),l&&(O={...O,...l});const P=c??HLe[C],j=Hqt(a),D=R*r,z=J=>{T.setTransform(A,0,0,A,0,0),T.clearRect(0,0,t,t),zLe(T,P(t,J,O),y,j)};if(S){z(.6);return}let L=0,$=!1;const U=()=>{z(performance.now()/1e3*D),$&&(L=requestAnimationFrame(U))},B=()=>{$||o||($=!0,L=requestAnimationFrame(U))},V=()=>{$=!1,cancelAnimationFrame(L)};z(performance.now()/1e3*D);let G=!0;const F=typeof IntersectionObserver<"u"?new IntersectionObserver(([J])=>{G=J.isIntersecting,G&&document.visibilityState!=="hidden"?B():V()}):null;F==null||F.observe(E);const Z=()=>{document.visibilityState==="hidden"?V():G&&B()};return document.addEventListener("visibilitychange",Z),F||B(),()=>{V(),F==null||F.disconnect(),document.removeEventListener("visibilitychange",Z)}},[e,t,y,r,o,S,a,i,s,v,c]),h.jsx("canvas",{ref:b,role:"img","aria-label":f??Vqt[e],style:{width:t,height:t,display:"block",...d},...g})}var ag={},s$={},J0e;function exe(){return J0e||(J0e=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.ALL=e.COLLECTION=e.ATOM=e.SPECIAL=e.INF=e._INFINITY=e.INFINITY=e.NAN=e.BOOL=e.NULL=e.OBJ=e.ARR=e.NUM=e.STR=void 0,e.STR=1,e.NUM=2,e.ARR=4,e.OBJ=8,e.NULL=16,e.BOOL=32,e.NAN=64,e.INFINITY=128,e._INFINITY=256,e.INF=e.INFINITY|e._INFINITY,e.SPECIAL=e.NULL|e.BOOL|e.INF|e.NAN,e.ATOM=e.STR|e.NUM|e.SPECIAL,e.COLLECTION=e.ARR|e.OBJ,e.ALL=e.ATOM|e.COLLECTION,e.Allow={STR:e.STR,NUM:e.NUM,ARR:e.ARR,OBJ:e.OBJ,NULL:e.NULL,BOOL:e.BOOL,NAN:e.NAN,INFINITY:e.INFINITY,_INFINITY:e._INFINITY,INF:e.INF,SPECIAL:e.SPECIAL,ATOM:e.ATOM,COLLECTION:e.COLLECTION,ALL:e.ALL},e.default=e.Allow})(s$)),s$}var txe;function Gqt(){return txe||(txe=1,(function(e){var t=ag&&ag.__createBinding||(Object.create?(function(c,u,d,f){f===void 0&&(f=d);var g=Object.getOwnPropertyDescriptor(u,d);(!g||("get"in g?!u.__esModule:g.writable||g.configurable))&&(g={enumerable:!0,get:function(){return u[d]}}),Object.defineProperty(c,f,g)}):(function(c,u,d,f){f===void 0&&(f=d),c[f]=u[d]})),n=ag&&ag.__exportStar||function(c,u){for(var d in c)d!=="default"&&!Object.prototype.hasOwnProperty.call(u,d)&&t(u,c,d)};Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.MalformedJSON=e.PartialJSON=e.parseJSON=e.parse=void 0;const r=exe();Object.defineProperty(e,"Allow",{enumerable:!0,get:function(){return r.Allow}}),n(exe(),e);class o extends Error{}e.PartialJSON=o;class a extends Error{}e.MalformedJSON=a;function i(c,u=r.Allow.ALL){if(typeof c!="string")throw new TypeError(`expecting str, got ${typeof c}`);if(!c.trim())throw new Error(`${c} is empty`);return s(c.trim(),u)}e.parseJSON=i;const s=(c,u)=>{const d=c.length;let f=0;const g=T=>{throw new o(`${T} at position ${f}`)},b=T=>{throw new a(`${T} at position ${f}`)},v=()=>(A(),f>=d&&g("Unexpected end of input"),c[f]==='"'?y():c[f]==="{"?w():c[f]==="["?S():c.substring(f,f+4)==="null"||r.Allow.NULL&u&&d-f<4&&"null".startsWith(c.substring(f))?(f+=4,null):c.substring(f,f+4)==="true"||r.Allow.BOOL&u&&d-f<4&&"true".startsWith(c.substring(f))?(f+=4,!0):c.substring(f,f+5)==="false"||r.Allow.BOOL&u&&d-f<5&&"false".startsWith(c.substring(f))?(f+=5,!1):c.substring(f,f+8)==="Infinity"||r.Allow.INFINITY&u&&d-f<8&&"Infinity".startsWith(c.substring(f))?(f+=8,1/0):c.substring(f,f+9)==="-Infinity"||r.Allow._INFINITY&u&&1<d-f&&d-f<9&&"-Infinity".startsWith(c.substring(f))?(f+=9,-1/0):c.substring(f,f+3)==="NaN"||r.Allow.NAN&u&&d-f<3&&"NaN".startsWith(c.substring(f))?(f+=3,NaN):E()),y=()=>{const T=f;let C=!1;for(f++;f<d&&(c[f]!=='"'||C&&c[f-1]==="\\");)C=c[f]==="\\"?!C:!1,f++;if(c.charAt(f)=='"')try{return JSON.parse(c.substring(T,++f-Number(C)))}catch(R){b(String(R))}else if(r.Allow.STR&u)try{return JSON.parse(c.substring(T,f-Number(C))+'"')}catch{return JSON.parse(c.substring(T,c.lastIndexOf("\\"))+'"')}g("Unterminated string literal")},w=()=>{f++,A();const T={};try{for(;c[f]!=="}";){if(A(),f>=d&&r.Allow.OBJ&u)return T;const C=y();A(),f++;try{const R=v();T[C]=R}catch(R){if(r.Allow.OBJ&u)return T;throw R}A(),c[f]===","&&f++}}catch{if(r.Allow.OBJ&u)return T;g("Expected '}' at end of object")}return f++,T},S=()=>{f++;const T=[];try{for(;c[f]!=="]";)T.push(v()),A(),c[f]===","&&f++}catch{if(r.Allow.ARR&u)return T;g("Expected ']' at end of array")}return f++,T},E=()=>{if(f===0){c==="-"&&b("Not sure what '-' is");try{return JSON.parse(c)}catch(C){if(r.Allow.NUM&u)try{return JSON.parse(c.substring(0,c.lastIndexOf("e")))}catch{}b(String(C))}}const T=f;for(c[f]==="-"&&f++;c[f]&&",]}".indexOf(c[f])===-1;)f++;f==d&&!(r.Allow.NUM&u)&&g("Unterminated number literal");try{return JSON.parse(c.substring(T,f))}catch{c.substring(T,f)==="-"&&g("Not sure what '-' is");try{return JSON.parse(c.substring(T,c.lastIndexOf("e")))}catch(R){b(String(R))}}},A=()=>{for(;f<d&&`
1091
1091
  \r `.includes(c[f]);)f++};return v()},l=i;e.parse=l})(ag)),ag}var Wqt=Gqt(),Kqt=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 737 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_10580_645)",children:[h.jsx("path",{d:"M0 0.015625L40 20.0156V40L20 40V80.0156H40V100.016L0 120.016V0.015625Z",fill:"white"}),h.jsx("path",{d:"M120 0L80 20V40H100V80H80V100L120 120V0Z",fill:"white"}),h.jsx("path",{d:"M59.9971 39.8193C61.0556 45.6178 63.1951 50.1614 66.5771 53.5215C69.9455 56.868 74.4738 58.9678 80.2051 60.0088C74.4712 61.0714 69.9429 63.2075 66.5752 66.5752C63.1954 69.955 61.0558 74.5036 59.9971 80.2666C58.933 74.5031 56.7854 69.9547 53.4004 66.5752C50.0276 63.2078 45.4981 61.0704 39.7725 60.0078C45.4953 58.9668 50.0251 56.8676 53.3984 53.5215C56.7857 50.1616 58.9332 45.6182 59.9971 39.8193Z",fill:"white",stroke:"white",strokeWidth:1.6,strokeLinejoin:"round"})]}),h.jsx("path",{d:"M622.099 24.752C631.17 24.752 637.822 27.7322 642.056 33.6934V27.084H659.938V90.4531C659.938 99.87 656.785 107.127 650.479 112.225C644.172 117.408 636.008 120 625.986 120C614.669 120 603.784 116.76 593.33 110.28L602.66 96.1553C611.559 101.252 619.248 103.801 625.728 103.801C635.835 103.801 640.89 98.7473 640.89 88.6396V84.752C636.57 89.8491 630.306 92.3975 622.099 92.3975C613.632 92.3974 606.548 89.2442 600.846 82.9375C595.23 76.6308 592.423 68.5094 592.423 58.5742C592.423 48.6393 595.23 40.5185 600.846 34.2119C606.548 27.9052 613.632 24.752 622.099 24.752ZM292.13 69.46C292.13 76.285 295.456 79.6982 302.108 79.6982C310.229 79.6982 314.29 75.421 314.29 66.8682V27.084H333.729V94.4707H315.975V87.3438C311.914 93.564 305.391 96.6738 296.406 96.6738C288.458 96.6738 282.497 94.773 278.522 90.9717C274.635 87.1704 272.691 81.7275 272.691 74.6436V27.084H292.13V69.46ZM378.339 24.752C388.62 24.752 396.525 27.7322 402.054 33.6934C407.669 39.6545 410.478 48.0349 410.478 58.834C410.478 61.2528 410.391 63.758 410.218 66.3496H362.658C364.732 75.5937 370.693 80.2158 380.542 80.2158C384.084 80.2158 387.237 79.6109 390.002 78.4014C392.766 77.1055 396.049 74.8595 399.851 71.6631L410.478 83.8447C401.579 92.3976 391.427 96.6738 380.023 96.6738C368.965 96.6738 360.153 93.4345 353.587 86.9551C347.108 80.4757 343.868 71.836 343.868 61.0371C343.868 50.4108 346.978 41.7279 353.198 34.9893C359.419 28.1642 367.799 24.752 378.339 24.752ZM499.098 24.752C509.465 24.752 517.974 28.121 524.626 34.8594C531.278 41.5116 534.604 50.1077 534.604 60.6475C534.604 71.2738 531.278 79.9566 524.626 86.6953C517.974 93.3474 509.465 96.6738 499.098 96.6738C488.644 96.6738 480.091 93.3476 473.438 86.6953C466.786 79.9567 463.46 71.2738 463.46 60.6475C463.46 50.1077 466.786 41.5116 473.438 34.8594C480.091 28.1207 488.644 24.752 499.098 24.752ZM704.464 24.752C714.745 24.752 722.65 27.7322 728.179 33.6934C733.794 39.6545 736.603 48.0349 736.603 58.834C736.603 61.2528 736.516 63.758 736.343 66.3496H688.783C690.857 75.5937 696.818 80.2158 706.667 80.2158C710.209 80.2158 713.362 79.6109 716.127 78.4014C718.891 77.1055 722.174 74.8595 725.976 71.6631L736.603 83.8447C727.704 92.3976 717.552 96.6738 706.148 96.6738C695.09 96.6738 686.278 93.4345 679.712 86.9551C673.233 80.4757 669.993 71.836 669.993 61.0371C669.993 50.4108 673.103 41.7279 679.323 34.9893C685.544 28.1642 693.924 24.752 704.464 24.752ZM194.087 27.085H209.249V41.5996H194.087V73.0898C194.087 75.3359 194.605 76.9345 195.642 77.8848C196.678 78.7486 198.277 79.1797 200.437 79.1797C202.078 79.1797 204.626 78.8347 208.082 78.1436L210.285 93.6943C204.842 95.3358 199.702 96.1562 194.864 96.1562C187.694 96.1562 182.51 94.6013 179.313 91.4912C176.203 88.3811 174.649 83.4137 174.648 76.5889V41.5996H162.855V27.085H174.648V7.3877H194.087V27.085ZM254.532 25.9189C257.21 25.9189 260.883 26.6959 265.548 28.251L261.919 45.3574C257.858 44.4071 254.921 43.9316 253.106 43.9316C248.787 43.9317 245.374 45.6162 242.869 48.9854C240.364 52.2683 239.111 56.8044 239.111 62.5928V94.4717H219.673V27.085H237.686V36.6748C241.314 29.5042 246.93 25.919 254.532 25.9189ZM579.519 25.9189C582.197 25.9189 585.869 26.6959 590.534 28.251L586.905 45.3574C582.845 44.4072 579.908 43.9317 578.094 43.9316C573.774 43.9316 570.361 45.616 567.855 48.9854C565.35 52.2683 564.098 56.8044 564.098 62.5928V94.4717H544.659V27.085H562.672V36.6748C566.3 29.5043 571.916 25.9191 579.519 25.9189ZM449.276 0C453.942 0 458.866 0.77795 464.05 2.33301L460.681 16.7168C458.175 16.1121 455.627 15.8096 453.035 15.8096C450.53 15.8096 448.758 16.3712 447.722 17.4941C446.685 18.5309 446.167 20.3892 446.167 23.0674V27.084H460.292V41.5986H446.167V94.4707H426.729V41.5986H415.454V27.084H426.729V22.2891C426.729 7.42983 434.244 0.000142379 449.276 0ZM499.098 41.209C494.346 41.209 490.501 42.9803 487.563 46.5225C484.626 50.0645 483.158 54.773 483.158 60.6475C483.158 66.6084 484.626 71.3603 487.563 74.9023C490.501 78.4445 494.346 80.2158 499.098 80.2158C503.849 80.2157 507.65 78.4444 510.501 74.9023C513.438 71.3602 514.907 66.6085 514.907 60.6475C514.907 54.7729 513.438 50.0645 510.501 46.5225C507.564 42.9806 503.763 41.2091 499.098 41.209ZM626.764 41.3389C622.358 41.3389 618.772 42.9373 616.008 46.1338C613.33 49.2439 611.99 53.3908 611.99 58.5742C611.99 63.7578 613.373 67.948 616.138 71.1445C618.902 74.341 622.444 75.9394 626.764 75.9395C631.17 75.9395 634.755 74.341 637.52 71.1445C640.284 67.948 641.667 63.7578 641.667 58.5742C641.667 53.3907 640.284 49.2439 637.52 46.1338C634.755 42.9374 631.17 41.3389 626.764 41.3389ZM378.08 39.9131C370.218 39.9131 365.207 44.1902 363.047 52.7432H391.945C390.995 44.1904 386.374 39.9132 378.08 39.9131ZM704.205 39.9131C696.343 39.9131 691.332 44.1902 689.172 52.7432H718.07C717.12 44.1904 712.499 39.9132 704.205 39.9131Z",fill:"white"}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_10580_645",children:h.jsx("rect",{width:120,height:120,fill:"white"})})})]}),Yqt=Kqt,Zqt=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 614 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_10581_1412)",children:[h.jsx("path",{d:"M-0.00195312 0.0136719L33.3314 16.6803V33.334L16.6647 33.334V66.6803H33.3314V83.347L-0.00195312 100.014V0.0136719Z",fill:"#05090E"}),h.jsx("path",{d:"M99.998 0L66.6647 16.6667V33.3333H83.3314V66.6667H66.6647V83.3333L99.998 100V0Z",fill:"#05090E"}),h.jsx("path",{d:"M49.9961 33.1826C50.8782 38.0147 52.6612 41.8005 55.4795 44.6006C58.2863 47.3892 62.0592 49.1393 66.835 50.0068C62.057 50.8924 58.2839 52.6732 55.4775 55.4795C52.6611 58.2959 50.8784 62.0863 49.9961 66.8887C49.1093 62.0858 47.3189 58.2958 44.498 55.4795C41.6875 52.6735 37.9135 50.8924 33.1426 50.0068C37.9113 49.1393 41.6861 47.3898 44.4971 44.6016C47.3198 41.8016 49.1095 38.0151 49.9961 33.1826Z",fill:"#6D58FB",stroke:"#6D58FB",strokeWidth:1.33333,strokeLinejoin:"round"})]}),h.jsx("path",{d:"M518.559 20.627C526.12 20.627 531.665 23.1106 535.193 28.0781V22.5703H550.1V75.3789C550.1 83.2261 547.47 89.2739 542.214 93.5215C536.957 97.8409 530.153 100.001 521.8 100.001C512.367 100.001 503.293 97.3008 494.58 91.9014L502.356 80.1299C509.773 84.3774 516.182 86.5019 521.583 86.502C530.008 86.502 534.221 82.2902 534.221 73.8672V70.627C530.62 74.8745 525.399 76.998 518.559 76.998C511.502 76.998 505.597 74.3706 500.845 69.1152C496.164 63.8597 493.823 57.0918 493.823 48.8125C493.823 40.5333 496.164 33.7663 500.845 28.5107C505.597 23.2553 511.502 20.627 518.559 20.627ZM315.383 20.627C323.952 20.627 330.541 23.1106 335.149 28.0781C339.83 33.0457 342.17 40.0293 342.17 49.0283C342.17 51.0441 342.098 53.1322 341.954 55.292H302.312C304.041 62.9954 309.01 66.8477 317.219 66.8477C320.171 66.8476 322.799 66.3429 325.104 65.335C327.408 64.2551 330.144 62.3835 333.312 59.7197L342.17 69.8711C334.753 76.9984 326.292 80.5624 316.787 80.5625C307.57 80.5625 300.225 77.8624 294.752 72.4629C289.351 67.0633 286.65 59.8635 286.65 50.8643C286.65 42.0091 289.243 34.7737 294.428 29.1582C299.612 23.4707 306.598 20.627 315.383 20.627ZM416.036 20.627C424.677 20.627 431.77 23.4346 437.314 29.0498C442.859 34.5934 445.632 41.7577 445.632 50.541C445.632 59.3961 442.859 66.6316 437.314 72.2471C431.77 77.7904 424.677 80.5625 416.036 80.5625C407.323 80.5625 400.194 77.7905 394.649 72.2471C389.105 66.6316 386.332 59.3961 386.332 50.541C386.332 41.7577 389.105 34.5934 394.649 29.0498C400.194 23.4345 407.323 20.627 416.036 20.627ZM587.211 20.627C595.78 20.627 602.369 23.1106 606.978 28.0781C611.658 33.0457 613.998 40.0292 613.998 49.0283C613.998 51.0441 613.926 53.1322 613.782 55.292H574.141C575.869 62.9953 580.838 66.8476 589.047 66.8477C591.999 66.8477 594.627 66.3428 596.932 65.335C599.236 64.2551 601.972 62.3834 605.141 59.7197L613.998 69.8711C606.581 76.9984 598.12 80.5624 588.615 80.5625C579.398 80.5625 572.053 77.8624 566.58 72.4629C561.179 67.0633 558.479 59.8635 558.479 50.8643C558.479 42.0091 561.071 34.7737 566.256 29.1582C571.441 23.4707 578.426 20.627 587.211 20.627ZM243.526 57.8838C243.526 63.5711 246.299 66.415 251.844 66.415C258.612 66.4149 261.997 62.8509 261.997 55.7236V22.5703H278.199V78.7256H263.4V72.7861C260.016 77.9696 254.58 80.5615 247.091 80.5615C240.466 80.5615 235.497 78.9782 232.185 75.8105C228.944 72.6428 227.324 68.1067 227.324 62.2031V22.5703H243.526V57.8838ZM161.807 22.5713H174.444V34.666H161.807V60.9082C161.807 62.7799 162.239 64.1114 163.104 64.9033C163.968 65.6232 165.299 65.9834 167.1 65.9834C168.468 65.9834 170.592 65.6951 173.473 65.1191L175.309 78.0781C170.772 79.446 166.488 80.1299 162.455 80.1299C156.478 80.1299 152.158 78.834 149.493 76.2422C146.901 73.6504 145.604 69.5106 145.604 63.8232V34.666H135.775V22.5713H145.604V6.15625H161.807V22.5713ZM212.189 21.5977C214.422 21.5977 217.482 22.2453 221.37 23.541L218.346 37.7959C214.962 37.004 212.513 36.6084 211.001 36.6084C207.401 36.6085 204.556 38.0126 202.468 40.8203C200.38 43.5561 199.336 47.3357 199.336 52.1592V78.7256H183.134V22.5693H198.147V30.5605C201.172 24.5852 205.853 21.5977 212.189 21.5977ZM374.509 0C378.397 0 382.502 0.647547 386.822 1.94336L384.015 13.9307C381.926 13.4267 379.802 13.1748 377.642 13.1748C375.553 13.1748 374.077 13.6432 373.213 14.5791C372.349 15.4431 371.917 16.9909 371.917 19.2227V22.5703H383.69V34.665H371.917V78.7256H355.715V34.665H346.317V22.5703H355.715V18.5742C355.715 6.19146 361.979 5.23399e-05 374.509 0ZM483.068 21.5977C485.301 21.5977 488.361 22.2453 492.249 23.541L489.225 37.7959C485.84 37.004 483.392 36.6084 481.88 36.6084C478.279 36.6084 475.435 38.0125 473.347 40.8203C471.258 43.5561 470.214 47.3357 470.214 52.1592V78.7256H454.012V22.5693H469.026V30.5605C472.051 24.5853 476.732 21.5977 483.068 21.5977ZM416.036 34.3418C412.076 34.3418 408.871 35.8178 406.423 38.7695C403.975 41.7213 402.75 45.6454 402.75 50.541C402.75 55.5084 403.975 59.4682 406.423 62.4199C408.871 65.3715 412.076 66.8477 416.036 66.8477C419.996 66.8476 423.165 65.3715 425.541 62.4199C427.989 59.4682 429.214 55.5084 429.214 50.541C429.214 45.6454 427.989 41.7213 425.541 38.7695C423.093 35.8179 419.925 34.3418 416.036 34.3418ZM522.447 34.4502C518.775 34.4502 515.787 35.7817 513.482 38.4453C511.25 41.0371 510.134 44.4929 510.134 48.8125C510.134 53.1321 511.286 56.6243 513.59 59.2881C515.894 61.9518 518.847 63.2831 522.447 63.2832C526.12 63.2832 529.109 61.9519 531.413 59.2881C533.717 56.6243 534.869 53.1321 534.869 48.8125C534.869 44.493 533.717 41.0371 531.413 38.4453C529.109 35.7815 526.12 34.4502 522.447 34.4502ZM315.166 33.2617C308.613 33.2619 304.437 36.8258 302.637 43.9531H326.724C325.932 36.8257 322.079 33.2617 315.166 33.2617ZM586.995 33.2617C580.442 33.2617 576.265 36.8257 574.465 43.9531H598.552C597.76 36.8258 593.908 33.2619 586.995 33.2617Z",fill:"black"}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_10581_1412",children:h.jsx("rect",{width:100,height:100,fill:"white"})})})]}),Xqt=Zqt,YLe="TrueForge";function Yvn(e){switch(e==null?void 0:e.mode){case"logo":return{expandedVariant:"logo",collapsedVariant:"icon",showTitle:!1};case"icon-only":return{expandedVariant:"icon",collapsedVariant:"icon",showTitle:!1};case"icon-title":return{expandedVariant:"icon",collapsedVariant:"icon",showTitle:!0};default:return{expandedVariant:"logo",collapsedVariant:"icon",showTitle:!1}}}function nxe({image:e,mode:t}){return typeof e=="string"?e:(t==="dark"?e.dark:e.light)??e.light??e.dark??e.src}function qqt(){var t;const e=(t=_.useContext(rh))==null?void 0:t.brand;return(e==null?void 0:e.name)!=null?e.name:(e==null?void 0:e.mode)==null?YLe:void 0}function jJ({className:e,variant:t="icon"}){const n=_.useContext(rh),r=n==null?void 0:n.brand,a=qqt()??YLe,i=(n==null?void 0:n.mode)??"light",s=t==="logo"?r==null?void 0:r.logo:r==null?void 0:r.icon,l=s==null?void 0:nxe({image:s,mode:i}),c=r==null?void 0:r.icon,u=l??(t==="logo"&&c!=null?nxe({image:c,mode:i}):void 0);if(u==null){if(t==="logo"){const g=i==="dark"?Yqt:Xqt;return h.jsx(g,{className:pe("w-auto",e),width:void 0,height:void 0,role:"img","aria-label":a})}return h.jsx(be,{name:i==="dark"?"trueforge-logomark-dark":"trueforge-logomark-light",className:e})}const d=h.jsx("img",{src:u,alt:a,className:e}),f=r==null?void 0:r.href;return f==null?d:h.jsx("a",{href:f,"aria-label":a,className:"inline-flex items-center",children:d})}function ZLe({expanded:e,onChange:t,children:n,className:r,background:o,sx:a,...i}){const s=_.useId();return h.jsx("div",{className:pe("w-full",r),"data-expanded":e||void 0,...i,children:K.Children.map(n,l=>K.isValidElement(l)?K.cloneElement(l,{expanded:e,onChange:t,panelId:s}):l)})}function XLe({children:e,className:t,expanded:n,onChange:r,panelId:o}){return h.jsx("button",{type:"button","aria-expanded":n,"aria-controls":o,className:pe("flex w-full cursor-pointer items-center text-left",t),onClick:a=>r==null?void 0:r(a,!n),children:e})}function qLe({children:e,className:t,expanded:n,panelId:r}){return n?h.jsx("div",{id:r,role:"region",className:pe(t),children:e}):null}_.createContext({openItems:new Set,toggle:()=>{}});function Qqt({toolCount:e,thinkingCount:t,expanded:n,active:r=!1,onToggle:o,children:a,borderColor:i,background:s,dataTestPrefix:l,className:c}){const u=`${e} tool ${e===1?"call":"calls"}`,d=t>0?` · ${t} thought${t===1?"":"s"}`:"";return h.jsxs(ZLe,{expanded:n,onChange:()=>o(),className:pe("aui-agent-steps-card mb-3 rounded-lg border border-border bg-card-bg text-text-primary",c),style:{...s!==void 0?{background:s}:{},...i!==void 0?{borderColor:i}:{}},"data-testid":l?`${l}-agent-steps-card`:void 0,children:[h.jsx(XLe,{className:"p-0",children:h.jsxs("div",{className:"flex w-full items-center gap-2 px-2 py-2 text-left text-xs",children:[h.jsx(be,{name:n?"chevron-down":"chevron-right",size:"0.75em",className:"shrink-0 text-text-secondary"}),h.jsx("span",{className:"font-semibold text-text-primary",children:"Agent steps"}),h.jsxs("span",{className:"text-text-secondary",children:["· ",u,d]}),r&&h.jsx("div",{className:"ml-auto",children:h.jsx(Al,{size:12,className:"text-primary-button-bg"})})]})}),h.jsx(qLe,{children:h.jsx("div",{className:"space-y-3 border-t border-border p-3","data-testid":l?`${l}-content`:void 0,children:a})})]})}var DJ=K.forwardRef(({className:e,variant:t="primary",size:n="large",...r},o)=>h.jsx("button",{ref:o,className:rn({variant:t,size:n,className:e}),...r}));DJ.displayName="Button";function JA(e,t){const n=K.forwardRef((r,o)=>h.jsx(DJ,{ref:o,variant:e,...r}));return n.displayName=t,n}var Tn=Object.assign(DJ,{Primary:JA("primary","Button.Primary"),Secondary:JA("secondary","Button.Secondary"),Ghost:JA("ghost","Button.Ghost"),Destructive:JA("destructive","Button.Destructive")});function w3(e){const t=e==null?void 0:e.closest("dialog");return t instanceof HTMLElement?t:(e==null?void 0:e.closest(".aui-theme-root"))??document.body}var QLe=8,Xi=6,Jqt=100,r1=null,w_=null;function eQt(e,t){r1!=null&&r1!==e&&(w_==null||w_()),r1=e,w_=t}function rxe(e){r1===e&&(r1=null,w_=null)}function tQt(e){return e==="bottom"?{left:0,right:0,top:-Xi,height:Xi}:e==="top"?{left:0,right:0,bottom:-Xi,height:Xi}:e==="right"?{top:0,bottom:0,left:-Xi,width:Xi}:{top:0,bottom:0,right:-Xi,width:Xi}}function oxe(e){return e==="top"||e==="bottom"}function nQt(e){return e==="bottom"?"translate(-50%, 0)":e==="top"?"translate(-50%, -100%)":e==="right"?"translate(0, -50%)":"translate(-100%, -50%)"}function rQt({left:e,top:t,width:n,height:r,side:o,viewportWidth:a,viewportHeight:i,pad:s=QLe}){let l=e;if(n>0){const u=n/2,d=s+u,f=a-s-u;l=f<d?a/2:Math.min(f,Math.max(d,e))}let c=t;if(r>0)if(o==="bottom"){const u=t+r-(i-s);u>0&&(c=Math.max(s,t-u))}else t-r<s&&(c=s+r);return{top:c,left:l}}function oQt({left:e,top:t,width:n,height:r,side:o,viewportWidth:a,viewportHeight:i,pad:s=QLe}){let l=t;if(r>0){const u=r/2;l=Math.min(i-s-u,Math.max(s+u,t))}let c=e;return n>0&&(c=o==="right"?Math.min(a-s-n,Math.max(s,e)):Math.min(a-s,Math.max(s+n,e))),{top:l,left:c}}function aQt(e){return e==null||e===!1?!1:typeof e=="string"?e.trim().length>0:!0}function sr({content:e,children:t,className:n,triggerClassName:r,side:o="top",dismissOnClick:a=!0,followCursor:i=!1,anchor:s=null,open:l,interactive:c=!0}){const[u,d]=_.useState(!1),f=l??u,g=l!==void 0,b=U=>{g||d(U)},[v,y]=_.useState(null),w=_.useRef(null),S=_.useRef(null),E=_.useRef(null),A=_.useRef(()=>{}),T=_.useRef(0),C=_.useRef(null),R=_.useRef({}),N=_.useRef(()=>{}),O=()=>{C.current!=null&&(clearTimeout(C.current),C.current=null)},P=()=>{O(),T.current=0,rxe(R.current),b(!1)};N.current=P;const j=()=>{O(),C.current=setTimeout(()=>{C.current=null,T.current<=0&&P()},Jqt)},D=()=>{g||eQt(R.current,()=>N.current()),b(!0)};if(_.useEffect(()=>()=>{O(),rxe(R.current)},[]),A.current=()=>{const U=w.current;let B=null;if(s!=null)B={top:o==="bottom"?s.top+Xi:s.top-Xi,left:s.left};else if(U){const F=U.getBoundingClientRect();B=oxe(o)?{top:o==="bottom"?F.bottom+Xi:F.top-Xi,left:i&&E.current!=null?E.current:F.left+F.width/2}:{top:F.top+F.height/2,left:o==="right"?F.right+Xi:F.left-Xi}}if(B==null)return;const V=S.current;if(V==null){y(B);return}const G={...B,width:V.offsetWidth,height:V.offsetHeight,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight};y(oxe(o)?rQt({...G,side:o}):oQt({...G,side:o}))},_.useLayoutEffect(()=>{if(!f){y(null);return}const U=()=>A.current();return U(),window.addEventListener("scroll",U,!0),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,!0),window.removeEventListener("resize",U)}},[s,i,f,o,e]),!_.isValidElement(t))return t;const z=t.props,L=_.cloneElement(t,{onMouseEnter(U){var B;i&&(E.current=U.clientX),c&&(O(),T.current+=1),D(),(B=z.onMouseEnter)==null||B.call(z,U)},onMouseMove(U){var B;i&&s==null&&(E.current=U.clientX,A.current()),(B=z.onMouseMove)==null||B.call(z,U)},onMouseLeave(U){var B;E.current=null,c?(T.current=Math.max(0,T.current-1),j()):P(),(B=z.onMouseLeave)==null||B.call(z,U)},onFocus(U){var B;D(),(B=z.onFocus)==null||B.call(z,U)},onBlur(U){var B;P(),(B=z.onBlur)==null||B.call(z,U)},onClick(U){var B;a&&P(),(B=z.onClick)==null||B.call(z,U)}}),$=f&&aQt(e)?Ui.createPortal(h.jsxs("span",{ref:S,role:"tooltip",style:{top:(v==null?void 0:v.top)??0,left:(v==null?void 0:v.left)??0,transform:nQt(o),visibility:v==null?"hidden":void 0},className:pe(c?"pointer-events-auto":"pointer-events-none","fixed z-[200] max-w-[calc(100vw-1rem)]","whitespace-nowrap rounded bg-card-bg px-2 py-1 text-xs text-text-primary shadow-md",n),onMouseEnter:c?()=>{O(),T.current+=1}:void 0,onMouseLeave:c?()=>{T.current=Math.max(0,T.current-1),j()}:void 0,children:[c?h.jsx("span",{"aria-hidden":!0,className:"pointer-events-auto absolute",style:tQt(o)}):null,e]}),w3(w.current)):null;return h.jsxs("span",{ref:w,className:pe("relative inline-flex",r),children:[L,$]})}function GS({title:e,children:t,className:n,triggerClassName:r,size:o,side:a,dismissOnClick:i,followCursor:s,anchor:l,open:c,interactive:u}){return h.jsx(sr,{content:e,className:n,triggerClassName:r,side:a,dismissOnClick:i,followCursor:s,anchor:l,open:c,interactive:u,children:t})}var Bf=K.forwardRef(({tooltip:e,children:t,...n},r)=>h.jsx(sr,{content:e,side:"bottom",children:h.jsx(Tn,{ref:r,size:"icon",...n,children:t})}));Bf.displayName="IconButton";var Ww="__tfy_ask_user_question_custom__";function axe(e){let t=e,n="";do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function ixe({letter:e,selected:t,className:n}){return h.jsx("span",{"aria-hidden":!0,className:pe("inline-flex size-5 shrink-0 items-center justify-center rounded border font-sans text-[0.6875rem] font-semibold leading-none",t?"border-primary-button-bg/50 bg-primary-button-bg/15 text-primary-button-bg":"border-border bg-transparent text-text-secondary",n),children:e})}function iQt({questions:e,answeredQuestions:t=[],onSubmit:n,currentQuestion:r,currentQuestionIndex:o=0,currentAnswer:a={radioValue:"",custom:""},totalQuestions:i=e.length,isMultiQuestion:s,isLastQuestion:l,allQuestionsAnswered:c=!1,isSubmitDisabled:u=!0,isSubmitAllDisabled:d=!0,onCurrentQuestionIndexChange:f,onCurrentAnswerChange:g,readOnly:b=!1,dataTestPrefix:v,className:y}){const w=Ge("Markdown"),S=s??i>1,E=l??o===i-1;if(e.length===0)return t.length===0?null:h.jsx("div",{className:pe("aui-ask-user-prompt mt-2 flex flex-col gap-3",y),children:t.map(D=>h.jsxs("div",{"data-testid":v?`${v}-answered-${D.id}`:void 0,children:[h.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border border-primary-button-bg/30 bg-primary-button-bg/10 px-4 py-2",children:[h.jsx("div",{className:"min-w-0 font-sans text-xs font-medium text-primary-button-bg [&_.markdown-body]:text-inherit!",children:h.jsx(w,{content:D.question})}),h.jsx("div",{className:"flex h-fit shrink-0 items-center gap-1 rounded border border-primary-button-bg/40 bg-primary-bg px-2 py-0.5 text-[0.6875rem] font-medium text-text-secondary",children:h.jsx("span",{className:"leading-tight",children:"Answered"})})]}),h.jsxs("div",{className:"flex items-center gap-2 rounded-b-lg border border-t-0 border-border px-4 py-3",children:[h.jsx(be,{name:"circle-check",size:"0.875em",className:"shrink-0 text-primary-button-bg"}),h.jsx("span",{className:"font-sans text-[0.8125rem] font-medium text-text-primary",children:D.isCustom?`Other: ${D.answer}`:D.answer})]})]},D.id))});if(!r)return null;const A=a.radioValue===Ww,T=r.options.length>0,C=axe(r.options.length),R=D=>{b||g==null||g(r.id,{radioValue:D})},N=()=>f==null?void 0:f(o+1),O=S&&!E,P=D=>{if(!(D.key!=="Enter"||D.shiftKey||b)){if(D.preventDefault(),O){u||N();return}d||n()}},j=h.jsx("textarea",{rows:1,value:a.custom,disabled:b||!r.id,onFocus:()=>g==null?void 0:g(r.id,{radioValue:Ww}),onChange:D=>{g==null||g(r.id,{custom:D.target.value,radioValue:Ww})},placeholder:T?"Other":"Type your answer","aria-label":T?"Other (custom answer)":"Your answer",className:pe("field-sizing-content min-h-8 max-h-[3lh] w-full resize-none overflow-y-auto rounded-md border border-input-border bg-primary-bg px-2.5 py-1 text-sm leading-5 text-text-primary","placeholder:text-sm focus:outline-none focus:ring-1 focus:ring-focus-ring")});return h.jsxs("div",{className:pe("aui-ask-user-prompt mx-auto w-[calc(100%-2rem)] min-w-0 overflow-hidden rounded-lg",y),"data-testid":v?`${v}-question-card`:void 0,children:[h.jsxs("div",{className:"flex items-center justify-between border rounded-t-lg border-primary-button-bg/30 bg-primary-button-bg/10 px-4 py-2.5",children:[i>1?h.jsx("div",{className:"min-w-0 font-sans text-sm font-medium text-primary-button-bg",children:"Questions"}):h.jsx("div",{className:"min-w-0 font-sans text-sm font-medium text-primary-button-bg [&_.markdown-body]:text-inherit!",children:h.jsx(w,{content:r.question})}),b?h.jsx("div",{className:"flex h-fit shrink-0 items-center gap-1 rounded border border-primary-button-bg/40 bg-primary-bg px-2 py-0.5 text-[0.6875rem] font-medium text-text-secondary",children:h.jsx("span",{className:"leading-tight",children:"Unanswered"})}):null,!b&&S&&h.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[h.jsx(Bf,{"aria-label":"Previous question",variant:"ghost",onClick:()=>f==null?void 0:f(Math.max(0,o-1)),disabled:o===0,className:"text-text-primary",children:h.jsx(be,{name:"chevron-left",size:"0.75em"})}),h.jsx(Bf,{"aria-label":"Next question",variant:"ghost",onClick:()=>f==null?void 0:f(Math.min(i-1,o+1)),disabled:o===i-1,className:"text-text-primary",children:h.jsx(be,{name:"chevron-right",size:"0.75em"})}),h.jsxs("div",{className:"ml-1 rounded bg-primary-button-bg/20 px-2 py-1 font-sans text-xs font-medium text-text-primary",children:[h.jsxs("span",{children:[" ",o+1," "]})," ",h.jsx("span",{children:" of "})," ",h.jsxs("span",{children:[" ",i," "]})]})]})]}),h.jsxs("div",{className:"flex flex-col gap-2 bg-primary-bg px-4 py-3 border border-t-0 border-border",children:[h.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[S&&h.jsx("div",{className:"font-sans text-xs font-medium text-text-primary",children:h.jsx(w,{content:r.question||"What would you like to do?"})}),h.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-3 overflow-visible",role:T?"radiogroup":void 0,"aria-label":T?r.question||"Answer options":void 0,onKeyDown:P,children:[r.options.map((D,z)=>{const L=a.radioValue===D,$=axe(z);return h.jsxs("label",{className:pe("col-span-2 grid grid-cols-subgrid items-center overflow-visible",b?"cursor-default":"cursor-pointer"),children:[h.jsx("input",{type:"radio",value:D,disabled:b||!r.id,name:`ask-user-question-option-${r.id}`,checked:L,onChange:()=>R(D),className:"sr-only"}),h.jsx(ixe,{letter:$,selected:L}),h.jsx("span",{className:"min-w-0 font-sans text-sm font-medium text-text-primary",children:D})]},`${z}:${D}`)}),T?h.jsxs("label",{className:pe("col-span-2 grid grid-cols-subgrid items-start overflow-visible",b?"cursor-default":"cursor-pointer"),children:[h.jsx("input",{type:"radio",disabled:b||!r.id,value:Ww,name:`ask-user-question-option-${r.id}`,checked:A,onChange:()=>R(Ww),className:"sr-only"}),h.jsx(ixe,{letter:C,selected:A,className:"mt-1.5"}),h.jsx("div",{className:"min-w-0",children:j})]}):h.jsx("div",{className:"col-span-2 min-w-0",children:j})]})]}),!b&&h.jsxs("div",{className:pe("flex items-center",{"justify-between":S,"justify-end":!S}),children:[S&&E&&!c?h.jsx("span",{className:"text-xs font-medium text-failure-bg",children:"Answer all questions to submit"}):h.jsx("span",{}),O?h.jsx(Tn.Primary,{type:"button",size:"small",onClick:N,disabled:u,className:"bg-gray-850 text-white hover:bg-gray-850 dark:text-black",children:"Next"}):h.jsx(Tn.Primary,{type:"button",size:"small",onClick:n,disabled:d,className:"bg-gray-850 text-white hover:bg-gray-850 dark:text-black",children:"Continue"})]})]})]})}function WS({className:e,colorClassName:t="bg-warning-bg",pulse:n=!0}){return h.jsxs("span",{"aria-hidden":!0,className:pe("relative inline-flex size-2 shrink-0",e),children:[n?h.jsx("span",{className:pe("pointer-events-none absolute inline-flex size-full rounded-full opacity-75 motion-safe:animate-ping motion-reduce:animate-none",t)}):null,h.jsx("span",{className:pe("relative inline-flex size-full rounded-full",t)})]})}function JLe({icon:e,iconSize:t="0.75em",variant:n="primary",className:r,iconClassName:o}){return h.jsx("div",{className:pe("flex size-5 shrink-0 items-center justify-center",r),children:h.jsx(be,{name:e,size:t,className:pe(n==="primary"?"text-primary-button-bg":"text-text-secondary",o)})})}function Qk({icon:e,iconVariant:t="primary",iconClassName:n,iconSize:r,title:o,label:a,body:i,expandable:s=!1,expanded:l=!1,onToggle:c,status:u="idle",statusText:d,showSpinner:f=!1,showConnector:g=!1,showContentConnector:b=!0,showPersistentContentConnector:v=!0,showChevronColumn:y=!0,children:w,persistentChildren:S,dataTestPrefix:E,className:A,titleClassName:T,align:C="center"}){const R=!!w,N=!!S,O=s&&c!=null,P=u==="running",j=u==="success",D=u==="error",z=C==="start";return h.jsxs("div",{className:pe("flex min-w-0 flex-col",A),"data-testid":E?`${E}-step-row`:void 0,children:[h.jsxs("div",{className:pe("flex gap-2",z?"items-start":"items-center"),children:[y&&(O?h.jsx("button",{type:"button",className:"flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center",onClick:c,"aria-expanded":l,"aria-label":l?"Collapse step":"Expand step","data-testid":E?`${E}-chevron`:void 0,children:h.jsx(be,{name:"chevron-right",size:"0.625rem",className:pe("shrink-0 text-text-secondary transition-transform duration-300",l&&"rotate-90")})}):h.jsx("div",{className:"w-5 shrink-0"})),h.jsx("div",{className:pe("relative flex shrink-0 flex-col items-center",z?"self-start":"self-center"),children:h.jsx(JLe,{icon:e,variant:t,iconClassName:n,iconSize:r})}),h.jsxs("div",{className:pe("flex min-w-0 flex-1 flex-col justify-center",{"cursor-pointer":O}),onClick:O?c:void 0,children:[a&&h.jsx("span",{className:"text-xs font-medium leading-none text-text-secondary",children:a}),o&&h.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[h.jsx("span",{className:pe("min-w-0 truncate font-sans text-[0.75rem] font-medium leading-5 text-text-primary",T),"data-testid":E?`${E}-title`:void 0,children:o}),j&&h.jsx(be,{name:"circle-check",size:"0.875rem",className:"shrink-0 text-success-bg","data-testid":E?`${E}-success-icon`:void 0})]}),i&&h.jsx("div",{className:"mt-1 font-sans text-sm text-text-secondary",onClick:L=>{l&&O&&L.stopPropagation()},"data-testid":E?`${E}-body`:void 0,children:i})]}),h.jsxs("div",{className:pe("flex shrink-0 items-center gap-2",z?"self-start":"self-center"),children:[d&&h.jsxs("span",{className:"flex items-center gap-1",children:[P&&h.jsx(WS,{}),h.jsx("span",{className:"font-sans text-xs font-medium leading-4 text-text-secondary",children:d})]}),!d&&P&&h.jsx(h.Fragment,{children:f?h.jsx("div",{className:"ml-1",children:h.jsx(Al,{size:12})}):h.jsx(WS,{})}),D&&h.jsx(be,{name:"circle-xmark",size:"0.875rem",className:"text-failure-bg","data-testid":E?`${E}-error-icon`:void 0})]})]}),l&&R&&h.jsxs("div",{className:"mt-2 flex min-w-0 gap-3","data-testid":E?`${E}-expanded-content`:void 0,children:[y&&h.jsx("div",{className:"w-5 shrink-0"}),b&&g&&h.jsx("div",{className:"flex w-3 shrink-0 justify-center",children:h.jsx("div",{className:"w-px bg-border"})}),h.jsx("div",{className:"min-w-0 flex-1",children:w})]}),N&&h.jsxs("div",{className:pe("flex min-w-0",v?"gap-3":"gap-2"),"data-testid":E?`${E}-persistent-content`:void 0,children:[y&&h.jsx("div",{className:"w-5 shrink-0"}),v&&g&&h.jsx("div",{className:"flex w-3 shrink-0 justify-center",children:h.jsx("div",{className:"w-px bg-border"})}),h.jsx("div",{className:"min-w-0 flex-1",children:S})]})]})}function sQt(e){return JSON.stringify(e.status==="complete"?e.finished:e.started,null,2)}function lQt(e){switch(e.status){case"running":return{title:"Summarizing context...",status:"running",showSpinner:!0};case"complete":return{title:"Summarized context",status:"success",showSpinner:!1};case"incomplete":return{title:e.reason==="cancelled"?"Context summarization cancelled":"Context summarization failed",status:"error",showSpinner:!1}}}function cQt({data:e,expanded:t=!1,onToggle:n,dataTestPrefix:r,className:o}){const a=Ge("ToolCallContentBlock"),{title:i,status:s,showSpinner:l}=lQt(e),c=sQt(e);return h.jsx("div",{className:pe("aui-context-compaction-card mt-2 flex min-w-0 flex-col",o),"data-testid":r?`${r}-context-compaction-card`:void 0,children:h.jsx(Qk,{icon:"layers",iconVariant:"primary",iconClassName:"text-[#a855f7]",title:i,expandable:!0,expanded:t,onToggle:n,status:s,showSpinner:l,dataTestPrefix:r,children:t?h.jsx("div",{className:"py-2 pt-0","data-testid":r?`${r}-event-json`:void 0,children:h.jsx(a,{title:"Event",content:c,isJson:!0,copyValue:c})}):null})})}var uQt="MCP Authentication Required";function dQt({servers:e,connectedServerIds:t,continueLoading:n=!1,onConnect:r,onContinue:o,readOnly:a=!1,title:i=uQt,dataTestPrefix:s,className:l}){return e.length===0?null:h.jsxs("div",{className:pe("aui-mcp-auth-prompt mx-auto w-[calc(100%-2rem)] min-w-0 overflow-hidden rounded-lg",l),"data-testid":s?`${s}-mcp-auth-card`:void 0,children:[h.jsx("div",{className:"border rounded-t-lg border-primary-button-bg/30 bg-primary-button-bg/10 px-4 py-2.5",children:h.jsx("div",{className:"font-sans text-sm font-medium text-primary-button-bg",children:i})}),h.jsxs("div",{className:"flex flex-col gap-3 bg-primary-bg px-4 py-3 border border-border border-t-0",children:[e.map(c=>h.jsxs("div",{className:"flex items-center justify-between gap-4",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-sm",children:[h.jsx(be,{name:"mcp-server",size:"0.875rem",className:"shrink-0 text-text-secondary"}),h.jsx("span",{className:"shrink-0 font-medium text-text-secondary",children:"MCP Server Name"}),h.jsx("span",{className:"shrink-0 text-xs font-semibold text-text-secondary",children:":"}),h.jsx("span",{className:"truncate font-sans font-medium text-text-primary",children:c.name})]}),t!=null&&t.has(c.id)?h.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-success-bg",children:[h.jsx(be,{name:"check",size:"0.875rem"}),"Connected"]}):h.jsxs(Tn.Secondary,{size:"small",disabled:a,onClick:()=>r(c.id),className:"shrink-0",children:["Connect",h.jsx(be,{name:"external-link",size:"0.75em",className:"ml-1"})]})]},c.id)),o&&h.jsx("div",{className:"flex justify-end pt-1",children:h.jsxs(Tn.Primary,{size:"small",disabled:a||n,onClick:o,className:"bg-gray-850 text-white hover:bg-gray-850 dark:text-black",children:[n?h.jsx(be,{name:"loader",className:"animate-spin"}):null,"Continue"]})})]})]})}function pQt({content:e,isStreaming:t=!1,expanded:n=!1,onToggle:r,isMultiLine:o=!1,reasoningTimeText:a,headingText:i="Reasoning",contentRef:s,dataTestPrefix:l,className:c}){const u=Ge("Markdown"),d=!t&&e.length>0&&!o,f=d||o||t,g=t?"running":e.length>0?"success":"idle",b=t?i:a??i,v=n&&e.length>0;return h.jsx("div",{className:pe("aui-reasoning-card mt-2 flex min-w-0 flex-col",c),"data-testid":l?`${l}-${d?"reasoning-inline":"reasoning-accordion"}`:void 0,children:h.jsx(Qk,{icon:t?"brain":"brain-regular",iconVariant:"primary",title:b,expandable:f,expanded:n,onToggle:r,status:g,dataTestPrefix:l,children:v&&h.jsx("div",{ref:s,className:"py-2 pt-0 font-sans text-sm font-normal text-text-secondary","data-testid":l?`${l}-content`:void 0,children:h.jsx(u,{content:e,className:"font-sans text-sm text-text-secondary"})})})})}var fQt="[[data-slot=step-tree-item]:has(~[data-branch=true]>[data-step-tree-content]:not(:empty))>*>&]:bottom-0 [[data-slot=step-tree-item]:has(~[data-branch=true]>[data-step-tree-content]:not(:empty))>*>&]:h-auto [[data-slot=step-tree-item]:has(~[data-branch=true]>[data-step-tree-content]:not(:empty))>*>&]:block";function hQt({children:e,branch:t=!0,continuesBelow:n=!1,branchesReachParentIcon:r=!1,className:o}){return h.jsxs("div",{"data-slot":"step-tree-item","data-branch":t?"true":"false",className:pe("relative flex min-w-0 has-[>[data-step-tree-content]:empty]:hidden",o),children:[h.jsxs("div",{className:pe("relative shrink-0 self-stretch",r?"w-7":"w-5"),children:[h.jsx("div",{className:pe("absolute top-0 left-[0.625rem] w-px -translate-x-1/2 bg-border",n?"bottom-0":pe(t?"h-[0.875rem]":"hidden",fQt))}),t&&h.jsx("div",{className:"absolute top-[0.875rem] right-0 left-[0.625rem] h-px bg-border"})]}),h.jsx("div",{"data-step-tree-content":!0,className:pe("min-w-0 flex-1",t&&"py-1 [&>*]:mt-0"),children:e})]})}function e6e(e){return _.Children.toArray(e).flatMap(t=>_.isValidElement(t)&&t.type===_.Fragment?e6e(t.props.children):[t])}function gQt({children:e,className:t,dataTestPrefix:n,branchesReachParentIcon:r=!1}){const o=Ge("StepTreeItem"),a=e6e(e);return a.length===0?null:h.jsx("div",{className:pe("flex min-w-0 flex-col",t),"data-slot":"step-tree","data-testid":n?`${n}-step-tree`:void 0,children:a.map((i,s)=>h.jsx(o,{branchesReachParentIcon:r,children:i},s))})}function mQt({code:e,language:t}){const n=Ge("SyntaxHighlighter"),r=O3();return h.jsx(n,{code:e,language:t,showLineNumbers:!0,darkTheme:r==="dark",className:"m-0 flex min-h-full flex-col rounded-none text-xs [&>pre]:flex-1"})}var sxe=100;function bQt(e){const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function vQt(e){const t=[];for(let n=0;n<e.length;n+=sxe)t.push(e.slice(n,n+sxe));return t}function Jk({resourceType:e,resourceIds:t}){const n=mXe(),r=JSON.stringify([...new Set(t.filter(b=>b.length>0))]),o=r!=="[]",a=`${e}:${r}`,i=_.useMemo(()=>bQt(r),[r]),s=_.useMemo(()=>new Set(i),[i]),[l,c]=_.useState({server:null,resourceType:null,key:"",data:{},loading:!1,error:null});_.useEffect(()=>{if(n==null||!o)return;let b=!1;return c(v=>v.server===n&&v.resourceType===e?{...v,key:a,loading:!0,error:null}:{server:n,resourceType:e,key:a,data:{},loading:!0,error:null}),Promise.all(vQt(i).map(v=>n.listPermissions({resourceType:e,resourceIds:v}))).then(v=>{b||c({server:n,resourceType:e,key:a,data:Object.assign({},...v.map(y=>y.data.permissions)),loading:!1,error:null})},v=>{b||c(y=>({server:n,resourceType:e,key:a,data:y.server===n&&y.resourceType===e?y.data:{},loading:!1,error:v}))}),()=>{b=!0}},[o,a,i,e,n]);const u=l.server===n&&l.resourceType===e,d=n!=null&&o&&(!u||l.key!==a||l.loading),f=u&&l.key===a?l.error:null,g=_.useCallback((b,v)=>n==null||b==null||b===""?!0:!s.has(b)||!u?!1:(l.data[b]??[]).includes(v),[s,u,n,l.data]);return{loading:d,error:f,allows:g}}var t6e=_.createContext(!0);function yQt({sessionId:e,assumeManage:t=!1,children:n}){const r=_.useMemo(()=>e==null?[]:[e],[e]),{allows:o}=Jk({resourceType:"session",resourceIds:r});return _.createElement(t6e.Provider,{value:t||o(e,"MANAGE")},n)}function _3(){return _.useContext(t6e)}var lxe=480,xQt=3e3,wQt="Request timed out",_Qt="The request took too long and was cancelled. Try again.",LJ=_.createContext(null),cxe=0;function uxe(){return cxe+=1,`toast-${cxe}`}function dxe(e){return e.length<=lxe?e:`${e.slice(0,lxe-1)}…`}function SQt(e){return e instanceof Error&&("statusCode"in e||"body"in e)}function kQt(e){if(FXe(e))return{title:wQt,description:_Qt};if(SQt(e)){const t=e.statusCode;if(t!=null||e.body!=null){const n=t!=null?`Request failed (${t})`:"Request failed",r=Oa(e,"The server returned an error.");return{title:n,description:dxe(r)}}}return{title:"Something went wrong",description:dxe(Oa(e,"An unexpected error occurred."))}}function n6e({children:e}){const t=Ge("Toast"),n=Ge("ToastStack"),[r,o]=_.useState([]),a=_.useCallback(c=>{o(u=>u.filter(d=>d.id!==c))},[]),i=_.useCallback(c=>{console.error("[trueforge-ui]",c);const u={id:uxe(),variant:"error",...kQt(c)};o(d=>[...d,u].slice(-5))},[]),s=_.useCallback(c=>{const u=uxe(),d={id:u,variant:"success",...c};o(f=>[...f,d].slice(-5)),typeof window<"u"&&window.setTimeout(()=>a(u),xQt)},[a]),l=_.useMemo(()=>({showError:i,showSuccess:s}),[i,s]);return h.jsxs(LJ.Provider,{value:l,children:[e,h.jsx(n,{children:r.map(c=>h.jsx(t,{title:c.title,description:c.description??"",variant:c.variant,open:!0,onOpenChange:u=>{u||a(c.id)}},c.id))})]})}function EQt(){const e=_.useContext(LJ);if(e==null)throw new Error("useToaster must be used within ToasterProvider");return e}function eE(){return _.useContext(LJ)}function r6e(e){var t,n;return{...e,model:{...e.model,params:e.model.params?{...e.model.params}:void 0},mcpServers:(t=e.mcpServers)==null?void 0:t.map(r=>({...r})),skills:(n=e.skills)==null?void 0:n.map(r=>({...r})),config:e.config?{...e.config}:void 0}}function vx({open:e,onOpenChange:t,children:n,className:r,"aria-label":o,"aria-labelledby":a}){const i=K.useRef(null);K.useEffect(()=>{const l=i.current;l&&(e&&!l.open?l.showModal():!e&&l.open&&l.close())},[e]),K.useEffect(()=>{const l=i.current;if(!l)return;const c=()=>t(!1);return l.addEventListener("close",c),()=>l.removeEventListener("close",c)},[t]);const s=l=>{l.target===i.current&&t(!1)};return h.jsx("dialog",{ref:i,"aria-label":o,"aria-labelledby":a,onClick:s,className:pe("m-auto max-h-[90dvh] w-full max-w-lg rounded-lg bg-card-bg p-0 text-text-primary shadow-lg","backdrop:bg-[var(--overlay)]","open:flex open:flex-col",r),children:n})}function tE({className:e,children:t,...n}){return h.jsx("div",{className:pe("flex flex-col gap-4 p-6",e),...n,children:t})}function S3({className:e,...t}){return h.jsx("div",{className:pe("flex flex-col gap-1.5",e),...t})}function k3({className:e,...t}){return h.jsx("h2",{className:pe("text-lg font-semibold leading-none tracking-tight",e),...t})}function zJ({className:e,...t}){return h.jsx("div",{className:pe("flex flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:justify-end",e),...t})}function o6e(e){return e.target===e.currentTarget}function Ep({trigger:e,children:t,align:n="end",side:r="bottom",className:o,containerClassName:a,open:i,onOpenChange:s,closeOnClick:l=!0,lockScroll:c=!1,captureOutsideClick:u=!1}){const[d,f]=_.useState(!1),g=i??d,b=_.useCallback(R=>{i===void 0&&f(R),s==null||s(R)},[i,s]),[v,y]=_.useState(null),w=_.useRef(null),S=_.useRef(null),E=_.useRef(!1),A=_.useId();_.useLayoutEffect(()=>{if(!g){y(null);return}const R=()=>{const N=w.current;if(!N)return;const O=N.getBoundingClientRect();y({top:r==="top"?O.top-4:O.bottom+4,left:n==="end"?O.right:O.left})};return R(),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R)}},[g,n,r]),_.useEffect(()=>{if(!g)return;const R=N=>{var P,j;const O=N.target;O instanceof Node&&((P=w.current)!=null&&P.contains(O)||(j=S.current)!=null&&j.contains(O)||b(!1))};return document.addEventListener("mousedown",R,u),()=>document.removeEventListener("mousedown",R,u)},[u,g,b]),_.useEffect(()=>{if(!g||!c)return;const R=N=>{var P;const O=N.target;O instanceof Node&&((P=S.current)!=null&&P.contains(O))||N.preventDefault()};return document.addEventListener("wheel",R,{passive:!1,capture:!0}),document.addEventListener("touchmove",R,{passive:!1,capture:!0}),()=>{document.removeEventListener("wheel",R,{capture:!0}),document.removeEventListener("touchmove",R,{capture:!0})}},[g,c]),_.useEffect(()=>{var N;if(!g){E.current=!1;return}if(v==null||E.current)return;const R=(N=S.current)==null?void 0:N.querySelector('[role="menuitem"]:not([disabled])');R==null||R.focus(),E.current=!0},[g,v]),_.useEffect(()=>{if(!g)return;const R=N=>{var D,z,L;if(N.key==="Escape"){N.preventDefault(),N.stopPropagation(),b(!1);const $=(D=w.current)==null?void 0:D.querySelector("[aria-haspopup='menu']");$==null||$.focus();return}if(N.key!=="ArrowDown"&&N.key!=="ArrowUp"&&N.key!=="Home"&&N.key!=="End")return;const O=Array.from(((z=S.current)==null?void 0:z.querySelectorAll('[role="menuitem"]:not([disabled])'))??[]);if(O.length===0)return;N.preventDefault();const P=O.indexOf(document.activeElement);let j=P;N.key==="ArrowDown"?j=(P+1)%O.length:N.key==="ArrowUp"?j=(P-1+O.length)%O.length:N.key==="Home"?j=0:N.key==="End"&&(j=O.length-1),(L=O[j])==null||L.focus()};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[g,b]);const T=K.isValidElement(e)?K.cloneElement(e,{"aria-haspopup":"menu","aria-expanded":g,"aria-controls":g?A:void 0,onKeyDown:R=>{const N=e.props.onKeyDown;N==null||N(R),(R.key==="ArrowDown"||R.key==="Enter"||R.key===" ")&&(R.preventDefault(),b(!0))}}):e,C=g&&v!=null?Ui.createPortal(h.jsx("div",{ref:S,id:A,role:"menu",style:{top:v.top,left:v.left,transform:[n==="end"?"translateX(-100%)":null,r==="top"?"translateY(-100%)":null].filter(R=>R!==null).join(" ")||void 0},className:pe("aui-popup-enter fixed z-[200] flex min-w-[8rem] flex-col overscroll-contain rounded-md border border-border bg-card-bg p-1","text-text-primary shadow-md",o),onMouseDown:R=>R.stopPropagation(),onClick:l?R=>{o6e(R)||b(!1)}:void 0,children:t}),w3(w.current)):null;return h.jsxs("div",{ref:w,className:pe("relative inline-flex",a),children:[h.jsx("div",{className:"contents",onClick:()=>b(!g),children:T}),C]})}function pu({className:e,...t}){return h.jsx("button",{role:"menuitem",type:"button",className:pe("flex w-full cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","transition-colors hover:bg-ghost-button-hover","focus-visible:bg-dropdown-selected-item-bg focus-visible:text-dropdown-selected-item-text","aria-selected:bg-dropdown-selected-item-bg aria-selected:text-dropdown-selected-item-text","disabled:pointer-events-none disabled:opacity-50",e),...t})}function a6e({className:e,...t}){return h.jsx("div",{role:"separator",className:pe("-mx-1 my-1 h-px bg-border",e),...t})}function $J(e,t,n=!1){const[r,o]=_.useState();return _.useLayoutEffect(()=>{var l;if(!t){o(void 0);return}const a=(l=e.current)==null?void 0:l.closest("[data-aui-compact-layout]");if(!a)return;const i=()=>{const c=a.getBoundingClientRect(),u=Math.min(c.height*.85,480);o({left:c.left,bottom:window.innerHeight-c.bottom,width:c.width,height:n?"fit-content":u,maxHeight:u})};i();const s=typeof ResizeObserver=="function"?new ResizeObserver(i):null;return s==null||s.observe(a),window.addEventListener("resize",i),()=>{s==null||s.disconnect(),window.removeEventListener("resize",i)}},[t,n,e]),r}var TQt={sm:"md:w-80",md:"md:w-[28rem]",lg:"md:w-[36rem]",xl:"md:w-[42rem]"};function E3({open:e,onOpenChange:t,title:n,description:r,titleAccessory:o,headerIcon:a,headerActions:i,children:s,footer:l,anchor:c="right",size:u="md",className:d,"aria-label":f}){const g=_.useRef(null),b=_.useId(),v=_.useId(),y=pp(),w=$J(g,y);return _.useEffect(()=>{const S=g.current;S&&(e&&!S.open?S.showModal():!e&&S.open&&S.close())},[e]),_.useEffect(()=>{const S=g.current;if(!S)return;const E=()=>t(!1);return S.addEventListener("close",E),()=>S.removeEventListener("close",E)},[t]),h.jsxs("dialog",{ref:g,"aria-label":f??n,"aria-labelledby":b,"aria-describedby":r?v:void 0,closedby:"closerequest",onCancel:S=>{S.preventDefault(),S.stopPropagation(),t(!1)},style:w,"data-anchor":c,"data-compact":y?"":void 0,className:pe("aui-side-drawer bg-card-bg text-text-primary border-border open:flex open:flex-col overflow-hidden rounded-none p-0 shadow-xl","backdrop:bg-black/50 backdrop:backdrop-blur-[2px] dark:backdrop:bg-black/70",y?"m-0 mt-auto h-[min(85dvh,40rem)] w-full max-w-none border-t pb-[env(safe-area-inset-bottom)]":pe("m-0 mt-auto h-[min(85dvh,40rem)] w-full max-w-none border-t pb-[env(safe-area-inset-bottom)]","md:mt-0 md:h-dvh md:max-h-none md:border md:pb-0",TQt[u],c==="right"?"md:ml-auto md:mr-0 md:border-y-0 md:border-r-0":"md:mr-auto md:ml-0 md:border-y-0 md:border-l-0"),d),children:[h.jsxs("header",{className:"bg-topbar-bg flex shrink-0 items-start gap-3 border-b border-border px-5 py-4",children:[a,h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-1.5",children:[h.jsx("h2",{id:b,className:"text-text-primary text-lg font-semibold tracking-tight",children:n}),o]}),r?h.jsx("p",{id:v,className:"text-text-secondary mt-1 text-sm",children:r}):null]}),i,h.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:rn({variant:"ghost",size:"icon"}),onClick:()=>t(!1),children:h.jsx(be,{name:"xmark"})})]}),h.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",children:s}),l?h.jsx("div",{className:"shrink-0 border-t border-border px-5 py-3",children:l}):null]})}function AQt(e){return`${e}-clone`}var CQt="No permission to create agents";function i6e({agentName:e,description:t,agentSpec:n,canMutate:r,canUse:o=!0,canManage:a=!0,canDelete:i=!0,canManageSchedules:s,onEdit:l,onManageSchedules:c,onDeleted:u}){const d=Za(),f=go(),g=eE(),b=Ge("PermissionGuard"),v=Ge("SaveAgentForm"),{canCreateAgent:y,loading:w}=Wke(),S=y&&!w,[E,A]=_.useState(!1),[T,C]=_.useState(!1),[R,N]=_.useState(""),[O,P]=_.useState(""),[j,D]=_.useState(null),[z,L]=_.useState(null),[$,U]=_.useState(!1),B=r&&n!=null,V=s&&c!=null;if(!(B||V||r))return null;const F=()=>{$||A(!1)},Z=()=>{$||(C(!1),D(null),L(null))},J=()=>{n==null||!S||(N(AQt(e)),P((t==null?void 0:t.trim())||e),D(r6e(n)),L(null),C(!0))},W=async()=>{if(!S||d==null||j==null)return;const q=R.trim(),ne=O.trim();if(!(!q||!ne||!j.model.name.trim())){U(!0),L(null);try{await d.saveAgent({agentName:q,description:ne,agentSpec:j,intent:"create"}),f==null||f.invalidateAgentsList(),g==null||g.showSuccess({title:"Agent cloned",description:`Created “${q}”.`}),C(!1),D(null)}catch(he){L(Oa(he,"Could not clone agent"))}finally{U(!1)}}},Y=async()=>{if(!(!i||d==null||typeof d.deleteAgent!="function")){A(!1),U(!0);try{await d.deleteAgent({agentName:e}),f==null||f.invalidateAgentsList(),g==null||g.showSuccess({title:"Agent deleted",description:`“${e}” was deleted.`}),u==null||u()}catch(q){g==null||g.showError(q)}finally{U(!1)}}};return h.jsxs(h.Fragment,{children:[h.jsxs(Ep,{align:"end",className:"min-w-48",trigger:h.jsx("button",{type:"button",className:rn({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${e}`,children:h.jsx(be,{name:"ellipsis-vertical"})}),children:[B?h.jsx(b,{allowed:a,children:h.jsxs(pu,{className:"whitespace-nowrap",onClick:()=>{a&&l()},children:[h.jsx(be,{name:"pencil",className:"size-3.5"}),"Edit"]})}):null,B?h.jsx(b,{allowed:S,deniedMessage:CQt,children:h.jsxs(pu,{className:"whitespace-nowrap",onClick:()=>{S&&J()},children:[h.jsx(be,{name:"clone",className:"size-3.5"}),"Clone"]})}):null,V?h.jsx(b,{allowed:o,children:h.jsxs(pu,{className:"whitespace-nowrap",onClick:()=>{o&&(c==null||c())},children:[h.jsx(be,{name:"calendar-clock",className:"size-3.5"}),"Manage Schedules"]})}):null,r?h.jsxs(h.Fragment,{children:[B||V?h.jsx(a6e,{}):null,h.jsx(b,{allowed:i,children:h.jsxs(pu,{className:"whitespace-nowrap text-failure-bg focus-visible:text-failure-bg",onClick:()=>{i&&A(!0)},children:[h.jsx(be,{name:"trash",className:"size-3.5"}),"Delete"]})})]}):null]}),h.jsx(E3,{open:T,onOpenChange:q=>!q&&Z(),title:"Clone Agent",anchor:"right",size:"md","aria-label":"Clone Agent",children:j!=null?h.jsx(v,{intent:"create",name:R,description:O,spec:j,saving:$,error:z,onNameChange:N,onDescriptionChange:P,onCancel:Z,onSave:()=>void W()}):null}),E?h.jsxs(vx,{open:!0,onOpenChange:q=>!q&&F(),"aria-label":"Delete agent",className:"max-w-md",children:[h.jsx(tE,{children:h.jsxs(S3,{children:[h.jsx(k3,{children:"Delete agent"}),h.jsxs("p",{className:"text-text-secondary text-sm",children:["“",e,"” will be permanently deleted, including any schedules for this agent. This cannot be undone."]})]})}),h.jsxs(zJ,{children:[h.jsx(Tn.Secondary,{type:"button",disabled:$,onClick:F,children:"Cancel"}),h.jsx(Tn.Destructive,{type:"button",disabled:$||!i||d==null||typeof d.deleteAgent!="function",onClick:()=>void Y(),children:"Delete"})]})]}):null]})}function RQt({agentId:e,detail:t,onBack:n}){const r=_m(),o=Za(),{allows:a}=Jk({resourceType:"agent",resourceIds:[e]}),i=r.isComposerEnabled&&t!=null&&o!=null,s=a(e,"USE"),l=a(e,"MANAGE"),c=a(e,"DELETE"),u=Ge("PermissionGuard"),d=()=>{!s||t==null||r.selectLibraryAgent({isMutable:!1,agentId:t.agentId,agentName:t.name})},f=()=>{!l||t==null||r.selectLibraryAgent({isMutable:!0,isCreateAgent:!0,agentId:t.agentId,agentName:t.name,...t.description===void 0?{}:{description:t.description},agentSpec:t.agentSpec})};return h.jsx(WH,{className:"bg-primary-bg",start:h.jsx("button",{type:"button","aria-label":"Back to Agents",title:"Back to Agents",className:rn({variant:"ghost",size:"icon"}),onClick:n,children:h.jsx(be,{name:"arrow-left"})}),title:h.jsxs("div",{className:pe("flex min-w-0 items-center gap-1",rAe),children:[h.jsx("button",{type:"button",className:"cursor-pointer truncate hover:text-text-primary",onClick:n,children:"Agents"}),h.jsx(be,{name:"chevron-right",className:"size-3 shrink-0"}),h.jsx("span",{className:"truncate",children:(t==null?void 0:t.name)??e})]}),end:h.jsxs(h.Fragment,{children:[h.jsx(u,{allowed:s,children:h.jsxs(Tn.Primary,{type:"button","aria-label":"Try agent",size:"large",disabled:t==null,onClick:d,children:[h.jsx(be,{name:"play",className:"size-3.5"}),"Try"]})}),t!=null?h.jsx(i6e,{agentName:t.name,...t.description===void 0?{}:{description:t.description},agentSpec:t.agentSpec,canMutate:i,canUse:s,canManage:l,canDelete:c,canManageSchedules:!1,onEdit:f,onDeleted:n}):null]})})}function IQt(e){return window.addEventListener("popstate",e),window.addEventListener(M9,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(M9,e)}}function NQt(){return window.location.search}function MQt(){return""}function T3(){const e=_.useSyncExternalStore(IQt,NQt,MQt),t=_.useCallback(n=>{O9(n)},[]);return{...Nd(e),updateShareSearch:t}}function n2({title:e,description:t,className:n}){return h.jsxs("div",{role:"status",className:pe("flex h-full min-h-0 w-full flex-1 flex-col items-center justify-center gap-4 px-6 py-16",n),children:[h.jsx(be,{name:"empty",size:48,className:"shrink-0","aria-hidden":!0}),h.jsxs("div",{className:"flex max-w-md flex-col items-center gap-1.5 text-center",children:[h.jsx("h2",{className:"text-base font-semibold text-text-primary",children:e}),t!=null?h.jsx("p",{className:"text-sm text-text-secondary",children:t}):null]})]})}function pxe({children:e}){return h.jsx("span",{className:"mx-0.5 inline-flex max-w-full truncate rounded-full bg-secondary-bg px-2 py-0.5 align-middle font-mono text-xs text-text-primary",children:e})}function fxe(){return h.jsx(n2,{title:"Best viewed on desktop",description:"This page works best on a larger screen. Open the same link on a desktop browser to continue."})}function da({className:e,...t}){return h.jsx("div",{className:pe("animate-pulse rounded-md bg-secondary-bg",e),...t})}function OQt({agentId:e}){const t=N0(),n=Yke(),r=YN(),o=_m(),a=km(),i=T3(),s=us(),{updateShareSearch:l}=i,c=yXe(i,e),u=wXe({metrics:n}),d=uk({schedules:r}),f=c==="metrics"&&!u||c==="schedules"&&!d?"overview":c,g=Ge("AgentDetailsHeader"),b=Ge("AgentDetailsTabs"),v=Ge("AgentDetailsUnavailable"),y=Ge("AgentOverview"),w=Ge("AgentSessions"),S=Ge("SchedulesPage"),E=Ge("AgentMetrics"),A=Ge("AgentMetricsTimeRangeFilter"),T=Ge("AgentCodeSnippets"),[C,R]=_.useState(),[N,O]=_.useState(!1),[P,j]=_.useState(),[D,z]=_.useState(!1),[L,$]=_.useState(Zke),U=_.useCallback(()=>{l({sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),o.closeLibraryAgent()},[o,l]);_.useEffect(()=>{s(io.AgentDetails.OPENED,{agent_id:e})},[]),_.useEffect(()=>{const V=G=>{G.key==="Escape"&&(aAe()||(G.stopImmediatePropagation(),U()))};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[U]),_.useEffect(()=>{if(t==null)return;let V=!1;return t.getAgent({agentId:e}).then(G=>{V||R(G)},()=>{V||O(!0)}),()=>{V=!0}},[e,t]),_.useEffect(()=>{if(f!=="code"||t==null||P!==void 0||D)return;let V=!1;return t.getCodeSnippets({agentId:e}).then(G=>{V||j(G)},()=>{V||z(!0)}),()=>{V=!0}},[f,e,t,P,D]);let B;return t==null?B=h.jsx(v,{onBack:U,reason:"This host does not provide agent details. Return to the library to choose an agent."}):N?B=h.jsx(v,{onBack:U}):C==null?B=h.jsxs("div",{className:"grid min-h-0 gap-3 overflow-auto p-4 md:grid-cols-[minmax(0,1fr)_22rem]",role:"status","aria-label":"Loading agent details",children:[h.jsx(da,{className:"min-h-80 rounded-lg"}),h.jsx("div",{className:"space-y-3",children:["mcp","skills","model","execution"].map(V=>h.jsx(da,{className:"h-24 rounded-lg"},V))})]}):f==="overview"?B=h.jsx(y,{detail:C}):f==="sessions"?B=a?h.jsx(fxe,{}):h.jsx(w,{agentId:e}):f==="schedules"?B=a?h.jsx(fxe,{}):h.jsx(S,{agentId:e}):f==="metrics"?B=h.jsx(E,{agentId:e,timeRange:L,onTimeRangeChange:$,showTimeRangeFilter:!1}):D?B=h.jsx(v,{onBack:U,reason:"Code samples for this agent could not be loaded."}):P===void 0?B=h.jsxs("div",{className:"flex min-h-64 gap-3 p-3",role:"status","aria-label":"Loading code samples",children:[h.jsx(da,{className:"hidden w-44 shrink-0 rounded-lg md:block"}),h.jsx(da,{className:"min-h-64 min-w-0 flex-1 rounded-lg"})]}):B=h.jsx(T,{snippets:P}),h.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[h.jsx(g,{agentId:e,detail:C,onBack:U}),t!=null&&!N?h.jsx(b,{activeTab:f,showMetrics:u,showSchedules:d,end:f==="metrics"?h.jsx(A,{timeRange:L,onTimeRangeChange:$}):null,onTabChange:V=>{s(io.AgentDetails.TAB_CHANGED,{agent_id:e,tab:V}),l({agentId:e,tab:V,view:null,timeRange:null,...V==="sessions"?{}:{sessionId:null}})}}):null,h.jsx("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",role:"tabpanel",children:h.jsx(_.Suspense,{fallback:h.jsx("div",{className:"p-4",role:"status","aria-label":"Loading",children:h.jsx(da,{className:"min-h-64 rounded-lg"})}),children:B})})]})}var PQt=[{id:"overview",label:"Overview",icon:"info"},{id:"sessions",label:"Sessions",icon:"message-square-text"},{id:"schedules",label:"Schedules",icon:"calendar-clock"},{id:"code",label:"Use In Code",icon:"code"},{id:"metrics",label:"Metrics",icon:"chart"}];function jQt({activeTab:e,onTabChange:t,showMetrics:n=!1,showSchedules:r=!1,end:o}){return h.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-primary-bg px-3",children:[h.jsx("div",{role:"tablist","aria-label":"Agent details",className:"flex min-w-0 flex-1 gap-1 overflow-x-auto",children:PQt.filter(a=>(a.id!=="metrics"||n)&&(a.id!=="schedules"||r)).map(a=>h.jsxs("button",{type:"button",role:"tab","aria-selected":e===a.id,"aria-current":e===a.id?"page":void 0,className:pe("relative flex h-10 shrink-0 cursor-pointer items-center gap-1.5 px-2 text-xs font-medium text-text-secondary","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",e===a.id&&"text-primary-button-bg after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-primary-button-bg"),onClick:()=>t(a.id),children:[h.jsx(be,{name:a.icon,className:"size-3.5"}),a.label]},a.id))}),o!=null?h.jsx("div",{className:"ml-auto shrink-0 pl-2",children:o}):null]})}function DQt({onBack:e,reason:t}){return h.jsxs("div",{className:"flex h-full min-h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[h.jsx("span",{className:"flex size-11 items-center justify-center rounded-full bg-secondary-bg text-text-secondary",children:h.jsx(be,{name:"circle-exclamation"})}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-base font-semibold text-text-primary",children:"Agent details unavailable"}),h.jsx("p",{className:"mt-1 max-w-md text-sm text-text-secondary",children:t??"The agent details could not be loaded. Please try again later."})]}),h.jsxs(Tn.Secondary,{type:"button",size:"small",onClick:e,children:[h.jsx(be,{name:"arrow-left",className:"size-3.5"}),"Back to Agents"]})]})}function tu(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Kw(e){const t=Math.trunc(e),n=t<0?"-":"",r=String(Math.abs(t));return`${n}${r.replace(/\B(?=(\d{3})+(?!\d))/g,",")}`}function nE(e){return`$${e.toFixed(4)}`}function s6e(e){return e<6e4?`${(e/1e3).toFixed(2)}s`:e<36e5?`${(e/6e4).toFixed(2)}m`:`${(e/36e5).toFixed(2)}h`}function LQt(e){return Math.max(0,Math.round(e/1e3)*1e3)}function l6e(e){const t=LQt(e)/1e3,n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),a=t%60;return[...n>0?[`${n}d`]:[],...r>0?[`${r}h`]:[],...o>0?[`${o}m`]:[],...a>0||t===0?[`${a}s`]:[]].join(" ")}function zQt(e){return[`${e.totalTurns} turns`,...e.totalCostInUsd==null?[]:[nE(e.totalCostInUsd)],l6e(e.totalDurationMs)].join(" | ")}var $Qt=new Intl.NumberFormat(void 0,{maximumFractionDigits:4});function UQt(e,t){return t==="$"?nE(e):t==="ms"?s6e(e):`${$Qt.format(e)}${t==="count"||t.length===0?"":` ${t}`}`}function FQt({meter:e}){const t=e.unit==="$";return h.jsxs("section",{className:pe("flex min-w-0 flex-col rounded-xl border border-l-4 border-border bg-card-bg p-3 shadow-sm",t?"border-l-success-bg":"border-l-primary-button-bg"),"data-slot":"agent-metric-card",children:[h.jsxs("div",{className:"flex w-full min-w-0 items-start justify-between gap-3",children:[h.jsx("h3",{className:"truncate text-sm font-medium text-text-secondary",title:e.description,children:e.description}),h.jsx("span",{className:pe("flex size-9 shrink-0 items-center justify-center rounded-lg text-sm font-semibold",t?"bg-success-bg/10 text-success-bg":"bg-primary-button-bg/10 text-primary-button-bg"),"aria-hidden":!0,children:h.jsx(be,{name:t?"dollar-sign":"message-square-text",className:"size-6"})})]}),h.jsx("p",{className:"text-4xl font-bold tabular-nums text-text-primary",children:UQt(e.aggregateValue,e.unit)})]})}function BQt({timeRange:e,onTimeRangeChange:t}){const n=Ge("AgentSessionsFilters");return h.jsx(n,{agentId:null,timeRange:e,onAgentChange:()=>{},onTimeRangeChange:t,showAgentFilter:!1,showCustomTimeRange:!1})}var HQt=["total_cost_in_usd","cost_per_session_in_usd","total_sessions","avg_turns_per_session"],VQt=new Set(["total_turns","min_turns_per_session","median_turns_per_session","max_turns_per_session","min_session_duration_ms","median_session_duration_ms","p95_session_duration_ms","max_session_duration_ms"]),GQt=new Intl.NumberFormat(void 0,{maximumFractionDigits:3});function WQt({meter:e,durationInSeconds:t}){return e==null?"—":GQt.format(t?e.aggregateValue/1e3:e.aggregateValue)}function KQt({meters:e}){const t=new Map(e.map(r=>[r.name,r])),n=[{ariaLabel:"Turn statistics",gridClassName:"grid-cols-4",durationInSeconds:!1,items:[{label:"Total turns",meter:t.get("total_turns"),prominent:!0,highlighted:!1},{label:"Min",meter:t.get("min_turns_per_session"),prominent:!1,highlighted:!1},{label:"Median",meter:t.get("median_turns_per_session"),prominent:!1,highlighted:!0},{label:"Max",meter:t.get("max_turns_per_session"),prominent:!1,highlighted:!1}]},{ariaLabel:"Duration statistics",gridClassName:"grid-cols-5",durationInSeconds:!0,items:[{label:"Duration (s)",meter:t.get("median_session_duration_ms"),prominent:!0,highlighted:!1},{label:"Min",meter:t.get("min_session_duration_ms"),prominent:!1,highlighted:!1},{label:"Median",meter:t.get("median_session_duration_ms"),prominent:!1,highlighted:!0},{label:"P95",meter:t.get("p95_session_duration_ms"),prominent:!1,highlighted:!0},{label:"Max",meter:t.get("max_session_duration_ms"),prominent:!1,highlighted:!1}]}].filter(r=>r.items.some(o=>o.meter!=null));return h.jsx("div",{className:"grid gap-4 lg:grid-cols-2","data-slot":"agent-metric-statistics",children:n.map(r=>h.jsx("section",{"aria-label":r.ariaLabel,className:"min-w-0 rounded-xl border border-border bg-card-bg p-4 shadow-sm",children:h.jsx("dl",{className:`grid ${r.gridClassName} divide-x divide-border`,children:r.items.map(o=>{const a=WQt({meter:o.meter,durationInSeconds:r.durationInSeconds});return h.jsxs("div",{className:`min-w-0 px-3 first:pl-0 last:pr-0 ${o.prominent?"":"text-center"}`,children:[h.jsx("dt",{className:"truncate text-sm font-medium text-text-secondary",children:o.label}),h.jsx("dd",{className:`truncate font-bold tabular-nums ${o.prominent?"text-3xl":"text-base mt-1.5"} ${o.highlighted?"text-primary-button-bg":"text-text-primary"}`,title:a,children:a})]},o.label)})})},r.ariaLabel))})}function YQt({meters:e,meterError:t,charts:n,chartsLoading:r,chartsError:o,timeRange:a,onTimeRangeChange:i,showTimeRangeFilter:s=!0}){const l=Ge("AgentMetricCard"),c=Ge("AgentMetricChart"),u=Ge("AgentMetricStatistics"),d=Ge("AgentMetricsTimeRangeFilter"),f=e==null?void 0:HQt.flatMap(b=>{const v=e.find(y=>y.name===b);return v==null?[]:[v]}),g=(e==null?void 0:e.some(b=>VQt.has(b.name)))??!1;return h.jsxs("div",{className:"min-h-0 flex-1 overflow-auto bg-secondary-bg/40 p-4","data-slot":"agent-metrics-view",children:[s?h.jsx("div",{className:"mb-4 flex justify-end",children:h.jsx(d,{timeRange:a,onTimeRangeChange:i})}):null,t!=null?h.jsx("div",{className:"mb-4 rounded-lg border border-failure-bg/30 bg-failure-bg/10 p-3 text-sm text-failure-bg",children:t}):e==null?h.jsxs("div",{className:"mb-4 grid gap-4","aria-label":"Loading metrics",children:[h.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:Array.from({length:4},(b,v)=>h.jsx(da,{className:"h-20 rounded-lg"},v))}),h.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:Array.from({length:2},(b,v)=>h.jsx(da,{className:"h-20 rounded-lg"},v))})]}):(f==null?void 0:f.length)===0&&!g?h.jsx("div",{className:"mb-4 rounded-lg border border-border bg-card-bg p-6 text-center text-sm text-text-secondary",children:"No aggregate metrics"}):h.jsxs("div",{className:"mb-3 grid gap-3",children:[f!=null&&f.length>0?h.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:f.map(b=>h.jsx(l,{meter:b},b.name))}):null,g?h.jsx(u,{meters:e}):null]}),o!=null?h.jsx("div",{className:"rounded-lg border border-failure-bg/30 bg-failure-bg/10 p-3 text-sm text-failure-bg",children:o}):r&&n.length===0?h.jsx("div",{className:"grid gap-4 lg:grid-cols-2","aria-label":"Loading metric charts",children:Array.from({length:2},(b,v)=>h.jsx(da,{className:"h-80 rounded-lg"},v))}):n.length===0?h.jsx("div",{className:"rounded-lg border border-border bg-card-bg p-6 text-center text-sm text-text-secondary",children:"No charts available"}):h.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:n.flatMap(b=>b.graphs!=null&&b.graphs.length>0?b.graphs.map(v=>({definition:b.definition,graph:v,error:b.error})):[{definition:b.definition,error:b.error}]).map(({definition:b,graph:v,error:y},w)=>h.jsx(c,{definition:b,error:y,colorIndex:w,...v==null?{}:{graph:v}},v==null?b.name:`${b.name}:${v.name}`))})]})}function ZQt({title:e,icon:t,count:n,children:r}){return h.jsxs("section",{className:"rounded-lg border border-border bg-card-bg p-3 text-text-primary",children:[h.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-xs font-semibold",children:[t?h.jsx(be,{name:t,className:"size-3.5 text-text-secondary"}):null,e,n!==void 0?h.jsxs("span",{className:"text-text-secondary",children:["(",n,")"]}):null]}),r]})}function hxe({disabled:e}){return h.jsxs("button",{type:"button",disabled:e,className:rn({variant:"secondary",size:"large"}),children:[h.jsx(be,{name:"share"}),"Share"]})}function XQt({title:e,sessionId:t,onClose:n,metadata:r,resumeHref:o,onResume:a,resumeLabel:i,canResume:s=!0,canShare:l=!0}){const c=Ge("PermissionGuard"),u=Ge("ShareSessionDialog"),d=r!=null&&Object.keys(r).length>0;return h.jsxs("div",{className:"flex shrink-0 flex-col border-b border-border",children:[h.jsxs("div",{className:"flex shrink-0 items-center gap-3 p-3",children:[h.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 pb-0.5",children:[h.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold leading-none text-text-primary",children:e}),h.jsx("code",{className:"min-w-0 truncate font-mono text-xs leading-none text-text-secondary",children:t})]}),l?h.jsx(u,{sessionId:t,trigger:h.jsx(hxe,{})}):h.jsx(c,{allowed:!1,children:h.jsx(hxe,{})}),i!=null&&o!=null&&s?h.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:rn({variant:"secondary",size:"large"}),children:[i,h.jsx(be,{name:"square-arrow-out-up-right",className:"shrink-0"})]}):i!=null&&o!=null?h.jsx(c,{allowed:!1,children:h.jsxs(Tn.Secondary,{type:"button",size:"large",children:[i,h.jsx(be,{name:"square-arrow-out-up-right",className:"shrink-0"})]})}):i!=null&&a!=null?h.jsx(c,{allowed:s,children:h.jsx(Tn.Secondary,{type:"button",size:"large",onClick:()=>{s&&a()},children:i})}):null,h.jsx("button",{type:"button","aria-label":"Close session details",className:pe("inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-secondary","hover:bg-ghost-button-hover hover:text-text-primary"),onClick:n,children:h.jsx(be,{name:"xmark",className:"size-4"})})]}),d?h.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-border px-3 py-2","data-slot":"session-metadata-tags",children:Object.entries(r).map(([f,g])=>h.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2.5 py-1 text-xs",children:[h.jsx(be,{name:"tag",className:"size-3 shrink-0 text-text-secondary"}),h.jsx("span",{className:"shrink-0 font-mono text-text-secondary",children:f}),h.jsx("span",{className:"truncate font-mono font-medium text-text-primary",title:g,children:g})]},f))}):null]})}function c6e(e){return e.subjectDisplayName||e.subjectId}function Zvn(e){return e.some(t=>t.createdBySubject!=null)}var u6e=_.createContext(void 0);function qQt({currentUser:e,children:t}){return h.jsx(u6e.Provider,{value:e,children:t})}function d6e(){return _.useContext(u6e)}var QQt={sm:"h-5 w-5 text-[0.625rem] leading-none",default:"h-8 w-8 text-sm leading-none",lg:"h-10 w-10 text-base leading-none"};function rE({className:e,size:t="default",...n}){return h.jsx("div",{"data-slot":"avatar","data-size":t,className:pe("relative flex shrink-0 overflow-hidden rounded-full",QQt[t],e),...n})}function JQt({className:e,src:t,alt:n="",onError:r,...o}){const[a,i]=_.useState(!1);return a||!t?null:h.jsx("img",{"data-slot":"avatar-image",src:t,alt:n,className:pe("aspect-square h-full w-full object-cover",e),onError:s=>{i(!0),r==null||r(s)},...o})}function oE({className:e,...t}){return h.jsx("div",{"data-slot":"avatar-fallback",className:pe("flex h-full w-full items-center justify-center rounded-full bg-gradient-to-br from-primary-button-bg/20 to-primary-button-bg/10 font-medium text-primary-button-bg dark:from-primary-button-bg dark:to-primary-button-hover dark:text-primary-button-text",e),...t})}function A3(e){const t=Array.from(e.trim())[0];return t===void 0?"":t.toLocaleUpperCase()}function eJt({labeled:e=!1,className:t}){const n=d6e(),r=n==null?void 0:n.displayName.trim();return r?h.jsxs("div",{"data-slot":"user-avatar","aria-label":r,title:r,className:pe("flex min-w-0 shrink-0 flex-col items-center justify-center gap-0.5 text-text-secondary",e?"w-14.5":"max-w-20",t),children:[h.jsx(rE,{size:"sm",children:h.jsx(oE,{children:A3(r)})}),h.jsx("span",{className:"w-full truncate text-center text-[0.625rem] leading-tight",children:r})]}):null}function p6e(e,{seconds:t=!1}={}){const n={month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};return t&&(n.second="2-digit"),new Intl.DateTimeFormat(void 0,n).format(e)}function Xvn(e,{fallback:t="—",nowMs:n=Date.now()}={}){if(e==null)return t;const r=Date.parse(e);if(Number.isNaN(r))return t;const o=Math.round((n-r)/1e3);if(o<60)return"just now";const a=Math.round(o/60);if(a<60)return`${String(a)} min ago`;const i=Math.round(a/60);if(i<48)return`${String(i)} hour${i===1?"":"s"} ago`;const s=Math.round(i/24);return`${String(s)} day${s===1?"":"s"} ago`}var qvn=50,tJt=new Set(Object.values(zt));function nJt(e){return typeof e=="string"&&tJt.has(e)}var rJt=2880*60*1e3;function oJt(e){return!Number.isNaN(e.getTime())}function f6e({status:e,activityAt:t,now:n=new Date}){switch(e){case"paused":return t!=null&&oJt(t)&&n.getTime()-t.getTime()>rJt?void 0:"bg-warning-bg";default:return}}function h6e(e){switch(e){case"running":return"Running";case"paused":return"Waiting for input";case"error":return"Failed";default:return}}function g6e(e){return e==="running"}function m6e(e){return e==="paused"}function b6e(e,t=new Date){const n=Math.max(0,t.getTime()-e.getTime()),r=Math.floor(n/6e4);if(r<60)return`${Math.max(1,r)}m`;const o=Math.floor(r/60);if(o<24)return`${o}h`;const a=Math.floor(o/24);if(a<7)return`${a}d`;const i=Math.floor(a/7);if(i<5)return`${i}w`;const s=Math.floor(a/30);return s<12?`${s}mo`:`${Math.floor(a/365)}y`}function Qvn({threadIds:e,threadItems:t}){var r;const n=new Map;for(const o of t){const a=((r=o.lastMessageAt)==null?void 0:r.getTime())??Number.POSITIVE_INFINITY;n.set(o.id,a),o.remoteId!=null&&n.set(o.remoteId,a)}return e.map((o,a)=>({index:a,t:n.get(o)??0})).sort((o,a)=>a.t-o.t||o.index-a.index).map(o=>o.index)}function aJt(e){if(e==null||typeof e!="object"||!("agentName"in e))return;const t=Reflect.get(e,"agentName");return typeof t=="string"&&t.length>0?t:void 0}function iJt(e){if(e==null||typeof e!="object"||!("isMutable"in e))return;const t=Reflect.get(e,"isMutable");return typeof t=="boolean"?t:void 0}function Jvn(e){if(e==null||typeof e!="object"||!("lastActivityAt"in e))return;const t=Reflect.get(e,"lastActivityAt");if(typeof t!="string")return;const n=new Date(t);return Number.isNaN(n.getTime())?void 0:n}function eyn(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?!1:t==null||Number.isNaN(t.getTime())?!0:n.getTime()>t.getTime()}function tyn(e,t){return e==null||Number.isNaN(e.getTime())?t!=null&&!Number.isNaN(t.getTime())?t:void 0:t==null||Number.isNaN(t.getTime())?e:t.getTime()>e.getTime()?t:e}function nyn(e){if(e==null||typeof e!="object"||!("lastTurnStatus"in e))return;const t=Reflect.get(e,"lastTurnStatus");return nJt(t)?t:void 0}function ryn(e,t,n){const r=e!=null&&typeof e=="object"&&!Array.isArray(e)?Object.fromEntries(Object.entries(e)):{};return Reflect.deleteProperty(r,"lastTurnStatus"),t!=null&&(r.lastTurnStatus=t),n!=null&&(r.lastActivityAt=n),r}function oyn(e){return iJt(e)??aJt(e)==null}function ayn({sessionMutable:e,shellMutable:t,shellAgentName:n,shellAgentId:r,remoteId:o,pendingSessionId:a}){return!e||!t?!1:n!=null&&n!==""||r!=null&&r!==""?o!=null&&o===a:!0}function sJt({title:e,agentName:t,scheduleId:n,lastActivityAt:r,lastTurnStatus:o,metrics:a,createdBySubject:i,active:s,onSelect:l,onRequestDelete:c,canDelete:u=!0,onOpenSchedule:d,loadScheduleName:f}){const g=Ge("PermissionGuard"),[b,v]=_.useState({status:"idle",name:null}),y=b.status==="loading"||b.status==="idle"&&f!=null,w=()=>{b.status!=="idle"||f==null||n==null||(v({status:"loading",name:null}),f(n).then(D=>v({status:"done",name:D})))},S=new Date(r),E=b6e(S),A=p6e(S),T=i!=null?c6e(i):null,C=T!=null?A3(T)||"?":null,R=f6e({status:o,activityAt:S}),N=o==="error",O=h6e(o),P=g6e(o),j=m6e(o);return h.jsxs("div",{"data-active":s||void 0,className:pe("group flex w-full flex-col border-b border-border transition-colors",s?"bg-dropdown-selected-item-bg":"hover:bg-ghost-button-hover"),children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 pt-3",children:[h.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[h.jsx("span",{className:pe("truncate text-sm font-medium text-text-primary",P&&"aui-text-shimmer"),children:e}),R!=null?h.jsx("span",{"data-slot":"session-status-dot",className:"shrink-0",children:h.jsx(WS,{className:"size-1.5",colorClassName:R,pulse:j})}):N?h.jsx("span",{"data-slot":"session-status-failed",className:"shrink-0 text-failure-bg","aria-hidden":!0,children:h.jsx(be,{name:"circle-exclamation-point",className:"size-3.5"})}):null,O!=null?h.jsx("span",{className:"sr-only",children:O}):null,n!=null?h.jsx(sr,{content:h.jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[h.jsx("span",{className:"font-medium",children:"Scheduled Run"}),y||b.name!=null?h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"text-text-secondary",children:"Schedule name:"}),b.name!=null?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:b.name}),d!=null?h.jsx("button",{type:"button","aria-label":`View schedule ${b.name}`,className:"text-primary-button-bg inline-flex shrink-0 cursor-pointer",onClick:D=>{D.stopPropagation(),n!=null&&b.name!=null&&d({id:n,name:b.name})},children:h.jsx(be,{name:"external-link",className:"size-3.5"})}):null]}):h.jsx("span",{role:"status",children:"Loading..."})]}):null]}),children:h.jsx("span",{"aria-label":"Scheduled run",className:"inline-flex shrink-0",onMouseEnter:w,onFocus:w,children:h.jsx(be,{name:"calendar",className:"size-3.5 text-primary-button-bg"})})}):null]}),c!=null?h.jsx("div",{className:pe("ml-auto shrink-0 transition-opacity","md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100 md:group-has-[[aria-expanded=true]]:opacity-100"),onClick:D=>D.stopPropagation(),onKeyDown:D=>D.stopPropagation(),children:h.jsx(Ep,{align:"end",className:"min-w-40",trigger:h.jsx("button",{type:"button",className:rn({variant:"ghost",size:"icon",className:"size-7"}),"aria-label":`Actions for ${e}`,children:h.jsx(be,{name:"ellipsis"})}),children:h.jsx(g,{allowed:u,children:h.jsxs(pu,{className:"whitespace-nowrap text-failure-bg focus-visible:text-failure-bg",onClick:()=>{u&&c()},children:[h.jsx(be,{name:"trash",className:"size-3.5"}),"Delete"]})})})}):null]}),h.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-end justify-between gap-2 px-4 pt-2 pb-3 text-left text-xs text-text-secondary",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[T!=null&&C!=null?h.jsx(sr,{content:T,children:h.jsx("span",{"aria-label":T,className:"inline-flex shrink-0",children:h.jsx(rE,{size:"sm","aria-hidden":!0,children:h.jsx(oE,{children:C})})})}):null,t!=null?h.jsxs(h.Fragment,{children:[h.jsx(be,{name:"agent-2",className:"size-3 shrink-0"}),h.jsx("span",{className:"truncate",children:t}),h.jsx("span",{"aria-hidden":"true",children:"·"})]}):null,h.jsx(sr,{content:A,side:"bottom",children:h.jsx("span",{children:E})})]}),h.jsx("span",{className:"shrink-0 tabular-nums",children:zQt(a)})]})]})}var Da="main";function lJt(e){const t=e.pauseWallStartMs,n=e.pauseWallEndMs;if(t!=null&&n!=null&&n>t)return{startMs:t,endMs:n};if(!e.isPauseChip)return;const r=e.wallDurationMs??0;if(r<=0)return;const o=e.turnIndex*1e12+e.startMs;return{startMs:o,endMs:o+r}}function v6e(e){const t=[];for(const r of e){if(r.isPauseChip!==!0&&r.isPauseSpan!==!0)continue;const o=lJt(r);o!=null&&t.push({...o,segment:r})}t.sort((r,o)=>r.startMs-o.startMs||r.endMs-o.endMs);const n=[];for(const r of t){const o=n.at(-1);if(o!=null&&r.startMs<=o.endMs){o.endMs=Math.max(o.endMs,r.endMs),r.segment.isPauseChip===!0&&o.segment.isPauseChip!==!0&&(o.segment=r.segment);continue}n.push({...r})}return n}function cJt(e){return v6e(e).reduce((t,n)=>t+(n.endMs-n.startMs),0)}function iyn(e){const t=e.filter(r=>r.isPauseChip!==!0&&r.isPauseSpan!==!0),n=v6e(e).map((r,o)=>({...r.segment,id:`${r.segment.id}:merged:${o}`,isPauseChip:!0,isPauseSpan:!1,wallDurationMs:r.endMs-r.startMs}));return[...t,...n]}var y6e=[{id:"system",label:"System",color:"#94a3b8"},{id:"user",label:"User",color:"#34d399"},{id:"model",label:"Model",color:"#3b82f6",darkColor:"#6366f1"},{id:"tool_call",label:"Tool call",color:"#f59e0b"},{id:"approval",label:"Approval / HITL",color:"#f472b6"},{id:"summary",label:"Summary",color:"#a855f7"},{id:"sub_agent",label:"Sub-agent",color:"#e2e8f0",darkColor:"#3f3f46"},{id:"waiting_on_human",label:"Waiting on human",color:"#22d3ee"},{id:"error",label:"Error",color:"#f87171"}],syn=new Set(["system","user","approval","error"]),uJt={user:"User Message",model:"Model Response"};function x6e(e){return e<=0?"0ms":e<1e3?`${Math.round(e)}ms`:e<6e4?`${Number((e/1e3).toPrecision(3))}s`:e<36e5?`${Number((e/6e4).toPrecision(3))}m`:e<864e5?`${Number((e/36e5).toPrecision(3))}h`:`${Number((e/864e5).toPrecision(3))}d`}function Xl(e,t=!1){const n=y6e.find(r=>r.id===e);return(t?n==null?void 0:n.darkColor:void 0)??(n==null?void 0:n.color)??"#94a3b8"}function lyn(e,t=!1){const n=Xl(e,t),r=n.replace("#",""),o=r.length===3?r.split("").map(s=>`${s}${s}`).join(""):r;if(o.length!==6)return n;const a=Number.parseInt(o,16),i=s=>Math.max(0,Math.round((a>>s&255)*.9)).toString(16).padStart(2,"0");return`#${i(16)}${i(8)}${i(0)}`}function dJt(e){var t;return((t=y6e.find(n=>n.id===e))==null?void 0:t.label)??e}function cyn(e){return uJt[e]??dJt(e)}i3.register(v_);function pJt({data:e}){const t=Math.max(0,...e.map(n=>n.value))||1;return h.jsx("div",{className:"max-h-72 w-full overflow-x-hidden overflow-y-auto pr-3",children:h.jsx("div",{className:"grid grid-cols-[max-content_minmax(0,1fr)_max-content] items-center gap-x-2 gap-y-2",children:e.map(n=>h.jsxs("div",{className:"contents",children:[h.jsx("span",{className:"max-w-28 truncate text-text-secondary",title:n.label,children:n.label}),h.jsx("div",{className:"h-1.5 min-w-0 overflow-hidden rounded-full bg-secondary-bg",children:h.jsx("div",{className:"h-full rounded-full",style:{width:`${n.value/t*100}%`,backgroundColor:n.color}})}),h.jsx("span",{className:"text-right font-semibold text-text-primary",children:nE(n.value)})]},n.label))})})}function eC({title:e,children:t,fitWidth:n=!1}){return h.jsxs("div",{className:n?"min-w-40 w-fit px-2 py-2 text-xs text-text-primary":"w-72 px-2 py-2 text-xs text-text-primary",children:[h.jsx("div",{className:"mb-3 text-xs font-medium capitalize tracking-wider text-text-secondary",children:e}),t]})}function w6e({data:e,formatValue:t}){const n=e.filter(o=>o.value>0),r=n.reduce((o,a)=>o+a.value,0);return n.length===0?null:h.jsxs("div",{children:[h.jsx("div",{className:"mb-3 flex h-3 w-full overflow-hidden rounded-full bg-secondary-bg",children:n.map(o=>h.jsx("span",{className:"h-full",style:{width:`${o.value/r*100}%`,backgroundColor:o.color}},o.label))}),h.jsx("div",{className:"space-y-2",children:n.map(o=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"size-2 shrink-0 rounded-sm",style:{backgroundColor:o.color}}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-text-secondary",children:o.label}),h.jsx("span",{className:"font-semibold text-text-primary",children:t(o.value)})]},o.label))})]})}function _6e({totalTokens:e,inputTokens:t,outputTokens:n,cacheReadTokens:r,cacheWriteTokens:o,inputBreakdown:a}){const i=a.some(l=>l.value>0),s=[{label:"Output tokens",value:n},{label:"Cache read",value:r},{label:"Cache write",value:o}];return h.jsxs("div",{className:"w-60 px-1 py-1 text-xs text-text-primary",children:[h.jsx("div",{className:"font-medium",children:`${Kw(e)} total tokens`}),h.jsx("div",{className:"mt-1 text-text-secondary",children:`${Kw(t)} input · ${Kw(n)} output`}),i?h.jsxs("div",{className:"mt-3",children:[h.jsx("div",{className:"mb-2 font-medium text-text-secondary",children:"Input breakdown"}),h.jsx(w6e,{data:a,formatValue:Kw})]}):null,h.jsx("div",{className:"my-3 border-t border-border","aria-hidden":"true"}),h.jsx("div",{className:"flex flex-col gap-2",children:s.map(l=>h.jsxs("div",{className:"flex items-center justify-between gap-4",children:[h.jsx("span",{className:"text-text-secondary",children:l.label}),h.jsx("span",{className:"font-medium text-text-primary",children:Kw(l.value)})]},l.label))})]})}var fJt={responsive:!0,maintainAspectRatio:!1,animation:!1,cutout:"60%",events:[],plugins:{legend:{display:!1},tooltip:{enabled:!1}}};function hJt({data:e}){const t=_.useMemo(()=>e.filter(r=>r.value>0),[e]),n=_.useMemo(()=>({labels:t.map(r=>r.label),datasets:[{data:t.map(r=>r.value),backgroundColor:t.map(r=>r.color),borderWidth:0}]}),[t]);return t.length===0?null:h.jsx("div",{className:"size-4 shrink-0","aria-hidden":"true",children:h.jsx(lWt,{data:n,options:fJt})})}function gxe({data:e,formatValue:t,scrollX:n=!1}){const r=Math.max(0,...e.map(o=>o.value))||1;return h.jsx("div",{className:n?"max-h-72 w-full overflow-auto pr-3":"max-h-72 w-full overflow-x-hidden overflow-y-auto pr-3",children:h.jsx("div",{className:n?"grid w-max min-w-full grid-cols-[max-content_minmax(6rem,1fr)_max-content] items-center gap-x-2 gap-y-2":"grid grid-cols-[max-content_minmax(0,1fr)_max-content] items-center gap-x-2 gap-y-2",children:e.map(o=>h.jsxs("div",{className:"contents",children:[n?h.jsx("span",{className:"whitespace-nowrap text-text-secondary",children:o.label}):h.jsx("span",{className:"max-w-28 truncate text-text-secondary",title:o.label,children:o.label}),h.jsx("div",{className:"h-1.5 min-w-0 overflow-hidden rounded-full bg-secondary-bg",children:h.jsx("div",{className:"h-full rounded-full",style:{width:`${o.value/r*100}%`,backgroundColor:o.color}})}),h.jsx("span",{className:"text-right font-semibold text-text-primary",children:t(o.value)})]},o.label))})})}var gJt="Some turns in this session were edited or retried. Showing only the latest lineage of the session";function ig({id:e,label:t,value:n,tooltip:r}){const o=h.jsxs("div",{className:"h-full w-full border-b border-r border-border bg-primary-bg px-3 py-2","data-slot":`session-metric-${e}`,children:[h.jsxs("div",{className:"mb-0.5 flex items-center gap-1 text-[0.625rem] font-medium uppercase tracking-wider text-text-secondary",children:[t,r!=null?h.jsx(be,{name:"info",className:"size-2.5 text-text-secondary"}):null]}),h.jsx("div",{className:"pt-1 text-base font-medium leading-none text-text-primary",children:n})]});return r==null?o:h.jsx(GS,{title:r,side:"bottom",triggerClassName:"block w-full",children:o})}function mJt({lineageTurns:e,sessionTotalTurns:t}){const n=t!=null&&t>e,r=e>1||t!=null&&t>1?"Turns":"Turn",o=n?h.jsxs("span",{className:"inline-flex h-4 items-center gap-2",children:[h.jsxs("span",{className:"leading-none",children:[h.jsxs("span",{className:"text-primary-button-bg",children:[e," "]}),h.jsxs("span",{className:"text-text-primary",children:["/ ",t]})]}),h.jsx(be,{name:"circle-exclamation",size:16,className:"size-4 shrink-0 text-warning-bg","data-testid":"icon-circle-exclamation"})]}):e,a=h.jsxs("div",{className:"h-full w-full border-b border-r border-border bg-primary-bg px-3 py-2","data-slot":"session-metric-turns",children:[h.jsx("div",{className:"mb-0.5 flex items-center gap-1 text-[0.625rem] font-medium uppercase tracking-wider text-text-secondary",children:r}),h.jsx("div",{className:"flex items-center pt-1 text-base font-medium leading-none text-text-primary",children:o})]});return n?h.jsx(GS,{title:gJt,side:"bottom",triggerClassName:"block w-full",className:"max-w-56 whitespace-normal",children:a}):a}function bJt({metrics:e}){return h.jsx("div",{className:"@container overflow-hidden border-b border-border","data-slot":"agent-session-metrics-strip",children:h.jsxs("div",{className:pe("-mb-px -mr-px grid grid-cols-3 @min-[24rem]:grid-cols-4",e.totalCostUsd==null?"@min-[48rem]:grid-cols-7":"@min-[48rem]:grid-cols-8"),children:[h.jsx(mJt,{lineageTurns:e.totalTurns,sessionTotalTurns:e.sessionTotalTurns}),h.jsx(ig,{id:"wall-time",label:"Duration",value:l6e(e.wallTimeMs),tooltip:h.jsx(eC,{title:"Where the time went",children:h.jsx(w6e,{data:e.timeBreakdown,formatValue:x6e})})}),e.totalCostUsd!=null?h.jsx(ig,{id:"cost",label:"Cost",value:nE(e.totalCostUsd),tooltip:e.costPerTurn.length>1&&e.totalCostUsd>0?h.jsx(eC,{title:"Cost per turn",children:h.jsx(pJt,{data:e.costPerTurn})}):null}):null,h.jsx(ig,{id:"tokens",label:"Tokens",value:h.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[tu(e.totalTokens),h.jsx(hJt,{data:e.tokenBreakdown})]}),tooltip:e.totalTokens>0?h.jsx(_6e,{totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheReadTokens:e.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens,inputBreakdown:e.inputBreakdown}):null}),h.jsx(ig,{id:"context",label:"Context Usage",value:tu(e.contextTokens),tooltip:e.contextByTurn.length>1&&e.contextTokens>0?h.jsx(eC,{title:"Context Usage at end of turn",children:h.jsx(gxe,{scrollX:!0,data:e.contextByTurn,formatValue:tu})}):null}),h.jsx(ig,{id:"tool-calls",label:"Tool calls",value:e.toolCalls,tooltip:e.toolCalls>1?h.jsx(eC,{title:"Tool call frequency",children:h.jsx(gxe,{data:e.toolCallFrequency,formatValue:String})}):null}),h.jsx(ig,{id:"sub-agents",label:"Sub-agents",value:e.subAgents}),h.jsx(ig,{id:"errors",label:"Errors",value:e.errors})]})})}var S6e=[{label:"Last 30 minutes",windowMs:1800*1e3},{label:"Last 1 hour",windowMs:3600*1e3},{label:"Last 3 hours",windowMs:10800*1e3},{label:"Last 6 hours",windowMs:360*60*1e3},{label:"Last 12 hours",windowMs:720*60*1e3},{label:"Last 24 hours",windowMs:1440*60*1e3},{label:"Last 2 days",windowMs:2880*60*1e3},{label:"Last 7 days",windowMs:10080*60*1e3},{label:"Last 30 days",windowMs:720*60*60*1e3}];function vJt(e){var t;return((t=S6e.find(n=>n.windowMs===e))==null?void 0:t.label)??null}function yJt(e=new Date){const t=-e.getTimezoneOffset(),n=t>=0?"+":"-",r=Math.abs(t),o=String(Math.floor(r/60)).padStart(2,"0"),a=String(r%60).padStart(2,"0");return`UTC${n}${o}:${a}`}function tC(e){const t=new Date(e),n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function mxe(e){const t=new Date(e).getTime();return Number.isNaN(t)?null:t}var xJt="w-full cursor-text rounded-md border border-input-border bg-input-box-bg px-3 text-sm text-text-primary outline-none placeholder:text-text-secondary/70 focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:cursor-not-allowed";function ga(e){return pe(xJt,e)}function C3(e){return ga(pe("flex h-8 cursor-pointer items-center justify-between gap-2 pr-2 text-left",e))}function k6e(e){return pe("inline-flex h-8 w-full cursor-pointer items-center rounded-md border border-border bg-input-box-bg text-left text-sm text-text-primary outline-none","focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:cursor-not-allowed disabled:opacity-50",e)}function R3(e){return pe("aui-popup-enter bg-card-bg text-text-primary z-50 max-h-64 overflow-y-auto rounded-md border border-border p-1 shadow-md",e)}function vm(e){return pe("text-text-primary flex w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors","hover:bg-ghost-button-hover focus:bg-dropdown-selected-item-bg focus:text-dropdown-selected-item-text","disabled:pointer-events-none disabled:opacity-50",e)}function wJt({value:e,selectedLabel:t,onValueChange:n,onAgentPicked:r,disabled:o=!1,onBuildAgent:a,allOption:i,prefix:s,"aria-label":l="Agent",placeholder:c="Search agent",className:u}){const[d,f]=_.useState(!1),[g,b]=_.useState(""),[v,y]=_.useState(null),w=_.useRef(null),S=_.useRef(null),E=_.useRef(null),A=_.useRef(null),T=_.useId(),{agents:C,isInitialLoading:R,isSearching:N,loadingMore:O,hasMore:P,error:j,listRef:D,sentinelRef:z}=lAe({enabled:d&&!o,query:g});_.useEffect(()=>{d||b("")},[d]),_.useLayoutEffect(()=>{if(!d){y(null);return}const Y=()=>{const q=S.current;if(!q)return;const ne=q.getBoundingClientRect();y({top:ne.bottom+4,left:ne.left,width:ne.width})};return Y(),window.addEventListener("scroll",Y,!0),window.addEventListener("resize",Y),()=>{window.removeEventListener("scroll",Y,!0),window.removeEventListener("resize",Y)}},[d]),_.useEffect(()=>{if(!d)return;const Y=q=>{var ne,he;q.target instanceof Node&&((ne=w.current)!=null&&ne.contains(q.target)||(he=A.current)!=null&&he.contains(q.target)||f(!1))};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[d]);const L=()=>{var Y;f(!1),b(""),(Y=E.current)==null||Y.blur()},$=Y=>{const q=Jc(Y);n(q),r==null||r(Y),L()},U=()=>{i!=null&&(n(i.value),L())},B=d?g:t,V=g.trim(),G=!R&&j!=null,F=!R&&j==null&&C.length===0&&V==="",Z=!R&&j==null&&C.length===0&&V!=="",J=d&&v!=null&&!o?Ui.createPortal(h.jsxs("div",{ref:A,className:R3("fixed z-[200] flex max-h-64 flex-col overflow-hidden"),style:{top:v.top,left:v.left,width:v.width},onMouseDown:Y=>Y.stopPropagation(),children:[h.jsxs("div",{ref:D,id:T,role:"listbox","aria-label":l,className:"min-h-0 flex-1 overflow-y-auto p-1",children:[i!=null&&V===""?h.jsxs("button",{type:"button",role:"option","aria-selected":e===i.value,className:vm(),onClick:U,children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label}),h.jsx(be,{name:"check",className:pe("ml-auto size-4 shrink-0",e===i.value?"opacity-100":"opacity-0")})]}):null,R?h.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:"Loading…"}):G?h.jsx("p",{className:"text-failure-bg px-3 py-5 text-center text-sm",role:"alert",children:j}):F?h.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",children:"No Agents created yet"}):Z?h.jsxs("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:['No agents match "',V,'".']}):h.jsxs(h.Fragment,{children:[N?h.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null,C.map(Y=>{const q=Jc(Y),ne=e===q;return h.jsxs("button",{type:"button",role:"option","aria-selected":ne,className:vm(),onClick:()=>$(Y),children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:Y.name}),h.jsx(be,{name:"check",className:pe("ml-auto size-4 shrink-0",ne?"opacity-100":"opacity-0")})]},q)}),P?h.jsx("div",{ref:z,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:O?h.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]}),F&&a!=null?h.jsx("div",{className:"flex justify-end border-t border-border px-2 pt-2",children:h.jsxs(Tn.Ghost,{type:"button",onClick:a,children:[h.jsx(be,{name:"plus",className:"size-3.5"}),"Build Agent"]})}):null]}),w3(w.current)):null,W=h.jsx("input",{ref:E,type:"text",role:"combobox","aria-label":l,"aria-expanded":d,"aria-controls":d?T:void 0,"aria-autocomplete":"list",disabled:o,placeholder:c,value:B,className:pe("min-w-0 bg-transparent outline-none placeholder:text-text-secondary/70 disabled:cursor-not-allowed",s==null?"flex-1":"absolute inset-0 w-full px-2"),onFocus:()=>{o||f(!0)},onChange:Y=>{o||(b(Y.target.value),f(!0))},onKeyDown:Y=>{var q;if(Y.key==="Escape"){Y.preventDefault(),f(!1),(q=E.current)==null||q.blur();return}Y.key==="ArrowDown"&&!d&&!o&&(Y.preventDefault(),f(!0))}});return h.jsxs("div",{ref:w,className:pe("relative",u),children:[h.jsxs("div",{ref:S,className:s==null?C3(o?"cursor-not-allowed opacity-50":"cursor-text"):k6e(pe("w-fit min-w-full",o?"cursor-not-allowed opacity-50":"cursor-text")),onClick:()=>{var Y;o||(Y=E.current)==null||Y.focus()},children:[s==null?null:h.jsx("span",{className:"text-text-primary shrink-0 border-r border-border px-3 font-semibold",children:s}),s==null?W:h.jsxs("div",{className:"relative mx-2 max-w-48 min-w-24 flex-none overflow-hidden px-2 py-0.5 text-sm",children:[h.jsx("span",{"aria-hidden":!0,className:"invisible block truncate whitespace-pre",children:t||c}),W]}),h.jsx(be,{name:"chevron-down",className:pe("size-4 shrink-0 text-text-secondary",s==null?null:"mr-2")})]}),J]})}function _Jt({agentId:e,timeRange:t,onAgentChange:n,onTimeRangeChange:r,showAgentFilter:o=!0,showCustomTimeRange:a=!0,onReload:i,isReloading:s=!1}){const l=Za(),[c,u]=_.useState({}),[d,f]=_.useState(!1),[g,b]=_.useState(!1),[v,y]=_.useState(()=>tC(t.startTs)),[w,S]=_.useState(()=>tC(t.endTs)),E=_.useRef(null),A=e==null?void 0:c[e];_.useEffect(()=>{if(l==null||e==null||A!=null)return;let R=!1;return sAe({server:l,agentKey:e}).then(N=>{R||N==null||u(O=>({...O,[e]:N.name}))},()=>{}),()=>{R=!0}},[e,A,l]),_.useEffect(()=>{y(tC(t.startTs)),S(tC(t.endTs))},[t.endTs,t.startTs]),_.useEffect(()=>{if(!d)return;const R=O=>{var P;((P=E.current)==null?void 0:P.contains(O.target))!==!0&&(f(!1),b(!1))},N=O=>{O.key==="Escape"&&(f(!1),b(!1))};return document.addEventListener("pointerdown",R),document.addEventListener("keydown",N),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("keydown",N)}},[d]);const T=t.timeWindowMs!=null?vJt(t.timeWindowMs)??"Custom Time Range":"Custom Time Range",C=()=>{const R=mxe(v),N=mxe(w);if(R==null||N==null||R>=N)return;const O=Date.now()-_ie*24*60*60*1e3,P=Math.max(R,O);P>=N||(r({startTs:P,endTs:N}),f(!1),b(!1))};return h.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i!=null?h.jsx(Tn.Secondary,{type:"button",size:"icon","aria-label":"Reload sessions",title:"Reload sessions",disabled:s,onClick:i,children:h.jsx(be,{name:"refresh-cw",className:pe("size-3.5",s&&"animate-spin")})}):null,o?h.jsx(wJt,{"aria-label":"Filter sessions by agent",prefix:"Agents",className:"min-w-40",value:e??"",selectedLabel:e==null?"All":A??e,allOption:{value:"",label:"All"},onValueChange:R=>n(R.length===0?null:R),onAgentPicked:R=>{u(N=>({...N,[Jc(R)]:R.name}))}}):null,h.jsxs("div",{className:"relative",ref:E,children:[h.jsxs("button",{type:"button","aria-expanded":d,"aria-haspopup":"listbox",className:C3("min-w-36"),onClick:()=>{f(R=>(R&&b(!1),!R))},children:[h.jsx("span",{className:"truncate",children:T}),h.jsx(be,{name:"chevron-down",className:"size-4 shrink-0"})]}),d?h.jsxs("div",{className:R3("absolute top-full right-0 mt-1 flex max-h-none overflow-y-visible p-0"),children:[g?h.jsxs("div",{className:"flex w-64 min-w-0 flex-col gap-2 border-r border-border p-3",children:[h.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Select Time Range"}),h.jsx("p",{className:"text-xs text-text-secondary",children:`You can select time for last ${String(_ie)} days`}),h.jsxs("label",{className:"flex flex-col gap-1 text-xs text-text-secondary",children:["From",h.jsx("input",{type:"datetime-local",step:"1",className:ga("h-8"),value:v,onChange:R=>y(R.target.value)})]}),h.jsxs("label",{className:"flex flex-col gap-1 text-xs text-text-secondary",children:["To",h.jsx("input",{type:"datetime-local",step:"1",className:ga("h-8"),value:w,onChange:R=>S(R.target.value)})]}),h.jsxs("p",{className:"text-xs text-text-secondary",children:["Timezone: ",h.jsx("span",{className:"font-medium text-text-primary",children:yJt()})]}),h.jsx(Tn.Primary,{type:"button",className:"mt-auto",onClick:C,children:"Apply"})]}):null,h.jsxs("div",{className:"flex max-h-80 w-44 shrink-0 flex-col overflow-y-auto p-1",role:"listbox",children:[a?h.jsxs("button",{type:"button",role:"option","aria-selected":t.timeWindowMs==null,className:vm(),onClick:()=>b(!0),children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Custom Time Range"}),h.jsx(be,{name:"check",className:pe("ml-auto size-4 shrink-0",t.timeWindowMs==null?"opacity-100":"opacity-0")})]}):null,S6e.map(R=>{const N=t.timeWindowMs===R.windowMs;return h.jsxs("button",{type:"button",role:"option","aria-selected":N,className:vm(),onClick:()=>{const O=Date.now();r({startTs:O-R.windowMs,endTs:O,timeWindowMs:R.windowMs}),f(!1),b(!1)},children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:R.label}),h.jsx(be,{name:"check",className:pe("ml-auto size-4 shrink-0",N?"opacity-100":"opacity-0")})]},R.windowMs)})]})]}):null]})]})}var SJt={type:"user.mcp_auth_continue"},kJt=new Set(["user.message","user.tool_approval","user.tool_response","user.mcp_auth_continue"]);function iv(e){const t=Date.parse(e);return Number.isNaN(t)?0:t}function bxe(e){const t=Reflect.get(e,"input");return Array.isArray(t)?t.some(n=>{if(typeof n!="object"||n==null||!("type"in n))return!1;const r=Reflect.get(n,"type");return typeof r=="string"&&kJt.has(r)}):!1}function EJt(e){if(e==null||e.state.status!=="done")return!1;const t=e.state.requiredActions;return Array.isArray(t)?t.some(n=>n.type==="mcp.auth_required"):!1}function TJt(e){const t=e.input??[];return t.some(n=>n.type==="user.mcp_auth_continue")?e:{...e,input:[...t,SJt]}}function sv(e,t,n){const r=Reflect.get(e,t);if(typeof r=="number"&&Number.isFinite(r))return r;const o=Reflect.get(e,n);return typeof o=="number"&&Number.isFinite(o)?o:void 0}function AJt(e){if(typeof e!="object"||e==null||!("status"in e))return{};const t=Reflect.get(e,"status");if(t!=="done"&&t!=="cancelled"&&t!=="error")return{};const n=Reflect.get(e,"metrics");if(n==null||typeof n!="object")return{};const r=sv(n,"totalTokens","total_tokens"),o=sv(n,"totalInputTokens","total_input_tokens"),a=sv(n,"totalOutputTokens","total_output_tokens"),i=sv(n,"totalCacheReadTokens","total_cache_read_tokens"),s=sv(n,"totalCacheWriteTokens","total_cache_write_tokens"),l=sv(n,"totalCostInUsd","total_cost_in_usd"),c=i!==void 0||s!==void 0?(i??0)+(s??0):void 0,u=o!==void 0?Math.max(0,o-(c??0)):void 0,d=r??(o!==void 0||a!==void 0?(o??0)+(a??0):void 0);return{...d!==void 0?{totalTokens:d}:{},...u!==void 0?{inputTokens:u}:{},...a!==void 0?{outputTokens:a}:{},...c!==void 0?{cachedTokens:c}:{},...i!==void 0?{cacheReadTokens:i}:{},...s!==void 0?{cacheWriteTokens:s}:{},...l!==void 0?{totalCostInUsd:l}:{}}}function CJt(e){var t;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if((r==null?void 0:r.type)==="model.message"&&r.threadId===Da&&((t=r.model)!=null&&t.name))return r.model.name}}function lv(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function RJt(e){if(typeof e!="object"||e==null)return;const t=Reflect.get(e,"inputTokensBreakdown")??Reflect.get(e,"input_tokens_breakdown");if(typeof t!="object"||t==null)return;const n=lv(Reflect.get(t,"harness")),r=lv(Reflect.get(t,"skills")),o=lv(Reflect.get(t,"instructions")),a=lv(Reflect.get(t,"toolDefinitions"))??lv(Reflect.get(t,"tool_definitions")),i=lv(Reflect.get(t,"messages"));if(!(n===void 0&&r===void 0&&o===void 0&&a===void 0&&i===void 0))return{harness:n??0,skills:r??0,instructions:o??0,toolDefinitions:a??0,messages:i??0}}function UJ(e,t){if(!(e==null&&t==null))return{harness:((e==null?void 0:e.harness)??0)+((t==null?void 0:t.harness)??0),skills:((e==null?void 0:e.skills)??0)+((t==null?void 0:t.skills)??0),instructions:((e==null?void 0:e.instructions)??0)+((t==null?void 0:t.instructions)??0),toolDefinitions:((e==null?void 0:e.toolDefinitions)??0)+((t==null?void 0:t.toolDefinitions)??0),messages:((e==null?void 0:e.messages)??0)+((t==null?void 0:t.messages)??0)}}function IJt(e){let t;for(const n of e){if(n.type!=="model.message")continue;const r=Reflect.get(n,"usage");t=UJ(t,RJt(r))}return t}function NJt(e){const t=new Map;for(const o of e){const{turnId:a,event:i}=o,s=t.get(a)??{events:[]};i.type==="turn.created"?s.created=i:i.type==="turn.done"?s.done=i:s.events.push(i),t.set(a,s)}const n=Array.from(t.entries()).flatMap(([o,a])=>a.created===void 0?[]:[{turnId:o,created:a.created,group:a}]).sort((o,a)=>iv(o.created.createdAt)-iv(a.created.createdAt));let r=0;return n.map(({turnId:o,created:a,group:i},s)=>{var v;const l=i.done,c=s>0?(v=n[s-1])==null?void 0:v.group.done:void 0,d=!bxe(a)&&EJt(c)?TJt(a):a,f=bxe(d);f&&(r+=1),i.events.sort((y,w)=>iv(y.createdAt)-iv(w.createdAt));const g=CJt(i.events),b=IJt(i.events);return{turnId:o,eventTurnNumber:s+1,turnNumber:Math.max(1,r),renderable:f,showHeader:f,created:d,...l===void 0?{}:{done:l,durationMs:Math.max(0,iv(l.createdAt)-iv(a.createdAt)),...AJt(l.state)},events:i.events,...g===void 0?{}:{modelName:g},...b===void 0?{}:{inputTokensBreakdown:b}}})}function MJt(e,t){const n=e.filter(C=>C.turnNumber===t),r=n.find(C=>C.renderable)??n[0];if(r==null)return;let o=0,a=0,i=0,s=0,l=0,c=0,u=0,d=0,f=!1,g=!1,b=!1,v=!1,y=!1,w=!1,S=!1,E=!1,A,T;for(const C of n)C.modelName!=null&&(A=C.modelName),C.totalTokens!=null&&(o+=C.totalTokens,f=!0),C.inputTokens!=null&&(a+=C.inputTokens,g=!0),C.outputTokens!=null&&(i+=C.outputTokens,b=!0),C.cachedTokens!=null&&(s+=C.cachedTokens,v=!0),C.cacheReadTokens!=null&&(l+=C.cacheReadTokens,y=!0),C.cacheWriteTokens!=null&&(c+=C.cacheWriteTokens,w=!0),C.totalCostInUsd!=null&&(u+=C.totalCostInUsd,S=!0),C.durationMs!=null&&(d+=C.durationMs,E=!0),T=UJ(T,C.inputTokensBreakdown);return{...r,...f?{totalTokens:o}:{},...g?{inputTokens:a}:{},...b?{outputTokens:i}:{},...v?{cachedTokens:s}:{},...y?{cacheReadTokens:l}:{},...w?{cacheWriteTokens:c}:{},...S?{totalCostInUsd:u}:{},...E?{durationMs:d}:{},...A===void 0?{}:{modelName:A},...T===void 0?{}:{inputTokensBreakdown:T}}}var OJt=[{key:"harness",label:"Harness",color:"#f59e0b"},{key:"skills",label:"Skills",color:"#6366f1"},{key:"instructions",label:"Instructions",color:"#22d3ee"},{key:"toolDefinitions",label:"Tool definitions",color:"#3b82f6"},{key:"messages",label:"Messages",color:"#ec4899"}];function E6e(e){return OJt.map(t=>({label:t.label,value:e[t.key],color:t.color}))}function vxe(e){return Math.max(0,e.endMs-e.startMs)}function PJt(e){return e.totalTokens!=null||e.inputTokens!=null||e.outputTokens!=null||e.cachedTokens!=null||e.totalCostInUsd!=null}function jJt({turns:e,segments:t,sessionMetrics:n}){let r=0,o=0,a=!1,i=0,s=0,l=0,c=0,u=0,d=0,f=0,g;const b=new Map,v=new Map;for(const L of e){if(r+=L.durationMs??0,!PJt(L)){b.has(L.turnNumber)||b.set(L.turnNumber,0),v.has(L.turnNumber)||v.set(L.turnNumber,0);continue}g=UJ(g,L.inputTokensBreakdown);const $=L.inputTokens??0,U=L.outputTokens??0,B=L.cachedTokens??0,V=L.cacheReadTokens!=null||L.cacheWriteTokens!=null,G=L.cacheReadTokens??0,F=L.cacheWriteTokens??0,Z=V?G+F:B,J=L.totalTokens??$+B+U,W=L.totalCostInUsd;W!=null&&(o+=W,a=!0),i+=J,s+=$,l+=$+Z,c+=U,u+=B,d+=G,f+=F,b.set(L.turnNumber,(b.get(L.turnNumber)??0)+(W??0)),v.set(L.turnNumber,(v.get(L.turnNumber)??0)+J)}const y=[],w=[];let S=0;for(const L of[...v.keys()].sort(($,U)=>$-U)){const $=`T${L}`;S+=v.get(L)??0,y.push({label:$,value:b.get(L)??0,color:Xl("tool_call")}),w.push({label:$,value:S,color:Xl("model")})}const E=t.filter(L=>L.type==="model").reduce((L,$)=>L+vxe($),0),A=t.filter(L=>L.type==="tool_call").reduce((L,$)=>L+vxe($),0),T=cJt(t),C=n!=null?n.totalDurationMs+T:r,R=Math.max(0,C-E-A-T),N=new Map;for(const L of t)L.type!=="tool_call"||L.threadId!==Da||N.set(L.description,(N.get(L.description)??0)+1);const O=Array.from(N,([L,$])=>({label:L,value:$,color:Xl("tool_call")})).sort((L,$)=>$.value-L.value),P=n!=null?n.totalCostInUsd:a?o:void 0,j=e.length,D=n==null?void 0:n.totalTurns,z=D!=null&&Number.isFinite(D)&&D>j?D:void 0;return{totalTurns:j,...z==null?{}:{sessionTotalTurns:z},wallTimeMs:C,...P==null?{}:{totalCostUsd:P},totalTokens:i,contextTokens:S,toolCalls:O.reduce((L,$)=>L+$.value,0),subAgents:t.filter(L=>L.type==="sub_agent").length,errors:t.filter(L=>L.type==="error").length,timeBreakdown:[{label:"model",value:E,color:Xl("model")},{label:"tools",value:A,color:Xl("tool_call")},{label:"waiting on human",value:T,color:Xl("approval")},{label:"overhead",value:R,color:Xl("system")}],costPerTurn:y,tokenBreakdown:[{label:"input",value:s,color:Xl("model")},{label:"output",value:c,color:Xl("user")},{label:"cached",value:u,color:Xl("sub_agent")}],inputTokens:l,outputTokens:c,cacheReadTokens:d,cacheWriteTokens:f,inputBreakdown:g==null?[]:E6e(g),contextByTurn:w,toolCallFrequency:O}}function DJt({turnNumber:e,totalTokens:t,inputTokens:n,outputTokens:r,cachedTokens:o,cacheReadTokens:a,cacheWriteTokens:i,inputTokensBreakdown:s,durationMs:l,totalCostInUsd:c,modelName:u}){const d=t!=null||l!=null||c!=null||u!=null,f=n!=null||r!=null||o!=null||a!=null||i!=null,g=a!=null||i!=null,b=a??0,v=i??0,y=r??0,w=g?b+v:o??0,S=(n??0)+w,E=t!=null?h.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-sm text-inherit","aria-label":f?`Tokens ${tu(t)}. Input ${tu(S)}, Output ${tu(y)}, Cache read ${tu(b)}, Cache write ${tu(v)}`:`Tokens ${tu(t)}`,children:[h.jsx(be,{name:"link",className:"size-3.5 shrink-0","aria-hidden":!0}),"Tokens ",h.jsx("span",{className:"font-semibold",children:tu(t)})]}):null;return h.jsxs("div",{className:"flex flex-col gap-2 text-xs text-text-secondary",children:[h.jsx("span",{className:"font-semibold text-text-primary",children:`Turn ${e}`}),d?h.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 tabular-nums",children:[u!=null?h.jsx(GS,{title:u,side:"bottom",children:h.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[h.jsx(be,{name:"cube",className:"size-3.5 shrink-0","aria-hidden":!0}),h.jsx("span",{className:"shrink-0",children:"Model"}),h.jsx("span",{className:"max-w-64 truncate font-semibold",children:u})]})}):null,E!=null?f?h.jsx(GS,{title:h.jsx(_6e,{totalTokens:t??0,inputTokens:S,outputTokens:y,cacheReadTokens:b,cacheWriteTokens:v,inputBreakdown:s==null?[]:E6e(s)}),side:"bottom",children:E}):E:null,l!=null?h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx(be,{name:"clock",className:"size-3.5 shrink-0"}),"Duration ",h.jsx("span",{className:"font-semibold",children:s6e(l)})]}):null,c!=null?h.jsxs("span",{children:["Cost ",h.jsx("span",{className:"font-semibold",children:nE(c)})]}):null]}):null,h.jsx("div",{className:"h-px w-full bg-border","aria-hidden":"true"})]})}function LJt(){const e=N0(),t=_m(),{updateShareSearch:n}=T3(),r=Ge("AgentSessions"),o=Ge("AgentSessionsFilters"),a=t.sharedSessionId,[i,s]=_.useState(()=>Nd(window.location.search).agentId),[l,c]=_.useState(()=>Nd(window.location.search).timeRange??OC());_.useEffect(()=>{if(a!=null)return;const A=Nd(window.location.search);n({view:"sessions",...A.timeRange==null?{timeRange:l}:{}})},[]),_.useEffect(()=>{const A=()=>{const T=Nd(window.location.search);s(T.agentId),c(T.timeRange??OC())};return window.addEventListener("popstate",A),()=>window.removeEventListener("popstate",A)},[]);const[u,d]=_.useState(0),[f,g]=_.useState(!1),b=_.useCallback(()=>{g(!0),d(A=>A+1)},[]),v=_.useCallback(A=>{A||g(!1)},[]),y=_.useMemo(()=>Xke(l),[l,u]),w=l.endTs-l.startTs,S=l.timeWindowMs==null&&w>0&&w<=2*N9,E=_.useCallback(()=>{const A=OC();c(A),n({timeRange:A,sessionId:null,view:"sessions"})},[n]);return h.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[h.jsx(WH,{title:"Agent Sessions",end:a==null?h.jsx(o,{agentId:i,timeRange:l,onAgentChange:A=>{s(A),n({agentId:A,sessionId:null,view:"sessions"})},onTimeRangeChange:A=>{c(A),n({timeRange:A,sessionId:null,view:"sessions"})},onReload:e==null?void 0:b,isReloading:f}):null}),h.jsx("div",{className:"min-h-0 flex-1",children:e==null?h.jsx("p",{className:"px-6 py-12 text-center text-sm text-text-secondary",children:"Session history is not available."}):h.jsx(_.Suspense,{fallback:h.jsx("div",{className:"p-4",role:"status","aria-label":"Loading sessions",children:h.jsx(da,{className:"min-h-64 rounded-lg"})}),children:h.jsx(r,{refreshKey:u,onLoadingChange:v,agentId:i??void 0,startTimestamp:new Date(y.startTs).toISOString(),endTimestamp:new Date(y.endTs).toISOString(),...a==null?{shareView:"sessions",...S?{onLoadRecentSessions:E}:{}}:{detailOnly:!0,detailSessionId:a,onCloseDetail:t.closeSharedSession}})})})]})}var T6e=1440*60*1e3,A6e=14,yxe=j2/T6e,zJt=A6e*T6e,$Jt="sessions_cost_over_time";function l$(e,t){const n=e.find(r=>r.name===t);return n==null||!Number.isFinite(n.aggregateValue)?null:n.aggregateValue}function UJt(e){return e==null?null:e.map(t=>({timestamp:t.timestamp,value:Number.isFinite(t.value)?t.value:0}))}function FJt(){return{totalSessions:null,totalCostUsd:null,costPerSessionUsd:null,dailyPoints:null}}async function BJt({agentId:e,metrics:t,metersStart:n,metersEnd:r,sparklineStart:o,sparklineEnd:a}){var f,g;const i=t.getMeters({agentId:e,startTimestamp:n,endTimestamp:r}).then(b=>({ok:!0,meters:b}),()=>({ok:!1})),s=t.getChartData({agentId:e,startTimestamp:o,endTimestamp:a,chartName:$Jt}).then(b=>({ok:!0,data:b}),()=>({ok:!1})),[l,c]=await Promise.all([i,s]),u=l.ok?l.meters:[],d=c.ok?UJt((g=(f=c.data.graphs[0])==null?void 0:f.graphLines[0])==null?void 0:g.values):null;return{totalSessions:l.ok?l$(u,"total_sessions"):null,totalCostUsd:l.ok?l$(u,"total_cost_in_usd"):null,costPerSessionUsd:l.ok?l$(u,"cost_per_session_in_usd"):null,dailyPoints:d}}function HJt({agentIds:e,refreshKey:t}){const n=Yke(),r=n!=null,[o,a]=_.useState(()=>new Map),i=e.join("\0"),s=_.useRef(null);return _.useEffect(()=>{const l=i.length===0?[]:i.split("\0");if(l.length===0||n==null){s.current=i,a(b=>b.size===0?b:new Map);return}s.current!==i&&(s.current=i,a(b=>b.size===0?b:new Map));let c=!1;const u=Date.now(),d=new Date(u).toISOString(),f=new Date(u-j2).toISOString(),g=new Date(u-zJt).toISOString();for(const b of l)BJt({agentId:b,metrics:n,metersStart:f,metersEnd:d,sparklineStart:g,sparklineEnd:d}).then(v=>{c||a(y=>{const w=new Map(y);return w.set(b,v),w})}).catch(()=>{c||a(v=>{const y=new Map(v);return y.set(b,FJt()),y})});return()=>{c=!0}},[i,n,t]),{usageByAgentId:o,metricsEnabled:r}}function nB(e){return`$${e.toFixed(2)}`}var VJt=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"});function GJt(e){const t=Date.parse(e);return Number.isNaN(t)?e:VJt.format(new Date(t))}var fy={sessions:`Sessions, ${String(yxe)}d`,spend:`Spend, ${String(yxe)}d`,daily:`Daily, ${String(A6e)}d`};function WJt({clientX:e,svg:t,count:n,width:r}){if(n<=1)return 0;const o=t.getBoundingClientRect(),a=(e-o.left)/Math.max(o.width,1)*r,i=r/(n-1);return Math.max(0,Math.min(n-1,Math.round(a/i)))}function KJt({points:e,agentName:t}){const[n,r]=_.useState(null);if(e==null)return h.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Activity unavailable for ${t}`,children:"—"});if(e.length===0||e.every(v=>v.value===0))return h.jsx("span",{className:"bg-border/80 mt-3 block h-px w-20","aria-label":`No activity in the last 14 days for ${t}`});const o=80,a=28,i=2,l=Math.max(0,...e.map(v=>v.value))||1,c=e.length===1?0:o/(e.length-1),u=e.map((v,y)=>{const w=e.length===1?o/2:y*c,S=a-i-Math.max(0,v.value)/l*(a-i*2);return{x:w,y:S}}),d=u.map(({x:v,y})=>`${String(v)},${String(y)}`).join(" "),f=n!=null?e[n.index]:null,g=n!=null?u[n.index]:null,b=v=>{const y=WJt({clientX:v.clientX,svg:v.currentTarget,count:e.length,width:o});r({index:y,clientX:v.clientX,clientY:v.clientY})};return h.jsx(sr,{open:n!=null&&f!=null,anchor:n!=null?{left:n.clientX,top:n.clientY}:null,interactive:!1,content:f==null?null:h.jsxs("span",{className:"flex flex-col gap-0.5 text-left",children:[h.jsx("span",{className:"text-text-secondary",children:GJt(f.timestamp)}),h.jsx("span",{className:"font-medium",children:nB(f.value)})]}),children:h.jsxs("svg",{width:o,height:a,viewBox:`0 0 ${String(o)} ${String(a)}`,className:"cursor-crosshair overflow-visible text-success-bg","aria-label":`Daily spend over 14 days for ${t}`,role:"img",onMouseMove:b,onMouseLeave:()=>r(null),children:[h.jsx("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",points:d}),g!=null?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:g.x,x2:g.x,y1:0,y2:a,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),h.jsx("circle",{cx:g.x,cy:g.y,r:2.5,fill:"currentColor"})]}):null]})})}function C6e({points:e,loading:t,agentName:n}){return t?h.jsx(da,{className:"h-7 w-20 rounded"}):h.jsx(KJt,{points:e,agentName:n})}function R6e({usage:e,loading:t,agentName:n}){return t?h.jsx(da,{className:"h-4 w-8 rounded"}):(e==null?void 0:e.totalSessions)==null?h.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Session count unavailable for ${n}`,children:"—"}):h.jsx("span",{className:"text-text-primary text-sm font-medium","aria-label":`${String(e.totalSessions)} sessions`,children:e.totalSessions})}function I6e({usage:e,loading:t,agentName:n}){return t?h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx(da,{className:"h-4 w-14 rounded"}),h.jsx(da,{className:"h-3 w-20 rounded"})]}):(e==null?void 0:e.totalCostUsd)==null?h.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Spend unavailable for ${n}`,children:"—"}):h.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h.jsx("span",{className:"text-text-primary text-sm font-medium",children:nB(e.totalCostUsd)}),e.costPerSessionUsd!=null?h.jsxs("span",{className:"text-text-secondary text-xs",children:[nB(e.costPerSessionUsd)," / session"]}):null]})}function c$({label:e,children:t}){return h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-text-secondary text-xs uppercase tracking-wide",children:e}),t]})}function YJt({usage:e,loading:t,agentName:n,showMetrics:r}){return r?h.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[h.jsx(c$,{label:fy.sessions,children:h.jsx(R6e,{usage:e,loading:t,agentName:n})}),h.jsx(c$,{label:fy.spend,children:h.jsx(I6e,{usage:e,loading:t,agentName:n})}),h.jsx(c$,{label:fy.daily,children:h.jsx(C6e,{points:e==null?void 0:e.dailyPoints,loading:t,agentName:n})})]}):null}function ZJt({subject:e}){if(e==null)return h.jsx("span",{className:"text-text-secondary text-sm",children:"—"});const t=c6e(e),n=A3(t)||"?";return h.jsx(sr,{content:t,children:h.jsxs("span",{className:"flex min-w-0 max-w-[14rem] items-center gap-2",children:[h.jsx(rE,{size:"sm","aria-hidden":!0,children:h.jsx(oE,{children:n})}),h.jsx("span",{className:"text-text-secondary truncate text-sm",children:t})]})})}function eN(e){return"name"in e&&typeof e.name=="string"?e.name:null}var XJt=({query:e,setQuery:t,placeholder:n="Search"})=>h.jsxs("label",{className:"relative block",children:[h.jsx(be,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),h.jsx("input",{type:"search",value:e,onChange:r=>t(r.target.value),placeholder:n,className:"border-input-border bg-input-box-bg text-text-primary placeholder:text-text-secondary/70 h-8 w-full rounded-md border py-1 pr-3 pl-8 text-sm outline-none",autoFocus:!0})]}),qJt=XJt,nC=4,QJt=256;function JJt({optionCount:e,hasFooter:t}){const n=Math.max(e,1)*32,r=t?40:0;return Math.min(8+n+r,QJt)}function een({preferred:e,spaceAbove:t,spaceBelow:n,menuHeight:r}){return e==="bottom"?n>=r?"bottom":t>=r||t>n?"top":"bottom":t>=r?"top":n>=r||n>t?"bottom":"top"}function rB(e){const[t,n]=_.useState(!1),r=_.useRef(e.onOpenChange);_.useLayoutEffect(()=>{r.current=e.onOpenChange},[e.onOpenChange]);const o=_.useCallback(T=>{var C;n(T),(C=r.current)==null||C.call(r,T)},[]),[a,i]=_.useState(null),s=_.useRef(null),l=_.useRef(null),c=_.useRef(null),u=_.useRef(null),d=_.useRef(!1),f=_.useId(),g=e.menuPlacement??"bottom",b=e.footer!=null,v=e.options.length;_.useLayoutEffect(()=>{if(!t){i(null);return}const T=()=>{var L;const R=l.current;if(!R)return;const N=R.getBoundingClientRect(),O=window.innerHeight-N.bottom-nC,P=N.top-nC,j=(L=c.current)==null?void 0:L.offsetHeight,D=j!=null&&j>0?j:JJt({optionCount:v,hasFooter:b}),z=een({preferred:g,spaceAbove:P,spaceBelow:O,menuHeight:D});i({top:z==="top"?N.top-nC:N.bottom+nC,left:N.left,width:N.width,placement:z})};T();const C=requestAnimationFrame(T);return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{cancelAnimationFrame(C),window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[t,g,v,b]),_.useEffect(()=>{if(!t)return;const T=C=>{var R,N;C.target instanceof Node&&((R=s.current)!=null&&R.contains(C.target)||(N=c.current)!=null&&N.contains(C.target)||o(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t,o]),_.useEffect(()=>{var R,N,O;if(!t){d.current=!1;return}if(a==null||d.current)return;const T=(R=u.current)==null?void 0:R.querySelector('[role="option"][aria-selected="true"]'),C=(N=u.current)==null?void 0:N.querySelector('[role="option"]:not([aria-disabled="true"])');(O=T??C)==null||O.focus(),d.current=!0},[t,a]),_.useEffect(()=>{if(!t)return;const T=C=>{var P,j,D;if(C.key==="Escape"){C.preventDefault(),o(!1),(P=l.current)==null||P.focus();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(C.key))return;const R=Array.from(((j=u.current)==null?void 0:j.querySelectorAll('[role="option"]:not([aria-disabled="true"])'))??[]);if(R.length===0)return;C.preventDefault();const N=R.findIndex(z=>z===document.activeElement),O=C.key==="Home"?0:C.key==="End"?R.length-1:C.key==="ArrowDown"?(N+1)%R.length:(N-1+R.length)%R.length;(D=R[O])==null||D.focus()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[t,o]);const y=T=>e.multiple?e.value.includes(T):e.value===T,w=e.options.filter(T=>y(T.value)).map(T=>T.label),S=w.length===0?e.placeholder??"Select":e.multiple&&w.length>1?`${w.length} selected`:w[0],E=T=>{var C;if(!T.disabled){if(e.multiple){e.onValueChange(e.value.includes(T.value)?e.value.filter(R=>R!==T.value):[...e.value,T.value]);return}e.onValueChange(T.value),o(!1),(C=l.current)==null||C.focus()}},A=t&&a!=null?Ui.createPortal(h.jsxs("div",{ref:c,className:pe(R3("fixed z-[200]"),e.menuClassName),style:{top:a.top,left:a.left,width:a.width,transform:a.placement==="top"?"translateY(-100%)":void 0},onMouseDown:T=>T.stopPropagation(),children:[h.jsx("div",{ref:u,id:f,role:"listbox","aria-label":e["aria-label"],"aria-multiselectable":e.multiple||void 0,children:e.options.length===0?e.emptyContent:e.options.map(T=>{const C=y(T.value),R=h.jsxs("button",{type:"button",role:"option","aria-selected":C,"aria-disabled":T.disabled||void 0,disabled:T.disabled,className:vm(),onClick:()=>E(T),children:[h.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.label}),h.jsx(be,{name:"check",className:pe("ml-auto size-4 shrink-0",C?"opacity-100":"opacity-0")})]});return T.disabled===!0&&T.disabledReason!==void 0?h.jsx(sr,{content:T.disabledReason,side:"right",className:"max-w-xs whitespace-normal text-left",triggerClassName:"block w-full",interactive:!1,children:h.jsx("span",{className:"block w-full",children:R})},T.value):h.jsx(_.Fragment,{children:R},T.value)})}),e.footer]}),w3(s.current)):null;return h.jsxs("div",{ref:s,className:pe("relative",e.className),children:[h.jsx("button",{ref:l,type:"button",disabled:e.disabled,"aria-label":e["aria-label"],"aria-haspopup":"listbox","aria-expanded":t,"aria-controls":t?f:void 0,className:e.prefix!=null?k6e():C3(),onClick:()=>o(!t),onKeyDown:T=>{(T.key==="ArrowDown"||T.key==="Enter"||T.key===" ")&&(T.preventDefault(),o(!0))},children:e.prefix!=null?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-primary shrink-0 border-r border-border px-3 font-semibold",children:e.prefix}),h.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-2 px-2",children:[h.jsx("span",{className:"bg-primary-button-bg/10 text-text-primary truncate rounded px-2 py-0.5 text-sm",children:S}),h.jsx(be,{name:"chevron-down",className:"text-text-secondary size-4 shrink-0"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"truncate",children:S}),h.jsx(be,{name:"chevron-down",className:"size-4 shrink-0"})]})}),A]})}var ten=10,nen=[10,25,50];function ren({className:e,containerClassName:t,...n}){return h.jsx("div",{className:pe("w-full overflow-x-auto",t),children:h.jsx("table",{className:pe("w-full min-w-full border-collapse bg-primary-bg text-sm",e),...n})})}function oen({className:e,...t}){return h.jsx("thead",{className:pe("bg-primary-bg",e),...t})}function aen({className:e,...t}){return h.jsx("tbody",{className:pe("[&>tr:not(:last-child)>td]:after:block",e),...t})}function N6e({className:e,...t}){return h.jsx("tr",{className:pe("group/table-row hover:bg-ghost-button-hover/40","[&_td:first-child_a]:text-text-primary [&_td:first-child_button]:text-text-primary","hover:[&_td:first-child_a]:underline hover:[&_td:first-child_button]:underline",e),...t})}function sg({className:e,...t}){return h.jsx("th",{className:pe("text-text-secondary p-3 text-left text-xs font-normal tracking-wide uppercase",e),...t})}function lg({className:e,...t}){return h.jsx("td",{className:pe("text-text-secondary relative px-3 py-3","after:bg-border after:pointer-events-none after:absolute after:right-0 after:bottom-0 after:left-0 after:hidden after:h-px","first:after:left-3 last:after:right-3",e),...t})}function xxe({pageSize:e,rowCount:t,canPrev:n,canNext:r,onPrev:o,onNext:a,onPageSizeChange:i,pageSizeOptions:s=nen,className:l}){const c=s.map(u=>({value:String(u),label:String(u)}));return h.jsxs("div",{className:pe("text-text-secondary flex flex-wrap items-center justify-between gap-3 px-3 py-2 text-sm",l),children:[h.jsx("p",{className:"tabular-nums","aria-live":"polite",children:t===0?"Showing 0":`Showing ${String(t)}`}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsxs("label",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),h.jsx(rB,{"aria-label":"Rows per page",className:"w-[4.5rem]",value:String(e),options:c,onValueChange:u=>{i(Number(u))}})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{type:"button","aria-label":"Previous page",disabled:!n,className:rn({variant:"ghost",size:"icon"}),onClick:o,children:h.jsx(be,{name:"chevron-left"})}),h.jsx("button",{type:"button","aria-label":"Next page",disabled:!r,className:rn({variant:"ghost",size:"icon"}),onClick:a,children:h.jsx(be,{name:"chevron-right"})})]})]})]})}var wxe=[10,25];function ien(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function _xe({title:e,names:t}){return h.jsxs("span",{className:"flex max-w-xs flex-col gap-1.5 text-left",children:[h.jsx("span",{className:"text-[0.625rem] font-medium tracking-wide text-text-secondary uppercase",children:e}),h.jsx("span",{className:"flex flex-col gap-0.5",children:t.map(n=>h.jsx("span",{className:"break-all",children:n},n))})]})}function sen({agentName:e,onOpen:t,disabled:n,alwaysShowAdd:r=!1}){return h.jsxs(h.Fragment,{children:[r?null:h.jsx("span",{"aria-hidden":!0,className:"text-text-secondary text-sm md:group-hover:hidden",children:"-"}),h.jsxs(Tn.Ghost,{type:"button",size:"small",disabled:n,"aria-label":`Add schedule for ${e}`,className:r?"inline-flex":"hidden md:group-hover:inline-flex",onClick:t,children:[h.jsx(be,{name:"plus",className:"size-3.5 shrink-0"}),"Schedule"]})]})}function len({name:e,description:t,createdBySubject:n,onOpen:r}){const o=r==null?h.jsx("span",{className:"text-text-primary block truncate font-medium",children:e}):h.jsx("button",{type:"button",className:"block max-w-full cursor-pointer text-left","aria-label":`Open ${e}`,onClick:r,children:h.jsx("span",{className:"text-text-primary block truncate font-medium",children:e})}),a=t==null?o:h.jsx(sr,{content:t,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:o});return h.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[a,n!=null?h.jsx(ZJt,{subject:n}):null]})}function cen({agentName:e,modelLabel:t,modelTitle:n,skillNames:r,mcpNames:o,className:a}){const i=r.length,s=o.length;return t!=null||i>0||s>0?h.jsxs("div",{className:pe("flex min-w-0 flex-col gap-0.5",a),children:[t!=null?h.jsx(sr,{content:n,children:h.jsx("span",{className:"truncate text-sm font-medium text-text-primary","aria-label":n,children:t})}):h.jsx("span",{className:"text-text-secondary text-sm",children:"—"}),s===0&&i===0?h.jsx("span",{className:"text-text-secondary text-xs",children:"no tools"}):h.jsxs("span",{className:"text-text-secondary inline-flex min-w-0 flex-wrap items-center gap-x-1 text-xs",children:[s>0?h.jsx(sr,{content:_xe({title:"MCP",names:o}),className:"max-w-xs whitespace-normal",children:h.jsxs("span",{className:"cursor-default","aria-label":`MCP: ${o.join(", ")}`,children:[s," MCP"]})}):null,s>0&&i>0?h.jsx("span",{"aria-hidden":!0,children:"•"}):null,i>0?h.jsx(sr,{content:_xe({title:i===1?"Skill":"Skills",names:r}),className:"max-w-xs whitespace-normal",children:h.jsxs("span",{className:"cursor-default","aria-label":`Skills: ${r.join(", ")}`,children:[i," skill",i===1?"":"s"]})}):null]})]}):h.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Configuration unavailable for ${e}`,children:"—"})}function Sxe({scheduleSummary:e,agentName:t,onOpenSchedules:n,onCreateSchedule:r,canUseAgent:o,alwaysShowAdd:a=!1}){return e===void 0?null:e!=null&&e.count>0?h.jsx(uen,{summary:e,agentName:t,onOpen:n,disabled:!o}):e!=null?h.jsx(sen,{agentName:t,onOpen:r,disabled:!o,alwaysShowAdd:a}):h.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Schedule count unavailable for ${t}`,children:"—"})}function kxe(e){return h.jsx("span",{className:"flex flex-col text-left",children:e.map((t,n)=>h.jsxs("span",{children:[t,n<e.length-1?",":""]},t))})}function uen({summary:e,agentName:t,onOpen:n,disabled:r}){const o=e.pausedCount,a=e.count-o,i=[...a>0?[`${a} active`]:[],...o>0?[`${o} paused`]:[]];return h.jsxs("button",{type:"button",disabled:r,"aria-label":`${i.join(", ")} schedules for ${t}`,className:"inline-flex cursor-pointer items-center gap-1.5",onClick:n,children:[a>0?h.jsx(sr,{content:kxe(e.activeNames),className:"whitespace-normal",children:h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-emerald-600/30 bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",children:[h.jsx(be,{name:"calendar-clock",className:"size-3.5 shrink-0"}),h.jsxs("span",{children:[a," Active"]})]})}):null,o>0?h.jsx(sr,{content:kxe(e.pausedNames),className:"whitespace-normal",children:h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-amber-600/30 bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-800 dark:border-amber-400/35 dark:bg-amber-500/15 dark:text-amber-300",children:[a===0?h.jsx(be,{name:"calendar-clock",className:"size-3.5 shrink-0"}):null,h.jsxs("span",{children:[o," Paused"]}),h.jsx(be,{name:"triangle-exclamation",className:"size-3.5 shrink-0"})]})}):null]})}function den({agent:e,canMutate:t,canUseAgent:n=!0,canManageAgent:r=!0,canDeleteAgent:o=!0,canManageSchedules:a,scheduleSummary:i,usage:s,showMetricsColumns:l=!1,onOpenSchedules:c,onCreateSchedule:u,onOpen:d,onTry:f,onEdit:g,onManageSchedules:b,variant:v="row"}){var B;const y=Ge("PermissionGuard"),w=Ge("AgentLibraryUsageCells"),S=e.agentSpec,E=S==null?void 0:S.model.name,A=((S==null?void 0:S.skills)??[]).map(eN).filter(V=>V!=null),T=((S==null?void 0:S.mcpServers)??[]).map(eN).filter(V=>V!=null),C=E!=null?ien(E):null,R=E??"",N=i!=null&&i.count===0,O=((B=e.description)==null?void 0:B.trim())||null,P=O!=null&&O!==e.name?O:null,j=l&&s==null,D=h.jsx(w,{loading:j,agentName:e.name,showMetrics:l,...s!==void 0?{usage:s}:{}}),z=h.jsx(i6e,{agentName:e.name,...O!=null?{description:O}:{},...S!=null?{agentSpec:S}:{},canMutate:t,canUse:n,canManage:r,canDelete:o,canManageSchedules:a,onEdit:g,...b!=null?{onManageSchedules:b}:{}}),L=h.jsx(y,{allowed:n,children:h.jsxs(Tn.Secondary,{type:"button","aria-label":`Try agent ${e.name}`,size:"large",onClick:f,children:[h.jsx(be,{name:"play",className:"size-3.5"}),"Try"]})}),$=h.jsx(cen,{agentName:e.name,modelLabel:C,modelTitle:R,skillNames:A,mcpNames:T}),U=h.jsx(len,{name:e.name,description:P,...e.createdBySubject!=null?{createdBySubject:e.createdBySubject}:{},...d!=null?{onOpen:d}:{}});return v==="card"?h.jsxs("li",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card-bg p-3",children:[h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx("div",{className:"min-w-0 flex-1",children:U}),z]}),$,D,h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("div",{className:"min-w-0",children:h.jsx(Sxe,{scheduleSummary:i,agentName:e.name,...c!=null?{onOpenSchedules:c}:{},...u!=null?{onCreateSchedule:u}:{},canUseAgent:n,alwaysShowAdd:!0})}),L]})]}):h.jsxs(N6e,{className:N?"group":void 0,children:[h.jsx(lg,{className:"w-72 max-w-72",children:U}),h.jsx(lg,{children:$}),i!==void 0?h.jsx(lg,{children:h.jsx(Sxe,{scheduleSummary:i,agentName:e.name,...c!=null?{onOpenSchedules:c}:{},...u!=null?{onCreateSchedule:u}:{},canUseAgent:n})}):null,l?h.jsxs(h.Fragment,{children:[h.jsx(lg,{children:h.jsx(R6e,{usage:s,loading:j,agentName:e.name})}),h.jsx(lg,{children:h.jsx(I6e,{usage:s,loading:j,agentName:e.name})}),h.jsx(lg,{className:"w-28",children:h.jsx(C6e,{points:s==null?void 0:s.dailyPoints,loading:j,agentName:e.name})})]}):null,h.jsx(lg,{className:"w-px",children:h.jsxs("div",{className:"flex items-center justify-end gap-3",children:[L,z]})})]})}function pen(e){const t=new Map;for(const n of e){const r=n.agentId,o=t.get(r)??{count:0,pausedCount:0,activeNames:[],pausedNames:[]},a=n.status==="paused",i={count:o.count+1,pausedCount:o.pausedCount+(a?1:0),activeNames:a?o.activeNames:[...o.activeNames,n.name],pausedNames:a?[...o.pausedNames,n.name]:o.pausedNames};t.set(r,i),n.agentName!=null&&n.agentName!==""&&n.agentName!==r&&t.set(n.agentName,i)}return t}async function fen({listSchedules:e,agentIds:t}){if(t.length===0)return[];const n=[];let r;do{const o=await e({agentIds:t,limit:25,...r===void 0?{}:{pageToken:r}});n.push(...o.data),r=o.nextPageToken}while(r!=null&&r!=="");return n}function hen({onSelectAgent:e,headerStart:t}){const n=_m(),r=km(),{updateShareSearch:o}=T3(),a=N0(),i=YN(),s=Ge("AgentLibraryRow"),l=us(),[c,u]=_.useState(()=>Qie(window.location.search).agentName??""),[d,f]=_.useState(null),g=_.useRef(!1),b=n.libraryOpen,v=n.isComposerEnabled===!0,y=n.agentsListEpoch,w=uk({schedules:i}),S=ck({sessions:a}),E=w&&S;_.useEffect(()=>{if(!b){u("");return}g.current=!0,u(Qie(window.location.search).agentName??"")},[b]),_.useEffect(()=>{if(b){if(g.current){g.current=!1;return}set({agentName:c.trim().length===0?null:c})}},[b,c]);const A=_.useCallback(()=>{l(io.Library.CLOSED),n.setLibraryOpen(!1),u("")},[n,l]);_.useEffect(()=>{if(!b)return;const q=ne=>{ne.key==="Escape"&&(aAe()||(ne.stopImmediatePropagation(),A()))};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[A,b]);const{agents:T,isInitialLoading:C,isSearching:R,error:N,pageSize:O,setPageSize:P,canPrev:j,canNext:D,goPrev:z,goNext:L}=lAe({enabled:b,query:c,refreshKey:y,mode:"paged",limit:ten}),$=j||D,U=b?T.map(Jc):[],{allows:B}=Jk({resourceType:"agent",resourceIds:U}),{usageByAgentId:V,metricsEnabled:G}=HJt({agentIds:U,refreshKey:y});_.useEffect(()=>{if(!b||i==null||T.length===0){f(null);return}let q=!1;f(null);const ne=T.map(Jc);return fen({listSchedules:i.listSchedules,agentIds:ne}).then(he=>{q||f(pen(he))}).catch(()=>{q||f(null)}),()=>{q=!0}},[T,b,i,y]);const F=({agentId:q,isNew:ne})=>{l(io.Library.AGENT_SCHEDULES_OPENED,{agent_id:q}),eet({agent:null,status:null,q:null,isNew:ne===!0?!0:null,scheduleId:null}),o({agentId:q,tab:"schedules",sessionId:null,view:null,timeRange:null}),n.openLibraryAgent(q)},Z=q=>{l(io.Library.AGENT_TRIED,{agent_id:Jc(q),agent_name:q.name}),e==null||e(q.name),n.selectLibraryAgent({isMutable:!1,agentId:Jc(q),agentName:q.name})},J=(q,ne)=>{l(io.Library.AGENT_EDITED,{agent_id:Jc(q),agent_name:q.name}),e==null||e(q.name),n.selectLibraryAgent({isMutable:!0,isCreateAgent:!0,agentId:Jc(q),agentName:q.name,...q.description===void 0?{}:{description:q.description},agentSpec:ne})};if(!b)return null;const W=(q,ne)=>{const he=q.agentSpec,se=q.agentId,ie=Jc(q),ue=w?(d==null?void 0:d.get(ie))??(d==null?void 0:d.get(q.name))??(d==null?null:{count:0,pausedCount:0,activeNames:[],pausedNames:[]}):void 0,te=V.get(ie);return h.jsx(s,{agent:q,canMutate:v,canUseAgent:B(ie,"USE"),canManageAgent:B(ie,"MANAGE"),canDeleteAgent:B(ie,"DELETE"),canManageSchedules:E,showMetricsColumns:G,variant:ne,...te!==void 0?{usage:te}:{},...ue!==void 0?{scheduleSummary:ue}:{},...E&&se!=null?{onOpenSchedules:()=>F({agentId:se}),onCreateSchedule:()=>F({agentId:se,isNew:!0}),onManageSchedules:()=>F({agentId:se})}:{},...S&&se!=null?{onOpen:()=>{l(io.Library.AGENT_DETAILS_OPENED,{agent_id:se,agent_name:q.name}),o({agentId:se,tab:"overview",sessionId:null,view:null,timeRange:null}),n.openLibraryAgent(se)}}:{},onTry:()=>{B(ie,"USE")&&Z(q)},onEdit:()=>{he!=null&&B(ie,"MANAGE")&&J(q,he)}},ie)},Y=h.jsx(xxe,{pageSize:O,rowCount:T.length,canPrev:j,canNext:D,onPrev:z,onNext:L,pageSizeOptions:wxe,onPageSizeChange:P});return h.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[h.jsx(WH,{title:"Agents",start:t,end:h.jsxs("div",{className:"w-56 shrink-0",children:[h.jsx(qJt,{query:c,setQuery:u,placeholder:"Search agents"}),R?h.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null]})}),h.jsx("div",{className:"bg-secondary-bg/40 flex min-h-0 flex-1 flex-col",children:h.jsx("div",{className:pe("min-h-0 flex-1 overflow-y-auto p-4",N?"flex flex-col":void 0),"aria-label":"Agents",children:C?h.jsx("div",{className:"flex flex-col gap-2 p-1",role:"status","aria-label":"Loading agents",children:Array.from({length:6},(q,ne)=>h.jsx(da,{className:pe("w-full rounded-md",r?"h-32":"h-14")},ne))}):N?h.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:h.jsx(n2,{title:"Couldn't load agents",description:N,className:"h-auto min-h-0 flex-none py-0"})}):T.length===0&&!$?h.jsx(n2,{title:"No Agents Found",description:c.trim()?h.jsxs(h.Fragment,{children:["No search results found for ",h.jsx(pxe,{children:c.trim()})]}):"Build one in a chat, then save it as an agent."}):T.length===0?h.jsxs("div",{className:"flex min-h-full flex-col",children:[h.jsx(n2,{title:"No Agents Found",description:c.trim()?h.jsxs(h.Fragment,{children:["No search results found for ",h.jsx(pxe,{children:c.trim()})]}):"Build one in a chat, then save it as an agent.",className:"flex-1"}),h.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:h.jsx(xxe,{pageSize:O,rowCount:0,canPrev:j,canNext:D,onPrev:z,onNext:L,pageSizeOptions:wxe,onPageSizeChange:P})})]}):r?h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsx("ul",{"aria-label":"Agents",className:"flex flex-col gap-3",children:T.map(q=>W(q,"card"))}),h.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:Y})]}):h.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[h.jsxs(ren,{children:[h.jsx(oen,{children:h.jsxs(N6e,{className:"hover:bg-transparent",children:[h.jsx(sg,{className:"w-72 min-w-72",children:"Agent"}),h.jsx(sg,{children:"Configuration"}),w?h.jsx(sg,{className:"w-[14rem]",children:"Schedules"}):null,G?h.jsxs(h.Fragment,{children:[h.jsx(sg,{children:fy.sessions}),h.jsx(sg,{children:fy.spend}),h.jsx(sg,{className:"w-28",children:fy.daily})]}):null,h.jsx(sg,{className:"w-px",children:h.jsx("span",{className:"sr-only",children:"Actions"})})]})}),h.jsx(aen,{children:T.map(q=>W(q,"row"))})]}),Y]})})})]})}function gen({className:e,compact:t=!1}){const n=Za(),r=go(),o=us(),[a,i]=_.useState(null),s=(r==null?void 0:r.isLibraryEnabled)===!0&&n!=null,l=(r==null?void 0:r.libraryOpen)===!0,c=(r==null?void 0:r.agentsListEpoch)??0;return _.useEffect(()=>{if(!s||!n||t)return;let u=!1;return n.searchAgents({limit:E1}).then(d=>{u||i(d.nextPageToken!=null&&d.nextPageToken!==""?`${E1}+`:String(d.data.length))}).catch(()=>{}),()=>{u=!0}},[s,n,c,t]),s?h.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:h.jsxs("button",{type:"button","aria-label":t?"Agents":void 0,title:t?"Agents":void 0,"aria-current":l?"page":void 0,className:rn({variant:"ghost",className:pe(fk,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?QN:"h-8 w-full !justify-start px-2.5 text-sm",l&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{l||o(io.Library.OPENED),r==null||r.setLibraryOpen(!0)},children:[h.jsx(be,{name:"library-big",size:t?14:void 0}),t?h.jsx("span",{className:"text-center",children:"Agents"}):h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"truncate",children:["Agents",a!=null?h.jsxs("span",{className:pe(!l&&"text-text-secondary"),children:[" (",a,")"]}):null]}),h.jsx(be,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}function men({total:e,current:t,canPrev:n,canNext:r,onPrev:o,onNext:a,onFocusCurrent:i,className:s}){const l=e===1?"1 tool needs your input":`${String(e)} tools need your input`;return h.jsxs("div",{"data-slot":"aui_approval-nav-banner",role:"status","aria-live":"polite","aria-label":`${l}. Click to go to approval ${String(t)} of ${String(e)}.`,onClick:i,className:pe("aui-approval-nav-banner border-approval-banner-border bg-approval-banner-bg text-approval-banner-fg flex w-full cursor-pointer items-center justify-between gap-2 border-t px-4 py-1.5 text-sm","rounded-t-[var(--composer-radius,1.5rem)]",s),children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[h.jsx("span",{className:"bg-approval-banner-accent size-2 shrink-0 rounded-full","aria-hidden":!0}),h.jsx("span",{className:"truncate font-medium leading-[1.4]",children:l})]}),h.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[h.jsxs("span",{className:"font-medium tabular-nums leading-[1.4]",children:["(",t,"/",e,")"]}),h.jsx("button",{type:"button","aria-label":"Next approval",disabled:!r,onClick:c=>{c.stopPropagation(),a()},className:"text-approval-banner-fg hover:bg-approval-banner-border/10 inline-flex size-6 items-center justify-center rounded-sm disabled:pointer-events-none disabled:opacity-40",children:h.jsx(be,{name:"arrow-down",size:"0.875rem"})}),h.jsx("button",{type:"button","aria-label":"Previous approval",disabled:!n,onClick:c=>{c.stopPropagation(),o()},className:"text-approval-banner-fg hover:bg-approval-banner-border/10 inline-flex size-6 items-center justify-center rounded-sm disabled:pointer-events-none disabled:opacity-40",children:h.jsx(be,{name:"arrow-up",size:"0.875rem"})})]})]})}function M6e({children:e,error:t,statusBanner:n,actionBar:r,className:o}){return h.jsxs("div",{"data-slot":"aui_assistant-message-root",className:pe("group/assistant relative min-w-0 max-w-full bg-assistant-message-bg text-assistant-message-text",o),children:[h.jsxs("div",{className:"min-w-0 max-w-full",children:[e,n,t&&h.jsx("div",{className:"mt-2 text-sm text-failure-bg",children:t})]}),r&&h.jsx("div",{className:"mt-1",children:r})]})}var O6e=12,ben={pdf:"file-text",ppt:"file-text",pptx:"file-text",doc:"file-text",docx:"file-text",txt:"file-text",csv:"file-spreadsheet",xls:"file-spreadsheet",xlsx:"file-spreadsheet",json:"file-code"};function ven(e){const t=e.lastIndexOf("."),n=t>0&&t<e.length-1?e.slice(t+1).toLowerCase():void 0;return n==null?"file":ben[n]??"file"}function yen(e){if(e===0)return"0 B";const t=e/(1024*1024);return t<1?`${(e/1024).toFixed(2)} KB`:`${t.toFixed(2)} MB`}function xen({name:e,sizeBytes:t,previewSrc:n,isImage:r=!1,size:o="chip",previewRem:a,onRemove:i,className:s}){if(o==="preview"&&r&&n){const u=a!=null?{width:`${a}rem`,height:`${a}rem`}:void 0;return h.jsx("div",{"data-slot":"aui_attachment-preview",style:u,className:pe("aui-attachment-preview relative shrink-0 cursor-pointer overflow-hidden rounded-lg border border-primary-button-bg/20",a==null&&"size-24",s),children:h.jsx("img",{src:n,alt:e,className:"h-full w-full object-cover"})})}const l=r&&n!=null,c=ven(e);return h.jsxs("div",{"data-slot":"aui_attachment-chip",style:a!=null?{maxWidth:`${a}rem`}:void 0,className:pe("aui-attachment-chip group relative shrink-0 overflow-hidden rounded-lg border border-primary-button-bg/20",l?"size-14":pe("bg-secondary-bg flex h-14 min-w-0 items-center gap-2 px-2 py-1.5",a==null&&"max-w-40",i!=null&&"pe-6"),s),children:[l?h.jsxs(rE,{className:"size-full rounded-none",children:[h.jsx(JQt,{src:n,alt:e,className:"object-cover"}),h.jsx(oE,{className:"rounded-none bg-secondary-bg bg-none text-text-secondary",children:h.jsx(be,{name:"file",size:"1.5rem",className:"text-text-secondary"})})]}):h.jsxs(h.Fragment,{children:[h.jsx(be,{name:c,size:"1.5rem",className:"text-text-secondary shrink-0"}),h.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h.jsx(sr,{content:e,side:"top",triggerClassName:"min-w-0",children:h.jsx("span",{className:"text-text-primary min-w-0 truncate text-sm font-medium",children:e})}),t!=null?h.jsx("span",{className:"text-text-secondary truncate text-xs",children:yen(t)}):null]})]}),i&&h.jsx("button",{type:"button","aria-label":"Remove file",title:"Remove file",className:rn({variant:"ghost",size:"icon",className:"aui-attachment-tile-remove absolute inset-e-0.5 top-0.5 z-10 size-4 rounded-full bg-black/50 text-white transition-opacity hover:bg-black/70 hover:text-white md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100"}),onClick:u=>{u.stopPropagation(),i()},children:h.jsx(be,{name:"xmark",size:"0.625rem"})})]})}function wen({className:e,...t}){return h.jsx("button",{type:"button","aria-label":"Add Attachment",title:"Add Attachment",className:rn({variant:"ghost",size:"icon",className:`size-7 rounded-full p-1 ${e??""}`}),...t,children:h.jsx(be,{name:"paperclip"})})}function _en({previewSrc:e,children:t}){const[n,r]=_.useState(!1);return e?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Open attachment preview",onClick:()=>r(!0),className:"block max-w-full cursor-pointer border-0 bg-transparent p-0 text-left",children:t}),h.jsx(vx,{open:n,onOpenChange:r,"aria-label":"Attachment preview",className:"max-w-[calc(100%-2rem)] sm:max-w-3xl",children:h.jsxs(tE,{className:"relative p-2",children:[h.jsx("span",{className:"absolute top-2 right-2 z-10 inline-flex",children:h.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:rn({variant:"ghost",size:"icon"}),onClick:()=>r(!1),children:h.jsx(be,{name:"xmark"})})}),h.jsx("div",{className:"bg-primary-bg relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:h.jsx("img",{src:e,alt:"Attachment preview",className:"block h-auto max-h-[80vh] w-auto max-w-full object-contain"})})]})})]}):h.jsx(h.Fragment,{children:t})}var P6e=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading)&&e.threadListItem.remoteId==null,FJ=_.createContext(null),j6e=_.createContext(void 0),D6e=_.createContext(null);function Sen({children:e}){const[t,n]=_.useState(null),[r,o]=_.useState("panel"),a=Ve(b=>b.threadListItem.id),i=Ve(P6e),s=t==null?null:`${t.turnId}:${t.path}`,l=_.useRef(s);l.current!==s&&(l.current=s,r!=="panel"&&o("panel"));const c=_.useRef(a);c.current!==a&&(c.current=a,n(null));const u=_.useRef(i);u.current!==i&&(u.current=i,i&&n(null));const d=_.useCallback(b=>{n(b)},[]),f=_.useCallback(()=>{n(null)},[]),g=_.useMemo(()=>({target:t,presentation:r,open:d,close:f,setPresentation:o}),[t,r,d,f,o]);return h.jsx(FJ.Provider,{value:g,children:e})}function uyn(){const e=_.useContext(FJ);if(e==null)throw new Error("File preview is only available inside FilePreviewProvider.");return e}function L6e(){return _.useContext(FJ)}function dyn({children:e}){return L6e()!=null?e:h.jsx(Sen,{children:e})}function ken({turnId:e,children:t}){return h.jsx(j6e.Provider,{value:e,children:t})}function Een(){return _.useContext(j6e)}function Ten({load:e,children:t}){return h.jsx(D6e.Provider,{value:e,children:t})}function z6e(){return _.useContext(D6e)}var Aen=2*1024*1024,Cen=1e5,$6e={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",avif:"image/avif",ico:"image/x-icon"},Ren={js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",php:"php",json:"json",css:"css",scss:"scss",xml:"markup",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",graphql:"graphql",toml:"toml"},U6e=new Set(["html","htm"]),Ien=new Set(["md","markdown"]),Exe="This file is empty.",Nen="This file is too large to preview. Download it to open it locally.",Men="This file can't be previewed here. Download it to open it locally.";function Txe(e){const t=e.split("/").pop()??e,n=t.lastIndexOf(".");return n<=0||n===t.length-1?"":t.slice(n+1).toLowerCase()}function Oen(e){return(e.length>8e3?e.slice(0,8e3):e).includes("\0")}function Pen(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{t(typeof r.result=="string"?r.result:"")},r.onerror=()=>{n(r.error??new Error("Failed to read file"))},r.readAsText(e)})}function F6e({name:e,path:t}){return Txe(t)||Txe(e)}function Axe(e){const t=F6e(e);return U6e.has(t)?"html":t==="pdf"?"pdf":$6e[t]!=null?"image":null}function jen(e){const t=e.trimStart().slice(0,300).toLowerCase();return t.startsWith("<!doctype html")||t.startsWith("<html")}function Den(e){return/^#{1,6}\s/m.test(e.trimStart().slice(0,500))}function Len(e,t){return e.type===t?e:new Blob([e],{type:t})}async function zen(e,t){if(e.size===0)return{status:"unavailable",message:Exe};if(e.size>Aen)return{status:"unavailable",message:Nen};const n=F6e(t),r=$6e[n];if(r!=null)return{status:"media",media:"image",mimeType:r};if(n==="pdf")return{status:"media",media:"pdf",mimeType:"application/pdf"};const o=await Pen(e);if(Oen(o))return{status:"unavailable",message:Men};if(o.trim().length===0)return{status:"unavailable",message:Exe};if(U6e.has(n)||n.length===0&&jen(o))return{status:"html",text:o};if(Ien.has(n)||n.length===0&&Den(o))return{status:"markdown",text:o};const a=Ren[n];return a==null?{status:"text",text:o}:{status:"text",text:o,language:a}}var $en="Couldn't load a preview of this file.",rC={view:{status:"loading"},blob:null};function Uen(e,t){return e==null?null:`${e.turnId}\0${e.path}\0${t}`}function Fen(e,t){const n=Uen(e,t),[r,o]=_.useState({key:null,...rC});return r.key!==n&&o({key:n,...rC}),_.useEffect(()=>{if(e==null||n==null)return;let a=!1,i;return o({key:n,...rC}),(async()=>{try{const s=await e.load();if(a)return;const l=await zen(s,{name:e.name,path:e.path});if(a)return;if(l.status==="media"){if(i=URL.createObjectURL(Len(s,l.mimeType)),a){URL.revokeObjectURL(i);return}o({key:n,blob:s,view:{status:"media",media:l.media,objectUrl:i}});return}o({key:n,blob:s,view:l})}catch{a||o({key:n,blob:null,view:{status:"error",message:$en}})}})(),()=>{a=!0,i!=null&&URL.revokeObjectURL(i)}},[e,t,n]),r.key===n?r:rC}function Ben({name:e,view:t}){return t.status==="loading"?h.jsx("div",{className:"flex aspect-video items-center justify-center bg-primary-bg text-text-secondary",children:h.jsx(Al,{size:16})}):t.status==="error"||t.status==="unavailable"?h.jsx("div",{className:"flex aspect-video items-center justify-center bg-primary-bg px-4 text-center text-xs text-text-secondary",children:t.message}):t.status==="html"?h.jsx("div",{className:"@container relative aspect-video overflow-hidden bg-white",children:h.jsx("iframe",{title:`Thumbnail of ${e}`,sandbox:"allow-scripts",referrerPolicy:"no-referrer",srcDoc:t.text,tabIndex:-1,style:{width:"80rem",height:"45rem",transform:"scale(calc(100cqw / 80rem))"},className:"pointer-events-none absolute top-0 left-0 origin-top-left border-0"})}):t.status==="media"&&t.media==="image"?h.jsx("div",{className:"aspect-video overflow-hidden bg-primary-bg",children:h.jsx("img",{src:t.objectUrl,alt:"",className:"h-full w-full object-cover object-top"})}):t.status==="media"&&t.media==="pdf"?h.jsx("iframe",{title:`Thumbnail of ${e}`,src:t.objectUrl,tabIndex:-1,className:"pointer-events-none aspect-video w-full border-0 bg-white"}):h.jsx("div",{className:"flex aspect-video items-center justify-center bg-primary-bg px-4 text-center text-xs text-text-secondary",children:"Open the preview to read this file."})}function Hen({name:e,onDownload:t,downloadHref:n,downloadBusy:r}){const o=rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),a=r?`Downloading ${e}`:`Download ${e}`,i=r?h.jsx(Al,{size:14}):h.jsx(be,{name:"download",size:14});return t!=null?h.jsx("button",{type:"button",onClick:t,disabled:r,"aria-busy":r||void 0,"aria-label":a,title:"Download",className:o,children:i}):n==null?null:h.jsx("a",{href:n,download:e,"aria-label":a,title:"Download",className:o,children:i})}function Ven({name:e,view:t,enlarged:n,onEnlarge:r,onDownload:o,downloadHref:a,downloadBusy:i=!1}){return h.jsxs("article",{"data-slot":"aui_inline-file-preview",className:pe("w-full max-w-80 overflow-hidden rounded-lg border bg-card-bg shadow-sm",n?"border-primary-button-bg":"border-border"),children:[h.jsx("button",{type:"button",onClick:r,"aria-pressed":n,"aria-label":`Enlarge preview of ${e}`,className:"block w-full cursor-pointer text-left",children:h.jsx(Ben,{name:e,view:t})}),h.jsxs("footer",{className:"flex items-center gap-1 border-t border-border px-2.5 py-1.5",children:[h.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:e}),h.jsx("button",{type:"button",onClick:r,"aria-pressed":n,"aria-label":`Enlarge ${e}`,title:"Enlarge preview",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"expand",size:14})}),h.jsx(Hen,{name:e,downloadBusy:i,...o!=null?{onDownload:o}:{},...a!=null?{downloadHref:a}:{}})]})]})}function B6e(e){return e.split("/").map(encodeURIComponent).join("/")}function Gen({files:e,fileDownloadBaseUrl:t,onDownloadArtifact:n,readOnly:r,readOnlyTooltip:o}){const[a,i]=_.useState(null),s=L6e(),l=Een(),c=z6e(),u=s!=null&&l!=null&&c!=null&&r!==!0,d=u?e.filter(v=>Axe(v)!=null):[],f=u?e.filter(v=>Axe(v)==null):e,g=({path:v,name:y})=>{!n||a===v||(i(v),n(v,y).finally(()=>{i(w=>w===v?null:w)}))},b=f.length===0?null:h.jsxs("details",{open:!0,className:pe("aui-sandbox-artifacts group overflow-hidden rounded-lg border border-primary-button-bg/20 bg-card-bg",d.length===0&&"my-2"),"data-testid":"aui-sandbox-artifacts",children:[h.jsx("summary",{className:"min-h-9 cursor-pointer list-none bg-primary-button-bg/5 px-3 py-2 text-xs font-medium leading-none text-primary-button-bg [&::-webkit-details-marker]:hidden",children:h.jsxs("span",{className:"inline-flex items-center gap-1",children:[h.jsx(be,{name:"chevron-down",size:13,className:"shrink-0 transition-transform group-open:rotate-180"}),h.jsx(be,{name:"file",size:16,className:"shrink-0"}),h.jsxs("span",{className:"leading-none",children:[f.length," ",f.length===1?"file":"files"," generated"]})]})}),h.jsx("div",{className:"flex flex-wrap items-center gap-y-1 px-3 py-2",children:f.map(v=>h.jsx(Ken,{file:v,downloadingPath:a,onStartDownload:g,...t!=null?{fileDownloadBaseUrl:t}:{},...n!=null?{onDownloadArtifact:n}:{},...r!=null?{readOnly:r}:{},...o!=null?{readOnlyTooltip:o}:{},...s!=null?{preview:s}:{},...l!=null?{previewTurnId:l}:{},...c!=null?{loadPreviewFile:c}:{},canPreview:u},v.path))})]});return d.length===0||s==null||l==null?b:h.jsxs("div",{className:"my-2 flex flex-col gap-2",children:[h.jsx("div",{className:"flex flex-wrap gap-2",children:d.map(v=>{var w;const y=t?`${t}${B6e(v.path)}`:void 0;return h.jsx(Wen,{name:v.name,path:v.path,turnId:l,enlarged:((w=s.target)==null?void 0:w.path)===v.path&&s.target.turnId===l,onEnlarge:()=>{const S=c;S!=null&&s.open({name:v.name,path:v.path,turnId:l,load:()=>S(v.path)})},downloadBusy:a===v.path,...n!=null?{onDownload:()=>g({path:v.path,name:v.name})}:{},...y!=null?{downloadHref:y}:{}},v.path)})}),b]})}function Wen({name:e,path:t,turnId:n,enlarged:r,onEnlarge:o,onDownload:a,downloadHref:i,downloadBusy:s}){const l=z6e(),c=_.useMemo(()=>l==null?null:{name:e,path:t,turnId:n,load:()=>l(t)},[l,e,t,n]),u=Fen(c,0);return h.jsx(Ven,{name:e,view:u.view,enlarged:r,onEnlarge:o,downloadBusy:s,...a!=null?{onDownload:a}:{},...i!=null?{downloadHref:i}:{}})}function Ken({file:e,downloadingPath:t,onStartDownload:n,fileDownloadBaseUrl:r,onDownloadArtifact:o,readOnly:a,readOnlyTooltip:i,preview:s,previewTurnId:l,loadPreviewFile:c,canPreview:u}){var w;const{name:d,path:f}=e;if(a){const S="mr-3 inline-flex min-h-7 items-center gap-1.5 border-r border-border pr-3 text-xs text-text-secondary last:mr-0 last:border-r-0 last:pr-0",E=h.jsxs(h.Fragment,{children:[h.jsx(be,{name:"file",size:14,className:"shrink-0"}),h.jsx("span",{className:"leading-none",children:d})]});return i?h.jsx(sr,{content:i,triggerClassName:S,children:h.jsx("span",{className:"inline-flex items-center gap-1.5",children:E})}):h.jsx("span",{className:S,children:E})}const g=r?`${r}${B6e(f)}`:void 0,b=!!(o||g),v=t===f,y=S=>{if(!o||v){S.preventDefault();return}S.preventDefault(),n({path:f,name:d})};if(u&&s!=null&&l!=null&&c!=null){const S=((w=s.target)==null?void 0:w.path)===f&&s.target.turnId===l,E=()=>{const A=c;s.open({name:d,path:f,turnId:l,load:()=>A(f)})};return h.jsxs("span",{className:pe("mr-3 inline-flex min-h-7 items-center gap-1 border-r border-border pr-3 last:mr-0 last:border-r-0 last:pr-0",S&&"rounded-md bg-primary-button-bg/10"),children:[h.jsxs("button",{type:"button",onClick:E,"aria-pressed":S,title:`Preview ${d}`,"aria-label":`Preview ${d}`,className:"inline-flex cursor-pointer items-center gap-1.5 text-xs text-text-primary hover:text-primary-button-bg",children:[h.jsx(be,{name:"file",size:14,className:"shrink-0 text-text-secondary"}),h.jsx("span",{className:"leading-none",children:d})]}),b?o?h.jsx("button",{type:"button",onClick:()=>n({path:f,name:d}),disabled:v,"aria-busy":v||void 0,"aria-label":v?`Downloading ${d}`:`Download ${d}`,title:v?`Downloading ${d}`:`Download ${d}`,className:pe("inline-flex items-center text-primary-button-bg",v?"cursor-progress":"cursor-pointer hover:text-primary-button-bg"),children:v?h.jsx(Al,{size:14}):h.jsx(be,{name:"download",size:14})}):h.jsx("a",{href:g,download:d,"aria-label":`Download ${d}`,title:`Download ${d}`,className:"inline-flex items-center text-primary-button-bg hover:text-primary-button-bg",children:h.jsx(be,{name:"download",size:14})}):null]})}return h.jsxs("a",{href:b?g??"#":void 0,onClick:o?y:void 0,"aria-busy":v||void 0,className:pe("mr-3 inline-flex min-h-7 items-center gap-1.5 border-r border-border pr-3 text-xs text-text-primary last:mr-0 last:border-r-0 last:pr-0",b&&!v&&"cursor-pointer hover:text-primary-button-bg",(v||!b)&&"pointer-events-none opacity-60"),download:d,"aria-label":v?`Downloading ${d}`:`Download ${d}`,children:[h.jsx(be,{name:"file",size:14,className:"shrink-0 text-text-secondary"}),h.jsx("span",{className:"leading-none",children:d}),v?h.jsx(Al,{size:14,className:"shrink-0 text-primary-button-bg"}):h.jsx(be,{name:"download",size:14,className:"shrink-0 text-primary-button-bg"})]})}function Yen(){const e=go();if(e==null||e.mode.status!=="active")return null;const t=e.mode.agentName??e.mode.agentId;return t!=null&&t.length>0?{name:t,isEditing:e.mode.isMutable&&e.mode.agentId!=null,allowThreadTitle:!1}:e.mode.isMutable?{name:e.mode.isCreateAgent?"New Agent":"New Chat",isEditing:!1,allowThreadTitle:!0}:null}function Zen(){return Yen()!==null}function H6e(){var n,r;const e=go(),{agentSpec:t}=Bu();return e==null||e.mode.status!=="active"||!e.mode.isMutable||!e.mode.isCreateAgent?!1:!!((r=(n=t==null?void 0:t.model)==null?void 0:n.name)!=null&&r.trim())}function V6e(){const e=go(),t=Ve(P6e);return e!=null&&e.mode.status==="active"&&!t}function Xen(){const e=go();return e!=null&&pk(e.mode)}function pyn(){const e=Zen(),t=H6e(),n=V6e(),r=Xen();return e||t||n||r}function qen(){const e=go(),{agentSpec:t}=Bu(),n=V6e(),r=_3(),o=Ge("PermissionGuard");return!n||e==null?null:h.jsx(o,{allowed:r,children:h.jsxs("button",{type:"button",title:"New Chat",className:rn({variant:"ghost",size:"large"}),onClick:()=>{r&&e.clearChat(pk(e.mode)?t??void 0:void 0)},children:[h.jsx(be,{name:"square-pen",size:"0.875rem"}),"New Chat"]})})}function oC({onClick:e,tooltip:t,icon:n,active:r,variant:o="ghost"}){return h.jsx("button",{type:"button",onClick:e,title:t,className:rn({variant:o,size:"icon",className:pe("h-7 w-7 shrink-0",o==="ghost"&&"text-text-secondary hover:text-text-primary",r&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text")}),"aria-label":t,children:h.jsx(be,{name:n,size:"0.875em"})})}function Qen({value:e,language:t,theme:n,filename:r,onChange:o,onMount:a,beforeMount:i,className:s,height:l,showToolbar:c=!0,defaultShowLineNumbers:u=!1}){const d=Ge("MonacoEditorCore"),[f,g]=_.useState(u),[b,v]=_.useState(!1),[y,w]=_.useState(!1),S=_.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{w(!0),setTimeout(()=>w(!1),2e3)})},[e]),E=_.useCallback(()=>{const C=new Blob([e],{type:"text/plain"}),R=URL.createObjectURL(C),N=document.createElement("a");N.href=R,N.download=r??`code.${t??"txt"}`,N.click(),URL.revokeObjectURL(R)},[e,r,t]),A={lineNumbers:f?"on":"off",minimap:{enabled:!1},scrollBeyondLastLine:!1,renderFinalNewline:"off",wordWrap:"on"},T=b?"100%":l??320;return h.jsxs("div",{className:pe("aui-code-editor flex flex-col overflow-hidden rounded-md border border-border",b&&"fixed inset-4 z-50 bg-primary-bg shadow-2xl",s),children:[c&&h.jsxs("div",{className:"flex items-center justify-between gap-1 border-b border-border px-2 py-1",children:[r&&h.jsx("span",{className:"truncate text-xs text-text-secondary",children:r}),h.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[h.jsx(oC,{onClick:()=>g(C=>!C),tooltip:f?"Hide line numbers":"Show line numbers",icon:"list-ol",active:f}),h.jsx(oC,{onClick:S,tooltip:y?"Copied!":"Copy",icon:y?"check":"copy",variant:"secondary"}),h.jsx(oC,{onClick:E,tooltip:"Download",icon:"download"}),h.jsx(oC,{onClick:()=>v(C=>!C),tooltip:b?"Collapse":"Expand",icon:b?"compress":"expand"})]})]}),h.jsx("div",{className:"flex-1 overflow-hidden",style:b?void 0:{height:T},children:h.jsx(d,{value:e,language:t,theme:n,options:A,onChange:o,onMount:a,beforeMount:i,height:"100%"})})]})}function Jen({onAttach:e}){return e?h.jsx("button",{type:"button","aria-label":"Attach",title:"Attach",className:rn({variant:"ghost",size:"icon"}),onClick:e,children:h.jsx(be,{name:"paperclip"})}):null}function etn(e){return null}function ttn({canSubmit:e,isRunning:t,isCancelling:n=!1,hasContent:r,blockedReason:o,onSubmit:a,onCancel:i}){if((t||n)&&!r)return h.jsxs(Tn.Primary,{type:"button",size:"small",disabled:!i||n,onClick:i,"aria-label":n?"Cancelling":"Cancel",children:[h.jsx(Al,{size:14}),n?"Cancelling...":"Cancel"]});const s=!e&&o!=null?o:"Send message";return h.jsx(Tn.Primary,{type:"button",size:"icon","data-slot":"aui_composer-send",className:"shadow-none",disabled:!e,onClick:a,title:s,"aria-label":s,children:h.jsx(be,{name:"arrow-up"})})}function ntn({input:e,disabled:t,canSubmit:n,isRunning:r=!1,isCancelling:o=!1,hasContent:a=!1,blockedReason:i,attachments:s,modelLabel:l,modelIcon:c,connectorStatusLabel:u,onSubmit:d,onCancel:f,onAttach:g,className:b}){const v=Ge("ComposerLeftSection"),y=Ge("ComposerRightSection"),w=Ge("ComposerSendButton");return h.jsxs("div",{"data-slot":"aui_composer-shell",className:pe("focus-within:ring-focus-ring/20 flex w-full flex-col gap-2 rounded-[0.75rem] border border-transparent bg-card-bg p-[var(--composer-padding,0.5rem)] shadow-[0_1.25rem_1.875rem_-1.25rem_color-mix(in_oklab,var(--primary-button-bg)_8%,transparent),0_0.75rem_1.25rem_-0.25rem_color-mix(in_oklab,var(--primary-button-bg)_8%,transparent)] transition-colors focus-within:ring-3","[background-clip:padding-box,border-box] [background-image:linear-gradient(var(--card-bg),var(--card-bg)),linear-gradient(to_bottom,color-mix(in_oklab,var(--primary-button-bg)_25%,transparent),var(--primary-button-bg))] [background-origin:border-box]","dark:border-border/60 dark:shadow-none dark:[background-clip:border-box] dark:[background-image:none]",b),children:[s,e,h.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2 px-1",children:[h.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2",children:[h.jsx(v,{disabled:t,isRunning:r,onAttach:g}),u&&h.jsx("span",{className:"text-text-secondary max-w-[12rem] truncate text-xs",children:u})]}),h.jsxs("div",{className:"ml-auto flex min-w-0 shrink-0 flex-wrap items-center justify-end gap-2",children:[l&&h.jsxs("span",{className:"bg-secondary-bg text-text-secondary flex max-w-[10rem] items-center gap-1 truncate rounded-full px-2 py-0.5 text-xs",children:[c,h.jsx("span",{className:"truncate",children:l})]}),h.jsx(y,{disabled:t,isRunning:r}),h.jsx(w,{disabled:t,canSubmit:n,isRunning:r,isCancelling:o,hasContent:a,blockedReason:i,onSubmit:d,onCancel:f})]})]})]})}function rtn(e){return typeof e!="object"||e===null?!1:Reflect.get(e,"type")==="user.message"&&typeof Reflect.get(e,"content")=="string"}function G6e(e){const t=Reflect.get(e,"messages");return Array.isArray(t)?t.filter(rtn):[]}function otn({spec:e,messages:t}){return{...e,messages:t.length>0?t:void 0}}function BJ(e){const t=Reflect.get(e,"annotations");if(typeof t!="object"||t===null)return;const n=Reflect.get(t,"readOnlyHint"),r=Reflect.get(t,"destructiveHint"),o={...typeof n=="boolean"?{readOnlyHint:n}:{},...typeof r=="boolean"?{destructiveHint:r}:{}};return Object.keys(o).length>0?o:void 0}function atn(e){const t=BJ(e);return(t==null?void 0:t.readOnlyHint)===!0?"read-only":(t==null?void 0:t.destructiveHint)===!0?"destructive":"others"}function fyn(e){const t=BJ(e);if((t==null?void 0:t.readOnlyHint)===!0)return"read";if((t==null?void 0:t.destructiveHint)===!0)return"destructive";if((t==null?void 0:t.readOnlyHint)===!1)return"write"}var itn=["read-only","others","destructive"],stn={"read-only":"Read-only Actions",others:"Other Actions",destructive:"Destructive Actions"},ltn={"read-only":"Enable all read-only tools",others:"Enable all other tools",destructive:"Enable all destructive tools"},ctn={others:"Require approval for all other tools",destructive:"Require approval for all destructive tools"};function Cxe(e){const t={"read-only":[],others:[],destructive:[]};for(const n of e)t[atn(n)].push(n);return t}var aE="@all",utn="@read-only",HJ="@write",VJ="@destructive";function W6e({tag:e,tool:t}){const n=BJ(t);switch(e){case aE:return!0;case utn:return(n==null?void 0:n.readOnlyHint)===!0;case VJ:return(n==null?void 0:n.destructiveHint)===!0;case HJ:return(n==null?void 0:n.readOnlyHint)===!1&&n.destructiveHint!==!0;default:return!1}}function ym({tool:e,selectors:t}){return t.some(n=>n.startsWith("@")?W6e({tag:n,tool:e}):n===e.name)}function hyn({enableSelectors:e,disableSelectors:t,tools:n}){return n.length===0?[...e,...t].some(o=>o.startsWith("@"))?{names:[],resolved:!1}:{names:e.filter(o=>!t.includes(o)),resolved:!0}:{names:n.filter(o=>ym({tool:o,selectors:e})&&!ym({tool:o,selectors:t})).map(o=>o.name),resolved:!0}}var m0=[HJ,VJ];function Rxe(e){return ym({tool:e,selectors:m0})}function dtn({tools:e,selectors:t,newlyEnabledNames:n}){if(e.length===0||n.length===0)return[...t];const r=r2({tools:e,selectors:t});for(const a of n){const i=e.find(s=>s.name===a);i!==void 0&&(Rxe(i)?r.add(a):r.delete(a))}const o=K6e({tools:e,approved:r});return o.length===0&&!e.some(a=>Rxe(a))?[...m0]:o}function Ixe({toolName:e,tools:t,selectors:n}){const r=t.find(o=>o.name===e);return r!==void 0?ym({tool:r,selectors:n}):n.includes(aE)||n.includes(e)}function r2({tools:e,selectors:t}){return new Set(e.filter(n=>ym({tool:n,selectors:t})).map(n=>n.name))}function K6e({tools:e,approved:t}){if(e.length>0&&e.every(r=>t.has(r.name)))return[aE];const n=[HJ,VJ].filter(r=>{const o=e.filter(a=>W6e({tag:r,tool:a}));return o.length>0&&o.every(a=>t.has(a.name))});for(const r of e)t.has(r.name)&&(ym({tool:r,selectors:n})||n.push(r.name));return n}function ptn(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}function b0(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const r=Reflect.get(n,"display_name"),o=Reflect.get(n,"name"),a=typeof r=="string"?r:typeof o=="string"?o:null;if(a===null)continue;const i=Reflect.get(n,"id");t.push({id:typeof i=="string"?i:a,name:a,value:n})}return t}function hy(e){const t=Reflect.get(e,"enableTools");return!Array.isArray(t)||t.includes(aE)?"all":t.filter(n=>typeof n=="string"&&!n.startsWith("@"))}function Y6e({value:e,key:t}){const n=Reflect.get(e,t);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}function gyn(e){return Y6e({value:e,key:"enableTools"})??[aE]}function myn(e){return Y6e({value:e,key:"disableTools"})??[]}function aC(e,t){return{...e,enableTools:t==="all"?["@all"]:t}}function iC(e){const t=Reflect.get(e,"requireApprovalForTools");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[...m0]}function u$(e,t){if(ptn(t,m0)){const n={...e};return Reflect.deleteProperty(n,"requireApprovalForTools"),n}return{...e,requireApprovalForTools:[...t]}}function tN(e){return Reflect.get(e,"preload")===!0}function Nxe(e,t){return{...e,preload:t}}function GJ({connectors:e,selected:t}){if(t.length===0)return e;const n=new Map(e.map(o=>[o.id,o])),r=[];for(const o of t)n.has(o.id)||r.push({id:o.id,name:o.name});return r.length===0?e:[...r,...e]}function ftn({editor:e,spec:t,models:n,connectors:r,skills:o,loading:a,error:i,skillsDisabled:s=!1,sandboxAvailable:l=!1,instructions:c,onInstructionsSave:u,loadMcpConnector:d,loadMcpTools:f,onRefreshConnectors:g,onChange:b,onClose:v}){var ze,Ze;const y=Ge("AgentModelConfigModal"),w=Ge("AgentResourceConfigModal"),S=Ge("AgentRuntimeConfigDrawer"),E=Ge("AgentInstructionsDrawer"),[A,T]=_.useState(""),[C,R]=_.useState(null),[N,O]=_.useState(),[P,j]=_.useState(!1),[D,z]=_.useState(null),[L,$]=_.useState([]),[U,B]=_.useState({}),[V,G]=_.useState(!1),[F,Z]=_.useState(null),[J,W]=_.useState(0),Y=_.useRef(new Set),q=_.useMemo(()=>b0(t.mcpServers),[t.mcpServers]),ne=_.useMemo(()=>GJ({connectors:r,selected:q}),[r,q]),he=_.useRef(ne);he.current=ne;const se=C!==null&&ne.some(Qe=>Qe.id===C),ie=q.map(Qe=>{var ct;return(ct=ne.find(De=>De.id===Qe.id||De.name===Qe.name))==null?void 0:ct.id}).find(Qe=>Qe!==void 0),ue=(se?C:null)??ie??((ze=ne[0])==null?void 0:ze.id)??null,te=ue===null||(Ze=ne.find(Qe=>Qe.id===ue))==null?void 0:Ze.authenticated,re=_.useMemo(()=>N===void 0?ne:ne.map(Qe=>Qe.id===N.id?{...Qe,...N}:Qe),[N,ne]);_.useEffect(()=>{if(e!=="mcp"||ue===null)return;let Qe=!1;const ct=he.current.find(De=>De.id===ue);return O(void 0),j(d!==void 0),z(null),$([]),G(!1),Z(null),(async()=>{let De=ct;if(d!==void 0)try{if(De=await d(ue)??ct,Qe)return;O(De)}catch(Ye){Qe||z(Oa(Ye,"Failed to load MCP server."));return}finally{Qe||j(!1)}if(!(Qe||(De==null?void 0:De.authenticated)===!1||f===void 0)){G(!0);try{const Ye=await f(ue);Y.current.add(ue),B(yt=>({...yt,[ue]:Ye})),Qe||$(Ye)}catch(Ye){Qe||Z(Oa(Ye,"Failed to load tools."))}finally{Qe||G(!1)}}})(),()=>{Qe=!0}},[e,d,f,ue,te,J]),_.useEffect(()=>{if(e!=="mcp"||f===void 0)return;const Qe=Y.current,ct=q.flatMap(Ye=>{const yt=he.current.find(gt=>gt.id===Ye.id||gt.name===Ye.name);return yt===void 0||yt.authenticated!==!0?[]:yt.id===ue||Qe.has(yt.id)?[]:[yt.id]});if(ct.length===0)return;for(const Ye of ct)Qe.add(Ye);const De=new Set;return Promise.all(ct.map(async Ye=>{try{const yt=await f(Ye);De.add(Ye),B(gt=>({...gt,[Ye]:yt}))}catch{}})),()=>{for(const Ye of ct)De.has(Ye)||Qe.delete(Ye)}},[e,f,q,ue]);const xe=()=>{T(""),R(null),O(void 0),z(null),$([]),B({}),Y.current.clear(),Z(null),v()},Ae=e==="model"||e==="model-settings"?e:null,Me=e==="mcp"||e==="skills"?e:null,qe=Qe=>{if(u!==void 0){u(Qe);return}b(otn({spec:{...t,instructions:Qe.instructions||void 0},messages:Qe.messages}))};return h.jsxs(h.Fragment,{children:[e==="instructions"?h.jsx(E,{open:!0,instructions:c??t.instructions??"",messages:G6e(t),onSave:qe,onClose:xe}):null,Ae?h.jsx(y,{editor:Ae,spec:t,models:n,loading:a,error:i,query:A,onQueryChange:T,onChange:b,onClose:xe}):null,e==="runtime"?h.jsx(S,{open:!0,spec:t,sandboxAvailable:l,onChange:b,onClose:xe}):null,Me?h.jsx(w,{editor:Me,spec:t,connectors:re,skills:o,skillsDisabled:s,query:A,activeConnectorId:ue,tools:L,toolsByConnector:U,connectorLoading:P||d!==void 0&&(N==null?void 0:N.id)!==ue&&D===null,connectorError:D,toolsLoading:V,toolsError:F,onQueryChange:T,onSelectConnector:R,onRetryTools:()=>W(Qe=>Qe+1),...d!==void 0?{onRefreshConnector:()=>W(Qe=>Qe+1)}:g!==void 0?{onRefreshConnector:()=>{g().then(()=>{W(Qe=>Qe+1)})}}:{},onChange:b,onClose:xe}):null]})}function I3({open:e,onOpenChange:t,children:n,className:r,id:o,"aria-label":a}){const i=_.useRef(null),s=pp(),l=$J(i,s);_.useEffect(()=>{const u=i.current;u&&(e&&!u.open?u.showModal():!e&&u.open&&u.close())},[e]),_.useEffect(()=>{const u=i.current;if(!u)return;const d=()=>t(!1);return u.addEventListener("close",d),()=>u.removeEventListener("close",d)},[t]);const c=u=>{u.target===i.current&&t(!1)};return h.jsxs("dialog",{ref:i,id:o,"aria-label":a,onClick:c,onCancel:u=>{u.preventDefault(),u.stopPropagation(),t(!1)},style:l??{height:"min(70dvh, 30rem)",maxHeight:"85dvh"},className:pe("aui-bottom-sheet bg-card-bg text-text-primary m-0 mt-auto w-full max-w-none overflow-hidden rounded-t-xl border border-b-0 border-border p-0 pb-[env(safe-area-inset-bottom)] shadow-xl","backdrop:bg-[var(--overlay)] backdrop:backdrop-blur-[2px]","open:flex open:flex-col",r),children:[h.jsx("div",{className:"flex h-5 shrink-0 items-center justify-center","aria-hidden":!0,children:h.jsx("span",{className:"h-1 w-10 rounded-full bg-text-secondary/30"})}),n]})}function Mxe({trigger:e,children:t,open:n,onOpenChange:r,sheetLabel:o,sheetClassName:a,containerClassName:i,closeOnClick:s=!0,...l}){const c=pp(),u=_.useId(),[d,f]=_.useState(!1),g=n??d,b=_.useCallback(y=>{n===void 0&&f(y),r==null||r(y)},[n,r]);if(!c)return h.jsx(Ep,{...l,trigger:e,open:n,onOpenChange:r,containerClassName:i,closeOnClick:s,children:t});const v=_.cloneElement(e,{"aria-haspopup":"dialog","aria-expanded":g,"aria-controls":g?u:void 0,onClick:y=>{var w,S;(S=(w=e.props).onClick)==null||S.call(w,y),y.defaultPrevented||b(!g)}});return h.jsxs("div",{className:pe("relative inline-flex",i),children:[v,g?h.jsx(I3,{id:u,open:!0,onOpenChange:b,"aria-label":o,className:a,children:h.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",onClick:s?y=>{o6e(y)||b(!1)}:void 0,children:t})}):null]})}function Z6e(e){const t=/^(.*\/)?([^/?#]+?)(\.[^./?#]+)([?#].*)?$/.exec(e);if(t==null)return;const n=t[1]??"",r=t[2],o=t[3],a=t[4]??"";if(!(r==null||o==null))return{dir:n,base:r,ext:o,suffix:a}}function htn(e){const t=Z6e(e);if(!(t==null||/-dark$/i.test(t.base)))return`${t.dir}${t.base}-dark${t.ext}${t.suffix}`}function gtn(e){const t=Z6e(e);if(!(t==null||!/-dark$/i.test(t.base)))return`${t.dir}${t.base.replace(/-dark$/i,"")}${t.ext}${t.suffix}`}function mtn({src:e,mode:t}){return t==="dark"?htn(e)??e:gtn(e)??e}function WJ({src:e,alt:t="",onError:n,...r}){const o=O3(),a=mtn({src:e,mode:o}),[i,s]=_.useState(!1);_.useEffect(()=>{s(!1)},[e,o,a]);const l=a!==e,c=i&&l?e:a;return _.createElement("img",{...r,key:c,src:c,alt:t,onError:u=>{if(l&&!i){s(!0);return}n==null||n(u)}})}function __({loading:e,emptyLabel:t,settingsTarget:n,onOpenSettings:r}){return!e&&r?h.jsxs("button",{type:"button",className:rn({variant:"ghost",className:"text-text-secondary w-full justify-center gap-1 py-4 text-xs"}),onClick:r,children:["Please configure ",n," in the ",h.jsx("span",{className:"underline",children:"settings"}),h.jsx(be,{name:"chevron-right",className:"size-3"})]}):h.jsx("p",{className:"text-text-secondary px-2 py-4 text-center text-sm",children:e?"Loading…":t})}function KS(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function X6e({providerName:e,needle:t}){return KS(e).includes(t)}function oB({model:e,needle:t}){return KS(e.name).includes(t)||KS(e.id).includes(t)||X6e({providerName:e.provider.name,needle:t})}function btn(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}function nN(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function d$(e){return Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function q6e({warning:e,side:t="right"}){return h.jsx(sr,{content:e,side:t,className:"max-w-xs whitespace-normal",children:h.jsx("span",{className:"inline-flex shrink-0",children:h.jsx(be,{name:"triangle-exclamation",className:"text-warning-bg size-3.5","aria-label":e})})})}function N3({logo:e,label:t,className:n}){return e?h.jsx(WJ,{src:e,alt:"",className:pe("shrink-0 rounded object-contain",n),"aria-hidden":!0}):h.jsx("span",{className:pe("bg-secondary-bg text-text-secondary flex shrink-0 items-center justify-center rounded font-semibold",n),"aria-hidden":!0,children:btn(t)})}function vtn(e){const t=[],n=new Map;for(const r of e){const o=r.provider.name.trim()||"Other",a=n.get(o);if(a)a.models.push(r),!a.logo&&r.provider.logo&&(a.logo=r.provider.logo);else{const i={name:o,logo:r.provider.logo,models:[r]};n.set(o,i),t.push(i)}}return t}function aB({models:e,loading:t,selectedName:n,query:r,onQueryChange:o,onSelect:a,onOpenSettings:i,listboxId:s,showHeading:l=!0,showSearch:c=!0}){const u=KS(r),d=_.useMemo(()=>u?e.filter(b=>oB({model:b,needle:u})):e,[e,u]),f=vtn(d),g="grid-cols-[minmax(0,1fr)_5rem_1rem]";return h.jsxs(h.Fragment,{children:[c&&h.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l?h.jsx("p",{className:"text-text-primary mb-2 text-sm font-normal",children:"Select model"}):null,h.jsxs("label",{className:"relative block",children:[h.jsx(be,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),h.jsx("input",{type:"search",value:r,onChange:b=>o(b.target.value),placeholder:"Search",className:ga("h-8 py-1 pr-2 pl-7"),autoFocus:!0})]})]}),h.jsxs("div",{className:"flex min-h-0 flex-auto flex-col overflow-y-auto",children:[l?null:h.jsxs("div",{className:pe("bg-card-bg text-text-secondary sticky top-0 z-10 grid shrink-0 gap-2 border-b border-border px-3 py-2 text-[10px] font-semibold uppercase",g),children:[h.jsx("span",{children:"Model"}),h.jsx("span",{children:"Context"}),h.jsx("span",{"aria-hidden":!0})]}),h.jsx("div",{id:s,role:"listbox","aria-label":"Select model",className:"flex flex-col p-1",children:d.length===0?h.jsx(__,{loading:t,emptyLabel:"No models",settingsTarget:"Models",onOpenSettings:i}):f.map((b,v)=>{const y=`${s}-provider-${v}`;return h.jsxs("div",{role:"group","aria-labelledby":y,className:pe(v>0&&"mt-2"),children:[h.jsxs("div",{id:y,className:"text-text-secondary flex items-center gap-1.5 px-2 py-1.5 text-[11px] font-medium tracking-wide uppercase",children:[h.jsx(N3,{logo:b.logo,label:b.name,className:"size-3.5 text-[9px]"}),h.jsx("span",{className:"truncate",children:b.name})]}),b.models.map(w=>{var A;const S=n?w.name===n:d[0]===w,E=(A=w.warning)==null?void 0:A.trim();return h.jsxs("button",{type:"button",role:"option","aria-selected":S,className:pe("w-full items-center rounded-md px-2 py-2 text-left text-sm",l?"flex":pe("grid gap-2",g),S?"bg-primary-button-bg/10 text-primary-button-bg":"hover:bg-ghost-button-hover"),onClick:()=>a(w),children:[h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:"block truncate font-normal",children:nN(w.name)}),l&&(w.properties.contextLength!==void 0||w.properties.maxOutputTokens!==void 0)?h.jsx("span",{className:"text-text-secondary mt-0.5 block truncate text-[10px]",children:[w.properties.contextLength===void 0?null:`${d$(w.properties.contextLength)} context`,w.properties.maxOutputTokens===void 0?null:`${d$(w.properties.maxOutputTokens)} output`].filter(T=>T!==null).join(" · ")}):null]}),l?null:h.jsx("span",{className:pe("text-text-secondary text-xs",S&&"text-primary-button-bg"),children:w.properties.contextLength===void 0?"—":d$(w.properties.contextLength)}),S&&l?h.jsx(be,{name:"check",className:"ml-auto size-3.5"}):null,E?h.jsx("span",{className:pe("flex items-center justify-end",l&&!S&&"ml-auto"),children:h.jsx(q6e,{warning:E})}):l?null:h.jsx("span",{"aria-hidden":!0})]},w.id||w.name)})]},b.name)})})]})]})}function ytn(e){if(!e)return[];const t=[];return e.maxTokens!==void 0&&t.push({label:"max tokens",value:String(e.maxTokens)}),e.reasoningEffort!==void 0&&t.push({label:"reasoning effort",value:e.reasoningEffort}),t}function af(e,t){return e??t?"on":"off"}function xtn(e){return e==="off"?"text-failure-bg font-medium":"text-primary-button-bg font-medium"}function wtn(e,{webSearchAvailable:t=!1,memoryOffered:n=!1}={}){var r,o,a,i,s,l,c,u,d,f;return[{label:"iteration limit",value:String((e==null?void 0:e.iterationLimit)??512)},{label:"sandbox",value:af((r=e==null?void 0:e.sandbox)==null?void 0:r.enabled,!1)},{label:"compaction",value:af((a=(o=e==null?void 0:e.contextManagement)==null?void 0:o.compaction)==null?void 0:a.enabled,!0)},{label:"large tool response",value:af((s=(i=e==null?void 0:e.contextManagement)==null?void 0:i.largeToolResponse)==null?void 0:s.enabled,!0)},{label:"dynamic sub-agents",value:af((l=e==null?void 0:e.dynamicSubAgents)==null?void 0:l.enabled,!0)},{label:"generative UI",value:af((c=e==null?void 0:e.generativeUi)==null?void 0:c.enabled,!0)},{label:"ask user questions",value:af((u=e==null?void 0:e.askUserQuestions)==null?void 0:u.enabled,!0)},{label:"web search",value:af((d=e==null?void 0:e.webSearch)==null?void 0:d.enabled,t)},...n?[{label:"memory",value:af((f=e==null?void 0:e.memory)==null?void 0:f.enabled,!1)}]:[]]}function o2(e){return typeof e=="string"&&e.length>0?e:void 0}function KJ(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0}function rN(e){return o2(Reflect.get(e,"skillRepoName"))}function YJ(e){return KJ(Reflect.get(e,"version"))}function Aa(e){return e.replace(/:\d+$/,"")}function _tn(e){const t=/:(\d+)$/.exec(e);return t===null?void 0:KJ(Number(t[1]))}async function Stn(e){const t=Reflect.get(e,"loadVersions");if(typeof t!="function")return[];const n=await Reflect.apply(t,e,[]);return Array.isArray(n)?n.flatMap(r=>{if(typeof r!="object"||r===null)return[];const o=o2(Reflect.get(r,"name")),a=o2(Reflect.get(r,"displayName")),i=o2(Reflect.get(r,"description")),s=KJ(Reflect.get(r,"version"));return o===void 0||a===void 0||s===void 0?[]:[{id:o,name:a,...i===void 0?{}:{description:i},version:s}]}):[]}function ktn({skill:e,selectedId:t,onChange:n}){const r=YJ(e),[o,a]=_.useState(null),[i,s]=_.useState(!1),[l,c]=_.useState(null),u=o!==null&&o.length>0?Math.max(...o.map(g=>g.version)):r,d=t===void 0?r:_tn(t);if(r===void 0)return null;const f=()=>{o!==null||i||(s(!0),c(null),Stn(e).then(a).catch(g=>c(Oa(g,"Failed to load versions."))).finally(()=>s(!1)))};return h.jsxs(Ep,{align:"end",onOpenChange:g=>{g&&f()},className:"max-h-64 min-w-40 overflow-y-auto",lockScroll:!0,trigger:h.jsxs("button",{type:"button","aria-label":`Select version for ${e.name}`,className:"text-text-secondary hover:bg-ghost-button-hover flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs",children:[h.jsxs("span",{children:["v",d??u]}),d===u?h.jsx("span",{className:"text-primary-button-bg",children:"latest"}):null,h.jsx(be,{name:"chevron-down",className:"size-3"})]}),children:[i?h.jsx("p",{className:"text-text-secondary px-2 py-1.5 text-xs",children:"Loading…"}):null,l?h.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1.5 text-xs",children:[h.jsx("p",{className:"text-failure-bg",children:"Failed to load versions."}),h.jsx("button",{type:"button",className:"text-text-secondary hover:text-text-primary shrink-0 underline",onClick:()=>{navigator.clipboard.writeText(l).catch(()=>{})},children:"Copy error"})]}):null,o==null?void 0:o.map(g=>h.jsxs(pu,{"aria-selected":g.id===t||t===void 0&&g.version===r,className:pe("justify-between",g.id===t&&"font-medium"),onClick:()=>n(g),children:[h.jsxs("span",{children:["v",g.version]}),g.version===u?h.jsx("span",{className:"text-primary-button-bg text-xs",children:"latest"}):null]},g.id)),!i&&l===null&&(o==null?void 0:o.length)===0?h.jsx("p",{className:"text-text-secondary px-2 py-1.5 text-xs",children:"No versions found."}):null]})}var Etn="Enter detailed instructions for your agent. E.g. You are a helpful assistant that helps users plan trips. Always ask clarifying questions before making suggestions...";function Ttn(e){return Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function Atn({item:e,onRemove:t,onTogglePreload:n}){const r=hy(e.value),o=tN(e.value),a=r==="all"?"All tools":`${r.length} tools`;return h.jsxs("span",{className:"flex items-center overflow-hidden rounded-md border border-border text-xs",children:[n?h.jsx(sr,{side:"bottom",dismissOnClick:!1,triggerClassName:"self-stretch",className:"w-64 whitespace-normal p-3 text-left shadow-lg",content:h.jsxs("span",{className:"flex flex-col gap-1.5",children:[h.jsxs("span",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"font-semibold",children:"Preload tools"}),h.jsx("span",{className:"text-primary-button-bg text-[0.625rem] font-semibold tracking-wide uppercase",children:o?"ON":"OFF"})]}),h.jsx("span",{className:"text-text-secondary text-xs leading-snug",children:"Load MCP tool definitions in the agent context upfront. When off, the agent discovers tools dynamically (uses less context upfront)."})]}),children:h.jsx("button",{type:"button","aria-pressed":o,"aria-label":`Preload tools for ${e.name}`,className:pe("flex h-full items-center justify-center border-r border-border px-1.5 transition-colors",o?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover"),onClick:i=>{i.stopPropagation(),n()},children:h.jsx(be,{name:"book-open",className:"size-3.5"})})}):null,h.jsx("span",{className:"py-1 pl-2",children:e.name}),h.jsx("span",{className:"text-text-secondary ml-1 py-1",children:a}),t?h.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,className:rn({variant:"ghost",size:"icon",className:"mx-1 size-5"}),onClick:i=>{i.stopPropagation(),t()},children:h.jsx(be,{name:"xmark",className:"size-3"})}):h.jsx("span",{className:"pr-2"})]})}function Ctn({item:e,preloadAvailable:t,onRemove:n,onTogglePreload:r}){const o=tN(e.value);return h.jsxs("span",{className:"flex items-center overflow-hidden rounded-md border border-border text-xs",children:[t&&r?h.jsx(sr,{side:"bottom",dismissOnClick:!1,triggerClassName:"self-stretch",className:"w-64 whitespace-normal p-3 text-left shadow-lg",content:h.jsxs("span",{className:"flex flex-col gap-1.5",children:[h.jsxs("span",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"font-semibold",children:"Preload skill"}),h.jsx("span",{className:"text-primary-button-bg text-[0.625rem] font-semibold tracking-wide uppercase",children:o?"ON":"OFF"})]}),h.jsx("span",{className:"text-text-secondary text-xs leading-snug",children:"Inline SKILL.md in the agent context upfront. When off, the agent loads the skill dynamically."})]}),children:h.jsx("button",{type:"button","aria-pressed":o,"aria-label":`Preload skill ${e.name}`,className:pe("flex h-full items-center justify-center border-r border-border px-1.5 transition-colors",o?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover"),onClick:a=>{a.stopPropagation(),r()},children:h.jsx(be,{name:"book-open",className:"size-3.5"})})}):null,h.jsx("span",{className:"py-1 pl-2",children:e.name}),n?h.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,className:rn({variant:"ghost",size:"icon",className:"mx-1 size-5"}),onClick:a=>{a.stopPropagation(),n()},children:h.jsx(be,{name:"xmark",className:"size-3"})}):h.jsx("span",{className:"pr-2"})]})}function Rtn({title:e,description:t,icon:n,actionIcon:r="pencil",actionLabel:o,onEdit:a,children:i}){const s=o??`Edit ${e}`;return h.jsxs("section",{className:pe("group border-b border-border px-4 py-4",a?"cursor-pointer":null),role:a?"button":void 0,tabIndex:a?0:void 0,onClick:a,onKeyDown:a?l=>{l.target===l.currentTarget&&(l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),a()))}:void 0,children:[e&&h.jsxs("div",{className:pe("flex items-start justify-between gap-3",i?"mb-3":null),children:[h.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n?h.jsx(be,{name:n,className:"text-text-secondary mt-0.5 size-4 shrink-0"}):null,h.jsxs("div",{className:"min-w-0",children:[h.jsx("h3",{className:"text-text-primary text-sm font-semibold",children:e}),t?h.jsx("p",{className:"text-text-secondary mt-0.5 text-xs",children:t}):null]})]}),a?h.jsx("button",{type:"button","aria-label":s,title:s,className:rn({variant:"ghost",size:"icon",className:"size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100"}),onClick:l=>{l.stopPropagation(),a()},children:h.jsx(be,{name:r,className:"size-3.5"})}):null]}),i]})}function Itn({spec:e,model:t,models:n,modelsLoading:r,modelsError:o,skills:a=[],skillsAvailable:i,webSearchAvailable:s=!1,memoryOffered:l=!1,instructions:c,onOpenEditor:u,onChange:d,onClose:f,disabled:g=!1}){const b=Ge("AgentConfigSection"),v=Ge("AgentModelEditorContent"),y=Ge("AgentModelSettingsContent"),[w,S]=_.useState(!1),[E,A]=_.useState(!1),[T,C]=_.useState(""),R=b0(e.mcpServers),N=b0(e.skills),O=ytn(e.model.params),P=wtn(e.config,{webSearchAvailable:s,memoryOffered:l}),j=c.trim(),D=G6e(e).length,z=[(t==null?void 0:t.properties.contextLength)===void 0?null:Ttn(t.properties.contextLength)].filter($=>$!==null),L=[(t==null?void 0:t.properties.contextLength)===void 0?null:`Context: ${t.properties.contextLength.toLocaleString()} tokens`,(t==null?void 0:t.properties.maxOutputTokens)===void 0?null:`Maximum output: ${t.properties.maxOutputTokens.toLocaleString()} tokens`].filter($=>$!==null).join(`
1092
1092
  `);return h.jsxs("div",{className:"bg-card-bg text-text-primary flex h-full min-h-0 flex-col",children:[h.jsxs("header",{className:"flex min-h-14 shrink-0 items-center gap-1 border-b border-border bg-topbar-bg px-3 py-1.5",children:[h.jsx(be,{name:"sliders",className:"size-4"}),h.jsx("h2",{className:"text-sm font-semibold",children:"Agent Config"}),h.jsx("span",{className:"min-w-0 flex-1"}),f?h.jsx("button",{type:"button","aria-label":"Close agent config",className:rn({variant:"ghost",size:"icon",className:"size-8"}),onClick:f,children:h.jsx(be,{name:"xmark"})}):null]}),h.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[h.jsxs(b,{children:[h.jsxs("div",{className:"flex w-full items-center gap-1",children:[h.jsx(Mxe,{open:w,onOpenChange:$=>{S($),$||C("")},closeOnClick:!1,align:"start",sheetLabel:"Select model",containerClassName:"flex min-w-0 flex-1",className:"w-[min(44rem,calc(100vw-2rem))] overflow-hidden p-0",trigger:h.jsxs("button",{type:"button","aria-label":"Edit Model",title:"Edit Model",disabled:g,className:"flex w-full cursor-pointer items-center gap-2 rounded-md py-1 text-left transition-colors",children:[h.jsx(N3,{logo:t==null?void 0:t.provider.logo,label:(t==null?void 0:t.provider.name)??e.model.name,className:"size-4 text-[0.5rem]"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:nN(e.model.name)}),z.length?h.jsx("span",{title:L,className:"text-text-secondary shrink-0 whitespace-nowrap text-[0.6875rem]",children:z.join(" · ")}):null,h.jsx(be,{name:"chevrons-up-down",className:"text-text-secondary size-3.5 shrink-0"})]}),children:h.jsx(v,{spec:e,models:n,loading:r,error:o,query:T,onQueryChange:C,onChange:$=>{d==null||d($),S(!1),C("")}})}),h.jsx(Mxe,{open:E,onOpenChange:A,closeOnClick:!1,align:"start",sheetLabel:"Model settings",className:"w-[min(36rem,calc(100vw-2rem))] overflow-hidden p-0",trigger:h.jsx("button",{type:"button","aria-label":"Model settings",title:"Model settings",disabled:g,className:rn({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),children:h.jsx(be,{name:"sliders",className:"size-3.5"})}),children:h.jsx(y,{spec:e,model:t,onChange:$=>d==null?void 0:d($)})})]}),h.jsx("button",{type:"button",disabled:g,"aria-label":"Edit model settings",onMouseDown:$=>$.stopPropagation(),onClick:()=>A($=>!$),className:"mt-2 flex w-full cursor-pointer flex-col text-left disabled:cursor-not-allowed disabled:opacity-50",children:h.jsx("dl",{className:"text-text-secondary flex min-w-0 flex-wrap gap-x-3 gap-y-1 text-xs",children:O.length?O.map($=>h.jsxs("div",{className:"flex gap-1",children:[h.jsxs("dt",{children:[$.label,":"]}),h.jsx("dd",{className:"text-text-primary font-medium",children:$.value})]},$.label)):h.jsx("div",{children:"model settings: defaults"})})})]}),h.jsx(b,{title:"Instructions",description:"Define the agent's role, goals, and behavior.",children:h.jsxs("button",{type:"button","aria-label":"Edit Instructions",disabled:g,className:"border-border hover:bg-ghost-button-hover flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors",onClick:()=>u("instructions"),children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:pe("line-clamp-3 whitespace-pre-wrap text-sm",j?"text-text-primary":"text-text-secondary"),children:j||Etn}),D>0?h.jsxs("p",{className:"text-text-secondary mt-2 text-xs",children:[D," user ",D===1?"message":"messages"]}):null]}),h.jsx(be,{name:"chevron-right",className:"text-text-secondary size-4 shrink-0"})]})}),h.jsx(b,{title:"Runtime Config",description:"Control execution and context behavior.",actionIcon:"sliders",onEdit:g?void 0:()=>u("runtime"),children:h.jsx("dl",{className:"text-text-secondary flex flex-wrap gap-x-3 gap-y-1 text-xs leading-relaxed",children:P.map($=>h.jsxs("div",{className:"flex gap-1",children:[h.jsxs("dt",{children:[$.label,":"]}),h.jsx("dd",{className:xtn($.value),children:$.value})]},$.label))})}),h.jsx(b,{title:"MCP Servers",icon:"mcp-server",actionIcon:"plus",actionLabel:"Add MCP server",onEdit:g?void 0:()=>u("mcp"),children:R.length?h.jsx("div",{className:"flex flex-wrap gap-1.5",children:R.map($=>h.jsx(Atn,{item:$,onRemove:d&&!g?()=>d({...e,mcpServers:R.filter(U=>U.id!==$.id).map(U=>U.value)}):void 0,onTogglePreload:d&&!g?()=>d({...e,mcpServers:R.map(U=>U.id===$.id?Nxe(U.value,!tN(U.value)):U.value)}):void 0},$.id))}):null}),h.jsx(b,{title:"Skills",icon:"lightbulb",actionIcon:"plus",actionLabel:"Add skill",onEdit:g?void 0:()=>u("skills"),children:i?N.length?h.jsx("div",{className:"flex flex-wrap gap-1.5",children:N.map($=>{const U=a.some(B=>YJ(B)!==void 0&&Aa(B.id)===Aa($.id));return h.jsx(Ctn,{item:$,preloadAvailable:U,onRemove:d&&!g?()=>d({...e,skills:N.filter(B=>B.id!==$.id).map(B=>B.value)}):void 0,onTogglePreload:U&&d&&!g?()=>d({...e,skills:N.map(B=>B.id===$.id?Nxe(B.value,!tN(B.value)):B.value)}):void 0},$.id)})}):h.jsx("p",{className:"text-text-secondary text-xs",children:"No skills selected."}):h.jsx("p",{className:"text-text-secondary text-xs",children:"Skills require an available sandbox."})})]})]})}function Ntn(e){return typeof e=="string"?"string":typeof e=="number"?"number":"json"}function Mtn(e,t){return t==="string"?typeof e=="string"?e:"":t==="number"?typeof e=="number"?String(e):"":JSON.stringify(e,null,2)??"null"}function iB(e){return{id:e,key:"",type:"string",value:""}}function Otn(e){return Object.entries(e).map(([t,n],r)=>{const o=Ntn(n);return{id:`existing-${r}-${t}`,key:t,type:o,value:Mtn(n,o)}})}function Ptn(e){const t=Otn(e);return t.length>0?t:[iB("new-0")]}function Q6e(e){if(e.type==="string")return{valid:!0,value:e.value};if(e.type==="number"){const t=Number(e.value);return e.value.trim()===""||!Number.isFinite(t)?{valid:!1,error:"Enter a valid number."}:{valid:!0,value:t}}try{return{valid:!0,value:JSON.parse(e.value)}}catch{return{valid:!1,error:"Enter valid JSON."}}}function Oxe({draft:e,drafts:t,reservedKeys:n}){const r=e.key.trim();if(r==="")return"Enter a parameter name.";if(n.has(r))return"This parameter already has a dedicated control.";if(t.some(a=>a.id!==e.id&&a.key.trim()===r))return"Parameter names must be unique.";const o=Q6e(e);return o.valid?null:o.error}function Pxe(e){return e==="string"?"Aa":e==="number"?"#":"{ }"}function jtn({value:e,reservedKeys:t,onChange:n}){const r=Ge("CodeEditor"),[o,a]=_.useState(()=>Ptn(e)),i=_.useRef(o.length),s=u=>{if(u.some(f=>Oxe({draft:f,drafts:u,reservedKeys:t})!==null))return;const d=[];u.forEach(f=>{const g=Q6e(f);g.valid&&d.push([f.key.trim(),g.value])}),n(Object.fromEntries(d))},l=({id:u,patch:d})=>{const f=o.map(g=>g.id===u?{...g,...d}:g);a(f),s(f)},c=u=>{const d=o.filter(g=>g.id!==u),f=`new-${i.current}`;i.current+=1,a(d.length>0?d:[iB(f)]),s(d)};return h.jsx("div",{className:"space-y-2",children:o.map(u=>{var g;const d=Oxe({draft:u,drafts:o,reservedKeys:t}),f=u.key.trim()===""?null:d;return h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center",children:[h.jsxs("div",{className:pe("bg-secondary-button-bg flex min-w-0 flex-1 items-stretch overflow-hidden rounded-md border border-input-border",u.type==="json"&&"rounded-b-none",f&&"border-failure-bg"),children:[h.jsx("input",{value:u.key,"aria-label":"Custom parameter name",placeholder:"Key",className:"text-text-primary placeholder:text-text-secondary h-8 min-w-0 flex-1 border-0 border-r border-input-border bg-transparent px-3 text-sm outline-none",onChange:b=>l({id:u.id,patch:{key:b.target.value}})}),u.type!=="json"?h.jsx("input",{type:u.type==="number"?"number":"text",value:u.value,"aria-label":`Value for ${u.key||"custom parameter"}`,placeholder:"Value",className:"text-text-primary placeholder:text-text-secondary h-8 min-w-0 flex-1 border-0 bg-transparent px-3 text-sm outline-none",onChange:b=>l({id:u.id,patch:{value:b.target.value}})}):null,h.jsx(Ep,{align:"end",className:"w-32",trigger:h.jsxs("button",{type:"button","aria-label":`Type for ${u.key||"custom parameter"}`,title:u.type==="string"?"String":u.type==="number"?"Number":"JSON",className:"text-text-secondary hover:bg-ghost-button-hover flex h-8 w-12 shrink-0 items-center justify-center gap-1 border-l border-input-border text-xs font-semibold",children:[h.jsx("span",{children:Pxe(u.type)}),h.jsx(be,{name:"chevron-down",className:"size-3"})]}),children:["string","number","json"].map(b=>h.jsxs(pu,{"aria-selected":u.type===b,onClick:()=>l({id:u.id,patch:{type:b,value:b==="number"?"0":b==="json"?"{}":""}}),children:[h.jsx("span",{"aria-hidden":!0,className:"w-5 text-center font-semibold",children:Pxe(b)}),b==="string"?"String":b==="number"?"Number":"JSON"]},b))})]}),h.jsxs("div",{className:"ml-3 flex items-center gap-3",children:[h.jsx("button",{type:"button","aria-label":`Remove ${u.key||"custom parameter"}`,className:"text-failure-bg border-failure-bg flex size-5 items-center justify-center rounded-full border text-sm leading-none",onClick:()=>c(u.id),children:h.jsx("span",{"aria-hidden":!0,children:"−"})}),h.jsx("button",{type:"button","aria-label":"Add parameter",className:pe("text-text-secondary flex size-5 items-center justify-center rounded-full border border-current",u.id!==((g=o.at(-1))==null?void 0:g.id)&&"invisible"),onClick:()=>{const b=`new-${i.current}`;i.current+=1;const v=o.findIndex(w=>w.id===u.id),y=[...o];y.splice(v+1,0,iB(b)),a(y)},children:h.jsx(be,{name:"plus",className:"size-3"})})]})]}),u.type==="json"?h.jsx(r,{value:u.value,language:"json",height:"8rem",showToolbar:!1,className:pe("mr-16 h-32 rounded-t-none border-t-0",f&&"border-failure-bg"),onChange:b=>{b!==void 0&&l({id:u.id,patch:{value:b}})}}):null,f?h.jsx("p",{className:"text-failure-bg mt-1 text-xs",children:f}):null]},u.id)})})}function Dtn(e){return e.filter(t=>t.content.trim().length>0).map(t=>({type:"user.message",content:t.content}))}function Ltn({open:e,instructions:t,messages:n=[],onSave:r,onClose:o}){const a=Ge("InstructionsFullScreenEditor"),i=Ge("InstructionsMarkdownEditor"),s=_.useId(),l=_.useRef(n.length),[c,u]=_.useState(t),[d,f]=_.useState(!1),[g,b]=_.useState(()=>n.map((A,T)=>({id:T,content:A.content}))),v=A=>{b(A)},y=()=>{const A=[...g,{id:l.current,content:""}];l.current+=1,b(A)},w=({id:A,content:T})=>{v(g.map(C=>C.id===A?{id:A,content:T}:C))},S=A=>{v(g.filter(T=>T.id!==A))},E=()=>{r({instructions:c,messages:Dtn(g)}),o()};return h.jsxs(E3,{open:e,onOpenChange:A=>!A&&o(),title:"Instructions",description:"System prompt that defines the agent's role, goals, and how it should behave. Written once, applied to every run.",anchor:"right",size:"lg","aria-label":"Edit Instructions",footer:h.jsx("div",{className:"flex justify-end",children:h.jsx(Tn.Primary,{type:"button",onClick:E,children:"Save"})}),children:[h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-6 p-5",children:[h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{children:[h.jsx("span",{id:`${s}-instructions`,className:"text-text-primary text-sm font-semibold",children:"Agent instructions"}),h.jsx("p",{className:"text-text-secondary mt-1 text-xs",children:"Describe the agent's role, goals, and constraints."})]}),h.jsx("button",{type:"button","aria-label":"Edit instructions full screen",title:"Full screen",className:rn({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),onClick:()=>f(!0),children:h.jsx(be,{name:"expand",className:"size-4"})})]}),h.jsx("div",{className:"border-border mt-3 overflow-hidden rounded-md border","aria-labelledby":`${s}-instructions`,children:d?h.jsx("div",{className:"h-72"}):h.jsx(i,{value:c,onChange:u,height:"18rem"})})]}),h.jsxs("section",{className:"border-border border-t pt-5",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-text-primary text-sm font-semibold",children:"User Messages"}),h.jsx("p",{className:"text-text-secondary mt-1 text-xs",children:"Add initial messages to every new agent session."})]}),h.jsxs(Tn.Secondary,{type:"button",size:"small",onClick:y,children:[h.jsx(be,{name:"plus",className:"size-3.5"}),"Add User Message"]})]}),g.length>0?h.jsx("div",{className:"mt-4 flex flex-col gap-4",children:g.map((A,T)=>{const C=`${s}-user-message-${A.id}`;return h.jsxs("div",{className:"border-border rounded-lg border p-3",children:[h.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[h.jsx(be,{name:"user",className:"text-text-secondary size-4"}),h.jsxs("label",{htmlFor:C,className:"text-text-primary flex-1 text-sm font-medium",children:["User Message ",T+1]}),h.jsx("button",{type:"button","aria-label":`Remove User Message ${T+1}`,className:rn({variant:"ghost",size:"icon",className:"size-7"}),onClick:()=>S(A.id),children:h.jsx(be,{name:"trash",className:"size-3.5"})})]}),h.jsx("textarea",{id:C,value:A.content,rows:4,placeholder:"Type message content…",className:ga("min-h-24 resize-y py-2"),onChange:R=>w({id:A.id,content:R.target.value})})]},A.id)})}):h.jsx("p",{className:"text-text-secondary mt-4 text-sm",children:"No initial user messages."})]})]}),h.jsx(a,{open:d,value:c,onChange:u,onClose:()=>f(!1)})]})}var J6e="truefoundry-mcp-auth-popup",ztn=()=>`mcp-oauth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,$tn=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.popupUid=="string"&&typeof t.isSuccess=="boolean"},eze=({callbackPath:e}={})=>{const{connectorCatalog:t}=hXe(),n=Za(),r=eE(),[o,a]=_.useState(0),i=_.useRef(new Set),s=_.useRef(new Set);_.useEffect(()=>{const f=i.current,g=s.current;return()=>{f.clear();for(const b of g)b();g.clear()}},[]);const l=_.useCallback(async f=>(n==null?void 0:n.getMcpConnector)!==void 0?n.getMcpConnector({connectorId:f}):t.getConnector({id:f}),[t,n]),c=_.useCallback(async({integrationId:f,callback:g,attempt:b})=>{try{const v=await l(f);if(!i.current.has(b))return;if(!v.authenticated)throw new Error("The MCP server is not authenticated yet. Please try again.");g(!0)}catch(v){if(!i.current.has(b))return;r==null||r.showError(v),g(!1)}},[l,r]),u=_.useCallback(({authorizationEndpoint:f,integrationId:g,callback:b,attempt:v,popupUid:y})=>{const w=new BroadcastChannel(J6e);let S=null;const E=()=>{w.close(),s.current.delete(A)},A=()=>{E(),S==null||S.close()};if(w.onmessage=T=>{if(!$tn(T.data)||T.data.popupUid!==y)return;const{isSuccess:C}=T.data;if(E(),!C){i.current.delete(v)&&b(!1);return}c({integrationId:g,callback:b,attempt:v}).finally(()=>{i.current.delete(v)})},s.current.add(A),S=window.open(f,"_blank","popup=true"),!S)throw A(),new Error("Popup blocked. Please allow pop-ups to authorize the MCP server.");S.focus()},[c]);return{handleAuthorize:_.useCallback(async(f,g)=>{var w;if(!f)return;const b={},v=ztn();i.current.add(b),a(S=>S+1);let y=!1;try{const S=e?new URL(e,window.location.origin):new URL(window.location.href);S.searchParams.set("screenType","mcp-auth"),S.searchParams.set("integrationId",f),S.searchParams.set("pUid",v);const E=await t.authenticateConnector({id:f,returnTo:`${S.pathname}${S.search}`});if(!i.current.has(b))return;if("status"in E&&((w=E.status)==null?void 0:w.toUpperCase())==="AUTHENTICATED"||"authenticated"in E&&E.authenticated){await c({integrationId:f,callback:g,attempt:b});return}const A="authorization_endpoint"in E?E.authorization_endpoint:void 0;if(!A)throw new Error("The MCP server did not return an authorization URL.");u({authorizationEndpoint:A,integrationId:f,callback:g,attempt:b,popupUid:v}),y=!0}catch(S){if(!i.current.has(b))return;r==null||r.showError(S),g(!1)}finally{i.current.has(b)&&a(S=>S-1),y||i.current.delete(b)}},[e,t,u,c,r]),isOAuthLoading:o>0}};function ZJ({checked:e,className:t}){return h.jsx("span",{className:pe("flex size-4 shrink-0 items-center justify-center rounded-sm border transition-colors",e?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-text-secondary/60 bg-input-box-bg",t),"aria-hidden":!0,children:e?h.jsx(be,{name:"check",className:"size-3"}):null})}var Utn={sm:{track:"h-5 w-9 p-0.5",thumb:"size-4",checkedThumb:"translate-x-4"},md:{track:"h-6 w-11 p-0.5",thumb:"size-5",checkedThumb:"translate-x-5"}};function gy({checked:e,onCheckedChange:t,size:n="sm",disabled:r,className:o,...a}){const i=Utn[n];return h.jsx("button",{...a,type:"button",role:"switch","aria-checked":e,"data-state":e?"checked":"unchecked",disabled:r,className:pe("flex shrink-0 cursor-pointer items-center overflow-hidden rounded-full transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40","disabled:cursor-not-allowed disabled:opacity-50",i.track,e?"bg-primary-button-bg":"bg-text-secondary/35 dark:bg-text-secondary/50",o),onClick:()=>t(!e),children:h.jsx("span",{"aria-hidden":!0,className:pe("shrink-0 translate-x-0 rounded-full shadow-sm transition-[transform,background-color]",e?"bg-primary-button-text":"bg-primary-bg",i.thumb,e&&i.checkedThumb)})})}function Ftn({connector:e}){const t=Reflect.get(e,"logo");return typeof t=="string"&&t.trim()!==""?h.jsx(WJ,{src:t,alt:"",className:"size-4 shrink-0 object-contain","aria-hidden":!0}):h.jsx(be,{name:"mcp-server",className:"text-text-secondary size-4 shrink-0"})}function jxe(e){return e.length===0?"0":e.every(n=>hy(n.value)==="all")?"All":`${e.reduce((n,r)=>{const o=hy(r.value);return o==="all"?n:n+o.length},0)}`}function Dxe(){return h.jsxs("span",{className:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[0.625rem] font-medium",children:[h.jsx(be,{name:"shield-check",className:"size-2.5"}),"approval"]})}function Btn({approvalRequired:e,toolName:t,onToggle:n}){return h.jsx(sr,{side:"bottom",dismissOnClick:!1,className:"w-64 whitespace-normal p-3 text-left shadow-lg",content:h.jsxs("span",{className:"flex flex-col gap-1.5",children:[h.jsxs("span",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"font-semibold",children:"Require approval"}),h.jsx("span",{className:"text-primary-button-bg text-[0.625rem] font-semibold tracking-wide uppercase",children:e?"ON":"OFF"})]}),h.jsx("span",{className:"text-text-secondary text-xs leading-snug",children:e?"This tool will ask for your approval before running — click to auto-run":"This tool runs without asking — click to require your approval"})]}),children:h.jsx("button",{type:"button","aria-pressed":e,"aria-label":`Require approval for ${t}`,className:rn({variant:"secondary",size:"small",className:pe("size-6 px-0 [&_svg]:size-3.5",e?"border-warning-bg/50 bg-warning-bg/10 text-warning-bg hover:bg-warning-bg/20":"text-text-secondary")}),onClick:n,children:h.jsx(be,{name:e?"shield-check":"shield"})})})}function Htn({connectorId:e,onConnected:t}){const{handleAuthorize:n,isOAuthLoading:r}=eze();return h.jsx(Tn.Primary,{type:"button",className:"min-w-44",disabled:r,onClick:()=>{n(e,o=>{o&&t()})},children:r?"Connecting...":"Connect Now"})}function Vtn({spec:e,connectors:t,query:n,activeConnectorId:r,tools:o,toolsByConnector:a={},connectorLoading:i,connectorError:s,toolsLoading:l,toolsError:c,onQueryChange:u,onSelectConnector:d,onRetryTools:f,onRefreshConnector:g,onChange:b}){const[v,y]=_.useState(""),[w,S]=_.useState(()=>new Set),[E]=_.useState(()=>{const te=new Set;for(const re of b0(e.mcpServers))te.add(re.id),te.add(re.name);return te}),A=b0(e.mcpServers),T=GJ({connectors:t,selected:A}),C=T.find(te=>te.id===r),R=C?A.find(te=>te.id===C.id||te.name===C.name):void 0,N=(C==null?void 0:C.authenticated)===!1,O=C!==void 0&&C.authenticated===!0,P=R?hy(R.value):[],j=n.trim().toLowerCase(),D=T.filter(te=>`${te.name} ${te.description??""}`.toLowerCase().includes(j)).sort((te,re)=>{const xe=E.has(te.id)||E.has(te.name),Ae=E.has(re.id)||E.has(re.name);return Number(Ae)-Number(xe)}),z=v.trim().toLowerCase(),L=z===""?o:o.filter(te=>te.name.toLowerCase().includes(z)),$=Cxe(L),U=Cxe(o),B=R?iC(R.value):[...m0],V=r2({tools:o,selectors:B}),G={...a,...r!==null&&o.length>0?{[r]:o}:{}},F=te=>{var xe;const re=(xe=T.find(Ae=>Ae.id===te.id||Ae.name===te.name))==null?void 0:xe.id;return G[te.id]??(re===void 0?void 0:G[re])??[]},Z=A.reduce((te,re)=>{const xe=iC(re.value),Ae=F(re),Me=hy(re.value);return Me==="all"?te+r2({tools:Ae,selectors:xe}).size:te+Me.filter(qe=>Ixe({toolName:qe,tools:Ae,selectors:xe})).length},0),J=(te,re)=>{b({...e,mcpServers:A.map(xe=>xe.id===te?re:xe.value)})},W=te=>{b({...e,mcpServers:A.filter(re=>re.id!==te).map(re=>re.value)})},Y=te=>{const re=T.find(xe=>xe.id===te.id||xe.name===te.name);d((re==null?void 0:re.id)??te.id)},q=({next:te,newlyEnabledNames:re,baseValue:xe})=>{let Ae=aC(xe,te);return re.length>0&&o.length>0&&(Ae=u$(Ae,dtn({tools:o,selectors:iC(Ae),newlyEnabledNames:re}))),Ae},ne=({next:te,newlyEnabledNames:re=[]})=>{if(C){if(te.length===0){R&&W(R.id);return}if(R){J(R.id,q({next:te,newlyEnabledNames:re,baseValue:R.value}));return}O&&b({...e,mcpServers:[...e.mcpServers??[],q({next:te,newlyEnabledNames:re,baseValue:{id:C.id,name:C.name}})]})}},he=te=>{if(!C)return;if(!R){if(!O)return;ne({next:[te],newlyEnabledNames:[te]});return}const re=P==="all"?o.map(Me=>Me.name):P,xe=re.includes(te),Ae=xe?re.filter(Me=>Me!==te):[...re,te];ne({next:Ae,newlyEnabledNames:xe?[]:[te]})},se=({sectionId:te,enabled:re})=>{const xe=U[te].map(Me=>Me.name);if(!C||xe.length===0)return;if(re){if(P==="all")return;const Me=R?[...P]:[],qe=[];for(const ze of xe)Me.includes(ze)||(Me.push(ze),qe.push(ze));ne({next:Me,newlyEnabledNames:qe});return}const Ae=P==="all"?o.map(Me=>Me.name):P;ne({next:Ae.filter(Me=>!xe.includes(Me))})},ie=({toolNames:te,required:re})=>{if(!R||te.length===0||o.length===0)return;const xe=new Set(V);for(const Ae of te)re?xe.add(Ae):xe.delete(Ae);J(R.id,u$(R.value,K6e({tools:o,approved:xe})))},ue=()=>{!C||R!==void 0||b({...e,mcpServers:[...e.mcpServers??[],u$(aC({id:C.id,name:C.name},"all"),m0)]})};return h.jsxs("div",{className:"flex h-[min(36rem,calc(100dvh-10rem))] w-full min-w-0 flex-col overflow-hidden md:grid md:grid-cols-[14rem_minmax(0,1fr)_14rem]",children:[h.jsxs("div",{className:"flex max-h-44 min-h-0 min-w-0 flex-col border-b border-border md:max-h-none md:border-r md:border-b-0 bg-sidebar-bg",children:[h.jsxs("label",{className:"relative m-3 block shrink-0",children:[h.jsx(be,{name:"search",className:"text-text-secondary absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),h.jsx("input",{value:n,onChange:te=>u(te.target.value),placeholder:"Search MCP",className:ga("h-8 w-full pl-7")})]}),h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:D.map(te=>{const re=A.some(Ae=>Ae.id===te.id||Ae.name===te.name),xe=te.id===r;return h.jsxs("button",{type:"button","aria-current":xe?"true":void 0,"aria-label":te.name,className:pe("flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-left",xe?"bg-primary-button-bg/10":"hover:bg-ghost-button-hover"),onClick:()=>d(te.id),children:[h.jsx(Ftn,{connector:te}),h.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm font-medium",children:te.name}),re?h.jsx("span",{className:"bg-success-bg text-success-text flex size-3 shrink-0 items-center justify-center rounded-full","aria-label":`${te.name} selected`,children:h.jsx(be,{name:"check",className:"size-2"})}):null]},te.id)})})]}),h.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col border-b border-border md:border-r md:border-b-0",children:C?i?h.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-3","aria-label":"Loading MCP server",children:h.jsx(Al,{size:20,className:"text-text-secondary"})}):s?h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center p-6 text-center",children:[h.jsx("p",{className:"text-failure-bg text-sm",children:s}),h.jsx(Tn.Secondary,{type:"button",size:"small",className:"mt-2",onClick:f,children:"Retry"})]}):N?h.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6 text-center",children:[h.jsx(be,{name:"lock",className:"text-text-secondary size-10"}),h.jsx("p",{className:"text-text-primary text-sm font-semibold",children:"You're not connected to this MCP Server"}),g?h.jsx(Htn,{connectorId:C.id,onConnected:g}):null,h.jsxs("div",{className:"text-text-secondary flex w-full max-w-xs items-center gap-3 text-xs",children:[h.jsx("span",{className:"bg-border h-px flex-1"}),"OR",h.jsx("span",{className:"bg-border h-px flex-1"})]}),h.jsx(Tn.Secondary,{type:"button",className:"min-w-44",disabled:R!==void 0,onClick:ue,children:"Connect During Chat"})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border p-3",children:[h.jsxs("p",{className:"min-w-0 truncate text-sm font-semibold",children:[C.name," Tools (",o.length,")"]}),h.jsxs("label",{className:"text-text-secondary flex shrink-0 cursor-pointer items-center gap-2 text-xs has-[:disabled]:cursor-not-allowed",children:["Enable All Tools",h.jsx(gy,{checked:R!==void 0&&P==="all",disabled:!O&&R===void 0,onCheckedChange:te=>{R?te?J(R.id,aC(R.value,"all")):W(R.id):te&&O&&b({...e,mcpServers:[...e.mcpServers??[],aC({id:C.id,name:C.name},"all")]})},"aria-label":"Enable all tools"})]})]}),h.jsxs("label",{className:"relative m-3 block shrink-0",children:[h.jsx(be,{name:"search",className:"text-text-secondary absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),h.jsx("input",{value:v,onChange:te=>y(te.target.value),placeholder:"Search Tools",className:ga("h-8 w-full pl-7")})]}),h.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[l?h.jsx("div",{className:"flex h-full min-h-24 items-center justify-center p-3","aria-label":"Loading tools",children:h.jsx(Al,{size:20,className:"text-text-secondary"})}):null,c?h.jsxs("div",{className:"p-3",children:[h.jsx("p",{className:"text-failure-bg text-sm",children:c}),h.jsx(Tn.Secondary,{type:"button",size:"small",className:"mt-2",onClick:f,children:"Retry"})]}):null,l?null:itn.map(te=>{const re=$[te];if(re.length===0)return null;const xe=$["read-only"].length===0&&$.destructive.length===0,Ae=te!=="others"||!xe,Me=U[te].map(ct=>ct.name),qe=Me.length>0&&(P==="all"||Me.every(ct=>P.includes(ct))),ze=P==="all"?Me:Me.filter(ct=>P.includes(ct)),Ze=ze.length>0&&ze.every(ct=>V.has(ct)),Qe=te==="others"||te==="destructive"?ctn[te]:void 0;return h.jsxs("div",{className:"mb-3",children:[Ae?h.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-2",children:[h.jsx("p",{className:pe("min-w-0 truncate text-sm font-semibold",te==="destructive"?"text-failure-bg":"text-text-primary"),children:stn[te]}),h.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[Qe===void 0||ze.length===0?null:h.jsxs("label",{className:"text-text-secondary flex shrink-0 cursor-pointer items-center gap-2 text-xs",children:["Approval required",h.jsx(gy,{checked:Ze,onCheckedChange:ct=>ie({toolNames:ze,required:ct}),"aria-label":Qe})]}),h.jsxs("label",{className:"text-text-secondary flex shrink-0 cursor-pointer items-center gap-2 text-xs has-[:disabled]:cursor-not-allowed",children:["Enable all",h.jsx(gy,{checked:qe,disabled:!O&&R===void 0,onCheckedChange:ct=>se({sectionId:te,enabled:ct}),"aria-label":ltn[te]})]})]})]}):null,re.map(ct=>{const De=P==="all"||P.includes(ct.name),Ye=ym({tool:ct,selectors:B});return h.jsxs("div",{className:"hover:bg-ghost-button-hover flex w-full items-center gap-1 rounded-md pr-2",children:[h.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":De,"aria-label":ct.name,disabled:!O&&R===void 0,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-left disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>he(ct.name),children:[h.jsx(ZJ,{checked:De}),h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"text-text-primary block truncate text-sm font-medium",children:ct.name}),ct.description?h.jsx(sr,{content:ct.description,side:"bottom",className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full",interactive:!1,children:h.jsx("span",{className:"text-text-secondary block truncate text-xs",children:ct.description})}):null]})]}),De?h.jsx(Btn,{approvalRequired:Ye,toolName:ct.name,onToggle:()=>ie({toolNames:[ct.name],required:!Ye})}):null]},ct.id)})]},te)})]})]}):h.jsx("p",{className:"text-text-secondary p-4 text-sm",children:"Select an MCP server to configure its tools."})}),h.jsxs("div",{className:"flex max-h-44 min-h-0 min-w-0 flex-col md:max-h-none",children:[h.jsxs("div",{className:"shrink-0 border-b border-border p-3",children:[h.jsxs("p",{className:"text-sm font-semibold",children:["Selected Tools (",jxe(A),")"]}),A.length?h.jsxs("p",{className:"text-text-secondary mt-0.5 text-xs",children:[jxe(A)," selected · ",Z," need approval"]}):null]}),h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:A.length?h.jsx("div",{className:"space-y-1",children:A.map(te=>{const re=hy(te.value),xe=iC(te.value),Ae=F(te);return h.jsxs("details",{className:"group/mount",open:!w.has(te.id),onToggle:Me=>{const qe=Me.currentTarget.open;S(ze=>{const Ze=new Set(ze);return qe?Ze.delete(te.id):Ze.add(te.id),Ze})},children:[h.jsxs("summary",{className:"hover:bg-ghost-button-hover flex cursor-pointer list-none items-center gap-1 rounded-md [&::-webkit-details-marker]:hidden",onClick:()=>Y(te),children:[h.jsx(be,{name:"chevron-down",className:"text-text-secondary size-3.5 shrink-0 -rotate-90 transition-transform group-open/mount:rotate-0"}),h.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-xs font-semibold",children:te.name}),h.jsxs("span",{className:"relative flex size-6 shrink-0 items-center justify-center",children:[h.jsx("span",{className:"text-text-secondary text-xs font-medium group-hover/mount:invisible group-focus-within/mount:invisible",children:re==="all"?"All":re.length}),h.jsx(sr,{content:"Remove All Tools",triggerClassName:"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 group-hover/mount:pointer-events-auto group-hover/mount:opacity-100 group-focus-within/mount:pointer-events-auto group-focus-within/mount:opacity-100",children:h.jsx("button",{type:"button","aria-label":`Remove all tools for ${te.name}`,className:rn({variant:"ghost",size:"icon",className:"text-text-secondary size-6"}),onClick:Me=>{Me.preventDefault(),Me.stopPropagation(),W(te.id)},children:h.jsx(be,{name:"xmark",className:"size-3.5"})})})]})]}),re==="all"?h.jsxs("button",{type:"button",className:"text-text-secondary hover:bg-ghost-button-hover flex w-full cursor-pointer items-center gap-1.5 rounded-md px-2 py-1.5 pl-7 text-left text-[0.6875rem] font-medium tracking-wide uppercase",onClick:()=>Y(te),children:[h.jsx(be,{name:"wrench",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:"ALL TOOLS ENABLED"}),r2({tools:Ae,selectors:xe}).size>0?h.jsx(Dxe,{}):null]}):re.length?re.map(Me=>h.jsxs("button",{type:"button","aria-label":`Open ${te.name} for ${Me}`,className:"text-text-primary hover:bg-ghost-button-hover flex w-full h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 py-1 pl-7 text-left text-[0.6875rem]",onClick:()=>Y(te),children:[h.jsx(be,{name:"wrench",className:"text-text-secondary size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:Me}),Ixe({toolName:Me,tools:Ae,selectors:xe})?h.jsx(Dxe,{}):null]},`${te.id}:${Me}`)):h.jsx("p",{className:"text-text-secondary px-2 py-1.5 pl-7 text-[0.6875rem]",children:"No tools selected."})]},te.id)})}):h.jsx("p",{className:"text-text-secondary p-4 text-center text-sm",children:"No tools selected."})})]})]})}function XJ({open:e,onOpenChange:t,title:n,description:r,titleAccessory:o,headerIcon:a,children:i,footer:s,className:l,contentSized:c=!1,"aria-label":u}){const d=_.useRef(null),f=_.useId(),g=_.useId(),b=pp(),v=$J(d,b,c);return _.useEffect(()=>{const y=d.current;y&&(e&&!y.open?y.showModal():!e&&y.open&&y.close())},[e]),_.useEffect(()=>{const y=d.current;if(!y)return;const w=()=>t(!1);return y.addEventListener("close",w),()=>y.removeEventListener("close",w)},[t]),h.jsxs("dialog",{ref:d,"aria-label":u??n,"aria-labelledby":f,"aria-describedby":r?g:void 0,onCancel:y=>{y.preventDefault(),y.stopPropagation(),t(!1)},style:v??(c?{height:"fit-content",maxHeight:"85dvh"}:void 0),className:pe("bg-card-bg text-text-primary border-border open:flex open:flex-col overflow-hidden p-0 shadow-xl","backdrop:bg-black/50 backdrop:backdrop-blur-[2px] dark:backdrop:bg-black/70",b?"m-0 mt-auto max-w-none rounded-t-xl rounded-b-none border-t pb-[env(safe-area-inset-bottom)]":c?"m-0 mt-auto h-auto max-h-[85dvh] w-full max-w-none rounded-t-xl rounded-b-none border-t pb-[env(safe-area-inset-bottom)] md:m-auto md:h-auto md:w-[min(28rem,calc(100%-3rem))] md:max-w-md md:rounded-xl md:border md:pb-0":pe("m-0 mt-auto h-[min(85dvh,40rem)] w-full max-w-none rounded-t-xl rounded-b-none border-t pb-[env(safe-area-inset-bottom)]","md:m-auto md:h-[min(80dvh,40rem)] md:w-[min(72rem,calc(100%-3rem))] md:max-w-5xl md:rounded-xl md:border md:pb-0"),l),children:[h.jsxs("header",{className:"bg-topbar-bg flex shrink-0 items-center gap-3 border-b border-border px-5 py-4",children:[a,h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[h.jsx("h2",{id:f,className:"text-text-primary truncate text-lg font-semibold tracking-tight",children:n}),o]}),r?h.jsx("p",{id:g,className:"text-text-secondary mt-1 text-sm",children:r}):null]}),h.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:rn({variant:"ghost",size:"icon"}),onClick:()=>t(!1),children:h.jsx(be,{name:"xmark"})})]}),h.jsx("div",{className:"flex min-h-0 flex-auto flex-col overflow-x-hidden overflow-y-auto",children:i}),s?h.jsx("div",{className:"shrink-0 border-t border-border px-5 py-3",children:s}):null]})}function Gtn({editor:e,spec:t,models:n,loading:r,error:o,query:a,onQueryChange:i,onChange:s,onClose:l}){const c=Ge("AgentModelEditorContent"),u=Ge("AgentModelSettingsContent"),d=_.useMemo(()=>n.find(g=>g.name===t.model.name),[n,t.model.name]),f=e==="model";return h.jsx(XJ,{open:e!==null,onOpenChange:g=>!g&&l(),title:f?"Select model":"Model settings",className:f?"md:w-[min(52rem,calc(100%-3rem))] md:max-w-5xl":"md:w-[min(36rem,calc(100%-3rem))] md:max-w-xl",contentSized:!0,"aria-label":f?"Edit model":"Edit model settings",children:f?h.jsx(c,{spec:t,models:n,loading:r,error:o,query:a,onQueryChange:i,onChange:s}):h.jsx(u,{spec:t,model:d,onChange:s})})}var Wtn=25e3,Ktn=100,Ytn=128e3,Ztn=100,a2=["none","minimal","low","medium","high"],Xtn="May not be supported by this Model";function qtn(e){return e===void 0?{min:Ktn,max:Ytn,step:Ztn,seed:Wtn}:{min:1,max:e,step:1,seed:e}}function Qtn(e,t){return YS(e)?e:t!==void 0&&!a2.some(n=>n===t)?[t,...a2]:[...a2]}function Jtn(e){const t=ZS([...a2],void 0)??"minimal";return ZS(e,void 0)??t}function YS(e){return Array.isArray(e)&&e.length>0}var enn=["medium","high","low"];function ZS(e,t){if(YS(e)){if(t&&e.includes(t))return t;for(const n of enn)if(e.includes(n))return n;return e.find(n=>n!=="none")??e[0]}}function v0(e,t,n){const r=ZS(n,t==null?void 0:t.reasoningEffort);if(r===void 0){if(!t)return{name:e};const{reasoningEffort:o,...a}=t;return{name:e,params:{...a,reasoningEffort:void 0}}}return{name:e,params:{...t,reasoningEffort:r}}}function Lxe(e,t){var o;const n=v0(t.name,e.model.params,t.properties.reasoningEfforts),r=t.properties.maxOutputTokens;return r===void 0||((o=n.params)==null?void 0:o.maxTokens)===void 0||n.params.maxTokens<=r?n:{...n,params:{...n.params,maxTokens:r}}}function tnn({spec:e,models:t,loading:n,error:r,query:o,onQueryChange:a,onChange:i}){const s=_.useId(),l=pp(),c=_.useMemo(()=>t.find(R=>R.name===e.model.name),[t,e.model.name]),u=_.useMemo(()=>Array.from(new Set(t.map(R=>R.provider.name))),[t]),[d,f]=_.useState((c==null?void 0:c.provider.name)??u[0]??""),[g,b]=_.useState(null),v=KS(o),y=_.useMemo(()=>u.map(R=>{const N=t.filter(O=>O.provider.name===R);return{name:R,models:X6e({providerName:R,needle:v})?N:N.filter(O=>oB({model:O,needle:v}))}}).filter(R=>R.models.length>0),[t,v,u]),w=_.useMemo(()=>y.map(R=>R.name),[y]),S=_.useMemo(()=>w.includes(d)?d:c&&w.includes(c.provider.name)?c.provider.name:w[0]??"",[d,c,w]),E=_.useMemo(()=>{var R;return((R=y.find(N=>N.name===S))==null?void 0:R.models)??[]},[S,y]),A=_.useMemo(()=>{if(g===null)return[];const R=t.filter(N=>N.provider.name===g);return v?R.filter(N=>oB({model:N,needle:v})):R},[g,t,v]),T=_.useCallback(()=>{a(""),b(null)},[a]),C=h.jsxs("label",{className:"relative block",children:[h.jsx(be,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),h.jsx("input",{type:"search",value:o,onChange:R=>a(R.target.value),placeholder:"Search",className:ga("h-8 py-1 pr-2 pl-7"),autoFocus:!0})]});return l?g===null?h.jsxs("div",{className:"flex min-h-0 flex-auto flex-col",children:[h.jsxs("div",{className:"shrink-0 border-b border-border px-3 py-2",children:[h.jsx("p",{className:"text-text-primary mb-2 text-base font-medium",children:"Select provider"}),C]}),r?h.jsx("p",{className:"text-failure-bg px-3 pt-3 text-sm",children:r}):null,h.jsx("div",{className:"min-h-0 flex-auto overflow-y-auto p-2",children:w.length===0?h.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-sm",role:"status",children:n?"Loading…":"No providers"}):w.map(R=>{const N=t.find(O=>O.provider.name===R);return h.jsxs("button",{type:"button",className:"hover:bg-ghost-button-hover flex w-full items-center gap-2 rounded-md px-2 py-2.5 text-left text-sm",onClick:()=>b(R),children:[h.jsx(N3,{logo:N==null?void 0:N.provider.logo,label:R,className:"size-5 text-xs"}),h.jsx("span",{className:"min-w-0 flex-1 truncate",children:R}),h.jsx(be,{name:"chevron-right",className:"text-text-secondary size-4 shrink-0"})]},R)})})]}):h.jsxs("div",{className:"flex min-h-0 flex-auto flex-col",children:[h.jsxs("div",{className:"shrink-0 border-b border-border px-3 py-2",children:[h.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[h.jsx("button",{type:"button","aria-label":"Back to providers",title:"Back to providers",className:rn({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),onClick:T,children:h.jsx(be,{name:"arrow-left",className:"size-4"})}),h.jsx("p",{className:"text-text-primary min-w-0 flex-1 truncate text-base font-medium",children:"Select Model"})]}),C]}),r?h.jsx("p",{className:"text-failure-bg px-3 pt-3 text-sm",children:r}):null,h.jsx(aB,{models:A,loading:n,selectedName:e.model.name,query:"",onQueryChange:a,listboxId:s,showHeading:!1,showSearch:!1,onSelect:R=>i({...e,model:Lxe(e,R)})})]}):h.jsxs("div",{children:[h.jsxs("div",{className:"border-b border-border px-3 py-2",children:[h.jsx("p",{className:"text-text-primary mb-2 text-base font-medium",children:"Select model"}),C]}),r?h.jsx("p",{className:"text-failure-bg px-3 pt-3 text-sm",children:r}):null,h.jsxs("div",{className:"grid h-[min(22rem,calc(100dvh-8rem))] w-full min-w-0 grid-cols-[13rem_minmax(0,1fr)] overflow-hidden",children:[h.jsx("div",{className:"min-h-0 overflow-y-auto border-r border-border p-2",children:w.map(R=>h.jsx("button",{type:"button",className:pe("text-text-secondary mb-1 w-full truncate rounded-md px-2 py-2 text-left text-xs",S===R&&"bg-primary-button-bg/10 border border-primary-button-bg font-medium text-primary-button-bg"),onClick:()=>f(R),children:R},R))}),h.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:h.jsx(aB,{models:E,loading:n,selectedName:e.model.name,query:o,onQueryChange:a,listboxId:s,showHeading:!1,showSearch:!1,onSelect:R=>i({...e,model:Lxe(e,R)})})})]})]})}var tze=(e=>(e.UI="ui",e.JSON="json",e))(tze||{}),nze=new Set(["maxTokens","reasoningEffort"]);function zxe(e){if(e.trim()==="")return null;const t=Number(e);return Number.isFinite(t)?t:null}function nnn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function rnn(e){if(!nnn(e))return!1;const t=e.maxTokens,n=e.reasoningEffort;return(t===void 0||typeof t=="number"&&Number.isFinite(t))&&(n===void 0||typeof n=="string")}function Yw(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>!nze.has(t)&&n!==void 0))}function $xe(e){return JSON.stringify(e,null,2)}function onn({spec:e,model:t,onChange:n}){const r=Ge("CodeEditor"),o=Ge("AgentCustomParametersEditor"),a=e.model.params??{},[i,s]=_.useState("ui"),[l,c]=_.useState(()=>$xe(a)),[u,d]=_.useState(null),[f,g]=_.useState(()=>Object.keys(Yw(a)).length>0),b=_.useRef(null),v=L=>n({...e,model:{...e.model,params:L}}),y=(L,$)=>v({...a,[L]:$}),w=L=>v({...a,[L]:void 0}),S=L=>{const $=Object.fromEntries(Object.keys(Yw(a)).map(U=>[U,void 0]));v({...a,...$,...L})},E=L=>{const $=Object.fromEntries(Object.keys(a).filter(U=>!Object.hasOwn(L,U)).map(U=>[U,void 0]));v({...$,...L})},A=L=>{s(L),d(null),L==="json"&&c($xe(a))},T=L=>{if(L!==void 0){c(L);try{const $=JSON.parse(L);if(!rnn($)){d("Parameters must be a JSON object with valid model parameter values.");return}d(null),g(Object.keys(Yw($)).length>0),E($)}catch{d("Invalid JSON.")}}},C=()=>{const L=!f;if(g(L),L){S(b.current??{});return}b.current=Yw(a),S({})},R=t==null?void 0:t.properties.maxOutputTokens,N=qtn(R),O=a.maxTokens??N.seed,P=t==null?void 0:t.properties.reasoningEfforts,j=Qtn(P,a.reasoningEffort),D=Jtn(P),z=[{label:"Maximum Tokens",enabled:a.maxTokens!==void 0,unsupported:R===void 0,onToggle:L=>L?y("maxTokens",N.seed):w("maxTokens"),control:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("input",{type:"range",min:N.min,max:N.max,step:N.step,value:O,"aria-label":"Maximum tokens slider",className:"min-w-0 flex-1 accent-primary-button-bg",onChange:L=>{const $=zxe(L.target.value);$!==null&&y("maxTokens",$)}}),h.jsx("input",{type:"number",min:N.min,max:N.max,step:N.step,value:O,"aria-label":"Maximum tokens value",className:ga("h-8 w-24"),onChange:L=>{const $=zxe(L.target.value);$!==null&&y("maxTokens",Math.min(N.max,$))},onBlur:()=>{O<N.min&&y("maxTokens",N.min)}})]})},{label:"Reasoning Effort",enabled:a.reasoningEffort!==void 0,unsupported:!YS(P),onToggle:L=>L?y("reasoningEffort",D):w("reasoningEffort"),control:h.jsx("select",{value:a.reasoningEffort??"","aria-label":"Reasoning effort value",className:ga("h-8 cursor-pointer py-1.5"),onChange:L=>y("reasoningEffort",L.target.value),children:j.map(L=>h.jsx("option",{value:L,children:L},L))})}];return h.jsxs("div",{className:"w-full",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3",children:[h.jsx("h3",{className:"text-text-primary text-sm font-semibold",children:"Parameters"}),h.jsx("div",{className:"bg-secondary-button-bg flex rounded-md border border-input-border p-0.5",children:Object.values(tze).map(L=>h.jsx("button",{type:"button","aria-pressed":i===L,className:pe("min-w-10 rounded px-2 py-1 text-xs font-medium transition-colors",i===L?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:text-text-primary"),onClick:()=>A(L),children:L==="ui"?"UI":"JSON"},L))})]}),i==="ui"?h.jsx("div",{className:"max-h-[min(30rem,calc(100dvh-8rem))] overflow-y-auto px-4",children:h.jsxs("div",{className:"divide-y divide-border",children:[z.map(L=>h.jsxs("div",{className:"py-3",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"text-text-primary text-sm font-medium",children:L.label}),h.jsx("button",{type:"button","aria-label":`Turn ${L.label} ${L.enabled?"off":"on"}`,"aria-pressed":L.enabled,className:rn({variant:"ghost",size:"small"}),onClick:()=>L.onToggle(!L.enabled),children:L.enabled?"On":"Off"})]}),L.enabled?h.jsxs("div",{className:"mt-2",children:[L.control,L.unsupported?h.jsx("p",{className:"text-failure-bg mt-2 text-xs font-medium",role:"status",children:Xtn}):null]}):null]},L.label)),h.jsxs("div",{className:"py-3",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"text-text-primary text-sm font-medium",children:"Custom Parameters"}),h.jsx("button",{type:"button","aria-label":`Turn Custom Parameters ${f?"off":"on"}`,"aria-pressed":f,className:rn({variant:"ghost",size:"small"}),onClick:C,children:f?"On":"Off"})]}),f?h.jsx("div",{className:"mt-3 mb-2",children:h.jsx(o,{value:Yw(a),reservedKeys:nze,onChange:S})}):null]})]})}):h.jsxs("div",{className:"min-h-88 p-4",children:[h.jsx(r,{value:l,language:"json",height:"20rem",showToolbar:!1,className:pe("h-80",u&&"border-failure-bg"),onChange:T}),u?h.jsx("p",{className:"text-failure-bg mt-2 text-sm font-medium",children:u}):null]})]})}function ann({editor:e,onClose:t,...n}){const r=Ge("AgentResourceEditorContent"),o=Ge("AgentSkillsHeaderActionSlot"),a=e==="mcp";return h.jsx(XJ,{open:e!==null,onOpenChange:i=>!i&&t(),title:a?"Select MCP Tools":"Skills",titleAccessory:a?void 0:h.jsx(o,{}),className:a?"md:w-[min(64rem,calc(100%-3rem))] md:max-w-5xl":"md:w-[min(40rem,calc(100%-3rem))] md:max-w-2xl",contentSized:!0,"aria-label":a?"Select MCP Tools":"Edit skills",footer:a?h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsxs("p",{className:"text-text-secondary flex min-w-0 items-center gap-1.5 text-xs",children:[h.jsx(be,{name:"shield-check",className:"text-warning-bg size-3.5 shrink-0"}),h.jsx("span",{className:"min-w-0",children:"Shielded tools always ask before the agent runs them."})]}),h.jsx(Tn.Primary,{type:"button",onClick:t,children:"Save"})]}):void 0,children:e?h.jsx(r,{editor:e,...n}):null})}function inn(e){const t=Ge("AgentMcpEditorContent"),n=Ge("AgentSkillsEditorContent");return e.editor==="skills"?h.jsx(n,{spec:e.spec,skills:e.skills,skillsDisabled:e.skillsDisabled,query:e.query,onQueryChange:e.onQueryChange,onChange:e.onChange}):h.jsx(t,{spec:e.spec,connectors:e.connectors,query:e.query,activeConnectorId:e.activeConnectorId,tools:e.tools,...e.toolsByConnector===void 0?{}:{toolsByConnector:e.toolsByConnector},connectorLoading:e.connectorLoading,connectorError:e.connectorError,toolsLoading:e.toolsLoading,toolsError:e.toolsError,onQueryChange:e.onQueryChange,onSelectConnector:e.onSelectConnector,onRetryTools:e.onRetryTools,onRefreshConnector:e.onRefreshConnector,onChange:e.onChange})}var snn="https://trueforge.dev/create-agent/overview";function lnn(){return h.jsxs("a",{href:snn,target:"_blank",rel:"noreferrer","aria-label":"View docs",className:"text-indigo-400 flex items-center gap-1",children:[h.jsx("span",{className:"text-xs",children:"Docs"}),h.jsx(be,{name:"external-link",className:"size-3 shrink-0"})]})}function cnn({open:e,spec:t,sandboxAvailable:n,onChange:r,onClose:o}){const a=Ge("AgentRuntimeEditorContent");return h.jsx(E3,{open:e,onOpenChange:i=>!i&&o(),title:"Runtime Config",titleAccessory:h.jsx(lnn,{}),description:"Control execution, sandbox, and context behavior.",anchor:"right",size:"xl",className:"md:w-3xl","aria-label":"Edit Runtime Config",children:h.jsx(a,{spec:t,sandboxAvailable:n,onChange:r})})}var unn="trueforge-sandbox-env";function byn(e){return e.trim()===unn}function rze(e){if(!e.enabled)return"Disabled by an admin. Existing chats and agents keep using it.";if(e.status==="pending")return"Still building. Available once the build finishes.";if(e.status==="failed")return"The last build failed. Fix it under Manage Environments."}function vyn(e){const t=(e==null?void 0:e.cpu)??1,n=(e==null?void 0:e.memory)??1,r=(e==null?void 0:e.disk)??3;return`${String(t)} vCPU · ${String(n)} GB RAM · ${String(r)} GB disk`}function yyn(e){var r;if((e==null?void 0:e.networkBlockAll)===!0)return"Blocked";const t=((r=e==null?void 0:e.domainAllowList)==null?void 0:r.trim())??"";if(t.length===0)return"Unrestricted";const n=t.split(",").map(o=>o.trim()).filter(o=>o.length>0).length;return n===0?"Unrestricted":`${String(n)} allowed domain${n===1?"":"s"}`}function xyn(){return{name:"",description:"",image:{type:"build",buildScript:""},resources:{cpu:1,memory:1,disk:3},networking:{networkBlockAll:!1}}}async function dnn({fetchPage:e}){const t=[];let n;do{const r=await e(n);t.push(...r.data),n=r.nextPageToken}while(n!=null&&n.length>0);return t}function oze(){const e=zH(),t=go(),n=(t==null?void 0:t.environmentsListEpoch)??0,r=(t==null?void 0:t.environmentsOpen)??!1,[o,a]=_.useState([]),[i,s]=_.useState(()=>e!=null),[l,c]=_.useState(!1),[u,d]=_.useState(null),f=_.useRef(0),g=_.useRef(r),b=_.useCallback(async()=>{if(!e){a([]),c(!1),s(!1),d(null);return}const y=++f.current;try{const w=await dnn({fetchPage:S=>e.listEnvironments({limit:1e3,pageToken:S})});if(y!==f.current)return;a(w),c(!0),d(null)}catch(w){if(y!==f.current)return;d(Oa(w,"Failed to load sandbox environments.")),a([])}finally{y===f.current&&s(!1)}},[e]),v=_.useCallback(async()=>{e&&(s(!0),d(null)),await b()},[e,b]);return _.useEffect(()=>{b()},[b,n]),_.useEffect(()=>{g.current&&!r&&v(),g.current=r},[r,v]),{environments:o,defaultEnvironment:o.find(y=>y.isDefault),loading:i,loaded:l,error:u,refetch:v}}var aze="Web search is not configured",ize="Web search is off for this tenant. Turning it off here is final until an admin turns it back on.";function sze({capabilities:e,enabled:t}){var r;if(e==null)return{locked:!1,offIsFinal:!1};const n=((r=e.webSearch)==null?void 0:r.enabled)===!0;return{locked:!n&&!t,offIsFinal:t&&!n}}var pnn="Memory is turned off for this tenant",fnn="Memory is off for this tenant. Turning it off here is final until an admin turns it back on.";function hnn({capabilities:e,enabled:t}){const n=e==null?void 0:e.memory;return n===void 0?{hidden:!0,locked:!1,offIsFinal:!1}:{hidden:!1,locked:!n.enabled&&!t,offIsFinal:t&&!n.enabled}}function Uxe(e){if(e.trim()==="")return null;const t=Number(e);return Number.isInteger(t)&&Number.isFinite(t)?Math.max(1,Math.min(1024,t)):null}function gnn(e){if(e.trim()==="")return null;const t=Number(e);return Number.isInteger(t)&&t>0?t:null}var mnn="Can't change the environment after a chat has started",Fxe="No sandbox provider yet, add one in Settings → Sandbox",Bxe=5e4,bnn=[{value:"auto",label:"Auto"},{value:"custom",label:"Custom"}];function p$({children:e}){return h.jsxs("p",{role:"status",className:"border-warning-bg bg-warning-bg/10 text-warning-bg mt-2 flex items-start gap-2 rounded-md border px-3 py-2 text-xs",children:[h.jsx(be,{name:"circle-exclamation",className:"size-3.5 shrink-0","aria-hidden":!0}),h.jsx("span",{className:"flex w-full items-center justify-between gap-1",children:e})]})}function vnn({value:e,sandboxAvailable:t,hasSkills:n,disabled:r=!1,showCapabilities:o=!0,layout:a="compact",onChange:i}){var he,se,ie,ue,te,re,xe,Ae,Me,qe,ze,Ze,Qe,ct,De,Ye,yt,gt,Nt,Re,Oe;const s=go(),l=th(),c=((se=(he=l==null?void 0:l.sandbox)==null?void 0:he.environments)==null?void 0:se.enabled)===!0,{environments:u,defaultEnvironment:d,loaded:f,refetch:g}=oze(),{draftSessionId:b}=Bu(),v=b!=null,y=Jke(e.sandbox),w=y??(d==null?void 0:d.name),S=!v&&f&&y===void 0?d==null?void 0:d.name:void 0;_.useEffect(()=>{S!==void 0&&i({...e,sandbox:D9(e.sandbox,S)})},[S]);const E=_.useMemo(()=>{const ve=u.map(je=>{const Se=rze(je);return{value:je.name,label:je.name,disabled:Se!==void 0,...Se===void 0?{}:{disabledReason:Se}}});return w!==void 0&&!ve.some(je=>je.value===w)&&ve.unshift({value:w,label:w,disabled:!0,disabledReason:"No longer available."}),ve},[u,w]),A=ve=>{var je;return{...e,contextManagement:{...e.contextManagement,compaction:ve,largeToolResponse:((je=e.contextManagement)==null?void 0:je.largeToolResponse)??{enabled:!0}}}},T=ve=>i(A(ve)),C=[{label:"Dynamic sub-agents",description:"Allow the agent to delegate complex work to focused sub-agents.",checked:((ie=e.dynamicSubAgents)==null?void 0:ie.enabled)??!0,update:ve=>({...e,dynamicSubAgents:{enabled:ve}})},{label:"Generative UI",description:"Allow rich interactive UI blocks in agent responses.",checked:((ue=e.generativeUi)==null?void 0:ue.enabled)??!0,update:ve=>({...e,generativeUi:{enabled:ve}})},{label:"Ask user questions",description:"Allow the agent to pause and ask for clarification.",checked:((te=e.askUserQuestions)==null?void 0:te.enabled)??!0,update:ve=>({...e,askUserQuestions:{enabled:ve}})}],R=((re=e.sandbox)==null?void 0:re.enabled)??!1,N=h.jsx(rB,{"aria-label":"Environment",value:w??"",options:E,placeholder:f&&u.length===0?"No environments":"Select environment",emptyContent:h.jsx("p",{className:"text-text-secondary px-2 py-1.5 text-sm",children:"No environments yet"}),disabled:r||v||!t||!R,className:"w-48",onOpenChange:ve=>{ve&&g()},onValueChange:ve=>i({...e,sandbox:D9(e.sandbox,ve)})}),O=((Ae=(xe=e.contextManagement)==null?void 0:xe.compaction)==null?void 0:Ae.enabled)??!0,P=((qe=(Me=e.contextManagement)==null?void 0:Me.compaction)==null?void 0:qe.trigger)!=null?"custom":"auto",j=((ze=e.webSearch)==null?void 0:ze.enabled)??((Ze=l==null?void 0:l.webSearch)==null?void 0:Ze.enabled)===!0,{locked:D,offIsFinal:z}=sze({capabilities:l,enabled:j}),L={label:"Web search",description:"Allow the agent to search the web and fetch pages.",checked:j,disabled:D,...D?{disabledTooltip:((Qe=l==null?void 0:l.webSearch)==null?void 0:Qe.reason)??aze}:{},update:ve=>({...e,webSearch:{enabled:ve}})},$=((ct=e.memory)==null?void 0:ct.enabled)??!1,{hidden:U,locked:B,offIsFinal:V}=hnn({capabilities:l,enabled:$}),G=U?null:{label:"Memory",description:"Remember details from your past chats.",checked:$,disabled:B,...B?{disabledTooltip:((De=l==null?void 0:l.memory)==null?void 0:De.reason)??pnn}:{},update:ve=>({...e,memory:{enabled:ve}})},F={label:"Sandbox",description:"Provide an isolated environment for code, files, and skills.",checked:R,disabled:!t||n,disabledTooltip:t?n?"Always on while skills are attached — remove them to turn it off":void 0:Fxe,update:ve=>({...e,sandbox:{...e.sandbox,enabled:ve}})},Z={label:"File downloads",description:"Allow users to download files produced in the sandbox.",checked:((Ye=e.sandbox)==null?void 0:Ye.fileDownloads)??!0,disabled:!t||!R,update:ve=>({...e,sandbox:{...e.sandbox,fileDownloads:ve}})},J={label:"Context compaction",description:"Summarize older turns as context fills.",checked:O,update:ve=>{var je;return A({...(je=e.contextManagement)==null?void 0:je.compaction,enabled:ve})}},W={label:"Large tool response offloading",description:"Move large tool output to the sandbox and retain a preview.",checked:((gt=(yt=e.contextManagement)==null?void 0:yt.largeToolResponse)==null?void 0:gt.enabled)??!0,disabled:!t,disabledTooltip:t?void 0:`Offloading needs a sandbox. ${Fxe}`,update:ve=>{var je;return{...e,contextManagement:{...e.contextManagement,compaction:((je=e.contextManagement)==null?void 0:je.compaction)??{enabled:!0},largeToolResponse:{enabled:ve}}}}},Y=[F,Z,J,W],q=((Oe=(Re=(Nt=e.contextManagement)==null?void 0:Nt.compaction)==null?void 0:Re.trigger)==null?void 0:Oe.value)??Bxe,ne=({field:ve,className:je,wrapperClassName:Se})=>{const $e=h.jsx(gy,{checked:ve.checked,disabled:r||ve.disabled,onCheckedChange:St=>i(ve.update(St)),"aria-label":ve.label});return h.jsxs("div",{className:pe("flex w-full min-w-0",Se,je??"items-center justify-between gap-3 py-1.5"),children:[h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:pe("text-text-primary",a==="detailed"?"block text-sm font-medium":"text-xs"),children:ve.label}),a==="detailed"?h.jsx("span",{className:"text-text-secondary mt-0.5 block text-xs leading-snug",children:ve.description}):null]}),ve.disabledTooltip?h.jsx(sr,{content:ve.disabledTooltip,children:h.jsx("span",{className:"inline-flex",children:$e})}):$e]},ve.label)};if(a==="detailed"){const ve="items-center justify-between gap-4";return h.jsxs("div",{className:"divide-y divide-border",children:[o?h.jsx("div",{className:"flex flex-col gap-3 py-4 md:flex-row md:gap-4",children:C.map((je,Se)=>ne({field:je,className:"items-start justify-between gap-3",wrapperClassName:pe("flex-1",Se<C.length-1&&"border-b border-border pb-4 md:border-b-0 md:border-r md:pb-0 md:pr-4")}))}):null,h.jsxs("div",{className:pe("flex py-4",ve),children:[h.jsxs("span",{className:"min-w-0",children:[h.jsx("span",{className:"text-text-primary block text-sm font-medium",children:"Iteration limit"}),h.jsx("span",{className:"text-text-secondary mt-0.5 block text-xs leading-snug",children:"Maximum agent-loop iterations for one turn."})]}),h.jsx("input",{type:"number",min:1,max:1024,disabled:r,"aria-label":"Iteration limit",value:e.iterationLimit??512,className:ga("h-8 w-24 shrink-0 disabled:opacity-60"),onChange:je=>{const Se=Uxe(je.target.value);Se!==null&&i({...e,iterationLimit:Se})}})]}),h.jsxs("div",{className:"py-4",children:[ne({field:L,className:ve}),z?h.jsx(p$,{children:ize}):null]}),G!=null?h.jsxs("div",{className:"py-4",children:[ne({field:G,className:ve}),V?h.jsx(p$,{children:fnn}):null]}):null,h.jsxs("section",{className:"py-4",children:[ne({field:F,className:ve}),t&&!R?h.jsxs(p$,{children:[h.jsx("span",{children:"Disabling sandbox will degrade trueforge's performance."}),h.jsxs("a",{className:"flex cursor-pointer items-center gap-1 text-xs font-medium text-amber-500",href:"https://trueforge.dev/key-features/code-mode#what-is-code-mode",target:"_blank",rel:"noopener noreferrer",children:[h.jsx("span",{children:"Learn more"}),h.jsx(be,{name:"external-link",className:"size-3"})]})]}):null,h.jsxs("div",{className:`mt-3 border-l-2 border-primary-button-bg/50 pl-3 ${R?"":"opacity-50"}`,children:[c?h.jsxs("div",{className:pe("flex py-4",ve),children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"text-text-primary block text-sm font-medium",children:"Environment"}),h.jsx("p",{className:"text-text-secondary mt-0.5 text-xs leading-snug",children:"Saved sandbox setup this agent uses when it runs."}),s&&R?h.jsxs("button",{type:"button",onClick:()=>s.setEnvironmentsOpen(!0),className:"text-primary-button-bg mt-1.5 inline-flex items-center gap-1 text-xs hover:underline",children:[h.jsx("span",{children:"Manage Environments"}),h.jsx(be,{name:"external-link",className:"size-3"})]}):null]}),h.jsx("div",{className:"flex shrink-0 items-center",children:v?h.jsx(sr,{content:mnn,children:h.jsx("span",{className:"inline-flex",children:N})}):N})]}):null,ne({field:Z,className:ve})]})]}),h.jsxs("section",{className:"py-4",children:[ne({field:J,className:ve}),h.jsxs("div",{className:pe("mt-3 flex border-l-2 border-primary-button-bg/50 pl-3",ve,O?"":"opacity-50"),children:[h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsx("span",{className:"text-text-primary block text-sm font-medium",children:"Compaction threshold tokens"}),h.jsx("span",{className:"text-text-secondary mt-0.5 block text-xs leading-snug",children:P==="auto"?"Automatically trigger compaction at 80% of model's context window":`Trigger compaction when input reaches ${q.toLocaleString()} tokens`})]}),h.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[P==="custom"?h.jsx("input",{type:"number",min:1,disabled:r||!O,value:q,"aria-label":"Compaction threshold tokens",className:ga("h-8 w-28 disabled:opacity-60"),onChange:je=>{const Se=gnn(je.target.value);Se!==null&&T({enabled:O,trigger:{type:"input_tokens",value:Se}})}}):null,h.jsx(rB,{"aria-label":"Compaction threshold mode",value:P,options:bnn,disabled:r||!O,className:"w-28",onValueChange:je=>T(je==="custom"?{enabled:O,trigger:{type:"input_tokens",value:Bxe}}:{enabled:O})})]})]})]}),ne({field:W,className:pe("py-4",ve)})]})}return h.jsxs("div",{children:[h.jsxs("label",{className:"mb-2 block text-xs",children:[h.jsx("span",{className:"text-text-secondary mb-1 block",children:"Iteration limit"}),h.jsx("input",{type:"number",min:1,max:1024,disabled:r,value:e.iterationLimit??512,className:ga("h-8 disabled:opacity-60"),onChange:ve=>{const je=Uxe(ve.target.value);je!==null&&i({...e,iterationLimit:je})}})]}),[L,...G!=null?[G]:[],...Y,...o?C:[]].map(ve=>ne({field:ve}))]})}function ynn({spec:e,sandboxAvailable:t,onChange:n}){var o;const r=Ge("AgentRuntimeConfigFields");return h.jsx("div",{className:"w-full p-5",children:h.jsx(r,{value:e.config??{},sandboxAvailable:t,hasSkills:(((o=e.skills)==null?void 0:o.length)??0)>0,layout:"detailed",onChange:a=>n({...e,config:a})})})}function xnn({spec:e,skills:t,skillsDisabled:n,query:r,onQueryChange:o,onChange:a}){const i=Ge("CatalogRow"),[s,l]=_.useState({}),c=b0(e.skills),[u]=_.useState(()=>new Set(c.map(g=>Aa(g.id)))),d=r.trim().toLowerCase(),f=t.filter(g=>`${g.name} ${rN(g)??""} ${g.description??""}`.toLowerCase().includes(d)).sort((g,b)=>{const v=u.has(Aa(g.id)),y=u.has(Aa(b.id));return Number(y)-Number(v)});return h.jsxs("div",{className:"flex h-[min(32rem,calc(100dvh-8rem))] w-full min-w-0 flex-col overflow-hidden",children:[h.jsxs("label",{className:"relative m-3 block shrink-0",children:[h.jsx(be,{name:"search",className:"text-text-secondary absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),h.jsx("input",{value:r,onChange:g=>o(g.target.value),placeholder:"Search skills",className:ga("h-8 w-full pl-7")})]}),h.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[f.map(g=>{const b=c.find(w=>Aa(w.id)===Aa(g.id)),v=s[g.id],y=rN(g);return h.jsx(i,{title:g.name,description:g.description,badge:y===void 0?void 0:h.jsx("span",{className:"bg-primary-button-bg/10 text-primary-button-bg shrink-0 rounded-full px-1.5 py-0.5 text-[0.625rem]",children:y}),checked:b!==void 0,disabled:n&&b===void 0,action:YJ(g)===void 0?void 0:h.jsx(ktn,{skill:g,selectedId:(v==null?void 0:v.id)??(b==null?void 0:b.id),onChange:w=>{l(S=>({...S,[g.id]:w})),b!==void 0&&a({...e,skills:c.map(S=>S===b?{...S.value,id:w.id,name:w.name}:S.value)})}}),onToggle:()=>{var S;const w=b===void 0;a({...e,skills:w?[...e.skills??[],{id:(v==null?void 0:v.id)??g.id,name:(v==null?void 0:v.name)??g.name}]:c.filter(E=>E!==b).map(E=>E.value),...w?{config:{...e.config,sandbox:{...(S=e.config)==null?void 0:S.sandbox,enabled:!0}}}:{}})}},g.id)}),f.length===0?h.jsx("p",{className:"text-text-secondary p-4 text-center text-sm",children:"No skills found."}):null]})]})}var lze=_.createContext(null);function wnn({routes:e,children:t}){return h.jsx(lze.Provider,{value:e,children:t})}function qJ(){return _.useContext(lze)}var cze="/skills",uze="/settings";function _nn({settingsSkillsUrl:e,routes:t}){if(e!==uze||t==null)return e;const n=qH({type:"settings"},t);return n==null?e:`${t.basename.endsWith("/")?t.basename.slice(0,-1):t.basename}${n}`||n}function Hxe({catalog:e,capabilities:t}){return XN({catalog:e,capabilities:t})&&(e==null?void 0:e.skillCatalog)!=null}function Vxe(e){return e.length>0}function dze({platformSkillsUrl:e=cze,settingsSkillsUrl:t=uze}={}){const n=KN(),r=th(),o=Kke(),a=go(),i=qJ(),s=_nn({settingsSkillsUrl:t,routes:i});if(!o)return null;const l=Hxe({catalog:n,capabilities:r}),c=Vxe(e);return!l&&!c?null:h.jsxs(Tn.Ghost,{type:"button",size:"small",className:"ml-1 shrink-0",title:"Register Skills",onClick:()=>{if(Hxe({catalog:n,capabilities:r})){if(a!=null){a.setSettingsOpen(!0,"skills");return}window.location.assign(s);return}Vxe(e)&&window.location.assign(e)},children:["Register Skills",h.jsx(be,{name:"external-link",className:"size-3 shrink-0"})]})}function my(e,t){return{...e,...t.sessionId!=null&&t.sessionId!==""?{session_id:t.sessionId}:{},...t.agentId!=null&&t.agentId!==""?{agent_id:t.agentId}:{},...t.agentName!=null&&t.agentName!==""?{agent_name:t.agentName}:{}}}function Snn({disabled:e,isRunning:t}){const n=go(),r=us(),o=(n==null?void 0:n.agentConfigOpen)===!0;return h.jsx(sr,{content:"Agent config",children:h.jsx("button",{type:"button","aria-label":"Agent config","aria-haspopup":"dialog","aria-expanded":o,disabled:e||t||n==null,className:rn({variant:"ghost",size:"icon",className:"size-8"}),onClick:()=>{const a=!o;a&&r(io.Config.OPENED,my(void 0,{...(n==null?void 0:n.mode.status)==="active"?{agentId:n.mode.agentId,agentName:n.mode.agentName}:{}})),n==null||n.setAgentConfigOpen(a)},children:h.jsx(be,{name:"sliders",className:"size-3.5"})})})}var Gxe=[{id:"generativeUi",label:"Generative UI",description:"Let the agent render interactive UI in its replies."},{id:"dynamicSubAgents",label:"Dynamic sub-agents",description:"Let the agent spin up sub-agents for complex tasks."},{id:"askUserQuestions",label:"Ask clarifying questions",description:"Let the agent ask before acting when unsure."}];function knn({value:e,onChange:t,disabled:n=!1,divided:r=!1,layout:o="list"}){return o==="cards"?h.jsx("div",{className:"flex flex-col gap-2 sm:flex-row",children:Gxe.map(a=>{const i=e[a.id];return h.jsxs("div",{className:"border-border flex min-w-0 flex-col gap-2 rounded-lg border p-3 sm:flex-1",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsx("p",{className:"text-text-primary text-sm font-medium",children:a.label}),h.jsx(gy,{checked:i,"aria-label":a.label,disabled:n,className:"mt-0.5",onCheckedChange:s=>t({...e,[a.id]:s})})]}),h.jsx("p",{className:"text-text-secondary text-xs leading-snug",children:a.description})]},a.id)})}):h.jsx("div",{className:pe("flex flex-col",r&&"overflow-hidden rounded-xl border border-border"),children:Gxe.map((a,i)=>{const s=e[a.id];return h.jsxs("div",{className:pe("flex items-start gap-3 px-3 py-3",r&&i>0&&"border-t border-border"),children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-text-primary text-sm font-medium",children:a.label}),h.jsx("p",{className:"text-text-secondary mt-0.5 text-xs leading-snug",children:a.description})]}),h.jsx(gy,{checked:s,"aria-label":a.label,disabled:n,className:"mt-0.5",onCheckedChange:l=>t({...e,[a.id]:l})})]},a.id)})})}function Enn({actions:e,disabled:t}){return e.length===0?null:h.jsx(Ep,{align:"start",side:"top",className:"w-48",trigger:h.jsx("button",{type:"button","aria-label":"Add",title:"Add",disabled:t,className:rn({variant:"ghost",size:"icon",className:"size-8 rounded-full"}),children:h.jsx(be,{name:"plus",className:"size-4"})}),children:e.map(n=>h.jsxs(pu,{onClick:n.onSelect,children:[h.jsx(be,{name:n.icon,className:"text-text-secondary size-4 shrink-0"}),h.jsx("span",{children:n.label})]},n.id))})}function Tnn({disabled:e,isRunning:t}){var E,A,T,C,R;const{models:n,ensureLoaded:r}=JN(),{agentSpec:o}=Bu(),a=qk(),[i,s]=_.useState(!1),l=_.useRef(null),c=_.useRef(null),u=_.useId(),d=km(),f=pp(),g=((E=o==null?void 0:o.model)==null?void 0:E.name)??((A=n[0])==null?void 0:A.name)??"",b=n.find(N=>N.name===g),v=b==null?void 0:b.properties.reasoningEfforts,y=(C=(T=o==null?void 0:o.model)==null?void 0:T.params)==null?void 0:C.reasoningEffort,w=ZS(v,y);if(_.useEffect(()=>{r()},[r]),_.useEffect(()=>{if(!i)return;const N=O=>{l.current&&!l.current.contains(O.target)&&s(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[i]),_.useEffect(()=>{var O;if(!a||b===void 0)return;const N=c.current;c.current=b.name,!(N===null||N===b.name)&&(YS(v)||y===void 0||a({model:v0(b.name,(O=o==null?void 0:o.model)==null?void 0:O.params,void 0)}))},[a,b,v,y,(R=o==null?void 0:o.model)==null?void 0:R.params]),!YS(v)||!w)return null;const S=h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"border-b border-border px-3 py-2",children:h.jsx("p",{className:"text-text-primary text-sm font-normal",children:"Reasoning effort"})}),h.jsx("div",{id:u,role:"listbox","aria-label":"Select reasoning effort",className:"flex min-h-0 flex-1 flex-col overflow-y-auto p-1",children:v.map(N=>{const O=N===w;return h.jsx("button",{type:"button",role:"option","aria-selected":O,className:pe("flex w-full items-center rounded-md px-2 py-2 text-left text-sm",O?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text":"hover:bg-ghost-button-hover"),onClick:()=>{var P;!b||!a||(a({model:v0(b.name,{...(P=o==null?void 0:o.model)==null?void 0:P.params,reasoningEffort:N},v)}),s(!1))},children:h.jsx("span",{className:"truncate font-normal",children:N})},N)})})]});return h.jsxs("div",{ref:l,className:"relative",children:[h.jsxs("button",{type:"button",disabled:e||t,"aria-haspopup":"listbox","aria-expanded":i,"aria-controls":i?u:void 0,title:"Select reasoning effort",className:rn({variant:"ghost",size:"small",className:pe("h-8 max-w-[10rem] gap-1.5 rounded-full px-2 text-xs font-medium","hover:bg-ghost-button-hover")}),onClick:()=>s(N=>!N),children:[h.jsx("span",{className:"truncate",children:w}),h.jsx(be,{name:"chevron-down",className:"size-3.5 shrink-0 opacity-60"})]}),i?d||f?h.jsx(I3,{open:!0,onOpenChange:s,"aria-label":"Select reasoning effort",children:S}):h.jsx("div",{className:"aui-popup-enter bg-card-bg text-text-primary absolute right-0 bottom-full z-50 mb-2 flex max-h-[22rem] w-[12rem] flex-col overflow-hidden rounded-lg border border-border shadow-lg",children:S}):null]})}function Ann({disabled:e,isRunning:t,onAttach:n}){const r=go(),o=us(),a=Ge("DraftCompositeSelector"),i=Ge("DraftAgentConfigTrigger"),s=Ge("DraftComposerActionsMenu"),l=pp(),c=km(),u=r!=null&&pk(r.mode),d=[{id:"agent-config",label:"Agent config",icon:"sliders",onSelect:()=>{o(io.Config.OPENED,my(void 0,{...(r==null?void 0:r.mode.status)==="active"?{agentId:r.mode.agentId,agentName:r.mode.agentName}:{}})),r==null||r.setAgentConfigOpen(!0)}},...n===void 0?[]:[{id:"attach",label:"Attach a file",icon:"paperclip",onSelect:n}]];return h.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[u?null:h.jsx(a,{disabled:e,isRunning:t,onAttach:n}),u&&l?h.jsx(s,{actions:d,disabled:e||t}):null,u&&!l&&c?h.jsx(i,{disabled:e,isRunning:t}):null,u&&!l&&n!=null?h.jsx(sr,{content:"Attach a file",children:h.jsx("button",{type:"button",disabled:e||t,"aria-label":"Attach a file",className:rn({variant:"ghost",size:"icon"}),onClick:n,children:h.jsx(be,{name:"paperclip"})})}):null]})}function Cnn({disabled:e,isRunning:t}){const n=go(),r=Ge("DraftModelSelector"),o=n!=null&&pk(n.mode);return h.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o?null:h.jsx(r,{disabled:e,isRunning:t}),h.jsx(Tnn,{disabled:e,isRunning:t})]})}function Wxe(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const r=Reflect.get(n,"name");if(typeof r!="string")continue;const o=Reflect.get(n,"id"),a=Reflect.get(n,"display_name"),i=Reflect.get(n,"preload");t.push({id:typeof o=="string"?o:r,name:typeof a=="string"?a:r,...typeof i=="boolean"?{preload:i}:{}})}return t}var Rnn=[{id:"connectors",label:"Connectors",icon:"plug"},{id:"skills",label:"Skills",icon:"lightbulb"},{id:"environments",label:"Environment",icon:"monitor"}],Inn=300,Kxe="Can't change the environment after a chat has started";function xg({title:e,description:t,badge:n,logo:r,fallbackIcon:o,checked:a,disabled:i=!1,disabledReason:s,selectionControl:l="checkbox",onToggle:c,onActivate:u,action:d}){const f=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"bg-secondary-bg text-text-secondary mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded border border-border text-xs font-semibold","aria-hidden":!0,children:r?h.jsx(WJ,{src:r,alt:e,className:"size-4"}):o?h.jsx(be,{name:o,className:"text-text-primary size-4"}):e.charAt(0).toUpperCase()}),h.jsxs("span",{className:"min-w-0 flex-1",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[h.jsx("span",{className:"text-text-primary truncate text-sm font-medium",children:e}),n]}),t?h.jsx(sr,{content:t,side:"bottom",className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full",interactive:!1,children:h.jsx("span",{className:"text-text-secondary block truncate text-xs",children:t})}):null]})]}),g=l==="radio"?h.jsx("span",{className:pe("flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors",a?"border-primary-button-bg bg-primary-button-bg":"border-text-secondary/60 bg-input-box-bg"),"aria-hidden":!0,children:a?h.jsx("span",{className:"size-1.5 rounded-full bg-primary-button-text"}):null}):h.jsx(ZJ,{checked:a}),b=l==="radio"?"menuitemradio":"menuitemcheckbox",v=h.jsx("button",{type:"button",role:l==="radio"?"radio":"checkbox","aria-checked":a,"aria-label":`${a?"Deselect":"Select"} ${e}`,disabled:i,className:"shrink-0 disabled:cursor-not-allowed disabled:opacity-50",onClick:w=>{w.stopPropagation(),!i&&c()},children:g}),y=i&&s?h.jsx(sr,{content:s,className:"max-w-xs text-left",children:h.jsx("span",{className:"inline-flex shrink-0",children:v})}):v;return d||u||i?h.jsxs("div",{role:b,"aria-checked":a,"aria-disabled":i||void 0,tabIndex:i?-1:0,className:pe("hover:bg-ghost-button-hover flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-left",i&&"cursor-default opacity-50 hover:bg-transparent"),onClick:()=>{i||(u??c)()},onKeyDown:w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),!i&&(u??c)())},children:[f,d?h.jsx("span",{className:"shrink-0",onClick:w=>w.stopPropagation(),onKeyDown:w=>w.stopPropagation(),children:d}):null,y]}):h.jsxs("button",{type:"button",role:b,"aria-checked":a,className:"hover:bg-ghost-button-hover flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-left",onClick:c,children:[f,g]})}function sC(e){const t=Reflect.get(e,"auth");return e.authenticated===!1&&typeof t=="object"&&t!==null&&Reflect.get(t,"type")==="dcr"}function sB({connector:e,onConnected:t}){const{handleAuthorize:n,isOAuthLoading:r}=eze();return h.jsx(Tn.Secondary,{type:"button","aria-label":`Connect ${e.name}`,disabled:r,size:"small",onKeyDown:o=>{o.stopPropagation()},onClick:o=>{o.stopPropagation(),n(e.id,a=>{a&&t()})},children:r?"Connecting...":"Connect"})}function Nnn({value:e,onChange:t,placeholder:n}){return h.jsxs("label",{className:"relative mx-3 my-2 block",children:[h.jsx(be,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),h.jsx("input",{type:"search",value:e,onChange:r=>t(r.target.value),placeholder:n,className:ga("h-8 bg-secondary-bg py-1 pr-2 pl-7 dark:bg-primary-bg")})]})}var f$="Web search",Yxe="Search the web for up-to-date answers",h$="TrueForge",Zxe="Create and update agents, schedules, and sandbox environments";function Zw({label:e,count:t}){return h.jsx("div",{className:"text-text-secondary px-3 pt-2 pb-1 text-[0.6875rem] font-medium tracking-wide uppercase",children:t==null?e:`${e} (${t})`})}function lC({children:e,icon:t="lock"}){return h.jsxs("div",{role:"status",className:"border-primary-button-bg/30 bg-primary-button-bg/5 text-text-primary mx-3 mb-2 flex items-start gap-2 rounded-lg border p-3",children:[h.jsx(be,{name:t,className:"text-primary-button-bg mt-px size-3 shrink-0"}),h.jsx("span",{className:"text-xs leading-snug",children:e})]})}function Mnn({disabled:e,isRunning:t,onAttach:n}){var On,Po,Vo,ko,Ja,ba,Cc,Wu;const r=Ge("DraftComposerActionsMenu"),{skills:o,connectors:a,connectorLogos:i,loading:s,ensureLoaded:l,refreshConnectors:c}=JN(),u=th(),d=KN(),f=go(),{agentSpec:g,draftSessionId:b}=Bu(),v=qk(),y=b!=null,[w,S]=_.useState(!1),[E,A]=_.useState("connectors"),[T,C]=_.useState(""),[R,N]=_.useState(()=>new Set),[O,P]=_.useState(()=>new Set),[j,D]=_.useState([]),[z,L]=_.useState([]),$=_.useRef(!1),U=_.useRef(null),B=_.useRef(j),V=_.useRef(z);B.current=j,V.current=z;const G=_.useRef(null),F=_.useId(),Z=km(),J=pp(),W=(u==null?void 0:u.skill.enabled)!==!0,Y=u==null?void 0:u.skill.reason,q=((Po=(On=u==null?void 0:u.sandbox)==null?void 0:On.environments)==null?void 0:Po.enabled)===!0,ne=((Vo=u==null?void 0:u.webSearch)==null?void 0:Vo.reason)??aze,he=((Ja=(ko=g==null?void 0:g.config)==null?void 0:ko.webSearch)==null?void 0:Ja.enabled)??((ba=u==null?void 0:u.webSearch)==null?void 0:ba.enabled)===!0,{locked:se,offIsFinal:ie}=sze({capabilities:u,enabled:he}),ue=!se,te=DH(g==null?void 0:g.config)!==!1,re=(u==null?void 0:u.sandbox.enabled)===!1,xe=u==null?void 0:u.settings,Ae=PC({settings:xe,section:"mcpServers"})&&(d==null?void 0:d.connectorCatalog)!=null,Me=PC({settings:xe,section:"skills"})&&(d==null?void 0:d.skillCatalog)!=null,qe=PC({settings:xe,section:"sandboxProviders"})&&(d==null?void 0:d.sandboxCatalog)!=null,ze=_.useMemo(()=>Rnn.filter(Xe=>Xe.id!=="environments"||q),[q]);_.useEffect(()=>{!q&&E==="environments"&&A("connectors")},[q,E]);const Ze=_.useMemo(()=>Wxe(g==null?void 0:g.mcpServers),[g==null?void 0:g.mcpServers]),Qe=_.useMemo(()=>Wxe(g==null?void 0:g.skills),[g==null?void 0:g.skills]),ct=w?j:Ze,De=w?z:Qe,Ye=_.useMemo(()=>new Set(ct.map(Xe=>Xe.id)),[ct]),yt=!!((Cc=g==null?void 0:g.model)!=null&&Cc.name.trim()),gt=ct.length+De.length+(he?1:0)+(te?1:0),Nt=_.useMemo(()=>{const Xe=Ct=>{const kr=Ct.map(vi=>vi.name);return kr.length<=4?kr.join(", "):`${kr.slice(0,4).join(", ")} +${kr.length-4}`},tn=[],Ke=[...te?[h$]:[],...he?[f$]:[]];return Ke.length>0&&tn.push(`Built-in: ${Ke.join(", ")}`),ct.length>0&&tn.push(`Connectors: ${Xe(ct)}`),De.length>0&&tn.push(`Skills: ${Xe(De)}`),tn.length>0?tn.join(`
1093
- `):"No connectors or skills selected"},[ct,De,te,he]),Re=_.useCallback(()=>{U.current!=null&&(window.clearTimeout(U.current),U.current=null)},[]),Oe=_.useCallback(()=>{Re(),$.current&&($.current=!1,v==null||v({mcpServers:B.current,skills:V.current}))},[Re,v]),ve=_.useCallback(()=>{Re(),U.current=window.setTimeout(()=>{U.current=null,Oe()},Inn)},[Re,Oe]),je=_.useCallback(Xe=>{Xe||Oe(),S(Xe)},[Oe]);_.useEffect(()=>{w&&l()},[w,l]),_.useEffect(()=>{w&&!yt&&je(!1)},[yt,w,je]),_.useEffect(()=>{if(!w)return;const Xe=tn=>{G.current&&!G.current.contains(tn.target)&&je(!1)};return document.addEventListener("mousedown",Xe),document.addEventListener("focusin",Xe),()=>{document.removeEventListener("mousedown",Xe),document.removeEventListener("focusin",Xe)}},[w,je]),_.useEffect(()=>()=>Re(),[Re]);const Se=_.useMemo(()=>GJ({connectors:a,selected:ct}),[a,ct]),$e=_.useMemo(()=>{const Xe=T.trim().toLowerCase();return[...Xe?Se.filter(Ke=>{var Ct;return Ke.name.toLowerCase().includes(Xe)||(((Ct=Ke.description)==null?void 0:Ct.toLowerCase().includes(Xe))??!1)}):Se].sort((Ke,Ct)=>Number(sC(Ke))-Number(sC(Ct)))},[Se,T]),St=_.useMemo(()=>{const Xe=T.trim().toLowerCase();return Xe?o.filter(tn=>{var Ke,Ct;return tn.name.toLowerCase().includes(Xe)||(((Ke=rN(tn))==null?void 0:Ke.toLowerCase().includes(Xe))??!1)||(((Ct=tn.description)==null?void 0:Ct.toLowerCase().includes(Xe))??!1)}):o},[o,T]),tt=_.useMemo(()=>$e.filter(Xe=>R.has(Xe.id)),[$e,R]),bt=_.useMemo(()=>$e.filter(Xe=>!R.has(Xe.id)),[$e,R]),At=_.useMemo(()=>St.filter(Xe=>O.has(Aa(Xe.id))),[St,O]),Et=_.useMemo(()=>St.filter(Xe=>!O.has(Aa(Xe.id))),[St,O]),Jt=Xe=>{D(tn=>tn.some(Ke=>Ke.id===Xe.id)?tn.filter(Ke=>Ke.id!==Xe.id):[...tn,{id:Xe.id,name:Xe.name}]),$.current=!0,ve()},hn=()=>{if(!ue||g==null)return;const Xe=!he,tn={...g,config:{...g.config,webSearch:{enabled:Xe}}};v==null||v({config:tn.config}),f==null||f.rememberDraftSpec(tn,"chat")},Tt=()=>{if(g==null)return;const Xe={...g,config:{...g.config,trueforge:{enabled:!te}}};v==null||v({config:Xe.config}),f==null||f.rememberDraftSpec(Xe,"chat")},Ut=(Xe,tn)=>{const Ke=T.trim().toLowerCase();return Ke?Xe.toLowerCase().includes(Ke)||tn.toLowerCase().includes(Ke):!0},en=Ut(f$,Yxe),xt=Ut(h$,Zxe),Ht=Xe=>{var Ct;const tn=Aa(Xe.id),Ke=!V.current.some(kr=>Aa(kr.id)===tn);L(kr=>kr.some(vi=>Aa(vi.id)===tn)?kr.filter(vi=>Aa(vi.id)!==tn):[...kr,{id:Xe.id,name:Xe.name}]),Ke&&(u==null?void 0:u.sandbox.enabled)===!0&&(v==null||v({config:{...g==null?void 0:g.config,sandbox:{...(Ct=g==null?void 0:g.config)==null?void 0:Ct.sandbox,enabled:!0}}})),$.current=!0,ve()},jn=Xe=>{const tn=De.find(Ct=>Aa(Ct.id)===Aa(Xe.id)),Ke=rN(Xe);return h.jsx(xg,{title:Xe.name,description:Xe.description,badge:Ke===void 0?void 0:h.jsx("span",{className:"bg-primary-button-bg/10 text-primary-button-bg shrink-0 rounded-full px-1.5 py-0.5 text-[0.625rem]",children:Ke}),checked:tn!==void 0,disabled:W&&tn===void 0,onToggle:()=>Ht(Xe)},Xe.id)},{environments:Vt,defaultEnvironment:eo,loading:Qa,refetch:_r}=oze(),Vn=Xe=>{const tn=E==="environments";if(w){tn&&_r();return}D(Ze),L(Qe),$.current=!1,Re(),N(new Set(Ze.map(Ke=>Ke.id))),P(new Set(Qe.map(Ke=>Aa(Ke.id)))),S(!0),tn&&_r()},So=Xe=>{je(!1),C(""),f==null||f.setSettingsOpen(!0,Xe)},Sr=Jke((Wu=g==null?void 0:g.config)==null?void 0:Wu.sandbox)??(eo==null?void 0:eo.name),Fi=_.useMemo(()=>{const Xe=Vt.map(Ke=>{const Ct=rze(Ke);return{value:Ke.name,title:Ke.name,description:Ke.manifest.description,...Ct===void 0?{}:{unavailable:Ct}}});Sr!==void 0&&!Xe.some(Ke=>Ke.value===Sr)&&Xe.unshift({value:Sr,title:Sr,description:void 0,unavailable:"No longer available."});const tn=T.trim().toLowerCase();return tn?Xe.filter(Ke=>{var Ct;return Ke.title.toLowerCase().includes(tn)||(((Ct=Ke.description)==null?void 0:Ct.toLowerCase().includes(tn))??!1)}):Xe},[Vt,T,Sr]),qs=Xe=>{var tn;y||v==null||v({config:{...g==null?void 0:g.config,sandbox:{...D9((tn=g==null?void 0:g.config)==null?void 0:tn.sandbox,Xe),enabled:!0}}})},Sn=h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"flex shrink-0 border-b border-border",children:ze.map(Xe=>{const tn=Xe.id==="connectors"?ct.length:Xe.id==="skills"?De.length:null,Ke=E===Xe.id;return h.jsxs("button",{type:"button",className:pe("text-text-secondary flex flex-1 items-center justify-center gap-1.5 px-2 py-2.5 text-xs font-medium",Ke&&"text-primary-button-bg border-b-2 border-primary-button-bg"),onClick:()=>{A(Xe.id),C(""),Xe.id==="environments"&&_r()},children:[h.jsx(be,{name:Xe.icon,className:"size-3.5"}),Xe.label,tn!=null&&tn>0?h.jsx("span",{className:"bg-secondary-bg rounded px-1 text-[0.625rem]",children:tn}):null]},Xe.id)})}),h.jsxs(h.Fragment,{children:[h.jsx(Nnn,{value:T,onChange:C,placeholder:E==="connectors"?"Search connectors...":E==="skills"?"Search skills...":"Search environment..."}),E==="skills"&&W&&Y?h.jsx(lC,{children:Y}):null,h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 pb-2",children:E==="connectors"?h.jsxs(h.Fragment,{children:[xt||en?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Built-in"}),xt?h.jsx(xg,{title:h$,description:Zxe,fallbackIcon:"bot",checked:te,onToggle:Tt}):null,en?h.jsxs(h.Fragment,{children:[h.jsx(xg,{title:f$,description:Yxe,fallbackIcon:"searchGlobe",checked:he,disabled:!ue,disabledReason:ne,onToggle:hn}),ue?null:h.jsx(lC,{children:ne}),ie?h.jsx(lC,{icon:"info",children:ize}):null]}):null]}):null,tt.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Selected",count:tt.length}),tt.map(Xe=>h.jsx(xg,{title:Xe.name,logo:i[Xe.name],fallbackIcon:"mcp-server",checked:Ye.has(Xe.id),action:sC(Xe)?h.jsx(sB,{connector:Xe,onConnected:c}):void 0,onToggle:()=>Jt(Xe)},Xe.id))]}):null,bt.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Available",count:bt.length}),bt.map(Xe=>h.jsx(xg,{title:Xe.name,logo:i[Xe.name],fallbackIcon:"mcp-server",checked:Ye.has(Xe.id),action:sC(Xe)?h.jsx(sB,{connector:Xe,onConnected:c}):void 0,onToggle:()=>Jt(Xe)},Xe.id))]}):null,$e.length===0&&a.length>0&&!en?h.jsx(__,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors"}):null,a.length===0?h.jsx(__,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors",onOpenSettings:f&&Ae?()=>So("connectors"):void 0}):null]}):E==="skills"?h.jsxs(h.Fragment,{children:[At.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Selected",count:At.length}),At.map(jn)]}):null,Et.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Available",count:Et.length}),Et.map(jn)]}):null,St.length===0?h.jsx(__,{loading:s,emptyLabel:"No skills",settingsTarget:re?"a Sandbox":"Skills",onOpenSettings:o.length===0&&f&&(re?qe:Me)?()=>So(re?"sandbox":"skills"):void 0}):null]}):h.jsxs(h.Fragment,{children:[y?h.jsx(lC,{children:Kxe}):null,Fi.map(Xe=>{const tn=Sr===Xe.value,Ke=y?Kxe:Xe.unavailable;return h.jsx(xg,{title:Xe.title,description:Xe.description,fallbackIcon:"monitor",selectionControl:"radio",checked:tn,disabled:Ke!==void 0,...Ke===void 0?{}:{disabledReason:Ke},onToggle:()=>qs(Xe.value)},Xe.value)}),Fi.length===0?h.jsx(__,{loading:Qa,emptyLabel:"No environments",settingsTarget:"Environments",onOpenSettings:f?()=>{je(!1),f.setEnvironmentsOpen(!0)}:void 0}):null]})})]})]}),ur=[...yt?[{id:"tools",label:`Tools (${gt})`,icon:"wrench",onSelect:()=>Vn()}]:[],...n===void 0?[]:[{id:"attach",label:"Attach a file",icon:"paperclip",onSelect:n}]];return h.jsxs("div",{ref:G,className:"relative flex flex-wrap items-center",children:[J?h.jsx(r,{actions:ur,disabled:e||t}):yt?h.jsx(sr,{content:Nt,className:"max-w-xs whitespace-pre-line text-left",side:"top",children:h.jsxs("button",{type:"button",disabled:e||t,"aria-label":`Tools (${gt})`,"aria-haspopup":"dialog","aria-expanded":w,"aria-controls":w?F:void 0,className:rn({variant:"ghost",size:"large",className:"gap-1.5 px-2 text-xs"}),onClick:()=>{if(w){je(!1);return}Vn()},children:[h.jsx(be,{name:"wrench"}),h.jsx("span",{children:"Tools"}),h.jsx("span",{className:"rounded bg-primary-button-bg/10 px-1.5 py-0.5 text-[0.625rem] font-semibold text-primary-button-bg",children:gt})]})}):null,!J&&n?h.jsx(sr,{content:"Attach a file",children:h.jsx("button",{type:"button",disabled:e||t,"aria-label":"Attach a file",className:rn({variant:"ghost",size:"icon"}),onClick:n,children:h.jsx(be,{name:"paperclip"})})}):null,w&&yt?Z||J?h.jsx(I3,{id:F,open:!0,onOpenChange:je,"aria-label":"Add to composer",children:Sn}):h.jsx("div",{id:F,role:"dialog","aria-label":"Add to composer",className:"aui-popup-enter bg-card-bg text-text-primary absolute bottom-full left-0 z-50 mb-2 flex h-[22rem] w-[28rem] max-w-[min(28rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-lg border border-border shadow-lg",children:Sn}):null]})}function Onn({disabled:e,isRunning:t}){var z,L,$,U,B;const{models:n,loading:r,loaded:o,ensureLoaded:a}=JN(),{agentSpec:i}=Bu(),s=qk(),l=KN(),c=th(),u=go(),d=us(),[f,g]=_.useState(!1),[b,v]=_.useState(""),y=_.useRef(null),w=_.useId(),S=km(),E=pp(),A=XN({catalog:l,capabilities:c}),T=o&&n.length===0&&A&&u!=null,C=_.useRef(null);_.useEffect(()=>{a()},[a]),_.useEffect(()=>{var Z,J,W;if(!s||r||n.length===0)return;const V=n[0];if(V===void 0)return;const G=V.name,F=((J=(Z=i==null?void 0:i.model)==null?void 0:Z.name)==null?void 0:J.trim())??"";if(F&&n.some(q=>q.name===F)){C.current=null;return}C.current!==G&&(C.current=G,s({model:v0(G,(W=i==null?void 0:i.model)==null?void 0:W.params,V.properties.reasoningEfforts)}))},[s,r,n,(z=i==null?void 0:i.model)==null?void 0:z.name,(L=i==null?void 0:i.model)==null?void 0:L.params]);const R=(($=i==null?void 0:i.model)==null?void 0:$.name)??((U=n[0])==null?void 0:U.name)??"",N=n.find(V=>V.name===R),O=(B=N==null?void 0:N.warning)==null?void 0:B.trim(),P=N?nN(N.name):R?nN(R):r?"Loading…":"Select model";if(_.useEffect(()=>{if(!f)return;const V=G=>{y.current&&!y.current.contains(G.target)&&g(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[f]),T)return h.jsx(Tn.Ghost,{type:"button",size:"small",disabled:e||t,"aria-label":"Configure model",className:"h-8 max-w-48 rounded-full px-2 text-xs font-medium",onClick:()=>{u!=null&&u.settingsOpen||d(io.Settings.OPENED),u==null||u.setSettingsOpen(!0,"models")},children:"Configure model"});const j=(N==null?void 0:N.provider.name)??R,D=h.jsx(aB,{models:n,loading:r,selectedName:R,query:b,onQueryChange:v,listboxId:w,onSelect:V=>{var G;s==null||s({model:v0(V.name,(G=i==null?void 0:i.model)==null?void 0:G.params,V.properties.reasoningEfforts)}),g(!1),v("")}});return h.jsxs("div",{ref:y,className:"relative flex min-w-0 items-center gap-1",children:[h.jsx(sr,{content:R||"Select model",className:"max-w-xs whitespace-normal break-all",children:h.jsxs("button",{type:"button",disabled:e||t,"aria-haspopup":"listbox","aria-expanded":f,"aria-controls":f?w:void 0,"aria-label":"Select model",className:rn({variant:"ghost",size:"small",className:pe("h-8 max-w-48 gap-1.5 rounded-full px-2 text-xs font-medium","hover:bg-ghost-button-hover")}),onClick:()=>g(V=>!V),children:[h.jsx(N3,{logo:N==null?void 0:N.provider.logo,label:j,className:"size-4 text-xs"}),h.jsx("span",{className:"truncate",children:P}),h.jsx(be,{name:"chevron-down",className:"size-3.5 shrink-0 opacity-60"})]})}),O?h.jsx(q6e,{warning:O,side:"bottom"}):null,f?S||E?h.jsx(I3,{open:!0,onOpenChange:g,"aria-label":"Select model",children:D}):h.jsx("div",{className:"aui-popup-enter bg-card-bg text-text-primary absolute right-0 bottom-full z-50 mb-2 flex max-h-[22rem] w-[18rem] flex-col overflow-hidden rounded-lg border border-border shadow-lg",children:D}):null]})}function Pnn({open:e,value:t,onChange:n,onClose:r}){const o=Ge("InstructionsMarkdownEditor");return h.jsx(vx,{open:e,onOpenChange:a=>!a&&r(),"aria-label":"Edit instructions full screen",className:"h-[calc(100dvh-2rem)] max-h-none w-[calc(100vw-2rem)] max-w-none",children:e?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"border-border flex items-center justify-between gap-3 border-b px-4 py-2",children:[h.jsx("h2",{className:"text-text-primary text-sm font-semibold",children:"Agent instructions"}),h.jsx("button",{type:"button","aria-label":"Exit full screen",title:"Exit full screen",className:rn({variant:"ghost",size:"icon",className:"size-7"}),onClick:r,children:h.jsx(be,{name:"compress",className:"size-4"})})]}),h.jsx("div",{className:"min-h-0 flex-1",children:h.jsx(o,{value:t,onChange:n,height:"100%"})})]}):null})}var jnn=/^(#{1,6})\s/,Dnn=/^\s*(```|~~~)/;function Lnn(e){const t=[],n=[];let r=null,o="";const a=({level:i,endLine:s})=>{var l;for(let c=n.at(-1);c!==void 0&&c.level>=i;c=n.at(-1)){n.pop();let u=s;for(;u>c.start&&((l=e[u-1])==null?void 0:l.trim())==="";)u-=1;u>c.start&&t.push({start:c.start,end:u})}};return e.forEach((i,s)=>{var f;const l=s+1,c=Dnn.exec(i);if(r!==null){c!==null&&c[1]===o&&(l>r&&t.push({start:r,end:l}),r=null);return}if(c!==null){r=l,o=c[1]??"";return}const u=jnn.exec(i);if(u===null)return;const d=((f=u[1])==null?void 0:f.length)??1;a({level:d,endLine:l-1}),n.push({level:d,start:l})}),a({level:0,endLine:e.length}),t}function znn(e){if(typeof e!="object"||e===null||!("languages"in e))return!1;const{languages:t}=e;return typeof t=="object"&&t!==null&&"registerFoldingRangeProvider"in t&&typeof t.registerFoldingRangeProvider=="function"}var Xxe=!1;function $nn(e){Xxe||!znn(e)||(Xxe=!0,e.languages.registerFoldingRangeProvider("markdown",{provideFoldingRanges(t){const n=Array.from({length:t.getLineCount()},(r,o)=>t.getLineContent(o+1));return Lnn(n)}}))}var Unn={lineNumbers:"on",renderFinalNewline:"on",guides:{indentation:!1},folding:!0,showFoldingControls:"always",renderLineHighlight:"line",fontSize:13,lineHeight:20,padding:{top:8,bottom:8}};function Fnn({value:e,onChange:t,height:n}){const r=Ge("MonacoEditorCore");return h.jsx(r,{value:e,language:"markdown",options:Unn,beforeMount:$nn,onChange:t,height:n})}function Bnn({className:e,compact:t=!1}){const n=go(),r=zH(),o=th(),a=us(),i=$H({sandboxEnvironments:r,capabilities:o})&&n!=null,s=(n==null?void 0:n.environmentsOpen)===!0;return i?h.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:h.jsxs("button",{type:"button","aria-label":t?"Environments":void 0,title:t?"Environments":void 0,"aria-current":s?"page":void 0,className:rn({variant:"ghost",className:pe(fk,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?QN:"h-8 w-full !justify-start px-2.5 text-sm",s&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{s||a(io.Environment.PAGE_OPENED),n.setEnvironmentsOpen(!s)},children:[h.jsx(be,{name:"monitor",size:t?14:void 0}),t?h.jsx("span",{className:"text-center",children:"Environments"}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"truncate",children:"Environments"}),h.jsx(be,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}var Hnn=288,Vnn=.75,Gnn=.42;function pze({requested:e,rowWidth:t}){if(t<=0)return e;const n=Math.min(Hnn,t*.3),r=Math.max(n,t*Vnn);return Math.min(r,Math.max(n,e))}function wyn(e){return pze({requested:e*Gnn,rowWidth:e})}function Wnn({name:e,view:t}){const n=Ge("SyntaxHighlighter"),r=Ge("Markdown");return t.status==="loading"?h.jsx("div",{className:"flex h-full items-center justify-center text-text-secondary",children:h.jsx(Al,{size:20})}):t.status==="error"||t.status==="unavailable"?h.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-text-secondary",children:t.message}):t.status==="media"?t.media==="image"?h.jsx("div",{className:"flex h-full items-center justify-center p-4",children:h.jsx("img",{src:t.objectUrl,alt:e,className:"max-h-full max-w-full object-contain"})}):h.jsx("iframe",{title:e,src:t.objectUrl,className:"absolute inset-0 h-full w-full border-0"}):t.status==="html"?h.jsx("iframe",{title:e,sandbox:"allow-scripts allow-forms",referrerPolicy:"no-referrer",srcDoc:t.text,className:"absolute inset-0 h-full w-full border-0 bg-white"}):t.status==="markdown"?h.jsx("div",{className:"px-4 py-3",children:h.jsx(r,{content:t.text})}):t.language!=null&&t.text.length<=Cen?h.jsx(n,{code:t.text,language:t.language,showLineNumbers:!0,className:"my-0 h-full rounded-none"}):h.jsx("pre",{className:"m-0 min-h-full whitespace-pre-wrap break-words p-4 font-mono text-sm text-text-primary",children:t.text})}function qxe(e,t,n){var o;const r=((o=e.parentElement)==null?void 0:o.getBoundingClientRect().width)??0;n(pze({requested:t,rowWidth:r}))}function Knn({name:e,placement:t,view:n,onClose:r,onDownload:o,onEnterFullPage:a,onExitFullPage:i,onRetry:s,downloadBusy:l=!1,widthPx:c,onWidthChange:u}){const d=_.useRef(null),f=t==="side"&&u!=null;_.useEffect(()=>{var v;(v=d.current)==null||v.focus()},[e,t]);const g=v=>{if(u==null)return;v.preventDefault();const y=v.currentTarget,w=d.current;if(w==null)return;typeof y.setPointerCapture=="function"&&y.setPointerCapture(v.pointerId);const S=v.clientX,E=w.getBoundingClientRect().width,A=C=>{qxe(w,E+(S-C.clientX),u)},T=C=>{typeof y.hasPointerCapture=="function"&&y.hasPointerCapture(C.pointerId)&&y.releasePointerCapture(C.pointerId),y.removeEventListener("pointermove",A),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T)};y.addEventListener("pointermove",A),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T)};return h.jsxs("aside",{ref:d,tabIndex:-1,"data-slot":"aui_file-preview","data-placement":t,"aria-label":`Preview of ${e}`,onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),t==="full"&&i!=null?i():r())},style:t==="side"&&c!=null?{width:`${c}px`}:void 0,className:pe("aui-file-preview relative flex min-h-0 min-w-0 flex-col bg-primary-bg outline-none",t==="overlay"&&"absolute inset-0 z-30",t==="full"&&"absolute inset-0 z-30",t==="side"&&"h-full shrink-0 border-l border-border",t==="side"&&c==null&&"w-1/2 max-w-[42rem]"),children:[f?h.jsxs("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize preview",...c!=null?{"aria-valuenow":Math.round(c)}:{},tabIndex:0,title:"Drag to resize",onPointerDown:g,onKeyDown:v=>{if(u==null||d.current==null)return;const y=v.shiftKey?48:16;if(v.key!=="ArrowLeft"&&v.key!=="ArrowRight")return;v.preventDefault(),v.stopPropagation();const w=d.current.getBoundingClientRect().width,S=v.key==="ArrowLeft"?y:-y;qxe(d.current,w+S,u)},className:"group/resizer absolute inset-y-0 -left-2 z-20 flex w-4 cursor-col-resize touch-none items-center justify-center focus-visible:outline-none",children:[h.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border group-hover/resizer:bg-primary-button-bg"}),h.jsx("div",{"aria-hidden":!0,className:pe("relative flex h-10 w-3.5 items-center justify-center rounded-full border border-border shadow-sm","bg-primary-bg text-text-secondary","group-hover/resizer:border-primary-button-bg group-hover/resizer:bg-primary-button-bg group-hover/resizer:text-primary-button-text","group-focus-visible/resizer:border-primary-button-bg group-focus-visible/resizer:bg-primary-button-bg group-focus-visible/resizer:text-primary-button-text"),children:h.jsx(be,{name:"grip-vertical",size:12})})]}):null,h.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border px-3",children:[h.jsx(be,{name:"file",size:16,className:"shrink-0 text-text-secondary"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-text-primary",children:e}),n.status==="error"&&s!=null?h.jsx("button",{type:"button",onClick:s,className:rn({variant:"ghost",size:"small"}),children:"Retry"}):null,t==="full"&&i!=null?h.jsx("button",{type:"button",onClick:i,"aria-label":"Exit full page",title:"Exit full page",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"compress",size:14})}):null,t!=="full"&&a!=null?h.jsx("button",{type:"button",onClick:a,"aria-label":"Full page",title:"Full page",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"expand",size:14})}):null,h.jsx("button",{type:"button",onClick:o,disabled:l,"aria-busy":l||void 0,"aria-label":l?`Downloading ${e}`:`Download ${e}`,title:"Download",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:l?h.jsx(Al,{size:14}):h.jsx(be,{name:"download",size:14})}),h.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",title:"Close preview",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"xmark",size:14})})]}),h.jsx("div",{className:pe("relative h-full min-h-0 flex-1",n.status==="html"||n.status==="media"&&n.media==="pdf"?"overflow-hidden":"overflow-auto"),children:h.jsx(Wnn,{name:e,view:n})})]})}var fze=_.forwardRef(({className:e,isLoading:t=!1,...n},r)=>h.jsx("div",{ref:r,"data-slot":"aui_history-loader",role:"status","aria-live":"polite","aria-label":t?"Loading older messages":"Scroll up to load older messages",className:pe("flex justify-center py-2",e),...n,children:t&&h.jsx(Al,{size:14})}));fze.displayName="HistoryLoader";var hze="aui-trusted-external-hosts";function oN(){return{version:1,links:[],images:[]}}function Qxe(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Ynn(e){if(e==null||typeof e!="object"||!("version"in e)||e.version!==1)return oN();const t="links"in e&&Qxe(e.links)?e.links:[],n="images"in e&&Qxe(e.images)?e.images:[];return{version:1,links:t,images:n}}function gze(){if(typeof window>"u")return oN();try{const e=JSON.parse(window.localStorage.getItem(hze)??"null");return Ynn(e)}catch{return oN()}}function Znn(e){if(!(typeof window>"u"))try{window.localStorage.setItem(hze,JSON.stringify(e))}catch{}}function mze(e){try{const t=typeof window<"u"?window.location.href:"http://localhost";return new URL(e,t)}catch{return null}}function XS(e){const t=mze(e);return t==null||t.protocol!=="http:"&&t.protocol!=="https:"?null:t.hostname.toLowerCase()}function lB(e){const t=XS(e);return t==null?!1:typeof window>"u"?!0:t!==window.location.hostname.toLowerCase()}function bze({kind:e,host:t}){const n=t.toLowerCase();return gze()[e].includes(n)}function Jxe({kind:e,host:t}){const n=t.toLowerCase(),r=gze();r[e].includes(n)||Znn({...r,[e]:[...r[e],n]})}function vze(e){const t=mze(e);t!=null&&(t.protocol!=="http:"&&t.protocol!=="https:"||window.open(t.href,"_blank","noopener,noreferrer"))}var yze=_.createContext(null);function xze(){const e=_.useContext(yze);if(e==null)throw new Error("Markdown external URL confirm requires ExternalUrlConfirmProvider");return e}function ewe(e){try{const t=new URL(e,typeof window<"u"?window.location.href:"http://localhost").protocol;return t==="javascript:"||t==="data:"||t==="vbscript:"}catch{return!0}}function Xnn({children:e}){const[t,n]=_.useState(null),[r,o]=_.useState(!1),[a,i]=_.useState(()=>new Set),s=_.useCallback(S=>{o(!1),n({kind:"link",url:S})},[]),l=_.useCallback(S=>{o(!1),n({kind:"image",url:S})},[]),c=_.useCallback(S=>a.has(S.toLowerCase()),[a]),u=_.useCallback(()=>{n(null),o(!1)},[]),d=_.useCallback(()=>{if(t==null)return;const S=XS(t.url);if(t.kind==="link"){r&&S!=null&&Jxe({kind:"links",host:S}),vze(t.url),u();return}S!=null&&(r&&Jxe({kind:"images",host:S}),i(E=>{const A=new Set(E);return A.add(S.toLowerCase()),A})),u()},[u,r,t]),f=_.useMemo(()=>({requestLinkConfirm:s,requestImageConfirm:l,isSessionImageHostTrusted:c}),[c,l,s]),g=t!=null?XS(t.url):null,b=(t==null?void 0:t.kind)==="image"?"Show external image":"Open external link",v=(t==null?void 0:t.kind)==="image"?"You're about to load an image from an external site:":"You're leaving this app to visit an external link:",y=(t==null?void 0:t.kind)==="image"?"Show image":"Open link",w=g==null?null:(t==null?void 0:t.kind)==="image"?`Don't ask again for images from ${g}`:`Don't ask again for links to ${g}`;return h.jsxs(yze.Provider,{value:f,children:[e,h.jsxs(vx,{open:t!=null,onOpenChange:S=>{S||u()},"aria-label":b,className:"max-w-md",children:[h.jsxs(tE,{children:[h.jsxs(S3,{children:[h.jsx(k3,{children:b}),h.jsx("p",{className:"text-sm text-text-secondary",children:v})]}),t!=null?h.jsx("div",{className:"max-h-24 overflow-auto break-all rounded-md bg-secondary-bg px-3 py-2 font-mono text-sm text-text-primary","data-testid":"aui-external-url-confirm-url",children:t.url}):null,w!=null?h.jsxs("button",{type:"button",role:"checkbox","aria-checked":r,className:"flex items-start gap-2 text-left text-sm text-text-secondary",onClick:()=>o(S=>!S),children:[h.jsx(ZJ,{checked:r,className:"mt-0.5"}),h.jsx("span",{children:w})]}):null]}),h.jsxs(zJ,{children:[h.jsx(Tn.Secondary,{type:"button",onClick:u,children:"Cancel"}),h.jsx(Tn.Primary,{type:"button",onClick:d,children:y})]})]})]})}function qnn({href:e,children:t,node:n,...r}){const{requestLinkConfirm:o}=xze(),a=e!=null&&e!==""&&ewe(e),i=e!=null&&e!==""&&!a&&lB(e),s=a?void 0:e,l=c=>{if(e==null||e==="")return;if(ewe(e)){c.preventDefault();return}if(!lB(e))return;c.preventDefault();const u=XS(e);if(u!=null&&bze({kind:"links",host:u})){vze(e);return}o(e)};return h.jsx("a",{...r,href:s,target:i||a?"_blank":r.target,rel:"noopener noreferrer",onClick:l,onAuxClick:l,children:t})}function Qnn({src:e,alt:t,node:n,...r}){const{requestImageConfirm:o,isSessionImageHostTrusted:a}=xze(),i=typeof e=="string"?e:"",s=i!==""?XS(i):null;return!(i!==""&&lB(i))||s!=null&&(bze({kind:"images",host:s})||a(s))?h.jsx("img",{...r,src:e,alt:t??""}):h.jsxs("span",{className:pe("my-2 flex max-w-full flex-col gap-2 rounded-md border border-border bg-secondary-bg p-3"),"data-testid":"aui-external-image-placeholder",children:[h.jsx("span",{className:"text-sm text-text-secondary",children:t!=null&&t!==""?t:"External image"}),h.jsx("span",{className:"max-h-16 overflow-auto break-all font-mono text-xs text-text-secondary",children:i}),h.jsx(Tn.Secondary,{type:"button",size:"small",className:"self-start",onClick:()=>{i!==""&&o(i)},children:"Show image"})]})}function _yn(){return Ya(()=>Promise.resolve().then(()=>ivn),void 0,import.meta.url)}var Jnn=8*1024;function ern(e){const t=/^(`{3,})([^\n]*)\n?/gm,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({after:r.index+r[0].length});if(n.length%2===0)return null;const o=n[n.length-1];return o==null?null:e.slice(o.after).replace(/\n$/,"")}function trn(e){const{isStreaming:t,getActiveFenceCode:n,darkTheme:r,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s,OpenUiFenceBlock:l,SandboxArtifactDownload:c,SyntaxHighlighter:u,inlineCodeClassName:d}=e;return{a:qnn,img:Qnn,pre({children:f}){return h.jsx(h.Fragment,{children:f})},code({className:f,children:g}){var S;const b=(S=/language-(\w+)/.exec(f??""))==null?void 0:S[1],v=String(g??"").replace(/\n$/,"");if(!f)return h.jsx("code",{className:pe("aui-inline-code rounded bg-secondary-bg px-1 py-0.5 font-mono text-sm",d),children:g});if(b==="openui")return h.jsx(l,{content:v,isStreaming:t,darkTheme:r});if(b==="sandbox_artifacts")return h.jsx(c,{code:v,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s});const y=n();return t===!0&&y!=null&&v===y&&v.length>Jnn?h.jsx("pre",{className:pe("aui-syntax-highlighter my-2 max-w-full min-w-0 overflow-x-auto whitespace-pre-wrap break-words rounded-md"),"data-testid":"aui-plain-streaming-fence",children:h.jsx("code",{className:pe(f,"whitespace-pre-wrap break-words"),children:v})}):h.jsx(u,{code:v,language:b,darkTheme:r})}}}var nrn=[JXt];function wze({content:e,isStreaming:t,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,className:i}){const s=O3(),l=qN(),c=s==="dark",u=Ge("OpenUiFenceBlock"),d=Ge("SandboxArtifactDownload"),f=Ge("SyntaxHighlighter"),g=_.useRef(null);g.current=t===!0?ern(e):null;const b=_.useMemo(()=>trn({isStreaming:t,getActiveFenceCode:()=>g.current,darkTheme:c,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,OpenUiFenceBlock:u,SandboxArtifactDownload:d,SyntaxHighlighter:f,inlineCodeClassName:l.inlineCode}),[t,c,n,r,o,a,u,d,f,l.inlineCode]);return h.jsx(Xnn,{children:h.jsx("div",{className:pe("aui-markdown markdown-body min-w-0 max-w-full overflow-x-clip",l.markdown,i),children:h.jsx(vMe,{remarkPlugins:nrn,components:b,children:e})})})}var rrn="h-6 w-6 text-text-secondary hover:text-text-primary [&_svg]:size-3.5";function _ze({isCopied:e,onCopy:t,createdAt:n,className:r}){const o=Ge("MessageTimestamp");return h.jsxs("div",{className:pe("aui-assistant-action-bar-root animate-in fade-in flex items-center gap-1 duration-200",r),children:[h.jsx(o,{createdAt:n,className:"mr-1"}),h.jsx(Bf,{"aria-label":"Copy",tooltip:"Copy",variant:"ghost",className:rrn,onClick:t,children:h.jsx(be,{name:e?"check":"clone",size:"0.875em"})})]})}function orn({message:e,className:t}){return h.jsxs("div",{role:"status",className:pe("aui-message-cancelled-root border-warning-bg bg-warning-bg/10 text-warning-bg mt-2 inline-flex w-fit max-w-full items-center gap-3 rounded-xl border px-3 py-1.5 text-sm font-medium leading-[1.4]",t),children:[h.jsx(be,{name:"circle-exclamation",size:"1rem",className:"text-warning-bg shrink-0","aria-hidden":!0}),h.jsx("span",{className:"aui-message-cancelled-message min-w-0 break-words",children:e})]})}function arn({message:e,className:t}){return h.jsx("div",{role:"alert",className:pe("aui-message-error-root border-failure-bg bg-failure-bg/10 text-failure-bg mt-2 rounded-md border p-3 text-sm",t),children:h.jsx("span",{className:"aui-message-error-message line-clamp-2",children:e})})}function irn({label:e="Working...",className:t}){return h.jsxs("span",{"data-slot":"aui_assistant-message-indicator",role:"status",className:pe("inline-flex items-center gap-1.5 font-sans text-sm text-text-secondary",t),children:[h.jsx(PJ,{state:"listening",size:20,"aria-hidden":!0}),h.jsx("span",{className:"aui-text-shimmer",children:e})]})}function srn(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function lrn(e){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).format(e)}function crn({createdAt:e,className:t}){const n=srn(e);return n==null?null:h.jsx(GS,{title:p6e(n),size:"fit",side:"bottom",children:h.jsx("span",{className:pe("text-xs font-medium cursor-pointer leading-normal shrink-0 text-text-secondary",t),children:lrn(n)})})}var twe;function Sze(){return twe??(twe=Ya(()=>import("./index-CdSOK6zy.js").then(e=>e.i),__vite__mapDeps([0,1]),import.meta.url)),twe}var kze="aui-monaco-light",Eze="aui-monaco-dark",fd="#00000000",QJ=18,Tze=8,nwe="10.5rem";function urn(e){const t={"editor.background":fd,"editor.lineHighlightBackground":fd,"editor.lineHighlightBorder":fd,"editorGutter.background":fd,"minimap.background":fd,focusBorder:fd,"scrollbar.shadow":fd,"editorOverviewRuler.border":fd,"editorOverviewRuler.background":fd};e.editor.defineTheme(kze,{base:"vs",inherit:!0,rules:[],colors:t}),e.editor.defineTheme(Eze,{base:"vs-dark",inherit:!0,rules:[],colors:t})}function drn(e,t,n){return e||t||(n==="dark"?Eze:kze)}function g$(e,t){if(e==null)return t;if(typeof e=="number")return e;const n=e.trim();if(n.endsWith("rem")){const o=parseFloat(n),a=typeof document<"u"&&parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Number.isFinite(o)?o*a:t}if(n.endsWith("px")){const o=parseFloat(n);return Number.isFinite(o)?o:t}const r=parseFloat(n);return Number.isFinite(r)?r:t}function prn(e,t,n){const o=Math.max(1,e.split(`
1093
+ `):"No connectors or skills selected"},[ct,De,te,he]),Re=_.useCallback(()=>{U.current!=null&&(window.clearTimeout(U.current),U.current=null)},[]),Oe=_.useCallback(()=>{Re(),$.current&&($.current=!1,v==null||v({mcpServers:B.current,skills:V.current}))},[Re,v]),ve=_.useCallback(()=>{Re(),U.current=window.setTimeout(()=>{U.current=null,Oe()},Inn)},[Re,Oe]),je=_.useCallback(Xe=>{Xe||Oe(),S(Xe)},[Oe]);_.useEffect(()=>{w&&l()},[w,l]),_.useEffect(()=>{w&&!yt&&je(!1)},[yt,w,je]),_.useEffect(()=>{if(!w)return;const Xe=tn=>{G.current&&!G.current.contains(tn.target)&&je(!1)};return document.addEventListener("mousedown",Xe),document.addEventListener("focusin",Xe),()=>{document.removeEventListener("mousedown",Xe),document.removeEventListener("focusin",Xe)}},[w,je]),_.useEffect(()=>()=>Re(),[Re]);const Se=_.useMemo(()=>GJ({connectors:a,selected:ct}),[a,ct]),$e=_.useMemo(()=>{const Xe=T.trim().toLowerCase();return[...Xe?Se.filter(Ke=>{var Ct;return Ke.name.toLowerCase().includes(Xe)||(((Ct=Ke.description)==null?void 0:Ct.toLowerCase().includes(Xe))??!1)}):Se].sort((Ke,Ct)=>Number(sC(Ke))-Number(sC(Ct)))},[Se,T]),St=_.useMemo(()=>{const Xe=T.trim().toLowerCase();return Xe?o.filter(tn=>{var Ke,Ct;return tn.name.toLowerCase().includes(Xe)||(((Ke=rN(tn))==null?void 0:Ke.toLowerCase().includes(Xe))??!1)||(((Ct=tn.description)==null?void 0:Ct.toLowerCase().includes(Xe))??!1)}):o},[o,T]),tt=_.useMemo(()=>$e.filter(Xe=>R.has(Xe.id)),[$e,R]),bt=_.useMemo(()=>$e.filter(Xe=>!R.has(Xe.id)),[$e,R]),At=_.useMemo(()=>St.filter(Xe=>O.has(Aa(Xe.id))),[St,O]),Et=_.useMemo(()=>St.filter(Xe=>!O.has(Aa(Xe.id))),[St,O]),Jt=Xe=>{D(tn=>tn.some(Ke=>Ke.id===Xe.id)?tn.filter(Ke=>Ke.id!==Xe.id):[...tn,{id:Xe.id,name:Xe.name}]),$.current=!0,ve()},hn=()=>{if(!ue||g==null)return;const Xe=!he,tn={...g,config:{...g.config,webSearch:{enabled:Xe}}};v==null||v({config:tn.config}),f==null||f.rememberDraftSpec(tn,"chat")},Tt=()=>{if(g==null)return;const Xe={...g,config:{...g.config,trueforge:{enabled:!te}}};v==null||v({config:Xe.config}),f==null||f.rememberDraftSpec(Xe,"chat")},Ut=(Xe,tn)=>{const Ke=T.trim().toLowerCase();return Ke?Xe.toLowerCase().includes(Ke)||tn.toLowerCase().includes(Ke):!0},en=Ut(f$,Yxe),xt=Ut(h$,Zxe),Ht=Xe=>{var Ct;const tn=Aa(Xe.id),Ke=!V.current.some(kr=>Aa(kr.id)===tn);L(kr=>kr.some(vi=>Aa(vi.id)===tn)?kr.filter(vi=>Aa(vi.id)!==tn):[...kr,{id:Xe.id,name:Xe.name}]),Ke&&(u==null?void 0:u.sandbox.enabled)===!0&&(v==null||v({config:{...g==null?void 0:g.config,sandbox:{...(Ct=g==null?void 0:g.config)==null?void 0:Ct.sandbox,enabled:!0}}})),$.current=!0,ve()},jn=Xe=>{const tn=De.find(Ct=>Aa(Ct.id)===Aa(Xe.id)),Ke=rN(Xe);return h.jsx(xg,{title:Xe.name,description:Xe.description,badge:Ke===void 0?void 0:h.jsx("span",{className:"bg-primary-button-bg/10 text-primary-button-bg shrink-0 rounded-full px-1.5 py-0.5 text-[0.625rem]",children:Ke}),checked:tn!==void 0,disabled:W&&tn===void 0,onToggle:()=>Ht(Xe)},Xe.id)},{environments:Vt,defaultEnvironment:eo,loading:Qa,refetch:_r}=oze(),Vn=Xe=>{const tn=E==="environments";if(w){tn&&_r();return}D(Ze),L(Qe),$.current=!1,Re(),N(new Set(Ze.map(Ke=>Ke.id))),P(new Set(Qe.map(Ke=>Aa(Ke.id)))),S(!0),tn&&_r()},So=Xe=>{je(!1),C(""),f==null||f.setSettingsOpen(!0,Xe)},Sr=Jke((Wu=g==null?void 0:g.config)==null?void 0:Wu.sandbox)??(eo==null?void 0:eo.name),Fi=_.useMemo(()=>{const Xe=Vt.map(Ke=>{const Ct=rze(Ke);return{value:Ke.name,title:Ke.name,description:Ke.manifest.description,...Ct===void 0?{}:{unavailable:Ct}}});Sr!==void 0&&!Xe.some(Ke=>Ke.value===Sr)&&Xe.unshift({value:Sr,title:Sr,description:void 0,unavailable:"No longer available."});const tn=T.trim().toLowerCase();return tn?Xe.filter(Ke=>{var Ct;return Ke.title.toLowerCase().includes(tn)||(((Ct=Ke.description)==null?void 0:Ct.toLowerCase().includes(tn))??!1)}):Xe},[Vt,T,Sr]),qs=Xe=>{var tn;y||v==null||v({config:{...g==null?void 0:g.config,sandbox:{...D9((tn=g==null?void 0:g.config)==null?void 0:tn.sandbox,Xe),enabled:!0}}})},Sn=h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"flex shrink-0 border-b border-border",children:ze.map(Xe=>{const tn=Xe.id==="connectors"?ct.length:Xe.id==="skills"?De.length:null,Ke=E===Xe.id;return h.jsxs("button",{type:"button",className:pe("text-text-secondary flex flex-1 items-center justify-center gap-1.5 px-2 py-2.5 text-xs font-medium",Ke&&"text-primary-button-bg border-b-2 border-primary-button-bg"),onClick:()=>{A(Xe.id),C(""),Xe.id==="environments"&&_r()},children:[h.jsx(be,{name:Xe.icon,className:"size-3.5"}),Xe.label,tn!=null&&tn>0?h.jsx("span",{className:"bg-secondary-bg rounded px-1 text-[0.625rem]",children:tn}):null]},Xe.id)})}),h.jsxs(h.Fragment,{children:[h.jsx(Nnn,{value:T,onChange:C,placeholder:E==="connectors"?"Search connectors...":E==="skills"?"Search skills...":"Search environment..."}),E==="skills"&&W&&Y?h.jsx(lC,{children:Y}):null,h.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 pb-2",children:E==="connectors"?h.jsxs(h.Fragment,{children:[xt||en?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Built-in"}),xt?h.jsx(xg,{title:h$,description:Zxe,fallbackIcon:"bot",checked:te,onToggle:Tt}):null,en?h.jsxs(h.Fragment,{children:[h.jsx(xg,{title:f$,description:Yxe,fallbackIcon:"searchGlobe",checked:he,disabled:!ue,disabledReason:ne,onToggle:hn}),ue?null:h.jsx(lC,{children:ne}),ie?h.jsx(lC,{icon:"info",children:ize}):null]}):null]}):null,tt.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Selected",count:tt.length}),tt.map(Xe=>h.jsx(xg,{title:Xe.name,logo:i[Xe.name],fallbackIcon:"mcp-server",checked:Ye.has(Xe.id),action:sC(Xe)?h.jsx(sB,{connector:Xe,onConnected:c}):void 0,onToggle:()=>Jt(Xe)},Xe.id))]}):null,bt.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Available",count:bt.length}),bt.map(Xe=>h.jsx(xg,{title:Xe.name,logo:i[Xe.name],fallbackIcon:"mcp-server",checked:Ye.has(Xe.id),action:sC(Xe)?h.jsx(sB,{connector:Xe,onConnected:c}):void 0,onToggle:()=>Jt(Xe)},Xe.id))]}):null,$e.length===0&&a.length>0&&!en?h.jsx(__,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors"}):null,a.length===0?h.jsx(__,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors",onOpenSettings:f&&Ae?()=>So("connectors"):void 0}):null]}):E==="skills"?h.jsxs(h.Fragment,{children:[At.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Selected",count:At.length}),At.map(jn)]}):null,Et.length>0?h.jsxs(h.Fragment,{children:[h.jsx(Zw,{label:"Available",count:Et.length}),Et.map(jn)]}):null,St.length===0?h.jsx(__,{loading:s,emptyLabel:"No skills",settingsTarget:re?"a Sandbox":"Skills",onOpenSettings:o.length===0&&f&&(re?qe:Me)?()=>So(re?"sandbox":"skills"):void 0}):null]}):h.jsxs(h.Fragment,{children:[y?h.jsx(lC,{children:Kxe}):null,Fi.map(Xe=>{const tn=Sr===Xe.value,Ke=y?Kxe:Xe.unavailable;return h.jsx(xg,{title:Xe.title,description:Xe.description,fallbackIcon:"monitor",selectionControl:"radio",checked:tn,disabled:Ke!==void 0,...Ke===void 0?{}:{disabledReason:Ke},onToggle:()=>qs(Xe.value)},Xe.value)}),Fi.length===0?h.jsx(__,{loading:Qa,emptyLabel:"No environments",settingsTarget:"Environments",onOpenSettings:f?()=>{je(!1),f.setEnvironmentsOpen(!0)}:void 0}):null]})})]})]}),ur=[...yt?[{id:"tools",label:`Tools (${gt})`,icon:"wrench",onSelect:()=>Vn()}]:[],...n===void 0?[]:[{id:"attach",label:"Attach a file",icon:"paperclip",onSelect:n}]];return h.jsxs("div",{ref:G,className:"relative flex flex-wrap items-center",children:[J?h.jsx(r,{actions:ur,disabled:e||t}):yt?h.jsx(sr,{content:Nt,className:"max-w-xs whitespace-pre-line text-left",side:"top",children:h.jsxs("button",{type:"button",disabled:e||t,"aria-label":`Tools (${gt})`,"aria-haspopup":"dialog","aria-expanded":w,"aria-controls":w?F:void 0,className:rn({variant:"ghost",size:"large",className:"gap-1.5 px-2 text-xs"}),onClick:()=>{if(w){je(!1);return}Vn()},children:[h.jsx(be,{name:"wrench"}),h.jsx("span",{children:"Tools"}),h.jsx("span",{className:"rounded bg-primary-button-bg/10 px-1.5 py-0.5 text-[0.625rem] font-semibold text-primary-button-bg",children:gt})]})}):null,!J&&n?h.jsx(sr,{content:"Attach a file",children:h.jsx("button",{type:"button",disabled:e||t,"aria-label":"Attach a file",className:rn({variant:"ghost",size:"icon"}),onClick:n,children:h.jsx(be,{name:"paperclip"})})}):null,w&&yt?Z||J?h.jsx(I3,{id:F,open:!0,onOpenChange:je,"aria-label":"Add to composer",children:Sn}):h.jsx("div",{id:F,role:"dialog","aria-label":"Add to composer",className:"aui-popup-enter bg-card-bg text-text-primary absolute bottom-full left-0 z-50 mb-2 flex h-[22rem] w-[28rem] max-w-[min(28rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-lg border border-border shadow-lg",children:Sn}):null]})}function Onn({disabled:e,isRunning:t}){var z,L,$,U,B;const{models:n,loading:r,loaded:o,ensureLoaded:a}=JN(),{agentSpec:i}=Bu(),s=qk(),l=KN(),c=th(),u=go(),d=us(),[f,g]=_.useState(!1),[b,v]=_.useState(""),y=_.useRef(null),w=_.useId(),S=km(),E=pp(),A=XN({catalog:l,capabilities:c}),T=o&&n.length===0&&A&&u!=null,C=_.useRef(null);_.useEffect(()=>{a()},[a]),_.useEffect(()=>{var Z,J,W;if(!s||r||n.length===0)return;const V=n[0];if(V===void 0)return;const G=V.name,F=((J=(Z=i==null?void 0:i.model)==null?void 0:Z.name)==null?void 0:J.trim())??"";if(F&&n.some(q=>q.name===F)){C.current=null;return}C.current!==G&&(C.current=G,s({model:v0(G,(W=i==null?void 0:i.model)==null?void 0:W.params,V.properties.reasoningEfforts)}))},[s,r,n,(z=i==null?void 0:i.model)==null?void 0:z.name,(L=i==null?void 0:i.model)==null?void 0:L.params]);const R=(($=i==null?void 0:i.model)==null?void 0:$.name)??((U=n[0])==null?void 0:U.name)??"",N=n.find(V=>V.name===R),O=(B=N==null?void 0:N.warning)==null?void 0:B.trim(),P=N?nN(N.name):R?nN(R):r?"Loading…":"Select model";if(_.useEffect(()=>{if(!f)return;const V=G=>{y.current&&!y.current.contains(G.target)&&g(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[f]),T)return h.jsx(Tn.Ghost,{type:"button",size:"small",disabled:e||t,"aria-label":"Configure model",className:"h-8 max-w-48 rounded-full px-2 text-xs font-medium",onClick:()=>{u!=null&&u.settingsOpen||d(io.Settings.OPENED),u==null||u.setSettingsOpen(!0,"models")},children:"Configure model"});const j=(N==null?void 0:N.provider.name)??R,D=h.jsx(aB,{models:n,loading:r,selectedName:R,query:b,onQueryChange:v,listboxId:w,onSelect:V=>{var G;s==null||s({model:v0(V.name,(G=i==null?void 0:i.model)==null?void 0:G.params,V.properties.reasoningEfforts)}),g(!1),v("")}});return h.jsxs("div",{ref:y,className:"relative flex min-w-0 items-center gap-1",children:[h.jsx(sr,{content:R||"Select model",className:"max-w-xs whitespace-normal break-all",children:h.jsxs("button",{type:"button",disabled:e||t,"aria-haspopup":"listbox","aria-expanded":f,"aria-controls":f?w:void 0,"aria-label":"Select model",className:rn({variant:"ghost",size:"small",className:pe("h-8 max-w-48 gap-1.5 rounded-full px-2 text-xs font-medium","hover:bg-ghost-button-hover")}),onClick:()=>g(V=>!V),children:[h.jsx(N3,{logo:N==null?void 0:N.provider.logo,label:j,className:"size-4 text-xs"}),h.jsx("span",{className:"truncate",children:P}),h.jsx(be,{name:"chevron-down",className:"size-3.5 shrink-0 opacity-60"})]})}),O?h.jsx(q6e,{warning:O,side:"bottom"}):null,f?S||E?h.jsx(I3,{open:!0,onOpenChange:g,"aria-label":"Select model",children:D}):h.jsx("div",{className:"aui-popup-enter bg-card-bg text-text-primary absolute right-0 bottom-full z-50 mb-2 flex max-h-[22rem] w-[18rem] flex-col overflow-hidden rounded-lg border border-border shadow-lg",children:D}):null]})}function Pnn({open:e,value:t,onChange:n,onClose:r}){const o=Ge("InstructionsMarkdownEditor");return h.jsx(vx,{open:e,onOpenChange:a=>!a&&r(),"aria-label":"Edit instructions full screen",className:"h-[calc(100dvh-2rem)] max-h-none w-[calc(100vw-2rem)] max-w-none",children:e?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"border-border flex items-center justify-between gap-3 border-b px-4 py-2",children:[h.jsx("h2",{className:"text-text-primary text-sm font-semibold",children:"Agent instructions"}),h.jsx("button",{type:"button","aria-label":"Exit full screen",title:"Exit full screen",className:rn({variant:"ghost",size:"icon",className:"size-7"}),onClick:r,children:h.jsx(be,{name:"compress",className:"size-4"})})]}),h.jsx("div",{className:"min-h-0 flex-1",children:h.jsx(o,{value:t,onChange:n,height:"100%"})})]}):null})}var jnn=/^(#{1,6})\s/,Dnn=/^\s*(```|~~~)/;function Lnn(e){const t=[],n=[];let r=null,o="";const a=({level:i,endLine:s})=>{var l;for(let c=n.at(-1);c!==void 0&&c.level>=i;c=n.at(-1)){n.pop();let u=s;for(;u>c.start&&((l=e[u-1])==null?void 0:l.trim())==="";)u-=1;u>c.start&&t.push({start:c.start,end:u})}};return e.forEach((i,s)=>{var f;const l=s+1,c=Dnn.exec(i);if(r!==null){c!==null&&c[1]===o&&(l>r&&t.push({start:r,end:l}),r=null);return}if(c!==null){r=l,o=c[1]??"";return}const u=jnn.exec(i);if(u===null)return;const d=((f=u[1])==null?void 0:f.length)??1;a({level:d,endLine:l-1}),n.push({level:d,start:l})}),a({level:0,endLine:e.length}),t}function znn(e){if(typeof e!="object"||e===null||!("languages"in e))return!1;const{languages:t}=e;return typeof t=="object"&&t!==null&&"registerFoldingRangeProvider"in t&&typeof t.registerFoldingRangeProvider=="function"}var Xxe=!1;function $nn(e){Xxe||!znn(e)||(Xxe=!0,e.languages.registerFoldingRangeProvider("markdown",{provideFoldingRanges(t){const n=Array.from({length:t.getLineCount()},(r,o)=>t.getLineContent(o+1));return Lnn(n)}}))}var Unn={lineNumbers:"on",renderFinalNewline:"on",guides:{indentation:!1},folding:!0,showFoldingControls:"always",renderLineHighlight:"line",fontSize:13,lineHeight:20,padding:{top:8,bottom:8}};function Fnn({value:e,onChange:t,height:n}){const r=Ge("MonacoEditorCore");return h.jsx(r,{value:e,language:"markdown",options:Unn,beforeMount:$nn,onChange:t,height:n})}function Bnn({className:e,compact:t=!1}){const n=go(),r=zH(),o=th(),a=us(),i=$H({sandboxEnvironments:r,capabilities:o})&&n!=null,s=(n==null?void 0:n.environmentsOpen)===!0;return i?h.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:h.jsxs("button",{type:"button","aria-label":t?"Environments":void 0,title:t?"Environments":void 0,"aria-current":s?"page":void 0,className:rn({variant:"ghost",className:pe(fk,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?QN:"h-8 w-full !justify-start px-2.5 text-sm",s&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{s||a(io.Environment.PAGE_OPENED),n.setEnvironmentsOpen(!s)},children:[h.jsx(be,{name:"monitor",size:t?14:void 0}),t?h.jsx("span",{className:"text-center",children:"Environments"}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"truncate",children:"Environments"}),h.jsx(be,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}var Hnn=288,Vnn=.75,Gnn=.42;function pze({requested:e,rowWidth:t}){if(t<=0)return e;const n=Math.min(Hnn,t*.3),r=Math.max(n,t*Vnn);return Math.min(r,Math.max(n,e))}function wyn(e){return pze({requested:e*Gnn,rowWidth:e})}function Wnn({name:e,view:t}){const n=Ge("SyntaxHighlighter"),r=Ge("Markdown");return t.status==="loading"?h.jsx("div",{className:"flex h-full items-center justify-center text-text-secondary",children:h.jsx(Al,{size:20})}):t.status==="error"||t.status==="unavailable"?h.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-text-secondary",children:t.message}):t.status==="media"?t.media==="image"?h.jsx("div",{className:"flex h-full items-center justify-center p-4",children:h.jsx("img",{src:t.objectUrl,alt:e,className:"max-h-full max-w-full object-contain"})}):h.jsx("iframe",{title:e,src:t.objectUrl,className:"absolute inset-0 h-full w-full border-0"}):t.status==="html"?h.jsx("iframe",{title:e,sandbox:"allow-scripts allow-forms",referrerPolicy:"no-referrer",srcDoc:t.text,className:"absolute inset-0 h-full w-full border-0 bg-white"}):t.status==="markdown"?h.jsx("div",{className:"px-4 py-3",children:h.jsx(r,{content:t.text})}):t.language!=null&&t.text.length<=Cen?h.jsx(n,{code:t.text,language:t.language,showLineNumbers:!0,className:"my-0 h-full rounded-none"}):h.jsx("pre",{className:"m-0 min-h-full whitespace-pre-wrap break-words p-4 font-mono text-sm text-text-primary",children:t.text})}function qxe(e,t,n){var o;const r=((o=e.parentElement)==null?void 0:o.getBoundingClientRect().width)??0;n(pze({requested:t,rowWidth:r}))}function Knn({name:e,placement:t,view:n,onClose:r,onDownload:o,onEnterFullPage:a,onExitFullPage:i,onRetry:s,downloadBusy:l=!1,widthPx:c,onWidthChange:u}){const d=_.useRef(null),f=t==="side"&&u!=null;_.useEffect(()=>{var v;(v=d.current)==null||v.focus()},[e,t]);const g=v=>{if(u==null)return;v.preventDefault();const y=v.currentTarget,w=d.current;if(w==null)return;typeof y.setPointerCapture=="function"&&y.setPointerCapture(v.pointerId);const S=v.clientX,E=w.getBoundingClientRect().width,A=C=>{qxe(w,E+(S-C.clientX),u)},T=C=>{typeof y.hasPointerCapture=="function"&&y.hasPointerCapture(C.pointerId)&&y.releasePointerCapture(C.pointerId),y.removeEventListener("pointermove",A),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T)};y.addEventListener("pointermove",A),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T)};return h.jsxs("aside",{ref:d,tabIndex:-1,"data-slot":"aui_file-preview","data-placement":t,"aria-label":`Preview of ${e}`,onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),t==="full"&&i!=null?i():r())},style:t==="side"&&c!=null?{width:`${c}px`}:void 0,className:pe("aui-file-preview relative flex min-h-0 min-w-0 flex-col bg-primary-bg outline-none",t==="overlay"&&"absolute inset-0 z-30",t==="full"&&"absolute inset-0 z-30",t==="side"&&"h-full shrink-0 border-l border-border",t==="side"&&c==null&&"w-1/2 max-w-[42rem]"),children:[f?h.jsxs("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize preview",...c!=null?{"aria-valuenow":Math.round(c)}:{},tabIndex:0,title:"Drag to resize",onPointerDown:g,onKeyDown:v=>{if(u==null||d.current==null)return;const y=v.shiftKey?48:16;if(v.key!=="ArrowLeft"&&v.key!=="ArrowRight")return;v.preventDefault(),v.stopPropagation();const w=d.current.getBoundingClientRect().width,S=v.key==="ArrowLeft"?y:-y;qxe(d.current,w+S,u)},className:"group/resizer absolute inset-y-0 -left-2 z-20 flex w-4 cursor-col-resize touch-none items-center justify-center focus-visible:outline-none",children:[h.jsx("div",{"aria-hidden":!0,className:"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border group-hover/resizer:bg-primary-button-bg"}),h.jsx("div",{"aria-hidden":!0,className:pe("relative flex h-10 w-3.5 items-center justify-center rounded-full border border-border shadow-sm","bg-primary-bg text-text-secondary","group-hover/resizer:border-primary-button-bg group-hover/resizer:bg-primary-button-bg group-hover/resizer:text-primary-button-text","group-focus-visible/resizer:border-primary-button-bg group-focus-visible/resizer:bg-primary-button-bg group-focus-visible/resizer:text-primary-button-text"),children:h.jsx(be,{name:"grip-vertical",size:12})})]}):null,h.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border px-3",children:[h.jsx(be,{name:"file",size:16,className:"shrink-0 text-text-secondary"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-text-primary",children:e}),n.status==="error"&&s!=null?h.jsx("button",{type:"button",onClick:s,className:rn({variant:"ghost",size:"small"}),children:"Retry"}):null,t==="full"&&i!=null?h.jsx("button",{type:"button",onClick:i,"aria-label":"Exit full page",title:"Exit full page",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"compress",size:14})}):null,t!=="full"&&a!=null?h.jsx("button",{type:"button",onClick:a,"aria-label":"Full page",title:"Full page",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"expand",size:14})}):null,h.jsx("button",{type:"button",onClick:o,disabled:l,"aria-busy":l||void 0,"aria-label":l?`Downloading ${e}`:`Download ${e}`,title:"Download",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:l?h.jsx(Al,{size:14}):h.jsx(be,{name:"download",size:14})}),h.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",title:"Close preview",className:rn({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:h.jsx(be,{name:"xmark",size:14})})]}),h.jsx("div",{className:pe("relative h-full min-h-0 flex-1",n.status==="html"||n.status==="media"&&n.media==="pdf"?"overflow-hidden":"overflow-auto"),children:h.jsx(Wnn,{name:e,view:n})})]})}var fze=_.forwardRef(({className:e,isLoading:t=!1,...n},r)=>h.jsx("div",{ref:r,"data-slot":"aui_history-loader",role:"status","aria-live":"polite","aria-label":t?"Loading older messages":"Scroll up to load older messages",className:pe("flex justify-center py-2",e),...n,children:t&&h.jsx(Al,{size:14})}));fze.displayName="HistoryLoader";var hze="aui-trusted-external-hosts";function oN(){return{version:1,links:[],images:[]}}function Qxe(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Ynn(e){if(e==null||typeof e!="object"||!("version"in e)||e.version!==1)return oN();const t="links"in e&&Qxe(e.links)?e.links:[],n="images"in e&&Qxe(e.images)?e.images:[];return{version:1,links:t,images:n}}function gze(){if(typeof window>"u")return oN();try{const e=JSON.parse(window.localStorage.getItem(hze)??"null");return Ynn(e)}catch{return oN()}}function Znn(e){if(!(typeof window>"u"))try{window.localStorage.setItem(hze,JSON.stringify(e))}catch{}}function mze(e){try{const t=typeof window<"u"?window.location.href:"http://localhost";return new URL(e,t)}catch{return null}}function XS(e){const t=mze(e);return t==null||t.protocol!=="http:"&&t.protocol!=="https:"?null:t.hostname.toLowerCase()}function lB(e){const t=XS(e);return t==null?!1:typeof window>"u"?!0:t!==window.location.hostname.toLowerCase()}function bze({kind:e,host:t}){const n=t.toLowerCase();return gze()[e].includes(n)}function Jxe({kind:e,host:t}){const n=t.toLowerCase(),r=gze();r[e].includes(n)||Znn({...r,[e]:[...r[e],n]})}function vze(e){const t=mze(e);t!=null&&(t.protocol!=="http:"&&t.protocol!=="https:"||window.open(t.href,"_blank","noopener,noreferrer"))}var yze=_.createContext(null);function xze(){const e=_.useContext(yze);if(e==null)throw new Error("Markdown external URL confirm requires ExternalUrlConfirmProvider");return e}function ewe(e){try{const t=new URL(e,typeof window<"u"?window.location.href:"http://localhost").protocol;return t==="javascript:"||t==="data:"||t==="vbscript:"}catch{return!0}}function Xnn({children:e}){const[t,n]=_.useState(null),[r,o]=_.useState(!1),[a,i]=_.useState(()=>new Set),s=_.useCallback(S=>{o(!1),n({kind:"link",url:S})},[]),l=_.useCallback(S=>{o(!1),n({kind:"image",url:S})},[]),c=_.useCallback(S=>a.has(S.toLowerCase()),[a]),u=_.useCallback(()=>{n(null),o(!1)},[]),d=_.useCallback(()=>{if(t==null)return;const S=XS(t.url);if(t.kind==="link"){r&&S!=null&&Jxe({kind:"links",host:S}),vze(t.url),u();return}S!=null&&(r&&Jxe({kind:"images",host:S}),i(E=>{const A=new Set(E);return A.add(S.toLowerCase()),A})),u()},[u,r,t]),f=_.useMemo(()=>({requestLinkConfirm:s,requestImageConfirm:l,isSessionImageHostTrusted:c}),[c,l,s]),g=t!=null?XS(t.url):null,b=(t==null?void 0:t.kind)==="image"?"Show external image":"Open external link",v=(t==null?void 0:t.kind)==="image"?"You're about to load an image from an external site:":"You're leaving this app to visit an external link:",y=(t==null?void 0:t.kind)==="image"?"Show image":"Open link",w=g==null?null:(t==null?void 0:t.kind)==="image"?`Don't ask again for images from ${g}`:`Don't ask again for links to ${g}`;return h.jsxs(yze.Provider,{value:f,children:[e,h.jsxs(vx,{open:t!=null,onOpenChange:S=>{S||u()},"aria-label":b,className:"max-w-md",children:[h.jsxs(tE,{children:[h.jsxs(S3,{children:[h.jsx(k3,{children:b}),h.jsx("p",{className:"text-sm text-text-secondary",children:v})]}),t!=null?h.jsx("div",{className:"max-h-24 overflow-auto break-all rounded-md bg-secondary-bg px-3 py-2 font-mono text-sm text-text-primary","data-testid":"aui-external-url-confirm-url",children:t.url}):null,w!=null?h.jsxs("button",{type:"button",role:"checkbox","aria-checked":r,className:"flex items-start gap-2 text-left text-sm text-text-secondary",onClick:()=>o(S=>!S),children:[h.jsx(ZJ,{checked:r,className:"mt-0.5"}),h.jsx("span",{children:w})]}):null]}),h.jsxs(zJ,{children:[h.jsx(Tn.Secondary,{type:"button",onClick:u,children:"Cancel"}),h.jsx(Tn.Primary,{type:"button",onClick:d,children:y})]})]})]})}function qnn({href:e,children:t,node:n,...r}){const{requestLinkConfirm:o}=xze(),a=e!=null&&e!==""&&ewe(e),i=e!=null&&e!==""&&!a&&lB(e),s=a?void 0:e,l=c=>{if(e==null||e==="")return;if(ewe(e)){c.preventDefault();return}if(!lB(e))return;c.preventDefault();const u=XS(e);if(u!=null&&bze({kind:"links",host:u})){vze(e);return}o(e)};return h.jsx("a",{...r,href:s,target:i||a?"_blank":r.target,rel:"noopener noreferrer",onClick:l,onAuxClick:l,children:t})}function Qnn({src:e,alt:t,node:n,...r}){const{requestImageConfirm:o,isSessionImageHostTrusted:a}=xze(),i=typeof e=="string"?e:"",s=i!==""?XS(i):null;return!(i!==""&&lB(i))||s!=null&&(bze({kind:"images",host:s})||a(s))?h.jsx("img",{...r,src:e,alt:t??""}):h.jsxs("span",{className:pe("my-2 flex max-w-full flex-col gap-2 rounded-md border border-border bg-secondary-bg p-3"),"data-testid":"aui-external-image-placeholder",children:[h.jsx("span",{className:"text-sm text-text-secondary",children:t!=null&&t!==""?t:"External image"}),h.jsx("span",{className:"max-h-16 overflow-auto break-all font-mono text-xs text-text-secondary",children:i}),h.jsx(Tn.Secondary,{type:"button",size:"small",className:"self-start",onClick:()=>{i!==""&&o(i)},children:"Show image"})]})}function _yn(){return Ya(()=>Promise.resolve().then(()=>ivn),void 0,import.meta.url)}var Jnn=8*1024;function ern(e){const t=/^(`{3,})([^\n]*)\n?/gm,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({after:r.index+r[0].length});if(n.length%2===0)return null;const o=n[n.length-1];return o==null?null:e.slice(o.after).replace(/\n$/,"")}function trn(e){const{isStreaming:t,getActiveFenceCode:n,darkTheme:r,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s,OpenUiFenceBlock:l,SandboxArtifactDownload:c,SyntaxHighlighter:u,inlineCodeClassName:d}=e;return{a:qnn,img:Qnn,pre({children:f}){return h.jsx(h.Fragment,{children:f})},code({className:f,children:g}){var S;const b=(S=/language-(\w+)/.exec(f??""))==null?void 0:S[1],v=String(g??"").replace(/\n$/,"");if(!f)return h.jsx("code",{className:pe("aui-inline-code rounded bg-secondary-bg px-1 py-0.5 font-mono text-sm",d),children:g});if(b==="openui")return h.jsx(l,{content:v,isStreaming:t,darkTheme:r});if(b==="sandbox_artifacts")return h.jsx(c,{code:v,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s});const y=n();return t===!0&&y!=null&&v===y&&v.length>Jnn?h.jsx("pre",{className:pe("aui-syntax-highlighter my-2 max-w-full min-w-0 overflow-x-auto whitespace-pre-wrap break-words rounded-md"),"data-testid":"aui-plain-streaming-fence",children:h.jsx("code",{className:pe(f,"whitespace-pre-wrap break-words"),children:v})}):h.jsx(u,{code:v,language:b,darkTheme:r})}}}var nrn=[JXt];function wze({content:e,isStreaming:t,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,className:i}){const s=O3(),l=qN(),c=s==="dark",u=Ge("OpenUiFenceBlock"),d=Ge("SandboxArtifactDownload"),f=Ge("SyntaxHighlighter"),g=_.useRef(null);g.current=t===!0?ern(e):null;const b=_.useMemo(()=>trn({isStreaming:t,getActiveFenceCode:()=>g.current,darkTheme:c,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,OpenUiFenceBlock:u,SandboxArtifactDownload:d,SyntaxHighlighter:f,inlineCodeClassName:l.inlineCode}),[t,c,n,r,o,a,u,d,f,l.inlineCode]);return h.jsx(Xnn,{children:h.jsx("div",{className:pe("aui-markdown markdown-body min-w-0 max-w-full overflow-x-clip",l.markdown,i),children:h.jsx(vMe,{remarkPlugins:nrn,components:b,children:e})})})}var rrn="h-6 w-6 text-text-secondary hover:text-text-primary [&_svg]:size-3.5";function _ze({isCopied:e,onCopy:t,createdAt:n,className:r}){const o=Ge("MessageTimestamp");return h.jsxs("div",{className:pe("aui-assistant-action-bar-root animate-in fade-in flex items-center gap-1 duration-200",r),children:[h.jsx(o,{createdAt:n,className:"mr-1"}),h.jsx(Bf,{"aria-label":"Copy",tooltip:"Copy",variant:"ghost",className:rrn,onClick:t,children:h.jsx(be,{name:e?"check":"clone",size:"0.875em"})})]})}function orn({message:e,className:t}){return h.jsxs("div",{role:"status",className:pe("aui-message-cancelled-root border-warning-bg bg-warning-bg/10 text-warning-bg mt-2 inline-flex w-fit max-w-full items-center gap-3 rounded-xl border px-3 py-1.5 text-sm font-medium leading-[1.4]",t),children:[h.jsx(be,{name:"circle-exclamation",size:"1rem",className:"text-warning-bg shrink-0","aria-hidden":!0}),h.jsx("span",{className:"aui-message-cancelled-message min-w-0 break-words",children:e})]})}function arn({message:e,className:t}){return h.jsx("div",{role:"alert",className:pe("aui-message-error-root border-failure-bg bg-failure-bg/10 text-failure-bg mt-2 rounded-md border p-3 text-sm",t),children:h.jsx("span",{className:"aui-message-error-message line-clamp-2",children:e})})}function irn({label:e="Working...",className:t}){return h.jsxs("span",{"data-slot":"aui_assistant-message-indicator",role:"status",className:pe("inline-flex items-center gap-1.5 font-sans text-sm text-text-secondary",t),children:[h.jsx(PJ,{state:"listening",size:20,"aria-hidden":!0}),h.jsx("span",{className:"aui-text-shimmer",children:e})]})}function srn(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function lrn(e){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).format(e)}function crn({createdAt:e,className:t}){const n=srn(e);return n==null?null:h.jsx(GS,{title:p6e(n),size:"fit",side:"bottom",children:h.jsx("span",{className:pe("text-xs font-medium cursor-pointer leading-normal shrink-0 text-text-secondary",t),children:lrn(n)})})}var twe;function Sze(){return twe??(twe=Ya(()=>import("./index-D8_qdDll.js").then(e=>e.i),__vite__mapDeps([0,1]),import.meta.url)),twe}var kze="aui-monaco-light",Eze="aui-monaco-dark",fd="#00000000",QJ=18,Tze=8,nwe="10.5rem";function urn(e){const t={"editor.background":fd,"editor.lineHighlightBackground":fd,"editor.lineHighlightBorder":fd,"editorGutter.background":fd,"minimap.background":fd,focusBorder:fd,"scrollbar.shadow":fd,"editorOverviewRuler.border":fd,"editorOverviewRuler.background":fd};e.editor.defineTheme(kze,{base:"vs",inherit:!0,rules:[],colors:t}),e.editor.defineTheme(Eze,{base:"vs-dark",inherit:!0,rules:[],colors:t})}function drn(e,t,n){return e||t||(n==="dark"?Eze:kze)}function g$(e,t){if(e==null)return t;if(typeof e=="number")return e;const n=e.trim();if(n.endsWith("rem")){const o=parseFloat(n),a=typeof document<"u"&&parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Number.isFinite(o)?o*a:t}if(n.endsWith("px")){const o=parseFloat(n);return Number.isFinite(o)?o:t}const r=parseFloat(n);return Number.isFinite(r)?r:t}function prn(e,t,n){const o=Math.max(1,e.split(`
1094
1094
  `).length)*QJ+Tze;return Math.min(n,Math.max(t,o))}var frn={automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,renderFinalNewline:"off",wordWrap:"on",fontSize:12,fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',lineHeight:QJ,padding:{top:4,bottom:4},renderLineHighlight:"none",overviewRulerLanes:0,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,glyphMargin:!1,folding:!0,scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8,useShadows:!1},stickyScroll:{enabled:!1}};function hrn({value:e,language:t="plaintext",theme:n,options:r,onChange:o,onMount:a,beforeMount:i,onAutoHeightChange:s,className:l,height:c=400,autoHeight:u=!1,maxHeight:d=nwe,minHeight:f}){var $,U,B;const g=AEe(),b=qN(),v=_.useRef(null),y=_.useRef(null),w=_.useRef(null),S=_.useRef(null),E=_.useRef(o),A=_.useRef(a),T=_.useRef(i),C=_.useRef(s);E.current=o,A.current=a,T.current=i,C.current=s;const R=g$(f,QJ+Tze),N=g$(d,g$(nwe,168)),O=_.useRef({minPx:R,maxPx:N,autoHeight:u});O.current={minPx:R,maxPx:N,autoHeight:u};const[P,j]=_.useState(()=>u?prn(e,R,N):0),D=drn(n,($=b.monaco)==null?void 0:$.monacoTheme,g),z=()=>{var Y;const V=w.current,G=v.current,{minPx:F,maxPx:Z,autoHeight:J}=O.current;if(!V||!G||!J)return;const W=Math.min(Z,Math.max(F,V.getContentHeight()));j(W),G.style.height=`${W}px`,V.layout(),(Y=C.current)==null||Y.call(C,W)};_.useEffect(()=>{if(!y.current)return;let V=null,G=null,F=null,Z=!1;return Sze().then(J=>{var Y,q;if(Z||!y.current)return;const W=J;S.current=W,urn(W),(Y=T.current)==null||Y.call(T,W),V=W.editor.create(y.current,{value:e,language:t,theme:D,...frn,...r}),w.current=V,G=V.onDidChangeModelContent(()=>{var ne;(ne=E.current)==null||ne.call(E,V.getValue())}),u&&(F=V.onDidContentSizeChange(()=>{z()}),requestAnimationFrame(()=>z())),(q=A.current)==null||q.call(A,V,W)}),()=>{Z=!0,G==null||G.dispose(),F==null||F.dispose(),V==null||V.dispose(),w.current=null,S.current=null}},[]),_.useEffect(()=>{const V=w.current;V&&V.getValue()!==e&&(V.setValue(e),u&&requestAnimationFrame(()=>z()))},[e,u,R,N]),_.useEffect(()=>{u&&requestAnimationFrame(()=>z())},[u,R,N]),_.useEffect(()=>{var V;(V=S.current)==null||V.editor.setTheme(D)},[D]);const L=u?P:c;return h.jsx("div",{ref:v,className:pe("aui-monaco overflow-hidden",(U=b.monaco)==null?void 0:U.root,l),style:{height:L},children:h.jsx("div",{ref:y,className:pe("h-full w-full overflow-hidden",(B=b.monaco)==null?void 0:B.editor)})})}var grn="You do not have permission to perform this action.";function mrn({allowed:e,children:t,deniedMessage:n=grn}){const r=_.cloneElement(t,{disabled:t.props.disabled===!0||!e});return e?r:h.jsx(sr,{content:n,side:"bottom",children:h.jsx("span",{"aria-disabled":"true",className:"inline-flex cursor-not-allowed *:pointer-events-none",children:r})})}function brn(){const e=go(),{agentSpec:t}=Bu(),n=us(),[r,o]=_.useState(!1);return e==null||!pk(e.mode)?null:h.jsxs(h.Fragment,{children:[h.jsxs(Tn.Ghost,{type:"button",title:"Reset playground",onClick:()=>o(!0),children:[h.jsx(be,{name:"rotate-right",size:"0.875rem"}),"Reset"]}),h.jsx(vx,{open:r,onOpenChange:o,"aria-label":"Reset agent config",children:h.jsxs(tE,{children:[h.jsx(S3,{children:h.jsx(k3,{children:"Reset agent config"})}),h.jsx("p",{className:"text-sm text-text-secondary",children:"Instructions, connectors, and skills will be cleared and the chat will restart."}),h.jsxs(zJ,{children:[h.jsx(Tn.Secondary,{type:"button",onClick:()=>o(!1),children:"Cancel"}),h.jsx(Tn.Primary,{type:"button",onClick:()=>{n(io.Config.RESET),e.resetAgentBuilder(t??void 0),o(!1)},children:"Reset"})]})]})})]})}function vrn({className:e}){return h.jsxs("p",{role:"status","aria-live":"polite",className:pe("text-text-secondary flex items-center gap-2 py-2 text-sm leading-snug",e),children:[h.jsx("span",{className:"animate-pulse font-sans","aria-hidden":!0,children:"●"}),"Still generating a response. It'll appear here when ready."]})}var rwe="sandbox_artifacts",cB=new Set(["[","]","(",")","\\"]),yrn=/(?:^|[\\/])\.\.(?:[\\/]|$)/,xrn=4095;function wrn(e){return!(e.length===0||e.length>xrn||e.includes("\0")||yrn.test(e)||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))}function owe(e,t){const n=e.trim(),r=t.trim();return!n||!wrn(r)?null:{name:n,path:r}}function _rn(e,t){let n=t+1,r="",o=!1;for(;n<e.length;){const l=e[n];if(l===`
1095
1095
  `||l==="\r")return null;if(l==="\\"&&cB.has(e[n+1]??"")){r+=e[n+1]??"",n+=2;continue}if(l==="]"){o=!0,n++;break}r+=l,n++}if(!o||e[n]!=="(")return null;n++;let a="",i=0,s=!1;for(;n<e.length;){const l=e[n];if(l===`
1096
1096
  `||l==="\r")return null;if(l==="\\"&&cB.has(e[n+1]??"")){a+=e[n+1]??"",n+=2;continue}if(l==="("){i++,a+=l,n++;continue}if(l===")"){if(i===0){s=!0,n++;break}i--,a+=l,n++;continue}a+=l,n++}return s?{name:r,path:a,end:n}:null}function Srn(e){const t=e.trim(),n=t.startsWith(rwe)?t.slice(rwe.length).trimStart():t,r=[];for(let o=0;o<n.length;o++){if(n[o]==="\\"&&cB.has(n[o+1]??"")){o++;continue}if(n[o]!=="[")continue;const a=_rn(n,o);if(a==null)continue;const i=owe(a.name,a.path);i!=null&&r.push(i),o=a.end-1}return r.length>0?r:n.split(`
@@ -1099,12 +1099,12 @@ ${l.children}`})})]})})]})}),oje=({language:e,codeString:t,theme:n})=>{const[r,o
1099
1099
  ${t}`;try{await navigator.clipboard.writeText(c),s(!0),window.setTimeout(()=>s(!1),1500)}catch{}},[e,t]);return n?h.jsxs("div",{role:"alert",className:pe("font-sans-flex bg-primary-bg text-text-primary pointer-events-auto flex w-full items-start gap-3 rounded-xl border border-border px-4 py-4 shadow-md dark:bg-card-bg","animate-in fade-in-0 slide-in-from-bottom-4",a),children:[h.jsx(be,{name:o==="success"?"circle-check":"circle-exclamation",size:"1.25em",className:pe("shrink-0",o==="success"?"text-success-bg":"text-failure-bg")}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsx("div",{className:pe("text-sm leading-none font-semibold",o==="success"?"text-success-bg":"text-failure-bg"),children:e}),h.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o==="error"?h.jsx("button",{type:"button","aria-label":"Copy",title:"Copy",className:rn({variant:"ghost",size:"icon"}),onClick:l,children:h.jsx(be,{name:i?"check":"clone"})}):null,h.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:rn({variant:"ghost",size:"icon"}),onClick:()=>r(!1),children:h.jsx(be,{name:"xmark"})})]})]}),t?h.jsx("div",{className:"text-text-secondary mt-1 max-h-24 overflow-y-auto text-sm leading-snug break-words whitespace-pre-wrap",children:t}):null]})]}):null}var gon=e=>{if(e!==null)try{if(typeof e.showPopover!="function")return;e.matches(":popover-open")&&e.hidePopover(),e.showPopover()}catch{}};function mon({children:e,duration:t=Number.POSITIVE_INFINITY}){const n=h.jsx("div",{ref:gon,popover:"manual",className:"pointer-events-none fixed inset-auto right-4 bottom-4 z-50 m-0 flex w-[calc(100vw-2rem)] max-w-md flex-col-reverse gap-2 overflow-visible bg-transparent",children:e});if(typeof document>"u")return n;const r=document.querySelectorAll("dialog[open]"),o=r.item(r.length-1);return o===null?n:Ui.createPortal(n,o)}var bon=[{id:"approve",label:"Approve once",variant:"primary"}],von=[{id:"deny",label:"Deny",variant:"secondary",requiresReason:!0}];function yon(e){return e.variant==="destructive"?"destructive":e.variant==="secondary"?"secondary":"primary"}function Oze({toolName:e,approveOptions:t=bon,denyOptions:n=von,onSelect:r,status:o,selectedDenyOption:a,denialReason:i="",showReasonError:s=!1,onDenyOptionChange:l,onDenialReasonChange:c,onReasonSubmit:u,disabled:d=!1,readOnly:f=!1,showLineBelow:g=!1,dataTestPrefix:b,className:v}){var O,P;const y=!!o,w=(o==null?void 0:o.type)==="approved",S=(o==null?void 0:o.type)==="denied",E=d&&!y,A=t[0],T=_.useId(),C=_.useRef(null),R=a==null?void 0:a.id;_.useEffect(()=>{var j;R!=null&&((j=C.current)==null||j.focus())},[R]);const N=w?"Tool Approved":S?"Tool Approval Denied":"Tool Approval Required for";return h.jsxs("div",{className:pe("aui-tool-approval-bar",v),"data-testid":b?`${b}-approval`:void 0,children:[h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("div",{className:pe("flex shrink-0 flex-col items-center",!g&&"pb-1"),children:[h.jsx("div",{className:"min-h-[0.75rem] w-px flex-1 bg-border"}),h.jsx(JLe,{icon:"wrench",variant:"muted",iconSize:"0.875em",className:"my-1"}),g&&h.jsx("div",{className:"min-h-[0.75rem] w-px flex-1 bg-border"})]}),h.jsxs("div",{className:"mt-2 flex flex-1 items-center justify-between",children:[h.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1 font-sans text-xs font-medium leading-4 text-text-primary",children:[N,h.jsx("span",{className:"rounded bg-secondary-bg px-1.5 py-0.5 text-xs text-text-secondary",children:e})]}),y&&h.jsx(be,{name:S?"circle-xmark":"circle-check",size:"0.875em",className:pe("shrink-0",S?"text-failure-bg":"text-success-bg")})]}),!y&&!f&&a&&h.jsx(Tn.Secondary,{size:"small",disabled:E,onClick:()=>l==null?void 0:l(null),children:"Back"})]}),!y&&!f&&!a&&h.jsxs(Ep,{align:"end",trigger:h.jsxs(Tn,{size:"small",variant:A==null?"secondary":yon(A),disabled:E||A==null,children:[h.jsx(be,{name:"check",size:"0.75rem"}),(A==null?void 0:A.label)??"Approve",h.jsx(be,{name:"chevron-down",className:"size-3"})]}),className:"w-max min-w-[16.25rem]",children:[t.map((j,D)=>h.jsxs(pu,{disabled:E,onClick:()=>r(j.id),className:"whitespace-nowrap",children:[h.jsx("span",{className:"w-3 shrink-0",children:D===0?h.jsx(be,{name:"check",size:"0.75rem"}):null}),j.label]},j.id)),t.length>0&&n.length>0?h.jsx(a6e,{}):null,n.map(j=>h.jsxs(pu,{disabled:E,onClick:()=>{j.requiresReason?l==null||l(j.id):r(j.id)},className:"whitespace-nowrap",children:[h.jsx("span",{className:"w-3 shrink-0"}),j.label]},j.id))]})]})]}),!y&&!f&&a&&h.jsxs("div",{className:"flex flex-col gap-1 pl-8 pt-3",children:[(((O=a.confirm)==null?void 0:O.title)||((P=a.confirm)==null?void 0:P.description))&&h.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.confirm.title&&h.jsx("span",{className:"text-xs font-medium text-text-primary",children:a.confirm.title}),a.confirm.description&&h.jsx("span",{className:"text-xs text-text-secondary",children:a.confirm.description})]}),a.grants&&a.grants.length>0&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[h.jsx("span",{className:"text-xs text-text-secondary",children:"Grants:"}),a.grants.map(j=>h.jsx("span",{className:"rounded bg-secondary-bg px-1.5 py-0.5 text-xs text-text-secondary",children:j},j))]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{ref:C,placeholder:"Enter reason for denial","aria-label":"Reason for denial","aria-invalid":s||void 0,"aria-describedby":s?T:void 0,value:i,disabled:E,onChange:j=>c==null?void 0:c(j.target.value),onKeyDown:j=>{j.key==="Enter"&&!j.repeat&&!j.nativeEvent.isComposing&&(j.preventDefault(),u==null||u())},className:pe("h-8 flex-1 rounded border border-input-border bg-primary-bg px-2 text-xs text-text-primary","focus:outline-none focus:ring-1 focus:ring-focus-ring")}),h.jsx(Tn.Primary,{size:"small",disabled:E,onClick:u,children:"Submit"})]}),s&&h.jsx("span",{id:T,className:"text-xs text-failure-bg",role:"alert",children:"Reason is required"})]}),y&&(o==null?void 0:o.reason)&&h.jsx("div",{className:"pl-8 pt-2",children:h.jsxs("span",{className:"text-xs text-text-secondary",children:["Reason: ",o.reason]})})]})}var iE="create_sub_agent",Pze="ask_user_question",eee=new Set(["exec","sandbox_exec"]),tee=new Set(["call_tool","list_tools","get_tool_info","get_tool_output_schema"]);function jze(e){try{return{success:!0,value:JSON.parse(e),isPartial:!1}}catch{const t=e.trim();if(t[0]!=="{"&&t[0]!=="[")return{success:!1};try{return{success:!0,value:Wqt.parse(e),isPartial:!0}}catch{return{success:!1}}}}function uB(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function xon(e){if(!e)return{};try{const t=JSON.parse(e);if(t==null||typeof t!="object"||Array.isArray(t))return{};const n=t,r=typeof n.question=="string"?n.question:void 0,o=Array.isArray(n.options)?n.options.filter(a=>typeof a=="string"):void 0;return{question:r,options:o}}catch{return{}}}function won(e){if(e!=null){if(typeof e=="string"){const t=e.trim();return t.length>0?t:void 0}if(typeof e=="object"&&"content"in e){const t=e.content;if(typeof t=="string"&&t.trim())return t.trim()}}}function Dze(e){return e!=null&&e.approved===void 0&&e.resolution===void 0}function _on(e){if(e<1e3)return"<1s";const t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}s`:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`}function Son(e){return e==="complete"?"success":e==="incomplete"?"error":"running"}function nee(e){if(!e)return{};const t=jze(e);return!t.success||!uB(t.value)?{argsJson:e}:{command:typeof t.value.command=="string"?t.value.command:void 0,intent:typeof t.value.intent=="string"?t.value.intent:void 0,argsJson:t.isPartial?e:JSON.stringify(t.value,null,2)}}function kon(e){if(e===void 0)return{};const t=jze(e);if(!t.success||!uB(t.value))return{resultText:e};const n=uB(t.value.response)?t.value.response:void 0,r=typeof(n==null?void 0:n.exitCode)=="number"?n.exitCode:null,o=typeof(n==null?void 0:n.result)=="string"?n.result:void 0;return{exitCode:r,resultText:o,resultJson:t.isPartial?e:JSON.stringify(t.value,null,2)}}function sE(e){if(!e)return{};try{const t=JSON.parse(e);return{mcpServer:t.mcp_server,innerToolName:t.tool_name,input:t.input}}catch{return{}}}function o1(e){if(!(e!=null&&e.trim()))return{value:"",isJson:!1};const t=e.trim();if(t[0]!=="{"&&t[0]!=="[")return{value:e,isJson:!1};try{const n=JSON.parse(e);return{value:JSON.stringify(n,null,2),isJson:!0}}catch{return{value:e,isJson:!1}}}function lwe(e){var t;try{if(!e)return{isJson:!1,data:""};const n=typeof e=="string"&&e.trim().startsWith("{")?JSON.parse(e):e;if(typeof n=="object"&&n!=null&&Array.isArray(n.content)){const o=((t=n.content[0])==null?void 0:t.text)||"",a=o1(typeof o=="string"?o:JSON.stringify(o));return{data:a.value,isJson:a.isJson}}const r=o1(typeof n=="string"?n:JSON.stringify(n));return{data:r.value,isJson:r.isJson}}catch{return{data:String(e),isJson:!1}}}function Eon(e){var o,a,i,s,l,c,u,d;const t=(a=(o=e.artifact)==null?void 0:o.subAgents)==null?void 0:a[0],n=(i=e.messages)==null?void 0:i[0],r=(l=(s=n==null?void 0:n.metadata)==null?void 0:s.custom)==null?void 0:l.subAgent;return{agentName:(r==null?void 0:r.title)??(r==null?void 0:r.name)??(t==null?void 0:t.title)??((c=t==null?void 0:t.agentInfo)==null?void 0:c.name)??e.toolName,instruction:(r==null?void 0:r.input)??((u=t==null?void 0:t.agentInfo)==null?void 0:u.input)??"",stepCount:((d=e.messages)==null?void 0:d.length)??0}}function Lze(e,t,n){return e==="list_tools"&&t?`list_tools (${t})`:e==="call_tool"&&n?t?`call_tool: ${n} (${t})`:`call_tool: ${n}`:(e==="get_tool_info"||e==="get_tool_output_schema")&&n&&t?`${e}: ${n} (${t})`:e}function Ton(e,t){return(e==null?void 0:e.id)===t&&e.approved===void 0&&e.resolution===void 0}function Aon(e,t){const n=[];function r(o,a){for(const i of o){if(i.type!=="tool-call")continue;if(Ton(i.approval,t))return n.push(...a),!0;const s=i.toolName===iE&&i.toolCallId!=null&&i.toolCallId!==""?[...a,i.toolCallId]:a;if(i.messages!=null){for(const l of i.messages)if(l.role==="assistant"&&r(l.content,s))return!0}}return!1}for(const o of e)if(o.role==="assistant"&&r(o.content,[]))return n;return n}var Con=2e3,Ron=50,Ion=12,zze=_.createContext(null);function kyn({children:e}){const t=_.useRef(new Map),n=_.useRef(new Map),r=_.useRef(null),o=_.useRef(null),[a,i]=_.useState(null),s=Ve(g=>g.thread.messages),l=_.useCallback((g,b)=>(t.current.set(g,b),()=>{t.current.get(g)===b&&t.current.delete(g)}),[]),c=_.useCallback((g,b)=>(n.current.set(g,b),()=>{n.current.get(g)===b&&n.current.delete(g)}),[]),u=_.useCallback(g=>{r.current!=null&&clearTimeout(r.current),i(g),r.current=setTimeout(()=>{i(null),r.current=null},Con)},[]);_.useEffect(()=>()=>{r.current!=null&&clearTimeout(r.current),o.current!=null&&clearInterval(o.current)},[]);const d=_.useCallback(g=>{const b=Aon(s,g);o.current!=null&&(clearInterval(o.current),o.current=null);const v=()=>{var S,E,A;for(const T of b)(S=n.current.get(T))==null||S();const w=((E=t.current.get(g))==null?void 0:E())??null;return w==null?!1:((A=w.scrollIntoView)==null||A.call(w,{block:"center",behavior:"smooth"}),u(g),!0)};if(v())return;let y=0;o.current=setInterval(()=>{y+=1,(v()||y>=Ion)&&o.current!=null&&(clearInterval(o.current),o.current=null)},Ron)},[s,u]),f=_.useMemo(()=>({registerTarget:l,registerExpand:c,focus:d,flashingApprovalId:a}),[l,c,d,a]);return h.jsx(zze.Provider,{value:f,children:e})}function ree(){return _.useContext(zze)}function Non(e,t){const n=ree();_.useEffect(()=>{if(!(n==null||e==null||e===""))return n.registerTarget(e,()=>t.current)},[n,e,t])}function Mon(e,t){const n=ree();_.useEffect(()=>{if(!(n==null||e===""))return n.registerExpand(e,t)},[n,t,e])}var Oon="Awaiting Response...";function $ze({icon:e="mcp-server",iconClassName:t,iconVariant:n,toolName:r,expanded:o=!1,onToggle:a,awaiting:i=!1,awaitingText:s=Oon,status:l,exitCode:c,showExpandChevron:u=!0,showResponseLine:d=!1,approvalSlot:f,approvalId:g,requestSlot:b,responseSlot:v,highlightCard:y=!1,className:w,mcpServerName:S,dataTestPrefix:E}){const A=_.useRef(null),T=ree();Non(g,A);const C=!!f,R=!!b,N=!!v,O=C||R||N,P=u&&(R||N),j=g!=null&&(T==null?void 0:T.flashingApprovalId)===g;let D="idle";l?D=l:i?D="running":c===0?D="success":c!=null?D="error":d&&(D="success");const z=i?s:void 0,L=e==="cube",$=n||(L?"primary":"muted"),U=L?"0.75em":void 0;return h.jsx("div",{ref:A,"data-approval-id":g,className:pe("aui-tool-call-card flex min-w-0 flex-col",g!=null||y?"mx-0 mt-2 rounded-md pt-1.5 pr-2 pb-1":"mx-0 mt-2 p-0",j&&"aui-approval-flash",w),"data-testid":E?`${E}-tool-call-card`:void 0,children:h.jsx(Qk,{icon:e,iconClassName:t,iconVariant:$,iconSize:U,title:r,expandable:P,expanded:o,onToggle:a,status:D,statusText:z,showConnector:O,showContentConnector:!0,showPersistentContentConnector:!C,dataTestPrefix:E?`${E}-header`:void 0,persistentChildren:h.jsxs(h.Fragment,{children:[f,o&&d&&v&&h.jsx("div",{"data-testid":E?`${E}-response`:void 0,children:v})]}),children:b&&h.jsx("div",{className:"py-2 pt-0","data-testid":E?`${E}-request`:void 0,children:b})})})}function cwe({content:e,height:t,autoHeight:n=!1,maxHeight:r,onAutoHeightChange:o}){const a=Ge("MonacoEditorCore");return h.jsx(a,{language:"json",value:e,height:t,autoHeight:n,maxHeight:r,onAutoHeightChange:o,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",folding:!0,fontSize:12},className:"border-0!"})}function Pon({title:e,content:t,isJson:n=!0,copyValue:r,maxHeight:o="10.5rem",resizable:a=!1,fullscreen:i=!1,onFullscreenChange:s,contentHeightRem:l,contentRef:c,onContentHeightChange:u,dataTestPrefix:d,className:f}){const g=Ge("Markdown"),[b,v]=_.useState(!1),y=()=>{const E=r??t;navigator.clipboard.writeText(E).then(()=>{v(!0),setTimeout(()=>v(!1),1500)})},w=a&&l!==void 0,S=a?{...w?{height:`${Math.min(l,10)}rem`}:{},resize:"vertical",padding:"0.25rem"}:{padding:"0.25rem"};return h.jsxs("div",{className:pe("aui-tool-call-content-block flex flex-col font-sans text-xs font-medium leading-4 text-text-primary",f),"data-testid":d?`${d}-content-block`:"tfy-tool-call-content-block","data-content":t,children:[h.jsxs("div",{className:"flex items-center justify-between rounded-t-lg border border-primary-button-bg/30 bg-primary-button-bg/10 px-3 py-1",children:[h.jsx("div",{className:"font-sans text-xs font-medium text-primary-button-bg",children:e}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{type:"button",onClick:y,className:"inline-flex size-6 cursor-pointer items-center justify-center rounded text-text-secondary transition-colors hover:text-text-primary","aria-label":"Copy","data-testid":d?`${d}-copy`:void 0,children:h.jsx(be,{name:b?"check":"clone",size:14})}),h.jsx("button",{type:"button",onClick:()=>s==null?void 0:s(!0),className:"inline-flex size-6 cursor-pointer items-center justify-center rounded text-text-secondary transition-colors hover:text-text-primary","aria-label":"Expand",children:h.jsx(be,{name:"expand-alt",size:14})})]})]}),h.jsx("div",{ref:a?c:void 0,className:pe("relative min-h-7.5 rounded-b-lg border border-t-0 border-border bg-primary-bg",a&&"overflow-hidden"),style:S,children:n?h.jsx(cwe,{content:t,height:w?"100%":void 0,autoHeight:!w,maxHeight:o,onAutoHeightChange:a?u:void 0}):h.jsx("div",{className:pe("overflow-y-auto",w&&"h-full"),style:!w&&o?{maxHeight:o}:void 0,children:h.jsx(g,{content:t,className:"text-xs text-text-secondary"})})}),i&&h.jsx(vx,{open:!0,onOpenChange:E=>s==null?void 0:s(E),children:h.jsxs(tE,{className:"flex h-[80vh] max-w-4xl flex-col",children:[h.jsxs(S3,{className:"flex flex-row items-center justify-between gap-2",children:[h.jsx(k3,{children:e}),h.jsx(Bf,{variant:"ghost",onClick:()=>s==null?void 0:s(!1),"aria-label":"Minimize",children:h.jsx(be,{name:"compress",size:"0.875em"})})]}),h.jsx("div",{className:"min-h-0 flex-1",children:h.jsx(cwe,{content:t,height:"100%"})})]})})]})}function jon({toolCallCount:e,expanded:t,status:n,active:r=!1,onToggle:o,children:a,className:i,dataTestPrefix:s}){const l=Ge("StepTree"),c=`${e} tool calls in parallel`,u=n??(r?"running":"idle");return h.jsxs("div",{"data-slot":"tool-group-card",className:pe("aui-tool-group-card min-w-0",i),"data-testid":s?`${s}-tool-group-card`:void 0,children:[h.jsx(Qk,{icon:"wrench",iconVariant:"muted",title:c,titleClassName:"text-text-secondary",expandable:!0,expanded:t,onToggle:o,status:u,showConnector:!1,dataTestPrefix:s}),t&&h.jsx(l,{className:"mt-1",branchesReachParentIcon:!0,children:a})]})}var b$="h-6 w-6 text-text-secondary hover:text-text-primary [&_svg]:size-3.5";function Don({isCopied:e,editDisabled:t,retryDisabled:n,createdAt:r,onCopy:o,onEdit:a,onRetry:i,className:s}){const l=Ge("MessageTimestamp");return h.jsxs("div",{className:pe("aui-user-action-bar-root animate-in fade-in flex items-center gap-1 duration-200",s),children:[h.jsx(l,{createdAt:r,className:"mr-1"}),h.jsx(Bf,{"aria-label":"Try again",tooltip:"Try again",variant:"ghost",className:b$,disabled:n,onClick:i,children:h.jsx(be,{name:"rotate-right",size:"0.875em"})}),h.jsx(Bf,{"aria-label":"Edit",tooltip:"Edit",variant:"ghost",className:b$,disabled:t,onClick:a,children:h.jsx(be,{name:"pencil",size:"0.875em"})}),h.jsx(Bf,{"aria-label":"Copy",tooltip:"Copy",variant:"ghost",className:b$,onClick:o,children:h.jsx(be,{name:e?"check":"clone",size:"0.875em"})})]})}function Lon({text:e,attachments:t,editAction:n,className:r}){return h.jsxs("div",{"data-slot":"aui_user-message-root",className:pe("group/user-message flex w-full min-w-0 flex-col items-end gap-1",r),children:[t,e.trim().length>0?h.jsx("div",{"data-slot":"aui_user-message-content",style:{borderRadius:"var(--composer-radius, 1.5rem)"},className:"max-w-[min(80%,100%)] min-w-0 bg-user-message-bg px-3 py-2 text-sm text-user-message-text whitespace-pre-wrap break-words sm:px-4 sm:py-2.5",children:e}):null,n&&h.jsx("div",{className:pe("flex max-w-[min(80%,100%)] justify-end transition-opacity","md:opacity-0 md:group-hover/user-message:opacity-100 md:focus-within:opacity-100"),children:n})]})}var zon=_.forwardRef(function({timestamp:t,attachments:n,input:r,footer:o,className:a,...i},s){return h.jsxs("div",{ref:s,"data-slot":"aui_user-message-edit",className:pe("flex flex-col gap-2 w-full",a),...i,children:[(t||n)&&h.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[h.jsx("span",{className:"font-medium text-text-primary",children:"User"}),t]}),n&&h.jsx("div",{className:"flex flex-wrap gap-1",children:n}),h.jsx("div",{className:"w-full",children:r}),h.jsx("div",{children:o})]})});function Uze({heading:e="How can I help you today?",icon:t,className:n}){const r=Zqe(),o=Ge("BrandLogo"),a=t!==void 0?t:r==="chatgpt"?null:r==="claude"?h.jsx(be,{name:"welcome-sparkle",className:"size-5 fill-current text-primary-button-bg"}):h.jsx(o,{variant:"icon",className:"size-10"});return h.jsxs("div",{"data-preset":r,className:pe("aui-thread-welcome-root relative isolate mb-6 flex flex-col items-center px-4 text-center text-text-primary",r==="gemini"&&"py-8",n),children:[r==="gemini"&&h.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-1/2 -z-10 size-64 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-button-bg/20 blur-3xl motion-safe:animate-pulse motion-reduce:animate-none [animation-duration:4s]"}),a!==null&&h.jsx("div",{className:pe("fill-mode-both mb-4 motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-reduce:animate-none",r==="claude"?"duration-300":"duration-200"),children:a}),h.jsx("h1",{className:pe("aui-thread-welcome-message-inner fill-mode-both text-2xl motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-reduce:animate-none",r==="trueforge"?"font-semibold":"font-normal",a!==null&&"delay-75",r==="gemini"?"text-[1.75rem] leading-tight duration-300":"duration-200"),children:e})]})}function $on({agentId:e,timeRange:t,onTimeRangeChange:n,showTimeRangeFilter:r=!0}){const o=gXe(),a=Ge("AgentMetricsView"),[i,s]=_.useState(Zke),l=t??i,c=n??s,[u,d]=_.useState(),[f,g]=_.useState(),[b,v]=_.useState(),[y,w]=_.useState(),[S,E]=_.useState([]),[A,T]=_.useState(!0);return _.useEffect(()=>{let C=!1;return d(void 0),g(void 0),o.getCharts().then(R=>{C||d(R)},R=>{C||(d([]),g(Oa(R,"Metric charts could not be loaded.")),T(!1))}),()=>{C=!0}},[o]),_.useEffect(()=>{if(u==null)return;let C=!1;const R=Xke(l),N={agentId:e,startTimestamp:new Date(R.startTs).toISOString(),endTimestamp:new Date(R.endTs).toISOString()};return v(void 0),w(void 0),E(u.map(O=>({definition:O}))),T(!0),o.getMeters(N).then(O=>{C||v(O)},O=>{C||w(Oa(O,"Aggregate metrics could not be loaded."))}),Promise.all(u.map(async O=>{try{const P=await o.getChartData({...N,chartName:O.name});return{definition:O,graphs:P.graphs}}catch(P){return{definition:O,error:Oa(P,`${O.displayName} could not be loaded.`)}}})).then(O=>{C||(E(O),T(!1))}),()=>{C=!0}},[e,u,o,l]),h.jsx(a,{meters:b,meterError:y,charts:S,chartsLoading:A,chartsError:f,timeRange:l,onTimeRangeChange:c,showTimeRangeFilter:r})}var uwe={turn:"turn",event:"event",markerGroup:"markerGroup",toolCallGroup:"toolCallGroup",subAgentGroup:"subAgentGroup"};function Eyn(e){return e==null?"":e.type===uwe.turn?e.bar.id:e.type===uwe.event?e.segment.id:e.group.id}function Tyn({startMs:e,endMs:t}){return[e,t]}function Ayn(e,{toleranceMs:t=0}={}){var o;const n=e.flatMap((a,i)=>a.isMarker?[{segment:a,index:i}]:[]).sort((a,i)=>a.segment.threadId.localeCompare(i.segment.threadId)||a.segment.startMs-i.segment.startMs||a.index-i.index).map(({segment:a})=>a),r=[];for(const a of n){const i=r.at(-1);if(i!=null&&((o=i.segments[0])==null?void 0:o.threadId)===a.threadId&&a.startMs-i.startMs<=t){i.segments.push(a);continue}r.push({id:a.id,startMs:a.startMs,endMs:a.startMs,segments:[a]})}return r.map(a=>({...a,id:`marker-group-${a.segments.map(i=>i.id).join("-")}`}))}function Fze(e){return e<1e3?{divisorMs:1,suffix:"ms"}:e<6e4?{divisorMs:1e3,suffix:"s"}:e<36e5?{divisorMs:6e4,suffix:"m"}:{divisorMs:36e5,suffix:"h"}}function Cyn(e){const t=Fze(e);return`${Number((e/t.divisorMs).toFixed(2))}${t.suffix}`}var dwe=8,Uon=120;function Ryn({durationsMs:e,msPerPx:t,minTurnBarPx:n,markerPx:r}){const o=[],a=[],i=[];let s=0;for(const l of e){i.push(s);const c=t>0?Math.max(0,l)/t:0,u=Math.max(0,n-(c+r));o.push(u),a.push(c>0?(c+u)/c:1),s+=u}return{extraPx:o,scale:a,leadingExtraPx:i}}function Fon(e){return e==null||e<=0?dwe:Math.max(dwe,Math.round(e/Uon))}function Bon({totalMs:e,tickTarget:t}){const{divisorMs:n}=Fze(e),r=e/n/t;if(n>=6e4&&r<1)return Math.max(.25,Math.ceil(r*4)/4)*n;const o=Math.max(1,r),a=10**Math.floor(Math.log10(o)),i=o/a;return(i<=1?1:i<=2?2:i<=5?5:10)*a*n}function Hon(e,t){return t.reduce((n,r)=>(r.containsAnchor?e>r.atActiveMs:e>=r.atActiveMs)?n+r.gapMs:n,0)}function Von(e){const t=[...e].sort((n,r)=>n.atActiveMs-r.atActiveMs);return t.map(n=>{const r=t.filter(a=>a.atActiveMs<n.atActiveMs).reduce((a,i)=>a+i.gapMs,0),o=n.atActiveMs+r;return{startMs:o,endMs:o+n.gapMs}})}var Gon=50;function Won({chip:e,offsetMs:t}){const n=Math.max(0,e.endMs-e.startMs),r=Math.max(0,e.wallDurationMs);if(n<=0||r<=0)return e.startMs;const o=Math.min(1,Math.max(0,t/r));return e.startMs+o*n}function Kon(e){const t=new Set(e.segments.map(n=>n.threadId));if(t.size===1)return[...t][0]}function pwe(e,t){return e.threadId==null?!0:t==null?!1:e.threadId===t}function Yon({group:e,pauseChips:t}){const n=Kon(e),r=t.find(i=>pwe(i,n)&&e.startMs>=i.startMs&&e.startMs<=i.endMs);if(r!=null)return r;let o,a=Number.POSITIVE_INFINITY;for(const i of t){if(!pwe(i,n)||e.startMs>i.startMs)continue;const s=i.startMs-e.startMs;s>Gon||s>=a||(o=i,a=s)}return o}function Iyn({groups:e,pauseChips:t}){const n=[];for(const r of e){const o=r.segments.filter(u=>u.pauseSpanId!=null),a=r.segments.filter(u=>u.pauseSpanId==null);for(const u of o){const d=t.find(g=>g.id===u.pauseSpanId),f=d==null?r.startMs:u.pauseSpanEdge==="end"?d.endMs:d.startMs;n.push({id:`${r.id}-${u.id}`,x:f,segments:[u]})}if(a.length===0)continue;const i={...r,segments:a},s=Yon({group:i,pauseChips:t});if(s==null){n.push({id:r.id,x:r.startMs,segments:a});continue}const l=[...a].sort((u,d)=>(u.pauseOffsetMs??0)-(d.pauseOffsetMs??0)||u.id.localeCompare(d.id)),c=new Map;for(const u of l){const d=u.pauseOffsetMs??0,f=c.get(d)??[];f.push(u),c.set(d,f)}for(const[u,d]of c)n.push({id:`${r.id}-${d.map(f=>f.id).join("-")}`,x:Won({chip:s,offsetMs:u}),segments:d})}return n}function Zon(e,t){if(e.isPauseChip||e.isPauseSpan||e.isMarker||e.type==="sub_agent")return[e];let n=[e];for(const r of t)n=n.flatMap(o=>o.startMs<r&&o.endMs>r?[{...o,endMs:r,id:`${o.id}@pre:${r}`},{...o,startMs:r,id:`${o.id}@post:${r}`}]:[o]);return n}function Nyn({segments:e,pauseChipMs:t}){const n=[...new Set(e.filter(a=>a.isPauseChip).map(a=>a.startMs))].sort((a,i)=>a-i);if(n.length===0||t<=0)return e;const r=new Map(e.filter(a=>a.isPauseChip).map(a=>[a.startMs,a.turnIndex]));return e.flatMap(a=>Zon(a,n)).map(a=>{let i=0,s=0;for(const c of n){if(a.isPauseChip&&a.startMs===c)continue;if(a.isMarker&&a.startMs===c){const d=r.get(c);if(a.pauseOffsetMs!=null||d!=null&&a.turnIndex===d)continue;i+=t,s+=t;continue}if(a.isPauseSpan&&a.startMs<=c&&a.endMs>=c){s+=t;continue}(a.isMarker?a.startMs>c:a.startMs>=c)?(i+=t,s+=t):a.endMs>c&&(s+=t)}const l=a.startMs+i;return a.isPauseChip?{...a,startMs:l,endMs:l+t}:{...a,startMs:l,endMs:a.endMs+s}})}function Myn({activeTotalMs:e,turnStartsMs:t,turnGapMs:n,visualGaps:r,chartWidthPx:o}){const a=r??(t??[]).slice(1).map(c=>({atActiveMs:c,gapMs:n??0})),i=Bon({totalMs:e,tickTarget:Fon(o)}),s=[];for(let c=0;c<e;c+=i)s.push(c);const l=s.at(-1);return l!=null&&l>0&&e-l<i/4&&s.pop(),s.at(-1)!==e&&s.push(e),s.map(c=>({value:c+Hon(c,a)}))}function Oyn({turnRanges:e,pauseChipStartsMs:t,turnGapMs:n}){const r=[...e].sort((i,s)=>i.ordinal-s.ordinal),o=new Map;let a=0;for(let i=0;i<r.length;i+=1){const s=r[i];if(s==null)continue;o.set(s.turnIndex,a);const l=r[i+1];if(l==null||n<=0)continue;t.some(u=>Math.abs(u-l.startMs)<=1)||(a+=n)}return o}function Pyn({turnRanges:e,pauseChipStartsMs:t}){var o;const n=[...e].sort((a,i)=>a.ordinal-i.ordinal),r=[];for(let a=1;a<n.length;a+=1){const i=(o=n[a])==null?void 0:o.startMs;i!=null&&(t.some(s=>Math.abs(s-i)<=1)||r.push(i))}return r}function jyn(e){const t=new Map;for(const r of e){const o=t.get(r.turnIndex);o?(o.startMs=Math.min(o.startMs,r.startMs),o.endMs=Math.max(o.endMs,r.endMs)):t.set(r.turnIndex,{startMs:r.startMs,endMs:r.endMs})}const n=Array.from(t.entries()).sort(([r],[o])=>r-o);return{turnStartsMs:n.map(([,r])=>r.startMs),turnOrdinals:new Map(n.map(([r],o)=>[r,o])),turnRanges:n.map(([r,o],a)=>({turnIndex:r,startMs:o.startMs,endMs:o.endMs,ordinal:a}))}}function Dyn(e){const t=new Map;for(const n of e){const r=t.get(n.turnIndex)??[];r.push(n),t.set(n.turnIndex,r)}return[...t.entries()].sort((n,r)=>n[0]-r[0]).flatMap(([n,r])=>{const o=r[0];if(o==null)return[];let a=o.startMs,i=o.endMs;for(const s of r)a=Math.min(a,s.startMs),i=Math.max(i,s.endMs);return[{...o,turnIndex:n,startMs:a,endMs:i}]})}function Lyn(e){var n,r;const t=[];for(const o of[...e].sort((a,i)=>a.startMs-i.startMs||a.endMs-i.endMs)){const a=t.at(-1);if(a==null||((n=a.segments[0])==null?void 0:n.turnIndex)!==o.turnIndex||((r=a.segments[0])==null?void 0:r.threadId)!==o.threadId||o.startMs>=a.endMs){t.push({id:`tool-call-group-${o.id}`,startMs:o.startMs,endMs:o.endMs,segments:[o]});continue}a.endMs=Math.max(a.endMs,o.endMs),a.segments.push(o)}return t}function zyn({bars:e,subAgentSegments:t}){return e.map(n=>({id:`sub-agent-group-${n.id}`,barId:n.id,startMs:n.startMs,endMs:n.endMs,segments:t.filter(r=>r.turnIndex===n.turnIndex)}))}function $yn({subAgentSegments:e,threadSegments:t,minWidthMs:n}){const r=[],o=[...e].sort((i,s)=>i.startMs-s.startMs).map(i=>{const s=Math.max(i.endMs,i.startMs+n),l=r.findIndex(u=>u<=i.startMs),c=l===-1?r.length:l;return r[c]=s,{...i,id:`${i.id}-lane`,lane:c,visualEndMs:s}}),a=new Map;for(const i of t){if(i.type==="sub_agent")continue;const s=a.get(i.threadId);s?s.push(i):a.set(i.threadId,[i])}return o.map(i=>({threadId:i.threadId,lane:i.lane,track:i,segments:a.get(i.threadId)??[]}))}function Xon(e){const t=e.filter(r=>r.isPauseChip).map(r=>({turnIndex:r.turnIndex,startMs:r.startMs,endMs:Math.max(r.endMs,r.startMs),wallDurationMs:r.wallDurationMs??Math.max(0,r.endMs-r.startMs)})).filter(r=>r.wallDurationMs>0).sort((r,o)=>r.turnIndex-o.turnIndex||r.startMs-o.startMs||r.endMs-o.endMs),n=[];for(const r of t){const o=n.at(-1);if(o!=null&&o.turnIndex===r.turnIndex&&r.startMs<=o.endMs){o.endMs=Math.max(o.endMs,r.endMs),o.wallDurationMs=o.endMs-o.startMs;continue}n.push({...r})}return n.length===0?e:e.map(r=>{const o=n.filter(l=>l.turnIndex===r.turnIndex);if(o.length===0)return r;let a=0,i=0;for(const l of o)r.startMs>=l.endMs?a+=l.wallDurationMs:r.startMs>l.startMs&&(a+=r.startMs-l.startMs),r.endMs>=l.endMs?i+=l.wallDurationMs:r.endMs>l.startMs&&(i+=r.endMs-l.startMs);const s=Math.max(0,r.startMs-a);return r.isPauseChip?{...r,startMs:s,endMs:s,wallDurationMs:r.wallDurationMs??Math.max(0,r.endMs-r.startMs)}:{...r,startMs:s,endMs:Math.max(s,r.endMs-i)}})}function qon(e){const t=new Map;for(const o of e){const a=t.get(o.turnIndex);a?(a.startMs=Math.min(a.startMs,o.startMs),a.endMs=Math.max(a.endMs,o.endMs)):t.set(o.turnIndex,{turnIndex:o.turnIndex,startMs:o.startMs,endMs:o.endMs})}const n=new Map;let r=0;for(const[o,a]of Array.from(t.values()).sort((i,s)=>i.turnIndex-s.turnIndex).entries()){const s=(o===0?0:r)-a.startMs;n.set(a.turnIndex,s),r=a.endMs+s}return e.map(o=>{const a=n.get(o.turnIndex)??0;return{...o,startMs:o.startMs+a,endMs:o.endMs+a}})}function Qon(e,t){let n=e;for(const r of t)n-=Math.max(0,Math.min(e,r.endMs)-r.startMs);return Math.max(0,n)}function Uyn({valueMs:e,visualGaps:t}){const n=[...t].sort((i,s)=>i.atActiveMs-s.atActiveMs),r=Von(n);let a=Qon(e,r);for(let i=0;i<n.length;i+=1){const s=n[i],l=r[i],c=(s==null?void 0:s.wallDurationMs)??0;if(!(s==null||l==null||c<=0)){if(e>=l.endMs){a+=c;continue}if(e>l.startMs){const u=l.endMs-l.startMs,d=u>0?(e-l.startMs)/u:0;a+=d*c}}}return Math.max(0,a)}function ra(e){return typeof e=="object"&&e!=null}function iN(e){return ra(e)&&typeof e.type=="string"?{...e,type:e.type}:null}function cs(e,t,n){const r=e[t];if(typeof r=="string"&&r.length>0)return r;const o=e[n];return typeof o=="string"&&o.length>0?o:void 0}function Jn(e){if(e==null)return null;const t=Date.parse(e);return Number.isNaN(t)?null:t}function Ao(e){return cs(e,"createdAt","created_at")}function Xd(e){return cs(e,"threadId","thread_id")??Da}function Ea(e){return typeof e.id=="string"?e.id:`${e.type}-${Ao(e)??"unknown"}`}function sN(e){return typeof e=="string"?e.trim():Array.isArray(e)?e.flatMap(t=>typeof t=="string"?t?[t]:[]:ra(t)&&typeof t.text=="string"&&t.text.length>0?[t.text]:[]).join(`
1100
1100
  `).trim():""}function mc(e){const t=e.toolCalls??e.tool_calls;return Array.isArray(t)?t.filter(ra):[]}function Bze(e){const t=ra(e.parent)?e.parent:void 0;return t==null?void 0:cs(t,"toolCallId","tool_call_id")}function Yg(e){return ra(e)?cs(e,"completedAt","completed_at"):void 0}function Hze(e){return ra(e)&&typeof e.message=="string"?e.message:""}function Jon(e){return ra(e)?cs(e,"reason","reason")??"":""}function ean(e){return ra(e)?typeof e.error=="string"&&e.error.length>0?e.error:Hze(e):""}function tan(e){const t=e.trim().toLowerCase();return t==="llm stream aborted"||t==="aborterror"||t.includes("stream aborted")||t.includes("aborterror")}function dB(e){return ra(e)&&typeof e.status=="string"?e.status:void 0}function Vze(e){const t=Reflect.get(e,"input");return Array.isArray(t)?t.flatMap(n=>typeof n!="object"||n==null?[]:[{..."type"in n?{type:n.type}:{},..."content"in n?{content:n.content}:{},..."approval"in n?{approval:n.approval}:{}}]):[]}function nan(e){const t=Vze(e.created).find(n=>typeof n.type=="string");return typeof(t==null?void 0:t.type)=="string"?t.type:"user.message"}function pB(e){if(e==null)return"";const t=ra(e.function)?e.function:void 0,n=typeof(t==null?void 0:t.name)=="string"?t.name:"",r=typeof(t==null?void 0:t.arguments)=="string"?t.arguments:void 0;if(tee.has(n)){const{mcpServer:o,innerToolName:a}=sE(r),i=[o,a].filter(s=>s!=null&&s.length>0).join("/");if(i.length>0)return i}return n}function ran(e){const t=new Map;for(const n of e){const r=n.trim();r.length!==0&&t.set(r,(t.get(r)??0)+1)}return t.size===0?"Approval required":[...t.entries()].map(([n,r])=>r>1?`${n} (${r})`:n).join(`
1101
1101
  `)}function Gze(e,{toolLabel:t}={}){const n=ra(e)?e:void 0,r=typeof(n==null?void 0:n.reason)=="string"?n.reason.trim():"",o=(n==null?void 0:n.status)==="deny"?r.length>0?`Denied: ${r}`:"Denied":(n==null?void 0:n.status)==="allow"?"approved":"Tool approval",a=(t==null?void 0:t.trim())??"";return a.length>0?`${a} · ${o}`:o==="approved"?"Approved":o}function oan(e){const t=e.policies;if(!Array.isArray(t)||t.length===0)return"Approval policy";const n=Jn(Ao(e)),r=t.flatMap(o=>{if(!ra(o))return[];const a=cs(o,"serverName","server_name")??"",i=typeof o.name=="string"?o.name:"",s=ra(o.policy)?o.policy:void 0,l=typeof(s==null?void 0:s.type)=="string"?s.type:"",c=[a,i].filter(b=>b.length>0).join("/");if(c.length===0&&l.length===0)return[];const u=s==null?void 0:cs(s,"expireAt","expire_at"),d=Jn(u),f=d!=null&&n!=null&&d>n?x6e(d-n):"",g=l.length>0?`${c||"tool"} · ${l}`:c;return[f.length>0?`${g} · ${f}`:g]});return r.length>0?r.join(", "):"Approval policy"}function Wze(e){const t=Vze(e.created).find(n=>typeof n.type=="string");return t==null?"":t.type==="user.tool_approval"?Gze(t.approval):t.type==="user.tool_response"?sN(t.content)||"Tool response":t.type==="user.mcp_auth_continue"?"MCP authorization completed":sN(t.content)||"User message"}function aan(e){const t=typeof e.title=="string"?e.title.trim():"",n=ra(e.agentInfo)?e.agentInfo:ra(e.agent_info)?e.agent_info:void 0,r=typeof(n==null?void 0:n.name)=="string"?n.name.trim():"",o=typeof(n==null?void 0:n.input)=="string"?n.input.trim():"";return t||r||o}function fwe(e){var o;const t=ra(e.function)?e.function:void 0,n=typeof(t==null?void 0:t.name)=="string"?t.name:"",r=typeof(t==null?void 0:t.arguments)=="string"?t.arguments:void 0;if(eee.has(n)||n==="code_sandbox"){const a=(o=nee(r).intent)==null?void 0:o.trim(),i=`Sandbox: ${n}`;return a!=null&&a.length>0?`${i} - ${a}`:i}if(tee.has(n)){const{mcpServer:a,innerToolName:i}=sE(r);return Lze(n,a,i)}return n}var Kze=new Set(["tool.approval_required","tool.response_required","mcp.auth_required","user.tool_approval","user.tool_approval_policy","user.tool_response","user.mcp_auth_continue"]),ian=new Set(["tool.approval_required","tool.response_required","mcp.auth_required"]),fB=1e3,san=50;function Yze(e){const t=ra(e.state)?e.state:void 0;return typeof(t==null?void 0:t.status)=="string"?t.status:void 0}function lan(e){const t=new Map,n=new Set;for(const r of e.events){const o=iN(r);if(o!=null){if(o.type==="model.message"){const a=Jn(Ao(o))??0;for(const i of mc(o))typeof i.id=="string"&&t.set(i.id,{startedAtMs:a,threadId:Xd(o),modelEventId:Ea(o),toolCall:i});continue}if(o.type==="tool.approval_required"){if(Xd(o)===Da)continue;for(const a of mc(o))typeof a.id=="string"&&n.add(a.id);continue}if(o.type==="user.tool_approval"){const a=cs(o,"toolCallId","tool_call_id");a!=null&&n.delete(a);continue}if(o.type==="user.tool_approval_policy")for(const a of oee({event:o,candidates:n,toolCallRequests:t}))n.delete(a)}}return n.size>0}function can(e){for(const t of e){if(t.done!=null)continue;let n=!1;for(const r of t.events){const o=iN(r);if(o==null||o.type!=="turn.update")continue;const a=Yze(o);a==="paused"?n=!0:a==="running"&&(n=!1)}if(n||lan(t))return!0}return!1}function uan({events:e,turnDoneMs:t,nowMs:n}){const r=[];let o;for(const a of e){if(a.type!=="turn.update")continue;const i=Jn(Ao(a));if(i==null)continue;const s=Yze(a);if(s==="paused"){o==null&&(o={startMs:i,eventId:Ea(a)});continue}s==="running"&&o!=null&&(r.push({startMs:o.startMs,endMs:Math.max(o.startMs,i),eventId:o.eventId}),o=void 0)}if(o!=null){const a=t??n;r.push({startMs:o.startMs,endMs:Math.max(o.startMs,a),eventId:o.eventId})}return r}function dan({events:e,beforeMs:t}){const n=new Set;for(const r of e){if(r.type!=="user.tool_approval"&&r.type!=="user.tool_response"&&r.type!=="user.mcp_auth_continue")continue;const o=Jn(Ao(r));if(o==null||o>=t)continue;const a=cs(r,"toolCallId","tool_call_id");a!=null&&n.add(a)}return n}function pan({events:e,windows:t}){return t.map((n,r)=>{var s;const o=r>0?((s=t[r-1])==null?void 0:s.endMs)??Number.NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,a=dan({events:e,beforeMs:n.startMs});let i=n.startMs;for(const l of e){if(!ian.has(l.type)||Xd(l)!==Da)continue;const c=Jn(Ao(l));if(c==null||c<=o||c>n.endMs)continue;const u=mc(l).map(d=>typeof d.id=="string"?d.id:void 0).filter(d=>d!=null);u.length>0&&u.every(d=>a.has(d))||(i=Math.min(i,c))}return i<n.startMs?{...n,startMs:i}:n})}function fan({events:e,window:t}){return e.some(n=>{if(!Kze.has(n.type))return!1;const r=Jn(Ao(n));return r!=null&&qS([t],r)!=null})}function han({events:e,window:t,threadDoneMsById:n}){const r=new Set;for(const a of e){if(!Kze.has(a.type))continue;const i=Jn(Ao(a));i==null||qS([t],i)==null||r.add(Xd(a))}const o=[...r].filter(a=>{if(a===Da)return!1;const i=n.get(a);return i==null||i>t.startMs});return o.length>0?o:[Da]}function qS(e,t){return e.find(n=>t>=n.startMs-san&&t<=n.endMs)}function gan({wait:e,pauseWindows:t}){return e.endMs-e.startMs<fB?!1:t.length===0?!0:t.some(n=>e.startMs<n.startMs||e.endMs>n.endMs)}function oee({event:e,candidates:t,toolCallRequests:n}){var i;const r=Array.isArray(e.policies)?e.policies.filter(ra):[],o=new Set(r.map(s=>{const l=cs(s,"serverName","server_name")??"",c=typeof s.name=="string"?s.name:"";return[l,c].filter(u=>u.length>0).join("/")}).filter(s=>s.length>0));if(o.size===0)return[];const a=[];for(const s of t){const l=pB((i=n==null?void 0:n.get(s))==null?void 0:i.toolCall);l.length>0&&o.has(l)&&a.push(s)}return a}function man({events:e,turnDoneMs:t,nowMs:n,threadDoneMsById:r,toolCallRequests:o}){const a=new Map,i=[],s=[...e].sort((d,f)=>(Jn(Ao(d))??0)-(Jn(Ao(f))??0)),l=d=>{const f=r.get(d.threadId);if(f!=null&&f<=d.startMs)return;const g=f!=null?Math.min(d.endMs,f):d.endMs;if(!(g<=d.startMs))return{...d,endMs:g}},c=(d,f)=>{const g=a.get(d);if(g==null)return;a.delete(d);const b=l({threadId:g.threadId,startMs:g.startMs,endMs:Math.max(g.startMs,f),eventId:g.eventId});b!=null&&i.push(b)};for(const d of s){const f=Jn(Ao(d));if(f==null)continue;if(d.type==="tool.approval_required"){const b=Xd(d);if(b===Da)continue;for(const v of mc(d))typeof v.id=="string"&&(a.has(v.id)||a.set(v.id,{threadId:b,startMs:f,eventId:Ea(d)}));continue}if(d.type==="user.tool_approval_policy"){for(const b of oee({event:d,candidates:[...a.keys()],toolCallRequests:o}))c(b,f);continue}if(d.type!=="user.tool_approval")continue;const g=cs(d,"toolCallId","tool_call_id");g!=null&&c(g,f)}const u=t??n;for(const d of a.values()){const f=r.get(d.threadId),g=l({threadId:d.threadId,startMs:d.startMs,endMs:Math.max(d.startMs,f??u),eventId:d.eventId});g!=null&&i.push(g)}return i}function ban(e){const t=e.filter(n=>n.isPauseSpan);for(const n of e){if(!n.isMarker||n.threadId===Da)continue;if(n.title==="tool.approval_required"){const o=t.find(a=>a.id===`${n.id}-wait-span-${n.threadId}`);if(o==null)continue;n.pauseSpanId=o.id,n.pauseSpanEdge="start";continue}if(n.title!=="user.tool_approval")continue;const r=t.find(o=>o.threadId===n.threadId&&o.turnIndex===n.turnIndex&&Math.abs(o.endMs-n.startMs)<=1);r!=null&&(n.pauseSpanId=r.id,n.pauseSpanEdge="end")}}function van(e){var n,r;const t=e.filter(o=>o.isCompressionOnly?!1:o.isPauseChip?!0:o.isPauseSpan===!0);if(t.length!==0)for(let o=e.length-1;o>=0;o-=1){const a=e[o];if(a==null||a.isPauseChip||a.isPauseSpan||a.isMarker||a.type==="sub_agent")continue;let i=[a];for(const l of t){if(l.threadId!==a.threadId||l.turnIndex!==a.turnIndex)continue;const c=Math.max(l.endMs,l.startMs);i=i.flatMap(u=>{if(u.endMs<=l.startMs||u.startMs>=c)return[u];const d=[];return u.startMs<l.startMs&&d.push({...u,endMs:l.startMs,id:`${u.id}@pre:${l.startMs}`}),u.endMs>c&&d.push({...u,startMs:c,id:`${u.id}@post:${c}`}),d})}const s=i.filter(l=>l.endMs>l.startMs);s.length===1&&((n=s[0])==null?void 0:n.id)===a.id&&((r=s[0])==null?void 0:r.endMs)===a.endMs||e.splice(o,1,...s)}}function yan(e){const t=e.filter(n=>!n.isCompressionOnly&&(n.isPauseChip||n.isPauseSpan)).sort((n,r)=>n.startMs-r.startMs||n.endMs-r.endMs);for(const n of t){let r;for(const i of e)i.threadId!==n.threadId||i.turnIndex!==n.turnIndex||i.isPauseChip||i.isPauseSpan||i.isMarker||i.type!=="sub_agent"&&(i.startMs>=n.startMs||(r==null||i.endMs>r.endMs)&&(r=i));if(r==null||r.endMs===n.startMs)continue;const o=r.endMs;t.some(i=>i!==n&&i.threadId===n.threadId&&i.turnIndex===n.turnIndex&&i.startMs>=o&&i.startMs<n.startMs)||(r.endMs=n.startMs)}}function xan({segments:e,threadId:t,turnIndex:n,afterMs:r}){return e.some(o=>o.threadId!==t||o.turnIndex!==n||o.isPauseChip||o.isPauseSpan||o.isMarker||o.type==="sub_agent"?!1:o.startMs>=r)}function wan(e){const t=new Set(e.filter(n=>n.type==="sub_agent"&&!n.isMarker).map(n=>n.threadId));for(const n of e)!n.isPauseChip&&!n.isPauseSpan||n.threadId===Da||t.has(n.threadId)&&(xan({segments:e,threadId:n.threadId,turnIndex:n.turnIndex,afterMs:n.endMs})||(n.isCompressionOnly=!0))}function Xw({windows:e,eventMs:t,originMs:n}){const r=qS(e,t);if(r==null)return{startMs:t-n,endMs:t-n};const o=Math.max(t,r.startMs);return{startMs:o-n,endMs:o-n,pauseOffsetMs:Math.max(0,t-r.startMs)}}function _an({events:e,pauseWindows:t,toolCallRequests:n}){const r=new Map,o=new Set;for(const i of e){if(i.type!=="tool.approval_required")continue;const s=Jn(Ao(i));if(s==null)continue;for(const c of mc(i))typeof c.id=="string"&&o.add(c.id);const l=qS(t,s);if(l!=null)for(const c of mc(i))typeof c.id=="string"&&r.set(c.id,l.endMs)}const a=(i,s)=>{const l=qS(t,s),c=l!=null?Math.max(l.endMs,s):s,u=r.get(i);r.set(i,u!=null?Math.max(u,c):c)};for(const i of e){const s=Jn(Ao(i));if(s==null)continue;if(i.type==="user.tool_approval_policy"){for(const c of oee({event:i,candidates:o,toolCallRequests:n}))a(c,s);continue}if(i.type!=="user.tool_approval")continue;const l=cs(i,"toolCallId","tool_call_id");l!=null&&a(l,s)}return r}function San(e,{nowMs:t=Date.now()}={}){var b,v,y;const n=Jn((b=e[0])==null?void 0:b.created.createdAt);if(n==null)return[];const r=new Map,o=new Map,a=new Map,i=new Map,s=new Set,l=new Map;let c=n;for(const w of e){c=Math.max(c,Jn(w.created.createdAt)??c),c=Math.max(c,Jn(Yg((v=w.done)==null?void 0:v.state))??c);for(const S of w.events){const E=iN(S);if(E!=null){if(c=Math.max(c,Jn(Ao(E))??c),E.type==="tool.response"){const A=cs(E,"toolCallId","tool_call_id");if(A==null)continue;const T=r.get(w.turnId)??new Map;T.set(A,E),r.set(w.turnId,T)}else if(E.type==="tool.response_required"){const A=o.get(w.turnId)??new Map;for(const T of mc(E))typeof T.id=="string"&&A.set(T.id,E);o.set(w.turnId,A)}else if(E.type==="tool.approval_required"){const A=a.get(w.turnId)??new Set;for(const T of mc(E))typeof T.id=="string"&&A.add(T.id);a.set(w.turnId,A)}else if(E.type==="thread.created"){const A=Bze(E);A!=null&&s.add(A)}else if(E.type==="thread.done")i.set(Xd(E),E);else if(E.type==="model.message"){const A=Jn(Ao(E));if(A==null)continue;const T=l.get(w.turnId)??new Map;for(const C of mc(E))typeof C.id=="string"&&T.set(C.id,{startedAtMs:A,threadId:Xd(E),modelEventId:Ea(E),toolCall:C});l.set(w.turnId,T)}}}}const u=[],d=new Set,f=new Map,g=new Map;for(const w of e)f.set(w.turnNumber,w.turnId),g.set(w.eventTurnNumber-1,w.turnNumber-1);for(const w of e){const S=Jn(w.created.createdAt);if(S==null)continue;const E=w.eventTurnNumber-1;w.renderable&&u.push({id:`${w.turnId}-user`,type:"user",title:nan(w),description:Wze(w),startMs:S-n,endMs:S-n,turnIndex:E,threadId:Da,isMarker:!0});const A=new Map,T=[...w.events].map(iN).filter(z=>z!=null).sort((z,L)=>(Jn(Ao(z))??0)-(Jn(Ao(L))??0)),C=Jn(Yg((y=w.done)==null?void 0:y.state)),R=new Map;for(const[z,L]of i){const $=Jn(Ao(L));$!=null&&R.set(z,$)}const N=pan({events:T,windows:uan({events:T,turnDoneMs:C,nowMs:t})}),O=man({events:T,turnDoneMs:C,nowMs:t,threadDoneMsById:R,toolCallRequests:l.get(w.turnId)}),P=new Set(O.filter(z=>gan({wait:z,pauseWindows:N})).map(z=>z.threadId));for(const z of N){const L=Math.max(0,z.endMs-z.startMs);if(L>=fB||fan({events:T,window:z}))for(const U of han({events:T,window:z,threadDoneMsById:R})){const B=R.get(U),V=U!==Da&&B!=null&&B<=z.endMs,G=U!==Da&&P.has(U);u.push({id:`${z.eventId}-pause-${U}`,type:"waiting_on_human",title:"turn.paused",description:"Paused",startMs:z.startMs-n,endMs:z.endMs-n,turnIndex:E,threadId:U,isPauseChip:!0,wallDurationMs:L,pauseWallStartMs:z.startMs-n,pauseWallEndMs:z.endMs-n,...V||G?{isCompressionOnly:!0}:{}})}}for(const z of O){const L=Math.max(0,z.endMs-z.startMs);L<fB||u.push({id:`${z.eventId}-wait-span-${z.threadId}`,type:"waiting_on_human",title:"thread.paused",description:"Paused",startMs:z.startMs-n,endMs:z.endMs-n,turnIndex:E,threadId:z.threadId,isPauseSpan:!0,wallDurationMs:L,pauseWallStartMs:z.startMs-n,pauseWallEndMs:z.endMs-n})}const j=_an({events:T,pauseWindows:N,toolCallRequests:l.get(w.turnId)}),D=Ean(T);for(const z of T){const L=Jn(Ao(z));if(L==null)continue;const $=Xd(z);Tan({compactionEndMsByStartedId:D,event:z,eventMs:L,createdMs:S,originMs:n,turn:w,turnIndex:E,threadId:$,lastTimestampByThreadId:A,toolResponsesByTurnId:r,toolResponseRequiredByTurnId:o,approvalRequiredIdsByTurnId:a,approvalToolResumeMs:j,pauseWindows:N,subAgentToolCallIds:s,toolCallRequestsByTurnId:l,threadDoneEvents:i,emittedWaitingRequestIds:d,segments:u}),A.set($,L)}wan(u),van(u),yan(u),Aan({turn:w,turnIndex:E,originMs:n,latestMs:c,segments:u,emitDoneMarker:f.get(w.turnNumber)===w.turnId})}return ban(u),qon(Xon(u.map(w=>({...w,startMs:Math.max(0,w.startMs),endMs:Math.max(0,w.endMs)})))).map(w=>({...w,turnIndex:g.get(w.turnIndex)??w.turnIndex})).sort((w,S)=>w.startMs-S.startMs||w.endMs-S.endMs)}function hwe({record:e,camel:t,snake:n}){const r=e[t];if(typeof r=="number"&&Number.isFinite(r)&&r>=0)return Math.floor(r);const o=e[n];if(typeof o=="number"&&Number.isFinite(o)&&o>=0)return Math.floor(o)}function kan(e){const t=ra(e.trigger)?e.trigger:void 0;if(t==null||t.type!=="context_threshold_exceeded")return;const n=hwe({record:t,camel:"contextTokens",snake:"context_tokens"}),r=hwe({record:t,camel:"thresholdTokens",snake:"threshold_tokens"});if(!(n==null||r==null||r<=0))return`Context ${String(n)} / threshold ${String(r)} tokens`}function Ean(e){const t=new Map,n=new Map;for(const r of e){const o=Xd(r);if(r.type==="thread.context_compaction_started")t.set(o,Ea(r));else if(r.type==="thread.context_compaction_finished"){const a=t.get(o),i=Jn(Ao(r));a!=null&&i!=null&&(n.set(a,i),t.delete(o))}}return n}function Tan({event:e,eventMs:t,createdMs:n,originMs:r,turn:o,turnIndex:a,threadId:i,lastTimestampByThreadId:s,toolResponsesByTurnId:l,toolResponseRequiredByTurnId:c,approvalRequiredIdsByTurnId:u,approvalToolResumeMs:d,pauseWindows:f,subAgentToolCallIds:g,toolCallRequestsByTurnId:b,threadDoneEvents:v,emittedWaitingRequestIds:y,compactionEndMsByStartedId:w,segments:S}){var E,A,T,C,R,N;switch(e.type){case"model.message":{const O=s.get(i)??n,P=sN(e.content),j=l.get(o.turnId),D=c.get(o.turnId),z=u.get(o.turnId),L=Jn(Yg((E=o.done)==null?void 0:E.state)),$=mc(e);for(const U of $){const B=typeof U.id=="string"?U.id:void 0;if(B==null||g.has(B))continue;const V=j==null?void 0:j.get(B),G=V==null?null:Jn(Ao(V)),F=D==null?void 0:D.get(B),Z=F==null?null:Jn(Ao(F));if(z!=null&&z.has(B)){const W=d.get(B);if(W==null)continue;const Y=G??Z??L;if(Y==null||Y<W)continue;S.push({id:`${Ea(e)}-${B}`,type:"tool_call",title:"tool.call",description:fwe(U),startMs:W-r,endMs:Y-r,turnIndex:a,threadId:i,...G==null&&Y<=W?{isMarker:!0}:{}});continue}const J=G??Z??L??t;J<t||S.push({id:`${Ea(e)}-${B}`,type:"tool_call",title:"tool.call",description:fwe(U),startMs:t-r,endMs:J-r,turnIndex:a,threadId:i,...G==null&&J<=t?{isMarker:!0}:{}})}(P.length>0||$.length>0||i===Da)&&S.push({id:Ea(e),type:"model",title:e.type,description:P,startMs:Math.max(0,O-r),endMs:Math.max(0,t-r),turnIndex:a,threadId:i,isMarker:t<=O});return}case"thread.created":{const O=Bze(e),P=O==null||(A=b.get(o.turnId))==null?void 0:A.get(O);if(P!=null){const U=`${o.turnId}:${P.modelEventId}`;y.has(U)||(y.add(U),P.startedAtMs<t&&S.push({id:`${Ea(e)}-waiting`,type:"system",title:"system.waiting_for_sub_agent",description:"System waiting for sub-agent to start executing",startMs:P.startedAtMs-r,endMs:t-r,turnIndex:a,threadId:P.threadId}))}const j=v.get(i),D=j==null?null:Jn(Ao(j)),z=Jn(Yg((T=o.done)==null?void 0:T.state))??Jn((C=o.done)==null?void 0:C.createdAt),L=D!=null&&D>=t?D:z!=null&&z>=t?z:t;S.push({id:Ea(e),type:"sub_agent",title:e.type,description:aan(e),startMs:t-r,endMs:L-r,turnIndex:a,threadId:i,isMarker:L<=t});const $=j!=null&&ra(j.state)?j.state:void 0;if($!=null&&dB($)==="error"){const U=ean($);if(!(dB((R=o.done)==null?void 0:R.state)==="cancelled"&&tan(U))){const V=D??t;S.push({id:`${Ea(e)}-error`,type:"error",title:"thread.error",description:U,startMs:V-r,endMs:V-r,turnIndex:a,threadId:i,isMarker:!0})}}return}case"user.tool_approval":{const O=cs(e,"toolCallId","tool_call_id"),P=O==null||(N=b.get(o.turnId))==null?void 0:N.get(O),j=pB(P==null?void 0:P.toolCall)||(O!=null&&O.length>0?O.slice(0,12):void 0);S.push({id:Ea(e),type:"approval",title:e.type,description:Gze(e.approval,{toolLabel:j}),turnIndex:a,threadId:i,isMarker:!0,...Xw({windows:f,eventMs:t,originMs:r})});return}case"user.tool_approval_policy":S.push({id:Ea(e),type:"approval",title:e.type,description:oan(e),turnIndex:a,threadId:Da,isMarker:!0,...Xw({windows:f,eventMs:t,originMs:r})});return;case"user.tool_response":S.push({id:Ea(e),type:"user",title:e.type,description:sN(e.content)||"Tool response",turnIndex:a,threadId:i,isMarker:!0,...Xw({windows:f,eventMs:t,originMs:r})});return;case"user.mcp_auth_continue":S.push({id:Ea(e),type:"user",title:e.type,description:"MCP authorization completed",turnIndex:a,threadId:i,isMarker:!0,...Xw({windows:f,eventMs:t,originMs:r})});return;case"thread.context_compaction_started":{const O=w.get(Ea(e))??t;S.push({id:Ea(e),type:"summary",title:e.type,description:kan(e)??"Summarizing context",startMs:t-r,endMs:O-r,turnIndex:a,threadId:i,...O<=t?{isMarker:!0}:{}});return}case"thread.context_compaction_finished":return;case"tool.approval_required":case"tool.response_required":case"mcp.auth_required":case"mcp.initialize":case"sandbox.created":{const O=e.type==="tool.approval_required"?mc(e).flatMap(P=>{var L;const j=typeof P.id=="string"?P.id:void 0,D=j==null||(L=b.get(o.turnId))==null?void 0:L.get(j),z=pB(D==null?void 0:D.toolCall);return z.length>0?[z]:[]}):[];S.push({id:Ea(e),type:e.type==="tool.approval_required"?"approval":e.type==="tool.response_required"||e.type==="mcp.auth_required"?"waiting_on_human":"system",title:e.type,description:e.type==="tool.approval_required"?ran(O):e.type==="tool.response_required"?"Waiting for user response":e.type==="mcp.auth_required"?"MCP authentication required":e.type==="mcp.initialize"?"MCP initialized":"Sandbox created",turnIndex:a,threadId:i,isMarker:!0,...Xw({windows:f,eventMs:t,originMs:r})});return}default:return}}function Aan({turn:e,turnIndex:t,originMs:n,latestMs:r,segments:o,emitDoneMarker:a}){var l,c,u,d,f,g;const i=dB((l=e.done)==null?void 0:l.state);if(i==="error"){const b=Jn(Yg((c=e.done)==null?void 0:c.state))??r;o.push({id:`${e.turnId}-error`,type:"error",title:"turn.error",description:Hze((u=e.done)==null?void 0:u.state),startMs:b-n,endMs:b-n,turnIndex:t,threadId:Da,isMarker:!0});return}if(i==="cancelled"){const b=Jn(Yg((d=e.done)==null?void 0:d.state))??r,v=Jon((f=e.done)==null?void 0:f.state);o.push({id:`${e.turnId}-turn.cancelled`,type:"system",title:"turn.cancelled",description:v.length>0?v:"cancelled",startMs:b-n,endMs:b-n,turnIndex:t,threadId:Da,isMarker:!0});return}if(i!=="done"||!a)return;const s=Jn(Yg((g=e.done)==null?void 0:g.state));s!=null&&o.push({id:`${e.turnId}-turn.done`,type:"system",title:"turn.done",description:"Turn completed",startMs:s-n,endMs:s-n,turnIndex:t,threadId:Da,isMarker:!0})}function Can(e,t){const n=[...e].reverse();return{async listEvents({pageToken:r}){const o=r==null||r.length===0?0:Number.parseInt(r,10),a=Number.isFinite(o)?o:0,i=n.length,s=n.slice(a,a+i),l=a+i,c=l<n.length?String(l):void 0,u={data:s};return c==null?u:{...u,nextPageToken:c}}}}var Ran=6e4,Ian="Taking longer than expected";function Nan({label:e,activityKey:t,progressKey:n}){const r=t==null?null:`${t}:${n??""}`,[o,a]=_.useState(null),[i,s]=_.useState(r);return i!==r&&(s(r),a(null)),_.useEffect(()=>{if(r==null)return;const l=window.setTimeout(()=>a(r),Ran);return()=>window.clearTimeout(l)},[r]),r==null||o!==r?e:Ian}function Man(e){return e.type==="tool-call"||e.type==="reasoning"||e.type==="data"&&e.name===Zk}function Oan(e,t){const n=[];let r=e.length;for(let u=e.length-1;u>=0;u--){const d=e[u];if(d)if(d.type==="text"){const f=d.text??"";f.trim()&&n.unshift({index:u,content:f}),r=u}else break}const o=n.reduce((u,d)=>u+d.content.length,0),a=e.slice(0,r).some(Man),i=n.length>0&&(!t||o>=500||!a),s=i?r:e.length;let l=0,c=0;for(let u=0;u<s;u++){const d=e[u];d&&(d.type==="tool-call"?l++:d.type==="reasoning"&&c++)}return{cutIndex:s,hasFinal:i,toolCount:l,thinkingCount:c}}var Pan=new Set([iE,Pze]);function jan(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;for(const t of Object.keys(e)){const n=Reflect.get(e,t);if(typeof n!="string"||n.length===0)return!1}return Object.keys(e).length>0}function Zze(e){if(e==null||typeof e!="object"||Array.isArray(e))return;const t=Reflect.get(e,"parallelToolGroups");return jan(t)?t:void 0}function gwe(e){return e.type==="tool-call"&&e.toolCallId!=null&&(e.toolName==null||!Pan.has(e.toolName))}function hB({part:e,parts:t,parallelToolGroups:n}){if(n==null||!gwe(e))return null;const r=n[e.toolCallId];if(r==null)return null;const o=t.findIndex(c=>c.toolCallId===e.toolCallId);if(o===-1)return null;const a=c=>c!=null&&gwe(c)&&n[c.toolCallId]===r;let i=o;for(;a(t[i-1]);)i-=1;let s=o;for(;a(t[s+1]);)s+=1;const l=t[i];return s-i+1<2||(l==null?void 0:l.toolCallId)==null?null:`group-parallel-${r}-${l.toolCallId}`}function Xze(e){return e.type.startsWith("group-parallel-")}var i2="Working...",mwe=60;function aee(e){return e.status?e.status.type:Dze(e.approval)?"requires-action":e.result===void 0?"running":"complete"}function Dan(e){let t=e.length;for(;t>0&&(e[t-1]==="."||e[t-1]==="…");)t--;return e.slice(0,t)}function qze(e){return e.type==="tool-call"&&e.toolName===iE&&aee(e)==="running"}function iee(e){return e.type==="data"&&e.name===Zk&&m4e(e.data)&&e.data.status==="running"}function Lan(e){var r;const t=e.toolName??"tool";if(eee.has(t)){const o=Dan(((r=nee(e.argsText).intent)==null?void 0:r.trim())??"");return o?`${o.length>mwe?`${o.slice(0,mwe)}…`:o} · ${t}`:"Running command..."}const{innerToolName:n}=sE(e.argsText);return`Running ${n??t}...`}function Qze(e){var r,o;const t=e[e.length-1];if(!t)return i2;if(t.type==="reasoning")return"Thinking...";if(iee(t))return"Summarizing context...";if(t.type!=="tool-call")return i2;const n=aee(t);if(n==="requires-action")return"Waiting for your approval";if(n!=="running")return i2;if(t.toolName===iE){const a=((o=(r=t.messages)==null?void 0:r[t.messages.length-1])==null?void 0:o.content)??[];return`Sub-agent: ${Qze(a)}`}return Lan(t)}function zan(e){if(e.some(qze))return null;const t=e[e.length-1];if(!t)return"model";if(t.type==="reasoning")return"thinking";if(iee(t))return"summarizing";if(t.type==="tool-call"){const n=aee(t);if(n==="requires-action")return null;if(n==="running")return`tool:${t.toolCallId??t.toolName??"tool"}`}return"model"}function $an(e){var n,r;const t=e[e.length-1];return t?t.type==="reasoning"?`${e.length}:reasoning:${((n=t.text)==null?void 0:n.length)??0}`:t.type==="tool-call"?`${e.length}:tool-call:${((r=t.argsText)==null?void 0:r.length)??0}`:`${e.length}:${t.type}`:`${e.length}:empty`}function Uan(e){const t=e.filter(qze).length;if(t>1)return`Waiting for ${t} sub-agents...`;if(t===1)return"Waiting for sub-agent...";const n=e[e.length-1];return(n==null?void 0:n.type)==="reasoning"?"Thinking...":n&&iee(n)?"Summarizing context...":i2}function Fan({children:e,toolCount:t,thinkingCount:n,hasFinal:r}){const o=Ge("AgentStepsCard"),[a,i]=_.useState(!0),s=_.useRef(!1);return _.useEffect(()=>{r&&!s.current&&(s.current=!0,i(!1))},[r]),h.jsx(o,{toolCount:t,thinkingCount:n,expanded:a,onToggle:()=>i(l=>!l),children:e})}var Ban=4*1024,Han=100;function Van(e,{isComplete:t,enabled:n,throttleMs:r=Han}){const[o,a]=_.useState(e),i=_.useRef(e),s=_.useRef(Date.now()),l=_.useRef(e),c=_.useRef(n);return _.useEffect(()=>{l.current=e;const u=g=>{g.length<i.current.length&&g!==i.current||(i.current=g,s.current=Date.now(),a(g))};if(!n){c.current=!1,i.current=e,s.current=Date.now(),a(e);return}if(!c.current){c.current=!0,u(e);return}if(i.current===e)return;if(t){u(e);return}const d=Date.now()-s.current;if(d>=r){u(e);return}const f=setTimeout(()=>{u(l.current)},r-d);return()=>clearTimeout(f)},[e,t,n,r]),n?o:e}function Gan(e){const t=e.split("/").pop()??"";return t.length>0?t:"download"}function Wan(e,t){if(typeof document>"u")return;const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function gB(){var w,S;const e=Ge("Markdown"),t=eE(),n=pYt(),r=_.useRef({downloadSandboxFile:n,toaster:t});r.current={downloadSandboxFile:n,toaster:t};const o=sLe(),a=_.useCallback(E=>r.current.downloadSandboxFile(E),[]),i=Ve(E=>E.part),s=_.useRef(!1),l=vRe(i,s.current?!1:{drainMs:150,maxCharIntervalMs:4,maxCharsPerFrame:128,minCommitMs:48}),c=((w=i.status)==null?void 0:w.type)!=="running",u=i.text.length-l.text.length;!s.current&&!c&&u>=Ban&&(s.current=!0);const d=s.current,f=Van(i.text,{enabled:d,isComplete:c}),g=d?f:l.text,b=d?!c||g!==i.text:((S=l.status)==null?void 0:S.type)==="running",v=_.useCallback(async E=>{const{downloadSandboxFile:A,toaster:T}=r.current;try{Wan(await A(E),Gan(E))}catch(C){T!=null?T.showError(C):console.error("Failed to download sandbox artifact",C)}},[]),y=_.useMemo(()=>h.jsx(e,{content:g,isStreaming:b,onDownloadArtifact:v}),[e,g,b,v]);return o==null?y:h.jsx(ken,{turnId:o,children:h.jsx(Ten,{load:a,children:y})})}function Kan(){const e=Ge("ContextCompactionCard"),t=Ve(o=>o.part),[n,r]=_.useState(!1);return t.type!=="data"||t.name!==Zk||!m4e(t.data)?null:h.jsx(e,{data:t.data,expanded:n,onToggle:()=>r(o=>!o)})}function Yan(){const e=Ge("AttachmentCard"),t=Ge("AttachmentPreviewDialog"),n=Ve(a=>a.part.type==="image"?a.part.image:""),r=Ve(a=>a.part.type==="image"?a.part.filename:void 0);if(!n)return null;const o=h.jsx(e,{name:r??"image",previewSrc:n,isImage:!0,size:"preview",previewRem:O6e});return h.jsx(t,{previewSrc:n,children:h.jsx("div",{className:"aui-message-image",children:o})})}var Jze=_.createContext(!1);function Zan(){return _.useContext(Jze)}function Xan(e){const t=Ge("SandboxToolCallCard"),[n,r]=_.useState("terminal"),o=_.useMemo(()=>n==="code"?!!(e.argsJson||e.resultJson):!!(e.command||e.resultText||e.resultJson),[e.argsJson,e.command,e.resultJson,e.resultText,n]);return h.jsx(t,{...e,viewMode:n,hasContent:o,onViewModeChange:r})}var e8e=_.createContext(!1);function t8e(){return _.useContext(e8e)}var dc={APPROVE_ONCE:"approve-once",APPROVE_SESSION:"approve-session",APPROVE_TEN_MINUTES:"approve-10-minutes",DENY:"deny"},qan=600*1e3,lN=[{id:dc.APPROVE_ONCE,label:"Approve once",isAllow:!0},{id:dc.APPROVE_TEN_MINUTES,label:"Approve this tool for next 10 minutes",isAllow:!0},{id:dc.APPROVE_SESSION,label:"Approve this tool in this session",isAllow:!0},{id:dc.DENY,label:"Deny",isAllow:!1,requiresReason:!0}],Qan=new Set([dc.APPROVE_SESSION,dc.APPROVE_TEN_MINUTES]);function Jan({supportsSessionPolicy:e}){return e?lN:lN.filter(t=>!Qan.has(t.id))}function ein({approvalId:e,optionId:t,reason:n,now:r=new Date}){switch(t){case dc.APPROVE_ONCE:return{approvalId:e,approved:!0};case dc.APPROVE_TEN_MINUTES:return{approvalId:e,approved:!0,policy:{type:wie.ALLOW_SESSION,expireAt:new Date(r.getTime()+qan).toISOString()}};case dc.APPROVE_SESSION:return{approvalId:e,approved:!0,policy:{type:wie.ALLOW_SESSION}};case dc.DENY:return{approvalId:e,approved:!1,...n==null?{}:{reason:n}}}}function tin({approvalId:e,toolName:t="",argsText:n,supportsSessionPolicy:r=!1,onRespond:o}){const a=Ge("ToolApprovalBar"),i=_3(),{mcpServer:s,innerToolName:l}=sE(n),c=l&&s?`${l} (${s})`:t,[u,d]=_.useState(null),[f,g]=_.useState(""),[b,v]=_.useState(!1),[y,w]=_.useState(!1),S=_.useMemo(()=>Jan({supportsSessionPolicy:r}).map(P=>({...P,...P.id===dc.DENY?{confirm:{}}:{}})),[r]),E=_.useMemo(()=>S.filter(P=>P.isAllow).map((P,j)=>({...P,variant:j===0?"primary":"secondary",requiresReason:!1})),[S]),A=_.useMemo(()=>S.filter(P=>!P.isAllow).map(P=>({...P,variant:"secondary",requiresReason:P.confirm!=null})),[S]),T=A.find(P=>P.id===u),C=_.useCallback(P=>{d(P),g(""),v(!1)},[]),R=_.useCallback(P=>{g(P),v(!1)},[]),N=_.useCallback(async(P,j)=>{if(!i||y)return!1;w(!0);try{return await o(ein({approvalId:e,optionId:P.id,...j==null?{}:{reason:j}})),!0}catch{return!1}finally{w(!1)}},[e,i,y,o]),O=_.useCallback(()=>{if(!i||y)return;const P=f.trim();if(!P){v(!0);return}const j=lN.find(D=>D.id===u);j!=null&&N(j,P).then(D=>{D&&C(null)})},[i,f,y,C,u,N]);return h.jsx(a,{toolName:c,approveOptions:E.length>0?E:void 0,denyOptions:A.length>0?A:void 0,selectedDenyOption:T,denialReason:f,showReasonError:b,disabled:!i||y,onSelect:P=>{const j=lN.find(D=>D.id===P);j!=null&&N(j)},onDenyOptionChange:C,onDenialReasonChange:R,onReasonSubmit:O})}function v$(e){const t=Ge("ToolCallContentBlock"),{isJson:n,onContentHeightChange:r,resizable:o}=e,[a,i]=_.useState(!1),[s,l]=_.useState(),c=_.useRef(null),u=_.useRef(null),d=_.useRef(!1),f=_.useCallback(b=>{var y;if((y=c.current)==null||y.disconnect(),c.current=null,u.current=b,d.current=!1,b==null||(l(void 0),!o))return;const v=()=>{if(!d.current&&n!==!1)return;const w=b.getBoundingClientRect().height,S=d.current&&w>0?w:b.scrollHeight;d.current=!0,l(S/16)};v(),c.current=new ResizeObserver(v),c.current.observe(b)},[n,o]),g=_.useCallback(b=>{const v=u.current;if(v==null)return;const y=v.getBoundingClientRect().height;d.current=!0,l((y>0?y:Math.max(b,v.scrollHeight))/16),r==null||r(b)},[r]);return _.useEffect(()=>()=>{var b;(b=c.current)==null||b.disconnect()},[]),h.jsx(t,{...e,fullscreen:a,onFullscreenChange:i,contentHeightRem:s,contentRef:f,onContentHeightChange:g})}function nin(e){var o;let t=!1,n=!1,r=!1;for(const a of e){const i=(o=a.status)==null?void 0:o.type;if(i==="running"||i==="requires-action"){t=!0;continue}if(a.isError===!0||i==="incomplete"){n=!0;continue}i==="complete"&&(r=!0)}return t?"running":n?"error":r?"success":"idle"}function n8e({children:e,group:t}){const n=Ge("ToolGroupCard"),r=t.indices.length,o=Ve(c=>{const u=t.indices.map(d=>c.message.parts[d]).filter(d=>d!=null&&d.type==="tool-call");return nin(u)}),[a,i]=_.useState(!0),[s,l]=_.useState(o);return o!==s&&(l(o),o==="running"&&i(!0)),h.jsx(n,{toolCallCount:r,expanded:a,status:o,onToggle:()=>i(c=>!c),children:e})}function rin(){const e=Ge("AssistantMessageBubble"),t=Ge("StepTreeItem"),n=Ve(a=>a.message.parts),r=Ve(a=>Zze(a.message.metadata.custom)),o=a=>{const i=hB({part:a,parts:n,parallelToolGroups:r});return i!=null?[i]:null};return h.jsx("div",{className:"mb-3 min-w-0",children:h.jsx(nm.Root,{"data-role":"assistant",children:h.jsx(e,{children:h.jsx("div",{className:"flex min-w-0 flex-col","data-slot":"step-tree",children:h.jsx(nm.GroupedParts,{groupBy:o,indicator:"never",children:({part:a,children:i})=>{if(Xze(a))return h.jsx(t,{children:h.jsx(n8e,{group:a,children:i})});if(a.type==="text"||a.type==="reasoning"||a.type==="tool-call"||a.type==="image"||a.type==="data"){const s=h.jsx(r8e,{part:a});if(hB({part:a,parts:n,parallelToolGroups:r})!=null)return s;const l=a.type==="tool-call"||a.type==="data";return h.jsx(t,{branch:l,children:s})}return null}})})})})})}function cC({part:e}){var l;const t=Zan(),n=dYt(),{pending:r}=uYt(),o=us(),a=e.approval;if(a==null)return null;const i=((l=r.find(c=>c.approvalId===a.id))==null?void 0:l.policyTarget)!=null,s=async c=>{o(io.Tool.APPROVAL_RESOLVED,{tool_name:e.toolName,option_id:c.optionId??(c.approved?"__allow":"__deny"),approved:c.approved,has_reason:c.reason!=null&&c.reason.trim().length>0,nested:t}),await n({...c,approvalId:a.id})};return h.jsx(tin,{approvalId:a.id,toolName:e.toolName,argsText:e.argsText,supportsSessionPolicy:i,onRespond:s})}function y$({request:e,response:t}){return{requestSlot:e.value?h.jsx(v$,{title:"Request",content:e.value,isJson:e.isJson,maxHeight:"10.5rem"}):t.data?h.jsx(v$,{title:"Request",content:"{}",isJson:!0,maxHeight:"10.5rem"}):void 0,responseSlot:t.data?h.jsx(v$,{title:"Response",content:t.data,isJson:t.isJson,resizable:!0}):void 0}}var oin=e=>{var C,R,N,O,P,j,D,z;const t=Ge("ToolCallCard"),n=Ge("SubAgentCard"),r=Ge("AskUserPrompt"),o=t8e(),a=ict(),i=((C=e.status)==null?void 0:C.type)==="requires-action",s=e.toolName===iE,l=eee.has(e.toolName),[c,u]=_.useState(i),[d,f]=_.useState(i);i!==d&&(f(i),i&&u(!0));const g=i&&Dze(e.approval),b=a===void 0?void 0:_on(a),v=Son((R=e.status)==null?void 0:R.type),y=()=>u(L=>!L),w=_.useCallback(()=>u(!0),[]);if(Mon(s?e.toolCallId:"",w),e.toolName===Pze){const{question:L,options:$=[]}=xon(e.argsText),U=won(e.result);if(U!=null){const V=$.length>0&&!$.includes(U);return h.jsx(r,{questions:[],answeredQuestions:[{id:e.toolCallId,question:L??"Question",options:$,answer:U,isCustom:V}],onSubmit:()=>{},readOnly:!0})}if(!o)return null;const B={id:e.toolCallId,question:L??"Question",options:$};return h.jsx(r,{questions:[B],currentQuestion:B,currentAnswer:{radioValue:"",custom:""},onSubmit:()=>{},readOnly:!0})}if(s){const{agentName:L,instruction:$,stepCount:U}=Eon(e);return h.jsx("div",{"data-slot":"tool-call-card","data-variant":"sub-agent",className:"w-full",children:h.jsx(n,{status:v,expanded:c,onToggle:y,durationText:b,activityText:Qze(((O=(N=e.messages)==null?void 0:N[e.messages.length-1])==null?void 0:O.content)??[]),agentName:L,instruction:$,stepCount:U,children:h.jsx(Jze.Provider,{value:!0,children:h.jsx(olt.Messages,{components:{AssistantMessage:rin,UserMessage:()=>null}})})})})}const S=e.result===void 0?void 0:typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2);if(l){const{command:L,intent:$,argsJson:U}=nee(e.argsText),{exitCode:B,resultText:V,resultJson:G}=kon(S);return h.jsx(Xan,{name:e.toolName,intent:$,status:v,expanded:c,onToggle:y,durationText:b,command:L,exitCode:B,argsJson:U,resultText:V,resultJson:G,approvalSlot:g?h.jsx(cC,{part:e}):void 0,approvalId:g?(P=e.approval)==null?void 0:P.id:void 0})}if(tee.has(e.toolName)){const{mcpServer:L,innerToolName:$,input:U}=sE(e.argsText),B=o1(e.argsText),V=lwe(e.result);if(e.toolName==="list_tools"&&L){const Z=y$({request:B,response:V});return h.jsx(t,{toolName:`Listing tools · ${L}`,icon:"mcp-server",expanded:c,onToggle:y,awaiting:v==="running",awaitingText:b??"Awaiting Response…",showResponseLine:v!=="running"&&!!V.data,mcpServerName:L,...Z,approvalSlot:g?h.jsx(cC,{part:e}):void 0,approvalId:g?(j=e.approval)==null?void 0:j.id:void 0})}const G=U!==void 0?o1(JSON.stringify(U,null,2)):B,F=y$({request:G,response:V});return h.jsx(t,{toolName:Lze(e.toolName,L,$),icon:"mcp-server",expanded:c,onToggle:y,awaiting:v==="running",awaitingText:b??"Awaiting Response…",showResponseLine:v!=="running"&&V.data!==void 0,mcpServerName:L,...F,approvalSlot:g?h.jsx(cC,{part:e}):void 0,approvalId:g?(D=e.approval)==null?void 0:D.id:void 0})}const E=o1(e.argsText),A=lwe(e.result),T=y$({request:E,response:A});return h.jsx(t,{toolName:e.toolName,expanded:c,onToggle:y,awaiting:v==="running",awaitingText:b??"Awaiting Response…",showResponseLine:v!=="running"&&A.data!==void 0,...T,approvalSlot:g?h.jsx(cC,{part:e}):void 0,approvalId:g?(z=e.approval)==null?void 0:z.id:void 0})};function r8e({part:e}){switch(e.type){case"text":case"reasoning":return h.jsx(gB,{});case"image":return h.jsx(Yan,{});case"tool-call":return h.jsx(oin,{...e});case"data":return e.name===Zk?h.jsx(Kan,{}):null;default:return null}}function ain({group:e}){const t=Ge("ReasoningCard"),n=Ve(y=>e.indices.map(w=>y.message.parts[w]).filter(w=>w!=null&&w.type==="reasoning").map(w=>w.text??"").join("")),r=Ve(y=>{var E,A;if(((E=y.message.status)==null?void 0:E.type)!=="running")return!1;const w=y.message.parts.length-1;if(w<0||((A=y.message.parts[w])==null?void 0:A.type)!=="reasoning")return!1;const S=e.indices[e.indices.length-1];return S!==void 0&&w>=e.indices[0]&&w<=S}),[o,a]=_.useState(r),[i,s]=_.useState(r),[l,c]=_.useState(!1),u=_.useRef(null);r!==i&&(s(r),r&&a(!0));const d=_.useCallback(y=>{var S;if((S=u.current)==null||S.disconnect(),u.current=null,y==null||r)return;const w=()=>{const E=Number.parseFloat(getComputedStyle(y).lineHeight)||24;c(y.scrollHeight>E*1.5)};w(),u.current=new ResizeObserver(w),u.current.observe(y)},[r]),f=null,g=n.replace(/\s+/g," ").trim(),b=!r&&n.length>0&&!l;return h.jsx(t,{content:n,isStreaming:r,expanded:o,isMultiLine:l,reasoningTimeText:f,previewText:g,headingText:"Reasoning",contentRef:b?d:void 0,onToggle:()=>a(y=>!y)})}function iin(e){switch(e){case void 0:return"Response stopped";case vf.CLIENT_CANCELLED:return"You stopped this response";case vf.SERVER_EXECUTION_TIMEOUT:return"Response timed out";case vf.ABANDONED:return"Response was interrupted";case vf.CANCELLED_FOR_NEXT_TURN:return"Stopped for a newer message";default:return e}}function sin(){var U;const e=Ge("AssistantMessageBubble"),t=Ge("MessageActionBar"),n=Ge("MessageErrorBanner"),r=Ge("MessageCancelledBanner"),o=Ge("MessageIndicator"),a=OH(),i=fYt(),s=Uke(),l=Ve(B=>B.message.createdAt),c=Ve(B=>B.threadListItem.remoteId),u=Ve(B=>{var V;return((V=B.message.status)==null?void 0:V.type)==="running"}),d=Ve(B=>B.message.status),f=Ve(B=>{var G,F;const V=(F=(G=B.message.metadata)==null?void 0:G.custom)==null?void 0:F[c3];return typeof V=="string"?V:void 0}),g=t8e(),b=us(),v=go(),y=(v==null?void 0:v.mode.status)==="active"?{agentId:v.mode.agentId,agentName:v.mode.agentName}:{},{copy:w,isCopied:S}=$ke({copyToClipboard:B=>navigator.clipboard.writeText(B)}),E=()=>{b(io.Message.COPIED,my({role:"assistant"},{sessionId:c,...y})),w()},A=Ve(B=>B.message.parts),T=Ve(B=>Zze(B.message.metadata.custom)),C=(d==null?void 0:d.type)==="incomplete"&&d.reason==="cancelled",R=C&&!g&&f===vf.CANCELLED_FOR_NEXT_TURN,N=C&&!R?iin(f):void 0,{cutIndex:O,hasFinal:P,toolCount:j,thinkingCount:D}=Oan(A,u),z=u&&a&&!i&&((U=A[A.length-1])==null?void 0:U.type)!=="text",L=Nan({label:Uan(A),activityKey:z?zan(A):null,progressKey:z?$an(A):null}),$=(B,V)=>{const G=A.findIndex(F=>F===B);if(G===-1||B.type==="text"&&G>=O)return null;if(G<O){if(B.type==="reasoning")return["group-agentSteps","group-reasoning"];const F=hB({part:B,parts:A,parallelToolGroups:T});return F!=null?["group-agentSteps",F]:["group-agentSteps"]}return null};return R&&A.length===0&&s===void 0?null:h.jsx(nm.Root,{"data-role":"assistant",children:h.jsxs(e,{error:s!==void 0?h.jsx(n,{message:String(s)}):void 0,statusBanner:N!==void 0?h.jsx(r,{message:N}):void 0,actionBar:a?void 0:h.jsx(t,{isCopied:S,onCopy:E,createdAt:l}),children:[h.jsx(nm.GroupedParts,{groupBy:$,indicator:"never",children:({part:B,children:V})=>{switch(B.type){case"group-agentSteps":return h.jsx(Fan,{toolCount:j,thinkingCount:D,hasFinal:P,children:V});case"group-reasoning":return h.jsx(ain,{group:B});case"text":{const G=A.findIndex(F=>F===B);return G>=0&&G<O?h.jsx("div",{className:"mb-2 ml-[1.75rem] text-xs text-text-secondary [&_.markdown-body]:text-inherit",children:h.jsx(gB,{})}):h.jsx(gB,{})}case"reasoning":case"tool-call":case"image":case"data":return h.jsx(r8e,{part:B});default:return Xze(B)?h.jsx(n8e,{group:B,children:V}):null}}}),z?h.jsx(o,{label:L}):null]})})}function lin({messages:e,slotOverrides:t,children:n}){const r=pke({messages:e,isRunning:!1,convertMessage:a=>a,onNew:async()=>{}}),o=h.jsx(e8e.Provider,{value:!0,children:h.jsx(hAe,{runtime:r,children:n})});return t==null?o:h.jsx(a1,{overrides:t,children:o})}function cN(e,t){return e==="image"||((t==null?void 0:t.startsWith("image/"))??!1)}function cin(e){const[t,n]=_.useState(void 0);return _.useLayoutEffect(()=>{if(!e){n(void 0);return}const r=URL.createObjectURL(e);return n(r),()=>URL.revokeObjectURL(r)},[e]),t}function o8e(){const e=Ve(i=>i.attachment.type),t=Ve(i=>i.attachment.contentType),n=Ve(i=>"file"in i.attachment?i.attachment.file:void 0),r=Ve(i=>{var l;if(!cN(i.attachment.type,i.attachment.contentType))return;const s=(l=i.attachment.content)==null?void 0:l.find(c=>c.type==="image");if((s==null?void 0:s.type)==="image"&&s.image)return s.image}),o=cN(e,t),a=cin(o?n:void 0);if(o)return a??r}function uin(e){const t=e.indexOf(",");if(t<0||!e.slice(0,t).endsWith(";base64"))return;const n=e.slice(t+1).replace(/\s/g,""),r=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.max(0,Math.floor(n.length*3/4)-r)}function a8e(){const e=Ve(n=>{var r;return"file"in n.attachment?(r=n.attachment.file)==null?void 0:r.size:void 0}),t=Ve(n=>{var o;const r=(o=n.attachment.content)==null?void 0:o.find(a=>a.type==="file");return(r==null?void 0:r.type)==="file"?r.data:void 0});return e??(t==null?void 0:uin(t))}function din(){const e=Ge("AttachmentPreviewDialog"),t=Ge("AttachmentCard"),n=pn(),r=Ve(c=>c.attachment.name),o=Ve(c=>c.attachment.contentType),a=Ve(c=>c.attachment.type),i=cN(a,o),s=o8e(),l=a8e();return h.jsx(e,{previewSrc:s,children:h.jsx(t,{name:r,contentType:o,sizeBytes:l,previewSrc:s,isImage:i,size:"chip",onRemove:()=>void n.attachment().remove()})})}function bwe({kind:e}){const t=Ge("AttachmentPreviewDialog"),n=Ge("AttachmentCard"),r=Ve(d=>d.attachment.name),o=Ve(d=>d.attachment.contentType),a=Ve(d=>d.attachment.type),i=cN(a,o),s=o8e(),l=a8e(),c=i&&s!=null;if(e==="image"!==c)return null;const u=h.jsx(n,{name:r,contentType:o,sizeBytes:l,previewSrc:s,isImage:i,size:i?"preview":"chip",previewRem:O6e});return c&&s?h.jsx(t,{previewSrc:s,children:u}):u}function Fyn(){return h.jsx("div",{className:"aui-composer-attachments aui-scrollbar-hidden flex w-full min-w-0 flex-row flex-nowrap items-center gap-2 overflow-x-auto overflow-y-hidden empty:hidden",children:h.jsx(Zst.Attachments,{children:()=>h.jsx(din,{})})})}var vwe="flex flex-row flex-wrap justify-end gap-2 empty:hidden";function pin(){return h.jsxs("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-col items-end gap-2",children:[h.jsx("div",{className:vwe,children:h.jsx(nm.Attachments,{children:()=>h.jsx(bwe,{kind:"image"})})}),h.jsx("div",{className:vwe,children:h.jsx(nm.Attachments,{children:()=>h.jsx(bwe,{kind:"file"})})})]})}function fin(){const e=Ge("UserMessageBubble"),t=Ge("UserMessageActionBar"),n=OH(),r=_3(),o=pn(),a=us(),i=go(),s=Ve(y=>y.message.createdAt),l=Ve(y=>y.threadListItem.remoteId),c=Ve(y=>y.message.content.filter(w=>w.type==="text").map(w=>w.text).join(`
1102
- `)),{edit:u,disabled:d}=JZe(),{copy:f,isCopied:g}=$ke({copyToClipboard:y=>navigator.clipboard.writeText(y)}),b=(i==null?void 0:i.mode.status)==="active"?{agentId:i.mode.agentId,agentName:i.mode.agentName}:{},v={sessionId:l,...b};return h.jsx(nm.Root,{"data-role":"user",children:h.jsx(e,{text:c,attachments:h.jsx(pin,{}),editAction:n?void 0:h.jsx(t,{isCopied:g,editDisabled:d||!r,retryDisabled:!r,createdAt:s,onCopy:()=>{a(io.Message.COPIED,my({role:"user"},v)),f()},onEdit:()=>{a(io.Message.EDIT_STARTED,my(void 0,v)),u()},onRetry:()=>{r&&(a(io.Message.RETRIED,my(void 0,v)),o.message().composer().beginEdit(),o.message().composer().send({startRun:!0}))}})})})}function hin(e){return h.jsx(wze,{...e,readOnly:!0,onDownloadArtifact:void 0,sandboxDownloadReadOnlyTooltip:"Download File is not available in read-only mode"})}function gin({isCopied:e,onCopy:t,createdAt:n,className:r}){return h.jsx(_ze,{isCopied:e,onCopy:t,createdAt:n,className:r})}function min(e){return h.jsx(Oze,{...e,readOnly:!0})}function bin(e){return h.jsx($ze,{...e,awaiting:e.approvalSlot?!1:e.awaiting})}function vin(e){const t=Ge("McpAuthPrompt"),n=Ve(a=>a.message.metadata.custom),r=(n==null?void 0:n.pendingMcpAuth)===!0?n==null?void 0:n.mcpServers:void 0,o=zS(r)?r:void 0;return h.jsxs(M6e,{...e,children:[e.children,o!=null&&o.length>0?h.jsx(t,{servers:o,readOnly:!0,onConnect:()=>{}}):null]})}var yin={AssistantMessageBubble:vin,UserMessageActionBar:gin,Markdown:hin,ToolApprovalBar:min,ToolCallCard:bin};function xin(e){const t=e.id??"";return e.role==="user"?t.replace(/-user$/,""):t.replace(/-assistant$/,"")}function win(e,t){const n=new Map(t.flatMap(r=>(r.created.input??[]).some(a=>a.type==="user.message")?[]:[[r.turnId,Wze(r)]]));return e.map(r=>{if(r.event.type!=="turn.created")return r;const o=n.get(r.turnId);if(o===void 0)return r;const a={type:"user.message",content:o};return{...r,event:{...r.event,input:[...r.event.input??[],a]}}})}function _in(e,t){var l,c,u;const n=(l=t.done)==null?void 0:l.state;if((n==null?void 0:n.status)!=="error"&&(n==null?void 0:n.status)!=="cancelled")return e;const r=e.findIndex(d=>d.role==="assistant"),o=r<0?void 0:e[r],a=new Date(n.completedAt??((c=t.done)==null?void 0:c.createdAt)??t.created.createdAt),i=o??{id:`${t.turnId}-assistant`,role:"assistant",content:[],createdAt:a,metadata:{custom:{turnId:t.turnId}}},s=n.status==="error"?{...i,status:{type:"incomplete",reason:"error",error:n.message}}:{...i,status:{type:"incomplete",reason:"cancelled"},metadata:{...i.metadata,custom:{...(u=i.metadata)==null?void 0:u.custom,[c3]:n.reason}}};return r<0?[...e,s]:e.map((d,f)=>f===r?s:d)}function Sin(e){const t=e.done;if((t==null?void 0:t.state.status)==="done"){const n=t.state.requiredActions;if(!Array.isArray(n))return;for(const r of n)if(r.type==="mcp.auth_required"&&zS(r.mcpServers))return r.mcpServers;return}if(t==null){for(const n of e.events)if(n.type==="mcp.auth_required"&&zS(n.mcpServers))return n.mcpServers}}function kin(e,t){var s,l,c;const n=Sin(t);if(n==null||n.length===0)return e;const r=e.findIndex(u=>u.role==="assistant"),o=r<0?void 0:e[r],a=new Date(((s=t.done)==null?void 0:s.createdAt)??t.created.createdAt),i={...o??{id:`${t.turnId}-assistant`,role:"assistant",content:[],createdAt:a},...((l=t.done)==null?void 0:l.state.status)==="done"?{status:{type:"complete",reason:"stop"}}:{},metadata:{...o==null?void 0:o.metadata,custom:{...(c=o==null?void 0:o.metadata)==null?void 0:c.custom,turnId:t.turnId,pendingMcpAuth:!0,mcpServers:n}}};return r<0?[...e,i]:e.map((u,d)=>d===r?i:u)}function Ein(e,t){var r,o;if(xin(e)===t)return!0;const n=(o=(r=e.metadata)==null?void 0:r.custom)==null?void 0:o.turnId;return typeof n=="string"&&n===t}function Tin(e,t){const n=e.filter(a=>Ein(a,t.turnId)),r=kin(n,t),o=_in(r,t);return t.done!=null?o:o.map(a=>{var i;return a.role!=="assistant"||((i=a.status)==null?void 0:i.type)!=="running"?a:{...a,status:{type:"complete",reason:"stop"}}})}function Ain({sessionId:e,events:t,contentMaxWidth:n,sessionMetrics:r}){const o=I0(),a=Ge("AgentSessionTurnHeader"),i=Ge("AgentSessionEventTimeline"),s=Ge("AgentSessionMetricsStrip"),l=Ge("MessageListSkeleton"),c=Ge("ThreadViewportShell"),[u,d]=_.useState(),[f,g]=_.useState(!1),b=_.useRef(new Map),v=_.useMemo(()=>NJt(t),[t]),y=_.useMemo(()=>v.filter(N=>N.renderable),[v]),w=_.useMemo(()=>win(t,y),[t,y]),S=_.useMemo(()=>can(v),[v]),[E,A]=_.useState(()=>Date.now());_.useEffect(()=>{if(!S)return;A(Date.now());const N=window.setInterval(()=>A(Date.now()),1e3);return()=>window.clearInterval(N)},[S,v]);const T=_.useMemo(()=>San(v,{nowMs:E}),[v,E]),C=_.useMemo(()=>jJt({turns:v,segments:T,sessionMetrics:r}),[r,T,v]),R=_.useCallback(N=>{var O;(O=b.current.get(N))==null||O.scrollIntoView({behavior:"smooth",block:"start"})},[]);return _.useEffect(()=>{let N=!1;d(void 0),g(!1);const O=Can(w),P={...o,listEvents:j=>O.listEvents(j),listTurns:async()=>({data:[]})};return HKt(P,e).then(j=>{N||d(j.messages)}).catch(()=>{N||g(!0)}),()=>{N=!0}},[w,o,e]),f?h.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session messages could not be loaded."}):u===void 0?h.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-4",children:h.jsx(l,{})}):y.length===0?h.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"This session has no messages yet."}):h.jsxs("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain","data-slot":"agent-session-scroll",children:[h.jsx("div",{className:"sticky top-0 z-20 bg-primary-bg","data-slot":"agent-session-metrics-sticky",children:h.jsx(s,{metrics:C})}),h.jsx("div",{className:"border-b border-border",children:h.jsx(_.Suspense,{fallback:null,children:h.jsx(i,{turns:v,segments:T,onSelectTurn:R})})}),h.jsx(c,{scrollable:!1,className:"pb-4",...n==null?{}:{contentMaxWidth:n},children:h.jsx("div",{className:"flex flex-col gap-4",children:y.map(N=>h.jsx(Cin,{turn:MJt(v,N.turnNumber)??N,messages:Tin(u,N),AgentSessionTurnHeader:a,onMount:O=>{O==null?b.current.delete(N.turnNumber-1):b.current.set(N.turnNumber-1,O)}},N.turnId))})})]})}function Cin({turn:e,messages:t,AgentSessionTurnHeader:n,onMount:r}){const o=e.done==null;return!e.showHeader&&t.length===0&&!o?null:h.jsxs("section",{ref:r,id:`session-turn-${e.turnNumber}`,className:"flex flex-col gap-2",children:[e.showHeader?h.jsx(n,{turnNumber:e.turnNumber,totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cachedTokens:e.cachedTokens,cacheReadTokens:e.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens,inputTokensBreakdown:e.inputTokensBreakdown,durationMs:e.durationMs,totalCostInUsd:e.totalCostInUsd,modelName:e.modelName}):null,t.length>0?h.jsx(lin,{slotOverrides:yin,messages:t,children:h.jsx(Vse.Root,{asChild:!0,children:h.jsx("div",{className:"aui-root aui-thread-root flex w-full flex-col",children:h.jsx(Vse.Messages,{children:({message:a})=>a.role==="user"?h.jsx(fin,{}):h.jsx(sin,{})})})})}):null,o?h.jsx("div",{role:"status",className:"border-warning-bg bg-warning-bg/10 text-warning-bg inline-flex w-fit max-w-full items-center gap-3 rounded-xl border px-3 py-1.5 text-sm font-medium leading-[1.4]",children:"Turn is still in running, all events might not be visible"}):null]})}var Rin=_.lazy(()=>Ya(()=>import("./AgentOverview-ZSZENAFZ-D0HM5BSW.js"),[],import.meta.url)),Iin=_.lazy(async()=>({default:(await Ya(()=>import("./AgentSessions-W2EDVBCS-lqR7dkcO.js"),__vite__mapDeps([2,3]),import.meta.url)).AgentSessions})),Nin=_.lazy(()=>Ya(()=>import("./AgentCodeSnippets-D2J3IH37-CQZZoOBC.js"),[],import.meta.url)),Min=_.lazy(async()=>({default:(await Ya(()=>import("./SchedulesPage-OVDMYD6Q-DWmVgOrq.js"),__vite__mapDeps([4,5]),import.meta.url)).SchedulesPage})),Oin=_.lazy(async()=>({default:(await Ya(()=>import("./EnvironmentsPage-BUA2EGXE-Dt-L2w8t.js"),__vite__mapDeps([6,7,5]),import.meta.url)).EnvironmentsPage})),Pin=_.lazy(async()=>({default:(await Ya(()=>import("./AgentSessionEventTimeline-26TTGY3F-6FMUgy7r.js"),[],import.meta.url)).AgentSessionEventTimeline})),jin=_.lazy(async()=>({default:(await Ya(()=>import("./AgentSessionEventTimelineChart-SV6ZYNU2-CNDMPnla.js"),[],import.meta.url)).AgentSessionEventTimelineChart})),Din=_.lazy(async()=>({default:(await Ya(()=>import("./AgentMetricChart-TCZEIIUV-5Rtf3TvY.js"),[],import.meta.url)).AgentMetricChart})),i8e={Accordion:ZLe,AccordionSummary:XLe,AccordionDetails:qLe,BrandLogo:jJ,ComposerShell:ntn,ComposerLeftSection:Jen,ComposerRightSection:etn,ComposerSendButton:ttn,PermissionGuard:mrn,DraftComposerLeftSection:Ann,DraftComposerRightSection:Cnn,DraftAgentConfigTrigger:Snn,DraftCapabilitiesPanel:knn,DraftComposerActionsMenu:Enn,AgentCustomParametersEditor:jtn,AgentConfigEditors:ftn,AgentInstructionsDrawer:Ltn,InstructionsFullScreenEditor:Pnn,InstructionsMarkdownEditor:Fnn,AgentModelEditorContent:tnn,AgentModelSettingsContent:onn,AgentMcpEditorContent:Vtn,AgentModelConfigModal:Gtn,AgentResourceEditorContent:inn,AgentResourceConfigModal:ann,AgentSkillsEditorContent:xnn,AgentSkillsHeaderActionSlot:dze,AgentConfigPanel:Itn,AgentConfigSection:Rtn,AgentRuntimeConfigFields:vnn,AgentRuntimeConfigDrawer:cnn,AgentRuntimeEditorContent:ynn,DraftCompositeSelector:Mnn,CatalogRow:xg,ConnectorConnectButton:sB,DraftModelSelector:Onn,AssistantMessageBubble:M6e,UserMessageBubble:Lon,UserMessageEdit:zon,UserMessageActionBar:Don,MessageActionBar:_ze,MessageCancelledBanner:orn,MessageErrorBanner:arn,MessageIndicator:irn,ResumeUnavailable:vrn,MessageTimestamp:crn,Markdown:wze,SyntaxHighlighter:ron,OpenUiFenceBlock:_De,SandboxArtifactDownload:krn,ChatFileDownload:Gen,FilePreviewPanel:Knn,MonacoEditorCore:hrn,CodeEditor:Qen,WelcomeScreen:Uze,ToolCallCard:$ze,ToolCallContentBlock:Pon,ToolApprovalBar:Oze,ToolGroupCard:jon,StepTree:gQt,StepTreeItem:hQt,SubAgentCard:qrn,SandboxToolCallCard:Trn,AgentStepsCard:Qqt,ReasoningCard:pQt,ContextCompactionCard:cQt,AskUserPrompt:iQt,McpAuthPrompt:dQt,AttachmentCard:xen,AttachmentPreviewDialog:_en,AttachmentPickerButton:wen,ScrollToBottomButton:Aze,ThreadListRow:don,ThreadListNewButton:oon,AgentsLibrary:hen,AgentLibraryRow:den,AgentLibraryUsageCells:YJt,AgentsLibraryButton:gen,ApprovalNavBanner:men,SessionsBrowserButton:Lrn,AgentDetailsPage:OQt,AgentDetailsHeader:RQt,AgentDetailsTabs:jQt,AgentDetailsUnavailable:DQt,AgentOverview:Rin,AgentOverviewCard:ZQt,AgentMetrics:$on,AgentMetricsView:YQt,AgentMetricsTimeRangeFilter:BQt,AgentMetricCard:FQt,AgentMetricStatistics:KQt,AgentMetricChart:Din,AgentSessionDetailHeader:XQt,AgentSessionsFilters:_Jt,SessionsPage:LJt,AgentSessionEventTimeline:Pin,AgentSessionEventTimelineChart:jin,AgentSessionListRow:sJt,AgentSessionMetricsStrip:bJt,AgentSessionTimelineContainer:Ain,AgentSessionTurnHeader:DJt,AgentSessions:Iin,AgentCodeSnippets:Nin,AgentCodeBlock:mQt,SchedulesPage:Min,SchedulesButton:jrn,EnvironmentsPage:Oin,EnvironmentsButton:Bnn,SaveAgentButton:Mrn,SaveAgentForm:Prn,SelectAgentEmptyState:Drn,ClearChatButton:qen,ResetAgentBuilderButton:brn,ShareChatButton:zrn,ShareSessionDialog:Yrn,ThreadListRowSkeleton:aon,ThreadListEmptyState:ion,ThreadListShell:son,HistoryLoader:fze,MessageListSkeleton:Xrn,ThreadRootShell:Rze,ThreadViewportShell:Ize,ThreadComposerAreaShell:Nze,MessageGroup:Mze,Toast:hon,ToastStack:mon,ShellActionsActionSlot:Zrn,UserAvatar:eJt},M3=_.createContext(i8e),see=_.createContext(void 0);function a1({overrides:e,theme:t,children:n}){const r=_.useContext(M3),o=_.useContext(see),a=_.useMemo(()=>({...r,...e}),[r,e]),i=h.jsx(Lin,{slots:a,inheritedTheme:o,theme:t,children:n});return t!==void 0||!(o!==void 0)?h.jsx(wv,{theme:t,children:i}):i}function Lin({slots:e,children:t,inheritedTheme:n,theme:r}){const o=AEe(),i=((r==null?void 0:r.mode)==="light"||(r==null?void 0:r.mode)==="dark"?r.mode:void 0)??n??o;return h.jsx(see.Provider,{value:i,children:h.jsx(M3.Provider,{value:e,children:t})})}function Ge(e){return _.useContext(M3)[e]}function Byn(e){return _.useContext(M3)[e]===i8e[e]}function O3(){return _.useContext(see)??"light"}var ywe={"tfg.source":"ui"};function zin({locallyCreatedSessionIds:e,children:t}){const n=Ve(r=>r.threadListItem.remoteId);return h.jsx(yQt,{sessionId:n,assumeManage:n!=null&&e.has(n),children:t})}function $in({server:e,locallyCreatedSessionIds:t}){return{...e,async createSession(n){const r=await e.createSession({...n,metadata:{...n.metadata,...ywe}});return t.add(r.id),r},async listSessions(n){const r=await e.listSessions({...n,metadata:{...n==null?void 0:n.metadata,...ywe}});return{...r,data:r.data.filter(o=>!lXe(o))}}}}function Uin({server:e,agent:t,agentName:n,listSessionsAgentId:r,initialSessionId:o,adapters:a,onError:i,children:s}){const{showError:l}=EQt(),c=i??l,d=_.useMemo(()=>({server:e,ids:new Set}),[e]).ids,f=_.useMemo(()=>$in({server:e,locallyCreatedSessionIds:d}),[d,e]),g=_.useCallback(v=>{oXe(),c(v)},[c]),b=VYt({server:f,agent:t,agentName:n,listSessionsAgentId:r,listSessionsCreatedByMe:!0,initialSessionId:o,onError:g,adapters:{...a,attachments:(a==null?void 0:a.attachments)??gWt}});return h.jsx(hAe,{runtime:b,children:h.jsx(zin,{locallyCreatedSessionIds:d,children:s})})}function Fin(e){const{server:t,initialSessionId:n,adapters:r,onError:o,children:a,agent:i,agentName:s,listSessionsAgentId:l}=e,c=_.useMemo(()=>t,[t]);return h.jsx(n6e,{children:h.jsx(Uin,{server:c,agent:i,agentName:s,listSessionsAgentId:l,initialSessionId:n,adapters:r,onError:o,children:a})})}function Bin(e){if(e.config===void 0)return;const t=Reflect.get(e.config,"sandbox");if(typeof t!="object"||t===null)return;const n=Reflect.get(t,"enabled");return typeof n=="boolean"?n:void 0}function xwe(e,t,{matchFamily:n=!1}={}){if(e===void 0)return;const r=e.filter(o=>{const a=eN(o);return a===null?!1:t.has(a)?!0:n&&t.has(Aa(a))});return r.length===e.length?e:r}function Hin(e){const t=new Set;for(const n of e)t.add(n.name),t.add(n.id),t.add(Aa(n.id));return t}function Vin(e,t){if(e===void 0)return;let n=!1;const r=e.map(o=>{const a=eN(o),i=t.find(s=>s.id===a);return i===void 0||a===i.name?o:(n=!0,{...o,id:i.id,name:i.name})});return n?r:e}function Gin({agentSpec:e,models:t,skills:n,connectors:r,skillsEnabled:o}){const a={},i=e.model.name.trim();if(!t.some(l=>l.name===i)){const l=t[0];l!==void 0&&(a.model=v0(l.name,e.model.params,l.properties.reasoningEfforts))}const s=xwe(e.mcpServers,new Set(r.map(l=>l.name)));if(s!==e.mcpServers&&(a.mcpServers=s),o===!1)e.skills!==void 0&&e.skills.length>0&&(a.skills=[]);else{const l=Vin(xwe(e.skills,Hin(n),{matchFamily:!0}),n);l!==e.skills&&(a.skills=l)}return a}function Win({agentSpec:e,sandboxEnabled:t,kind:n="agent"}){var o,a;if(n==="chat"){if(t==null)return{};const i=Bin(e);return t===!0&&i!==!0?{config:{...e.config,sandbox:{...(o=e.config)==null?void 0:o.sandbox,enabled:!0}}}:t===!1&&i===!0?{config:{...e.config,sandbox:{...(a=e.config)==null?void 0:a.sandbox,enabled:!1}}}:{}}const r=L9(e,t);return r===e?{}:{config:r.config}}function Kin({agentSpec:e,webSearchEnabled:t,previousWebSearchEnabled:n,explicitOff:r=!1,kind:o="agent"}){const a=rEe({spec:e,previousWebSearchEnabled:n,webSearchEnabled:t,explicitOff:r,kind:o}),i=Rv({spec:a,webSearchEnabled:t});return i===e?{}:{config:i.config}}function Yin({agentSpec:e,memoryEnabled:t,previousMemoryEnabled:n,explicitOff:r=!1}){var a,i,s;const o=sEe({spec:e,previousMemoryEnabled:n,memoryEnabled:t,explicitOff:r});if(t===!1&&((i=(a=o.config)==null?void 0:a.memory)==null?void 0:i.enabled)===!0){const{memory:l,...c}=o.config;return{config:c}}return t===!0&&((s=o.config)==null?void 0:s.memory)===void 0?{config:{...o.config,memory:{enabled:!0}}}:o===e?{}:{config:o.config}}function Zin(){var O,P;const{mode:e,pendingSessionId:t,rememberDraftSpec:n}=_m(),{agentSpec:r,draftSessionId:o,isSpecLoading:a}=Bu(),i=qk(),s=th(),l=s==null?void 0:s.sandbox.enabled,c=(O=s==null?void 0:s.webSearch)==null?void 0:O.enabled,u=s==null?void 0:((P=s.memory)==null?void 0:P.enabled)??!1,d=_.useRef(c),f=_.useRef(u),{models:g,skills:b,connectors:v,loaded:y,error:w,ensureLoaded:S}=JN(),E=e.status==="active"&&e.isMutable&&t==null,A=e.status==="active"?e.agentId:void 0,T=E&&A==null,C=!a,R=e.status==="active"&&e.isMutable&&e.isCreateAgent?"agent":"chat",N=R==="chat"?o!=null:A!=null;return _.useEffect(()=>{T&&S()},[S,T]),_.useEffect(()=>{T&&C&&r!=null&&n(r,R)},[r,C,T,R,n]),_.useEffect(()=>{if(!T||!C||r==null||i==null)return;const j=Win({agentSpec:r,sandboxEnabled:l,kind:R});Object.keys(j).length>0&&i(j)},[r,C,T,R,l,i]),_.useEffect(()=>{const j=f.current;if(f.current=u,!E||R!=="agent"||N||!C||r==null||i==null)return;const D=Yin({agentSpec:r,memoryEnabled:u,previousMemoryEnabled:j,explicitOff:iEe()===!1});Object.keys(D).length>0&&i(D)},[r,C,N,E,u,R,i]),_.useEffect(()=>{const j=d.current;if(d.current=c,!E||N||!C||r==null||i==null)return;const D=Kin({agentSpec:r,webSearchEnabled:c,previousWebSearchEnabled:T?j:void 0,explicitOff:T&&oEe(R)===!1,kind:R});Object.keys(D).length>0&&i(D)},[r,C,N,E,T,R,c,i]),_.useEffect(()=>{if(!T||!C||r==null||i==null||!y||w!=null)return;const j=Gin({agentSpec:r,models:g,skills:b,connectors:v,skillsEnabled:s==null?void 0:s.skill.enabled});Object.keys(j).length>0&&i(j)},[r,C,s==null?void 0:s.skill.enabled,v,w,T,y,g,b,i]),null}function Xin(){const e=go(),t=pn(),n=e==null?void 0:e.pendingSessionId,r=(e==null?void 0:e.pendingSessionEpoch)??0;return _.useEffect(()=>{n==null||(e==null?void 0:e.sessionAccessError)!=null||Promise.resolve(t.threads().switchToThread(n)).catch(()=>{})},[t,n,r,e==null?void 0:e.sessionAccessError]),null}function qin(){const{openLibraryAgent:e,openSharedSession:t,setSessionsOpen:n}=_m(),r=N0(),o=ck({sessions:r});return _.useEffect(()=>{if(!o)return;const a=Nd(window.location.search);if(a.view===ZN&&a.sessionId!=null){t(a.sessionId);return}if(a.view==="sessions"){n(!0);return}a.agentId!=null&&e(a.agentId)},[e,t,o,n]),null}function Qin({onRemoteIdChange:e}){const t=Ve(n=>n.threadListItem.remoteId);return _.useEffect(()=>{e(t??void 0)},[t,e]),null}var Jin=3e4;function esn(){return new Map}function tsn(e){const t={...e};return delete t.startTimestamp,JSON.stringify(t,Object.keys(t).sort())}function nsn({server:e,cache:t}){const{deleteSession:n,renameSession:r}=e;return{...e,listSessions(o){const a=tsn(o),i=Date.now(),s=t.get(a);if(s!==void 0&&i-s.at<Jin)return s.page;const l=e.listSessions(o);return t.set(a,{at:i,page:l}),l.catch(()=>{var c;((c=t.get(a))==null?void 0:c.page)===l&&t.delete(a)}),l},async createSession(o){const a=await e.createSession(o);return t.clear(),a},async updateSession(o){const a=await e.updateSession(o);return t.clear(),a},...n!=null?{deleteSession:async o=>{await n.call(e,o),t.clear()}}:{},...r!=null?{renameSession:async o=>{await r.call(e,o),t.clear()}}:{}}}var rsn={data:{sandbox:{enabled:!0},skill:{enabled:!0},settings:{modelProviders:{enabled:!0,manageProviders:!0},mcpServers:{enabled:!0,manageProviders:!0},skills:{enabled:!0,manageProviders:!0},sandboxProviders:{enabled:!0,manageProviders:!0},webSearch:{enabled:!0,manageProviders:!0},memoryProviders:{enabled:!0,manageProviders:!0}},webSearch:{enabled:!1},sessionSharing:{granularity:"tenant"}}};function wwe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="trueforge"}function osn(e){return typeof Reflect.get(e,"getCapabilities")=="function"}function asn(e,t,n){const r=osn(e)?()=>e.getCapabilities():async()=>rsn,a={...{...e,getCapabilities:r}};if(!isn(a))throw new Error("TrueForgeUI: runtime adapter returned an incomplete AgentUIServer");return a}function isn(e){return typeof Reflect.get(e,"createSession")=="function"&&typeof Reflect.get(e,"listSessions")=="function"&&typeof Reflect.get(e,"getSession")=="function"&&typeof Reflect.get(e,"updateSession")=="function"&&typeof Reflect.get(e,"createTurn")=="function"&&typeof Reflect.get(e,"cancelSession")=="function"&&typeof Reflect.get(e,"listTurns")=="function"&&typeof Reflect.get(e,"getTurn")=="function"&&typeof Reflect.get(e,"listEvents")=="function"&&typeof Reflect.get(e,"getCapabilities")=="function"&&typeof Reflect.get(e,"getModels")=="function"&&typeof Reflect.get(e,"getSkills")=="function"&&typeof Reflect.get(e,"getMcp")=="function"&&typeof Reflect.get(e,"searchAgents")=="function"&&typeof Reflect.get(e,"saveAgent")=="function"}function ssn(e,t){const n=wwe(e)?e:null,r=wwe(e)?null:e,o=(n==null?void 0:n.baseUrl)??"",a=(n==null?void 0:n.token)??"",i=n==null?void 0:n.fetch,s=n==null?void 0:n.catalog,l=n==null?void 0:n.permissions,[c,u]=_.useState(()=>r?{status:"ready",server:r,error:null}:{status:"loading",server:null,error:null});return _.useEffect(()=>{if(r){u({status:"ready",server:r,error:null});return}let d=!1;return u({status:"loading",server:null,error:null}),(async()=>{const{createTrueForgeAgentUIServer:g}=await Ya(async()=>{const{createTrueForgeAgentUIServer:b}=await Promise.resolve().then(()=>vhn);return{createTrueForgeAgentUIServer:b}},void 0,import.meta.url);return g({...o?{baseUrl:o}:{},...a?{token:a}:{},...i!==void 0?{fetch:i}:{},...s!=null?{catalog:s}:{},...l!=null?{permissions:l}:{}})})().then(g=>{if(!d)try{u({status:"ready",server:asn(g,void 0,void 0),error:null})}catch(b){t==null||t(b),u({status:"error",server:null,error:b})}}).catch(g=>{d||(t==null||t(g),u({status:"error",server:null,error:g}))}),()=>{d=!0}},[r,o,a,i,s,l,t]),c}var lsn=_.lazy(()=>Ya(()=>import("./SidebarLayout-YWA6PPZM-CFjD1Kmo.js"),__vite__mapDeps([8,9,7,3]),import.meta.url).then(e=>({default:e.SidebarLayout}))),csn=_.lazy(()=>Ya(()=>import("./DrawerLayout-IGDKPIOC-CF0zSf6U.js"),__vite__mapDeps([10,9]),import.meta.url).then(e=>({default:e.DrawerLayout}))),usn=_.lazy(()=>Ya(()=>import("./DockLayout-OYD7YJSD-CqCN5TbW.js"),__vite__mapDeps([11,12,9]),import.meta.url).then(e=>({default:e.DockLayout}))),dsn=_.lazy(()=>Ya(()=>import("./WidgetLayout-HQZFWVZ2-CW9j2zi5.js"),__vite__mapDeps([13,12,9]),import.meta.url).then(e=>({default:e.WidgetLayout}))),psn=_.lazy(()=>Ya(()=>import("./ShellRouteSync-4T763MWC-BOFQkqAR.js"),__vite__mapDeps([14,15]),import.meta.url).then(e=>({default:e.ShellRouteSync})));function fsn({className:e}){return h.jsx("div",{className:e,style:{height:"100%",minHeight:"12rem",background:"linear-gradient(90deg, color-mix(in oklab, var(--secondary-bg) 55%, transparent) 25%, color-mix(in oklab, var(--secondary-bg) 25%, transparent) 50%, color-mix(in oklab, var(--secondary-bg) 55%, transparent) 75%)",backgroundSize:"200% 100%",animation:"tfy-aui-pulse 1.2s ease-in-out infinite"},"aria-hidden":!0})}function s8e({className:e}){const t=O3();return h.jsx("div",{role:"status","aria-label":"Loading","aria-live":"polite","aria-busy":"true",className:pe("flex h-full min-h-48 w-full flex-1 items-center justify-center bg-primary-bg text-text-secondary",e),children:h.jsx(PJ,{state:"connecting",speed:1,theme:t,paused:!1,"aria-hidden":!0,size:64,style:{width:"4.5rem",height:"4.5rem"}})})}function hsn({error:e,className:t}){const n=Oa(e,"Failed to initialize server");return h.jsx("div",{role:"alert",className:pe("flex h-full min-h-48 items-center justify-center bg-primary-bg px-6 text-center text-sm text-failure-bg",t),children:n})}function gsn(e){return e==="sidebar"||e==="drawer"||e==="dock"||e==="widget"}function msn({layout:e,className:t}){switch(e){case"sidebar":return h.jsx(lsn,{className:t});case"drawer":return h.jsx(csn,{className:t});case"dock":return h.jsx(usn,{className:t});case"widget":return h.jsx(dsn,{className:t})}}function bsn({layout:e,className:t}){if(gsn(e))return h.jsx(_.Suspense,{fallback:h.jsx(fsn,{className:t}),children:h.jsx(msn,{layout:e,className:t})});const n=e;return h.jsx(n,{className:t})}function vsn({children:e,initialSessionId:t,onRemoteIdChange:n,server:r,...o}){const{mode:a,runtimeKey:i,historyAgentFilter:s,listSessionsAgentId:l,pendingSessionId:c,sessionAccessError:u}=_m(),d=a.status==="active"&&a.isMutable&&a.isCreateAgent,[f]=_.useState(esn),g=_.useMemo(()=>({...r,createSession:S=>{if(S.agentSpec===void 0)return r.createSession(S);const E={...S,metadata:{...S.metadata,[Hke]:sXe(d)}};return r.createSession(E)}}),[r,d]),b=_.useMemo(()=>nsn({server:g,cache:f}),[g,f]),v=_.useMemo(()=>s==null||s.agentId!=null?b:{...b,listSessions:async()=>({data:[]})},[b,s]),y=_.useMemo(()=>a.status==="active"&&a.isMutable?a.agentSpec??{model:{name:"openai-main/gpt-4.1"}}:{model:{name:"openai-main/gpt-4.1"}},[i]),w=_.useMemo(()=>{if(a.status==="idle")return{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}};if(u!=null)return{mode:"draft",defaultAgentSpec:y};if(!a.isMutable){const S=a.agentName??a.agentId??c;return S==null?{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}}:{mode:"named",agentName:S}}return{mode:"draft",defaultAgentSpec:y}},[a,y,c,u]);return h.jsx(VJe,{children:h.jsx(Fin,{...o,server:v,agent:w,listSessionsAgentId:l,initialSessionId:u!=null?void 0:c??t,children:h.jsxs(Rrn,{children:[h.jsx(Zin,{}),h.jsx(Xin,{}),n!=null?h.jsx(Qin,{onRemoteIdChange:n}):null,e]})},i)})}function ysn(e){const{layout:t="sidebar",overrides:n,theme:r,className:o,agentConfig:a=lEe,initialSettingsOpen:i=!1,server:s,onError:l,analytics:c,customActionRenderers:u,currentUser:d,resolvedRoutes:f,routes:g,...b}=e,v=ssn(s,l),[y,w]=_.useState(void 0),S=_.useCallback(R=>w(R),[]);if(_.useEffect(()=>{Sze()},[]),v.status==="loading")return h.jsx(a1,{overrides:n,theme:r,children:h.jsx(s8e,{className:o})});if(v.status==="error")return h.jsx(a1,{overrides:n,theme:r,children:h.jsx(hsn,{error:v.error,className:o})});const E=v.server,A=h.jsx(bsn,{layout:t,className:o}),T=h.jsx($Je,{track:c==null?void 0:c.track,children:h.jsx(n6e,{children:h.jsxs(NXe,{agentConfig:a,initialSettingsOpen:i,children:[h.jsx(qin,{}),f!=null?h.jsx(_.Suspense,{fallback:null,children:h.jsx(psn,{routes:f,activeRemoteId:y,initialSettingsOpen:i})}):null,h.jsx(vsn,{server:E,onError:l,onRemoteIdChange:f!=null?S:void 0,...b,children:A})]})})}),C=t==="widget"?h.jsx(jHe,{children:T}):T;return h.jsx(a1,{overrides:n,theme:r,children:h.jsx(qQt,{currentUser:d,children:h.jsx(iXe,{renderers:u,children:h.jsx(pXe,{server:E,children:f!=null?h.jsx(wnn,{routes:f,children:C}):C})})})})}function xsn(e){const t={getCapabilities:e.getCapabilities,getModels:e.getModels,getSkills:e.getSkills,getMcp:e.getMcp,...e.getMcpConnector===void 0?{}:{getMcpConnector:e.getMcpConnector},...e.getMcpTools===void 0?{}:{getMcpTools:e.getMcpTools},searchAgents:e.searchAgents,saveAgent:e.saveAgent,deleteAgent:async r=>{if(e.deleteAgent){await e.deleteAgent(r);return}throw new Error("deleteAgent is host-owned. Pass deleteAgent to createTrueForgeServer.")}};return{...e.chatServer,...t,...e.catalog!=null?{catalog:e.catalog}:{},...e.sessions!=null?{sessions:e.sessions}:{},...e.metrics!=null?{metrics:e.metrics}:{},...e.schedules!=null?{schedules:e.schedules}:{},...e.sandboxEnvironments!=null?{sandboxEnvironments:e.sandboxEnvironments}:{},...e.permissions!=null?{permissions:e.permissions}:{},...e.configuration!=null?{configuration:e.configuration}:{},...e.sessionAccess!=null?{sessionAccess:e.sessionAccess}:{},...e.getMe!=null?{getMe:e.getMe}:{}}}var wsn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M8 0C8.40158 8.28071e-05 8.72754 0.325937 8.72754 0.727539V2.90918H12.3623C13.5671 2.90921 14.5437 3.88607 14.5439 5.09082V7.27246H15.2725C15.6741 7.27253 16 7.59839 16 8C15.9999 8.40155 15.674 8.72747 15.2725 8.72754H14.5439V10.9092C14.5437 12.1139 13.5671 13.0908 12.3623 13.0908H3.63477C2.43015 13.0906 1.45334 12.1138 1.45312 10.9092V8.72754H0.727539C0.325964 8.7275 7.21982e-05 8.40157 0 8C0 7.59837 0.32592 7.2725 0.727539 7.27246H1.45312V5.09082C1.45335 3.8862 2.43015 2.90942 3.63477 2.90918H7.27246V1.45508H5.09082C4.68943 1.4549 4.36346 1.12893 4.36328 0.727539C4.36328 0.325997 4.68932 0.00017902 5.09082 0H8ZM3.63477 4.36426C3.23346 4.3645 2.90843 4.68951 2.9082 5.09082V7.99023C2.90824 7.99344 2.90918 7.99678 2.90918 8C2.90918 8.00326 2.90825 8.00651 2.9082 8.00977V10.9092C2.90841 11.3105 3.23345 11.6365 3.63477 11.6367H12.3623C12.7638 11.6367 13.0896 11.3106 13.0898 10.9092V5.09082C13.0896 4.68937 12.7638 4.36428 12.3623 4.36426H3.63477ZM5.81738 6.54492C6.21902 6.54492 6.54489 6.87084 6.54492 7.27246V8.72656C6.54492 9.12822 6.21904 9.4541 5.81738 9.4541C5.41587 9.45393 5.08984 9.12811 5.08984 8.72656V7.27246C5.08988 6.87094 5.41589 6.54509 5.81738 6.54492ZM10.1816 6.54492C10.5831 6.54514 10.9091 6.87097 10.9092 7.27246V8.72656C10.9092 9.12808 10.5831 9.45388 10.1816 9.4541C9.77999 9.4541 9.4541 9.12822 9.4541 8.72656V7.27246C9.45413 6.87084 9.78001 6.54492 10.1816 6.54492Z",fill:"currentColor"})}),x$=wsn,_sn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsxs("g",{opacity:.9,children:[h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.4419 9.43023C15.7501 9.43023 16 9.68012 16 9.98837V10.0304C16 11.398 16 12.4813 15.886 13.329C15.7687 14.2015 15.5216 14.9077 14.9647 15.4647C14.4077 16.0216 13.7015 16.2687 12.829 16.386C11.9813 16.5 10.898 16.5 9.53035 16.5H9.48837C9.18012 16.5 8.93023 16.2501 8.93023 15.9419C8.93023 15.6336 9.18012 15.3837 9.48837 15.3837C10.9074 15.3837 11.9155 15.3825 12.6803 15.2797C13.429 15.1791 13.8604 14.9903 14.1753 14.6753C14.4903 14.3604 14.6791 13.929 14.7797 13.1803C14.8825 12.4155 14.8837 11.4074 14.8837 9.98837C14.8837 9.68012 15.1336 9.43023 15.4419 9.43023Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.55814 9.43023C0.866392 9.43023 1.11628 9.68012 1.11628 9.98837C1.11628 11.4074 1.11747 12.4155 1.22029 13.1803C1.32095 13.929 1.50973 14.3604 1.82467 14.6753C2.13962 14.9903 2.57098 15.1791 3.3197 15.2797C4.08448 15.3825 5.0926 15.3837 6.51163 15.3837C6.81988 15.3837 7.06977 15.6336 7.06977 15.9419C7.06977 16.2501 6.81988 16.5 6.51163 16.5H6.46965C5.10201 16.5 4.01875 16.5 3.17096 16.386C2.29846 16.2687 1.59227 16.0216 1.03534 15.4647C0.478423 14.9077 0.231266 14.2015 0.113961 13.329C-2.0957e-05 12.4813 -1.15596e-05 11.398 2.3934e-07 10.0304C3.72411e-07 10.0164 5.05482e-07 10.0024 5.05482e-07 9.98837C5.05482e-07 9.68012 0.249888 9.43023 0.55814 9.43023Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.46964 0.5L6.51163 0.500001C6.81988 0.500001 7.06977 0.749888 7.06977 1.05814C7.06977 1.36639 6.81988 1.61628 6.51163 1.61628C5.0926 1.61628 4.08448 1.61747 3.3197 1.72029C2.57098 1.82095 2.13962 2.00973 1.82467 2.32467C1.50973 2.63962 1.32095 3.07098 1.22029 3.8197C1.11747 4.58448 1.11628 5.5926 1.11628 7.01163C1.11628 7.31988 0.866392 7.56977 0.55814 7.56977C0.249888 7.56977 5.05482e-07 7.31988 5.05482e-07 7.01163L2.3934e-07 6.96964C-1.15596e-05 5.60201 -2.0957e-05 4.51875 0.113961 3.67096C0.231266 2.79846 0.478423 2.09227 1.03534 1.53534C1.59227 0.978423 2.29846 0.731266 3.17096 0.613961C4.01875 0.499979 5.10201 0.499988 6.46964 0.5Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.6803 1.72029C11.9155 1.61747 10.9074 1.61628 9.48837 1.61628C9.18012 1.61628 8.93023 1.36639 8.93023 1.05814C8.93023 0.749888 9.18012 0.500001 9.48837 0.500001C9.5024 0.500001 9.51639 0.5 9.53036 0.5C10.898 0.499988 11.9813 0.499979 12.829 0.613961C13.7015 0.731266 14.4077 0.978423 14.9647 1.53534C15.5216 2.09227 15.7687 2.79846 15.886 3.67096C16 4.51875 16 5.60201 16 6.96965V7.01163C16 7.31988 15.7501 7.56977 15.4419 7.56977C15.1336 7.56977 14.8837 7.31988 14.8837 7.01163C14.8837 5.5926 14.8825 4.58448 14.7797 3.8197C14.6791 3.07098 14.4903 2.63962 14.1753 2.32467C13.8604 2.00973 13.429 1.82095 12.6803 1.72029Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.70041 3.20041C2.04651 3.85431 2.04651 4.90675 2.04651 7.01163V9.98837C2.04651 12.0933 2.04651 13.1457 2.70041 13.7996C3.35431 14.4535 4.40675 14.4535 6.51163 14.4535H9.48837C11.5933 14.4535 12.6457 14.4535 13.2996 13.7996C13.9535 13.1457 13.9535 12.0933 13.9535 9.98837V7.01163C13.9535 4.90675 13.9535 3.85431 13.2996 3.20041C12.6457 2.54651 11.5933 2.54651 9.48837 2.54651H6.51163C4.40675 2.54651 3.35431 2.54651 2.70041 3.20041ZM5.65417 10.5348C5.81478 10.3181 6.12065 10.2726 6.33733 10.4332C6.8116 10.7848 7.38407 10.9884 8 10.9884C8.61593 10.9884 9.1884 10.7848 9.66267 10.4332C9.87936 10.2726 10.1852 10.3181 10.3458 10.5348C10.5064 10.7514 10.461 11.0573 10.2443 11.2179C9.61111 11.6873 8.83673 11.9651 8 11.9651C7.16327 11.9651 6.38889 11.6873 5.75569 11.2179C5.53901 11.0573 5.49356 10.7514 5.65417 10.5348ZM10.6047 7.24419C10.6047 7.78363 10.3131 8.22093 9.95349 8.22093C9.59386 8.22093 9.30233 7.78363 9.30233 7.24419C9.30233 6.70475 9.59386 6.26744 9.95349 6.26744C10.3131 6.26744 10.6047 6.70475 10.6047 7.24419ZM6.04651 8.22093C6.40614 8.22093 6.69767 7.78363 6.69767 7.24419C6.69767 6.70475 6.40614 6.26744 6.04651 6.26744C5.68688 6.26744 5.39535 6.70475 5.39535 7.24419C5.39535 7.78363 5.68688 8.22093 6.04651 8.22093Z",fill:"currentColor"})]})}),Ssn=_sn,ksn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M0 6.9375C0 6.30469 0.234375 5.69531 0.609375 5.25C0.5625 5.0625 0.5625 4.875 0.5625 4.6875C0.5625 3.9375 0.9375 3.25781 1.52344 2.85938C1.61719 2.17969 2.01562 1.59375 2.60156 1.26562C2.90625 0.515625 3.63281 0 4.5 0C5.08594 0 5.60156 0.257812 6 0.65625C6.375 0.257812 6.89062 0 7.5 0C8.34375 0 9.07031 0.515625 9.375 1.26562C9.96094 1.59375 10.3594 2.17969 10.4531 2.85938C11.0391 3.25781 11.4375 3.9375 11.4375 4.6875C11.4375 4.875 11.4141 5.0625 11.3672 5.25C11.7422 5.69531 12 6.30469 12 6.9375C12 7.66406 11.6953 8.32031 11.2266 8.78906L11.25 8.8125C11.25 9.9375 10.4297 10.8516 9.375 11.0391C9 11.625 8.34375 12 7.59375 12C6.96094 12 6.375 11.7422 6 11.2969C5.60156 11.7422 5.01562 12 4.40625 12C3.63281 12 2.97656 11.625 2.60156 11.0391C1.54688 10.8516 0.75 9.9375 0.75 8.8125V8.78906C0.28125 8.32031 0 7.66406 0 6.9375ZM5.41406 9.9375H5.4375V2.0625C5.4375 1.54688 5.01562 1.125 4.5 1.125C3.96094 1.125 3.5625 1.54688 3.5625 2.0625V2.08594C3.07031 2.17969 2.69531 2.55469 2.625 3.04688C2.625 3.09375 2.625 3.14062 2.625 3.1875C2.625 3.32812 2.625 3.46875 2.67188 3.58594C2.50781 3.60938 2.32031 3.65625 2.17969 3.75C1.89844 3.9375 1.71094 4.24219 1.6875 4.57031C1.6875 4.61719 1.6875 4.66406 1.6875 4.6875C1.6875 5.03906 1.82812 5.34375 2.0625 5.55469C1.71094 5.69531 1.40625 5.97656 1.24219 6.32812C1.17188 6.51562 1.10156 6.72656 1.10156 6.9375C1.10156 7.5 1.42969 7.99219 1.875 8.25C1.92188 8.27344 1.94531 8.29688 1.99219 8.32031C1.96875 8.34375 1.96875 8.36719 1.94531 8.39062C1.89844 8.53125 1.875 8.67188 1.875 8.8125C1.875 9.32812 2.20312 9.77344 2.67188 9.91406C2.76562 9.9375 2.88281 9.9375 3 9.9375C3.11719 9.9375 3.25781 9.91406 3.375 9.89062C3.375 10.1016 3.44531 10.3125 3.58594 10.4766C3.77344 10.7344 4.05469 10.875 4.40625 10.875C4.92188 10.875 5.36719 10.4766 5.41406 9.9375ZM8.41406 2.08594L8.4375 2.0625C8.4375 1.54688 8.01562 1.125 7.5 1.125C6.96094 1.125 6.5625 1.54688 6.5625 2.0625V9.9375C6.60938 10.4766 7.05469 10.875 7.59375 10.875C7.92188 10.875 8.20312 10.7344 8.39062 10.4766C8.53125 10.3125 8.60156 10.1016 8.60156 9.89062C8.71875 9.91406 8.85938 9.9375 9 9.9375C9.09375 9.9375 9.21094 9.9375 9.30469 9.91406C9.77344 9.77344 10.125 9.32812 10.125 8.8125C10.125 8.67188 10.0781 8.53125 10.0312 8.39062C10.0078 8.36719 10.0078 8.34375 9.98438 8.32031C10.0312 8.29688 10.0547 8.27344 10.1016 8.25C10.5469 7.99219 10.875 7.5 10.875 6.9375C10.875 6.72656 10.8047 6.51562 10.7344 6.32812C10.5703 5.97656 10.2656 5.69531 9.91406 5.55469C10.1484 5.34375 10.3125 5.03906 10.3125 4.6875C10.3125 4.66406 10.2891 4.61719 10.2891 4.57031C10.2656 4.24219 10.0781 3.9375 9.79688 3.75C9.65625 3.65625 9.46875 3.60938 9.30469 3.58594C9.35156 3.46875 9.375 3.32812 9.375 3.1875C9.375 3.14062 9.35156 3.09375 9.35156 3.04688C9.28125 2.55469 8.90625 2.17969 8.41406 2.08594Z",fill:"currentColor"})}),Esn=ksn,Tsn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M5.09091 16.5V15.0455H1.45455C1.05455 15.0455 0.712121 14.903 0.427273 14.6182C0.142424 14.3333 0 13.9909 0 13.5909V3.40909C0 3.00909 0.142424 2.66667 0.427273 2.38182C0.712121 2.09697 1.05455 1.95455 1.45455 1.95455H5.09091V0.5H6.54545V16.5H5.09091ZM8 15.0455V13.5909L11.6364 13.5909V3.40909H8V1.95455H11.6364C12.0364 1.95455 12.3788 2.09697 12.6636 2.38182C12.9485 2.66667 13.0909 3.00909 13.0909 3.40909V13.5909C13.0909 13.9909 12.9485 14.3333 12.6636 14.6182C12.3788 14.903 12.0364 15.0455 11.6364 15.0455H8Z",fill:"currentColor"})}),Asn=Tsn,Csn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 22 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4824 12.432L21.0265 6.20004L10.5441 0L0 6.20004L10.4824 12.432Z",fill:"#ECF2F9"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4729 11.7499L19.75 6.23584L10.5271 0.749939L1.25 6.23584L10.4729 11.7499Z",fill:"#FDFEFF"}),h.jsx("path",{d:"M10.5 11.7499V0.749939L19.75 6.24994L10.5 11.7499Z",fill:"url(#paint0_linear_10651_178757)"}),h.jsx("path",{d:"M10.5 11.7499V0.749939L1.25 6.24994L10.5 11.7499Z",fill:"#0E1623"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 6.20001V18.686L10.5441 25V12.4319L0 6.20001Z",fill:"#CEE0F8"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.0265 6.20001V18.686L10.4824 25V12.4319L21.0265 6.20001Z",fill:"#82A0CE"}),h.jsx("path",{d:"M10.4973 11.7478L4.64099 8.26706V8.95172L10.4973 12.4126L15.8148 9.27748V8.59062L10.4973 11.7478Z",fill:"#ECF2F9"}),h.jsx("defs",{children:h.jsxs("linearGradient",{id:"paint0_linear_10651_178757",x1:15.0834,y1:2.10412,x2:15.125,y2:11.7499,gradientUnits:"userSpaceOnUse",children:[h.jsx("stop",{stopColor:"#5E7BAA"}),h.jsx("stop",{offset:1,stopColor:"#030407"})]})})]}),Rsn=Csn,Isn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_5446_3655)",children:[h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.15174 1.36702C8.86989 1.09272 8.49212 0.939234 8.09883 0.939234C7.70553 0.939234 7.32776 1.09272 7.04591 1.36702L1.43074 6.87369C1.33678 6.96502 1.21091 7.01611 1.07987 7.01611C0.948831 7.01611 0.822958 6.96502 0.728994 6.87369C0.68299 6.82895 0.646423 6.77544 0.621453 6.71633C0.596483 6.65721 0.583618 6.59369 0.583618 6.52952C0.583618 6.46535 0.596483 6.40183 0.621453 6.34272C0.646423 6.2836 0.68299 6.23009 0.728994 6.18536L6.34416 0.678689C6.81387 0.221585 7.44341 -0.0341797 8.09883 -0.0341797C8.75424 -0.0341797 9.38379 0.221585 9.85349 0.678689C10.1253 0.943 10.3306 1.26791 10.4527 1.62683C10.5748 1.98575 10.6101 2.36848 10.5558 2.74369C10.936 2.68962 11.3235 2.72356 11.6885 2.8429C12.0535 2.96224 12.3863 3.16379 12.6611 3.43202L12.6902 3.46119C12.9203 3.68489 13.1031 3.95243 13.2279 4.248C13.3528 4.54357 13.4171 4.86117 13.4171 5.18202C13.4171 5.50288 13.3528 5.82048 13.2279 6.11605C13.1031 6.41162 12.9203 6.67916 12.6902 6.90286L7.61174 11.8828C7.59642 11.8977 7.58423 11.9155 7.57591 11.9352C7.56759 11.9549 7.5633 11.976 7.5633 11.9974C7.5633 12.0188 7.56759 12.0399 7.57591 12.0596C7.58423 12.0793 7.59642 12.0971 7.61174 12.112L8.65474 13.1352C8.70075 13.1799 8.73731 13.2334 8.76228 13.2926C8.78725 13.3517 8.80012 13.4152 8.80012 13.4794C8.80012 13.5435 8.78725 13.607 8.76228 13.6662C8.73731 13.7253 8.70075 13.7788 8.65474 13.8235C8.56078 13.9149 8.43491 13.9659 8.30387 13.9659C8.17283 13.9659 8.04696 13.9149 7.95299 13.8235L6.90999 12.8009C6.80257 12.6966 6.71717 12.5717 6.65886 12.4337C6.60054 12.2957 6.5705 12.1475 6.5705 11.9977C6.5705 11.8479 6.60054 11.6996 6.65886 11.5617C6.71717 11.4237 6.80257 11.2988 6.90999 11.1944L11.9885 6.21394C12.1264 6.07968 12.2361 5.91914 12.3109 5.74181C12.3858 5.56447 12.4244 5.37393 12.4244 5.18144C12.4244 4.98895 12.3858 4.79841 12.3109 4.62107C12.2361 4.44374 12.1264 4.2832 11.9885 4.14894L11.9593 4.12036C11.6778 3.84634 11.3005 3.69287 10.9076 3.69254C10.5148 3.69222 10.1372 3.84506 9.85524 4.11861L5.67158 8.22177L5.67041 8.22294L5.61324 8.27952C5.51925 8.37103 5.39326 8.42223 5.26208 8.42223C5.1309 8.42223 5.0049 8.37103 4.91091 8.27952C4.86491 8.23478 4.82834 8.18128 4.80337 8.12216C4.7784 8.06305 4.76553 7.99953 4.76553 7.93536C4.76553 7.87118 4.7784 7.80766 4.80337 7.74855C4.82834 7.68944 4.86491 7.63593 4.91091 7.59119L9.15349 3.43027C9.29105 3.29592 9.40033 3.1354 9.47488 2.95816C9.54943 2.78093 9.58776 2.59056 9.58759 2.39828C9.58743 2.206 9.54878 2.0157 9.47393 1.83859C9.39907 1.66147 9.28953 1.50114 9.15174 1.36702Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.44964 2.74425C8.49564 2.69951 8.53221 2.646 8.55718 2.58689C8.58215 2.52777 8.59501 2.46425 8.59501 2.40008C8.59501 2.33591 8.58215 2.27239 8.55718 2.21328C8.53221 2.15416 8.49564 2.10066 8.44964 2.05592C8.35564 1.96441 8.22965 1.91321 8.09847 1.91321C7.96729 1.91321 7.84129 1.96441 7.7473 2.05592L3.59455 6.12875C3.36454 6.35245 3.1817 6.61999 3.05685 6.91556C2.932 7.21113 2.86768 7.52873 2.86768 7.84958C2.86768 8.17044 2.932 8.48804 3.05685 8.78361C3.1817 9.07918 3.36454 9.34672 3.59455 9.57042C4.06433 10.0274 4.69385 10.2831 5.34922 10.2831C6.00459 10.2831 6.63411 10.0274 7.10389 9.57042L11.2572 5.49758C11.3032 5.45284 11.3398 5.39934 11.3648 5.34022C11.3897 5.28111 11.4026 5.21759 11.4026 5.15342C11.4026 5.08925 11.3897 5.02573 11.3648 4.96661C11.3398 4.9075 11.3032 4.85399 11.2572 4.80925C11.1632 4.71774 11.0372 4.66654 10.9061 4.66654C10.7749 4.66654 10.6489 4.71774 10.5549 4.80925L6.40214 8.88208C6.12029 9.15639 5.74252 9.30987 5.34922 9.30987C4.95592 9.30987 4.57815 9.15639 4.2963 8.88208C4.15836 8.74782 4.04873 8.58729 3.97386 8.40995C3.899 8.23261 3.86043 8.04207 3.86043 7.84958C3.86043 7.65709 3.899 7.46655 3.97386 7.28922C4.04873 7.11188 4.15836 6.95134 4.2963 6.81708L8.44964 2.74425Z",fill:"currentColor"})]}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_5446_3655",children:h.jsx("rect",{width:14,height:14,fill:"white"})})})]}),Nsn=Isn,Msn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M7 0C10.8555 0 14 3.14453 14 7C14 10.8828 10.8555 14 7 14C3.11719 14 0 10.8828 0 7C0 3.14453 3.11719 0 7 0ZM7 12.6875C7.19141 12.6875 7.71094 12.4961 8.28516 11.375C8.53125 10.8828 8.72266 10.3086 8.88672 9.625H5.08594C5.25 10.3086 5.44141 10.8828 5.6875 11.375C6.26172 12.4961 6.78125 12.6875 7 12.6875ZM4.86719 8.3125H9.10547C9.16016 7.90234 9.1875 7.46484 9.1875 7C9.1875 6.5625 9.16016 6.125 9.10547 5.6875H4.86719C4.8125 6.125 4.8125 6.5625 4.8125 7C4.8125 7.46484 4.8125 7.90234 4.86719 8.3125ZM8.88672 4.375C8.72266 3.71875 8.53125 3.14453 8.28516 2.65234C7.71094 1.53125 7.19141 1.3125 7 1.3125C6.78125 1.3125 6.26172 1.53125 5.6875 2.65234C5.44141 3.14453 5.25 3.71875 5.08594 4.375H8.88672ZM10.418 5.6875C10.4727 6.125 10.5 6.5625 10.5 7C10.5 7.46484 10.4727 7.90234 10.418 8.3125H12.5234C12.6328 7.90234 12.6875 7.46484 12.6875 7C12.6875 6.5625 12.6328 6.125 12.5234 5.6875H10.418ZM9.35156 1.83203C9.73438 2.54297 10.0352 3.41797 10.2266 4.375H12.0312C11.457 3.25391 10.5 2.35156 9.35156 1.83203ZM4.62109 1.83203C3.47266 2.35156 2.51562 3.25391 1.94141 4.375H3.74609C3.9375 3.41797 4.23828 2.54297 4.62109 1.83203ZM1.3125 7C1.3125 7.46484 1.33984 7.90234 1.44922 8.3125H3.55469C3.5 7.90234 3.5 7.46484 3.5 7C3.5 6.5625 3.5 6.125 3.55469 5.6875H1.44922C1.33984 6.125 1.3125 6.5625 1.3125 7ZM12.0312 9.625H10.2266C10.0352 10.6094 9.73438 11.4844 9.35156 12.1953C10.5 11.6758 11.457 10.7734 12.0312 9.625ZM3.74609 9.625H1.94141C2.51562 10.7734 3.47266 11.6758 4.62109 12.1953C4.23828 11.4844 3.9375 10.6094 3.74609 9.625Z",fill:"currentColor"})}),Osn=Msn,Psn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_10581_4008)",children:[h.jsx("path",{d:"M-0.000793457 0.015625L39.9992 20.0156V40L19.9992 40V80.0156H39.9992V100.016L-0.000793457 120.016V0.015625Z",fill:"white"}),h.jsx("path",{d:"M119.999 0L79.9992 20V40H99.9992V80H79.9992V100L119.999 120V0Z",fill:"white"}),h.jsx("path",{d:"M59.9955 39.8193C61.054 45.6178 63.1935 50.1614 66.5756 53.5215C69.9439 56.868 74.4722 58.9678 80.2035 60.0088C74.4696 61.0714 69.9413 63.2075 66.5736 66.5752C63.1938 69.955 61.0542 74.5036 59.9955 80.2666C58.9314 74.5031 56.7838 69.9547 53.3988 66.5752C50.026 63.2078 45.4965 61.0704 39.7709 60.0078C45.4938 58.9668 50.0235 56.8676 53.3969 53.5215C56.7841 50.1616 58.9316 45.6182 59.9955 39.8193Z",fill:"white",stroke:"white",strokeWidth:1.6,strokeLinejoin:"round"})]}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_10581_4008",children:h.jsx("rect",{width:120,height:120,fill:"white"})})})]}),jsn=Psn,Dsn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_10581_1729)",children:[h.jsx("path",{d:"M-0.000976562 0.0195312L46.6657 23.3529V46.668L23.3324 46.668V93.3529H46.6657V116.686L-0.000976562 140.02V0.0195312Z",fill:"#05090E"}),h.jsx("path",{d:"M139.999 0L93.3324 23.3333V46.6667H116.666V93.3333H93.3324V116.667L139.999 140V0Z",fill:"#05090E"}),h.jsx("path",{d:"M69.9941 46.4561C71.2291 53.2208 73.7252 58.5213 77.6709 62.4414C81.6 66.345 86.8814 68.7951 93.5664 70.0098C86.8784 71.2497 81.5974 73.7435 77.6689 77.6719C73.7259 81.615 71.2293 86.921 69.9941 93.6445C68.7527 86.9203 66.2461 81.6138 62.2969 77.6709C58.3624 73.7429 53.0791 71.2496 46.4004 70.0098C53.076 68.7952 58.3597 66.3456 62.2949 62.4424C66.2468 58.5225 68.7529 53.2215 69.9941 46.4561Z",fill:"#6D58FB",stroke:"#6D58FB",strokeWidth:1.86667,strokeLinejoin:"round"})]}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_10581_1729",children:h.jsx("rect",{width:140,height:140,fill:"white"})})})]}),Lsn=Dsn;RJe({"mcp-server":Nsn,"agent-2":x$,bot:x$,robot:x$,compare:Asn,ai:Ssn,searchGlobe:Osn,"brain-regular":Esn,empty:Rsn,"trueforge-logomark-light":Lsn,"trueforge-logomark-dark":jsn});var zsn=1e3,$sn=5e3;function Usn(e){var r;if(e.get("error"))return!1;const t=(r=e.get("isSuccess"))==null?void 0:r.toLowerCase();if(t==="true")return!0;if(t==="false")return!1;const n=e.get("code");return n!=null&&n.length>0}var Fsn=()=>{const[e,t]=_.useState();_.useEffect(()=>{const a=new URLSearchParams(window.location.search),i=a.get("pUid"),s=Usn(a);t(i?{popupUid:i,isSuccess:s}:null);const l=()=>{if(!i)return;const d=new BroadcastChannel(J6e),f={popupUid:i,isSuccess:s};d.postMessage(f),d.close()};l();const c=window.setTimeout(l,zsn),u=window.setTimeout(()=>{window.close()},$sn);return()=>{window.clearTimeout(c),window.clearTimeout(u)}},[]);const n=!!(e!=null&&e.isSuccess),r=e===void 0?"Completing authorization":n?"Authorization successful":"Authorization failed",o=e===void 0?"Please wait while the authorization result is confirmed.":e===null?"The authorization result is invalid. You can close this window and try again.":n?"The MCP server is now connected. This window will close automatically.":"The MCP server could not be authorized. You can close this window and try again.";return h.jsx("main",{className:"flex min-h-screen items-center justify-center bg-primary-bg p-6",children:h.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-3 rounded-2xl border border-border bg-card-bg p-8 text-center shadow-sm",children:[e===void 0?h.jsx(be,{name:"oauth-loading",className:"size-16 animate-spin text-text-secondary"}):n?h.jsx(be,{name:"oauth-success",className:"size-16 text-success-bg"}):h.jsx(be,{name:"oauth-error",className:"size-16 text-failure-bg"}),h.jsx("h1",{className:"text-2xl font-semibold text-text-primary",children:r}),h.jsx("p",{className:"text-sm leading-6 text-text-secondary",children:o})]})})},Bsn=Fsn,Hsn=_.lazy(()=>Ya(()=>import("./TrueForgeUIWithRouter-LFJ4E5VL-o7uC8O0Z.js"),__vite__mapDeps([16,15]),import.meta.url).then(e=>({default:e.TrueForgeUIWithRouter})));function Vsn(e){if(typeof window<"u"&&new URLSearchParams(window.location.search).get("screenType")==="mcp-auth")return h.jsx(a1,{overrides:e.overrides,theme:e.theme,children:h.jsx(Bsn,{})});const{withRouter:n,...r}=e;return n?h.jsx(_.Suspense,{fallback:h.jsx(s8e,{className:e.className}),children:h.jsx(Hsn,{...r})}):h.jsx(ysn,{...r})}const uN=(e,t,n)=>JSON.stringify(e,t,n);function Fv(e,t){return JSON.parse(e,t)}class Pe extends Error{constructor({message:t,statusCode:n,body:r,rawResponse:o,cause:a}){super(Gsn({message:t,statusCode:n,body:r})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="TrueForgeError",this.statusCode=n,this.body=r,this.rawResponse=o,a!=null&&(this.cause=a)}get requestId(){var o;const t=(o=this.rawResponse)==null?void 0:o.headers;if(t==null)return;const n=t.get("X-Request-Id");if(n!=null)return n;let r;return t.forEach((a,i)=>{r===void 0&&/request[-_]?id$/i.test(i)&&(r=a)}),r}}function Gsn({message:e,statusCode:t,body:n}){const r=[];return e!=null&&r.push(e),t!=null&&r.push(`Status code: ${t.toString()}`),n!=null&&r.push(`Body: ${uN(n,void 0,2)}`),r.join(`
1102
+ `)),{edit:u,disabled:d}=JZe(),{copy:f,isCopied:g}=$ke({copyToClipboard:y=>navigator.clipboard.writeText(y)}),b=(i==null?void 0:i.mode.status)==="active"?{agentId:i.mode.agentId,agentName:i.mode.agentName}:{},v={sessionId:l,...b};return h.jsx(nm.Root,{"data-role":"user",children:h.jsx(e,{text:c,attachments:h.jsx(pin,{}),editAction:n?void 0:h.jsx(t,{isCopied:g,editDisabled:d||!r,retryDisabled:!r,createdAt:s,onCopy:()=>{a(io.Message.COPIED,my({role:"user"},v)),f()},onEdit:()=>{a(io.Message.EDIT_STARTED,my(void 0,v)),u()},onRetry:()=>{r&&(a(io.Message.RETRIED,my(void 0,v)),o.message().composer().beginEdit(),o.message().composer().send({startRun:!0}))}})})})}function hin(e){return h.jsx(wze,{...e,readOnly:!0,onDownloadArtifact:void 0,sandboxDownloadReadOnlyTooltip:"Download File is not available in read-only mode"})}function gin({isCopied:e,onCopy:t,createdAt:n,className:r}){return h.jsx(_ze,{isCopied:e,onCopy:t,createdAt:n,className:r})}function min(e){return h.jsx(Oze,{...e,readOnly:!0})}function bin(e){return h.jsx($ze,{...e,awaiting:e.approvalSlot?!1:e.awaiting})}function vin(e){const t=Ge("McpAuthPrompt"),n=Ve(a=>a.message.metadata.custom),r=(n==null?void 0:n.pendingMcpAuth)===!0?n==null?void 0:n.mcpServers:void 0,o=zS(r)?r:void 0;return h.jsxs(M6e,{...e,children:[e.children,o!=null&&o.length>0?h.jsx(t,{servers:o,readOnly:!0,onConnect:()=>{}}):null]})}var yin={AssistantMessageBubble:vin,UserMessageActionBar:gin,Markdown:hin,ToolApprovalBar:min,ToolCallCard:bin};function xin(e){const t=e.id??"";return e.role==="user"?t.replace(/-user$/,""):t.replace(/-assistant$/,"")}function win(e,t){const n=new Map(t.flatMap(r=>(r.created.input??[]).some(a=>a.type==="user.message")?[]:[[r.turnId,Wze(r)]]));return e.map(r=>{if(r.event.type!=="turn.created")return r;const o=n.get(r.turnId);if(o===void 0)return r;const a={type:"user.message",content:o};return{...r,event:{...r.event,input:[...r.event.input??[],a]}}})}function _in(e,t){var l,c,u;const n=(l=t.done)==null?void 0:l.state;if((n==null?void 0:n.status)!=="error"&&(n==null?void 0:n.status)!=="cancelled")return e;const r=e.findIndex(d=>d.role==="assistant"),o=r<0?void 0:e[r],a=new Date(n.completedAt??((c=t.done)==null?void 0:c.createdAt)??t.created.createdAt),i=o??{id:`${t.turnId}-assistant`,role:"assistant",content:[],createdAt:a,metadata:{custom:{turnId:t.turnId}}},s=n.status==="error"?{...i,status:{type:"incomplete",reason:"error",error:n.message}}:{...i,status:{type:"incomplete",reason:"cancelled"},metadata:{...i.metadata,custom:{...(u=i.metadata)==null?void 0:u.custom,[c3]:n.reason}}};return r<0?[...e,s]:e.map((d,f)=>f===r?s:d)}function Sin(e){const t=e.done;if((t==null?void 0:t.state.status)==="done"){const n=t.state.requiredActions;if(!Array.isArray(n))return;for(const r of n)if(r.type==="mcp.auth_required"&&zS(r.mcpServers))return r.mcpServers;return}if(t==null){for(const n of e.events)if(n.type==="mcp.auth_required"&&zS(n.mcpServers))return n.mcpServers}}function kin(e,t){var s,l,c;const n=Sin(t);if(n==null||n.length===0)return e;const r=e.findIndex(u=>u.role==="assistant"),o=r<0?void 0:e[r],a=new Date(((s=t.done)==null?void 0:s.createdAt)??t.created.createdAt),i={...o??{id:`${t.turnId}-assistant`,role:"assistant",content:[],createdAt:a},...((l=t.done)==null?void 0:l.state.status)==="done"?{status:{type:"complete",reason:"stop"}}:{},metadata:{...o==null?void 0:o.metadata,custom:{...(c=o==null?void 0:o.metadata)==null?void 0:c.custom,turnId:t.turnId,pendingMcpAuth:!0,mcpServers:n}}};return r<0?[...e,i]:e.map((u,d)=>d===r?i:u)}function Ein(e,t){var r,o;if(xin(e)===t)return!0;const n=(o=(r=e.metadata)==null?void 0:r.custom)==null?void 0:o.turnId;return typeof n=="string"&&n===t}function Tin(e,t){const n=e.filter(a=>Ein(a,t.turnId)),r=kin(n,t),o=_in(r,t);return t.done!=null?o:o.map(a=>{var i;return a.role!=="assistant"||((i=a.status)==null?void 0:i.type)!=="running"?a:{...a,status:{type:"complete",reason:"stop"}}})}function Ain({sessionId:e,events:t,contentMaxWidth:n,sessionMetrics:r}){const o=I0(),a=Ge("AgentSessionTurnHeader"),i=Ge("AgentSessionEventTimeline"),s=Ge("AgentSessionMetricsStrip"),l=Ge("MessageListSkeleton"),c=Ge("ThreadViewportShell"),[u,d]=_.useState(),[f,g]=_.useState(!1),b=_.useRef(new Map),v=_.useMemo(()=>NJt(t),[t]),y=_.useMemo(()=>v.filter(N=>N.renderable),[v]),w=_.useMemo(()=>win(t,y),[t,y]),S=_.useMemo(()=>can(v),[v]),[E,A]=_.useState(()=>Date.now());_.useEffect(()=>{if(!S)return;A(Date.now());const N=window.setInterval(()=>A(Date.now()),1e3);return()=>window.clearInterval(N)},[S,v]);const T=_.useMemo(()=>San(v,{nowMs:E}),[v,E]),C=_.useMemo(()=>jJt({turns:v,segments:T,sessionMetrics:r}),[r,T,v]),R=_.useCallback(N=>{var O;(O=b.current.get(N))==null||O.scrollIntoView({behavior:"smooth",block:"start"})},[]);return _.useEffect(()=>{let N=!1;d(void 0),g(!1);const O=Can(w),P={...o,listEvents:j=>O.listEvents(j),listTurns:async()=>({data:[]})};return HKt(P,e).then(j=>{N||d(j.messages)}).catch(()=>{N||g(!0)}),()=>{N=!0}},[w,o,e]),f?h.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session messages could not be loaded."}):u===void 0?h.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-4",children:h.jsx(l,{})}):y.length===0?h.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"This session has no messages yet."}):h.jsxs("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain","data-slot":"agent-session-scroll",children:[h.jsx("div",{className:"sticky top-0 z-20 bg-primary-bg","data-slot":"agent-session-metrics-sticky",children:h.jsx(s,{metrics:C})}),h.jsx("div",{className:"border-b border-border",children:h.jsx(_.Suspense,{fallback:null,children:h.jsx(i,{turns:v,segments:T,onSelectTurn:R})})}),h.jsx(c,{scrollable:!1,className:"pb-4",...n==null?{}:{contentMaxWidth:n},children:h.jsx("div",{className:"flex flex-col gap-4",children:y.map(N=>h.jsx(Cin,{turn:MJt(v,N.turnNumber)??N,messages:Tin(u,N),AgentSessionTurnHeader:a,onMount:O=>{O==null?b.current.delete(N.turnNumber-1):b.current.set(N.turnNumber-1,O)}},N.turnId))})})]})}function Cin({turn:e,messages:t,AgentSessionTurnHeader:n,onMount:r}){const o=e.done==null;return!e.showHeader&&t.length===0&&!o?null:h.jsxs("section",{ref:r,id:`session-turn-${e.turnNumber}`,className:"flex flex-col gap-2",children:[e.showHeader?h.jsx(n,{turnNumber:e.turnNumber,totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cachedTokens:e.cachedTokens,cacheReadTokens:e.cacheReadTokens,cacheWriteTokens:e.cacheWriteTokens,inputTokensBreakdown:e.inputTokensBreakdown,durationMs:e.durationMs,totalCostInUsd:e.totalCostInUsd,modelName:e.modelName}):null,t.length>0?h.jsx(lin,{slotOverrides:yin,messages:t,children:h.jsx(Vse.Root,{asChild:!0,children:h.jsx("div",{className:"aui-root aui-thread-root flex w-full flex-col",children:h.jsx(Vse.Messages,{children:({message:a})=>a.role==="user"?h.jsx(fin,{}):h.jsx(sin,{})})})})}):null,o?h.jsx("div",{role:"status",className:"border-warning-bg bg-warning-bg/10 text-warning-bg inline-flex w-fit max-w-full items-center gap-3 rounded-xl border px-3 py-1.5 text-sm font-medium leading-[1.4]",children:"Turn is still in running, all events might not be visible"}):null]})}var Rin=_.lazy(()=>Ya(()=>import("./AgentOverview-ZSZENAFZ-MH2qXo-8.js"),[],import.meta.url)),Iin=_.lazy(async()=>({default:(await Ya(()=>import("./AgentSessions-W2EDVBCS-DJ_2ids3.js"),__vite__mapDeps([2,3]),import.meta.url)).AgentSessions})),Nin=_.lazy(()=>Ya(()=>import("./AgentCodeSnippets-D2J3IH37-DD3K7eq2.js"),[],import.meta.url)),Min=_.lazy(async()=>({default:(await Ya(()=>import("./SchedulesPage-OVDMYD6Q-O2hNR1RH.js"),__vite__mapDeps([4,5]),import.meta.url)).SchedulesPage})),Oin=_.lazy(async()=>({default:(await Ya(()=>import("./EnvironmentsPage-BUA2EGXE-hn2BUGZI.js"),__vite__mapDeps([6,7,5]),import.meta.url)).EnvironmentsPage})),Pin=_.lazy(async()=>({default:(await Ya(()=>import("./AgentSessionEventTimeline-26TTGY3F-B3RffNd5.js"),[],import.meta.url)).AgentSessionEventTimeline})),jin=_.lazy(async()=>({default:(await Ya(()=>import("./AgentSessionEventTimelineChart-SV6ZYNU2-BJDI4-l_.js"),[],import.meta.url)).AgentSessionEventTimelineChart})),Din=_.lazy(async()=>({default:(await Ya(()=>import("./AgentMetricChart-TCZEIIUV-DlkbLiqX.js"),[],import.meta.url)).AgentMetricChart})),i8e={Accordion:ZLe,AccordionSummary:XLe,AccordionDetails:qLe,BrandLogo:jJ,ComposerShell:ntn,ComposerLeftSection:Jen,ComposerRightSection:etn,ComposerSendButton:ttn,PermissionGuard:mrn,DraftComposerLeftSection:Ann,DraftComposerRightSection:Cnn,DraftAgentConfigTrigger:Snn,DraftCapabilitiesPanel:knn,DraftComposerActionsMenu:Enn,AgentCustomParametersEditor:jtn,AgentConfigEditors:ftn,AgentInstructionsDrawer:Ltn,InstructionsFullScreenEditor:Pnn,InstructionsMarkdownEditor:Fnn,AgentModelEditorContent:tnn,AgentModelSettingsContent:onn,AgentMcpEditorContent:Vtn,AgentModelConfigModal:Gtn,AgentResourceEditorContent:inn,AgentResourceConfigModal:ann,AgentSkillsEditorContent:xnn,AgentSkillsHeaderActionSlot:dze,AgentConfigPanel:Itn,AgentConfigSection:Rtn,AgentRuntimeConfigFields:vnn,AgentRuntimeConfigDrawer:cnn,AgentRuntimeEditorContent:ynn,DraftCompositeSelector:Mnn,CatalogRow:xg,ConnectorConnectButton:sB,DraftModelSelector:Onn,AssistantMessageBubble:M6e,UserMessageBubble:Lon,UserMessageEdit:zon,UserMessageActionBar:Don,MessageActionBar:_ze,MessageCancelledBanner:orn,MessageErrorBanner:arn,MessageIndicator:irn,ResumeUnavailable:vrn,MessageTimestamp:crn,Markdown:wze,SyntaxHighlighter:ron,OpenUiFenceBlock:_De,SandboxArtifactDownload:krn,ChatFileDownload:Gen,FilePreviewPanel:Knn,MonacoEditorCore:hrn,CodeEditor:Qen,WelcomeScreen:Uze,ToolCallCard:$ze,ToolCallContentBlock:Pon,ToolApprovalBar:Oze,ToolGroupCard:jon,StepTree:gQt,StepTreeItem:hQt,SubAgentCard:qrn,SandboxToolCallCard:Trn,AgentStepsCard:Qqt,ReasoningCard:pQt,ContextCompactionCard:cQt,AskUserPrompt:iQt,McpAuthPrompt:dQt,AttachmentCard:xen,AttachmentPreviewDialog:_en,AttachmentPickerButton:wen,ScrollToBottomButton:Aze,ThreadListRow:don,ThreadListNewButton:oon,AgentsLibrary:hen,AgentLibraryRow:den,AgentLibraryUsageCells:YJt,AgentsLibraryButton:gen,ApprovalNavBanner:men,SessionsBrowserButton:Lrn,AgentDetailsPage:OQt,AgentDetailsHeader:RQt,AgentDetailsTabs:jQt,AgentDetailsUnavailable:DQt,AgentOverview:Rin,AgentOverviewCard:ZQt,AgentMetrics:$on,AgentMetricsView:YQt,AgentMetricsTimeRangeFilter:BQt,AgentMetricCard:FQt,AgentMetricStatistics:KQt,AgentMetricChart:Din,AgentSessionDetailHeader:XQt,AgentSessionsFilters:_Jt,SessionsPage:LJt,AgentSessionEventTimeline:Pin,AgentSessionEventTimelineChart:jin,AgentSessionListRow:sJt,AgentSessionMetricsStrip:bJt,AgentSessionTimelineContainer:Ain,AgentSessionTurnHeader:DJt,AgentSessions:Iin,AgentCodeSnippets:Nin,AgentCodeBlock:mQt,SchedulesPage:Min,SchedulesButton:jrn,EnvironmentsPage:Oin,EnvironmentsButton:Bnn,SaveAgentButton:Mrn,SaveAgentForm:Prn,SelectAgentEmptyState:Drn,ClearChatButton:qen,ResetAgentBuilderButton:brn,ShareChatButton:zrn,ShareSessionDialog:Yrn,ThreadListRowSkeleton:aon,ThreadListEmptyState:ion,ThreadListShell:son,HistoryLoader:fze,MessageListSkeleton:Xrn,ThreadRootShell:Rze,ThreadViewportShell:Ize,ThreadComposerAreaShell:Nze,MessageGroup:Mze,Toast:hon,ToastStack:mon,ShellActionsActionSlot:Zrn,UserAvatar:eJt},M3=_.createContext(i8e),see=_.createContext(void 0);function a1({overrides:e,theme:t,children:n}){const r=_.useContext(M3),o=_.useContext(see),a=_.useMemo(()=>({...r,...e}),[r,e]),i=h.jsx(Lin,{slots:a,inheritedTheme:o,theme:t,children:n});return t!==void 0||!(o!==void 0)?h.jsx(wv,{theme:t,children:i}):i}function Lin({slots:e,children:t,inheritedTheme:n,theme:r}){const o=AEe(),i=((r==null?void 0:r.mode)==="light"||(r==null?void 0:r.mode)==="dark"?r.mode:void 0)??n??o;return h.jsx(see.Provider,{value:i,children:h.jsx(M3.Provider,{value:e,children:t})})}function Ge(e){return _.useContext(M3)[e]}function Byn(e){return _.useContext(M3)[e]===i8e[e]}function O3(){return _.useContext(see)??"light"}var ywe={"tfg.source":"ui"};function zin({locallyCreatedSessionIds:e,children:t}){const n=Ve(r=>r.threadListItem.remoteId);return h.jsx(yQt,{sessionId:n,assumeManage:n!=null&&e.has(n),children:t})}function $in({server:e,locallyCreatedSessionIds:t}){return{...e,async createSession(n){const r=await e.createSession({...n,metadata:{...n.metadata,...ywe}});return t.add(r.id),r},async listSessions(n){const r=await e.listSessions({...n,metadata:{...n==null?void 0:n.metadata,...ywe}});return{...r,data:r.data.filter(o=>!lXe(o))}}}}function Uin({server:e,agent:t,agentName:n,listSessionsAgentId:r,initialSessionId:o,adapters:a,onError:i,children:s}){const{showError:l}=EQt(),c=i??l,d=_.useMemo(()=>({server:e,ids:new Set}),[e]).ids,f=_.useMemo(()=>$in({server:e,locallyCreatedSessionIds:d}),[d,e]),g=_.useCallback(v=>{oXe(),c(v)},[c]),b=VYt({server:f,agent:t,agentName:n,listSessionsAgentId:r,listSessionsCreatedByMe:!0,initialSessionId:o,onError:g,adapters:{...a,attachments:(a==null?void 0:a.attachments)??gWt}});return h.jsx(hAe,{runtime:b,children:h.jsx(zin,{locallyCreatedSessionIds:d,children:s})})}function Fin(e){const{server:t,initialSessionId:n,adapters:r,onError:o,children:a,agent:i,agentName:s,listSessionsAgentId:l}=e,c=_.useMemo(()=>t,[t]);return h.jsx(n6e,{children:h.jsx(Uin,{server:c,agent:i,agentName:s,listSessionsAgentId:l,initialSessionId:n,adapters:r,onError:o,children:a})})}function Bin(e){if(e.config===void 0)return;const t=Reflect.get(e.config,"sandbox");if(typeof t!="object"||t===null)return;const n=Reflect.get(t,"enabled");return typeof n=="boolean"?n:void 0}function xwe(e,t,{matchFamily:n=!1}={}){if(e===void 0)return;const r=e.filter(o=>{const a=eN(o);return a===null?!1:t.has(a)?!0:n&&t.has(Aa(a))});return r.length===e.length?e:r}function Hin(e){const t=new Set;for(const n of e)t.add(n.name),t.add(n.id),t.add(Aa(n.id));return t}function Vin(e,t){if(e===void 0)return;let n=!1;const r=e.map(o=>{const a=eN(o),i=t.find(s=>s.id===a);return i===void 0||a===i.name?o:(n=!0,{...o,id:i.id,name:i.name})});return n?r:e}function Gin({agentSpec:e,models:t,skills:n,connectors:r,skillsEnabled:o}){const a={},i=e.model.name.trim();if(!t.some(l=>l.name===i)){const l=t[0];l!==void 0&&(a.model=v0(l.name,e.model.params,l.properties.reasoningEfforts))}const s=xwe(e.mcpServers,new Set(r.map(l=>l.name)));if(s!==e.mcpServers&&(a.mcpServers=s),o===!1)e.skills!==void 0&&e.skills.length>0&&(a.skills=[]);else{const l=Vin(xwe(e.skills,Hin(n),{matchFamily:!0}),n);l!==e.skills&&(a.skills=l)}return a}function Win({agentSpec:e,sandboxEnabled:t,kind:n="agent"}){var o,a;if(n==="chat"){if(t==null)return{};const i=Bin(e);return t===!0&&i!==!0?{config:{...e.config,sandbox:{...(o=e.config)==null?void 0:o.sandbox,enabled:!0}}}:t===!1&&i===!0?{config:{...e.config,sandbox:{...(a=e.config)==null?void 0:a.sandbox,enabled:!1}}}:{}}const r=L9(e,t);return r===e?{}:{config:r.config}}function Kin({agentSpec:e,webSearchEnabled:t,previousWebSearchEnabled:n,explicitOff:r=!1,kind:o="agent"}){const a=rEe({spec:e,previousWebSearchEnabled:n,webSearchEnabled:t,explicitOff:r,kind:o}),i=Rv({spec:a,webSearchEnabled:t});return i===e?{}:{config:i.config}}function Yin({agentSpec:e,memoryEnabled:t,previousMemoryEnabled:n,explicitOff:r=!1}){var a,i,s;const o=sEe({spec:e,previousMemoryEnabled:n,memoryEnabled:t,explicitOff:r});if(t===!1&&((i=(a=o.config)==null?void 0:a.memory)==null?void 0:i.enabled)===!0){const{memory:l,...c}=o.config;return{config:c}}return t===!0&&((s=o.config)==null?void 0:s.memory)===void 0?{config:{...o.config,memory:{enabled:!0}}}:o===e?{}:{config:o.config}}function Zin(){var O,P;const{mode:e,pendingSessionId:t,rememberDraftSpec:n}=_m(),{agentSpec:r,draftSessionId:o,isSpecLoading:a}=Bu(),i=qk(),s=th(),l=s==null?void 0:s.sandbox.enabled,c=(O=s==null?void 0:s.webSearch)==null?void 0:O.enabled,u=s==null?void 0:((P=s.memory)==null?void 0:P.enabled)??!1,d=_.useRef(c),f=_.useRef(u),{models:g,skills:b,connectors:v,loaded:y,error:w,ensureLoaded:S}=JN(),E=e.status==="active"&&e.isMutable&&t==null,A=e.status==="active"?e.agentId:void 0,T=E&&A==null,C=!a,R=e.status==="active"&&e.isMutable&&e.isCreateAgent?"agent":"chat",N=R==="chat"?o!=null:A!=null;return _.useEffect(()=>{T&&S()},[S,T]),_.useEffect(()=>{T&&C&&r!=null&&n(r,R)},[r,C,T,R,n]),_.useEffect(()=>{if(!T||!C||r==null||i==null)return;const j=Win({agentSpec:r,sandboxEnabled:l,kind:R});Object.keys(j).length>0&&i(j)},[r,C,T,R,l,i]),_.useEffect(()=>{const j=f.current;if(f.current=u,!E||R!=="agent"||N||!C||r==null||i==null)return;const D=Yin({agentSpec:r,memoryEnabled:u,previousMemoryEnabled:j,explicitOff:iEe()===!1});Object.keys(D).length>0&&i(D)},[r,C,N,E,u,R,i]),_.useEffect(()=>{const j=d.current;if(d.current=c,!E||N||!C||r==null||i==null)return;const D=Kin({agentSpec:r,webSearchEnabled:c,previousWebSearchEnabled:T?j:void 0,explicitOff:T&&oEe(R)===!1,kind:R});Object.keys(D).length>0&&i(D)},[r,C,N,E,T,R,c,i]),_.useEffect(()=>{if(!T||!C||r==null||i==null||!y||w!=null)return;const j=Gin({agentSpec:r,models:g,skills:b,connectors:v,skillsEnabled:s==null?void 0:s.skill.enabled});Object.keys(j).length>0&&i(j)},[r,C,s==null?void 0:s.skill.enabled,v,w,T,y,g,b,i]),null}function Xin(){const e=go(),t=pn(),n=e==null?void 0:e.pendingSessionId,r=(e==null?void 0:e.pendingSessionEpoch)??0;return _.useEffect(()=>{n==null||(e==null?void 0:e.sessionAccessError)!=null||Promise.resolve(t.threads().switchToThread(n)).catch(()=>{})},[t,n,r,e==null?void 0:e.sessionAccessError]),null}function qin(){const{openLibraryAgent:e,openSharedSession:t,setSessionsOpen:n}=_m(),r=N0(),o=ck({sessions:r});return _.useEffect(()=>{if(!o)return;const a=Nd(window.location.search);if(a.view===ZN&&a.sessionId!=null){t(a.sessionId);return}if(a.view==="sessions"){n(!0);return}a.agentId!=null&&e(a.agentId)},[e,t,o,n]),null}function Qin({onRemoteIdChange:e}){const t=Ve(n=>n.threadListItem.remoteId);return _.useEffect(()=>{e(t??void 0)},[t,e]),null}var Jin=3e4;function esn(){return new Map}function tsn(e){const t={...e};return delete t.startTimestamp,JSON.stringify(t,Object.keys(t).sort())}function nsn({server:e,cache:t}){const{deleteSession:n,renameSession:r}=e;return{...e,listSessions(o){const a=tsn(o),i=Date.now(),s=t.get(a);if(s!==void 0&&i-s.at<Jin)return s.page;const l=e.listSessions(o);return t.set(a,{at:i,page:l}),l.catch(()=>{var c;((c=t.get(a))==null?void 0:c.page)===l&&t.delete(a)}),l},async createSession(o){const a=await e.createSession(o);return t.clear(),a},async updateSession(o){const a=await e.updateSession(o);return t.clear(),a},...n!=null?{deleteSession:async o=>{await n.call(e,o),t.clear()}}:{},...r!=null?{renameSession:async o=>{await r.call(e,o),t.clear()}}:{}}}var rsn={data:{sandbox:{enabled:!0},skill:{enabled:!0},settings:{modelProviders:{enabled:!0,manageProviders:!0},mcpServers:{enabled:!0,manageProviders:!0},skills:{enabled:!0,manageProviders:!0},sandboxProviders:{enabled:!0,manageProviders:!0},webSearch:{enabled:!0,manageProviders:!0},memoryProviders:{enabled:!0,manageProviders:!0}},webSearch:{enabled:!1},sessionSharing:{granularity:"tenant"}}};function wwe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="trueforge"}function osn(e){return typeof Reflect.get(e,"getCapabilities")=="function"}function asn(e,t,n){const r=osn(e)?()=>e.getCapabilities():async()=>rsn,a={...{...e,getCapabilities:r}};if(!isn(a))throw new Error("TrueForgeUI: runtime adapter returned an incomplete AgentUIServer");return a}function isn(e){return typeof Reflect.get(e,"createSession")=="function"&&typeof Reflect.get(e,"listSessions")=="function"&&typeof Reflect.get(e,"getSession")=="function"&&typeof Reflect.get(e,"updateSession")=="function"&&typeof Reflect.get(e,"createTurn")=="function"&&typeof Reflect.get(e,"cancelSession")=="function"&&typeof Reflect.get(e,"listTurns")=="function"&&typeof Reflect.get(e,"getTurn")=="function"&&typeof Reflect.get(e,"listEvents")=="function"&&typeof Reflect.get(e,"getCapabilities")=="function"&&typeof Reflect.get(e,"getModels")=="function"&&typeof Reflect.get(e,"getSkills")=="function"&&typeof Reflect.get(e,"getMcp")=="function"&&typeof Reflect.get(e,"searchAgents")=="function"&&typeof Reflect.get(e,"saveAgent")=="function"}function ssn(e,t){const n=wwe(e)?e:null,r=wwe(e)?null:e,o=(n==null?void 0:n.baseUrl)??"",a=(n==null?void 0:n.token)??"",i=n==null?void 0:n.fetch,s=n==null?void 0:n.catalog,l=n==null?void 0:n.permissions,[c,u]=_.useState(()=>r?{status:"ready",server:r,error:null}:{status:"loading",server:null,error:null});return _.useEffect(()=>{if(r){u({status:"ready",server:r,error:null});return}let d=!1;return u({status:"loading",server:null,error:null}),(async()=>{const{createTrueForgeAgentUIServer:g}=await Ya(async()=>{const{createTrueForgeAgentUIServer:b}=await Promise.resolve().then(()=>vhn);return{createTrueForgeAgentUIServer:b}},void 0,import.meta.url);return g({...o?{baseUrl:o}:{},...a?{token:a}:{},...i!==void 0?{fetch:i}:{},...s!=null?{catalog:s}:{},...l!=null?{permissions:l}:{}})})().then(g=>{if(!d)try{u({status:"ready",server:asn(g,void 0,void 0),error:null})}catch(b){t==null||t(b),u({status:"error",server:null,error:b})}}).catch(g=>{d||(t==null||t(g),u({status:"error",server:null,error:g}))}),()=>{d=!0}},[r,o,a,i,s,l,t]),c}var lsn=_.lazy(()=>Ya(()=>import("./SidebarLayout-YWA6PPZM-DrVGRycR.js"),__vite__mapDeps([8,9,7,3]),import.meta.url).then(e=>({default:e.SidebarLayout}))),csn=_.lazy(()=>Ya(()=>import("./DrawerLayout-IGDKPIOC-B-eU-MHF.js"),__vite__mapDeps([10,9]),import.meta.url).then(e=>({default:e.DrawerLayout}))),usn=_.lazy(()=>Ya(()=>import("./DockLayout-OYD7YJSD-BsU6EkTC.js"),__vite__mapDeps([11,12,9]),import.meta.url).then(e=>({default:e.DockLayout}))),dsn=_.lazy(()=>Ya(()=>import("./WidgetLayout-HQZFWVZ2-msxsQ6JO.js"),__vite__mapDeps([13,12,9]),import.meta.url).then(e=>({default:e.WidgetLayout}))),psn=_.lazy(()=>Ya(()=>import("./ShellRouteSync-4T763MWC-CPxzGJDG.js"),__vite__mapDeps([14,15]),import.meta.url).then(e=>({default:e.ShellRouteSync})));function fsn({className:e}){return h.jsx("div",{className:e,style:{height:"100%",minHeight:"12rem",background:"linear-gradient(90deg, color-mix(in oklab, var(--secondary-bg) 55%, transparent) 25%, color-mix(in oklab, var(--secondary-bg) 25%, transparent) 50%, color-mix(in oklab, var(--secondary-bg) 55%, transparent) 75%)",backgroundSize:"200% 100%",animation:"tfy-aui-pulse 1.2s ease-in-out infinite"},"aria-hidden":!0})}function s8e({className:e}){const t=O3();return h.jsx("div",{role:"status","aria-label":"Loading","aria-live":"polite","aria-busy":"true",className:pe("flex h-full min-h-48 w-full flex-1 items-center justify-center bg-primary-bg text-text-secondary",e),children:h.jsx(PJ,{state:"connecting",speed:1,theme:t,paused:!1,"aria-hidden":!0,size:64,style:{width:"4.5rem",height:"4.5rem"}})})}function hsn({error:e,className:t}){const n=Oa(e,"Failed to initialize server");return h.jsx("div",{role:"alert",className:pe("flex h-full min-h-48 items-center justify-center bg-primary-bg px-6 text-center text-sm text-failure-bg",t),children:n})}function gsn(e){return e==="sidebar"||e==="drawer"||e==="dock"||e==="widget"}function msn({layout:e,className:t}){switch(e){case"sidebar":return h.jsx(lsn,{className:t});case"drawer":return h.jsx(csn,{className:t});case"dock":return h.jsx(usn,{className:t});case"widget":return h.jsx(dsn,{className:t})}}function bsn({layout:e,className:t}){if(gsn(e))return h.jsx(_.Suspense,{fallback:h.jsx(fsn,{className:t}),children:h.jsx(msn,{layout:e,className:t})});const n=e;return h.jsx(n,{className:t})}function vsn({children:e,initialSessionId:t,onRemoteIdChange:n,server:r,...o}){const{mode:a,runtimeKey:i,historyAgentFilter:s,listSessionsAgentId:l,pendingSessionId:c,sessionAccessError:u}=_m(),d=a.status==="active"&&a.isMutable&&a.isCreateAgent,[f]=_.useState(esn),g=_.useMemo(()=>({...r,createSession:S=>{if(S.agentSpec===void 0)return r.createSession(S);const E={...S,metadata:{...S.metadata,[Hke]:sXe(d)}};return r.createSession(E)}}),[r,d]),b=_.useMemo(()=>nsn({server:g,cache:f}),[g,f]),v=_.useMemo(()=>s==null||s.agentId!=null?b:{...b,listSessions:async()=>({data:[]})},[b,s]),y=_.useMemo(()=>a.status==="active"&&a.isMutable?a.agentSpec??{model:{name:"openai-main/gpt-4.1"}}:{model:{name:"openai-main/gpt-4.1"}},[i]),w=_.useMemo(()=>{if(a.status==="idle")return{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}};if(u!=null)return{mode:"draft",defaultAgentSpec:y};if(!a.isMutable){const S=a.agentName??a.agentId??c;return S==null?{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}}:{mode:"named",agentName:S}}return{mode:"draft",defaultAgentSpec:y}},[a,y,c,u]);return h.jsx(VJe,{children:h.jsx(Fin,{...o,server:v,agent:w,listSessionsAgentId:l,initialSessionId:u!=null?void 0:c??t,children:h.jsxs(Rrn,{children:[h.jsx(Zin,{}),h.jsx(Xin,{}),n!=null?h.jsx(Qin,{onRemoteIdChange:n}):null,e]})},i)})}function ysn(e){const{layout:t="sidebar",overrides:n,theme:r,className:o,agentConfig:a=lEe,initialSettingsOpen:i=!1,server:s,onError:l,analytics:c,customActionRenderers:u,currentUser:d,resolvedRoutes:f,routes:g,...b}=e,v=ssn(s,l),[y,w]=_.useState(void 0),S=_.useCallback(R=>w(R),[]);if(_.useEffect(()=>{Sze()},[]),v.status==="loading")return h.jsx(a1,{overrides:n,theme:r,children:h.jsx(s8e,{className:o})});if(v.status==="error")return h.jsx(a1,{overrides:n,theme:r,children:h.jsx(hsn,{error:v.error,className:o})});const E=v.server,A=h.jsx(bsn,{layout:t,className:o}),T=h.jsx($Je,{track:c==null?void 0:c.track,children:h.jsx(n6e,{children:h.jsxs(NXe,{agentConfig:a,initialSettingsOpen:i,children:[h.jsx(qin,{}),f!=null?h.jsx(_.Suspense,{fallback:null,children:h.jsx(psn,{routes:f,activeRemoteId:y,initialSettingsOpen:i})}):null,h.jsx(vsn,{server:E,onError:l,onRemoteIdChange:f!=null?S:void 0,...b,children:A})]})})}),C=t==="widget"?h.jsx(jHe,{children:T}):T;return h.jsx(a1,{overrides:n,theme:r,children:h.jsx(qQt,{currentUser:d,children:h.jsx(iXe,{renderers:u,children:h.jsx(pXe,{server:E,children:f!=null?h.jsx(wnn,{routes:f,children:C}):C})})})})}function xsn(e){const t={getCapabilities:e.getCapabilities,getModels:e.getModels,getSkills:e.getSkills,getMcp:e.getMcp,...e.getMcpConnector===void 0?{}:{getMcpConnector:e.getMcpConnector},...e.getMcpTools===void 0?{}:{getMcpTools:e.getMcpTools},searchAgents:e.searchAgents,saveAgent:e.saveAgent,deleteAgent:async r=>{if(e.deleteAgent){await e.deleteAgent(r);return}throw new Error("deleteAgent is host-owned. Pass deleteAgent to createTrueForgeServer.")}};return{...e.chatServer,...t,...e.catalog!=null?{catalog:e.catalog}:{},...e.sessions!=null?{sessions:e.sessions}:{},...e.metrics!=null?{metrics:e.metrics}:{},...e.schedules!=null?{schedules:e.schedules}:{},...e.sandboxEnvironments!=null?{sandboxEnvironments:e.sandboxEnvironments}:{},...e.permissions!=null?{permissions:e.permissions}:{},...e.configuration!=null?{configuration:e.configuration}:{},...e.sessionAccess!=null?{sessionAccess:e.sessionAccess}:{},...e.getMe!=null?{getMe:e.getMe}:{}}}var wsn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M8 0C8.40158 8.28071e-05 8.72754 0.325937 8.72754 0.727539V2.90918H12.3623C13.5671 2.90921 14.5437 3.88607 14.5439 5.09082V7.27246H15.2725C15.6741 7.27253 16 7.59839 16 8C15.9999 8.40155 15.674 8.72747 15.2725 8.72754H14.5439V10.9092C14.5437 12.1139 13.5671 13.0908 12.3623 13.0908H3.63477C2.43015 13.0906 1.45334 12.1138 1.45312 10.9092V8.72754H0.727539C0.325964 8.7275 7.21982e-05 8.40157 0 8C0 7.59837 0.32592 7.2725 0.727539 7.27246H1.45312V5.09082C1.45335 3.8862 2.43015 2.90942 3.63477 2.90918H7.27246V1.45508H5.09082C4.68943 1.4549 4.36346 1.12893 4.36328 0.727539C4.36328 0.325997 4.68932 0.00017902 5.09082 0H8ZM3.63477 4.36426C3.23346 4.3645 2.90843 4.68951 2.9082 5.09082V7.99023C2.90824 7.99344 2.90918 7.99678 2.90918 8C2.90918 8.00326 2.90825 8.00651 2.9082 8.00977V10.9092C2.90841 11.3105 3.23345 11.6365 3.63477 11.6367H12.3623C12.7638 11.6367 13.0896 11.3106 13.0898 10.9092V5.09082C13.0896 4.68937 12.7638 4.36428 12.3623 4.36426H3.63477ZM5.81738 6.54492C6.21902 6.54492 6.54489 6.87084 6.54492 7.27246V8.72656C6.54492 9.12822 6.21904 9.4541 5.81738 9.4541C5.41587 9.45393 5.08984 9.12811 5.08984 8.72656V7.27246C5.08988 6.87094 5.41589 6.54509 5.81738 6.54492ZM10.1816 6.54492C10.5831 6.54514 10.9091 6.87097 10.9092 7.27246V8.72656C10.9092 9.12808 10.5831 9.45388 10.1816 9.4541C9.77999 9.4541 9.4541 9.12822 9.4541 8.72656V7.27246C9.45413 6.87084 9.78001 6.54492 10.1816 6.54492Z",fill:"currentColor"})}),x$=wsn,_sn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsxs("g",{opacity:.9,children:[h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.4419 9.43023C15.7501 9.43023 16 9.68012 16 9.98837V10.0304C16 11.398 16 12.4813 15.886 13.329C15.7687 14.2015 15.5216 14.9077 14.9647 15.4647C14.4077 16.0216 13.7015 16.2687 12.829 16.386C11.9813 16.5 10.898 16.5 9.53035 16.5H9.48837C9.18012 16.5 8.93023 16.2501 8.93023 15.9419C8.93023 15.6336 9.18012 15.3837 9.48837 15.3837C10.9074 15.3837 11.9155 15.3825 12.6803 15.2797C13.429 15.1791 13.8604 14.9903 14.1753 14.6753C14.4903 14.3604 14.6791 13.929 14.7797 13.1803C14.8825 12.4155 14.8837 11.4074 14.8837 9.98837C14.8837 9.68012 15.1336 9.43023 15.4419 9.43023Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.55814 9.43023C0.866392 9.43023 1.11628 9.68012 1.11628 9.98837C1.11628 11.4074 1.11747 12.4155 1.22029 13.1803C1.32095 13.929 1.50973 14.3604 1.82467 14.6753C2.13962 14.9903 2.57098 15.1791 3.3197 15.2797C4.08448 15.3825 5.0926 15.3837 6.51163 15.3837C6.81988 15.3837 7.06977 15.6336 7.06977 15.9419C7.06977 16.2501 6.81988 16.5 6.51163 16.5H6.46965C5.10201 16.5 4.01875 16.5 3.17096 16.386C2.29846 16.2687 1.59227 16.0216 1.03534 15.4647C0.478423 14.9077 0.231266 14.2015 0.113961 13.329C-2.0957e-05 12.4813 -1.15596e-05 11.398 2.3934e-07 10.0304C3.72411e-07 10.0164 5.05482e-07 10.0024 5.05482e-07 9.98837C5.05482e-07 9.68012 0.249888 9.43023 0.55814 9.43023Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.46964 0.5L6.51163 0.500001C6.81988 0.500001 7.06977 0.749888 7.06977 1.05814C7.06977 1.36639 6.81988 1.61628 6.51163 1.61628C5.0926 1.61628 4.08448 1.61747 3.3197 1.72029C2.57098 1.82095 2.13962 2.00973 1.82467 2.32467C1.50973 2.63962 1.32095 3.07098 1.22029 3.8197C1.11747 4.58448 1.11628 5.5926 1.11628 7.01163C1.11628 7.31988 0.866392 7.56977 0.55814 7.56977C0.249888 7.56977 5.05482e-07 7.31988 5.05482e-07 7.01163L2.3934e-07 6.96964C-1.15596e-05 5.60201 -2.0957e-05 4.51875 0.113961 3.67096C0.231266 2.79846 0.478423 2.09227 1.03534 1.53534C1.59227 0.978423 2.29846 0.731266 3.17096 0.613961C4.01875 0.499979 5.10201 0.499988 6.46964 0.5Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.6803 1.72029C11.9155 1.61747 10.9074 1.61628 9.48837 1.61628C9.18012 1.61628 8.93023 1.36639 8.93023 1.05814C8.93023 0.749888 9.18012 0.500001 9.48837 0.500001C9.5024 0.500001 9.51639 0.5 9.53036 0.5C10.898 0.499988 11.9813 0.499979 12.829 0.613961C13.7015 0.731266 14.4077 0.978423 14.9647 1.53534C15.5216 2.09227 15.7687 2.79846 15.886 3.67096C16 4.51875 16 5.60201 16 6.96965V7.01163C16 7.31988 15.7501 7.56977 15.4419 7.56977C15.1336 7.56977 14.8837 7.31988 14.8837 7.01163C14.8837 5.5926 14.8825 4.58448 14.7797 3.8197C14.6791 3.07098 14.4903 2.63962 14.1753 2.32467C13.8604 2.00973 13.429 1.82095 12.6803 1.72029Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.70041 3.20041C2.04651 3.85431 2.04651 4.90675 2.04651 7.01163V9.98837C2.04651 12.0933 2.04651 13.1457 2.70041 13.7996C3.35431 14.4535 4.40675 14.4535 6.51163 14.4535H9.48837C11.5933 14.4535 12.6457 14.4535 13.2996 13.7996C13.9535 13.1457 13.9535 12.0933 13.9535 9.98837V7.01163C13.9535 4.90675 13.9535 3.85431 13.2996 3.20041C12.6457 2.54651 11.5933 2.54651 9.48837 2.54651H6.51163C4.40675 2.54651 3.35431 2.54651 2.70041 3.20041ZM5.65417 10.5348C5.81478 10.3181 6.12065 10.2726 6.33733 10.4332C6.8116 10.7848 7.38407 10.9884 8 10.9884C8.61593 10.9884 9.1884 10.7848 9.66267 10.4332C9.87936 10.2726 10.1852 10.3181 10.3458 10.5348C10.5064 10.7514 10.461 11.0573 10.2443 11.2179C9.61111 11.6873 8.83673 11.9651 8 11.9651C7.16327 11.9651 6.38889 11.6873 5.75569 11.2179C5.53901 11.0573 5.49356 10.7514 5.65417 10.5348ZM10.6047 7.24419C10.6047 7.78363 10.3131 8.22093 9.95349 8.22093C9.59386 8.22093 9.30233 7.78363 9.30233 7.24419C9.30233 6.70475 9.59386 6.26744 9.95349 6.26744C10.3131 6.26744 10.6047 6.70475 10.6047 7.24419ZM6.04651 8.22093C6.40614 8.22093 6.69767 7.78363 6.69767 7.24419C6.69767 6.70475 6.40614 6.26744 6.04651 6.26744C5.68688 6.26744 5.39535 6.70475 5.39535 7.24419C5.39535 7.78363 5.68688 8.22093 6.04651 8.22093Z",fill:"currentColor"})]})}),Ssn=_sn,ksn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M0 6.9375C0 6.30469 0.234375 5.69531 0.609375 5.25C0.5625 5.0625 0.5625 4.875 0.5625 4.6875C0.5625 3.9375 0.9375 3.25781 1.52344 2.85938C1.61719 2.17969 2.01562 1.59375 2.60156 1.26562C2.90625 0.515625 3.63281 0 4.5 0C5.08594 0 5.60156 0.257812 6 0.65625C6.375 0.257812 6.89062 0 7.5 0C8.34375 0 9.07031 0.515625 9.375 1.26562C9.96094 1.59375 10.3594 2.17969 10.4531 2.85938C11.0391 3.25781 11.4375 3.9375 11.4375 4.6875C11.4375 4.875 11.4141 5.0625 11.3672 5.25C11.7422 5.69531 12 6.30469 12 6.9375C12 7.66406 11.6953 8.32031 11.2266 8.78906L11.25 8.8125C11.25 9.9375 10.4297 10.8516 9.375 11.0391C9 11.625 8.34375 12 7.59375 12C6.96094 12 6.375 11.7422 6 11.2969C5.60156 11.7422 5.01562 12 4.40625 12C3.63281 12 2.97656 11.625 2.60156 11.0391C1.54688 10.8516 0.75 9.9375 0.75 8.8125V8.78906C0.28125 8.32031 0 7.66406 0 6.9375ZM5.41406 9.9375H5.4375V2.0625C5.4375 1.54688 5.01562 1.125 4.5 1.125C3.96094 1.125 3.5625 1.54688 3.5625 2.0625V2.08594C3.07031 2.17969 2.69531 2.55469 2.625 3.04688C2.625 3.09375 2.625 3.14062 2.625 3.1875C2.625 3.32812 2.625 3.46875 2.67188 3.58594C2.50781 3.60938 2.32031 3.65625 2.17969 3.75C1.89844 3.9375 1.71094 4.24219 1.6875 4.57031C1.6875 4.61719 1.6875 4.66406 1.6875 4.6875C1.6875 5.03906 1.82812 5.34375 2.0625 5.55469C1.71094 5.69531 1.40625 5.97656 1.24219 6.32812C1.17188 6.51562 1.10156 6.72656 1.10156 6.9375C1.10156 7.5 1.42969 7.99219 1.875 8.25C1.92188 8.27344 1.94531 8.29688 1.99219 8.32031C1.96875 8.34375 1.96875 8.36719 1.94531 8.39062C1.89844 8.53125 1.875 8.67188 1.875 8.8125C1.875 9.32812 2.20312 9.77344 2.67188 9.91406C2.76562 9.9375 2.88281 9.9375 3 9.9375C3.11719 9.9375 3.25781 9.91406 3.375 9.89062C3.375 10.1016 3.44531 10.3125 3.58594 10.4766C3.77344 10.7344 4.05469 10.875 4.40625 10.875C4.92188 10.875 5.36719 10.4766 5.41406 9.9375ZM8.41406 2.08594L8.4375 2.0625C8.4375 1.54688 8.01562 1.125 7.5 1.125C6.96094 1.125 6.5625 1.54688 6.5625 2.0625V9.9375C6.60938 10.4766 7.05469 10.875 7.59375 10.875C7.92188 10.875 8.20312 10.7344 8.39062 10.4766C8.53125 10.3125 8.60156 10.1016 8.60156 9.89062C8.71875 9.91406 8.85938 9.9375 9 9.9375C9.09375 9.9375 9.21094 9.9375 9.30469 9.91406C9.77344 9.77344 10.125 9.32812 10.125 8.8125C10.125 8.67188 10.0781 8.53125 10.0312 8.39062C10.0078 8.36719 10.0078 8.34375 9.98438 8.32031C10.0312 8.29688 10.0547 8.27344 10.1016 8.25C10.5469 7.99219 10.875 7.5 10.875 6.9375C10.875 6.72656 10.8047 6.51562 10.7344 6.32812C10.5703 5.97656 10.2656 5.69531 9.91406 5.55469C10.1484 5.34375 10.3125 5.03906 10.3125 4.6875C10.3125 4.66406 10.2891 4.61719 10.2891 4.57031C10.2656 4.24219 10.0781 3.9375 9.79688 3.75C9.65625 3.65625 9.46875 3.60938 9.30469 3.58594C9.35156 3.46875 9.375 3.32812 9.375 3.1875C9.375 3.14062 9.35156 3.09375 9.35156 3.04688C9.28125 2.55469 8.90625 2.17969 8.41406 2.08594Z",fill:"currentColor"})}),Esn=ksn,Tsn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M5.09091 16.5V15.0455H1.45455C1.05455 15.0455 0.712121 14.903 0.427273 14.6182C0.142424 14.3333 0 13.9909 0 13.5909V3.40909C0 3.00909 0.142424 2.66667 0.427273 2.38182C0.712121 2.09697 1.05455 1.95455 1.45455 1.95455H5.09091V0.5H6.54545V16.5H5.09091ZM8 15.0455V13.5909L11.6364 13.5909V3.40909H8V1.95455H11.6364C12.0364 1.95455 12.3788 2.09697 12.6636 2.38182C12.9485 2.66667 13.0909 3.00909 13.0909 3.40909V13.5909C13.0909 13.9909 12.9485 14.3333 12.6636 14.6182C12.3788 14.903 12.0364 15.0455 11.6364 15.0455H8Z",fill:"currentColor"})}),Asn=Tsn,Csn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 22 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4824 12.432L21.0265 6.20004L10.5441 0L0 6.20004L10.4824 12.432Z",fill:"#ECF2F9"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4729 11.7499L19.75 6.23584L10.5271 0.749939L1.25 6.23584L10.4729 11.7499Z",fill:"#FDFEFF"}),h.jsx("path",{d:"M10.5 11.7499V0.749939L19.75 6.24994L10.5 11.7499Z",fill:"url(#paint0_linear_10651_178757)"}),h.jsx("path",{d:"M10.5 11.7499V0.749939L1.25 6.24994L10.5 11.7499Z",fill:"#0E1623"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 6.20001V18.686L10.5441 25V12.4319L0 6.20001Z",fill:"#CEE0F8"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.0265 6.20001V18.686L10.4824 25V12.4319L21.0265 6.20001Z",fill:"#82A0CE"}),h.jsx("path",{d:"M10.4973 11.7478L4.64099 8.26706V8.95172L10.4973 12.4126L15.8148 9.27748V8.59062L10.4973 11.7478Z",fill:"#ECF2F9"}),h.jsx("defs",{children:h.jsxs("linearGradient",{id:"paint0_linear_10651_178757",x1:15.0834,y1:2.10412,x2:15.125,y2:11.7499,gradientUnits:"userSpaceOnUse",children:[h.jsx("stop",{stopColor:"#5E7BAA"}),h.jsx("stop",{offset:1,stopColor:"#030407"})]})})]}),Rsn=Csn,Isn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_5446_3655)",children:[h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.15174 1.36702C8.86989 1.09272 8.49212 0.939234 8.09883 0.939234C7.70553 0.939234 7.32776 1.09272 7.04591 1.36702L1.43074 6.87369C1.33678 6.96502 1.21091 7.01611 1.07987 7.01611C0.948831 7.01611 0.822958 6.96502 0.728994 6.87369C0.68299 6.82895 0.646423 6.77544 0.621453 6.71633C0.596483 6.65721 0.583618 6.59369 0.583618 6.52952C0.583618 6.46535 0.596483 6.40183 0.621453 6.34272C0.646423 6.2836 0.68299 6.23009 0.728994 6.18536L6.34416 0.678689C6.81387 0.221585 7.44341 -0.0341797 8.09883 -0.0341797C8.75424 -0.0341797 9.38379 0.221585 9.85349 0.678689C10.1253 0.943 10.3306 1.26791 10.4527 1.62683C10.5748 1.98575 10.6101 2.36848 10.5558 2.74369C10.936 2.68962 11.3235 2.72356 11.6885 2.8429C12.0535 2.96224 12.3863 3.16379 12.6611 3.43202L12.6902 3.46119C12.9203 3.68489 13.1031 3.95243 13.2279 4.248C13.3528 4.54357 13.4171 4.86117 13.4171 5.18202C13.4171 5.50288 13.3528 5.82048 13.2279 6.11605C13.1031 6.41162 12.9203 6.67916 12.6902 6.90286L7.61174 11.8828C7.59642 11.8977 7.58423 11.9155 7.57591 11.9352C7.56759 11.9549 7.5633 11.976 7.5633 11.9974C7.5633 12.0188 7.56759 12.0399 7.57591 12.0596C7.58423 12.0793 7.59642 12.0971 7.61174 12.112L8.65474 13.1352C8.70075 13.1799 8.73731 13.2334 8.76228 13.2926C8.78725 13.3517 8.80012 13.4152 8.80012 13.4794C8.80012 13.5435 8.78725 13.607 8.76228 13.6662C8.73731 13.7253 8.70075 13.7788 8.65474 13.8235C8.56078 13.9149 8.43491 13.9659 8.30387 13.9659C8.17283 13.9659 8.04696 13.9149 7.95299 13.8235L6.90999 12.8009C6.80257 12.6966 6.71717 12.5717 6.65886 12.4337C6.60054 12.2957 6.5705 12.1475 6.5705 11.9977C6.5705 11.8479 6.60054 11.6996 6.65886 11.5617C6.71717 11.4237 6.80257 11.2988 6.90999 11.1944L11.9885 6.21394C12.1264 6.07968 12.2361 5.91914 12.3109 5.74181C12.3858 5.56447 12.4244 5.37393 12.4244 5.18144C12.4244 4.98895 12.3858 4.79841 12.3109 4.62107C12.2361 4.44374 12.1264 4.2832 11.9885 4.14894L11.9593 4.12036C11.6778 3.84634 11.3005 3.69287 10.9076 3.69254C10.5148 3.69222 10.1372 3.84506 9.85524 4.11861L5.67158 8.22177L5.67041 8.22294L5.61324 8.27952C5.51925 8.37103 5.39326 8.42223 5.26208 8.42223C5.1309 8.42223 5.0049 8.37103 4.91091 8.27952C4.86491 8.23478 4.82834 8.18128 4.80337 8.12216C4.7784 8.06305 4.76553 7.99953 4.76553 7.93536C4.76553 7.87118 4.7784 7.80766 4.80337 7.74855C4.82834 7.68944 4.86491 7.63593 4.91091 7.59119L9.15349 3.43027C9.29105 3.29592 9.40033 3.1354 9.47488 2.95816C9.54943 2.78093 9.58776 2.59056 9.58759 2.39828C9.58743 2.206 9.54878 2.0157 9.47393 1.83859C9.39907 1.66147 9.28953 1.50114 9.15174 1.36702Z",fill:"currentColor"}),h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.44964 2.74425C8.49564 2.69951 8.53221 2.646 8.55718 2.58689C8.58215 2.52777 8.59501 2.46425 8.59501 2.40008C8.59501 2.33591 8.58215 2.27239 8.55718 2.21328C8.53221 2.15416 8.49564 2.10066 8.44964 2.05592C8.35564 1.96441 8.22965 1.91321 8.09847 1.91321C7.96729 1.91321 7.84129 1.96441 7.7473 2.05592L3.59455 6.12875C3.36454 6.35245 3.1817 6.61999 3.05685 6.91556C2.932 7.21113 2.86768 7.52873 2.86768 7.84958C2.86768 8.17044 2.932 8.48804 3.05685 8.78361C3.1817 9.07918 3.36454 9.34672 3.59455 9.57042C4.06433 10.0274 4.69385 10.2831 5.34922 10.2831C6.00459 10.2831 6.63411 10.0274 7.10389 9.57042L11.2572 5.49758C11.3032 5.45284 11.3398 5.39934 11.3648 5.34022C11.3897 5.28111 11.4026 5.21759 11.4026 5.15342C11.4026 5.08925 11.3897 5.02573 11.3648 4.96661C11.3398 4.9075 11.3032 4.85399 11.2572 4.80925C11.1632 4.71774 11.0372 4.66654 10.9061 4.66654C10.7749 4.66654 10.6489 4.71774 10.5549 4.80925L6.40214 8.88208C6.12029 9.15639 5.74252 9.30987 5.34922 9.30987C4.95592 9.30987 4.57815 9.15639 4.2963 8.88208C4.15836 8.74782 4.04873 8.58729 3.97386 8.40995C3.899 8.23261 3.86043 8.04207 3.86043 7.84958C3.86043 7.65709 3.899 7.46655 3.97386 7.28922C4.04873 7.11188 4.15836 6.95134 4.2963 6.81708L8.44964 2.74425Z",fill:"currentColor"})]}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_5446_3655",children:h.jsx("rect",{width:14,height:14,fill:"white"})})})]}),Nsn=Isn,Msn=e=>h.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:h.jsx("path",{d:"M7 0C10.8555 0 14 3.14453 14 7C14 10.8828 10.8555 14 7 14C3.11719 14 0 10.8828 0 7C0 3.14453 3.11719 0 7 0ZM7 12.6875C7.19141 12.6875 7.71094 12.4961 8.28516 11.375C8.53125 10.8828 8.72266 10.3086 8.88672 9.625H5.08594C5.25 10.3086 5.44141 10.8828 5.6875 11.375C6.26172 12.4961 6.78125 12.6875 7 12.6875ZM4.86719 8.3125H9.10547C9.16016 7.90234 9.1875 7.46484 9.1875 7C9.1875 6.5625 9.16016 6.125 9.10547 5.6875H4.86719C4.8125 6.125 4.8125 6.5625 4.8125 7C4.8125 7.46484 4.8125 7.90234 4.86719 8.3125ZM8.88672 4.375C8.72266 3.71875 8.53125 3.14453 8.28516 2.65234C7.71094 1.53125 7.19141 1.3125 7 1.3125C6.78125 1.3125 6.26172 1.53125 5.6875 2.65234C5.44141 3.14453 5.25 3.71875 5.08594 4.375H8.88672ZM10.418 5.6875C10.4727 6.125 10.5 6.5625 10.5 7C10.5 7.46484 10.4727 7.90234 10.418 8.3125H12.5234C12.6328 7.90234 12.6875 7.46484 12.6875 7C12.6875 6.5625 12.6328 6.125 12.5234 5.6875H10.418ZM9.35156 1.83203C9.73438 2.54297 10.0352 3.41797 10.2266 4.375H12.0312C11.457 3.25391 10.5 2.35156 9.35156 1.83203ZM4.62109 1.83203C3.47266 2.35156 2.51562 3.25391 1.94141 4.375H3.74609C3.9375 3.41797 4.23828 2.54297 4.62109 1.83203ZM1.3125 7C1.3125 7.46484 1.33984 7.90234 1.44922 8.3125H3.55469C3.5 7.90234 3.5 7.46484 3.5 7C3.5 6.5625 3.5 6.125 3.55469 5.6875H1.44922C1.33984 6.125 1.3125 6.5625 1.3125 7ZM12.0312 9.625H10.2266C10.0352 10.6094 9.73438 11.4844 9.35156 12.1953C10.5 11.6758 11.457 10.7734 12.0312 9.625ZM3.74609 9.625H1.94141C2.51562 10.7734 3.47266 11.6758 4.62109 12.1953C4.23828 11.4844 3.9375 10.6094 3.74609 9.625Z",fill:"currentColor"})}),Osn=Msn,Psn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_10581_4008)",children:[h.jsx("path",{d:"M-0.000793457 0.015625L39.9992 20.0156V40L19.9992 40V80.0156H39.9992V100.016L-0.000793457 120.016V0.015625Z",fill:"white"}),h.jsx("path",{d:"M119.999 0L79.9992 20V40H99.9992V80H79.9992V100L119.999 120V0Z",fill:"white"}),h.jsx("path",{d:"M59.9955 39.8193C61.054 45.6178 63.1935 50.1614 66.5756 53.5215C69.9439 56.868 74.4722 58.9678 80.2035 60.0088C74.4696 61.0714 69.9413 63.2075 66.5736 66.5752C63.1938 69.955 61.0542 74.5036 59.9955 80.2666C58.9314 74.5031 56.7838 69.9547 53.3988 66.5752C50.026 63.2078 45.4965 61.0704 39.7709 60.0078C45.4938 58.9668 50.0235 56.8676 53.3969 53.5215C56.7841 50.1616 58.9316 45.6182 59.9955 39.8193Z",fill:"white",stroke:"white",strokeWidth:1.6,strokeLinejoin:"round"})]}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_10581_4008",children:h.jsx("rect",{width:120,height:120,fill:"white"})})})]}),jsn=Psn,Dsn=e=>h.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[h.jsxs("g",{clipPath:"url(#clip0_10581_1729)",children:[h.jsx("path",{d:"M-0.000976562 0.0195312L46.6657 23.3529V46.668L23.3324 46.668V93.3529H46.6657V116.686L-0.000976562 140.02V0.0195312Z",fill:"#05090E"}),h.jsx("path",{d:"M139.999 0L93.3324 23.3333V46.6667H116.666V93.3333H93.3324V116.667L139.999 140V0Z",fill:"#05090E"}),h.jsx("path",{d:"M69.9941 46.4561C71.2291 53.2208 73.7252 58.5213 77.6709 62.4414C81.6 66.345 86.8814 68.7951 93.5664 70.0098C86.8784 71.2497 81.5974 73.7435 77.6689 77.6719C73.7259 81.615 71.2293 86.921 69.9941 93.6445C68.7527 86.9203 66.2461 81.6138 62.2969 77.6709C58.3624 73.7429 53.0791 71.2496 46.4004 70.0098C53.076 68.7952 58.3597 66.3456 62.2949 62.4424C66.2468 58.5225 68.7529 53.2215 69.9941 46.4561Z",fill:"#6D58FB",stroke:"#6D58FB",strokeWidth:1.86667,strokeLinejoin:"round"})]}),h.jsx("defs",{children:h.jsx("clipPath",{id:"clip0_10581_1729",children:h.jsx("rect",{width:140,height:140,fill:"white"})})})]}),Lsn=Dsn;RJe({"mcp-server":Nsn,"agent-2":x$,bot:x$,robot:x$,compare:Asn,ai:Ssn,searchGlobe:Osn,"brain-regular":Esn,empty:Rsn,"trueforge-logomark-light":Lsn,"trueforge-logomark-dark":jsn});var zsn=1e3,$sn=5e3;function Usn(e){var r;if(e.get("error"))return!1;const t=(r=e.get("isSuccess"))==null?void 0:r.toLowerCase();if(t==="true")return!0;if(t==="false")return!1;const n=e.get("code");return n!=null&&n.length>0}var Fsn=()=>{const[e,t]=_.useState();_.useEffect(()=>{const a=new URLSearchParams(window.location.search),i=a.get("pUid"),s=Usn(a);t(i?{popupUid:i,isSuccess:s}:null);const l=()=>{if(!i)return;const d=new BroadcastChannel(J6e),f={popupUid:i,isSuccess:s};d.postMessage(f),d.close()};l();const c=window.setTimeout(l,zsn),u=window.setTimeout(()=>{window.close()},$sn);return()=>{window.clearTimeout(c),window.clearTimeout(u)}},[]);const n=!!(e!=null&&e.isSuccess),r=e===void 0?"Completing authorization":n?"Authorization successful":"Authorization failed",o=e===void 0?"Please wait while the authorization result is confirmed.":e===null?"The authorization result is invalid. You can close this window and try again.":n?"The MCP server is now connected. This window will close automatically.":"The MCP server could not be authorized. You can close this window and try again.";return h.jsx("main",{className:"flex min-h-screen items-center justify-center bg-primary-bg p-6",children:h.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-3 rounded-2xl border border-border bg-card-bg p-8 text-center shadow-sm",children:[e===void 0?h.jsx(be,{name:"oauth-loading",className:"size-16 animate-spin text-text-secondary"}):n?h.jsx(be,{name:"oauth-success",className:"size-16 text-success-bg"}):h.jsx(be,{name:"oauth-error",className:"size-16 text-failure-bg"}),h.jsx("h1",{className:"text-2xl font-semibold text-text-primary",children:r}),h.jsx("p",{className:"text-sm leading-6 text-text-secondary",children:o})]})})},Bsn=Fsn,Hsn=_.lazy(()=>Ya(()=>import("./TrueForgeUIWithRouter-LFJ4E5VL-BNRfP9iQ.js"),__vite__mapDeps([16,15]),import.meta.url).then(e=>({default:e.TrueForgeUIWithRouter})));function Vsn(e){if(typeof window<"u"&&new URLSearchParams(window.location.search).get("screenType")==="mcp-auth")return h.jsx(a1,{overrides:e.overrides,theme:e.theme,children:h.jsx(Bsn,{})});const{withRouter:n,...r}=e;return n?h.jsx(_.Suspense,{fallback:h.jsx(s8e,{className:e.className}),children:h.jsx(Hsn,{...r})}):h.jsx(ysn,{...r})}const uN=(e,t,n)=>JSON.stringify(e,t,n);function Fv(e,t){return JSON.parse(e,t)}class Pe extends Error{constructor({message:t,statusCode:n,body:r,rawResponse:o,cause:a}){super(Gsn({message:t,statusCode:n,body:r})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="TrueForgeError",this.statusCode=n,this.body=r,this.rawResponse=o,a!=null&&(this.cause=a)}get requestId(){var o;const t=(o=this.rawResponse)==null?void 0:o.headers;if(t==null)return;const n=t.get("X-Request-Id");if(n!=null)return n;let r;return t.forEach((a,i)=>{r===void 0&&/request[-_]?id$/i.test(i)&&(r=a)}),r}}function Gsn({message:e,statusCode:t,body:n}){const r=[];return e!=null&&r.push(e),t!=null&&r.push(`Status code: ${t.toString()}`),n!=null&&r.push(`Body: ${uN(n,void 0,2)}`),r.join(`
1103
1103
  `)}class Wsn extends Pe{constructor(t,n){super({message:t,cause:n==null?void 0:n.cause}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="TrueForgeTimeoutError"}}class s2 extends Pe{constructor(t,n){super({message:"BadGatewayError",statusCode:502,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="BadGatewayError"}}class In extends Pe{constructor(t,n){super({message:"BadRequestError",statusCode:400,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="BadRequestError"}}class ui extends Pe{constructor(t,n){super({message:"ConflictError",statusCode:409,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="ConflictError"}}class l2 extends Pe{constructor(t,n){super({message:"ContentTooLargeError",statusCode:413,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="ContentTooLargeError"}}class Hs extends Pe{constructor(t,n){super({message:"FailedDependencyError",statusCode:424,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="FailedDependencyError"}}class nr extends Pe{constructor(t,n){super({message:"ForbiddenError",statusCode:403,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="ForbiddenError"}}class Ksn extends Pe{constructor(t,n){super({message:"GoneError",statusCode:410,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="GoneError"}}class l8e extends Pe{constructor(t,n){super({message:"InternalServerError",statusCode:500,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="InternalServerError"}}class _n extends Pe{constructor(t,n){super({message:"NotFoundError",statusCode:404,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="NotFoundError"}}class Av extends Pe{constructor(t,n){super({message:"PreconditionFailedError",statusCode:412,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="PreconditionFailedError"}}class Fn extends Pe{constructor(t,n){super({message:"UnauthorizedError",statusCode:401,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="UnauthorizedError"}}class Bo extends Pe{constructor(t,n){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:n}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="UnprocessableEntityError"}}const Ysn={Openai:"openai",Anthropic:"anthropic",GoogleGemini:"google-gemini",Fireworks:"fireworks",Zai:"zai",Moonshot:"moonshot",Alibaba:"alibaba",Together:"together"};function Zsn(e){return typeof e=="object"&&e!==null&&"getAuthRequest"in e&&typeof e.getAuthRequest=="function"}class c8e{getAuthRequest(){return Promise.resolve({headers:{}})}}const u8e={get:async(e,t)=>typeof e=="function"?e(t):e},fu={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},_we={[fu.Debug]:1,[fu.Info]:2,[fu.Warn]:3,[fu.Error]:4};class d8e{debug(t,...n){console.debug(t,...n)}info(t,...n){console.info(t,...n)}warn(t,...n){console.warn(t,...n)}error(t,...n){console.error(t,...n)}}class mB{constructor(t){this.level=_we[t.level],this.logger=t.logger,this.silent=t.silent}shouldLog(t){return!this.silent&&this.level<=_we[t]}isDebug(){return this.shouldLog(fu.Debug)}debug(t,...n){this.isDebug()&&this.logger.debug(t,...n)}isInfo(){return this.shouldLog(fu.Info)}info(t,...n){this.isInfo()&&this.logger.info(t,...n)}isWarn(){return this.shouldLog(fu.Warn)}warn(t,...n){this.isWarn()&&this.logger.warn(t,...n)}isError(){return this.shouldLog(fu.Error)}error(t,...n){this.isError()&&this.logger.error(t,...n)}}function lee(e){return e==null?Xsn:e instanceof mB?e:(e=e??{},e.level??(e.level=fu.Info),e.logger??(e.logger=new d8e),e.silent??(e.silent=!0),new mB(e))}const Xsn=new mB({level:fu.Info,logger:new d8e,silent:!0}),qsn={arrayFormat:"indices",encode:!0};function w$(e,t){if(e===void 0||e===null)return"";const n=String(e);return t?encodeURIComponent(n):n}function bB(e,t="",n){const r=[];for(const[o,a]of Object.entries(e)){const i=t?`${t}[${o}]`:o;if(a!=null)if(Array.isArray(a)){if(a.length===0)continue;const s=n.arrayFormat;if(s==="comma"){const l=n.encode?encodeURIComponent(i):i,c=a.filter(u=>u!=null).map(u=>w$(u,n.encode));c.length>0&&r.push(`${l}=${c.join(",")}`)}else for(let l=0;l<a.length;l++){const c=a[l];if(c!=null)if(typeof c=="object"&&!Array.isArray(c)&&c!==null){const u=s==="indices"?`${i}[${l}]`:i;r.push(...bB(c,u,n))}else{const u=s==="indices"?`${i}[${l}]`:i,d=n.encode?encodeURIComponent(u):u;r.push(`${d}=${w$(c,n.encode)}`)}}}else if(typeof a=="object"&&a!==null){if(Object.keys(a).length===0)continue;r.push(...bB(a,i,n))}else{const s=n.encode?encodeURIComponent(i):i;r.push(`${s}=${w$(a,n.encode)}`)}}return r}function dN(e,t){return e==null||typeof e!="object"?"":bB(e,"",{...qsn,...t}).join("&")}function Qsn(e,t){const n=dN(t,{arrayFormat:"repeat"});return n?`${e}?${n}`:e}function Jsn(e){const t={get bodyUsed(){return e.bodyUsed},stream:()=>e.body,arrayBuffer:e.arrayBuffer.bind(e),blob:e.blob.bind(e)};return"bytes"in e&&typeof e.bytes=="function"&&(t.bytes=e.bytes.bind(e)),t}function Swe(e,t){Object.defineProperty(e,"__fern_response_ref",{value:t,enumerable:!1,configurable:!0,writable:!1})}const p8e=new WeakSet;function _$(e){const t={ok:!1,error:e};return p8e.add(t),t}function f8e(e){return typeof e=="object"&&e!=null&&p8e.has(e)}async function h8e(e,t){switch(t){case"binary-response":return Jsn(e);case"blob":return await e.blob();case"arrayBuffer":return await e.arrayBuffer();case"sse":return e.body==null?_$({reason:"body-is-null",statusCode:e.status}):(Swe(e.body,e),e.body);case"streaming":return e.body==null?_$({reason:"body-is-null",statusCode:e.status}):(Swe(e.body,e),e.body);case"text":return await e.text()}const n=await e.text();if(n.length>0)try{return Fv(n)}catch{return _$({reason:"non-json",statusCode:e.status,rawBody:n})}}function kwe(e){if(e.length!==0)try{return Fv(e)}catch{return e}}async function eln(e){var n,r;let t=(n=e.headers.get("Content-Type"))==null?void 0:n.toLowerCase();if(t==null||t.length===0){const o=await h8e(e);return f8e(o)?o.error.reason==="non-json"?o.error.rawBody:void 0:o}switch(t.indexOf(";")!==-1&&(t=((r=t.split(";")[0])==null?void 0:r.trim())??""),t){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":return kwe(await e.text());default:return t.startsWith("application/vnd.")&&t.endsWith("+json")?kwe(await e.text()):await e.text()}}async function g8e(){return fetch}async function tln({body:e,type:t}){return t==="form"?dN(e,{arrayFormat:"repeat",encode:!0}):t.includes("json")?uN(e):e}let y0;typeof globalThis.Headers<"u"?y0=globalThis.Headers:y0=class m8e{constructor(t){if(this.headers=new Map,t)if(t instanceof m8e)t.forEach((n,r)=>this.append(r,n));else if(Array.isArray(t))for(const[n,r]of t)if(typeof n=="string"&&typeof r=="string")this.append(n,r);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(const[n,r]of Object.entries(t))if(typeof r=="string")this.append(n,r);else throw new TypeError("Header values must be strings")}append(t,n){const r=t.toLowerCase(),o=this.headers.get(r)||[];this.headers.set(r,[...o,n])}delete(t){const n=t.toLowerCase();this.headers.delete(n)}get(t){const n=t.toLowerCase(),r=this.headers.get(n);return r?r.join(", "):null}has(t){const n=t.toLowerCase();return this.headers.has(n)}set(t,n){const r=t.toLowerCase();this.headers.set(r,[n])}forEach(t,n){const r=n?t.bind(n):t;this.headers.forEach((o,a)=>r(o.join(", "),a,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(const[t,n]of this.headers.entries())yield[t,n.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(const t of this.headers.values())yield t.join(", ")}[Symbol.iterator](){return this.entries()}};const P3="timeout";function nln(e){const t=new AbortController,n=setTimeout(()=>t.abort(P3),e);return{signal:t.signal,abortId:n}}function rln(...e){const t=e.length===1&&Array.isArray(e[0])?e[0]:e,n=new AbortController;for(const r of t)if(r.aborted||(r.addEventListener("abort",()=>n.abort(r==null?void 0:r.reason),{signal:n.signal}),r.aborted))return n.abort(r==null?void 0:r.reason),n.signal;return n.signal}let qw;function oln(){if(qw!=null)return qw;try{new Request("http://localhost",{cache:"no-store"}),qw=!0}catch{qw=!1}return qw}const vB=new WeakMap;function Ewe(e){const t=vB.get(e);t!=null&&(clearTimeout(t),vB.delete(e))}const b8e=async(e,t,n,r,o,a,i,s,l,c,u)=>{const d=[];let f,g;if(a!=null){const{signal:y,abortId:w}=nln(a);f=w,g=y,d.push(y)}i!=null&&d.push(i);const b=rln(d);let v;try{v=await e(t,{method:n,headers:r,body:o,signal:b,credentials:s?"include":void 0,duplex:l,...c&&oln()?{cache:"no-store"}:{}})}catch(y){throw f!=null&&clearTimeout(f),g!=null&&g.aborted&&!(i!=null&&i.aborted)?P3:y}return f!=null&&(u?vB.set(v,f):clearTimeout(f)),v},Twe={headers:new y0,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},Awe={headers:new y0,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function S$(e){return{headers:e.headers,redirected:e.redirected,status:e.status,statusText:e.statusText,type:e.type,url:e.url}}const yB=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function kd(e){const t=e.indexOf("://");if(t===-1)return e;const n=t+3,r=e.indexOf("/",n);let o=e.indexOf("?",n),a=e.indexOf("#",n);const i=Math.min(r===-1?e.length:r,o===-1?e.length:o,a===-1?e.length:a);let s=-1;for(let b=n;b<i;b++)e[b]==="@"&&(s=b);if(s!==-1&&(e=`${e.slice(0,n)}[REDACTED]@${e.slice(s+1)}`),o=e.indexOf("?"),o===-1)return e;a=e.indexOf("#",o);const l=a!==-1?a:e.length,c=e.slice(o+1,l);if(c.length===0)return e;const u=c.toLowerCase();if(!(u.includes("token")||u.includes("key")||u.includes("password")||u.includes("passwd")||u.includes("secret")||u.includes("session")||u.includes("auth")))return e;const f=[],g=c.split("&");for(const b of g){const v=b.indexOf("=");if(v===-1){f.push(b);continue}const y=b.slice(0,v);let w=yB.has(y.toLowerCase());if(!w&&y.includes("%"))try{const S=decodeURIComponent(y);w=yB.has(S.toLowerCase())}catch{}f.push(w?`${y}=[REDACTED]`:b)}return e.slice(0,o+1)+f.join("&")+e.slice(l)}const aln=1e3,uC=6e4,iln=2,v8e=.2;function sln(e){return[408,429].includes(e)||e>=500}function lln(e){const t=1+Math.random()*v8e;return e*t}function cln(e){const t=1+(Math.random()-.5)*v8e;return e*t}function uln(e,t){const n=e.headers.get("Retry-After");if(n){const o=parseInt(n,10);if(!Number.isNaN(o)&&o>0)return Math.min(o*1e3,uC);const a=new Date(n);if(!Number.isNaN(a.getTime())){const i=a.getTime()-Date.now();if(i>0)return Math.min(Math.max(i,0),uC)}}const r=e.headers.get("X-RateLimit-Reset");if(r){const o=parseInt(r,10);if(!Number.isNaN(o)){const a=o*1e3-Date.now();if(a>0)return lln(Math.min(a,uC))}}return cln(Math.min(aln*2**t,uC))}function dln(e,t){return new Promise((n,r)=>{if(t!=null&&t.aborted){r(t.reason);return}const o=()=>{clearTimeout(a),r(t==null?void 0:t.reason)},a=setTimeout(()=>{t==null||t.removeEventListener("abort",o),n()},e);t==null||t.addEventListener("abort",o,{once:!0})})}async function y8e(e,t=iln,n){let r=await e();for(let o=0;o<t&&sln(r.status);++o){const a=uln(r,o);await dln(a,n),r=await e()}return r}const pln=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function k$(e){const t={};for(const[n,r]of e instanceof y0?e.entries():Object.entries(e))pln.has(n.toLowerCase())?t[n]="[REDACTED]":t[n]=r;return t}function fln(e){if(e==null)return;const t={};for(const[n,r]of Object.entries(e))t[n]=yB.has(n.toLowerCase())?"[REDACTED]":r;return t}async function hln(e){const t=new y0;if(t.set("Accept",e.responseType==="json"?"application/json":e.responseType==="text"?"text/plain":e.responseType==="sse"?"text/event-stream":"*/*"),e.body!==void 0&&e.contentType!=null&&t.set("Content-Type",e.contentType),e.headers==null)return t;for(const[n,r]of Object.entries(e.headers)){const o=await u8e.get(r,{endpointMetadata:e.endpointMetadata??{}});if(typeof o=="string"){t.set(n,o);continue}o!=null&&t.set(n,`${o}`)}return t}function gln(e){var n;const t=((n=e==null?void 0:e.split(";")[0])==null?void 0:n.trim().toLowerCase())??"";return t==="application/json"||t==="text/json"||t.endsWith("+json")}async function mln(e){var l;let t=e.url;e.queryString!=null&&e.queryString.length>0?t=`${t}?${e.queryString}`:t=Qsn(e.url,e.queryParameters);const n=await tln({body:e.body,type:e.requestType??"other"}),r=e.fetchFn??await g8e(),o=await hln(e),a=lee(e.logging);if(a.isDebug()){const c={method:e.method,url:kd(t),headers:k$(o),queryParameters:fln(e.queryParameters),hasBody:n!=null};a.debug("Making HTTP request",c)}const i=e.responseType!=="streaming"&&e.responseType!=="sse"&&e.responseType!=="binary-response",s=[];try{const c=await y8e(async()=>{for(const d of s)Ewe(d);const u=await b8e(r,t,e.method,o,n,e.timeoutMs,e.abortSignal,e.withCredentials,e.duplex,e.responseType==="streaming"||e.responseType==="sse",i);return s.push(u),u},e.maxRetries,e.abortSignal);if(c.status>=200&&c.status<400){if(a.isDebug()){const d={method:e.method,url:kd(t),statusCode:c.status,responseHeaders:k$(c.headers)};a.debug("HTTP request succeeded",d)}const u=await h8e(c,e.responseType);return f8e(u)&&u.error.reason==="non-json"&&gln(c.headers.get("Content-Type"))?{ok:!1,error:u.error,rawResponse:S$(c)}:{ok:!0,body:u,headers:c.headers,rawResponse:S$(c)}}else{if(a.isError()){const u={method:e.method,url:kd(t),statusCode:c.status,responseHeaders:k$(Object.fromEntries(c.headers.entries()))};a.error("HTTP request failed with error status",u)}return{ok:!1,error:{reason:"status-code",statusCode:c.status,body:await eln(c)},rawResponse:S$(c)}}}catch(c){if((l=e.abortSignal)!=null&&l.aborted){if(a.isError()){const u={method:e.method,url:kd(t)};a.error("HTTP request was aborted",u)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:c},rawResponse:Twe}}else if(c===P3||c instanceof Error&&c.name==="AbortError"){if(a.isError()){const u={method:e.method,url:kd(t),timeoutMs:e.timeoutMs};a.error("HTTP request timed out",u)}return{ok:!1,error:{reason:"timeout",cause:c},rawResponse:Twe}}else if(c instanceof Error){if(a.isError()){const u={method:e.method,url:kd(t),errorMessage:c.message};a.error("HTTP request failed with error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:c.message,cause:c},rawResponse:Awe}}if(a.isError()){const u={method:e.method,url:kd(t),error:uN(c)};a.error("HTTP request failed with unknown error",u)}return{ok:!1,error:{reason:"unknown",errorMessage:uN(c),cause:c},rawResponse:Awe}}finally{for(const c of s)Ewe(c)}}const pt=mln;class lt extends Promise{constructor(t){super(n=>{n(void 0)}),this.innerPromise=t}static fromFunction(t,...n){return new lt(t(...n))}static interceptFunction(t){return(...n)=>lt.fromPromise(t(...n))}static fromPromise(t){return new lt(t)}static fromExecutor(t){const n=new Promise(t);return new lt(n)}static fromResult(t){const n=Promise.resolve(t);return new lt(n)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,n){return this.unwrap().then(t,n)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}async withRawResponse(){return await this.innerPromise}}function ut(e,...t){if(!e)return"";if(t.length===0)return e;if(e.includes("://")){let n;try{n=new URL(e)}catch{return Cwe(e,...t)}const r=t[t.length-1],o=r==null?void 0:r.endsWith("/");for(const a of t){const i=w8e(a);i&&(n.pathname=x8e(n.pathname,i))}return o&&!n.pathname.endsWith("/")&&(n.pathname+="/"),n.toString()}return Cwe(e,...t)}function Cwe(e,...t){if(t.length===0)return e;let n=e;const r=t[t.length-1],o=r==null?void 0:r.endsWith("/");for(const a of t){const i=w8e(a);i&&(n=x8e(n,i))}return o&&!n.endsWith("/")&&(n+="/"),n}function x8e(e,t){return e.endsWith("/")?e+t:`${e}/${t}`}function w8e(e){if(!e)return e;let t=0,n=e.length;return e.startsWith("/")&&(t=1),e.endsWith("/")&&(n=e.length-1),t===0&&n===e.length?e:e.slice(t,n)}const Ee={get:async e=>typeof e=="function"?e():e};async function bln(e,t,n,r){const o=lee(n.logging);let a,i=t;e instanceof Request?(a=e.url,t==null&&(i={method:e.method,headers:Object.fromEntries(e.headers.entries()),body:e.body,signal:e.signal,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity,mode:e.mode})):a=e instanceof URL?e.toString():e;const s=(n.baseUrl!=null?await Ee.get(n.baseUrl):void 0)??(n.environment!=null?await Ee.get(n.environment):void 0);let l;a.startsWith("http://")||a.startsWith("https://")?l=a:s!=null?l=ut(s,a):l=a;const c={};if(n.headers!=null)for(const[S,E]of Object.entries(n.headers)){const A=await u8e.get(E,{endpointMetadata:{}});A!=null&&(c[S.toLowerCase()]=`${A}`)}if(n.getAuthHeaders!=null&&yln(l,s)){const S=await n.getAuthHeaders();for(const[E,A]of Object.entries(S))c[E.toLowerCase()]=A}if((i==null?void 0:i.headers)!=null){const S=i.headers instanceof Headers?Object.fromEntries(i.headers.entries()):Array.isArray(i.headers)?Object.fromEntries(i.headers):i.headers;for(const[E,A]of Object.entries(S))A!=null&&(c[E.toLowerCase()]=A)}if((r==null?void 0:r.headers)!=null)for(const[S,E]of Object.entries(r.headers))c[S.toLowerCase()]=E;const u=(i==null?void 0:i.method)??"GET",d=i==null?void 0:i.body,f=(r==null?void 0:r.timeoutInSeconds)??n.timeoutInSeconds,g=f!=null?f*1e3:void 0,b=(r==null?void 0:r.maxRetries)??n.maxRetries,v=(r==null?void 0:r.abortSignal)??(i==null?void 0:i.signal)??void 0,y=n.fetch??await g8e();o.isDebug()&&o.debug("Making passthrough HTTP request",{method:u,url:kd(l),hasBody:d!=null});let w;try{w=await y8e(async()=>b8e(y,l,u,c,d??void 0,g,v,(i==null?void 0:i.credentials)==="include",void 0,!1),b,v)}catch(S){throw S===P3?vln():S}return o.isDebug()&&o.debug("Passthrough HTTP request completed",{method:u,url:kd(l),statusCode:w.status}),w}function vln(){const e=new Error("The request timed out.");return e.name="TimeoutError",e}function yln(e,t){if(t==null)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}}class Ud{constructor({response:t,rawResponse:n,hasNextPage:r,getItems:o,loadPage:a}){this.response=t,this.rawResponse=n,this.data=o(t),this._hasNextPage=r,this.getItems=o,this.loadNextPage=a}async getNextPage(){const{data:t,rawResponse:n}=await this.loadNextPage(this.response).withRawResponse();return this.response=t,this.rawResponse=n,this.data=this.getItems(this.response),this}hasNextPage(){return this._hasNextPage(this.response)}async*iterMessages(){for(const t of this.data)yield t;for(;this.hasNextPage();){await this.getNextPage();for(const t of this.data)yield t}}async*[Symbol.asyncIterator](){for await(const t of this.iterMessages())yield t}}const xB=xln();function xln(){var c,u,d,f,g,b,v;if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&((c=globalThis==null?void 0:globalThis.navigator)==null?void 0:c.userAgent)==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof(self==null?void 0:self.importScripts)=="function"&&(((u=self.constructor)==null?void 0:u.name)==="DedicatedWorkerGlobalScope"||((d=self.constructor)==null?void 0:d.name)==="ServiceWorkerGlobalScope"||((f=self.constructor)==null?void 0:f.name)==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno,os:(g=Deno.build)==null?void 0:g.os,arch:(b=Deno.build)==null?void 0:b.arch};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version,os:typeof process<"u"?process.platform:void 0,arch:typeof process<"u"?process.arch:void 0};if(typeof navigator<"u"&&(navigator==null?void 0:navigator.product)==="ReactNative")return{type:"react-native"};const s=typeof process<"u"?process:void 0;return typeof s<"u"&&typeof((v=s.versions)==null?void 0:v.node)=="string"?{type:"node",version:s.versions.node,parsedVersion:Number(s.versions.node.split(".")[0]),os:s.platform,arch:s.arch}:{type:"unknown"}}const Ro={DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function Di(e,t){return`Expected ${t}. Received ${wln(e)}.`}function wln(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function yx(e){return{...e,json:Rwe(e.json),parse:Rwe(e.parse)}}function Rwe(e){return(t,n)=>{const r=e(t,n),{skipValidation:o=!1}=n??{};return!r.ok&&o?(console.warn(["Failed to validate.",...r.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1104
- `)),{ok:!0,value:t}):r}}function _8e(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}class cee extends Error{constructor(t){super(t.map(_8e).join("; ")),this.errors=t,Object.setPrototypeOf(this,cee.prototype),this.name="JsonError"}}class uee extends Error{constructor(t){super(t.map(_8e).join("; ")),this.errors=t,Object.setPrototypeOf(this,uee.prototype),this.name="ParseError"}}function Zs(e){return{nullable:()=>_ln(e),optional:()=>Sln(e),optionalNullable:()=>kln(e),transform:t=>Eln(e,t),parseOrThrow:(t,n)=>{const r=e.parse(t,n);if(r.ok)return r.value;throw new uee(r.errors)},jsonOrThrow:(t,n)=>{const r=e.json(t,n);if(r.ok)return r.value;throw new cee(r.errors)}}}function _ln(e){const t={parse:(n,r)=>n==null?{ok:!0,value:null}:e.parse(n,r),json:(n,r)=>n==null?{ok:!0,value:null}:e.json(n,r),getType:()=>Ro.NULLABLE};return{...t,...Zs(t)}}function Sln(e){const t={parse:(n,r)=>n==null?{ok:!0,value:void 0}:e.parse(n,r),json:(n,r)=>r!=null&&r.omitUndefined&&n===void 0?{ok:!0,value:void 0}:n==null?{ok:!0,value:null}:e.json(n,r),getType:()=>Ro.OPTIONAL};return{...t,...Zs(t)}}function kln(e){const t={parse:(n,r)=>n===void 0?{ok:!0,value:void 0}:n===null?{ok:!0,value:null}:e.parse(n,r),json:(n,r)=>n===void 0?{ok:!0,value:void 0}:n===null?{ok:!0,value:null}:e.json(n,r),getType:()=>Ro.OPTIONAL_NULLABLE};return{...t,...Zs(t)}}function Eln(e,t){const n={parse:(r,o)=>{const a=e.parse(r,o);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(r,o)=>{const a=t.untransform(r);return e.json(a,o)},getType:()=>e.getType()};return{...n,...Zs(n)}}const Tln=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Fd(){const e={parse:(t,{breadcrumbsPrefix:n=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:n,message:Di(t,"string")}]}:Tln.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:n,message:Di(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:n=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:n,message:Di(t,"Date object")}]},getType:()=>Ro.DATE};return{...yx(e),...Zs(e)}}function Xm(e,t){return()=>{const n={parse:t,json:t,getType:()=>e};return{...yx(n),...Zs(n)}}}function Uo(e){const t=new Set(e);return Xm(Ro.ENUM,(r,{allowUnrecognizedEnumValues:o,breadcrumbsPrefix:a=[]}={})=>typeof r!="string"?{ok:!1,errors:[{path:a,message:Di(r,"string")}]}:!t.has(r)&&!o?{ok:!1,errors:[{path:a,message:Di(r,"enum")}]}:{ok:!0,value:r})()}function Iwe(e){return Object.entries(e)}function wB(e,t){const n=new Set(t);return Object.entries(e).reduce((r,[o,a])=>(n.has(o)&&(r[o]=a),r),{})}function j3(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function S8e(e){return Object.keys(e)}function Aln(e,t){const n=[],r=[];for(const o of e)t(o)?n.push(o):r.push(o);return[n,r]}const Cln=Object.prototype.hasOwnProperty;function pN(e){return{withParsedProperties:t=>Rln(e,t)}}function Rln(e,t){const n={parse:(r,o)=>{const a=e.parse(r,o);if(!a.ok)return a;const i={};for(const s in t)if(Cln.call(t,s)){const l=t[s];i[s]=typeof l=="function"?l(a.value):l}return{ok:!0,value:{...a.value,...i}}},json:(r,o)=>{if(!j3(r))return{ok:!1,errors:[{path:(o==null?void 0:o.breadcrumbsPrefix)??[],message:Di(r,"object")}]};const a=new Set(Object.keys(t)),i=wB(r,Object.keys(r).filter(s=>!a.has(s)));return e.json(i,o)},getType:()=>e.getType()};return{...n,...Zs(n),...pN(n)}}function de(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function cv(e){return e.isProperty}const Iln=Object.prototype.hasOwnProperty;function ae(e){let t;function n(){if(t==null){t={};for(const[f,g]of Iwe(e)){const b=cv(g)?g.rawKey:f,v=cv(g)?g.valueSchema:g;t[b]={rawKey:b,parsedKey:f,valueSchema:v}}}return t}let r,o,a,i;function s(){if(r==null){r=[],o=[];for(const[f,g]of Iwe(e)){const b=cv(g)?g.rawKey:f,v=cv(g)?g.valueSchema:g;Nln(v)&&(r.push(b),o.push(f))}a=new Set(r),i=new Set(o)}return r}function l(){return o==null&&s(),o}function c(){return a==null&&s(),a}function u(){return i==null&&s(),i}const d={_getRawProperties:()=>Object.entries(e).map(([f,g])=>cv(g)?g.rawKey:f),_getParsedProperties:()=>S8e(e),parse:(f,g)=>{const b=(g==null?void 0:g.breadcrumbsPrefix)??[];return Nwe({value:f,requiredKeys:s(),requiredKeysSet:c(),getProperty:v=>{const y=n()[v];if(y!=null)return{transformedKey:y.parsedKey,transform:w=>{const S=[...b,v];return y.valueSchema.parse(w,{...g,breadcrumbsPrefix:S})}}},unrecognizedObjectKeys:g==null?void 0:g.unrecognizedObjectKeys,skipValidation:g==null?void 0:g.skipValidation,breadcrumbsPrefix:b,omitUndefined:g==null?void 0:g.omitUndefined})},json:(f,g)=>{const b=(g==null?void 0:g.breadcrumbsPrefix)??[];return Nwe({value:f,requiredKeys:l(),requiredKeysSet:u(),getProperty:v=>{const y=e[v];if(y!=null)return cv(y)?{transformedKey:y.rawKey,transform:w=>{const S=[...b,v];return y.valueSchema.json(w,{...g,breadcrumbsPrefix:S})}}:{transformedKey:v,transform:w=>{const S=[...b,v];return y.json(w,{...g,breadcrumbsPrefix:S})}}},unrecognizedObjectKeys:g==null?void 0:g.unrecognizedObjectKeys,skipValidation:g==null?void 0:g.skipValidation,breadcrumbsPrefix:b,omitUndefined:g==null?void 0:g.omitUndefined})},getType:()=>Ro.OBJECT};return{...yx(d),...Zs(d),...pN(d),..._B(d)}}function Nwe({value:e,requiredKeys:t,requiredKeysSet:n,getProperty:r,unrecognizedObjectKeys:o="fail",skipValidation:a=!1,breadcrumbsPrefix:i=[]}){if(!j3(e))return{ok:!1,errors:[{path:i,message:Di(e,"object")}]};let s=t.length;const l=[],c={};for(const u in e){if(!Iln.call(e,u))continue;const d=e[u],f=r(u);if(f!=null){s>0&&n.has(u)&&s--;const g=f.transform(d);g.ok?c[f.transformedKey]=g.value:(c[u]=d,l.push(...g.errors))}else switch(o){case"fail":l.push({path:[...i,u],message:`Unexpected key "${u}"`});break;case"strip":break;case"passthrough":c[u]=d;break}}if(s>0)for(const u of t)u in e||l.push({path:i,message:`Missing required key "${u}"`});return l.length===0||a?{ok:!0,value:c}:{ok:!1,errors:l}}function _B(e){return{extend:t=>{const n={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(r,o)=>Mwe({extensionKeys:t._getRawProperties(),value:r,transformBase:a=>e.parse(a,o),transformExtension:a=>t.parse(a,o),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),json:(r,o)=>Mwe({extensionKeys:t._getParsedProperties(),value:r,transformBase:a=>e.json(a,o),transformExtension:a=>t.json(a,o),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),getType:()=>Ro.OBJECT};return{...n,...Zs(n),...pN(n),..._B(n)}},passthrough:()=>{const t=new Set(e._getRawProperties()),n=new Set(e._getParsedProperties()),r={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(o,a)=>{const i=e.parse(o,{...a,unrecognizedObjectKeys:"passthrough"});if(!i.ok)return i;const s={};if(typeof o=="object"&&o!=null)for(const[l,c]of Object.entries(o))t.has(l)||(s[l]=c);return{ok:!0,value:{...s,...i.value}}},json:(o,a)=>{const i=e.json(o,{...a,unrecognizedObjectKeys:"passthrough"});if(!i.ok)return i;const s={};if(typeof o=="object"&&o!=null)for(const[l,c]of Object.entries(o))n.has(l)||(s[l]=c);return{ok:!0,value:{...s,...i.value}}},getType:()=>Ro.OBJECT};return{...r,...Zs(r),...pN(r),..._B(r)}}}}function Mwe({extensionKeys:e,value:t,transformBase:n,transformExtension:r,breadcrumbsPrefix:o=[]}){if(!j3(t))return{ok:!1,errors:[{path:o,message:Di(t,"object")}]};const a=new Set(e),[i,s]=Aln(S8e(t),u=>a.has(u)),l=n(wB(t,s)),c=r(wB(t,i));return l.ok&&c.ok?{ok:!0,value:{...l.value,...c.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...c.ok?[]:c.errors]}}function Nln(e){return!Mln(e)}function Mln(e){switch(e.getType()){case Ro.ANY:case Ro.UNKNOWN:case Ro.OPTIONAL:case Ro.OPTIONAL_NULLABLE:return!0;default:return!1}}function wt(e){const t={parse:(n,r)=>Owe(n,(o,a)=>e.parse(o,{...r,breadcrumbsPrefix:[...(r==null?void 0:r.breadcrumbsPrefix)??[],`[${a}]`]})),json:(n,r)=>Owe(n,(o,a)=>e.json(o,{...r,breadcrumbsPrefix:[...(r==null?void 0:r.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>Ro.LIST};return{...yx(t),...Zs(t)}}function Owe(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:Di(e,"list"),path:[]}]};const n=[],r=[];for(let o=0;o<e.length;o++){const a=t(e[o],o);a.ok?n.push(a.value):r.push(...a.errors)}return r.length===0?{ok:!0,value:n}:{ok:!1,errors:r}}function Oln(e){return Xm(Ro.BOOLEAN_LITERAL,(n,{breadcrumbsPrefix:r=[]}={})=>n===e?{ok:!0,value:e}:{ok:!1,errors:[{path:r,message:Di(n,`${e.toString()}`)}]})()}function st(e){return Xm(Ro.STRING_LITERAL,(n,{breadcrumbsPrefix:r=[]}={})=>n===e?{ok:!0,value:e}:{ok:!1,errors:[{path:r,message:Di(n,`"${e}"`)}]})()}const Jr=Xm(Ro.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Di(e,"boolean")}]}),nn=Xm(Ro.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Di(e,"number")}]}),oe=Xm(Ro.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Di(e,"string")}]}),D3=Xm(Ro.UNKNOWN,e=>({ok:!0,value:e})),Pln=Object.prototype.hasOwnProperty;function Ac(e,t){const n={parse:(r,o)=>Pwe({value:r,isKeyNumeric:e.getType()===Ro.NUMBER,transformKey:a=>e.parse(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,i)=>t.parse(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${i}`]}),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),json:(r,o)=>Pwe({value:r,isKeyNumeric:e.getType()===Ro.NUMBER,transformKey:a=>e.json(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,i)=>t.json(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${i}`]}),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),getType:()=>Ro.RECORD};return{...yx(n),...Zs(n)}}function Pwe({value:e,isKeyNumeric:t,transformKey:n,transformValue:r,breadcrumbsPrefix:o=[]}){if(!j3(e))return{ok:!1,errors:[{path:o,message:Di(e,"object")}]};const a={},i=[];for(const s in e){if(!Pln.call(e,s))continue;const l=e[s];if(l===void 0)continue;let c=s;if(t){const f=s.length>0?Number(s):NaN;Number.isNaN(f)||(c=f)}const u=n(c),d=r(l,c);u.ok&&d.ok?a[u.value]=d.value:(u.ok||i.push(...u.errors),d.ok||i.push(...d.errors))}return i.length===0?{ok:!0,value:a}:{ok:!1,errors:i}}function $r(e){const t={parse:(n,r)=>jwe((o,a)=>o.parse(n,a),e,r),json:(n,r)=>jwe((o,a)=>o.json(n,a),e,r),getType:()=>Ro.UNDISCRIMINATED_UNION};return{...yx(t),...Zs(t)}}function jwe(e,t,n){const r=[];for(const[o,a]of t.entries()){const i=e(a,{...n,skipValidation:!1});if(i.ok)return i;for(const s of i.errors)r.push({path:s.path,message:`[Variant ${o}] ${s.message}`})}return{ok:!1,errors:r}}const E$="data:",Dwe="event:",dC="id:",pC="retry:",jln=5,Dln=1e3,Lln=3e4;class Lwe{constructor({stream:t,parse:n,eventShape:r,signal:o,reconnectionEnabled:a,maxReconnectionAttempts:i,reconnect:s}){this.controller=new AbortController,this.stream=t,this.parse=n,r.type==="sse"?(this.prefix=E$,this.messageTerminator=`
1104
+ `)),{ok:!0,value:t}):r}}function _8e(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}class cee extends Error{constructor(t){super(t.map(_8e).join("; ")),this.errors=t,Object.setPrototypeOf(this,cee.prototype),this.name="JsonError"}}class uee extends Error{constructor(t){super(t.map(_8e).join("; ")),this.errors=t,Object.setPrototypeOf(this,uee.prototype),this.name="ParseError"}}function Zs(e){return{nullable:()=>_ln(e),optional:()=>Sln(e),optionalNullable:()=>kln(e),transform:t=>Eln(e,t),parseOrThrow:(t,n)=>{const r=e.parse(t,n);if(r.ok)return r.value;throw new uee(r.errors)},jsonOrThrow:(t,n)=>{const r=e.json(t,n);if(r.ok)return r.value;throw new cee(r.errors)}}}function _ln(e){const t={parse:(n,r)=>n==null?{ok:!0,value:null}:e.parse(n,r),json:(n,r)=>n==null?{ok:!0,value:null}:e.json(n,r),getType:()=>Ro.NULLABLE};return{...t,...Zs(t)}}function Sln(e){const t={parse:(n,r)=>n==null?{ok:!0,value:void 0}:e.parse(n,r),json:(n,r)=>r!=null&&r.omitUndefined&&n===void 0?{ok:!0,value:void 0}:n==null?{ok:!0,value:null}:e.json(n,r),getType:()=>Ro.OPTIONAL};return{...t,...Zs(t)}}function kln(e){const t={parse:(n,r)=>n===void 0?{ok:!0,value:void 0}:n===null?{ok:!0,value:null}:e.parse(n,r),json:(n,r)=>n===void 0?{ok:!0,value:void 0}:n===null?{ok:!0,value:null}:e.json(n,r),getType:()=>Ro.OPTIONAL_NULLABLE};return{...t,...Zs(t)}}function Eln(e,t){const n={parse:(r,o)=>{const a=e.parse(r,o);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(r,o)=>{const a=t.untransform(r);return e.json(a,o)},getType:()=>e.getType()};return{...n,...Zs(n)}}const Tln=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Fd(){const e={parse:(t,{breadcrumbsPrefix:n=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:n,message:Di(t,"string")}]}:Tln.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:n,message:Di(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:n=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:n,message:Di(t,"Date object")}]},getType:()=>Ro.DATE};return{...yx(e),...Zs(e)}}function Xm(e,t){return()=>{const n={parse:t,json:t,getType:()=>e};return{...yx(n),...Zs(n)}}}function Uo(e){const t=new Set(e);return Xm(Ro.ENUM,(r,{allowUnrecognizedEnumValues:o,breadcrumbsPrefix:a=[]}={})=>typeof r!="string"?{ok:!1,errors:[{path:a,message:Di(r,"string")}]}:!t.has(r)&&!o?{ok:!1,errors:[{path:a,message:Di(r,"enum")}]}:{ok:!0,value:r})()}function Iwe(e){return Object.entries(e)}function wB(e,t){const n=new Set(t);return Object.entries(e).reduce((r,[o,a])=>(n.has(o)&&(r[o]=a),r),{})}function j3(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function S8e(e){return Object.keys(e)}function Aln(e,t){const n=[],r=[];for(const o of e)t(o)?n.push(o):r.push(o);return[n,r]}const Cln=Object.prototype.hasOwnProperty;function pN(e){return{withParsedProperties:t=>Rln(e,t)}}function Rln(e,t){const n={parse:(r,o)=>{const a=e.parse(r,o);if(!a.ok)return a;const i={};for(const s in t)if(Cln.call(t,s)){const l=t[s];i[s]=typeof l=="function"?l(a.value):l}return{ok:!0,value:{...a.value,...i}}},json:(r,o)=>{if(!j3(r))return{ok:!1,errors:[{path:(o==null?void 0:o.breadcrumbsPrefix)??[],message:Di(r,"object")}]};const a=new Set(Object.keys(t)),i=wB(r,Object.keys(r).filter(s=>!a.has(s)));return e.json(i,o)},getType:()=>e.getType()};return{...n,...Zs(n),...pN(n)}}function de(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function cv(e){return e.isProperty}const Iln=Object.prototype.hasOwnProperty;function ae(e){let t;function n(){if(t==null){t={};for(const[f,g]of Iwe(e)){const b=cv(g)?g.rawKey:f,v=cv(g)?g.valueSchema:g;t[b]={rawKey:b,parsedKey:f,valueSchema:v}}}return t}let r,o,a,i;function s(){if(r==null){r=[],o=[];for(const[f,g]of Iwe(e)){const b=cv(g)?g.rawKey:f,v=cv(g)?g.valueSchema:g;Nln(v)&&(r.push(b),o.push(f))}a=new Set(r),i=new Set(o)}return r}function l(){return o==null&&s(),o}function c(){return a==null&&s(),a}function u(){return i==null&&s(),i}const d={_getRawProperties:()=>Object.entries(e).map(([f,g])=>cv(g)?g.rawKey:f),_getParsedProperties:()=>S8e(e),parse:(f,g)=>{const b=(g==null?void 0:g.breadcrumbsPrefix)??[];return Nwe({value:f,requiredKeys:s(),requiredKeysSet:c(),getProperty:v=>{const y=n()[v];if(y!=null)return{transformedKey:y.parsedKey,transform:w=>{const S=[...b,v];return y.valueSchema.parse(w,{...g,breadcrumbsPrefix:S})}}},unrecognizedObjectKeys:g==null?void 0:g.unrecognizedObjectKeys,skipValidation:g==null?void 0:g.skipValidation,breadcrumbsPrefix:b,omitUndefined:g==null?void 0:g.omitUndefined})},json:(f,g)=>{const b=(g==null?void 0:g.breadcrumbsPrefix)??[];return Nwe({value:f,requiredKeys:l(),requiredKeysSet:u(),getProperty:v=>{const y=e[v];if(y!=null)return cv(y)?{transformedKey:y.rawKey,transform:w=>{const S=[...b,v];return y.valueSchema.json(w,{...g,breadcrumbsPrefix:S})}}:{transformedKey:v,transform:w=>{const S=[...b,v];return y.json(w,{...g,breadcrumbsPrefix:S})}}},unrecognizedObjectKeys:g==null?void 0:g.unrecognizedObjectKeys,skipValidation:g==null?void 0:g.skipValidation,breadcrumbsPrefix:b,omitUndefined:g==null?void 0:g.omitUndefined})},getType:()=>Ro.OBJECT};return{...yx(d),...Zs(d),...pN(d),..._B(d)}}function Nwe({value:e,requiredKeys:t,requiredKeysSet:n,getProperty:r,unrecognizedObjectKeys:o="fail",skipValidation:a=!1,breadcrumbsPrefix:i=[]}){if(!j3(e))return{ok:!1,errors:[{path:i,message:Di(e,"object")}]};let s=t.length;const l=[],c={};for(const u in e){if(!Iln.call(e,u))continue;const d=e[u],f=r(u);if(f!=null){s>0&&n.has(u)&&s--;const g=f.transform(d);if(g.ok)c[f.transformedKey]=g.value;else{c[u]=d;for(const b of g.errors)l.push(b)}}else switch(o){case"fail":l.push({path:[...i,u],message:`Unexpected key "${u}"`});break;case"strip":break;case"passthrough":c[u]=d;break}}if(s>0)for(const u of t)u in e||l.push({path:i,message:`Missing required key "${u}"`});return l.length===0||a?{ok:!0,value:c}:{ok:!1,errors:l}}function _B(e){return{extend:t=>{const n={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(r,o)=>Mwe({extensionKeys:t._getRawProperties(),value:r,transformBase:a=>e.parse(a,o),transformExtension:a=>t.parse(a,o),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),json:(r,o)=>Mwe({extensionKeys:t._getParsedProperties(),value:r,transformBase:a=>e.json(a,o),transformExtension:a=>t.json(a,o),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),getType:()=>Ro.OBJECT};return{...n,...Zs(n),...pN(n),..._B(n)}},passthrough:()=>{const t=new Set(e._getRawProperties()),n=new Set(e._getParsedProperties()),r={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(o,a)=>{const i=e.parse(o,{...a,unrecognizedObjectKeys:"passthrough"});if(!i.ok)return i;const s={};if(typeof o=="object"&&o!=null)for(const[l,c]of Object.entries(o))t.has(l)||(s[l]=c);return{ok:!0,value:{...s,...i.value}}},json:(o,a)=>{const i=e.json(o,{...a,unrecognizedObjectKeys:"passthrough"});if(!i.ok)return i;const s={};if(typeof o=="object"&&o!=null)for(const[l,c]of Object.entries(o))n.has(l)||(s[l]=c);return{ok:!0,value:{...s,...i.value}}},getType:()=>Ro.OBJECT};return{...r,...Zs(r),...pN(r),..._B(r)}}}}function Mwe({extensionKeys:e,value:t,transformBase:n,transformExtension:r,breadcrumbsPrefix:o=[]}){if(!j3(t))return{ok:!1,errors:[{path:o,message:Di(t,"object")}]};const a=new Set(e),[i,s]=Aln(S8e(t),u=>a.has(u)),l=n(wB(t,s)),c=r(wB(t,i));return l.ok&&c.ok?{ok:!0,value:{...l.value,...c.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...c.ok?[]:c.errors]}}function Nln(e){return!Mln(e)}function Mln(e){switch(e.getType()){case Ro.ANY:case Ro.UNKNOWN:case Ro.OPTIONAL:case Ro.OPTIONAL_NULLABLE:return!0;default:return!1}}function wt(e){const t={parse:(n,r)=>Owe(n,(o,a)=>e.parse(o,{...r,breadcrumbsPrefix:[...(r==null?void 0:r.breadcrumbsPrefix)??[],`[${a}]`]})),json:(n,r)=>Owe(n,(o,a)=>e.json(o,{...r,breadcrumbsPrefix:[...(r==null?void 0:r.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>Ro.LIST};return{...yx(t),...Zs(t)}}function Owe(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:Di(e,"list"),path:[]}]};const n=[],r=[];for(let o=0;o<e.length;o++){const a=t(e[o],o);if(a.ok)n.push(a.value);else for(const i of a.errors)r.push(i)}return r.length===0?{ok:!0,value:n}:{ok:!1,errors:r}}function Oln(e){return Xm(Ro.BOOLEAN_LITERAL,(n,{breadcrumbsPrefix:r=[]}={})=>n===e?{ok:!0,value:e}:{ok:!1,errors:[{path:r,message:Di(n,`${e.toString()}`)}]})()}function st(e){return Xm(Ro.STRING_LITERAL,(n,{breadcrumbsPrefix:r=[]}={})=>n===e?{ok:!0,value:e}:{ok:!1,errors:[{path:r,message:Di(n,`"${e}"`)}]})()}const Jr=Xm(Ro.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Di(e,"boolean")}]}),nn=Xm(Ro.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Di(e,"number")}]}),oe=Xm(Ro.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Di(e,"string")}]}),D3=Xm(Ro.UNKNOWN,e=>({ok:!0,value:e})),Pln=Object.prototype.hasOwnProperty;function Ac(e,t){const n={parse:(r,o)=>Pwe({value:r,isKeyNumeric:e.getType()===Ro.NUMBER,transformKey:a=>e.parse(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,i)=>t.parse(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${i}`]}),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),json:(r,o)=>Pwe({value:r,isKeyNumeric:e.getType()===Ro.NUMBER,transformKey:a=>e.json(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,i)=>t.json(a,{...o,breadcrumbsPrefix:[...(o==null?void 0:o.breadcrumbsPrefix)??[],`${i}`]}),breadcrumbsPrefix:o==null?void 0:o.breadcrumbsPrefix}),getType:()=>Ro.RECORD};return{...yx(n),...Zs(n)}}function Pwe({value:e,isKeyNumeric:t,transformKey:n,transformValue:r,breadcrumbsPrefix:o=[]}){if(!j3(e))return{ok:!1,errors:[{path:o,message:Di(e,"object")}]};const a={},i=[];for(const s in e){if(!Pln.call(e,s))continue;const l=e[s];if(l===void 0)continue;let c=s;if(t){const f=s.length>0?Number(s):NaN;Number.isNaN(f)||(c=f)}const u=n(c),d=r(l,c);if(u.ok&&d.ok)a[u.value]=d.value;else{if(!u.ok)for(const f of u.errors)i.push(f);if(!d.ok)for(const f of d.errors)i.push(f)}}return i.length===0?{ok:!0,value:a}:{ok:!1,errors:i}}function $r(e){const t={parse:(n,r)=>jwe((o,a)=>o.parse(n,a),e,r),json:(n,r)=>jwe((o,a)=>o.json(n,a),e,r),getType:()=>Ro.UNDISCRIMINATED_UNION};return{...yx(t),...Zs(t)}}function jwe(e,t,n){const r=[];for(const[o,a]of t.entries()){const i=e(a,{...n,skipValidation:!1});if(i.ok)return i;for(const s of i.errors)r.push({path:s.path,message:`[Variant ${o}] ${s.message}`})}return{ok:!1,errors:r}}const E$="data:",Dwe="event:",dC="id:",pC="retry:",jln=5,Dln=1e3,Lln=3e4;class Lwe{constructor({stream:t,parse:n,eventShape:r,signal:o,reconnectionEnabled:a,maxReconnectionAttempts:i,reconnect:s}){this.controller=new AbortController,this.stream=t,this.parse=n,r.type==="sse"?(this.prefix=E$,this.messageTerminator=`
1105
1105
  `,this.streamTerminator=r.streamTerminator,this.eventDiscriminator=r.eventDiscriminator,this.envelopeEvents=r.envelopeEvents!=null?new Set(r.envelopeEvents):void 0,this.resumable=r.resumable??!1):(this.messageTerminator=r.messageTerminator,this.resumable=!1),this.reconnectionEnabled=a??!0,this.maxReconnectionAttempts=i??jln,this.reconnect=s,o!=null&&(this.externalSignal=o,this.onExternalAbort=()=>this.controller.abort(),o.addEventListener("abort",this.onExternalAbort,{once:!0})),typeof TextDecoder<"u"&&(this.decoder=new TextDecoder("utf-8"))}async*iterMessages(){this.eventDiscriminator!=null?yield*this.iterSseEvents():yield*this.iterDataMessages()}async*iterDataMessages(){let t=0,n=this.stream,r,o,a;for(;;){const i=zwe(n);let s="",l;for await(const u of i){s+=this.decodeChunk(u);let d;for(;(d=s.indexOf(this.messageTerminator))>=0;){const f=s.slice(0,d);if(s=s.slice(d+this.messageTerminator.length),!f.trim()){if(this.prefix!=null&&l!=null){if(this.streamTerminator!=null&&l.includes(this.streamTerminator))return;yield{data:await this.parse(Fv(l)),id:r,retry:a,event:void 0},o=r,t=0,l=void 0}continue}if(f.startsWith(dC)){const g=f.slice(dC.length).trim();g.includes("\0")||(r=g);continue}if(f.startsWith(pC)){const g=f.slice(pC.length).trim(),b=parseInt(g,10);!Number.isNaN(b)&&String(b)===g&&(a=b);continue}if(this.prefix!=null){const g=f.indexOf(this.prefix);if(g===-1)continue;const b=f.slice(g+this.prefix.length).trim();l=l!=null?`${l}
1106
1106
  ${b}`:b}else{if(this.streamTerminator!=null&&f.includes(this.streamTerminator))return;yield{data:await this.parse(Fv(f)),id:r,retry:a,event:void 0},o=r,t=0}}}if(this.prefix!=null&&l!=null){if(this.streamTerminator!=null&&l.includes(this.streamTerminator))return;yield{data:await this.parse(Fv(l)),id:r,retry:a,event:void 0},o=r,t=0}if(!this.shouldReconnect(o,t)||(t++,await this.delayReconnect(a),this.controller.signal.aborted))return;const c=this.reconnect;if(c==null||o==null)return;try{const u=await c(o);if(u==null){n=this.createEmptyStream();continue}n=u}catch{n=this.createEmptyStream()}}}async*iterSseEvents(){let t=0,n=this.stream,r,o,a;for(;;){const i=zwe(n);let s="",l,c;for await(const d of i){s+=this.decodeChunk(d);let f;for(;(f=s.indexOf(`
1107
1107
  `))>=0;){const g=s.slice(0,f).replace(/\r$/,"");if(s=s.slice(f+1),!g.trim()){if(c!=null){const b=await this.dispatchSseEvent(c,l);if(b==null)return;yield{data:b,id:r,retry:a,event:l},o=r,t=0}l=void 0,c=void 0;continue}if(g.startsWith(Dwe))l=g.slice(Dwe.length).trim();else if(g.startsWith(E$)){const b=g.slice(E$.length).trim();c=c!=null?`${c}
1108
- ${b}`:b}else if(g.startsWith(dC)){const b=g.slice(dC.length).trim();b.includes("\0")||(r=b)}else if(g.startsWith(pC)){const b=g.slice(pC.length).trim(),v=parseInt(b,10);!Number.isNaN(v)&&String(v)===b&&(a=v)}}}if(c!=null){const d=await this.dispatchSseEvent(c,l);d!=null&&(yield{data:d,id:r,retry:a,event:l},o=r,t=0)}if(!this.shouldReconnect(o,t)||(t++,await this.delayReconnect(a),this.controller.signal.aborted))return;const u=this.reconnect;if(u==null||o==null)return;try{const d=await u(o);if(d==null){n=this.createEmptyStream();continue}n=d}catch{n=this.createEmptyStream()}}}async dispatchSseEvent(t,n){return this.streamTerminator!=null&&t.includes(this.streamTerminator)?null:this.parse(this.injectDiscriminator(Fv(t),n))}shouldReconnect(t,n){return!(!this.resumable||this.streamTerminator==null||!this.reconnectionEnabled||this.reconnect==null||t==null||t===""||n>=this.maxReconnectionAttempts||this.controller.signal.aborted)}async delayReconnect(t){const n=t!=null&&t>0?t:Dln,r=Math.min(n,Lln),o=this.controller.signal;o.aborted||await new Promise(a=>{const i=setTimeout(()=>{o.removeEventListener("abort",s),a()},r),s=()=>{clearTimeout(i),a()};o.addEventListener("abort",s,{once:!0})})}createEmptyStream(){return new ReadableStream({start(t){t.close()}})}removeAbortListener(){this.externalSignal!=null&&this.onExternalAbort!=null&&(this.externalSignal.removeEventListener("abort",this.onExternalAbort),this.onExternalAbort=void 0)}withMetadata(){const t=this;return{async*[Symbol.asyncIterator](){try{yield*t.iterMessages()}finally{t.removeAbortListener()}}}}injectDiscriminator(t,n){var o;if(this.eventDiscriminator==null||n==null)return t;if((o=this.envelopeEvents)!=null&&o.has(n))return{[this.eventDiscriminator]:n,data:t};if(t==null||typeof t!="object"||Array.isArray(t))return t;const r=t;return this.eventDiscriminator in r?t:{[this.eventDiscriminator]:n,...r}}async*[Symbol.asyncIterator](){try{for await(const t of this.iterMessages())yield t.data}finally{this.removeAbortListener()}}decodeChunk(t){let n="";return this.decoder!=null?n+=this.decoder.decode(t,{stream:!0}):xB.type==="node"&&typeof t<"u"&&(n+=Buffer.isBuffer(t)?t:Buffer.from(t)),n}}function zwe(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n!=null&&n.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}function Pn(e,t){if(e===null)return"null";switch(typeof e){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:e=String(e);break}const r=encodeURIComponent(e);if(r==="."||r===".."){const o=`Invalid path parameter "${r}": "." and ".." are not allowed because they change the request path.`;throw t!=null?new t({message:o}):new Error(o)}return r}function ft(){return new zln}class zln{constructor(){this.parts=new Map}add(t,n,r){if(n==null)return this;const o=dN({[t]:n},{arrayFormat:(r==null?void 0:r.style)==="comma"?"comma":"repeat"});return o.length>0&&this.parts.set(t,o),this}addMany(t){if(t!=null)for(const[n,r]of Object.entries(t))this.add(n,r);return this}mergeAdditional(t){if(t!=null)for(const[n,r]of Object.entries(t)){if(r==null)continue;const o=dN({[n]:r},{arrayFormat:"repeat"});o.length>0&&this.parts.set(n,o)}return this}build(){return[...this.parts.values()].join("&")}}function Bd(e,t,n){if(e==null)return e;const r=t.split(".");if(r.length===0)return e;const o={...e};let a=o;for(let s=0;s<r.length-1;s++){const l=r[s];if(l==null)continue;const c=a[l];Array.isArray(c)?a[l]=[...c]:a[l]=c!=null&&typeof c=="object"?{...c}:{},a=a[l]}const i=r[r.length-1];return i==null||(a[i]=n),o}const SB="token";class kB{constructor(t){this.options=t}static canCreate(t){return(t==null?void 0:t[SB])!=null}async getAuthRequest({endpointMetadata:t}={}){const n=await Ee.get(this.options[SB]);return n==null?{headers:{}}:{headers:{Authorization:`Bearer ${n}`}}}}(e=>{e.AUTH_SCHEME="BearerAuth",e.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${SB}' when initializing the client`;function t(n){return new e(n)}e.createInstance=t})(kB||(kB={}));function dt(...e){const t={};for(const[n,r]of e.filter(o=>o!=null).flatMap(o=>Object.entries(o))){const o=n.toLowerCase();r!=null?t[o]=r:o in t&&delete t[o]}return t}function T$(...e){const t={};for(const[n,r]of e.filter(o=>o!=null).flatMap(o=>Object.entries(o))){const o=n.toLowerCase();r!=null&&(t[o]=r)}return t}function $ln(e){const t=dt({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@truefoundry/trueforge-sdk","X-Fern-SDK-Version":"0.186.0-rc.0","User-Agent":"@truefoundry/trueforge-sdk/0.186.0-rc.0","X-Fern-Runtime":xB.type,"X-Fern-Runtime-Version":xB.version},e==null?void 0:e.headers);return{...e,logging:lee(e==null?void 0:e.logging),headers:t}}function vr(e){const t=$ln(e);if(e.auth===!1)return t.authProvider=new c8e,t;if(e.auth!=null){if(typeof e.auth=="function")return t.authProvider={getAuthRequest:e.auth},t;if(Zsn(e.auth))return t.authProvider=e.auth,t;Object.assign(t,e.auth)}const n=Uln(t);return t.authProvider??(t.authProvider=new kB(n)),t}function Uln(e){return{...e,authProvider:new c8e}}function Cr(e,t){return t==null?e:e==null?{...t}:typeof e=="object"&&!Array.isArray(e)?{...e,...t}:e}function ht(e,t,n,r){switch(e.reason){case"non-json":throw new Pe({statusCode:e.statusCode,body:e.rawBody,rawResponse:t});case"body-is-null":throw new Pe({statusCode:e.statusCode,rawResponse:t});case"timeout":throw new Wsn(`Timeout exceeded when calling ${n} ${r}.`,{cause:e.cause});case"unknown":throw new Pe({message:e.errorMessage,rawResponse:t,cause:e.cause});default:throw new Pe({message:"Unknown error",rawResponse:t})}}const Fln=ae({content:oe(),type:st("user.message")}),Bln=$r([st("@all"),st("@write"),st("@destructive"),oe()]),A$=$r([st("@all"),st("@read-only"),oe()]),Hln=ae({disableTools:de("disable_tools",wt(A$).optional()),enableTools:de("enable_tools",wt(A$).optional()),name:oe(),preload:Jr().optional(),preloadTools:de("preload_tools",wt(A$).optional()),requireApprovalForTools:de("require_approval_for_tools",wt(Bln).optional())}),Vln=ae({maxTokens:de("max_tokens",nn().optional()),parallelToolCalls:de("parallel_tool_calls",Jr().optional()),reasoningEffort:de("reasoning_effort",oe().optional()),temperature:nn().optional(),topK:de("top_k",nn().optional()),topP:de("top_p",nn().optional())}).passthrough(),k8e=ae({name:oe(),params:Vln.optional()}),Gln=ae({type:st("json_object")}).passthrough(),Wln=ae({description:oe().optional(),name:oe(),schema:Ac(oe(),D3()).optional(),strict:Jr().optionalNullable()}).passthrough(),Kln=ae({jsonSchema:de("json_schema",Wln),type:st("json_schema")}).passthrough(),Yln=ae({type:st("text")}).passthrough(),Zln=$r([Gln,Kln,Yln]),Xln=ae({enabled:Jr().optional()}),qln=ae({type:st("input_tokens"),value:nn()}),Qln=ae({enabled:Jr().optional(),trigger:qln.optional()}),Jln=ae({enabled:Jr().optional()}),ecn=ae({compaction:Qln.optional(),largeToolResponse:de("large_tool_response",Jln.optional())}),tcn=ae({enabled:Jr().optional()}),ncn=ae({enabled:Jr().optional()}),rcn=ae({enabled:Jr().optional()}),ocn=ae({enabled:Jr(),environmentName:de("environment_name",oe().optional()),fileDownloads:de("file_downloads",Jr().optional())}),acn=ae({enabled:Jr().optional()}),icn=ae({askUserQuestions:de("ask_user_questions",Xln.optional()),contextManagement:de("context_management",ecn.optional()),dynamicSubAgents:de("dynamic_sub_agents",tcn.optional()),generativeUi:de("generative_ui",ncn.optional()),iterationLimit:de("iteration_limit",nn().optional()),memory:rcn.optional(),sandbox:ocn.optional(),webSearch:de("web_search",acn.optional())}),scn=ae({name:oe(),preload:Jr().optional()}),lE=ae({config:icn.optional(),instructions:oe().optional(),mcpServers:de("mcp_servers",wt(Hln).optional()),messages:wt(Fln).optional(),model:k8e,responseFormat:de("response_format",Zln.optional()),skills:wt(scn).optional()}),wo=oe(),lcn=ae({description:oe(),manifest:lE,name:wo}),ccn=ae({description:oe().optional(),manifest:lE}),E8e=Uo(["agent","schedule","session","tenant","sandbox_environment"]),ucn=ae({resourceIds:de("resource_ids",wt(oe())),resourceType:de("resource_type",E8e)}),dcn=ae({environmentVersionId:de("environment_version_id",oe())}),pcn=ae({scheduleRunId:de("schedule_run_id",oe())}),fcn=ae({name:wo}),T8e=ae({spec:lE}),A8e=$r([fcn,T8e]),hcn=ae({id:oe(),runId:de("run_id",oe()),type:st("schedule")}),gcn=ae({type:st("service")}),C8e=$r([hcn,gcn]),mcn=ae({agent:A8e,externalId:de("external_id",oe()),source:C8e.optionalNullable()}),dee=$r([st("auto"),st("none"),oe()]),bcn=ae({data:oe(),name:oe(),type:st("file")}),vcn=ae({text:oe(),type:st("text")}),ycn=$r([bcn,vcn]),xcn=$r([oe(),wt(ycn)]),L3=ae({content:xcn,type:st("user.message")}),wcn=ae({}).extend(L3),_cn=ae({input:wt(wcn),previousTurnId:de("previous_turn_id",dee.optional()),stream:Oln(!1).optional()}),R8e=ae({buildScript:de("build_script",oe().optional()),type:st("build")}),Scn=ae({env:oe(),hosts:wt(oe()),value:oe()}),I8e=ae({domainAllowList:de("domain_allow_list",oe().optional()),networkBlockAll:de("network_block_all",Jr().optional()),secrets:wt(Scn).optional()}),N8e=ae({cpu:nn().optional(),disk:nn().optional(),memory:nn().optional()}),M8e=ae({description:oe().optional(),environmentVariables:de("environment_variables",Ac(oe(),oe()).optional()),image:R8e.optional(),name:wo,networking:I8e.optional(),resources:N8e.optional()}),kcn=ae({manifest:M8e}),Ecn=ae({enabled:Jr().optional(),isDefault:de("is_default",Jr().optional())}),Tcn=ae({manifest:M8e}),Acn=oe(),Ccn=Uo(["active","paused"]),Rcn=oe(),pee=ae({cron:Acn,status:Ccn.optional(),task:oe(),timezone:Rcn.optional()}),Icn=ae({agentName:de("agent_name",wo),manifest:pee,name:wo}),Ncn=ae({scheduleId:de("schedule_id",oe())}),Mcn=ae({manifest:pee,name:wo}),Ocn=ae({}),fee=Ac(oe(),oe()),Pcn=ae({agent:A8e,metadata:fee.optional()}),jcn=ae({type:st("user.mcp_auth_continue")}),Dcn=ae({status:st("allow")}),Lcn=ae({reason:oe().optional(),status:st("deny")}),O8e=$r([Dcn,Lcn]),P8e=ae({approval:O8e,threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_approval")}),zcn=ae({expireAt:de("expire_at",oe().optional()),type:st("allow_session")}),j8e=zcn,D8e=ae({name:oe(),policy:j8e,serverName:de("server_name",oe())}),$cn=ae({policies:wt(D8e),type:st("user.tool_approval_policy")}),L8e=ae({content:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_response")}),Ucn=$r([jcn,P8e,$cn,L8e]),Fcn=ae({events:wt(Ucn)}),Bcn=ae({}).extend(L3),Hcn=ae({input:wt(Bcn),previousTurnId:de("previous_turn_id",dee.optional())}),Vcn=ae({}).extend(L3),Gcn=ae({input:wt(Vcn),previousTurnId:de("previous_turn_id",dee.optional())}),Wcn=Uo(["user","tenant"]),EB=ae({subjectId:de("subject_id",oe()),subjectType:de("subject_type",Wcn)}),Kcn=ae({grant:wt(EB).optional(),revoke:wt(EB).optional()}),Ycn=ae({agent:T8e.optional(),metadata:fee.optional(),title:oe().optional()}),z8e=ae({enabled:Jr()}),$8e=ae({enabled:Jr()}),Zcn=ae({memory:z8e.optional(),webSearch:de("web_search",$8e.optional())}),Xcn=ae({manifest:Zcn}),qcn=ae({type:st("dcr")}),Qcn=ae({headers:Ac(oe(),oe()),type:st("header")}),hee=$r([qcn,Qcn]),Jcn=ae({auth:hee.optional(),description:oe(),name:wo,type:st("remote"),url:oe()}),eun=ae({auth:hee.optional(),description:oe(),name:wo,type:st("truefoundry"),url:oe()}),gee=$r([Jcn,eun]),tun=ae({manifest:gee}),nun=ae({manifest:gee}),run=ae({apiKey:de("api_key",oe())}),U8e=ae({auth:run,serverUrl:de("server_url",oe().optional()),type:st("zep")}),oun=ae({manifest:U8e}),F8e=Uo(["none","minimal","low","medium","high","xhigh","max"]),mee=ae({contextLength:de("context_length",nn().optional()),maxOutputTokens:de("max_output_tokens",nn().optional()),reasoningEfforts:de("reasoning_efforts",wt(F8e).optional())}),Vu=ae({modelId:de("model_id",oe()),name:wo,properties:mee}),Gu=ae({apiKey:de("api_key",oe())}),aun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("alibaba")}),iun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("anthropic")}),sun=ae({auth:Gu.optional(),baseUrl:de("base_url",oe()),models:wt(Vu),name:wo,type:st("custom")}),lun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("fireworks")}),cun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("google-gemini")}),uun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("moonshot")}),dun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("openai")}),pun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("together")}),fun=ae({auth:Gu.optional(),baseUrl:de("base_url",oe()),models:wt(Vu),type:st("truefoundry")}),hun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("zai")}),bee=$r([aun,iun,sun,lun,cun,uun,dun,pun,fun,hun]),gun=ae({manifest:bee}),mun=ae({manifest:bee}),bun=ae({apiKey:de("api_key",oe())}),B8e=ae({auth:bun,autoArchiveIntervalInMinutes:de("auto_archive_interval_in_minutes",nn()),autoDeleteIntervalInMinutes:de("auto_delete_interval_in_minutes",nn()),autoStopIntervalInMinutes:de("auto_stop_interval_in_minutes",nn()),execTimeoutMs:de("exec_timeout_ms",nn()),type:st("daytona")}),vun=ae({manifest:B8e}),yun=ae({description:oe(),name:wo,path:oe().optional(),ref:oe(),type:st("git"),url:oe()}),xun=ae({description:oe(),displayName:de("display_name",oe()),name:oe(),repositoryName:de("repository_name",oe()),type:st("truefoundry"),version:nn()}),vee=$r([yun,xun]),wun=ae({manifest:vee}),_un=ae({manifest:vee}),Sun=ae({apiKey:de("api_key",oe())}),H8e=ae({auth:Sun,type:st("parallel")}),kun=ae({manifest:H8e}),Eun=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe().nullable())}),Tun=ae({authUrl:de("auth_url",oe()),id:oe(),name:oe()}),yee=ae({mcpServers:de("mcp_servers",wt(Tun)),type:st("mcp.auth_required")}).extend(Eun),V8e=ae({id:oe(),sourceEventId:de("source_event_id",oe())}),xee=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(V8e)),type:st("tool.approval_required")}),wee=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(V8e)),type:st("tool.response_required")}),Aun=$r([yee,xee,wee]),xx=ae({subjectDisplayName:de("subject_display_name",oe()),subjectId:de("subject_id",oe()),subjectType:de("subject_type",oe())}),G8e=ae({createdBySubject:de("created_by_subject",xx),description:oe(),id:oe(),manifest:lE,name:wo}),Cun=ae({nonStream:de("non_stream",oe()),stream:oe()}),Run=ae({icon:oe(),labelName:de("label_name",oe()),language:oe(),sampleCode:de("sample_code",Cun)}),Iun=ae({baseUrl:de("base_url",oe()),snippets:wt(Run)}),Nun=ae({input:oe(),model:oe().optional(),name:oe(),type:st("dynamic")}),W8e=ae({threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe())}),Mun=Uo(["authenticated","auth_required","not_required"]),_ee=ae({authorizationUrl:de("authorization_url",oe().optional()),status:Mun}),Oun=ae({type:st("header")}),Pun=ae({type:st("dcr")}),jun=$r([Pun,Oun]),K8e=ae({auth:jun.optional(),authStatus:de("auth_status",_ee),name:wo,url:oe()}),Dun=ae({name:oe()}),Lun=ae({modelId:de("model_id",oe()),name:oe(),properties:mee,provider:Dun,warning:oe().optional()}),zun=ae({description:oe(),metadata:Ac(oe(),oe()).optional(),name:oe()}),$un=ae({}),Uun=ae({enabled:Jr(),reason:oe().optional()}),Fun=ae({enabled:Jr()}),Hun=ae({enabled:Jr(),environments:Fun}),Vun=Uo(["tenant","subject"]),Gun=ae({granularity:Vun}),uv=ae({enabled:Jr(),manageProviders:de("manage_providers",Jr())}),Wun=ae({mcpServers:de("mcp_servers",uv),memoryProviders:de("memory_providers",uv),modelProviders:de("model_providers",uv),sandboxProviders:de("sandbox_providers",uv),skills:uv,webSearch:de("web_search",uv)}),Kun=ae({enabled:Jr(),reason:oe().optional()}),Yun=ae({enabled:Jr(),reason:oe().optional()}),Zun=ae({memory:Uun.optional(),sandbox:Hun,sessionSharing:de("session_sharing",Gun),settings:Wun,skill:Kun,webSearch:de("web_search",Yun)}),Xun=ae({supportedReasoningEfforts:de("supported_reasoning_efforts",wt(F8e)),type:st("custom")}),qun=st("remote"),Qun=ae({auth:hee.optional(),description:oe(),logo:oe().optional(),name:wo,type:qun,url:oe()}),Jun=ae({type:st("zep")}),edn=ae({modelId:de("model_id",oe()),name:wo,properties:mee}),tdn=Uo(["openai","anthropic","google-gemini","fireworks","zai","moonshot","alibaba","together"]),ndn=ae({logo:oe().optional(),models:wt(edn),type:tdn}),rdn=$r([ndn,Xun]),odn=ae({autoArchiveIntervalInMinutes:de("auto_archive_interval_in_minutes",nn()),autoDeleteIntervalInMinutes:de("auto_delete_interval_in_minutes",nn()),autoStopIntervalInMinutes:de("auto_stop_interval_in_minutes",nn()),execTimeoutMs:de("exec_timeout_ms",nn()),type:st("daytona")}),adn=st("git"),idn=ae({description:oe(),name:wo,path:oe().optional(),ref:oe(),type:adn,url:oe()}),sdn=ae({type:st("parallel")}),ldn=ae({arguments:oe().optional(),name:oe().optional()}),cdn=ae({function:ldn.optional(),id:oe().optional(),index:nn(),type:st("function").optional()}),udn=ae({refusal:oe(),type:st("refusal")}),ddn=ae({text:oe(),type:st("text")}),pdn=ae({arguments:oe(),name:oe()}),fdn=ae({function:pdn,id:oe(),type:st("function")}),Y8e=ae({contextTokens:de("context_tokens",nn()),thresholdTokens:de("threshold_tokens",nn()),type:st("context_threshold_exceeded")}),hdn=ae({cacheReadTokens:de("cache_read_tokens",nn().optional()),cacheWriteTokens:de("cache_write_tokens",nn().optional()),costInUsd:de("cost_in_usd",nn().optional()),inputTokens:de("input_tokens",nn()),outputTokens:de("output_tokens",nn()),reasoningTokens:de("reasoning_tokens",nn().optional()),totalTokens:de("total_tokens",nn())}),gdn=ae({memory:z8e,webSearch:de("web_search",$8e)}),mdn=ae({manifest:gdn,updatedAt:de("updated_at",Fd())}),Z8e=ae({authStatus:de("auth_status",_ee),manifest:gee,name:wo}),bdn=ae({manifest:U8e,name:wo}),X8e=ae({manifest:bee,name:wo}),vdn=ae({manifest:B8e}),q8e=ae({manifest:vee,name:oe()}),ydn=ae({manifest:H8e,name:wo}),xdn=Uo(["scheduled","triggered","failed"]),Q8e=ae({createdAt:de("created_at",Fd()),createdBySubject:de("created_by_subject",xx),id:oe(),name:oe(),reason:oe().nullable(),scheduleId:de("schedule_id",oe()),scheduledFor:de("scheduled_for",Fd()),sessionId:de("session_id",oe().nullable()),status:xdn,triggeredAt:de("triggered_at",Fd().nullable()),updatedAt:de("updated_at",Fd())}),wdn=ae({data:Q8e}),See=ae({createdAt:de("created_at",oe()),id:oe(),type:st("user.mcp_auth_continue")}),kee=ae({approval:O8e,createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_approval")}),Eee=ae({createdAt:de("created_at",oe()),id:oe(),policies:wt(D8e),type:st("user.tool_approval_policy")}),Tee=ae({content:oe(),createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_response")}),_dn=$r([See,kee,Eee,Tee]),Sdn=ae({data:wt(_dn)}),kdn=ae({}),Edn=ae({}),Tdn=ae({}),Adn=ae({}),Cdn=ae({}),Rdn=ae({}),Idn=ae({name:oe(),serverId:de("server_id",oe()),serverName:de("server_name",oe()),type:st("mcp")}),Ndn=ae({name:oe(),type:st("truefoundry-system")}),J8e=$r([Idn,Ndn]),Mdn=ae({providerSpecificFields:de("provider_specific_fields",Ac(oe(),D3()).optional()),toolInfo:de("tool_info",J8e.optional())}).extend(cdn),e$e=Uo(["stop","length","tool_calls","content_filter","function_call"]),Odn=ae({data:Iun}),C$=ae({data:G8e}),Pdn=ae({data:K8e}),jdn=ae({data:Zun}),$we=ae({data:mdn}),Ddn=ae({data:wt(Qun)}),c2=ae({data:Z8e}),Ldn=ae({data:wt(Jun)}),Uwe=ae({data:bdn}),zdn=ae({displayName:de("display_name",oe()),id:oe(),type:oe()}),$dn=Uo(["default","oidc-connected"]),Udn=ae({roles:wt(oe()),subject:zdn,tenantId:de("tenant_id",oe()),type:$dn}),Fdn=ae({data:Udn}),Bdn=ae({data:wt(rdn)}),Fwe=ae({data:X8e}),Hdn=Uo(["active","deleted"]),Vdn=ae({description:oe().optional(),environmentVariables:de("environment_variables",Ac(oe(),oe()).optional()),image:R8e.optional(),name:wo,networking:I8e.optional(),resources:N8e.optional()}),Gdn=Uo(["pending","ready","failed"]),t$e=ae({createdAt:de("created_at",Fd()),createdBySubject:de("created_by_subject",xx),description:oe(),enabled:Jr(),id:oe(),isDefault:de("is_default",Jr()),lifecycleStage:de("lifecycle_stage",Hdn),manifest:Vdn,name:wo,status:Gdn,statusReason:de("status_reason",oe().nullable()),updatedAt:de("updated_at",Fd())}),fC=ae({data:t$e}),Wdn=ae({data:wt(odn)}),Bwe=ae({data:vdn}),n$e=ae({agentName:de("agent_name",wo),createdAt:de("created_at",Fd()),createdBySubject:de("created_by_subject",xx),id:oe(),manifest:pee,name:wo,updatedAt:de("updated_at",Fd())}),R$=ae({data:n$e}),r$e=Uo(["count","$","ms"]),Aee=Uo(["sessions_over_time","sessions_cost_over_time","turns_over_time"]),Kdn=ae({timestamp:oe(),value:nn()}),Ydn=ae({name:oe(),values:wt(Kdn)}),Zdn=ae({chartType:de("chart_type",st("line")),description:oe(),displayName:de("display_name",oe()),graphLines:de("graph_lines",wt(Ydn)),name:Aee,unit:r$e}),Xdn=ae({graphs:wt(Zdn),step:oe()}),qdn=ae({data:Xdn}),Qdn=ae({chartType:de("chart_type",st("line")),description:oe(),displayName:de("display_name",oe()),name:Aee}),Jdn=ae({charts:wt(Qdn)}),epn=ae({data:Jdn}),tpn=Uo(["total_sessions","total_cost_in_usd","total_turns","cost_per_session_in_usd","avg_turns_per_session","min_turns_per_session","max_turns_per_session","median_turns_per_session","min_session_duration_ms","max_session_duration_ms","median_session_duration_ms","p95_session_duration_ms"]),npn=ae({aggregateValue:de("aggregate_value",nn()),description:oe(),name:tpn,unit:r$e}),rpn=ae({meters:wt(npn)}),opn=ae({data:rpn}),apn=ae({spec:lE,type:st("inline")}),ipn=ae({id:oe(),name:oe().nullable(),type:st("reference")}),spn=$r([apn,ipn]),lpn=Uo(["running","paused","done","cancelled","error"]),cpn=ae({status:lpn}),upn=ae({id:oe(),state:cpn}),dpn=ae({totalCostInUsd:de("total_cost_in_usd",nn().optional()),totalDurationMs:de("total_duration_ms",nn()),totalTurns:de("total_turns",nn())}),o$e=ae({agent:spn,createdAt:de("created_at",oe()),createdBySubject:de("created_by_subject",xx),id:oe(),lastTurnDetails:de("last_turn_details",upn.nullable()),metadata:fee,metrics:dpn,source:C8e.nullable(),title:oe().nullable(),updatedAt:de("updated_at",oe())}),u2=ae({data:o$e}),ppn=ae({data:wt(idn)}),Hwe=ae({data:q8e}),a$e=$r([L3,P8e,L8e]),z3=ae({totalCacheReadTokens:de("total_cache_read_tokens",nn().optional()),totalCacheWriteTokens:de("total_cache_write_tokens",nn().optional()),totalCostInUsd:de("total_cost_in_usd",nn().optional()),totalInputTokens:de("total_input_tokens",nn().optional()),totalOutputTokens:de("total_output_tokens",nn().optional()),totalReasoningTokens:de("total_reasoning_tokens",nn().optional()),totalTokens:de("total_tokens",nn().optional())}),fpn=Uo(["server-execution-timeout","client-cancelled","cancelled-for-next-turn","abandoned"]),i$e=ae({completedAt:de("completed_at",oe()),metrics:z3.optional(),reason:fpn,status:st("cancelled")}),hpn=$r([ddn,udn]),gpn=$r([oe(),wt(hpn)]),mpn=ae({harness:nn(),instructions:nn(),messages:nn(),skills:nn(),toolDefinitions:de("tool_definitions",nn())}),s$e=ae({cacheReadTokens:de("cache_read_tokens",nn().optional()),cacheWriteTokens:de("cache_write_tokens",nn().optional()),inputTokens:de("input_tokens",nn()),inputTokensBreakdown:de("input_tokens_breakdown",mpn),outputTokens:de("output_tokens",nn())}),bpn=ae({providerSpecificFields:de("provider_specific_fields",Ac(oe(),D3()).optional())}).extend(fdn),vpn=ae({toolInfo:de("tool_info",J8e)}).extend(bpn),cE=ae({content:gpn.optionalNullable(),createdAt:de("created_at",oe()),finishReason:de("finish_reason",e$e.optionalNullable()),id:oe(),model:k8e.optional(),name:oe().optional(),reasoningContent:de("reasoning_content",oe().optional()),refusal:oe().optionalNullable(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(vpn).optional()),type:st("model.message"),usage:s$e.optional()}),l$e=ae({completedAt:de("completed_at",oe()),metrics:z3.optional(),output:cE.nullable(),requiredActions:de("required_actions",wt(Aun)),status:st("done")}),c$e=ae({completedAt:de("completed_at",oe()),message:oe(),metrics:z3.optional(),status:st("error")}),u$e=ae({metrics:z3.optional(),status:st("paused")}),Cee=ae({status:st("running")}),ypn=$r([i$e,l$e,c$e,u$e,Cee]),d$e=ae({createdAt:de("created_at",oe()),id:oe(),input:wt(a$e).optional(),previousTurnId:de("previous_turn_id",oe().nullable()),sessionId:de("session_id",oe()),state:ypn}),TB=ae({data:d$e}),xpn=ae({data:wt(sdn)}),Vwe=ae({data:ydn}),Tp=ae({limit:nn(),nextPageToken:de("next_page_token",oe().optional()),previousPageToken:de("previous_page_token",oe().optional())}),wpn=ae({data:wt(G8e),pagination:Tp}),_pn=ae({data:wt(K8e)}),Spn=ae({data:wt(Lun)}),kpn=ae({data:wt(zun)}),Epn=ae({data:wt(Z8e)}),Tpn=ae({data:wt(Ac(oe(),D3()))}),Apn=ae({data:wt(X8e)}),Cpn=ae({environmentVersionId:de("environment_version_id",oe())}),Rpn=ae({data:wt(Cpn)}),Ipn=Uo(["USE","MANAGE","DELETE","CREATE"]),Npn=ae({permissions:Ac(oe(),wt(Ipn)),type:E8e}),Mpn=ae({data:Npn}),Opn=ae({data:wt(t$e),pagination:Tp}),Ppn=ae({data:wt(Q8e),pagination:Tp}),jpn=ae({data:wt(n$e),pagination:Tp}),Dpn=Uo(["streamable-http","sse"]),Lpn=ae({approvalPolicies:de("approval_policies",Ac(oe(),j8e).optional()),id:oe(),name:oe(),sessionId:de("session_id",oe().optional()),transportType:de("transport_type",Dpn.optional())}),p$e=ae({createdAt:de("created_at",oe()),id:oe(),mcpServers:de("mcp_servers",wt(Lpn)),threadId:de("thread_id",oe()),type:st("mcp.initialize")}),f$e=ae({createdAt:de("created_at",oe()),id:oe(),sandboxId:de("sandbox_id",oe()),threadId:de("thread_id",oe().nullable()),type:st("sandbox.created")}),h$e=ae({createdAt:de("created_at",oe()),durationMs:de("duration_ms",nn()),id:oe(),threadId:de("thread_id",oe()),trigger:Y8e,type:st("thread.context_compaction_finished"),usage:hdn}),g$e=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),trigger:Y8e,type:st("thread.context_compaction_started")}),m$e=ae({agentInfo:de("agent_info",Nun),createdAt:de("created_at",oe()),id:oe(),parent:W8e,threadId:de("thread_id",oe()),title:oe(),type:st("thread.created")}),zpn=ae({output:cE,status:st("done")}),$pn=ae({error:oe(),output:cE.optional(),status:st("error")}),Upn=$r([zpn,$pn]),b$e=ae({createdAt:de("created_at",oe()),id:oe(),parent:W8e.optional(),state:Upn,threadId:de("thread_id",oe()),title:oe(),type:st("thread.done")}),v$e=ae({content:oe(),createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("tool.response")}),y$e=ae({createdAt:de("created_at",oe()),id:oe(),input:wt(a$e).optional(),previousTurnId:de("previous_turn_id",oe().nullable()),state:Cee,threadId:de("thread_id",oe().nullable()),turnId:de("turn_id",oe()),type:st("turn.created")}),Fpn=$r([i$e,l$e,c$e]),x$e=ae({createdAt:de("created_at",oe()),id:oe(),state:Fpn,threadId:de("thread_id",oe().nullable()),type:st("turn.done")}),Bpn=$r([u$e,Cee]),w$e=ae({createdAt:de("created_at",oe()),id:oe(),state:Bpn,threadId:de("thread_id",oe().nullable()),type:st("turn.update")}),_$e=$r([yee,p$e,cE,f$e,h$e,g$e,m$e,b$e,xee,v$e,wee,y$e,x$e,w$e,See,kee,Eee,Tee]),Hpn=ae({event:_$e,turnId:de("turn_id",oe())}),Vpn=ae({data:wt(Hpn),pagination:Tp}),Gpn=ae({createdAt:de("created_at",oe()),grantedBySubject:de("granted_by_subject",xx),subject:EB}),Gwe=ae({data:wt(Gpn)}),Wpn=Uo(["asc","desc"]),Kpn=ae({data:wt(o$e),pagination:Tp}),Ypn=ae({data:wt(q8e)}),Zpn=ae({description:oe(),displayName:de("display_name",oe()),name:oe(),version:nn()}),Xpn=ae({data:wt(Zpn)}),qpn=Uo(["asc","desc"]),Qpn=ae({data:wt(_$e),pagination:Tp}),Jpn=ae({data:wt(d$e),pagination:Tp}),efn=ae({displayName:de("display_name",oe()),email:oe(),id:oe()}),tfn=ae({data:wt(efn),pagination:Tp}),nfn=ae({content:oe().optionalNullable(),createdAt:de("created_at",oe().optional()),finishReason:de("finish_reason",e$e.optionalNullable()),id:oe(),reasoningContent:de("reasoning_content",oe().optional()),refusal:oe().optionalNullable(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(Mdn).optional()),type:st("model.message.delta"),usage:s$e.optional()}),rfn=ae({code:oe().optionalNullable(),message:oe(),param:oe().optionalNullable(),type:oe().optional()}),fe=ae({error:rfn}),ofn=Uo(["schedule","service"]),Wwe=$r([yee,p$e,cE,nfn,f$e,h$e,g$e,m$e,b$e,xee,v$e,wee,y$e,x$e,w$e,See,kee,Eee,Tee]);let afn=class{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var g,b,v,y;const{limit:i=50,pageToken:s,agentName:l}=a,c={limit:i,page_token:s,agent_name:l},u=await this._options.authProvider.getAuthRequest(),d=dt(u.headers,(g=this._options)==null?void 0:g.headers,n==null?void 0:n.headers),f=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/agents"),method:"GET",headers:d,queryString:ft().addMany(c).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((b=this._options)==null?void 0:b.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((v=this._options)==null?void 0:v.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(y=this._options)==null?void 0:y.fetch,logging:this._options.logging});if(f.ok)return{data:wpn.parseOrThrow(f.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new In(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 401:throw new Fn(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new Pe({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return ht(f.error,f.rawResponse,"GET","/api/v1/agents")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/agents"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(lcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:C$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/agents")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:C$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/agents/{agent_id}")}update(t,n,r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(ccn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:C$.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PUT","/api/v1/agents/{agent_id}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:kdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/agents/{agent_id}")}};class ifn{constructor(t){this._options=vr(t)}me(t){return lt.fromPromise(this.__me(t))}async __me(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/auth/me"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Fdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/auth/me")}}let sfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/mcp-servers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Ddn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/mcp-servers")}},lfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/memory-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Ldn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/memory-providers")}},cfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/model-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Bdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/model-providers")}},ufn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/sandbox-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Wdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/sandbox-providers")}},dfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/skills"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:ppn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/skills")}},pfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/web-search-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:xpn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/web-search-providers")}};class ffn{constructor(t){this._options=vr(t)}get mcpServers(){return this._mcpServers??(this._mcpServers=new sfn(this._options))}get memoryProviders(){return this._memoryProviders??(this._memoryProviders=new lfn(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new cfn(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new ufn(this._options))}get skills(){return this._skills??(this._skills=new dfn(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new pfn(this._options))}}class hfn{constructor(t){this._options=vr(t)}getCodeSnippets(t,n={},r){return lt.fromPromise(this.__getCodeSnippets(t,n,r))}async __getCodeSnippets(t,n={},r){var c,u,d,f;const{baseUrl:o}=n,a={base_url:o},i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}/code-snippets`),method:"GET",headers:s,queryString:ft().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:Odn.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"GET","/api/v1/agents/{agent_id}/code-snippets")}}class gfn{constructor(t){this._options=vr(t)}listCharts(t){return lt.fromPromise(this.__listCharts(t))}async __listCharts(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/metrics/charts"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:epn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});return ht(o.error,o.rawResponse,"GET","/api/internal/metrics/charts")}getChartData(t,n){return lt.fromPromise(this.__getChartData(t,n))}async __getChartData(t,n){var d,f,g,b;const{agentId:r,startTimestamp:o,endTimestamp:a,chartName:i}=t,s={agent_id:r,start_timestamp:o.toISOString(),end_timestamp:a.toISOString(),chart_name:Aee.jsonOrThrow(i,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0})},l=await this._options.authProvider.getAuthRequest(),c=dt(l.headers,(d=this._options)==null?void 0:d.headers,n==null?void 0:n.headers),u=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/metrics/charts-data"),method:"GET",headers:c,queryString:ft().addMany(s).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((f=this._options)==null?void 0:f.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((g=this._options)==null?void 0:g.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(b=this._options)==null?void 0:b.fetch,logging:this._options.logging});if(u.ok)return{data:qdn.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new In(fe.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new Pe({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return ht(u.error,u.rawResponse,"GET","/api/internal/metrics/charts-data")}getMeters(t,n){return lt.fromPromise(this.__getMeters(t,n))}async __getMeters(t,n){var u,d,f,g;const{agentId:r,startTimestamp:o,endTimestamp:a}=t,i={agent_id:r,start_timestamp:o.toISOString(),end_timestamp:a.toISOString()},s=await this._options.authProvider.getAuthRequest(),l=dt(s.headers,(u=this._options)==null?void 0:u.headers,n==null?void 0:n.headers),c=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/metrics/meters"),method:"GET",headers:l,queryString:ft().addMany(i).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((f=this._options)==null?void 0:f.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(g=this._options)==null?void 0:g.fetch,logging:this._options.logging});if(c.ok)return{data:opn.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new In(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new Pe({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return ht(c.error,c.rawResponse,"GET","/api/internal/metrics/meters")}}let mfn=class{constructor(t){this._options=vr(t)}listPending(t){return lt.fromPromise(this.__listPending(t))}async __listPending(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/sandbox-environments/pending"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Rpn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/internal/sandbox-environments/pending")}progress(t,n){return lt.fromPromise(this.__progress(t,n))}async __progress(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/sandbox-environments/progress"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(dcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/sandbox-environments/progress")}},bfn=class{constructor(t){this._options=vr(t)}executeRun(t,n){return lt.fromPromise(this.__executeRun(t,n))}async __executeRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/schedules/runs/execute"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(pcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/schedules/runs/execute")}},vfn=class{constructor(t){this._options=vr(t)}getOrCreateByExternalId(t,n){return lt.fromPromise(this.__getOrCreateByExternalId(t,n))}async __getOrCreateByExternalId(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/sessions/get-or-create-by-external-id"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(mcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:u2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/sessions/get-or-create-by-external-id")}createTurn(t,n,r){return lt.fromPromise(this.__createTurn(t,n,r))}async __createTurn(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/internal/sessions/${Pn(t,Pe)}/turns`),method:"POST",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(_cn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:TB.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Fn(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new Av(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 413:throw new l2(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"POST","/api/internal/sessions/{session_id}/turns")}};class yfn{constructor(t){this._options=vr(t)}get metrics(){return this._metrics??(this._metrics=new gfn(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new mfn(this._options))}get schedules(){return this._schedules??(this._schedules=new bfn(this._options))}get sessions(){return this._sessions??(this._sessions=new vfn(this._options))}get agents(){return this._agents??(this._agents=new hfn(this._options))}listPermissions(t,n){return lt.fromPromise(this.__listPermissions(t,n))}async __listPermissions(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/list-permissions"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(ucn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Mpn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/list-permissions")}}let xfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/mcp-servers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:_pn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/mcp-servers")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Pdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}")}authorize(t,n={},r){return lt.fromPromise(this.__authorize(t,n,r))}async __authorize(t,n={},r){var c,u,d,f;const{returnTo:o}=n,a={return_to:o},i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}/authorize`),method:"GET",headers:s,queryString:ft().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:_ee.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new In(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new Bo(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 424:throw new Hs(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new l8e(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"GET","/api/v1/mcp-servers/{name}/authorize")}deleteAuthorization(t,n){return lt.fromPromise(this.__deleteAuthorization(t,n))}async __deleteAuthorization(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}/authorize`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/mcp-servers/{name}/authorize")}listTools(t,n){return lt.fromPromise(this.__listTools(t,n))}async __listTools(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}/tools`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Tpn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}/tools")}};class wfn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/models"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Spn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/models")}}class _fn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var f,g,b,v;const{limit:i=25,pageToken:s}=a,l={limit:i,page_token:s},c=await this._options.authProvider.getAuthRequest(),u=dt(c.headers,(f=this._options)==null?void 0:f.headers,n==null?void 0:n.headers),d=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sandbox-environments"),method:"GET",headers:u,queryString:ft().addMany(l).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((g=this._options)==null?void 0:g.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((b=this._options)==null?void 0:b.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(v=this._options)==null?void 0:v.fetch,logging:this._options.logging});if(d.ok)return{data:Opn.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new In(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new Fn(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new Pe({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return ht(d.error,d.rawResponse,"GET","/api/v1/sandbox-environments")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sandbox-environments"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(kcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:fC.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/sandbox-environments")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sandbox-environments"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Tcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:fC.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/sandbox-environments")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sandbox-environments/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:fC.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/sandbox-environments/{name}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sandbox-environments/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Adn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/sandbox-environments/{name}")}update(t,n={},r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sandbox-environments/${Pn(t,Pe)}`),method:"PATCH",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Ecn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:fC.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Fn(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 409:throw new ui(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PATCH","/api/v1/sandbox-environments/{name}")}}class Sfn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var b,v,y,w;const{limit:i=25,pageToken:s,agentNames:l,createdByMe:c}=a,u={limit:i,page_token:s,agent_names:l,created_by_me:c},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,n==null?void 0:n.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/schedules"),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:jpn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new Fn(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/schedules")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/schedules"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Icn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:R$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/schedules")}createRun(t,n){return lt.fromPromise(this.__createRun(t,n))}async __createRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/schedules/runs"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Ncn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:wdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/schedules/runs")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:R$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/schedules/{schedule_id}")}update(t,n,r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Mcn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:R$.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 409:throw new ui(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PUT","/api/v1/schedules/{schedule_id}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Cdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/schedules/{schedule_id}")}async listRuns(t,n={},r){const o=lt.interceptFunction(async i=>{var g,b,v,y;const{limit:s=25,pageToken:l}=i,c={limit:s,page_token:l},u=await this._options.authProvider.getAuthRequest(),d=dt(u.headers,(g=this._options)==null?void 0:g.headers,r==null?void 0:r.headers),f=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}/runs`),method:"GET",headers:d,queryString:ft().addMany(c).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((b=this._options)==null?void 0:b.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((v=this._options)==null?void 0:v.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(y=this._options)==null?void 0:y.fetch,logging:this._options.logging});if(f.ok)return{data:Ppn.parseOrThrow(f.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new In(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 403:throw new nr(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 404:throw new _n(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new Pe({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return ht(f.error,f.rawResponse,"GET","/api/v1/schedules/{schedule_id}/runs")}),a=await o(n).withRawResponse();return new Ud({response:a.data,rawResponse:a.rawResponse,hasNextPage:i=>(i==null?void 0:i.pagination.nextPageToken)!=null&&!(typeof(i==null?void 0:i.pagination.nextPageToken)=="string"&&(i==null?void 0:i.pagination.nextPageToken)===""),getItems:i=>(i==null?void 0:i.data)??[],loadPage:i=>o(Bd(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}}class kfn{constructor(t){this._options=vr(t)}getCapabilities(t){return lt.fromPromise(this.__getCapabilities(t))}async __getCapabilities(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/capabilities"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:jdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/capabilities")}}class Efn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var A,T,C,R;const{limit:i=25,order:s,pageToken:l,startTimestamp:c,endTimestamp:u,agentId:d,createdByMe:f,metadata:g,sourceType:b,sourceId:v}=a,y={limit:i,order:s!=null?Wpn.jsonOrThrow(s,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0,page_token:l,start_timestamp:c!=null?c==null?void 0:c.toISOString():void 0,end_timestamp:u!=null?u==null?void 0:u.toISOString():void 0,agent_id:d,created_by_me:f,metadata:g,source_type:b!=null?ofn.jsonOrThrow(b,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0,source_id:v},w=await this._options.authProvider.getAuthRequest(),S=dt(w.headers,(A=this._options)==null?void 0:A.headers,n==null?void 0:n.headers),E=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sessions"),method:"GET",headers:S,queryString:ft().addMany(y).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((T=this._options)==null?void 0:T.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((C=this._options)==null?void 0:C.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(R=this._options)==null?void 0:R.fetch,logging:this._options.logging});if(E.ok)return{data:Kpn.parseOrThrow(E.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:E.rawResponse};if(E.error.reason==="status-code")switch(E.error.statusCode){case 400:throw new In(fe.parseOrThrow(E.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),E.rawResponse);default:throw new Pe({statusCode:E.error.statusCode,body:E.error.body,rawResponse:E.rawResponse})}return ht(E.error,E.rawResponse,"GET","/api/v1/sessions")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sessions"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Pcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:u2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/sessions")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:u2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/sessions/{session_id}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/sessions/{session_id}")}update(t,n={},r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}`),method:"PATCH",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Ycn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:u2.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PATCH","/api/v1/sessions/{session_id}")}cancel(t,n={},r){return lt.fromPromise(this.__cancel(t,n,r))}async __cancel(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/cancel`),method:"POST",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Ocn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:$un.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new Av(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/cancel")}async listEvents(t,n={},r){const o=lt.interceptFunction(async i=>{var b,v,y,w;const{pageToken:s,lastTurnId:l,limit:c}=i,u={page_token:s,last_turn_id:l,limit:c},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,r==null?void 0:r.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/events`),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:Vpn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new nr(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _n(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/sessions/{session_id}/events")}),a=await o(n).withRawResponse();return new Ud({response:a.data,rawResponse:a.rawResponse,hasNextPage:i=>(i==null?void 0:i.pagination.nextPageToken)!=null&&!(typeof(i==null?void 0:i.pagination.nextPageToken)=="string"&&(i==null?void 0:i.pagination.nextPageToken)===""),getItems:i=>(i==null?void 0:i.data)??[],loadPage:i=>o(Bd(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}listGrants(t,n){return lt.fromPromise(this.__listGrants(t,n))}async __listGrants(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/grants`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Gwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/sessions/{session_id}/grants")}updateGrants(t,n={},r){return lt.fromPromise(this.__updateGrants(t,n,r))}async __updateGrants(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/grants`),method:"POST",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Kcn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:Gwe.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/grants")}async listTurns(t,n={},r){const o=lt.interceptFunction(async i=>{var b,v,y,w;const{limit:s=25,pageToken:l,assumeUser:c}=i,u={limit:s,page_token:l},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,T$({"assume-user":c}),r==null?void 0:r.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns`),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:Jpn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new nr(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _n(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/sessions/{session_id}/turns")}),a=await o(n).withRawResponse();return new Ud({response:a.data,rawResponse:a.rawResponse,hasNextPage:i=>(i==null?void 0:i.pagination.nextPageToken)!=null&&!(typeof(i==null?void 0:i.pagination.nextPageToken)=="string"&&(i==null?void 0:i.pagination.nextPageToken)===""),getItems:i=>(i==null?void 0:i.data)??[],loadPage:i=>o(Bd(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}createTurnStream(t,n,r){return lt.fromPromise(this.__createTurnStream(t,n,r))}async __createTurnStream(t,n,r){var c,u,d,f;const{assumeUser:o,...a}=n,i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,T$({"assume-user":o}),r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns`),method:"POST",headers:s,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr({...Gcn.jsonOrThrow(a,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),stream:!0},r==null?void 0:r.additionalBodyParameters),responseType:"sse",timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:new Lwe({stream:l.body,parse:async g=>Wwe.parseOrThrow(g,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:r==null?void 0:r.abortSignal,eventShape:{type:"sse"}}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new In(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new Fn(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new nr(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 412:throw new Av(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 413:throw new l2(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new Bo(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}createTurn(t,n,r){return lt.fromPromise(this.__createTurn(t,n,r))}async __createTurn(t,n,r){var c,u,d,f;const{assumeUser:o,...a}=n,i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,T$({"assume-user":o}),r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns`),method:"POST",headers:s,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr({...Hcn.jsonOrThrow(a,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),stream:!1},r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:TB.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new In(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new Fn(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new nr(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 412:throw new Av(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 413:throw new l2(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new Bo(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}getTurn(t,n,r){return lt.fromPromise(this.__getTurn(t,n,r))}async __getTurn(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}`),method:"GET",headers:a,queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:TB.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}")}downloadSandboxFile(t,n,r,o){return lt.fromPromise(this.__downloadSandboxFile(t,n,r,o))}async __downloadSandboxFile(t,n,r,o){var u,d,f,g;const{path:a}=r,i={path:a},s=await this._options.authProvider.getAuthRequest(),l=dt(s.headers,(u=this._options)==null?void 0:u.headers,o==null?void 0:o.headers),c=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/download-sandbox-file`),method:"GET",headers:l,queryString:ft().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"binary-response",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((f=this._options)==null?void 0:f.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(g=this._options)==null?void 0:g.fetch,logging:this._options.logging});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new In(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new nr(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _n(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 410:throw new Ksn(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 412:throw new Av(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 413:throw new l2(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 424:throw new Hs(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new Pe({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return ht(c.error,c.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/download-sandbox-file")}async listTurnEvents(t,n,r={},o){const a=lt.interceptFunction(async s=>{var v,y,w,S;const{limit:l,pageToken:c,order:u}=s,d={limit:l,page_token:c,order:u!=null?qpn.jsonOrThrow(u,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0},f=await this._options.authProvider.getAuthRequest(),g=dt(f.headers,(v=this._options)==null?void 0:v.headers,o==null?void 0:o.headers),b=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/events`),method:"GET",headers:g,queryString:ft().addMany(d).mergeAdditional(o==null?void 0:o.queryParams).build(),timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((y=this._options)==null?void 0:y.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((w=this._options)==null?void 0:w.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(S=this._options)==null?void 0:S.fetch,logging:this._options.logging});if(b.ok)return{data:Qpn.parseOrThrow(b.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:b.rawResponse};if(b.error.reason==="status-code")switch(b.error.statusCode){case 400:throw new In(fe.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 403:throw new nr(fe.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 404:throw new _n(fe.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);default:throw new Pe({statusCode:b.error.statusCode,body:b.error.body,rawResponse:b.rawResponse})}return ht(b.error,b.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}),i=await a(r).withRawResponse();return new Ud({response:i.data,rawResponse:i.rawResponse,hasNextPage:s=>(s==null?void 0:s.pagination.nextPageToken)!=null&&!(typeof(s==null?void 0:s.pagination.nextPageToken)=="string"&&(s==null?void 0:s.pagination.nextPageToken)===""),getItems:s=>(s==null?void 0:s.data)??[],loadPage:s=>a(Bd(r,"pageToken",s==null?void 0:s.pagination.nextPageToken))})}createTurnEvents(t,n,r,o){return lt.fromPromise(this.__createTurnEvents(t,n,r,o))}async __createTurnEvents(t,n,r,o){var l,c,u,d;const a=await this._options.authProvider.getAuthRequest(),i=dt(a.headers,(l=this._options)==null?void 0:l.headers,o==null?void 0:o.headers),s=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/events`),method:"POST",headers:i,contentType:"application/json",queryString:ft().mergeAdditional(o==null?void 0:o.queryParams).build(),requestType:"json",body:Cr(Fcn.jsonOrThrow(r,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),o==null?void 0:o.additionalBodyParameters),timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((c=this._options)==null?void 0:c.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((u=this._options)==null?void 0:u.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(s.ok)return{data:Sdn.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 400:throw new In(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new nr(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _n(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 409:throw new ui(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 422:throw new Bo(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new l8e(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new Pe({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return ht(s.error,s.rawResponse,"POST","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}subscribeToTurn(t,n,r={},o){return lt.fromPromise(this.__subscribeToTurn(t,n,r,o))}async __subscribeToTurn(t,n,r={},o){var f,g,b,v;const{afterSequenceNumber:a,fromEventId:i,afterEventId:s}=r,l={after_sequence_number:a,from_event_id:i,after_event_id:s},c=await this._options.authProvider.getAuthRequest(),u=dt(c.headers,(f=this._options)==null?void 0:f.headers,o==null?void 0:o.headers),d=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/subscribe`),method:"GET",headers:u,queryString:ft().addMany(l).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"sse",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((g=this._options)==null?void 0:g.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((b=this._options)==null?void 0:b.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(v=this._options)==null?void 0:v.fetch,logging:this._options.logging});if(d.ok)return{data:new Lwe({stream:d.body,parse:async y=>Wwe.parseOrThrow(y,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:o==null?void 0:o.abortSignal,eventShape:{type:"sse"}}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new In(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new nr(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new _n(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 412:throw new Av(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new Pe({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return ht(d.error,d.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/subscribe")}}class Tfn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/configuration"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:$we.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/configuration")}update(t,n){return lt.fromPromise(this.__update(t,n))}async __update(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/configuration"),method:"PATCH",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Xcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:$we.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PATCH","/api/v1/settings/configuration")}}class Afn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Epn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/mcp-servers")}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(tun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/settings/mcp-servers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(nun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/mcp-servers")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/mcp-servers/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/settings/mcp-servers/{name}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/mcp-servers/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Edn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/settings/mcp-servers/{name}")}}class Cfn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/memory-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Uwe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 404:throw new _n(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/memory-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/memory-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(oun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Uwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/memory-providers")}}class Rfn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/model-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Apn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/model-providers")}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/model-providers"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(gun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Fwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/settings/model-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/model-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(mun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Fwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/model-providers")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/model-providers/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Tdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/settings/model-providers/{name}")}}class Ifn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Bwe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _n(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/sandbox-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(vun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Bwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/sandbox-providers")}}let Nfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/skills"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Ypn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/skills")}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/skills"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(wun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Hwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/settings/skills")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/skills"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(_un.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Hwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/skills")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/skills/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Rdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/settings/skills/{name}")}};class Mfn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Vwe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 404:throw new _n(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/web-search-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(kun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Vwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/web-search-providers")}}class Ofn{constructor(t){this._options=vr(t)}get configuration(){return this._configuration??(this._configuration=new Tfn(this._options))}get mcpServers(){return this._mcpServers??(this._mcpServers=new Afn(this._options))}get memoryProviders(){return this._memoryProviders??(this._memoryProviders=new Cfn(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new Rfn(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new Ifn(this._options))}get skills(){return this._skills??(this._skills=new Nfn(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new Mfn(this._options))}}class Pfn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/skills"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:kpn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/skills")}listVersions(t,n){return lt.fromPromise(this.__listVersions(t,n))}async __listVersions(t,n){var l,c,u,d;const{name:r}=t,o={name:r},a=await this._options.authProvider.getAuthRequest(),i=dt(a.headers,(l=this._options)==null?void 0:l.headers,n==null?void 0:n.headers),s=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/skills/versions"),method:"GET",headers:i,queryString:ft().addMany(o).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((c=this._options)==null?void 0:c.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((u=this._options)==null?void 0:u.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(s.ok)return{data:Xpn.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new Pe({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return ht(s.error,s.rawResponse,"GET","/api/v1/skills/versions")}}class jfn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var b,v,y,w;const{query:i,limit:s=25,pageToken:l,ids:c}=a,u={query:i,limit:s,page_token:l,ids:c},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,n==null?void 0:n.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/users"),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:tfn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/users")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}}class Ree{constructor(t){this._options=vr(t)}get internal(){return this._internal??(this._internal=new yfn(this._options))}get agents(){return this._agents??(this._agents=new afn(this._options))}get auth(){return this._auth??(this._auth=new ifn(this._options))}get server(){return this._server??(this._server=new kfn(this._options))}get mcpServers(){return this._mcpServers??(this._mcpServers=new xfn(this._options))}get models(){return this._models??(this._models=new wfn(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new _fn(this._options))}get schedules(){return this._schedules??(this._schedules=new Sfn(this._options))}get sessions(){return this._sessions??(this._sessions=new Efn(this._options))}get skills(){return this._skills??(this._skills=new Pfn(this._options))}get users(){return this._users??(this._users=new jfn(this._options))}get catalogs(){return this._catalogs??(this._catalogs=new ffn(this._options))}get settings(){return this._settings??(this._settings=new Ofn(this._options))}async fetch(t,n,r){return bln(t,n,{baseUrl:this._options.baseUrl??this._options.environment,headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:async()=>(await this._options.authProvider.getAuthRequest()).headers},r)}}var fN="daytona",Dfn="Daytona";function S$e(e){return e===fN?Dfn:e}function Lfn(e){return"execTimeoutMs"in e&&typeof e.execTimeoutMs=="number"&&"autoStopIntervalInMinutes"in e&&typeof e.autoStopIntervalInMinutes=="number"&&"autoArchiveIntervalInMinutes"in e&&typeof e.autoArchiveIntervalInMinutes=="number"&&"autoDeleteIntervalInMinutes"in e&&typeof e.autoDeleteIntervalInMinutes=="number"}function Iee(e){return{execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes}}function k$e(e){return{id:e.type,name:S$e(e.type),type:e.type,...Iee(e)}}function d2(e){return{id:e.type,name:S$e(e.type),catalogId:e.type,isConnected:!0,...Iee(e)}}function E$e({providers:e,query:t}){const n=t==null?void 0:t.trim().toLowerCase();return n===void 0||n===""?e:e.filter(r=>r.name.toLowerCase().includes(n)||r.id.toLowerCase().includes(n))}function AB(e){if(e.type!==fN)throw new Error(`Unsupported sandbox provider type: ${e.type}`);return{type:fN,execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes,auth:{apiKey:e.apiKey}}}function T$e(e){async function t(n){const r=n==null?void 0:n.trim();return r!==void 0&&r!==""?r:(await e.settings.sandboxProviders.get()).data.manifest.auth.apiKey}return{getSandboxProviderCatalog:async()=>(await e.catalogs.sandboxProviders.list()).data.map(k$e),listSandboxProviders:async n=>{let r;try{const o=await e.settings.sandboxProviders.get();r=[d2(o.data.manifest)]}catch(o){if(o instanceof _n)r=[];else throw o}return E$e({providers:r,query:n==null?void 0:n.query})},createSandboxProvider:async n=>{const r=await e.settings.sandboxProviders.createOrUpdate({manifest:AB({type:n.type,apiKey:n.apiKey,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return d2(r.data.manifest)},updateSandboxProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.sandboxProviders.createOrUpdate({manifest:AB({type:fN,apiKey:r,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return d2(o.data.manifest)}}}var zfn="/";function A$e(e){var n;if(/^https?:\/\//i.test(e))return e;const t=(n=globalThis.location)==null?void 0:n.origin;return typeof t=="string"&&t.length>0&&t!=="null"?new URL(e,t).href:e}function Ap(e={}){const t=VXe(e.fetch??globalThis.fetch.bind(globalThis));return new Ree({baseUrl:A$e(e.baseUrl??zfn),fetch:t,...e.token===void 0?{}:{token:e.token}})}function Bv(e){const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid ISO timestamp: ${e}`);return t}function $fn(e){if(e==="sessions_over_time"||e==="sessions_cost_over_time"||e==="turns_over_time")return e;throw new Error(`Unsupported Harness metrics chart: ${e}`)}function C$e(e={}){const t=e.client??Ap(e);return{async getCharts(){const{data:n}=await t.internal.metrics.listCharts();return n.charts},async getMeters({agentId:n,startTimestamp:r,endTimestamp:o}){const{data:a}=await t.internal.metrics.getMeters({agentId:n,startTimestamp:Bv(r),endTimestamp:Bv(o)});return a.meters},async getChartData({agentId:n,startTimestamp:r,endTimestamp:o,chartName:a}){const{data:i}=await t.internal.metrics.getChartData({agentId:n,startTimestamp:Bv(r),endTimestamp:Bv(o),chartName:$fn(a)});return i}}}function I$(e){return{totalInputTokens:e.totalInputTokens??0,totalOutputTokens:e.totalOutputTokens??0,totalTokens:e.totalTokens??0,totalCacheReadTokens:e.totalCacheReadTokens??0,totalCacheWriteTokens:e.totalCacheWriteTokens??0,totalReasoningTokens:e.totalReasoningTokens??0,...e.totalCostInUsd==null?{}:{totalCostInUsd:e.totalCostInUsd}}}function Ufn(e){return e.status==="running"?{status:"running"}:e.status==="paused"?{status:"paused"}:Nee(e)}function R$e(e){return e.status==="running"?{status:"running"}:{status:"paused"}}function Nee(e){switch(e.status){case"cancelled":return{status:"cancelled",reason:e.reason,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:I$(e.metrics)}};case"error":return{status:"error",message:e.message,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:I$(e.metrics)}};case"done":return{status:"done",completedAt:e.completedAt,requiredActions:e.requiredActions,...e.output==null?{}:{output:e.output},...e.metrics==null?{}:{metrics:I$(e.metrics)}}}}function Ffn(e){return e.type==="turn.update"?{...e,state:R$e(e.state)}:e.type!=="turn.done"?{...e}:{...e,state:Nee(e.state)}}function Kwe(e){return e.type==="turn.update"?{...e,state:R$e(e.state)}:e.type!=="turn.done"?{...e}:{...e,state:Nee(e.state)}}function I$e(e){const t=Ffn(e.event);return t===void 0?void 0:{turnId:e.turnId,event:t}}function Bfn(e){return{...e}}function Hfn(e){return e}function Vfn(e){return{name:e.name,preload:e.preload===!0}}function Gfn(e){return{name:e.id??e.name,preload:e.preload===!0}}function hN(e){const{skills:t,mcpServers:n,...r}=e;return{...r,...n===void 0?{}:{mcpServers:n.map(o=>{if("id"in o){const{id:a,...i}=o;return i}return o})},...t===void 0?{}:{skills:t.map(Gfn)}}}function uE(e){const{mcpServers:t,skills:n,...r}=e;return{...r,...t&&t.length>0?{mcpServers:t.map(Hfn)}:{},...n?{skills:n.map(Vfn)}:{}}}function Qw(e){return{id:e.id,isMutable:e.agent.type==="inline",isCreateAgent:PH(e.metadata),createdBy:{id:e.createdBySubject.subjectId,displayName:e.createdBySubject.subjectDisplayName},createdAt:e.createdAt,updatedAt:e.updatedAt,lastTurnDetails:e.lastTurnDetails??null,metrics:{totalTurns:e.metrics.totalTurns,totalDurationMs:e.metrics.totalDurationMs,...e.metrics.totalCostInUsd==null?{}:{totalCostInUsd:e.metrics.totalCostInUsd}},...e.title===null?{}:{title:e.title},...e.agent.type==="reference"&&e.agent.name!==null?{agentName:e.agent.name}:{},...e.agent.type==="inline"?{agentSpec:uE(e.agent.spec)}:{},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function Wfn(e){if(e.metadata!==void 0)return e.metadata}function Kfn(e){return typeof e=="string"?e:e.map(t=>({...t}))}function Yfn(e){return e.map(t=>t.type==="user.message"?{...t,content:Kfn(t.content)}:t)}function Ywe(e){const{previousTurnId:t,input:n,state:r,...o}=e;return{...o,state:Ufn(r),...t===null?{}:{previousTurnId:t},...n===void 0?{}:{input:Yfn(n)}}}function qd(e,t){const n=[];for(const a of e.data){const i=t(a);i!==void 0&&n.push(i)}const r=e.response.pagination.nextPageToken,o=e.response.pagination.previousPageToken;return{data:n,...r===void 0?{}:{nextPageToken:r},...o===void 0?{}:{previousPageToken:o}}}function Zwe(e){if(e===void 0)return;const t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function Zfn(e){return typeof e=="string"?e:e.map(t=>{if(t.type==="text")return t;const{name:n,data:r}=t;if(typeof n!="string"||typeof r!="string")throw new Error("File attachment must carry a string `name` and a data-URI `data`");return{type:"file",name:n,data:r}})}function Xfn(e){return e.map(t=>({...t,content:Zfn(t.content)}))}function qfn(e){return e.map(t=>({...t}))}function N$e(e={}){const t=e.client??Ap(e);return{async downloadSandboxFile({sessionId:n,turnId:r,path:o}){return(await t.sessions.downloadSandboxFile(n,r,{path:o})).blob()},async createSession(n){const r=Wfn(n);if(n.agentName!==void 0&&n.agentName.length>0){const o=await t.sessions.create({agent:{name:n.agentName},...r===void 0?{}:{metadata:r}});return Qw(o.data)}if(n.agentSpec!==void 0){const o=await t.sessions.create({agent:{spec:hN(n.agentSpec)},...r===void 0?{}:{metadata:r}});return Qw(o.data)}throw new Error("createSession requires agentName or agentSpec")},async listSessions(n={}){const r=await t.sessions.list({...n.limit===void 0?{}:{limit:n.limit},...n.order===void 0?{}:{order:n.order},...n.pageToken===void 0?{}:{pageToken:n.pageToken},...n.agentId===void 0||n.agentId.length===0?{}:{agentId:n.agentId},...n.createdByMe===void 0?{}:{createdByMe:n.createdByMe},...n.metadata===void 0?{}:{metadata:n.metadata}});return qd(r,Qw)},async getSession({sessionId:n}){const r=await t.sessions.get(n);return Qw(r.data)},async deleteSession({sessionId:n}){await t.sessions.delete(n)},async renameSession({sessionId:n,title:r}){await t.sessions.update(n,{title:r})},async updateSession({sessionId:n,agentSpec:r,title:o}){const a={...r===void 0?{}:{agent:{spec:hN(r)}},...o===void 0?{}:{title:o}},i=await t.sessions.update(n,a);return Qw(i.data)},async*createTurn({sessionId:n,input:r,previousTurnId:o,headers:a}){const i=await t.sessions.createTurnStream(n,{input:Xfn(r),...o===void 0?{}:{previousTurnId:o}},a===void 0?void 0:{headers:a});for await(const s of i.withMetadata()){const l=Kwe(s.data);if(l===void 0)continue;const c=Zwe(s.id);yield c===void 0?{event:l}:{sequenceNumber:c,event:l}}},async sendTurnEvents({sessionId:n,turnId:r,events:o}){return(await t.sessions.createTurnEvents(n,r,{events:qfn(o)})).data.map(Bfn)},async*subscribeToTurn({sessionId:n,turnId:r,afterSequenceNumber:o,fromEventId:a,afterEventId:i}){const s=await t.sessions.subscribeToTurn(n,r,{...o===void 0?{}:{afterSequenceNumber:o},...a===void 0?{}:{fromEventId:a},...i===void 0?{}:{afterEventId:i}});for await(const l of s.withMetadata()){const c=Kwe(l.data);if(c===void 0)continue;const u=Zwe(l.id);yield u===void 0?{event:c}:{sequenceNumber:u,event:c}}},async cancelSession({sessionId:n}){await t.sessions.cancel(n)},async listTurns({sessionId:n,limit:r,pageToken:o}){const a=await t.sessions.listTurns(n,{...r===void 0?{}:{limit:r},...o===void 0?{}:{pageToken:o}});return qd(a,Ywe)},async getTurn({sessionId:n,turnId:r}){const o=await t.sessions.getTurn(n,r);return Ywe(o.data)},async listEvents({sessionId:n,pageToken:r,lastTurnId:o}){const a=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r},...o===void 0?{}:{lastTurnId:o}});return qd(a,I$e)}}}function Qfn(e){var t;return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,lastActivityAt:e.updatedAt,isCreateAgent:PH(e.metadata),isMutable:e.agent.type==="inline",lastTurnDetails:e.lastTurnDetails??null,metrics:{totalTurns:e.metrics.totalTurns,...e.metrics.totalCostInUsd==null?{}:{totalCostInUsd:e.metrics.totalCostInUsd},totalDurationMs:e.metrics.totalDurationMs},...e.title===null?{}:{title:e.title},...e.agent.type==="reference"&&e.agent.name!==null?{agentName:e.agent.name}:{},...e.agent.type==="inline"?{agentSpec:uE(e.agent.spec)}:{},...((t=e.source)==null?void 0:t.type)==="schedule"?{scheduleId:e.source.id}:{},...e.createdBySubject==null?{}:{createdBySubject:e.createdBySubject},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function M$e(e={}){const t=e.client??Ap(e);return{async getAgent({agentId:n}){const{data:r}=await t.agents.get(n);return{agentId:r.id,name:r.name,description:r.description,agentSpec:uE(r.manifest)}},async getCodeSnippets({agentId:n}){const r=A$e(e.baseUrl??"/").replace(/\/$/,""),{data:o}=await t.internal.agents.getCodeSnippets(n,/^https?:\/\//i.test(r)?{baseUrl:r}:void 0);return o.snippets},async listSessions(n={}){const r=await t.sessions.list({...n.limit===void 0?{}:{limit:n.limit},...n.order===void 0?{}:{order:n.order},...n.pageToken===void 0?{}:{pageToken:n.pageToken},...n.startTimestamp===void 0?{}:{startTimestamp:Bv(n.startTimestamp)},...n.endTimestamp===void 0?{}:{endTimestamp:Bv(n.endTimestamp)},...n.agentId===void 0||n.agentId.length===0?{}:{agentId:n.agentId},...n.createdByMe===void 0?{}:{createdByMe:n.createdByMe}});return qd(r,Qfn)},async listSessionEvents({sessionId:n,pageToken:r}){const o=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r}});return qd(o,I$e)}}}var O$e=50,Jfn=100;function P$e(e){return Math.min(Math.max(e,1),Jfn)}async function j$e({client:e,limit:t,pageToken:n,agentName:r}){const o=P$e(t),a=await e.agents.list({limit:o,...n===void 0||n===""?{}:{pageToken:n},...r===void 0?{}:{agentName:r}});return qd(a,i=>i)}async function CB(e){const t=[];let n;for(;;){const r=await j$e({client:e,limit:O$e,...n===void 0?{}:{pageToken:n}});if(t.push(...r.data),r.nextPageToken==null||r.nextPageToken==="")break;n=r.nextPageToken}return t}var Mee="Authorization";function ehn({headerName:e,value:t}){return e.toLowerCase()!==Mee.toLowerCase()||/^bearer\s+/i.test(t)?t:`Bearer ${t}`}function D$e(e){if(e===void 0)return{type:"none"};if(e.type==="dcr")return{type:"dcr"};const t=Object.keys(e.headers)[0];return{type:"header",...t===void 0?{}:{headerName:t}}}function L$e(e){var o,a;if(e.type==="none")return;if(e.type==="dcr")return{type:"dcr"};const t=(o=e.apiKey)==null?void 0:o.trim();if(t===void 0||t==="")throw new Error("API key is required for header-authenticated MCP servers");const n=(a=e.headerName)==null?void 0:a.trim(),r=n!==void 0&&n!==""?n:Mee;return{type:"header",headers:{[r]:ehn({headerName:r,value:t})}}}function thn(e){return{id:e.name,name:e.name,url:e.url,description:e.description,...e.logo===void 0?{}:{logo:e.logo},auth:D$e(e.auth)}}function nhn(e){if(typeof e!="object"||e===null)return;const t=Reflect.get(e,"readOnlyHint"),n=Reflect.get(e,"destructiveHint"),r={...typeof t=="boolean"?{readOnlyHint:t}:{},...typeof n=="boolean"?{destructiveHint:n}:{}};return Object.keys(r).length>0?r:void 0}function z$e(e){const t=typeof e.name=="string"&&e.name!==""?e.name:"tool",n=typeof e.description=="string"?e.description:"",r=nhn(Reflect.get(e,"annotations"));return r===void 0?{id:t,name:t,description:n}:{id:t,name:t,description:n,annotations:r}}function Cv(e){const t=D$e(e.manifest.auth);return{id:e.name,name:e.name,description:e.manifest.description,url:e.manifest.url,auth:t,requiresAuth:e.authStatus.status==="auth_required",authenticated:e.authStatus.status!=="auth_required"}}function RB(e){var n;const t=(n=e.auth)!=null&&n.type?{type:e.auth.type}:{type:"none"};return{id:e.name,name:e.name,description:e.url,url:e.url,auth:t,requiresAuth:e.authStatus.status==="auth_required",authenticated:e.authStatus.status!=="auth_required"}}function IB(e){var r;const t=L$e(e.auth),n=(r=e.description)==null?void 0:r.trim();return{type:"remote",name:e.name,url:e.url,description:n!==void 0&&n!==""?n:`${e.name} MCP server`,...t===void 0?{}:{auth:t}}}function $$e(e){async function t(r){const a=(await e.settings.mcpServers.list()).data.find(i=>i.name===r);if(a===void 0)throw new Error(`MCP server "${r}" not found`);return a}async function n(r){var u,d,f;if(r.auth.type!=="header")return r.auth;const o=(u=r.auth.apiKey)==null?void 0:u.trim();if(o!==void 0&&o!=="")return r.auth;if(r.id===void 0)throw new Error("API key is required for header-authenticated MCP servers");const a=await t(r.id);if(((d=a.manifest.auth)==null?void 0:d.type)!=="header")throw new Error(`MCP server "${r.id}" has no stored header credentials to reuse`);const i=(f=r.auth.headerName)==null?void 0:f.trim(),s=Object.keys(a.manifest.auth.headers)[0],l=i!==void 0&&i!==""?i:s??Mee,c=a.manifest.auth.headers[l]??Object.values(a.manifest.auth.headers)[0];if(c===void 0)throw new Error(`MCP server "${r.id}" has no stored header credentials to reuse`);return{type:"header",apiKey:c,headerName:l}}return{getConnectorCatalog:async()=>(await e.catalogs.mcpServers.list()).data.map(thn),getConnector:async r=>{const o=await e.settings.mcpServers.get(r.id);return Cv(o.data)},listConnectors:async r=>{var s;const a=(await e.settings.mcpServers.list()).data.map(Cv),i=(s=r==null?void 0:r.query)==null?void 0:s.trim().toLowerCase();return i===void 0||i===""?a:a.filter(l=>l.name.toLowerCase().includes(i)||l.description.toLowerCase().includes(i)||l.url.toLowerCase().includes(i))},getToolsByConnectorId:async({id:r})=>(await e.mcpServers.listTools(r)).data.map(z$e),createConnector:async r=>{const o=await n({auth:r.auth}),a=await e.settings.mcpServers.create({manifest:IB({name:r.name,url:r.url,auth:o,description:r.description})});return Cv(a.data)},updateConnector:async r=>{const o=await n({id:r.id,auth:r.auth}),a=await e.settings.mcpServers.createOrUpdate({manifest:IB({name:r.id,url:r.url,auth:o,description:r.description})});return Cv(a.data)},authenticateConnector:async r=>{const o=await e.mcpServers.authorize(r.id,r.returnTo===void 0?{}:{returnTo:r.returnTo});return{status:o.status,authorization_endpoint:o.authorizationUrl}},disconnectConnector:async r=>{var i;if(((i=(await t(r.id)).manifest.auth)==null?void 0:i.type)!=="dcr")throw new Error("Disconnect is only supported for OAuth MCP servers");const a=await e.mcpServers.deleteAuthorization(r.id);return Cv(a.data)},deleteConnector:async({id:r})=>{await e.settings.mcpServers.delete(r)}}}async function U$e(e){return(await e.models.list()).data}async function F$e(e){return(await e.mcpServers.list()).data}async function B$e(e){return(await e.skills.list()).data}async function H$e(e){return(await e.server.getCapabilities()).data}function V$e(e){const t=new Map;for(const n of e)n.type==="custom"||n.logo===void 0||t.set(n.type,n.logo);return t}function G$e({model:e,logo:t}){const{contextLength:n,maxOutputTokens:r,reasoningEfforts:o}=e.properties;return{id:e.modelId,name:e.name,provider:{name:e.provider.name,...t===void 0?{}:{logo:t}},properties:{...n===void 0?{}:{contextLength:n},...r===void 0?{}:{maxOutputTokens:r},...o===void 0?{}:{reasoningEfforts:[...o]}},...e.warning===void 0?{}:{warning:e.warning}}}function rhn(e){return{name:e.name,agentId:e.id,description:e.description,agentSpec:uE(e.manifest),createdBySubject:e.createdBySubject}}function W$e(e={}){const t=e.client??Ap(e);return{getCapabilities:()=>t.server.getCapabilities(),getModels:async()=>{const[n,r]=await Promise.all([t.models.list(),t.catalogs.modelProviders.list().then(a=>a.data,()=>[])]),o=V$e(r);return n.data.map(a=>{const i=o.get(a.provider.name);return G$e(i===void 0?{model:a}:{model:a,logo:i})})},getSkills:async()=>(await B$e(t)).map(r=>{const{display_name:o,repository_name:a,version:i}=r.metadata??{},s=Number(i),l=Number.isInteger(s)&&s>0;return{id:r.name,name:o??r.name,description:r.description,...a===void 0?{}:{skillRepoName:a},...l?{version:s,loadVersions:async()=>(await t.skills.listVersions({name:r.name})).data}:{}}}),getMcp:async()=>(await F$e(t)).map(RB),getMcpConnector:async({connectorId:n})=>{const r=await t.mcpServers.get(n);return RB(r.data)},getMcpTools:async({connectorId:n})=>(await t.mcpServers.listTools(n)).data.flatMap(o=>typeof o.name=="string"&&o.name.trim()!==""?[z$e(o)]:[]),async searchAgents(n){var i;const r=P$e((n==null?void 0:n.limit)??O$e),o=(i=n==null?void 0:n.query)==null?void 0:i.trim(),a=await j$e({client:t,limit:r,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken},...o===void 0||o===""?{}:{agentName:o}});return{data:a.data.map(rhn),...a.nextPageToken===void 0?{}:{nextPageToken:a.nextPageToken},...a.previousPageToken===void 0?{}:{previousPageToken:a.previousPageToken}}},async saveAgent({agentName:n,description:r,agentSpec:o,intent:a}){const i=hN(o),s=r==null?void 0:r.trim();if(a==="update"){const u=(await CB(t)).find(d=>d.name===n);return u?(await t.agents.update(u.id,{...s?{description:s}:{},manifest:i}),{agentId:u.id}):{}}return{agentId:(await t.agents.create({name:n,description:s||n,manifest:i})).data.id}},async deleteAgent({agentName:n}){const o=(await CB(t)).find(a=>a.name===n);o&&await t.agents.delete(o.id)}}}var gN="zep",ohn="Zep";function K$e(e){return e===gN?ohn:e}function Y$e(e){return{id:e.type,name:K$e(e.type),type:e.type}}function p2(e){return{id:e.type,name:K$e(e.type),catalogId:e.type,isConnected:!0,...e.serverUrl===void 0?{}:{serverUrl:e.serverUrl}}}function NB({type:e,apiKey:t,serverUrl:n}){if(e!==gN)throw new Error(`Unsupported memory provider type: ${e}`);const r=n==null?void 0:n.trim();return{type:gN,...r===void 0||r===""?{}:{serverUrl:r},auth:{apiKey:t}}}function Z$e(e){async function t(n){const r=n==null?void 0:n.trim();return r!==void 0&&r!==""?r:(await e.settings.memoryProviders.get()).data.manifest.auth.apiKey}return{getMemoryProviderCatalog:async()=>(await e.catalogs.memoryProviders.list()).data.map(Y$e),listMemoryProviders:async()=>{try{const n=await e.settings.memoryProviders.get();return[p2(n.data.manifest)]}catch(n){if(n instanceof _n)return[];throw n}},createMemoryProvider:async n=>{const r=await e.settings.memoryProviders.createOrUpdate({manifest:NB({type:n.type,apiKey:n.apiKey,serverUrl:n.serverUrl})});return p2(r.data.manifest)},updateMemoryProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.memoryProviders.createOrUpdate({manifest:NB({type:gN,apiKey:r,serverUrl:n.serverUrl})});return p2(o.data.manifest)}}}function X$e(e){return{id:e.modelId,name:e.name,properties:e.properties}}function ahn(e){return{modelId:e.id,name:e.name,properties:e.properties??{}}}function f2(e){const{name:t,manifest:n}=e;return{id:t,type:n.type,name:t,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models.map(X$e)}}function q$e(e){return e.type==="custom"?{type:e.type,name:e.type,supportedReasoningEfforts:e.supportedReasoningEfforts,models:[]}:{type:e.type,name:e.type,...e.logo===void 0?{}:{logo:e.logo},models:e.models.map(X$e)}}var ihn=[...Object.values(Ysn),"custom"];function shn(e){return ihn.includes(e)}function MB(e){var o;const t=e.models.map(ahn);if(!shn(e.type))throw new Error(`Unsupported model provider type: ${e.type}`);const n=((o=e.baseUrl)==null?void 0:o.trim())===""?void 0:e.baseUrl;if(e.type==="custom"){if(n===void 0)throw new Error(`Model providers of type "${e.type}" require a base URL`);return{type:e.type,name:e.name,models:t,baseUrl:n,...e.apiKey===""?{}:{auth:{apiKey:e.apiKey}}}}const r={apiKey:e.apiKey};return n!==void 0?{type:e.type,auth:r,models:t,baseUrl:n}:{type:e.type,auth:r,models:t}}function Q$e(e){async function t(n){var i;const r=n.apiKey.trim();if(r!=="")return r;if(n.id===void 0){if(n.type==="custom")return"";throw new Error("API key is required")}const a=(await e.settings.modelProviders.list()).data.find(s=>s.name===n.id);if(a===void 0)throw new Error(`Model provider "${n.id}" not found`);return((i=a.manifest.auth)==null?void 0:i.apiKey)??""}return{getModelProviderCatalog:async()=>(await e.catalogs.modelProviders.list()).data.map(q$e),listModelProviders:async()=>(await e.settings.modelProviders.list()).data.map(f2),createModelProvider:async n=>{const r=await t({type:n.type,apiKey:n.apiKey}),o=await e.settings.modelProviders.create({manifest:MB({type:n.type,name:n.name,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return f2(o.data)},updateModelProvider:async n=>{const r=await t({id:n.id,type:n.type,apiKey:n.apiKey}),o=await e.settings.modelProviders.createOrUpdate({manifest:MB({type:n.type,name:n.id,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return f2(o.data)},deleteModelProvider:async({id:n})=>{await e.settings.modelProviders.delete(n)}}}function lhn(e){return{id:e.name,name:e.name,description:e.description,repoURL:e.url,path:e.path??"",ref:e.ref}}function J$e(e){const t=e.path.trim();return{type:"git",name:e.name,url:e.repoURL,...t===""?{}:{path:t},ref:e.ref,description:e.description}}function e9e(e,t){const n=e.manifest,r="displayName"in n&&typeof n.displayName=="string"?n.displayName:n.name,o={id:e.name,name:r,description:n.description};return t.has(e.name)?{...o,catalogId:e.name}:o}function t9e(e){return{getSkillCatalog:async()=>(await e.catalogs.skills.list()).data.map(lhn),listSkills:async t=>{var s;const[n,r]=await Promise.all([e.settings.skills.list(),e.catalogs.skills.list()]),o=new Set(r.data.map(l=>l.name)),a=n.data.map(l=>e9e(l,o)),i=(s=t==null?void 0:t.query)==null?void 0:s.trim().toLowerCase();return i===void 0||i===""?a:a.filter(l=>l.name.toLowerCase().includes(i)||l.description.toLowerCase().includes(i))},createSkill:async t=>{const n=await e.settings.skills.create({manifest:J$e(t)}),r="catalogId"in t?t.catalogId:void 0;return r!==void 0?{id:n.data.name,name:n.data.name,description:n.data.manifest.description,catalogId:r}:{id:n.data.name,name:n.data.name,description:n.data.manifest.description}},deleteSkill:async({id:t})=>{await e.settings.skills.delete(t)}}}var mN="parallel",chn="Parallel";function n9e(e){return e===mN?chn:e}function r9e(e){return{id:e.type,name:n9e(e.type),type:e.type}}function h2(e){return{id:e.type,name:n9e(e.type),catalogId:e.type,isConnected:!0}}function o9e({providers:e,query:t}){const n=t==null?void 0:t.trim().toLowerCase();return n===void 0||n===""?e:e.filter(r=>r.name.toLowerCase().includes(n)||r.id.toLowerCase().includes(n))}function OB({type:e,apiKey:t}){if(e!==mN)throw new Error(`Unsupported web-search provider type: ${e}`);return{type:mN,auth:{apiKey:t}}}function a9e(e){async function t(n){const r=n==null?void 0:n.trim();return r!==void 0&&r!==""?r:(await e.settings.webSearchProviders.get()).data.manifest.auth.apiKey}return{getWebSearchProviderCatalog:async()=>(await e.catalogs.webSearchProviders.list()).data.map(r9e),listWebSearchProviders:async n=>{let r;try{const o=await e.settings.webSearchProviders.get();r=[h2(o.data.manifest)]}catch(o){if(o instanceof _n)r=[];else throw o}return o9e({providers:r,query:n==null?void 0:n.query})},createWebSearchProvider:async n=>{const r=await e.settings.webSearchProviders.createOrUpdate({manifest:OB({type:n.type,apiKey:n.apiKey})});return h2(r.data.manifest)},updateWebSearchProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.webSearchProviders.createOrUpdate({manifest:OB({type:mN,apiKey:r})});return h2(o.data.manifest)}}}function Xwe(e){return{webSearch:{enabled:e.webSearch.enabled},memory:{enabled:e.memory.enabled}}}function i9e(e){return{getConfiguration:async()=>{const t=await e.settings.configuration.get();return Xwe(t.data.manifest)},updateConfiguration:async t=>{const n=await e.settings.configuration.update({manifest:{...t.webSearch===void 0?{}:{webSearch:{enabled:t.webSearch.enabled}},...t.memory===void 0?{}:{memory:{enabled:t.memory.enabled}}}});return Xwe(n.data.manifest)}}}function s9e(e={}){const t=e.client??Ap(e);return{listPermissions:async n=>t.internal.listPermissions(n)}}var uhn=25,dhn=1e3;function qwe(e){return e instanceof Date?e.toISOString():e}function phn(e){return{name:e.name,...e.description===void 0?{}:{description:e.description},...e.image===void 0?{}:{image:{type:"build",...e.image.buildScript===void 0?{}:{buildScript:e.image.buildScript}}},...e.resources===void 0?{}:{resources:{cpu:e.resources.cpu??1,memory:e.resources.memory??1,disk:e.resources.disk??3}},...e.environmentVariables===void 0?{}:{environmentVariables:e.environmentVariables},...e.networking===void 0?{}:{networking:{...e.networking.networkBlockAll===void 0?{}:{networkBlockAll:e.networking.networkBlockAll},...e.networking.domainAllowList===void 0?{}:{domainAllowList:e.networking.domainAllowList},...e.networking.secrets===void 0?{}:{secrets:e.networking.secrets.map(t=>({env:t.env,value:t.value,hosts:t.hosts}))}}}}}function Qwe(e){return{name:e.name,...e.description===void 0?{}:{description:e.description},...e.image===void 0?{}:{image:{type:"build",...e.image.buildScript===void 0?{}:{buildScript:e.image.buildScript}}},...e.resources===void 0?{}:{resources:{cpu:e.resources.cpu,memory:e.resources.memory,disk:e.resources.disk}},...e.environmentVariables===void 0?{}:{environmentVariables:e.environmentVariables},...e.networking===void 0?{}:{networking:{...e.networking.networkBlockAll===void 0?{}:{networkBlockAll:e.networking.networkBlockAll},...e.networking.domainAllowList===void 0?{}:{domainAllowList:e.networking.domainAllowList},...e.networking.secrets===void 0?{}:{secrets:e.networking.secrets.map(t=>({env:t.env,value:t.value,hosts:t.hosts}))}}}}}function dv(e){return{id:e.id,name:e.name,description:e.description,enabled:e.enabled,isDefault:e.isDefault,status:e.status,statusReason:e.statusReason,manifest:phn(e.manifest),createdBySubject:e.createdBySubject,createdAt:qwe(e.createdAt),updatedAt:qwe(e.updatedAt)}}function l9e(e){const{client:t}=e;return{async listEnvironments(n){const r=Math.min(Math.max((n==null?void 0:n.limit)??uhn,1),dhn),o=await t.sandboxEnvironments.list({limit:r,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken}});return qd(o,dv)},async getEnvironment({name:n}){const{data:r}=await t.sandboxEnvironments.get(n);return dv(r)},async createEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.create({manifest:Qwe(n)});return dv(r)},async createOrUpdateEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.createOrUpdate({manifest:Qwe(n)});return dv(r)},async setEnvironmentEnabled({name:n,enabled:r}){const{data:o}=await t.sandboxEnvironments.update(n,{enabled:r});return dv(o)},async setDefaultEnvironment({name:n}){const{data:r}=await t.sandboxEnvironments.update(n,{isDefault:!0});return dv(r)},async deleteEnvironment({name:n}){await t.sandboxEnvironments.delete(n)}}}var Jwe=25;async function hC(e){const t=await CB(e),n=new Map,r=new Map;for(const o of t)n.set(o.id,o.name),r.set(o.name,o.id);return{idToName:n,nameToId:r}}function e_e(e,t){const n=t.idToName.get(e);if(n!=null)return n;if(t.nameToId.has(e))return e;throw new Error(`Unknown agent: ${e}`)}function fhn(e){const t=[];if((e==null?void 0:e.agentIds)!=null)for(const n of e.agentIds)n!==""&&t.push(n);return(e==null?void 0:e.agentId)!=null&&e.agentId!==""&&t.push(e.agentId),[...new Set(t)]}function hhn(e){return e.status??"active"}function gC(e,t){const n=t.nameToId.get(e.agentName)??e.agentName;return{id:e.id,name:e.name,agentId:n,agentName:e.agentName,task:e.manifest.task,cron:e.manifest.cron,timezone:e.manifest.timezone??"UTC",status:hhn(e.manifest),lastRunAt:null,createdBySubject:e.createdBySubject}}function t_e(e){return{task:e.task,cron:e.cron,timezone:e.timezone??"UTC",status:e.status??"active"}}function n_e(e){return e instanceof Date?e.toISOString():e}function r_e(e){return{id:e.id,scheduleId:e.scheduleId,name:e.name,scheduledFor:n_e(e.scheduledFor),status:e.status,reason:e.reason,triggeredAt:e.triggeredAt==null?null:n_e(e.triggeredAt),triggeredBy:e.createdBySubject.subjectDisplayName||e.createdBySubject.subjectId,sessionId:e.sessionId}}function c9e(e){const{client:t}=e;return{async listSchedules(n){const r=await hC(t),o=fhn(n),a=o.length===0?void 0:o.map(l=>e_e(l,r)).join(","),i=Math.min(Math.max((n==null?void 0:n.limit)??Jwe,1),Jwe),s=await t.schedules.list({limit:i,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken},...a===void 0?{}:{agentNames:a}});return qd(s,l=>gC(l,r))},async getSchedule({id:n}){const r=await hC(t),{data:o}=await t.schedules.get(n);return gC(o,r)},async createSchedule(n){const r=await hC(t),o=e_e(n.agentId,r),{data:a}=await t.schedules.create({agentName:o,name:n.name,manifest:t_e(n)});return gC(a,r)},async updateSchedule(n){const r=await hC(t),{data:o}=await t.schedules.update(n.id,{name:n.name,manifest:t_e(n)});return gC(o,r)},async deleteSchedule({id:n}){await t.schedules.delete(n)},async listScheduleRuns({scheduleId:n}){const{data:r}=await t.schedules.listRuns(n);return r.map(r_e)},async createScheduleRun(n){const{data:r}=await t.schedules.createRun({scheduleId:n.scheduleId});return r_e(r)}}}var o_e=100;function ghn(e){return{id:e.id,displayName:e.displayName,email:e.email}}async function mhn({client:e,ids:t}){const n=new Map;for(let r=0;r<t.length;r+=o_e){const o=await e.users.list({ids:t.slice(r,r+o_e).join(",")});for(const a of o.data)n.set(a.id,a)}return n}async function a_e({client:e,grants:t}){const n=t.filter(o=>o.subject.subjectType==="user"),r=await mhn({client:e,ids:n.map(o=>o.subject.subjectId)});return t.map(o=>{const a=o.subject.subjectType==="user"?r.get(o.subject.subjectId):void 0;return{subjectType:o.subject.subjectType,subjectId:o.subject.subjectId,displayName:(a==null?void 0:a.displayName)??null,email:(a==null?void 0:a.email)??null,createdAt:o.createdAt}})}function u9e(e={}){const t=e.client??Ap(e);return{async listAccess({sessionId:n}){const{data:r}=await t.sessions.listGrants(n);return a_e({client:t,grants:r})},async grantAccess({sessionId:n,subjects:r}){const{data:o}=await t.sessions.updateGrants(n,{grant:r});return a_e({client:t,grants:o})},async revokeAccess({sessionId:n,subjectType:r,subjectId:o}){await t.sessions.updateGrants(n,{revoke:[{subjectType:r,subjectId:o}]})},async searchUsers(n){const r=await t.users.list({...n.query===void 0||n.query.length===0?{}:{query:n.query},...n.limit===void 0?{}:{limit:n.limit},...n.pageToken===void 0||n.pageToken.length===0?{}:{pageToken:n.pageToken}});return qd(r,ghn)}}}function bhn(e={}){const{catalog:t,permissions:n,...r}=e,o=Ap(r),a=t??{modelCatalog:Q$e(o),connectorCatalog:$$e(o),skillCatalog:t9e(o),sandboxCatalog:T$e(o),webSearchCatalog:a9e(o),memoryCatalog:Z$e(o)};return xsn({chatServer:N$e({client:o}),...W$e({client:o}),catalog:a,configuration:i9e(o),sessions:M$e({...r,client:o}),metrics:C$e({...r,client:o}),schedules:c9e({client:o}),sandboxEnvironments:l9e({client:o}),permissions:n??s9e({client:o}),sessionAccess:u9e({client:o}),getMe:async()=>{const{data:i}=await o.auth.me();return{tenantId:i.tenantId}}})}const vhn=Object.freeze(Object.defineProperty({__proto__:null,configFromHarness:Iee,createConfigurationServer:i9e,createConnectorCatalog:$$e,createHarnessAgentMetricsServer:C$e,createHarnessAgentSessionsServer:M$e,createHarnessBuilderServer:W$e,createHarnessChatServer:N$e,createHarnessPermissionsServer:s9e,createHarnessSessionAccessServer:u9e,createMemoryProviderCatalog:Z$e,createModelProviderCatalog:Q$e,createSandboxEnvironmentServer:l9e,createSandboxProviderCatalog:T$e,createScheduleServer:c9e,createSkillCatalog:t9e,createTrueForgeAgentUIServer:bhn,createTrueForgeClient:Ap,createWebSearchProviderCatalog:a9e,filterUiSandboxProviders:E$e,filterUiWebSearchProviders:o9e,getCapabilities:H$e,isDaytonaSandboxConfig:Lfn,listConfiguredMcpServers:F$e,listModels:U$e,listSkills:B$e,modelProviderLogosByName:V$e,toHarnessAgentSpec:hN,toHarnessAuth:L$e,toHarnessConnectorManifest:IB,toHarnessMemoryManifest:NB,toHarnessModelProvider:MB,toHarnessSandboxManifest:AB,toHarnessSkillManifest:J$e,toHarnessWebSearchManifest:OB,toModelSelection:G$e,toUiAgentSpec:uE,toUiCatalogModelProviderEntry:q$e,toUiConnector:Cv,toUiConnectorFromReadEntry:RB,toUiMemoryCatalogEntry:Y$e,toUiMemoryProvider:p2,toUiModelProvider:f2,toUiSandboxCatalogEntry:k$e,toUiSandboxProvider:d2,toUiSkill:e9e,toUiWebSearchCatalogEntry:r9e,toUiWebSearchProvider:h2},Symbol.toStringTag,{value:"Module"})),ke="u">typeof window?window:void 0,di="u">typeof globalThis?globalThis:ke,ua=di==null?void 0:di.navigator,Fe=di==null?void 0:di.document,uo=di==null?void 0:di.location,QS=di==null?void 0:di.fetch,Oee=di!=null&&di.XMLHttpRequest&&"withCredentials"in new di.XMLHttpRequest?di.XMLHttpRequest:void 0,i_e=di==null?void 0:di.AbortController,yhn=di==null?void 0:di.CompressionStream,Ri=ua==null?void 0:ua.userAgent;function d9e(){return!(!ke||ke.navigator.onLine===!1)}const Jw=typeof globalThis<"u"?globalThis:ke;Jw&&typeof self>"u"&&(Jw.self=Jw),Jw&&typeof File>"u"&&(Jw.File=function(){});const $t=ke??{},xhn="0.9.0",Hd={DEBUG:!1,LIB_VERSION:xhn,LIB_NAME:"browser-common"};var Qc=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),PB=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const whn=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],_hn=["token"];function Kt(e,t){return e.indexOf(t)!==-1}const $3=function(e){return e.trim()},jB=function(e){return e.replace(/^\$/,"")};function p9e(e){var t;const n=[];return(t=JSON.stringify(e,function(r,o){if(typeof o=="bigint")return o.toString();if(typeof o!="function"&&typeof o!="symbol"){if(o instanceof Error)return{name:o.name,message:o.message,stack:o.stack};if(o&&typeof o=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(o))return"[Circular]";n.push(o)}return o}}))!==null&&t!==void 0?t:"null"}const f9e=Object.prototype,Pee=f9e.hasOwnProperty,U3=f9e.toString,Yt=Array.isArray||function(e){return U3.call(e)==="[object Array]"},ca=e=>typeof e=="function",Rn=e=>e===Object(e)&&!Yt(e),Qi=e=>{if(Rn(e)){for(const t in e)if(Pee.call(e,t))return!1;return!0}return!1},Le=e=>e===void 0,kn=e=>U3.call(e)=="[object String]",i1=e=>kn(e)&&e.trim().length===0,fo=e=>e===null,sn=e=>Le(e)||fo(e),xo=e=>U3.call(e)=="[object Number]"&&e==e,yd=e=>xo(e)&&e>0,Mi=e=>U3.call(e)==="[object Boolean]",Shn=e=>Kt(whn,e),khn=e=>Kt(_hn,e);function h9e(e){return e===null||typeof e!="object"}function bN(e,t){return{}.toString.call(e)===`[object ${t}]`}function wx(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return g9e(e,Error)}}function jee(e){return"u">typeof Event&&g9e(e,Event)}function g9e(e,t){try{return e instanceof t}catch{return!1}}const Ehn=[!0,"true",1,"1","yes"],N$=e=>Kt(Ehn,e),Thn=[!1,"false",0,"0","no"];function s_e(e,t,n,r,o,a,i){try{var s=e[a](i),l=s.value}catch(c){return void n(c)}s.done?t(l):Promise.resolve(l).then(r,o)}function Zr(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(l){s_e(a,r,o,i,s,"next",l)}function s(l){s_e(a,r,o,i,s,"throw",l)}i(void 0)})}}const Ahn=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],l_e=function(e,t=[]){if(!e)return!1;const n=e.toLowerCase();return Ahn.concat(t).some(r=>{const o=r.toLowerCase();return n.indexOf(o)!==-1})};function hu(e,t,n,r,o){return t>n&&(r.warn("min cannot be greater than max."),t=n),xo(e)?e>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+o),hu(o??n,t,n,r))}var Chn=class{constructor(e){this.C={},this.I=e.I,this.R=hu(e.bucketSize,0,100,e.A),this.$=hu(e.refillRate,0,this.R,e.A),this.O=hu(e.refillInterval,0,864e5,e.A)}F(e,t){const n=Math.floor((t-e.lastAccess)/this.O);n>0&&(e.tokens=Math.min(e.tokens+n*this.$,this.R),e.lastAccess=e.lastAccess+n*this.O)}consumeRateLimit(e){var t;const n=Date.now(),r=String(e);let o=this.C[r];return o?this.F(o,n):(o={tokens:this.R,lastAccess:n},this.C[r]=o),o.tokens===0||(o.tokens--,o.tokens===0&&((t=this.I)===null||t===void 0||t.call(this,e)),o.tokens===0)}stop(){this.C={}}};const x0="Mobile",JS="Android",vN="Tablet",m9e="Android Tablet",b9e="iPad",v9e="Apple Watch",g2="Safari",F3="BlackBerry",y9e="Samsung Internet",m2="Chrome",x9e="Chrome iOS",w9e="Internet Explorer",_9e="Internet Explorer Mobile",S9e="Opera",k9e="Microsoft Edge",b2="Firefox",E9e="Firefox iOS",yN="Nintendo",xN="PlayStation",B3="Xbox",T9e="Android Mobile",A9e="Mobile Safari",M$="Windows",C9e="Windows Phone",c_e="Nokia",DB="Ouya",Rhn="Generic "+x0.toLowerCase(),R9e="Generic "+vN.toLowerCase(),LB="Konqueror",I9e="Oculus Browser",N9e="Vivaldi",M9e="Yandex",O9e="Whale",P9e="DuckDuckGo",j9e="Pale Moon",D9e="Waterfox",zB="Brave",L9e="Claude",z9e="Codex",$9e="ChatGPT",U9e="Google Search App",O$=new RegExp("Version/(\\d+(\\.\\d+)?)"),P$=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ihn=new RegExp(B3,"i"),Nhn=new RegExp("PlayStation \\w+","i"),Mhn=new RegExp("Nintendo \\w+","i"),Dee=new RegExp("BlackBerry|PlayBook|BB10","i"),Ohn={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},F9e=function(e,t,n,r){return t=t||"",(function(a){return a!=null&&a.brave?zB:null})(n)||(r!=null&&r.detectGoogleSearchApp&&Kt(e,"GSA/")?U9e:Kt(e," OPR/")&&Kt(e,"Mini")?"Opera Mini":Kt(e," OPR/")?S9e:Dee.test(e)?F3:Kt(e,"IEMobile")||Kt(e,"WPDesktop")?_9e:Kt(e,"OculusBrowser")?I9e:Kt(e,"SamsungBrowser")?y9e:Kt(e,"Edge")||Kt(e,"Edg/")?k9e:Kt(e,"Vivaldi/")?N9e:Kt(e,"YaBrowser/")?M9e:Kt(e,"Whale/")?O9e:Kt(e,"DuckDuckGo/")||Kt(e,"Ddg/")?P9e:Kt(e,"Claude/")?L9e:Kt(e,"Codex/")?z9e:Kt(e,"ChatGPT/")?$9e:Kt(e,"FBIOS")?"Facebook Mobile":Kt(e,"UCWEB")||Kt(e,"UCBrowser")?"UC Browser":Kt(e,"CriOS")?x9e:Kt(e,"CrMo")||Kt(e,m2)?m2:Kt(e,JS)&&Kt(e,g2)?T9e:Kt(e,"FxiOS")?E9e:Kt(e.toLowerCase(),LB.toLowerCase())?LB:Kt(e,"Brave/")?zB:((a,i)=>i&&Kt(i,"Apple")||(function(s){return Kt(s,g2)&&!Kt(s,m2)&&!Kt(s,JS)})(a))(e,t)?Kt(e,x0)?A9e:g2:Kt(e,"PaleMoon/")?j9e:Kt(e,"Waterfox/")?D9e:Kt(e,b2)?b2:Kt(e,"MSIE")||Kt(e,"Trident/")?w9e:Kt(e,"Gecko")?b2:"")},Phn={[_9e]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[k9e]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[m2]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[x9e]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[g2]:[O$],[A9e]:[O$],[S9e]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[b2]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[E9e]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[LB]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[F3]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),O$],[T9e]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[y9e]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[I9e]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[N9e]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[M9e]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[O9e]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[zB]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[L9e]:[P$],[z9e]:[P$],[$9e]:[P$],[P9e]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[j9e]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[D9e]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[U9e]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[w9e]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},jhn=function(e,t,n,r){const o=F9e(e,t,n,r),a=Phn[o];if(Le(a))return null;for(let i=0;a.length>i;i++){const s=e.match(a[i]);if(s)return parseFloat(s[s.length-2])}return null},u_e=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[B3,e&&e[1]||""]],[new RegExp(yN,"i"),[yN,""]],[new RegExp(xN,"i"),[xN,""]],[Dee,[F3,""]],[new RegExp(M$,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[C9e,""];if(new RegExp(x0).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let r=Ohn[n[1]]||"";return/arm/i.test(t)&&(r="RT"),[M$,r]}return[M$,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=Le(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[JS,[e[2],e[3],e[4]||"0"].join(".")]:[JS,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],B9e=function(e){for(let t=0;u_e.length>t;t++){const[n,r]=u_e[t],o=n.exec(e),a=o&&(ca(r)?r(o,e):r);if(a)return a}return["",""]},H9e=function(e){return Mhn.test(e)?yN:Nhn.test(e)?xN:Ihn.test(e)?B3:new RegExp(DB,"i").test(e)?DB:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?C9e:/iPad/.test(e)?b9e:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?v9e:Dee.test(e)?F3:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(c_e,"i").test(e)?c_e:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(x0).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?JS:m9e:new RegExp("(pda|Mobile)","i").test(e)?Rhn:new RegExp(vN,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?R9e:""},Dhn=function(e,t){var n;const r=H9e(e);return r===b9e||r===m9e||r==="Kobo"||r==="Kindle Fire"||r===R9e?vN:r===yN||r===B3||r===xN||r===DB?"Console":r===v9e?"Wearable":r?x0:(t==null?void 0:t.userAgentDataPlatform)==="Android"&&((n=t==null?void 0:t.maxTouchPoints)!==null&&n!==void 0?n:0)>0?600>Math.min((o=t==null?void 0:t.screenWidth)!==null&&o!==void 0?o:0,(a=t==null?void 0:t.screenHeight)!==null&&a!==void 0?a:0)/((i=t==null?void 0:t.devicePixelRatio)!==null&&i!==void 0?i:1)?x0:vN:"Desktop";var o,a,i},j$=/\bFBAV\/(\d+(?:\.\d+)*)/i,d_e=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",j$],[/\bFBAN\/EMA\b/i,"Facebook Lite",j$],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",j$],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],$B="[Truncated]",dE="[Unserializable]";function by(e){let t="";for(let n=0;e.length>n;n++){const r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:"�";else{const o=e.charCodeAt(n+1);56320>o||o>57343?t+="�":(t+=e[n]+e[n+1],n++)}}return t}function V9e(e,t){if(!t)return e;let n=[];try{n=Object.keys(t)}catch{n=[]}for(const r of n){let o;try{o=t[r]}catch{o=dE}Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0,configurable:!0})}return e}const v2=3e5;var G9e=class{record(e){if(e.kind==="too-large")return;if(e.kind!=="retry-later")return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),n=Date.now(),r=Math.min(e.retryAfterMs,v2);if(!t)return this.ts=n,void(this.es=n+r);this.es=Math.max(this.es,Math.min(n+r,this.ts+v2))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(v2,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const Lhn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function p_e(e,t){return typeof(n=e)=="string"&&Lhn.test(n)?e:t();var n}function W9e(e,t){const n=new Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function eh(e){return e&&e.split("#")[0]}function f_e(e){try{return e()}catch{return}}function K9e(e,t){const n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function h_e(e,t,n){return Y9e.apply(this,arguments)}function Y9e(){return(Y9e=Zr(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((o,a)=>{r=K9e(()=>{try{n==null||n(),o()}catch(i){a(i)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}let mC,g_e,D$;function zhn(e){const t=globalThis._posthogChunkIds;if(!t)return;const n=Object.keys(t);return D$&&n.length===g_e||(g_e=n.length,D$=n.reduce((r,o)=>{mC||(mC={});const a=mC[o];if(a)r[a[0]]=a[1];else{const i=e(o);for(let s=i.length-1;s>=0;s--){const l=i[s],c=l==null?void 0:l.filename,u=t[o];if(c&&u){r[c]=u,mC[o]=[c,u];break}}}return r},{})),D$}function s1(e){return s1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s1(e)}function $hn(e,t,n){return(t=(function(r){var o=(function(a){if(s1(a)!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var s=i.call(a,"string");if(s1(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)})(r);return s1(o)=="symbol"?o:o+""})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m_e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ce(e){for(var t=1;arguments.length>t;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?m_e(Object(n),!0).forEach(function(r){$hn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m_e(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Uhn=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){const n=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(n,t,0).apply(e),o=this.buildParsingContext(t),a=this.parseStacktrace(r,o);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:"error"}}modifyFrames(e){var t=this;return Zr(function*(){for(const n of e)n.stacktrace&&n.stacktrace.frames&&Yt(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)===null||t===void 0?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var n;let r,o;if(e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null)try{o=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return ce(ce({},e),{},{cause:r,stack:o,errors:(n=e.errors)===null||n===void 0?void 0:n.map(a=>this.parseStacktrace(a,t))})}applyChunkIds(e,t){return e.map(n=>(n.filename&&t&&(n.chunk_id=t[n.filename]),n))}applyCoercers(e,t){for(const n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Zr(function*(){let n=e;for(const r of t.modifiers)n=yield r(n);return n})()}convertToExceptionList(e,t){const n=[],r=(o,a,i)=>{var s;const l=n.length,c=a===void 0?ce(ce({type:typeof t.type=="string"&&t.type.length>0?t.type:"generic"},typeof t.handled=="boolean"?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic=="boolean"?t.synthetic:o.synthetic,exception_id:l}):{type:"chained",source:i,synthetic:o.synthetic,exception_id:l,parent_id:a},u={type:o.type,value:o.value,mechanism:c};o.stack&&(u.stacktrace={type:"raw",frames:o.stack}),n.push(u),o.cause&&r(o.cause,l,"cause");for(const d of(s=o.errors)!==null&&s!==void 0?s:[])r(d,l,"member")};return r(e),n}buildParsingContext(e){var t;return{chunkIdMap:zhn(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(wx(e)){let n=Object.getPrototypeOf(e);for(let r=0;n&&100>r;r++){var t;const o=(t=Object.getOwnPropertyDescriptor(n,"constructor"))===null||t===void 0?void 0:t.value;if(typeof o=="function"&&o.name==="AggregateError"){const a=e.errors;return Yt(a)?a:void 0}n=Object.getPrototypeOf(n)}}}catch{}}buildCoercingContext(e,t,n=0){let r=0,o=0,a=!1;const i=new Set,s=[],l={},c=(f,g,b=0)=>{const v=u(g,b),y=v.apply;if(v.apply=C=>{s.push(f);try{return y(C)}finally{s.pop()}},b>4||b>0&&s.indexOf(f)!==-1)return this.coerceFallback(v);const w=typeof f=="object"&&f!==null||typeof f=="function";if(b===0&&r>=50||w&&i.has(f))return;w&&i.add(f),b===0&&r++;const S=this.getAggregateErrors(f);let E,A;a||(a=!!S);try{if(E=this.applyCoercers(f,v),!E)throw l}catch(C){if(C===l)return void(b===0&&r--);if(!a)throw C;E=this.coerceFallback(v)}if(!S||r>=50)return E;try{A=S.length}catch{return E}if(!Number.isInteger(A)||0>A||A>4294967295)return E;const T=[];for(let C=0;50>r&&1e3>o&&A>C;C++){let R;o++;try{R=v.next(S[C])}catch{r++,R=this.coerceFallback(u(g+1))}R&&T.push(R)}return ce(ce({},E),{},{errors:T})},u=(f,g=0)=>ce(ce({},t),{},{syntheticException:f==0?t.syntheticException:void 0,mechanism:f==0?e:{},apply(b){const v=c(b,f,g+1);if(!v)throw l;return v},next:b=>c(b,f+1)}),d=u(n);return ce(ce({},d),{},{apply:f=>{var g;return(g=c(f,n))!==null&&g!==void 0?g:this.coerceFallback(d)}})}};const Fhn=/^([a-z][a-z0-9.+-]+):/i,Bhn=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function Hhn(e){if(!e||e==="<anonymous>")return!1;const t=Fhn.exec(e);return!t||Bhn.includes(t[1].toLowerCase())}function UB(e,t,n,r,o){const a={platform:e,filename:t,function:n==="<anonymous>"?"?":n,in_app:Hhn(t)};return Le(r)||(a.lineno=r),Le(o)||(a.colno=o),a}const Z9e=(e,t)=>{const n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:"?",n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Vhn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ghn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Whn=/\((\S*)(?::(\d+))(?::(\d+))\)/,Khn=(e,t)=>{const n=Vhn.exec(e);if(n){const[,o,a,i]=n;return UB(t,o,"?",+a,+i)}const r=Ghn.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){const i=Whn.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}const[o,a]=Z9e(r[1]||"?",r[2]);return UB(t,a,o,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Yhn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Zhn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Xhn=(e,t)=>{const n=Yhn.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const a=Zhn.exec(n[3]);a&&(n[1]=n[1]||"eval",n[3]=a[1],n[4]=a[2],n[5]="")}let r=n[3],o=n[1]||"?";return[o,r]=Z9e(o,r),UB(t,r,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},b_e=/\(error: (.*)\)/;function Lee(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function qhn(e){for(let t=1;10>=t;t++){const n=e.length-2*t;if(0>n)break;let r=!0;for(let o=0;t>o;o++)if(!Lee(e[n+o],e[n+t+o])){r=!1;break}if(r){for(let o=0;t>o;o++)e[n+o]=e[n+t+o];return e.length=n+t,{start:n,length:t}}}}function Qhn(e,t){const n=t.start+t.length,r=q9e(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function X9e(e,t){let n=t.start;for(;n>0&&Lee(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function q9e(e,t){const n=t.start+t.length;let r=n;for(;e.length>r&&Lee(e[r],e[r-t.length]);)r++;return r-n}function Jhn(e,t){const n=t[0];let r=e.length-(n?X9e(e,n):0);for(const o of t)r-=q9e(e,o);return r}function egn(e,t,n){for(let r=0;e.length>r;r++){const o=e[(t+r)%e.length],a=e[(n+r)%e.length];if(o!==a)return a>o}return!1}var tgn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const n=kn(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return bN(e,"DOMException")}isDOMError(e){return bN(e,"DOMError")}},ngn=class{match(e){return wx(e)}coerce(e,t){var n;const r=this.getStack(e),o=r===void 0?(n=t.syntheticException)===null||n===void 0?void 0:n.stack:void 0,a=!!o;return{type:this.getType(e),value:this.getMessage(e,t),stack:r??o,cause:e.cause?t.next(e.cause):void 0,synthetic:a}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const n=e.message;return String(n.error&&typeof n.error.message=="string"?n.error.message:n)}getStack(e){try{const t=e.stacktrace;if(typeof t=="string"&&t.length>0)return t;const n=e.stack;return typeof n=="string"&&n.length>0?n:void 0}catch{return}}},rgn=class{match(e){return!!bN(e,"ErrorEvent")&&(e.error!=null||this.sr(e))}coerce(e,t){var n;if(e.error!=null)return t.apply(e.error);const r=t.apply(e.message);return ce(ce({},r),{},{stack:(n=this.ar(e))!==null&&n!==void 0?n:r.stack,synthetic:!0})}sr(e){return kn(e.message)&&e.message.length>0}ar(e){var t,n;const r=e,o=(t=r.lineno)!==null&&t!==void 0?t:0,a=(n=r.colno)!==null&&n!==void 0?n:0;if(kn(r.filename)&&r.filename.length!==0&&o!==0)return`Error
1108
+ ${b}`:b}else if(g.startsWith(dC)){const b=g.slice(dC.length).trim();b.includes("\0")||(r=b)}else if(g.startsWith(pC)){const b=g.slice(pC.length).trim(),v=parseInt(b,10);!Number.isNaN(v)&&String(v)===b&&(a=v)}}}if(c!=null){const d=await this.dispatchSseEvent(c,l);d!=null&&(yield{data:d,id:r,retry:a,event:l},o=r,t=0)}if(!this.shouldReconnect(o,t)||(t++,await this.delayReconnect(a),this.controller.signal.aborted))return;const u=this.reconnect;if(u==null||o==null)return;try{const d=await u(o);if(d==null){n=this.createEmptyStream();continue}n=d}catch{n=this.createEmptyStream()}}}async dispatchSseEvent(t,n){return this.streamTerminator!=null&&t.includes(this.streamTerminator)?null:this.parse(this.injectDiscriminator(Fv(t),n))}shouldReconnect(t,n){return!(!this.resumable||this.streamTerminator==null||!this.reconnectionEnabled||this.reconnect==null||t==null||t===""||n>=this.maxReconnectionAttempts||this.controller.signal.aborted)}async delayReconnect(t){const n=t!=null&&t>0?t:Dln,r=Math.min(n,Lln),o=this.controller.signal;o.aborted||await new Promise(a=>{const i=setTimeout(()=>{o.removeEventListener("abort",s),a()},r),s=()=>{clearTimeout(i),a()};o.addEventListener("abort",s,{once:!0})})}createEmptyStream(){return new ReadableStream({start(t){t.close()}})}removeAbortListener(){this.externalSignal!=null&&this.onExternalAbort!=null&&(this.externalSignal.removeEventListener("abort",this.onExternalAbort),this.onExternalAbort=void 0)}withMetadata(){const t=this;return{async*[Symbol.asyncIterator](){try{yield*t.iterMessages()}finally{t.removeAbortListener()}}}}injectDiscriminator(t,n){var o;if(this.eventDiscriminator==null||n==null)return t;if((o=this.envelopeEvents)!=null&&o.has(n))return{[this.eventDiscriminator]:n,data:t};if(t==null||typeof t!="object"||Array.isArray(t))return t;const r=t;return this.eventDiscriminator in r?t:{[this.eventDiscriminator]:n,...r}}async*[Symbol.asyncIterator](){try{for await(const t of this.iterMessages())yield t.data}finally{this.removeAbortListener()}}decodeChunk(t){let n="";return this.decoder!=null?n+=this.decoder.decode(t,{stream:!0}):xB.type==="node"&&typeof t<"u"&&(n+=Buffer.isBuffer(t)?t:Buffer.from(t)),n}}function zwe(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n!=null&&n.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}function Pn(e,t){if(e===null)return"null";switch(typeof e){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:e=String(e);break}const r=encodeURIComponent(e);if(r==="."||r===".."){const o=`Invalid path parameter "${r}": "." and ".." are not allowed because they change the request path.`;throw t!=null?new t({message:o}):new Error(o)}return r}function ft(){return new zln}class zln{constructor(){this.parts=new Map}add(t,n,r){if(n==null)return this;const o=dN({[t]:n},{arrayFormat:(r==null?void 0:r.style)==="comma"?"comma":"repeat"});return o.length>0&&this.parts.set(t,o),this}addMany(t){if(t!=null)for(const[n,r]of Object.entries(t))this.add(n,r);return this}mergeAdditional(t){if(t!=null)for(const[n,r]of Object.entries(t)){if(r==null)continue;const o=dN({[n]:r},{arrayFormat:"repeat"});o.length>0&&this.parts.set(n,o)}return this}build(){return[...this.parts.values()].join("&")}}function Bd(e,t,n){if(e==null)return e;const r=t.split(".");if(r.length===0)return e;const o={...e};let a=o;for(let s=0;s<r.length-1;s++){const l=r[s];if(l==null)continue;const c=a[l];Array.isArray(c)?a[l]=[...c]:a[l]=c!=null&&typeof c=="object"?{...c}:{},a=a[l]}const i=r[r.length-1];return i==null||(a[i]=n),o}const SB="token";class kB{constructor(t){this.options=t}static canCreate(t){return(t==null?void 0:t[SB])!=null}async getAuthRequest({endpointMetadata:t}={}){const n=await Ee.get(this.options[SB]);return n==null?{headers:{}}:{headers:{Authorization:`Bearer ${n}`}}}}(e=>{e.AUTH_SCHEME="BearerAuth",e.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${SB}' when initializing the client`;function t(n){return new e(n)}e.createInstance=t})(kB||(kB={}));function dt(...e){const t={};for(const[n,r]of e.filter(o=>o!=null).flatMap(o=>Object.entries(o))){const o=n.toLowerCase();r!=null?t[o]=r:o in t&&delete t[o]}return t}function T$(...e){const t={};for(const[n,r]of e.filter(o=>o!=null).flatMap(o=>Object.entries(o))){const o=n.toLowerCase();r!=null&&(t[o]=r)}return t}function $ln(e){const t=dt({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@truefoundry/trueforge-sdk","X-Fern-SDK-Version":"0.186.0","User-Agent":"@truefoundry/trueforge-sdk/0.186.0","X-Fern-Runtime":xB.type,"X-Fern-Runtime-Version":xB.version},e==null?void 0:e.headers);return{...e,logging:lee(e==null?void 0:e.logging),headers:t}}function vr(e){const t=$ln(e);if(e.auth===!1)return t.authProvider=new c8e,t;if(e.auth!=null){if(typeof e.auth=="function")return t.authProvider={getAuthRequest:e.auth},t;if(Zsn(e.auth))return t.authProvider=e.auth,t;Object.assign(t,e.auth)}const n=Uln(t);return t.authProvider??(t.authProvider=new kB(n)),t}function Uln(e){return{...e,authProvider:new c8e}}function Cr(e,t){return t==null?e:e==null?{...t}:typeof e=="object"&&!Array.isArray(e)?{...e,...t}:e}function ht(e,t,n,r){switch(e.reason){case"non-json":throw new Pe({statusCode:e.statusCode,body:e.rawBody,rawResponse:t});case"body-is-null":throw new Pe({statusCode:e.statusCode,rawResponse:t});case"timeout":throw new Wsn(`Timeout exceeded when calling ${n} ${r}.`,{cause:e.cause});case"unknown":throw new Pe({message:e.errorMessage,rawResponse:t,cause:e.cause});default:throw new Pe({message:"Unknown error",rawResponse:t})}}const Fln=ae({content:oe(),type:st("user.message")}),Bln=$r([st("@all"),st("@write"),st("@destructive"),oe()]),A$=$r([st("@all"),st("@read-only"),oe()]),Hln=ae({disableTools:de("disable_tools",wt(A$).optional()),enableTools:de("enable_tools",wt(A$).optional()),name:oe(),preload:Jr().optional(),preloadTools:de("preload_tools",wt(A$).optional()),requireApprovalForTools:de("require_approval_for_tools",wt(Bln).optional())}),Vln=ae({maxTokens:de("max_tokens",nn().optional()),parallelToolCalls:de("parallel_tool_calls",Jr().optional()),reasoningEffort:de("reasoning_effort",oe().optional()),temperature:nn().optional(),topK:de("top_k",nn().optional()),topP:de("top_p",nn().optional())}).passthrough(),k8e=ae({name:oe(),params:Vln.optional()}),Gln=ae({type:st("json_object")}).passthrough(),Wln=ae({description:oe().optional(),name:oe(),schema:Ac(oe(),D3()).optional(),strict:Jr().optionalNullable()}).passthrough(),Kln=ae({jsonSchema:de("json_schema",Wln),type:st("json_schema")}).passthrough(),Yln=ae({type:st("text")}).passthrough(),Zln=$r([Gln,Kln,Yln]),Xln=ae({enabled:Jr().optional()}),qln=ae({type:st("input_tokens"),value:nn()}),Qln=ae({enabled:Jr().optional(),trigger:qln.optional()}),Jln=ae({enabled:Jr().optional()}),ecn=ae({compaction:Qln.optional(),largeToolResponse:de("large_tool_response",Jln.optional())}),tcn=ae({enabled:Jr().optional()}),ncn=ae({enabled:Jr().optional()}),rcn=ae({enabled:Jr().optional()}),ocn=ae({enabled:Jr(),environmentName:de("environment_name",oe().optional()),fileDownloads:de("file_downloads",Jr().optional())}),acn=ae({enabled:Jr().optional()}),icn=ae({askUserQuestions:de("ask_user_questions",Xln.optional()),contextManagement:de("context_management",ecn.optional()),dynamicSubAgents:de("dynamic_sub_agents",tcn.optional()),generativeUi:de("generative_ui",ncn.optional()),iterationLimit:de("iteration_limit",nn().optional()),memory:rcn.optional(),sandbox:ocn.optional(),webSearch:de("web_search",acn.optional())}),scn=ae({name:oe(),preload:Jr().optional()}),lE=ae({config:icn.optional(),instructions:oe().optional(),mcpServers:de("mcp_servers",wt(Hln).optional()),messages:wt(Fln).optional(),model:k8e,responseFormat:de("response_format",Zln.optional()),skills:wt(scn).optional()}),wo=oe(),lcn=ae({description:oe(),manifest:lE,name:wo}),ccn=ae({description:oe().optional(),manifest:lE}),E8e=Uo(["agent","schedule","session","tenant","sandbox_environment"]),ucn=ae({resourceIds:de("resource_ids",wt(oe())),resourceType:de("resource_type",E8e)}),dcn=ae({environmentVersionId:de("environment_version_id",oe())}),pcn=ae({scheduleRunId:de("schedule_run_id",oe())}),fcn=ae({name:wo}),T8e=ae({spec:lE}),A8e=$r([fcn,T8e]),hcn=ae({id:oe(),runId:de("run_id",oe()),type:st("schedule")}),gcn=ae({type:st("service")}),C8e=$r([hcn,gcn]),mcn=ae({agent:A8e,externalId:de("external_id",oe()),source:C8e.optionalNullable()}),dee=$r([st("auto"),st("none"),oe()]),bcn=ae({data:oe(),name:oe(),type:st("file")}),vcn=ae({text:oe(),type:st("text")}),ycn=$r([bcn,vcn]),xcn=$r([oe(),wt(ycn)]),L3=ae({content:xcn,type:st("user.message")}),wcn=ae({}).extend(L3),_cn=ae({input:wt(wcn),previousTurnId:de("previous_turn_id",dee.optional()),stream:Oln(!1).optional()}),R8e=ae({buildScript:de("build_script",oe().optional()),type:st("build")}),Scn=ae({env:oe(),hosts:wt(oe()),value:oe()}),I8e=ae({domainAllowList:de("domain_allow_list",oe().optional()),networkBlockAll:de("network_block_all",Jr().optional()),secrets:wt(Scn).optional()}),N8e=ae({cpu:nn().optional(),disk:nn().optional(),memory:nn().optional()}),M8e=ae({description:oe().optional(),environmentVariables:de("environment_variables",Ac(oe(),oe()).optional()),image:R8e.optional(),name:wo,networking:I8e.optional(),resources:N8e.optional()}),kcn=ae({manifest:M8e}),Ecn=ae({enabled:Jr().optional(),isDefault:de("is_default",Jr().optional())}),Tcn=ae({manifest:M8e}),Acn=oe(),Ccn=Uo(["active","paused"]),Rcn=oe(),pee=ae({cron:Acn,status:Ccn.optional(),task:oe(),timezone:Rcn.optional()}),Icn=ae({agentName:de("agent_name",wo),manifest:pee,name:wo}),Ncn=ae({scheduleId:de("schedule_id",oe())}),Mcn=ae({manifest:pee,name:wo}),Ocn=ae({}),fee=Ac(oe(),oe()),Pcn=ae({agent:A8e,metadata:fee.optional()}),jcn=ae({type:st("user.mcp_auth_continue")}),Dcn=ae({status:st("allow")}),Lcn=ae({reason:oe().optional(),status:st("deny")}),O8e=$r([Dcn,Lcn]),P8e=ae({approval:O8e,threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_approval")}),zcn=ae({expireAt:de("expire_at",oe().optional()),type:st("allow_session")}),j8e=zcn,D8e=ae({name:oe(),policy:j8e,serverName:de("server_name",oe())}),$cn=ae({policies:wt(D8e),type:st("user.tool_approval_policy")}),L8e=ae({content:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_response")}),Ucn=$r([jcn,P8e,$cn,L8e]),Fcn=ae({events:wt(Ucn)}),Bcn=ae({}).extend(L3),Hcn=ae({input:wt(Bcn),previousTurnId:de("previous_turn_id",dee.optional())}),Vcn=ae({}).extend(L3),Gcn=ae({input:wt(Vcn),previousTurnId:de("previous_turn_id",dee.optional())}),Wcn=Uo(["user","tenant"]),EB=ae({subjectId:de("subject_id",oe()),subjectType:de("subject_type",Wcn)}),Kcn=ae({grant:wt(EB).optional(),revoke:wt(EB).optional()}),Ycn=ae({agent:T8e.optional(),metadata:fee.optional(),title:oe().optional()}),z8e=ae({enabled:Jr()}),$8e=ae({enabled:Jr()}),Zcn=ae({memory:z8e.optional(),webSearch:de("web_search",$8e.optional())}),Xcn=ae({manifest:Zcn}),qcn=ae({type:st("dcr")}),Qcn=ae({headers:Ac(oe(),oe()),type:st("header")}),hee=$r([qcn,Qcn]),Jcn=ae({auth:hee.optional(),description:oe(),name:wo,type:st("remote"),url:oe()}),eun=ae({auth:hee.optional(),description:oe(),name:wo,type:st("truefoundry"),url:oe()}),gee=$r([Jcn,eun]),tun=ae({manifest:gee}),nun=ae({manifest:gee}),run=ae({apiKey:de("api_key",oe())}),U8e=ae({auth:run,serverUrl:de("server_url",oe().optional()),type:st("zep")}),oun=ae({manifest:U8e}),F8e=Uo(["none","minimal","low","medium","high","xhigh","max"]),mee=ae({contextLength:de("context_length",nn().optional()),maxOutputTokens:de("max_output_tokens",nn().optional()),reasoningEfforts:de("reasoning_efforts",wt(F8e).optional())}),Vu=ae({modelId:de("model_id",oe()),name:wo,properties:mee}),Gu=ae({apiKey:de("api_key",oe())}),aun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("alibaba")}),iun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("anthropic")}),sun=ae({auth:Gu.optional(),baseUrl:de("base_url",oe()),models:wt(Vu),name:wo,type:st("custom")}),lun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("fireworks")}),cun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("google-gemini")}),uun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("moonshot")}),dun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("openai")}),pun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("together")}),fun=ae({auth:Gu.optional(),baseUrl:de("base_url",oe()),models:wt(Vu),type:st("truefoundry")}),hun=ae({auth:Gu,baseUrl:de("base_url",oe().optional()),models:wt(Vu),type:st("zai")}),bee=$r([aun,iun,sun,lun,cun,uun,dun,pun,fun,hun]),gun=ae({manifest:bee}),mun=ae({manifest:bee}),bun=ae({apiKey:de("api_key",oe())}),B8e=ae({auth:bun,autoArchiveIntervalInMinutes:de("auto_archive_interval_in_minutes",nn()),autoDeleteIntervalInMinutes:de("auto_delete_interval_in_minutes",nn()),autoStopIntervalInMinutes:de("auto_stop_interval_in_minutes",nn()),execTimeoutMs:de("exec_timeout_ms",nn()),type:st("daytona")}),vun=ae({manifest:B8e}),yun=ae({description:oe(),name:wo,path:oe().optional(),ref:oe(),type:st("git"),url:oe()}),xun=ae({description:oe(),displayName:de("display_name",oe()),name:oe(),repositoryName:de("repository_name",oe()),type:st("truefoundry"),version:nn()}),vee=$r([yun,xun]),wun=ae({manifest:vee}),_un=ae({manifest:vee}),Sun=ae({apiKey:de("api_key",oe())}),H8e=ae({auth:Sun,type:st("parallel")}),kun=ae({manifest:H8e}),Eun=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe().nullable())}),Tun=ae({authUrl:de("auth_url",oe()),id:oe(),name:oe()}),yee=ae({mcpServers:de("mcp_servers",wt(Tun)),type:st("mcp.auth_required")}).extend(Eun),V8e=ae({id:oe(),sourceEventId:de("source_event_id",oe())}),xee=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(V8e)),type:st("tool.approval_required")}),wee=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(V8e)),type:st("tool.response_required")}),Aun=$r([yee,xee,wee]),xx=ae({subjectDisplayName:de("subject_display_name",oe()),subjectId:de("subject_id",oe()),subjectType:de("subject_type",oe())}),G8e=ae({createdBySubject:de("created_by_subject",xx),description:oe(),id:oe(),manifest:lE,name:wo}),Cun=ae({nonStream:de("non_stream",oe()),stream:oe()}),Run=ae({icon:oe(),labelName:de("label_name",oe()),language:oe(),sampleCode:de("sample_code",Cun)}),Iun=ae({baseUrl:de("base_url",oe()),snippets:wt(Run)}),Nun=ae({input:oe(),model:oe().optional(),name:oe(),type:st("dynamic")}),W8e=ae({threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe())}),Mun=Uo(["authenticated","auth_required","not_required"]),_ee=ae({authorizationUrl:de("authorization_url",oe().optional()),status:Mun}),Oun=ae({type:st("header")}),Pun=ae({type:st("dcr")}),jun=$r([Pun,Oun]),K8e=ae({auth:jun.optional(),authStatus:de("auth_status",_ee),name:wo,url:oe()}),Dun=ae({name:oe()}),Lun=ae({modelId:de("model_id",oe()),name:oe(),properties:mee,provider:Dun,warning:oe().optional()}),zun=ae({description:oe(),metadata:Ac(oe(),oe()).optional(),name:oe()}),$un=ae({}),Uun=ae({enabled:Jr(),reason:oe().optional()}),Fun=ae({enabled:Jr()}),Hun=ae({enabled:Jr(),environments:Fun}),Vun=Uo(["tenant","subject"]),Gun=ae({granularity:Vun}),uv=ae({enabled:Jr(),manageProviders:de("manage_providers",Jr())}),Wun=ae({mcpServers:de("mcp_servers",uv),memoryProviders:de("memory_providers",uv),modelProviders:de("model_providers",uv),sandboxProviders:de("sandbox_providers",uv),skills:uv,webSearch:de("web_search",uv)}),Kun=ae({enabled:Jr(),reason:oe().optional()}),Yun=ae({enabled:Jr(),reason:oe().optional()}),Zun=ae({memory:Uun.optional(),sandbox:Hun,sessionSharing:de("session_sharing",Gun),settings:Wun,skill:Kun,webSearch:de("web_search",Yun)}),Xun=ae({supportedReasoningEfforts:de("supported_reasoning_efforts",wt(F8e)),type:st("custom")}),qun=st("remote"),Qun=ae({auth:hee.optional(),description:oe(),logo:oe().optional(),name:wo,type:qun,url:oe()}),Jun=ae({type:st("zep")}),edn=ae({modelId:de("model_id",oe()),name:wo,properties:mee}),tdn=Uo(["openai","anthropic","google-gemini","fireworks","zai","moonshot","alibaba","together"]),ndn=ae({logo:oe().optional(),models:wt(edn),type:tdn}),rdn=$r([ndn,Xun]),odn=ae({autoArchiveIntervalInMinutes:de("auto_archive_interval_in_minutes",nn()),autoDeleteIntervalInMinutes:de("auto_delete_interval_in_minutes",nn()),autoStopIntervalInMinutes:de("auto_stop_interval_in_minutes",nn()),execTimeoutMs:de("exec_timeout_ms",nn()),type:st("daytona")}),adn=st("git"),idn=ae({description:oe(),name:wo,path:oe().optional(),ref:oe(),type:adn,url:oe()}),sdn=ae({type:st("parallel")}),ldn=ae({arguments:oe().optional(),name:oe().optional()}),cdn=ae({function:ldn.optional(),id:oe().optional(),index:nn(),type:st("function").optional()}),udn=ae({refusal:oe(),type:st("refusal")}),ddn=ae({text:oe(),type:st("text")}),pdn=ae({arguments:oe(),name:oe()}),fdn=ae({function:pdn,id:oe(),type:st("function")}),Y8e=ae({contextTokens:de("context_tokens",nn()),thresholdTokens:de("threshold_tokens",nn()),type:st("context_threshold_exceeded")}),hdn=ae({cacheReadTokens:de("cache_read_tokens",nn().optional()),cacheWriteTokens:de("cache_write_tokens",nn().optional()),costInUsd:de("cost_in_usd",nn().optional()),inputTokens:de("input_tokens",nn()),outputTokens:de("output_tokens",nn()),reasoningTokens:de("reasoning_tokens",nn().optional()),totalTokens:de("total_tokens",nn())}),gdn=ae({memory:z8e,webSearch:de("web_search",$8e)}),mdn=ae({manifest:gdn,updatedAt:de("updated_at",Fd())}),Z8e=ae({authStatus:de("auth_status",_ee),manifest:gee,name:wo}),bdn=ae({manifest:U8e,name:wo}),X8e=ae({manifest:bee,name:wo}),vdn=ae({manifest:B8e}),q8e=ae({manifest:vee,name:oe()}),ydn=ae({manifest:H8e,name:wo}),xdn=Uo(["scheduled","triggered","failed"]),Q8e=ae({createdAt:de("created_at",Fd()),createdBySubject:de("created_by_subject",xx),id:oe(),name:oe(),reason:oe().nullable(),scheduleId:de("schedule_id",oe()),scheduledFor:de("scheduled_for",Fd()),sessionId:de("session_id",oe().nullable()),status:xdn,triggeredAt:de("triggered_at",Fd().nullable()),updatedAt:de("updated_at",Fd())}),wdn=ae({data:Q8e}),See=ae({createdAt:de("created_at",oe()),id:oe(),type:st("user.mcp_auth_continue")}),kee=ae({approval:O8e,createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_approval")}),Eee=ae({createdAt:de("created_at",oe()),id:oe(),policies:wt(D8e),type:st("user.tool_approval_policy")}),Tee=ae({content:oe(),createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("user.tool_response")}),_dn=$r([See,kee,Eee,Tee]),Sdn=ae({data:wt(_dn)}),kdn=ae({}),Edn=ae({}),Tdn=ae({}),Adn=ae({}),Cdn=ae({}),Rdn=ae({}),Idn=ae({name:oe(),serverId:de("server_id",oe()),serverName:de("server_name",oe()),type:st("mcp")}),Ndn=ae({name:oe(),type:st("truefoundry-system")}),J8e=$r([Idn,Ndn]),Mdn=ae({providerSpecificFields:de("provider_specific_fields",Ac(oe(),D3()).optional()),toolInfo:de("tool_info",J8e.optional())}).extend(cdn),e$e=Uo(["stop","length","tool_calls","content_filter","function_call"]),Odn=ae({data:Iun}),C$=ae({data:G8e}),Pdn=ae({data:K8e}),jdn=ae({data:Zun}),$we=ae({data:mdn}),Ddn=ae({data:wt(Qun)}),c2=ae({data:Z8e}),Ldn=ae({data:wt(Jun)}),Uwe=ae({data:bdn}),zdn=ae({displayName:de("display_name",oe()),id:oe(),type:oe()}),$dn=Uo(["default","oidc-connected"]),Udn=ae({roles:wt(oe()),subject:zdn,tenantId:de("tenant_id",oe()),type:$dn}),Fdn=ae({data:Udn}),Bdn=ae({data:wt(rdn)}),Fwe=ae({data:X8e}),Hdn=Uo(["active","deleted"]),Vdn=ae({description:oe().optional(),environmentVariables:de("environment_variables",Ac(oe(),oe()).optional()),image:R8e.optional(),name:wo,networking:I8e.optional(),resources:N8e.optional()}),Gdn=Uo(["pending","ready","failed"]),t$e=ae({createdAt:de("created_at",Fd()),createdBySubject:de("created_by_subject",xx),description:oe(),enabled:Jr(),id:oe(),isDefault:de("is_default",Jr()),lifecycleStage:de("lifecycle_stage",Hdn),manifest:Vdn,name:wo,status:Gdn,statusReason:de("status_reason",oe().nullable()),updatedAt:de("updated_at",Fd())}),fC=ae({data:t$e}),Wdn=ae({data:wt(odn)}),Bwe=ae({data:vdn}),n$e=ae({agentName:de("agent_name",wo),createdAt:de("created_at",Fd()),createdBySubject:de("created_by_subject",xx),id:oe(),manifest:pee,name:wo,updatedAt:de("updated_at",Fd())}),R$=ae({data:n$e}),r$e=Uo(["count","$","ms"]),Aee=Uo(["sessions_over_time","sessions_cost_over_time","turns_over_time"]),Kdn=ae({timestamp:oe(),value:nn()}),Ydn=ae({name:oe(),values:wt(Kdn)}),Zdn=ae({chartType:de("chart_type",st("line")),description:oe(),displayName:de("display_name",oe()),graphLines:de("graph_lines",wt(Ydn)),name:Aee,unit:r$e}),Xdn=ae({graphs:wt(Zdn),step:oe()}),qdn=ae({data:Xdn}),Qdn=ae({chartType:de("chart_type",st("line")),description:oe(),displayName:de("display_name",oe()),name:Aee}),Jdn=ae({charts:wt(Qdn)}),epn=ae({data:Jdn}),tpn=Uo(["total_sessions","total_cost_in_usd","total_turns","cost_per_session_in_usd","avg_turns_per_session","min_turns_per_session","max_turns_per_session","median_turns_per_session","min_session_duration_ms","max_session_duration_ms","median_session_duration_ms","p95_session_duration_ms"]),npn=ae({aggregateValue:de("aggregate_value",nn()),description:oe(),name:tpn,unit:r$e}),rpn=ae({meters:wt(npn)}),opn=ae({data:rpn}),apn=ae({spec:lE,type:st("inline")}),ipn=ae({id:oe(),name:oe().nullable(),type:st("reference")}),spn=$r([apn,ipn]),lpn=Uo(["running","paused","done","cancelled","error"]),cpn=ae({status:lpn}),upn=ae({id:oe(),state:cpn}),dpn=ae({totalCostInUsd:de("total_cost_in_usd",nn().optional()),totalDurationMs:de("total_duration_ms",nn()),totalTurns:de("total_turns",nn())}),o$e=ae({agent:spn,createdAt:de("created_at",oe()),createdBySubject:de("created_by_subject",xx),id:oe(),lastTurnDetails:de("last_turn_details",upn.nullable()),metadata:fee,metrics:dpn,source:C8e.nullable(),title:oe().nullable(),updatedAt:de("updated_at",oe())}),u2=ae({data:o$e}),ppn=ae({data:wt(idn)}),Hwe=ae({data:q8e}),a$e=$r([L3,P8e,L8e]),z3=ae({totalCacheReadTokens:de("total_cache_read_tokens",nn().optional()),totalCacheWriteTokens:de("total_cache_write_tokens",nn().optional()),totalCostInUsd:de("total_cost_in_usd",nn().optional()),totalInputTokens:de("total_input_tokens",nn().optional()),totalOutputTokens:de("total_output_tokens",nn().optional()),totalReasoningTokens:de("total_reasoning_tokens",nn().optional()),totalTokens:de("total_tokens",nn().optional())}),fpn=Uo(["server-execution-timeout","client-cancelled","cancelled-for-next-turn","abandoned"]),i$e=ae({completedAt:de("completed_at",oe()),metrics:z3.optional(),reason:fpn,status:st("cancelled")}),hpn=$r([ddn,udn]),gpn=$r([oe(),wt(hpn)]),mpn=ae({harness:nn(),instructions:nn(),messages:nn(),skills:nn(),toolDefinitions:de("tool_definitions",nn())}),s$e=ae({cacheReadTokens:de("cache_read_tokens",nn().optional()),cacheWriteTokens:de("cache_write_tokens",nn().optional()),inputTokens:de("input_tokens",nn()),inputTokensBreakdown:de("input_tokens_breakdown",mpn),outputTokens:de("output_tokens",nn())}),bpn=ae({providerSpecificFields:de("provider_specific_fields",Ac(oe(),D3()).optional())}).extend(fdn),vpn=ae({toolInfo:de("tool_info",J8e)}).extend(bpn),cE=ae({content:gpn.optionalNullable(),createdAt:de("created_at",oe()),finishReason:de("finish_reason",e$e.optionalNullable()),id:oe(),model:k8e.optional(),name:oe().optional(),reasoningContent:de("reasoning_content",oe().optional()),refusal:oe().optionalNullable(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(vpn).optional()),type:st("model.message"),usage:s$e.optional()}),l$e=ae({completedAt:de("completed_at",oe()),metrics:z3.optional(),output:cE.nullable(),requiredActions:de("required_actions",wt(Aun)),status:st("done")}),c$e=ae({completedAt:de("completed_at",oe()),message:oe(),metrics:z3.optional(),status:st("error")}),u$e=ae({metrics:z3.optional(),status:st("paused")}),Cee=ae({status:st("running")}),ypn=$r([i$e,l$e,c$e,u$e,Cee]),d$e=ae({createdAt:de("created_at",oe()),id:oe(),input:wt(a$e).optional(),previousTurnId:de("previous_turn_id",oe().nullable()),sessionId:de("session_id",oe()),state:ypn}),TB=ae({data:d$e}),xpn=ae({data:wt(sdn)}),Vwe=ae({data:ydn}),Tp=ae({limit:nn(),nextPageToken:de("next_page_token",oe().optional()),previousPageToken:de("previous_page_token",oe().optional())}),wpn=ae({data:wt(G8e),pagination:Tp}),_pn=ae({data:wt(K8e)}),Spn=ae({data:wt(Lun)}),kpn=ae({data:wt(zun)}),Epn=ae({data:wt(Z8e)}),Tpn=ae({data:wt(Ac(oe(),D3()))}),Apn=ae({data:wt(X8e)}),Cpn=ae({environmentVersionId:de("environment_version_id",oe())}),Rpn=ae({data:wt(Cpn)}),Ipn=Uo(["USE","MANAGE","DELETE","CREATE"]),Npn=ae({permissions:Ac(oe(),wt(Ipn)),type:E8e}),Mpn=ae({data:Npn}),Opn=ae({data:wt(t$e),pagination:Tp}),Ppn=ae({data:wt(Q8e),pagination:Tp}),jpn=ae({data:wt(n$e),pagination:Tp}),Dpn=Uo(["streamable-http","sse"]),Lpn=ae({approvalPolicies:de("approval_policies",Ac(oe(),j8e).optional()),id:oe(),name:oe(),sessionId:de("session_id",oe().optional()),transportType:de("transport_type",Dpn.optional())}),p$e=ae({createdAt:de("created_at",oe()),id:oe(),mcpServers:de("mcp_servers",wt(Lpn)),threadId:de("thread_id",oe()),type:st("mcp.initialize")}),f$e=ae({createdAt:de("created_at",oe()),id:oe(),sandboxId:de("sandbox_id",oe()),threadId:de("thread_id",oe().nullable()),type:st("sandbox.created")}),h$e=ae({createdAt:de("created_at",oe()),durationMs:de("duration_ms",nn()),id:oe(),threadId:de("thread_id",oe()),trigger:Y8e,type:st("thread.context_compaction_finished"),usage:hdn}),g$e=ae({createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),trigger:Y8e,type:st("thread.context_compaction_started")}),m$e=ae({agentInfo:de("agent_info",Nun),createdAt:de("created_at",oe()),id:oe(),parent:W8e,threadId:de("thread_id",oe()),title:oe(),type:st("thread.created")}),zpn=ae({output:cE,status:st("done")}),$pn=ae({error:oe(),output:cE.optional(),status:st("error")}),Upn=$r([zpn,$pn]),b$e=ae({createdAt:de("created_at",oe()),id:oe(),parent:W8e.optional(),state:Upn,threadId:de("thread_id",oe()),title:oe(),type:st("thread.done")}),v$e=ae({content:oe(),createdAt:de("created_at",oe()),id:oe(),threadId:de("thread_id",oe()),toolCallId:de("tool_call_id",oe()),type:st("tool.response")}),y$e=ae({createdAt:de("created_at",oe()),id:oe(),input:wt(a$e).optional(),previousTurnId:de("previous_turn_id",oe().nullable()),state:Cee,threadId:de("thread_id",oe().nullable()),turnId:de("turn_id",oe()),type:st("turn.created")}),Fpn=$r([i$e,l$e,c$e]),x$e=ae({createdAt:de("created_at",oe()),id:oe(),state:Fpn,threadId:de("thread_id",oe().nullable()),type:st("turn.done")}),Bpn=$r([u$e,Cee]),w$e=ae({createdAt:de("created_at",oe()),id:oe(),state:Bpn,threadId:de("thread_id",oe().nullable()),type:st("turn.update")}),_$e=$r([yee,p$e,cE,f$e,h$e,g$e,m$e,b$e,xee,v$e,wee,y$e,x$e,w$e,See,kee,Eee,Tee]),Hpn=ae({event:_$e,turnId:de("turn_id",oe())}),Vpn=ae({data:wt(Hpn),pagination:Tp}),Gpn=ae({createdAt:de("created_at",oe()),grantedBySubject:de("granted_by_subject",xx),subject:EB}),Gwe=ae({data:wt(Gpn)}),Wpn=Uo(["asc","desc"]),Kpn=ae({data:wt(o$e),pagination:Tp}),Ypn=ae({data:wt(q8e)}),Zpn=ae({description:oe(),displayName:de("display_name",oe()),name:oe(),version:nn()}),Xpn=ae({data:wt(Zpn)}),qpn=Uo(["asc","desc"]),Qpn=ae({data:wt(_$e),pagination:Tp}),Jpn=ae({data:wt(d$e),pagination:Tp}),efn=ae({displayName:de("display_name",oe()),email:oe(),id:oe()}),tfn=ae({data:wt(efn),pagination:Tp}),nfn=ae({content:oe().optionalNullable(),createdAt:de("created_at",oe().optional()),finishReason:de("finish_reason",e$e.optionalNullable()),id:oe(),reasoningContent:de("reasoning_content",oe().optional()),refusal:oe().optionalNullable(),threadId:de("thread_id",oe()),toolCalls:de("tool_calls",wt(Mdn).optional()),type:st("model.message.delta"),usage:s$e.optional()}),rfn=ae({code:oe().optionalNullable(),message:oe(),param:oe().optionalNullable(),type:oe().optional()}),fe=ae({error:rfn}),ofn=Uo(["schedule","service"]),Wwe=$r([yee,p$e,cE,nfn,f$e,h$e,g$e,m$e,b$e,xee,v$e,wee,y$e,x$e,w$e,See,kee,Eee,Tee]);let afn=class{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var g,b,v,y;const{limit:i=50,pageToken:s,agentName:l}=a,c={limit:i,page_token:s,agent_name:l},u=await this._options.authProvider.getAuthRequest(),d=dt(u.headers,(g=this._options)==null?void 0:g.headers,n==null?void 0:n.headers),f=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/agents"),method:"GET",headers:d,queryString:ft().addMany(c).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((b=this._options)==null?void 0:b.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((v=this._options)==null?void 0:v.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(y=this._options)==null?void 0:y.fetch,logging:this._options.logging});if(f.ok)return{data:wpn.parseOrThrow(f.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new In(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 401:throw new Fn(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new Pe({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return ht(f.error,f.rawResponse,"GET","/api/v1/agents")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/agents"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(lcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:C$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/agents")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:C$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/agents/{agent_id}")}update(t,n,r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(ccn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:C$.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PUT","/api/v1/agents/{agent_id}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:kdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/agents/{agent_id}")}};class ifn{constructor(t){this._options=vr(t)}me(t){return lt.fromPromise(this.__me(t))}async __me(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/auth/me"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Fdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/auth/me")}}let sfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/mcp-servers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Ddn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/mcp-servers")}},lfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/memory-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Ldn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/memory-providers")}},cfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/model-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Bdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/model-providers")}},ufn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/sandbox-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Wdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/sandbox-providers")}},dfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/skills"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:ppn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/skills")}},pfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/catalogs/web-search-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:xpn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/catalogs/web-search-providers")}};class ffn{constructor(t){this._options=vr(t)}get mcpServers(){return this._mcpServers??(this._mcpServers=new sfn(this._options))}get memoryProviders(){return this._memoryProviders??(this._memoryProviders=new lfn(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new cfn(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new ufn(this._options))}get skills(){return this._skills??(this._skills=new dfn(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new pfn(this._options))}}class hfn{constructor(t){this._options=vr(t)}getCodeSnippets(t,n={},r){return lt.fromPromise(this.__getCodeSnippets(t,n,r))}async __getCodeSnippets(t,n={},r){var c,u,d,f;const{baseUrl:o}=n,a={base_url:o},i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/agents/${Pn(t,Pe)}/code-snippets`),method:"GET",headers:s,queryString:ft().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:Odn.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"GET","/api/v1/agents/{agent_id}/code-snippets")}}class gfn{constructor(t){this._options=vr(t)}listCharts(t){return lt.fromPromise(this.__listCharts(t))}async __listCharts(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/metrics/charts"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:epn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});return ht(o.error,o.rawResponse,"GET","/api/internal/metrics/charts")}getChartData(t,n){return lt.fromPromise(this.__getChartData(t,n))}async __getChartData(t,n){var d,f,g,b;const{agentId:r,startTimestamp:o,endTimestamp:a,chartName:i}=t,s={agent_id:r,start_timestamp:o.toISOString(),end_timestamp:a.toISOString(),chart_name:Aee.jsonOrThrow(i,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0})},l=await this._options.authProvider.getAuthRequest(),c=dt(l.headers,(d=this._options)==null?void 0:d.headers,n==null?void 0:n.headers),u=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/metrics/charts-data"),method:"GET",headers:c,queryString:ft().addMany(s).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((f=this._options)==null?void 0:f.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((g=this._options)==null?void 0:g.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(b=this._options)==null?void 0:b.fetch,logging:this._options.logging});if(u.ok)return{data:qdn.parseOrThrow(u.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 400:throw new In(fe.parseOrThrow(u.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),u.rawResponse);default:throw new Pe({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}return ht(u.error,u.rawResponse,"GET","/api/internal/metrics/charts-data")}getMeters(t,n){return lt.fromPromise(this.__getMeters(t,n))}async __getMeters(t,n){var u,d,f,g;const{agentId:r,startTimestamp:o,endTimestamp:a}=t,i={agent_id:r,start_timestamp:o.toISOString(),end_timestamp:a.toISOString()},s=await this._options.authProvider.getAuthRequest(),l=dt(s.headers,(u=this._options)==null?void 0:u.headers,n==null?void 0:n.headers),c=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/metrics/meters"),method:"GET",headers:l,queryString:ft().addMany(i).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((f=this._options)==null?void 0:f.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(g=this._options)==null?void 0:g.fetch,logging:this._options.logging});if(c.ok)return{data:opn.parseOrThrow(c.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new In(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new Pe({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return ht(c.error,c.rawResponse,"GET","/api/internal/metrics/meters")}}let mfn=class{constructor(t){this._options=vr(t)}listPending(t){return lt.fromPromise(this.__listPending(t))}async __listPending(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/sandbox-environments/pending"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Rpn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/internal/sandbox-environments/pending")}progress(t,n){return lt.fromPromise(this.__progress(t,n))}async __progress(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/sandbox-environments/progress"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(dcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/sandbox-environments/progress")}},bfn=class{constructor(t){this._options=vr(t)}executeRun(t,n){return lt.fromPromise(this.__executeRun(t,n))}async __executeRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/schedules/runs/execute"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(pcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/schedules/runs/execute")}},vfn=class{constructor(t){this._options=vr(t)}getOrCreateByExternalId(t,n){return lt.fromPromise(this.__getOrCreateByExternalId(t,n))}async __getOrCreateByExternalId(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/sessions/get-or-create-by-external-id"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(mcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:u2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/sessions/get-or-create-by-external-id")}createTurn(t,n,r){return lt.fromPromise(this.__createTurn(t,n,r))}async __createTurn(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/internal/sessions/${Pn(t,Pe)}/turns`),method:"POST",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(_cn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:TB.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Fn(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new Av(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 413:throw new l2(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"POST","/api/internal/sessions/{session_id}/turns")}};class yfn{constructor(t){this._options=vr(t)}get metrics(){return this._metrics??(this._metrics=new gfn(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new mfn(this._options))}get schedules(){return this._schedules??(this._schedules=new bfn(this._options))}get sessions(){return this._sessions??(this._sessions=new vfn(this._options))}get agents(){return this._agents??(this._agents=new hfn(this._options))}listPermissions(t,n){return lt.fromPromise(this.__listPermissions(t,n))}async __listPermissions(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/internal/list-permissions"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(ucn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Mpn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/internal/list-permissions")}}let xfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/mcp-servers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:_pn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/mcp-servers")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Pdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}")}authorize(t,n={},r){return lt.fromPromise(this.__authorize(t,n,r))}async __authorize(t,n={},r){var c,u,d,f;const{returnTo:o}=n,a={return_to:o},i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}/authorize`),method:"GET",headers:s,queryString:ft().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:_ee.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new In(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new Bo(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 424:throw new Hs(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new l8e(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"GET","/api/v1/mcp-servers/{name}/authorize")}deleteAuthorization(t,n){return lt.fromPromise(this.__deleteAuthorization(t,n))}async __deleteAuthorization(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}/authorize`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/mcp-servers/{name}/authorize")}listTools(t,n){return lt.fromPromise(this.__listTools(t,n))}async __listTools(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/mcp-servers/${Pn(t,Pe)}/tools`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Tpn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}/tools")}};class wfn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/models"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Spn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/models")}}class _fn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var f,g,b,v;const{limit:i=25,pageToken:s}=a,l={limit:i,page_token:s},c=await this._options.authProvider.getAuthRequest(),u=dt(c.headers,(f=this._options)==null?void 0:f.headers,n==null?void 0:n.headers),d=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sandbox-environments"),method:"GET",headers:u,queryString:ft().addMany(l).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((g=this._options)==null?void 0:g.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((b=this._options)==null?void 0:b.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(v=this._options)==null?void 0:v.fetch,logging:this._options.logging});if(d.ok)return{data:Opn.parseOrThrow(d.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new In(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 401:throw new Fn(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new Pe({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return ht(d.error,d.rawResponse,"GET","/api/v1/sandbox-environments")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sandbox-environments"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(kcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:fC.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/sandbox-environments")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sandbox-environments"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Tcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:fC.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/sandbox-environments")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sandbox-environments/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:fC.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/sandbox-environments/{name}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sandbox-environments/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Adn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new s2(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/sandbox-environments/{name}")}update(t,n={},r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sandbox-environments/${Pn(t,Pe)}`),method:"PATCH",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Ecn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:fC.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Fn(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 409:throw new ui(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PATCH","/api/v1/sandbox-environments/{name}")}}class Sfn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var b,v,y,w;const{limit:i=25,pageToken:s,agentNames:l,createdByMe:c}=a,u={limit:i,page_token:s,agent_names:l,created_by_me:c},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,n==null?void 0:n.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/schedules"),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:jpn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 401:throw new Fn(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/schedules")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/schedules"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Icn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:R$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/schedules")}createRun(t,n){return lt.fromPromise(this.__createRun(t,n))}async __createRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/schedules/runs"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Ncn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:wdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/schedules/runs")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:R$.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/schedules/{schedule_id}")}update(t,n,r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Mcn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:R$.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 409:throw new ui(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PUT","/api/v1/schedules/{schedule_id}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Cdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/schedules/{schedule_id}")}async listRuns(t,n={},r){const o=lt.interceptFunction(async i=>{var g,b,v,y;const{limit:s=25,pageToken:l}=i,c={limit:s,page_token:l},u=await this._options.authProvider.getAuthRequest(),d=dt(u.headers,(g=this._options)==null?void 0:g.headers,r==null?void 0:r.headers),f=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/schedules/${Pn(t,Pe)}/runs`),method:"GET",headers:d,queryString:ft().addMany(c).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((b=this._options)==null?void 0:b.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((v=this._options)==null?void 0:v.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(y=this._options)==null?void 0:y.fetch,logging:this._options.logging});if(f.ok)return{data:Ppn.parseOrThrow(f.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new In(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 403:throw new nr(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 404:throw new _n(fe.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new Pe({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return ht(f.error,f.rawResponse,"GET","/api/v1/schedules/{schedule_id}/runs")}),a=await o(n).withRawResponse();return new Ud({response:a.data,rawResponse:a.rawResponse,hasNextPage:i=>(i==null?void 0:i.pagination.nextPageToken)!=null&&!(typeof(i==null?void 0:i.pagination.nextPageToken)=="string"&&(i==null?void 0:i.pagination.nextPageToken)===""),getItems:i=>(i==null?void 0:i.data)??[],loadPage:i=>o(Bd(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}}class kfn{constructor(t){this._options=vr(t)}getCapabilities(t){return lt.fromPromise(this.__getCapabilities(t))}async __getCapabilities(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/capabilities"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:jdn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/capabilities")}}class Efn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var A,T,C,R;const{limit:i=25,order:s,pageToken:l,startTimestamp:c,endTimestamp:u,agentId:d,createdByMe:f,metadata:g,sourceType:b,sourceId:v}=a,y={limit:i,order:s!=null?Wpn.jsonOrThrow(s,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0,page_token:l,start_timestamp:c!=null?c==null?void 0:c.toISOString():void 0,end_timestamp:u!=null?u==null?void 0:u.toISOString():void 0,agent_id:d,created_by_me:f,metadata:g,source_type:b!=null?ofn.jsonOrThrow(b,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0,source_id:v},w=await this._options.authProvider.getAuthRequest(),S=dt(w.headers,(A=this._options)==null?void 0:A.headers,n==null?void 0:n.headers),E=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sessions"),method:"GET",headers:S,queryString:ft().addMany(y).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((T=this._options)==null?void 0:T.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((C=this._options)==null?void 0:C.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(R=this._options)==null?void 0:R.fetch,logging:this._options.logging});if(E.ok)return{data:Kpn.parseOrThrow(E.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:E.rawResponse};if(E.error.reason==="status-code")switch(E.error.statusCode){case 400:throw new In(fe.parseOrThrow(E.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),E.rawResponse);default:throw new Pe({statusCode:E.error.statusCode,body:E.error.body,rawResponse:E.rawResponse})}return ht(E.error,E.rawResponse,"GET","/api/v1/sessions")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/sessions"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Pcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:u2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/sessions")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:u2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/sessions/{session_id}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:void 0,rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/sessions/{session_id}")}update(t,n={},r){return lt.fromPromise(this.__update(t,n,r))}async __update(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}`),method:"PATCH",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Ycn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:u2.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"PATCH","/api/v1/sessions/{session_id}")}cancel(t,n={},r){return lt.fromPromise(this.__cancel(t,n,r))}async __cancel(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/cancel`),method:"POST",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Ocn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:$un.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new Av(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/cancel")}async listEvents(t,n={},r){const o=lt.interceptFunction(async i=>{var b,v,y,w;const{pageToken:s,lastTurnId:l,limit:c}=i,u={page_token:s,last_turn_id:l,limit:c},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,r==null?void 0:r.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/events`),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:Vpn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new nr(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _n(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/sessions/{session_id}/events")}),a=await o(n).withRawResponse();return new Ud({response:a.data,rawResponse:a.rawResponse,hasNextPage:i=>(i==null?void 0:i.pagination.nextPageToken)!=null&&!(typeof(i==null?void 0:i.pagination.nextPageToken)=="string"&&(i==null?void 0:i.pagination.nextPageToken)===""),getItems:i=>(i==null?void 0:i.data)??[],loadPage:i=>o(Bd(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}listGrants(t,n){return lt.fromPromise(this.__listGrants(t,n))}async __listGrants(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/grants`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Gwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/sessions/{session_id}/grants")}updateGrants(t,n={},r){return lt.fromPromise(this.__updateGrants(t,n,r))}async __updateGrants(t,n={},r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/grants`),method:"POST",headers:a,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr(Kcn.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:Gwe.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new In(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new Bo(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/grants")}async listTurns(t,n={},r){const o=lt.interceptFunction(async i=>{var b,v,y,w;const{limit:s=25,pageToken:l,assumeUser:c}=i,u={limit:s,page_token:l},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,T$({"assume-user":c}),r==null?void 0:r.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns`),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:Jpn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 403:throw new nr(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);case 404:throw new _n(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/sessions/{session_id}/turns")}),a=await o(n).withRawResponse();return new Ud({response:a.data,rawResponse:a.rawResponse,hasNextPage:i=>(i==null?void 0:i.pagination.nextPageToken)!=null&&!(typeof(i==null?void 0:i.pagination.nextPageToken)=="string"&&(i==null?void 0:i.pagination.nextPageToken)===""),getItems:i=>(i==null?void 0:i.data)??[],loadPage:i=>o(Bd(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}createTurnStream(t,n,r){return lt.fromPromise(this.__createTurnStream(t,n,r))}async __createTurnStream(t,n,r){var c,u,d,f;const{assumeUser:o,...a}=n,i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,T$({"assume-user":o}),r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns`),method:"POST",headers:s,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr({...Gcn.jsonOrThrow(a,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),stream:!0},r==null?void 0:r.additionalBodyParameters),responseType:"sse",timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:new Lwe({stream:l.body,parse:async g=>Wwe.parseOrThrow(g,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:r==null?void 0:r.abortSignal,eventShape:{type:"sse"}}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new In(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new Fn(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new nr(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 412:throw new Av(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 413:throw new l2(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new Bo(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}createTurn(t,n,r){return lt.fromPromise(this.__createTurn(t,n,r))}async __createTurn(t,n,r){var c,u,d,f;const{assumeUser:o,...a}=n,i=await this._options.authProvider.getAuthRequest(),s=dt(i.headers,(c=this._options)==null?void 0:c.headers,T$({"assume-user":o}),r==null?void 0:r.headers),l=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns`),method:"POST",headers:s,contentType:"application/json",queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Cr({...Hcn.jsonOrThrow(a,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),stream:!1},r==null?void 0:r.additionalBodyParameters),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((u=this._options)==null?void 0:u.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(f=this._options)==null?void 0:f.fetch,logging:this._options.logging});if(l.ok)return{data:TB.parseOrThrow(l.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 400:throw new In(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 401:throw new Fn(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 403:throw new nr(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new _n(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 412:throw new Av(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 413:throw new l2(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new Bo(fe.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new Pe({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return ht(l.error,l.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}getTurn(t,n,r){return lt.fromPromise(this.__getTurn(t,n,r))}async __getTurn(t,n,r){var s,l,c,u;const o=await this._options.authProvider.getAuthRequest(),a=dt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}`),method:"GET",headers:a,queryString:ft().mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((l=this._options)==null?void 0:l.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((c=this._options)==null?void 0:c.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(u=this._options)==null?void 0:u.fetch,logging:this._options.logging});if(i.ok)return{data:TB.parseOrThrow(i.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 403:throw new nr(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new _n(fe.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new Pe({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return ht(i.error,i.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}")}downloadSandboxFile(t,n,r,o){return lt.fromPromise(this.__downloadSandboxFile(t,n,r,o))}async __downloadSandboxFile(t,n,r,o){var u,d,f,g;const{path:a}=r,i={path:a},s=await this._options.authProvider.getAuthRequest(),l=dt(s.headers,(u=this._options)==null?void 0:u.headers,o==null?void 0:o.headers),c=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/download-sandbox-file`),method:"GET",headers:l,queryString:ft().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"binary-response",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((f=this._options)==null?void 0:f.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(g=this._options)==null?void 0:g.fetch,logging:this._options.logging});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new In(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new nr(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new _n(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 410:throw new Ksn(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 412:throw new Av(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 413:throw new l2(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 424:throw new Hs(fe.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new Pe({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return ht(c.error,c.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/download-sandbox-file")}async listTurnEvents(t,n,r={},o){const a=lt.interceptFunction(async s=>{var v,y,w,S;const{limit:l,pageToken:c,order:u}=s,d={limit:l,page_token:c,order:u!=null?qpn.jsonOrThrow(u,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0},f=await this._options.authProvider.getAuthRequest(),g=dt(f.headers,(v=this._options)==null?void 0:v.headers,o==null?void 0:o.headers),b=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/events`),method:"GET",headers:g,queryString:ft().addMany(d).mergeAdditional(o==null?void 0:o.queryParams).build(),timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((y=this._options)==null?void 0:y.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((w=this._options)==null?void 0:w.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(S=this._options)==null?void 0:S.fetch,logging:this._options.logging});if(b.ok)return{data:Qpn.parseOrThrow(b.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:b.rawResponse};if(b.error.reason==="status-code")switch(b.error.statusCode){case 400:throw new In(fe.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 403:throw new nr(fe.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 404:throw new _n(fe.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);default:throw new Pe({statusCode:b.error.statusCode,body:b.error.body,rawResponse:b.rawResponse})}return ht(b.error,b.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}),i=await a(r).withRawResponse();return new Ud({response:i.data,rawResponse:i.rawResponse,hasNextPage:s=>(s==null?void 0:s.pagination.nextPageToken)!=null&&!(typeof(s==null?void 0:s.pagination.nextPageToken)=="string"&&(s==null?void 0:s.pagination.nextPageToken)===""),getItems:s=>(s==null?void 0:s.data)??[],loadPage:s=>a(Bd(r,"pageToken",s==null?void 0:s.pagination.nextPageToken))})}createTurnEvents(t,n,r,o){return lt.fromPromise(this.__createTurnEvents(t,n,r,o))}async __createTurnEvents(t,n,r,o){var l,c,u,d;const a=await this._options.authProvider.getAuthRequest(),i=dt(a.headers,(l=this._options)==null?void 0:l.headers,o==null?void 0:o.headers),s=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/events`),method:"POST",headers:i,contentType:"application/json",queryString:ft().mergeAdditional(o==null?void 0:o.queryParams).build(),requestType:"json",body:Cr(Fcn.jsonOrThrow(r,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),o==null?void 0:o.additionalBodyParameters),timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((c=this._options)==null?void 0:c.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((u=this._options)==null?void 0:u.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(s.ok)return{data:Sdn.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 400:throw new In(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new nr(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new _n(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 409:throw new ui(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 422:throw new Bo(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 500:throw new l8e(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new Pe({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return ht(s.error,s.rawResponse,"POST","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}subscribeToTurn(t,n,r={},o){return lt.fromPromise(this.__subscribeToTurn(t,n,r,o))}async __subscribeToTurn(t,n,r={},o){var f,g,b,v;const{afterSequenceNumber:a,fromEventId:i,afterEventId:s}=r,l={after_sequence_number:a,from_event_id:i,after_event_id:s},c=await this._options.authProvider.getAuthRequest(),u=dt(c.headers,(f=this._options)==null?void 0:f.headers,o==null?void 0:o.headers),d=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/sessions/${Pn(t,Pe)}/turns/${Pn(n,Pe)}/subscribe`),method:"GET",headers:u,queryString:ft().addMany(l).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"sse",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((g=this._options)==null?void 0:g.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((b=this._options)==null?void 0:b.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(v=this._options)==null?void 0:v.fetch,logging:this._options.logging});if(d.ok)return{data:new Lwe({stream:d.body,parse:async y=>Wwe.parseOrThrow(y,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:o==null?void 0:o.abortSignal,eventShape:{type:"sse"}}),rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new In(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 403:throw new nr(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 404:throw new _n(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);case 412:throw new Av(fe.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new Pe({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return ht(d.error,d.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/subscribe")}}class Tfn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/configuration"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:$we.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/configuration")}update(t,n){return lt.fromPromise(this.__update(t,n))}async __update(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/configuration"),method:"PATCH",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(Xcn.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:$we.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Fn(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new nr(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PATCH","/api/v1/settings/configuration")}}class Afn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Epn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/mcp-servers")}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(tun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/settings/mcp-servers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(nun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/mcp-servers")}get(t,n){return lt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/mcp-servers/${Pn(t,Pe)}`),method:"GET",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:c2.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"GET","/api/v1/settings/mcp-servers/{name}")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/mcp-servers/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Edn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/settings/mcp-servers/{name}")}}class Cfn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/memory-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Uwe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 404:throw new _n(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/memory-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/memory-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(oun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Uwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/memory-providers")}}class Rfn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/model-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Apn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/model-providers")}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/model-providers"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(gun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Fwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/settings/model-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/model-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(mun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Fwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/model-providers")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/model-providers/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Tdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/settings/model-providers/{name}")}}class Ifn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Bwe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 404:throw new _n(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/sandbox-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(vun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Bwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new Bo(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/sandbox-providers")}}let Nfn=class{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/skills"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Ypn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/skills")}create(t,n){return lt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/skills"),method:"POST",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(wun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Hwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"POST","/api/v1/settings/skills")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/skills"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(_un.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Hwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/skills")}delete(t,n){return lt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),`api/v1/settings/skills/${Pn(t,Pe)}`),method:"DELETE",headers:o,queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Rdn.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 404:throw new _n(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ui(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"DELETE","/api/v1/settings/skills/{name}")}};class Mfn{constructor(t){this._options=vr(t)}get(t){return lt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:Vwe.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new nr(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 404:throw new _n(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/settings/web-search-providers")}createOrUpdate(t,n){return lt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=dt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ft().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Cr(kun.jsonOrThrow(t,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),n==null?void 0:n.additionalBodyParameters),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((s=this._options)==null?void 0:s.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((l=this._options)==null?void 0:l.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(c=this._options)==null?void 0:c.fetch,logging:this._options.logging});if(a.ok)return{data:Vwe.parseOrThrow(a.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:a.rawResponse};if(a.error.reason==="status-code")switch(a.error.statusCode){case 400:throw new In(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(fe.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new Pe({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return ht(a.error,a.rawResponse,"PUT","/api/v1/settings/web-search-providers")}}class Ofn{constructor(t){this._options=vr(t)}get configuration(){return this._configuration??(this._configuration=new Tfn(this._options))}get mcpServers(){return this._mcpServers??(this._mcpServers=new Afn(this._options))}get memoryProviders(){return this._memoryProviders??(this._memoryProviders=new Cfn(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new Rfn(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new Ifn(this._options))}get skills(){return this._skills??(this._skills=new Nfn(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new Mfn(this._options))}}class Pfn{constructor(t){this._options=vr(t)}list(t){return lt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=dt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/skills"),method:"GET",headers:r,queryString:ft().mergeAdditional(t==null?void 0:t.queryParams).build(),timeoutMs:((t==null?void 0:t.timeoutInSeconds)??((i=this._options)==null?void 0:i.timeoutInSeconds)??60)*1e3,maxRetries:(t==null?void 0:t.maxRetries)??((s=this._options)==null?void 0:s.maxRetries),abortSignal:t==null?void 0:t.abortSignal,fetchFn:(l=this._options)==null?void 0:l.fetch,logging:this._options.logging});if(o.ok)return{data:kpn.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new Pe({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return ht(o.error,o.rawResponse,"GET","/api/v1/skills")}listVersions(t,n){return lt.fromPromise(this.__listVersions(t,n))}async __listVersions(t,n){var l,c,u,d;const{name:r}=t,o={name:r},a=await this._options.authProvider.getAuthRequest(),i=dt(a.headers,(l=this._options)==null?void 0:l.headers,n==null?void 0:n.headers),s=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/skills/versions"),method:"GET",headers:i,queryString:ft().addMany(o).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((c=this._options)==null?void 0:c.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((u=this._options)==null?void 0:u.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(s.ok)return{data:Xpn.parseOrThrow(s.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 401:throw new Fn(fe.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new Pe({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return ht(s.error,s.rawResponse,"GET","/api/v1/skills/versions")}}class jfn{constructor(t){this._options=vr(t)}async list(t={},n){const r=lt.interceptFunction(async a=>{var b,v,y,w;const{query:i,limit:s=25,pageToken:l,ids:c}=a,u={query:i,limit:s,page_token:l,ids:c},d=await this._options.authProvider.getAuthRequest(),f=dt(d.headers,(b=this._options)==null?void 0:b.headers,n==null?void 0:n.headers),g=await(this._options.fetcher??pt)({url:ut(await Ee.get(this._options.baseUrl)??await Ee.get(this._options.environment),"api/v1/users"),method:"GET",headers:f,queryString:ft().addMany(u).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((v=this._options)==null?void 0:v.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(w=this._options)==null?void 0:w.fetch,logging:this._options.logging});if(g.ok)return{data:tfn.parseOrThrow(g.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:g.rawResponse};if(g.error.reason==="status-code")switch(g.error.statusCode){case 400:throw new In(fe.parseOrThrow(g.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),g.rawResponse);default:throw new Pe({statusCode:g.error.statusCode,body:g.error.body,rawResponse:g.rawResponse})}return ht(g.error,g.rawResponse,"GET","/api/v1/users")}),o=await r(t).withRawResponse();return new Ud({response:o.data,rawResponse:o.rawResponse,hasNextPage:a=>(a==null?void 0:a.pagination.nextPageToken)!=null&&!(typeof(a==null?void 0:a.pagination.nextPageToken)=="string"&&(a==null?void 0:a.pagination.nextPageToken)===""),getItems:a=>(a==null?void 0:a.data)??[],loadPage:a=>r(Bd(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}}class Ree{constructor(t){this._options=vr(t)}get internal(){return this._internal??(this._internal=new yfn(this._options))}get agents(){return this._agents??(this._agents=new afn(this._options))}get auth(){return this._auth??(this._auth=new ifn(this._options))}get server(){return this._server??(this._server=new kfn(this._options))}get mcpServers(){return this._mcpServers??(this._mcpServers=new xfn(this._options))}get models(){return this._models??(this._models=new wfn(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new _fn(this._options))}get schedules(){return this._schedules??(this._schedules=new Sfn(this._options))}get sessions(){return this._sessions??(this._sessions=new Efn(this._options))}get skills(){return this._skills??(this._skills=new Pfn(this._options))}get users(){return this._users??(this._users=new jfn(this._options))}get catalogs(){return this._catalogs??(this._catalogs=new ffn(this._options))}get settings(){return this._settings??(this._settings=new Ofn(this._options))}async fetch(t,n,r){return bln(t,n,{baseUrl:this._options.baseUrl??this._options.environment,headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:async()=>(await this._options.authProvider.getAuthRequest()).headers},r)}}var fN="daytona",Dfn="Daytona";function S$e(e){return e===fN?Dfn:e}function Lfn(e){return"execTimeoutMs"in e&&typeof e.execTimeoutMs=="number"&&"autoStopIntervalInMinutes"in e&&typeof e.autoStopIntervalInMinutes=="number"&&"autoArchiveIntervalInMinutes"in e&&typeof e.autoArchiveIntervalInMinutes=="number"&&"autoDeleteIntervalInMinutes"in e&&typeof e.autoDeleteIntervalInMinutes=="number"}function Iee(e){return{execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes}}function k$e(e){return{id:e.type,name:S$e(e.type),type:e.type,...Iee(e)}}function d2(e){return{id:e.type,name:S$e(e.type),catalogId:e.type,isConnected:!0,...Iee(e)}}function E$e({providers:e,query:t}){const n=t==null?void 0:t.trim().toLowerCase();return n===void 0||n===""?e:e.filter(r=>r.name.toLowerCase().includes(n)||r.id.toLowerCase().includes(n))}function AB(e){if(e.type!==fN)throw new Error(`Unsupported sandbox provider type: ${e.type}`);return{type:fN,execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes,auth:{apiKey:e.apiKey}}}function T$e(e){async function t(n){const r=n==null?void 0:n.trim();return r!==void 0&&r!==""?r:(await e.settings.sandboxProviders.get()).data.manifest.auth.apiKey}return{getSandboxProviderCatalog:async()=>(await e.catalogs.sandboxProviders.list()).data.map(k$e),listSandboxProviders:async n=>{let r;try{const o=await e.settings.sandboxProviders.get();r=[d2(o.data.manifest)]}catch(o){if(o instanceof _n)r=[];else throw o}return E$e({providers:r,query:n==null?void 0:n.query})},createSandboxProvider:async n=>{const r=await e.settings.sandboxProviders.createOrUpdate({manifest:AB({type:n.type,apiKey:n.apiKey,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return d2(r.data.manifest)},updateSandboxProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.sandboxProviders.createOrUpdate({manifest:AB({type:fN,apiKey:r,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return d2(o.data.manifest)}}}var zfn="/";function A$e(e){var n;if(/^https?:\/\//i.test(e))return e;const t=(n=globalThis.location)==null?void 0:n.origin;return typeof t=="string"&&t.length>0&&t!=="null"?new URL(e,t).href:e}function Ap(e={}){const t=VXe(e.fetch??globalThis.fetch.bind(globalThis));return new Ree({baseUrl:A$e(e.baseUrl??zfn),fetch:t,...e.token===void 0?{}:{token:e.token}})}function Bv(e){const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid ISO timestamp: ${e}`);return t}function $fn(e){if(e==="sessions_over_time"||e==="sessions_cost_over_time"||e==="turns_over_time")return e;throw new Error(`Unsupported Harness metrics chart: ${e}`)}function C$e(e={}){const t=e.client??Ap(e);return{async getCharts(){const{data:n}=await t.internal.metrics.listCharts();return n.charts},async getMeters({agentId:n,startTimestamp:r,endTimestamp:o}){const{data:a}=await t.internal.metrics.getMeters({agentId:n,startTimestamp:Bv(r),endTimestamp:Bv(o)});return a.meters},async getChartData({agentId:n,startTimestamp:r,endTimestamp:o,chartName:a}){const{data:i}=await t.internal.metrics.getChartData({agentId:n,startTimestamp:Bv(r),endTimestamp:Bv(o),chartName:$fn(a)});return i}}}function I$(e){return{totalInputTokens:e.totalInputTokens??0,totalOutputTokens:e.totalOutputTokens??0,totalTokens:e.totalTokens??0,totalCacheReadTokens:e.totalCacheReadTokens??0,totalCacheWriteTokens:e.totalCacheWriteTokens??0,totalReasoningTokens:e.totalReasoningTokens??0,...e.totalCostInUsd==null?{}:{totalCostInUsd:e.totalCostInUsd}}}function Ufn(e){return e.status==="running"?{status:"running"}:e.status==="paused"?{status:"paused"}:Nee(e)}function R$e(e){return e.status==="running"?{status:"running"}:{status:"paused"}}function Nee(e){switch(e.status){case"cancelled":return{status:"cancelled",reason:e.reason,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:I$(e.metrics)}};case"error":return{status:"error",message:e.message,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:I$(e.metrics)}};case"done":return{status:"done",completedAt:e.completedAt,requiredActions:e.requiredActions,...e.output==null?{}:{output:e.output},...e.metrics==null?{}:{metrics:I$(e.metrics)}}}}function Ffn(e){return e.type==="turn.update"?{...e,state:R$e(e.state)}:e.type!=="turn.done"?{...e}:{...e,state:Nee(e.state)}}function Kwe(e){return e.type==="turn.update"?{...e,state:R$e(e.state)}:e.type!=="turn.done"?{...e}:{...e,state:Nee(e.state)}}function I$e(e){const t=Ffn(e.event);return t===void 0?void 0:{turnId:e.turnId,event:t}}function Bfn(e){return{...e}}function Hfn(e){return e}function Vfn(e){return{name:e.name,preload:e.preload===!0}}function Gfn(e){return{name:e.id??e.name,preload:e.preload===!0}}function hN(e){const{skills:t,mcpServers:n,...r}=e;return{...r,...n===void 0?{}:{mcpServers:n.map(o=>{if("id"in o){const{id:a,...i}=o;return i}return o})},...t===void 0?{}:{skills:t.map(Gfn)}}}function uE(e){const{mcpServers:t,skills:n,...r}=e;return{...r,...t&&t.length>0?{mcpServers:t.map(Hfn)}:{},...n?{skills:n.map(Vfn)}:{}}}function Qw(e){return{id:e.id,isMutable:e.agent.type==="inline",isCreateAgent:PH(e.metadata),createdBy:{id:e.createdBySubject.subjectId,displayName:e.createdBySubject.subjectDisplayName},createdAt:e.createdAt,updatedAt:e.updatedAt,lastTurnDetails:e.lastTurnDetails??null,metrics:{totalTurns:e.metrics.totalTurns,totalDurationMs:e.metrics.totalDurationMs,...e.metrics.totalCostInUsd==null?{}:{totalCostInUsd:e.metrics.totalCostInUsd}},...e.title===null?{}:{title:e.title},...e.agent.type==="reference"&&e.agent.name!==null?{agentName:e.agent.name}:{},...e.agent.type==="inline"?{agentSpec:uE(e.agent.spec)}:{},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function Wfn(e){if(e.metadata!==void 0)return e.metadata}function Kfn(e){return typeof e=="string"?e:e.map(t=>({...t}))}function Yfn(e){return e.map(t=>t.type==="user.message"?{...t,content:Kfn(t.content)}:t)}function Ywe(e){const{previousTurnId:t,input:n,state:r,...o}=e;return{...o,state:Ufn(r),...t===null?{}:{previousTurnId:t},...n===void 0?{}:{input:Yfn(n)}}}function qd(e,t){const n=[];for(const a of e.data){const i=t(a);i!==void 0&&n.push(i)}const r=e.response.pagination.nextPageToken,o=e.response.pagination.previousPageToken;return{data:n,...r===void 0?{}:{nextPageToken:r},...o===void 0?{}:{previousPageToken:o}}}function Zwe(e){if(e===void 0)return;const t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:void 0}function Zfn(e){return typeof e=="string"?e:e.map(t=>{if(t.type==="text")return t;const{name:n,data:r}=t;if(typeof n!="string"||typeof r!="string")throw new Error("File attachment must carry a string `name` and a data-URI `data`");return{type:"file",name:n,data:r}})}function Xfn(e){return e.map(t=>({...t,content:Zfn(t.content)}))}function qfn(e){return e.map(t=>({...t}))}function N$e(e={}){const t=e.client??Ap(e);return{async downloadSandboxFile({sessionId:n,turnId:r,path:o}){return(await t.sessions.downloadSandboxFile(n,r,{path:o})).blob()},async createSession(n){const r=Wfn(n);if(n.agentName!==void 0&&n.agentName.length>0){const o=await t.sessions.create({agent:{name:n.agentName},...r===void 0?{}:{metadata:r}});return Qw(o.data)}if(n.agentSpec!==void 0){const o=await t.sessions.create({agent:{spec:hN(n.agentSpec)},...r===void 0?{}:{metadata:r}});return Qw(o.data)}throw new Error("createSession requires agentName or agentSpec")},async listSessions(n={}){const r=await t.sessions.list({...n.limit===void 0?{}:{limit:n.limit},...n.order===void 0?{}:{order:n.order},...n.pageToken===void 0?{}:{pageToken:n.pageToken},...n.agentId===void 0||n.agentId.length===0?{}:{agentId:n.agentId},...n.createdByMe===void 0?{}:{createdByMe:n.createdByMe},...n.metadata===void 0?{}:{metadata:n.metadata}});return qd(r,Qw)},async getSession({sessionId:n}){const r=await t.sessions.get(n);return Qw(r.data)},async deleteSession({sessionId:n}){await t.sessions.delete(n)},async renameSession({sessionId:n,title:r}){await t.sessions.update(n,{title:r})},async updateSession({sessionId:n,agentSpec:r,title:o}){const a={...r===void 0?{}:{agent:{spec:hN(r)}},...o===void 0?{}:{title:o}},i=await t.sessions.update(n,a);return Qw(i.data)},async*createTurn({sessionId:n,input:r,previousTurnId:o,headers:a}){const i=await t.sessions.createTurnStream(n,{input:Xfn(r),...o===void 0?{}:{previousTurnId:o}},a===void 0?void 0:{headers:a});for await(const s of i.withMetadata()){const l=Kwe(s.data);if(l===void 0)continue;const c=Zwe(s.id);yield c===void 0?{event:l}:{sequenceNumber:c,event:l}}},async sendTurnEvents({sessionId:n,turnId:r,events:o}){return(await t.sessions.createTurnEvents(n,r,{events:qfn(o)})).data.map(Bfn)},async*subscribeToTurn({sessionId:n,turnId:r,afterSequenceNumber:o,fromEventId:a,afterEventId:i}){const s=await t.sessions.subscribeToTurn(n,r,{...o===void 0?{}:{afterSequenceNumber:o},...a===void 0?{}:{fromEventId:a},...i===void 0?{}:{afterEventId:i}});for await(const l of s.withMetadata()){const c=Kwe(l.data);if(c===void 0)continue;const u=Zwe(l.id);yield u===void 0?{event:c}:{sequenceNumber:u,event:c}}},async cancelSession({sessionId:n}){await t.sessions.cancel(n)},async listTurns({sessionId:n,limit:r,pageToken:o}){const a=await t.sessions.listTurns(n,{...r===void 0?{}:{limit:r},...o===void 0?{}:{pageToken:o}});return qd(a,Ywe)},async getTurn({sessionId:n,turnId:r}){const o=await t.sessions.getTurn(n,r);return Ywe(o.data)},async listEvents({sessionId:n,pageToken:r,lastTurnId:o}){const a=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r},...o===void 0?{}:{lastTurnId:o}});return qd(a,I$e)}}}function Qfn(e){var t;return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,lastActivityAt:e.updatedAt,isCreateAgent:PH(e.metadata),isMutable:e.agent.type==="inline",lastTurnDetails:e.lastTurnDetails??null,metrics:{totalTurns:e.metrics.totalTurns,...e.metrics.totalCostInUsd==null?{}:{totalCostInUsd:e.metrics.totalCostInUsd},totalDurationMs:e.metrics.totalDurationMs},...e.title===null?{}:{title:e.title},...e.agent.type==="reference"&&e.agent.name!==null?{agentName:e.agent.name}:{},...e.agent.type==="inline"?{agentSpec:uE(e.agent.spec)}:{},...((t=e.source)==null?void 0:t.type)==="schedule"?{scheduleId:e.source.id}:{},...e.createdBySubject==null?{}:{createdBySubject:e.createdBySubject},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function M$e(e={}){const t=e.client??Ap(e);return{async getAgent({agentId:n}){const{data:r}=await t.agents.get(n);return{agentId:r.id,name:r.name,description:r.description,agentSpec:uE(r.manifest)}},async getCodeSnippets({agentId:n}){const r=A$e(e.baseUrl??"/").replace(/\/$/,""),{data:o}=await t.internal.agents.getCodeSnippets(n,/^https?:\/\//i.test(r)?{baseUrl:r}:void 0);return o.snippets},async listSessions(n={}){const r=await t.sessions.list({...n.limit===void 0?{}:{limit:n.limit},...n.order===void 0?{}:{order:n.order},...n.pageToken===void 0?{}:{pageToken:n.pageToken},...n.startTimestamp===void 0?{}:{startTimestamp:Bv(n.startTimestamp)},...n.endTimestamp===void 0?{}:{endTimestamp:Bv(n.endTimestamp)},...n.agentId===void 0||n.agentId.length===0?{}:{agentId:n.agentId},...n.createdByMe===void 0?{}:{createdByMe:n.createdByMe}});return qd(r,Qfn)},async listSessionEvents({sessionId:n,pageToken:r}){const o=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r}});return qd(o,I$e)}}}var O$e=50,Jfn=100;function P$e(e){return Math.min(Math.max(e,1),Jfn)}async function j$e({client:e,limit:t,pageToken:n,agentName:r}){const o=P$e(t),a=await e.agents.list({limit:o,...n===void 0||n===""?{}:{pageToken:n},...r===void 0?{}:{agentName:r}});return qd(a,i=>i)}async function CB(e){const t=[];let n;for(;;){const r=await j$e({client:e,limit:O$e,...n===void 0?{}:{pageToken:n}});if(t.push(...r.data),r.nextPageToken==null||r.nextPageToken==="")break;n=r.nextPageToken}return t}var Mee="Authorization";function ehn({headerName:e,value:t}){return e.toLowerCase()!==Mee.toLowerCase()||/^bearer\s+/i.test(t)?t:`Bearer ${t}`}function D$e(e){if(e===void 0)return{type:"none"};if(e.type==="dcr")return{type:"dcr"};const t=Object.keys(e.headers)[0];return{type:"header",...t===void 0?{}:{headerName:t}}}function L$e(e){var o,a;if(e.type==="none")return;if(e.type==="dcr")return{type:"dcr"};const t=(o=e.apiKey)==null?void 0:o.trim();if(t===void 0||t==="")throw new Error("API key is required for header-authenticated MCP servers");const n=(a=e.headerName)==null?void 0:a.trim(),r=n!==void 0&&n!==""?n:Mee;return{type:"header",headers:{[r]:ehn({headerName:r,value:t})}}}function thn(e){return{id:e.name,name:e.name,url:e.url,description:e.description,...e.logo===void 0?{}:{logo:e.logo},auth:D$e(e.auth)}}function nhn(e){if(typeof e!="object"||e===null)return;const t=Reflect.get(e,"readOnlyHint"),n=Reflect.get(e,"destructiveHint"),r={...typeof t=="boolean"?{readOnlyHint:t}:{},...typeof n=="boolean"?{destructiveHint:n}:{}};return Object.keys(r).length>0?r:void 0}function z$e(e){const t=typeof e.name=="string"&&e.name!==""?e.name:"tool",n=typeof e.description=="string"?e.description:"",r=nhn(Reflect.get(e,"annotations"));return r===void 0?{id:t,name:t,description:n}:{id:t,name:t,description:n,annotations:r}}function Cv(e){const t=D$e(e.manifest.auth);return{id:e.name,name:e.name,description:e.manifest.description,url:e.manifest.url,auth:t,requiresAuth:e.authStatus.status==="auth_required",authenticated:e.authStatus.status!=="auth_required"}}function RB(e){var n;const t=(n=e.auth)!=null&&n.type?{type:e.auth.type}:{type:"none"};return{id:e.name,name:e.name,description:e.url,url:e.url,auth:t,requiresAuth:e.authStatus.status==="auth_required",authenticated:e.authStatus.status!=="auth_required"}}function IB(e){var r;const t=L$e(e.auth),n=(r=e.description)==null?void 0:r.trim();return{type:"remote",name:e.name,url:e.url,description:n!==void 0&&n!==""?n:`${e.name} MCP server`,...t===void 0?{}:{auth:t}}}function $$e(e){async function t(r){const a=(await e.settings.mcpServers.list()).data.find(i=>i.name===r);if(a===void 0)throw new Error(`MCP server "${r}" not found`);return a}async function n(r){var u,d,f;if(r.auth.type!=="header")return r.auth;const o=(u=r.auth.apiKey)==null?void 0:u.trim();if(o!==void 0&&o!=="")return r.auth;if(r.id===void 0)throw new Error("API key is required for header-authenticated MCP servers");const a=await t(r.id);if(((d=a.manifest.auth)==null?void 0:d.type)!=="header")throw new Error(`MCP server "${r.id}" has no stored header credentials to reuse`);const i=(f=r.auth.headerName)==null?void 0:f.trim(),s=Object.keys(a.manifest.auth.headers)[0],l=i!==void 0&&i!==""?i:s??Mee,c=a.manifest.auth.headers[l]??Object.values(a.manifest.auth.headers)[0];if(c===void 0)throw new Error(`MCP server "${r.id}" has no stored header credentials to reuse`);return{type:"header",apiKey:c,headerName:l}}return{getConnectorCatalog:async()=>(await e.catalogs.mcpServers.list()).data.map(thn),getConnector:async r=>{const o=await e.settings.mcpServers.get(r.id);return Cv(o.data)},listConnectors:async r=>{var s;const a=(await e.settings.mcpServers.list()).data.map(Cv),i=(s=r==null?void 0:r.query)==null?void 0:s.trim().toLowerCase();return i===void 0||i===""?a:a.filter(l=>l.name.toLowerCase().includes(i)||l.description.toLowerCase().includes(i)||l.url.toLowerCase().includes(i))},getToolsByConnectorId:async({id:r})=>(await e.mcpServers.listTools(r)).data.map(z$e),createConnector:async r=>{const o=await n({auth:r.auth}),a=await e.settings.mcpServers.create({manifest:IB({name:r.name,url:r.url,auth:o,description:r.description})});return Cv(a.data)},updateConnector:async r=>{const o=await n({id:r.id,auth:r.auth}),a=await e.settings.mcpServers.createOrUpdate({manifest:IB({name:r.id,url:r.url,auth:o,description:r.description})});return Cv(a.data)},authenticateConnector:async r=>{const o=await e.mcpServers.authorize(r.id,r.returnTo===void 0?{}:{returnTo:r.returnTo});return{status:o.status,authorization_endpoint:o.authorizationUrl}},disconnectConnector:async r=>{var i;if(((i=(await t(r.id)).manifest.auth)==null?void 0:i.type)!=="dcr")throw new Error("Disconnect is only supported for OAuth MCP servers");const a=await e.mcpServers.deleteAuthorization(r.id);return Cv(a.data)},deleteConnector:async({id:r})=>{await e.settings.mcpServers.delete(r)}}}async function U$e(e){return(await e.models.list()).data}async function F$e(e){return(await e.mcpServers.list()).data}async function B$e(e){return(await e.skills.list()).data}async function H$e(e){return(await e.server.getCapabilities()).data}function V$e(e){const t=new Map;for(const n of e)n.type==="custom"||n.logo===void 0||t.set(n.type,n.logo);return t}function G$e({model:e,logo:t}){const{contextLength:n,maxOutputTokens:r,reasoningEfforts:o}=e.properties;return{id:e.modelId,name:e.name,provider:{name:e.provider.name,...t===void 0?{}:{logo:t}},properties:{...n===void 0?{}:{contextLength:n},...r===void 0?{}:{maxOutputTokens:r},...o===void 0?{}:{reasoningEfforts:[...o]}},...e.warning===void 0?{}:{warning:e.warning}}}function rhn(e){return{name:e.name,agentId:e.id,description:e.description,agentSpec:uE(e.manifest),createdBySubject:e.createdBySubject}}function W$e(e={}){const t=e.client??Ap(e);return{getCapabilities:()=>t.server.getCapabilities(),getModels:async()=>{const[n,r]=await Promise.all([t.models.list(),t.catalogs.modelProviders.list().then(a=>a.data,()=>[])]),o=V$e(r);return n.data.map(a=>{const i=o.get(a.provider.name);return G$e(i===void 0?{model:a}:{model:a,logo:i})})},getSkills:async()=>(await B$e(t)).map(r=>{const{display_name:o,repository_name:a,version:i}=r.metadata??{},s=Number(i),l=Number.isInteger(s)&&s>0;return{id:r.name,name:o??r.name,description:r.description,...a===void 0?{}:{skillRepoName:a},...l?{version:s,loadVersions:async()=>(await t.skills.listVersions({name:r.name})).data}:{}}}),getMcp:async()=>(await F$e(t)).map(RB),getMcpConnector:async({connectorId:n})=>{const r=await t.mcpServers.get(n);return RB(r.data)},getMcpTools:async({connectorId:n})=>(await t.mcpServers.listTools(n)).data.flatMap(o=>typeof o.name=="string"&&o.name.trim()!==""?[z$e(o)]:[]),async searchAgents(n){var i;const r=P$e((n==null?void 0:n.limit)??O$e),o=(i=n==null?void 0:n.query)==null?void 0:i.trim(),a=await j$e({client:t,limit:r,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken},...o===void 0||o===""?{}:{agentName:o}});return{data:a.data.map(rhn),...a.nextPageToken===void 0?{}:{nextPageToken:a.nextPageToken},...a.previousPageToken===void 0?{}:{previousPageToken:a.previousPageToken}}},async saveAgent({agentName:n,description:r,agentSpec:o,intent:a}){const i=hN(o),s=r==null?void 0:r.trim();if(a==="update"){const u=(await CB(t)).find(d=>d.name===n);return u?(await t.agents.update(u.id,{...s?{description:s}:{},manifest:i}),{agentId:u.id}):{}}return{agentId:(await t.agents.create({name:n,description:s||n,manifest:i})).data.id}},async deleteAgent({agentName:n}){const o=(await CB(t)).find(a=>a.name===n);o&&await t.agents.delete(o.id)}}}var gN="zep",ohn="Zep";function K$e(e){return e===gN?ohn:e}function Y$e(e){return{id:e.type,name:K$e(e.type),type:e.type}}function p2(e){return{id:e.type,name:K$e(e.type),catalogId:e.type,isConnected:!0,...e.serverUrl===void 0?{}:{serverUrl:e.serverUrl}}}function NB({type:e,apiKey:t,serverUrl:n}){if(e!==gN)throw new Error(`Unsupported memory provider type: ${e}`);const r=n==null?void 0:n.trim();return{type:gN,...r===void 0||r===""?{}:{serverUrl:r},auth:{apiKey:t}}}function Z$e(e){async function t(n){const r=n==null?void 0:n.trim();return r!==void 0&&r!==""?r:(await e.settings.memoryProviders.get()).data.manifest.auth.apiKey}return{getMemoryProviderCatalog:async()=>(await e.catalogs.memoryProviders.list()).data.map(Y$e),listMemoryProviders:async()=>{try{const n=await e.settings.memoryProviders.get();return[p2(n.data.manifest)]}catch(n){if(n instanceof _n)return[];throw n}},createMemoryProvider:async n=>{const r=await e.settings.memoryProviders.createOrUpdate({manifest:NB({type:n.type,apiKey:n.apiKey,serverUrl:n.serverUrl})});return p2(r.data.manifest)},updateMemoryProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.memoryProviders.createOrUpdate({manifest:NB({type:gN,apiKey:r,serverUrl:n.serverUrl})});return p2(o.data.manifest)}}}function X$e(e){return{id:e.modelId,name:e.name,properties:e.properties}}function ahn(e){return{modelId:e.id,name:e.name,properties:e.properties??{}}}function f2(e){const{name:t,manifest:n}=e;return{id:t,type:n.type,name:t,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models.map(X$e)}}function q$e(e){return e.type==="custom"?{type:e.type,name:e.type,supportedReasoningEfforts:e.supportedReasoningEfforts,models:[]}:{type:e.type,name:e.type,...e.logo===void 0?{}:{logo:e.logo},models:e.models.map(X$e)}}var ihn=[...Object.values(Ysn),"custom"];function shn(e){return ihn.includes(e)}function MB(e){var o;const t=e.models.map(ahn);if(!shn(e.type))throw new Error(`Unsupported model provider type: ${e.type}`);const n=((o=e.baseUrl)==null?void 0:o.trim())===""?void 0:e.baseUrl;if(e.type==="custom"){if(n===void 0)throw new Error(`Model providers of type "${e.type}" require a base URL`);return{type:e.type,name:e.name,models:t,baseUrl:n,...e.apiKey===""?{}:{auth:{apiKey:e.apiKey}}}}const r={apiKey:e.apiKey};return n!==void 0?{type:e.type,auth:r,models:t,baseUrl:n}:{type:e.type,auth:r,models:t}}function Q$e(e){async function t(n){var i;const r=n.apiKey.trim();if(r!=="")return r;if(n.id===void 0){if(n.type==="custom")return"";throw new Error("API key is required")}const a=(await e.settings.modelProviders.list()).data.find(s=>s.name===n.id);if(a===void 0)throw new Error(`Model provider "${n.id}" not found`);return((i=a.manifest.auth)==null?void 0:i.apiKey)??""}return{getModelProviderCatalog:async()=>(await e.catalogs.modelProviders.list()).data.map(q$e),listModelProviders:async()=>(await e.settings.modelProviders.list()).data.map(f2),createModelProvider:async n=>{const r=await t({type:n.type,apiKey:n.apiKey}),o=await e.settings.modelProviders.create({manifest:MB({type:n.type,name:n.name,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return f2(o.data)},updateModelProvider:async n=>{const r=await t({id:n.id,type:n.type,apiKey:n.apiKey}),o=await e.settings.modelProviders.createOrUpdate({manifest:MB({type:n.type,name:n.id,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return f2(o.data)},deleteModelProvider:async({id:n})=>{await e.settings.modelProviders.delete(n)}}}function lhn(e){return{id:e.name,name:e.name,description:e.description,repoURL:e.url,path:e.path??"",ref:e.ref}}function J$e(e){const t=e.path.trim();return{type:"git",name:e.name,url:e.repoURL,...t===""?{}:{path:t},ref:e.ref,description:e.description}}function e9e(e,t){const n=e.manifest,r="displayName"in n&&typeof n.displayName=="string"?n.displayName:n.name,o={id:e.name,name:r,description:n.description};return t.has(e.name)?{...o,catalogId:e.name}:o}function t9e(e){return{getSkillCatalog:async()=>(await e.catalogs.skills.list()).data.map(lhn),listSkills:async t=>{var s;const[n,r]=await Promise.all([e.settings.skills.list(),e.catalogs.skills.list()]),o=new Set(r.data.map(l=>l.name)),a=n.data.map(l=>e9e(l,o)),i=(s=t==null?void 0:t.query)==null?void 0:s.trim().toLowerCase();return i===void 0||i===""?a:a.filter(l=>l.name.toLowerCase().includes(i)||l.description.toLowerCase().includes(i))},createSkill:async t=>{const n=await e.settings.skills.create({manifest:J$e(t)}),r="catalogId"in t?t.catalogId:void 0;return r!==void 0?{id:n.data.name,name:n.data.name,description:n.data.manifest.description,catalogId:r}:{id:n.data.name,name:n.data.name,description:n.data.manifest.description}},deleteSkill:async({id:t})=>{await e.settings.skills.delete(t)}}}var mN="parallel",chn="Parallel";function n9e(e){return e===mN?chn:e}function r9e(e){return{id:e.type,name:n9e(e.type),type:e.type}}function h2(e){return{id:e.type,name:n9e(e.type),catalogId:e.type,isConnected:!0}}function o9e({providers:e,query:t}){const n=t==null?void 0:t.trim().toLowerCase();return n===void 0||n===""?e:e.filter(r=>r.name.toLowerCase().includes(n)||r.id.toLowerCase().includes(n))}function OB({type:e,apiKey:t}){if(e!==mN)throw new Error(`Unsupported web-search provider type: ${e}`);return{type:mN,auth:{apiKey:t}}}function a9e(e){async function t(n){const r=n==null?void 0:n.trim();return r!==void 0&&r!==""?r:(await e.settings.webSearchProviders.get()).data.manifest.auth.apiKey}return{getWebSearchProviderCatalog:async()=>(await e.catalogs.webSearchProviders.list()).data.map(r9e),listWebSearchProviders:async n=>{let r;try{const o=await e.settings.webSearchProviders.get();r=[h2(o.data.manifest)]}catch(o){if(o instanceof _n)r=[];else throw o}return o9e({providers:r,query:n==null?void 0:n.query})},createWebSearchProvider:async n=>{const r=await e.settings.webSearchProviders.createOrUpdate({manifest:OB({type:n.type,apiKey:n.apiKey})});return h2(r.data.manifest)},updateWebSearchProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.webSearchProviders.createOrUpdate({manifest:OB({type:mN,apiKey:r})});return h2(o.data.manifest)}}}function Xwe(e){return{webSearch:{enabled:e.webSearch.enabled},memory:{enabled:e.memory.enabled}}}function i9e(e){return{getConfiguration:async()=>{const t=await e.settings.configuration.get();return Xwe(t.data.manifest)},updateConfiguration:async t=>{const n=await e.settings.configuration.update({manifest:{...t.webSearch===void 0?{}:{webSearch:{enabled:t.webSearch.enabled}},...t.memory===void 0?{}:{memory:{enabled:t.memory.enabled}}}});return Xwe(n.data.manifest)}}}function s9e(e={}){const t=e.client??Ap(e);return{listPermissions:async n=>t.internal.listPermissions(n)}}var uhn=25,dhn=1e3;function qwe(e){return e instanceof Date?e.toISOString():e}function phn(e){return{name:e.name,...e.description===void 0?{}:{description:e.description},...e.image===void 0?{}:{image:{type:"build",...e.image.buildScript===void 0?{}:{buildScript:e.image.buildScript}}},...e.resources===void 0?{}:{resources:{cpu:e.resources.cpu??1,memory:e.resources.memory??1,disk:e.resources.disk??3}},...e.environmentVariables===void 0?{}:{environmentVariables:e.environmentVariables},...e.networking===void 0?{}:{networking:{...e.networking.networkBlockAll===void 0?{}:{networkBlockAll:e.networking.networkBlockAll},...e.networking.domainAllowList===void 0?{}:{domainAllowList:e.networking.domainAllowList},...e.networking.secrets===void 0?{}:{secrets:e.networking.secrets.map(t=>({env:t.env,value:t.value,hosts:t.hosts}))}}}}}function Qwe(e){return{name:e.name,...e.description===void 0?{}:{description:e.description},...e.image===void 0?{}:{image:{type:"build",...e.image.buildScript===void 0?{}:{buildScript:e.image.buildScript}}},...e.resources===void 0?{}:{resources:{cpu:e.resources.cpu,memory:e.resources.memory,disk:e.resources.disk}},...e.environmentVariables===void 0?{}:{environmentVariables:e.environmentVariables},...e.networking===void 0?{}:{networking:{...e.networking.networkBlockAll===void 0?{}:{networkBlockAll:e.networking.networkBlockAll},...e.networking.domainAllowList===void 0?{}:{domainAllowList:e.networking.domainAllowList},...e.networking.secrets===void 0?{}:{secrets:e.networking.secrets.map(t=>({env:t.env,value:t.value,hosts:t.hosts}))}}}}}function dv(e){return{id:e.id,name:e.name,description:e.description,enabled:e.enabled,isDefault:e.isDefault,status:e.status,statusReason:e.statusReason,manifest:phn(e.manifest),createdBySubject:e.createdBySubject,createdAt:qwe(e.createdAt),updatedAt:qwe(e.updatedAt)}}function l9e(e){const{client:t}=e;return{async listEnvironments(n){const r=Math.min(Math.max((n==null?void 0:n.limit)??uhn,1),dhn),o=await t.sandboxEnvironments.list({limit:r,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken}});return qd(o,dv)},async getEnvironment({name:n}){const{data:r}=await t.sandboxEnvironments.get(n);return dv(r)},async createEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.create({manifest:Qwe(n)});return dv(r)},async createOrUpdateEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.createOrUpdate({manifest:Qwe(n)});return dv(r)},async setEnvironmentEnabled({name:n,enabled:r}){const{data:o}=await t.sandboxEnvironments.update(n,{enabled:r});return dv(o)},async setDefaultEnvironment({name:n}){const{data:r}=await t.sandboxEnvironments.update(n,{isDefault:!0});return dv(r)},async deleteEnvironment({name:n}){await t.sandboxEnvironments.delete(n)}}}var Jwe=25;async function hC(e){const t=await CB(e),n=new Map,r=new Map;for(const o of t)n.set(o.id,o.name),r.set(o.name,o.id);return{idToName:n,nameToId:r}}function e_e(e,t){const n=t.idToName.get(e);if(n!=null)return n;if(t.nameToId.has(e))return e;throw new Error(`Unknown agent: ${e}`)}function fhn(e){const t=[];if((e==null?void 0:e.agentIds)!=null)for(const n of e.agentIds)n!==""&&t.push(n);return(e==null?void 0:e.agentId)!=null&&e.agentId!==""&&t.push(e.agentId),[...new Set(t)]}function hhn(e){return e.status??"active"}function gC(e,t){const n=t.nameToId.get(e.agentName)??e.agentName;return{id:e.id,name:e.name,agentId:n,agentName:e.agentName,task:e.manifest.task,cron:e.manifest.cron,timezone:e.manifest.timezone??"UTC",status:hhn(e.manifest),lastRunAt:null,createdBySubject:e.createdBySubject}}function t_e(e){return{task:e.task,cron:e.cron,timezone:e.timezone??"UTC",status:e.status??"active"}}function n_e(e){return e instanceof Date?e.toISOString():e}function r_e(e){return{id:e.id,scheduleId:e.scheduleId,name:e.name,scheduledFor:n_e(e.scheduledFor),status:e.status,reason:e.reason,triggeredAt:e.triggeredAt==null?null:n_e(e.triggeredAt),triggeredBy:e.createdBySubject.subjectDisplayName||e.createdBySubject.subjectId,sessionId:e.sessionId}}function c9e(e){const{client:t}=e;return{async listSchedules(n){const r=await hC(t),o=fhn(n),a=o.length===0?void 0:o.map(l=>e_e(l,r)).join(","),i=Math.min(Math.max((n==null?void 0:n.limit)??Jwe,1),Jwe),s=await t.schedules.list({limit:i,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken},...a===void 0?{}:{agentNames:a}});return qd(s,l=>gC(l,r))},async getSchedule({id:n}){const r=await hC(t),{data:o}=await t.schedules.get(n);return gC(o,r)},async createSchedule(n){const r=await hC(t),o=e_e(n.agentId,r),{data:a}=await t.schedules.create({agentName:o,name:n.name,manifest:t_e(n)});return gC(a,r)},async updateSchedule(n){const r=await hC(t),{data:o}=await t.schedules.update(n.id,{name:n.name,manifest:t_e(n)});return gC(o,r)},async deleteSchedule({id:n}){await t.schedules.delete(n)},async listScheduleRuns({scheduleId:n}){const{data:r}=await t.schedules.listRuns(n);return r.map(r_e)},async createScheduleRun(n){const{data:r}=await t.schedules.createRun({scheduleId:n.scheduleId});return r_e(r)}}}var o_e=100;function ghn(e){return{id:e.id,displayName:e.displayName,email:e.email}}async function mhn({client:e,ids:t}){const n=new Map;for(let r=0;r<t.length;r+=o_e){const o=await e.users.list({ids:t.slice(r,r+o_e).join(",")});for(const a of o.data)n.set(a.id,a)}return n}async function a_e({client:e,grants:t}){const n=t.filter(o=>o.subject.subjectType==="user"),r=await mhn({client:e,ids:n.map(o=>o.subject.subjectId)});return t.map(o=>{const a=o.subject.subjectType==="user"?r.get(o.subject.subjectId):void 0;return{subjectType:o.subject.subjectType,subjectId:o.subject.subjectId,displayName:(a==null?void 0:a.displayName)??null,email:(a==null?void 0:a.email)??null,createdAt:o.createdAt}})}function u9e(e={}){const t=e.client??Ap(e);return{async listAccess({sessionId:n}){const{data:r}=await t.sessions.listGrants(n);return a_e({client:t,grants:r})},async grantAccess({sessionId:n,subjects:r}){const{data:o}=await t.sessions.updateGrants(n,{grant:r});return a_e({client:t,grants:o})},async revokeAccess({sessionId:n,subjectType:r,subjectId:o}){await t.sessions.updateGrants(n,{revoke:[{subjectType:r,subjectId:o}]})},async searchUsers(n){const r=await t.users.list({...n.query===void 0||n.query.length===0?{}:{query:n.query},...n.limit===void 0?{}:{limit:n.limit},...n.pageToken===void 0||n.pageToken.length===0?{}:{pageToken:n.pageToken}});return qd(r,ghn)}}}function bhn(e={}){const{catalog:t,permissions:n,...r}=e,o=Ap(r),a=t??{modelCatalog:Q$e(o),connectorCatalog:$$e(o),skillCatalog:t9e(o),sandboxCatalog:T$e(o),webSearchCatalog:a9e(o),memoryCatalog:Z$e(o)};return xsn({chatServer:N$e({client:o}),...W$e({client:o}),catalog:a,configuration:i9e(o),sessions:M$e({...r,client:o}),metrics:C$e({...r,client:o}),schedules:c9e({client:o}),sandboxEnvironments:l9e({client:o}),permissions:n??s9e({client:o}),sessionAccess:u9e({client:o}),getMe:async()=>{const{data:i}=await o.auth.me();return{tenantId:i.tenantId}}})}const vhn=Object.freeze(Object.defineProperty({__proto__:null,configFromHarness:Iee,createConfigurationServer:i9e,createConnectorCatalog:$$e,createHarnessAgentMetricsServer:C$e,createHarnessAgentSessionsServer:M$e,createHarnessBuilderServer:W$e,createHarnessChatServer:N$e,createHarnessPermissionsServer:s9e,createHarnessSessionAccessServer:u9e,createMemoryProviderCatalog:Z$e,createModelProviderCatalog:Q$e,createSandboxEnvironmentServer:l9e,createSandboxProviderCatalog:T$e,createScheduleServer:c9e,createSkillCatalog:t9e,createTrueForgeAgentUIServer:bhn,createTrueForgeClient:Ap,createWebSearchProviderCatalog:a9e,filterUiSandboxProviders:E$e,filterUiWebSearchProviders:o9e,getCapabilities:H$e,isDaytonaSandboxConfig:Lfn,listConfiguredMcpServers:F$e,listModels:U$e,listSkills:B$e,modelProviderLogosByName:V$e,toHarnessAgentSpec:hN,toHarnessAuth:L$e,toHarnessConnectorManifest:IB,toHarnessMemoryManifest:NB,toHarnessModelProvider:MB,toHarnessSandboxManifest:AB,toHarnessSkillManifest:J$e,toHarnessWebSearchManifest:OB,toModelSelection:G$e,toUiAgentSpec:uE,toUiCatalogModelProviderEntry:q$e,toUiConnector:Cv,toUiConnectorFromReadEntry:RB,toUiMemoryCatalogEntry:Y$e,toUiMemoryProvider:p2,toUiModelProvider:f2,toUiSandboxCatalogEntry:k$e,toUiSandboxProvider:d2,toUiSkill:e9e,toUiWebSearchCatalogEntry:r9e,toUiWebSearchProvider:h2},Symbol.toStringTag,{value:"Module"})),ke="u">typeof window?window:void 0,di="u">typeof globalThis?globalThis:ke,ua=di==null?void 0:di.navigator,Fe=di==null?void 0:di.document,uo=di==null?void 0:di.location,QS=di==null?void 0:di.fetch,Oee=di!=null&&di.XMLHttpRequest&&"withCredentials"in new di.XMLHttpRequest?di.XMLHttpRequest:void 0,i_e=di==null?void 0:di.AbortController,yhn=di==null?void 0:di.CompressionStream,Ri=ua==null?void 0:ua.userAgent;function d9e(){return!(!ke||ke.navigator.onLine===!1)}const Jw=typeof globalThis<"u"?globalThis:ke;Jw&&typeof self>"u"&&(Jw.self=Jw),Jw&&typeof File>"u"&&(Jw.File=function(){});const $t=ke??{},xhn="0.9.0",Hd={DEBUG:!1,LIB_VERSION:xhn,LIB_NAME:"browser-common"};var Qc=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),PB=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const whn=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],_hn=["token"];function Kt(e,t){return e.indexOf(t)!==-1}const $3=function(e){return e.trim()},jB=function(e){return e.replace(/^\$/,"")};function p9e(e){var t;const n=[];return(t=JSON.stringify(e,function(r,o){if(typeof o=="bigint")return o.toString();if(typeof o!="function"&&typeof o!="symbol"){if(o instanceof Error)return{name:o.name,message:o.message,stack:o.stack};if(o&&typeof o=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(o))return"[Circular]";n.push(o)}return o}}))!==null&&t!==void 0?t:"null"}const f9e=Object.prototype,Pee=f9e.hasOwnProperty,U3=f9e.toString,Yt=Array.isArray||function(e){return U3.call(e)==="[object Array]"},ca=e=>typeof e=="function",Rn=e=>e===Object(e)&&!Yt(e),Qi=e=>{if(Rn(e)){for(const t in e)if(Pee.call(e,t))return!1;return!0}return!1},Le=e=>e===void 0,kn=e=>U3.call(e)=="[object String]",i1=e=>kn(e)&&e.trim().length===0,fo=e=>e===null,sn=e=>Le(e)||fo(e),xo=e=>U3.call(e)=="[object Number]"&&e==e,yd=e=>xo(e)&&e>0,Mi=e=>U3.call(e)==="[object Boolean]",Shn=e=>Kt(whn,e),khn=e=>Kt(_hn,e);function h9e(e){return e===null||typeof e!="object"}function bN(e,t){return{}.toString.call(e)===`[object ${t}]`}function wx(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return g9e(e,Error)}}function jee(e){return"u">typeof Event&&g9e(e,Event)}function g9e(e,t){try{return e instanceof t}catch{return!1}}const Ehn=[!0,"true",1,"1","yes"],N$=e=>Kt(Ehn,e),Thn=[!1,"false",0,"0","no"];function s_e(e,t,n,r,o,a,i){try{var s=e[a](i),l=s.value}catch(c){return void n(c)}s.done?t(l):Promise.resolve(l).then(r,o)}function Zr(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(l){s_e(a,r,o,i,s,"next",l)}function s(l){s_e(a,r,o,i,s,"throw",l)}i(void 0)})}}const Ahn=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],l_e=function(e,t=[]){if(!e)return!1;const n=e.toLowerCase();return Ahn.concat(t).some(r=>{const o=r.toLowerCase();return n.indexOf(o)!==-1})};function hu(e,t,n,r,o){return t>n&&(r.warn("min cannot be greater than max."),t=n),xo(e)?e>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+o),hu(o??n,t,n,r))}var Chn=class{constructor(e){this.C={},this.I=e.I,this.R=hu(e.bucketSize,0,100,e.A),this.$=hu(e.refillRate,0,this.R,e.A),this.O=hu(e.refillInterval,0,864e5,e.A)}F(e,t){const n=Math.floor((t-e.lastAccess)/this.O);n>0&&(e.tokens=Math.min(e.tokens+n*this.$,this.R),e.lastAccess=e.lastAccess+n*this.O)}consumeRateLimit(e){var t;const n=Date.now(),r=String(e);let o=this.C[r];return o?this.F(o,n):(o={tokens:this.R,lastAccess:n},this.C[r]=o),o.tokens===0||(o.tokens--,o.tokens===0&&((t=this.I)===null||t===void 0||t.call(this,e)),o.tokens===0)}stop(){this.C={}}};const x0="Mobile",JS="Android",vN="Tablet",m9e="Android Tablet",b9e="iPad",v9e="Apple Watch",g2="Safari",F3="BlackBerry",y9e="Samsung Internet",m2="Chrome",x9e="Chrome iOS",w9e="Internet Explorer",_9e="Internet Explorer Mobile",S9e="Opera",k9e="Microsoft Edge",b2="Firefox",E9e="Firefox iOS",yN="Nintendo",xN="PlayStation",B3="Xbox",T9e="Android Mobile",A9e="Mobile Safari",M$="Windows",C9e="Windows Phone",c_e="Nokia",DB="Ouya",Rhn="Generic "+x0.toLowerCase(),R9e="Generic "+vN.toLowerCase(),LB="Konqueror",I9e="Oculus Browser",N9e="Vivaldi",M9e="Yandex",O9e="Whale",P9e="DuckDuckGo",j9e="Pale Moon",D9e="Waterfox",zB="Brave",L9e="Claude",z9e="Codex",$9e="ChatGPT",U9e="Google Search App",O$=new RegExp("Version/(\\d+(\\.\\d+)?)"),P$=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ihn=new RegExp(B3,"i"),Nhn=new RegExp("PlayStation \\w+","i"),Mhn=new RegExp("Nintendo \\w+","i"),Dee=new RegExp("BlackBerry|PlayBook|BB10","i"),Ohn={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},F9e=function(e,t,n,r){return t=t||"",(function(a){return a!=null&&a.brave?zB:null})(n)||(r!=null&&r.detectGoogleSearchApp&&Kt(e,"GSA/")?U9e:Kt(e," OPR/")&&Kt(e,"Mini")?"Opera Mini":Kt(e," OPR/")?S9e:Dee.test(e)?F3:Kt(e,"IEMobile")||Kt(e,"WPDesktop")?_9e:Kt(e,"OculusBrowser")?I9e:Kt(e,"SamsungBrowser")?y9e:Kt(e,"Edge")||Kt(e,"Edg/")?k9e:Kt(e,"Vivaldi/")?N9e:Kt(e,"YaBrowser/")?M9e:Kt(e,"Whale/")?O9e:Kt(e,"DuckDuckGo/")||Kt(e,"Ddg/")?P9e:Kt(e,"Claude/")?L9e:Kt(e,"Codex/")?z9e:Kt(e,"ChatGPT/")?$9e:Kt(e,"FBIOS")?"Facebook Mobile":Kt(e,"UCWEB")||Kt(e,"UCBrowser")?"UC Browser":Kt(e,"CriOS")?x9e:Kt(e,"CrMo")||Kt(e,m2)?m2:Kt(e,JS)&&Kt(e,g2)?T9e:Kt(e,"FxiOS")?E9e:Kt(e.toLowerCase(),LB.toLowerCase())?LB:Kt(e,"Brave/")?zB:((a,i)=>i&&Kt(i,"Apple")||(function(s){return Kt(s,g2)&&!Kt(s,m2)&&!Kt(s,JS)})(a))(e,t)?Kt(e,x0)?A9e:g2:Kt(e,"PaleMoon/")?j9e:Kt(e,"Waterfox/")?D9e:Kt(e,b2)?b2:Kt(e,"MSIE")||Kt(e,"Trident/")?w9e:Kt(e,"Gecko")?b2:"")},Phn={[_9e]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[k9e]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[m2]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[x9e]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[g2]:[O$],[A9e]:[O$],[S9e]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[b2]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[E9e]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[LB]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[F3]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),O$],[T9e]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[y9e]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[I9e]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[N9e]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[M9e]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[O9e]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[zB]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[L9e]:[P$],[z9e]:[P$],[$9e]:[P$],[P9e]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[j9e]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[D9e]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[U9e]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[w9e]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},jhn=function(e,t,n,r){const o=F9e(e,t,n,r),a=Phn[o];if(Le(a))return null;for(let i=0;a.length>i;i++){const s=e.match(a[i]);if(s)return parseFloat(s[s.length-2])}return null},u_e=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[B3,e&&e[1]||""]],[new RegExp(yN,"i"),[yN,""]],[new RegExp(xN,"i"),[xN,""]],[Dee,[F3,""]],[new RegExp(M$,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[C9e,""];if(new RegExp(x0).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let r=Ohn[n[1]]||"";return/arm/i.test(t)&&(r="RT"),[M$,r]}return[M$,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=Le(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[JS,[e[2],e[3],e[4]||"0"].join(".")]:[JS,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],B9e=function(e){for(let t=0;u_e.length>t;t++){const[n,r]=u_e[t],o=n.exec(e),a=o&&(ca(r)?r(o,e):r);if(a)return a}return["",""]},H9e=function(e){return Mhn.test(e)?yN:Nhn.test(e)?xN:Ihn.test(e)?B3:new RegExp(DB,"i").test(e)?DB:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?C9e:/iPad/.test(e)?b9e:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?v9e:Dee.test(e)?F3:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(c_e,"i").test(e)?c_e:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(x0).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?JS:m9e:new RegExp("(pda|Mobile)","i").test(e)?Rhn:new RegExp(vN,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?R9e:""},Dhn=function(e,t){var n;const r=H9e(e);return r===b9e||r===m9e||r==="Kobo"||r==="Kindle Fire"||r===R9e?vN:r===yN||r===B3||r===xN||r===DB?"Console":r===v9e?"Wearable":r?x0:(t==null?void 0:t.userAgentDataPlatform)==="Android"&&((n=t==null?void 0:t.maxTouchPoints)!==null&&n!==void 0?n:0)>0?600>Math.min((o=t==null?void 0:t.screenWidth)!==null&&o!==void 0?o:0,(a=t==null?void 0:t.screenHeight)!==null&&a!==void 0?a:0)/((i=t==null?void 0:t.devicePixelRatio)!==null&&i!==void 0?i:1)?x0:vN:"Desktop";var o,a,i},j$=/\bFBAV\/(\d+(?:\.\d+)*)/i,d_e=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",j$],[/\bFBAN\/EMA\b/i,"Facebook Lite",j$],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",j$],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],$B="[Truncated]",dE="[Unserializable]";function by(e){let t="";for(let n=0;e.length>n;n++){const r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:"�";else{const o=e.charCodeAt(n+1);56320>o||o>57343?t+="�":(t+=e[n]+e[n+1],n++)}}return t}function V9e(e,t){if(!t)return e;let n=[];try{n=Object.keys(t)}catch{n=[]}for(const r of n){let o;try{o=t[r]}catch{o=dE}Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0,configurable:!0})}return e}const v2=3e5;var G9e=class{record(e){if(e.kind==="too-large")return;if(e.kind!=="retry-later")return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),n=Date.now(),r=Math.min(e.retryAfterMs,v2);if(!t)return this.ts=n,void(this.es=n+r);this.es=Math.max(this.es,Math.min(n+r,this.ts+v2))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(v2,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const Lhn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function p_e(e,t){return typeof(n=e)=="string"&&Lhn.test(n)?e:t();var n}function W9e(e,t){const n=new Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function eh(e){return e&&e.split("#")[0]}function f_e(e){try{return e()}catch{return}}function K9e(e,t){const n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function h_e(e,t,n){return Y9e.apply(this,arguments)}function Y9e(){return(Y9e=Zr(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((o,a)=>{r=K9e(()=>{try{n==null||n(),o()}catch(i){a(i)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}let mC,g_e,D$;function zhn(e){const t=globalThis._posthogChunkIds;if(!t)return;const n=Object.keys(t);return D$&&n.length===g_e||(g_e=n.length,D$=n.reduce((r,o)=>{mC||(mC={});const a=mC[o];if(a)r[a[0]]=a[1];else{const i=e(o);for(let s=i.length-1;s>=0;s--){const l=i[s],c=l==null?void 0:l.filename,u=t[o];if(c&&u){r[c]=u,mC[o]=[c,u];break}}}return r},{})),D$}function s1(e){return s1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s1(e)}function $hn(e,t,n){return(t=(function(r){var o=(function(a){if(s1(a)!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var s=i.call(a,"string");if(s1(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)})(r);return s1(o)=="symbol"?o:o+""})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m_e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ce(e){for(var t=1;arguments.length>t;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?m_e(Object(n),!0).forEach(function(r){$hn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m_e(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Uhn=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){const n=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(n,t,0).apply(e),o=this.buildParsingContext(t),a=this.parseStacktrace(r,o);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:"error"}}modifyFrames(e){var t=this;return Zr(function*(){for(const n of e)n.stacktrace&&n.stacktrace.frames&&Yt(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)===null||t===void 0?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var n;let r,o;if(e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null)try{o=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return ce(ce({},e),{},{cause:r,stack:o,errors:(n=e.errors)===null||n===void 0?void 0:n.map(a=>this.parseStacktrace(a,t))})}applyChunkIds(e,t){return e.map(n=>(n.filename&&t&&(n.chunk_id=t[n.filename]),n))}applyCoercers(e,t){for(const n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Zr(function*(){let n=e;for(const r of t.modifiers)n=yield r(n);return n})()}convertToExceptionList(e,t){const n=[],r=(o,a,i)=>{var s;const l=n.length,c=a===void 0?ce(ce({type:typeof t.type=="string"&&t.type.length>0?t.type:"generic"},typeof t.handled=="boolean"?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic=="boolean"?t.synthetic:o.synthetic,exception_id:l}):{type:"chained",source:i,synthetic:o.synthetic,exception_id:l,parent_id:a},u={type:o.type,value:o.value,mechanism:c};o.stack&&(u.stacktrace={type:"raw",frames:o.stack}),n.push(u),o.cause&&r(o.cause,l,"cause");for(const d of(s=o.errors)!==null&&s!==void 0?s:[])r(d,l,"member")};return r(e),n}buildParsingContext(e){var t;return{chunkIdMap:zhn(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(wx(e)){let n=Object.getPrototypeOf(e);for(let r=0;n&&100>r;r++){var t;const o=(t=Object.getOwnPropertyDescriptor(n,"constructor"))===null||t===void 0?void 0:t.value;if(typeof o=="function"&&o.name==="AggregateError"){const a=e.errors;return Yt(a)?a:void 0}n=Object.getPrototypeOf(n)}}}catch{}}buildCoercingContext(e,t,n=0){let r=0,o=0,a=!1;const i=new Set,s=[],l={},c=(f,g,b=0)=>{const v=u(g,b),y=v.apply;if(v.apply=C=>{s.push(f);try{return y(C)}finally{s.pop()}},b>4||b>0&&s.indexOf(f)!==-1)return this.coerceFallback(v);const w=typeof f=="object"&&f!==null||typeof f=="function";if(b===0&&r>=50||w&&i.has(f))return;w&&i.add(f),b===0&&r++;const S=this.getAggregateErrors(f);let E,A;a||(a=!!S);try{if(E=this.applyCoercers(f,v),!E)throw l}catch(C){if(C===l)return void(b===0&&r--);if(!a)throw C;E=this.coerceFallback(v)}if(!S||r>=50)return E;try{A=S.length}catch{return E}if(!Number.isInteger(A)||0>A||A>4294967295)return E;const T=[];for(let C=0;50>r&&1e3>o&&A>C;C++){let R;o++;try{R=v.next(S[C])}catch{r++,R=this.coerceFallback(u(g+1))}R&&T.push(R)}return ce(ce({},E),{},{errors:T})},u=(f,g=0)=>ce(ce({},t),{},{syntheticException:f==0?t.syntheticException:void 0,mechanism:f==0?e:{},apply(b){const v=c(b,f,g+1);if(!v)throw l;return v},next:b=>c(b,f+1)}),d=u(n);return ce(ce({},d),{},{apply:f=>{var g;return(g=c(f,n))!==null&&g!==void 0?g:this.coerceFallback(d)}})}};const Fhn=/^([a-z][a-z0-9.+-]+):/i,Bhn=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function Hhn(e){if(!e||e==="<anonymous>")return!1;const t=Fhn.exec(e);return!t||Bhn.includes(t[1].toLowerCase())}function UB(e,t,n,r,o){const a={platform:e,filename:t,function:n==="<anonymous>"?"?":n,in_app:Hhn(t)};return Le(r)||(a.lineno=r),Le(o)||(a.colno=o),a}const Z9e=(e,t)=>{const n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:"?",n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Vhn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ghn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Whn=/\((\S*)(?::(\d+))(?::(\d+))\)/,Khn=(e,t)=>{const n=Vhn.exec(e);if(n){const[,o,a,i]=n;return UB(t,o,"?",+a,+i)}const r=Ghn.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){const i=Whn.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}const[o,a]=Z9e(r[1]||"?",r[2]);return UB(t,a,o,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Yhn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Zhn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Xhn=(e,t)=>{const n=Yhn.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const a=Zhn.exec(n[3]);a&&(n[1]=n[1]||"eval",n[3]=a[1],n[4]=a[2],n[5]="")}let r=n[3],o=n[1]||"?";return[o,r]=Z9e(o,r),UB(t,r,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},b_e=/\(error: (.*)\)/;function Lee(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function qhn(e){for(let t=1;10>=t;t++){const n=e.length-2*t;if(0>n)break;let r=!0;for(let o=0;t>o;o++)if(!Lee(e[n+o],e[n+t+o])){r=!1;break}if(r){for(let o=0;t>o;o++)e[n+o]=e[n+t+o];return e.length=n+t,{start:n,length:t}}}}function Qhn(e,t){const n=t.start+t.length,r=q9e(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function X9e(e,t){let n=t.start;for(;n>0&&Lee(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function q9e(e,t){const n=t.start+t.length;let r=n;for(;e.length>r&&Lee(e[r],e[r-t.length]);)r++;return r-n}function Jhn(e,t){const n=t[0];let r=e.length-(n?X9e(e,n):0);for(const o of t)r-=q9e(e,o);return r}function egn(e,t,n){for(let r=0;e.length>r;r++){const o=e[(t+r)%e.length],a=e[(n+r)%e.length];if(o!==a)return a>o}return!1}var tgn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const n=kn(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return bN(e,"DOMException")}isDOMError(e){return bN(e,"DOMError")}},ngn=class{match(e){return wx(e)}coerce(e,t){var n;const r=this.getStack(e),o=r===void 0?(n=t.syntheticException)===null||n===void 0?void 0:n.stack:void 0,a=!!o;return{type:this.getType(e),value:this.getMessage(e,t),stack:r??o,cause:e.cause?t.next(e.cause):void 0,synthetic:a}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const n=e.message;return String(n.error&&typeof n.error.message=="string"?n.error.message:n)}getStack(e){try{const t=e.stacktrace;if(typeof t=="string"&&t.length>0)return t;const n=e.stack;return typeof n=="string"&&n.length>0?n:void 0}catch{return}}},rgn=class{match(e){return!!bN(e,"ErrorEvent")&&(e.error!=null||this.sr(e))}coerce(e,t){var n;if(e.error!=null)return t.apply(e.error);const r=t.apply(e.message);return ce(ce({},r),{},{stack:(n=this.ar(e))!==null&&n!==void 0?n:r.stack,synthetic:!0})}sr(e){return kn(e.message)&&e.message.length>0}ar(e){var t,n;const r=e,o=(t=r.lineno)!==null&&t!==void 0?t:0,a=(n=r.colno)!==null&&n!==void 0?n:0;if(kn(r.filename)&&r.filename.length!==0&&o!==0)return`Error
1109
1109
  at ${r.filename}:${o}:${a}`}};const ogn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var agn=class{match(e){return typeof e=="string"}coerce(e,t){var n;const[r,o]=this.getInfos(e);return{type:r??"Error",value:o??e,stack:(n=t.syntheticException)===null||n===void 0?void 0:n.stack,synthetic:!0}}getInfos(e){let t="Error",n=e;const r=e.match(ogn);return r&&(t=r[1],n=r[2]),[t,n]}};const ign=["fatal","error","warning","log","info","debug"];function Q9e(e,t=40){const n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(let r=n.length;r>0;r--){const o=n.slice(0,r).join(", ");if(t>=o.length)return r===n.length?o:o.length>t?`${o.slice(0,t)}...`:o}return""}var sgn=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var n,r;const o=this.getErrorPropertyFromObject(e);return o?t.apply(o):{type:this.getType(e),value:this.getValue(e),stack:(n=this.getStack(e))!==null&&n!==void 0?n:(r=t.syntheticException)===null||r===void 0?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(jee(e))return e.constructor.name;const t="name"in e?e.name:void 0;return kn(t)&&!i1(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message: '${e.message}'`),n}if("message"in e&&typeof e.message=="string")return e.message;const t=this.getObjectClassName(e);return`${t&&t!=="Object"?`'${t}'`:"Object"} captured as exception with keys: ${Q9e(e)}`}isSeverityLevel(e){return kn(e)&&!i1(e)&&ign.indexOf(e)>=0}getStack(e){try{return kn(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:kn(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const n=e[t];if(wx(n))return n}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},lgn=class{match(e){return jee(e)}coerce(e,t){var n;const r=e.constructor.name;return{type:r,value:`${r} captured as exception with keys: ${Q9e(e)}`,stack:(n=t.syntheticException)===null||n===void 0?void 0:n.stack,synthetic:!0}}},cgn=class{match(e){return h9e(e)}coerce(e,t){var n;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(n=t.syntheticException)===null||n===void 0?void 0:n.stack,synthetic:!0}}},ugn=class{match(e){return bN(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!jee(e))return!1;try{const t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var n;const r=this.getUnhandledRejectionReason(e);return h9e(r)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(r)}`,stack:(n=t.syntheticException)===null||n===void 0?void 0:n.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}};const wN="$message",_N="$timestamp",dgn=new Set([wN,_N]),L$={enabled:!0,max_bytes:32768};function SN(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:L$.enabled,max_bytes:fgn(e.max_bytes,L$.max_bytes)}:ce({},L$)}var pgn=class{constructor(e){this.ns=[],this.ss=0,this.Mr=SN(e)}setConfig(e){this.Mr=SN(e),this.rs()}add(e){const t=(function(r){let o;try{o=p9e(r)}catch{return}try{const a=JSON.parse(o);if(!Rn(a))return;const i=a,s=i[wN],l=i[_N];return!kn(s)||s.trim().length===0||!kn(l)&&!xo(l)?void 0:{step:i,json:o}}catch{return}})(e);if(!t)return;const n=(function(r){if("u">typeof TextEncoder)return new TextEncoder().encode(r).length;const o=encodeURIComponent(r);let a=0;for(let i=0;o.length>i;i++)o[i]==="%"?(a+=1,i+=2):a+=1;return a})(t.json);n>this.Mr.max_bytes||(this.ns.push({step:t.step,bytes:n}),this.ss+=n,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function fgn(e,t){if(!xo(e)||e===1/0||e===-1/0)return t;const n=Math.floor(e);return 0>n?t:n}const v_e=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function y_e(e){return typeof e=="string"||e}function x_e(e){return typeof e=="string"?e:void 0}const hgn=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],J9e="NativeGzipValidationError",FB=e=>e.length>=2&&e[0]===31&&e[1]===139,w_e=(e,t)=>e===PB.GZipJS||t===PB.GZipJS||t==="gzip",__e=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let e_;const bC=e=>{throw W9e(J9e,`Native gzip produced invalid output: ${e}`)},ggn=(S_e=Zr(function*(e,t){18>e.size&&bC("too-short");const n=new Uint8Array(yield e.slice(0,10).arrayBuffer());FB(n)&&n[2]===8||bC("invalid-header");const r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(a=>{const i=(()=>{if(e_)return e_;e_=[];for(let l=0;256>l;l++){let c=l;for(let u=0;8>u;u++)c=1&c?3988292384^c>>>1:c>>>1;e_[l]=c>>>0}return e_})();let s=4294967295;for(let l=0;a.length>l;l++)s=i[255&(s^a[l])]^s>>>8;return(4294967295^s)>>>0})(t)&&bC("invalid-crc");const o=t.length>>>0;r.getUint32(4,!0)!==o&&bC("invalid-size")}),function(e,t){return S_e.apply(this,arguments)});var S_e;function BB(){return BB=Zr(function*(e,t=!0,n){try{const o=new TextEncoder().encode(e),a=new globalThis.CompressionStream("gzip"),i=a.writable.getWriter(),s=i.write(o).then(()=>i.close()).catch((r=Zr(function*(u){try{yield i.abort(u)}catch{}throw u}),function(u){return r.apply(this,arguments)})),l=new Response(a.readable).blob(),[c]=yield Promise.all([l,s]);return yield ggn(c,o),c}catch(o){if(n!=null&&n.rethrow)throw o;return t&&console.error("Failed to gzip compress data",o),null}var r}),BB.apply(this,arguments)}function eUe(e,t){if(e==null)return{};var n,r,o=(function(i,s){if(i==null)return{};var l={};for(var c in i)if({}.hasOwnProperty.call(i,c)){if(s.includes(c))continue;l[c]=i[c]}return l})(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;a.length>r;r++)t.includes(n=a[r])||{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const mgn={}.propertyIsEnumerable;function kN(e,t){try{return tUe(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function zee(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:$B};if(n.remainingNodes--,Mi(e))return{boolValue:e};if(typeof e=="bigint")return(function(o,a){const i=o.toString(),s=BigInt("9223372036854775808");return o>=s||-s>o?(a==null||a.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}})(e,t);if(typeof e=="number"){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const o=BigInt(e).toString();return e>=9223372036854776e3||-9223372036854776e3>e?(t==null||t.debug(`Attribute ${o} is outside the int64 range; encoding it as a string`),{stringValue:o}):{intValue:o}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:by(e)};if(typeof e=="function")return{stringValue:"[Function]"};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(n.ancestors.has(e))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:$B};if(e instanceof Date){const o=e.getTime(),a=Number.isFinite(o)?e.toISOString():String(e);return{stringValue:typeof a=="string"?by(a):String(a)}}n.ancestors.add(e);try{try{const o=e.toJSON;if(typeof o=="function")return zee(o.call(e),t,n,r+1)}catch{}return Yt(e)?{arrayValue:{values:bgn(e,t,n,r+1)}}:{kvlistValue:{values:tUe(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:by(String(e))}}function bgn(e,t,n,r){const o=[],a=Math.min(e.length,1e3);let i=0;for(;a>i&&n.remainingNodes>0;i++)try{const s=i in e?e[i]:void 0;if(sn(s))continue;o.push(zee(s,t,n,r))}catch{o.push({stringValue:dE})}return e.length>i&&o.push({stringValue:$B}),o}function tUe(e,t,n,r){const o=[];for(const a in e)if(mgn.call(e,a)){if(!a){t==null||t.debug("Dropping an attribute with an empty key");continue}if(o.length>=1e3||0>=n.remainingNodes){t==null||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const i=e[a];if(fo(i)||Le(i))continue;o.push({key:by(a),value:zee(i,t,n,r)})}catch{o.push({key:by(a),value:{stringValue:dE}})}}return o}function nUe(e,t,n){return ce(ce(ce(ce({},V9e({},e.resourceAttributes)),{},{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}const vgn=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function rUe(e,t){const n=V9e({},e),r={};for(const o of vgn)({}).hasOwnProperty.call(n,o)&&(r[o]=n[o],delete n[o]);return[...kN(n,t),...kN(r,t)]}const k_e={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},oUe={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},ygn=oUe.info;function xgn(e){try{return by(String(e))}catch{return dE}}function wgn(e,t,n,r){const o=e.level||"info",{text:a,number:i}=oUe[o]||ygn,s=(function(f=Date.now()){return String(f)+"000000"})(xo(r)?r:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),sn(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),sn(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=ce({},l),u=e.attributes;if(u){let f=[];try{f=Object.keys(u)}catch{f=[]}for(const g of f){let b;try{b=u[g]}catch{b=dE}Object.defineProperty(c,g,{value:b,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:s,observedTimeUnixNano:s,severityNumber:i,severityText:a,body:{stringValue:xgn(e.body)},attributes:kN(c,n)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),Le(e.trace_flags)||(d.flags=e.trace_flags),d}function aUe(e,t,n){return nUe(e,t,n)}function iUe(e,t,n,r){return{resourceLogs:[{resource:{attributes:rUe(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var sUe=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=K9e(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function lUe(){return .75+.5*Math.random()}function cUe(e,t,n,r){const o=Math.min(Math.max(0,t-1),6),a=e*Math.pow(2,o);return Math.round(Math.min(a,Math.max(r,e))*n)}var _gn=class{constructor(e,t,n,r,o,a=()=>Promise.resolve(),i){var s;this._instance=e,this.Mr=t,this.A=n,this.cs=r,this.ds=o,this.vs=a,this.fs=i,this.ps=new sUe(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new G9e,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=t.maxBufferSize,this.Is=Math.max((s=t.maxQueueSize)!==null&&s!==void 0?s:t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(Qc.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){var n;if(this._instance.isDisabled||this._instance.optedOut||!(e!=null&&e.body))return;const r=this.Os(e);if(r===null)return;if(!r.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const o={record:wgn(r,(n=t==null?void 0:t.context)!==null&&n!==void 0?n:this.cs(),this.A,t==null?void 0:t.occurredAtMs)};this.ds(()=>this.Ls(o))}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const n=Yt(t)?t:[t];let r=e;for(const o of n)try{const a=o(r);if(!a)return this.A.info("Log was rejected in beforeSend function"),null;r=a}catch(a){return this.A.error("Error in beforeSend function for log:",a),null}return r}Ds(){if(this.Rs===void 0)return!0;const e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.$s=!0),!1)}flush(){var e=this;return Zr(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Zr(function*(){var t;e.ps.clear();let n=(t=e._instance.getPersistedProperty(Qc.LogsQueue))!==null&&t!==void 0?t:[];if(n.length===0)return;const r=n.length;let o=0;for(;n.length>0&&r>o;){var a,i;const s=e._s;e.bs=0;const l=Math.min(n.length,e.Es),c=n.slice(0,l),u=iUe(c.map(f=>f.record),e.qs(),(a=e.fs)!==null&&a!==void 0?a:e._instance.getLibraryId(),e._instance.getLibraryVersion()),d=yield e._instance.js(u);if(e._s!==s)return;if(d.kind==="too-large"&&c.length>1)e.Es=Math.max(1,Math.floor(c.length/2)),e.A.warn(`Logs batch of size ${c.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(d),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),d.kind==="retry-later"||(d.kind==="too-large"?e.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):d.kind==="ok"&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(c.length),n=(i=e._instance.getPersistedProperty(Qc.LogsQueue))!==null&&i!==void 0?i:[],o+=c.length,d.kind==="fatal"))throw d.error}})()}Bs(e){var t=this;return Zr(function*(){var n;const r=Math.max(0,e-t.bs),o=(n=t._instance.getPersistedProperty(Qc.LogsQueue))!==null&&n!==void 0?n:[];t._instance.setPersistedProperty(Qc.LogsQueue,o.slice(r)),yield t.vs()})()}qs(){return aUe(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const n=(t=this._instance.getPersistedProperty(Qc.LogsQueue))!==null&&t!==void 0?t:[];this.Is>n.length||(n.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),n.push(e),this._instance.setPersistedProperty(Qc.LogsQueue,n),this.Ts>n.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(cUe(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(Qc.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Zr(function*(){t.ps.clear();const n=t.flush().catch(()=>{});e!==void 0?yield h_e(n,e):yield n})()}flushWithTimeout(e){var t=this;return Zr(function*(){const n=t.flush();yield h_e(n,e,()=>{n.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=lUe(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const z$=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function E_e(e){return String(e)+"000000"}function T_e(e,t,n,r){let o="";return r&&(o=Object.keys(r).sort().map(a=>`${JSON.stringify(a)}:${JSON.stringify(r[a])}`).join(",")),`${e}\0${t}\0${n??""}\0${o}`}var Sgn=class{constructor(e,t,n){this._instance=e,this.Mr=t,this.A=n,this.zs=new Map,this.ps=new sUe(()=>this.flush().catch(r=>{this.A.error("Metrics flush failed:",r)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new G9e,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,n){this.Zs({name:e,type:"count",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}gauge(e,t,n){this.Zs({name:e,type:"gauge",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}histogram(e,t,n){this.Zs({name:e,type:"histogram",value:t,unit:n==null?void 0:n.unit,attributes:n==null?void 0:n.attributes})}flush(){var e=this;const t=this.ys,n=(function(){var r=Zr(function*(){t&&(yield t.catch(()=>{})),yield e.Qs()});return function(){return r.apply(this,arguments)}})()().finally(()=>{this.ys===n&&(this.ys=null)});return this.ys=n,n}drainWindow(){if(this.zs.size===0)return null;const e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.A.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.A.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let n,r;try{n=t.attributes?ce({},t.attributes):void 0,r=T_e(t.type,t.name,t.unit,n)}catch(i){return void this.A.warn(`Dropping metric '${t.name}': attributes could not be serialized`,i)}let o=this.zs.get(r);if(!o){if(!this.Ks())return;o={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.zs.set(r,o)}const a=this.Ws.get(t.name);a===void 0?this.Ws.set(t.name,t.type):a===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.A.warn(`Metric name '${t.name}' is already used as a ${a}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(o,t.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case"count":var n;e.total=((n=e.total)!==null&&n!==void 0?n:0)+t;break;case"gauge":e.last=t;break;case"histogram":{e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(z$.length+1).fill(0)});const r=e.hist;r.count+=1,r.sum+=t,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t),r.bucketCounts[(function(o,a){for(let i=0;a.length>i;i++)if(a[i]>=o)return i;return a.length})(t,z$)]+=1;break}}}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const n=Yt(t)?t:[t];let r=e;for(const o of n)try{const a=o(r);if(!a)return this.A.info("Metric was rejected in beforeSend function"),null;r=a}catch(a){return this.A.error("Error in beforeSend function for metric:",a),null}return r}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(cUe(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return Zr(function*(){if(e.ps.clear(),e.zs.size===0)return;const t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const n=e.Gs,r=yield e._instance.Ys(e.Js(t));if(n===e.Gs)switch(e.ws.record(r),r.kind==="retry-later"?(e.ks++,e.Ss=lUe()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),r.kind){case"ok":return;case"retry-later":return e.uo(t),void e.ps.armNoEarlierThan(e.Hs());case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",r.error)}})()}Js(e){return t=this.ho(e),n=(function(a,i,s){return nUe(a,i,s)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),o=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:rUe(n)},scopeMetrics:[{scope:{name:r,version:o},metrics:t}]}]};var t,n,r,o}ho(e){const t=E_e(Date.now()),n=new Map;for(const i of e.values()){var r;const s=T_e(i.type,i.name,i.unit,void 0);let l=n.get(s);l||(l=ce({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},n.set(s,l));const c=kN((r=i.attributes)!==null&&r!==void 0?r:{},this.A),u=E_e(i.windowStartMs);if(i.type==="count"){var o;const d={attributes:c,startTimeUnixNano:u,timeUnixNano:t,asDouble:(o=i.total)!==null&&o!==void 0?o:0};l.sum.dataPoints.push(d)}else if(i.type==="gauge"){var a;const d={attributes:c,timeUnixNano:t,asDouble:(a=i.last)!==null&&a!==void 0?a:0};l.gauge.dataPoints.push(d)}else i.hist&&l.histogram.dataPoints.push({attributes:c,startTimeUnixNano:u,timeUnixNano:t,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:z$})}return Array.from(n.values())}uo(e){for(const[r,o]of e){const a=this.zs.get(r);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,o.windowStartMs),a.type){case"count":var t,n;a.total=((t=a.total)!==null&&t!==void 0?t:0)+((n=o.total)!==null&&n!==void 0?n:0);break;case"gauge":break;case"histogram":if(o.hist)if(a.hist){a.hist.count+=o.hist.count,a.hist.sum+=o.hist.sum,a.hist.min=Math.min(a.hist.min,o.hist.min),a.hist.max=Math.max(a.hist.max,o.hist.max);for(let i=0;a.hist.bucketCounts.length>i;i++)a.hist.bucketCounts[i]+=o.hist.bucketCounts[i]}else a.hist=o.hist}else this.Ks()&&this.zs.set(r,o)}}};const uUe=(e,{debugEnabled:t}={})=>{const n={N(r,...o){ke&&(Hd.DEBUG||ke.POSTHOG_DEBUG||t)&&!Le(ke.console)&&ke.console&&("__rrweb_original__"in ke.console[r]?ke.console[r].__rrweb_original__:ke.console[r])(e,...o)},debug(...r){n.N("debug",...r)},info(...r){n.N("log",...r)},warn(...r){n.N("warn",...r)},error(...r){n.N("error",...r)},critical(...r){console.error(e,...r)},uninitializedWarning(r){n.error(`You must initialize PostHog before calling ${r}`)},createLogger:(r,o)=>uUe(`${e} ${r}`,o)};return n},Je=uUe("[PostHog.js]"),mo=Je.createLogger,kgn=mo("[ExternalScriptsLoader]"),EN=e=>{const t=Fe==null?void 0:Fe.querySelectorAll("script");if(t){for(let n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute("src")===e)return t[n]}},wg=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return kgn.warn(`${t} was requested but loading of external scripts is disabled.`),n("Loading of external scripts is disabled");const r=EN(t);if(r){if(r.__posthog_loading_callback_fired)return n();const a=r.__posthog_loading_error;return a?n(a):(r.addEventListener("load",i=>{r.__posthog_loading_callback_fired=!0,n(void 0,i)}),void r.addEventListener("error",i=>{r.__posthog_loading_error=i,n(i)}))}const o=()=>{if(!Fe)return n("document not found");if(EN(t))return wg(e,t,n);let a=Fe.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=t,a.onload=s=>{a.__posthog_loading_callback_fired=!0,n(void 0,s)},a.onerror=s=>{a.__posthog_loading_error=s,n(s)},e.config.prepare_external_dependency_script&&(a=e.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")Fe.head.appendChild(a);else{const s=Fe.querySelectorAll("body > script");var i;s.length>0?(i=s[0].parentNode)===null||i===void 0||i.insertBefore(a,s[0]):Fe.body.appendChild(a)}};Fe!=null&&Fe.body?o():Fe==null||Fe.addEventListener("DOMContentLoaded",o)},$$={},A_e=(e,t)=>{let n=`/static/${t}.js?v=${e.version}`;return t==="toolbar"&&(n=`${n}&t=${Math.floor(Date.now()/3e5)*3e5}`),e.requestRouter.endpointFor("assets",n)};$t.__PosthogExtensions__=$t.__PosthogExtensions__||{},$t.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t==="remote-config"){const o=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void wg(e,o,n)}const r=e.config.strict_script_versioning;if(r){const o=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),a=$$[o];if(r==="fallback"&&a){if(EN(a))return void wg(e,a,n);delete $$[o]}return void wg(e,o,r==="fallback"?(i,s)=>{if(i)if(typeof i=="string")n(i);else{var l;const c=A_e(e,t);$$[o]=c;const u=EN(o);u==null||(l=u.parentNode)===null||l===void 0||l.removeChild(u),wg(e,c,n)}else n(void 0,s)}:n)}wg(e,A_e(e,t),n)},$t.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{const r=e.requestRouter.endpointFor("api",t);wg(e,r,n)},Hd.DEBUG=!1,Hd.LIB_VERSION="1.435.2",Hd.LIB_NAME="web";var ea=Hd;const Egn="$people_distinct_id",ql="distinct_id",$ee="$device_id",U$="$device_model",TN="__alias",Tgn="__cmpns",C_e="$fbc",vy="$fbc_persistence",R_e="$fbp",l1="$fbp_persistence",HB="__timers",dUe="$autocapture_disabled_server_side",VB="$heatmaps_enabled_server_side",GB="$exception_capture_enabled_server_side",pUe="$error_tracking_suppression_rules",WB="$error_tracking_capture_extension_exceptions",KB="$web_vitals_enabled_server_side",Uee="$dead_clicks_enabled_server_side",Fee="$product_tours_enabled_server_side",fUe="$logs_capture_enabled_server_side",hUe="$web_vitals_allowed_metrics",c1="$session_recording_remote_config",Agn="$session_recording_enabled_server_side",Cgn="$replay_sample_rate",Rgn="$replay_override_sampling",Ign="$replay_override_linked_flag",Ngn="$replay_override_url_trigger",Mgn="$replay_override_event_trigger",Hv="$sesid",gUe="$session_is_sampled",Ogn="$session_past_minimum_duration",Pgn="$session_recording_url_trigger_activated_session",jgn="$session_recording_event_trigger_activated_session",Dgn="$debug_first_full_snapshot_timestamp",Lgn="$sess_rec_flush_size",rc="$enabled_feature_flags",Rd="$active_feature_flags",YB="$early_access_features",Zg="$feature_flag_details",Nf="$feature_flag_payloads",Xg="$feature_flag_request_id",u1="$minimal_flag_called_events",Yc="$override_feature_flags",_g="$override_feature_flag_payloads",Mf="$stored_person_properties",Of="$stored_group_properties",mUe="$groups",S_="$surveys",AN="$surveys_loaded_at",bUe="$surveys_activated",vUe="$surveys_activated_session",yUe="$surveys_activated_timestamps",ZB="ph_product_tours",zgn="$product_tours_activated",$gn="$product_tours_activated_session",Ugn="$conversations_widget_session_id",Fgn="$conversations_ticket_id",Bgn="$conversations_widget_state",Hgn="$conversations_user_traits",Pf="$flag_call_reported",k_="$flag_call_reported_session_id",ek="$feature_flag_errors",Vf="$feature_flag_evaluated_at",Ii="$user_state",XB="$client_session_props",Vgn="$capture_rate_limit",xUe="$initial_campaign_params",wUe="$initial_referrer_info",Vv="$initial_person_info",Bee="$epp",F$="$posthog_cookieless",_Ue="$cookieless_mode",SUe="$sdk_debug_extensions_init_method",kUe="$sdk_debug_extensions_init_time_ms",Hee="$sdk_debug_recording_script_not_loaded",Vee="$sdk_debug_replay_stale_config",EUe="$sdk_debug_replay_event_trigger_status",TUe="$sdk_debug_replay_linked_flag_trigger_status",AUe="$sdk_debug_replay_matched_recording_trigger_groups",CUe="$sdk_debug_replay_pending_trigger_conditions",RUe="$sdk_debug_replay_remote_trigger_matching_config",IUe="$sdk_debug_replay_trigger_groups_count",NUe="$sdk_debug_replay_url_trigger_status",Ggn="$session_recording_start_reason",Gee="PostHog loadExternalDependency extension not found.",Id="anonymous",y2="identified",MUe="identified_only",tk="visibilitychange",CN="beforeunload",Wee="$pageview",I_e="$pageleave",OUe="$identify",N_e="$groupidentify";function Gv(e,t){Yt(e)&&e.forEach(t)}function rr(e,t){if(!sn(e))if(Yt(e))e.forEach(t);else if((n=>n instanceof FormData)(e))e.forEach((n,r)=>t(n,r));else for(const n in e)Pee.call(e,n)&&t(e[n],n)}const Kr=function(e,...t){for(const n of t)for(const r in n)n[r]!==void 0&&(e[r]=n[r]);return e};function x2(e){const t=Object.keys(e);let n=t.length;const r=new Array(n);for(;n--;)r[n]=[t[n],e[t[n]]];return r}const Wgn=function(e){return function(...t){try{return e.apply(this,t)}catch(n){Je.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Je.critical(n)}}},Kee=function(e){const t={};return rr(e,function(n,r){(kn(n)&&n.length>0||xo(n))&&(t[r]=n)}),t};function PUe(e){const t=ce({},e);for(const n of["name","message","stack","cause","errors"])try{n in e&&(t[n]=e[n])}catch{}return t}const Kgn=["herokuapp.com","vercel.app","netlify.app"];function Ygn(e){const t=e==null?void 0:e.hostname;if(!kn(t))return!1;const n=t.split(".").slice(-2).join(".");for(const r of Kgn)if(n===r)return!1;return!0}function Zn(e,t,n,r){const{capture:o=!1,passive:a=!0}=r??{};e==null||e.addEventListener(t,n,{capture:o,passive:a})}function qB(e){return e.name==="ph_toolbar_internal"}const d1=e=>{if(Fe){try{const t=e+"=",n=Fe.cookie.split(";").filter(r=>r.length);for(let r=0;n.length>r;r++){let o=n[r];for(;o.charAt(0)==" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return decodeURIComponent(o.substring(t.length,o.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return xo(e)&&isFinite(e)&&Math.floor(e)===e});var Zgn=class QB{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,o){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(o)||0>t||0>n||0>r||0>o||t>0xffffffffffff||n>4095||r>1073741823||o>4294967295)throw new RangeError("invalid field value");const a=new Uint8Array(16);return a[0]=t/Math.pow(2,40),a[1]=t/Math.pow(2,32),a[2]=t/Math.pow(2,24),a[3]=t/Math.pow(2,16),a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=o>>>24,a[13]=o>>>16,a[14]=o>>>8,a[15]=o,new QB(a)}toString(){let t="";for(let n=0;this.bytes.length>n;n++)t=t+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new QB(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let n=0;16>n;n++){const r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}},Xgn=class{generate(){const e=this.generateOrAbort();if(!Le(e))return e;{this.Ct=0;const t=this.generateOrAbort();if(Le(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const e=(()=>{const t=Date.now();return xo(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return Zgn.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(2,30)-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new qgn}};let jUe=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ke&&!Le(ke.crypto)&&crypto.getRandomValues&&(jUe=e=>crypto.getRandomValues(e));var qgn=class{nextUint32(){return this.Rt.length>this.Et||(jUe(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let M_e;const oc=()=>Qgn().toString(),Qgn=()=>(M_e||(M_e=new Xgn)).generate();let t_="";const Jgn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let pv=null;const lo={At(){if(!fo(pv))return pv;if(pv=!1,Fe)try{const e=`__ph_cookie_support_${oc()}`;lo.$t(e,"xyz"),pv=d1(e)==='"xyz"',lo.Lt(e)}catch{pv=!1}return pv},Pt(e){Je.error("cookieStore error: "+e)},Ot:d1,Dt(e){let t;try{t=JSON.parse(lo.Ot(e))||{}}catch{}return t},$t(e,t,n,r,o){if(!Fe)return!1;try{let a="",i="";const s=(function(c,u){if(u){let d=(function(f,g=Fe){if(t_)return t_;if(!g||["localhost","127.0.0.1"].includes(f))return"";const b=f.split(".");let v=Math.min(b.length,8);const y="dmn_chk_"+oc();for(;!t_&&v--;){const w=b.slice(v).join("."),S=y+"=1;domain=."+w+";path=/";g.cookie=S+";max-age=3",g.cookie.includes(y)&&(g.cookie=S+";max-age=0",t_=w)}return t_})(c);if(!d){const f=(g=>{const b=g.match(Jgn);return b?b[0]:""})(c);f!==d&&Je.info("Warning: cookie subdomain discovery mismatch",f,d),d=f}return d?"; domain=."+d:""}return""})(Fe.location.hostname,r);if(n){const c=new Date;c.setTime(c.getTime()+864e5*n),a="; expires="+c.toUTCString()}o&&(i="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+a+"; SameSite=Lax; path=/"+s+i;return l.length>3686.4&&Je.warn("cookieStore warning: large cookie, len="+l.length),Fe.cookie=l,!0}catch{return!1}},Lt(e,t){if(Fe!=null&&Fe.cookie&&(!t||!fo(d1(e))))try{lo.$t(e,"",-1,t)}catch{return}}};let B$=null;const Un={At(){if(!fo(B$))return B$;let e=!0;if(Le(ke))e=!1;else try{const t="__mplssupport__";Un.$t(t,"xyz"),Un.Ot(t)!=='"xyz"'&&(e=!1),Un.Lt(t)}catch{e=!1}return e||Je.error("localStorage unsupported; falling back to cookie store"),B$=e,e},Pt(e){Je.error("localStorage error: "+e)},Ot(e){try{return ke==null?void 0:ke.localStorage.getItem(e)}catch(t){Un.Pt(t)}return null},Dt(e){try{return JSON.parse(Un.Ot(e))||{}}catch{}return null},$t(e,t){try{return ke==null||ke.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Un.Pt(n)}return!1},Lt(e){try{ke==null||ke.localStorage.removeItem(e)}catch(t){Un.Pt(t)}}},H$=[Mf,Rd,rc,Zg,Nf,Xg,Vf,ek,Pf],Sg=[$ee,ql,Hv,gUe,Bee,Vv,vy,Ii],RN=e=>e+"_cpm",emn=["__proto__","constructor","prototype"],V$=e=>{if(!Rn(e))return{};const t={};return Object.keys(e).forEach(n=>{emn.indexOf(n)===-1&&(t[n]=e[n])}),t},G$=(e,t=[])=>{const n={};return[...Sg,...t].forEach(r=>{const o=e[r];Le(o)||fo(o)||o===""||(n[r]=o)}),n},DUe=e=>{let t=5381,n=2166136261;for(let r=0;e.length>r;r++){const o=e.charCodeAt(r);t=33*t^o,n=Math.imul(n^o,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(n>>>0).toString(36)},O_e=(e,t)=>({p:t,f:DUe(JSON.stringify(e))}),P_e=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const n=lo.Dt(RN(e)),r=(n==null?void 0:n.f)===DUe(t)&&Yt(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},W$=(e,t)=>t+"|"+(lo.Ot(RN(e))||""),fv={},JB={At:()=>!0,Pt(e){Je.error("memoryStorage error: "+e)},Ot:e=>e in fv?fv[e]:null,Dt:e=>e in fv?fv[e]:null,$t:(e,t)=>(fv[e]=t,!0),Lt(e){delete fv[e]}};let cg=null;const Dr={At(){if(!fo(cg))return cg;if(cg=!0,Le(ke))cg=!1;else try{const e="__support__";Dr.$t(e,"xyz"),Dr.Ot(e)!=='"xyz"'&&(cg=!1),Dr.Lt(e)}catch{cg=!1}return cg},Pt(e){Je.error("sessionStorage error: ",e)},Ot(e){try{return ke==null?void 0:ke.sessionStorage.getItem(e)}catch(t){Dr.Pt(t)}return null},Dt(e){try{return JSON.parse(Dr.Ot(e))||null}catch{}return null},$t(e,t){try{return ke==null||ke.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Dr.Pt(n)}return!1},Lt(e){try{ke==null||ke.sessionStorage.removeItem(e)}catch(t){Dr.Pt(t)}}};var tmn=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Oo()?0:this.Do}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.Lo.$t(this.No,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.Lo.Lt(this.No,this.Mr.cross_subdomain_cookie)}get No(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:"__ph_opt_in_out_"+e)}get Do(){const e=this.Lo.Ot(this.No);return N$(e)?1:Kt(Thn,e)?0:-1}get Lo(){const e=this.Mr.opt_out_capturing_persistence_type,t=e==="localStorage"?Un:lo,n=t.At()?t:JB;if(!this.qo||this.qo!==n){this.qo=n;const r=e==="localStorage"?lo:Un;r.Ot(this.No)&&(this.qo.Ot(this.No)||this.optInOut(N$(r.Ot(this.No))),r.Lt(this.No,this.Mr.cross_subdomain_cookie))}return this.qo}Oo(){return!!this.Mr.respect_dnt&&[ua==null?void 0:ua.doNotTrack,ua==null?void 0:ua.msDoNotTrack,$t.doNotTrack,ua==null?void 0:ua.globalPrivacyControl].some(e=>N$(e))}};function LUe(e,t){var n;const r=e==null||(n=e.config)===null||n===void 0?void 0:n.get_current_url;if(!ca(r))return t;try{const o=r(t);return kn(o)&&o?o:t}catch(o){return Je.error("Error in get_current_url, falling back to window.location.href",o),t}}function j_e(e){var t;return e instanceof Element&&(e.id==="__POSTHOG_TOOLBAR__"||!!(!((t=e.closest)===null||t===void 0)&&t.call(e,".toolbar-global-fade-container")))}function Mu(e){return!!e&&e.nodeType===1}function Wa(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function zUe(e){return!!e&&e.nodeType===3}function Yee(e){return!!e&&e.nodeType===11&&Mu(e.host)}function Zee(e){return e?$3(e).split(/\s+/):[]}function D_e(e,t){const n=(function(r){var o;const a=ke==null||(o=ke.location)===null||o===void 0?void 0:o.href;return Le(a)?void 0:LUe(r,a)})(t);return!!(n&&e&&e.some(r=>n.match(r)))}function w0(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Zee(t)}function $Ue(e){return sn(e)?null:$3(e).split(/(\s+)/).filter(t=>f1(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function nk(e){let t="";return yy(e)&&!rk(e)&&e.childNodes&&e.childNodes.length&&rr(e.childNodes,function(n){var r;zUe(n)&&n.textContent&&(t+=(r=$Ue(n.textContent))!==null&&r!==void 0?r:"")}),$3(t)}function p1(e){var t;return Le(e.target)?e.srcElement||null:!((t=e.target)===null||t===void 0)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}const Xee=["a","button","form","input","select","textarea","label"];function eH(e,t){const n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}function tH(e,t){if(Le(t))return!0;for(const n of e)if(t.some(r=>eH(n,r)))return!0;return!1}function UUe(e){const t=e.parentNode;return!(!t||!Mu(t))&&t}const K$=[".ph-no-autocapture","[data-ph-no-autocapture]"],FUe=["next","previous","prev",">","<"],nmn=[...FUe,"+","-","−","–"],L_e=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,z_e=[".ph-no-rageclick",".ph-no-capture"],rmn=["","text","search","email","password","url","tel","number"];function BUe(e,t){if(!ke||qee(e))return!1;let n,r,o;var a,i;if(Mi(t)?(n=!!t&&z_e,r=void 0,o=!1):(n=(a=t==null?void 0:t.css_selector_ignorelist)!==null&&a!==void 0?a:z_e,r=t==null?void 0:t.content_ignorelist,o=(i=t==null?void 0:t.ignore_text_selection)!==null&&i!==void 0&&i),n===!1||o&&(function(l){return!(!l||!Mu(l))&&(!!Wa(l,"textarea")||(Wa(l,"input")?Kt(rmn,(l.getAttribute("type")||"").toLowerCase()):(function(c){var u;if(c.isContentEditable)return!0;const d=(u=c.getAttribute)===null||u===void 0?void 0:u.call(c,"contenteditable");return d==="true"||d===""})(l)))})(e))return!1;const{targetElementList:s}=HUe(e,!1);return!(function(l,c){if(l===!1||Le(l))return!1;let u;if(l===!0)u=FUe;else{if(!Yt(l))return!1;if(l.length>10)return Je.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;u=l.map(d=>d.toLowerCase())}return c.some(({safeText:d,ariaLabel:f})=>u.some(g=>L_e(d,g)||L_e(f,g)))})(r,s.map(l=>{var c;return{safeText:nk(l).toLowerCase(),ariaLabel:((c=l.getAttribute("aria-label"))===null||c===void 0?void 0:c.toLowerCase().trim())||""}}))&&!tH(s,n)}const qee=e=>!e||Wa(e,"html")||!Mu(e),HUe=(e,t)=>{if(!ke||qee(e))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const r=[e];let o=e;for(;o.parentNode&&!Wa(o,"body");){if(Yee(o.parentNode)){r.push(o.parentNode.host),o=o.parentNode.host;continue}const a=UUe(o);if(!a)break;if(t||Xee.indexOf(a.tagName.toLowerCase())>-1)n=!0;else try{const i=ke.getComputedStyle(a);i&&i.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}r.push(a),o=a}return{parentIsUsefulElement:n,targetElementList:r}};function yy(e){const t=new Set;let n=0;for(let a=e;a.parentNode&&!Wa(a,"body");a=a.parentNode){if(n++>=1e3||t.has(a))return!1;t.add(a);const i=w0(a);if(Kt(i,"ph-sensitive")||Kt(i,"ph-no-capture"))return!1}if(Kt(w0(e),"ph-include"))return!0;const r=e.type||"";if(kn(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}const o=e.name||e.id||"";return!kn(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function rk(e){return!!(Wa(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Wa(e,"select")||Wa(e,"textarea")||e.getAttribute("contenteditable")==="true")}const $_e=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),U_e=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,omn=[16,15,14,13],amn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),F_e=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),B_e=/[0-9A-Za-z_]/;function imn(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r)-48;n&&(o*=2,o>9&&(o-=9)),t+=o,n=!n}return t%10==0}function f1(e,t=!0){return!(sn(e)||kn(e)&&(e=$3(e),(t?$_e.test((e||"").replace(/[- ]/g,"")):(function(n){let r;for(U_e.lastIndex=0;r=U_e.exec(n);){const o=r[2];if(!o)continue;const a=o.replace(/[- ]/g,"");for(let i=0;a.length>i;i++)for(const s of omn){const l=i+s;if(a.length>=l){const c=a.slice(i,l);if($_e.test(c)&&imn(c))return!0}}}return!1})(e))||(t?amn.test(e):(function(n){let r;for(F_e.lastIndex=0;r=F_e.exec(n);){const o=r[1],a=r[3];if(!(o&&a&&B_e.test(o)&&B_e.test(a)))return!0}return!1})(e))))}function H_e(e){let t=nk(e);return t=`${t} ${VUe(e)}`.trim(),f1(t)?t:""}function VUe(e){let t="";return e&&e.childNodes&&e.childNodes.length&&rr(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{const o=nk(n);t=`${t} ${o}`.trim(),n.childNodes&&n.childNodes.length&&(t=`${t} ${VUe(n)}`.trim())}catch(o){Je.error("[AutoCapture]",o)}}),t}function V_e(e){return e.replace(/"|\\"/g,'\\"')}function smn(e){const t=e.attr__class;if(t)return Yt(t)?t:Zee(t)}const vC=mo("[Dead Clicks]"),lmn=()=>!0,cmn=e=>{var t;const n=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(Uee)),r=e.instance.config.capture_dead_clicks;return Mi(r)?r:!!Rn(r)||n};var G_e=class{get lazyLoadedDeadClicksAutocapture(){return this.jo}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Uee]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Bo(()=>{this.Ho()}):this.stop()}Bo(e){var t,n,r;!((t=$t.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(n=$t.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,"dead-clicks-autocapture",o=>{o?vC.error("failed to load script",o):e()})}Ho(){var e;if(Fe){if(!this.jo&&(!((e=$t.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=Rn(this.instance.config.capture_dead_clicks)?ce({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.jo=$t.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.jo.start(Fe),vC.info("starting...")}}else vC.error("`document` not found. Cannot start.")}stop(){this.jo&&(this.jo.stop(),this.jo=void 0,vC.info("stopping..."))}};const n_=mo("[SegmentIntegration]");function W_e(e,t,n=!0){const r=e.config.segment;if(!r)return t();const{analytics:o,filterProperties:a}=(s=>ca(s.register))(i=r)?{analytics:i}:i;var i;(function(s,l,c,u){const d=g=>{const b=()=>g.anonymousId()||oc();s.config.get_device_id=b,u&&g.id()&&(s.register({distinct_id:g.id(),$device_id:b()}),s.persistence.set_property(Ii,y2)),c(u?void 0:g.anonymousId()||void 0)},f=l.user();"then"in f&&ca(f.then)?f.then(d):d(f)})(e,o,s=>{o.register(((l,c,{filterProperties:u}={})=>{typeof Promise<"u"&&Promise.resolve||n_.warn("This browser does not have Promise support, and can not use the segment integration");const d=(f,g)=>{if(!g)return f;const b=!!c&&f.event.anonymousId===c&&!f.event.userId;b||f.event.userId||f.event.anonymousId===l.get_distinct_id()||(n_.info("No userId set, resetting PostHog"),l.reset()),b||(c=void 0),f.event.userId&&f.event.userId!==l.get_distinct_id()&&(n_.info("UserId set, identifying with PostHog"),l.identify(f.event.userId));let v=l.calculateEventProperties(g,f.event.properties);if(!sn(u)){const y=f.event.properties||{},w={};for(const E of Object.keys(v))Pee.call(y,E)||(w[E]=v[E]);const S=((E,A)=>{const T=Yt(E)?E:[E];let C=ce({},A);for(const R of T)try{if(C=R(C),sn(C))return null}catch(N){return n_.error("Error in Segment filterProperties:",N),null}return C})(u,w);if(sn(S))return f;v=S}return f.event.properties=Object.assign({},v,f.event.properties),f};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(f){return d(f,f.event.event)},page(f){return d(f,Wee)},identify(f){return d(f,OUe)},screen(f){return d(f,"$screen")}}})(e,s,{filterProperties:a})).then(()=>{t()},l=>{n_.error("Failed to register the Segment integration",l),t()})},n)}const GUe="posthog-js";function WUe(e,{organization:t,projectId:n,prefix:r,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}={}){return i=>{var s,l,c,u,d;if(o!=="*"&&!o.includes(i.level)||!e.__loaded)return i;i.tags||(i.tags={});const f=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);i.tags["PostHog Person URL"]=f,e.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const g=((s=i.exception)===null||s===void 0?void 0:s.values)||[],b=g.map(w=>ce(ce({},w),{},{stacktrace:w.stacktrace?ce(ce({},w.stacktrace),{},{type:"raw",frames:(w.stacktrace.frames||[]).map(S=>ce(ce({},S),{},{platform:"web:javascript"}))}):void 0})),v={$exception_message:((l=g[0])===null||l===void 0?void 0:l.value)||i.message,$exception_type:(c=g[0])===null||c===void 0?void 0:c.type,$exception_level:i.level,$exception_list:b,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:((u=g[0])===null||u===void 0?void 0:u.value)||i.message,$sentry_exception_type:(d=g[0])===null||d===void 0?void 0:d.type,$sentry_tags:i.tags};var y;return t&&n&&(v.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+i.event_id),a&&((y=e.exceptions)===null||y===void 0||y.sendExceptionEvent(v)),i}}var umn=class{constructor(e,t,n,r,o,a){this.name=GUe,this.setupOnce=function(i){i(WUe(e,{organization:t,projectId:n,prefix:r,severityAllowList:o,sendExceptionsToPostHog:a==null||a}))}}},K_e=class{constructor(e){this.zo=(t,n,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength||r.crossTabAdoption)&&(Je.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.Uo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Wo()}Wo(){var e;this.Vo=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.zo)}destroy(){var e;(e=this.Vo)===null||e===void 0||e.call(this),this.Vo=void 0}doPageView(e,t){var n;const r=this.Go(e,t);return this.Uo={pathname:(n=ke==null?void 0:ke.location.pathname)!==null&&n!==void 0?n:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.Go(e,(t=this.Uo)===null||t===void 0?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Uo)===null||e===void 0?void 0:e.pageViewId}}Go(e,t){const n=this.Uo;if(!n)return{$pageview_id:t};let r={$pageview_id:t,$prev_pageview_id:n.pageViewId};const o=this._instance.scrollManager.getContext();if(o&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:a,lastScrollY:i,maxScrollY:s,maxContentHeight:l,lastContentY:c,maxContentY:u}=o;if(!(Le(a)||Le(i)||Le(s)||Le(l)||Le(c)||Le(u))){a=Math.ceil(a),i=Math.ceil(i),s=Math.ceil(s),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);const d=a>1?hu(i/a,0,1,Je):1,f=a>1?hu(s/a,0,1,Je):1,g=l>1?hu(c/l,0,1,Je):1,b=l>1?hu(u/l,0,1,Je):1;r=Kr(r,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:b})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}};const r_=["flags","surveys"],dmn={[Egn]:{exposure:"hidden"},[TN]:{exposure:"hidden"},[Tgn]:{exposure:"hidden"},[HB]:{exposure:"hidden"},[vy]:{exposure:"hidden"},[l1]:{exposure:"hidden"},[dUe]:{exposure:"event"},[VB]:{exposure:"hidden"},[fUe]:{exposure:"hidden"},[GB]:{exposure:"event"},[pUe]:{exposure:"hidden"},[WB]:{exposure:"event"},[KB]:{exposure:"event"},[Uee]:{exposure:"event"},[Fee]:{exposure:"hidden"},[hUe]:{exposure:"event"},[c1]:{exposure:"hidden"},[Agn]:{exposure:"hidden"},[Hv]:{exposure:"hidden"},[gUe]:{exposure:"event"},[Cgn]:{exposure:"event",shouldSkipFromEventProperties:e=>fo(e)},[Ogn]:{exposure:"event"},[Pgn]:{exposure:"event"},[jgn]:{exposure:"event"},[Dgn]:{exposure:"event"},[Lgn]:{exposure:"hidden"},[rc]:{exposure:"hidden",storageGroup:"flags"},[Rd]:{exposure:"hidden",storageGroup:"flags"},[YB]:{exposure:"hidden"},[Zg]:{exposure:"hidden",storageGroup:"flags"},[Nf]:{exposure:"hidden",storageGroup:"flags"},[Xg]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[u1]:{exposure:"hidden",storageGroup:"flags"},[Yc]:{exposure:"hidden"},[_g]:{exposure:"hidden"},[Mf]:{exposure:"hidden"},[Of]:{exposure:"hidden"},[S_]:{exposure:"hidden",storageGroup:"surveys"},[AN]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[bUe]:{exposure:"event"},[vUe]:{exposure:"hidden"},[yUe]:{exposure:"hidden"},[ZB]:{exposure:"hidden"},[zgn]:{exposure:"hidden"},[$gn]:{exposure:"hidden"},[Ugn]:{exposure:"event"},[Fgn]:{exposure:"event"},[Bgn]:{exposure:"event"},[Hgn]:{exposure:"event"},[Pf]:{exposure:"hidden"},[k_]:{exposure:"hidden"},[mUe]:{exposure:"event"},[ek]:{exposure:"hidden"},[Vf]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Ii]:{exposure:"hidden"},[XB]:{exposure:"hidden"},[Vgn]:{exposure:"hidden"},[xUe]:{exposure:"hidden"},[wUe]:{exposure:"hidden"},[Vv]:{exposure:"hidden"},[Bee]:{exposure:"hidden"},[Rgn]:{exposure:"event"},[Ign]:{exposure:"event"},[Ngn]:{exposure:"event"},[Mgn]:{exposure:"event"},[SUe]:{exposure:"event"},[kUe]:{exposure:"event"},[Hee]:{exposure:"hidden"},[Vee]:{exposure:"hidden"},[EUe]:{exposure:"hidden"},[TUe]:{exposure:"hidden"},[AUe]:{exposure:"hidden"},[CUe]:{exposure:"hidden"},[RUe]:{exposure:"hidden"},[IUe]:{exposure:"hidden"},[NUe]:{exposure:"hidden"},[Ggn]:{exposure:"event"}},pmn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],_a=e=>{const t=dmn[e];if(t)return t;for(const[n,r]of pmn)if(e.indexOf(n)===0)return r},Wv=(e,t)=>{try{let n;return JSON.stringify(e,(r,o)=>{var a;return wx(o)?((a=n)!==null&&a!==void 0||(n=new WeakMap),n.has(o)||n.set(o,PUe(o)),n.get(o)):typeof o=="bigint"?o.toString():o},t)}catch{return p9e(e)}},cp=e=>{const t=Fe==null?void 0:Fe.createElement("a");return Le(t)?null:(t.href=e,t)},_0=function(e,t){const n=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let r;for(let o=0;n.length>o;o++){const a=n[o].split("=");if(a[0]===t){r=a;break}}if(!Yt(r)||2>r.length)return"";{let o=r[1];try{o=decodeURIComponent(o)}catch{Je.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")}},ok=function(e,t,n){if(!e||!t||!t.length)return e;const r=e.split("#"),o=r[1],a=(r[0]||"").split("?"),i=a[1],s=a[0],l=(i||"").split("&"),c=[];for(let d=0;l.length>d;d++){const f=l[d].split("=");Yt(f)&&(t.includes(f[0])?c.push(f[0]+"="+n):c.push(l[d]))}let u=s;return i!=null&&(u+="?"+c.join("&")),o!=null&&(u+="#"+o),u},IN=function(e,t){const n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},KUe=(e,t)=>e>=t&&d9e(),YUe=(e,t,n,r)=>{if(e===0){if(d9e()){const o=t+1;return o===n&&r(),o}return t}return 0},S0=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],fmn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...S0],ak="<masked>",hmn=["li_fat_id"];function ZUe(e,t,n){if(!Fe)return{};const r=t?[...S0,...n||[]]:[],o=XUe(ok(Fe.URL,r,ak),e),a=(function(){const i={};return rr(hmn,function(s){const l=d1(s);i[s]=l||null}),i})();return Kr(a,o)}function XUe(e,t){const n=fmn.concat(t||[]),r={};return rr(n,function(o){const a=_0(e,o);r[o]=a||null}),r}function qUe(e){const t=(function(o){return o?o.search("https?://(.*)google.([^/?]*)")===0?"google":o.search("https?://(.*)bing.com")===0?"bing":o.search("https?://(.*)yahoo.com")===0?"yahoo":o.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(e),n=t!="yahoo"?"q":"p",r={};if(!fo(t)){r.$search_engine=t;const o=Fe?_0(Fe.referrer,n):"";o.length&&(r.ph_keyword=o)}return r}function QUe(){return navigator.language||navigator.userLanguage}function gmn(){const e=QUe();return typeof e=="string"?e.split("-")[0]:void 0}const NN="$direct";function JUe(){return(Fe==null?void 0:Fe.referrer)||NN}function eFe(e,t,n=!1){const r=e?[...S0,...t||[]]:[],o=n?eh(uo==null?void 0:uo.href):uo==null?void 0:uo.href,a=o==null?void 0:o.substring(0,1e3);return{r:JUe().substring(0,1e3),u:a?ok(a,r,ak):void 0}}function tFe(e,t=!1){var n;const{r,u:o}=e,a=t?eh(o):o,i={$referrer:r,$referring_domain:r==null?void 0:r==NN?NN:(n=cp(r))===null||n===void 0?void 0:n.host};if(a){i.$current_url=a;const s=cp(a);i.$host=s==null?void 0:s.host,i.$pathname=s==null?void 0:s.pathname;const l=XUe(a);Kr(i,l)}if(r){const s=qUe(r);Kr(i,s)}return i}function nFe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function mmn(){try{return new Date().getTimezoneOffset()}catch{return}}const bmn={flags:Vf,surveys:AN},vmn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],yC=e=>`${e}_cookie_identity_change_pending`,xC=e=>{let t="",n=0;for(const r of e){const o=encodeURIComponent(JSON.stringify(r).slice(1,-1)).length;if(n+o>1e3)break;t+=r,n+=o}return t},Zo="main",xd=[rc,Rd,Zg,Nf,Xg,Vf,u1,Mf],Y$=e=>xd.indexOf(e)!==-1,rFe=[vy,l1],Y_e=e=>rFe.indexOf(e)!==-1,sf=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},hv=e=>{if(!e)return{};const t=JSON.parse(e);return Rn(t)?t:{}},Z_e=(e,t)=>{rr(e,(n,r)=>{const o=_a(r);o&&o.exposure!=="event"||{}.hasOwnProperty.call(t,r)||delete e[r]})};var Z$=class{constructor(e,t,n=!0){if(this.Zo={},this.Qo=!1,this.Jo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=new Map,this.ea=!1,this.ia=!1,this.na=!1,this.sa=new Set,this.ra=new Set,this.Mr=e,this.oa=n,this.props={},this.aa=void 0,this.la=(r=>{let o="";return r.token&&(o=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+o+"_posthog"})(e),this.hi=e.disable_persistence||!!t,this.Lo=this.ua(e),this.Ko=this.ha(e),this.load(),this.ca(),e.debug&&Je.info("Persistence loaded",e.persistence,ce({},this.props)),this.update_config(e,e,t),this.save(),ke){const r=()=>this.flush();Zn(ke,"beforeunload",r,{capture:!1}),Zn(ke,"pagehide",r,{capture:!1}),this.da=o=>{if(this.Qo&&(!o.storageArea||o.storageArea===(ke==null?void 0:ke.localStorage))&&o.key)if(o.key!==this.la){if(this.Ko){const a=r_.find(i=>o.key===this.va(i));a&&this.fa(o.key,a)}}else this.fa(o.key,Zo)},Zn(ke,"storage",this.da)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,n])=>{const r=this.ta.get(t);if(!Y$(t)||r===!0)return;if(n===!0)return void this.pa(t,!0);const o=new Set(r||[]);n.forEach(a=>o.add(a)),o.size&&this.pa(t,o)})}onCrossTabFeatureFlagChange(e){return this.ra.add(e),()=>this.ra.delete(e)}destroy(){this.da&&ke&&(ke.removeEventListener("storage",this.da),this.da=void 0),this.ra.clear()}fa(e,t,n=!0){if(this.hi)return!1;let r,o;try{if(o=Un.Ot(e),fo(o)){const s=this.ga(t);return s.storageValue=null,t!==Zo&&(s.persisted=!1),!1}r=hv(o)}catch{return!1}const a=t===Zo?r:Un.Dt(this.la);if(a&&this.ma(a))return!1;const i=this.ya(r,t,n);return t===Zo&&this.Ko&&!sf(this.ba().main,r)||this._a(r,t,!0,o),i}ma(e){const t=this.props[ql],n=e[ql];return!Le(t)&&!Le(n)&&t!==n}_a(e,t,n,r){const o=this.ga(t);o.storageValue=r,t!==Zo&&(o.persisted=n);try{o.fingerprint=this.wa(e,t)}catch{o.fingerprint=void 0}}ya(e,t,n){let r=!1;return xd.forEach(o=>{var a;const i=(a=_a(o))===null||a===void 0?void 0:a.storageGroup;if(t===Zo&&this.Ko&&i||t!==Zo&&i!==t)return;const s=o in e,l=this.ka(o,s?e[o]:void 0),c=this.ta.has(o)?o in this.props:s;c===o in this.props&&sf(l,this.props[o])||(c?this.Sa(o,l,!1):this.xa(o,!1),r=!0)}),r&&n&&this.ra.forEach(o=>o()),r}Ca(){if(!this.Qo)return!1;try{this.na=!1;const e=Un.Ot(this.la),t=this.ga(Zo);let n,r=!1,o=!1;if(e!==t.storageValue)if(fo(e))t.storageValue=null;else{if(n=hv(e),this.na=!this.ia&&this.ma(n),this.na)return!1;o=this.ya(n,Zo,!1),!this.Ko||sf(this.ba().main,n)?this._a(n,Zo,!0,e):t.storageValue=e,r=!0}return this.Ko&&r_.forEach(a=>{const i=Un.Ot(this.va(a)),s=this.ga(a),l=n||{},c=r&&xd.some(d=>{var f;return((f=_a(d))===null||f===void 0?void 0:f.storageGroup)===a&&d in l});if(i===s.storageValue&&!c)return;if(fo(i))return s.storageValue=null,s.persisted=!1,void(c&&(o=this.ya(l,a,!1)||o));const u=hv(i);o=this.ya(u,a,!1)||o,this._a(u,a,!0,i)}),o}catch{return!1}}pa(e,t){this.ta.set(e,t);const n=_a(e);n!=null&&n.volatile||(this.ga((this.Ko?n==null?void 0:n.storageGroup:void 0)||Zo).fingerprint=void 0,this.$a(e))}Ta(){xd.forEach(e=>this.ta.set(e,!0))}ca(){if(this.Qo)try{const e=Un.Ot(this.la),t=hv(e);this.ga(Zo).storageValue=e,xd.forEach(n=>{var r;const o=this.Ko?(r=_a(n))===null||r===void 0?void 0:r.storageGroup:void 0,a=o?Un.Ot(this.va(o)):null;if(o){const s=this.ga(o);s.storageValue=a,s.persisted=!fo(a)}const i=o&&!fo(a)?hv(a):t;n in this.props?this.Ia(n,i[n],this.props[n]):n in i&&this.pa(n,!0)})}catch{}}ka(e,t){const n=this.ta.get(e);if(!n)return t;if(n===!0)return this.props[e];if(e==="$active_feature_flags"){const a=new Set(Yt(t)?t:[]),i=new Set(Yt(this.props[e])?this.props[e]:[]);return n.forEach(s=>i.has(s)?a.add(s):a.delete(s)),Array.from(a)}const r=Rn(t)?ce({},t):{},o=Rn(this.props[e])?this.props[e]:{};return n.forEach(a=>{a in o?r[a]=o[a]:delete r[a]}),r}Ia(e,t,n){if(!Y$(e))return;const r=this.ta.get(e);if(r===!0)return;let o=t;if(this.Qo)try{var a;const s=this.Ko?(a=_a(e))===null||a===void 0?void 0:a.storageGroup:void 0,l=s?this.va(s):this.la;o=hv(Un.Ot(l))[e]}catch{}const i=new Set(r||[]);if(e==="$active_feature_flags"){if(!Le(t)&&!Yt(t)||!Le(o)&&!Yt(o)||!Yt(n))return void this.pa(e,!0);const s=new Set(t||[]),l=new Set(o||[]),c=new Set(n);new Set([...s,...c]).forEach(u=>{s.has(u)!==c.has(u)&&i.add(u)}),i.forEach(u=>{l.has(u)===c.has(u)&&i.delete(u)})}else{if(!Rn(n))return void(sf(o,n)?this.ta.delete(e):this.pa(e,!0));{if(!Le(t)&&!Rn(t)||Le(t)&&Qi(n)&&Le(o))return void this.pa(e,!0);const s=Rn(t)?t:{},l=Rn(o)?o:{};new Set([...Object.keys(s),...Object.keys(n)]).forEach(c=>{c in s==c in n&&sf(s[c],n[c])||i.add(c)}),i.forEach(c=>{c in l==c in n&&sf(l[c],n[c])&&i.delete(c)})}}i.size?this.pa(e,i):this.ta.delete(e)}Ma(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return xo(t)&&t>0?t:0}Ea(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=G$(e,this.Mr.cookie_persisted_properties||[]),n=O_e(t,this.Mr.cookie_persisted_properties||[]),r=JSON.stringify(t)+"|"+JSON.stringify(n),o=lo.Ot(this.la)||void 0;o&&W$(this.la,o)===r&&(this.Pa=r,this.Ra=o)}catch{}else try{const t=lo.Ot(this.la)||void 0;this.Pa=t?W$(this.la,t):void 0,this.Ra=t}catch{}}syncCookieProperties(){return this.Aa(this.Mr)}Aa(e,t=!1){if(this.hi&&!t||this.Yo||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let n;try{n=lo.Ot(this.la)||void 0}catch{}if(!n||n===this.Ra)return!1;const r=W$(this.la,n);let o;try{o=V$(JSON.parse(n))}catch{return!1}if((lo.Ot(this.la)||void 0)!==n)return!1;this.Pa=r,this.Ra=n;const a=P_e(this.la,n),i=[...Sg,...a.properties],s={};if(Object.keys(o).forEach(v=>{const y=o[v];(Le(y)||fo(y)||y===""||v==="$user_state"&&y!=="anonymous"&&y!=="identified")&&(s[v]=!0,delete o[v])}),Qi(o))return!1;const l="distinct_id"in o||o.$user_state==="anonymous"||o.$user_state==="identified",c=this.props,u=c[ql],d=c[Ii],f=Kr({},c);[...Sg,...e.cookie_persisted_properties||[]].forEach(v=>{if(i.indexOf(v)!==-1&&!(v in o)&&!s[v]&&(l||v!=="distinct_id"&&v!=="$user_state")){const y=f[v];(a.isValid||Sg.indexOf(v)===-1||y!==!1&&y!==0)&&delete f[v]}}),this.props=Kr(f,o),xd.forEach(v=>{const y=v in this.props;v in c===y&&sf(c[v],this.props[v])||(y?this.Ia(v,c[v],this.props[v]):this.pa(v,!0))}),!l||"$user_state"in o||"$user_state"in this.props||this.Sa(Ii,Id);const g=this.props[ql],b=this.props[Ii];return!l||g===u&&b===d||(this.ia=!0,this.Xo=!0,Dr.$t(yC(this.la),!0),this.xa(Mf),this.xa(Rd),this.xa(rc),this.xa(Zg),this.xa(Nf),this.xa(Xg),this.xa(Vf),this.xa(ek),this.xa(Pf),b!=="anonymous"||d!=="identified"&&o.$user_state!=="anonymous"&&(Le(u)||g===u)||(Z_e(this.props,o),this.xa(Of)),b==="identified"?this.props.$user_id=g:delete this.props.$user_id,this.xa(TN)),!0}consumeCookieIdentityChange(){const e=yC(this.la),t=this.Xo||!!Dr.Ot(e);return this.Xo=!1,t&&Dr.Lt(e),t}Fa(e=!1){return!(this.Yo||this.hi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.Yo=!0,0))}Oa(){this.Yo&&(Le(this.Da)||(clearTimeout(this.Da),this.Da=void 0),delete this.Zo[Zo],this.La(!0))}Na(e=!0){if(this.Yo)try{e?this.Oa():Le(this.Da)||(clearTimeout(this.Da),this.Da=void 0)}finally{this.Yo=!1}}isDisabled(){return!!this.hi}ua(e){vmn.indexOf(e.persistence.toLowerCase())===-1&&(Je.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((i=[],s=!1)=>{const l=[...Sg,...i];return ce(ce({},Un),{},{Dt(c){try{let d,f={};try{d=lo.Ot(c)||void 0,f=d?V$(JSON.parse(d)):{}}catch{}const g=JSON.parse(Un.Ot(c)||"{}");let b;if(s){const v=P_e(c,d),y=[...Sg,...v.properties],w={};Object.keys(f).forEach(E=>{const A=f[E];fo(A)||A===""||E==="$user_state"&&A!=="anonymous"&&A!=="identified"||(w[E]=A)});const S="distinct_id"in w||w.$user_state==="anonymous"||w.$user_state==="identified";if(Object.keys(w).length>0){var u;const E=g[ql],A=(u=g.$user_state)!==null&&u!==void 0?u:Id;l.forEach(T=>{if(y.indexOf(T)!==-1&&!(T in f)&&(S||T!=="distinct_id"&&T!=="$user_state")){const C=g[T];(v.isValid||Sg.indexOf(T)===-1||C!==!1&&C!==0)&&delete g[T]}}),!S||"$user_state"in f||"$user_state"in g||(g[Ii]=Id),!S||("distinct_id"in w?w[ql]:g[ql])===E&&("$user_state"in w?w[Ii]:g[Ii])===A||(H$.forEach(T=>delete g[T]),w.$user_state==="identified"&&"distinct_id"in w?g.$user_id=w[ql]:delete g.$user_id,w.$user_state!=="identified"&&(delete g[mUe],delete g[Of]),delete g.__alias)}b=Kr(g,w)}else b=Kr(f,g);return Un.$t(c,b),b}catch{}return null},$t(c,u,d,f,g,b){const v=Un.$t(c,u,void 0,void 0,b);try{const y=G$(u,i);if(Object.keys(y).length){if(s){const w=RN(c),S=O_e(y,i);if(lo.$t(w,S,d,f,g,b),lo.Ot(w)!==JSON.stringify(S)){lo.Lt(w,f);const E=G$(u);return lo.$t(c,E,d,f,g,b),v}}lo.$t(c,y,d,f,g,b)}}catch(y){Un.Pt(y)}return v},Lt(c,u){try{ke==null||ke.localStorage.removeItem(c),lo.Lt(c,u),lo.Lt(RN(c),u)}catch(d){Un.Pt(d)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict);let n,r=!1,o=!1;const a=e.persistence.toLowerCase();return a==="localstorage"&&Un.At()?(n=Un,o=!0):a==="localstorage+cookie"&&t.At()?(n=t,o=!0,r=!0):a==="sessionstorage"&&Dr.At()?n=Dr:a==="memory"?n=JB:a==="cookie"&&lo.At()?(n=lo,r=!0):t.At()?(n=t,o=!0,r=!0):lo.At()?(n=lo,r=!0):n=JB,this.Qo=o,this.Jo=r,n}va(e){return`${this.la}__${e}`}ha(e){return this.Qo&&!!e.split_storage}properties(){const e={};return rr(this.props,(t,n)=>{const r=_a(n);if(!r||r.exposure==="event"){var o;if(!(r==null||(o=r.shouldSkipFromEventProperties)===null||o===void 0)&&o.call(r,t))return;e[n]=t}}),e}load(e=!1){if(this.hi&&!e)return;const t=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",n=t?Un.Dt(this.la):null;let r={};if(t)try{r=V$(lo.Dt(this.la)),rr(r,(s,l)=>{(Le(s)||fo(s)||s==="")&&delete r[l]})}catch{}const o=this.Lo.Dt(this.la);if(o&&(this.props=Kr({},o)),this.Ko&&this.qa(),t&&o){var a,i;const s=n==null?void 0:n[ql],l=(a=n==null?void 0:n.$user_state)!==null&&a!==void 0?a:Id,c=o[ql],u=(i=o.$user_state)!==null&&i!==void 0?i:Id;if(c!==s||u!==l){this.Xo=!0,Dr.$t(yC(this.la),!0);const d=Kr({},this.props);H$.forEach(g=>delete d[g]),u!=="anonymous"||l!=="identified"&&r.$user_state!=="anonymous"&&(Le(s)||c===s)||(Z_e(d,r),delete d[Of]),this.props=d;const f=new Set;H$.forEach(g=>{var b;const v=(b=_a(g))===null||b===void 0?void 0:b.storageGroup;v&&f.add(v)}),f.forEach(g=>{const b={};rr(this.props,(v,y)=>{var w;((w=_a(y))===null||w===void 0?void 0:w.storageGroup)===g&&(b[y]=v)}),Qi(b)?(Un.Lt(this.va(g)),this.Zo[g]={}):Un.$t(this.va(g),b)&&(this.Zo[g]={persisted:!0,fingerprint:this.wa(b,g)})})}}Dr.Ot(yC(this.la))&&(this.Xo=!0)}qa(){for(const e of r_){const t=Un.Dt(this.va(e));if(t&&!Qi(t)){const n=this.ga(e);n.persisted=!0,this.ja(e)||(n.fingerprint=this.wa(t,e)),this.Ba(e,t)||Kr(this.props,t)}}}ja(e){return Object.keys(this.props).some(t=>{var n;return((n=_a(t))===null||n===void 0?void 0:n.storageGroup)===e})}Ba(e,t){const n=bmn[e];if(!n)return!1;const r=t[n],o=this.props[n];return xo(r)&&xo(o)&&o>r}refreshKey(e){var t;if(this.hi||this.sa.has(e))return;const n=this.Ko?(t=_a(e))===null||t===void 0?void 0:t.storageGroup:void 0,r=n?Un.Dt(this.va(n)):this.Lo.Dt(this.la);if(r&&e in r)this.Sa(e,r[e],!1);else{if(n){const o=this.Lo.Dt(this.la);if(o&&e in o)return void this.Sa(e,o[e],!1)}this.xa(e,!1)}}save(){if(this.hi)return;const e=this.Ma();e>0?Le(this.Da)&&(this.Da=setTimeout(()=>{this.Da=void 0,this.La()},e)):this.La()}flush(){Le(this.Da)||(clearTimeout(this.Da),this.Da=void 0,this.La())}La(e=!1){if(this.hi||this.Yo&&!e)return;e||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||rFe.forEach(o=>this.refreshKey(o)));const t=!e&&!this.ea;t||(this.na=!1);const n=!!t&&this.Ca();if(this.na)return void(this.Mr.debug&&Je.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Ko)return this.Ha(),void(n&&this.ra.forEach(o=>o()));const r=this.za(this.Lo,this.la,this.props,Zo);r==="written"&&this.Ea(this.props),r!=="failed"&&(this.ta.clear(),this.ia=!1,this.sa.clear()),n&&this.ra.forEach(o=>o())}Ha(){const{main:e,groups:t}=this.ba(),n=this.za(this.Lo,this.la,e,Zo);n==="written"&&this.Ea(e),n!=="failed"&&(this.ia=!1,this.sa.clear(),xd.forEach(o=>{var a;!((a=_a(o))===null||a===void 0)&&a.storageGroup||this.ta.delete(o)}));for(const o of r_){var r;const a=t[o];if(Qi(a)&&!(!((r=this.Zo[o])===null||r===void 0)&&r.persisted)){xd.forEach(s=>{var l;((l=_a(s))===null||l===void 0?void 0:l.storageGroup)===o&&this.ta.delete(s)});continue}const i=this.za(Un,this.va(o),a,o);i!=="failed"&&xd.forEach(s=>{const l=_a(s);(l==null?void 0:l.storageGroup)!==o||i!=="written"&&l.volatile||this.ta.delete(s)})}}ba(){const e={},t={flags:{},surveys:{}};return rr(this.props,(n,r)=>{var o;const a=(o=_a(r))===null||o===void 0?void 0:o.storageGroup;a?t[a][r]=n:e[r]=n}),{main:e,groups:t}}wa(e,t){if(t===Zo)return JSON.stringify(e)+"|"+this.Ua+"|"+this.Wa+"|"+this.Va;const n={};return rr(e,(r,o)=>{var a;n[o]=!((a=_a(o))===null||a===void 0)&&a.volatile?"__volatile__":r}),JSON.stringify(n)}za(e,t,n,r){const o=this.ga(r);if(r!==Zo&&!o.dirty&&!Le(o.fingerprint))return"skipped";let a;try{if(a=this.wa(n,r),a===o.fingerprint)return o.dirty=!1,"skipped"}catch{a=void 0}return e.$t(t,n,this.Ua,this.Wa,this.Va,this.Mr.debug)?(o.dirty=!1,r!==Zo&&(o.persisted=!0),Le(a)||(o.fingerprint=a),this.Qo&&(o.storageValue=Un.Ot(t)),"written"):(this.Mr.debug&&Je.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ta(),Le(this.Da)||(clearTimeout(this.Da),this.Da=void 0),this.Lo.Lt(this.la,!1),this.Lo.Lt(this.la,!0),!e&&this.oa)for(const t of r_)Un.Lt(this.va(t));e?delete this.Zo[Zo]:this.Zo={},this.Pa=void 0,this.Ra=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(Rn(e)){this.syncCookieProperties(),Le(t)&&(t="None"),this.Ua=Le(n)?this.Ga:n;let r=!1;if(rr(e,(o,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.Sa(a,o),r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(Rn(e)){this.syncCookieProperties(),this.Ua=Le(t)?this.Ga:t;let n=!1;if(rr(e,(r,o)=>{e.hasOwnProperty(o)&&(this.props[o]!==r||Rn(r)||Yt(r))&&(this.Sa(o,r),n=!0)}),n)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t=typeof e=="string"?[e]:e;let n=!1;for(const r of t)r in this.props&&(this.xa(r),n=!0);n&&this.save()}update_campaign_params(){const e=Fe==null?void 0:Fe.URL;if(e===this.aa)return;const t=ZUe(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),n=!Qi(Kee(t));return n&&this.register(t),this.aa=e,n?t:void 0}update_search_keyword(){this.register((function(){const e=Fe==null?void 0:Fe.referrer;return e?qUe(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:JUe(),$referring_domain:(Fe==null?void 0:Fe.referrer)&&((e=cp(Fe.referrer))===null||e===void 0?void 0:e.host)||NN},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=eFe(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[Vv]:this.Jo?{r:xC(e.r),u:e.u?xC(e.u):void 0}:e},void 0)}get_initial_props(){const e={};rr([wUe,xUe],n=>{const r=this.props[n];r&&rr(r,function(o,a){e["$initial_"+jB(a)]=o})});const t=this.props[Vv];if(t){const n=(function(r,o=!1){const a=tFe(r,o),i={};return rr(a,function(s,l){i[`$initial_${jB(l)}`]=s}),i})(t,this.Mr.disable_capture_url_hashes);Kr(e,n)}return e}safe_merge(e){return rr(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){const r=e.persistence!==t.persistence,o=!((g,b)=>{if(g.length!==b.length)return!1;const v=[...g].sort(),y=[...b].sort();return v.every((w,S)=>w===y[S])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||o,i=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,s=e.disable_persistence||!!n,l=!!this.hi&&!s;s||this.Aa(t,l),this.Mr=e,!s&&(r||o||i)&&(this.Pa=void 0,this.Ra=void 0,this.Aa(ce(ce({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=a||i?this.ua(e):this.Lo;this.Za();const u=this.ha(e),d=a||u!==this.Ko,f=!s&&(d||e.cross_subdomain_cookie!==this.Wa||e.secure_cookie!==this.Va)&&this.Fa(l);this.ea=d;try{if(this.Ga=this.Ua=e.cookie_expiration,this.set_disabled(s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const g=this.props;this.clear(),this.Lo=c,this.Ko=u,this.props=g,this.save()}else i&&(this.Lo=c,s||(delete this.Zo[Zo],this.La()))}finally{this.ea=!1,f&&this.Na()}}Za(){const e=this.props[Vv];if(!this.Jo||!Rn(e)||typeof e.r!="string")return;const t=xC(e.r),n=typeof e.u=="string"?xC(e.u):e.u;t===e.r&&n===e.u||this.Sa(Vv,ce(ce({},e),{},{r:t,u:n}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Wa&&(this.Wa=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Va&&(this.Va=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const n=this.props.__timers||{};n[e]=t,this.Sa(HB,n),this.save()}remove_event_timer(e){const t=this.props.__timers||{},n=t[e];return Le(n)||(delete t[e],this.Sa(HB,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Sa(e,t),this.save()}Sa(e,t,n=!0){var r;const o=this.props[e];this.props[e]=t,n&&(e!=="distinct_id"&&e!=="$user_state"||o===t||(this.ia=!0),Y_e(e)&&!sf(o,t)&&this.sa.add(e),this.Ia(e,o,t),!((r=_a(e))===null||r===void 0)&&r.volatile||this.$a(e))}xa(e,t=!0){delete this.props[e],t&&(Y$(e)&&this.pa(e,!0),Y_e(e)&&this.sa.add(e),this.$a(e))}$a(e){var t;const n=(t=_a(e))===null||t===void 0?void 0:t.storageGroup;n&&(this.ga(n).dirty=!0)}ga(e){return this.Zo[e]||(this.Zo[e]={})}};const js={GZipJS:"gzip-js",Base64:"base64"},o_={Activation:"events",Cancellation:"cancelEvents"},X$={Popover:"popover",API:"api",Widget:"widget"},Ns={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},q$={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},nH={Popover:"popover",Inline:"inline"};function wC(e){let t=!0;return{dispose(){if(t){t=!1;const n=e();n&&ca(n.then)&&n.then(void 0,()=>{})}}}}const ymn={SHOWN:"product tour shown"},X_e={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},q_e=mo("[RateLimiter]");var xmn=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const n=t.text;if(n&&n.length)try{(JSON.parse(n).quota_limited||[]).forEach(r=>{q_e.info(`${r||"events"} is quota limited.`),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void q_e.warn(`could not rate limit - continuing. Error: "${r==null?void 0:r.message}"`,{text:n})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,n,r;const{captureEventsBurstLimit:o,captureEventsPerSecond:a}=this,i=new Date().getTime(),s=(t=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_property("$capture_rate_limit"))!==null&&t!==void 0?t:{tokens:o,last:i};s.tokens+=(i-s.last)/1e3*a,s.last=i,s.tokens>o&&(s.tokens=o);const l=1>s.tokens;if(l||e||(s.tokens=Math.max(0,s.tokens-1)),l&&!e){const c=(xo(s.dropped)?s.dropped:0)+1;s.dropped=c,!this.lastEventRateLimited&&this.Qa(c)&&(s.dropped=0)}return this.lastEventRateLimited=l,(r=this.instance.persistence)===null||r===void 0||r.set_property("$capture_rate_limit",s),{isRateLimited:l,remainingTokens:s.tokens}}Ja(e){const t=this.instance.config.property_denylist;return!Yt(t)||!t.includes(e)}Ka(){var e;if(this.Ja("$current_url")&&this.Ja("$pathname")&&(uo!=null&&uo.pathname))return`${(e=uo.origin)!==null&&e!==void 0?e:""}${uo.pathname}`}Qa(e){var t,n;const{captureEventsBurstLimit:r,captureEventsPerSecond:o}=this,a=this.Ka(),i=this.Ja("$session_id")?(t=(n=this.instance).get_session_id)===null||t===void 0?void 0:t.call(n):void 0,s=[`${e} event(s) dropped since the last warning`,a?`triggered on ${a}`:void 0,i?`session ${i}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${s}. Config is set to ${o} events per second and ${r} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}};const lf=mo("[RemoteConfig]");var oFe=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=$t._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Xa(e){var t,n,r;!((t=$t.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(n=$t.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}Ya(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return lf.info("Using preloaded remote config",this.remoteConfig),void this.tl(this.remoteConfig);if(this._instance.el())return void lf.warn("Remote config is disabled. Falling back to local config.");this.Xa(e=>{if(!e)return lf.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ya(t=>{this.tl(t.json,t)});this.tl(e)})}catch(e){lf.error("Error loading remote config",e),this.tl()}}tl(e,t){!e&&t&&(t.statusCode===0?t.error||lf.warn("Failed to fetch remote config from PostHog."):lf.error("Failed to fetch remote config from PostHog."));try{this._instance.tl(e?{ok:!0,config:e}:{ok:!1})}catch(r){lf.error("Error applying remote config",r)}if((e==null?void 0:e.hasFeatureFlags)!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var n;(n=this._instance.featureFlags)===null||n===void 0||n.ensureFlagsLoaded()}catch(r){lf.error("Error loading feature flags",r)}}},El=Uint8Array,rs=Uint16Array,k0=Uint32Array,Qee=new El([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Jee=new El([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Q_e=new El([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),aFe=function(e,t){for(var n=new rs(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var o=new k0(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)o[a]=a-n[r]<<5|r;return[n,o]},iFe=aFe(Qee,2),rH=iFe[1];iFe[0][28]=258,rH[258]=28;for(var J_e=aFe(Jee,0)[1],sFe=new rs(32768),ho=0;32768>ho;++ho){var gv=(43690&ho)>>>1|(21845&ho)<<1;sFe[ho]=((65280&(gv=(61680&(gv=(52428&gv)>>>2|(13107&gv)<<2))>>>4|(3855&gv)<<4))>>>8|(255&gv)<<8)>>>1}var h1=function(e,t,n){for(var r=e.length,o=0,a=new rs(t);r>o;++o)++a[e[o]-1];var i,s=new rs(t);for(o=0;t>o;++o)s[o]=s[o-1]+a[o-1]<<1;for(i=new rs(r),o=0;r>o;++o)i[o]=sFe[s[e[o]-1]++]>>>15-e[o];return i},xm=new El(288);for(ho=0;144>ho;++ho)xm[ho]=8;for(ho=144;256>ho;++ho)xm[ho]=9;for(ho=256;280>ho;++ho)xm[ho]=7;for(ho=280;288>ho;++ho)xm[ho]=8;var MN=new El(32);for(ho=0;32>ho;++ho)MN[ho]=5;var wmn=h1(xm,9),_mn=h1(MN,5),lFe=function(e){return(e/8|0)+(7&e&&1)},cFe=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof rs?rs:e instanceof k0?k0:El)(n-t);return r.set(e.subarray(t,n)),r},hd=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},a_=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Q$=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,a=n.slice();if(!o)return[new El(0),0];if(o==1){var i=new El(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(T,C){return T.f-C.f}),n.push({s:-1,f:25001});var s=n[0],l=n[1],c=0,u=1,d=2;for(n[0]={s:-1,f:s.f+l.f,l:s,r:l};u!=o-1;)s=n[n[d].f>n[c].f?c++:d++],l=n[c!=u&&n[d].f>n[c].f?c++:d++],n[u++]={s:-1,f:s.f+l.f,l:s,r:l};var f=a[0].s;for(r=1;o>r;++r)a[r].s>f&&(f=a[r].s);var g=new rs(f+1),b=oH(n[u-1],g,0);if(b>t){r=0;var v=0,y=b-t,w=1<<y;for(a.sort(function(T,C){return g[C.s]-g[T.s]||T.f-C.f});o>r;++r){var S=a[r].s;if(t>=g[S])break;v+=w-(1<<b-g[S]),g[S]=t}for(v>>>=y;v>0;){var E=a[r].s;t>g[E]?v-=1<<t-g[E]++-1:++r}for(;r>=0&&v;--r){var A=a[r].s;g[A]==t&&(--g[A],++v)}b=t}return[new El(g),b]},oH=function(e,t,n){return e.s==-1?Math.max(oH(e.l,t,n+1),oH(e.r,t,n+1)):t[e.s]=n},e1e=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new rs(++t),r=0,o=e[0],a=1,i=function(l){n[r++]=l},s=1;t>=s;++s)if(e[s]==o&&s!=t)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=e[s]}return[n.subarray(0,r),t]},i_=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},aH=function(e,t,n){var r=n.length,o=lFe(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var a=0;r>a;++a)e[o+a+4]=n[a];return 8*(o+4+r)},t1e=function(e,t,n,r,o,a,i,s,l,c,u){hd(t,u++,n),++o[256];for(var d=Q$(o,15),f=d[0],g=d[1],b=Q$(a,15),v=b[0],y=b[1],w=e1e(f),S=w[0],E=w[1],A=e1e(v),T=A[0],C=A[1],R=new rs(19),N=0;S.length>N;++N)R[31&S[N]]++;for(N=0;T.length>N;++N)R[31&T[N]]++;for(var O=Q$(R,7),P=O[0],j=O[1],D=19;D>4&&!P[Q_e[D-1]];--D);var z,L,$,U,B=c+5<<3,V=i_(o,xm)+i_(a,MN)+i,G=i_(o,f)+i_(a,v)+i+14+3*D+i_(R,P)+(2*R[16]+3*R[17]+7*R[18]);if(V>=B&&G>=B)return aH(t,u,e.subarray(l,l+c));if(hd(t,u,1+(V>G)),u+=2,V>G){z=h1(f,g),L=f,$=h1(v,y),U=v;var F=h1(P,j);for(hd(t,u,E-257),hd(t,u+5,C-1),hd(t,u+10,D-4),u+=14,N=0;D>N;++N)hd(t,u+3*N,P[Q_e[N]]);u+=3*D;for(var Z=[S,T],J=0;2>J;++J){var W=Z[J];for(N=0;W.length>N;++N)hd(t,u,F[Y=31&W[N]]),u+=P[Y],Y>15&&(hd(t,u,W[N]>>>5&127),u+=W[N]>>>12)}}else z=wmn,L=xm,$=_mn,U=MN;for(N=0;s>N;++N)if(r[N]>255){var Y;a_(t,u,z[257+(Y=r[N]>>>18&31)]),u+=L[Y+257],Y>7&&(hd(t,u,r[N]>>>23&31),u+=Qee[Y]);var q=31&r[N];a_(t,u,$[q]),u+=U[q],q>3&&(a_(t,u,r[N]>>>5&8191),u+=Jee[q])}else a_(t,u,z[r[N]]),u+=L[r[N]];return a_(t,u,z[256]),u+L[256]},Smn=new k0([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kmn=(function(){for(var e=new k0(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e})(),J$=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Emn(e,t){t===void 0&&(t={});var n=(function(){var d=4294967295;return{p(f){for(var g=d,b=0;f.length>b;++b)g=kmn[255&g^f[b]]^g>>>8;d=g},d(){return 4294967295^d}}})(),r=e.length;n.p(e);var o,a,i,s,l,c=(s=10+((o=t).filename&&o.filename.length+1||0),l=8,(function(d,f,g,b,v,y){var w=d.length,S=new El(b+w+5*(1+Math.floor(w/7e3))+v),E=S.subarray(b,S.length-v),A=0;if(!f||8>w)for(var T=0;w>=T;T+=65535){var C=T+65535;w>C?A=aH(E,A,d.subarray(T,C)):(E[T]=y,A=aH(E,A,d.subarray(T,w)))}else{for(var R=Smn[f-1],N=R>>>13,O=8191&R,P=(1<<g)-1,j=new rs(32768),D=new rs(P+1),z=Math.ceil(g/3),L=2*z,$=function(yt){return(d[yt]^d[yt+1]<<z^d[yt+2]<<L)&P},U=new k0(25e3),B=new rs(288),V=new rs(32),G=0,F=0,Z=(T=0,0),J=0,W=0;w>T;++T){var Y=$(T),q=32767&T,ne=D[Y];if(j[q]=ne,D[Y]=q,T>=J){var he=w-T;if((G>7e3||Z>24576)&&he>423){A=t1e(d,E,0,U,B,V,F,Z,W,T-W,A),Z=G=F=0,W=T;for(var se=0;286>se;++se)B[se]=0;for(se=0;30>se;++se)V[se]=0}var ie=2,ue=0,te=O,re=q-ne&32767;if(he>2&&Y==$(T-re))for(var xe=Math.min(N,he)-1,Ae=Math.min(32767,T),Me=Math.min(258,he);Ae>=re&&--te&&q!=ne;){if(d[T+ie]==d[T+ie-re]){for(var qe=0;Me>qe&&d[T+qe]==d[T+qe-re];++qe);if(qe>ie){if(ie=qe,ue=re,qe>xe)break;var ze=Math.min(re,qe-2),Ze=0;for(se=0;ze>se;++se){var Qe=T-re+se+32768&32767,ct=Qe-j[Qe]+32768&32767;ct>Ze&&(Ze=ct,ne=Qe)}}}re+=(q=ne)-(ne=j[q])+32768&32767}if(ue){U[Z++]=268435456|rH[ie]<<18|J_e[ue];var De=31&rH[ie],Ye=31&J_e[ue];F+=Qee[De]+Jee[Ye],++B[257+De],++V[Ye],J=T+ie,++G}else U[Z++]=d[T],++B[d[T]]}}A=t1e(d,E,y,U,B,V,F,Z,W,T-W,A)}return cFe(S,0,b+lFe(A)+v)})(a=e,(i=t).level==null?6:i.level,i.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+i.mem,s,l,!0)),u=c.length;return(function(d,f){var g=f.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>f.level?4:f.level==9?2:0,d[9]=3,f.mtime!=0&&J$(d,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),g){d[3]=8;for(var b=0;g.length>=b;++b)d[b+10]=g.charCodeAt(b)}})(c,t),J$(c,u-8,n.d()),J$(c,u-4,r),c}const Tmn=!!Oee||!!QS,uFe=new WeakMap,dFe="text/plain";let e9=0,w2=!1;const pFe=(e,t)=>{const[n,r]=e.split("#"),[o,a]=n.split("?");if(!a)return e;const i=a.split("&").filter(s=>s.split("=")[0]!==t).join("&");return`${o}${i?`?${i}`:""}${r?`#${r}`:""}`},pE=(e,t,n=!0)=>{var r;const[o,a]=e.split("?"),i=ce({},t),s=(r=a==null?void 0:a.split("&").map(c=>{var u;const[d,f]=c.split("="),g=n&&(u=i[d])!==null&&u!==void 0?u:f;return delete i[d],`${d}=${g}`}))!==null&&r!==void 0?r:[],l=(function(c,u="&"){let d,f;const g=[];return rr(c,function(b,v){Le(b)||Le(v)||v==="undefined"||(d=encodeURIComponent((y=>y instanceof File)(b)?b.name:b.toString()),f=encodeURIComponent(v),g[g.length]=f+"="+d)}),g.join(u)})(i);return l&&s.push(l),s.length>0?`${o}?${s.join("&")}`:o},t9=e=>{if(e.il)return e.il;const{data:t,compression:n}=e;if(!t)return;if(n===js.GZipJS){const o=Emn((function(a){var i=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var s=new El(a.length+(a.length>>>1)),l=0,c=function(g){s[l++]=g},u=0;i>u;++u){if(l+5>s.length){var d=new El(l+8+(i-u<<1));d.set(s),s=d}var f=a.charCodeAt(u);128>f?c(f):2048>f?(c(192|f>>>6),c(128|63&f)):f>55295&&57344>f?(c(240|(f=65536+(1047552&f)|1023&a.charCodeAt(++u))>>>18),c(128|f>>>12&63),c(128|f>>>6&63),c(128|63&f)):(c(224|f>>>12),c(128|f>>>6&63),c(128|63&f))}return cFe(s,0,l)})(Wv(t)),{mtime:0});return{contentType:dFe,body:o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),estimatedSize:o.byteLength}}if(n===js.Base64){const o=(function(i){return i&&btoa(encodeURIComponent(i).replace(/%([0-9A-F]{2})/g,(s,l)=>String.fromCharCode(parseInt(l,16))))})(Wv(t)),a=(i=>"data="+encodeURIComponent(typeof i=="string"?i:Wv(i)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}const r=Wv(t);return{contentType:"application/json",body:r,estimatedSize:new Blob([r]).size}},fFe=e=>{const t=()=>e.transport==="sendBeacon"?{url:pE(e.url,{compression:js.Base64}),encodedBody:t9(ce(ce({},e),{},{compression:js.Base64,il:void 0}))}:{url:pFe(e.url,"compression"),encodedBody:t9(ce(ce({},e),{},{compression:void 0,il:void 0}))};let n;try{n=t9(e)}catch(o){if(w_e(e.compression,_0(e.url,"compression")))return Je.error("Failed to gzip request body, sending uncompressed payload",o),t();throw o}return n&&w_e(e.compression,_0(e.url,"compression"))&&!((r=n.body)instanceof ArrayBuffer?FB(new Uint8Array(r)):ArrayBuffer.isView(r)&&FB(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(w2=!0,t()):{url:e.url,encodedBody:n};var r},hFe=e=>{try{return fFe(e)}catch(n){var t;return Je.error(n),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:n}))}},Amn=(function(){var e=Zr(function*(t){const n=yield(function(o){return BB.apply(this,arguments)})(Wv(t.data),ea.DEBUG,{rethrow:!0});if(!n)return t;const r=yield n.arrayBuffer();return ce(ce({},t),{},{il:{contentType:dFe,body:r,estimatedSize:r.byteLength}})});return function(t){return e.apply(this,arguments)}})(),Cmn=/Failed to fetch|NetworkError|Load failed/i,gFe=e=>(e==null?void 0:e.name)==="TypeError"&&Cmn.test((e==null?void 0:e.message)||""),mFe=e=>{try{const t=(function(n,r=Date.now()){if(typeof n!="string"||!n)return;const o=n.trim(),a=/^\d+\s*,/.test(o)?o.slice(0,o.indexOf(",")).trim():o;if(/^\d+$/.test(a)){const l=1e3*Math.min(Number(a),300);return l>0?l:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(a))return;const i=/^\w{3} \w{3} /.test(a)?a+" GMT":a,s=Date.parse(i)-r;return Number.isFinite(s)&&s>0?Math.min(s,v2):void 0})(e());return Le(t)?void 0:Math.min(t,3e4)}catch{return}},bFe=e=>{const t=hFe(e);if(!t)return;const n=new Oee;uFe.set(n,!0);const{url:r,encodedBody:o}=t;n.open(e.method||"GET",r,!0);const{contentType:a,body:i}=o??{};rr(e.headers,function(s,l){n.setRequestHeader(l,s)}),a&&n.setRequestHeader("Content-Type",a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var s;const l={statusCode:n.status,text:n.responseText};if(n.status===200)try{l.json=JSON.parse(n.responseText)}catch{}(s=e.callback)===null||s===void 0||s.call(e,l,mFe(()=>n.getResponseHeader("Retry-After")))}},n.send(i)},vFe=e=>{const t=hFe(e);if(!t)return;const{url:n,encodedBody:r}=t,{contentType:o,body:a,estimatedSize:i}=r??{},s=new Headers;rr(e.headers,function(b,v){s.append(v,b)}),o&&s.append("Content-Type",o);let l=null,c=!1;if(i_e){const b=new i_e;l={signal:b.signal,timeout:setTimeout(()=>{c=!0;try{b.abort(W9e("AbortError","PostHog request timed out"+((v=e.timeout)?` after ${v}ms`:"")))}catch(y){d(y)}var v},e.timeout)}}let u=!1;const d=b=>{var v;u||(u=!0,c&&(b==null?void 0:b.name)==="AbortError"||gFe(b)?Je.warn(b):Je.error(b),(v=e.callback)===null||v===void 0||v.call(e,{statusCode:0,error:b}))};let f=0;const g=()=>{e9-=f,f=0,l&&clearTimeout(l.timeout)};try{const b=ce({method:(e==null?void 0:e.method)||"GET",headers:s,referrerPolicy:"strict-origin",body:a,signal:l==null?void 0:l.signal},e.fetchOptions),v=i??(Le(a)?0:void 0);b.keepalive=b.method==="POST"&&!e.nl&&b.keepalive!==!1&&b.body===a&&!Le(v)&&v>=0&&52428.8>e9+v,b.keepalive&&(f=v,e9+=f),QS(n,b).then(y=>y.text().then(w=>{var S;if(u)return;const E={statusCode:y.status,text:w};if(y.status===200)try{E.json=JSON.parse(w)}catch(A){Je.error(A)}u=!0,g(),(S=e.callback)===null||S===void 0||S.call(e,E,mFe(()=>y.headers.get("Retry-After")))})).catch(y=>{g(),d(y)}).finally(g)}catch(b){g(),d(b)}},iH=e=>{try{var t;const{url:n,encodedBody:r}=fFe(e),{contentType:o,body:a,estimatedSize:i}=r??{};if(!a)return;const s=a instanceof Blob?a:new Blob([a],{type:o});if(ua.sendBeacon(n,s))return;const l=Yt(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(Yt(l)&&l.length>1&&(i??0)>16384){const c=Math.ceil(l.length/2),u=d=>Yt(e.data)?d:ce(ce({},e.data),{},{batch:d});return iH(ce(ce({},e),{},{data:u(l.slice(0,c))})),void iH(ce(ce({},e),{},{data:u(l.slice(c))}))}Je.warn(`Beacon of ~${i??0} bytes was rejected by the browser, falling back to ${QS?"fetch":"XHR"}`),QS?vFe(ce(ce({},e),{},{nl:!0})):bFe(e)}catch(n){Je.warn("Beacon send failed",n)}},n1e=(e,t,n,r)=>{const o=r==="query"?t==="POST"?"sent_at":"_":void 0;return pE(n===js.GZipJS?pFe(e,"compression"):e,ce(ce({},o?{[o]:Date.now().toString()}:{}),n===js.GZipJS?{}:{compression:n}))},Rmn=(()=>{const e=[];return QS&&e.push({transport:"fetch",method:vFe}),Oee&&e.push({transport:"XHR",method:bFe}),ua!=null&&ua.sendBeacon&&e.push({transport:"sendBeacon",method:iH}),e})();let yFe=!Tmn&&(Ri==null?void 0:Ri.indexOf("MSIE"))===-1&&(Ri==null?void 0:Ri.indexOf("Mozilla"))===-1;function xFe(e,t,n){var r,o,a;n&&(t=ce(ce({},t),{},{callback:i=>n(i)})),e.__loaded?yFe?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((o=t.callback)===null||o===void 0||o.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=ce(ce({},e.config.request_headers),t.headers),t.compression=t.compression==="best-available"?(r=e.compression)!==null&&r!==void 0?r:t.compressionFallback:t.compression,(Le(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((i,s)=>{var l,c,u;const d=ce(ce({},i),{},{callback:s??(y=>{var w;return(w=i.callback)===null||w===void 0?void 0:w.call(i,y)})});d.timeout=d.timeout||6e4;const f=(l=d.transport)!==null&&l!==void 0?l:"fetch";f==="sendBeacon"&&Le(d.compression)&&d.data&&(d.compression=js.Base64),d.method==="POST"&&d.data&&(d.timestampMode==="capture-body"?d.data=(y=>{var w,S;const E=(Yt(y)?y:[y]).map(T=>ce(ce({},T),T.timestamp instanceof Date&&!isNaN(T.timestamp.getTime())?{timestamp:T.timestamp.toISOString()}:{})),A=E[0];return{api_key:(w=A==null||(S=A.properties)===null||S===void 0?void 0:S.token)!==null&&w!==void 0?w:A==null?void 0:A.token,batch:E,sent_at:new Date().toISOString()}})(d.data):d.timestampMode==="body"&&(d.data=((y,w=new Date().toISOString())=>Yt(y)?y.map(S=>ce(ce({},S),{},{sent_at:w})):ce(ce({},y),{},{sent_at:w}))(d.data))),d.url=n1e(d.url,d.method,d.compression,d.timestampMode);const g=Rmn.filter(y=>!d.disableTransport||!y.transport||!d.disableTransport.includes(y.transport)),b=(c=(u=(function(y,w){for(let S=0;y.length>S;S++)if(w(y[S]))return y[S]})(g,y=>y.transport===f))===null||u===void 0?void 0:u.method)!==null&&c!==void 0?c:g[0].method;if(!b)throw new Error("No available transport method");const v=y=>{try{b(y)}catch(S){var w;gFe(S)?Je.warn(S):Je.error(S),(w=d.callback)===null||w===void 0||w.call(d,{statusCode:0,error:S})}};f!=="sendBeacon"&&!d.preferSyncCompression&&d.data&&d.compression===js.GZipJS&&yhn&&typeof Promise<"u"&&!w2?Amn(d).then(y=>{v(y)}).catch(y=>{if(__e(y))return w2=!0,void v(ce(ce({},d),{},{compression:void 0,url:n1e(i.url,i.method,void 0,i.timestampMode)}));(w=>{if(!w||typeof w!="object")return!1;const S="name"in w?String(w.name):"";return __e(w)||S===J9e})(y)&&(w2=!0),v(d)}):v(d)})(t,(i,s)=>{var l,c,u;e.rateLimiter.checkForLimiting(i),400>i.statusCode||(l=(c=e.config).on_request_error)===null||l===void 0||l.call(c,i),n?n(i,s):(u=t.callback)===null||u===void 0||u.call(t,i)})):t.fireCallbackOnDrop&&((a=t.callback)===null||a===void 0||a.call(t,{statusCode:0}))}var Imn=class{constructor(e,t){this.sl=!0,this.rl=[],this.ol=hu((t==null?void 0:t.flush_interval_ms)||3e3,250,5e3,Je.createLogger("flush interval"),3e3),this.al=e}enqueue(e){this.rl.push(e),this.ll||this.ul()}unload(){this.hl();const e=this.rl.length>0?this.cl():{},t=Object.values(e);[...t.filter(n=>n.url.indexOf("/e")===0),...t.filter(n=>n.url.indexOf("/e")!==0)].map(n=>{this.dl(n,"sendBeacon")})}enable(){this.sl=!1,this.ul()}ul(){this.sl||(this.ll=setTimeout(()=>{if(this.hl(),this.rl.length>0){const e=this.cl();for(const t in e)this.dl(e[t])}},this.ol))}dl(e,t){try{this.al(e,t)}catch(n){Je.error(n)}}hl(){clearTimeout(this.ll),this.ll=void 0}cl(){const e={};return rr(this.rl,t=>{var n;const r=t,o=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:"");Le(e[o])&&(e[o]=ce(ce({},r),{},{data:[]})),(n=e[o].data)===null||n===void 0||n.push(r.data)}),this.rl=[],e}};const Nmn=["retriesPerformedSoFar"];var Mmn=class{constructor(e){this._instance=e,this.vl=!1,this.fl=3e3,this.rl=[],this.rl=[],this.pl=!0,this.resume()}resume(){if(!Le(ke)&&"onLine"in ke.navigator){if(this.pl=ke.navigator.onLine,this.gl)return;this.gl=()=>{this.pl=!0,this.ml()},this.yl=()=>{this.pl=!1},Zn(ke,"online",this.gl),Zn(ke,"offline",this.yl)}}get length(){return this.rl.length}retriableRequest(e,t){let{retriesPerformedSoFar:n}=e,r=eUe(e,Nmn);yd(n)&&(r.url=pE(r.url,{retry_count:n})),xFe(this._instance,t?ce(ce({},r),{},{transport:t}):r,(o,a)=>{var i;if(o.statusCode!==200&&(400>o.statusCode||o.statusCode>=500)){if((o.statusCode===0?3:10)>(n??0))return void this.Ls(ce({retriesPerformedSoFar:n},r),a);o.statusCode===0&&Je.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${n??0} retries.`)}(i=r.callback)===null||i===void 0||i.call(r,o)})}Ls(e,t){const n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;const r=Math.max((function(i){const s=3e3*Math.pow(2,i),l=s/2,c=Math.min(18e5,s),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(n),t??0),o=Date.now()+r;this.rl.push({retryAt:o,requestOptions:e});let a=`Enqueued failed request for retry in ${r}`;navigator.onLine||(a+=" (Browser is offline)"),Je.warn(a),this.vl||(this.vl=!0,this.bl())}bl(){if(this._l&&clearTimeout(this._l),this.rl.length===0)return this.vl=!1,void(this._l=void 0);this._l=setTimeout(()=>{this.pl&&this.rl.length>0&&this.ml(),this.bl()},this.fl)}ml(){const e=Date.now(),t=[],n=this.rl.filter(r=>e>r.retryAt||(t.push(r),!1));if(this.rl=t,n.length>0)for(const{requestOptions:r}of n)this.retriableRequest(r)}unload(){this._l&&(clearTimeout(this._l),this._l=void 0),this.vl=!1,Le(ke)||(this.gl&&(ke.removeEventListener("online",this.gl),this.gl=void 0),this.yl&&(ke.removeEventListener("offline",this.yl),this.yl=void 0));for(const{requestOptions:e}of this.rl)try{this._instance._send_request(ce(ce({},e),{},{transport:"sendBeacon"}))}catch(t){Je.error(t)}this.rl=[]}},Omn=class{constructor(e){this._instance=e,this.wl=()=>{var t,n,r,o;this.kl||(this.kl={});const a=this.scrollElement(),i=this.scrollY(),s=a?Math.max(0,a.scrollHeight-a.clientHeight):0,l=i+((a==null?void 0:a.clientHeight)||0),c=(a==null?void 0:a.scrollHeight)||0;this.kl.lastScrollY=Math.ceil(i),this.kl.maxScrollY=Math.max(i,(t=this.kl.maxScrollY)!==null&&t!==void 0?t:0),this.kl.maxScrollHeight=Math.max(s,(n=this.kl.maxScrollHeight)!==null&&n!==void 0?n:0),this.kl.lastContentY=l,this.kl.maxContentY=Math.max(l,(r=this.kl.maxContentY)!==null&&r!==void 0?r:0),this.kl.maxContentHeight=Math.max(c,(o=this.kl.maxContentHeight)!==null&&o!==void 0?o:0)}}get Sl(){return this._instance.config.scroll_root_selector}getContext(){return this.kl}resetContext(){const e=this.kl;return this.kl=void 0,setTimeout(this.wl,0),e}startMeasuringScrollPosition(){Zn(ke,"scroll",this.wl,{capture:!0}),Zn(ke,"scrollend",this.wl,{capture:!0}),Zn(ke,"resize",this.wl)}scrollElement(){if(this.Sl){const n=Yt(this.Sl)?this.Sl:[this.Sl];for(const r of n){var e;const o=ke==null||(e=ke.document)===null||e===void 0?void 0:e.querySelector(r);if(o)return o}return}var t;return ke==null||(t=ke.document)===null||t===void 0?void 0:t.documentElement}xl(e){var t,n;const r=e==="y"?"scrollTop":"scrollLeft";if(this.Sl){const o=this.scrollElement();return o&&o[r]||0}return ke?e==="y"?ke.scrollY||ke.pageYOffset||((t=ke.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:ke.scrollX||ke.pageXOffset||((n=ke.document)===null||n===void 0||(n=n.documentElement)===null||n===void 0?void 0:n.scrollLeft)||0:0}scrollY(){return this.xl("y")}scrollX(){return this.xl("x")}};const Pmn=e=>eFe(e==null?void 0:e.config.mask_personal_data_properties,e==null?void 0:e.config.custom_personal_data_properties,e==null?void 0:e.config.disable_capture_url_hashes);var r1e=class{constructor(e,t,n,r){this.qe=o=>{const a=this.Cl();if(a&&a.sessionId===o)return;const i={sessionId:o,props:this.$l(this._instance)};this.Tl.register({[XB]:i})},this._instance=e,this.Il=t,this.Tl=n,this.$l=r||Pmn,this.Il.onSessionId(this.qe)}Cl(){return this.Tl.props[XB]}getSetOnceProps(){var e;const t=(e=this.Cl())===null||e===void 0?void 0:e.props;return t?"r"in t?tFe(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){const e={};return rr(Kee(this.getSetOnceProps()),(t,n)=>{n==="$current_url"&&(n="url"),e[`$session_entry_${jB(n)}`]=t}),e}},ON=class{on(e,t){return this.Ml[e]||(this.Ml[e]=[]),this.Ml[e].push(t),()=>{this.Ml[e]=this.Ml[e].filter(n=>n!==t)}}emit(e,t){for(const n of this.Ml[e]||[])n(t);for(const n of this.Ml["*"]||[])n(e,t)}constructor(){this.Ml={}}};const mv=mo("[SessionId]"),o1e=864e5;var a1e=class{on(e,t){return this.El.on(e,t)}constructor(e,t,n){var r;if(this.Pl=null,this.Rl=null,this.Al=[],this.Fl=void 0,this.Ol=!1,this.El=new ON,this.Dl=(a,i)=>!(!yd(a)||!yd(i))&&Math.abs(a-i)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=e.config,this.Tl=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Ll=void 0,this._sessionActivityTimestamp=null,this.Nl=t||oc,this.ql=n||oc;const o=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*hu(this.Mr.session_idle_timeout_seconds||1800,60,36e3,mv.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.jl(),this.Bl="ph_"+o+"_window_id",this.Hl="ph_"+o+"_primary_window_exists",this.zl()){const a=Dr.Dt(this.Bl),i=Dr.Dt(this.Hl);a&&!i?this.je=a:Dr.Lt(this.Bl),Dr.$t(this.Hl,!0)}!((r=this.Mr.bootstrap)===null||r===void 0)&&r.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Ul()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Le(this.Al)&&(this.Al=[]),this.Al.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.Al=this.Al.filter(t=>t!==e)}}zl(){return this.Mr.persistence!=="memory"&&!this.Tl.hi&&Dr.At()}Wl(e){e!==this.je&&(this.je=e,this.zl()&&Dr.$t(this.Bl,e))}Vl(){return this.je?this.je:this.zl()?Dr.Dt(this.Bl):null}Gl(e){const t=this.Pl;return!fo(t)&&!fo(e)&&5e3>Math.abs(e-t)}Zl(e,t,n){const r=t!==this._sessionActivityTimestamp,o=!(e!==this.Xt||n!==this._sessionStartTimestamp);this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Xt=e,o&&!r||o&&this.Gl(t)||(this.Pl=t,this.Tl.register({[Hv]:[t,e,n]}))}Ql(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return yd(t)&&t>0}Jl(){this.Ql()?this.Tl.refreshKey(Hv):(this.Tl.flush(),this.Tl.load())}Kl(){var e;if(fo(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Pl)return;this.Jl();const[,t,n]=this.Xl();t===this.Xt&&n===this._sessionStartTimestamp&&(this.Pl=this._sessionActivityTimestamp,this.Tl.register({[Hv]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Tl.flush())}Yl(){const[e]=this.Xl(),t=yd(e)?e:0,n=yd(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}tu(e){return this.Jl(),this.Dl(e,this.Yl())}Xl(){const e=this.Tl.props[Hv];return Yt(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Pl=null,this.Ll=void 0,clearTimeout(this.eu),this.eu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(e,t=!1){const n=((r,o=new Date().getTime())=>{try{const a=(i=>{const s=i.replace(/-/g,"");if(s.length!==32)throw new Error("Not a valid UUID");if(s[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(s.substring(0,12),16)})(r);return a>o+6e4?void mv.error("Bootstrap sessionID cannot be in the future"):a}catch(a){return void mv.error("Invalid sessionID in bootstrap",a)}})(e);return!Le(n)&&(t?this.Ll={sessionId:e,sessionStartTimestamp:n}:this.Zl(e,new Date().getTime(),n),!0)}destroy(){this.Ol=!0,this.Kl(),clearTimeout(this.eu),this.eu=void 0,this.Fl&&ke&&(ke.removeEventListener(CN,this.Fl,{capture:!1}),this.Fl=void 0),this.Al=[]}Ul(){this.Fl=()=>{this.Kl(),this.zl()&&Dr.Lt(this.Hl)},Zn(ke,CN,this.Fl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,n=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const r=t||new Date().getTime(),o=this.Xt;if(n)this.Rl=r;else if(fo(this.Rl)||this.Rl>r||r-this.Rl>=1e3){var a,i;(a=(i=this.Tl).syncCookieProperties)===null||a===void 0||a.call(i),this.Rl=r}let[,s,l]=this.Xl();const c=!Le(o)&&s!==o,u=this.Yl();let d=this.Vl();const f=this.Ll,g=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>o1e),b=f?g:yd(l)&&Math.abs(r-l)>o1e;let v=!1,y=c,w=!s||!!f;const S=s;let E=!w&&!e&&this.Dl(r,u);if(E&&(E=this.tu(r),E||mv.info("cross-tab refresh kept the session alive",{sessionId:s}),[,s,l]=this.Xl(),E||(w=!s||!!f)),w||E||b){y=!1;const R=f&&!g;s=R?f.sessionId:this.Nl(),d=this.ql(),mv.info("new session ID assigned",{sessionId:s,windowId:d,bootstrapped:!!R,changeReason:{noSessionId:w,activityTimeout:E,sessionPastMaximumLength:b}}),l=R?f.sessionStartTimestamp:r,this.Ll=void 0,v=!0}else d||(d=this.ql(),v=!0),y=y||s!==S,y&&(mv.info("adopted cross-tab session id",{sessionId:s,windowId:d}),v=!0);const A=yd(u)&&e&&!b?u:r,T=yd(l)?l:new Date().getTime();this.Wl(d),this.Zl(s,A,T),e||this.jl();const C={noSessionId:w,activityTimeout:E,sessionPastMaximumLength:b,crossTabAdoption:y};return v&&this.Al.forEach(R=>R(s,d,C)),{sessionId:s,windowId:d,sessionStartTimestamp:T,changeReason:v?C:void 0,lastActivityTimestamp:u}}jl(){this.Ol||(clearTimeout(this.eu),this.eu=setTimeout(()=>{if(!this.Ol)if(this.tu(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.El.emit("forcedIdleReset",{idleSessionId:e})}else this.jl()},1.1*this.sessionTimeoutMs))}};const wFe=function(e,t){if(!e)return!1;const n=e.userAgent;if(n&&l_e(n,t))return!0;try{const r=e==null?void 0:e.userAgentData;if(r!=null&&r.brands&&r.brands.some(o=>l_e(o==null?void 0:o.brand,t)))return!0}catch{}return!!e.webdriver};function _Fe(){return(_Fe=Zr(function*(){const e=ua==null?void 0:ua.userAgentData;if(e!=null&&e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return kn(n)&&n.length>0?n:void 0}catch(t){return void Je.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function jmn(e,t){let n=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_${t}/${e.id}/${e.current_iteration}`),n}function SFe(e){var t;return!!(!((t=e.conditions)===null||t===void 0||(t=t.events)===null||t===void 0||(t=t.values)===null||t===void 0)&&t.length)}const PN=(e,t)=>{if(!(n=>{try{new RegExp(n)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},_C=e=>e.toLowerCase(),kFe={exact:(e,t)=>t.some(n=>e.some(r=>n===r)),is_not:(e,t)=>t.every(n=>e.every(r=>n!==r)),regex:(e,t)=>t.some(n=>e.some(r=>PN(n,r))),not_regex:(e,t)=>t.every(n=>e.every(r=>!PN(n,r))),icontains:(e,t)=>t.map(_C).some(n=>e.map(_C).some(r=>n.includes(r))),not_icontains:(e,t)=>t.map(_C).every(n=>e.map(_C).every(r=>!n.includes(r))),gt:(e,t)=>t.some(n=>{const r=parseFloat(n);return!isNaN(r)&&e.some(o=>r>parseFloat(o))}),lt:(e,t)=>t.some(n=>{const r=parseFloat(n);return!isNaN(r)&&e.some(o=>r<parseFloat(o))})};function EFe(e,t){return!e||Object.entries(e).every(([n,r])=>{const o=t==null?void 0:t[n];if(o==null)return!1;const a=kFe[r.operator];return!!a&&a(r.values.map(String),[String(o)])})}function n9(e,t,n){return Wv({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}const sH="custom",i1e="i.posthog.com",Dmn=/^\/static\//,Lmn=["/s/","/e/","/i/"];var zmn=class{constructor(e){this.iu={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${i1e}`,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.iu[this.apiHost]||(this.iu[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":sH),this.iu[this.apiHost]}nu(e){if(!Dmn.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}su(e){const t=cp(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}ru(e,t,n){if(e==="ui")return n;let r=n;const o=this.instance.config.rewriteRequestPath;if(o){var a;const i=((a=cp(n))===null||a===void 0?void 0:a.href)||n;r=o(new URL(i)).toString()}if(o&&e==="api"&&Lmn.some(i=>t.indexOf(i)===0)){const i=this.su(r);if(i){const s=this.apiHost;let l=this.ou;(l==null?void 0:l.apiHost)===s&&l.rewriteRequestPath===o||(l={apiHost:s,rewriteRequestPath:o,urls:new Set},this.ou=l),l.urls.add(i)}}return r}isIngestionEndpoint(e){const t=this.ou,n=this.su(e);return(t==null?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&t.urls.has(n)}endpointFor(e,t=""){if(t&&(t=t[0]==="/"?t:`/${t}`),e==="ui")return this.ru(e,t,this.uiHost+t);if(e==="flags")return this.ru(e,t,this.flagsApiHost+t);if(e==="assets"){const r=this.nu(t);if(r)return this.ru(e,t,`${r}${t}`)}if(this.region===sH)return this.ru(e,t,this.apiHost+t);const n=i1e+t;switch(e){case"assets":return this.ru(e,t,`https://${this.region}-assets.${n}`);case"api":return this.ru(e,t,`https://${this.region}.${n}`)}}};const Qn=mo("[Surveys]"),TFe=e=>{try{const t=(n=>((r,o)=>`seenSurvey_${(function(a){return a.current_iteration&&a.current_iteration>0?`${a.id}_${a.current_iteration}`:a.id})(o)}`)(0,n))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(t){Qn.error("Failed to persist survey seen state",t)}},$mn=[X$.Popover,X$.Widget,X$.API],Umn={ignoreConditions:!1,ignoreDelay:!1,displayType:nH.Popover},Fmn=mo("[PostHog ExternalIntegrations]"),Bmn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Hmn=class{constructor(e){this._instance=e}Bo(e,t){var n,r;(n=$t.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,e,o=>{if(o)return Fmn.error("failed to load script",o);t()})}startIfEnabledOrStop(){var e;for(const[o,a]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var t,n,r;a&&!(!((t=$t.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[o])&&this.Bo(Bmn[o],()=>{var i;(i=$t.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[o])===null||i===void 0||i.start(this._instance)}),!a&&(!((n=$t.__PosthogExtensions__)===null||n===void 0||(n=n.integrations)===null||n===void 0)&&n[o])&&((r=$t.__PosthogExtensions__)===null||r===void 0||(r=r.integrations)===null||r===void 0||(r=r[o])===null||r===void 0||r.stop())}}},Vmn=class{constructor(e,t){this.A=e,this.yo=t,this.au=new Map,this.$o=!1}add(e){var t=this;return Zr(function*(){if(t.$o)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.au.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);t.au.set(e.name,e);try{const n=e.setup(t.yo);n&&(yield n)}catch(n){const r=t.au.get(e.name)===e;r&&t.au.delete(e.name),t.A.error(`Failed to set up browser extension "${e.name}"`,n),r&&t.lu(e)}})()}getExtension(e){return this.au.get(e)}dispose(){if(this.$o)return;this.$o=!0;const e=Array.from(this.au.values()).reverse();this.au.clear();for(const t of e)this.lu(t)}lu(e){try{var t;const n=(t=e.dispose)===null||t===void 0?void 0:t.call(e);n&&ca(n.then)&&n.then(void 0,r=>{this.A.error(`Failed to dispose browser extension "${e.name}"`,r)})}catch(n){this.A.error(`Failed to dispose browser extension "${e.name}"`,n)}}},Gmn=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if(typeof e=="string")return t==null?void 0:t.get_property(e);const n={};for(const r of e){const o=t==null?void 0:t.get_property(r);Le(o)||(n[r]=o)}return n}set(e,t){var n;(n=this._instance.persistence)===null||n===void 0||n.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)===null||t===void 0||t.unregister(e)}};const s1e="extensionsRemoteConfig";var Wmn=class{constructor(e){this.instance=e,this.$o=!1,this.A=Je,this.uu=e.hu,this.kv=new Gmn(e),this.onEvent=t=>wC(this.instance.on("eventCaptured",n=>{try{t({event:n.event,properties:n.properties})}catch(r){this.A.error("Browser extension event listener failed",r)}})),this.onRemoteConfig=t=>{if(this.$o)return wC(()=>{});const n=o=>{try{t(o)}catch(a){this.A.error("Browser extension remote config listener failed",a)}},r=this.instance.cu.on(s1e,n);return this.uu&&n(this.uu),wC(r)},this.du=new Vmn(Je.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){const e=this.instance.get_property($ee);return typeof e=="string"?e:void 0}get library(){return{name:ea.LIB_NAME,version:ea.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)===null||t===void 0?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,n,r;const o=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=o==null?void 0:o.sessionId)!==null&&t!==void 0?t:"",windowId:(n=o==null?void 0:o.windowId)!==null&&n!==void 0?n:"",sessionStartTimestamp:(r=o==null?void 0:o.sessionStartTimestamp)!==null&&r!==void 0?r:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.du.add(e)}getExtension(e){return this.du.getExtension(e)}capture(e,t,n){n?this.instance.capture(e,t,{timestamp:n.timestamp,uuid:n.uuid,$set:n.set,$set_once:n.setOnce}):this.instance.capture(e,t)}registerDynamicEventProperties(e){return wC(this.instance.vu(e))}handleRemoteConfig(e){this.$o||(this.uu=e,this.instance.cu.emit(s1e,e))}sendRequest(e){var t=this;return Zr(function*(n,r={}){var o;const a=t.instance.requestRouter.endpointFor((o=r.target)!==null&&o!==void 0?o:"api",n),i={method:r.method,url:r.query?pE(a,r.query):a,data:r.body,headers:r.headers,timeout:r.timeoutMs,fireCallbackOnDrop:!0,transport:r.transport,compression:r.compression,compressionFallback:r.target==="flags"&&r.compression==="best-available"?PB.Base64:void 0,timestampMode:r.sentAt};return r.transport==="sendBeacon"?(t.instance._send_request(i),{statusCode:202}):new Promise(s=>{i.callback=s,t.instance._send_request(i)})}).apply(this,arguments)}dispose(){this.$o||(this.$o=!0,this.du.dispose())}};const g1={};let r9=0;const m1=()=>{},l1e='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',bv="Surveys module not available",c1e="sanitize_properties is deprecated. Use before_send instead",AFe="Invalid value for property_denylist config: ",Kmn=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],Ymn=["$feature_flag_called","$$heatmap","$snapshot"],u1e=e=>e.charAt(0)==="$"&&!Kt(Ymn,e),Zmn=/^[A-Za-z0-9_-]{1,400}$/,d1e=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,p1e=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Xmn=["token","distinct_id",_Ue],E_="posthog",qmn=e=>{const t={};return e&&e!=="unset"&&("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0)),t},o9=e=>{var t;return ce({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Ygn(Fe==null?void 0:Fe.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:m1,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:uo&&kn(uo==null?void 0:uo.search)&&uo.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(ke==null||(t=ke.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(n){Je.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:MUe,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:m1},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:nmn,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:qmn(n),external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n),cookieWinsOnConflict:!(!n||n==="unset"||"2026-08-29">n)}))(e))},Qmn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],f1e=e=>{const t={};for(const[o,a]of Qmn)Le(e[o])||(t[a]=e[o]);const n=Kr({},t,e),r=e.__preview_external_dependency_versioned_paths;return Le(r)||(Le(e.strict_script_versioning)&&(n.strict_script_versioning=!!r),kn(r)&&Le(e.asset_host)&&(n.asset_host=r)),Yt(e.property_blacklist)&&(Le(e.property_denylist)?n.property_denylist=e.property_blacklist:Yt(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Je.error(AFe+e.property_denylist)),n};var Jmn=class{constructor(){this.__forceAllowLocalhost=!1}get fu(){return this.__forceAllowLocalhost}set fu(e){Je.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},b1=class ff{pu(t){if(!t)return;const n=this.au.indexOf(t);n!==-1&&this.au.splice(n,1)}gu(t,n){var r;return this.pu(t),this.au.push(n),(r=n.initialize)===null||r===void 0||r.call(n),n}mu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}yu(){if(this.bu||this.config.reuseAnonymousId||this.config.segment||this.mu())return;const t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this._u)return;let n,r,o;t?(n=`persistence is set to '${this.config.persistence}'`,r=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",o="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(n="persistence is disabled (disable_persistence is true)",r="on every page load",o="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.bu=!0,console.warn("[PostHog.js]",`${n} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${r}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${o}`)}wu(){if(this.mu()||this.get_distinct_id()!=="$posthog_cookieless")return;const t=this.persistence;if(!t)return;this.ku()||t.load(!0);const n=this.get_distinct_id();if(!n||n==="$posthog_cookieless"){const r=this.config.get_device_id(oc());this.register({distinct_id:r,$device_id:r}),t.set_property(Ii,Id)}this.Su()}get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.xu=!1,this.Cu=!1,this.webPerformance=new Jmn,this.$u=!1,this.version=ea.LIB_VERSION,this.Tu=new Set,this.Iu="",this.cu=new ON,this.au=[],this.Mu=[],this.Eu=!1,this._u=!1,this.bu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=o9(),this.SentryIntegration=umn,this.sentryIntegration=r=>(function(o,a){const i=WUe(o,a);return{name:GUe,processEvent:s=>i(s)}})(this,r),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Pu=!1,this.Ru=null,this.Au=null,this.Fu=null,this.scrollManager=new Omn(this),this.pageViewManager=new K_e(this),this.rateLimiter=new xmn(this),this.requestRouter=new zmn(this),this.consent=new tmn(this),this.externalIntegrations=new Hmn(this);const n=(t=ff.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(r,o,a)=>{const i=kn(r)?{[r]:o}:r;this.setPersonProperties(i),a==null||a({})},set_once:(r,o,a)=>{const i=kn(r)?{[r]:o}:r;this.setPersonProperties(void 0,i),a==null||a({})}},this.on("eventCaptured",r=>Je.info(`send "${r==null?void 0:r.event}"`,r))}init(t,n,r){if(r&&r!==E_){var o;const a=(o=g1[r])!==null&&o!==void 0?o:new ff;return a._init(t,n,r),g1[r]=a,g1[E_][r]=a,a}return this._init(t,n,r)}_init(t,n={},r){var o,a,i;const s=kn(t)?t.trim():"";if(!s)return Je.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return s!==((l=this.config)===null||l===void 0?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${s}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=o9(n.defaults),n.debug=this.Ou(n.debug),this.Du=n,this.Lu=[],n.person_profiles?this.Au=n.person_profiles:n.process_person&&(this.Au=n.process_person);const c=o9(n.defaults),u=f1e(n),d=Kr({},c,u,{name:r,token:s});Rn(c.rageclick)&&Rn(u.rageclick)&&(d.rageclick=Kr({},c.rageclick,u.rageclick)),Rn(c.session_recording)&&Rn(u.session_recording)&&(d.session_recording=Kr({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Je.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:js.GZipJS;const f=this.ku();if(this.persistence=new Z$(this.config,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Z$(ce(ce({},this.config),{},{persistence:"sessionStorage"}),f,!1),this.Iu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!f&&Dr.At()){const w=Dr.Dt(this.Iu);Yt(w)&&w.forEach(S=>{kn(S)&&this.Tu.add(S)})}else Dr.Lt(this.Iu);const g=ce({},this.persistence.props),b=ce({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Nu=new Imn((w,S)=>this.qu(w,S),this.config.request_queue_config),this.ju=new Mmn(this),this.__request_queue=[];const v=this.mu();v||(this.sessionManager=new a1e(this),this.sessionPropsManager=new r1e(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((w,S,E)=>{(E!=null&&E.activityTimeout||E!=null&&E.sessionPastMaximumLength||E!=null&&E.crossTabAdoption)&&this.Bu()})),this.Hu(),this.config.__preview_deferred_init_extensions?(Je.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.zu(v)},0)):(Je.info("Initializing extensions synchronously"),this.zu(v)),ea.DEBUG=ea.DEBUG||this.config.debug,ea.DEBUG&&Je.info("Starting in debug mode",{this:this,config:n,thisC:ce({},this.config),p:g,s:b}),this.config.identity_distinct_id&&!(!((o=n.bootstrap)===null||o===void 0)&&o.distinctID)&&(n.bootstrap=ce(ce({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const y=(a=n.bootstrap)===null||a===void 0?void 0:a.distinctID;if(this._u=!!y&&!i1(y),(i=n.bootstrap)===null||i===void 0?void 0:i.distinctID){const w=n.bootstrap.distinctID,S=this.get_distinct_id(),E=this.persistence.get_property(Ii);if(n.bootstrap.isIdentifiedID&&S!=null&&S!==w&&E==="anonymous")this.identify(w);else if(n.bootstrap.isIdentifiedID&&S!=null&&S!==w&&E==="identified")Je.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const A=this.config.get_device_id(oc()),T=n.bootstrap.isIdentifiedID?A:w;this.persistence.set_property(Ii,n.bootstrap.isIdentifiedID?y2:Id),this.register({distinct_id:w,$device_id:T})}}if(v)this.register_once({distinct_id:F$,$device_id:null},"");else if(!this.get_distinct_id()){const w=this.config.get_device_id(oc());this.register_once({distinct_id:w,$device_id:w},""),this.persistence.set_property(Ii,Id)}return Zn(ke,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Zn(ke,"pageshow",()=>{var w;this.xu=!1,this.Cu||(w=this.ju)===null||w===void 0||w.resume()}),n.segment?W_e(this,()=>this.Uu()):this.Uu(),ca(this.config._onCapture)&&this.config._onCapture!==m1&&(Je.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",w=>this.config._onCapture(w.event,w))),this.config.ip&&Je.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return _Fe.apply(this,arguments)})().then(w=>{w&&this.register({[U$]:w})}).catch(m1),this}Wu(t){const n=t;return kn(n.name)&&ca(n.setup)}Vu(t,n){this.Wu(t)?n.push(()=>{this.Gu().add(t).catch(()=>{var r;return(r=t.dispose)===null||r===void 0?void 0:r.call(t)}).catch(r=>{Je.error(`Failed to dispose browser extension "${t.name}"`,r)})}):this.au.push(t)}Hu(){var t,n,r;const o=(t=(n=this.config.__extensionClasses)===null||n===void 0?void 0:n.featureFlags)!==null&&t!==void 0?t:(r=ff.__defaultExtensionClasses)===null||r===void 0?void 0:r.featureFlags;var a,i,s;o&&(this.featureFlags&&this.featureFlags instanceof o||((a=this.Zu)===null||a===void 0||a.call(this),this.Zu=void 0,this.featureFlags=new o(this)),ca(this.featureFlags.onReloading)&&ca(this.featureFlags.setup)?this.Zu||(this.Zu=this.featureFlags.onReloading(()=>{this.cu.emit("featureFlagsReloading",!0)}),this.Gu().add(this.featureFlags)):(i=(s=this.featureFlags).initialize)===null||i===void 0||i.call(s))}zu(t){const n=performance.now(),r=ce(ce({},ff.__defaultExtensionClasses),this.config.__extensionClasses),o=[];var a,i,s,l,c,u,d;r.exceptions&&this.au.push(this.exceptions=(a=this.exceptions)!==null&&a!==void 0?a:new r.exceptions(this)),r.historyAutocapture&&this.au.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.au.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.au.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.au.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||o.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.autocapture&&this.Vu(this.autocapture=new r.autocapture(this),o),r.surveys&&this.Vu(this.surveys=(i=this.surveys)!==null&&i!==void 0?i:new r.surveys(this),o),r.logs&&this.Vu(this.logs=(s=this.logs)!==null&&s!==void 0?s:new r.logs(this),o),r.metrics&&this.au.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new r.metrics(this)),r.conversations&&this.au.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new r.conversations(this)),r.productTours&&this.au.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.au.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.au.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.au.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.au.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,cmn)),r.toolbar&&this.au.push(this.toolbar=(u=this.toolbar)!==null&&u!==void 0?u:new r.toolbar(this)),r.experiments&&this.au.push(this.experiments=(d=this.experiments)!==null&&d!==void 0?d:new r.experiments(this)),this.au.forEach(f=>{f.initialize&&o.push(()=>{var g;(g=f.initialize)===null||g===void 0||g.call(f)})}),o.push(()=>{if(this.Qu){const f=this.Qu;this.Qu=void 0,this.au.forEach(g=>{var b;return(b=g.onRemoteConfig)===null||b===void 0?void 0:b.call(g,f)})}}),this.Ju(o,n)}Ju(t,n){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&t.length>0)return void setTimeout(()=>{this.Ju(t,n)},0);const o=t.shift();if(o)try{o()}catch(a){Je.error("Error initializing extension:",a)}}const r=Math.round(performance.now()-n);this.register_for_session({[SUe]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[kUe]:r}),this.config.__preview_deferred_init_extensions&&Je.info(`PostHog extensions initialized (${r}ms)`)}tl(t){var n;if(!Fe||!Fe.body)return Je.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.tl(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Qu=t),this.hu=t,this.compression=void 0,t.ok){var r;const o=t.config;o.supportedCompression&&!this.config.disable_compression&&(this.compression=Kt(o.supportedCompression,js.GZipJS)?js.GZipJS:Kt(o.supportedCompression,js.Base64)?js.Base64:void 0),!((r=o.analytics)===null||r===void 0)&&r.endpoint&&(this.analyticsDefaultEndpoint=o.analytics.endpoint)}this.set_config({person_profiles:this.Au?this.Au:MUe}),(n=this.Ku)===null||n===void 0||n.handleRemoteConfig(t),this.au.forEach(o=>{var a;return(a=o.onRemoteConfig)===null||a===void 0?void 0:a.call(o,t)})}Uu(){try{this.config.loaded(this)}catch(t){Je.critical("`loaded` function failed",t)}if(this.Xu(),this.config.internal_or_test_user_hostname&&(uo==null?void 0:uo.hostname)){const t=uo.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?t===n:n.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.mu())&&this.Yu()},1),this.th=new oFe(this),this.th.load()}Xu(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Nu)===null||t===void 0||t.enable())}_dom_loaded(){this.is_capturing()&&Gv(this.__request_queue,t=>this.qu(t)),this.__request_queue=[],this.Xu()}_handle_unload(){var t,n,r,o,a,i;this.xu=!0,(t=this.surveys)===null||t===void 0||(n=t.handlePageUnload)===null||n===void 0||n.call(t),(r=this.metrics)===null||r===void 0||r.flush("sendBeacon"),this.config.request_batching?(this.eh()&&this.capture(I_e),(o=this.logs)===null||o===void 0||o.flushLogs("sendBeacon"),(a=this.Nu)===null||a===void 0||a.unload(),(i=this.ju)===null||i===void 0||i.unload()):this.eh()&&this.capture(I_e,null,{transport:"sendBeacon"})}_send_request(t){xFe(this,t)}qu(t,n){this.ju?this.ju.retriableRequest(t,n):this._send_request(n?ce(ce({},t),{},{transport:n}):t)}_execute_array(t){r9++;try{let n;const r=[],o=[],a=[];Gv(t,s=>{if(s)if(n=s[0],Yt(n))a.push(s);else if(ca(s))try{s.call(this)}catch(l){Je.error("Error executing queued PostHog call",s,l)}else Yt(s)&&n==="alias"?r.push(s):Yt(s)&&n.indexOf("capture")!==-1&&ca(this[n])?a.push(s):o.push(s)});const i=function(s,l){Gv(s,function(c){try{if(Yt(c[0])){let u=l;rr(c,function(d){u=u[d[0]].apply(u,d.slice(1))})}else l[c[0]].apply(l,c.slice(1))}catch(u){Je.error("Error executing queued PostHog call",c,u)}})};i(r,this),i(o,this),i(a,this)}finally{r9--}}push(t){if(r9>0&&Yt(t)&&kn(t[0])){const n=ff.prototype[t[0]];return void(ca(n)&&n.apply(this,t.slice(1)))}this._execute_array([t])}get ih(){return{property:C_e,persistenceKey:vy,cookieName:"_fbc",pattern:d1e,register:(t,n)=>{var r;return(r=this.persistence)===null||r===void 0?void 0:r.register({[vy]:{value:t,delivered:n}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(vy)}}}get nh(){return{property:R_e,persistenceKey:l1,cookieName:"_fbp",pattern:p1e,register:(t,n)=>{var r;return(r=this.persistence)===null||r===void 0?void 0:r.register({[l1]:{value:t,delivered:n}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(l1)}}}sh(t){var n;const r=(n=this.persistence)===null||n===void 0?void 0:n.get_property(t.persistenceKey);return kn(r)&&t.pattern.test(r)?{value:r,delivered:!1}:Rn(r)&&kn(r.value)&&t.pattern.test(r.value)?{value:r.value,delivered:r.delivered===!0}:void 0}rh(t,n,r){return n===(r==null?void 0:r.value)?{value:n,pending:!r.delivered}:(t.register(n,!1),{value:n,pending:!0})}oh(t){if(!this.config.save_campaign_params||this.mu())return;const n=d1(t.cookieName);return kn(n)&&t.pattern.test(n)?n:void 0}ah(t,n,r,o){if(!this.persistence)return;const a=this.ih;this.persistence.refreshKey(a.persistenceKey);const i=this.sh(a);if(o)return void a.unregister();if(r)return kn(n)&&d1e.test(n)?this.rh(a,n,i):void a.unregister();const s=kn(t)&&Zmn.test(t)?t:void 0,l=this.oh(a);return l&&((c,u,d)=>{const f=c.split(".");if(u)return f[3]===u;if(!d)return!0;const g=d.value.split(".");return f[3]===g[3]||Number(f[2])>Number(g[2])})(l,s,i)?this.rh(a,l,i):s?(i==null?void 0:i.value.split(".")[3])===s?{value:i.value,pending:!i.delivered}:this.rh(a,`fb.1.${Date.now()}.${s}`,i):i?{value:i.value,pending:!i.delivered}:void 0}uh(t,n,r){if(!this.persistence)return;const o=this.nh;this.persistence.refreshKey(o.persistenceKey);const a=this.sh(o);if(r)return void o.unregister();if(n)return kn(t)&&p1e.test(t)?this.rh(o,t,a):void o.unregister();const i=this.oh(o);return i?this.rh(o,i,a):a?{value:a.value,pending:!a.delivered}:void 0}hh(t,n){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const r=this.sh(t);(r==null?void 0:r.value)!==n||r.delivered||t.register(n,!0)}capture(t,n,r){var o,a;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Nu))return void Je.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(Le(t)||!kn(t))return void Je.error("No event name provided to posthog.capture");this.wu();const i=!this.config.opt_out_useragent_filter&&this._is_bot();if(i&&!this.config.__preview_capture_bot_pageviews)return;const s=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s!=null&&s.isRateLimited)return void Je.critical("This capture call is ignored due to client rate limiting.");let l;n!=null&&n.$current_url&&!kn(n==null?void 0:n.$current_url)&&(Je.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),t!=="$exception"||r!=null&&r.dh||Je.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const c=new Date,u=(r==null?void 0:r.timestamp)||c,d=p_e(r==null?void 0:r.uuid,oc);let f={uuid:d,event:t,properties:this.calculateEventProperties(t,n||{},u,d)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&i&&(f.event="$bot_pageview",f.properties.$browser_type="bot"),s&&(f.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens);const g=t==="$feature_flag_called"&&f.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;r!=null&&r.$set&&!g&&(f.$set=r==null?void 0:r.$set);const b=Rn(n==null?void 0:n.$set)?n.$set:void 0,v=Yt(n==null?void 0:n.$unset)?n.$unset:[],y=(r==null?void 0:r.$unset)||[],w=L=>{var $;const U=!!(r!=null&&r.$set)&&L in r.$set;return{hasProvided:U||!!b&&L in b,provided:U?r==null||($=r.$set)===null||$===void 0?void 0:$[L]:b==null?void 0:b[L],unset:v.indexOf(L)!==-1||y.indexOf(L)!==-1}},S=w(C_e),E=w(R_e),A=[{channel:this.ih,hasProvided:S.hasProvided,update:this.ah(l==null?void 0:l.fbclid,S.provided,S.hasProvided,S.unset)},{channel:this.nh,hasProvided:E.hasProvided,update:this.uh(E.provided,E.hasProvided,E.unset)}];for(const{channel:L,hasProvided:$,update:U}of A)U&&f.properties.$process_person_profile===!0&&U.pending&&!$&&!g&&(f.$set=ce({[L.property]:U.value},f.$set));const T=r==null?void 0:r.$unset;T&&(f.$unset=T);const C=g?void 0:this.fh(r==null?void 0:r.$set_once,t!==N_e,t===OUe);if(C&&(f.$set_once=C),r!=null&&r._noTruncate||(R=this.config.properties_string_max_length,f=(function(L,$){const U=new Set;return(function B(V,G){if(V!==Object(V))return $?$(V):V;if(U.has(V))return;let F;if(U.add(V),Yt(V))F=[],Gv(V,Z=>{F.push(B(Z))});else{const Z={};rr(wx(V)?PUe(V):V,(J,W)=>{U.has(J)||(Z[W]=B(J))}),F=Z}return F})(L)})(f,L=>kn(L)?L.slice(0,R):L)),f.timestamp=u,Le(r==null?void 0:r.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=c),g&&(f.properties=((L,$=[])=>{const U={},B=V=>{L[V]!==void 0&&(U[V]=L[V])};return hgn.forEach(B),$.forEach(B),U})(f.properties,Xmn)),t===Ns.DISMISSED||t===Ns.SENT){const L=n==null?void 0:n[q$.SURVEY_ID],$=n==null?void 0:n[q$.SURVEY_ITERATION];TFe({id:L,current_iteration:$}),f.$set=ce(ce({},f.$set),{},{[jmn({id:L,current_iteration:$},t===Ns.SENT?"responded":"dismissed")]:!0})}else t===Ns.SHOWN&&(f.$set=ce(ce({},f.$set),{},{[q$.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var R;if(t===ymn.SHOWN){const L=n==null?void 0:n[X_e.TOUR_TYPE];L&&(f.$set=ce(ce({},f.$set),{},{[`${X_e.TOUR_LAST_SEEN_DATE}/${L}`]:new Date().toISOString()}))}const N=ce(ce({},f.properties.$set),f.$set);if(Qi(N)||this.setPersonPropertiesForFlags(N),!sn(this.config.before_send)){const L=this.Os(f);if(!L)return;f=L,f.uuid=p_e(f.uuid,oc)}this.sessionRecording&&!this.Eu&&u1e(t)&&(this.Eu=!0,setTimeout(()=>this.Eu=!1,3e4));const O=A.filter(({channel:L,update:$})=>{var U,B,V;const G=(U=(B=f.$set)===null||B===void 0?void 0:B[L.property])!==null&&U!==void 0?U:Rn((V=f.properties)===null||V===void 0?void 0:V.$set)?f.properties.$set[L.property]:void 0;return($==null?void 0:$.pending)&&G===$.value});this.cu.emit("eventCaptured",f);const P=(o=r==null?void 0:r._url)!==null&&o!==void 0?o:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),j=(r==null?void 0:r._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(P),D=ce(ce(ce({method:"POST",url:P,data:f,compression:"best-available",preferSyncCompression:r==null?void 0:r.send_instantly,timestampMode:j?"body":"capture-body",batchKey:r==null?void 0:r._batchKey},j&&(!((a=f.properties)===null||a===void 0)&&a.$session_id)?{batchGroup:f.properties.$session_id+(f.properties.$window_id?`-${f.properties.$window_id}`:"")}:{}),r!=null&&r.transport?{transport:r.transport}:{}),O.length?{fireCallbackOnDrop:!0,callback:L=>{if(L.statusCode>=200&&300>L.statusCode)for(const{channel:$,update:U}of O)this.hh($,U.value)}}:{});if(!this.config.request_batching||r&&!(r!=null&&r._batchKey)||r!=null&&r.send_instantly||O.length){var z;let L;!D.transport&&!D.callback&&Qi((z=this.config.request_headers)!==null&&z!==void 0?z:{})&&this.xu&&(L="sendBeacon"),this.qu(D,L)}else this.Nu.enqueue(D);return f}_addCaptureHook(t){return this.on("eventCaptured",n=>t(n.event,n))}getExtension(t){var n;return(n=this.Ku)===null||n===void 0?void 0:n.getExtension(t)}Gu(){var t;return(t=this.Ku)!==null&&t!==void 0?t:this.Ku=new Wmn(this)}vu(t){this.Mu.push(t);let n=!0;return()=>{if(!n)return;n=!1;const r=this.Mu.indexOf(t);r!==-1&&this.Mu.splice(r,1)}}ph(t=!0){var n,r,o;return!!(!((n=this.persistence)===null||n===void 0)&&n.consumeCookieIdentityChange())&&(this.Fu=null,this.persistence.get_property("$user_state")==="anonymous"&&((o=this.sessionPersistence)===null||o===void 0||o.clear(),this.Tu.clear(),this.gh()),(r=this.featureFlags)===null||r===void 0||r.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,r,o,a){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.ph();const i=a?void 0:this.persistence.remove_event_timer(t);let s=ce({},n);if(s.token=this.config.token,s.$config_defaults=this.config.defaults,this.mu()&&(s[_Ue]=!0),t==="$snapshot"){const S=ce(ce({},this.persistence.properties()),this.sessionPersistence.properties());return s.distinct_id=S.distinct_id,(!kn(s.distinct_id)&&!xo(s.distinct_id)||i1(s.distinct_id))&&Je.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}const l=(function(S,E,A,T=!1){var C,R,N,O;if(!Ri)return{};const P=S?[...S0,...E||[]]:[],[j,D]=B9e(Ri),[z,L]=(function(Y){for(let q=0;d_e.length>q;q++){const[ne,he,se]=d_e[q],ie=Y.match(ne);if(ie){const ue=se&&Y.match(se)||ie;return[he,(ue==null?void 0:ue[1])||""]}}return["",""]})(Ri),$=(function(){const Y="u">typeof navigator?navigator:void 0;return Y!=null&&Y.brave?{brave:!0}:{}})(),U={};Le(A)||(U.detectGoogleSearchApp=A);const B={},V=(C=navigator)===null||C===void 0||(C=C.userAgentData)===null||C===void 0?void 0:C.platform,G=(R=navigator)===null||R===void 0?void 0:R.maxTouchPoints,F=ke==null||(N=ke.screen)===null||N===void 0?void 0:N.width,Z=ke==null||(O=ke.screen)===null||O===void 0?void 0:O.height,J=ke==null?void 0:ke.devicePixelRatio;Le(V)||(B.userAgentDataPlatform=V),Le(G)||(B.maxTouchPoints=G),Le(F)||(B.screenWidth=F),Le(Z)||(B.screenHeight=Z),Le(J)||(B.devicePixelRatio=J);const W=Kr(Kee({$os:j,$os_version:D,$browser:F9e(Ri,navigator.vendor,$,U),$webview_app:z,$webview_app_version:L,$device:H9e(Ri),$device_type:Dhn(Ri,B),$timezone:nFe(),$timezone_offset:mmn()}),{$current_url:ok(T?eh(uo==null?void 0:uo.href):uo==null?void 0:uo.href,P,ak),$host:uo==null?void 0:uo.host,$pathname:uo==null?void 0:uo.pathname,$raw_user_agent:Ri.length>1e3?Ri.substring(0,997)+"...":Ri,$browser_version:jhn(Ri,navigator.vendor,$,U),$browser_language:QUe(),$browser_language_prefix:gmn(),$screen_height:ke==null?void 0:ke.screen.height,$screen_width:ke==null?void 0:ke.screen.width,$viewport_height:ke==null?void 0:ke.innerHeight,$viewport_width:ke==null?void 0:ke.innerWidth,$lib:Hd.LIB_NAME,$lib_version:Hd.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Hd.SDK_DIST_CHANNEL&&(W.$sdk_dist_channel=Hd.SDK_DIST_CHANNEL),W})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:S,windowId:E}=this.sessionManager.checkAndGetSessionAndWindowId(a,r.getTime(),!0);s.$session_id=S,s.$window_id=E}this.sessionPropsManager&&Kr(s,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const S=this.sessionRecording.sdkDebugProperties,E=!this.Eu&&u1e(t);for(const A in S)(E||Kt(Kmn,A))&&(s[A]=S[A])}s.$sdk_debug_retry_queue_size=(c=this.ju)===null||c===void 0?void 0:c.length}catch(S){s.$sdk_debug_error_capturing_properties=String(S)}let u;if(this.requestRouter.region===sH&&(s.$lib_custom_api_host=this.config.api_host),u=t!=="$pageview"||a?t!=="$pageleave"||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),s=Kr(s,u),t==="$pageview"&&Fe&&(s.title=Fe.title),!Le(i)){const S=r.getTime()-i;s.$duration=parseFloat((S/1e3).toFixed(3))}Ri&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),f=this.sessionPersistence.properties(),g=s.$groups,b=d.$groups;Rn(g)&&!Qi(g)&&(s.$groups=ce(ce({},Rn(b)?b:{}),g)),rr(["$referrer","$referring_domain"],S=>{S in d&&delete f[S]});const v={};if(this.Mu.length>0)for(const S of this.Mu.slice())try{Kr(v,S())}catch(E){Je.error("Failed to produce browser extension event properties",E)}s=Kr({},l,d,f,ce(ce({},v),s)),s.$is_identified=this._isIdentified(),Yt(this.config.property_denylist)?rr(this.config.property_denylist,function(S){delete s[S]}):Je.error(AFe+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(Je.error(c1e),s=y(s,t));const w=this.mh();return s.$process_person_profile=w,w&&!a&&this.yh("_calculate_event_properties"),s}fh(t,n=!0,r=!1){var o;if(!this.persistence||!this.mh()||this.$u&&!r)return t;const a=this.persistence.get_initial_props(),i=(o=this.sessionPropsManager)===null||o===void 0?void 0:o.getSetOnceProps();let s=Kr({},a,i||{},t||{});const l=this.config.sanitize_properties;return l&&(Je.error(c1e),s=l(s,"$set_once")),n&&(this.$u=!0),Qi(s)?void 0:s}register(t,n){var r;(r=this.persistence)===null||r===void 0||r.register(t,n)}register_once(t,n,r){var o;(o=this.persistence)===null||o===void 0||o.register_once(t,n,r)}register_for_session(t){var n,r;(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.ph(),(r=this.sessionPersistence)===null||r===void 0||r.register(t),Object.keys(t).forEach(o=>this.Tu.add(o)),this.gh()}unregister(t){var n;(n=this.persistence)===null||n===void 0||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(t),this.Tu.delete(t),this.gh()}bh(t,n){this.register({[t]:n})}Bu(){this.Tu.forEach(t=>{var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(t)}),this.Tu.clear(),this.gh()}gh(){var t;if(!this.Iu)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.hi||!Dr.At())return void Dr.Lt(this.Iu);const n=[];this.Tu.forEach(r=>n.push(r)),n.length>0?Dr.$t(this.Iu,n):Dr.Lt(this.Iu)}getFeatureFlag(t,n){var r;return(r=this.featureFlags)===null||r===void 0?void 0:r.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getFeatureFlagPayload(t)}getFeatureFlagResult(t,n){var r;return(r=this.featureFlags)===null||r===void 0?void 0:r.getFeatureFlagResult(t,n)}getAllFeatureFlags(){var t,n;return(t=(n=this.featureFlags)===null||n===void 0?void 0:n.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,n){var r,o;return(r=(o=this.featureFlags)===null||o===void 0?void 0:o.isFeatureEnabled(t,n))!==null&&r!==void 0?r:n==null?void 0:n.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)===null||t===void 0||t.reloadFeatureFlags()}updateFlags(t,n,r){var o;(o=this.featureFlags)===null||o===void 0||o.updateFlags(t,n,r)}updateEarlyAccessFeatureEnrollment(t,n,r){var o;(o=this.featureFlags)===null||o===void 0||o.updateEarlyAccessFeatureEnrollment(t,n,r)}getEarlyAccessFeatures(t,n=!1,r){var o;return(o=this.featureFlags)===null||o===void 0?void 0:o.getEarlyAccessFeatures(t,n,r)}on(t,n){return this.cu.on(t,n)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:bv}),()=>{})}onSessionId(t){var n,r;return(n=(r=this.sessionManager)===null||r===void 0?void 0:r.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t,n=!1){this.surveys?this.surveys.getSurveys(t,n):t([],{isLoaded:!1,error:bv})}getActiveMatchingSurveys(t,n=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:bv})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:bv}),()=>{})}renderSurvey(t,n){var r;(r=this.surveys)===null||r===void 0||r.renderSurvey(t,n)}displaySurvey(t,n=Umn){var r;(r=this.surveys)===null||r===void 0||r.displaySurvey(t,n)}cancelPendingSurvey(t){var n;(n=this.surveys)===null||n===void 0||n.cancelPendingSurvey(t)}canRenderSurvey(t){var n,r;return(n=(r=this.surveys)===null||r===void 0?void 0:r.canRenderSurvey(t))!==null&&n!==void 0?n:{visible:!1,disabledReason:bv}}canRenderSurveyAsync(t,n=!1){var r,o;return(r=(o=this.surveys)===null||o===void 0?void 0:o.canRenderSurveyAsync(t,n))!==null&&r!==void 0?r:Promise.resolve({visible:!1,disabledReason:bv})}_h(t){return!t||i1(t)?(Je.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(Je.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Je.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,n,r){if(!this.__loaded||!this.persistence)return Je.uninitializedWarning("posthog.identify");if(xo(t)&&(t=t.toString(),Je.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._h(t)||!this.yh("posthog.identify"))return;this.wu();const o=this.get_distinct_id(),a=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==o,i=this.ph(!1),s=this.persistence.Fa();let l=!1;try{const u=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),t!==u&&t!==this.get_property("__alias")&&(this.unregister(TN),this.register({distinct_id:t}));const d=(this.persistence.get_property("$user_state")||"anonymous")===Id,f=t!==u,g=!f&&d;if(f&&d){var c;const b=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:u};this.persistence.set_property(Ii,y2),this.setPersonPropertiesForFlags({$set:n||{},$set_once:r||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Oa(),this.capture("$identify",b,{$set:n||{},$set_once:r||{}})&&(this.Fu=n9(t,n,r)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(g){this.persistence.set_property(Ii,y2);const b=n||{},v=r||{};this.setPersonPropertiesForFlags({$set:b,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence.Oa(),this.capture("$set",{$set:b,$set_once:v})&&(this.Fu=n9(t,n,r))}else(n||r)&&this.setPersonProperties(n,r);f||a||i?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Pf)):g&&(n||r)&&this.reloadFeatureFlags(),l=!0}finally{s&&this.persistence.Na(l)}}setPersonProperties(t,n){if(!t&&!n||!this.yh("posthog.setPersonProperties"))return;const r=n9(this.get_distinct_id(),t,n);this.Fu!==r?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!0),this.capture("$set",{$set:t||{},$set_once:n||{}})&&(this.Fu=r)):Je.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var n;const r=(Yt(t)?t:[t]).filter(o=>kn(o)&&o.length>0);r.length!==0&&this.yh("posthog.unsetPersonProperties")&&((n=this.featureFlags)===null||n===void 0||n.unsetPersonPropertiesForFlags(r,!0),this.capture("$set",{$unset:r}),this.Fu=null)}group(t,n,r){var o;if(!t||!n)return void Je.error("posthog.group requires a group type and group key");(o=this.persistence)===null||o===void 0||o.syncCookieProperties(),this.ph();const a=this.getGroups(),i=a[t]!==n;if(i&&this.resetGroupPropertiesForFlags(t),this.register({$groups:ce(ce({},a),{},{[t]:n})}),(i||r)&&this.mh()){const s={$group_type:t,$group_key:n};r&&(s.$group_set=r),this.capture(N_e,s)}r&&this.setGroupPropertiesForFlags({[t]:r}),i&&!r&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,n=!0){var r;(r=this.featureFlags)===null||r===void 0||r.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(t=!0){var n;(n=this.featureFlags)===null||n===void 0||n.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,n=!0){var r;this.yh("posthog.setGroupPropertiesForFlags")&&((r=this.featureFlags)===null||r===void 0||r.setGroupPropertiesForFlags(t,n))}resetGroupPropertiesForFlags(t){var n;(n=this.featureFlags)===null||n===void 0||n.resetGroupPropertiesForFlags(t)}reset(t){const n=Mi(t)?t:t==null?void 0:t.resetDeviceID,r=Mi(t)||t==null?void 0:t.bootstrap;this.wh(n,!1,r)}wh(t,n=!1,r){var o,a,i,s,l,c;if(Je.info("reset"),!this.__loaded)return Je.uninitializedWarning("posthog.reset");const u=r==null?void 0:r.sessionID;this.config.bootstrap=r||((o=this.Du)===null||o===void 0?void 0:o.bootstrap)||{},(a=this.featureFlags)===null||a===void 0||(i=a.updateConfig)===null||i===void 0||i.call(a,this.config,this.el());const d=this.get_property($ee),f=this.get_property(U$),g=this.get_property(c1);(s=this.sessionRecording)===null||s===void 0||s.flushBeforeIdentityReset();const b=this.is_capturing();this.consent.reset(),n||!b||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const v=(l=this.persistence)===null||l===void 0||(c=l.Fa)===null||c===void 0?void 0:c.call(l);let y=!1;try{var w,S,E,A,T,C,R,N,O,P,j,D,z;if((w=this.persistence)===null||w===void 0||w.clear(),(S=this.sessionPersistence)===null||S===void 0||S.clear(),this.Tu.clear(),this.gh(),Le(g)||(P=this.persistence)===null||P===void 0||P.register({$session_recording_remote_config:g}),(E=this.surveys)===null||E===void 0||E.reset(),(A=this.featureFlags)===null||A===void 0||A.reset(),(T=this.conversations)===null||T===void 0||T.reset(),(C=this.logs)===null||C===void 0||C.reset(),(R=this.metrics)===null||R===void 0||R.reset(),(N=this.persistence)===null||N===void 0||N.set_property("$user_state","anonymous"),(O=this.sessionManager)===null||O===void 0||O.resetSessionId(),this.Fu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:F$,$device_id:null},"");else{const U=this.config.get_device_id(oc());this.register_once({distinct_id:U,$device_id:t?U:d},""),t||Le(f)||this.register({[U$]:f})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),r&&(r.distinctID&&!this.mu()&&((z=this.persistence)===null||z===void 0||z.set_property("$user_state",r.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:r.distinctID})),(j=this.featureFlags)===null||j===void 0||j.initialize(),!sn(u)&&!(!((D=this.sessionManager)===null||D===void 0)&&D.setBootstrapSessionId(u,!0)))){const U=ce({},r);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,y=!0}finally{var L,$;v&&((L=this.persistence)===null||L===void 0||($=L.Na)===null||$===void 0||$.call(L,y))}this.reloadFeatureFlags()}shutdown(t){var n=this;return Zr(function*(){var r,o,a,i,s,l,c,u;if(n.__loaded){n.Cu=!0,n.Gu().dispose(),(r=n.sessionRecording)===null||r===void 0||r.dispose(),(o=n.logs)===null||o===void 0||o.flushLogs("sendBeacon"),(a=n.metrics)===null||a===void 0||a.flush("sendBeacon"),(i=n.metrics)===null||i===void 0||i.dispose(),(s=n.Nu)===null||s===void 0||s.unload(),(l=n.ju)===null||l===void 0||l.unload();try{var d;(d=n.featureFlags)===null||d===void 0||d.destroy()}catch(f){Je.error("Error while destroying feature flags",f)}(c=n.persistence)===null||c===void 0||c.destroy(),(u=n.sessionPersistence)===null||u===void 0||u.destroy()}else Je.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,n){var r;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=n,this.alias(t),(r=this.conversations)===null||r===void 0||r.kh()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(t=this.conversations)===null||t===void 0||t.Sh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)===null||n===void 0?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let o=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${n}`);if(t!=null&&t.withTimestamp&&r){var a;const i=(a=t.timestampLookBack)!==null&&a!==void 0?a:10;if(!r)return o;o+=`?t=${Math.max(Math.floor((new Date().getTime()-r)/1e3)-i,0)}`}return o}alias(t,n){return t===this.get_property("$people_distinct_id")?(Je.critical("Attempting to create alias for existing People user - aborting."),-2):this.yh("posthog.alias")?(Le(n)&&(n=this.get_distinct_id()),t!==n?(this.bh(TN,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(Je.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const n=ce({},this.config);if(Rn(t)){var r,o,a,i,s,l,c,u,d,f,g,b,v,y;Kr(this.config,f1e(t));const S=this.ku();(r=this.persistence)===null||r===void 0||r.update_config(this.config,n,S),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Z$(ce(ce({},this.config),{},{persistence:"sessionStorage"}),S,!1);const E=this.Ou(this.config.debug);var w;Mi(E)&&(this.config.debug=E),Mi(this.config.debug)&&(this.config.debug?(ea.DEBUG=!0,Un.At()&&Un.$t("ph_debug",!0),Je.info("set_config",{config:t,oldConfig:n,newConfig:ce({},this.config)})):(ea.DEBUG=!1,Un.At()&&Un.Lt("ph_debug"))),(o=this.featureFlags)===null||o===void 0||(a=o.updateConfig)===null||a===void 0||a.call(o,this.config,this.el()),(i=this.exceptionObserver)===null||i===void 0||i.onConfigChange(),(s=this.exceptions)===null||s===void 0||s.onConfigChange(),(l=this.metrics)===null||l===void 0||l.onConfigChange(),(c=this.sessionRecording)===null||c===void 0||c.startIfEnabledOrStop(),(u=this.tracingHeaders)===null||u===void 0||u.startIfEnabledOrStop(),(d=this.autocapture)===null||d===void 0||d.startIfEnabled(),(f=this.heatmaps)===null||f===void 0||f.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((w=this.historyAutocapture)===null||w===void 0||w.startIfEnabledOrStop()),(g=this.exceptionObserver)===null||g===void 0||g.startIfEnabledOrStop(),(b=this.deadClicksAutocapture)===null||b===void 0||b.startIfEnabledOrStop(),(v=this.surveys)===null||v===void 0||v.loadIfEnabled(),this.Su(),(y=this.externalIntegrations)===null||y===void 0||y.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&W_e(this,m1,!1)}}_overrideSDKInfo(t,n){ea.LIB_NAME=t,ea.LIB_VERSION=n}startSessionRecording(t){const n=t===!0,r={sampling:n||!!(t!=null&&t.sampling),linked_flag:n||!!(t!=null&&t.linked_flag),url_trigger:n||!!(t!=null&&t.url_trigger),event_trigger:n||!!(t!=null&&t.event_trigger)};var o,a,i,s,l;Object.values(r).some(Boolean)&&((o=this.sessionManager)===null||o===void 0||o.checkAndGetSessionAndWindowId(),r.sampling&&((a=this.sessionRecording)===null||a===void 0||a.overrideSampling()),r.linked_flag&&((i=this.sessionRecording)===null||i===void 0||i.overrideLinkedFlag()),r.url_trigger&&((s=this.sessionRecording)===null||s===void 0||s.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(!((t=this.sessionRecording)===null||t===void 0)&&t.started)}captureException(t,n){try{if(!this.exceptions)return;const r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(ce(ce({},r),n))}catch{return}}addExceptionStep(t,n){var r;(r=this.exceptions)===null||r===void 0||r.addExceptionStep(t,n)}captureLog(t){var n;(n=this.logs)===null||n===void 0||n.captureLog(t)}get logger(){var t,n;return(t=(n=this.logs)===null||n===void 0?void 0:n.logger)!==null&&t!==void 0?t:ff.xh}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var n,r;return(n=(r=this.toolbar)===null||r===void 0?void 0:r.loadToolbar(t))!==null&&n!==void 0&&n}get_property(t){var n;return(n=this.persistence)===null||n===void 0?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)===null||n===void 0?void 0:n.props[t]}toString(){var t;let n=(t=this.config.name)!==null&&t!==void 0?t:E_;return n!==E_&&(n="posthog."+n),n}_isIdentified(){var t,n;return((t=this.persistence)===null||t===void 0?void 0:t.get_property("$user_state"))==="identified"||((n=this.sessionPersistence)===null||n===void 0?void 0:n.get_property("$user_state"))==="identified"}mh(){var t,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Qi(this.getGroups())&&!(!((t=this.persistence)===null||t===void 0||(t=t.props)===null||t===void 0)&&t.__alias)&&!(!((n=this.persistence)===null||n===void 0||(n=n.props)===null||n===void 0)&&n.$epp))}eh(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.mh()||this.yh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.yh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}yh(t){return this.config.person_profiles==="never"?(Je.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.yu(),this.bh(Bee,!0),!0)}ku(){if(this.config.cookieless_mode==="always")return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}Su(){var t,n;const r=this.ku();var o,a,i;return this.is_capturing()||(o=this.logs)===null||o===void 0||o.Ch(),((t=this.persistence)===null||t===void 0?void 0:t.hi)!==r&&((a=this.persistence)===null||a===void 0||a.set_disabled(r)),((n=this.sessionPersistence)===null||n===void 0?void 0:n.hi)!==r&&((i=this.sessionPersistence)===null||i===void 0||i.set_disabled(r)),r&&(this.Tu.clear(),this.gh()),r}opt_in_capturing(t){var n;if(this.config.cookieless_mode!=="always"){if(this.mu()){var r,o,a,i,s,l;(r=this.sessionRecording)===null||r===void 0||r.dispose({discardBufferedEvents:!0}),this.wh(!0,!0),(o=this.sessionManager)===null||o===void 0||o.destroy(),(a=this.pageViewManager)===null||a===void 0||a.destroy(),this.sessionManager=new a1e(this),this.pageViewManager=new K_e(this),this.persistence&&(this.sessionPropsManager=new r1e(this,this.sessionManager,this.persistence));const g=(i=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.sessionRecording)!==null&&i!==void 0?i:(l=ff.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var c,u;g&&(this.sessionRecording=this.gu(this.sessionRecording,new g(this)),this.hu&&((c=this.sessionRecording)===null||c===void 0||(u=c.onRemoteConfig)===null||u===void 0||u.call(c,this.hu)))}var d,f;this.consent.optInOut(!0),this.Su(),this.Xu(),(n=this.sessionRecording)===null||n===void 0||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((d=this.surveys)===null||d===void 0||d.loadIfEnabled()),(Le(t==null?void 0:t.captureEventName)||t!=null&&t.captureEventName)&&this.capture((f=t==null?void 0:t.captureEventName)!==null&&f!==void 0?f:"$opt_in",t==null?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Yu()}else Je.warn(l1e)}opt_out_capturing(){if(this.config.cookieless_mode==="always")return void Je.warn(l1e);const t=this.config.cookieless_mode==="on_reject"?this.sessionRecording:void 0;var n,r;t==null||t.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.wh(!0,!0),this.consent.optInOut(!1),this.Su(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:F$,$device_id:null}),this.pu(t),this.sessionRecording=void 0,(n=this.sessionManager)===null||n===void 0||n.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Yu(),this.Xu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return t===1?"granted":t===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Su()}_is_bot(){return ua?wFe(ua,this.config.custom_blocked_useragents):void 0}Yu(){Fe&&(Fe.visibilityState==="visible"?this.Pu||(this.Pu=!0,this.capture(Wee,{title:Fe.title},{send_instantly:!0}),this.Ru&&(Fe.removeEventListener(tk,this.Ru),this.Ru=null)):this.Ru||(this.Ru=this.Yu.bind(this),Zn(Fe,tk,this.Ru)))}debug(t){t===!1?(ke==null||ke.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(ke==null||ke.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}el(){const t=this.Du||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(Je.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(n,r,o,a,i){const s=r in n&&!sn(n[r]),l=o in n&&!sn(n[o]);return s?n[r]:!!l&&(i&&i.warn(`Config field '${o}' is deprecated. Please use '${r}' instead. The old field will be removed in a future major version.`),n[o])})(t,"advanced_disable_flags","advanced_disable_decide",0,Je)}Os(t){var n;if(sn(this.config.before_send))return t;const r=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter(khn),o=Yt(this.config.before_send)?this.config.before_send:[this.config.before_send];let a=t;for(const i of o)try{if(a=i(a),sn(a)){const s=`Event '${t.event}' was rejected in beforeSend function`;return Shn(t.event)?Je.warn(`${s}. This can cause unexpected behavior.`):Je.info(s),null}a.properties&&!Qi(a.properties)||Je.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(s){return Je.error(`Error in beforeSend function for event '${t.event}':`,s),null}for(const i of r)if(a.properties&&sn(a.properties[i]))return Je.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return a}getPageViewId(){var t;return(t=this.pageViewManager.Uo)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,r){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(r)})}Ou(t){const n=Mi(t)&&!t,r=Un.At()&&Un.Ot("ph_debug")==="true";return!n&&(!!r||t)}};b1.__defaultExtensionClasses={},b1.xh=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(let n=0;t.length>n;n++)e.prototype[t[n]]=Wgn(e.prototype[t[n]])})(b1,["identify"]);var CFe=class{constructor(e){this.disabled=e===!1;const t=Rn(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;const r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}};const a9="$copy_autocapture",i9=mo("[AutoCapture]");function s9(e,t){return t.length>e?t.slice(0,e)+"...":t}function ebn(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Mu(t));return t}function tbn(e,{e:t,maskAllElementAttributes:n,maskAllText:r,elementAttributeIgnoreList:o,elementsChainAsString:a,disableCaptureUrlHashes:i}){var s,l;if(!Mu(e))return{props:{}};const c=[e],u=new Set([e]);let d=e;for(;d.parentNode&&!Wa(d,"body")&&1e3>c.length;){if(Yee(d.parentNode)){const C=d.parentNode.host;if(u.has(C))break;u.add(C),c.push(C),d=C;continue}if(!Mu(d.parentNode)||u.has(d.parentNode))break;u.add(d.parentNode),c.push(d.parentNode),d=d.parentNode}const f=t.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(C=>Wa(C,"button")||Wa(C,"a")):-1;f>0&&(r=r||c.slice(0,f+1).some(C=>!yy(C)||rk(C)));const g=[],b={};let v,y=!1,w=!1;if(rr(c,C=>{const R=yy(C);if(Wa(C,"a")&&!n&&!(o!=null&&o.includes("href"))){const N=C.getAttribute("href");y=!!(R&&N&&f1(N))&&(i?eh(N):N)}Kt(w0(C),"ph-no-capture")&&(w=!0),g.push((function(N,O,P,j,D=!1){const z=N.tagName.toLowerCase(),L={tag_name:z};Xee.indexOf(z)>-1&&!P&&(L.$el_text=z.toLowerCase()==="a"||z.toLowerCase()==="button"?s9(1024,H_e(N)):s9(1024,nk(N)));const $=w0(N);O||j!=null&&j.includes("class")||0>=$.length||(L.classes=$.filter(function(G){return G!==""})),rr(N.attributes,function(G){var F;if((!rk(N)||["name","id","class","aria-label"].indexOf(G.name)!==-1)&&!(j!=null&&j.includes(G.name))&&!O&&f1(G.value)&&(!kn(F=G.name)||F.substring(0,10)!=="_ngcontent"&&F.substring(0,7)!=="_nghost")){let Z=G.value;G.name==="class"&&(Z=Zee(Z).join(" ")),L["attr__"+G.name]=s9(1024,G.name==="href"&&D?eh(Z):Z)}});let U=1,B=1,V=N;for(;V=ebn(V);)U++,V.tagName===N.tagName&&B++;return L.nth_child=U,L.nth_of_type=B,L})(C,n,r,o,i)),rr((function(N){if(!yy(N))return{};const O={};return rr(N.attributes,function(P){if(P.name&&P.name.indexOf("data-ph-capture-attribute")===0){const j=P.name.replace("data-ph-capture-attribute-",""),D=P.value;j&&D&&f1(D)&&(O[j]=D)}}),O})(C),(N,O)=>{({}).hasOwnProperty.call(b,O)||(b[O]=N)})}),w)return{props:{},explicitNoCapture:w};if(f>0&&(e=c[f],g.splice(0,f)),r||(g[0].$el_text=Wa(e,"a")||Wa(e,"button")?H_e(e):nk(e)),y){var S,E;g[0].attr__href=y;const C=(S=cp(y))===null||S===void 0?void 0:S.host,R=ke==null||(E=ke.location)===null||E===void 0?void 0:E.host;C&&R&&C!==R&&(v=y)}return{props:Kr((T=t.type,{$event_type:T,$ce_version:1}),a?{}:{$elements:g},{$elements_chain:(A=g,Yt(A)?(function(C){return C.map(R=>{var N,O;let P="";if(R.tag_name&&(P+=R.tag_name),R.attr_class){R.attr_class.sort();for(const z of R.attr_class)P+=`.${z.replace(/"/g,"")}`}const j=ce(ce(ce(ce({},R.text?{text:R.text}:{}),{},{"nth-child":(N=R.nth_child)!==null&&N!==void 0?N:0,"nth-of-type":(O=R.nth_of_type)!==null&&O!==void 0?O:0},R.href?{href:R.href}:{}),R.attr_id?{attr_id:R.attr_id}:{}),R.attributes),D={};return x2(j).sort(([z],[L])=>(function($,U){return U>$?-1:$>U?1:0})(z,L)).forEach(([z,L])=>D[V_e(z.toString())]=V_e(L.toString())),P+=":",P+=x2(D).map(([z,L])=>`${z}="${L}"`).join(""),P}).join(";")})((function(C){return C.map(R=>{var N,O;const P={text:(N=R.$el_text)===null||N===void 0?void 0:N.slice(0,400),tag_name:R.tag_name,href:(O=R.attr__href)===null||O===void 0?void 0:O.slice(0,2048),attr_class:smn(R),attr_id:R.attr__id,nth_child:R.nth_child,nth_of_type:R.nth_of_type,attributes:{}};return x2(R).filter(([j])=>j.indexOf("attr__")===0).forEach(([j,D])=>P.attributes[j]=D),P})})(A)):"")},!((s=g[0])===null||s===void 0)&&s.$el_text?{$el_text:(l=g[0])===null||l===void 0?void 0:l.$el_text}:{},v&&t.type==="click"?{$external_click_url:v}:{},b),target:e};var A,T}var nbn=class{co(){this.do=void 0,clearTimeout(this.vo),this.vo=void 0}fo(e){var t;if(!yy(e))return!0;const n=(t=this.po().css_selector_ignorelist)!==null&&t!==void 0?t:K$,r=new Set;let o=e;for(;o;){if(r.size>=1e3||r.has(o))return!0;r.add(o);const a=o,i=w0(a);if(Kt(i,"ph-no-capture")||Kt(i,"ph-sensitive")||rk(a)||n.some(l=>eH(a,l)))return!0;const s=o.parentNode;o=Yee(s)?s.host:s&&Mu(s)?s:null}return!1}mo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.co();if(e.type==="pointerdown"){this.co();const r=p1(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&r&&Mu(r)&&(this.do={target:r,excluded:this.fo(r),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this.yo)===null||t===void 0?void 0:t.distinctId}))}const n=this.do;n&&(e.pointerId!==n.id||Math.abs(e.clientX-n.x)>5||Math.abs(e.clientY-n.y)>5?this.co():e.type==="pointerup"&&(n.released=!0,this.vo=setTimeout(()=>this.co(),0)))}bo(e){var t;const n=this.do;this.co();const r=p1(e);if(n!=null&&n.released&&n.target.isConnected&&n.distinctId===((t=this.yo)===null||t===void 0?void 0:t.distinctId)&&e.pointerId===n.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-n.x)&&5>=Math.abs(e.clientY-n.y)&&r&&(Wa(r,"html")||Wa(r,"body"))){var o;if(n.excluded)return null;const a=(o=this.po().css_selector_ignorelist)!==null&&o!==void 0?o:K$;return[r,Fe==null?void 0:Fe.documentElement,Fe==null?void 0:Fe.body].some(i=>{if(!i)return!1;const s=w0(i);return Kt(s,"ph-no-capture")||Kt(s,"ph-sensitive")||!yy(i)||rk(i)||a.some(l=>eH(i,l))})?null:n.target}}constructor(e){this._o=e,this.name="autocapture",this.wo=!1,this.ko=null,this.So=!1,this.xo=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.$o=!1,this._o.refresh(this.Mr),this.rageclicks=new CFe(this.Mr.rageclick),this.To=null}setup(e){this.Io(),this.yo=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.$o?t.dispose():(this.Mo=t,this.startIfEnabled())}dispose(){var e;this.$o||(this.$o=!0,this.yo=void 0,(e=this.Mo)===null||e===void 0||e.dispose(),this.Mo=void 0,this.xo.clear(),this.To=null,this.Eo())}po(){return this._o.refresh(this.Mr),this.Mr}Io(){var e,t;return this.po(),this.Mr.url_allowlist=(e=this.Mr.url_allowlist)===null||e===void 0?void 0:e.map(n=>new RegExp(n)),this.Mr.url_ignorelist=(t=this.Mr.url_ignorelist)===null||t===void 0?void 0:t.map(n=>new RegExp(n)),this.Mr}Po(){if(!this.isBrowserSupported())return void i9.info("Disabling Automatic Event Collection because this browser is not supported");if(!ke||!Fe)return;const e=this.Ro=t=>{t=t||(ke==null?void 0:ke.event);try{if(t.type==="blur")return void this.co();if(t.type.indexOf("pointer")===0)return void this.mo(t);const n=t.type==="click"?this.bo(t):void 0;if(fo(n))return;this.Ao(t,"$autocapture",n)}catch(n){i9.error("Failed to capture event",n)}};if(Zn(ke,"blur",e),Zn(Fe,"submit",e,{capture:!0}),Zn(Fe,"change",e,{capture:!0}),Zn(Fe,"click",e,{capture:!0}),rr(["pointerdown","pointermove","pointerup","pointercancel"],t=>{Zn(Fe,t,e,{capture:!0})}),this.po().capture_copied_text){const t=this.Fo=n=>{n=n||(ke==null?void 0:ke.event);try{this.Ao(n,a9)}catch(r){i9.error("Failed to capture clipboard event",r)}};Zn(Fe,"copy",t,{capture:!0}),Zn(Fe,"cut",t,{capture:!0}),Zn(Fe,"paste",t,{capture:!0})}}Eo(){this.co(),this.Ro&&(ke==null||ke.removeEventListener("blur",this.Ro),rr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{Fe==null||Fe.removeEventListener(e,this.Ro,!0)}),Fe==null||Fe.removeEventListener("submit",this.Ro,!0),Fe==null||Fe.removeEventListener("change",this.Ro,!0),Fe==null||Fe.removeEventListener("click",this.Ro,!0),this.Ro=void 0),this.Fo&&(Fe==null||Fe.removeEventListener("copy",this.Fo,!0),Fe==null||Fe.removeEventListener("cut",this.Fo,!0),Fe==null||Fe.removeEventListener("paste",this.Fo,!0),this.Fo=void 0),this.wo=!1}startIfEnabled(){this.isEnabled||this.co(),!this.$o&&this.yo&&this.isEnabled&&!this.wo&&(this.Po(),this.wo=!0)}onRemoteConfig(e){if(this.$o)return;if(this.So=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this.Co=t.elementsChainAsString);const n=t.autocapture_opt_out;var r;Mi(n)&&((r=this.yo)===null||r===void 0||r.kv.set("$autocapture_disabled_server_side",n),this.ko=n),this.startIfEnabled()}setElementSelectors(e,t=this){if(this.$o)return;e.size?this.xo.set(t,new Set(e)):this.xo.delete(t);const n=new Set;this.xo.forEach(r=>{r.forEach(o=>n.add(o))}),this.To=n}getElementSelectors(e,t){var n;const r=[];return(n=this.To)===null||n===void 0||n.forEach(o=>{const a=Fe==null?void 0:Fe.querySelectorAll(o);a==null||a.forEach(i=>{e!==i&&t!==i||Kt(r,o)||r.push(o)})}),r}get isEnabled(){var e,t;if(this.$o)return!1;const n=(e=this.yo)===null||e===void 0?void 0:e.kv.get(dUe),r=this.ko,o=this.po();if(!o.remoteRequestsDisabled&&!this.So)return!1;const a=o.remoteRequestsDisabled&&!this.So;if(fo(r)&&!Mi(n)&&!a)return!1;const i=(t=this.ko)!==null&&t!==void 0?t:!!n;return!!o.enabled&&!i}Ao(e,t="$autocapture",n){if(!this.isEnabled)return void this.co();let r=n||p1(e);zUe(r)&&(r=r.parentNode||null);const o=this.Io();var a;t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&o.rageclick&&(!((a=this.rageclicks)===null||a===void 0)&&a.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime()))&&BUe(r,o.rageclick)&&this.Ao(e,"$rageclick",n);const i=t===a9,s=i?ce(ce({},o),{},{dom_event_allowlist:void 0}):o;if(r&&(function(d,f,g,b,v,y){var w;if(!ke||qee(d)||g!=null&&g.url_allowlist&&!D_e(g.url_allowlist,y)||g!=null&&g.url_ignorelist&&D_e(g.url_ignorelist,y))return!1;if(g!=null&&g.dom_event_allowlist){const T=g.dom_event_allowlist;if(T&&!T.some(C=>f.type===C))return!1}const{parentIsUsefulElement:S,targetElementList:E}=HUe(d,b);if(!(function(T,C){const R=C==null?void 0:C.element_allowlist;if(Le(R))return!0;for(const N of T)if(R.some(O=>N.tagName.toLowerCase()===O))return!0;return!1})(E,g)||!tH(E,g==null?void 0:g.css_selector_allowlist)||tH(E,(w=g==null?void 0:g.css_selector_ignorelist)!==null&&w!==void 0?w:K$))return!1;try{const T=ke.getComputedStyle(d);if(T&&T.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0}catch{}const A=d.tagName.toLowerCase();switch(A){case"html":return!1;case"form":return(v||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(f.type)>=0;default:return S?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(Xee.indexOf(A)>-1||d.getAttribute("contenteditable")==="true")}})(r,e,s,i,i?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var l;const{props:d,explicitNoCapture:f,target:g}=tbn(r,{e,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:o.disableCaptureUrlHashes});if(f)return!1;const b=this.getElementSelectors(r,g);if(b&&b.length>0&&(d.$element_selectors=b),t===a9){const v=e.type||"clipboard";if(v!=="paste"){var c,u;const y=ke==null||(c=ke.getSelection())===null||c===void 0?void 0:c.toString(),w=$Ue(y);if(!w)return!1;d.$selected_content=w,d.$clipboard_text_length=(u=y==null?void 0:y.length)!==null&&u!==void 0?u:0}d.$copy_type=v}return(l=this.yo)===null||l===void 0||l.capture(t,d),!0}}isBrowserSupported(){return ca(Fe==null?void 0:Fe.querySelectorAll)}},rbn=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,n=Rn(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance.el(),e.url_allowlist=n==null?void 0:n.url_allowlist,e.url_ignorelist=n==null?void 0:n.url_ignorelist,e.dom_event_allowlist=n==null?void 0:n.dom_event_allowlist,e.element_allowlist=n==null?void 0:n.element_allowlist,e.css_selector_allowlist=n==null?void 0:n.css_selector_allowlist,e.css_selector_ignorelist=n==null?void 0:n.css_selector_ignorelist,e.element_attribute_ignorelist=n==null?void 0:n.element_attribute_ignorelist,e.capture_copied_text=n==null?void 0:n.capture_copied_text}};const s_=mo("[ExceptionAutocapture]"),h1e=()=>{},g1e=e=>{var t;if(ca(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function ik(e,t,n){try{if(!(t in e))return h1e;const r={next:e[t]},o=n(function(...a){return r.next.apply(this,a)});return ca(o)&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=o,()=>{if(e[t]===o)return void(e[t]=r.next);let a=e[t],i=g1e(a);for(;i;){if(i.next===o)return void(i.next=r.next);a=i.next,i=g1e(a)}}}catch{return h1e}}const obn=mo("[TracingHeaders]"),ug=mo("[Web Vitals]"),m1e=9e5,b1e=["CLS","FCP","INP","LCP"],abn=["INP","LCP"],ibn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],l9="disabled",v1e="lazy_loading",gd=mo("[SessionRecording]"),sbn=[Hee,Vee,EUe,TUe,AUe,CUe,RUe,IUe,NUe],lbn=mo("[Heatmaps]");function c9(e){return Rn(e)&&"clientX"in e&&"clientY"in e&&xo(e.clientX)&&xo(e.clientY)}const SC=mo("[Product Tours]"),u9=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(Fee))},cbn=["$set_once","$set"],Gc=mo("[SiteApps]"),y1e="Error while initializing PostHog app with config id ",RFe=(e,t)=>e!=null&&e.then?e.then(t):t(e),vv="SDK is not enabled or survey functionality is not yet loaded",x1e="Disabled. Not loading surveys.";var ubn=class{constructor(e,t){this._o=e,this.$h=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Th=!1,this.Ih=!1,this.Mh=[],this.Eh=[],this.Ph=null,this.Rh=null,this.$o=!1,this.Ah=new Set,this.onRemoteConfig=n=>{if(this.$o||this.Mr.disableSurveys)return;if(!n.ok)return this.Ih=!0,this.Fh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),Qn.warn("Remote config unavailable. Not loading surveys.");const r=n.config.surveys;if(sn(r))return Qn.warn("Flags not loaded yet. Not loading surveys.");this.Oh=Mi(r)?r:r.length>0,Qn.info(`flags response received, isSurveysEnabled: ${this.Oh}`),this.loadIfEnabled()},this.Fh=n=>{this.Eh.slice().forEach(r=>this.Dh(r,n))}}setup(e){if(!this.$o)return this.Lh=e,RFe(e.kv.initialize(),()=>{if(this.Lh!==e||this.$o)return;this.Lh=void 0,this.yo=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.$o?t.dispose():(this.Mo=t,this.loadIfEnabled())})}dispose(){var e,t,n,r,o;this.$o||(this.$o=!0,this.Lh=void 0,this.yo=void 0,(e=this.Mo)===null||e===void 0||e.dispose(),this.Mo=void 0,(t=this._surveyEventReceiver)===null||t===void 0||t.dispose(),this._surveyEventReceiver=null,(n=this._surveyManager)===null||n===void 0||(r=n.dispose)===null||r===void 0||r.call(n),this._surveyManager=null,this.Mh=[],this.Eh.forEach(a=>{a.active=!1}),this.Eh=[],(o=this.Nh)===null||o===void 0||o.call(this),this.Nh=void 0,this.Ph=null,this.Ah.forEach(a=>clearTimeout(a)),this.Ah.clear())}get Mr(){return this._o.get()}initialize(){this.loadIfEnabled()}reset(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.clearInMemoryInProgressSurveyState)===null||t===void 0||t.call(e);try{var n;(n=this._surveyEventReceiver)===null||n===void 0||n.reset(),localStorage.removeItem("lastSeenSurveyDate");const r=[];for(let o=0;o<localStorage.length;o++){const a=localStorage.key(o);(a!=null&&a.startsWith("seenSurvey_")||a!=null&&a.startsWith("inProgressSurvey_"))&&r.push(a)}r.forEach(o=>localStorage.removeItem(o))}catch{}this.Fh()}loadIfEnabled(){if(this.$o||!this.yo)return;const e=this.Mr;if(this._surveyManager)return;if(this.Th)return void Qn.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void Qn.info(x1e);if(e.cookielessMode&&this._o.isOptedOut())return void Qn.info("Not loading surveys in cookieless mode without consent.");const t=this._o.getExtensions();if(!t)return void this.qh("PostHog Extensions not found.");if(Le(this.Oh)&&!e.advancedEnableSurveys)return;const n=this.Oh||e.advancedEnableSurveys;this.Th=!0,this.Ih=!1;try{const r=t.generateSurveys;if(r)return this.jh(r,n),void(this.Th=!1);const o=t.loadExternalDependency;if(!o)return this.qh(Gee),void(this.Th=!1);o(a=>{try{if(this.$o)return;const i=this._o.getExtensions();a||!(i!=null&&i.generateSurveys)?this.qh("Could not load surveys script",a):this.jh(i.generateSurveys,n)}finally{this.Th=!1}})}catch(r){throw this.Th=!1,this.qh("Error initializing surveys",r),r}}jh(e,t){var n,r;if(this.$o)return;this._surveyManager=e(t),this._surveyEventReceiver=this._o.createEventReceiver(this.Fh);const o=(n=(r=this.yo)!==null&&r!==void 0?r:this.$h)===null||n===void 0?void 0:n.kv.get(S_);o&&this.Bh(o),Qn.info("Surveys loaded successfully"),this.Hh(),this.Fh(),this.zh({isLoaded:!0})}qh(e,t){this.Ih=!0,Qn.error(e,t),this.Fh({isLoaded:!1,error:e}),this.zh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Mh.push(e),this._surveyManager&&this.zh({isLoaded:!0}),()=>{this.Mh=this.Mh.filter(t=>t!==e)}}getSurveys(e,t=!1){var n;const r=(n=this.yo)!==null&&n!==void 0?n:this.$h;if(!r||this.$o)return;if(this.Mr.disableSurveys)return Qn.info(x1e),e([]);const o=r.kv.get(S_);if(o&&!t)return e(o,{isLoaded:!0}),void(this.Uh()&&this.getSurveys(()=>{},!0));if(this.Ph)return void this.Ph.then(({surveys:s,context:l})=>{this.$o||e(s,l)}).catch(s=>Qn.error("Error in survey callback",s));const a=this.Wh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(s=>{try{return this.Vh(r,s)}catch(l){return Qn.error("Error processing surveys response",l),this.Vh(r,{statusCode:0,error:l})}},s=>this.Vh(r,{statusCode:0,error:s}));this.Ph=a;const i=()=>{this.Ph===a&&(this.Ph=null)};a.then(s=>{i(),this.$o||(this.Fh(s.context),e(s.surveys,s.context))},i).catch(s=>Qn.error("Error in survey callback",s))}Wh(e,t){const n=this.yo;return n?n.sendRequest(e,t):new Promise(r=>r({statusCode:0,error:new Error(vv)}))}Vh(e,t){if(this.$o)return{surveys:[],context:{isLoaded:!1,error:vv}};const n=t.statusCode;if(n!==200||!t.json){const o=`Surveys API could not be loaded, status: ${n}`;return n!==0?Qn.error(o):t.error||Qn.warn(o),this.Rh=Date.now(),{surveys:[],context:{isLoaded:!1,error:o}}}this.Rh=null;const r=t.json.surveys||[];return e.kv.set({[S_]:r,[AN]:Date.now()}),this.Bh(r),{surveys:r,context:{isLoaded:!0}}}Bh(e){var t;const n=e.filter(r=>(function(o){return!(!o.start_date||o.end_date)})(r)&&(SFe(r)||(function(o){var a;return!!(!((a=o.conditions)===null||a===void 0||(a=a.actions)===null||a===void 0||(a=a.values)===null||a===void 0)&&a.length)})(r)));(t=this._surveyEventReceiver)===null||t===void 0||t.replace(n)}Uh(){return this.Gh()&&!this.Ph&&!this.Zh()}Gh(){var e,t;const n=(e=(t=this.yo)!==null&&t!==void 0?t:this.$h)===null||e===void 0?void 0:e.kv.get(AN);return xo(n)&&Date.now()-n>3e5}Zh(){return xo(this.Rh)&&3e5>Date.now()-this.Rh}markSurveyAsSeen(e,t){var n;const r={id:e,current_iteration:(n=t==null?void 0:t.iteration)!==null&&n!==void 0?n:null};TFe(r);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Fh()}zh(e){for(const t of this.Mh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(n){Qn.error("Error in survey callback",n)}}getActiveMatchingSurveys(e,t=!1){if(!sn(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Qn.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t,n;if(this.$o)return()=>{};const r={callback:e,active:!0,revision:0};this.Eh.push(r),this.Hh();const o=(t=(n=this.yo)!==null&&n!==void 0?n:this.$h)===null||t===void 0?void 0:t.kv.get(S_);return this.Mr.disableSurveys||!this._surveyManager&&this.Ih&&!this.Th||!o&&!sn(this.Rh)&&!this.Ph?this.Dh(r,{isLoaded:!1}):this._surveyManager&&this.Dh(r),()=>{var a;r.active=!1,this.Eh=this.Eh.filter(i=>i!==r),this.Eh.length===0&&((a=this.Nh)===null||a===void 0||a.call(this),this.Nh=void 0)}}Hh(){var e,t,n;this._surveyManager&&this.Eh.length>0&&((e=this.Nh)!==null&&e!==void 0||(this.Nh=(t=(n=this._o).onMatchingConditionsChanged)===null||t===void 0?void 0:t.call(n,this.Fh)))}Dh(e,t){if(this.$o||!e.active)return;const n=++e.revision,r=o=>{if(!this.$o&&e.active&&n===e.revision)try{const a=t??{isLoaded:!0},i=JSON.stringify([o,a]);if(i===e.lastResult)return;e.lastResult=i,e.callback(o,a)}catch(a){Qn.error("Error in active matching surveys callback",a)}};try{t&&!t.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(o){Qn.error("Error in active matching surveys callback",o)}}Qh(e){let t=null;return this.getSurveys(n=>{var r;t=(r=n.find(o=>o.id===e))!==null&&r!==void 0?r:null}),t}Jh(e){if(sn(this._surveyManager))return{eligible:!1,reason:vv};const t=typeof e=="string"?this.Qh(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Kh(e){if(!this._o.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(sn(this._surveyManager))return{eligible:!1,reason:vv};const t=typeof e=="string"?this.Qh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(sn(this._surveyManager))return Qn.warn("init was not called"),{visible:!1,disabledReason:vv};const t=this.Kh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return sn(this._surveyManager)?(Qn.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:vv})):new Promise(n=>{this.getSurveys(r=>{var o;const a=(o=r.find(i=>i.id===e))!==null&&o!==void 0?o:null;if(a){const i=this.Kh(a);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,n){var r;if(!this._o.isCapturing())return;if(sn(this._surveyManager))return void Qn.warn("init was not called");const o=typeof e=="string"?this.Qh(e):e;if(!(o!=null&&o.id))return void Qn.warn("Survey not found");if(!$mn.includes(o.type))return void Qn.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=Fe==null?void 0:Fe.querySelector(t);if(a){if(!((r=o.appearance)===null||r===void 0)&&r.surveyPopupDelaySeconds){Qn.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const i=setTimeout(()=>{var s,l;this.Ah.delete(i),!this.$o&&this._o.isCapturing()&&(Qn.info(`Rendering survey ${o.id} with delay of ${(s=o.appearance)===null||s===void 0?void 0:s.surveyPopupDelaySeconds} seconds`),(l=this._surveyManager)===null||l===void 0||l.renderSurvey(o,a,n),Qn.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this.Ah.add(i)}this._surveyManager.renderSurvey(o,a,n)}else Qn.warn("Survey element not found")}displaySurvey(e,t){var n;if(!this._o.isCapturing())return;if(sn(this._surveyManager))return void Qn.warn("init was not called");const r=this.Qh(e);if(!r)return void Qn.warn("Survey not found");let o=r;if(!((n=r.appearance)===null||n===void 0)&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(o=ce(ce({},r),{},{appearance:ce(ce({},r.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==nH.Popover&&t.initialResponses&&Qn.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){const a=this.Jh(r);if(!a.eligible)return void Qn.warn("Survey is not eligible to be displayed: ",a.reason)}t.displayType!==nH.Inline?this._surveyManager.handlePopoverSurvey(o,t):this.renderSurvey(o,t.selector,t.properties)}cancelPendingSurvey(e){sn(this._surveyManager)?Qn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.handlePageUnload)===null||t===void 0||t.call(e)}};function yv(e,t,n){if(sn(e))return!1;switch(n){case"exact":return e===t;case"contains":{const r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var dbn=class{constructor(e){this._instance=e,this.Xh=new Set,this.Yh=new Set,this.tc=new ON,this.ec=(t,n)=>this.nc(t,n)&&this.sc(t,n)&&this.rc(t,n)&&this.oc(t,n),this.nc=(t,n)=>!(n!=null&&n.event)||(t==null?void 0:t.event)===(n==null?void 0:n.event)}init(){var e,t;Le((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.ac=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook((n,r)=>{this.on(n,r)}))}dispose(){var e,t;(e=this.ac)===null||e===void 0||e.call(this),this.ac=void 0,(t=this._instance)===null||t===void 0||(t=t.autocapture)===null||t===void 0||t.setElementSelectors(new Set,this),this.tc=new ON}register(e){var t,n;if(!Le((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(r=>{var o;this.Xh.add(r),(o=r.steps)===null||o===void 0||o.forEach(a=>{this.Yh.add((a==null?void 0:a.event)||"")})}),(n=this._instance)===null||n===void 0?void 0:n.autocapture)){const r=new Set;this.Xh.forEach(o=>{var a;(a=o.steps)===null||a===void 0||a.forEach(i=>{i!=null&&i.selector&&r.add(i.selector)})}),this._instance.autocapture.setElementSelectors(r,this)}}replace(e){this.Xh.clear(),this.Yh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.Yh.has(e)||this.Yh.has(t.event))&&this.Xh.forEach(n=>{this.lc(t,n)&&this.tc.emit("actionCaptured",n.name)})}uc(e){this.onAction("actionCaptured",t=>e(t))}lc(e,t){if((t==null?void 0:t.steps)==null)return!1;for(const n of t.steps)if(this.ec(e,n))return!0;return!1}onAction(e,t){return this.tc.on(e,t)}sc(e,t){if(t!=null&&t.url){var n;const r=e==null||(n=e.properties)===null||n===void 0?void 0:n.$current_url;if(!r||typeof r!="string"||!yv(r,t.url,t.url_matching||"contains"))return!1}return!0}rc(e,t){return!!this.hc(e,t)&&!!this.cc(e,t)&&!!this.dc(e,t)}hc(e,t){var n;if(!(t!=null&&t.href))return!0;const r=this.vc(e);if(r.length>0)return r.some(a=>yv(a.href,t.href,t.href_matching||"exact"));const o=(e==null||(n=e.properties)===null||n===void 0?void 0:n.$elements_chain)||"";return!!o&&yv((function(a){const i=a.match(/(?::|")href="(.*?)"/);return i?i[1]:""})(o),t.href,t.href_matching||"exact")}cc(e,t){var n;if(!(t!=null&&t.text))return!0;const r=this.vc(e);if(r.length>0)return r.some(l=>yv(l.text,t.text,t.text_matching||"exact")||yv(l.$el_text,t.text,t.text_matching||"exact"));const o=(e==null||(n=e.properties)===null||n===void 0?void 0:n.$elements_chain)||"";return!!o&&(a=(function(l){const c=[],u=/(?::|")text="(.*?)"/g;let d;for(;!sn(d=u.exec(l));)c.includes(d[1])||c.push(d[1]);return c})(o),i=t.text,s=t.text_matching||"exact",a.some(l=>yv(l,i,s)));var a,i,s}dc(e,t){var n,r;if(!(t!=null&&t.selector))return!0;const o=e==null||(n=e.properties)===null||n===void 0?void 0:n.$element_selectors;if(o!=null&&o.includes(t.selector))return!0;const a=(e==null||(r=e.properties)===null||r===void 0?void 0:r.$elements_chain)||"";if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}vc(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e==null?void 0:e.properties.$elements}oc(e,t){return!(t!=null&&t.properties)||t.properties.length===0||EFe(t.properties.reduce((n,r)=>{const o=Yt(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return n[r.key]={values:o,operator:r.operator||"exact"},n},{}),e==null?void 0:e.properties)}},pbn=class{constructor(e,t){var n,r;this.fc=[],this._instance=e,this.gc=t,this.mc=new Map,this.yc=new Map,this.bc=new Map,this._c=(n=this._instance)===null||n===void 0||(r=n.onSessionId)===null||r===void 0?void 0:r.call(n,o=>this.wc(o))}kc(e){return!1}Sc(){return null}xc(e){}Cc(){}$c(e,t){return!!e&&EFe(e.propertyFilters,t==null?void 0:t.properties)}Tc(e,t){const n=new Map;return e.forEach(r=>{var o;(o=r.conditions)===null||o===void 0||(o=o[t])===null||o===void 0||(o=o.values)===null||o===void 0||o.forEach(a=>{if(a!=null&&a.name){const i=n.get(a.name)||[];i.push(r.id),n.set(a.name,i)}})}),n}Ic(e,t,n){const r=(n===o_.Activation?this.mc:this.yc).get(e);let o=[];return this.Mc(a=>{o=a.filter(i=>r==null?void 0:r.includes(i.id))}),o.filter(a=>{var i;const s=(i=a.conditions)===null||i===void 0||(i=i[n])===null||i===void 0||(i=i.values)===null||i===void 0?void 0:i.find(l=>l.name===e);return this.$c(s,t)})}register(e){this.Ec(e,!1)}replace(e){this.Ec(e,!0)}Ec(e,t){var n;Le((n=this._instance)===null||n===void 0?void 0:n._addCaptureHook)||(this.Pc(e,t),this.Rc(e,t))}Rc(e,t){const n=e.filter(a=>{var i;return(i=a.conditions)===null||i===void 0||(i=i.actions)===null||i===void 0||(i=i.values)===null||i===void 0?void 0:i.length});var r;if(t&&this.bc.clear(),n.length===0)return void(t&&((r=this.Ac)===null||r===void 0||r.replace([])));this.Ac||(this.Ac=new dbn(this._instance),this.Ac.init(),this.Ac.uc(a=>this.onAction(a)));const o=[];n.forEach(a=>{var i;(i=a.conditions)===null||i===void 0||(i=i.actions)===null||i===void 0||i.values.forEach(s=>{if(o.push(s),s.name){var l;const c=(l=this.bc.get(s.name))!==null&&l!==void 0?l:[];c.includes(a.id)||c.push(a.id),this.bc.set(s.name,c)}})}),t?this.Ac.replace(o):this.Ac.register(o)}Fc(e,t){t.forEach((n,r)=>{var o;const a=(o=e.get(r))!==null&&o!==void 0?o:[];n.forEach(i=>{a.includes(i)||a.push(i)}),e.set(r,a)})}Pc(e,t){var n,r;const o=e.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.events)&&((u=l.conditions)===null||u===void 0||(u=u.events)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),a=e.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.cancelEvents)&&((u=l.conditions)===null||u===void 0||(u=u.cancelEvents)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),i=this.Tc(e,o_.Activation),s=this.Tc(e,o_.Cancellation);t?(this.mc=i,this.yc=s):(this.Fc(this.mc,i),this.Fc(this.yc,s)),(o.length!==0||a.length!==0||e.some(l=>{var c;return(c=l.conditions)===null||c===void 0||(c=c.actions)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length}))&&((n=this.ac)!==null&&n!==void 0||(this.ac=(r=this._instance)===null||r===void 0?void 0:r._addCaptureHook((l,c)=>{this.onEvent(l,c)})))}onEvent(e,t){var n,r;const o=this.Oc(),a=(t==null||(n=t.properties)===null||n===void 0?void 0:n.$survey_id)||(t==null||(r=t.properties)===null||r===void 0?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){const s=this.Dc(e,a,t);if(s==="consume")return o.info("event consumed activated item, removing it",{event:e,itemId:a}),void this.Lc([a]);if(s==="persist")return o.info("shown item promoted to persisted activation",{event:e,itemId:a}),this.Nc(a),void this.qc([a])}if(this.yc.has(e)){const s=this.Ic(e,t,o_.Cancellation);s.length>0&&(o.info("cancel event matched, cancelling items",{event:e,itemsToCancel:s.map(l=>l.id)}),this.Lc(s.map(l=>l.id)),s.forEach(l=>this.jc(l.id)))}if(!this.mc.has(e))return;o.info("event name matched",{event:e,eventPayload:t,items:this.mc.get(e)});const i=this.Ic(e,t,o_.Activation);this.Bc(i.map(s=>s.id))}onAction(e){this.bc.has(e)&&this.Bc(this.bc.get(e)||[])}Bc(e){var t,n;if(e.length===0)return;const r=!!(!((t=this._instance)===null||t===void 0||(n=t.get_session_id)===null||n===void 0)&&n.call(t)),o=[];for(const a of e)r&&this.kc(a)?this.Nc(a)&&this.Hc(a):o.push(a);o.length>0&&(this.fc=[...new Set([...this.fc,...o])]),this.Oc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.zc()}Nc(e){this.fc=this.fc.filter(n=>n!==e);const t=this.Uc();return!t.includes(e)&&(this.Wc([...t,e]),this.Vc(),!0)}Lc(e){const t=new Set(e);this.fc=this.fc.filter(o=>!t.has(o));const n=this.Gc(),r=n.filter(o=>!t.has(o));r.length!==n.length&&(this.Wc(r),r.length===0&&this.Zc()),this.qc(e),this.zc()}zc(){try{var e;(e=this.gc)===null||e===void 0||e.call(this)}catch(t){this.Oc().error("Error while handling activated items change",t)}}Qc(){var e;const t=this.Sc();if(!t)return{};const n=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t];return n&&typeof n=="object"?n:{}}Hc(e){if(!this.Sc())return;const t=this.Qc();this.xc(ce(ce({},t),{},{[e]:Date.now()}))}qc(e){if(!this.Sc())return;const t=this.Qc(),n={};let r=!1;for(const[o,a]of Object.entries(t))e.includes(o)?r=!0:n[o]=a;r&&(Qi(n)?this.Cc():this.xc(n))}Jc(){this.Sc()&&this.Cc()}getActivationTimestamp(e){if(!this.Uc().includes(e))return;const t=this.Qc()[e];return xo(t)?t:void 0}Gc(){var e;const t=this.Kc();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t])||[]}Uc(){var e,t,n;const r=this.Gc();if(r.length===0)return[];const o=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.Xc()],a=(t=this._instance)===null||t===void 0||(n=t.get_session_id)===null||n===void 0?void 0:n.call(t);return a&&o===a?r:[]}Vc(){var e,t;const n=(e=this._instance)===null||e===void 0||(t=e.get_session_id)===null||t===void 0?void 0:t.call(e);n&&this.Yc(n)}Zc(){this.td()}wc(e){var t;const n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.Xc()];if(n&&n!==e){const r=this.Gc(),o=this.Qc();r.length>0&&(this.Wc([]),r.filter(a=>xo(o[a])).forEach(a=>this.jc(a))),this.Zc(),this.Jc(),r.length>0&&this.zc()}}getActivatedIds(){return[...new Set([...this.Uc(),...this.fc])].filter(e=>!this.ed(e))}dispose(){var e,t,n;(e=this._c)===null||e===void 0||e.call(this),this._c=void 0,(t=this.ac)===null||t===void 0||t.call(this),this.ac=void 0,(n=this.Ac)===null||n===void 0||n.dispose(),this.Ac=void 0}reset(){this.fc=[],this.Gc().length>0&&this.Wc([]),this.Zc(),this.Jc(),this.zc()}getEventToItemsMap(){return this.mc}nd(){return this.Ac}},fbn=class extends pbn{constructor(e,t){super(e,t)}Kc(){return bUe}Xc(){return vUe}Sc(){return yUe}xc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_timestamps:e})}Cc(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}kc(e){var t;let n;this.Mc(o=>{n=o.find(a=>a.id===e)});const r=n==null||(t=n.appearance)===null||t===void 0?void 0:t.surveyPopupDelaySeconds;return xo(r)&&r>0}sd(){return Ns.SHOWN}Mc(e){var t;(t=this._instance)===null||t===void 0||t.getSurveys(e)}jc(e){var t;(t=this._instance)===null||t===void 0||t.cancelPendingSurvey(e)}Oc(){return Qn}Wc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated:e})}Yc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_session:e})}td(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}ed(){return!1}Dc(e,t,n){var r;if(e===Ns.SENT&&(n==null||(r=n.properties)===null||r===void 0?void 0:r.$survey_completed)===!1)return"ignore";let o;return this.Mc(a=>{o=a.find(i=>i.id===t)}),!o||(function(a){var i;return SFe(a)&&!!(!((i=a.conditions)===null||i===void 0||(i=i.events)===null||i===void 0)&&i.repeatedActivation)||a.schedule==="always"})(o)?e===Ns.SHOWN?"consume":"ignore":e===Ns.SHOWN?"persist":e===Ns.DISMISSED||e===Ns.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},hbn=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);const t={};for(const n of e){const r=this._instance.get_property(n);Le(r)||(t[n]=r)}return t}set(e,t){this._instance.register(typeof e=="string"?{[e]:t}:e)}remove(e){typeof e!="string"?e.forEach(t=>this._instance.unregister(t)):this._instance.unregister(e)}},gbn=class{constructor(e){this._instance=e}get(){const e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=$t==null?void 0:$t.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:n}=e;return{generateSurveys:t?r=>t(this._instance,r):void 0,loadExternalDependency:n?r=>n(this._instance,"surveys",r):void 0}}createEventReceiver(e){return new fbn(this._instance,e)}onMatchingConditionsChanged(e){const t=this._instance._addCaptureHook(a=>{a!=="$pageview"&&a!==Ns.SHOWN&&a!==Ns.DISMISSED&&a!==Ns.SENT||e()}),n=()=>e();Zn(ke,"PHSurveyShown",n);let r=!1;const o=this._instance.onFeatureFlags(()=>{r&&e()});return r=!0,()=>{r=!1,t(),o(),ke==null||ke.removeEventListener("PHSurveyShown",n)}}};const mbn=ke!=null&&ke.location?IN(ke.location.hash,"__posthog")||IN(location.hash,"state"):null,w1e="_postHogToolbarParams",_1e=mo("[Toolbar]"),S1e=mo("[FeatureFlags]");var bbn=class{constructor(e,t=!1){this.rd=!1,this.update(e,t)}update(e,t){this.od=((n,r)=>{var o,a,i,s,l,c,u,d;return{bootstrap:{featureFlags:(o=(a=n.bootstrap)===null||a===void 0?void 0:a.featureFlags)!==null&&o!==void 0?o:void 0,featureFlagPayloads:(i=(s=n.bootstrap)===null||s===void 0?void 0:s.featureFlagPayloads)!==null&&i!==void 0?i:void 0},remoteRequestsDisabled:r,featureFlagsDisabled:!!n.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!n.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!n.advanced_feature_flags_dedup_per_session,cacheTtlMs:n.feature_flag_cache_ttl_ms,refreshIntervalMs:(l=n.remote_config_refresh_interval_ms)!==null&&l!==void 0?l:3e5,idleRefreshBackoff:Le(n.remote_config_refresh_interval_ms),requestTimeoutMs:n.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(c=n.feature_flag_request_max_retries)!==null&&c!==void 0?c:1),compression:n.disable_compression?void 0:"best-available",evaluationContexts:(u=(d=n.evaluation_contexts)!==null&&d!==void 0?d:n.evaluation_environments)!==null&&u!==void 0?u:[],flagKeys:Yt(n.flag_keys)?n.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.rd||(S1e.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.rd=!0),Le(e.flag_keys)||Yt(e.flag_keys)||S1e.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.od}};const k1e=mo("[FeatureFlags]"),dg=mo("[FeatureFlags]",{debugEnabled:!0}),d9=`" failed. Feature flags didn't load in time.`,vbn=[502,504],E1e=["click","keydown","wheel","touchstart","pointerdown"],T1e="connection_error",A1e=e=>{const t={};for(let n=0;e.length>n;n++)t[e[n]]=!0;return t},C1e=e=>{const t={};for(const[n,r]of x2(e||{}))r&&(t[n]=r);return t},R1e=e=>wx(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Zl=mo("[Error tracking]"),lH="webkit-masked-url:",ybn=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],xbn=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",lH],wbn=["__firefox__","__gCrWeb"],I1e="Refusing to render web experiment since the viewer is a likely bot",_bn={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>PN(t,e),not_regex:(e,t)=>!PN(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},fl=mo("[Conversations]"),pg="Conversations not available yet.";function N1e(e,t){var n,r,o,a,i,s,l;const c=(n=e==null?void 0:e.flushIntervalMs)!==null&&n!==void 0?n:3e3,u=(r=e==null?void 0:e.maxBufferSize)!==null&&r!==void 0?r:100,d=t!=null&&t.consoleCapture?void 0:(o=e==null?void 0:e.maxLogsPerInterval)!==null&&o!==void 0?o:1e3,f=Le(d)?Math.max(u,2048):Math.max(u,d),g=ce(ce({},(function(){let b="",v="";try{const y=ua==null?void 0:ua.userAgent;y&&([b,v]=B9e(y))}catch{}return(function(y,w){const S=(function(E){if(E)return{}.hasOwnProperty.call(k_e,E)?k_e[E]:E})(y);return ce(ce({},S?{"os.name":S}:{}),w?{"os.version":w}:{})})(b,v)})()),e==null?void 0:e.resourceAttributes);return{serviceName:(a=(i=g==null?void 0:g["service.name"])!==null&&i!==void 0?i:e==null?void 0:e.serviceName)!==null&&a!==void 0?a:t==null?void 0:t.serviceNameDefault,serviceVersion:(s=g==null?void 0:g["service.version"])!==null&&s!==void 0?s:e==null?void 0:e.serviceVersion,environment:(l=g==null?void 0:g["deployment.environment"])!==null&&l!==void 0?l:e==null?void 0:e.environment,resourceAttributes:g,beforeSend:e==null?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:f,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Sbn=["debug","log","warn","error","info"],kbn=e=>{for(;e!=null&&e.__rrweb_original__;)e=e.__rrweb_original__;return e},M1e="console",IFe="__posthogHandledLogsRequestError",p9=(e,t)=>{const n=e instanceof Error?e:new Error(t);return n[IFe]=!0,n},O1e=e=>!!e&&typeof e=="object"&&e[IFe]===!0,jN=mo("[NetworkMetrics]"),ete=()=>{var e;return!(ke==null||(e=ke.performance)===null||e===void 0)&&e.now?ke.performance.now():Date.now()},Ebn={"http:":80,"https:":443},Tbn=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),NFe=(e,t)=>{var n;const r=String(t);return{method:String(e).toUpperCase(),url:((n=cp(r))===null||n===void 0?void 0:n.href)||r}},cH=(e,t,n,r,o,a,i=!1)=>{try{var s,l;const c=o();if(!c)return;const u=n||void 0,d=ete()-r,f=cp(t.url);if(f&&f.protocol!=="http:"&&f.protocol!=="https:")return;const g={url:(f==null?void 0:f.href)||t.url,method:t.method},b=ca(c.name)?c.name(g):kn(c.name)?c.name:"http.client.request.duration";if(!b)return;const v=i&&!u?void 0:((w,S)=>w?400>w?void 0:String(w):(S==null?void 0:S.name)||"_OTHER")(u,a),y=ce(ce(ce(ce(ce({},(w=>{const S=Tbn.has(w)?w:"_OTHER";return ce({"http.request.method":S},S==="_OTHER"&&w!==S?{"http.request.method_original":w}:{})})(g.method)),f?(w=>{return{"server.address":w.hostname.startsWith("[")&&w.hostname.endsWith("]")?w.hostname.slice(1,-1):w.hostname,"server.port":Number(w.port)||Ebn[w.protocol],"url.scheme":w.protocol.slice(0,-1),"url.template":(S=w.pathname,S.split("/").map(E=>(A=>/^\d+$/.test(A)||A.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(A))(E)?":id":E).join("/"))};var S})(f):{}),u?{"http.response.status_code":u}:{}),v?{"error.type":v}:{}),(s=c.attributes)===null||s===void 0?void 0:s.call(c,g,{status:u,durationMs:d}));(l=e.metrics)===null||l===void 0||l.histogram(b,d,{unit:"ms",attributes:y})}catch(c){jN.error("Failed to record network metric",c)}},MFe=()=>{},Abn=(e,t)=>ca(ke==null?void 0:ke.fetch)?ik(ke,"fetch",n=>function(...r){const o=ete(),a=n.apply(this,r);if(!t())return a;try{var i,s,l;const[c,u]=r,d=NFe((i=(s=u==null?void 0:u.method)!==null&&s!==void 0?s:c==null?void 0:c.method)!==null&&i!==void 0?i:"GET",(l=c==null?void 0:c.url)!==null&&l!==void 0?l:c);return a.then(f=>(cH(e,d,f==null?void 0:f.status,o,t,void 0,!0),f),f=>{throw cH(e,d,void 0,o,t,f),f})}catch(c){return jN.error("Failed to observe fetch",c),a}}):MFe,Cbn=(e,t)=>{var n;const r=ke==null||(n=ke.XMLHttpRequest)===null||n===void 0?void 0:n.prototype;if(!r)return MFe;const o=new WeakMap,a=ik(r,"open",s=>function(...l){try{uFe.has(this)||o.set(this,NFe(l[0],l[1]))}catch(c){jN.error("Failed to observe XHR open",c)}return s.apply(this,l)}),i=ik(r,"send",s=>function(...l){let c;try{const u=o.get(this);if(u&&t()){const d=ete();c=()=>{this.removeEventListener("loadend",c),cH(e,u,this.status,d,t)},Zn(this,"loadend",c)}}catch(u){jN.error("Failed to observe XHR send",u)}try{return s.apply(this,l)}catch(u){throw c&&this.removeEventListener("loadend",c),u}});return()=>{a(),i()}},H3={featureFlags:class{constructor(e){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.A=k1e,this.ld={},this.ud={},this.hd=[],this.dd=!1,this.vd=!1,this.fd=0,this.pd=!1,this.gd=!1,this.md=!1,this.yd=!1,this.bd=0,this._d=!1,this.rn=()=>{const t=this.wd();this.bd=0,t&&this.reloadFeatureFlags()},this.kd=()=>{var t,n;const r=this.Sd,o=(t=this.xd)!==null&&t!==void 0?t:r;Le(r)||Le(o)||this.Mr.remoteRequestsDisabled||!Fe||Fe.visibilityState==="hidden"||Date.now()-((n=this.Cd)!==null&&n!==void 0?n:0)<o||(this.xd=this._d||!this.Mr.idleRefreshBackoff?r:Math.min(2*o,36e5),this._d=!1,this.reloadFeatureFlags(),this.$d())},this.Td=()=>{this._d&&this.xd===this.Sd||this.Id()},this.sn=()=>{(Fe==null?void 0:Fe.visibilityState)==="visible"&&this.Id()},"get"in e?this._o=e:(this._instance=e,this.Md=new bbn(e.config,e.el()),this._o=this.Md)}updateConfig(e,t){var n;(n=this.Md)===null||n===void 0||n.update(e,t),this.yo&&this.Ed()}setup(e){return this.Lh=e,this.A=e.logger.createLogger("[FeatureFlags]"),RFe(e.kv.initialize(),()=>{this.Lh===e&&(this.Lh=void 0,this.yo=e,this.Pd(e))})}Pd(e){var t;if(this.yo===e)return ke&&Zn(ke,"online",this.rn),this.Ed(),this.Rd=e.registerDynamicEventProperties(()=>this.Ad()?this.ld:this.ud),this.Fd=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.Od(),this.Dd(),this.Ld()}),this.Dd(),this.initialize()}Id(){this._d=!0,this.xd=this.Sd,this.kd()}Ed(){const e=this.Mr.refreshIntervalMs,t=!this.Mr.remoteRequestsDisabled&&Fe&&!Le(e)&&e>0?e:void 0;this.Mr.idleRefreshBackoff||(this.xd=t),t!==this.Sd&&(this.Nd(),Le(t)||(this.Sd=t,this.xd=t,this.$d(),Fe!=null&&Fe.addEventListener&&(Zn(Fe,tk,this.sn),Gv(E1e,n=>{Zn(Fe,n,this.Td,{capture:!0})}))))}$d(){Le(this.Sd)||(Le(this.qd)||clearInterval(this.qd),this.Cd=Date.now(),this.qd=setInterval(this.kd,this.Sd))}Nd(){var e;Le(this.qd)||(clearInterval(this.qd),this.qd=void 0,Fe==null||(e=Fe.removeEventListener)===null||e===void 0||e.call(Fe,"visibilitychange",this.sn),Gv(E1e,t=>{var n;Fe==null||(n=Fe.removeEventListener)===null||n===void 0||n.call(Fe,t,this.Td,{capture:!0})})),this.Sd=void 0,this.xd=void 0,this._d=!1,this.Cd=void 0}destroy(){this.jd()}dispose(){this.jd()}jd(){var e,t;this.Nd(),this.fd++,this.gd=!1,this.Lh=void 0,this.yo&&(this.Bd(),(e=this.Rd)===null||e===void 0||e.dispose(),this.Rd=void 0,(t=this.Fd)===null||t===void 0||t.call(this),this.Fd=void 0,this.hd=[],ke==null||ke.removeEventListener("online",this.rn),this.yo=void 0)}get Mr(){return this._o.get()}Hd(e){var t;return this.zd&&e in this.zd?this.zd[e]:(t=this.yo)===null||t===void 0?void 0:t.kv.get(e)}Od(){return!!this.zd&&(this.zd=void 0,!0)}Ud(){var e;return!Le((e=this.yo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.Od()}$t(e){this.Wd(()=>{var t;return(t=this.yo)===null||t===void 0?void 0:t.kv.set(e)})}Vd(e,t,n){var r;if(!(!((r=this._instance)===null||r===void 0)&&r.persistence)||!e.$enabled_feature_flags)return;const o=this.Hd("$enabled_feature_flags")||{},a=e.$enabled_feature_flags||{},i=t.flags||t.featureFlags,s=t.flags?Object.entries(t.flags).filter(([,w])=>!(w!=null&&w.failed)).map(([w])=>w):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,c=l?s:n&&!Yt(i)?Object.keys(i||{}):Array.from(new Set([...Object.keys(o),...Object.keys(a)])),u=this.Hd("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},f=l||n?c:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),g=!l&&!n,b=!!g||c,v=!!g||f,y={[Rd]:b,[rc]:b,[Nf]:v};e.$feature_flag_details&&(y[Zg]=b);for(const w of[Xg,Vf,u1])Le(e[w])||(y[w]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(y)}Lt(e){this.Wd(()=>{var t;return(t=this.yo)===null||t===void 0?void 0:t.kv.remove(e)})}Wd(e){try{e()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Dd(){const e={};for(const r of[Rd,Nf,Xg,Yc]){const o=this.Hd(r);Le(o)||(e[r]=o)}this.ld=e;const t=ce({},e),n=this.Hd(rc);if(n)for(const[r,o]of Object.entries(n))t[`$feature/${r}`]=o;this.ud=t}Ad(){const e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;const t=this.Hd(Vf);return typeof t!="number"||Date.now()-t>e}Gd(){return!!this.Ad()&&(this.yd||this.vd||(this.yd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Zd(){const e=this.Mr.evaluationContexts;return e!=null&&e.length?e.filter(t=>{const n=t&&typeof t=="string"&&t.trim().length>0;return n||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),n}):[]}Qd(){const e=this.Mr.flagKeys;if(!Le(e))return e.filter(t=>{const n=t&&typeof t=="string"&&t.trim().length>0;return n||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),n})}initialize(){var e,t;const n=this.Mr,r=(e=(t=n.bootstrap)===null||t===void 0?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(r).length){var o,a;const i=(o=(a=n.bootstrap)===null||a===void 0?void 0:a.featureFlagPayloads)!==null&&o!==void 0?o:{},s=Object.keys(r).filter(c=>!Le(r[c])).reduce((c,u)=>(c[u]=r[u],c),{}),l=Object.keys(i).filter(c=>s[c]).reduce((c,u)=>(c[u]=i[u],c),{});return this.Jd({featureFlags:s,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,n){var r,o;const a=n!=null&&n.merge&&(r=this.Hd("$enabled_feature_flags"))!==null&&r!==void 0?r:{},i=n!=null&&n.merge&&(o=this.Hd("$feature_flag_payloads"))!==null&&o!==void 0?o:{},s=ce(ce({},a),e),l=ce(ce({},i),t),c={};for(const[u,d]of Object.entries(s))c[u]={key:u,enabled:y_e(d),variant:x_e(d),reason:void 0,metadata:Le(l==null?void 0:l[u])?void 0:{id:0,version:void 0,description:void 0,payload:l[u]}};this.Jd({flags:c})}get hasLoadedFlags(){return this.dd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Hd(Zg),t=this.Hd(Yc),n=this.Hd(_g);if(!n&&!t)return e||{};const r=Kr({},e||{}),o=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(const s of o){var a;const l=r[s],c=t==null?void 0:t[s],u=Le(c)?(a=l==null?void 0:l.enabled)!==null&&a!==void 0&&a:!!c,d=Le(c)?l==null?void 0:l.variant:typeof c=="string"?c:void 0,f=n==null?void 0:n[s],g=ce(ce({},l),{},{enabled:u,variant:u?d??(l==null?void 0:l.variant):void 0});var i;u!==(l==null?void 0:l.enabled)&&(g.original_enabled=l==null?void 0:l.enabled),d!==(l==null?void 0:l.variant)&&(g.original_variant=l==null?void 0:l.variant),f&&(g.metadata=ce(ce({},l==null?void 0:l.metadata),{},{payload:f,original_payload:l==null||(i=l.metadata)===null||i===void 0?void 0:i.payload})),r[s]=g}return this.ad||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:r}),this.ad=!0),r}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(n=>{const r=e[n];return{key:n,enabled:y_e(r),variant:x_e(r),payload:v_e(t[n])}})}getFlagVariants(){const e=this.Hd(rc),t=this.Hd(Yc);if(!t)return e||{};const n=Kr({},e||{}),r=Object.keys(t);for(let o=0;r.length>o;o++)n[r[o]]=t[r[o]];return this.ad||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ad=!0),n}getFlagPayloads(){const e=this.Hd(Nf),t=this.Hd(_g);if(!t)return e||{};const n=Kr({},e||{}),r=Object.keys(t);for(let o=0;r.length>o;o++)n[r[o]]=t[r[o]];return this.ad||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ad=!0),n}reloadFeatureFlags(){this.pd||this.Mr.featureFlagsDisabled||this.wd()||(this.vd&&(this.gd=!0),this.Kd||(this.hd.slice().forEach(e=>{try{e()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.Kd=setTimeout(()=>{this.Xd()},5)))}Bd(){clearTimeout(this.Kd),this.Kd=void 0}onReloading(e){return this.hd.push(e),()=>{this.hd=this.hd.filter(t=>t!==e)}}ensureFlagsLoaded(){this.dd||this.vd||this.Kd||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.pd=e}resetFlagCallReported(){this.Lt(Pf)}Xd(e){this.Bd();const t=this.yo;if(!t||this.Mr.remoteRequestsDisabled||this.wd())return;if(this.vd)return void(this.gd=!0);const n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:ce(ce(ce({},t.initialPersonProperties),this.Hd("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Hd(Of),timezone:nFe()};Le(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Mr.featureFlagsDisabled)&&(n.disable_flags=!0);const r=this.Zd();r.length&&(n.evaluation_contexts=r);const o=this.Qd();Le(o)||(n.flag_keys=o);const a=this.Mr.onlyEvaluateSurveyFeatureFlags,i="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),s=this.fd;this.vd=!0;const l=()=>{this.gd&&(this.gd=!1,this.Xd())},c=b=>{var v,y;const w=(v=b.json)!==null&&v!==void 0?v:{},S=b.statusCode!==200;if(this.vd=!1,s!==this.fd)return void l();if(this.Yd(b.statusCode),S||this.gd||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.gd)return;this.md=!S;const E=[];b.error?E.push(b.error instanceof Error&&b.error.name==="AbortError"?"timeout":b.error instanceof Error?T1e:"unknown_error"):b.statusCode!==200&&E.push(`api_error_${b.statusCode}`),w.errorsWhileComputingFlags&&E.push("errors_while_computing_flags");const A=!!(!((y=w.quotaLimited)===null||y===void 0)&&y.includes("feature_flags"));A&&E.push("quota_limited"),this.$t({[ek]:E}),A?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):n.disable_flags||this.Jd(w,S,{partialResponse:a}),l()},u=b=>{this.vd=!1,s===this.fd&&(this.$t({[ek]:[T1e]}),this.A.error("Feature flag request failed",b),this.Ud()&&this.Ld(!0)),l()};let d=this.Mr.requestMaxRetries;const f=()=>d>0&&s===this.fd,g=()=>{if(s!==this.fd||!this.yo||this.Mr.remoteRequestsDisabled)return this.vd=!1,void l();try{t.sendRequest(i,{target:"flags",method:"POST",body:n,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(b=>{if((v=>vbn.includes(v.statusCode)||(y=>y.statusCode===0&&y.error instanceof Error&&y.error.name==="AbortError")(v))(b)&&f())return d--,void setTimeout(g,500);c(b)}).catch(u)}catch(b){u(b)}};g()}wd(){return KUe(this.bd,3)}Yd(e){this.bd=YUe(e,this.bd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var n;if(t.fresh&&!this.md)return;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+e+d9);if(this.Gd())return;const r=this.getFeatureFlagResult(e,t);return(n=r==null?void 0:r.variant)!==null&&n!==void 0?n:r==null?void 0:r.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.md)return;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+e+d9);if(this.Gd())return;const n=this.getFlagVariants(),r=e in n,o=n[e],a=this.getFlagPayloads()[e],i=String(o),s=this.Hd("$feature_flag_request_id")||void 0,l=this.Hd("$feature_flag_evaluated_at")||void 0;let c,u=this.Hd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var d;const O=(d=this.yo)===null||d===void 0?void 0:d.session.sessionId,P=this.Hd(k_);O&&O!==P&&(u={},c=O)}if(t.send_event||!("send_event"in t))if(e in u&&u[e].includes(i))c&&this.$t({[Pf]:u,[k_]:c});else{var f,g,b,v,y,w,S,E,A,T,C,R;Yt(u[e])?u[e].push(i):u[e]=[i],this.$t(ce({[Pf]:u},c?{[k_]:c}:{}));const O=this.getFeatureFlagDetails(e),P=[...(f=this.Hd("$feature_flag_errors"))!==null&&f!==void 0?f:[]];Le(o)&&P.push("flag_missing");const j={$feature_flag:e,$feature_flag_response:o,$feature_flag_payload:a??null,$feature_flag_request_id:s,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(g=(b=this.Mr.bootstrap)===null||b===void 0||(b=b.featureFlags)===null||b===void 0?void 0:b[e])!==null&&g!==void 0?g:null,$feature_flag_bootstrapped_payload:(v=(y=this.Mr.bootstrap)===null||y===void 0||(y=y.featureFlagPayloads)===null||y===void 0?void 0:y[e])!==null&&v!==void 0?v:null,$used_bootstrap_value:!this.md};Le(O==null||(w=O.metadata)===null||w===void 0?void 0:w.has_experiment)||(j.$feature_flag_has_experiment=O.metadata.has_experiment),Le(O==null||(S=O.metadata)===null||S===void 0?void 0:S.version)||(j.$feature_flag_version=O.metadata.version);const D=(E=O==null||(A=O.reason)===null||A===void 0?void 0:A.description)!==null&&E!==void 0?E:O==null||(T=O.reason)===null||T===void 0?void 0:T.code;var N;D&&(j.$feature_flag_reason=D),!(O==null||(C=O.metadata)===null||C===void 0)&&C.id&&(j.$feature_flag_id=O.metadata.id),Le(O==null?void 0:O.original_variant)&&Le(O==null?void 0:O.original_enabled)||(j.$feature_flag_original_response=Le(O.original_variant)?O.original_enabled:O.original_variant),!(O==null||(R=O.metadata)===null||R===void 0)&&R.original_payload&&(j.$feature_flag_original_payload=O==null||(N=O.metadata)===null||N===void 0?void 0:N.original_payload),P.length&&(j.$feature_flag_error=P.join(",")),this.tv(j)}else c&&this.$t({[Pf]:u,[k_]:c});return r?{key:e,enabled:!!o,variant:typeof o=="string"?o:void 0,payload:v_e(a)}:void 0}tv(e){try{var t;(t=this.yo)===null||t===void 0||t.capture("$feature_flag_called",e)}catch(n){this.A.error("Failed to capture feature flag call",n)}}getRemoteConfigPayload(e,t){this.ev(e,t)}ev(e,t){var n=this;return Zr(function*(){const r=n.yo;if(!r)return;const o={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},a=n.Zd();a.length&&(o.evaluation_contexts=a);const i=n.Qd();let s;Le(i)||(o.flag_keys=i);try{var l;const c=(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:o,compression:n.Mr.compression,sentAt:"body",timeoutMs:n.Mr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;s=(c==null?void 0:c[e])||void 0}catch(c){return void n.A.error("Remote config feature flag request failed",c)}try{t(s)}catch(c){n.A.error("Remote config feature flag callback failed",c)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.md)return t.defaultValue;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+e+d9),t.defaultValue;const n=this.getFeatureFlag(e,t);return Le(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this.Jd(e,t,n)}Jd(e,t,n){if(!this.yo)return;this.dd=!0;const r=((o,a={},i={},s={},l,c=k1e)=>{const u=((E,A)=>{const T=E.flags;if(T){const C=Object.fromEntries(Object.keys(T).map(N=>{var O;return[N,(O=T[N].variant)!==null&&O!==void 0?O:T[N].enabled]})),R=Object.fromEntries(Object.keys(T).filter(N=>T[N].enabled).filter(N=>{var O;return!Le((O=T[N].metadata)===null||O===void 0?void 0:O.payload)}).map(N=>{var O;return[N,(O=T[N].metadata)===null||O===void 0?void 0:O.payload]}));return ce(ce({},E),{},{featureFlags:C,featureFlagPayloads:R})}return E.featureFlags&&A.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),E})(o,c),d=u.flags,f=u.featureFlags,g=u.featureFlagPayloads;if(!f)return;const b=o.requestId,v=o.evaluatedAt;if(Yt(f)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const E={};if(f)for(let A=0;f.length>A;A++)E[f[A]]=!0;return{[Rd]:f,[rc]:E,[u1]:!1}}let y=f,w=g,S=d;if(l!=null&&l.partialResponse){const E=Object.keys(y),A=w||{};y=ce(ce({},a),y),w=ce(ce({},i),A),E.forEach(T=>{T in A||w==null||delete w[T]}),S=ce(ce({},s),S)}else if(o.errorsWhileComputingFlags)if(d){const E=new Set(Object.keys(d).filter(T=>{var C;return!(!((C=d[T])===null||C===void 0)&&C.failed)}));y=ce(ce({},a),Object.fromEntries(Object.entries(y).filter(([T])=>E.has(T))));const A=Object.fromEntries(Object.entries(w||{}).filter(([T])=>E.has(T)));w=ce(ce({},i),A),E.forEach(T=>{T in A||w==null||delete w[T]}),S=ce(ce({},s),Object.fromEntries(Object.entries(S||{}).filter(([T])=>E.has(T))))}else y=ce(ce({},a),y),w=ce(ce({},i),w),S=ce(ce({},s),S);return ce(ce({[Rd]:Object.keys(C1e(y)),[rc]:y||{},[Nf]:w||{},[Zg]:S||{},[u1]:o.minimalFlagCalledEvents===!0},b?{[Xg]:b}:{}),v?{[Vf]:v}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.A);if(r)if((n==null?void 0:n.persist)===!1){const o=!Le(this.yo.kv.get(rc));this.zd=r,o||this.$t(r)}else this.Od(),this.Vd(r,e,!!(n!=null&&n.partialResponse)),this.$t(r);else t&&this.Ud();t||(this.yd=!1),this.Ld(t)}override(e,t=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.iv(e)}iv(e){if(this.yo){if(e===!1)return this.Lt([Yc,_g]),this.Ld(),void dg.info("All overrides cleared");if(Yt(e))return this.$t({[Yc]:A1e(e)}),this.Ld(),void dg.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;const n=e;this.ad=!!((t=n.suppressWarning)!==null&&t!==void 0&&t);const r={},o=n.flags,a=n.payloads;return o&&(r[Yc]=Yt(o)?A1e(o):o),a&&(r[_g]=a),Object.keys(r).length&&this.$t(r),o===!1&&a===!1?this.Lt([Yc,_g]):o===!1?this.Lt(Yc):a===!1&&this.Lt(_g),this.Ld(),o===!1?dg.info("Flag overrides cleared"):o&&dg.info("Flag overrides set",{flags:o}),void(a===!1?dg.info("Payload overrides cleared"):a&&dg.info("Payload overrides set",{payloads:a}))}if(e&&typeof e=="object")return this.$t({[Yc]:e}),this.Ld(),void dg.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.dd){const{flags:t,flagVariants:n}=this.nv();try{e(t,n)}catch(r){this.A.error("Error while running feature flags callback",r)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;const o=(this.Hd("$early_access_features")||[]).find(c=>c.flagKey===e),a={[`$feature_enrollment/${e}`]:t},i={$feature_flag:e,$feature_enrollment:t,$set:a};o&&(i.$early_access_feature_name=o.name),n&&(i.$feature_enrollment_stage=n);const s=ce(ce({},this.getFlagVariants()),{},{[e]:t});(r=this._instance)===null||r===void 0||(r=r.persistence)===null||r===void 0||r.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(a)}),this.$t({[Rd]:Object.keys(C1e(s)),[rc]:s,[Mf]:ce(ce({},this.Hd("$stored_person_properties")||{}),a)}),this.Ld();try{var l;(l=this.yo)===null||l===void 0||l.capture("$feature_enrollment_update",i)}catch(c){this.A.error("Failed to capture early access feature enrollment",c)}}getEarlyAccessFeatures(e,t=!1,n){const r=this.Hd(YB);!r||t?this.sv(e,n):e(r)}sv(e,t){var n=this;return Zr(function*(){const r=n.yo;if(!r)return;const o=t?`&${t.map(i=>`stage=${i}`).join("&")}`:"";let a;try{const i=yield r.sendRequest(`/api/early_access_features/?token=${r.projectToken}${o}`,{target:"api",method:"GET",sentAt:"query"});if(!i.json)return;a=i.json.earlyAccessFeatures,n.$t({[YB]:a})}catch(i){return void n.A.error("Early access feature request failed",i)}try{e(a)}catch(i){n.A.error("Early access feature callback failed",i)}})()}nv(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(n=>t[n]),flagVariants:Object.keys(t).filter(n=>t[n]).reduce((n,r)=>(n[r]=t[r],n),{})}}Ld(e){this.Dd();const{flags:t,flagVariants:n}=this.nv();this.featureFlagEventHandlers.forEach(r=>{try{r(t,n,{errorsLoading:e})}catch(o){this.A.error("Error while running feature flags callback",o)}})}setPersonPropertiesForFlags(e,t=!0){this.rv(e,t)}rv(e,t=!0){const n=this.Hd("$stored_person_properties")||{},r=(e==null?void 0:e.$set)||(e!=null&&e.$set_once?{}:e),o=e==null?void 0:e.$set_once,a={};if(o)for(const i in o)({}).hasOwnProperty.call(o,i)&&(i in n||(a[i]=o[i]));this.$t({[Mf]:ce(ce(ce({},n),a),r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const n=ce({},this.Hd("$stored_person_properties")||{});e.forEach(r=>{delete n[r]}),this.$t({[Mf]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(Mf),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const n=this.Hd("$stored_group_properties")||{},r=ce({},n);for(const o of Object.keys(e))r[o]=ce(ce({},n[o]),e[o]);this.$t({[Of]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.Hd("$stored_group_properties")||{};this.$t({[Of]:ce(ce({},t),{},{[e]:{}})})}else this.Lt(Of)}reset(){this.fd++,this.gd=!1,this.ld={},this.ud={},this.zd=void 0,this.dd=!1,this.pd=!1,this.md=!1,this.$anon_distinct_id=void 0,this.Bd(),this.ad=!1,this.bd=0}}},Rbn={sessionRecording:class{get Mr(){return this._instance.config}get Tl(){return this._instance.persistence}get started(){var e;return!!(!((e=this.ov)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.av==="awaiting_config"||this.av==="missing_config"?this.av:(e=(t=this.ov)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.av}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.av=l9,this.lv=void 0,this.uv=!1,this.Je=(()=>{var t,n;if(!(Fe!=null&&Fe.visibilityState)||Fe.visibilityState==="visible")return!0;const r=ke==null||(t=ke.performance)===null||t===void 0||(n=t.getEntriesByType)===null||n===void 0?void 0:n.call(t,"visibility-state");return!(r!=null&&r.length)||r.some(o=>o.name==="visible")})(),this.sn=()=>{var t,n;(Fe==null?void 0:Fe.visibilityState)==="visible"&&(this.Je=!0,(t=this.ov)===null||t===void 0||(n=t.setDocumentWasEverVisible)===null||n===void 0||n.call(t,!0))},!this._instance.sessionManager)throw gd.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');Fe!=null&&Fe.addEventListener&&Zn(Fe,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.uv=!0,Fe==null||(t=Fe.removeEventListener)===null||t===void 0||t.call(Fe,"visibilitychange",this.sn),e?this.hv(!0):this.stopRecording()}get dv(){var e;const t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),n=!this.Mr.disable_session_recording,r=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return ke&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(this.uv||this.dv&&(!((t=this.ov)===null||t===void 0)&&t.isStarted))return;const n=!Le(Object.assign)&&!Le(Array.from);this.dv&&n?(this.vv(e),gd.info("starting")):(this.av=l9,this.stopRecording())}vv(e){var t,n;if(this.dv)if(this.av!=="awaiting_config"&&this.av!=="missing_config"&&(this.av=v1e),($t==null||(t=$t.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((n=$t.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording))this.fv(e);else{var r,o;const a=this._instance.sessionManager;(r=$t.__PosthogExtensions__)===null||r===void 0||(o=r.loadExternalDependency)===null||o===void 0||o.call(r,this._instance,this.pv,i=>{if(!this.uv&&this.dv&&this._instance.sessionManager===a)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),gd.error("could not load recorder",i)):void this.fv(e);this.av="disabled"})}}stopRecording(){var e,t;(e=this.lv)===null||e===void 0||e.call(this),this.lv=void 0,(t=this.ov)===null||t===void 0||t.stop()}hv(e=!1){var t,n;(t=this.lv)===null||t===void 0||t.call(this),this.lv=void 0,(n=this.ov)===null||n===void 0||n.discard({discardProducerEvents:e})}gv(){var e,t;(e=this.Tl)===null||e===void 0||e.unregister("$session_is_sampled"),(t=this.Tl)===null||t===void 0||t.unregister("$replay_sample_rate")}mv(e,t){if(sn(e))return null;const n=xo(e)?e:parseFloat(e);return typeof(r=n)!="number"||!Number.isFinite(r)||0>r||r>1?(gd.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):n;var r}yv(e){if(this.Tl){var t,n;const r=this.Tl,o=()=>{var a;const i=e.sessionRecording===!1?void 0:e.sessionRecording,s=this.mv((a=this.Mr.session_recording)===null||a===void 0?void 0:a.sampleRate,"session_recording.sampleRate"),l=this.mv(i==null?void 0:i.sampleRate,"remote config sampleRate"),c=s??l;sn(c)&&this.gv();const u=i==null?void 0:i.minimumDurationMilliseconds;r.register({[c1]:ce(ce({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:ce({capturePerformance:e.capturePerformance},i==null?void 0:i.networkPayloadCapture),canvasRecording:{enabled:i==null?void 0:i.recordCanvas,fps:i==null?void 0:i.canvasFps,quality:i==null?void 0:i.canvasQuality},sampleRate:c,minimumDurationMilliseconds:Le(u)?null:u,endpoint:i==null?void 0:i.endpoint,triggerMatchType:i==null?void 0:i.triggerMatchType,masking:i==null?void 0:i.masking,urlTriggers:i==null?void 0:i.urlTriggers,version:i==null?void 0:i.version,triggerGroups:i==null?void 0:i.triggerGroups})})};o(),(t=this.lv)===null||t===void 0||t.call(this),this.lv=(n=this._instance.sessionManager)===null||n===void 0?void 0:n.onSessionId(o)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.yv(t),void this.hv()):(this.yv(t),void this.startIfEnabledOrStop()):(this.av==="awaiting_config"&&(this.av="missing_config",this._instance.register_for_session({[Vee]:!0}),gd.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var n;!((n=this.ov)===null||n===void 0)&&n.log?this.ov.log(e,t):gd.warn("log called before recorder was ready")}get pv(){var e,t;const n=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(c1);return(n==null||(t=n.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}bv(){const e=this._instance.get_property(c1);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(n){return gd.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!sn(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}fv(e){var t,n,r;if(!this.uv&&this.dv&&this._instance.sessionManager){if(!(!((t=$t.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return gd.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Hee]:!0});var o;if(this.ov||(this.ov=(o=$t.__PosthogExtensions__)===null||o===void 0?void 0:o.initSessionRecording(this._instance,this.Je),this.ov._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.bv())return this.av==="missing_config"||this.av==="awaiting_config"?void 0:(this.av="awaiting_config",gd.info("persisted remote config is stale, requesting fresh config before starting"),void new oFe(this._instance).load());this.av=v1e,(n=(r=this.ov).setDocumentWasEverVisible)===null||n===void 0||n.call(r,this.Je),this.ov.start(e)}else this.av=l9}onRRwebEmit(e){var t,n;(t=this.ov)===null||t===void 0||(n=t.onRRwebEmit)===null||n===void 0||n.call(t,e)}overrideLinkedFlag(){var e,t;this.ov||(t=this.Tl)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.ov)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.ov||(t=this.Tl)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.ov)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,n;this.ov||(n=this.Tl)===null||n===void 0||n.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.ov)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const r of sbn){var n;const o=(n=this._instance.sessionPersistence)===null||n===void 0?void 0:n.get_property(r);Le(o)||(t[r]=o)}return ce(ce({},t),((e=this.ov)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var n;return!!(!((n=this.ov)===null||n===void 0)&&n.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.ov)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},Ibn={autocapture:class extends nbn{constructor(e){super(new rbn(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._v=!1,this._instance=e,this.wv=this.Sv()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.xv();return!!(e.path||e.search||this.Cv(e))}startIfEnabled(){this.isEnabled&&(Je.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.wv=this.Sv(),this.startIfEnabled()}stop(){this.$v&&this.$v(),this.$v=void 0,this.Tv&&this.Tv(),this.Tv=void 0,Je.info("History API monitoring stopped")}monitorHistoryChanges(){ke&&ke.history&&(this.Iv("pushState"),this.Iv("replaceState"),this.Mv(),this.Cv()&&this.Ev())}Iv(e){var t;if(!ke||!((t=ke.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const n=this;ik(ke.history,e,r=>function(o,a,i){var s;n.Pv(i)&&n.Rv(),r.call(this,o,a,i),n.Av(e,!n._v&&(ke==null||(s=ke.event)===null||s===void 0?void 0:s.type)!=="popstate")})}Sv(){const e=ke==null?void 0:ke.location;if(e!=null&&e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}xv(){const e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:Rn(e)?e:{}}Cv(e=this.xv()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}Fv(e){const t=this.xv(),n=this.wv;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this.Cv(t)&&e.hash!==n.hash))}Av(e,t=!1){try{t||this.Rv();const n=this.Sv();if(!n)return;if(this.Fv(n)){const r=()=>this._instance.capture(Wee,{navigation_type:e});t?(this.Ov=r,Promise.resolve().then(()=>this.Rv())):r()}this.wv=n}catch(n){Je.error(`Error capturing ${e} pageview`,n)}}Pv(e){var t,n;return!(sn(e)||!ke)&&((t=cp(String(e)))===null||t===void 0?void 0:t.href)!==((n=ke.location)===null||n===void 0?void 0:n.href)}Rv(){const e=this.Ov;if(e){this.Ov=void 0,this._v=!0;try{e()}catch(t){Je.error("Error capturing deferred pageview",t)}finally{this._v=!1}this.wv=this.Sv()}}Mv(){if(this.$v)return;const e=()=>{this.Av("popstate")};Zn(ke,"popstate",e),this.$v=()=>{ke&&ke.removeEventListener("popstate",e)}}Ev(){if(this.Tv)return;const e=()=>{this.Av("hashchange")};Zn(ke,"hashchange",e),this.Tv=()=>{ke&&ke.removeEventListener("hashchange",e)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(e){var t;this.Dv=!1,this.wo=!1,this.Lv=null,this.instance=e,this.Dv=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[VB]),this.rageclicks=new CFe(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return Rn(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return sn(this.Mr.capture_heatmaps)?sn(this.Mr.enable_heatmaps)?this.Dv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.wo)return;lbn.info("starting..."),this.Nv(),this.sn()}else{var e;clearInterval((e=this.Lv)!==null&&e!==void 0?e:void 0),this.qv(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[VB]:n}),this.Dv=n,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}jv(e){c9(e.originalEvent)&&this.Cr(e.originalEvent,"deadclick")}sn(){this.Lv&&clearInterval(this.Lv),this.Lv=(Fe==null?void 0:Fe.visibilityState)==="visible"?setInterval(this.ml.bind(this),this.flushIntervalMilliseconds):null}Nv(){ke&&Fe&&(this.Bv=this.ml.bind(this),Zn(ke,CN,this.Bv),this.Hv=e=>this.Cr(e||(ke==null?void 0:ke.event)),Zn(Fe,"click",this.Hv,{capture:!0}),this.zv=e=>this.Uv(e||(ke==null?void 0:ke.event)),Zn(Fe,"mousemove",this.zv,{capture:!0}),this.Wv=new G_e(this.instance,lmn,this.jv.bind(this)),this.Wv.startIfEnabledOrStop(),this.Vv=this.sn.bind(this),Zn(Fe,tk,this.Vv),this.wo=!0)}qv(){var e;ke&&Fe&&(this.Bv&&ke.removeEventListener(CN,this.Bv),this.Hv&&Fe.removeEventListener("click",this.Hv,{capture:!0}),this.zv&&Fe.removeEventListener("mousemove",this.zv,{capture:!0}),this.Vv&&Fe.removeEventListener(tk,this.Vv),clearTimeout(this.Gv),(e=this.Wv)===null||e===void 0||e.stop(),this.wo=!1)}Zv(e,t){const n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),o=this.instance.scrollManager.scrollElement(),a=(function(i,s,l){let c=i;for(;c&&Mu(c)&&!Wa(c,"body");){if(c===l)return!1;let g;try{var u,d,f;g=(u=(d=(f=c.ownerDocument)===null||f===void 0?void 0:f.defaultView)!==null&&d!==void 0?d:ke)===null||u===void 0?void 0:u.getComputedStyle(c).position}catch{return!1}if(Kt(s,g))return!0;c=UUe(c)}return!1})(p1(e),["fixed","sticky"],o);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}Cr(e,t="click"){var n;if(j_e(e.target)||!c9(e))return;const r=this.Zv(e,t);!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&BUe(p1(e),this.instance.config.rageclick)&&this.Zs(ce(ce({},r),{},{type:"rageclick"})),this.Zs(r)}Uv(e){!j_e(e.target)&&c9(e)&&(clearTimeout(this.Gv),this.Gv=setTimeout(()=>{this.Zs(this.Zv(e,"mousemove"))},500))}Zs(e){if(!ke)return;const t=this.Mr.disable_capture_url_hashes?eh(ke.location.href):ke.location.href,n=this.Mr.custom_personal_data_properties,r=this.Mr.mask_personal_data_properties?[...S0,...n||[]]:[],o=ok(t,r,ak);this.Rt=this.Rt||{},this.Rt[o]||(this.Rt[o]=[]),this.Rt[o].push(e)}ml(){this.Rt&&!Qi(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:G_e,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.Dv=!1,this.wo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Qv=()=>{clearTimeout(this.Jv),this.Jv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",ce({$current_url:this.Rt.url},this.Rt.metrics.reduce((n,r)=>ce(ce({},n),{},{[`$web_vitals_${r.name}_event`]:ce({},r),[`$web_vitals_${r.name}_value`]:r.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Kv=n=>{var r;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},sn(n==null?void 0:n.name)||sn(n==null?void 0:n.value))return void ug.error("Invalid metric received",n);const o=typeof n.navigationURL=="string"?n.navigationURL:void 0,a=this.Xv(o);if(Le(a))return;const i=xo(n.navigationId)||typeof n.navigationId=="string"?`navigation:${n.navigationId}`:`url:${a}`;if(this.Yv&&n.value>=this.Yv)return void ug.error("Ignoring metric with value >= "+this.Yv,n);this.Rt.navigationKey!==i&&(this.Qv(),this.Jv=setTimeout(this.Qv,this.flushToCaptureTimeoutMs)),Le(this.Rt.navigationKey)&&(this.Rt.navigationKey=i,this.Rt.url=a),this.Rt.firstMetricTimestamp=Le(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const s=(r=this._instance.sessionManager)===null||r===void 0?void 0:r.checkAndGetSessionAndWindowId(!0),l=ce(ce(ce({},n),o?{navigationURL:a}:{}),{},{$current_url:a,timestamp:Date.now()});if(delete l.entries,Rn(n.attribution)&&this.attributionMetrics.indexOf(n.name)>-1){const c={};for(const u of ibn){const d=u==="url"&&typeof n.attribution[u]=="string"?this.Xv(n.attribution[u]):n.attribution[u];Le(d)||(c[u]=d)}l.attribution=c}else delete l.attribution;Le(s)||(l.$session_id=s.sessionId,l.$window_id=s.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.Qv()},this.tf=()=>{if(this.wo)return;let n,r,o,a,i=!1;const s=$t.__PosthogExtensions__,l=s==null?void 0:s.postHogWebVitalsCallbacksByFlavor,c=(l==null?void 0:l[this.ef])||(this.ef==="web-vitals"&&Le(l)?s==null?void 0:s.postHogWebVitalsCallbacks:void 0);if(!Le(c)){const f=c.withoutAttribution,g=this.attributionMetrics;i=!Le(f),n=g.indexOf("LCP")>-1?c.onLCP:(f==null?void 0:f.onLCP)||c.onLCP,r=g.indexOf("CLS")>-1?c.onCLS:(f==null?void 0:f.onCLS)||c.onCLS,o=g.indexOf("FCP")>-1?c.onFCP:(f==null?void 0:f.onFCP)||c.onFCP,a=g.indexOf("INP")>-1?c.onINP:(f==null?void 0:f.onINP)||c.onINP}if(!(n&&r&&o&&a))return void ug.error("web vitals callbacks not loaded - not starting");const u={reportSoftNavs:this.useSoftNavs},d=i&&this.attributionMetrics.indexOf("INP")>-1?ce(ce({},u),{},{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&n(this.Kv.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Kv.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&o(this.Kv.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&a(this.Kv.bind(this),d),this.wo=!0},this.Dv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[KB]),this.startIfEnabled()}get if(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const n=Rn(this.if)?(e=this.if)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return sn(n)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||b1e:n}get flushToCaptureTimeoutMs(){return(Rn(this.if)?this.if.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=Rn(this.if)?this.if.web_vitals_attribution:void 0;return Mi(e)?e?b1e:[]:Yt(e)?e:abn}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=Rn(this.if)?this.if.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Yv(){const e=Rn(this.if)&&xo(this.if.__web_vitals_max_value)?this.if.__web_vitals_max_value:m1e;return e>0&&6e4>=e?m1e:e}get isEnabled(){const e=uo==null?void 0:uo.protocol;if(e!=="http:"&&e!=="https:")return ug.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=Rn(this.if)?this.if.web_vitals:Mi(this.if)?this.if:void 0;return Mi(t)?t:this.Dv}startIfEnabled(){this.isEnabled&&!this.wo&&(ug.info("enabled, starting..."),this.Bo(this.tf))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const n=Rn(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=Rn(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[KB]:n}),this._instance.persistence.register({[hUe]:r})),this.Dv=n,this.startIfEnabled()}get ef(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Bo(e){var t;const n=$t.__PosthogExtensions__,r=this.ef,o=n==null?void 0:n.postHogWebVitalsCallbacksByFlavor;o!=null&&o[r]||r==="web-vitals"&&Le(o)&&(n!=null&&n.postHogWebVitalsCallbacks)?e():n==null||(t=n.loadExternalDependency)===null||t===void 0||t.call(n,this._instance,r,a=>{a?ug.error("failed to load script",a):e()})}Xv(e){const t=e||(ke==null?void 0:ke.location.href);if(!t)return void ug.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?eh(t):t,r=this._instance.config.custom_personal_data_properties,o=this._instance.config.mask_personal_data_properties?[...S0,...r||[]]:[];return ok(n,o,ak)}}},Nbn={exceptionObserver:class{constructor(e){var t;this.tf=()=>{var n;if(!ke||!this.isEnabled||!(!((n=$t.__PosthogExtensions__)===null||n===void 0)&&n.errorWrappingFunctions))return;const r=$t.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=$t.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=$t.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.nf&&this.Mr.capture_unhandled_errors&&(this.nf=r(this.captureException.bind(this))),!this.sf&&this.Mr.capture_unhandled_rejections&&(this.sf=o(this.captureException.bind(this))),!this.rf&&this.Mr.capture_console_errors&&(this.rf=a(this.captureException.bind(this)))}catch(i){s_.error("failed to start",i),this.af()}},this._instance=e,this.lf=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[GB]),this.wt=new Chn(ce(ce({},(function(n={}){var r,o,a,i;return{refillRate:(r=(o=n.exceptionRateLimiterRefillRate)!==null&&o!==void 0?o:n.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(a=(i=n.exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:n.__exceptionRateLimiterBucketSize)!==null&&a!==void 0?a:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:s_})),this.Mr=this.uf(),this.startIfEnabledOrStop()}uf(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Rn(e)?t=ce(ce({},t),e):(Le(e)?this.lf:e)&&(t=ce(ce({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(s_.info("enabled"),this.af(),this.Bo(this.tf)):this.af()}Bo(e){var t,n,r;!((t=$t.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(n=$t.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"exception-autocapture",o=>{if(o)return s_.error("failed to load script",o);e()})}af(){var e,t,n;(e=this.nf)===null||e===void 0||e.call(this),this.nf=void 0,(t=this.sf)===null||t===void 0||t.call(this),this.sf=void 0,(n=this.rf)===null||n===void 0||n.call(this),this.rf=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.lf=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[GB]:this.lf}),this.Mr=this.uf(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.uf()}captureException(e){try{var t,n,r;const o=(t=e==null||(n=e.$exception_list)===null||n===void 0||(n=n[0])===null||n===void 0?void 0:n.type)!==null&&t!==void 0?t:"Exception";if(this.wt.consumeRateLimit(o))return void s_.info("Skipping exception capture because of client rate limiting.",{exception:o});(r=this._instance.exceptions)===null||r===void 0||r.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){var t,n;this.hf=[],this.cf=new Uhn([new tgn,new ugn,new rgn,new ngn,new lgn,new sgn,new agn,new cgn],(function(r,...o){return(a,i=0)=>{const s=[],l=a.split(`
1110
1110
  `),c=Math.min(l.length,i+1e3),u=[];for(let g=i;c>g;g++){const b=l[g];if(b.length>1024)continue;const v=b_e.test(b)?b.replace(b_e,"$1"):b;if(!v.match(/\S*Error: /)){for(const y of o){const w=y(v,r);if(w){s.push(w);const S=qhn(s);if(S){for(let E=u.length-1;E>=0;E--){const A=u[E];if(S.start>=A.start+A.length)break;u.pop()}u.push(S)}break}}if(Jhn(s,u)>=50)break}}const d=[...u].sort((g,b)=>b.start-g.start),f=d[d.length-1];if(f){const g=X9e(s,f);s.splice(f.start-g,g);for(const b of d)b.start-=g}for(const g of d)Qhn(s,g);return u.some(g=>g.start===0&&s.length===g.length)&&(function(g){const b=g.map(y=>`${y.function}|${y.filename}|${y.lineno}|${y.colno}|${y.module}`);let v=0;for(let y=1;b.length>y;y++)egn(b,y,v)&&(v=y);g.push(...g.splice(0,v))})(s),(function(g){if(!g.length)return[];const b=Array.from(g);return b.reverse(),b.slice(0,50).map(v=>{return ce(ce({},v),{},{filename:v.filename||(y=b,y[y.length-1]||{}).filename,function:v.function||"?"});var y})})(s)}})("web:javascript",Khn,Xhn)),this._instance=e,this.hf=(t=(n=this._instance.persistence)===null||n===void 0?void 0:n.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.df=SN(this.vf()),this.ff=new pgn(this.df)}onConfigChange(){this.df=SN(this.vf()),this.ff.setConfig(this.df)}onRemoteConfig(e){var t,n,r;if(!e.ok)return;const o=e.config;if(!("errorTracking"in o))return;const a=(t=(n=o.errorTracking)===null||n===void 0?void 0:n.suppressionRules)!==null&&t!==void 0?t:[],i=(r=o.errorTracking)===null||r===void 0?void 0:r.captureExtensionExceptions;this.hf=a,this._instance.persistence&&this._instance.persistence.register({[pUe]:this.hf,[WB]:i})}get pf(){var e;const t=!!this._instance.get_property(WB),n=this._instance.config.error_tracking.captureExtensionExceptions;return(e=n??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.cf.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}addExceptionStep(e,t){if(this.df.enabled)try{if(!kn(e)||e.trim().length===0)return void Zl.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:n,droppedKeys:r}=(function(o){if(!o)return{sanitizedProperties:{},droppedKeys:[]};const a=[];return{sanitizedProperties:Object.keys(o).reduce((i,s)=>dgn.has(s)?(a.push(s),i):(i[s]=o[s],i),{}),droppedKeys:a}})(this.gf(t));r.length>0&&Zl.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.ff.add(ce({[wN]:e,[_N]:new Date().toISOString()},n))}catch(n){Zl.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this.mf(t)){if(this.yf(t))return this.bf("Exception dropped: matched a suppression rule"),void Zl.info("Skipping exception capture because a suppression rule matched");if(!this.pf&&this._f(t))return this.bf("Exception dropped: thrown by a browser extension"),void Zl.info("Skipping exception capture because it was thrown by an extension");if(!this.pf&&this.wf(t))return this.bf("Exception dropped: thrown by an injected browser script"),void Zl.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.kf(t))return this.bf("Exception dropped: thrown by the PostHog SDK"),void Zl.info("Skipping exception capture because it was thrown by the PostHog SDK")}const n=this.df.enabled&&sn(e.$exception_steps)?this.Sf(e):e,r=(function(){const o=globalThis._posthogReleaseId;return typeof o=="string"&&o.length>0?o:void 0})();r&&(n.$release_id=r);try{const o=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",dh:!0});return o&&this.ff.clear(),o}catch(o){return R1e(o)||Zl.error("Failed to capture exception event. Dropping this exception.",o),void this.ff.clear()}}catch(t){return void(R1e(t)||Zl.error("Failed to process exception event. Ignoring this exception.",t))}}Sf(e){try{const t=this.ff.getAttachable();return t.length===0?e:ce(ce({},e),{},{$exception_steps:t})}catch(t){return Zl.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}bf(e){this.df.enabled&&this.ff.add({[wN]:e,[_N]:new Date().toISOString()})}gf(e){return Rn(e)?ce({},e):{}}vf(){var e,t;return(e=(t=this._instance.config.error_tracking)===null||t===void 0?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}yf(e){if(e.length===0)return!1;try{const t=e.reduce((n,{type:r,value:o})=>(kn(r)&&r.length>0&&n.$exception_types.push(r),kn(o)&&o.length>0&&n.$exception_values.push(o),n),{$exception_types:[],$exception_values:[]});return this.hf.some(n=>{const r=n.values.map(o=>{const a=kFe[o.operator],i=t[o.key];if(!a||!i)return!1;const s=Yt(o.value)?o.value:[o.value];return s.length>0&&a(s,i)});return n.type==="OR"?r.some(Boolean):r.every(Boolean)})}catch(t){return Zl.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}_f(e){const t=e.flatMap(r=>{var o,a;return(o=(a=r.stacktrace)===null||a===void 0?void 0:a.frames)!==null&&o!==void 0?o:[]}),n=t.filter(({filename:r})=>!!r&&xbn.some(o=>r.startsWith(o)));return n.length!==0&&(!n.every(({filename:r})=>!!r&&r.startsWith(lH))||e.some(({type:r,value:o})=>r==="NoResponse"||kn(o)&&ybn.some(({value:a,exact:i})=>i?o===a:o.includes(a)))&&!t.some(({in_app:r,filename:o})=>r&&!(o!=null&&o.startsWith(lH))))}wf(e){return e.some(({value:t})=>kn(t)&&wbn.some(n=>t.includes(n)))}kf(e){if(e.length>0){var t,n,r,o;const a=(t=(n=e[0].stacktrace)===null||n===void 0?void 0:n.frames)!==null&&t!==void 0?t:[],i=a[a.length-1];return(r=i==null||(o=i.filename)===null||o===void 0?void 0:o.includes("posthog.com/static"))!==null&&r!==void 0&&r}return!1}mf(e){return!sn(e)&&Yt(e)}}},Mbn=ce({productTours:class{get Tl(){return this._instance.persistence}constructor(e){this.xf=null,this.Cf=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var n,r;if(this.Tl&&this.Tl.register({[Fee]:!!t.productTours}),!u9(this._instance))return!this.xf&&sn((n=this.Tl)===null||n===void 0?void 0:n.props.ph_product_tours)||SC.info("product tours disabled; stopping and clearing cached tours"),(r=this.xf)===null||r===void 0||r.stop(),this.xf=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.xf&&u9(this._instance)&&this.Bo(()=>this.$f())}Bo(e){var t,n,r;!((t=$t.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(n=$t.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"product-tours",o=>{o?SC.error("Could not load product tours script",o):e()})}$f(){var e;!this.xf&&(!((e=$t.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.xf=$t.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(Yt(this.Cf)&&!t)return void e(this.Cf,{isLoaded:!0});const n=this.Tl;if(n){const r=n.props[ZB];if(Yt(r)&&!t)return this.Cf=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:r=>{if(!u9(this._instance))return void e([],{isLoaded:!0});const o=r.statusCode;if(o!==200||!r.json){const i=`Product Tours API could not be loaded, status: ${o}`;return o===0?r.error||SC.warn(i):SC.error(i),void e([],{isLoaded:!1,error:i})}const a=Yt(r.json.product_tours)?r.json.product_tours:[];this.Cf=a,n&&n.register({[ZB]:a}),e(a,{isLoaded:!0})}})}getActiveProductTours(e){sn(this.xf)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.xf.getActiveProductTours(e)}showProductTour(e){var t;(t=this.xf)===null||t===void 0||t.showTourById(e)}previewTour(e){this.xf?this.xf.previewTour(e):this.Bo(()=>{var t;this.$f(),(t=this.xf)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.xf)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.xf)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.xf)===null||e===void 0||e.previousStep()}clearCache(){var e;this.Cf=null,(e=this.Tl)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.xf)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.xf)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.xf)===null||t===void 0||t.cancelPendingTour(e)}}},H3),Obn={siteApps:class{constructor(e){this._instance=e,this.Tf=0,this.If=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Mf(e,t){if(!t)return;const n=this.globalsForEvent(t);this.If.push(n),this.If.length>1e3&&(this.If=this.If.slice(10))}get siteAppLoaders(){var e;return(e=$t._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this.Mf.bind(this));this.Ef=()=>{e(),this.If=[],this.Ef=void 0}}}globalsForEvent(e){var t,n,r,o,a,i,s;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[g,b]of Object.entries(u))l[g]={id:c[g],type:g,properties:b};const{$set_once:d,$set:f}=e;return{event:ce(ce({},eUe(e,cbn)),{},{properties:ce(ce(ce({},e.properties),f?{$set:ce(ce({},(t=(n=e.properties)===null||n===void 0?void 0:n.$set)!==null&&t!==void 0?t:{}),f)}:{}),d?{$set_once:ce(ce({},(r=(o=e.properties)===null||o===void 0?void 0:o.$set_once)!==null&&r!==void 0?r:{}),d)}:{}),elements_chain:(a=(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)!==null&&a!==void 0?a:"",distinct_id:(s=e.properties)===null||s===void 0?void 0:s.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}Pf(e){var t;const n=(t=e.tagName)===null||t===void 0?void 0:t.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Gc.error("prepare_external_dependency_stylesheet returned null"),null):n==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Gc.error("prepare_external_dependency_script returned null"),null):e}Rf(){var e,t,n,r,o,a,i,s;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=Fe==null?void 0:Fe.defaultView,c=l==null||(e=l.Node)===null||e===void 0?void 0:e.prototype;if(!l||!c)return()=>{};if(this.Tf++,this.Af)return this.Ff();const u=[],d=this,f=new WeakSet,g=(y,w,S)=>{if(!(y!=null&&y[w]))return;const E=y[w];y[w]=S(E),u.push(()=>{y[w]=E})},b=y=>{if(f.has(y))return y;const w=d.Pf(y);return w&&f.add(w),w},v=y=>y.map(w=>typeof w=="string"?w:b(w)).filter(w=>!fo(w));return g(c,"appendChild",y=>function(w){const S=b(w);return S?y.call(this,S):w}),g(c,"insertBefore",y=>function(w,S){const E=b(w);return E?y.call(this,E,S):w}),g(c,"replaceChild",y=>function(w,S){const E=b(w);return E?y.call(this,E,S):S}),[(t=l.Element)===null||t===void 0?void 0:t.prototype,(n=l.Document)===null||n===void 0?void 0:n.prototype,(r=l.DocumentFragment)===null||r===void 0?void 0:r.prototype].forEach(y=>{g(y,"append",w=>function(...S){return w.apply(this,v(S))}),g(y,"prepend",w=>function(...S){return w.apply(this,v(S))})}),[(o=l.Element)===null||o===void 0?void 0:o.prototype,(a=l.CharacterData)===null||a===void 0?void 0:a.prototype,(i=l.DocumentType)===null||i===void 0?void 0:i.prototype].forEach(y=>{g(y,"before",w=>function(...S){return w.apply(this,v(S))}),g(y,"after",w=>function(...S){return w.apply(this,v(S))}),g(y,"replaceWith",w=>function(...S){const E=v(S);return S.length&&!E.length?void 0:w.apply(this,E)})}),g((s=l.Element)===null||s===void 0?void 0:s.prototype,"insertAdjacentElement",y=>function(w,S){const E=b(S);return E?y.call(this,w,E):null}),this.Af=()=>{u.forEach(y=>y()),this.Af=void 0},this.Ff()}Ff(){let e=!1;return()=>{var t;e||(e=!0,this.Tf--,this.Tf===0&&((t=this.Af)===null||t===void 0||t.call(this)))}}Of(e,t=!0){const n=this.Rf();try{const r=e(n);return t&&n(),r}catch(r){throw n(),r}}setupSiteApp(e){const t=this.apps[e.id],n=()=>{var a;!t.errored&&this.If.length&&(Gc.info(`Processing ${this.If.length} events for site app with id ${e.id}`),this.If.forEach(i=>this.Of(()=>{var s;return(s=t.processEvent)===null||s===void 0?void 0:s.call(t,i)})),t.processedBuffer=!0),Object.values(this.apps).every(i=>i.processedBuffer||i.errored)&&((a=this.Ef)===null||a===void 0||a.call(this))};let r=!1;const o=a=>{t.errored=!a,t.loaded=!0,Gc.info(`Site app with id ${e.id} ${a?"loaded":"errored"}`),r&&n()};try{const{processEvent:a}=this.Of(i=>e.init({posthog:this._instance,callback(s){i(),o(s)}}),!1);a&&(t.processEvent=a),r=!0}catch(a){Gc.error(y1e+e.id,a),o(!1)}if(r&&t.loaded)try{n()}catch(a){Gc.error(`Error while processing buffered events PostHog app with config id ${e.id}`,a),t.errored=!0}}Df(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}Lf(e){if(Object.keys(this.apps).length===0)return;const t=this.globalsForEvent(e);for(const n of Object.values(this.apps))try{this.Of(()=>{var r;return(r=n.processEvent)===null||r===void 0?void 0:r.call(n,t)})}catch(r){Gc.error(`Error while processing event ${e.event} for site app ${n.id}`,r)}}onRemoteConfig(e){var t,n,r;if(!((t=this.siteAppLoaders)===null||t===void 0)&&t.length)return this.isEnabled?(this.Df(),void this._instance.on("eventCaptured",s=>this.Lf(s))):void Gc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.Ef)===null||n===void 0||n.call(this),!e.ok)return;const o=e.config;if(!((r=o.siteApps)===null||r===void 0)&&r.length)if(this.isEnabled)for(const{id:s,url:l}of o.siteApps){var a,i;$t[`__$$ph_site_app_${s}`]=this._instance,(a=$t.__PosthogExtensions__)===null||a===void 0||(i=a.loadSiteApp)===null||i===void 0||i.call(a,this._instance,l,c=>{if(c)return Gc.error(y1e+s,c)})}else Gc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Pbn={tracingHeaders:class{constructor(e){this._instance=e,this.Nf=void 0,this.qf=void 0,this.jf=void 0,this.tf=()=>{const t=this.Bf();var n,r;t?(Le(this.Nf)&&(this.Nf=(n=$t.__PosthogExtensions__)===null||n===void 0||(n=n.tracingHeadersPatchFns)===null||n===void 0?void 0:n._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),Le(this.qf)&&(this.qf=(r=$t.__PosthogExtensions__)===null||r===void 0||(r=r.tracingHeadersPatchFns)===null||r===void 0?void 0:r._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.af()}}initialize(){this.startIfEnabledOrStop()}Bo(e){var t,n,r;!((t=$t.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(n=$t.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"tracing-headers",o=>{if(o)return obn.error("failed to load script",o);e()})}Hf(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}Bf(){const e=this.Hf();return Yt(e)?(Yt(this.jf)?this.jf.splice(0,this.jf.length,...e):this.jf=[...e],e.length>0?this.jf:void 0):(Yt(this.jf)&&this.jf.splice(0),this.jf=e||void 0,this.jf)}af(){var e,t;(e=this.Nf)===null||e===void 0||e.call(this),(t=this.qf)===null||t===void 0||t.call(this),this.Nf=void 0,this.qf=void 0}startIfEnabledOrStop(){this.Bf()?this.Bo(this.tf):this.af()}}},jbn=ce({surveys:class extends ubn{constructor(e){var t;super(new gbn(e),(t=e,{get projectToken(){return t.config.token},kv:new hbn(t)})),this._instance=e}Wh(e,t){const n=t.query?pE(e,t.query):e;return new Promise(r=>{var o;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((o=t.target)!==null&&o!==void 0?o:"api",n),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:r})})}}},H3),Dbn={toolbar:class{constructor(e){this.instance=e}zf(e){$t.ph_toolbar_state=e}Uf(){var e;return(e=$t.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,n=void 0){var r,o;if(qB(this.instance.config)||!ke||!Fe)return!1;e=(r=e)!==null&&r!==void 0?r:ke.location,n=(o=n)!==null&&o!==void 0?o:ke.history;try{if(!t){try{ke.localStorage.setItem("test","test"),ke.localStorage.removeItem("test")}catch{return!1}t=ke==null?void 0:ke.localStorage}const a=mbn||IN(e.hash,"__posthog")||IN(e.hash,"state");let i;const s=a?f_e(()=>JSON.parse(atob(decodeURIComponent(a))))||f_e(()=>JSON.parse(decodeURIComponent(a))):null;return s&&s.action==="ph_authorize"?(i=s,i.source="url",i&&Object.keys(i).length>0&&(s.desiredHash?e.hash=s.desiredHash:n?n.replaceState(n.state,"",e.pathname+e.search):e.hash="")):(i=JSON.parse(t.getItem(w1e)||"{}"),i.source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Wf(e){const t=$t.ph_load_toolbar||$t.ph_load_editor;!sn(t)&&ca(t)?t(e,this.instance):_1e.warn("No toolbar load function found")}loadToolbar(e){const t=!!(Fe!=null&&Fe.getElementById("__POSTHOG_TOOLBAR__"));if(!ke||t)return!1;const n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=ce(ce({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(ke.localStorage.setItem(w1e,JSON.stringify(ce(ce({},r),{},{source:void 0}))),this.Uf()===2)this.Wf(r);else if(this.Uf()===0){var o,a;this.zf(1),(o=$t.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"toolbar",i=>{if(i)return _1e.error("[Toolbar] Failed to load",i),void this.zf(0);this.zf(2),this.Wf(r)}),Zn(ke,"turbolinks:load",()=>{this.zf(0),this.loadToolbar(r)})}return!0}Vf(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,n=void 0){return this.maybeLoadToolbar(e,t,n)}}},Lbn=ce({experiments:class Ti{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(n=!1)=>{this.getWebExperiments(r=>{Ti.Gf("retrieved web experiments from the server"),this.Zf=new Map,r.forEach(o=>{if(o.feature_flag_key){var a;this.Zf&&(Ti.Gf("setting flag key ",o.feature_flag_key," to web experiment ",o),(a=this.Zf)===null||a===void 0||a.set(o.feature_flag_key,o));const i=this._instance.getFeatureFlag(o.feature_flag_key);kn(i)&&o.variants[i]&&this.Qf(o.name,i,o.variants[i].transforms)}else if(o.variants)for(const i in o.variants){const s=o.variants[i];Ti.Jf(s,this._instance)&&this.Qf(o.name,i,s.transforms)}})},n)},this._instance.onFeatureFlags(n=>{this.onFeatureFlags(n)})}initialize(){}onFeatureFlags(t){if(this._is_bot())Ti.Gf(I1e);else if(!this.Mr.disable_web_experiments){if(sn(this.Zf))return this.Zf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ti.Gf("applying feature flags",t),t.forEach(n=>{var r;if(this.Zf&&(!((r=this.Zf)===null||r===void 0)&&r.has(n))){var o;const a=this._instance.getFeatureFlag(n),i=(o=this.Zf)===null||o===void 0?void 0:o.get(n);a&&(i!=null&&i.variants[a])&&this.Qf(i.name,a,i.variants[a].transforms)}})}}previewWebExperiment(){const t=Ti.getWindowLocation();if(t!=null&&t.search){const n=_0(t==null?void 0:t.search,"__experiment_id"),r=_0(t==null?void 0:t.search,"__experiment_variant");n&&r&&(Ti.Gf(`previewing web experiments ${n} && ${r}`),this.getWebExperiments(o=>{this.Kf(parseInt(n),r,o)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,r){if(this.Mr.disable_web_experiments&&!r)return t([]);const o=this._instance.get_property("$web_experiments");if(o&&!n)return t(o);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:a=>t(a.statusCode===200&&a.json&&a.json.experiments||[])})}Kf(t,n,r){const o=r.filter(a=>a.id===t);o&&o.length>0&&(Ti.Gf(`Previewing web experiment [${o[0].name}] with variant [${n}]`),this.Qf(o[0].name,n,o[0].variants[n].transforms))}static Jf(t,n){return!sn(t.conditions)&&Ti.Xf(t,n)&&Ti.Yf(t)}static Xf(t,n){var r;if(sn(t.conditions)||sn((r=t.conditions)===null||r===void 0?void 0:r.url))return!0;const o=Ti.getWindowLocation();if(o){var a,i,s;const l=LUe(n,o.href);return!(!((a=t.conditions)===null||a===void 0)&&a.url)||_bn[(i=(s=t.conditions)===null||s===void 0?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return ke==null?void 0:ke.location}static Yf(t){var n;if(sn(t.conditions)||sn((n=t.conditions)===null||n===void 0?void 0:n.utm))return!0;const r=ZUe();if(r.utm_source){var o,a,i,s,l,c,u,d;const f=!(!((o=t.conditions)===null||o===void 0||(o=o.utm)===null||o===void 0)&&o.utm_campaign)||((a=t.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_campaign)==r.utm_campaign,g=!(!((i=t.conditions)===null||i===void 0||(i=i.utm)===null||i===void 0)&&i.utm_source)||((s=t.conditions)===null||s===void 0||(s=s.utm)===null||s===void 0?void 0:s.utm_source)==r.utm_source,b=!(!((l=t.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((c=t.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0?void 0:c.utm_medium)==r.utm_medium,v=!(!((u=t.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0)&&u.utm_term)||((d=t.conditions)===null||d===void 0||(d=d.utm)===null||d===void 0?void 0:d.utm_term)==r.utm_term;return f&&b&&v&&g}return!1}static Gf(t,...n){Je.info(`[WebExperiments] ${t}`,n)}Qf(t,n,r){this._is_bot()?Ti.Gf(I1e):n!=="control"?r.forEach(o=>{if(o.selector){var a;Ti.Gf(`applying transform of variant ${n} for experiment ${t} `,o);const i=(a=document)===null||a===void 0?void 0:a.querySelectorAll(o.selector);i==null||i.forEach(s=>{const l=s;o.html&&(l.innerHTML=o.html),o.css&&l.setAttribute("style",o.css)})}}):Ti.Gf("Control variants leave the page unmodified.")}_is_bot(){return ua&&this._instance?wFe(ua,this.Mr.custom_blocked_useragents):void 0}}},H3),zbn={conversations:class{constructor(e){this._instance=e,this.tp=void 0,this._conversationsManager=null,this.ep=!1,this.ne=null,this.np=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.sp=e.ok,!e.ok))return;const t=e.config.conversations;sn(t)||(Mi(t)?this.tp=t:(this.tp=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this.tp=void 0,this.ne=null,this.sp=void 0,this.np=!1}loadIfEnabled(){if(this._conversationsManager||this.ep||this._instance.config.disable_conversations||qB(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=$t==null?void 0:$t.__PosthogExtensions__;if(e&&!Le(this.tp)&&this.tp)if(this.ne&&this.ne.token){this.ep=!0;try{const t=e.initConversations;if(t)return this.rp(t),void(this.ep=!1);const n=e.loadExternalDependency;if(!n)return void this.op(Gee);n(this._instance,"conversations",r=>{r||!e.initConversations?this.op("Could not load conversations script",r):this.rp(e.initConversations),this.ep=!1})}catch(t){this.op("Error initializing conversations",t),this.ep=!1}}else fl.error("Conversations enabled but missing token in remote config.")}rp(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.np=!1,fl.info("Conversations loaded successfully")}catch(t){this.op("Error completing conversations initialization",t)}else fl.error("Cannot complete initialization: remote config is null")}op(e,t){fl.error(e,t),this._conversationsManager=null,this.ep=!1,this.np=!0}show(){this._conversationsManager?this._conversationsManager.show():fl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.tp===!0&&!fo(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":qB(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.sp===!1?"remote_config_failed":Le(this.tp)?this.sp?"disabled_in_project":"remote_config_pending":this.tp?sn(this.ne)||!this.ne.token?"missing_token":$t!=null&&$t.__PosthogExtensions__?this.ep?"initializing":this.np?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,n){var r=this;return Zr(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(fl.warn(pg),null)})()}getMessages(e,t){var n=this;return Zr(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(fl.warn(pg),null)})()}markAsRead(e){var t=this;return Zr(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(fl.warn(pg),null)})()}getTickets(e){var t=this;return Zr(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(fl.warn(pg),null)})()}requestRestoreLink(e){var t=this;return Zr(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(fl.warn(pg),null)})()}restoreFromToken(e){var t=this;return Zr(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(fl.warn(pg),null)})()}restoreFromUrlToken(){var e=this;return Zr(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(fl.warn(pg),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}kh(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}Sh(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},$bn={logs:class{constructor(e){var t;this._instance=e,this.name="logs",this.ap=!1,this.lp=!1,this.up=!1,this.A=mo("[logs]"),this.hp=ce(ce({},this.A),{},{error:(...n)=>{n.some(O1e)||this.A.error(...n)}}),this.rl=[],this.cp=[],this.bd=0,this.$o=!1,this.dp=[],this.vp=[],this.fp=!1,this.pp=!1,this.gp=()=>{var n,r;this.$o||(this.bd=0,(n=this.mp)===null||n===void 0||n.onReconnect(),(r=this.yp)===null||r===void 0||r.onReconnect())},this._instance&&(!((t=this._instance.config.logs)===null||t===void 0)&&t.captureConsoleLogs)&&(this.ap=!0),ke&&Zn(ke,"online",this.gp)}bp(e,t,n,r){var o;const a=N1e((o=this._instance)===null||o===void 0||(o=o.config)===null||o===void 0?void 0:o.logs,n);return[new _gn(this._p(e,t),a,this.hp,()=>this.wp(),i=>i(),void 0,r),a]}kp(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var n;return this.mp&&this.Sp===t||((n=this.mp)===null||n===void 0||n.reset(),this.Sp=t,[this.mp,this.xp]=this.bp(()=>this.rl,r=>{this.rl=r})),this.mp}Cp(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var n;return this.yp&&this.$p===t||((n=this.yp)===null||n===void 0||n.reset(),this.$p=t,[this.yp,this.Tp]=this.bp(()=>this.cp,r=>{this.cp=r},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},M1e)),this.yp}setup(e){var t;if(this.$o)return;this.yo=e,!((t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0||(t=t.logs)===null||t===void 0)&&t.captureConsoleLogs&&(this.ap=!0),(this.ap||this.Ip()&&this.Mp())&&this.Ep();let n=!1;const r=e.onRemoteConfig(o=>{var a;n=o.ok&&((a=o.config.logs)===null||a===void 0?void 0:a.captureConsoleLogs)===!0,this.onRemoteConfig(o)});this.$o?r.dispose():(this.Mo=r,n||this.loadIfEnabled())}dispose(){var e,t,n,r;this.$o||(this.$o=!0,this.Pp(),(e=this.Mo)===null||e===void 0||e.dispose(),this.Mo=void 0,this.yo=void 0,this.up=!1,ke==null||ke.removeEventListener("online",this.gp),(t=this.Rp)===null||t===void 0||t.call(this),this.Rp=void 0,(n=this.mp)===null||n===void 0||n.reset(),(r=this.yp)===null||r===void 0||r.reset())}onRemoteConfig(e){var t,n;if(this.$o)return;const r=e.ok?(t=e.config.logs)===null||t===void 0?void 0:t.captureConsoleLogs:void 0;sn(r)?this.Ap():((n=this._instance)===null||n===void 0||(n=n.persistence)===null||n===void 0||n.register({$logs_capture_enabled_server_side:!!r}),r?(this.ap=!0,this.lp||this.Ep(),this.loadIfEnabled()):this.Ap())}reset(){var e,t,n,r;this.Pp(),(e=this.mp)===null||e===void 0||e.clearQueue(),this.rl=[],(t=this.mp)===null||t===void 0||t.reset(),(n=this.yp)===null||n===void 0||n.clearQueue(),this.cp=[],(r=this.yp)===null||r===void 0||r.reset(),this.bd=0}captureLog(e){this.$o||this.kp().captureLog(e)}captureConsoleLog(e){this.$o||this.Cp().captureLog(e)}captureBufferedConsoleLog(e,t,n){this.$o||this.Cp().captureLog(e,{context:t,occurredAtMs:n})}Mp(){var e;return!!(!((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e[fUe])}Ip(){var e,t,n;return!(!((e=this._instance)===null||e===void 0||(t=e.el)===null||t===void 0)&&t.call(e))||!!(!((n=$t._POSTHOG_REMOTE_CONFIG)===null||n===void 0||(n=n[this._instance.config.token])===null||n===void 0)&&n.config)}Ch(){var e;this.Pp(),(e=this.yp)===null||e===void 0||e.clearQueue(),this.cp=[]}Ap(){this.ap||this.Pp()}Ep(){var e;if(this.fp||!($t!=null&&$t.console))return;const t=N1e((e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs).maxBufferSize;let n=!0;this.vp.push(()=>{n=!1});for(const r of Sbn){let o;try{o=kbn($t.console[r])}catch{continue}o&&this.vp.push(ik($t.console,r,a=>{const i=(...s)=>{try{n&&this.Fp(r,s,t)}catch{}return a.apply($t.console,s)};return i.__rrweb_original__=o,i}))}this.fp=!0,this.Op=setTimeout(()=>{this.Pp()},3e4)}Fp(e,t,n){var r;if(this.fp&&!this.pp&&t.length!==0)if(!((r=this._instance)===null||r===void 0)&&r.is_capturing()){if(n>this.dp.length){this.pp=!0;try{this.dp.push({level:e,args:t,occurredAtMs:Date.now(),context:this.wp()})}finally{this.pp=!1}}}else this.Pp()}Pp(){if(this.dp=[],this.fp){this.fp=!1,this.Op&&(clearTimeout(this.Op),this.Op=void 0);for(const e of this.vp)e();this.vp=[]}}Dp(){const e=this.dp;return this.Pp(),e}get logger(){return this.Lp||(this.Lp={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this.Lp}flushLogs(e){e?this.Np(e):(this.mp&&this.mp.flush().catch(t=>this.qp(t)),this.yp&&this.yp.flush().catch(t=>this.qp(t)))}qp(e){O1e(e)||this.A.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.$o||!this.ap||this.lp||this.up)return;const e=$t==null?void 0:$t.__PosthogExtensions__;if(!e)return this.A.error("PostHog Extensions not found."),void this.Pp();const t=e.loadExternalDependency;if(!t)return this.A.error(Gee),void this.Pp();this.up=!0;try{t(this._instance,"logs",n=>{if(this.up=!1,this.$o||!this.ap)return;const r=e.logs;if(n||!(r!=null&&r.initializeLogs))this.A.error("Could not load logs script",n),this.Pp();else{var o;const s=this.Dp();var a,i;this.Rp=r.initializeLogs((o=this.yo)!==null&&o!==void 0?o:this._instance),this.lp=!0,s.length>0&&((a=r.replayConsoleBuffer)===null||a===void 0||a.call(r,(i=this.yo)!==null&&i!==void 0?i:this._instance,s))}})}catch(n){throw this.up=!1,n}}_p(e,t){const n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:r=>r===Qc.LogsQueue?e():void 0,setPersistedProperty(r,o){var a;r===Qc.LogsQueue&&t((a=o)!==null&&a!==void 0?a:[])},js:r=>this.js(r),getLibraryId:()=>ea.LIB_NAME,getLibraryVersion:()=>ea.LIB_VERSION}}js(e){return new Promise(t=>{if(KUe(this.bd,3))return void t({kind:"fatal",error:p9(void 0,"logs endpoint is unreachable, dropping batch")});let n=!1;const r=a=>{n||(n=!0,clearTimeout(o),t(a))},o=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:p9(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.jp(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:a=>{const i=a.statusCode;if(this.Bp(i),i>=200&&300>i)r({kind:"ok"});else if(i===413)r({kind:"too-large"});else if(i!==0&&i!==408&&i!==429&&500>i)r({kind:"fatal",error:new Error(`logs request failed with status ${i}`)});else{var s;i===0?(a.error||this.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:p9(a.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:(s=a.error)!==null&&s!==void 0?s:new Error(`logs request failed with status ${i}`)})}}})})}Bp(e){(e!==0||this._instance.__loaded)&&(this.bd=YUe(e,this.bd,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Np(e){this.rl.length>0&&this.Hp(e,this.rl,this.xp,ea.LIB_NAME,t=>{this.rl=t}),this.cp.length>0&&this.Hp(e,this.cp,this.Tp,M1e,t=>{this.cp=t})}Hp(e,t,n,r,o){if(t.length===0)return;const a=t.map(s=>s.record);o([]);const i=iUe(a,aUe(n,ea.LIB_NAME,ea.LIB_VERSION),r,ea.LIB_VERSION);this._instance._send_request({method:"POST",url:this.jp(),data:i,compression:"best-available",batchKey:"logs",transport:e})}jp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}wp(){var e;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:n,windowId:r,sessionStartTimestamp:o,lastActivityTimestamp:a}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n,t.windowId=r,sn(o)||(t.sessionStartTimestamp=o),sn(a)||(t.lastActivityTimestamp=a)}if(!($t==null||(e=$t.location)===null||e===void 0)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?eh($t.location.href):$t.location.href),this._instance.featureFlags){const n=this._instance.featureFlags.getFlags();n&&n.length>0&&(t.activeFeatureFlags=n)}return t}}},Ubn={metrics:class{constructor(e){this._instance=e,this.A=mo("[metrics]"),this.$o=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this.$o)return;const t=!!(!((e=this._instance.config.metrics)===null||e===void 0)&&e.network);t&&!this.zp?this.zp=(n=>{let r=!0;const o=()=>r?(s=>{var l;const c=(l=s.config.metrics)===null||l===void 0?void 0:l.network;return c===!0?{}:c||void 0})(n):void 0,a=Abn(n,o),i=Cbn(n,o);return()=>{r=!1,a(),i()}})(this._instance):!t&&this.zp&&(this.zp(),this.zp=void 0)}kp(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.metrics;var n;return this.mp&&this.Sp===t||((n=this.mp)===null||n===void 0||n.reset(),this.Sp=t,this.mp=new Sgn(this._p(),(function(r){var o,a,i,s,l;const c=r==null?void 0:r.resourceAttributes;return{serviceName:(o=c==null?void 0:c["service.name"])!==null&&o!==void 0?o:r==null?void 0:r.serviceName,serviceVersion:(a=c==null?void 0:c["service.version"])!==null&&a!==void 0?a:r==null?void 0:r.serviceVersion,environment:(i=c==null?void 0:c["deployment.environment"])!==null&&i!==void 0?i:r==null?void 0:r.environment,resourceAttributes:c,beforeSend:r==null?void 0:r.beforeSend,flushIntervalMs:(s=r==null?void 0:r.flushIntervalMs)!==null&&s!==void 0?s:1e4,maxSeriesPerFlush:(l=r==null?void 0:r.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(t),this.A)),this.mp}count(e,t=1,n){this.kp().count(e,t,n)}gauge(e,t,n){this.kp().gauge(e,t,n)}histogram(e,t,n){this.kp().histogram(e,t,n)}flush(e){if(!this.mp)return Promise.resolve();if(e){const t=this.mp.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this.mp.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this.mp)===null||e===void 0||e.reset()}dispose(){var e,t;this.$o=!0,(e=this.zp)===null||e===void 0||e.call(this),this.zp=void 0,(t=this.mp)===null||t===void 0||t.reset()}_p(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:n=>t.Ys(n),getLibraryId:()=>ea.LIB_NAME,getLibraryVersion:()=>ea.LIB_VERSION}}Ys(e,t){return new Promise(n=>{let r=!1;const o=i=>{r||(r=!0,clearTimeout(a),n(i))},a=setTimeout(()=>o({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(ce(ce({method:"POST",url:this.Up(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(i){const s=i.statusCode;if(s>=200&&300>s)o({kind:"ok"});else if(s===413)o({kind:"too-large"});else if(s!==0&&s!==408&&s!==429&&500>s)o({kind:"fatal",error:new Error(`metrics request failed with status ${s}`)});else{var l;o({kind:"retry-later",error:(l=i.error)!==null&&l!==void 0?l:new Error(`metrics request failed with status ${s}`)})}}}))})}Up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};b1.__defaultExtensionClasses=ce({},ce(ce(ce(ce(ce(ce(ce(ce(ce(ce(ce(ce(ce({},H3),Rbn),Ibn),Nbn),Mbn),Obn),jbn),Pbn),Dbn),Lbn),zbn),$bn),Ubn));(function(){ea.SDK_DIST_CHANNEL="npm";const e=g1[E_]=new b1;return(function(){function t(){t.done||(t.done=!0,yFe=!1,rr(g1,function(n){n._dom_loaded()}))}Fe!=null&&Fe.addEventListener?Fe.readyState==="complete"?t():Zn(Fe,"DOMContentLoaded",t,{capture:!1}):ke&&Je.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();const Fbn="%%TRUEFORGE_BASE_PATH%%";function Bbn(){var t;if(typeof window>"u")return"/";const e=(t=window.__TRUEFORGE_BASE_PATH__)==null?void 0:t.trim();return e===void 0||e===""||e.includes(Fbn)?"/":e.endsWith("/")?e:`${e}/`}const up=Bbn(),V3=up;function Hbn(){return up.length>1?up.replace(/\/$/,""):void 0}function tte(e){const t=e.startsWith("/")?e:`/${e}`;return up==="/"?t:`${up.replace(/\/$/,"")}${t}`}const P1e="monacoeditorwork";function j1e(e){const t=e.split("/").pop();return t===void 0||t===""?`${up}${P1e}/`:`${up}${P1e}/${t}`}function Vbn(){if(typeof window>"u")return;const e=window.MonacoEnvironment;window.MonacoEnvironment={...e,getWorkerUrl(t,n){var o;const r=(o=e==null?void 0:e.getWorkerUrl)==null?void 0:o.call(e,t,n);return typeof r=="string"&&r.length>0?j1e(r):j1e(`${n}.worker.bundle.js`)}}}const Gbn=tte("/api/v1/auth/login"),Wbn=tte("/api/v1/auth/logout");function nte(e=up){const t=new URLSearchParams({return_to:e});return`${Gbn}?${t.toString()}`}function OFe(e=globalThis.fetch.bind(globalThis)){let t=!1;return async(n,r)=>{const o=await e(n,r);return o.status!==401||typeof window>"u"?o:(t||(t=!0,window.location.assign(nte(`${window.location.pathname}${window.location.search}`))),new Promise(a=>{}))}}function Kbn({reason:e}){const t=e==="login_failed"?"We couldn’t complete sign-in. Please try again.":e;return h.jsx("main",{className:"auth-screen",children:h.jsxs("div",{className:"auth-screen-card",children:[h.jsx(jJ,{className:"auth-screen-logo"}),h.jsx("h1",{className:"auth-screen-title",children:"Sign-in failed"}),h.jsx("p",{className:"auth-screen-message",children:t}),h.jsx("a",{className:"auth-screen-button",href:nte(),children:"Try again"})]})})}const Ybn=new Ree({baseUrl:V3,fetch:OFe()}),Zbn=new Ree({baseUrl:V3,fetch:globalThis.fetch.bind(globalThis)});let PFe;function D1e(){return PFe}async function Xbn(e=Ybn){const{data:t}=await e.auth.me(),n=t.type==="oidc-connected";return PFe=n,n}async function qbn(e=globalThis.fetch.bind(globalThis)){const t=await e(Wbn,{method:"POST",credentials:"include"});if(!t.ok)throw new Error(`Logout failed (${String(t.status)})`)}async function Qbn(e=Zbn){try{const{data:t}=await e.auth.me();return{status:"authenticated",subjectId:t.subject.id,displayName:t.subject.displayName,tenantId:t.tenantId}}catch{return{status:"unauthenticated"}}}function L1e(e){var n;const t=(n=new URLSearchParams(e).get("error"))==null?void 0:n.trim();return t||null}function Jbn({authError:e,session:t}){return e==null||t.status!=="unauthenticated"?null:e}function evn({pathname:e,search:t,hash:n}){const r=new URLSearchParams(t);r.delete("error");const o=r.toString();return`${e}${o===""?"":`?${o}`}${n}`}function tvn(){return h.jsx("main",{className:"auth-screen",children:h.jsxs("div",{className:"auth-screen-card",children:[h.jsx(jJ,{className:"auth-screen-logo"}),h.jsx("h1",{className:"auth-screen-title",children:"Welcome to TrueForge"}),h.jsx("button",{type:"button",className:"auth-screen-button",onClick:()=>{window.location.assign(nte())},children:"Let's Get Started"})]})})}function nvn(){const[e,t]=_.useState(()=>D1e()===!0),[n,r]=_.useState(!1),[o,a]=_.useState(!1);if(_.useEffect(()=>{const s={cancelled:!1};return Xbn().then(l=>{s.cancelled||t(l)}).catch(()=>{!s.cancelled&&D1e()===void 0&&t(!1)}),()=>{s.cancelled=!0}},[]),!e)return null;const i=()=>{o||(a(!0),qbn().then(()=>{window.location.assign(up)}).catch(()=>{a(!1)}))};return h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Log out",title:"Log out",className:"harness-logout",onClick:()=>{r(!0)},children:h.jsx(be,{name:"log-out"})}),h.jsx(XJ,{open:n,onOpenChange:s=>{o||r(s)},title:"Log out",description:"Sure to logout?",contentSized:!0,children:h.jsxs("div",{className:"harness-logout-confirm",children:[h.jsx("button",{type:"button",className:"harness-logout-cancel",disabled:o,onClick:()=>{r(!1)},children:"Cancel"}),h.jsx("button",{type:"button",className:"harness-logout-submit",disabled:o,onClick:i,children:o?"Logging out…":"Confirm"})]})})]})}function rvn(e){const t=go(),r=[(t==null?void 0:t.mode.status)==="active"&&t.mode.isMutable&&t.mode.isCreateAgent&&!(t.mode.agentName!=null&&t.mode.agentName.length>0)?"new-agent-welcome":void 0,e.className].filter(Boolean).join(" ");return h.jsx(Uze,{...e,...r?{className:r}:{}})}function ovn(e={}){return h.jsx(dze,{platformSkillsUrl:e.platformSkillsUrl??cze,settingsSkillsUrl:e.settingsSkillsUrl??tte("/settings")})}const jFe=OFe(),z1e=Ap({baseUrl:V3,fetch:jFe}),$1e=Hbn(),xv={className:"harness-primary-gradient",tokens:{primaryButtonBg:"#6366F1",primaryButtonHover:"#3d2dd4"}};function U1e(){const{mode:e}=Yqe();return h.jsx("div",{className:"boot-screen",role:"status","aria-label":"Loading","aria-live":"polite","aria-busy":"true",children:h.jsx(PJ,{state:"connecting",speed:1,theme:e,paused:!1,"aria-hidden":!0,size:64,style:{width:"4.5rem",height:"4.5rem"}})})}function avn(){const e=L1e(window.location.search),[t,n]=_.useState({status:"checking"}),[r,o]=_.useState({status:"loading"});_.useEffect(()=>{const l={cancelled:!1};return Qbn().then(c=>{l.cancelled||n(c)}),()=>{l.cancelled=!0}},[]),_.useEffect(()=>{t.status==="authenticated"&&L1e(window.location.search)!=null&&window.history.replaceState(window.history.state,"",evn({pathname:window.location.pathname,search:window.location.search,hash:window.location.hash}))},[t]),_.useEffect(()=>{if(t.status!=="authenticated")return;const l={cancelled:!1};return(async()=>{try{const[c,u]=await Promise.all([U$e(z1e),H$e(z1e)]);if(l.cancelled)return;const d=c[0],f={sandbox:{enabled:u.sandbox.enabled}};if(d===void 0){o({status:"ready",openSettings:u.settings.modelProviders.enabled,defaultAgentSpec:{model:{name:""},config:f}});return}const g=ZS(d.properties.reasoningEfforts,void 0);o({status:"ready",openSettings:!1,defaultAgentSpec:{model:{name:d.name,...g?{params:{reasoningEffort:g}}:{}},config:f}})}catch(c){l.cancelled||o({status:"error",message:Oa(c,"Failed to boot")})}})(),()=>{l.cancelled=!0}},[t]);const a=_.useMemo(()=>({ShellActionsActionSlot:nvn,WelcomeScreen:rvn,AgentSkillsHeaderActionSlot:ovn}),[]),i=_.useMemo(()=>{},[t]),s=Jbn({authError:e,session:t});return s!=null?h.jsx(wv,{theme:xv,children:h.jsx(Kbn,{reason:s})}):t.status==="checking"?h.jsx(wv,{theme:xv,children:h.jsx(U1e,{})}):t.status==="unauthenticated"?h.jsx(wv,{theme:xv,children:h.jsx(tvn,{})}):r.status==="error"?h.jsx(wv,{theme:xv,children:h.jsxs("div",{className:"boot-screen","data-error":"true",children:["Failed to load application configuration: ",r.message]})}):r.status==="loading"?h.jsx(wv,{theme:xv,children:h.jsx(U1e,{})}):h.jsx("div",{className:"app-root",children:h.jsx(Vsn,{server:{type:"trueforge",baseUrl:V3,fetch:jFe},layout:"sidebar",withRouter:!0,...$1e?{routes:{basename:$1e}}:{},agentConfig:{mode:"AgentLibraryWithComposer",defaultAgentSpec:r.defaultAgentSpec},initialSettingsOpen:r.openSettings,currentUser:{subjectId:t.subjectId,displayName:t.displayName},overrides:a,theme:xv,className:"app-assistant",...i?{analytics:i}:{}})})}Vbn();const DFe=document.getElementById("root");if(!DFe)throw new Error("Root element #root not found");MHe.createRoot(DFe).render(h.jsx(_.StrictMode,{children:h.jsx(avn,{})}));const ivn=Object.freeze(Object.defineProperty({__proto__:null,OpenUiFenceBlock:_De},Symbol.toStringTag,{value:"Module"}));export{mvn as $,Zvn as A,rB as B,wJt as C,Jc as D,Tn as E,da as F,n2 as G,xxe as H,be as I,ren as J,oen as K,N6e as L,sg as M,aen as N,lg as O,WH as P,ZJt as Q,vx as R,qJt as S,ysn as T,tE as U,S3 as V,k3 as W,zJ as X,ten as Y,ck as Z,io as _,Svn as a,x6e as a$,O9 as a0,Ep as a1,pu as a2,rn as a3,VJe as a4,sAe as a5,eN as a6,E3 as a7,p6e as a8,JN as a9,Ayn as aA,Iyn as aB,cJt as aC,Dyn as aD,zyn as aE,$yn as aF,Lyn as aG,uwe as aH,lyn as aI,dJt as aJ,Von as aK,Qon as aL,Cyn as aM,Uyn as aN,Fon as aO,Myn as aP,Eyn as aQ,MJt as aR,iyn as aS,GS as aT,sWt as aU,LQt as aV,Tyn as aW,Yg as aX,l6e as aY,nE as aZ,tu as a_,ga as aa,KN as ab,sB as ac,Xvn as ad,hvn as ae,Wke as af,wvn as ag,_vn as ah,tet as ai,byn as aj,pxe as ak,vyn as al,yyn as am,xyn as an,gy as ao,unn as ap,K as aq,O3 as ar,y6e as as,Xl as at,jyn as au,Da as av,Pyn as aw,Oyn as ax,Ryn as ay,Nyn as az,th as b,OH as b$,syn as b0,cyn as b1,i3 as b2,V8 as b3,Q8 as b4,d0e as b5,Z8 as b6,G8 as b7,Bvn as b8,Hvn as b9,fXe as bA,pp as bB,PC as bC,aAe as bD,hXe as bE,WJ as bF,XJ as bG,ZLe as bH,XLe as bI,qLe as bJ,eze as bK,Lfn as bL,pvn as bM,qJ as bN,T3 as bO,dnn as bP,kvn as bQ,xvn as bR,my as bS,_yn as bT,Ve as bU,P6e as bV,dyn as bW,cvn as bX,kyn as bY,Vse as bZ,_3 as b_,s6e as ba,c0e as bb,VA as bc,Uvn as bd,pn as be,km as bf,V6e as bg,pk as bh,Al as bi,fxe as bj,Ya as bk,yvn as bl,lvn as bm,_m as bn,mXe as bo,YN as bp,zH as bq,Kke as br,bvn as bs,lXe as bt,XJe as bu,Evn as bv,Tvn as bw,qH as bx,uAe as by,gvn as bz,pe as c,wAe as c$,nyn as c0,ryn as c1,Jvn as c2,eyn as c3,Kvn as c4,fin as c5,sin as c6,fYt as c7,uyn as c8,Fen as c9,hYt as cA,Syn as cB,otn as cC,Yqe as cD,XN as cE,QN as cF,Yen as cG,rAe as cH,Ie as cI,zs as cJ,Vs as cK,Io as cL,C0 as cM,fi as cN,pM as cO,gM as cP,hk as cQ,fp as cR,vn as cS,gCe as cT,kt as cU,oM as cV,fV as cW,eCe as cX,lV as cY,XCe as cZ,FCe as c_,Vvn as ca,uYt as cb,dvn as cc,Gvn as cd,Ww as ce,Byn as cf,a1 as cg,FZe as ch,$Ze as ci,nm as cj,Zst as ck,wyn as cl,pze as cm,Wan as cn,Gan as co,ree as cp,Bu as cq,uvn as cr,Wvn as cs,Fyn as ct,pin as cu,qk as cv,oze as cw,$H as cx,Jke as cy,D9 as cz,Za as d,qCe as d0,cn as d1,Qd as d2,Li as d3,Cm as d4,$Ce as d5,UCe as d6,dV as d7,is as d8,Sl as d9,Iet as da,La as db,Am as dc,Xs as dd,Ol as de,eM as df,Nn as dg,Vke as dh,Qvn as di,aJt as dj,tyn as dk,oyn as dl,iJt as dm,lAe as dn,I3 as dp,Ui as dq,w3 as dr,ayn as ds,qvn as dt,pyn as du,Sen as dv,vvn as dw,Yvn as dx,qqt as dy,b0 as e,iC as f,gyn as g,myn as h,aE as i,h as j,sr as k,fvn as l,fyn as m,Ixe as n,I0 as o,eE as p,us as q,_ as r,hyn as s,go as t,Ge as u,N0 as v,Jk as w,Oa as x,eet as y,JJe as z};