@truefoundry/trueforge 0.179.0-rc.3 → 0.179.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.
- package/dist/_frontend/assets/{AgentCodeSnippets-GX5MTZLF-C1qMMx83.js → AgentCodeSnippets-GX5MTZLF-D1o4DvyC.js} +1 -1
- package/dist/_frontend/assets/AgentCodeSnippets-GX5MTZLF-D1o4DvyC.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-GX5MTZLF-D1o4DvyC.js.gz +0 -0
- package/dist/_frontend/assets/{AgentMetricChart-MMZYPKVN-DBJeoFu0.js → AgentMetricChart-MMZYPKVN-8E4ELOjM.js} +1 -1
- package/dist/_frontend/assets/AgentMetricChart-MMZYPKVN-8E4ELOjM.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-MMZYPKVN-8E4ELOjM.js.gz +0 -0
- package/dist/_frontend/assets/{AgentOverview-OBBGSUOK-C_7h7s2o.js → AgentOverview-OBBGSUOK-D0-uAThW.js} +1 -1
- package/dist/_frontend/assets/AgentOverview-OBBGSUOK-D0-uAThW.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-OBBGSUOK-D0-uAThW.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimeline-ZBW3AIU2-BpsEEOy4.js → AgentSessionEventTimeline-ZBW3AIU2-BjA4oeYw.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimeline-ZBW3AIU2-BjA4oeYw.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-ZBW3AIU2-BjA4oeYw.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimelineChart-VQNS2G4D-Bf8Z-J0v.js → AgentSessionEventTimelineChart-VQNS2G4D-o3La8fse.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-VQNS2G4D-o3La8fse.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-VQNS2G4D-o3La8fse.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessions-OB32CD3H-DsqoPWfh.js → AgentSessions-OB32CD3H-BvEB36Q4.js} +1 -1
- package/dist/_frontend/assets/AgentSessions-OB32CD3H-BvEB36Q4.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-OB32CD3H-BvEB36Q4.js.gz +0 -0
- package/dist/_frontend/assets/{ConnectorSettings-XXE32AUQ-CXIdb6bA.js → ConnectorSettings-XXE32AUQ-Bi01homi.js} +1 -1
- package/dist/_frontend/assets/ConnectorSettings-XXE32AUQ-Bi01homi.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-XXE32AUQ-Bi01homi.js.gz +0 -0
- package/dist/_frontend/assets/{DockLayout-YSSOMIEK-Ct_Ma6-M.js → DockLayout-YSSOMIEK-S7QeeWVV.js} +1 -1
- package/dist/_frontend/assets/{DrawerLayout-T6U5AGG7-B4mayMKB.js → DrawerLayout-T6U5AGG7-BQoBVjqu.js} +2 -2
- package/dist/_frontend/assets/DrawerLayout-T6U5AGG7-BQoBVjqu.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-T6U5AGG7-BQoBVjqu.js.gz +0 -0
- package/dist/_frontend/assets/{EnvironmentsPage-OXKHJMOO-CgRxeC0e.js → EnvironmentsPage-OXKHJMOO-C-t7Dp_i.js} +1 -1
- package/dist/_frontend/assets/EnvironmentsPage-OXKHJMOO-C-t7Dp_i.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-OXKHJMOO-C-t7Dp_i.js.gz +0 -0
- package/dist/_frontend/assets/{ModelSettings-J5QDA4OJ-DPCcOIGv.js → ModelSettings-J5QDA4OJ-1_KW1bju.js} +1 -1
- package/dist/_frontend/assets/ModelSettings-J5QDA4OJ-1_KW1bju.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-J5QDA4OJ-1_KW1bju.js.gz +0 -0
- package/dist/_frontend/assets/{SandboxSettings-Y3NPODM5-CfQQnGaU.js → SandboxSettings-Y3NPODM5-CD9DUFxP.js} +1 -1
- package/dist/_frontend/assets/SandboxSettings-Y3NPODM5-CD9DUFxP.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-Y3NPODM5-CD9DUFxP.js.gz +0 -0
- package/dist/_frontend/assets/{SchedulesPage-HLHAOIS6-DqVBKUZr.js → SchedulesPage-HLHAOIS6-BcDOMjiM.js} +1 -1
- package/dist/_frontend/assets/SchedulesPage-HLHAOIS6-BcDOMjiM.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-HLHAOIS6-BcDOMjiM.js.gz +0 -0
- package/dist/_frontend/assets/{SettingsBuilder-CVPLV5HY-g0AvC4-n.js → SettingsBuilder-CVPLV5HY-D0lac3y-.js} +2 -2
- package/dist/_frontend/assets/SettingsBuilder-CVPLV5HY-D0lac3y-.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-CVPLV5HY-D0lac3y-.js.gz +0 -0
- package/dist/_frontend/assets/{ShellRouteSync-XIPKA3OH-DC61bU3T.js → ShellRouteSync-XIPKA3OH-ByKCgD91.js} +1 -1
- package/dist/_frontend/assets/ShellRouteSync-XIPKA3OH-ByKCgD91.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-XIPKA3OH-ByKCgD91.js.gz +0 -0
- package/dist/_frontend/assets/{SidebarLayout-LHIKWYLB-Deq6FslD.js → SidebarLayout-LHIKWYLB-DgTk6yLL.js} +2 -2
- package/dist/_frontend/assets/SidebarLayout-LHIKWYLB-DgTk6yLL.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-LHIKWYLB-DgTk6yLL.js.gz +0 -0
- package/dist/_frontend/assets/{SkillSettings-6I63TUL7-xPvd8aiE.js → SkillSettings-6I63TUL7-D4s5Ticy.js} +1 -1
- package/dist/_frontend/assets/SkillSettings-6I63TUL7-D4s5Ticy.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-6I63TUL7-D4s5Ticy.js.gz +0 -0
- package/dist/_frontend/assets/{TrueForgeUIWithRouter-SZT3KVCD-D8zD2X-X.js → TrueForgeUIWithRouter-SZT3KVCD-BMJaD7KT.js} +1 -1
- package/dist/_frontend/assets/{WebSearchSettings-SUBJH2C5-BKS1O0JS.js → WebSearchSettings-SUBJH2C5-DL7KJKp-.js} +1 -1
- package/dist/_frontend/assets/WebSearchSettings-SUBJH2C5-DL7KJKp-.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-SUBJH2C5-DL7KJKp-.js.gz +0 -0
- package/dist/_frontend/assets/{WidgetLayout-Q3F3UWN3-CNvkLcEG.js → WidgetLayout-Q3F3UWN3-BQaDzdhk.js} +1 -1
- package/dist/_frontend/assets/WidgetLayout-Q3F3UWN3-BQaDzdhk.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-Q3F3UWN3-BQaDzdhk.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-GSAVSNGR-B2YT0rof.js → chunk-GSAVSNGR-BJhfT2HB.js} +1 -1
- package/dist/_frontend/assets/{chunk-ICZTJLTU-CZ-h2uJn.js → chunk-ICZTJLTU-CSBYGLaq.js} +1 -1
- package/dist/_frontend/assets/chunk-ICZTJLTU-CSBYGLaq.js.br +0 -0
- package/dist/_frontend/assets/chunk-ICZTJLTU-CSBYGLaq.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-NYCSPKHJ-DuGi-pMl.js → chunk-NYCSPKHJ-BXKEzm55.js} +1 -1
- package/dist/_frontend/assets/chunk-NYCSPKHJ-BXKEzm55.js.br +0 -0
- package/dist/_frontend/assets/chunk-NYCSPKHJ-BXKEzm55.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-OB3PAWPO-DHGcDoiH.js → chunk-OB3PAWPO-WTBtRmxH.js} +1 -1
- package/dist/_frontend/assets/chunk-OB3PAWPO-WTBtRmxH.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-WTBtRmxH.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-OD7JCND5-DYPtfS-t.js → chunk-OD7JCND5-BlwWGx2k.js} +2 -2
- package/dist/_frontend/assets/chunk-OD7JCND5-BlwWGx2k.js.br +0 -0
- package/dist/_frontend/assets/chunk-OD7JCND5-BlwWGx2k.js.gz +0 -0
- package/dist/_frontend/assets/{cssMode-cvAmQ5FH.js → cssMode-BnrOGoXe.js} +1 -1
- package/dist/_frontend/assets/cssMode-BnrOGoXe.js.br +0 -0
- package/dist/_frontend/assets/cssMode-BnrOGoXe.js.gz +0 -0
- package/dist/_frontend/assets/{freemarker2-K3ZFsJS2.js → freemarker2-Cu2qkLE9.js} +1 -1
- package/dist/_frontend/assets/freemarker2-Cu2qkLE9.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-Cu2qkLE9.js.gz +0 -0
- package/dist/_frontend/assets/{handlebars-DdP9ynhY.js → handlebars-qoIGMfY0.js} +1 -1
- package/dist/_frontend/assets/handlebars-qoIGMfY0.js.br +0 -0
- package/dist/_frontend/assets/handlebars-qoIGMfY0.js.gz +0 -0
- package/dist/_frontend/assets/{html-DO3tqX8t.js → html-jIKazNfg.js} +1 -1
- package/dist/_frontend/assets/html-jIKazNfg.js.br +0 -0
- package/dist/_frontend/assets/html-jIKazNfg.js.gz +0 -0
- package/dist/_frontend/assets/{htmlMode-IZkbubp7.js → htmlMode-M1ZSzZKt.js} +1 -1
- package/dist/_frontend/assets/htmlMode-M1ZSzZKt.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-M1ZSzZKt.js.gz +0 -0
- package/dist/_frontend/assets/{index-DSRqHF1Z.js → index-4r7-LeFK.js} +1 -1
- package/dist/_frontend/assets/index-4r7-LeFK.js.br +0 -0
- package/dist/_frontend/assets/index-4r7-LeFK.js.gz +0 -0
- package/dist/_frontend/assets/{index-Bo_34uF1.js → index-BJsGMvc-.js} +4 -4
- package/dist/_frontend/assets/index-BJsGMvc-.js.br +0 -0
- package/dist/_frontend/assets/index-BJsGMvc-.js.gz +0 -0
- package/dist/_frontend/assets/{index-DfER8M3D.js → index-YbpMGQU0.js} +3 -3
- package/dist/_frontend/assets/index-YbpMGQU0.js.br +0 -0
- package/dist/_frontend/assets/index-YbpMGQU0.js.gz +0 -0
- package/dist/_frontend/assets/{javascript-DJkE-0Ux.js → javascript-X_qdyURb.js} +1 -1
- package/dist/_frontend/assets/{jsonMode-cMDmNE73.js → jsonMode-CT04G6VA.js} +1 -1
- package/dist/_frontend/assets/jsonMode-CT04G6VA.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-CT04G6VA.js.gz +0 -0
- package/dist/_frontend/assets/{liquid-D4AI_62T.js → liquid-B2a653EE.js} +1 -1
- package/dist/_frontend/assets/liquid-B2a653EE.js.br +0 -0
- package/dist/_frontend/assets/liquid-B2a653EE.js.gz +0 -0
- package/dist/_frontend/assets/{lspLanguageFeatures-BLeDg5mE.js → lspLanguageFeatures-mffTaZGc.js} +1 -1
- package/dist/_frontend/assets/lspLanguageFeatures-mffTaZGc.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-mffTaZGc.js.gz +0 -0
- package/dist/_frontend/assets/{mdx-CKksvjbU.js → mdx-DN_e2xx5.js} +1 -1
- package/dist/_frontend/assets/mdx-DN_e2xx5.js.br +0 -0
- package/dist/_frontend/assets/mdx-DN_e2xx5.js.gz +0 -0
- package/dist/_frontend/assets/{python-D-EbEiyL.js → python-CMZDwpP1.js} +1 -1
- package/dist/_frontend/assets/python-CMZDwpP1.js.br +0 -0
- package/dist/_frontend/assets/python-CMZDwpP1.js.gz +0 -0
- package/dist/_frontend/assets/{razor-56FEP78E.js → razor-CJvSmNFI.js} +1 -1
- package/dist/_frontend/assets/razor-CJvSmNFI.js.br +0 -0
- package/dist/_frontend/assets/razor-CJvSmNFI.js.gz +0 -0
- package/dist/_frontend/assets/{tsMode-BALY8irl.js → tsMode-ZJxciJ2G.js} +1 -1
- package/dist/_frontend/assets/tsMode-ZJxciJ2G.js.br +0 -0
- package/dist/_frontend/assets/tsMode-ZJxciJ2G.js.gz +0 -0
- package/dist/_frontend/assets/{typescript-DrD3_sc2.js → typescript-DS4oUy9B.js} +1 -1
- package/dist/_frontend/assets/typescript-DS4oUy9B.js.br +0 -0
- package/dist/_frontend/assets/typescript-DS4oUy9B.js.gz +0 -0
- package/dist/_frontend/assets/{workers-B7SMgiFd.js → workers-DPKHJxKo.js} +1 -1
- package/dist/_frontend/assets/workers-DPKHJxKo.js.br +0 -0
- package/dist/_frontend/assets/workers-DPKHJxKo.js.gz +0 -0
- package/dist/_frontend/assets/{xml-D2LS2tt_.js → xml-BJmCYv7o.js} +1 -1
- package/dist/_frontend/assets/xml-BJmCYv7o.js.br +0 -0
- package/dist/_frontend/assets/xml-BJmCYv7o.js.gz +0 -0
- package/dist/_frontend/assets/{yaml-z9V4zcpU.js → yaml-DzYUCVsV.js} +1 -1
- package/dist/_frontend/assets/yaml-DzYUCVsV.js.br +0 -0
- package/dist/_frontend/assets/yaml-DzYUCVsV.js.gz +0 -0
- package/dist/_frontend/index.html +1 -1
- package/package.json +3 -3
- package/dist/_frontend/assets/AgentCodeSnippets-GX5MTZLF-C1qMMx83.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-GX5MTZLF-C1qMMx83.js.gz +0 -0
- package/dist/_frontend/assets/AgentMetricChart-MMZYPKVN-DBJeoFu0.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-MMZYPKVN-DBJeoFu0.js.gz +0 -0
- package/dist/_frontend/assets/AgentOverview-OBBGSUOK-C_7h7s2o.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-OBBGSUOK-C_7h7s2o.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-ZBW3AIU2-BpsEEOy4.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-ZBW3AIU2-BpsEEOy4.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-VQNS2G4D-Bf8Z-J0v.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-VQNS2G4D-Bf8Z-J0v.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessions-OB32CD3H-DsqoPWfh.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-OB32CD3H-DsqoPWfh.js.gz +0 -0
- package/dist/_frontend/assets/ConnectorSettings-XXE32AUQ-CXIdb6bA.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-XXE32AUQ-CXIdb6bA.js.gz +0 -0
- package/dist/_frontend/assets/DrawerLayout-T6U5AGG7-B4mayMKB.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-T6U5AGG7-B4mayMKB.js.gz +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-OXKHJMOO-CgRxeC0e.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-OXKHJMOO-CgRxeC0e.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-J5QDA4OJ-DPCcOIGv.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-J5QDA4OJ-DPCcOIGv.js.gz +0 -0
- package/dist/_frontend/assets/SandboxSettings-Y3NPODM5-CfQQnGaU.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-Y3NPODM5-CfQQnGaU.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-HLHAOIS6-DqVBKUZr.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-HLHAOIS6-DqVBKUZr.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-CVPLV5HY-g0AvC4-n.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-CVPLV5HY-g0AvC4-n.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-XIPKA3OH-DC61bU3T.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-XIPKA3OH-DC61bU3T.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-LHIKWYLB-Deq6FslD.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-LHIKWYLB-Deq6FslD.js.gz +0 -0
- package/dist/_frontend/assets/SkillSettings-6I63TUL7-xPvd8aiE.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-6I63TUL7-xPvd8aiE.js.gz +0 -0
- package/dist/_frontend/assets/WebSearchSettings-SUBJH2C5-BKS1O0JS.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-SUBJH2C5-BKS1O0JS.js.gz +0 -0
- package/dist/_frontend/assets/WidgetLayout-Q3F3UWN3-CNvkLcEG.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-Q3F3UWN3-CNvkLcEG.js.gz +0 -0
- package/dist/_frontend/assets/chunk-ICZTJLTU-CZ-h2uJn.js.br +0 -0
- package/dist/_frontend/assets/chunk-ICZTJLTU-CZ-h2uJn.js.gz +0 -0
- package/dist/_frontend/assets/chunk-NYCSPKHJ-DuGi-pMl.js.br +0 -0
- package/dist/_frontend/assets/chunk-NYCSPKHJ-DuGi-pMl.js.gz +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-DHGcDoiH.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-DHGcDoiH.js.gz +0 -0
- package/dist/_frontend/assets/chunk-OD7JCND5-DYPtfS-t.js.br +0 -0
- package/dist/_frontend/assets/chunk-OD7JCND5-DYPtfS-t.js.gz +0 -0
- package/dist/_frontend/assets/cssMode-cvAmQ5FH.js.br +0 -0
- package/dist/_frontend/assets/cssMode-cvAmQ5FH.js.gz +0 -0
- package/dist/_frontend/assets/freemarker2-K3ZFsJS2.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-K3ZFsJS2.js.gz +0 -0
- package/dist/_frontend/assets/handlebars-DdP9ynhY.js.br +0 -0
- package/dist/_frontend/assets/handlebars-DdP9ynhY.js.gz +0 -0
- package/dist/_frontend/assets/html-DO3tqX8t.js.br +0 -0
- package/dist/_frontend/assets/html-DO3tqX8t.js.gz +0 -0
- package/dist/_frontend/assets/htmlMode-IZkbubp7.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-IZkbubp7.js.gz +0 -0
- package/dist/_frontend/assets/index-Bo_34uF1.js.br +0 -0
- package/dist/_frontend/assets/index-Bo_34uF1.js.gz +0 -0
- package/dist/_frontend/assets/index-DSRqHF1Z.js.br +0 -0
- package/dist/_frontend/assets/index-DSRqHF1Z.js.gz +0 -0
- package/dist/_frontend/assets/index-DfER8M3D.js.br +0 -0
- package/dist/_frontend/assets/index-DfER8M3D.js.gz +0 -0
- package/dist/_frontend/assets/jsonMode-cMDmNE73.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-cMDmNE73.js.gz +0 -0
- package/dist/_frontend/assets/liquid-D4AI_62T.js.br +0 -0
- package/dist/_frontend/assets/liquid-D4AI_62T.js.gz +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-BLeDg5mE.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-BLeDg5mE.js.gz +0 -0
- package/dist/_frontend/assets/mdx-CKksvjbU.js.br +0 -0
- package/dist/_frontend/assets/mdx-CKksvjbU.js.gz +0 -0
- package/dist/_frontend/assets/python-D-EbEiyL.js.br +0 -0
- package/dist/_frontend/assets/python-D-EbEiyL.js.gz +0 -0
- package/dist/_frontend/assets/razor-56FEP78E.js.br +0 -0
- package/dist/_frontend/assets/razor-56FEP78E.js.gz +0 -0
- package/dist/_frontend/assets/tsMode-BALY8irl.js.br +0 -0
- package/dist/_frontend/assets/tsMode-BALY8irl.js.gz +0 -0
- package/dist/_frontend/assets/typescript-DrD3_sc2.js.br +0 -0
- package/dist/_frontend/assets/typescript-DrD3_sc2.js.gz +0 -0
- package/dist/_frontend/assets/workers-B7SMgiFd.js.br +0 -3
- package/dist/_frontend/assets/workers-B7SMgiFd.js.gz +0 -0
- package/dist/_frontend/assets/xml-D2LS2tt_.js.br +0 -0
- package/dist/_frontend/assets/xml-D2LS2tt_.js.gz +0 -0
- package/dist/_frontend/assets/yaml-z9V4zcpU.js.br +0 -0
- package/dist/_frontend/assets/yaml-z9V4zcpU.js.gz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-YbpMGQU0.js","./index-CX3ij07K.css","./AgentSessions-OB32CD3H-BvEB36Q4.js","./chunk-BZ2EOR5X-BgN-bqzz.js","./SchedulesPage-HLHAOIS6-BcDOMjiM.js","./chunk-ICZTJLTU-CSBYGLaq.js","./EnvironmentsPage-OXKHJMOO-C-t7Dp_i.js","./AgentSessionEventTimelineChart-VQNS2G4D-o3La8fse.js","./index-4r7-LeFK.js","./AgentMetricChart-MMZYPKVN-8E4ELOjM.js","./SidebarLayout-LHIKWYLB-DgTk6yLL.js","./chunk-NYCSPKHJ-BXKEzm55.js","./DrawerLayout-T6U5AGG7-BQoBVjqu.js","./DockLayout-YSSOMIEK-S7QeeWVV.js","./chunk-OD7JCND5-BlwWGx2k.js","./WidgetLayout-Q3F3UWN3-BQaDzdhk.js","./ShellRouteSync-XIPKA3OH-ByKCgD91.js","./chunk-OB3PAWPO-WTBtRmxH.js","./TrueForgeUIWithRouter-SZT3KVCD-BMJaD7KT.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var G6e=Object.defineProperty;var ete=e=>{throw TypeError(e)};var W6e=(e,t,n)=>t in e?G6e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>W6e(e,typeof t!="symbol"?t+"":t,n),tte=(e,t,n)=>t.has(e)||ete("Cannot "+n);var Aa=(e,t,n)=>(tte(e,t,"read from private field"),n?n.call(e):t.get(e)),nte=(e,t,n)=>t.has(e)?ete("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),QO=(e,t,n,r)=>(tte(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function K6e(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 _k=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var JO={exports:{}},M0={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -983,18 +983,18 @@ ${l.children}`})})]})})]})}),pRe=({language:e,codeString:t,theme:n})=>{const[r,o
|
|
|
983
983
|
`))}function l(m,b,y,x){const _=y.enter("tableCell"),k=y.enter("phrasing"),E=y.containerPhrasing(m,{...x,before:a,after:a});return k(),_(),E}function c(m,b){return qzt(m,{align:b,alignDelimiters:r,padding:n,stringLength:o})}function d(m,b,y){const x=m.children;let _=-1;const k=[],E=b.enter("table");for(;++_<x.length;)k[_]=p(x[_],b,y);return E(),k}function p(m,b,y){const x=m.children;let _=-1;const k=[],E=b.enter("tableRow");for(;++_<x.length;)k[_]=l(x[_],m,b,y);return E(),k}function f(m,b,y){let x=RNe.inlineCode(m,b,y);return y.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function z8t(){return{exit:{taskListCheckValueChecked:qhe,taskListCheckValueUnchecked:qhe,paragraph:F8t}}}function $8t(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:U8t}}}function qhe(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function F8t(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 U8t(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=RNe.listItem(e,t,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(d){return d+i}}function B8t(){return[xzt(),Uzt(),Gzt(),N8t(),z8t()]}function H8t(e){return{extensions:[wzt(),Bzt(e),Wzt(),L8t(e),$8t()]}}const V8t={tokenize:X8t,partial:!0},INe={tokenize:q8t,partial:!0},NNe={tokenize:Q8t,partial:!0},MNe={tokenize:J8t,partial:!0},G8t={tokenize:e9t,partial:!0},ONe={name:"wwwAutolink",tokenize:Y8t,previous:PNe},jNe={name:"protocolAutolink",tokenize:Z8t,previous:DNe},wd={name:"emailAutolink",tokenize:K8t,previous:LNe},Yc={};function W8t(){return{text:Yc}}let $f=48;for(;$f<123;)Yc[$f]=wd,$f++,$f===58?$f=65:$f===91&&($f=97);Yc[43]=wd;Yc[45]=wd;Yc[46]=wd;Yc[95]=wd;Yc[72]=[wd,jNe];Yc[104]=[wd,jNe];Yc[87]=[wd,ONe];Yc[119]=[wd,ONe];function K8t(e,t,n){const r=this;let o,a;return i;function i(p){return!J9(p)||!LNe.call(r,r.previous)||uZ(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(p))}function s(p){return J9(p)?(e.consume(p),s):p===64?(e.consume(p),l):n(p)}function l(p){return p===46?e.check(G8t,d,c)(p):p===45||p===95||Pa(p)?(a=!0,e.consume(p),l):d(p)}function c(p){return e.consume(p),o=!0,l}function d(p){return a&&o&&ei(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function Y8t(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!PNe.call(r,r.previous)||uZ(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(V8t,e.attempt(INe,e.attempt(NNe,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function Z8t(e,t,n){const r=this;let o="",a=!1;return i;function i(p){return(p===72||p===104)&&DNe.call(r,r.previous)&&!uZ(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(p),e.consume(p),s):n(p)}function s(p){if(ei(p)&&o.length<5)return o+=String.fromCodePoint(p),e.consume(p),s;if(p===58){const f=o.toLowerCase();if(f==="http"||f==="https")return e.consume(p),l}return n(p)}function l(p){return p===47?(e.consume(p),a?c:(a=!0,l)):n(p)}function c(p){return p===null||EA(p)||Lr(p)||Vh(p)||kR(p)?n(p):e.attempt(INe,e.attempt(NNe,d),n)(p)}function d(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function X8t(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 q8t(e,t,n){let r,o,a;return i;function i(c){return c===46||c===95?e.check(MNe,l,s)(c):c===null||Lr(c)||Vh(c)||c!==45&&kR(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 Q8t(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(MNe,t,a)(i):i===null||Lr(i)||Vh(i)?t(i):(e.consume(i),o)}function a(i){return i===41&&r++,e.consume(i),o}}function J8t(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||Lr(s)||Vh(s)?t(s):n(s)}function o(s){return s===null||s===40||s===91||Lr(s)||Vh(s)?t(s):r(s)}function a(s){return ei(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),r):ei(s)?(e.consume(s),i):n(s)}}function e9t(e,t,n){return r;function r(a){return e.consume(a),o}function o(a){return Pa(a)?n(a):t(a)}}function PNe(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Lr(e)}function DNe(e){return!ei(e)}function LNe(e){return!(e===47||J9(e))}function J9(e){return e===43||e===45||e===46||e===95||Pa(e)}function uZ(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 t9t={tokenize:c9t,partial:!0};function n9t(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:i9t,continuation:{tokenize:s9t},exit:l9t}},text:{91:{name:"gfmFootnoteCall",tokenize:a9t},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:r9t,resolveTo:o9t}}}}function r9t(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=Il(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 o9t(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 a9t(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,i;return s;function s(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),l}function l(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(p){if(a>999||p===93&&!i||p===null||p===91||Lr(p))return n(p);if(p===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return o.includes(Il(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Lr(p)||(i=!0),a++,e.consume(p),p===92?d:c}function d(p){return p===91||p===92||p===93?(e.consume(p),a++,c):c(p)}}function i9t(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",d):n(b)}function d(b){if(i>999||b===93&&!s||b===null||b===91||Lr(b))return n(b);if(b===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return a=Il(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Lr(b)||(s=!0),i++,e.consume(b),b===92?p:d}function p(b){return b===91||b===92||b===93?(e.consume(b),i++,d):d(b)}function f(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),o.includes(a)||o.push(a),kl(e,m,"gfmFootnoteDefinitionWhitespace")):n(b)}function m(b){return t(b)}}function s9t(e,t,n){return e.check(v1,t,e.attempt(t9t,t,n))}function l9t(e){e.exit("gfmFootnoteDefinition")}function c9t(e,t,n){const r=this;return kl(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 u9t(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 d={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[l][1].end)},p={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[l][1].start)},f=[["enter",d,s],["enter",i[c][1],s],["exit",i[c][1],s],["enter",p,s]],m=s.parser.constructs.insideSpan.null;m&&ss(f,f.length,0,ER(m,i.slice(c+1,l),s)),ss(f,f.length,0,[["exit",p,s],["enter",i[l][1],s],["exit",i[l][1],s],["exit",d,s]]),ss(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,d=this.events;let p=0;return f;function f(b){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(b):(i.enter("strikethroughSequenceTemporary"),m(b))}function m(b){const y=Wb(c);if(b===126)return p>1?l(b):(i.consume(b),p++,m);if(p<2&&!n)return l(b);const x=i.exit("strikethroughSequenceTemporary"),_=Wb(b);return x._open=!_||_===2&&!!y,x._close=!y||y===2&&!!_,s(b)}}}class d9t{constructor(){this.map=[]}add(t,n,r){p9t(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 p9t(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 f9t(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 h9t(){return{flow:{null:{name:"table",tokenize:g9t,resolveAll:m9t}}}}function g9t(e,t,n){const r=this;let o=0,a=0,i;return s;function s(O){let P=r.events.length-1;for(;P>-1;){const z=r.events[P][1].type;if(z==="lineEnding"||z==="linePrefix")P--;else break}const D=P>-1?r.events[P][1].type:null,L=D==="tableHead"||D==="tableRow"?A:l;return L===A&&r.parser.lazy[r.now().line]?n(O):L(O)}function l(O){return e.enter("tableHead"),e.enter("tableRow"),c(O)}function c(O){return O===124||(i=!0,a+=1),d(O)}function d(O){return O===null?n(O):Zt(O)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),m):n(O):Tn(O)?kl(e,d,"whitespace")(O):(a+=1,i&&(i=!1,o+=1),O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),i=!0,d):(e.enter("data"),p(O)))}function p(O){return O===null||O===124||Lr(O)?(e.exit("data"),d(O)):(e.consume(O),O===92?f:p)}function f(O){return O===92||O===124?(e.consume(O),p):p(O)}function m(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(e.enter("tableDelimiterRow"),i=!1,Tn(O)?kl(e,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):b(O))}function b(O){return O===45||O===58?x(O):O===124?(i=!0,e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),y):C(O)}function y(O){return Tn(O)?kl(e,x,"whitespace")(O):x(O)}function x(O){return O===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),_):O===45?(a+=1,_(O)):O===null||Zt(O)?T(O):C(O)}function _(O){return O===45?(e.enter("tableDelimiterFiller"),k(O)):C(O)}function k(O){return O===45?(e.consume(O),k):O===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(O))}function E(O){return Tn(O)?kl(e,T,"whitespace")(O):T(O)}function T(O){return O===124?b(O):O===null||Zt(O)?!i||o!==a?C(O):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(O)):C(O)}function C(O){return n(O)}function A(O){return e.enter("tableRow"),R(O)}function R(O){return O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),R):O===null||Zt(O)?(e.exit("tableRow"),t(O)):Tn(O)?kl(e,R,"whitespace")(O):(e.enter("data"),M(O))}function M(O){return O===null||O===124||Lr(O)?(e.exit("data"),R(O)):(e.consume(O),O===92?j:M)}function j(O){return O===92||O===124?(e.consume(O),M):M(O)}}function m9t(e,t){let n=-1,r=!0,o=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,l=0,c,d,p;const f=new d9t;for(;++n<e.length;){const m=e[n],b=m[1];m[0]==="enter"?b.type==="tableHead"?(s=!1,l!==0&&(Qhe(f,t,l,c,d),d=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,p=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,d={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",d,t]])),o=b.type==="tableDelimiterRow"?2:d?3:1):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],p=xE(f,t,a,o,void 0,p),a=[0,0,0,0]),i[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(i[0]=i[1],p=xE(f,t,a,o,void 0,p)),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],p=xE(f,t,a,o,n,p)):i[1]!==0&&(p=xE(f,t,i,o,n,p)),o=0):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(i[3]=n)}for(l!==0&&Qhe(f,t,l,c,d),f.consume(t.events),n=-1;++n<t.events.length;){const m=t.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=f9t(t.events,n))}return e}function xE(e,t,n,r,o,a){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Xm(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=Xm(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=Xm(t.events,n[2]),d=Xm(t.events,n[3]),p={type:s,start:Object.assign({},c),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const f=t.events[n[2]],m=t.events[n[3]];if(f[1].end=Object.assign({},m[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,y=n[3]-n[2]-1;e.add(b,y,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return o!==void 0&&(a.end=Object.assign({},Xm(t.events,o)),e.add(o,0,[["exit",a,t]]),a=void 0),a}function Qhe(e,t,n,r,o){const a=[],i=Xm(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 Xm(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const b9t={name:"tasklistCheck",tokenize:y9t};function v9t(){return{text:{91:b9t}}}function y9t(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 Lr(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 Zt(l)?t(l):Tn(l)?e.check({tokenize:x9t},t,n)(l):n(l)}}function x9t(e,t,n){return kl(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function w9t(e){return oEe([W8t(),n9t(),u9t(e),h9t(),v9t()])}const _9t={};function S9t(e){const t=this,n=e||_9t,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(w9t(n)),a.push(B8t()),i.push(H8t(n))}function S6(e,t,n){return e+(t-e)*n}function zNe(e){return e-Math.floor(e)}function k6(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=Fs(n,r),s=Fs(n+1,r),l=Fs(n,r+1),c=Fs(n+1,r+1);return i+(s-i)*o+(l-i)*a+(i-s-l+c)*o*a}function Fs(e,t){const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)}function dZ(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 k9t(e,t){return Math.atan2(Math.sin(e-t),Math.cos(e-t))}function Tg(e,t,n,r,o){const a=Math.sin(t),i=Math.cos(t),s=Math.sin(e),l=Math.cos(e);return(c,d,p)=>{const f=c*l+p*s,m=-c*s+p*l,b=d*i-m*a,y=d*a+m*i;return[n+f*o,r-b*o,y]}}function $Ne(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 E9t(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=$Ne(s,i,n,o),e.beginPath(),e.arc(a.x,a.y,a.r,0,Math.PI*2),e.fill()}}function T9t(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=$Ne(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 rf(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 FNe(e,t,n,r){t.lines.length&&T9t(e,t.lines,n,r),E9t(e,t.dots,n,.3,r)}function Ag(e,t){return(e/300)**t}const A9t=[["latRings","lonDensity"],["rings","lonDensity"],["lanes","segs"]],C9t=["orbitN","ghostN","nodeN","strandN","signals"],R9t=["iconD"],I9t=["rBase","rDepth","rActive","rDot","ghostR","partR","partRDepth","nodeR","nodeRDepth"];function UNe(e,t){const n={...e},r=new Set,o=Math.sqrt(t);for(const[a,i]of A9t){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 C9t){const i=n[a];i!=null&&i!==0&&!r.has(a)&&(n[a]=Math.max(1,Math.round(i*t)))}for(const a of R9t){const i=n[a];i!=null&&(n[a]=Math.max(.02,i*t))}return n}function BNe(e,t){const n={...e};for(const r of I9t){const o=n[r];o!=null&&(n[r]=o*t)}return n.rSizeMul=(n.rSizeMul??1)*t,n}const N9t={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}},M9t=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.76,i=Tg(t*.4,.3,r,o,1),s=Ag(e,n.rsPow??.6),l=[],c=n.ghostN??150;for(let f=0;f<c;f++){const m=dZ(f,c),[b,y,x]=i(m[0]*a,m[1]*a,m[2]*a),_=(x/a+1)/2;l.push({x:b,y,z:x,r:.8*s,white:.78,a:.1+.22*_})}const d=n.strandN??52,p=n.turns??3;for(let f=0;f<3;f++){const m=f/3*2*Math.PI;for(let b=0;b<d;b++){const y=(zNe(b/d+t*.045)*2-1)*.96,x=Math.sqrt(Math.max(0,1-y*y)),_=Math.min(1,(1-Math.abs(y))/.1),k=y*Math.PI*p+m,E=1+.075*Math.sin(y*Math.PI*p*2+m*2+t*.8),T=x*a*E,[C,A,R]=i(Math.cos(k)*T,y*a*E,Math.sin(k)*T),M=(R/a+1)/2;l.push({x:C,y:A,z:R,r:((n.rBase??1.2)+(n.rDepth??1.8)*M)*s,white:.55-.45*M,a:_*(.45+.55*M)})}}return rf(l,[],n.rMin)};function O9t(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,p=1-(1-Math.min(1,c/.7))**3;if(l<t){for(let f=0;f<l;f++)i[f]=1;i[l]=p,s=l}else{const f=2*t-1-l;for(let m=0;m<f;m++)i[m]=1;i[f]=1-p,s=f}}return{amount:i,active:s}}function j9t(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 d=l.ang*n.amount[s],p=Math.cos(d),f=Math.sin(d);if(l.axis===0){const m=o*p-a*f;a=o*f+a*p,o=m}else if(l.axis===1){const m=r*p+a*f;a=-r*f+a*p,r=m}else{const m=r*p-o*f;o=r*f+o*p,r=m}}return[r,o,a,i]}function P9t(e){const t=[];for(let n=0;n<e;n++){const r=Math.min(2,Math.floor(Fs(n,2.3)*3)),o=-1+.5*Math.min(3,Math.floor(Fs(n,5.9)*4)),a=Fs(n,7.7)<.5?1:-1;t.push({axis:r,lo:o,hi:o+.5,ang:a*Math.PI/2})}return t}const D9t=(e,t,n)=>{const o=e/2,a=e/2,i=e/2*.82,s=.4+.06*Math.sin(t*.35),l=Tg(t*.5,s,o,a,i),c=t*(.5+(1.7-.5)*(n.scanMul??1)),d=Ag(e,n.rsPow??.6),p=n.dimBase??1,f=[],m=n.latRings??17,b=n.lonDensity??44;for(let y=0;y<=m;y++){const x=-Math.PI/2+y/m*Math.PI,_=Math.cos(x),k=Math.sin(x),E=Math.max(1,Math.round(Math.abs(_)*b));for(let T=0;T<E;T++){const C=T/E*2*Math.PI,[A,R,M]=l(_*Math.cos(C),k,_*Math.sin(C)),j=(M+1)/2,O=k9t(C+t*.5,c),P=Math.exp(-(O*O)/.18)*Math.max(0,M);f.push({x:A,y:R,z:M,r:((n.rBase??.6)+(n.rDepth??1.7)*j+(n.rBoost??1)*P)*d,white:(n.inkFar??.62)-(n.inkSpan??.54)*j,a:p+(1-p)*Math.min(1,P)})}}return rf(f,[],n.rMin)},L9t=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.82,i=Tg(t*.55,.35+.1*Math.sin(t*.9),r,o,a),s=Ag(e,n.rsPow??.6),l=n.moveCount??14,c=P9t(l),d=O9t(t,l,.42,1.2),p=[],f=n.latRings??15,m=n.lonDensity??40;for(let b=0;b<=f;b++){const y=-Math.PI/2+b/f*Math.PI,x=Math.cos(y),_=Math.sin(y),k=Math.max(1,Math.round(Math.abs(x)*m));for(let E=0;E<k;E++){const T=E/k*2*Math.PI,[C,A,R,M]=j9t([x*Math.cos(T),_,x*Math.sin(T)],c,d),[j,O,P]=i(C,A,R),D=(P+1)/2;p.push({x:j,y:O,z:P,r:((n.rBase??.6)+(n.rDepth??1.7)*D+(M?n.rActive??.3:0))*s,white:(n.inkFar??.62)-(n.inkSpan??.54)*D-(M?.14:0)})}}return rf(p,[],n.rMin)},z9t=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.874,i=Tg(t*.18,.38,r,o,1),s=Ag(e,n.rsPow??.6),l=[],c=n.rings??15,d=n.lonDensity??40;for(let p=0;p<=c;p++){const f=-Math.PI/2+p/c*Math.PI,m=Math.cos(f),b=Math.sin(f),y=.62*Math.sin(t*2.1-p*.52)+.38*Math.sin(t*1.27+p*.83),x=a*(.88+.105*y),_=Math.max(1,Math.round(Math.abs(m)*d));for(let k=0;k<_;k++){const E=k/_*2*Math.PI,[T,C,A]=i(m*Math.cos(E)*x,b*x,m*Math.sin(E)*x),R=(A/a+1)/2,M=Math.max(0,y);l.push({x:T,y:C,z:A,r:((n.rBase??.6)+(n.rDepth??1.7)*R)*(1+.4*M)*s,white:.66-.56*R-.1*M})}}return rf(l,[],n.rMin)};function $9t(e){return e*e*(3-2*e)}function HNe(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 F9t=e=>{const t=-Math.PI/2+e*2*Math.PI;return[Math.cos(t)*.24,Math.sin(t)*.24]},U9t=HNe([[0,-.26],[.24,.16],[-.24,.16]]),B9t=HNe([[0,-.2],[.2,-.2],[.2,.2],[-.2,.2],[-.2,-.2]]),E6=[F9t,U9t,B9t];function H9t(e){return Math.max(6,Math.round(34*e))}const e$=1.4,VNe=.9,wE=e$+VNe,V9t=(e,t,n)=>{const r=E6.length,o=t%(wE*r),a=n.shape!=null&&n.shape>=0&&n.shape<r?Math.floor(n.shape):-1,i=a>=0?a:Math.floor(o/wE),s=a>=0?t%wE:o-i*wE,l=a>=0?0:s>e$?$9t((s-e$)/VNe):0,c=n.spread??1,d=E6[i],p=a>=0?d:E6[(i+1)%r],f=160,m=[];for(let R=0;R<f;R++){const M=R/f,j=d(M),O=p(M);m.push([(j[0]+(O[0]-j[0])*l)*c,(j[1]+(O[1]-j[1])*l)*c])}const b=[];let y=0;for(let R=0;R<f;R++){const M=m[R],j=m[(R+1)%f],O=Math.hypot(j[0]-M[0],j[1]-M[1]);b.push(O),y+=O}const x=H9t(n.iconD??1),_=(n.rDot??.021)*1.35*c,k=1+.02*Math.sin(s*3.1),E=[],T=e/2;let C=0,A=0;for(let R=0;R<x;R++){const M=R/x*y;for(;A+b[C]<M&&C<f-1;)A+=b[C],C++;const j=m[C],O=m[(C+1)%f],P=b[C]?Math.min(1,(M-A)/b[C]):0,D=(j[0]+(O[0]-j[0])*P)*k,L=(j[1]+(O[1]-j[1])*P)*k;E.push({x:T+D*e,y:T+L*e,z:0,r:Math.max(.35,_*e),white:.1})}return rf(E,[],n.rMin)},G9t=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.82,i=Tg(t*.12,.3,r,o,1),s=Ag(e,n.rsPow??.6),l=[],c=n.orbitN??12,d=n.ghostN??40,p=n.particles??3;for(let f=0;f<c;f++){const m=Fs(f,1.7),b=Fs(f,5.2),y=Fs(f,8.9),x=a*(.45+.52*m),_=m*2*Math.PI,k=Math.acos(2*b-1),E=Math.sin(k)*Math.cos(_),T=Math.cos(k),C=Math.sin(k)*Math.sin(_);let A=-T,R=E;const M=0,j=Math.max(1e-6,Math.sqrt(A*A+R*R));A/=j,R/=j;const O=T*M-C*R,P=C*A-E*M,D=E*R-T*A,L=(.25+.55*y)*(y>.5?1:-1);for(let z=0;z<d;z++){const F=z/d*2*Math.PI,[$,H,V]=i((A*Math.cos(F)+O*Math.sin(F))*x,(R*Math.cos(F)+P*Math.sin(F))*x,(M*Math.cos(F)+D*Math.sin(F))*x),Y=(V/x+1)/2;l.push({x:$,y:H,z:V,r:(n.ghostR??.9)*s,white:.72,a:(n.ghostA??.5)*(.4+.6*Y)})}for(let z=0;z<p;z++){const F=t*L+z/p*2*Math.PI+b*6,[$,H,V]=i((A*Math.cos(F)+O*Math.sin(F))*x,(R*Math.cos(F)+P*Math.sin(F))*x,(M*Math.cos(F)+D*Math.sin(F))*x),Y=(V/x+1)/2;l.push({x:$,y:H,z:V,r:((n.partR??1.2)+(n.partRDepth??1.6)*Y)*s,white:.3-.22*Y})}}return rf(l,[],n.rMin)},Jhe=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.78,i=n.spin??1,s=.3,l=Tg(t*.1*i,s,r,o,1),c=Ag(e,n.rsPow??.6),d=[],p=n.ghostN??150;for(let D=0;D<p;D++){const L=dZ(D,p),[z,F,$]=l(L[0]*a,L[1]*a,L[2]*a),H=($/a+1)/2;d.push({x:z,y:F,z:$,r:.8*c,white:.78,a:.1+.22*H})}const f=t*.24*i,m=n.faceOn?-s:.55+.3*Math.sin(t*.18)*i,b=Math.cos(f),y=0,x=Math.sin(f),_=-x*Math.sin(m),k=Math.cos(m),E=b*Math.sin(m),T=y*E-x*k,C=x*_-b*E,A=b*k-y*_,R=.23*(n.wobMul??1),M=n.faceOn?a/(1+.85*R):a,j=n.lanes??5,O=n.segs??88,P=Math.max(1,Math.round(j*(n.bandMul??1)));for(let D=0;D<P;D++){const L=(D-(P-1)/2)*.075,z=Math.abs(D-(P-1)/2)/Math.max(1,(P-1)/2);for(let F=0;F<O;F++){const $=F/O*2*Math.PI,H=(.16*Math.sin($*3-t*1.7+D*.22)+.07*Math.sin($*5+t*1.1))*(n.wobMul??1),V=n.faceOn?1+H:1,Y=n.faceOn?L:L+H,U=b*Math.cos($)+_*Math.sin($)+T*Y,X=y*Math.cos($)+k*Math.sin($)+C*Y,J=x*Math.cos($)+E*Math.sin($)+A*Y,K=Math.sqrt(U*U+X*X+J*J),G=M*V,[Q,ne,de]=l(U/K*G,X/K*G,J/K*G),se=(de/a+1)/2;d.push({x:Q,y:ne,z:de,r:((n.rBase??1.1)+(n.rDepth??1.7)*se)*(1-.25*z)*c,white:.52-.44*se+.18*z,a:.4+.6*se})}}return rf(d,[],n.rMin)},W9t=(e,t,n)=>{const r=e/2,o=e/2,a=e/2*.8*(n.spread??1),i=Tg(t*.12,.32,r,o,a),s=Ag(e,n.rsPow??.6),l=n.nodeN??30,c=n.thr??.72,d=n.nodeR??1.4,p=n.nodeRDepth??1.8,f=[];for(let x=0;x<l;x++){const _=dZ(x,l),k=_[0]+.3*(k6(x*.31+9,t*.24)-.5)*2,E=_[1]+.3*(k6(x*.53+27,t*.21)-.5)*2,T=_[2]+.3*(k6(x*.77+55,t*.27)-.5)*2,C=Math.sqrt(k*k+E*E+T*T);f.push([k/C,E/C,T/C])}const m=[],b=[];for(let x=0;x<l;x++)for(let _=x+1;_<l;_++){const k=f[x][0]-f[_][0],E=f[x][1]-f[_][1],T=f[x][2]-f[_][2],C=Math.sqrt(k*k+E*E+T*T);if(C>=c)continue;const[A,R,M]=i(f[x][0],f[x][1],f[x][2]),[j,O,P]=i(f[_][0],f[_][1],f[_][2]),D=((M+P)/2+1)/2;m.push({x1:A,y1:R,x2:j,y2:O,white:.42,a:(1-C/c)*(.3+.55*D),w:Math.max(.6,(n.lineW??.8)*s)})}for(let x=0;x<l;x++){const[_,k,E]=i(f[x][0],f[x][1],f[x][2]),T=(E+1)/2,C=1+.25*Math.sin(t*1.4+x*2.7);b.push({x:_,y:k,z:E,r:(d+p*T)*C*s,white:.55-.45*T})}const y=n.signals??5;for(let x=0;x<y;x++){const _=Math.floor(t*.55+x*7.31),k=Math.floor(Fs(_,x*3.1+1.7)*l),E=Math.floor(Fs(_,x*5.7+4.2)*l);if(k===E)continue;const T=zNe(t*.55+x*7.31),C=S6(f[k][0],f[E][0],T),A=S6(f[k][1],f[E][1],T),R=S6(f[k][2],f[E][2],T),M=Math.max(1e-6,Math.sqrt(C*C+A*A+R*R)),[j,O,P]=i(C/M,A/M,R/M),D=(P+1)/2;b.push({x:j,y:O,z:P,r:(d*1.5+p*D)*s,white:.05,a:.5+.5*D})}return rf(b,m,n.rMin)},GNe={orbits:G9t,globe:D9t,rubik:L9t,wave:z9t,web:W9t,braid:M9t,ribbon:Jhe,ring:Jhe,morph:V9t};Object.fromEntries(Object.entries(GNe).map(([e,t])=>[e,(n,r,o,a,i)=>FNe(n,t(r,o,i),a)]));const K9t={working:"orbits",searching:"globe",solving:"rubik",listening:"wave",connecting:"web",weaving:"braid",composing:"ribbon",breathing:"ring",shaping:"morph"},Y9t={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}}}},ege=new Map;function Z9t(e,t){const n=`${e}-${t}`,r=ege.get(n);if(r)return r;const o=K9t[e],a=Y9t[o][t];let i={...N9t[o]};a.count!==1&&(i=UNe(i,a.count)),a.size!==1&&(i=BNe(i,a.size)),a.extra&&(i={...i,...a.extra});const s={mode:o,speed:a.speed,opts:i};return ege.set(n,s),s}function X9t(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 q9t(){return typeof matchMedia>"u"||matchMedia("(prefers-color-scheme: dark)").matches}function Q9t(e,t){const[n,r]=w.useState(!0);return w.useEffect(()=>{if(e==="dark"){r(!0);return}if(e==="light"){r(!1);return}const o=()=>{const l=X9t(t.current);r(l??q9t())};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 J9t(){const[e,t]=w.useState(!1);return w.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 Os=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 Tl=null,Xh=null,Ib=null,tge=0,WNe=0,sw=!1,t$="",n$=0;function e$t(e){if(e===Tl||(Tl=e,Xh=null,Ib=null,sw=!1,n$=0,WNe=typeof window<"u"&&window.devicePixelRatio||1,qh(),!e||typeof Image>"u"))return;const t=new Image;t.decoding="async",t.onload=()=>{Tl===e&&(Xh=t,rN())},t.src=e.src}const ib=new Set;let Rv=!1,Rp=0,r$=0,bl=Number.NaN,sh=Number.NaN,o$=0,a$=0,rp=0,Yi=null,gT=!0,lw=!1;function t$t(e,t=!0){const n=t===!0?{}:t;n.sprite&&e$t(n.sprite);const r={el:e,opts:{reach:Math.max(1,n.reach??Os.reach),strength:Math.max(0,Math.min(64,n.strength??Os.strength)),deform:Math.max(0,Math.min(32,n.deform??Os.deform)),taper:Math.max(1,Math.min(4,n.taper??Os.taper)),curve:Math.max(1,Math.min(4,n.curve??Os.curve)),falloff:Math.max(2,Math.min(200,n.falloff??Os.falloff)),smoothing:nge(n.smoothing??Os.smoothing),handover:nge(n.handover??Os.handover),squash:Math.max(0,Math.min(3,n.squash??Os.squash)),blur:Math.max(0,Math.min(24,n.blur??Os.blur)),fadeMs:Math.max(1,n.fadeMs??Os.fadeMs)}};return ib.add(r),o$t(),rN(),()=>{ib.delete(r),Yi===r&&(Yi=null),ib.size===0&&queueMicrotask(()=>{ib.size===0&&a$t()})}}const nge=e=>Math.max(0,Math.min(1,e)),mT=e=>e.opts,Ox=e=>typeof window.matchMedia=="function"&&window.matchMedia(e).matches;function n$t(){if(sw)return t$||"disabled by a fail-safe";if(!Tl)return"no pointer sprite set";if(!Xh)return"pointer sprite still loading";if(Ox("(prefers-reduced-motion: reduce)"))return"prefers-reduced-motion is on";if(Ox("(forced-colors: active)"))return"forced colours are active";if(!Ox("(pointer: fine)")||!Ox("(hover: hover)"))return"no fine pointer";if((window.devicePixelRatio||1)!==WNe)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 r$t(){return n$t()===null}function o$t(){Rv||ib.size===0||typeof document>"u"||Ox("(pointer: fine)")&&(Rv=!0,document.addEventListener("pointermove",KNe,{passive:!0}),document.addEventListener("pointerleave",mp),document.addEventListener("pointercancel",mp),document.addEventListener("keydown",YNe,{passive:!0}),document.addEventListener("visibilitychange",mp),window.addEventListener("blur",mp))}function a$t(){Rv&&(Rv=!1,document.removeEventListener("pointermove",KNe),document.removeEventListener("pointerleave",mp),document.removeEventListener("pointercancel",mp),document.removeEventListener("keydown",YNe),document.removeEventListener("visibilitychange",mp),window.removeEventListener("blur",mp),Rp!==0&&(cancelAnimationFrame(Rp),Rp=0),Yi=null,rp=0,qh(),Ic&&(Ic.remove(),Ic=null,Eu=null,W2=null),mh&&(mh.remove(),mh=null))}function KNe(e){gT=e.pointerType==="mouse"||e.pointerType==="",lw=!1,pZ++,bl=o$=e.clientX,sh=a$=e.clientY,B_&&(B_=!1,cw(),uw=0,dw=0,lh=sb=Number.NaN),rN()}function YNe(){lw=!0,qh()}function mp(){bl=sh=Number.NaN,rN()}function rN(){!Rv||Rp!==0||(r$=performance.now(),Rp=requestAnimationFrame(l$))}let Ic=null,Eu=null,W2=null,Iv=!1;const Rh="thinking-orb-gravity-hide";let mh=null,U_=!1;const rge=new WeakMap;let pZ=0,fZ=-1,i$=0,ZNe=-1;function i$t(){if(Ic)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?(Ic=e,Eu=t,W2=n,s$=0,!0):(e.remove(),!1)}function s$t(){mh||(mh=document.createElement("style"),mh.textContent=`html.${Rh}, html.${Rh} * { cursor: none !important; }`,document.head.appendChild(mh))}function l$t(e){const t=rge.get(e);if(t)return t;const n=document.documentElement,r=n.classList.contains(Rh);r&&n.classList.remove(Rh);const o=getComputedStyle(e).cursor;return r&&n.classList.add(Rh),rge.set(e,o),o}function oge(e,t){const n=document.elementFromPoint(e,t);if(!n)return!1;const r=l$t(n);return r!=="auto"&&r!=="default"?(hZ(),!1):(U_||(s$t(),document.documentElement.classList.add(Rh),U_=!0,fZ=pZ,ZNe=i$),!0)}function hZ(){U_&&(document.documentElement.classList.remove(Rh),U_=!1,fZ=-1)}function cw(){Ic&&Iv&&(Ic.style.display="none",Iv=!1)}const c$t=500;let age=Number.NEGATIVE_INFINITY,B_=!1;function qh(){B_=!1,hZ(),cw(),uw=0,dw=0,lh=sb=Number.NaN}const bh={cx:0,cy:0,r:0};let uw=0,dw=0,lh=Number.NaN,sb=Number.NaN;const Ff=48,ige=10;let Mm=null,T6=null,Uf=null,Bf=null,lb=null,s$=0,sge=0,lge=0;function u$t(e){if(!Xh||!Tl)return null;const t=document.createElement("canvas");t.width=Math.ceil(Tl.width*e),t.height=Math.ceil(Tl.height*e);const n=t.getContext("2d",{willReadFrequently:!0});return n?(n.scale(e,e),n.drawImage(Xh,0,0,Tl.width,Tl.height),n.getImageData(0,0,t.width,t.height)):null}function d$t(e,t,n,r,o,a,i){if(!Ib||!lb)return;const s=lb.width,l=lb.height,c=Ib,d=c.width,p=c.height,f=c.data,m=lb.data;m.fill(0);const b=Math.max(1,Math.hypot(d,p)),y=a-r,x=i-o,_=Math.hypot(y,x)||1,k=y/_,E=x/_,T=Math.max(0,Math.floor(n+Math.min(0,e*k)-3)),C=Math.min(s,Math.ceil(n+d+Math.max(0,e*k)+3)),A=Math.max(0,Math.floor(n+Math.min(0,e*E)-3)),R=Math.min(l,Math.ceil(n+p+Math.max(0,e*E)+3));for(let M=A;M<R;M++)for(let j=T;j<C;j++){const O=(M*s+j)*4;let P=j-n,D=M-n;if(e>.01){let X=j,J=M,K=0,G=0,Q=0,ne=1;for(let oe=0;oe<7;oe++){const re=Math.hypot(X-r,J-o)/b;K=e*Math.pow(Math.min(1,re),t),G=a-X,Q=i-J,ne=Math.hypot(G,Q)||1,X+=(j-K*G/ne-X)*.5,J+=(M-K*Q/ne-J)*.5}const de=X+K*G/ne-j,se=J+K*Q/ne-M;if(de*de+se*se>2.25){m[O]=m[O+1]=m[O+2]=m[O+3]=0;continue}P=X-n,D=J-n}const L=Math.floor(P),z=Math.floor(D);if(L<-1||z<-1||L>=d||z>=p){m[O]=m[O+1]=m[O+2]=m[O+3]=0;continue}const F=P-L,$=D-z;let H=0,V=0,Y=0,U=0;for(let X=0;X<4;X++){const J=L+(X&1),K=z+(X>>1);if(J<0||K<0||J>=d||K>=p)continue;const G=(X&1?F:1-F)*(X>>1?$:1-$),Q=(K*d+J)*4,ne=G*f[Q+3];H+=f[Q]*ne,V+=f[Q+1]*ne,Y+=f[Q+2]*ne,U+=ne}U>0?(m[O]=H/U,m[O+1]=V/U,m[O+2]=Y/U,m[O+3]=U):m[O]=m[O+1]=m[O+2]=m[O+3]=0}}function cge(e,t,n){if(!W2||!Eu||!Ic||!Tl||!Xh)return;const r=Tl,o=mT(e),a=Math.min(3,window.devicePixelRatio||1);if(Mm||(Mm=document.createElement("canvas"),T6=Mm.getContext("2d")),Uf||(Uf=document.createElement("canvas"),Bf=Uf.getContext("2d")),!T6||!Bf||((!Ib||tge!==a)&&(Ib=u$t(a),tge=a),!Ib))return;if(a!==s$||r.width!==sge||r.height!==lge){s$=a,sge=r.width,lge=r.height;const $=Math.ceil((r.width+2*Ff)*a),H=Math.ceil((r.height+2*Ff)*a);Eu.width=Mm.width=Uf.width=$,Eu.height=Mm.height=Uf.height=H,Eu.style.width=`${r.width+2*Ff}px`,Eu.style.height=`${r.height+2*Ff}px`,lb=Bf.createImageData($,H)}const i=Eu.width,s=Eu.height,l=Math.pow(t,o.curve),c=1-Math.exp(-n/(.012+o.smoothing*.14));uw+=(o.strength*l-uw)*c,dw+=(o.deform*l-dw)*c;let d=uw*a,p=dw*a;if(Number.isNaN(lh))lh=bh.cx,sb=bh.cy;else{const $=1-Math.exp(-n/(.05+o.handover*.6));lh+=(bh.cx-lh)*$,sb+=(bh.cy-sb)*$}const f=Ff*a,m=f+r.hotX*a,b=f+r.hotY*a,y=m+(lh-o$)*a,x=b+(sb-a$)*a,_=Math.hypot(y-m,x-b)||1,k=(y-m)/_,E=(x-b)/_,T=o.falloff*a;if(o.squash>0){const $=Math.hypot(r.width*.5-r.hotX,r.height-r.hotY)||1,H=(r.width*.5-r.hotX)/$,V=(r.height-r.hotY)/$,Y=Math.max(0,-(k*H+E*V)),U=1+o.squash*Y;d*=U,p*=U}const C=Math.ceil(Math.max(p,1))+4,A=Math.floor(Math.min(f,f+k*d)-C),R=Math.floor(Math.min(f,f+E*d)-C),M=Math.ceil(Math.max(f,f+k*d)+r.width*a+C),j=Math.ceil(Math.max(f,f+E*d)+r.height*a+C),O=Math.max(0,A),P=Math.max(0,R),D=Math.min(i,M)-O,L=Math.min(s,j)-P;p>.01?(d$t(p,o.taper,f,m,b,y,x),Bf.putImageData(lb,0,0,O,P,D,L)):(Bf.setTransform(1,0,0,1,0,0),Bf.clearRect(0,0,i,s),Bf.drawImage(Xh,f,f,r.width*a,r.height*a));const z=W2,F=T6;if(z.setTransform(1,0,0,1,0,0),z.clearRect(0,0,i,s),z.globalAlpha=1,z.globalCompositeOperation="source-over",z.drawImage(Uf,0,0),d>.5){const $=f+r.width*a*.42,H=f+r.height*a*.5,V=T/2,Y=F.createLinearGradient($-k*V,H-E*V,$+k*V,H+E*V);Y.addColorStop(0,"rgba(0,0,0,0)"),Y.addColorStop(1,"rgba(0,0,0,1)");for(let U=ige;U>=1;U--){const X=U/ige;F.setTransform(1,0,0,1,0,0),F.globalCompositeOperation="source-over",F.globalAlpha=1,F.clearRect(O,P,D,L),F.drawImage(Uf,O,P,D,L,O+k*d*X,P+E*d*X,D,L),F.globalCompositeOperation="destination-in",F.fillStyle=Y,F.fillRect(O,P,D,L),z.globalCompositeOperation="destination-over",z.globalAlpha=Math.pow(1-X,1.6)*.9,o.blur>0&&(z.filter=`blur(${(o.blur*Math.sqrt(X)*a).toFixed(2)}px)`),z.drawImage(Mm,O,P,D,L,O,P,D,L)}z.filter="none",z.globalAlpha=1,z.globalCompositeOperation="source-over"}Ic.style.transform=`translate3d(${(o$-r.hotX-Ff).toFixed(2)}px,${(a$-r.hotY-Ff).toFixed(2)}px,0)`,Iv||(Ic.style.display="",Iv=!0)}function l$(e){if(Rp=0,!Rv)return;const t=performance.now();try{p$t(e)}catch(r){sw=!0,t$=`disabled after an error (${r instanceof Error?r.message:String(r)})`,qh(),Yi=null,typeof console<"u"&&console.warn("thinking-orbs: gravity disabled after error",r);return}const n=performance.now()-t;n>12?++n$>=30&&!sw&&(sw=!0,t$=`disabled after slow frames (~${Math.round(n)}ms each)`,qh()):n$=0}function p$t(e){const t=Math.min(.05,Math.max(.001,(e-r$)/1e3));r$=e,i$++;let n=null,r=0;if(!Number.isNaN(bl)&&r$t()){let s=Number.POSITIVE_INFINITY;for(const l of ib){if(!l.el.isConnected)continue;const c=l.el.getBoundingClientRect();if(c.width<=0)continue;const d=c.left+c.width/2,p=c.top+c.height/2,f=Math.min(c.width,c.height)/2,m=mT(l).reach;if(bl<d-f-m||bl>d+f+m||sh<p-f-m||sh>p+f+m)continue;const b=Math.hypot(bl-d,sh-p)-f;b<=m&&b<s&&(s=b,n=l,bh.cx=d,bh.cy=p,bh.r=f)}if(n){const l=1-Math.max(0,s)/mT(n).reach;r=l*l*(3-2*l),age=e}}const o=Yi??n,a=o?mT(o).fadeMs:Os.fadeMs,i=1-Math.exp(-(t*1e3)/(a/3));if(rp+=(r-rp)*i,n&&n!==Yi&&(Yi=n),!n&&rp<.002){if(rp=0,Yi&&U_&&!B_&&gT&&!lw&&!Number.isNaN(bl)){if(e-age<c$t){oge(bl,sh)?cge(Yi,0,t):cw(),Rp=requestAnimationFrame(l$);return}if(Iv){hZ(),B_=!0,Yi=null;return}}Yi=null,qh();return}Yi&&(rp>.002&&gT&&!lw&&!Number.isNaN(bl)&&i$t()&&oge(bl,sh)?fZ===pZ&&i$-ZNe<2&&!Iv?cw():cge(Yi,rp,t):rp>.002&&!Number.isNaN(bl)&&gT&&!lw?cw():qh(),Rp=requestAnimationFrame(l$))}function f$t(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 h$t={working:"Working…",searching:"Searching…",solving:"Solving…",listening:"Listening…",connecting:"Connecting…",weaving:"Weaving…",composing:"Composing…",breathing:"Thinking…",shaping:"Shaping…"};function gZ({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:d,style:p,"aria-label":f,...m}){const b=w.useRef(null),y=l?JSON.stringify(l):"",x=Q9t(n,b),_=d?JSON.stringify(d):"";w.useEffect(()=>{const E=b.current;if(!(!E||!d))return t$t(E,d===!0?!0:d)},[_]);const k=J9t();return w.useEffect(()=>{const E=b.current;if(!E)return;const T=Math.min(2,typeof devicePixelRatio<"u"&&devicePixelRatio||1);E.width=Math.round(t*T),E.height=Math.round(t*T);const C=E.getContext("2d");if(!C)return;const{mode:A,speed:R,opts:M}=Z9t(e,t);let j=i!==1?UNe(M,Math.max(.1,i)):M;s!==1&&(j=BNe(j,Math.max(.1,s))),l&&(j={...j,...l});const O=c??GNe[A],P=f$t(a),D=R*r,L=J=>{C.setTransform(T,0,0,T,0,0),C.clearRect(0,0,t,t),FNe(C,O(t,J,j),x,P)};if(k){L(.6);return}let z=0,F=!1;const $=()=>{L(performance.now()/1e3*D),F&&(z=requestAnimationFrame($))},H=()=>{F||o||(F=!0,z=requestAnimationFrame($))},V=()=>{F=!1,cancelAnimationFrame(z)};L(performance.now()/1e3*D);let Y=!0;const U=typeof IntersectionObserver<"u"?new IntersectionObserver(([J])=>{Y=J.isIntersecting,Y&&document.visibilityState!=="hidden"?H():V()}):null;U==null||U.observe(E);const X=()=>{document.visibilityState==="hidden"?V():Y&&H()};return document.addEventListener("visibilitychange",X),U||H(),()=>{V(),U==null||U.disconnect(),document.removeEventListener("visibilitychange",X)}},[e,t,x,r,o,k,a,i,s,y,c]),g.jsx("canvas",{ref:b,role:"img","aria-label":f??h$t[e],style:{width:t,height:t,display:"block",...p},...m})}var Hf={},A6={},uge;function dge(){return uge||(uge=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})(A6)),A6}var pge;function g$t(){return pge||(pge=1,(function(e){var t=Hf&&Hf.__createBinding||(Object.create?(function(c,d,p,f){f===void 0&&(f=p);var m=Object.getOwnPropertyDescriptor(d,p);(!m||("get"in m?!d.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return d[p]}}),Object.defineProperty(c,f,m)}):(function(c,d,p,f){f===void 0&&(f=p),c[f]=d[p]})),n=Hf&&Hf.__exportStar||function(c,d){for(var p in c)p!=="default"&&!Object.prototype.hasOwnProperty.call(d,p)&&t(d,c,p)};Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.MalformedJSON=e.PartialJSON=e.parseJSON=e.parse=void 0;const r=dge();Object.defineProperty(e,"Allow",{enumerable:!0,get:function(){return r.Allow}}),n(dge(),e);class o extends Error{}e.PartialJSON=o;class a extends Error{}e.MalformedJSON=a;function i(c,d=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(),d)}e.parseJSON=i;const s=(c,d)=>{const p=c.length;let f=0;const m=C=>{throw new o(`${C} at position ${f}`)},b=C=>{throw new a(`${C} at position ${f}`)},y=()=>(T(),f>=p&&m("Unexpected end of input"),c[f]==='"'?x():c[f]==="{"?_():c[f]==="["?k():c.substring(f,f+4)==="null"||r.Allow.NULL&d&&p-f<4&&"null".startsWith(c.substring(f))?(f+=4,null):c.substring(f,f+4)==="true"||r.Allow.BOOL&d&&p-f<4&&"true".startsWith(c.substring(f))?(f+=4,!0):c.substring(f,f+5)==="false"||r.Allow.BOOL&d&&p-f<5&&"false".startsWith(c.substring(f))?(f+=5,!1):c.substring(f,f+8)==="Infinity"||r.Allow.INFINITY&d&&p-f<8&&"Infinity".startsWith(c.substring(f))?(f+=8,1/0):c.substring(f,f+9)==="-Infinity"||r.Allow._INFINITY&d&&1<p-f&&p-f<9&&"-Infinity".startsWith(c.substring(f))?(f+=9,-1/0):c.substring(f,f+3)==="NaN"||r.Allow.NAN&d&&p-f<3&&"NaN".startsWith(c.substring(f))?(f+=3,NaN):E()),x=()=>{const C=f;let A=!1;for(f++;f<p&&(c[f]!=='"'||A&&c[f-1]==="\\");)A=c[f]==="\\"?!A:!1,f++;if(c.charAt(f)=='"')try{return JSON.parse(c.substring(C,++f-Number(A)))}catch(R){b(String(R))}else if(r.Allow.STR&d)try{return JSON.parse(c.substring(C,f-Number(A))+'"')}catch{return JSON.parse(c.substring(C,c.lastIndexOf("\\"))+'"')}m("Unterminated string literal")},_=()=>{f++,T();const C={};try{for(;c[f]!=="}";){if(T(),f>=p&&r.Allow.OBJ&d)return C;const A=x();T(),f++;try{const R=y();C[A]=R}catch(R){if(r.Allow.OBJ&d)return C;throw R}T(),c[f]===","&&f++}}catch{if(r.Allow.OBJ&d)return C;m("Expected '}' at end of object")}return f++,C},k=()=>{f++;const C=[];try{for(;c[f]!=="]";)C.push(y()),T(),c[f]===","&&f++}catch{if(r.Allow.ARR&d)return C;m("Expected ']' at end of array")}return f++,C},E=()=>{if(f===0){c==="-"&&b("Not sure what '-' is");try{return JSON.parse(c)}catch(A){if(r.Allow.NUM&d)try{return JSON.parse(c.substring(0,c.lastIndexOf("e")))}catch{}b(String(A))}}const C=f;for(c[f]==="-"&&f++;c[f]&&",]}".indexOf(c[f])===-1;)f++;f==p&&!(r.Allow.NUM&d)&&m("Unterminated number literal");try{return JSON.parse(c.substring(C,f))}catch{c.substring(C,f)==="-"&&m("Not sure what '-' is");try{return JSON.parse(c.substring(C,c.lastIndexOf("e")))}catch(R){b(String(R))}}},T=()=>{for(;f<p&&`
|
|
984
984
|
\r `.includes(c[f]);)f++};return y()},l=i;e.parse=l})(Hf)),Hf}var m$t=g$t(),b$t=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 737 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_10580_645)",children:[g.jsx("path",{d:"M0 0.015625L40 20.0156V40L20 40V80.0156H40V100.016L0 120.016V0.015625Z",fill:"white"}),g.jsx("path",{d:"M120 0L80 20V40H100V80H80V100L120 120V0Z",fill:"white"}),g.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"})]}),g.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"}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_10580_645",children:g.jsx("rect",{width:120,height:120,fill:"white"})})})]}),v$t=b$t,y$t=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 614 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_10581_1412)",children:[g.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"}),g.jsx("path",{d:"M99.998 0L66.6647 16.6667V33.3333H83.3314V66.6667H66.6647V83.3333L99.998 100V0Z",fill:"#05090E"}),g.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"})]}),g.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"}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_10581_1412",children:g.jsx("rect",{width:100,height:100,fill:"white"})})})]}),x$t=y$t,XNe="TrueForge";function znn(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 fge({image:e,mode:t}){return typeof e=="string"?e:(t==="dark"?e.dark:e.light)??e.light??e.dark??e.src}function w$t(){var t;const e=(t=w.useContext(Hp))==null?void 0:t.brand;return(e==null?void 0:e.name)!=null?e.name:(e==null?void 0:e.mode)==null?XNe:void 0}function mZ({className:e,variant:t="icon"}){const n=w.useContext(Hp),r=n==null?void 0:n.brand,a=w$t()??XNe,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:fge({image:s,mode:i}),c=r==null?void 0:r.icon,d=l??(t==="logo"&&c!=null?fge({image:c,mode:i}):void 0);if(d==null){if(t==="logo"){const m=i==="dark"?v$t:x$t;return g.jsx(m,{className:pe("w-auto",e),width:void 0,height:void 0,role:"img","aria-label":a})}return g.jsx(xe,{name:i==="dark"?"trueforge-logomark-dark":"trueforge-logomark-light",className:e})}const p=g.jsx("img",{src:d,alt:a,className:e}),f=r==null?void 0:r.href;return f==null?p:g.jsx("a",{href:f,"aria-label":a,className:"inline-flex items-center",children:p})}function qNe({expanded:e,onChange:t,children:n,className:r,background:o,sx:a,...i}){const s=w.useId();return g.jsx("div",{className:pe("w-full",r),"data-expanded":e||void 0,...i,children:W.Children.map(n,l=>W.isValidElement(l)?W.cloneElement(l,{expanded:e,onChange:t,panelId:s}):l)})}function QNe({children:e,className:t,expanded:n,onChange:r,panelId:o}){return g.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 JNe({children:e,className:t,expanded:n,panelId:r}){return n?g.jsx("div",{id:r,role:"region",className:pe(t),children:e}):null}w.createContext({openItems:new Set,toggle:()=>{}});function _$t({toolCount:e,thinkingCount:t,expanded:n,active:r=!1,onToggle:o,children:a,borderColor:i,background:s,dataTestPrefix:l,className:c}){const d=`${e} tool ${e===1?"call":"calls"}`,p=t>0?` · ${t} thought${t===1?"":"s"}`:"";return g.jsxs(qNe,{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:[g.jsx(QNe,{className:"p-0",children:g.jsxs("div",{className:"flex w-full items-center gap-2 px-2 py-2 text-left text-xs",children:[g.jsx(xe,{name:n?"chevron-down":"chevron-right",size:"0.75em",className:"shrink-0 text-text-secondary"}),g.jsx("span",{className:"font-semibold text-text-primary",children:"Agent steps"}),g.jsxs("span",{className:"text-text-secondary",children:["· ",d,p]}),r&&g.jsx("div",{className:"ml-auto",children:g.jsx(Gs,{size:12,className:"text-primary-button-bg"})})]})}),g.jsx(JNe,{children:g.jsx("div",{className:"space-y-3 border-t border-border p-3","data-testid":l?`${l}-content`:void 0,children:a})})]})}var bZ=W.forwardRef(({className:e,variant:t="primary",size:n="large",...r},o)=>g.jsx("button",{ref:o,className:Xt({variant:t,size:n,className:e}),...r}));bZ.displayName="Button";function _E(e,t){const n=W.forwardRef((r,o)=>g.jsx(bZ,{ref:o,variant:e,...r}));return n.displayName=t,n}var In=Object.assign(bZ,{Primary:_E("primary","Button.Primary"),Secondary:_E("secondary","Button.Secondary"),Ghost:_E("ghost","Button.Ghost"),Destructive:_E("destructive","Button.Destructive")});function oN(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 eMe=8,xi=6,S$t=100,pw=null,jx=null;function k$t(e,t){pw!=null&&pw!==e&&(jx==null||jx()),pw=e,jx=t}function hge(e){pw===e&&(pw=null,jx=null)}function E$t(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 gge(e){return e==="top"||e==="bottom"}function T$t(e){return e==="bottom"?"translate(-50%, 0)":e==="top"?"translate(-50%, -100%)":e==="right"?"translate(0, -50%)":"translate(-100%, -50%)"}function A$t({left:e,top:t,width:n,height:r,side:o,viewportWidth:a,viewportHeight:i,pad:s=eMe}){let l=e;if(n>0){const d=n/2,p=s+d,f=a-s-d;l=f<p?a/2:Math.min(f,Math.max(p,e))}let c=t;if(r>0)if(o==="bottom"){const d=t+r-(i-s);d>0&&(c=Math.max(s,t-d))}else t-r<s&&(c=s+r);return{top:c,left:l}}function C$t({left:e,top:t,width:n,height:r,side:o,viewportWidth:a,viewportHeight:i,pad:s=eMe}){let l=t;if(r>0){const d=r/2;l=Math.min(i-s-d,Math.max(s+d,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 R$t(e){return e==null||e===!1?!1:typeof e=="string"?e.trim().length>0:!0}function eo({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[d,p]=w.useState(!1),f=l??d,m=l!==void 0,b=$=>{m||p($)},[y,x]=w.useState(null),_=w.useRef(null),k=w.useRef(null),E=w.useRef(null),T=w.useRef(()=>{}),C=w.useRef(0),A=w.useRef(null),R=w.useRef({}),M=w.useRef(()=>{}),j=()=>{A.current!=null&&(clearTimeout(A.current),A.current=null)},O=()=>{j(),C.current=0,hge(R.current),b(!1)};M.current=O;const P=()=>{j(),A.current=setTimeout(()=>{A.current=null,C.current<=0&&O()},S$t)},D=()=>{m||k$t(R.current,()=>M.current()),b(!0)};if(w.useEffect(()=>()=>{j(),hge(R.current)},[]),T.current=()=>{const $=_.current;let H=null;if(s!=null)H={top:o==="bottom"?s.top+xi:s.top-xi,left:s.left};else if($){const U=$.getBoundingClientRect();H=gge(o)?{top:o==="bottom"?U.bottom+xi:U.top-xi,left:i&&E.current!=null?E.current:U.left+U.width/2}:{top:U.top+U.height/2,left:o==="right"?U.right+xi:U.left-xi}}if(H==null)return;const V=k.current;if(V==null){x(H);return}const Y={...H,width:V.offsetWidth,height:V.offsetHeight,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight};x(gge(o)?A$t({...Y,side:o}):C$t({...Y,side:o}))},w.useLayoutEffect(()=>{if(!f){x(null);return}const $=()=>T.current();return $(),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[s,i,f,o,e]),!w.isValidElement(t))return t;const L=t.props,z=w.cloneElement(t,{onMouseEnter($){var H;i&&(E.current=$.clientX),c&&(j(),C.current+=1),D(),(H=L.onMouseEnter)==null||H.call(L,$)},onMouseMove($){var H;i&&s==null&&(E.current=$.clientX,T.current()),(H=L.onMouseMove)==null||H.call(L,$)},onMouseLeave($){var H;E.current=null,c?(C.current=Math.max(0,C.current-1),P()):O(),(H=L.onMouseLeave)==null||H.call(L,$)},onFocus($){var H;D(),(H=L.onFocus)==null||H.call(L,$)},onBlur($){var H;O(),(H=L.onBlur)==null||H.call(L,$)},onClick($){var H;a&&O(),(H=L.onClick)==null||H.call(L,$)}}),F=f&&R$t(e)?di.createPortal(g.jsxs("span",{ref:k,role:"tooltip",style:{top:(y==null?void 0:y.top)??0,left:(y==null?void 0:y.left)??0,transform:T$t(o),visibility:y==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?()=>{j(),C.current+=1}:void 0,onMouseLeave:c?()=>{C.current=Math.max(0,C.current-1),P()}:void 0,children:[c?g.jsx("span",{"aria-hidden":!0,className:"pointer-events-auto absolute",style:E$t(o)}):null,e]}),oN(_.current)):null;return g.jsxs("span",{ref:_,className:pe("relative inline-flex",r),children:[z,F]})}function aN({title:e,children:t,className:n,triggerClassName:r,size:o,side:a,dismissOnClick:i,followCursor:s,anchor:l,open:c,interactive:d}){return g.jsx(eo,{content:e,className:n,triggerClassName:r,side:a,dismissOnClick:i,followCursor:s,anchor:l,open:c,interactive:d,children:t})}var Ip=W.forwardRef(({tooltip:e,children:t,...n},r)=>g.jsx(eo,{content:e,side:"bottom",children:g.jsx(In,{ref:r,size:"icon",...n,children:t})}));Ip.displayName="IconButton";var ox="__tfy_ask_user_question_custom__";function mge(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 bge({letter:e,selected:t,className:n}){return g.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 I$t({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:d=!0,isSubmitAllDisabled:p=!0,onCurrentQuestionIndexChange:f,onCurrentAnswerChange:m,readOnly:b=!1,dataTestPrefix:y,className:x}){const _=s??i>1,k=l??o===i-1;if(e.length===0)return t.length===0?null:g.jsx("div",{className:pe("aui-ask-user-prompt mt-2 flex flex-col gap-3",x),children:t.map(P=>g.jsxs("div",{"data-testid":y?`${y}-answered-${P.id}`:void 0,children:[g.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:[g.jsx("div",{className:"font-sans text-xs font-medium text-primary-button-bg",children:P.question}),g.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:g.jsx("span",{className:"leading-tight",children:"Answered"})})]}),g.jsxs("div",{className:"flex items-center gap-2 rounded-b-lg border border-t-0 border-border px-4 py-3",children:[g.jsx(xe,{name:"circle-check",size:"0.875em",className:"shrink-0 text-primary-button-bg"}),g.jsx("span",{className:"font-sans text-[0.8125rem] font-medium text-text-primary",children:P.isCustom?`Other: ${P.answer}`:P.answer})]})]},P.id))});if(!r)return null;const E=a.radioValue===ox,T=r.options.length>0,C=mge(r.options.length),A=P=>{b||m==null||m(r.id,{radioValue:P})},R=()=>f==null?void 0:f(o+1),M=_&&!k,j=P=>{if(!(P.key!=="Enter"||P.shiftKey||b)){if(P.preventDefault(),M){d||R();return}p||n()}},O=g.jsx("textarea",{rows:1,value:a.custom,disabled:b||!r.id,onFocus:()=>m==null?void 0:m(r.id,{radioValue:ox}),onChange:P=>{m==null||m(r.id,{custom:P.target.value,radioValue:ox})},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 g.jsxs("div",{className:pe("aui-ask-user-prompt mx-auto w-[calc(100%-2rem)] min-w-0 overflow-hidden rounded-lg",x),"data-testid":y?`${y}-question-card`:void 0,children:[g.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:[g.jsx("div",{className:"min-w-0 font-sans text-sm font-medium text-primary-button-bg",children:i>1?"Questions":r.question}),b?g.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:g.jsx("span",{className:"leading-tight",children:"Unanswered"})}):null,!b&&_&&g.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[g.jsx(Ip,{"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:g.jsx(xe,{name:"chevron-left",size:"0.75em"})}),g.jsx(Ip,{"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:g.jsx(xe,{name:"chevron-right",size:"0.75em"})}),g.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:[g.jsxs("span",{children:[" ",o+1," "]})," ",g.jsx("span",{children:" of "})," ",g.jsxs("span",{children:[" ",i," "]})]})]})]}),g.jsxs("div",{className:"flex flex-col gap-2 bg-primary-bg px-4 py-3 border border-t-0 border-border",children:[g.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[_&&g.jsx("div",{className:"font-sans text-xs font-medium text-text-primary",children:r.question||"What would you like to do?"}),g.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:j,children:[r.options.map((P,D)=>{const L=a.radioValue===P,z=mge(D);return g.jsxs("label",{className:pe("col-span-2 grid grid-cols-subgrid items-center overflow-visible",b?"cursor-default":"cursor-pointer"),children:[g.jsx("input",{type:"radio",value:P,disabled:b||!r.id,name:`ask-user-question-option-${r.id}`,checked:L,onChange:()=>A(P),className:"sr-only"}),g.jsx(bge,{letter:z,selected:L}),g.jsx("span",{className:"min-w-0 font-sans text-sm font-medium text-text-primary",children:P})]},`${D}:${P}`)}),T?g.jsxs("label",{className:pe("col-span-2 grid grid-cols-subgrid items-start overflow-visible",b?"cursor-default":"cursor-pointer"),children:[g.jsx("input",{type:"radio",disabled:b||!r.id,value:ox,name:`ask-user-question-option-${r.id}`,checked:E,onChange:()=>A(ox),className:"sr-only"}),g.jsx(bge,{letter:C,selected:E,className:"mt-1.5"}),g.jsx("div",{className:"min-w-0",children:O})]}):g.jsx("div",{className:"col-span-2 min-w-0",children:O})]})]}),!b&&g.jsxs("div",{className:pe("flex items-center",{"justify-between":_,"justify-end":!_}),children:[_&&k&&!c?g.jsx("span",{className:"text-xs font-medium text-failure-bg",children:"Answer all questions to submit"}):g.jsx("span",{}),M?g.jsx(In.Primary,{type:"button",size:"small",onClick:R,disabled:d,className:"bg-gray-850 text-white hover:bg-gray-850 dark:text-black",children:"Next"}):g.jsx(In.Primary,{type:"button",size:"small",onClick:n,disabled:p,className:"bg-gray-850 text-white hover:bg-gray-850 dark:text-black",children:"Continue"})]})]})]})}var N$t="MCP Authentication Required";function M$t({servers:e,connectedServerIds:t,continueLoading:n=!1,onConnect:r,onContinue:o,readOnly:a=!1,title:i=N$t,dataTestPrefix:s,className:l}){return e.length===0?null:g.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:[g.jsx("div",{className:"border rounded-t-lg border-primary-button-bg/30 bg-primary-button-bg/10 px-4 py-2.5",children:g.jsx("div",{className:"font-sans text-sm font-medium text-primary-button-bg",children:i})}),g.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=>g.jsxs("div",{className:"flex items-center justify-between gap-4",children:[g.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-sm",children:[g.jsx(xe,{name:"mcp-server",size:"0.875rem",className:"shrink-0 text-text-secondary"}),g.jsx("span",{className:"shrink-0 font-medium text-text-secondary",children:"MCP Server Name"}),g.jsx("span",{className:"shrink-0 text-xs font-semibold text-text-secondary",children:":"}),g.jsx("span",{className:"truncate font-sans font-medium text-text-primary",children:c.name})]}),t!=null&&t.has(c.id)?g.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-success-bg",children:[g.jsx(xe,{name:"check",size:"0.875rem"}),"Connected"]}):g.jsxs(In.Secondary,{size:"small",disabled:a,onClick:()=>r(c.id),className:"shrink-0",children:["Connect",g.jsx(xe,{name:"external-link",size:"0.75em",className:"ml-1"})]})]},c.id)),o&&g.jsx("div",{className:"flex justify-end pt-1",children:g.jsxs(In.Primary,{size:"small",disabled:a||n,onClick:o,className:"bg-gray-850 text-white hover:bg-gray-850 dark:text-black",children:[n?g.jsx(xe,{name:"loader",className:"animate-spin"}):null,"Continue"]})})]})]})}function vge({className:e,colorClassName:t="bg-warning-bg"}){return g.jsxs("span",{"aria-hidden":!0,className:pe("relative inline-flex h-2 w-2 shrink-0",e),children:[g.jsx("span",{className:pe("pointer-events-none absolute inline-flex h-full w-full rounded-full opacity-75 motion-safe:animate-ping motion-reduce:animate-none",t)}),g.jsx("span",{className:pe("relative inline-flex h-2 w-2 rounded-full",t)})]})}function tMe({icon:e,iconSize:t="0.75em",variant:n="primary",className:r,iconClassName:o}){return g.jsx("div",{className:pe("flex size-5 shrink-0 items-center justify-center",r),children:g.jsx(xe,{name:e,size:t,className:pe(n==="primary"?"text-primary-button-bg":"text-text-secondary",o)})})}function vZ({icon:e,iconVariant:t="primary",iconClassName:n,iconSize:r,title:o,label:a,body:i,expandable:s=!1,expanded:l=!1,onToggle:c,status:d="idle",statusText:p,showSpinner:f=!1,showConnector:m=!1,showContentConnector:b=!0,showPersistentContentConnector:y=!0,showChevronColumn:x=!0,children:_,persistentChildren:k,dataTestPrefix:E,className:T,titleClassName:C,align:A="center"}){const R=!!_,M=!!k,j=s&&c!=null,O=d==="running",P=d==="success",D=d==="error",L=A==="start";return g.jsxs("div",{className:pe("flex min-w-0 flex-col",T),"data-testid":E?`${E}-step-row`:void 0,children:[g.jsxs("div",{className:pe("flex gap-2",L?"items-start":"items-center"),children:[x&&(j?g.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:g.jsx(xe,{name:"chevron-right",size:"0.625rem",className:pe("shrink-0 text-text-secondary transition-transform duration-300",l&&"rotate-90")})}):g.jsx("div",{className:"w-5 shrink-0"})),g.jsx("div",{className:pe("relative flex shrink-0 flex-col items-center",L?"self-start":"self-center"),children:g.jsx(tMe,{icon:e,variant:t,iconClassName:n,iconSize:r})}),g.jsxs("div",{className:pe("flex min-w-0 flex-1 flex-col justify-center",{"cursor-pointer":j}),onClick:j?c:void 0,children:[a&&g.jsx("span",{className:"text-xs font-medium leading-none text-text-secondary",children:a}),o&&g.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[g.jsx("span",{className:pe("min-w-0 truncate font-sans text-[0.75rem] font-medium leading-5 text-text-primary",C),"data-testid":E?`${E}-title`:void 0,children:o}),P&&g.jsx(xe,{name:"circle-check",size:"0.875rem",className:"shrink-0 text-success-bg","data-testid":E?`${E}-success-icon`:void 0})]}),i&&g.jsx("div",{className:"mt-1 font-sans text-sm text-text-secondary",onClick:z=>{l&&j&&z.stopPropagation()},"data-testid":E?`${E}-body`:void 0,children:i})]}),g.jsxs("div",{className:pe("flex shrink-0 items-center gap-2",L?"self-start":"self-center"),children:[p&&g.jsxs("span",{className:"flex items-center gap-1",children:[O&&g.jsx(vge,{}),g.jsx("span",{className:"font-sans text-xs font-medium leading-4 text-text-secondary",children:p})]}),!p&&O&&g.jsx(g.Fragment,{children:f?g.jsx("div",{className:"ml-1",children:g.jsx(Gs,{size:12})}):g.jsx(vge,{})}),D&&g.jsx(xe,{name:"circle-xmark",size:"0.875rem",className:"text-failure-bg","data-testid":E?`${E}-error-icon`:void 0})]})]}),l&&R&&g.jsxs("div",{className:"mt-2 flex min-w-0 gap-3","data-testid":E?`${E}-expanded-content`:void 0,children:[x&&g.jsx("div",{className:"w-5 shrink-0"}),b&&m&&g.jsx("div",{className:"flex w-3 shrink-0 justify-center",children:g.jsx("div",{className:"w-px bg-border"})}),g.jsx("div",{className:"min-w-0 flex-1",children:_})]}),M&&g.jsxs("div",{className:pe("flex min-w-0",y?"gap-3":"gap-2"),"data-testid":E?`${E}-persistent-content`:void 0,children:[x&&g.jsx("div",{className:"w-5 shrink-0"}),y&&m&&g.jsx("div",{className:"flex w-3 shrink-0 justify-center",children:g.jsx("div",{className:"w-px bg-border"})}),g.jsx("div",{className:"min-w-0 flex-1",children:k})]})]})}function O$t({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 d=We("Markdown"),p=!t&&e.length>0&&!o,f=p||o||t,m=t?"running":e.length>0?"success":"idle",b=t?i:a??i,y=n&&e.length>0;return g.jsx("div",{className:pe("aui-reasoning-card mt-2 flex min-w-0 flex-col",c),"data-testid":l?`${l}-${p?"reasoning-inline":"reasoning-accordion"}`:void 0,children:g.jsx(vZ,{icon:t?"brain":"brain-regular",iconVariant:"primary",title:b,expandable:f,expanded:n,onToggle:r,status:m,dataTestPrefix:l,children:y&&g.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:g.jsx(d,{content:e,className:"font-sans text-sm text-text-secondary"})})})})}function j$t({className:e}){return g.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:[g.jsx("span",{className:"animate-pulse font-sans","aria-hidden":!0,children:"●"}),"Still generating a response. It'll appear here when ready."]})}function P$t({code:e,language:t}){const n=We("SyntaxHighlighter"),r=mN();return g.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 yge=100;function D$t(e){const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function L$t(e){const t=[];for(let n=0;n<e.length;n+=yge)t.push(e.slice(n,n+yge));return t}function G1({resourceType:e,resourceIds:t}){const n=j$e(),r=JSON.stringify([...new Set(t.filter(b=>b.length>0))]),o=r!=="[]",a=`${e}:${r}`,i=w.useMemo(()=>D$t(r),[r]),s=w.useMemo(()=>new Set(i),[i]),[l,c]=w.useState({server:null,resourceType:null,key:"",data:{},loading:!1,error:null});w.useEffect(()=>{if(n==null||!o)return;let b=!1;return c(y=>y.server===n&&y.resourceType===e?{...y,key:a,loading:!0,error:null}:{server:n,resourceType:e,key:a,data:{},loading:!0,error:null}),Promise.all(L$t(i).map(y=>n.listPermissions({resourceType:e,resourceIds:y}))).then(y=>{b||c({server:n,resourceType:e,key:a,data:Object.assign({},...y.map(x=>x.data.permissions)),loading:!1,error:null})},y=>{b||c(x=>({server:n,resourceType:e,key:a,data:x.server===n&&x.resourceType===e?x.data:{},loading:!1,error:y}))}),()=>{b=!0}},[o,a,i,e,n]);const d=l.server===n&&l.resourceType===e,p=n!=null&&o&&(!d||l.key!==a||l.loading),f=d&&l.key===a?l.error:null,m=w.useCallback((b,y)=>n==null||b==null||b===""?!0:!s.has(b)||!d?!1:(l.data[b]??[]).includes(y),[s,d,n,l.data]);return{loading:p,error:f,allows:m}}var nMe=w.createContext(!0);function z$t({sessionId:e,assumeManage:t=!1,children:n}){const r=w.useMemo(()=>e==null?[]:[e],[e]),{allows:o}=G1({resourceType:"session",resourceIds:r});return w.createElement(nMe.Provider,{value:t||o(e,"MANAGE")},n)}function iN(){return w.useContext(nMe)}var xge=480,$$t=3e3,yZ=w.createContext(null),wge=0;function _ge(){return wge+=1,`toast-${wge}`}function Sge(e){return e.length<=xge?e:`${e.slice(0,xge-1)}…`}function F$t(e){return e instanceof Error&&("statusCode"in e||"body"in e)}function U$t(e){if(F$t(e)){const t=e.statusCode;if(t!=null||e.body!=null){const n=t!=null?`Request failed (${t})`:"Request failed",r=aa(e,"The server returned an error.");return{title:n,description:Sge(r)}}}return{title:"Something went wrong",description:Sge(aa(e,"An unexpected error occurred."))}}function rMe({children:e}){const t=We("Toast"),n=We("ToastStack"),[r,o]=w.useState([]),a=w.useCallback(c=>{o(d=>d.filter(p=>p.id!==c))},[]),i=w.useCallback(c=>{console.error("[trueforge-ui]",c);const d={id:_ge(),variant:"error",...U$t(c)};o(p=>[...p,d].slice(-5))},[]),s=w.useCallback(c=>{const d=_ge(),p={id:d,variant:"success",...c};o(f=>[...f,p].slice(-5)),typeof window<"u"&&window.setTimeout(()=>a(d),$$t)},[a]),l=w.useMemo(()=>({showError:i,showSuccess:s}),[i,s]);return g.jsxs(yZ.Provider,{value:l,children:[e,g.jsx(n,{children:r.map(c=>g.jsx(t,{title:c.title,description:c.description??"",variant:c.variant,open:!0,onOpenChange:d=>{d||a(c.id)}},c.id))})]})}function B$t(){const e=w.useContext(yZ);if(e==null)throw new Error("useToaster must be used within ToasterProvider");return e}function sN(){return w.useContext(yZ)}function oMe(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 lN({open:e,onOpenChange:t,children:n,className:r,"aria-label":o,"aria-labelledby":a}){const i=W.useRef(null);W.useEffect(()=>{const l=i.current;l&&(e&&!l.open?l.showModal():!e&&l.open&&l.close())},[e]),W.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 g.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 cN({className:e,children:t,...n}){return g.jsx("div",{className:pe("flex flex-col gap-4 p-6",e),...n,children:t})}function xZ({className:e,...t}){return g.jsx("div",{className:pe("flex flex-col gap-1.5",e),...t})}function wZ({className:e,...t}){return g.jsx("h2",{className:pe("text-lg font-semibold leading-none tracking-tight",e),...t})}function aMe({className:e,...t}){return g.jsx("div",{className:pe("flex flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:justify-end",e),...t})}function iMe(e){return e.target===e.currentTarget}function of({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:d=!1}){const[p,f]=w.useState(!1),m=i??p,b=w.useCallback(R=>{i===void 0&&f(R),s==null||s(R)},[i,s]),[y,x]=w.useState(null),_=w.useRef(null),k=w.useRef(null),E=w.useRef(!1),T=w.useId();w.useLayoutEffect(()=>{if(!m){x(null);return}const R=()=>{const M=_.current;if(!M)return;const j=M.getBoundingClientRect();x({top:r==="top"?j.top-4:j.bottom+4,left:n==="end"?j.right:j.left})};return R(),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R)}},[m,n,r]),w.useEffect(()=>{if(!m)return;const R=M=>{var O,P;const j=M.target;j instanceof Node&&((O=_.current)!=null&&O.contains(j)||(P=k.current)!=null&&P.contains(j)||b(!1))};return document.addEventListener("mousedown",R,d),()=>document.removeEventListener("mousedown",R,d)},[d,m,b]),w.useEffect(()=>{if(!m||!c)return;const R=M=>{var O;const j=M.target;j instanceof Node&&((O=k.current)!=null&&O.contains(j))||M.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})}},[m,c]),w.useEffect(()=>{var M;if(!m){E.current=!1;return}if(y==null||E.current)return;const R=(M=k.current)==null?void 0:M.querySelector('[role="menuitem"]:not([disabled])');R==null||R.focus(),E.current=!0},[m,y]),w.useEffect(()=>{if(!m)return;const R=M=>{var D,L,z;if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),b(!1);const F=(D=_.current)==null?void 0:D.querySelector("[aria-haspopup='menu']");F==null||F.focus();return}if(M.key!=="ArrowDown"&&M.key!=="ArrowUp"&&M.key!=="Home"&&M.key!=="End")return;const j=Array.from(((L=k.current)==null?void 0:L.querySelectorAll('[role="menuitem"]:not([disabled])'))??[]);if(j.length===0)return;M.preventDefault();const O=j.indexOf(document.activeElement);let P=O;M.key==="ArrowDown"?P=(O+1)%j.length:M.key==="ArrowUp"?P=(O-1+j.length)%j.length:M.key==="Home"?P=0:M.key==="End"&&(P=j.length-1),(z=j[P])==null||z.focus()};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[m,b]);const C=W.isValidElement(e)?W.cloneElement(e,{"aria-haspopup":"menu","aria-expanded":m,"aria-controls":m?T:void 0,onKeyDown:R=>{const M=e.props.onKeyDown;M==null||M(R),(R.key==="ArrowDown"||R.key==="Enter"||R.key===" ")&&(R.preventDefault(),b(!0))}}):e,A=m&&y!=null?di.createPortal(g.jsx("div",{ref:k,id:T,role:"menu",style:{top:y.top,left:y.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=>{iMe(R)||b(!1)}:void 0,children:t}),oN(_.current)):null;return g.jsxs("div",{ref:_,className:pe("relative inline-flex",a),children:[g.jsx("div",{className:"contents",onClick:()=>b(!m),children:C}),A]})}function bp({className:e,...t}){return g.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 H$t({className:e,...t}){return g.jsx("div",{role:"separator",className:pe("-mx-1 my-1 h-px bg-border",e),...t})}function _Z(e,t,n=!1){const[r,o]=w.useState();return w.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(),d=Math.min(c.height*.85,480);o({left:c.left,bottom:window.innerHeight-c.bottom,width:c.width,height:n?"fit-content":d,maxHeight:d})};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 V$t={sm:"md:w-80",md:"md:w-[28rem]",lg:"md:w-[36rem]",xl:"md:w-[42rem]"};function uN({open:e,onOpenChange:t,title:n,description:r,headerIcon:o,headerActions:a,children:i,footer:s,anchor:l="right",size:c="md",className:d,"aria-label":p}){const f=w.useRef(null),m=w.useId(),b=w.useId(),y=ld(),x=_Z(f,y);return w.useEffect(()=>{const _=f.current;_&&(e&&!_.open?_.showModal():!e&&_.open&&_.close())},[e]),w.useEffect(()=>{const _=f.current;if(!_)return;const k=()=>t(!1);return _.addEventListener("close",k),()=>_.removeEventListener("close",k)},[t]),g.jsxs("dialog",{ref:f,"aria-label":p??n,"aria-labelledby":m,"aria-describedby":r?b:void 0,closedby:"closerequest",onCancel:_=>{_.preventDefault(),_.stopPropagation(),t(!1)},style:x,"data-anchor":l,"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",V$t[c],l==="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:[g.jsxs("header",{className:"bg-topbar-bg flex shrink-0 items-center gap-3 border-b border-border px-5 py-4",children:[o,g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("h2",{id:m,className:"text-text-primary text-lg font-semibold tracking-tight",children:n}),r?g.jsx("p",{id:b,className:"text-text-secondary mt-1 text-sm",children:r}):null]}),a,g.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:Xt({variant:"ghost",size:"icon"}),onClick:()=>t(!1),children:g.jsx(xe,{name:"xmark"})})]}),g.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",children:i}),s?g.jsx("div",{className:"shrink-0 border-t border-border px-5 py-3",children:s}):null]})}function G$t(e){return`${e}-clone`}var W$t="No permission to create agents";function sMe({agentName:e,description:t,agentSpec:n,canMutate:r,canUse:o=!0,canManage:a=!0,canDelete:i=!0,canManageSchedules:s,onEdit:l,onManageSchedules:c,onDeleted:d}){const p=ui(),f=vo(),m=sN(),b=We("PermissionGuard"),y=We("SaveAgentForm"),{canCreateAgent:x,loading:_}=uye(),k=x&&!_,[E,T]=w.useState(!1),[C,A]=w.useState(!1),[R,M]=w.useState(""),[j,O]=w.useState(""),[P,D]=w.useState(null),[L,z]=w.useState(null),[F,$]=w.useState(!1),H=r&&n!=null,V=s&&c!=null;if(!(H||V||r))return null;const U=()=>{F||T(!1)},X=()=>{F||(A(!1),D(null),z(null))},J=()=>{n==null||!k||(M(G$t(e)),O((t==null?void 0:t.trim())||e),D(oMe(n)),z(null),A(!0))},K=async()=>{if(!k||p==null||P==null)return;const Q=R.trim(),ne=j.trim();if(!(!Q||!ne||!P.model.name.trim())){$(!0),z(null);try{await p.saveAgent({agentName:Q,description:ne,agentSpec:P,intent:"create"}),f==null||f.invalidateAgentsList(),m==null||m.showSuccess({title:"Agent cloned",description:`Created “${Q}”.`}),A(!1),D(null)}catch(de){z(aa(de,"Could not clone agent"))}finally{$(!1)}}},G=async()=>{if(!(!i||p==null||typeof p.deleteAgent!="function")){T(!1),$(!0);try{await p.deleteAgent({agentName:e}),f==null||f.invalidateAgentsList(),m==null||m.showSuccess({title:"Agent deleted",description:`“${e}” was deleted.`}),d==null||d()}catch(Q){m==null||m.showError(Q)}finally{$(!1)}}};return g.jsxs(g.Fragment,{children:[g.jsxs(of,{align:"end",className:"min-w-48",trigger:g.jsx("button",{type:"button",className:Xt({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${e}`,children:g.jsx(xe,{name:"ellipsis-vertical"})}),children:[H?g.jsx(b,{allowed:a,children:g.jsxs(bp,{className:"whitespace-nowrap",onClick:()=>{a&&l()},children:[g.jsx(xe,{name:"pencil",className:"size-3.5"}),"Edit"]})}):null,H?g.jsx(b,{allowed:k,deniedMessage:W$t,children:g.jsxs(bp,{className:"whitespace-nowrap",onClick:()=>{k&&J()},children:[g.jsx(xe,{name:"clone",className:"size-3.5"}),"Clone"]})}):null,V?g.jsx(b,{allowed:o,children:g.jsxs(bp,{className:"whitespace-nowrap",onClick:()=>{o&&(c==null||c())},children:[g.jsx(xe,{name:"calendar-clock",className:"size-3.5"}),"Manage Schedules"]})}):null,r?g.jsxs(g.Fragment,{children:[H||V?g.jsx(H$t,{}):null,g.jsx(b,{allowed:i,children:g.jsxs(bp,{className:"whitespace-nowrap text-failure-bg focus-visible:text-failure-bg",onClick:()=>{i&&T(!0)},children:[g.jsx(xe,{name:"trash",className:"size-3.5"}),"Delete"]})})]}):null]}),g.jsx(uN,{open:C,onOpenChange:Q=>!Q&&X(),title:"Clone Agent",anchor:"right",size:"md","aria-label":"Clone Agent",children:P!=null?g.jsx(y,{intent:"create",name:R,description:j,spec:P,saving:F,error:L,onNameChange:M,onDescriptionChange:O,onCancel:X,onSave:()=>void K()}):null}),E?g.jsxs(lN,{open:!0,onOpenChange:Q=>!Q&&U(),"aria-label":"Delete agent",className:"max-w-md",children:[g.jsx(cN,{children:g.jsxs(xZ,{children:[g.jsx(wZ,{children:"Delete agent"}),g.jsxs("p",{className:"text-text-secondary text-sm",children:["“",e,"” will be permanently deleted, including any schedules for this agent. This cannot be undone."]})]})}),g.jsxs(aMe,{children:[g.jsx(In.Secondary,{type:"button",disabled:F,onClick:U,children:"Cancel"}),g.jsx(In.Destructive,{type:"button",disabled:F||!i||p==null||typeof p.deleteAgent!="function",onClick:()=>void G(),children:"Delete"})]})]}):null]})}function K$t({agentId:e,detail:t,onBack:n}){const r=ng(),o=ui(),{allows:a}=G1({resourceType:"agent",resourceIds:[e]}),i=r.isComposerEnabled&&t!=null&&o!=null,s=a(e,"USE"),l=a(e,"MANAGE"),c=a(e,"DELETE"),d=We("PermissionGuard"),p=()=>{!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 g.jsx(k7,{className:"bg-primary-bg",start:g.jsx("button",{type:"button","aria-label":"Back to Agents",title:"Back to Agents",className:Xt({variant:"ghost",size:"icon"}),onClick:n,children:g.jsx(xe,{name:"arrow-left"})}),title:g.jsxs("div",{className:pe("flex min-w-0 items-center gap-1",_ye),children:[g.jsx("button",{type:"button",className:"cursor-pointer truncate hover:text-text-primary",onClick:n,children:"Agents"}),g.jsx(xe,{name:"chevron-right",className:"size-3 shrink-0"}),g.jsx("span",{className:"truncate",children:(t==null?void 0:t.name)??e})]}),end:g.jsxs(g.Fragment,{children:[g.jsx(d,{allowed:s,children:g.jsxs(In.Primary,{type:"button","aria-label":"Try agent",size:"large",disabled:t==null,onClick:p,children:[g.jsx(xe,{name:"play",className:"size-3.5"}),"Try"]})}),t!=null?g.jsx(sMe,{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 Y$t(e){return window.addEventListener("popstate",e),window.addEventListener(UL,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(UL,e)}}function Z$t(){return window.location.search}function X$t(){return""}function dN(){const e=w.useSyncExternalStore(Y$t,Z$t,X$t),t=w.useCallback(n=>{BL(n)},[]);return{...Mu(e),updateShareSearch:t}}function bT({title:e,description:t,className:n}){return g.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:[g.jsx(xe,{name:"empty",size:48,className:"shrink-0","aria-hidden":!0}),g.jsxs("div",{className:"flex max-w-md flex-col items-center gap-1.5 text-center",children:[g.jsx("h2",{className:"text-base font-semibold text-text-primary",children:e}),t!=null?g.jsx("p",{className:"text-sm text-text-secondary",children:t}):null]})]})}function kge({children:e}){return g.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 Ege(){return g.jsx(bT,{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 ti({className:e,...t}){return g.jsx("div",{className:pe("animate-pulse rounded-md bg-secondary-bg",e),...t})}function q$t({agentId:e}){const t=Vv(),n=O$e(),r=OC(),o=ng(),a=Gv(),i=dN(),s=Zs(),{updateShareSearch:l}=i,c=L$e(i,e),d=z$e({metrics:n}),p=o1({schedules:r}),f=c==="metrics"&&!d||c==="schedules"&&!p?"overview":c,m=We("AgentDetailsHeader"),b=We("AgentDetailsTabs"),y=We("AgentDetailsUnavailable"),x=We("AgentOverview"),_=We("AgentSessions"),k=We("SchedulesPage"),E=We("AgentMetrics"),T=We("AgentMetricsTimeRangeFilter"),C=We("AgentCodeSnippets"),[A,R]=w.useState(),[M,j]=w.useState(!1),[O,P]=w.useState(),[D,L]=w.useState(!1),[z,F]=w.useState(dye),$=w.useCallback(()=>{l({sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),o.closeLibraryAgent()},[o,l]);w.useEffect(()=>{s(Io.AgentDetails.OPENED,{agent_id:e})},[]),w.useEffect(()=>{const V=Y=>{Y.key==="Escape"&&(kye()||(Y.stopImmediatePropagation(),$()))};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[$]),w.useEffect(()=>{if(t==null)return;let V=!1;return t.getAgent({agentId:e}).then(Y=>{V||R(Y)},()=>{V||j(!0)}),()=>{V=!0}},[e,t]),w.useEffect(()=>{if(f!=="code"||t==null||O!==void 0||D)return;let V=!1;return t.getCodeSnippets({agentId:e}).then(Y=>{V||P(Y)},()=>{V||L(!0)}),()=>{V=!0}},[f,e,t,O,D]);let H;return t==null?H=g.jsx(y,{onBack:$,reason:"This host does not provide agent details. Return to the library to choose an agent."}):M?H=g.jsx(y,{onBack:$}):A==null?H=g.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:[g.jsx(ti,{className:"min-h-80 rounded-lg"}),g.jsx("div",{className:"space-y-3",children:["mcp","skills","model","execution"].map(V=>g.jsx(ti,{className:"h-24 rounded-lg"},V))})]}):f==="overview"?H=g.jsx(x,{detail:A}):f==="sessions"?H=a?g.jsx(Ege,{}):g.jsx(_,{agentId:e}):f==="schedules"?H=a?g.jsx(Ege,{}):g.jsx(k,{agentId:e}):f==="metrics"?H=g.jsx(E,{agentId:e,timeRange:z,onTimeRangeChange:F,showTimeRangeFilter:!1}):D?H=g.jsx(y,{onBack:$,reason:"Code samples for this agent could not be loaded."}):O===void 0?H=g.jsxs("div",{className:"flex min-h-64 gap-3 p-3",role:"status","aria-label":"Loading code samples",children:[g.jsx(ti,{className:"hidden w-44 shrink-0 rounded-lg md:block"}),g.jsx(ti,{className:"min-h-64 min-w-0 flex-1 rounded-lg"})]}):H=g.jsx(C,{snippets:O}),g.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[g.jsx(m,{agentId:e,detail:A,onBack:$}),t!=null&&!M?g.jsx(b,{activeTab:f,showMetrics:d,showSchedules:p,end:f==="metrics"?g.jsx(T,{timeRange:z,onTimeRangeChange:F}):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,g.jsx("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",role:"tabpanel",children:g.jsx(w.Suspense,{fallback:g.jsx("div",{className:"p-4",role:"status","aria-label":"Loading",children:g.jsx(ti,{className:"min-h-64 rounded-lg"})}),children:H})})]})}var Q$t=[{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 J$t({activeTab:e,onTabChange:t,showMetrics:n=!1,showSchedules:r=!1,end:o}){return g.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-primary-bg px-3",children:[g.jsx("div",{role:"tablist","aria-label":"Agent details",className:"flex min-w-0 flex-1 gap-1 overflow-x-auto",children:Q$t.filter(a=>(a.id!=="metrics"||n)&&(a.id!=="schedules"||r)).map(a=>g.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:[g.jsx(xe,{name:a.icon,className:"size-3.5"}),a.label]},a.id))}),o!=null?g.jsx("div",{className:"ml-auto shrink-0 pl-2",children:o}):null]})}function e7t({onBack:e,reason:t}){return g.jsxs("div",{className:"flex h-full min-h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[g.jsx("span",{className:"flex size-11 items-center justify-center rounded-full bg-secondary-bg text-text-secondary",children:g.jsx(xe,{name:"circle-exclamation"})}),g.jsxs("div",{children:[g.jsx("h2",{className:"text-base font-semibold text-text-primary",children:"Agent details unavailable"}),g.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."})]}),g.jsxs(In.Secondary,{type:"button",size:"small",onClick:e,children:[g.jsx(xe,{name:"arrow-left",className:"size-3.5"}),"Back to Agents"]})]})}function wl(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function W1(e){return`$${e.toFixed(4)}`}function lMe(e){return e<6e4?`${(e/1e3).toFixed(2)}s`:e<36e5?`${(e/6e4).toFixed(2)}m`:`${(e/36e5).toFixed(2)}h`}function t7t(e){return Math.max(0,Math.round(e/1e3)*1e3)}function cMe(e){const t=t7t(e)/1e3,n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=t%60;return[...n>0?[`${n}h`]:[],...r>0?[`${r}m`]:[],...o>0||t===0?[`${o}s`]:[]].join(" ")}function n7t(e){return[`${e.totalTurns} turns`,...e.totalCostInUsd==null?[]:[W1(e.totalCostInUsd)],cMe(e.totalDurationMs)].join(" | ")}var r7t=new Intl.NumberFormat(void 0,{maximumFractionDigits:4});function o7t(e,t){return t==="$"?W1(e):t==="ms"?lMe(e):`${r7t.format(e)}${t==="count"||t.length===0?"":` ${t}`}`}function a7t({meter:e}){const t=e.unit==="$";return g.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:[g.jsxs("div",{className:"flex w-full min-w-0 items-start justify-between gap-3",children:[g.jsx("h3",{className:"truncate text-sm font-medium text-text-secondary",title:e.description,children:e.description}),g.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:g.jsx(xe,{name:t?"dollar-sign":"message-square-text",className:"size-6"})})]}),g.jsx("p",{className:"text-4xl font-bold tabular-nums text-text-primary",children:o7t(e.aggregateValue,e.unit)})]})}function i7t({timeRange:e,onTimeRangeChange:t}){const n=We("AgentSessionsFilters");return g.jsx(n,{agentId:null,timeRange:e,onAgentChange:()=>{},onTimeRangeChange:t,showAgentFilter:!1,showCustomTimeRange:!1})}var s7t=["total_cost_in_usd","cost_per_session_in_usd","total_sessions","avg_turns_per_session"],l7t=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"]),c7t=new Intl.NumberFormat(void 0,{maximumFractionDigits:3});function u7t({meter:e,durationInSeconds:t}){return e==null?"—":c7t.format(t?e.aggregateValue/1e3:e.aggregateValue)}function d7t({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 g.jsx("div",{className:"grid gap-4 lg:grid-cols-2","data-slot":"agent-metric-statistics",children:n.map(r=>g.jsx("section",{"aria-label":r.ariaLabel,className:"min-w-0 rounded-xl border border-border bg-card-bg p-4 shadow-sm",children:g.jsx("dl",{className:`grid ${r.gridClassName} divide-x divide-border`,children:r.items.map(o=>{const a=u7t({meter:o.meter,durationInSeconds:r.durationInSeconds});return g.jsxs("div",{className:`min-w-0 px-3 first:pl-0 last:pr-0 ${o.prominent?"":"text-center"}`,children:[g.jsx("dt",{className:"truncate text-sm font-medium text-text-secondary",children:o.label}),g.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 p7t({meters:e,meterError:t,charts:n,chartsLoading:r,chartsError:o,timeRange:a,onTimeRangeChange:i,showTimeRangeFilter:s=!0}){const l=We("AgentMetricCard"),c=We("AgentMetricChart"),d=We("AgentMetricStatistics"),p=We("AgentMetricsTimeRangeFilter"),f=e==null?void 0:s7t.flatMap(b=>{const y=e.find(x=>x.name===b);return y==null?[]:[y]}),m=(e==null?void 0:e.some(b=>l7t.has(b.name)))??!1;return g.jsxs("div",{className:"min-h-0 flex-1 overflow-auto bg-secondary-bg/40 p-4","data-slot":"agent-metrics-view",children:[s?g.jsx("div",{className:"mb-4 flex justify-end",children:g.jsx(p,{timeRange:a,onTimeRangeChange:i})}):null,t!=null?g.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?g.jsxs("div",{className:"mb-4 grid gap-4","aria-label":"Loading metrics",children:[g.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:Array.from({length:4},(b,y)=>g.jsx(ti,{className:"h-20 rounded-lg"},y))}),g.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:Array.from({length:2},(b,y)=>g.jsx(ti,{className:"h-20 rounded-lg"},y))})]}):(f==null?void 0:f.length)===0&&!m?g.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"}):g.jsxs("div",{className:"mb-3 grid gap-3",children:[f!=null&&f.length>0?g.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:f.map(b=>g.jsx(l,{meter:b},b.name))}):null,m?g.jsx(d,{meters:e}):null]}),o!=null?g.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?g.jsx("div",{className:"grid gap-4 lg:grid-cols-2","aria-label":"Loading metric charts",children:Array.from({length:2},(b,y)=>g.jsx(ti,{className:"h-80 rounded-lg"},y))}):n.length===0?g.jsx("div",{className:"rounded-lg border border-border bg-card-bg p-6 text-center text-sm text-text-secondary",children:"No charts available"}):g.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:n.flatMap(b=>b.graphs!=null&&b.graphs.length>0?b.graphs.map(y=>({definition:b.definition,graph:y,error:b.error})):[{definition:b.definition,error:b.error}]).map(({definition:b,graph:y,error:x},_)=>g.jsx(c,{definition:b,error:x,colorIndex:_,...y==null?{}:{graph:y}},y==null?b.name:`${b.name}:${y.name}`))})]})}function f7t({title:e,icon:t,count:n,children:r}){return g.jsxs("section",{className:"rounded-lg border border-border bg-card-bg p-3 text-text-primary",children:[g.jsxs("h2",{className:"mb-2 flex items-center gap-1.5 text-xs font-semibold",children:[t?g.jsx(xe,{name:t,className:"size-3.5 text-text-secondary"}):null,e,n!==void 0?g.jsxs("span",{className:"text-text-secondary",children:["(",n,")"]}):null]}),r]})}function Tge({disabled:e}){return g.jsxs("button",{type:"button",disabled:e,className:Xt({variant:"secondary",size:"large"}),children:[g.jsx(xe,{name:"share"}),"Share"]})}function h7t({title:e,sessionId:t,onClose:n,metadata:r,resumeHref:o,onResume:a,resumeLabel:i,canResume:s=!0,canShare:l=!0}){const c=We("PermissionGuard"),d=We("ShareSessionDialog"),p=r!=null&&Object.keys(r).length>0;return g.jsxs("div",{className:"flex shrink-0 flex-col border-b border-border",children:[g.jsxs("div",{className:"flex shrink-0 items-center gap-3 p-3",children:[g.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 pb-0.5",children:[g.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold leading-none text-text-primary",children:e}),g.jsx("code",{className:"min-w-0 truncate font-mono text-xs leading-none text-text-secondary",children:t})]}),l?g.jsx(d,{sessionId:t,trigger:g.jsx(Tge,{})}):g.jsx(c,{allowed:!1,children:g.jsx(Tge,{})}),i!=null&&o!=null&&s?g.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:Xt({variant:"secondary",size:"large"}),children:[i,g.jsx(xe,{name:"square-arrow-out-up-right",className:"shrink-0"})]}):i!=null&&o!=null?g.jsx(c,{allowed:!1,children:g.jsxs(In.Secondary,{type:"button",size:"large",children:[i,g.jsx(xe,{name:"square-arrow-out-up-right",className:"shrink-0"})]})}):i!=null&&a!=null?g.jsx(c,{allowed:s,children:g.jsx(In.Secondary,{type:"button",size:"large",onClick:()=>{s&&a()},children:i})}):null,g.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:g.jsx(xe,{name:"xmark",className:"size-4"})})]}),p?g.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,m])=>g.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:[g.jsx(xe,{name:"tag",className:"size-3 shrink-0 text-text-secondary"}),g.jsx("span",{className:"shrink-0 font-mono text-text-secondary",children:f}),g.jsx("span",{className:"truncate font-mono font-medium text-text-primary",title:m,children:m})]},f))}):null]})}function uMe(e){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}).format(e)}function $nn(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 Fnn=50;function dMe(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 Unn({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 g7t(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 m7t(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 Bnn(e){return m7t(e)??g7t(e)==null}function Hnn({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 b7t({title:e,agentName:t,sourceType:n,lastActivityAt:r,metrics:o,active:a,onSelect:i,onRequestDelete:s,canDelete:l=!0}){const c=We("PermissionGuard"),d=new Date(r),p=dMe(d),f=uMe(d);return g.jsxs("div",{"data-active":a||void 0,className:pe("group flex w-full flex-col border-b border-border transition-colors",a?"bg-dropdown-selected-item-bg":"hover:bg-ghost-button-hover"),children:[g.jsxs("div",{className:"flex items-center gap-2 px-4 pt-3",children:[g.jsxs("button",{type:"button",onClick:i,className:"flex min-w-0 flex-1 items-center gap-1 text-left",children:[g.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:e}),n==="schedule"?g.jsx(eo,{content:"Scheduled Session",children:g.jsx("span",{"aria-label":"Scheduled run",className:"inline-flex shrink-0",children:g.jsx(xe,{name:"calendar",className:"size-3.5 text-primary-button-bg"})})}):null]}),s!=null?g.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:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),children:g.jsx(of,{align:"end",className:"min-w-40",trigger:g.jsx("button",{type:"button",className:Xt({variant:"ghost",size:"icon",className:"size-7"}),"aria-label":`Actions for ${e}`,children:g.jsx(xe,{name:"ellipsis"})}),children:g.jsx(c,{allowed:l,children:g.jsxs(bp,{className:"whitespace-nowrap text-failure-bg focus-visible:text-failure-bg",onClick:()=>{l&&s()},children:[g.jsx(xe,{name:"trash",className:"size-3.5"}),"Delete"]})})})}):null]}),g.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-end justify-between gap-2 px-4 pt-2 pb-3 text-left text-xs text-text-secondary",children:[g.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[t!=null?g.jsxs(g.Fragment,{children:[g.jsx(xe,{name:"agent-2",className:"size-3 shrink-0"}),g.jsx("span",{className:"truncate",children:t}),g.jsx("span",{"aria-hidden":"true",children:"·"})]}):null,g.jsx(eo,{content:f,side:"bottom",children:g.jsx("span",{children:p})})]}),g.jsx("span",{className:"shrink-0 tabular-nums",children:n7t(o)})]})]})}var Ih="main",pMe=[{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:"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"}],Vnn=new Set(["system","user","error"]),v7t={user:"User Message",model:"Model Response"};function y7t(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`:`${Number((e/36e5).toPrecision(3))}h`}function hl(e,t=!1){const n=pMe.find(r=>r.id===e);return(t?n==null?void 0:n.darkColor:void 0)??(n==null?void 0:n.color)??"#94a3b8"}function Gnn(e,t=!1){const n=hl(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 x7t(e){var t;return((t=pMe.find(n=>n.id===e))==null?void 0:t.label)??e}function Wnn(e){return v7t[e]??x7t(e)}function w7t({data:e}){const t=Math.max(0,...e.map(n=>n.value))||1;return g.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=>g.jsxs("div",{className:"contents",children:[g.jsx("span",{className:"max-w-28 truncate text-text-secondary",children:n.label}),g.jsx("div",{className:"h-1.5 min-w-0 overflow-hidden rounded-full bg-secondary-bg",children:g.jsx("div",{className:"h-full rounded-full",style:{width:`${n.value/t*100}%`,backgroundColor:n.color}})}),g.jsx("span",{className:"text-right font-semibold text-text-primary",children:W1(n.value)})]},n.label))})}function ax({title:e,children:t,fitWidth:n=!1}){return g.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:[g.jsx("div",{className:"mb-3 text-xs font-medium capitalize tracking-wider text-text-secondary",children:e}),t]})}function Age({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:g.jsxs("div",{children:[g.jsx("div",{className:"mb-3 flex h-3 w-full overflow-hidden rounded-full bg-secondary-bg",children:n.map(o=>g.jsx("span",{className:"h-full",style:{width:`${o.value/r*100}%`,backgroundColor:o.color}},o.label))}),g.jsx("div",{className:"space-y-2",children:n.map(o=>g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"size-2 shrink-0 rounded-sm",style:{backgroundColor:o.color}}),g.jsx("span",{className:"min-w-0 flex-1 truncate text-text-secondary",children:o.label}),g.jsx("span",{className:"font-semibold text-text-primary",children:t(o.value)})]},o.label))})]})}function Cge({data:e,formatValue:t}){const n=Math.max(0,...e.map(r=>r.value))||1;return g.jsx("div",{className:"grid grid-cols-[max-content_minmax(0,1fr)_max-content] items-center gap-x-2 gap-y-2",children:e.map(r=>g.jsxs("div",{className:"contents",children:[g.jsx("span",{className:"max-w-28 truncate text-text-secondary",children:r.label}),g.jsx("div",{className:"h-1.5 min-w-0 overflow-hidden rounded-full bg-secondary-bg",children:g.jsx("div",{className:"h-full rounded-full",style:{width:`${r.value/n*100}%`,backgroundColor:r.color}})}),g.jsx("span",{className:"text-right font-semibold text-text-primary",children:t(r.value)})]},r.label))})}var _7t="Some turns in this session were edited or retried. Showing only the latest lineage of the session";function Vf({id:e,label:t,value:n,tooltip:r}){const o=g.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:[g.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?g.jsx(xe,{name:"info",className:"size-2.5 text-text-secondary"}):null]}),g.jsx("div",{className:"pt-1 text-base font-medium leading-none text-text-primary",children:n})]});return r==null?o:g.jsx(aN,{title:r,side:"bottom",triggerClassName:"block w-full",children:o})}function S7t({lineageTurns:e,sessionTotalTurns:t}){const n=t!=null&&t>e,r=e>1||t!=null&&t>1?"Turns":"Turn",o=n?g.jsxs("span",{className:"inline-flex h-4 items-center gap-2",children:[g.jsxs("span",{className:"leading-none",children:[g.jsxs("span",{className:"text-primary-button-bg",children:[e," "]}),g.jsxs("span",{className:"text-text-primary",children:["/ ",t]})]}),g.jsx(xe,{name:"circle-exclamation",size:16,className:"size-4 shrink-0 text-warning-bg","data-testid":"icon-circle-exclamation"})]}):e,a=g.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:[g.jsx("div",{className:"mb-0.5 flex items-center gap-1 text-[0.625rem] font-medium uppercase tracking-wider text-text-secondary",children:r}),g.jsx("div",{className:"flex items-center pt-1 text-base font-medium leading-none text-text-primary",children:o})]});return n?g.jsx(aN,{title:_7t,side:"bottom",triggerClassName:"block w-full",className:"max-w-56 whitespace-normal",children:a}):a}function k7t({metrics:e}){return g.jsx("div",{className:"@container overflow-hidden border-b border-border","data-slot":"agent-session-metrics-strip",children:g.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:[g.jsx(S7t,{lineageTurns:e.totalTurns,sessionTotalTurns:e.sessionTotalTurns}),g.jsx(Vf,{id:"wall-time",label:"Duration",value:cMe(e.wallTimeMs),tooltip:g.jsx(ax,{title:"Where the time went",children:g.jsx(Age,{data:e.timeBreakdown,formatValue:y7t})})}),e.totalCostUsd!=null?g.jsx(Vf,{id:"cost",label:"Cost",value:W1(e.totalCostUsd),tooltip:e.costPerTurn.length>1&&e.totalCostUsd>0?g.jsx(ax,{title:"Cost per turn",children:g.jsx(w7t,{data:e.costPerTurn})}):null}):null,g.jsx(Vf,{id:"tokens",label:"Tokens",value:wl(e.totalTokens),tooltip:e.totalTokens>0?g.jsx(ax,{title:"Tokens",children:g.jsx(Age,{data:e.tokenBreakdown,formatValue:wl})}):null}),g.jsx(Vf,{id:"context",label:"Context",value:wl(e.contextTokens),tooltip:e.contextByTurn.length>1&&e.contextTokens>0?g.jsx(ax,{title:"Context length at end of turn",children:g.jsx(Cge,{data:e.contextByTurn,formatValue:wl})}):null}),g.jsx(Vf,{id:"tool-calls",label:"Tool calls",value:e.toolCalls,tooltip:e.toolCalls>1?g.jsx(ax,{title:"Tool call frequency",children:g.jsx(Cge,{data:e.toolCallFrequency,formatValue:String})}):null}),g.jsx(Vf,{id:"sub-agents",label:"Sub-agents",value:e.subAgents}),g.jsx(Vf,{id:"errors",label:"Errors",value:e.errors})]})})}var fMe=[{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 E7t(e){var t;return((t=fMe.find(n=>n.windowMs===e))==null?void 0:t.label)??null}function T7t(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 SE(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 Rge(e){const t=new Date(e).getTime();return Number.isNaN(t)?null:t}var A7t="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 Bo(e){return pe(A7t,e)}function pN(e){return Bo(pe("flex h-8 cursor-pointer items-center justify-between gap-2 pr-2 text-left",e))}function hMe(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 SZ(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 Nv(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 C7t(e,t){const[n,r]=w.useState(e);return w.useEffect(()=>{const o=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(o)},[e,t]),n}var H_=50,R7t=100,I7t=300,N7t="48px";function C6(e){return Math.min(Math.max(e,1),R7t)}async function M7t({server:e,agentName:t,pageToken:n}){const r=await e.searchAgents({query:t,limit:H_,...n===void 0||n===""?{}:{pageToken:n}}),o=r.data.find(a=>a.name===t);return o!=null||r.nextPageToken==null||r.nextPageToken===""?o:M7t({server:e,agentName:t,pageToken:r.nextPageToken})}async function gMe({server:e,agentKey:t,pageToken:n}){const r=await e.searchAgents({limit:H_,...n===void 0||n===""?{}:{pageToken:n}}),o=r.data.find(a=>a.name===t||a.agentId===t);return o!=null||r.nextPageToken==null||r.nextPageToken===""?o:gMe({server:e,agentKey:t,pageToken:r.nextPageToken})}function mMe({enabled:e,query:t,refreshKey:n=0,limit:r=H_,debounceMs:o=I7t,mode:a="infinite"}){const i=ui(),s=C7t(t,e?o:0),[l,c]=w.useState([]),[d,p]=w.useState(!1),[f,m]=w.useState(!1),[b,y]=w.useState(null),[x,_]=w.useState(!1),[k,E]=w.useState(()=>C6(r)),[T,C]=w.useState(void 0),[A,R]=w.useState(void 0),[M,j]=w.useState(void 0),O=w.useRef(0),P=w.useRef(!1),D=w.useRef(!1),L=w.useRef(void 0),z=w.useRef(null),F=w.useRef(null),[$,H]=w.useState(null),[V,Y]=w.useState(null),U=a==="paged"?k:C6(r);D.current=x,L.current=A;const X=w.useCallback(se=>{z.current=se,H(se)},[]),J=w.useCallback(se=>{F.current=se,Y(se)},[]),K=s.trim()||void 0;w.useEffect(()=>{a==="paged"&&C(void 0)},[a,K,n]),w.useEffect(()=>{if(!e||i==null)return;const se=++O.current;P.current=!1,p(!0),y(null);const oe=a==="paged"?T:void 0;return i.searchAgents({query:K,limit:U,...oe===void 0||oe===""?{}:{pageToken:oe}}).then(re=>{se===O.current&&(c(re.data),R(re.nextPageToken),j(re.previousPageToken),_(re.nextPageToken!=null&&re.nextPageToken!==""))}).catch(re=>{se===O.current&&(c([]),R(void 0),j(void 0),_(!1),y(aa(re,"Check your connection and try again.")))}).finally(()=>{se===O.current&&p(!1)}),()=>{O.current+=1}},[e,i,K,U,n,a,T]);const G=w.useCallback(()=>{if(a!=="infinite")return;const se=L.current;if(!e||i==null||!D.current||se==null||se===""||P.current||d)return;const oe=O.current;P.current=!0,m(!0),i.searchAgents({query:K,limit:U,pageToken:se}).then(re=>{oe===O.current&&(c(q=>[...q,...re.data]),R(re.nextPageToken),_(re.nextPageToken!=null&&re.nextPageToken!==""))}).catch(()=>{oe===O.current&&_(!1)}).finally(()=>{P.current=!1,oe===O.current&&m(!1)})},[e,i,K,U,d,a]);w.useEffect(()=>{if(a!=="infinite"||!e||!x||$==null||V==null)return;const se=new IntersectionObserver(oe=>{oe.some(re=>re.isIntersecting)&&G()},{root:$,rootMargin:N7t});return se.observe(V),()=>se.disconnect()},[a,e,x,$,V,G,l.length]);const Q=w.useCallback(se=>{E(C6(se)),C(void 0)},[]),ne=w.useCallback(()=>{if(a!=="paged"||d)return;const se=L.current;se==null||se===""||C(se)},[a,d]),de=w.useCallback(()=>{a!=="paged"||d||C(M===void 0||M===""?void 0:M)},[a,d,M]);return{agents:l,isInitialLoading:d&&l.length===0,isSearching:d&&l.length>0,loadingMore:f,error:b,hasMore:x,listRef:X,sentinelRef:J,pageSize:k,setPageSize:Q,canPrev:a==="paged"&&M!=null&&M!=="",canNext:a==="paged"&&A!=null&&A!=="",goPrev:de,goNext:ne}}function O7t({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:d}){const[p,f]=w.useState(!1),[m,b]=w.useState(""),[y,x]=w.useState(null),_=w.useRef(null),k=w.useRef(null),E=w.useRef(null),T=w.useRef(null),C=w.useId(),{agents:A,isInitialLoading:R,isSearching:M,loadingMore:j,hasMore:O,error:P,listRef:D,sentinelRef:L}=mMe({enabled:p&&!o,query:m});w.useEffect(()=>{p||b("")},[p]),w.useLayoutEffect(()=>{if(!p){x(null);return}const G=()=>{const Q=k.current;if(!Q)return;const ne=Q.getBoundingClientRect();x({top:ne.bottom+4,left:ne.left,width:ne.width})};return G(),window.addEventListener("scroll",G,!0),window.addEventListener("resize",G),()=>{window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G)}},[p]),w.useEffect(()=>{if(!p)return;const G=Q=>{var ne,de;Q.target instanceof Node&&((ne=_.current)!=null&&ne.contains(Q.target)||(de=T.current)!=null&&de.contains(Q.target)||f(!1))};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[p]);const z=()=>{var G;f(!1),b(""),(G=E.current)==null||G.blur()},F=G=>{const Q=dc(G);n(Q),r==null||r(G),z()},$=()=>{i!=null&&(n(i.value),z())},H=p?m:t,V=m.trim(),Y=!R&&P!=null,U=!R&&P==null&&A.length===0&&V==="",X=!R&&P==null&&A.length===0&&V!=="",J=p&&y!=null&&!o?di.createPortal(g.jsxs("div",{ref:T,className:SZ("fixed z-[200] flex max-h-64 flex-col overflow-hidden"),style:{top:y.top,left:y.left,width:y.width},onMouseDown:G=>G.stopPropagation(),children:[g.jsxs("div",{ref:D,id:C,role:"listbox","aria-label":l,className:"min-h-0 flex-1 overflow-y-auto p-1",children:[i!=null&&V===""?g.jsxs("button",{type:"button",role:"option","aria-selected":e===i.value,className:Nv(),onClick:$,children:[g.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label}),g.jsx(xe,{name:"check",className:pe("ml-auto size-4 shrink-0",e===i.value?"opacity-100":"opacity-0")})]}):null,R?g.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:"Loading…"}):Y?g.jsx("p",{className:"text-failure-bg px-3 py-5 text-center text-sm",role:"alert",children:P}):U?g.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",children:"No Agents created yet"}):X?g.jsxs("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:['No agents match "',V,'".']}):g.jsxs(g.Fragment,{children:[M?g.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null,A.map(G=>{const Q=dc(G),ne=e===Q;return g.jsxs("button",{type:"button",role:"option","aria-selected":ne,className:Nv(),onClick:()=>F(G),children:[g.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.name}),g.jsx(xe,{name:"check",className:pe("ml-auto size-4 shrink-0",ne?"opacity-100":"opacity-0")})]},Q)}),O?g.jsx("div",{ref:L,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:j?g.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]}),U&&a!=null?g.jsx("div",{className:"flex justify-end border-t border-border px-2 pt-2",children:g.jsxs(In.Ghost,{type:"button",onClick:a,children:[g.jsx(xe,{name:"plus",className:"size-3.5"}),"Build Agent"]})}):null]}),oN(_.current)):null,K=g.jsx("input",{ref:E,type:"text",role:"combobox","aria-label":l,"aria-expanded":p,"aria-controls":p?C:void 0,"aria-autocomplete":"list",disabled:o,placeholder:c,value:H,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:G=>{o||(b(G.target.value),f(!0))},onKeyDown:G=>{var Q;if(G.key==="Escape"){G.preventDefault(),f(!1),(Q=E.current)==null||Q.blur();return}G.key==="ArrowDown"&&!p&&!o&&(G.preventDefault(),f(!0))}});return g.jsxs("div",{ref:_,className:pe("relative",d),children:[g.jsxs("div",{ref:k,className:s==null?pN(o?"cursor-not-allowed opacity-50":"cursor-text"):hMe(pe("w-fit min-w-full",o?"cursor-not-allowed opacity-50":"cursor-text")),onClick:()=>{var G;o||(G=E.current)==null||G.focus()},children:[s==null?null:g.jsx("span",{className:"text-text-primary shrink-0 border-r border-border px-3 font-semibold",children:s}),s==null?K:g.jsxs("div",{className:"relative mx-2 max-w-48 min-w-24 flex-none overflow-hidden px-2 py-0.5 text-sm",children:[g.jsx("span",{"aria-hidden":!0,className:"invisible block truncate whitespace-pre",children:t||c}),K]}),g.jsx(xe,{name:"chevron-down",className:pe("size-4 shrink-0 text-text-secondary",s==null?null:"mr-2")})]}),J]})}function j7t({agentId:e,timeRange:t,onAgentChange:n,onTimeRangeChange:r,showAgentFilter:o=!0,showCustomTimeRange:a=!0,onReload:i,isReloading:s=!1}){const l=ui(),[c,d]=w.useState({}),[p,f]=w.useState(!1),[m,b]=w.useState(!1),[y,x]=w.useState(()=>SE(t.startTs)),[_,k]=w.useState(()=>SE(t.endTs)),E=w.useRef(null),T=e==null?void 0:c[e];w.useEffect(()=>{if(l==null||e==null||T!=null)return;let R=!1;return gMe({server:l,agentKey:e}).then(M=>{R||M==null||d(j=>({...j,[e]:M.name}))},()=>{}),()=>{R=!0}},[e,T,l]),w.useEffect(()=>{x(SE(t.startTs)),k(SE(t.endTs))},[t.endTs,t.startTs]),w.useEffect(()=>{if(!p)return;const R=j=>{var O;((O=E.current)==null?void 0:O.contains(j.target))!==!0&&(f(!1),b(!1))},M=j=>{j.key==="Escape"&&(f(!1),b(!1))};return document.addEventListener("pointerdown",R),document.addEventListener("keydown",M),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("keydown",M)}},[p]);const C=t.timeWindowMs!=null?E7t(t.timeWindowMs)??"Custom Time Range":"Custom Time Range",A=()=>{const R=Rge(y),M=Rge(_);if(R==null||M==null||R>=M)return;const j=Date.now()-Cte*24*60*60*1e3,O=Math.max(R,j);O>=M||(r({startTs:O,endTs:M}),f(!1),b(!1))};return g.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i!=null?g.jsx(In.Secondary,{type:"button",size:"icon","aria-label":"Reload sessions",title:"Reload sessions",disabled:s,onClick:i,children:g.jsx(xe,{name:"refresh-cw",className:pe("size-3.5",s&&"animate-spin")})}):null,o?g.jsx(O7t,{"aria-label":"Filter sessions by agent",prefix:"Agents",className:"min-w-40",value:e??"",selectedLabel:e==null?"All":T??e,allOption:{value:"",label:"All"},onValueChange:R=>n(R.length===0?null:R),onAgentPicked:R=>{d(M=>({...M,[dc(R)]:R.name}))}}):null,g.jsxs("div",{className:"relative",ref:E,children:[g.jsxs("button",{type:"button","aria-expanded":p,"aria-haspopup":"listbox",className:pN("min-w-36"),onClick:()=>{f(R=>(R&&b(!1),!R))},children:[g.jsx("span",{className:"truncate",children:C}),g.jsx(xe,{name:"chevron-down",className:"size-4 shrink-0"})]}),p?g.jsxs("div",{className:SZ("absolute top-full right-0 mt-1 flex max-h-none overflow-y-visible p-0"),children:[m?g.jsxs("div",{className:"flex w-64 min-w-0 flex-col gap-2 border-r border-border p-3",children:[g.jsx("div",{className:"text-sm font-medium text-text-primary",children:"Select Time Range"}),g.jsx("p",{className:"text-xs text-text-secondary",children:`You can select time for last ${String(Cte)} days`}),g.jsxs("label",{className:"flex flex-col gap-1 text-xs text-text-secondary",children:["From",g.jsx("input",{type:"datetime-local",step:"1",className:Bo("h-8"),value:y,onChange:R=>x(R.target.value)})]}),g.jsxs("label",{className:"flex flex-col gap-1 text-xs text-text-secondary",children:["To",g.jsx("input",{type:"datetime-local",step:"1",className:Bo("h-8"),value:_,onChange:R=>k(R.target.value)})]}),g.jsxs("p",{className:"text-xs text-text-secondary",children:["Timezone: ",g.jsx("span",{className:"font-medium text-text-primary",children:T7t()})]}),g.jsx(In.Primary,{type:"button",className:"mt-auto",onClick:A,children:"Apply"})]}):null,g.jsxs("div",{className:"flex max-h-80 w-44 shrink-0 flex-col overflow-y-auto p-1",role:"listbox",children:[a?g.jsxs("button",{type:"button",role:"option","aria-selected":t.timeWindowMs==null,className:Nv(),onClick:()=>b(!0),children:[g.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Custom Time Range"}),g.jsx(xe,{name:"check",className:pe("ml-auto size-4 shrink-0",t.timeWindowMs==null?"opacity-100":"opacity-0")})]}):null,fMe.map(R=>{const M=t.timeWindowMs===R.windowMs;return g.jsxs("button",{type:"button",role:"option","aria-selected":M,className:Nv(),onClick:()=>{const j=Date.now();r({startTs:j-R.windowMs,endTs:j,timeWindowMs:R.windowMs}),f(!1),b(!1)},children:[g.jsx("span",{className:"min-w-0 flex-1 truncate",children:R.label}),g.jsx(xe,{name:"check",className:pe("ml-auto size-4 shrink-0",M?"opacity-100":"opacity-0")})]},R.windowMs)})]})]}):null]})]})}function P7t({inputTokens:e,outputTokens:t,cachedTokens:n}){const r=[{label:"Input",value:e},{label:"Output",value:t},{label:"Cached",value:n}];return g.jsx("div",{className:"min-w-28 px-2 py-1.5 text-xs text-text-primary",children:g.jsx("div",{className:"flex flex-col gap-1",children:r.map(o=>g.jsxs("div",{className:"flex items-center justify-between gap-4",children:[g.jsx("span",{className:"text-text-secondary",children:o.label}),g.jsx("span",{className:"tabular-nums font-medium text-text-primary",children:wl(o.value)})]},o.label))})})}function D7t({turnNumber:e,totalTokens:t,inputTokens:n,outputTokens:r,cachedTokens:o,durationMs:a,totalCostInUsd:i}){const s=t!=null||a!=null||i!=null,l=n!=null||r!=null||o!=null,c=n??0,d=r??0,p=o??0,f=t!=null?g.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-sm text-inherit","aria-label":l?`Tokens ${wl(t)}. Input ${wl(c)}, Output ${wl(d)}, Cached ${wl(p)}`:`Tokens ${wl(t)}`,children:[g.jsx(xe,{name:"link",className:"size-3.5 shrink-0","aria-hidden":!0}),`Tokens ${wl(t)}`]}):null;return g.jsxs("div",{className:"flex items-center gap-3 py-1 text-xs text-text-secondary",children:[g.jsx("span",{className:"shrink-0 font-semibold text-text-primary",children:`Turn ${e}`}),g.jsx("div",{className:"h-px min-w-4 flex-1 bg-border","aria-hidden":"true"}),s?g.jsxs("div",{className:"flex shrink-0 items-center gap-3 tabular-nums",children:[f!=null?l?g.jsx(aN,{title:g.jsx(P7t,{inputTokens:c,outputTokens:d,cachedTokens:p}),side:"bottom",children:f}):f:null,a!=null?g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsx(xe,{name:"clock",className:"size-3.5 shrink-0"}),`Duration ${lMe(a)}`]}):null,i!=null?g.jsx("span",{children:`Cost ${W1(i)}`}):null]}):null]})}function L7t(){const e=Vv(),t=ng(),{updateShareSearch:n}=dN(),r=We("AgentSessions"),o=We("AgentSessionsFilters"),a=t.sharedSessionId,[i,s]=w.useState(()=>Mu(window.location.search).agentId),[l,c]=w.useState(()=>Mu(window.location.search).timeRange??XE());w.useEffect(()=>{if(a!=null)return;const T=Mu(window.location.search);n({view:"sessions",...T.timeRange==null?{timeRange:l}:{}})},[]),w.useEffect(()=>{const T=()=>{const C=Mu(window.location.search);s(C.agentId),c(C.timeRange??XE())};return window.addEventListener("popstate",T),()=>window.removeEventListener("popstate",T)},[]);const[d,p]=w.useState(0),[f,m]=w.useState(!1),b=w.useCallback(()=>{m(!0),p(T=>T+1)},[]),y=w.useCallback(T=>{T||m(!1)},[]),x=w.useMemo(()=>pye(l),[l,d]),_=l.endTs-l.startTs,k=l.timeWindowMs==null&&_>0&&_<=2*FL,E=w.useCallback(()=>{const T=XE();c(T),n({timeRange:T,sessionId:null,view:"sessions"})},[n]);return g.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[g.jsx(k7,{title:"Agent Sessions",end:a==null?g.jsx(o,{agentId:i,timeRange:l,onAgentChange:T=>{s(T),n({agentId:T,sessionId:null,view:"sessions"})},onTimeRangeChange:T=>{c(T),n({timeRange:T,sessionId:null,view:"sessions"})},onReload:e==null?void 0:b,isReloading:f}):null}),g.jsx("div",{className:"min-h-0 flex-1",children:e==null?g.jsx("p",{className:"px-6 py-12 text-center text-sm text-text-secondary",children:"Session history is not available."}):g.jsx(w.Suspense,{fallback:g.jsx("div",{className:"p-4",role:"status","aria-label":"Loading sessions",children:g.jsx(ti,{className:"min-h-64 rounded-lg"})}),children:g.jsx(r,{refreshKey:d,onLoadingChange:y,agentId:i??void 0,startTimestamp:new Date(x.startTs).toISOString(),endTimestamp:new Date(x.endTs).toISOString(),...a==null?{shareView:"sessions",...k?{onLoadRecentSessions:E}:{}}:{detailOnly:!0,detailSessionId:a,onCloseDetail:t.closeSharedSession}})})})]})}function z7t(e){return e.subjectDisplayName||e.subjectId}function $7t(e){return e.some(t=>t.createdBySubject!=null)}var K2="agent_name",F7t="trueforge-library-share";function U7t(e){return e!=null&&e.length>0?e:null}function Ige(e){const t=new URLSearchParams(e.startsWith("?")?e.slice(1):e);return{agentName:U7t(t.get(K2))}}function B7t(e,t){t.agentName===null?e.delete(K2):t.agentName!=null&&e.set(K2,t.agentName)}function ix(e){e.delete(K2)}function H7t(e){const t=new URL(window.location.href);return B7t(t.searchParams,e),window.history.replaceState(window.history.state,"",t),window.dispatchEvent(new Event(F7t)),t.search}var Y2="agent",Z2="status",X2="q",q2="isNew",V7t="trueforge-schedule-share";function Nge(e){return e!=null&&e.length>0?e:null}function G7t(e){return e==="active"||e==="paused"?e:null}function W7t(e){const t=new URLSearchParams(e.startsWith("?")?e.slice(1):e);return{agent:Nge(t.get(Y2)),status:G7t(t.get(Z2)),q:Nge(t.get(X2)),isNew:t.get(q2)==="true"}}function bMe(e,t){t.agent===null?e.delete(Y2):t.agent!=null&&e.set(Y2,t.agent),t.status===null?e.delete(Z2):t.status!=null&&e.set(Z2,t.status),t.q===null?e.delete(X2):t.q!=null&&e.set(X2,t.q),t.isNew===null||t.isNew===!1?e.delete(q2):t.isNew===!0&&e.set(q2,"true")}function sx(e){e.delete(Y2),e.delete(Z2),e.delete(X2),e.delete(q2)}function K7t(e){const t=new URL(window.location.href);return bMe(t.searchParams,e),window.history.replaceState(window.history.state,"",t),window.dispatchEvent(new Event(V7t)),t.search}var vMe=w.createContext(void 0);function Y7t({currentUser:e,children:t}){return g.jsx(vMe.Provider,{value:e,children:t})}function Z7t(){return w.useContext(vMe)}var X7t={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 kZ({className:e,size:t="default",...n}){return g.jsx("div",{"data-slot":"avatar","data-size":t,className:pe("relative flex shrink-0 overflow-hidden rounded-full",X7t[t],e),...n})}function q7t({className:e,src:t,alt:n="",onError:r,...o}){const[a,i]=w.useState(!1);return a||!t?null:g.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 EZ({className:e,...t}){return g.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 yMe(e){const t=Array.from(e.trim())[0];return t===void 0?"":t.toLocaleUpperCase()}function Q7t({labeled:e=!1,className:t}){const n=Z7t(),r=n==null?void 0:n.displayName.trim();return r?g.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:[g.jsx(kZ,{size:"sm",children:g.jsx(EZ,{children:yMe(r)})}),g.jsx("span",{className:"w-full truncate text-center text-[0.625rem] leading-tight",children:r})]}):null}function Mge({subject:e}){if(e==null)return g.jsx("span",{className:"text-text-secondary text-sm",children:"—"});const t=z7t(e),n=yMe(t)||"?";return g.jsx(eo,{content:t,children:g.jsxs("span",{className:"flex min-w-0 max-w-[14rem] items-center gap-2",children:[g.jsx(kZ,{size:"sm","aria-hidden":!0,children:g.jsx(EZ,{children:n})}),g.jsx("span",{className:"text-text-secondary truncate text-sm",children:t})]})})}function c$(e){return"name"in e&&typeof e.name=="string"?e.name:null}var J7t=({query:e,setQuery:t,placeholder:n="Search"})=>g.jsxs("label",{className:"relative block",children:[g.jsx(xe,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),g.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})]}),eFt=J7t,kE=4,tFt=256;function nFt({optionCount:e,hasFooter:t}){const n=Math.max(e,1)*32,r=t?40:0;return Math.min(8+n+r,tFt)}function rFt({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 u$(e){const[t,n]=w.useState(!1),r=T=>{var C;n(T),(C=e.onOpenChange)==null||C.call(e,T)},[o,a]=w.useState(null),i=w.useRef(null),s=w.useRef(null),l=w.useRef(null),c=w.useRef(null),d=w.useRef(!1),p=w.useId(),f=e.menuPlacement??"bottom",m=e.footer!=null,b=e.options.length;w.useLayoutEffect(()=>{if(!t){a(null);return}const T=()=>{var L;const A=s.current;if(!A)return;const R=A.getBoundingClientRect(),M=window.innerHeight-R.bottom-kE,j=R.top-kE,O=(L=l.current)==null?void 0:L.offsetHeight,P=O!=null&&O>0?O:nFt({optionCount:b,hasFooter:m}),D=rFt({preferred:f,spaceAbove:j,spaceBelow:M,menuHeight:P});a({top:D==="top"?R.top-kE:R.bottom+kE,left:R.left,width:R.width,placement:D})};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,f,b,m]),w.useEffect(()=>{if(!t)return;const T=C=>{var A,R;C.target instanceof Node&&((A=i.current)!=null&&A.contains(C.target)||(R=l.current)!=null&&R.contains(C.target)||r(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),w.useEffect(()=>{var A,R,M;if(!t){d.current=!1;return}if(o==null||d.current)return;const T=(A=c.current)==null?void 0:A.querySelector('[role="option"][aria-selected="true"]'),C=(R=c.current)==null?void 0:R.querySelector('[role="option"]:not([aria-disabled="true"])');(M=T??C)==null||M.focus(),d.current=!0},[t,o]),w.useEffect(()=>{if(!t)return;const T=C=>{var j,O,P;if(C.key==="Escape"){C.preventDefault(),r(!1),(j=s.current)==null||j.focus();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(C.key))return;const A=Array.from(((O=c.current)==null?void 0:O.querySelectorAll('[role="option"]:not([aria-disabled="true"])'))??[]);if(A.length===0)return;C.preventDefault();const R=A.findIndex(D=>D===document.activeElement),M=C.key==="Home"?0:C.key==="End"?A.length-1:C.key==="ArrowDown"?(R+1)%A.length:(R-1+A.length)%A.length;(P=A[M])==null||P.focus()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[t]);const y=T=>e.multiple?e.value.includes(T):e.value===T,x=e.options.filter(T=>y(T.value)).map(T=>T.label),_=x.length===0?e.placeholder??"Select":e.multiple&&x.length>1?`${x.length} selected`:x[0],k=T=>{var C;if(!T.disabled){if(e.multiple){e.onValueChange(e.value.includes(T.value)?e.value.filter(A=>A!==T.value):[...e.value,T.value]);return}e.onValueChange(T.value),r(!1),(C=s.current)==null||C.focus()}},E=t&&o!=null?di.createPortal(g.jsxs("div",{ref:l,className:pe(SZ("fixed z-[200]"),e.menuClassName),style:{top:o.top,left:o.left,width:o.width,transform:o.placement==="top"?"translateY(-100%)":void 0},onMouseDown:T=>T.stopPropagation(),children:[g.jsx("div",{ref:c,id:p,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);return g.jsxs("button",{type:"button",role:"option","aria-selected":C,"aria-disabled":T.disabled||void 0,disabled:T.disabled,className:Nv(),onClick:()=>k(T),children:[g.jsx("span",{className:"min-w-0 flex-1 truncate",children:T.label}),g.jsx(xe,{name:"check",className:pe("ml-auto size-4 shrink-0",C?"opacity-100":"opacity-0")})]},T.value)})}),e.footer]}),oN(i.current)):null;return g.jsxs("div",{ref:i,className:pe("relative",e.className),children:[g.jsx("button",{ref:s,type:"button",disabled:e.disabled,"aria-label":e["aria-label"],"aria-haspopup":"listbox","aria-expanded":t,"aria-controls":t?p:void 0,className:e.prefix!=null?hMe():pN(),onClick:()=>r(!t),onKeyDown:T=>{(T.key==="ArrowDown"||T.key==="Enter"||T.key===" ")&&(T.preventDefault(),r(!0))},children:e.prefix!=null?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"text-text-primary shrink-0 border-r border-border px-3 font-semibold",children:e.prefix}),g.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-2 px-2",children:[g.jsx("span",{className:"bg-primary-button-bg/10 text-text-primary truncate rounded px-2 py-0.5 text-sm",children:_}),g.jsx(xe,{name:"chevron-down",className:"text-text-secondary size-4 shrink-0"})]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"truncate",children:_}),g.jsx(xe,{name:"chevron-down",className:"size-4 shrink-0"})]})}),E]})}var oFt=10,aFt=[10,25,50];function iFt({className:e,containerClassName:t,...n}){return g.jsx("div",{className:pe("w-full overflow-x-auto",t),children:g.jsx("table",{className:pe("w-full min-w-full border-collapse bg-primary-bg text-sm",e),...n})})}function sFt({className:e,...t}){return g.jsx("thead",{className:pe("bg-primary-bg",e),...t})}function lFt({className:e,...t}){return g.jsx("tbody",{className:pe("[&>tr:not(:last-child)>td]:after:block",e),...t})}function xMe({className:e,...t}){return g.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 lx({className:e,...t}){return g.jsx("th",{className:pe("text-text-secondary p-3 text-left text-xs font-normal tracking-wide uppercase",e),...t})}function cx({className:e,...t}){return g.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 Oge({pageSize:e,rowCount:t,canPrev:n,canNext:r,onPrev:o,onNext:a,onPageSizeChange:i,pageSizeOptions:s=aFt,className:l}){const c=s.map(d=>({value:String(d),label:String(d)}));return g.jsxs("div",{className:pe("text-text-secondary flex flex-wrap items-center justify-between gap-3 px-3 py-2 text-sm",l),children:[g.jsx("p",{className:"tabular-nums","aria-live":"polite",children:t===0?"Showing 0":`Showing ${String(t)}`}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsxs("label",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"whitespace-nowrap",children:"Rows per page"}),g.jsx(u$,{"aria-label":"Rows per page",className:"w-[4.5rem]",value:String(e),options:c,onValueChange:d=>{i(Number(d))}})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("button",{type:"button","aria-label":"Previous page",disabled:!n,className:Xt({variant:"ghost",size:"icon"}),onClick:o,children:g.jsx(xe,{name:"chevron-left"})}),g.jsx("button",{type:"button","aria-label":"Next page",disabled:!r,className:Xt({variant:"ghost",size:"icon"}),onClick:a,children:g.jsx(xe,{name:"chevron-right"})})]})]})]})}var jge=[10,25];function cFt(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function uFt({agentName:e,onOpen:t,disabled:n,alwaysShowAdd:r=!1}){return g.jsxs(g.Fragment,{children:[r?null:g.jsx("span",{"aria-hidden":!0,className:"text-text-secondary text-sm md:group-hover:hidden",children:"-"}),g.jsxs(In.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:[g.jsx(xe,{name:"plus",className:"size-3.5 shrink-0"}),"Schedule"]})]})}function Pge({name:e,description:t,onOpen:n,descriptionMode:r="tooltip"}){const o=n==null?g.jsx("span",{className:"block truncate",children:e}):g.jsx("button",{type:"button",className:"block max-w-full cursor-pointer text-left","aria-label":`Open ${e}`,onClick:n,children:g.jsx("span",{className:"block truncate",children:e})});return t==null?g.jsx(g.Fragment,{children:o}):r==="clamp"?g.jsxs(g.Fragment,{children:[o,g.jsx("span",{className:"text-text-secondary line-clamp-2 text-xs font-normal",children:t})]}):g.jsxs(g.Fragment,{children:[o,g.jsx(eo,{content:t,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:g.jsx("span",{className:"text-text-secondary block truncate text-xs font-normal",children:t})})]})}function Dge({agentName:e,modelLabel:t,modelTitle:n,skillsCount:r,skillsTitle:o,mcpCount:a,connectorsTitle:i,className:s}){return t!=null||r>0||a>0?g.jsxs("div",{className:pe("text-text-secondary flex min-w-0 items-center gap-2",s),children:[t!=null?g.jsx(eo,{content:n,children:g.jsxs("span",{className:"bg-secondary-bg text-text-secondary inline-flex max-w-[10rem] items-center gap-1 truncate rounded-full px-2 py-0.5 text-xs font-medium","aria-label":n,children:[g.jsx(xe,{name:"cpu",className:"size-3.5 shrink-0"}),g.jsx("span",{className:"truncate",children:t})]})}):null,r>0?g.jsx(eo,{content:o,children:g.jsxs("span",{className:"inline-flex items-center gap-1 text-xs","aria-label":`Skills: ${o}`,children:[g.jsx(xe,{name:"lightbulb",className:"size-3.5 shrink-0"}),r]})}):null,a>0?g.jsx(eo,{content:i,children:g.jsxs("span",{className:"inline-flex items-center gap-1 text-xs","aria-label":`Connectors: ${i}`,children:[g.jsx(xe,{name:"plug",className:"size-3.5 shrink-0"}),a]})}):null]}):g.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Configuration unavailable for ${e}`,children:"—"})}function Lge({scheduleSummary:e,agentName:t,onOpenSchedules:n,onCreateSchedule:r,canUseAgent:o,alwaysShowAdd:a=!1}){return e===void 0?null:e!=null&&e.count>0?g.jsx(dFt,{summary:e,agentName:t,onOpen:n,disabled:!o}):e!=null?g.jsx(uFt,{agentName:t,onOpen:r,disabled:!o,alwaysShowAdd:a}):g.jsx("span",{className:"text-text-secondary text-sm","aria-label":`Schedule count unavailable for ${t}`,children:"—"})}function zge(e){return g.jsx("span",{className:"flex flex-col text-left",children:e.map((t,n)=>g.jsxs("span",{children:[t,n<e.length-1?",":""]},t))})}function dFt({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 g.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?g.jsx(eo,{content:zge(e.activeNames),className:"whitespace-normal",children:g.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:[g.jsx(xe,{name:"calendar-clock",className:"size-3.5 shrink-0"}),g.jsxs("span",{children:[a," Active"]})]})}):null,o>0?g.jsx(eo,{content:zge(e.pausedNames),className:"whitespace-normal",children:g.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?g.jsx(xe,{name:"calendar-clock",className:"size-3.5 shrink-0"}):null,g.jsxs("span",{children:[o," Paused"]}),g.jsx(xe,{name:"triangle-exclamation",className:"size-3.5 shrink-0"})]})}):null]})}function pFt({agent:e,canMutate:t,canUseAgent:n=!0,canManageAgent:r=!0,canDeleteAgent:o=!0,canManageSchedules:a,showCreatedBy:i=!1,scheduleSummary:s,onOpenSchedules:l,onCreateSchedule:c,onOpen:d,onTry:p,onEdit:f,onManageSchedules:m,variant:b="row"}){var $,H,V;const y=We("PermissionGuard"),x=e.agentSpec,_=x==null?void 0:x.model.name,k=(($=x==null?void 0:x.skills)==null?void 0:$.length)??0,E=((H=x==null?void 0:x.mcpServers)==null?void 0:H.length)??0,T=((x==null?void 0:x.skills)??[]).map(c$).filter(Y=>Y!=null),C=((x==null?void 0:x.mcpServers)??[]).map(c$).filter(Y=>Y!=null),A=_!=null?cFt(_):null,R=_??"",M=C.length?C.join(", "):`${E} connectors`,j=T.length?T.join(", "):`${k} skills`,O=s!=null&&s.count===0,P=((V=e.description)==null?void 0:V.trim())||null,D=P!=null&&P!==e.name?P:null,L=g.jsx(sMe,{agentName:e.name,...P!=null?{description:P}:{},...x!=null?{agentSpec:x}:{},canMutate:t,canUse:n,canManage:r,canDelete:o,canManageSchedules:a,onEdit:f,...m!=null?{onManageSchedules:m}:{}}),z=g.jsx(y,{allowed:n,children:g.jsxs(In.Secondary,{type:"button","aria-label":`Try agent ${e.name}`,size:"large",onClick:p,children:[g.jsx(xe,{name:"play",className:"size-3.5"}),"Try"]})}),F=g.jsx(Dge,{agentName:e.name,modelLabel:A,modelTitle:R,skillsCount:k,skillsTitle:j,mcpCount:E,connectorsTitle:M});return b==="card"?g.jsxs("li",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card-bg p-3",children:[g.jsxs("div",{className:"flex items-start gap-2",children:[g.jsx("div",{className:"text-text-primary min-w-0 flex-1 font-medium",children:g.jsx(Pge,{name:e.name,description:D,...d!=null?{onOpen:d}:{},descriptionMode:"clamp"})}),L]}),g.jsx(Dge,{agentName:e.name,modelLabel:A,modelTitle:R,skillsCount:k,skillsTitle:j,mcpCount:E,connectorsTitle:M,className:"flex-wrap"}),i?g.jsx(Mge,{subject:e.createdBySubject}):null,g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("div",{className:"min-w-0",children:g.jsx(Lge,{scheduleSummary:s,agentName:e.name,...l!=null?{onOpenSchedules:l}:{},...c!=null?{onCreateSchedule:c}:{},canUseAgent:n,alwaysShowAdd:!0})}),z]})]}):g.jsxs(xMe,{className:O?"group":void 0,children:[g.jsx(cx,{className:"text-text-primary w-96 max-w-96 font-medium",children:g.jsx(Pge,{name:e.name,description:D,...d!=null?{onOpen:d}:{}})}),g.jsx(cx,{children:F}),i?g.jsx(cx,{children:g.jsx(Mge,{subject:e.createdBySubject})}):null,s!==void 0?g.jsx(cx,{children:g.jsx(Lge,{scheduleSummary:s,agentName:e.name,...l!=null?{onOpenSchedules:l}:{},...c!=null?{onCreateSchedule:c}:{},canUseAgent:n})}):null,g.jsx(cx,{className:"w-px",children:g.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[z,L]})})]})}function fFt(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 hFt({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 gFt({onSelectAgent:e,headerStart:t}){const n=ng(),r=Gv(),{updateShareSearch:o}=dN(),a=Vv(),i=OC(),s=We("AgentLibraryRow"),l=Zs(),[c,d]=w.useState(()=>Ige(window.location.search).agentName??""),[p,f]=w.useState(null),m=w.useRef(!1),b=n.libraryOpen,y=n.isComposerEnabled===!0,x=n.agentsListEpoch,_=o1({schedules:i}),k=r1({sessions:a}),E=_&&k;w.useEffect(()=>{if(!b){d("");return}m.current=!0,d(Ige(window.location.search).agentName??"")},[b]),w.useEffect(()=>{if(b){if(m.current){m.current=!1;return}H7t({agentName:c.trim().length===0?null:c})}},[b,c]);const T=w.useCallback(()=>{l(Io.Library.CLOSED),n.setLibraryOpen(!1),d("")},[n,l]);w.useEffect(()=>{if(!b)return;const G=Q=>{Q.key==="Escape"&&(kye()||(Q.stopImmediatePropagation(),T()))};return window.addEventListener("keydown",G,!0),()=>window.removeEventListener("keydown",G,!0)},[T,b]);const{agents:C,isInitialLoading:A,isSearching:R,error:M,pageSize:j,setPageSize:O,canPrev:P,canNext:D,goPrev:L,goNext:z}=mMe({enabled:b,query:c,refreshKey:x,mode:"paged",limit:oFt}),F=P||D,$=$7t(C),H=b?C.map(dc):[],{allows:V}=G1({resourceType:"agent",resourceIds:H});w.useEffect(()=>{if(!b||i==null||C.length===0){f(null);return}let G=!1;f(null);const Q=C.map(dc);return hFt({listSchedules:i.listSchedules,agentIds:Q}).then(ne=>{G||f(fFt(ne))}).catch(()=>{G||f(null)}),()=>{G=!0}},[C,b,i,x]);const Y=({agentId:G,isNew:Q})=>{l(Io.Library.AGENT_SCHEDULES_OPENED,{agent_id:G}),K7t({agent:null,status:null,q:null,isNew:Q===!0?!0:null}),o({agentId:G,tab:"schedules",sessionId:null,view:null,timeRange:null}),n.openLibraryAgent(G)},U=G=>{l(Io.Library.AGENT_TRIED,{agent_id:dc(G),agent_name:G.name}),e==null||e(G.name),n.selectLibraryAgent({isMutable:!1,agentId:dc(G),agentName:G.name})},X=(G,Q)=>{l(Io.Library.AGENT_EDITED,{agent_id:dc(G),agent_name:G.name}),e==null||e(G.name),n.selectLibraryAgent({isMutable:!0,isCreateAgent:!0,agentId:dc(G),agentName:G.name,...G.description===void 0?{}:{description:G.description},agentSpec:Q})};if(!b)return null;const J=(G,Q)=>{const ne=G.agentSpec,de=G.agentId,se=dc(G),oe=_?(p==null?void 0:p.get(se))??(p==null?void 0:p.get(G.name))??(p==null?null:{count:0,pausedCount:0,activeNames:[],pausedNames:[]}):void 0;return g.jsx(s,{agent:G,canMutate:y,canUseAgent:V(se,"USE"),canManageAgent:V(se,"MANAGE"),canDeleteAgent:V(se,"DELETE"),canManageSchedules:E,showCreatedBy:$,variant:Q,...oe!==void 0?{scheduleSummary:oe}:{},...E&&de!=null?{onOpenSchedules:()=>Y({agentId:de}),onCreateSchedule:()=>Y({agentId:de,isNew:!0}),onManageSchedules:()=>Y({agentId:de})}:{},...k&&de!=null?{onOpen:()=>{l(Io.Library.AGENT_DETAILS_OPENED,{agent_id:de,agent_name:G.name}),o({agentId:de,tab:"overview",sessionId:null,view:null,timeRange:null}),n.openLibraryAgent(de)}}:{},onTry:()=>{V(se,"USE")&&U(G)},onEdit:()=>{ne!=null&&V(se,"MANAGE")&&X(G,ne)}},se)},K=g.jsx(Oge,{pageSize:j,rowCount:C.length,canPrev:P,canNext:D,onPrev:L,onNext:z,pageSizeOptions:jge,onPageSizeChange:O});return g.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[g.jsx(k7,{title:"Agents",start:t,end:g.jsxs("div",{className:"w-56 shrink-0",children:[g.jsx(eFt,{query:c,setQuery:d,placeholder:"Search agents"}),R?g.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null]})}),g.jsx("div",{className:"bg-secondary-bg/40 flex min-h-0 flex-1 flex-col",children:g.jsx("div",{className:pe("min-h-0 flex-1 overflow-y-auto p-4",M?"flex flex-col":void 0),"aria-label":"Agents",children:A?g.jsx("div",{className:"flex flex-col gap-2 p-1",role:"status","aria-label":"Loading agents",children:Array.from({length:6},(G,Q)=>g.jsx(ti,{className:pe("w-full rounded-md",r?"h-32":"h-11")},Q))}):M?g.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:g.jsx(bT,{title:"Couldn't load agents",description:M,className:"h-auto min-h-0 flex-none py-0"})}):C.length===0&&!F?g.jsx(bT,{title:"No Agents Found",description:c.trim()?g.jsxs(g.Fragment,{children:["No search results found for ",g.jsx(kge,{children:c.trim()})]}):"Build one in a chat, then save it as an agent."}):C.length===0?g.jsxs("div",{className:"flex min-h-full flex-col",children:[g.jsx(bT,{title:"No Agents Found",description:c.trim()?g.jsxs(g.Fragment,{children:["No search results found for ",g.jsx(kge,{children:c.trim()})]}):"Build one in a chat, then save it as an agent.",className:"flex-1"}),g.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:g.jsx(Oge,{pageSize:j,rowCount:0,canPrev:P,canNext:D,onPrev:L,onNext:z,pageSizeOptions:jge,onPageSizeChange:O})})]}):r?g.jsxs("div",{className:"flex flex-col gap-3",children:[g.jsx("ul",{"aria-label":"Agents",className:"flex flex-col gap-3",children:C.map(G=>J(G,"card"))}),g.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:K})]}):g.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[g.jsxs(iFt,{children:[g.jsx(sFt,{children:g.jsxs(xMe,{className:"hover:bg-transparent",children:[g.jsx(lx,{className:"w-96 min-w-96",children:"Agent name"}),g.jsx(lx,{children:"Configuration"}),$?g.jsx(lx,{children:"Created by"}):null,_?g.jsx(lx,{className:"w-[14rem]",children:"Schedules"}):null,g.jsx(lx,{className:"w-px",children:g.jsx("span",{className:"sr-only",children:"Actions"})})]})}),g.jsx(lFt,{children:C.map(G=>J(G,"row"))})]}),K]})})})]})}function mFt({className:e,compact:t=!1}){const n=ui(),r=vo(),o=Zs(),[a,i]=w.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 w.useEffect(()=>{if(!s||!n||t)return;let d=!1;return n.searchAgents({limit:H_}).then(p=>{d||i(p.nextPageToken!=null&&p.nextPageToken!==""?`${H_}+`:String(p.data.length))}).catch(()=>{}),()=>{d=!0}},[s,n,c,t]),s?g.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:g.jsxs("button",{type:"button","aria-label":t?"Agents":void 0,title:t?"Agents":void 0,"aria-current":l?"page":void 0,className:Xt({variant:"ghost",className:pe(n1,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?NC:"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:[g.jsx(xe,{name:"library-big",size:t?14:void 0}),t?g.jsx("span",{className:"text-center",children:"Agents"}):g.jsxs(g.Fragment,{children:[g.jsxs("span",{className:"truncate",children:["Agents",a!=null?g.jsxs("span",{className:pe(!l&&"text-text-secondary"),children:[" (",a,")"]}):null]}),g.jsx(xe,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}function bFt({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 g.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:[g.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[g.jsx("span",{className:"bg-approval-banner-accent size-2 shrink-0 rounded-full","aria-hidden":!0}),g.jsx("span",{className:"truncate font-medium leading-[1.4]",children:l})]}),g.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g.jsxs("span",{className:"font-medium tabular-nums leading-[1.4]",children:["(",t,"/",e,")"]}),g.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:g.jsx(xe,{name:"arrow-down",size:"0.875rem"})}),g.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:g.jsx(xe,{name:"arrow-up",size:"0.875rem"})})]})]})}function wMe({children:e,error:t,statusBanner:n,actionBar:r,className:o}){return g.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:[g.jsxs("div",{className:"min-w-0 max-w-full",children:[e,n,t&&g.jsx("div",{className:"mt-2 text-sm text-failure-bg",children:t})]}),r&&g.jsx("div",{className:"mt-1",children:r})]})}var _Me=12,vFt={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 yFt(e){const t=e.lastIndexOf("."),n=t>0&&t<e.length-1?e.slice(t+1).toLowerCase():void 0;return n==null?"file":vFt[n]??"file"}function xFt(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 wFt({name:e,sizeBytes:t,previewSrc:n,isImage:r=!1,size:o="chip",previewRem:a,onRemove:i,className:s}){if(o==="preview"&&r&&n){const d=a!=null?{width:`${a}rem`,height:`${a}rem`}:void 0;return g.jsx("div",{"data-slot":"aui_attachment-preview",style:d,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:g.jsx("img",{src:n,alt:e,className:"h-full w-full object-cover"})})}const l=r&&n!=null,c=yFt(e);return g.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?g.jsxs(kZ,{className:"size-full rounded-none",children:[g.jsx(q7t,{src:n,alt:e,className:"object-cover"}),g.jsx(EZ,{className:"rounded-none bg-secondary-bg bg-none text-text-secondary",children:g.jsx(xe,{name:"file",size:"1.5rem",className:"text-text-secondary"})})]}):g.jsxs(g.Fragment,{children:[g.jsx(xe,{name:c,size:"1.5rem",className:"text-text-secondary shrink-0"}),g.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[g.jsx(eo,{content:e,side:"top",triggerClassName:"min-w-0",children:g.jsx("span",{className:"text-text-primary min-w-0 truncate text-sm font-medium",children:e})}),t!=null?g.jsx("span",{className:"text-text-secondary truncate text-xs",children:xFt(t)}):null]})]}),i&&g.jsx("button",{type:"button","aria-label":"Remove file",title:"Remove file",className:Xt({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:d=>{d.stopPropagation(),i()},children:g.jsx(xe,{name:"xmark",size:"0.625rem"})})]})}function _Ft({className:e,...t}){return g.jsx("button",{type:"button","aria-label":"Add Attachment",title:"Add Attachment",className:Xt({variant:"ghost",size:"icon",className:`size-7 rounded-full p-1 ${e??""}`}),...t,children:g.jsx(xe,{name:"paperclip"})})}function SFt({previewSrc:e,children:t}){const[n,r]=w.useState(!1);return e?g.jsxs(g.Fragment,{children:[g.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}),g.jsx(lN,{open:n,onOpenChange:r,"aria-label":"Attachment preview",className:"max-w-[calc(100%-2rem)] sm:max-w-3xl",children:g.jsxs(cN,{className:"relative p-2",children:[g.jsx("span",{className:"absolute top-2 right-2 z-10 inline-flex",children:g.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:Xt({variant:"ghost",size:"icon"}),onClick:()=>r(!1),children:g.jsx(xe,{name:"xmark"})})}),g.jsx("div",{className:"bg-primary-bg relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:g.jsx("img",{src:e,alt:"Attachment preview",className:"block h-auto max-h-[80vh] w-auto max-w-full object-contain"})})]})})]}):g.jsx(g.Fragment,{children:t})}var SMe=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading)&&e.threadListItem.remoteId==null,TZ=w.createContext(null),kMe=w.createContext(void 0),EMe=w.createContext(null);function kFt({children:e}){const[t,n]=w.useState(null),[r,o]=w.useState("panel"),a=Ve(b=>b.threadListItem.id),i=Ve(SMe),s=t==null?null:`${t.turnId}:${t.path}`,l=w.useRef(s);l.current!==s&&(l.current=s,r!=="panel"&&o("panel"));const c=w.useRef(a);c.current!==a&&(c.current=a,n(null));const d=w.useRef(i);d.current!==i&&(d.current=i,i&&n(null));const p=w.useCallback(b=>{n(b)},[]),f=w.useCallback(()=>{n(null)},[]),m=w.useMemo(()=>({target:t,presentation:r,open:p,close:f,setPresentation:o}),[t,r,p,f,o]);return g.jsx(TZ.Provider,{value:m,children:e})}function Knn(){const e=w.useContext(TZ);if(e==null)throw new Error("File preview is only available inside FilePreviewProvider.");return e}function TMe(){return w.useContext(TZ)}function Ynn({children:e}){return TMe()!=null?e:g.jsx(kFt,{children:e})}function EFt({turnId:e,children:t}){return g.jsx(kMe.Provider,{value:e,children:t})}function TFt(){return w.useContext(kMe)}function AFt({load:e,children:t}){return g.jsx(EMe.Provider,{value:e,children:t})}function AMe(){return w.useContext(EMe)}var CFt=2*1024*1024,RFt=1e5,CMe={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"},IFt={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"},RMe=new Set(["html","htm"]),NFt=new Set(["md","markdown"]),$ge="This file is empty.",MFt="This file is too large to preview. Download it to open it locally.",OFt="This file can't be previewed here. Download it to open it locally.";function Fge(e){const t=e.split("/").pop()??e,n=t.lastIndexOf(".");return n<=0||n===t.length-1?"":t.slice(n+1).toLowerCase()}function jFt(e){return(e.length>8e3?e.slice(0,8e3):e).includes("\0")}function PFt(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 IMe({name:e,path:t}){return Fge(t)||Fge(e)}function Uge(e){const t=IMe(e);return RMe.has(t)?"html":t==="pdf"?"pdf":CMe[t]!=null?"image":null}function DFt(e){const t=e.trimStart().slice(0,300).toLowerCase();return t.startsWith("<!doctype html")||t.startsWith("<html")}function LFt(e){return/^#{1,6}\s/m.test(e.trimStart().slice(0,500))}function zFt(e,t){return e.type===t?e:new Blob([e],{type:t})}async function $Ft(e,t){if(e.size===0)return{status:"unavailable",message:$ge};if(e.size>CFt)return{status:"unavailable",message:MFt};const n=IMe(t),r=CMe[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 PFt(e);if(jFt(o))return{status:"unavailable",message:OFt};if(o.trim().length===0)return{status:"unavailable",message:$ge};if(RMe.has(n)||n.length===0&&DFt(o))return{status:"html",text:o};if(NFt.has(n)||n.length===0&&LFt(o))return{status:"markdown",text:o};const a=IFt[n];return a==null?{status:"text",text:o}:{status:"text",text:o,language:a}}var FFt="Couldn't load a preview of this file.",EE={view:{status:"loading"},blob:null};function UFt(e,t){return e==null?null:`${e.turnId}\0${e.path}\0${t}`}function BFt(e,t){const n=UFt(e,t),[r,o]=w.useState({key:null,...EE});return r.key!==n&&o({key:n,...EE}),w.useEffect(()=>{if(e==null||n==null)return;let a=!1,i;return o({key:n,...EE}),(async()=>{try{const s=await e.load();if(a)return;const l=await $Ft(s,{name:e.name,path:e.path});if(a)return;if(l.status==="media"){if(i=URL.createObjectURL(zFt(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:FFt}})}})(),()=>{a=!0,i!=null&&URL.revokeObjectURL(i)}},[e,t,n]),r.key===n?r:EE}function HFt({name:e,view:t}){return t.status==="loading"?g.jsx("div",{className:"flex aspect-video items-center justify-center bg-primary-bg text-text-secondary",children:g.jsx(Gs,{size:16})}):t.status==="error"||t.status==="unavailable"?g.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"?g.jsx("div",{className:"@container relative aspect-video overflow-hidden bg-white",children:g.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"?g.jsx("div",{className:"aspect-video overflow-hidden bg-primary-bg",children:g.jsx("img",{src:t.objectUrl,alt:"",className:"h-full w-full object-cover object-top"})}):t.status==="media"&&t.media==="pdf"?g.jsx("iframe",{title:`Thumbnail of ${e}`,src:t.objectUrl,tabIndex:-1,className:"pointer-events-none aspect-video w-full border-0 bg-white"}):g.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 VFt({name:e,onDownload:t,downloadHref:n,downloadBusy:r}){const o=Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),a=r?`Downloading ${e}`:`Download ${e}`,i=r?g.jsx(Gs,{size:14}):g.jsx(xe,{name:"download",size:14});return t!=null?g.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:g.jsx("a",{href:n,download:e,"aria-label":a,title:"Download",className:o,children:i})}function GFt({name:e,view:t,enlarged:n,onEnlarge:r,onDownload:o,downloadHref:a,downloadBusy:i=!1}){return g.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:[g.jsx("button",{type:"button",onClick:r,"aria-pressed":n,"aria-label":`Enlarge preview of ${e}`,className:"block w-full cursor-pointer text-left",children:g.jsx(HFt,{name:e,view:t})}),g.jsxs("footer",{className:"flex items-center gap-1 border-t border-border px-2.5 py-1.5",children:[g.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:e}),g.jsx("button",{type:"button",onClick:r,"aria-pressed":n,"aria-label":`Enlarge ${e}`,title:"Enlarge preview",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"expand",size:14})}),g.jsx(VFt,{name:e,downloadBusy:i,...o!=null?{onDownload:o}:{},...a!=null?{downloadHref:a}:{}})]})]})}function NMe(e){return e.split("/").map(encodeURIComponent).join("/")}function WFt({files:e,fileDownloadBaseUrl:t,onDownloadArtifact:n,readOnly:r,readOnlyTooltip:o}){const[a,i]=w.useState(null),s=TMe(),l=TFt(),c=AMe(),d=s!=null&&l!=null&&c!=null&&r!==!0,p=d?e.filter(y=>Uge(y)!=null):[],f=d?e.filter(y=>Uge(y)==null):e,m=({path:y,name:x})=>{!n||a===y||(i(y),n(y,x).finally(()=>{i(_=>_===y?null:_)}))},b=f.length===0?null:g.jsxs("details",{open:!0,className:pe("aui-sandbox-artifacts group overflow-hidden rounded-lg border border-primary-button-bg/20 bg-card-bg",p.length===0&&"my-2"),"data-testid":"aui-sandbox-artifacts",children:[g.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:g.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.jsx(xe,{name:"chevron-down",size:13,className:"shrink-0 transition-transform group-open:rotate-180"}),g.jsx(xe,{name:"file",size:16,className:"shrink-0"}),g.jsxs("span",{className:"leading-none",children:[f.length," ",f.length===1?"file":"files"," generated"]})]})}),g.jsx("div",{className:"flex flex-wrap items-center gap-y-1 px-3 py-2",children:f.map(y=>g.jsx(YFt,{file:y,downloadingPath:a,onStartDownload:m,...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:d},y.path))})]});return p.length===0||s==null||l==null?b:g.jsxs("div",{className:"my-2 flex flex-col gap-2",children:[g.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(y=>{var _;const x=t?`${t}${NMe(y.path)}`:void 0;return g.jsx(KFt,{name:y.name,path:y.path,turnId:l,enlarged:((_=s.target)==null?void 0:_.path)===y.path&&s.target.turnId===l,onEnlarge:()=>{const k=c;k!=null&&s.open({name:y.name,path:y.path,turnId:l,load:()=>k(y.path)})},downloadBusy:a===y.path,...n!=null?{onDownload:()=>m({path:y.path,name:y.name})}:{},...x!=null?{downloadHref:x}:{}},y.path)})}),b]})}function KFt({name:e,path:t,turnId:n,enlarged:r,onEnlarge:o,onDownload:a,downloadHref:i,downloadBusy:s}){const l=AMe(),c=w.useMemo(()=>l==null?null:{name:e,path:t,turnId:n,load:()=>l(t)},[l,e,t,n]),d=BFt(c,0);return g.jsx(GFt,{name:e,view:d.view,enlarged:r,onEnlarge:o,downloadBusy:s,...a!=null?{onDownload:a}:{},...i!=null?{downloadHref:i}:{}})}function YFt({file:e,downloadingPath:t,onStartDownload:n,fileDownloadBaseUrl:r,onDownloadArtifact:o,readOnly:a,readOnlyTooltip:i,preview:s,previewTurnId:l,loadPreviewFile:c,canPreview:d}){var _;const{name:p,path:f}=e;if(a){const k="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=g.jsxs(g.Fragment,{children:[g.jsx(xe,{name:"file",size:14,className:"shrink-0"}),g.jsx("span",{className:"leading-none",children:p})]});return i?g.jsx(eo,{content:i,triggerClassName:k,children:g.jsx("span",{className:"inline-flex items-center gap-1.5",children:E})}):g.jsx("span",{className:k,children:E})}const m=r?`${r}${NMe(f)}`:void 0,b=!!(o||m),y=t===f,x=k=>{if(!o||y){k.preventDefault();return}k.preventDefault(),n({path:f,name:p})};if(d&&s!=null&&l!=null&&c!=null){const k=((_=s.target)==null?void 0:_.path)===f&&s.target.turnId===l,E=()=>{const T=c;s.open({name:p,path:f,turnId:l,load:()=>T(f)})};return g.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",k&&"rounded-md bg-primary-button-bg/10"),children:[g.jsxs("button",{type:"button",onClick:E,"aria-pressed":k,title:`Preview ${p}`,"aria-label":`Preview ${p}`,className:"inline-flex cursor-pointer items-center gap-1.5 text-xs text-text-primary hover:text-primary-button-bg",children:[g.jsx(xe,{name:"file",size:14,className:"shrink-0 text-text-secondary"}),g.jsx("span",{className:"leading-none",children:p})]}),b?o?g.jsx("button",{type:"button",onClick:()=>n({path:f,name:p}),disabled:y,"aria-busy":y||void 0,"aria-label":y?`Downloading ${p}`:`Download ${p}`,title:y?`Downloading ${p}`:`Download ${p}`,className:pe("inline-flex items-center text-primary-button-bg",y?"cursor-progress":"cursor-pointer hover:text-primary-button-bg"),children:y?g.jsx(Gs,{size:14}):g.jsx(xe,{name:"download",size:14})}):g.jsx("a",{href:m,download:p,"aria-label":`Download ${p}`,title:`Download ${p}`,className:"inline-flex items-center text-primary-button-bg hover:text-primary-button-bg",children:g.jsx(xe,{name:"download",size:14})}):null]})}return g.jsxs("a",{href:b?m??"#":void 0,onClick:o?x:void 0,"aria-busy":y||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&&!y&&"cursor-pointer hover:text-primary-button-bg",(y||!b)&&"pointer-events-none opacity-60"),download:p,"aria-label":y?`Downloading ${p}`:`Download ${p}`,children:[g.jsx(xe,{name:"file",size:14,className:"shrink-0 text-text-secondary"}),g.jsx("span",{className:"leading-none",children:p}),y?g.jsx(Gs,{size:14,className:"shrink-0 text-primary-button-bg"}):g.jsx(xe,{name:"download",size:14,className:"shrink-0 text-primary-button-bg"})]})}function ZFt(){const e=vo();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 XFt(){return ZFt()!==null}function MMe(){var n,r;const e=vo(),{agentSpec:t}=Eg();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 OMe(){const e=vo(),t=Ve(SMe);return e!=null&&e.mode.status==="active"&&!t}function Znn(){const e=XFt(),t=MMe(),n=OMe();return e||t||n}function qFt(){const e=vo(),t=OMe(),n=iN(),r=We("PermissionGuard");return!t||e==null?null:g.jsx(r,{allowed:n,children:g.jsxs("button",{type:"button",title:"New Chat",className:Xt({variant:"ghost",size:"large"}),onClick:()=>{n&&e.clearChat()},children:[g.jsx(xe,{name:"square-pen",size:"0.875rem"}),"New Chat"]})})}function TE({onClick:e,tooltip:t,icon:n,active:r,variant:o="ghost"}){return g.jsx("button",{type:"button",onClick:e,title:t,className:Xt({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:g.jsx(xe,{name:n,size:"0.875em"})})}function QFt({value:e,language:t,theme:n,filename:r,onChange:o,onMount:a,beforeMount:i,className:s,height:l,showToolbar:c=!0,defaultShowLineNumbers:d=!1}){const p=We("MonacoEditorCore"),[f,m]=w.useState(d),[b,y]=w.useState(!1),[x,_]=w.useState(!1),k=w.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{_(!0),setTimeout(()=>_(!1),2e3)})},[e]),E=w.useCallback(()=>{const A=new Blob([e],{type:"text/plain"}),R=URL.createObjectURL(A),M=document.createElement("a");M.href=R,M.download=r??`code.${t??"txt"}`,M.click(),URL.revokeObjectURL(R)},[e,r,t]),T={lineNumbers:f?"on":"off",minimap:{enabled:!1},scrollBeyondLastLine:!1,renderFinalNewline:"off",wordWrap:"on"},C=b?"100%":l??320;return g.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&&g.jsxs("div",{className:"flex items-center justify-between gap-1 border-b border-border px-2 py-1",children:[r&&g.jsx("span",{className:"truncate text-xs text-text-secondary",children:r}),g.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[g.jsx(TE,{onClick:()=>m(A=>!A),tooltip:f?"Hide line numbers":"Show line numbers",icon:"list-ol",active:f}),g.jsx(TE,{onClick:k,tooltip:x?"Copied!":"Copy",icon:x?"check":"copy",variant:"secondary"}),g.jsx(TE,{onClick:E,tooltip:"Download",icon:"download"}),g.jsx(TE,{onClick:()=>y(A=>!A),tooltip:b?"Collapse":"Expand",icon:b?"compress":"expand"})]})]}),g.jsx("div",{className:"flex-1 overflow-hidden",style:b?void 0:{height:C},children:g.jsx(p,{value:e,language:t,theme:n,options:T,onChange:o,onMount:a,beforeMount:i,height:"100%"})})]})}function JFt({onAttach:e}){return e?g.jsx("button",{type:"button","aria-label":"Attach",title:"Attach",className:Xt({variant:"ghost",size:"icon"}),onClick:e,children:g.jsx(xe,{name:"paperclip"})}):null}function eUt(e){return null}function tUt({canSubmit:e,isRunning:t,hasContent:n,onSubmit:r,onCancel:o}){return t&&!n?g.jsxs(In.Primary,{type:"button",size:"small",disabled:!o,onClick:o,"aria-label":"Cancel",children:[g.jsx(Gs,{size:14}),"Cancel"]}):g.jsx(In.Primary,{type:"button",size:"icon","data-slot":"aui_composer-send",className:"shadow-none",disabled:!e,onClick:r,title:"Send message","aria-label":"Send message",children:g.jsx(xe,{name:"arrow-up"})})}function nUt({input:e,disabled:t,canSubmit:n,isRunning:r=!1,hasContent:o=!1,attachments:a,modelLabel:i,modelIcon:s,connectorStatusLabel:l,onSubmit:c,onCancel:d,onAttach:p,className:f}){const m=We("ComposerLeftSection"),b=We("ComposerRightSection"),y=We("ComposerSendButton");return g.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]",f),children:[a,e,g.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2 px-1",children:[g.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2",children:[g.jsx(m,{disabled:t,isRunning:r,onAttach:p}),l&&g.jsx("span",{className:"text-text-secondary max-w-[12rem] truncate text-xs",children:l})]}),g.jsxs("div",{className:"ml-auto flex min-w-0 shrink-0 flex-wrap items-center justify-end gap-2",children:[i&&g.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:[s,g.jsx("span",{className:"truncate",children:i})]}),g.jsx(b,{disabled:t,isRunning:r}),g.jsx(y,{disabled:t,canSubmit:n,isRunning:r,hasContent:o,onSubmit:c,onCancel:d})]})]})]})}function rUt(e){return typeof e!="object"||e===null?!1:Reflect.get(e,"type")==="user.message"&&typeof Reflect.get(e,"content")=="string"}function jMe(e){const t=Reflect.get(e,"messages");return Array.isArray(t)?t.filter(rUt):[]}function oUt({spec:e,messages:t}){return{...e,messages:t.length>0?t:void 0}}function AZ(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 aUt(e){const t=AZ(e);return(t==null?void 0:t.readOnlyHint)===!0?"read-only":(t==null?void 0:t.destructiveHint)===!0?"destructive":"others"}function Xnn(e){const t=AZ(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 iUt=["read-only","others","destructive"],sUt={"read-only":"Read-only Actions",others:"Other Actions",destructive:"Destructive Actions"},lUt={"read-only":"Enable all read-only tools",others:"Enable all other tools",destructive:"Enable all destructive tools"},cUt={others:"Require approval for all other tools",destructive:"Require approval for all destructive tools"};function Bge(e){const t={"read-only":[],others:[],destructive:[]};for(const n of e)t[aUt(n)].push(n);return t}var K1="@all",uUt="@read-only",CZ="@write",RZ="@destructive";function PMe({tag:e,tool:t}){const n=AZ(t);switch(e){case K1:return!0;case uUt:return(n==null?void 0:n.readOnlyHint)===!0;case RZ:return(n==null?void 0:n.destructiveHint)===!0;case CZ:return(n==null?void 0:n.readOnlyHint)===!1&&n.destructiveHint!==!0;default:return!1}}function Qh({tool:e,selectors:t}){return t.some(n=>n.startsWith("@")?PMe({tag:n,tool:e}):n===e.name)}function qnn({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=>Qh({tool:o,selectors:e})&&!Qh({tool:o,selectors:t})).map(o=>o.name),resolved:!0}}var Mv=[CZ,RZ];function Hge(e){return Qh({tool:e,selectors:Mv})}function dUt({tools:e,selectors:t,newlyEnabledNames:n}){if(e.length===0||n.length===0)return[...t];const r=vT({tools:e,selectors:t});for(const a of n){const i=e.find(s=>s.name===a);i!==void 0&&(Hge(i)?r.add(a):r.delete(a))}const o=DMe({tools:e,approved:r});return o.length===0&&!e.some(a=>Hge(a))?[...Mv]:o}function Vge({toolName:e,tools:t,selectors:n}){const r=t.find(o=>o.name===e);return r!==void 0?Qh({tool:r,selectors:n}):n.includes(K1)||n.includes(e)}function vT({tools:e,selectors:t}){return new Set(e.filter(n=>Qh({tool:n,selectors:t})).map(n=>n.name))}function DMe({tools:e,approved:t}){if(e.length>0&&e.every(r=>t.has(r.name)))return[K1];const n=[CZ,RZ].filter(r=>{const o=e.filter(a=>PMe({tag:r,tool:a}));return o.length>0&&o.every(a=>t.has(a.name))});for(const r of e)t.has(r.name)&&(Qh({tool:r,selectors:n})||n.push(r.name));return n}function pUt(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}function Ov(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 Nb(e){const t=Reflect.get(e,"enableTools");return!Array.isArray(t)||t.includes(K1)?"all":t.filter(n=>typeof n=="string"&&!n.startsWith("@"))}function LMe({value:e,key:t}){const n=Reflect.get(e,t);if(Array.isArray(n))return n.filter(r=>typeof r=="string")}function Qnn(e){return LMe({value:e,key:"enableTools"})??[K1]}function Jnn(e){return LMe({value:e,key:"disableTools"})??[]}function AE(e,t){return{...e,enableTools:t==="all"?["@all"]:t}}function CE(e){const t=Reflect.get(e,"requireApprovalForTools");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[...Mv]}function R6(e,t){if(pUt(t,Mv)){const n={...e};return Reflect.deleteProperty(n,"requireApprovalForTools"),n}return{...e,requireApprovalForTools:[...t]}}function Q2(e){return Reflect.get(e,"preload")===!0}function Gge(e,t){return{...e,preload:t}}function IZ({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 fUt({editor:e,spec:t,models:n,connectors:r,skills:o,loading:a,error:i,skillsDisabled:s=!1,sandboxAvailable:l=!1,webSearchAvailable:c=!1,instructions:d,onInstructionsSave:p,loadMcpConnector:f,loadMcpTools:m,onRefreshConnectors:b,onChange:y,onClose:x}){var Ye,Rt;const _=We("AgentModelConfigModal"),k=We("AgentResourceConfigModal"),E=We("AgentRuntimeConfigDrawer"),T=We("AgentInstructionsDrawer"),[C,A]=w.useState(""),[R,M]=w.useState(null),[j,O]=w.useState(),[P,D]=w.useState(!1),[L,z]=w.useState(null),[F,$]=w.useState([]),[H,V]=w.useState({}),[Y,U]=w.useState(!1),[X,J]=w.useState(null),[K,G]=w.useState(0),Q=w.useRef(new Set),ne=w.useMemo(()=>Ov(t.mcpServers),[t.mcpServers]),de=w.useMemo(()=>IZ({connectors:r,selected:ne}),[r,ne]),se=w.useRef(de);se.current=de;const oe=R!==null&&de.some(Ke=>Ke.id===R),re=ne.map(Ke=>{var De;return(De=de.find(Be=>Be.id===Ke.id||Be.name===Ke.name))==null?void 0:De.id}).find(Ke=>Ke!==void 0),q=(oe?R:null)??re??((Ye=de[0])==null?void 0:Ye.id)??null,te=q===null||(Rt=de.find(Ke=>Ke.id===q))==null?void 0:Rt.authenticated,ye=w.useMemo(()=>j===void 0?de:de.map(Ke=>Ke.id===j.id?{...Ke,...j}:Ke),[j,de]);w.useEffect(()=>{if(e!=="mcp"||q===null)return;let Ke=!1;const De=se.current.find(Be=>Be.id===q);return O(void 0),D(f!==void 0),z(null),$([]),U(!1),J(null),(async()=>{let Be=De;if(f!==void 0)try{if(Be=await f(q)??De,Ke)return;O(Be)}catch(Ae){Ke||z(aa(Ae,"Failed to load MCP server."));return}finally{Ke||D(!1)}if(!(Ke||(Be==null?void 0:Be.authenticated)===!1||m===void 0)){U(!0);try{const Ae=await m(q);Q.current.add(q),V(Le=>({...Le,[q]:Ae})),Ke||$(Ae)}catch(Ae){Ke||J(aa(Ae,"Failed to load tools."))}finally{Ke||U(!1)}}})(),()=>{Ke=!0}},[e,f,m,q,te,K]),w.useEffect(()=>{if(e!=="mcp"||m===void 0)return;const Ke=Q.current,De=ne.flatMap(Ae=>{const Le=se.current.find(st=>st.id===Ae.id||st.name===Ae.name);return Le===void 0||Le.authenticated!==!0?[]:Le.id===q||Ke.has(Le.id)?[]:[Le.id]});if(De.length===0)return;for(const Ae of De)Ke.add(Ae);const Be=new Set;return Promise.all(De.map(async Ae=>{try{const Le=await m(Ae);Be.add(Ae),V(st=>({...st,[Ae]:Le}))}catch{}})),()=>{for(const Ae of De)Be.has(Ae)||Ke.delete(Ae)}},[e,m,ne,q]);const Me=()=>{A(""),M(null),O(void 0),z(null),$([]),V({}),Q.current.clear(),J(null),x()},Oe=e==="model"||e==="model-settings"?e:null,qe=e==="mcp"||e==="skills"?e:null,Ge=Ke=>{if(p!==void 0){p(Ke);return}y(oUt({spec:{...t,instructions:Ke.instructions||void 0},messages:Ke.messages}))};return g.jsxs(g.Fragment,{children:[e==="instructions"?g.jsx(T,{open:!0,instructions:d??t.instructions??"",messages:jMe(t),onSave:Ge,onClose:Me}):null,Oe?g.jsx(_,{editor:Oe,spec:t,models:n,loading:a,error:i,query:C,onQueryChange:A,onChange:y,onClose:Me}):null,e==="runtime"?g.jsx(E,{open:!0,spec:t,sandboxAvailable:l,webSearchAvailable:c,onChange:y,onClose:Me}):null,qe?g.jsx(k,{editor:qe,spec:t,connectors:ye,skills:o,skillsDisabled:s,query:C,activeConnectorId:q,tools:F,toolsByConnector:H,connectorLoading:P||f!==void 0&&(j==null?void 0:j.id)!==q&&L===null,connectorError:L,toolsLoading:Y,toolsError:X,onQueryChange:A,onSelectConnector:M,onRetryTools:()=>G(Ke=>Ke+1),...f!==void 0?{onRefreshConnector:()=>G(Ke=>Ke+1)}:b!==void 0?{onRefreshConnector:()=>{b().then(()=>{G(Ke=>Ke+1)})}}:{},onChange:y,onClose:Me}):null]})}function fN({open:e,onOpenChange:t,children:n,className:r,id:o,"aria-label":a}){const i=w.useRef(null),s=ld(),l=_Z(i,s);w.useEffect(()=>{const d=i.current;d&&(e&&!d.open?d.showModal():!e&&d.open&&d.close())},[e]),w.useEffect(()=>{const d=i.current;if(!d)return;const p=()=>t(!1);return d.addEventListener("close",p),()=>d.removeEventListener("close",p)},[t]);const c=d=>{d.target===i.current&&t(!1)};return g.jsxs("dialog",{ref:i,id:o,"aria-label":a,onClick:c,onCancel:d=>{d.preventDefault(),d.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:[g.jsx("div",{className:"flex h-5 shrink-0 items-center justify-center","aria-hidden":!0,children:g.jsx("span",{className:"h-1 w-10 rounded-full bg-text-secondary/30"})}),n]})}function Wge({trigger:e,children:t,open:n,onOpenChange:r,sheetLabel:o,sheetClassName:a,containerClassName:i,closeOnClick:s=!0,...l}){const c=ld(),d=w.useId(),[p,f]=w.useState(!1),m=n??p,b=w.useCallback(x=>{n===void 0&&f(x),r==null||r(x)},[n,r]);if(!c)return g.jsx(of,{...l,trigger:e,open:n,onOpenChange:r,containerClassName:i,closeOnClick:s,children:t});const y=w.cloneElement(e,{"aria-haspopup":"dialog","aria-expanded":m,"aria-controls":m?d:void 0,onClick:x=>{var _,k;(k=(_=e.props).onClick)==null||k.call(_,x),x.defaultPrevented||b(!m)}});return g.jsxs("div",{className:pe("relative inline-flex",i),children:[y,m?g.jsx(fN,{id:d,open:!0,onOpenChange:b,"aria-label":o,className:a,children:g.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto",onClick:s?x=>{iMe(x)||b(!1)}:void 0,children:t})}):null]})}function zMe(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 hUt(e){const t=zMe(e);if(!(t==null||/-dark$/i.test(t.base)))return`${t.dir}${t.base}-dark${t.ext}${t.suffix}`}function gUt(e){const t=zMe(e);if(!(t==null||!/-dark$/i.test(t.base)))return`${t.dir}${t.base.replace(/-dark$/i,"")}${t.ext}${t.suffix}`}function mUt({src:e,mode:t}){return t==="dark"?hUt(e)??e:gUt(e)??e}function NZ({src:e,alt:t="",onError:n,...r}){const o=mN(),a=mUt({src:e,mode:o}),[i,s]=w.useState(!1);w.useEffect(()=>{s(!1)},[e,o,a]);const l=a!==e,c=i&&l?e:a;return w.createElement("img",{...r,key:c,src:c,alt:t,onError:d=>{if(l&&!i){s(!0);return}n==null||n(d)}})}function Px({loading:e,emptyLabel:t,settingsTarget:n,onOpenSettings:r}){return!e&&r?g.jsxs("button",{type:"button",className:Xt({variant:"ghost",className:"text-text-secondary w-full justify-center gap-1 py-4 text-xs"}),onClick:r,children:["Please configure ",n," in the ",g.jsx("span",{className:"underline",children:"settings"}),g.jsx(xe,{name:"chevron-right",className:"size-3"})]}):g.jsx("p",{className:"text-text-secondary px-2 py-4 text-center text-sm",children:e?"Loading…":t})}function V_(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function $Me({providerName:e,needle:t}){return V_(e).includes(t)}function d$({model:e,needle:t}){return V_(e.name).includes(t)||V_(e.id).includes(t)||$Me({providerName:e.provider.name,needle:t})}function bUt(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}function J2(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function I6(e){return Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function hN({logo:e,label:t,className:n}){return e?g.jsx(NZ,{src:e,alt:"",className:pe("shrink-0 rounded object-contain",n),"aria-hidden":!0}):g.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:bUt(t)})}function vUt(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 p$({models:e,loading:t,selectedName:n,query:r,onQueryChange:o,onSelect:a,onOpenSettings:i,listboxId:s,showHeading:l=!0,showSearch:c=!0}){const d=V_(r),p=w.useMemo(()=>d?e.filter(b=>d$({model:b,needle:d})):e,[e,d]),f=vUt(p),m="grid-cols-[minmax(0,1fr)_5rem]";return g.jsxs(g.Fragment,{children:[c&&g.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l?g.jsx("p",{className:"text-text-primary mb-2 text-sm font-normal",children:"Select model"}):null,g.jsxs("label",{className:"relative block",children:[g.jsx(xe,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),g.jsx("input",{type:"search",value:r,onChange:b=>o(b.target.value),placeholder:"Search",className:Bo("h-8 py-1 pr-2 pl-7"),autoFocus:!0})]})]}),l?null:g.jsxs("div",{className:pe("text-text-secondary grid gap-2 border-b border-border px-3 py-2 text-[10px] font-semibold uppercase",m),children:[g.jsx("span",{children:"Model"}),g.jsx("span",{children:"Context"})]}),g.jsx("div",{id:s,role:"listbox","aria-label":"Select model",className:"flex min-h-0 flex-auto flex-col overflow-y-auto p-1",children:p.length===0?g.jsx(Px,{loading:t,emptyLabel:"No models",settingsTarget:"Models",onOpenSettings:i}):f.map((b,y)=>{const x=`${s}-provider-${y}`;return g.jsxs("div",{role:"group","aria-labelledby":x,className:pe(y>0&&"mt-2"),children:[g.jsxs("div",{id:x,className:"text-text-secondary flex items-center gap-1.5 px-2 py-1.5 text-[11px] font-medium tracking-wide uppercase",children:[g.jsx(hN,{logo:b.logo,label:b.name,className:"size-3.5 text-[9px]"}),g.jsx("span",{className:"truncate",children:b.name})]}),b.models.map(_=>{const k=n?_.name===n:p[0]===_;return g.jsxs("button",{type:"button",role:"option","aria-selected":k,className:pe("w-full items-center rounded-md px-2 py-2 text-left text-sm",l?"flex":pe("grid gap-2",m),k?"bg-primary-button-bg/10 text-primary-button-bg":"hover:bg-ghost-button-hover"),onClick:()=>a(_),children:[g.jsxs("span",{className:"min-w-0",children:[g.jsx("span",{className:"block truncate font-normal",children:J2(_.name)}),l&&(_.properties.contextLength!==void 0||_.properties.maxOutputTokens!==void 0)?g.jsx("span",{className:"text-text-secondary mt-0.5 block truncate text-[10px]",children:[_.properties.contextLength===void 0?null:`${I6(_.properties.contextLength)} context`,_.properties.maxOutputTokens===void 0?null:`${I6(_.properties.maxOutputTokens)} output`].filter(E=>E!==null).join(" · ")}):null]}),l?null:g.jsx(g.Fragment,{children:g.jsx("span",{className:pe("text-text-secondary text-xs",k&&"text-primary-button-bg"),children:_.properties.contextLength===void 0?"—":I6(_.properties.contextLength)})}),k&&l?g.jsx(xe,{name:"check",className:"ml-auto size-3.5"}):null]},_.id||_.name)})]},b.name)})})]})}function yUt(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 Gf(e,t){return e??t?"on":"off"}function xUt(e){return e==="off"?"text-failure-bg font-medium":"text-primary-button-bg font-medium"}function wUt(e,{webSearchAvailable:t=!1}={}){var n,r,o,a,i,s,l,c,d;return[{label:"iteration limit",value:String((e==null?void 0:e.iterationLimit)??512)},{label:"sandbox",value:Gf((n=e==null?void 0:e.sandbox)==null?void 0:n.enabled,!1)},{label:"compaction",value:Gf((o=(r=e==null?void 0:e.contextManagement)==null?void 0:r.compaction)==null?void 0:o.enabled,!0)},{label:"large tool response",value:Gf((i=(a=e==null?void 0:e.contextManagement)==null?void 0:a.largeToolResponse)==null?void 0:i.enabled,!0)},{label:"dynamic sub-agents",value:Gf((s=e==null?void 0:e.dynamicSubAgents)==null?void 0:s.enabled,!0)},{label:"generative UI",value:Gf((l=e==null?void 0:e.generativeUi)==null?void 0:l.enabled,!0)},{label:"ask user questions",value:Gf((c=e==null?void 0:e.askUserQuestions)==null?void 0:c.enabled,!0)},...t?[{label:"web search",value:Gf((d=e==null?void 0:e.webSearch)==null?void 0:d.enabled,!0)}]:[]]}function yT(e){return typeof e=="string"&&e.length>0?e:void 0}function MZ(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0}function eC(e){return yT(Reflect.get(e,"skillRepoName"))}function OZ(e){return MZ(Reflect.get(e,"version"))}function Ia(e){return e.replace(/:\d+$/,"")}function _Ut(e){const t=/:(\d+)$/.exec(e);return t===null?void 0:MZ(Number(t[1]))}async function SUt(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=yT(Reflect.get(r,"name")),a=yT(Reflect.get(r,"displayName")),i=yT(Reflect.get(r,"description")),s=MZ(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 kUt({skill:e,selectedId:t,onChange:n}){const r=OZ(e),o=t===void 0?r:_Ut(t),[a,i]=w.useState(null),[s,l]=w.useState(!1),[c,d]=w.useState(null);if(r===void 0)return null;const p=()=>{a!==null||s||(l(!0),d(null),SUt(e).then(i).catch(f=>d(aa(f,"Failed to load versions."))).finally(()=>l(!1)))};return g.jsxs(of,{align:"end",onOpenChange:f=>{f&&p()},className:"max-h-64 min-w-40 overflow-y-auto",lockScroll:!0,trigger:g.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:[g.jsxs("span",{children:["v",o??r]}),o===r?g.jsx("span",{className:"text-primary-button-bg",children:"latest"}):null,g.jsx(xe,{name:"chevron-down",className:"size-3"})]}),children:[s?g.jsx("p",{className:"text-text-secondary px-2 py-1.5 text-xs",children:"Loading…"}):null,c?g.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1.5 text-xs",children:[g.jsx("p",{className:"text-failure-bg",children:"Failed to load versions."}),g.jsx("button",{type:"button",className:"text-text-secondary hover:text-text-primary shrink-0 underline",onClick:()=>{navigator.clipboard.writeText(c).catch(()=>{})},children:"Copy error"})]}):null,a==null?void 0:a.map(f=>g.jsxs(bp,{"aria-selected":f.id===t||t===void 0&&f.version===r,className:pe("justify-between",f.id===t&&"font-medium"),onClick:()=>n(f),children:[g.jsxs("span",{children:["v",f.version]}),f.version===r?g.jsx("span",{className:"text-primary-button-bg text-xs",children:"latest"}):null]},f.id)),!s&&c===null&&(a==null?void 0:a.length)===0?g.jsx("p",{className:"text-text-secondary px-2 py-1.5 text-xs",children:"No versions found."}):null]})}var EUt="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 TUt(e){return Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function AUt({item:e,onRemove:t,onTogglePreload:n}){const r=Nb(e.value),o=Q2(e.value),a=r==="all"?"All tools":`${r.length} tools`;return g.jsxs("span",{className:"flex items-center overflow-hidden rounded-md border border-border text-xs",children:[n?g.jsx(eo,{side:"bottom",dismissOnClick:!1,triggerClassName:"self-stretch",className:"w-64 whitespace-normal p-3 text-left shadow-lg",content:g.jsxs("span",{className:"flex flex-col gap-1.5",children:[g.jsxs("span",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"font-semibold",children:"Preload tools"}),g.jsx("span",{className:"text-primary-button-bg text-[0.625rem] font-semibold tracking-wide uppercase",children:o?"ON":"OFF"})]}),g.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:g.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:g.jsx(xe,{name:"book-open",className:"size-3.5"})})}):null,g.jsx("span",{className:"py-1 pl-2",children:e.name}),g.jsx("span",{className:"text-text-secondary ml-1 py-1",children:a}),t?g.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,className:Xt({variant:"ghost",size:"icon",className:"mx-1 size-5"}),onClick:i=>{i.stopPropagation(),t()},children:g.jsx(xe,{name:"xmark",className:"size-3"})}):g.jsx("span",{className:"pr-2"})]})}function CUt({item:e,preloadAvailable:t,onRemove:n,onTogglePreload:r}){const o=Q2(e.value);return g.jsxs("span",{className:"flex items-center overflow-hidden rounded-md border border-border text-xs",children:[t&&r?g.jsx(eo,{side:"bottom",dismissOnClick:!1,triggerClassName:"self-stretch",className:"w-64 whitespace-normal p-3 text-left shadow-lg",content:g.jsxs("span",{className:"flex flex-col gap-1.5",children:[g.jsxs("span",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"font-semibold",children:"Preload skill"}),g.jsx("span",{className:"text-primary-button-bg text-[0.625rem] font-semibold tracking-wide uppercase",children:o?"ON":"OFF"})]}),g.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:g.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:g.jsx(xe,{name:"book-open",className:"size-3.5"})})}):null,g.jsx("span",{className:"py-1 pl-2",children:e.name}),n?g.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,className:Xt({variant:"ghost",size:"icon",className:"mx-1 size-5"}),onClick:a=>{a.stopPropagation(),n()},children:g.jsx(xe,{name:"xmark",className:"size-3"})}):g.jsx("span",{className:"pr-2"})]})}function RUt({title:e,description:t,icon:n,actionIcon:r="pencil",actionLabel:o,onEdit:a,children:i}){const s=o??`Edit ${e}`;return g.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&&g.jsxs("div",{className:pe("flex items-start justify-between gap-3",i?"mb-3":null),children:[g.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n?g.jsx(xe,{name:n,className:"text-text-secondary mt-0.5 size-4 shrink-0"}):null,g.jsxs("div",{className:"min-w-0",children:[g.jsx("h3",{className:"text-text-primary text-sm font-semibold",children:e}),t?g.jsx("p",{className:"text-text-secondary mt-0.5 text-xs",children:t}):null]})]}),a?g.jsx("button",{type:"button","aria-label":s,title:s,className:Xt({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:g.jsx(xe,{name:r,className:"size-3.5"})}):null]}),i]})}function IUt({spec:e,model:t,models:n,modelsLoading:r,modelsError:o,skills:a=[],skillsAvailable:i,webSearchAvailable:s=!1,instructions:l,onOpenEditor:c,onChange:d,onClose:p,disabled:f=!1}){const m=We("AgentConfigSection"),b=We("AgentModelEditorContent"),y=We("AgentModelSettingsContent"),[x,_]=w.useState(!1),[k,E]=w.useState(!1),[T,C]=w.useState(""),A=Ov(e.mcpServers),R=Ov(e.skills),M=yUt(e.model.params),j=wUt(e.config,{webSearchAvailable:s}),O=l.trim(),P=jMe(e).length,D=[(t==null?void 0:t.properties.contextLength)===void 0?null:TUt(t.properties.contextLength)].filter(z=>z!==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(z=>z!==null).join(`
|
|
985
985
|
`);return g.jsxs("div",{className:"bg-card-bg text-text-primary flex h-full min-h-0 flex-col",children:[g.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:[g.jsx(xe,{name:"sliders",className:"size-4"}),g.jsx("h2",{className:"text-sm font-semibold",children:"Agent Config"}),g.jsx("span",{className:"min-w-0 flex-1"}),p?g.jsx("button",{type:"button","aria-label":"Close agent config",className:Xt({variant:"ghost",size:"icon",className:"size-8"}),onClick:p,children:g.jsx(xe,{name:"xmark"})}):null]}),g.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[g.jsxs(m,{children:[g.jsxs("div",{className:"flex w-full items-center gap-1",children:[g.jsx(Wge,{open:x,onOpenChange:z=>{_(z),z||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:g.jsxs("button",{type:"button","aria-label":"Edit Model",title:"Edit Model",disabled:f,className:"flex w-full cursor-pointer items-center gap-2 rounded-md py-1 text-left transition-colors",children:[g.jsx(hN,{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]"}),g.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:J2(e.model.name)}),D.length?g.jsx("span",{title:L,className:"text-text-secondary shrink-0 whitespace-nowrap text-[0.6875rem]",children:D.join(" · ")}):null,g.jsx(xe,{name:"chevrons-up-down",className:"text-text-secondary size-3.5 shrink-0"})]}),children:g.jsx(b,{spec:e,models:n,loading:r,error:o,query:T,onQueryChange:C,onChange:z=>{d==null||d(z),_(!1),C("")}})}),g.jsx(Wge,{open:k,onOpenChange:E,closeOnClick:!1,align:"start",sheetLabel:"Model settings",className:"w-[min(36rem,calc(100vw-2rem))] overflow-hidden p-0",trigger:g.jsx("button",{type:"button","aria-label":"Model settings",title:"Model settings",disabled:f,className:Xt({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),children:g.jsx(xe,{name:"sliders",className:"size-3.5"})}),children:g.jsx(y,{spec:e,model:t,onChange:z=>d==null?void 0:d(z)})})]}),g.jsx("button",{type:"button",disabled:f,"aria-label":"Edit model settings",onMouseDown:z=>z.stopPropagation(),onClick:()=>E(z=>!z),className:"mt-2 flex w-full cursor-pointer flex-col text-left disabled:cursor-not-allowed disabled:opacity-50",children:g.jsx("dl",{className:"text-text-secondary flex min-w-0 flex-wrap gap-x-3 gap-y-1 text-xs",children:M.length?M.map(z=>g.jsxs("div",{className:"flex gap-1",children:[g.jsxs("dt",{children:[z.label,":"]}),g.jsx("dd",{className:"text-text-primary font-medium",children:z.value})]},z.label)):g.jsx("div",{children:"model settings: defaults"})})})]}),g.jsx(m,{title:"Instructions",description:"Define the agent's role, goals, and behavior.",children:g.jsxs("button",{type:"button","aria-label":"Edit Instructions",disabled:f,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:()=>c("instructions"),children:[g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("p",{className:pe("line-clamp-3 whitespace-pre-wrap text-sm",O?"text-text-primary":"text-text-secondary"),children:O||EUt}),P>0?g.jsxs("p",{className:"text-text-secondary mt-2 text-xs",children:[P," user ",P===1?"message":"messages"]}):null]}),g.jsx(xe,{name:"chevron-right",className:"text-text-secondary size-4 shrink-0"})]})}),g.jsx(m,{title:"Runtime Config",description:"Control execution and context behavior.",actionIcon:"sliders",onEdit:f?void 0:()=>c("runtime"),children:g.jsx("dl",{className:"text-text-secondary flex flex-wrap gap-x-3 gap-y-1 text-xs leading-relaxed",children:j.map(z=>g.jsxs("div",{className:"flex gap-1",children:[g.jsxs("dt",{children:[z.label,":"]}),g.jsx("dd",{className:xUt(z.value),children:z.value})]},z.label))})}),g.jsx(m,{title:"MCP Servers",icon:"mcp-server",actionIcon:"plus",actionLabel:"Add MCP server",onEdit:f?void 0:()=>c("mcp"),children:A.length?g.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(z=>g.jsx(AUt,{item:z,onRemove:d&&!f?()=>d({...e,mcpServers:A.filter(F=>F.id!==z.id).map(F=>F.value)}):void 0,onTogglePreload:d&&!f?()=>d({...e,mcpServers:A.map(F=>F.id===z.id?Gge(F.value,!Q2(F.value)):F.value)}):void 0},z.id))}):null}),g.jsx(m,{title:"Skills",actionIcon:"plus",actionLabel:"Add skill",onEdit:f?void 0:()=>c("skills"),children:i?R.length?g.jsx("div",{className:"flex flex-wrap gap-1.5",children:R.map(z=>{const F=a.some($=>OZ($)!==void 0&&Ia($.id)===Ia(z.id));return g.jsx(CUt,{item:z,preloadAvailable:F,onRemove:d&&!f?()=>d({...e,skills:R.filter($=>$.id!==z.id).map($=>$.value)}):void 0,onTogglePreload:F&&d&&!f?()=>d({...e,skills:R.map($=>$.id===z.id?Gge($.value,!Q2($.value)):$.value)}):void 0},z.id)})}):g.jsx("p",{className:"text-text-secondary text-xs",children:"No skills selected."}):g.jsx("p",{className:"text-text-secondary text-xs",children:"Skills require an available sandbox."})})]})]})}function NUt(e){return typeof e=="string"?"string":typeof e=="number"?"number":"json"}function MUt(e,t){return t==="string"?typeof e=="string"?e:"":t==="number"?typeof e=="number"?String(e):"":JSON.stringify(e,null,2)??"null"}function f$(e){return{id:e,key:"",type:"string",value:""}}function OUt(e){return Object.entries(e).map(([t,n],r)=>{const o=NUt(n);return{id:`existing-${r}-${t}`,key:t,type:o,value:MUt(n,o)}})}function jUt(e){const t=OUt(e);return t.length>0?t:[f$("new-0")]}function FMe(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 Kge({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=FMe(e);return o.valid?null:o.error}function Yge(e){return e==="string"?"Aa":e==="number"?"#":"{ }"}function PUt({value:e,reservedKeys:t,onChange:n}){const r=We("CodeEditor"),[o,a]=w.useState(()=>jUt(e)),i=w.useRef(o.length),s=d=>{if(d.some(f=>Kge({draft:f,drafts:d,reservedKeys:t})!==null))return;const p=[];d.forEach(f=>{const m=FMe(f);m.valid&&p.push([f.key.trim(),m.value])}),n(Object.fromEntries(p))},l=({id:d,patch:p})=>{const f=o.map(m=>m.id===d?{...m,...p}:m);a(f),s(f)},c=d=>{const p=o.filter(m=>m.id!==d),f=`new-${i.current}`;i.current+=1,a(p.length>0?p:[f$(f)]),s(p)};return g.jsx("div",{className:"space-y-2",children:o.map(d=>{var m;const p=Kge({draft:d,drafts:o,reservedKeys:t}),f=d.key.trim()===""?null:p;return g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center",children:[g.jsxs("div",{className:pe("bg-secondary-button-bg flex min-w-0 flex-1 items-stretch overflow-hidden rounded-md border border-input-border",d.type==="json"&&"rounded-b-none",f&&"border-failure-bg"),children:[g.jsx("input",{value:d.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:d.id,patch:{key:b.target.value}})}),d.type!=="json"?g.jsx("input",{type:d.type==="number"?"number":"text",value:d.value,"aria-label":`Value for ${d.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:d.id,patch:{value:b.target.value}})}):null,g.jsx(of,{align:"end",className:"w-32",trigger:g.jsxs("button",{type:"button","aria-label":`Type for ${d.key||"custom parameter"}`,title:d.type==="string"?"String":d.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:[g.jsx("span",{children:Yge(d.type)}),g.jsx(xe,{name:"chevron-down",className:"size-3"})]}),children:["string","number","json"].map(b=>g.jsxs(bp,{"aria-selected":d.type===b,onClick:()=>l({id:d.id,patch:{type:b,value:b==="number"?"0":b==="json"?"{}":""}}),children:[g.jsx("span",{"aria-hidden":!0,className:"w-5 text-center font-semibold",children:Yge(b)}),b==="string"?"String":b==="number"?"Number":"JSON"]},b))})]}),g.jsxs("div",{className:"ml-3 flex items-center gap-3",children:[g.jsx("button",{type:"button","aria-label":`Remove ${d.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(d.id),children:g.jsx("span",{"aria-hidden":!0,children:"−"})}),g.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",d.id!==((m=o.at(-1))==null?void 0:m.id)&&"invisible"),onClick:()=>{const b=`new-${i.current}`;i.current+=1;const y=o.findIndex(_=>_.id===d.id),x=[...o];x.splice(y+1,0,f$(b)),a(x)},children:g.jsx(xe,{name:"plus",className:"size-3"})})]})]}),d.type==="json"?g.jsx(r,{value:d.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:d.id,patch:{value:b}})}}):null,f?g.jsx("p",{className:"text-failure-bg mt-1 text-xs",children:f}):null]},d.id)})})}function DUt(e){return e.filter(t=>t.content.trim().length>0).map(t=>({type:"user.message",content:t.content}))}function LUt({open:e,instructions:t,messages:n=[],onSave:r,onClose:o}){const a=w.useId(),i=w.useRef(n.length),[s,l]=w.useState(t),[c,d]=w.useState(()=>n.map((x,_)=>({id:_,content:x.content}))),p=x=>{d(x)},f=()=>{const x=[...c,{id:i.current,content:""}];i.current+=1,d(x)},m=({id:x,content:_})=>{p(c.map(k=>k.id===x?{id:x,content:_}:k))},b=x=>{p(c.filter(_=>_.id!==x))},y=()=>{r({instructions:s,messages:DUt(c)}),o()};return g.jsx(uN,{open:e,onOpenChange:x=>!x&&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:g.jsx("div",{className:"flex justify-end",children:g.jsx(In.Primary,{type:"button",onClick:y,children:"Save"})}),children:g.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-6 p-5",children:[g.jsxs("section",{children:[g.jsx("label",{htmlFor:`${a}-instructions`,className:"text-text-primary text-sm font-semibold",children:"Agent instructions"}),g.jsx("p",{className:"text-text-secondary mt-1 text-xs",children:"Describe the agent's role, goals, and constraints."}),g.jsx("textarea",{id:`${a}-instructions`,value:s,rows:14,placeholder:"Enter detailed instructions for your agent…",className:Bo("mt-3 min-h-64 resize-y py-3"),onChange:x=>l(x.target.value)})]}),g.jsxs("section",{className:"border-border border-t pt-5",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsxs("div",{children:[g.jsx("h3",{className:"text-text-primary text-sm font-semibold",children:"User Messages"}),g.jsx("p",{className:"text-text-secondary mt-1 text-xs",children:"Add initial messages to every new agent session."})]}),g.jsxs(In.Secondary,{type:"button",size:"small",onClick:f,children:[g.jsx(xe,{name:"plus",className:"size-3.5"}),"Add User Message"]})]}),c.length>0?g.jsx("div",{className:"mt-4 flex flex-col gap-4",children:c.map((x,_)=>{const k=`${a}-user-message-${x.id}`;return g.jsxs("div",{className:"border-border rounded-lg border p-3",children:[g.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[g.jsx(xe,{name:"user",className:"text-text-secondary size-4"}),g.jsxs("label",{htmlFor:k,className:"text-text-primary flex-1 text-sm font-medium",children:["User Message ",_+1]}),g.jsx("button",{type:"button","aria-label":`Remove User Message ${_+1}`,className:Xt({variant:"ghost",size:"icon",className:"size-7"}),onClick:()=>b(x.id),children:g.jsx(xe,{name:"trash",className:"size-3.5"})})]}),g.jsx("textarea",{id:k,value:x.content,rows:4,placeholder:"Type message content…",className:Bo("min-h-24 resize-y py-2"),onChange:E=>m({id:x.id,content:E.target.value})})]},x.id)})}):g.jsx("p",{className:"text-text-secondary mt-4 text-sm",children:"No initial user messages."})]})]})})}var UMe="truefoundry-mcp-auth-popup",zUt=()=>`mcp-oauth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,$Ut=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.popupUid=="string"&&typeof t.isSuccess=="boolean"},BMe=({callbackPath:e}={})=>{const{connectorCatalog:t}=N$e(),n=ui(),r=sN(),[o,a]=w.useState(0),i=w.useRef(new Set),s=w.useRef(new Set);w.useEffect(()=>{const f=i.current,m=s.current;return()=>{f.clear();for(const b of m)b();m.clear()}},[]);const l=w.useCallback(async f=>(n==null?void 0:n.getMcpConnector)!==void 0?n.getMcpConnector({connectorId:f}):t.getConnector({id:f}),[t,n]),c=w.useCallback(async({integrationId:f,callback:m,attempt:b})=>{try{const y=await l(f);if(!i.current.has(b))return;if(!y.authenticated)throw new Error("The MCP server is not authenticated yet. Please try again.");m(!0)}catch(y){if(!i.current.has(b))return;r==null||r.showError(y),m(!1)}},[l,r]),d=w.useCallback(({authorizationEndpoint:f,integrationId:m,callback:b,attempt:y,popupUid:x})=>{const _=new BroadcastChannel(UMe);let k=null;const E=()=>{_.close(),s.current.delete(T)},T=()=>{E(),k==null||k.close()};if(_.onmessage=C=>{if(!$Ut(C.data)||C.data.popupUid!==x)return;const{isSuccess:A}=C.data;if(E(),!A){i.current.delete(y)&&b(!1);return}c({integrationId:m,callback:b,attempt:y}).finally(()=>{i.current.delete(y)})},s.current.add(T),k=window.open(f,"_blank","popup=true"),!k)throw T(),new Error("Popup blocked. Please allow pop-ups to authorize the MCP server.");k.focus()},[c]);return{handleAuthorize:w.useCallback(async(f,m)=>{var _;if(!f)return;const b={},y=zUt();i.current.add(b),a(k=>k+1);let x=!1;try{const k=e?new URL(e,window.location.origin):new URL(window.location.href);k.searchParams.set("screenType","mcp-auth"),k.searchParams.set("integrationId",f),k.searchParams.set("pUid",y);const E=await t.authenticateConnector({id:f,returnTo:`${k.pathname}${k.search}`});if(!i.current.has(b))return;if("status"in E&&((_=E.status)==null?void 0:_.toUpperCase())==="AUTHENTICATED"||"authenticated"in E&&E.authenticated){await c({integrationId:f,callback:m,attempt:b});return}const T="authorization_endpoint"in E?E.authorization_endpoint:void 0;if(!T)throw new Error("The MCP server did not return an authorization URL.");d({authorizationEndpoint:T,integrationId:f,callback:m,attempt:b,popupUid:y}),x=!0}catch(k){if(!i.current.has(b))return;r==null||r.showError(k),m(!1)}finally{i.current.has(b)&&a(k=>k-1),x||i.current.delete(b)}},[e,t,d,c,r]),isOAuthLoading:o>0}};function jZ({checked:e,className:t}){return g.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?g.jsx(xe,{name:"check",className:"size-3"}):null})}var FUt={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 Mb({checked:e,onCheckedChange:t,size:n="sm",disabled:r,className:o,...a}){const i=FUt[n];return g.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:g.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 UUt({connector:e}){const t=Reflect.get(e,"logo");return typeof t=="string"&&t.trim()!==""?g.jsx(NZ,{src:t,alt:"",className:"size-4 shrink-0 object-contain","aria-hidden":!0}):g.jsx(xe,{name:"mcp-server",className:"text-text-secondary size-4 shrink-0"})}function Zge(e){return e.length===0?"0":e.every(n=>Nb(n.value)==="all")?"All":`${e.reduce((n,r)=>{const o=Nb(r.value);return o==="all"?n:n+o.length},0)}`}function Xge(){return g.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:[g.jsx(xe,{name:"shield-check",className:"size-2.5"}),"approval"]})}function BUt({approvalRequired:e,toolName:t,onToggle:n}){return g.jsx(eo,{side:"bottom",dismissOnClick:!1,className:"w-64 whitespace-normal p-3 text-left shadow-lg",content:g.jsxs("span",{className:"flex flex-col gap-1.5",children:[g.jsxs("span",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"font-semibold",children:"Require approval"}),g.jsx("span",{className:"text-primary-button-bg text-[0.625rem] font-semibold tracking-wide uppercase",children:e?"ON":"OFF"})]}),g.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:g.jsx("button",{type:"button","aria-pressed":e,"aria-label":`Require approval for ${t}`,className:Xt({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:g.jsx(xe,{name:e?"shield-check":"shield"})})})}function HUt({connectorId:e,onConnected:t}){const{handleAuthorize:n,isOAuthLoading:r}=BMe();return g.jsx(In.Primary,{type:"button",className:"min-w-44",disabled:r,onClick:()=>{n(e,o=>{o&&t()})},children:r?"Connecting...":"Connect Now"})}function VUt({spec:e,connectors:t,query:n,activeConnectorId:r,tools:o,toolsByConnector:a={},connectorLoading:i,connectorError:s,toolsLoading:l,toolsError:c,onQueryChange:d,onSelectConnector:p,onRetryTools:f,onRefreshConnector:m,onChange:b}){const[y,x]=w.useState(""),[_,k]=w.useState(()=>new Set),[E]=w.useState(()=>{const q=new Set;for(const te of Ov(e.mcpServers))q.add(te.id),q.add(te.name);return q}),T=Ov(e.mcpServers),C=IZ({connectors:t,selected:T}),A=C.find(q=>q.id===r),R=A?T.find(q=>q.id===A.id||q.name===A.name):void 0,M=(A==null?void 0:A.authenticated)===!1,j=A!==void 0&&A.authenticated===!0,O=R?Nb(R.value):[],P=n.trim().toLowerCase(),D=C.filter(q=>`${q.name} ${q.description??""}`.toLowerCase().includes(P)).sort((q,te)=>{const ye=E.has(q.id)||E.has(q.name),Me=E.has(te.id)||E.has(te.name);return Number(Me)-Number(ye)}),L=y.trim().toLowerCase(),z=L===""?o:o.filter(q=>q.name.toLowerCase().includes(L)),F=Bge(z),$=Bge(o),H=R?CE(R.value):[...Mv],V=vT({tools:o,selectors:H}),Y={...a,...r!==null&&o.length>0?{[r]:o}:{}},U=q=>{var ye;const te=(ye=C.find(Me=>Me.id===q.id||Me.name===q.name))==null?void 0:ye.id;return Y[q.id]??(te===void 0?void 0:Y[te])??[]},X=T.reduce((q,te)=>{const ye=CE(te.value),Me=U(te),Oe=Nb(te.value);return Oe==="all"?q+vT({tools:Me,selectors:ye}).size:q+Oe.filter(qe=>Vge({toolName:qe,tools:Me,selectors:ye})).length},0),J=(q,te)=>{b({...e,mcpServers:T.map(ye=>ye.id===q?te:ye.value)})},K=q=>{b({...e,mcpServers:T.filter(te=>te.id!==q).map(te=>te.value)})},G=q=>{const te=C.find(ye=>ye.id===q.id||ye.name===q.name);p((te==null?void 0:te.id)??q.id)},Q=({next:q,newlyEnabledNames:te,baseValue:ye})=>{let Me=AE(ye,q);return te.length>0&&o.length>0&&(Me=R6(Me,dUt({tools:o,selectors:CE(Me),newlyEnabledNames:te}))),Me},ne=({next:q,newlyEnabledNames:te=[]})=>{if(A){if(q.length===0){R&&K(R.id);return}if(R){J(R.id,Q({next:q,newlyEnabledNames:te,baseValue:R.value}));return}j&&b({...e,mcpServers:[...e.mcpServers??[],Q({next:q,newlyEnabledNames:te,baseValue:{id:A.id,name:A.name}})]})}},de=q=>{if(!A)return;if(!R){if(!j)return;ne({next:[q],newlyEnabledNames:[q]});return}const te=O==="all"?o.map(Oe=>Oe.name):O,ye=te.includes(q),Me=ye?te.filter(Oe=>Oe!==q):[...te,q];ne({next:Me,newlyEnabledNames:ye?[]:[q]})},se=({sectionId:q,enabled:te})=>{const ye=$[q].map(Oe=>Oe.name);if(!A||ye.length===0)return;if(te){if(O==="all")return;const Oe=R?[...O]:[],qe=[];for(const Ge of ye)Oe.includes(Ge)||(Oe.push(Ge),qe.push(Ge));ne({next:Oe,newlyEnabledNames:qe});return}const Me=O==="all"?o.map(Oe=>Oe.name):O;ne({next:Me.filter(Oe=>!ye.includes(Oe))})},oe=({toolNames:q,required:te})=>{if(!R||q.length===0||o.length===0)return;const ye=new Set(V);for(const Me of q)te?ye.add(Me):ye.delete(Me);J(R.id,R6(R.value,DMe({tools:o,approved:ye})))},re=()=>{!A||R!==void 0||b({...e,mcpServers:[...e.mcpServers??[],R6(AE({id:A.id,name:A.name},"all"),Mv)]})};return g.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:[g.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:[g.jsxs("label",{className:"relative m-3 block shrink-0",children:[g.jsx(xe,{name:"search",className:"text-text-secondary absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),g.jsx("input",{value:n,onChange:q=>d(q.target.value),placeholder:"Search MCP",className:Bo("h-8 w-full pl-7")})]}),g.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:D.map(q=>{const te=T.some(Me=>Me.id===q.id||Me.name===q.name),ye=q.id===r;return g.jsxs("button",{type:"button","aria-current":ye?"true":void 0,"aria-label":q.name,className:pe("flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-left",ye?"bg-primary-button-bg/10":"hover:bg-ghost-button-hover"),onClick:()=>p(q.id),children:[g.jsx(UUt,{connector:q}),g.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm font-medium",children:q.name}),te?g.jsx("span",{className:"bg-success-bg text-success-text flex size-3 shrink-0 items-center justify-center rounded-full","aria-label":`${q.name} selected`,children:g.jsx(xe,{name:"check",className:"size-2"})}):null]},q.id)})})]}),g.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:A?i?g.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-3","aria-label":"Loading MCP server",children:g.jsx(Gs,{size:20,className:"text-text-secondary"})}):s?g.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center p-6 text-center",children:[g.jsx("p",{className:"text-failure-bg text-sm",children:s}),g.jsx(In.Secondary,{type:"button",size:"small",className:"mt-2",onClick:f,children:"Retry"})]}):M?g.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-4 p-6 text-center",children:[g.jsx(xe,{name:"lock",className:"text-text-secondary size-10"}),g.jsx("p",{className:"text-text-primary text-sm font-semibold",children:"You're not connected to this MCP Server"}),m?g.jsx(HUt,{connectorId:A.id,onConnected:m}):null,g.jsxs("div",{className:"text-text-secondary flex w-full max-w-xs items-center gap-3 text-xs",children:[g.jsx("span",{className:"bg-border h-px flex-1"}),"OR",g.jsx("span",{className:"bg-border h-px flex-1"})]}),g.jsx(In.Secondary,{type:"button",className:"min-w-44",disabled:R!==void 0,onClick:re,children:"Connect During Chat"})]}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border p-3",children:[g.jsxs("p",{className:"min-w-0 truncate text-sm font-semibold",children:[A.name," Tools (",o.length,")"]}),g.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",g.jsx(Mb,{checked:R!==void 0&&O==="all",disabled:!j&&R===void 0,onCheckedChange:q=>{R?q?J(R.id,AE(R.value,"all")):K(R.id):q&&j&&b({...e,mcpServers:[...e.mcpServers??[],AE({id:A.id,name:A.name},"all")]})},"aria-label":"Enable all tools"})]})]}),g.jsxs("label",{className:"relative m-3 block shrink-0",children:[g.jsx(xe,{name:"search",className:"text-text-secondary absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),g.jsx("input",{value:y,onChange:q=>x(q.target.value),placeholder:"Search Tools",className:Bo("h-8 w-full pl-7")})]}),g.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[l?g.jsx("div",{className:"flex h-full min-h-24 items-center justify-center p-3","aria-label":"Loading tools",children:g.jsx(Gs,{size:20,className:"text-text-secondary"})}):null,c?g.jsxs("div",{className:"p-3",children:[g.jsx("p",{className:"text-failure-bg text-sm",children:c}),g.jsx(In.Secondary,{type:"button",size:"small",className:"mt-2",onClick:f,children:"Retry"})]}):null,l?null:iUt.map(q=>{const te=F[q];if(te.length===0)return null;const ye=F["read-only"].length===0&&F.destructive.length===0,Me=q!=="others"||!ye,Oe=$[q].map(Ke=>Ke.name),qe=Oe.length>0&&(O==="all"||Oe.every(Ke=>O.includes(Ke))),Ge=O==="all"?Oe:Oe.filter(Ke=>O.includes(Ke)),Ye=Ge.length>0&&Ge.every(Ke=>V.has(Ke)),Rt=q==="others"||q==="destructive"?cUt[q]:void 0;return g.jsxs("div",{className:"mb-3",children:[Me?g.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-2",children:[g.jsx("p",{className:pe("min-w-0 truncate text-sm font-semibold",q==="destructive"?"text-failure-bg":"text-text-primary"),children:sUt[q]}),g.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[Rt===void 0||Ge.length===0?null:g.jsxs("label",{className:"text-text-secondary flex shrink-0 cursor-pointer items-center gap-2 text-xs",children:["Approval required",g.jsx(Mb,{checked:Ye,onCheckedChange:Ke=>oe({toolNames:Ge,required:Ke}),"aria-label":Rt})]}),g.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",g.jsx(Mb,{checked:qe,disabled:!j&&R===void 0,onCheckedChange:Ke=>se({sectionId:q,enabled:Ke}),"aria-label":lUt[q]})]})]})]}):null,te.map(Ke=>{const De=O==="all"||O.includes(Ke.name),Be=Qh({tool:Ke,selectors:H});return g.jsxs("div",{className:"hover:bg-ghost-button-hover flex w-full items-center gap-1 rounded-md pr-2",children:[g.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":De,"aria-label":Ke.name,disabled:!j&&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:()=>de(Ke.name),children:[g.jsx(jZ,{checked:De}),g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:"text-text-primary block truncate text-sm font-medium",children:Ke.name}),Ke.description?g.jsx("span",{className:"text-text-secondary line-clamp-1 text-xs",children:Ke.description}):null]})]}),De?g.jsx(BUt,{approvalRequired:Be,toolName:Ke.name,onToggle:()=>oe({toolNames:[Ke.name],required:!Be})}):null]},Ke.id)})]},q)})]})]}):g.jsx("p",{className:"text-text-secondary p-4 text-sm",children:"Select an MCP server to configure its tools."})}),g.jsxs("div",{className:"flex max-h-44 min-h-0 min-w-0 flex-col md:max-h-none",children:[g.jsxs("div",{className:"shrink-0 border-b border-border p-3",children:[g.jsxs("p",{className:"text-sm font-semibold",children:["Selected Tools (",Zge(T),")"]}),T.length?g.jsxs("p",{className:"text-text-secondary mt-0.5 text-xs",children:[Zge(T)," selected · ",X," need approval"]}):null]}),g.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:T.length?g.jsx("div",{className:"space-y-1",children:T.map(q=>{const te=Nb(q.value),ye=CE(q.value),Me=U(q);return g.jsxs("details",{className:"group/mount",open:!_.has(q.id),onToggle:Oe=>{const qe=Oe.currentTarget.open;k(Ge=>{const Ye=new Set(Ge);return qe?Ye.delete(q.id):Ye.add(q.id),Ye})},children:[g.jsxs("summary",{className:"hover:bg-ghost-button-hover flex cursor-pointer list-none items-center gap-1 rounded-md [&::-webkit-details-marker]:hidden",onClick:()=>G(q),children:[g.jsx(xe,{name:"chevron-down",className:"text-text-secondary size-3.5 shrink-0 -rotate-90 transition-transform group-open/mount:rotate-0"}),g.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-xs font-semibold",children:q.name}),g.jsxs("span",{className:"relative flex size-6 shrink-0 items-center justify-center",children:[g.jsx("span",{className:"text-text-secondary text-xs font-medium group-hover/mount:invisible group-focus-within/mount:invisible",children:te==="all"?"All":te.length}),g.jsx(eo,{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:g.jsx("button",{type:"button","aria-label":`Remove all tools for ${q.name}`,className:Xt({variant:"ghost",size:"icon",className:"text-text-secondary size-6"}),onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),K(q.id)},children:g.jsx(xe,{name:"xmark",className:"size-3.5"})})})]})]}),te==="all"?g.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:()=>G(q),children:[g.jsx(xe,{name:"wrench",className:"size-3 shrink-0"}),g.jsx("span",{className:"min-w-0 flex-1 truncate",children:"ALL TOOLS ENABLED"}),vT({tools:Me,selectors:ye}).size>0?g.jsx(Xge,{}):null]}):te.length?te.map(Oe=>g.jsxs("button",{type:"button","aria-label":`Open ${q.name} for ${Oe}`,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:()=>G(q),children:[g.jsx(xe,{name:"wrench",className:"text-text-secondary size-3 shrink-0"}),g.jsx("span",{className:"min-w-0 flex-1 truncate",children:Oe}),Vge({toolName:Oe,tools:Me,selectors:ye})?g.jsx(Xge,{}):null]},`${q.id}:${Oe}`)):g.jsx("p",{className:"text-text-secondary px-2 py-1.5 pl-7 text-[0.6875rem]",children:"No tools selected."})]},q.id)})}):g.jsx("p",{className:"text-text-secondary p-4 text-center text-sm",children:"No tools selected."})})]})]})}function PZ({open:e,onOpenChange:t,title:n,description:r,headerIcon:o,children:a,footer:i,className:s,contentSized:l=!1,"aria-label":c}){const d=w.useRef(null),p=w.useId(),f=w.useId(),m=ld(),b=_Z(d,m,l);return w.useEffect(()=>{const y=d.current;y&&(e&&!y.open?y.showModal():!e&&y.open&&y.close())},[e]),w.useEffect(()=>{const y=d.current;if(!y)return;const x=()=>t(!1);return y.addEventListener("close",x),()=>y.removeEventListener("close",x)},[t]),g.jsxs("dialog",{ref:d,"aria-label":c??n,"aria-labelledby":p,"aria-describedby":r?f:void 0,onCancel:y=>{y.preventDefault(),y.stopPropagation(),t(!1)},style:b??(l?{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",m?"m-0 mt-auto max-w-none rounded-t-xl rounded-b-none border-t pb-[env(safe-area-inset-bottom)]":l?"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"),s),children:[g.jsxs("header",{className:"bg-topbar-bg flex shrink-0 items-center gap-3 border-b border-border px-5 py-4",children:[o,g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("h2",{id:p,className:"text-text-primary text-lg font-semibold tracking-tight",children:n}),r?g.jsx("p",{id:f,className:"text-text-secondary mt-1 text-sm",children:r}):null]}),g.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:Xt({variant:"ghost",size:"icon"}),onClick:()=>t(!1),children:g.jsx(xe,{name:"xmark"})})]}),g.jsx("div",{className:"flex min-h-0 flex-auto flex-col overflow-x-hidden overflow-y-auto",children:a}),i?g.jsx("div",{className:"shrink-0 border-t border-border px-5 py-3",children:i}):null]})}function GUt({editor:e,spec:t,models:n,loading:r,error:o,query:a,onQueryChange:i,onChange:s,onClose:l}){const c=We("AgentModelEditorContent"),d=We("AgentModelSettingsContent"),p=w.useMemo(()=>n.find(m=>m.name===t.model.name),[n,t.model.name]),f=e==="model";return g.jsx(PZ,{open:e!==null,onOpenChange:m=>!m&&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?g.jsx(c,{spec:t,models:n,loading:r,error:o,query:a,onQueryChange:i,onChange:s}):g.jsx(d,{spec:t,model:p,onChange:s})})}function h$(e){return Array.isArray(e)&&e.length>0}function HMe(e,t){if(h$(e))return t&&e.includes(t)?t:e.find(n=>n!=="none")??e[0]}function jv(e,t,n){const r=HMe(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 qge(e,t){var o;const n=jv(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 WUt({spec:e,models:t,loading:n,error:r,query:o,onQueryChange:a,onChange:i}){const s=w.useId(),l=ld(),c=w.useMemo(()=>t.find(R=>R.name===e.model.name),[t,e.model.name]),d=w.useMemo(()=>Array.from(new Set(t.map(R=>R.provider.name))),[t]),[p,f]=w.useState((c==null?void 0:c.provider.name)??d[0]??""),[m,b]=w.useState(null),y=V_(o),x=w.useMemo(()=>d.map(R=>{const M=t.filter(j=>j.provider.name===R);return{name:R,models:$Me({providerName:R,needle:y})?M:M.filter(j=>d$({model:j,needle:y}))}}).filter(R=>R.models.length>0),[t,y,d]),_=w.useMemo(()=>x.map(R=>R.name),[x]),k=w.useMemo(()=>_.includes(p)?p:c&&_.includes(c.provider.name)?c.provider.name:_[0]??"",[p,c,_]),E=w.useMemo(()=>{var R;return((R=x.find(M=>M.name===k))==null?void 0:R.models)??[]},[k,x]),T=w.useMemo(()=>{if(m===null)return[];const R=t.filter(M=>M.provider.name===m);return y?R.filter(M=>d$({model:M,needle:y})):R},[m,t,y]),C=w.useCallback(()=>{a(""),b(null)},[a]),A=g.jsxs("label",{className:"relative block",children:[g.jsx(xe,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),g.jsx("input",{type:"search",value:o,onChange:R=>a(R.target.value),placeholder:"Search",className:Bo("h-8 py-1 pr-2 pl-7"),autoFocus:!0})]});return l?m===null?g.jsxs("div",{className:"flex min-h-0 flex-auto flex-col",children:[g.jsxs("div",{className:"shrink-0 border-b border-border px-3 py-2",children:[g.jsx("p",{className:"text-text-primary mb-2 text-base font-medium",children:"Select provider"}),A]}),r?g.jsx("p",{className:"text-failure-bg px-3 pt-3 text-sm",children:r}):null,g.jsx("div",{className:"min-h-0 flex-auto overflow-y-auto p-2",children:_.length===0?g.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-sm",role:"status",children:n?"Loading…":"No providers"}):_.map(R=>{const M=t.find(j=>j.provider.name===R);return g.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:[g.jsx(hN,{logo:M==null?void 0:M.provider.logo,label:R,className:"size-5 text-xs"}),g.jsx("span",{className:"min-w-0 flex-1 truncate",children:R}),g.jsx(xe,{name:"chevron-right",className:"text-text-secondary size-4 shrink-0"})]},R)})})]}):g.jsxs("div",{className:"flex min-h-0 flex-auto flex-col",children:[g.jsxs("div",{className:"shrink-0 border-b border-border px-3 py-2",children:[g.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[g.jsx("button",{type:"button","aria-label":"Back to providers",title:"Back to providers",className:Xt({variant:"ghost",size:"icon",className:"size-7 shrink-0"}),onClick:C,children:g.jsx(xe,{name:"arrow-left",className:"size-4"})}),g.jsx("p",{className:"text-text-primary min-w-0 flex-1 truncate text-base font-medium",children:"Select Model"})]}),A]}),r?g.jsx("p",{className:"text-failure-bg px-3 pt-3 text-sm",children:r}):null,g.jsx(p$,{models:T,loading:n,selectedName:e.model.name,query:"",onQueryChange:a,listboxId:s,showHeading:!1,showSearch:!1,onSelect:R=>i({...e,model:qge(e,R)})})]}):g.jsxs("div",{children:[g.jsxs("div",{className:"border-b border-border px-3 py-2",children:[g.jsx("p",{className:"text-text-primary mb-2 text-base font-medium",children:"Select model"}),A]}),r?g.jsx("p",{className:"text-failure-bg px-3 pt-3 text-sm",children:r}):null,g.jsxs("div",{className:"grid h-[min(22rem,calc(100dvh-8rem))] w-full min-w-0 grid-cols-[13rem_minmax(0,1fr)] overflow-hidden",children:[g.jsx("div",{className:"min-h-0 overflow-y-auto border-r border-border p-2",children:_.map(R=>g.jsx("button",{type:"button",className:pe("text-text-secondary mb-1 w-full truncate rounded-md px-2 py-2 text-left text-xs",k===R&&"bg-primary-button-bg/10 border border-primary-button-bg font-medium text-primary-button-bg"),onClick:()=>f(R),children:R},R))}),g.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:g.jsx(p$,{models:E,loading:n,selectedName:e.model.name,query:o,onQueryChange:a,listboxId:s,showHeading:!1,showSearch:!1,onSelect:R=>i({...e,model:qge(e,R)})})})]})]})}var VMe=(e=>(e.UI="ui",e.JSON="json",e))(VMe||{}),GMe=new Set(["maxTokens","reasoningEffort"]);function Qge(e){if(e.trim()==="")return null;const t=Number(e);return Number.isFinite(t)?t:null}function KUt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function YUt(e){if(!KUt(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 ux(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>!GMe.has(t)&&n!==void 0))}function Jge(e){return JSON.stringify(e,null,2)}function ZUt({spec:e,model:t,onChange:n}){const r=We("CodeEditor"),o=We("AgentCustomParametersEditor"),a=e.model.params??{},[i,s]=w.useState("ui"),[l,c]=w.useState(()=>Jge(a)),[d,p]=w.useState(null),[f,m]=w.useState(()=>Object.keys(ux(a)).length>0),b=w.useRef(null),y=P=>n({...e,model:{...e.model,params:P}}),x=(P,D)=>y({...a,[P]:D}),_=P=>y({...a,[P]:void 0}),k=P=>{const D=Object.fromEntries(Object.keys(ux(a)).map(L=>[L,void 0]));y({...a,...D,...P})},E=P=>{const D=Object.fromEntries(Object.keys(a).filter(L=>!Object.hasOwn(P,L)).map(L=>[L,void 0]));y({...D,...P})},T=P=>{s(P),p(null),P==="json"&&c(Jge(a))},C=P=>{if(P!==void 0){c(P);try{const D=JSON.parse(P);if(!YUt(D)){p("Parameters must be a JSON object with valid model parameter values.");return}p(null),m(Object.keys(ux(D)).length>0),E(D)}catch{p("Invalid JSON.")}}},A=()=>{const P=!f;if(m(P),P){k(b.current??{});return}b.current=ux(a),k({})},R=t==null?void 0:t.properties.maxOutputTokens,M=(t==null?void 0:t.properties.reasoningEfforts)??[],j=M[0],O=[];return j!==void 0&&O.push({label:"Reasoning Effort",enabled:a.reasoningEffort!==void 0,onToggle:P=>P?x("reasoningEffort",j):_("reasoningEffort"),control:g.jsx("select",{value:a.reasoningEffort??"","aria-label":"Reasoning effort value",className:Bo("h-8 cursor-pointer py-1.5"),onChange:P=>x("reasoningEffort",P.target.value),children:M.map(P=>g.jsx("option",{value:P,children:P},P))})}),R!==void 0&&O.push({label:"Maximum Tokens",enabled:a.maxTokens!==void 0,onToggle:P=>P?x("maxTokens",R):_("maxTokens"),control:g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("input",{type:"range",min:1,max:R,value:a.maxTokens??R,"aria-label":"Maximum tokens slider",className:"min-w-0 flex-1 accent-primary-button-bg",onChange:P=>{const D=Qge(P.target.value);D!==null&&x("maxTokens",D)}}),g.jsx("input",{type:"number",min:1,max:R,value:a.maxTokens??R,"aria-label":"Maximum tokens value",className:Bo("h-8 w-24"),onChange:P=>{const D=Qge(P.target.value);D!==null&&x("maxTokens",Math.max(1,Math.min(R,D)))}})]})}),g.jsxs("div",{className:"w-full",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-3",children:[g.jsx("h3",{className:"text-text-primary text-sm font-semibold",children:"Parameters"}),g.jsx("div",{className:"bg-secondary-button-bg flex rounded-md border border-input-border p-0.5",children:Object.values(VMe).map(P=>g.jsx("button",{type:"button","aria-pressed":i===P,className:pe("min-w-10 rounded px-2 py-1 text-xs font-medium transition-colors",i===P?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:text-text-primary"),onClick:()=>T(P),children:P==="ui"?"UI":"JSON"},P))})]}),i==="ui"?g.jsx("div",{className:"max-h-[min(30rem,calc(100dvh-8rem))] overflow-y-auto px-4",children:g.jsxs("div",{className:"divide-y divide-border",children:[O.map(P=>g.jsxs("div",{className:"py-3",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"text-text-primary text-sm font-medium",children:P.label}),g.jsx("button",{type:"button","aria-label":`Turn ${P.label} ${P.enabled?"off":"on"}`,"aria-pressed":P.enabled,className:Xt({variant:"ghost",size:"small"}),onClick:()=>P.onToggle(!P.enabled),children:P.enabled?"On":"Off"})]}),P.enabled?g.jsx("div",{className:"mt-2",children:P.control}):null]},P.label)),g.jsxs("div",{className:"py-3",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"text-text-primary text-sm font-medium",children:"Custom Parameters"}),g.jsx("button",{type:"button","aria-label":`Turn Custom Parameters ${f?"off":"on"}`,"aria-pressed":f,className:Xt({variant:"ghost",size:"small"}),onClick:A,children:f?"On":"Off"})]}),f?g.jsx("div",{className:"mt-3 mb-2",children:g.jsx(o,{value:ux(a),reservedKeys:GMe,onChange:k})}):null]})]})}):g.jsxs("div",{className:"min-h-88 p-4",children:[g.jsx(r,{value:l,language:"json",height:"20rem",showToolbar:!1,className:pe("h-80",d&&"border-failure-bg"),onChange:C}),d?g.jsx("p",{className:"text-failure-bg mt-2 text-sm font-medium",children:d}):null]})]})}function XUt({editor:e,onClose:t,...n}){const r=We("AgentResourceEditorContent"),o=e==="mcp";return g.jsx(PZ,{open:e!==null,onOpenChange:a=>!a&&t(),title:o?"Select MCP Tools":"Skills",className:o?"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":o?"Select MCP Tools":"Edit skills",footer:o?g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsxs("p",{className:"text-text-secondary flex min-w-0 items-center gap-1.5 text-xs",children:[g.jsx(xe,{name:"shield-check",className:"text-warning-bg size-3.5 shrink-0"}),g.jsx("span",{className:"min-w-0",children:"Shielded tools always ask before the agent runs them."})]}),g.jsx(In.Primary,{type:"button",onClick:t,children:"Save"})]}):void 0,children:e?g.jsx(r,{editor:e,...n}):null})}function qUt(e){const t=We("AgentMcpEditorContent"),n=We("AgentSkillsEditorContent");return e.editor==="skills"?g.jsx(n,{spec:e.spec,skills:e.skills,skillsDisabled:e.skillsDisabled,query:e.query,onQueryChange:e.onQueryChange,onChange:e.onChange}):g.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})}function QUt({open:e,spec:t,sandboxAvailable:n,webSearchAvailable:r=!1,onChange:o,onClose:a}){const i=We("AgentRuntimeEditorContent");return g.jsx(uN,{open:e,onOpenChange:s=>!s&&a(),title:"Runtime Config",description:"Control execution, sandbox, and context behavior.",anchor:"right",size:"xl",className:"md:w-3xl","aria-label":"Edit Runtime Config",children:g.jsx(i,{spec:t,sandboxAvailable:n,webSearchAvailable:r,onChange:o})})}async function JUt({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 WMe(){const e=x7(),t=vo(),n=(t==null?void 0:t.environmentsListEpoch)??0,r=(t==null?void 0:t.environmentsOpen)??!1,[o,a]=w.useState([]),[i,s]=w.useState(!1),[l,c]=w.useState(null),d=w.useRef(0),p=w.useRef(r),f=w.useCallback(async()=>{if(!e){a([]),s(!1),c(null);return}const m=++d.current;s(!0),c(null);try{const b=await JUt({fetchPage:x=>e.listEnvironments({limit:1e3,pageToken:x})});if(m!==d.current)return;const y=b.filter(x=>x.status==="ready");a(y)}catch(b){if(m!==d.current)return;c(aa(b,"Failed to load sandbox environments.")),a([])}finally{m===d.current&&s(!1)}},[e]);return w.useEffect(()=>{f()},[f,n]),w.useEffect(()=>{p.current&&!r&&f(),p.current=r},[r,f]),{environments:o,loading:i,error:l,refetch:f}}function eme(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 eBt(e){if(e.trim()==="")return null;const t=Number(e);return Number.isInteger(t)&&t>0?t:null}var tme="No sandbox provider yet, add one in Settings → Sandbox",nme=5e4,tBt=[{value:"auto",label:"Auto"},{value:"custom",label:"Custom"}];function nBt({value:e,sandboxAvailable:t,webSearchAvailable:n=!1,hasSkills:r,disabled:o=!1,showCapabilities:a=!0,layout:i="compact",onChange:s}){var P,D,L,z,F,$,H,V,Y,U,X,J,K,G,Q,ne,de,se,oe;const l=vo(),{environments:c,refetch:d}=WMe(),p=((D=(P=e.sandbox)==null?void 0:P.environmentName)==null?void 0:D.trim())||"default",f=w.useMemo(()=>{const re=c.map(q=>({value:q.name,label:q.name}));return p!=="default"&&!re.some(q=>q.value===p)&&re.unshift({value:p,label:p,disabled:!0}),re},[c,p]),m=re=>{var q;return{...e,contextManagement:{...e.contextManagement,compaction:re,largeToolResponse:((q=e.contextManagement)==null?void 0:q.largeToolResponse)??{enabled:!0}}}},b=re=>s(m(re)),y=[{label:"Dynamic sub-agents",description:"Allow the agent to delegate complex work to focused sub-agents.",checked:((L=e.dynamicSubAgents)==null?void 0:L.enabled)??!0,update:re=>({...e,dynamicSubAgents:{enabled:re}})},{label:"Generative UI",description:"Allow rich interactive UI blocks in agent responses.",checked:((z=e.generativeUi)==null?void 0:z.enabled)??!0,update:re=>({...e,generativeUi:{enabled:re}})},{label:"Ask user questions",description:"Allow the agent to pause and ask for clarification.",checked:((F=e.askUserQuestions)==null?void 0:F.enabled)??!0,update:re=>({...e,askUserQuestions:{enabled:re}})}],x=(($=e.sandbox)==null?void 0:$.enabled)??!1,_=((V=(H=e.contextManagement)==null?void 0:H.compaction)==null?void 0:V.enabled)??!0,k=((U=(Y=e.contextManagement)==null?void 0:Y.compaction)==null?void 0:U.trigger)!=null?"custom":"auto",E=n?{label:"Web search",description:"Allow the agent to search the web and fetch pages.",checked:((X=e.webSearch)==null?void 0:X.enabled)??!0,update:re=>({...e,webSearch:{enabled:re}})}:null,T={label:"Sandbox",description:"Provide an isolated environment for code, files, and skills.",checked:x,disabled:!t||r,disabledTooltip:t?r?"Always on while skills are attached — remove them to turn it off":void 0:tme,update:re=>({...e,sandbox:{...e.sandbox,enabled:re}})},C={label:"File downloads",description:"Allow users to download files produced in the sandbox.",checked:((J=e.sandbox)==null?void 0:J.fileDownloads)??!0,disabled:!t||!x,update:re=>({...e,sandbox:{...e.sandbox,fileDownloads:re}})},A={label:"Context compaction",description:"Summarize older turns as context fills.",checked:_,update:re=>{var q;return m({...(q=e.contextManagement)==null?void 0:q.compaction,enabled:re})}},R={label:"Large tool response offloading",description:"Move large tool output to the sandbox and retain a preview.",checked:((G=(K=e.contextManagement)==null?void 0:K.largeToolResponse)==null?void 0:G.enabled)??!0,disabled:!t,disabledTooltip:t?void 0:`Offloading needs a sandbox. ${tme}`,update:re=>{var q;return{...e,contextManagement:{...e.contextManagement,compaction:((q=e.contextManagement)==null?void 0:q.compaction)??{enabled:!0},largeToolResponse:{enabled:re}}}}},M=[T,C,A,R],j=((de=(ne=(Q=e.contextManagement)==null?void 0:Q.compaction)==null?void 0:ne.trigger)==null?void 0:de.value)??nme,O=({field:re,className:q,wrapperClassName:te})=>{const ye=g.jsx(Mb,{checked:re.checked,disabled:o||re.disabled,onCheckedChange:Me=>s(re.update(Me)),"aria-label":re.label});return g.jsxs("div",{className:pe("flex w-full min-w-0",te,q??"items-center justify-between gap-3 py-1.5"),children:[g.jsxs("span",{className:"min-w-0",children:[g.jsx("span",{className:pe("text-text-primary",i==="detailed"?"block text-sm font-medium":"text-xs"),children:re.label}),i==="detailed"?g.jsx("span",{className:"text-text-secondary mt-0.5 block text-xs leading-snug",children:re.description}):null]}),re.disabledTooltip?g.jsx(eo,{content:re.disabledTooltip,children:g.jsx("span",{className:"inline-flex",children:ye})}):ye]},re.label)};if(i==="detailed"){const re="items-center justify-between gap-4";return g.jsxs("div",{className:"divide-y divide-border",children:[a?g.jsx("div",{className:"flex flex-col gap-3 py-4 md:flex-row md:gap-4",children:y.map((q,te)=>O({field:q,className:"items-start justify-between gap-3",wrapperClassName:pe("flex-1",te<y.length-1&&"border-b border-border pb-4 md:border-b-0 md:border-r md:pb-0 md:pr-4")}))}):null,g.jsxs("label",{className:pe("flex py-4",re),children:[g.jsxs("span",{className:"min-w-0",children:[g.jsx("span",{className:"text-text-primary block text-sm font-medium",children:"Iteration limit"}),g.jsx("span",{className:"text-text-secondary mt-0.5 block text-xs leading-snug",children:"Maximum agent-loop iterations for one turn."})]}),g.jsx("input",{type:"number",min:1,max:1024,disabled:o,value:e.iterationLimit??512,className:Bo("h-8 w-24 shrink-0 disabled:opacity-60"),onChange:q=>{const te=eme(q.target.value);te!==null&&s({...e,iterationLimit:te})}})]}),E!=null?O({field:E,className:pe("py-4",re)}):null,g.jsxs("section",{className:"py-4",children:[O({field:T,className:re}),g.jsxs("div",{className:`mt-3 border-l-2 border-primary-button-bg/50 pl-3 ${x?"":"opacity-50"}`,children:[g.jsxs("div",{className:pe("flex py-4",re),children:[g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:"text-text-primary block text-sm font-medium",children:"Environment"}),g.jsx("p",{className:"text-text-secondary mt-0.5 text-xs leading-snug",children:"Saved sandbox setup this agent uses when it runs."}),l&&x?g.jsxs("button",{type:"button",onClick:()=>l.setEnvironmentsOpen(!0),className:"text-primary-button-bg mt-1.5 inline-flex items-center gap-1 text-xs hover:underline",children:[g.jsx("span",{children:"Manage Environments"}),g.jsx(xe,{name:"external-link",className:"size-3"})]}):null]}),g.jsx("div",{className:"flex shrink-0 items-center",children:g.jsx(u$,{"aria-label":"Environment",value:((oe=(se=e.sandbox)==null?void 0:se.environmentName)==null?void 0:oe.trim())||"default",options:f,disabled:o||!t||!x,className:"w-48",onOpenChange:q=>{q&&d()},onValueChange:q=>s({...e,sandbox:{...e.sandbox,environmentName:q==="default"?void 0:q}})})})]}),O({field:C,className:re})]})]}),g.jsxs("section",{className:"py-4",children:[O({field:A,className:re}),g.jsxs("div",{className:pe("mt-3 flex border-l-2 border-primary-button-bg/50 pl-3",re,_?"":"opacity-50"),children:[g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:"text-text-primary block text-sm font-medium",children:"Compaction threshold tokens"}),g.jsx("span",{className:"text-text-secondary mt-0.5 block text-xs leading-snug",children:k==="auto"?"Automatically trigger compaction at 80% of model's context window":`Trigger compaction when input reaches ${j.toLocaleString()} tokens`})]}),g.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[k==="custom"?g.jsx("input",{type:"number",min:1,disabled:o||!_,value:j,"aria-label":"Compaction threshold tokens",className:Bo("h-8 w-28 disabled:opacity-60"),onChange:q=>{const te=eBt(q.target.value);te!==null&&b({enabled:_,trigger:{type:"input_tokens",value:te}})}}):null,g.jsx(u$,{"aria-label":"Compaction threshold mode",value:k,options:tBt,disabled:o||!_,className:"w-28",onValueChange:q=>b(q==="custom"?{enabled:_,trigger:{type:"input_tokens",value:nme}}:{enabled:_})})]})]})]}),O({field:R,className:pe("py-4",re)})]})}return g.jsxs("div",{children:[g.jsxs("label",{className:"mb-2 block text-xs",children:[g.jsx("span",{className:"text-text-secondary mb-1 block",children:"Iteration limit"}),g.jsx("input",{type:"number",min:1,max:1024,disabled:o,value:e.iterationLimit??512,className:Bo("h-8 disabled:opacity-60"),onChange:re=>{const q=eme(re.target.value);q!==null&&s({...e,iterationLimit:q})}})]}),[...E!=null?[E]:[],...M,...a?y:[]].map(re=>O({field:re}))]})}function rBt({spec:e,sandboxAvailable:t,webSearchAvailable:n=!1,onChange:r}){var a;const o=We("AgentRuntimeConfigFields");return g.jsx("div",{className:"w-full p-5",children:g.jsx(o,{value:e.config??{},sandboxAvailable:t,webSearchAvailable:n,hasSkills:(((a=e.skills)==null?void 0:a.length)??0)>0,layout:"detailed",onChange:i=>r({...e,config:i})})})}function oBt({spec:e,skills:t,skillsDisabled:n,query:r,onQueryChange:o,onChange:a}){const i=We("CatalogRow"),[s,l]=w.useState({}),c=Ov(e.skills),[d]=w.useState(()=>new Set(c.map(m=>Ia(m.id)))),p=r.trim().toLowerCase(),f=t.filter(m=>`${m.name} ${eC(m)??""} ${m.description??""}`.toLowerCase().includes(p)).sort((m,b)=>{const y=d.has(Ia(m.id)),x=d.has(Ia(b.id));return Number(x)-Number(y)});return g.jsxs("div",{className:"flex h-[min(32rem,calc(100dvh-8rem))] w-full min-w-0 flex-col overflow-hidden",children:[g.jsxs("label",{className:"relative m-3 block shrink-0",children:[g.jsx(xe,{name:"search",className:"text-text-secondary absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),g.jsx("input",{value:r,onChange:m=>o(m.target.value),placeholder:"Search skills",className:Bo("h-8 w-full pl-7")})]}),g.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[f.map(m=>{const b=c.find(_=>Ia(_.id)===Ia(m.id)),y=s[m.id],x=eC(m);return g.jsx(i,{title:m.name,description:m.description,badge:x===void 0?void 0:g.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:x}),checked:b!==void 0,disabled:n&&b===void 0,action:OZ(m)===void 0?void 0:g.jsx(kUt,{skill:m,selectedId:(y==null?void 0:y.id)??(b==null?void 0:b.id),onChange:_=>{l(k=>({...k,[m.id]:_})),b!==void 0&&a({...e,skills:c.map(k=>k===b?{...k.value,id:_.id,name:_.name}:k.value)})}}),onToggle:()=>{var k;const _=b===void 0;a({...e,skills:_?[...e.skills??[],{id:(y==null?void 0:y.id)??m.id,name:(y==null?void 0:y.name)??m.name}]:c.filter(E=>E!==b).map(E=>E.value),..._?{config:{...e.config,sandbox:{...(k=e.config)==null?void 0:k.sandbox,enabled:!0}}}:{}})}},m.id)}),f.length===0?g.jsx("p",{className:"text-text-secondary p-4 text-center text-sm",children:"No skills found."}):null]})]})}function Ob(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 aBt({disabled:e,isRunning:t}){const n=vo(),r=Zs(),o=(n==null?void 0:n.agentConfigOpen)===!0;return g.jsx(eo,{content:"Agent config",children:g.jsx("button",{type:"button","aria-label":"Agent config","aria-haspopup":"dialog","aria-expanded":o,disabled:e||t||n==null,className:Xt({variant:"ghost",size:"icon",className:"size-8"}),onClick:()=>{const a=!o;a&&r(Io.Config.OPENED,Ob(void 0,{...(n==null?void 0:n.mode.status)==="active"?{agentId:n.mode.agentId,agentName:n.mode.agentName}:{}})),n==null||n.setAgentConfigOpen(a)},children:g.jsx(xe,{name:"sliders",className:"size-3.5"})})})}var rme=[{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 iBt({value:e,onChange:t,disabled:n=!1,divided:r=!1,layout:o="list"}){return o==="cards"?g.jsx("div",{className:"flex flex-col gap-2 sm:flex-row",children:rme.map(a=>{const i=e[a.id];return g.jsxs("div",{className:"border-border flex min-w-0 flex-col gap-2 rounded-lg border p-3 sm:flex-1",children:[g.jsxs("div",{className:"flex items-start justify-between gap-2",children:[g.jsx("p",{className:"text-text-primary text-sm font-medium",children:a.label}),g.jsx(Mb,{checked:i,"aria-label":a.label,disabled:n,className:"mt-0.5",onCheckedChange:s=>t({...e,[a.id]:s})})]}),g.jsx("p",{className:"text-text-secondary text-xs leading-snug",children:a.description})]},a.id)})}):g.jsx("div",{className:pe("flex flex-col",r&&"overflow-hidden rounded-xl border border-border"),children:rme.map((a,i)=>{const s=e[a.id];return g.jsxs("div",{className:pe("flex items-start gap-3 px-3 py-3",r&&i>0&&"border-t border-border"),children:[g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("p",{className:"text-text-primary text-sm font-medium",children:a.label}),g.jsx("p",{className:"text-text-secondary mt-0.5 text-xs leading-snug",children:a.description})]}),g.jsx(Mb,{checked:s,"aria-label":a.label,disabled:n,className:"mt-0.5",onCheckedChange:l=>t({...e,[a.id]:l})})]},a.id)})})}function sBt({actions:e,disabled:t}){return e.length===0?null:g.jsx(of,{align:"start",side:"top",className:"w-48",trigger:g.jsx("button",{type:"button","aria-label":"Add",title:"Add",disabled:t,className:Xt({variant:"ghost",size:"icon",className:"size-8 rounded-full"}),children:g.jsx(xe,{name:"plus",className:"size-4"})}),children:e.map(n=>g.jsxs(bp,{onClick:n.onSelect,children:[g.jsx(xe,{name:n.icon,className:"text-text-secondary size-4 shrink-0"}),g.jsx("span",{children:n.label})]},n.id))})}function lBt({disabled:e,isRunning:t}){var E,T,C,A,R;const{models:n,ensureLoaded:r}=PC(),{agentSpec:o}=Eg(),a=V1(),[i,s]=w.useState(!1),l=w.useRef(null),c=w.useRef(null),d=w.useId(),p=Gv(),f=ld(),m=((E=o==null?void 0:o.model)==null?void 0:E.name)??((T=n[0])==null?void 0:T.name)??"",b=n.find(M=>M.name===m),y=b==null?void 0:b.properties.reasoningEfforts,x=(A=(C=o==null?void 0:o.model)==null?void 0:C.params)==null?void 0:A.reasoningEffort,_=HMe(y,x);if(w.useEffect(()=>{r()},[r]),w.useEffect(()=>{if(!i)return;const M=j=>{l.current&&!l.current.contains(j.target)&&s(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[i]),w.useEffect(()=>{var M;if(!(!a||b===void 0)){if(h$(y)){c.current=null;return}x!==void 0&&c.current!==b.name&&(c.current=b.name,a({model:jv(b.name,(M=o==null?void 0:o.model)==null?void 0:M.params,void 0)}))}},[a,b,y,x,(R=o==null?void 0:o.model)==null?void 0:R.params]),!h$(y)||!_)return null;const k=g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"border-b border-border px-3 py-2",children:g.jsx("p",{className:"text-text-primary text-sm font-normal",children:"Reasoning effort"})}),g.jsx("div",{id:d,role:"listbox","aria-label":"Select reasoning effort",className:"flex min-h-0 flex-1 flex-col overflow-y-auto p-1",children:y.map(M=>{const j=M===_;return g.jsx("button",{type:"button",role:"option","aria-selected":j,className:pe("flex w-full items-center rounded-md px-2 py-2 text-left text-sm",j?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text":"hover:bg-ghost-button-hover"),onClick:()=>{var O;!b||!a||(a({model:jv(b.name,{...(O=o==null?void 0:o.model)==null?void 0:O.params,reasoningEffort:M},y)}),s(!1))},children:g.jsx("span",{className:"truncate font-normal",children:M})},M)})})]});return g.jsxs("div",{ref:l,className:"relative",children:[g.jsxs("button",{type:"button",disabled:e||t,"aria-haspopup":"listbox","aria-expanded":i,"aria-controls":i?d:void 0,title:"Select reasoning effort",className:Xt({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(M=>!M),children:[g.jsx("span",{className:"truncate",children:_}),g.jsx(xe,{name:"chevron-down",className:"size-3.5 shrink-0 opacity-60"})]}),i?p||f?g.jsx(fN,{open:!0,onOpenChange:s,"aria-label":"Select reasoning effort",children:k}):g.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:k}):null]})}function cBt({disabled:e,isRunning:t,onAttach:n}){const r=vo(),o=Zs(),a=We("DraftCompositeSelector"),i=We("DraftAgentConfigTrigger"),s=We("DraftComposerActionsMenu"),l=ld(),c=Gv(),d=r!=null&&xye(r.mode),p=[{id:"agent-config",label:"Agent config",icon:"sliders",onSelect:()=>{o(Io.Config.OPENED,Ob(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 g.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[d?null:g.jsx(a,{disabled:e,isRunning:t,onAttach:n}),d&&l?g.jsx(s,{actions:p,disabled:e||t}):null,d&&!l&&c?g.jsx(i,{disabled:e,isRunning:t}):null,d&&!l&&n!=null?g.jsx(eo,{content:"Attach a file",children:g.jsx("button",{type:"button",disabled:e||t,"aria-label":"Attach a file",className:Xt({variant:"ghost",size:"icon"}),onClick:n,children:g.jsx(xe,{name:"paperclip"})})}):null]})}function uBt({disabled:e,isRunning:t}){const n=vo(),r=We("DraftModelSelector"),o=n!=null&&xye(n.mode);return g.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o?null:g.jsx(r,{disabled:e,isRunning:t}),g.jsx(lBt,{disabled:e,isRunning:t})]})}function ome(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 dBt=[{id:"connectors",label:"Connectors",icon:"plug"},{id:"skills",label:"Skills",icon:"lightbulb"},{id:"environments",label:"Environment",icon:"monitor"}],pBt=300,ame="Can't change the environment after a chat has started";function qm({title:e,description:t,badge:n,logo:r,fallbackIcon:o,checked:a,disabled:i=!1,disabledReason:s,selectionControl:l="checkbox",onToggle:c,onActivate:d,action:p}){const f=g.jsxs(g.Fragment,{children:[g.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?g.jsx(NZ,{src:r,alt:e,className:"size-4"}):o?g.jsx(xe,{name:o,className:"text-text-primary size-4"}):e.charAt(0).toUpperCase()}),g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[g.jsx("span",{className:"text-text-primary truncate text-sm font-medium",children:e}),n]}),t?g.jsx("span",{className:"text-text-secondary line-clamp-1 text-xs",children:t}):null]})]}),m=l==="radio"?g.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?g.jsx("span",{className:"size-1.5 rounded-full bg-primary-button-text"}):null}):g.jsx(jZ,{checked:a}),b=l==="radio"?"menuitemradio":"menuitemcheckbox",y=g.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:_=>{_.stopPropagation(),!i&&c()},children:m}),x=i&&s?g.jsx(eo,{content:s,className:"max-w-xs text-left",children:g.jsx("span",{className:"inline-flex shrink-0",children:y})}):y;return p||d||i?g.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||(d??c)()},onKeyDown:_=>{_.key!=="Enter"&&_.key!==" "||(_.preventDefault(),!i&&(d??c)())},children:[f,p?g.jsx("span",{className:"shrink-0",onClick:_=>_.stopPropagation(),onKeyDown:_=>_.stopPropagation(),children:p}):null,x]}):g.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,m]})}function RE(e){const t=Reflect.get(e,"auth");return e.authenticated===!1&&typeof t=="object"&&t!==null&&Reflect.get(t,"type")==="dcr"}function g$({connector:e,onConnected:t}){const{handleAuthorize:n,isOAuthLoading:r}=BMe();return g.jsx(In.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 fBt({value:e,onChange:t,placeholder:n}){return g.jsxs("label",{className:"relative mx-3 my-2 block",children:[g.jsx(xe,{name:"search",className:"text-text-secondary pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2"}),g.jsx("input",{type:"search",value:e,onChange:r=>t(r.target.value),placeholder:n,className:Bo("h-8 bg-secondary-bg py-1 pr-2 pl-7 dark:bg-primary-bg")})]})}var hBt="Web search is not configured",N6="Web search",ime="Search the web for up-to-date answers";function dx({label:e,count:t}){return g.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 gBt({disabled:e,isRunning:t,onAttach:n}){var pi,Go,fo,gn,Vn,kr,bs,Hl;const r=We("DraftComposerActionsMenu"),{skills:o,connectors:a,connectorLogos:i,loading:s,ensureLoaded:l,refreshConnectors:c}=PC(),d=v7(),p=y7(),f=vo(),{agentSpec:m,draftSessionId:b}=Eg(),y=V1(),x=b!=null,[_,k]=w.useState(!1),[E,T]=w.useState("connectors"),[C,A]=w.useState(""),[R,M]=w.useState(()=>new Set),[j,O]=w.useState(()=>new Set),[P,D]=w.useState([]),[L,z]=w.useState([]),F=w.useRef(!1),$=w.useRef(null),H=w.useRef(P),V=w.useRef(L);H.current=P,V.current=L;const Y=w.useRef(null),U=w.useId(),X=Gv(),J=ld(),K=(d==null?void 0:d.skill.enabled)!==!0,G=d==null?void 0:d.skill.reason,Q=((pi=d==null?void 0:d.webSearch)==null?void 0:pi.enabled)===!0,ne=((fo=(Go=m==null?void 0:m.config)==null?void 0:Go.webSearch)==null?void 0:fo.enabled)??Q,de=(d==null?void 0:d.sandbox.enabled)===!1,se=((gn=d==null?void 0:d.settings)==null?void 0:gn.enabled)!==!1,oe=se&&(p==null?void 0:p.connectorCatalog)!=null,re=se&&(p==null?void 0:p.skillCatalog)!=null,q=se&&(p==null?void 0:p.sandboxCatalog)!=null,te=w.useMemo(()=>ome(m==null?void 0:m.mcpServers),[m==null?void 0:m.mcpServers]),ye=w.useMemo(()=>ome(m==null?void 0:m.skills),[m==null?void 0:m.skills]),Me=_?P:te,Oe=_?L:ye,qe=w.useMemo(()=>new Set(Me.map(Je=>Je.id)),[Me]),Ge=!!((Vn=m==null?void 0:m.model)!=null&&Vn.name.trim()),Ye=Me.length+Oe.length+(ne?1:0),Rt=w.useMemo(()=>{const Je=yn=>{const et=yn.map(Wt=>Wt.name);return et.length<=4?et.join(", "):`${et.slice(0,4).join(", ")} +${et.length-4}`},Qt=[];return ne&&Qt.push(`Built-in: ${N6}`),Me.length>0&&Qt.push(`Connectors: ${Je(Me)}`),Oe.length>0&&Qt.push(`Skills: ${Je(Oe)}`),Qt.length>0?Qt.join(`
|
|
986
|
-
`):"No connectors or skills selected"},[Me,Oe,ne]),Ke=w.useCallback(()=>{$.current!=null&&(window.clearTimeout($.current),$.current=null)},[]),De=w.useCallback(()=>{Ke(),F.current&&(F.current=!1,y==null||y({mcpServers:H.current,skills:V.current}))},[Ke,y]),Be=w.useCallback(()=>{Ke(),$.current=window.setTimeout(()=>{$.current=null,De()},pBt)},[Ke,De]),Ae=w.useCallback(Je=>{Je||De(),k(Je)},[De]);w.useEffect(()=>{_&&l()},[_,l]),w.useEffect(()=>{_&&!Ge&&Ae(!1)},[Ge,_,Ae]),w.useEffect(()=>{if(!_)return;const Je=Qt=>{Y.current&&!Y.current.contains(Qt.target)&&Ae(!1)};return document.addEventListener("mousedown",Je),document.addEventListener("focusin",Je),()=>{document.removeEventListener("mousedown",Je),document.removeEventListener("focusin",Je)}},[_,Ae]),w.useEffect(()=>()=>Ke(),[Ke]);const Le=w.useMemo(()=>IZ({connectors:a,selected:Me}),[a,Me]),st=w.useMemo(()=>{const Je=C.trim().toLowerCase();return[...Je?Le.filter(yn=>{var et;return yn.name.toLowerCase().includes(Je)||(((et=yn.description)==null?void 0:et.toLowerCase().includes(Je))??!1)}):Le].sort((yn,et)=>Number(RE(yn))-Number(RE(et)))},[Le,C]),me=w.useMemo(()=>{const Je=C.trim().toLowerCase();return Je?o.filter(Qt=>{var yn,et;return Qt.name.toLowerCase().includes(Je)||(((yn=eC(Qt))==null?void 0:yn.toLowerCase().includes(Je))??!1)||(((et=Qt.description)==null?void 0:et.toLowerCase().includes(Je))??!1)}):o},[o,C]),we=w.useMemo(()=>st.filter(Je=>R.has(Je.id)),[st,R]),Se=w.useMemo(()=>st.filter(Je=>!R.has(Je.id)),[st,R]),Pe=w.useMemo(()=>me.filter(Je=>j.has(Ia(Je.id))),[me,j]),Xe=w.useMemo(()=>me.filter(Je=>!j.has(Ia(Je.id))),[me,j]),Ot=Je=>{D(Qt=>Qt.some(yn=>yn.id===Je.id)?Qt.filter(yn=>yn.id!==Je.id):[...Qt,{id:Je.id,name:Je.name}]),F.current=!0,Be()},pr=()=>{if(!Q||m==null)return;const Je=!ne,Qt={...m,config:{...m.config,webSearch:{enabled:Je}}};y==null||y({config:Qt.config}),f==null||f.rememberDraftSpec(Qt,"chat")},An=w.useMemo(()=>{const Je=C.trim().toLowerCase();return Je?N6.toLowerCase().includes(Je)||ime.toLowerCase().includes(Je):!0},[C]),fr=Je=>{var et;const Qt=Ia(Je.id),yn=!V.current.some(Wt=>Ia(Wt.id)===Qt);z(Wt=>Wt.some(da=>Ia(da.id)===Qt)?Wt.filter(da=>Ia(da.id)!==Qt):[...Wt,{id:Je.id,name:Je.name}]),yn&&(d==null?void 0:d.sandbox.enabled)===!0&&(y==null||y({config:{...m==null?void 0:m.config,sandbox:{...(et=m==null?void 0:m.config)==null?void 0:et.sandbox,enabled:!0}}})),F.current=!0,Be()},nn=Je=>{const Qt=Oe.find(et=>Ia(et.id)===Ia(Je.id)),yn=eC(Je);return g.jsx(qm,{title:Je.name,description:Je.description,badge:yn===void 0?void 0:g.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:yn}),checked:Qt!==void 0,disabled:K&&Qt===void 0,onToggle:()=>fr(Je)},Je.id)},{environments:$n,loading:_r,refetch:_n}=WMe(),Fn=Je=>{const Qt=E==="environments";if(_){Qt&&_n();return}D(te),z(ye),F.current=!1,Ke(),M(new Set(te.map(yn=>yn.id))),O(new Set(ye.map(yn=>Ia(yn.id)))),k(!0),Qt&&_n()},Pt=Je=>{Ae(!1),A(""),f==null||f.setSettingsOpen(!0,Je)},Yt=((Hl=(bs=(kr=m==null?void 0:m.config)==null?void 0:kr.sandbox)==null?void 0:bs.environmentName)==null?void 0:Hl.trim())||"default",lt=w.useMemo(()=>{const Je=new Set($n.map(et=>et.name)),Qt=$n.map(et=>({name:et.name,description:et.manifest.description,unavailable:!1}));Yt!=="default"&&!Je.has(Yt)&&Qt.unshift({name:Yt,description:void 0,unavailable:!0});const yn=C.trim().toLowerCase();return yn?Qt.filter(et=>{var Wt;return et.name.toLowerCase().includes(yn)||(((Wt=et.description)==null?void 0:Wt.toLowerCase().includes(yn))??!1)}):Qt},[$n,C,Yt]),Gt=Je=>{var yn,et,Wt;if(x)return;const Qt=Je==="default";y==null||y({config:{...m==null?void 0:m.config,sandbox:{...(yn=m==null?void 0:m.config)==null?void 0:yn.sandbox,enabled:Qt?(Wt=(et=m==null?void 0:m.config)==null?void 0:et.sandbox)==null?void 0:Wt.enabled:!0,environmentName:Qt?void 0:Je}}})},Sr=g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex shrink-0 border-b border-border",children:dBt.map(Je=>{const Qt=Je.id==="connectors"?Me.length:Je.id==="skills"?Oe.length:null,yn=E===Je.id;return g.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",yn&&"text-primary-button-bg border-b-2 border-primary-button-bg"),onClick:()=>{T(Je.id),A(""),Je.id==="environments"&&_n()},children:[g.jsx(xe,{name:Je.icon,className:"size-3.5"}),Je.label,Qt!=null&&Qt>0?g.jsx("span",{className:"bg-secondary-bg rounded px-1 text-[0.625rem]",children:Qt}):null]},Je.id)})}),g.jsxs(g.Fragment,{children:[g.jsx(fBt,{value:C,onChange:A,placeholder:E==="connectors"?"Search connectors...":E==="skills"?"Search skills...":"Search environment..."}),E==="skills"&&K&&G?g.jsxs("div",{role:"status",className:"border-primary-button-bg/30 bg-primary-button-bg/5 text-text-primary mx-3 mb-2 flex items-center gap-2 rounded-lg border p-3",children:[g.jsx(xe,{name:"lock",className:"text-primary-button-bg size-3 shrink-0"}),g.jsx("span",{className:"text-xs leading-none",children:G})]}):null,g.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 pb-2",children:E==="connectors"?g.jsxs(g.Fragment,{children:[An?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Built-in"}),g.jsx(qm,{title:N6,description:ime,fallbackIcon:"searchGlobe",checked:ne,disabled:!Q,disabledReason:hBt,onToggle:pr})]}):null,we.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Selected",count:we.length}),we.map(Je=>g.jsx(qm,{title:Je.name,logo:i[Je.name],fallbackIcon:"mcp-server",checked:qe.has(Je.id),action:RE(Je)?g.jsx(g$,{connector:Je,onConnected:c}):void 0,onToggle:()=>Ot(Je)},Je.id))]}):null,Se.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Available",count:Se.length}),Se.map(Je=>g.jsx(qm,{title:Je.name,logo:i[Je.name],fallbackIcon:"mcp-server",checked:qe.has(Je.id),action:RE(Je)?g.jsx(g$,{connector:Je,onConnected:c}):void 0,onToggle:()=>Ot(Je)},Je.id))]}):null,st.length===0&&a.length>0&&!An?g.jsx(Px,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors"}):null,a.length===0?g.jsx(Px,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors",onOpenSettings:f&&oe?()=>Pt("connectors"):void 0}):null]}):E==="skills"?g.jsxs(g.Fragment,{children:[Pe.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Selected",count:Pe.length}),Pe.map(nn)]}):null,Xe.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Available",count:Xe.length}),Xe.map(nn)]}):null,me.length===0?g.jsx(Px,{loading:s,emptyLabel:"No skills",settingsTarget:de?"a Sandbox":"Skills",onOpenSettings:o.length===0&&f&&(de?q:re)?()=>Pt(de?"sandbox":"skills"):void 0}):null]}):g.jsxs(g.Fragment,{children:[x?g.jsxs("div",{role:"status",className:"border-primary-button-bg/30 bg-primary-button-bg/5 text-text-primary mx-3 mb-2 flex items-center gap-2 rounded-lg border p-3",children:[g.jsx(xe,{name:"lock",className:"text-primary-button-bg size-3 shrink-0"}),g.jsx("span",{className:"text-xs leading-none",children:ame})]}):null,lt.map(Je=>{const Qt=Yt===Je.name,yn=x||Je.unavailable;return g.jsx(qm,{title:Je.name,description:Je.description,fallbackIcon:"monitor",selectionControl:"radio",checked:Qt,disabled:yn,disabledReason:x?ame:void 0,onToggle:()=>Gt(Je.name)},Je.name)}),lt.length===0?g.jsx(Px,{loading:_r,emptyLabel:"No environments",settingsTarget:"Environments",onOpenSettings:f?()=>{Ae(!1),f.setEnvironmentsOpen(!0)}:void 0}):null]})})]})]}),on=[...Ge?[{id:"tools",label:`Tools (${Ye})`,icon:"wrench",onSelect:()=>Fn()}]:[],...n===void 0?[]:[{id:"attach",label:"Attach a file",icon:"paperclip",onSelect:n}]];return g.jsxs("div",{ref:Y,className:"relative flex flex-wrap items-center",children:[J?g.jsx(r,{actions:on,disabled:e||t}):Ge?g.jsx(eo,{content:Rt,className:"max-w-xs whitespace-pre-line text-left",side:"top",children:g.jsxs("button",{type:"button",disabled:e||t,"aria-label":`Tools (${Ye})`,"aria-haspopup":"dialog","aria-expanded":_,"aria-controls":_?U:void 0,className:Xt({variant:"ghost",size:"large",className:"gap-1.5 px-2 text-xs"}),onClick:()=>{if(_){Ae(!1);return}Fn()},children:[g.jsx(xe,{name:"wrench"}),g.jsx("span",{children:"Tools"}),g.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:Ye})]})}):null,!J&&n?g.jsx(eo,{content:"Attach a file",children:g.jsx("button",{type:"button",disabled:e||t,"aria-label":"Attach a file",className:Xt({variant:"ghost",size:"icon"}),onClick:n,children:g.jsx(xe,{name:"paperclip"})})}):null,_&&Ge?X||J?g.jsx(fN,{id:U,open:!0,onOpenChange:Ae,"aria-label":"Add to composer",children:Sr}):g.jsx("div",{id:U,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:Sr}):null]})}function mBt({disabled:e,isRunning:t}){var M,j,O,P;const{models:n,loading:r,ensureLoaded:o}=PC(),{agentSpec:a}=Eg(),i=V1(),s=y7(),l=vo(),[c,d]=w.useState(!1),[p,f]=w.useState(""),m=w.useRef(null),b=w.useId(),y=Gv(),x=ld(),_=!r&&n.length===0&&s!=null,k=w.useRef(null);w.useEffect(()=>{o()},[o]),w.useEffect(()=>{var F,$,H;if(!i||r||n.length===0)return;const D=n[0];if(D===void 0)return;const L=D.name,z=(($=(F=a==null?void 0:a.model)==null?void 0:F.name)==null?void 0:$.trim())??"";if(z&&n.some(Y=>Y.name===z)){k.current=null;return}k.current!==L&&(k.current=L,i({model:jv(L,(H=a==null?void 0:a.model)==null?void 0:H.params,D.properties.reasoningEfforts)}))},[i,r,n,(M=a==null?void 0:a.model)==null?void 0:M.name,(j=a==null?void 0:a.model)==null?void 0:j.params]);const E=((O=a==null?void 0:a.model)==null?void 0:O.name)??((P=n[0])==null?void 0:P.name)??"",T=n.find(D=>D.name===E),C=T?J2(T.name):E?J2(E):r?"Loading…":"Select model";w.useEffect(()=>{if(!c)return;const D=L=>{m.current&&!m.current.contains(L.target)&&d(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[c]);const A=(T==null?void 0:T.provider.name)??E,R=g.jsx(p$,{models:n,loading:r,selectedName:E,query:p,onQueryChange:f,listboxId:b,onOpenSettings:_?()=>{d(!1),f(""),l==null||l.setSettingsOpen(!0,"models")}:void 0,onSelect:D=>{var L;i==null||i({model:jv(D.name,(L=a==null?void 0:a.model)==null?void 0:L.params,D.properties.reasoningEfforts)}),d(!1),f("")}});return g.jsxs("div",{ref:m,className:"relative",children:[g.jsxs("button",{type:"button",disabled:e||t,"aria-haspopup":"listbox","aria-expanded":c,"aria-controls":c?b:void 0,title:"Select model",className:Xt({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:()=>d(D=>!D),children:[g.jsx(hN,{logo:T==null?void 0:T.provider.logo,label:A,className:"size-4 text-xs"}),g.jsx("span",{className:"truncate",children:C}),g.jsx(xe,{name:"chevron-down",className:"size-3.5 shrink-0 opacity-60"})]}),c?y||x?g.jsx(fN,{open:!0,onOpenChange:d,"aria-label":"Select model",children:R}):g.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:R}):null]})}function bBt({className:e,compact:t=!1}){const n=vo(),r=x7(),o=Zs(),a=w7({sandboxEnvironments:r})&&n!=null,i=(n==null?void 0:n.environmentsOpen)===!0;return a?g.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:g.jsxs("button",{type:"button","aria-label":t?"Environments":void 0,title:t?"Environments":void 0,"aria-current":i?"page":void 0,className:Xt({variant:"ghost",className:pe(n1,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?NC:"h-8 w-full !justify-start px-2.5 text-sm",i&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{i||o(Io.Environment.PAGE_OPENED),n.setEnvironmentsOpen(!i)},children:[g.jsx(xe,{name:"monitor",size:t?14:void 0}),t?g.jsx("span",{className:"text-center",children:"Environments"}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"truncate",children:"Environments"}),g.jsx(xe,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}var vBt=288,yBt=.75,xBt=.42;function KMe({requested:e,rowWidth:t}){if(t<=0)return e;const n=Math.min(vBt,t*.3),r=Math.max(n,t*yBt);return Math.min(r,Math.max(n,e))}function ern(e){return KMe({requested:e*xBt,rowWidth:e})}function wBt({name:e,view:t}){const n=We("SyntaxHighlighter"),r=We("Markdown");return t.status==="loading"?g.jsx("div",{className:"flex h-full items-center justify-center text-text-secondary",children:g.jsx(Gs,{size:20})}):t.status==="error"||t.status==="unavailable"?g.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"?g.jsx("div",{className:"flex h-full items-center justify-center p-4",children:g.jsx("img",{src:t.objectUrl,alt:e,className:"max-h-full max-w-full object-contain"})}):g.jsx("iframe",{title:e,src:t.objectUrl,className:"absolute inset-0 h-full w-full border-0"}):t.status==="html"?g.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"?g.jsx("div",{className:"px-4 py-3",children:g.jsx(r,{content:t.text})}):t.language!=null&&t.text.length<=RFt?g.jsx(n,{code:t.text,language:t.language,showLineNumbers:!0,className:"my-0 h-full rounded-none"}):g.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 sme(e,t,n){var o;const r=((o=e.parentElement)==null?void 0:o.getBoundingClientRect().width)??0;n(KMe({requested:t,rowWidth:r}))}function _Bt({name:e,placement:t,view:n,onClose:r,onDownload:o,onEnterFullPage:a,onExitFullPage:i,onRetry:s,downloadBusy:l=!1,widthPx:c,onWidthChange:d}){const p=w.useRef(null),f=t==="side"&&d!=null;w.useEffect(()=>{var y;(y=p.current)==null||y.focus()},[e,t]);const m=y=>{if(d==null)return;y.preventDefault();const x=y.currentTarget,_=p.current;if(_==null)return;typeof x.setPointerCapture=="function"&&x.setPointerCapture(y.pointerId);const k=y.clientX,E=_.getBoundingClientRect().width,T=A=>{sme(_,E+(k-A.clientX),d)},C=A=>{typeof x.hasPointerCapture=="function"&&x.hasPointerCapture(A.pointerId)&&x.releasePointerCapture(A.pointerId),x.removeEventListener("pointermove",T),x.removeEventListener("pointerup",C),x.removeEventListener("pointercancel",C)};x.addEventListener("pointermove",T),x.addEventListener("pointerup",C),x.addEventListener("pointercancel",C)};return g.jsxs("aside",{ref:p,tabIndex:-1,"data-slot":"aui_file-preview","data-placement":t,"aria-label":`Preview of ${e}`,onKeyDown:y=>{y.key==="Escape"&&(y.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?g.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:m,onKeyDown:y=>{if(d==null||p.current==null)return;const x=y.shiftKey?48:16;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault(),y.stopPropagation();const _=p.current.getBoundingClientRect().width,k=y.key==="ArrowLeft"?x:-x;sme(p.current,_+k,d)},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:[g.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"}),g.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:g.jsx(xe,{name:"grip-vertical",size:12})})]}):null,g.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border px-3",children:[g.jsx(xe,{name:"file",size:16,className:"shrink-0 text-text-secondary"}),g.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-text-primary",children:e}),n.status==="error"&&s!=null?g.jsx("button",{type:"button",onClick:s,className:Xt({variant:"ghost",size:"small"}),children:"Retry"}):null,t==="full"&&i!=null?g.jsx("button",{type:"button",onClick:i,"aria-label":"Exit full page",title:"Exit full page",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"compress",size:14})}):null,t!=="full"&&a!=null?g.jsx("button",{type:"button",onClick:a,"aria-label":"Full page",title:"Full page",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"expand",size:14})}):null,g.jsx("button",{type:"button",onClick:o,disabled:l,"aria-busy":l||void 0,"aria-label":l?`Downloading ${e}`:`Download ${e}`,title:"Download",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:l?g.jsx(Gs,{size:14}):g.jsx(xe,{name:"download",size:14})}),g.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",title:"Close preview",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"xmark",size:14})})]}),g.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:g.jsx(wBt,{name:e,view:n})})]})}var YMe=w.forwardRef(({className:e,isLoading:t=!1,...n},r)=>g.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&&g.jsx(Gs,{size:14})}));YMe.displayName="HistoryLoader";var ZMe="aui-trusted-external-hosts";function tC(){return{version:1,links:[],images:[]}}function lme(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function SBt(e){if(e==null||typeof e!="object"||!("version"in e)||e.version!==1)return tC();const t="links"in e&&lme(e.links)?e.links:[],n="images"in e&&lme(e.images)?e.images:[];return{version:1,links:t,images:n}}function XMe(){if(typeof window>"u")return tC();try{const e=JSON.parse(window.localStorage.getItem(ZMe)??"null");return SBt(e)}catch{return tC()}}function kBt(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ZMe,JSON.stringify(e))}catch{}}function qMe(e){try{const t=typeof window<"u"?window.location.href:"http://localhost";return new URL(e,t)}catch{return null}}function G_(e){const t=qMe(e);return t==null||t.protocol!=="http:"&&t.protocol!=="https:"?null:t.hostname.toLowerCase()}function m$(e){const t=G_(e);return t==null?!1:typeof window>"u"?!0:t!==window.location.hostname.toLowerCase()}function QMe({kind:e,host:t}){const n=t.toLowerCase();return XMe()[e].includes(n)}function cme({kind:e,host:t}){const n=t.toLowerCase(),r=XMe();r[e].includes(n)||kBt({...r,[e]:[...r[e],n]})}function JMe(e){const t=qMe(e);t!=null&&(t.protocol!=="http:"&&t.protocol!=="https:"||window.open(t.href,"_blank","noopener,noreferrer"))}var eOe=w.createContext(null);function tOe(){const e=w.useContext(eOe);if(e==null)throw new Error("Markdown external URL confirm requires ExternalUrlConfirmProvider");return e}function ume(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 EBt({children:e}){const[t,n]=w.useState(null),[r,o]=w.useState(!1),[a,i]=w.useState(()=>new Set),s=w.useCallback(k=>{o(!1),n({kind:"link",url:k})},[]),l=w.useCallback(k=>{o(!1),n({kind:"image",url:k})},[]),c=w.useCallback(k=>a.has(k.toLowerCase()),[a]),d=w.useCallback(()=>{n(null),o(!1)},[]),p=w.useCallback(()=>{if(t==null)return;const k=G_(t.url);if(t.kind==="link"){r&&k!=null&&cme({kind:"links",host:k}),JMe(t.url),d();return}k!=null&&(r&&cme({kind:"images",host:k}),i(E=>{const T=new Set(E);return T.add(k.toLowerCase()),T})),d()},[d,r,t]),f=w.useMemo(()=>({requestLinkConfirm:s,requestImageConfirm:l,isSessionImageHostTrusted:c}),[c,l,s]),m=t!=null?G_(t.url):null,b=(t==null?void 0:t.kind)==="image"?"Show external image":"Open external link",y=(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:",x=(t==null?void 0:t.kind)==="image"?"Show image":"Open link",_=m==null?null:(t==null?void 0:t.kind)==="image"?`Don't ask again for images from ${m}`:`Don't ask again for links to ${m}`;return g.jsxs(eOe.Provider,{value:f,children:[e,g.jsxs(lN,{open:t!=null,onOpenChange:k=>{k||d()},"aria-label":b,className:"max-w-md",children:[g.jsxs(cN,{children:[g.jsxs(xZ,{children:[g.jsx(wZ,{children:b}),g.jsx("p",{className:"text-sm text-text-secondary",children:y})]}),t!=null?g.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,_!=null?g.jsxs("button",{type:"button",role:"checkbox","aria-checked":r,className:"flex items-start gap-2 text-left text-sm text-text-secondary",onClick:()=>o(k=>!k),children:[g.jsx(jZ,{checked:r,className:"mt-0.5"}),g.jsx("span",{children:_})]}):null]}),g.jsxs(aMe,{children:[g.jsx(In.Secondary,{type:"button",onClick:d,children:"Cancel"}),g.jsx(In.Primary,{type:"button",onClick:p,children:x})]})]})]})}function TBt({href:e,children:t,node:n,...r}){const{requestLinkConfirm:o}=tOe(),a=e!=null&&e!==""&&ume(e),i=e!=null&&e!==""&&!a&&m$(e),s=a?void 0:i?"#":e,l=c=>{if(e==null||e==="")return;if(ume(e)){c.preventDefault();return}if(!m$(e))return;c.preventDefault();const d=G_(e);if(d!=null&&QMe({kind:"links",host:d})){JMe(e);return}o(e)};return g.jsx("a",{...r,href:s,target:i||a?"_blank":r.target,rel:"noopener noreferrer",onClick:l,onAuxClick:l,children:t})}function ABt({src:e,alt:t,node:n,...r}){const{requestImageConfirm:o,isSessionImageHostTrusted:a}=tOe(),i=typeof e=="string"?e:"",s=i!==""?G_(i):null;return!(i!==""&&m$(i))||s!=null&&(QMe({kind:"images",host:s})||a(s))?g.jsx("img",{...r,src:e,alt:t??""}):g.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:[g.jsx("span",{className:"text-sm text-text-secondary",children:t!=null&&t!==""?t:"External image"}),g.jsx("span",{className:"max-h-16 overflow-auto break-all font-mono text-xs text-text-secondary",children:i}),g.jsx(In.Secondary,{type:"button",size:"small",className:"self-start",onClick:()=>{i!==""&&o(i)},children:"Show image"})]})}function trn(){return Sa(()=>Promise.resolve().then(()=>pnn),void 0,import.meta.url)}var CBt=8*1024;function RBt(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 IBt(e){const{isStreaming:t,getActiveFenceCode:n,darkTheme:r,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s,OpenUiFenceBlock:l,SandboxArtifactDownload:c,SyntaxHighlighter:d,inlineCodeClassName:p}=e;return{a:TBt,img:ABt,pre({children:f}){return g.jsx(g.Fragment,{children:f})},code({className:f,children:m}){var k;const b=(k=/language-(\w+)/.exec(f??""))==null?void 0:k[1],y=String(m??"").replace(/\n$/,"");if(!f)return g.jsx("code",{className:pe("aui-inline-code rounded bg-secondary-bg px-1 py-0.5 font-mono text-sm",p),children:m});if(b==="openui")return g.jsx(l,{content:y,isStreaming:t,darkTheme:r});if(b==="sandbox_artifacts")return g.jsx(c,{code:y,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s});const x=n();return t===!0&&x!=null&&y===x&&y.length>CBt?g.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:g.jsx("code",{className:pe(f,"whitespace-pre-wrap break-words"),children:y})}):g.jsx(d,{code:y,language:b,darkTheme:r})}}}var NBt=[S9t];function nOe({content:e,isStreaming:t,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,className:i}){const s=mN(),l=IC(),c=s==="dark",d=We("OpenUiFenceBlock"),p=We("SandboxArtifactDownload"),f=We("SyntaxHighlighter"),m=w.useRef(null);m.current=t===!0?RBt(e):null;const b=w.useMemo(()=>IBt({isStreaming:t,getActiveFenceCode:()=>m.current,darkTheme:c,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,OpenUiFenceBlock:d,SandboxArtifactDownload:p,SyntaxHighlighter:f,inlineCodeClassName:l.inlineCode}),[t,c,n,r,o,a,d,p,f,l.inlineCode]);return g.jsx(EBt,{children:g.jsx("div",{className:pe("aui-markdown markdown-body min-w-0 max-w-full overflow-x-clip",l.markdown,i),children:g.jsx(TEe,{remarkPlugins:NBt,components:b,children:e})})})}var MBt="h-6 w-6 text-text-secondary hover:text-text-primary [&_svg]:size-3.5";function rOe({isCopied:e,onCopy:t,createdAt:n,className:r}){const o=We("MessageTimestamp");return g.jsxs("div",{className:pe("aui-assistant-action-bar-root animate-in fade-in flex items-center gap-1 duration-200",r),children:[g.jsx(o,{createdAt:n,className:"mr-1"}),g.jsx(Ip,{"aria-label":"Copy",tooltip:"Copy",variant:"ghost",className:MBt,onClick:t,children:g.jsx(xe,{name:e?"check":"clone",size:"0.875em"})})]})}function OBt({message:e,className:t}){return g.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:[g.jsx(xe,{name:"circle-exclamation",size:"1rem",className:"text-warning-bg shrink-0","aria-hidden":!0}),g.jsx("span",{className:"aui-message-cancelled-message min-w-0 break-words",children:e})]})}function jBt({message:e,className:t}){return g.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:g.jsx("span",{className:"aui-message-error-message line-clamp-2",children:e})})}function PBt({className:e}){return g.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",e),children:[g.jsx(gZ,{state:"listening",size:20,"aria-hidden":!0}),g.jsx("span",{className:"aui-message-indicator-shimmer",children:"Working..."})]})}function DBt(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function LBt(e){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).format(e)}function zBt({createdAt:e,className:t}){const n=DBt(e);return n==null?null:g.jsx(aN,{title:uMe(n),size:"fit",side:"bottom",children:g.jsx("span",{className:pe("text-xs font-medium cursor-pointer leading-normal shrink-0 text-text-secondary",t),children:LBt(n)})})}var dme;function oOe(){return dme??(dme=Sa(()=>import("./index-DfER8M3D.js").then(e=>e.i),__vite__mapDeps([0,1]),import.meta.url)),dme}var aOe="aui-monaco-light",iOe="aui-monaco-dark",bu="#00000000",DZ=18,sOe=8,pme="10.5rem";function $Bt(e){const t={"editor.background":bu,"editor.lineHighlightBackground":bu,"editor.lineHighlightBorder":bu,"editorGutter.background":bu,"minimap.background":bu,focusBorder:bu,"scrollbar.shadow":bu,"editorOverviewRuler.border":bu,"editorOverviewRuler.background":bu};e.editor.defineTheme(aOe,{base:"vs",inherit:!0,rules:[],colors:t}),e.editor.defineTheme(iOe,{base:"vs-dark",inherit:!0,rules:[],colors:t})}function FBt(e,t,n){return e||t||(n==="dark"?iOe:aOe)}function M6(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 UBt(e,t,n){const o=Math.max(1,e.split(`
|
|
986
|
+
`):"No connectors or skills selected"},[Me,Oe,ne]),Ke=w.useCallback(()=>{$.current!=null&&(window.clearTimeout($.current),$.current=null)},[]),De=w.useCallback(()=>{Ke(),F.current&&(F.current=!1,y==null||y({mcpServers:H.current,skills:V.current}))},[Ke,y]),Be=w.useCallback(()=>{Ke(),$.current=window.setTimeout(()=>{$.current=null,De()},pBt)},[Ke,De]),Ae=w.useCallback(Je=>{Je||De(),k(Je)},[De]);w.useEffect(()=>{_&&l()},[_,l]),w.useEffect(()=>{_&&!Ge&&Ae(!1)},[Ge,_,Ae]),w.useEffect(()=>{if(!_)return;const Je=Qt=>{Y.current&&!Y.current.contains(Qt.target)&&Ae(!1)};return document.addEventListener("mousedown",Je),document.addEventListener("focusin",Je),()=>{document.removeEventListener("mousedown",Je),document.removeEventListener("focusin",Je)}},[_,Ae]),w.useEffect(()=>()=>Ke(),[Ke]);const Le=w.useMemo(()=>IZ({connectors:a,selected:Me}),[a,Me]),st=w.useMemo(()=>{const Je=C.trim().toLowerCase();return[...Je?Le.filter(yn=>{var et;return yn.name.toLowerCase().includes(Je)||(((et=yn.description)==null?void 0:et.toLowerCase().includes(Je))??!1)}):Le].sort((yn,et)=>Number(RE(yn))-Number(RE(et)))},[Le,C]),me=w.useMemo(()=>{const Je=C.trim().toLowerCase();return Je?o.filter(Qt=>{var yn,et;return Qt.name.toLowerCase().includes(Je)||(((yn=eC(Qt))==null?void 0:yn.toLowerCase().includes(Je))??!1)||(((et=Qt.description)==null?void 0:et.toLowerCase().includes(Je))??!1)}):o},[o,C]),we=w.useMemo(()=>st.filter(Je=>R.has(Je.id)),[st,R]),Se=w.useMemo(()=>st.filter(Je=>!R.has(Je.id)),[st,R]),Pe=w.useMemo(()=>me.filter(Je=>j.has(Ia(Je.id))),[me,j]),Xe=w.useMemo(()=>me.filter(Je=>!j.has(Ia(Je.id))),[me,j]),Ot=Je=>{D(Qt=>Qt.some(yn=>yn.id===Je.id)?Qt.filter(yn=>yn.id!==Je.id):[...Qt,{id:Je.id,name:Je.name}]),F.current=!0,Be()},pr=()=>{if(!Q||m==null)return;const Je=!ne,Qt={...m,config:{...m.config,webSearch:{enabled:Je}}};y==null||y({config:Qt.config}),f==null||f.rememberDraftSpec(Qt,"chat")},An=w.useMemo(()=>{const Je=C.trim().toLowerCase();return Je?N6.toLowerCase().includes(Je)||ime.toLowerCase().includes(Je):!0},[C]),fr=Je=>{var et;const Qt=Ia(Je.id),yn=!V.current.some(Wt=>Ia(Wt.id)===Qt);z(Wt=>Wt.some(da=>Ia(da.id)===Qt)?Wt.filter(da=>Ia(da.id)!==Qt):[...Wt,{id:Je.id,name:Je.name}]),yn&&(d==null?void 0:d.sandbox.enabled)===!0&&(y==null||y({config:{...m==null?void 0:m.config,sandbox:{...(et=m==null?void 0:m.config)==null?void 0:et.sandbox,enabled:!0}}})),F.current=!0,Be()},nn=Je=>{const Qt=Oe.find(et=>Ia(et.id)===Ia(Je.id)),yn=eC(Je);return g.jsx(qm,{title:Je.name,description:Je.description,badge:yn===void 0?void 0:g.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:yn}),checked:Qt!==void 0,disabled:K&&Qt===void 0,onToggle:()=>fr(Je)},Je.id)},{environments:$n,loading:_r,refetch:_n}=WMe(),Fn=Je=>{const Qt=E==="environments";if(_){Qt&&_n();return}D(te),z(ye),F.current=!1,Ke(),M(new Set(te.map(yn=>yn.id))),O(new Set(ye.map(yn=>Ia(yn.id)))),k(!0),Qt&&_n()},Pt=Je=>{Ae(!1),A(""),f==null||f.setSettingsOpen(!0,Je)},Yt=((Hl=(bs=(kr=m==null?void 0:m.config)==null?void 0:kr.sandbox)==null?void 0:bs.environmentName)==null?void 0:Hl.trim())||"default",lt=w.useMemo(()=>{const Je=new Set($n.map(et=>et.name)),Qt=$n.map(et=>({name:et.name,description:et.manifest.description,unavailable:!1}));Yt!=="default"&&!Je.has(Yt)&&Qt.unshift({name:Yt,description:void 0,unavailable:!0});const yn=C.trim().toLowerCase();return yn?Qt.filter(et=>{var Wt;return et.name.toLowerCase().includes(yn)||(((Wt=et.description)==null?void 0:Wt.toLowerCase().includes(yn))??!1)}):Qt},[$n,C,Yt]),Gt=Je=>{var yn,et,Wt;if(x)return;const Qt=Je==="default";y==null||y({config:{...m==null?void 0:m.config,sandbox:{...(yn=m==null?void 0:m.config)==null?void 0:yn.sandbox,enabled:Qt?(Wt=(et=m==null?void 0:m.config)==null?void 0:et.sandbox)==null?void 0:Wt.enabled:!0,environmentName:Qt?void 0:Je}}})},Sr=g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex shrink-0 border-b border-border",children:dBt.map(Je=>{const Qt=Je.id==="connectors"?Me.length:Je.id==="skills"?Oe.length:null,yn=E===Je.id;return g.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",yn&&"text-primary-button-bg border-b-2 border-primary-button-bg"),onClick:()=>{T(Je.id),A(""),Je.id==="environments"&&_n()},children:[g.jsx(xe,{name:Je.icon,className:"size-3.5"}),Je.label,Qt!=null&&Qt>0?g.jsx("span",{className:"bg-secondary-bg rounded px-1 text-[0.625rem]",children:Qt}):null]},Je.id)})}),g.jsxs(g.Fragment,{children:[g.jsx(fBt,{value:C,onChange:A,placeholder:E==="connectors"?"Search connectors...":E==="skills"?"Search skills...":"Search environment..."}),E==="skills"&&K&&G?g.jsxs("div",{role:"status",className:"border-primary-button-bg/30 bg-primary-button-bg/5 text-text-primary mx-3 mb-2 flex items-center gap-2 rounded-lg border p-3",children:[g.jsx(xe,{name:"lock",className:"text-primary-button-bg size-3 shrink-0"}),g.jsx("span",{className:"text-xs leading-none",children:G})]}):null,g.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1 pb-2",children:E==="connectors"?g.jsxs(g.Fragment,{children:[An?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Built-in"}),g.jsx(qm,{title:N6,description:ime,fallbackIcon:"searchGlobe",checked:ne,disabled:!Q,disabledReason:hBt,onToggle:pr})]}):null,we.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Selected",count:we.length}),we.map(Je=>g.jsx(qm,{title:Je.name,logo:i[Je.name],fallbackIcon:"mcp-server",checked:qe.has(Je.id),action:RE(Je)?g.jsx(g$,{connector:Je,onConnected:c}):void 0,onToggle:()=>Ot(Je)},Je.id))]}):null,Se.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Available",count:Se.length}),Se.map(Je=>g.jsx(qm,{title:Je.name,logo:i[Je.name],fallbackIcon:"mcp-server",checked:qe.has(Je.id),action:RE(Je)?g.jsx(g$,{connector:Je,onConnected:c}):void 0,onToggle:()=>Ot(Je)},Je.id))]}):null,st.length===0&&a.length>0&&!An?g.jsx(Px,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors"}):null,a.length===0?g.jsx(Px,{loading:s,emptyLabel:"No connectors",settingsTarget:"Connectors",onOpenSettings:f&&oe?()=>Pt("connectors"):void 0}):null]}):E==="skills"?g.jsxs(g.Fragment,{children:[Pe.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Selected",count:Pe.length}),Pe.map(nn)]}):null,Xe.length>0?g.jsxs(g.Fragment,{children:[g.jsx(dx,{label:"Available",count:Xe.length}),Xe.map(nn)]}):null,me.length===0?g.jsx(Px,{loading:s,emptyLabel:"No skills",settingsTarget:de?"a Sandbox":"Skills",onOpenSettings:o.length===0&&f&&(de?q:re)?()=>Pt(de?"sandbox":"skills"):void 0}):null]}):g.jsxs(g.Fragment,{children:[x?g.jsxs("div",{role:"status",className:"border-primary-button-bg/30 bg-primary-button-bg/5 text-text-primary mx-3 mb-2 flex items-center gap-2 rounded-lg border p-3",children:[g.jsx(xe,{name:"lock",className:"text-primary-button-bg size-3 shrink-0"}),g.jsx("span",{className:"text-xs leading-none",children:ame})]}):null,lt.map(Je=>{const Qt=Yt===Je.name,yn=x||Je.unavailable;return g.jsx(qm,{title:Je.name,description:Je.description,fallbackIcon:"monitor",selectionControl:"radio",checked:Qt,disabled:yn,disabledReason:x?ame:void 0,onToggle:()=>Gt(Je.name)},Je.name)}),lt.length===0?g.jsx(Px,{loading:_r,emptyLabel:"No environments",settingsTarget:"Environments",onOpenSettings:f?()=>{Ae(!1),f.setEnvironmentsOpen(!0)}:void 0}):null]})})]})]}),on=[...Ge?[{id:"tools",label:`Tools (${Ye})`,icon:"wrench",onSelect:()=>Fn()}]:[],...n===void 0?[]:[{id:"attach",label:"Attach a file",icon:"paperclip",onSelect:n}]];return g.jsxs("div",{ref:Y,className:"relative flex flex-wrap items-center",children:[J?g.jsx(r,{actions:on,disabled:e||t}):Ge?g.jsx(eo,{content:Rt,className:"max-w-xs whitespace-pre-line text-left",side:"top",children:g.jsxs("button",{type:"button",disabled:e||t,"aria-label":`Tools (${Ye})`,"aria-haspopup":"dialog","aria-expanded":_,"aria-controls":_?U:void 0,className:Xt({variant:"ghost",size:"large",className:"gap-1.5 px-2 text-xs"}),onClick:()=>{if(_){Ae(!1);return}Fn()},children:[g.jsx(xe,{name:"wrench"}),g.jsx("span",{children:"Tools"}),g.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:Ye})]})}):null,!J&&n?g.jsx(eo,{content:"Attach a file",children:g.jsx("button",{type:"button",disabled:e||t,"aria-label":"Attach a file",className:Xt({variant:"ghost",size:"icon"}),onClick:n,children:g.jsx(xe,{name:"paperclip"})})}):null,_&&Ge?X||J?g.jsx(fN,{id:U,open:!0,onOpenChange:Ae,"aria-label":"Add to composer",children:Sr}):g.jsx("div",{id:U,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:Sr}):null]})}function mBt({disabled:e,isRunning:t}){var M,j,O,P;const{models:n,loading:r,ensureLoaded:o}=PC(),{agentSpec:a}=Eg(),i=V1(),s=y7(),l=vo(),[c,d]=w.useState(!1),[p,f]=w.useState(""),m=w.useRef(null),b=w.useId(),y=Gv(),x=ld(),_=!r&&n.length===0&&s!=null,k=w.useRef(null);w.useEffect(()=>{o()},[o]),w.useEffect(()=>{var F,$,H;if(!i||r||n.length===0)return;const D=n[0];if(D===void 0)return;const L=D.name,z=(($=(F=a==null?void 0:a.model)==null?void 0:F.name)==null?void 0:$.trim())??"";if(z&&n.some(Y=>Y.name===z)){k.current=null;return}k.current!==L&&(k.current=L,i({model:jv(L,(H=a==null?void 0:a.model)==null?void 0:H.params,D.properties.reasoningEfforts)}))},[i,r,n,(M=a==null?void 0:a.model)==null?void 0:M.name,(j=a==null?void 0:a.model)==null?void 0:j.params]);const E=((O=a==null?void 0:a.model)==null?void 0:O.name)??((P=n[0])==null?void 0:P.name)??"",T=n.find(D=>D.name===E),C=T?J2(T.name):E?J2(E):r?"Loading…":"Select model";w.useEffect(()=>{if(!c)return;const D=L=>{m.current&&!m.current.contains(L.target)&&d(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[c]);const A=(T==null?void 0:T.provider.name)??E,R=g.jsx(p$,{models:n,loading:r,selectedName:E,query:p,onQueryChange:f,listboxId:b,onOpenSettings:_?()=>{d(!1),f(""),l==null||l.setSettingsOpen(!0,"models")}:void 0,onSelect:D=>{var L;i==null||i({model:jv(D.name,(L=a==null?void 0:a.model)==null?void 0:L.params,D.properties.reasoningEfforts)}),d(!1),f("")}});return g.jsxs("div",{ref:m,className:"relative",children:[g.jsxs("button",{type:"button",disabled:e||t,"aria-haspopup":"listbox","aria-expanded":c,"aria-controls":c?b:void 0,title:"Select model",className:Xt({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:()=>d(D=>!D),children:[g.jsx(hN,{logo:T==null?void 0:T.provider.logo,label:A,className:"size-4 text-xs"}),g.jsx("span",{className:"truncate",children:C}),g.jsx(xe,{name:"chevron-down",className:"size-3.5 shrink-0 opacity-60"})]}),c?y||x?g.jsx(fN,{open:!0,onOpenChange:d,"aria-label":"Select model",children:R}):g.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:R}):null]})}function bBt({className:e,compact:t=!1}){const n=vo(),r=x7(),o=Zs(),a=w7({sandboxEnvironments:r})&&n!=null,i=(n==null?void 0:n.environmentsOpen)===!0;return a?g.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:g.jsxs("button",{type:"button","aria-label":t?"Environments":void 0,title:t?"Environments":void 0,"aria-current":i?"page":void 0,className:Xt({variant:"ghost",className:pe(n1,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?NC:"h-8 w-full !justify-start px-2.5 text-sm",i&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{i||o(Io.Environment.PAGE_OPENED),n.setEnvironmentsOpen(!i)},children:[g.jsx(xe,{name:"monitor",size:t?14:void 0}),t?g.jsx("span",{className:"text-center",children:"Environments"}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"truncate",children:"Environments"}),g.jsx(xe,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}var vBt=288,yBt=.75,xBt=.42;function KMe({requested:e,rowWidth:t}){if(t<=0)return e;const n=Math.min(vBt,t*.3),r=Math.max(n,t*yBt);return Math.min(r,Math.max(n,e))}function ern(e){return KMe({requested:e*xBt,rowWidth:e})}function wBt({name:e,view:t}){const n=We("SyntaxHighlighter"),r=We("Markdown");return t.status==="loading"?g.jsx("div",{className:"flex h-full items-center justify-center text-text-secondary",children:g.jsx(Gs,{size:20})}):t.status==="error"||t.status==="unavailable"?g.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"?g.jsx("div",{className:"flex h-full items-center justify-center p-4",children:g.jsx("img",{src:t.objectUrl,alt:e,className:"max-h-full max-w-full object-contain"})}):g.jsx("iframe",{title:e,src:t.objectUrl,className:"absolute inset-0 h-full w-full border-0"}):t.status==="html"?g.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"?g.jsx("div",{className:"px-4 py-3",children:g.jsx(r,{content:t.text})}):t.language!=null&&t.text.length<=RFt?g.jsx(n,{code:t.text,language:t.language,showLineNumbers:!0,className:"my-0 h-full rounded-none"}):g.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 sme(e,t,n){var o;const r=((o=e.parentElement)==null?void 0:o.getBoundingClientRect().width)??0;n(KMe({requested:t,rowWidth:r}))}function _Bt({name:e,placement:t,view:n,onClose:r,onDownload:o,onEnterFullPage:a,onExitFullPage:i,onRetry:s,downloadBusy:l=!1,widthPx:c,onWidthChange:d}){const p=w.useRef(null),f=t==="side"&&d!=null;w.useEffect(()=>{var y;(y=p.current)==null||y.focus()},[e,t]);const m=y=>{if(d==null)return;y.preventDefault();const x=y.currentTarget,_=p.current;if(_==null)return;typeof x.setPointerCapture=="function"&&x.setPointerCapture(y.pointerId);const k=y.clientX,E=_.getBoundingClientRect().width,T=A=>{sme(_,E+(k-A.clientX),d)},C=A=>{typeof x.hasPointerCapture=="function"&&x.hasPointerCapture(A.pointerId)&&x.releasePointerCapture(A.pointerId),x.removeEventListener("pointermove",T),x.removeEventListener("pointerup",C),x.removeEventListener("pointercancel",C)};x.addEventListener("pointermove",T),x.addEventListener("pointerup",C),x.addEventListener("pointercancel",C)};return g.jsxs("aside",{ref:p,tabIndex:-1,"data-slot":"aui_file-preview","data-placement":t,"aria-label":`Preview of ${e}`,onKeyDown:y=>{y.key==="Escape"&&(y.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?g.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:m,onKeyDown:y=>{if(d==null||p.current==null)return;const x=y.shiftKey?48:16;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault(),y.stopPropagation();const _=p.current.getBoundingClientRect().width,k=y.key==="ArrowLeft"?x:-x;sme(p.current,_+k,d)},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:[g.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"}),g.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:g.jsx(xe,{name:"grip-vertical",size:12})})]}):null,g.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border px-3",children:[g.jsx(xe,{name:"file",size:16,className:"shrink-0 text-text-secondary"}),g.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-text-primary",children:e}),n.status==="error"&&s!=null?g.jsx("button",{type:"button",onClick:s,className:Xt({variant:"ghost",size:"small"}),children:"Retry"}):null,t==="full"&&i!=null?g.jsx("button",{type:"button",onClick:i,"aria-label":"Exit full page",title:"Exit full page",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"compress",size:14})}):null,t!=="full"&&a!=null?g.jsx("button",{type:"button",onClick:a,"aria-label":"Full page",title:"Full page",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"expand",size:14})}):null,g.jsx("button",{type:"button",onClick:o,disabled:l,"aria-busy":l||void 0,"aria-label":l?`Downloading ${e}`:`Download ${e}`,title:"Download",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:l?g.jsx(Gs,{size:14}):g.jsx(xe,{name:"download",size:14})}),g.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",title:"Close preview",className:Xt({variant:"ghost",size:"icon",className:"h-7 w-7"}),children:g.jsx(xe,{name:"xmark",size:14})})]}),g.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:g.jsx(wBt,{name:e,view:n})})]})}var YMe=w.forwardRef(({className:e,isLoading:t=!1,...n},r)=>g.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&&g.jsx(Gs,{size:14})}));YMe.displayName="HistoryLoader";var ZMe="aui-trusted-external-hosts";function tC(){return{version:1,links:[],images:[]}}function lme(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function SBt(e){if(e==null||typeof e!="object"||!("version"in e)||e.version!==1)return tC();const t="links"in e&&lme(e.links)?e.links:[],n="images"in e&&lme(e.images)?e.images:[];return{version:1,links:t,images:n}}function XMe(){if(typeof window>"u")return tC();try{const e=JSON.parse(window.localStorage.getItem(ZMe)??"null");return SBt(e)}catch{return tC()}}function kBt(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ZMe,JSON.stringify(e))}catch{}}function qMe(e){try{const t=typeof window<"u"?window.location.href:"http://localhost";return new URL(e,t)}catch{return null}}function G_(e){const t=qMe(e);return t==null||t.protocol!=="http:"&&t.protocol!=="https:"?null:t.hostname.toLowerCase()}function m$(e){const t=G_(e);return t==null?!1:typeof window>"u"?!0:t!==window.location.hostname.toLowerCase()}function QMe({kind:e,host:t}){const n=t.toLowerCase();return XMe()[e].includes(n)}function cme({kind:e,host:t}){const n=t.toLowerCase(),r=XMe();r[e].includes(n)||kBt({...r,[e]:[...r[e],n]})}function JMe(e){const t=qMe(e);t!=null&&(t.protocol!=="http:"&&t.protocol!=="https:"||window.open(t.href,"_blank","noopener,noreferrer"))}var eOe=w.createContext(null);function tOe(){const e=w.useContext(eOe);if(e==null)throw new Error("Markdown external URL confirm requires ExternalUrlConfirmProvider");return e}function ume(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 EBt({children:e}){const[t,n]=w.useState(null),[r,o]=w.useState(!1),[a,i]=w.useState(()=>new Set),s=w.useCallback(k=>{o(!1),n({kind:"link",url:k})},[]),l=w.useCallback(k=>{o(!1),n({kind:"image",url:k})},[]),c=w.useCallback(k=>a.has(k.toLowerCase()),[a]),d=w.useCallback(()=>{n(null),o(!1)},[]),p=w.useCallback(()=>{if(t==null)return;const k=G_(t.url);if(t.kind==="link"){r&&k!=null&&cme({kind:"links",host:k}),JMe(t.url),d();return}k!=null&&(r&&cme({kind:"images",host:k}),i(E=>{const T=new Set(E);return T.add(k.toLowerCase()),T})),d()},[d,r,t]),f=w.useMemo(()=>({requestLinkConfirm:s,requestImageConfirm:l,isSessionImageHostTrusted:c}),[c,l,s]),m=t!=null?G_(t.url):null,b=(t==null?void 0:t.kind)==="image"?"Show external image":"Open external link",y=(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:",x=(t==null?void 0:t.kind)==="image"?"Show image":"Open link",_=m==null?null:(t==null?void 0:t.kind)==="image"?`Don't ask again for images from ${m}`:`Don't ask again for links to ${m}`;return g.jsxs(eOe.Provider,{value:f,children:[e,g.jsxs(lN,{open:t!=null,onOpenChange:k=>{k||d()},"aria-label":b,className:"max-w-md",children:[g.jsxs(cN,{children:[g.jsxs(xZ,{children:[g.jsx(wZ,{children:b}),g.jsx("p",{className:"text-sm text-text-secondary",children:y})]}),t!=null?g.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,_!=null?g.jsxs("button",{type:"button",role:"checkbox","aria-checked":r,className:"flex items-start gap-2 text-left text-sm text-text-secondary",onClick:()=>o(k=>!k),children:[g.jsx(jZ,{checked:r,className:"mt-0.5"}),g.jsx("span",{children:_})]}):null]}),g.jsxs(aMe,{children:[g.jsx(In.Secondary,{type:"button",onClick:d,children:"Cancel"}),g.jsx(In.Primary,{type:"button",onClick:p,children:x})]})]})]})}function TBt({href:e,children:t,node:n,...r}){const{requestLinkConfirm:o}=tOe(),a=e!=null&&e!==""&&ume(e),i=e!=null&&e!==""&&!a&&m$(e),s=a?void 0:i?"#":e,l=c=>{if(e==null||e==="")return;if(ume(e)){c.preventDefault();return}if(!m$(e))return;c.preventDefault();const d=G_(e);if(d!=null&&QMe({kind:"links",host:d})){JMe(e);return}o(e)};return g.jsx("a",{...r,href:s,target:i||a?"_blank":r.target,rel:"noopener noreferrer",onClick:l,onAuxClick:l,children:t})}function ABt({src:e,alt:t,node:n,...r}){const{requestImageConfirm:o,isSessionImageHostTrusted:a}=tOe(),i=typeof e=="string"?e:"",s=i!==""?G_(i):null;return!(i!==""&&m$(i))||s!=null&&(QMe({kind:"images",host:s})||a(s))?g.jsx("img",{...r,src:e,alt:t??""}):g.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:[g.jsx("span",{className:"text-sm text-text-secondary",children:t!=null&&t!==""?t:"External image"}),g.jsx("span",{className:"max-h-16 overflow-auto break-all font-mono text-xs text-text-secondary",children:i}),g.jsx(In.Secondary,{type:"button",size:"small",className:"self-start",onClick:()=>{i!==""&&o(i)},children:"Show image"})]})}function trn(){return Sa(()=>Promise.resolve().then(()=>pnn),void 0,import.meta.url)}var CBt=8*1024;function RBt(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 IBt(e){const{isStreaming:t,getActiveFenceCode:n,darkTheme:r,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s,OpenUiFenceBlock:l,SandboxArtifactDownload:c,SyntaxHighlighter:d,inlineCodeClassName:p}=e;return{a:TBt,img:ABt,pre({children:f}){return g.jsx(g.Fragment,{children:f})},code({className:f,children:m}){var k;const b=(k=/language-(\w+)/.exec(f??""))==null?void 0:k[1],y=String(m??"").replace(/\n$/,"");if(!f)return g.jsx("code",{className:pe("aui-inline-code rounded bg-secondary-bg px-1 py-0.5 font-mono text-sm",p),children:m});if(b==="openui")return g.jsx(l,{content:y,isStreaming:t,darkTheme:r});if(b==="sandbox_artifacts")return g.jsx(c,{code:y,fileDownloadBaseUrl:o,onDownloadArtifact:a,readOnly:i,sandboxDownloadReadOnlyTooltip:s});const x=n();return t===!0&&x!=null&&y===x&&y.length>CBt?g.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:g.jsx("code",{className:pe(f,"whitespace-pre-wrap break-words"),children:y})}):g.jsx(d,{code:y,language:b,darkTheme:r})}}}var NBt=[S9t];function nOe({content:e,isStreaming:t,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,className:i}){const s=mN(),l=IC(),c=s==="dark",d=We("OpenUiFenceBlock"),p=We("SandboxArtifactDownload"),f=We("SyntaxHighlighter"),m=w.useRef(null);m.current=t===!0?RBt(e):null;const b=w.useMemo(()=>IBt({isStreaming:t,getActiveFenceCode:()=>m.current,darkTheme:c,fileDownloadBaseUrl:n,onDownloadArtifact:r,readOnly:o,sandboxDownloadReadOnlyTooltip:a,OpenUiFenceBlock:d,SandboxArtifactDownload:p,SyntaxHighlighter:f,inlineCodeClassName:l.inlineCode}),[t,c,n,r,o,a,d,p,f,l.inlineCode]);return g.jsx(EBt,{children:g.jsx("div",{className:pe("aui-markdown markdown-body min-w-0 max-w-full overflow-x-clip",l.markdown,i),children:g.jsx(TEe,{remarkPlugins:NBt,components:b,children:e})})})}var MBt="h-6 w-6 text-text-secondary hover:text-text-primary [&_svg]:size-3.5";function rOe({isCopied:e,onCopy:t,createdAt:n,className:r}){const o=We("MessageTimestamp");return g.jsxs("div",{className:pe("aui-assistant-action-bar-root animate-in fade-in flex items-center gap-1 duration-200",r),children:[g.jsx(o,{createdAt:n,className:"mr-1"}),g.jsx(Ip,{"aria-label":"Copy",tooltip:"Copy",variant:"ghost",className:MBt,onClick:t,children:g.jsx(xe,{name:e?"check":"clone",size:"0.875em"})})]})}function OBt({message:e,className:t}){return g.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:[g.jsx(xe,{name:"circle-exclamation",size:"1rem",className:"text-warning-bg shrink-0","aria-hidden":!0}),g.jsx("span",{className:"aui-message-cancelled-message min-w-0 break-words",children:e})]})}function jBt({message:e,className:t}){return g.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:g.jsx("span",{className:"aui-message-error-message line-clamp-2",children:e})})}function PBt({className:e}){return g.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",e),children:[g.jsx(gZ,{state:"listening",size:20,"aria-hidden":!0}),g.jsx("span",{className:"aui-message-indicator-shimmer",children:"Working..."})]})}function DBt(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function LBt(e){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}).format(e)}function zBt({createdAt:e,className:t}){const n=DBt(e);return n==null?null:g.jsx(aN,{title:uMe(n),size:"fit",side:"bottom",children:g.jsx("span",{className:pe("text-xs font-medium cursor-pointer leading-normal shrink-0 text-text-secondary",t),children:LBt(n)})})}var dme;function oOe(){return dme??(dme=Sa(()=>import("./index-YbpMGQU0.js").then(e=>e.i),__vite__mapDeps([0,1]),import.meta.url)),dme}var aOe="aui-monaco-light",iOe="aui-monaco-dark",bu="#00000000",DZ=18,sOe=8,pme="10.5rem";function $Bt(e){const t={"editor.background":bu,"editor.lineHighlightBackground":bu,"editor.lineHighlightBorder":bu,"editorGutter.background":bu,"minimap.background":bu,focusBorder:bu,"scrollbar.shadow":bu,"editorOverviewRuler.border":bu,"editorOverviewRuler.background":bu};e.editor.defineTheme(aOe,{base:"vs",inherit:!0,rules:[],colors:t}),e.editor.defineTheme(iOe,{base:"vs-dark",inherit:!0,rules:[],colors:t})}function FBt(e,t,n){return e||t||(n==="dark"?iOe:aOe)}function M6(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 UBt(e,t,n){const o=Math.max(1,e.split(`
|
|
987
987
|
`).length)*DZ+sOe;return Math.min(n,Math.max(t,o))}var BBt={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:DZ,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 HBt({value:e,language:t="plaintext",theme:n,options:r,onChange:o,onMount:a,beforeMount:i,onAutoHeightChange:s,className:l,height:c=400,autoHeight:d=!1,maxHeight:p=pme,minHeight:f}){var F,$,H;const m=iye(),b=IC(),y=w.useRef(null),x=w.useRef(null),_=w.useRef(null),k=w.useRef(null),E=w.useRef(o),T=w.useRef(a),C=w.useRef(i),A=w.useRef(s);E.current=o,T.current=a,C.current=i,A.current=s;const R=M6(f,DZ+sOe),M=M6(p,M6(pme,168)),j=w.useRef({minPx:R,maxPx:M,autoHeight:d});j.current={minPx:R,maxPx:M,autoHeight:d};const[O,P]=w.useState(()=>d?UBt(e,R,M):0),D=FBt(n,(F=b.monaco)==null?void 0:F.monacoTheme,m),L=()=>{var G;const V=_.current,Y=y.current,{minPx:U,maxPx:X,autoHeight:J}=j.current;if(!V||!Y||!J)return;const K=Math.min(X,Math.max(U,V.getContentHeight()));P(K),Y.style.height=`${K}px`,V.layout(),(G=A.current)==null||G.call(A,K)};w.useEffect(()=>{if(!x.current)return;let V=null,Y=null,U=null,X=!1;return oOe().then(J=>{var G,Q;if(X||!x.current)return;const K=J;k.current=K,$Bt(K),(G=C.current)==null||G.call(C,K),V=K.editor.create(x.current,{value:e,language:t,theme:D,...BBt,...r}),_.current=V,Y=V.onDidChangeModelContent(()=>{var ne;(ne=E.current)==null||ne.call(E,V.getValue())}),d&&(U=V.onDidContentSizeChange(()=>{L()}),requestAnimationFrame(()=>L())),(Q=T.current)==null||Q.call(T,V,K)}),()=>{X=!0,Y==null||Y.dispose(),U==null||U.dispose(),V==null||V.dispose(),_.current=null,k.current=null}},[]),w.useEffect(()=>{const V=_.current;V&&V.getValue()!==e&&(V.setValue(e),d&&requestAnimationFrame(()=>L()))},[e,d,R,M]),w.useEffect(()=>{d&&requestAnimationFrame(()=>L())},[d,R,M]),w.useEffect(()=>{var V;(V=k.current)==null||V.editor.setTheme(D)},[D]);const z=d?O:c;return g.jsx("div",{ref:y,className:pe("aui-monaco overflow-hidden",($=b.monaco)==null?void 0:$.root,l),style:{height:z},children:g.jsx("div",{ref:x,className:pe("h-full w-full overflow-hidden",(H=b.monaco)==null?void 0:H.editor)})})}var VBt="You do not have permission to perform this action.";function GBt({allowed:e,children:t,deniedMessage:n=VBt}){const r=w.cloneElement(t,{disabled:t.props.disabled===!0||!e});return e?r:g.jsx(eo,{content:n,side:"bottom",children:g.jsx("span",{"aria-disabled":"true",className:"inline-flex cursor-not-allowed *:pointer-events-none",children:r})})}var fme="sandbox_artifacts",O6=/\[([^\]]*)\]\(([^)]*)\)/g;function WBt(e){var a,i;const t=e.trim(),n=t.startsWith(fme)?t.slice(fme.length).trimStart():t,r=[];O6.lastIndex=0;let o=O6.exec(n);for(;o!==null;){const s=((a=o[1])==null?void 0:a.trim())??"",l=((i=o[2])==null?void 0:i.trim())??"";s&&l&&r.push({name:s,path:l}),o=O6.exec(n)}return r.length>0?r:n.split(`
|
|
988
988
|
`).flatMap(s=>{const l=s.indexOf(":");if(l===-1)return[];const c=s.slice(0,l).trim(),d=s.slice(l+1).trim();return!c||!d?[]:c.startsWith("[")||d.startsWith("(")?[]:[{name:c,path:d}]})}function KBt({code:e,fileDownloadBaseUrl:t,onDownloadArtifact:n,readOnly:r,sandboxDownloadReadOnlyTooltip:o}){const a=We("ChatFileDownload"),i=w.useMemo(()=>WBt(e),[e]);return i.length===0?null:g.jsx(a,{files:i,fileDownloadBaseUrl:t,onDownloadArtifact:n,readOnly:r,readOnlyTooltip:o})}function j6({value:e,className:t}){const n=We("MonacoEditorCore");return g.jsx(n,{language:"json",value:e,autoHeight:!0,maxHeight:"10.5rem",options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"off",folding:!0,fontSize:12},className:pe("!border-0",t)})}function YBt({command:e,exitCode:t,argsJson:n,resultText:r,resultJson:o,viewMode:a="terminal",hasContent:i=!1,onViewModeChange:s,dataTestPrefix:l}){return g.jsxs("div",{className:"rounded-lg border border-border bg-primary-bg","data-testid":l?`${l}-sandbox`:void 0,children:[g.jsx("div",{className:"rounded-t-md border-b border-primary-button-bg/30 bg-primary-button-bg/10",children:g.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2 px-3 py-1.5",children:[g.jsx("p",{className:"min-w-0 font-sans text-xs font-medium text-primary-button-bg",children:"sandbox"}),g.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",onClick:c=>c.stopPropagation(),onKeyDown:c=>c.stopPropagation(),children:[t!=null&&g.jsxs("span",{className:pe("inline-flex h-6 items-center gap-1 rounded px-1.5 text-xs lowercase",t===0?"bg-success-bg/10 text-success-bg":"bg-failure-bg/10 text-failure-bg"),"data-testid":l?`${l}-exit-code`:void 0,children:[g.jsx(xe,{name:t===0?"circle-check":"circle-xmark",size:12}),"exit: ",t]}),g.jsxs("div",{className:"inline-flex h-6 items-center rounded-md border border-border bg-primary-bg p-0.5",role:"group","aria-label":"Sandbox view",children:[g.jsx("button",{type:"button",title:"Terminal View","aria-label":"Terminal View","aria-pressed":a==="terminal",onClick:()=>s==null?void 0:s("terminal"),className:pe("inline-flex size-5 cursor-pointer items-center justify-center rounded-sm text-text-secondary transition-colors",a==="terminal"&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm"),children:g.jsx(xe,{name:"terminal",size:12})}),g.jsx("button",{type:"button",title:"Code View","aria-label":"Code View","aria-pressed":a==="code",onClick:()=>s==null?void 0:s("code"),className:pe("inline-flex size-5 cursor-pointer items-center justify-center rounded-sm text-text-secondary transition-colors",a==="code"&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm"),children:g.jsx(xe,{name:"code",size:12})})]})]})]})}),g.jsx("div",{className:"rounded-b-lg border border-t-0 border-border p-3",children:i&&g.jsx("div",{className:"max-h-80 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words font-mono text-xs text-text-primary",children:a==="code"?g.jsxs(g.Fragment,{children:[n&&g.jsxs("div",{className:"my-1 border-l-4 border-primary-button-bg px-3",children:[g.jsx("div",{className:"mb-1 font-sans text-xs font-medium leading-4",children:"Arguments"}),g.jsx(j6,{value:n,className:"pl-2"})]}),o&&g.jsxs("div",{className:"my-1 border-l-4 border-primary-button-bg/60 px-3",children:[g.jsx("div",{className:"mb-1 mt-2 font-sans text-xs font-medium leading-4",children:"Result"}),g.jsx(j6,{value:o,className:"pl-2"})]})]}):g.jsxs(g.Fragment,{children:[e&&g.jsxs("div",{className:"my-1 break-all border-l-4 border-primary-button-bg px-3",children:[g.jsx("div",{className:"mb-1 text-[12px] font-medium leading-4 text-text-secondary",children:"COMMAND"}),g.jsxs("div",{children:[g.jsx("span",{className:"text-primary-button-bg",children:"$"})," ",e]})]}),r?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"mx-3 my-1 border-t border-border"}),g.jsxs("div",{className:"my-1 break-all border-l-4 border-primary-button-bg/60 px-3",children:[g.jsx("div",{className:"mb-1 text-[12px] font-medium leading-4 text-text-secondary",children:"OUTPUT"}),g.jsx("div",{children:r})]})]}):o&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"mx-3 my-1 border-t border-border"}),g.jsxs("div",{className:"my-1 border-l-4 border-primary-button-bg/60 px-3",children:[g.jsx("div",{className:"mb-1 text-[12px] font-medium leading-4 text-text-secondary",children:"OUTPUT"}),g.jsx(j6,{value:o,className:"pl-2"})]})]})]})})})]})}function ZBt({name:e,intent:t,status:n,expanded:r,onToggle:o,command:a,exitCode:i,argsJson:s,resultText:l,resultJson:c,viewMode:d="terminal",hasContent:p=!1,onViewModeChange:f,durationText:m,approvalSlot:b,approvalId:y,dataTestPrefix:x,className:_}){const k=We("ToolCallCard"),E=n==="running";return g.jsx(k,{toolName:t||e,icon:"cube",iconClassName:"text-primary-button-bg shrink-0",expanded:r,onToggle:o,awaiting:E,awaitingText:m??"Running…",showResponseLine:!1,status:E?void 0:n,exitCode:i,approvalSlot:b,approvalId:y,dataTestPrefix:x,requestSlot:g.jsx(YBt,{command:a,exitCode:i,argsJson:s,resultText:l,resultJson:c,viewMode:d,hasContent:p,onViewModeChange:f,dataTestPrefix:x}),className:pe("aui-sandbox-tool-call-card",_)})}var XBt=400;function qBt({value:e,onCommit:t,delayMs:n=XBt}){const[r,o]=w.useState(e),a=w.useRef(e),i=w.useRef(!1),s=w.useRef(null),l=w.useRef(t);l.current=t;const c=w.useCallback(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),d=w.useCallback(()=>{c(),i.current&&(i.current=!1,l.current(a.current))},[c]),p=w.useCallback(f=>{a.current=f,i.current=!0,o(f),c(),s.current=setTimeout(d,n)},[c,n,d]);return w.useEffect(()=>{i.current||(a.current=e,o(e))},[e]),w.useEffect(()=>()=>{c(),i.current&&(i.current=!1,l.current(a.current))},[c]),{draft:r,onChange:p,flush:d}}var LZ=w.createContext(null);function QBt({children:e}){const{agentSpec:t}=Eg(),n=V1(),r=w.useCallback(l=>n==null?void 0:n({instructions:l}),[n]),{draft:o,onChange:a,flush:i}=qBt({value:(t==null?void 0:t.instructions)??"",onCommit:r}),s=w.useMemo(()=>({draft:o,onChange:a,flush:i}),[o,i,a]);return g.jsx(LZ.Provider,{value:s,children:e})}function nrn(){const e=w.useContext(LZ);if(e===null)throw new Error("useAgentConfigInstructions must be used within AgentConfigInstructionsProvider");return e}function JBt(){return w.useContext(LZ)}var eHt="No permission to create agents";function tHt({disabled:e=!1,className:t,children:n="Save Agent",instructionsOverride:r}){return g.jsx(nHt,{disabled:e,className:t,instructionsOverride:r,children:n})}function nHt({disabled:e,className:t,children:n,instructionsOverride:r}){const{agentSpec:o,draftSessionId:a}=Eg(),i=w.useRef(o);i.current=o;const s=FLt(),l=ULt(),c=ui(),d=vo(),p=(d==null?void 0:d.mode.status)==="active"?d.mode.agentId:void 0,{allows:f}=G1({resourceType:"agent",resourceIds:p==null?[]:[p]}),m=f(p,"MANAGE"),{canCreateAgent:b,loading:y}=uye(),x=JBt(),_=We("SaveAgentForm"),k=We("PermissionGuard"),E=MMe(),[T,C]=w.useState(!1),[A,R]=w.useState("create"),[M,j]=w.useState(""),[O,P]=w.useState(""),[D,L]=w.useState(null),[z,F]=w.useState(!1),[$,H]=w.useState(null),V=(d==null?void 0:d.mode.status)==="active"&&d.mode.isMutable&&d.mode.agentId!==void 0,Y=b&&!y,U=V?m:Y,X=()=>{z||(C(!1),P(""),L(null),H(null))},J=async()=>{if(i.current===null||c===null||(V?!m:!Y))return;H(null),x==null||x.flush(),await s();const Q=i.current;if(Q===null)return;const ne=r??(x==null?void 0:x.draft),de=ne===void 0?Q:{...Q,instructions:ne},se=(d==null?void 0:d.mode.status)==="active"?d.mode.agentName??d.mode.agentId??"":"";R(V?"update":"create"),j(se),P(se&&(d==null?void 0:d.mode.status)==="active"?d.mode.description??"":""),L(oMe(de)),C(!0)},K=async()=>{if(c===null||D===null||(A==="update"?!m:!Y))return;const Q=M.trim();if(!Q||!D.model.name.trim())return;const ne=O.trim();if(ne){F(!0),H(null);try{const de=await c.saveAgent({agentName:Q,...ne?{description:ne}:{},agentSpec:D,intent:A,sessionId:a});l({agentSpec:D,updatedAt:de.sessionUpdatedAt}),d==null||d.bindMutableAgent({agentId:de.agentId??Q,agentName:Q,...ne?{description:ne}:{},agentSpec:D}),d==null||d.invalidateAgentsList(),C(!1),P(""),L(null)}catch(de){H(aa(de,"Could not save agent"))}finally{F(!1)}}},G=V&&n==="Save Agent"?"Update Agent":n;return E?g.jsxs(g.Fragment,{children:[g.jsx(k,{allowed:U,deniedMessage:V?void 0:eHt,children:g.jsxs(In.Primary,{type:"button",size:"large",disabled:e||c===null||o===null,className:t,onClick:()=>void J(),children:[g.jsx(xe,{name:"save",className:"size-3.5"}),G]})}),g.jsx(uN,{open:T,onOpenChange:Q=>!Q&&X(),title:A==="create"?"Save agent":"Update agent",anchor:"right",size:"md","aria-label":A==="create"?"Save agent":"Update agent",children:D?g.jsx(_,{intent:A,name:M,description:O,spec:D,saving:z,error:$,onNameChange:j,onDescriptionChange:P,onCancel:X,onSave:()=>void K()}):null})]}):null}function rHt({intent:e,name:t,description:n,spec:r,saving:o,error:a,onNameChange:i,onDescriptionChange:s,onCancel:l,onSave:c}){const d=w.useRef(null);w.useEffect(()=>{var f,m;a!==null&&((m=(f=d.current)==null?void 0:f.scrollIntoView)==null||m.call(f,{block:"nearest",behavior:"smooth"}))},[a]);const p=t.trim()!==""&&r.model.name.trim()!==""&&n.trim()!=="";return g.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:[g.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-3",children:[g.jsxs("label",{className:"mb-3 block",children:[g.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent name"}),g.jsx("input",{value:t,disabled:o||e==="update",onChange:f=>i(f.target.value),placeholder:"release-notes",className:Bo("h-8 disabled:opacity-60")})]}),g.jsxs("label",{className:"mb-3 block",children:[g.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Description"}),g.jsx("textarea",{value:n,disabled:o,onChange:f=>s(f.target.value),rows:4,maxLength:1024,placeholder:"Describe what this agent does.",className:Bo("resize-y py-2 disabled:opacity-60")})]}),a?g.jsx("p",{ref:d,role:"alert",className:"text-failure-bg mt-3 text-sm wrap-break-word whitespace-pre-wrap tab-4",children:a}):null]}),g.jsxs("div",{className:"bg-card-bg sticky bottom-0 z-10 flex shrink-0 justify-end gap-2 border-t border-border px-5 py-4",children:[g.jsx(In.Secondary,{type:"button",disabled:o,onClick:l,children:"Cancel"}),g.jsx(In.Primary,{type:"button",disabled:o||!p,onClick:c,children:o?"Saving…":"Save changes"})]})]})}function oHt({className:e,compact:t=!1}){const n=vo(),r=OC(),o=Zs(),a=o1({schedules:r})&&n!=null,i=(n==null?void 0:n.schedulesOpen)===!0;return a?g.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:g.jsxs("button",{type:"button","aria-label":t?"Schedules":void 0,title:t?"Schedules":void 0,"aria-current":i?"page":void 0,className:Xt({variant:"ghost",className:pe(n1,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?NC:"h-8 w-full !justify-start px-2.5 text-sm",i&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{i||o(Io.Schedule.PAGE_OPENED),n.setSchedulesOpen(!i)},children:[g.jsx(xe,{name:"calendar-clock",size:t?14:void 0}),t?g.jsx("span",{className:"text-center",children:"Schedules"}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"truncate",children:"Schedules"}),g.jsx(xe,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}var lOe=w.forwardRef(({className:e,disabled:t,...n},r)=>t?null:g.jsx("span",{ref:r,className:pe("absolute -top-14 z-10 inline-flex self-center"),children:g.jsx("button",{type:"button","aria-label":"Scroll to bottom",title:"Scroll to bottom",disabled:t,className:Xt({variant:"ghost",size:"icon",className:pe("aui-thread-scroll-to-bottom rounded-full border border-border bg-primary-bg text-text-primary shadow-sm hover:bg-ghost-button-hover hover:text-text-primary p-3",e)}),...n,children:g.jsx(xe,{name:"arrow-down"})})}));lOe.displayName="ScrollToBottomButton";function aHt(){const e=vo(),t=We("AgentsLibraryButton");return(e==null?void 0:e.mode.status)!=="idle"?null:g.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col items-center justify-center gap-4 px-6","data-slot":"aui_select-agent-empty",children:[g.jsx("p",{className:"text-text-secondary max-w-sm text-center text-sm",children:"Select an agent to start chatting"}),g.jsx(t,{className:"w-56 max-w-full"})]})}function iHt({className:e,compact:t=!1}){const n=Vv(),r=vo(),o=Zs(),{updateShareSearch:a}=dN(),i=(r==null?void 0:r.sessionsOpen)===!0;return r1({sessions:n})&&r!=null?g.jsx("div",{className:pe("relative min-w-0",t?"flex justify-center":"w-full",e),children:g.jsxs("button",{type:"button","aria-label":t?"Sessions":void 0,title:t?"Sessions":void 0,"aria-current":i?"page":void 0,className:Xt({variant:"ghost",className:pe(n1,"font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",t?NC:"h-8 w-full !justify-start px-2.5 text-sm",i&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{if(!i){o(Io.SessionsBrowser.OPENED);const l=Mu(window.location.search);a({view:"sessions",agentId:null,sessionId:null,timeRange:l.timeRange??XE()})}r.setSessionsOpen(!0)},children:[g.jsx(xe,{name:"message-square-text",size:t?14:void 0}),t?g.jsx("span",{className:"text-center",children:"Sessions"}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"truncate",children:"Sessions"}),g.jsx(xe,{name:"chevron-right",className:"ml-auto size-3.5 shrink-0 opacity-60"})]})]})}):null}function sHt(){const e=Ve(a=>a.threadListItem.remoteId),t=iN(),n=We("ShareSessionDialog"),r=We("PermissionGuard");if(e==null)return null;const o=g.jsxs(In.Ghost,{type:"button",title:"Share",children:[g.jsx(xe,{name:"share"}),"Share"]});return t?g.jsx(n,{sessionId:e,trigger:o}):g.jsx(r,{allowed:!1,children:o})}var nC="envQ",rC="envIsNew",lHt="trueforge-environment-share";function cHt(e){return e!=null&&e.length>0?e:null}function rrn(e){const t=new URLSearchParams(e.startsWith("?")?e.slice(1):e);return{q:cHt(t.get(nC)),isNew:t.get(rC)==="true"}}function uHt(e,t){t.q===null?e.delete(nC):t.q!=null&&e.set(nC,t.q),t.isNew===null||t.isNew===!1?e.delete(rC):t.isNew===!0&&e.set(rC,"true")}function px(e){e.delete(nC),e.delete(rC)}function orn(e){const t=new URL(window.location.href);return uHt(t.searchParams,e),window.history.replaceState(window.history.state,"",t),window.dispatchEvent(new Event(lHt)),t.search}var pl={root:"/",settings:"/settings",library:"/library",libraryAgent:"/library/:agentId",schedules:"/schedules",environments:"/environments",buildAgent:"/build-agent",agent:"/agents/:agentName",session:"/sessions/:sessionId",sharedSession:"/sessions/share/:sessionId",sessionsBrowser:"/sessions"};function zZ(e){const t=e.trim(),n=t.startsWith("/")?t:`/${t}`;return n.length>1&&n.endsWith("/")?n.slice(0,-1):n}function oc(e,t){return e===!1?null:zZ(e??t)}function arn(e){const t=e==null?void 0:e.paths;return{basename:(e==null?void 0:e.basename)??"",root:zZ((t==null?void 0:t.root)??pl.root),settings:oc(t==null?void 0:t.settings,pl.settings),library:oc(t==null?void 0:t.library,pl.library),libraryAgent:oc(t==null?void 0:t.libraryAgent,pl.libraryAgent),schedules:oc(t==null?void 0:t.schedules,pl.schedules),environments:oc(t==null?void 0:t.environments,pl.environments),buildAgent:oc(t==null?void 0:t.buildAgent,pl.buildAgent),agent:oc(t==null?void 0:t.agent,pl.agent),session:oc(t==null?void 0:t.session,pl.session),sharedSession:oc(t==null?void 0:t.sharedSession,pl.sharedSession),sessionsBrowser:oc(t==null?void 0:t.sessionsBrowser,pl.sessionsBrowser)}}function $Z(e){return e.split("/").filter(t=>t.length>0)}function IE(e,t){return"/"+$Z(e).map(n=>n.startsWith(":")?encodeURIComponent(t):n).join("/")}function cOe(e,t){switch(e.type){case"root":return t.root;case"settings":return t.settings;case"library":return t.library;case"libraryAgent":return t.libraryAgent==null?null:IE(t.libraryAgent,e.agentId);case"schedules":return t.schedules;case"environments":return t.environments;case"buildAgent":return t.buildAgent;case"agent":return t.agent==null?null:IE(t.agent,e.agentName);case"session":return t.session==null?null:IE(t.session,e.sessionId);case"sharedSession":return t.sharedSession==null?null:IE(t.sharedSession,e.sessionId);case"sessionsBrowser":return t.sessionsBrowser}}function irn({sessionId:e,routes:t,href:n=typeof window>"u"?"http://localhost/":window.location.href}){const r=cOe({type:"session",sessionId:e},t);if(r==null)return null;const o=new URL(n),a=t.basename.endsWith("/")?t.basename.slice(0,-1):t.basename;return o.pathname=`${a}${r}`||"/",o.search=dOe({type:"session"},o.search),o.hash="",o.toString()}function uOe({sessionId:e,routes:t,href:n=typeof window>"u"?"http://localhost/":window.location.href}){const r={type:"sharedSession",sessionId:e},o=t==null?null:cOe(r,t),a=new URL(n);if(t!=null&&o!=null){const i=t.basename.endsWith("/")?t.basename.slice(0,-1):t.basename;return a.pathname=`${i}${o}`||"/",a.search=dOe(r,a.search),a.hash="",a.toString()}return ap(a.searchParams,{sessionId:e,agentId:null,tab:null,view:jC,timeRange:null}),a.toString()}function dOe(e,t){if(e.type==="settings")return t;const n=new URLSearchParams(t.startsWith("?")?t.slice(1):t);if(e.type==="sessionsBrowser")ap(n,{tab:null}),sx(n),px(n),ix(n);else if(e.type==="library")ap(n,{sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),sx(n),px(n);else if(e.type==="libraryAgent"){const o=Mu(t),a=W7t(t);ap(n,{view:null,timeRange:null,...o.sessionId!=null&&o.agentId!==e.agentId?{sessionId:null,agentId:null}:{}}),sx(n),px(n),ix(n),o.tab==="schedules"&&bMe(n,{status:a.status,q:a.q,isNew:a.isNew})}else e.type==="schedules"?(ap(n,{sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),px(n),ix(n)):e.type==="environments"?(ap(n,{sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),sx(n),ix(n)):(ap(n,{sessionId:null,agentId:null,tab:null,view:null,timeRange:null}),sx(n),px(n),ix(n));const r=n.toString();return r.length>0?`?${r}`:""}function dHt(e){try{return decodeURIComponent(e)}catch{return null}}function NE(e,t){const n=$Z(e);if(n.length!==t.length)return null;let r=null;for(const[o,a]of n.entries()){const i=t[o];if(i===void 0)return null;if(a.startsWith(":")){const s=dHt(i);if(s==null)return null;r=s}else if(a!==i)return null}return r}function pHt(e,t){const n=zZ(e),r=$Z(n);if(t.settings!=null&&n===t.settings)return{type:"settings"};if(t.library!=null&&n===t.library)return{type:"library"};if(t.sessionsBrowser!=null&&n===t.sessionsBrowser)return{type:"sessionsBrowser"};if(t.libraryAgent!=null){const o=NE(t.libraryAgent,r);if(o!=null)return{type:"libraryAgent",agentId:o}}if(t.schedules!=null&&n===t.schedules)return{type:"schedules"};if(t.environments!=null&&n===t.environments)return{type:"environments"};if(t.buildAgent!=null&&n===t.buildAgent)return{type:"buildAgent"};if(t.agent!=null){const o=NE(t.agent,r);if(o!=null)return{type:"agent",agentName:o}}if(t.session!=null){const o=NE(t.session,r);if(o!=null)return{type:"session",sessionId:o}}if(t.sharedSession!=null){const o=NE(t.sharedSession,r);if(o!=null)return{type:"sharedSession",sessionId:o}}return n===t.root?{type:"root"}:null}function srn({pathname:e,search:t,routes:n}){const r=pHt(e,n);if(r==null||r.type!=="root")return r;const{agentId:o,sessionId:a,view:i}=Mu(t);return i===jC&&a!=null?{type:"sharedSession",sessionId:a}:o!=null?{type:"libraryAgent",agentId:o}:r}function lrn(e,t){return e.type!==t.type?!1:e.type==="agent"&&t.type==="agent"?e.agentName===t.agentName:e.type==="libraryAgent"&&t.type==="libraryAgent"?e.agentId===t.agentId:e.type==="session"&&t.type==="session"||e.type==="sharedSession"&&t.type==="sharedSession"?e.sessionId===t.sessionId:!0}var pOe=w.createContext(null);function fHt({routes:e,children:t}){return g.jsx(pOe.Provider,{value:e,children:t})}function fOe(){return w.useContext(pOe)}function hHt(e){const t=fOe(),[n,r]=w.useState(!1);w.useEffect(()=>{if(!n)return;const a=window.setTimeout(()=>r(!1),2e3);return()=>window.clearTimeout(a)},[n]);const o=w.useCallback(async()=>{if(e!=null)try{await navigator.clipboard.writeText(uOe({sessionId:e,routes:t})),r(!0)}catch{}},[t,e]);return{copied:n,copySharedSessionLink:o}}function gHt(e){const t=ui(),n=sN(),r=fOe(),o=e==null||e.length===0?[]:[e],{allows:a}=G1({resourceType:"session",resourceIds:o}),i=a(e,"MANAGE"),{copied:s,copySharedSessionLink:l}=hHt(e),[c,d]=w.useState("private"),[p,f]=w.useState(),[m,b]=w.useState(!1),y=e==null||e.length===0?"":uOe({sessionId:e,routes:r}),x=w.useCallback(async()=>{if(!(e==null||e.length===0||t==null)){b(!0);try{const k=await t.getSession({sessionId:e});if(d(k.shared===!0?"tenant":"private"),t.getMe!=null)try{const E=await t.getMe();E.tenantId.length>0&&f(E.tenantId)}catch{}}catch(k){n==null||n.showError(k)}finally{b(!1)}}},[t,e,n]),_=w.useCallback(async k=>{if(!i||k===c)return;const E=c;if(d(k),!(e==null||e.length===0||t==null))try{await t.updateSession({sessionId:e,shared:k==="tenant"})}catch(T){d(E),n==null||n.showError(T)}},[i,c,t,e,n]);return{permission:c,canManage:i,loading:m,shareUrl:y,copied:s,tenantId:p,load:x,changePermission:_,copySharedSessionLink:l}}var hme={private:{title:"Only you",description:"Only you have access"},tenant:{title:"Everyone within this tenant",description:"Everyone has access"}},mHt=["private","tenant"];function gme({permission:e,tenantId:t}){return e==="tenant"&&t!=null&&t.length>0?{title:`Everyone within ${t}`,description:hme.tenant.description}:hme[e]}function bHt({permission:e,tenantId:t,disabled:n,onChange:r}){const o=gme({permission:e,tenantId:t});return g.jsx(of,{align:"start",captureOutsideClick:!0,containerClassName:"w-full",className:"z-210 w-108 p-1 gap-1",trigger:g.jsxs("button",{type:"button",disabled:n,"aria-label":"Session sharing",className:pN("h-auto w-full bg-secondary-bg px-4 py-1.75 disabled:cursor-not-allowed disabled:opacity-50"),children:[g.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[g.jsx(xe,{name:"check",size:"1rem",className:"text-text-primary shrink-0"}),g.jsxs("span",{className:"flex min-w-0 items-baseline gap-2 text-sm",children:[g.jsx("span",{className:"text-text-primary font-semibold",children:o.title}),g.jsx("span",{className:"text-text-secondary truncate",children:o.description})]})]}),g.jsx(xe,{name:"chevron-down",size:"1rem",className:"text-text-secondary shrink-0"})]}),children:mHt.map(a=>{const i=gme({permission:a,tenantId:t});return g.jsxs("button",{type:"button",role:"option","aria-label":i.title,"aria-selected":a===e,className:Nv(),onClick:()=>r(a),children:[g.jsxs("span",{"aria-hidden":!0,className:"flex min-w-0 flex-1 items-baseline gap-2",children:[g.jsx("span",{className:"font-semibold",children:i.title}),g.jsx("span",{className:"text-text-secondary truncate",children:i.description})]}),g.jsx(xe,{name:"check",className:a===e?"opacity-100":"opacity-0"})]},a)})})}function vHt({sessionId:e,trigger:t}){const{permission:n,canManage:r,loading:o,shareUrl:a,copied:i,tenantId:s,load:l,changePermission:c,copySharedSessionLink:d}=gHt(e),p=Zs();return g.jsxs(of,{trigger:t,align:"end",closeOnClick:!1,onOpenChange:f=>{f&&(p(Io.Session.SHARE_OPENED,{session_id:e}),l())},className:"w-120 gap-5 rounded-[0.75rem] p-6 shadow-xs",children:[g.jsxs("div",{className:"flex w-full items-center gap-2",children:[g.jsx(xe,{name:"user-cog",size:"1.25rem",className:"text-text-primary shrink-0"}),g.jsx("p",{className:"text-text-primary min-w-0 flex-1 text-base font-semibold",children:"Change permissions"})]}),g.jsx(bHt,{permission:n,tenantId:s,disabled:!r||o,onChange:f=>{c(f)}}),g.jsx("div",{role:"separator",className:"bg-border h-px w-full"}),g.jsxs("div",{className:"flex w-full items-center gap-2",children:[g.jsx(xe,{name:"link",size:"1rem",className:"text-text-primary shrink-0"}),g.jsx("p",{className:"text-text-primary min-w-0 flex-1 text-sm font-semibold",children:"Share URL"})]}),g.jsxs("div",{className:"flex h-8 w-full items-center gap-2",children:[g.jsx("input",{readOnly:!0,value:a,"aria-label":"Share URL",className:Bo("h-8 min-w-0 flex-1 px-3.5 text-[0.8125rem]")}),g.jsxs(In.Primary,{type:"button",size:"large",className:"h-8 shrink-0 rounded px-2.5 text-xs",onClick:()=>{p(Io.Session.SHARE_LINK_COPIED,{session_id:e,permission:n}),d()},children:[g.jsx(xe,{name:i?"check":"copy",size:"0.875rem"}),i?"Copied":"Copy"]})]})]})}function yHt(){return null}function xHt({className:e}){return g.jsxs("div",{role:"status","aria-label":"Loading conversation","data-slot":"aui_thread-history-skeleton",className:pe("mb-14 flex flex-col gap-y-6",e),children:[g.jsx("div",{className:"flex justify-end",children:g.jsx(ti,{className:"h-10 w-[min(85%,20rem)] rounded-xl"})}),g.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[g.jsx(ti,{className:"h-4 w-full max-w-md"}),g.jsx(ti,{className:"h-4 w-full max-w-sm"}),g.jsx(ti,{className:"h-4 w-2/3 max-w-xs"})]})]})}function wHt({agentName:e,instruction:t,stepCount:n,status:r,expanded:o,onToggle:a,durationText:i,children:s,renderInstruction:l,dataTestPrefix:c,className:d}){const p=We("Markdown"),f=r==="running"?"running":r==="success"?"success":"error",m=t.trim().length>0?l?l(t):g.jsx(p,{content:t,className:"flex flex-col font-sans text-sm text-text-secondary"}):null;return g.jsx("div",{className:pe("aui-sub-agent-card min-w-0",d),"data-testid":c?`${c}-sub-agent-card`:void 0,children:g.jsxs(vZ,{icon:"agent-2",iconVariant:"primary",title:`Sub-agent: ${e}`,expandable:!0,expanded:o,onToggle:a,status:f,statusText:i,dataTestPrefix:c,children:[m!=null&&g.jsxs("div",{className:"mb-3 flex flex-col gap-2 rounded-md border border-border p-2",children:[g.jsx("h4",{className:"text-sm font-semibold text-text-primary",children:"Instructions"}),g.jsx("div",{className:"text-sm text-text-secondary","data-testid":c?`${c}-instructions`:void 0,children:m})]}),s!=null&&g.jsx("div",{className:"flex min-w-0 flex-col gap-3","data-testid":c?`${c}-nested-content`:void 0,children:s})]})})}var _Ht={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}},SHt={'code[class*="language-"]':{background:"hsl(230, 1%, 98%)",color:"hsl(230, 8%, 24%)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(230, 1%, 98%)",color:"hsl(230, 8%, 24%)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"] *::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"]::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"] *::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'pre[class*="language-"] *::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},prolog:{color:"hsl(230, 4%, 64%)"},cdata:{color:"hsl(230, 4%, 64%)"},doctype:{color:"hsl(230, 8%, 24%)"},punctuation:{color:"hsl(230, 8%, 24%)"},entity:{color:"hsl(230, 8%, 24%)",cursor:"help"},"attr-name":{color:"hsl(35, 99%, 36%)"},"class-name":{color:"hsl(35, 99%, 36%)"},boolean:{color:"hsl(35, 99%, 36%)"},constant:{color:"hsl(35, 99%, 36%)"},number:{color:"hsl(35, 99%, 36%)"},atrule:{color:"hsl(35, 99%, 36%)"},keyword:{color:"hsl(301, 63%, 40%)"},property:{color:"hsl(5, 74%, 59%)"},tag:{color:"hsl(5, 74%, 59%)"},symbol:{color:"hsl(5, 74%, 59%)"},deleted:{color:"hsl(5, 74%, 59%)"},important:{color:"hsl(5, 74%, 59%)"},selector:{color:"hsl(119, 34%, 47%)"},string:{color:"hsl(119, 34%, 47%)"},char:{color:"hsl(119, 34%, 47%)"},builtin:{color:"hsl(119, 34%, 47%)"},inserted:{color:"hsl(119, 34%, 47%)"},regex:{color:"hsl(119, 34%, 47%)"},"attr-value":{color:"hsl(119, 34%, 47%)"},"attr-value > .token.punctuation":{color:"hsl(119, 34%, 47%)"},variable:{color:"hsl(221, 87%, 60%)"},operator:{color:"hsl(221, 87%, 60%)"},function:{color:"hsl(221, 87%, 60%)"},url:{color:"hsl(198, 99%, 37%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(230, 8%, 24%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(230, 8%, 24%)"},".language-css .token.selector":{color:"hsl(5, 74%, 59%)"},".language-css .token.property":{color:"hsl(230, 8%, 24%)"},".language-css .token.function":{color:"hsl(198, 99%, 37%)"},".language-css .token.url > .token.function":{color:"hsl(198, 99%, 37%)"},".language-css .token.url > .token.string.url":{color:"hsl(119, 34%, 47%)"},".language-css .token.important":{color:"hsl(301, 63%, 40%)"},".language-css .token.atrule .token.rule":{color:"hsl(301, 63%, 40%)"},".language-javascript .token.operator":{color:"hsl(301, 63%, 40%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(344, 84%, 43%)"},".language-json .token.operator":{color:"hsl(230, 8%, 24%)"},".language-json .token.null.keyword":{color:"hsl(35, 99%, 36%)"},".language-markdown .token.url":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url > .token.operator":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url > .token.content":{color:"hsl(221, 87%, 60%)"},".language-markdown .token.url > .token.url":{color:"hsl(198, 99%, 37%)"},".language-markdown .token.url-reference.url":{color:"hsl(198, 99%, 37%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(119, 34%, 47%)"},".language-markdown .token.bold .token.content":{color:"hsl(35, 99%, 36%)"},".language-markdown .token.italic .token.content":{color:"hsl(301, 63%, 40%)"},".language-markdown .token.strike .token.content":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.list.punctuation":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(5, 74%, 59%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.cr:before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.lf:before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.space:before":{color:"hsla(230, 8%, 24%, 0.2)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},".line-highlight.line-highlight":{background:"hsla(230, 8%, 24%, 0.05)"},".line-highlight.line-highlight:before":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 8%, 24%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 8%, 24%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(230, 8%, 24%, 0.05)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(230, 8%, 24%, 0.2)"},".command-line .command-line-prompt":{borderRightColor:"hsla(230, 8%, 24%, 0.2)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(230, 1%, 62%)"},".command-line .command-line-prompt > span:before":{color:"hsl(230, 1%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(301, 63%, 40%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(301, 63%, 40%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(301, 63%, 40%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(0, 0, 95%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(0, 0, 95%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(0, 0, 95%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(0, 0, 95%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(0, 0%, 100%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(0, 0%, 100%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(0, 0%, 100%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(230, 8%, 24%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(230, 8%, 24%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(230, 8%, 24%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(230, 8%, 24%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(230, 8%, 24%)"}};function kHt(e){return e.endsWith(`
|
|
989
989
|
`)?e.slice(0,-1):e}function EHt(e,t){return t?w.Children.map(e,n=>{var r;return!w.isValidElement(n)||!((r=n.props.className)!=null&&r.includes("react-syntax-highlighter-line-number"))?n:w.cloneElement(n,{className:pe(n.props.className,t)})}):e}function THt({code:e,language:t,darkTheme:n,className:r,showLineNumbers:o}){var p;const a=IC(),i=n?_Ht:SHt,[s,l]=w.useState(!1),c=w.useMemo(()=>kHt(e),[e]),d=w.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},[e]);return g.jsxs("div",{className:pe("aui-syntax-highlighter relative my-2 max-w-full min-w-0 overflow-x-auto rounded-md",(p=a.syntaxHighlighter)==null?void 0:p.root,r),children:[g.jsx("button",{type:"button",onClick:d,title:s?"Copied!":"Copy","aria-label":s?"Copied!":"Copy",className:Xt({variant:"secondary",size:"icon",className:"absolute top-2 right-2 z-10 h-7 w-7"}),children:g.jsx(xe,{name:s?"check":"copy",size:"0.875em"})}),g.jsx($W,{language:t,style:i,customStyle:{margin:0,maxWidth:"100%",whiteSpace:"pre-wrap",wordBreak:"break-word"},wrapLongLines:!0,showLineNumbers:o,PreTag:({children:f,className:m,...b})=>{var y;return g.jsx("pre",{...b,className:pe("max-w-full overflow-x-auto whitespace-pre-wrap break-words",(y=a.syntaxHighlighter)==null?void 0:y.pre,m),children:f})},CodeTag:({children:f,className:m,...b})=>{var y,x;return g.jsx("code",{...b,className:pe("whitespace-pre-wrap break-words",(y=a.syntaxHighlighter)==null?void 0:y.code,m),children:EHt(f,(x=a.syntaxHighlighter)==null?void 0:x.lineNumber)})},children:c})]})}var AHt=w.memo(THt);function CHt({className:e,children:t,style:n,...r}){return g.jsx("button",{type:"button","aria-label":"Start new chat",style:{borderRadius:"var(--thread-list-item-radius, 0.75rem)",...n},className:Xt({variant:"ghost",className:pe("!justify-start h-8 px-2.5 text-sm font-normal text-sidebar-text shadow-none hover:bg-secondary-button-hover hover:text-ghost-button-text",e)}),...r,children:t??g.jsxs(g.Fragment,{children:[g.jsx(xe,{name:"square-pen"}),"New Chat"]})})}function RHt({count:e=5,className:t}){return g.jsx("div",{className:pe("flex flex-col gap-1",t),role:"status","aria-label":"Loading threads",children:Array.from({length:e},(n,r)=>g.jsx("div",{className:"flex h-8 items-center px-2.5",children:g.jsx(ti,{className:"h-3.5 w-full"})},r))})}function IHt({message:e="No threads yet",className:t}){return g.jsx("div",{className:pe("text-text-secondary flex flex-1 items-center justify-center px-4 text-center text-sm",t),children:e})}function NHt({header:e,children:t,className:n}){return g.jsxs("div",{className:pe("font-sans-flex flex h-full min-h-0 flex-1 flex-col overflow-hidden",n),children:[e!=null?g.jsx("div",{className:"shrink-0 border-b border-border px-2 py-2",children:e}):null,g.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-2",children:t})]})}function MHt({agentName:e}){return g.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-[0.75rem] text-text-secondary",children:[g.jsx(xe,{name:"bot",className:"shrink-0"}),g.jsx("span",{className:"truncate",children:e})]})}function OHt({title:e,active:t,onSelect:n,agentName:r,lastMessageAt:o,actions:a,className:i}){const s=o!=null?dMe(o):void 0,l=s!=null||a!=null;return g.jsxs("div",{"data-slot":"aui_thread-list-item","data-active":t||void 0,className:pe("group flex min-w-0 items-center gap-0.5 rounded-[0.5rem] transition-colors",t?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text":"text-text-secondary hover:bg-ghost-button-hover hover:text-text-primary",i),children:[g.jsx("button",{type:"button",onClick:n,style:{borderRadius:"var(--thread-list-item-radius, 0.75rem)"},className:Xt({variant:"ghost",className:pe("!justify-start h-auto min-h-8 min-w-0 flex-1 overflow-hidden rounded-[0.75rem] px-2.5 py-1.5 text-left font-normal shadow-none","bg-transparent hover:bg-transparent hover:text-inherit",t?"text-dropdown-selected-item-text":"text-inherit")}),children:g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:"block truncate text-sm font-normal text-text-primary",children:e}),r!=null?g.jsx(MHt,{agentName:r}):null]})}),l?g.jsxs("div",{className:"relative mr-1 flex size-7 shrink-0 items-center justify-center",children:[s!=null?g.jsx("span",{"data-slot":"aui_thread-list-item-age",className:pe("pointer-events-none text-xs text-text-secondary transition-opacity",a!=null&&"opacity-0 md:opacity-100 md:group-hover:opacity-0 md:group-focus-within:opacity-0 md:group-has-[[data-state=open]]:opacity-0"),children:s}):null,a!=null?g.jsx("div",{"data-slot":"aui_thread-list-item-actions",className:pe("absolute inset-0 flex items-center justify-center transition-opacity",s!=null&&"md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100 md:group-has-[[data-state=open]]:opacity-100"),children:a}):null]}):null]})}var hOe="44rem",jHt=`var(--thread-max-width, ${hOe})`,PHt={"--thread-max-width":hOe,"--composer-padding":"8px"},gOe=w.forwardRef(({className:e,style:t,...n},r)=>g.jsx("div",{ref:r,className:pe("font-sans-flex aui-root aui-thread-root bg-primary-bg @container flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",e),style:{...PHt,...t},...n}));gOe.displayName="ThreadRootShell";var mOe=w.forwardRef(({className:e,isEmpty:t,scrollable:n=!0,contentMaxWidth:r,children:o,...a},i)=>g.jsx("div",{ref:i,"data-slot":"aui_thread-viewport",className:pe("relative flex min-h-0 min-w-0 flex-col",n?"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain":"shrink-0 overflow-visible",e),...a,children:g.jsx("div",{className:pe("mx-auto flex w-full min-w-0 flex-col px-3 pt-3",t?"min-h-full justify-center pb-4":"pb-32"),style:{maxWidth:r??jHt},children:o})}));mOe.displayName="ThreadViewportShell";var bOe=w.forwardRef(({className:e,isEmpty:t,...n},r)=>g.jsx("div",{ref:r,"data-slot":"aui_thread-composer",className:pe("aui-thread-composer bg-primary-bg relative mx-auto flex w-full min-w-0 max-w-(--thread-max-width) shrink-0 flex-col gap-3 px-3 pb-[max(1rem,env(safe-area-inset-bottom,0px))] sm:gap-4 sm:px-4 md:pb-[max(1.5rem,env(safe-area-inset-bottom,0px))]",!t&&"rounded-t-(--composer-radius)",e),...n}));bOe.displayName="ThreadComposerAreaShell";var vOe=w.forwardRef(({className:e,...t},n)=>g.jsx("div",{ref:n,"data-slot":"aui_message-group",className:pe("flex flex-col gap-y-4 empty:hidden",e),...t}));vOe.displayName="MessageGroup";function DHt({title:e,description:t,open:n,onOpenChange:r,variant:o="error",className:a}){const[i,s]=w.useState(!1),l=w.useCallback(async()=>{const c=`${e}
|
|
990
990
|
${t}`;try{await navigator.clipboard.writeText(c),s(!0),window.setTimeout(()=>s(!1),1500)}catch{}},[e,t]);return n?g.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:[g.jsx(xe,{name:o==="success"?"circle-check":"circle-exclamation",size:"1.25em",className:pe("shrink-0",o==="success"?"text-success-bg":"text-failure-bg")}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsxs("div",{className:"flex items-start justify-between gap-2",children:[g.jsx("div",{className:pe("text-sm leading-none font-semibold",o==="success"?"text-success-bg":"text-failure-bg"),children:e}),g.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o==="error"?g.jsx("button",{type:"button","aria-label":"Copy",title:"Copy",className:Xt({variant:"ghost",size:"icon"}),onClick:l,children:g.jsx(xe,{name:i?"check":"clone"})}):null,g.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:Xt({variant:"ghost",size:"icon"}),onClick:()=>r(!1),children:g.jsx(xe,{name:"xmark"})})]})]}),t?g.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 LHt=e=>{if(e!==null)try{if(typeof e.showPopover!="function")return;e.matches(":popover-open")&&e.hidePopover(),e.showPopover()}catch{}};function zHt({children:e,duration:t=Number.POSITIVE_INFINITY}){const n=g.jsx("div",{ref:LHt,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:di.createPortal(n,o)}var $Ht=[{id:"approve",label:"Approve",variant:"primary"}],FHt=[{id:"deny",label:"Deny",variant:"secondary",requiresReason:!0}];function mme(e){return e.variant==="destructive"?"destructive":e.variant==="secondary"?"secondary":"primary"}function yOe({toolName:e,approveOptions:t=$Ht,denyOptions:n=FHt,onSelect:r,status:o,selectedDenyOption:a,denialReason:i="",showReasonError:s=!1,onDenyOptionChange:l,onDenialReasonChange:c,onReasonSubmit:d,disabled:p=!1,readOnly:f=!1,showLineBelow:m=!1,dataTestPrefix:b,className:y}){var C,A;const x=!!o,_=(o==null?void 0:o.type)==="approved",k=(o==null?void 0:o.type)==="denied",E=p&&!x,T=_?"Tool Approved":k?"Tool Approval Denied":"Tool Approval Required for";return g.jsxs("div",{className:pe("aui-tool-approval-bar",y),"data-testid":b?`${b}-approval`:void 0,children:[g.jsxs("div",{className:"flex gap-2",children:[g.jsxs("div",{className:pe("flex shrink-0 flex-col items-center",!m&&"pb-1"),children:[g.jsx("div",{className:"min-h-[0.75rem] w-px flex-1 bg-border"}),g.jsx(tMe,{icon:"wrench",variant:"muted",iconSize:"0.875em",className:"my-1"}),m&&g.jsx("div",{className:"min-h-[0.75rem] w-px flex-1 bg-border"})]}),g.jsxs("div",{className:"mt-2 flex flex-1 items-center justify-between",children:[g.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1 font-sans text-xs font-medium leading-4 text-text-primary",children:[T,g.jsx("span",{className:"rounded bg-secondary-bg px-1.5 py-0.5 text-xs text-text-secondary",children:e})]}),x&&g.jsx(xe,{name:k?"circle-xmark":"circle-check",size:"0.875em",className:pe("shrink-0",k?"text-failure-bg":"text-success-bg")})]}),!x&&!f&&a&&g.jsx(In.Secondary,{size:"small",disabled:E,onClick:()=>l==null?void 0:l(null),children:"Back"})]}),!x&&!f&&!a&&g.jsxs("div",{className:"flex gap-2",children:[t.map(R=>g.jsxs(In,{size:"small",variant:mme(R),disabled:E,onClick:()=>r(R.id),children:[R.variant==="primary"&&g.jsx(xe,{name:"check",size:"0.75rem"}),R.label]},R.id)),n.map(R=>g.jsx(In,{size:"small",variant:mme(R),disabled:E,onClick:()=>{R.requiresReason?l==null||l(R.id):r(R.id)},children:R.label},R.id))]})]})]}),!x&&!f&&a&&g.jsxs("div",{className:"flex flex-col gap-1 pl-8 pt-3",children:[(((C=a.confirm)==null?void 0:C.title)||((A=a.confirm)==null?void 0:A.description))&&g.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.confirm.title&&g.jsx("span",{className:"text-xs font-medium text-text-primary",children:a.confirm.title}),a.confirm.description&&g.jsx("span",{className:"text-xs text-text-secondary",children:a.confirm.description})]}),a.grants&&a.grants.length>0&&g.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[g.jsx("span",{className:"text-xs text-text-secondary",children:"Grants:"}),a.grants.map(R=>g.jsx("span",{className:"rounded bg-secondary-bg px-1.5 py-0.5 text-xs text-text-secondary",children:R},R))]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("input",{placeholder:"Enter reason for denial","aria-label":"Reason for denial","aria-invalid":s||void 0,"aria-describedby":s?"aui-denial-reason-error":void 0,value:i,disabled:E,onChange:R=>c==null?void 0:c(R.target.value),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")}),g.jsx(In.Primary,{size:"small",disabled:E,onClick:d,children:"Submit"})]}),s&&g.jsx("span",{id:"aui-denial-reason-error",className:"text-xs text-failure-bg",role:"alert",children:"Reason is required"})]}),x&&(o==null?void 0:o.reason)&&g.jsx("div",{className:"pl-8 pt-2",children:g.jsxs("span",{className:"text-xs text-text-secondary",children:["Reason: ",o.reason]})})]})}var xOe="create_sub_agent",UHt="ask_user_question",wOe=new Set(["exec","sandbox_exec"]),_Oe=new Set(["call_tool","list_tools","get_tool_info","get_tool_output_schema"]),bme={"allow-once":"Allow","allow-always":"Always allow","reject-once":"Deny","reject-always":"Always deny"},P6=e=>e==="allow-once"||e==="allow-always";function SOe(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:m$t.parse(e),isPartial:!0}}catch{return{success:!1}}}}function b$(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function BHt(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 HHt(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 VHt(e){return e!=null&&e.approved===void 0&&e.resolution===void 0}function D6(e){const t=e==null?void 0:e.filter(n=>Object.hasOwn(bme,n.kind));if(t&&t.length>0){const n=t.filter(a=>P6(a.kind)),r=t.filter(a=>!P6(a.kind)),o=[...n,...r].map(a=>({id:a.id,label:a.label??bme[a.kind]??a.id,isAllow:P6(a.kind),grants:a.grants,confirm:a.confirm!=null?typeof a.confirm=="object"?a.confirm:{}:void 0}));return r.length===0&&o.push({id:"__deny",label:"Deny",isAllow:!1,confirm:{}}),o}return[{id:"__allow",label:"Allow",isAllow:!0},{id:"__deny",label:"Deny",isAllow:!1,confirm:{}}]}function GHt(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 WHt(e){return e==="complete"?"success":e==="incomplete"?"error":"running"}function kOe(e){if(!e)return{};const t=SOe(e);return!t.success||!b$(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 KHt(e){if(e===void 0)return{};const t=SOe(e);if(!t.success||!b$(t.value))return{resultText:e};const n=b$(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 FZ(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 fw(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 vme(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=fw(typeof o=="string"?o:JSON.stringify(o));return{data:a.value,isJson:a.isJson}}const r=fw(typeof n=="string"?n:JSON.stringify(n));return{data:r.value,isJson:r.isJson}}catch{return{data:String(e),isJson:!1}}}function YHt(e){var o,a,i,s,l,c,d,p;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)??((d=t==null?void 0:t.agentInfo)==null?void 0:d.input)??"",stepCount:((p=e.messages)==null?void 0:p.length)??0}}function EOe(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 ZHt(e,t){return(e==null?void 0:e.id)===t&&e.approved===void 0&&e.resolution===void 0}function XHt(e,t){const n=[];function r(o,a){for(const i of o){if(i.type!=="tool-call")continue;if(ZHt(i.approval,t))return n.push(...a),!0;const s=i.toolName===xOe&&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 qHt=2e3,QHt=50,JHt=12,TOe=w.createContext(null);function crn({children:e}){const t=w.useRef(new Map),n=w.useRef(new Map),r=w.useRef(null),o=w.useRef(null),[a,i]=w.useState(null),s=Ve(m=>m.thread.messages),l=w.useCallback((m,b)=>(t.current.set(m,b),()=>{t.current.get(m)===b&&t.current.delete(m)}),[]),c=w.useCallback((m,b)=>(n.current.set(m,b),()=>{n.current.get(m)===b&&n.current.delete(m)}),[]),d=w.useCallback(m=>{r.current!=null&&clearTimeout(r.current),i(m),r.current=setTimeout(()=>{i(null),r.current=null},qHt)},[]);w.useEffect(()=>()=>{r.current!=null&&clearTimeout(r.current),o.current!=null&&clearInterval(o.current)},[]);const p=w.useCallback(m=>{const b=XHt(s,m);o.current!=null&&(clearInterval(o.current),o.current=null);const y=()=>{var k,E,T;for(const C of b)(k=n.current.get(C))==null||k();const _=((E=t.current.get(m))==null?void 0:E())??null;return _==null?!1:((T=_.scrollIntoView)==null||T.call(_,{block:"center",behavior:"smooth"}),d(m),!0)};if(y())return;let x=0;o.current=setInterval(()=>{x+=1,(y()||x>=JHt)&&o.current!=null&&(clearInterval(o.current),o.current=null)},QHt)},[s,d]),f=w.useMemo(()=>({registerTarget:l,registerExpand:c,focus:p,flashingApprovalId:a}),[l,c,p,a]);return g.jsx(TOe.Provider,{value:f,children:e})}function UZ(){return w.useContext(TOe)}function eVt(e,t){const n=UZ();w.useEffect(()=>{if(!(n==null||e==null||e===""))return n.registerTarget(e,()=>t.current)},[n,e,t])}function tVt(e,t){const n=UZ();w.useEffect(()=>{if(!(n==null||e===""))return n.registerExpand(e,t)},[n,t,e])}var nVt="Awaiting Response...";function AOe({icon:e="mcp-server",iconClassName:t,iconVariant:n,toolName:r,expanded:o=!1,onToggle:a,awaiting:i=!1,awaitingText:s=nVt,status:l,exitCode:c,showExpandChevron:d=!0,showResponseLine:p=!1,approvalSlot:f,approvalId:m,requestSlot:b,responseSlot:y,highlightCard:x=!1,className:_,mcpServerName:k,dataTestPrefix:E}){const T=w.useRef(null),C=UZ();eVt(m,T);const A=!!f,R=!!b,M=!!y,j=A||R||M,O=d&&(R||M),P=m!=null&&(C==null?void 0:C.flashingApprovalId)===m;let D="idle";l?D=l:i?D="running":c===0?D="success":c!=null?D="error":p&&(D="success");const L=i?s:void 0,z=e==="cube",F=n||(z?"primary":"muted"),$=z?"0.75em":void 0;return g.jsx("div",{ref:T,"data-approval-id":m,className:pe("aui-tool-call-card flex min-w-0 flex-col",m!=null||x?"mx-0 mt-2 rounded-md pt-1.5 pr-2 pb-1":"mx-0 mt-2 p-0",P&&"aui-approval-flash",_),"data-testid":E?`${E}-tool-call-card`:void 0,children:g.jsx(vZ,{icon:e,iconClassName:t,iconVariant:F,iconSize:$,title:r,expandable:O,expanded:o,onToggle:a,status:D,statusText:L,showConnector:j,showContentConnector:!0,showPersistentContentConnector:!A,dataTestPrefix:E?`${E}-header`:void 0,persistentChildren:g.jsxs(g.Fragment,{children:[f,o&&p&&y&&g.jsx("div",{"data-testid":E?`${E}-response`:void 0,children:y})]}),children:b&&g.jsx("div",{className:"py-2 pt-0","data-testid":E?`${E}-request`:void 0,children:b})})})}function yme({content:e,height:t,autoHeight:n=!1,maxHeight:r,onAutoHeightChange:o}){const a=We("MonacoEditorCore");return g.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 rVt({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:d,dataTestPrefix:p,className:f}){const m=We("Markdown"),[b,y]=w.useState(!1),x=()=>{const E=r??t;navigator.clipboard.writeText(E).then(()=>{y(!0),setTimeout(()=>y(!1),1500)})},_=a&&l!==void 0,k=a?{..._?{height:`${Math.min(l,10)}rem`}:{},resize:"vertical",padding:"0.25rem"}:{padding:"0.25rem"};return g.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":p?`${p}-content-block`:"tfy-tool-call-content-block","data-content":t,children:[g.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:[g.jsx("div",{className:"font-sans text-xs font-medium text-primary-button-bg",children:e}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("button",{type:"button",onClick:x,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":p?`${p}-copy`:void 0,children:g.jsx(xe,{name:b?"check":"clone",size:14})}),g.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:g.jsx(xe,{name:"expand-alt",size:14})})]})]}),g.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:k,children:n?g.jsx(yme,{content:t,height:_?"100%":void 0,autoHeight:!_,maxHeight:o,onAutoHeightChange:a?d:void 0}):g.jsx("div",{className:pe("overflow-y-auto",_&&"h-full"),style:!_&&o?{maxHeight:o}:void 0,children:g.jsx(m,{content:t,className:"text-xs text-text-secondary"})})}),i&&g.jsx(lN,{open:!0,onOpenChange:E=>s==null?void 0:s(E),children:g.jsxs(cN,{className:"flex h-[80vh] max-w-4xl flex-col",children:[g.jsxs(xZ,{className:"flex flex-row items-center justify-between gap-2",children:[g.jsx(wZ,{children:e}),g.jsx(Ip,{variant:"ghost",onClick:()=>s==null?void 0:s(!1),"aria-label":"Minimize",children:g.jsx(xe,{name:"compress",size:"0.875em"})})]}),g.jsx("div",{className:"min-h-0 flex-1",children:g.jsx(yme,{content:t,height:"100%"})})]})})]})}function oVt({toolCallCount:e,expanded:t,active:n=!1,onToggle:r,children:o,className:a}){const i=We("Accordion"),s=We("AccordionSummary"),l=We("AccordionDetails"),c=`${e} tool ${e===1?"call":"calls"}`;return g.jsxs(i,{"data-slot":"tool-group-card",expanded:t,onChange:()=>r(),background:"transparent",className:pe("aui-tool-group-card group/tool-group w-full",a),sx:{margin:0,border:"none",boxShadow:"none"},children:[g.jsx(s,{hideIcon:!0,disableRipple:!0,sx:{padding:0,minHeight:0,"&.Mui-expanded":{minHeight:0},"&:hover":{backgroundColor:"transparent"},"& .MuiAccordionSummary-content":{margin:0,width:"100%"}},children:g.jsxs("div",{className:"text-text-secondary hover:text-text-primary flex origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]",children:[n&&g.jsx(xe,{name:"loader",className:"size-3 shrink-0 animate-spin [animation-duration:0.6s]"}),g.jsx("span",{className:"text-xs font-medium",children:c}),g.jsx(xe,{name:"chevron-down",className:pe("size-3 shrink-0 transition-transform duration-200 ease-[cubic-bezier(0.32,0.72,0,1)]",t?"rotate-0":"-rotate-90")})]})}),g.jsx(l,{sx:{padding:0},children:g.jsx("div",{className:"mt-1 flex flex-col gap-2 text-text-primary",children:o})})]})}var L6="h-6 w-6 text-text-secondary hover:text-text-primary [&_svg]:size-3.5";function aVt({isCopied:e,editDisabled:t,retryDisabled:n,createdAt:r,onCopy:o,onEdit:a,onRetry:i,className:s}){const l=We("MessageTimestamp");return g.jsxs("div",{className:pe("aui-user-action-bar-root animate-in fade-in flex items-center gap-1 duration-200",s),children:[g.jsx(l,{createdAt:r,className:"mr-1"}),g.jsx(Ip,{"aria-label":"Try again",tooltip:"Try again",variant:"ghost",className:L6,disabled:n,onClick:i,children:g.jsx(xe,{name:"rotate-right",size:"0.875em"})}),g.jsx(Ip,{"aria-label":"Edit",tooltip:"Edit",variant:"ghost",className:L6,disabled:t,onClick:a,children:g.jsx(xe,{name:"pencil",size:"0.875em"})}),g.jsx(Ip,{"aria-label":"Copy",tooltip:"Copy",variant:"ghost",className:L6,onClick:o,children:g.jsx(xe,{name:e?"check":"clone",size:"0.875em"})})]})}function iVt({text:e,attachments:t,editAction:n,className:r}){return g.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?g.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&&g.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 sVt=w.forwardRef(function({timestamp:t,attachments:n,input:r,footer:o,className:a,...i},s){return g.jsxs("div",{ref:s,"data-slot":"aui_user-message-edit",className:pe("flex flex-col gap-2 w-full",a),...i,children:[(t||n)&&g.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[g.jsx("span",{className:"font-medium text-text-primary",children:"User"}),t]}),n&&g.jsx("div",{className:"flex flex-wrap gap-1",children:n}),g.jsx("div",{className:"w-full",children:r}),g.jsx("div",{children:o})]})});function COe({heading:e="How can I help you today?",icon:t,className:n}){const r=cze(),o=We("BrandLogo"),a=t!==void 0?t:r==="chatgpt"?null:r==="claude"?g.jsx(xe,{name:"welcome-sparkle",className:"size-5 fill-current text-primary-button-bg"}):g.jsx(o,{variant:"icon",className:"size-10"});return g.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"&&g.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&&g.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}),g.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 lVt({agentId:e,timeRange:t,onTimeRangeChange:n,showTimeRangeFilter:r=!0}){const o=M$e(),a=We("AgentMetricsView"),[i,s]=w.useState(dye),l=t??i,c=n??s,[d,p]=w.useState(),[f,m]=w.useState(),[b,y]=w.useState(),[x,_]=w.useState(),[k,E]=w.useState([]),[T,C]=w.useState(!0);return w.useEffect(()=>{let A=!1;return p(void 0),m(void 0),o.getCharts().then(R=>{A||p(R)},R=>{A||(p([]),m(aa(R,"Metric charts could not be loaded.")),C(!1))}),()=>{A=!0}},[o]),w.useEffect(()=>{if(d==null)return;let A=!1;const R=pye(l),M={agentId:e,startTimestamp:new Date(R.startTs).toISOString(),endTimestamp:new Date(R.endTs).toISOString()};return y(void 0),_(void 0),E(d.map(j=>({definition:j}))),C(!0),o.getMeters(M).then(j=>{A||y(j)},j=>{A||_(aa(j,"Aggregate metrics could not be loaded."))}),Promise.all(d.map(async j=>{try{const O=await o.getChartData({...M,chartName:j.name});return{definition:j,graphs:O.graphs}}catch(O){return{definition:j,error:aa(O,`${j.displayName} could not be loaded.`)}}})).then(j=>{A||(E(j),C(!1))}),()=>{A=!0}},[e,d,o,l]),g.jsx(a,{meters:b,meterError:x,charts:k,chartsLoading:T,chartsError:f,timeRange:l,onTimeRangeChange:c,showTimeRangeFilter:r})}function z6(e){return Math.max(0,e.endMs-e.startMs)}function cVt(e){return e.totalTokens!=null||e.inputTokens!=null||e.outputTokens!=null||e.cachedTokens!=null||e.totalCostInUsd!=null}function uVt({turns:e,segments:t,sessionMetrics:n}){let r=0,o=0,a=!1,i=0,s=0,l=0,c=0;const d=new Map,p=new Map;for(const O of e){if(r+=O.durationMs??0,!cVt(O)){d.has(O.turnNumber)||d.set(O.turnNumber,0),p.has(O.turnNumber)||p.set(O.turnNumber,0);continue}const P=O.inputTokens??0,D=O.outputTokens??0,L=O.cachedTokens??0,z=O.totalTokens??P+L+D,F=O.totalCostInUsd;F!=null&&(o+=F,a=!0),i+=z,s+=P,l+=D,c+=L,d.set(O.turnNumber,(d.get(O.turnNumber)??0)+(F??0)),p.set(O.turnNumber,(p.get(O.turnNumber)??0)+z)}const f=[],m=[];let b=0;for(const O of[...p.keys()].sort((P,D)=>P-D)){const P=`T${O}`;b+=p.get(O)??0,f.push({label:P,value:d.get(O)??0,color:hl("tool_call")}),m.push({label:P,value:b,color:hl("model")})}const y=t.filter(O=>O.type==="model").reduce((O,P)=>O+z6(P),0),x=t.filter(O=>O.type==="tool_call").reduce((O,P)=>O+z6(P),0),_=t.filter(O=>O.type==="waiting_on_human"||O.type==="approval").reduce((O,P)=>O+z6(P),0),k=n!=null?n.totalDurationMs:r,E=Math.max(0,k-y-x-_),T=new Map;for(const O of t)O.type!=="tool_call"||O.threadId!==Ih||T.set(O.description,(T.get(O.description)??0)+1);const C=Array.from(T,([O,P])=>({label:O,value:P,color:hl("tool_call")})).sort((O,P)=>P.value-O.value),A=n!=null?n.totalCostInUsd:a?o:void 0,R=e.length,M=n==null?void 0:n.totalTurns,j=M!=null&&Number.isFinite(M)&&M>R?M:void 0;return{totalTurns:R,...j==null?{}:{sessionTotalTurns:j},wallTimeMs:k,...A==null?{}:{totalCostUsd:A},totalTokens:i,contextTokens:b,toolCalls:C.reduce((O,P)=>O+P.value,0),subAgents:t.filter(O=>O.type==="sub_agent").length,errors:t.filter(O=>O.type==="error").length,timeBreakdown:[{label:"model",value:y,color:hl("model")},{label:"tools",value:x,color:hl("tool_call")},{label:"waiting on human",value:_,color:hl("approval")},{label:"overhead",value:E,color:hl("system")}],costPerTurn:f,tokenBreakdown:[{label:"input",value:s,color:hl("model")},{label:"output",value:l,color:hl("user")},{label:"cached",value:c,color:hl("sub_agent")}],contextByTurn:m,toolCallFrequency:C}}var xme={turn:"turn",event:"event",markerGroup:"markerGroup",toolCallGroup:"toolCallGroup",subAgentGroup:"subAgentGroup"};function urn(e){return e==null?"":e.type===xme.turn?e.bar.id:e.type===xme.event?e.segment.id:e.group.id}function drn({startMs:e,endMs:t}){return[e,t]}function prn(e,{toleranceMs:t=0}={}){const n=e.flatMap((o,a)=>o.isMarker?[{segment:o,index:a}]:[]).sort((o,a)=>o.segment.startMs-a.segment.startMs||o.index-a.index).map(({segment:o})=>o),r=[];for(const o of n){const a=r.at(-1);if(a!=null&&o.startMs-a.startMs<=t){a.segments.push(o);continue}r.push({id:o.id,startMs:o.startMs,endMs:o.startMs,segments:[o]})}return r.map(o=>({...o,id:`marker-group-${o.segments.map(a=>a.id).join("-")}`}))}function ROe(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 frn(e){const t=ROe(e);return`${Number((e/t.divisorMs).toFixed(2))}${t.suffix}`}function dVt(e){const{divisorMs:t}=ROe(e),n=e/t/8;if(t>=6e4&&n<1)return Math.max(.25,Math.ceil(n*4)/4)*t;const r=Math.max(1,n),o=10**Math.floor(Math.log10(r)),a=r/o;return(a<=1?1:a<=2?2:a<=5?5:10)*o*t}function hrn({activeTotalMs:e,turnStartsMs:t,turnGapMs:n}){const r=dVt(e),o=[];for(let i=0;i<e;i+=r)o.push(i);const a=o.at(-1);return a!=null&&a>0&&e-a<r/4&&o.pop(),o.at(-1)!==e&&o.push(e),o.map(i=>({value:i+t.slice(1).filter(s=>s<=i).length*n}))}function grn(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 IOe(e,t){return e.startMs<t.endMs&&t.startMs<e.endMs}function mrn(e){const t=[];for(const n of[...e].sort((r,o)=>r.turnIndex-o.turnIndex||r.startMs-o.startMs||r.endMs-o.endMs)){const r=t.at(-1);if(r==null||r.turnIndex!==n.turnIndex||!IOe(r,n)){t.push({...n});continue}r.endMs=Math.max(r.endMs,n.endMs)}return t}function brn(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 vrn({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&&(r.id===n.id||IOe(n,r)))}))}function yrn({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(d=>d<=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 pVt(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 xrn(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 Mi(e){return typeof e=="object"&&e!=null}function wme(e){return Mi(e)&&typeof e.type=="string"?{...e,type:e.type}:null}function Py(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 ea(e){if(e==null)return null;const t=Date.parse(e);return Number.isNaN(t)?null:t}function Ru(e){return Py(e,"createdAt","created_at")}function $6(e){return Py(e,"threadId","thread_id")??Ih}function th(e){return typeof e.id=="string"?e.id:`${e.type}-${Ru(e)??"unknown"}`}function v$(e){return typeof e=="string"?e.trim():Array.isArray(e)?e.flatMap(t=>typeof t=="string"?t?[t]:[]:Mi(t)&&typeof t.text=="string"&&t.text.length>0?[t.text]:[]).join(`
|
|
991
991
|
`).trim():""}function xT(e){const t=e.toolCalls??e.tool_calls;return Array.isArray(t)?t.filter(Mi):[]}function NOe(e){const t=Mi(e.parent)?e.parent:void 0;return t==null?void 0:Py(t,"toolCallId","tool_call_id")}function jb(e){return Mi(e)?Py(e,"completedAt","completed_at"):void 0}function MOe(e){return Mi(e)&&typeof e.message=="string"?e.message:""}function fVt(e){return Mi(e)?Py(e,"reason","reason")??"":""}function hVt(e){return Mi(e)?typeof e.error=="string"&&e.error.length>0?e.error:MOe(e):""}function gVt(e){const t=e.trim().toLowerCase();return t==="llm stream aborted"||t==="aborterror"||t.includes("stream aborted")||t.includes("aborterror")}function y$(e){return Mi(e)&&typeof e.status=="string"?e.status:void 0}function OOe(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 mVt(e){const t=OOe(e.created).find(n=>typeof n.type=="string");return typeof(t==null?void 0:t.type)=="string"?t.type:"user.message"}function jOe(e){const t=OOe(e.created).find(n=>typeof n.type=="string");if(t==null)return"";if(t.type==="user.tool_approval"){const n=Mi(t.approval)?t.approval:void 0,r=typeof(n==null?void 0:n.reason)=="string"?n.reason.trim():"";return(n==null?void 0:n.status)==="deny"?r.length>0?`Denied: ${r}`:"Denied":(n==null?void 0:n.status)==="allow"?"Approved":"Tool approval"}return t.type==="user.tool_response"?v$(t.content)||"Tool response":t.type==="user.mcp_auth_continue"?"MCP authorization completed":v$(t.content)||"User message"}function bVt(e){const t=typeof e.title=="string"?e.title.trim():"",n=Mi(e.agentInfo)?e.agentInfo:Mi(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 vVt(e){var o;const t=Mi(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(wOe.has(n)||n==="code_sandbox"){const a=(o=kOe(r).intent)==null?void 0:o.trim(),i=`Sandbox: ${n}`;return a!=null&&a.length>0?`${i} - ${a}`:i}if(_Oe.has(n)){const{mcpServer:a,innerToolName:i}=FZ(r);return EOe(n,a,i)}return n}function yVt(e){var m,b;const t=ea((m=e[0])==null?void 0:m.created.createdAt);if(t==null)return[];const n=new Map,r=new Map,o=new Map,a=new Map,i=new Set,s=new Map;let l=t;for(const y of e){l=Math.max(l,ea(y.created.createdAt)??l),l=Math.max(l,ea(jb((b=y.done)==null?void 0:b.state))??l);for(const x of y.events){const _=wme(x);if(_!=null){if(l=Math.max(l,ea(Ru(_))??l),_.type==="tool.response"){const k=Py(_,"toolCallId","tool_call_id");if(k==null)continue;const E=n.get(y.turnId)??new Map;E.set(k,_),n.set(y.turnId,E)}else if(_.type==="tool.response_required"){const k=r.get(y.turnId)??new Map;for(const E of xT(_))typeof E.id=="string"&&k.set(E.id,_);r.set(y.turnId,k)}else if(_.type==="tool.approval_required"){const k=o.get(y.turnId)??new Set;for(const E of xT(_))typeof E.id=="string"&&k.add(E.id);o.set(y.turnId,k)}else if(_.type==="thread.created"){const k=NOe(_);k!=null&&i.add(k)}else if(_.type==="thread.done")a.set($6(_),_);else if(_.type==="model.message"){const k=ea(Ru(_));if(k==null)continue;const E=s.get(y.turnId)??new Map;for(const T of xT(_))typeof T.id=="string"&&E.set(T.id,{startedAtMs:k,threadId:$6(_),modelEventId:th(_)});s.set(y.turnId,E)}}}}const c=[],d=new Set,p=new Map,f=new Map;for(const y of e)p.set(y.turnNumber,y.turnId),f.set(y.eventTurnNumber-1,y.turnNumber-1);for(const y of e){const x=ea(y.created.createdAt);if(x==null)continue;const _=y.eventTurnNumber-1;y.renderable&&c.push({id:`${y.turnId}-user`,type:"user",title:mVt(y),description:jOe(y),startMs:x-t,endMs:x-t,turnIndex:_,threadId:Ih,isMarker:!0});const k=new Map,E=[...y.events].map(wme).filter(T=>T!=null).sort((T,C)=>(ea(Ru(T))??0)-(ea(Ru(C))??0));for(const T of E){const C=ea(Ru(T));if(C==null)continue;const A=$6(T);xVt({event:T,eventMs:C,createdMs:x,originMs:t,turn:y,turnIndex:_,threadId:A,lastTimestampByThreadId:k,toolResponsesByTurnId:n,toolResponseRequiredByTurnId:r,approvalRequiredIdsByTurnId:o,subAgentToolCallIds:i,toolCallRequestsByTurnId:s,threadDoneEvents:a,emittedWaitingRequestIds:d,segments:c}),k.set(A,C)}wVt({turn:y,turnIndex:_,originMs:t,latestMs:l,segments:c,emitDoneMarker:p.get(y.turnNumber)===y.turnId})}return pVt(c.map(y=>({...y,startMs:Math.max(0,y.startMs),endMs:Math.max(0,y.endMs)}))).map(y=>({...y,turnIndex:f.get(y.turnIndex)??y.turnIndex})).sort((y,x)=>y.startMs-x.startMs||y.endMs-x.endMs)}function xVt({event:e,eventMs:t,createdMs:n,originMs:r,turn:o,turnIndex:a,threadId:i,lastTimestampByThreadId:s,toolResponsesByTurnId:l,toolResponseRequiredByTurnId:c,approvalRequiredIdsByTurnId:d,subAgentToolCallIds:p,toolCallRequestsByTurnId:f,threadDoneEvents:m,emittedWaitingRequestIds:b,segments:y}){var x,_,k,E,T;switch(e.type){case"model.message":{const C=s.get(i)??n,A=v$(e.content),R=l.get(o.turnId),M=c.get(o.turnId),j=d.get(o.turnId),O=ea(jb((x=o.done)==null?void 0:x.state));for(const P of xT(e)){const D=typeof P.id=="string"?P.id:void 0;if(D==null||p.has(D)||j!=null&&j.has(D))continue;const L=R==null?void 0:R.get(D),z=L==null?null:ea(Ru(L)),F=M==null?void 0:M.get(D),$=F==null?null:ea(Ru(F)),H=z??$??O??t;H<t||y.push({id:`${th(e)}-${D}`,type:"tool_call",title:"tool.call",description:vVt(P),startMs:t-r,endMs:H-r,turnIndex:a,threadId:i,...z==null&&H<=t?{isMarker:!0}:{}})}(A.length>0||i===Ih)&&y.push({id:th(e),type:"model",title:e.type,description:A,startMs:Math.max(0,C-r),endMs:Math.max(0,t-r),turnIndex:a,threadId:i,isMarker:t<=C});return}case"thread.created":{const C=NOe(e),A=C==null||(_=f.get(o.turnId))==null?void 0:_.get(C);if(A!=null){const D=`${o.turnId}:${A.modelEventId}`;b.has(D)||(b.add(D),A.startedAtMs<t&&y.push({id:`${th(e)}-waiting`,type:"system",title:"system.waiting_for_sub_agent",description:"System waiting for sub-agent to start executing",startMs:A.startedAtMs-r,endMs:t-r,turnIndex:a,threadId:A.threadId}))}const R=m.get(i),M=R==null?null:ea(Ru(R)),j=ea(jb((k=o.done)==null?void 0:k.state))??ea((E=o.done)==null?void 0:E.createdAt),O=M!=null&&M>=t?M:j!=null&&j>=t?j:t;y.push({id:th(e),type:"sub_agent",title:e.type,description:bVt(e),startMs:t-r,endMs:O-r,turnIndex:a,threadId:i,isMarker:O<=t});const P=R!=null&&Mi(R.state)?R.state:void 0;if(P!=null&&y$(P)==="error"){const D=hVt(P);if(!(y$((T=o.done)==null?void 0:T.state)==="cancelled"&&gVt(D))){const z=M??t;y.push({id:`${th(e)}-error`,type:"error",title:"thread.error",description:D,startMs:z-r,endMs:z-r,turnIndex:a,threadId:i,isMarker:!0})}}return}case"tool.approval_required":case"tool.response_required":case"mcp.auth_required":case"mcp.initialize":case"sandbox.created":y.push({id:th(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"?"Approval required":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",startMs:t-r,endMs:t-r,turnIndex:a,threadId:i,isMarker:!0});return;default:return}}function wVt({turn:e,turnIndex:t,originMs:n,latestMs:r,segments:o,emitDoneMarker:a}){var l,c,d,p,f,m;const i=y$((l=e.done)==null?void 0:l.state);if(i==="error"){const b=ea(jb((c=e.done)==null?void 0:c.state))??r;o.push({id:`${e.turnId}-error`,type:"error",title:"turn.error",description:MOe((d=e.done)==null?void 0:d.state),startMs:b-n,endMs:b-n,turnIndex:t,threadId:Ih,isMarker:!0});return}if(i==="cancelled"){const b=ea(jb((p=e.done)==null?void 0:p.state))??r,y=fVt((f=e.done)==null?void 0:f.state);o.push({id:`${e.turnId}-turn.cancelled`,type:"system",title:"turn.cancelled",description:y.length>0?y:"cancelled",startMs:b-n,endMs:b-n,turnIndex:t,threadId:Ih,isMarker:!0});return}if(i!=="done"||!a)return;const s=ea(jb((m=e.done)==null?void 0:m.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:Ih,isMarker:!0})}var _Vt=100;function SVt(e,t){const n=[...e].reverse();return{async listEvents({limit:r=_Vt,pageToken:o}){const a=o==null||o.length===0?0:Number.parseInt(o,10),i=Number.isFinite(a)?a:0,s=n.length,l=n.slice(i,i+s),c=i+s,d=c<n.length?String(c):void 0,p={data:l};return d==null?p:{...p,nextPageToken:d}}}}var kVt={type:"user.mcp_auth_continue"},EVt=new Set(["user.message","user.tool_approval","user.tool_response","user.mcp_auth_continue"]);function Om(e){const t=Date.parse(e);return Number.isNaN(t)?0:t}function _me(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"&&EVt.has(r)}):!1}function TVt(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 AVt(e){const t=e.input??[];return t.some(n=>n.type==="user.mcp_auth_continue")?e:{...e,input:[...t,kVt]}}function jm(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 CVt(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=jm(n,"totalTokens","total_tokens"),o=jm(n,"totalInputTokens","total_input_tokens"),a=jm(n,"totalOutputTokens","total_output_tokens"),i=jm(n,"totalCacheReadTokens","total_cache_read_tokens"),s=jm(n,"totalCacheWriteTokens","total_cache_write_tokens"),l=jm(n,"totalCostInUsd","total_cost_in_usd"),c=i!==void 0||s!==void 0?(i??0)+(s??0):void 0,d=o!==void 0?Math.max(0,o-(c??0)):void 0,p=r??(o!==void 0||a!==void 0?(o??0)+(a??0):void 0);return{...p!==void 0?{totalTokens:p}:{},...d!==void 0?{inputTokens:d}:{},...a!==void 0?{outputTokens:a}:{},...c!==void 0?{cachedTokens:c}:{},...l!==void 0?{totalCostInUsd:l}:{}}}function RVt(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)=>Om(o.created.createdAt)-Om(a.created.createdAt));let r=0;return n.map(({turnId:o,created:a,group:i},s)=>{var m;const l=i.done,c=s>0?(m=n[s-1])==null?void 0:m.group.done:void 0,p=!_me(a)&&TVt(c)?AVt(a):a,f=_me(p);return f&&(r+=1),i.events.sort((b,y)=>Om(b.createdAt)-Om(y.createdAt)),{turnId:o,eventTurnNumber:s+1,turnNumber:Math.max(1,r),renderable:f,showHeader:f,created:p,...l===void 0?{}:{done:l,durationMs:Math.max(0,Om(l.createdAt)-Om(a.createdAt)),...CVt(l.state)},events:i.events}})}function IVt(e,t){const n=e.filter(x=>x.turnNumber===t),r=n.find(x=>x.renderable)??n[0];if(r==null)return;let o=0,a=0,i=0,s=0,l=0,c=0,d=!1,p=!1,f=!1,m=!1,b=!1,y=!1;for(const x of n)x.totalTokens!=null&&(o+=x.totalTokens,d=!0),x.inputTokens!=null&&(a+=x.inputTokens,p=!0),x.outputTokens!=null&&(i+=x.outputTokens,f=!0),x.cachedTokens!=null&&(s+=x.cachedTokens,m=!0),x.totalCostInUsd!=null&&(l+=x.totalCostInUsd,b=!0),x.durationMs!=null&&(c+=x.durationMs,y=!0);return{...r,...d?{totalTokens:o}:{},...p?{inputTokens:a}:{},...f?{outputTokens:i}:{},...m?{cachedTokens:s}:{},...b?{totalCostInUsd:l}:{},...y?{durationMs:c}:{}}}function NVt(e,t){const n=[];let r=e.length;for(let d=e.length-1;d>=0;d--){const p=e[d];if(p)if(p.type==="text"){const f=p.text??"";f.trim()&&n.unshift({index:d,content:f}),r=d}else break}const o=n.reduce((d,p)=>d+p.content.length,0),a=e.slice(0,r).some(d=>d.type==="tool-call"||d.type==="reasoning"),i=n.length>0&&(!t||o>=500||!a),s=i?r:e.length;let l=0,c=0;for(let d=0;d<s;d++){const p=e[d];p&&(p.type==="tool-call"?l++:p.type==="reasoning"&&c++)}return{cutIndex:s,hasFinal:i,toolCount:l,thinkingCount:c}}function MVt({children:e,toolCount:t,thinkingCount:n,hasFinal:r}){const o=We("AgentStepsCard"),[a,i]=w.useState(!0),s=w.useRef(!1);return w.useEffect(()=>{r&&!s.current&&(s.current=!0,i(!1))},[r]),g.jsx(o,{toolCount:t,thinkingCount:n,expanded:a,onToggle:()=>i(l=>!l),children:e})}var OVt=4*1024,jVt=100;function PVt(e,{isComplete:t,enabled:n,throttleMs:r=jVt}){const[o,a]=w.useState(e),i=w.useRef(e),s=w.useRef(Date.now()),l=w.useRef(e),c=w.useRef(n);return w.useEffect(()=>{l.current=e;const d=m=>{m.length<i.current.length&&m!==i.current||(i.current=m,s.current=Date.now(),a(m))};if(!n){c.current=!1,i.current=e,s.current=Date.now(),a(e);return}if(!c.current){c.current=!0,d(e);return}if(i.current===e)return;if(t){d(e);return}const p=Date.now()-s.current;if(p>=r){d(e);return}const f=setTimeout(()=>{d(l.current)},r-p);return()=>clearTimeout(f)},[e,t,n,r]),n?o:e}function DVt(e){const t=e.split("/").pop()??"";return t.length>0?t:"download"}function LVt(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 W_(){var _,k;const e=We("Markdown"),t=sN(),n=zLt(),r=w.useRef({downloadSandboxFile:n,toaster:t});r.current={downloadSandboxFile:n,toaster:t};const o=cNe(),a=w.useCallback(E=>r.current.downloadSandboxFile(E),[]),i=Ve(E=>E.part),s=w.useRef(!1),l=I1e(i,s.current?!1:{drainMs:150,maxCharIntervalMs:4,maxCharsPerFrame:128,minCommitMs:48}),c=((_=i.status)==null?void 0:_.type)!=="running",d=i.text.length-l.text.length;!s.current&&!c&&d>=OVt&&(s.current=!0);const p=s.current,f=PVt(i.text,{enabled:p,isComplete:c}),m=p?f:l.text,b=p?!c||m!==i.text:((k=l.status)==null?void 0:k.type)==="running",y=w.useCallback(async E=>{const{downloadSandboxFile:T,toaster:C}=r.current;try{LVt(await T(E),DVt(E))}catch(A){C!=null?C.showError(A):console.error("Failed to download sandbox artifact",A)}},[]),x=w.useMemo(()=>g.jsx(e,{content:m,isStreaming:b,onDownloadArtifact:y}),[e,m,b,y]);return o==null?x:g.jsx(EFt,{turnId:o,children:g.jsx(AFt,{load:a,children:x})})}function zVt(){const e=We("AttachmentCard"),t=We("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=g.jsx(e,{name:r??"image",previewSrc:n,isImage:!0,size:"preview",previewRem:_Me});return g.jsx(t,{previewSrc:n,children:g.jsx("div",{className:"aui-message-image",children:o})})}function $Vt({group:e}){const t=We("ReasoningCard"),n=Ve(x=>e.indices.map(_=>x.message.parts[_]).filter(_=>_!=null&&_.type==="reasoning").map(_=>_.text??"").join("")),r=Ve(x=>{var E,T;if(((E=x.message.status)==null?void 0:E.type)!=="running")return!1;const _=x.message.parts.length-1;if(_<0||((T=x.message.parts[_])==null?void 0:T.type)!=="reasoning")return!1;const k=e.indices[e.indices.length-1];return k!==void 0&&_>=e.indices[0]&&_<=k}),[o,a]=w.useState(r),[i,s]=w.useState(r),[l,c]=w.useState(!1),d=w.useRef(null);r!==i&&(s(r),r&&a(!0));const p=w.useCallback(x=>{var k;if((k=d.current)==null||k.disconnect(),d.current=null,x==null||r)return;const _=()=>{const E=Number.parseFloat(getComputedStyle(x).lineHeight)||24;c(x.scrollHeight>E*1.5)};_(),d.current=new ResizeObserver(_),d.current.observe(x)},[r]),f=null,m=n.replace(/\s+/g," ").trim(),b=!r&&n.length>0&&!l;return g.jsx(t,{content:n,isStreaming:r,expanded:o,isMultiLine:l,reasoningTimeText:f,previewText:m,headingText:"Reasoning",contentRef:b?p:void 0,onToggle:()=>a(x=>!x)})}var POe=w.createContext(!1);function FVt(){return w.useContext(POe)}function UVt(e){const t=We("SandboxToolCallCard"),[n,r]=w.useState("terminal"),o=w.useMemo(()=>n==="code"?!!(e.argsJson||e.resultJson):!!(e.command||e.resultText||e.resultJson),[e.argsJson,e.command,e.resultJson,e.resultText,n]);return g.jsx(t,{...e,viewMode:n,hasContent:o,onViewModeChange:r})}var DOe=w.createContext(!1);function BVt(){return w.useContext(DOe)}function HVt({toolName:e="",argsText:t,options:n,onSelectOption:r}){const o=We("ToolApprovalBar"),a=iN(),{mcpServer:i,innerToolName:s}=FZ(t),l=s&&i?`${s} (${i})`:e,[c,d]=w.useState(null),[p,f]=w.useState(""),[m,b]=w.useState(!1),y=w.useMemo(()=>n.filter(C=>C.isAllow).map((C,A)=>({...C,variant:A===0?"primary":"secondary",requiresReason:!1})),[n]),x=w.useMemo(()=>n.filter(C=>!C.isAllow).map(C=>({...C,variant:"secondary",requiresReason:C.confirm!=null})),[n]),_=x.find(C=>C.id===c),k=w.useCallback(C=>{d(C),f(""),b(!1)},[]),E=w.useCallback(C=>{f(C),b(!1)},[]),T=w.useCallback(()=>{if(!a)return;const C=p.trim();if(!C){b(!0);return}c&&(r(c,C),k(null))},[a,p,k,r,c]);return g.jsx(o,{toolName:l,approveOptions:y.length>0?y:void 0,denyOptions:x.length>0?x:void 0,selectedDenyOption:_,denialReason:p,showReasonError:m,disabled:!a,onSelect:(C,A)=>{if(a){if(A===void 0){r(C);return}r(C,A)}},onDenyOptionChange:k,onDenialReasonChange:E,onReasonSubmit:T})}function F6(e){const t=We("ToolCallContentBlock"),{isJson:n,onContentHeightChange:r,resizable:o}=e,[a,i]=w.useState(!1),[s,l]=w.useState(),c=w.useRef(null),d=w.useRef(null),p=w.useRef(!1),f=w.useCallback(b=>{var x;if((x=c.current)==null||x.disconnect(),c.current=null,d.current=b,p.current=!1,b==null||(l(void 0),!o))return;const y=()=>{if(!p.current&&n!==!1)return;const _=b.getBoundingClientRect().height,k=p.current&&_>0?_:b.scrollHeight;p.current=!0,l(k/16)};y(),c.current=new ResizeObserver(y),c.current.observe(b)},[n,o]),m=w.useCallback(b=>{const y=d.current;if(y==null)return;const x=y.getBoundingClientRect().height;p.current=!0,l((x>0?x:Math.max(b,y.scrollHeight))/16),r==null||r(b)},[r]);return w.useEffect(()=>()=>{var b;(b=c.current)==null||b.disconnect()},[]),g.jsx(t,{...e,fullscreen:a,onFullscreenChange:i,contentHeightRem:s,contentRef:f,onContentHeightChange:m})}function VVt(){const e=We("AssistantMessageBubble");return g.jsx("div",{className:"mb-3 min-w-0",children:g.jsx(zh.Root,{"data-role":"assistant",children:g.jsx(e,{children:g.jsx(zh.Parts,{components:{Text:W_,Reasoning:W_,tools:{Fallback:LOe}}})})})})}function ME({part:e}){var i;const t=FVt(),n=LLt(),r=Zs(),o=s=>{if(!t){e.respondToApproval(s);return}if(e.approval==null)return;let l,c;if("approved"in s)l=s.approved;else if("optionId"in s){const d=D6(e.approval.options).find(p=>p.id===s.optionId);if(d==null)return;l=d.isAllow,c=s.optionId}l!==void 0&&n({approvalId:e.approval.id,approved:l,...c!=null&&c!=="__allow"&&c!=="__deny"?{optionId:c}:{},..."reason"in s&&s.reason!=null?{reason:s.reason}:{}})},a=(s,l)=>{var f;const d=D6((f=e.approval)==null?void 0:f.options).find(m=>m.id===s),p=s==="__allow"?!0:s==="__deny"?!1:d==null?void 0:d.isAllow;return r(Io.Tool.APPROVAL_RESOLVED,{tool_name:e.toolName,option_id:s,approved:p,has_reason:l!=null&&l.trim().length>0,nested:t}),o(s==="__allow"?{approved:!0}:s==="__deny"?{approved:!1,reason:l}:{optionId:s,reason:l})};return g.jsx(HVt,{toolName:e.toolName,argsText:e.argsText,options:D6((i=e.approval)==null?void 0:i.options),onSelectOption:a})}function U6({request:e,response:t}){return{requestSlot:e.value?g.jsx(F6,{title:"Request",content:e.value,isJson:e.isJson,maxHeight:"10.5rem"}):t.data?g.jsx(F6,{title:"Request",content:"{}",isJson:!0,maxHeight:"10.5rem"}):void 0,responseSlot:t.data?g.jsx(F6,{title:"Response",content:t.data,isJson:t.isJson,resizable:!0}):void 0}}var LOe=e=>{var A,R,M,j,O,P;const t=We("ToolCallCard"),n=We("SubAgentCard"),r=We("AskUserPrompt"),o=BVt(),a=Tet(),i=((A=e.status)==null?void 0:A.type)==="requires-action",s=e.toolName===xOe,l=wOe.has(e.toolName),[c,d]=w.useState(i),[p,f]=w.useState(i);i!==p&&(f(i),i&&d(!0));const m=i&&VHt(e.approval),b=a===void 0?void 0:GHt(a),y=WHt((R=e.status)==null?void 0:R.type),x=()=>d(D=>!D),_=w.useCallback(()=>d(!0),[]);if(tVt(s?e.toolCallId:"",_),e.toolName===UHt){const{question:D,options:L=[]}=BHt(e.argsText),z=HHt(e.result);if(z!=null){const $=L.length>0&&!L.includes(z);return g.jsx(r,{questions:[],answeredQuestions:[{id:e.toolCallId,question:D??"Question",options:L,answer:z,isCustom:$}],onSubmit:()=>{},readOnly:!0})}if(!o)return null;const F={id:e.toolCallId,question:D??"Question",options:L};return g.jsx(r,{questions:[F],currentQuestion:F,currentAnswer:{radioValue:"",custom:""},onSubmit:()=>{},readOnly:!0})}if(s){const{agentName:D,instruction:L,stepCount:z}=YHt(e);return g.jsx("div",{"data-slot":"tool-call-card","data-variant":"sub-agent",className:"w-full",children:g.jsx(n,{status:y,expanded:c,onToggle:x,durationText:b,agentName:D,instruction:L,stepCount:z,children:g.jsx(POe.Provider,{value:!0,children:g.jsx(_Je.Messages,{components:{AssistantMessage:VVt,UserMessage:()=>null}})})})})}const k=e.result===void 0?void 0:typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2);if(l){const{command:D,intent:L,argsJson:z}=kOe(e.argsText),{exitCode:F,resultText:$,resultJson:H}=KHt(k);return g.jsx(UVt,{name:e.toolName,intent:L,status:y,expanded:c,onToggle:x,durationText:b,command:D,exitCode:F,argsJson:z,resultText:$,resultJson:H,approvalSlot:m?g.jsx(ME,{part:e}):void 0,approvalId:m?(M=e.approval)==null?void 0:M.id:void 0})}if(_Oe.has(e.toolName)){const{mcpServer:D,innerToolName:L,input:z}=FZ(e.argsText),F=fw(e.argsText),$=vme(e.result);if(e.toolName==="list_tools"&&D){const Y=U6({request:F,response:$});return g.jsx(t,{toolName:`Listing tools · ${D}`,icon:"mcp-server",expanded:c,onToggle:x,awaiting:y==="running",awaitingText:b??"Awaiting Response…",showResponseLine:y!=="running"&&!!$.data,mcpServerName:D,...Y,approvalSlot:m?g.jsx(ME,{part:e}):void 0,approvalId:m?(j=e.approval)==null?void 0:j.id:void 0})}const H=z!==void 0?fw(JSON.stringify(z,null,2)):F,V=U6({request:H,response:$});return g.jsx(t,{toolName:EOe(e.toolName,D,L),icon:"mcp-server",expanded:c,onToggle:x,awaiting:y==="running",awaitingText:b??"Awaiting Response…",showResponseLine:y!=="running"&&$.data!==void 0,mcpServerName:D,...V,approvalSlot:m?g.jsx(ME,{part:e}):void 0,approvalId:m?(O=e.approval)==null?void 0:O.id:void 0})}const E=fw(e.argsText),T=vme(e.result),C=U6({request:E,response:T});return g.jsx(t,{toolName:e.toolName,expanded:c,onToggle:x,awaiting:y==="running",awaitingText:b??"Awaiting Response…",showResponseLine:y!=="running"&&T.data!==void 0,...C,approvalSlot:m?g.jsx(ME,{part:e}):void 0,approvalId:m?(P=e.approval)==null?void 0:P.id:void 0})};function GVt({part:e}){switch(e.type){case"text":case"reasoning":return g.jsx(W_,{});case"image":return g.jsx(zVt,{});case"tool-call":return g.jsx(LOe,{...e});default:return null}}function WVt(){const e=We("AssistantMessageBubble"),t=We("MessageActionBar"),n=We("MessageErrorBanner"),r=We("MessageCancelledBanner"),o=We("MessageIndicator"),a=Y7(),i=$Lt(),s=_xe(),l=Ve(O=>O.message.createdAt),c=Ve(O=>O.threadListItem.remoteId),d=Ve(O=>{var P;return((P=O.message.status)==null?void 0:P.type)==="running"}),p=Ve(O=>O.message.status),f=Ve(O=>{var D,L;const P=(L=(D=O.message.metadata)==null?void 0:D.custom)==null?void 0:L[eN];return typeof P=="string"?P:void 0}),m=Zs(),b=vo(),y=(b==null?void 0:b.mode.status)==="active"?{agentId:b.mode.agentId,agentName:b.mode.agentName}:{},{copy:x,isCopied:_}=wxe({copyToClipboard:O=>navigator.clipboard.writeText(O)}),k=()=>{m(Io.Message.COPIED,Ob({role:"assistant"},{sessionId:c,...y})),x()},E=Ve(O=>O.message.parts),T=(p==null?void 0:p.type)==="incomplete"&&p.reason==="cancelled"?f??"cancelled":void 0,{cutIndex:C,hasFinal:A,toolCount:R,thinkingCount:M}=NVt(E,d),j=(O,P)=>{const D=E.findIndex(L=>L===O);return D===-1||O.type==="text"&&D>=C?null:D<C?O.type==="reasoning"?["group-agentSteps","group-reasoning"]:["group-agentSteps"]:null};return g.jsx(zh.Root,{"data-role":"assistant",children:g.jsx(e,{error:s!==void 0?g.jsx(n,{message:String(s)}):void 0,statusBanner:T!==void 0?g.jsx(r,{message:T}):void 0,actionBar:a?void 0:g.jsx(t,{isCopied:_,onCopy:k,createdAt:l}),children:g.jsx(zh.GroupedParts,{groupBy:j,children:({part:O,children:P})=>{switch(O.type){case"group-agentSteps":return g.jsx(MVt,{toolCount:R,thinkingCount:M,hasFinal:A,children:P});case"group-reasoning":return g.jsx($Vt,{group:O});case"text":{const D=E.findIndex(L=>L===O);return D>=0&&D<C?g.jsx("div",{className:"mb-2 ml-[1.75rem] text-xs text-text-secondary [&_.markdown-body]:text-inherit",children:g.jsx(W_,{})}):g.jsx(W_,{})}case"reasoning":case"tool-call":case"image":case"data":return g.jsx(GVt,{part:O});case"indicator":return i?null:g.jsx(o,{});default:return null}}})})})}function KVt({messages:e,slotOverrides:t,children:n}){const r=Y0e({messages:e,isRunning:!1,convertMessage:a=>a,onNew:async()=>{}}),o=g.jsx(DOe.Provider,{value:!0,children:g.jsx(Txe,{runtime:r,children:n})});return t==null?o:g.jsx(hw,{overrides:t,children:o})}function oC(e,t){return e==="image"||((t==null?void 0:t.startsWith("image/"))??!1)}function YVt(e){const[t,n]=w.useState(void 0);return w.useLayoutEffect(()=>{if(!e){n(void 0);return}const r=URL.createObjectURL(e);return n(r),()=>URL.revokeObjectURL(r)},[e]),t}function zOe(){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(!oC(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=oC(e,t),a=YVt(o?n:void 0);if(o)return a??r}function ZVt(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 $Oe(){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:ZVt(t))}function XVt(){const e=We("AttachmentPreviewDialog"),t=We("AttachmentCard"),n=tn(),r=Ve(c=>c.attachment.name),o=Ve(c=>c.attachment.contentType),a=Ve(c=>c.attachment.type),i=oC(a,o),s=zOe(),l=$Oe();return g.jsx(e,{previewSrc:s,children:g.jsx(t,{name:r,contentType:o,sizeBytes:l,previewSrc:s,isImage:i,size:"chip",onRemove:()=>void n.attachment().remove()})})}function Sme({kind:e}){const t=We("AttachmentPreviewDialog"),n=We("AttachmentCard"),r=Ve(p=>p.attachment.name),o=Ve(p=>p.attachment.contentType),a=Ve(p=>p.attachment.type),i=oC(a,o),s=zOe(),l=$Oe(),c=i&&s!=null;if(e==="image"!==c)return null;const d=g.jsx(n,{name:r,contentType:o,sizeBytes:l,previewSrc:s,isImage:i,size:i?"preview":"chip",previewRem:_Me});return c&&s?g.jsx(t,{previewSrc:s,children:d}):d}function wrn(){return g.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:g.jsx(fJe.Attachments,{children:()=>g.jsx(XVt,{})})})}var kme="flex flex-row flex-wrap justify-end gap-2 empty:hidden";function qVt(){return g.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:[g.jsx("div",{className:kme,children:g.jsx(zh.Attachments,{children:()=>g.jsx(Sme,{kind:"image"})})}),g.jsx("div",{className:kme,children:g.jsx(zh.Attachments,{children:()=>g.jsx(Sme,{kind:"file"})})})]})}function QVt(){const e=We("UserMessageBubble"),t=We("UserMessageActionBar"),n=Y7(),r=iN(),o=tn(),a=Zs(),i=vo(),s=Ve(x=>x.message.createdAt),l=Ve(x=>x.threadListItem.remoteId),c=Ve(x=>x.message.content.filter(_=>_.type==="text").map(_=>_.text).join(`
|
|
992
|
-
`)),{edit:d,disabled:p}=EGe(),{copy:f,isCopied:m}=wxe({copyToClipboard:x=>navigator.clipboard.writeText(x)}),b=(i==null?void 0:i.mode.status)==="active"?{agentId:i.mode.agentId,agentName:i.mode.agentName}:{},y={sessionId:l,...b};return g.jsx(zh.Root,{"data-role":"user",children:g.jsx(e,{text:c,attachments:g.jsx(qVt,{}),editAction:n?void 0:g.jsx(t,{isCopied:m,editDisabled:p||!r,retryDisabled:!r,createdAt:s,onCopy:()=>{a(Io.Message.COPIED,Ob({role:"user"},y)),f()},onEdit:()=>{a(Io.Message.EDIT_STARTED,Ob(void 0,y)),d()},onRetry:()=>{r&&(a(Io.Message.RETRIED,Ob(void 0,y)),o.message().composer().beginEdit(),o.message().composer().send({startRun:!0}))}})})})}function JVt(e){return g.jsx(nOe,{...e,readOnly:!0,onDownloadArtifact:void 0,sandboxDownloadReadOnlyTooltip:"Download File is not available in read-only mode"})}function eGt({isCopied:e,onCopy:t,createdAt:n,className:r}){return g.jsx(rOe,{isCopied:e,onCopy:t,createdAt:n,className:r})}function tGt(e){return g.jsx(yOe,{...e,readOnly:!0})}function nGt(e){return g.jsx(AOe,{...e,awaiting:e.approvalSlot?!1:e.awaiting})}function rGt(e){const t=We("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=$_(r)?r:void 0;return g.jsxs(wMe,{...e,children:[e.children,o!=null&&o.length>0?g.jsx(t,{servers:o,readOnly:!0,onConnect:()=>{}}):null]})}var oGt={AssistantMessageBubble:rGt,UserMessageActionBar:eGt,Markdown:JVt,ToolApprovalBar:tGt,ToolCallCard:nGt};function aGt(e){const t=e.id??"";return e.role==="user"?t.replace(/-user$/,""):t.replace(/-assistant$/,"")}function iGt(e,t){const n=new Map(t.flatMap(r=>(r.created.input??[]).some(a=>a.type==="user.message")?[]:[[r.turnId,jOe(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 sGt(e){var n;const t=((n=e.done)==null?void 0:n.state.status)==="done"?e.done.state.requiredActions:void 0;if(Array.isArray(t)){for(const r of t)if(r.type==="mcp.auth_required"&&$_(r.mcpServers))return r.mcpServers}for(const r of e.events)if(r.type==="mcp.auth_required"&&$_(r.mcpServers))return r.mcpServers}function lGt(e,t){var s,l,c;const n=sGt(t);if(n==null||n.length===0)return e;const r=e.findIndex(d=>d.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((d,p)=>p===r?i:d)}function cGt(e,t){var r,o;if(aGt(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 uGt(e,t){const n=e.filter(r=>cGt(r,t.turnId));return lGt(n,t)}function dGt({sessionId:e,events:t,contentMaxWidth:n,sessionMetrics:r}){const o=Hv(),a=We("AgentSessionTurnHeader"),i=We("AgentSessionEventTimeline"),s=We("AgentSessionMetricsStrip"),l=We("MessageListSkeleton"),c=We("ThreadViewportShell"),[d,p]=w.useState(),[f,m]=w.useState(!1),b=w.useRef(new Map),y=w.useMemo(()=>RVt(t),[t]),x=w.useMemo(()=>y.filter(C=>C.renderable),[y]),_=w.useMemo(()=>iGt(t,x),[t,x]),k=w.useMemo(()=>yVt(y),[y]),E=w.useMemo(()=>uVt({turns:y,segments:k,sessionMetrics:r}),[r,k,y]),T=w.useCallback(C=>{var A;(A=b.current.get(C))==null||A.scrollIntoView({behavior:"smooth",block:"start"})},[]);return w.useEffect(()=>{let C=!1;p(void 0),m(!1);const A=SVt(_),R={...o,listEvents:M=>A.listEvents(M),listTurns:async()=>({data:[]})};return mLt(R,e).then(M=>{C||p(M.messages)}).catch(()=>{C||m(!0)}),()=>{C=!0}},[_,o,e]),f?g.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session messages could not be loaded."}):d===void 0?g.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-4",children:g.jsx(l,{})}):d.length===0&&x.length===0?g.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"This session has no messages yet."}):g.jsxs("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain","data-slot":"agent-session-scroll",children:[g.jsx("div",{className:"sticky top-0 z-20 bg-primary-bg","data-slot":"agent-session-metrics-sticky",children:g.jsx(s,{metrics:E})}),g.jsx("div",{className:"border-b border-border",children:g.jsx(w.Suspense,{fallback:null,children:g.jsx(i,{turns:y,segments:k,onSelectTurn:T})})}),g.jsx(c,{scrollable:!1,className:"pb-4",...n==null?{}:{contentMaxWidth:n},children:g.jsx("div",{className:"flex flex-col gap-4",children:x.map(C=>g.jsx(pGt,{turn:IVt(y,C.turnNumber)??C,messages:uGt(d,C),AgentSessionTurnHeader:a,onMount:A=>{A==null?b.current.delete(C.turnNumber-1):b.current.set(C.turnNumber-1,A)}},C.turnId))})})]})}function pGt({turn:e,messages:t,AgentSessionTurnHeader:n,onMount:r}){return!e.showHeader&&t.length===0?null:g.jsxs("section",{ref:r,id:`session-turn-${e.turnNumber}`,className:"flex flex-col gap-2",children:[e.showHeader?g.jsx(n,{turnNumber:e.turnNumber,totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cachedTokens:e.cachedTokens,durationMs:e.durationMs,totalCostInUsd:e.totalCostInUsd}):null,t.length>0?g.jsx(KVt,{slotOverrides:oGt,messages:t,children:g.jsx(_re.Root,{asChild:!0,children:g.jsx("div",{className:"aui-root aui-thread-root flex w-full flex-col",children:g.jsx(_re.Messages,{children:({message:o})=>o.role==="user"?g.jsx(QVt,{}):g.jsx(WVt,{})})})})}):null]})}var fGt=w.lazy(()=>Sa(()=>import("./AgentOverview-OBBGSUOK-C_7h7s2o.js"),[],import.meta.url)),hGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentSessions-OB32CD3H-DsqoPWfh.js"),__vite__mapDeps([2,3]),import.meta.url)).AgentSessions})),gGt=w.lazy(()=>Sa(()=>import("./AgentCodeSnippets-GX5MTZLF-C1qMMx83.js"),[],import.meta.url)),mGt=w.lazy(async()=>({default:(await Sa(()=>import("./SchedulesPage-HLHAOIS6-DqVBKUZr.js"),__vite__mapDeps([4,5]),import.meta.url)).SchedulesPage})),bGt=w.lazy(async()=>({default:(await Sa(()=>import("./EnvironmentsPage-OXKHJMOO-CgRxeC0e.js"),__vite__mapDeps([6,5]),import.meta.url)).EnvironmentsPage})),vGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentSessionEventTimeline-ZBW3AIU2-BpsEEOy4.js"),[],import.meta.url)).AgentSessionEventTimeline})),yGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentSessionEventTimelineChart-VQNS2G4D-Bf8Z-J0v.js"),__vite__mapDeps([7,8]),import.meta.url)).AgentSessionEventTimelineChart})),xGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentMetricChart-MMZYPKVN-DBJeoFu0.js"),__vite__mapDeps([9,8]),import.meta.url)).AgentMetricChart})),FOe={Accordion:qNe,AccordionSummary:QNe,AccordionDetails:JNe,BrandLogo:mZ,ComposerShell:nUt,ComposerLeftSection:JFt,ComposerRightSection:eUt,ComposerSendButton:tUt,PermissionGuard:GBt,DraftComposerLeftSection:cBt,DraftComposerRightSection:uBt,DraftAgentConfigTrigger:aBt,DraftCapabilitiesPanel:iBt,DraftComposerActionsMenu:sBt,AgentCustomParametersEditor:PUt,AgentConfigEditors:fUt,AgentInstructionsDrawer:LUt,AgentModelEditorContent:WUt,AgentModelSettingsContent:ZUt,AgentMcpEditorContent:VUt,AgentModelConfigModal:GUt,AgentResourceEditorContent:qUt,AgentResourceConfigModal:XUt,AgentSkillsEditorContent:oBt,AgentConfigPanel:IUt,AgentConfigSection:RUt,AgentRuntimeConfigFields:nBt,AgentRuntimeConfigDrawer:QUt,AgentRuntimeEditorContent:rBt,DraftCompositeSelector:gBt,CatalogRow:qm,ConnectorConnectButton:g$,DraftModelSelector:mBt,AssistantMessageBubble:wMe,UserMessageBubble:iVt,UserMessageEdit:sVt,UserMessageActionBar:aVt,MessageActionBar:rOe,MessageCancelledBanner:OBt,MessageErrorBanner:jBt,MessageIndicator:PBt,MessageTimestamp:zBt,Markdown:nOe,SyntaxHighlighter:AHt,OpenUiFenceBlock:IIe,SandboxArtifactDownload:KBt,ChatFileDownload:WFt,FilePreviewPanel:_Bt,MonacoEditorCore:HBt,CodeEditor:QFt,WelcomeScreen:COe,ToolCallCard:AOe,ToolCallContentBlock:rVt,ToolApprovalBar:yOe,ToolGroupCard:oVt,SubAgentCard:wHt,SandboxToolCallCard:ZBt,AgentStepsCard:_$t,ReasoningCard:O$t,AskUserPrompt:I$t,McpAuthPrompt:M$t,ResumeUnavailable:j$t,AttachmentCard:wFt,AttachmentPreviewDialog:SFt,AttachmentPickerButton:_Ft,ScrollToBottomButton:lOe,ThreadListRow:OHt,ThreadListNewButton:CHt,AgentsLibrary:gFt,AgentLibraryRow:pFt,AgentsLibraryButton:mFt,ApprovalNavBanner:bFt,SessionsBrowserButton:iHt,AgentDetailsPage:q$t,AgentDetailsHeader:K$t,AgentDetailsTabs:J$t,AgentDetailsUnavailable:e7t,AgentOverview:fGt,AgentOverviewCard:f7t,AgentMetrics:lVt,AgentMetricsView:p7t,AgentMetricsTimeRangeFilter:i7t,AgentMetricCard:a7t,AgentMetricStatistics:d7t,AgentMetricChart:xGt,AgentSessionDetailHeader:h7t,AgentSessionsFilters:j7t,SessionsPage:L7t,AgentSessionEventTimeline:vGt,AgentSessionEventTimelineChart:yGt,AgentSessionListRow:b7t,AgentSessionMetricsStrip:k7t,AgentSessionTimelineContainer:dGt,AgentSessionTurnHeader:D7t,AgentSessions:hGt,AgentCodeSnippets:gGt,AgentCodeBlock:P$t,SchedulesPage:mGt,SchedulesButton:oHt,EnvironmentsPage:bGt,EnvironmentsButton:bBt,SaveAgentButton:tHt,SaveAgentForm:rHt,SelectAgentEmptyState:aHt,ClearChatButton:qFt,ShareChatButton:sHt,ShareSessionDialog:vHt,ThreadListRowSkeleton:RHt,ThreadListEmptyState:IHt,ThreadListShell:NHt,HistoryLoader:YMe,MessageListSkeleton:xHt,ThreadRootShell:gOe,ThreadViewportShell:mOe,ThreadComposerAreaShell:bOe,MessageGroup:vOe,Toast:DHt,ToastStack:zHt,ShellActionsActionSlot:yHt,UserAvatar:Q7t},gN=w.createContext(FOe),BZ=w.createContext(void 0);function hw({overrides:e,theme:t,children:n}){const r=w.useContext(gN),o=w.useContext(BZ),a=w.useMemo(()=>({...r,...e}),[r,e]),i=g.jsx(wGt,{slots:a,inheritedTheme:o,theme:t,children:n});return t!==void 0||!(o!==void 0)?g.jsx(Gm,{theme:t,children:i}):i}function wGt({slots:e,children:t,inheritedTheme:n,theme:r}){const o=iye(),i=((r==null?void 0:r.mode)==="light"||(r==null?void 0:r.mode)==="dark"?r.mode:void 0)??n??o;return g.jsx(BZ.Provider,{value:i,children:g.jsx(gN.Provider,{value:e,children:t})})}function We(e){return w.useContext(gN)[e]}function _rn(e){return w.useContext(gN)[e]===FOe[e]}function mN(){return w.useContext(BZ)??"light"}var UOe=w.createContext(null),x$=new Set;function _Gt(){for(const e of x$)e()}function SGt(){const e=Y7(),[t,n]=w.useState(!1);w.useEffect(()=>{e||n(!1)},[e]),w.useEffect(()=>{const i=()=>{n(!1)};return x$.add(i),()=>{x$.delete(i)}},[]);const r=e||t,o=w.useCallback(()=>{n(!1)},[]),a=w.useCallback(i=>{n(!0);try{const s=i();s!=null&&typeof s.then=="function"&&s.catch(()=>{n(!1)})}catch{n(!1)}},[]);return{isBusy:r,isRunning:e,isSubmitting:t,send:a,resetBusy:o}}function Srn({children:e}){const t=SGt();return w.createElement(UOe.Provider,{value:t},e)}function krn(){const e=w.useContext(UOe);if(e==null)throw new Error("useComposerBusyState must be used within ComposerBusyProvider");return e}var BOe=w.createContext(void 0);function kGt({renderers:e,children:t}){return g.jsx(BOe.Provider,{value:e,children:t})}function Ern(){return w.useContext(BOe)}var HOe=w.createContext(null);function EGt({children:e}){const[t,n]=w.useState(!1),r=w.useMemo(()=>({open:t,setOpen:n}),[t]);return g.jsx(HOe.Provider,{value:r,children:e})}function Trn(){const e=w.useContext(HOe);if(e===null)throw new Error("useWidgetVisibility must be used within WidgetVisibilityProvider");return e}var VOe="is_create_agent";function TGt(e){return e?"true":"false"}function HZ(e){return e==null?!1:Reflect.get(e,VOe)==="true"}function AGt(e){if("isCreateAgent"in e&&Reflect.get(e,"isCreateAgent")===!0)return!0;if(!("metadata"in e))return!1;const t=Reflect.get(e,"metadata");if(typeof t!="object"||t===null)return!1;const n={};for(const r of Object.keys(t)){const o=Reflect.get(t,r);typeof o=="string"&&(n[r]=o)}return HZ(n)}function CGt({locallyCreatedSessionIds:e,children:t}){const n=Ve(r=>r.threadListItem.remoteId);return g.jsx(z$t,{sessionId:n,assumeManage:n!=null&&e.has(n),children:t})}function RGt({server:e,locallyCreatedSessionIds:t}){return{...e,async createSession(n){const r=await e.createSession(n);return t.add(r.id),r},async listSessions(n){const r=await e.listSessions(n);return{...r,data:r.data.filter(o=>!AGt(o))}}}}function IGt({server:e,agent:t,agentName:n,listSessionsAgentId:r,initialSessionId:o,adapters:a,onError:i,children:s}){const{showError:l}=B$t(),c=i??l,p=w.useMemo(()=>({server:e,ids:new Set}),[e]).ids,f=w.useMemo(()=>RGt({server:e,locallyCreatedSessionIds:p}),[p,e]),m=w.useCallback(y=>{_Gt(),c(y)},[c]),b=hzt({server:f,agent:t,agentName:n,listSessionsAgentId:r,listSessionsCreatedByMe:!0,initialSessionId:o,onError:m,adapters:{...a,attachments:(a==null?void 0:a.attachments)??UDt}});return g.jsx(Txe,{runtime:b,children:g.jsx(CGt,{locallyCreatedSessionIds:p,children:s})})}function NGt(e){const{server:t,initialSessionId:n,adapters:r,onError:o,children:a,agent:i,agentName:s,listSessionsAgentId:l}=e,c=w.useMemo(()=>t,[t]);return g.jsx(rMe,{children:g.jsx(IGt,{server:c,agent:i,agentName:s,listSessionsAgentId:l,initialSessionId:n,adapters:r,onError:o,children:a})})}function MGt(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 Eme(e,t){if(e===void 0)return;const n=e.filter(r=>{const o=c$(r);return o!==null&&t.has(o)});return n.length===e.length?e:n}function OGt({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=jv(l.name,e.model.params,l.properties.reasoningEfforts))}const s=Eme(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=Eme(e.skills,new Set(n.map(c=>c.name)));l!==e.skills&&(a.skills=l)}return a}function jGt({agentSpec:e,sandboxEnabled:t,kind:n="agent"}){var o,a;if(n==="chat"){if(t==null)return{};const i=MGt(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=GL(e,t);return r===e?{}:{config:r.config}}function PGt({agentSpec:e,webSearchEnabled:t,previousWebSearchEnabled:n,explicitOff:r=!1,kind:o="agent"}){const a=bye({spec:e,previousWebSearchEnabled:n,webSearchEnabled:t,explicitOff:r,kind:o}),i=DT({spec:a,webSearchEnabled:t});return i===e?{}:{config:i.config}}function DGt(){var T;const{mode:e,pendingSessionId:t,rememberDraftSpec:n}=ng(),{agentSpec:r,isSpecLoading:o}=Eg(),a=V1(),i=v7(),s=i==null?void 0:i.sandbox.enabled,l=(T=i==null?void 0:i.webSearch)==null?void 0:T.enabled,c=w.useRef(l),{models:d,skills:p,connectors:f,loaded:m,error:b,ensureLoaded:y}=PC(),x=e.status==="active"&&e.isMutable&&t==null,_=x&&e.agentId==null,k=!o,E=e.status==="active"&&e.isMutable&&e.isCreateAgent?"agent":"chat";return w.useEffect(()=>{_&&y()},[y,_]),w.useEffect(()=>{_&&k&&r!=null&&n(r,E)},[r,k,_,E,n]),w.useEffect(()=>{if(!_||!k||r==null||a==null)return;const C=jGt({agentSpec:r,sandboxEnabled:s,kind:E});Object.keys(C).length>0&&a(C)},[r,k,_,E,s,a]),w.useEffect(()=>{const C=c.current;if(c.current=l,!x||!k||r==null||a==null)return;const A=PGt({agentSpec:r,webSearchEnabled:l,previousWebSearchEnabled:_?C:void 0,explicitOff:_&&vye(E)===!1,kind:E});Object.keys(A).length>0&&a(A)},[r,k,x,_,E,l,a]),w.useEffect(()=>{if(!_||!k||r==null||a==null||!m||b!=null)return;const C=OGt({agentSpec:r,models:d,skills:p,connectors:f,skillsEnabled:i==null?void 0:i.skill.enabled});Object.keys(C).length>0&&a(C)},[r,k,i==null?void 0:i.skill.enabled,f,b,_,m,d,p,a]),null}function LGt(){const e=vo(),t=tn(),n=e==null?void 0:e.pendingSessionId,r=(e==null?void 0:e.pendingSessionEpoch)??0;return w.useEffect(()=>{n!=null&&Promise.resolve(t.threads().switchToThread(n)).catch(()=>{})},[t,n,r]),null}function zGt(){const{openLibraryAgent:e,openSharedSession:t,setSessionsOpen:n}=ng(),r=Vv(),o=r1({sessions:r});return w.useEffect(()=>{if(!o)return;const a=Mu(window.location.search);if(a.view===jC&&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 $Gt({onRemoteIdChange:e}){const t=Ve(n=>n.threadListItem.remoteId);return w.useEffect(()=>{e(t??void 0)},[t,e]),null}var FGt=3e4;function UGt(){return new Map}function BGt(e){const t={...e};return delete t.startTimestamp,JSON.stringify(t,Object.keys(t).sort())}function HGt({server:e,cache:t}){const{deleteSession:n,renameSession:r}=e;return{...e,listSessions(o){const a=BGt(o),i=Date.now(),s=t.get(a);if(s!==void 0&&i-s.at<FGt)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 VGt={data:{sandbox:{enabled:!0},skill:{enabled:!0},settings:{enabled:!0},webSearch:{enabled:!1}}};function Tme(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="trueforge"}function GGt(e){return typeof Reflect.get(e,"getCapabilities")=="function"}function WGt(e,t,n){const r=GGt(e)?()=>e.getCapabilities():async()=>VGt,a={...{...e,getCapabilities:r}};if(!KGt(a))throw new Error("TrueForgeUI: runtime adapter returned an incomplete AgentUIServer");return a}function KGt(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 YGt(e,t){const n=Tme(e)?e:null,r=Tme(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,d]=w.useState(()=>r?{status:"ready",server:r,error:null}:{status:"loading",server:null,error:null});return w.useEffect(()=>{if(r){d({status:"ready",server:r,error:null});return}let p=!1;return d({status:"loading",server:null,error:null}),(async()=>{const{createTrueForgeAgentUIServer:m}=await Sa(async()=>{const{createTrueForgeAgentUIServer:b}=await Promise.resolve().then(()=>EQt);return{createTrueForgeAgentUIServer:b}},void 0,import.meta.url);return m({...o?{baseUrl:o}:{},...a?{token:a}:{},...i!==void 0?{fetch:i}:{},...s!=null?{catalog:s}:{},...l!=null?{permissions:l}:{}})})().then(m=>{if(!p)try{d({status:"ready",server:WGt(m,void 0,void 0),error:null})}catch(b){t==null||t(b),d({status:"error",server:null,error:b})}}).catch(m=>{p||(t==null||t(m),d({status:"error",server:null,error:m}))}),()=>{p=!0}},[r,o,a,i,s,l,t]),c}var ZGt=w.lazy(()=>Sa(()=>import("./SidebarLayout-LHIKWYLB-Deq6FslD.js"),__vite__mapDeps([10,11]),import.meta.url).then(e=>({default:e.SidebarLayout}))),XGt=w.lazy(()=>Sa(()=>import("./DrawerLayout-T6U5AGG7-B4mayMKB.js"),__vite__mapDeps([12,11]),import.meta.url).then(e=>({default:e.DrawerLayout}))),qGt=w.lazy(()=>Sa(()=>import("./DockLayout-YSSOMIEK-Ct_Ma6-M.js"),__vite__mapDeps([13,14,11]),import.meta.url).then(e=>({default:e.DockLayout}))),QGt=w.lazy(()=>Sa(()=>import("./WidgetLayout-Q3F3UWN3-CNvkLcEG.js"),__vite__mapDeps([15,14,11]),import.meta.url).then(e=>({default:e.WidgetLayout}))),JGt=w.lazy(()=>Sa(()=>import("./ShellRouteSync-XIPKA3OH-DC61bU3T.js"),__vite__mapDeps([16,3,17]),import.meta.url).then(e=>({default:e.ShellRouteSync})));function eWt({className:e}){return g.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 GOe({className:e}){const t=mN();return g.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:g.jsx(gZ,{state:"connecting",speed:1,theme:t,paused:!1,"aria-hidden":!0,size:64,style:{width:"4.5rem",height:"4.5rem"}})})}function tWt({error:e,className:t}){const n=aa(e,"Failed to initialize server");return g.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 nWt(e){return e==="sidebar"||e==="drawer"||e==="dock"||e==="widget"}function rWt({layout:e,className:t}){switch(e){case"sidebar":return g.jsx(ZGt,{className:t});case"drawer":return g.jsx(XGt,{className:t});case"dock":return g.jsx(qGt,{className:t});case"widget":return g.jsx(QGt,{className:t})}}function oWt({layout:e,className:t}){if(nWt(e))return g.jsx(w.Suspense,{fallback:g.jsx(eWt,{className:t}),children:g.jsx(rWt,{layout:e,className:t})});const n=e;return g.jsx(n,{className:t})}function aWt({children:e,initialSessionId:t,onRemoteIdChange:n,server:r,...o}){const{mode:a,runtimeKey:i,historyAgentFilter:s,listSessionsAgentId:l,pendingSessionId:c}=ng(),d=a.status==="active"&&a.isMutable&&a.isCreateAgent,[p]=w.useState(UGt),f=w.useMemo(()=>({...r,createSession:_=>{if(_.agentSpec===void 0)return r.createSession(_);const k={..._,metadata:{[VOe]:TGt(d)}};return r.createSession(k)}}),[r,d]),m=w.useMemo(()=>HGt({server:f,cache:p}),[f,p]),b=w.useMemo(()=>s==null||s.agentId!=null?m:{...m,listSessions:async()=>({data:[]})},[m,s]),y=w.useMemo(()=>a.status==="active"&&a.isMutable?a.agentSpec??{model:{name:"openai-main/gpt-4.1"}}:{model:{name:"openai-main/gpt-4.1"}},[i]),x=w.useMemo(()=>{if(a.status==="idle")return{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}};if(!a.isMutable){const _=a.agentName??a.agentId??c;return _==null?{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}}:{mode:"named",agentName:_}}return{mode:"draft",defaultAgentSpec:y}},[a,y,c]);return g.jsx(a7e,{children:g.jsx(NGt,{...o,server:b,agent:x,listSessionsAgentId:l,initialSessionId:c??t,children:g.jsxs(QBt,{children:[g.jsx(DGt,{}),g.jsx(LGt,{}),n!=null?g.jsx($Gt,{onRemoteIdChange:n}):null,e]})},i)})}function iWt(e){const{layout:t="sidebar",overrides:n,theme:r,className:o,agentConfig:a=yye,initialSettingsOpen:i=!1,server:s,onError:l,analytics:c,customActionRenderers:d,currentUser:p,resolvedRoutes:f,routes:m,...b}=e,y=YGt(s,l),[x,_]=w.useState(void 0),k=w.useCallback(R=>_(R),[]);if(w.useEffect(()=>{oOe()},[]),y.status==="loading")return g.jsx(hw,{overrides:n,theme:r,children:g.jsx(GOe,{className:o})});if(y.status==="error")return g.jsx(hw,{overrides:n,theme:r,children:g.jsx(tWt,{error:y.error,className:o})});const E=y.server,T=g.jsx(oWt,{layout:t,className:o}),C=g.jsx(e7e,{track:c==null?void 0:c.track,children:g.jsx(rMe,{children:g.jsxs(K$e,{agentConfig:a,initialSettingsOpen:i,children:[g.jsx(zGt,{}),f!=null?g.jsx(w.Suspense,{fallback:null,children:g.jsx(JGt,{routes:f,activeRemoteId:x,initialSettingsOpen:i,onError:l})}):null,g.jsx(aWt,{server:E,onError:l,onRemoteIdChange:f!=null?k:void 0,...b,children:T})]})})}),A=t==="widget"?g.jsx(EGt,{children:C}):C;return g.jsx(hw,{overrides:n,theme:r,children:g.jsx(Y7t,{currentUser:p,children:g.jsx(kGt,{renderers:d,children:g.jsx(R$e,{server:E,children:f!=null?g.jsx(fHt,{routes:f,children:A}):A})})})})}function sWt(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.getMe!=null?{getMe:e.getMe}:{}}}var lWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),B6=lWt,cWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsxs("g",{opacity:.9,children:[g.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"}),g.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"}),g.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"}),g.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"}),g.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"})]})}),uWt=cWt,dWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),pWt=dWt,fWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),hWt=fWt,gWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 22 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4824 12.432L21.0265 6.20004L10.5441 0L0 6.20004L10.4824 12.432Z",fill:"#ECF2F9"}),g.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"}),g.jsx("path",{d:"M10.5 11.7499V0.749939L19.75 6.24994L10.5 11.7499Z",fill:"url(#paint0_linear_10651_178757)"}),g.jsx("path",{d:"M10.5 11.7499V0.749939L1.25 6.24994L10.5 11.7499Z",fill:"#0E1623"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 6.20001V18.686L10.5441 25V12.4319L0 6.20001Z",fill:"#CEE0F8"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.0265 6.20001V18.686L10.4824 25V12.4319L21.0265 6.20001Z",fill:"#82A0CE"}),g.jsx("path",{d:"M10.4973 11.7478L4.64099 8.26706V8.95172L10.4973 12.4126L15.8148 9.27748V8.59062L10.4973 11.7478Z",fill:"#ECF2F9"}),g.jsx("defs",{children:g.jsxs("linearGradient",{id:"paint0_linear_10651_178757",x1:15.0834,y1:2.10412,x2:15.125,y2:11.7499,gradientUnits:"userSpaceOnUse",children:[g.jsx("stop",{stopColor:"#5E7BAA"}),g.jsx("stop",{offset:1,stopColor:"#030407"})]})})]}),mWt=gWt,bWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_5446_3655)",children:[g.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"}),g.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"})]}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_5446_3655",children:g.jsx("rect",{width:14,height:14,fill:"white"})})})]}),vWt=bWt,yWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),xWt=yWt,wWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_10581_4008)",children:[g.jsx("path",{d:"M-0.000793457 0.015625L39.9992 20.0156V40L19.9992 40V80.0156H39.9992V100.016L-0.000793457 120.016V0.015625Z",fill:"white"}),g.jsx("path",{d:"M119.999 0L79.9992 20V40H99.9992V80H79.9992V100L119.999 120V0Z",fill:"white"}),g.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"})]}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_10581_4008",children:g.jsx("rect",{width:120,height:120,fill:"white"})})})]}),_Wt=wWt,SWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_10581_1729)",children:[g.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"}),g.jsx("path",{d:"M139.999 0L93.3324 23.3333V46.6667H116.666V93.3333H93.3324V116.667L139.999 140V0Z",fill:"#05090E"}),g.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"})]}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_10581_1729",children:g.jsx("rect",{width:140,height:140,fill:"white"})})})]}),kWt=SWt;y$e({"mcp-server":vWt,"agent-2":B6,bot:B6,robot:B6,compare:hWt,ai:uWt,searchGlobe:xWt,"brain-regular":pWt,empty:mWt,"trueforge-logomark-light":kWt,"trueforge-logomark-dark":_Wt});var EWt=1e3,TWt=5e3;function AWt(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 CWt=()=>{const[e,t]=w.useState();w.useEffect(()=>{const a=new URLSearchParams(window.location.search),i=a.get("pUid"),s=AWt(a);t(i?{popupUid:i,isSuccess:s}:null);const l=()=>{if(!i)return;const p=new BroadcastChannel(UMe),f={popupUid:i,isSuccess:s};p.postMessage(f),p.close()};l();const c=window.setTimeout(l,EWt),d=window.setTimeout(()=>{window.close()},TWt);return()=>{window.clearTimeout(c),window.clearTimeout(d)}},[]);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 g.jsx("main",{className:"flex min-h-screen items-center justify-center bg-primary-bg p-6",children:g.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?g.jsx(xe,{name:"oauth-loading",className:"size-16 animate-spin text-text-secondary"}):n?g.jsx(xe,{name:"oauth-success",className:"size-16 text-success-bg"}):g.jsx(xe,{name:"oauth-error",className:"size-16 text-failure-bg"}),g.jsx("h1",{className:"text-2xl font-semibold text-text-primary",children:r}),g.jsx("p",{className:"text-sm leading-6 text-text-secondary",children:o})]})})},RWt=CWt,IWt=w.lazy(()=>Sa(()=>import("./TrueForgeUIWithRouter-SZT3KVCD-D8zD2X-X.js"),__vite__mapDeps([18,17]),import.meta.url).then(e=>({default:e.TrueForgeUIWithRouter})));function NWt(e){if(typeof window<"u"&&new URLSearchParams(window.location.search).get("screenType")==="mcp-auth")return g.jsx(hw,{overrides:e.overrides,theme:e.theme,children:g.jsx(RWt,{})});const{withRouter:n,...r}=e;return n?g.jsx(w.Suspense,{fallback:g.jsx(GOe,{className:e.className}),children:g.jsx(IWt,{...r})}):g.jsx(iWt,{...r})}const aC=(e,t,n)=>JSON.stringify(e,t,n);function vh(e,t){return JSON.parse(e,t)}class at extends Error{constructor({message:t,statusCode:n,body:r,rawResponse:o,cause:a}){super(MWt({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 t,n;return((n=(t=this.rawResponse)==null?void 0:t.headers)==null?void 0:n.get("x-request-id"))??void 0}}function MWt({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: ${aC(n,void 0,2)}`),r.join(`
|
|
992
|
+
`)),{edit:d,disabled:p}=EGe(),{copy:f,isCopied:m}=wxe({copyToClipboard:x=>navigator.clipboard.writeText(x)}),b=(i==null?void 0:i.mode.status)==="active"?{agentId:i.mode.agentId,agentName:i.mode.agentName}:{},y={sessionId:l,...b};return g.jsx(zh.Root,{"data-role":"user",children:g.jsx(e,{text:c,attachments:g.jsx(qVt,{}),editAction:n?void 0:g.jsx(t,{isCopied:m,editDisabled:p||!r,retryDisabled:!r,createdAt:s,onCopy:()=>{a(Io.Message.COPIED,Ob({role:"user"},y)),f()},onEdit:()=>{a(Io.Message.EDIT_STARTED,Ob(void 0,y)),d()},onRetry:()=>{r&&(a(Io.Message.RETRIED,Ob(void 0,y)),o.message().composer().beginEdit(),o.message().composer().send({startRun:!0}))}})})})}function JVt(e){return g.jsx(nOe,{...e,readOnly:!0,onDownloadArtifact:void 0,sandboxDownloadReadOnlyTooltip:"Download File is not available in read-only mode"})}function eGt({isCopied:e,onCopy:t,createdAt:n,className:r}){return g.jsx(rOe,{isCopied:e,onCopy:t,createdAt:n,className:r})}function tGt(e){return g.jsx(yOe,{...e,readOnly:!0})}function nGt(e){return g.jsx(AOe,{...e,awaiting:e.approvalSlot?!1:e.awaiting})}function rGt(e){const t=We("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=$_(r)?r:void 0;return g.jsxs(wMe,{...e,children:[e.children,o!=null&&o.length>0?g.jsx(t,{servers:o,readOnly:!0,onConnect:()=>{}}):null]})}var oGt={AssistantMessageBubble:rGt,UserMessageActionBar:eGt,Markdown:JVt,ToolApprovalBar:tGt,ToolCallCard:nGt};function aGt(e){const t=e.id??"";return e.role==="user"?t.replace(/-user$/,""):t.replace(/-assistant$/,"")}function iGt(e,t){const n=new Map(t.flatMap(r=>(r.created.input??[]).some(a=>a.type==="user.message")?[]:[[r.turnId,jOe(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 sGt(e){var n;const t=((n=e.done)==null?void 0:n.state.status)==="done"?e.done.state.requiredActions:void 0;if(Array.isArray(t)){for(const r of t)if(r.type==="mcp.auth_required"&&$_(r.mcpServers))return r.mcpServers}for(const r of e.events)if(r.type==="mcp.auth_required"&&$_(r.mcpServers))return r.mcpServers}function lGt(e,t){var s,l,c;const n=sGt(t);if(n==null||n.length===0)return e;const r=e.findIndex(d=>d.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((d,p)=>p===r?i:d)}function cGt(e,t){var r,o;if(aGt(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 uGt(e,t){const n=e.filter(r=>cGt(r,t.turnId));return lGt(n,t)}function dGt({sessionId:e,events:t,contentMaxWidth:n,sessionMetrics:r}){const o=Hv(),a=We("AgentSessionTurnHeader"),i=We("AgentSessionEventTimeline"),s=We("AgentSessionMetricsStrip"),l=We("MessageListSkeleton"),c=We("ThreadViewportShell"),[d,p]=w.useState(),[f,m]=w.useState(!1),b=w.useRef(new Map),y=w.useMemo(()=>RVt(t),[t]),x=w.useMemo(()=>y.filter(C=>C.renderable),[y]),_=w.useMemo(()=>iGt(t,x),[t,x]),k=w.useMemo(()=>yVt(y),[y]),E=w.useMemo(()=>uVt({turns:y,segments:k,sessionMetrics:r}),[r,k,y]),T=w.useCallback(C=>{var A;(A=b.current.get(C))==null||A.scrollIntoView({behavior:"smooth",block:"start"})},[]);return w.useEffect(()=>{let C=!1;p(void 0),m(!1);const A=SVt(_),R={...o,listEvents:M=>A.listEvents(M),listTurns:async()=>({data:[]})};return mLt(R,e).then(M=>{C||p(M.messages)}).catch(()=>{C||m(!0)}),()=>{C=!0}},[_,o,e]),f?g.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"Session messages could not be loaded."}):d===void 0?g.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-4",children:g.jsx(l,{})}):d.length===0&&x.length===0?g.jsx("div",{className:"flex flex-1 items-center justify-center px-6 text-sm text-text-secondary",children:"This session has no messages yet."}):g.jsxs("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain","data-slot":"agent-session-scroll",children:[g.jsx("div",{className:"sticky top-0 z-20 bg-primary-bg","data-slot":"agent-session-metrics-sticky",children:g.jsx(s,{metrics:E})}),g.jsx("div",{className:"border-b border-border",children:g.jsx(w.Suspense,{fallback:null,children:g.jsx(i,{turns:y,segments:k,onSelectTurn:T})})}),g.jsx(c,{scrollable:!1,className:"pb-4",...n==null?{}:{contentMaxWidth:n},children:g.jsx("div",{className:"flex flex-col gap-4",children:x.map(C=>g.jsx(pGt,{turn:IVt(y,C.turnNumber)??C,messages:uGt(d,C),AgentSessionTurnHeader:a,onMount:A=>{A==null?b.current.delete(C.turnNumber-1):b.current.set(C.turnNumber-1,A)}},C.turnId))})})]})}function pGt({turn:e,messages:t,AgentSessionTurnHeader:n,onMount:r}){return!e.showHeader&&t.length===0?null:g.jsxs("section",{ref:r,id:`session-turn-${e.turnNumber}`,className:"flex flex-col gap-2",children:[e.showHeader?g.jsx(n,{turnNumber:e.turnNumber,totalTokens:e.totalTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cachedTokens:e.cachedTokens,durationMs:e.durationMs,totalCostInUsd:e.totalCostInUsd}):null,t.length>0?g.jsx(KVt,{slotOverrides:oGt,messages:t,children:g.jsx(_re.Root,{asChild:!0,children:g.jsx("div",{className:"aui-root aui-thread-root flex w-full flex-col",children:g.jsx(_re.Messages,{children:({message:o})=>o.role==="user"?g.jsx(QVt,{}):g.jsx(WVt,{})})})})}):null]})}var fGt=w.lazy(()=>Sa(()=>import("./AgentOverview-OBBGSUOK-D0-uAThW.js"),[],import.meta.url)),hGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentSessions-OB32CD3H-BvEB36Q4.js"),__vite__mapDeps([2,3]),import.meta.url)).AgentSessions})),gGt=w.lazy(()=>Sa(()=>import("./AgentCodeSnippets-GX5MTZLF-D1o4DvyC.js"),[],import.meta.url)),mGt=w.lazy(async()=>({default:(await Sa(()=>import("./SchedulesPage-HLHAOIS6-BcDOMjiM.js"),__vite__mapDeps([4,5]),import.meta.url)).SchedulesPage})),bGt=w.lazy(async()=>({default:(await Sa(()=>import("./EnvironmentsPage-OXKHJMOO-C-t7Dp_i.js"),__vite__mapDeps([6,5]),import.meta.url)).EnvironmentsPage})),vGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentSessionEventTimeline-ZBW3AIU2-BjA4oeYw.js"),[],import.meta.url)).AgentSessionEventTimeline})),yGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentSessionEventTimelineChart-VQNS2G4D-o3La8fse.js"),__vite__mapDeps([7,8]),import.meta.url)).AgentSessionEventTimelineChart})),xGt=w.lazy(async()=>({default:(await Sa(()=>import("./AgentMetricChart-MMZYPKVN-8E4ELOjM.js"),__vite__mapDeps([9,8]),import.meta.url)).AgentMetricChart})),FOe={Accordion:qNe,AccordionSummary:QNe,AccordionDetails:JNe,BrandLogo:mZ,ComposerShell:nUt,ComposerLeftSection:JFt,ComposerRightSection:eUt,ComposerSendButton:tUt,PermissionGuard:GBt,DraftComposerLeftSection:cBt,DraftComposerRightSection:uBt,DraftAgentConfigTrigger:aBt,DraftCapabilitiesPanel:iBt,DraftComposerActionsMenu:sBt,AgentCustomParametersEditor:PUt,AgentConfigEditors:fUt,AgentInstructionsDrawer:LUt,AgentModelEditorContent:WUt,AgentModelSettingsContent:ZUt,AgentMcpEditorContent:VUt,AgentModelConfigModal:GUt,AgentResourceEditorContent:qUt,AgentResourceConfigModal:XUt,AgentSkillsEditorContent:oBt,AgentConfigPanel:IUt,AgentConfigSection:RUt,AgentRuntimeConfigFields:nBt,AgentRuntimeConfigDrawer:QUt,AgentRuntimeEditorContent:rBt,DraftCompositeSelector:gBt,CatalogRow:qm,ConnectorConnectButton:g$,DraftModelSelector:mBt,AssistantMessageBubble:wMe,UserMessageBubble:iVt,UserMessageEdit:sVt,UserMessageActionBar:aVt,MessageActionBar:rOe,MessageCancelledBanner:OBt,MessageErrorBanner:jBt,MessageIndicator:PBt,MessageTimestamp:zBt,Markdown:nOe,SyntaxHighlighter:AHt,OpenUiFenceBlock:IIe,SandboxArtifactDownload:KBt,ChatFileDownload:WFt,FilePreviewPanel:_Bt,MonacoEditorCore:HBt,CodeEditor:QFt,WelcomeScreen:COe,ToolCallCard:AOe,ToolCallContentBlock:rVt,ToolApprovalBar:yOe,ToolGroupCard:oVt,SubAgentCard:wHt,SandboxToolCallCard:ZBt,AgentStepsCard:_$t,ReasoningCard:O$t,AskUserPrompt:I$t,McpAuthPrompt:M$t,ResumeUnavailable:j$t,AttachmentCard:wFt,AttachmentPreviewDialog:SFt,AttachmentPickerButton:_Ft,ScrollToBottomButton:lOe,ThreadListRow:OHt,ThreadListNewButton:CHt,AgentsLibrary:gFt,AgentLibraryRow:pFt,AgentsLibraryButton:mFt,ApprovalNavBanner:bFt,SessionsBrowserButton:iHt,AgentDetailsPage:q$t,AgentDetailsHeader:K$t,AgentDetailsTabs:J$t,AgentDetailsUnavailable:e7t,AgentOverview:fGt,AgentOverviewCard:f7t,AgentMetrics:lVt,AgentMetricsView:p7t,AgentMetricsTimeRangeFilter:i7t,AgentMetricCard:a7t,AgentMetricStatistics:d7t,AgentMetricChart:xGt,AgentSessionDetailHeader:h7t,AgentSessionsFilters:j7t,SessionsPage:L7t,AgentSessionEventTimeline:vGt,AgentSessionEventTimelineChart:yGt,AgentSessionListRow:b7t,AgentSessionMetricsStrip:k7t,AgentSessionTimelineContainer:dGt,AgentSessionTurnHeader:D7t,AgentSessions:hGt,AgentCodeSnippets:gGt,AgentCodeBlock:P$t,SchedulesPage:mGt,SchedulesButton:oHt,EnvironmentsPage:bGt,EnvironmentsButton:bBt,SaveAgentButton:tHt,SaveAgentForm:rHt,SelectAgentEmptyState:aHt,ClearChatButton:qFt,ShareChatButton:sHt,ShareSessionDialog:vHt,ThreadListRowSkeleton:RHt,ThreadListEmptyState:IHt,ThreadListShell:NHt,HistoryLoader:YMe,MessageListSkeleton:xHt,ThreadRootShell:gOe,ThreadViewportShell:mOe,ThreadComposerAreaShell:bOe,MessageGroup:vOe,Toast:DHt,ToastStack:zHt,ShellActionsActionSlot:yHt,UserAvatar:Q7t},gN=w.createContext(FOe),BZ=w.createContext(void 0);function hw({overrides:e,theme:t,children:n}){const r=w.useContext(gN),o=w.useContext(BZ),a=w.useMemo(()=>({...r,...e}),[r,e]),i=g.jsx(wGt,{slots:a,inheritedTheme:o,theme:t,children:n});return t!==void 0||!(o!==void 0)?g.jsx(Gm,{theme:t,children:i}):i}function wGt({slots:e,children:t,inheritedTheme:n,theme:r}){const o=iye(),i=((r==null?void 0:r.mode)==="light"||(r==null?void 0:r.mode)==="dark"?r.mode:void 0)??n??o;return g.jsx(BZ.Provider,{value:i,children:g.jsx(gN.Provider,{value:e,children:t})})}function We(e){return w.useContext(gN)[e]}function _rn(e){return w.useContext(gN)[e]===FOe[e]}function mN(){return w.useContext(BZ)??"light"}var UOe=w.createContext(null),x$=new Set;function _Gt(){for(const e of x$)e()}function SGt(){const e=Y7(),[t,n]=w.useState(!1);w.useEffect(()=>{e||n(!1)},[e]),w.useEffect(()=>{const i=()=>{n(!1)};return x$.add(i),()=>{x$.delete(i)}},[]);const r=e||t,o=w.useCallback(()=>{n(!1)},[]),a=w.useCallback(i=>{n(!0);try{const s=i();s!=null&&typeof s.then=="function"&&s.catch(()=>{n(!1)})}catch{n(!1)}},[]);return{isBusy:r,isRunning:e,isSubmitting:t,send:a,resetBusy:o}}function Srn({children:e}){const t=SGt();return w.createElement(UOe.Provider,{value:t},e)}function krn(){const e=w.useContext(UOe);if(e==null)throw new Error("useComposerBusyState must be used within ComposerBusyProvider");return e}var BOe=w.createContext(void 0);function kGt({renderers:e,children:t}){return g.jsx(BOe.Provider,{value:e,children:t})}function Ern(){return w.useContext(BOe)}var HOe=w.createContext(null);function EGt({children:e}){const[t,n]=w.useState(!1),r=w.useMemo(()=>({open:t,setOpen:n}),[t]);return g.jsx(HOe.Provider,{value:r,children:e})}function Trn(){const e=w.useContext(HOe);if(e===null)throw new Error("useWidgetVisibility must be used within WidgetVisibilityProvider");return e}var VOe="is_create_agent";function TGt(e){return e?"true":"false"}function HZ(e){return e==null?!1:Reflect.get(e,VOe)==="true"}function AGt(e){if("isCreateAgent"in e&&Reflect.get(e,"isCreateAgent")===!0)return!0;if(!("metadata"in e))return!1;const t=Reflect.get(e,"metadata");if(typeof t!="object"||t===null)return!1;const n={};for(const r of Object.keys(t)){const o=Reflect.get(t,r);typeof o=="string"&&(n[r]=o)}return HZ(n)}function CGt({locallyCreatedSessionIds:e,children:t}){const n=Ve(r=>r.threadListItem.remoteId);return g.jsx(z$t,{sessionId:n,assumeManage:n!=null&&e.has(n),children:t})}function RGt({server:e,locallyCreatedSessionIds:t}){return{...e,async createSession(n){const r=await e.createSession(n);return t.add(r.id),r},async listSessions(n){const r=await e.listSessions(n);return{...r,data:r.data.filter(o=>!AGt(o))}}}}function IGt({server:e,agent:t,agentName:n,listSessionsAgentId:r,initialSessionId:o,adapters:a,onError:i,children:s}){const{showError:l}=B$t(),c=i??l,p=w.useMemo(()=>({server:e,ids:new Set}),[e]).ids,f=w.useMemo(()=>RGt({server:e,locallyCreatedSessionIds:p}),[p,e]),m=w.useCallback(y=>{_Gt(),c(y)},[c]),b=hzt({server:f,agent:t,agentName:n,listSessionsAgentId:r,listSessionsCreatedByMe:!0,initialSessionId:o,onError:m,adapters:{...a,attachments:(a==null?void 0:a.attachments)??UDt}});return g.jsx(Txe,{runtime:b,children:g.jsx(CGt,{locallyCreatedSessionIds:p,children:s})})}function NGt(e){const{server:t,initialSessionId:n,adapters:r,onError:o,children:a,agent:i,agentName:s,listSessionsAgentId:l}=e,c=w.useMemo(()=>t,[t]);return g.jsx(rMe,{children:g.jsx(IGt,{server:c,agent:i,agentName:s,listSessionsAgentId:l,initialSessionId:n,adapters:r,onError:o,children:a})})}function MGt(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 Eme(e,t){if(e===void 0)return;const n=e.filter(r=>{const o=c$(r);return o!==null&&t.has(o)});return n.length===e.length?e:n}function OGt({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=jv(l.name,e.model.params,l.properties.reasoningEfforts))}const s=Eme(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=Eme(e.skills,new Set(n.map(c=>c.name)));l!==e.skills&&(a.skills=l)}return a}function jGt({agentSpec:e,sandboxEnabled:t,kind:n="agent"}){var o,a;if(n==="chat"){if(t==null)return{};const i=MGt(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=GL(e,t);return r===e?{}:{config:r.config}}function PGt({agentSpec:e,webSearchEnabled:t,previousWebSearchEnabled:n,explicitOff:r=!1,kind:o="agent"}){const a=bye({spec:e,previousWebSearchEnabled:n,webSearchEnabled:t,explicitOff:r,kind:o}),i=DT({spec:a,webSearchEnabled:t});return i===e?{}:{config:i.config}}function DGt(){var T;const{mode:e,pendingSessionId:t,rememberDraftSpec:n}=ng(),{agentSpec:r,isSpecLoading:o}=Eg(),a=V1(),i=v7(),s=i==null?void 0:i.sandbox.enabled,l=(T=i==null?void 0:i.webSearch)==null?void 0:T.enabled,c=w.useRef(l),{models:d,skills:p,connectors:f,loaded:m,error:b,ensureLoaded:y}=PC(),x=e.status==="active"&&e.isMutable&&t==null,_=x&&e.agentId==null,k=!o,E=e.status==="active"&&e.isMutable&&e.isCreateAgent?"agent":"chat";return w.useEffect(()=>{_&&y()},[y,_]),w.useEffect(()=>{_&&k&&r!=null&&n(r,E)},[r,k,_,E,n]),w.useEffect(()=>{if(!_||!k||r==null||a==null)return;const C=jGt({agentSpec:r,sandboxEnabled:s,kind:E});Object.keys(C).length>0&&a(C)},[r,k,_,E,s,a]),w.useEffect(()=>{const C=c.current;if(c.current=l,!x||!k||r==null||a==null)return;const A=PGt({agentSpec:r,webSearchEnabled:l,previousWebSearchEnabled:_?C:void 0,explicitOff:_&&vye(E)===!1,kind:E});Object.keys(A).length>0&&a(A)},[r,k,x,_,E,l,a]),w.useEffect(()=>{if(!_||!k||r==null||a==null||!m||b!=null)return;const C=OGt({agentSpec:r,models:d,skills:p,connectors:f,skillsEnabled:i==null?void 0:i.skill.enabled});Object.keys(C).length>0&&a(C)},[r,k,i==null?void 0:i.skill.enabled,f,b,_,m,d,p,a]),null}function LGt(){const e=vo(),t=tn(),n=e==null?void 0:e.pendingSessionId,r=(e==null?void 0:e.pendingSessionEpoch)??0;return w.useEffect(()=>{n!=null&&Promise.resolve(t.threads().switchToThread(n)).catch(()=>{})},[t,n,r]),null}function zGt(){const{openLibraryAgent:e,openSharedSession:t,setSessionsOpen:n}=ng(),r=Vv(),o=r1({sessions:r});return w.useEffect(()=>{if(!o)return;const a=Mu(window.location.search);if(a.view===jC&&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 $Gt({onRemoteIdChange:e}){const t=Ve(n=>n.threadListItem.remoteId);return w.useEffect(()=>{e(t??void 0)},[t,e]),null}var FGt=3e4;function UGt(){return new Map}function BGt(e){const t={...e};return delete t.startTimestamp,JSON.stringify(t,Object.keys(t).sort())}function HGt({server:e,cache:t}){const{deleteSession:n,renameSession:r}=e;return{...e,listSessions(o){const a=BGt(o),i=Date.now(),s=t.get(a);if(s!==void 0&&i-s.at<FGt)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 VGt={data:{sandbox:{enabled:!0},skill:{enabled:!0},settings:{enabled:!0},webSearch:{enabled:!1}}};function Tme(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="trueforge"}function GGt(e){return typeof Reflect.get(e,"getCapabilities")=="function"}function WGt(e,t,n){const r=GGt(e)?()=>e.getCapabilities():async()=>VGt,a={...{...e,getCapabilities:r}};if(!KGt(a))throw new Error("TrueForgeUI: runtime adapter returned an incomplete AgentUIServer");return a}function KGt(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 YGt(e,t){const n=Tme(e)?e:null,r=Tme(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,d]=w.useState(()=>r?{status:"ready",server:r,error:null}:{status:"loading",server:null,error:null});return w.useEffect(()=>{if(r){d({status:"ready",server:r,error:null});return}let p=!1;return d({status:"loading",server:null,error:null}),(async()=>{const{createTrueForgeAgentUIServer:m}=await Sa(async()=>{const{createTrueForgeAgentUIServer:b}=await Promise.resolve().then(()=>EQt);return{createTrueForgeAgentUIServer:b}},void 0,import.meta.url);return m({...o?{baseUrl:o}:{},...a?{token:a}:{},...i!==void 0?{fetch:i}:{},...s!=null?{catalog:s}:{},...l!=null?{permissions:l}:{}})})().then(m=>{if(!p)try{d({status:"ready",server:WGt(m,void 0,void 0),error:null})}catch(b){t==null||t(b),d({status:"error",server:null,error:b})}}).catch(m=>{p||(t==null||t(m),d({status:"error",server:null,error:m}))}),()=>{p=!0}},[r,o,a,i,s,l,t]),c}var ZGt=w.lazy(()=>Sa(()=>import("./SidebarLayout-LHIKWYLB-DgTk6yLL.js"),__vite__mapDeps([10,11]),import.meta.url).then(e=>({default:e.SidebarLayout}))),XGt=w.lazy(()=>Sa(()=>import("./DrawerLayout-T6U5AGG7-BQoBVjqu.js"),__vite__mapDeps([12,11]),import.meta.url).then(e=>({default:e.DrawerLayout}))),qGt=w.lazy(()=>Sa(()=>import("./DockLayout-YSSOMIEK-S7QeeWVV.js"),__vite__mapDeps([13,14,11]),import.meta.url).then(e=>({default:e.DockLayout}))),QGt=w.lazy(()=>Sa(()=>import("./WidgetLayout-Q3F3UWN3-BQaDzdhk.js"),__vite__mapDeps([15,14,11]),import.meta.url).then(e=>({default:e.WidgetLayout}))),JGt=w.lazy(()=>Sa(()=>import("./ShellRouteSync-XIPKA3OH-ByKCgD91.js"),__vite__mapDeps([16,3,17]),import.meta.url).then(e=>({default:e.ShellRouteSync})));function eWt({className:e}){return g.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 GOe({className:e}){const t=mN();return g.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:g.jsx(gZ,{state:"connecting",speed:1,theme:t,paused:!1,"aria-hidden":!0,size:64,style:{width:"4.5rem",height:"4.5rem"}})})}function tWt({error:e,className:t}){const n=aa(e,"Failed to initialize server");return g.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 nWt(e){return e==="sidebar"||e==="drawer"||e==="dock"||e==="widget"}function rWt({layout:e,className:t}){switch(e){case"sidebar":return g.jsx(ZGt,{className:t});case"drawer":return g.jsx(XGt,{className:t});case"dock":return g.jsx(qGt,{className:t});case"widget":return g.jsx(QGt,{className:t})}}function oWt({layout:e,className:t}){if(nWt(e))return g.jsx(w.Suspense,{fallback:g.jsx(eWt,{className:t}),children:g.jsx(rWt,{layout:e,className:t})});const n=e;return g.jsx(n,{className:t})}function aWt({children:e,initialSessionId:t,onRemoteIdChange:n,server:r,...o}){const{mode:a,runtimeKey:i,historyAgentFilter:s,listSessionsAgentId:l,pendingSessionId:c}=ng(),d=a.status==="active"&&a.isMutable&&a.isCreateAgent,[p]=w.useState(UGt),f=w.useMemo(()=>({...r,createSession:_=>{if(_.agentSpec===void 0)return r.createSession(_);const k={..._,metadata:{[VOe]:TGt(d)}};return r.createSession(k)}}),[r,d]),m=w.useMemo(()=>HGt({server:f,cache:p}),[f,p]),b=w.useMemo(()=>s==null||s.agentId!=null?m:{...m,listSessions:async()=>({data:[]})},[m,s]),y=w.useMemo(()=>a.status==="active"&&a.isMutable?a.agentSpec??{model:{name:"openai-main/gpt-4.1"}}:{model:{name:"openai-main/gpt-4.1"}},[i]),x=w.useMemo(()=>{if(a.status==="idle")return{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}};if(!a.isMutable){const _=a.agentName??a.agentId??c;return _==null?{mode:"draft",defaultAgentSpec:{model:{name:"openai-main/gpt-4.1"}}}:{mode:"named",agentName:_}}return{mode:"draft",defaultAgentSpec:y}},[a,y,c]);return g.jsx(a7e,{children:g.jsx(NGt,{...o,server:b,agent:x,listSessionsAgentId:l,initialSessionId:c??t,children:g.jsxs(QBt,{children:[g.jsx(DGt,{}),g.jsx(LGt,{}),n!=null?g.jsx($Gt,{onRemoteIdChange:n}):null,e]})},i)})}function iWt(e){const{layout:t="sidebar",overrides:n,theme:r,className:o,agentConfig:a=yye,initialSettingsOpen:i=!1,server:s,onError:l,analytics:c,customActionRenderers:d,currentUser:p,resolvedRoutes:f,routes:m,...b}=e,y=YGt(s,l),[x,_]=w.useState(void 0),k=w.useCallback(R=>_(R),[]);if(w.useEffect(()=>{oOe()},[]),y.status==="loading")return g.jsx(hw,{overrides:n,theme:r,children:g.jsx(GOe,{className:o})});if(y.status==="error")return g.jsx(hw,{overrides:n,theme:r,children:g.jsx(tWt,{error:y.error,className:o})});const E=y.server,T=g.jsx(oWt,{layout:t,className:o}),C=g.jsx(e7e,{track:c==null?void 0:c.track,children:g.jsx(rMe,{children:g.jsxs(K$e,{agentConfig:a,initialSettingsOpen:i,children:[g.jsx(zGt,{}),f!=null?g.jsx(w.Suspense,{fallback:null,children:g.jsx(JGt,{routes:f,activeRemoteId:x,initialSettingsOpen:i,onError:l})}):null,g.jsx(aWt,{server:E,onError:l,onRemoteIdChange:f!=null?k:void 0,...b,children:T})]})})}),A=t==="widget"?g.jsx(EGt,{children:C}):C;return g.jsx(hw,{overrides:n,theme:r,children:g.jsx(Y7t,{currentUser:p,children:g.jsx(kGt,{renderers:d,children:g.jsx(R$e,{server:E,children:f!=null?g.jsx(fHt,{routes:f,children:A}):A})})})})}function sWt(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.getMe!=null?{getMe:e.getMe}:{}}}var lWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),B6=lWt,cWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsxs("g",{opacity:.9,children:[g.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"}),g.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"}),g.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"}),g.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"}),g.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"})]})}),uWt=cWt,dWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),pWt=dWt,fWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),hWt=fWt,gWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 22 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.4824 12.432L21.0265 6.20004L10.5441 0L0 6.20004L10.4824 12.432Z",fill:"#ECF2F9"}),g.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"}),g.jsx("path",{d:"M10.5 11.7499V0.749939L19.75 6.24994L10.5 11.7499Z",fill:"url(#paint0_linear_10651_178757)"}),g.jsx("path",{d:"M10.5 11.7499V0.749939L1.25 6.24994L10.5 11.7499Z",fill:"#0E1623"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 6.20001V18.686L10.5441 25V12.4319L0 6.20001Z",fill:"#CEE0F8"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.0265 6.20001V18.686L10.4824 25V12.4319L21.0265 6.20001Z",fill:"#82A0CE"}),g.jsx("path",{d:"M10.4973 11.7478L4.64099 8.26706V8.95172L10.4973 12.4126L15.8148 9.27748V8.59062L10.4973 11.7478Z",fill:"#ECF2F9"}),g.jsx("defs",{children:g.jsxs("linearGradient",{id:"paint0_linear_10651_178757",x1:15.0834,y1:2.10412,x2:15.125,y2:11.7499,gradientUnits:"userSpaceOnUse",children:[g.jsx("stop",{stopColor:"#5E7BAA"}),g.jsx("stop",{offset:1,stopColor:"#030407"})]})})]}),mWt=gWt,bWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_5446_3655)",children:[g.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"}),g.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"})]}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_5446_3655",children:g.jsx("rect",{width:14,height:14,fill:"white"})})})]}),vWt=bWt,yWt=e=>g.jsx("svg",{width:"1em",height:"1em",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:g.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"})}),xWt=yWt,wWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_10581_4008)",children:[g.jsx("path",{d:"M-0.000793457 0.015625L39.9992 20.0156V40L19.9992 40V80.0156H39.9992V100.016L-0.000793457 120.016V0.015625Z",fill:"white"}),g.jsx("path",{d:"M119.999 0L79.9992 20V40H99.9992V80H79.9992V100L119.999 120V0Z",fill:"white"}),g.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"})]}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_10581_4008",children:g.jsx("rect",{width:120,height:120,fill:"white"})})})]}),_Wt=wWt,SWt=e=>g.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 140 140",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsxs("g",{clipPath:"url(#clip0_10581_1729)",children:[g.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"}),g.jsx("path",{d:"M139.999 0L93.3324 23.3333V46.6667H116.666V93.3333H93.3324V116.667L139.999 140V0Z",fill:"#05090E"}),g.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"})]}),g.jsx("defs",{children:g.jsx("clipPath",{id:"clip0_10581_1729",children:g.jsx("rect",{width:140,height:140,fill:"white"})})})]}),kWt=SWt;y$e({"mcp-server":vWt,"agent-2":B6,bot:B6,robot:B6,compare:hWt,ai:uWt,searchGlobe:xWt,"brain-regular":pWt,empty:mWt,"trueforge-logomark-light":kWt,"trueforge-logomark-dark":_Wt});var EWt=1e3,TWt=5e3;function AWt(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 CWt=()=>{const[e,t]=w.useState();w.useEffect(()=>{const a=new URLSearchParams(window.location.search),i=a.get("pUid"),s=AWt(a);t(i?{popupUid:i,isSuccess:s}:null);const l=()=>{if(!i)return;const p=new BroadcastChannel(UMe),f={popupUid:i,isSuccess:s};p.postMessage(f),p.close()};l();const c=window.setTimeout(l,EWt),d=window.setTimeout(()=>{window.close()},TWt);return()=>{window.clearTimeout(c),window.clearTimeout(d)}},[]);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 g.jsx("main",{className:"flex min-h-screen items-center justify-center bg-primary-bg p-6",children:g.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?g.jsx(xe,{name:"oauth-loading",className:"size-16 animate-spin text-text-secondary"}):n?g.jsx(xe,{name:"oauth-success",className:"size-16 text-success-bg"}):g.jsx(xe,{name:"oauth-error",className:"size-16 text-failure-bg"}),g.jsx("h1",{className:"text-2xl font-semibold text-text-primary",children:r}),g.jsx("p",{className:"text-sm leading-6 text-text-secondary",children:o})]})})},RWt=CWt,IWt=w.lazy(()=>Sa(()=>import("./TrueForgeUIWithRouter-SZT3KVCD-BMJaD7KT.js"),__vite__mapDeps([18,17]),import.meta.url).then(e=>({default:e.TrueForgeUIWithRouter})));function NWt(e){if(typeof window<"u"&&new URLSearchParams(window.location.search).get("screenType")==="mcp-auth")return g.jsx(hw,{overrides:e.overrides,theme:e.theme,children:g.jsx(RWt,{})});const{withRouter:n,...r}=e;return n?g.jsx(w.Suspense,{fallback:g.jsx(GOe,{className:e.className}),children:g.jsx(IWt,{...r})}):g.jsx(iWt,{...r})}const aC=(e,t,n)=>JSON.stringify(e,t,n);function vh(e,t){return JSON.parse(e,t)}class at extends Error{constructor({message:t,statusCode:n,body:r,rawResponse:o,cause:a}){super(MWt({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 t,n;return((n=(t=this.rawResponse)==null?void 0:t.headers)==null?void 0:n.get("x-request-id"))??void 0}}function MWt({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: ${aC(n,void 0,2)}`),r.join(`
|
|
993
993
|
`)}class OWt extends at{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 wT extends at{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 Ln extends at{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 ii extends at{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 H6 extends at{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 at{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 oo extends at{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 jWt extends at{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 PWt extends at{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 Sn extends at{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 fx extends at{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 Jn extends at{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 wa extends at{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 DWt={Openai:"openai",Anthropic:"anthropic",GoogleGemini:"google-gemini",Fireworks:"fireworks",Zai:"zai",Moonshot:"moonshot",Alibaba:"alibaba",Together:"together"};function LWt(e){return typeof e=="object"&&e!==null&&"getAuthRequest"in e&&typeof e.getAuthRequest=="function"}class WOe{getAuthRequest(){return Promise.resolve({headers:{}})}}const KOe={get:async(e,t)=>typeof e=="function"?e(t):e},_c={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Ame={[_c.Debug]:1,[_c.Info]:2,[_c.Warn]:3,[_c.Error]:4};class YOe{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 w${constructor(t){this.level=Ame[t.level],this.logger=t.logger,this.silent=t.silent}shouldLog(t){return!this.silent&&this.level<=Ame[t]}isDebug(){return this.shouldLog(_c.Debug)}debug(t,...n){this.isDebug()&&this.logger.debug(t,...n)}isInfo(){return this.shouldLog(_c.Info)}info(t,...n){this.isInfo()&&this.logger.info(t,...n)}isWarn(){return this.shouldLog(_c.Warn)}warn(t,...n){this.isWarn()&&this.logger.warn(t,...n)}isError(){return this.shouldLog(_c.Error)}error(t,...n){this.isError()&&this.logger.error(t,...n)}}function VZ(e){return e==null?zWt:e instanceof w$?e:(e=e??{},e.level??(e.level=_c.Info),e.logger??(e.logger=new YOe),e.silent??(e.silent=!0),new w$(e))}const zWt=new w$({level:_c.Info,logger:new YOe,silent:!0}),$Wt={arrayFormat:"indices",encode:!0};function V6(e,t){if(e===void 0||e===null)return"";const n=String(e);return t?encodeURIComponent(n):n}function _$(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(d=>d!=null).map(d=>V6(d,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 d=s==="indices"?`${i}[${l}]`:i;r.push(..._$(c,d,n))}else{const d=s==="indices"?`${i}[${l}]`:i,p=n.encode?encodeURIComponent(d):d;r.push(`${p}=${V6(c,n.encode)}`)}}}else if(typeof a=="object"&&a!==null){if(Object.keys(a).length===0)continue;r.push(..._$(a,i,n))}else{const s=n.encode?encodeURIComponent(i):i;r.push(`${s}=${V6(a,n.encode)}`)}}return r}function iC(e,t){return e==null||typeof e!="object"?"":_$(e,"",{...$Wt,...t}).join("&")}function FWt(e,t){const n=iC(t,{arrayFormat:"repeat"});return n?`${e}?${n}`:e}function UWt(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 Cme(e,t){Object.defineProperty(e,"__fern_response_ref",{value:t,enumerable:!1,configurable:!0,writable:!1})}async function ZOe(e,t){switch(t){case"binary-response":return UWt(e);case"blob":return await e.blob();case"arrayBuffer":return await e.arrayBuffer();case"sse":return e.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:e.status}}:(Cme(e.body,e),e.body);case"streaming":return e.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:e.status}}:(Cme(e.body,e),e.body);case"text":return await e.text()}const n=await e.text();if(n.length>0)try{return vh(n)}catch{return{ok:!1,error:{reason:"non-json",statusCode:e.status,rawBody:n}}}}async function BWt(e){var n,r;let t=(n=e.headers.get("Content-Type"))==null?void 0:n.toLowerCase();if(t==null||t.length===0)return ZOe(e);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":{const o=await e.text();return o.length>0?vh(o):void 0}default:if(t.startsWith("application/vnd.")&&t.endsWith("+json")){const o=await e.text();return o.length>0?vh(o):void 0}return await e.text()}}async function XOe(){return fetch}async function HWt({body:e,type:t}){return t==="form"?iC(e,{arrayFormat:"repeat",encode:!0}):t.includes("json")?aC(e):e}let Pv;typeof globalThis.Headers<"u"?Pv=globalThis.Headers:Pv=class qOe{constructor(t){if(this.headers=new Map,t)if(t instanceof qOe)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 VWt="timeout";function GWt(e){const t=new AbortController,n=setTimeout(()=>t.abort(VWt),e);return{signal:t.signal,abortId:n}}function WWt(...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 hx;function KWt(){if(hx!=null)return hx;try{new Request("http://localhost",{cache:"no-store"}),hx=!0}catch{hx=!1}return hx}const QOe=async(e,t,n,r,o,a,i,s,l,c)=>{const d=[];let p;if(a!=null){const{signal:b,abortId:y}=GWt(a);p=y,d.push(b)}i!=null&&d.push(i);const f=WWt(d),m=await e(t,{method:n,headers:r,body:o,signal:f,credentials:s?"include":void 0,duplex:l,...c&&KWt()?{cache:"no-store"}:{}});return p!=null&&clearTimeout(p),m},Rme={headers:new Pv,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},Ime={headers:new Pv,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function Nme(e){return{headers:e.headers,redirected:e.redirected,status:e.status,statusText:e.statusText,type:e.type,url:e.url}}const S$=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 Tu(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 d=c.toLowerCase();if(!(d.includes("token")||d.includes("key")||d.includes("password")||d.includes("passwd")||d.includes("secret")||d.includes("session")||d.includes("auth")))return e;const f=[],m=c.split("&");for(const b of m){const y=b.indexOf("=");if(y===-1){f.push(b);continue}const x=b.slice(0,y);let _=S$.has(x.toLowerCase());if(!_&&x.includes("%"))try{const k=decodeURIComponent(x);_=S$.has(k.toLowerCase())}catch{}f.push(_?`${x}=[REDACTED]`:b)}return e.slice(0,o+1)+f.join("&")+e.slice(l)}const YWt=1e3,OE=6e4,ZWt=2,JOe=.2;function XWt(e){return[408,429].includes(e)||e>=500}function qWt(e){const t=1+Math.random()*JOe;return e*t}function QWt(e){const t=1+(Math.random()-.5)*JOe;return e*t}function JWt(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,OE);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),OE)}}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 qWt(Math.min(a,OE))}}return QWt(Math.min(YWt*2**t,OE))}async function e3e(e,t=ZWt){let n=await e();for(let r=0;r<t&&XWt(n.status);++r){const o=JWt(n,r);await new Promise(a=>setTimeout(a,o)),n=await e()}return n}const eKt=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 G6(e){const t={};for(const[n,r]of e instanceof Pv?e.entries():Object.entries(e))eKt.has(n.toLowerCase())?t[n]="[REDACTED]":t[n]=r;return t}function tKt(e){if(e==null)return;const t={};for(const[n,r]of Object.entries(e))t[n]=S$.has(n.toLowerCase())?"[REDACTED]":r;return t}async function nKt(e){const t=new Pv;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 KOe.get(r,{endpointMetadata:e.endpointMetadata??{}});if(typeof o=="string"){t.set(n,o);continue}o!=null&&t.set(n,`${o}`)}return t}async function rKt(e){var i;let t=e.url;e.queryString!=null&&e.queryString.length>0?t=`${t}?${e.queryString}`:t=FWt(e.url,e.queryParameters);const n=await HWt({body:e.body,type:e.requestType??"other"}),r=e.fetchFn??await XOe(),o=await nKt(e),a=VZ(e.logging);if(a.isDebug()){const s={method:e.method,url:Tu(t),headers:G6(o),queryParameters:tKt(e.queryParameters),hasBody:n!=null};a.debug("Making HTTP request",s)}try{const s=await e3e(async()=>QOe(r,t,e.method,o,n,e.timeoutMs,e.abortSignal,e.withCredentials,e.duplex,e.responseType==="streaming"||e.responseType==="sse"),e.maxRetries);if(s.status>=200&&s.status<400){if(a.isDebug()){const c={method:e.method,url:Tu(t),statusCode:s.status,responseHeaders:G6(s.headers)};a.debug("HTTP request succeeded",c)}return{ok:!0,body:await ZOe(s,e.responseType),headers:s.headers,rawResponse:Nme(s)}}else{if(a.isError()){const l={method:e.method,url:Tu(t),statusCode:s.status,responseHeaders:G6(Object.fromEntries(s.headers.entries()))};a.error("HTTP request failed with error status",l)}return{ok:!1,error:{reason:"status-code",statusCode:s.status,body:await BWt(s)},rawResponse:Nme(s)}}}catch(s){if((i=e.abortSignal)!=null&&i.aborted){if(a.isError()){const l={method:e.method,url:Tu(t)};a.error("HTTP request was aborted",l)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:s},rawResponse:Rme}}else if(s instanceof Error&&s.name==="AbortError"){if(a.isError()){const l={method:e.method,url:Tu(t),timeoutMs:e.timeoutMs};a.error("HTTP request timed out",l)}return{ok:!1,error:{reason:"timeout",cause:s},rawResponse:Rme}}else if(s instanceof Error){if(a.isError()){const l={method:e.method,url:Tu(t),errorMessage:s.message};a.error("HTTP request failed with error",l)}return{ok:!1,error:{reason:"unknown",errorMessage:s.message,cause:s},rawResponse:Ime}}if(a.isError()){const l={method:e.method,url:Tu(t),error:aC(s)};a.error("HTTP request failed with unknown error",l)}return{ok:!1,error:{reason:"unknown",errorMessage:aC(s),cause:s},rawResponse:Ime}}}const ft=rKt;class dt extends Promise{constructor(t){super(n=>{n(void 0)}),this.innerPromise=t}static fromFunction(t,...n){return new dt(t(...n))}static interceptFunction(t){return(...n)=>dt.fromPromise(t(...n))}static fromPromise(t){return new dt(t)}static fromExecutor(t){const n=new Promise(t);return new dt(n)}static fromResult(t){const n=Promise.resolve(t);return new dt(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 pt(e,...t){if(!e)return"";if(t.length===0)return e;if(e.includes("://")){let n;try{n=new URL(e)}catch{return Mme(e,...t)}const r=t[t.length-1],o=r==null?void 0:r.endsWith("/");for(const a of t){const i=n3e(a);i&&(n.pathname=t3e(n.pathname,i))}return o&&!n.pathname.endsWith("/")&&(n.pathname+="/"),n.toString()}return Mme(e,...t)}function Mme(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=n3e(a);i&&(n=t3e(n,i))}return o&&!n.endsWith("/")&&(n+="/"),n}function t3e(e,t){return e.endsWith("/")?e+t:`${e}/${t}`}function n3e(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 Ne={get:async e=>typeof e=="function"?e():e};async function oKt(e,t,n,r){const o=VZ(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 Ne.get(n.baseUrl):void 0)??(n.environment!=null?await Ne.get(n.environment):void 0);let l;a.startsWith("http://")||a.startsWith("https://")?l=a:s!=null?l=pt(s,a):l=a;const c={};if(n.headers!=null)for(const[k,E]of Object.entries(n.headers)){const T=await KOe.get(E,{endpointMetadata:{}});T!=null&&(c[k.toLowerCase()]=`${T}`)}if(n.getAuthHeaders!=null&&aKt(l,s)){const k=await n.getAuthHeaders();for(const[E,T]of Object.entries(k))c[E.toLowerCase()]=T}if((i==null?void 0:i.headers)!=null){const k=i.headers instanceof Headers?Object.fromEntries(i.headers.entries()):Array.isArray(i.headers)?Object.fromEntries(i.headers):i.headers;for(const[E,T]of Object.entries(k))T!=null&&(c[E.toLowerCase()]=T)}if((r==null?void 0:r.headers)!=null)for(const[k,E]of Object.entries(r.headers))c[k.toLowerCase()]=E;const d=(i==null?void 0:i.method)??"GET",p=i==null?void 0:i.body,f=(r==null?void 0:r.timeoutInSeconds)??n.timeoutInSeconds,m=f!=null?f*1e3:void 0,b=(r==null?void 0:r.maxRetries)??n.maxRetries,y=(r==null?void 0:r.abortSignal)??(i==null?void 0:i.signal)??void 0,x=n.fetch??await XOe();o.isDebug()&&o.debug("Making passthrough HTTP request",{method:d,url:Tu(l),hasBody:p!=null});const _=await e3e(async()=>QOe(x,l,d,c,p??void 0,m,y,(i==null?void 0:i.credentials)==="include",void 0,!1),b);return o.isDebug()&&o.debug("Passthrough HTTP request completed",{method:d,url:Tu(l),statusCode:_.status}),_}function aKt(e,t){if(t==null)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}}class vp{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 k$=iKt();function iKt(){var c,d,p,f,m,b,y;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"&&(((d=self.constructor)==null?void 0:d.name)==="DedicatedWorkerGlobalScope"||((p=self.constructor)==null?void 0:p.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:(m=Deno.build)==null?void 0:m.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((y=s.versions)==null?void 0:y.node)=="string"?{type:"node",version:s.versions.node,parsedVersion:Number(s.versions.node.split(".")[0]),os:s.platform,arch:s.arch}:{type:"unknown"}}const bo={DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",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 Ci(e,t){return`Expected ${t}. Received ${sKt(e)}.`}function sKt(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 Dy(e){return{...e,json:Ome(e.json),parse:Ome(e.parse)}}function Ome(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(`
|
|
994
994
|
`)),{ok:!0,value:t}):r}}function r3e(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}class GZ extends Error{constructor(t){super(t.map(r3e).join("; ")),this.errors=t,Object.setPrototypeOf(this,GZ.prototype),this.name="JsonError"}}class WZ extends Error{constructor(t){super(t.map(r3e).join("; ")),this.errors=t,Object.setPrototypeOf(this,WZ.prototype),this.name="ParseError"}}function gs(e){return{nullable:()=>lKt(e),optional:()=>cKt(e),optionalNullable:()=>uKt(e),transform:t=>dKt(e,t),parseOrThrow:(t,n)=>{const r=e.parse(t,n);if(r.ok)return r.value;throw new WZ(r.errors)},jsonOrThrow:(t,n)=>{const r=e.json(t,n);if(r.ok)return r.value;throw new GZ(r.errors)}}}function lKt(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:()=>bo.NULLABLE};return{...t,...gs(t)}}function cKt(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:()=>bo.OPTIONAL};return{...t,...gs(t)}}function uKt(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:()=>bo.OPTIONAL_NULLABLE};return{...t,...gs(t)}}function dKt(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,...gs(n)}}const pKt=/^([+-]?\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 yp(){const e={parse:(t,{breadcrumbsPrefix:n=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:n,message:Ci(t,"string")}]}:pKt.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:n,message:Ci(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:n=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:n,message:Ci(t,"Date object")}]},getType:()=>bo.DATE};return{...Dy(e),...gs(e)}}function Ly(e,t){return()=>{const n={parse:t,json:t,getType:()=>e};return{...Dy(n),...gs(n)}}}function ua(e){const t=new Set(e);return Ly(bo.ENUM,(r,{allowUnrecognizedEnumValues:o,breadcrumbsPrefix:a=[]}={})=>typeof r!="string"?{ok:!1,errors:[{path:a,message:Ci(r,"string")}]}:!t.has(r)&&!o?{ok:!1,errors:[{path:a,message:Ci(r,"enum")}]}:{ok:!0,value:r})()}function jme(e){return Object.entries(e)}function E$(e,t){const n=new Set(t);return Object.entries(e).reduce((r,[o,a])=>(n.has(o)&&(r[o]=a),r),{})}function bN(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function o3e(e){return Object.keys(e)}function fKt(e,t){const n=[],r=[];for(const o of e)t(o)?n.push(o):r.push(o);return[n,r]}const hKt=Object.prototype.hasOwnProperty;function sC(e){return{withParsedProperties:t=>gKt(e,t)}}function gKt(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(hKt.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(!bN(r))return{ok:!1,errors:[{path:(o==null?void 0:o.breadcrumbsPrefix)??[],message:Ci(r,"object")}]};const a=new Set(Object.keys(t)),i=E$(r,Object.keys(r).filter(s=>!a.has(s)));return e.json(i,o)},getType:()=>e.getType()};return{...n,...gs(n),...sC(n)}}function fe(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Pm(e){return e.isProperty}const mKt=Object.prototype.hasOwnProperty;function ue(e){let t;function n(){if(t==null){t={};for(const[f,m]of jme(e)){const b=Pm(m)?m.rawKey:f,y=Pm(m)?m.valueSchema:m;t[b]={rawKey:b,parsedKey:f,valueSchema:y}}}return t}let r,o,a,i;function s(){if(r==null){r=[],o=[];for(const[f,m]of jme(e)){const b=Pm(m)?m.rawKey:f,y=Pm(m)?m.valueSchema:m;bKt(y)&&(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 d(){return i==null&&s(),i}const p={_getRawProperties:()=>Object.entries(e).map(([f,m])=>Pm(m)?m.rawKey:f),_getParsedProperties:()=>o3e(e),parse:(f,m)=>{const b=(m==null?void 0:m.breadcrumbsPrefix)??[];return Pme({value:f,requiredKeys:s(),requiredKeysSet:c(),getProperty:y=>{const x=n()[y];if(x!=null)return{transformedKey:x.parsedKey,transform:_=>{const k=[...b,y];return x.valueSchema.parse(_,{...m,breadcrumbsPrefix:k})}}},unrecognizedObjectKeys:m==null?void 0:m.unrecognizedObjectKeys,skipValidation:m==null?void 0:m.skipValidation,breadcrumbsPrefix:b,omitUndefined:m==null?void 0:m.omitUndefined})},json:(f,m)=>{const b=(m==null?void 0:m.breadcrumbsPrefix)??[];return Pme({value:f,requiredKeys:l(),requiredKeysSet:d(),getProperty:y=>{const x=e[y];if(x!=null)return Pm(x)?{transformedKey:x.rawKey,transform:_=>{const k=[...b,y];return x.valueSchema.json(_,{...m,breadcrumbsPrefix:k})}}:{transformedKey:y,transform:_=>{const k=[...b,y];return x.json(_,{...m,breadcrumbsPrefix:k})}}},unrecognizedObjectKeys:m==null?void 0:m.unrecognizedObjectKeys,skipValidation:m==null?void 0:m.skipValidation,breadcrumbsPrefix:b,omitUndefined:m==null?void 0:m.omitUndefined})},getType:()=>bo.OBJECT};return{...Dy(p),...gs(p),...sC(p),...T$(p)}}function Pme({value:e,requiredKeys:t,requiredKeysSet:n,getProperty:r,unrecognizedObjectKeys:o="fail",skipValidation:a=!1,breadcrumbsPrefix:i=[]}){if(!bN(e))return{ok:!1,errors:[{path:i,message:Ci(e,"object")}]};let s=t.length;const l=[],c={};for(const d in e){if(!mKt.call(e,d))continue;const p=e[d],f=r(d);if(f!=null){s>0&&n.has(d)&&s--;const m=f.transform(p);m.ok?c[f.transformedKey]=m.value:(c[d]=p,l.push(...m.errors))}else switch(o){case"fail":l.push({path:[...i,d],message:`Unexpected key "${d}"`});break;case"strip":break;case"passthrough":c[d]=p;break}}if(s>0)for(const d of t)d in e||l.push({path:i,message:`Missing required key "${d}"`});return l.length===0||a?{ok:!0,value:c}:{ok:!1,errors:l}}function T$(e){return{extend:t=>{const n={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(r,o)=>Dme({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)=>Dme({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:()=>bo.OBJECT};return{...n,...gs(n),...sC(n),...T$(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:()=>bo.OBJECT};return{...r,...gs(r),...sC(r),...T$(r)}}}}function Dme({extensionKeys:e,value:t,transformBase:n,transformExtension:r,breadcrumbsPrefix:o=[]}){if(!bN(t))return{ok:!1,errors:[{path:o,message:Ci(t,"object")}]};const a=new Set(e),[i,s]=fKt(o3e(t),d=>a.has(d)),l=n(E$(t,s)),c=r(E$(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 bKt(e){return!vKt(e)}function vKt(e){switch(e.getType()){case bo.ANY:case bo.UNKNOWN:case bo.OPTIONAL:case bo.OPTIONAL_NULLABLE:return!0;default:return!1}}function yt(e){const t={parse:(n,r)=>Lme(n,(o,a)=>e.parse(o,{...r,breadcrumbsPrefix:[...(r==null?void 0:r.breadcrumbsPrefix)??[],`[${a}]`]})),json:(n,r)=>Lme(n,(o,a)=>e.json(o,{...r,breadcrumbsPrefix:[...(r==null?void 0:r.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>bo.LIST};return{...Dy(t),...gs(t)}}function Lme(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:Ci(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 ct(e){return Ly(bo.STRING_LITERAL,(n,{breadcrumbsPrefix:r=[]}={})=>n===e?{ok:!0,value:e}:{ok:!1,errors:[{path:r,message:Ci(n,`"${e}"`)}]})()}const Ho=Ly(bo.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Ci(e,"boolean")}]}),zt=Ly(bo.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Ci(e,"number")}]}),ie=Ly(bo.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Ci(e,"string")}]}),vN=Ly(bo.UNKNOWN,e=>({ok:!0,value:e})),yKt=Object.prototype.hasOwnProperty;function Bl(e,t){const n={parse:(r,o)=>zme({value:r,isKeyNumeric:e.getType()===bo.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)=>zme({value:r,isKeyNumeric:e.getType()===bo.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:()=>bo.RECORD};return{...Dy(n),...gs(n)}}function zme({value:e,isKeyNumeric:t,transformKey:n,transformValue:r,breadcrumbsPrefix:o=[]}){if(!bN(e))return{ok:!1,errors:[{path:o,message:Ci(e,"object")}]};const a={},i=[];for(const s in e){if(!yKt.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 d=n(c),p=r(l,c);d.ok&&p.ok?a[d.value]=p.value:(d.ok||i.push(...d.errors),p.ok||i.push(...p.errors))}return i.length===0?{ok:!0,value:a}:{ok:!1,errors:i}}function Ir(e){const t={parse:(n,r)=>$me((o,a)=>o.parse(n,a),e,r),json:(n,r)=>$me((o,a)=>o.json(n,a),e,r),getType:()=>bo.UNDISCRIMINATED_UNION};return{...Dy(t),...gs(t)}}function $me(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 W6="data:",Fme="event:",jE="id:",PE="retry:",xKt=5,wKt=1e3,_Kt=3e4;class Ume{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=W6,this.messageTerminator=`
|
|
995
995
|
`,this.streamTerminator=r.streamTerminator,this.eventDiscriminator=r.eventDiscriminator,this.resumable=r.resumable??!1):(this.messageTerminator=r.messageTerminator,this.resumable=!1),this.reconnectionEnabled=a??!0,this.maxReconnectionAttempts=i??xKt,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=Bme(n);let s="",l;for await(const d of i){s+=this.decodeChunk(d);let p;for(;(p=s.indexOf(this.messageTerminator))>=0;){const f=s.slice(0,p);if(s=s.slice(p+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(vh(l)),id:r,retry:a,event:void 0},o=r,t=0,l=void 0}continue}if(f.startsWith(jE)){const m=f.slice(jE.length).trim();m.includes("\0")||(r=m);continue}if(f.startsWith(PE)){const m=f.slice(PE.length).trim(),b=parseInt(m,10);!Number.isNaN(b)&&String(b)===m&&(a=b);continue}if(this.prefix!=null){const m=f.indexOf(this.prefix);if(m===-1)continue;const b=f.slice(m+this.prefix.length).trim();l=l!=null?`${l}
|
|
996
996
|
${b}`:b}else{if(this.streamTerminator!=null&&f.includes(this.streamTerminator))return;yield{data:await this.parse(vh(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(vh(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 d=await c(o);if(d==null){n=this.createEmptyStream();continue}n=d}catch{n=this.createEmptyStream()}}}async*iterSseEvents(){let t=0,n=this.stream,r,o,a;for(;;){const i=Bme(n);let s="",l,c;for await(const p of i){s+=this.decodeChunk(p);let f;for(;(f=s.indexOf(`
|
|
997
997
|
`))>=0;){const m=s.slice(0,f).replace(/\r$/,"");if(s=s.slice(f+1),!m.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(m.startsWith(Fme))l=m.slice(Fme.length).trim();else if(m.startsWith(W6)){const b=m.slice(W6.length).trim();c=c!=null?`${c}
|
|
998
|
-
${b}`:b}else if(m.startsWith(jE)){const b=m.slice(jE.length).trim();b.includes("\0")||(r=b)}else if(m.startsWith(PE)){const b=m.slice(PE.length).trim(),y=parseInt(b,10);!Number.isNaN(y)&&String(y)===b&&(a=y)}}}if(c!=null){const p=await this.dispatchSseEvent(c,l);p!=null&&(yield{data:p,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 d=this.reconnect;if(d==null||o==null)return;try{const p=await d(o);if(p==null){n=this.createEmptyStream();continue}n=p}catch{n=this.createEmptyStream()}}}async dispatchSseEvent(t,n){return this.streamTerminator!=null&&t.includes(this.streamTerminator)?null:this.parse(this.injectDiscriminator(vh(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:wKt,r=Math.min(n,_Kt),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){if(this.eventDiscriminator==null||n==null||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}):k$.type==="node"&&typeof t<"u"&&(n+=Buffer.isBuffer(t)?t:Buffer.from(t)),n}}function Bme(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 Rn(e){if(e===null)return"null";switch(typeof e){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:e=String(e);break}return encodeURIComponent(e)}function ht(){return new SKt}class SKt{constructor(){this.parts=new Map}add(t,n,r){if(n==null)return this;const o=iC({[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=iC({[n]:r},{arrayFormat:"repeat"});o.length>0&&this.parts.set(n,o)}return this}build(){return[...this.parts.values()].join("&")}}function xp(e,t,n){if(e==null)return e;const r=t.split(".");if(r.length===0)return e;let o=e;for(let i=0;i<r.length-1;i++){const s=r[i];s!=null&&((!o[s]||typeof o[s]!="object")&&(o[s]={}),o=o[s])}const a=r[r.length-1];return a==null||(o[a]=n),e}const A$="token";class C${constructor(t){this.options=t}static canCreate(t){return(t==null?void 0:t[A$])!=null}async getAuthRequest({endpointMetadata:t}={}){const n=await Ne.get(this.options[A$]);return n==null?{headers:{}}:{headers:{Authorization:`Bearer ${n}`}}}}(e=>{e.AUTH_SCHEME="BearerAuth",e.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${A$}' when initializing the client`;function t(n){return new e(n)}e.createInstance=t})(C$||(C$={}));function gt(...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 kKt(e){const t=gt({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@truefoundry/trueforge-sdk","X-Fern-SDK-Version":"0.179.0-rc.1","User-Agent":"@truefoundry/trueforge-sdk/0.179.0-rc.1","X-Fern-Runtime":k$.type,"X-Fern-Runtime-Version":k$.version},e==null?void 0:e.headers);return{...e,logging:VZ(e==null?void 0:e.logging),headers:t}}function Nr(e){const t=kKt(e);if(e.auth===!1)return t.authProvider=new WOe,t;if(e.auth!=null){if(typeof e.auth=="function")return t.authProvider={getAuthRequest:e.auth},t;if(LWt(e.auth))return t.authProvider=e.auth,t;Object.assign(t,e.auth)}const n=EKt(t);return t.authProvider??(t.authProvider=new C$(n)),t}function EKt(e){return{...e,authProvider:new WOe}}function Yr(e,t){return t==null?e:e==null?{...t}:typeof e=="object"&&!Array.isArray(e)?{...e,...t}:e}function bt(e,t,n,r){switch(e.reason){case"non-json":throw new at({statusCode:e.statusCode,body:e.rawBody,rawResponse:t});case"body-is-null":throw new at({statusCode:e.statusCode,rawResponse:t});case"timeout":throw new OWt(`Timeout exceeded when calling ${n} ${r}.`,{cause:e.cause});case"unknown":throw new at({message:e.errorMessage,rawResponse:t,cause:e.cause});default:throw new at({message:"Unknown error",rawResponse:t})}}const TKt=ue({content:ie(),type:ct("user.message")}),AKt=Ir([ct("@all"),ct("@write"),ct("@destructive"),ie()]),K6=Ir([ct("@all"),ct("@read-only"),ie()]),CKt=ue({disableTools:fe("disable_tools",yt(K6).optional()),enableTools:fe("enable_tools",yt(K6).optional()),name:ie(),preload:Ho().optional(),preloadTools:fe("preload_tools",yt(K6).optional()),requireApprovalForTools:fe("require_approval_for_tools",yt(AKt).optional())}),RKt=ue({maxTokens:fe("max_tokens",zt().optional()),parallelToolCalls:fe("parallel_tool_calls",Ho().optional()),reasoningEffort:fe("reasoning_effort",ie().optional()),temperature:zt().optional(),topK:fe("top_k",zt().optional()),topP:fe("top_p",zt().optional())}).passthrough(),IKt=ue({name:ie(),params:RKt.optional()}),NKt=ue({type:ct("json_object")}).passthrough(),MKt=ue({description:ie().optional(),name:ie(),schema:Bl(ie(),vN()).optional(),strict:Ho().optionalNullable()}).passthrough(),OKt=ue({jsonSchema:fe("json_schema",MKt),type:ct("json_schema")}).passthrough(),jKt=ue({type:ct("text")}).passthrough(),PKt=Ir([NKt,OKt,jKt]),DKt=ue({enabled:Ho().optional()}),LKt=ue({type:ct("input_tokens"),value:zt()}),zKt=ue({enabled:Ho().optional(),trigger:LKt.optional()}),$Kt=ue({enabled:Ho().optional()}),FKt=ue({compaction:zKt.optional(),largeToolResponse:fe("large_tool_response",$Kt.optional())}),UKt=ue({enabled:Ho().optional()}),BKt=ue({enabled:Ho().optional()}),HKt=ue({enabled:Ho(),environmentName:fe("environment_name",ie().optional()),fileDownloads:fe("file_downloads",Ho().optional())}),VKt=ue({enabled:Ho().optional()}),GKt=ue({askUserQuestions:fe("ask_user_questions",DKt.optional()),contextManagement:fe("context_management",FKt.optional()),dynamicSubAgents:fe("dynamic_sub_agents",UKt.optional()),generativeUi:fe("generative_ui",BKt.optional()),iterationLimit:fe("iteration_limit",zt().optional()),sandbox:HKt.optional(),webSearch:fe("web_search",VKt.optional())}),WKt=ue({name:ie(),preload:Ho().optional()}),Y1=ue({config:GKt.optional(),instructions:ie().optional(),mcpServers:fe("mcp_servers",yt(CKt).optional()),messages:yt(TKt).optional(),model:IKt,responseFormat:fe("response_format",PKt.optional()),skills:yt(WKt).optional()}),so=ie(),KKt=ue({description:ie(),manifest:Y1,name:so}),YKt=ue({description:ie().optional(),manifest:Y1}),a3e=ua(["agent","schedule","session","tenant"]),ZKt=ue({resourceIds:fe("resource_ids",yt(ie())),resourceType:fe("resource_type",a3e)}),XKt=ue({environmentVersionId:fe("environment_version_id",ie())}),qKt=ue({scheduleRunId:fe("schedule_run_id",ie())}),QKt=ue({name:so}),i3e=ue({spec:Y1}),s3e=Ir([QKt,i3e]),JKt=ue({id:ie(),runId:fe("run_id",ie()),type:ct("schedule")}),eYt=ue({agent:s3e,externalId:fe("external_id",ie()),source:JKt.optional()}),l3e=ue({buildScript:fe("build_script",ie().optional()),type:ct("build")}),tYt=ue({env:ie(),hosts:yt(ie()),value:ie()}),c3e=ue({domainAllowList:fe("domain_allow_list",ie().optional()),networkBlockAll:fe("network_block_all",Ho().optional()),secrets:yt(tYt).optional()}),u3e=ue({cpu:zt().optional(),disk:zt().optional(),memory:zt().optional()}),d3e=ue({description:ie().optional(),environmentVariables:fe("environment_variables",Bl(ie(),ie()).optional()),image:l3e.optional(),name:so,networking:c3e.optional(),resources:u3e.optional()}),nYt=ue({manifest:d3e}),rYt=ue({manifest:d3e}),oYt=ie(),aYt=ua(["active","paused"]),iYt=ie(),KZ=ue({cron:oYt,status:aYt.optional(),task:ie(),timezone:iYt.optional()}),sYt=ue({agentName:fe("agent_name",so),manifest:KZ,name:so}),lYt=ue({scheduleId:fe("schedule_id",ie())}),cYt=ue({manifest:KZ,name:so}),uYt=ue({}),YZ=Bl(ie(),ie()),dYt=ue({agent:s3e,metadata:YZ.optional()}),pYt=ue({type:ct("user.mcp_auth_continue")}),fYt=ue({status:ct("allow")}),hYt=ue({reason:ie().optional(),status:ct("deny")}),p3e=Ir([fYt,hYt]),f3e=ue({approval:p3e,threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_approval")}),gYt=ue({expireAt:fe("expire_at",ie().optional()),type:ct("allow_session")}),h3e=gYt,g3e=ue({action:h3e,name:ie(),serverName:fe("server_name",ie())}),mYt=ue({policies:yt(g3e),type:ct("user.tool_approval_policy")}),m3e=ue({content:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_response")}),bYt=Ir([pYt,f3e,mYt,m3e]),vYt=ue({events:yt(bYt)}),b3e=Ir([ct("auto"),ct("none"),ie()]),yYt=ue({data:ie(),name:ie(),type:ct("file")}),xYt=ue({text:ie(),type:ct("text")}),wYt=Ir([yYt,xYt]),_Yt=Ir([ie(),yt(wYt)]),SYt=ue({content:_Yt,type:ct("user.message")}),yN=Ir([SYt,f3e,m3e]),kYt=ue({input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",b3e.optional())}),EYt=ue({input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",b3e.optional())}),TYt=ue({agent:i3e.optional(),metadata:YZ.optional(),shared:Ho().optional(),title:ie().optional()}),AYt=ue({type:ct("dcr")}),CYt=ue({headers:Bl(ie(),ie()),type:ct("header")}),ZZ=Ir([AYt,CYt]),RYt=ue({auth:ZZ.optional(),description:ie(),name:so,type:ct("remote"),url:ie()}),IYt=ue({auth:ZZ.optional(),description:ie(),name:so,type:ct("truefoundry"),url:ie()}),XZ=Ir([RYt,IYt]),NYt=ue({manifest:XZ}),MYt=ue({manifest:XZ}),v3e=ua(["none","minimal","low","medium","high","xhigh","max"]),qZ=ue({contextLength:fe("context_length",zt().optional()),maxOutputTokens:fe("max_output_tokens",zt().optional()),reasoningEfforts:fe("reasoning_efforts",yt(v3e).optional())}),Zc=ue({modelId:fe("model_id",ie()),name:so,properties:qZ}),Xc=ue({apiKey:fe("api_key",ie())}),OYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("alibaba")}),jYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("anthropic")}),PYt=ue({auth:Xc.optional(),baseUrl:fe("base_url",ie()),models:yt(Zc),name:so,type:ct("custom")}),DYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("fireworks")}),LYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("google-gemini")}),zYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("moonshot")}),$Yt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("openai")}),FYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("together")}),UYt=ue({auth:Xc.optional(),baseUrl:fe("base_url",ie()),models:yt(Zc),type:ct("truefoundry")}),BYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("zai")}),QZ=Ir([OYt,jYt,PYt,DYt,LYt,zYt,$Yt,FYt,UYt,BYt]),HYt=ue({manifest:QZ}),VYt=ue({manifest:QZ}),GYt=ue({apiKey:fe("api_key",ie())}),y3e=ue({auth:GYt,autoArchiveIntervalInMinutes:fe("auto_archive_interval_in_minutes",zt()),autoDeleteIntervalInMinutes:fe("auto_delete_interval_in_minutes",zt()),autoStopIntervalInMinutes:fe("auto_stop_interval_in_minutes",zt()),execTimeoutMs:fe("exec_timeout_ms",zt()),type:ct("daytona")}),WYt=ue({manifest:y3e}),KYt=ue({description:ie(),name:so,path:ie().optional(),ref:ie(),type:ct("git"),url:ie()}),YYt=ue({description:ie(),displayName:fe("display_name",ie()),name:ie(),repositoryName:fe("repository_name",ie()),type:ct("truefoundry"),version:zt()}),JZ=Ir([KYt,YYt]),ZYt=ue({manifest:JZ}),XYt=ue({manifest:JZ}),qYt=ue({apiKey:fe("api_key",ie())}),x3e=ue({auth:qYt,type:ct("parallel")}),QYt=ue({manifest:x3e}),JYt=ue({id:ie()}),eZt=ue({createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie().nullable())}),tZt=ue({authUrl:fe("auth_url",ie()),id:ie(),name:ie()}),eX=ue({mcpServers:fe("mcp_servers",yt(tZt)),type:ct("mcp.auth_required")}).extend(eZt),w3e=ue({id:ie(),sourceEventId:fe("source_event_id",ie())}),tX=ue({createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(w3e)),type:ct("tool.approval_required")}),nX=ue({createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(w3e)),type:ct("tool.response_required")}),nZt=Ir([eX,tX,nX]),Z1=ue({subjectDisplayName:fe("subject_display_name",ie()),subjectId:fe("subject_id",ie()),subjectType:fe("subject_type",ie())}),_3e=ue({createdBySubject:fe("created_by_subject",Z1),description:ie(),id:ie(),manifest:Y1,name:so}),rZt=ue({nonStream:fe("non_stream",ie()),stream:ie()}),oZt=ue({icon:ie(),labelName:fe("label_name",ie()),language:ie(),sampleCode:fe("sample_code",rZt)}),aZt=ue({baseUrl:fe("base_url",ie()),snippets:yt(oZt)}),iZt=ue({input:ie(),model:ie().optional(),name:ie(),type:ct("dynamic")}),S3e=ue({threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie())}),sZt=ua(["authenticated","auth_required","not_required"]),rX=ue({authorizationUrl:fe("authorization_url",ie().optional()),status:sZt}),lZt=ue({type:ct("header")}),cZt=ue({type:ct("dcr")}),uZt=Ir([cZt,lZt]),k3e=ue({auth:uZt.optional(),authStatus:fe("auth_status",rX),name:so,url:ie()}),dZt=ue({name:ie()}),pZt=ue({modelId:fe("model_id",ie()),name:ie(),properties:qZ,provider:dZt}),fZt=ue({description:ie(),metadata:Bl(ie(),ie()).optional(),name:ie()}),hZt=ue({}),gZt=ue({enabled:Ho()}),mZt=ue({enabled:Ho()}),bZt=ue({enabled:Ho(),reason:ie().optional()}),vZt=ue({enabled:Ho()}),yZt=ue({sandbox:gZt,settings:mZt,skill:bZt,webSearch:fe("web_search",vZt)}),xZt=ue({supportedReasoningEfforts:fe("supported_reasoning_efforts",yt(v3e)),type:ct("custom")}),wZt=ct("remote"),_Zt=ue({auth:ZZ.optional(),description:ie(),logo:ie().optional(),name:so,type:wZt,url:ie()}),SZt=ue({modelId:fe("model_id",ie()),name:so,properties:qZ}),kZt=ua(["openai","anthropic","google-gemini","fireworks","zai","moonshot","alibaba","together"]),EZt=ue({logo:ie().optional(),models:yt(SZt),type:kZt}),TZt=Ir([EZt,xZt]),AZt=ue({autoArchiveIntervalInMinutes:fe("auto_archive_interval_in_minutes",zt()),autoDeleteIntervalInMinutes:fe("auto_delete_interval_in_minutes",zt()),autoStopIntervalInMinutes:fe("auto_stop_interval_in_minutes",zt()),execTimeoutMs:fe("exec_timeout_ms",zt()),type:ct("daytona")}),CZt=ct("git"),RZt=ue({description:ie(),name:so,path:ie().optional(),ref:ie(),type:CZt,url:ie()}),IZt=ue({type:ct("parallel")}),NZt=ue({arguments:ie().optional(),name:ie().optional()}),MZt=ue({function:NZt.optional(),id:ie().optional(),index:zt(),type:ct("function").optional()}),OZt=ue({refusal:ie(),type:ct("refusal")}),jZt=ue({text:ie(),type:ct("text")}),PZt=ue({arguments:ie(),name:ie()}),DZt=ue({function:PZt,id:ie(),type:ct("function")}),E3e=ue({authStatus:fe("auth_status",rX),manifest:XZ,name:so}),T3e=ue({manifest:QZ,name:so}),LZt=ue({manifest:y3e}),A3e=ue({manifest:JZ,name:ie()}),zZt=ue({manifest:x3e,name:so}),$Zt=ua(["scheduled","triggered","failed"]),C3e=ue({createdAt:fe("created_at",yp()),createdBySubject:fe("created_by_subject",Z1),id:ie(),name:ie(),reason:ie().nullable(),scheduleId:fe("schedule_id",ie()),scheduledFor:fe("scheduled_for",yp()),status:$Zt,triggeredAt:fe("triggered_at",yp().nullable()),updatedAt:fe("updated_at",yp())}),FZt=ue({data:C3e}),oX=ue({createdAt:fe("created_at",ie()),id:ie(),type:ct("user.mcp_auth_continue")}),aX=ue({approval:p3e,createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_approval")}),iX=ue({createdAt:fe("created_at",ie()),id:ie(),policies:yt(g3e),type:ct("user.tool_approval_policy")}),sX=ue({content:ie(),createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_response")}),UZt=Ir([oX,aX,iX,sX]),BZt=ue({data:yt(UZt)}),HZt=ue({}),VZt=ue({}),GZt=ue({}),WZt=ue({}),KZt=ue({}),YZt=ue({}),ZZt=ue({name:ie(),serverId:fe("server_id",ie()),serverName:fe("server_name",ie()),type:ct("mcp")}),XZt=ue({name:ie(),type:ct("truefoundry-system")}),R3e=Ir([ZZt,XZt]),qZt=ue({providerSpecificFields:fe("provider_specific_fields",Bl(ie(),vN()).optional()),toolInfo:fe("tool_info",R3e.optional())}).extend(MZt),I3e=ua(["stop","length","tool_calls","content_filter","function_call"]),QZt=ue({data:aZt}),Y6=ue({data:_3e}),JZt=ue({data:k3e}),eXt=ue({data:yZt}),tXt=ue({data:yt(_Zt)}),_T=ue({data:E3e}),nXt=ue({displayName:fe("display_name",ie()),id:ie(),type:ie()}),rXt=ua(["default","oidc-connected"]),oXt=ue({roles:yt(ie()),subject:nXt,tenantId:fe("tenant_id",ie()),type:rXt}),aXt=ue({data:oXt}),iXt=ue({data:yt(TZt)}),Hme=ue({data:T3e}),sXt=ua(["active","deleted"]),lXt=ue({description:ie().optional(),environmentVariables:fe("environment_variables",Bl(ie(),ie()).optional()),image:l3e.optional(),name:so,networking:c3e.optional(),resources:u3e.optional()}),cXt=ua(["pending","ready","failed"]),N3e=ue({createdAt:fe("created_at",yp()),createdBySubject:fe("created_by_subject",Z1),description:ie(),id:ie(),lifecycleStage:fe("lifecycle_stage",sXt),manifest:lXt,name:so,status:cXt,statusReason:fe("status_reason",ie().nullable()),updatedAt:fe("updated_at",yp())}),Z6=ue({data:N3e}),uXt=ue({data:yt(AZt)}),Vme=ue({data:LZt}),M3e=ue({agentName:fe("agent_name",so),createdAt:fe("created_at",yp()),createdBySubject:fe("created_by_subject",Z1),id:ie(),manifest:KZ,name:so,updatedAt:fe("updated_at",yp())}),X6=ue({data:M3e}),O3e=ua(["count","$","ms"]),lX=ua(["sessions_over_time","sessions_cost_over_time","turns_over_time"]),dXt=ue({timestamp:ie(),value:zt()}),pXt=ue({name:ie(),values:yt(dXt)}),fXt=ue({chartType:fe("chart_type",ct("line")),description:ie(),displayName:fe("display_name",ie()),graphLines:fe("graph_lines",yt(pXt)),name:lX,unit:O3e}),hXt=ue({graphs:yt(fXt),step:ie()}),gXt=ue({data:hXt}),mXt=ue({chartType:fe("chart_type",ct("line")),description:ie(),displayName:fe("display_name",ie()),name:lX}),bXt=ue({charts:yt(mXt)}),vXt=ue({data:bXt}),yXt=ua(["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"]),xXt=ue({aggregateValue:fe("aggregate_value",zt()),description:ie(),name:yXt,unit:O3e}),wXt=ue({meters:yt(xXt)}),_Xt=ue({data:wXt}),SXt=ue({spec:Y1,type:ct("inline")}),kXt=ue({id:ie(),name:ie().nullable(),type:ct("reference")}),EXt=Ir([SXt,kXt]),TXt=ue({totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalDurationMs:fe("total_duration_ms",zt()),totalTurns:fe("total_turns",zt())}),AXt=ue({id:ie(),runId:fe("run_id",ie()),type:ct("schedule")}),j3e=ue({agent:EXt,createdAt:fe("created_at",ie()),createdBySubject:fe("created_by_subject",Z1),id:ie(),metadata:YZ,metrics:TXt,shared:Ho(),source:AXt.nullable(),title:ie().nullable(),updatedAt:fe("updated_at",ie())}),ST=ue({data:j3e}),CXt=ue({data:yt(RZt)}),Gme=ue({data:A3e}),RXt=ue({totalCacheReadTokens:fe("total_cache_read_tokens",zt().optional()),totalCacheWriteTokens:fe("total_cache_write_tokens",zt().optional()),totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalInputTokens:fe("total_input_tokens",zt().optional()),totalOutputTokens:fe("total_output_tokens",zt().optional()),totalReasoningTokens:fe("total_reasoning_tokens",zt().optional()),totalTokens:fe("total_tokens",zt().optional())}),IXt=ua(["server-execution-timeout","client-cancelled","cancelled-for-next-turn","abandoned"]),P3e=ue({completedAt:fe("completed_at",ie()),metrics:RXt.optional(),reason:IXt,status:ct("cancelled")}),NXt=Ir([jZt,OZt]),MXt=Ir([ie(),yt(NXt)]),OXt=ue({harness:zt(),instructions:zt(),messages:zt(),skills:zt(),toolDefinitions:fe("tool_definitions",zt())}),D3e=ue({cacheReadTokens:fe("cache_read_tokens",zt().optional()),cacheWriteTokens:fe("cache_write_tokens",zt().optional()),inputTokens:fe("input_tokens",zt()),inputTokensBreakdown:fe("input_tokens_breakdown",OXt),outputTokens:fe("output_tokens",zt())}),jXt=ue({providerSpecificFields:fe("provider_specific_fields",Bl(ie(),vN()).optional())}).extend(DZt),PXt=ue({toolInfo:fe("tool_info",R3e)}).extend(jXt),X1=ue({content:MXt.optionalNullable(),createdAt:fe("created_at",ie()),finishReason:fe("finish_reason",I3e.optionalNullable()),id:ie(),name:ie().optional(),reasoningContent:fe("reasoning_content",ie().optional()),refusal:ie().optionalNullable(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(PXt).optional()),type:ct("model.message"),usage:D3e.optional()}),DXt=ue({totalCacheReadTokens:fe("total_cache_read_tokens",zt().optional()),totalCacheWriteTokens:fe("total_cache_write_tokens",zt().optional()),totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalInputTokens:fe("total_input_tokens",zt().optional()),totalOutputTokens:fe("total_output_tokens",zt().optional()),totalReasoningTokens:fe("total_reasoning_tokens",zt().optional()),totalTokens:fe("total_tokens",zt().optional())}),L3e=ue({completedAt:fe("completed_at",ie()),metrics:DXt.optional(),output:X1.nullable(),requiredActions:fe("required_actions",yt(nZt)),status:ct("done")}),LXt=ue({totalCacheReadTokens:fe("total_cache_read_tokens",zt().optional()),totalCacheWriteTokens:fe("total_cache_write_tokens",zt().optional()),totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalInputTokens:fe("total_input_tokens",zt().optional()),totalOutputTokens:fe("total_output_tokens",zt().optional()),totalReasoningTokens:fe("total_reasoning_tokens",zt().optional()),totalTokens:fe("total_tokens",zt().optional())}),z3e=ue({completedAt:fe("completed_at",ie()),message:ie(),metrics:LXt.optional(),status:ct("error")}),$3e=ue({actionRequiredOnEvents:fe("action_required_on_events",yt(JYt)),status:ct("paused")}),cX=ue({status:ct("running")}),zXt=Ir([P3e,L3e,z3e,$3e,cX]),F3e=ue({createdAt:fe("created_at",ie()),id:ie(),input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",ie().nullable()),sessionId:fe("session_id",ie()),state:zXt}),Wme=ue({data:F3e}),$Xt=ue({data:yt(IZt)}),Kme=ue({data:zZt}),af=ue({limit:zt(),nextPageToken:fe("next_page_token",ie().optional()),previousPageToken:fe("previous_page_token",ie().optional())}),FXt=ue({data:yt(_3e),pagination:af}),UXt=ue({data:yt(k3e)}),BXt=ue({data:yt(pZt)}),HXt=ue({data:yt(fZt)}),VXt=ue({data:yt(E3e)}),GXt=ue({data:yt(Bl(ie(),vN()))}),WXt=ue({data:yt(T3e)}),KXt=ue({environmentVersionId:fe("environment_version_id",ie())}),YXt=ue({data:yt(KXt)}),ZXt=ua(["USE","MANAGE","DELETE","CREATE"]),XXt=ue({permissions:Bl(ie(),yt(ZXt)),type:a3e}),qXt=ue({data:XXt}),QXt=ue({data:yt(N3e),pagination:af}),JXt=ue({data:yt(C3e),pagination:af}),eqt=ue({data:yt(M3e),pagination:af}),tqt=ua(["streamable-http","sse"]),nqt=ue({approvalPolicies:fe("approval_policies",Bl(ie(),h3e).optional()),id:ie(),name:ie(),sessionId:fe("session_id",ie().optional()),transportType:fe("transport_type",tqt.optional())}),U3e=ue({createdAt:fe("created_at",ie()),id:ie(),mcpServers:fe("mcp_servers",yt(nqt)),threadId:fe("thread_id",ie()),type:ct("mcp.initialize")}),B3e=ue({createdAt:fe("created_at",ie()),id:ie(),sandboxId:fe("sandbox_id",ie()),threadId:fe("thread_id",ie().nullable()),type:ct("sandbox.created")}),H3e=ue({agentInfo:fe("agent_info",iZt),createdAt:fe("created_at",ie()),id:ie(),parent:S3e,threadId:fe("thread_id",ie()),title:ie(),type:ct("thread.created")}),rqt=ue({output:X1,status:ct("done")}),oqt=ue({error:ie(),output:X1.optional(),status:ct("error")}),aqt=Ir([rqt,oqt]),V3e=ue({createdAt:fe("created_at",ie()),id:ie(),parent:S3e.optional(),state:aqt,threadId:fe("thread_id",ie()),title:ie(),type:ct("thread.done")}),G3e=ue({content:ie(),createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("tool.response")}),W3e=ue({createdAt:fe("created_at",ie()),id:ie(),input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",ie().nullable()),state:cX,threadId:fe("thread_id",ie().nullable()),turnId:fe("turn_id",ie()),type:ct("turn.created")}),iqt=Ir([P3e,L3e,z3e]),K3e=ue({createdAt:fe("created_at",ie()),id:ie(),state:iqt,threadId:fe("thread_id",ie().nullable()),type:ct("turn.done")}),sqt=Ir([$3e,cX]),Y3e=ue({createdAt:fe("created_at",ie()),id:ie(),state:sqt,threadId:fe("thread_id",ie().nullable()),type:ct("turn.update")}),Z3e=Ir([eX,U3e,X1,B3e,H3e,V3e,tX,G3e,nX,W3e,K3e,Y3e,oX,aX,iX,sX]),lqt=ue({event:Z3e,turnId:fe("turn_id",ie())}),cqt=ue({data:yt(lqt),pagination:af}),uqt=ua(["asc","desc"]),dqt=ue({data:yt(j3e),pagination:af}),pqt=ue({data:yt(A3e)}),fqt=ue({description:ie(),displayName:fe("display_name",ie()),name:ie(),version:zt()}),hqt=ue({data:yt(fqt)}),gqt=ua(["asc","desc"]),mqt=ue({data:yt(Z3e),pagination:af}),bqt=ue({data:yt(F3e),pagination:af}),vqt=ue({content:ie().optionalNullable(),createdAt:fe("created_at",ie().optional()),finishReason:fe("finish_reason",I3e.optionalNullable()),id:ie(),reasoningContent:fe("reasoning_content",ie().optional()),refusal:ie().optionalNullable(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(qZt).optional()),type:ct("model.message.delta"),usage:D3e.optional()}),yqt=ue({code:ie().optionalNullable(),message:ie(),param:ie().optionalNullable(),type:ie().optional()}),ve=ue({error:yqt}),xqt=ct("schedule"),Yme=Ir([eX,U3e,X1,vqt,B3e,H3e,V3e,tX,G3e,nX,W3e,K3e,Y3e,oX,aX,iX,sX]);let wqt=class{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var m,b,y,x;const{limit:i=50,pageToken:s,agentName:l}=a,c={limit:i,page_token:s,agent_name:l},d=await this._options.authProvider.getAuthRequest(),p=gt(d.headers,(m=this._options)==null?void 0:m.headers,n==null?void 0:n.headers),f=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/agents"),method:"GET",headers:p,queryString:ht().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)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(x=this._options)==null?void 0:x.fetch,logging:this._options.logging});if(f.ok)return{data:FXt.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 Ln(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 401:throw new Jn(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new at({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return bt(f.error,f.rawResponse,"GET","/api/v1/agents")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/agents"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(KKt.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:Y6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/agents")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:Y6.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/agents/{agent_id}")}update(t,n,r){return dt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(YKt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:Y6.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"PUT","/api/v1/agents/{agent_id}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:HZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/agents/{agent_id}")}};class _qt{constructor(t){this._options=Nr(t)}me(t){return dt.fromPromise(this.__me(t))}async __me(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/auth/me"),method:"GET",headers:r,queryString:ht().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:aXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/auth/me")}}let Sqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/mcp-servers"),method:"GET",headers:r,queryString:ht().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:tXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/mcp-servers")}},kqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/model-providers"),method:"GET",headers:r,queryString:ht().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:iXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/model-providers")}},Eqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/sandbox-providers"),method:"GET",headers:r,queryString:ht().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:uXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/sandbox-providers")}},Tqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/skills"),method:"GET",headers:r,queryString:ht().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:CXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/skills")}},Aqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/web-search-providers"),method:"GET",headers:r,queryString:ht().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:$Xt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/web-search-providers")}};class Cqt{constructor(t){this._options=Nr(t)}get mcpServers(){return this._mcpServers??(this._mcpServers=new Sqt(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new kqt(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new Eqt(this._options))}get skills(){return this._skills??(this._skills=new Tqt(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new Aqt(this._options))}}class Rqt{constructor(t){this._options=Nr(t)}getCodeSnippets(t,n={},r){return dt.fromPromise(this.__getCodeSnippets(t,n,r))}async __getCodeSnippets(t,n={},r){var c,d,p,f;const{baseUrl:o}=n,a={base_url:o},i=await this._options.authProvider.getAuthRequest(),s=gt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}/code-snippets`),method:"GET",headers:s,queryString:ht().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((p=this._options)==null?void 0:p.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:QZt.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 Sn(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new at({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return bt(l.error,l.rawResponse,"GET","/api/v1/agents/{agent_id}/code-snippets")}}class Iqt{constructor(t){this._options=Nr(t)}listCharts(t){return dt.fromPromise(this.__listCharts(t))}async __listCharts(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/metrics/charts"),method:"GET",headers:r,queryString:ht().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:vXt.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});return bt(o.error,o.rawResponse,"GET","/api/internal/metrics/charts")}getChartData(t,n){return dt.fromPromise(this.__getChartData(t,n))}async __getChartData(t,n){var p,f,m,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:lX.jsonOrThrow(i,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0})},l=await this._options.authProvider.getAuthRequest(),c=gt(l.headers,(p=this._options)==null?void 0:p.headers,n==null?void 0:n.headers),d=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/metrics/charts-data"),method:"GET",headers:c,queryString:ht().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)??((m=this._options)==null?void 0:m.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(b=this._options)==null?void 0:b.fetch,logging:this._options.logging});if(d.ok)return{data:gXt.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 Ln(ve.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new at({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return bt(d.error,d.rawResponse,"GET","/api/internal/metrics/charts-data")}getMeters(t,n){return dt.fromPromise(this.__getMeters(t,n))}async __getMeters(t,n){var d,p,f,m;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=gt(s.headers,(d=this._options)==null?void 0:d.headers,n==null?void 0:n.headers),c=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/metrics/meters"),method:"GET",headers:l,queryString:ht().addMany(i).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((p=this._options)==null?void 0:p.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:(m=this._options)==null?void 0:m.fetch,logging:this._options.logging});if(c.ok)return{data:_Xt.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 Ln(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new at({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return bt(c.error,c.rawResponse,"GET","/api/internal/metrics/meters")}}let Nqt=class{constructor(t){this._options=Nr(t)}listPending(t){return dt.fromPromise(this.__listPending(t))}async __listPending(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/sandbox-environments/pending"),method:"GET",headers:r,queryString:ht().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:YXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/internal/sandbox-environments/pending")}progress(t,n){return dt.fromPromise(this.__progress(t,n))}async __progress(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/sandbox-environments/progress"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(XKt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/sandbox-environments/progress")}},Mqt=class{constructor(t){this._options=Nr(t)}executeRun(t,n){return dt.fromPromise(this.__executeRun(t,n))}async __executeRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/schedules/runs/execute"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(qKt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/schedules/runs/execute")}},Oqt=class{constructor(t){this._options=Nr(t)}getOrCreateByExternalId(t,n){return dt.fromPromise(this.__getOrCreateByExternalId(t,n))}async __getOrCreateByExternalId(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/sessions/get-or-create-by-external-id"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(eYt.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:ST.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/sessions/get-or-create-by-external-id")}};class jqt{constructor(t){this._options=Nr(t)}get metrics(){return this._metrics??(this._metrics=new Iqt(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new Nqt(this._options))}get schedules(){return this._schedules??(this._schedules=new Mqt(this._options))}get sessions(){return this._sessions??(this._sessions=new Oqt(this._options))}get agents(){return this._agents??(this._agents=new Rqt(this._options))}listPermissions(t,n){return dt.fromPromise(this.__listPermissions(t,n))}async __listPermissions(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/list-permissions"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(ZKt.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:qXt.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/list-permissions")}}let Pqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/mcp-servers"),method:"GET",headers:r,queryString:ht().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:UXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/mcp-servers")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:JZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}")}authorize(t,n={},r){return dt.fromPromise(this.__authorize(t,n,r))}async __authorize(t,n={},r){var c,d,p,f;const{returnTo:o}=n,a={return_to:o},i=await this._options.authProvider.getAuthRequest(),s=gt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}/authorize`),method:"GET",headers:s,queryString:ht().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((p=this._options)==null?void 0:p.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:rX.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 Ln(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new Sn(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new wa(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 424:throw new Hs(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new PWt(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new at({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return bt(l.error,l.rawResponse,"GET","/api/v1/mcp-servers/{name}/authorize")}deleteAuthorization(t,n){return dt.fromPromise(this.__deleteAuthorization(t,n))}async __deleteAuthorization(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}/authorize`),method:"DELETE",headers:o,queryString:ht().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:_T.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/mcp-servers/{name}/authorize")}listTools(t,n){return dt.fromPromise(this.__listTools(t,n))}async __listTools(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}/tools`),method:"GET",headers:o,queryString:ht().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:GXt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}/tools")}};class Dqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/models"),method:"GET",headers:r,queryString:ht().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:BXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/models")}}class Lqt{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var f,m,b,y;const{limit:i=25,pageToken:s}=a,l={limit:i,page_token:s},c=await this._options.authProvider.getAuthRequest(),d=gt(c.headers,(f=this._options)==null?void 0:f.headers,n==null?void 0:n.headers),p=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sandbox-environments"),method:"GET",headers:d,queryString:ht().addMany(l).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((m=this._options)==null?void 0:m.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:(y=this._options)==null?void 0:y.fetch,logging:this._options.logging});if(p.ok)return{data:QXt.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:p.rawResponse};if(p.error.reason==="status-code")switch(p.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(p.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),p.rawResponse);case 401:throw new Jn(ve.parseOrThrow(p.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),p.rawResponse);default:throw new at({statusCode:p.error.statusCode,body:p.error.body,rawResponse:p.rawResponse})}return bt(p.error,p.rawResponse,"GET","/api/v1/sandbox-environments")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sandbox-environments"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(nYt.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:Z6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/sandbox-environments")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sandbox-environments"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(rYt.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:Z6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/sandbox-environments")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sandbox-environments/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:Z6.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/sandbox-environments/{name}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sandbox-environments/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:WZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/sandbox-environments/{name}")}}class zqt{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var b,y,x,_;const{limit:i=25,pageToken:s,agentNames:l,createdByMe:c}=a,d={limit:i,page_token:s,agent_names:l,created_by_me:c},p=await this._options.authProvider.getAuthRequest(),f=gt(p.headers,(b=this._options)==null?void 0:b.headers,n==null?void 0:n.headers),m=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/schedules"),method:"GET",headers:f,queryString:ht().addMany(d).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((y=this._options)==null?void 0:y.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((x=this._options)==null?void 0:x.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(_=this._options)==null?void 0:_.fetch,logging:this._options.logging});if(m.ok)return{data:eqt.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);case 401:throw new Jn(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);default:throw new at({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}return bt(m.error,m.rawResponse,"GET","/api/v1/schedules")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/schedules"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(sYt.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:X6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/schedules")}createRun(t,n){return dt.fromPromise(this.__createRun(t,n))}async __createRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/schedules/runs"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(lYt.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:FZt.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/schedules/runs")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:X6.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 oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/schedules/{schedule_id}")}update(t,n,r){return dt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(cYt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:X6.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 409:throw new ii(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"PUT","/api/v1/schedules/{schedule_id}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:KZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/schedules/{schedule_id}")}async listRuns(t,n={},r){const o=dt.interceptFunction(async i=>{var m,b,y,x;const{limit:s=25,pageToken:l}=i,c={limit:s,page_token:l},d=await this._options.authProvider.getAuthRequest(),p=gt(d.headers,(m=this._options)==null?void 0:m.headers,r==null?void 0:r.headers),f=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}/runs`),method:"GET",headers:p,queryString:ht().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)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(x=this._options)==null?void 0:x.fetch,logging:this._options.logging});if(f.ok)return{data:JXt.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 Ln(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 403:throw new oo(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 404:throw new Sn(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new at({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return bt(f.error,f.rawResponse,"GET","/api/v1/schedules/{schedule_id}/runs")}),a=await o(n).withRawResponse();return new vp({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(xp(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}}class $qt{constructor(t){this._options=Nr(t)}getCapabilities(t){return dt.fromPromise(this.__getCapabilities(t))}async __getCapabilities(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/capabilities"),method:"GET",headers:r,queryString:ht().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:eXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/capabilities")}}class Fqt{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var T,C,A,R;const{limit:i=25,order:s,pageToken:l,startTimestamp:c,endTimestamp:d,agentId:p,createdByMe:f,metadata:m,sourceType:b,sourceId:y}=a,x={limit:i,order:s!=null?uqt.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:d!=null?d==null?void 0:d.toISOString():void 0,agent_id:p,created_by_me:f,metadata:m,source_type:b!=null?xqt.jsonOrThrow(b,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0,source_id:y},_=await this._options.authProvider.getAuthRequest(),k=gt(_.headers,(T=this._options)==null?void 0:T.headers,n==null?void 0:n.headers),E=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sessions"),method:"GET",headers:k,queryString:ht().addMany(x).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)??((A=this._options)==null?void 0:A.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:dqt.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 Ln(ve.parseOrThrow(E.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),E.rawResponse);default:throw new at({statusCode:E.error.statusCode,body:E.error.body,rawResponse:E.rawResponse})}return bt(E.error,E.rawResponse,"GET","/api/v1/sessions")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sessions"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(dYt.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:ST.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/sessions")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:ST.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 oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/sessions/{session_id}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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 oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/sessions/{session_id}")}update(t,n={},r){return dt.fromPromise(this.__update(t,n,r))}async __update(t,n={},r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}`),method:"PATCH",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(TYt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:ST.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"PATCH","/api/v1/sessions/{session_id}")}cancel(t,n={},r){return dt.fromPromise(this.__cancel(t,n,r))}async __cancel(t,n={},r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/cancel`),method:"POST",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(uYt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:hZt.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 oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new fx(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/cancel")}async listEvents(t,n={},r){const o=dt.interceptFunction(async i=>{var b,y,x,_;const{pageToken:s,lastTurnId:l,limit:c=100}=i,d={page_token:s,last_turn_id:l,limit:c},p=await this._options.authProvider.getAuthRequest(),f=gt(p.headers,(b=this._options)==null?void 0:b.headers,r==null?void 0:r.headers),m=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/events`),method:"GET",headers:f,queryString:ht().addMany(d).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((y=this._options)==null?void 0:y.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((x=this._options)==null?void 0:x.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(_=this._options)==null?void 0:_.fetch,logging:this._options.logging});if(m.ok)return{data:cqt.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);case 403:throw new oo(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);case 404:throw new Sn(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);default:throw new at({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}return bt(m.error,m.rawResponse,"GET","/api/v1/sessions/{session_id}/events")}),a=await o(n).withRawResponse();return new vp({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(xp(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}async listTurns(t,n={},r){const o=dt.interceptFunction(async i=>{var m,b,y,x;const{limit:s=25,pageToken:l}=i,c={limit:s,page_token:l},d=await this._options.authProvider.getAuthRequest(),p=gt(d.headers,(m=this._options)==null?void 0:m.headers,r==null?void 0:r.headers),f=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns`),method:"GET",headers:p,queryString:ht().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)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(x=this._options)==null?void 0:x.fetch,logging:this._options.logging});if(f.ok)return{data:bqt.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 Ln(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 403:throw new oo(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 404:throw new Sn(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new at({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return bt(f.error,f.rawResponse,"GET","/api/v1/sessions/{session_id}/turns")}),a=await o(n).withRawResponse();return new vp({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(xp(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}createTurnStream(t,n,r){return dt.fromPromise(this.__createTurnStream(t,n,r))}async __createTurnStream(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns`),method:"POST",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr({...EYt.jsonOrThrow(n,{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)??((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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:new Ume({stream:i.body,parse:async p=>Yme.parseOrThrow(p,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:r==null?void 0:r.abortSignal,eventShape:{type:"sse"}}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Jn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new fx(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 413:throw new H6(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}createTurn(t,n,r){return dt.fromPromise(this.__createTurn(t,n,r))}async __createTurn(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns`),method:"POST",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr({...kYt.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),stream:!1},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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:Wme.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Jn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new fx(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 413:throw new H6(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}getTurn(t,n,r){return dt.fromPromise(this.__getTurn(t,n,r))}async __getTurn(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}`),method:"GET",headers:a,queryString:ht().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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:Wme.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 oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}")}downloadSandboxFile(t,n,r,o){return dt.fromPromise(this.__downloadSandboxFile(t,n,r,o))}async __downloadSandboxFile(t,n,r,o){var d,p,f,m;const{path:a}=r,i={path:a},s=await this._options.authProvider.getAuthRequest(),l=gt(s.headers,(d=this._options)==null?void 0:d.headers,o==null?void 0:o.headers),c=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/download-sandbox-file`),method:"GET",headers:l,queryString:ht().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"binary-response",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((p=this._options)==null?void 0:p.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:(m=this._options)==null?void 0:m.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 Ln(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new oo(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new Sn(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 410:throw new jWt(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 412:throw new fx(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 413:throw new H6(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 424:throw new Hs(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new at({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return bt(c.error,c.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/download-sandbox-file")}async listTurnEvents(t,n,r={},o){const a=dt.interceptFunction(async s=>{var y,x,_,k;const{limit:l=100,pageToken:c,order:d}=s,p={limit:l,page_token:c,order:d!=null?gqt.jsonOrThrow(d,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0},f=await this._options.authProvider.getAuthRequest(),m=gt(f.headers,(y=this._options)==null?void 0:y.headers,o==null?void 0:o.headers),b=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/events`),method:"GET",headers:m,queryString:ht().addMany(p).mergeAdditional(o==null?void 0:o.queryParams).build(),timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((x=this._options)==null?void 0:x.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((_=this._options)==null?void 0:_.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(k=this._options)==null?void 0:k.fetch,logging:this._options.logging});if(b.ok)return{data:mqt.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 Ln(ve.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 403:throw new oo(ve.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 404:throw new Sn(ve.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);default:throw new at({statusCode:b.error.statusCode,body:b.error.body,rawResponse:b.rawResponse})}return bt(b.error,b.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}),i=await a(r).withRawResponse();return new vp({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(xp(r,"pageToken",s==null?void 0:s.pagination.nextPageToken))})}createTurnEvent(t,n,r,o){return dt.fromPromise(this.__createTurnEvent(t,n,r,o))}async __createTurnEvent(t,n,r,o){var l,c,d,p;const a=await this._options.authProvider.getAuthRequest(),i=gt(a.headers,(l=this._options)==null?void 0:l.headers,o==null?void 0:o.headers),s=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/events`),method:"POST",headers:i,contentType:"application/json",queryString:ht().mergeAdditional(o==null?void 0:o.queryParams).build(),requestType:"json",body:Yr(vYt.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)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(p=this._options)==null?void 0:p.fetch,logging:this._options.logging});if(s.ok)return{data:BZt.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 Ln(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new oo(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new Sn(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 409:throw new ii(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new at({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return bt(s.error,s.rawResponse,"POST","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}subscribeToTurn(t,n,r={},o){return dt.fromPromise(this.__subscribeToTurn(t,n,r,o))}async __subscribeToTurn(t,n,r={},o){var p,f,m,b,y,x,_,k,E,T;const{afterSequenceNumber:a}=r,i={after_sequence_number:a},s=await this._options.authProvider.getAuthRequest(),l=gt(s.headers,(p=this._options)==null?void 0:p.headers,o==null?void 0:o.headers),c=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/subscribe`),method:"GET",headers:l,queryString:ht().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"sse",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((f=this._options)==null?void 0:f.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((m=this._options)==null?void 0:m.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(b=this._options)==null?void 0:b.fetch,logging:this._options.logging}),d=async C=>{var R,M,j;const A=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/subscribe`),method:"GET",headers:{...l,"Last-Event-ID":C},queryString:ht().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"sse",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((R=this._options)==null?void 0:R.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((M=this._options)==null?void 0:M.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(j=this._options)==null?void 0:j.fetch,logging:this._options.logging});if(!A.ok)throw new Error("SSE stream reconnection failed");if(A.body==null)throw new Error("SSE stream reconnection failed: empty response body");return A.body};if(c.ok)return{data:new Ume({stream:c.body,parse:async C=>Yme.parseOrThrow(C,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:o==null?void 0:o.abortSignal,eventShape:{type:"sse",resumable:!0},reconnectionEnabled:((y=o==null?void 0:o.stream)==null?void 0:y.reconnectionEnabled)??((_=(x=this._options)==null?void 0:x.stream)==null?void 0:_.reconnectionEnabled),maxReconnectionAttempts:((k=o==null?void 0:o.stream)==null?void 0:k.maxReconnectionAttempts)??((T=(E=this._options)==null?void 0:E.stream)==null?void 0:T.maxReconnectionAttempts),reconnect:d}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new oo(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new Sn(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 412:throw new fx(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new at({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return bt(c.error,c.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/subscribe")}}class Uqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"GET",headers:r,queryString:ht().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:VXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/mcp-servers")}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(NYt.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:_T.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/settings/mcp-servers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(MYt.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:_T.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/mcp-servers")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/mcp-servers/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:_T.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/settings/mcp-servers/{name}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/mcp-servers/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:VZt.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/settings/mcp-servers/{name}")}}class Bqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/model-providers"),method:"GET",headers:r,queryString:ht().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:WXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/model-providers")}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/model-providers"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(HYt.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:Hme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/settings/model-providers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/model-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(VYt.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:Hme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/model-providers")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/model-providers/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:GZt.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/settings/model-providers/{name}")}}class Hqt{constructor(t){this._options=Nr(t)}get(t){return dt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"GET",headers:r,queryString:ht().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:Vme.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 Sn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/sandbox-providers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(WYt.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:Vme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/sandbox-providers")}}let Vqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/skills"),method:"GET",headers:r,queryString:ht().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:pqt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/skills")}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/skills"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(ZYt.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:Gme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/settings/skills")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/skills"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(XYt.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:Gme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/skills")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/skills/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:YZt.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/settings/skills/{name}")}};class Gqt{constructor(t){this._options=Nr(t)}get(t){return dt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"GET",headers:r,queryString:ht().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:Kme.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 404:throw new Sn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/web-search-providers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(QYt.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:Kme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/web-search-providers")}}class Wqt{constructor(t){this._options=Nr(t)}get mcpServers(){return this._mcpServers??(this._mcpServers=new Uqt(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new Bqt(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new Hqt(this._options))}get skills(){return this._skills??(this._skills=new Vqt(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new Gqt(this._options))}}class Kqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/skills"),method:"GET",headers:r,queryString:ht().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:HXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/skills")}listVersions(t,n){return dt.fromPromise(this.__listVersions(t,n))}async __listVersions(t,n){var l,c,d,p;const{name:r}=t,o={name:r},a=await this._options.authProvider.getAuthRequest(),i=gt(a.headers,(l=this._options)==null?void 0:l.headers,n==null?void 0:n.headers),s=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/skills/versions"),method:"GET",headers:i,queryString:ht().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)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(p=this._options)==null?void 0:p.fetch,logging:this._options.logging});if(s.ok)return{data:hqt.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 Jn(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new at({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return bt(s.error,s.rawResponse,"GET","/api/v1/skills/versions")}}class uX{constructor(t){this._options=Nr(t)}get internal(){return this._internal??(this._internal=new jqt(this._options))}get agents(){return this._agents??(this._agents=new wqt(this._options))}get auth(){return this._auth??(this._auth=new _qt(this._options))}get server(){return this._server??(this._server=new $qt(this._options))}get mcpServers(){return this._mcpServers??(this._mcpServers=new Pqt(this._options))}get models(){return this._models??(this._models=new Dqt(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new Lqt(this._options))}get schedules(){return this._schedules??(this._schedules=new zqt(this._options))}get sessions(){return this._sessions??(this._sessions=new Fqt(this._options))}get skills(){return this._skills??(this._skills=new Kqt(this._options))}get catalogs(){return this._catalogs??(this._catalogs=new Cqt(this._options))}get settings(){return this._settings??(this._settings=new Wqt(this._options))}async fetch(t,n,r){return oKt(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 lC="daytona",Yqt="Daytona";function X3e(e){return e===lC?Yqt:e}function Zqt(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 dX(e){return{execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes}}function q3e(e){return{id:e.type,name:X3e(e.type),type:e.type,...dX(e)}}function kT(e){return{id:e.type,name:X3e(e.type),catalogId:e.type,isConnected:!0,...dX(e)}}function Q3e({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 R$(e){if(e.type!==lC)throw new Error(`Unsupported sandbox provider type: ${e.type}`);return{type:lC,execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes,auth:{apiKey:e.apiKey}}}function J3e(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(q3e),listSandboxProviders:async n=>{let r;try{const o=await e.settings.sandboxProviders.get();r=[kT(o.data.manifest)]}catch(o){if(o instanceof Sn)r=[];else throw o}return Q3e({providers:r,query:n==null?void 0:n.query})},createSandboxProvider:async n=>{const r=await e.settings.sandboxProviders.createOrUpdate({manifest:R$({type:n.type,apiKey:n.apiKey,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return kT(r.data.manifest)},updateSandboxProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.sandboxProviders.createOrUpdate({manifest:R$({type:lC,apiKey:r,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return kT(o.data.manifest)}}}var Xqt="/";function e5e(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 sf(e={}){return new uX({baseUrl:e5e(e.baseUrl??Xqt),...e.token===void 0?{}:{token:e.token},...e.fetch===void 0?{}:{fetch:e.fetch}})}function cb(e){const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid ISO timestamp: ${e}`);return t}function qqt(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 t5e(e={}){const t=e.client??sf(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:cb(r),endTimestamp:cb(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:cb(r),endTimestamp:cb(o),chartName:qqt(a)});return i}}}function q6(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 Qqt(e){return e.status==="running"||e.status==="paused"?{status:"running"}:pX(e)}function pX(e){switch(e.status){case"cancelled":return{status:"cancelled",reason:e.reason,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:q6(e.metrics)}};case"error":return{status:"error",message:e.message,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:q6(e.metrics)}};case"done":return{status:"done",completedAt:e.completedAt,requiredActions:e.requiredActions,...e.output==null?{}:{output:e.output},...e.metrics==null?{}:{metrics:q6(e.metrics)}}}}function n5e(e){return e.type==="turn.update"||e.type==="user.tool_approval"||e.type==="user.tool_response"||e.type==="user.tool_approval_policy"||e.type==="user.mcp_auth_continue"}function Jqt(e){if(!n5e(e))return e.type!=="turn.done"?{...e}:{...e,state:pX(e.state)}}function Zme(e){if(!n5e(e))return e.type!=="turn.done"?{...e}:{...e,state:pX(e.state)}}function r5e(e){const t=Jqt(e.event);return t===void 0?void 0:{turnId:e.turnId,event:t}}function eQt(e){return e}function tQt(e){return{name:e.name,preload:e.preload===!0}}function nQt(e){return{name:e.id??e.name,preload:e.preload===!0}}function cC(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(nQt)}}}function q1(e){const{mcpServers:t,skills:n,...r}=e;return{...r,...t?{mcpServers:t.map(eQt)}:{},...n?{skills:n.map(tQt)}:{}}}function gx(e){return{id:e.id,isMutable:e.agent.type==="inline",isCreateAgent:HZ(e.metadata),shared:e.shared,createdAt:e.createdAt,updatedAt:e.updatedAt,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:q1(e.agent.spec)}:{},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function rQt(e){if(e.metadata!==void 0)return e.metadata}function oQt(e){return typeof e=="string"?e:e.map(t=>({...t}))}function aQt(e){return e.map(t=>t.type==="user.message"?{...t,content:oQt(t.content)}:t)}function Xme(e){const{previousTurnId:t,input:n,state:r,...o}=e;return{...o,state:Qqt(r),...t===null?{}:{previousTurnId:t},...n===void 0?{}:{input:aQt(n)}}}function Np(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 qme(e,t){if(e===void 0)return t;const n=Number(e);return Number.isSafeInteger(n)&&n>=0?n:t}function iQt(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 sQt(e){const t=[];for(const n of e)if(n.type!=="user.mcp_auth_continue"){if(n.type==="user.message"){t.push({...n,content:iQt(n.content)});continue}t.push(n)}return t}function o5e(e={}){const t=e.client??sf(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=rQt(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 gx(o.data)}if(n.agentSpec!==void 0){const o=await t.sessions.create({agent:{spec:cC(n.agentSpec)},...r===void 0?{}:{metadata:r}});return gx(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}});return Np(r,gx)},async getSession({sessionId:n}){const r=await t.sessions.get(n);return gx(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,shared:a}){const i={...r===void 0?{}:{agent:{spec:cC(r)}},...o===void 0?{}:{title:o},...a===void 0?{}:{shared:a}},s=await t.sessions.update(n,i);return gx(s.data)},async*createTurn({sessionId:n,input:r,previousTurnId:o}){const a=await t.sessions.createTurnStream(n,{...r===void 0?{}:{input:sQt(r)},...o===void 0?{}:{previousTurnId:o}});let i=0;for await(const s of a.withMetadata()){const l=Zme(s.data);l!==void 0&&(yield{sequenceNumber:qme(s.id,i),event:l}),i+=1}},async*subscribeToTurn({sessionId:n,turnId:r,afterSequenceNumber:o}){const a=await t.sessions.subscribeToTurn(n,r,{...o===void 0?{}:{afterSequenceNumber:o}});let i=0;for await(const s of a.withMetadata()){const l=Zme(s.data);l!==void 0&&(yield{sequenceNumber:qme(s.id,i),event:l}),i+=1}},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 Np(a,Xme)},async getTurn({sessionId:n,turnId:r}){const o=await t.sessions.getTurn(n,r);return Xme(o.data)},async listEvents({sessionId:n,pageToken:r,lastTurnId:o,limit:a}){const i=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r},...o===void 0?{}:{lastTurnId:o},...a===void 0?{}:{limit:a}});return Np(i,r5e)}}}function lQt(e){var t;return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,lastActivityAt:e.updatedAt,isCreateAgent:HZ(e.metadata),isMutable:e.agent.type==="inline",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:q1(e.agent.spec)}:{},...((t=e.source)==null?void 0:t.type)==="schedule"?{sourceType:e.source.type}:{},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function a5e(e={}){const t=e.client??sf(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:q1(r.manifest)}},async getCodeSnippets({agentId:n}){const r=e5e(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:cb(n.startTimestamp)},...n.endTimestamp===void 0?{}:{endTimestamp:cb(n.endTimestamp)},...n.agentId===void 0||n.agentId.length===0?{}:{agentId:n.agentId},...n.createdByMe===void 0?{}:{createdByMe:n.createdByMe}});return Np(r,lQt)},async listSessionEvents({sessionId:n,pageToken:r,limit:o}){const a=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r},...o===void 0?{}:{limit:o}});return Np(a,r5e)}}}var i5e=50,cQt=100;function s5e(e){return Math.min(Math.max(e,1),cQt)}async function l5e({client:e,limit:t,pageToken:n,agentName:r}){const o=s5e(t),a=await e.agents.list({limit:o,...n===void 0||n===""?{}:{pageToken:n},...r===void 0?{}:{agentName:r}});return Np(a,i=>i)}async function I$(e){const t=[];let n;for(;;){const r=await l5e({client:e,limit:i5e,...n===void 0?{}:{pageToken:n}});if(t.push(...r.data),r.nextPageToken==null||r.nextPageToken==="")break;n=r.nextPageToken}return t}var fX="Authorization";function uQt({headerName:e,value:t}){return e.toLowerCase()!==fX.toLowerCase()||/^bearer\s+/i.test(t)?t:`Bearer ${t}`}function c5e(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 u5e(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:fX;return{type:"header",headers:{[r]:uQt({headerName:r,value:t})}}}function dQt(e){return{id:e.name,name:e.name,url:e.url,description:e.description,...e.logo===void 0?{}:{logo:e.logo},auth:c5e(e.auth)}}function pQt(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 d5e(e){const t=typeof e.name=="string"&&e.name!==""?e.name:"tool",n=typeof e.description=="string"?e.description:"",r=pQt(Reflect.get(e,"annotations"));return r===void 0?{id:t,name:t,description:n}:{id:t,name:t,description:n,annotations:r}}function Qm(e){const t=c5e(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 N$(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 M$(e){var r;const t=u5e(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 p5e(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 d,p,f;if(r.auth.type!=="header")return r.auth;const o=(d=r.auth.apiKey)==null?void 0:d.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(((p=a.manifest.auth)==null?void 0:p.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??fX,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(dQt),getConnector:async r=>{const o=await e.settings.mcpServers.get(r.id);return Qm(o.data)},listConnectors:async r=>{var s;const a=(await e.settings.mcpServers.list()).data.map(Qm),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(d5e),createConnector:async r=>{const o=await n({auth:r.auth}),a=await e.settings.mcpServers.create({manifest:M$({name:r.name,url:r.url,auth:o,description:r.description})});return Qm(a.data)},updateConnector:async r=>{const o=await n({id:r.id,auth:r.auth}),a=await e.settings.mcpServers.createOrUpdate({manifest:M$({name:r.id,url:r.url,auth:o,description:r.description})});return Qm(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 Qm(a.data)},deleteConnector:async({id:r})=>{await e.settings.mcpServers.delete(r)}}}async function f5e(e){return(await e.models.list()).data}async function h5e(e){return(await e.mcpServers.list()).data}async function g5e(e){return(await e.skills.list()).data}async function m5e(e){return(await e.server.getCapabilities()).data}function b5e(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 v5e({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]}}}}function fQt(e){return{name:e.name,agentId:e.id,description:e.description,agentSpec:q1(e.manifest),createdBySubject:e.createdBySubject}}function y5e(e={}){const t=e.client??sf(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=b5e(r);return n.data.map(a=>{const i=o.get(a.provider.name);return v5e(i===void 0?{model:a}:{model:a,logo:i})})},getSkills:async()=>(await g5e(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 h5e(t)).map(N$),getMcpConnector:async({connectorId:n})=>{const r=await t.mcpServers.get(n);return N$(r.data)},getMcpTools:async({connectorId:n})=>(await t.mcpServers.listTools(n)).data.flatMap(o=>typeof o.name=="string"&&o.name.trim()!==""?[d5e(o)]:[]),async searchAgents(n){var i;const r=s5e((n==null?void 0:n.limit)??i5e),o=(i=n==null?void 0:n.query)==null?void 0:i.trim(),a=await l5e({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(fQt),...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=cC(o),s=r==null?void 0:r.trim();if(a==="update"){const d=(await I$(t)).find(p=>p.name===n);return d?(await t.agents.update(d.id,{...s?{description:s}:{},manifest:i}),{agentId:d.id}):{}}return{agentId:(await t.agents.create({name:n,description:s||n,manifest:i})).data.id}},async deleteAgent({agentName:n}){const o=(await I$(t)).find(a=>a.name===n);o&&await t.agents.delete(o.id)}}}function x5e(e){return{id:e.modelId,name:e.name,properties:e.properties}}function hQt(e){return{modelId:e.id,name:e.name,properties:e.properties??{}}}function ET(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(x5e)}}function w5e(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(x5e)}}var gQt=[...Object.values(DWt),"custom"];function mQt(e){return gQt.includes(e)}function O$(e){var o;const t=e.models.map(hQt);if(!mQt(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 _5e(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(w5e),listModelProviders:async()=>(await e.settings.modelProviders.list()).data.map(ET),createModelProvider:async n=>{const r=await t({type:n.type,apiKey:n.apiKey}),o=await e.settings.modelProviders.create({manifest:O$({type:n.type,name:n.name,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return ET(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:O$({type:n.type,name:n.id,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return ET(o.data)},deleteModelProvider:async({id:n})=>{await e.settings.modelProviders.delete(n)}}}function bQt(e){return{id:e.name,name:e.name,description:e.description,repoURL:e.url,path:e.path??"",ref:e.ref}}function S5e(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 k5e(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 E5e(e){return{getSkillCatalog:async()=>(await e.catalogs.skills.list()).data.map(bQt),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=>k5e(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:S5e(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 uC="parallel",vQt="Parallel";function T5e(e){return e===uC?vQt:e}function A5e(e){return{id:e.type,name:T5e(e.type),type:e.type}}function TT(e){return{id:e.type,name:T5e(e.type),catalogId:e.type,isConnected:!0}}function C5e({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 j$({type:e,apiKey:t}){if(e!==uC)throw new Error(`Unsupported web-search provider type: ${e}`);return{type:uC,auth:{apiKey:t}}}function R5e(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(A5e),listWebSearchProviders:async n=>{let r;try{const o=await e.settings.webSearchProviders.get();r=[TT(o.data.manifest)]}catch(o){if(o instanceof Sn)r=[];else throw o}return C5e({providers:r,query:n==null?void 0:n.query})},createWebSearchProvider:async n=>{const r=await e.settings.webSearchProviders.createOrUpdate({manifest:j$({type:n.type,apiKey:n.apiKey})});return TT(r.data.manifest)},updateWebSearchProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.webSearchProviders.createOrUpdate({manifest:j$({type:uC,apiKey:r})});return TT(o.data.manifest)}}}function I5e(e={}){const t=e.client??sf(e);return{listPermissions:async n=>t.internal.listPermissions(n)}}var yQt=25,xQt=1e3;function Qme(e){return e instanceof Date?e.toISOString():e}function wQt(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 Jme(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 DE(e){return{id:e.id,name:e.name,description:e.description,status:e.status,statusReason:e.statusReason,manifest:wQt(e.manifest),createdBySubject:e.createdBySubject,createdAt:Qme(e.createdAt),updatedAt:Qme(e.updatedAt)}}function N5e(e){const{client:t}=e;return{async listEnvironments(n){const r=Math.min(Math.max((n==null?void 0:n.limit)??yQt,1),xQt),o=await t.sandboxEnvironments.list({limit:r,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken}});return Np(o,DE)},async getEnvironment({name:n}){const{data:r}=await t.sandboxEnvironments.get(n);return DE(r)},async createEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.create({manifest:Jme(n)});return DE(r)},async createOrUpdateEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.createOrUpdate({manifest:Jme(n)});return DE(r)},async deleteEnvironment({name:n}){await t.sandboxEnvironments.delete(n)}}}var ebe=25;async function LE(e){const t=await I$(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 tbe(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 _Qt(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 SQt(e){return e.status??"active"}function zE(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:SQt(e.manifest),lastRunAt:null,createdBySubject:e.createdBySubject}}function nbe(e){return{task:e.task,cron:e.cron,timezone:e.timezone??"UTC",status:e.status??"active"}}function rbe(e){return e instanceof Date?e.toISOString():e}function obe(e){return{id:e.id,scheduleId:e.scheduleId,name:e.name,scheduledFor:rbe(e.scheduledFor),status:e.status,reason:e.reason,triggeredAt:e.triggeredAt==null?null:rbe(e.triggeredAt),triggeredBy:e.createdBySubject.subjectDisplayName||e.createdBySubject.subjectId}}function M5e(e){const{client:t}=e;return{async listSchedules(n){const r=await LE(t),o=_Qt(n),a=o.length===0?void 0:o.map(l=>tbe(l,r)).join(","),i=Math.min(Math.max((n==null?void 0:n.limit)??ebe,1),ebe),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 Np(s,l=>zE(l,r))},async getSchedule({id:n}){const r=await LE(t),{data:o}=await t.schedules.get(n);return zE(o,r)},async createSchedule(n){const r=await LE(t),o=tbe(n.agentId,r),{data:a}=await t.schedules.create({agentName:o,name:n.name,manifest:nbe(n)});return zE(a,r)},async updateSchedule(n){const r=await LE(t),{data:o}=await t.schedules.update(n.id,{name:n.name,manifest:nbe(n)});return zE(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(obe)},async createScheduleRun(n){const{data:r}=await t.schedules.createRun({scheduleId:n.scheduleId});return obe(r)}}}function kQt(e={}){const{catalog:t,permissions:n,...r}=e,o=sf(r),a=t??{modelCatalog:_5e(o),connectorCatalog:p5e(o),skillCatalog:E5e(o),sandboxCatalog:J3e(o),webSearchCatalog:R5e(o)};return sWt({chatServer:o5e({client:o}),...y5e({client:o}),catalog:a,sessions:a5e({...r,client:o}),metrics:t5e({...r,client:o}),schedules:M5e({client:o}),sandboxEnvironments:N5e({client:o}),permissions:n??I5e({client:o}),getMe:async()=>{const{data:i}=await o.auth.me();return{tenantId:i.tenantId}}})}const EQt=Object.freeze(Object.defineProperty({__proto__:null,configFromHarness:dX,createConnectorCatalog:p5e,createHarnessAgentMetricsServer:t5e,createHarnessAgentSessionsServer:a5e,createHarnessBuilderServer:y5e,createHarnessChatServer:o5e,createHarnessPermissionsServer:I5e,createModelProviderCatalog:_5e,createSandboxEnvironmentServer:N5e,createSandboxProviderCatalog:J3e,createScheduleServer:M5e,createSkillCatalog:E5e,createTrueForgeAgentUIServer:kQt,createTrueForgeClient:sf,createWebSearchProviderCatalog:R5e,filterUiSandboxProviders:Q3e,filterUiWebSearchProviders:C5e,getCapabilities:m5e,isDaytonaSandboxConfig:Zqt,listConfiguredMcpServers:h5e,listModels:f5e,listSkills:g5e,modelProviderLogosByName:b5e,toHarnessAgentSpec:cC,toHarnessAuth:u5e,toHarnessConnectorManifest:M$,toHarnessModelProvider:O$,toHarnessSandboxManifest:R$,toHarnessSkillManifest:S5e,toHarnessWebSearchManifest:j$,toModelSelection:v5e,toUiAgentSpec:q1,toUiCatalogModelProviderEntry:w5e,toUiConnector:Qm,toUiConnectorFromReadEntry:N$,toUiModelProvider:ET,toUiSandboxCatalogEntry:q3e,toUiSandboxProvider:kT,toUiSkill:k5e,toUiWebSearchCatalogEntry:A5e,toUiWebSearchProvider:TT},Symbol.toStringTag,{value:"Module"})),Ee="u">typeof window?window:void 0,Da="u">typeof globalThis?globalThis:Ee,$o=Da==null?void 0:Da.navigator,$e=Da==null?void 0:Da.document,Gr=Da==null?void 0:Da.location,K_=Da==null?void 0:Da.fetch,hX=Da!=null&&Da.XMLHttpRequest&&"withCredentials"in new Da.XMLHttpRequest?Da.XMLHttpRequest:void 0,abe=Da==null?void 0:Da.AbortController,TQt=Da==null?void 0:Da.CompressionStream,Qa=$o==null?void 0:$o.userAgent;function O5e(){return!(!Ee||Ee.navigator.onLine===!1)}const mx=typeof globalThis<"u"?globalThis:Ee;mx&&typeof self>"u"&&(mx.self=mx),mx&&typeof File>"u"&&(mx.File=function(){});const Ct=Ee??{},AQt="0.9.0",Fu={DEBUG:!1,LIB_VERSION:AQt,LIB_NAME:"browser-common"};var uc=(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})({}),P$=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const CQt=["$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"],RQt=["token"];function Dt(e,t){return e.indexOf(t)!==-1}const xN=function(e){return e.trim()},D$=function(e){return e.replace(/^\$/,"")};function j5e(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 P5e=Object.prototype,gX=P5e.hasOwnProperty,wN=P5e.toString,Lt=Array.isArray||function(e){return wN.call(e)==="[object Array]"},zo=e=>typeof e=="function",vn=e=>e===Object(e)&&!Lt(e),_i=e=>{if(vn(e)){for(const t in e)if(gX.call(e,t))return!1;return!0}return!1},je=e=>e===void 0,fn=e=>wN.call(e)=="[object String]",gw=e=>fn(e)&&e.trim().length===0,Kr=e=>e===null,Kt=e=>je(e)||Kr(e),to=e=>wN.call(e)=="[object Number]"&&e==e,wu=e=>to(e)&&e>0,ni=e=>wN.call(e)==="[object Boolean]",IQt=e=>Dt(CQt,e),NQt=e=>Dt(RQt,e);function D5e(e){return e===null||typeof e!="object"}function dC(e,t){return{}.toString.call(e)===`[object ${t}]`}function zy(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 L5e(e,Error)}}function mX(e){return"u">typeof Event&&L5e(e,Event)}function L5e(e,t){try{return e instanceof t}catch{return!1}}const MQt=[!0,"true",1,"1","yes"],Q6=e=>Dt(MQt,e),OQt=[!1,"false",0,"0","no"];function ibe(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 Pr(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(l){ibe(a,r,o,i,s,"next",l)}function s(l){ibe(a,r,o,i,s,"throw",l)}i(void 0)})}}const jQt=["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"],sbe=function(e,t=[]){if(!e)return!1;const n=e.toLowerCase();return jQt.concat(t).some(r=>{const o=r.toLowerCase();return n.indexOf(o)!==-1})};function Sc(e,t,n,r,o){return t>n&&(r.warn("min cannot be greater than max."),t=n),to(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),Sc(o??n,t,n,r))}var PQt=class{constructor(e){this.C={},this.I=e.I,this.R=Sc(e.bucketSize,0,100,e.A),this.$=Sc(e.refillRate,0,this.R,e.A),this.O=Sc(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 Dv="Mobile",Y_="Android",pC="Tablet",z5e="Android Tablet",$5e="iPad",F5e="Apple Watch",AT="Safari",_N="BlackBerry",U5e="Samsung Internet",CT="Chrome",B5e="Chrome iOS",H5e="Internet Explorer",V5e="Internet Explorer Mobile",G5e="Opera",W5e="Microsoft Edge",RT="Firefox",K5e="Firefox iOS",fC="Nintendo",hC="PlayStation",SN="Xbox",Y5e="Android Mobile",Z5e="Mobile Safari",J6="Windows",X5e="Windows Phone",lbe="Nokia",L$="Ouya",DQt="Generic "+Dv.toLowerCase(),q5e="Generic "+pC.toLowerCase(),z$="Konqueror",Q5e="Oculus Browser",J5e="Vivaldi",e4e="Yandex",t4e="Whale",n4e="DuckDuckGo",r4e="Pale Moon",o4e="Waterfox",$$="Brave",a4e="Claude",i4e="Codex",s4e="ChatGPT",l4e="Google Search App",eL=new RegExp("Version/(\\d+(\\.\\d+)?)"),tL=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),LQt=new RegExp(SN,"i"),zQt=new RegExp("PlayStation \\w+","i"),$Qt=new RegExp("Nintendo \\w+","i"),bX=new RegExp("BlackBerry|PlayBook|BB10","i"),FQt={"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"},c4e=function(e,t,n,r){return t=t||"",(function(a){return a!=null&&a.brave?$$:null})(n)||(r!=null&&r.detectGoogleSearchApp&&Dt(e,"GSA/")?l4e:Dt(e," OPR/")&&Dt(e,"Mini")?"Opera Mini":Dt(e," OPR/")?G5e:bX.test(e)?_N:Dt(e,"IEMobile")||Dt(e,"WPDesktop")?V5e:Dt(e,"OculusBrowser")?Q5e:Dt(e,"SamsungBrowser")?U5e:Dt(e,"Edge")||Dt(e,"Edg/")?W5e:Dt(e,"Vivaldi/")?J5e:Dt(e,"YaBrowser/")?e4e:Dt(e,"Whale/")?t4e:Dt(e,"DuckDuckGo/")||Dt(e,"Ddg/")?n4e:Dt(e,"Claude/")?a4e:Dt(e,"Codex/")?i4e:Dt(e,"ChatGPT/")?s4e:Dt(e,"FBIOS")?"Facebook Mobile":Dt(e,"UCWEB")||Dt(e,"UCBrowser")?"UC Browser":Dt(e,"CriOS")?B5e:Dt(e,"CrMo")||Dt(e,CT)?CT:Dt(e,Y_)&&Dt(e,AT)?Y5e:Dt(e,"FxiOS")?K5e:Dt(e.toLowerCase(),z$.toLowerCase())?z$:Dt(e,"Brave/")?$$:((a,i)=>i&&Dt(i,"Apple")||(function(s){return Dt(s,AT)&&!Dt(s,CT)&&!Dt(s,Y_)})(a))(e,t)?Dt(e,Dv)?Z5e:AT:Dt(e,"PaleMoon/")?r4e:Dt(e,"Waterfox/")?o4e:Dt(e,RT)?RT:Dt(e,"MSIE")||Dt(e,"Trident/")?H5e:Dt(e,"Gecko")?RT:"")},UQt={[V5e]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[W5e]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[CT]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[B5e]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[AT]:[eL],[Z5e]:[eL],[G5e]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[RT]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[K5e]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[z$]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[_N]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),eL],[Y5e]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[U5e]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Q5e]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[J5e]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[e4e]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[t4e]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[$$]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[a4e]:[tL],[i4e]:[tL],[s4e]:[tL],[n4e]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[r4e]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[o4e]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[l4e]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[H5e]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},BQt=function(e,t,n,r){const o=c4e(e,t,n,r),a=UQt[o];if(je(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},cbe=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[SN,e&&e[1]||""]],[new RegExp(fC,"i"),[fC,""]],[new RegExp(hC,"i"),[hC,""]],[bX,[_N,""]],[new RegExp(J6,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[X5e,""];if(new RegExp(Dv).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let r=FQt[n[1]]||"";return/arm/i.test(t)&&(r="RT"),[J6,r]}return[J6,""]}],[/((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=je(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Y_,[e[2],e[3],e[4]||"0"].join(".")]:[Y_,""]],[/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",""]]],u4e=function(e){for(let t=0;cbe.length>t;t++){const[n,r]=cbe[t],o=n.exec(e),a=o&&(zo(r)?r(o,e):r);if(a)return a}return["",""]},d4e=function(e){return $Qt.test(e)?fC:zQt.test(e)?hC:LQt.test(e)?SN:new RegExp(L$,"i").test(e)?L$:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?X5e:/iPad/.test(e)?$5e:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?F5e:bX.test(e)?_N:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(lbe,"i").test(e)?lbe:/(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(Dv).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)?Y_:z5e:new RegExp("(pda|Mobile)","i").test(e)?DQt:new RegExp(pC,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?q5e:""},HQt=function(e,t){var n;const r=d4e(e);return r===$5e||r===z5e||r==="Kobo"||r==="Kindle Fire"||r===q5e?pC:r===fC||r===SN||r===hC||r===L$?"Console":r===F5e?"Wearable":r?Dv:(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)?Dv:pC:"Desktop";var o,a,i},nL=/\bFBAV\/(\d+(?:\.\d+)*)/i,ube=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",nL],[/\bFBAN\/EMA\b/i,"Facebook Lite",nL],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",nL],[/\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"]],F$="[Truncated]",Q1="[Unserializable]";function Pb(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 p4e(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=Q1}Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0,configurable:!0})}return e}const IT=3e5;var f4e=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,IT);if(!t)return this.ts=n,void(this.es=n+r);this.es=Math.max(this.es,Math.min(n+r,this.ts+IT))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(IT,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 VQt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function dbe(e,t){return typeof(n=e)=="string"&&VQt.test(n)?e:t();var n}function h4e(e,t){const n=new Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function Up(e){return e&&e.split("#")[0]}function pbe(e){try{return e()}catch{return}}function g4e(e,t){const n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function fbe(e,t,n){return m4e.apply(this,arguments)}function m4e(){return(m4e=Pr(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((o,a)=>{r=g4e(()=>{try{n==null||n(),o()}catch(i){a(i)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}let $E,hbe,rL;function GQt(e){const t=globalThis._posthogChunkIds;if(!t)return;const n=Object.keys(t);return rL&&n.length===hbe||(hbe=n.length,rL=n.reduce((r,o)=>{$E||($E={});const a=$E[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,d=t[o];if(c&&d){r[c]=d,$E[o]=[c,d];break}}}return r},{})),rL}function mw(e){return mw=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},mw(e)}function WQt(e,t,n){return(t=(function(r){var o=(function(a){if(mw(a)!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var s=i.call(a,"string");if(mw(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)})(r);return mw(o)=="symbol"?o:o+""})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gbe(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?gbe(Object(n),!0).forEach(function(r){WQt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gbe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var KQt=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 Pr(function*(){for(const n of e)n.stacktrace&&n.stacktrace.frames&&Lt(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 Pr(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},d={type:o.type,value:o.value,mechanism:c};o.stack&&(d.stacktrace={type:"raw",frames:o.stack}),n.push(d),o.cause&&r(o.cause,l,"cause");for(const p of(s=o.errors)!==null&&s!==void 0?s:[])r(p,l,"member")};return r(e),n}buildParsingContext(e){var t;return{chunkIdMap:GQt(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(zy(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 Lt(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,m,b=0)=>{const y=d(m,b),x=y.apply;if(y.apply=A=>{s.push(f);try{return x(A)}finally{s.pop()}},b>4||b>0&&s.indexOf(f)!==-1)return this.coerceFallback(y);const _=typeof f=="object"&&f!==null||typeof f=="function";if(b===0&&r>=50||_&&i.has(f))return;_&&i.add(f),b===0&&r++;const k=this.getAggregateErrors(f);let E,T;a||(a=!!k);try{if(E=this.applyCoercers(f,y),!E)throw l}catch(A){if(A===l)return void(b===0&&r--);if(!a)throw A;E=this.coerceFallback(y)}if(!k||r>=50)return E;try{T=k.length}catch{return E}if(!Number.isInteger(T)||0>T||T>4294967295)return E;const C=[];for(let A=0;50>r&&1e3>o&&T>A;A++){let R;o++;try{R=y.next(k[A])}catch{r++,R=this.coerceFallback(d(m+1))}R&&C.push(R)}return ce(ce({},E),{},{errors:C})},d=(f,m=0)=>ce(ce({},t),{},{syntheticException:f==0?t.syntheticException:void 0,mechanism:f==0?e:{},apply(b){const y=c(b,f,m+1);if(!y)throw l;return y},next:b=>c(b,f+1)}),p=d(n);return ce(ce({},p),{},{apply:f=>{var m;return(m=c(f,n))!==null&&m!==void 0?m:this.coerceFallback(p)}})}};const YQt=/^([a-z][a-z0-9.+-]+):/i,ZQt=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function XQt(e){if(!e||e==="<anonymous>")return!1;const t=YQt.exec(e);return!t||ZQt.includes(t[1].toLowerCase())}function U$(e,t,n,r,o){const a={platform:e,filename:t,function:n==="<anonymous>"?"?":n,in_app:XQt(t)};return je(r)||(a.lineno=r),je(o)||(a.colno=o),a}const b4e=(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]},qQt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,QQt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,JQt=/\((\S*)(?::(\d+))(?::(\d+))\)/,eJt=(e,t)=>{const n=qQt.exec(e);if(n){const[,o,a,i]=n;return U$(t,o,"?",+a,+i)}const r=QQt.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){const i=JQt.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}const[o,a]=b4e(r[1]||"?",r[2]);return U$(t,a,o,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},tJt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,nJt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,rJt=(e,t)=>{const n=tJt.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const a=nJt.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]=b4e(o,r),U$(t,r,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},mbe=/\(error: (.*)\)/;function vX(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function oJt(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(!vX(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 aJt(e,t){const n=t.start+t.length,r=y4e(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function v4e(e,t){let n=t.start;for(;n>0&&vX(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function y4e(e,t){const n=t.start+t.length;let r=n;for(;e.length>r&&vX(e[r],e[r-t.length]);)r++;return r-n}function iJt(e,t){const n=t[0];let r=e.length-(n?v4e(e,n):0);for(const o of t)r-=y4e(e,o);return r}function sJt(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 lJt=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const n=fn(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 dC(e,"DOMException")}isDOMError(e){return dC(e,"DOMError")}},cJt=class{match(e){return zy(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}}},uJt=class{match(e){return!!dC(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 fn(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(fn(r.filename)&&r.filename.length!==0&&o!==0)return`Error
|
|
998
|
+
${b}`:b}else if(m.startsWith(jE)){const b=m.slice(jE.length).trim();b.includes("\0")||(r=b)}else if(m.startsWith(PE)){const b=m.slice(PE.length).trim(),y=parseInt(b,10);!Number.isNaN(y)&&String(y)===b&&(a=y)}}}if(c!=null){const p=await this.dispatchSseEvent(c,l);p!=null&&(yield{data:p,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 d=this.reconnect;if(d==null||o==null)return;try{const p=await d(o);if(p==null){n=this.createEmptyStream();continue}n=p}catch{n=this.createEmptyStream()}}}async dispatchSseEvent(t,n){return this.streamTerminator!=null&&t.includes(this.streamTerminator)?null:this.parse(this.injectDiscriminator(vh(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:wKt,r=Math.min(n,_Kt),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){if(this.eventDiscriminator==null||n==null||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}):k$.type==="node"&&typeof t<"u"&&(n+=Buffer.isBuffer(t)?t:Buffer.from(t)),n}}function Bme(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 Rn(e){if(e===null)return"null";switch(typeof e){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:e=String(e);break}return encodeURIComponent(e)}function ht(){return new SKt}class SKt{constructor(){this.parts=new Map}add(t,n,r){if(n==null)return this;const o=iC({[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=iC({[n]:r},{arrayFormat:"repeat"});o.length>0&&this.parts.set(n,o)}return this}build(){return[...this.parts.values()].join("&")}}function xp(e,t,n){if(e==null)return e;const r=t.split(".");if(r.length===0)return e;let o=e;for(let i=0;i<r.length-1;i++){const s=r[i];s!=null&&((!o[s]||typeof o[s]!="object")&&(o[s]={}),o=o[s])}const a=r[r.length-1];return a==null||(o[a]=n),e}const A$="token";class C${constructor(t){this.options=t}static canCreate(t){return(t==null?void 0:t[A$])!=null}async getAuthRequest({endpointMetadata:t}={}){const n=await Ne.get(this.options[A$]);return n==null?{headers:{}}:{headers:{Authorization:`Bearer ${n}`}}}}(e=>{e.AUTH_SCHEME="BearerAuth",e.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${A$}' when initializing the client`;function t(n){return new e(n)}e.createInstance=t})(C$||(C$={}));function gt(...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 kKt(e){const t=gt({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@truefoundry/trueforge-sdk","X-Fern-SDK-Version":"0.179.0","User-Agent":"@truefoundry/trueforge-sdk/0.179.0","X-Fern-Runtime":k$.type,"X-Fern-Runtime-Version":k$.version},e==null?void 0:e.headers);return{...e,logging:VZ(e==null?void 0:e.logging),headers:t}}function Nr(e){const t=kKt(e);if(e.auth===!1)return t.authProvider=new WOe,t;if(e.auth!=null){if(typeof e.auth=="function")return t.authProvider={getAuthRequest:e.auth},t;if(LWt(e.auth))return t.authProvider=e.auth,t;Object.assign(t,e.auth)}const n=EKt(t);return t.authProvider??(t.authProvider=new C$(n)),t}function EKt(e){return{...e,authProvider:new WOe}}function Yr(e,t){return t==null?e:e==null?{...t}:typeof e=="object"&&!Array.isArray(e)?{...e,...t}:e}function bt(e,t,n,r){switch(e.reason){case"non-json":throw new at({statusCode:e.statusCode,body:e.rawBody,rawResponse:t});case"body-is-null":throw new at({statusCode:e.statusCode,rawResponse:t});case"timeout":throw new OWt(`Timeout exceeded when calling ${n} ${r}.`,{cause:e.cause});case"unknown":throw new at({message:e.errorMessage,rawResponse:t,cause:e.cause});default:throw new at({message:"Unknown error",rawResponse:t})}}const TKt=ue({content:ie(),type:ct("user.message")}),AKt=Ir([ct("@all"),ct("@write"),ct("@destructive"),ie()]),K6=Ir([ct("@all"),ct("@read-only"),ie()]),CKt=ue({disableTools:fe("disable_tools",yt(K6).optional()),enableTools:fe("enable_tools",yt(K6).optional()),name:ie(),preload:Ho().optional(),preloadTools:fe("preload_tools",yt(K6).optional()),requireApprovalForTools:fe("require_approval_for_tools",yt(AKt).optional())}),RKt=ue({maxTokens:fe("max_tokens",zt().optional()),parallelToolCalls:fe("parallel_tool_calls",Ho().optional()),reasoningEffort:fe("reasoning_effort",ie().optional()),temperature:zt().optional(),topK:fe("top_k",zt().optional()),topP:fe("top_p",zt().optional())}).passthrough(),IKt=ue({name:ie(),params:RKt.optional()}),NKt=ue({type:ct("json_object")}).passthrough(),MKt=ue({description:ie().optional(),name:ie(),schema:Bl(ie(),vN()).optional(),strict:Ho().optionalNullable()}).passthrough(),OKt=ue({jsonSchema:fe("json_schema",MKt),type:ct("json_schema")}).passthrough(),jKt=ue({type:ct("text")}).passthrough(),PKt=Ir([NKt,OKt,jKt]),DKt=ue({enabled:Ho().optional()}),LKt=ue({type:ct("input_tokens"),value:zt()}),zKt=ue({enabled:Ho().optional(),trigger:LKt.optional()}),$Kt=ue({enabled:Ho().optional()}),FKt=ue({compaction:zKt.optional(),largeToolResponse:fe("large_tool_response",$Kt.optional())}),UKt=ue({enabled:Ho().optional()}),BKt=ue({enabled:Ho().optional()}),HKt=ue({enabled:Ho(),environmentName:fe("environment_name",ie().optional()),fileDownloads:fe("file_downloads",Ho().optional())}),VKt=ue({enabled:Ho().optional()}),GKt=ue({askUserQuestions:fe("ask_user_questions",DKt.optional()),contextManagement:fe("context_management",FKt.optional()),dynamicSubAgents:fe("dynamic_sub_agents",UKt.optional()),generativeUi:fe("generative_ui",BKt.optional()),iterationLimit:fe("iteration_limit",zt().optional()),sandbox:HKt.optional(),webSearch:fe("web_search",VKt.optional())}),WKt=ue({name:ie(),preload:Ho().optional()}),Y1=ue({config:GKt.optional(),instructions:ie().optional(),mcpServers:fe("mcp_servers",yt(CKt).optional()),messages:yt(TKt).optional(),model:IKt,responseFormat:fe("response_format",PKt.optional()),skills:yt(WKt).optional()}),so=ie(),KKt=ue({description:ie(),manifest:Y1,name:so}),YKt=ue({description:ie().optional(),manifest:Y1}),a3e=ua(["agent","schedule","session","tenant"]),ZKt=ue({resourceIds:fe("resource_ids",yt(ie())),resourceType:fe("resource_type",a3e)}),XKt=ue({environmentVersionId:fe("environment_version_id",ie())}),qKt=ue({scheduleRunId:fe("schedule_run_id",ie())}),QKt=ue({name:so}),i3e=ue({spec:Y1}),s3e=Ir([QKt,i3e]),JKt=ue({id:ie(),runId:fe("run_id",ie()),type:ct("schedule")}),eYt=ue({agent:s3e,externalId:fe("external_id",ie()),source:JKt.optional()}),l3e=ue({buildScript:fe("build_script",ie().optional()),type:ct("build")}),tYt=ue({env:ie(),hosts:yt(ie()),value:ie()}),c3e=ue({domainAllowList:fe("domain_allow_list",ie().optional()),networkBlockAll:fe("network_block_all",Ho().optional()),secrets:yt(tYt).optional()}),u3e=ue({cpu:zt().optional(),disk:zt().optional(),memory:zt().optional()}),d3e=ue({description:ie().optional(),environmentVariables:fe("environment_variables",Bl(ie(),ie()).optional()),image:l3e.optional(),name:so,networking:c3e.optional(),resources:u3e.optional()}),nYt=ue({manifest:d3e}),rYt=ue({manifest:d3e}),oYt=ie(),aYt=ua(["active","paused"]),iYt=ie(),KZ=ue({cron:oYt,status:aYt.optional(),task:ie(),timezone:iYt.optional()}),sYt=ue({agentName:fe("agent_name",so),manifest:KZ,name:so}),lYt=ue({scheduleId:fe("schedule_id",ie())}),cYt=ue({manifest:KZ,name:so}),uYt=ue({}),YZ=Bl(ie(),ie()),dYt=ue({agent:s3e,metadata:YZ.optional()}),pYt=ue({type:ct("user.mcp_auth_continue")}),fYt=ue({status:ct("allow")}),hYt=ue({reason:ie().optional(),status:ct("deny")}),p3e=Ir([fYt,hYt]),f3e=ue({approval:p3e,threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_approval")}),gYt=ue({expireAt:fe("expire_at",ie().optional()),type:ct("allow_session")}),h3e=gYt,g3e=ue({action:h3e,name:ie(),serverName:fe("server_name",ie())}),mYt=ue({policies:yt(g3e),type:ct("user.tool_approval_policy")}),m3e=ue({content:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_response")}),bYt=Ir([pYt,f3e,mYt,m3e]),vYt=ue({events:yt(bYt)}),b3e=Ir([ct("auto"),ct("none"),ie()]),yYt=ue({data:ie(),name:ie(),type:ct("file")}),xYt=ue({text:ie(),type:ct("text")}),wYt=Ir([yYt,xYt]),_Yt=Ir([ie(),yt(wYt)]),SYt=ue({content:_Yt,type:ct("user.message")}),yN=Ir([SYt,f3e,m3e]),kYt=ue({input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",b3e.optional())}),EYt=ue({input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",b3e.optional())}),TYt=ue({agent:i3e.optional(),metadata:YZ.optional(),shared:Ho().optional(),title:ie().optional()}),AYt=ue({type:ct("dcr")}),CYt=ue({headers:Bl(ie(),ie()),type:ct("header")}),ZZ=Ir([AYt,CYt]),RYt=ue({auth:ZZ.optional(),description:ie(),name:so,type:ct("remote"),url:ie()}),IYt=ue({auth:ZZ.optional(),description:ie(),name:so,type:ct("truefoundry"),url:ie()}),XZ=Ir([RYt,IYt]),NYt=ue({manifest:XZ}),MYt=ue({manifest:XZ}),v3e=ua(["none","minimal","low","medium","high","xhigh","max"]),qZ=ue({contextLength:fe("context_length",zt().optional()),maxOutputTokens:fe("max_output_tokens",zt().optional()),reasoningEfforts:fe("reasoning_efforts",yt(v3e).optional())}),Zc=ue({modelId:fe("model_id",ie()),name:so,properties:qZ}),Xc=ue({apiKey:fe("api_key",ie())}),OYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("alibaba")}),jYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("anthropic")}),PYt=ue({auth:Xc.optional(),baseUrl:fe("base_url",ie()),models:yt(Zc),name:so,type:ct("custom")}),DYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("fireworks")}),LYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("google-gemini")}),zYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("moonshot")}),$Yt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("openai")}),FYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("together")}),UYt=ue({auth:Xc.optional(),baseUrl:fe("base_url",ie()),models:yt(Zc),type:ct("truefoundry")}),BYt=ue({auth:Xc,baseUrl:fe("base_url",ie().optional()),models:yt(Zc),type:ct("zai")}),QZ=Ir([OYt,jYt,PYt,DYt,LYt,zYt,$Yt,FYt,UYt,BYt]),HYt=ue({manifest:QZ}),VYt=ue({manifest:QZ}),GYt=ue({apiKey:fe("api_key",ie())}),y3e=ue({auth:GYt,autoArchiveIntervalInMinutes:fe("auto_archive_interval_in_minutes",zt()),autoDeleteIntervalInMinutes:fe("auto_delete_interval_in_minutes",zt()),autoStopIntervalInMinutes:fe("auto_stop_interval_in_minutes",zt()),execTimeoutMs:fe("exec_timeout_ms",zt()),type:ct("daytona")}),WYt=ue({manifest:y3e}),KYt=ue({description:ie(),name:so,path:ie().optional(),ref:ie(),type:ct("git"),url:ie()}),YYt=ue({description:ie(),displayName:fe("display_name",ie()),name:ie(),repositoryName:fe("repository_name",ie()),type:ct("truefoundry"),version:zt()}),JZ=Ir([KYt,YYt]),ZYt=ue({manifest:JZ}),XYt=ue({manifest:JZ}),qYt=ue({apiKey:fe("api_key",ie())}),x3e=ue({auth:qYt,type:ct("parallel")}),QYt=ue({manifest:x3e}),JYt=ue({id:ie()}),eZt=ue({createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie().nullable())}),tZt=ue({authUrl:fe("auth_url",ie()),id:ie(),name:ie()}),eX=ue({mcpServers:fe("mcp_servers",yt(tZt)),type:ct("mcp.auth_required")}).extend(eZt),w3e=ue({id:ie(),sourceEventId:fe("source_event_id",ie())}),tX=ue({createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(w3e)),type:ct("tool.approval_required")}),nX=ue({createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(w3e)),type:ct("tool.response_required")}),nZt=Ir([eX,tX,nX]),Z1=ue({subjectDisplayName:fe("subject_display_name",ie()),subjectId:fe("subject_id",ie()),subjectType:fe("subject_type",ie())}),_3e=ue({createdBySubject:fe("created_by_subject",Z1),description:ie(),id:ie(),manifest:Y1,name:so}),rZt=ue({nonStream:fe("non_stream",ie()),stream:ie()}),oZt=ue({icon:ie(),labelName:fe("label_name",ie()),language:ie(),sampleCode:fe("sample_code",rZt)}),aZt=ue({baseUrl:fe("base_url",ie()),snippets:yt(oZt)}),iZt=ue({input:ie(),model:ie().optional(),name:ie(),type:ct("dynamic")}),S3e=ue({threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie())}),sZt=ua(["authenticated","auth_required","not_required"]),rX=ue({authorizationUrl:fe("authorization_url",ie().optional()),status:sZt}),lZt=ue({type:ct("header")}),cZt=ue({type:ct("dcr")}),uZt=Ir([cZt,lZt]),k3e=ue({auth:uZt.optional(),authStatus:fe("auth_status",rX),name:so,url:ie()}),dZt=ue({name:ie()}),pZt=ue({modelId:fe("model_id",ie()),name:ie(),properties:qZ,provider:dZt}),fZt=ue({description:ie(),metadata:Bl(ie(),ie()).optional(),name:ie()}),hZt=ue({}),gZt=ue({enabled:Ho()}),mZt=ue({enabled:Ho()}),bZt=ue({enabled:Ho(),reason:ie().optional()}),vZt=ue({enabled:Ho()}),yZt=ue({sandbox:gZt,settings:mZt,skill:bZt,webSearch:fe("web_search",vZt)}),xZt=ue({supportedReasoningEfforts:fe("supported_reasoning_efforts",yt(v3e)),type:ct("custom")}),wZt=ct("remote"),_Zt=ue({auth:ZZ.optional(),description:ie(),logo:ie().optional(),name:so,type:wZt,url:ie()}),SZt=ue({modelId:fe("model_id",ie()),name:so,properties:qZ}),kZt=ua(["openai","anthropic","google-gemini","fireworks","zai","moonshot","alibaba","together"]),EZt=ue({logo:ie().optional(),models:yt(SZt),type:kZt}),TZt=Ir([EZt,xZt]),AZt=ue({autoArchiveIntervalInMinutes:fe("auto_archive_interval_in_minutes",zt()),autoDeleteIntervalInMinutes:fe("auto_delete_interval_in_minutes",zt()),autoStopIntervalInMinutes:fe("auto_stop_interval_in_minutes",zt()),execTimeoutMs:fe("exec_timeout_ms",zt()),type:ct("daytona")}),CZt=ct("git"),RZt=ue({description:ie(),name:so,path:ie().optional(),ref:ie(),type:CZt,url:ie()}),IZt=ue({type:ct("parallel")}),NZt=ue({arguments:ie().optional(),name:ie().optional()}),MZt=ue({function:NZt.optional(),id:ie().optional(),index:zt(),type:ct("function").optional()}),OZt=ue({refusal:ie(),type:ct("refusal")}),jZt=ue({text:ie(),type:ct("text")}),PZt=ue({arguments:ie(),name:ie()}),DZt=ue({function:PZt,id:ie(),type:ct("function")}),E3e=ue({authStatus:fe("auth_status",rX),manifest:XZ,name:so}),T3e=ue({manifest:QZ,name:so}),LZt=ue({manifest:y3e}),A3e=ue({manifest:JZ,name:ie()}),zZt=ue({manifest:x3e,name:so}),$Zt=ua(["scheduled","triggered","failed"]),C3e=ue({createdAt:fe("created_at",yp()),createdBySubject:fe("created_by_subject",Z1),id:ie(),name:ie(),reason:ie().nullable(),scheduleId:fe("schedule_id",ie()),scheduledFor:fe("scheduled_for",yp()),status:$Zt,triggeredAt:fe("triggered_at",yp().nullable()),updatedAt:fe("updated_at",yp())}),FZt=ue({data:C3e}),oX=ue({createdAt:fe("created_at",ie()),id:ie(),type:ct("user.mcp_auth_continue")}),aX=ue({approval:p3e,createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_approval")}),iX=ue({createdAt:fe("created_at",ie()),id:ie(),policies:yt(g3e),type:ct("user.tool_approval_policy")}),sX=ue({content:ie(),createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("user.tool_response")}),UZt=Ir([oX,aX,iX,sX]),BZt=ue({data:yt(UZt)}),HZt=ue({}),VZt=ue({}),GZt=ue({}),WZt=ue({}),KZt=ue({}),YZt=ue({}),ZZt=ue({name:ie(),serverId:fe("server_id",ie()),serverName:fe("server_name",ie()),type:ct("mcp")}),XZt=ue({name:ie(),type:ct("truefoundry-system")}),R3e=Ir([ZZt,XZt]),qZt=ue({providerSpecificFields:fe("provider_specific_fields",Bl(ie(),vN()).optional()),toolInfo:fe("tool_info",R3e.optional())}).extend(MZt),I3e=ua(["stop","length","tool_calls","content_filter","function_call"]),QZt=ue({data:aZt}),Y6=ue({data:_3e}),JZt=ue({data:k3e}),eXt=ue({data:yZt}),tXt=ue({data:yt(_Zt)}),_T=ue({data:E3e}),nXt=ue({displayName:fe("display_name",ie()),id:ie(),type:ie()}),rXt=ua(["default","oidc-connected"]),oXt=ue({roles:yt(ie()),subject:nXt,tenantId:fe("tenant_id",ie()),type:rXt}),aXt=ue({data:oXt}),iXt=ue({data:yt(TZt)}),Hme=ue({data:T3e}),sXt=ua(["active","deleted"]),lXt=ue({description:ie().optional(),environmentVariables:fe("environment_variables",Bl(ie(),ie()).optional()),image:l3e.optional(),name:so,networking:c3e.optional(),resources:u3e.optional()}),cXt=ua(["pending","ready","failed"]),N3e=ue({createdAt:fe("created_at",yp()),createdBySubject:fe("created_by_subject",Z1),description:ie(),id:ie(),lifecycleStage:fe("lifecycle_stage",sXt),manifest:lXt,name:so,status:cXt,statusReason:fe("status_reason",ie().nullable()),updatedAt:fe("updated_at",yp())}),Z6=ue({data:N3e}),uXt=ue({data:yt(AZt)}),Vme=ue({data:LZt}),M3e=ue({agentName:fe("agent_name",so),createdAt:fe("created_at",yp()),createdBySubject:fe("created_by_subject",Z1),id:ie(),manifest:KZ,name:so,updatedAt:fe("updated_at",yp())}),X6=ue({data:M3e}),O3e=ua(["count","$","ms"]),lX=ua(["sessions_over_time","sessions_cost_over_time","turns_over_time"]),dXt=ue({timestamp:ie(),value:zt()}),pXt=ue({name:ie(),values:yt(dXt)}),fXt=ue({chartType:fe("chart_type",ct("line")),description:ie(),displayName:fe("display_name",ie()),graphLines:fe("graph_lines",yt(pXt)),name:lX,unit:O3e}),hXt=ue({graphs:yt(fXt),step:ie()}),gXt=ue({data:hXt}),mXt=ue({chartType:fe("chart_type",ct("line")),description:ie(),displayName:fe("display_name",ie()),name:lX}),bXt=ue({charts:yt(mXt)}),vXt=ue({data:bXt}),yXt=ua(["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"]),xXt=ue({aggregateValue:fe("aggregate_value",zt()),description:ie(),name:yXt,unit:O3e}),wXt=ue({meters:yt(xXt)}),_Xt=ue({data:wXt}),SXt=ue({spec:Y1,type:ct("inline")}),kXt=ue({id:ie(),name:ie().nullable(),type:ct("reference")}),EXt=Ir([SXt,kXt]),TXt=ue({totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalDurationMs:fe("total_duration_ms",zt()),totalTurns:fe("total_turns",zt())}),AXt=ue({id:ie(),runId:fe("run_id",ie()),type:ct("schedule")}),j3e=ue({agent:EXt,createdAt:fe("created_at",ie()),createdBySubject:fe("created_by_subject",Z1),id:ie(),metadata:YZ,metrics:TXt,shared:Ho(),source:AXt.nullable(),title:ie().nullable(),updatedAt:fe("updated_at",ie())}),ST=ue({data:j3e}),CXt=ue({data:yt(RZt)}),Gme=ue({data:A3e}),RXt=ue({totalCacheReadTokens:fe("total_cache_read_tokens",zt().optional()),totalCacheWriteTokens:fe("total_cache_write_tokens",zt().optional()),totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalInputTokens:fe("total_input_tokens",zt().optional()),totalOutputTokens:fe("total_output_tokens",zt().optional()),totalReasoningTokens:fe("total_reasoning_tokens",zt().optional()),totalTokens:fe("total_tokens",zt().optional())}),IXt=ua(["server-execution-timeout","client-cancelled","cancelled-for-next-turn","abandoned"]),P3e=ue({completedAt:fe("completed_at",ie()),metrics:RXt.optional(),reason:IXt,status:ct("cancelled")}),NXt=Ir([jZt,OZt]),MXt=Ir([ie(),yt(NXt)]),OXt=ue({harness:zt(),instructions:zt(),messages:zt(),skills:zt(),toolDefinitions:fe("tool_definitions",zt())}),D3e=ue({cacheReadTokens:fe("cache_read_tokens",zt().optional()),cacheWriteTokens:fe("cache_write_tokens",zt().optional()),inputTokens:fe("input_tokens",zt()),inputTokensBreakdown:fe("input_tokens_breakdown",OXt),outputTokens:fe("output_tokens",zt())}),jXt=ue({providerSpecificFields:fe("provider_specific_fields",Bl(ie(),vN()).optional())}).extend(DZt),PXt=ue({toolInfo:fe("tool_info",R3e)}).extend(jXt),X1=ue({content:MXt.optionalNullable(),createdAt:fe("created_at",ie()),finishReason:fe("finish_reason",I3e.optionalNullable()),id:ie(),name:ie().optional(),reasoningContent:fe("reasoning_content",ie().optional()),refusal:ie().optionalNullable(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(PXt).optional()),type:ct("model.message"),usage:D3e.optional()}),DXt=ue({totalCacheReadTokens:fe("total_cache_read_tokens",zt().optional()),totalCacheWriteTokens:fe("total_cache_write_tokens",zt().optional()),totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalInputTokens:fe("total_input_tokens",zt().optional()),totalOutputTokens:fe("total_output_tokens",zt().optional()),totalReasoningTokens:fe("total_reasoning_tokens",zt().optional()),totalTokens:fe("total_tokens",zt().optional())}),L3e=ue({completedAt:fe("completed_at",ie()),metrics:DXt.optional(),output:X1.nullable(),requiredActions:fe("required_actions",yt(nZt)),status:ct("done")}),LXt=ue({totalCacheReadTokens:fe("total_cache_read_tokens",zt().optional()),totalCacheWriteTokens:fe("total_cache_write_tokens",zt().optional()),totalCostInUsd:fe("total_cost_in_usd",zt().optional()),totalInputTokens:fe("total_input_tokens",zt().optional()),totalOutputTokens:fe("total_output_tokens",zt().optional()),totalReasoningTokens:fe("total_reasoning_tokens",zt().optional()),totalTokens:fe("total_tokens",zt().optional())}),z3e=ue({completedAt:fe("completed_at",ie()),message:ie(),metrics:LXt.optional(),status:ct("error")}),$3e=ue({actionRequiredOnEvents:fe("action_required_on_events",yt(JYt)),status:ct("paused")}),cX=ue({status:ct("running")}),zXt=Ir([P3e,L3e,z3e,$3e,cX]),F3e=ue({createdAt:fe("created_at",ie()),id:ie(),input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",ie().nullable()),sessionId:fe("session_id",ie()),state:zXt}),Wme=ue({data:F3e}),$Xt=ue({data:yt(IZt)}),Kme=ue({data:zZt}),af=ue({limit:zt(),nextPageToken:fe("next_page_token",ie().optional()),previousPageToken:fe("previous_page_token",ie().optional())}),FXt=ue({data:yt(_3e),pagination:af}),UXt=ue({data:yt(k3e)}),BXt=ue({data:yt(pZt)}),HXt=ue({data:yt(fZt)}),VXt=ue({data:yt(E3e)}),GXt=ue({data:yt(Bl(ie(),vN()))}),WXt=ue({data:yt(T3e)}),KXt=ue({environmentVersionId:fe("environment_version_id",ie())}),YXt=ue({data:yt(KXt)}),ZXt=ua(["USE","MANAGE","DELETE","CREATE"]),XXt=ue({permissions:Bl(ie(),yt(ZXt)),type:a3e}),qXt=ue({data:XXt}),QXt=ue({data:yt(N3e),pagination:af}),JXt=ue({data:yt(C3e),pagination:af}),eqt=ue({data:yt(M3e),pagination:af}),tqt=ua(["streamable-http","sse"]),nqt=ue({approvalPolicies:fe("approval_policies",Bl(ie(),h3e).optional()),id:ie(),name:ie(),sessionId:fe("session_id",ie().optional()),transportType:fe("transport_type",tqt.optional())}),U3e=ue({createdAt:fe("created_at",ie()),id:ie(),mcpServers:fe("mcp_servers",yt(nqt)),threadId:fe("thread_id",ie()),type:ct("mcp.initialize")}),B3e=ue({createdAt:fe("created_at",ie()),id:ie(),sandboxId:fe("sandbox_id",ie()),threadId:fe("thread_id",ie().nullable()),type:ct("sandbox.created")}),H3e=ue({agentInfo:fe("agent_info",iZt),createdAt:fe("created_at",ie()),id:ie(),parent:S3e,threadId:fe("thread_id",ie()),title:ie(),type:ct("thread.created")}),rqt=ue({output:X1,status:ct("done")}),oqt=ue({error:ie(),output:X1.optional(),status:ct("error")}),aqt=Ir([rqt,oqt]),V3e=ue({createdAt:fe("created_at",ie()),id:ie(),parent:S3e.optional(),state:aqt,threadId:fe("thread_id",ie()),title:ie(),type:ct("thread.done")}),G3e=ue({content:ie(),createdAt:fe("created_at",ie()),id:ie(),threadId:fe("thread_id",ie()),toolCallId:fe("tool_call_id",ie()),type:ct("tool.response")}),W3e=ue({createdAt:fe("created_at",ie()),id:ie(),input:yt(yN).optional(),previousTurnId:fe("previous_turn_id",ie().nullable()),state:cX,threadId:fe("thread_id",ie().nullable()),turnId:fe("turn_id",ie()),type:ct("turn.created")}),iqt=Ir([P3e,L3e,z3e]),K3e=ue({createdAt:fe("created_at",ie()),id:ie(),state:iqt,threadId:fe("thread_id",ie().nullable()),type:ct("turn.done")}),sqt=Ir([$3e,cX]),Y3e=ue({createdAt:fe("created_at",ie()),id:ie(),state:sqt,threadId:fe("thread_id",ie().nullable()),type:ct("turn.update")}),Z3e=Ir([eX,U3e,X1,B3e,H3e,V3e,tX,G3e,nX,W3e,K3e,Y3e,oX,aX,iX,sX]),lqt=ue({event:Z3e,turnId:fe("turn_id",ie())}),cqt=ue({data:yt(lqt),pagination:af}),uqt=ua(["asc","desc"]),dqt=ue({data:yt(j3e),pagination:af}),pqt=ue({data:yt(A3e)}),fqt=ue({description:ie(),displayName:fe("display_name",ie()),name:ie(),version:zt()}),hqt=ue({data:yt(fqt)}),gqt=ua(["asc","desc"]),mqt=ue({data:yt(Z3e),pagination:af}),bqt=ue({data:yt(F3e),pagination:af}),vqt=ue({content:ie().optionalNullable(),createdAt:fe("created_at",ie().optional()),finishReason:fe("finish_reason",I3e.optionalNullable()),id:ie(),reasoningContent:fe("reasoning_content",ie().optional()),refusal:ie().optionalNullable(),threadId:fe("thread_id",ie()),toolCalls:fe("tool_calls",yt(qZt).optional()),type:ct("model.message.delta"),usage:D3e.optional()}),yqt=ue({code:ie().optionalNullable(),message:ie(),param:ie().optionalNullable(),type:ie().optional()}),ve=ue({error:yqt}),xqt=ct("schedule"),Yme=Ir([eX,U3e,X1,vqt,B3e,H3e,V3e,tX,G3e,nX,W3e,K3e,Y3e,oX,aX,iX,sX]);let wqt=class{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var m,b,y,x;const{limit:i=50,pageToken:s,agentName:l}=a,c={limit:i,page_token:s,agent_name:l},d=await this._options.authProvider.getAuthRequest(),p=gt(d.headers,(m=this._options)==null?void 0:m.headers,n==null?void 0:n.headers),f=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/agents"),method:"GET",headers:p,queryString:ht().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)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(x=this._options)==null?void 0:x.fetch,logging:this._options.logging});if(f.ok)return{data:FXt.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 Ln(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 401:throw new Jn(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new at({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return bt(f.error,f.rawResponse,"GET","/api/v1/agents")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/agents"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(KKt.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:Y6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/agents")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:Y6.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/agents/{agent_id}")}update(t,n,r){return dt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(YKt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:Y6.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"PUT","/api/v1/agents/{agent_id}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:HZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/agents/{agent_id}")}};class _qt{constructor(t){this._options=Nr(t)}me(t){return dt.fromPromise(this.__me(t))}async __me(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/auth/me"),method:"GET",headers:r,queryString:ht().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:aXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/auth/me")}}let Sqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/mcp-servers"),method:"GET",headers:r,queryString:ht().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:tXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/mcp-servers")}},kqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/model-providers"),method:"GET",headers:r,queryString:ht().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:iXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/model-providers")}},Eqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/sandbox-providers"),method:"GET",headers:r,queryString:ht().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:uXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/sandbox-providers")}},Tqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/skills"),method:"GET",headers:r,queryString:ht().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:CXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/skills")}},Aqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/catalogs/web-search-providers"),method:"GET",headers:r,queryString:ht().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:$Xt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/catalogs/web-search-providers")}};class Cqt{constructor(t){this._options=Nr(t)}get mcpServers(){return this._mcpServers??(this._mcpServers=new Sqt(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new kqt(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new Eqt(this._options))}get skills(){return this._skills??(this._skills=new Tqt(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new Aqt(this._options))}}class Rqt{constructor(t){this._options=Nr(t)}getCodeSnippets(t,n={},r){return dt.fromPromise(this.__getCodeSnippets(t,n,r))}async __getCodeSnippets(t,n={},r){var c,d,p,f;const{baseUrl:o}=n,a={base_url:o},i=await this._options.authProvider.getAuthRequest(),s=gt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/agents/${Rn(t)}/code-snippets`),method:"GET",headers:s,queryString:ht().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((p=this._options)==null?void 0:p.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:QZt.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 Sn(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new at({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return bt(l.error,l.rawResponse,"GET","/api/v1/agents/{agent_id}/code-snippets")}}class Iqt{constructor(t){this._options=Nr(t)}listCharts(t){return dt.fromPromise(this.__listCharts(t))}async __listCharts(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/metrics/charts"),method:"GET",headers:r,queryString:ht().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:vXt.parseOrThrow(o.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});return bt(o.error,o.rawResponse,"GET","/api/internal/metrics/charts")}getChartData(t,n){return dt.fromPromise(this.__getChartData(t,n))}async __getChartData(t,n){var p,f,m,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:lX.jsonOrThrow(i,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0})},l=await this._options.authProvider.getAuthRequest(),c=gt(l.headers,(p=this._options)==null?void 0:p.headers,n==null?void 0:n.headers),d=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/metrics/charts-data"),method:"GET",headers:c,queryString:ht().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)??((m=this._options)==null?void 0:m.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(b=this._options)==null?void 0:b.fetch,logging:this._options.logging});if(d.ok)return{data:gXt.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 Ln(ve.parseOrThrow(d.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),d.rawResponse);default:throw new at({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}return bt(d.error,d.rawResponse,"GET","/api/internal/metrics/charts-data")}getMeters(t,n){return dt.fromPromise(this.__getMeters(t,n))}async __getMeters(t,n){var d,p,f,m;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=gt(s.headers,(d=this._options)==null?void 0:d.headers,n==null?void 0:n.headers),c=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/metrics/meters"),method:"GET",headers:l,queryString:ht().addMany(i).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((p=this._options)==null?void 0:p.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:(m=this._options)==null?void 0:m.fetch,logging:this._options.logging});if(c.ok)return{data:_Xt.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 Ln(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new at({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return bt(c.error,c.rawResponse,"GET","/api/internal/metrics/meters")}}let Nqt=class{constructor(t){this._options=Nr(t)}listPending(t){return dt.fromPromise(this.__listPending(t))}async __listPending(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/sandbox-environments/pending"),method:"GET",headers:r,queryString:ht().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:YXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/internal/sandbox-environments/pending")}progress(t,n){return dt.fromPromise(this.__progress(t,n))}async __progress(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/sandbox-environments/progress"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(XKt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/sandbox-environments/progress")}},Mqt=class{constructor(t){this._options=Nr(t)}executeRun(t,n){return dt.fromPromise(this.__executeRun(t,n))}async __executeRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/schedules/runs/execute"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(qKt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/schedules/runs/execute")}},Oqt=class{constructor(t){this._options=Nr(t)}getOrCreateByExternalId(t,n){return dt.fromPromise(this.__getOrCreateByExternalId(t,n))}async __getOrCreateByExternalId(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/sessions/get-or-create-by-external-id"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(eYt.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:ST.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/sessions/get-or-create-by-external-id")}};class jqt{constructor(t){this._options=Nr(t)}get metrics(){return this._metrics??(this._metrics=new Iqt(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new Nqt(this._options))}get schedules(){return this._schedules??(this._schedules=new Mqt(this._options))}get sessions(){return this._sessions??(this._sessions=new Oqt(this._options))}get agents(){return this._agents??(this._agents=new Rqt(this._options))}listPermissions(t,n){return dt.fromPromise(this.__listPermissions(t,n))}async __listPermissions(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/internal/list-permissions"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(ZKt.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:qXt.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/internal/list-permissions")}}let Pqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/mcp-servers"),method:"GET",headers:r,queryString:ht().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:UXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/mcp-servers")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:JZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}")}authorize(t,n={},r){return dt.fromPromise(this.__authorize(t,n,r))}async __authorize(t,n={},r){var c,d,p,f;const{returnTo:o}=n,a={return_to:o},i=await this._options.authProvider.getAuthRequest(),s=gt(i.headers,(c=this._options)==null?void 0:c.headers,r==null?void 0:r.headers),l=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}/authorize`),method:"GET",headers:s,queryString:ht().addMany(a).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((d=this._options)==null?void 0:d.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((p=this._options)==null?void 0:p.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:rX.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 Ln(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 404:throw new Sn(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 422:throw new wa(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 424:throw new Hs(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);case 500:throw new PWt(ve.parseOrThrow(l.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),l.rawResponse);default:throw new at({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}return bt(l.error,l.rawResponse,"GET","/api/v1/mcp-servers/{name}/authorize")}deleteAuthorization(t,n){return dt.fromPromise(this.__deleteAuthorization(t,n))}async __deleteAuthorization(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}/authorize`),method:"DELETE",headers:o,queryString:ht().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:_T.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/mcp-servers/{name}/authorize")}listTools(t,n){return dt.fromPromise(this.__listTools(t,n))}async __listTools(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/mcp-servers/${Rn(t)}/tools`),method:"GET",headers:o,queryString:ht().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:GXt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/mcp-servers/{name}/tools")}};class Dqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/models"),method:"GET",headers:r,queryString:ht().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:BXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/models")}}class Lqt{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var f,m,b,y;const{limit:i=25,pageToken:s}=a,l={limit:i,page_token:s},c=await this._options.authProvider.getAuthRequest(),d=gt(c.headers,(f=this._options)==null?void 0:f.headers,n==null?void 0:n.headers),p=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sandbox-environments"),method:"GET",headers:d,queryString:ht().addMany(l).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((m=this._options)==null?void 0:m.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:(y=this._options)==null?void 0:y.fetch,logging:this._options.logging});if(p.ok)return{data:QXt.parseOrThrow(p.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:p.rawResponse};if(p.error.reason==="status-code")switch(p.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(p.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),p.rawResponse);case 401:throw new Jn(ve.parseOrThrow(p.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),p.rawResponse);default:throw new at({statusCode:p.error.statusCode,body:p.error.body,rawResponse:p.rawResponse})}return bt(p.error,p.rawResponse,"GET","/api/v1/sandbox-environments")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sandbox-environments"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(nYt.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:Z6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/sandbox-environments")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sandbox-environments"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(rYt.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:Z6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 401:throw new Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/sandbox-environments")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sandbox-environments/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:Z6.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/sandbox-environments/{name}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sandbox-environments/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:WZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 502:throw new wT(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/sandbox-environments/{name}")}}class zqt{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var b,y,x,_;const{limit:i=25,pageToken:s,agentNames:l,createdByMe:c}=a,d={limit:i,page_token:s,agent_names:l,created_by_me:c},p=await this._options.authProvider.getAuthRequest(),f=gt(p.headers,(b=this._options)==null?void 0:b.headers,n==null?void 0:n.headers),m=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/schedules"),method:"GET",headers:f,queryString:ht().addMany(d).mergeAdditional(n==null?void 0:n.queryParams).build(),timeoutMs:((n==null?void 0:n.timeoutInSeconds)??((y=this._options)==null?void 0:y.timeoutInSeconds)??60)*1e3,maxRetries:(n==null?void 0:n.maxRetries)??((x=this._options)==null?void 0:x.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(_=this._options)==null?void 0:_.fetch,logging:this._options.logging});if(m.ok)return{data:eqt.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);case 401:throw new Jn(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);default:throw new at({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}return bt(m.error,m.rawResponse,"GET","/api/v1/schedules")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/schedules"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(sYt.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:X6.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/schedules")}createRun(t,n){return dt.fromPromise(this.__createRun(t,n))}async __createRun(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/schedules/runs"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(lYt.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:FZt.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/schedules/runs")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:X6.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 oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/schedules/{schedule_id}")}update(t,n,r){return dt.fromPromise(this.__update(t,n,r))}async __update(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}`),method:"PUT",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(cYt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:X6.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 409:throw new ii(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"PUT","/api/v1/schedules/{schedule_id}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:KZt.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 Jn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 403:throw new oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/schedules/{schedule_id}")}async listRuns(t,n={},r){const o=dt.interceptFunction(async i=>{var m,b,y,x;const{limit:s=25,pageToken:l}=i,c={limit:s,page_token:l},d=await this._options.authProvider.getAuthRequest(),p=gt(d.headers,(m=this._options)==null?void 0:m.headers,r==null?void 0:r.headers),f=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/schedules/${Rn(t)}/runs`),method:"GET",headers:p,queryString:ht().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)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(x=this._options)==null?void 0:x.fetch,logging:this._options.logging});if(f.ok)return{data:JXt.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 Ln(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 403:throw new oo(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 404:throw new Sn(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new at({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return bt(f.error,f.rawResponse,"GET","/api/v1/schedules/{schedule_id}/runs")}),a=await o(n).withRawResponse();return new vp({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(xp(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}}class $qt{constructor(t){this._options=Nr(t)}getCapabilities(t){return dt.fromPromise(this.__getCapabilities(t))}async __getCapabilities(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/capabilities"),method:"GET",headers:r,queryString:ht().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:eXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/capabilities")}}class Fqt{constructor(t){this._options=Nr(t)}async list(t={},n){const r=dt.interceptFunction(async a=>{var T,C,A,R;const{limit:i=25,order:s,pageToken:l,startTimestamp:c,endTimestamp:d,agentId:p,createdByMe:f,metadata:m,sourceType:b,sourceId:y}=a,x={limit:i,order:s!=null?uqt.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:d!=null?d==null?void 0:d.toISOString():void 0,agent_id:p,created_by_me:f,metadata:m,source_type:b!=null?xqt.jsonOrThrow(b,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0,source_id:y},_=await this._options.authProvider.getAuthRequest(),k=gt(_.headers,(T=this._options)==null?void 0:T.headers,n==null?void 0:n.headers),E=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sessions"),method:"GET",headers:k,queryString:ht().addMany(x).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)??((A=this._options)==null?void 0:A.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:dqt.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 Ln(ve.parseOrThrow(E.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),E.rawResponse);default:throw new at({statusCode:E.error.statusCode,body:E.error.body,rawResponse:E.rawResponse})}return bt(E.error,E.rawResponse,"GET","/api/v1/sessions")}),o=await r(t).withRawResponse();return new vp({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(xp(t,"pageToken",a==null?void 0:a.pagination.nextPageToken))})}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/sessions"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(dYt.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:ST.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/sessions")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:ST.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 oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 404:throw new Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/sessions/{session_id}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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 oo(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/sessions/{session_id}")}update(t,n={},r){return dt.fromPromise(this.__update(t,n,r))}async __update(t,n={},r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}`),method:"PATCH",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(TYt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:ST.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"PATCH","/api/v1/sessions/{session_id}")}cancel(t,n={},r){return dt.fromPromise(this.__cancel(t,n,r))}async __cancel(t,n={},r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/cancel`),method:"POST",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr(uYt.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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:hZt.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 oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new fx(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/cancel")}async listEvents(t,n={},r){const o=dt.interceptFunction(async i=>{var b,y,x,_;const{pageToken:s,lastTurnId:l,limit:c=100}=i,d={page_token:s,last_turn_id:l,limit:c},p=await this._options.authProvider.getAuthRequest(),f=gt(p.headers,(b=this._options)==null?void 0:b.headers,r==null?void 0:r.headers),m=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/events`),method:"GET",headers:f,queryString:ht().addMany(d).mergeAdditional(r==null?void 0:r.queryParams).build(),timeoutMs:((r==null?void 0:r.timeoutInSeconds)??((y=this._options)==null?void 0:y.timeoutInSeconds)??60)*1e3,maxRetries:(r==null?void 0:r.maxRetries)??((x=this._options)==null?void 0:x.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(_=this._options)==null?void 0:_.fetch,logging:this._options.logging});if(m.ok)return{data:cqt.parseOrThrow(m.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);case 403:throw new oo(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);case 404:throw new Sn(ve.parseOrThrow(m.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),m.rawResponse);default:throw new at({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}return bt(m.error,m.rawResponse,"GET","/api/v1/sessions/{session_id}/events")}),a=await o(n).withRawResponse();return new vp({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(xp(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}async listTurns(t,n={},r){const o=dt.interceptFunction(async i=>{var m,b,y,x;const{limit:s=25,pageToken:l}=i,c={limit:s,page_token:l},d=await this._options.authProvider.getAuthRequest(),p=gt(d.headers,(m=this._options)==null?void 0:m.headers,r==null?void 0:r.headers),f=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns`),method:"GET",headers:p,queryString:ht().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)??((y=this._options)==null?void 0:y.maxRetries),abortSignal:r==null?void 0:r.abortSignal,fetchFn:(x=this._options)==null?void 0:x.fetch,logging:this._options.logging});if(f.ok)return{data:bqt.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 Ln(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 403:throw new oo(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);case 404:throw new Sn(ve.parseOrThrow(f.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),f.rawResponse);default:throw new at({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}return bt(f.error,f.rawResponse,"GET","/api/v1/sessions/{session_id}/turns")}),a=await o(n).withRawResponse();return new vp({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(xp(n,"pageToken",i==null?void 0:i.pagination.nextPageToken))})}createTurnStream(t,n,r){return dt.fromPromise(this.__createTurnStream(t,n,r))}async __createTurnStream(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns`),method:"POST",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr({...EYt.jsonOrThrow(n,{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)??((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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:new Ume({stream:i.body,parse:async p=>Yme.parseOrThrow(p,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:r==null?void 0:r.abortSignal,eventShape:{type:"sse"}}),rawResponse:i.rawResponse};if(i.error.reason==="status-code")switch(i.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Jn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new fx(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 413:throw new H6(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}createTurn(t,n,r){return dt.fromPromise(this.__createTurn(t,n,r))}async __createTurn(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns`),method:"POST",headers:a,contentType:"application/json",queryString:ht().mergeAdditional(r==null?void 0:r.queryParams).build(),requestType:"json",body:Yr({...kYt.jsonOrThrow(n,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}),stream:!1},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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:Wme.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 Ln(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 401:throw new Jn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 403:throw new oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 412:throw new fx(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 413:throw new H6(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 422:throw new wa(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"POST","/api/v1/sessions/{session_id}/turns")}getTurn(t,n,r){return dt.fromPromise(this.__getTurn(t,n,r))}async __getTurn(t,n,r){var s,l,c,d;const o=await this._options.authProvider.getAuthRequest(),a=gt(o.headers,(s=this._options)==null?void 0:s.headers,r==null?void 0:r.headers),i=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}`),method:"GET",headers:a,queryString:ht().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:(d=this._options)==null?void 0:d.fetch,logging:this._options.logging});if(i.ok)return{data:Wme.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 oo(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);case 404:throw new Sn(ve.parseOrThrow(i.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),i.rawResponse);default:throw new at({statusCode:i.error.statusCode,body:i.error.body,rawResponse:i.rawResponse})}return bt(i.error,i.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}")}downloadSandboxFile(t,n,r,o){return dt.fromPromise(this.__downloadSandboxFile(t,n,r,o))}async __downloadSandboxFile(t,n,r,o){var d,p,f,m;const{path:a}=r,i={path:a},s=await this._options.authProvider.getAuthRequest(),l=gt(s.headers,(d=this._options)==null?void 0:d.headers,o==null?void 0:o.headers),c=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/download-sandbox-file`),method:"GET",headers:l,queryString:ht().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"binary-response",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((p=this._options)==null?void 0:p.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:(m=this._options)==null?void 0:m.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 Ln(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new oo(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new Sn(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 410:throw new jWt(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 412:throw new fx(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 413:throw new H6(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 424:throw new Hs(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new at({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return bt(c.error,c.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/download-sandbox-file")}async listTurnEvents(t,n,r={},o){const a=dt.interceptFunction(async s=>{var y,x,_,k;const{limit:l=100,pageToken:c,order:d}=s,p={limit:l,page_token:c,order:d!=null?gqt.jsonOrThrow(d,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,omitUndefined:!0}):void 0},f=await this._options.authProvider.getAuthRequest(),m=gt(f.headers,(y=this._options)==null?void 0:y.headers,o==null?void 0:o.headers),b=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/events`),method:"GET",headers:m,queryString:ht().addMany(p).mergeAdditional(o==null?void 0:o.queryParams).build(),timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((x=this._options)==null?void 0:x.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((_=this._options)==null?void 0:_.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(k=this._options)==null?void 0:k.fetch,logging:this._options.logging});if(b.ok)return{data:mqt.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 Ln(ve.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 403:throw new oo(ve.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);case 404:throw new Sn(ve.parseOrThrow(b.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),b.rawResponse);default:throw new at({statusCode:b.error.statusCode,body:b.error.body,rawResponse:b.rawResponse})}return bt(b.error,b.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}),i=await a(r).withRawResponse();return new vp({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(xp(r,"pageToken",s==null?void 0:s.pagination.nextPageToken))})}createTurnEvent(t,n,r,o){return dt.fromPromise(this.__createTurnEvent(t,n,r,o))}async __createTurnEvent(t,n,r,o){var l,c,d,p;const a=await this._options.authProvider.getAuthRequest(),i=gt(a.headers,(l=this._options)==null?void 0:l.headers,o==null?void 0:o.headers),s=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/events`),method:"POST",headers:i,contentType:"application/json",queryString:ht().mergeAdditional(o==null?void 0:o.queryParams).build(),requestType:"json",body:Yr(vYt.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)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(p=this._options)==null?void 0:p.fetch,logging:this._options.logging});if(s.ok)return{data:BZt.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 Ln(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 403:throw new oo(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 404:throw new Sn(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);case 409:throw new ii(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new at({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return bt(s.error,s.rawResponse,"POST","/api/v1/sessions/{session_id}/turns/{turn_id}/events")}subscribeToTurn(t,n,r={},o){return dt.fromPromise(this.__subscribeToTurn(t,n,r,o))}async __subscribeToTurn(t,n,r={},o){var p,f,m,b,y,x,_,k,E,T;const{afterSequenceNumber:a}=r,i={after_sequence_number:a},s=await this._options.authProvider.getAuthRequest(),l=gt(s.headers,(p=this._options)==null?void 0:p.headers,o==null?void 0:o.headers),c=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/subscribe`),method:"GET",headers:l,queryString:ht().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"sse",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((f=this._options)==null?void 0:f.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((m=this._options)==null?void 0:m.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(b=this._options)==null?void 0:b.fetch,logging:this._options.logging}),d=async C=>{var R,M,j;const A=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/sessions/${Rn(t)}/turns/${Rn(n)}/subscribe`),method:"GET",headers:{...l,"Last-Event-ID":C},queryString:ht().addMany(i).mergeAdditional(o==null?void 0:o.queryParams).build(),responseType:"sse",timeoutMs:((o==null?void 0:o.timeoutInSeconds)??((R=this._options)==null?void 0:R.timeoutInSeconds)??60)*1e3,maxRetries:(o==null?void 0:o.maxRetries)??((M=this._options)==null?void 0:M.maxRetries),abortSignal:o==null?void 0:o.abortSignal,fetchFn:(j=this._options)==null?void 0:j.fetch,logging:this._options.logging});if(!A.ok)throw new Error("SSE stream reconnection failed");if(A.body==null)throw new Error("SSE stream reconnection failed: empty response body");return A.body};if(c.ok)return{data:new Ume({stream:c.body,parse:async C=>Yme.parseOrThrow(C,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),signal:o==null?void 0:o.abortSignal,eventShape:{type:"sse",resumable:!0},reconnectionEnabled:((y=o==null?void 0:o.stream)==null?void 0:y.reconnectionEnabled)??((_=(x=this._options)==null?void 0:x.stream)==null?void 0:_.reconnectionEnabled),maxReconnectionAttempts:((k=o==null?void 0:o.stream)==null?void 0:k.maxReconnectionAttempts)??((T=(E=this._options)==null?void 0:E.stream)==null?void 0:T.maxReconnectionAttempts),reconnect:d}),rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 400:throw new Ln(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 403:throw new oo(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 404:throw new Sn(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);case 412:throw new fx(ve.parseOrThrow(c.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),c.rawResponse);default:throw new at({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}return bt(c.error,c.rawResponse,"GET","/api/v1/sessions/{session_id}/turns/{turn_id}/subscribe")}}class Uqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"GET",headers:r,queryString:ht().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:VXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/mcp-servers")}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(NYt.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:_T.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/settings/mcp-servers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/mcp-servers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(MYt.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:_T.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/mcp-servers")}get(t,n){return dt.fromPromise(this.__get(t,n))}async __get(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/mcp-servers/${Rn(t)}`),method:"GET",headers:o,queryString:ht().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:_T.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"GET","/api/v1/settings/mcp-servers/{name}")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/mcp-servers/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:VZt.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/settings/mcp-servers/{name}")}}class Bqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/model-providers"),method:"GET",headers:r,queryString:ht().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:WXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/model-providers")}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/model-providers"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(HYt.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:Hme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/settings/model-providers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/model-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(VYt.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:Hme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/model-providers")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/model-providers/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:GZt.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/settings/model-providers/{name}")}}class Hqt{constructor(t){this._options=Nr(t)}get(t){return dt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"GET",headers:r,queryString:ht().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:Vme.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 Sn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/sandbox-providers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/sandbox-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(WYt.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:Vme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 422:throw new wa(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/sandbox-providers")}}let Vqt=class{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/skills"),method:"GET",headers:r,queryString:ht().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:pqt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/skills")}create(t,n){return dt.fromPromise(this.__create(t,n))}async __create(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/skills"),method:"POST",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(ZYt.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:Gme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"POST","/api/v1/settings/skills")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/skills"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(XYt.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:Gme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/skills")}delete(t,n){return dt.fromPromise(this.__delete(t,n))}async __delete(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),`api/v1/settings/skills/${Rn(t)}`),method:"DELETE",headers:o,queryString:ht().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:YZt.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 Sn(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 409:throw new ii(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"DELETE","/api/v1/settings/skills/{name}")}};class Gqt{constructor(t){this._options=Nr(t)}get(t){return dt.fromPromise(this.__get(t))}async __get(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"GET",headers:r,queryString:ht().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:Kme.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 403:throw new oo(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);case 404:throw new Sn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/settings/web-search-providers")}createOrUpdate(t,n){return dt.fromPromise(this.__createOrUpdate(t,n))}async __createOrUpdate(t,n){var i,s,l,c;const r=await this._options.authProvider.getAuthRequest(),o=gt(r.headers,(i=this._options)==null?void 0:i.headers,n==null?void 0:n.headers),a=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/settings/web-search-providers"),method:"PUT",headers:o,contentType:"application/json",queryString:ht().mergeAdditional(n==null?void 0:n.queryParams).build(),requestType:"json",body:Yr(QYt.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:Kme.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 Ln(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);case 424:throw new Hs(ve.parseOrThrow(a.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),a.rawResponse);default:throw new at({statusCode:a.error.statusCode,body:a.error.body,rawResponse:a.rawResponse})}return bt(a.error,a.rawResponse,"PUT","/api/v1/settings/web-search-providers")}}class Wqt{constructor(t){this._options=Nr(t)}get mcpServers(){return this._mcpServers??(this._mcpServers=new Uqt(this._options))}get modelProviders(){return this._modelProviders??(this._modelProviders=new Bqt(this._options))}get sandboxProviders(){return this._sandboxProviders??(this._sandboxProviders=new Hqt(this._options))}get skills(){return this._skills??(this._skills=new Vqt(this._options))}get webSearchProviders(){return this._webSearchProviders??(this._webSearchProviders=new Gqt(this._options))}}class Kqt{constructor(t){this._options=Nr(t)}list(t){return dt.fromPromise(this.__list(t))}async __list(t){var a,i,s,l;const n=await this._options.authProvider.getAuthRequest(),r=gt(n.headers,(a=this._options)==null?void 0:a.headers,t==null?void 0:t.headers),o=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/skills"),method:"GET",headers:r,queryString:ht().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:HXt.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 Jn(ve.parseOrThrow(o.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),o.rawResponse);default:throw new at({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}return bt(o.error,o.rawResponse,"GET","/api/v1/skills")}listVersions(t,n){return dt.fromPromise(this.__listVersions(t,n))}async __listVersions(t,n){var l,c,d,p;const{name:r}=t,o={name:r},a=await this._options.authProvider.getAuthRequest(),i=gt(a.headers,(l=this._options)==null?void 0:l.headers,n==null?void 0:n.headers),s=await(this._options.fetcher??ft)({url:pt(await Ne.get(this._options.baseUrl)??await Ne.get(this._options.environment),"api/v1/skills/versions"),method:"GET",headers:i,queryString:ht().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)??((d=this._options)==null?void 0:d.maxRetries),abortSignal:n==null?void 0:n.abortSignal,fetchFn:(p=this._options)==null?void 0:p.fetch,logging:this._options.logging});if(s.ok)return{data:hqt.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 Jn(ve.parseOrThrow(s.error.body,{unrecognizedObjectKeys:"passthrough",allowUnrecognizedUnionMembers:!0,allowUnrecognizedEnumValues:!0,skipValidation:!0,breadcrumbsPrefix:["response"]}),s.rawResponse);default:throw new at({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}return bt(s.error,s.rawResponse,"GET","/api/v1/skills/versions")}}class uX{constructor(t){this._options=Nr(t)}get internal(){return this._internal??(this._internal=new jqt(this._options))}get agents(){return this._agents??(this._agents=new wqt(this._options))}get auth(){return this._auth??(this._auth=new _qt(this._options))}get server(){return this._server??(this._server=new $qt(this._options))}get mcpServers(){return this._mcpServers??(this._mcpServers=new Pqt(this._options))}get models(){return this._models??(this._models=new Dqt(this._options))}get sandboxEnvironments(){return this._sandboxEnvironments??(this._sandboxEnvironments=new Lqt(this._options))}get schedules(){return this._schedules??(this._schedules=new zqt(this._options))}get sessions(){return this._sessions??(this._sessions=new Fqt(this._options))}get skills(){return this._skills??(this._skills=new Kqt(this._options))}get catalogs(){return this._catalogs??(this._catalogs=new Cqt(this._options))}get settings(){return this._settings??(this._settings=new Wqt(this._options))}async fetch(t,n,r){return oKt(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 lC="daytona",Yqt="Daytona";function X3e(e){return e===lC?Yqt:e}function Zqt(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 dX(e){return{execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes}}function q3e(e){return{id:e.type,name:X3e(e.type),type:e.type,...dX(e)}}function kT(e){return{id:e.type,name:X3e(e.type),catalogId:e.type,isConnected:!0,...dX(e)}}function Q3e({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 R$(e){if(e.type!==lC)throw new Error(`Unsupported sandbox provider type: ${e.type}`);return{type:lC,execTimeoutMs:e.execTimeoutMs,autoStopIntervalInMinutes:e.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:e.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:e.autoDeleteIntervalInMinutes,auth:{apiKey:e.apiKey}}}function J3e(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(q3e),listSandboxProviders:async n=>{let r;try{const o=await e.settings.sandboxProviders.get();r=[kT(o.data.manifest)]}catch(o){if(o instanceof Sn)r=[];else throw o}return Q3e({providers:r,query:n==null?void 0:n.query})},createSandboxProvider:async n=>{const r=await e.settings.sandboxProviders.createOrUpdate({manifest:R$({type:n.type,apiKey:n.apiKey,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return kT(r.data.manifest)},updateSandboxProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.sandboxProviders.createOrUpdate({manifest:R$({type:lC,apiKey:r,execTimeoutMs:n.execTimeoutMs,autoStopIntervalInMinutes:n.autoStopIntervalInMinutes,autoArchiveIntervalInMinutes:n.autoArchiveIntervalInMinutes,autoDeleteIntervalInMinutes:n.autoDeleteIntervalInMinutes})});return kT(o.data.manifest)}}}var Xqt="/";function e5e(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 sf(e={}){return new uX({baseUrl:e5e(e.baseUrl??Xqt),...e.token===void 0?{}:{token:e.token},...e.fetch===void 0?{}:{fetch:e.fetch}})}function cb(e){const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid ISO timestamp: ${e}`);return t}function qqt(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 t5e(e={}){const t=e.client??sf(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:cb(r),endTimestamp:cb(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:cb(r),endTimestamp:cb(o),chartName:qqt(a)});return i}}}function q6(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 Qqt(e){return e.status==="running"||e.status==="paused"?{status:"running"}:pX(e)}function pX(e){switch(e.status){case"cancelled":return{status:"cancelled",reason:e.reason,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:q6(e.metrics)}};case"error":return{status:"error",message:e.message,completedAt:e.completedAt,...e.metrics==null?{}:{metrics:q6(e.metrics)}};case"done":return{status:"done",completedAt:e.completedAt,requiredActions:e.requiredActions,...e.output==null?{}:{output:e.output},...e.metrics==null?{}:{metrics:q6(e.metrics)}}}}function n5e(e){return e.type==="turn.update"||e.type==="user.tool_approval"||e.type==="user.tool_response"||e.type==="user.tool_approval_policy"||e.type==="user.mcp_auth_continue"}function Jqt(e){if(!n5e(e))return e.type!=="turn.done"?{...e}:{...e,state:pX(e.state)}}function Zme(e){if(!n5e(e))return e.type!=="turn.done"?{...e}:{...e,state:pX(e.state)}}function r5e(e){const t=Jqt(e.event);return t===void 0?void 0:{turnId:e.turnId,event:t}}function eQt(e){return e}function tQt(e){return{name:e.name,preload:e.preload===!0}}function nQt(e){return{name:e.id??e.name,preload:e.preload===!0}}function cC(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(nQt)}}}function q1(e){const{mcpServers:t,skills:n,...r}=e;return{...r,...t?{mcpServers:t.map(eQt)}:{},...n?{skills:n.map(tQt)}:{}}}function gx(e){return{id:e.id,isMutable:e.agent.type==="inline",isCreateAgent:HZ(e.metadata),shared:e.shared,createdAt:e.createdAt,updatedAt:e.updatedAt,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:q1(e.agent.spec)}:{},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function rQt(e){if(e.metadata!==void 0)return e.metadata}function oQt(e){return typeof e=="string"?e:e.map(t=>({...t}))}function aQt(e){return e.map(t=>t.type==="user.message"?{...t,content:oQt(t.content)}:t)}function Xme(e){const{previousTurnId:t,input:n,state:r,...o}=e;return{...o,state:Qqt(r),...t===null?{}:{previousTurnId:t},...n===void 0?{}:{input:aQt(n)}}}function Np(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 qme(e,t){if(e===void 0)return t;const n=Number(e);return Number.isSafeInteger(n)&&n>=0?n:t}function iQt(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 sQt(e){const t=[];for(const n of e)if(n.type!=="user.mcp_auth_continue"){if(n.type==="user.message"){t.push({...n,content:iQt(n.content)});continue}t.push(n)}return t}function o5e(e={}){const t=e.client??sf(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=rQt(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 gx(o.data)}if(n.agentSpec!==void 0){const o=await t.sessions.create({agent:{spec:cC(n.agentSpec)},...r===void 0?{}:{metadata:r}});return gx(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}});return Np(r,gx)},async getSession({sessionId:n}){const r=await t.sessions.get(n);return gx(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,shared:a}){const i={...r===void 0?{}:{agent:{spec:cC(r)}},...o===void 0?{}:{title:o},...a===void 0?{}:{shared:a}},s=await t.sessions.update(n,i);return gx(s.data)},async*createTurn({sessionId:n,input:r,previousTurnId:o}){const a=await t.sessions.createTurnStream(n,{...r===void 0?{}:{input:sQt(r)},...o===void 0?{}:{previousTurnId:o}});let i=0;for await(const s of a.withMetadata()){const l=Zme(s.data);l!==void 0&&(yield{sequenceNumber:qme(s.id,i),event:l}),i+=1}},async*subscribeToTurn({sessionId:n,turnId:r,afterSequenceNumber:o}){const a=await t.sessions.subscribeToTurn(n,r,{...o===void 0?{}:{afterSequenceNumber:o}});let i=0;for await(const s of a.withMetadata()){const l=Zme(s.data);l!==void 0&&(yield{sequenceNumber:qme(s.id,i),event:l}),i+=1}},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 Np(a,Xme)},async getTurn({sessionId:n,turnId:r}){const o=await t.sessions.getTurn(n,r);return Xme(o.data)},async listEvents({sessionId:n,pageToken:r,lastTurnId:o,limit:a}){const i=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r},...o===void 0?{}:{lastTurnId:o},...a===void 0?{}:{limit:a}});return Np(i,r5e)}}}function lQt(e){var t;return{id:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,lastActivityAt:e.updatedAt,isCreateAgent:HZ(e.metadata),isMutable:e.agent.type==="inline",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:q1(e.agent.spec)}:{},...((t=e.source)==null?void 0:t.type)==="schedule"?{sourceType:e.source.type}:{},...e.metadata!=null&&Object.keys(e.metadata).length>0?{metadata:e.metadata}:{}}}function a5e(e={}){const t=e.client??sf(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:q1(r.manifest)}},async getCodeSnippets({agentId:n}){const r=e5e(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:cb(n.startTimestamp)},...n.endTimestamp===void 0?{}:{endTimestamp:cb(n.endTimestamp)},...n.agentId===void 0||n.agentId.length===0?{}:{agentId:n.agentId},...n.createdByMe===void 0?{}:{createdByMe:n.createdByMe}});return Np(r,lQt)},async listSessionEvents({sessionId:n,pageToken:r,limit:o}){const a=await t.sessions.listEvents(n,{...r===void 0?{}:{pageToken:r},...o===void 0?{}:{limit:o}});return Np(a,r5e)}}}var i5e=50,cQt=100;function s5e(e){return Math.min(Math.max(e,1),cQt)}async function l5e({client:e,limit:t,pageToken:n,agentName:r}){const o=s5e(t),a=await e.agents.list({limit:o,...n===void 0||n===""?{}:{pageToken:n},...r===void 0?{}:{agentName:r}});return Np(a,i=>i)}async function I$(e){const t=[];let n;for(;;){const r=await l5e({client:e,limit:i5e,...n===void 0?{}:{pageToken:n}});if(t.push(...r.data),r.nextPageToken==null||r.nextPageToken==="")break;n=r.nextPageToken}return t}var fX="Authorization";function uQt({headerName:e,value:t}){return e.toLowerCase()!==fX.toLowerCase()||/^bearer\s+/i.test(t)?t:`Bearer ${t}`}function c5e(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 u5e(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:fX;return{type:"header",headers:{[r]:uQt({headerName:r,value:t})}}}function dQt(e){return{id:e.name,name:e.name,url:e.url,description:e.description,...e.logo===void 0?{}:{logo:e.logo},auth:c5e(e.auth)}}function pQt(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 d5e(e){const t=typeof e.name=="string"&&e.name!==""?e.name:"tool",n=typeof e.description=="string"?e.description:"",r=pQt(Reflect.get(e,"annotations"));return r===void 0?{id:t,name:t,description:n}:{id:t,name:t,description:n,annotations:r}}function Qm(e){const t=c5e(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 N$(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 M$(e){var r;const t=u5e(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 p5e(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 d,p,f;if(r.auth.type!=="header")return r.auth;const o=(d=r.auth.apiKey)==null?void 0:d.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(((p=a.manifest.auth)==null?void 0:p.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??fX,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(dQt),getConnector:async r=>{const o=await e.settings.mcpServers.get(r.id);return Qm(o.data)},listConnectors:async r=>{var s;const a=(await e.settings.mcpServers.list()).data.map(Qm),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(d5e),createConnector:async r=>{const o=await n({auth:r.auth}),a=await e.settings.mcpServers.create({manifest:M$({name:r.name,url:r.url,auth:o,description:r.description})});return Qm(a.data)},updateConnector:async r=>{const o=await n({id:r.id,auth:r.auth}),a=await e.settings.mcpServers.createOrUpdate({manifest:M$({name:r.id,url:r.url,auth:o,description:r.description})});return Qm(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 Qm(a.data)},deleteConnector:async({id:r})=>{await e.settings.mcpServers.delete(r)}}}async function f5e(e){return(await e.models.list()).data}async function h5e(e){return(await e.mcpServers.list()).data}async function g5e(e){return(await e.skills.list()).data}async function m5e(e){return(await e.server.getCapabilities()).data}function b5e(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 v5e({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]}}}}function fQt(e){return{name:e.name,agentId:e.id,description:e.description,agentSpec:q1(e.manifest),createdBySubject:e.createdBySubject}}function y5e(e={}){const t=e.client??sf(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=b5e(r);return n.data.map(a=>{const i=o.get(a.provider.name);return v5e(i===void 0?{model:a}:{model:a,logo:i})})},getSkills:async()=>(await g5e(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 h5e(t)).map(N$),getMcpConnector:async({connectorId:n})=>{const r=await t.mcpServers.get(n);return N$(r.data)},getMcpTools:async({connectorId:n})=>(await t.mcpServers.listTools(n)).data.flatMap(o=>typeof o.name=="string"&&o.name.trim()!==""?[d5e(o)]:[]),async searchAgents(n){var i;const r=s5e((n==null?void 0:n.limit)??i5e),o=(i=n==null?void 0:n.query)==null?void 0:i.trim(),a=await l5e({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(fQt),...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=cC(o),s=r==null?void 0:r.trim();if(a==="update"){const d=(await I$(t)).find(p=>p.name===n);return d?(await t.agents.update(d.id,{...s?{description:s}:{},manifest:i}),{agentId:d.id}):{}}return{agentId:(await t.agents.create({name:n,description:s||n,manifest:i})).data.id}},async deleteAgent({agentName:n}){const o=(await I$(t)).find(a=>a.name===n);o&&await t.agents.delete(o.id)}}}function x5e(e){return{id:e.modelId,name:e.name,properties:e.properties}}function hQt(e){return{modelId:e.id,name:e.name,properties:e.properties??{}}}function ET(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(x5e)}}function w5e(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(x5e)}}var gQt=[...Object.values(DWt),"custom"];function mQt(e){return gQt.includes(e)}function O$(e){var o;const t=e.models.map(hQt);if(!mQt(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 _5e(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(w5e),listModelProviders:async()=>(await e.settings.modelProviders.list()).data.map(ET),createModelProvider:async n=>{const r=await t({type:n.type,apiKey:n.apiKey}),o=await e.settings.modelProviders.create({manifest:O$({type:n.type,name:n.name,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return ET(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:O$({type:n.type,name:n.id,apiKey:r,...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},models:n.models})});return ET(o.data)},deleteModelProvider:async({id:n})=>{await e.settings.modelProviders.delete(n)}}}function bQt(e){return{id:e.name,name:e.name,description:e.description,repoURL:e.url,path:e.path??"",ref:e.ref}}function S5e(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 k5e(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 E5e(e){return{getSkillCatalog:async()=>(await e.catalogs.skills.list()).data.map(bQt),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=>k5e(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:S5e(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 uC="parallel",vQt="Parallel";function T5e(e){return e===uC?vQt:e}function A5e(e){return{id:e.type,name:T5e(e.type),type:e.type}}function TT(e){return{id:e.type,name:T5e(e.type),catalogId:e.type,isConnected:!0}}function C5e({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 j$({type:e,apiKey:t}){if(e!==uC)throw new Error(`Unsupported web-search provider type: ${e}`);return{type:uC,auth:{apiKey:t}}}function R5e(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(A5e),listWebSearchProviders:async n=>{let r;try{const o=await e.settings.webSearchProviders.get();r=[TT(o.data.manifest)]}catch(o){if(o instanceof Sn)r=[];else throw o}return C5e({providers:r,query:n==null?void 0:n.query})},createWebSearchProvider:async n=>{const r=await e.settings.webSearchProviders.createOrUpdate({manifest:j$({type:n.type,apiKey:n.apiKey})});return TT(r.data.manifest)},updateWebSearchProvider:async n=>{const r=await t(n.apiKey),o=await e.settings.webSearchProviders.createOrUpdate({manifest:j$({type:uC,apiKey:r})});return TT(o.data.manifest)}}}function I5e(e={}){const t=e.client??sf(e);return{listPermissions:async n=>t.internal.listPermissions(n)}}var yQt=25,xQt=1e3;function Qme(e){return e instanceof Date?e.toISOString():e}function wQt(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 Jme(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 DE(e){return{id:e.id,name:e.name,description:e.description,status:e.status,statusReason:e.statusReason,manifest:wQt(e.manifest),createdBySubject:e.createdBySubject,createdAt:Qme(e.createdAt),updatedAt:Qme(e.updatedAt)}}function N5e(e){const{client:t}=e;return{async listEnvironments(n){const r=Math.min(Math.max((n==null?void 0:n.limit)??yQt,1),xQt),o=await t.sandboxEnvironments.list({limit:r,...(n==null?void 0:n.pageToken)===void 0||n.pageToken===""?{}:{pageToken:n.pageToken}});return Np(o,DE)},async getEnvironment({name:n}){const{data:r}=await t.sandboxEnvironments.get(n);return DE(r)},async createEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.create({manifest:Jme(n)});return DE(r)},async createOrUpdateEnvironment({manifest:n}){const{data:r}=await t.sandboxEnvironments.createOrUpdate({manifest:Jme(n)});return DE(r)},async deleteEnvironment({name:n}){await t.sandboxEnvironments.delete(n)}}}var ebe=25;async function LE(e){const t=await I$(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 tbe(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 _Qt(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 SQt(e){return e.status??"active"}function zE(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:SQt(e.manifest),lastRunAt:null,createdBySubject:e.createdBySubject}}function nbe(e){return{task:e.task,cron:e.cron,timezone:e.timezone??"UTC",status:e.status??"active"}}function rbe(e){return e instanceof Date?e.toISOString():e}function obe(e){return{id:e.id,scheduleId:e.scheduleId,name:e.name,scheduledFor:rbe(e.scheduledFor),status:e.status,reason:e.reason,triggeredAt:e.triggeredAt==null?null:rbe(e.triggeredAt),triggeredBy:e.createdBySubject.subjectDisplayName||e.createdBySubject.subjectId}}function M5e(e){const{client:t}=e;return{async listSchedules(n){const r=await LE(t),o=_Qt(n),a=o.length===0?void 0:o.map(l=>tbe(l,r)).join(","),i=Math.min(Math.max((n==null?void 0:n.limit)??ebe,1),ebe),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 Np(s,l=>zE(l,r))},async getSchedule({id:n}){const r=await LE(t),{data:o}=await t.schedules.get(n);return zE(o,r)},async createSchedule(n){const r=await LE(t),o=tbe(n.agentId,r),{data:a}=await t.schedules.create({agentName:o,name:n.name,manifest:nbe(n)});return zE(a,r)},async updateSchedule(n){const r=await LE(t),{data:o}=await t.schedules.update(n.id,{name:n.name,manifest:nbe(n)});return zE(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(obe)},async createScheduleRun(n){const{data:r}=await t.schedules.createRun({scheduleId:n.scheduleId});return obe(r)}}}function kQt(e={}){const{catalog:t,permissions:n,...r}=e,o=sf(r),a=t??{modelCatalog:_5e(o),connectorCatalog:p5e(o),skillCatalog:E5e(o),sandboxCatalog:J3e(o),webSearchCatalog:R5e(o)};return sWt({chatServer:o5e({client:o}),...y5e({client:o}),catalog:a,sessions:a5e({...r,client:o}),metrics:t5e({...r,client:o}),schedules:M5e({client:o}),sandboxEnvironments:N5e({client:o}),permissions:n??I5e({client:o}),getMe:async()=>{const{data:i}=await o.auth.me();return{tenantId:i.tenantId}}})}const EQt=Object.freeze(Object.defineProperty({__proto__:null,configFromHarness:dX,createConnectorCatalog:p5e,createHarnessAgentMetricsServer:t5e,createHarnessAgentSessionsServer:a5e,createHarnessBuilderServer:y5e,createHarnessChatServer:o5e,createHarnessPermissionsServer:I5e,createModelProviderCatalog:_5e,createSandboxEnvironmentServer:N5e,createSandboxProviderCatalog:J3e,createScheduleServer:M5e,createSkillCatalog:E5e,createTrueForgeAgentUIServer:kQt,createTrueForgeClient:sf,createWebSearchProviderCatalog:R5e,filterUiSandboxProviders:Q3e,filterUiWebSearchProviders:C5e,getCapabilities:m5e,isDaytonaSandboxConfig:Zqt,listConfiguredMcpServers:h5e,listModels:f5e,listSkills:g5e,modelProviderLogosByName:b5e,toHarnessAgentSpec:cC,toHarnessAuth:u5e,toHarnessConnectorManifest:M$,toHarnessModelProvider:O$,toHarnessSandboxManifest:R$,toHarnessSkillManifest:S5e,toHarnessWebSearchManifest:j$,toModelSelection:v5e,toUiAgentSpec:q1,toUiCatalogModelProviderEntry:w5e,toUiConnector:Qm,toUiConnectorFromReadEntry:N$,toUiModelProvider:ET,toUiSandboxCatalogEntry:q3e,toUiSandboxProvider:kT,toUiSkill:k5e,toUiWebSearchCatalogEntry:A5e,toUiWebSearchProvider:TT},Symbol.toStringTag,{value:"Module"})),Ee="u">typeof window?window:void 0,Da="u">typeof globalThis?globalThis:Ee,$o=Da==null?void 0:Da.navigator,$e=Da==null?void 0:Da.document,Gr=Da==null?void 0:Da.location,K_=Da==null?void 0:Da.fetch,hX=Da!=null&&Da.XMLHttpRequest&&"withCredentials"in new Da.XMLHttpRequest?Da.XMLHttpRequest:void 0,abe=Da==null?void 0:Da.AbortController,TQt=Da==null?void 0:Da.CompressionStream,Qa=$o==null?void 0:$o.userAgent;function O5e(){return!(!Ee||Ee.navigator.onLine===!1)}const mx=typeof globalThis<"u"?globalThis:Ee;mx&&typeof self>"u"&&(mx.self=mx),mx&&typeof File>"u"&&(mx.File=function(){});const Ct=Ee??{},AQt="0.9.0",Fu={DEBUG:!1,LIB_VERSION:AQt,LIB_NAME:"browser-common"};var uc=(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})({}),P$=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const CQt=["$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"],RQt=["token"];function Dt(e,t){return e.indexOf(t)!==-1}const xN=function(e){return e.trim()},D$=function(e){return e.replace(/^\$/,"")};function j5e(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 P5e=Object.prototype,gX=P5e.hasOwnProperty,wN=P5e.toString,Lt=Array.isArray||function(e){return wN.call(e)==="[object Array]"},zo=e=>typeof e=="function",vn=e=>e===Object(e)&&!Lt(e),_i=e=>{if(vn(e)){for(const t in e)if(gX.call(e,t))return!1;return!0}return!1},je=e=>e===void 0,fn=e=>wN.call(e)=="[object String]",gw=e=>fn(e)&&e.trim().length===0,Kr=e=>e===null,Kt=e=>je(e)||Kr(e),to=e=>wN.call(e)=="[object Number]"&&e==e,wu=e=>to(e)&&e>0,ni=e=>wN.call(e)==="[object Boolean]",IQt=e=>Dt(CQt,e),NQt=e=>Dt(RQt,e);function D5e(e){return e===null||typeof e!="object"}function dC(e,t){return{}.toString.call(e)===`[object ${t}]`}function zy(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 L5e(e,Error)}}function mX(e){return"u">typeof Event&&L5e(e,Event)}function L5e(e,t){try{return e instanceof t}catch{return!1}}const MQt=[!0,"true",1,"1","yes"],Q6=e=>Dt(MQt,e),OQt=[!1,"false",0,"0","no"];function ibe(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 Pr(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(l){ibe(a,r,o,i,s,"next",l)}function s(l){ibe(a,r,o,i,s,"throw",l)}i(void 0)})}}const jQt=["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"],sbe=function(e,t=[]){if(!e)return!1;const n=e.toLowerCase();return jQt.concat(t).some(r=>{const o=r.toLowerCase();return n.indexOf(o)!==-1})};function Sc(e,t,n,r,o){return t>n&&(r.warn("min cannot be greater than max."),t=n),to(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),Sc(o??n,t,n,r))}var PQt=class{constructor(e){this.C={},this.I=e.I,this.R=Sc(e.bucketSize,0,100,e.A),this.$=Sc(e.refillRate,0,this.R,e.A),this.O=Sc(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 Dv="Mobile",Y_="Android",pC="Tablet",z5e="Android Tablet",$5e="iPad",F5e="Apple Watch",AT="Safari",_N="BlackBerry",U5e="Samsung Internet",CT="Chrome",B5e="Chrome iOS",H5e="Internet Explorer",V5e="Internet Explorer Mobile",G5e="Opera",W5e="Microsoft Edge",RT="Firefox",K5e="Firefox iOS",fC="Nintendo",hC="PlayStation",SN="Xbox",Y5e="Android Mobile",Z5e="Mobile Safari",J6="Windows",X5e="Windows Phone",lbe="Nokia",L$="Ouya",DQt="Generic "+Dv.toLowerCase(),q5e="Generic "+pC.toLowerCase(),z$="Konqueror",Q5e="Oculus Browser",J5e="Vivaldi",e4e="Yandex",t4e="Whale",n4e="DuckDuckGo",r4e="Pale Moon",o4e="Waterfox",$$="Brave",a4e="Claude",i4e="Codex",s4e="ChatGPT",l4e="Google Search App",eL=new RegExp("Version/(\\d+(\\.\\d+)?)"),tL=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),LQt=new RegExp(SN,"i"),zQt=new RegExp("PlayStation \\w+","i"),$Qt=new RegExp("Nintendo \\w+","i"),bX=new RegExp("BlackBerry|PlayBook|BB10","i"),FQt={"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"},c4e=function(e,t,n,r){return t=t||"",(function(a){return a!=null&&a.brave?$$:null})(n)||(r!=null&&r.detectGoogleSearchApp&&Dt(e,"GSA/")?l4e:Dt(e," OPR/")&&Dt(e,"Mini")?"Opera Mini":Dt(e," OPR/")?G5e:bX.test(e)?_N:Dt(e,"IEMobile")||Dt(e,"WPDesktop")?V5e:Dt(e,"OculusBrowser")?Q5e:Dt(e,"SamsungBrowser")?U5e:Dt(e,"Edge")||Dt(e,"Edg/")?W5e:Dt(e,"Vivaldi/")?J5e:Dt(e,"YaBrowser/")?e4e:Dt(e,"Whale/")?t4e:Dt(e,"DuckDuckGo/")||Dt(e,"Ddg/")?n4e:Dt(e,"Claude/")?a4e:Dt(e,"Codex/")?i4e:Dt(e,"ChatGPT/")?s4e:Dt(e,"FBIOS")?"Facebook Mobile":Dt(e,"UCWEB")||Dt(e,"UCBrowser")?"UC Browser":Dt(e,"CriOS")?B5e:Dt(e,"CrMo")||Dt(e,CT)?CT:Dt(e,Y_)&&Dt(e,AT)?Y5e:Dt(e,"FxiOS")?K5e:Dt(e.toLowerCase(),z$.toLowerCase())?z$:Dt(e,"Brave/")?$$:((a,i)=>i&&Dt(i,"Apple")||(function(s){return Dt(s,AT)&&!Dt(s,CT)&&!Dt(s,Y_)})(a))(e,t)?Dt(e,Dv)?Z5e:AT:Dt(e,"PaleMoon/")?r4e:Dt(e,"Waterfox/")?o4e:Dt(e,RT)?RT:Dt(e,"MSIE")||Dt(e,"Trident/")?H5e:Dt(e,"Gecko")?RT:"")},UQt={[V5e]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[W5e]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[CT]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[B5e]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[AT]:[eL],[Z5e]:[eL],[G5e]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[RT]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[K5e]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[z$]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[_N]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),eL],[Y5e]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[U5e]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Q5e]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[J5e]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[e4e]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[t4e]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[$$]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[a4e]:[tL],[i4e]:[tL],[s4e]:[tL],[n4e]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[r4e]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[o4e]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[l4e]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[H5e]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},BQt=function(e,t,n,r){const o=c4e(e,t,n,r),a=UQt[o];if(je(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},cbe=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[SN,e&&e[1]||""]],[new RegExp(fC,"i"),[fC,""]],[new RegExp(hC,"i"),[hC,""]],[bX,[_N,""]],[new RegExp(J6,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[X5e,""];if(new RegExp(Dv).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let r=FQt[n[1]]||"";return/arm/i.test(t)&&(r="RT"),[J6,r]}return[J6,""]}],[/((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=je(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Y_,[e[2],e[3],e[4]||"0"].join(".")]:[Y_,""]],[/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",""]]],u4e=function(e){for(let t=0;cbe.length>t;t++){const[n,r]=cbe[t],o=n.exec(e),a=o&&(zo(r)?r(o,e):r);if(a)return a}return["",""]},d4e=function(e){return $Qt.test(e)?fC:zQt.test(e)?hC:LQt.test(e)?SN:new RegExp(L$,"i").test(e)?L$:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?X5e:/iPad/.test(e)?$5e:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?F5e:bX.test(e)?_N:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(lbe,"i").test(e)?lbe:/(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(Dv).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)?Y_:z5e:new RegExp("(pda|Mobile)","i").test(e)?DQt:new RegExp(pC,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?q5e:""},HQt=function(e,t){var n;const r=d4e(e);return r===$5e||r===z5e||r==="Kobo"||r==="Kindle Fire"||r===q5e?pC:r===fC||r===SN||r===hC||r===L$?"Console":r===F5e?"Wearable":r?Dv:(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)?Dv:pC:"Desktop";var o,a,i},nL=/\bFBAV\/(\d+(?:\.\d+)*)/i,ube=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",nL],[/\bFBAN\/EMA\b/i,"Facebook Lite",nL],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",nL],[/\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"]],F$="[Truncated]",Q1="[Unserializable]";function Pb(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 p4e(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=Q1}Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0,configurable:!0})}return e}const IT=3e5;var f4e=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,IT);if(!t)return this.ts=n,void(this.es=n+r);this.es=Math.max(this.es,Math.min(n+r,this.ts+IT))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(IT,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 VQt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function dbe(e,t){return typeof(n=e)=="string"&&VQt.test(n)?e:t();var n}function h4e(e,t){const n=new Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function Up(e){return e&&e.split("#")[0]}function pbe(e){try{return e()}catch{return}}function g4e(e,t){const n=setTimeout(e,t);return n!=null&&n.unref&&(n==null||n.unref()),n}function fbe(e,t,n){return m4e.apply(this,arguments)}function m4e(){return(m4e=Pr(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((o,a)=>{r=g4e(()=>{try{n==null||n(),o()}catch(i){a(i)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}let $E,hbe,rL;function GQt(e){const t=globalThis._posthogChunkIds;if(!t)return;const n=Object.keys(t);return rL&&n.length===hbe||(hbe=n.length,rL=n.reduce((r,o)=>{$E||($E={});const a=$E[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,d=t[o];if(c&&d){r[c]=d,$E[o]=[c,d];break}}}return r},{})),rL}function mw(e){return mw=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},mw(e)}function WQt(e,t,n){return(t=(function(r){var o=(function(a){if(mw(a)!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var s=i.call(a,"string");if(mw(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)})(r);return mw(o)=="symbol"?o:o+""})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gbe(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?gbe(Object(n),!0).forEach(function(r){WQt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gbe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var KQt=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 Pr(function*(){for(const n of e)n.stacktrace&&n.stacktrace.frames&&Lt(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 Pr(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},d={type:o.type,value:o.value,mechanism:c};o.stack&&(d.stacktrace={type:"raw",frames:o.stack}),n.push(d),o.cause&&r(o.cause,l,"cause");for(const p of(s=o.errors)!==null&&s!==void 0?s:[])r(p,l,"member")};return r(e),n}buildParsingContext(e){var t;return{chunkIdMap:GQt(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(zy(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 Lt(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,m,b=0)=>{const y=d(m,b),x=y.apply;if(y.apply=A=>{s.push(f);try{return x(A)}finally{s.pop()}},b>4||b>0&&s.indexOf(f)!==-1)return this.coerceFallback(y);const _=typeof f=="object"&&f!==null||typeof f=="function";if(b===0&&r>=50||_&&i.has(f))return;_&&i.add(f),b===0&&r++;const k=this.getAggregateErrors(f);let E,T;a||(a=!!k);try{if(E=this.applyCoercers(f,y),!E)throw l}catch(A){if(A===l)return void(b===0&&r--);if(!a)throw A;E=this.coerceFallback(y)}if(!k||r>=50)return E;try{T=k.length}catch{return E}if(!Number.isInteger(T)||0>T||T>4294967295)return E;const C=[];for(let A=0;50>r&&1e3>o&&T>A;A++){let R;o++;try{R=y.next(k[A])}catch{r++,R=this.coerceFallback(d(m+1))}R&&C.push(R)}return ce(ce({},E),{},{errors:C})},d=(f,m=0)=>ce(ce({},t),{},{syntheticException:f==0?t.syntheticException:void 0,mechanism:f==0?e:{},apply(b){const y=c(b,f,m+1);if(!y)throw l;return y},next:b=>c(b,f+1)}),p=d(n);return ce(ce({},p),{},{apply:f=>{var m;return(m=c(f,n))!==null&&m!==void 0?m:this.coerceFallback(p)}})}};const YQt=/^([a-z][a-z0-9.+-]+):/i,ZQt=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function XQt(e){if(!e||e==="<anonymous>")return!1;const t=YQt.exec(e);return!t||ZQt.includes(t[1].toLowerCase())}function U$(e,t,n,r,o){const a={platform:e,filename:t,function:n==="<anonymous>"?"?":n,in_app:XQt(t)};return je(r)||(a.lineno=r),je(o)||(a.colno=o),a}const b4e=(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]},qQt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,QQt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,JQt=/\((\S*)(?::(\d+))(?::(\d+))\)/,eJt=(e,t)=>{const n=qQt.exec(e);if(n){const[,o,a,i]=n;return U$(t,o,"?",+a,+i)}const r=QQt.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){const i=JQt.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}const[o,a]=b4e(r[1]||"?",r[2]);return U$(t,a,o,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},tJt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,nJt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,rJt=(e,t)=>{const n=tJt.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const a=nJt.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]=b4e(o,r),U$(t,r,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},mbe=/\(error: (.*)\)/;function vX(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function oJt(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(!vX(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 aJt(e,t){const n=t.start+t.length,r=y4e(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function v4e(e,t){let n=t.start;for(;n>0&&vX(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function y4e(e,t){const n=t.start+t.length;let r=n;for(;e.length>r&&vX(e[r],e[r-t.length]);)r++;return r-n}function iJt(e,t){const n=t[0];let r=e.length-(n?v4e(e,n):0);for(const o of t)r-=y4e(e,o);return r}function sJt(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 lJt=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const n=fn(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 dC(e,"DOMException")}isDOMError(e){return dC(e,"DOMError")}},cJt=class{match(e){return zy(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}}},uJt=class{match(e){return!!dC(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 fn(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(fn(r.filename)&&r.filename.length!==0&&o!==0)return`Error
|
|
999
999
|
at ${r.filename}:${o}:${a}`}};const dJt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var pJt=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(dJt);return r&&(t=r[1],n=r[2]),[t,n]}};const fJt=["fatal","error","warning","log","info","debug"];function x4e(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 hJt=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(mX(e))return e.constructor.name;const t="name"in e?e.name:void 0;return fn(t)&&!gw(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: ${x4e(e)}`}isSeverityLevel(e){return fn(e)&&!gw(e)&&fJt.indexOf(e)>=0}getStack(e){try{return fn(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:fn(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(zy(n))return n}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},gJt=class{match(e){return mX(e)}coerce(e,t){var n;const r=e.constructor.name;return{type:r,value:`${r} captured as exception with keys: ${x4e(e)}`,stack:(n=t.syntheticException)===null||n===void 0?void 0:n.stack,synthetic:!0}}},mJt=class{match(e){return D5e(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}}},bJt=class{match(e){return dC(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!mX(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 D5e(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 gC="$message",mC="$timestamp",vJt=new Set([gC,mC]),oL={enabled:!0,max_bytes:32768};function bC(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:oL.enabled,max_bytes:xJt(e.max_bytes,oL.max_bytes)}:ce({},oL)}var yJt=class{constructor(e){this.ns=[],this.ss=0,this.Mr=bC(e)}setConfig(e){this.Mr=bC(e),this.rs()}add(e){const t=(function(r){let o;try{o=j5e(r)}catch{return}try{const a=JSON.parse(o);if(!vn(a))return;const i=a,s=i[gC],l=i[mC];return!fn(s)||s.trim().length===0||!fn(l)&&!to(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 xJt(e,t){if(!to(e)||e===1/0||e===-1/0)return t;const n=Math.floor(e);return 0>n?t:n}const bbe=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function vbe(e){return typeof e=="string"||e}function ybe(e){return typeof e=="string"?e:void 0}const wJt=["$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"],w4e="NativeGzipValidationError",B$=e=>e.length>=2&&e[0]===31&&e[1]===139,xbe=(e,t)=>e===P$.GZipJS||t===P$.GZipJS||t==="gzip",wbe=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let bx;const FE=e=>{throw h4e(w4e,`Native gzip produced invalid output: ${e}`)},_Jt=(_be=Pr(function*(e,t){18>e.size&&FE("too-short");const n=new Uint8Array(yield e.slice(0,10).arrayBuffer());B$(n)&&n[2]===8||FE("invalid-header");const r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(a=>{const i=(()=>{if(bx)return bx;bx=[];for(let l=0;256>l;l++){let c=l;for(let d=0;8>d;d++)c=1&c?3988292384^c>>>1:c>>>1;bx[l]=c>>>0}return bx})();let s=4294967295;for(let l=0;a.length>l;l++)s=i[255&(s^a[l])]^s>>>8;return(4294967295^s)>>>0})(t)&&FE("invalid-crc");const o=t.length>>>0;r.getUint32(4,!0)!==o&&FE("invalid-size")}),function(e,t){return _be.apply(this,arguments)});var _be;function H$(){return H$=Pr(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=Pr(function*(d){try{yield i.abort(d)}catch{}throw d}),function(d){return r.apply(this,arguments)})),l=new Response(a.readable).blob(),[c]=yield Promise.all([l,s]);return yield _Jt(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}),H$.apply(this,arguments)}function _4e(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 SJt={}.propertyIsEnumerable;function vC(e,t){try{return S4e(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function yX(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:F$};if(n.remainingNodes--,ni(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:Pb(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:F$};if(e instanceof Date){const o=e.getTime(),a=Number.isFinite(o)?e.toISOString():String(e);return{stringValue:typeof a=="string"?Pb(a):String(a)}}n.ancestors.add(e);try{try{const o=e.toJSON;if(typeof o=="function")return yX(o.call(e),t,n,r+1)}catch{}return Lt(e)?{arrayValue:{values:kJt(e,t,n,r+1)}}:{kvlistValue:{values:S4e(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:Pb(String(e))}}function kJt(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(Kt(s))continue;o.push(yX(s,t,n,r))}catch{o.push({stringValue:Q1})}return e.length>i&&o.push({stringValue:F$}),o}function S4e(e,t,n,r){const o=[];for(const a in e)if(SJt.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(Kr(i)||je(i))continue;o.push({key:Pb(a),value:yX(i,t,n,r)})}catch{o.push({key:Pb(a),value:{stringValue:Q1}})}}return o}function k4e(e,t,n){return ce(ce(ce(ce({},p4e({},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 EJt=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function E4e(e,t){const n=p4e({},e),r={};for(const o of EJt)({}).hasOwnProperty.call(n,o)&&(r[o]=n[o],delete n[o]);return[...vC(n,t),...vC(r,t)]}const Sbe={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"},T4e={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}},TJt=T4e.info;function AJt(e){try{return Pb(String(e))}catch{return Q1}}function CJt(e,t,n,r){const o=e.level||"info",{text:a,number:i}=T4e[o]||TJt,s=(function(f=Date.now()){return String(f)+"000000"})(to(r)?r:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),Kt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),Kt(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),d=e.attributes;if(d){let f=[];try{f=Object.keys(d)}catch{f=[]}for(const m of f){let b;try{b=d[m]}catch{b=Q1}Object.defineProperty(c,m,{value:b,enumerable:!0,writable:!0,configurable:!0})}}const p={timeUnixNano:s,observedTimeUnixNano:s,severityNumber:i,severityText:a,body:{stringValue:AJt(e.body)},attributes:vC(c,n)};return e.trace_id&&(p.traceId=e.trace_id),e.span_id&&(p.spanId=e.span_id),je(e.trace_flags)||(p.flags=e.trace_flags),p}function A4e(e,t,n){return k4e(e,t,n)}function C4e(e,t,n,r){return{resourceLogs:[{resource:{attributes:E4e(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var R4e=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=g4e(()=>{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 I4e(){return .75+.5*Math.random()}function N4e(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 RJt=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 R4e(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new f4e,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(uc.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:CJt(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=Lt(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 Pr(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Pr(function*(){var t;e.ps.clear();let n=(t=e._instance.getPersistedProperty(uc.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),d=C4e(c.map(f=>f.record),e.qs(),(a=e.fs)!==null&&a!==void 0?a:e._instance.getLibraryId(),e._instance.getLibraryVersion()),p=yield e._instance.js(d);if(e._s!==s)return;if(p.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(p),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),p.kind==="retry-later"||(p.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."):p.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(uc.LogsQueue))!==null&&i!==void 0?i:[],o+=c.length,p.kind==="fatal"))throw p.error}})()}Bs(e){var t=this;return Pr(function*(){var n;const r=Math.max(0,e-t.bs),o=(n=t._instance.getPersistedProperty(uc.LogsQueue))!==null&&n!==void 0?n:[];t._instance.setPersistedProperty(uc.LogsQueue,o.slice(r)),yield t.vs()})()}qs(){return A4e(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const n=(t=this._instance.getPersistedProperty(uc.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(uc.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(N4e(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(uc.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Pr(function*(){t.ps.clear();const n=t.flush().catch(()=>{});e!==void 0?yield fbe(n,e):yield n})()}flushWithTimeout(e){var t=this;return Pr(function*(){const n=t.flush();yield fbe(n,e,()=>{n.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=I4e(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const aL=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function kbe(e){return String(e)+"000000"}function Ebe(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 IJt=class{constructor(e,t,n){this._instance=e,this.Mr=t,this.A=n,this.zs=new Map,this.ps=new R4e(()=>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 f4e,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=Pr(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=Ebe(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(aL.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,aL)]+=1;break}}}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const n=Lt(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(N4e(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return Pr(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=I4e()):(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 k4e(a,i,s)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),o=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:E4e(n)},scopeMetrics:[{scope:{name:r,version:o},metrics:t}]}]};var t,n,r,o}ho(e){const t=kbe(Date.now()),n=new Map;for(const i of e.values()){var r;const s=Ebe(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=vC((r=i.attributes)!==null&&r!==void 0?r:{},this.A),d=kbe(i.windowStartMs);if(i.type==="count"){var o;const p={attributes:c,startTimeUnixNano:d,timeUnixNano:t,asDouble:(o=i.total)!==null&&o!==void 0?o:0};l.sum.dataPoints.push(p)}else if(i.type==="gauge"){var a;const p={attributes:c,timeUnixNano:t,asDouble:(a=i.last)!==null&&a!==void 0?a:0};l.gauge.dataPoints.push(p)}else i.hist&&l.histogram.dataPoints.push({attributes:c,startTimeUnixNano:d,timeUnixNano:t,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:aL})}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 M4e=(e,{debugEnabled:t}={})=>{const n={N(r,...o){Ee&&(Fu.DEBUG||Ee.POSTHOG_DEBUG||t)&&!je(Ee.console)&&Ee.console&&("__rrweb_original__"in Ee.console[r]?Ee.console[r].__rrweb_original__:Ee.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)=>M4e(`${e} ${r}`,o)};return n},Ze=M4e("[PostHog.js]"),Xr=Ze.createLogger,NJt=Xr("[ExternalScriptsLoader]"),yC=e=>{const t=$e==null?void 0:$e.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]}},nh=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return NJt.warn(`${t} was requested but loading of external scripts is disabled.`),n("Loading of external scripts is disabled");const r=yC(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(!$e)return n("document not found");if(yC(t))return nh(e,t,n);let a=$e.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")$e.head.appendChild(a);else{const s=$e.querySelectorAll("body > script");var i;s.length>0?(i=s[0].parentNode)===null||i===void 0||i.insertBefore(a,s[0]):$e.body.appendChild(a)}};$e!=null&&$e.body?o():$e==null||$e.addEventListener("DOMContentLoaded",o)},iL={},Tbe=(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)};Ct.__PosthogExtensions__=Ct.__PosthogExtensions__||{},Ct.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t==="remote-config"){const o=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void nh(e,o,n)}const r=e.config.strict_script_versioning;if(r){const o=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),a=iL[o];if(r==="fallback"&&a){if(yC(a))return void nh(e,a,n);delete iL[o]}return void nh(e,o,r==="fallback"?(i,s)=>{if(i)if(typeof i=="string")n(i);else{var l;const c=Tbe(e,t);iL[o]=c;const d=yC(o);d==null||(l=d.parentNode)===null||l===void 0||l.removeChild(d),nh(e,c,n)}else n(void 0,s)}:n)}nh(e,Tbe(e,t),n)},Ct.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{const r=e.requestRouter.endpointFor("api",t);nh(e,r,n)},Fu.DEBUG=!1,Fu.LIB_VERSION="1.435.2",Fu.LIB_NAME="web";var Ro=Fu;const MJt="$people_distinct_id",gl="distinct_id",xX="$device_id",sL="$device_model",xC="__alias",OJt="__cmpns",Abe="$fbc",Db="$fbc_persistence",Cbe="$fbp",bw="$fbp_persistence",V$="__timers",O4e="$autocapture_disabled_server_side",G$="$heatmaps_enabled_server_side",W$="$exception_capture_enabled_server_side",j4e="$error_tracking_suppression_rules",K$="$error_tracking_capture_extension_exceptions",Y$="$web_vitals_enabled_server_side",wX="$dead_clicks_enabled_server_side",_X="$product_tours_enabled_server_side",P4e="$logs_capture_enabled_server_side",D4e="$web_vitals_allowed_metrics",vw="$session_recording_remote_config",jJt="$session_recording_enabled_server_side",PJt="$replay_sample_rate",DJt="$replay_override_sampling",LJt="$replay_override_linked_flag",zJt="$replay_override_url_trigger",$Jt="$replay_override_event_trigger",ub="$sesid",L4e="$session_is_sampled",FJt="$session_past_minimum_duration",UJt="$session_recording_url_trigger_activated_session",BJt="$session_recording_event_trigger_activated_session",HJt="$debug_first_full_snapshot_timestamp",VJt="$sess_rec_flush_size",xl="$enabled_feature_flags",Iu="$active_feature_flags",Z$="$early_access_features",Nh="$feature_flag_details",wp="$feature_flag_payloads",Mh="$feature_flag_request_id",yw="$minimal_flag_called_events",sc="$override_feature_flags",rh="$override_feature_flag_payloads",_p="$stored_person_properties",Sp="$stored_group_properties",z4e="$groups",Dx="$surveys",wC="$surveys_loaded_at",$4e="$surveys_activated",F4e="$surveys_activated_session",U4e="$surveys_activated_timestamps",X$="ph_product_tours",GJt="$product_tours_activated",WJt="$product_tours_activated_session",KJt="$conversations_widget_session_id",YJt="$conversations_ticket_id",ZJt="$conversations_widget_state",XJt="$conversations_user_traits",kp="$flag_call_reported",Lx="$flag_call_reported_session_id",Z_="$feature_flag_errors",Mp="$feature_flag_evaluated_at",Ja="$user_state",q$="$client_session_props",qJt="$capture_rate_limit",B4e="$initial_campaign_params",H4e="$initial_referrer_info",db="$initial_person_info",SX="$epp",lL="$posthog_cookieless",V4e="$cookieless_mode",G4e="$sdk_debug_extensions_init_method",W4e="$sdk_debug_extensions_init_time_ms",kX="$sdk_debug_recording_script_not_loaded",EX="$sdk_debug_replay_stale_config",K4e="$sdk_debug_replay_event_trigger_status",Y4e="$sdk_debug_replay_linked_flag_trigger_status",Z4e="$sdk_debug_replay_matched_recording_trigger_groups",X4e="$sdk_debug_replay_pending_trigger_conditions",q4e="$sdk_debug_replay_remote_trigger_matching_config",Q4e="$sdk_debug_replay_trigger_groups_count",J4e="$sdk_debug_replay_url_trigger_status",QJt="$session_recording_start_reason",TX="PostHog loadExternalDependency extension not found.",Nu="anonymous",NT="identified",eje="identified_only",X_="visibilitychange",_C="beforeunload",AX="$pageview",Rbe="$pageleave",tje="$identify",Ibe="$groupidentify";function pb(e,t){Lt(e)&&e.forEach(t)}function Wn(e,t){if(!Kt(e))if(Lt(e))e.forEach(t);else if((n=>n instanceof FormData)(e))e.forEach((n,r)=>t(n,r));else for(const n in e)gX.call(e,n)&&t(e[n],n)}const jr=function(e,...t){for(const n of t)for(const r in n)n[r]!==void 0&&(e[r]=n[r]);return e};function MT(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 JJt=function(e){return function(...t){try{return e.apply(this,t)}catch(n){Ze.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ze.critical(n)}}},CX=function(e){const t={};return Wn(e,function(n,r){(fn(n)&&n.length>0||to(n))&&(t[r]=n)}),t};function nje(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 een=["herokuapp.com","vercel.app","netlify.app"];function ten(e){const t=e==null?void 0:e.hostname;if(!fn(t))return!1;const n=t.split(".").slice(-2).join(".");for(const r of een)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 Q$(e){return e.name==="ph_toolbar_internal"}const xw=e=>{if($e){try{const t=e+"=",n=$e.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 to(e)&&isFinite(e)&&Math.floor(e)===e});var nen=class J${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 J$(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 J$(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}},ren=class{generate(){const e=this.generateOrAbort();if(!je(e))return e;{this.Ct=0;const t=this.generateOrAbort();if(je(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const e=(()=>{const t=Date.now();return to(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 nen.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 oen}};let rje=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};Ee&&!je(Ee.crypto)&&crypto.getRandomValues&&(rje=e=>crypto.getRandomValues(e));var oen=class{nextUint32(){return this.Rt.length>this.Et||(rje(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}};let Nbe;const _l=()=>aen().toString(),aen=()=>(Nbe||(Nbe=new ren)).generate();let vx="";const ien=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Dm=null;const Vr={At(){if(!Kr(Dm))return Dm;if(Dm=!1,$e)try{const e=`__ph_cookie_support_${_l()}`;Vr.$t(e,"xyz"),Dm=xw(e)==='"xyz"',Vr.Lt(e)}catch{Dm=!1}return Dm},Pt(e){Ze.error("cookieStore error: "+e)},Ot:xw,Dt(e){let t;try{t=JSON.parse(Vr.Ot(e))||{}}catch{}return t},$t(e,t,n,r,o){if(!$e)return!1;try{let a="",i="";const s=(function(c,d){if(d){let p=(function(f,m=$e){if(vx)return vx;if(!m||["localhost","127.0.0.1"].includes(f))return"";const b=f.split(".");let y=Math.min(b.length,8);const x="dmn_chk_"+_l();for(;!vx&&y--;){const _=b.slice(y).join("."),k=x+"=1;domain=."+_+";path=/";m.cookie=k+";max-age=3",m.cookie.includes(x)&&(m.cookie=k+";max-age=0",vx=_)}return vx})(c);if(!p){const f=(m=>{const b=m.match(ien);return b?b[0]:""})(c);f!==p&&Ze.info("Warning: cookie subdomain discovery mismatch",f,p),p=f}return p?"; domain=."+p:""}return""})($e.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&&Ze.warn("cookieStore warning: large cookie, len="+l.length),$e.cookie=l,!0}catch{return!1}},Lt(e,t){if($e!=null&&$e.cookie&&(!t||!Kr(xw(e))))try{Vr.$t(e,"",-1,t)}catch{return}}};let cL=null;const Cn={At(){if(!Kr(cL))return cL;let e=!0;if(je(Ee))e=!1;else try{const t="__mplssupport__";Cn.$t(t,"xyz"),Cn.Ot(t)!=='"xyz"'&&(e=!1),Cn.Lt(t)}catch{e=!1}return e||Ze.error("localStorage unsupported; falling back to cookie store"),cL=e,e},Pt(e){Ze.error("localStorage error: "+e)},Ot(e){try{return Ee==null?void 0:Ee.localStorage.getItem(e)}catch(t){Cn.Pt(t)}return null},Dt(e){try{return JSON.parse(Cn.Ot(e))||{}}catch{}return null},$t(e,t){try{return Ee==null||Ee.localStorage.setItem(e,JSON.stringify(t)),!0}catch(n){Cn.Pt(n)}return!1},Lt(e){try{Ee==null||Ee.localStorage.removeItem(e)}catch(t){Cn.Pt(t)}}},uL=[_p,Iu,xl,Nh,wp,Mh,Mp,Z_,kp],oh=[xX,gl,ub,L4e,SX,db,Db,Ja],SC=e=>e+"_cpm",sen=["__proto__","constructor","prototype"],dL=e=>{if(!vn(e))return{};const t={};return Object.keys(e).forEach(n=>{sen.indexOf(n)===-1&&(t[n]=e[n])}),t},pL=(e,t=[])=>{const n={};return[...oh,...t].forEach(r=>{const o=e[r];je(o)||Kr(o)||o===""||(n[r]=o)}),n},oje=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)},Mbe=(e,t)=>({p:t,f:oje(JSON.stringify(e))}),Obe=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const n=Vr.Dt(SC(e)),r=(n==null?void 0:n.f)===oje(t)&&Lt(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},fL=(e,t)=>t+"|"+(Vr.Ot(SC(e))||""),Lm={},e7={At:()=>!0,Pt(e){Ze.error("memoryStorage error: "+e)},Ot:e=>e in Lm?Lm[e]:null,Dt:e=>e in Lm?Lm[e]:null,$t:(e,t)=>(Lm[e]=t,!0),Lt(e){delete Lm[e]}};let Wf=null;const yr={At(){if(!Kr(Wf))return Wf;if(Wf=!0,je(Ee))Wf=!1;else try{const e="__support__";yr.$t(e,"xyz"),yr.Ot(e)!=='"xyz"'&&(Wf=!1),yr.Lt(e)}catch{Wf=!1}return Wf},Pt(e){Ze.error("sessionStorage error: ",e)},Ot(e){try{return Ee==null?void 0:Ee.sessionStorage.getItem(e)}catch(t){yr.Pt(t)}return null},Dt(e){try{return JSON.parse(yr.Ot(e))||null}catch{}return null},$t(e,t){try{return Ee==null||Ee.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(n){yr.Pt(n)}return!1},Lt(e){try{Ee==null||Ee.sessionStorage.removeItem(e)}catch(t){yr.Pt(t)}}};var len=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 Q6(e)?1:Dt(OQt,e)?0:-1}get Lo(){const e=this.Mr.opt_out_capturing_persistence_type,t=e==="localStorage"?Cn:Vr,n=t.At()?t:e7;if(!this.qo||this.qo!==n){this.qo=n;const r=e==="localStorage"?Vr:Cn;r.Ot(this.No)&&(this.qo.Ot(this.No)||this.optInOut(Q6(r.Ot(this.No))),r.Lt(this.No,this.Mr.cross_subdomain_cookie))}return this.qo}Oo(){return!!this.Mr.respect_dnt&&[$o==null?void 0:$o.doNotTrack,$o==null?void 0:$o.msDoNotTrack,Ct.doNotTrack,$o==null?void 0:$o.globalPrivacyControl].some(e=>Q6(e))}};function aje(e,t){var n;const r=e==null||(n=e.config)===null||n===void 0?void 0:n.get_current_url;if(!zo(r))return t;try{const o=r(t);return fn(o)&&o?o:t}catch(o){return Ze.error("Error in get_current_url, falling back to window.location.href",o),t}}function jbe(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 zc(e){return!!e&&e.nodeType===1}function xa(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function ije(e){return!!e&&e.nodeType===3}function RX(e){return!!e&&e.nodeType===11&&zc(e.host)}function IX(e){return e?xN(e).split(/\s+/):[]}function Pbe(e,t){const n=(function(r){var o;const a=Ee==null||(o=Ee.location)===null||o===void 0?void 0:o.href;return je(a)?void 0:aje(r,a)})(t);return!!(n&&e&&e.some(r=>n.match(r)))}function Lv(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 IX(t)}function sje(e){return Kt(e)?null:xN(e).split(/(\s+)/).filter(t=>_w(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function q_(e){let t="";return Lb(e)&&!Q_(e)&&e.childNodes&&e.childNodes.length&&Wn(e.childNodes,function(n){var r;ije(n)&&n.textContent&&(t+=(r=sje(n.textContent))!==null&&r!==void 0?r:"")}),xN(t)}function ww(e){var t;return je(e.target)?e.srcElement||null:!((t=e.target)===null||t===void 0)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}const NX=["a","button","form","input","select","textarea","label"];function t7(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 n7(e,t){if(je(t))return!0;for(const n of e)if(t.some(r=>t7(n,r)))return!0;return!1}function lje(e){const t=e.parentNode;return!(!t||!zc(t))&&t}const hL=[".ph-no-autocapture","[data-ph-no-autocapture]"],cje=["next","previous","prev",">","<"],cen=[...cje,"+","-","−","–"],Dbe=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Lbe=[".ph-no-rageclick",".ph-no-capture"],uen=["","text","search","email","password","url","tel","number"];function uje(e,t){if(!Ee||MX(e))return!1;let n,r,o;var a,i;if(ni(t)?(n=!!t&&Lbe,r=void 0,o=!1):(n=(a=t==null?void 0:t.css_selector_ignorelist)!==null&&a!==void 0?a:Lbe,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||!zc(l))&&(!!xa(l,"textarea")||(xa(l,"input")?Dt(uen,(l.getAttribute("type")||"").toLowerCase()):(function(c){var d;if(c.isContentEditable)return!0;const p=(d=c.getAttribute)===null||d===void 0?void 0:d.call(c,"contenteditable");return p==="true"||p===""})(l)))})(e))return!1;const{targetElementList:s}=dje(e,!1);return!(function(l,c){if(l===!1||je(l))return!1;let d;if(l===!0)d=cje;else{if(!Lt(l))return!1;if(l.length>10)return Ze.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;d=l.map(p=>p.toLowerCase())}return c.some(({safeText:p,ariaLabel:f})=>d.some(m=>Dbe(p,m)||Dbe(f,m)))})(r,s.map(l=>{var c;return{safeText:q_(l).toLowerCase(),ariaLabel:((c=l.getAttribute("aria-label"))===null||c===void 0?void 0:c.toLowerCase().trim())||""}}))&&!n7(s,n)}const MX=e=>!e||xa(e,"html")||!zc(e),dje=(e,t)=>{if(!Ee||MX(e))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const r=[e];let o=e;for(;o.parentNode&&!xa(o,"body");){if(RX(o.parentNode)){r.push(o.parentNode.host),o=o.parentNode.host;continue}const a=lje(o);if(!a)break;if(t||NX.indexOf(a.tagName.toLowerCase())>-1)n=!0;else try{const i=Ee.getComputedStyle(a);i&&i.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}r.push(a),o=a}return{parentIsUsefulElement:n,targetElementList:r}};function Lb(e){const t=new Set;let n=0;for(let a=e;a.parentNode&&!xa(a,"body");a=a.parentNode){if(n++>=1e3||t.has(a))return!1;t.add(a);const i=Lv(a);if(Dt(i,"ph-sensitive")||Dt(i,"ph-no-capture"))return!1}if(Dt(Lv(e),"ph-include"))return!0;const r=e.type||"";if(fn(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}const o=e.name||e.id||"";return!fn(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 Q_(e){return!!(xa(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||xa(e,"select")||xa(e,"textarea")||e.getAttribute("contenteditable")==="true")}const zbe=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}))$"),$be=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,den=[16,15,14,13],pen=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Fbe=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ube=/[0-9A-Za-z_]/;function fen(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 _w(e,t=!0){return!(Kt(e)||fn(e)&&(e=xN(e),(t?zbe.test((e||"").replace(/[- ]/g,"")):(function(n){let r;for($be.lastIndex=0;r=$be.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 den){const l=i+s;if(a.length>=l){const c=a.slice(i,l);if(zbe.test(c)&&fen(c))return!0}}}return!1})(e))||(t?pen.test(e):(function(n){let r;for(Fbe.lastIndex=0;r=Fbe.exec(n);){const o=r[1],a=r[3];if(!(o&&a&&Ube.test(o)&&Ube.test(a)))return!0}return!1})(e))))}function Bbe(e){let t=q_(e);return t=`${t} ${pje(e)}`.trim(),_w(t)?t:""}function pje(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Wn(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{const o=q_(n);t=`${t} ${o}`.trim(),n.childNodes&&n.childNodes.length&&(t=`${t} ${pje(n)}`.trim())}catch(o){Ze.error("[AutoCapture]",o)}}),t}function Hbe(e){return e.replace(/"|\\"/g,'\\"')}function hen(e){const t=e.attr__class;if(t)return Lt(t)?t:IX(t)}const UE=Xr("[Dead Clicks]"),gen=()=>!0,men=e=>{var t;const n=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(wX)),r=e.instance.config.capture_dead_clicks;return ni(r)?r:!!vn(r)||n};var Vbe=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({[wX]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Bo(()=>{this.Ho()}):this.stop()}Bo(e){var t,n,r;!((t=Ct.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(n=Ct.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,"dead-clicks-autocapture",o=>{o?UE.error("failed to load script",o):e()})}Ho(){var e;if($e){if(!this.jo&&(!((e=Ct.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=vn(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=Ct.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.jo.start($e),UE.info("starting...")}}else UE.error("`document` not found. Cannot start.")}stop(){this.jo&&(this.jo.stop(),this.jo=void 0,UE.info("stopping..."))}};const yx=Xr("[SegmentIntegration]");function Gbe(e,t,n=!0){const r=e.config.segment;if(!r)return t();const{analytics:o,filterProperties:a}=(s=>zo(s.register))(i=r)?{analytics:i}:i;var i;(function(s,l,c,d){const p=m=>{const b=()=>m.anonymousId()||_l();s.config.get_device_id=b,d&&m.id()&&(s.register({distinct_id:m.id(),$device_id:b()}),s.persistence.set_property(Ja,NT)),c(d?void 0:m.anonymousId()||void 0)},f=l.user();"then"in f&&zo(f.then)?f.then(p):p(f)})(e,o,s=>{o.register(((l,c,{filterProperties:d}={})=>{typeof Promise<"u"&&Promise.resolve||yx.warn("This browser does not have Promise support, and can not use the segment integration");const p=(f,m)=>{if(!m)return f;const b=!!c&&f.event.anonymousId===c&&!f.event.userId;b||f.event.userId||f.event.anonymousId===l.get_distinct_id()||(yx.info("No userId set, resetting PostHog"),l.reset()),b||(c=void 0),f.event.userId&&f.event.userId!==l.get_distinct_id()&&(yx.info("UserId set, identifying with PostHog"),l.identify(f.event.userId));let y=l.calculateEventProperties(m,f.event.properties);if(!Kt(d)){const x=f.event.properties||{},_={};for(const E of Object.keys(y))gX.call(x,E)||(_[E]=y[E]);const k=((E,T)=>{const C=Lt(E)?E:[E];let A=ce({},T);for(const R of C)try{if(A=R(A),Kt(A))return null}catch(M){return yx.error("Error in Segment filterProperties:",M),null}return A})(d,_);if(Kt(k))return f;y=k}return f.event.properties=Object.assign({},y,f.event.properties),f};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(f){return p(f,f.event.event)},page(f){return p(f,AX)},identify(f){return p(f,tje)},screen(f){return p(f,"$screen")}}})(e,s,{filterProperties:a})).then(()=>{t()},l=>{yx.error("Failed to register the Segment integration",l),t()})},n)}const fje="posthog-js";function hje(e,{organization:t,projectId:n,prefix:r,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}={}){return i=>{var s,l,c,d,p;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 m=((s=i.exception)===null||s===void 0?void 0:s.values)||[],b=m.map(_=>ce(ce({},_),{},{stacktrace:_.stacktrace?ce(ce({},_.stacktrace),{},{type:"raw",frames:(_.stacktrace.frames||[]).map(k=>ce(ce({},k),{},{platform:"web:javascript"}))}):void 0})),y={$exception_message:((l=m[0])===null||l===void 0?void 0:l.value)||i.message,$exception_type:(c=m[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:((d=m[0])===null||d===void 0?void 0:d.value)||i.message,$sentry_exception_type:(p=m[0])===null||p===void 0?void 0:p.type,$sentry_tags:i.tags};var x;return t&&n&&(y.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+i.event_id),a&&((x=e.exceptions)===null||x===void 0||x.sendExceptionEvent(y)),i}}var ben=class{constructor(e,t,n,r,o,a){this.name=fje,this.setupOnce=function(i){i(hje(e,{organization:t,projectId:n,prefix:r,severityAllowList:o,sendExceptionsToPostHog:a==null||a}))}}},Wbe=class{constructor(e){this.zo=(t,n,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength||r.crossTabAdoption)&&(Ze.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=Ee==null?void 0:Ee.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:d}=o;if(!(je(a)||je(i)||je(s)||je(l)||je(c)||je(d))){a=Math.ceil(a),i=Math.ceil(i),s=Math.ceil(s),l=Math.ceil(l),c=Math.ceil(c),d=Math.ceil(d);const p=a>1?Sc(i/a,0,1,Ze):1,f=a>1?Sc(s/a,0,1,Ze):1,m=l>1?Sc(c/l,0,1,Ze):1,b=l>1?Sc(d/l,0,1,Ze):1;r=jr(r,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:p,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:m,$prev_pageview_max_content:d,$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 xx=["flags","surveys"],ven={[MJt]:{exposure:"hidden"},[xC]:{exposure:"hidden"},[OJt]:{exposure:"hidden"},[V$]:{exposure:"hidden"},[Db]:{exposure:"hidden"},[bw]:{exposure:"hidden"},[O4e]:{exposure:"event"},[G$]:{exposure:"hidden"},[P4e]:{exposure:"hidden"},[W$]:{exposure:"event"},[j4e]:{exposure:"hidden"},[K$]:{exposure:"event"},[Y$]:{exposure:"event"},[wX]:{exposure:"event"},[_X]:{exposure:"hidden"},[D4e]:{exposure:"event"},[vw]:{exposure:"hidden"},[jJt]:{exposure:"hidden"},[ub]:{exposure:"hidden"},[L4e]:{exposure:"event"},[PJt]:{exposure:"event",shouldSkipFromEventProperties:e=>Kr(e)},[FJt]:{exposure:"event"},[UJt]:{exposure:"event"},[BJt]:{exposure:"event"},[HJt]:{exposure:"event"},[VJt]:{exposure:"hidden"},[xl]:{exposure:"hidden",storageGroup:"flags"},[Iu]:{exposure:"hidden",storageGroup:"flags"},[Z$]:{exposure:"hidden"},[Nh]:{exposure:"hidden",storageGroup:"flags"},[wp]:{exposure:"hidden",storageGroup:"flags"},[Mh]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[yw]:{exposure:"hidden",storageGroup:"flags"},[sc]:{exposure:"hidden"},[rh]:{exposure:"hidden"},[_p]:{exposure:"hidden"},[Sp]:{exposure:"hidden"},[Dx]:{exposure:"hidden",storageGroup:"surveys"},[wC]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[$4e]:{exposure:"event"},[F4e]:{exposure:"hidden"},[U4e]:{exposure:"hidden"},[X$]:{exposure:"hidden"},[GJt]:{exposure:"hidden"},[WJt]:{exposure:"hidden"},[KJt]:{exposure:"event"},[YJt]:{exposure:"event"},[ZJt]:{exposure:"event"},[XJt]:{exposure:"event"},[kp]:{exposure:"hidden"},[Lx]:{exposure:"hidden"},[z4e]:{exposure:"event"},[Z_]:{exposure:"hidden"},[Mp]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Ja]:{exposure:"hidden"},[q$]:{exposure:"hidden"},[qJt]:{exposure:"hidden"},[B4e]:{exposure:"hidden"},[H4e]:{exposure:"hidden"},[db]:{exposure:"hidden"},[SX]:{exposure:"hidden"},[DJt]:{exposure:"event"},[LJt]:{exposure:"event"},[zJt]:{exposure:"event"},[$Jt]:{exposure:"event"},[G4e]:{exposure:"event"},[W4e]:{exposure:"event"},[kX]:{exposure:"hidden"},[EX]:{exposure:"hidden"},[K4e]:{exposure:"hidden"},[Y4e]:{exposure:"hidden"},[Z4e]:{exposure:"hidden"},[X4e]:{exposure:"hidden"},[q4e]:{exposure:"hidden"},[Q4e]:{exposure:"hidden"},[J4e]:{exposure:"hidden"},[QJt]:{exposure:"event"}},yen=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Xo=e=>{const t=ven[e];if(t)return t;for(const[n,r]of yen)if(e.indexOf(n)===0)return r},fb=(e,t)=>{try{let n;return JSON.stringify(e,(r,o)=>{var a;return zy(o)?((a=n)!==null&&a!==void 0||(n=new WeakMap),n.has(o)||n.set(o,nje(o)),n.get(o)):typeof o=="bigint"?o.toString():o},t)}catch{return j5e(e)}},od=e=>{const t=$e==null?void 0:$e.createElement("a");return je(t)?null:(t.href=e,t)},zv=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(!Lt(r)||2>r.length)return"";{let o=r[1];try{o=decodeURIComponent(o)}catch{Ze.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")}},J_=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 p=0;l.length>p;p++){const f=l[p].split("=");Lt(f)&&(t.includes(f[0])?c.push(f[0]+"="+n):c.push(l[p]))}let d=s;return i!=null&&(d+="?"+c.join("&")),o!=null&&(d+="#"+o),d},kC=function(e,t){const n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},gje=(e,t)=>e>=t&&O5e(),mje=(e,t,n,r)=>{if(e===0){if(O5e()){const o=t+1;return o===n&&r(),o}return t}return 0},$v=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],xen=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...$v],e1="<masked>",wen=["li_fat_id"];function bje(e,t,n){if(!$e)return{};const r=t?[...$v,...n||[]]:[],o=vje(J_($e.URL,r,e1),e),a=(function(){const i={};return Wn(wen,function(s){const l=xw(s);i[s]=l||null}),i})();return jr(a,o)}function vje(e,t){const n=xen.concat(t||[]),r={};return Wn(n,function(o){const a=zv(e,o);r[o]=a||null}),r}function yje(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(!Kr(t)){r.$search_engine=t;const o=$e?zv($e.referrer,n):"";o.length&&(r.ph_keyword=o)}return r}function xje(){return navigator.language||navigator.userLanguage}function _en(){const e=xje();return typeof e=="string"?e.split("-")[0]:void 0}const EC="$direct";function wje(){return($e==null?void 0:$e.referrer)||EC}function _je(e,t,n=!1){const r=e?[...$v,...t||[]]:[],o=n?Up(Gr==null?void 0:Gr.href):Gr==null?void 0:Gr.href,a=o==null?void 0:o.substring(0,1e3);return{r:wje().substring(0,1e3),u:a?J_(a,r,e1):void 0}}function Sje(e,t=!1){var n;const{r,u:o}=e,a=t?Up(o):o,i={$referrer:r,$referring_domain:r==null?void 0:r==EC?EC:(n=od(r))===null||n===void 0?void 0:n.host};if(a){i.$current_url=a;const s=od(a);i.$host=s==null?void 0:s.host,i.$pathname=s==null?void 0:s.pathname;const l=vje(a);jr(i,l)}if(r){const s=yje(r);jr(i,s)}return i}function kje(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Sen(){try{return new Date().getTimezoneOffset()}catch{return}}const ken={flags:Mp,surveys:wC},Een=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],BE=e=>`${e}_cookie_identity_change_pending`,HE=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},ko="main",_u=[xl,Iu,Nh,wp,Mh,Mp,yw,_p],gL=e=>_u.indexOf(e)!==-1,Eje=[Db,bw],Kbe=e=>Eje.indexOf(e)!==-1,Jd=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},zm=e=>{if(!e)return{};const t=JSON.parse(e);return vn(t)?t:{}},Ybe=(e,t)=>{Wn(e,(n,r)=>{const o=Xo(r);o&&o.exposure!=="event"||{}.hasOwnProperty.call(t,r)||delete e[r]})};var mL=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&&Ze.info("Persistence loaded",e.persistence,ce({},this.props)),this.update_config(e,e,t),this.save(),Ee){const r=()=>this.flush();zn(Ee,"beforeunload",r,{capture:!1}),zn(Ee,"pagehide",r,{capture:!1}),this.da=o=>{if(this.Qo&&(!o.storageArea||o.storageArea===(Ee==null?void 0:Ee.localStorage))&&o.key)if(o.key!==this.la){if(this.Ko){const a=xx.find(i=>o.key===this.va(i));a&&this.fa(o.key,a)}}else this.fa(o.key,ko)},zn(Ee,"storage",this.da)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,n])=>{const r=this.ta.get(t);if(!gL(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&&Ee&&(Ee.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=Cn.Ot(e),Kr(o)){const s=this.ga(t);return s.storageValue=null,t!==ko&&(s.persisted=!1),!1}r=zm(o)}catch{return!1}const a=t===ko?r:Cn.Dt(this.la);if(a&&this.ma(a))return!1;const i=this.ya(r,t,n);return t===ko&&this.Ko&&!Jd(this.ba().main,r)||this._a(r,t,!0,o),i}ma(e){const t=this.props[gl],n=e[gl];return!je(t)&&!je(n)&&t!==n}_a(e,t,n,r){const o=this.ga(t);o.storageValue=r,t!==ko&&(o.persisted=n);try{o.fingerprint=this.wa(e,t)}catch{o.fingerprint=void 0}}ya(e,t,n){let r=!1;return _u.forEach(o=>{var a;const i=(a=Xo(o))===null||a===void 0?void 0:a.storageGroup;if(t===ko&&this.Ko&&i||t!==ko&&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&&Jd(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=Cn.Ot(this.la),t=this.ga(ko);let n,r=!1,o=!1;if(e!==t.storageValue)if(Kr(e))t.storageValue=null;else{if(n=zm(e),this.na=!this.ia&&this.ma(n),this.na)return!1;o=this.ya(n,ko,!1),!this.Ko||Jd(this.ba().main,n)?this._a(n,ko,!0,e):t.storageValue=e,r=!0}return this.Ko&&xx.forEach(a=>{const i=Cn.Ot(this.va(a)),s=this.ga(a),l=n||{},c=r&&_u.some(p=>{var f;return((f=Xo(p))===null||f===void 0?void 0:f.storageGroup)===a&&p in l});if(i===s.storageValue&&!c)return;if(Kr(i))return s.storageValue=null,s.persisted=!1,void(c&&(o=this.ya(l,a,!1)||o));const d=zm(i);o=this.ya(d,a,!1)||o,this._a(d,a,!0,i)}),o}catch{return!1}}pa(e,t){this.ta.set(e,t);const n=Xo(e);n!=null&&n.volatile||(this.ga((this.Ko?n==null?void 0:n.storageGroup:void 0)||ko).fingerprint=void 0,this.$a(e))}Ta(){_u.forEach(e=>this.ta.set(e,!0))}ca(){if(this.Qo)try{const e=Cn.Ot(this.la),t=zm(e);this.ga(ko).storageValue=e,_u.forEach(n=>{var r;const o=this.Ko?(r=Xo(n))===null||r===void 0?void 0:r.storageGroup:void 0,a=o?Cn.Ot(this.va(o)):null;if(o){const s=this.ga(o);s.storageValue=a,s.persisted=!Kr(a)}const i=o&&!Kr(a)?zm(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(Lt(t)?t:[]),i=new Set(Lt(this.props[e])?this.props[e]:[]);return n.forEach(s=>i.has(s)?a.add(s):a.delete(s)),Array.from(a)}const r=vn(t)?ce({},t):{},o=vn(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(!gL(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=Xo(e))===null||a===void 0?void 0:a.storageGroup:void 0,l=s?this.va(s):this.la;o=zm(Cn.Ot(l))[e]}catch{}const i=new Set(r||[]);if(e==="$active_feature_flags"){if(!je(t)&&!Lt(t)||!je(o)&&!Lt(o)||!Lt(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(d=>{s.has(d)!==c.has(d)&&i.add(d)}),i.forEach(d=>{l.has(d)===c.has(d)&&i.delete(d)})}else{if(!vn(n))return void(Jd(o,n)?this.ta.delete(e):this.pa(e,!0));{if(!je(t)&&!vn(t)||je(t)&&_i(n)&&je(o))return void this.pa(e,!0);const s=vn(t)?t:{},l=vn(o)?o:{};new Set([...Object.keys(s),...Object.keys(n)]).forEach(c=>{c in s==c in n&&Jd(s[c],n[c])||i.add(c)}),i.forEach(c=>{c in l==c in n&&Jd(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 to(t)&&t>0?t:0}Ea(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=pL(e,this.Mr.cookie_persisted_properties||[]),n=Mbe(t,this.Mr.cookie_persisted_properties||[]),r=JSON.stringify(t)+"|"+JSON.stringify(n),o=Vr.Ot(this.la)||void 0;o&&fL(this.la,o)===r&&(this.Pa=r,this.Ra=o)}catch{}else try{const t=Vr.Ot(this.la)||void 0;this.Pa=t?fL(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=Vr.Ot(this.la)||void 0}catch{}if(!n||n===this.Ra)return!1;const r=fL(this.la,n);let o;try{o=dL(JSON.parse(n))}catch{return!1}if((Vr.Ot(this.la)||void 0)!==n)return!1;this.Pa=r,this.Ra=n;const a=Obe(this.la,n),i=[...oh,...a.properties],s={};if(Object.keys(o).forEach(y=>{const x=o[y];(je(x)||Kr(x)||x===""||y==="$user_state"&&x!=="anonymous"&&x!=="identified")&&(s[y]=!0,delete o[y])}),_i(o))return!1;const l="distinct_id"in o||o.$user_state==="anonymous"||o.$user_state==="identified",c=this.props,d=c[gl],p=c[Ja],f=jr({},c);[...oh,...e.cookie_persisted_properties||[]].forEach(y=>{if(i.indexOf(y)!==-1&&!(y in o)&&!s[y]&&(l||y!=="distinct_id"&&y!=="$user_state")){const x=f[y];(a.isValid||oh.indexOf(y)===-1||x!==!1&&x!==0)&&delete f[y]}}),this.props=jr(f,o),_u.forEach(y=>{const x=y in this.props;y in c===x&&Jd(c[y],this.props[y])||(x?this.Ia(y,c[y],this.props[y]):this.pa(y,!0))}),!l||"$user_state"in o||"$user_state"in this.props||this.Sa(Ja,Nu);const m=this.props[gl],b=this.props[Ja];return!l||m===d&&b===p||(this.ia=!0,this.Xo=!0,yr.$t(BE(this.la),!0),this.xa(_p),this.xa(Iu),this.xa(xl),this.xa(Nh),this.xa(wp),this.xa(Mh),this.xa(Mp),this.xa(Z_),this.xa(kp),b!=="anonymous"||p!=="identified"&&o.$user_state!=="anonymous"&&(je(d)||m===d)||(Ybe(this.props,o),this.xa(Sp)),b==="identified"?this.props.$user_id=m:delete this.props.$user_id,this.xa(xC)),!0}consumeCookieIdentityChange(){const e=BE(this.la),t=this.Xo||!!yr.Ot(e);return this.Xo=!1,t&&yr.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&&(je(this.Da)||(clearTimeout(this.Da),this.Da=void 0),delete this.Zo[ko],this.La(!0))}Na(e=!0){if(this.Yo)try{e?this.Oa():je(this.Da)||(clearTimeout(this.Da),this.Da=void 0)}finally{this.Yo=!1}}isDisabled(){return!!this.hi}ua(e){Een.indexOf(e.persistence.toLowerCase())===-1&&(Ze.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((i=[],s=!1)=>{const l=[...oh,...i];return ce(ce({},Cn),{},{Dt(c){try{let p,f={};try{p=Vr.Ot(c)||void 0,f=p?dL(JSON.parse(p)):{}}catch{}const m=JSON.parse(Cn.Ot(c)||"{}");let b;if(s){const y=Obe(c,p),x=[...oh,...y.properties],_={};Object.keys(f).forEach(E=>{const T=f[E];Kr(T)||T===""||E==="$user_state"&&T!=="anonymous"&&T!=="identified"||(_[E]=T)});const k="distinct_id"in _||_.$user_state==="anonymous"||_.$user_state==="identified";if(Object.keys(_).length>0){var d;const E=m[gl],T=(d=m.$user_state)!==null&&d!==void 0?d:Nu;l.forEach(C=>{if(x.indexOf(C)!==-1&&!(C in f)&&(k||C!=="distinct_id"&&C!=="$user_state")){const A=m[C];(y.isValid||oh.indexOf(C)===-1||A!==!1&&A!==0)&&delete m[C]}}),!k||"$user_state"in f||"$user_state"in m||(m[Ja]=Nu),!k||("distinct_id"in _?_[gl]:m[gl])===E&&("$user_state"in _?_[Ja]:m[Ja])===T||(uL.forEach(C=>delete m[C]),_.$user_state==="identified"&&"distinct_id"in _?m.$user_id=_[gl]:delete m.$user_id,_.$user_state!=="identified"&&(delete m[z4e],delete m[Sp]),delete m.__alias)}b=jr(m,_)}else b=jr(f,m);return Cn.$t(c,b),b}catch{}return null},$t(c,d,p,f,m,b){const y=Cn.$t(c,d,void 0,void 0,b);try{const x=pL(d,i);if(Object.keys(x).length){if(s){const _=SC(c),k=Mbe(x,i);if(Vr.$t(_,k,p,f,m,b),Vr.Ot(_)!==JSON.stringify(k)){Vr.Lt(_,f);const E=pL(d);return Vr.$t(c,E,p,f,m,b),y}}Vr.$t(c,x,p,f,m,b)}}catch(x){Cn.Pt(x)}return y},Lt(c,d){try{Ee==null||Ee.localStorage.removeItem(c),Vr.Lt(c,d),Vr.Lt(SC(c),d)}catch(p){Cn.Pt(p)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict);let n,r=!1,o=!1;const a=e.persistence.toLowerCase();return a==="localstorage"&&Cn.At()?(n=Cn,o=!0):a==="localstorage+cookie"&&t.At()?(n=t,o=!0,r=!0):a==="sessionstorage"&&yr.At()?n=yr:a==="memory"?n=e7:a==="cookie"&&Vr.At()?(n=Vr,r=!0):t.At()?(n=t,o=!0,r=!0):Vr.At()?(n=Vr,r=!0):n=e7,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 Wn(this.props,(t,n)=>{const r=Xo(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?Cn.Dt(this.la):null;let r={};if(t)try{r=dL(Vr.Dt(this.la)),Wn(r,(s,l)=>{(je(s)||Kr(s)||s==="")&&delete r[l]})}catch{}const o=this.Lo.Dt(this.la);if(o&&(this.props=jr({},o)),this.Ko&&this.qa(),t&&o){var a,i;const s=n==null?void 0:n[gl],l=(a=n==null?void 0:n.$user_state)!==null&&a!==void 0?a:Nu,c=o[gl],d=(i=o.$user_state)!==null&&i!==void 0?i:Nu;if(c!==s||d!==l){this.Xo=!0,yr.$t(BE(this.la),!0);const p=jr({},this.props);uL.forEach(m=>delete p[m]),d!=="anonymous"||l!=="identified"&&r.$user_state!=="anonymous"&&(je(s)||c===s)||(Ybe(p,r),delete p[Sp]),this.props=p;const f=new Set;uL.forEach(m=>{var b;const y=(b=Xo(m))===null||b===void 0?void 0:b.storageGroup;y&&f.add(y)}),f.forEach(m=>{const b={};Wn(this.props,(y,x)=>{var _;((_=Xo(x))===null||_===void 0?void 0:_.storageGroup)===m&&(b[x]=y)}),_i(b)?(Cn.Lt(this.va(m)),this.Zo[m]={}):Cn.$t(this.va(m),b)&&(this.Zo[m]={persisted:!0,fingerprint:this.wa(b,m)})})}}yr.Ot(BE(this.la))&&(this.Xo=!0)}qa(){for(const e of xx){const t=Cn.Dt(this.va(e));if(t&&!_i(t)){const n=this.ga(e);n.persisted=!0,this.ja(e)||(n.fingerprint=this.wa(t,e)),this.Ba(e,t)||jr(this.props,t)}}}ja(e){return Object.keys(this.props).some(t=>{var n;return((n=Xo(t))===null||n===void 0?void 0:n.storageGroup)===e})}Ba(e,t){const n=ken[e];if(!n)return!1;const r=t[n],o=this.props[n];return to(r)&&to(o)&&o>r}refreshKey(e){var t;if(this.hi||this.sa.has(e))return;const n=this.Ko?(t=Xo(e))===null||t===void 0?void 0:t.storageGroup:void 0,r=n?Cn.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?je(this.Da)&&(this.Da=setTimeout(()=>{this.Da=void 0,this.La()},e)):this.La()}flush(){je(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"||Eje.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&&Ze.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,ko);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,ko);n==="written"&&this.Ea(e),n!=="failed"&&(this.ia=!1,this.sa.clear(),_u.forEach(o=>{var a;!((a=Xo(o))===null||a===void 0)&&a.storageGroup||this.ta.delete(o)}));for(const o of xx){var r;const a=t[o];if(_i(a)&&!(!((r=this.Zo[o])===null||r===void 0)&&r.persisted)){_u.forEach(s=>{var l;((l=Xo(s))===null||l===void 0?void 0:l.storageGroup)===o&&this.ta.delete(s)});continue}const i=this.za(Cn,this.va(o),a,o);i!=="failed"&&_u.forEach(s=>{const l=Xo(s);(l==null?void 0:l.storageGroup)!==o||i!=="written"&&l.volatile||this.ta.delete(s)})}}ba(){const e={},t={flags:{},surveys:{}};return Wn(this.props,(n,r)=>{var o;const a=(o=Xo(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===ko)return JSON.stringify(e)+"|"+this.Ua+"|"+this.Wa+"|"+this.Va;const n={};return Wn(e,(r,o)=>{var a;n[o]=!((a=Xo(o))===null||a===void 0)&&a.volatile?"__volatile__":r}),JSON.stringify(n)}za(e,t,n,r){const o=this.ga(r);if(r!==ko&&!o.dirty&&!je(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!==ko&&(o.persisted=!0),je(a)||(o.fingerprint=a),this.Qo&&(o.storageValue=Cn.Ot(t)),"written"):(this.Mr.debug&&Ze.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ta(),je(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 xx)Cn.Lt(this.va(t));e?delete this.Zo[ko]:this.Zo={},this.Pa=void 0,this.Ra=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(vn(e)){this.syncCookieProperties(),je(t)&&(t="None"),this.Ua=je(n)?this.Ga:n;let r=!1;if(Wn(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(vn(e)){this.syncCookieProperties(),this.Ua=je(t)?this.Ga:t;let n=!1;if(Wn(e,(r,o)=>{e.hasOwnProperty(o)&&(this.props[o]!==r||vn(r)||Lt(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=$e==null?void 0:$e.URL;if(e===this.aa)return;const t=bje(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),n=!_i(CX(t));return n&&this.register(t),this.aa=e,n?t:void 0}update_search_keyword(){this.register((function(){const e=$e==null?void 0:$e.referrer;return e?yje(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:wje(),$referring_domain:($e==null?void 0:$e.referrer)&&((e=od($e.referrer))===null||e===void 0?void 0:e.host)||EC},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=_je(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[db]:this.Jo?{r:HE(e.r),u:e.u?HE(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Wn([H4e,B4e],n=>{const r=this.props[n];r&&Wn(r,function(o,a){e["$initial_"+D$(a)]=o})});const t=this.props[db];if(t){const n=(function(r,o=!1){const a=Sje(r,o),i={};return Wn(a,function(s,l){i[`$initial_${D$(l)}`]=s}),i})(t,this.Mr.disable_capture_url_hashes);jr(e,n)}return e}safe_merge(e){return Wn(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){const r=e.persistence!==t.persistence,o=!((m,b)=>{if(m.length!==b.length)return!1;const y=[...m].sort(),x=[...b].sort();return y.every((_,k)=>_===x[k])})(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 d=this.ha(e),p=a||d!==this.Ko,f=!s&&(p||e.cross_subdomain_cookie!==this.Wa||e.secure_cookie!==this.Va)&&this.Fa(l);this.ea=p;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),p){const m=this.props;this.clear(),this.Lo=c,this.Ko=d,this.props=m,this.save()}else i&&(this.Lo=c,s||(delete this.Zo[ko],this.La()))}finally{this.ea=!1,f&&this.Na()}}Za(){const e=this.props[db];if(!this.Jo||!vn(e)||typeof e.r!="string")return;const t=HE(e.r),n=typeof e.u=="string"?HE(e.u):e.u;t===e.r&&n===e.u||this.Sa(db,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(V$,n),this.save()}remove_event_timer(e){const t=this.props.__timers||{},n=t[e];return je(n)||(delete t[e],this.Sa(V$,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),Kbe(e)&&!Jd(o,t)&&this.sa.add(e),this.Ia(e,o,t),!((r=Xo(e))===null||r===void 0)&&r.volatile||this.$a(e))}xa(e,t=!0){delete this.props[e],t&&(gL(e)&&this.pa(e,!0),Kbe(e)&&this.sa.add(e),this.$a(e))}$a(e){var t;const n=(t=Xo(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 ns={GZipJS:"gzip-js",Base64:"base64"},wx={Activation:"events",Cancellation:"cancelEvents"},bL={Popover:"popover",API:"api",Widget:"widget"},Qi={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},vL={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},r7={Popover:"popover",Inline:"inline"};function VE(e){let t=!0;return{dispose(){if(t){t=!1;const n=e();n&&zo(n.then)&&n.then(void 0,()=>{})}}}}const Ten={SHOWN:"product tour shown"},Zbe={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Xbe=Xr("[RateLimiter]");var Aen=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=>{Xbe.info(`${r||"events"} is quota limited.`),this.serverLimits[r]=new Date().getTime()+6e4})}catch(r){return void Xbe.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=(to(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!Lt(t)||!t.includes(e)}Ka(){var e;if(this.Ja("$current_url")&&this.Ja("$pathname")&&(Gr!=null&&Gr.pathname))return`${(e=Gr.origin)!==null&&e!==void 0?e:""}${Gr.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 ep=Xr("[RemoteConfig]");var Tje=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Ct._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=Ct.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(n=Ct.__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 ep.info("Using preloaded remote config",this.remoteConfig),void this.tl(this.remoteConfig);if(this._instance.el())return void ep.warn("Remote config is disabled. Falling back to local config.");this.Xa(e=>{if(!e)return ep.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){ep.error("Error loading remote config",e),this.tl()}}tl(e,t){!e&&t&&(t.statusCode===0?t.error||ep.warn("Failed to fetch remote config from PostHog."):ep.error("Failed to fetch remote config from PostHog."));try{this._instance.tl(e?{ok:!0,config:e}:{ok:!1})}catch(r){ep.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){ep.error("Error loading feature flags",r)}}},Vs=Uint8Array,Ei=Uint16Array,Fv=Uint32Array,OX=new Vs([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]),jX=new Vs([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]),qbe=new Vs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Aje=function(e,t){for(var n=new Ei(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var o=new Fv(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]},Cje=Aje(OX,2),o7=Cje[1];Cje[0][28]=258,o7[258]=28;for(var Qbe=Aje(jX,0)[1],Rje=new Ei(32768),Zr=0;32768>Zr;++Zr){var $m=(43690&Zr)>>>1|(21845&Zr)<<1;Rje[Zr]=((65280&($m=(61680&($m=(52428&$m)>>>2|(13107&$m)<<2))>>>4|(3855&$m)<<4))>>>8|(255&$m)<<8)>>>1}var Sw=function(e,t,n){for(var r=e.length,o=0,a=new Ei(t);r>o;++o)++a[e[o]-1];var i,s=new Ei(t);for(o=0;t>o;++o)s[o]=s[o-1]+a[o-1]<<1;for(i=new Ei(r),o=0;r>o;++o)i[o]=Rje[s[e[o]-1]++]>>>15-e[o];return i},Jh=new Vs(288);for(Zr=0;144>Zr;++Zr)Jh[Zr]=8;for(Zr=144;256>Zr;++Zr)Jh[Zr]=9;for(Zr=256;280>Zr;++Zr)Jh[Zr]=7;for(Zr=280;288>Zr;++Zr)Jh[Zr]=8;var TC=new Vs(32);for(Zr=0;32>Zr;++Zr)TC[Zr]=5;var Cen=Sw(Jh,9),Ren=Sw(TC,5),Ije=function(e){return(e/8|0)+(7&e&&1)},Nje=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Ei?Ei:e instanceof Fv?Fv:Vs)(n-t);return r.set(e.subarray(t,n)),r},vu=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},_x=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},yL=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 Vs(0),0];if(o==1){var i=new Vs(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort(function(C,A){return C.f-A.f}),n.push({s:-1,f:25001});var s=n[0],l=n[1],c=0,d=1,p=2;for(n[0]={s:-1,f:s.f+l.f,l:s,r:l};d!=o-1;)s=n[n[p].f>n[c].f?c++:p++],l=n[c!=d&&n[p].f>n[c].f?c++:p++],n[d++]={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 m=new Ei(f+1),b=a7(n[d-1],m,0);if(b>t){r=0;var y=0,x=b-t,_=1<<x;for(a.sort(function(C,A){return m[A.s]-m[C.s]||C.f-A.f});o>r;++r){var k=a[r].s;if(t>=m[k])break;y+=_-(1<<b-m[k]),m[k]=t}for(y>>>=x;y>0;){var E=a[r].s;t>m[E]?y-=1<<t-m[E]++-1:++r}for(;r>=0&&y;--r){var T=a[r].s;m[T]==t&&(--m[T],++y)}b=t}return[new Vs(m),b]},a7=function(e,t,n){return e.s==-1?Math.max(a7(e.l,t,n+1),a7(e.r,t,n+1)):t[e.s]=n},Jbe=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Ei(++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]},Sx=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},i7=function(e,t,n){var r=n.length,o=Ije(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)},eve=function(e,t,n,r,o,a,i,s,l,c,d){vu(t,d++,n),++o[256];for(var p=yL(o,15),f=p[0],m=p[1],b=yL(a,15),y=b[0],x=b[1],_=Jbe(f),k=_[0],E=_[1],T=Jbe(y),C=T[0],A=T[1],R=new Ei(19),M=0;k.length>M;++M)R[31&k[M]]++;for(M=0;C.length>M;++M)R[31&C[M]]++;for(var j=yL(R,7),O=j[0],P=j[1],D=19;D>4&&!O[qbe[D-1]];--D);var L,z,F,$,H=c+5<<3,V=Sx(o,Jh)+Sx(a,TC)+i,Y=Sx(o,f)+Sx(a,y)+i+14+3*D+Sx(R,O)+(2*R[16]+3*R[17]+7*R[18]);if(V>=H&&Y>=H)return i7(t,d,e.subarray(l,l+c));if(vu(t,d,1+(V>Y)),d+=2,V>Y){L=Sw(f,m),z=f,F=Sw(y,x),$=y;var U=Sw(O,P);for(vu(t,d,E-257),vu(t,d+5,A-1),vu(t,d+10,D-4),d+=14,M=0;D>M;++M)vu(t,d+3*M,O[qbe[M]]);d+=3*D;for(var X=[k,C],J=0;2>J;++J){var K=X[J];for(M=0;K.length>M;++M)vu(t,d,U[G=31&K[M]]),d+=O[G],G>15&&(vu(t,d,K[M]>>>5&127),d+=K[M]>>>12)}}else L=Cen,z=Jh,F=Ren,$=TC;for(M=0;s>M;++M)if(r[M]>255){var G;_x(t,d,L[257+(G=r[M]>>>18&31)]),d+=z[G+257],G>7&&(vu(t,d,r[M]>>>23&31),d+=OX[G]);var Q=31&r[M];_x(t,d,F[Q]),d+=$[Q],Q>3&&(_x(t,d,r[M]>>>5&8191),d+=jX[Q])}else _x(t,d,L[r[M]]),d+=z[r[M]];return _x(t,d,L[256]),d+z[256]},Ien=new Fv([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Nen=(function(){for(var e=new Fv(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e})(),xL=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Men(e,t){t===void 0&&(t={});var n=(function(){var p=4294967295;return{p(f){for(var m=p,b=0;f.length>b;++b)m=Nen[255&m^f[b]]^m>>>8;p=m},d(){return 4294967295^p}}})(),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(p,f,m,b,y,x){var _=p.length,k=new Vs(b+_+5*(1+Math.floor(_/7e3))+y),E=k.subarray(b,k.length-y),T=0;if(!f||8>_)for(var C=0;_>=C;C+=65535){var A=C+65535;_>A?T=i7(E,T,p.subarray(C,A)):(E[C]=x,T=i7(E,T,p.subarray(C,_)))}else{for(var R=Ien[f-1],M=R>>>13,j=8191&R,O=(1<<m)-1,P=new Ei(32768),D=new Ei(O+1),L=Math.ceil(m/3),z=2*L,F=function(Ae){return(p[Ae]^p[Ae+1]<<L^p[Ae+2]<<z)&O},$=new Fv(25e3),H=new Ei(288),V=new Ei(32),Y=0,U=0,X=(C=0,0),J=0,K=0;_>C;++C){var G=F(C),Q=32767&C,ne=D[G];if(P[Q]=ne,D[G]=Q,C>=J){var de=_-C;if((Y>7e3||X>24576)&&de>423){T=eve(p,E,0,$,H,V,U,X,K,C-K,T),X=Y=U=0,K=C;for(var se=0;286>se;++se)H[se]=0;for(se=0;30>se;++se)V[se]=0}var oe=2,re=0,q=j,te=Q-ne&32767;if(de>2&&G==F(C-te))for(var ye=Math.min(M,de)-1,Me=Math.min(32767,C),Oe=Math.min(258,de);Me>=te&&--q&&Q!=ne;){if(p[C+oe]==p[C+oe-te]){for(var qe=0;Oe>qe&&p[C+qe]==p[C+qe-te];++qe);if(qe>oe){if(oe=qe,re=te,qe>ye)break;var Ge=Math.min(te,qe-2),Ye=0;for(se=0;Ge>se;++se){var Rt=C-te+se+32768&32767,Ke=Rt-P[Rt]+32768&32767;Ke>Ye&&(Ye=Ke,ne=Rt)}}}te+=(Q=ne)-(ne=P[Q])+32768&32767}if(re){$[X++]=268435456|o7[oe]<<18|Qbe[re];var De=31&o7[oe],Be=31&Qbe[re];U+=OX[De]+jX[Be],++H[257+De],++V[Be],J=C+oe,++Y}else $[X++]=p[C],++H[p[C]]}}T=eve(p,E,x,$,H,V,U,X,K,C-K,T)}return Nje(k,0,b+Ije(T)+y)})(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)),d=c.length;return(function(p,f){var m=f.filename;if(p[0]=31,p[1]=139,p[2]=8,p[8]=2>f.level?4:f.level==9?2:0,p[9]=3,f.mtime!=0&&xL(p,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),m){p[3]=8;for(var b=0;m.length>=b;++b)p[b+10]=m.charCodeAt(b)}})(c,t),xL(c,d-8,n.d()),xL(c,d-4,r),c}const Oen=!!hX||!!K_,Mje=new WeakMap,Oje="text/plain";let wL=0,OT=!1;const jje=(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}`:""}`},J1=(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 d;const[p,f]=c.split("="),m=n&&(d=i[p])!==null&&d!==void 0?d:f;return delete i[p],`${p}=${m}`}))!==null&&r!==void 0?r:[],l=(function(c,d="&"){let p,f;const m=[];return Wn(c,function(b,y){je(b)||je(y)||y==="undefined"||(p=encodeURIComponent((x=>x instanceof File)(b)?b.name:b.toString()),f=encodeURIComponent(y),m[m.length]=f+"="+p)}),m.join(d)})(i);return l&&s.push(l),s.length>0?`${o}?${s.join("&")}`:o},_L=e=>{if(e.il)return e.il;const{data:t,compression:n}=e;if(!t)return;if(n===ns.GZipJS){const o=Men((function(a){var i=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var s=new Vs(a.length+(a.length>>>1)),l=0,c=function(m){s[l++]=m},d=0;i>d;++d){if(l+5>s.length){var p=new Vs(l+8+(i-d<<1));p.set(s),s=p}var f=a.charCodeAt(d);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(++d))>>>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 Nje(s,0,l)})(fb(t)),{mtime:0});return{contentType:Oje,body:o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),estimatedSize:o.byteLength}}if(n===ns.Base64){const o=(function(i){return i&&btoa(encodeURIComponent(i).replace(/%([0-9A-F]{2})/g,(s,l)=>String.fromCharCode(parseInt(l,16))))})(fb(t)),a=(i=>"data="+encodeURIComponent(typeof i=="string"?i:fb(i)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}const r=fb(t);return{contentType:"application/json",body:r,estimatedSize:new Blob([r]).size}},Pje=e=>{const t=()=>e.transport==="sendBeacon"?{url:J1(e.url,{compression:ns.Base64}),encodedBody:_L(ce(ce({},e),{},{compression:ns.Base64,il:void 0}))}:{url:jje(e.url,"compression"),encodedBody:_L(ce(ce({},e),{},{compression:void 0,il:void 0}))};let n;try{n=_L(e)}catch(o){if(xbe(e.compression,zv(e.url,"compression")))return Ze.error("Failed to gzip request body, sending uncompressed payload",o),t();throw o}return n&&xbe(e.compression,zv(e.url,"compression"))&&!((r=n.body)instanceof ArrayBuffer?B$(new Uint8Array(r)):ArrayBuffer.isView(r)&&B$(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(OT=!0,t()):{url:e.url,encodedBody:n};var r},Dje=e=>{try{return Pje(e)}catch(n){var t;return Ze.error(n),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:n}))}},jen=(function(){var e=Pr(function*(t){const n=yield(function(o){return H$.apply(this,arguments)})(fb(t.data),Ro.DEBUG,{rethrow:!0});if(!n)return t;const r=yield n.arrayBuffer();return ce(ce({},t),{},{il:{contentType:Oje,body:r,estimatedSize:r.byteLength}})});return function(t){return e.apply(this,arguments)}})(),Pen=/Failed to fetch|NetworkError|Load failed/i,Lje=e=>(e==null?void 0:e.name)==="TypeError"&&Pen.test((e==null?void 0:e.message)||""),zje=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,IT):void 0})(e());return je(t)?void 0:Math.min(t,3e4)}catch{return}},$je=e=>{const t=Dje(e);if(!t)return;const n=new hX;Mje.set(n,!0);const{url:r,encodedBody:o}=t;n.open(e.method||"GET",r,!0);const{contentType:a,body:i}=o??{};Wn(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,zje(()=>n.getResponseHeader("Retry-After")))}},n.send(i)},Fje=e=>{const t=Dje(e);if(!t)return;const{url:n,encodedBody:r}=t,{contentType:o,body:a,estimatedSize:i}=r??{},s=new Headers;Wn(e.headers,function(b,y){s.append(y,b)}),o&&s.append("Content-Type",o);let l=null,c=!1;if(abe){const b=new abe;l={signal:b.signal,timeout:setTimeout(()=>{c=!0;try{b.abort(h4e("AbortError","PostHog request timed out"+((y=e.timeout)?` after ${y}ms`:"")))}catch(x){p(x)}var y},e.timeout)}}let d=!1;const p=b=>{var y;d||(d=!0,c&&(b==null?void 0:b.name)==="AbortError"||Lje(b)?Ze.warn(b):Ze.error(b),(y=e.callback)===null||y===void 0||y.call(e,{statusCode:0,error:b}))};let f=0;const m=()=>{wL-=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),y=i??(je(a)?0:void 0);b.keepalive=b.method==="POST"&&!e.nl&&b.keepalive!==!1&&b.body===a&&!je(y)&&y>=0&&52428.8>wL+y,b.keepalive&&(f=y,wL+=f),K_(n,b).then(x=>x.text().then(_=>{var k;if(d)return;const E={statusCode:x.status,text:_};if(x.status===200)try{E.json=JSON.parse(_)}catch(T){Ze.error(T)}d=!0,m(),(k=e.callback)===null||k===void 0||k.call(e,E,zje(()=>x.headers.get("Retry-After")))})).catch(x=>{m(),p(x)}).finally(m)}catch(b){m(),p(b)}},s7=e=>{try{var t;const{url:n,encodedBody:r}=Pje(e),{contentType:o,body:a,estimatedSize:i}=r??{};if(!a)return;const s=a instanceof Blob?a:new Blob([a],{type:o});if($o.sendBeacon(n,s))return;const l=Lt(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(Lt(l)&&l.length>1&&(i??0)>16384){const c=Math.ceil(l.length/2),d=p=>Lt(e.data)?p:ce(ce({},e.data),{},{batch:p});return s7(ce(ce({},e),{},{data:d(l.slice(0,c))})),void s7(ce(ce({},e),{},{data:d(l.slice(c))}))}Ze.warn(`Beacon of ~${i??0} bytes was rejected by the browser, falling back to ${K_?"fetch":"XHR"}`),K_?Fje(ce(ce({},e),{},{nl:!0})):$je(e)}catch(n){Ze.warn("Beacon send failed",n)}},tve=(e,t,n,r)=>{const o=r==="query"?t==="POST"?"sent_at":"_":void 0;return J1(n===ns.GZipJS?jje(e,"compression"):e,ce(ce({},o?{[o]:Date.now().toString()}:{}),n===ns.GZipJS?{}:{compression:n}))},Den=(()=>{const e=[];return K_&&e.push({transport:"fetch",method:Fje}),hX&&e.push({transport:"XHR",method:$je}),$o!=null&&$o.sendBeacon&&e.push({transport:"sendBeacon",method:s7}),e})();let Uje=!Oen&&(Qa==null?void 0:Qa.indexOf("MSIE"))===-1&&(Qa==null?void 0:Qa.indexOf("Mozilla"))===-1;function Bje(e,t,n){var r,o,a;n&&(t=ce(ce({},t),{},{callback:i=>n(i)})),e.__loaded?Uje?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,(je(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,d;const p=ce(ce({},i),{},{callback:s??(x=>{var _;return(_=i.callback)===null||_===void 0?void 0:_.call(i,x)})});p.timeout=p.timeout||6e4;const f=(l=p.transport)!==null&&l!==void 0?l:"fetch";f==="sendBeacon"&&je(p.compression)&&p.data&&(p.compression=ns.Base64),p.method==="POST"&&p.data&&(p.timestampMode==="capture-body"?p.data=(x=>{var _,k;const E=(Lt(x)?x:[x]).map(C=>ce(ce({},C),C.timestamp instanceof Date&&!isNaN(C.timestamp.getTime())?{timestamp:C.timestamp.toISOString()}:{})),T=E[0];return{api_key:(_=T==null||(k=T.properties)===null||k===void 0?void 0:k.token)!==null&&_!==void 0?_:T==null?void 0:T.token,batch:E,sent_at:new Date().toISOString()}})(p.data):p.timestampMode==="body"&&(p.data=((x,_=new Date().toISOString())=>Lt(x)?x.map(k=>ce(ce({},k),{},{sent_at:_})):ce(ce({},x),{},{sent_at:_}))(p.data))),p.url=tve(p.url,p.method,p.compression,p.timestampMode);const m=Den.filter(x=>!p.disableTransport||!x.transport||!p.disableTransport.includes(x.transport)),b=(c=(d=(function(x,_){for(let k=0;x.length>k;k++)if(_(x[k]))return x[k]})(m,x=>x.transport===f))===null||d===void 0?void 0:d.method)!==null&&c!==void 0?c:m[0].method;if(!b)throw new Error("No available transport method");const y=x=>{try{b(x)}catch(k){var _;Lje(k)?Ze.warn(k):Ze.error(k),(_=p.callback)===null||_===void 0||_.call(p,{statusCode:0,error:k})}};f!=="sendBeacon"&&!p.preferSyncCompression&&p.data&&p.compression===ns.GZipJS&&TQt&&typeof Promise<"u"&&!OT?jen(p).then(x=>{y(x)}).catch(x=>{if(wbe(x))return OT=!0,void y(ce(ce({},p),{},{compression:void 0,url:tve(i.url,i.method,void 0,i.timestampMode)}));(_=>{if(!_||typeof _!="object")return!1;const k="name"in _?String(_.name):"";return wbe(_)||k===w4e})(x)&&(OT=!0),y(p)}):y(p)})(t,(i,s)=>{var l,c,d;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):(d=t.callback)===null||d===void 0||d.call(t,i)})):t.fireCallbackOnDrop&&((a=t.callback)===null||a===void 0||a.call(t,{statusCode:0}))}var Len=class{constructor(e,t){this.sl=!0,this.rl=[],this.ol=Sc((t==null?void 0:t.flush_interval_ms)||3e3,250,5e3,Ze.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){Ze.error(n)}}hl(){clearTimeout(this.ll),this.ll=void 0}cl(){const e={};return Wn(this.rl,t=>{var n;const r=t,o=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:"");je(e[o])&&(e[o]=ce(ce({},r),{},{data:[]})),(n=e[o].data)===null||n===void 0||n.push(r.data)}),this.rl=[],e}};const zen=["retriesPerformedSoFar"];var $en=class{constructor(e){this._instance=e,this.vl=!1,this.fl=3e3,this.rl=[],this.rl=[],this.pl=!0,this.resume()}resume(){if(!je(Ee)&&"onLine"in Ee.navigator){if(this.pl=Ee.navigator.onLine,this.gl)return;this.gl=()=>{this.pl=!0,this.ml()},this.yl=()=>{this.pl=!1},zn(Ee,"online",this.gl),zn(Ee,"offline",this.yl)}}get length(){return this.rl.length}retriableRequest(e,t){let{retriesPerformedSoFar:n}=e,r=_4e(e,zen);wu(n)&&(r.url=J1(r.url,{retry_count:n})),Bje(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&&Ze.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),d=(Math.random()-.5)*(c-l);return Math.ceil(c+d)})(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)"),Ze.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,je(Ee)||(this.gl&&(Ee.removeEventListener("online",this.gl),this.gl=void 0),this.yl&&(Ee.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){Ze.error(t)}this.rl=[]}},Fen=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(Ee,"scroll",this.wl,{capture:!0}),zn(Ee,"scrollend",this.wl,{capture:!0}),zn(Ee,"resize",this.wl)}scrollElement(){if(this.Sl){const n=Lt(this.Sl)?this.Sl:[this.Sl];for(const r of n){var e;const o=Ee==null||(e=Ee.document)===null||e===void 0?void 0:e.querySelector(r);if(o)return o}return}var t;return Ee==null||(t=Ee.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 Ee?e==="y"?Ee.scrollY||Ee.pageYOffset||((t=Ee.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:Ee.scrollX||Ee.pageXOffset||((n=Ee.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 Uen=e=>_je(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 nve=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({[q$]:i})},this._instance=e,this.Il=t,this.Tl=n,this.$l=r||Uen,this.Il.onSessionId(this.qe)}Cl(){return this.Tl.props[q$]}getSetOnceProps(){var e;const t=(e=this.Cl())===null||e===void 0?void 0:e.props;return t?"r"in t?Sje(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 Wn(CX(this.getSetOnceProps()),(t,n)=>{n==="$current_url"&&(n="url"),e[`$session_entry_${D$(n)}`]=t}),e}},AC=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 Fm=Xr("[SessionId]"),rve=864e5;var ove=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 AC,this.Dl=(a,i)=>!(!wu(a)||!wu(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||_l,this.ql=n||_l;const o=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Sc(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Fm.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=yr.Dt(this.Bl),i=yr.Dt(this.Hl);a&&!i?this.je=a:yr.Lt(this.Bl),yr.$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 je(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&&yr.At()}Wl(e){e!==this.je&&(this.je=e,this.zl()&&yr.$t(this.Bl,e))}Vl(){return this.je?this.je:this.zl()?yr.Dt(this.Bl):null}Gl(e){const t=this.Pl;return!Kr(t)&&!Kr(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({[ub]:[t,e,n]}))}Ql(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return wu(t)&&t>0}Jl(){this.Ql()?this.Tl.refreshKey(ub):(this.Tl.flush(),this.Tl.load())}Kl(){var e;if(Kr(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({[ub]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Tl.flush())}Yl(){const[e]=this.Xl(),t=wu(e)?e:0,n=wu(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[ub];return Lt(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 Fm.error("Bootstrap sessionID cannot be in the future"):a}catch(a){return void Fm.error("Invalid sessionID in bootstrap",a)}})(e);return!je(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&&Ee&&(Ee.removeEventListener(_C,this.Fl,{capture:!1}),this.Fl=void 0),this.Al=[]}Ul(){this.Fl=()=>{this.Kl(),this.zl()&&yr.Lt(this.Hl)},zn(Ee,_C,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(Kr(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=!je(o)&&s!==o,d=this.Yl();let p=this.Vl();const f=this.Ll,m=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>rve),b=f?m:wu(l)&&Math.abs(r-l)>rve;let y=!1,x=c,_=!s||!!f;const k=s;let E=!_&&!e&&this.Dl(r,d);if(E&&(E=this.tu(r),E||Fm.info("cross-tab refresh kept the session alive",{sessionId:s}),[,s,l]=this.Xl(),E||(_=!s||!!f)),_||E||b){x=!1;const R=f&&!m;s=R?f.sessionId:this.Nl(),p=this.ql(),Fm.info("new session ID assigned",{sessionId:s,windowId:p,bootstrapped:!!R,changeReason:{noSessionId:_,activityTimeout:E,sessionPastMaximumLength:b}}),l=R?f.sessionStartTimestamp:r,this.Ll=void 0,y=!0}else p||(p=this.ql(),y=!0),x=x||s!==k,x&&(Fm.info("adopted cross-tab session id",{sessionId:s,windowId:p}),y=!0);const T=wu(d)&&e&&!b?d:r,C=wu(l)?l:new Date().getTime();this.Wl(p),this.Zl(s,T,C),e||this.jl();const A={noSessionId:_,activityTimeout:E,sessionPastMaximumLength:b,crossTabAdoption:x};return y&&this.Al.forEach(R=>R(s,p,A)),{sessionId:s,windowId:p,sessionStartTimestamp:C,changeReason:y?A:void 0,lastActivityTimestamp:d}}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 Hje=function(e,t){if(!e)return!1;const n=e.userAgent;if(n&&sbe(n,t))return!0;try{const r=e==null?void 0:e.userAgentData;if(r!=null&&r.brands&&r.brands.some(o=>sbe(o==null?void 0:o.brand,t)))return!0}catch{}return!!e.webdriver};function Vje(){return(Vje=Pr(function*(){const e=$o==null?void 0:$o.userAgentData;if(e!=null&&e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),n=t==null?void 0:t.model;return fn(n)&&n.length>0?n:void 0}catch(t){return void Ze.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function Ben(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 Gje(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 CC=(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}},GE=e=>e.toLowerCase(),Wje={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=>CC(n,r))),not_regex:(e,t)=>t.every(n=>e.every(r=>!CC(n,r))),icontains:(e,t)=>t.map(GE).some(n=>e.map(GE).some(r=>n.includes(r))),not_icontains:(e,t)=>t.map(GE).every(n=>e.map(GE).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 Kje(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=Wje[r.operator];return!!a&&a(r.values.map(String),[String(o)])})}function SL(e,t,n){return fb({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}const l7="custom",ave="i.posthog.com",Hen=/^\/static\//,Ven=["/s/","/e/","/i/"];var Gen=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(`.${ave}`,".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":l7),this.iu[this.apiHost]}nu(e){if(!Hen.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}su(e){const t=od(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=od(n))===null||a===void 0?void 0:a.href)||n;r=o(new URL(i)).toString()}if(o&&e==="api"&&Ven.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===l7)return this.ru(e,t,this.apiHost+t);const n=ave+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 Bn=Xr("[Surveys]"),Yje=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){Bn.error("Failed to persist survey seen state",t)}},Wen=[bL.Popover,bL.Widget,bL.API],Ken={ignoreConditions:!1,ignoreDelay:!1,displayType:r7.Popover},Yen=Xr("[PostHog ExternalIntegrations]"),Zen={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Xen=class{constructor(e){this._instance=e}Bo(e,t){var n,r;(n=Ct.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,e,o=>{if(o)return Yen.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=Ct.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[o])&&this.Bo(Zen[o],()=>{var i;(i=Ct.__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=Ct.__PosthogExtensions__)===null||n===void 0||(n=n.integrations)===null||n===void 0)&&n[o])&&((r=Ct.__PosthogExtensions__)===null||r===void 0||(r=r.integrations)===null||r===void 0||(r=r[o])===null||r===void 0||r.stop())}}},qen=class{constructor(e,t){this.A=e,this.yo=t,this.au=new Map,this.$o=!1}add(e){var t=this;return Pr(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&&zo(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)}}},Qen=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);je(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 ive="extensionsRemoteConfig";var Jen=class{constructor(e){this.instance=e,this.$o=!1,this.A=Ze,this.uu=e.hu,this.kv=new Qen(e),this.onEvent=t=>VE(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 VE(()=>{});const n=o=>{try{t(o)}catch(a){this.A.error("Browser extension remote config listener failed",a)}},r=this.instance.cu.on(ive,n);return this.uu&&n(this.uu),VE(r)},this.du=new qen(Ze.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(xX);return typeof e=="string"?e:void 0}get library(){return{name:Ro.LIB_NAME,version:Ro.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 VE(this.instance.vu(e))}handleRemoteConfig(e){this.$o||(this.uu=e,this.instance.cu.emit(ive,e))}sendRequest(e){var t=this;return Pr(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?J1(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"?P$.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 kw={};let kL=0;const Ew=()=>{},sve='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Um="Surveys module not available",lve="sanitize_properties is deprecated. Use before_send instead",Zje="Invalid value for property_denylist config: ",etn=["$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"],ttn=["$feature_flag_called","$$heatmap","$snapshot"],cve=e=>e.charAt(0)==="$"&&!Dt(ttn,e),ntn=/^[A-Za-z0-9_-]{1,400}$/,uve=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,dve=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,rtn=["token","distinct_id",V4e],zx="posthog",otn=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},EL=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:ten($e==null?void 0:$e.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ew,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:Gr&&fn(Gr==null?void 0:Gr.search)&&Gr.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:(Ee==null||(t=Ee.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){Ze.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:eje,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:Ew},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:cen,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:otn(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))},atn=[["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"]],pve=e=>{const t={};for(const[o,a]of atn)je(e[o])||(t[a]=e[o]);const n=jr({},t,e),r=e.__preview_external_dependency_versioned_paths;return je(r)||(je(e.strict_script_versioning)&&(n.strict_script_versioning=!!r),fn(r)&&je(e.asset_host)&&(n.asset_host=r)),Lt(e.property_blacklist)&&(je(e.property_denylist)?n.property_denylist=e.property_blacklist:Lt(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ze.error(Zje+e.property_denylist)),n};var itn=class{constructor(){this.__forceAllowLocalhost=!1}get fu(){return this.__forceAllowLocalhost}set fu(e){Ze.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Tw=class op{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(_l());this.register({distinct_id:r,$device_id:r}),t.set_property(Ja,Nu)}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 itn,this.$u=!1,this.version=Ro.LIB_VERSION,this.Tu=new Set,this.Iu="",this.cu=new AC,this.au=[],this.Mu=[],this.Eu=!1,this._u=!1,this.bu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=EL(),this.SentryIntegration=ben,this.sentryIntegration=r=>(function(o,a){const i=hje(o,a);return{name:fje,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 Fen(this),this.pageViewManager=new Wbe(this),this.rateLimiter=new Aen(this),this.requestRouter=new Gen(this),this.consent=new len(this),this.externalIntegrations=new Xen(this);const n=(t=op.__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=fn(r)?{[r]:o}:r;this.setPersonProperties(i),a==null||a({})},set_once:(r,o,a)=>{const i=fn(r)?{[r]:o}:r;this.setPersonProperties(void 0,i),a==null||a({})}},this.on("eventCaptured",r=>Ze.info(`send "${r==null?void 0:r.event}"`,r))}init(t,n,r){if(r&&r!==zx){var o;const a=(o=kw[r])!==null&&o!==void 0?o:new op;return a._init(t,n,r),kw[r]=a,kw[zx][r]=a,a}return this._init(t,n,r)}_init(t,n={},r){var o,a,i;const s=fn(t)?t.trim():"";if(!s)return Ze.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=EL(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=EL(n.defaults),d=pve(n),p=jr({},c,d,{name:r,token:s});vn(c.rageclick)&&vn(d.rageclick)&&(p.rageclick=jr({},c.rageclick,d.rageclick)),vn(c.session_recording)&&vn(d.session_recording)&&(p.session_recording=jr({},c.session_recording,d.session_recording)),this.set_config(p),this.config.on_xhr_error&&Ze.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:ns.GZipJS;const f=this.ku();if(this.persistence=new mL(this.config,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new mL(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&&yr.At()){const _=yr.Dt(this.Iu);Lt(_)&&_.forEach(k=>{fn(k)&&this.Tu.add(k)})}else yr.Lt(this.Iu);const m=ce({},this.persistence.props),b=ce({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Nu=new Len((_,k)=>this.qu(_,k),this.config.request_queue_config),this.ju=new $en(this),this.__request_queue=[];const y=this.mu();y||(this.sessionManager=new ove(this),this.sessionPropsManager=new nve(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((_,k,E)=>{(E!=null&&E.activityTimeout||E!=null&&E.sessionPastMaximumLength||E!=null&&E.crossTabAdoption)&&this.Bu()})),this.Hu(),this.config.__preview_deferred_init_extensions?(Ze.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.zu(y)},0)):(Ze.info("Initializing extensions synchronously"),this.zu(y)),Ro.DEBUG=Ro.DEBUG||this.config.debug,Ro.DEBUG&&Ze.info("Starting in debug mode",{this:this,config:n,thisC:ce({},this.config),p:m,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 x=(a=n.bootstrap)===null||a===void 0?void 0:a.distinctID;if(this._u=!!x&&!gw(x),(i=n.bootstrap)===null||i===void 0?void 0:i.distinctID){const _=n.bootstrap.distinctID,k=this.get_distinct_id(),E=this.persistence.get_property(Ja);if(n.bootstrap.isIdentifiedID&&k!=null&&k!==_&&E==="anonymous")this.identify(_);else if(n.bootstrap.isIdentifiedID&&k!=null&&k!==_&&E==="identified")Ze.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 T=this.config.get_device_id(_l()),C=n.bootstrap.isIdentifiedID?T:_;this.persistence.set_property(Ja,n.bootstrap.isIdentifiedID?NT:Nu),this.register({distinct_id:_,$device_id:C})}}if(y)this.register_once({distinct_id:lL,$device_id:null},"");else if(!this.get_distinct_id()){const _=this.config.get_device_id(_l());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property(Ja,Nu)}return zn(Ee,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),zn(Ee,"pageshow",()=>{var _;this.xu=!1,this.Cu||(_=this.ju)===null||_===void 0||_.resume()}),n.segment?Gbe(this,()=>this.Uu()):this.Uu(),zo(this.config._onCapture)&&this.config._onCapture!==Ew&&(Ze.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",_=>this.config._onCapture(_.event,_))),this.config.ip&&Ze.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 Vje.apply(this,arguments)})().then(_=>{_&&this.register({[sL]:_})}).catch(Ew),this}Wu(t){const n=t;return fn(n.name)&&zo(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=>{Ze.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=op.__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)),zo(this.featureFlags.onReloading)&&zo(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({},op.__defaultExtensionClasses),this.config.__extensionClasses),o=[];var a,i,s,l,c,d,p;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,men)),r.toolbar&&this.au.push(this.toolbar=(d=this.toolbar)!==null&&d!==void 0?d:new r.toolbar(this)),r.experiments&&this.au.push(this.experiments=(p=this.experiments)!==null&&p!==void 0?p:new r.experiments(this)),this.au.forEach(f=>{f.initialize&&o.push(()=>{var m;(m=f.initialize)===null||m===void 0||m.call(f)})}),o.push(()=>{if(this.Qu){const f=this.Qu;this.Qu=void 0,this.au.forEach(m=>{var b;return(b=m.onRemoteConfig)===null||b===void 0?void 0:b.call(m,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){Ze.error("Error initializing extension:",a)}}const r=Math.round(performance.now()-n);this.register_for_session({[G4e]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[W4e]:r}),this.config.__preview_deferred_init_extensions&&Ze.info(`PostHog extensions initialized (${r}ms)`)}tl(t){var n;if(!$e||!$e.body)return Ze.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=Dt(o.supportedCompression,ns.GZipJS)?ns.GZipJS:Dt(o.supportedCompression,ns.Base64)?ns.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:eje}),(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){Ze.critical("`loaded` function failed",t)}if(this.Xu(),this.config.internal_or_test_user_hostname&&(Gr==null?void 0:Gr.hostname)){const t=Gr.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 Tje(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()&&pb(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(Rbe),(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(Rbe,null,{transport:"sendBeacon"})}_send_request(t){Bje(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){kL++;try{let n;const r=[],o=[],a=[];pb(t,s=>{if(s)if(n=s[0],Lt(n))a.push(s);else if(zo(s))try{s.call(this)}catch(l){Ze.error("Error executing queued PostHog call",s,l)}else Lt(s)&&n==="alias"?r.push(s):Lt(s)&&n.indexOf("capture")!==-1&&zo(this[n])?a.push(s):o.push(s)});const i=function(s,l){pb(s,function(c){try{if(Lt(c[0])){let d=l;Wn(c,function(p){d=d[p[0]].apply(d,p.slice(1))})}else l[c[0]].apply(l,c.slice(1))}catch(d){Ze.error("Error executing queued PostHog call",c,d)}})};i(r,this),i(o,this),i(a,this)}finally{kL--}}push(t){if(kL>0&&Lt(t)&&fn(t[0])){const n=op.prototype[t[0]];return void(zo(n)&&n.apply(this,t.slice(1)))}this._execute_array([t])}get ih(){return{property:Abe,persistenceKey:Db,cookieName:"_fbc",pattern:uve,register:(t,n)=>{var r;return(r=this.persistence)===null||r===void 0?void 0:r.register({[Db]:{value:t,delivered:n}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Db)}}}get nh(){return{property:Cbe,persistenceKey:bw,cookieName:"_fbp",pattern:dve,register:(t,n)=>{var r;return(r=this.persistence)===null||r===void 0?void 0:r.register({[bw]:{value:t,delivered:n}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(bw)}}}sh(t){var n;const r=(n=this.persistence)===null||n===void 0?void 0:n.get_property(t.persistenceKey);return fn(r)&&t.pattern.test(r)?{value:r,delivered:!1}:vn(r)&&fn(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=xw(t.cookieName);return fn(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 fn(n)&&uve.test(n)?this.rh(a,n,i):void a.unregister();const s=fn(t)&&ntn.test(t)?t:void 0,l=this.oh(a);return l&&((c,d,p)=>{const f=c.split(".");if(d)return f[3]===d;if(!p)return!0;const m=p.value.split(".");return f[3]===m[3]||Number(f[2])>Number(m[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 fn(t)&&dve.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 Ze.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(je(t)||!fn(t))return void Ze.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 Ze.critical("This capture call is ignored due to client rate limiting.");let l;n!=null&&n.$current_url&&!fn(n==null?void 0:n.$current_url)&&(Ze.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||Ze.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,d=(r==null?void 0:r.timestamp)||c,p=dbe(r==null?void 0:r.uuid,_l);let f={uuid:p,event:t,properties:this.calculateEventProperties(t,n||{},d,p)};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 m=t==="$feature_flag_called"&&f.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;r!=null&&r.$set&&!m&&(f.$set=r==null?void 0:r.$set);const b=vn(n==null?void 0:n.$set)?n.$set:void 0,y=Lt(n==null?void 0:n.$unset)?n.$unset:[],x=(r==null?void 0:r.$unset)||[],_=z=>{var F;const $=!!(r!=null&&r.$set)&&z in r.$set;return{hasProvided:$||!!b&&z in b,provided:$?r==null||(F=r.$set)===null||F===void 0?void 0:F[z]:b==null?void 0:b[z],unset:y.indexOf(z)!==-1||x.indexOf(z)!==-1}},k=_(Abe),E=_(Cbe),T=[{channel:this.ih,hasProvided:k.hasProvided,update:this.ah(l==null?void 0:l.fbclid,k.provided,k.hasProvided,k.unset)},{channel:this.nh,hasProvided:E.hasProvided,update:this.uh(E.provided,E.hasProvided,E.unset)}];for(const{channel:z,hasProvided:F,update:$}of T)$&&f.properties.$process_person_profile===!0&&$.pending&&!F&&!m&&(f.$set=ce({[z.property]:$.value},f.$set));const C=r==null?void 0:r.$unset;C&&(f.$unset=C);const A=m?void 0:this.fh(r==null?void 0:r.$set_once,t!==Ibe,t===tje);if(A&&(f.$set_once=A),r!=null&&r._noTruncate||(R=this.config.properties_string_max_length,f=(function(z,F){const $=new Set;return(function H(V,Y){if(V!==Object(V))return F?F(V):V;if($.has(V))return;let U;if($.add(V),Lt(V))U=[],pb(V,X=>{U.push(H(X))});else{const X={};Wn(zy(V)?nje(V):V,(J,K)=>{$.has(J)||(X[K]=H(J))}),U=X}return U})(z)})(f,z=>fn(z)?z.slice(0,R):z)),f.timestamp=d,je(r==null?void 0:r.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=c),m&&(f.properties=((z,F=[])=>{const $={},H=V=>{z[V]!==void 0&&($[V]=z[V])};return wJt.forEach(H),F.forEach(H),$})(f.properties,rtn)),t===Qi.DISMISSED||t===Qi.SENT){const z=n==null?void 0:n[vL.SURVEY_ID],F=n==null?void 0:n[vL.SURVEY_ITERATION];Yje({id:z,current_iteration:F}),f.$set=ce(ce({},f.$set),{},{[Ben({id:z,current_iteration:F},t===Qi.SENT?"responded":"dismissed")]:!0})}else t===Qi.SHOWN&&(f.$set=ce(ce({},f.$set),{},{[vL.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var R;if(t===Ten.SHOWN){const z=n==null?void 0:n[Zbe.TOUR_TYPE];z&&(f.$set=ce(ce({},f.$set),{},{[`${Zbe.TOUR_LAST_SEEN_DATE}/${z}`]:new Date().toISOString()}))}const M=ce(ce({},f.properties.$set),f.$set);if(_i(M)||this.setPersonPropertiesForFlags(M),!Kt(this.config.before_send)){const z=this.Os(f);if(!z)return;f=z,f.uuid=dbe(f.uuid,_l)}this.sessionRecording&&!this.Eu&&cve(t)&&(this.Eu=!0,setTimeout(()=>this.Eu=!1,3e4));const j=T.filter(({channel:z,update:F})=>{var $,H,V;const Y=($=(H=f.$set)===null||H===void 0?void 0:H[z.property])!==null&&$!==void 0?$:vn((V=f.properties)===null||V===void 0?void 0:V.$set)?f.properties.$set[z.property]:void 0;return(F==null?void 0:F.pending)&&Y===F.value});this.cu.emit("eventCaptured",f);const O=(o=r==null?void 0:r._url)!==null&&o!==void 0?o:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),P=(r==null?void 0:r._batchKey)==="recordings"||/\/s\/(?:\?|$)/.test(O),D=ce(ce(ce({method:"POST",url:O,data:f,compression:"best-available",preferSyncCompression:r==null?void 0:r.send_instantly,timestampMode:P?"body":"capture-body",batchKey:r==null?void 0:r._batchKey},P&&(!((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}:{}),j.length?{fireCallbackOnDrop:!0,callback:z=>{if(z.statusCode>=200&&300>z.statusCode)for(const{channel:F,update:$}of j)this.hh(F,$.value)}}:{});if(!this.config.request_batching||r&&!(r!=null&&r._batchKey)||r!=null&&r.send_instantly||j.length){var L;let z;!D.transport&&!D.callback&&_i((L=this.config.request_headers)!==null&&L!==void 0?L:{})&&this.xu&&(z="sendBeacon"),this.qu(D,z)}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 Jen(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[V4e]=!0),t==="$snapshot"){const k=ce(ce({},this.persistence.properties()),this.sessionPersistence.properties());return s.distinct_id=k.distinct_id,(!fn(s.distinct_id)&&!to(s.distinct_id)||gw(s.distinct_id))&&Ze.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}const l=(function(k,E,T,C=!1){var A,R,M,j;if(!Qa)return{};const O=k?[...$v,...E||[]]:[],[P,D]=u4e(Qa),[L,z]=(function(G){for(let Q=0;ube.length>Q;Q++){const[ne,de,se]=ube[Q],oe=G.match(ne);if(oe){const re=se&&G.match(se)||oe;return[de,(re==null?void 0:re[1])||""]}}return["",""]})(Qa),F=(function(){const G="u">typeof navigator?navigator:void 0;return G!=null&&G.brave?{brave:!0}:{}})(),$={};je(T)||($.detectGoogleSearchApp=T);const H={},V=(A=navigator)===null||A===void 0||(A=A.userAgentData)===null||A===void 0?void 0:A.platform,Y=(R=navigator)===null||R===void 0?void 0:R.maxTouchPoints,U=Ee==null||(M=Ee.screen)===null||M===void 0?void 0:M.width,X=Ee==null||(j=Ee.screen)===null||j===void 0?void 0:j.height,J=Ee==null?void 0:Ee.devicePixelRatio;je(V)||(H.userAgentDataPlatform=V),je(Y)||(H.maxTouchPoints=Y),je(U)||(H.screenWidth=U),je(X)||(H.screenHeight=X),je(J)||(H.devicePixelRatio=J);const K=jr(CX({$os:P,$os_version:D,$browser:c4e(Qa,navigator.vendor,F,$),$webview_app:L,$webview_app_version:z,$device:d4e(Qa),$device_type:HQt(Qa,H),$timezone:kje(),$timezone_offset:Sen()}),{$current_url:J_(C?Up(Gr==null?void 0:Gr.href):Gr==null?void 0:Gr.href,O,e1),$host:Gr==null?void 0:Gr.host,$pathname:Gr==null?void 0:Gr.pathname,$raw_user_agent:Qa.length>1e3?Qa.substring(0,997)+"...":Qa,$browser_version:BQt(Qa,navigator.vendor,F,$),$browser_language:xje(),$browser_language_prefix:_en(),$screen_height:Ee==null?void 0:Ee.screen.height,$screen_width:Ee==null?void 0:Ee.screen.width,$viewport_height:Ee==null?void 0:Ee.innerHeight,$viewport_width:Ee==null?void 0:Ee.innerWidth,$lib:Fu.LIB_NAME,$lib_version:Fu.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Fu.SDK_DIST_CHANNEL&&(K.$sdk_dist_channel=Fu.SDK_DIST_CHANNEL),K})(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:k,windowId:E}=this.sessionManager.checkAndGetSessionAndWindowId(a,r.getTime(),!0);s.$session_id=k,s.$window_id=E}this.sessionPropsManager&&jr(s,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const k=this.sessionRecording.sdkDebugProperties,E=!this.Eu&&cve(t);for(const T in k)(E||Dt(etn,T))&&(s[T]=k[T])}s.$sdk_debug_retry_queue_size=(c=this.ju)===null||c===void 0?void 0:c.length}catch(k){s.$sdk_debug_error_capturing_properties=String(k)}let d;if(this.requestRouter.region===l7&&(s.$lib_custom_api_host=this.config.api_host),d=t!=="$pageview"||a?t!=="$pageleave"||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),s=jr(s,d),t==="$pageview"&&$e&&(s.title=$e.title),!je(i)){const k=r.getTime()-i;s.$duration=parseFloat((k/1e3).toFixed(3))}Qa&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser");const p=this.persistence.properties(),f=this.sessionPersistence.properties(),m=s.$groups,b=p.$groups;vn(m)&&!_i(m)&&(s.$groups=ce(ce({},vn(b)?b:{}),m)),Wn(["$referrer","$referring_domain"],k=>{k in p&&delete f[k]});const y={};if(this.Mu.length>0)for(const k of this.Mu.slice())try{jr(y,k())}catch(E){Ze.error("Failed to produce browser extension event properties",E)}s=jr({},l,p,f,ce(ce({},y),s)),s.$is_identified=this._isIdentified(),Lt(this.config.property_denylist)?Wn(this.config.property_denylist,function(k){delete s[k]}):Ze.error(Zje+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const x=this.config.sanitize_properties;x&&(Ze.error(lve),s=x(s,t));const _=this.mh();return s.$process_person_profile=_,_&&!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=jr({},a,i||{},t||{});const l=this.config.sanitize_properties;return l&&(Ze.error(lve),s=l(s,"$set_once")),n&&(this.$u=!0),_i(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||!yr.At())return void yr.Lt(this.Iu);const n=[];this.Tu.forEach(r=>n.push(r)),n.length>0?yr.$t(this.Iu,n):yr.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:Um}),()=>{})}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:Um})}getActiveMatchingSurveys(t,n=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,n):t([],{isLoaded:!1,error:Um})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:Um}),()=>{})}renderSurvey(t,n){var r;(r=this.surveys)===null||r===void 0||r.renderSurvey(t,n)}displaySurvey(t,n=Ken){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:Um}}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:Um})}_h(t){return!t||gw(t)?(Ze.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(Ze.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())||(Ze.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 Ze.uninitializedWarning("posthog.identify");if(to(t)&&(t=t.toString(),Ze.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 d=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:d},""),t!==d&&t!==this.get_property("__alias")&&(this.unregister(xC),this.register({distinct_id:t}));const p=(this.persistence.get_property("$user_state")||"anonymous")===Nu,f=t!==d,m=!f&&p;if(f&&p){var c;const b=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:d};this.persistence.set_property(Ja,NT),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=SL(t,n,r)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:d)}else if(m){this.persistence.set_property(Ja,NT);const b=n||{},y=r||{};this.setPersonPropertiesForFlags({$set:b,$set_once:y},!1),this.config.cookieWinsOnConflict&&this.persistence.Oa(),this.capture("$set",{$set:b,$set_once:y})&&(this.Fu=SL(t,n,r))}else(n||r)&&this.setPersonProperties(n,r);f||a||i?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(kp)):m&&(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=SL(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)):Ze.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var n;const r=(Lt(t)?t:[t]).filter(o=>fn(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 Ze.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(Ibe,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=ni(t)?t:t==null?void 0:t.resetDeviceID,r=ni(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(Ze.info("reset"),!this.__loaded)return Ze.uninitializedWarning("posthog.reset");const d=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 p=this.get_property(xX),f=this.get_property(sL),m=this.get_property(vw);(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 y=(l=this.persistence)===null||l===void 0||(c=l.Fa)===null||c===void 0?void 0:c.call(l);let x=!1;try{var _,k,E,T,C,A,R,M,j,O,P,D,L;if((_=this.persistence)===null||_===void 0||_.clear(),(k=this.sessionPersistence)===null||k===void 0||k.clear(),this.Tu.clear(),this.gh(),je(m)||(O=this.persistence)===null||O===void 0||O.register({$session_recording_remote_config:m}),(E=this.surveys)===null||E===void 0||E.reset(),(T=this.featureFlags)===null||T===void 0||T.reset(),(C=this.conversations)===null||C===void 0||C.reset(),(A=this.logs)===null||A===void 0||A.reset(),(R=this.metrics)===null||R===void 0||R.reset(),(M=this.persistence)===null||M===void 0||M.set_property("$user_state","anonymous"),(j=this.sessionManager)===null||j===void 0||j.resetSessionId(),this.Fu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:lL,$device_id:null},"");else{const $=this.config.get_device_id(_l());this.register_once({distinct_id:$,$device_id:t?$:p},""),t||je(f)||this.register({[sL]:f})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),r&&(r.distinctID&&!this.mu()&&((L=this.persistence)===null||L===void 0||L.set_property("$user_state",r.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:r.distinctID})),(P=this.featureFlags)===null||P===void 0||P.initialize(),!Kt(d)&&!(!((D=this.sessionManager)===null||D===void 0)&&D.setBootstrapSessionId(d,!0)))){const $=ce({},r);delete $.sessionID,this.config.bootstrap=$}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,x=!0}finally{var z,F;y&&((z=this.persistence)===null||z===void 0||(F=z.Na)===null||F===void 0||F.call(z,x))}this.reloadFeatureFlags()}shutdown(t){var n=this;return Pr(function*(){var r,o,a,i,s,l,c,d;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 p;(p=n.featureFlags)===null||p===void 0||p.destroy()}catch(f){Ze.error("Error while destroying feature flags",f)}(c=n.persistence)===null||c===void 0||c.destroy(),(d=n.sessionPersistence)===null||d===void 0||d.destroy()}else Ze.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")?(Ze.critical("Attempting to create alias for existing People user - aborting."),-2):this.yh("posthog.alias")?(je(n)&&(n=this.get_distinct_id()),t!==n?(this.bh(xC,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(Ze.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const n=ce({},this.config);if(vn(t)){var r,o,a,i,s,l,c,d,p,f,m,b,y,x;jr(this.config,pve(t));const k=this.ku();(r=this.persistence)===null||r===void 0||r.update_config(this.config,n,k),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new mL(ce(ce({},this.config),{},{persistence:"sessionStorage"}),k,!1);const E=this.Ou(this.config.debug);var _;ni(E)&&(this.config.debug=E),ni(this.config.debug)&&(this.config.debug?(Ro.DEBUG=!0,Cn.At()&&Cn.$t("ph_debug",!0),Ze.info("set_config",{config:t,oldConfig:n,newConfig:ce({},this.config)})):(Ro.DEBUG=!1,Cn.At()&&Cn.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(),(d=this.tracingHeaders)===null||d===void 0||d.startIfEnabledOrStop(),(p=this.autocapture)===null||p===void 0||p.startIfEnabled(),(f=this.heatmaps)===null||f===void 0||f.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((_=this.historyAutocapture)===null||_===void 0||_.startIfEnabledOrStop()),(m=this.exceptionObserver)===null||m===void 0||m.startIfEnabledOrStop(),(b=this.deadClicksAutocapture)===null||b===void 0||b.startIfEnabledOrStop(),(y=this.surveys)===null||y===void 0||y.loadIfEnabled(),this.Su(),(x=this.externalIntegrations)===null||x===void 0||x.startIfEnabledOrStop(),!n.segment&&this.config.segment&&this.persistence&&Gbe(this,Ew,!1)}}_overrideSDKInfo(t,n){Ro.LIB_NAME=t,Ro.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:op.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:zx;return n!==zx&&(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()&&_i(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"?(Ze.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.yu(),this.bh(SX,!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 ove(this),this.pageViewManager=new Wbe(this),this.persistence&&(this.sessionPropsManager=new nve(this,this.sessionManager,this.persistence));const m=(i=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.sessionRecording)!==null&&i!==void 0?i:(l=op.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var c,d;m&&(this.sessionRecording=this.gu(this.sessionRecording,new m(this)),this.hu&&((c=this.sessionRecording)===null||c===void 0||(d=c.onRemoteConfig)===null||d===void 0||d.call(c,this.hu)))}var p,f;this.consent.optInOut(!0),this.Su(),this.Xu(),(n=this.sessionRecording)===null||n===void 0||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((p=this.surveys)===null||p===void 0||p.loadIfEnabled()),(je(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 Ze.warn(sve)}opt_out_capturing(){if(this.config.cookieless_mode==="always")return void Ze.warn(sve);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:lL,$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 $o?Hje($o,this.config.custom_blocked_useragents):void 0}Yu(){$e&&($e.visibilityState==="visible"?this.Pu||(this.Pu=!0,this.capture(AX,{title:$e.title},{send_instantly:!0}),this.Ru&&($e.removeEventListener(X_,this.Ru),this.Ru=null)):this.Ru||(this.Ru=this.Yu.bind(this),zn($e,X_,this.Ru)))}debug(t){t===!1?(Ee==null||Ee.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(Ee==null||Ee.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?(Ze.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&&!Kt(n[r]),l=o in n&&!Kt(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,Ze)}Os(t){var n;if(Kt(this.config.before_send))return t;const r=Object.keys((n=t.properties)!==null&&n!==void 0?n:{}).filter(NQt),o=Lt(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),Kt(a)){const s=`Event '${t.event}' was rejected in beforeSend function`;return IQt(t.event)?Ze.warn(`${s}. This can cause unexpected behavior.`):Ze.info(s),null}a.properties&&!_i(a.properties)||Ze.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(s){return Ze.error(`Error in beforeSend function for event '${t.event}':`,s),null}for(const i of r)if(a.properties&&Kt(a.properties[i]))return Ze.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=ni(t)&&!t,r=Cn.At()&&Cn.Ot("ph_debug")==="true";return!n&&(!!r||t)}};Tw.__defaultExtensionClasses={},Tw.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]]=JJt(e.prototype[t[n]])})(Tw,["identify"]);var Xje=class{constructor(e){this.disabled=e===!1;const t=vn(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 TL="$copy_autocapture",AL=Xr("[AutoCapture]");function CL(e,t){return t.length>e?t.slice(0,e)+"...":t}function stn(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!zc(t));return t}function ltn(e,{e:t,maskAllElementAttributes:n,maskAllText:r,elementAttributeIgnoreList:o,elementsChainAsString:a,disableCaptureUrlHashes:i}){var s,l;if(!zc(e))return{props:{}};const c=[e],d=new Set([e]);let p=e;for(;p.parentNode&&!xa(p,"body")&&1e3>c.length;){if(RX(p.parentNode)){const A=p.parentNode.host;if(d.has(A))break;d.add(A),c.push(A),p=A;continue}if(!zc(p.parentNode)||d.has(p.parentNode))break;d.add(p.parentNode),c.push(p.parentNode),p=p.parentNode}const f=t.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(A=>xa(A,"button")||xa(A,"a")):-1;f>0&&(r=r||c.slice(0,f+1).some(A=>!Lb(A)||Q_(A)));const m=[],b={};let y,x=!1,_=!1;if(Wn(c,A=>{const R=Lb(A);if(xa(A,"a")&&!n&&!(o!=null&&o.includes("href"))){const M=A.getAttribute("href");x=!!(R&&M&&_w(M))&&(i?Up(M):M)}Dt(Lv(A),"ph-no-capture")&&(_=!0),m.push((function(M,j,O,P,D=!1){const L=M.tagName.toLowerCase(),z={tag_name:L};NX.indexOf(L)>-1&&!O&&(z.$el_text=L.toLowerCase()==="a"||L.toLowerCase()==="button"?CL(1024,Bbe(M)):CL(1024,q_(M)));const F=Lv(M);j||P!=null&&P.includes("class")||0>=F.length||(z.classes=F.filter(function(Y){return Y!==""})),Wn(M.attributes,function(Y){var U;if((!Q_(M)||["name","id","class","aria-label"].indexOf(Y.name)!==-1)&&!(P!=null&&P.includes(Y.name))&&!j&&_w(Y.value)&&(!fn(U=Y.name)||U.substring(0,10)!=="_ngcontent"&&U.substring(0,7)!=="_nghost")){let X=Y.value;Y.name==="class"&&(X=IX(X).join(" ")),z["attr__"+Y.name]=CL(1024,Y.name==="href"&&D?Up(X):X)}});let $=1,H=1,V=M;for(;V=stn(V);)$++,V.tagName===M.tagName&&H++;return z.nth_child=$,z.nth_of_type=H,z})(A,n,r,o,i)),Wn((function(M){if(!Lb(M))return{};const j={};return Wn(M.attributes,function(O){if(O.name&&O.name.indexOf("data-ph-capture-attribute")===0){const P=O.name.replace("data-ph-capture-attribute-",""),D=O.value;P&&D&&_w(D)&&(j[P]=D)}}),j})(A),(M,j)=>{({}).hasOwnProperty.call(b,j)||(b[j]=M)})}),_)return{props:{},explicitNoCapture:_};if(f>0&&(e=c[f],m.splice(0,f)),r||(m[0].$el_text=xa(e,"a")||xa(e,"button")?Bbe(e):q_(e)),x){var k,E;m[0].attr__href=x;const A=(k=od(x))===null||k===void 0?void 0:k.host,R=Ee==null||(E=Ee.location)===null||E===void 0?void 0:E.host;A&&R&&A!==R&&(y=x)}return{props:jr((C=t.type,{$event_type:C,$ce_version:1}),a?{}:{$elements:m},{$elements_chain:(T=m,Lt(T)?(function(A){return A.map(R=>{var M,j;let O="";if(R.tag_name&&(O+=R.tag_name),R.attr_class){R.attr_class.sort();for(const L of R.attr_class)O+=`.${L.replace(/"/g,"")}`}const P=ce(ce(ce(ce({},R.text?{text:R.text}:{}),{},{"nth-child":(M=R.nth_child)!==null&&M!==void 0?M:0,"nth-of-type":(j=R.nth_of_type)!==null&&j!==void 0?j:0},R.href?{href:R.href}:{}),R.attr_id?{attr_id:R.attr_id}:{}),R.attributes),D={};return MT(P).sort(([L],[z])=>(function(F,$){return $>F?-1:F>$?1:0})(L,z)).forEach(([L,z])=>D[Hbe(L.toString())]=Hbe(z.toString())),O+=":",O+=MT(D).map(([L,z])=>`${L}="${z}"`).join(""),O}).join(";")})((function(A){return A.map(R=>{var M,j;const O={text:(M=R.$el_text)===null||M===void 0?void 0:M.slice(0,400),tag_name:R.tag_name,href:(j=R.attr__href)===null||j===void 0?void 0:j.slice(0,2048),attr_class:hen(R),attr_id:R.attr__id,nth_child:R.nth_child,nth_of_type:R.nth_of_type,attributes:{}};return MT(R).filter(([P])=>P.indexOf("attr__")===0).forEach(([P,D])=>O.attributes[P]=D),O})})(T)):"")},!((s=m[0])===null||s===void 0)&&s.$el_text?{$el_text:(l=m[0])===null||l===void 0?void 0:l.$el_text}:{},y&&t.type==="click"?{$external_click_url:y}:{},b),target:e};var T,C}var ctn=class{co(){this.do=void 0,clearTimeout(this.vo),this.vo=void 0}fo(e){var t;if(!Lb(e))return!0;const n=(t=this.po().css_selector_ignorelist)!==null&&t!==void 0?t:hL,r=new Set;let o=e;for(;o;){if(r.size>=1e3||r.has(o))return!0;r.add(o);const a=o,i=Lv(a);if(Dt(i,"ph-no-capture")||Dt(i,"ph-sensitive")||Q_(a)||n.some(l=>t7(a,l)))return!0;const s=o.parentNode;o=RX(s)?s.host:s&&zc(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=ww(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&r&&zc(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=ww(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&&(xa(r,"html")||xa(r,"body"))){var o;if(n.excluded)return null;const a=(o=this.po().css_selector_ignorelist)!==null&&o!==void 0?o:hL;return[r,$e==null?void 0:$e.documentElement,$e==null?void 0:$e.body].some(i=>{if(!i)return!1;const s=Lv(i);return Dt(s,"ph-no-capture")||Dt(s,"ph-sensitive")||!Lb(i)||Q_(i)||a.some(l=>t7(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 Xje(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 AL.info("Disabling Automatic Event Collection because this browser is not supported");if(!Ee||!$e)return;const e=this.Ro=t=>{t=t||(Ee==null?void 0:Ee.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(Kr(n))return;this.Ao(t,"$autocapture",n)}catch(n){AL.error("Failed to capture event",n)}};if(zn(Ee,"blur",e),zn($e,"submit",e,{capture:!0}),zn($e,"change",e,{capture:!0}),zn($e,"click",e,{capture:!0}),Wn(["pointerdown","pointermove","pointerup","pointercancel"],t=>{zn($e,t,e,{capture:!0})}),this.po().capture_copied_text){const t=this.Fo=n=>{n=n||(Ee==null?void 0:Ee.event);try{this.Ao(n,TL)}catch(r){AL.error("Failed to capture clipboard event",r)}};zn($e,"copy",t,{capture:!0}),zn($e,"cut",t,{capture:!0}),zn($e,"paste",t,{capture:!0})}}Eo(){this.co(),this.Ro&&(Ee==null||Ee.removeEventListener("blur",this.Ro),Wn(["pointerdown","pointermove","pointerup","pointercancel"],e=>{$e==null||$e.removeEventListener(e,this.Ro,!0)}),$e==null||$e.removeEventListener("submit",this.Ro,!0),$e==null||$e.removeEventListener("change",this.Ro,!0),$e==null||$e.removeEventListener("click",this.Ro,!0),this.Ro=void 0),this.Fo&&($e==null||$e.removeEventListener("copy",this.Fo,!0),$e==null||$e.removeEventListener("cut",this.Fo,!0),$e==null||$e.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;ni(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=$e==null?void 0:$e.querySelectorAll(o);a==null||a.forEach(i=>{e!==i&&t!==i||Dt(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(O4e),r=this.ko,o=this.po();if(!o.remoteRequestsDisabled&&!this.So)return!1;const a=o.remoteRequestsDisabled&&!this.So;if(Kr(r)&&!ni(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||ww(e);ije(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()))&&uje(r,o.rageclick)&&this.Ao(e,"$rageclick",n);const i=t===TL,s=i?ce(ce({},o),{},{dom_event_allowlist:void 0}):o;if(r&&(function(p,f,m,b,y,x){var _;if(!Ee||MX(p)||m!=null&&m.url_allowlist&&!Pbe(m.url_allowlist,x)||m!=null&&m.url_ignorelist&&Pbe(m.url_ignorelist,x))return!1;if(m!=null&&m.dom_event_allowlist){const C=m.dom_event_allowlist;if(C&&!C.some(A=>f.type===A))return!1}const{parentIsUsefulElement:k,targetElementList:E}=dje(p,b);if(!(function(C,A){const R=A==null?void 0:A.element_allowlist;if(je(R))return!0;for(const M of C)if(R.some(j=>M.tagName.toLowerCase()===j))return!0;return!1})(E,m)||!n7(E,m==null?void 0:m.css_selector_allowlist)||n7(E,(_=m==null?void 0:m.css_selector_ignorelist)!==null&&_!==void 0?_:hL))return!1;try{const C=Ee.getComputedStyle(p);if(C&&C.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0}catch{}const T=p.tagName.toLowerCase();switch(T){case"html":return!1;case"form":return(y||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(y||["change","click"]).indexOf(f.type)>=0;default:return k?(y||["click"]).indexOf(f.type)>=0:(y||["click"]).indexOf(f.type)>=0&&(NX.indexOf(T)>-1||p.getAttribute("contenteditable")==="true")}})(r,e,s,i,i?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var l;const{props:p,explicitNoCapture:f,target:m}=ltn(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,m);if(b&&b.length>0&&(p.$element_selectors=b),t===TL){const y=e.type||"clipboard";if(y!=="paste"){var c,d;const x=Ee==null||(c=Ee.getSelection())===null||c===void 0?void 0:c.toString(),_=sje(x);if(!_)return!1;p.$selected_content=_,p.$clipboard_text_length=(d=x==null?void 0:x.length)!==null&&d!==void 0?d:0}p.$copy_type=y}return(l=this.yo)===null||l===void 0||l.capture(t,p),!0}}isBrowserSupported(){return zo($e==null?void 0:$e.querySelectorAll)}},utn=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,n=vn(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 kx=Xr("[ExceptionAutocapture]"),fve=()=>{},hve=e=>{var t;if(zo(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function t1(e,t,n){try{if(!(t in e))return fve;const r={next:e[t]},o=n(function(...a){return r.next.apply(this,a)});return zo(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=hve(a);for(;i;){if(i.next===o)return void(i.next=r.next);a=i.next,i=hve(a)}}}catch{return fve}}const dtn=Xr("[TracingHeaders]"),Kf=Xr("[Web Vitals]"),gve=9e5,mve=["CLS","FCP","INP","LCP"],ptn=["INP","LCP"],ftn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],RL="disabled",bve="lazy_loading",yu=Xr("[SessionRecording]"),htn=[kX,EX,K4e,Y4e,Z4e,X4e,q4e,Q4e,J4e],gtn=Xr("[Heatmaps]");function IL(e){return vn(e)&&"clientX"in e&&"clientY"in e&&to(e.clientX)&&to(e.clientY)}const WE=Xr("[Product Tours]"),NL=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(_X))},mtn=["$set_once","$set"],ac=Xr("[SiteApps]"),vve="Error while initializing PostHog app with config id ",qje=(e,t)=>e!=null&&e.then?e.then(t):t(e),Bm="SDK is not enabled or survey functionality is not yet loaded",yve="Disabled. Not loading surveys.";var btn=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."}),Bn.warn("Remote config unavailable. Not loading surveys.");const r=n.config.surveys;if(Kt(r))return Bn.warn("Flags not loaded yet. Not loading surveys.");this.Oh=ni(r)?r:r.length>0,Bn.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,qje(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 Bn.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void Bn.info(yve);if(e.cookielessMode&&this._o.isOptedOut())return void Bn.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(je(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(TX),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(Dx);o&&this.Bh(o),Bn.info("Surveys loaded successfully"),this.Hh(),this.Fh(),this.zh({isLoaded:!0})}qh(e,t){this.Ih=!0,Bn.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 Bn.info(yve),e([]);const o=r.kv.get(Dx);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=>Bn.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 Bn.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=>Bn.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(Bm)}))}Vh(e,t){if(this.$o)return{surveys:[],context:{isLoaded:!1,error:Bm}};const n=t.statusCode;if(n!==200||!t.json){const o=`Surveys API could not be loaded, status: ${n}`;return n!==0?Bn.error(o):t.error||Bn.warn(o),this.Rh=Date.now(),{surveys:[],context:{isLoaded:!1,error:o}}}this.Rh=null;const r=t.json.surveys||[];return e.kv.set({[Dx]:r,[wC]: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)&&(Gje(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(wC);return to(n)&&Date.now()-n>3e5}Zh(){return to(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};Yje(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){Bn.error("Error in survey callback",n)}}getActiveMatchingSurveys(e,t=!1){if(!Kt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Bn.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(Dx);return this.Mr.disableSurveys||!this._surveyManager&&this.Ih&&!this.Th||!o&&!Kt(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){Bn.error("Error in active matching surveys callback",a)}};try{t&&!t.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(o){Bn.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(Kt(this._surveyManager))return{eligible:!1,reason:Bm};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(Kt(this._surveyManager))return{eligible:!1,reason:Bm};const t=typeof e=="string"?this.Qh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Kt(this._surveyManager))return Bn.warn("init was not called"),{visible:!1,disabledReason:Bm};const t=this.Kh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Kt(this._surveyManager)?(Bn.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Bm})):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(Kt(this._surveyManager))return void Bn.warn("init was not called");const o=typeof e=="string"?this.Qh(e):e;if(!(o!=null&&o.id))return void Bn.warn("Survey not found");if(!Wen.includes(o.type))return void Bn.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=$e==null?void 0:$e.querySelector(t);if(a){if(!((r=o.appearance)===null||r===void 0)&&r.surveyPopupDelaySeconds){Bn.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()&&(Bn.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),Bn.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this.Ah.add(i)}this._surveyManager.renderSurvey(o,a,n)}else Bn.warn("Survey element not found")}displaySurvey(e,t){var n;if(!this._o.isCapturing())return;if(Kt(this._surveyManager))return void Bn.warn("init was not called");const r=this.Qh(e);if(!r)return void Bn.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!==r7.Popover&&t.initialResponses&&Bn.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 Bn.warn("Survey is not eligible to be displayed: ",a.reason)}t.displayType!==r7.Inline?this._surveyManager.handlePopoverSurvey(o,t):this.renderSurvey(o,t.selector,t.properties)}cancelPendingSurvey(e){Kt(this._surveyManager)?Bn.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 Hm(e,t,n){if(Kt(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 vtn=class{constructor(e){this._instance=e,this.Xh=new Set,this.Yh=new Set,this.tc=new AC,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;je((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 AC}register(e){var t,n;if(!je((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"||!Hm(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=>Hm(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&&Hm((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=>Hm(l.text,t.text,t.text_matching||"exact")||Hm(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=[],d=/(?::|")text="(.*?)"/g;let p;for(;!Kt(p=d.exec(l));)c.includes(p[1])||c.push(p[1]);return c})(o),i=t.text,s=t.text_matching||"exact",a.some(l=>Hm(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||Kje(t.properties.reduce((n,r)=>{const o=Lt(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)}},ytn=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&&Kje(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===wx.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;je((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 vtn(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,d;return((c=l.conditions)===null||c===void 0?void 0:c.events)&&((d=l.conditions)===null||d===void 0||(d=d.events)===null||d===void 0||(d=d.values)===null||d===void 0?void 0:d.length)>0}),a=e.filter(l=>{var c,d;return((c=l.conditions)===null||c===void 0?void 0:c.cancelEvents)&&((d=l.conditions)===null||d===void 0||(d=d.cancelEvents)===null||d===void 0||(d=d.values)===null||d===void 0?void 0:d.length)>0}),i=this.Tc(e,wx.Activation),s=this.Tc(e,wx.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,wx.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,wx.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&&(_i(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 to(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=>to(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}},xtn=class extends ytn{constructor(e,t){super(e,t)}Kc(){return $4e}Xc(){return F4e}Sc(){return U4e}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 to(r)&&r>0}sd(){return Qi.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 Bn}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===Qi.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 Gje(a)&&!!(!((i=a.conditions)===null||i===void 0||(i=i.events)===null||i===void 0)&&i.repeatedActivation)||a.schedule==="always"})(o)?e===Qi.SHOWN?"consume":"ignore":e===Qi.SHOWN?"persist":e===Qi.DISMISSED||e===Qi.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},wtn=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);je(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)}},_tn=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=Ct==null?void 0:Ct.__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 xtn(this._instance,e)}onMatchingConditionsChanged(e){const t=this._instance._addCaptureHook(a=>{a!=="$pageview"&&a!==Qi.SHOWN&&a!==Qi.DISMISSED&&a!==Qi.SENT||e()}),n=()=>e();zn(Ee,"PHSurveyShown",n);let r=!1;const o=this._instance.onFeatureFlags(()=>{r&&e()});return r=!0,()=>{r=!1,t(),o(),Ee==null||Ee.removeEventListener("PHSurveyShown",n)}}};const Stn=Ee!=null&&Ee.location?kC(Ee.location.hash,"__posthog")||kC(location.hash,"state"):null,xve="_postHogToolbarParams",wve=Xr("[Toolbar]"),_ve=Xr("[FeatureFlags]");var ktn=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,d,p;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:je(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:(d=(p=n.evaluation_contexts)!==null&&p!==void 0?p:n.evaluation_environments)!==null&&d!==void 0?d:[],flagKeys:Lt(n.flag_keys)?n.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.rd||(_ve.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.rd=!0),je(e.flag_keys)||Lt(e.flag_keys)||_ve.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.od}};const Sve=Xr("[FeatureFlags]"),Yf=Xr("[FeatureFlags]",{debugEnabled:!0}),ML=`" failed. Feature flags didn't load in time.`,Etn=[502,504],kve=["click","keydown","wheel","touchstart","pointerdown"],Eve="connection_error",Tve=e=>{const t={};for(let n=0;e.length>n;n++)t[e[n]]=!0;return t},Ave=e=>{const t={};for(const[n,r]of MT(e||{}))r&&(t[n]=r);return t},Cve=e=>zy(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),fl=Xr("[Error tracking]"),c7="webkit-masked-url:",Ttn=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Atn=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",c7],Ctn=["__firefox__","__gCrWeb"],Rve="Refusing to render web experiment since the viewer is a likely bot",Rtn={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>CC(t,e),not_regex:(e,t)=>!CC(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Ms=Xr("[Conversations]"),Zf="Conversations not available yet.";function Ive(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,d=(r=e==null?void 0:e.maxBufferSize)!==null&&r!==void 0?r:100,p=t!=null&&t.consoleCapture?void 0:(o=e==null?void 0:e.maxLogsPerInterval)!==null&&o!==void 0?o:1e3,f=je(p)?Math.max(d,2048):Math.max(d,p),m=ce(ce({},(function(){let b="",y="";try{const x=$o==null?void 0:$o.userAgent;x&&([b,y]=u4e(x))}catch{}return(function(x,_){const k=(function(E){if(E)return{}.hasOwnProperty.call(Sbe,E)?Sbe[E]:E})(x);return ce(ce({},k?{"os.name":k}:{}),_?{"os.version":_}:{})})(b,y)})()),e==null?void 0:e.resourceAttributes);return{serviceName:(a=(i=m==null?void 0:m["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=m==null?void 0:m["service.version"])!==null&&s!==void 0?s:e==null?void 0:e.serviceVersion,environment:(l=m==null?void 0:m["deployment.environment"])!==null&&l!==void 0?l:e==null?void 0:e.environment,resourceAttributes:m,beforeSend:e==null?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:d,maxQueueSize:f,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:p,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Itn=["debug","log","warn","error","info"],Ntn=e=>{for(;e!=null&&e.__rrweb_original__;)e=e.__rrweb_original__;return e},Nve="console",Qje="__posthogHandledLogsRequestError",OL=(e,t)=>{const n=e instanceof Error?e:new Error(t);return n[Qje]=!0,n},Mve=e=>!!e&&typeof e=="object"&&e[Qje]===!0,RC=Xr("[NetworkMetrics]"),PX=()=>{var e;return!(Ee==null||(e=Ee.performance)===null||e===void 0)&&e.now?Ee.performance.now():Date.now()},Mtn={"http:":80,"https:":443},Otn=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Jje=(e,t)=>{var n;const r=String(t);return{method:String(e).toUpperCase(),url:((n=od(r))===null||n===void 0?void 0:n.href)||r}},u7=(e,t,n,r,o,a,i=!1)=>{try{var s,l;const c=o();if(!c)return;const d=n||void 0,p=PX()-r,f=od(t.url);if(f&&f.protocol!=="http:"&&f.protocol!=="https:")return;const m={url:(f==null?void 0:f.href)||t.url,method:t.method},b=zo(c.name)?c.name(m):fn(c.name)?c.name:"http.client.request.duration";if(!b)return;const y=i&&!d?void 0:((_,k)=>_?400>_?void 0:String(_):(k==null?void 0:k.name)||"_OTHER")(d,a),x=ce(ce(ce(ce(ce({},(_=>{const k=Otn.has(_)?_:"_OTHER";return ce({"http.request.method":k},k==="_OTHER"&&_!==k?{"http.request.method_original":_}:{})})(m.method)),f?(_=>{return{"server.address":_.hostname.startsWith("[")&&_.hostname.endsWith("]")?_.hostname.slice(1,-1):_.hostname,"server.port":Number(_.port)||Mtn[_.protocol],"url.scheme":_.protocol.slice(0,-1),"url.template":(k=_.pathname,k.split("/").map(E=>(T=>/^\d+$/.test(T)||T.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(T))(E)?":id":E).join("/"))};var k})(f):{}),d?{"http.response.status_code":d}:{}),y?{"error.type":y}:{}),(s=c.attributes)===null||s===void 0?void 0:s.call(c,m,{status:d,durationMs:p}));(l=e.metrics)===null||l===void 0||l.histogram(b,p,{unit:"ms",attributes:x})}catch(c){RC.error("Failed to record network metric",c)}},ePe=()=>{},jtn=(e,t)=>zo(Ee==null?void 0:Ee.fetch)?t1(Ee,"fetch",n=>function(...r){const o=PX(),a=n.apply(this,r);if(!t())return a;try{var i,s,l;const[c,d]=r,p=Jje((i=(s=d==null?void 0:d.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=>(u7(e,p,f==null?void 0:f.status,o,t,void 0,!0),f),f=>{throw u7(e,p,void 0,o,t,f),f})}catch(c){return RC.error("Failed to observe fetch",c),a}}):ePe,Ptn=(e,t)=>{var n;const r=Ee==null||(n=Ee.XMLHttpRequest)===null||n===void 0?void 0:n.prototype;if(!r)return ePe;const o=new WeakMap,a=t1(r,"open",s=>function(...l){try{Mje.has(this)||o.set(this,Jje(l[0],l[1]))}catch(c){RC.error("Failed to observe XHR open",c)}return s.apply(this,l)}),i=t1(r,"send",s=>function(...l){let c;try{const d=o.get(this);if(d&&t()){const p=PX();c=()=>{this.removeEventListener("loadend",c),u7(e,d,this.status,p,t)},zn(this,"loadend",c)}}catch(d){RC.error("Failed to observe XHR send",d)}try{return s.apply(this,l)}catch(d){throw c&&this.removeEventListener("loadend",c),d}});return()=>{a(),i()}},kN={featureFlags:class{constructor(e){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.A=Sve,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;je(r)||je(o)||this.Mr.remoteRequestsDisabled||!$e||$e.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=()=>{($e==null?void 0:$e.visibilityState)==="visible"&&this.Id()},"get"in e?this._o=e:(this._instance=e,this.Md=new ktn(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]"),qje(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 Ee&&zn(Ee,"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&&$e&&!je(e)&&e>0?e:void 0;this.Mr.idleRefreshBackoff||(this.xd=t),t!==this.Sd&&(this.Nd(),je(t)||(this.Sd=t,this.xd=t,this.$d(),$e!=null&&$e.addEventListener&&(zn($e,X_,this.sn),pb(kve,n=>{zn($e,n,this.Td,{capture:!0})}))))}$d(){je(this.Sd)||(je(this.qd)||clearInterval(this.qd),this.Cd=Date.now(),this.qd=setInterval(this.kd,this.Sd))}Nd(){var e;je(this.qd)||(clearInterval(this.qd),this.qd=void 0,$e==null||(e=$e.removeEventListener)===null||e===void 0||e.call($e,"visibilitychange",this.sn),pb(kve,t=>{var n;$e==null||(n=$e.removeEventListener)===null||n===void 0||n.call($e,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=[],Ee==null||Ee.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!je((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(([,_])=>!(_!=null&&_.failed)).map(([_])=>_):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,c=l?s:n&&!Lt(i)?Object.keys(i||{}):Array.from(new Set([...Object.keys(o),...Object.keys(a)])),d=this.Hd("$feature_flag_payloads")||{},p=e.$feature_flag_payloads||{},f=l||n?c:Array.from(new Set([...Object.keys(d),...Object.keys(p)])),m=!l&&!n,b=!!m||c,y=!!m||f,x={[Iu]:b,[xl]:b,[wp]:y};e.$feature_flag_details&&(x[Nh]=b);for(const _ of[Mh,Mp,yw])je(e[_])||(x[_]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(x)}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[Iu,wp,Mh,sc]){const o=this.Hd(r);je(o)||(e[r]=o)}this.ld=e;const t=ce({},e),n=this.Hd(xl);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(Mp);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(!je(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=>!je(r[c])).reduce((c,d)=>(c[d]=r[d],c),{}),l=Object.keys(i).filter(c=>s[c]).reduce((c,d)=>(c[d]=i[d],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[d,p]of Object.entries(s))c[d]={key:d,enabled:vbe(p),variant:ybe(p),reason:void 0,metadata:je(l==null?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}};this.Jd({flags:c})}get hasLoadedFlags(){return this.dd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Hd(Nh),t=this.Hd(sc),n=this.Hd(rh);if(!n&&!t)return e||{};const r=jr({},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],d=je(c)?(a=l==null?void 0:l.enabled)!==null&&a!==void 0&&a:!!c,p=je(c)?l==null?void 0:l.variant:typeof c=="string"?c:void 0,f=n==null?void 0:n[s],m=ce(ce({},l),{},{enabled:d,variant:d?p??(l==null?void 0:l.variant):void 0});var i;d!==(l==null?void 0:l.enabled)&&(m.original_enabled=l==null?void 0:l.enabled),p!==(l==null?void 0:l.variant)&&(m.original_variant=l==null?void 0:l.variant),f&&(m.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]=m}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:vbe(r),variant:ybe(r),payload:bbe(t[n])}})}getFlagVariants(){const e=this.Hd(xl),t=this.Hd(sc);if(!t)return e||{};const n=jr({},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(wp),t=this.Hd(rh);if(!t)return e||{};const n=jr({},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(kp)}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(Sp),timezone:kje()};je(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();je(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 y,x;const _=(y=b.json)!==null&&y!==void 0?y:{},k=b.statusCode!==200;if(this.vd=!1,s!==this.fd)return void l();if(this.Yd(b.statusCode),k||this.gd||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.gd)return;this.md=!k;const E=[];b.error?E.push(b.error instanceof Error&&b.error.name==="AbortError"?"timeout":b.error instanceof Error?Eve:"unknown_error"):b.statusCode!==200&&E.push(`api_error_${b.statusCode}`),_.errorsWhileComputingFlags&&E.push("errors_while_computing_flags");const T=!!(!((x=_.quotaLimited)===null||x===void 0)&&x.includes("feature_flags"));T&&E.push("quota_limited"),this.$t({[Z_]:E}),T?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(_,k,{partialResponse:a}),l()},d=b=>{this.vd=!1,s===this.fd&&(this.$t({[Z_]:[Eve]}),this.A.error("Feature flag request failed",b),this.Ud()&&this.Ld(!0)),l()};let p=this.Mr.requestMaxRetries;const f=()=>p>0&&s===this.fd,m=()=>{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((y=>Etn.includes(y.statusCode)||(x=>x.statusCode===0&&x.error instanceof Error&&x.error.name==="AbortError")(y))(b)&&f())return p--,void setTimeout(m,500);c(b)}).catch(d)}catch(b){d(b)}};m()}wd(){return gje(this.bd,3)}Yd(e){this.bd=mje(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+ML);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+ML);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,d=this.Hd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var p;const j=(p=this.yo)===null||p===void 0?void 0:p.session.sessionId,O=this.Hd(Lx);j&&j!==O&&(d={},c=j)}if(t.send_event||!("send_event"in t))if(e in d&&d[e].includes(i))c&&this.$t({[kp]:d,[Lx]:c});else{var f,m,b,y,x,_,k,E,T,C,A,R;Lt(d[e])?d[e].push(i):d[e]=[i],this.$t(ce({[kp]:d},c?{[Lx]:c}:{}));const j=this.getFeatureFlagDetails(e),O=[...(f=this.Hd("$feature_flag_errors"))!==null&&f!==void 0?f:[]];je(o)&&O.push("flag_missing");const P={$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:(m=(b=this.Mr.bootstrap)===null||b===void 0||(b=b.featureFlags)===null||b===void 0?void 0:b[e])!==null&&m!==void 0?m:null,$feature_flag_bootstrapped_payload:(y=(x=this.Mr.bootstrap)===null||x===void 0||(x=x.featureFlagPayloads)===null||x===void 0?void 0:x[e])!==null&&y!==void 0?y:null,$used_bootstrap_value:!this.md};je(j==null||(_=j.metadata)===null||_===void 0?void 0:_.has_experiment)||(P.$feature_flag_has_experiment=j.metadata.has_experiment),je(j==null||(k=j.metadata)===null||k===void 0?void 0:k.version)||(P.$feature_flag_version=j.metadata.version);const D=(E=j==null||(T=j.reason)===null||T===void 0?void 0:T.description)!==null&&E!==void 0?E:j==null||(C=j.reason)===null||C===void 0?void 0:C.code;var M;D&&(P.$feature_flag_reason=D),!(j==null||(A=j.metadata)===null||A===void 0)&&A.id&&(P.$feature_flag_id=j.metadata.id),je(j==null?void 0:j.original_variant)&&je(j==null?void 0:j.original_enabled)||(P.$feature_flag_original_response=je(j.original_variant)?j.original_enabled:j.original_variant),!(j==null||(R=j.metadata)===null||R===void 0)&&R.original_payload&&(P.$feature_flag_original_payload=j==null||(M=j.metadata)===null||M===void 0?void 0:M.original_payload),O.length&&(P.$feature_flag_error=O.join(",")),this.tv(P)}else c&&this.$t({[kp]:d,[Lx]:c});return r?{key:e,enabled:!!o,variant:typeof o=="string"?o:void 0,payload:bbe(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 Pr(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;je(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+ML),t.defaultValue;const n=this.getFeatureFlag(e,t);return je(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=Sve)=>{const d=((E,T)=>{const C=E.flags;if(C){const A=Object.fromEntries(Object.keys(C).map(M=>{var j;return[M,(j=C[M].variant)!==null&&j!==void 0?j:C[M].enabled]})),R=Object.fromEntries(Object.keys(C).filter(M=>C[M].enabled).filter(M=>{var j;return!je((j=C[M].metadata)===null||j===void 0?void 0:j.payload)}).map(M=>{var j;return[M,(j=C[M].metadata)===null||j===void 0?void 0:j.payload]}));return ce(ce({},E),{},{featureFlags:A,featureFlagPayloads:R})}return E.featureFlags&&T.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),E})(o,c),p=d.flags,f=d.featureFlags,m=d.featureFlagPayloads;if(!f)return;const b=o.requestId,y=o.evaluatedAt;if(Lt(f)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const E={};if(f)for(let T=0;f.length>T;T++)E[f[T]]=!0;return{[Iu]:f,[xl]:E,[yw]:!1}}let x=f,_=m,k=p;if(l!=null&&l.partialResponse){const E=Object.keys(x),T=_||{};x=ce(ce({},a),x),_=ce(ce({},i),T),E.forEach(C=>{C in T||_==null||delete _[C]}),k=ce(ce({},s),k)}else if(o.errorsWhileComputingFlags)if(p){const E=new Set(Object.keys(p).filter(C=>{var A;return!(!((A=p[C])===null||A===void 0)&&A.failed)}));x=ce(ce({},a),Object.fromEntries(Object.entries(x).filter(([C])=>E.has(C))));const T=Object.fromEntries(Object.entries(_||{}).filter(([C])=>E.has(C)));_=ce(ce({},i),T),E.forEach(C=>{C in T||_==null||delete _[C]}),k=ce(ce({},s),Object.fromEntries(Object.entries(k||{}).filter(([C])=>E.has(C))))}else x=ce(ce({},a),x),_=ce(ce({},i),_),k=ce(ce({},s),k);return ce(ce({[Iu]:Object.keys(Ave(x)),[xl]:x||{},[wp]:_||{},[Nh]:k||{},[yw]:o.minimalFlagCalledEvents===!0},b?{[Mh]:b}:{}),y?{[Mp]:y}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.A);if(r)if((n==null?void 0:n.persist)===!1){const o=!je(this.yo.kv.get(xl));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([sc,rh]),this.Ld(),void Yf.info("All overrides cleared");if(Lt(e))return this.$t({[sc]:Tve(e)}),this.Ld(),void Yf.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[sc]=Lt(o)?Tve(o):o),a&&(r[rh]=a),Object.keys(r).length&&this.$t(r),o===!1&&a===!1?this.Lt([sc,rh]):o===!1?this.Lt(sc):a===!1&&this.Lt(rh),this.Ld(),o===!1?Yf.info("Flag overrides cleared"):o&&Yf.info("Flag overrides set",{flags:o}),void(a===!1?Yf.info("Payload overrides cleared"):a&&Yf.info("Payload overrides set",{payloads:a}))}if(e&&typeof e=="object")return this.$t({[sc]:e}),this.Ld(),void Yf.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({[Iu]:Object.keys(Ave(s)),[xl]:s,[_p]: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(Z$);!r||t?this.sv(e,n):e(r)}sv(e,t){var n=this;return Pr(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({[Z$]: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({[_p]: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({[_p]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(_p),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({[Sp]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.Hd("$stored_group_properties")||{};this.$t({[Sp]:ce(ce({},t),{},{[e]:{}})})}else this.Lt(Sp)}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}}},Dtn={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=RL,this.lv=void 0,this.uv=!1,this.Je=(()=>{var t,n;if(!($e!=null&&$e.visibilityState)||$e.visibilityState==="visible")return!0;const r=Ee==null||(t=Ee.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;($e==null?void 0:$e.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 yu.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"');$e!=null&&$e.addEventListener&&zn($e,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.uv=!0,$e==null||(t=$e.removeEventListener)===null||t===void 0||t.call($e,"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 Ee&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(this.uv||this.dv&&(!((t=this.ov)===null||t===void 0)&&t.isStarted))return;const n=!je(Object.assign)&&!je(Array.from);this.dv&&n?(this.vv(e),yu.info("starting")):(this.av=RL,this.stopRecording())}vv(e){var t,n;if(this.dv)if(this.av!=="awaiting_config"&&this.av!=="missing_config"&&(this.av=bve),(Ct==null||(t=Ct.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((n=Ct.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording))this.fv(e);else{var r,o;const a=this._instance.sessionManager;(r=Ct.__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}),yu.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(Kt(e))return null;const n=to(e)?e:parseFloat(e);return typeof(r=n)!="number"||!Number.isFinite(r)||0>r||r>1?(yu.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;Kt(c)&&this.gv();const d=i==null?void 0:i.minimumDurationMilliseconds;r.register({[vw]: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:je(d)?null:d,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({[EX]:!0}),yu.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):yu.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(vw);return(n==null||(t=n.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}bv(){const e=this._instance.get_property(vw);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(n){return yu.warn("persisted remote config for session recording is invalid and will be ignored",n),!1}return!Kt(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=Ct.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return yu.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[kX]:!0});var o;if(this.ov||(this.ov=(o=Ct.__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",yu.info("persisted remote config is stale, requesting fresh config before starting"),void new Tje(this._instance).load());this.av=bve,(n=(r=this.ov).setDocumentWasEverVisible)===null||n===void 0||n.call(r,this.Je),this.ov.start(e)}else this.av=RL}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 htn){var n;const o=(n=this._instance.sessionPersistence)===null||n===void 0?void 0:n.get_property(r);je(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)}}},Ltn={autocapture:class extends ctn{constructor(e){super(new utn(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&&(Ze.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,Ze.info("History API monitoring stopped")}monitorHistoryChanges(){Ee&&Ee.history&&(this.Iv("pushState"),this.Iv("replaceState"),this.Mv(),this.Cv()&&this.Ev())}Iv(e){var t;if(!Ee||!((t=Ee.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const n=this;t1(Ee.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&&(Ee==null||(s=Ee.event)===null||s===void 0?void 0:s.type)!=="popstate")})}Sv(){const e=Ee==null?void 0:Ee.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}:vn(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(AX,{navigation_type:e});t?(this.Ov=r,Promise.resolve().then(()=>this.Rv())):r()}this.wv=n}catch(n){Ze.error(`Error capturing ${e} pageview`,n)}}Pv(e){var t,n;return!(Kt(e)||!Ee)&&((t=od(String(e)))===null||t===void 0?void 0:t.href)!==((n=Ee.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){Ze.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(Ee,"popstate",e),this.$v=()=>{Ee&&Ee.removeEventListener("popstate",e)}}Ev(){if(this.Tv)return;const e=()=>{this.Av("hashchange")};zn(Ee,"hashchange",e),this.Tv=()=>{Ee&&Ee.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[G$]),this.rageclicks=new Xje(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return vn(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Kt(this.Mr.capture_heatmaps)?Kt(this.Mr.enable_heatmaps)?this.Dv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.wo)return;gtn.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({[G$]:n}),this.Dv=n,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}jv(e){IL(e.originalEvent)&&this.Cr(e.originalEvent,"deadclick")}sn(){this.Lv&&clearInterval(this.Lv),this.Lv=($e==null?void 0:$e.visibilityState)==="visible"?setInterval(this.ml.bind(this),this.flushIntervalMilliseconds):null}Nv(){Ee&&$e&&(this.Bv=this.ml.bind(this),zn(Ee,_C,this.Bv),this.Hv=e=>this.Cr(e||(Ee==null?void 0:Ee.event)),zn($e,"click",this.Hv,{capture:!0}),this.zv=e=>this.Uv(e||(Ee==null?void 0:Ee.event)),zn($e,"mousemove",this.zv,{capture:!0}),this.Wv=new Vbe(this.instance,gen,this.jv.bind(this)),this.Wv.startIfEnabledOrStop(),this.Vv=this.sn.bind(this),zn($e,X_,this.Vv),this.wo=!0)}qv(){var e;Ee&&$e&&(this.Bv&&Ee.removeEventListener(_C,this.Bv),this.Hv&&$e.removeEventListener("click",this.Hv,{capture:!0}),this.zv&&$e.removeEventListener("mousemove",this.zv,{capture:!0}),this.Vv&&$e.removeEventListener(X_,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&&zc(c)&&!xa(c,"body");){if(c===l)return!1;let m;try{var d,p,f;m=(d=(p=(f=c.ownerDocument)===null||f===void 0?void 0:f.defaultView)!==null&&p!==void 0?p:Ee)===null||d===void 0?void 0:d.getComputedStyle(c).position}catch{return!1}if(Dt(s,m))return!0;c=lje(c)}return!1})(ww(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(jbe(e.target)||!IL(e))return;const r=this.Zv(e,t);!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&uje(ww(e),this.instance.config.rageclick)&&this.Zs(ce(ce({},r),{},{type:"rageclick"})),this.Zs(r)}Uv(e){!jbe(e.target)&&IL(e)&&(clearTimeout(this.Gv),this.Gv=setTimeout(()=>{this.Zs(this.Zv(e,"mousemove"))},500))}Zs(e){if(!Ee)return;const t=this.Mr.disable_capture_url_hashes?Up(Ee.location.href):Ee.location.href,n=this.Mr.custom_personal_data_properties,r=this.Mr.mask_personal_data_properties?[...$v,...n||[]]:[],o=J_(t,r,e1);this.Rt=this.Rt||{},this.Rt[o]||(this.Rt[o]=[]),this.Rt[o].push(e)}ml(){this.Rt&&!_i(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Vbe,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},Kt(n==null?void 0:n.name)||Kt(n==null?void 0:n.value))return void Kf.error("Invalid metric received",n);const o=typeof n.navigationURL=="string"?n.navigationURL:void 0,a=this.Xv(o);if(je(a))return;const i=to(n.navigationId)||typeof n.navigationId=="string"?`navigation:${n.navigationId}`:`url:${a}`;if(this.Yv&&n.value>=this.Yv)return void Kf.error("Ignoring metric with value >= "+this.Yv,n);this.Rt.navigationKey!==i&&(this.Qv(),this.Jv=setTimeout(this.Qv,this.flushToCaptureTimeoutMs)),je(this.Rt.navigationKey)&&(this.Rt.navigationKey=i,this.Rt.url=a),this.Rt.firstMetricTimestamp=je(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,vn(n.attribution)&&this.attributionMetrics.indexOf(n.name)>-1){const c={};for(const d of ftn){const p=d==="url"&&typeof n.attribution[d]=="string"?this.Xv(n.attribution[d]):n.attribution[d];je(p)||(c[d]=p)}l.attribution=c}else delete l.attribution;je(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=Ct.__PosthogExtensions__,l=s==null?void 0:s.postHogWebVitalsCallbacksByFlavor,c=(l==null?void 0:l[this.ef])||(this.ef==="web-vitals"&&je(l)?s==null?void 0:s.postHogWebVitalsCallbacks:void 0);if(!je(c)){const f=c.withoutAttribution,m=this.attributionMetrics;i=!je(f),n=m.indexOf("LCP")>-1?c.onLCP:(f==null?void 0:f.onLCP)||c.onLCP,r=m.indexOf("CLS")>-1?c.onCLS:(f==null?void 0:f.onCLS)||c.onCLS,o=m.indexOf("FCP")>-1?c.onFCP:(f==null?void 0:f.onFCP)||c.onFCP,a=m.indexOf("INP")>-1?c.onINP:(f==null?void 0:f.onINP)||c.onINP}if(!(n&&r&&o&&a))return void Kf.error("web vitals callbacks not loaded - not starting");const d={reportSoftNavs:this.useSoftNavs},p=i&&this.attributionMetrics.indexOf("INP")>-1?ce(ce({},d),{},{includeProcessedEventEntries:!1}):d;this.allowedMetrics.indexOf("LCP")>-1&&n(this.Kv.bind(this),d),this.allowedMetrics.indexOf("CLS")>-1&&r(this.Kv.bind(this),d),this.allowedMetrics.indexOf("FCP")>-1&&o(this.Kv.bind(this),d),this.allowedMetrics.indexOf("INP")>-1&&a(this.Kv.bind(this),p),this.wo=!0},this.Dv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[Y$]),this.startIfEnabled()}get if(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const n=vn(this.if)?(e=this.if)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return Kt(n)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||mve:n}get flushToCaptureTimeoutMs(){return(vn(this.if)?this.if.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=vn(this.if)?this.if.web_vitals_attribution:void 0;return ni(e)?e?mve:[]:Lt(e)?e:ptn}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=vn(this.if)?this.if.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Yv(){const e=vn(this.if)&&to(this.if.__web_vitals_max_value)?this.if.__web_vitals_max_value:gve;return e>0&&6e4>=e?gve:e}get isEnabled(){const e=Gr==null?void 0:Gr.protocol;if(e!=="http:"&&e!=="https:")return Kf.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=vn(this.if)?this.if.web_vitals:ni(this.if)?this.if:void 0;return ni(t)?t:this.Dv}startIfEnabled(){this.isEnabled&&!this.wo&&(Kf.info("enabled, starting..."),this.Bo(this.tf))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const n=vn(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=vn(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Y$]:n}),this._instance.persistence.register({[D4e]: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=Ct.__PosthogExtensions__,r=this.ef,o=n==null?void 0:n.postHogWebVitalsCallbacksByFlavor;o!=null&&o[r]||r==="web-vitals"&&je(o)&&(n!=null&&n.postHogWebVitalsCallbacks)?e():n==null||(t=n.loadExternalDependency)===null||t===void 0||t.call(n,this._instance,r,a=>{a?Kf.error("failed to load script",a):e()})}Xv(e){const t=e||(Ee==null?void 0:Ee.location.href);if(!t)return void Kf.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?Up(t):t,r=this._instance.config.custom_personal_data_properties,o=this._instance.config.mask_personal_data_properties?[...$v,...r||[]]:[];return J_(n,o,e1)}}},ztn={exceptionObserver:class{constructor(e){var t;this.tf=()=>{var n;if(!Ee||!this.isEnabled||!(!((n=Ct.__PosthogExtensions__)===null||n===void 0)&&n.errorWrappingFunctions))return;const r=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=Ct.__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){kx.error("failed to start",i),this.af()}},this._instance=e,this.lf=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[W$]),this.wt=new PQt(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:kx})),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 vn(e)?t=ce(ce({},t),e):(je(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?(kx.info("enabled"),this.af(),this.Bo(this.tf)):this.af()}Bo(e){var t,n,r;!((t=Ct.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(n=Ct.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"exception-autocapture",o=>{if(o)return kx.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({[W$]: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 kx.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 KQt([new lJt,new bJt,new uJt,new cJt,new gJt,new hJt,new pJt,new mJt],(function(r,...o){return(a,i=0)=>{const s=[],l=a.split(`
|
|
1000
1000
|
`),c=Math.min(l.length,i+1e3),d=[];for(let m=i;c>m;m++){const b=l[m];if(b.length>1024)continue;const y=mbe.test(b)?b.replace(mbe,"$1"):b;if(!y.match(/\S*Error: /)){for(const x of o){const _=x(y,r);if(_){s.push(_);const k=oJt(s);if(k){for(let E=d.length-1;E>=0;E--){const T=d[E];if(k.start>=T.start+T.length)break;d.pop()}d.push(k)}break}}if(iJt(s,d)>=50)break}}const p=[...d].sort((m,b)=>b.start-m.start),f=p[p.length-1];if(f){const m=v4e(s,f);s.splice(f.start-m,m);for(const b of p)b.start-=m}for(const m of p)aJt(s,m);return d.some(m=>m.start===0&&s.length===m.length)&&(function(m){const b=m.map(x=>`${x.function}|${x.filename}|${x.lineno}|${x.colno}|${x.module}`);let y=0;for(let x=1;b.length>x;x++)sJt(b,x,y)&&(y=x);m.push(...m.splice(0,y))})(s),(function(m){if(!m.length)return[];const b=Array.from(m);return b.reverse(),b.slice(0,50).map(y=>{return ce(ce({},y),{},{filename:y.filename||(x=b,x[x.length-1]||{}).filename,function:y.function||"?"});var x})})(s)}})("web:javascript",eJt,rJt)),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=bC(this.vf()),this.ff=new yJt(this.df)}onConfigChange(){this.df=bC(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({[j4e]:this.hf,[K$]:i})}get pf(){var e;const t=!!this._instance.get_property(K$),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(!fn(e)||e.trim().length===0)return void fl.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)=>vJt.has(s)?(a.push(s),i):(i[s]=o[s],i),{}),droppedKeys:a}})(this.gf(t));r.length>0&&fl.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.ff.add(ce({[gC]:e,[mC]:new Date().toISOString()},n))}catch(n){fl.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 fl.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 fl.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 fl.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 fl.info("Skipping exception capture because it was thrown by the PostHog SDK")}const n=this.df.enabled&&Kt(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 Cve(o)||fl.error("Failed to capture exception event. Dropping this exception.",o),void this.ff.clear()}}catch(t){return void(Cve(t)||fl.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 fl.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}bf(e){this.df.enabled&&this.ff.add({[gC]:e,[mC]:new Date().toISOString()})}gf(e){return vn(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})=>(fn(r)&&r.length>0&&n.$exception_types.push(r),fn(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=Wje[o.operator],i=t[o.key];if(!a||!i)return!1;const s=Lt(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 fl.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&&Atn.some(o=>r.startsWith(o)));return n.length!==0&&(!n.every(({filename:r})=>!!r&&r.startsWith(c7))||e.some(({type:r,value:o})=>r==="NoResponse"||fn(o)&&Ttn.some(({value:a,exact:i})=>i?o===a:o.includes(a)))&&!t.some(({in_app:r,filename:o})=>r&&!(o!=null&&o.startsWith(c7))))}wf(e){return e.some(({value:t})=>fn(t)&&Ctn.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!Kt(e)&&Lt(e)}}},$tn=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({[_X]:!!t.productTours}),!NL(this._instance))return!this.xf&&Kt((n=this.Tl)===null||n===void 0?void 0:n.props.ph_product_tours)||WE.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&&NL(this._instance)&&this.Bo(()=>this.$f())}Bo(e){var t,n,r;!((t=Ct.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(n=Ct.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"product-tours",o=>{o?WE.error("Could not load product tours script",o):e()})}$f(){var e;!this.xf&&(!((e=Ct.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.xf=Ct.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(Lt(this.Cf)&&!t)return void e(this.Cf,{isLoaded:!0});const n=this.Tl;if(n){const r=n.props[X$];if(Lt(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(!NL(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||WE.warn(i):WE.error(i),void e([],{isLoaded:!1,error:i})}const a=Lt(r.json.product_tours)?r.json.product_tours:[];this.Cf=a,n&&n.register({[X$]:a}),e(a,{isLoaded:!0})}})}getActiveProductTours(e){Kt(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)}}},kN),Ftn={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=Ct._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")||[],d=this._instance.get_property("$stored_group_properties")||{};for(const[m,b]of Object.entries(d))l[m]={id:c[m],type:m,properties:b};const{$set_once:p,$set:f}=e;return{event:ce(ce({},_4e(e,mtn)),{},{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)}:{}),p?{$set_once:ce(ce({},(r=(o=e.properties)===null||o===void 0?void 0:o.$set_once)!==null&&r!==void 0?r:{}),p)}:{}),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)||(ac.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)||(ac.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=$e==null?void 0:$e.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 d=[],p=this,f=new WeakSet,m=(x,_,k)=>{if(!(x!=null&&x[_]))return;const E=x[_];x[_]=k(E),d.push(()=>{x[_]=E})},b=x=>{if(f.has(x))return x;const _=p.Pf(x);return _&&f.add(_),_},y=x=>x.map(_=>typeof _=="string"?_:b(_)).filter(_=>!Kr(_));return m(c,"appendChild",x=>function(_){const k=b(_);return k?x.call(this,k):_}),m(c,"insertBefore",x=>function(_,k){const E=b(_);return E?x.call(this,E,k):_}),m(c,"replaceChild",x=>function(_,k){const E=b(_);return E?x.call(this,E,k):k}),[(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(x=>{m(x,"append",_=>function(...k){return _.apply(this,y(k))}),m(x,"prepend",_=>function(...k){return _.apply(this,y(k))})}),[(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(x=>{m(x,"before",_=>function(...k){return _.apply(this,y(k))}),m(x,"after",_=>function(...k){return _.apply(this,y(k))}),m(x,"replaceWith",_=>function(...k){const E=y(k);return k.length&&!E.length?void 0:_.apply(this,E)})}),m((s=l.Element)===null||s===void 0?void 0:s.prototype,"insertAdjacentElement",x=>function(_,k){const E=b(k);return E?x.call(this,_,E):null}),this.Af=()=>{d.forEach(x=>x()),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&&(ac.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,ac.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){ac.error(vve+e.id,a),o(!1)}if(r&&t.loaded)try{n()}catch(a){ac.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){ac.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 ac.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;Ct[`__$$ph_site_app_${s}`]=this._instance,(a=Ct.__PosthogExtensions__)===null||a===void 0||(i=a.loadSiteApp)===null||i===void 0||i.call(a,this._instance,l,c=>{if(c)return ac.error(vve+s,c)})}else ac.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Utn={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?(je(this.Nf)&&(this.Nf=(n=Ct.__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)),je(this.qf)&&(this.qf=(r=Ct.__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=Ct.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(n=Ct.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this._instance,"tracing-headers",o=>{if(o)return dtn.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 Lt(e)?(Lt(this.jf)?this.jf.splice(0,this.jf.length,...e):this.jf=[...e],e.length>0?this.jf:void 0):(Lt(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()}}},Btn=ce({surveys:class extends btn{constructor(e){var t;super(new _tn(e),(t=e,{get projectToken(){return t.config.token},kv:new wtn(t)})),this._instance=e}Wh(e,t){const n=t.query?J1(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})})}}},kN),Htn={toolbar:class{constructor(e){this.instance=e}zf(e){Ct.ph_toolbar_state=e}Uf(){var e;return(e=Ct.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(Q$(this.instance.config)||!Ee||!$e)return!1;e=(r=e)!==null&&r!==void 0?r:Ee.location,n=(o=n)!==null&&o!==void 0?o:Ee.history;try{if(!t){try{Ee.localStorage.setItem("test","test"),Ee.localStorage.removeItem("test")}catch{return!1}t=Ee==null?void 0:Ee.localStorage}const a=Stn||kC(e.hash,"__posthog")||kC(e.hash,"state");let i;const s=a?pbe(()=>JSON.parse(atob(decodeURIComponent(a))))||pbe(()=>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(xve)||"{}"),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=Ct.ph_load_toolbar||Ct.ph_load_editor;!Kt(t)&&zo(t)?t(e,this.instance):wve.warn("No toolbar load function found")}loadToolbar(e){const t=!!($e!=null&&$e.getElementById("__POSTHOG_TOOLBAR__"));if(!Ee||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(Ee.localStorage.setItem(xve,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=Ct.__PosthogExtensions__)===null||o===void 0||(a=o.loadExternalDependency)===null||a===void 0||a.call(o,this.instance,"toolbar",i=>{if(i)return wve.error("[Toolbar] Failed to load",i),void this.zf(0);this.zf(2),this.Wf(r)}),zn(Ee,"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)}}},Vtn=ce({experiments:class Za{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(n=!1)=>{this.getWebExperiments(r=>{Za.Gf("retrieved web experiments from the server"),this.Zf=new Map,r.forEach(o=>{if(o.feature_flag_key){var a;this.Zf&&(Za.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);fn(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];Za.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())Za.Gf(Rve);else if(!this.Mr.disable_web_experiments){if(Kt(this.Zf))return this.Zf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Za.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=Za.getWindowLocation();if(t!=null&&t.search){const n=zv(t==null?void 0:t.search,"__experiment_id"),r=zv(t==null?void 0:t.search,"__experiment_variant");n&&r&&(Za.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&&(Za.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!Kt(t.conditions)&&Za.Xf(t,n)&&Za.Yf(t)}static Xf(t,n){var r;if(Kt(t.conditions)||Kt((r=t.conditions)===null||r===void 0?void 0:r.url))return!0;const o=Za.getWindowLocation();if(o){var a,i,s;const l=aje(n,o.href);return!(!((a=t.conditions)===null||a===void 0)&&a.url)||Rtn[(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 Ee==null?void 0:Ee.location}static Yf(t){var n;if(Kt(t.conditions)||Kt((n=t.conditions)===null||n===void 0?void 0:n.utm))return!0;const r=bje();if(r.utm_source){var o,a,i,s,l,c,d,p;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,m=!(!((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,y=!(!((d=t.conditions)===null||d===void 0||(d=d.utm)===null||d===void 0)&&d.utm_term)||((p=t.conditions)===null||p===void 0||(p=p.utm)===null||p===void 0?void 0:p.utm_term)==r.utm_term;return f&&b&&y&&m}return!1}static Gf(t,...n){Ze.info(`[WebExperiments] ${t}`,n)}Qf(t,n,r){this._is_bot()?Za.Gf(Rve):n!=="control"?r.forEach(o=>{if(o.selector){var a;Za.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)})}}):Za.Gf("Control variants leave the page unmodified.")}_is_bot(){return $o&&this._instance?Hje($o,this.Mr.custom_blocked_useragents):void 0}}},kN),Gtn={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;Kt(t)||(ni(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||Q$(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=Ct==null?void 0:Ct.__PosthogExtensions__;if(e&&!je(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(TX);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 Ms.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,Ms.info("Conversations loaded successfully")}catch(t){this.op("Error completing conversations initialization",t)}else Ms.error("Cannot complete initialization: remote config is null")}op(e,t){Ms.error(e,t),this._conversationsManager=null,this.ep=!1,this.np=!0}show(){this._conversationsManager?this._conversationsManager.show():Ms.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.tp===!0&&!Kr(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Q$(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.sp===!1?"remote_config_failed":je(this.tp)?this.sp?"disabled_in_project":"remote_config_pending":this.tp?Kt(this.ne)||!this.ne.token?"missing_token":Ct!=null&&Ct.__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 Pr(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Ms.warn(Zf),null)})()}getMessages(e,t){var n=this;return Pr(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Ms.warn(Zf),null)})()}markAsRead(e){var t=this;return Pr(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Ms.warn(Zf),null)})()}getTickets(e){var t=this;return Pr(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Ms.warn(Zf),null)})()}requestRestoreLink(e){var t=this;return Pr(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Ms.warn(Zf),null)})()}restoreFromToken(e){var t=this;return Pr(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Ms.warn(Zf),null)})()}restoreFromUrlToken(){var e=this;return Pr(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Ms.warn(Zf),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()}}},Wtn={logs:class{constructor(e){var t;this._instance=e,this.name="logs",this.ap=!1,this.lp=!1,this.up=!1,this.A=Xr("[logs]"),this.hp=ce(ce({},this.A),{},{error:(...n)=>{n.some(Mve)||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),Ee&&zn(Ee,"online",this.gp)}bp(e,t,n,r){var o;const a=Ive((o=this._instance)===null||o===void 0||(o=o.config)===null||o===void 0?void 0:o.logs,n);return[new RJt(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},Nve)),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,Ee==null||Ee.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;Kt(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[P4e])}Ip(){var e,t,n;return!(!((e=this._instance)===null||e===void 0||(t=e.el)===null||t===void 0)&&t.call(e))||!!(!((n=Ct._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||!(Ct!=null&&Ct.console))return;const t=Ive((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 Itn){let o;try{o=Ntn(Ct.console[r])}catch{continue}o&&this.vp.push(t1(Ct.console,r,a=>{const i=(...s)=>{try{n&&this.Fp(r,s,t)}catch{}return a.apply(Ct.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){Mve(e)||this.A.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.$o||!this.ap||this.lp||this.up)return;const e=Ct==null?void 0:Ct.__PosthogExtensions__;if(!e)return this.A.error("PostHog Extensions not found."),void this.Pp();const t=e.loadExternalDependency;if(!t)return this.A.error(TX),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===uc.LogsQueue?e():void 0,setPersistedProperty(r,o){var a;r===uc.LogsQueue&&t((a=o)!==null&&a!==void 0?a:[])},js:r=>this.js(r),getLibraryId:()=>Ro.LIB_NAME,getLibraryVersion:()=>Ro.LIB_VERSION}}js(e){return new Promise(t=>{if(gje(this.bd,3))return void t({kind:"fatal",error:OL(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:OL(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:OL(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=mje(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,Ro.LIB_NAME,t=>{this.rl=t}),this.cp.length>0&&this.Hp(e,this.cp,this.Tp,Nve,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=C4e(a,A4e(n,Ro.LIB_NAME,Ro.LIB_VERSION),r,Ro.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,Kt(o)||(t.sessionStartTimestamp=o),Kt(a)||(t.lastActivityTimestamp=a)}if(!(Ct==null||(e=Ct.location)===null||e===void 0)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Up(Ct.location.href):Ct.location.href),this._instance.featureFlags){const n=this._instance.featureFlags.getFlags();n&&n.length>0&&(t.activeFeatureFlags=n)}return t}}},Ktn={metrics:class{constructor(e){this._instance=e,this.A=Xr("[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=jtn(n,o),i=Ptn(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 IJt(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:()=>Ro.LIB_NAME,getLibraryVersion:()=>Ro.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)}}};Tw.__defaultExtensionClasses=ce({},ce(ce(ce(ce(ce(ce(ce(ce(ce(ce(ce(ce(ce({},kN),Dtn),Ltn),ztn),$tn),Ftn),Btn),Utn),Htn),Vtn),Gtn),Wtn),Ktn));(function(){Ro.SDK_DIST_CHANNEL="npm";const e=kw[zx]=new Tw;return(function(){function t(){t.done||(t.done=!0,Uje=!1,Wn(kw,function(n){n._dom_loaded()}))}$e!=null&&$e.addEventListener?$e.readyState==="complete"?t():zn($e,"DOMContentLoaded",t,{capture:!1}):Ee&&Ze.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();const Ytn="%%TRUEFORGE_BASE_PATH%%";function Ztn(){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(Ytn)?"/":e.endsWith("/")?e:`${e}/`}const ad=Ztn(),EN=ad;function Xtn(){return ad.length>1?ad.replace(/\/$/,""):void 0}function tPe(e){const t=e.startsWith("/")?e:`/${e}`;return ad==="/"?t:`${ad.replace(/\/$/,"")}${t}`}const Ove="monacoeditorwork";function jve(e){const t=e.split("/").pop();return t===void 0||t===""?`${ad}${Ove}/`:`${ad}${Ove}/${t}`}function qtn(){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?jve(r):jve(`${n}.worker.bundle.js`)}}}const Qtn=tPe("/api/v1/auth/login"),Jtn=tPe("/api/v1/auth/logout");function DX(e=ad){const t=new URLSearchParams({return_to:e});return`${Qtn}?${t.toString()}`}function nPe(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(DX(`${window.location.pathname}${window.location.search}`))),new Promise(a=>{}))}}function enn({reason:e}){const t=e==="login_failed"?"We couldn’t complete sign-in. Please try again.":e;return g.jsx("main",{className:"auth-screen",children:g.jsxs("div",{className:"auth-screen-card",children:[g.jsx(mZ,{className:"auth-screen-logo"}),g.jsx("h1",{className:"auth-screen-title",children:"Sign-in failed"}),g.jsx("p",{className:"auth-screen-message",children:t}),g.jsx("a",{className:"auth-screen-button",href:DX(),children:"Try again"})]})})}const tnn=new uX({baseUrl:EN,fetch:nPe()}),nnn=new uX({baseUrl:EN,fetch:globalThis.fetch.bind(globalThis)});let rPe;function Pve(){return rPe}async function rnn(e=tnn){const{data:t}=await e.auth.me(),n=t.type==="oidc-connected";return rPe=n,n}async function onn(e=globalThis.fetch.bind(globalThis)){const t=await e(Jtn,{method:"POST",credentials:"include"});if(!t.ok)throw new Error(`Logout failed (${String(t.status)})`)}async function ann(e=nnn){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 Dve(e){var n;const t=(n=new URLSearchParams(e).get("error"))==null?void 0:n.trim();return t||null}function inn({authError:e,session:t}){return e==null||t.status!=="unauthenticated"?null:e}function snn({pathname:e,search:t,hash:n}){const r=new URLSearchParams(t);r.delete("error");const o=r.toString();return`${e}${o===""?"":`?${o}`}${n}`}function lnn(){return g.jsx("main",{className:"auth-screen",children:g.jsxs("div",{className:"auth-screen-card",children:[g.jsx(mZ,{className:"auth-screen-logo"}),g.jsx("h1",{className:"auth-screen-title",children:"Welcome to TrueForge"}),g.jsx("button",{type:"button",className:"auth-screen-button",onClick:()=>{window.location.assign(DX())},children:"Let's Get Started"})]})})}function cnn(){const[e,t]=w.useState(()=>Pve()===!0),[n,r]=w.useState(!1),[o,a]=w.useState(!1);if(w.useEffect(()=>{const s={cancelled:!1};return rnn().then(l=>{s.cancelled||t(l)}).catch(()=>{!s.cancelled&&Pve()===void 0&&t(!1)}),()=>{s.cancelled=!0}},[]),!e)return null;const i=()=>{o||(a(!0),onn().then(()=>{window.location.assign(ad)}).catch(()=>{a(!1)}))};return g.jsxs(g.Fragment,{children:[g.jsx("button",{type:"button","aria-label":"Log out",title:"Log out",className:"harness-logout",onClick:()=>{r(!0)},children:g.jsx(xe,{name:"log-out"})}),g.jsx(PZ,{open:n,onOpenChange:s=>{o||r(s)},title:"Log out",description:"Sure to logout?",contentSized:!0,children:g.jsxs("div",{className:"harness-logout-confirm",children:[g.jsx("button",{type:"button",className:"harness-logout-cancel",disabled:o,onClick:()=>{r(!1)},children:"Cancel"}),g.jsx("button",{type:"button",className:"harness-logout-submit",disabled:o,onClick:i,children:o?"Logging out…":"Confirm"})]})})]})}function unn(e){const t=vo(),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 g.jsx(COe,{...e,...r?{className:r}:{}})}const oPe=nPe(),Lve=sf({baseUrl:EN,fetch:oPe}),zve=Xtn(),Vm={className:"harness-primary-gradient",tokens:{primaryButtonBg:"#6366F1",primaryButtonHover:"#3d2dd4"}};function $ve(){const{mode:e}=lze();return g.jsx("div",{className:"boot-screen",role:"status","aria-label":"Loading","aria-live":"polite","aria-busy":"true",children:g.jsx(gZ,{state:"connecting",speed:1,theme:e,paused:!1,"aria-hidden":!0,size:64,style:{width:"4.5rem",height:"4.5rem"}})})}function dnn(){const e=Dve(window.location.search),[t,n]=w.useState({status:"checking"}),[r,o]=w.useState({status:"loading"});w.useEffect(()=>{const s={cancelled:!1};return ann().then(l=>{s.cancelled||n(l)}),()=>{s.cancelled=!0}},[]),w.useEffect(()=>{t.status==="authenticated"&&Dve(window.location.search)!=null&&window.history.replaceState(window.history.state,"",snn({pathname:window.location.pathname,search:window.location.search,hash:window.location.hash}))},[t]),w.useEffect(()=>{if(t.status!=="authenticated")return;const s={cancelled:!1};return(async()=>{try{const[l,c]=await Promise.all([f5e(Lve),m5e(Lve)]);if(s.cancelled)return;const d=l[0],p={sandbox:{enabled:c.sandbox.enabled}};if(d===void 0){o({status:"ready",openSettings:c.settings.enabled,defaultAgentSpec:{model:{name:""},config:p}});return}const f=d.properties.reasoningEfforts,m=(f==null?void 0:f.find(b=>b!=="none"))??(f==null?void 0:f[0]);o({status:"ready",openSettings:!1,defaultAgentSpec:{model:{name:d.name,...m?{params:{reasoningEffort:m}}:{}},config:p}})}catch(l){s.cancelled||o({status:"error",message:aa(l,"Failed to boot")})}})(),()=>{s.cancelled=!0}},[t]);const a=w.useMemo(()=>({ShellActionsActionSlot:cnn,WelcomeScreen:unn}),[]),i=inn({authError:e,session:t});return i!=null?g.jsx(Gm,{theme:Vm,children:g.jsx(enn,{reason:i})}):t.status==="checking"?g.jsx(Gm,{theme:Vm,children:g.jsx($ve,{})}):t.status==="unauthenticated"?g.jsx(Gm,{theme:Vm,children:g.jsx(lnn,{})}):r.status==="error"?g.jsx(Gm,{theme:Vm,children:g.jsxs("div",{className:"boot-screen","data-error":"true",children:["Failed to load application configuration: ",r.message]})}):r.status==="loading"?g.jsx(Gm,{theme:Vm,children:g.jsx($ve,{})}):g.jsx("div",{className:"app-root",children:g.jsx(NWt,{server:{type:"trueforge",baseUrl:EN,fetch:oPe},layout:"sidebar",withRouter:!0,...zve?{routes:{basename:zve}}:{},agentConfig:{mode:"AgentLibraryWithComposer",defaultAgentSpec:r.defaultAgentSpec},initialSettingsOpen:r.openSettings,currentUser:{subjectId:t.subjectId,displayName:t.displayName},overrides:a,theme:Vm,className:"app-assistant"})})}qtn();const aPe=document.getElementById("root");if(!aPe)throw new Error("Root element #root not found");nLe.createRoot(aPe).render(g.jsx(w.StrictMode,{children:g.jsx(dnn,{})}));const pnn=Object.freeze(Object.defineProperty({__proto__:null,OpenUiFenceBlock:IIe},Symbol.toStringTag,{value:"Module"}));export{eFt as $,lrn as A,cOe as B,wnn as C,Ege as D,dOe as E,Ov as F,CE as G,Qnn as H,xe as I,qnn as J,Jnn as K,Xnn as L,Vge as M,K1 as N,eo as O,k7 as P,bnn as Q,Hv as R,Gs as S,iWt as T,Zs as U,G1 as V,aa as W,K7t as X,W7t as Y,$7t as Z,Sa as _,arn as a,y7t as a$,u$ as a0,O7t as a1,In as a2,ti as a3,bT as a4,Oge as a5,iFt as a6,sFt as a7,xMe as a8,lx as a9,kge as aA,Mb as aB,W as aC,mN as aD,pMe as aE,hl as aF,grn as aG,prn as aH,mrn as aI,vrn as aJ,yrn as aK,brn as aL,Ih as aM,xme as aN,Gnn as aO,x7t as aP,frn as aQ,xrn as aR,hrn as aS,urn as aT,IVt as aU,aN as aV,t7t as aW,drn as aX,lMe as aY,W1 as aZ,wl as a_,lFt as aa,cx as ab,Mge as ac,lN as ad,cN as ae,xZ as af,wZ as ag,aMe as ah,oFt as ai,of as aj,bp as ak,Io as al,a7e as am,gMe as an,c$ as ao,uN as ap,uMe as aq,PC as ar,Bo as as,g$ as at,$nn as au,vnn as av,Z7t as aw,rrn as ax,orn as ay,lHt as az,vo as b,irn as b$,Vnn as b0,Wnn as b1,I$e as b2,ld as b3,kye as b4,N$e as b5,NZ as b6,PZ as b7,qNe as b8,QNe as b9,dGe as bA,zh as bB,fJe as bC,ern as bD,KMe as bE,LVt as bF,DVt as bG,UZ as bH,Eg as bI,krn as bJ,Dnn as bK,Ob as bL,wrn as bM,qVt as bN,V1 as bO,FLt as bP,nrn as bQ,oUt as bR,lze as bS,fye as bT,NC as bU,ZFt as bV,_ye as bW,mnn as bX,fOe as bY,dN as bZ,JUt as b_,JNe as ba,BMe as bb,Zqt as bc,trn as bd,Ve as be,SMe as bf,Ynn as bg,Srn as bh,crn as bi,_re as bj,iN as bk,Y7 as bl,Lnn as bm,QVt as bn,WVt as bo,$Lt as bp,Knn as bq,BFt as br,jnn as bs,Onn as bt,Ern as bu,Pnn as bv,ox as bw,_rn as bx,hw as by,fGe as bz,Gv as c,ynn as c0,Re as c1,as as c2,us as c3,lo as c4,Yv as c5,za as c6,oR as c7,sR as c8,l1 as c9,WC as cA,xn as cB,Unn as cC,g7t as cD,Bnn as cE,Hnn as cF,mMe as cG,fN as cH,di as cI,oN as cJ,Fnn as cK,Znn as cL,kFt as cM,hnn as cN,znn as cO,w$t as cP,ud as ca,cn as cb,Awe as cc,vt as cd,XC as ce,uF as cf,pwe as cg,aF as ch,l_e as ci,Jwe as cj,Oxe as ck,c_e as cl,qt as cm,Ku as cn,si as co,sg as cp,qwe as cq,Qwe as cr,lF as cs,Ri as ct,Bs as cu,YGe as cv,la as cw,ig as cx,ms as cy,Qs as cz,We as d,OMe as e,Xt as f,pe as g,Trn as h,ng as i,g as j,ui as k,y7 as l,Vv as m,OC as n,x7 as o,v7 as p,gnn as q,w as r,xye as s,sN as t,tn as u,xnn as v,AGt as w,M7t as x,dc as y,srn as z};
|