@henlii/pidance 0.1.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/.next/BUILD_ID +1 -0
- package/.next/app-path-routes-manifest.json +54 -0
- package/.next/build-manifest.json +20 -0
- package/.next/package.json +1 -0
- package/.next/prerender-manifest.json +114 -0
- package/.next/required-server-files.json +340 -0
- package/.next/routes-manifest.json +405 -0
- package/.next/server/app/_global-error/page.js +32 -0
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_global-error.html +1 -0
- package/.next/server/app/_global-error.meta +16 -0
- package/.next/server/app/_global-error.rsc +14 -0
- package/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
- package/.next/server/app/_not-found/page.js +2 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_not-found.html +1 -0
- package/.next/server/app/_not-found.meta +16 -0
- package/.next/server/app/_not-found.rsc +20 -0
- package/.next/server/app/_not-found.segments/_full.segment.rsc +20 -0
- package/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
- package/.next/server/app/_not-found.segments/_index.segment.rsc +7 -0
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +5 -0
- package/.next/server/app/api/about/route.js +1 -0
- package/.next/server/app/api/about/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -0
- package/.next/server/app/api/agent/[id]/bash-output/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/[id]/events/route.js +3 -0
- package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/[id]/route.js +1 -0
- package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/new/route.js +1 -0
- package/.next/server/app/api/agent/new/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/running/events/route.js +3 -0
- package/.next/server/app/api/agent/running/events/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent/running/route.js +1 -0
- package/.next/server/app/api/agent/running/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/agent-settings/route.js +2 -0
- package/.next/server/app/api/agent-settings/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/attachments/route.js +1 -0
- package/.next/server/app/api/attachments/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/all-providers/route.js +1 -0
- package/.next/server/app/api/auth/all-providers/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -0
- package/.next/server/app/api/auth/api-key/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/login/[provider]/route.js +3 -0
- package/.next/server/app/api/auth/login/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -0
- package/.next/server/app/api/auth/logout/[provider]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/providers/route.js +1 -0
- package/.next/server/app/api/auth/providers/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/auth/ui-session/route.js +1 -0
- package/.next/server/app/api/auth/ui-session/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/cwd/browse/route.js +1 -0
- package/.next/server/app/api/cwd/browse/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/cwd/validate/route.js +1 -0
- package/.next/server/app/api/cwd/validate/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/default-cwd/route.js +1 -0
- package/.next/server/app/api/default-cwd/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/file-index/route.js +1 -0
- package/.next/server/app/api/file-index/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/files/[...path]/route.js +49 -0
- package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/git/diff/route.js +1 -0
- package/.next/server/app/api/git/diff/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/git/status/route.js +1 -0
- package/.next/server/app/api/git/status/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/home/route.js +1 -0
- package/.next/server/app/api/home/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models/route.js +1 -0
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/route.js +1 -0
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/models-config/test/route.js +1 -0
- package/.next/server/app/api/models-config/test/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/plugins/route.js +2 -0
- package/.next/server/app/api/plugins/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/runtime/route.js +1 -0
- package/.next/server/app/api/runtime/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/runtime/switch/route.js +1 -0
- package/.next/server/app/api/runtime/switch/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/archive/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/archive/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +11 -0
- package/.next/server/app/api/sessions/[id]/auto-name/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/command-entry/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/command-entry/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/export/route.js +67 -0
- package/.next/server/app/api/sessions/[id]/export/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/info/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/info/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/state/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/[id]/tool-results/[toolCallId]/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/tool-results/[toolCallId]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/route.js +1 -0
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/search/route.js +26 -0
- package/.next/server/app/api/sessions/search/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/check/route.js +1 -0
- package/.next/server/app/api/skills/check/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/install/route.js +1 -0
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/route.js +2 -0
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/search/route.js +1 -0
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/skills/update/route.js +1 -0
- package/.next/server/app/api/skills/update/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/subagent-runs/route.js +1 -0
- package/.next/server/app/api/subagent-runs/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/worktrees/route.js +1 -0
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -0
- package/.next/server/app/icon.png/route.js +1 -0
- package/.next/server/app/icon.png.body +0 -0
- package/.next/server/app/icon.png.meta +1 -0
- package/.next/server/app/index.html +1 -0
- package/.next/server/app/index.meta +14 -0
- package/.next/server/app/index.rsc +20 -0
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +7 -0
- package/.next/server/app/index.segments/_full.segment.rsc +20 -0
- package/.next/server/app/index.segments/_head.segment.rsc +6 -0
- package/.next/server/app/index.segments/_index.segment.rsc +7 -0
- package/.next/server/app/index.segments/_tree.segment.rsc +5 -0
- package/.next/server/app/page.js +26 -0
- package/.next/server/app/page_client-reference-manifest.js +1 -0
- package/.next/server/app-paths-manifest.json +54 -0
- package/.next/server/chunks/1069.js +23 -0
- package/.next/server/chunks/1089.js +1 -0
- package/.next/server/chunks/1130.js +79 -0
- package/.next/server/chunks/1207.js +36 -0
- package/.next/server/chunks/1515.js +1 -0
- package/.next/server/chunks/1570.js +24 -0
- package/.next/server/chunks/1605.js +1 -0
- package/.next/server/chunks/1707.js +93 -0
- package/.next/server/chunks/1734.js +1 -0
- package/.next/server/chunks/1792.js +38 -0
- package/.next/server/chunks/1813.js +1 -0
- package/.next/server/chunks/188.js +1 -0
- package/.next/server/chunks/1965.js +8 -0
- package/.next/server/chunks/2018.js +148 -0
- package/.next/server/chunks/2106.js +1 -0
- package/.next/server/chunks/2155.js +34 -0
- package/.next/server/chunks/2185.js +5 -0
- package/.next/server/chunks/2190.js +1 -0
- package/.next/server/chunks/2325.js +82 -0
- package/.next/server/chunks/2349.js +1 -0
- package/.next/server/chunks/2394.js +1 -0
- package/.next/server/chunks/2537.js +1 -0
- package/.next/server/chunks/2744.js +1 -0
- package/.next/server/chunks/2815.js +1 -0
- package/.next/server/chunks/2817.js +17 -0
- package/.next/server/chunks/2871.js +8 -0
- package/.next/server/chunks/2903.js +1 -0
- package/.next/server/chunks/3115.js +4 -0
- package/.next/server/chunks/319.js +45 -0
- package/.next/server/chunks/3252.js +115 -0
- package/.next/server/chunks/3379.js +1 -0
- package/.next/server/chunks/3504.js +1 -0
- package/.next/server/chunks/3533.js +1293 -0
- package/.next/server/chunks/3603.js +1 -0
- package/.next/server/chunks/3757.js +1 -0
- package/.next/server/chunks/3770.js +1 -0
- package/.next/server/chunks/3776.js +1 -0
- package/.next/server/chunks/3894.js +1 -0
- package/.next/server/chunks/3960.js +1 -0
- package/.next/server/chunks/4030.js +86 -0
- package/.next/server/chunks/4188.js +1 -0
- package/.next/server/chunks/4286.js +1 -0
- package/.next/server/chunks/4309.js +1 -0
- package/.next/server/chunks/4338.js +64 -0
- package/.next/server/chunks/4367.js +1 -0
- package/.next/server/chunks/4372.js +1 -0
- package/.next/server/chunks/4424.js +215 -0
- package/.next/server/chunks/443.js +32 -0
- package/.next/server/chunks/4485.js +1 -0
- package/.next/server/chunks/46.js +62 -0
- package/.next/server/chunks/4674.js +1 -0
- package/.next/server/chunks/4741.js +20 -0
- package/.next/server/chunks/4742.js +80 -0
- package/.next/server/chunks/4796.js +104 -0
- package/.next/server/chunks/4980.js +1 -0
- package/.next/server/chunks/5029.js +1 -0
- package/.next/server/chunks/5198.js +90 -0
- package/.next/server/chunks/5318.js +1 -0
- package/.next/server/chunks/5319.js +1 -0
- package/.next/server/chunks/5461.js +1 -0
- package/.next/server/chunks/5598.js +1 -0
- package/.next/server/chunks/5627.js +1 -0
- package/.next/server/chunks/6192.js +6 -0
- package/.next/server/chunks/6219.js +41 -0
- package/.next/server/chunks/6337.js +1 -0
- package/.next/server/chunks/6454.js +28 -0
- package/.next/server/chunks/6476.js +27 -0
- package/.next/server/chunks/6509.js +153 -0
- package/.next/server/chunks/6949.js +1 -0
- package/.next/server/chunks/6953.js +1 -0
- package/.next/server/chunks/703.js +1 -0
- package/.next/server/chunks/7075.js +1 -0
- package/.next/server/chunks/7129.js +6 -0
- package/.next/server/chunks/7152.js +1 -0
- package/.next/server/chunks/7181.js +160 -0
- package/.next/server/chunks/7233.js +1 -0
- package/.next/server/chunks/7307.js +1 -0
- package/.next/server/chunks/7434.js +77 -0
- package/.next/server/chunks/7527.js +1 -0
- package/.next/server/chunks/7561.js +1 -0
- package/.next/server/chunks/7872.js +1 -0
- package/.next/server/chunks/7914.js +226 -0
- package/.next/server/chunks/8213.js +1 -0
- package/.next/server/chunks/8267.js +24 -0
- package/.next/server/chunks/8294.js +1 -0
- package/.next/server/chunks/835.js +1 -0
- package/.next/server/chunks/8645.js +141 -0
- package/.next/server/chunks/8875.js +2 -0
- package/.next/server/chunks/9071.js +1 -0
- package/.next/server/chunks/9081.js +1 -0
- package/.next/server/chunks/9169.js +1 -0
- package/.next/server/chunks/9280.js +255 -0
- package/.next/server/chunks/940.js +287 -0
- package/.next/server/chunks/9486.js +1 -0
- package/.next/server/chunks/9509.js +1 -0
- package/.next/server/chunks/951.js +8 -0
- package/.next/server/chunks/9784.js +2 -0
- package/.next/server/chunks/981.js +2 -0
- package/.next/server/chunks/9874.js +1 -0
- package/.next/server/chunks/9883.js +2 -0
- package/.next/server/functions-config-manifest.json +21 -0
- package/.next/server/instrumentation.js +1 -0
- package/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/.next/server/middleware.js +18 -0
- package/.next/server/next-font-manifest.json +1 -0
- package/.next/server/pages/404.html +1 -0
- package/.next/server/pages/500.html +1 -0
- package/.next/server/pages-manifest.json +4 -0
- package/.next/server/prefetch-hints.json +1 -0
- package/.next/server/server-reference-manifest.js +1 -0
- package/.next/server/server-reference-manifest.json +1 -0
- package/.next/server/webpack-runtime.js +1 -0
- package/.next/static/M5hSQWk4seDK1NGMqmgGY/_buildManifest.js +1 -0
- package/.next/static/M5hSQWk4seDK1NGMqmgGY/_ssgManifest.js +1 -0
- package/.next/static/chunks/050357b0.986bc6597f184c3b.js +62 -0
- package/.next/static/chunks/1212.c32f02f461182c5b.js +226 -0
- package/.next/static/chunks/127.394be8b7a579a747.js +8 -0
- package/.next/static/chunks/1327.09252bb80616cc3a.js +1 -0
- package/.next/static/chunks/1377.e883e13864574c26.js +36 -0
- package/.next/static/chunks/1390.3e7d84d187924556.js +104 -0
- package/.next/static/chunks/1438.d742ea00e0f072ca.js +27 -0
- package/.next/static/chunks/1474.605367a77b6161a0.js +115 -0
- package/.next/static/chunks/1576.93e0666990c12243.js +38 -0
- package/.next/static/chunks/1951.4b73bf47740c2bfb.js +160 -0
- package/.next/static/chunks/2081.47b6e9391094055f.js +1 -0
- package/.next/static/chunks/2178.2adcd2b51553bd50.js +1 -0
- package/.next/static/chunks/2217.4bf1455eb89bdd9b.js +1 -0
- package/.next/static/chunks/2325.23caf22075e51aa5.js +1 -0
- package/.next/static/chunks/2356.52627097a8b56ec1.js +1 -0
- package/.next/static/chunks/2418.b5d9e177e10a686e.js +1 -0
- package/.next/static/chunks/249.973d23a3940a5fc9.js +1 -0
- package/.next/static/chunks/2554.ca4cb2f8bc69f32e.js +86 -0
- package/.next/static/chunks/2566.505384571dedf726.js +79 -0
- package/.next/static/chunks/2646.c653cac657d7b035.js +215 -0
- package/.next/static/chunks/2784.3d8e0d20edb71dcd.js +64 -0
- package/.next/static/chunks/2821.934bcf60fbdc28c6.js +1 -0
- package/.next/static/chunks/2847.b66f6d92e4f5e495.js +23 -0
- package/.next/static/chunks/2866.4ecb766127917d99.js +1 -0
- package/.next/static/chunks/28f0fb3b.5f2b0099c24fbe32.js +122 -0
- package/.next/static/chunks/3308.23eadd1744bb967c.js +73 -0
- package/.next/static/chunks/3316.5c51b238308a838b.js +34 -0
- package/.next/static/chunks/3341.6042c7cb7225d88d.js +41 -0
- package/.next/static/chunks/339.1a094bb1c6eaf9dc.js +1 -0
- package/.next/static/chunks/370.57cfa27da8567918.js +1 -0
- package/.next/static/chunks/3708.81252290870c8487.js +1 -0
- package/.next/static/chunks/3794-907785a527d8128b.js +32 -0
- package/.next/static/chunks/3832.5d713641634c65b5.js +24 -0
- package/.next/static/chunks/4368.e43e952c5535cba6.js +80 -0
- package/.next/static/chunks/4424.fd0c93a807a333e1.js +1 -0
- package/.next/static/chunks/4866.d1060b4faf2ae1e2.js +1 -0
- package/.next/static/chunks/4bd1b696-e356ca5ba0218e27.js +1 -0
- package/.next/static/chunks/5020.9ac8d0dc8390bb6e.js +1 -0
- package/.next/static/chunks/5166.7d3648847337fe52.js +62 -0
- package/.next/static/chunks/5242.7b643c6b3394cac1.js +1 -0
- package/.next/static/chunks/5361.afc00ab2626bacbf.js +1 -0
- package/.next/static/chunks/5460.0337c14f29b9ff9a.js +90 -0
- package/.next/static/chunks/5521.cfdf2cfc6db31407.js +1 -0
- package/.next/static/chunks/5531-66b1a21ff1c52081.js +1 -0
- package/.next/static/chunks/5715.048f1bae2c41fa89.js +1 -0
- package/.next/static/chunks/6121.5b8cb3199531d194.js +1 -0
- package/.next/static/chunks/6294.24f510c0c3e3714c.js +1 -0
- package/.next/static/chunks/6467.b354ed428e3bef01.js +5 -0
- package/.next/static/chunks/66d203d7.3e90bc8f1f096a8e.js +153 -0
- package/.next/static/chunks/6787.a15de946178e8ef7.js +1 -0
- package/.next/static/chunks/7176.2979806e91c0df29.js +1 -0
- package/.next/static/chunks/7256.e07cf52d87d40252.js +1 -0
- package/.next/static/chunks/7543.89f7b805ed0f2901.js +1 -0
- package/.next/static/chunks/776.fe8e64ab3669a915.js +287 -0
- package/.next/static/chunks/8118.f905a690db2b859b.js +148 -0
- package/.next/static/chunks/8233.a465d18b04719c6d.js +141 -0
- package/.next/static/chunks/8249.7a48897e80a16391.js +1 -0
- package/.next/static/chunks/8365.dc22e1ff76d04a3b.js +93 -0
- package/.next/static/chunks/8498.1083c36ddbbedd69.js +1 -0
- package/.next/static/chunks/8511.c7c064a8f58f1355.js +1 -0
- package/.next/static/chunks/869.7152372b662e31af.js +1 -0
- package/.next/static/chunks/8782.9ab86081b5661687.js +77 -0
- package/.next/static/chunks/8863.fa0320ea586efb3b.js +1 -0
- package/.next/static/chunks/8953.e5e7399c7952a1ff.js +1 -0
- package/.next/static/chunks/90542734.b75ad0df50bf68f5.js +1 -0
- package/.next/static/chunks/9165.02dc1f4804b94791.js +24 -0
- package/.next/static/chunks/934.9006461bd0548660.js +1 -0
- package/.next/static/chunks/9522.c7c6e9c330f9ba6b.js +1 -0
- package/.next/static/chunks/9667.f6918525b31688b4.js +1 -0
- package/.next/static/chunks/9705.40a82b97f214e28b.js +1 -0
- package/.next/static/chunks/9780-509b4d1bec6b6e17.js +1 -0
- package/.next/static/chunks/9793.4567af813117ad25.js +1 -0
- package/.next/static/chunks/app/_global-error/page-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/_not-found/page-32c24c2d341ba407.js +1 -0
- package/.next/static/chunks/app/api/about/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent/running/events/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent/running/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/agent-settings/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/attachments/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/auth/all-providers/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/auth/ui-session/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/cwd/browse/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/cwd/validate/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/file-index/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/git/diff/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/git/status/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/home/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/models/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/models-config/test/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/plugins/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/runtime/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/runtime/switch/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/archive/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/command-entry/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/export/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/info/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/state/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/tool-results/[toolCallId]/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/sessions/search/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/skills/check/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/skills/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/skills/update/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/subagent-runs/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/app/layout-88764b4be2728d3f.js +1 -0
- package/.next/static/chunks/app/page-f1ebfa55dc4bd91c.js +25 -0
- package/.next/static/chunks/d2c09beb.4f5ff7197b5bbbea.js +1 -0
- package/.next/static/chunks/d3ac728e-7964f816a1ca64e5.js +1 -0
- package/.next/static/chunks/da12927c.00775c0e4542fd3e.js +82 -0
- package/.next/static/chunks/framework-711ef29bc66f648c.js +1 -0
- package/.next/static/chunks/main-8e7ef001ea9dd641.js +5 -0
- package/.next/static/chunks/main-app-06b2b50b226e40d1.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-f351187b7f546530.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-451d6ba79f90a9c4.js +1 -0
- package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/.next/static/chunks/webpack-9f5e68be126b5e81.js +1 -0
- package/.next/static/css/88714c00e109ce28.css +1 -0
- package/.next/static/css/edecf7d5ab33f0fd.css +1 -0
- package/.next/static/media/15605e25b523335c-s.woff2 +0 -0
- package/.next/static/media/1a3dce5cfb5f7760-s.woff2 +0 -0
- package/.next/static/media/1cdd02902f937a18-s.woff2 +0 -0
- package/.next/static/media/4c4b3b30b6bcb2be-s.woff2 +0 -0
- package/.next/static/media/641a7b8a5800ee0e-s.woff2 +0 -0
- package/.next/static/media/7deddc85b7ffd1dc-s.p.woff2 +0 -0
- package/.next/static/media/KaTeX_AMS-Regular.1608a09b.woff +0 -0
- package/.next/static/media/KaTeX_AMS-Regular.4aafdb68.ttf +0 -0
- package/.next/static/media/KaTeX_AMS-Regular.a79f1c31.woff2 +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Bold.b6770918.woff +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Bold.cce5b8ec.ttf +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Bold.ec17d132.woff2 +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Regular.07ef19e7.ttf +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Regular.55fac258.woff2 +0 -0
- package/.next/static/media/KaTeX_Caligraphic-Regular.dad44a7f.woff +0 -0
- package/.next/static/media/KaTeX_Fraktur-Bold.9f256b85.woff +0 -0
- package/.next/static/media/KaTeX_Fraktur-Bold.b18f59e1.ttf +0 -0
- package/.next/static/media/KaTeX_Fraktur-Bold.d42a5579.woff2 +0 -0
- package/.next/static/media/KaTeX_Fraktur-Regular.7c187121.woff +0 -0
- package/.next/static/media/KaTeX_Fraktur-Regular.d3c882a6.woff2 +0 -0
- package/.next/static/media/KaTeX_Fraktur-Regular.ed38e79f.ttf +0 -0
- package/.next/static/media/KaTeX_Main-Bold.b74a1a8b.ttf +0 -0
- package/.next/static/media/KaTeX_Main-Bold.c3fb5ac2.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-Bold.d181c465.woff +0 -0
- package/.next/static/media/KaTeX_Main-BoldItalic.6f2bb1df.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-BoldItalic.70d8b0a5.ttf +0 -0
- package/.next/static/media/KaTeX_Main-BoldItalic.e3f82f9d.woff +0 -0
- package/.next/static/media/KaTeX_Main-Italic.47373d1e.ttf +0 -0
- package/.next/static/media/KaTeX_Main-Italic.8916142b.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-Italic.9024d815.woff +0 -0
- package/.next/static/media/KaTeX_Main-Regular.0462f03b.woff2 +0 -0
- package/.next/static/media/KaTeX_Main-Regular.7f51fe03.woff +0 -0
- package/.next/static/media/KaTeX_Main-Regular.b7f8fe9b.ttf +0 -0
- package/.next/static/media/KaTeX_Math-BoldItalic.572d331f.woff2 +0 -0
- package/.next/static/media/KaTeX_Math-BoldItalic.a879cf83.ttf +0 -0
- package/.next/static/media/KaTeX_Math-BoldItalic.f1035d8d.woff +0 -0
- package/.next/static/media/KaTeX_Math-Italic.5295ba48.woff +0 -0
- package/.next/static/media/KaTeX_Math-Italic.939bc644.ttf +0 -0
- package/.next/static/media/KaTeX_Math-Italic.f28c23ac.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Bold.8c5b5494.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Bold.94e1e8dc.ttf +0 -0
- package/.next/static/media/KaTeX_SansSerif-Bold.bf59d231.woff +0 -0
- package/.next/static/media/KaTeX_SansSerif-Italic.3b1e59b3.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Italic.7c9bc82b.woff +0 -0
- package/.next/static/media/KaTeX_SansSerif-Italic.b4c20c84.ttf +0 -0
- package/.next/static/media/KaTeX_SansSerif-Regular.74048478.woff +0 -0
- package/.next/static/media/KaTeX_SansSerif-Regular.ba21ed5f.woff2 +0 -0
- package/.next/static/media/KaTeX_SansSerif-Regular.d4d7ba48.ttf +0 -0
- package/.next/static/media/KaTeX_Script-Regular.03e9641d.woff2 +0 -0
- package/.next/static/media/KaTeX_Script-Regular.07505710.woff +0 -0
- package/.next/static/media/KaTeX_Script-Regular.fe9cbbe1.ttf +0 -0
- package/.next/static/media/KaTeX_Size1-Regular.e1e279cb.woff +0 -0
- package/.next/static/media/KaTeX_Size1-Regular.eae34984.woff2 +0 -0
- package/.next/static/media/KaTeX_Size1-Regular.fabc004a.ttf +0 -0
- package/.next/static/media/KaTeX_Size2-Regular.57727022.woff +0 -0
- package/.next/static/media/KaTeX_Size2-Regular.5916a24f.woff2 +0 -0
- package/.next/static/media/KaTeX_Size2-Regular.d6b476ec.ttf +0 -0
- package/.next/static/media/KaTeX_Size3-Regular.9acaf01c.woff +0 -0
- package/.next/static/media/KaTeX_Size3-Regular.a144ef58.ttf +0 -0
- package/.next/static/media/KaTeX_Size3-Regular.b4230e7e.woff2 +0 -0
- package/.next/static/media/KaTeX_Size4-Regular.10d95fd3.woff2 +0 -0
- package/.next/static/media/KaTeX_Size4-Regular.7a996c9d.woff +0 -0
- package/.next/static/media/KaTeX_Size4-Regular.fbccdabe.ttf +0 -0
- package/.next/static/media/KaTeX_Typewriter-Regular.6258592b.woff +0 -0
- package/.next/static/media/KaTeX_Typewriter-Regular.a8709e36.woff2 +0 -0
- package/.next/static/media/KaTeX_Typewriter-Regular.d97aaf4a.ttf +0 -0
- package/.next/static/media/ec14413c594b3356-s.p.woff2 +0 -0
- package/LICENSE +22 -0
- package/README.en.md +151 -0
- package/README.md +151 -0
- package/README.zh-CN.md +182 -0
- package/bin/pidance-auth-gate.js +44 -0
- package/bin/pidance-options.js +34 -0
- package/bin/pidance.js +95 -0
- package/package.json +92 -0
- package/public/brand/pidance-banner.svg +45 -0
- package/public/brand/pidance-icon.svg +32 -0
- package/public/brand/pidance-logo.png +0 -0
- package/public/brand/pidance-mark-dark.svg +18 -0
- package/public/brand/pidance-mark-light.svg +18 -0
- package/public/brand/pidance-mark.png +0 -0
- package/public/brand/pidance-preview.svg +279 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
exports.id=2817,exports.ids=[2817],exports.modules={1486:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.USER_AGENT=b.PRODUCT_NAME=b.pkg=void 0;let d=c(59968);b.pkg=d;let e="google-api-nodejs-client";b.PRODUCT_NAME=e,b.USER_AGENT=`${e}/${d.version}`},3817:function(a,b,c){var d;!function(e){"use strict";var f,g=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,h=Math.ceil,i=Math.floor,j="[BigNumber Error] ",k=j+"Number primitive has more than 15 significant digits: ",l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13];function m(a){var b=0|a;return a>0||a===b?b:b-1}function n(a){for(var b,c,d=1,e=a.length,f=a[0]+"";d<e;){for(c=14-(b=a[d++]+"").length;c--;b="0"+b);f+=b}for(e=f.length;48===f.charCodeAt(--e););return f.slice(0,e+1||1)}function o(a,b){var c,d,e=a.c,f=b.c,g=a.s,h=b.s,i=a.e,j=b.e;if(!g||!h)return null;if(c=e&&!e[0],d=f&&!f[0],c||d)return c?d?0:-h:g;if(g!=h)return g;if(c=g<0,d=i==j,!e||!f)return d?0:!e^c?1:-1;if(!d)return i>j^c?1:-1;for(g=0,h=(i=e.length)<(j=f.length)?i:j;g<h;g++)if(e[g]!=f[g])return e[g]>f[g]^c?1:-1;return i==j?0:i>j^c?1:-1}function p(a,b,c,d){if(a<b||a>c||a!==i(a))throw Error(j+(d||"Argument")+("number"==typeof a?a<b||a>c?" out of range: ":" not an integer: ":" not a primitive number: ")+String(a))}function q(a){var b=a.c.length-1;return m(a.e/14)==b&&a.c[b]%2!=0}function r(a,b){return(a.length>1?a.charAt(0)+"."+a.slice(1):a)+(b<0?"e":"e+")+b}function s(a,b,c){var d,e;if(b<0){for(e=c+".";++b;e+=c);a=e+a}else if(d=a.length,++b>d){for(e=c,b-=d;--b;e+=c);a+=e}else b<d&&(a=a.slice(0,b)+"."+a.slice(b));return a}(f=function a(b){var c,d,e,f,t,u,v,w,x,y=M.prototype={constructor:M,toString:null,valueOf:null},z=new M(1),A=20,B=4,C=-7,D=21,E=-1e7,F=1e7,G=!1,H=1,I=0,J={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xa0",suffix:""},K="0123456789abcdefghijklmnopqrstuvwxyz",L=!0;function M(a,b){var c,d,e,f,h,j,l,m,n=this;if(!(n instanceof M))return new M(a,b);if(null==b){if(a&&!0===a._isBigNumber){n.s=a.s,!a.c||a.e>F?n.c=n.e=null:a.e<E?n.c=[n.e=0]:(n.e=a.e,n.c=a.c.slice());return}if((j="number"==typeof a)&&0*a==0){if(n.s=1/a<0?(a=-a,-1):1,a===~~a){for(f=0,h=a;h>=10;h/=10,f++);f>F?n.c=n.e=null:(n.e=f,n.c=[a]);return}m=String(a)}else{if(!g.test(m=String(a)))return x(n,m,j);n.s=45==m.charCodeAt(0)?(m=m.slice(1),-1):1}(f=m.indexOf("."))>-1&&(m=m.replace(".","")),(h=m.search(/e/i))>0?(f<0&&(f=h),f+=+m.slice(h+1),m=m.substring(0,h)):f<0&&(f=m.length)}else{if(p(b,2,K.length,"Base"),10==b&&L)return Q(n=new M(a),A+n.e+1,B);if(m=String(a),j="number"==typeof a){if(0*a!=0)return x(n,m,j,b);if(n.s=1/a<0?(m=m.slice(1),-1):1,M.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(k+a)}else n.s=45===m.charCodeAt(0)?(m=m.slice(1),-1):1;for(c=K.slice(0,b),f=h=0,l=m.length;h<l;h++)if(0>c.indexOf(d=m.charAt(h))){if("."==d){if(h>f){f=l;continue}}else if(!e&&(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase()))){e=!0,h=-1,f=0;continue}return x(n,String(a),j,b)}j=!1,(f=(m=w(m,b,10,n.s)).indexOf("."))>-1?m=m.replace(".",""):f=m.length}for(h=0;48===m.charCodeAt(h);h++);for(l=m.length;48===m.charCodeAt(--l););if(m=m.slice(h,++l)){if(l-=h,j&&M.DEBUG&&l>15&&(a>0x1fffffffffffff||a!==i(a)))throw Error(k+n.s*a);if((f=f-h-1)>F)n.c=n.e=null;else if(f<E)n.c=[n.e=0];else{if(n.e=f,n.c=[],h=(f+1)%14,f<0&&(h+=14),h<l){for(h&&n.c.push(+m.slice(0,h)),l-=14;h<l;)n.c.push(+m.slice(h,h+=14));h=14-(m=m.slice(h)).length}else h-=l;for(;h--;m+="0");n.c.push(+m)}}else n.c=[n.e=0]}function N(a,b,c,d){var e,f,g,h,i;if(null==c?c=B:p(c,0,8),!a.c)return a.toString();if(e=a.c[0],g=a.e,null==b)i=n(a.c),i=1==d||2==d&&(g<=C||g>=D)?r(i,g):s(i,g,"0");else if(f=(a=Q(new M(a),b,c)).e,h=(i=n(a.c)).length,1==d||2==d&&(b<=f||f<=C)){for(;h<b;i+="0",h++);i=r(i,f)}else if(b-=g+(2===d&&f>g),i=s(i,f,"0"),f+1>h){if(--b>0)for(i+=".";b--;i+="0");}else if((b+=f-h)>0)for(f+1==h&&(i+=".");b--;i+="0");return a.s<0&&e?"-"+i:i}function O(a,b){for(var c,d,e=1,f=new M(a[0]);e<a.length;e++)(d=new M(a[e])).s&&(c=o(f,d))!==b&&(0!==c||f.s!==b)||(f=d);return f}function P(a,b,c){for(var d=1,e=b.length;!b[--e];b.pop());for(e=b[0];e>=10;e/=10,d++);return(c=d+14*c-1)>F?a.c=a.e=null:c<E?a.c=[a.e=0]:(a.e=c,a.c=b),a}function Q(a,b,c,d){var e,f,g,j,k,m,n,o=a.c;if(o){a:{for(e=1,j=o[0];j>=10;j/=10,e++);if((f=b-e)<0)f+=14,g=b,n=i((k=o[m=0])/l[e-g-1]%10);else if((m=h((f+1)/14))>=o.length)if(d){for(;o.length<=m;o.push(0));k=n=0,e=1,f%=14,g=f-14+1}else break a;else{for(e=1,k=j=o[m];j>=10;j/=10,e++);f%=14,n=(g=f-14+e)<0?0:i(k/l[e-g-1]%10)}if(d=d||b<0||null!=o[m+1]||(g<0?k:k%l[e-g-1]),d=c<4?(n||d)&&(0==c||c==(a.s<0?3:2)):n>5||5==n&&(4==c||d||6==c&&(f>0?g>0?k/l[e-g]:0:o[m-1])%10&1||c==(a.s<0?8:7)),b<1||!o[0])return o.length=0,d?(b-=a.e+1,o[0]=l[(14-b%14)%14],a.e=-b||0):o[0]=a.e=0,a;if(0==f?(o.length=m,j=1,m--):(o.length=m+1,j=l[14-f],o[m]=g>0?i(k/l[e-g]%l[g])*j:0),d)for(;;)if(0==m){for(f=1,g=o[0];g>=10;g/=10,f++);for(g=o[0]+=j,j=1;g>=10;g/=10,j++);f!=j&&(a.e++,1e14==o[0]&&(o[0]=1));break}else{if(o[m]+=j,1e14!=o[m])break;o[m--]=0,j=1}for(f=o.length;0===o[--f];o.pop());}a.e>F?a.c=a.e=null:a.e<E&&(a.c=[a.e=0])}return a}function R(a){var b,c=a.e;return null===c?a.toString():(b=n(a.c),b=c<=C||c>=D?r(b,c):s(b,c,"0"),a.s<0?"-"+b:b)}return M.clone=a,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(a){var b,c;if(null!=a)if("object"==typeof a){if(a.hasOwnProperty(b="DECIMAL_PLACES")&&(p(c=a[b],0,1e9,b),A=c),a.hasOwnProperty(b="ROUNDING_MODE")&&(p(c=a[b],0,8,b),B=c),a.hasOwnProperty(b="EXPONENTIAL_AT")&&((c=a[b])&&c.pop?(p(c[0],-1e9,0,b),p(c[1],0,1e9,b),C=c[0],D=c[1]):(p(c,-1e9,1e9,b),C=-(D=c<0?-c:c))),a.hasOwnProperty(b="RANGE"))if((c=a[b])&&c.pop)p(c[0],-1e9,-1,b),p(c[1],1,1e9,b),E=c[0],F=c[1];else if(p(c,-1e9,1e9,b),c)E=-(F=c<0?-c:c);else throw Error(j+b+" cannot be zero: "+c);if(a.hasOwnProperty(b="CRYPTO"))if(!!(c=a[b])===c)if(c)if("u">typeof crypto&&crypto&&(crypto.getRandomValues||crypto.randomBytes))G=c;else throw G=!c,Error(j+"crypto unavailable");else G=c;else throw Error(j+b+" not true or false: "+c);if(a.hasOwnProperty(b="MODULO_MODE")&&(p(c=a[b],0,9,b),H=c),a.hasOwnProperty(b="POW_PRECISION")&&(p(c=a[b],0,1e9,b),I=c),a.hasOwnProperty(b="FORMAT"))if("object"==typeof(c=a[b]))J=c;else throw Error(j+b+" not an object: "+c);if(a.hasOwnProperty(b="ALPHABET")){if("string"!=typeof(c=a[b])||/^.?$|[+\-.\s]|(.).*\1/.test(c))throw Error(j+b+" invalid: "+c);L="0123456789"==c.slice(0,10),K=c}}else throw Error(j+"Object expected: "+a);return{DECIMAL_PLACES:A,ROUNDING_MODE:B,EXPONENTIAL_AT:[C,D],RANGE:[E,F],CRYPTO:G,MODULO_MODE:H,POW_PRECISION:I,FORMAT:J,ALPHABET:K}},M.isBigNumber=function(a){if(!a||!0!==a._isBigNumber)return!1;if(!M.DEBUG)return!0;var b,c,d=a.c,e=a.e,f=a.s;a:if("[object Array]"==({}).toString.call(d)){if((1===f||-1===f)&&e>=-1e9&&e<=1e9&&e===i(e)){if(0===d[0]){if(0===e&&1===d.length)return!0;break a}if((b=(e+1)%14)<1&&(b+=14),String(d[0]).length==b){for(b=0;b<d.length;b++)if((c=d[b])<0||c>=1e14||c!==i(c))break a;if(0!==c)return!0}}}else if(null===d&&null===e&&(null===f||1===f||-1===f))return!0;throw Error(j+"Invalid BigNumber: "+a)},M.maximum=M.max=function(){return O(arguments,-1)},M.minimum=M.min=function(){return O(arguments,1)},c=0x20000000000000*Math.random()&2097151?function(){return i(0x20000000000000*Math.random())}:function(){return(0x40000000*Math.random()|0)*8388608+(8388608*Math.random()|0)},M.random=function(a){var b,d,e,f,g,k=0,m=[],n=new M(z);if(null==a?a=A:p(a,0,1e9),f=h(a/14),G)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(f*=2));k<f;)(g=131072*b[k]+(b[k+1]>>>11))>=9e15?(d=crypto.getRandomValues(new Uint32Array(2)),b[k]=d[0],b[k+1]=d[1]):(m.push(g%1e14),k+=2);k=f/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(f*=7);k<f;)(g=(31&b[k])*0x1000000000000+0x10000000000*b[k+1]+0x100000000*b[k+2]+0x1000000*b[k+3]+(b[k+4]<<16)+(b[k+5]<<8)+b[k+6])>=9e15?crypto.randomBytes(7).copy(b,k):(m.push(g%1e14),k+=7);k=f/7}else throw G=!1,Error(j+"crypto unavailable");if(!G)for(;k<f;)(g=c())<9e15&&(m[k++]=g%1e14);for(f=m[--k],a%=14,f&&a&&(g=l[14-a],m[k]=i(f/g)*g);0===m[k];m.pop(),k--);if(k<0)m=[e=0];else{for(e=-1;0===m[0];m.splice(0,1),e-=14);for(k=1,g=m[0];g>=10;g/=10,k++);k<14&&(e-=14-k)}return n.e=e,n.c=m,n},M.sum=function(){for(var a=1,b=arguments,c=new M(b[0]);a<b.length;)c=c.plus(b[a++]);return c},w=function(){var a="0123456789";function b(a,b,c,d){for(var e,f,g=[0],h=0,i=a.length;h<i;){for(f=g.length;f--;g[f]*=b);for(g[0]+=d.indexOf(a.charAt(h++)),e=0;e<g.length;e++)g[e]>c-1&&(null==g[e+1]&&(g[e+1]=0),g[e+1]+=g[e]/c|0,g[e]%=c)}return g.reverse()}return function(c,d,e,f,g){var h,i,j,k,l,m,o,p,q=c.indexOf("."),r=A,t=B;for(q>=0&&(k=I,I=0,c=c.replace(".",""),m=(p=new M(d)).pow(c.length-q),I=k,p.c=b(s(n(m.c),m.e,"0"),10,e,a),p.e=p.c.length),j=k=(o=b(c,d,e,g?(h=K,a):(h=a,K))).length;0==o[--k];o.pop());if(!o[0])return h.charAt(0);if(q<0?--j:(m.c=o,m.e=j,m.s=f,o=(m=v(m,p,r,t,e)).c,l=m.r,j=m.e),q=o[i=j+r+1],k=e/2,l=l||i<0||null!=o[i+1],l=t<4?(null!=q||l)&&(0==t||t==(m.s<0?3:2)):q>k||q==k&&(4==t||l||6==t&&1&o[i-1]||t==(m.s<0?8:7)),i<1||!o[0])c=l?s(h.charAt(1),-r,h.charAt(0)):h.charAt(0);else{if(o.length=i,l)for(--e;++o[--i]>e;)o[i]=0,i||(++j,o=[1].concat(o));for(k=o.length;!o[--k];);for(q=0,c="";q<=k;c+=h.charAt(o[q++]));c=s(c,j,h.charAt(0))}return c}}(),v=function(){function a(a,b,c){var d,e,f,g,h=0,i=a.length,j=b%1e7,k=b/1e7|0;for(a=a.slice();i--;)d=k*(f=a[i]%1e7)+(g=a[i]/1e7|0)*j,h=((e=j*f+d%1e7*1e7+h)/c|0)+(d/1e7|0)+k*g,a[i]=e%c;return h&&(a=[h].concat(a)),a}function b(a,b,c,d){var e,f;if(c!=d)f=c>d?1:-1;else for(e=f=0;e<c;e++)if(a[e]!=b[e]){f=a[e]>b[e]?1:-1;break}return f}function c(a,b,c,d){for(var e=0;c--;)a[c]-=e,e=+(a[c]<b[c]),a[c]=e*d+a[c]-b[c];for(;!a[0]&&a.length>1;a.splice(0,1));}return function(d,e,f,g,h){var j,k,l,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=d.s==e.s?1:-1,C=d.c,D=e.c;if(!C||!C[0]||!D||!D[0])return new M(!d.s||!e.s||(C?D&&C[0]==D[0]:!D)?NaN:C&&0==C[0]||!D?0*B:B/0);for(s=(r=new M(B)).c=[],B=f+(k=d.e-e.e)+1,h||(h=1e14,k=m(d.e/14)-m(e.e/14),B=B/14|0),l=0;D[l]==(C[l]||0);l++);if(D[l]>(C[l]||0)&&k--,B<0)s.push(1),n=!0;else{for(x=C.length,z=D.length,l=0,B+=2,(o=i(h/(D[0]+1)))>1&&(D=a(D,o,h),C=a(C,o,h),z=D.length,x=C.length),w=z,u=(t=C.slice(0,z)).length;u<z;t[u++]=0);A=[0].concat(A=D.slice()),y=D[0],D[1]>=h/2&&y++;do{if(o=0,(j=b(D,t,z,u))<0){if(v=t[0],z!=u&&(v=v*h+(t[1]||0)),(o=i(v/y))>1)for(o>=h&&(o=h-1),q=(p=a(D,o,h)).length,u=t.length;1==b(p,t,q,u);)o--,c(p,z<q?A:D,q,h),q=p.length,j=1;else 0==o&&(j=o=1),q=(p=D.slice()).length;if(q<u&&(p=[0].concat(p)),c(t,p,u,h),u=t.length,-1==j)for(;1>b(D,t,z,u);)o++,c(t,z<u?A:D,u,h),u=t.length}else 0===j&&(o++,t=[0]);s[l++]=o,t[0]?t[u++]=C[w]||0:(t=[C[w]],u=1)}while((w++<x||null!=t[0])&&B--);n=null!=t[0],s[0]||s.splice(0,1)}if(1e14==h){for(l=1,B=s[0];B>=10;B/=10,l++);Q(r,f+(r.e=l+14*k-1)+1,g,n)}else r.e=k,r.r=+n;return r}}(),d=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,f=/^\.([^.]+)$/,t=/^-?(Infinity|NaN)$/,u=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(a,b,c,g){var h,i=c?b:b.replace(u,"");if(t.test(i))a.s=isNaN(i)?null:i<0?-1:1;else{if(!c&&(i=i.replace(d,function(a,b,c){return h="x"==(c=c.toLowerCase())?16:"b"==c?2:8,g&&g!=h?a:b}),g&&(h=g,i=i.replace(e,"$1").replace(f,"0.$1")),b!=i))return new M(i,h);if(M.DEBUG)throw Error(j+"Not a"+(g?" base "+g:"")+" number: "+b);a.s=null}a.c=a.e=null},y.absoluteValue=y.abs=function(){var a=new M(this);return a.s<0&&(a.s=1),a},y.comparedTo=function(a,b){return o(this,new M(a,b))},y.decimalPlaces=y.dp=function(a,b){var c,d,e;if(null!=a)return p(a,0,1e9),null==b?b=B:p(b,0,8),Q(new M(this),a+this.e+1,b);if(!(c=this.c))return null;if(d=((e=c.length-1)-m(this.e/14))*14,e=c[e])for(;e%10==0;e/=10,d--);return d<0&&(d=0),d},y.dividedBy=y.div=function(a,b){return v(this,new M(a,b),A,B)},y.dividedToIntegerBy=y.idiv=function(a,b){return v(this,new M(a,b),0,1)},y.exponentiatedBy=y.pow=function(a,b){var c,d,e,f,g,k,l,m,n,o=this;if((a=new M(a)).c&&!a.isInteger())throw Error(j+"Exponent not an integer: "+R(a));if(null!=b&&(b=new M(b)),k=a.e>14,!o.c||!o.c[0]||1==o.c[0]&&!o.e&&1==o.c.length||!a.c||!a.c[0])return n=new M(Math.pow(+R(o),k?a.s*(2-q(a)):+R(a))),b?n.mod(b):n;if(l=a.s<0,b){if(b.c?!b.c[0]:!b.s)return new M(NaN);(d=!l&&o.isInteger()&&b.isInteger())&&(o=o.mod(b))}else{if(a.e>9&&(o.e>0||o.e<-1||(0==o.e?o.c[0]>1||k&&o.c[1]>=24e7:o.c[0]<8e13||k&&o.c[0]<=9999975e7)))return f=o.s<0&&q(a)?-0:0,o.e>-1&&(f=1/f),new M(l?1/f:f);I&&(f=h(I/14+2))}for(k?(c=new M(.5),l&&(a.s=1),m=q(a)):m=(e=Math.abs(+R(a)))%2,n=new M(z);;){if(m){if(!(n=n.times(o)).c)break;f?n.c.length>f&&(n.c.length=f):d&&(n=n.mod(b))}if(e){if(0===(e=i(e/2)))break;m=e%2}else if(Q(a=a.times(c),a.e+1,1),a.e>14)m=q(a);else{if(0==(e=+R(a)))break;m=e%2}o=o.times(o),f?o.c&&o.c.length>f&&(o.c.length=f):d&&(o=o.mod(b))}return d?n:(l&&(n=z.div(n)),b?n.mod(b):f?Q(n,I,B,g):n)},y.integerValue=function(a){var b=new M(this);return null==a?a=B:p(a,0,8),Q(b,b.e+1,a)},y.isEqualTo=y.eq=function(a,b){return 0===o(this,new M(a,b))},y.isFinite=function(){return!!this.c},y.isGreaterThan=y.gt=function(a,b){return o(this,new M(a,b))>0},y.isGreaterThanOrEqualTo=y.gte=function(a,b){return 1===(b=o(this,new M(a,b)))||0===b},y.isInteger=function(){return!!this.c&&m(this.e/14)>this.c.length-2},y.isLessThan=y.lt=function(a,b){return 0>o(this,new M(a,b))},y.isLessThanOrEqualTo=y.lte=function(a,b){return -1===(b=o(this,new M(a,b)))||0===b},y.isNaN=function(){return!this.s},y.isNegative=function(){return this.s<0},y.isPositive=function(){return this.s>0},y.isZero=function(){return!!this.c&&0==this.c[0]},y.minus=function(a,b){var c,d,e,f,g=this.s;if(b=(a=new M(a,b)).s,!g||!b)return new M(NaN);if(g!=b)return a.s=-b,this.plus(a);var h=this.e/14,i=a.e/14,j=this.c,k=a.c;if(!h||!i){if(!j||!k)return j?(a.s=-b,a):new M(k?this:NaN);if(!j[0]||!k[0])return k[0]?(a.s=-b,a):new M(j[0]?this:3==B?-0:0)}if(h=m(h),i=m(i),j=j.slice(),g=h-i){for((f=g<0)?(g=-g,e=j):(i=h,e=k),e.reverse(),b=g;b--;e.push(0));e.reverse()}else for(d=(f=(g=j.length)<(b=k.length))?g:b,g=b=0;b<d;b++)if(j[b]!=k[b]){f=j[b]<k[b];break}if(f&&(e=j,j=k,k=e,a.s=-a.s),(b=(d=k.length)-(c=j.length))>0)for(;b--;j[c++]=0);for(b=1e14-1;d>g;){if(j[--d]<k[d]){for(c=d;c&&!j[--c];j[c]=b);--j[c],j[d]+=1e14}j[d]-=k[d]}for(;0==j[0];j.splice(0,1),--i);return j[0]?P(a,j,i):(a.s=3==B?-1:1,a.c=[a.e=0],a)},y.modulo=y.mod=function(a,b){var c,d;return(a=new M(a,b),this.c&&a.s&&(!a.c||a.c[0]))?a.c&&(!this.c||this.c[0])?(9==H?(d=a.s,a.s=1,c=v(this,a,0,3),a.s=d,c.s*=d):c=v(this,a,0,H),(a=this.minus(c.times(a))).c[0]||1!=H||(a.s=this.s),a):new M(this):new M(NaN)},y.multipliedBy=y.times=function(a,b){var c,d,e,f,g,h,i,j,k,l,n,o,p,q=this.c,r=(a=new M(a,b)).c;if(!q||!r||!q[0]||!r[0])return this.s&&a.s&&(!q||q[0]||r)&&(!r||r[0]||q)?(a.s*=this.s,q&&r?(a.c=[0],a.e=0):a.c=a.e=null):a.c=a.e=a.s=null,a;for(d=m(this.e/14)+m(a.e/14),a.s*=this.s,(i=q.length)<(l=r.length)&&(p=q,q=r,r=p,e=i,i=l,l=e),e=i+l,p=[];e--;p.push(0));for(e=l;--e>=0;){for(c=0,n=r[e]%1e7,o=r[e]/1e7|0,f=e+(g=i);f>e;)h=o*(j=q[--g]%1e7)+(k=q[g]/1e7|0)*n,c=((j=n*j+h%1e7*1e7+p[f]+c)/1e14|0)+(h/1e7|0)+o*k,p[f--]=j%1e14;p[f]=c}return c?++d:p.splice(0,1),P(a,p,d)},y.negated=function(){var a=new M(this);return a.s=-a.s||null,a},y.plus=function(a,b){var c,d=this.s;if(b=(a=new M(a,b)).s,!d||!b)return new M(NaN);if(d!=b)return a.s=-b,this.minus(a);var e=this.e/14,f=a.e/14,g=this.c,h=a.c;if(!e||!f){if(!g||!h)return new M(d/0);if(!g[0]||!h[0])return h[0]?a:new M(g[0]?this:0*d)}if(e=m(e),f=m(f),g=g.slice(),d=e-f){for(d>0?(f=e,c=h):(d=-d,c=g),c.reverse();d--;c.push(0));c.reverse()}for((d=g.length)-(b=h.length)<0&&(c=h,h=g,g=c,b=d),d=0;b;)d=(g[--b]=g[b]+h[b]+d)/1e14|0,g[b]=1e14===g[b]?0:g[b]%1e14;return d&&(g=[d].concat(g),++f),P(a,g,f)},y.precision=y.sd=function(a,b){var c,d,e;if(null!=a&&!!a!==a)return p(a,1,1e9),null==b?b=B:p(b,0,8),Q(new M(this),a,b);if(!(c=this.c))return null;if(d=14*(e=c.length-1)+1,e=c[e]){for(;e%10==0;e/=10,d--);for(e=c[0];e>=10;e/=10,d++);}return a&&this.e+1>d&&(d=this.e+1),d},y.shiftedBy=function(a){return p(a,-0x1fffffffffffff,0x1fffffffffffff),this.times("1e"+a)},y.squareRoot=y.sqrt=function(){var a,b,c,d,e,f=this.c,g=this.s,h=this.e,i=A+4,j=new M("0.5");if(1!==g||!f||!f[0])return new M(!g||g<0&&(!f||f[0])?NaN:f?this:1/0);if(0==(g=Math.sqrt(+R(this)))||g==1/0?(((b=n(f)).length+h)%2==0&&(b+="0"),g=Math.sqrt(+b),h=m((h+1)/2)-(h<0||h%2),c=new M(b=g==1/0?"5e"+h:(b=g.toExponential()).slice(0,b.indexOf("e")+1)+h)):c=new M(g+""),c.c[0]){for((g=(h=c.e)+i)<3&&(g=0);;)if(e=c,c=j.times(e.plus(v(this,e,i,1))),n(e.c).slice(0,g)===(b=n(c.c)).slice(0,g)){if(c.e<h&&--g,"9999"!=(b=b.slice(g-3,g+1))&&(d||"4999"!=b)){+b&&(+b.slice(1)||"5"!=b.charAt(0))||(Q(c,c.e+A+2,1),a=!c.times(c).eq(this));break}if(!d&&(Q(e,e.e+A+2,0),e.times(e).eq(this))){c=e;break}i+=4,g+=4,d=1}}return Q(c,c.e+A+1,B,a)},y.toExponential=function(a,b){return null!=a&&(p(a,0,1e9),a++),N(this,a,b,1)},y.toFixed=function(a,b){return null!=a&&(p(a,0,1e9),a=a+this.e+1),N(this,a,b)},y.toFormat=function(a,b,c){var d;if(null==c)null!=a&&b&&"object"==typeof b?(c=b,b=null):a&&"object"==typeof a?(c=a,a=b=null):c=J;else if("object"!=typeof c)throw Error(j+"Argument not an object: "+c);if(d=this.toFixed(a,b),this.c){var e,f=d.split("."),g=+c.groupSize,h=+c.secondaryGroupSize,i=c.groupSeparator||"",k=f[0],l=f[1],m=this.s<0,n=m?k.slice(1):k,o=n.length;if(h&&(e=g,g=h,h=e,o-=e),g>0&&o>0){for(e=o%g||g,k=n.substr(0,e);e<o;e+=g)k+=i+n.substr(e,g);h>0&&(k+=i+n.slice(e)),m&&(k="-"+k)}d=l?k+(c.decimalSeparator||"")+((h=+c.fractionGroupSize)?l.replace(RegExp("\\d{"+h+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):l):k}return(c.prefix||"")+d+(c.suffix||"")},y.toFraction=function(a){var b,c,d,e,f,g,h,i,k,m,o,p,q=this.c;if(null!=a&&(!(h=new M(a)).isInteger()&&(h.c||1!==h.s)||h.lt(z)))throw Error(j+"Argument "+(h.isInteger()?"out of range: ":"not an integer: ")+R(h));if(!q)return new M(this);for(b=new M(z),k=c=new M(z),d=i=new M(z),p=n(q),f=b.e=p.length-this.e-1,b.c[0]=l[(g=f%14)<0?14+g:g],a=!a||h.comparedTo(b)>0?f>0?b:k:h,g=F,F=1/0,h=new M(p),i.c[0]=0;m=v(h,b,0,1),1!=(e=c.plus(m.times(d))).comparedTo(a);)c=d,d=e,k=i.plus(m.times(e=k)),i=e,b=h.minus(m.times(e=b)),h=e;return e=v(a.minus(c),d,0,1),i=i.plus(e.times(k)),c=c.plus(e.times(d)),i.s=k.s=this.s,f*=2,o=1>v(k,d,f,B).minus(this).abs().comparedTo(v(i,c,f,B).minus(this).abs())?[k,d]:[i,c],F=g,o},y.toNumber=function(){return+R(this)},y.toPrecision=function(a,b){return null!=a&&p(a,1,1e9),N(this,a,b,2)},y.toString=function(a){var b,c=this,d=c.s,e=c.e;return null===e?d?(b="Infinity",d<0&&(b="-"+b)):b="NaN":(null==a?b=e<=C||e>=D?r(n(c.c),e):s(n(c.c),e,"0"):10===a&&L?b=s(n((c=Q(new M(c),A+e+1,B)).c),c.e,"0"):(p(a,2,K.length,"Base"),b=w(s(n(c.c),e,"0"),10,a,d,!0)),d<0&&c.c[0]&&(b="-"+b)),b},y.valueOf=y.toJSON=function(){return R(this)},y._isBigNumber=!0,null!=b&&M.set(b),M}()).default=f.BigNumber=f,void 0===(d=(function(){return f}).call(b,c,b,a))||(a.exports=d)}(0)},3939:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.AwsClient=void 0;let d=c(63133),e=c(64876),f=c(26107),g=c(90852),h=c(51596);class i extends e.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static #a="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(a){super(a);const b=(0,g.originalOrCamelOptions)(a),c=b.get("credential_source"),d=b.get("aws_security_credentials_supplier");if(!c&&!d)throw Error("A credential source or AWS security credentials supplier must be specified.");if(c&&d)throw Error("Only one of credential source or AWS security credentials supplier can be specified.");if(d)this.awsSecurityCredentialsSupplier=d,this.regionalCredVerificationUrl=i.#a,this.credentialSourceType="programmatic";else{const a=(0,g.originalOrCamelOptions)(c);this.environmentId=a.get("environment_id");const b=a.get("region_url"),d=a.get("url"),e=a.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new f.DefaultAwsSecurityCredentialsSupplier({regionUrl:b,securityCredentialsUrl:d,imdsV2SessionTokenUrl:e}),this.regionalCredVerificationUrl=a.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){let a=this.environmentId?.match(/^(aws)(\d+)$/);if(a&&this.regionalCredVerificationUrl){if(1!==parseInt(a[2],10))throw Error(`aws version "${a[2]}" is not supported in the current build.`)}else throw Error('No valid AWS "credential_source" provided')}async retrieveSubjectToken(){this.awsRequestSigner||(this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new d.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region));let a=await this.awsRequestSigner.getRequestOptions({...i.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),b=[];return h.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},a.headers).forEach((a,c)=>b.push({key:c,value:a})),encodeURIComponent(JSON.stringify({url:a.url,method:a.method,headers:b}))}}b.AwsClient=i},3969:(a,b,c)=>{"use strict";let{tokenChars:d}=c(45633);function e(a,b,c){void 0===a[b]?a[b]=[c]:a[b].push(c)}a.exports={format:function(a){return Object.keys(a).map(b=>{let c=a[b];return Array.isArray(c)||(c=[c]),c.map(a=>[b].concat(Object.keys(a).map(b=>{let c=a[b];return Array.isArray(c)||(c=[c]),c.map(a=>!0===a?b:`${b}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(a){let b,c,f=Object.create(null),g=Object.create(null),h=!1,i=!1,j=!1,k=-1,l=-1,m=-1,n=0;for(;n<a.length;n++)if(l=a.charCodeAt(n),void 0===b)if(-1===m&&1===d[l])-1===k&&(k=n);else if(0!==n&&(32===l||9===l))-1===m&&-1!==k&&(m=n);else if(59===l||44===l){if(-1===k)throw SyntaxError(`Unexpected character at index ${n}`);-1===m&&(m=n);let c=a.slice(k,m);44===l?(e(f,c,g),g=Object.create(null)):b=c,k=m=-1}else throw SyntaxError(`Unexpected character at index ${n}`);else if(void 0===c)if(-1===m&&1===d[l])-1===k&&(k=n);else if(32===l||9===l)-1===m&&-1!==k&&(m=n);else if(59===l||44===l){if(-1===k)throw SyntaxError(`Unexpected character at index ${n}`);-1===m&&(m=n),e(g,a.slice(k,m),!0),44===l&&(e(f,b,g),g=Object.create(null),b=void 0),k=m=-1}else if(61===l&&-1!==k&&-1===m)c=a.slice(k,n),k=m=-1;else throw SyntaxError(`Unexpected character at index ${n}`);else if(i){if(1!==d[l])throw SyntaxError(`Unexpected character at index ${n}`);-1===k?k=n:h||(h=!0),i=!1}else if(j)if(1===d[l])-1===k&&(k=n);else if(34===l&&-1!==k)j=!1,m=n;else if(92===l)i=!0;else throw SyntaxError(`Unexpected character at index ${n}`);else if(34===l&&61===a.charCodeAt(n-1))j=!0;else if(-1===m&&1===d[l])-1===k&&(k=n);else if(-1!==k&&(32===l||9===l))-1===m&&(m=n);else if(59===l||44===l){if(-1===k)throw SyntaxError(`Unexpected character at index ${n}`);-1===m&&(m=n);let d=a.slice(k,m);h&&(d=d.replace(/\\/g,""),h=!1),e(g,c,d),44===l&&(e(f,b,g),g=Object.create(null),b=void 0),c=void 0,k=m=-1}else throw SyntaxError(`Unexpected character at index ${n}`);if(-1===k||j||32===l||9===l)throw SyntaxError("Unexpected end of input");-1===m&&(m=n);let o=a.slice(k,m);return void 0===b?e(f,o,g):(void 0===c?e(g,o,!0):h?e(g,c,o.replace(/\\/g,"")):e(g,c,o),e(f,b,g)),f}}},5582:(a,b,c)=>{var d=c(23956);b.operation=function(a){return new d(b.timeouts(a),{forever:a&&(a.forever||a.retries===1/0),unref:a&&a.unref,maxRetryTime:a&&a.maxRetryTime})},b.timeouts=function(a){if(a instanceof Array)return[].concat(a);var b={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var c in a)b[c]=a[c];if(b.minTimeout>b.maxTimeout)throw Error("minTimeout is greater than maxTimeout");for(var d=[],e=0;e<b.retries;e++)d.push(this.createTimeout(e,b));return a&&a.forever&&!d.length&&d.push(this.createTimeout(e,b)),d.sort(function(a,b){return a-b}),d},b.createTimeout=function(a,b){var c=Math.round((b.randomize?Math.random()+1:1)*Math.max(b.minTimeout,1)*Math.pow(b.factor,a));return Math.min(c,b.maxTimeout)},b.wrap=function(a,c,d){if(c instanceof Array&&(d=c,c=null),!d)for(var e in d=[],a)"function"==typeof a[e]&&d.push(e);for(var f=0;f<d.length;f++){var g=d[f],h=a[g];a[g]=(function(d){var e=b.operation(c),f=Array.prototype.slice.call(arguments,1),g=f.pop();f.push(function(a){e.retry(a)||(a&&(arguments[0]=e.mainError()),g.apply(this,arguments))}),e.attempt(function(){d.apply(a,f)})}).bind(a,h),a[g].options=c}}},7686:(a,b,c)=>{"use strict";let{tokenChars:d}=c(45633);a.exports={parse:function(a){let b=new Set,c=-1,e=-1,f=0;for(;f<a.length;f++){let g=a.charCodeAt(f);if(-1===e&&1===d[g])-1===c&&(c=f);else if(0!==f&&(32===g||9===g))-1===e&&-1!==c&&(e=f);else if(44===g){if(-1===c)throw SyntaxError(`Unexpected character at index ${f}`);-1===e&&(e=f);let d=a.slice(c,e);if(b.has(d))throw SyntaxError(`The "${d}" subprotocol is duplicated`);b.add(d),c=e=-1}else throw SyntaxError(`Unexpected character at index ${f}`)}if(-1===c||-1!==e)throw SyntaxError("Unexpected end of input");let g=a.slice(c,f);if(b.has(g))throw SyntaxError(`The "${g}" subprotocol is duplicated`);return b.add(g),b}}},8334:(a,b,c)=>{"use strict";function d(a){var b;if(!(a instanceof Error))return{message:g(a),messageCarriesBody:!1};let c="number"==typeof(b=a).statusCode?b.statusCode:"number"==typeof b.status?b.status:"number"==typeof b.$metadata?.httpStatusCode?b.$metadata.httpStatusCode:"number"==typeof b.$response?.statusCode?b.$response.statusCode:void 0,d=function(a){let b=function(a){if("string"==typeof a.body)return a.body;if(e(a.error))return g(a.error);let b=a.$response?.body;return"string"==typeof b?b:e(b)?g(b):void 0}(a);if(void 0===b)return;let c=b.trim();if(0!==c.length){var d;return(d=c).length<=4e3?d:`${d.slice(0,4e3)}... [truncated ${d.length-4e3} chars]`}}(a),f=void 0===d||a.message.includes(d);return{status:c,body:d,message:a.message,messageCarriesBody:f}}function e(a){return"object"==typeof a&&null!==a&&Object.keys(a).length>0}function f(a,b){return a.messageCarriesBody||void 0===a.status||void 0===a.body?void 0!==b&&void 0!==a.status?`${b} (${a.status}): ${a.message}`:a.message:void 0!==b?`${b} (${a.status}): ${a.body}`:`${a.status}: ${a.body}`}function g(a){try{let b=JSON.stringify(a);return void 0===b?String(a):b}catch{return String(a)}}c.d(b,{Jo:()=>d,lR:()=>f})},10140:(a,b,c)=>{var d=c(79428),e=d.Buffer;function f(a,b){for(var c in a)b[c]=a[c]}function g(a,b,c){return e(a,b,c)}e.from&&e.alloc&&e.allocUnsafe&&e.allocUnsafeSlow?a.exports=d:(f(d,b),b.Buffer=g),g.prototype=Object.create(e.prototype),f(e,g),g.from=function(a,b,c){if("number"==typeof a)throw TypeError("Argument must not be a number");return e(a,b,c)},g.alloc=function(a,b,c){if("number"!=typeof a)throw TypeError("Argument must be a number");var d=e(a);return void 0!==b?"string"==typeof c?d.fill(b,c):d.fill(b):d.fill(0),d},g.allocUnsafe=function(a){if("number"!=typeof a)throw TypeError("Argument must be a number");return e(a)},g.allocUnsafeSlow=function(a){if("number"!=typeof a)throw TypeError("Argument must be a number");return d.SlowBuffer(a)}},13022:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.Impersonated=b.IMPERSONATED_ACCOUNT_TYPE=void 0;let d=c(85113),e=c(51596),f=c(90852);b.IMPERSONATED_ACCOUNT_TYPE="impersonated_service_account";class g extends d.OAuth2Client{sourceClient;targetPrincipal;targetScopes;delegates;lifetime;endpoint;constructor(a={}){if(super(a),this.credentials={expiry_date:1,refresh_token:"impersonated-placeholder"},this.sourceClient=a.sourceClient??new d.OAuth2Client,this.targetPrincipal=a.targetPrincipal??"",this.delegates=a.delegates??[],this.targetScopes=a.targetScopes??[],this.lifetime=a.lifetime??3600,(0,f.originalOrCamelOptions)(a).get("universe_domain")){if(this.sourceClient.universeDomain!==this.universeDomain)throw RangeError(`Universe domain ${this.sourceClient.universeDomain} in source credentials does not match ${this.universeDomain} universe domain set for impersonated credentials.`)}else this.universeDomain=this.sourceClient.universeDomain;this.endpoint=a.endpoint??`https://iamcredentials.${this.universeDomain}`}async sign(a){await this.sourceClient.getAccessToken();let b=`projects/-/serviceAccounts/${this.targetPrincipal}`,c=`${this.endpoint}/v1/${b}:signBlob`,d={delegates:this.delegates,payload:Buffer.from(a).toString("base64")};return(await this.sourceClient.request({...g.RETRY_CONFIG,url:c,data:d,method:"POST"})).data}getTargetPrincipal(){return this.targetPrincipal}async refreshToken(){try{await this.sourceClient.getAccessToken();let a="projects/-/serviceAccounts/"+this.targetPrincipal,b=`${this.endpoint}/v1/${a}:generateAccessToken`,c={delegates:this.delegates,scope:this.targetScopes,lifetime:this.lifetime+"s"},d=await this.sourceClient.request({...g.RETRY_CONFIG,url:b,data:c,method:"POST"}),e=d.data;return this.credentials.access_token=e.accessToken,this.credentials.expiry_date=Date.parse(e.expireTime),{tokens:this.credentials,res:d}}catch(c){if(!(c instanceof Error))throw c;let a=0,b="";if(c instanceof e.GaxiosError&&(a=c?.response?.data?.error?.status,b=c?.response?.data?.error?.message),a&&b)throw c.message=`${a}: unable to impersonate: ${b}`,c;throw c.message=`unable to impersonate: ${c}`,c}}async fetchIdToken(a,b){await this.sourceClient.getAccessToken();let c=`projects/-/serviceAccounts/${this.targetPrincipal}`,d=`${this.endpoint}/v1/${c}:generateIdToken`,e={delegates:this.delegates,audience:a,includeEmail:b?.includeEmail??!0,useEmailAzp:b?.includeEmail??!0};return(await this.sourceClient.request({...g.RETRY_CONFIG,url:d,data:e,method:"POST"})).data.token}}b.Impersonated=g},13618:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.JWTAccess=void 0;let d=c(62758),e=c(90852),f={alg:"RS256",typ:"JWT"};class g{email;key;keyId;projectId;eagerRefreshThresholdMillis;cache=new e.LRUCache({capacity:500,maxAge:36e5});constructor(a,b,c,d){this.email=a,this.key=b,this.keyId=c,this.eagerRefreshThresholdMillis=d??3e5}getCachedKey(a,b){let c=a;if(b&&Array.isArray(b)&&b.length?c=a?`${a}_${b.join("_")}`:`${b.join("_")}`:"string"==typeof b&&(c=a?`${a}_${b}`:b),!c)throw Error("Scopes or url must be provided");return c}getRequestHeaders(a,b,c){let e,h=this.getCachedKey(a,c),i=this.cache.get(h),j=Date.now();if(i&&i.expiration-j>this.eagerRefreshThresholdMillis)return new Headers(i.headers);let k=Math.floor(Date.now()/1e3),l=g.getExpirationTime(k);if(Array.isArray(c)&&(c=c.join(" ")),e=c?{iss:this.email,sub:this.email,scope:c,exp:l,iat:k}:{iss:this.email,sub:this.email,aud:a,exp:l,iat:k},b){for(let a in e)if(b[a])throw Error(`The '${a}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`)}let m=this.keyId?{...f,kid:this.keyId}:f,n=Object.assign(e,b),o=d.sign({header:m,payload:n,secret:this.key}),p=new Headers({authorization:`Bearer ${o}`});return this.cache.set(h,{expiration:1e3*l,headers:p}),p}static getExpirationTime(a){return a+3600}fromJSON(a){if(!a)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!a.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!a.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=a.client_email,this.key=a.private_key,this.keyId=a.private_key_id,this.projectId=a.project_id}fromStream(a,b){if(!b)return this.fromStreamAsync(a);this.fromStreamAsync(a).then(()=>b(),b)}fromStreamAsync(a){return new Promise((b,c)=>{a||c(Error("Must pass in a stream containing the service account auth settings."));let d="";a.setEncoding("utf8").on("data",a=>d+=a).on("error",c).on("end",()=>{try{let a=JSON.parse(d);this.fromJSON(a),b()}catch(a){c(a)}})})}}b.JWTAccess=g},13859:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.GaxiosInterceptorManager=void 0;class c extends Set{}b.GaxiosInterceptorManager=c},14669:(a,b,c)=>{"use strict";let{EMPTY_BUFFER:d}=c(89721),e=Buffer[Symbol.species];function f(a,b,c,d,e){for(let f=0;f<e;f++)c[d+f]=a[f]^b[3&f]}function g(a,b){for(let c=0;c<a.length;c++)a[c]^=b[3&c]}function h(a){let b;return(h.readOnly=!0,Buffer.isBuffer(a))?a:(a instanceof ArrayBuffer?b=new e(a):ArrayBuffer.isView(a)?b=new e(a.buffer,a.byteOffset,a.byteLength):(b=Buffer.from(a),h.readOnly=!1),b)}if(a.exports={concat:function(a,b){if(0===a.length)return d;if(1===a.length)return a[0];let c=Buffer.allocUnsafe(b),f=0;for(let b=0;b<a.length;b++){let d=a[b];c.set(d,f),f+=d.length}return f<b?new e(c.buffer,c.byteOffset,f):c},mask:f,toArrayBuffer:function(a){return a.length===a.buffer.byteLength?a.buffer:a.buffer.slice(a.byteOffset,a.byteOffset+a.length)},toBuffer:h,unmask:g},!process.env.WS_NO_BUFFER_UTIL)try{let b=c(64601);a.exports.mask=function(a,c,d,e,g){g<48?f(a,c,d,e,g):b.mask(a,c,d,e,g)},a.exports.unmask=function(a,c){a.length<32?g(a,c):b.unmask(a,c)}}catch(a){}},16838:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.NodeCrypto=void 0;let d=c(55511);class e{async sha256DigestBase64(a){return d.createHash("sha256").update(a).digest("base64")}randomBytesBase64(a){return d.randomBytes(a).toString("base64")}async verify(a,b,c){let e=d.createVerify("RSA-SHA256");return e.update(b),e.end(),e.verify(a,c,"base64")}async sign(a,b){let c=d.createSign("RSA-SHA256");return c.update(b),c.end(),c.sign(a,"base64")}decodeBase64StringUtf8(a){return Buffer.from(a,"base64").toString("utf-8")}encodeBase64StringUtf8(a){return Buffer.from(a,"utf-8").toString("base64")}async sha256DigestHex(a){return d.createHash("sha256").update(a).digest("hex")}async signWithHmacSha256(a,b){var c;let e="string"==typeof a?a:(c=a,Buffer.from(c));return function(a){let b=new ArrayBuffer(a.length),c=new Uint8Array(b);for(let b=0;b<a.length;++b)c[b]=a[b];return b}(d.createHmac("sha256",e).update(b).digest())}}b.NodeCrypto=e},17144:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.BrowserCrypto=void 0;let d=c(69371),e=c(90337);class f{constructor(){if("u"<typeof window||void 0===window.crypto||void 0===window.crypto.subtle)throw Error("SubtleCrypto not found. Make sure it's an https:// website.")}async sha256DigestBase64(a){let b=new TextEncoder().encode(a),c=await window.crypto.subtle.digest("SHA-256",b);return d.fromByteArray(new Uint8Array(c))}randomBytesBase64(a){let b=new Uint8Array(a);return window.crypto.getRandomValues(b),d.fromByteArray(b)}static padBase64(a){for(;a.length%4!=0;)a+="=";return a}async verify(a,b,c){let e={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},g=new TextEncoder().encode(b),h=d.toByteArray(f.padBase64(c)),i=await window.crypto.subtle.importKey("jwk",a,e,!0,["verify"]);return await window.crypto.subtle.verify(e,i,Buffer.from(h),g)}async sign(a,b){let c={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},e=new TextEncoder().encode(b),f=await window.crypto.subtle.importKey("jwk",a,c,!0,["sign"]),g=await window.crypto.subtle.sign(c,f,e);return d.fromByteArray(new Uint8Array(g))}decodeBase64StringUtf8(a){let b=d.toByteArray(f.padBase64(a));return new TextDecoder().decode(b)}encodeBase64StringUtf8(a){let b=new TextEncoder().encode(a);return d.fromByteArray(b)}async sha256DigestHex(a){let b=new TextEncoder().encode(a),c=await window.crypto.subtle.digest("SHA-256",b);return(0,e.fromArrayBufferToHex)(c)}async signWithHmacSha256(a,b){let c="string"==typeof a?a:String.fromCharCode(...new Uint16Array(a)),d=new TextEncoder,e=await window.crypto.subtle.importKey("raw",d.encode(c),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return window.crypto.subtle.sign("HMAC",e,d.encode(b))}}b.BrowserCrypto=f},17201:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.GoogleToken=void 0;let d=c(51596),e=c(98358),f=c(74674);class g{tokenOptions;tokenHandler;constructor(a){this.tokenOptions=a||{},this.tokenOptions.transporter=this.tokenOptions.transporter||{request:a=>(0,d.request)(a)},this.tokenOptions.iss||(this.tokenOptions.iss=this.tokenOptions.email),"object"==typeof this.tokenOptions.scope&&(this.tokenOptions.scope=this.tokenOptions.scope.join(" ")),this.tokenHandler=new e.TokenHandler(this.tokenOptions)}get expiresAt(){return this.tokenHandler.tokenExpiresAt}get accessToken(){return this.tokenHandler.token?.access_token}get idToken(){return this.tokenHandler.token?.id_token}get tokenType(){return this.tokenHandler.token?.token_type}get refreshToken(){return this.tokenHandler.token?.refresh_token}hasExpired(){return this.tokenHandler.hasExpired()}isTokenExpiring(){return this.tokenHandler.isTokenExpiring()}getToken(a,b={forceRefresh:!1}){let c;"function"==typeof a?c=a:"object"==typeof a&&(b=a);let d=this.tokenHandler.getToken(b.forceRefresh??!1);return c&&d.then(a=>c(null,a),c),d}revokeToken(a){if(!this.accessToken)return Promise.reject(Error("No token to revoke."));let b=(0,f.revokeToken)(this.accessToken,this.tokenOptions.transporter);a&&b.then(()=>a(),a),this.tokenHandler=new e.TokenHandler(this.tokenOptions)}get googleTokenOptions(){return this.tokenOptions}}b.GoogleToken=g},18094:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.DownscopedClient=b.EXPIRATION_TIME_OFFSET=b.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;let d=c(51596),e=c(27910),f=c(25072),g=c(32075);b.MAX_ACCESS_BOUNDARY_RULES_COUNT=10,b.EXPIRATION_TIME_OFFSET=3e5;class h extends f.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(a,c={accessBoundary:{accessBoundaryRules:[]}}){if(super(a instanceof f.AuthClient?{}:a),a instanceof f.AuthClient?(this.authClient=a,this.credentialAccessBoundary=c):(this.authClient=a.authClient,this.credentialAccessBoundary=a.credentialAccessBoundary),0===this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length)throw Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>b.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${b.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(const a of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(0===a.availablePermissions.length)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new g.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(a){if(!a.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(a),this.cachedDownscopedAccessToken=a}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let a=await this.getAccessToken(),b=new Headers({authorization:`Bearer ${a.token}`});return this.addSharedMetadataHeaders(b)}request(a,b){if(!b)return this.requestAsync(a);this.requestAsync(a).then(a=>b(null,a),a=>b(a,a.response))}async requestAsync(a,b=!1){let c;try{let b=await this.getRequestHeaders();a.headers=d.Gaxios.mergeHeaders(a.headers),this.addUserProjectAndAuthHeaders(a.headers,b),c=await this.transporter.request(a)}catch(d){let c=d.response;if(c){let d=c.status,f=c.config.data instanceof e.Readable;if(!b&&(401===d||403===d)&&!f&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(a,!0)}throw d}return c}async refreshAccessTokenAsync(){let a=(await this.authClient.getAccessToken()).token,b=await this.stsCredential.exchangeToken({grantType:"urn:ietf:params:oauth:grant-type:token-exchange",requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:a,subjectTokenType:"urn:ietf:params:oauth:token-type:access_token"},void 0,this.credentialAccessBoundary),c=this.authClient.credentials?.expiry_date||null,d=b.expires_in?new Date().getTime()+1e3*b.expires_in:c;return this.cachedDownscopedAccessToken={access_token:b.access_token,expiry_date:d,res:b.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(a){let b=new Date().getTime();return!!a.expiry_date&&b>=a.expiry_date-this.eagerRefreshThresholdMillis}}b.DownscopedClient=h},18367:(a,b,c)=>{"use strict";function d(a,b){let c=[],d=!1;for(let e of a){if("image"===e.type){d||c.push({type:"text",text:b}),d=!0;continue}c.push(e),d=e.text===b}return c}function e(a,b,c){var e;let f=new Map,g=(e=a.map(a=>null==a.content?{...a,content:[]}:a),b.input.includes("image")?e:e.map(a=>"user"===a.role&&Array.isArray(a.content)?{...a,content:d(a.content,"(image omitted: model does not support images)")}:"toolResult"===a.role?{...a,content:d(a.content,"(tool image omitted: model does not support images)")}:a)).map(a=>{if("user"===a.role)return a;if("toolResult"===a.role){let b=f.get(a.toolCallId);return b&&b!==a.toolCallId?{...a,toolCallId:b}:a}if("assistant"===a.role){let d=a.provider===b.provider&&a.api===b.api&&a.model===b.id,e=a.content.flatMap(e=>{if("thinking"===e.type)return e.redacted?d?e:[]:d&&e.thinkingSignature?e:e.thinking&&""!==e.thinking.trim()?d?e:{type:"text",text:e.thinking}:[];if("text"===e.type)return d?e:{type:"text",text:e.text};if("toolCall"===e.type){let g=e;if(!d&&e.thoughtSignature&&(g={...e},delete g.thoughtSignature),!d&&c){let d=c(e.id,b,a);d!==e.id&&(f.set(e.id,d),g={...g,id:d})}return g}return e});return{...a,content:e}}return a}),h=[],i=[],j=new Set,k=()=>{if(i.length>0){for(let a of i)j.has(a.id)||h.push({role:"toolResult",toolCallId:a.id,toolName:a.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});i=[],j=new Set}};for(let a=0;a<g.length;a++){let b=g[a];if("assistant"===b.role){if(k(),"error"===b.stopReason||"aborted"===b.stopReason)continue;let a=b.content.filter(a=>"toolCall"===a.type);a.length>0&&(i=a,j=new Set),h.push(b)}else"toolResult"===b.role?j.add(b.toolCallId):"user"===b.role&&k(),h.push(b)}return k(),h}c.d(b,{b:()=>e})},20244:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.buildPayloadForJwsSign=e,b.getJwsSign=function(a){let b=e(a);return(0,d.sign)({header:{alg:"RS256"},payload:b,secret:a.key})};let d=c(62758);function e(a){let b=Math.floor(new Date().getTime()/1e3);return{iss:a.iss,scope:a.scope,aud:"https://oauth2.googleapis.com/token",exp:b+3600,iat:b,sub:a.sub,...a.additionalClaims}}},20491:(a,b,c)=>{"use strict";var d,e;Object.defineProperty(b,"__esModule",{value:!0}),b.getCredentials=o;let f=c(33873),g=c(29021),h=c(28354),i=c(62350),j=g.readFile?(0,h.promisify)(g.readFile):async()=>{throw new i.ErrorWithCode("use key rather than keyFile.","MISSING_CREDENTIALS")};(e=d||(d={})).JSON=".json",e.DER=".der",e.CRT=".crt",e.PEM=".pem",e.P12=".p12",e.PFX=".pfx";class k{keyFilePath;constructor(a){this.keyFilePath=a}async getCredentials(){let a,b=await j(this.keyFilePath,"utf8");try{a=JSON.parse(b)}catch(a){throw Error(`Invalid JSON key file: ${a.message}`)}let c=a.private_key,d=a.client_email;if(!c||!d)throw new i.ErrorWithCode("private_key and client_email are required.","MISSING_CREDENTIALS");return{privateKey:c,clientEmail:d}}}class l{keyFilePath;constructor(a){this.keyFilePath=a}async getCredentials(){return{privateKey:await j(this.keyFilePath,"utf8")}}}class m{async getCredentials(){throw new i.ErrorWithCode("*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.","UNKNOWN_CERTIFICATE_TYPE")}}class n{static create(a){switch(f.extname(a)){case d.JSON:return new k(a);case d.DER:case d.CRT:case d.PEM:return new l(a);case d.P12:case d.PFX:return new m;default:throw new i.ErrorWithCode("Unknown certificate type. Type is determined based on file extension. Current supported extensions are *.json, and *.pem.","UNKNOWN_CERTIFICATE_TYPE")}}}async function o(a){return n.create(a).getCredentials()}},22559:(a,b,c)=>{"use strict";var d=c(10140).Buffer,e=c(91418);function f(a){if(d.isBuffer(a))return a;if("string"==typeof a)return d.from(a,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function g(a,b,c){for(var d=0;b+d<c&&0===a[b+d];)++d;return a[b+d]>=128&&--d,d}a.exports={derToJose:function(a,b){a=f(a);var c=e(b),g=c+1,h=a.length,i=0;if(48!==a[i++])throw Error('Could not find expected "seq"');var j=a[i++];if(129===j&&(j=a[i++]),h-i<j)throw Error('"seq" specified length of "'+j+'", only "'+(h-i)+'" remaining');if(2!==a[i++])throw Error('Could not find expected "int" for "r"');var k=a[i++];if(h-i-2<k)throw Error('"r" specified length of "'+k+'", only "'+(h-i-2)+'" available');if(g<k)throw Error('"r" specified length of "'+k+'", max of "'+g+'" is acceptable');var l=i;if(i+=k,2!==a[i++])throw Error('Could not find expected "int" for "s"');var m=a[i++];if(h-i!==m)throw Error('"s" specified length of "'+m+'", expected "'+(h-i)+'"');if(g<m)throw Error('"s" specified length of "'+m+'", max of "'+g+'" is acceptable');var n=i;if((i+=m)!==h)throw Error('Expected to consume entire buffer, but "'+(h-i)+'" bytes remain');var o=c-k,p=c-m,q=d.allocUnsafe(o+k+p+m);for(i=0;i<o;++i)q[i]=0;a.copy(q,i,l+Math.max(-o,0),l+k),i=c;for(var r=i;i<r+p;++i)q[i]=0;return a.copy(q,i,n+Math.max(-p,0),n+m),q=(q=q.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(a,b){a=f(a);var c=e(b),h=a.length;if(h!==2*c)throw TypeError('"'+b+'" signatures must be "'+2*c+'" bytes, saw "'+h+'"');var i=g(a,0,c),j=g(a,c,a.length),k=c-i,l=c-j,m=2+k+1+1+l,n=m<128,o=d.allocUnsafe((n?2:3)+m),p=0;return o[p++]=48,n?o[p++]=m:(o[p++]=129,o[p++]=255&m),o[p++]=2,o[p++]=k,i<0?(o[p++]=0,p+=a.copy(o,p,0,c)):p+=a.copy(o,p,i,c),o[p++]=2,o[p++]=l,j<0?(o[p++]=0,a.copy(o,p,c)):a.copy(o,p,c+j),o}}},23956:a=>{function b(a,b){"boolean"==typeof b&&(b={forever:b}),this._originalTimeouts=JSON.parse(JSON.stringify(a)),this._timeouts=a,this._options=b||{},this._maxRetryTime=b&&b.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}a.exports=b,b.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},b.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},b.prototype.retry=function(a){if(this._timeout&&clearTimeout(this._timeout),!a)return!1;var b=new Date().getTime();if(a&&b-this._operationStart>=this._maxRetryTime)return this._errors.push(a),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(a);var c=this._timeouts.shift();if(void 0===c)if(!this._cachedTimeouts)return!1;else this._errors.splice(0,this._errors.length-1),c=this._cachedTimeouts.slice(-1);var d=this;return this._timer=setTimeout(function(){d._attempts++,d._operationTimeoutCb&&(d._timeout=setTimeout(function(){d._operationTimeoutCb(d._attempts)},d._operationTimeout),d._options.unref&&d._timeout.unref()),d._fn(d._attempts)},c),this._options.unref&&this._timer.unref(),!0},b.prototype.attempt=function(a,b){this._fn=a,b&&(b.timeout&&(this._operationTimeout=b.timeout),b.cb&&(this._operationTimeoutCb=b.cb));var c=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){c._operationTimeoutCb()},c._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},b.prototype.try=function(a){console.log("Using RetryOperation.try() is deprecated"),this.attempt(a)},b.prototype.start=function(a){console.log("Using RetryOperation.start() is deprecated"),this.attempt(a)},b.prototype.start=b.prototype.try,b.prototype.errors=function(){return this._errors},b.prototype.attempts=function(){return this._attempts},b.prototype.mainError=function(){if(0===this._errors.length)return null;for(var a={},b=null,c=0,d=0;d<this._errors.length;d++){var e=this._errors[d],f=e.message,g=(a[f]||0)+1;a[f]=g,g>=c&&(b=e,c=g)}return b}},24099:function(a,b,c){"use strict";var d=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),e=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||d(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),e(c(73642),b)},24656:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.LoginTicket=void 0;class c{envelope;payload;constructor(a,b){this.envelope=a,this.payload=b}getEnvelope(){return this.envelope}getPayload(){return this.payload}getUserId(){let a=this.getPayload();return a&&a.sub?a.sub:null}getAttributes(){return{envelope:this.getEnvelope(),payload:this.getPayload()}}}b.LoginTicket=c},25072:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.AuthClient=b.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=b.DEFAULT_UNIVERSE=void 0;let d=c(94735),e=c(51596),f=c(90852),g=c(24099),h=c(1486);b.DEFAULT_UNIVERSE="googleapis.com",b.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=3e5;class i extends d.EventEmitter{apiKey;projectId;quotaProjectId;transporter;credentials={};eagerRefreshThresholdMillis=b.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS;forceRefreshOnFailure=!1;universeDomain=b.DEFAULT_UNIVERSE;static RequestMethodNameSymbol=Symbol("request method name");static RequestLogIdSymbol=Symbol("request log id");constructor(a={}){super();const c=(0,f.originalOrCamelOptions)(a);this.apiKey=a.apiKey,this.projectId=c.get("project_id")??null,this.quotaProjectId=c.get("quota_project_id"),this.credentials=c.get("credentials")??{},this.universeDomain=c.get("universe_domain")??b.DEFAULT_UNIVERSE,this.transporter=a.transporter??new e.Gaxios(a.transporterOptions),!1!==c.get("useAuthRequestParameters")&&(this.transporter.interceptors.request.add(i.DEFAULT_REQUEST_INTERCEPTOR),this.transporter.interceptors.response.add(i.DEFAULT_RESPONSE_INTERCEPTOR)),a.eagerRefreshThresholdMillis&&(this.eagerRefreshThresholdMillis=a.eagerRefreshThresholdMillis),this.forceRefreshOnFailure=a.forceRefreshOnFailure??!1}fetch(...a){let b,c=a[0],d=a[1],f=new Headers;return("string"==typeof c?b=new URL(c):c instanceof URL?b=c:c&&c.url&&(b=new URL(c.url)),c&&"object"==typeof c&&"headers"in c&&e.Gaxios.mergeHeaders(f,c.headers),d&&e.Gaxios.mergeHeaders(f,new Headers(d.headers)),"object"!=typeof c||c instanceof URL)?this.request({...d,headers:f,url:b}):this.request({...d,...c,headers:f,url:b})}setCredentials(a){this.credentials=a}addSharedMetadataHeaders(a){return!a.has("x-goog-user-project")&&this.quotaProjectId&&a.set("x-goog-user-project",this.quotaProjectId),a}addUserProjectAndAuthHeaders(a,b){let c=b.get("x-goog-user-project"),d=b.get("authorization");return c&&a.set("x-goog-user-project",c),d&&a.set("authorization",d),a}static log=(0,g.log)("auth");static DEFAULT_REQUEST_INTERCEPTOR={resolved:async a=>{if(!a.headers.has("x-goog-api-client")){let b=process.version.replace(/^v/,"");a.headers.set("x-goog-api-client",`gl-node/${b}`)}let b=a.headers.get("User-Agent");b?b.includes(`${h.PRODUCT_NAME}/`)||a.headers.set("User-Agent",`${b} ${h.USER_AGENT}`):a.headers.set("User-Agent",h.USER_AGENT);try{let b=a[i.RequestMethodNameSymbol],c=`${Math.floor(1e3*Math.random())}`;a[i.RequestLogIdSymbol]=c;let d={url:a.url,headers:a.headers};b?i.log.info("%s [%s] request %j",b,c,d):i.log.info("[%s] request %j",c,d)}catch(a){}return a}};static DEFAULT_RESPONSE_INTERCEPTOR={resolved:async a=>{try{let b=a.config,c=b[i.RequestMethodNameSymbol],d=b[i.RequestLogIdSymbol];c?i.log.info("%s [%s] response %j",c,d,a.data):i.log.info("[%s] response %j",d,a.data)}catch(a){}return a},rejected:async a=>{try{let b=a.config,c=b[i.RequestMethodNameSymbol],d=b[i.RequestLogIdSymbol];c?i.log.info("%s [%s] error %j",c,d,a.response?.data):i.log.error("[%s] error %j",d,a.response?.data)}catch(a){}throw a}};static setMethodName(a,b){try{a[i.RequestMethodNameSymbol]=b}catch(a){}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}b.AuthClient=i},25467:(a,b,c)=>{"use strict";let d,{Duplex:e}=c(27910),{randomFillSync:f}=c(55511),{types:{isUint8Array:g}}=c(28354),h=c(49478),{EMPTY_BUFFER:i,kWebSocket:j,NOOP:k}=c(89721),{isBlob:l,isValidStatusCode:m}=c(45633),{mask:n,toBuffer:o}=c(14669),p=Symbol("kByteLength"),q=Buffer.alloc(4),r=8192;class s{constructor(a,b,c){this._extensions=b||{},c&&(this._generateMask=c,this._maskBuffer=Buffer.alloc(4)),this._socket=a,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=k,this[j]=void 0}static frame(a,b){let c,e,g=!1,h=2,i=!1;b.mask&&(c=b.maskBuffer||q,b.generateMask?b.generateMask(c):(8192===r&&(void 0===d&&(d=Buffer.alloc(8192)),f(d,0,8192),r=0),c[0]=d[r++],c[1]=d[r++],c[2]=d[r++],c[3]=d[r++]),i=(c[0]|c[1]|c[2]|c[3])==0,h=6),"string"==typeof a?e=(!b.mask||i)&&void 0!==b[p]?b[p]:(a=Buffer.from(a)).length:(e=a.length,g=b.mask&&b.readOnly&&!i);let j=e;e>=65536?(h+=8,j=127):e>125&&(h+=2,j=126);let k=Buffer.allocUnsafe(g?e+h:h);return(k[0]=b.fin?128|b.opcode:b.opcode,b.rsv1&&(k[0]|=64),k[1]=j,126===j?k.writeUInt16BE(e,2):127===j&&(k[2]=k[3]=0,k.writeUIntBE(e,4,6)),b.mask)?(k[1]|=128,k[h-4]=c[0],k[h-3]=c[1],k[h-2]=c[2],k[h-1]=c[3],i)?[k,a]:g?(n(a,c,k,h,e),[k]):(n(a,c,a,0,e),[k,a]):[k,a]}close(a,b,c,d){let e;if(void 0===a)e=i;else if("number"==typeof a&&m(a))if(void 0!==b&&b.length){let c=Buffer.byteLength(b);if(c>123)throw RangeError("The message must not be greater than 123 bytes");if((e=Buffer.allocUnsafe(2+c)).writeUInt16BE(a,0),"string"==typeof b)e.write(b,2);else if(g(b))e.set(b,2);else throw TypeError("Second argument must be a string or a Uint8Array")}else(e=Buffer.allocUnsafe(2)).writeUInt16BE(a,0);else throw TypeError("First argument must be a valid error code number");let f={[p]:e.length,fin:!0,generateMask:this._generateMask,mask:c,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,e,!1,f,d]):this.sendFrame(s.frame(e,f),d)}ping(a,b,c){let d,e;if("string"==typeof a?(d=Buffer.byteLength(a),e=!1):l(a)?(d=a.size,e=!1):(d=(a=o(a)).length,e=o.readOnly),d>125)throw RangeError("The data size must not be greater than 125 bytes");let f={[p]:d,fin:!0,generateMask:this._generateMask,mask:b,maskBuffer:this._maskBuffer,opcode:9,readOnly:e,rsv1:!1};l(a)?0!==this._state?this.enqueue([this.getBlobData,a,!1,f,c]):this.getBlobData(a,!1,f,c):0!==this._state?this.enqueue([this.dispatch,a,!1,f,c]):this.sendFrame(s.frame(a,f),c)}pong(a,b,c){let d,e;if("string"==typeof a?(d=Buffer.byteLength(a),e=!1):l(a)?(d=a.size,e=!1):(d=(a=o(a)).length,e=o.readOnly),d>125)throw RangeError("The data size must not be greater than 125 bytes");let f={[p]:d,fin:!0,generateMask:this._generateMask,mask:b,maskBuffer:this._maskBuffer,opcode:10,readOnly:e,rsv1:!1};l(a)?0!==this._state?this.enqueue([this.getBlobData,a,!1,f,c]):this.getBlobData(a,!1,f,c):0!==this._state?this.enqueue([this.dispatch,a,!1,f,c]):this.sendFrame(s.frame(a,f),c)}send(a,b,c){let d,e,f=this._extensions[h.extensionName],g=b.binary?2:1,i=b.compress;"string"==typeof a?(d=Buffer.byteLength(a),e=!1):l(a)?(d=a.size,e=!1):(d=(a=o(a)).length,e=o.readOnly),this._firstFragment?(this._firstFragment=!1,i&&f&&f.params[f._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=d>=f._threshold),this._compress=i):(i=!1,g=0),b.fin&&(this._firstFragment=!0);let j={[p]:d,fin:b.fin,generateMask:this._generateMask,mask:b.mask,maskBuffer:this._maskBuffer,opcode:g,readOnly:e,rsv1:i};l(a)?0!==this._state?this.enqueue([this.getBlobData,a,this._compress,j,c]):this.getBlobData(a,this._compress,j,c):0!==this._state?this.enqueue([this.dispatch,a,this._compress,j,c]):this.dispatch(a,this._compress,j,c)}getBlobData(a,b,c,d){this._bufferedBytes+=c[p],this._state=2,a.arrayBuffer().then(a=>{if(this._socket.destroyed){let a=Error("The socket was closed while the blob was being read");process.nextTick(t,this,a,d);return}this._bufferedBytes-=c[p];let e=o(a);b?this.dispatch(e,b,c,d):(this._state=0,this.sendFrame(s.frame(e,c),d),this.dequeue())}).catch(a=>{process.nextTick(u,this,a,d)})}dispatch(a,b,c,d){if(!b)return void this.sendFrame(s.frame(a,c),d);let e=this._extensions[h.extensionName];this._bufferedBytes+=c[p],this._state=1,e.compress(a,c.fin,(a,b)=>{this._socket.destroyed?t(this,Error("The socket was closed while data was being compressed"),d):(this._bufferedBytes-=c[p],this._state=0,c.readOnly=!1,this.sendFrame(s.frame(b,c),d),this.dequeue())})}dequeue(){for(;0===this._state&&this._queue.length;){let a=this._queue.shift();this._bufferedBytes-=a[3][p],Reflect.apply(a[0],this,a.slice(1))}}enqueue(a){this._bufferedBytes+=a[3][p],this._queue.push(a)}sendFrame(a,b){2===a.length?(this._socket.cork(),this._socket.write(a[0]),this._socket.write(a[1],b),this._socket.uncork()):this._socket.write(a[0],b)}}function t(a,b,c){"function"==typeof c&&c(b);for(let c=0;c<a._queue.length;c++){let d=a._queue[c],e=d[d.length-1];"function"==typeof e&&e(b)}}function u(a,b,c){t(a,b,c),a.onerror(b)}a.exports=s},26107:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.DefaultAwsSecurityCredentialsSupplier=void 0;let d=c(25072);class e{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(a){this.regionUrl=a.regionUrl,this.securityCredentialsUrl=a.securityCredentialsUrl,this.imdsV2SessionTokenUrl=a.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=a.additionalGaxiosOptions}async getAwsRegion(a){if(this.#b)return this.#b;let b=new Headers;if(!this.#b&&this.imdsV2SessionTokenUrl&&b.set("x-aws-ec2-metadata-token",await this.#c(a.transporter)),!this.regionUrl)throw RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');let c={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:b};d.AuthClient.setMethodName(c,"getAwsRegion");let e=await a.transporter.request(c);return e.data.substr(0,e.data.length-1)}async getAwsSecurityCredentials(a){if(this.#d)return this.#d;let b=new Headers;this.imdsV2SessionTokenUrl&&b.set("x-aws-ec2-metadata-token",await this.#c(a.transporter));let c=await this.#e(b,a.transporter),d=await this.#f(c,b,a.transporter);return{accessKeyId:d.AccessKeyId,secretAccessKey:d.SecretAccessKey,token:d.Token}}async #c(a){let b={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};return d.AuthClient.setMethodName(b,"#getImdsV2SessionToken"),(await a.request(b)).data}async #e(a,b){if(!this.securityCredentialsUrl)throw Error('Unable to determine AWS role name due to missing "options.credential_source.url"');let c={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:a};return d.AuthClient.setMethodName(c,"#getAwsRoleName"),(await b.request(c)).data}async #f(a,b,c){let e={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${a}`,headers:b,responseType:"json"};return d.AuthClient.setMethodName(e,"#retrieveAwsSecurityCredentials"),(await c.request(e)).data}get #b(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get #d(){return process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY?{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN}:null}}b.DefaultAwsSecurityCredentialsSupplier=e},26678:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.FileSubjectTokenSupplier=void 0;let d=c(28354),e=c(29021),f=(0,d.promisify)(e.readFile??(()=>{})),g=(0,d.promisify)(e.realpath??(()=>{})),h=(0,d.promisify)(e.lstat??(()=>{}));class i{filePath;formatType;subjectTokenFieldName;constructor(a){this.filePath=a.filePath,this.formatType=a.formatType,this.subjectTokenFieldName=a.subjectTokenFieldName}async getSubjectToken(){let a,b=this.filePath;try{if(b=await g(b),!(await h(b)).isFile())throw Error()}catch(a){throw a instanceof Error&&(a.message=`The file at ${b} does not exist, or it is not a file. ${a.message}`),a}let c=await f(b,{encoding:"utf8"});if("text"===this.formatType?a=c:"json"===this.formatType&&this.subjectTokenFieldName&&(a=JSON.parse(c)[this.subjectTokenFieldName]),!a)throw Error("Unable to parse the subject_token from the credential_source file");return a}}b.FileSubjectTokenSupplier=i},27879:(a,b,c)=>{"use strict";let d=c(94735),e=c(55591),f=c(81630),g=c(91645),h=c(34631),{randomBytes:i,createHash:j}=c(55511),{Duplex:k,Readable:l}=c(27910),{URL:m}=c(1932),n=c(49478),o=c(93959),p=c(25467),{isBlob:q}=c(45633),{BINARY_TYPES:r,CLOSE_TIMEOUT:s,EMPTY_BUFFER:t,GUID:u,kForOnEventAttribute:v,kListener:w,kStatusCode:x,kWebSocket:y,NOOP:z}=c(89721),{EventTarget:{addEventListener:A,removeEventListener:B}}=c(81840),{format:C,parse:D}=c(3969),{toBuffer:E}=c(14669),F=Symbol("kAborted"),G=[8,13],H=["CONNECTING","OPEN","CLOSING","CLOSED"],I=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class J extends d{constructor(a,b,c){super(),this._binaryType=r[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=t,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=J.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==a?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===b?b=[]:Array.isArray(b)||("object"==typeof b&&null!==b?(c=b,b=[]):b=[b]),function a(b,c,d,g){let h,k,l,o,p={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:s,protocolVersion:G[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...g,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(b._autoPong=p.autoPong,b._closeTimeout=p.closeTimeout,!G.includes(p.protocolVersion))throw RangeError(`Unsupported protocol version: ${p.protocolVersion} (supported versions: ${G.join(", ")})`);if(c instanceof m)h=c;else try{h=new m(c)}catch{throw SyntaxError(`Invalid URL: ${c}`)}"http:"===h.protocol?h.protocol="ws:":"https:"===h.protocol&&(h.protocol="wss:"),b._url=h.href;let q="wss:"===h.protocol,r="ws+unix:"===h.protocol;if("ws:"===h.protocol||q||r?r&&!h.pathname?k="The URL's pathname is empty":h.hash&&(k="The URL contains a fragment identifier"):k='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',k){let a=SyntaxError(k);if(0!==b._redirects)return void K(b,a);throw a}let t=q?443:80,v=i(16).toString("base64"),w=q?e.request:f.request,x=new Set;if(p.createConnection=p.createConnection||(q?M:L),p.defaultPort=p.defaultPort||t,p.port=h.port||t,p.host=h.hostname.startsWith("[")?h.hostname.slice(1,-1):h.hostname,p.headers={...p.headers,"Sec-WebSocket-Version":p.protocolVersion,"Sec-WebSocket-Key":v,Connection:"Upgrade",Upgrade:"websocket"},p.path=h.pathname+h.search,p.timeout=p.handshakeTimeout,p.perMessageDeflate&&(l=new n({...p.perMessageDeflate,isServer:!1,maxPayload:p.maxPayload}),p.headers["Sec-WebSocket-Extensions"]=C({[n.extensionName]:l.offer()})),d.length){for(let a of d){if("string"!=typeof a||!I.test(a)||x.has(a))throw SyntaxError("An invalid or duplicated subprotocol was specified");x.add(a)}p.headers["Sec-WebSocket-Protocol"]=d.join(",")}if(p.origin&&(p.protocolVersion<13?p.headers["Sec-WebSocket-Origin"]=p.origin:p.headers.Origin=p.origin),(h.username||h.password)&&(p.auth=`${h.username}:${h.password}`),r){let a=p.path.split(":");p.socketPath=a[0],p.path=a[1]}if(p.followRedirects){if(0===b._redirects){b._originalIpc=r,b._originalSecure=q,b._originalHostOrSocketPath=r?p.socketPath:h.host;let a=g&&g.headers;if(g={...g,headers:{}},a)for(let[b,c]of Object.entries(a))g.headers[b.toLowerCase()]=c}else if(0===b.listenerCount("redirect")){let a=r?!!b._originalIpc&&p.socketPath===b._originalHostOrSocketPath:!b._originalIpc&&h.host===b._originalHostOrSocketPath;a&&(!b._originalSecure||q)||(delete p.headers.authorization,delete p.headers.cookie,a||delete p.headers.host,p.auth=void 0)}p.auth&&!g.headers.authorization&&(g.headers.authorization="Basic "+Buffer.from(p.auth).toString("base64")),o=b._req=w(p),b._redirects&&b.emit("redirect",b.url,o)}else o=b._req=w(p);p.timeout&&o.on("timeout",()=>{N(b,o,"Opening handshake has timed out")}),o.on("error",a=>{null===o||o[F]||(o=b._req=null,K(b,a))}),o.on("response",e=>{let f=e.headers.location,h=e.statusCode;if(f&&p.followRedirects&&h>=300&&h<400){let e;if(++b._redirects>p.maxRedirects)return void N(b,o,"Maximum redirects exceeded");o.abort();try{e=new m(f,c)}catch(a){K(b,SyntaxError(`Invalid URL: ${f}`));return}a(b,e,d,g)}else b.emit("unexpected-response",o,e)||N(b,o,`Unexpected server response: ${e.statusCode}`)}),o.on("upgrade",(a,c,d)=>{let e;if(b.emit("upgrade",a),b.readyState!==J.CONNECTING)return;o=b._req=null;let f=a.headers.upgrade;if(void 0===f||"websocket"!==f.toLowerCase())return void N(b,c,"Invalid Upgrade header");let g=j("sha1").update(v+u).digest("base64");if(a.headers["sec-websocket-accept"]!==g)return void N(b,c,"Invalid Sec-WebSocket-Accept header");let h=a.headers["sec-websocket-protocol"];if(void 0!==h?x.size?x.has(h)||(e="Server sent an invalid subprotocol"):e="Server sent a subprotocol but none was requested":x.size&&(e="Server sent no subprotocol"),e)return void N(b,c,e);h&&(b._protocol=h);let i=a.headers["sec-websocket-extensions"];if(void 0!==i){let a;if(!l)return void N(b,c,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");try{a=D(i)}catch(a){N(b,c,"Invalid Sec-WebSocket-Extensions header");return}let d=Object.keys(a);if(1!==d.length||d[0]!==n.extensionName)return void N(b,c,"Server indicated an extension that was not requested");try{l.accept(a[n.extensionName])}catch(a){N(b,c,"Invalid Sec-WebSocket-Extensions header");return}b._extensions[n.extensionName]=l}b.setSocket(c,d,{allowSynchronousEvents:p.allowSynchronousEvents,generateMask:p.generateMask,maxBufferedChunks:p.maxBufferedChunks,maxFragments:p.maxFragments,maxPayload:p.maxPayload,skipUTF8Validation:p.skipUTF8Validation})}),p.finishRequest?p.finishRequest(o,b):o.end()}(this,a,b,c)):(this._autoPong=c.autoPong,this._closeTimeout=c.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(a){r.includes(a)&&(this._binaryType=a,this._receiver&&(this._receiver._binaryType=a))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(a,b,c){let d=new o({allowSynchronousEvents:c.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:c.maxBufferedChunks,maxFragments:c.maxFragments,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation}),e=new p(a,this._extensions,c.generateMask);this._receiver=d,this._sender=e,this._socket=a,d[y]=this,e[y]=this,a[y]=this,d.on("conclude",P),d.on("drain",Q),d.on("error",R),d.on("message",T),d.on("ping",U),d.on("pong",V),e.onerror=X,a.setTimeout&&a.setTimeout(0),a.setNoDelay&&a.setNoDelay(),b.length>0&&a.unshift(b),a.on("close",Z),a.on("data",$),a.on("end",_),a.on("error",aa),this._readyState=J.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=J.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[n.extensionName]&&this._extensions[n.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=J.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(a,b){if(this.readyState!==J.CLOSED){if(this.readyState===J.CONNECTING)return void N(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===J.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=J.CLOSING,this._sender.close(a,b,!this._isServer,a=>{!a&&(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Y(this)}}pause(){this.readyState!==J.CONNECTING&&this.readyState!==J.CLOSED&&(this._paused=!0,this._socket.pause())}ping(a,b,c){if(this.readyState===J.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof a?(c=a,a=b=void 0):"function"==typeof b&&(c=b,b=void 0),"number"==typeof a&&(a=a.toString()),this.readyState!==J.OPEN)?O(this,a,c):(void 0===b&&(b=!this._isServer),this._sender.ping(a||t,b,c))}pong(a,b,c){if(this.readyState===J.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof a?(c=a,a=b=void 0):"function"==typeof b&&(c=b,b=void 0),"number"==typeof a&&(a=a.toString()),this.readyState!==J.OPEN)?O(this,a,c):(void 0===b&&(b=!this._isServer),this._sender.pong(a||t,b,c))}resume(){this.readyState!==J.CONNECTING&&this.readyState!==J.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(a,b,c){if(this.readyState===J.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof b&&(c=b,b={}),"number"==typeof a&&(a=a.toString()),this.readyState!==J.OPEN)return void O(this,a,c);let d={binary:"string"!=typeof a,mask:!this._isServer,compress:!0,fin:!0,...b};this._extensions[n.extensionName]||(d.compress=!1),this._sender.send(a||t,d,c)}terminate(){if(this.readyState!==J.CLOSED){if(this.readyState===J.CONNECTING)return void N(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=J.CLOSING,this._socket.destroy())}}}function K(a,b){a._readyState=J.CLOSING,a._errorEmitted=!0,a.emit("error",b),a.emitClose()}function L(a){return a.path=a.socketPath,g.connect(a)}function M(a){return a.path=void 0,a.servername||""===a.servername||(a.servername=g.isIP(a.host)?"":a.host),h.connect(a)}function N(a,b,c){a._readyState=J.CLOSING;let d=Error(c);Error.captureStackTrace(d,N),b.setHeader?(b[F]=!0,b.abort(),b.socket&&!b.socket.destroyed&&b.socket.destroy(),process.nextTick(K,a,d)):(b.destroy(d),b.once("error",a.emit.bind(a,"error")),b.once("close",a.emitClose.bind(a)))}function O(a,b,c){if(b){let c=q(b)?b.size:E(b).length;a._socket?a._sender._bufferedBytes+=c:a._bufferedAmount+=c}if(c){let b=Error(`WebSocket is not open: readyState ${a.readyState} (${H[a.readyState]})`);process.nextTick(c,b)}}function P(a,b){let c=this[y];c._closeFrameReceived=!0,c._closeMessage=b,c._closeCode=a,void 0!==c._socket[y]&&(c._socket.removeListener("data",$),process.nextTick(W,c._socket),1005===a?c.close():c.close(a,b))}function Q(){let a=this[y];a.isPaused||a._socket.resume()}function R(a){let b=this[y];void 0!==b._socket[y]&&(b._socket.removeListener("data",$),process.nextTick(W,b._socket),b.close(a[x])),b._errorEmitted||(b._errorEmitted=!0,b.emit("error",a))}function S(){this[y].emitClose()}function T(a,b){this[y].emit("message",a,b)}function U(a){let b=this[y];b._autoPong&&b.pong(a,!this._isServer,z),b.emit("ping",a)}function V(a){this[y].emit("pong",a)}function W(a){a.resume()}function X(a){let b=this[y];b.readyState!==J.CLOSED&&(b.readyState===J.OPEN&&(b._readyState=J.CLOSING,Y(b)),this._socket.end(),b._errorEmitted||(b._errorEmitted=!0,b.emit("error",a)))}function Y(a){a._closeTimer=setTimeout(a._socket.destroy.bind(a._socket),a._closeTimeout)}function Z(){let a=this[y];if(this.removeListener("close",Z),this.removeListener("data",$),this.removeListener("end",_),a._readyState=J.CLOSING,!this._readableState.endEmitted&&!a._closeFrameReceived&&!a._receiver._writableState.errorEmitted&&0!==this._readableState.length){let b=this.read(this._readableState.length);a._receiver.write(b)}a._receiver.end(),this[y]=void 0,clearTimeout(a._closeTimer),a._receiver._writableState.finished||a._receiver._writableState.errorEmitted?a.emitClose():(a._receiver.on("error",S),a._receiver.on("finish",S))}function $(a){this[y]._receiver.write(a)||this.pause()}function _(){let a=this[y];a._readyState=J.CLOSING,a._receiver.end(),this.end()}function aa(){let a=this[y];this.removeListener("error",aa),this.on("error",z),a&&(a._readyState=J.CLOSING,this.destroy())}Object.defineProperty(J,"CONNECTING",{enumerable:!0,value:H.indexOf("CONNECTING")}),Object.defineProperty(J.prototype,"CONNECTING",{enumerable:!0,value:H.indexOf("CONNECTING")}),Object.defineProperty(J,"OPEN",{enumerable:!0,value:H.indexOf("OPEN")}),Object.defineProperty(J.prototype,"OPEN",{enumerable:!0,value:H.indexOf("OPEN")}),Object.defineProperty(J,"CLOSING",{enumerable:!0,value:H.indexOf("CLOSING")}),Object.defineProperty(J.prototype,"CLOSING",{enumerable:!0,value:H.indexOf("CLOSING")}),Object.defineProperty(J,"CLOSED",{enumerable:!0,value:H.indexOf("CLOSED")}),Object.defineProperty(J.prototype,"CLOSED",{enumerable:!0,value:H.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(a=>{Object.defineProperty(J.prototype,a,{enumerable:!0})}),["open","error","close","message"].forEach(a=>{Object.defineProperty(J.prototype,`on${a}`,{enumerable:!0,get(){for(let b of this.listeners(a))if(b[v])return b[w];return null},set(b){for(let b of this.listeners(a))if(b[v]){this.removeListener(a,b);break}"function"==typeof b&&this.addEventListener(a,b,{[v]:!0})}})}),J.prototype.addEventListener=A,J.prototype.removeEventListener=B,a.exports=J},30787:function(a,b,c){"use strict";var d,e=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(b,"__esModule",{value:!0}),b.Gaxios=void 0;let f=e(c(73482)),g=c(55591),h=c(43699),i=c(85778),j=c(27910),k=c(13859),l=async()=>globalThis.crypto?.randomUUID()||(await Promise.resolve().then(c.t.bind(c,55511,23))).randomUUID();class m{agentCache=new Map;defaults;interceptors;constructor(a){this.defaults=a||{},this.interceptors={request:new k.GaxiosInterceptorManager,response:new k.GaxiosInterceptorManager}}fetch(...a){let b,c=a[0],e=a[1],f=new Headers;return("string"==typeof c?b=new URL(c):c instanceof URL?b=c:c&&c.url&&(b=new URL(c.url)),c&&"object"==typeof c&&"headers"in c&&d.mergeHeaders(f,c.headers),e&&d.mergeHeaders(f,new Headers(e.headers)),"object"!=typeof c||c instanceof URL)?this.request({...e,headers:f,url:b}):this.request({...e,...c,headers:f,url:b})}async request(a={}){let b=await this.#g(a);return b=await this.#h(b),this.#i(this._request(b))}async _defaultAdapter(a){let b=a.fetchImplementation||this.defaults.fetchImplementation||await d.#j(),c={...a};delete c.data;let e=await b(a.url,c),f=await this.getResponseData(a,e);return Object.getOwnPropertyDescriptor(e,"data")?.configurable||Object.defineProperties(e,{data:{configurable:!0,writable:!0,enumerable:!0,value:f}}),Object.assign(e,{config:a,data:f})}async _request(a){try{let b;if(b=a.adapter?await a.adapter(a,this._defaultAdapter.bind(this)):await this._defaultAdapter(a),!a.validateStatus(b.status)){if("stream"===a.responseType){let a=[];for await(let c of b.data)a.push(c);b.data=a.toString()}let c=h.GaxiosError.extractAPIErrorFromResponse(b,`Request failed with status code ${b.status}`);throw new h.GaxiosError(c?.message,a,b,c)}return b}catch(e){let b;b=e instanceof h.GaxiosError?e:e instanceof Error?new h.GaxiosError(e.message,a,void 0,e):new h.GaxiosError("Unexpected Gaxios Error",a,void 0,e);let{shouldRetry:c,config:d}=await (0,i.getRetryConfig)(b);if(c&&d)return b.config.retryConfig.currentRetryAttempt=d.retryConfig.currentRetryAttempt,a.retryConfig=b.config?.retryConfig,this.#k(a),this._request(a);throw a.errorRedactor&&a.errorRedactor(b),b}}async getResponseData(a,b){if(204===b.status)return"";if(a.maxContentLength&&b.headers.has("content-length")&&a.maxContentLength<Number.parseInt(b.headers?.get("content-length")||""))throw new h.GaxiosError("Response's `Content-Length` is over the limit.",a,Object.assign(b,{config:a}));switch(a.responseType){case"stream":return b.body;case"json":{let a=await b.text();try{return JSON.parse(a)}catch{return a}}case"arraybuffer":return b.arrayBuffer();case"blob":return b.blob();case"text":return b.text();default:return this.getResponseDataFromContentType(b)}}#l(a,b=[]){let c=new URL(a),d=[...b];for(let a of(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[])d.push(a.trim());for(let a of d)if(a instanceof RegExp){if(a.test(c.toString()))return!1}else if(a instanceof URL){if(a.origin===c.origin)return!1}else if(a.startsWith("*.")||a.startsWith(".")){let b=a.replace(/^\*\./,".");if(c.hostname.endsWith(b))return!1}else if(a===c.origin||a===c.hostname||a===c.href)return!1;return!0}async #h(a){let b=Promise.resolve(a);for(let a of this.interceptors.request.values())a&&(b=b.then(a.resolved,a.rejected));return b}async #i(a){let b=Promise.resolve(a);for(let a of this.interceptors.response.values())a&&(b=b.then(a.resolved,a.rejected));return b}async #g(a){let b=new Headers(this.defaults.headers);d.mergeHeaders(b,a.headers);let c=(0,f.default)(!0,{},this.defaults,a);if(!c.url)throw Error("URL is required.");if(c.baseURL&&(c.url=new URL(c.url,c.baseURL)),c.url=new URL(c.url),c.params)if(c.paramsSerializer){let a=c.paramsSerializer(c.params);a.startsWith("?")&&(a=a.slice(1));let b=c.url.toString().includes("?")?"&":"?";c.url=c.url+b+a}else{let a=c.url instanceof URL?c.url:new URL(c.url);for(let[b,d]of new URLSearchParams(c.params))a.searchParams.append(b,d);c.url=a}"number"==typeof a.maxContentLength&&(c.size=a.maxContentLength),"number"==typeof a.maxRedirects&&(c.follow=a.maxRedirects);let e="string"==typeof c.data||c.data instanceof ArrayBuffer||c.data instanceof Blob||globalThis.File&&c.data instanceof File||c.data instanceof FormData||c.data instanceof j.Readable||c.data instanceof ReadableStream||c.data instanceof String||c.data instanceof URLSearchParams||ArrayBuffer.isView(c.data)||["Blob","File","FormData"].includes(c.data?.constructor?.name||"");if(c.multipart?.length){let a=await l();b.set("content-type",`multipart/related; boundary=${a}`),c.body=j.Readable.from(this.getMultipartRequest(c.multipart,a))}else e?c.body=c.data:"object"==typeof c.data?"application/x-www-form-urlencoded"===b.get("Content-Type")?c.body=c.paramsSerializer?c.paramsSerializer(c.data):new URLSearchParams(c.data):(b.has("content-type")||b.set("content-type","application/json"),c.body=JSON.stringify(c.data)):c.data&&(c.body=c.data);c.validateStatus=c.validateStatus||this.validateStatus,c.responseType=c.responseType||"unknown",b.has("accept")||"json"!==c.responseType||b.set("accept","application/json");let i=c.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(c.agent);else if(i&&this.#l(c.url,c.noProxy)){let a=await d.#m();this.agentCache.has(i)?c.agent=this.agentCache.get(i):(c.agent=new a(i,{cert:c.cert,key:c.key}),this.agentCache.set(i,c.agent))}else c.cert&&c.key&&(this.agentCache.has(c.key)?c.agent=this.agentCache.get(c.key):(c.agent=new g.Agent({cert:c.cert,key:c.key}),this.agentCache.set(c.key,c.agent)));return"function"!=typeof c.errorRedactor&&!1!==c.errorRedactor&&(c.errorRedactor=h.defaultErrorRedactor),!c.body||"duplex"in c||(c.duplex="half"),this.#k(c),Object.assign(c,{headers:b,url:c.url instanceof URL?c.url:new URL(c.url)})}#k(a){if(a.timeout){let b=AbortSignal.timeout(a.timeout);a.signal&&!a.signal.aborted?a.signal=AbortSignal.any([a.signal,b]):a.signal=b}}validateStatus(a){return a>=200&&a<300}async getResponseDataFromContentType(a){let b=a.headers.get("Content-Type");if(null===b)return a.text();if((b=b.toLowerCase()).includes("application/json")){let b=await a.text();try{b=JSON.parse(b)}catch{}return b}return b.match(/^text\//)?a.text():a.blob()}async *getMultipartRequest(a,b){let c=`--${b}--`;for(let c of a){let a=c.headers.get("Content-Type")||"application/octet-stream",d=`--${b}\r
|
|
2
|
+
Content-Type: ${a}\r
|
|
3
|
+
\r
|
|
4
|
+
`;yield d,"string"==typeof c.content?yield c.content:yield*c.content,yield"\r\n"}yield c}static #n;static #o;static async #m(){return this.#n||=(await c.e(3115).then(c.t.bind(c,23115,23))).HttpsProxyAgent,this.#n}static async #j(){let a="u">typeof window&&!!window;return this.#o||=a?window.fetch:(await c.e(1965).then(c.bind(c,41965))).default,this.#o}static mergeHeaders(a,...b){for(let c of(a=a instanceof Headers?a:new Headers(a),b))(c instanceof Headers?c:new Headers(c)).forEach((b,c)=>{"set-cookie"===c?a.append(c,b):a.set(c,b)});return a}}b.Gaxios=m,d=m},32075:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.StsCredentials=void 0;let d=c(51596),e=c(25072),f=c(88711),g=c(90852);class h extends f.OAuthClientAuthHandler{#p;constructor(a={tokenExchangeEndpoint:""},b){("object"!=typeof a||a instanceof URL)&&(a={tokenExchangeEndpoint:a,clientAuthentication:b}),super(a),this.#p=a.tokenExchangeEndpoint}async exchangeToken(a,b,c){let i={grant_type:a.grantType,resource:a.resource,audience:a.audience,scope:a.scope?.join(" "),requested_token_type:a.requestedTokenType,subject_token:a.subjectToken,subject_token_type:a.subjectTokenType,actor_token:a.actingParty?.actorToken,actor_token_type:a.actingParty?.actorTokenType,options:c&&JSON.stringify(c)},j={...h.RETRY_CONFIG,url:this.#p.toString(),method:"POST",headers:b,data:new URLSearchParams((0,g.removeUndefinedValuesInObject)(i)),responseType:"json"};e.AuthClient.setMethodName(j,"exchangeToken"),this.applyClientAuthenticationOptions(j);try{let a=await this.transporter.request(j),b=a.data;return b.res=a,b}catch(a){if(a instanceof d.GaxiosError&&a.response)throw(0,f.getErrorFromOAuthErrorResponse)(a.response.data,a);throw a}}}b.StsCredentials=h},32422:function(a,b,c){"use strict";var d=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),e=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||d(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),b.GoogleAuth=b.auth=b.PassThroughClient=b.ExternalAccountAuthorizedUserClient=b.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=b.ExecutableError=b.PluggableAuthClient=b.DownscopedClient=b.BaseExternalAccountClient=b.ExternalAccountClient=b.IdentityPoolClient=b.AwsRequestSigner=b.AwsClient=b.UserRefreshClient=b.LoginTicket=b.ClientAuthentication=b.OAuth2Client=b.CodeChallengeMethod=b.Impersonated=b.JWT=b.JWTAccess=b.IdTokenClient=b.IAMAuth=b.GCPEnv=b.Compute=b.DEFAULT_UNIVERSE=b.AuthClient=b.gaxios=b.gcpMetadata=void 0;let f=c(80924);Object.defineProperty(b,"GoogleAuth",{enumerable:!0,get:function(){return f.GoogleAuth}}),b.gcpMetadata=c(69348),b.gaxios=c(51596);var g=c(25072);Object.defineProperty(b,"AuthClient",{enumerable:!0,get:function(){return g.AuthClient}}),Object.defineProperty(b,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return g.DEFAULT_UNIVERSE}});var h=c(32927);Object.defineProperty(b,"Compute",{enumerable:!0,get:function(){return h.Compute}});var i=c(35657);Object.defineProperty(b,"GCPEnv",{enumerable:!0,get:function(){return i.GCPEnv}});var j=c(47248);Object.defineProperty(b,"IAMAuth",{enumerable:!0,get:function(){return j.IAMAuth}});var k=c(99660);Object.defineProperty(b,"IdTokenClient",{enumerable:!0,get:function(){return k.IdTokenClient}});var l=c(13618);Object.defineProperty(b,"JWTAccess",{enumerable:!0,get:function(){return l.JWTAccess}});var m=c(42195);Object.defineProperty(b,"JWT",{enumerable:!0,get:function(){return m.JWT}});var n=c(13022);Object.defineProperty(b,"Impersonated",{enumerable:!0,get:function(){return n.Impersonated}});var o=c(85113);Object.defineProperty(b,"CodeChallengeMethod",{enumerable:!0,get:function(){return o.CodeChallengeMethod}}),Object.defineProperty(b,"OAuth2Client",{enumerable:!0,get:function(){return o.OAuth2Client}}),Object.defineProperty(b,"ClientAuthentication",{enumerable:!0,get:function(){return o.ClientAuthentication}});var p=c(24656);Object.defineProperty(b,"LoginTicket",{enumerable:!0,get:function(){return p.LoginTicket}});var q=c(54729);Object.defineProperty(b,"UserRefreshClient",{enumerable:!0,get:function(){return q.UserRefreshClient}});var r=c(3939);Object.defineProperty(b,"AwsClient",{enumerable:!0,get:function(){return r.AwsClient}});var s=c(63133);Object.defineProperty(b,"AwsRequestSigner",{enumerable:!0,get:function(){return s.AwsRequestSigner}});var t=c(84950);Object.defineProperty(b,"IdentityPoolClient",{enumerable:!0,get:function(){return t.IdentityPoolClient}});var u=c(85977);Object.defineProperty(b,"ExternalAccountClient",{enumerable:!0,get:function(){return u.ExternalAccountClient}});var v=c(64876);Object.defineProperty(b,"BaseExternalAccountClient",{enumerable:!0,get:function(){return v.BaseExternalAccountClient}});var w=c(18094);Object.defineProperty(b,"DownscopedClient",{enumerable:!0,get:function(){return w.DownscopedClient}});var x=c(68423);Object.defineProperty(b,"PluggableAuthClient",{enumerable:!0,get:function(){return x.PluggableAuthClient}}),Object.defineProperty(b,"ExecutableError",{enumerable:!0,get:function(){return x.ExecutableError}});var y=c(95954);Object.defineProperty(b,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return y.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}}),Object.defineProperty(b,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return y.ExternalAccountAuthorizedUserClient}});var z=c(87812);Object.defineProperty(b,"PassThroughClient",{enumerable:!0,get:function(){return z.PassThroughClient}}),e(c(17201),b),b.auth=new f.GoogleAuth},32480:(a,b,c)=>{var d=c(79428).Buffer;a.exports=function(a){return"string"==typeof a?a:"number"==typeof a||d.isBuffer(a)?a.toString():JSON.stringify(a)}},32927:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.Compute=void 0;let d=c(51596),e=c(69348),f=c(85113);class g extends f.OAuth2Client{serviceAccountEmail;scopes;constructor(a={}){super(a),this.credentials={expiry_date:1,refresh_token:"compute-placeholder"},this.serviceAccountEmail=a.serviceAccountEmail||"default",this.scopes=Array.isArray(a.scopes)?a.scopes:a.scopes?[a.scopes]:[]}async refreshTokenNoCache(){let a,b=`service-accounts/${this.serviceAccountEmail}/token`;try{let c={property:b};this.scopes.length>0&&(c.params={scopes:this.scopes.join(",")}),a=await e.instance(c)}catch(a){throw a instanceof d.GaxiosError&&(a.message=`Could not refresh access token: ${a.message}`,this.wrapError(a)),a}let c=a;return a&&a.expires_in&&(c.expiry_date=new Date().getTime()+1e3*a.expires_in,delete c.expires_in),this.emit("tokens",c),{tokens:c,res:null}}async fetchIdToken(a){let b,c=`service-accounts/${this.serviceAccountEmail}/identity?format=full&audience=${a}`;try{b=await e.instance({property:c})}catch(a){throw a instanceof Error&&(a.message=`Could not fetch ID token: ${a.message}`),a}return b}wrapError(a){let b=a.response;b&&b.status&&(a.status=b.status,403===b.status?a.message="A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified: "+a.message:404===b.status&&(a.message="A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: "+a.message))}}b.Compute=g},35657:(a,b,c)=>{"use strict";var d,e;let f;Object.defineProperty(b,"__esModule",{value:!0}),b.GCPEnv=void 0,b.clear=function(){f=void 0},b.getEnv=h;let g=c(69348);async function h(){return f||(f=i())}async function i(){d.NONE;return process.env.GAE_SERVICE||process.env.GAE_MODULE_NAME?d.APP_ENGINE:process.env.FUNCTION_NAME||process.env.FUNCTION_TARGET?d.CLOUD_FUNCTIONS:await k()?await j()?d.KUBERNETES_ENGINE:process.env.K_CONFIGURATION?d.CLOUD_RUN:process.env.CLOUD_RUN_JOB?d.CLOUD_RUN_JOBS:d.COMPUTE_ENGINE:d.NONE}async function j(){try{return await g.instance("attributes/cluster-name"),!0}catch(a){return!1}}async function k(){return g.isAvailable()}(e=d||(b.GCPEnv=d={})).APP_ENGINE="APP_ENGINE",e.KUBERNETES_ENGINE="KUBERNETES_ENGINE",e.CLOUD_FUNCTIONS="CLOUD_FUNCTIONS",e.COMPUTE_ENGINE="COMPUTE_ENGINE",e.CLOUD_RUN="CLOUD_RUN",e.CLOUD_RUN_JOBS="CLOUD_RUN_JOBS",e.NONE="NONE"},36543:(a,b,c)=>{"use strict";a.exports={pkg:c(74745)}},39545:(a,b,c)=>{var d=c(10140).Buffer,e=c(27910);function f(a){if(this.buffer=null,this.writable=!0,this.readable=!0,!a)return this.buffer=d.alloc(0),this;if("function"==typeof a.pipe)return this.buffer=d.alloc(0),a.pipe(this),this;if(a.length||"object"==typeof a)return this.buffer=a,this.writable=!1,process.nextTick((function(){this.emit("end",a),this.readable=!1,this.emit("close")}).bind(this)),this;throw TypeError("Unexpected data type ("+typeof a+")")}c(28354).inherits(f,e),f.prototype.write=function(a){this.buffer=d.concat([this.buffer,d.from(a)]),this.emit("data",a)},f.prototype.end=function(a){a&&this.write(a),this.emit("end",a),this.emit("close"),this.writable=!1,this.readable=!1},a.exports=f},42195:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.JWT=void 0;let d=c(17201),e=c(20491),f=c(13618),g=c(85113),h=c(25072);class i extends g.OAuth2Client{email;keyFile;key;keyId;defaultScopes;scopes;scope;subject;gtoken;additionalClaims;useJWTAccessWithScope;defaultServicePath;access;constructor(a={}){super(a),this.email=a.email,this.keyFile=a.keyFile,this.key=a.key,this.keyId=a.keyId,this.scopes=a.scopes,this.subject=a.subject,this.additionalClaims=a.additionalClaims,this.credentials={refresh_token:"jwt-placeholder",expiry_date:1}}createScoped(a){let b=new i(this);return b.scopes=a,b}async getRequestMetadataAsync(a){a=this.defaultServicePath?`https://${this.defaultServicePath}/`:a;let b=!this.hasUserScopes()&&a||this.useJWTAccessWithScope&&this.hasAnyScopes()||this.universeDomain!==h.DEFAULT_UNIVERSE;if(this.subject&&this.universeDomain!==h.DEFAULT_UNIVERSE)throw RangeError(`Service Account user is configured for the credential. Domain-wide delegation is not supported in universes other than ${h.DEFAULT_UNIVERSE}`);if(!this.apiKey&&b)if(this.additionalClaims&&this.additionalClaims.target_audience){let{tokens:a}=await this.refreshToken();return{headers:this.addSharedMetadataHeaders(new Headers({authorization:`Bearer ${a.id_token}`}))}}else{let b;this.access||(this.access=new f.JWTAccess(this.email,this.key,this.keyId,this.eagerRefreshThresholdMillis)),this.hasUserScopes()?b=this.scopes:a||(b=this.defaultScopes);let c=this.useJWTAccessWithScope||this.universeDomain!==h.DEFAULT_UNIVERSE,d=await this.access.getRequestHeaders(a??void 0,this.additionalClaims,c?b:void 0);return{headers:this.addSharedMetadataHeaders(d)}}return this.hasAnyScopes()||this.apiKey?super.getRequestMetadataAsync(a):{headers:new Headers}}async fetchIdToken(a){let b=new d.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:{target_audience:a},transporter:this.transporter});if(await b.getToken({forceRefresh:!0}),!b.idToken)throw Error("Unknown error: Failed to fetch ID token");return b.idToken}hasUserScopes(){return!!this.scopes&&this.scopes.length>0}hasAnyScopes(){return!!this.scopes&&!!(this.scopes.length>0)||!!this.defaultScopes&&!!(this.defaultScopes.length>0)}authorize(a){if(!a)return this.authorizeAsync();this.authorizeAsync().then(b=>a(null,b),a)}async authorizeAsync(){let a=await this.refreshToken();if(!a)throw Error("No result returned");return this.credentials=a.tokens,this.credentials.refresh_token="jwt-placeholder",this.key=this.gtoken.googleTokenOptions?.key,this.email=this.gtoken.googleTokenOptions?.iss,a.tokens}async refreshTokenNoCache(){let a=this.createGToken(),b={access_token:(await a.getToken({forceRefresh:this.isTokenExpiring()})).access_token,token_type:"Bearer",expiry_date:a.expiresAt,id_token:a.idToken};return this.emit("tokens",b),{res:null,tokens:b}}createGToken(){return this.gtoken||(this.gtoken=new d.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:this.additionalClaims,transporter:this.transporter})),this.gtoken}fromJSON(a){if(!a)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!a.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!a.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=a.client_email,this.key=a.private_key,this.keyId=a.private_key_id,this.projectId=a.project_id,this.quotaProjectId=a.quota_project_id,this.universeDomain=a.universe_domain||this.universeDomain}fromStream(a,b){if(!b)return this.fromStreamAsync(a);this.fromStreamAsync(a).then(()=>b(),b)}fromStreamAsync(a){return new Promise((b,c)=>{if(!a)throw Error("Must pass in a stream containing the service account auth settings.");let d="";a.setEncoding("utf8").on("error",c).on("data",a=>d+=a).on("end",()=>{try{let a=JSON.parse(d);this.fromJSON(a),b()}catch(a){c(a)}})})}fromAPIKey(a){if("string"!=typeof a)throw Error("Must provide an API Key string.");this.apiKey=a}async getCredentials(){if(this.key)return{private_key:this.key,client_email:this.email};if(this.keyFile){this.createGToken();let a=await (0,e.getCredentials)(this.keyFile);return{private_key:a.privateKey,client_email:a.clientEmail}}throw Error("A key or a keyFile must be provided to getCredentials.")}}b.JWT=i},43588:(a,b,c)=>{"use strict";function d(a){return a.totalTokens||a.input+a.output+a.cacheRead+a.cacheWrite}function e(a){try{return JSON.stringify(a)??"undefined"}catch{return"[unserializable]"}}function f(a){return Math.ceil(a.length/4)}c.d(b,{xw:()=>l,QP:()=>k,Yx:()=>j});function g(a){let b=0;if("user"===a.role||"toolResult"===a.role)return Math.ceil(function(a){if("string"==typeof a)return a.length;let b=0;for(let c of a)b+="text"===c.type?c.text.length:4800;return b}(a.content)/4);for(let c of a.content)"text"===c.type?b+=c.text.length:"thinking"===c.type?b+=c.thinking.length:b+=c.name.length+e(c.arguments).length;return Math.ceil(b/4)}function h(a){let b=function(a){let b,c=-1/0;for(let e=0;e<a.length;e++){let f=a[e];"assistant"===f.role&&f.timestamp>=c&&"aborted"!==f.stopReason&&"error"!==f.stopReason&&d(f.usage)>0&&(b={usage:f.usage,index:e}),c=Math.max(c,f.timestamp)}return b}(a);if(b){let c=d(b.usage),e=0;for(let c=b.index+1;c<a.length;c++)e+=g(a[c]);return{tokens:c+e,usageTokens:c,trailingTokens:e,lastUsageIndex:b.index}}let c=0;for(let b of a)c+=g(b);return{tokens:c,usageTokens:0,trailingTokens:c,lastUsageIndex:null}}function i(a){return a&&0!==a.length?f(e(a)):0}function j(a,b,c){return a.contextWindow<=0?Math.max(1,c):Math.min(c,Math.max(1,a.contextWindow-function(a){if(Array.isArray(a))return h(a);let b=h(a.messages);if(null!==b.lastUsageIndex){let c=new Set(a.messages.slice(b.lastUsageIndex+1).filter(a=>"toolResult"===a.role).flatMap(a=>a.addedToolNames??[])),d=i(a.tools?.filter(a=>c.has(a.name)));return{tokens:b.tokens+d,usageTokens:b.usageTokens,trailingTokens:b.trailingTokens+d,lastUsageIndex:b.lastUsageIndex}}let c=(a.systemPrompt?f(a.systemPrompt):0)+i(a.tools);return{tokens:b.tokens+c,usageTokens:b.usageTokens,trailingTokens:b.trailingTokens+c,lastUsageIndex:b.lastUsageIndex}}(b).tokens-4096))}function k(a,b,c,d){return{temperature:c?.temperature,maxTokens:j(a,b,c?.maxTokens??a.maxTokens),signal:c?.signal,apiKey:d||c?.apiKey,transport:c?.transport,cacheRetention:c?.cacheRetention,sessionId:c?.sessionId,headers:c?.headers,onPayload:c?.onPayload,onResponse:c?.onResponse,timeoutMs:c?.timeoutMs,websocketConnectTimeoutMs:c?.websocketConnectTimeoutMs,maxRetries:c?.maxRetries,maxRetryDelayMs:c?.maxRetryDelayMs,metadata:c?.metadata,env:c?.env}}function l(a,b,c,d){let e={minimal:1024,low:2048,medium:8192,high:16384,...d}["xhigh"===c||"max"===c?"high":c],f=void 0===a?b:Math.min(a+e,b);return f<=e&&(e=Math.max(0,f-1024)),{maxTokens:f,thinkingBudget:e}}},43699:function(a,b,c){"use strict";var d=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(b,"__esModule",{value:!0}),b.GaxiosError=b.GAXIOS_ERROR_SYMBOL=void 0,b.defaultErrorRedactor=function a(b){let c="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";function d(a){a&&a.forEach((b,d)=>{(/^authentication$/i.test(d)||/^authorization$/i.test(d)||/secret/i.test(d))&&a.set(d,c)})}function e(a,b){if("object"==typeof a&&null!==a&&"string"==typeof a[b]){let d=a[b];(/grant_type=/i.test(d)||/assertion=/i.test(d)||/secret/i.test(d))&&(a[b]=c)}}function f(a){!a||"object"!=typeof a||(a instanceof FormData||a instanceof URLSearchParams||"forEach"in a&&"set"in a?a.forEach((b,d)=>{(["grant_type","assertion"].includes(d)||/secret/.test(d))&&a.set(d,c)}):("grant_type"in a&&(a.grant_type=c),"assertion"in a&&(a.assertion=c),"client_secret"in a&&(a.client_secret=c)))}return b.config&&(d(b.config.headers),e(b.config,"data"),f(b.config.data),e(b.config,"body"),f(b.config.body),b.config.url.searchParams.has("token")&&b.config.url.searchParams.set("token",c),b.config.url.searchParams.has("client_secret")&&b.config.url.searchParams.set("client_secret",c)),b.response&&(a({config:b.response.config}),d(b.response.headers),b.response.bodyUsed&&(e(b.response,"data"),f(b.response.data))),b};let e=d(c(73482)),f=d(c(36543)).default.pkg;b.GAXIOS_ERROR_SYMBOL=Symbol.for(`${f.name}-gaxios-error`);class g extends Error{config;response;code;status;error;[b.GAXIOS_ERROR_SYMBOL]=f.version;static[Symbol.hasInstance](a){return!!a&&"object"==typeof a&&b.GAXIOS_ERROR_SYMBOL in a&&a[b.GAXIOS_ERROR_SYMBOL]===f.version||Function.prototype[Symbol.hasInstance].call(g,a)}constructor(a,b,c,d){if(super(a,{cause:d}),this.config=b,this.response=c,this.error=d instanceof Error?d:void 0,this.config=(0,e.default)(!0,{},b),this.response&&(this.response.config=(0,e.default)(!0,{},this.response.config)),this.response){try{this.response.data=function(a,b){switch(a){case"stream":default:return b;case"json":return JSON.parse(JSON.stringify(b));case"arraybuffer":return JSON.parse(Buffer.from(b).toString("utf8"));case"blob":return JSON.parse(b.text())}}(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}d instanceof DOMException?this.code=d.name:d&&"object"==typeof d&&"code"in d&&("string"==typeof d.code||"number"==typeof d.code)&&(this.code=d.code)}static extractAPIErrorFromResponse(a,b="The request failed"){let c=b;if("string"==typeof a.data&&(c=a.data),a.data&&"object"==typeof a.data&&"error"in a.data&&a.data.error&&!a.ok){if("string"==typeof a.data.error)return{message:a.data.error,code:a.status,status:a.statusText};if("object"==typeof a.data.error){c="message"in a.data.error&&"string"==typeof a.data.error.message?a.data.error.message:c;let b="status"in a.data.error&&"string"==typeof a.data.error.status?a.data.error.status:a.statusText,d="code"in a.data.error&&"number"==typeof a.data.error.code?a.data.error.code:a.status;if("errors"in a.data.error&&Array.isArray(a.data.error.errors)){let e=[];for(let b of a.data.error.errors)"object"==typeof b&&"message"in b&&"string"==typeof b.message&&e.push(b.message);return Object.assign({message:e.join("\n")||c,code:d,status:b},a.data.error)}return Object.assign({message:c,code:d,status:b},a.data.error)}}return{message:c,code:a.status,status:a.statusText}}}b.GaxiosError=g},45633:(a,b,c)=>{"use strict";let{isUtf8:d}=c(79428),{hasBlob:e}=c(89721);function f(a){let b=a.length,c=0;for(;c<b;)if((128&a[c])==0)c++;else if((224&a[c])==192){if(c+1===b||(192&a[c+1])!=128||(254&a[c])==192)return!1;c+=2}else if((240&a[c])==224){if(c+2>=b||(192&a[c+1])!=128||(192&a[c+2])!=128||224===a[c]&&(224&a[c+1])==128||237===a[c]&&(224&a[c+1])==160)return!1;c+=3}else{if((248&a[c])!=240||c+3>=b||(192&a[c+1])!=128||(192&a[c+2])!=128||(192&a[c+3])!=128||240===a[c]&&(240&a[c+1])==128||244===a[c]&&a[c+1]>143||a[c]>244)return!1;c+=4}return!0}if(a.exports={isBlob:function(a){return e&&"object"==typeof a&&"function"==typeof a.arrayBuffer&&"string"==typeof a.type&&"function"==typeof a.stream&&("Blob"===a[Symbol.toStringTag]||"File"===a[Symbol.toStringTag])},isValidStatusCode:function(a){return a>=1e3&&a<=1014&&1004!==a&&1005!==a&&1006!==a||a>=3e3&&a<=4999},isValidUTF8:f,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},d)a.exports.isValidUTF8=function(a){return a.length<24?f(a):d(a)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let b=c(13072);a.exports.isValidUTF8=function(a){return a.length<32?f(a):b(a)}}catch(a){}},45722:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.PluggableAuthHandler=b.ExecutableError=void 0;let d=c(92301),e=c(79646),f=c(29021);class g extends Error{code;constructor(a,b){super(`The executable failed with exit code: ${b} and error message: ${a}.`),this.code=b,Object.setPrototypeOf(this,new.target.prototype)}}b.ExecutableError=g;class h{commandComponents;timeoutMillis;outputFile;constructor(a){if(!a.command)throw Error("No command provided.");if(this.commandComponents=h.parseCommand(a.command),this.timeoutMillis=a.timeoutMillis,!this.timeoutMillis)throw Error("No timeoutMillis provided.");this.outputFile=a.outputFile}retrieveResponseFromExecutable(a){return new Promise((b,c)=>{let f=e.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(a)}}),h="";f.stdout.on("data",a=>{h+=a}),f.stderr.on("data",a=>{h+=a});let i=setTimeout(()=>(f.removeAllListeners(),f.kill(),c(Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);f.on("close",a=>{if(clearTimeout(i),0!==a)return c(new g(h,a.toString()));try{let a=JSON.parse(h),c=new d.ExecutableResponse(a);return b(c)}catch(a){if(a instanceof d.ExecutableResponseError)return c(a);return c(new d.ExecutableResponseError(`The executable returned an invalid response: ${h}`))}})})}async retrieveCachedResponse(){let a;if(!this.outputFile||0===this.outputFile.length)return;try{a=await f.promises.realpath(this.outputFile)}catch{return}if(!(await f.promises.lstat(a)).isFile())return;let b=await f.promises.readFile(a,{encoding:"utf8"});if(""!==b)try{let a=JSON.parse(b);if(new d.ExecutableResponse(a).isValid())return new d.ExecutableResponse(a);return}catch(a){if(a instanceof d.ExecutableResponseError)throw a;throw new d.ExecutableResponseError(`The output file contained an invalid response: ${b}`)}}static parseCommand(a){let b=a.match(/(?:[^\s"]+|"[^"]*")+/g);if(!b)throw Error(`Provided command: "${a}" could not be parsed.`);for(let a=0;a<b.length;a++)'"'===b[a][0]&&'"'===b[a].slice(-1)&&(b[a]=b[a].slice(1,-1));return b}}b.PluggableAuthHandler=h},47248:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.IAMAuth=void 0;class c{selector;token;constructor(a,b){this.selector=a,this.token=b,this.selector=a,this.token=b}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}b.IAMAuth=c},48902:(a,b,c)=>{"use strict";c(27879);let{Duplex:d}=c(27910);function e(a){a.emit("close")}function f(){!this.destroyed&&this._writableState.finished&&this.destroy()}function g(a){this.removeListener("error",g),this.destroy(),0===this.listenerCount("error")&&this.emit("error",a)}a.exports=function(a,b){let c=!0,h=new d({...b,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return a.on("message",function(b,c){let d=!c&&h._readableState.objectMode?b.toString():b;h.push(d)||a.pause()}),a.once("error",function(a){h.destroyed||(c=!1,h.destroy(a))}),a.once("close",function(){h.destroyed||h.push(null)}),h._destroy=function(b,d){if(a.readyState===a.CLOSED){d(b),process.nextTick(e,h);return}let f=!1;a.once("error",function(a){f=!0,d(a)}),a.once("close",function(){f||d(b),process.nextTick(e,h)}),c&&a.terminate()},h._final=function(b){a.readyState===a.CONNECTING?a.once("open",function(){h._final(b)}):null!==a._socket&&(a._socket._writableState.finished?(b(),h._readableState.endEmitted&&h.destroy()):(a._socket.once("finish",function(){b()}),a.close()))},h._read=function(){a.isPaused&&a.resume()},h._write=function(b,c,d){a.readyState===a.CONNECTING?a.once("open",function(){h._write(b,c,d)}):a.send(b,d)},h.on("end",f),h.on("error",g),h}},49478:(a,b,c)=>{"use strict";let d,e=c(74075),f=c(14669),g=c(86716),{kStatusCode:h}=c(89721),i=Buffer[Symbol.species],j=Buffer.from([0,0,255,255]),k=Symbol("permessage-deflate"),l=Symbol("total-length"),m=Symbol("callback"),n=Symbol("buffers"),o=Symbol("error");class p{constructor(a){this._options=a||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._maxPayload=0|this._options.maxPayload,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,d||(d=new g(void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10))}static get extensionName(){return"permessage-deflate"}offer(){let a={};return this._options.serverNoContextTakeover&&(a.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(a.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(a.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?a.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(a.client_max_window_bits=!0),a}accept(a){return a=this.normalizeParams(a),this.params=this._isServer?this.acceptAsServer(a):this.acceptAsClient(a),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let a=this._deflate[m];this._deflate.close(),this._deflate=null,a&&a(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(a){let b=this._options,c=a.find(a=>(!1!==b.serverNoContextTakeover||!a.server_no_context_takeover)&&(!a.server_max_window_bits||!1!==b.serverMaxWindowBits&&("number"!=typeof b.serverMaxWindowBits||!(b.serverMaxWindowBits>a.server_max_window_bits)))&&("number"!=typeof b.clientMaxWindowBits||!!a.client_max_window_bits));if(!c)throw Error("None of the extension offers can be accepted");return b.serverNoContextTakeover&&(c.server_no_context_takeover=!0),b.clientNoContextTakeover&&(c.client_no_context_takeover=!0),"number"==typeof b.serverMaxWindowBits&&(c.server_max_window_bits=b.serverMaxWindowBits),"number"==typeof b.clientMaxWindowBits?c.client_max_window_bits=b.clientMaxWindowBits:(!0===c.client_max_window_bits||!1===b.clientMaxWindowBits)&&delete c.client_max_window_bits,c}acceptAsClient(a){let b=a[0];if(!1===this._options.clientNoContextTakeover&&b.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(b.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&b.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(b.client_max_window_bits=this._options.clientMaxWindowBits);return b}normalizeParams(a){return a.forEach(a=>{Object.keys(a).forEach(b=>{let c=a[b];if(c.length>1)throw Error(`Parameter "${b}" must have only a single value`);if(c=c[0],"client_max_window_bits"===b){if(!0!==c){let a=+c;if(!Number.isInteger(a)||a<8||a>15)throw TypeError(`Invalid value for parameter "${b}": ${c}`);c=a}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${b}": ${c}`)}else if("server_max_window_bits"===b){let a=+c;if(!Number.isInteger(a)||a<8||a>15)throw TypeError(`Invalid value for parameter "${b}": ${c}`);c=a}else if("client_no_context_takeover"===b||"server_no_context_takeover"===b){if(!0!==c)throw TypeError(`Invalid value for parameter "${b}": ${c}`)}else throw Error(`Unknown parameter "${b}"`);a[b]=c})}),a}decompress(a,b,c){d.add(d=>{this._decompress(a,b,(a,b)=>{d(),c(a,b)})})}compress(a,b,c){d.add(d=>{this._compress(a,b,(a,b)=>{d(),c(a,b)})})}_decompress(a,b,c){let d=this._isServer?"client":"server";if(!this._inflate){let a=`${d}_max_window_bits`,b="number"!=typeof this.params[a]?e.Z_DEFAULT_WINDOWBITS:this.params[a];this._inflate=e.createInflateRaw({...this._options.zlibInflateOptions,windowBits:b}),this._inflate[k]=this,this._inflate[l]=0,this._inflate[n]=[],this._inflate.on("error",s),this._inflate.on("data",r)}this._inflate[m]=c,this._inflate.write(a),b&&this._inflate.write(j),this._inflate.flush(()=>{let a=this._inflate[o];if(a){this._inflate.close(),this._inflate=null,c(a);return}let e=f.concat(this._inflate[n],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[n]=[],b&&this.params[`${d}_no_context_takeover`]&&this._inflate.reset()),c(null,e)})}_compress(a,b,c){let d=this._isServer?"server":"client";if(!this._deflate){let a=`${d}_max_window_bits`,b="number"!=typeof this.params[a]?e.Z_DEFAULT_WINDOWBITS:this.params[a];this._deflate=e.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:b}),this._deflate[l]=0,this._deflate[n]=[],this._deflate.on("data",q)}this._deflate[m]=c,this._deflate.write(a),this._deflate.flush(e.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let a=f.concat(this._deflate[n],this._deflate[l]);b&&(a=new i(a.buffer,a.byteOffset,a.length-4)),this._deflate[m]=null,this._deflate[l]=0,this._deflate[n]=[],b&&this.params[`${d}_no_context_takeover`]&&this._deflate.reset(),c(null,a)})}}function q(a){this[n].push(a),this[l]+=a.length}function r(a){(this[l]+=a.length,this[k]._maxPayload<1||this[l]<=this[k]._maxPayload)?this[n].push(a):(this[o]=RangeError("Max payload size exceeded"),this[o].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[o][h]=1009,this.removeListener("data",r),this.reset())}function s(a){(this[k]._inflate=null,this[o])?this[m](this[o]):(a[h]=1007,this[m](a))}a.exports=p},51596:function(a,b,c){"use strict";var d=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),e=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||d(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),b.instance=b.Gaxios=b.GaxiosError=void 0,b.request=h;let f=c(30787);Object.defineProperty(b,"Gaxios",{enumerable:!0,get:function(){return f.Gaxios}});var g=c(43699);async function h(a){return b.instance.request(a)}Object.defineProperty(b,"GaxiosError",{enumerable:!0,get:function(){return g.GaxiosError}}),e(c(13859),b),b.instance=new f.Gaxios},53163:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.GCE_LINUX_BIOS_PATHS=void 0,b.isGoogleCloudServerless=g,b.isGoogleComputeEngineLinux=h,b.isGoogleComputeEngineMACAddress=i,b.isGoogleComputeEngine=j,b.detectGCPResidency=function(){return g()||j()};let d=c(29021),e=c(21820);b.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};let f=/^42:01/;function g(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function h(){if("linux"!==(0,e.platform)())return!1;try{(0,d.statSync)(b.GCE_LINUX_BIOS_PATHS.BIOS_DATE);let a=(0,d.readFileSync)(b.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,"utf8");return/Google/.test(a)}catch{return!1}}function i(){for(let a of Object.values((0,e.networkInterfaces)()))if(a){for(let{mac:b}of a)if(f.test(b))return!0}return!1}function j(){return h()||i()}},54729:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.UserRefreshClient=b.USER_REFRESH_ACCOUNT_TYPE=void 0;let d=c(85113),e=c(25072);b.USER_REFRESH_ACCOUNT_TYPE="authorized_user";class f extends d.OAuth2Client{_refreshToken;constructor(a,b,c,d,e){const f=a&&"object"==typeof a?a:{clientId:a,clientSecret:b,refreshToken:c,eagerRefreshThresholdMillis:d,forceRefreshOnFailure:e};super(f),this._refreshToken=f.refreshToken,this.credentials.refresh_token=f.refreshToken}async refreshTokenNoCache(){return super.refreshTokenNoCache(this._refreshToken)}async fetchIdToken(a){let b={...f.RETRY_CONFIG,url:this.endpoints.oauth2TokenUrl,method:"POST",data:new URLSearchParams({client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token",refresh_token:this._refreshToken,target_audience:a}),responseType:"json"};return e.AuthClient.setMethodName(b,"fetchIdToken"),(await this.transporter.request(b)).data.id_token}fromJSON(a){if(!a)throw Error("Must pass in a JSON object containing the user refresh token");if("authorized_user"!==a.type)throw Error('The incoming JSON object does not have the "authorized_user" type');if(!a.client_id)throw Error("The incoming JSON object does not contain a client_id field");if(!a.client_secret)throw Error("The incoming JSON object does not contain a client_secret field");if(!a.refresh_token)throw Error("The incoming JSON object does not contain a refresh_token field");this._clientId=a.client_id,this._clientSecret=a.client_secret,this._refreshToken=a.refresh_token,this.credentials.refresh_token=a.refresh_token,this.quotaProjectId=a.quota_project_id,this.universeDomain=a.universe_domain||this.universeDomain}fromStream(a,b){if(!b)return this.fromStreamAsync(a);this.fromStreamAsync(a).then(()=>b(),b)}async fromStreamAsync(a){return new Promise((b,c)=>{if(!a)return c(Error("Must pass in a stream containing the user refresh token."));let d="";a.setEncoding("utf8").on("error",c).on("data",a=>d+=a).on("end",()=>{try{let a=JSON.parse(d);return this.fromJSON(a),b()}catch(a){return c(a)}})})}static fromJSON(a){let b=new f;return b.fromJSON(a),b}}b.UserRefreshClient=f},55686:(a,b,c)=>{"use strict";let d,e,f,g;c.d(b,{eD:()=>aL,ce:()=>aE,M4:()=>eR,r:()=>a2,HL:()=>aF});var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,aA,aB,aC,aD,aE,aF,aG,aH,aI,aJ,aK,aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,aX,aY,aZ,a$,a_,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw=c(78289),bx=c(32422),by=c(29021),bz=c(79748),bA=c(26238),bB=c(22949);c(48902),c(3969),c(49478),c(93959),c(25467),c(7686);var bC=c(27879);c(57827);var bD=c(33873);class bE{}function bF(a,b){return a.replace(/\{([^}]+)\}/g,(a,c)=>{if(Object.prototype.hasOwnProperty.call(b,c)){let a=b[c];return null!=a?String(a):""}throw Error(`Key '${c}' not found in valueMap.`)})}function bG(a,b,c){for(let d=0;d<b.length-1;d++){let e=b[d];if(e.endsWith("[]")){let f=e.slice(0,-2);if(!(f in a))if(Array.isArray(c))a[f]=Array.from({length:c.length},()=>({}));else throw Error(`Value must be a list given an array path ${e}`);if(Array.isArray(a[f])){let e=a[f];if(Array.isArray(c))for(let a=0;a<e.length;a++)bG(e[a],b.slice(d+1),c[a]);else for(let a of e)bG(a,b.slice(d+1),c)}return}if(e.endsWith("[0]")){let f=e.slice(0,-3);f in a||(a[f]=[{}]),bG(a[f][0],b.slice(d+1),c);return}a[e]&&"object"==typeof a[e]||(a[e]={}),a=a[e]}let d=b[b.length-1],e=a[d];if(void 0!==e){if(!c||"object"==typeof c&&0===Object.keys(c).length||c===e)return;if("object"==typeof e&&"object"==typeof c&&null!==e&&null!==c)Object.assign(e,c);else throw Error(`Cannot set value for an existing key. Key: ${d}`)}else"_self"!==d||"object"!=typeof c||null===c||Array.isArray(c)?a[d]=c:Object.assign(a,c)}function bH(a,b,c){try{if(1===b.length&&"_self"===b[0])return a;for(let d=0;d<b.length;d++){if("object"!=typeof a||null===a)return c;let e=b[d];if(e.endsWith("[]")){let f=e.slice(0,-2);if(!(f in a))return c;{let e=a[f];if(!Array.isArray(e))return c;return e.map(a=>bH(a,b.slice(d+1),c))}}a=a[e]}return a}catch(a){if(a instanceof TypeError)return c;throw a}}function bI(a){if("string"!=typeof a)throw Error("fromImageBytes must be a string");return a}function bJ(a){var b;let c,d,e,f,g={},h=bH(a,["name"]);null!=h&&bG(g,["name"],h);let i=bH(a,["metadata"]);null!=i&&bG(g,["metadata"],i);let j=bH(a,["done"]);null!=j&&bG(g,["done"],j);let k=bH(a,["error"]);null!=k&&bG(g,["error"],k);let l=bH(a,["response"]);return null!=l&&bG(g,["response"],(c={},null!=(d=bH(b=l,["sdkHttpResponse"]))&&bG(c,["sdkHttpResponse"],d),null!=(e=bH(b,["parent"]))&&bG(c,["parent"],e),null!=(f=bH(b,["documentName"]))&&bG(c,["documentName"],f),c)),g}(h=at||(at={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",h.PYTHON="PYTHON",(i=au||(au={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",(j=av||(av={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",j.SILENT="SILENT",j.WHEN_IDLE="WHEN_IDLE",j.INTERRUPT="INTERRUPT",(k=aw||(aw={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",k.STRING="STRING",k.NUMBER="NUMBER",k.INTEGER="INTEGER",k.BOOLEAN="BOOLEAN",k.ARRAY="ARRAY",k.OBJECT="OBJECT",k.NULL="NULL",(l=ax||(ax={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",l.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",(m=ay||(ay={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",m.NO_AUTH="NO_AUTH",m.API_KEY_AUTH="API_KEY_AUTH",m.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",m.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",m.OAUTH="OAUTH",m.OIDC_AUTH="OIDC_AUTH",(n=az||(az={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",n.HTTP_IN_QUERY="HTTP_IN_QUERY",n.HTTP_IN_HEADER="HTTP_IN_HEADER",n.HTTP_IN_PATH="HTTP_IN_PATH",n.HTTP_IN_BODY="HTTP_IN_BODY",n.HTTP_IN_COOKIE="HTTP_IN_COOKIE",(o=aA||(aA={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",o.SIMPLE_SEARCH="SIMPLE_SEARCH",o.ELASTIC_SEARCH="ELASTIC_SEARCH",(p=aB||(aB={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",p.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",p.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",p.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",p.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",p.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",p.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",(q=aC||(aC={})).UNSPECIFIED="UNSPECIFIED",q.BLOCKING="BLOCKING",q.NON_BLOCKING="NON_BLOCKING",(r=aD||(aD={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",r.MODE_DYNAMIC="MODE_DYNAMIC",(s=aE||(aE={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",s.AUTO="AUTO",s.ANY="ANY",s.NONE="NONE",s.VALIDATED="VALIDATED",(t=aF||(aF={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",t.MINIMAL="MINIMAL",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH",(u=aG||(aG={})).DONT_ALLOW="DONT_ALLOW",u.ALLOW_ADULT="ALLOW_ADULT",u.ALLOW_ALL="ALLOW_ALL",(v=aH||(aH={})).PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",v.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",v.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE",(w=aI||(aI={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",w.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",w.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",w.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",w.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",w.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",w.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",w.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",w.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",w.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",w.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",(x=aJ||(aJ={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",x.SEVERITY="SEVERITY",x.PROBABILITY="PROBABILITY",(y=aK||(aK={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",y.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",y.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",y.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",y.BLOCK_NONE="BLOCK_NONE",y.OFF="OFF",(z=aL||(aL={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",z.STOP="STOP",z.MAX_TOKENS="MAX_TOKENS",z.SAFETY="SAFETY",z.RECITATION="RECITATION",z.LANGUAGE="LANGUAGE",z.OTHER="OTHER",z.BLOCKLIST="BLOCKLIST",z.PROHIBITED_CONTENT="PROHIBITED_CONTENT",z.SPII="SPII",z.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",z.IMAGE_SAFETY="IMAGE_SAFETY",z.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",z.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",z.NO_IMAGE="NO_IMAGE",z.IMAGE_RECITATION="IMAGE_RECITATION",z.IMAGE_OTHER="IMAGE_OTHER",(A=aM||(aM={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",A.NEGLIGIBLE="NEGLIGIBLE",A.LOW="LOW",A.MEDIUM="MEDIUM",A.HIGH="HIGH",(B=aN||(aN={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",B.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",B.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",B.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",B.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",(C=aO||(aO={})).URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",C.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",C.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",C.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",C.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE",(D=aP||(aP={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",D.SAFETY="SAFETY",D.OTHER="OTHER",D.BLOCKLIST="BLOCKLIST",D.PROHIBITED_CONTENT="PROHIBITED_CONTENT",D.IMAGE_SAFETY="IMAGE_SAFETY",D.MODEL_ARMOR="MODEL_ARMOR",D.JAILBREAK="JAILBREAK",(E=aQ||(aQ={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",E.ON_DEMAND="ON_DEMAND",E.ON_DEMAND_PRIORITY="ON_DEMAND_PRIORITY",E.ON_DEMAND_FLEX="ON_DEMAND_FLEX",E.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",(F=aR||(aR={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",F.TEXT="TEXT",F.IMAGE="IMAGE",F.AUDIO="AUDIO",F.VIDEO="VIDEO",(G=aS||(aS={})).MODEL_STAGE_UNSPECIFIED="MODEL_STAGE_UNSPECIFIED",G.UNSTABLE_EXPERIMENTAL="UNSTABLE_EXPERIMENTAL",G.EXPERIMENTAL="EXPERIMENTAL",G.PREVIEW="PREVIEW",G.STABLE="STABLE",G.LEGACY="LEGACY",G.DEPRECATED="DEPRECATED",G.RETIRED="RETIRED",(H=aT||(aT={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",H.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",H.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",H.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",(I=aU||(aU={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",I.TUNING_MODE_FULL="TUNING_MODE_FULL",I.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",(J=aV||(aV={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",J.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",J.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",J.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",J.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",J.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",J.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",(K=aW||(aW={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",K.JOB_STATE_QUEUED="JOB_STATE_QUEUED",K.JOB_STATE_PENDING="JOB_STATE_PENDING",K.JOB_STATE_RUNNING="JOB_STATE_RUNNING",K.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",K.JOB_STATE_FAILED="JOB_STATE_FAILED",K.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",K.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",K.JOB_STATE_PAUSED="JOB_STATE_PAUSED",K.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",K.JOB_STATE_UPDATING="JOB_STATE_UPDATING",K.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",(L=aX||(aX={})).TUNING_JOB_STATE_UNSPECIFIED="TUNING_JOB_STATE_UNSPECIFIED",L.TUNING_JOB_STATE_WAITING_FOR_QUOTA="TUNING_JOB_STATE_WAITING_FOR_QUOTA",L.TUNING_JOB_STATE_PROCESSING_DATASET="TUNING_JOB_STATE_PROCESSING_DATASET",L.TUNING_JOB_STATE_WAITING_FOR_CAPACITY="TUNING_JOB_STATE_WAITING_FOR_CAPACITY",L.TUNING_JOB_STATE_TUNING="TUNING_JOB_STATE_TUNING",L.TUNING_JOB_STATE_POST_PROCESSING="TUNING_JOB_STATE_POST_PROCESSING",(M=aY||(aY={})).AGGREGATION_METRIC_UNSPECIFIED="AGGREGATION_METRIC_UNSPECIFIED",M.AVERAGE="AVERAGE",M.MODE="MODE",M.STANDARD_DEVIATION="STANDARD_DEVIATION",M.VARIANCE="VARIANCE",M.MINIMUM="MINIMUM",M.MAXIMUM="MAXIMUM",M.MEDIAN="MEDIAN",M.PERCENTILE_P90="PERCENTILE_P90",M.PERCENTILE_P95="PERCENTILE_P95",M.PERCENTILE_P99="PERCENTILE_P99",(N=aZ||(aZ={})).PAIRWISE_CHOICE_UNSPECIFIED="PAIRWISE_CHOICE_UNSPECIFIED",N.BASELINE="BASELINE",N.CANDIDATE="CANDIDATE",N.TIE="TIE",(O=a$||(a$={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",O.TUNING_TASK_I2V="TUNING_TASK_I2V",O.TUNING_TASK_T2V="TUNING_TASK_T2V",O.TUNING_TASK_R2V="TUNING_TASK_R2V",(P=a_||(a_={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",P.STATE_PENDING="STATE_PENDING",P.STATE_ACTIVE="STATE_ACTIVE",P.STATE_FAILED="STATE_FAILED",(Q=a0||(a0={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",Q.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",Q.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",Q.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",Q.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",(R=a1||(a1={})).TOOL_TYPE_UNSPECIFIED="TOOL_TYPE_UNSPECIFIED",R.GOOGLE_SEARCH_WEB="GOOGLE_SEARCH_WEB",R.GOOGLE_SEARCH_IMAGE="GOOGLE_SEARCH_IMAGE",R.URL_CONTEXT="URL_CONTEXT",R.GOOGLE_MAPS="GOOGLE_MAPS",R.FILE_SEARCH="FILE_SEARCH",(a2||(a2={})).COLLECTION="COLLECTION",(S=a3||(a3={})).UNSPECIFIED="unspecified",S.FLEX="flex",S.STANDARD="standard",S.PRIORITY="priority",(T=a4||(a4={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",T.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",T.BALANCED="BALANCED",T.PRIORITIZE_COST="PRIORITIZE_COST",(U=a5||(a5={})).PREDICT="PREDICT",U.EMBED_CONTENT="EMBED_CONTENT",(V=a6||(a6={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",V.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",V.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",V.BLOCK_NONE="BLOCK_NONE",(W=a7||(a7={})).auto="auto",W.en="en",W.ja="ja",W.ko="ko",W.hi="hi",W.zh="zh",W.pt="pt",W.es="es",(X=a8||(a8={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",X.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",X.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",X.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",X.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",(Y=a9||(a9={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",Y.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",Y.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",Y.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",(Z=ba||(ba={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",Z.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",Z.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",Z.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",($=bb||(bb={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",$.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",$.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",$.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",$.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",$.EDIT_MODE_STYLE="EDIT_MODE_STYLE",$.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",$.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",(_=bc||(bc={})).FOREGROUND="FOREGROUND",_.BACKGROUND="BACKGROUND",_.PROMPT="PROMPT",_.SEMANTIC="SEMANTIC",_.INTERACTIVE="INTERACTIVE",(aa=bd||(bd={})).ASSET="ASSET",aa.STYLE="STYLE",(ab=be||(be={})).INSERT="INSERT",ab.REMOVE="REMOVE",ab.REMOVE_STATIC="REMOVE_STATIC",ab.OUTPAINT="OUTPAINT",(ac=bf||(bf={})).OPTIMIZED="OPTIMIZED",ac.LOSSLESS="LOSSLESS",(ad=bg||(bg={})).CROP="CROP",ad.PAD="PAD",(ae=bh||(bh={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",ae.PREFERENCE_TUNING="PREFERENCE_TUNING",ae.DISTILLATION="DISTILLATION",(af=bi||(bi={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",af.PROCESSING="PROCESSING",af.ACTIVE="ACTIVE",af.FAILED="FAILED",(ag=bj||(bj={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",ag.UPLOADED="UPLOADED",ag.GENERATED="GENERATED",ag.REGISTERED="REGISTERED",(ah=bk||(bk={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",ah.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",ah.RESPONSE_REJECTED="RESPONSE_REJECTED",ah.NEED_MORE_INPUT="NEED_MORE_INPUT",ah.PROHIBITED_INPUT_CONTENT="PROHIBITED_INPUT_CONTENT",ah.IMAGE_PROHIBITED_INPUT_CONTENT="IMAGE_PROHIBITED_INPUT_CONTENT",ah.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED="INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED",ah.INPUT_IMAGE_CELEBRITY="INPUT_IMAGE_CELEBRITY",ah.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED="INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED",ah.INPUT_TEXT_NCII_PROHIBITED="INPUT_TEXT_NCII_PROHIBITED",ah.INPUT_OTHER="INPUT_OTHER",ah.INPUT_IP_PROHIBITED="INPUT_IP_PROHIBITED",ah.BLOCKLIST="BLOCKLIST",ah.UNSAFE_PROMPT_FOR_IMAGE_GENERATION="UNSAFE_PROMPT_FOR_IMAGE_GENERATION",ah.GENERATED_IMAGE_SAFETY="GENERATED_IMAGE_SAFETY",ah.GENERATED_CONTENT_SAFETY="GENERATED_CONTENT_SAFETY",ah.GENERATED_AUDIO_SAFETY="GENERATED_AUDIO_SAFETY",ah.GENERATED_VIDEO_SAFETY="GENERATED_VIDEO_SAFETY",ah.GENERATED_CONTENT_PROHIBITED="GENERATED_CONTENT_PROHIBITED",ah.GENERATED_CONTENT_BLOCKLIST="GENERATED_CONTENT_BLOCKLIST",ah.GENERATED_IMAGE_PROHIBITED="GENERATED_IMAGE_PROHIBITED",ah.GENERATED_IMAGE_CELEBRITY="GENERATED_IMAGE_CELEBRITY",ah.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER="GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER",ah.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE="GENERATED_IMAGE_IDENTIFIABLE_PEOPLE",ah.GENERATED_IMAGE_MINORS="GENERATED_IMAGE_MINORS",ah.OUTPUT_IMAGE_IP_PROHIBITED="OUTPUT_IMAGE_IP_PROHIBITED",ah.GENERATED_OTHER="GENERATED_OTHER",ah.MAX_REGENERATION_REACHED="MAX_REGENERATION_REACHED",(ai=bl||(bl={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",ai.TEXT="TEXT",ai.IMAGE="IMAGE",ai.VIDEO="VIDEO",ai.AUDIO="AUDIO",ai.DOCUMENT="DOCUMENT",(aj=bm||(bm={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",aj.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",aj.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",(ak=bn||(bn={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",ak.ACTIVITY_START="ACTIVITY_START",ak.ACTIVITY_END="ACTIVITY_END",(al=bo||(bo={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",al.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",al.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",(am=bp||(bp={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",am.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",am.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",(an=bq||(bq={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",an.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",an.NO_INTERRUPTION="NO_INTERRUPTION",(ao=br||(br={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",ao.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",ao.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",ao.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO="TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO",(ap=bs||(bs={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",ap.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",ap.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",ap.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",ap.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",ap.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",ap.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",ap.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",ap.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",ap.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",ap.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",ap.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",ap.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",(aq=bt||(bt={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",aq.QUALITY="QUALITY",aq.DIVERSITY="DIVERSITY",aq.VOCALIZATION="VOCALIZATION",(ar=bu||(bu={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",ar.PLAY="PLAY",ar.PAUSE="PAUSE",ar.STOP="STOP",ar.RESET_CONTEXT="RESET_CONTEXT";class bK{constructor(a){const b={};for(const c of a.headers.entries())b[c[0]]=c[1];this.headers=b,this.responseInternal=a}json(){return this.responseInternal.json()}}class bL{get text(){var a,b,c,d,e,f,g,h;if((null==(d=null==(c=null==(b=null==(a=this.candidates)?void 0:a[0])?void 0:b.content)?void 0:c.parts)?void 0:d.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let i="",j=!1,k=[];for(let a of null!=(h=null==(g=null==(f=null==(e=this.candidates)?void 0:e[0])?void 0:f.content)?void 0:g.parts)?h:[]){for(let[b,c]of Object.entries(a))"text"!==b&&"thought"!==b&&"thoughtSignature"!==b&&(null!==c||void 0!==c)&&k.push(b);if("string"==typeof a.text){if("boolean"==typeof a.thought&&a.thought)continue;j=!0,i+=a.text}}return k.length>0&&console.warn(`there are non-text parts ${k} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),j?i:void 0}get data(){var a,b,c,d,e,f,g,h;if((null==(d=null==(c=null==(b=null==(a=this.candidates)?void 0:a[0])?void 0:b.content)?void 0:c.parts)?void 0:d.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let i="",j=[];for(let a of null!=(h=null==(g=null==(f=null==(e=this.candidates)?void 0:e[0])?void 0:f.content)?void 0:g.parts)?h:[]){for(let[b,c]of Object.entries(a))"inlineData"!==b&&(null!==c||void 0!==c)&&j.push(b);a.inlineData&&"string"==typeof a.inlineData.data&&(i+=atob(a.inlineData.data))}return j.length>0&&console.warn(`there are non-data parts ${j} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),i.length>0?btoa(i):void 0}get functionCalls(){var a,b,c,d,e,f,g,h;if((null==(d=null==(c=null==(b=null==(a=this.candidates)?void 0:a[0])?void 0:b.content)?void 0:c.parts)?void 0:d.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let i=null==(h=null==(g=null==(f=null==(e=this.candidates)?void 0:e[0])?void 0:f.content)?void 0:g.parts)?void 0:h.filter(a=>a.functionCall).map(a=>a.functionCall).filter(a=>void 0!==a);if((null==i?void 0:i.length)!==0)return i}get executableCode(){var a,b,c,d,e,f,g,h,i;if((null==(d=null==(c=null==(b=null==(a=this.candidates)?void 0:a[0])?void 0:b.content)?void 0:c.parts)?void 0:d.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let j=null==(h=null==(g=null==(f=null==(e=this.candidates)?void 0:e[0])?void 0:f.content)?void 0:g.parts)?void 0:h.filter(a=>a.executableCode).map(a=>a.executableCode).filter(a=>void 0!==a);if((null==j?void 0:j.length)!==0)return null==(i=null==j?void 0:j[0])?void 0:i.code}get codeExecutionResult(){var a,b,c,d,e,f,g,h,i;if((null==(d=null==(c=null==(b=null==(a=this.candidates)?void 0:a[0])?void 0:b.content)?void 0:c.parts)?void 0:d.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let j=null==(h=null==(g=null==(f=null==(e=this.candidates)?void 0:e[0])?void 0:f.content)?void 0:g.parts)?void 0:h.filter(a=>a.codeExecutionResult).map(a=>a.codeExecutionResult).filter(a=>void 0!==a);if((null==j?void 0:j.length)!==0)return null==(i=null==j?void 0:j[0])?void 0:i.output}}class bM{}class bN{}class bO{}class bP{}class bQ{}class bR{}class bS{}class bT{}class bU{}class bV{}class bW{_fromAPIResponse({apiResponse:a,_isVertexAI:b}){let c,d=new bW;if(b){let b,d,e,f,g,h;b={},null!=(d=bH(a,["name"]))&&bG(b,["name"],d),null!=(e=bH(a,["metadata"]))&&bG(b,["metadata"],e),null!=(f=bH(a,["done"]))&&bG(b,["done"],f),null!=(g=bH(a,["error"]))&&bG(b,["error"],g),null!=(h=bH(a,["response"]))&&bG(b,["response"],function(a){let b={},c=bH(a,["videos"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h;return c={},null!=(d=bH(a,["_self"]))&&bG(c,["video"],(e={},null!=(f=bH(b=d,["gcsUri"]))&&bG(e,["uri"],f),null!=(g=bH(b,["bytesBase64Encoded"]))&&bG(e,["videoBytes"],bI(g)),null!=(h=bH(b,["mimeType"]))&&bG(e,["mimeType"],h),e)),c})),bG(b,["generatedVideos"],a)}let d=bH(a,["raiMediaFilteredCount"]);null!=d&&bG(b,["raiMediaFilteredCount"],d);let e=bH(a,["raiMediaFilteredReasons"]);return null!=e&&bG(b,["raiMediaFilteredReasons"],e),b}(h)),c=b}else{let b,d,e,f,g,h;b={},null!=(d=bH(a,["name"]))&&bG(b,["name"],d),null!=(e=bH(a,["metadata"]))&&bG(b,["metadata"],e),null!=(f=bH(a,["done"]))&&bG(b,["done"],f),null!=(g=bH(a,["error"]))&&bG(b,["error"],g),null!=(h=bH(a,["response","generateVideoResponse"]))&&bG(b,["response"],function(a){let b={},c=bH(a,["generatedSamples"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h;return c={},null!=(d=bH(a,["video"]))&&bG(c,["video"],(e={},null!=(f=bH(b=d,["uri"]))&&bG(e,["uri"],f),null!=(g=bH(b,["encodedVideo"]))&&bG(e,["videoBytes"],bI(g)),null!=(h=bH(b,["encoding"]))&&bG(e,["mimeType"],h),e)),c})),bG(b,["generatedVideos"],a)}let d=bH(a,["raiMediaFilteredCount"]);null!=d&&bG(b,["raiMediaFilteredCount"],d);let e=bH(a,["raiMediaFilteredReasons"]);return null!=e&&bG(b,["raiMediaFilteredReasons"],e),b}(h)),c=b}return Object.assign(d,c),d}}class bX{}class bY{}class bZ{}class b${}class b_{}class b0{}class b1{}class b2{_fromAPIResponse({apiResponse:a,_isVertexAI:b}){var c;let d,e,f,g,h,i,j,k,l,m,n=new b2;return Object.assign(n,(h={},null!=(i=bH(a,["name"]))&&bG(h,["name"],i),null!=(j=bH(a,["metadata"]))&&bG(h,["metadata"],j),null!=(k=bH(a,["done"]))&&bG(h,["done"],k),null!=(l=bH(a,["error"]))&&bG(h,["error"],l),null!=(m=bH(a,["response"]))&&bG(h,["response"],(d={},null!=(e=bH(c=m,["sdkHttpResponse"]))&&bG(d,["sdkHttpResponse"],e),null!=(f=bH(c,["parent"]))&&bG(d,["parent"],f),null!=(g=bH(c,["documentName"]))&&bG(d,["documentName"],g),d)),h)),n}}class b3{}class b4{}class b5{}class b6{}class b7{}class b8{get text(){var a,b,c;let d="",e=!1,f=[];for(let g of null!=(c=null==(b=null==(a=this.serverContent)?void 0:a.modelTurn)?void 0:b.parts)?c:[]){for(let[a,b]of Object.entries(g))"text"!==a&&"thought"!==a&&null!==b&&f.push(a);if("string"==typeof g.text){if("boolean"==typeof g.thought&&g.thought)continue;e=!0,d+=g.text}}return f.length>0&&console.warn(`there are non-text parts ${f} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),e?d:void 0}get data(){var a,b,c;let d="",e=[];for(let f of null!=(c=null==(b=null==(a=this.serverContent)?void 0:a.modelTurn)?void 0:b.parts)?c:[]){for(let[a,b]of Object.entries(f))"inlineData"!==a&&null!==b&&e.push(a);f.inlineData&&"string"==typeof f.inlineData.data&&(d+=atob(f.inlineData.data))}return e.length>0&&console.warn(`there are non-data parts ${e} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}}class b9{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class ca{_fromAPIResponse({apiResponse:a,_isVertexAI:b}){let c=new ca;return Object.assign(c,bJ(a)),c}}function cb(a,b){if(!b||"string"!=typeof b)throw Error("model is required and must be a string");if(b.includes("..")||b.includes("?")||b.includes("&"))throw Error("invalid model parameter");if(a.isVertexAI())if(b.startsWith("publishers/")||b.startsWith("projects/")||b.startsWith("models/"))return b;else{if(!(b.indexOf("/")>=0))return`publishers/google/models/${b}`;let a=b.split("/",2);return`publishers/${a[0]}/models/${a[1]}`}return b.startsWith("models/")||b.startsWith("tunedModels/")?b:`models/${b}`}function cc(a,b){let c=cb(a,b);return c?c.startsWith("publishers/")&&a.isVertexAI()?`projects/${a.getProject()}/locations/${a.getLocation()}/${c}`:c.startsWith("models/")&&a.isVertexAI()?`projects/${a.getProject()}/locations/${a.getLocation()}/publishers/google/${c}`:c:""}function cd(a){return Array.isArray(a)?a.map(a=>ce(a)):[ce(a)]}function ce(a){if("object"==typeof a&&null!==a)return a;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof a}`)}function cf(a){let b=ce(a);if(b.mimeType&&b.mimeType.startsWith("image/"))return b;throw Error(`Unsupported mime type: ${b.mimeType}`)}function cg(a){let b=ce(a);if(b.mimeType&&b.mimeType.startsWith("audio/"))return b;throw Error(`Unsupported mime type: ${b.mimeType}`)}function ch(a){if(null==a)throw Error("PartUnion is required");if("object"==typeof a)return a;if("string"==typeof a)return{text:a};throw Error(`Unsupported part type: ${typeof a}`)}function ci(a){if(null==a||Array.isArray(a)&&0===a.length)throw Error("PartListUnion is required");return Array.isArray(a)?a.map(a=>ch(a)):[ch(a)]}function cj(a){return null!=a&&"object"==typeof a&&"parts"in a&&Array.isArray(a.parts)}function ck(a){return null!=a&&"object"==typeof a&&"functionCall"in a}function cl(a){return null!=a&&"object"==typeof a&&"functionResponse"in a}function cm(a){if(null==a)throw Error("ContentUnion is required");return cj(a)?a:{role:"user",parts:ci(a)}}function cn(a,b){if(!b)return[];if(a.isVertexAI()&&Array.isArray(b))return b.flatMap(a=>{let b=cm(a);return b.parts&&b.parts.length>0&&void 0!==b.parts[0].text?[b.parts[0].text]:[]});if(a.isVertexAI()){let a=cm(b);return a.parts&&a.parts.length>0&&void 0!==a.parts[0].text?[a.parts[0].text]:[]}return Array.isArray(b)?b.map(a=>cm(a)):[cm(b)]}function co(a){if(null==a||Array.isArray(a)&&0===a.length)throw Error("contents are required");if(!Array.isArray(a)){if(ck(a)||cl(a))throw Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[cm(a)]}let b=[],c=[],d=cj(a[0]);for(let e of a){let a=cj(e);if(a!=d)throw Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(a)b.push(e);else if(ck(e)||cl(e))throw Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");else c.push(e)}return d||b.push({role:"user",parts:ci(c)}),b}function cp(a){let b={},c=["items"],d=["anyOf"],e=["properties"];if(a.type&&a.anyOf)throw Error("type and anyOf cannot be both populated.");let f=a.anyOf;for(let[g,h]of(null!=f&&2==f.length&&("null"===f[0].type?(b.nullable=!0,a=f[1]):"null"===f[1].type&&(b.nullable=!0,a=f[0])),a.type instanceof Array&&function(a,b){a.includes("null")&&(b.nullable=!0);let c=a.filter(a=>"null"!==a);if(1===c.length)b.type=Object.values(aw).includes(c[0].toUpperCase())?c[0].toUpperCase():aw.TYPE_UNSPECIFIED;else for(let a of(b.anyOf=[],c))b.anyOf.push({type:Object.values(aw).includes(a.toUpperCase())?a.toUpperCase():aw.TYPE_UNSPECIFIED})}(a.type,b),Object.entries(a)))if(null!=h)if("type"==g){if("null"===h)throw Error("type: null can not be the only possible type for the field.");if(h instanceof Array)continue;b.type=Object.values(aw).includes(h.toUpperCase())?h.toUpperCase():aw.TYPE_UNSPECIFIED}else if(c.includes(g))b[g]=cp(h);else if(d.includes(g)){let a=[];for(let c of h){if("null"==c.type){b.nullable=!0;continue}a.push(cp(c))}b[g]=a}else if(e.includes(g)){let a={};for(let[b,c]of Object.entries(h))a[b]=cp(c);b[g]=a}else{if("additionalProperties"===g)continue;b[g]=h}return b}function cq(a){if("object"==typeof a)return a;if("string"==typeof a)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:a}}};throw Error(`Unsupported speechConfig type: ${typeof a}`)}function cr(a){if("multiSpeakerVoiceConfig"in a)throw Error("multiSpeakerVoiceConfig is not supported in the live API.");return a}function cs(a){if(a.functionDeclarations)for(let b of a.functionDeclarations)b.parameters&&(Object.keys(b.parameters).includes("$schema")?b.parametersJsonSchema||(b.parametersJsonSchema=b.parameters,delete b.parameters):b.parameters=cp(b.parameters)),b.response&&(Object.keys(b.response).includes("$schema")?b.responseJsonSchema||(b.responseJsonSchema=b.response,delete b.response):b.response=cp(b.response));return a}function ct(a){if(null==a)throw Error("tools is required");if(!Array.isArray(a))throw Error("tools is required and must be an array of Tools");let b=[];for(let c of a)b.push(c);return b}function cu(a,b){if("string"!=typeof b)throw Error("name must be a string");return function(a,b,c,d=1){let e=!b.startsWith(`${c}/`)&&b.split("/").length===d;if(a.isVertexAI())if(b.startsWith("projects/"))return b;else if(b.startsWith("locations/"))return`projects/${a.getProject()}/${b}`;else if(b.startsWith(`${c}/`))return`projects/${a.getProject()}/locations/${a.getLocation()}/${b}`;else if(e)return`projects/${a.getProject()}/locations/${a.getLocation()}/${c}/${b}`;else return b;return e?`${c}/${b}`:b}(a,b,"cachedContents")}function cv(a){switch(a){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return a}}function cw(a){return null!=a&&"object"==typeof a&&"video"in a}function cx(a){return null!=a&&"object"==typeof a&&"uri"in a}function cy(a){var b;let c;if(null!=a&&"object"==typeof a&&"name"in a&&(c=a.name),!cx(a)||void 0!==(c=a.uri)){if(!cw(a)||void 0!==(c=null==(b=a.video)?void 0:b.uri)){if("string"==typeof a&&(c=a),void 0===c)throw Error("Could not extract file name from the provided input.");if(c.startsWith("https://")){let a=c.split("files/")[1].match(/[a-z0-9]+/);if(null===a)throw Error(`Could not extract file name from URI ${c}`);c=a[0]}else c.startsWith("files/")&&(c=c.split("files/")[1]);return c}}}function cz(a,b){return a.isVertexAI()?b?"publishers/google/models":"models":b?"models":"tunedModels"}function cA(a){for(let d of["models","tunedModels","publisherModels"]){var b,c;if(b=a,c=d,null!==b&&"object"==typeof b&&c in b)return a[d]}return[]}function cB(a,b){let c;if("string"==typeof b)if(a.isVertexAI())if(b.startsWith("gs://"))c={format:"jsonl",gcsUri:[b]};else if(b.startsWith("bq://"))c={format:"bigquery",bigqueryUri:b};else if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(b))c={format:"vertex-dataset",vertexDatasetName:b};else throw Error(`Unsupported string source for Vertex AI: ${b}`);else if(b.startsWith("files/"))c={fileName:b};else throw Error(`Unsupported string source for Gemini API: ${b}`);else if(Array.isArray(b)){if(a.isVertexAI())throw Error("InlinedRequest[] is not supported in Vertex AI.");c={inlinedRequests:b}}else c=b;let d=[c.gcsUri,c.bigqueryUri,c.vertexDatasetName].filter(Boolean).length,e=[c.inlinedRequests,c.fileName].filter(Boolean).length;if(a.isVertexAI()){if(e>0||1!==d)throw Error("Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.")}else if(d>0||1!==e)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return c}function cC(a){if("object"!=typeof a||null===a)return{};let b=a.inlinedResponses;if("object"!=typeof b||null===b)return a;let c=b.inlinedResponses;if(!Array.isArray(c)||0===c.length)return a;let d=!1;for(let a of c){if("object"!=typeof a||null===a)continue;let b=a.response;if("object"==typeof b&&null!==b&&void 0!==b.embedding){d=!0;break}}return d&&(a.inlinedEmbedContentResponses=a.inlinedResponses,delete a.inlinedResponses),a}function cD(a,b){if(!a.isVertexAI()){if(/batches\/[^/]+$/.test(b))return b.split("/").pop();throw Error(`Invalid batch job name: ${b}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(b))return b.split("/").pop();if(/^\d+$/.test(b))return b;throw Error(`Invalid batch job name: ${b}.`)}function cE(a){if("BATCH_STATE_UNSPECIFIED"===a)return"JOB_STATE_UNSPECIFIED";if("BATCH_STATE_PENDING"===a)return"JOB_STATE_PENDING";if("BATCH_STATE_RUNNING"===a)return"JOB_STATE_RUNNING";if("BATCH_STATE_SUCCEEDED"===a)return"JOB_STATE_SUCCEEDED";if("BATCH_STATE_FAILED"===a)return"JOB_STATE_FAILED";else if("BATCH_STATE_CANCELLED"===a)return"JOB_STATE_CANCELLED";else if("BATCH_STATE_EXPIRED"===a)return"JOB_STATE_EXPIRED";else return a}function cF(a){let b={},c=bH(a,["name"]);null!=c&&bG(b,["name"],c);let d=bH(a,["metadata","displayName"]);null!=d&&bG(b,["displayName"],d);let e=bH(a,["metadata","state"]);null!=e&&bG(b,["state"],cE(e));let f=bH(a,["metadata","createTime"]);null!=f&&bG(b,["createTime"],f);let g=bH(a,["metadata","endTime"]);null!=g&&bG(b,["endTime"],g);let h=bH(a,["metadata","updateTime"]);null!=h&&bG(b,["updateTime"],h);let i=bH(a,["metadata","model"]);null!=i&&bG(b,["model"],i);let j=bH(a,["metadata","output"]);return null!=j&&bG(b,["dest"],function(a){let b={},c=bH(a,["responsesFile"]);null!=c&&bG(b,["fileName"],c);let d=bH(a,["inlinedResponses","inlinedResponses"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f;return c={},null!=(d=bH(b=a,["response"]))&&bG(c,["response"],function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["candidates"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["content"]);null!=c&&bG(b,["content"],c);let d=bH(a,["citationMetadata"]);null!=d&&bG(b,["citationMetadata"],function(a){let b={},c=bH(a,["citationSources"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["citations"],a)}return b}(d));let e=bH(a,["tokenCount"]);null!=e&&bG(b,["tokenCount"],e);let f=bH(a,["finishReason"]);null!=f&&bG(b,["finishReason"],f);let g=bH(a,["groundingMetadata"]);null!=g&&bG(b,["groundingMetadata"],g);let h=bH(a,["avgLogprobs"]);null!=h&&bG(b,["avgLogprobs"],h);let i=bH(a,["index"]);null!=i&&bG(b,["index"],i);let j=bH(a,["logprobsResult"]);null!=j&&bG(b,["logprobsResult"],j);let k=bH(a,["safetyRatings"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["safetyRatings"],a)}let l=bH(a,["urlContextMetadata"]);return null!=l&&bG(b,["urlContextMetadata"],l),b})(a))),bG(b,["candidates"],a)}let e=bH(a,["modelVersion"]);null!=e&&bG(b,["modelVersion"],e);let f=bH(a,["promptFeedback"]);null!=f&&bG(b,["promptFeedback"],f);let g=bH(a,["responseId"]);null!=g&&bG(b,["responseId"],g);let h=bH(a,["usageMetadata"]);null!=h&&bG(b,["usageMetadata"],h);let i=bH(a,["modelStatus"]);return null!=i&&bG(b,["modelStatus"],i),b}(d)),null!=(e=bH(b,["metadata"]))&&bG(c,["metadata"],e),null!=(f=bH(b,["error"]))&&bG(c,["error"],f),c})),bG(b,["inlinedResponses"],a)}let e=bH(a,["inlinedEmbedContentResponses","inlinedResponses"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["inlinedEmbedContentResponses"],a)}return b}(cC(j))),b}function cG(a){var b,c,d;let e,f,g,h,i,j,k,l,m,n,o,p,q,r={},s=bH(a,["name"]);null!=s&&bG(r,["name"],s);let t=bH(a,["displayName"]);null!=t&&bG(r,["displayName"],t);let u=bH(a,["state"]);null!=u&&bG(r,["state"],cE(u));let v=bH(a,["error"]);null!=v&&bG(r,["error"],v);let w=bH(a,["createTime"]);null!=w&&bG(r,["createTime"],w);let x=bH(a,["startTime"]);null!=x&&bG(r,["startTime"],x);let y=bH(a,["endTime"]);null!=y&&bG(r,["endTime"],y);let z=bH(a,["updateTime"]);null!=z&&bG(r,["updateTime"],z);let A=bH(a,["model"]);null!=A&&bG(r,["model"],A);let B=bH(a,["inputConfig"]);null!=B&&bG(r,["src"],(e={},null!=(f=bH(c=B,["instancesFormat"]))&&bG(e,["format"],f),null!=(g=bH(c,["gcsSource","uris"]))&&bG(e,["gcsUri"],g),null!=(h=bH(c,["bigquerySource","inputUri"]))&&bG(e,["bigqueryUri"],h),null!=(i=bH(c,["vertexMultimodalDatasetSource","datasetName"]))&&bG(e,["vertexDatasetName"],i),e));let C=bH(a,["outputConfig"]);null!=C&&bG(r,["dest"],(b=cC(C),m={},null!=(n=bH(b,["predictionsFormat"]))&&bG(m,["format"],n),null!=(o=bH(b,["gcsDestination","outputUriPrefix"]))&&bG(m,["gcsUri"],o),null!=(p=bH(b,["bigqueryDestination","outputUri"]))&&bG(m,["bigqueryUri"],p),null!=(q=bH(b,["vertexMultimodalDatasetDestination"]))&&bG(m,["vertexDataset"],(j={},null!=(k=bH(d=q,["bigqueryDestination","outputUri"]))&&bG(j,["bigqueryDestination"],k),null!=(l=bH(d,["displayName"]))&&bG(j,["displayName"],l),j)),m));let D=bH(a,["completionStats"]);null!=D&&bG(r,["completionStats"],D);let E=bH(a,["outputInfo"]);return null!=E&&bG(r,["outputInfo"],E),r}function cH(a){let b={},c=bH(a,["parts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return c={},null!=(d=bH(b=a,["mediaResolution"]))&&bG(c,["mediaResolution"],d),null!=(e=bH(b,["codeExecutionResult"]))&&bG(c,["codeExecutionResult"],e),null!=(f=bH(b,["executableCode"]))&&bG(c,["executableCode"],f),null!=(g=bH(b,["fileData"]))&&bG(c,["fileData"],function(a){let b={};if(void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let c=bH(a,["fileUri"]);null!=c&&bG(b,["fileUri"],c);let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(g)),null!=(h=bH(b,["functionCall"]))&&bG(c,["functionCall"],function(a){let b={},c=bH(a,["id"]);null!=c&&bG(b,["id"],c);let d=bH(a,["args"]);null!=d&&bG(b,["args"],d);let e=bH(a,["name"]);if(null!=e&&bG(b,["name"],e),void 0!==bH(a,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==bH(a,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return b}(h)),null!=(i=bH(b,["functionResponse"]))&&bG(c,["functionResponse"],i),null!=(j=bH(b,["inlineData"]))&&bG(c,["inlineData"],function(a){let b={},c=bH(a,["data"]);if(null!=c&&bG(b,["data"],c),void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(j)),null!=(k=bH(b,["text"]))&&bG(c,["text"],k),null!=(l=bH(b,["thought"]))&&bG(c,["thought"],l),null!=(m=bH(b,["thoughtSignature"]))&&bG(c,["thoughtSignature"],m),null!=(n=bH(b,["videoMetadata"]))&&bG(c,["videoMetadata"],n),null!=(o=bH(b,["toolCall"]))&&bG(c,["toolCall"],o),null!=(p=bH(b,["toolResponse"]))&&bG(c,["toolResponse"],p),null!=(q=bH(b,["partMetadata"]))&&bG(c,["partMetadata"],q),c})),bG(b,["parts"],a)}let d=bH(a,["role"]);return null!=d&&bG(b,["role"],d),b}function cI(a,b){let c={},d=bH(b,["model"]);null!=d&&bG(c,["_url","model"],cb(a,d));let e=bH(b,["src"]);null!=e&&bG(c,["batch","inputConfig"],function(a,b){let c={};if(void 0!==bH(b,["format"]))throw Error("format parameter is not supported in Gemini API.");if(void 0!==bH(b,["gcsUri"]))throw Error("gcsUri parameter is not supported in Gemini API.");if(void 0!==bH(b,["bigqueryUri"]))throw Error("bigqueryUri parameter is not supported in Gemini API.");let d=bH(b,["fileName"]);null!=d&&bG(c,["fileName"],d);let e=bH(b,["inlinedRequests"]);if(null!=e){let b=e;Array.isArray(b)&&(b=b.map(b=>(function(a,b){let c={},d=bH(b,["model"]);null!=d&&bG(c,["request","model"],cb(a,d));let e=bH(b,["contents"]);if(null!=e){let a=co(e);Array.isArray(a)&&(a=a.map(a=>cH(a))),bG(c,["request","contents"],a)}let f=bH(b,["metadata"]);null!=f&&bG(c,["metadata"],f);let g=bH(b,["config"]);return null!=g&&bG(c,["request","generationConfig"],function(a,b,c){var d;let e,f,g,h,i={},j=bH(b,["systemInstruction"]);void 0!==c&&null!=j&&bG(c,["systemInstruction"],cH(cm(j)));let k=bH(b,["temperature"]);null!=k&&bG(i,["temperature"],k);let l=bH(b,["topP"]);null!=l&&bG(i,["topP"],l);let m=bH(b,["topK"]);null!=m&&bG(i,["topK"],m);let n=bH(b,["candidateCount"]);null!=n&&bG(i,["candidateCount"],n);let o=bH(b,["maxOutputTokens"]);null!=o&&bG(i,["maxOutputTokens"],o);let p=bH(b,["stopSequences"]);null!=p&&bG(i,["stopSequences"],p);let q=bH(b,["responseLogprobs"]);null!=q&&bG(i,["responseLogprobs"],q);let r=bH(b,["logprobs"]);null!=r&&bG(i,["logprobs"],r);let s=bH(b,["presencePenalty"]);null!=s&&bG(i,["presencePenalty"],s);let t=bH(b,["frequencyPenalty"]);null!=t&&bG(i,["frequencyPenalty"],t);let u=bH(b,["seed"]);null!=u&&bG(i,["seed"],u);let v=bH(b,["responseMimeType"]);null!=v&&bG(i,["responseMimeType"],v);let w=bH(b,["responseSchema"]);null!=w&&bG(i,["responseSchema"],cp(w));let x=bH(b,["responseJsonSchema"]);if(null!=x&&bG(i,["responseJsonSchema"],x),void 0!==bH(b,["routingConfig"]))throw Error("routingConfig parameter is not supported in Gemini API.");if(void 0!==bH(b,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is not supported in Gemini API.");let y=bH(b,["safetySettings"]);if(void 0!==c&&null!=y){let a=y;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["category"]);if(null!=c&&bG(b,["category"],c),void 0!==bH(a,["method"]))throw Error("method parameter is not supported in Gemini API.");let d=bH(a,["threshold"]);return null!=d&&bG(b,["threshold"],d),b})(a))),bG(c,["safetySettings"],a)}let z=bH(b,["tools"]);if(void 0!==c&&null!=z){let a=ct(z);Array.isArray(a)&&(a=a.map(a=>(function(a){let b,c,d,e={};if(void 0!==bH(a,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let f=bH(a,["computerUse"]);null!=f&&bG(e,["computerUse"],f);let g=bH(a,["fileSearch"]);null!=g&&bG(e,["fileSearch"],g);let h=bH(a,["googleSearch"]);null!=h&&bG(e,["googleSearch"],function(a){let b={},c=bH(a,["searchTypes"]);if(null!=c&&bG(b,["searchTypes"],c),void 0!==bH(a,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");if(void 0!==bH(a,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");let d=bH(a,["timeRangeFilter"]);return null!=d&&bG(b,["timeRangeFilter"],d),b}(h));let i=bH(a,["googleMaps"]);null!=i&&bG(e,["googleMaps"],(b={},null!=(c=bH(i,["authConfig"]))&&bG(b,["authConfig"],function(a){let b={},c=bH(a,["apiKey"]);if(null!=c&&bG(b,["apiKey"],c),void 0!==bH(a,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["authType"]))throw Error("authType parameter is not supported in Gemini API.");if(void 0!==bH(a,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oauthConfig"]))throw Error("oauthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oidcConfig"]))throw Error("oidcConfig parameter is not supported in Gemini API.");return b}(c)),null!=(d=bH(i,["enableWidget"]))&&bG(b,["enableWidget"],d),b));let j=bH(a,["codeExecution"]);if(null!=j&&bG(e,["codeExecution"],j),void 0!==bH(a,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let k=bH(a,["functionDeclarations"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["functionDeclarations"],a)}let l=bH(a,["googleSearchRetrieval"]);if(null!=l&&bG(e,["googleSearchRetrieval"],l),void 0!==bH(a,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is not supported in Gemini API.");let m=bH(a,["urlContext"]);null!=m&&bG(e,["urlContext"],m);let n=bH(a,["mcpServers"]);if(null!=n){let a=n;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["mcpServers"],a)}return e})(cs(a)))),bG(c,["tools"],a)}let A=bH(b,["toolConfig"]);if(void 0!==c&&null!=A&&bG(c,["toolConfig"],(e={},null!=(f=bH(d=A,["retrievalConfig"]))&&bG(e,["retrievalConfig"],f),null!=(g=bH(d,["functionCallingConfig"]))&&bG(e,["functionCallingConfig"],function(a){let b={},c=bH(a,["allowedFunctionNames"]);null!=c&&bG(b,["allowedFunctionNames"],c);let d=bH(a,["mode"]);if(null!=d&&bG(b,["mode"],d),void 0!==bH(a,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return b}(g)),null!=(h=bH(d,["includeServerSideToolInvocations"]))&&bG(e,["includeServerSideToolInvocations"],h),e)),void 0!==bH(b,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let B=bH(b,["cachedContent"]);void 0!==c&&null!=B&&bG(c,["cachedContent"],cu(a,B));let C=bH(b,["responseModalities"]);null!=C&&bG(i,["responseModalities"],C);let D=bH(b,["mediaResolution"]);null!=D&&bG(i,["mediaResolution"],D);let E=bH(b,["speechConfig"]);if(null!=E&&bG(i,["speechConfig"],cq(E)),void 0!==bH(b,["audioTimestamp"]))throw Error("audioTimestamp parameter is not supported in Gemini API.");let F=bH(b,["thinkingConfig"]);null!=F&&bG(i,["thinkingConfig"],F);let G=bH(b,["imageConfig"]);null!=G&&bG(i,["imageConfig"],function(a){let b={},c=bH(a,["aspectRatio"]);null!=c&&bG(b,["aspectRatio"],c);let d=bH(a,["imageSize"]);if(null!=d&&bG(b,["imageSize"],d),void 0!==bH(a,["personGeneration"]))throw Error("personGeneration parameter is not supported in Gemini API.");if(void 0!==bH(a,["prominentPeople"]))throw Error("prominentPeople parameter is not supported in Gemini API.");if(void 0!==bH(a,["outputMimeType"]))throw Error("outputMimeType parameter is not supported in Gemini API.");if(void 0!==bH(a,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is not supported in Gemini API.");if(void 0!==bH(a,["imageOutputOptions"]))throw Error("imageOutputOptions parameter is not supported in Gemini API.");return b}(G));let H=bH(b,["enableEnhancedCivicAnswers"]);if(null!=H&&bG(i,["enableEnhancedCivicAnswers"],H),void 0!==bH(b,["modelArmorConfig"]))throw Error("modelArmorConfig parameter is not supported in Gemini API.");let I=bH(b,["serviceTier"]);return void 0!==c&&null!=I&&bG(c,["serviceTier"],I),i}(a,g,bH(c,["request"],{}))),c})(a,b))),bG(c,["requests","requests"],b)}if(void 0!==bH(b,["vertexDatasetName"]))throw Error("vertexDatasetName parameter is not supported in Gemini API.");return c}(a,cB(a,e)));let f=bH(b,["config"]);return null!=f&&function(a,b){let c=bH(a,["displayName"]);if(void 0!==b&&null!=c&&bG(b,["batch","displayName"],c),void 0!==bH(a,["dest"]))throw Error("dest parameter is not supported in Gemini API.");let d=bH(a,["webhookConfig"]);void 0!==b&&null!=d&&bG(b,["batch","webhookConfig"],d)}(f,c),c}(as=bv||(bv={})).PAGED_ITEM_BATCH_JOBS="batchJobs",as.PAGED_ITEM_MODELS="models",as.PAGED_ITEM_TUNING_JOBS="tuningJobs",as.PAGED_ITEM_FILES="files",as.PAGED_ITEM_CACHED_CONTENTS="cachedContents",as.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",as.PAGED_ITEM_DOCUMENTS="documents";class cJ{constructor(a,b,c,d){this.pageInternal=[],this.paramsInternal={},this.requestInternal=b,this.init(a,c,d)}init(a,b,c){var d,e;this.nameInternal=a,this.pageInternal=b[this.nameInternal]||[],this.sdkHttpResponseInternal=null==b?void 0:b.sdkHttpResponse,this.idxInternal=0;let f={config:{}};(f=c&&0!==Object.keys(c).length?"object"==typeof c?Object.assign({},c):c:{config:{}}).config&&(f.config.pageToken=b.nextPageToken),this.paramsInternal=f,this.pageInternalSize=null!=(e=null==(d=f.config)?void 0:d.pageSize)?e:this.pageInternal.length}initNextPage(a){this.init(this.nameInternal,a,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(a){return this.pageInternal[a]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(!this.hasNextPage())return{value:void 0,done:!0};else await this.nextPage();let a=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:a,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error("No more pages to fetch.");let a=await this.requestInternal(this.params);return this.initNextPage(a),this.page}hasNextPage(){var a;return(null==(a=this.params.config)?void 0:a.pageToken)!==void 0}}class cK extends bE{constructor(a){super(),this.apiClient=a,this.list=async(a={})=>new cJ(bv.PAGED_ITEM_BATCH_JOBS,a=>this.listInternal(a),await this.listInternal(a),a),this.create=async a=>(this.apiClient.isVertexAI()&&(a.config=this.formatDestination(a.src,a.config)),this.createInternal(a)),this.createEmbeddings=async a=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(a)}}createInlinedGenerateContentRequest(a){let b=cI(this.apiClient,a),c=bF("{model}:batchGenerateContent",b._url),d=b.batch.inputConfig.requests,e=d.requests,f=[];for(let a of e){let b=Object.assign({},a);if(b.systemInstruction){let a=b.systemInstruction;delete b.systemInstruction;let c=b.request;c.systemInstruction=a,b.request=c}f.push(b)}return d.requests=f,delete b.config,delete b._url,delete b._query,{path:c,body:b}}getGcsUri(a){return"string"==typeof a?a.startsWith("gs://")?a:void 0:!Array.isArray(a)&&a.gcsUri&&a.gcsUri.length>0?a.gcsUri[0]:void 0}getBigqueryUri(a){return"string"==typeof a?a.startsWith("bq://")?a:void 0:Array.isArray(a)?void 0:a.bigqueryUri}formatDestination(a,b){let c=b?Object.assign({},b):{},d=Date.now().toString();if(c.displayName||(c.displayName=`genaiBatchJob_${d}`),void 0===c.dest){let b=this.getGcsUri(a),e=this.getBigqueryUri(a);if(b)b.endsWith(".jsonl")?c.dest=`${b.slice(0,-6)}/dest`:c.dest=`${b}_dest_${d}`;else if(e)c.dest=`${e}_dest_${d}`;else throw Error("Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.")}return c}async createInternal(a){var b,c,d,e,f;let g="",h={};if(this.apiClient.isVertexAI()){let d,e,i,j,k=(f=this.apiClient,d={},null!=(e=bH(a,["model"]))&&bG(d,["model"],cb(f,e)),null!=(i=bH(a,["src"]))&&bG(d,["inputConfig"],function(a){let b={},c=bH(a,["format"]);null!=c&&bG(b,["instancesFormat"],c);let d=bH(a,["gcsUri"]);null!=d&&bG(b,["gcsSource","uris"],d);let e=bH(a,["bigqueryUri"]);if(null!=e&&bG(b,["bigquerySource","inputUri"],e),void 0!==bH(a,["fileName"]))throw Error("fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["inlinedRequests"]))throw Error("inlinedRequests parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let f=bH(a,["vertexDatasetName"]);return null!=f&&bG(b,["vertexMultimodalDatasetSource","datasetName"],f),b}(cB(f,i))),null!=(j=bH(a,["config"]))&&function(a,b){let c=bH(a,["displayName"]);void 0!==b&&null!=c&&bG(b,["displayName"],c);let d=bH(a,["dest"]);if(void 0!==b&&null!=d&&bG(b,["outputConfig"],function(a){var b;let c,d,e,f={},g=bH(a,["format"]);null!=g&&bG(f,["predictionsFormat"],g);let h=bH(a,["gcsUri"]);null!=h&&bG(f,["gcsDestination","outputUriPrefix"],h);let i=bH(a,["bigqueryUri"]);if(null!=i&&bG(f,["bigqueryDestination","outputUri"],i),void 0!==bH(a,["fileName"]))throw Error("fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["inlinedResponses"]))throw Error("inlinedResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["inlinedEmbedContentResponses"]))throw Error("inlinedEmbedContentResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let j=bH(a,["vertexDataset"]);return null!=j&&bG(f,["vertexMultimodalDatasetDestination"],(c={},null!=(d=bH(b=j,["bigqueryDestination"]))&&bG(c,["bigqueryDestination","outputUri"],d),null!=(e=bH(b,["displayName"]))&&bG(c,["displayName"],e),c)),f}(function(a){if("string"!=typeof a)return a;if(a.startsWith("gs://"))return{format:"jsonl",gcsUri:a};if(a.startsWith("bq://"))return{format:"bigquery",bigqueryUri:a};throw Error(`Unsupported destination: ${a}`)}(d))),void 0!==bH(a,["webhookConfig"]))throw Error("webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).")}(j,d),d);return g=bF("batchPredictionJobs",k._url),h=k._query,delete k._url,delete k._query,this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(k),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>cG(a))}{let b=cI(this.apiClient,a);return g=bF("{model}:batchGenerateContent",b._url),h=b._query,delete b._url,delete b._query,this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>cF(a))}}async createEmbeddingsInternal(a){var b,c,d,e,f;let g="",h={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let i,j,k,l,m,n,o,p,q=(d=this.apiClient,l={},null!=(m=bH(a,["model"]))&&bG(l,["_url","model"],cb(d,m)),null!=(n=bH(a,["src"]))&&bG(l,["batch","inputConfig"],(e=d,i={},null!=(j=bH(f=n,["fileName"]))&&bG(i,["file_name"],j),null!=(k=bH(f,["inlinedRequests"]))&&bG(i,["requests"],function(a,b){let c={},d=bH(b,["contents"]);if(null!=d){let b=cn(a,d);Array.isArray(b)&&(b=b.map(a=>a)),bG(c,["requests[]","request","content"],b)}let e=bH(b,["config"]);return null!=e&&(bG(c,["_self"],function(a,b){let c=bH(a,["taskType"]);void 0!==b&&null!=c&&bG(b,["requests[]","taskType"],c);let d=bH(a,["title"]);void 0!==b&&null!=d&&bG(b,["requests[]","title"],d);let e=bH(a,["outputDimensionality"]);if(void 0!==b&&null!=e&&bG(b,["requests[]","outputDimensionality"],e),void 0!==bH(a,["mimeType"]))throw Error("mimeType parameter is not supported in Gemini API.");if(void 0!==bH(a,["autoTruncate"]))throw Error("autoTruncate parameter is not supported in Gemini API.");if(void 0!==bH(a,["documentOcr"]))throw Error("documentOcr parameter is not supported in Gemini API.");if(void 0!==bH(a,["audioTrackExtraction"]))throw Error("audioTrackExtraction parameter is not supported in Gemini API.");return{}}(e,c)),!function(a,b){for(let[c,d]of Object.entries(b)){let b=c.split("."),e=d.split("."),f=new Set,g=-1;for(let a=0;a<b.length;a++)if("*"===b[a]){g=a;break}if(-1!==g&&e.length>g)for(let a=g;a<e.length;a++){let b=e[a];"*"===b||b.endsWith("[]")||b.endsWith("[0]")||f.add(b)}!function a(b,c,d,e,f){if(e>=c.length||"object"!=typeof b||null===b)return;let g=c[e];if(g.endsWith("[]")){let h=g.slice(0,-2);if(h in b&&Array.isArray(b[h]))for(let g of b[h])a(g,c,d,e+1,f)}else if("*"===g){if("object"==typeof b&&null!==b&&!Array.isArray(b)){let a=Object.keys(b).filter(a=>!a.startsWith("_")&&!f.has(a)),c={};for(let d of a)c[d]=b[d];for(let[a,f]of Object.entries(c)){let c=[];for(let b of d.slice(e))"*"===b?c.push(a):c.push(b);bG(b,c,f)}for(let c of a)delete b[c]}}else g in b&&a(b[g],c,d,e+1,f)}(a,b,e,0,f)}}(c,{"requests[].*":"requests[].request.*"})),c}(e,k)),i)),null!=(o=bH(a,["config"]))&&(p=bH(o,["displayName"]),void 0!==l&&null!=p&&bG(l,["batch","displayName"],p)),l);return g=bF("{model}:asyncBatchEmbedContent",q._url),h=q._query,delete q._url,delete q._query,this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(q),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>cF(a))}}async get(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],cD(f,e)),d);return h=bF("batchPredictionJobs/{name}",g._url),i=g._query,delete g._url,delete g._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>cG(a))}{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],cD(g,c)),b);return h=bF("batches/{name}",f._url),i=f._query,delete f._url,delete f._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>cF(a))}}async cancel(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],cD(f,e)),d);h=bF("batchPredictionJobs/{name}:cancel",g._url),i=g._query,delete g._url,delete g._query,await this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal})}else{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],cD(g,c)),b);h=bF("batches/{name}:cancel",f._url),i=f._query,delete f._url,delete f._query,await this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal})}}async listInternal(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d,e,h,i,j,k=(d={},null!=(e=bH(a,["config"]))&&(h=bH(e,["pageSize"]),void 0!==d&&null!=h&&bG(d,["_query","pageSize"],h),i=bH(e,["pageToken"]),void 0!==d&&null!=i&&bG(d,["_query","pageToken"],i),j=bH(e,["filter"]),void 0!==d&&null!=j&&bG(d,["_query","filter"],j)),d);return f=bF("batchPredictionJobs",k._url),g=k._query,delete k._url,delete k._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(k),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["batchPredictionJobs"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>cG(a))),bG(b,["batchJobs"],a)}return b}(a),c=new b7;return Object.assign(c,b),c})}{let b,c,h=(b={},null!=(c=bH(a,["config"]))&&function(a,b){let c=bH(a,["pageSize"]);void 0!==b&&null!=c&&bG(b,["_query","pageSize"],c);let d=bH(a,["pageToken"]);if(void 0!==b&&null!=d&&bG(b,["_query","pageToken"],d),void 0!==bH(a,["filter"]))throw Error("filter parameter is not supported in Gemini API.")}(c,b),b);return f=bF("batches",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["operations"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>cF(a))),bG(b,["batchJobs"],a)}return b}(a),c=new b7;return Object.assign(c,b),c})}}async delete(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],cD(f,e)),d);return h=bF("batchPredictionJobs/{name}",g._url),i=g._query,delete g._url,delete g._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d,e,f;return b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),null!=(d=bH(a,["name"]))&&bG(b,["name"],d),null!=(e=bH(a,["done"]))&&bG(b,["done"],e),null!=(f=bH(a,["error"]))&&bG(b,["error"],f),b})}{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],cD(g,c)),b);return h=bF("batches/{name}",f._url),i=f._query,delete f._url,delete f._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d,e,f;return b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),null!=(d=bH(a,["name"]))&&bG(b,["name"],d),null!=(e=bH(a,["done"]))&&bG(b,["done"],e),null!=(f=bH(a,["error"]))&&bG(b,["error"],f),b})}}}function cL(a){let b={},c=bH(a,["parts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return c={},null!=(d=bH(b=a,["mediaResolution"]))&&bG(c,["mediaResolution"],d),null!=(e=bH(b,["codeExecutionResult"]))&&bG(c,["codeExecutionResult"],e),null!=(f=bH(b,["executableCode"]))&&bG(c,["executableCode"],f),null!=(g=bH(b,["fileData"]))&&bG(c,["fileData"],function(a){let b={};if(void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let c=bH(a,["fileUri"]);null!=c&&bG(b,["fileUri"],c);let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(g)),null!=(h=bH(b,["functionCall"]))&&bG(c,["functionCall"],function(a){let b={},c=bH(a,["id"]);null!=c&&bG(b,["id"],c);let d=bH(a,["args"]);null!=d&&bG(b,["args"],d);let e=bH(a,["name"]);if(null!=e&&bG(b,["name"],e),void 0!==bH(a,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==bH(a,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return b}(h)),null!=(i=bH(b,["functionResponse"]))&&bG(c,["functionResponse"],i),null!=(j=bH(b,["inlineData"]))&&bG(c,["inlineData"],function(a){let b={},c=bH(a,["data"]);if(null!=c&&bG(b,["data"],c),void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(j)),null!=(k=bH(b,["text"]))&&bG(c,["text"],k),null!=(l=bH(b,["thought"]))&&bG(c,["thought"],l),null!=(m=bH(b,["thoughtSignature"]))&&bG(c,["thoughtSignature"],m),null!=(n=bH(b,["videoMetadata"]))&&bG(c,["videoMetadata"],n),null!=(o=bH(b,["toolCall"]))&&bG(c,["toolCall"],o),null!=(p=bH(b,["toolResponse"]))&&bG(c,["toolResponse"],p),null!=(q=bH(b,["partMetadata"]))&&bG(c,["partMetadata"],q),c})),bG(b,["parts"],a)}let d=bH(a,["role"]);return null!=d&&bG(b,["role"],d),b}function cM(a){let b={},c=bH(a,["parts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["mediaResolution"]);null!=c&&bG(b,["mediaResolution"],c);let d=bH(a,["codeExecutionResult"]);null!=d&&bG(b,["codeExecutionResult"],d);let e=bH(a,["executableCode"]);null!=e&&bG(b,["executableCode"],e);let f=bH(a,["fileData"]);null!=f&&bG(b,["fileData"],f);let g=bH(a,["functionCall"]);null!=g&&bG(b,["functionCall"],g);let h=bH(a,["functionResponse"]);null!=h&&bG(b,["functionResponse"],h);let i=bH(a,["inlineData"]);null!=i&&bG(b,["inlineData"],i);let j=bH(a,["text"]);null!=j&&bG(b,["text"],j);let k=bH(a,["thought"]);null!=k&&bG(b,["thought"],k);let l=bH(a,["thoughtSignature"]);null!=l&&bG(b,["thoughtSignature"],l);let m=bH(a,["videoMetadata"]);if(null!=m&&bG(b,["videoMetadata"],m),void 0!==bH(a,["toolCall"]))throw Error("toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["toolResponse"]))throw Error("toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["partMetadata"]))throw Error("partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(b,["parts"],a)}let d=bH(a,["role"]);return null!=d&&bG(b,["role"],d),b}class cN extends bE{constructor(a){super(),this.apiClient=a,this.list=async(a={})=>new cJ(bv.PAGED_ITEM_CACHED_CONTENTS,a=>this.listInternal(a),await this.listInternal(a),a)}async create(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g,j=(f=this.apiClient,d={},null!=(e=bH(a,["model"]))&&bG(d,["model"],cc(f,e)),null!=(g=bH(a,["config"]))&&function(a,b){let c=bH(a,["ttl"]);void 0!==b&&null!=c&&bG(b,["ttl"],c);let d=bH(a,["expireTime"]);void 0!==b&&null!=d&&bG(b,["expireTime"],d);let e=bH(a,["displayName"]);void 0!==b&&null!=e&&bG(b,["displayName"],e);let f=bH(a,["contents"]);if(void 0!==b&&null!=f){let a=co(f);Array.isArray(a)&&(a=a.map(a=>cM(a))),bG(b,["contents"],a)}let g=bH(a,["systemInstruction"]);void 0!==b&&null!=g&&bG(b,["systemInstruction"],cM(cm(g)));let h=bH(a,["tools"]);if(void 0!==b&&null!=h){let a=h;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["retrieval"]);null!=c&&bG(b,["retrieval"],c);let d=bH(a,["computerUse"]);if(null!=d&&bG(b,["computerUse"],d),void 0!==bH(a,["fileSearch"]))throw Error("fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let e=bH(a,["googleSearch"]);null!=e&&bG(b,["googleSearch"],e);let f=bH(a,["googleMaps"]);null!=f&&bG(b,["googleMaps"],f);let g=bH(a,["codeExecution"]);null!=g&&bG(b,["codeExecution"],g);let h=bH(a,["enterpriseWebSearch"]);null!=h&&bG(b,["enterpriseWebSearch"],h);let i=bH(a,["functionDeclarations"]);if(null!=i){let a=i;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["description"]);null!=c&&bG(b,["description"],c);let d=bH(a,["name"]);null!=d&&bG(b,["name"],d);let e=bH(a,["parameters"]);null!=e&&bG(b,["parameters"],e);let f=bH(a,["parametersJsonSchema"]);null!=f&&bG(b,["parametersJsonSchema"],f);let g=bH(a,["response"]);null!=g&&bG(b,["response"],g);let h=bH(a,["responseJsonSchema"]);if(null!=h&&bG(b,["responseJsonSchema"],h),void 0!==bH(a,["behavior"]))throw Error("behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(b,["functionDeclarations"],a)}let j=bH(a,["googleSearchRetrieval"]);null!=j&&bG(b,["googleSearchRetrieval"],j);let k=bH(a,["parallelAiSearch"]);null!=k&&bG(b,["parallelAiSearch"],k);let l=bH(a,["urlContext"]);if(null!=l&&bG(b,["urlContext"],l),void 0!==bH(a,["mcpServers"]))throw Error("mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(b,["tools"],a)}let i=bH(a,["toolConfig"]);void 0!==b&&null!=i&&bG(b,["toolConfig"],function(a){let b={},c=bH(a,["retrievalConfig"]);null!=c&&bG(b,["retrievalConfig"],c);let d=bH(a,["functionCallingConfig"]);if(null!=d&&bG(b,["functionCallingConfig"],d),void 0!==bH(a,["includeServerSideToolInvocations"]))throw Error("includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b}(i));let j=bH(a,["kmsKeyName"]);void 0!==b&&null!=j&&bG(b,["encryption_spec","kmsKeyName"],j)}(g,d),d);return h=bF("cachedContents",j._url),i=j._query,delete j._url,delete j._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(j),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}{let b,c,f,j=(g=this.apiClient,b={},null!=(c=bH(a,["model"]))&&bG(b,["model"],cc(g,c)),null!=(f=bH(a,["config"]))&&function(a,b){var c;let d,e,f,g,h=bH(a,["ttl"]);void 0!==b&&null!=h&&bG(b,["ttl"],h);let i=bH(a,["expireTime"]);void 0!==b&&null!=i&&bG(b,["expireTime"],i);let j=bH(a,["displayName"]);void 0!==b&&null!=j&&bG(b,["displayName"],j);let k=bH(a,["contents"]);if(void 0!==b&&null!=k){let a=co(k);Array.isArray(a)&&(a=a.map(a=>cL(a))),bG(b,["contents"],a)}let l=bH(a,["systemInstruction"]);void 0!==b&&null!=l&&bG(b,["systemInstruction"],cL(cm(l)));let m=bH(a,["tools"]);if(void 0!==b&&null!=m){let a=m;Array.isArray(a)&&(a=a.map(a=>(function(a){let b,c,d,e={};if(void 0!==bH(a,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let f=bH(a,["computerUse"]);null!=f&&bG(e,["computerUse"],f);let g=bH(a,["fileSearch"]);null!=g&&bG(e,["fileSearch"],g);let h=bH(a,["googleSearch"]);null!=h&&bG(e,["googleSearch"],function(a){let b={},c=bH(a,["searchTypes"]);if(null!=c&&bG(b,["searchTypes"],c),void 0!==bH(a,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");if(void 0!==bH(a,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");let d=bH(a,["timeRangeFilter"]);return null!=d&&bG(b,["timeRangeFilter"],d),b}(h));let i=bH(a,["googleMaps"]);null!=i&&bG(e,["googleMaps"],(b={},null!=(c=bH(i,["authConfig"]))&&bG(b,["authConfig"],function(a){let b={},c=bH(a,["apiKey"]);if(null!=c&&bG(b,["apiKey"],c),void 0!==bH(a,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["authType"]))throw Error("authType parameter is not supported in Gemini API.");if(void 0!==bH(a,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oauthConfig"]))throw Error("oauthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oidcConfig"]))throw Error("oidcConfig parameter is not supported in Gemini API.");return b}(c)),null!=(d=bH(i,["enableWidget"]))&&bG(b,["enableWidget"],d),b));let j=bH(a,["codeExecution"]);if(null!=j&&bG(e,["codeExecution"],j),void 0!==bH(a,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let k=bH(a,["functionDeclarations"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["functionDeclarations"],a)}let l=bH(a,["googleSearchRetrieval"]);if(null!=l&&bG(e,["googleSearchRetrieval"],l),void 0!==bH(a,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is not supported in Gemini API.");let m=bH(a,["urlContext"]);null!=m&&bG(e,["urlContext"],m);let n=bH(a,["mcpServers"]);if(null!=n){let a=n;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["mcpServers"],a)}return e})(a))),bG(b,["tools"],a)}let n=bH(a,["toolConfig"]);if(void 0!==b&&null!=n&&bG(b,["toolConfig"],(d={},null!=(e=bH(c=n,["retrievalConfig"]))&&bG(d,["retrievalConfig"],e),null!=(f=bH(c,["functionCallingConfig"]))&&bG(d,["functionCallingConfig"],function(a){let b={},c=bH(a,["allowedFunctionNames"]);null!=c&&bG(b,["allowedFunctionNames"],c);let d=bH(a,["mode"]);if(null!=d&&bG(b,["mode"],d),void 0!==bH(a,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return b}(f)),null!=(g=bH(c,["includeServerSideToolInvocations"]))&&bG(d,["includeServerSideToolInvocations"],g),d)),void 0!==bH(a,["kmsKeyName"]))throw Error("kmsKeyName parameter is not supported in Gemini API.")}(f,b),b);return h=bF("cachedContents",j._url),i=j._query,delete j._url,delete j._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(j),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>a)}}async get(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],cu(f,e)),d);return h=bF("{name}",g._url),i=g._query,delete g._url,delete g._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],cu(g,c)),b);return h=bF("{name}",f._url),i=f._query,delete f._url,delete f._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>a)}}async delete(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],cu(f,e)),d);return h=bF("{name}",g._url),i=g._query,delete g._url,delete g._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new bZ;return Object.assign(e,d),e})}{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],cu(g,c)),b);return h=bF("{name}",f._url),i=f._query,delete f._url,delete f._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new bZ;return Object.assign(e,d),e})}}async update(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g,j,k,l=(f=this.apiClient,d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],cu(f,e)),null!=(g=bH(a,["config"]))&&(j=bH(g,["ttl"]),void 0!==d&&null!=j&&bG(d,["ttl"],j),k=bH(g,["expireTime"]),void 0!==d&&null!=k&&bG(d,["expireTime"],k)),d);return h=bF("{name}",l._url),i=l._query,delete l._url,delete l._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(l),httpMethod:"PATCH",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}{let b,c,f,j,k,l=(g=this.apiClient,b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],cu(g,c)),null!=(f=bH(a,["config"]))&&(j=bH(f,["ttl"]),void 0!==b&&null!=j&&bG(b,["ttl"],j),k=bH(f,["expireTime"]),void 0!==b&&null!=k&&bG(b,["expireTime"],k)),b);return h=bF("{name}",l._url),i=l._query,delete l._url,delete l._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(l),httpMethod:"PATCH",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>a)}}async listInternal(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d,e,h,i,j=(d={},null!=(e=bH(a,["config"]))&&(h=bH(e,["pageSize"]),void 0!==d&&null!=h&&bG(d,["_query","pageSize"],h),i=bH(e,["pageToken"]),void 0!==d&&null!=i&&bG(d,["_query","pageToken"],i)),d);return f=bF("cachedContents",j._url),g=j._query,delete j._url,delete j._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(j),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["cachedContents"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["cachedContents"],a)}return b}(a),c=new b$;return Object.assign(c,b),c})}{let b,c,h,i,j=(b={},null!=(c=bH(a,["config"]))&&(h=bH(c,["pageSize"]),void 0!==b&&null!=h&&bG(b,["_query","pageSize"],h),i=bH(c,["pageToken"]),void 0!==b&&null!=i&&bG(b,["_query","pageToken"],i)),b);return f=bF("cachedContents",j._url),g=j._query,delete j._url,delete j._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(j),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["cachedContents"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["cachedContents"],a)}return b}(a),c=new b$;return Object.assign(c,b),c})}}}function cO(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&0>b.indexOf(d)&&(c[d]=a[d]);if(null!=a&&"function"==typeof Object.getOwnPropertySymbols)for(var e=0,d=Object.getOwnPropertySymbols(a);e<d.length;e++)0>b.indexOf(d[e])&&Object.prototype.propertyIsEnumerable.call(a,d[e])&&(c[d[e]]=a[d[e]]);return c}function cP(a){return this instanceof cP?(this.v=a,this):new cP(a)}function cQ(a,b,c){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var d,e=c.apply(a,b||[]),f=[];return d=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",function(a){return function(b){return Promise.resolve(b).then(a,j)}}),d[Symbol.asyncIterator]=function(){return this},d;function g(a,b){e[a]&&(d[a]=function(b){return new Promise(function(c,d){f.push([a,b,c,d])>1||h(a,b)})},b&&(d[a]=b(d[a])))}function h(a,b){try{var c;(c=e[a](b)).value instanceof cP?Promise.resolve(c.value.v).then(i,j):k(f[0][2],c)}catch(a){k(f[0][3],a)}}function i(a){h("next",a)}function j(a){h("throw",a)}function k(a,b){a(b),f.shift(),f.length&&h(f[0][0],f[0][1])}}function cR(a){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var b,c=a[Symbol.asyncIterator];return c?c.call(a):(a=function(a){var b="function"==typeof Symbol&&Symbol.iterator,c=b&&a[b],d=0;if(c)return c.call(a);if(a&&"number"==typeof a.length)return{next:function(){return a&&d>=a.length&&(a=void 0),{value:a&&a[d++],done:!a}}};throw TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.")}(a),b={},d("next"),d("throw"),d("return"),b[Symbol.asyncIterator]=function(){return this},b);function d(c){b[c]=a[c]&&function(b){return new Promise(function(d,e){var f,g,h;f=d,g=e,h=(b=a[c](b)).done,Promise.resolve(b.value).then(function(a){f({value:a,done:h})},g)})}}}function cS(a){if(void 0===a.parts||0===a.parts.length)return!1;for(let b of a.parts)if(void 0===b||0===Object.keys(b).length)return!1;return!0}function cT(a){if(void 0===a||0===a.length)return[];let b=[],c=a.length,d=0;for(;d<c;)if("user"===a[d].role)b.push(a[d]),d++;else{let e=[],f=!0;for(;d<c&&"model"===a[d].role;)e.push(a[d]),f&&!cS(a[d])&&(f=!1),d++;f?b.push(...e):b.pop()}return b}"function"==typeof SuppressedError&&SuppressedError;class cU{constructor(a,b){this.modelsModule=a,this.apiClient=b}create(a){return new cV(this.apiClient,this.modelsModule,a.model,a.config,structuredClone(a.history))}}class cV{constructor(a,b,c,d={},e=[]){this.apiClient=a,this.modelsModule=b,this.model=c,this.config=d,this.history=e,this.sendPromise=Promise.resolve(),function(a){if(0!==a.length){for(let b of a)if("user"!==b.role&&"model"!==b.role)throw Error(`Role must be user or model, but got ${b.role}.`)}}(e)}async sendMessage(a){var b;await this.sendPromise;let c=cm(a.message),d=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(c),config:null!=(b=a.config)?b:this.config});return this.sendPromise=(async()=>{var a,b,e;let f=await d,g=null==(b=null==(a=f.candidates)?void 0:a[0])?void 0:b.content,h=f.automaticFunctionCallingHistory,i=this.getHistory(!0).length,j=[];null!=h&&(j=null!=(e=h.slice(i))?e:[]),this.recordHistory(c,g?[g]:[],j)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),d}async sendMessageStream(a){var b;await this.sendPromise;let c=cm(a.message),d=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(c),config:null!=(b=a.config)?b:this.config});this.sendPromise=d.then(()=>void 0).catch(()=>void 0);let e=await d;return this.processStreamResponse(e,c)}getHistory(a=!1){return structuredClone(a?cT(this.history):this.history)}processStreamResponse(a,b){return cQ(this,arguments,function*(){let c=[];try{for(var d,e,f,g,h,i,j,k=!0,l=cR(a);!(d=(j=yield cP(l.next())).done);k=!0){if(g=j.value,k=!1,function(a){var b;if(void 0==a.candidates||0===a.candidates.length)return!1;let c=null==(b=a.candidates[0])?void 0:b.content;return void 0!==c&&cS(c)}(g)){let a=null==(i=null==(h=g.candidates)?void 0:h[0])?void 0:i.content;void 0!==a&&c.push(a)}yield yield cP(g)}}catch(a){e={error:a}}finally{try{!k&&!d&&(f=l.return)&&(yield cP(f.call(l)))}finally{if(e)throw e.error}}this.recordHistory(b,c)})}recordHistory(a,b,c){let d=[];b.length>0&&b.every(a=>void 0!==a.role)?d=b:d.push({role:"model",parts:[]}),c&&c.length>0?this.history.push(...cT(c)):this.history.push(a),this.history.push(...d)}}class cW extends Error{constructor(a){super(a.message),this.name="ApiError",this.status=a.status,Object.setPrototypeOf(this,cW.prototype)}}class cX extends bE{constructor(a){super(),this.apiClient=a,this.list=async(a={})=>new cJ(bv.PAGED_ITEM_FILES,a=>this.listInternal(a),await this.listInternal(a),a)}async upload(a){if(this.apiClient.isVertexAI())throw Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(a.file,a.config).then(a=>a)}async download(a){await this.apiClient.downloadFile(a)}async registerFiles(a){throw Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(a){return this.registerFilesInternal(a)}async listInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j=(f={},null!=(g=bH(a,["config"]))&&(h=bH(g,["pageSize"]),void 0!==f&&null!=h&&bG(f,["_query","pageSize"],h),i=bH(g,["pageToken"]),void 0!==f&&null!=i&&bG(f,["_query","pageToken"],i)),f);return d=bF("files",j._url),e=j._query,delete j._url,delete j._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(j),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["files"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["files"],a)}return b}(a),c=new b3;return Object.assign(c,b),c})}}async createInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h=(f={},null!=(g=bH(a,["file"]))&&bG(f,["file"],g),f);return d=bF("upload/v1beta/files",h._url),e=h._query,delete h._url,delete h._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(h),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new b4;return Object.assign(e,d),e})}}async get(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h=(f={},null!=(g=bH(a,["name"]))&&bG(f,["_url","file"],cy(g)),f);return d=bF("files/{file}",h._url),e=h._query,delete h._url,delete h._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}}async delete(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h=(f={},null!=(g=bH(a,["name"]))&&bG(f,["_url","file"],cy(g)),f);return d=bF("files/{file}",h._url),e=h._query,delete h._url,delete h._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new b5;return Object.assign(e,d),e})}}async registerFilesInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h=(f={},null!=(g=bH(a,["uris"]))&&bG(f,["uris"],g),f);return d=bF("files:register",h._url),e=h._query,delete h._url,delete h._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(h),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["files"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["files"],a)}return b}(a),c=new b6;return Object.assign(c,b),c})}}}function cY(a){if(void 0!==bH(a,["languageCodes"]))throw Error("languageCodes parameter is not supported in Gemini API.");return{}}function cZ(a){let b={},c=bH(a,["data"]);if(null!=c&&bG(b,["data"],c),void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}function c$(a,b){let c={},d=bH(a,["parts"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return c={},null!=(d=bH(b=a,["mediaResolution"]))&&bG(c,["mediaResolution"],d),null!=(e=bH(b,["codeExecutionResult"]))&&bG(c,["codeExecutionResult"],e),null!=(f=bH(b,["executableCode"]))&&bG(c,["executableCode"],f),null!=(g=bH(b,["fileData"]))&&bG(c,["fileData"],function(a){let b={};if(void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let c=bH(a,["fileUri"]);null!=c&&bG(b,["fileUri"],c);let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(g)),null!=(h=bH(b,["functionCall"]))&&bG(c,["functionCall"],function(a){let b={},c=bH(a,["id"]);null!=c&&bG(b,["id"],c);let d=bH(a,["args"]);null!=d&&bG(b,["args"],d);let e=bH(a,["name"]);if(null!=e&&bG(b,["name"],e),void 0!==bH(a,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==bH(a,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return b}(h)),null!=(i=bH(b,["functionResponse"]))&&bG(c,["functionResponse"],i),null!=(j=bH(b,["inlineData"]))&&bG(c,["inlineData"],function(a){let b={},c=bH(a,["data"]);if(null!=c&&bG(b,["data"],c),void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(j)),null!=(k=bH(b,["text"]))&&bG(c,["text"],k),null!=(l=bH(b,["thought"]))&&bG(c,["thought"],l),null!=(m=bH(b,["thoughtSignature"]))&&bG(c,["thoughtSignature"],m),null!=(n=bH(b,["videoMetadata"]))&&bG(c,["videoMetadata"],n),null!=(o=bH(b,["toolCall"]))&&bG(c,["toolCall"],o),null!=(p=bH(b,["toolResponse"]))&&bG(c,["toolResponse"],p),null!=(q=bH(b,["partMetadata"]))&&bG(c,["partMetadata"],q),c})),bG(c,["parts"],a)}let e=bH(a,["role"]);return null!=e&&bG(c,["role"],e),c}function c_(a,b){let c={},d=bH(a,["parts"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["mediaResolution"]);null!=c&&bG(b,["mediaResolution"],c);let d=bH(a,["codeExecutionResult"]);null!=d&&bG(b,["codeExecutionResult"],d);let e=bH(a,["executableCode"]);null!=e&&bG(b,["executableCode"],e);let f=bH(a,["fileData"]);null!=f&&bG(b,["fileData"],f);let g=bH(a,["functionCall"]);null!=g&&bG(b,["functionCall"],g);let h=bH(a,["functionResponse"]);null!=h&&bG(b,["functionResponse"],h);let i=bH(a,["inlineData"]);null!=i&&bG(b,["inlineData"],i);let j=bH(a,["text"]);null!=j&&bG(b,["text"],j);let k=bH(a,["thought"]);null!=k&&bG(b,["thought"],k);let l=bH(a,["thoughtSignature"]);null!=l&&bG(b,["thoughtSignature"],l);let m=bH(a,["videoMetadata"]);if(null!=m&&bG(b,["videoMetadata"],m),void 0!==bH(a,["toolCall"]))throw Error("toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["toolResponse"]))throw Error("toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["partMetadata"]))throw Error("partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(c,["parts"],a)}let e=bH(a,["role"]);return null!=e&&bG(c,["role"],e),c}function c0(a,b,c){let d={},e=bH(b,["model"]);null!=e&&bG(d,["_url","model"],cb(a,e));let f=bH(b,["contents"]);if(null!=f){let a=co(f);Array.isArray(a)&&(a=a.map(a=>c$(a))),bG(d,["contents"],a)}let g=bH(b,["config"]);return null!=g&&bG(d,["generationConfig"],function(a,b,c){var d;let e,f,g,h,i={},j=bH(b,["systemInstruction"]);void 0!==c&&null!=j&&bG(c,["systemInstruction"],c$(cm(j)));let k=bH(b,["temperature"]);null!=k&&bG(i,["temperature"],k);let l=bH(b,["topP"]);null!=l&&bG(i,["topP"],l);let m=bH(b,["topK"]);null!=m&&bG(i,["topK"],m);let n=bH(b,["candidateCount"]);null!=n&&bG(i,["candidateCount"],n);let o=bH(b,["maxOutputTokens"]);null!=o&&bG(i,["maxOutputTokens"],o);let p=bH(b,["stopSequences"]);null!=p&&bG(i,["stopSequences"],p);let q=bH(b,["responseLogprobs"]);null!=q&&bG(i,["responseLogprobs"],q);let r=bH(b,["logprobs"]);null!=r&&bG(i,["logprobs"],r);let s=bH(b,["presencePenalty"]);null!=s&&bG(i,["presencePenalty"],s);let t=bH(b,["frequencyPenalty"]);null!=t&&bG(i,["frequencyPenalty"],t);let u=bH(b,["seed"]);null!=u&&bG(i,["seed"],u);let v=bH(b,["responseMimeType"]);null!=v&&bG(i,["responseMimeType"],v);let w=bH(b,["responseSchema"]);null!=w&&bG(i,["responseSchema"],cp(w));let x=bH(b,["responseJsonSchema"]);if(null!=x&&bG(i,["responseJsonSchema"],x),void 0!==bH(b,["routingConfig"]))throw Error("routingConfig parameter is not supported in Gemini API.");if(void 0!==bH(b,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is not supported in Gemini API.");let y=bH(b,["safetySettings"]);if(void 0!==c&&null!=y){let a=y;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["category"]);if(null!=c&&bG(b,["category"],c),void 0!==bH(a,["method"]))throw Error("method parameter is not supported in Gemini API.");let d=bH(a,["threshold"]);return null!=d&&bG(b,["threshold"],d),b})(a))),bG(c,["safetySettings"],a)}let z=bH(b,["tools"]);if(void 0!==c&&null!=z){let a=ct(z);Array.isArray(a)&&(a=a.map(a=>(function(a){let b,c,d,e={};if(void 0!==bH(a,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let f=bH(a,["computerUse"]);null!=f&&bG(e,["computerUse"],f);let g=bH(a,["fileSearch"]);null!=g&&bG(e,["fileSearch"],g);let h=bH(a,["googleSearch"]);null!=h&&bG(e,["googleSearch"],function(a){let b={},c=bH(a,["searchTypes"]);if(null!=c&&bG(b,["searchTypes"],c),void 0!==bH(a,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");if(void 0!==bH(a,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");let d=bH(a,["timeRangeFilter"]);return null!=d&&bG(b,["timeRangeFilter"],d),b}(h));let i=bH(a,["googleMaps"]);null!=i&&bG(e,["googleMaps"],(b={},null!=(c=bH(i,["authConfig"]))&&bG(b,["authConfig"],function(a){let b={},c=bH(a,["apiKey"]);if(null!=c&&bG(b,["apiKey"],c),void 0!==bH(a,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["authType"]))throw Error("authType parameter is not supported in Gemini API.");if(void 0!==bH(a,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oauthConfig"]))throw Error("oauthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oidcConfig"]))throw Error("oidcConfig parameter is not supported in Gemini API.");return b}(c)),null!=(d=bH(i,["enableWidget"]))&&bG(b,["enableWidget"],d),b));let j=bH(a,["codeExecution"]);if(null!=j&&bG(e,["codeExecution"],j),void 0!==bH(a,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let k=bH(a,["functionDeclarations"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["functionDeclarations"],a)}let l=bH(a,["googleSearchRetrieval"]);if(null!=l&&bG(e,["googleSearchRetrieval"],l),void 0!==bH(a,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is not supported in Gemini API.");let m=bH(a,["urlContext"]);null!=m&&bG(e,["urlContext"],m);let n=bH(a,["mcpServers"]);if(null!=n){let a=n;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["mcpServers"],a)}return e})(cs(a)))),bG(c,["tools"],a)}let A=bH(b,["toolConfig"]);if(void 0!==c&&null!=A&&bG(c,["toolConfig"],(e={},null!=(f=bH(d=A,["retrievalConfig"]))&&bG(e,["retrievalConfig"],f),null!=(g=bH(d,["functionCallingConfig"]))&&bG(e,["functionCallingConfig"],function(a){let b={},c=bH(a,["allowedFunctionNames"]);null!=c&&bG(b,["allowedFunctionNames"],c);let d=bH(a,["mode"]);if(null!=d&&bG(b,["mode"],d),void 0!==bH(a,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return b}(g)),null!=(h=bH(d,["includeServerSideToolInvocations"]))&&bG(e,["includeServerSideToolInvocations"],h),e)),void 0!==bH(b,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let B=bH(b,["cachedContent"]);void 0!==c&&null!=B&&bG(c,["cachedContent"],cu(a,B));let C=bH(b,["responseModalities"]);null!=C&&bG(i,["responseModalities"],C);let D=bH(b,["mediaResolution"]);null!=D&&bG(i,["mediaResolution"],D);let E=bH(b,["speechConfig"]);if(null!=E&&bG(i,["speechConfig"],cq(E)),void 0!==bH(b,["audioTimestamp"]))throw Error("audioTimestamp parameter is not supported in Gemini API.");let F=bH(b,["thinkingConfig"]);null!=F&&bG(i,["thinkingConfig"],F);let G=bH(b,["imageConfig"]);null!=G&&bG(i,["imageConfig"],function(a){let b={},c=bH(a,["aspectRatio"]);null!=c&&bG(b,["aspectRatio"],c);let d=bH(a,["imageSize"]);if(null!=d&&bG(b,["imageSize"],d),void 0!==bH(a,["personGeneration"]))throw Error("personGeneration parameter is not supported in Gemini API.");if(void 0!==bH(a,["prominentPeople"]))throw Error("prominentPeople parameter is not supported in Gemini API.");if(void 0!==bH(a,["outputMimeType"]))throw Error("outputMimeType parameter is not supported in Gemini API.");if(void 0!==bH(a,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is not supported in Gemini API.");if(void 0!==bH(a,["imageOutputOptions"]))throw Error("imageOutputOptions parameter is not supported in Gemini API.");return b}(G));let H=bH(b,["enableEnhancedCivicAnswers"]);if(null!=H&&bG(i,["enableEnhancedCivicAnswers"],H),void 0!==bH(b,["modelArmorConfig"]))throw Error("modelArmorConfig parameter is not supported in Gemini API.");let I=bH(b,["serviceTier"]);return void 0!==c&&null!=I&&bG(c,["serviceTier"],I),i}(a,g,d)),d}function c1(a,b,c){let d={},e=bH(b,["model"]);null!=e&&bG(d,["_url","model"],cb(a,e));let f=bH(b,["contents"]);if(null!=f){let a=co(f);Array.isArray(a)&&(a=a.map(a=>c_(a))),bG(d,["contents"],a)}let g=bH(b,["config"]);return null!=g&&bG(d,["generationConfig"],function(a,b,c){var d;let e,f,g,h,i,j,k,l,m={},n=bH(b,["systemInstruction"]);void 0!==c&&null!=n&&bG(c,["systemInstruction"],c_(cm(n)));let o=bH(b,["temperature"]);null!=o&&bG(m,["temperature"],o);let p=bH(b,["topP"]);null!=p&&bG(m,["topP"],p);let q=bH(b,["topK"]);null!=q&&bG(m,["topK"],q);let r=bH(b,["candidateCount"]);null!=r&&bG(m,["candidateCount"],r);let s=bH(b,["maxOutputTokens"]);null!=s&&bG(m,["maxOutputTokens"],s);let t=bH(b,["stopSequences"]);null!=t&&bG(m,["stopSequences"],t);let u=bH(b,["responseLogprobs"]);null!=u&&bG(m,["responseLogprobs"],u);let v=bH(b,["logprobs"]);null!=v&&bG(m,["logprobs"],v);let w=bH(b,["presencePenalty"]);null!=w&&bG(m,["presencePenalty"],w);let x=bH(b,["frequencyPenalty"]);null!=x&&bG(m,["frequencyPenalty"],x);let y=bH(b,["seed"]);null!=y&&bG(m,["seed"],y);let z=bH(b,["responseMimeType"]);null!=z&&bG(m,["responseMimeType"],z);let A=bH(b,["responseSchema"]);null!=A&&bG(m,["responseSchema"],cp(A));let B=bH(b,["responseJsonSchema"]);null!=B&&bG(m,["responseJsonSchema"],B);let C=bH(b,["routingConfig"]);null!=C&&bG(m,["routingConfig"],C);let D=bH(b,["modelSelectionConfig"]);null!=D&&bG(m,["modelConfig"],D);let E=bH(b,["safetySettings"]);if(void 0!==c&&null!=E){let a=E;Array.isArray(a)&&(a=a.map(a=>a)),bG(c,["safetySettings"],a)}let F=bH(b,["tools"]);if(void 0!==c&&null!=F){let a=ct(F);Array.isArray(a)&&(a=a.map(a=>dc(cs(a)))),bG(c,["tools"],a)}let G=bH(b,["toolConfig"]);void 0!==c&&null!=G&&bG(c,["toolConfig"],function(a){let b={},c=bH(a,["retrievalConfig"]);null!=c&&bG(b,["retrievalConfig"],c);let d=bH(a,["functionCallingConfig"]);if(null!=d&&bG(b,["functionCallingConfig"],d),void 0!==bH(a,["includeServerSideToolInvocations"]))throw Error("includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b}(G));let H=bH(b,["labels"]);void 0!==c&&null!=H&&bG(c,["labels"],H);let I=bH(b,["cachedContent"]);void 0!==c&&null!=I&&bG(c,["cachedContent"],cu(a,I));let J=bH(b,["responseModalities"]);null!=J&&bG(m,["responseModalities"],J);let K=bH(b,["mediaResolution"]);null!=K&&bG(m,["mediaResolution"],K);let L=bH(b,["speechConfig"]);null!=L&&bG(m,["speechConfig"],cq(L));let M=bH(b,["audioTimestamp"]);null!=M&&bG(m,["audioTimestamp"],M);let N=bH(b,["thinkingConfig"]);null!=N&&bG(m,["thinkingConfig"],N);let O=bH(b,["imageConfig"]);if(null!=O&&bG(m,["imageConfig"],(e={},null!=(f=bH(d=O,["aspectRatio"]))&&bG(e,["aspectRatio"],f),null!=(g=bH(d,["imageSize"]))&&bG(e,["imageSize"],g),null!=(h=bH(d,["personGeneration"]))&&bG(e,["personGeneration"],h),null!=(i=bH(d,["prominentPeople"]))&&bG(e,["prominentPeople"],i),null!=(j=bH(d,["outputMimeType"]))&&bG(e,["imageOutputOptions","mimeType"],j),null!=(k=bH(d,["outputCompressionQuality"]))&&bG(e,["imageOutputOptions","compressionQuality"],k),null!=(l=bH(d,["imageOutputOptions"]))&&bG(e,["imageOutputOptions"],l),e)),void 0!==bH(b,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let P=bH(b,["modelArmorConfig"]);void 0!==c&&null!=P&&bG(c,["modelArmorConfig"],P);let Q=bH(b,["serviceTier"]);return void 0!==c&&null!=Q&&bG(c,["serviceTier"],Q),m}(a,g,d)),d}function c2(a,b){let c={},d=bH(a,["sdkHttpResponse"]);null!=d&&bG(c,["sdkHttpResponse"],d);let e=bH(a,["candidates"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["content"]);null!=c&&bG(b,["content"],c);let d=bH(a,["citationMetadata"]);null!=d&&bG(b,["citationMetadata"],function(a){let b={},c=bH(a,["citationSources"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["citations"],a)}return b}(d));let e=bH(a,["tokenCount"]);null!=e&&bG(b,["tokenCount"],e);let f=bH(a,["finishReason"]);null!=f&&bG(b,["finishReason"],f);let g=bH(a,["groundingMetadata"]);null!=g&&bG(b,["groundingMetadata"],g);let h=bH(a,["avgLogprobs"]);null!=h&&bG(b,["avgLogprobs"],h);let i=bH(a,["index"]);null!=i&&bG(b,["index"],i);let j=bH(a,["logprobsResult"]);null!=j&&bG(b,["logprobsResult"],j);let k=bH(a,["safetyRatings"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["safetyRatings"],a)}let l=bH(a,["urlContextMetadata"]);return null!=l&&bG(b,["urlContextMetadata"],l),b})(a))),bG(c,["candidates"],a)}let f=bH(a,["modelVersion"]);null!=f&&bG(c,["modelVersion"],f);let g=bH(a,["promptFeedback"]);null!=g&&bG(c,["promptFeedback"],g);let h=bH(a,["responseId"]);null!=h&&bG(c,["responseId"],h);let i=bH(a,["usageMetadata"]);null!=i&&bG(c,["usageMetadata"],i);let j=bH(a,["modelStatus"]);return null!=j&&bG(c,["modelStatus"],j),c}function c3(a,b){let c={},d=bH(a,["sdkHttpResponse"]);null!=d&&bG(c,["sdkHttpResponse"],d);let e=bH(a,["candidates"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(c,["candidates"],a)}let f=bH(a,["createTime"]);null!=f&&bG(c,["createTime"],f);let g=bH(a,["modelVersion"]);null!=g&&bG(c,["modelVersion"],g);let h=bH(a,["promptFeedback"]);null!=h&&bG(c,["promptFeedback"],h);let i=bH(a,["responseId"]);null!=i&&bG(c,["responseId"],i);let j=bH(a,["usageMetadata"]);return null!=j&&bG(c,["usageMetadata"],j),c}function c4(a,b){let c={},d=bH(a,["_self"]);null!=d&&bG(c,["image"],c5(d));let e=bH(a,["raiFilteredReason"]);null!=e&&bG(c,["raiFilteredReason"],e);let f=bH(a,["_self"]);null!=f&&bG(c,["safetyAttributes"],db(f));let g=bH(a,["prompt"]);return null!=g&&bG(c,["enhancedPrompt"],g),c}function c5(a,b){let c={},d=bH(a,["gcsUri"]);null!=d&&bG(c,["gcsUri"],d);let e=bH(a,["bytesBase64Encoded"]);null!=e&&bG(c,["imageBytes"],bI(e));let f=bH(a,["mimeType"]);return null!=f&&bG(c,["mimeType"],f),c}function c6(a,b){let c={};if(void 0!==bH(a,["gcsUri"]))throw Error("gcsUri parameter is not supported in Gemini API.");let d=bH(a,["imageBytes"]);null!=d&&bG(c,["bytesBase64Encoded"],bI(d));let e=bH(a,["mimeType"]);return null!=e&&bG(c,["mimeType"],e),c}function c7(a,b){let c={},d=bH(a,["gcsUri"]);null!=d&&bG(c,["gcsUri"],d);let e=bH(a,["imageBytes"]);null!=e&&bG(c,["bytesBase64Encoded"],bI(e));let f=bH(a,["mimeType"]);return null!=f&&bG(c,["mimeType"],f),c}function c8(a,b){var c;let d,e,f,g,h={},i=bH(a,["name"]);null!=i&&bG(h,["name"],i);let j=bH(a,["displayName"]);null!=j&&bG(h,["displayName"],j);let k=bH(a,["description"]);null!=k&&bG(h,["description"],k);let l=bH(a,["version"]);null!=l&&bG(h,["version"],l);let m=bH(a,["_self"]);null!=m&&bG(h,["tunedModelInfo"],(d={},null!=(e=bH(c=m,["baseModel"]))&&bG(d,["baseModel"],e),null!=(f=bH(c,["createTime"]))&&bG(d,["createTime"],f),null!=(g=bH(c,["updateTime"]))&&bG(d,["updateTime"],g),d));let n=bH(a,["inputTokenLimit"]);null!=n&&bG(h,["inputTokenLimit"],n);let o=bH(a,["outputTokenLimit"]);null!=o&&bG(h,["outputTokenLimit"],o);let p=bH(a,["supportedGenerationMethods"]);null!=p&&bG(h,["supportedActions"],p);let q=bH(a,["temperature"]);null!=q&&bG(h,["temperature"],q);let r=bH(a,["maxTemperature"]);null!=r&&bG(h,["maxTemperature"],r);let s=bH(a,["topP"]);null!=s&&bG(h,["topP"],s);let t=bH(a,["topK"]);null!=t&&bG(h,["topK"],t);let u=bH(a,["thinking"]);return null!=u&&bG(h,["thinking"],u),h}function c9(a,b){var c;let d,e,f,g,h={},i=bH(a,["name"]);null!=i&&bG(h,["name"],i);let j=bH(a,["displayName"]);null!=j&&bG(h,["displayName"],j);let k=bH(a,["description"]);null!=k&&bG(h,["description"],k);let l=bH(a,["versionId"]);null!=l&&bG(h,["version"],l);let m=bH(a,["deployedModels"]);if(null!=m){let a=m;Array.isArray(a)&&(a=a.map(a=>{let b,c,d;return b={},null!=(c=bH(a,["endpoint"]))&&bG(b,["name"],c),null!=(d=bH(a,["deployedModelId"]))&&bG(b,["deployedModelId"],d),b})),bG(h,["endpoints"],a)}let n=bH(a,["labels"]);null!=n&&bG(h,["labels"],n);let o=bH(a,["_self"]);null!=o&&bG(h,["tunedModelInfo"],(d={},null!=(e=bH(c=o,["labels","google-vertex-llm-tuning-base-model-id"]))&&bG(d,["baseModel"],e),null!=(f=bH(c,["createTime"]))&&bG(d,["createTime"],f),null!=(g=bH(c,["updateTime"]))&&bG(d,["updateTime"],g),d));let p=bH(a,["defaultCheckpointId"]);null!=p&&bG(h,["defaultCheckpointId"],p);let q=bH(a,["checkpoints"]);if(null!=q){let a=q;Array.isArray(a)&&(a=a.map(a=>a)),bG(h,["checkpoints"],a)}return h}function da(a,b){let c={},d=bH(a,["safetyAttributes","categories"]);null!=d&&bG(c,["categories"],d);let e=bH(a,["safetyAttributes","scores"]);null!=e&&bG(c,["scores"],e);let f=bH(a,["contentType"]);return null!=f&&bG(c,["contentType"],f),c}function db(a,b){let c={},d=bH(a,["safetyAttributes","categories"]);null!=d&&bG(c,["categories"],d);let e=bH(a,["safetyAttributes","scores"]);null!=e&&bG(c,["scores"],e);let f=bH(a,["contentType"]);return null!=f&&bG(c,["contentType"],f),c}function dc(a,b){let c={},d=bH(a,["retrieval"]);null!=d&&bG(c,["retrieval"],d);let e=bH(a,["computerUse"]);if(null!=e&&bG(c,["computerUse"],e),void 0!==bH(a,["fileSearch"]))throw Error("fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let f=bH(a,["googleSearch"]);null!=f&&bG(c,["googleSearch"],f);let g=bH(a,["googleMaps"]);null!=g&&bG(c,["googleMaps"],g);let h=bH(a,["codeExecution"]);null!=h&&bG(c,["codeExecution"],h);let i=bH(a,["enterpriseWebSearch"]);null!=i&&bG(c,["enterpriseWebSearch"],i);let j=bH(a,["functionDeclarations"]);if(null!=j){let a=j;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["description"]);null!=c&&bG(b,["description"],c);let d=bH(a,["name"]);null!=d&&bG(b,["name"],d);let e=bH(a,["parameters"]);null!=e&&bG(b,["parameters"],e);let f=bH(a,["parametersJsonSchema"]);null!=f&&bG(b,["parametersJsonSchema"],f);let g=bH(a,["response"]);null!=g&&bG(b,["response"],g);let h=bH(a,["responseJsonSchema"]);if(null!=h&&bG(b,["responseJsonSchema"],h),void 0!==bH(a,["behavior"]))throw Error("behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(c,["functionDeclarations"],a)}let k=bH(a,["googleSearchRetrieval"]);null!=k&&bG(c,["googleSearchRetrieval"],k);let l=bH(a,["parallelAiSearch"]);null!=l&&bG(c,["parallelAiSearch"],l);let m=bH(a,["urlContext"]);if(null!=m&&bG(c,["urlContext"],m),void 0!==bH(a,["mcpServers"]))throw Error("mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return c}function dd(a,b){let c={},d=bH(a,["uri"]);null!=d&&bG(c,["uri"],d);let e=bH(a,["videoBytes"]);null!=e&&bG(c,["encodedVideo"],bI(e));let f=bH(a,["mimeType"]);return null!=f&&bG(c,["encoding"],f),c}function de(a,b){let c={},d=bH(a,["uri"]);null!=d&&bG(c,["gcsUri"],d);let e=bH(a,["videoBytes"]);null!=e&&bG(c,["bytesBase64Encoded"],bI(e));let f=bH(a,["mimeType"]);return null!=f&&bG(c,["mimeType"],f),c}function df(a,b){let c=bH(a,["mimeType"]);void 0!==b&&null!=c&&bG(b,["mimeType"],c);let d=bH(a,["displayName"]);void 0!==b&&null!=d&&bG(b,["displayName"],d);let e=bH(a,["customMetadata"]);if(void 0!==b&&null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["customMetadata"],a)}let f=bH(a,["chunkingConfig"]);return void 0!==b&&null!=f&&bG(b,["chunkingConfig"],f),{}}let dg="x-goog-api-client",dh=new Set(["us","eu"]),di=[408,429,500,502,503,504];class dj{constructor(a){var b,c,d;this.clientOptions=Object.assign({},a),this.customBaseUrl=null==(b=a.httpOptions)?void 0:b.baseUrl,this.clientOptions.vertexai&&(this.clientOptions.project&&this.clientOptions.location?this.clientOptions.apiKey=void 0:this.clientOptions.apiKey&&(this.clientOptions.project=void 0,this.clientOptions.location=void 0));const e={};if(this.clientOptions.vertexai){if(this.clientOptions.location||this.clientOptions.apiKey||this.customBaseUrl||(this.clientOptions.location="global"),!(this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey)&&!this.customBaseUrl)throw Error("Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.");const b=a.project&&a.location||!!a.apiKey;this.customBaseUrl&&!b?(e.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey||"global"===this.clientOptions.location?e.baseUrl="https://aiplatform.googleapis.com/":this.clientOptions.project&&this.clientOptions.location&&dh.has(this.clientOptions.location)?e.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(e.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),e.apiVersion=null!=(c=this.clientOptions.apiVersion)?c:"v1beta1"}else this.clientOptions.apiKey||console.warn("API key should be set when using the Gemini API."),e.apiVersion=null!=(d=this.clientOptions.apiVersion)?d:"v1beta",e.baseUrl="https://generativelanguage.googleapis.com/";e.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=e,a.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(e,a.httpOptions))}isVertexAI(){var a;return null!=(a=this.clientOptions.vertexai)&&a}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){let a=new Headers;return await this.clientOptions.auth.addAuthHeaders(a),a}getApiVersion(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.apiVersion)return this.clientOptions.httpOptions.apiVersion;throw Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.baseUrl)return this.clientOptions.httpOptions.baseUrl;throw Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.headers)return this.clientOptions.httpOptions.headers;throw Error("Headers are not set.")}getRequestUrlInternal(a){if(!a||void 0===a.baseUrl||void 0===a.apiVersion)throw Error("HTTP options are not correctly set.");let b=[a.baseUrl.endsWith("/")?a.baseUrl.slice(0,-1):a.baseUrl];return a.apiVersion&&""!==a.apiVersion&&b.push(a.apiVersion),b.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let a=new URL(this.getBaseUrl());return a.protocol="http:"==a.protocol?"ws":"wss",a.toString()}setBaseUrl(a){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=a;else throw Error("HTTP options are not correctly set.")}constructUrl(a,b,c){let d=[this.getRequestUrlInternal(b)];return c&&d.push(this.getBaseResourcePath()),""!==a&&d.push(a),new URL(`${d.join("/")}`)}shouldPrependVertexProjectPath(a,b){return!(b.baseUrl&&b.baseUrlResourceScope===a2.COLLECTION||this.clientOptions.apiKey||!this.clientOptions.vertexai||a.path.startsWith("projects/")||"GET"===a.httpMethod&&a.path.startsWith("publishers/google/models"))}async request(a){let b=this.clientOptions.httpOptions;a.httpOptions&&(b=this.patchHttpOptions(this.clientOptions.httpOptions,a.httpOptions));let c=this.shouldPrependVertexProjectPath(a,b),d=this.constructUrl(a.path,b,c);if(a.queryParams)for(let[b,c]of Object.entries(a.queryParams))d.searchParams.append(b,String(c));let e={};if("GET"===a.httpMethod){if(a.body&&"{}"!==a.body)throw Error("Request body should be empty for GET request, but got non empty request body")}else e.body=a.body;return e=await this.includeExtraHttpOptionsToRequestInit(e,b,d.toString(),a.abortSignal),this.unaryApiCall(d,e,a.httpMethod)}patchHttpOptions(a,b){let c=JSON.parse(JSON.stringify(a));for(let[a,d]of Object.entries(b))"object"==typeof d?c[a]=Object.assign(Object.assign({},c[a]),d):void 0!==d&&(c[a]=d);return c}async requestStream(a){let b=this.clientOptions.httpOptions;a.httpOptions&&(b=this.patchHttpOptions(this.clientOptions.httpOptions,a.httpOptions));let c=this.shouldPrependVertexProjectPath(a,b),d=this.constructUrl(a.path,b,c);d.searchParams.has("alt")&&"sse"===d.searchParams.get("alt")||d.searchParams.set("alt","sse");let e={};return e.body=a.body,e=await this.includeExtraHttpOptionsToRequestInit(e,b,d.toString(),a.abortSignal),this.streamApiCall(d,e,a.httpMethod)}async includeExtraHttpOptionsToRequestInit(a,b,c,d){if(b&&b.timeout||d){let c=new AbortController,e=c.signal;if(b.timeout&&(null==b?void 0:b.timeout)>0){let a=setTimeout(()=>c.abort(),b.timeout);a&&"function"==typeof a.unref&&a.unref()}d&&d.addEventListener("abort",()=>{c.abort()}),a.signal=e}return b&&null!==b.extraBody&&function(a,b){if(!b||0===Object.keys(b).length)return;if(a.body instanceof Blob)return console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");let c={};if("string"==typeof a.body&&a.body.length>0)try{let b=JSON.parse(a.body);if("object"!=typeof b||null===b||Array.isArray(b))return void console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");c=b}catch(a){console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}a.body=JSON.stringify(function a(b,c){let d=Object.assign({},b);for(let b in c)if(Object.prototype.hasOwnProperty.call(c,b)){let e=c[b],f=d[b];e&&"object"==typeof e&&!Array.isArray(e)&&f&&"object"==typeof f&&!Array.isArray(f)?d[b]=a(f,e):(f&&e&&typeof f!=typeof e&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${b}". Original type: ${typeof f}, New type: ${typeof e}. Overwriting.`),d[b]=e)}return d}(c,b))}(a,b.extraBody),a.headers=await this.getHeadersInternal(b,c),a}async unaryApiCall(a,b,c){return this.apiCall(a.toString(),Object.assign(Object.assign({},b),{method:c})).then(async a=>(await dk(a),new bK(a))).catch(a=>{if(a instanceof Error)throw a;throw Error(JSON.stringify(a))})}async streamApiCall(a,b,c){return this.apiCall(a.toString(),Object.assign(Object.assign({},b),{method:c})).then(async a=>(await dk(a),this.processStreamResponse(a))).catch(a=>{if(a instanceof Error)throw a;throw Error(JSON.stringify(a))})}processStreamResponse(a){return cQ(this,arguments,function*(){var b;let c=null==(b=null==a?void 0:a.body)?void 0:b.getReader(),d=new TextDecoder("utf-8");if(!c)throw Error("Response body is empty");try{let b="",e="data:",f=["\n\n","\r\r","\r\n\r\n"];for(;;){let{done:g,value:h}=yield cP(c.read());if(g){if(b.trim().length>0)throw Error("Incomplete JSON segment at the end");break}let i=d.decode(h,{stream:!0});try{let a=JSON.parse(i);if("error"in a){let b=JSON.parse(JSON.stringify(a.error)),c=b.status,d=b.code,e=`got status: ${c}. ${JSON.stringify(a)}`;if(d>=400&&d<600)throw new cW({message:e,status:d})}}catch(a){if("ApiError"===a.name)throw a}b+=i;let j=-1,k=0;for(;;){for(let a of(j=-1,k=0,f)){let c=b.indexOf(a);-1!==c&&(-1===j||c<j)&&(j=c,k=a.length)}if(-1===j)break;let c=b.substring(0,j);b=b.substring(j+k);let d=c.trim();if(d.startsWith(e)){let b=d.substring(e.length).trim();try{let c=new Response(b,{headers:null==a?void 0:a.headers,status:null==a?void 0:a.status,statusText:null==a?void 0:a.statusText});yield yield cP(new bK(c))}catch(a){throw Error(`exception parsing stream chunk ${b}. ${a}`)}}}}}finally{c.releaseLock()}})}async apiCall(a,b){var c;if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions)return fetch(a,b);let d=this.clientOptions.httpOptions.retryOptions,e=async()=>{let c=await fetch(a,b);if(c.ok)return c;if(di.includes(c.status))throw Error(`Retryable HTTP Error: ${c.statusText}`);throw new bw.AbortError(`Non-retryable exception ${c.statusText} sending request`)};return bw(e,{retries:(null!=(c=d.attempts)?c:5)-1})}getDefaultHeaders(){let a={},b="google-genai-sdk/1.52.0 "+this.clientOptions.userAgentExtra;return a["User-Agent"]=b,a[dg]=b,a["Content-Type"]="application/json",a}async getHeadersInternal(a,b){let c=new Headers;if(a&&a.headers){for(let[b,d]of Object.entries(a.headers))c.append(b,d);a.timeout&&a.timeout>0&&c.append("X-Server-Timeout",String(Math.ceil(a.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(c,b),c}getFileName(a){var b;let c="";return"string"==typeof a&&(c=null!=(b=(c=a.replace(/[/\\]+$/,"")).split(/[/\\]/).pop())?b:""),c}async uploadFile(a,b){var c;let d={};null!=b&&(d.mimeType=b.mimeType,d.name=b.name,d.displayName=b.displayName),d.name&&!d.name.startsWith("files/")&&(d.name=`files/${d.name}`);let e=this.clientOptions.uploader,f=await e.stat(a);d.sizeBytes=String(f.size);let g=null!=(c=null==b?void 0:b.mimeType)?c:f.type;if(void 0===g||""===g)throw Error("Can not determine mimeType. Please provide mimeType in the config.");d.mimeType=g;let h={file:d},i=this.getFileName(a),j=bF("upload/v1beta/files",h._url),k=await this.fetchUploadUrl(j,d.sizeBytes,d.mimeType,i,h,null==b?void 0:b.httpOptions);return e.upload(a,k,this)}async uploadFileToFileSearchStore(a,b,c){var d;let e=this.clientOptions.uploader,f=await e.stat(b),g=String(f.size),h=null!=(d=null==c?void 0:c.mimeType)?d:f.type;if(void 0===h||""===h)throw Error("Can not determine mimeType. Please provide mimeType in the config.");let i=`upload/v1beta/${a}:uploadToFileSearchStore`,j=this.getFileName(b),k={};null!=c&&df(c,k);let l=await this.fetchUploadUrl(i,g,h,j,k,null==c?void 0:c.httpOptions);return e.uploadToFileSearchStore(b,l,this)}async downloadFile(a){let b=this.clientOptions.downloader;await b.download(a,this)}async fetchUploadUrl(a,b,c,d,e,f){var g;let h={};h=f||{apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${b}`,"X-Goog-Upload-Header-Content-Type":`${c}`},d?{"X-Goog-Upload-File-Name":d}:{})};let i=await this.request({path:a,body:JSON.stringify(e),httpMethod:"POST",httpOptions:h});if(!i||!(null==i?void 0:i.headers))throw Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");let j=null==(g=null==i?void 0:i.headers)?void 0:g["x-goog-upload-url"];if(void 0===j)throw Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return j}}async function dk(a){var b;if(void 0===a)throw Error("response is undefined");if(!a.ok){let c=a.status,d=JSON.stringify((null==(b=a.headers.get("content-type"))?void 0:b.includes("application/json"))?await a.json():{error:{message:await a.text(),code:a.status,status:a.statusText}});if(c>=400&&c<600)throw new cW({message:d,status:c});throw Error(d)}}function dl(a){for(let c of a){var b;if(null!==(b=c)&&"object"==typeof b&&b instanceof dn||"object"==typeof c&&"inputSchema"in c)return!0}return!1}function dm(a){var b;let c=null!=(b=a[dg])?b:"";a[dg]=(c+" mcp_used/unknown").trimStart()}class dn{constructor(a=[],b){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=a,this.config=b}static create(a,b){return new dn(a,b)}async initialize(){var a,b,c,d;if(this.mcpTools.length>0)return;let e={},f=[];for(let j of this.mcpClients)try{for(var g,h=!0,i=(b=void 0,cR(function(a){return cQ(this,arguments,function*(a,b=100){let c,d=0;for(;d<b;){let b=yield cP(a.listTools({cursor:c}));for(let a of b.tools)yield yield cP(a),d++;if(!b.nextCursor)break;c=b.nextCursor}})}(j)));!(a=(g=await i.next()).done);h=!0){d=g.value,h=!1,f.push(d);let a=d.name;if(e[a])throw Error(`Duplicate function name ${a} found in MCP tools. Please ensure function names are unique.`);e[a]=j}}catch(a){b={error:a}}finally{try{!h&&!a&&(c=i.return)&&await c.call(i)}finally{if(b)throw b.error}}this.mcpTools=f,this.functionNameToMcpClient=e}async tool(){return await this.initialize(),function(a,b={}){let c=[],d=new Set;for(let e of a){let a=e.name;if(d.has(a))throw Error(`Duplicate function name ${a} found in MCP tools. Please ensure function names are unique.`);d.add(a);let f=function(a,b={}){let c={name:a.name,description:a.description,parametersJsonSchema:a.inputSchema};return a.outputSchema&&(c.responseJsonSchema=a.outputSchema),b.behavior&&(c.behavior=b.behavior),{functionDeclarations:[c]}}(e,b);f.functionDeclarations&&c.push(...f.functionDeclarations)}return{functionDeclarations:c}}(this.mcpTools,this.config)}async callTool(a){await this.initialize();let b=[];for(let c of a)if(c.name in this.functionNameToMcpClient){let a,d=this.functionNameToMcpClient[c.name];this.config.timeout&&(a={timeout:this.config.timeout});let e=await d.callTool({name:c.name,arguments:c.args},void 0,a);b.push({functionResponse:{name:c.name,response:e.isError?{error:e}:e}})}return b}}async function dp(a,b,c){let d=new b9;Object.assign(d,c.data instanceof Blob?JSON.parse(await c.data.text()):JSON.parse(c.data)),b(d)}class dq{constructor(a,b,c){this.apiClient=a,this.auth=b,this.webSocketFactory=c}async connect(a){var b,c;let d;if(this.apiClient.isVertexAI())throw Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");let e=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion(),g=function(a){let b=new Headers;for(let[c,d]of Object.entries(a))b.append(c,d);return b}(this.apiClient.getDefaultHeaders()),h=this.apiClient.getApiKey(),i=`${e}/ws/google.ai.generativelanguage.${f}.GenerativeService.BidiGenerateMusic?key=${h}`,j=()=>{},k=new Promise(a=>{j=a}),l=a.callbacks,m=this.apiClient,n={onopen:function(){j({})},onmessage:a=>{dp(m,l.onmessage,a)},onerror:null!=(b=null==l?void 0:l.onerror)?b:function(a){},onclose:null!=(c=null==l?void 0:l.onclose)?c:function(a){}},o=this.webSocketFactory.create(i,(d={},g.forEach((a,b)=>{d[b]=a}),d),n);o.connect(),await k;let p=cb(this.apiClient,a.model);return o.send(JSON.stringify({setup:{model:p}})),new dr(o,this.apiClient)}}class dr{constructor(a,b){this.conn=a,this.apiClient=b}async setWeightedPrompts(a){if(!a.weightedPrompts||0===Object.keys(a.weightedPrompts).length)throw Error("Weighted prompts must be set and contain at least one entry.");let b=function(a){let b={},c=bH(a,["weightedPrompts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["weightedPrompts"],a)}return b}(a);this.conn.send(JSON.stringify({clientContent:b}))}async setMusicGenerationConfig(a){let b,c;a.musicGenerationConfig||(a.musicGenerationConfig={});let d=(b={},null!=(c=bH(a,["musicGenerationConfig"]))&&bG(b,["musicGenerationConfig"],c),b);this.conn.send(JSON.stringify(d))}sendPlaybackControl(a){this.conn.send(JSON.stringify({playbackControl:a}))}play(){this.sendPlaybackControl(bu.PLAY)}pause(){this.sendPlaybackControl(bu.PAUSE)}stop(){this.sendPlaybackControl(bu.STOP)}resetContext(){this.sendPlaybackControl(bu.RESET_CONTEXT)}close(){this.conn.close()}}async function ds(a,b,c){let d=new b8,e=JSON.parse(c.data instanceof Blob?await c.data.text():c.data instanceof ArrayBuffer?new TextDecoder().decode(c.data):c.data);if(a.isVertexAI()){let a,b,c,f,g,h,i,j,k,l,m,n;Object.assign(d,(a={},null!=(b=bH(e,["setupComplete"]))&&bG(a,["setupComplete"],b),null!=(c=bH(e,["serverContent"]))&&bG(a,["serverContent"],c),null!=(f=bH(e,["toolCall"]))&&bG(a,["toolCall"],f),null!=(g=bH(e,["toolCallCancellation"]))&&bG(a,["toolCallCancellation"],g),null!=(h=bH(e,["usageMetadata"]))&&bG(a,["usageMetadata"],function(a){let b={},c=bH(a,["promptTokenCount"]);null!=c&&bG(b,["promptTokenCount"],c);let d=bH(a,["cachedContentTokenCount"]);null!=d&&bG(b,["cachedContentTokenCount"],d);let e=bH(a,["candidatesTokenCount"]);null!=e&&bG(b,["responseTokenCount"],e);let f=bH(a,["toolUsePromptTokenCount"]);null!=f&&bG(b,["toolUsePromptTokenCount"],f);let g=bH(a,["thoughtsTokenCount"]);null!=g&&bG(b,["thoughtsTokenCount"],g);let h=bH(a,["totalTokenCount"]);null!=h&&bG(b,["totalTokenCount"],h);let i=bH(a,["promptTokensDetails"]);if(null!=i){let a=i;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["promptTokensDetails"],a)}let j=bH(a,["cacheTokensDetails"]);if(null!=j){let a=j;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["cacheTokensDetails"],a)}let k=bH(a,["candidatesTokensDetails"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["responseTokensDetails"],a)}let l=bH(a,["toolUsePromptTokensDetails"]);if(null!=l){let a=l;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["toolUsePromptTokensDetails"],a)}let m=bH(a,["trafficType"]);return null!=m&&bG(b,["trafficType"],m),b}(h)),null!=(i=bH(e,["goAway"]))&&bG(a,["goAway"],i),null!=(j=bH(e,["sessionResumptionUpdate"]))&&bG(a,["sessionResumptionUpdate"],j),null!=(k=bH(e,["voiceActivityDetectionSignal"]))&&bG(a,["voiceActivityDetectionSignal"],k),null!=(l=bH(e,["voiceActivity"]))&&bG(a,["voiceActivity"],(m={},null!=(n=bH(l,["type"]))&&bG(m,["voiceActivityType"],n),m)),a))}else Object.assign(d,e);b(d)}class dt{constructor(a,b,c){this.apiClient=a,this.auth=b,this.webSocketFactory=c,this.music=new dq(this.apiClient,this.auth,this.webSocketFactory)}async connect(a){var b,c,d,e,f,g,h,i;let j,k;if(a.config&&a.config.httpOptions)throw Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");let l=this.apiClient.getWebsocketBaseUrl(),m=this.apiClient.getApiVersion(),n=this.apiClient.getHeaders();a.config&&a.config.tools&&dl(a.config.tools)&&dm(n);let o=function(a){let b=new Headers;for(let[c,d]of Object.entries(a))b.append(c,d);return b}(n);if(this.apiClient.isVertexAI()){let a=this.apiClient.getProject(),b=this.apiClient.getLocation(),c=this.apiClient.getApiKey();this.apiClient.getCustomBaseUrl()&&!(a&&b||c)?j=l:(j=`${l}/ws/google.cloud.aiplatform.${m}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(o,j))}else{let a=this.apiClient.getApiKey(),b="BidiGenerateContent",c="key";(null==a?void 0:a.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==m&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),b="BidiGenerateContentConstrained",c="access_token"),j=`${l}/ws/google.ai.generativelanguage.${m}.GenerativeService.${b}?${c}=${a}`}let p=()=>{},q=new Promise(a=>{p=a}),r=a.callbacks,s=this.apiClient,t={onopen:function(){var a;null==(a=null==r?void 0:r.onopen)||a.call(r),p({})},onmessage:a=>{ds(s,r.onmessage,a)},onerror:null!=(b=null==r?void 0:r.onerror)?b:function(a){},onclose:null!=(c=null==r?void 0:r.onclose)?c:function(a){}},u=this.webSocketFactory.create(j,(k={},o.forEach((a,b)=>{k[b]=a}),k),t);u.connect(),await q;let v=cb(this.apiClient,a.model);if(this.apiClient.isVertexAI()&&v.startsWith("publishers/")){let a=this.apiClient.getProject(),b=this.apiClient.getLocation();a&&b&&(v=`projects/${a}/locations/${b}/`+v)}let w={};this.apiClient.isVertexAI()&&(null==(d=a.config)?void 0:d.responseModalities)===void 0&&(void 0===a.config?a.config={responseModalities:[aR.AUDIO]}:a.config.responseModalities=[aR.AUDIO]),(null==(e=a.config)?void 0:e.generationConfig)&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");let x=null!=(g=null==(f=a.config)?void 0:f.tools)?g:[],y=[];for(let a of x)this.isCallableTool(a)?y.push(await a.tool()):y.push(a);y.length>0&&(a.config.tools=y);let z={model:v,config:a.config,callbacks:a.callbacks};if(this.apiClient.isVertexAI()){let a,b,c;h=this.apiClient,a={},null!=(b=bH(z,["model"]))&&bG(a,["setup","model"],cb(h,b)),null!=(c=bH(z,["config"]))&&bG(a,["config"],function(a,b){let c=bH(a,["generationConfig"]);void 0!==b&&null!=c&&bG(b,["setup","generationConfig"],function(a){let b={},c=bH(a,["modelSelectionConfig"]);null!=c&&bG(b,["modelConfig"],c);let d=bH(a,["responseJsonSchema"]);null!=d&&bG(b,["responseJsonSchema"],d);let e=bH(a,["audioTimestamp"]);null!=e&&bG(b,["audioTimestamp"],e);let f=bH(a,["candidateCount"]);null!=f&&bG(b,["candidateCount"],f);let g=bH(a,["enableAffectiveDialog"]);null!=g&&bG(b,["enableAffectiveDialog"],g);let h=bH(a,["frequencyPenalty"]);null!=h&&bG(b,["frequencyPenalty"],h);let i=bH(a,["logprobs"]);null!=i&&bG(b,["logprobs"],i);let j=bH(a,["maxOutputTokens"]);null!=j&&bG(b,["maxOutputTokens"],j);let k=bH(a,["mediaResolution"]);null!=k&&bG(b,["mediaResolution"],k);let l=bH(a,["presencePenalty"]);null!=l&&bG(b,["presencePenalty"],l);let m=bH(a,["responseLogprobs"]);null!=m&&bG(b,["responseLogprobs"],m);let n=bH(a,["responseMimeType"]);null!=n&&bG(b,["responseMimeType"],n);let o=bH(a,["responseModalities"]);null!=o&&bG(b,["responseModalities"],o);let p=bH(a,["responseSchema"]);null!=p&&bG(b,["responseSchema"],p);let q=bH(a,["routingConfig"]);null!=q&&bG(b,["routingConfig"],q);let r=bH(a,["seed"]);null!=r&&bG(b,["seed"],r);let s=bH(a,["speechConfig"]);null!=s&&bG(b,["speechConfig"],s);let t=bH(a,["stopSequences"]);null!=t&&bG(b,["stopSequences"],t);let u=bH(a,["temperature"]);null!=u&&bG(b,["temperature"],u);let v=bH(a,["thinkingConfig"]);null!=v&&bG(b,["thinkingConfig"],v);let w=bH(a,["topK"]);null!=w&&bG(b,["topK"],w);let x=bH(a,["topP"]);if(null!=x&&bG(b,["topP"],x),void 0!==bH(a,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b}(c));let d=bH(a,["responseModalities"]);void 0!==b&&null!=d&&bG(b,["setup","generationConfig","responseModalities"],d);let e=bH(a,["temperature"]);void 0!==b&&null!=e&&bG(b,["setup","generationConfig","temperature"],e);let f=bH(a,["topP"]);void 0!==b&&null!=f&&bG(b,["setup","generationConfig","topP"],f);let g=bH(a,["topK"]);void 0!==b&&null!=g&&bG(b,["setup","generationConfig","topK"],g);let h=bH(a,["maxOutputTokens"]);void 0!==b&&null!=h&&bG(b,["setup","generationConfig","maxOutputTokens"],h);let i=bH(a,["mediaResolution"]);void 0!==b&&null!=i&&bG(b,["setup","generationConfig","mediaResolution"],i);let j=bH(a,["seed"]);void 0!==b&&null!=j&&bG(b,["setup","generationConfig","seed"],j);let k=bH(a,["speechConfig"]);void 0!==b&&null!=k&&bG(b,["setup","generationConfig","speechConfig"],cr(k));let l=bH(a,["thinkingConfig"]);void 0!==b&&null!=l&&bG(b,["setup","generationConfig","thinkingConfig"],l);let m=bH(a,["enableAffectiveDialog"]);void 0!==b&&null!=m&&bG(b,["setup","generationConfig","enableAffectiveDialog"],m);let n=bH(a,["systemInstruction"]);void 0!==b&&null!=n&&bG(b,["setup","systemInstruction"],function(a){let b={},c=bH(a,["parts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["mediaResolution"]);null!=c&&bG(b,["mediaResolution"],c);let d=bH(a,["codeExecutionResult"]);null!=d&&bG(b,["codeExecutionResult"],d);let e=bH(a,["executableCode"]);null!=e&&bG(b,["executableCode"],e);let f=bH(a,["fileData"]);null!=f&&bG(b,["fileData"],f);let g=bH(a,["functionCall"]);null!=g&&bG(b,["functionCall"],g);let h=bH(a,["functionResponse"]);null!=h&&bG(b,["functionResponse"],h);let i=bH(a,["inlineData"]);null!=i&&bG(b,["inlineData"],i);let j=bH(a,["text"]);null!=j&&bG(b,["text"],j);let k=bH(a,["thought"]);null!=k&&bG(b,["thought"],k);let l=bH(a,["thoughtSignature"]);null!=l&&bG(b,["thoughtSignature"],l);let m=bH(a,["videoMetadata"]);if(null!=m&&bG(b,["videoMetadata"],m),void 0!==bH(a,["toolCall"]))throw Error("toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["toolResponse"]))throw Error("toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");if(void 0!==bH(a,["partMetadata"]))throw Error("partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(b,["parts"],a)}let d=bH(a,["role"]);return null!=d&&bG(b,["role"],d),b}(cm(n)));let o=bH(a,["tools"]);if(void 0!==b&&null!=o){let a=ct(o);Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["retrieval"]);null!=c&&bG(b,["retrieval"],c);let d=bH(a,["computerUse"]);if(null!=d&&bG(b,["computerUse"],d),void 0!==bH(a,["fileSearch"]))throw Error("fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let e=bH(a,["googleSearch"]);null!=e&&bG(b,["googleSearch"],e);let f=bH(a,["googleMaps"]);null!=f&&bG(b,["googleMaps"],f);let g=bH(a,["codeExecution"]);null!=g&&bG(b,["codeExecution"],g);let h=bH(a,["enterpriseWebSearch"]);null!=h&&bG(b,["enterpriseWebSearch"],h);let i=bH(a,["functionDeclarations"]);if(null!=i){let a=i;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["description"]);null!=c&&bG(b,["description"],c);let d=bH(a,["name"]);null!=d&&bG(b,["name"],d);let e=bH(a,["parameters"]);null!=e&&bG(b,["parameters"],e);let f=bH(a,["parametersJsonSchema"]);null!=f&&bG(b,["parametersJsonSchema"],f);let g=bH(a,["response"]);null!=g&&bG(b,["response"],g);let h=bH(a,["responseJsonSchema"]);if(null!=h&&bG(b,["responseJsonSchema"],h),void 0!==bH(a,["behavior"]))throw Error("behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(a))),bG(b,["functionDeclarations"],a)}let j=bH(a,["googleSearchRetrieval"]);null!=j&&bG(b,["googleSearchRetrieval"],j);let k=bH(a,["parallelAiSearch"]);null!=k&&bG(b,["parallelAiSearch"],k);let l=bH(a,["urlContext"]);if(null!=l&&bG(b,["urlContext"],l),void 0!==bH(a,["mcpServers"]))throw Error("mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b})(cs(a)))),bG(b,["setup","tools"],a)}let p=bH(a,["sessionResumption"]);void 0!==b&&null!=p&&bG(b,["setup","sessionResumption"],p);let q=bH(a,["inputAudioTranscription"]);void 0!==b&&null!=q&&bG(b,["setup","inputAudioTranscription"],q);let r=bH(a,["outputAudioTranscription"]);void 0!==b&&null!=r&&bG(b,["setup","outputAudioTranscription"],r);let s=bH(a,["realtimeInputConfig"]);void 0!==b&&null!=s&&bG(b,["setup","realtimeInputConfig"],s);let t=bH(a,["contextWindowCompression"]);void 0!==b&&null!=t&&bG(b,["setup","contextWindowCompression"],t);let u=bH(a,["proactivity"]);void 0!==b&&null!=u&&bG(b,["setup","proactivity"],u);let v=bH(a,["explicitVadSignal"]);void 0!==b&&null!=v&&bG(b,["setup","explicitVadSignal"],v);let w=bH(a,["avatarConfig"]);void 0!==b&&null!=w&&bG(b,["setup","avatarConfig"],w);let x=bH(a,["safetySettings"]);if(void 0!==b&&null!=x){let a=x;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["setup","safetySettings"],a)}return{}}(c,a)),w=a}else{let a,b,c;i=this.apiClient,a={},null!=(b=bH(z,["model"]))&&bG(a,["setup","model"],cb(i,b)),null!=(c=bH(z,["config"]))&&bG(a,["config"],function(a,b){let c=bH(a,["generationConfig"]);void 0!==b&&null!=c&&bG(b,["setup","generationConfig"],c);let d=bH(a,["responseModalities"]);void 0!==b&&null!=d&&bG(b,["setup","generationConfig","responseModalities"],d);let e=bH(a,["temperature"]);void 0!==b&&null!=e&&bG(b,["setup","generationConfig","temperature"],e);let f=bH(a,["topP"]);void 0!==b&&null!=f&&bG(b,["setup","generationConfig","topP"],f);let g=bH(a,["topK"]);void 0!==b&&null!=g&&bG(b,["setup","generationConfig","topK"],g);let h=bH(a,["maxOutputTokens"]);void 0!==b&&null!=h&&bG(b,["setup","generationConfig","maxOutputTokens"],h);let i=bH(a,["mediaResolution"]);void 0!==b&&null!=i&&bG(b,["setup","generationConfig","mediaResolution"],i);let j=bH(a,["seed"]);void 0!==b&&null!=j&&bG(b,["setup","generationConfig","seed"],j);let k=bH(a,["speechConfig"]);void 0!==b&&null!=k&&bG(b,["setup","generationConfig","speechConfig"],cr(k));let l=bH(a,["thinkingConfig"]);void 0!==b&&null!=l&&bG(b,["setup","generationConfig","thinkingConfig"],l);let m=bH(a,["enableAffectiveDialog"]);void 0!==b&&null!=m&&bG(b,["setup","generationConfig","enableAffectiveDialog"],m);let n=bH(a,["systemInstruction"]);void 0!==b&&null!=n&&bG(b,["setup","systemInstruction"],function(a){let b={},c=bH(a,["parts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return c={},null!=(d=bH(b=a,["mediaResolution"]))&&bG(c,["mediaResolution"],d),null!=(e=bH(b,["codeExecutionResult"]))&&bG(c,["codeExecutionResult"],e),null!=(f=bH(b,["executableCode"]))&&bG(c,["executableCode"],f),null!=(g=bH(b,["fileData"]))&&bG(c,["fileData"],function(a){let b={};if(void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let c=bH(a,["fileUri"]);null!=c&&bG(b,["fileUri"],c);let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(g)),null!=(h=bH(b,["functionCall"]))&&bG(c,["functionCall"],function(a){let b={},c=bH(a,["id"]);null!=c&&bG(b,["id"],c);let d=bH(a,["args"]);null!=d&&bG(b,["args"],d);let e=bH(a,["name"]);if(null!=e&&bG(b,["name"],e),void 0!==bH(a,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==bH(a,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return b}(h)),null!=(i=bH(b,["functionResponse"]))&&bG(c,["functionResponse"],i),null!=(j=bH(b,["inlineData"]))&&bG(c,["inlineData"],cZ(j)),null!=(k=bH(b,["text"]))&&bG(c,["text"],k),null!=(l=bH(b,["thought"]))&&bG(c,["thought"],l),null!=(m=bH(b,["thoughtSignature"]))&&bG(c,["thoughtSignature"],m),null!=(n=bH(b,["videoMetadata"]))&&bG(c,["videoMetadata"],n),null!=(o=bH(b,["toolCall"]))&&bG(c,["toolCall"],o),null!=(p=bH(b,["toolResponse"]))&&bG(c,["toolResponse"],p),null!=(q=bH(b,["partMetadata"]))&&bG(c,["partMetadata"],q),c})),bG(b,["parts"],a)}let d=bH(a,["role"]);return null!=d&&bG(b,["role"],d),b}(cm(n)));let o=bH(a,["tools"]);if(void 0!==b&&null!=o){let a=ct(o);Array.isArray(a)&&(a=a.map(a=>(function(a){let b,c,d,e={};if(void 0!==bH(a,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let f=bH(a,["computerUse"]);null!=f&&bG(e,["computerUse"],f);let g=bH(a,["fileSearch"]);null!=g&&bG(e,["fileSearch"],g);let h=bH(a,["googleSearch"]);null!=h&&bG(e,["googleSearch"],function(a){let b={},c=bH(a,["searchTypes"]);if(null!=c&&bG(b,["searchTypes"],c),void 0!==bH(a,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");if(void 0!==bH(a,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");let d=bH(a,["timeRangeFilter"]);return null!=d&&bG(b,["timeRangeFilter"],d),b}(h));let i=bH(a,["googleMaps"]);null!=i&&bG(e,["googleMaps"],(b={},null!=(c=bH(i,["authConfig"]))&&bG(b,["authConfig"],function(a){let b={},c=bH(a,["apiKey"]);if(null!=c&&bG(b,["apiKey"],c),void 0!==bH(a,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["authType"]))throw Error("authType parameter is not supported in Gemini API.");if(void 0!==bH(a,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oauthConfig"]))throw Error("oauthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oidcConfig"]))throw Error("oidcConfig parameter is not supported in Gemini API.");return b}(c)),null!=(d=bH(i,["enableWidget"]))&&bG(b,["enableWidget"],d),b));let j=bH(a,["codeExecution"]);if(null!=j&&bG(e,["codeExecution"],j),void 0!==bH(a,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let k=bH(a,["functionDeclarations"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["functionDeclarations"],a)}let l=bH(a,["googleSearchRetrieval"]);if(null!=l&&bG(e,["googleSearchRetrieval"],l),void 0!==bH(a,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is not supported in Gemini API.");let m=bH(a,["urlContext"]);null!=m&&bG(e,["urlContext"],m);let n=bH(a,["mcpServers"]);if(null!=n){let a=n;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["mcpServers"],a)}return e})(cs(a)))),bG(b,["setup","tools"],a)}let p=bH(a,["sessionResumption"]);void 0!==b&&null!=p&&bG(b,["setup","sessionResumption"],function(a){let b={},c=bH(a,["handle"]);if(null!=c&&bG(b,["handle"],c),void 0!==bH(a,["transparent"]))throw Error("transparent parameter is not supported in Gemini API.");return b}(p));let q=bH(a,["inputAudioTranscription"]);void 0!==b&&null!=q&&bG(b,["setup","inputAudioTranscription"],cY(q));let r=bH(a,["outputAudioTranscription"]);void 0!==b&&null!=r&&bG(b,["setup","outputAudioTranscription"],cY(r));let s=bH(a,["realtimeInputConfig"]);void 0!==b&&null!=s&&bG(b,["setup","realtimeInputConfig"],s);let t=bH(a,["contextWindowCompression"]);void 0!==b&&null!=t&&bG(b,["setup","contextWindowCompression"],t);let u=bH(a,["proactivity"]);if(void 0!==b&&null!=u&&bG(b,["setup","proactivity"],u),void 0!==bH(a,["explicitVadSignal"]))throw Error("explicitVadSignal parameter is not supported in Gemini API.");let v=bH(a,["avatarConfig"]);void 0!==b&&null!=v&&bG(b,["setup","avatarConfig"],v);let w=bH(a,["safetySettings"]);if(void 0!==b&&null!=w){let a=w;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["category"]);if(null!=c&&bG(b,["category"],c),void 0!==bH(a,["method"]))throw Error("method parameter is not supported in Gemini API.");let d=bH(a,["threshold"]);return null!=d&&bG(b,["threshold"],d),b})(a))),bG(b,["setup","safetySettings"],a)}return{}}(c,a)),w=a}return delete w.config,u.send(JSON.stringify(w)),new dv(u,this.apiClient)}isCallableTool(a){return"callTool"in a&&"function"==typeof a.callTool}}let du={turnComplete:!0};class dv{constructor(a,b){this.conn=a,this.apiClient=b}tLiveClientContent(a,b){if(null!==b.turns&&void 0!==b.turns){let c=[];try{c=co(b.turns),a.isVertexAI()||(c=c.map(a=>c$(a)))}catch(a){throw Error(`Failed to parse client content "turns", type: '${typeof b.turns}'`)}return{clientContent:{turns:c,turnComplete:b.turnComplete}}}return{clientContent:{turnComplete:b.turnComplete}}}tLiveClienttToolResponse(a,b){let c=[];if(null==b.functionResponses||0===(c=Array.isArray(b.functionResponses)?b.functionResponses:[b.functionResponses]).length)throw Error("functionResponses is required.");for(let b of c){if("object"!=typeof b||null===b||!("name"in b)||!("response"in b))throw Error(`Could not parse function response, type '${typeof b}'.`);if(!a.isVertexAI()&&!("id"in b))throw Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:c}}}sendClientContent(a){a=Object.assign(Object.assign({},du),a);let b=this.tLiveClientContent(this.apiClient,a);this.conn.send(JSON.stringify(b))}sendRealtimeInput(a){let b={};b=this.apiClient.isVertexAI()?{realtimeInput:function(a){let b={},c=bH(a,["media"]);if(null!=c){let a=cd(c);Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["mediaChunks"],a)}let d=bH(a,["audio"]);null!=d&&bG(b,["audio"],cg(d));let e=bH(a,["audioStreamEnd"]);null!=e&&bG(b,["audioStreamEnd"],e);let f=bH(a,["video"]);null!=f&&bG(b,["video"],cf(f));let g=bH(a,["text"]);null!=g&&bG(b,["text"],g);let h=bH(a,["activityStart"]);null!=h&&bG(b,["activityStart"],h);let i=bH(a,["activityEnd"]);return null!=i&&bG(b,["activityEnd"],i),b}(a)}:{realtimeInput:function(a){let b={},c=bH(a,["media"]);if(null!=c){let a=cd(c);Array.isArray(a)&&(a=a.map(a=>cZ(a))),bG(b,["mediaChunks"],a)}let d=bH(a,["audio"]);null!=d&&bG(b,["audio"],cZ(cg(d)));let e=bH(a,["audioStreamEnd"]);null!=e&&bG(b,["audioStreamEnd"],e);let f=bH(a,["video"]);null!=f&&bG(b,["video"],cZ(cf(f)));let g=bH(a,["text"]);null!=g&&bG(b,["text"],g);let h=bH(a,["activityStart"]);null!=h&&bG(b,["activityStart"],h);let i=bH(a,["activityEnd"]);return null!=i&&bG(b,["activityEnd"],i),b}(a)},this.conn.send(JSON.stringify(b))}sendToolResponse(a){if(null==a.functionResponses)throw Error("Tool response parameters are required.");let b=this.tLiveClienttToolResponse(this.apiClient,a);this.conn.send(JSON.stringify(b))}close(){this.conn.close()}}function dw(a){var b,c,d;if(null==(b=null==a?void 0:a.automaticFunctionCalling)?void 0:b.disable)return!0;let e=!1;for(let b of null!=(c=null==a?void 0:a.tools)?c:[])if(dx(b)){e=!0;break}if(!e)return!0;let f=null==(d=null==a?void 0:a.automaticFunctionCalling)?void 0:d.maximumRemoteCalls;return(!(!f||!(f<0)&&Number.isInteger(f))||0==f)&&(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",f),!0)}function dx(a){return"callTool"in a&&"function"==typeof a.callTool}function dy(a){var b;let c=[];return(null==(b=null==a?void 0:a.config)?void 0:b.tools)&&a.config.tools.forEach((a,b)=>{dx(a)||a.functionDeclarations&&a.functionDeclarations.length>0&&c.push(b)}),c}function dz(a){var b;return!(null==(b=null==a?void 0:a.automaticFunctionCalling)?void 0:b.ignoreCallHistory)}class dA extends bE{constructor(a){super(),this.apiClient=a,this.embedContent=async a=>{if(!this.apiClient.isVertexAI())return a.model.includes("gemini-embedding-2")&&(a.contents=co(a.contents)),await this.embedContentInternal(a);if(a.model.includes("gemini")&&"gemini-embedding-001"!==a.model||a.model.includes("maas")){let b=co(a.contents);if(b.length>1)throw Error("The embedContent API for this model only supports one content at a time.");let c=Object.assign(Object.assign({},a),{content:b[0],embeddingApiType:a5.EMBED_CONTENT});return await this.embedContentInternal(c)}{let b=Object.assign(Object.assign({},a),{embeddingApiType:a5.PREDICT});return await this.embedContentInternal(b)}},this.generateContent=async a=>{var b,c,d,e,f,g,h,i;let j,k,l=await this.processParamsMaybeAddMcpUsage(a);if(this.maybeMoveToResponseJsonSchem(a),!(null!=(i=null==(h=null==(g=a.config)?void 0:g.tools)?void 0:h.some(a=>dx(a)))&&i)||dw(a.config))return await this.generateContentInternal(l);let m=dy(a);if(m.length>0){let a=m.map(a=>`tools[${a}]`).join(", ");throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${a}.`)}let n=co(l.contents),o=null!=(d=null==(c=null==(b=l.config)?void 0:b.automaticFunctionCalling)?void 0:c.maximumRemoteCalls)?d:10,p=0;for(;p<o&&(j=await this.generateContentInternal(l)).functionCalls&&0!==j.functionCalls.length;){let b=j.candidates[0].content,c=[];for(let b of null!=(f=null==(e=a.config)?void 0:e.tools)?f:[])if(dx(b)){let a=await b.callTool(j.functionCalls);c.push(...a)}p++,k={role:"user",parts:c},l.contents=co(l.contents),l.contents.push(b),l.contents.push(k),dz(l.config)&&(n.push(b),n.push(k))}return dz(l.config)&&(j.automaticFunctionCallingHistory=n),j},this.generateContentStream=async a=>{var b,c,d,e,f;if(this.maybeMoveToResponseJsonSchem(a),dw(a.config)){let b=await this.processParamsMaybeAddMcpUsage(a);return await this.generateContentStreamInternal(b)}let g=dy(a);if(g.length>0){let a=g.map(a=>`tools[${a}]`).join(", ");throw Error(`Incompatible tools found at ${a}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let h=null==(d=null==(c=null==(b=null==a?void 0:a.config)?void 0:b.toolConfig)?void 0:c.functionCallingConfig)?void 0:d.streamFunctionCallArguments,i=null==(f=null==(e=null==a?void 0:a.config)?void 0:e.automaticFunctionCalling)?void 0:f.disable;if(h&&!i)throw Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(a)},this.generateImages=async a=>await this.generateImagesInternal(a).then(a=>{var b;let c,d=[];if(null==a?void 0:a.generatedImages)for(let e of a.generatedImages)e&&(null==e?void 0:e.safetyAttributes)&&(null==(b=null==e?void 0:e.safetyAttributes)?void 0:b.contentType)==="Positive Prompt"?c=null==e?void 0:e.safetyAttributes:d.push(e);return c?{generatedImages:d,positivePromptSafetyAttributes:c,sdkHttpResponse:a.sdkHttpResponse}:{generatedImages:d,sdkHttpResponse:a.sdkHttpResponse}}),this.list=async a=>{var b;let c={config:Object.assign(Object.assign({},{queryBase:!0}),null==a?void 0:a.config)};if(this.apiClient.isVertexAI()&&!c.config.queryBase)if(null==(b=c.config)?void 0:b.filter)throw Error("Filtering tuned models list for Gemini Enterprise Agent Platform (previously known as Vertex AI) is not currently supported");else c.config.filter="labels.tune-type:*";return new cJ(bv.PAGED_ITEM_MODELS,a=>this.listInternal(a),await this.listInternal(c),c)},this.editImage=async a=>{let b={model:a.model,prompt:a.prompt,referenceImages:[],config:a.config};return a.referenceImages&&a.referenceImages&&(b.referenceImages=a.referenceImages.map(a=>a.toReferenceImageAPI())),await this.editImageInternal(b)},this.upscaleImage=async a=>{let b={numberOfImages:1,mode:"upscale"};a.config&&(b=Object.assign(Object.assign({},b),a.config));let c={model:a.model,image:a.image,upscaleFactor:a.upscaleFactor,config:b};return await this.upscaleImageInternal(c)},this.generateVideos=async a=>{var b,c,d,e,f,g;if((a.prompt||a.image||a.video)&&a.source)throw Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return!this.apiClient.isVertexAI()&&((null==(b=a.video)?void 0:b.uri)&&(null==(c=a.video)?void 0:c.videoBytes)?a.video={uri:a.video.uri,mimeType:a.video.mimeType}:(null==(e=null==(d=a.source)?void 0:d.video)?void 0:e.uri)&&(null==(g=null==(f=a.source)?void 0:f.video)?void 0:g.videoBytes)&&(a.source.video={uri:a.source.video.uri,mimeType:a.source.video.mimeType})),await this.generateVideosInternal(a)}}maybeMoveToResponseJsonSchem(a){a.config&&a.config.responseSchema&&!a.config.responseJsonSchema&&Object.keys(a.config.responseSchema).includes("$schema")&&(a.config.responseJsonSchema=a.config.responseSchema,delete a.config.responseSchema)}async processParamsMaybeAddMcpUsage(a){var b,c,d;let e=null==(b=a.config)?void 0:b.tools;if(!e)return a;let f=await Promise.all(e.map(async a=>dx(a)?await a.tool():a)),g={model:a.model,contents:a.contents,config:Object.assign(Object.assign({},a.config),{tools:f})};if(g.config.tools=f,a.config&&a.config.tools&&dl(a.config.tools)){let b=Object.assign({},null!=(d=null==(c=a.config.httpOptions)?void 0:c.headers)?d:{});0===Object.keys(b).length&&(b=this.apiClient.getDefaultHeaders()),dm(b),g.config.httpOptions=Object.assign(Object.assign({},a.config.httpOptions),{headers:b})}return g}async initAfcToolsMap(a){var b,c,d;let e=new Map;for(let f of null!=(c=null==(b=a.config)?void 0:b.tools)?c:[])if(dx(f))for(let a of null!=(d=(await f.tool()).functionDeclarations)?d:[]){if(!a.name)throw Error("Function declaration name is required.");if(e.has(a.name))throw Error(`Duplicate tool declaration name: ${a.name}`);e.set(a.name,f)}return e}async processAfcStream(a){var b,c,d;let e=null!=(d=null==(c=null==(b=a.config)?void 0:b.automaticFunctionCalling)?void 0:c.maximumRemoteCalls)?d:10,f=!1,g=0;return function(a,b,c){return cQ(this,arguments,function*(){for(;g<e;){f&&(g++,f=!1);let p=yield cP(a.processParamsMaybeAddMcpUsage(c)),q=yield cP(a.generateContentStreamInternal(p)),r=[],s=[];try{for(var d,h,i,j,k,l,m,n=!0,o=(h=void 0,cR(q));!(d=(m=yield cP(o.next())).done);n=!0)if(j=m.value,n=!1,yield yield cP(j),j.candidates&&(null==(k=j.candidates[0])?void 0:k.content)){for(let a of(s.push(j.candidates[0].content),null!=(l=j.candidates[0].content.parts)?l:[]))if(g<e&&a.functionCall){if(!a.functionCall.name)throw Error("Function call name was not returned by the model.");if(b.has(a.functionCall.name)){let c=yield cP(b.get(a.functionCall.name).callTool([a.functionCall]));r.push(...c)}else throw Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${b.keys()}, mising tool: ${a.functionCall.name}`)}}}catch(a){h={error:a}}finally{try{!n&&!d&&(i=o.return)&&(yield cP(i.call(o)))}finally{if(h)throw h.error}}if(r.length>0){f=!0;let a=new bL;a.candidates=[{content:{role:"user",parts:r}}],yield yield cP(a);let b=[];b.push(...s),b.push({role:"user",parts:r});let d=co(c.contents).concat(b);c.contents=d}else break}})}(this,await this.initAfcToolsMap(a),a)}async generateContentInternal(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d=c1(this.apiClient,a);return f=bF("{model}:generateContent",d._url),g=d._query,delete d._url,delete d._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(d),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=c3(a),c=new bL;return Object.assign(c,b),c})}{let b=c0(this.apiClient,a);return f=bF("{model}:generateContent",b._url),g=b._query,delete b._url,delete b._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=c2(a),c=new bL;return Object.assign(c,b),c})}}async generateContentStreamInternal(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d=c1(this.apiClient,a);return f=bF("{model}:streamGenerateContent?alt=sse",d._url),g=d._query,delete d._url,delete d._query,this.apiClient.requestStream({path:f,queryParams:g,body:JSON.stringify(d),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(function(b){return cQ(this,arguments,function*(){var c,d,e,f;try{for(var g,h=!0,i=cR(b);!(c=(g=yield cP(i.next())).done);h=!0){f=g.value,h=!1;let b=c3((yield cP(f.json())),a);b.sdkHttpResponse={headers:f.headers};let c=new bL;Object.assign(c,b),yield yield cP(c)}}catch(a){d={error:a}}finally{try{!h&&!c&&(e=i.return)&&(yield cP(e.call(i)))}finally{if(d)throw d.error}}})})}{let b=c0(this.apiClient,a);return f=bF("{model}:streamGenerateContent?alt=sse",b._url),g=b._query,delete b._url,delete b._query,this.apiClient.requestStream({path:f,queryParams:g,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(function(b){return cQ(this,arguments,function*(){var c,d,e,f;try{for(var g,h=!0,i=cR(b);!(c=(g=yield cP(i.next())).done);h=!0){f=g.value,h=!1;let b=c2((yield cP(f.json())),a);b.sdkHttpResponse={headers:f.headers};let c=new bL;Object.assign(c,b),yield yield cP(c)}}catch(a){d={error:a}}finally{try{!h&&!c&&(e=i.return)&&(yield cP(e.call(i)))}finally{if(d)throw d.error}}})})}}async embedContentInternal(a){var b,c,d,e,f;let g="",h={};if(this.apiClient.isVertexAI()){let d=function(a,b,c){let d={},e=bH(b,["model"]);null!=e&&bG(d,["_url","model"],cb(a,e));let f=bH(c,["embeddingApiType"]);if(void 0===f&&(f="PREDICT"),"PREDICT"===f){let c=bH(b,["contents"]);if(null!=c){let b=cn(a,c);Array.isArray(b)&&(b=b.map(a=>a)),bG(d,["instances[]","content"],b)}}let g=bH(c,["embeddingApiType"]);if(void 0===g&&(g="PREDICT"),"EMBED_CONTENT"===g){let a=bH(b,["content"]);null!=a&&bG(d,["content"],c_(cm(a)))}let h=bH(b,["config"]);return null!=h&&function(a,b,c){let d=bH(c,["embeddingApiType"]);if(void 0===d&&(d="PREDICT"),"PREDICT"===d){let c=bH(a,["taskType"]);void 0!==b&&null!=c&&bG(b,["instances[]","task_type"],c)}else if("EMBED_CONTENT"===d){let c=bH(a,["taskType"]);void 0!==b&&null!=c&&bG(b,["embedContentConfig","taskType"],c)}let e=bH(c,["embeddingApiType"]);if(void 0===e&&(e="PREDICT"),"PREDICT"===e){let c=bH(a,["title"]);void 0!==b&&null!=c&&bG(b,["instances[]","title"],c)}else if("EMBED_CONTENT"===e){let c=bH(a,["title"]);void 0!==b&&null!=c&&bG(b,["embedContentConfig","title"],c)}let f=bH(c,["embeddingApiType"]);if(void 0===f&&(f="PREDICT"),"PREDICT"===f){let c=bH(a,["outputDimensionality"]);void 0!==b&&null!=c&&bG(b,["parameters","outputDimensionality"],c)}else if("EMBED_CONTENT"===f){let c=bH(a,["outputDimensionality"]);void 0!==b&&null!=c&&bG(b,["embedContentConfig","outputDimensionality"],c)}let g=bH(c,["embeddingApiType"]);if(void 0===g&&(g="PREDICT"),"PREDICT"===g){let c=bH(a,["mimeType"]);void 0!==b&&null!=c&&bG(b,["instances[]","mimeType"],c)}let h=bH(c,["embeddingApiType"]);if(void 0===h&&(h="PREDICT"),"PREDICT"===h){let c=bH(a,["autoTruncate"]);void 0!==b&&null!=c&&bG(b,["parameters","autoTruncate"],c)}else if("EMBED_CONTENT"===h){let c=bH(a,["autoTruncate"]);void 0!==b&&null!=c&&bG(b,["embedContentConfig","autoTruncate"],c)}let i=bH(c,["embeddingApiType"]);if(void 0===i&&(i="PREDICT"),"EMBED_CONTENT"===i){let c=bH(a,["documentOcr"]);void 0!==b&&null!=c&&bG(b,["embedContentConfig","documentOcr"],c)}let j=bH(c,["embeddingApiType"]);if(void 0===j&&(j="PREDICT"),"EMBED_CONTENT"===j){let c=bH(a,["audioTrackExtraction"]);void 0!==b&&null!=c&&bG(b,["embedContentConfig","audioTrackExtraction"],c)}}(h,d,c),d}(this.apiClient,a,a);return g=bF((f=a.model).includes("gemini")&&"gemini-embedding-001"!==f||f.includes("maas")?"{model}:embedContent":"{model}:predict",d._url),h=d._query,delete d._url,delete d._query,this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(d),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(b=>{let c=function(a,b){let c={},d=bH(a,["sdkHttpResponse"]);null!=d&&bG(c,["sdkHttpResponse"],d);let e=bH(a,["predictions[]","embeddings"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h;return c={},null!=(d=bH(a,["values"]))&&bG(c,["values"],d),null!=(e=bH(a,["statistics"]))&&bG(c,["statistics"],(f={},null!=(g=bH(b=e,["truncated"]))&&bG(f,["truncated"],g),null!=(h=bH(b,["token_count"]))&&bG(f,["tokenCount"],h),f)),c})),bG(c,["embeddings"],a)}let f=bH(a,["metadata"]);if(null!=f&&bG(c,["metadata"],f),b&&"EMBED_CONTENT"===bH(b,["embeddingApiType"])){let b=bH(a,["embedding"]),d=bH(a,["usageMetadata"]),e=bH(a,["truncated"]);if(b){let a={};d&&d.promptTokenCount&&(a.tokenCount=d.promptTokenCount),e&&(a.truncated=e),b.statistics=a,bG(c,["embeddings"],[b])}}return c}(b,a),d=new bM;return Object.assign(d,c),d})}{let b=function(a,b){let c={},d=bH(b,["model"]);null!=d&&bG(c,["_url","model"],cb(a,d));let e=bH(b,["contents"]);if(null!=e){let b=cn(a,e);Array.isArray(b)&&(b=b.map(a=>a)),bG(c,["requests[]","content"],b)}let f=bH(b,["content"]);null!=f&&c$(cm(f));let g=bH(b,["config"]);null!=g&&function(a,b){let c=bH(a,["taskType"]);void 0!==b&&null!=c&&bG(b,["requests[]","taskType"],c);let d=bH(a,["title"]);void 0!==b&&null!=d&&bG(b,["requests[]","title"],d);let e=bH(a,["outputDimensionality"]);if(void 0!==b&&null!=e&&bG(b,["requests[]","outputDimensionality"],e),void 0!==bH(a,["mimeType"]))throw Error("mimeType parameter is not supported in Gemini API.");if(void 0!==bH(a,["autoTruncate"]))throw Error("autoTruncate parameter is not supported in Gemini API.");if(void 0!==bH(a,["documentOcr"]))throw Error("documentOcr parameter is not supported in Gemini API.");if(void 0!==bH(a,["audioTrackExtraction"]))throw Error("audioTrackExtraction parameter is not supported in Gemini API.")}(g,c);let h=bH(b,["model"]);return void 0!==h&&bG(c,["requests[]","model"],cb(a,h)),c}(this.apiClient,a);return g=bF("{model}:batchEmbedContents",b._url),h=b._query,delete b._url,delete b._query,this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["embeddings"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["embeddings"],a)}let e=bH(a,["metadata"]);return null!=e&&bG(b,["metadata"],e),b}(a),c=new bM;return Object.assign(c,b),c})}}async generateImagesInternal(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=(f=this.apiClient,d={},null!=(e=bH(a,["model"]))&&bG(d,["_url","model"],cb(f,e)),null!=(g=bH(a,["prompt"]))&&bG(d,["instances[0]","prompt"],g),null!=(j=bH(a,["config"]))&&(k=bH(j,["outputGcsUri"]),void 0!==d&&null!=k&&bG(d,["parameters","storageUri"],k),l=bH(j,["negativePrompt"]),void 0!==d&&null!=l&&bG(d,["parameters","negativePrompt"],l),m=bH(j,["numberOfImages"]),void 0!==d&&null!=m&&bG(d,["parameters","sampleCount"],m),n=bH(j,["aspectRatio"]),void 0!==d&&null!=n&&bG(d,["parameters","aspectRatio"],n),o=bH(j,["guidanceScale"]),void 0!==d&&null!=o&&bG(d,["parameters","guidanceScale"],o),p=bH(j,["seed"]),void 0!==d&&null!=p&&bG(d,["parameters","seed"],p),q=bH(j,["safetyFilterLevel"]),void 0!==d&&null!=q&&bG(d,["parameters","safetySetting"],q),r=bH(j,["personGeneration"]),void 0!==d&&null!=r&&bG(d,["parameters","personGeneration"],r),s=bH(j,["includeSafetyAttributes"]),void 0!==d&&null!=s&&bG(d,["parameters","includeSafetyAttributes"],s),t=bH(j,["includeRaiReason"]),void 0!==d&&null!=t&&bG(d,["parameters","includeRaiReason"],t),u=bH(j,["language"]),void 0!==d&&null!=u&&bG(d,["parameters","language"],u),v=bH(j,["outputMimeType"]),void 0!==d&&null!=v&&bG(d,["parameters","outputOptions","mimeType"],v),w=bH(j,["outputCompressionQuality"]),void 0!==d&&null!=w&&bG(d,["parameters","outputOptions","compressionQuality"],w),x=bH(j,["addWatermark"]),void 0!==d&&null!=x&&bG(d,["parameters","addWatermark"],x),y=bH(j,["labels"]),void 0!==d&&null!=y&&bG(d,["labels"],y),z=bH(j,["imageSize"]),void 0!==d&&null!=z&&bG(d,["parameters","sampleImageSize"],z),A=bH(j,["enhancePrompt"]),void 0!==d&&null!=A&&bG(d,["parameters","enhancePrompt"],A)),d);return h=bF("{model}:predict",B._url),i=B._query,delete B._url,delete B._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(B),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["predictions"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>c4(a))),bG(b,["generatedImages"],a)}let e=bH(a,["positivePromptSafetyAttributes"]);return null!=e&&bG(b,["positivePromptSafetyAttributes"],db(e)),b}(a),c=new bN;return Object.assign(c,b),c})}{let b,c,f,j,k=(g=this.apiClient,b={},null!=(c=bH(a,["model"]))&&bG(b,["_url","model"],cb(g,c)),null!=(f=bH(a,["prompt"]))&&bG(b,["instances[0]","prompt"],f),null!=(j=bH(a,["config"]))&&function(a,b){if(void 0!==bH(a,["outputGcsUri"]))throw Error("outputGcsUri parameter is not supported in Gemini API.");if(void 0!==bH(a,["negativePrompt"]))throw Error("negativePrompt parameter is not supported in Gemini API.");let c=bH(a,["numberOfImages"]);void 0!==b&&null!=c&&bG(b,["parameters","sampleCount"],c);let d=bH(a,["aspectRatio"]);void 0!==b&&null!=d&&bG(b,["parameters","aspectRatio"],d);let e=bH(a,["guidanceScale"]);if(void 0!==b&&null!=e&&bG(b,["parameters","guidanceScale"],e),void 0!==bH(a,["seed"]))throw Error("seed parameter is not supported in Gemini API.");let f=bH(a,["safetyFilterLevel"]);void 0!==b&&null!=f&&bG(b,["parameters","safetySetting"],f);let g=bH(a,["personGeneration"]);void 0!==b&&null!=g&&bG(b,["parameters","personGeneration"],g);let h=bH(a,["includeSafetyAttributes"]);void 0!==b&&null!=h&&bG(b,["parameters","includeSafetyAttributes"],h);let i=bH(a,["includeRaiReason"]);void 0!==b&&null!=i&&bG(b,["parameters","includeRaiReason"],i);let j=bH(a,["language"]);void 0!==b&&null!=j&&bG(b,["parameters","language"],j);let k=bH(a,["outputMimeType"]);void 0!==b&&null!=k&&bG(b,["parameters","outputOptions","mimeType"],k);let l=bH(a,["outputCompressionQuality"]);if(void 0!==b&&null!=l&&bG(b,["parameters","outputOptions","compressionQuality"],l),void 0!==bH(a,["addWatermark"]))throw Error("addWatermark parameter is not supported in Gemini API.");if(void 0!==bH(a,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let m=bH(a,["imageSize"]);if(void 0!==b&&null!=m&&bG(b,["parameters","sampleImageSize"],m),void 0!==bH(a,["enhancePrompt"]))throw Error("enhancePrompt parameter is not supported in Gemini API.")}(j,b),b);return h=bF("{model}:predict",k._url),i=k._query,delete k._url,delete k._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(k),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["predictions"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>{var b,c;let d,e,f,g,h,i,j;return d={},null!=(e=bH(b=a,["_self"]))&&bG(d,["image"],(f={},null!=(g=bH(c=e,["bytesBase64Encoded"]))&&bG(f,["imageBytes"],bI(g)),null!=(h=bH(c,["mimeType"]))&&bG(f,["mimeType"],h),f)),null!=(i=bH(b,["raiFilteredReason"]))&&bG(d,["raiFilteredReason"],i),null!=(j=bH(b,["_self"]))&&bG(d,["safetyAttributes"],da(j)),d})),bG(b,["generatedImages"],a)}let e=bH(a,["positivePromptSafetyAttributes"]);return null!=e&&bG(b,["positivePromptSafetyAttributes"],da(e)),b}(a),c=new bN;return Object.assign(c,b),c})}}async editImageInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI()){let f=function(a,b){let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t={},u=bH(b,["model"]);null!=u&&bG(t,["_url","model"],cb(a,u));let v=bH(b,["prompt"]);null!=v&&bG(t,["instances[0]","prompt"],v);let w=bH(b,["referenceImages"]);if(null!=w){let a=w;Array.isArray(a)&&(a=a.map(a=>(function(a){let b,c,d,e,f,g,h,i={},j=bH(a,["referenceImage"]);null!=j&&bG(i,["referenceImage"],c7(j));let k=bH(a,["referenceId"]);null!=k&&bG(i,["referenceId"],k);let l=bH(a,["referenceType"]);null!=l&&bG(i,["referenceType"],l);let m=bH(a,["maskImageConfig"]);null!=m&&bG(i,["maskImageConfig"],(b={},null!=(c=bH(m,["maskMode"]))&&bG(b,["maskMode"],c),null!=(d=bH(m,["segmentationClasses"]))&&bG(b,["maskClasses"],d),null!=(e=bH(m,["maskDilation"]))&&bG(b,["dilation"],e),b));let n=bH(a,["controlImageConfig"]);null!=n&&bG(i,["controlImageConfig"],(f={},null!=(g=bH(n,["controlType"]))&&bG(f,["controlType"],g),null!=(h=bH(n,["enableControlImageComputation"]))&&bG(f,["computeControl"],h),f));let o=bH(a,["styleImageConfig"]);null!=o&&bG(i,["styleImageConfig"],o);let p=bH(a,["subjectImageConfig"]);return null!=p&&bG(i,["subjectImageConfig"],p),i})(a))),bG(t,["instances[0]","referenceImages"],a)}let x=bH(b,["config"]);return null!=x&&(c=bH(x,["outputGcsUri"]),void 0!==t&&null!=c&&bG(t,["parameters","storageUri"],c),d=bH(x,["negativePrompt"]),void 0!==t&&null!=d&&bG(t,["parameters","negativePrompt"],d),e=bH(x,["numberOfImages"]),void 0!==t&&null!=e&&bG(t,["parameters","sampleCount"],e),f=bH(x,["aspectRatio"]),void 0!==t&&null!=f&&bG(t,["parameters","aspectRatio"],f),g=bH(x,["guidanceScale"]),void 0!==t&&null!=g&&bG(t,["parameters","guidanceScale"],g),h=bH(x,["seed"]),void 0!==t&&null!=h&&bG(t,["parameters","seed"],h),i=bH(x,["safetyFilterLevel"]),void 0!==t&&null!=i&&bG(t,["parameters","safetySetting"],i),j=bH(x,["personGeneration"]),void 0!==t&&null!=j&&bG(t,["parameters","personGeneration"],j),k=bH(x,["includeSafetyAttributes"]),void 0!==t&&null!=k&&bG(t,["parameters","includeSafetyAttributes"],k),l=bH(x,["includeRaiReason"]),void 0!==t&&null!=l&&bG(t,["parameters","includeRaiReason"],l),m=bH(x,["language"]),void 0!==t&&null!=m&&bG(t,["parameters","language"],m),n=bH(x,["outputMimeType"]),void 0!==t&&null!=n&&bG(t,["parameters","outputOptions","mimeType"],n),o=bH(x,["outputCompressionQuality"]),void 0!==t&&null!=o&&bG(t,["parameters","outputOptions","compressionQuality"],o),p=bH(x,["addWatermark"]),void 0!==t&&null!=p&&bG(t,["parameters","addWatermark"],p),q=bH(x,["labels"]),void 0!==t&&null!=q&&bG(t,["labels"],q),r=bH(x,["editMode"]),void 0!==t&&null!=r&&bG(t,["parameters","editMode"],r),s=bH(x,["baseSteps"]),void 0!==t&&null!=s&&bG(t,["parameters","editConfig","baseSteps"],s)),t}(this.apiClient,a);return d=bF("{model}:predict",f._url),e=f._query,delete f._url,delete f._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(f),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["predictions"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>c4(a))),bG(b,["generatedImages"],a)}return b}(a),c=new bO;return Object.assign(c,b),c})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async upscaleImageInternal(a){var b,c,d;let e="",f={};if(this.apiClient.isVertexAI()){let g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w=(d=this.apiClient,g={},null!=(h=bH(a,["model"]))&&bG(g,["_url","model"],cb(d,h)),null!=(i=bH(a,["image"]))&&bG(g,["instances[0]","image"],c7(i)),null!=(j=bH(a,["upscaleFactor"]))&&bG(g,["parameters","upscaleConfig","upscaleFactor"],j),null!=(k=bH(a,["config"]))&&(l=bH(k,["outputGcsUri"]),void 0!==g&&null!=l&&bG(g,["parameters","storageUri"],l),m=bH(k,["safetyFilterLevel"]),void 0!==g&&null!=m&&bG(g,["parameters","safetySetting"],m),n=bH(k,["personGeneration"]),void 0!==g&&null!=n&&bG(g,["parameters","personGeneration"],n),o=bH(k,["includeRaiReason"]),void 0!==g&&null!=o&&bG(g,["parameters","includeRaiReason"],o),p=bH(k,["outputMimeType"]),void 0!==g&&null!=p&&bG(g,["parameters","outputOptions","mimeType"],p),q=bH(k,["outputCompressionQuality"]),void 0!==g&&null!=q&&bG(g,["parameters","outputOptions","compressionQuality"],q),r=bH(k,["enhanceInputImage"]),void 0!==g&&null!=r&&bG(g,["parameters","upscaleConfig","enhanceInputImage"],r),s=bH(k,["imagePreservationFactor"]),void 0!==g&&null!=s&&bG(g,["parameters","upscaleConfig","imagePreservationFactor"],s),t=bH(k,["labels"]),void 0!==g&&null!=t&&bG(g,["labels"],t),u=bH(k,["numberOfImages"]),void 0!==g&&null!=u&&bG(g,["parameters","sampleCount"],u),v=bH(k,["mode"]),void 0!==g&&null!=v&&bG(g,["parameters","mode"],v)),g);return e=bF("{model}:predict",w._url),f=w._query,delete w._url,delete w._query,this.apiClient.request({path:e,queryParams:f,body:JSON.stringify(w),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["predictions"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>c4(a))),bG(b,["generatedImages"],a)}return b}(a),c=new bP;return Object.assign(c,b),c})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async recontextImage(a){var b,c,d;let e="",f={};if(this.apiClient.isVertexAI()){let g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=(d=this.apiClient,g={},null!=(h=bH(a,["model"]))&&bG(g,["_url","model"],cb(d,h)),null!=(i=bH(a,["source"]))&&function(a,b){let c=bH(a,["prompt"]);void 0!==b&&null!=c&&bG(b,["instances[0]","prompt"],c);let d=bH(a,["personImage"]);void 0!==b&&null!=d&&bG(b,["instances[0]","personImage","image"],c7(d));let e=bH(a,["productImages"]);if(void 0!==b&&null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>{let b,c;return b={},null!=(c=bH(a,["productImage"]))&&bG(b,["image"],c7(c)),b})),bG(b,["instances[0]","productImages"],a)}}(i,g),null!=(j=bH(a,["config"]))&&(k=bH(j,["numberOfImages"]),void 0!==g&&null!=k&&bG(g,["parameters","sampleCount"],k),l=bH(j,["baseSteps"]),void 0!==g&&null!=l&&bG(g,["parameters","baseSteps"],l),m=bH(j,["outputGcsUri"]),void 0!==g&&null!=m&&bG(g,["parameters","storageUri"],m),n=bH(j,["seed"]),void 0!==g&&null!=n&&bG(g,["parameters","seed"],n),o=bH(j,["safetyFilterLevel"]),void 0!==g&&null!=o&&bG(g,["parameters","safetySetting"],o),p=bH(j,["personGeneration"]),void 0!==g&&null!=p&&bG(g,["parameters","personGeneration"],p),q=bH(j,["addWatermark"]),void 0!==g&&null!=q&&bG(g,["parameters","addWatermark"],q),r=bH(j,["outputMimeType"]),void 0!==g&&null!=r&&bG(g,["parameters","outputOptions","mimeType"],r),s=bH(j,["outputCompressionQuality"]),void 0!==g&&null!=s&&bG(g,["parameters","outputOptions","compressionQuality"],s),t=bH(j,["enhancePrompt"]),void 0!==g&&null!=t&&bG(g,["parameters","enhancePrompt"],t),u=bH(j,["labels"]),void 0!==g&&null!=u&&bG(g,["labels"],u)),g);return e=bF("{model}:predict",v._url),f=v._query,delete v._url,delete v._query,this.apiClient.request({path:e,queryParams:f,body:JSON.stringify(v),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b=function(a){let b={},c=bH(a,["predictions"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>c4(a))),bG(b,["generatedImages"],a)}return b}(a),c=new bQ;return Object.assign(c,b),c})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async segmentImage(a){var b,c,d,e,f;let g="",h={};if(this.apiClient.isVertexAI()){let i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x=(d=this.apiClient,n={},null!=(o=bH(a,["model"]))&&bG(n,["_url","model"],cb(d,o)),null!=(p=bH(a,["source"]))&&(e=p,f=n,k=bH(e,["prompt"]),void 0!==f&&null!=k&&bG(f,["instances[0]","prompt"],k),l=bH(e,["image"]),void 0!==f&&null!=l&&bG(f,["instances[0]","image"],c7(l)),m=bH(e,["scribbleImage"]),void 0!==f&&null!=m&&bG(f,["instances[0]","scribble"],(i={},null!=(j=bH(m,["image"]))&&bG(i,["image"],c7(j)),i))),null!=(q=bH(a,["config"]))&&(r=bH(q,["mode"]),void 0!==n&&null!=r&&bG(n,["parameters","mode"],r),s=bH(q,["maxPredictions"]),void 0!==n&&null!=s&&bG(n,["parameters","maxPredictions"],s),t=bH(q,["confidenceThreshold"]),void 0!==n&&null!=t&&bG(n,["parameters","confidenceThreshold"],t),u=bH(q,["maskDilation"]),void 0!==n&&null!=u&&bG(n,["parameters","maskDilation"],u),v=bH(q,["binaryColorThreshold"]),void 0!==n&&null!=v&&bG(n,["parameters","binaryColorThreshold"],v),w=bH(q,["labels"]),void 0!==n&&null!=w&&bG(n,["labels"],w)),n);return g=bF("{model}:predict",x._url),h=x._query,delete x._url,delete x._query,this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(x),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b=function(a){let b={},c=bH(a,["predictions"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["_self"]);null!=c&&bG(b,["mask"],c5(c));let d=bH(a,["labels"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["labels"],a)}return b})(a))),bG(b,["generatedMasks"],a)}return b}(a),c=new bR;return Object.assign(c,b),c})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async get(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["model"]))&&bG(d,["_url","name"],cb(f,e)),d);return h=bF("{name}",g._url),i=g._query,delete g._url,delete g._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>c9(a))}{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["model"]))&&bG(b,["_url","name"],cb(g,c)),b);return h=bF("{name}",f._url),i=f._query,delete f._url,delete f._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>c8(a))}}async listInternal(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g,j,k,l,m=(f=this.apiClient,d={},null!=(e=bH(a,["config"]))&&(g=bH(e,["pageSize"]),void 0!==d&&null!=g&&bG(d,["_query","pageSize"],g),j=bH(e,["pageToken"]),void 0!==d&&null!=j&&bG(d,["_query","pageToken"],j),k=bH(e,["filter"]),void 0!==d&&null!=k&&bG(d,["_query","filter"],k),l=bH(e,["queryBase"]),void 0!==d&&null!=l&&bG(d,["_url","models_url"],cz(f,l))),d);return h=bF("{models_url}",m._url),i=m._query,delete m._url,delete m._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(m),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["_self"]);if(null!=e){let a=cA(e);Array.isArray(a)&&(a=a.map(a=>c9(a))),bG(b,["models"],a)}return b}(a),c=new bS;return Object.assign(c,b),c})}{let b,c,f,j,k,l,m=(g=this.apiClient,b={},null!=(c=bH(a,["config"]))&&(f=bH(c,["pageSize"]),void 0!==b&&null!=f&&bG(b,["_query","pageSize"],f),j=bH(c,["pageToken"]),void 0!==b&&null!=j&&bG(b,["_query","pageToken"],j),k=bH(c,["filter"]),void 0!==b&&null!=k&&bG(b,["_query","filter"],k),l=bH(c,["queryBase"]),void 0!==b&&null!=l&&bG(b,["_url","models_url"],cz(g,l))),b);return h=bF("{models_url}",m._url),i=m._query,delete m._url,delete m._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(m),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["_self"]);if(null!=e){let a=cA(e);Array.isArray(a)&&(a=a.map(a=>c8(a))),bG(b,["models"],a)}return b}(a),c=new bS;return Object.assign(c,b),c})}}async update(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g,j,k,l,m=(f=this.apiClient,d={},null!=(e=bH(a,["model"]))&&bG(d,["_url","model"],cb(f,e)),null!=(g=bH(a,["config"]))&&(j=bH(g,["displayName"]),void 0!==d&&null!=j&&bG(d,["displayName"],j),k=bH(g,["description"]),void 0!==d&&null!=k&&bG(d,["description"],k),l=bH(g,["defaultCheckpointId"]),void 0!==d&&null!=l&&bG(d,["defaultCheckpointId"],l)),d);return h=bF("{model}",m._url),i=m._query,delete m._url,delete m._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>c9(a))}{let b,c,f,j,k,l,m=(g=this.apiClient,b={},null!=(c=bH(a,["model"]))&&bG(b,["_url","name"],cb(g,c)),null!=(f=bH(a,["config"]))&&(j=bH(f,["displayName"]),void 0!==b&&null!=j&&bG(b,["displayName"],j),k=bH(f,["description"]),void 0!==b&&null!=k&&bG(b,["description"],k),l=bH(f,["defaultCheckpointId"]),void 0!==b&&null!=l&&bG(b,["defaultCheckpointId"],l)),b);return h=bF("{name}",m._url),i=m._query,delete m._url,delete m._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>c8(a))}}async delete(a){var b,c,d,e,f,g;let h="",i={};if(this.apiClient.isVertexAI()){let d,e,g=(f=this.apiClient,d={},null!=(e=bH(a,["model"]))&&bG(d,["_url","name"],cb(f,e)),d);return h=bF("{name}",g._url),i=g._query,delete g._url,delete g._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new bT;return Object.assign(e,d),e})}{let b,c,f=(g=this.apiClient,b={},null!=(c=bH(a,["model"]))&&bG(b,["_url","name"],cb(g,c)),b);return h=bF("{name}",f._url),i=f._query,delete f._url,delete f._query,this.apiClient.request({path:h,queryParams:i,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new bT;return Object.assign(e,d),e})}}async countTokens(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d=function(a,b){let c={},d=bH(b,["model"]);null!=d&&bG(c,["_url","model"],cb(a,d));let e=bH(b,["contents"]);if(null!=e){let a=co(e);Array.isArray(a)&&(a=a.map(a=>c_(a))),bG(c,["contents"],a)}let f=bH(b,["config"]);return null!=f&&function(a,b){let c=bH(a,["systemInstruction"]);void 0!==b&&null!=c&&bG(b,["systemInstruction"],c_(cm(c)));let d=bH(a,["tools"]);if(void 0!==b&&null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>dc(a))),bG(b,["tools"],a)}let e=bH(a,["generationConfig"]);void 0!==b&&null!=e&&bG(b,["generationConfig"],function(a){let b={},c=bH(a,["modelSelectionConfig"]);null!=c&&bG(b,["modelConfig"],c);let d=bH(a,["responseJsonSchema"]);null!=d&&bG(b,["responseJsonSchema"],d);let e=bH(a,["audioTimestamp"]);null!=e&&bG(b,["audioTimestamp"],e);let f=bH(a,["candidateCount"]);null!=f&&bG(b,["candidateCount"],f);let g=bH(a,["enableAffectiveDialog"]);null!=g&&bG(b,["enableAffectiveDialog"],g);let h=bH(a,["frequencyPenalty"]);null!=h&&bG(b,["frequencyPenalty"],h);let i=bH(a,["logprobs"]);null!=i&&bG(b,["logprobs"],i);let j=bH(a,["maxOutputTokens"]);null!=j&&bG(b,["maxOutputTokens"],j);let k=bH(a,["mediaResolution"]);null!=k&&bG(b,["mediaResolution"],k);let l=bH(a,["presencePenalty"]);null!=l&&bG(b,["presencePenalty"],l);let m=bH(a,["responseLogprobs"]);null!=m&&bG(b,["responseLogprobs"],m);let n=bH(a,["responseMimeType"]);null!=n&&bG(b,["responseMimeType"],n);let o=bH(a,["responseModalities"]);null!=o&&bG(b,["responseModalities"],o);let p=bH(a,["responseSchema"]);null!=p&&bG(b,["responseSchema"],p);let q=bH(a,["routingConfig"]);null!=q&&bG(b,["routingConfig"],q);let r=bH(a,["seed"]);null!=r&&bG(b,["seed"],r);let s=bH(a,["speechConfig"]);null!=s&&bG(b,["speechConfig"],s);let t=bH(a,["stopSequences"]);null!=t&&bG(b,["stopSequences"],t);let u=bH(a,["temperature"]);null!=u&&bG(b,["temperature"],u);let v=bH(a,["thinkingConfig"]);null!=v&&bG(b,["thinkingConfig"],v);let w=bH(a,["topK"]);null!=w&&bG(b,["topK"],w);let x=bH(a,["topP"]);if(null!=x&&bG(b,["topP"],x),void 0!==bH(a,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");return b}(e))}(f,c),c}(this.apiClient,a);return f=bF("{model}:countTokens",d._url),g=d._query,delete d._url,delete d._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(d),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d,e=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),null!=(d=bH(a,["totalTokens"]))&&bG(b,["totalTokens"],d),b),f=new bU;return Object.assign(f,e),f})}{let b=function(a,b){let c={},d=bH(b,["model"]);null!=d&&bG(c,["_url","model"],cb(a,d));let e=bH(b,["contents"]);if(null!=e){let a=co(e);Array.isArray(a)&&(a=a.map(a=>c$(a))),bG(c,["contents"],a)}let f=bH(b,["config"]);return null!=f&&function(a){if(void 0!==bH(a,["systemInstruction"]))throw Error("systemInstruction parameter is not supported in Gemini API.");if(void 0!==bH(a,["tools"]))throw Error("tools parameter is not supported in Gemini API.");if(void 0!==bH(a,["generationConfig"]))throw Error("generationConfig parameter is not supported in Gemini API.")}(f),c}(this.apiClient,a);return f=bF("{model}:countTokens",b._url),g=b._query,delete b._url,delete b._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d,e,f=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),null!=(d=bH(a,["totalTokens"]))&&bG(b,["totalTokens"],d),null!=(e=bH(a,["cachedContentTokenCount"]))&&bG(b,["cachedContentTokenCount"],e),b),g=new bU;return Object.assign(g,f),g})}}async computeTokens(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI()){let f=function(a,b){let c={},d=bH(b,["model"]);null!=d&&bG(c,["_url","model"],cb(a,d));let e=bH(b,["contents"]);if(null!=e){let a=co(e);Array.isArray(a)&&(a=a.map(a=>c_(a))),bG(c,["contents"],a)}return c}(this.apiClient,a);return d=bF("{model}:computeTokens",f._url),e=f._query,delete f._url,delete f._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(f),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["tokensInfo"]);if(null!=d){let a=d;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["tokensInfo"],a)}return b}(a),c=new bV;return Object.assign(c,b),c})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async generateVideosInternal(a){var b,c,d,e,f,g,h,i,j,k;let l="",m={};if(this.apiClient.isVertexAI()){let d,e,g,j,k,n,o,p,q,r,s=(f=this.apiClient,j={},null!=(k=bH(a,["model"]))&&bG(j,["_url","model"],cb(f,k)),null!=(n=bH(a,["prompt"]))&&bG(j,["instances[0]","prompt"],n),null!=(o=bH(a,["image"]))&&bG(j,["instances[0]","image"],c7(o)),null!=(p=bH(a,["video"]))&&bG(j,["instances[0]","video"],de(p)),null!=(q=bH(a,["source"]))&&(h=q,i=j,d=bH(h,["prompt"]),void 0!==i&&null!=d&&bG(i,["instances[0]","prompt"],d),e=bH(h,["image"]),void 0!==i&&null!=e&&bG(i,["instances[0]","image"],c7(e)),g=bH(h,["video"]),void 0!==i&&null!=g&&bG(i,["instances[0]","video"],de(g))),null!=(r=bH(a,["config"]))&&function(a,b){var c;let d,e,f,g=bH(a,["numberOfVideos"]);void 0!==b&&null!=g&&bG(b,["parameters","sampleCount"],g);let h=bH(a,["outputGcsUri"]);void 0!==b&&null!=h&&bG(b,["parameters","storageUri"],h);let i=bH(a,["fps"]);void 0!==b&&null!=i&&bG(b,["parameters","fps"],i);let j=bH(a,["durationSeconds"]);void 0!==b&&null!=j&&bG(b,["parameters","durationSeconds"],j);let k=bH(a,["seed"]);void 0!==b&&null!=k&&bG(b,["parameters","seed"],k);let l=bH(a,["aspectRatio"]);void 0!==b&&null!=l&&bG(b,["parameters","aspectRatio"],l);let m=bH(a,["resolution"]);void 0!==b&&null!=m&&bG(b,["parameters","resolution"],m);let n=bH(a,["personGeneration"]);void 0!==b&&null!=n&&bG(b,["parameters","personGeneration"],n);let o=bH(a,["pubsubTopic"]);void 0!==b&&null!=o&&bG(b,["parameters","pubsubTopic"],o);let p=bH(a,["negativePrompt"]);void 0!==b&&null!=p&&bG(b,["parameters","negativePrompt"],p);let q=bH(a,["enhancePrompt"]);void 0!==b&&null!=q&&bG(b,["parameters","enhancePrompt"],q);let r=bH(a,["generateAudio"]);void 0!==b&&null!=r&&bG(b,["parameters","generateAudio"],r);let s=bH(a,["lastFrame"]);void 0!==b&&null!=s&&bG(b,["instances[0]","lastFrame"],c7(s));let t=bH(a,["referenceImages"]);if(void 0!==b&&null!=t){let a=t;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e;return c={},null!=(d=bH(b=a,["image"]))&&bG(c,["image"],c7(d)),null!=(e=bH(b,["referenceType"]))&&bG(c,["referenceType"],e),c})),bG(b,["instances[0]","referenceImages"],a)}let u=bH(a,["mask"]);void 0!==b&&null!=u&&bG(b,["instances[0]","mask"],(d={},null!=(e=bH(c=u,["image"]))&&bG(d,["_self"],c7(e)),null!=(f=bH(c,["maskMode"]))&&bG(d,["maskMode"],f),d));let v=bH(a,["compressionQuality"]);void 0!==b&&null!=v&&bG(b,["parameters","compressionQuality"],v);let w=bH(a,["labels"]);if(void 0!==b&&null!=w&&bG(b,["labels"],w),void 0!==bH(a,["webhookConfig"]))throw Error("webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).");let x=bH(a,["resizeMode"]);void 0!==b&&null!=x&&bG(b,["parameters","resizeMode"],x)}(r,j),j);return l=bF("{model}:predictLongRunning",s._url),m=s._query,delete s._url,delete s._query,this.apiClient.request({path:l,queryParams:m,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b,c,d,e,f,g,h=(b={},null!=(c=bH(a,["name"]))&&bG(b,["name"],c),null!=(d=bH(a,["metadata"]))&&bG(b,["metadata"],d),null!=(e=bH(a,["done"]))&&bG(b,["done"],e),null!=(f=bH(a,["error"]))&&bG(b,["error"],f),null!=(g=bH(a,["response"]))&&bG(b,["response"],function(a){let b={},c=bH(a,["videos"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h;return c={},null!=(d=bH(a,["_self"]))&&bG(c,["video"],(e={},null!=(f=bH(b=d,["gcsUri"]))&&bG(e,["uri"],f),null!=(g=bH(b,["bytesBase64Encoded"]))&&bG(e,["videoBytes"],bI(g)),null!=(h=bH(b,["mimeType"]))&&bG(e,["mimeType"],h),e)),c})),bG(b,["generatedVideos"],a)}let d=bH(a,["raiMediaFilteredCount"]);null!=d&&bG(b,["raiMediaFilteredCount"],d);let e=bH(a,["raiMediaFilteredReasons"]);return null!=e&&bG(b,["raiMediaFilteredReasons"],e),b}(g)),b),i=new bW;return Object.assign(i,h),i})}{let b,c,f,h,i,n,o,p,q,r,s=(g=this.apiClient,h={},null!=(i=bH(a,["model"]))&&bG(h,["_url","model"],cb(g,i)),null!=(n=bH(a,["prompt"]))&&bG(h,["instances[0]","prompt"],n),null!=(o=bH(a,["image"]))&&bG(h,["instances[0]","image"],c6(o)),null!=(p=bH(a,["video"]))&&bG(h,["instances[0]","video"],dd(p)),null!=(q=bH(a,["source"]))&&(j=q,k=h,b=bH(j,["prompt"]),void 0!==k&&null!=b&&bG(k,["instances[0]","prompt"],b),c=bH(j,["image"]),void 0!==k&&null!=c&&bG(k,["instances[0]","image"],c6(c)),f=bH(j,["video"]),void 0!==k&&null!=f&&bG(k,["instances[0]","video"],dd(f))),null!=(r=bH(a,["config"]))&&function(a,b){let c=bH(a,["numberOfVideos"]);if(void 0!==b&&null!=c&&bG(b,["parameters","sampleCount"],c),void 0!==bH(a,["outputGcsUri"]))throw Error("outputGcsUri parameter is not supported in Gemini API.");if(void 0!==bH(a,["fps"]))throw Error("fps parameter is not supported in Gemini API.");let d=bH(a,["durationSeconds"]);if(void 0!==b&&null!=d&&bG(b,["parameters","durationSeconds"],d),void 0!==bH(a,["seed"]))throw Error("seed parameter is not supported in Gemini API.");let e=bH(a,["aspectRatio"]);void 0!==b&&null!=e&&bG(b,["parameters","aspectRatio"],e);let f=bH(a,["resolution"]);void 0!==b&&null!=f&&bG(b,["parameters","resolution"],f);let g=bH(a,["personGeneration"]);if(void 0!==b&&null!=g&&bG(b,["parameters","personGeneration"],g),void 0!==bH(a,["pubsubTopic"]))throw Error("pubsubTopic parameter is not supported in Gemini API.");let h=bH(a,["negativePrompt"]);void 0!==b&&null!=h&&bG(b,["parameters","negativePrompt"],h);let i=bH(a,["enhancePrompt"]);if(void 0!==b&&null!=i&&bG(b,["parameters","enhancePrompt"],i),void 0!==bH(a,["generateAudio"]))throw Error("generateAudio parameter is not supported in Gemini API.");let j=bH(a,["lastFrame"]);void 0!==b&&null!=j&&bG(b,["instances[0]","lastFrame"],c6(j));let k=bH(a,["referenceImages"]);if(void 0!==b&&null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e;return c={},null!=(d=bH(b=a,["image"]))&&bG(c,["image"],c6(d)),null!=(e=bH(b,["referenceType"]))&&bG(c,["referenceType"],e),c})),bG(b,["instances[0]","referenceImages"],a)}if(void 0!==bH(a,["mask"]))throw Error("mask parameter is not supported in Gemini API.");if(void 0!==bH(a,["compressionQuality"]))throw Error("compressionQuality parameter is not supported in Gemini API.");if(void 0!==bH(a,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let l=bH(a,["webhookConfig"]);if(void 0!==b&&null!=l&&bG(b,["webhookConfig"],l),void 0!==bH(a,["resizeMode"]))throw Error("resizeMode parameter is not supported in Gemini API.")}(r,h),h);return l=bF("{model}:predictLongRunning",s._url),m=s._query,delete s._url,delete s._query,this.apiClient.request({path:l,queryParams:m,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json()).then(a=>{let b,c,d,e,f,g,h=(b={},null!=(c=bH(a,["name"]))&&bG(b,["name"],c),null!=(d=bH(a,["metadata"]))&&bG(b,["metadata"],d),null!=(e=bH(a,["done"]))&&bG(b,["done"],e),null!=(f=bH(a,["error"]))&&bG(b,["error"],f),null!=(g=bH(a,["response","generateVideoResponse"]))&&bG(b,["response"],function(a){let b={},c=bH(a,["generatedSamples"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h;return c={},null!=(d=bH(a,["video"]))&&bG(c,["video"],(e={},null!=(f=bH(b=d,["uri"]))&&bG(e,["uri"],f),null!=(g=bH(b,["encodedVideo"]))&&bG(e,["videoBytes"],bI(g)),null!=(h=bH(b,["encoding"]))&&bG(e,["mimeType"],h),e)),c})),bG(b,["generatedVideos"],a)}let d=bH(a,["raiMediaFilteredCount"]);null!=d&&bG(b,["raiMediaFilteredCount"],d);let e=bH(a,["raiMediaFilteredReasons"]);return null!=e&&bG(b,["raiMediaFilteredReasons"],e),b}(g)),b),i=new bW;return Object.assign(i,h),i})}}}class dB extends bE{constructor(a){super(),this.apiClient=a}async getVideosOperation(a){let b=a.operation,c=a.config;if(void 0===b.name||""===b.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let a,d=b.name.split("/operations/")[0];c&&"httpOptions"in c&&(a=c.httpOptions);let e=await this.fetchPredictVideosOperationInternal({operationName:b.name,resourceName:d,config:{httpOptions:a}});return b._fromAPIResponse({apiResponse:e,_isVertexAI:!0})}{let a=await this.getVideosOperationInternal({operationName:b.name,config:c});return b._fromAPIResponse({apiResponse:a,_isVertexAI:!1})}}async get(a){let b=a.operation,c=a.config;if(void 0===b.name||""===b.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let a,d=b.name.split("/operations/")[0];c&&"httpOptions"in c&&(a=c.httpOptions);let e=await this.fetchPredictVideosOperationInternal({operationName:b.name,resourceName:d,config:{httpOptions:a}});return b._fromAPIResponse({apiResponse:e,_isVertexAI:!0})}{let a=await this.getVideosOperationInternal({operationName:b.name,config:c});return b._fromAPIResponse({apiResponse:a,_isVertexAI:!1})}}async getVideosOperationInternal(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d,e,h=(d={},null!=(e=bH(a,["operationName"]))&&bG(d,["_url","operationName"],e),d);return f=bF("{operationName}",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json())}{let b,c,h=(b={},null!=(c=bH(a,["operationName"]))&&bG(b,["_url","operationName"],c),b);return f=bF("{operationName}",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json())}}async fetchPredictVideosOperationInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI()){let f,g,h,i=(f={},null!=(g=bH(a,["operationName"]))&&bG(f,["operationName"],g),null!=(h=bH(a,["resourceName"]))&&bG(f,["_url","resourceName"],h),f);return d=bF("{resourceName}:fetchPredictOperation",i._url),e=i._query,delete i._url,delete i._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json())}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}}function dC(a){if(void 0!==bH(a,["languageCodes"]))throw Error("languageCodes parameter is not supported in Gemini API.");return{}}class dD extends bE{constructor(a){super(),this.apiClient=a}async create(a){var b,c,d,e,f;let g="",h={};if(this.apiClient.isVertexAI())throw Error("The client.tokens.create method is only supported by the Gemini Developer API.");{let i,j,k,l,m,n,o,p,q,r,s=(d=this.apiClient,l={},null!=(m=bH(a,["config"]))&&bG(l,["config"],(n=bH(m,["expireTime"]),void 0!==l&&null!=n&&bG(l,["expireTime"],n),o=bH(m,["newSessionExpireTime"]),void 0!==l&&null!=o&&bG(l,["newSessionExpireTime"],o),p=bH(m,["uses"]),void 0!==l&&null!=p&&bG(l,["uses"],p),q=bH(m,["liveConnectConstraints"]),void 0!==l&&null!=q&&bG(l,["bidiGenerateContentSetup"],(e=d,i={},null!=(j=bH(f=q,["model"]))&&bG(i,["setup","model"],cb(e,j)),null!=(k=bH(f,["config"]))&&bG(i,["config"],function(a,b){let c=bH(a,["generationConfig"]);void 0!==b&&null!=c&&bG(b,["setup","generationConfig"],c);let d=bH(a,["responseModalities"]);void 0!==b&&null!=d&&bG(b,["setup","generationConfig","responseModalities"],d);let e=bH(a,["temperature"]);void 0!==b&&null!=e&&bG(b,["setup","generationConfig","temperature"],e);let f=bH(a,["topP"]);void 0!==b&&null!=f&&bG(b,["setup","generationConfig","topP"],f);let g=bH(a,["topK"]);void 0!==b&&null!=g&&bG(b,["setup","generationConfig","topK"],g);let h=bH(a,["maxOutputTokens"]);void 0!==b&&null!=h&&bG(b,["setup","generationConfig","maxOutputTokens"],h);let i=bH(a,["mediaResolution"]);void 0!==b&&null!=i&&bG(b,["setup","generationConfig","mediaResolution"],i);let j=bH(a,["seed"]);void 0!==b&&null!=j&&bG(b,["setup","generationConfig","seed"],j);let k=bH(a,["speechConfig"]);void 0!==b&&null!=k&&bG(b,["setup","generationConfig","speechConfig"],cr(k));let l=bH(a,["thinkingConfig"]);void 0!==b&&null!=l&&bG(b,["setup","generationConfig","thinkingConfig"],l);let m=bH(a,["enableAffectiveDialog"]);void 0!==b&&null!=m&&bG(b,["setup","generationConfig","enableAffectiveDialog"],m);let n=bH(a,["systemInstruction"]);void 0!==b&&null!=n&&bG(b,["setup","systemInstruction"],function(a){let b={},c=bH(a,["parts"]);if(null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>{var b;let c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return c={},null!=(d=bH(b=a,["mediaResolution"]))&&bG(c,["mediaResolution"],d),null!=(e=bH(b,["codeExecutionResult"]))&&bG(c,["codeExecutionResult"],e),null!=(f=bH(b,["executableCode"]))&&bG(c,["executableCode"],f),null!=(g=bH(b,["fileData"]))&&bG(c,["fileData"],function(a){let b={};if(void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let c=bH(a,["fileUri"]);null!=c&&bG(b,["fileUri"],c);let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(g)),null!=(h=bH(b,["functionCall"]))&&bG(c,["functionCall"],function(a){let b={},c=bH(a,["id"]);null!=c&&bG(b,["id"],c);let d=bH(a,["args"]);null!=d&&bG(b,["args"],d);let e=bH(a,["name"]);if(null!=e&&bG(b,["name"],e),void 0!==bH(a,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==bH(a,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return b}(h)),null!=(i=bH(b,["functionResponse"]))&&bG(c,["functionResponse"],i),null!=(j=bH(b,["inlineData"]))&&bG(c,["inlineData"],function(a){let b={},c=bH(a,["data"]);if(null!=c&&bG(b,["data"],c),void 0!==bH(a,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let d=bH(a,["mimeType"]);return null!=d&&bG(b,["mimeType"],d),b}(j)),null!=(k=bH(b,["text"]))&&bG(c,["text"],k),null!=(l=bH(b,["thought"]))&&bG(c,["thought"],l),null!=(m=bH(b,["thoughtSignature"]))&&bG(c,["thoughtSignature"],m),null!=(n=bH(b,["videoMetadata"]))&&bG(c,["videoMetadata"],n),null!=(o=bH(b,["toolCall"]))&&bG(c,["toolCall"],o),null!=(p=bH(b,["toolResponse"]))&&bG(c,["toolResponse"],p),null!=(q=bH(b,["partMetadata"]))&&bG(c,["partMetadata"],q),c})),bG(b,["parts"],a)}let d=bH(a,["role"]);return null!=d&&bG(b,["role"],d),b}(cm(n)));let o=bH(a,["tools"]);if(void 0!==b&&null!=o){let a=ct(o);Array.isArray(a)&&(a=a.map(a=>(function(a){let b,c,d,e={};if(void 0!==bH(a,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let f=bH(a,["computerUse"]);null!=f&&bG(e,["computerUse"],f);let g=bH(a,["fileSearch"]);null!=g&&bG(e,["fileSearch"],g);let h=bH(a,["googleSearch"]);null!=h&&bG(e,["googleSearch"],function(a){let b={},c=bH(a,["searchTypes"]);if(null!=c&&bG(b,["searchTypes"],c),void 0!==bH(a,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");if(void 0!==bH(a,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");let d=bH(a,["timeRangeFilter"]);return null!=d&&bG(b,["timeRangeFilter"],d),b}(h));let i=bH(a,["googleMaps"]);null!=i&&bG(e,["googleMaps"],(b={},null!=(c=bH(i,["authConfig"]))&&bG(b,["authConfig"],function(a){let b={},c=bH(a,["apiKey"]);if(null!=c&&bG(b,["apiKey"],c),void 0!==bH(a,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["authType"]))throw Error("authType parameter is not supported in Gemini API.");if(void 0!==bH(a,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oauthConfig"]))throw Error("oauthConfig parameter is not supported in Gemini API.");if(void 0!==bH(a,["oidcConfig"]))throw Error("oidcConfig parameter is not supported in Gemini API.");return b}(c)),null!=(d=bH(i,["enableWidget"]))&&bG(b,["enableWidget"],d),b));let j=bH(a,["codeExecution"]);if(null!=j&&bG(e,["codeExecution"],j),void 0!==bH(a,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let k=bH(a,["functionDeclarations"]);if(null!=k){let a=k;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["functionDeclarations"],a)}let l=bH(a,["googleSearchRetrieval"]);if(null!=l&&bG(e,["googleSearchRetrieval"],l),void 0!==bH(a,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is not supported in Gemini API.");let m=bH(a,["urlContext"]);null!=m&&bG(e,["urlContext"],m);let n=bH(a,["mcpServers"]);if(null!=n){let a=n;Array.isArray(a)&&(a=a.map(a=>a)),bG(e,["mcpServers"],a)}return e})(cs(a)))),bG(b,["setup","tools"],a)}let p=bH(a,["sessionResumption"]);void 0!==b&&null!=p&&bG(b,["setup","sessionResumption"],function(a){let b={},c=bH(a,["handle"]);if(null!=c&&bG(b,["handle"],c),void 0!==bH(a,["transparent"]))throw Error("transparent parameter is not supported in Gemini API.");return b}(p));let q=bH(a,["inputAudioTranscription"]);void 0!==b&&null!=q&&bG(b,["setup","inputAudioTranscription"],dC(q));let r=bH(a,["outputAudioTranscription"]);void 0!==b&&null!=r&&bG(b,["setup","outputAudioTranscription"],dC(r));let s=bH(a,["realtimeInputConfig"]);void 0!==b&&null!=s&&bG(b,["setup","realtimeInputConfig"],s);let t=bH(a,["contextWindowCompression"]);void 0!==b&&null!=t&&bG(b,["setup","contextWindowCompression"],t);let u=bH(a,["proactivity"]);if(void 0!==b&&null!=u&&bG(b,["setup","proactivity"],u),void 0!==bH(a,["explicitVadSignal"]))throw Error("explicitVadSignal parameter is not supported in Gemini API.");let v=bH(a,["avatarConfig"]);void 0!==b&&null!=v&&bG(b,["setup","avatarConfig"],v);let w=bH(a,["safetySettings"]);if(void 0!==b&&null!=w){let a=w;Array.isArray(a)&&(a=a.map(a=>(function(a){let b={},c=bH(a,["category"]);if(null!=c&&bG(b,["category"],c),void 0!==bH(a,["method"]))throw Error("method parameter is not supported in Gemini API.");let d=bH(a,["threshold"]);return null!=d&&bG(b,["threshold"],d),b})(a))),bG(b,["setup","safetySettings"],a)}return{}}(k,i)),i)),r=bH(m,["lockAdditionalFields"]),void 0!==l&&null!=r&&bG(l,["fieldMask"],r),{})),l);g=bF("auth_tokens",s._url),h=s._query,delete s.config,delete s._url,delete s._query;let t=function(a,b){let c=null,d=a.bidiGenerateContentSetup;if("object"==typeof d&&null!==d&&"setup"in d){let b=d.setup;"object"==typeof b&&null!==b?(a.bidiGenerateContentSetup=b,c=b):delete a.bidiGenerateContentSetup}else void 0!==d&&delete a.bidiGenerateContentSetup;let e=a.fieldMask;if(c){let d=function(a){let b=[];for(let c in a)if(Object.prototype.hasOwnProperty.call(a,c)){let d=a[c];if("object"==typeof d&&null!=d&&Object.keys(d).length>0){let a=Object.keys(d).map(a=>`${c}.${a}`);b.push(...a)}else b.push(c)}return b.join(",")}(c);if(Array.isArray(null==b?void 0:b.lockAdditionalFields)&&(null==b?void 0:b.lockAdditionalFields.length)===0)d?a.fieldMask=d:delete a.fieldMask;else if((null==b?void 0:b.lockAdditionalFields)&&b.lockAdditionalFields.length>0&&null!==e&&Array.isArray(e)&&e.length>0){let b=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"],c=[];e.length>0&&(c=e.map(a=>b.includes(a)?`generationConfig.${a}`:a));let f=[];d&&f.push(d),c.length>0&&f.push(...c),f.length>0?a.fieldMask=f.join(","):delete a.fieldMask}else delete a.fieldMask}else null!==e&&Array.isArray(e)&&e.length>0?a.fieldMask=e.join(","):delete a.fieldMask;return a}(s,a.config);return this.apiClient.request({path:g,queryParams:h,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}}}class dE extends bE{constructor(a){super(),this.apiClient=a,this.list=async a=>new cJ(bv.PAGED_ITEM_DOCUMENTS,b=>this.listInternal({parent:a.parent,config:b.config}),await this.listInternal(a),a)}async get(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h=(f={},null!=(g=bH(a,["name"]))&&bG(f,["_url","name"],g),f);return d=bF("{name}",h._url),e=h._query,delete h._url,delete h._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}}async delete(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j=(f={},null!=(g=bH(a,["name"]))&&bG(f,["_url","name"],g),null!=(h=bH(a,["config"]))&&(i=bH(h,["force"]),void 0!==f&&null!=i&&bG(f,["_query","force"],i)),f);d=bF("{name}",j._url),e=j._query,delete j._url,delete j._query,await this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(j),httpMethod:"DELETE",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal})}}async listInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j,k=(f={},null!=(g=bH(a,["parent"]))&&bG(f,["_url","parent"],g),null!=(h=bH(a,["config"]))&&(i=bH(h,["pageSize"]),void 0!==f&&null!=i&&bG(f,["_query","pageSize"],i),j=bH(h,["pageToken"]),void 0!==f&&null!=j&&bG(f,["_query","pageToken"],j)),f);return d=bF("{parent}/documents",k._url),e=k._query,delete k._url,delete k._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(k),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["documents"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["documents"],a)}return b}(a),c=new b_;return Object.assign(c,b),c})}}}class dF extends bE{constructor(a,b=new dE(a)){super(),this.apiClient=a,this.documents=b,this.list=async(a={})=>new cJ(bv.PAGED_ITEM_FILE_SEARCH_STORES,a=>this.listInternal(a),await this.listInternal(a),a)}async uploadToFileSearchStore(a){if(this.apiClient.isVertexAI())throw Error("Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(a.fileSearchStoreName,a.file,a.config)}async downloadMedia(a,b){if(this.apiClient.isVertexAI())throw Error("This method is only supported in the Gemini Developer client.");let c=new URL(a,"http://dummy.com"),d=c.pathname;if(d.startsWith("/")&&(d=d.slice(1)),!d.includes("/media/"))throw Error(`Invalid uri format: ${a}. Expected to contain /media/`);let e={};c.searchParams.forEach((a,b)=>{e[b]=a}),e.alt="media";let f=Object.assign({},null==b?void 0:b.httpOptions),g=await this.apiClient.request({path:d,httpMethod:"GET",queryParams:e,httpOptions:f});if(g instanceof bK)return new Uint8Array(await g.responseInternal.arrayBuffer());throw Error("Unexpected response type from downloadMedia")}async create(a){var b,c,d;let e="",f={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let g,h,i,j,k=(d=this.apiClient,g={},null!=(h=bH(a,["config"]))&&(i=bH(h,["displayName"]),void 0!==g&&null!=i&&bG(g,["displayName"],i),j=bH(h,["embeddingModel"]),void 0!==g&&null!=j&&bG(g,["embeddingModel"],cb(d,j))),g);return e=bF("fileSearchStores",k._url),f=k._query,delete k._url,delete k._query,this.apiClient.request({path:e,queryParams:f,body:JSON.stringify(k),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}}async get(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h=(f={},null!=(g=bH(a,["name"]))&&bG(f,["_url","name"],g),f);return d=bF("{name}",h._url),e=h._query,delete h._url,delete h._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>a)}}async delete(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j=(f={},null!=(g=bH(a,["name"]))&&bG(f,["_url","name"],g),null!=(h=bH(a,["config"]))&&(i=bH(h,["force"]),void 0!==f&&null!=i&&bG(f,["_query","force"],i)),f);d=bF("{name}",j._url),e=j._query,delete j._url,delete j._query,await this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(j),httpMethod:"DELETE",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal})}}async listInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j=(f={},null!=(g=bH(a,["config"]))&&(h=bH(g,["pageSize"]),void 0!==f&&null!=h&&bG(f,["_query","pageSize"],h),i=bH(g,["pageToken"]),void 0!==f&&null!=i&&bG(f,["_query","pageToken"],i)),f);return d=bF("fileSearchStores",j._url),e=j._query,delete j._url,delete j._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(j),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["fileSearchStores"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["fileSearchStores"],a)}return b}(a),c=new b0;return Object.assign(c,b),c})}}async uploadToFileSearchStoreInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i=(f={},null!=(g=bH(a,["fileSearchStoreName"]))&&bG(f,["_url","file_search_store_name"],g),null!=(h=bH(a,["config"]))&&df(h,f),f);return d=bF("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",i._url),e=i._query,delete i._url,delete i._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new b1;return Object.assign(e,d),e})}}async importFile(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j=(f={},null!=(g=bH(a,["fileSearchStoreName"]))&&bG(f,["_url","file_search_store_name"],g),null!=(h=bH(a,["fileName"]))&&bG(f,["fileName"],h),null!=(i=bH(a,["config"]))&&function(a,b){let c=bH(a,["customMetadata"]);if(void 0!==b&&null!=c){let a=c;Array.isArray(a)&&(a=a.map(a=>a)),bG(b,["customMetadata"],a)}let d=bH(a,["chunkingConfig"]);void 0!==b&&null!=d&&bG(b,["chunkingConfig"],d)}(i,f),f);return d=bF("{file_search_store_name}:importFile",j._url),e=j._query,delete j._url,delete j._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(j),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json()).then(a=>{var b;let c,d,e,f,g,h,i,j,k,l,m=(g={},null!=(h=bH(a,["name"]))&&bG(g,["name"],h),null!=(i=bH(a,["metadata"]))&&bG(g,["metadata"],i),null!=(j=bH(a,["done"]))&&bG(g,["done"],j),null!=(k=bH(a,["error"]))&&bG(g,["error"],k),null!=(l=bH(a,["response"]))&&bG(g,["response"],(c={},null!=(d=bH(b=l,["sdkHttpResponse"]))&&bG(c,["sdkHttpResponse"],d),null!=(e=bH(b,["parent"]))&&bG(c,["parent"],e),null!=(f=bH(b,["documentName"]))&&bG(c,["documentName"],f),c)),g),n=new b2;return Object.assign(n,m),n})}}}let dG=function(){let{crypto:a}=globalThis;if(null==a?void 0:a.randomUUID)return dG=a.randomUUID.bind(a),a.randomUUID();let b=new Uint8Array(1),c=a?()=>a.getRandomValues(b)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,a=>(a^c()&15>>a/4).toString(16))};function dH(a){return"object"==typeof a&&null!==a&&("name"in a&&"AbortError"===a.name||"message"in a&&String(a.message).includes("FetchRequestCanceledException"))}let dI=a=>{if(a instanceof Error)return a;if("object"==typeof a&&null!==a){try{if("[object Error]"===Object.prototype.toString.call(a)){let b=Error(a.message,a.cause?{cause:a.cause}:{});return a.stack&&(b.stack=a.stack),a.cause&&!b.cause&&(b.cause=a.cause),a.name&&(b.name=a.name),b}}catch(a){}try{return Error(JSON.stringify(a))}catch(a){}}return Error(a)};class dJ extends Error{}class dK extends dJ{constructor(a,b,c,d){super(`${dK.makeMessage(a,b,c)}`),this.status=a,this.headers=d,this.error=b}static makeMessage(a,b,c){let d=(null==b?void 0:b.message)?"string"==typeof b.message?b.message:JSON.stringify(b.message):b?JSON.stringify(b):c;return a&&d?`${a} ${d}`:a?`${a} status code (no body)`:d||"(no status code or body)"}static generate(a,b,c,d){return a&&d?400===a?new dO(a,b,c,d):401===a?new dP(a,b,c,d):403===a?new dQ(a,b,c,d):404===a?new dR(a,b,c,d):409===a?new dS(a,b,c,d):422===a?new dT(a,b,c,d):429===a?new dU(a,b,c,d):a>=500?new dV(a,b,c,d):new dK(a,b,c,d):new dM({message:c,cause:dI(b)})}}class dL extends dK{constructor({message:a}={}){super(void 0,void 0,a||"Request was aborted.",void 0)}}class dM extends dK{constructor({message:a,cause:b}){super(void 0,void 0,a||"Connection error.",void 0),b&&(this.cause=b)}}class dN extends dM{constructor({message:a}={}){super({message:null!=a?a:"Request timed out."})}}class dO extends dK{}class dP extends dK{}class dQ extends dK{}class dR extends dK{}class dS extends dK{}class dT extends dK{}class dU extends dK{}class dV extends dK{}let dW=/^[a-z][a-z0-9+.-]*:/i,dX=a=>(dX=Array.isArray)(a),dY=dX;function dZ(a){if(!a)return!0;for(let b in a)return!1;return!0}function d$(...a){let b=globalThis.ReadableStream;if(void 0===b)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new b(...a)}function d_(a){if(a[Symbol.asyncIterator])return a;let b=a.getReader();return{async next(){try{let a=await b.read();return(null==a?void 0:a.done)&&b.releaseLock(),a}catch(a){throw b.releaseLock(),a}},async return(){let a=b.cancel();return b.releaseLock(),await a,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function d0(a){var b,c;if(null===a||"object"!=typeof a)return;if(a[Symbol.asyncIterator])return void await (null==(c=(b=a[Symbol.asyncIterator]()).return)?void 0:c.call(b));let d=a.getReader(),e=d.cancel();d.releaseLock(),await e}let d1=({headers:a,body:b})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(b)}),d2=()=>{var a;if("u"<typeof File){let{process:b}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof(null==(a=null==b?void 0:b.versions)?void 0:a.node)&&20>parseInt(b.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function d3(a,b,c){return d2(),new File(a,null!=b?b:"unknown_file",c)}let d4=a=>null!=a&&"object"==typeof a&&"number"==typeof a.size&&"string"==typeof a.type&&"function"==typeof a.text&&"function"==typeof a.slice&&"function"==typeof a.arrayBuffer;async function d5(a,b,c){var d;let e,f;if(d2(),null!=(e=a=await a)&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&d4(e))return a instanceof File?a:d3([await a.arrayBuffer()],a.name);if(null!=(f=a)&&"object"==typeof f&&"string"==typeof f.url&&"function"==typeof f.blob){let d=await a.blob();return b||(b=new URL(a.url).pathname.split(/[\\/]/).pop()),d3(await d6(d),b,c)}let g=await d6(a);if(b||(b=("object"==typeof(d=a)&&null!==d&&("name"in d&&d.name&&String(d.name)||"url"in d&&d.url&&String(d.url)||"filename"in d&&d.filename&&String(d.filename)||"path"in d&&d.path&&String(d.path))||"").split(/[\\/]/).pop()||void 0),!(null==c?void 0:c.type)){let a=g.find(a=>"object"==typeof a&&"type"in a&&a.type);"string"==typeof a&&(c=Object.assign(Object.assign({},c),{type:a}))}return d3(g,b,c)}async function d6(a){let b=[];if("string"==typeof a||ArrayBuffer.isView(a)||a instanceof ArrayBuffer)b.push(a);else if(d4(a))b.push(a instanceof Blob?a:await a.arrayBuffer());else if(null!=a&&"object"==typeof a&&"function"==typeof a[Symbol.asyncIterator])try{for(var c,d,e,f,g,h,i=!0,j=cR(a);!(c=(h=await j.next()).done);i=!0)f=h.value,i=!1,b.push(...await d6(f))}catch(a){d={error:a}}finally{try{!i&&!c&&(e=j.return)&&await e.call(j)}finally{if(d)throw d.error}}else{let b=null==(g=null==a?void 0:a.constructor)?void 0:g.name;throw Error(`Unexpected data type: ${typeof a}${b?`; constructor: ${b}`:""}${function(a){if("object"!=typeof a||null===a)return"";let b=Object.getOwnPropertyNames(a);return`; props: [${b.map(a=>`"${a}"`).join(", ")}]`}(a)}`)}return b}class d7{constructor(a){this._client=a}}function d8(a){return a.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}d7._key=[];let d9=Object.freeze(Object.create(null)),ea=((a=d8)=>function(b,...c){let d;if(1===b.length)return b[0];let e=!1,f=[],g=b.reduce((b,d,g)=>{var h,i,j;/[?#]/.test(d)&&(e=!0);let k=c[g],l=(e?encodeURIComponent:a)(""+k);return g!==c.length&&(null==k||"object"==typeof k&&k.toString===(null==(j=Object.getPrototypeOf(null!=(i=Object.getPrototypeOf(null!=(h=k.hasOwnProperty)?h:d9))?i:d9))?void 0:j.toString))&&(l=k+"",f.push({start:b.length+d.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(k).slice(8,-1)} is not a valid path parameter`})),b+d+(g===c.length?"":l)},""),h=g.split(/[?#]/,1)[0],i=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(d=i.exec(h));){let a=d[0].startsWith("/"),b=+!!a,c=a?d[0].slice(1):d[0];f.push({start:d.index+b,length:c.length,error:`Value "${c}" can't be safely passed as a path parameter`})}if(f.sort((a,b)=>a.start-b.start),f.length>0){let a=0,b=f.reduce((b,c)=>{let d=" ".repeat(c.start-a),e="^".repeat(c.length);return a=c.start+c.length,b+d+e},"");throw new dJ(`Path parameters result in path with invalid segments:
|
|
5
|
+
${f.map(a=>a.error).join("\n")}
|
|
6
|
+
${g}
|
|
7
|
+
${b}`)}return g})(d8);class eb extends d7{create(a,b){var c;let{api_version:d=this._client.apiVersion}=a,e=cO(a,["api_version"]);if("model"in e&&"agent_config"in e)throw new dJ("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in e&&"generation_config"in e)throw new dJ("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(ea`/${d}/interactions`,Object.assign(Object.assign({body:e},b),{stream:null!=(c=a.stream)&&c}))}delete(a,b={},c){let{api_version:d=this._client.apiVersion}=null!=b?b:{};return this._client.delete(ea`/${d}/interactions/${a}`,c)}cancel(a,b={},c){let{api_version:d=this._client.apiVersion}=null!=b?b:{};return this._client.post(ea`/${d}/interactions/${a}/cancel`,c)}get(a,b={},c){var d;let e=null!=b?b:{},{api_version:f=this._client.apiVersion}=e,g=cO(e,["api_version"]);return this._client.get(ea`/${f}/interactions/${a}`,Object.assign(Object.assign({query:g},c),{stream:null!=(d=null==b?void 0:b.stream)&&d}))}}eb._key=Object.freeze(["interactions"]);class ec extends eb{}class ed extends d7{create(a,b){let{api_version:c=this._client.apiVersion}=a,d=cO(a,["api_version"]);return this._client.post(ea`/${c}/webhooks`,Object.assign({body:d},b))}update(a,b={},c){let d=null!=b?b:{},{api_version:e=this._client.apiVersion,update_mask:f}=d,g=cO(d,["api_version","update_mask"]);return this._client.patch(ea`/${e}/webhooks/${a}`,Object.assign({query:{update_mask:f},body:g},c))}list(a={},b){let c=null!=a?a:{},{api_version:d=this._client.apiVersion}=c,e=cO(c,["api_version"]);return this._client.get(ea`/${d}/webhooks`,Object.assign({query:e},b))}delete(a,b={},c){let{api_version:d=this._client.apiVersion}=null!=b?b:{};return this._client.delete(ea`/${d}/webhooks/${a}`,c)}get(a,b={},c){let{api_version:d=this._client.apiVersion}=null!=b?b:{};return this._client.get(ea`/${d}/webhooks/${a}`,c)}ping(a,b,c){let{api_version:d=this._client.apiVersion,body:e}=null!=b?b:{};return this._client.post(ea`/${d}/webhooks/${a}:ping`,Object.assign({body:e},c))}rotateSigningSecret(a,b={},c){let d=null!=b?b:{},{api_version:e=this._client.apiVersion}=d,f=cO(d,["api_version"]);return this._client.post(ea`/${e}/webhooks/${a}:rotateSigningSecret`,Object.assign({body:f},c))}}ed._key=Object.freeze(["webhooks"]);class ee extends ed{}function ef(a){let b;return(null!=d?d:d=(b=new globalThis.TextEncoder).encode.bind(b))(a)}function eg(a){let b;return(null!=e?e:e=(b=new globalThis.TextDecoder).decode.bind(b))(a)}class eh{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null,this.searchIndex=0}decode(a){var b,c,d;let e,f,g,h,i;if(null==a)return[];let j=a instanceof ArrayBuffer?new Uint8Array(a):"string"==typeof a?ef(a):a;this.buffer=function(a){let b=0;for(let c of a)b+=c.length;let c=new Uint8Array(b),d=0;for(let b of a)c.set(b,d),d+=b.length;return c}([this.buffer,j]);let k=[];for(;null!=(c=this.buffer,g=null!=(d=null!=(b=this.carriageReturnIndex)?b:this.searchIndex)?d:0,h=c.indexOf(10,g),i=c.indexOf(13,g),e=-1===h&&-1===i?null:10===c[f=-1!==h&&-1!==i?Math.min(h,i):-1!==h?h:i]?{preceding:f,index:f+1,carriage:!1}:{preceding:f,index:f+1,carriage:!0});){if(e.carriage&&null==this.carriageReturnIndex){this.carriageReturnIndex=e.index;continue}if(null!=this.carriageReturnIndex&&(e.index!==this.carriageReturnIndex+1||e.carriage)){k.push(eg(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null,this.searchIndex=0;continue}let a=null!==this.carriageReturnIndex?e.preceding-1:e.preceding,b=eg(this.buffer.subarray(0,a));k.push(b),this.buffer=this.buffer.subarray(e.index),this.carriageReturnIndex=null,this.searchIndex=0}return this.searchIndex=Math.max(0,this.buffer.length-1),k}flush(){return this.buffer.length?this.decode("\n"):[]}}eh.NEWLINE_CHARS=new Set(["\n","\r"]),eh.NEWLINE_REGEXP=/\r\n|[\n\r]/g;let ei={off:0,error:200,warn:300,info:400,debug:500},ej=(a,b,c)=>{if(a){if(Object.prototype.hasOwnProperty.call(ei,a))return a;eo(c).warn(`${b} was set to ${JSON.stringify(a)}, expected one of ${JSON.stringify(Object.keys(ei))}`)}};function ek(){}function el(a,b,c){return!b||ei[a]>ei[c]?ek:b[a].bind(b)}let em={error:ek,warn:ek,info:ek,debug:ek},en=new WeakMap;function eo(a){var b;let c=a.logger,d=null!=(b=a.logLevel)?b:"off";if(!c)return em;let e=en.get(c);if(e&&e[0]===d)return e[1];let f={error:el("error",c,d),warn:el("warn",c,d),info:el("info",c,d),debug:el("debug",c,d)};return en.set(c,[d,f]),f}let ep=a=>(a.options&&(a.options=Object.assign({},a.options),delete a.options.headers),a.headers&&(a.headers=Object.fromEntries((a.headers instanceof Headers?[...a.headers]:Object.entries(a.headers)).map(([a,b])=>[a,"x-goog-api-key"===a.toLowerCase()||"authorization"===a.toLowerCase()||"cookie"===a.toLowerCase()||"set-cookie"===a.toLowerCase()?"***":b]))),"retryOfRequestLogID"in a&&(a.retryOfRequestLogID&&(a.retryOf=a.retryOfRequestLogID),delete a.retryOfRequestLogID),a);class eq{constructor(a,b,c){this.iterator=a,this.controller=b,this.client=c}static fromSSEResponse(a,b,c){let d=!1,e=c?eo(c):console;return new eq(function(){return cQ(this,arguments,function*(){var c,f,g,h;if(d)throw new dJ("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");d=!0;let i=!1;try{try{for(var j,k=!0,l=cR(function(a,b){return cQ(this,arguments,function*(){var c,d,e,f;if(!a.body){if(b.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new dJ("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new dJ("Attempted to iterate over a response with no body")}let g=new er,h=new eh,i=d_(a.body);try{for(var j,k=!0,l=cR(function(a){return cQ(this,arguments,function*(){var b,c,d,e;try{for(var f,g=!0,h=cR(a);!(b=(f=yield cP(h.next())).done);g=!0){if(e=f.value,g=!1,null==e)continue;let a=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?ef(e):e;yield yield cP(a)}}catch(a){c={error:a}}finally{try{!g&&!b&&(d=h.return)&&(yield cP(d.call(h)))}finally{if(c)throw c.error}}})}(i));!(c=(j=yield cP(l.next())).done);k=!0)for(let a of(f=j.value,k=!1,h.decode(f))){let b=g.decode(a);b&&(yield yield cP(b))}}catch(a){d={error:a}}finally{try{!k&&!c&&(e=l.return)&&(yield cP(e.call(l)))}finally{if(d)throw d.error}}for(let a of h.flush()){let b=g.decode(a);b&&(yield yield cP(b))}})}(a,b));!(c=(j=yield cP(l.next())).done);k=!0)if(h=j.value,k=!1,!i)if(h.data.startsWith("[DONE]")){i=!0;continue}else try{yield yield cP(JSON.parse(h.data))}catch(a){throw e.error("Could not parse message into JSON:",h.data),e.error("From chunk:",h.raw),a}}catch(a){f={error:a}}finally{try{!k&&!c&&(g=l.return)&&(yield cP(g.call(l)))}finally{if(f)throw f.error}}i=!0}catch(a){if(dH(a))return yield cP(void 0);throw a}finally{i||b.abort()}})},b,c)}static fromReadableStream(a,b,c){let d=!1;return new eq(function(){return cQ(this,arguments,function*(){var c,e,f,g;if(d)throw new dJ("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");d=!0;let h=!1;try{try{for(var i,j=!0,k=cR(function(){return cQ(this,arguments,function*(){var b,c,d,e;let f=new eh,g=d_(a);try{for(var h,i=!0,j=cR(g);!(b=(h=yield cP(j.next())).done);i=!0)for(let a of(e=h.value,i=!1,f.decode(e)))yield yield cP(a)}catch(a){c={error:a}}finally{try{!i&&!b&&(d=j.return)&&(yield cP(d.call(j)))}finally{if(c)throw c.error}}for(let a of f.flush())yield yield cP(a)})}());!(c=(i=yield cP(k.next())).done);j=!0)g=i.value,j=!1,!h&&g&&(yield yield cP(JSON.parse(g)))}catch(a){e={error:a}}finally{try{!j&&!c&&(f=k.return)&&(yield cP(f.call(k)))}finally{if(e)throw e.error}}h=!0}catch(a){if(dH(a))return yield cP(void 0);throw a}finally{h||b.abort()}})},b,c)}[Symbol.asyncIterator](){return this.iterator()}tee(){let a=[],b=[],c=this.iterator(),d=d=>({next:()=>{if(0===d.length){let d=c.next();a.push(d),b.push(d)}return d.shift()}});return[new eq(()=>d(a),this.controller,this.client),new eq(()=>d(b),this.controller,this.client)]}toReadableStream(){let a,b=this;return d$({async start(){a=b[Symbol.asyncIterator]()},async pull(b){try{let{value:c,done:d}=await a.next();if(d)return b.close();let e=ef(JSON.stringify(c)+"\n");b.enqueue(e)}catch(a){b.error(a)}},async cancel(){var b;await (null==(b=a.return)?void 0:b.call(a))}})}}class er{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(a){var b;let c;if(a.endsWith("\r")&&(a=a.substring(0,a.length-1)),!a){if(!this.event&&!this.data.length)return null;let a={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],a}if(this.chunks.push(a),a.startsWith(":"))return null;let[d,e,f]=-1!==(c=(b=a).indexOf(":"))?[b.substring(0,c),":",b.substring(c+1)]:[b,"",""];return f.startsWith(" ")&&(f=f.substring(1)),"event"===d?this.event=f:"data"===d&&this.data.push(f),null}}async function es(a,b){let{response:c,requestLogID:d,retryOfRequestLogID:e,startTime:f}=b,g=await (async()=>{var d;if(b.options.stream)return(eo(a).debug("response",c.status,c.url,c.headers,c.body),b.options.__streamClass)?b.options.__streamClass.fromSSEResponse(c,b.controller,a):eq.fromSSEResponse(c,b.controller,a);if(204===c.status)return null;if(b.options.__binaryResponse)return c;let e=c.headers.get("content-type"),f=null==(d=null==e?void 0:e.split(";")[0])?void 0:d.trim();if((null==f?void 0:f.includes("application/json"))||(null==f?void 0:f.endsWith("+json"))){if("0"===c.headers.get("content-length"))return;return await c.json()}return await c.text()})();return eo(a).debug(`[${d}] response parsed`,ep({retryOfRequestLogID:e,url:c.url,status:c.status,body:g,durationMs:Date.now()-f})),g}class et extends Promise{constructor(a,b,c=es){super(a=>{a(null)}),this.responsePromise=b,this.parseResponse=c,this.client=a}_thenUnwrap(a){return new et(this.client,this.responsePromise,async(b,c)=>a(await this.parseResponse(b,c),c))}asResponse(){return this.responsePromise.then(a=>a.response)}async withResponse(){let[a,b]=await Promise.all([this.parse(),this.asResponse()]);return{data:a,response:b}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(a=>this.parseResponse(this.client,a))),this.parsedPromise}then(a,b){return this.parse().then(a,b)}catch(a){return this.parse().catch(a)}finally(a){return this.parse().finally(a)}}let eu=Symbol("brand.privateNullableHeaders"),ev=a=>{let b=new Headers,c=new Set;for(let d of a){let a=new Set;for(let[e,f]of function*(a){let b;if(!a)return;if(eu in a){let{values:b,nulls:c}=a;for(let a of(yield*b.entries(),c))yield[a,null];return}let c=!1;for(let d of(a instanceof Headers?b=a.entries():dY(a)?b=a:(c=!0,b=Object.entries(null!=a?a:{})),b)){let a=d[0];if("string"!=typeof a)throw TypeError("expected header name to be a string");let b=dY(d[1])?d[1]:[d[1]],e=!1;for(let d of b)void 0!==d&&(c&&!e&&(e=!0,yield[a,null]),yield[a,d])}}(d)){let d=e.toLowerCase();a.has(d)||(b.delete(e),a.add(d)),null===f?(b.delete(e),c.add(d)):(b.append(e,f),c.delete(d))}}return{[eu]:!0,values:b,nulls:c}},ew=a=>{var b,c,d,e,f;return void 0!==globalThis.process?(null==(c=null==(b=globalThis.process.env)?void 0:b[a])?void 0:c.trim())||void 0:void 0!==globalThis.Deno&&(null==(f=null==(e=null==(d=globalThis.Deno.env)?void 0:d.get)?void 0:e.call(d,a))?void 0:f.trim())||void 0};class ex{constructor(a){var b,c,d,e,f,g,h,{baseURL:i=ew("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:j=null!=(b=ew("GEMINI_API_KEY"))?b:null,apiVersion:k="v1beta"}=a;const l=Object.assign(Object.assign({apiKey:j,apiVersion:k},cO(a,["baseURL","apiKey","apiVersion"])),{baseURL:i||"https://generativelanguage.googleapis.com"});this.baseURL=l.baseURL,this.timeout=null!=(c=l.timeout)?c:ex.DEFAULT_TIMEOUT,this.logger=null!=(d=l.logger)?d:console;const m="warn";this.logLevel=m,this.logLevel=null!=(f=null!=(e=ej(l.logLevel,"ClientOptions.logLevel",this))?e:ej(ew("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))?f:m,this.fetchOptions=l.fetchOptions,this.maxRetries=null!=(g=l.maxRetries)?g:2,this.fetch=null!=(h=l.fetch)?h:function(){if("u">typeof fetch)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),this.encoder=d1,this._options=l,this.apiKey=j,this.apiVersion=k,this.clientAdapter=l.clientAdapter}withOptions(a){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),a))}baseURLOverridden(){return"https://generativelanguage.googleapis.com"!==this.baseURL}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:a,nulls:b}){if(!(a.has("authorization")||a.has("x-goog-api-key")||this.apiKey&&a.get("x-goog-api-key"))&&!b.has("x-goog-api-key"))throw Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(a){let b=ev([a.headers]);if(!(b.values.has("authorization")||b.values.has("x-goog-api-key"))){if(this.apiKey)return ev([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter&&this.clientAdapter.isVertexAI())return ev([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(a){return Object.entries(a).filter(([a,b])=>void 0!==b).map(([a,b])=>{if("string"==typeof b||"number"==typeof b||"boolean"==typeof b)return`${encodeURIComponent(a)}=${encodeURIComponent(b)}`;if(null===b)return`${encodeURIComponent(a)}=`;throw new dJ(`Cannot stringify type ${typeof b}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS 0.0.1`}defaultIdempotencyKey(){return`stainless-node-retry-${dG()}`}makeStatusError(a,b,c,d){return dK.generate(a,b,c,d)}buildURL(a,b,c){let d=!this.baseURLOverridden()&&c||this.baseURL,e=new URL(dW.test(a)?a:d+(d.endsWith("/")&&a.startsWith("/")?a.slice(1):a)),f=this.defaultQuery(),g=Object.fromEntries(e.searchParams);return dZ(f)&&dZ(g)||(b=Object.assign(Object.assign(Object.assign({},g),f),b)),"object"==typeof b&&b&&!Array.isArray(b)&&(e.search=this.stringifyQuery(b)),e.toString()}async prepareOptions(a){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!a.path.startsWith(`/${this.apiVersion}/projects/`)){let b=a.path.slice(this.apiVersion.length+1);a.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${b}`}}async prepareRequest(a,{url:b,options:c}){}get(a,b){return this.methodRequest("get",a,b)}post(a,b){return this.methodRequest("post",a,b)}patch(a,b){return this.methodRequest("patch",a,b)}put(a,b){return this.methodRequest("put",a,b)}delete(a,b){return this.methodRequest("delete",a,b)}methodRequest(a,b,c){return this.request(Promise.resolve(c).then(c=>Object.assign({method:a,path:b},c)))}request(a,b=null){return new et(this,this.makeRequest(a,b,void 0))}async makeRequest(a,b,c){var d,e,f;let g=await a,h=null!=(d=g.maxRetries)?d:this.maxRetries;null==b&&(b=h),await this.prepareOptions(g);let{req:i,url:j,timeout:k}=await this.buildRequest(g,{retryCount:h-b});await this.prepareRequest(i,{url:j,options:g});let l="log_"+(0x1000000*Math.random()|0).toString(16).padStart(6,"0"),m=void 0===c?"":`, retryOf: ${c}`,n=Date.now();if(eo(this).debug(`[${l}] sending request`,ep({retryOfRequestLogID:c,method:g.method,url:j,options:g,headers:i.headers})),null==(e=g.signal)?void 0:e.aborted)throw new dL;let o=new AbortController,p=await this.fetchWithTimeout(j,i,k,o).catch(dI),q=Date.now();if(p instanceof globalThis.Error){let a=`retrying, ${b} attempts remaining`;if(null==(f=g.signal)?void 0:f.aborted)throw new dL;let d=dH(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(b)return eo(this).info(`[${l}] connection ${d?"timed out":"failed"} - ${a}`),eo(this).debug(`[${l}] connection ${d?"timed out":"failed"} (${a})`,ep({retryOfRequestLogID:c,url:j,durationMs:q-n,message:p.message})),this.retryRequest(g,b,null!=c?c:l);if(eo(this).info(`[${l}] connection ${d?"timed out":"failed"} - error; no more retries left`),eo(this).debug(`[${l}] connection ${d?"timed out":"failed"} (error; no more retries left)`,ep({retryOfRequestLogID:c,url:j,durationMs:q-n,message:p.message})),d)throw new dN;throw new dM({cause:p})}let r=`[${l}${m}] ${i.method} ${j} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${q-n}ms`;if(!p.ok){let a=await this.shouldRetry(p);if(b&&a){let a=`retrying, ${b} attempts remaining`;return await d0(p.body),eo(this).info(`${r} - ${a}`),eo(this).debug(`[${l}] response error (${a})`,ep({retryOfRequestLogID:c,url:p.url,status:p.status,headers:p.headers,durationMs:q-n})),this.retryRequest(g,b,null!=c?c:l,p.headers)}let d=a?"error; no more retries left":"error; not retryable";eo(this).info(`${r} - ${d}`);let e=await p.text().catch(a=>dI(a).message),f=(a=>{try{return JSON.parse(a)}catch(a){return}})(e),h=f?void 0:e;throw eo(this).debug(`[${l}] response error (${d})`,ep({retryOfRequestLogID:c,url:p.url,status:p.status,headers:p.headers,message:h,durationMs:Date.now()-n})),this.makeStatusError(p.status,f,h,p.headers)}return eo(this).info(r),eo(this).debug(`[${l}] response start`,ep({retryOfRequestLogID:c,url:p.url,status:p.status,headers:p.headers,durationMs:q-n})),{response:p,options:g,controller:o,requestLogID:l,retryOfRequestLogID:c,startTime:n}}async fetchWithTimeout(a,b,c,d){let e=b||{},{signal:f,method:g}=e,h=cO(e,["signal","method"]),i=this._makeAbort(d);f&&f.addEventListener("abort",i,{once:!0});let j=setTimeout(i,c),k=globalThis.ReadableStream&&h.body instanceof globalThis.ReadableStream||"object"==typeof h.body&&null!==h.body&&Symbol.asyncIterator in h.body,l=Object.assign(Object.assign(Object.assign({signal:d.signal},k?{duplex:"half"}:{}),{method:"GET"}),h);g&&(l.method=g.toUpperCase());try{return await this.fetch.call(void 0,a,l)}finally{clearTimeout(j)}}async shouldRetry(a){let b=a.headers.get("x-should-retry");return"true"===b||"false"!==b&&(408===a.status||409===a.status||429===a.status||!!(a.status>=500))}async retryRequest(a,b,c,d){var e;let f,g,h=null==d?void 0:d.get("retry-after-ms");if(h){let a=parseFloat(h);Number.isNaN(a)||(f=a)}let i=null==d?void 0:d.get("retry-after");if(i&&!f){let a=parseFloat(i);f=Number.isNaN(a)?Date.parse(i)-Date.now():1e3*a}if(void 0===f){let c=null!=(e=a.maxRetries)?e:this.maxRetries;f=this.calculateDefaultRetryTimeoutMillis(b,c)}return await (g=f,new Promise(a=>setTimeout(a,g))),this.makeRequest(a,b-1,c)}calculateDefaultRetryTimeoutMillis(a,b){return Math.min(.5*Math.pow(2,b-a),8)*(1-.25*Math.random())*1e3}async buildRequest(a,{retryCount:b=0}={}){var c,d,e;let f=Object.assign({},a),{method:g,path:h,query:i,defaultBaseURL:j}=f,k=this.buildURL(h,i,j);"timeout"in f&&((a,b)=>{if("number"!=typeof b||!Number.isInteger(b))throw new dJ(`${a} must be an integer`);if(b<0)throw new dJ(`${a} must be a positive integer`)})("timeout",f.timeout),f.timeout=null!=(c=f.timeout)?c:this.timeout;let{bodyHeaders:l,body:m}=this.buildBody({options:f}),n=await this.buildHeaders({options:a,method:g,bodyHeaders:l,retryCount:b});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:g,headers:n},f.signal&&{signal:f.signal}),globalThis.ReadableStream&&m instanceof globalThis.ReadableStream&&{duplex:"half"}),m&&{body:m}),null!=(d=this.fetchOptions)?d:{}),null!=(e=f.fetchOptions)?e:{}),url:k,timeout:f.timeout}}async buildHeaders({options:a,method:b,bodyHeaders:c,retryCount:d}){let e={};this.idempotencyHeader&&"get"!==b&&(a.idempotencyKey||(a.idempotencyKey=this.defaultIdempotencyKey()),e[this.idempotencyHeader]=a.idempotencyKey);let f=await this.authHeaders(a),g=ev([e,{Accept:"application/json","User-Agent":this.getUserAgent()},this._options.defaultHeaders,c,a.headers,f]);return this.validateHeaders(g),g.values}_makeAbort(a){return()=>a.abort()}buildBody({options:{body:a,headers:b}}){if(!a)return{bodyHeaders:void 0,body:void 0};let c=ev([b]);if(ArrayBuffer.isView(a)||a instanceof ArrayBuffer||a instanceof DataView||"string"==typeof a&&c.values.has("content-type")||globalThis.Blob&&a instanceof globalThis.Blob||a instanceof FormData||a instanceof URLSearchParams||globalThis.ReadableStream&&a instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:a};if("object"==typeof a&&(Symbol.asyncIterator in a||Symbol.iterator in a&&"next"in a&&"function"==typeof a.next)){let b;return{bodyHeaders:void 0,body:(b=Symbol.asyncIterator in a?a[Symbol.asyncIterator]():a[Symbol.iterator](),d$({start(){},async pull(a){let{done:c,value:d}=await b.next();c?a.close():a.enqueue(d)},async cancel(){var a;await (null==(a=b.return)?void 0:a.call(b))}}))}}return"object"==typeof a&&"application/x-www-form-urlencoded"===c.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(a)}:this.encoder({body:a,headers:c})}}ex.DEFAULT_TIMEOUT=6e4;class ey extends ex{constructor(){super(...arguments),this.interactions=new ec(this),this.webhooks=new ee(this)}}ey.GeminiNextGenAPIClient=ey,ey.GeminiNextGenAPIClientError=dJ,ey.APIError=dK,ey.APIConnectionError=dM,ey.APIConnectionTimeoutError=dN,ey.APIUserAbortError=dL,ey.NotFoundError=dR,ey.ConflictError=dS,ey.RateLimitError=dU,ey.BadRequestError=dO,ey.AuthenticationError=dP,ey.InternalServerError=dV,ey.PermissionDeniedError=dQ,ey.UnprocessableEntityError=dT,ey.toFile=d5,ey.Interactions=ec,ey.Webhooks=ee;let ez="x-goog-api-key",eA="https://www.googleapis.com/auth/cloud-platform";class eB{constructor(a){if(void 0!==a.apiKey){this.apiKey=a.apiKey;return}const b=function(a){let b;if(!a)return{scopes:[eA]};if((b=a).scopes){if("string"==typeof b.scopes&&b.scopes!==eA||Array.isArray(b.scopes)&&0>b.scopes.indexOf(eA))throw Error(`Invalid auth scopes. Scopes must include: ${eA}`)}else b.scopes=[eA];return b}(a.googleAuthOptions);this.googleAuth=new bx.GoogleAuth(b)}async addAuthHeaders(a,b){if(void 0!==this.apiKey){if(this.apiKey.startsWith("auth_tokens/"))throw Error("Ephemeral tokens are only supported by the live API.");this.addKeyHeader(a);return}return this.addGoogleAuthHeaders(a,b)}addKeyHeader(a){if(null===a.get(ez)){if(void 0===this.apiKey)throw Error("Trying to set API key header but apiKey is not set");a.append(ez,this.apiKey)}}async addGoogleAuthHeaders(a,b){if(void 0===this.googleAuth)throw Error("Trying to set google-auth headers but googleAuth is unset");for(let[c,d]of(await this.googleAuth.getRequestHeaders(b)))null===a.get(c)&&a.append(c,d)}}class eC{async download(a,b){if(a.downloadPath){let c=await eD(a,b);if(c instanceof bK){let b=(0,by.createWriteStream)(a.downloadPath);bA.Readable.fromWeb(c.responseInternal.body).pipe(b),await (0,bB.finished)(b)}else try{await (0,bz.writeFile)(a.downloadPath,c,{encoding:"base64"})}catch(b){throw Error(`Failed to write file to ${a.downloadPath}: ${b}`)}}}}async function eD(a,b){var c,d,e;let f=cy(a.file);if(void 0!==f)return await b.request({path:`files/${f}:download`,httpMethod:"GET",queryParams:{alt:"media"},httpOptions:null==(c=a.config)?void 0:c.httpOptions,abortSignal:null==(d=a.config)?void 0:d.abortSignal});if(cw(a.file)){let b=null==(e=a.file.video)?void 0:e.videoBytes;if("string"==typeof b)return b;throw Error("Failed to download generated video, Uri or videoBytes not found.")}if(cx(a.file)){let b=a.file.videoBytes;if("string"==typeof b)return b;throw Error("Failed to download video, Uri or videoBytes not found.")}throw Error("Unsupported file type")}class eE{create(a,b,c){return new eF(a,b,c)}}class eF{constructor(a,b,c){this.url=a,this.headers=b,this.callbacks=c}connect(){this.ws=new bC(this.url,{headers:this.headers}),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(a){if(void 0===this.ws)throw Error("WebSocket is not connected");this.ws.send(a)}close(){if(void 0===this.ws)throw Error("WebSocket is not connected");this.ws.close()}}function eG(a,b){let c={},d=bH(a,["sdkHttpResponse"]);null!=d&&bG(c,["sdkHttpResponse"],d);let e=bH(a,["name"]);null!=e&&bG(c,["name"],e);let f=bH(a,["state"]);null!=f&&bG(c,["state"],cv(f));let g=bH(a,["createTime"]);null!=g&&bG(c,["createTime"],g);let h=bH(a,["startTime"]);null!=h&&bG(c,["startTime"],h);let i=bH(a,["endTime"]);null!=i&&bG(c,["endTime"],i);let j=bH(a,["updateTime"]);null!=j&&bG(c,["updateTime"],j);let k=bH(a,["error"]);null!=k&&bG(c,["error"],k);let l=bH(a,["description"]);null!=l&&bG(c,["description"],l);let m=bH(a,["baseModel"]);null!=m&&bG(c,["baseModel"],m);let n=bH(a,["tunedModel"]);null!=n&&bG(c,["tunedModel"],n);let o=bH(a,["preTunedModel"]);null!=o&&bG(c,["preTunedModel"],o);let p=bH(a,["supervisedTuningSpec"]);null!=p&&bG(c,["supervisedTuningSpec"],p);let q=bH(a,["preferenceOptimizationSpec"]);null!=q&&bG(c,["preferenceOptimizationSpec"],q);let r=bH(a,["distillationSpec"]);null!=r&&bG(c,["distillationSpec"],r);let s=bH(a,["tuningDataStats"]);null!=s&&bG(c,["tuningDataStats"],s);let t=bH(a,["encryptionSpec"]);null!=t&&bG(c,["encryptionSpec"],t);let u=bH(a,["partnerModelTuningSpec"]);null!=u&&bG(c,["partnerModelTuningSpec"],u);let v=bH(a,["customBaseModel"]);null!=v&&bG(c,["customBaseModel"],v);let w=bH(a,["evaluateDatasetRuns"]);if(null!=w){let a=w;Array.isArray(a)&&(a=a.map(a=>a)),bG(c,["evaluateDatasetRuns"],a)}let x=bH(a,["experiment"]);null!=x&&bG(c,["experiment"],x);let y=bH(a,["fullFineTuningSpec"]);null!=y&&bG(c,["fullFineTuningSpec"],y);let z=bH(a,["labels"]);null!=z&&bG(c,["labels"],z);let A=bH(a,["outputUri"]);null!=A&&bG(c,["outputUri"],A);let B=bH(a,["pipelineJob"]);null!=B&&bG(c,["pipelineJob"],B);let C=bH(a,["serviceAccount"]);null!=C&&bG(c,["serviceAccount"],C);let D=bH(a,["tunedModelDisplayName"]);null!=D&&bG(c,["tunedModelDisplayName"],D);let E=bH(a,["tuningJobState"]);null!=E&&bG(c,["tuningJobState"],E);let F=bH(a,["veoTuningSpec"]);null!=F&&bG(c,["veoTuningSpec"],F);let G=bH(a,["distillationSamplingSpec"]);null!=G&&bG(c,["distillationSamplingSpec"],G);let H=bH(a,["tuningJobMetadata"]);return null!=H&&bG(c,["tuningJobMetadata"],H),c}function eH(a,b){let c={},d=bH(a,["gcsUri"]);null!=d&&bG(c,["validationDatasetUri"],d);let e=bH(a,["vertexDatasetResource"]);return null!=e&&bG(c,["validationDatasetUri"],e),c}class eI extends bE{constructor(a){super(),this.apiClient=a,this.list=async(a={})=>new cJ(bv.PAGED_ITEM_TUNING_JOBS,a=>this.listInternal(a),await this.listInternal(a),a),this.get=async a=>await this.getInternal(a),this.tune=async a=>{var b;if(this.apiClient.isVertexAI())if(a.baseModel.startsWith("projects/")){let c={tunedModelName:a.baseModel};(null==(b=a.config)?void 0:b.preTunedModelCheckpointId)&&(c.checkpointId=a.config.preTunedModelCheckpointId);let d=Object.assign(Object.assign({},a),{preTunedModel:c});return d.baseModel=void 0,await this.tuneInternal(d)}else{let b=Object.assign({},a);return await this.tuneInternal(b)}{let b=Object.assign({},a),c=await this.tuneMldevInternal(b),d="";return void 0!==c.metadata&&void 0!==c.metadata.tunedModel?d=c.metadata.tunedModel:void 0!==c.name&&c.name.includes("/operations/")&&(d=c.name.split("/operations/")[0]),{name:d,state:aW.JOB_STATE_QUEUED}}}}async getInternal(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d,e,h=(d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],e),d);return f=bF("{name}",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>eG(a))}{let b,c,h=(b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],c),b);return f=bF("{name}",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"GET",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d,e,f,g,h,i,j,k,l,m,n,o;return b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),null!=(d=bH(a,["name"]))&&bG(b,["name"],d),null!=(e=bH(a,["state"]))&&bG(b,["state"],cv(e)),null!=(f=bH(a,["createTime"]))&&bG(b,["createTime"],f),null!=(g=bH(a,["tuningTask","startTime"]))&&bG(b,["startTime"],g),null!=(h=bH(a,["tuningTask","completeTime"]))&&bG(b,["endTime"],h),null!=(i=bH(a,["updateTime"]))&&bG(b,["updateTime"],i),null!=(j=bH(a,["description"]))&&bG(b,["description"],j),null!=(k=bH(a,["baseModel"]))&&bG(b,["baseModel"],k),null!=(l=bH(a,["_self"]))&&bG(b,["tunedModel"],(m={},null!=(n=bH(l,["name"]))&&bG(m,["model"],n),null!=(o=bH(l,["name"]))&&bG(m,["endpoint"],o),m)),b})}}async listInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI()){let f,g,h,i,j,k=(f={},null!=(g=bH(a,["config"]))&&(h=bH(g,["pageSize"]),void 0!==f&&null!=h&&bG(f,["_query","pageSize"],h),i=bH(g,["pageToken"]),void 0!==f&&null!=i&&bG(f,["_query","pageToken"],i),j=bH(g,["filter"]),void 0!==f&&null!=j&&bG(f,["_query","filter"],j)),f);return d=bF("tuningJobs",k._url),e=k._query,delete k._url,delete k._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(k),httpMethod:"GET",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b=function(a){let b={},c=bH(a,["sdkHttpResponse"]);null!=c&&bG(b,["sdkHttpResponse"],c);let d=bH(a,["nextPageToken"]);null!=d&&bG(b,["nextPageToken"],d);let e=bH(a,["tuningJobs"]);if(null!=e){let a=e;Array.isArray(a)&&(a=a.map(a=>eG(a))),bG(b,["tuningJobs"],a)}return b}(a),c=new bX;return Object.assign(c,b),c})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async cancel(a){var b,c,d,e;let f="",g={};if(this.apiClient.isVertexAI()){let d,e,h=(d={},null!=(e=bH(a,["name"]))&&bG(d,["_url","name"],e),d);return f=bF("{name}:cancel",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new bY;return Object.assign(e,d),e})}{let b,c,h=(b={},null!=(c=bH(a,["name"]))&&bG(b,["_url","name"],c),b);return f=bF("{name}:cancel",h._url),g=h._query,delete h._url,delete h._query,this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(h),httpMethod:"POST",httpOptions:null==(d=a.config)?void 0:d.httpOptions,abortSignal:null==(e=a.config)?void 0:e.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d=(b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),b),e=new bY;return Object.assign(e,d),e})}}async tuneInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI()){let f,g,h,i,j,k=(f={},null!=(g=bH(a,["baseModel"]))&&bG(f,["baseModel"],g),null!=(h=bH(a,["preTunedModel"]))&&bG(f,["preTunedModel"],h),null!=(i=bH(a,["trainingDataset"]))&&function(a,b,c){let d=bH(c,["config","method"]);if(void 0===d&&(d="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===d){let c=bH(a,["gcsUri"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","trainingDatasetUri"],c)}else if("PREFERENCE_TUNING"===d){let c=bH(a,["gcsUri"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec","trainingDatasetUri"],c)}else if("DISTILLATION"===d){let c=bH(a,["gcsUri"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","promptDatasetUri"],c)}let e=bH(c,["config","method"]);if(void 0===e&&(e="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===e){let c=bH(a,["vertexDatasetResource"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","trainingDatasetUri"],c)}else if("PREFERENCE_TUNING"===e){let c=bH(a,["vertexDatasetResource"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec","trainingDatasetUri"],c)}else if("DISTILLATION"===e){let c=bH(a,["vertexDatasetResource"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","promptDatasetUri"],c)}if(void 0!==bH(a,["examples"]))throw Error("examples parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).")}(i,f,a),null!=(j=bH(a,["config"]))&&function(a,b,c){let d=bH(c,["config","method"]);if(void 0===d&&(d="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===d){let c=bH(a,["validationDataset"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec"],eH(c))}else if("PREFERENCE_TUNING"===d){let c=bH(a,["validationDataset"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec"],eH(c))}else if("DISTILLATION"===d){let c=bH(a,["validationDataset"]);void 0!==b&&null!=c&&bG(b,["distillationSpec"],eH(c))}let e=bH(a,["tunedModelDisplayName"]);void 0!==b&&null!=e&&bG(b,["tunedModelDisplayName"],e);let f=bH(a,["description"]);void 0!==b&&null!=f&&bG(b,["description"],f);let g=bH(c,["config","method"]);if(void 0===g&&(g="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===g){let c=bH(a,["epochCount"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","hyperParameters","epochCount"],c)}else if("PREFERENCE_TUNING"===g){let c=bH(a,["epochCount"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec","hyperParameters","epochCount"],c)}else if("DISTILLATION"===g){let c=bH(a,["epochCount"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","hyperParameters","epochCount"],c)}let h=bH(c,["config","method"]);if(void 0===h&&(h="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===h){let c=bH(a,["learningRateMultiplier"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],c)}else if("PREFERENCE_TUNING"===h){let c=bH(a,["learningRateMultiplier"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],c)}else if("DISTILLATION"===h){let c=bH(a,["learningRateMultiplier"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","hyperParameters","learningRateMultiplier"],c)}let i=bH(c,["config","method"]);if(void 0===i&&(i="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===i){let c=bH(a,["exportLastCheckpointOnly"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","exportLastCheckpointOnly"],c)}else if("PREFERENCE_TUNING"===i){let c=bH(a,["exportLastCheckpointOnly"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec","exportLastCheckpointOnly"],c)}else if("DISTILLATION"===i){let c=bH(a,["exportLastCheckpointOnly"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","exportLastCheckpointOnly"],c)}let j=bH(c,["config","method"]);if(void 0===j&&(j="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===j){let c=bH(a,["adapterSize"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","hyperParameters","adapterSize"],c)}else if("PREFERENCE_TUNING"===j){let c=bH(a,["adapterSize"]);void 0!==b&&null!=c&&bG(b,["preferenceOptimizationSpec","hyperParameters","adapterSize"],c)}else if("DISTILLATION"===j){let c=bH(a,["adapterSize"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","hyperParameters","adapterSize"],c)}let k=bH(c,["config","method"]);if(void 0===k&&(k="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===k){let c=bH(a,["tuningMode"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","tuningMode"],c)}else if("DISTILLATION"===k){let c=bH(a,["tuningMode"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","tuningMode"],c)}let l=bH(a,["customBaseModel"]);void 0!==b&&null!=l&&bG(b,["customBaseModel"],l);let m=bH(c,["config","method"]);if(void 0===m&&(m="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===m){let c=bH(a,["batchSize"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","hyperParameters","batchSize"],c)}else if("DISTILLATION"===m){let c=bH(a,["batchSize"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","hyperParameters","batchSize"],c)}let n=bH(c,["config","method"]);if(void 0===n&&(n="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===n){let c=bH(a,["learningRate"]);void 0!==b&&null!=c&&bG(b,["supervisedTuningSpec","hyperParameters","learningRate"],c)}else if("DISTILLATION"===n){let c=bH(a,["learningRate"]);void 0!==b&&null!=c&&bG(b,["distillationSpec","hyperParameters","learningRate"],c)}let o=bH(a,["labels"]);void 0!==b&&null!=o&&bG(b,["labels"],o);let p=bH(a,["beta"]);void 0!==b&&null!=p&&bG(b,["preferenceOptimizationSpec","hyperParameters","beta"],p);let q=bH(a,["baseTeacherModel"]);void 0!==b&&null!=q&&bG(b,["distillationSpec","baseTeacherModel"],q);let r=bH(a,["tunedTeacherModelSource"]);void 0!==b&&null!=r&&bG(b,["distillationSpec","tunedTeacherModelSource"],r);let s=bH(a,["sftLossWeightMultiplier"]);void 0!==b&&null!=s&&bG(b,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],s);let t=bH(a,["outputUri"]);void 0!==b&&null!=t&&bG(b,["outputUri"],t);let u=bH(a,["encryptionSpec"]);void 0!==b&&null!=u&&bG(b,["encryptionSpec"],u)}(j,f,a),f);return d=bF("tuningJobs",k._url),e=k._query,delete k._url,delete k._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(k),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>eG(a))}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async tuneMldevInternal(a){var b,c;let d="",e={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let f,g,h,i,j,k=(f={},null!=(g=bH(a,["baseModel"]))&&bG(f,["baseModel"],g),null!=(h=bH(a,["preTunedModel"]))&&bG(f,["preTunedModel"],h),null!=(i=bH(a,["trainingDataset"]))&&function(a){if(void 0!==bH(a,["gcsUri"]))throw Error("gcsUri parameter is not supported in Gemini API.");if(void 0!==bH(a,["vertexDatasetResource"]))throw Error("vertexDatasetResource parameter is not supported in Gemini API.");let b=bH(a,["examples"]);if(null!=b){let a=b;Array.isArray(a)&&(a=a.map(a=>a)),bG({},["examples","examples"],a)}}(i),null!=(j=bH(a,["config"]))&&function(a,b){if(void 0!==bH(a,["validationDataset"]))throw Error("validationDataset parameter is not supported in Gemini API.");let c=bH(a,["tunedModelDisplayName"]);if(void 0!==b&&null!=c&&bG(b,["displayName"],c),void 0!==bH(a,["description"]))throw Error("description parameter is not supported in Gemini API.");let d=bH(a,["epochCount"]);void 0!==b&&null!=d&&bG(b,["tuningTask","hyperparameters","epochCount"],d);let e=bH(a,["learningRateMultiplier"]);if(null!=e&&bG({},["tuningTask","hyperparameters","learningRateMultiplier"],e),void 0!==bH(a,["exportLastCheckpointOnly"]))throw Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(void 0!==bH(a,["preTunedModelCheckpointId"]))throw Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(void 0!==bH(a,["adapterSize"]))throw Error("adapterSize parameter is not supported in Gemini API.");if(void 0!==bH(a,["tuningMode"]))throw Error("tuningMode parameter is not supported in Gemini API.");if(void 0!==bH(a,["customBaseModel"]))throw Error("customBaseModel parameter is not supported in Gemini API.");let f=bH(a,["batchSize"]);void 0!==b&&null!=f&&bG(b,["tuningTask","hyperparameters","batchSize"],f);let g=bH(a,["learningRate"]);if(void 0!==b&&null!=g&&bG(b,["tuningTask","hyperparameters","learningRate"],g),void 0!==bH(a,["labels"]))throw Error("labels parameter is not supported in Gemini API.");if(void 0!==bH(a,["beta"]))throw Error("beta parameter is not supported in Gemini API.");if(void 0!==bH(a,["baseTeacherModel"]))throw Error("baseTeacherModel parameter is not supported in Gemini API.");if(void 0!==bH(a,["tunedTeacherModelSource"]))throw Error("tunedTeacherModelSource parameter is not supported in Gemini API.");if(void 0!==bH(a,["sftLossWeightMultiplier"]))throw Error("sftLossWeightMultiplier parameter is not supported in Gemini API.");if(void 0!==bH(a,["outputUri"]))throw Error("outputUri parameter is not supported in Gemini API.");if(void 0!==bH(a,["encryptionSpec"]))throw Error("encryptionSpec parameter is not supported in Gemini API.")}(j,f),f);return d=bF("tunedModels",k._url),e=k._query,delete k._url,delete k._query,this.apiClient.request({path:d,queryParams:e,body:JSON.stringify(k),httpMethod:"POST",httpOptions:null==(b=a.config)?void 0:b.httpOptions,abortSignal:null==(c=a.config)?void 0:c.abortSignal}).then(a=>a.json().then(b=>(b.sdkHttpResponse={headers:a.headers},b))).then(a=>{let b,c,d,e,f,g;return b={},null!=(c=bH(a,["sdkHttpResponse"]))&&bG(b,["sdkHttpResponse"],c),null!=(d=bH(a,["name"]))&&bG(b,["name"],d),null!=(e=bH(a,["metadata"]))&&bG(b,["metadata"],e),null!=(f=bH(a,["done"]))&&bG(b,["done"],f),null!=(g=bH(a,["error"]))&&bG(b,["error"],g),b})}}}let eJ="x-goog-upload-status";async function eK(a,b,c,d){var e;let f=await eM(a,b,c,d),g=await (null==f?void 0:f.json());if((null==(e=null==f?void 0:f.headers)?void 0:e[eJ])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");return g.file}async function eL(a,b,c,d){var e;let f=await eM(a,b,c,d),g=await (null==f?void 0:f.json());if((null==(e=null==f?void 0:f.headers)?void 0:e[eJ])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");let h=bJ(g),i=new ca;return Object.assign(i,h),i}async function eM(a,b,c,d){var e,f,g;let h=b,i=(null==d?void 0:d.baseUrl)||(null==(e=c.clientOptions.httpOptions)?void 0:e.baseUrl);if(i){let a=new URL(i),c=new URL(b);c.protocol=a.protocol,c.host=a.host,c.port=a.port,h=c.toString()}let j=0,k=0,l=new bK(new Response),m="upload";for(j=a.size;k<j;){let b=Math.min(8388608,j-k),e=a.slice(k,k+b);k+b>=j&&(m+=", finalize");let i=0,n=1e3;for(;i<3;){let a=Object.assign(Object.assign({},(null==d?void 0:d.headers)||{}),{"X-Goog-Upload-Command":m,"X-Goog-Upload-Offset":String(k),"Content-Length":String(b)});if(null==(f=null==(l=await c.request({path:"",body:e,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},d),{apiVersion:"",baseUrl:h,headers:a})}))?void 0:l.headers)?void 0:f[eJ])break;i++,await eO(n),n*=2}if(k+=b,(null==(g=null==l?void 0:l.headers)?void 0:g[eJ])!=="active")break;if(j<=k)throw Error("All content has been uploaded, but the upload status is not finalized.")}return l}async function eN(a){return{size:a.size,type:a.type}}function eO(a){return new Promise(b=>setTimeout(b,a))}class eP{async stat(a){let b={size:0,type:void 0};return"string"==typeof a?(b.size=(await bz.stat(a)).size,b.type=this.inferMimeType(a),b):await eN(a)}async upload(a,b,c,d){return"string"==typeof a?await this.uploadFileFromPath(a,b,c,d):eK(a,b,c,d)}async uploadToFileSearchStore(a,b,c,d){return"string"==typeof a?await this.uploadFileToFileSearchStoreFromPath(a,b,c,d):eL(a,b,c,d)}inferMimeType(a){return({aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",kml:"application/vnd.google-earth.kml+xml",kmz:"application/vnd.google-earth.kmz+xml",mjs:"text/javascript",mp3:"audio/mpeg",mp4:"video/mp4",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/x-httpd-php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3g2":"video/3gpp2","7z":"application/x-7z-compressed"})[a.slice(a.lastIndexOf(".")+1).toLowerCase()]}async uploadFileFromPath(a,b,c,d){var e;let f=await this.uploadFileFromPathInternal(a,b,c,d),g=await (null==f?void 0:f.json());if((null==(e=null==f?void 0:f.headers)?void 0:e[eJ])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");return g.file}async uploadFileToFileSearchStoreFromPath(a,b,c,d){var e;let f=await this.uploadFileFromPathInternal(a,b,c,d),g=await (null==f?void 0:f.json());if((null==(e=null==f?void 0:f.headers)?void 0:e[eJ])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");let h=bJ(g),i=new ca;return Object.assign(i,h),i}async uploadFileFromPathInternal(a,b,c,d){var e,f,g;let h,i=b,j=(null==d?void 0:d.baseUrl)||(null==(e=c.clientOptions.httpOptions)?void 0:e.baseUrl);if(j){let a=new URL(j),c=new URL(b);c.protocol=a.protocol,c.host=a.host,c.port=a.port,i=c.toString()}let k=0,l=0,m=new bK(new Response),n="upload",o=bD.basename(a);try{if(!(h=await bz.open(a,"r")))throw Error("Failed to open file");for(k=(await h.stat()).size;l<k;){let a=Math.min(8388608,k-l);l+a>=k&&(n+=", finalize");let b=new Uint8Array(a),{bytesRead:e}=await h.read(b,0,a,l);if(e!==a)throw Error(`Failed to read ${a} bytes from file at offset ${l}. bytes actually read: ${e}`);let j=new Blob([b]),p=0,q=1e3;for(;p<3;){let a=Object.assign(Object.assign({},(null==d?void 0:d.headers)||{}),{"X-Goog-Upload-Command":n,"X-Goog-Upload-Offset":String(l),"Content-Length":String(e),"X-Goog-Upload-File-Name":o});if(null==(f=null==(m=await c.request({path:"",body:j,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},d),{apiVersion:"",baseUrl:i,headers:a})}))?void 0:m.headers)?void 0:f[eJ])break;p++,await eO(q),q*=2}if(l+=e,(null==(g=null==m?void 0:m.headers)?void 0:g[eJ])!=="active")break;if(k<=l)throw Error("All content has been uploaded, but the upload status is not finalized.")}return m}finally{h&&await h.close()}}}class eQ extends cX{async registerFiles(a){if("u"<typeof process||!process.versions||!process.versions.node)throw Error("registerFiles is only supported in Node.js environments.");let b=a.auth,c=await b.getRequestHeaders(),d=a.config||{},e=d.httpOptions||{},f=Object.assign({},e.headers||{});if(c)if("function"==typeof c[Symbol.iterator])for(let[a,b]of c)f[a]=b;else for(let[a,b]of Object.entries(c))f[a]=b;return this._registerFiles({uris:a.uris,config:Object.assign(Object.assign({},d),{httpOptions:Object.assign(Object.assign({},e),{headers:f})})})}}class eR{getNextGenClient(){var a;let b=this.httpOptions;return void 0===this._nextGenClient&&(this._nextGenClient=new ey({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==b?void 0:b.timeout,maxRetries:null==(a=null==b?void 0:b.retryOptions)?void 0:a.attempts})),(null==b?void 0:b.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored."),this._nextGenClient}get interactions(){return void 0!==this._interactions||(console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."),this._interactions=this.getNextGenClient().interactions),this._interactions}get webhooks(){return void 0!==this._webhooks||(this._webhooks=this.getNextGenClient().webhooks),this._webhooks}constructor(a){var b,c,d,e;if((a.project||a.location)&&a.apiKey)throw Error("Project/location and API key are mutually exclusive in the client initializer.");this.vertexai=function(a){var b;if(void 0!==a.enterprise||void 0!==a.vertexai){if(void 0!==a.enterprise&&void 0!==a.vertexai&&a.enterprise!==a.vertexai)throw Error("enterprise and vertexAI flags have conflicting values, please set enterprise value only.");return null!=(b=a.enterprise)?b:a.vertexai}let c=eS("GOOGLE_GENAI_USE_ENTERPRISE"),d=eS("GOOGLE_GENAI_USE_VERTEXAI"),e=eT(c),f=eT(d);return(void 0!==c&&void 0!==d&&e!==f&&console.warn("Warning: Both GOOGLE_GENAI_USE_ENTERPRISE and GOOGLE_GENAI_USE_VERTEXAI are set with conflicting values. The value of GOOGLE_GENAI_USE_ENTERPRISE will be used."),void 0!==c)?e:void 0!==d&&f}(a);const h=function(){let a=eS("GOOGLE_API_KEY"),b=eS("GEMINI_API_KEY");return a&&b&&console.warn("Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY."),a||b||void 0}(),i=eS("GOOGLE_CLOUD_PROJECT"),j=eS("GOOGLE_CLOUD_LOCATION");this.apiKey=null!=(b=a.apiKey)?b:h,this.project=null!=(c=a.project)?c:i,this.location=null!=(d=a.location)?d:j,this.vertexai||this.apiKey||console.warn("API key should be set when using the Gemini API."),this.vertexai&&((null==(e=a.googleAuthOptions)?void 0:e.credentials)&&(console.debug("The user provided Google Cloud credentials will take precedence over the API key from the environment variable."),this.apiKey=void 0),(i||j)&&a.apiKey?(console.debug("The user provided Vertex AI API key will take precedence over the project/location from the environment variables."),this.project=void 0,this.location=void 0):(a.project||a.location)&&h?(console.debug("The user provided project/location will take precedence over the API key from the environment variables."),this.apiKey=void 0):(i||j)&&h&&(console.debug("The project/location from the environment variables will take precedence over the API key from the environment variables."),this.apiKey=void 0),this.location||this.apiKey||(this.location="global"));const k=function(a,b,c,d){return(null==a?void 0:a.baseUrl)?a.baseUrl:b?null!=g?g:c:null!=f?f:d}(a.httpOptions,this.vertexai,eS("GOOGLE_VERTEX_BASE_URL"),eS("GOOGLE_GEMINI_BASE_URL"));k&&(a.httpOptions?a.httpOptions.baseUrl=k:a.httpOptions={baseUrl:k}),this.apiVersion=a.apiVersion,this.httpOptions=a.httpOptions;const l=new eB({apiKey:this.apiKey,googleAuthOptions:a.googleAuthOptions});this.apiClient=new dj({auth:l,project:this.project,location:this.location,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/"+process.version,uploader:new eP,downloader:new eC}),this.models=new dA(this.apiClient),this.live=new dt(this.apiClient,l,new eE),this.batches=new cK(this.apiClient),this.chats=new cU(this.models,this.apiClient),this.caches=new cN(this.apiClient),this.files=new eQ(this.apiClient),this.operations=new dB(this.apiClient),this.authTokens=new dD(this.apiClient),this.tunings=new eI(this.apiClient),this.fileSearchStores=new dF(this.apiClient)}}function eS(a){var b,c,d;return null!=(d=null==(c=null==(b=null==process?void 0:process.env)?void 0:b[a])?void 0:c.trim())?d:void 0}function eT(a){return void 0!==a&&"true"===a.toLowerCase()}},55723:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.CertificateSubjectTokenSupplier=b.InvalidConfigurationError=b.CertificateSourceUnavailableError=b.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=void 0;let d=c(90852),e=c(29021),f=c(55511),g=c(55591);b.CERTIFICATE_CONFIGURATION_ENV_VARIABLE="GOOGLE_API_CERTIFICATE_CONFIG";class h extends Error{constructor(a){super(a),this.name="CertificateSourceUnavailableError"}}b.CertificateSourceUnavailableError=h;class i extends Error{constructor(a){super(a),this.name="InvalidConfigurationError"}}b.InvalidConfigurationError=i;class j{certificateConfigPath;trustChainPath;cert;key;constructor(a){if(!a.useDefaultCertificateConfig&&!a.certificateConfigLocation)throw new i("Either `useDefaultCertificateConfig` must be true or a `certificateConfigLocation` must be provided.");if(a.useDefaultCertificateConfig&&a.certificateConfigLocation)throw new i("Both `useDefaultCertificateConfig` and `certificateConfigLocation` cannot be provided.");this.trustChainPath=a.trustChainPath,this.certificateConfigPath=a.certificateConfigLocation??""}async createMtlsHttpsAgent(){if(!this.key||!this.cert)throw new i("Cannot create mTLS Agent with missing certificate or key");return new g.Agent({key:this.key,cert:this.cert})}async getSubjectToken(){this.certificateConfigPath=await this.#q();let{certPath:a,keyPath:b}=await this.#r();return{cert:this.cert,key:this.key}=await this.#s(a,b),await this.#t(this.cert)}async #q(){let a=this.certificateConfigPath;if(a){if(await (0,d.isValidFile)(a))return a;throw new h(`Provided certificate config path is invalid: ${a}`)}let c=process.env[b.CERTIFICATE_CONFIGURATION_ENV_VARIABLE];if(c){if(await (0,d.isValidFile)(c))return c;throw new h(`Path from environment variable "${b.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" is invalid: ${c}`)}let e=(0,d.getWellKnownCertificateConfigFileLocation)();if(await (0,d.isValidFile)(e))return e;throw new h(`Could not find certificate configuration file. Searched override path, the "${b.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" env var, and the gcloud path (${e}).`)}async #r(){let a,b=this.certificateConfigPath;try{a=await e.promises.readFile(b,"utf8")}catch(a){throw new h(`Failed to read certificate config file at: ${b}`)}try{let c=JSON.parse(a),d=c?.cert_configs?.workload?.cert_path,e=c?.cert_configs?.workload?.key_path;if(!d||!e)throw new i(`Certificate config file (${b}) is missing required "cert_path" or "key_path" in the workload config.`);return{certPath:d,keyPath:e}}catch(a){if(a instanceof i)throw a;throw new i(`Failed to parse certificate config from ${b}: ${a.message}`)}}async #s(a,b){let c,d;try{c=await e.promises.readFile(a),new f.X509Certificate(c)}catch(c){let b=c instanceof Error?c.message:String(c);throw new h(`Failed to read certificate file at ${a}: ${b}`)}try{d=await e.promises.readFile(b),(0,f.createPrivateKey)(d)}catch(c){let a=c instanceof Error?c.message:String(c);throw new h(`Failed to read private key file at ${b}: ${a}`)}return{cert:c,key:d}}async #t(a){let b=new f.X509Certificate(a);if(!this.trustChainPath)return JSON.stringify([b.raw.toString("base64")]);try{let a,c=((await e.promises.readFile(this.trustChainPath,"utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g)??[]).map((a,b)=>{try{return new f.X509Certificate(a)}catch(c){let a=c instanceof Error?c.message:String(c);throw new i(`Failed to parse certificate at index ${b} in trust chain file ${this.trustChainPath}: ${a}`)}}),d=c.findIndex(a=>b.raw.equals(a.raw));if(-1===d)a=[b,...c];else if(0===d)a=c;else throw new i(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${d}).`);return JSON.stringify(a.map(a=>a.raw.toString("base64")))}catch(b){if(b instanceof i)throw b;let a=b instanceof Error?b.message:String(b);throw new h(`Failed to process certificate chain from ${this.trustChainPath}: ${a}`)}}}b.CertificateSubjectTokenSupplier=j},57827:(a,b,c)=>{"use strict";let d=c(94735),e=c(81630),{Duplex:f}=c(27910),{createHash:g}=c(55511),h=c(3969),i=c(49478),j=c(7686),k=c(27879),{CLOSE_TIMEOUT:l,GUID:m,kWebSocket:n}=c(89721),o=/^[+/0-9A-Za-z]{22}==$/;class p extends d{constructor(a,b){if(super(),null==(a={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:l,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:k,...a}).port&&!a.server&&!a.noServer||null!=a.port&&(a.server||a.noServer)||a.server&&a.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=a.port?(this._server=e.createServer((a,b)=>{let c=e.STATUS_CODES[426];b.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),b.end(c)}),this._server.listen(a.port,a.host,a.backlog,b)):a.server&&(this._server=a.server),this._server){const a=this.emit.bind(this,"connection");this._removeListeners=function(a,b){for(let c of Object.keys(b))a.on(c,b[c]);return function(){for(let c of Object.keys(b))a.removeListener(c,b[c])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(b,c,d)=>{this.handleUpgrade(b,c,d,a)}})}!0===a.perMessageDeflate&&(a.perMessageDeflate={}),a.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=a,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(a){if(2===this._state){a&&this.once("close",()=>{a(Error("The server is not running"))}),process.nextTick(q,this);return}if(a&&this.once("close",a),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(q,this);else{let a=this._server;this._removeListeners(),this._removeListeners=this._server=null,a.close(()=>{q(this)})}}shouldHandle(a){if(this.options.path){let b=a.url.indexOf("?");if((-1!==b?a.url.slice(0,b):a.url)!==this.options.path)return!1}return!0}handleUpgrade(a,b,c,d){b.on("error",r);let e=a.headers["sec-websocket-key"],f=a.headers.upgrade,g=+a.headers["sec-websocket-version"];if("GET"!==a.method)return void t(this,a,b,405,"Invalid HTTP method");if(void 0===f||"websocket"!==f.toLowerCase())return void t(this,a,b,400,"Invalid Upgrade header");if(void 0===e||!o.test(e))return void t(this,a,b,400,"Missing or invalid Sec-WebSocket-Key header");if(13!==g&&8!==g)return void t(this,a,b,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});if(!this.shouldHandle(a))return void s(b,400);let k=a.headers["sec-websocket-protocol"],l=new Set;if(void 0!==k)try{l=j.parse(k)}catch(c){t(this,a,b,400,"Invalid Sec-WebSocket-Protocol header");return}let m=a.headers["sec-websocket-extensions"],n={};if(this.options.perMessageDeflate&&void 0!==m){let c=new i({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let a=h.parse(m);a[i.extensionName]&&(c.accept(a[i.extensionName]),n[i.extensionName]=c)}catch(c){t(this,a,b,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:a.headers[`${8===g?"sec-websocket-origin":"origin"}`],secure:!!(a.socket.authorized||a.socket.encrypted),req:a};if(2===this.options.verifyClient.length)return void this.options.verifyClient(f,(f,g,h,i)=>{if(!f)return s(b,g||401,h,i);this.completeUpgrade(n,e,l,a,b,c,d)});if(!this.options.verifyClient(f))return s(b,401)}this.completeUpgrade(n,e,l,a,b,c,d)}completeUpgrade(a,b,c,d,e,f,j){if(!e.readable||!e.writable)return e.destroy();if(e[n])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return s(e,503);let k=g("sha1").update(b+m).digest("base64"),l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${k}`],o=new this.options.WebSocket(null,void 0,this.options);if(c.size){let a=this.options.handleProtocols?this.options.handleProtocols(c,d):c.values().next().value;a&&(l.push(`Sec-WebSocket-Protocol: ${a}`),o._protocol=a)}if(a[i.extensionName]){let b=a[i.extensionName].params,c=h.format({[i.extensionName]:[b]});l.push(`Sec-WebSocket-Extensions: ${c}`),o._extensions=a}this.emit("headers",l,d),e.write(l.concat("\r\n").join("\r\n")),e.removeListener("error",r),o.setSocket(e,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(o),o.on("close",()=>{this.clients.delete(o),this._shouldEmitClose&&!this.clients.size&&process.nextTick(q,this)})),j(o,d)}}function q(a){a._state=2,a.emit("close")}function r(){this.destroy()}function s(a,b,c,d){c=c||e.STATUS_CODES[b],d={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(c),...d},a.once("finish",a.destroy),a.end(`HTTP/1.1 ${b} ${e.STATUS_CODES[b]}\r
|
|
8
|
+
`+Object.keys(d).map(a=>`${a}: ${d[a]}`).join("\r\n")+"\r\n\r\n"+c)}function t(a,b,c,d,e,f){if(a.listenerCount("wsClientError")){let d=Error(e);Error.captureStackTrace(d,t),a.emit("wsClientError",d,c,b)}else s(c,d,e,f)}a.exports=p},58672:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.getToken=e;let d=c(20244);async function e(a){if(!a.transporter)throw Error("No transporter set.");try{let b={method:"POST",url:"https://oauth2.googleapis.com/token",data:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:(0,d.getJwsSign)(a)}),responseType:"json",retryConfig:{httpMethodsToRetry:["POST"]}};return(await a.transporter.request(b)).data}catch(b){let a=b.response?.data;throw a?.error&&(b.message=`${a.error}: ${a.error_description}`),b}}},59968:a=>{"use strict";a.exports=JSON.parse('{"name":"google-auth-library","version":"10.6.2","author":"Google Inc.","description":"Google APIs Authentication Client Library for Node.js","engines":{"node":">=18"},"main":"./build/src/index.js","types":"./build/src/index.d.ts","repository":{"type":"git","directory":"packages/google-auth-library-nodejs","url":"https://github.com/googleapis/google-cloud-node-core.git"},"keywords":["google","api","google apis","client","client library"],"dependencies":{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11","gaxios":"^7.1.4","gcp-metadata":"8.1.2","google-logging-utils":"1.1.3","jws":"^4.0.0"},"devDependencies":{"@types/base64-js":"^1.2.5","@types/jws":"^3.1.0","@types/mocha":"^10.0.10","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","assert-rejects":"^1.0.0","c8":"^10.1.3","codecov":"^3.8.3","gts":"^6.0.2","is-docker":"^3.0.0","jsdoc":"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0","karma":"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1","keypair":"^1.0.4","mocha":"^11.1.0","mv":"^2.1.1","ncp":"^2.0.0","nock":"^14.0.5","null-loader":"^4.0.1","puppeteer":"^24.0.0","sinon":"^21.0.0","ts-loader":"^9.5.2","typescript":"5.8.3","webpack":"^5.97.1","webpack-cli":"^6.0.1"},"files":["build/src","!build/src/**/*.map"],"scripts":{"test":"c8 mocha build/test","clean":"gts clean","prepare":"npm run compile","lint":"gts check --no-inline-config","compile":"tsc -p .","fix":"gts fix","pretest":"npm run compile -- --sourceMap","docs":"jsdoc -c .jsdoc.js","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap","webpack":"webpack","browser-test":"karma start","docs-test":"echo \'disabled until linkinator is fixed\'","predocs-test":"npm run docs","prelint":"cd samples; npm link ../; npm install"},"license":"Apache-2.0","homepage":"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/google-auth-library-nodejs"}')},61721:function(a,b,c){"use strict";var d=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),e=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||d(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),b.createCrypto=function(){return h()?new f.BrowserCrypto:new g.NodeCrypto},b.hasBrowserCrypto=h;let f=c(17144),g=c(16838);function h(){return"u">typeof window&&void 0!==window.crypto&&void 0!==window.crypto.subtle}e(c(90337),b)},62350:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.ErrorWithCode=void 0;class c extends Error{code;constructor(a,b){super(a),this.code=b}}b.ErrorWithCode=c},62758:(a,b,c)=>{var d=c(77978),e=c(88218);b.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],b.sign=d.sign,b.verify=e.verify,b.decode=e.decode,b.isValid=e.isValid,b.createSign=function(a){return new d(a)},b.createVerify=function(a){return new e(a)}},63133:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.AwsRequestSigner=void 0;let d=c(51596),e=c(61721),f="AWS4-HMAC-SHA256";class g{getCredentials;region;crypto;constructor(a,b){this.getCredentials=a,this.region=b,this.crypto=(0,e.createCrypto)()}async getRequestOptions(a){if(!a.url)throw RangeError('"url" is required in "amzOptions"');let b="object"==typeof a.data?JSON.stringify(a.data):a.data,c=a.url,e=a.method||"GET",f=a.body||b,g=a.headers,h=await this.getCredentials(),i=new URL(c);if("string"!=typeof f&&void 0!==f)throw TypeError(`'requestPayload' is expected to be a string if provided. Got: ${f}`);let k=await j({crypto:this.crypto,host:i.host,canonicalUri:i.pathname,canonicalQuerystring:i.search.slice(1),method:e,region:this.region,securityCredentials:h,requestPayload:f,additionalAmzHeaders:g}),l=d.Gaxios.mergeHeaders(k.amzDate?{"x-amz-date":k.amzDate}:{},{authorization:k.authorizationHeader,host:i.host},g||{});h.token&&d.Gaxios.mergeHeaders(l,{"x-amz-security-token":h.token});let m={url:c,method:e,headers:l};return void 0!==f&&(m.body=f),m}}async function h(a,b,c){return await a.signWithHmacSha256(b,c)}async function i(a,b,c,d,e){let f=await h(a,`AWS4${b}`,c),g=await h(a,f,d),i=await h(a,g,e);return await h(a,i,"aws4_request")}async function j(a){let b=d.Gaxios.mergeHeaders(a.additionalAmzHeaders),c=a.requestPayload||"",g=a.host.split(".")[0],j=new Date,k=j.toISOString().replace(/[-:]/g,"").replace(/\.[0-9]+/,""),l=j.toISOString().replace(/[-]/g,"").replace(/T.*/,"");a.securityCredentials.token&&b.set("x-amz-security-token",a.securityCredentials.token);let m=d.Gaxios.mergeHeaders({host:a.host},b.has("date")?{}:{"x-amz-date":k},b),n="",o=[...m.keys()].sort();o.forEach(a=>{n+=`${a}:${m.get(a)}
|
|
9
|
+
`});let p=o.join(";"),q=await a.crypto.sha256DigestHex(c),r=`${a.method.toUpperCase()}
|
|
10
|
+
${a.canonicalUri}
|
|
11
|
+
${a.canonicalQuerystring}
|
|
12
|
+
${n}
|
|
13
|
+
${p}
|
|
14
|
+
${q}`,s=`${l}/${a.region}/${g}/aws4_request`,t=`${f}
|
|
15
|
+
${k}
|
|
16
|
+
${s}
|
|
17
|
+
`+await a.crypto.sha256DigestHex(r),u=await i(a.crypto,a.securityCredentials.secretAccessKey,l,a.region,g),v=await h(a.crypto,u,t),w=`${f} Credential=${a.securityCredentials.accessKeyId}/${s}, SignedHeaders=${p}, Signature=${(0,e.fromArrayBufferToHex)(v)}`;return{amzDate:b.has("date")?void 0:k,authorizationHeader:w,canonicalQuerystring:a.canonicalQuerystring}}b.AwsRequestSigner=g},64762:(a,b,c)=>{"use strict";var d=c(79428).Buffer,e=c(79428).SlowBuffer;function f(a,b){if(!d.isBuffer(a)||!d.isBuffer(b)||a.length!==b.length)return!1;for(var c=0,e=0;e<a.length;e++)c|=a[e]^b[e];return 0===c}a.exports=f,f.install=function(){d.prototype.equal=e.prototype.equal=function(a){return f(this,a)}};var g=d.prototype.equal,h=e.prototype.equal;f.restore=function(){d.prototype.equal=g,e.prototype.equal=h}},64876:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.BaseExternalAccountClient=b.CLOUD_RESOURCE_MANAGER=b.EXTERNAL_ACCOUNT_TYPE=b.EXPIRATION_TIME_OFFSET=void 0;let d=c(51596),e=c(27910),f=c(25072),g=c(32075),h=c(90852),i=c(1486),j="https://www.googleapis.com/auth/cloud-platform";b.EXPIRATION_TIME_OFFSET=3e5,b.EXTERNAL_ACCOUNT_TYPE="external_account",b.CLOUD_RESOURCE_MANAGER="https://cloudresourcemanager.googleapis.com/v1/projects/";class k extends f.AuthClient{scopes;projectNumber;audience;subjectTokenType;stsCredential;clientAuth;credentialSourceType;cachedAccessToken;serviceAccountImpersonationUrl;serviceAccountImpersonationLifetime;workforcePoolUserProject;configLifetimeRequested;tokenUrl;cloudResourceManagerURL;supplierContext;#u=null;constructor(a){super(a);const c=(0,h.originalOrCamelOptions)(a),d=c.get("type");if(d&&d!==b.EXTERNAL_ACCOUNT_TYPE)throw Error(`Expected "${b.EXTERNAL_ACCOUNT_TYPE}" type but received "${a.type}"`);const e=c.get("client_id"),f=c.get("client_secret");this.tokenUrl=c.get("token_url")??"https://sts.{universeDomain}/v1/token".replace("{universeDomain}",this.universeDomain);const i=c.get("subject_token_type"),k=c.get("workforce_pool_user_project"),l=c.get("service_account_impersonation_url"),m=c.get("service_account_impersonation"),n=(0,h.originalOrCamelOptions)(m).get("token_lifetime_seconds");this.cloudResourceManagerURL=new URL(c.get("cloud_resource_manager_url")||`https://cloudresourcemanager.${this.universeDomain}/v1/projects/`),e&&(this.clientAuth={confidentialClientType:"basic",clientId:e,clientSecret:f}),this.stsCredential=new g.StsCredentials({tokenExchangeEndpoint:this.tokenUrl,clientAuthentication:this.clientAuth}),this.scopes=c.get("scopes")||[j],this.cachedAccessToken=null,this.audience=c.get("audience"),this.subjectTokenType=i,this.workforcePoolUserProject=k;const o=RegExp("//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+");if(this.workforcePoolUserProject&&!this.audience.match(o))throw Error("workforcePoolUserProject should not be set for non-workforce pool credentials.");this.serviceAccountImpersonationUrl=l,this.serviceAccountImpersonationLifetime=n,this.serviceAccountImpersonationLifetime?this.configLifetimeRequested=!0:(this.configLifetimeRequested=!1,this.serviceAccountImpersonationLifetime=3600),this.projectNumber=this.getProjectNumber(this.audience),this.supplierContext={audience:this.audience,subjectTokenType:this.subjectTokenType,transporter:this.transporter}}getServiceAccountEmail(){if(this.serviceAccountImpersonationUrl){if(this.serviceAccountImpersonationUrl.length>256)throw RangeError(`URL is too long: ${this.serviceAccountImpersonationUrl}`);let a=/serviceAccounts\/(?<email>[^:]+):generateAccessToken$/.exec(this.serviceAccountImpersonationUrl);return a?.groups?.email||null}return null}setCredentials(a){super.setCredentials(a),this.cachedAccessToken=a}async getAccessToken(){return(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let a=await this.getAccessToken(),b=new Headers({authorization:`Bearer ${a.token}`});return this.addSharedMetadataHeaders(b)}request(a,b){if(!b)return this.requestAsync(a);this.requestAsync(a).then(a=>b(null,a),a=>b(a,a.response))}async getProjectId(){let a=this.projectNumber||this.workforcePoolUserProject;if(this.projectId)return this.projectId;if(a){let b=await this.getRequestHeaders(),c={...k.RETRY_CONFIG,headers:b,url:`${this.cloudResourceManagerURL.toString()}${a}`,responseType:"json"};f.AuthClient.setMethodName(c,"getProjectId");let d=await this.transporter.request(c);return this.projectId=d.data.projectId,this.projectId}return null}async requestAsync(a,b=!1){let c;try{let b=await this.getRequestHeaders();a.headers=d.Gaxios.mergeHeaders(a.headers),this.addUserProjectAndAuthHeaders(a.headers,b),c=await this.transporter.request(a)}catch(d){let c=d.response;if(c){let d=c.status,f=c.config.data instanceof e.Readable;if(!b&&(401===d||403===d)&&!f&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(a,!0)}throw d}return c}async refreshAccessTokenAsync(){this.#u=this.#u||this.#v();try{return await this.#u}finally{this.#u=null}}async #v(){let a=await this.retrieveSubjectToken(),b={grantType:"urn:ietf:params:oauth:grant-type:token-exchange",audience:this.audience,requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:a,subjectTokenType:this.subjectTokenType,scope:this.serviceAccountImpersonationUrl?[j]:this.getScopesArray()},c=!this.clientAuth&&this.workforcePoolUserProject?{userProject:this.workforcePoolUserProject}:void 0,d=new Headers({"x-goog-api-client":this.getMetricsHeaderValue()}),e=await this.stsCredential.exchangeToken(b,d,c);return this.serviceAccountImpersonationUrl?this.cachedAccessToken=await this.getImpersonatedAccessToken(e.access_token):e.expires_in?this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+1e3*e.expires_in,res:e.res}:this.cachedAccessToken={access_token:e.access_token,res:e.res},this.credentials={},Object.assign(this.credentials,this.cachedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedAccessToken.expiry_date,access_token:this.cachedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedAccessToken}getProjectNumber(a){let b=a.match(/\/projects\/([^/]+)/);return b?b[1]:null}async getImpersonatedAccessToken(a){let b={...k.RETRY_CONFIG,url:this.serviceAccountImpersonationUrl,method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${a}`},data:{scope:this.getScopesArray(),lifetime:this.serviceAccountImpersonationLifetime+"s"},responseType:"json"};f.AuthClient.setMethodName(b,"getImpersonatedAccessToken");let c=await this.transporter.request(b),d=c.data;return{access_token:d.accessToken,expiry_date:new Date(d.expireTime).getTime(),res:c}}isExpired(a){let b=new Date().getTime();return!!a.expiry_date&&b>=a.expiry_date-this.eagerRefreshThresholdMillis}getScopesArray(){return"string"==typeof this.scopes?[this.scopes]:this.scopes||[j]}getMetricsHeaderValue(){let a=process.version.replace(/^v/,""),b=void 0!==this.serviceAccountImpersonationUrl,c=this.credentialSourceType?this.credentialSourceType:"unknown";return`gl-node/${a} auth/${i.pkg.version} google-byoid-sdk source/${c} sa-impersonation/${b} config-lifetime/${this.configLifetimeRequested}`}getTokenUrl(){return this.tokenUrl}}b.BaseExternalAccountClient=k},65891:(a,b,c)=>{var d=null;let e=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,f=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;a.exports=function(a){"use strict";var b={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(null!=a){if(!0===a.strict&&(b.strict=!0),!0===a.storeAsString&&(b.storeAsString=!0),b.alwaysParseAsBig=!0===a.alwaysParseAsBig&&a.alwaysParseAsBig,b.useNativeBigInt=!0===a.useNativeBigInt&&a.useNativeBigInt,void 0!==a.constructorAction)if("error"===a.constructorAction||"ignore"===a.constructorAction||"preserve"===a.constructorAction)b.constructorAction=a.constructorAction;else throw Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${a.constructorAction}`);if(void 0!==a.protoAction)if("error"===a.protoAction||"ignore"===a.protoAction||"preserve"===a.protoAction)b.protoAction=a.protoAction;else throw Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${a.protoAction}`)}var g,h,i,j,k={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:" "},l=function(a){throw{name:"SyntaxError",message:a,at:g,text:i}},m=function(a){return a&&a!==h&&l("Expected '"+a+"' instead of '"+h+"'"),h=i.charAt(g),g+=1,h},n=function(){var a,e="";for("-"===h&&(e="-",m("-"));h>="0"&&h<="9";)e+=h,m();if("."===h)for(e+=".";m()&&h>="0"&&h<="9";)e+=h;if("e"===h||"E"===h)for(e+=h,m(),("-"===h||"+"===h)&&(e+=h,m());h>="0"&&h<="9";)e+=h,m();if(isFinite(a=+e))return(null==d&&(d=c(3817)),e.length>15)?b.storeAsString?e:b.useNativeBigInt?BigInt(e):new d(e):b.alwaysParseAsBig?b.useNativeBigInt?BigInt(a):new d(a):a;l("Bad number")},o=function(){var a,b,c,d="";if('"'===h)for(var e=g;m();){if('"'===h)return g-1>e&&(d+=i.substring(e,g-1)),m(),d;if("\\"===h){if(g-1>e&&(d+=i.substring(e,g-1)),m(),"u"===h){for(b=0,c=0;b<4&&isFinite(a=parseInt(m(),16));b+=1)c=16*c+a;d+=String.fromCharCode(c)}else if("string"==typeof k[h])d+=k[h];else break;e=g}}l("Bad string")},p=function(){for(;h&&h<=" ";)m()},q=function(){switch(h){case"t":return m("t"),m("r"),m("u"),m("e"),!0;case"f":return m("f"),m("a"),m("l"),m("s"),m("e"),!1;case"n":return m("n"),m("u"),m("l"),m("l"),null}l("Unexpected '"+h+"'")},r=function(){var a=[];if("["===h){if(m("["),p(),"]"===h)return m("]"),a;for(;h;){if(a.push(j()),p(),"]"===h)return m("]"),a;m(","),p()}}l("Bad array")},s=function(){var a,c=Object.create(null);if("{"===h){if(m("{"),p(),"}"===h)return m("}"),c;for(;h;){if(a=o(),p(),m(":"),!0===b.strict&&Object.hasOwnProperty.call(c,a)&&l('Duplicate key "'+a+'"'),!0===e.test(a)?"error"===b.protoAction?l("Object contains forbidden prototype property"):"ignore"===b.protoAction?j():c[a]=j():!0===f.test(a)?"error"===b.constructorAction?l("Object contains forbidden constructor property"):"ignore"===b.constructorAction?j():c[a]=j():c[a]=j(),p(),"}"===h)return m("}"),c;m(","),p()}}l("Bad object")};return j=function(){switch(p(),h){case"{":return s();case"[":return r();case'"':return o();case"-":return n();default:return h>="0"&&h<="9"?n():q()}},function(a,b){var c;return i=a+"",g=0,h=" ",c=j(),p(),h&&l("Syntax error"),"function"==typeof b?function a(c,d){var e,f=c[d];return f&&"object"==typeof f&&Object.keys(f).forEach(function(b){void 0!==(e=a(f,b))?f[b]=e:delete f[b]}),b.call(c,d,f)}({"":c},""):c}}},67181:(a,b,c)=>{"use strict";c.d(b,{B1:()=>n,_0:()=>l,_Q:()=>o,f7:()=>p,oH:()=>g,pc:()=>h});var d=c(55686),e=c(88470),f=c(18367);function g(a){return!0===a.thought}function h(a,b){return"string"==typeof b&&b.length>0?b:a}let i=/^[A-Za-z0-9+/]+={0,2}$/;function j(a,b){return a&&b&&b.length%4==0&&i.test(b)?b:void 0}function k(a){return a.startsWith("claude-")||a.startsWith("gpt-oss-")}function l(a,b){let c=[];for(let d of(0,f.b)(b.messages,a,b=>k(a.id)?b.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64):b))if("user"===d.role)if("string"==typeof d.content)c.push({role:"user",parts:[{text:(0,e.J)(d.content)}]});else{let a=d.content.map(a=>"text"===a.type?{text:(0,e.J)(a.text)}:{inlineData:{mimeType:a.mimeType,data:a.data}});if(0===a.length)continue;c.push({role:"user",parts:a})}else if("assistant"===d.role){let b=[],f=d.provider===a.provider&&d.model===a.id;for(let c of d.content)if("text"===c.type){if(!c.text||""===c.text.trim())continue;let a=j(f,c.textSignature);b.push({text:(0,e.J)(c.text),...a&&{thoughtSignature:a}})}else if("thinking"===c.type){if(!c.thinking||""===c.thinking.trim())continue;if(f){let a=j(f,c.thinkingSignature);b.push({thought:!0,text:(0,e.J)(c.thinking),...a&&{thoughtSignature:a}})}else b.push({text:(0,e.J)(c.thinking)})}else if("toolCall"===c.type){let d=j(f,c.thoughtSignature),e={functionCall:{name:c.name,args:c.arguments??{},...k(a.id)?{id:c.id}:{}},...d&&{thoughtSignature:d}};b.push(e)}if(0===b.length)continue;c.push({role:"model",parts:b})}else if("toolResult"===d.role){let b=d.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n"),f=a.input.includes("image")?d.content.filter(a=>"image"===a.type):[],g=b.length>0,h=f.length>0,i=function(a){let b=function(a){let b=a.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(b)return Number.parseInt(b[1],10)}(a);return void 0===b||b>=3}(a.id),j=g?(0,e.J)(b):h?"(see attached image)":"",l=f.map(a=>({inlineData:{mimeType:a.mimeType,data:a.data}})),m=k(a.id),n={functionResponse:{name:d.toolName,response:d.isError?{error:j}:{output:j},...h&&i&&{parts:l},...m?{id:d.toolCallId}:{}}},o=c[c.length-1];o?.role==="user"&&o.parts?.some(a=>a.functionResponse)?o.parts.push(n):c.push({role:"user",parts:[n]}),h&&!i&&c.push({role:"user",parts:[{text:"Tool result image:"},...l]})}return c}let m=new Set(["$schema","$id","$anchor","$dynamicAnchor","$vocabulary","$comment","$defs","definitions"]);function n(a,b=!1){if(0!==a.length)return[{functionDeclarations:a.map(a=>({name:a.name,description:a.description,...b?{parameters:function a(b){if("object"!=typeof b||null===b||Array.isArray(b))return b;let c={};for(let[d,e]of Object.entries(b))m.has(d)||(c[d]=a(e));return c}(a.parameters)}:{parametersJsonSchema:a.parameters}}))}]}function o(a){switch(a){case"auto":default:return d.ce.AUTO;case"none":return d.ce.NONE;case"any":return d.ce.ANY}}function p(a){switch(a){case d.eD.STOP:return"stop";case d.eD.MAX_TOKENS:return"length";case d.eD.BLOCKLIST:case d.eD.PROHIBITED_CONTENT:case d.eD.SPII:case d.eD.SAFETY:case d.eD.IMAGE_SAFETY:case d.eD.IMAGE_PROHIBITED_CONTENT:case d.eD.IMAGE_RECITATION:case d.eD.IMAGE_OTHER:case d.eD.RECITATION:case d.eD.FINISH_REASON_UNSPECIFIED:case d.eD.OTHER:case d.eD.LANGUAGE:case d.eD.MALFORMED_FUNCTION_CALL:case d.eD.UNEXPECTED_TOOL_CALL:case d.eD.NO_IMAGE:return"error";default:throw Error(`Unhandled stop reason: ${a}`)}}},68423:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.PluggableAuthClient=b.ExecutableError=void 0;let d=c(64876),e=c(92301),f=c(45722);var g=c(45722);Object.defineProperty(b,"ExecutableError",{enumerable:!0,get:function(){return g.ExecutableError}});class h extends d.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(a){if(super(a),!a.credential_source.executable||(this.command=a.credential_source.executable.command,!this.command))throw Error('No valid Pluggable Auth "credential_source" provided.');if(void 0===a.credential_source.executable.timeout_millis)this.timeoutMillis=3e4;else if(this.timeoutMillis=a.credential_source.executable.timeout_millis,this.timeoutMillis<5e3||this.timeoutMillis>12e4)throw Error("Timeout must be between 5000120000 milliseconds.");this.outputFile=a.credential_source.executable.output_file,this.handler=new f.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){let a;if("1"!==process.env.GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES)throw Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");if(this.outputFile&&(a=await this.handler.retrieveCachedResponse()),!a){let b=new Map;b.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),b.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),b.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile&&b.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);let c=this.getServiceAccountEmail();c&&b.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",c),a=await this.handler.retrieveResponseFromExecutable(b)}if(a.version>1)throw Error("Version of executable is not currently supported, maximum supported version is 1.");if(!a.success)throw new f.ExecutableError(a.errorMessage,a.errorCode);if(this.outputFile&&!a.expirationTime)throw new e.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.");if(a.isExpired())throw Error("Executable response is expired.");return a.subjectToken}}b.PluggableAuthClient=h},69348:function(a,b,c){"use strict";let d;var e,f=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),g=this&&this.__setModuleDefault||(Object.create?function(a,b){Object.defineProperty(a,"default",{enumerable:!0,value:b})}:function(a,b){a.default=b}),h=this&&this.__importStar||(e=function(a){return(e=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[b.length]=c);return b})(a)},function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c=e(a),d=0;d<c.length;d++)"default"!==c[d]&&f(b,a,c[d]);return g(b,a),b}),i=this&&this.__exportStar||function(a,b){for(var c in a)"default"===c||Object.prototype.hasOwnProperty.call(b,c)||f(b,a,c)};Object.defineProperty(b,"__esModule",{value:!0}),b.gcpResidencyCache=b.METADATA_SERVER_DETECTION=b.HEADERS=b.HEADER_VALUE=b.HEADER_NAME=b.SECONDARY_HOST_ADDRESS=b.HOST_ADDRESS=b.BASE_PATH=void 0,b.instance=function(a){return p("instance",a)},b.project=function(a){return p("project",a)},b.universe=function(a){return p("universe",a)},b.bulk=r,b.isAvailable=s,b.resetIsAvailableCache=function(){d=void 0},b.getGCPResidency=t,b.setGCPResidency=u,b.requestTimeout=v;let j=c(51596),k=c(89072),l=c(53163),m=h(c(24099));b.BASE_PATH="/computeMetadata/v1",b.HOST_ADDRESS="http://169.254.169.254",b.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.",b.HEADER_NAME="Metadata-Flavor",b.HEADER_VALUE="Google",b.HEADERS=Object.freeze({[b.HEADER_NAME]:b.HEADER_VALUE});let n=m.log("gcp-metadata");function o(a){return a||(a=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||b.HOST_ADDRESS),/^https?:\/\//.test(a)||(a=`http://${a}`),new URL(b.BASE_PATH,a).href}async function p(a,c={},d=3,e=!1){let f=new Headers(b.HEADERS),g="",h={};("object"==typeof a?(new Headers(a.headers).forEach((a,b)=>f.set(b,a)),g=a.metadataKey,h=a.params||h,d=a.noResponseRetries||d,e=a.fastFail||e):g=a,"string"==typeof c)?g+=`/${c}`:(Object.keys(c).forEach(a=>{switch(a){case"params":case"property":case"headers":break;case"qs":throw Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw Error(`'${a}' is not a valid configuration option.`)}}),c.property&&(g+=`/${c.property}`),new Headers(c.headers).forEach((a,b)=>f.set(b,a)),h=c.params||h);let i=e?q:j.request,l={url:`${o()}/${g}`,headers:f,retryConfig:{noResponseRetries:d},params:h,responseType:"text",timeout:v()};n.info("instance request %j",l);let m=await i(l);n.info("instance metadata is %s",m.data);let r=m.headers.get(b.HEADER_NAME);if(r!==b.HEADER_VALUE)throw RangeError(`Invalid response from metadata service: incorrect ${b.HEADER_NAME} header. Expected '${b.HEADER_VALUE}', got ${r?`'${r}'`:"no header"}`);if("string"==typeof m.data)try{return k.parse(m.data)}catch{}return m.data}async function q(a){let c={...a,url:a.url?.toString().replace(o(),o(b.SECONDARY_HOST_ADDRESS))};return Promise.any([(0,j.request)(a),(0,j.request)(c)])}async function r(a){let b={};return await Promise.all(a.map(a=>(async()=>{let c=await p(a);b[a.metadataKey]=c})())),b}async function s(){if(process.env.METADATA_SERVER_DETECTION){let a=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(a in b.METADATA_SERVER_DETECTION))throw RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${a}\`, but it should be \`${Object.keys(b.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(a){case"assume-present":return!0;case"none":return!1;case"bios-only":return t()}}try{return void 0===d&&(d=p("instance",void 0,process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0,!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST))),await d,!0}catch(a){if(process.env.DEBUG_AUTH&&console.info(a),"request-timeout"===a.type||a.response&&404===a.response.status)return!1;if(!(a.response&&404===a.response.status)&&(!a.code||!["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(a.code.toString()))){let b="UNKNOWN";a.code&&(b=a.code.toString()),process.emitWarning(`received unexpected error = ${a.message} code = ${b}`,"MetadataLookupWarning")}return!1}}function t(){return null===b.gcpResidencyCache&&u(),b.gcpResidencyCache}function u(a=null){b.gcpResidencyCache=null!==a?a:(0,l.detectGCPResidency)()}function v(){return 3e3*!t()}b.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"}),b.gcpResidencyCache=null,i(c(53163),b)},69371:(a,b)=>{"use strict";b.byteLength=function(a){var b=i(a),c=b[0],d=b[1];return(c+d)*3/4-d},b.toByteArray=function(a){var b,c,f=i(a),g=f[0],h=f[1],j=new e((g+h)*3/4-h),k=0,l=h>0?g-4:g;for(c=0;c<l;c+=4)b=d[a.charCodeAt(c)]<<18|d[a.charCodeAt(c+1)]<<12|d[a.charCodeAt(c+2)]<<6|d[a.charCodeAt(c+3)],j[k++]=b>>16&255,j[k++]=b>>8&255,j[k++]=255&b;return 2===h&&(b=d[a.charCodeAt(c)]<<2|d[a.charCodeAt(c+1)]>>4,j[k++]=255&b),1===h&&(b=d[a.charCodeAt(c)]<<10|d[a.charCodeAt(c+1)]<<4|d[a.charCodeAt(c+2)]>>2,j[k++]=b>>8&255,j[k++]=255&b),j},b.fromByteArray=function(a){for(var b,d=a.length,e=d%3,f=[],g=0,h=d-e;g<h;g+=16383)f.push(function(a,b,d){for(var e,f=[],g=b;g<d;g+=3)e=(a[g]<<16&0xff0000)+(a[g+1]<<8&65280)+(255&a[g+2]),f.push(c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]);return f.join("")}(a,g,g+16383>h?h:g+16383));return 1===e?f.push(c[(b=a[d-1])>>2]+c[b<<4&63]+"=="):2===e&&f.push(c[(b=(a[d-2]<<8)+a[d-1])>>10]+c[b>>4&63]+c[b<<2&63]+"="),f.join("")};for(var c=[],d=[],e="u">typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g=0,h=f.length;g<h;++g)c[g]=f[g],d[f.charCodeAt(g)]=g;function i(a){var b=a.length;if(b%4>0)throw Error("Invalid string. Length must be a multiple of 4");var c=a.indexOf("=");-1===c&&(c=b);var d=c===b?0:4-c%4;return[c,d]}d[45]=62,d[95]=63},72893:(a,b,c)=>{"use strict";function d(a){let b={};for(let[c,d]of a.entries())b[c]=d;return b}function e(a){if(!a)return;let b={};for(let[c,d]of Object.entries(a))null!==d&&(b[c]=d);return Object.keys(b).length>0?b:void 0}c.d(b,{j:()=>d,m:()=>e})},73482:a=>{"use strict";var b=Object.prototype.hasOwnProperty,c=Object.prototype.toString,d=Object.defineProperty,e=Object.getOwnPropertyDescriptor,f=function(a){return"function"==typeof Array.isArray?Array.isArray(a):"[object Array]"===c.call(a)},g=function(a){if(!a||"[object Object]"!==c.call(a))return!1;var d,e=b.call(a,"constructor"),f=a.constructor&&a.constructor.prototype&&b.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!e&&!f)return!1;for(d in a);return void 0===d||b.call(a,d)},h=function(a,b){d&&"__proto__"===b.name?d(a,b.name,{enumerable:!0,configurable:!0,value:b.newValue,writable:!0}):a[b.name]=b.newValue},i=function(a,c){if("__proto__"===c){if(!b.call(a,c))return;else if(e)return e(a,c).value}return a[c]};a.exports=function a(){var b,c,d,e,j,k,l=arguments[0],m=1,n=arguments.length,o=!1;for("boolean"==typeof l&&(o=l,l=arguments[1]||{},m=2),(null==l||"object"!=typeof l&&"function"!=typeof l)&&(l={});m<n;++m)if(b=arguments[m],null!=b)for(c in b)d=i(l,c),l!==(e=i(b,c))&&(o&&e&&(g(e)||(j=f(e)))?(j?(j=!1,k=d&&f(d)?d:[]):k=d&&g(d)?d:{},h(l,{name:c,newValue:a(o,k,e)})):void 0!==e&&h(l,{name:c,newValue:e}));return l}},73642:function(a,b,c){"use strict";let d;var e,f,g,h=this&&this.__createBinding||(Object.create?function(a,b,c,d){void 0===d&&(d=c);var e=Object.getOwnPropertyDescriptor(b,c);(!e||("get"in e?!b.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return b[c]}}),Object.defineProperty(a,d,e)}:function(a,b,c,d){void 0===d&&(d=c),a[d]=b[c]}),i=this&&this.__setModuleDefault||(Object.create?function(a,b){Object.defineProperty(a,"default",{enumerable:!0,value:b})}:function(a,b){a.default=b}),j=this&&this.__importStar||(e=function(a){return(e=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[b.length]=c);return b})(a)},function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c=e(a),d=0;d<c.length;d++)"default"!==c[d]&&h(b,a,c[d]);return i(b,a),b});Object.defineProperty(b,"__esModule",{value:!0}),b.env=b.DebugLogBackendBase=b.placeholder=b.AdhocDebugLogger=b.LogSeverity=void 0,b.getNodeBackend=r,b.getDebugBackend=function(a){return new s(a)},b.getStructuredBackend=function(a){return new t(a)},b.setBackend=function(a){d=a,u.clear()},b.log=v;let k=c(94735),l=j(c(19771)),m=j(c(28354)),n=c(91830);(f=g||(b.LogSeverity=g={})).DEFAULT="DEFAULT",f.DEBUG="DEBUG",f.INFO="INFO",f.WARNING="WARNING",f.ERROR="ERROR";class o extends k.EventEmitter{constructor(a,b){super(),this.namespace=a,this.upstream=b,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(a,b)=>this.on(a,b)}),this.func.debug=(...a)=>this.invokeSeverity(g.DEBUG,...a),this.func.info=(...a)=>this.invokeSeverity(g.INFO,...a),this.func.warn=(...a)=>this.invokeSeverity(g.WARNING,...a),this.func.error=(...a)=>this.invokeSeverity(g.ERROR,...a),this.func.sublog=a=>v(a,this.func)}invoke(a,...b){if(this.upstream)try{this.upstream(a,...b)}catch(a){}try{this.emit("log",a,b)}catch(a){}}invokeSeverity(a,...b){this.invoke({severity:a},...b)}}b.AdhocDebugLogger=o,b.placeholder=new o("",()=>{}).func;class p{constructor(){var a;this.cached=new Map,this.filters=[],this.filtersSet=!1;let c=null!=(a=l.env[b.env.nodeEnables])?a:"*";"all"===c&&(c="*"),this.filters=c.split(",")}log(a,b,...c){try{this.filtersSet||(this.setFilters(),this.filtersSet=!0);let d=this.cached.get(a);d||(d=this.makeLogger(a),this.cached.set(a,d)),d(b,...c)}catch(a){console.error(a)}}}b.DebugLogBackendBase=p;class q extends p{constructor(){super(...arguments),this.enabledRegexp=/.*/g}isEnabled(a){return this.enabledRegexp.test(a)}makeLogger(a){return this.enabledRegexp.test(a)?(b,...c)=>{var d;let e,f=`${n.Colours.green}${a}${n.Colours.reset}`,h=`${n.Colours.yellow}${l.pid}${n.Colours.reset}`;switch(b.severity){case g.ERROR:e=`${n.Colours.red}${b.severity}${n.Colours.reset}`;break;case g.INFO:e=`${n.Colours.magenta}${b.severity}${n.Colours.reset}`;break;case g.WARNING:e=`${n.Colours.yellow}${b.severity}${n.Colours.reset}`;break;default:e=null!=(d=b.severity)?d:g.DEFAULT}let i=m.formatWithOptions({colors:n.Colours.enabled},...c),j=Object.assign({},b);delete j.severity;let k=Object.getOwnPropertyNames(j).length?JSON.stringify(j):"",o=k?`${n.Colours.grey}${k}${n.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",h,f,e,i,k?` ${o}`:"")}:()=>{}}setFilters(){let a=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=RegExp(`^${a}$`,"i")}}function r(){return new q}class s extends p{constructor(a){super(),this.debugPkg=a}makeLogger(a){let b=this.debugPkg(a);return(a,...c)=>{b(c[0],...c.slice(1))}}setFilters(){var a;let b=null!=(a=l.env.NODE_DEBUG)?a:"";l.env.NODE_DEBUG=`${b}${b?",":""}${this.filters.join(",")}`}}class t extends p{constructor(a){super(),this.upstream=null!=a?a:void 0}makeLogger(a){var b;let c=null==(b=this.upstream)?void 0:b.makeLogger(a);return(a,...b)=>{var d;let e=JSON.stringify(Object.assign({severity:null!=(d=a.severity)?d:g.INFO,message:m.format(...b)},a));c?c(a,e):console.log("%s",e)}}setFilters(){var a;null==(a=this.upstream)||a.setFilters()}}b.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};let u=new Map;function v(a,c){let e;if(!d&&!l.env[b.env.nodeEnables]||!a)return b.placeholder;c&&(a=`${c.instance.namespace}:${a}`);let f=u.get(a);if(f)return f.func;if(null===d)return b.placeholder;void 0===d&&(d=r());let g=new o(a,(b,...c)=>{if(e!==d){if(null===d)return;void 0===d&&(d=r()),e=d}null==d||d.log(a,b,...c)});return u.set(a,g),g.func}},74674:(a,b)=>{"use strict";async function c(a,b){return await b.request({url:"https://oauth2.googleapis.com/revoke?token="+a,retry:!0})}Object.defineProperty(b,"__esModule",{value:!0}),b.revokeToken=c},74745:a=>{"use strict";a.exports=JSON.parse('{"name":"gaxios","version":"7.1.4","description":"A simple common HTTP client specifically for Google APIs and services.","main":"build/cjs/src/index.js","types":"build/cjs/src/index.d.ts","files":["build/"],"exports":{".":{"import":{"types":"./build/esm/src/index.d.ts","default":"./build/esm/src/index.js"},"require":{"types":"./build/cjs/src/index.d.ts","default":"./build/cjs/src/index.js"}}},"scripts":{"lint":"gts check --no-inline-config","test":"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000","compile":"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs","fix":"gts fix","prepare":"npm run compile","pretest":"npm run compile","webpack":"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js","docs":"jsdoc -c .jsdoc.js","docs-test":"linkinator docs","predocs-test":"npm run docs","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","prelint":"cd samples; npm link ../; npm install","clean":"gts clean"},"repository":{"type":"git","directory":"packages/gaxios","url":"https://github.com/googleapis/google-cloud-node-core.git"},"keywords":["google"],"engines":{"node":">=18"},"author":"Google, LLC","license":"Apache-2.0","devDependencies":{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^22.13.1","@types/sinon":"^17.0.3","@types/tmp":"^0.2.6","assert":"^2.0.0","browserify":"^17.0.0","c8":"^10.1.3","cors":"^2.8.5","express":"^5.0.0","gts":"^6.0.2","is-docker":"^3.0.0","jsdoc":"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0","karma":"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1","linkinator":"^6.1.2","mocha":"^11.1.0","multiparty":"^4.2.1","mv":"^2.1.1","ncp":"^2.0.0","nock":"^14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0","puppeteer":"^24.0.0","sinon":"^21.0.0","stream-browserify":"^3.0.0","tmp":"0.2.5","ts-loader":"^9.5.2","typescript":"5.8.3","webpack":"^5.97.1","webpack-cli":"^6.0.1"},"dependencies":{"extend":"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},"homepage":"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/gaxios"}')},74941:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.UrlSubjectTokenSupplier=void 0;let d=c(25072);class e{url;headers;formatType;subjectTokenFieldName;additionalGaxiosOptions;constructor(a){this.url=a.url,this.formatType=a.formatType,this.subjectTokenFieldName=a.subjectTokenFieldName,this.headers=a.headers,this.additionalGaxiosOptions=a.additionalGaxiosOptions}async getSubjectToken(a){let b,c={...this.additionalGaxiosOptions,url:this.url,method:"GET",headers:this.headers,responseType:this.formatType};if(d.AuthClient.setMethodName(c,"getSubjectToken"),"text"===this.formatType?b=(await a.transporter.request(c)).data:"json"===this.formatType&&this.subjectTokenFieldName&&(b=(await a.transporter.request(c)).data[this.subjectTokenFieldName]),!b)throw Error("Unable to parse the subject_token from the credential_source URL");return b}}b.UrlSubjectTokenSupplier=e},75833:(a,b,c)=>{var d=c(3817),e=a.exports;!function(){"use strict";var a,b,c,f=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function h(a){return f.lastIndex=0,f.test(a)?'"'+a.replace(f,function(a){var b=g[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}"function"!=typeof e.stringify&&(e.stringify=function(e,f,g){var i;if(a="",b="","number"==typeof g)for(i=0;i<g;i+=1)b+=" ";else"string"==typeof g&&(b=g);if(c=f,f&&"function"!=typeof f&&("object"!=typeof f||"number"!=typeof f.length))throw Error("JSON.stringify");return function e(f,g){var i,j,k,l,m,n=a,o=g[f],p=null!=o&&(o instanceof d||d.isBigNumber(o));switch(o&&"object"==typeof o&&"function"==typeof o.toJSON&&(o=o.toJSON(f)),"function"==typeof c&&(o=c.call(g,f,o)),typeof o){case"string":if(p)return o;return h(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":case"bigint":return String(o);case"object":if(!o)return"null";if(a+=b,m=[],"[object Array]"===Object.prototype.toString.apply(o)){for(i=0,l=o.length;i<l;i+=1)m[i]=e(i,o)||"null";return k=0===m.length?"[]":a?"[\n"+a+m.join(",\n"+a)+"\n"+n+"]":"["+m.join(",")+"]",a=n,k}if(c&&"object"==typeof c)for(i=0,l=c.length;i<l;i+=1)"string"==typeof c[i]&&(k=e(j=c[i],o))&&m.push(h(j)+(a?": ":":")+k);else Object.keys(o).forEach(function(b){var c=e(b,o);c&&m.push(h(b)+(a?": ":":")+c)});return k=0===m.length?"{}":a?"{\n"+a+m.join(",\n"+a)+"\n"+n+"}":"{"+m.join(",")+"}",a=n,k}}("",{"":e})})}()},77978:(a,b,c)=>{var d=c(10140).Buffer,e=c(39545),f=c(92704),g=c(27910),h=c(32480),i=c(28354);function j(a,b){return d.from(a,b).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function k(a){var b,c,d,e=a.header,g=a.payload,k=a.secret||a.privateKey,l=a.encoding,m=f(e.alg),n=(b=(b=l)||"utf8",c=j(h(e),"binary"),d=j(h(g),b),i.format("%s.%s",c,d)),o=m.sign(n,k);return i.format("%s.%s",n,o)}function l(a){var b=a.secret;if(b=null==(b=null==b?a.privateKey:b)?a.key:b,!0===/^hs/i.test(a.header.alg)&&null==b)throw TypeError("secret must be a string or buffer or a KeyObject");var c=new e(b);this.readable=!0,this.header=a.header,this.encoding=a.encoding,this.secret=this.privateKey=this.key=c,this.payload=new e(a.payload),this.secret.once("close",(function(){!this.payload.writable&&this.readable&&this.sign()}).bind(this)),this.payload.once("close",(function(){!this.secret.writable&&this.readable&&this.sign()}).bind(this))}i.inherits(l,g),l.prototype.sign=function(){try{var a=k({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",a),this.emit("data",a),this.emit("end"),this.readable=!1,a}catch(a){this.readable=!1,this.emit("error",a),this.emit("close")}},l.sign=k,a.exports=l},78289:(a,b,c)=>{"use strict";let d=c(89420),e=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class f extends Error{constructor(a){super(),a instanceof Error?(this.originalError=a,{message:a}=a):(this.originalError=Error(a),this.originalError.stack=this.stack),this.name="AbortError",this.message=a}}let g=(a,b)=>new Promise((c,g)=>{b={onFailedAttempt:()=>{},retries:10,...b};let h=d.operation(b);h.attempt(async d=>{try{c(await a(d))}catch(a){if(!(a instanceof Error))return void g(TypeError(`Non-error was thrown: "${a}". You should only throw errors.`));if(a instanceof f)h.stop(),g(a.originalError);else{let c;if(a instanceof TypeError&&(c=a.message,!e.includes(c)))h.stop(),g(a);else{let c;c=b.retries-(d-1),a.attemptNumber=d,a.retriesLeft=c;try{await b.onFailedAttempt(a)}catch(a){g(a);return}h.retry(a)||g(h.mainError())}}}})});a.exports=g,a.exports.default=g,a.exports.AbortError=f},80924:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.GoogleAuth=b.GoogleAuthExceptionMessages=void 0;let d=c(79646),e=c(29021),f=c(51596),g=c(69348),h=c(21820),i=c(33873),j=c(61721),k=c(32927),l=c(99660),m=c(35657),n=c(42195),o=c(54729),p=c(13022),q=c(85977),r=c(64876),s=c(25072),t=c(95954),u=c(90852);b.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:"Unable to detect a Project Id in the current environment. \nTo learn more about authentication and Google APIs, visit: \nhttps://cloud.google.com/docs/authentication/getting-started",NO_CREDENTIALS_FOUND:"Unable to find credentials in current environment. \nTo learn more about authentication and Google APIs, visit: \nhttps://cloud.google.com/docs/authentication/getting-started",NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:"Unable to detect a Universe Domain in the current environment.\nTo learn more about Universe Domain retrieval, visit: \nhttps://cloud.google.com/compute/docs/metadata/predefined-metadata-keys"};class v{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#w=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(a={}){if(this._cachedProjectId=a.projectId||null,this.cachedCredential=a.authClient||null,this.keyFilename=a.keyFilename||a.keyFile,this.scopes=a.scopes,this.clientOptions=a.clientOptions||{},this.jsonContent=a.credentials||null,this.apiKey=a.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError(b.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);a.universeDomain&&(this.clientOptions.universeDomain=a.universeDomain)}setGapicJWTValues(a){a.defaultServicePath=this.defaultServicePath,a.useJWTAccessWithScope=this.useJWTAccessWithScope,a.defaultScopes=this.defaultScopes}getProjectId(a){if(!a)return this.getProjectIdAsync();this.getProjectIdAsync().then(b=>a(null,b),a)}async getProjectIdOptional(){try{return await this.getProjectId()}catch(a){if(a instanceof Error&&a.message===b.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw a}}async findAndCacheProjectId(){let a=null;if(a||=await this.getProductionProjectId(),a||=await this.getFileProjectId(),a||=await this.getDefaultServiceProjectId(),a||=await this.getGCEProjectId(),a||=await this.getExternalAccountClientProjectId())return this._cachedProjectId=a,a;throw Error(b.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let a;try{a=await g.universe("universe-domain"),a||=s.DEFAULT_UNIVERSE}catch(b){if(b&&b?.response?.status===404)a=s.DEFAULT_UNIVERSE;else throw b}return a}async getUniverseDomain(){let a=(0,u.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{a??=(await this.getClient()).universeDomain}catch{a??=s.DEFAULT_UNIVERSE}return a}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(a={},b){let c;if("function"==typeof a?b=a:c=a,!b)return this.getApplicationDefaultAsync(c);this.getApplicationDefaultAsync(c).then(a=>b(null,a.credential,a.projectId),b)}async getApplicationDefaultAsync(a={}){let c;if(this.cachedCredential)return await this.#x(this.cachedCredential,null);if((c=await this._tryGetApplicationCredentialsFromEnvironmentVariable(a))||(c=await this._tryGetApplicationCredentialsFromWellKnownFile(a)))return c instanceof n.JWT?c.scopes=this.scopes:c instanceof r.BaseExternalAccountClient&&(c.scopes=this.getAnyScopes()),await this.#x(c);if(await this._checkIsGCE())return a.scopes=this.getAnyScopes(),await this.#x(new k.Compute(a));throw Error(b.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async #x(a,b=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let c=await this.getProjectIdOptional();return b&&(a.quotaProjectId=b),this.cachedCredential=a,{credential:a,projectId:c}}async _checkIsGCE(){return void 0===this.checkIsGCE&&(this.checkIsGCE=g.getGCPResidency()||await g.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(a){let b=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!b||0===b.length)return null;try{return this._getApplicationCredentialsFromFilePath(b,a)}catch(a){throw a instanceof Error&&(a.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${a.message}`),a}}async _tryGetApplicationCredentialsFromWellKnownFile(a){let b=null;if(this._isWindows())b=process.env.APPDATA;else{let a=process.env.HOME;a&&(b=i.join(a,".config"))}return(b&&(b=i.join(b,"gcloud","application_default_credentials.json"),e.existsSync(b)||(b=null)),b)?await this._getApplicationCredentialsFromFilePath(b,a):null}async _getApplicationCredentialsFromFilePath(a,b={}){if(!a||0===a.length)throw Error("The file path is invalid.");try{if(a=e.realpathSync(a),!e.lstatSync(a).isFile())throw Error()}catch(b){throw b instanceof Error&&(b.message=`The file at ${a} does not exist, or it is not a file. ${b.message}`),b}let c=e.createReadStream(a);return this.fromStream(c,b)}fromImpersonatedJSON(a){if(!a)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(a.type!==p.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${p.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!a.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!a.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let b=this.fromJSON(a.source_credentials);if(a.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${a.service_account_impersonation_url}`);let c=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(a.service_account_impersonation_url)?.groups?.target;if(!c)throw RangeError(`Cannot extract target principal from ${a.service_account_impersonation_url}`);let d=(this.scopes||a.scopes||this.defaultScopes)??[];return new p.Impersonated({...a,sourceClient:b,targetPrincipal:c,targetScopes:Array.isArray(d)?d:[d]})}fromJSON(a,b={}){let c,d=(0,u.originalOrCamelOptions)(b).get("universe_domain");return a.type===o.USER_REFRESH_ACCOUNT_TYPE?(c=new o.UserRefreshClient(b)).fromJSON(a):a.type===p.IMPERSONATED_ACCOUNT_TYPE?c=this.fromImpersonatedJSON(a):a.type===r.EXTERNAL_ACCOUNT_TYPE?(c=q.ExternalAccountClient.fromJSON({...a,...b})).scopes=this.getAnyScopes():a.type===t.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?c=new t.ExternalAccountAuthorizedUserClient({...a,...b}):(b.scopes=this.scopes,c=new n.JWT(b),this.setGapicJWTValues(c),c.fromJSON(a)),d&&(c.universeDomain=d),c}_cacheClientFromJSON(a,b){let c=this.fromJSON(a,b);return this.jsonContent=a,this.cachedCredential=c,c}fromStream(a,b={},c){let d={};if("function"==typeof b?c=b:d=b,!c)return this.fromStreamAsync(a,d);this.fromStreamAsync(a,d).then(a=>c(null,a),c)}fromStreamAsync(a,b){return new Promise((c,d)=>{if(!a)throw Error("Must pass in a stream containing the Google auth settings.");let e=[];a.setEncoding("utf8").on("error",d).on("data",a=>e.push(a)).on("end",()=>{try{try{let a=JSON.parse(e.join("")),d=this._cacheClientFromJSON(a,b);return c(d)}catch(b){if(!this.keyFilename)throw b;let a=new n.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=a,this.setGapicJWTValues(a),c(a)}}catch(a){return d(a)}})})}fromAPIKey(a,b={}){return new n.JWT({...b,apiKey:a})}_isWindows(){let a=h.platform();return!!a&&!!(a.length>=3)&&"win"===a.substring(0,3).toLowerCase()}async getDefaultServiceProjectId(){return new Promise(a=>{(0,d.exec)("gcloud config config-helper --format json",(b,c)=>{if(!b&&c)try{let b=JSON.parse(c).configuration.properties.core.project;a(b);return}catch(a){}a(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let a=await this.getClient();if(a&&a.projectId)return a.projectId}let a=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return a?a.projectId:null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==r.EXTERNAL_ACCOUNT_TYPE)return null;let a=await this.getClient();return await a.getProjectId()}async getGCEProjectId(){try{return await g.project("project-id")}catch(a){return null}}getCredentials(a){if(!a)return this.getCredentialsAsync();this.getCredentialsAsync().then(b=>a(null,b),a)}async getCredentialsAsync(){let a=await this.getClient();if(a instanceof p.Impersonated)return{client_email:a.getTargetPrincipal()};if(a instanceof r.BaseExternalAccountClient){let b=a.getServiceAccountEmail();if(b)return{client_email:b,universe_domain:a.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[a,b]=await Promise.all([g.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:a,universe_domain:b}}throw Error(b.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#w=this.#w||this.#y();try{return await this.#w}finally{this.#w=null}}async #y(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let a=i.resolve(this.keyFilename),b=e.createReadStream(a);return await this.fromStreamAsync(b,this.clientOptions)}if(this.apiKey){let a=await this.fromAPIKey(this.apiKey,this.clientOptions);a.scopes=this.scopes;let{credential:b}=await this.#x(a);return b}{let{credential:a}=await this.getApplicationDefaultAsync(this.clientOptions);return a}}async getIdTokenClient(a){let b=await this.getClient();if(!("fetchIdToken"in b))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new l.IdTokenClient({targetAudience:a,idTokenProvider:b})}async getAccessToken(){let a=await this.getClient();return(await a.getAccessToken()).token}async getRequestHeaders(a){return(await this.getClient()).getRequestHeaders(a)}async authorizeRequest(a={}){let b=a.url,c=await this.getClient(),d=await c.getRequestHeaders(b);return a.headers=f.Gaxios.mergeHeaders(a.headers,d),a}async fetch(...a){return(await this.getClient()).fetch(...a)}async request(a){return(await this.getClient()).request(a)}getEnv(){return(0,m.getEnv)()}async sign(a,b){let c=await this.getClient(),d=await this.getUniverseDomain();if(b=b||`https://iamcredentials.${d}/v1/projects/-/serviceAccounts/`,c instanceof p.Impersonated)return(await c.sign(a)).signedBlob;let e=(0,j.createCrypto)();if(c instanceof n.JWT&&c.key)return await e.sign(c.key,a);let f=await this.getCredentials();if(!f.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(e,f.client_email,a,b)}async signBlob(a,b,c,d){let e=new URL(d+`${b}:signBlob`);return(await this.request({method:"POST",url:e.href,data:{payload:a.encodeBase64StringUtf8(c)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}b.GoogleAuth=v},81840:(a,b,c)=>{"use strict";let{kForOnEventAttribute:d,kListener:e}=c(89721),f=Symbol("kCode"),g=Symbol("kData"),h=Symbol("kError"),i=Symbol("kMessage"),j=Symbol("kReason"),k=Symbol("kTarget"),l=Symbol("kType"),m=Symbol("kWasClean");class n{constructor(a){this[k]=null,this[l]=a}get target(){return this[k]}get type(){return this[l]}}Object.defineProperty(n.prototype,"target",{enumerable:!0}),Object.defineProperty(n.prototype,"type",{enumerable:!0});class o extends n{constructor(a,b={}){super(a),this[f]=void 0===b.code?0:b.code,this[j]=void 0===b.reason?"":b.reason,this[m]=void 0!==b.wasClean&&b.wasClean}get code(){return this[f]}get reason(){return this[j]}get wasClean(){return this[m]}}Object.defineProperty(o.prototype,"code",{enumerable:!0}),Object.defineProperty(o.prototype,"reason",{enumerable:!0}),Object.defineProperty(o.prototype,"wasClean",{enumerable:!0});class p extends n{constructor(a,b={}){super(a),this[h]=void 0===b.error?null:b.error,this[i]=void 0===b.message?"":b.message}get error(){return this[h]}get message(){return this[i]}}Object.defineProperty(p.prototype,"error",{enumerable:!0}),Object.defineProperty(p.prototype,"message",{enumerable:!0});class q extends n{constructor(a,b={}){super(a),this[g]=void 0===b.data?null:b.data}get data(){return this[g]}}function r(a,b,c){"object"==typeof a&&a.handleEvent?a.handleEvent.call(a,c):a.call(b,c)}Object.defineProperty(q.prototype,"data",{enumerable:!0}),a.exports={CloseEvent:o,ErrorEvent:p,Event:n,EventTarget:{addEventListener(a,b,c={}){let f;for(let f of this.listeners(a))if(!c[d]&&f[e]===b&&!f[d])return;if("message"===a)f=function(a,c){let d=new q("message",{data:c?a:a.toString()});d[k]=this,r(b,this,d)};else if("close"===a)f=function(a,c){let d=new o("close",{code:a,reason:c.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});d[k]=this,r(b,this,d)};else if("error"===a)f=function(a){let c=new p("error",{error:a,message:a.message});c[k]=this,r(b,this,c)};else{if("open"!==a)return;f=function(){let a=new n("open");a[k]=this,r(b,this,a)}}f[d]=!!c[d],f[e]=b,c.once?this.once(a,f):this.on(a,f)},removeEventListener(a,b){for(let c of this.listeners(a))if(c[e]===b&&!c[d]){this.removeListener(a,c);break}}},MessageEvent:q}},84950:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.IdentityPoolClient=void 0;let d=c(64876),e=c(90852),f=c(26678),g=c(74941),h=c(55723),i=c(32075),j=c(51596);class k extends d.BaseExternalAccountClient{subjectTokenSupplier;constructor(a){super(a);const b=(0,e.originalOrCamelOptions)(a),c=b.get("credential_source"),d=b.get("subject_token_supplier");if(!c&&!d)throw Error("A credential source or subject token supplier must be specified.");if(c&&d)throw Error("Only one of credential source or subject token supplier can be specified.");if(d)this.subjectTokenSupplier=d,this.credentialSourceType="programmatic";else{const a=(0,e.originalOrCamelOptions)(c),b=(0,e.originalOrCamelOptions)(a.get("format")),d=b.get("type")||"text",i=b.get("subject_token_field_name");if("json"!==d&&"text"!==d)throw Error(`Invalid credential_source format "${d}"`);if("json"===d&&!i)throw Error("Missing subject_token_field_name for JSON credential_source format");const j=a.get("file"),l=a.get("url"),m=a.get("certificate"),n=a.get("headers");if(j&&l||l&&m||j&&m)throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');if(j)this.credentialSourceType="file",this.subjectTokenSupplier=new f.FileSubjectTokenSupplier({filePath:j,formatType:d,subjectTokenFieldName:i});else if(l)this.credentialSourceType="url",this.subjectTokenSupplier=new g.UrlSubjectTokenSupplier({url:l,formatType:d,subjectTokenFieldName:i,headers:n,additionalGaxiosOptions:k.RETRY_CONFIG});else if(m){this.credentialSourceType="certificate";const a=new h.CertificateSubjectTokenSupplier({useDefaultCertificateConfig:m.use_default_certificate_config,certificateConfigLocation:m.certificate_config_location,trustChainPath:m.trust_chain_path});this.subjectTokenSupplier=a}else throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.')}}async retrieveSubjectToken(){let a=await this.subjectTokenSupplier.getSubjectToken(this.supplierContext);if(this.subjectTokenSupplier instanceof h.CertificateSubjectTokenSupplier){let a=await this.subjectTokenSupplier.createMtlsHttpsAgent();this.stsCredential=new i.StsCredentials({tokenExchangeEndpoint:this.getTokenUrl(),clientAuthentication:this.clientAuth,transporter:new j.Gaxios({agent:a})}),this.transporter=new j.Gaxios({...this.transporter.defaults||{},agent:a})}return a}}b.IdentityPoolClient=k},85113:(a,b,c)=>{"use strict";var d,e,f,g,h,i;Object.defineProperty(b,"__esModule",{value:!0}),b.OAuth2Client=b.ClientAuthentication=b.CertificateFormat=b.CodeChallengeMethod=void 0;let j=c(51596),k=c(11723),l=c(27910),m=c(22559),n=c(90852),o=c(61721),p=c(25072),q=c(24656);(g=d||(b.CodeChallengeMethod=d={})).Plain="plain",g.S256="S256",(h=e||(b.CertificateFormat=e={})).PEM="PEM",h.JWK="JWK",(i=f||(b.ClientAuthentication=f={})).ClientSecretPost="ClientSecretPost",i.ClientSecretBasic="ClientSecretBasic",i.None="None";class r extends p.AuthClient{redirectUri;certificateCache={};certificateExpiry=null;certificateCacheFormat=e.PEM;refreshTokenPromises=new Map;endpoints;issuers;clientAuthentication;_clientId;_clientSecret;refreshHandler;constructor(a={},b,c){super("object"==typeof a?a:{}),"object"!=typeof a&&(a={clientId:a,clientSecret:b,redirectUri:c}),this._clientId=a.clientId||a.client_id,this._clientSecret=a.clientSecret||a.client_secret,this.redirectUri=a.redirectUri||a.redirect_uris?.[0],this.endpoints={tokenInfoUrl:"https://oauth2.googleapis.com/tokeninfo",oauth2AuthBaseUrl:"https://accounts.google.com/o/oauth2/v2/auth",oauth2TokenUrl:"https://oauth2.googleapis.com/token",oauth2RevokeUrl:"https://oauth2.googleapis.com/revoke",oauth2FederatedSignonPemCertsUrl:"https://www.googleapis.com/oauth2/v1/certs",oauth2FederatedSignonJwkCertsUrl:"https://www.googleapis.com/oauth2/v3/certs",oauth2IapPublicKeyUrl:"https://www.gstatic.com/iap/verify/public_key",...a.endpoints},this.clientAuthentication=a.clientAuthentication||f.ClientSecretPost,this.issuers=a.issuers||["accounts.google.com","https://accounts.google.com",this.universeDomain]}static GOOGLE_TOKEN_INFO_URL="https://oauth2.googleapis.com/tokeninfo";static CLOCK_SKEW_SECS_=300;static DEFAULT_MAX_TOKEN_LIFETIME_SECS_=86400;generateAuthUrl(a={}){if(a.code_challenge_method&&!a.code_challenge)throw Error("If a code_challenge_method is provided, code_challenge must be included.");return a.response_type=a.response_type||"code",a.client_id=a.client_id||this._clientId,a.redirect_uri=a.redirect_uri||this.redirectUri,Array.isArray(a.scope)&&(a.scope=a.scope.join(" ")),this.endpoints.oauth2AuthBaseUrl.toString()+"?"+k.stringify(a)}generateCodeVerifier(){throw Error("generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.")}async generateCodeVerifierAsync(){let a=(0,o.createCrypto)(),b=a.randomBytesBase64(96).replace(/\+/g,"~").replace(/=/g,"_").replace(/\//g,"-"),c=(await a.sha256DigestBase64(b)).split("=")[0].replace(/\+/g,"-").replace(/\//g,"_");return{codeVerifier:b,codeChallenge:c}}getToken(a,b){let c="string"==typeof a?{code:a}:a;if(!b)return this.getTokenAsync(c);this.getTokenAsync(c).then(a=>b(null,a.tokens,a.res),a=>b(a,null,a.response))}async getTokenAsync(a){let b=this.endpoints.oauth2TokenUrl.toString(),c=new Headers,d={client_id:a.client_id||this._clientId,code_verifier:a.codeVerifier,code:a.code,grant_type:"authorization_code",redirect_uri:a.redirect_uri||this.redirectUri};if(this.clientAuthentication===f.ClientSecretBasic){let a=Buffer.from(`${this._clientId}:${this._clientSecret}`);c.set("authorization",`Basic ${a.toString("base64")}`)}this.clientAuthentication===f.ClientSecretPost&&(d.client_secret=this._clientSecret);let e={...r.RETRY_CONFIG,method:"POST",url:b,data:new URLSearchParams((0,n.removeUndefinedValuesInObject)(d)),headers:c};p.AuthClient.setMethodName(e,"getTokenAsync");let g=await this.transporter.request(e),h=g.data;return g.data&&g.data.expires_in&&(h.expiry_date=new Date().getTime()+1e3*g.data.expires_in,delete h.expires_in),this.emit("tokens",h),{tokens:h,res:g}}async refreshToken(a){if(!a)return this.refreshTokenNoCache(a);if(this.refreshTokenPromises.has(a))return this.refreshTokenPromises.get(a);let b=this.refreshTokenNoCache(a).then(b=>(this.refreshTokenPromises.delete(a),b),b=>{throw this.refreshTokenPromises.delete(a),b});return this.refreshTokenPromises.set(a,b),b}async refreshTokenNoCache(a){let b;if(!a)throw Error("No refresh token is set.");let c=this.endpoints.oauth2TokenUrl.toString(),d={refresh_token:a,client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token"};try{let a={...r.RETRY_CONFIG,method:"POST",url:c,data:new URLSearchParams((0,n.removeUndefinedValuesInObject)(d))};p.AuthClient.setMethodName(a,"refreshTokenNoCache"),b=await this.transporter.request(a)}catch(a){throw a instanceof j.GaxiosError&&"invalid_grant"===a.message&&a.response?.data&&/ReAuth/i.test(a.response.data.error_description)&&(a.message=JSON.stringify(a.response.data)),a}let e=b.data;return b.data&&b.data.expires_in&&(e.expiry_date=new Date().getTime()+1e3*b.data.expires_in,delete e.expires_in),this.emit("tokens",e),{tokens:e,res:b}}refreshAccessToken(a){if(!a)return this.refreshAccessTokenAsync();this.refreshAccessTokenAsync().then(b=>a(null,b.credentials,b.res),a)}async refreshAccessTokenAsync(){let a=await this.refreshToken(this.credentials.refresh_token),b=a.tokens;return b.refresh_token=this.credentials.refresh_token,this.credentials=b,{credentials:this.credentials,res:a.res}}getAccessToken(a){if(!a)return this.getAccessTokenAsync();this.getAccessTokenAsync().then(b=>a(null,b.token,b.res),a)}async getAccessTokenAsync(){if(!(!this.credentials.access_token||this.isTokenExpiring()))return{token:this.credentials.access_token};{if(!this.credentials.refresh_token)if(this.refreshHandler){let a=await this.processAndValidateRefreshHandler();if(a?.access_token)return this.setCredentials(a),{token:this.credentials.access_token}}else throw Error("No refresh token or refresh handler callback is set.");let a=await this.refreshAccessTokenAsync();if(!a.credentials||a.credentials&&!a.credentials.access_token)throw Error("Could not refresh access token.");return{token:a.credentials.access_token,res:a.res}}}async getRequestHeaders(a){return(await this.getRequestMetadataAsync(a)).headers}async getRequestMetadataAsync(a){let b=this.credentials;if(!b.access_token&&!b.refresh_token&&!this.apiKey&&!this.refreshHandler)throw Error("No access, refresh token, API key or refresh handler callback is set.");if(b.access_token&&!this.isTokenExpiring()){b.token_type=b.token_type||"Bearer";let a=new Headers({authorization:b.token_type+" "+b.access_token});return{headers:this.addSharedMetadataHeaders(a)}}if(this.refreshHandler){let a=await this.processAndValidateRefreshHandler();if(a?.access_token){this.setCredentials(a);let b=new Headers({authorization:"Bearer "+this.credentials.access_token});return{headers:this.addSharedMetadataHeaders(b)}}}if(this.apiKey)return{headers:new Headers({"X-Goog-Api-Key":this.apiKey})};let c=null,d=null;try{d=(c=await this.refreshToken(b.refresh_token)).tokens}catch(a){throw a.response&&(403===a.response.status||404===a.response.status)&&(a.message=`Could not refresh access token: ${a.message}`),a}let e=this.credentials;e.token_type=e.token_type||"Bearer",d.refresh_token=e.refresh_token,this.credentials=d;let f=new Headers({authorization:e.token_type+" "+d.access_token});return{headers:this.addSharedMetadataHeaders(f),res:c.res}}static getRevokeTokenUrl(a){return new r().getRevokeTokenURL(a).toString()}getRevokeTokenURL(a){let b=new URL(this.endpoints.oauth2RevokeUrl);return b.searchParams.append("token",a),b}revokeToken(a,b){let c={...r.RETRY_CONFIG,url:this.getRevokeTokenURL(a).toString(),method:"POST"};if(p.AuthClient.setMethodName(c,"revokeToken"),!b)return this.transporter.request(c);this.transporter.request(c).then(a=>b(null,a),b)}revokeCredentials(a){if(!a)return this.revokeCredentialsAsync();this.revokeCredentialsAsync().then(b=>a(null,b),a)}async revokeCredentialsAsync(){let a=this.credentials.access_token;if(this.credentials={},a)return this.revokeToken(a);throw Error("No access token to revoke.")}request(a,b){if(!b)return this.requestAsync(a);this.requestAsync(a).then(a=>b(null,a),a=>b(a,a.response))}async requestAsync(a,b=!1){try{let b=await this.getRequestMetadataAsync();return a.headers=j.Gaxios.mergeHeaders(a.headers),this.addUserProjectAndAuthHeaders(a.headers,b.headers),this.apiKey&&a.headers.set("X-Goog-Api-Key",this.apiKey),await this.transporter.request(a)}catch(d){let c=d.response;if(c){let d=c.status,e=this.credentials&&this.credentials.access_token&&this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure),f=this.credentials&&this.credentials.access_token&&!this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure)&&this.refreshHandler,g=c.config.data instanceof l.Readable,h=401===d||403===d;if(!b&&h&&!g&&e)return await this.refreshAccessTokenAsync(),this.requestAsync(a,!0);if(!b&&h&&!g&&f){let b=await this.processAndValidateRefreshHandler();return b?.access_token&&this.setCredentials(b),this.requestAsync(a,!0)}}throw d}}verifyIdToken(a,b){if(b&&"function"!=typeof b)throw Error("This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.");if(!b)return this.verifyIdTokenAsync(a);this.verifyIdTokenAsync(a).then(a=>b(null,a),b)}async verifyIdTokenAsync(a){if(!a.idToken)throw Error("The verifyIdToken method requires an ID Token");let b=await this.getFederatedSignonCertsAsync();return await this.verifySignedJwtWithCertsAsync(a.idToken,b.certs,a.audience,this.issuers,a.maxExpiry)}async getTokenInfo(a){let{data:b}=await this.transporter.request({...r.RETRY_CONFIG,method:"POST",headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8",authorization:`Bearer ${a}`},url:this.endpoints.tokenInfoUrl.toString()}),c=Object.assign({expiry_date:new Date().getTime()+1e3*b.expires_in,scopes:b.scope.split(" ")},b);return delete c.expires_in,delete c.scope,c}getFederatedSignonCerts(a){if(!a)return this.getFederatedSignonCertsAsync();this.getFederatedSignonCertsAsync().then(b=>a(null,b.certs,b.res),a)}async getFederatedSignonCertsAsync(){let a,b,c=new Date().getTime(),d=(0,o.hasBrowserCrypto)()?e.JWK:e.PEM;if(this.certificateExpiry&&c<this.certificateExpiry.getTime()&&this.certificateCacheFormat===d)return{certs:this.certificateCache,format:d};switch(d){case e.PEM:b=this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();break;case e.JWK:b=this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();break;default:throw Error(`Unsupported certificate format ${d}`)}try{let c={...r.RETRY_CONFIG,url:b};p.AuthClient.setMethodName(c,"getFederatedSignonCertsAsync"),a=await this.transporter.request(c)}catch(a){throw a instanceof Error&&(a.message=`Failed to retrieve verification certificates: ${a.message}`),a}let f=a?.headers.get("cache-control"),g=-1;if(f){let a=/max-age=(?<maxAge>[0-9]+)/.exec(f)?.groups?.maxAge;a&&(g=1e3*Number(a))}let h={};switch(d){case e.PEM:h=a.data;break;case e.JWK:for(let b of a.data.keys)h[b.kid]=b;break;default:throw Error(`Unsupported certificate format ${d}`)}let i=new Date;return this.certificateExpiry=-1===g?null:new Date(i.getTime()+g),this.certificateCache=h,this.certificateCacheFormat=d,{certs:h,format:d,res:a}}getIapPublicKeys(a){if(!a)return this.getIapPublicKeysAsync();this.getIapPublicKeysAsync().then(b=>a(null,b.pubkeys,b.res),a)}async getIapPublicKeysAsync(){let a,b=this.endpoints.oauth2IapPublicKeyUrl.toString();try{let c={...r.RETRY_CONFIG,url:b};p.AuthClient.setMethodName(c,"getIapPublicKeysAsync"),a=await this.transporter.request(c)}catch(a){throw a instanceof Error&&(a.message=`Failed to retrieve verification certificates: ${a.message}`),a}return{pubkeys:a.data,res:a}}verifySignedJwtWithCerts(){throw Error("verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.")}async verifySignedJwtWithCertsAsync(a,b,c,d,e){let f,g,h=(0,o.createCrypto)();e||(e=r.DEFAULT_MAX_TOKEN_LIFETIME_SECS_);let i=a.split(".");if(3!==i.length)throw Error("Wrong number of segments in token: "+a);let j=i[0]+"."+i[1],k=i[2];try{f=JSON.parse(h.decodeBase64StringUtf8(i[0]))}catch(a){throw a instanceof Error&&(a.message=`Can't parse token envelope: ${i[0]}': ${a.message}`),a}if(!f)throw Error("Can't parse token envelope: "+i[0]);try{g=JSON.parse(h.decodeBase64StringUtf8(i[1]))}catch(a){throw a instanceof Error&&(a.message=`Can't parse token payload '${i[0]}`),a}if(!g)throw Error("Can't parse token payload: "+i[1]);if(!Object.prototype.hasOwnProperty.call(b,f.kid))throw Error("No pem found for envelope: "+JSON.stringify(f));let l=b[f.kid];if("ES256"===f.alg&&(k=m.joseToDer(k,"ES256").toString("base64")),!await h.verify(l,j,k))throw Error("Invalid token signature: "+a);if(!g.iat)throw Error("No issue time in token: "+JSON.stringify(g));if(!g.exp)throw Error("No expiration time in token: "+JSON.stringify(g));let n=Number(g.iat);if(isNaN(n))throw Error("iat field using invalid format");let p=Number(g.exp);if(isNaN(p))throw Error("exp field using invalid format");let s=new Date().getTime()/1e3;if(p>=s+e)throw Error("Expiration time too far in future: "+JSON.stringify(g));let t=n-r.CLOCK_SKEW_SECS_,u=p+r.CLOCK_SKEW_SECS_;if(s<t)throw Error("Token used too early, "+s+" < "+t+": "+JSON.stringify(g));if(s>u)throw Error("Token used too late, "+s+" > "+u+": "+JSON.stringify(g));if(d&&0>d.indexOf(g.iss))throw Error("Invalid issuer, expected one of ["+d+"], but got "+g.iss);if(null!=c){let a=g.aud;if(!(c.constructor===Array?c.indexOf(a)>-1:a===c))throw Error("Wrong recipient, payload audience != requiredAudience")}return new q.LoginTicket(f,g)}async processAndValidateRefreshHandler(){if(this.refreshHandler){let a=await this.refreshHandler();if(!a.access_token)throw Error("No access token is returned by the refreshHandler callback.");return a}}isTokenExpiring(){let a=this.credentials.expiry_date;return!!a&&a<=new Date().getTime()+this.eagerRefreshThresholdMillis}}b.OAuth2Client=r},85778:(a,b)=>{"use strict";async function c(a){var b;let c=e(a);if(!a||!a.config||!c&&!a.config.retry)return{shouldRetry:!1};(c=c||{}).currentRetryAttempt=c.currentRetryAttempt||0,c.retry=void 0===c.retry||null===c.retry?3:c.retry,c.httpMethodsToRetry=c.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],c.noResponseRetries=void 0===c.noResponseRetries||null===c.noResponseRetries?2:c.noResponseRetries,c.retryDelayMultiplier=c.retryDelayMultiplier?c.retryDelayMultiplier:2,c.timeOfFirstRequest=c.timeOfFirstRequest?c.timeOfFirstRequest:Date.now(),c.totalTimeout=c.totalTimeout?c.totalTimeout:Number.MAX_SAFE_INTEGER,c.maxRetryDelay=c.maxRetryDelay?c.maxRetryDelay:Number.MAX_SAFE_INTEGER,c.statusCodesToRetry=c.statusCodesToRetry||[[100,199],[408,408],[429,429],[500,599]],a.config.retryConfig=c;let f=c.shouldRetry||d;if(!await f(a))return{shouldRetry:!1,config:a.config};let g=Math.min(((b=c).currentRetryAttempt?0:b.retryDelay??100)+(Math.pow(b.retryDelayMultiplier,b.currentRetryAttempt)-1)/2*1e3,b.totalTimeout-(Date.now()-b.timeOfFirstRequest),b.maxRetryDelay);a.config.retryConfig.currentRetryAttempt+=1;let h=c.retryBackoff?c.retryBackoff(a,g):new Promise(a=>{setTimeout(a,g)});return c.onRetryAttempt&&await c.onRetryAttempt(a),await h,{shouldRetry:!0,config:a.config}}function d(a){let b=e(a);if(a.config.signal?.aborted&&"TimeoutError"!==a.code||"AbortError"===a.code||!b||0===b.retry||!a.response&&(b.currentRetryAttempt||0)>=b.noResponseRetries||!b.httpMethodsToRetry||!b.httpMethodsToRetry.includes(a.config.method?.toUpperCase()||"GET"))return!1;if(a.response&&a.response.status){let c=!1;for(let[d,e]of b.statusCodesToRetry){let b=a.response.status;if(b>=d&&b<=e){c=!0;break}}if(!c)return!1}return b.currentRetryAttempt=b.currentRetryAttempt||0,!(b.currentRetryAttempt>=b.retry)}function e(a){if(a&&a.config&&a.config.retryConfig)return a.config.retryConfig}Object.defineProperty(b,"__esModule",{value:!0}),b.getRetryConfig=c},85977:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.ExternalAccountClient=void 0;let d=c(64876),e=c(84950),f=c(3939),g=c(68423);class h{constructor(){throw Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(a){return a&&a.type===d.EXTERNAL_ACCOUNT_TYPE?a.credential_source?.environment_id?new f.AwsClient(a):a.credential_source?.executable?new g.PluggableAuthClient(a):new e.IdentityPoolClient(a):null}}b.ExternalAccountClient=h},86716:a=>{"use strict";let b=Symbol("kDone"),c=Symbol("kRun");class d{constructor(a){this[b]=()=>{this.pending--,this[c]()},this.concurrency=a||1/0,this.jobs=[],this.pending=0}add(a){this.jobs.push(a),this[c]()}[c](){if(this.pending!==this.concurrency&&this.jobs.length){let a=this.jobs.shift();this.pending++,a(this[b])}}}a.exports=d},87812:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.PassThroughClient=void 0;let d=c(25072);class e extends d.AuthClient{async request(a){return this.transporter.request(a)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}b.PassThroughClient=e},88218:(a,b,c)=>{var d=c(10140).Buffer,e=c(39545),f=c(92704),g=c(27910),h=c(32480),i=c(28354),j=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function k(a){var b=a.split(".",1)[0],c=d.from(b,"base64").toString("binary");if("[object Object]"===Object.prototype.toString.call(c))return c;try{return JSON.parse(c)}catch(a){return}}function l(a){return a.split(".")[2]}function m(a){return j.test(a)&&!!k(a)}function n(a,b,c){if(!b){var d=Error("Missing algorithm parameter for jws.verify");throw d.code="MISSING_ALGORITHM",d}var e=l(a=h(a)),g=a.split(".",2).join(".");return f(b).verify(g,e,c)}function o(a,b){if(b=b||{},!m(a=h(a)))return null;var c,e,f=k(a);if(!f)return null;var g=(c=c||"utf8",e=a.split(".")[1],d.from(e,"base64").toString(c));return("JWT"===f.typ||b.json)&&(g=JSON.parse(g,b.encoding)),{header:f,payload:g,signature:l(a)}}function p(a){var b=(a=a||{}).secret;if(b=null==(b=null==b?a.publicKey:b)?a.key:b,!0===/^hs/i.test(a.algorithm)&&null==b)throw TypeError("secret must be a string or buffer or a KeyObject");var c=new e(b);this.readable=!0,this.algorithm=a.algorithm,this.encoding=a.encoding,this.secret=this.publicKey=this.key=c,this.signature=new e(a.signature),this.secret.once("close",(function(){!this.signature.writable&&this.readable&&this.verify()}).bind(this)),this.signature.once("close",(function(){!this.secret.writable&&this.readable&&this.verify()}).bind(this))}i.inherits(p,g),p.prototype.verify=function(){try{var a=n(this.signature.buffer,this.algorithm,this.key.buffer),b=o(this.signature.buffer,this.encoding);return this.emit("done",a,b),this.emit("data",a),this.emit("end"),this.readable=!1,a}catch(a){this.readable=!1,this.emit("error",a),this.emit("close")}},p.decode=o,p.isValid=m,p.verify=n,a.exports=p},88470:(a,b,c)=>{"use strict";function d(a){return a.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}c.d(b,{J:()=>d})},88711:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.OAuthClientAuthHandler=void 0,b.getErrorFromOAuthErrorResponse=function(a,b){let c=a.error,d=a.error_description,e=a.error_uri,f=`Error code ${c}`;void 0!==d&&(f+=`: ${d}`),void 0!==e&&(f+=` - ${e}`);let g=Error(f);if(b){let a=Object.keys(b);b.stack&&a.push("stack"),a.forEach(a=>{"message"!==a&&Object.defineProperty(g,a,{value:b[a],writable:!1,enumerable:!0})})}return g};let d=c(51596),e=c(61721),f=["PUT","POST","PATCH"];class g{#z=(0,e.createCrypto)();#A;transporter;constructor(a){a&&"clientId"in a?(this.#A=a,this.transporter=new d.Gaxios):(this.#A=a?.clientAuthentication,this.transporter=a?.transporter||new d.Gaxios)}applyClientAuthenticationOptions(a,b){a.headers=d.Gaxios.mergeHeaders(a.headers),this.injectAuthenticatedHeaders(a,b),b||this.injectAuthenticatedRequestBody(a)}injectAuthenticatedHeaders(a,b){if(b)a.headers=d.Gaxios.mergeHeaders(a.headers,{authorization:`Bearer ${b}`});else if(this.#A?.confidentialClientType==="basic"){a.headers=d.Gaxios.mergeHeaders(a.headers);let b=this.#A.clientId,c=this.#A.clientSecret||"",e=this.#z.encodeBase64StringUtf8(`${b}:${c}`);d.Gaxios.mergeHeaders(a.headers,{authorization:`Basic ${e}`})}}injectAuthenticatedRequestBody(a){if(this.#A?.confidentialClientType==="request-body"){let b=(a.method||"GET").toUpperCase();if(!f.includes(b))throw Error(`${b} HTTP method does not support ${this.#A.confidentialClientType} client authentication`);let c=new Headers(a.headers).get("content-type");if(c?.startsWith("application/x-www-form-urlencoded")||a.data instanceof URLSearchParams){let b=new URLSearchParams(a.data??"");b.append("client_id",this.#A.clientId),b.append("client_secret",this.#A.clientSecret||""),a.data=b}else if(c?.startsWith("application/json"))a.data=a.data||{},Object.assign(a.data,{client_id:this.#A.clientId,client_secret:this.#A.clientSecret||""});else throw Error(`${c} content-types are not supported with ${this.#A.confidentialClientType} client authentication`)}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}b.OAuthClientAuthHandler=g},89072:(a,b,c)=>{var d=c(75833).stringify,e=c(65891);a.exports=function(a){return{parse:e(a),stringify:d}},a.exports.parse=e(),a.exports.stringify=d},89420:(a,b,c)=>{a.exports=c(5582)},89721:a=>{"use strict";let b=["nodebuffer","arraybuffer","fragments"],c="u">typeof Blob;c&&b.push("blob"),a.exports={BINARY_TYPES:b,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:c,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},90337:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.fromArrayBufferToHex=function(a){return Array.from(new Uint8Array(a)).map(a=>a.toString(16).padStart(2,"0")).join("")}},90852:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.LRUCache=void 0,b.snakeToCamel=h,b.originalOrCamelOptions=function(a){return{get:function(b){let c=a||{};return c[b]??c[h(b)]}}},b.removeUndefinedValuesInObject=function(a){return Object.entries(a).forEach(([b,c])=>{(void 0===c||"undefined"===c)&&delete a[b]}),a},b.isValidFile=j,b.getWellKnownCertificateConfigFileLocation=function(){let a=process.env.CLOUDSDK_CONFIG||(e.platform().startsWith("win")?f.join(process.env.APPDATA||"",g):f.join(process.env.HOME||"",".config",g));return f.join(a,"certificate_config.json")};let d=c(29021),e=c(21820),f=c(33873),g="gcloud";function h(a){return a.replace(/([_][^_])/g,a=>a.slice(1).toUpperCase())}class i{capacity;#B=new Map;maxAge;constructor(a){this.capacity=a.capacity,this.maxAge=a.maxAge}#C(a,b){this.#B.delete(a),this.#B.set(a,{value:b,lastAccessed:Date.now()})}set(a,b){this.#C(a,b),this.#D()}get(a){let b=this.#B.get(a);if(b)return this.#C(a,b.value),this.#D(),b.value}#D(){let a=this.maxAge?Date.now()-this.maxAge:0,b=this.#B.entries().next();for(;!b.done&&(this.#B.size>this.capacity||b.value[1].lastAccessed<a);)this.#B.delete(b.value[0]),b=this.#B.entries().next()}}async function j(a){try{return(await d.promises.lstat(a)).isFile()}catch(a){return!1}}b.LRUCache=i},91418:a=>{"use strict";function b(a){return(a/8|0)+ +(a%8!=0)}var c={ES256:b(256),ES384:b(384),ES512:b(521)};a.exports=function(a){var b=c[a];if(b)return b;throw Error('Unknown algorithm "'+a+'"')}},91830:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.Colours=void 0;class c{static isEnabled(a){return a&&a.isTTY&&("function"!=typeof a.getColorDepth||a.getColorDepth()>2)}static refresh(){c.enabled=c.isEnabled(null==process?void 0:process.stderr),this.enabled?(c.reset="\x1b[0m",c.bright="\x1b[1m",c.dim="\x1b[2m",c.red="\x1b[31m",c.green="\x1b[32m",c.yellow="\x1b[33m",c.blue="\x1b[34m",c.magenta="\x1b[35m",c.cyan="\x1b[36m",c.white="\x1b[37m",c.grey="\x1b[90m"):(c.reset="",c.bright="",c.dim="",c.red="",c.green="",c.yellow="",c.blue="",c.magenta="",c.cyan="",c.white="",c.grey="")}}b.Colours=c,c.enabled=!1,c.reset="",c.bright="",c.dim="",c.red="",c.green="",c.yellow="",c.blue="",c.magenta="",c.cyan="",c.white="",c.grey="",c.refresh()},92301:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.InvalidSubjectTokenError=b.InvalidMessageFieldError=b.InvalidCodeFieldError=b.InvalidTokenTypeFieldError=b.InvalidExpirationTimeFieldError=b.InvalidSuccessFieldError=b.InvalidVersionFieldError=b.ExecutableResponseError=b.ExecutableResponse=void 0;let c="urn:ietf:params:oauth:token-type:saml2",d="urn:ietf:params:oauth:token-type:id_token",e="urn:ietf:params:oauth:token-type:jwt";class f{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(a){if(!a.version)throw new h("Executable response must contain a 'version' field.");if(void 0===a.success)throw new i("Executable response must contain a 'success' field.");if(this.version=a.version,this.success=a.success,this.success){if(this.expirationTime=a.expiration_time,this.tokenType=a.token_type,this.tokenType!==c&&this.tokenType!==d&&this.tokenType!==e)throw new k(`Executable response must contain a 'token_type' field when successful and it must be one of ${d}, ${e}, or ${c}.`);if(this.tokenType===c){if(!a.saml_response)throw new n(`Executable response must contain a 'saml_response' field when token_type=${c}.`);this.subjectToken=a.saml_response}else{if(!a.id_token)throw new n(`Executable response must contain a 'id_token' field when token_type=${d} or ${e}.`);this.subjectToken=a.id_token}}else{if(!a.code)throw new l("Executable response must contain a 'code' field when unsuccessful.");if(!a.message)throw new m("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=a.code,this.errorMessage=a.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return void 0!==this.expirationTime&&this.expirationTime<Math.round(Date.now()/1e3)}}b.ExecutableResponse=f;class g extends Error{constructor(a){super(a),Object.setPrototypeOf(this,new.target.prototype)}}b.ExecutableResponseError=g;class h extends g{}b.InvalidVersionFieldError=h;class i extends g{}b.InvalidSuccessFieldError=i;class j extends g{}b.InvalidExpirationTimeFieldError=j;class k extends g{}b.InvalidTokenTypeFieldError=k;class l extends g{}b.InvalidCodeFieldError=l;class m extends g{}b.InvalidMessageFieldError=m;class n extends g{}b.InvalidSubjectTokenError=n},92704:(a,b,c)=>{var d,e=c(10140).Buffer,f=c(55511),g=c(22559),h=c(28354),i="secret must be a string or buffer",j="key must be a string or a buffer",k="function"==typeof f.createPublicKey;function l(a){if(!e.isBuffer(a)&&"string"!=typeof a&&(!k||"object"!=typeof a||"string"!=typeof a.type||"string"!=typeof a.asymmetricKeyType||"function"!=typeof a.export))throw p(j)}function m(a){if(!e.isBuffer(a)&&"string"!=typeof a&&"object"!=typeof a)throw p("key must be a string, a buffer or an object")}function n(a){return a.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function o(a){var b=4-(a=a.toString()).length%4;if(4!==b)for(var c=0;c<b;++c)a+="=";return a.replace(/\-/g,"+").replace(/_/g,"/")}function p(a){var b=[].slice.call(arguments,1);return TypeError(h.format.bind(h,a).apply(null,b))}function q(a){var b;return b=a,e.isBuffer(b)||"string"==typeof b||(a=JSON.stringify(a)),a}function r(a){return function(b,c){!function(a){if(!e.isBuffer(a)){if("string"!=typeof a){if(!k||"object"!=typeof a||"secret"!==a.type||"function"!=typeof a.export)throw p(i)}}}(c),b=q(b);var d=f.createHmac("sha"+a,c);return n((d.update(b),d.digest("base64")))}}k&&(j+=" or a KeyObject",i+="or a KeyObject");var s="timingSafeEqual"in f?function(a,b){return a.byteLength===b.byteLength&&f.timingSafeEqual(a,b)}:function(a,b){return d||(d=c(64762)),d(a,b)};function t(a){return function(b,c,d){var f=r(a)(b,d);return s(e.from(c),e.from(f))}}function u(a){return function(b,c){m(c),b=q(b);var d=f.createSign("RSA-SHA"+a);return n((d.update(b),d.sign(c,"base64")))}}function v(a){return function(b,c,d){l(d),b=q(b),c=o(c);var e=f.createVerify("RSA-SHA"+a);return e.update(b),e.verify(d,c,"base64")}}function w(a){return function(b,c){m(c),b=q(b);var d=f.createSign("RSA-SHA"+a);return n((d.update(b),d.sign({key:c,padding:f.constants.RSA_PKCS1_PSS_PADDING,saltLength:f.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function x(a){return function(b,c,d){l(d),b=q(b),c=o(c);var e=f.createVerify("RSA-SHA"+a);return e.update(b),e.verify({key:d,padding:f.constants.RSA_PKCS1_PSS_PADDING,saltLength:f.constants.RSA_PSS_SALTLEN_DIGEST},c,"base64")}}function y(a){var b=u(a);return function(){var c=b.apply(null,arguments);return g.derToJose(c,"ES"+a)}}function z(a){var b=v(a);return function(c,d,e){return b(c,d=g.joseToDer(d,"ES"+a).toString("base64"),e)}}function A(){return function(){return""}}function B(){return function(a,b){return""===b}}a.exports=function(a){var b=a.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!b)throw p('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',a);var c=(b[1]||b[3]).toLowerCase(),d=b[2];return{sign:({hs:r,rs:u,ps:w,es:y,none:A})[c](d),verify:({hs:t,rs:v,ps:x,es:z,none:B})[c](d)}}},93959:(a,b,c)=>{"use strict";let{Writable:d}=c(27910),e=c(49478),{BINARY_TYPES:f,EMPTY_BUFFER:g,kStatusCode:h,kWebSocket:i}=c(89721),{concat:j,toArrayBuffer:k,unmask:l}=c(14669),{isValidStatusCode:m,isValidUTF8:n}=c(45633),o=Buffer[Symbol.species];class p extends d{constructor(a={}){super(),this._allowSynchronousEvents=void 0===a.allowSynchronousEvents||a.allowSynchronousEvents,this._binaryType=a.binaryType||f[0],this._extensions=a.extensions||{},this._isServer=!!a.isServer,this._maxBufferedChunks=0|a.maxBufferedChunks,this._maxFragments=0|a.maxFragments,this._maxPayload=0|a.maxPayload,this._skipUTF8Validation=!!a.skipUTF8Validation,this[i]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(a,b,c){return 8===this._opcode&&0==this._state?c():this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks?void c(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS")):void(this._bufferedBytes+=a.length,this._buffers.push(a),this.startLoop(c))}consume(a){if(this._bufferedBytes-=a,a===this._buffers[0].length)return this._buffers.shift();if(a<this._buffers[0].length){let b=this._buffers[0];return this._buffers[0]=new o(b.buffer,b.byteOffset+a,b.length-a),new o(b.buffer,b.byteOffset,a)}let b=Buffer.allocUnsafe(a);do{let c=this._buffers[0],d=b.length-a;a>=c.length?b.set(this._buffers.shift(),d):(b.set(new Uint8Array(c.buffer,c.byteOffset,a),d),this._buffers[0]=new o(c.buffer,c.byteOffset+a,c.length-a)),a-=c.length}while(a>0);return b}startLoop(a){this._loop=!0;do switch(this._state){case 0:this.getInfo(a);break;case 1:this.getPayloadLength16(a);break;case 2:this.getPayloadLength64(a);break;case 3:this.getMask();break;case 4:this.getData(a);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||a()}getInfo(a){if(this._bufferedBytes<2){this._loop=!1;return}let b=this.consume(2);if((48&b[0])!=0)return void a(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"));let c=(64&b[0])==64;if(c&&!this._extensions[e.extensionName])return void a(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._fin=(128&b[0])==128,this._opcode=15&b[0],this._payloadLength=127&b[1],0===this._opcode){if(c)return void a(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(!this._fragmented)return void a(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"));this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return void a(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));this._compressed=c}else{if(!(this._opcode>7)||!(this._opcode<11))return void a(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));if(!this._fin)return void a(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"));if(c)return void a(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return void a(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=(128&b[1])==128,this._isServer){if(!this._masked)return void a(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}else if(this._masked)return void a(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"));126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(a)}getPayloadLength16(a){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(a)}getPayloadLength64(a){if(this._bufferedBytes<8){this._loop=!1;return}let b=this.consume(8),c=b.readUInt32BE(0);c>2097151?a(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=0x100000000*c+b.readUInt32BE(4),this.haveLength(a))}haveLength(a){this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)?a(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")):this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(a){let b=g;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}b=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!=0&&l(b,this._mask)}if(this._opcode>7)return void this.controlMessage(b,a);if(this._compressed){this._state=5,this.decompress(b,a);return}if(b.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void a(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._messageLength=this._totalPayloadLength,this._fragments.push(b)}this.dataMessage(a)}decompress(a,b){this._extensions[e.extensionName].decompress(a,this._fin,(a,c)=>{if(a)return b(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return void b(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void b(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._fragments.push(c)}this.dataMessage(b),0===this._state&&this.startLoop(b)})}dataMessage(a){if(!this._fin){this._state=0;return}let b=this._messageLength,c=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let d;d="nodebuffer"===this._binaryType?j(c,b):"arraybuffer"===this._binaryType?k(j(c,b)):"blob"===this._binaryType?new Blob(c):c,this._allowSynchronousEvents?(this.emit("message",d,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",d,!0),this._state=0,this.startLoop(a)}))}else{let d=j(c,b);if(!this._skipUTF8Validation&&!n(d))return void a(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));5===this._state||this._allowSynchronousEvents?(this.emit("message",d,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",d,!1),this._state=0,this.startLoop(a)}))}}controlMessage(a,b){if(8===this._opcode){if(0===a.length)this._loop=!1,this.emit("conclude",1005,g),this.end();else{let c=a.readUInt16BE(0);if(!m(c))return void b(this.createError(RangeError,`invalid status code ${c}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE"));let d=new o(a.buffer,a.byteOffset+2,a.length-2);if(!this._skipUTF8Validation&&!n(d))return void b(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));this._loop=!1,this.emit("conclude",c,d),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",a),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",a),this._state=0,this.startLoop(b)}))}createError(a,b,c,d,e){this._loop=!1,this._errored=!0;let f=new a(c?`Invalid WebSocket frame: ${b}`:b);return Error.captureStackTrace(f,this.createError),f.code=e,f[h]=d,f}}a.exports=p},95954:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.ExternalAccountAuthorizedUserClient=b.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;let d=c(25072),e=c(88711),f=c(51596),g=c(27910),h=c(64876);b.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";class i extends e.OAuthClientAuthHandler{#E;constructor(a){super(a),this.#E=a.tokenRefreshEndpoint}async refreshToken(a,b){let c={...i.RETRY_CONFIG,url:this.#E,method:"POST",headers:b,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:a}),responseType:"json"};d.AuthClient.setMethodName(c,"refreshToken"),this.applyClientAuthenticationOptions(c);try{let a=await this.transporter.request(c),b=a.data;return b.res=a,b}catch(a){if(a instanceof f.GaxiosError&&a.response)throw(0,e.getErrorFromOAuthErrorResponse)(a.response.data,a);throw a}}}class j extends d.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(a){super(a),a.universe_domain&&(this.universeDomain=a.universe_domain),this.refreshToken=a.refresh_token;const b={confidentialClientType:"basic",clientId:a.client_id,clientSecret:a.client_secret};this.externalAccountAuthorizedUserHandler=new i({tokenRefreshEndpoint:a.token_url??"https://sts.{universeDomain}/v1/oauthtoken".replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:b}),this.cachedAccessToken=null,this.quotaProjectId=a.quota_project_id,"number"!=typeof a?.eagerRefreshThresholdMillis?this.eagerRefreshThresholdMillis=h.EXPIRATION_TIME_OFFSET:this.eagerRefreshThresholdMillis=a.eagerRefreshThresholdMillis,this.forceRefreshOnFailure=!!a?.forceRefreshOnFailure}async getAccessToken(){return(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let a=await this.getAccessToken(),b=new Headers({authorization:`Bearer ${a.token}`});return this.addSharedMetadataHeaders(b)}request(a,b){if(!b)return this.requestAsync(a);this.requestAsync(a).then(a=>b(null,a),a=>b(a,a.response))}async requestAsync(a,b=!1){let c;try{let b=await this.getRequestHeaders();a.headers=f.Gaxios.mergeHeaders(a.headers),this.addUserProjectAndAuthHeaders(a.headers,b),c=await this.transporter.request(a)}catch(d){let c=d.response;if(c){let d=c.status,e=c.config.data instanceof g.Readable;if(!b&&(401===d||403===d)&&!e&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(a,!0)}throw d}return c}async refreshAccessTokenAsync(){let a=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);return this.cachedAccessToken={access_token:a.access_token,expiry_date:new Date().getTime()+1e3*a.expires_in,res:a.res},void 0!==a.refresh_token&&(this.refreshToken=a.refresh_token),this.cachedAccessToken}isExpired(a){let b=new Date().getTime();return!!a.expiry_date&&b>=a.expiry_date-this.eagerRefreshThresholdMillis}}b.ExternalAccountAuthorizedUserClient=j},98358:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.TokenHandler=void 0;let d=c(58672),e=c(20491);class f{token;tokenExpiresAt;inFlightRequest;tokenOptions;constructor(a){this.tokenOptions=a}async processCredentials(){if(!this.tokenOptions.key&&!this.tokenOptions.keyFile)throw Error("No key or keyFile set.");if(!this.tokenOptions.key&&this.tokenOptions.keyFile){let a=await (0,e.getCredentials)(this.tokenOptions.keyFile);this.tokenOptions.key=a.privateKey,this.tokenOptions.email=a.clientEmail}}isTokenExpiring(){if(!this.token||!this.tokenExpiresAt)return!0;let a=new Date().getTime(),b=this.tokenOptions.eagerRefreshThresholdMillis??0;return this.tokenExpiresAt<=a+b}hasExpired(){return new Date().getTime(),!this.token||!this.tokenExpiresAt||new Date().getTime()>=this.tokenExpiresAt}async getToken(a){if(await this.processCredentials(),this.inFlightRequest&&!a)return this.inFlightRequest;if(this.token&&!this.isTokenExpiring()&&!a)return this.token;try{this.inFlightRequest=(0,d.getToken)(this.tokenOptions);let a=await this.inFlightRequest;return this.token=a,this.tokenExpiresAt=new Date().getTime()+(a.expires_in??0)*1e3,a}finally{this.inFlightRequest=void 0}}}b.TokenHandler=f},99660:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.IdTokenClient=void 0;let d=c(85113);class e extends d.OAuth2Client{targetAudience;idTokenProvider;constructor(a){super(a),this.targetAudience=a.targetAudience,this.idTokenProvider=a.idTokenProvider}async getRequestMetadataAsync(){if(!this.credentials.id_token||!this.credentials.expiry_date||this.isTokenExpiring()){let a=await this.idTokenProvider.fetchIdToken(this.targetAudience);this.credentials={id_token:a,expiry_date:this.getIdTokenExpiryDate(a)}}return{headers:new Headers({authorization:"Bearer "+this.credentials.id_token})}}getIdTokenExpiryDate(a){let b=a.split(".")[1];if(b)return 1e3*JSON.parse(Buffer.from(b,"base64").toString("ascii")).exp}}b.IdTokenClient=e}};
|