sliccy 2.41.2 → 2.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/ui/assets/__vite-browser-external-CTFk2Lkt.js +1 -0
  2. package/dist/ui/assets/__vite-browser-external-DWqD2dLY.js +1 -0
  3. package/dist/ui/assets/addon-fit-yURJy3qA.js +13 -0
  4. package/dist/ui/assets/{adobe-B289PMn-.js → adobe-CH2L4W6h.js} +1 -1
  5. package/dist/ui/assets/adobe-DEWuHFse.js +1 -0
  6. package/dist/ui/assets/{agent-bridge-VMFIuopH.js → agent-bridge-zA0Ev9gp.js} +1 -1
  7. package/dist/ui/assets/agent-message-to-chat-DTeEu8-L.js +7 -0
  8. package/dist/ui/assets/{anthropic-BNzn9jxd.js → anthropic-C2TXpozA.js} +1 -1
  9. package/dist/ui/assets/anthropic-rJPW2O12.js +39 -0
  10. package/dist/ui/assets/azure-ai-foundry-CaxHzIfg.js +1 -0
  11. package/dist/ui/assets/{azure-openai-WlNLdxb8.js → azure-openai-Bp-0Xcsq.js} +1 -1
  12. package/dist/ui/assets/azure-openai-KAoRKaJ2.js +1 -0
  13. package/dist/ui/assets/{azure-openai-responses-2u29KiQ4.js → azure-openai-responses-D6_PN55T.js} +1 -1
  14. package/dist/ui/assets/azure-openai-responses-DD7oqs8R.js +1 -0
  15. package/dist/ui/assets/bedrock-camp-BUaVLUkX.js +5 -0
  16. package/dist/ui/assets/{bedrock-camp-BYUI3MPM.js → bedrock-camp-BdP76xIG.js} +3 -3
  17. package/dist/ui/assets/bsh-watchdog-BPXsh13l.js +42 -0
  18. package/dist/ui/assets/chunk-Cn1BcAw8.js +1 -0
  19. package/dist/ui/assets/cost-command-u41z5zYF.js +1 -0
  20. package/dist/ui/assets/db-Cdoacmjm.js +1 -0
  21. package/dist/ui/assets/diagnostics-DgDchIlf.js +1 -0
  22. package/dist/ui/assets/dist-CdiravWB.js +43 -0
  23. package/dist/ui/assets/dist-Dvfs0thb.js +9 -0
  24. package/dist/ui/assets/es-C_ffrbst.js +36 -0
  25. package/dist/ui/assets/{fs-DGvU58ce.js → fs-C24mGi62.js} +3 -3
  26. package/dist/ui/assets/fs-DNQsNm4m.js +3 -0
  27. package/dist/ui/assets/git-config-CdPD25HI.js +7 -0
  28. package/dist/ui/assets/github-BNbefD1y.js +1 -0
  29. package/dist/ui/assets/{github-BdBT7jQP.js → github-BNgNrxNK.js} +2 -2
  30. package/dist/ui/assets/github-copilot-headers-CnBwk0a7.js +1 -0
  31. package/dist/ui/assets/google-DIN3PdVg.js +1 -0
  32. package/dist/ui/assets/google-shared-D8AVju7J.js +269 -0
  33. package/dist/ui/assets/google-vertex-BNPwBn3T.js +1 -0
  34. package/dist/ui/assets/{google-DXyEIJQt.js → google-w6hFUWTs.js} +1 -1
  35. package/dist/ui/assets/headers-1z24dq00.js +1 -0
  36. package/dist/ui/assets/{index-2YPPqfMe.js → index-DgpEf1ai.js} +4 -4
  37. package/dist/ui/assets/js-realm-worker-CxL23t6B.js +1 -0
  38. package/dist/ui/assets/kernel-worker-CTDGZQ-9.js +7014 -0
  39. package/dist/ui/assets/lick-manager-proxy-CU8QckrD.js +1 -0
  40. package/dist/ui/assets/local-llm-CrY4zo6D.js +2 -0
  41. package/dist/ui/assets/{local-llm-v6E29R0f.js → local-llm-DypPzJOJ.js} +1 -1
  42. package/dist/ui/assets/logger-BHrAkMIS.js +1 -0
  43. package/dist/ui/assets/magick-wasm-2iwpLX2j.js +1 -0
  44. package/dist/ui/assets/mime-types-CtECiBq5.js +1 -0
  45. package/dist/ui/assets/{mistral-DCT8MOLt.js → mistral-C7VnXhNV.js} +1 -1
  46. package/dist/ui/assets/mistral-CpPS-t-f.js +46 -0
  47. package/dist/ui/assets/{mount-DGceyJAY.js → mount-D5v-EQOi.js} +2 -2
  48. package/dist/ui/assets/mount-UPc-Yzt_.js +1 -0
  49. package/dist/ui/assets/mount-id-DTHL0KHy.js +1 -0
  50. package/dist/ui/assets/{nuke-command-B2Cr8yRU.js → nuke-command-Dz3yTV_Q.js} +1 -1
  51. package/dist/ui/assets/oauth-service-BOg00ewY.js +1 -0
  52. package/dist/ui/assets/{offscreen-client-BZcNIg4B.js → offscreen-client-D-03EtPp.js} +1 -1
  53. package/dist/ui/assets/{onboarding-orchestrator-DNrrFQR0.js → onboarding-orchestrator-DYgO_F5N.js} +1 -1
  54. package/dist/ui/assets/openai-BHyrBS3D.js +16 -0
  55. package/dist/ui/assets/{openai-codex-responses-DcX-CN3X.js → openai-codex-responses-0QAdRT8o.js} +1 -1
  56. package/dist/ui/assets/openai-codex-responses-BVWxiojY.js +7 -0
  57. package/dist/ui/assets/{openai-completions-Bew_ZujQ.js → openai-completions-AkqWeeEZ.js} +1 -1
  58. package/dist/ui/assets/openai-completions-CXOhvu4T.js +5 -0
  59. package/dist/ui/assets/openai-responses-BFwC5JqN.js +1 -0
  60. package/dist/ui/assets/{openai-responses-C6R1BTfa.js → openai-responses-BUlnD83Q.js} +1 -1
  61. package/dist/ui/assets/openai-responses-shared-B6jGECcG.js +12 -0
  62. package/dist/ui/assets/{openai-responses-shared-6i2YUTcv.js → openai-responses-shared-B9id-zQc.js} +1 -1
  63. package/dist/ui/assets/pdfjs-Dcpzfrlx.js +54 -0
  64. package/dist/ui/assets/{provider-settings-CZjUI9ty.js → provider-settings-BR2V82gY.js} +2 -2
  65. package/dist/ui/assets/provider-settings-h-kRNJ35.js +90 -0
  66. package/dist/ui/assets/providers-lxjVkr6c.js +1 -0
  67. package/dist/ui/assets/py-realm-worker-BLXn1Tp_.js +23 -0
  68. package/dist/ui/assets/pyodide-C2X7foBW.js +3 -0
  69. package/dist/ui/assets/pyodide-Nsz9RSYM.js +3 -0
  70. package/dist/ui/assets/remote-cache-BSVr74Dp.js +1 -0
  71. package/dist/ui/assets/sanitize-unicode-BzRhXPLL.js +1 -0
  72. package/dist/ui/assets/secret-masking-BMzkw8ZK.js +1 -0
  73. package/dist/ui/assets/{spawn-DPstb7fx.js → spawn-AxN2wGU7.js} +1 -1
  74. package/dist/ui/assets/sprinkle-bridge-channel-DhKQ_srk.js +1 -0
  75. package/dist/ui/assets/sprinkle-proxy-DFfNIL2L.js +1 -0
  76. package/dist/ui/assets/sql-wasm-D1epIc7x.js +2 -0
  77. package/dist/ui/assets/transform-messages-BdxHijhT.js +1 -0
  78. package/dist/ui/assets/upgrade-detection-BlY-hwQ2.js +1 -0
  79. package/dist/ui/assets/xterm-BUXrv9NX.js +48 -0
  80. package/dist/ui/index.html +6 -6
  81. package/dist/ui/packages/webapp/index.html +6 -6
  82. package/package.json +1 -1
  83. package/dist/ui/assets/cost-command-C-iNLlwZ.js +0 -1
  84. package/dist/ui/assets/js-realm-worker-1pc5_MyD.js +0 -1
  85. package/dist/ui/assets/kernel-worker-F5kL1tTL.js +0 -7573
  86. package/dist/ui/assets/py-realm-worker-C_uxhdB2.js +0 -25
@@ -0,0 +1,269 @@
1
+ import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./transform-messages-BdxHijhT.js";import{t as r}from"./sanitize-unicode-BzRhXPLL.js";var i=t(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.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))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),a=t((e=>{var t=i();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),o=t(((e,t)=>{t.exports=a()})),s=e(t(((e,t)=>{let n=o(),r=[`Failed to fetch`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`];var i=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=Error(e),this.originalError.stack=this.stack),this.name=`AbortError`,this.message=e}};let a=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},s=e=>r.includes(e),c=(e,t)=>new Promise((r,o)=>{t={onFailedAttempt:()=>{},retries:10,...t};let c=n.operation(t);c.attempt(async n=>{try{r(await e(n))}catch(e){if(!(e instanceof Error)){o(TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));return}if(e instanceof i)c.stop(),o(e.originalError);else if(e instanceof TypeError&&!s(e.message))c.stop(),o(e);else{a(e,n,t);try{await t.onFailedAttempt(e)}catch(e){o(e);return}c.retry(e)||o(c.mainError())}}})});t.exports=c,t.exports.default=c,t.exports.AbortError=i}))(),1);function c(){return{geminiUrl:void 0,vertexUrl:void 0}}function l(e,t,n,r){if(!e?.baseUrl){let e=c();return t?e.vertexUrl??n:e.geminiUrl??r}return e.baseUrl}
2
+ /**
3
+ * @license
4
+ * Copyright 2025 Google LLC
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ var u=class{};function d(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return e==null?``:String(e)}else throw Error(`Key '${n}' not found in valueMap.`)})}function f(e,t,n){for(let r=0;r<t.length-1;r++){let i=t[r];if(i.endsWith(`[]`)){let a=i.slice(0,-2);if(!(a in e))if(Array.isArray(n))e[a]=Array.from({length:n.length},()=>({}));else throw Error(`Value must be a list given an array path ${i}`);if(Array.isArray(e[a])){let i=e[a];if(Array.isArray(n))for(let e=0;e<i.length;e++){let a=i[e];f(a,t.slice(r+1),n[e])}else for(let e of i)f(e,t.slice(r+1),n)}return}else if(i.endsWith(`[0]`)){let a=i.slice(0,-3);a in e||(e[a]=[{}]);let o=e[a];f(o[0],t.slice(r+1),n);return}(!e[i]||typeof e[i]!=`object`)&&(e[i]={}),e=e[i]}let r=t[t.length-1],i=e[r];if(i!==void 0){if(!n||typeof n==`object`&&Object.keys(n).length===0||n===i)return;if(typeof i==`object`&&typeof n==`object`&&i!==null&&n!==null)Object.assign(i,n);else throw Error(`Cannot set value for an existing key. Key: ${r}`)}else r===`_self`&&typeof n==`object`&&n&&!Array.isArray(n)?Object.assign(e,n):e[r]=n}function p(e,t,n=void 0){try{if(t.length===1&&t[0]===`_self`)return e;for(let r=0;r<t.length;r++){if(typeof e!=`object`||!e)return n;let i=t[r];if(i.endsWith(`[]`)){let a=i.slice(0,-2);if(a in e){let i=e[a];return Array.isArray(i)?i.map(e=>p(e,t.slice(r+1),n)):n}else return n}else e=e[i]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function m(e,t){for(let[n,r]of Object.entries(t)){let t=n.split(`.`),i=r.split(`.`),a=new Set,o=-1;for(let e=0;e<t.length;e++)if(t[e]===`*`){o=e;break}if(o!==-1&&i.length>o)for(let e=o;e<i.length;e++){let t=i[e];t!==`*`&&!t.endsWith(`[]`)&&!t.endsWith(`[0]`)&&a.add(t)}h(e,t,i,0,a)}}function h(e,t,n,r,i){if(r>=t.length||typeof e!=`object`||!e)return;let a=t[r];if(a.endsWith(`[]`)){let o=a.slice(0,-2),s=e;if(o in s&&Array.isArray(s[o]))for(let e of s[o])h(e,t,n,r+1,i)}else if(a===`*`){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,a=Object.keys(t).filter(e=>!e.startsWith(`_`)&&!i.has(e)),o={};for(let e of a)o[e]=t[e];for(let[e,i]of Object.entries(o)){let a=[];for(let t of n.slice(r))t===`*`?a.push(e):a.push(t);f(t,a,i)}for(let e of a)delete t[e]}}else{let o=e;a in o&&h(o[a],t,n,r+1,i)}}
8
+ /**
9
+ * @license
10
+ * Copyright 2025 Google LLC
11
+ * SPDX-License-Identifier: Apache-2.0
12
+ */
13
+ function g(e){if(typeof e!=`string`)throw Error(`fromImageBytes must be a string`);return e}
14
+ /**
15
+ * @license
16
+ * Copyright 2025 Google LLC
17
+ * SPDX-License-Identifier: Apache-2.0
18
+ */
19
+ function _(e){let t={},n=p(e,[`operationName`]);n!=null&&f(t,[`operationName`],n);let r=p(e,[`resourceName`]);return r!=null&&f(t,[`_url`,`resourceName`],r),t}function v(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`metadata`]);r!=null&&f(t,[`metadata`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);a!=null&&f(t,[`error`],a);let o=p(e,[`response`,`generateVideoResponse`]);return o!=null&&f(t,[`response`],b(o)),t}function y(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`metadata`]);r!=null&&f(t,[`metadata`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);a!=null&&f(t,[`error`],a);let o=p(e,[`response`]);return o!=null&&f(t,[`response`],x(o)),t}function b(e){let t={},n=p(e,[`generatedSamples`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>S(e))),f(t,[`generatedVideos`],e)}let r=p(e,[`raiMediaFilteredCount`]);r!=null&&f(t,[`raiMediaFilteredCount`],r);let i=p(e,[`raiMediaFilteredReasons`]);return i!=null&&f(t,[`raiMediaFilteredReasons`],i),t}function x(e){let t={},n=p(e,[`videos`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>C(e))),f(t,[`generatedVideos`],e)}let r=p(e,[`raiMediaFilteredCount`]);r!=null&&f(t,[`raiMediaFilteredCount`],r);let i=p(e,[`raiMediaFilteredReasons`]);return i!=null&&f(t,[`raiMediaFilteredReasons`],i),t}function S(e){let t={},n=p(e,[`video`]);return n!=null&&f(t,[`video`],A(n)),t}function C(e){let t={},n=p(e,[`_self`]);return n!=null&&f(t,[`video`],ee(n)),t}function w(e){let t={},n=p(e,[`operationName`]);return n!=null&&f(t,[`_url`,`operationName`],n),t}function T(e){let t={},n=p(e,[`operationName`]);return n!=null&&f(t,[`_url`,`operationName`],n),t}function E(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`metadata`]);r!=null&&f(t,[`metadata`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);a!=null&&f(t,[`error`],a);let o=p(e,[`response`]);return o!=null&&f(t,[`response`],D(o)),t}function D(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`parent`]);r!=null&&f(t,[`parent`],r);let i=p(e,[`documentName`]);return i!=null&&f(t,[`documentName`],i),t}function O(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`metadata`]);r!=null&&f(t,[`metadata`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);a!=null&&f(t,[`error`],a);let o=p(e,[`response`]);return o!=null&&f(t,[`response`],k(o)),t}function k(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`parent`]);r!=null&&f(t,[`parent`],r);let i=p(e,[`documentName`]);return i!=null&&f(t,[`documentName`],i),t}function A(e){let t={},n=p(e,[`uri`]);n!=null&&f(t,[`uri`],n);let r=p(e,[`encodedVideo`]);r!=null&&f(t,[`videoBytes`],g(r));let i=p(e,[`encoding`]);return i!=null&&f(t,[`mimeType`],i),t}function ee(e){let t={},n=p(e,[`gcsUri`]);n!=null&&f(t,[`uri`],n);let r=p(e,[`bytesBase64Encoded`]);r!=null&&f(t,[`videoBytes`],g(r));let i=p(e,[`mimeType`]);return i!=null&&f(t,[`mimeType`],i),t}
20
+ /**
21
+ * @license
22
+ * Copyright 2025 Google LLC
23
+ * SPDX-License-Identifier: Apache-2.0
24
+ */
25
+ var te;(function(e){e.OUTCOME_UNSPECIFIED=`OUTCOME_UNSPECIFIED`,e.OUTCOME_OK=`OUTCOME_OK`,e.OUTCOME_FAILED=`OUTCOME_FAILED`,e.OUTCOME_DEADLINE_EXCEEDED=`OUTCOME_DEADLINE_EXCEEDED`})(te||={});var ne;(function(e){e.LANGUAGE_UNSPECIFIED=`LANGUAGE_UNSPECIFIED`,e.PYTHON=`PYTHON`})(ne||={});var re;(function(e){e.SCHEDULING_UNSPECIFIED=`SCHEDULING_UNSPECIFIED`,e.SILENT=`SILENT`,e.WHEN_IDLE=`WHEN_IDLE`,e.INTERRUPT=`INTERRUPT`})(re||={});var j;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.STRING=`STRING`,e.NUMBER=`NUMBER`,e.INTEGER=`INTEGER`,e.BOOLEAN=`BOOLEAN`,e.ARRAY=`ARRAY`,e.OBJECT=`OBJECT`,e.NULL=`NULL`})(j||={});var ie;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED=`PHISH_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_HIGH_AND_ABOVE=`BLOCK_HIGH_AND_ABOVE`,e.BLOCK_HIGHER_AND_ABOVE=`BLOCK_HIGHER_AND_ABOVE`,e.BLOCK_VERY_HIGH_AND_ABOVE=`BLOCK_VERY_HIGH_AND_ABOVE`,e.BLOCK_ONLY_EXTREMELY_HIGH=`BLOCK_ONLY_EXTREMELY_HIGH`})(ie||={});var ae;(function(e){e.API_SPEC_UNSPECIFIED=`API_SPEC_UNSPECIFIED`,e.SIMPLE_SEARCH=`SIMPLE_SEARCH`,e.ELASTIC_SEARCH=`ELASTIC_SEARCH`})(ae||={});var oe;(function(e){e.AUTH_TYPE_UNSPECIFIED=`AUTH_TYPE_UNSPECIFIED`,e.NO_AUTH=`NO_AUTH`,e.API_KEY_AUTH=`API_KEY_AUTH`,e.HTTP_BASIC_AUTH=`HTTP_BASIC_AUTH`,e.GOOGLE_SERVICE_ACCOUNT_AUTH=`GOOGLE_SERVICE_ACCOUNT_AUTH`,e.OAUTH=`OAUTH`,e.OIDC_AUTH=`OIDC_AUTH`})(oe||={});var se;(function(e){e.HTTP_IN_UNSPECIFIED=`HTTP_IN_UNSPECIFIED`,e.HTTP_IN_QUERY=`HTTP_IN_QUERY`,e.HTTP_IN_HEADER=`HTTP_IN_HEADER`,e.HTTP_IN_PATH=`HTTP_IN_PATH`,e.HTTP_IN_BODY=`HTTP_IN_BODY`,e.HTTP_IN_COOKIE=`HTTP_IN_COOKIE`})(se||={});var ce;(function(e){e.UNSPECIFIED=`UNSPECIFIED`,e.BLOCKING=`BLOCKING`,e.NON_BLOCKING=`NON_BLOCKING`})(ce||={});var le;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.MODE_DYNAMIC=`MODE_DYNAMIC`})(le||={});var ue;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.AUTO=`AUTO`,e.ANY=`ANY`,e.NONE=`NONE`,e.VALIDATED=`VALIDATED`})(ue||={});var de;(function(e){e.THINKING_LEVEL_UNSPECIFIED=`THINKING_LEVEL_UNSPECIFIED`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`,e.MINIMAL=`MINIMAL`})(de||={});var fe;(function(e){e.HARM_CATEGORY_UNSPECIFIED=`HARM_CATEGORY_UNSPECIFIED`,e.HARM_CATEGORY_HARASSMENT=`HARM_CATEGORY_HARASSMENT`,e.HARM_CATEGORY_HATE_SPEECH=`HARM_CATEGORY_HATE_SPEECH`,e.HARM_CATEGORY_SEXUALLY_EXPLICIT=`HARM_CATEGORY_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_DANGEROUS_CONTENT=`HARM_CATEGORY_DANGEROUS_CONTENT`,e.HARM_CATEGORY_CIVIC_INTEGRITY=`HARM_CATEGORY_CIVIC_INTEGRITY`,e.HARM_CATEGORY_IMAGE_HATE=`HARM_CATEGORY_IMAGE_HATE`,e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT=`HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT`,e.HARM_CATEGORY_IMAGE_HARASSMENT=`HARM_CATEGORY_IMAGE_HARASSMENT`,e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT=`HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_JAILBREAK=`HARM_CATEGORY_JAILBREAK`})(fe||={});var pe;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED=`HARM_BLOCK_METHOD_UNSPECIFIED`,e.SEVERITY=`SEVERITY`,e.PROBABILITY=`PROBABILITY`})(pe||={});var me;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED=`HARM_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`,e.OFF=`OFF`})(me||={});var M;(function(e){e.FINISH_REASON_UNSPECIFIED=`FINISH_REASON_UNSPECIFIED`,e.STOP=`STOP`,e.MAX_TOKENS=`MAX_TOKENS`,e.SAFETY=`SAFETY`,e.RECITATION=`RECITATION`,e.LANGUAGE=`LANGUAGE`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.SPII=`SPII`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.UNEXPECTED_TOOL_CALL=`UNEXPECTED_TOOL_CALL`,e.IMAGE_PROHIBITED_CONTENT=`IMAGE_PROHIBITED_CONTENT`,e.NO_IMAGE=`NO_IMAGE`,e.IMAGE_RECITATION=`IMAGE_RECITATION`,e.IMAGE_OTHER=`IMAGE_OTHER`})(M||={});var he;(function(e){e.HARM_PROBABILITY_UNSPECIFIED=`HARM_PROBABILITY_UNSPECIFIED`,e.NEGLIGIBLE=`NEGLIGIBLE`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(he||={});var ge;(function(e){e.HARM_SEVERITY_UNSPECIFIED=`HARM_SEVERITY_UNSPECIFIED`,e.HARM_SEVERITY_NEGLIGIBLE=`HARM_SEVERITY_NEGLIGIBLE`,e.HARM_SEVERITY_LOW=`HARM_SEVERITY_LOW`,e.HARM_SEVERITY_MEDIUM=`HARM_SEVERITY_MEDIUM`,e.HARM_SEVERITY_HIGH=`HARM_SEVERITY_HIGH`})(ge||={});var _e;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED=`URL_RETRIEVAL_STATUS_UNSPECIFIED`,e.URL_RETRIEVAL_STATUS_SUCCESS=`URL_RETRIEVAL_STATUS_SUCCESS`,e.URL_RETRIEVAL_STATUS_ERROR=`URL_RETRIEVAL_STATUS_ERROR`,e.URL_RETRIEVAL_STATUS_PAYWALL=`URL_RETRIEVAL_STATUS_PAYWALL`,e.URL_RETRIEVAL_STATUS_UNSAFE=`URL_RETRIEVAL_STATUS_UNSAFE`})(_e||={});var ve;(function(e){e.BLOCKED_REASON_UNSPECIFIED=`BLOCKED_REASON_UNSPECIFIED`,e.SAFETY=`SAFETY`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.MODEL_ARMOR=`MODEL_ARMOR`,e.JAILBREAK=`JAILBREAK`})(ve||={});var ye;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED=`TRAFFIC_TYPE_UNSPECIFIED`,e.ON_DEMAND=`ON_DEMAND`,e.PROVISIONED_THROUGHPUT=`PROVISIONED_THROUGHPUT`})(ye||={});var be;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.AUDIO=`AUDIO`})(be||={});var xe;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`})(xe||={});var Se;(function(e){e.TUNING_MODE_UNSPECIFIED=`TUNING_MODE_UNSPECIFIED`,e.TUNING_MODE_FULL=`TUNING_MODE_FULL`,e.TUNING_MODE_PEFT_ADAPTER=`TUNING_MODE_PEFT_ADAPTER`})(Se||={});var Ce;(function(e){e.ADAPTER_SIZE_UNSPECIFIED=`ADAPTER_SIZE_UNSPECIFIED`,e.ADAPTER_SIZE_ONE=`ADAPTER_SIZE_ONE`,e.ADAPTER_SIZE_TWO=`ADAPTER_SIZE_TWO`,e.ADAPTER_SIZE_FOUR=`ADAPTER_SIZE_FOUR`,e.ADAPTER_SIZE_EIGHT=`ADAPTER_SIZE_EIGHT`,e.ADAPTER_SIZE_SIXTEEN=`ADAPTER_SIZE_SIXTEEN`,e.ADAPTER_SIZE_THIRTY_TWO=`ADAPTER_SIZE_THIRTY_TWO`})(Ce||={});var we;(function(e){e.JOB_STATE_UNSPECIFIED=`JOB_STATE_UNSPECIFIED`,e.JOB_STATE_QUEUED=`JOB_STATE_QUEUED`,e.JOB_STATE_PENDING=`JOB_STATE_PENDING`,e.JOB_STATE_RUNNING=`JOB_STATE_RUNNING`,e.JOB_STATE_SUCCEEDED=`JOB_STATE_SUCCEEDED`,e.JOB_STATE_FAILED=`JOB_STATE_FAILED`,e.JOB_STATE_CANCELLING=`JOB_STATE_CANCELLING`,e.JOB_STATE_CANCELLED=`JOB_STATE_CANCELLED`,e.JOB_STATE_PAUSED=`JOB_STATE_PAUSED`,e.JOB_STATE_EXPIRED=`JOB_STATE_EXPIRED`,e.JOB_STATE_UPDATING=`JOB_STATE_UPDATING`,e.JOB_STATE_PARTIALLY_SUCCEEDED=`JOB_STATE_PARTIALLY_SUCCEEDED`})(we||={});var Te;(function(e){e.TUNING_TASK_UNSPECIFIED=`TUNING_TASK_UNSPECIFIED`,e.TUNING_TASK_I2V=`TUNING_TASK_I2V`,e.TUNING_TASK_T2V=`TUNING_TASK_T2V`,e.TUNING_TASK_R2V=`TUNING_TASK_R2V`})(Te||={});var Ee;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`,e.MEDIA_RESOLUTION_ULTRA_HIGH=`MEDIA_RESOLUTION_ULTRA_HIGH`})(Ee||={});var De;(function(e){e.COLLECTION=`COLLECTION`})(De||={});var Oe;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED=`FEATURE_SELECTION_PREFERENCE_UNSPECIFIED`,e.PRIORITIZE_QUALITY=`PRIORITIZE_QUALITY`,e.BALANCED=`BALANCED`,e.PRIORITIZE_COST=`PRIORITIZE_COST`})(Oe||={});var ke;(function(e){e.ENVIRONMENT_UNSPECIFIED=`ENVIRONMENT_UNSPECIFIED`,e.ENVIRONMENT_BROWSER=`ENVIRONMENT_BROWSER`})(ke||={});var Ae;(function(e){e.PROMINENT_PEOPLE_UNSPECIFIED=`PROMINENT_PEOPLE_UNSPECIFIED`,e.ALLOW_PROMINENT_PEOPLE=`ALLOW_PROMINENT_PEOPLE`,e.BLOCK_PROMINENT_PEOPLE=`BLOCK_PROMINENT_PEOPLE`})(Ae||={});var je;(function(e){e.PREDICT=`PREDICT`,e.EMBED_CONTENT=`EMBED_CONTENT`})(je||={});var Me;(function(e){e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`})(Me||={});var Ne;(function(e){e.DONT_ALLOW=`DONT_ALLOW`,e.ALLOW_ADULT=`ALLOW_ADULT`,e.ALLOW_ALL=`ALLOW_ALL`})(Ne||={});var Pe;(function(e){e.auto=`auto`,e.en=`en`,e.ja=`ja`,e.ko=`ko`,e.hi=`hi`,e.zh=`zh`,e.pt=`pt`,e.es=`es`})(Pe||={});var Fe;(function(e){e.MASK_MODE_DEFAULT=`MASK_MODE_DEFAULT`,e.MASK_MODE_USER_PROVIDED=`MASK_MODE_USER_PROVIDED`,e.MASK_MODE_BACKGROUND=`MASK_MODE_BACKGROUND`,e.MASK_MODE_FOREGROUND=`MASK_MODE_FOREGROUND`,e.MASK_MODE_SEMANTIC=`MASK_MODE_SEMANTIC`})(Fe||={});var Ie;(function(e){e.CONTROL_TYPE_DEFAULT=`CONTROL_TYPE_DEFAULT`,e.CONTROL_TYPE_CANNY=`CONTROL_TYPE_CANNY`,e.CONTROL_TYPE_SCRIBBLE=`CONTROL_TYPE_SCRIBBLE`,e.CONTROL_TYPE_FACE_MESH=`CONTROL_TYPE_FACE_MESH`})(Ie||={});var Le;(function(e){e.SUBJECT_TYPE_DEFAULT=`SUBJECT_TYPE_DEFAULT`,e.SUBJECT_TYPE_PERSON=`SUBJECT_TYPE_PERSON`,e.SUBJECT_TYPE_ANIMAL=`SUBJECT_TYPE_ANIMAL`,e.SUBJECT_TYPE_PRODUCT=`SUBJECT_TYPE_PRODUCT`})(Le||={});var Re;(function(e){e.EDIT_MODE_DEFAULT=`EDIT_MODE_DEFAULT`,e.EDIT_MODE_INPAINT_REMOVAL=`EDIT_MODE_INPAINT_REMOVAL`,e.EDIT_MODE_INPAINT_INSERTION=`EDIT_MODE_INPAINT_INSERTION`,e.EDIT_MODE_OUTPAINT=`EDIT_MODE_OUTPAINT`,e.EDIT_MODE_CONTROLLED_EDITING=`EDIT_MODE_CONTROLLED_EDITING`,e.EDIT_MODE_STYLE=`EDIT_MODE_STYLE`,e.EDIT_MODE_BGSWAP=`EDIT_MODE_BGSWAP`,e.EDIT_MODE_PRODUCT_IMAGE=`EDIT_MODE_PRODUCT_IMAGE`})(Re||={});var ze;(function(e){e.FOREGROUND=`FOREGROUND`,e.BACKGROUND=`BACKGROUND`,e.PROMPT=`PROMPT`,e.SEMANTIC=`SEMANTIC`,e.INTERACTIVE=`INTERACTIVE`})(ze||={});var Be;(function(e){e.ASSET=`ASSET`,e.STYLE=`STYLE`})(Be||={});var Ve;(function(e){e.INSERT=`INSERT`,e.REMOVE=`REMOVE`,e.REMOVE_STATIC=`REMOVE_STATIC`,e.OUTPAINT=`OUTPAINT`})(Ve||={});var He;(function(e){e.OPTIMIZED=`OPTIMIZED`,e.LOSSLESS=`LOSSLESS`})(He||={});var Ue;(function(e){e.SUPERVISED_FINE_TUNING=`SUPERVISED_FINE_TUNING`,e.PREFERENCE_TUNING=`PREFERENCE_TUNING`,e.DISTILLATION=`DISTILLATION`})(Ue||={});var We;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.STATE_PENDING=`STATE_PENDING`,e.STATE_ACTIVE=`STATE_ACTIVE`,e.STATE_FAILED=`STATE_FAILED`})(We||={});var Ge;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.PROCESSING=`PROCESSING`,e.ACTIVE=`ACTIVE`,e.FAILED=`FAILED`})(Ge||={});var Ke;(function(e){e.SOURCE_UNSPECIFIED=`SOURCE_UNSPECIFIED`,e.UPLOADED=`UPLOADED`,e.GENERATED=`GENERATED`,e.REGISTERED=`REGISTERED`})(Ke||={});var qe;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED=`TURN_COMPLETE_REASON_UNSPECIFIED`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.RESPONSE_REJECTED=`RESPONSE_REJECTED`,e.NEED_MORE_INPUT=`NEED_MORE_INPUT`})(qe||={});var Je;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.VIDEO=`VIDEO`,e.AUDIO=`AUDIO`,e.DOCUMENT=`DOCUMENT`})(Je||={});var Ye;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED=`VAD_SIGNAL_TYPE_UNSPECIFIED`,e.VAD_SIGNAL_TYPE_SOS=`VAD_SIGNAL_TYPE_SOS`,e.VAD_SIGNAL_TYPE_EOS=`VAD_SIGNAL_TYPE_EOS`})(Ye||={});var Xe;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.ACTIVITY_START=`ACTIVITY_START`,e.ACTIVITY_END=`ACTIVITY_END`})(Xe||={});var Ze;(function(e){e.START_SENSITIVITY_UNSPECIFIED=`START_SENSITIVITY_UNSPECIFIED`,e.START_SENSITIVITY_HIGH=`START_SENSITIVITY_HIGH`,e.START_SENSITIVITY_LOW=`START_SENSITIVITY_LOW`})(Ze||={});var Qe;(function(e){e.END_SENSITIVITY_UNSPECIFIED=`END_SENSITIVITY_UNSPECIFIED`,e.END_SENSITIVITY_HIGH=`END_SENSITIVITY_HIGH`,e.END_SENSITIVITY_LOW=`END_SENSITIVITY_LOW`})(Qe||={});var $e;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED=`ACTIVITY_HANDLING_UNSPECIFIED`,e.START_OF_ACTIVITY_INTERRUPTS=`START_OF_ACTIVITY_INTERRUPTS`,e.NO_INTERRUPTION=`NO_INTERRUPTION`})($e||={});var et;(function(e){e.TURN_COVERAGE_UNSPECIFIED=`TURN_COVERAGE_UNSPECIFIED`,e.TURN_INCLUDES_ONLY_ACTIVITY=`TURN_INCLUDES_ONLY_ACTIVITY`,e.TURN_INCLUDES_ALL_INPUT=`TURN_INCLUDES_ALL_INPUT`})(et||={});var tt;(function(e){e.SCALE_UNSPECIFIED=`SCALE_UNSPECIFIED`,e.C_MAJOR_A_MINOR=`C_MAJOR_A_MINOR`,e.D_FLAT_MAJOR_B_FLAT_MINOR=`D_FLAT_MAJOR_B_FLAT_MINOR`,e.D_MAJOR_B_MINOR=`D_MAJOR_B_MINOR`,e.E_FLAT_MAJOR_C_MINOR=`E_FLAT_MAJOR_C_MINOR`,e.E_MAJOR_D_FLAT_MINOR=`E_MAJOR_D_FLAT_MINOR`,e.F_MAJOR_D_MINOR=`F_MAJOR_D_MINOR`,e.G_FLAT_MAJOR_E_FLAT_MINOR=`G_FLAT_MAJOR_E_FLAT_MINOR`,e.G_MAJOR_E_MINOR=`G_MAJOR_E_MINOR`,e.A_FLAT_MAJOR_F_MINOR=`A_FLAT_MAJOR_F_MINOR`,e.A_MAJOR_G_FLAT_MINOR=`A_MAJOR_G_FLAT_MINOR`,e.B_FLAT_MAJOR_G_MINOR=`B_FLAT_MAJOR_G_MINOR`,e.B_MAJOR_A_FLAT_MINOR=`B_MAJOR_A_FLAT_MINOR`})(tt||={});var nt;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED=`MUSIC_GENERATION_MODE_UNSPECIFIED`,e.QUALITY=`QUALITY`,e.DIVERSITY=`DIVERSITY`,e.VOCALIZATION=`VOCALIZATION`})(nt||={});var rt;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED=`PLAYBACK_CONTROL_UNSPECIFIED`,e.PLAY=`PLAY`,e.PAUSE=`PAUSE`,e.STOP=`STOP`,e.RESET_CONTEXT=`RESET_CONTEXT`})(rt||={});var it=class{constructor(e){let t={};for(let n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}},at=class{get text(){if(this.candidates?.[0]?.content?.parts?.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 e=``,t=!1,n=[];for(let r of this.candidates?.[0]?.content?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&e!==`thoughtSignature`&&(t!==null||t!==void 0)&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){if(this.candidates?.[0]?.content?.parts?.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 e=``,t=[];for(let n of this.candidates?.[0]?.content?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&(r!==null||r!==void 0)&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}get functionCalls(){if(this.candidates?.[0]?.content?.parts?.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 e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>e!==void 0);if(e?.length!==0)return e}get executableCode(){if(this.candidates?.[0]?.content?.parts?.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 e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.code}get codeExecutionResult(){if(this.candidates?.[0]?.content?.parts?.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 e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.output}},ot=class{},st=class{},ct=class{},lt=class{},ut=class{},dt=class{},ft=class{},pt=class{},mt=class{},ht=class{},gt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i,a=t;return i=n?y(a):v(a),Object.assign(r,i),r}},_t=class{},vt=class{},yt=class{},bt=class{},xt=class{},St=class{},Ct=class{},wt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=E(t);return Object.assign(r,i),r}},Tt=class{},Et=class{},Dt=class{},Ot=class{},kt=class{},At=class{get text(){let e=``,t=!1,n=[];for(let r of this.serverContent?.modelTurn?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&t!==null&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){let e=``,t=[];for(let n of this.serverContent?.modelTurn?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&r!==null&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}},jt=class{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}},Mt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=O(t);return Object.assign(r,i),r}};
26
+ /**
27
+ * @license
28
+ * Copyright 2025 Google LLC
29
+ * SPDX-License-Identifier: Apache-2.0
30
+ */
31
+ function N(e,t){if(!t||typeof t!=`string`)throw Error(`model is required and must be a string`);if(t.includes(`..`)||t.includes(`?`)||t.includes(`&`))throw Error(`invalid model parameter`);if(e.isVertexAI()){if(t.startsWith(`publishers/`)||t.startsWith(`projects/`)||t.startsWith(`models/`))return t;if(t.indexOf(`/`)>=0){let e=t.split(`/`,2);return`publishers/${e[0]}/models/${e[1]}`}else return`publishers/google/models/${t}`}else if(t.startsWith(`models/`)||t.startsWith(`tunedModels/`))return t;else return`models/${t}`}function Nt(e,t){let n=N(e,t);return n?n.startsWith(`publishers/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith(`models/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:``}function Pt(e){return Array.isArray(e)?e.map(e=>Ft(e)):[Ft(e)]}function Ft(e){if(typeof e==`object`&&e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function It(e){let t=Ft(e);if(t.mimeType&&t.mimeType.startsWith(`image/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Lt(e){let t=Ft(e);if(t.mimeType&&t.mimeType.startsWith(`audio/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Rt(e){if(e==null)throw Error(`PartUnion is required`);if(typeof e==`object`)return e;if(typeof e==`string`)return{text:e};throw Error(`Unsupported part type: ${typeof e}`)}function zt(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`PartListUnion is required`);return Array.isArray(e)?e.map(e=>Rt(e)):[Rt(e)]}function Bt(e){return typeof e==`object`&&!!e&&`parts`in e&&Array.isArray(e.parts)}function Vt(e){return typeof e==`object`&&!!e&&`functionCall`in e}function Ht(e){return typeof e==`object`&&!!e&&`functionResponse`in e}function P(e){if(e==null)throw Error(`ContentUnion is required`);return Bt(e)?e:{role:`user`,parts:zt(e)}}function Ut(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=P(e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=P(t);return e.parts&&e.parts.length>0&&e.parts[0].text!==void 0?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>P(e)):[P(t)]}function F(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`contents are required`);if(!Array.isArray(e)){if(Vt(e)||Ht(e))throw Error(`To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them`);return[P(e)]}let t=[],n=[],r=Bt(e[0]);for(let i of e){let e=Bt(i);if(e!=r)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(e)t.push(i);else if(Vt(i)||Ht(i))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 n.push(i)}return r||t.push({role:`user`,parts:zt(n)}),t}function Wt(e,t){e.includes(`null`)&&(t.nullable=!0);let n=e.filter(e=>e!==`null`);if(n.length===1)t.type=Object.values(j).includes(n[0].toUpperCase())?n[0].toUpperCase():j.TYPE_UNSPECIFIED;else{t.anyOf=[];for(let e of n)t.anyOf.push({type:Object.values(j).includes(e.toUpperCase())?e.toUpperCase():j.TYPE_UNSPECIFIED})}}function Gt(e){let t={},n=[`items`],r=[`anyOf`],i=[`properties`];if(e.type&&e.anyOf)throw Error(`type and anyOf cannot be both populated.`);let a=e.anyOf;a!=null&&a.length==2&&(a[0].type===`null`?(t.nullable=!0,e=a[1]):a[1].type===`null`&&(t.nullable=!0,e=a[0])),e.type instanceof Array&&Wt(e.type,t);for(let[a,o]of Object.entries(e))if(o!=null)if(a==`type`){if(o===`null`)throw Error(`type: null can not be the only possible type for the field.`);if(o instanceof Array)continue;t.type=Object.values(j).includes(o.toUpperCase())?o.toUpperCase():j.TYPE_UNSPECIFIED}else if(n.includes(a))t[a]=Gt(o);else if(r.includes(a)){let e=[];for(let n of o){if(n.type==`null`){t.nullable=!0;continue}e.push(Gt(n))}t[a]=e}else if(i.includes(a)){let e={};for(let[t,n]of Object.entries(o))e[t]=Gt(n);t[a]=e}else{if(a===`additionalProperties`)continue;t[a]=o}return t}function Kt(e){return Gt(e)}function qt(e){if(typeof e==`object`)return e;if(typeof e==`string`)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function Jt(e){if(`multiSpeakerVoiceConfig`in e)throw Error(`multiSpeakerVoiceConfig is not supported in the live API.`);return e}function I(e){if(e.functionDeclarations)for(let t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes(`$schema`)?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=Gt(t.parameters)),t.response&&(Object.keys(t.response).includes(`$schema`)?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Gt(t.response));return e}function L(e){if(e==null)throw Error(`tools is required`);if(!Array.isArray(e))throw Error(`tools is required and must be an array of Tools`);let t=[];for(let n of e)t.push(n);return t}function Yt(e,t,n,r=1){let i=!t.startsWith(`${n}/`)&&t.split(`/`).length===r;return e.isVertexAI()?t.startsWith(`projects/`)?t:t.startsWith(`locations/`)?`projects/${e.getProject()}/${t}`:t.startsWith(`${n}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:i?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`:t:i?`${n}/${t}`:t}function R(e,t){if(typeof t!=`string`)throw Error(`name must be a string`);return Yt(e,t,`cachedContents`)}function Xt(e){switch(e){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 e}}function z(e){return g(e)}function Zt(e){return typeof e==`object`&&!!e&&`name`in e}function Qt(e){return typeof e==`object`&&!!e&&`video`in e}function $t(e){return typeof e==`object`&&!!e&&`uri`in e}function en(e){let t;if(Zt(e)&&(t=e.name),!($t(e)&&(t=e.uri,t===void 0))&&!(Qt(e)&&(t=e.video?.uri,t===void 0))){if(typeof e==`string`&&(t=e),t===void 0)throw Error(`Could not extract file name from the provided input.`);if(t.startsWith(`https://`)){let e=t.split(`files/`)[1].match(/[a-z0-9]+/);if(e===null)throw Error(`Could not extract file name from URI ${t}`);t=e[0]}else t.startsWith(`files/`)&&(t=t.split(`files/`)[1]);return t}}function tn(e,t){let n;return n=e.isVertexAI()?t?`publishers/google/models`:`models`:t?`models`:`tunedModels`,n}function nn(e){for(let t of[`models`,`tunedModels`,`publisherModels`])if(rn(e,t))return e[t];return[]}function rn(e,t){return typeof e==`object`&&!!e&&t in e}function an(e,t={}){let n=e,r={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(r.responseJsonSchema=n.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}function on(e,t={}){let n=[],r=new Set;for(let i of e){let e=i.name;if(r.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);r.add(e);let a=an(i,t);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function sn(e,t){let n;if(typeof t==`string`)if(e.isVertexAI())if(t.startsWith(`gs://`))n={format:`jsonl`,gcsUri:[t]};else if(t.startsWith(`bq://`))n={format:`bigquery`,bigqueryUri:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith(`files/`))n={fileName:t};else throw Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw Error(`InlinedRequest[] is not supported in Vertex AI.`);n={inlinedRequests:t}}else n=t;let r=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,i=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||r!==1)throw Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(r>0||i!==1)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function cn(e){if(typeof e!=`string`)return e;let t=e;if(t.startsWith(`gs://`))return{format:`jsonl`,gcsUri:t};if(t.startsWith(`bq://`))return{format:`bigquery`,bigqueryUri:t};throw Error(`Unsupported destination: ${t}`)}function ln(e){if(typeof e!=`object`||!e)return{};let t=e,n=t.inlinedResponses;if(typeof n!=`object`||!n)return e;let r=n.inlinedResponses;if(!Array.isArray(r)||r.length===0)return e;let i=!1;for(let e of r){if(typeof e!=`object`||!e)continue;let t=e.response;if(!(typeof t!=`object`||!t)&&t.embedding!==void 0){i=!0;break}}return i&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function B(e,t){let n=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split(`/`).pop();throw Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split(`/`).pop();if(/^\d+$/.test(n))return n;throw Error(`Invalid batch job name: ${n}.`)}function un(e){let t=e;return t===`BATCH_STATE_UNSPECIFIED`?`JOB_STATE_UNSPECIFIED`:t===`BATCH_STATE_PENDING`?`JOB_STATE_PENDING`:t===`BATCH_STATE_RUNNING`?`JOB_STATE_RUNNING`:t===`BATCH_STATE_SUCCEEDED`?`JOB_STATE_SUCCEEDED`:t===`BATCH_STATE_FAILED`?`JOB_STATE_FAILED`:t===`BATCH_STATE_CANCELLED`?`JOB_STATE_CANCELLED`:t===`BATCH_STATE_EXPIRED`?`JOB_STATE_EXPIRED`:t}function dn(e){return e.includes(`gemini`)&&e!==`gemini-embedding-001`||e.includes(`maas`)}
32
+ /**
33
+ * @license
34
+ * Copyright 2025 Google LLC
35
+ * SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ function fn(e){let t={},n=p(e,[`responsesFile`]);n!=null&&f(t,[`fileName`],n);let r=p(e,[`inlinedResponses`,`inlinedResponses`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Xn(e))),f(t,[`inlinedResponses`],e)}let i=p(e,[`inlinedEmbedContentResponses`,`inlinedResponses`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`inlinedEmbedContentResponses`],e)}return t}function pn(e){let t={},n=p(e,[`predictionsFormat`]);n!=null&&f(t,[`format`],n);let r=p(e,[`gcsDestination`,`outputUriPrefix`]);r!=null&&f(t,[`gcsUri`],r);let i=p(e,[`bigqueryDestination`,`outputUri`]);return i!=null&&f(t,[`bigqueryUri`],i),t}function mn(e){let t={},n=p(e,[`format`]);n!=null&&f(t,[`predictionsFormat`],n);let r=p(e,[`gcsUri`]);r!=null&&f(t,[`gcsDestination`,`outputUriPrefix`],r);let i=p(e,[`bigqueryUri`]);if(i!=null&&f(t,[`bigqueryDestination`,`outputUri`],i),p(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Vertex AI.`);if(p(e,[`inlinedResponses`])!==void 0)throw Error(`inlinedResponses parameter is not supported in Vertex AI.`);if(p(e,[`inlinedEmbedContentResponses`])!==void 0)throw Error(`inlinedEmbedContentResponses parameter is not supported in Vertex AI.`);return t}function hn(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`metadata`,`displayName`]);r!=null&&f(t,[`displayName`],r);let i=p(e,[`metadata`,`state`]);i!=null&&f(t,[`state`],un(i));let a=p(e,[`metadata`,`createTime`]);a!=null&&f(t,[`createTime`],a);let o=p(e,[`metadata`,`endTime`]);o!=null&&f(t,[`endTime`],o);let s=p(e,[`metadata`,`updateTime`]);s!=null&&f(t,[`updateTime`],s);let c=p(e,[`metadata`,`model`]);c!=null&&f(t,[`model`],c);let l=p(e,[`metadata`,`output`]);return l!=null&&f(t,[`dest`],fn(ln(l))),t}function gn(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`displayName`]);r!=null&&f(t,[`displayName`],r);let i=p(e,[`state`]);i!=null&&f(t,[`state`],un(i));let a=p(e,[`error`]);a!=null&&f(t,[`error`],a);let o=p(e,[`createTime`]);o!=null&&f(t,[`createTime`],o);let s=p(e,[`startTime`]);s!=null&&f(t,[`startTime`],s);let c=p(e,[`endTime`]);c!=null&&f(t,[`endTime`],c);let l=p(e,[`updateTime`]);l!=null&&f(t,[`updateTime`],l);let u=p(e,[`model`]);u!=null&&f(t,[`model`],u);let d=p(e,[`inputConfig`]);d!=null&&f(t,[`src`],_n(d));let m=p(e,[`outputConfig`]);m!=null&&f(t,[`dest`],pn(ln(m)));let h=p(e,[`completionStats`]);return h!=null&&f(t,[`completionStats`],h),t}function _n(e){let t={},n=p(e,[`instancesFormat`]);n!=null&&f(t,[`format`],n);let r=p(e,[`gcsSource`,`uris`]);r!=null&&f(t,[`gcsUri`],r);let i=p(e,[`bigquerySource`,`inputUri`]);return i!=null&&f(t,[`bigqueryUri`],i),t}function vn(e,t){let n={};if(p(t,[`format`])!==void 0)throw Error(`format parameter is not supported in Gemini API.`);if(p(t,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(p(t,[`bigqueryUri`])!==void 0)throw Error(`bigqueryUri parameter is not supported in Gemini API.`);let r=p(t,[`fileName`]);r!=null&&f(n,[`fileName`],r);let i=p(t,[`inlinedRequests`]);if(i!=null){let t=i;Array.isArray(t)&&(t=t.map(t=>Yn(e,t))),f(n,[`requests`,`requests`],t)}return n}function yn(e){let t={},n=p(e,[`format`]);n!=null&&f(t,[`instancesFormat`],n);let r=p(e,[`gcsUri`]);r!=null&&f(t,[`gcsSource`,`uris`],r);let i=p(e,[`bigqueryUri`]);if(i!=null&&f(t,[`bigquerySource`,`inputUri`],i),p(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Vertex AI.`);if(p(e,[`inlinedRequests`])!==void 0)throw Error(`inlinedRequests parameter is not supported in Vertex AI.`);return t}function bn(e){let t={},n=p(e,[`data`]);if(n!=null&&f(t,[`data`],n),p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function xn(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],B(e,r)),n}function Sn(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],B(e,r)),n}function Cn(e){let t={},n=p(e,[`content`]);n!=null&&f(t,[`content`],n);let r=p(e,[`citationMetadata`]);r!=null&&f(t,[`citationMetadata`],wn(r));let i=p(e,[`tokenCount`]);i!=null&&f(t,[`tokenCount`],i);let a=p(e,[`finishReason`]);a!=null&&f(t,[`finishReason`],a);let o=p(e,[`groundingMetadata`]);o!=null&&f(t,[`groundingMetadata`],o);let s=p(e,[`avgLogprobs`]);s!=null&&f(t,[`avgLogprobs`],s);let c=p(e,[`index`]);c!=null&&f(t,[`index`],c);let l=p(e,[`logprobsResult`]);l!=null&&f(t,[`logprobsResult`],l);let u=p(e,[`safetyRatings`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`safetyRatings`],e)}let d=p(e,[`urlContextMetadata`]);return d!=null&&f(t,[`urlContextMetadata`],d),t}function wn(e){let t={},n=p(e,[`citationSources`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`citations`],e)}return t}function Tn(e){let t={},n=p(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>rr(e))),f(t,[`parts`],e)}let r=p(e,[`role`]);return r!=null&&f(t,[`role`],r),t}function En(e,t){let n={},r=p(e,[`displayName`]);if(t!==void 0&&r!=null&&f(t,[`batch`,`displayName`],r),p(e,[`dest`])!==void 0)throw Error(`dest parameter is not supported in Gemini API.`);return n}function Dn(e,t){let n={},r=p(e,[`displayName`]);t!==void 0&&r!=null&&f(t,[`displayName`],r);let i=p(e,[`dest`]);return t!==void 0&&i!=null&&f(t,[`outputConfig`],mn(cn(i))),n}function On(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`_url`,`model`],N(e,r));let i=p(t,[`src`]);i!=null&&f(n,[`batch`,`inputConfig`],vn(e,sn(e,i)));let a=p(t,[`config`]);return a!=null&&En(a,n),n}function kn(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`model`],N(e,r));let i=p(t,[`src`]);i!=null&&f(n,[`inputConfig`],yn(sn(e,i)));let a=p(t,[`config`]);return a!=null&&Dn(a,n),n}function An(e,t){let n={},r=p(e,[`displayName`]);return t!==void 0&&r!=null&&f(t,[`batch`,`displayName`],r),n}function jn(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`_url`,`model`],N(e,r));let i=p(t,[`src`]);i!=null&&f(n,[`batch`,`inputConfig`],Rn(e,i));let a=p(t,[`config`]);return a!=null&&An(a,n),n}function Mn(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],B(e,r)),n}function Nn(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],B(e,r)),n}function Pn(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`name`]);r!=null&&f(t,[`name`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);return a!=null&&f(t,[`error`],a),t}function Fn(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`name`]);r!=null&&f(t,[`name`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);return a!=null&&f(t,[`error`],a),t}function In(e,t){let n={},r=p(t,[`contents`]);if(r!=null){let t=Ut(e,r);Array.isArray(t)&&(t=t.map(e=>e)),f(n,[`requests[]`,`request`,`content`],t)}let i=p(t,[`config`]);return i!=null&&(f(n,[`_self`],Ln(i,n)),m(n,{"requests[].*":`requests[].request.*`})),n}function Ln(e,t){let n={},r=p(e,[`taskType`]);t!==void 0&&r!=null&&f(t,[`requests[]`,`taskType`],r);let i=p(e,[`title`]);t!==void 0&&i!=null&&f(t,[`requests[]`,`title`],i);let a=p(e,[`outputDimensionality`]);if(t!==void 0&&a!=null&&f(t,[`requests[]`,`outputDimensionality`],a),p(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(p(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);return n}function Rn(e,t){let n={},r=p(t,[`fileName`]);r!=null&&f(n,[`file_name`],r);let i=p(t,[`inlinedRequests`]);return i!=null&&f(n,[`requests`],In(e,i)),n}function zn(e){let t={};if(p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=p(e,[`fileUri`]);n!=null&&f(t,[`fileUri`],n);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function Bn(e){let t={},n=p(e,[`id`]);n!=null&&f(t,[`id`],n);let r=p(e,[`args`]);r!=null&&f(t,[`args`],r);let i=p(e,[`name`]);if(i!=null&&f(t,[`name`],i),p(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(p(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Vn(e){let t={},n=p(e,[`allowedFunctionNames`]);n!=null&&f(t,[`allowedFunctionNames`],n);let r=p(e,[`mode`]);if(r!=null&&f(t,[`mode`],r),p(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function Hn(e,t,n){let r={},i=p(t,[`systemInstruction`]);n!==void 0&&i!=null&&f(n,[`systemInstruction`],Tn(P(i)));let a=p(t,[`temperature`]);a!=null&&f(r,[`temperature`],a);let o=p(t,[`topP`]);o!=null&&f(r,[`topP`],o);let s=p(t,[`topK`]);s!=null&&f(r,[`topK`],s);let c=p(t,[`candidateCount`]);c!=null&&f(r,[`candidateCount`],c);let l=p(t,[`maxOutputTokens`]);l!=null&&f(r,[`maxOutputTokens`],l);let u=p(t,[`stopSequences`]);u!=null&&f(r,[`stopSequences`],u);let d=p(t,[`responseLogprobs`]);d!=null&&f(r,[`responseLogprobs`],d);let m=p(t,[`logprobs`]);m!=null&&f(r,[`logprobs`],m);let h=p(t,[`presencePenalty`]);h!=null&&f(r,[`presencePenalty`],h);let g=p(t,[`frequencyPenalty`]);g!=null&&f(r,[`frequencyPenalty`],g);let _=p(t,[`seed`]);_!=null&&f(r,[`seed`],_);let v=p(t,[`responseMimeType`]);v!=null&&f(r,[`responseMimeType`],v);let y=p(t,[`responseSchema`]);y!=null&&f(r,[`responseSchema`],Kt(y));let b=p(t,[`responseJsonSchema`]);if(b!=null&&f(r,[`responseJsonSchema`],b),p(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(p(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let x=p(t,[`safetySettings`]);if(n!==void 0&&x!=null){let e=x;Array.isArray(e)&&(e=e.map(e=>ir(e))),f(n,[`safetySettings`],e)}let S=p(t,[`tools`]);if(n!==void 0&&S!=null){let e=L(S);Array.isArray(e)&&(e=e.map(e=>or(I(e)))),f(n,[`tools`],e)}let C=p(t,[`toolConfig`]);if(n!==void 0&&C!=null&&f(n,[`toolConfig`],ar(C)),p(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let w=p(t,[`cachedContent`]);n!==void 0&&w!=null&&f(n,[`cachedContent`],R(e,w));let T=p(t,[`responseModalities`]);T!=null&&f(r,[`responseModalities`],T);let E=p(t,[`mediaResolution`]);E!=null&&f(r,[`mediaResolution`],E);let D=p(t,[`speechConfig`]);if(D!=null&&f(r,[`speechConfig`],qt(D)),p(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let O=p(t,[`thinkingConfig`]);O!=null&&f(r,[`thinkingConfig`],O);let k=p(t,[`imageConfig`]);k!=null&&f(r,[`imageConfig`],Jn(k));let A=p(t,[`enableEnhancedCivicAnswers`]);if(A!=null&&f(r,[`enableEnhancedCivicAnswers`],A),p(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is not supported in Gemini API.`);return r}function Un(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Cn(e))),f(t,[`candidates`],e)}let i=p(e,[`modelVersion`]);i!=null&&f(t,[`modelVersion`],i);let a=p(e,[`promptFeedback`]);a!=null&&f(t,[`promptFeedback`],a);let o=p(e,[`responseId`]);o!=null&&f(t,[`responseId`],o);let s=p(e,[`usageMetadata`]);return s!=null&&f(t,[`usageMetadata`],s),t}function Wn(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],B(e,r)),n}function Gn(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],B(e,r)),n}function Kn(e){let t={};if(p(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=p(e,[`enableWidget`]);return n!=null&&f(t,[`enableWidget`],n),t}function qn(e){let t={},n=p(e,[`searchTypes`]);if(n!=null&&f(t,[`searchTypes`],n),p(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(p(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let r=p(e,[`timeRangeFilter`]);return r!=null&&f(t,[`timeRangeFilter`],r),t}function Jn(e){let t={},n=p(e,[`aspectRatio`]);n!=null&&f(t,[`aspectRatio`],n);let r=p(e,[`imageSize`]);if(r!=null&&f(t,[`imageSize`],r),p(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is not supported in Gemini API.`);if(p(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is not supported in Gemini API.`);if(p(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(p(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);return t}function Yn(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`request`,`model`],N(e,r));let i=p(t,[`contents`]);if(i!=null){let e=F(i);Array.isArray(e)&&(e=e.map(e=>Tn(e))),f(n,[`request`,`contents`],e)}let a=p(t,[`metadata`]);a!=null&&f(n,[`metadata`],a);let o=p(t,[`config`]);return o!=null&&f(n,[`request`,`generationConfig`],Hn(e,o,p(n,[`request`],{}))),n}function Xn(e){let t={},n=p(e,[`response`]);n!=null&&f(t,[`response`],Un(n));let r=p(e,[`metadata`]);r!=null&&f(t,[`metadata`],r);let i=p(e,[`error`]);return i!=null&&f(t,[`error`],i),t}function Zn(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);if(t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i),p(e,[`filter`])!==void 0)throw Error(`filter parameter is not supported in Gemini API.`);return n}function Qn(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i);let a=p(e,[`filter`]);return t!==void 0&&a!=null&&f(t,[`_query`,`filter`],a),n}function $n(e){let t={},n=p(e,[`config`]);return n!=null&&Zn(n,t),t}function er(e){let t={},n=p(e,[`config`]);return n!=null&&Qn(n,t),t}function tr(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`operations`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>hn(e))),f(t,[`batchJobs`],e)}return t}function nr(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`batchPredictionJobs`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>gn(e))),f(t,[`batchJobs`],e)}return t}function rr(e){let t={},n=p(e,[`mediaResolution`]);n!=null&&f(t,[`mediaResolution`],n);let r=p(e,[`codeExecutionResult`]);r!=null&&f(t,[`codeExecutionResult`],r);let i=p(e,[`executableCode`]);i!=null&&f(t,[`executableCode`],i);let a=p(e,[`fileData`]);a!=null&&f(t,[`fileData`],zn(a));let o=p(e,[`functionCall`]);o!=null&&f(t,[`functionCall`],Bn(o));let s=p(e,[`functionResponse`]);s!=null&&f(t,[`functionResponse`],s);let c=p(e,[`inlineData`]);c!=null&&f(t,[`inlineData`],bn(c));let l=p(e,[`text`]);l!=null&&f(t,[`text`],l);let u=p(e,[`thought`]);u!=null&&f(t,[`thought`],u);let d=p(e,[`thoughtSignature`]);d!=null&&f(t,[`thoughtSignature`],d);let m=p(e,[`videoMetadata`]);return m!=null&&f(t,[`videoMetadata`],m),t}function ir(e){let t={},n=p(e,[`category`]);if(n!=null&&f(t,[`category`],n),p(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=p(e,[`threshold`]);return r!=null&&f(t,[`threshold`],r),t}function ar(e){let t={},n=p(e,[`retrievalConfig`]);n!=null&&f(t,[`retrievalConfig`],n);let r=p(e,[`functionCallingConfig`]);return r!=null&&f(t,[`functionCallingConfig`],Vn(r)),t}function or(e){let t={};if(p(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=p(e,[`computerUse`]);n!=null&&f(t,[`computerUse`],n);let r=p(e,[`fileSearch`]);r!=null&&f(t,[`fileSearch`],r);let i=p(e,[`googleSearch`]);i!=null&&f(t,[`googleSearch`],qn(i));let a=p(e,[`codeExecution`]);if(a!=null&&f(t,[`codeExecution`],a),p(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let o=p(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`functionDeclarations`],e)}let s=p(e,[`googleMaps`]);s!=null&&f(t,[`googleMaps`],Kn(s));let c=p(e,[`googleSearchRetrieval`]);c!=null&&f(t,[`googleSearchRetrieval`],c);let l=p(e,[`urlContext`]);l!=null&&f(t,[`urlContext`],l);let u=p(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`mcpServers`],e)}return t}
38
+ /**
39
+ * @license
40
+ * Copyright 2025 Google LLC
41
+ * SPDX-License-Identifier: Apache-2.0
42
+ */
43
+ var V;(function(e){e.PAGED_ITEM_BATCH_JOBS=`batchJobs`,e.PAGED_ITEM_MODELS=`models`,e.PAGED_ITEM_TUNING_JOBS=`tuningJobs`,e.PAGED_ITEM_FILES=`files`,e.PAGED_ITEM_CACHED_CONTENTS=`cachedContents`,e.PAGED_ITEM_FILE_SEARCH_STORES=`fileSearchStores`,e.PAGED_ITEM_DOCUMENTS=`documents`})(V||={});var H=class{constructor(e,t,n,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,r)}init(e,t,n){this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=t?.sdkHttpResponse,this.idxInternal=0;let r={config:{}};r=!n||Object.keys(n).length===0?{config:{}}:typeof n==`object`?Object.assign({},n):n,r.config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=r.config?.pageSize??this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,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(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};let e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error(`No more pages to fetch.`);let e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){return this.params.config?.pageToken!==void 0}},sr=class extends u{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.create=async e=>(this.apiClient.isVertexAI()&&(e.config=this.formatDestination(e.src,e.config)),this.createInternal(e)),this.createEmbeddings=async e=>{if(console.warn(`batches.createEmbeddings() is experimental and may change without notice.`),this.apiClient.isVertexAI())throw Error(`Vertex AI does not support batches.createEmbeddings.`);return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){let t=On(this.apiClient,e),n=t._url,r=d(`{model}:batchGenerateContent`,n),i=t.batch.inputConfig.requests,a=i.requests,o=[];for(let e of a){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let n=t.request;n.systemInstruction=e,t.request=n}o.push(t)}return i.requests=o,delete t.config,delete t._url,delete t._query,{path:r,body:t}}getGcsUri(e){if(typeof e==`string`)return e.startsWith(`gs://`)?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e==`string`)return e.startsWith(`bq://`)?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,t){let n=t?Object.assign({},t):{},r=Date.now().toString();if(n.displayName||=`genaiBatchJob_${r}`,n.dest===void 0){let t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)t.endsWith(`.jsonl`)?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${r}`;else if(i)n.dest=`${i}_dest_${r}`;else throw Error(`Unsupported source for Vertex AI: No GCS or BigQuery URI found.`)}return n}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=kn(this.apiClient,e);return n=d(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>gn(e))}else{let i=On(this.apiClient,e);return n=d(`{model}:batchGenerateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>hn(e))}}async createEmbeddingsInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=jn(this.apiClient,e);return n=d(`{model}:asyncBatchEmbedContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>hn(e))}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Gn(this.apiClient,e);return n=d(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>gn(e))}else{let i=Wn(this.apiClient,e);return n=d(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>hn(e))}}async cancel(e){let t=``,n={};if(this.apiClient.isVertexAI()){let r=Sn(this.apiClient,e);t=d(`batchPredictionJobs/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}else{let r=xn(this.apiClient,e);t=d(`batches/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=er(e);return n=d(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=nr(e),n=new kt;return Object.assign(n,t),n})}else{let i=$n(e);return n=d(`batches`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=tr(e),n=new kt;return Object.assign(n,t),n})}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Nn(this.apiClient,e);return n=d(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Fn(e))}else{let i=Mn(this.apiClient,e);return n=d(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Pn(e))}}};
44
+ /**
45
+ * @license
46
+ * Copyright 2025 Google LLC
47
+ * SPDX-License-Identifier: Apache-2.0
48
+ */
49
+ function cr(e){let t={},n=p(e,[`data`]);if(n!=null&&f(t,[`data`],n),p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function lr(e){let t={},n=p(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Mr(e))),f(t,[`parts`],e)}let r=p(e,[`role`]);return r!=null&&f(t,[`role`],r),t}function ur(e,t){let n={},r=p(e,[`ttl`]);t!==void 0&&r!=null&&f(t,[`ttl`],r);let i=p(e,[`expireTime`]);t!==void 0&&i!=null&&f(t,[`expireTime`],i);let a=p(e,[`displayName`]);t!==void 0&&a!=null&&f(t,[`displayName`],a);let o=p(e,[`contents`]);if(t!==void 0&&o!=null){let e=F(o);Array.isArray(e)&&(e=e.map(e=>lr(e))),f(t,[`contents`],e)}let s=p(e,[`systemInstruction`]);t!==void 0&&s!=null&&f(t,[`systemInstruction`],lr(P(s)));let c=p(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Pr(e))),f(t,[`tools`],e)}let l=p(e,[`toolConfig`]);if(t!==void 0&&l!=null&&f(t,[`toolConfig`],Nr(l)),p(e,[`kmsKeyName`])!==void 0)throw Error(`kmsKeyName parameter is not supported in Gemini API.`);return n}function dr(e,t){let n={},r=p(e,[`ttl`]);t!==void 0&&r!=null&&f(t,[`ttl`],r);let i=p(e,[`expireTime`]);t!==void 0&&i!=null&&f(t,[`expireTime`],i);let a=p(e,[`displayName`]);t!==void 0&&a!=null&&f(t,[`displayName`],a);let o=p(e,[`contents`]);if(t!==void 0&&o!=null){let e=F(o);Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`contents`],e)}let s=p(e,[`systemInstruction`]);t!==void 0&&s!=null&&f(t,[`systemInstruction`],P(s));let c=p(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Fr(e))),f(t,[`tools`],e)}let l=p(e,[`toolConfig`]);t!==void 0&&l!=null&&f(t,[`toolConfig`],l);let u=p(e,[`kmsKeyName`]);return t!==void 0&&u!=null&&f(t,[`encryption_spec`,`kmsKeyName`],u),n}function fr(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`model`],Nt(e,r));let i=p(t,[`config`]);return i!=null&&ur(i,n),n}function pr(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`model`],Nt(e,r));let i=p(t,[`config`]);return i!=null&&dr(i,n),n}function mr(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],R(e,r)),n}function hr(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],R(e,r)),n}function gr(e){let t={},n=p(e,[`sdkHttpResponse`]);return n!=null&&f(t,[`sdkHttpResponse`],n),t}function _r(e){let t={},n=p(e,[`sdkHttpResponse`]);return n!=null&&f(t,[`sdkHttpResponse`],n),t}function vr(e){let t={};if(p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=p(e,[`fileUri`]);n!=null&&f(t,[`fileUri`],n);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function yr(e){let t={},n=p(e,[`id`]);n!=null&&f(t,[`id`],n);let r=p(e,[`args`]);r!=null&&f(t,[`args`],r);let i=p(e,[`name`]);if(i!=null&&f(t,[`name`],i),p(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(p(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function br(e){let t={},n=p(e,[`allowedFunctionNames`]);n!=null&&f(t,[`allowedFunctionNames`],n);let r=p(e,[`mode`]);if(r!=null&&f(t,[`mode`],r),p(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function xr(e){let t={},n=p(e,[`description`]);n!=null&&f(t,[`description`],n);let r=p(e,[`name`]);r!=null&&f(t,[`name`],r);let i=p(e,[`parameters`]);i!=null&&f(t,[`parameters`],i);let a=p(e,[`parametersJsonSchema`]);a!=null&&f(t,[`parametersJsonSchema`],a);let o=p(e,[`response`]);o!=null&&f(t,[`response`],o);let s=p(e,[`responseJsonSchema`]);if(s!=null&&f(t,[`responseJsonSchema`],s),p(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Vertex AI.`);return t}function Sr(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],R(e,r)),n}function Cr(e,t){let n={},r=p(t,[`name`]);return r!=null&&f(n,[`_url`,`name`],R(e,r)),n}function wr(e){let t={};if(p(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=p(e,[`enableWidget`]);return n!=null&&f(t,[`enableWidget`],n),t}function Tr(e){let t={},n=p(e,[`searchTypes`]);if(n!=null&&f(t,[`searchTypes`],n),p(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(p(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let r=p(e,[`timeRangeFilter`]);return r!=null&&f(t,[`timeRangeFilter`],r),t}function Er(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);return t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i),n}function Dr(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);return t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i),n}function Or(e){let t={},n=p(e,[`config`]);return n!=null&&Er(n,t),t}function kr(e){let t={},n=p(e,[`config`]);return n!=null&&Dr(n,t),t}function Ar(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`cachedContents`],e)}return t}function jr(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`cachedContents`],e)}return t}function Mr(e){let t={},n=p(e,[`mediaResolution`]);n!=null&&f(t,[`mediaResolution`],n);let r=p(e,[`codeExecutionResult`]);r!=null&&f(t,[`codeExecutionResult`],r);let i=p(e,[`executableCode`]);i!=null&&f(t,[`executableCode`],i);let a=p(e,[`fileData`]);a!=null&&f(t,[`fileData`],vr(a));let o=p(e,[`functionCall`]);o!=null&&f(t,[`functionCall`],yr(o));let s=p(e,[`functionResponse`]);s!=null&&f(t,[`functionResponse`],s);let c=p(e,[`inlineData`]);c!=null&&f(t,[`inlineData`],cr(c));let l=p(e,[`text`]);l!=null&&f(t,[`text`],l);let u=p(e,[`thought`]);u!=null&&f(t,[`thought`],u);let d=p(e,[`thoughtSignature`]);d!=null&&f(t,[`thoughtSignature`],d);let m=p(e,[`videoMetadata`]);return m!=null&&f(t,[`videoMetadata`],m),t}function Nr(e){let t={},n=p(e,[`retrievalConfig`]);n!=null&&f(t,[`retrievalConfig`],n);let r=p(e,[`functionCallingConfig`]);return r!=null&&f(t,[`functionCallingConfig`],br(r)),t}function Pr(e){let t={};if(p(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=p(e,[`computerUse`]);n!=null&&f(t,[`computerUse`],n);let r=p(e,[`fileSearch`]);r!=null&&f(t,[`fileSearch`],r);let i=p(e,[`googleSearch`]);i!=null&&f(t,[`googleSearch`],Tr(i));let a=p(e,[`codeExecution`]);if(a!=null&&f(t,[`codeExecution`],a),p(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let o=p(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`functionDeclarations`],e)}let s=p(e,[`googleMaps`]);s!=null&&f(t,[`googleMaps`],wr(s));let c=p(e,[`googleSearchRetrieval`]);c!=null&&f(t,[`googleSearchRetrieval`],c);let l=p(e,[`urlContext`]);l!=null&&f(t,[`urlContext`],l);let u=p(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`mcpServers`],e)}return t}function Fr(e){let t={},n=p(e,[`retrieval`]);n!=null&&f(t,[`retrieval`],n);let r=p(e,[`computerUse`]);if(r!=null&&f(t,[`computerUse`],r),p(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Vertex AI.`);let i=p(e,[`googleSearch`]);i!=null&&f(t,[`googleSearch`],i);let a=p(e,[`codeExecution`]);a!=null&&f(t,[`codeExecution`],a);let o=p(e,[`enterpriseWebSearch`]);o!=null&&f(t,[`enterpriseWebSearch`],o);let s=p(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>xr(e))),f(t,[`functionDeclarations`],e)}let c=p(e,[`googleMaps`]);c!=null&&f(t,[`googleMaps`],c);let l=p(e,[`googleSearchRetrieval`]);l!=null&&f(t,[`googleSearchRetrieval`],l);let u=p(e,[`urlContext`]);if(u!=null&&f(t,[`urlContext`],u),p(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Vertex AI.`);return t}function Ir(e,t){let n={},r=p(e,[`ttl`]);t!==void 0&&r!=null&&f(t,[`ttl`],r);let i=p(e,[`expireTime`]);return t!==void 0&&i!=null&&f(t,[`expireTime`],i),n}function Lr(e,t){let n={},r=p(e,[`ttl`]);t!==void 0&&r!=null&&f(t,[`ttl`],r);let i=p(e,[`expireTime`]);return t!==void 0&&i!=null&&f(t,[`expireTime`],i),n}function Rr(e,t){let n={},r=p(t,[`name`]);r!=null&&f(n,[`_url`,`name`],R(e,r));let i=p(t,[`config`]);return i!=null&&Ir(i,n),n}function zr(e,t){let n={},r=p(t,[`name`]);r!=null&&f(n,[`_url`,`name`],R(e,r));let i=p(t,[`config`]);return i!=null&&Lr(i,n),n}
50
+ /**
51
+ * @license
52
+ * Copyright 2025 Google LLC
53
+ * SPDX-License-Identifier: Apache-2.0
54
+ */
55
+ var Br=class extends u{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=pr(this.apiClient,e);return n=d(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=fr(this.apiClient,e);return n=d(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Cr(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Sr(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=hr(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=_r(e),n=new yt;return Object.assign(n,t),n})}else{let i=mr(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=gr(e),n=new yt;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=zr(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Rr(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=kr(e);return n=d(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=jr(e),n=new bt;return Object.assign(n,t),n})}else{let i=Or(e);return n=d(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ar(e),n=new bt;return Object.assign(n,t),n})}}};function Vr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Hr(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function U(e){return this instanceof U?(this.v=e,this):new U(e)}function W(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof U?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function G(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Hr==`function`?Hr(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}
56
+ /**
57
+ * @license
58
+ * Copyright 2025 Google LLC
59
+ * SPDX-License-Identifier: Apache-2.0
60
+ */
61
+ function Ur(e){if(e.candidates==null||e.candidates.length===0)return!1;let t=e.candidates[0]?.content;return t===void 0?!1:Wr(t)}function Wr(e){if(e.parts===void 0||e.parts.length===0)return!1;for(let t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function Gr(e){if(e.length!==0){for(let t of e)if(t.role!==`user`&&t.role!==`model`)throw Error(`Role must be user or model, but got ${t.role}.`)}}function Kr(e){if(e===void 0||e.length===0)return[];let t=[],n=e.length,r=0;for(;r<n;)if(e[r].role===`user`)t.push(e[r]),r++;else{let i=[],a=!0;for(;r<n&&e[r].role===`model`;)i.push(e[r]),a&&!Wr(e[r])&&(a=!1),r++;a?t.push(...i):t.pop()}return t}var qr=class{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new Jr(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}},Jr=class{constructor(e,t,n,r={},i=[]){this.apiClient=e,this.modelsModule=t,this.model=n,this.config=r,this.history=i,this.sendPromise=Promise.resolve(),Gr(i)}async sendMessage(e){await this.sendPromise;let t=P(e.message),n=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});return this.sendPromise=(async()=>{let e=await n,r=e.candidates?.[0]?.content,i=e.automaticFunctionCallingHistory,a=this.getHistory(!0).length,o=[];i!=null&&(o=i.slice(a)??[]);let s=r?[r]:[];this.recordHistory(t,s,o)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),n}async sendMessageStream(e){await this.sendPromise;let t=P(e.message),n=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});this.sendPromise=n.then(()=>void 0).catch(()=>void 0);let r=await n;return this.processStreamResponse(r,t)}getHistory(e=!1){let t=e?Kr(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){return W(this,arguments,function*(){var n,r,i,a;let o=[];try{for(var s=!0,c=G(e),l;l=yield U(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;if(Ur(e)){let t=e.candidates?.[0]?.content;t!==void 0&&o.push(t)}yield yield U(e)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield U(i.call(c)))}finally{if(r)throw r.error}}this.recordHistory(t,o)})}recordHistory(e,t,n){let r=[];t.length>0&&t.every(e=>e.role!==void 0)?r=t:r.push({role:`model`,parts:[]}),n&&n.length>0?this.history.push(...Kr(n)):this.history.push(e),this.history.push(...r)}},Yr=class e extends Error{constructor(t){super(t.message),this.name=`ApiError`,this.status=t.status,Object.setPrototypeOf(this,e.prototype)}};
62
+ /**
63
+ * @license
64
+ * Copyright 2025 Google LLC
65
+ * SPDX-License-Identifier: Apache-2.0
66
+ */
67
+ function Xr(e){let t={},n=p(e,[`file`]);return n!=null&&f(t,[`file`],n),t}function Zr(e){let t={},n=p(e,[`sdkHttpResponse`]);return n!=null&&f(t,[`sdkHttpResponse`],n),t}function Qr(e){let t={},n=p(e,[`name`]);return n!=null&&f(t,[`_url`,`file`],en(n)),t}function $r(e){let t={},n=p(e,[`sdkHttpResponse`]);return n!=null&&f(t,[`sdkHttpResponse`],n),t}function ei(e){let t={},n=p(e,[`name`]);return n!=null&&f(t,[`_url`,`file`],en(n)),t}function ti(e){let t={},n=p(e,[`uris`]);return n!=null&&f(t,[`uris`],n),t}function ni(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);return t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i),n}function ri(e){let t={},n=p(e,[`config`]);return n!=null&&ni(n,t),t}function ii(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`files`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`files`],e)}return t}function ai(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`files`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`files`],e)}return t}
68
+ /**
69
+ * @license
70
+ * Copyright 2025 Google LLC
71
+ * SPDX-License-Identifier: Apache-2.0
72
+ */
73
+ var oi=class extends u{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI())throw Error(`Vertex AI does not support uploading files. You can share files through a GCS bucket.`);return this.apiClient.uploadFile(e.file,e.config).then(e=>e)}async download(e){await this.apiClient.downloadFile(e)}async registerFiles(e){throw Error(`registerFiles is only supported in Node.js environments.`)}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ri(e);return n=d(`files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ii(e),n=new Tt;return Object.assign(n,t),n})}}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Xr(e);return n=d(`upload/v1beta/files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Zr(e),n=new Et;return Object.assign(n,t),n})}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ei(e);return n=d(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Qr(e);return n=d(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=$r(e),n=new Dt;return Object.assign(n,t),n})}}async registerFilesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ti(e);return n=d(`files:register`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=ai(e),n=new Ot;return Object.assign(n,t),n})}}};
74
+ /**
75
+ * @license
76
+ * Copyright 2025 Google LLC
77
+ * SPDX-License-Identifier: Apache-2.0
78
+ */
79
+ function si(e){let t={},n=p(e,[`data`]);if(n!=null&&f(t,[`data`],n),p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function ci(e){let t={},n=p(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>wi(e))),f(t,[`parts`],e)}let r=p(e,[`role`]);return r!=null&&f(t,[`role`],r),t}function li(e){let t={};if(p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=p(e,[`fileUri`]);n!=null&&f(t,[`fileUri`],n);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function ui(e){let t={},n=p(e,[`id`]);n!=null&&f(t,[`id`],n);let r=p(e,[`args`]);r!=null&&f(t,[`args`],r);let i=p(e,[`name`]);if(i!=null&&f(t,[`name`],i),p(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(p(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function di(e){let t={},n=p(e,[`description`]);n!=null&&f(t,[`description`],n);let r=p(e,[`name`]);r!=null&&f(t,[`name`],r);let i=p(e,[`parameters`]);i!=null&&f(t,[`parameters`],i);let a=p(e,[`parametersJsonSchema`]);a!=null&&f(t,[`parametersJsonSchema`],a);let o=p(e,[`response`]);o!=null&&f(t,[`response`],o);let s=p(e,[`responseJsonSchema`]);if(s!=null&&f(t,[`responseJsonSchema`],s),p(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Vertex AI.`);return t}function fi(e){let t={},n=p(e,[`modelSelectionConfig`]);n!=null&&f(t,[`modelConfig`],n);let r=p(e,[`responseJsonSchema`]);r!=null&&f(t,[`responseJsonSchema`],r);let i=p(e,[`audioTimestamp`]);i!=null&&f(t,[`audioTimestamp`],i);let a=p(e,[`candidateCount`]);a!=null&&f(t,[`candidateCount`],a);let o=p(e,[`enableAffectiveDialog`]);o!=null&&f(t,[`enableAffectiveDialog`],o);let s=p(e,[`frequencyPenalty`]);s!=null&&f(t,[`frequencyPenalty`],s);let c=p(e,[`logprobs`]);c!=null&&f(t,[`logprobs`],c);let l=p(e,[`maxOutputTokens`]);l!=null&&f(t,[`maxOutputTokens`],l);let u=p(e,[`mediaResolution`]);u!=null&&f(t,[`mediaResolution`],u);let d=p(e,[`presencePenalty`]);d!=null&&f(t,[`presencePenalty`],d);let m=p(e,[`responseLogprobs`]);m!=null&&f(t,[`responseLogprobs`],m);let h=p(e,[`responseMimeType`]);h!=null&&f(t,[`responseMimeType`],h);let g=p(e,[`responseModalities`]);g!=null&&f(t,[`responseModalities`],g);let _=p(e,[`responseSchema`]);_!=null&&f(t,[`responseSchema`],_);let v=p(e,[`routingConfig`]);v!=null&&f(t,[`routingConfig`],v);let y=p(e,[`seed`]);y!=null&&f(t,[`seed`],y);let b=p(e,[`speechConfig`]);b!=null&&f(t,[`speechConfig`],b);let x=p(e,[`stopSequences`]);x!=null&&f(t,[`stopSequences`],x);let S=p(e,[`temperature`]);S!=null&&f(t,[`temperature`],S);let C=p(e,[`thinkingConfig`]);C!=null&&f(t,[`thinkingConfig`],C);let w=p(e,[`topK`]);w!=null&&f(t,[`topK`],w);let T=p(e,[`topP`]);if(T!=null&&f(t,[`topP`],T),p(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Vertex AI.`);return t}function pi(e){let t={};if(p(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=p(e,[`enableWidget`]);return n!=null&&f(t,[`enableWidget`],n),t}function mi(e){let t={},n=p(e,[`searchTypes`]);if(n!=null&&f(t,[`searchTypes`],n),p(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(p(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let r=p(e,[`timeRangeFilter`]);return r!=null&&f(t,[`timeRangeFilter`],r),t}function hi(e,t){let n={},r=p(e,[`generationConfig`]);t!==void 0&&r!=null&&f(t,[`setup`,`generationConfig`],r);let i=p(e,[`responseModalities`]);t!==void 0&&i!=null&&f(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=p(e,[`temperature`]);t!==void 0&&a!=null&&f(t,[`setup`,`generationConfig`,`temperature`],a);let o=p(e,[`topP`]);t!==void 0&&o!=null&&f(t,[`setup`,`generationConfig`,`topP`],o);let s=p(e,[`topK`]);t!==void 0&&s!=null&&f(t,[`setup`,`generationConfig`,`topK`],s);let c=p(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&f(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=p(e,[`mediaResolution`]);t!==void 0&&l!=null&&f(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=p(e,[`seed`]);t!==void 0&&u!=null&&f(t,[`setup`,`generationConfig`,`seed`],u);let d=p(e,[`speechConfig`]);t!==void 0&&d!=null&&f(t,[`setup`,`generationConfig`,`speechConfig`],Jt(d));let m=p(e,[`thinkingConfig`]);t!==void 0&&m!=null&&f(t,[`setup`,`generationConfig`,`thinkingConfig`],m);let h=p(e,[`enableAffectiveDialog`]);t!==void 0&&h!=null&&f(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],h);let g=p(e,[`systemInstruction`]);t!==void 0&&g!=null&&f(t,[`setup`,`systemInstruction`],ci(P(g)));let _=p(e,[`tools`]);if(t!==void 0&&_!=null){let e=L(_);Array.isArray(e)&&(e=e.map(e=>Ei(I(e)))),f(t,[`setup`,`tools`],e)}let v=p(e,[`sessionResumption`]);t!==void 0&&v!=null&&f(t,[`setup`,`sessionResumption`],Ti(v));let y=p(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&f(t,[`setup`,`inputAudioTranscription`],y);let b=p(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&f(t,[`setup`,`outputAudioTranscription`],b);let x=p(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&f(t,[`setup`,`realtimeInputConfig`],x);let S=p(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&f(t,[`setup`,`contextWindowCompression`],S);let C=p(e,[`proactivity`]);if(t!==void 0&&C!=null&&f(t,[`setup`,`proactivity`],C),p(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);return n}function gi(e,t){let n={},r=p(e,[`generationConfig`]);t!==void 0&&r!=null&&f(t,[`setup`,`generationConfig`],fi(r));let i=p(e,[`responseModalities`]);t!==void 0&&i!=null&&f(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=p(e,[`temperature`]);t!==void 0&&a!=null&&f(t,[`setup`,`generationConfig`,`temperature`],a);let o=p(e,[`topP`]);t!==void 0&&o!=null&&f(t,[`setup`,`generationConfig`,`topP`],o);let s=p(e,[`topK`]);t!==void 0&&s!=null&&f(t,[`setup`,`generationConfig`,`topK`],s);let c=p(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&f(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=p(e,[`mediaResolution`]);t!==void 0&&l!=null&&f(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=p(e,[`seed`]);t!==void 0&&u!=null&&f(t,[`setup`,`generationConfig`,`seed`],u);let d=p(e,[`speechConfig`]);t!==void 0&&d!=null&&f(t,[`setup`,`generationConfig`,`speechConfig`],Jt(d));let m=p(e,[`thinkingConfig`]);t!==void 0&&m!=null&&f(t,[`setup`,`generationConfig`,`thinkingConfig`],m);let h=p(e,[`enableAffectiveDialog`]);t!==void 0&&h!=null&&f(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],h);let g=p(e,[`systemInstruction`]);t!==void 0&&g!=null&&f(t,[`setup`,`systemInstruction`],P(g));let _=p(e,[`tools`]);if(t!==void 0&&_!=null){let e=L(_);Array.isArray(e)&&(e=e.map(e=>Di(I(e)))),f(t,[`setup`,`tools`],e)}let v=p(e,[`sessionResumption`]);t!==void 0&&v!=null&&f(t,[`setup`,`sessionResumption`],v);let y=p(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&f(t,[`setup`,`inputAudioTranscription`],y);let b=p(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&f(t,[`setup`,`outputAudioTranscription`],b);let x=p(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&f(t,[`setup`,`realtimeInputConfig`],x);let S=p(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&f(t,[`setup`,`contextWindowCompression`],S);let C=p(e,[`proactivity`]);t!==void 0&&C!=null&&f(t,[`setup`,`proactivity`],C);let w=p(e,[`explicitVadSignal`]);return t!==void 0&&w!=null&&f(t,[`setup`,`explicitVadSignal`],w),n}function _i(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`setup`,`model`],N(e,r));let i=p(t,[`config`]);return i!=null&&f(n,[`config`],hi(i,n)),n}function vi(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`setup`,`model`],N(e,r));let i=p(t,[`config`]);return i!=null&&f(n,[`config`],gi(i,n)),n}function yi(e){let t={},n=p(e,[`musicGenerationConfig`]);return n!=null&&f(t,[`musicGenerationConfig`],n),t}function bi(e){let t={},n=p(e,[`weightedPrompts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`weightedPrompts`],e)}return t}function xi(e){let t={},n=p(e,[`media`]);if(n!=null){let e=Pt(n);Array.isArray(e)&&(e=e.map(e=>si(e))),f(t,[`mediaChunks`],e)}let r=p(e,[`audio`]);r!=null&&f(t,[`audio`],si(Lt(r)));let i=p(e,[`audioStreamEnd`]);i!=null&&f(t,[`audioStreamEnd`],i);let a=p(e,[`video`]);a!=null&&f(t,[`video`],si(It(a)));let o=p(e,[`text`]);o!=null&&f(t,[`text`],o);let s=p(e,[`activityStart`]);s!=null&&f(t,[`activityStart`],s);let c=p(e,[`activityEnd`]);return c!=null&&f(t,[`activityEnd`],c),t}function Si(e){let t={},n=p(e,[`media`]);if(n!=null){let e=Pt(n);Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`mediaChunks`],e)}let r=p(e,[`audio`]);r!=null&&f(t,[`audio`],Lt(r));let i=p(e,[`audioStreamEnd`]);i!=null&&f(t,[`audioStreamEnd`],i);let a=p(e,[`video`]);a!=null&&f(t,[`video`],It(a));let o=p(e,[`text`]);o!=null&&f(t,[`text`],o);let s=p(e,[`activityStart`]);s!=null&&f(t,[`activityStart`],s);let c=p(e,[`activityEnd`]);return c!=null&&f(t,[`activityEnd`],c),t}function Ci(e){let t={},n=p(e,[`setupComplete`]);n!=null&&f(t,[`setupComplete`],n);let r=p(e,[`serverContent`]);r!=null&&f(t,[`serverContent`],r);let i=p(e,[`toolCall`]);i!=null&&f(t,[`toolCall`],i);let a=p(e,[`toolCallCancellation`]);a!=null&&f(t,[`toolCallCancellation`],a);let o=p(e,[`usageMetadata`]);o!=null&&f(t,[`usageMetadata`],Oi(o));let s=p(e,[`goAway`]);s!=null&&f(t,[`goAway`],s);let c=p(e,[`sessionResumptionUpdate`]);c!=null&&f(t,[`sessionResumptionUpdate`],c);let l=p(e,[`voiceActivityDetectionSignal`]);l!=null&&f(t,[`voiceActivityDetectionSignal`],l);let u=p(e,[`voiceActivity`]);return u!=null&&f(t,[`voiceActivity`],ki(u)),t}function wi(e){let t={},n=p(e,[`mediaResolution`]);n!=null&&f(t,[`mediaResolution`],n);let r=p(e,[`codeExecutionResult`]);r!=null&&f(t,[`codeExecutionResult`],r);let i=p(e,[`executableCode`]);i!=null&&f(t,[`executableCode`],i);let a=p(e,[`fileData`]);a!=null&&f(t,[`fileData`],li(a));let o=p(e,[`functionCall`]);o!=null&&f(t,[`functionCall`],ui(o));let s=p(e,[`functionResponse`]);s!=null&&f(t,[`functionResponse`],s);let c=p(e,[`inlineData`]);c!=null&&f(t,[`inlineData`],si(c));let l=p(e,[`text`]);l!=null&&f(t,[`text`],l);let u=p(e,[`thought`]);u!=null&&f(t,[`thought`],u);let d=p(e,[`thoughtSignature`]);d!=null&&f(t,[`thoughtSignature`],d);let m=p(e,[`videoMetadata`]);return m!=null&&f(t,[`videoMetadata`],m),t}function Ti(e){let t={},n=p(e,[`handle`]);if(n!=null&&f(t,[`handle`],n),p(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function Ei(e){let t={};if(p(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=p(e,[`computerUse`]);n!=null&&f(t,[`computerUse`],n);let r=p(e,[`fileSearch`]);r!=null&&f(t,[`fileSearch`],r);let i=p(e,[`googleSearch`]);i!=null&&f(t,[`googleSearch`],mi(i));let a=p(e,[`codeExecution`]);if(a!=null&&f(t,[`codeExecution`],a),p(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let o=p(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`functionDeclarations`],e)}let s=p(e,[`googleMaps`]);s!=null&&f(t,[`googleMaps`],pi(s));let c=p(e,[`googleSearchRetrieval`]);c!=null&&f(t,[`googleSearchRetrieval`],c);let l=p(e,[`urlContext`]);l!=null&&f(t,[`urlContext`],l);let u=p(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`mcpServers`],e)}return t}function Di(e){let t={},n=p(e,[`retrieval`]);n!=null&&f(t,[`retrieval`],n);let r=p(e,[`computerUse`]);if(r!=null&&f(t,[`computerUse`],r),p(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Vertex AI.`);let i=p(e,[`googleSearch`]);i!=null&&f(t,[`googleSearch`],i);let a=p(e,[`codeExecution`]);a!=null&&f(t,[`codeExecution`],a);let o=p(e,[`enterpriseWebSearch`]);o!=null&&f(t,[`enterpriseWebSearch`],o);let s=p(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>di(e))),f(t,[`functionDeclarations`],e)}let c=p(e,[`googleMaps`]);c!=null&&f(t,[`googleMaps`],c);let l=p(e,[`googleSearchRetrieval`]);l!=null&&f(t,[`googleSearchRetrieval`],l);let u=p(e,[`urlContext`]);if(u!=null&&f(t,[`urlContext`],u),p(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Vertex AI.`);return t}function Oi(e){let t={},n=p(e,[`promptTokenCount`]);n!=null&&f(t,[`promptTokenCount`],n);let r=p(e,[`cachedContentTokenCount`]);r!=null&&f(t,[`cachedContentTokenCount`],r);let i=p(e,[`candidatesTokenCount`]);i!=null&&f(t,[`responseTokenCount`],i);let a=p(e,[`toolUsePromptTokenCount`]);a!=null&&f(t,[`toolUsePromptTokenCount`],a);let o=p(e,[`thoughtsTokenCount`]);o!=null&&f(t,[`thoughtsTokenCount`],o);let s=p(e,[`totalTokenCount`]);s!=null&&f(t,[`totalTokenCount`],s);let c=p(e,[`promptTokensDetails`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`promptTokensDetails`],e)}let l=p(e,[`cacheTokensDetails`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`cacheTokensDetails`],e)}let u=p(e,[`candidatesTokensDetails`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`responseTokensDetails`],e)}let d=p(e,[`toolUsePromptTokensDetails`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`toolUsePromptTokensDetails`],e)}let m=p(e,[`trafficType`]);return m!=null&&f(t,[`trafficType`],m),t}function ki(e){let t={},n=p(e,[`type`]);return n!=null&&f(t,[`voiceActivityType`],n),t}
80
+ /**
81
+ * @license
82
+ * Copyright 2025 Google LLC
83
+ * SPDX-License-Identifier: Apache-2.0
84
+ */
85
+ function Ai(e,t){let n={},r=p(e,[`data`]);if(r!=null&&f(n,[`data`],r),p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let i=p(e,[`mimeType`]);return i!=null&&f(n,[`mimeType`],i),n}function ji(e,t){let n={},r=p(e,[`content`]);r!=null&&f(n,[`content`],r);let i=p(e,[`citationMetadata`]);i!=null&&f(n,[`citationMetadata`],Mi(i));let a=p(e,[`tokenCount`]);a!=null&&f(n,[`tokenCount`],a);let o=p(e,[`finishReason`]);o!=null&&f(n,[`finishReason`],o);let s=p(e,[`groundingMetadata`]);s!=null&&f(n,[`groundingMetadata`],s);let c=p(e,[`avgLogprobs`]);c!=null&&f(n,[`avgLogprobs`],c);let l=p(e,[`index`]);l!=null&&f(n,[`index`],l);let u=p(e,[`logprobsResult`]);u!=null&&f(n,[`logprobsResult`],u);let d=p(e,[`safetyRatings`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`safetyRatings`],e)}let m=p(e,[`urlContextMetadata`]);return m!=null&&f(n,[`urlContextMetadata`],m),n}function Mi(e,t){let n={},r=p(e,[`citationSources`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`citations`],e)}return n}function Ni(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`contents`]);if(a!=null){let e=F(a);Array.isArray(e)&&(e=e.map(e=>e)),f(r,[`contents`],e)}return r}function Pi(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`tokensInfo`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`tokensInfo`],e)}return n}function Fi(e,t){let n={},r=p(e,[`values`]);r!=null&&f(n,[`values`],r);let i=p(e,[`statistics`]);return i!=null&&f(n,[`statistics`],Ii(i)),n}function Ii(e,t){let n={},r=p(e,[`truncated`]);r!=null&&f(n,[`truncated`],r);let i=p(e,[`token_count`]);return i!=null&&f(n,[`tokenCount`],i),n}function Li(e,t){let n={},r=p(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>to(e))),f(n,[`parts`],e)}let i=p(e,[`role`]);return i!=null&&f(n,[`role`],i),n}function Ri(e,t){let n={},r=p(e,[`controlType`]);r!=null&&f(n,[`controlType`],r);let i=p(e,[`enableControlImageComputation`]);return i!=null&&f(n,[`computeControl`],i),n}function zi(e,t){let n={};if(p(e,[`systemInstruction`])!==void 0)throw Error(`systemInstruction parameter is not supported in Gemini API.`);if(p(e,[`tools`])!==void 0)throw Error(`tools parameter is not supported in Gemini API.`);if(p(e,[`generationConfig`])!==void 0)throw Error(`generationConfig parameter is not supported in Gemini API.`);return n}function Bi(e,t,n){let r={},i=p(e,[`systemInstruction`]);t!==void 0&&i!=null&&f(t,[`systemInstruction`],P(i));let a=p(e,[`tools`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>yo(e))),f(t,[`tools`],e)}let o=p(e,[`generationConfig`]);return t!==void 0&&o!=null&&f(t,[`generationConfig`],Ia(o)),r}function Vi(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`contents`]);if(a!=null){let e=F(a);Array.isArray(e)&&(e=e.map(e=>Li(e))),f(r,[`contents`],e)}let o=p(t,[`config`]);return o!=null&&zi(o),r}function Hi(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`contents`]);if(a!=null){let e=F(a);Array.isArray(e)&&(e=e.map(e=>e)),f(r,[`contents`],e)}let o=p(t,[`config`]);return o!=null&&Bi(o,r),r}function Ui(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`totalTokens`]);i!=null&&f(n,[`totalTokens`],i);let a=p(e,[`cachedContentTokenCount`]);return a!=null&&f(n,[`cachedContentTokenCount`],a),n}function Wi(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`totalTokens`]);return i!=null&&f(n,[`totalTokens`],i),n}function Gi(e,t,n){let r={},i=p(t,[`model`]);return i!=null&&f(r,[`_url`,`name`],N(e,i)),r}function Ki(e,t,n){let r={},i=p(t,[`model`]);return i!=null&&f(r,[`_url`,`name`],N(e,i)),r}function qi(e,t){let n={},r=p(e,[`sdkHttpResponse`]);return r!=null&&f(n,[`sdkHttpResponse`],r),n}function Ji(e,t){let n={},r=p(e,[`sdkHttpResponse`]);return r!=null&&f(n,[`sdkHttpResponse`],r),n}function Yi(e,t,n){let r={},i=p(e,[`outputGcsUri`]);t!==void 0&&i!=null&&f(t,[`parameters`,`storageUri`],i);let a=p(e,[`negativePrompt`]);t!==void 0&&a!=null&&f(t,[`parameters`,`negativePrompt`],a);let o=p(e,[`numberOfImages`]);t!==void 0&&o!=null&&f(t,[`parameters`,`sampleCount`],o);let s=p(e,[`aspectRatio`]);t!==void 0&&s!=null&&f(t,[`parameters`,`aspectRatio`],s);let c=p(e,[`guidanceScale`]);t!==void 0&&c!=null&&f(t,[`parameters`,`guidanceScale`],c);let l=p(e,[`seed`]);t!==void 0&&l!=null&&f(t,[`parameters`,`seed`],l);let u=p(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&f(t,[`parameters`,`safetySetting`],u);let d=p(e,[`personGeneration`]);t!==void 0&&d!=null&&f(t,[`parameters`,`personGeneration`],d);let m=p(e,[`includeSafetyAttributes`]);t!==void 0&&m!=null&&f(t,[`parameters`,`includeSafetyAttributes`],m);let h=p(e,[`includeRaiReason`]);t!==void 0&&h!=null&&f(t,[`parameters`,`includeRaiReason`],h);let g=p(e,[`language`]);t!==void 0&&g!=null&&f(t,[`parameters`,`language`],g);let _=p(e,[`outputMimeType`]);t!==void 0&&_!=null&&f(t,[`parameters`,`outputOptions`,`mimeType`],_);let v=p(e,[`outputCompressionQuality`]);t!==void 0&&v!=null&&f(t,[`parameters`,`outputOptions`,`compressionQuality`],v);let y=p(e,[`addWatermark`]);t!==void 0&&y!=null&&f(t,[`parameters`,`addWatermark`],y);let b=p(e,[`labels`]);t!==void 0&&b!=null&&f(t,[`labels`],b);let x=p(e,[`editMode`]);t!==void 0&&x!=null&&f(t,[`parameters`,`editMode`],x);let S=p(e,[`baseSteps`]);return t!==void 0&&S!=null&&f(t,[`parameters`,`editConfig`,`baseSteps`],S),r}function Xi(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`prompt`]);a!=null&&f(r,[`instances[0]`,`prompt`],a);let o=p(t,[`referenceImages`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>so(e))),f(r,[`instances[0]`,`referenceImages`],e)}let s=p(t,[`config`]);return s!=null&&Yi(s,r),r}function Zi(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Ma(e))),f(n,[`generatedImages`],e)}return n}function Qi(e,t,n){let r={},i=p(e,[`taskType`]);t!==void 0&&i!=null&&f(t,[`requests[]`,`taskType`],i);let a=p(e,[`title`]);t!==void 0&&a!=null&&f(t,[`requests[]`,`title`],a);let o=p(e,[`outputDimensionality`]);if(t!==void 0&&o!=null&&f(t,[`requests[]`,`outputDimensionality`],o),p(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(p(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);return r}function $i(e,t,n){let r={},i=p(n,[`embeddingApiType`]);if(i===void 0&&(i=`PREDICT`),i===`PREDICT`){let n=p(e,[`taskType`]);t!==void 0&&n!=null&&f(t,[`instances[]`,`task_type`],n)}else if(i===`EMBED_CONTENT`){let n=p(e,[`taskType`]);t!==void 0&&n!=null&&f(t,[`taskType`],n)}let a=p(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=p(e,[`title`]);t!==void 0&&n!=null&&f(t,[`instances[]`,`title`],n)}else if(a===`EMBED_CONTENT`){let n=p(e,[`title`]);t!==void 0&&n!=null&&f(t,[`title`],n)}let o=p(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`PREDICT`){let n=p(e,[`outputDimensionality`]);t!==void 0&&n!=null&&f(t,[`parameters`,`outputDimensionality`],n)}else if(o===`EMBED_CONTENT`){let n=p(e,[`outputDimensionality`]);t!==void 0&&n!=null&&f(t,[`outputDimensionality`],n)}let s=p(n,[`embeddingApiType`]);if(s===void 0&&(s=`PREDICT`),s===`PREDICT`){let n=p(e,[`mimeType`]);t!==void 0&&n!=null&&f(t,[`instances[]`,`mimeType`],n)}let c=p(n,[`embeddingApiType`]);if(c===void 0&&(c=`PREDICT`),c===`PREDICT`){let n=p(e,[`autoTruncate`]);t!==void 0&&n!=null&&f(t,[`parameters`,`autoTruncate`],n)}else if(c===`EMBED_CONTENT`){let n=p(e,[`autoTruncate`]);t!==void 0&&n!=null&&f(t,[`autoTruncate`],n)}return r}function ea(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`contents`]);if(a!=null){let t=Ut(e,a);Array.isArray(t)&&(t=t.map(e=>e)),f(r,[`requests[]`,`content`],t)}let o=p(t,[`content`]);o!=null&&Li(P(o));let s=p(t,[`config`]);s!=null&&Qi(s,r);let c=p(t,[`model`]);return c!==void 0&&f(r,[`requests[]`,`model`],N(e,c)),r}function ta(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=p(t,[`contents`]);if(n!=null){let t=Ut(e,n);Array.isArray(t)&&(t=t.map(e=>e)),f(r,[`instances[]`,`content`],t)}}let o=p(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`EMBED_CONTENT`){let e=p(t,[`content`]);e!=null&&f(r,[`content`],P(e))}let s=p(t,[`config`]);return s!=null&&$i(s,r,n),r}function na(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`embeddings`],e)}let a=p(e,[`metadata`]);return a!=null&&f(n,[`metadata`],a),n}function ra(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`predictions[]`,`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Fi(e))),f(n,[`embeddings`],e)}let a=p(e,[`metadata`]);if(a!=null&&f(n,[`metadata`],a),t&&p(t,[`embeddingApiType`])===`EMBED_CONTENT`){let t=p(e,[`embedding`]),r=p(e,[`usageMetadata`]),i=p(e,[`truncated`]);if(t){let e={};r&&r.promptTokenCount&&(e.tokenCount=r.promptTokenCount),i&&(e.truncated=i),t.statistics=e,f(n,[`embeddings`],[t])}}return n}function ia(e,t){let n={},r=p(e,[`endpoint`]);r!=null&&f(n,[`name`],r);let i=p(e,[`deployedModelId`]);return i!=null&&f(n,[`deployedModelId`],i),n}function aa(e,t){let n={};if(p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=p(e,[`fileUri`]);r!=null&&f(n,[`fileUri`],r);let i=p(e,[`mimeType`]);return i!=null&&f(n,[`mimeType`],i),n}function oa(e,t){let n={},r=p(e,[`id`]);r!=null&&f(n,[`id`],r);let i=p(e,[`args`]);i!=null&&f(n,[`args`],i);let a=p(e,[`name`]);if(a!=null&&f(n,[`name`],a),p(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(p(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return n}function sa(e,t){let n={},r=p(e,[`allowedFunctionNames`]);r!=null&&f(n,[`allowedFunctionNames`],r);let i=p(e,[`mode`]);if(i!=null&&f(n,[`mode`],i),p(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return n}function ca(e,t){let n={},r=p(e,[`description`]);r!=null&&f(n,[`description`],r);let i=p(e,[`name`]);i!=null&&f(n,[`name`],i);let a=p(e,[`parameters`]);a!=null&&f(n,[`parameters`],a);let o=p(e,[`parametersJsonSchema`]);o!=null&&f(n,[`parametersJsonSchema`],o);let s=p(e,[`response`]);s!=null&&f(n,[`response`],s);let c=p(e,[`responseJsonSchema`]);if(c!=null&&f(n,[`responseJsonSchema`],c),p(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Vertex AI.`);return n}function la(e,t,n,r){let i={},a=p(t,[`systemInstruction`]);n!==void 0&&a!=null&&f(n,[`systemInstruction`],Li(P(a)));let o=p(t,[`temperature`]);o!=null&&f(i,[`temperature`],o);let s=p(t,[`topP`]);s!=null&&f(i,[`topP`],s);let c=p(t,[`topK`]);c!=null&&f(i,[`topK`],c);let l=p(t,[`candidateCount`]);l!=null&&f(i,[`candidateCount`],l);let u=p(t,[`maxOutputTokens`]);u!=null&&f(i,[`maxOutputTokens`],u);let d=p(t,[`stopSequences`]);d!=null&&f(i,[`stopSequences`],d);let m=p(t,[`responseLogprobs`]);m!=null&&f(i,[`responseLogprobs`],m);let h=p(t,[`logprobs`]);h!=null&&f(i,[`logprobs`],h);let g=p(t,[`presencePenalty`]);g!=null&&f(i,[`presencePenalty`],g);let _=p(t,[`frequencyPenalty`]);_!=null&&f(i,[`frequencyPenalty`],_);let v=p(t,[`seed`]);v!=null&&f(i,[`seed`],v);let y=p(t,[`responseMimeType`]);y!=null&&f(i,[`responseMimeType`],y);let b=p(t,[`responseSchema`]);b!=null&&f(i,[`responseSchema`],Kt(b));let x=p(t,[`responseJsonSchema`]);if(x!=null&&f(i,[`responseJsonSchema`],x),p(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(p(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let S=p(t,[`safetySettings`]);if(n!==void 0&&S!=null){let e=S;Array.isArray(e)&&(e=e.map(e=>uo(e))),f(n,[`safetySettings`],e)}let C=p(t,[`tools`]);if(n!==void 0&&C!=null){let e=L(C);Array.isArray(e)&&(e=e.map(e=>vo(I(e)))),f(n,[`tools`],e)}let w=p(t,[`toolConfig`]);if(n!==void 0&&w!=null&&f(n,[`toolConfig`],_o(w)),p(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let T=p(t,[`cachedContent`]);n!==void 0&&T!=null&&f(n,[`cachedContent`],R(e,T));let E=p(t,[`responseModalities`]);E!=null&&f(i,[`responseModalities`],E);let D=p(t,[`mediaResolution`]);D!=null&&f(i,[`mediaResolution`],D);let O=p(t,[`speechConfig`]);if(O!=null&&f(i,[`speechConfig`],qt(O)),p(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let k=p(t,[`thinkingConfig`]);k!=null&&f(i,[`thinkingConfig`],k);let A=p(t,[`imageConfig`]);A!=null&&f(i,[`imageConfig`],Va(A));let ee=p(t,[`enableEnhancedCivicAnswers`]);if(ee!=null&&f(i,[`enableEnhancedCivicAnswers`],ee),p(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is not supported in Gemini API.`);return i}function ua(e,t,n,r){let i={},a=p(t,[`systemInstruction`]);n!==void 0&&a!=null&&f(n,[`systemInstruction`],P(a));let o=p(t,[`temperature`]);o!=null&&f(i,[`temperature`],o);let s=p(t,[`topP`]);s!=null&&f(i,[`topP`],s);let c=p(t,[`topK`]);c!=null&&f(i,[`topK`],c);let l=p(t,[`candidateCount`]);l!=null&&f(i,[`candidateCount`],l);let u=p(t,[`maxOutputTokens`]);u!=null&&f(i,[`maxOutputTokens`],u);let d=p(t,[`stopSequences`]);d!=null&&f(i,[`stopSequences`],d);let m=p(t,[`responseLogprobs`]);m!=null&&f(i,[`responseLogprobs`],m);let h=p(t,[`logprobs`]);h!=null&&f(i,[`logprobs`],h);let g=p(t,[`presencePenalty`]);g!=null&&f(i,[`presencePenalty`],g);let _=p(t,[`frequencyPenalty`]);_!=null&&f(i,[`frequencyPenalty`],_);let v=p(t,[`seed`]);v!=null&&f(i,[`seed`],v);let y=p(t,[`responseMimeType`]);y!=null&&f(i,[`responseMimeType`],y);let b=p(t,[`responseSchema`]);b!=null&&f(i,[`responseSchema`],Kt(b));let x=p(t,[`responseJsonSchema`]);x!=null&&f(i,[`responseJsonSchema`],x);let S=p(t,[`routingConfig`]);S!=null&&f(i,[`routingConfig`],S);let C=p(t,[`modelSelectionConfig`]);C!=null&&f(i,[`modelConfig`],C);let w=p(t,[`safetySettings`]);if(n!==void 0&&w!=null){let e=w;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`safetySettings`],e)}let T=p(t,[`tools`]);if(n!==void 0&&T!=null){let e=L(T);Array.isArray(e)&&(e=e.map(e=>yo(I(e)))),f(n,[`tools`],e)}let E=p(t,[`toolConfig`]);n!==void 0&&E!=null&&f(n,[`toolConfig`],E);let D=p(t,[`labels`]);n!==void 0&&D!=null&&f(n,[`labels`],D);let O=p(t,[`cachedContent`]);n!==void 0&&O!=null&&f(n,[`cachedContent`],R(e,O));let k=p(t,[`responseModalities`]);k!=null&&f(i,[`responseModalities`],k);let A=p(t,[`mediaResolution`]);A!=null&&f(i,[`mediaResolution`],A);let ee=p(t,[`speechConfig`]);ee!=null&&f(i,[`speechConfig`],qt(ee));let te=p(t,[`audioTimestamp`]);te!=null&&f(i,[`audioTimestamp`],te);let ne=p(t,[`thinkingConfig`]);ne!=null&&f(i,[`thinkingConfig`],ne);let re=p(t,[`imageConfig`]);if(re!=null&&f(i,[`imageConfig`],Ha(re)),p(t,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Vertex AI.`);let j=p(t,[`modelArmorConfig`]);return n!==void 0&&j!=null&&f(n,[`modelArmorConfig`],j),i}function da(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`contents`]);if(a!=null){let e=F(a);Array.isArray(e)&&(e=e.map(e=>Li(e))),f(r,[`contents`],e)}let o=p(t,[`config`]);return o!=null&&f(r,[`generationConfig`],la(e,o,r)),r}function fa(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`contents`]);if(a!=null){let e=F(a);Array.isArray(e)&&(e=e.map(e=>e)),f(r,[`contents`],e)}let o=p(t,[`config`]);return o!=null&&f(r,[`generationConfig`],ua(e,o,r)),r}function pa(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ji(e))),f(n,[`candidates`],e)}let a=p(e,[`modelVersion`]);a!=null&&f(n,[`modelVersion`],a);let o=p(e,[`promptFeedback`]);o!=null&&f(n,[`promptFeedback`],o);let s=p(e,[`responseId`]);s!=null&&f(n,[`responseId`],s);let c=p(e,[`usageMetadata`]);return c!=null&&f(n,[`usageMetadata`],c),n}function ma(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`candidates`],e)}let a=p(e,[`createTime`]);a!=null&&f(n,[`createTime`],a);let o=p(e,[`modelVersion`]);o!=null&&f(n,[`modelVersion`],o);let s=p(e,[`promptFeedback`]);s!=null&&f(n,[`promptFeedback`],s);let c=p(e,[`responseId`]);c!=null&&f(n,[`responseId`],c);let l=p(e,[`usageMetadata`]);return l!=null&&f(n,[`usageMetadata`],l),n}function ha(e,t,n){let r={};if(p(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(p(e,[`negativePrompt`])!==void 0)throw Error(`negativePrompt parameter is not supported in Gemini API.`);let i=p(e,[`numberOfImages`]);t!==void 0&&i!=null&&f(t,[`parameters`,`sampleCount`],i);let a=p(e,[`aspectRatio`]);t!==void 0&&a!=null&&f(t,[`parameters`,`aspectRatio`],a);let o=p(e,[`guidanceScale`]);if(t!==void 0&&o!=null&&f(t,[`parameters`,`guidanceScale`],o),p(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let s=p(e,[`safetyFilterLevel`]);t!==void 0&&s!=null&&f(t,[`parameters`,`safetySetting`],s);let c=p(e,[`personGeneration`]);t!==void 0&&c!=null&&f(t,[`parameters`,`personGeneration`],c);let l=p(e,[`includeSafetyAttributes`]);t!==void 0&&l!=null&&f(t,[`parameters`,`includeSafetyAttributes`],l);let u=p(e,[`includeRaiReason`]);t!==void 0&&u!=null&&f(t,[`parameters`,`includeRaiReason`],u);let d=p(e,[`language`]);t!==void 0&&d!=null&&f(t,[`parameters`,`language`],d);let m=p(e,[`outputMimeType`]);t!==void 0&&m!=null&&f(t,[`parameters`,`outputOptions`,`mimeType`],m);let h=p(e,[`outputCompressionQuality`]);if(t!==void 0&&h!=null&&f(t,[`parameters`,`outputOptions`,`compressionQuality`],h),p(e,[`addWatermark`])!==void 0)throw Error(`addWatermark parameter is not supported in Gemini API.`);if(p(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let g=p(e,[`imageSize`]);if(t!==void 0&&g!=null&&f(t,[`parameters`,`sampleImageSize`],g),p(e,[`enhancePrompt`])!==void 0)throw Error(`enhancePrompt parameter is not supported in Gemini API.`);return r}function ga(e,t,n){let r={},i=p(e,[`outputGcsUri`]);t!==void 0&&i!=null&&f(t,[`parameters`,`storageUri`],i);let a=p(e,[`negativePrompt`]);t!==void 0&&a!=null&&f(t,[`parameters`,`negativePrompt`],a);let o=p(e,[`numberOfImages`]);t!==void 0&&o!=null&&f(t,[`parameters`,`sampleCount`],o);let s=p(e,[`aspectRatio`]);t!==void 0&&s!=null&&f(t,[`parameters`,`aspectRatio`],s);let c=p(e,[`guidanceScale`]);t!==void 0&&c!=null&&f(t,[`parameters`,`guidanceScale`],c);let l=p(e,[`seed`]);t!==void 0&&l!=null&&f(t,[`parameters`,`seed`],l);let u=p(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&f(t,[`parameters`,`safetySetting`],u);let d=p(e,[`personGeneration`]);t!==void 0&&d!=null&&f(t,[`parameters`,`personGeneration`],d);let m=p(e,[`includeSafetyAttributes`]);t!==void 0&&m!=null&&f(t,[`parameters`,`includeSafetyAttributes`],m);let h=p(e,[`includeRaiReason`]);t!==void 0&&h!=null&&f(t,[`parameters`,`includeRaiReason`],h);let g=p(e,[`language`]);t!==void 0&&g!=null&&f(t,[`parameters`,`language`],g);let _=p(e,[`outputMimeType`]);t!==void 0&&_!=null&&f(t,[`parameters`,`outputOptions`,`mimeType`],_);let v=p(e,[`outputCompressionQuality`]);t!==void 0&&v!=null&&f(t,[`parameters`,`outputOptions`,`compressionQuality`],v);let y=p(e,[`addWatermark`]);t!==void 0&&y!=null&&f(t,[`parameters`,`addWatermark`],y);let b=p(e,[`labels`]);t!==void 0&&b!=null&&f(t,[`labels`],b);let x=p(e,[`imageSize`]);t!==void 0&&x!=null&&f(t,[`parameters`,`sampleImageSize`],x);let S=p(e,[`enhancePrompt`]);return t!==void 0&&S!=null&&f(t,[`parameters`,`enhancePrompt`],S),r}function _a(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`prompt`]);a!=null&&f(r,[`instances[0]`,`prompt`],a);let o=p(t,[`config`]);return o!=null&&ha(o,r),r}function va(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`prompt`]);a!=null&&f(r,[`instances[0]`,`prompt`],a);let o=p(t,[`config`]);return o!=null&&ga(o,r),r}function ya(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ja(e))),f(n,[`generatedImages`],e)}let a=p(e,[`positivePromptSafetyAttributes`]);return a!=null&&f(n,[`positivePromptSafetyAttributes`],co(a)),n}function ba(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Ma(e))),f(n,[`generatedImages`],e)}let a=p(e,[`positivePromptSafetyAttributes`]);return a!=null&&f(n,[`positivePromptSafetyAttributes`],lo(a)),n}function xa(e,t,n){let r={},i=p(e,[`numberOfVideos`]);if(t!==void 0&&i!=null&&f(t,[`parameters`,`sampleCount`],i),p(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(p(e,[`fps`])!==void 0)throw Error(`fps parameter is not supported in Gemini API.`);let a=p(e,[`durationSeconds`]);if(t!==void 0&&a!=null&&f(t,[`parameters`,`durationSeconds`],a),p(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let o=p(e,[`aspectRatio`]);t!==void 0&&o!=null&&f(t,[`parameters`,`aspectRatio`],o);let s=p(e,[`resolution`]);t!==void 0&&s!=null&&f(t,[`parameters`,`resolution`],s);let c=p(e,[`personGeneration`]);if(t!==void 0&&c!=null&&f(t,[`parameters`,`personGeneration`],c),p(e,[`pubsubTopic`])!==void 0)throw Error(`pubsubTopic parameter is not supported in Gemini API.`);let l=p(e,[`negativePrompt`]);t!==void 0&&l!=null&&f(t,[`parameters`,`negativePrompt`],l);let u=p(e,[`enhancePrompt`]);if(t!==void 0&&u!=null&&f(t,[`parameters`,`enhancePrompt`],u),p(e,[`generateAudio`])!==void 0)throw Error(`generateAudio parameter is not supported in Gemini API.`);let d=p(e,[`lastFrame`]);t!==void 0&&d!=null&&f(t,[`instances[0]`,`lastFrame`],Ga(d));let m=p(e,[`referenceImages`]);if(t!==void 0&&m!=null){let e=m;Array.isArray(e)&&(e=e.map(e=>Mo(e))),f(t,[`instances[0]`,`referenceImages`],e)}if(p(e,[`mask`])!==void 0)throw Error(`mask parameter is not supported in Gemini API.`);if(p(e,[`compressionQuality`])!==void 0)throw Error(`compressionQuality parameter is not supported in Gemini API.`);return r}function Sa(e,t,n){let r={},i=p(e,[`numberOfVideos`]);t!==void 0&&i!=null&&f(t,[`parameters`,`sampleCount`],i);let a=p(e,[`outputGcsUri`]);t!==void 0&&a!=null&&f(t,[`parameters`,`storageUri`],a);let o=p(e,[`fps`]);t!==void 0&&o!=null&&f(t,[`parameters`,`fps`],o);let s=p(e,[`durationSeconds`]);t!==void 0&&s!=null&&f(t,[`parameters`,`durationSeconds`],s);let c=p(e,[`seed`]);t!==void 0&&c!=null&&f(t,[`parameters`,`seed`],c);let l=p(e,[`aspectRatio`]);t!==void 0&&l!=null&&f(t,[`parameters`,`aspectRatio`],l);let u=p(e,[`resolution`]);t!==void 0&&u!=null&&f(t,[`parameters`,`resolution`],u);let d=p(e,[`personGeneration`]);t!==void 0&&d!=null&&f(t,[`parameters`,`personGeneration`],d);let m=p(e,[`pubsubTopic`]);t!==void 0&&m!=null&&f(t,[`parameters`,`pubsubTopic`],m);let h=p(e,[`negativePrompt`]);t!==void 0&&h!=null&&f(t,[`parameters`,`negativePrompt`],h);let g=p(e,[`enhancePrompt`]);t!==void 0&&g!=null&&f(t,[`parameters`,`enhancePrompt`],g);let _=p(e,[`generateAudio`]);t!==void 0&&_!=null&&f(t,[`parameters`,`generateAudio`],_);let v=p(e,[`lastFrame`]);t!==void 0&&v!=null&&f(t,[`instances[0]`,`lastFrame`],K(v));let y=p(e,[`referenceImages`]);if(t!==void 0&&y!=null){let e=y;Array.isArray(e)&&(e=e.map(e=>No(e))),f(t,[`instances[0]`,`referenceImages`],e)}let b=p(e,[`mask`]);t!==void 0&&b!=null&&f(t,[`instances[0]`,`mask`],jo(b));let x=p(e,[`compressionQuality`]);return t!==void 0&&x!=null&&f(t,[`parameters`,`compressionQuality`],x),r}function Ca(e,t){let n={},r=p(e,[`name`]);r!=null&&f(n,[`name`],r);let i=p(e,[`metadata`]);i!=null&&f(n,[`metadata`],i);let a=p(e,[`done`]);a!=null&&f(n,[`done`],a);let o=p(e,[`error`]);o!=null&&f(n,[`error`],o);let s=p(e,[`response`,`generateVideoResponse`]);return s!=null&&f(n,[`response`],Da(s)),n}function wa(e,t){let n={},r=p(e,[`name`]);r!=null&&f(n,[`name`],r);let i=p(e,[`metadata`]);i!=null&&f(n,[`metadata`],i);let a=p(e,[`done`]);a!=null&&f(n,[`done`],a);let o=p(e,[`error`]);o!=null&&f(n,[`error`],o);let s=p(e,[`response`]);return s!=null&&f(n,[`response`],Oa(s)),n}function Ta(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`prompt`]);a!=null&&f(r,[`instances[0]`,`prompt`],a);let o=p(t,[`image`]);o!=null&&f(r,[`instances[0]`,`image`],Ga(o));let s=p(t,[`video`]);s!=null&&f(r,[`instances[0]`,`video`],Po(s));let c=p(t,[`source`]);c!=null&&ka(c,r);let l=p(t,[`config`]);return l!=null&&xa(l,r),r}function Ea(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`prompt`]);a!=null&&f(r,[`instances[0]`,`prompt`],a);let o=p(t,[`image`]);o!=null&&f(r,[`instances[0]`,`image`],K(o));let s=p(t,[`video`]);s!=null&&f(r,[`instances[0]`,`video`],Fo(s));let c=p(t,[`source`]);c!=null&&Aa(c,r);let l=p(t,[`config`]);return l!=null&&Sa(l,r),r}function Da(e,t){let n={},r=p(e,[`generatedSamples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Pa(e))),f(n,[`generatedVideos`],e)}let i=p(e,[`raiMediaFilteredCount`]);i!=null&&f(n,[`raiMediaFilteredCount`],i);let a=p(e,[`raiMediaFilteredReasons`]);return a!=null&&f(n,[`raiMediaFilteredReasons`],a),n}function Oa(e,t){let n={},r=p(e,[`videos`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Fa(e))),f(n,[`generatedVideos`],e)}let i=p(e,[`raiMediaFilteredCount`]);i!=null&&f(n,[`raiMediaFilteredCount`],i);let a=p(e,[`raiMediaFilteredReasons`]);return a!=null&&f(n,[`raiMediaFilteredReasons`],a),n}function ka(e,t,n){let r={},i=p(e,[`prompt`]);t!==void 0&&i!=null&&f(t,[`instances[0]`,`prompt`],i);let a=p(e,[`image`]);t!==void 0&&a!=null&&f(t,[`instances[0]`,`image`],Ga(a));let o=p(e,[`video`]);return t!==void 0&&o!=null&&f(t,[`instances[0]`,`video`],Po(o)),r}function Aa(e,t,n){let r={},i=p(e,[`prompt`]);t!==void 0&&i!=null&&f(t,[`instances[0]`,`prompt`],i);let a=p(e,[`image`]);t!==void 0&&a!=null&&f(t,[`instances[0]`,`image`],K(a));let o=p(e,[`video`]);return t!==void 0&&o!=null&&f(t,[`instances[0]`,`video`],Fo(o)),r}function ja(e,t){let n={},r=p(e,[`_self`]);r!=null&&f(n,[`image`],Ua(r));let i=p(e,[`raiFilteredReason`]);i!=null&&f(n,[`raiFilteredReason`],i);let a=p(e,[`_self`]);return a!=null&&f(n,[`safetyAttributes`],co(a)),n}function Ma(e,t){let n={},r=p(e,[`_self`]);r!=null&&f(n,[`image`],Wa(r));let i=p(e,[`raiFilteredReason`]);i!=null&&f(n,[`raiFilteredReason`],i);let a=p(e,[`_self`]);a!=null&&f(n,[`safetyAttributes`],lo(a));let o=p(e,[`prompt`]);return o!=null&&f(n,[`enhancedPrompt`],o),n}function Na(e,t){let n={},r=p(e,[`_self`]);r!=null&&f(n,[`mask`],Wa(r));let i=p(e,[`labels`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`labels`],e)}return n}function Pa(e,t){let n={},r=p(e,[`video`]);return r!=null&&f(n,[`video`],ko(r)),n}function Fa(e,t){let n={},r=p(e,[`_self`]);return r!=null&&f(n,[`video`],Ao(r)),n}function Ia(e,t){let n={},r=p(e,[`modelSelectionConfig`]);r!=null&&f(n,[`modelConfig`],r);let i=p(e,[`responseJsonSchema`]);i!=null&&f(n,[`responseJsonSchema`],i);let a=p(e,[`audioTimestamp`]);a!=null&&f(n,[`audioTimestamp`],a);let o=p(e,[`candidateCount`]);o!=null&&f(n,[`candidateCount`],o);let s=p(e,[`enableAffectiveDialog`]);s!=null&&f(n,[`enableAffectiveDialog`],s);let c=p(e,[`frequencyPenalty`]);c!=null&&f(n,[`frequencyPenalty`],c);let l=p(e,[`logprobs`]);l!=null&&f(n,[`logprobs`],l);let u=p(e,[`maxOutputTokens`]);u!=null&&f(n,[`maxOutputTokens`],u);let d=p(e,[`mediaResolution`]);d!=null&&f(n,[`mediaResolution`],d);let m=p(e,[`presencePenalty`]);m!=null&&f(n,[`presencePenalty`],m);let h=p(e,[`responseLogprobs`]);h!=null&&f(n,[`responseLogprobs`],h);let g=p(e,[`responseMimeType`]);g!=null&&f(n,[`responseMimeType`],g);let _=p(e,[`responseModalities`]);_!=null&&f(n,[`responseModalities`],_);let v=p(e,[`responseSchema`]);v!=null&&f(n,[`responseSchema`],v);let y=p(e,[`routingConfig`]);y!=null&&f(n,[`routingConfig`],y);let b=p(e,[`seed`]);b!=null&&f(n,[`seed`],b);let x=p(e,[`speechConfig`]);x!=null&&f(n,[`speechConfig`],x);let S=p(e,[`stopSequences`]);S!=null&&f(n,[`stopSequences`],S);let C=p(e,[`temperature`]);C!=null&&f(n,[`temperature`],C);let w=p(e,[`thinkingConfig`]);w!=null&&f(n,[`thinkingConfig`],w);let T=p(e,[`topK`]);T!=null&&f(n,[`topK`],T);let E=p(e,[`topP`]);if(E!=null&&f(n,[`topP`],E),p(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Vertex AI.`);return n}function La(e,t,n){let r={},i=p(t,[`model`]);return i!=null&&f(r,[`_url`,`name`],N(e,i)),r}function Ra(e,t,n){let r={},i=p(t,[`model`]);return i!=null&&f(r,[`_url`,`name`],N(e,i)),r}function za(e,t){let n={};if(p(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let r=p(e,[`enableWidget`]);return r!=null&&f(n,[`enableWidget`],r),n}function Ba(e,t){let n={},r=p(e,[`searchTypes`]);if(r!=null&&f(n,[`searchTypes`],r),p(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(p(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let i=p(e,[`timeRangeFilter`]);return i!=null&&f(n,[`timeRangeFilter`],i),n}function Va(e,t){let n={},r=p(e,[`aspectRatio`]);r!=null&&f(n,[`aspectRatio`],r);let i=p(e,[`imageSize`]);if(i!=null&&f(n,[`imageSize`],i),p(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is not supported in Gemini API.`);if(p(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is not supported in Gemini API.`);if(p(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(p(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);return n}function Ha(e,t){let n={},r=p(e,[`aspectRatio`]);r!=null&&f(n,[`aspectRatio`],r);let i=p(e,[`imageSize`]);i!=null&&f(n,[`imageSize`],i);let a=p(e,[`personGeneration`]);a!=null&&f(n,[`personGeneration`],a);let o=p(e,[`prominentPeople`]);o!=null&&f(n,[`prominentPeople`],o);let s=p(e,[`outputMimeType`]);s!=null&&f(n,[`imageOutputOptions`,`mimeType`],s);let c=p(e,[`outputCompressionQuality`]);return c!=null&&f(n,[`imageOutputOptions`,`compressionQuality`],c),n}function Ua(e,t){let n={},r=p(e,[`bytesBase64Encoded`]);r!=null&&f(n,[`imageBytes`],z(r));let i=p(e,[`mimeType`]);return i!=null&&f(n,[`mimeType`],i),n}function Wa(e,t){let n={},r=p(e,[`gcsUri`]);r!=null&&f(n,[`gcsUri`],r);let i=p(e,[`bytesBase64Encoded`]);i!=null&&f(n,[`imageBytes`],z(i));let a=p(e,[`mimeType`]);return a!=null&&f(n,[`mimeType`],a),n}function Ga(e,t){let n={};if(p(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);let r=p(e,[`imageBytes`]);r!=null&&f(n,[`bytesBase64Encoded`],z(r));let i=p(e,[`mimeType`]);return i!=null&&f(n,[`mimeType`],i),n}function K(e,t){let n={},r=p(e,[`gcsUri`]);r!=null&&f(n,[`gcsUri`],r);let i=p(e,[`imageBytes`]);i!=null&&f(n,[`bytesBase64Encoded`],z(i));let a=p(e,[`mimeType`]);return a!=null&&f(n,[`mimeType`],a),n}function Ka(e,t,n,r){let i={},a=p(t,[`pageSize`]);n!==void 0&&a!=null&&f(n,[`_query`,`pageSize`],a);let o=p(t,[`pageToken`]);n!==void 0&&o!=null&&f(n,[`_query`,`pageToken`],o);let s=p(t,[`filter`]);n!==void 0&&s!=null&&f(n,[`_query`,`filter`],s);let c=p(t,[`queryBase`]);return n!==void 0&&c!=null&&f(n,[`_url`,`models_url`],tn(e,c)),i}function qa(e,t,n,r){let i={},a=p(t,[`pageSize`]);n!==void 0&&a!=null&&f(n,[`_query`,`pageSize`],a);let o=p(t,[`pageToken`]);n!==void 0&&o!=null&&f(n,[`_query`,`pageToken`],o);let s=p(t,[`filter`]);n!==void 0&&s!=null&&f(n,[`_query`,`filter`],s);let c=p(t,[`queryBase`]);return n!==void 0&&c!=null&&f(n,[`_url`,`models_url`],tn(e,c)),i}function Ja(e,t,n){let r={},i=p(t,[`config`]);return i!=null&&Ka(e,i,r),r}function Ya(e,t,n){let r={},i=p(t,[`config`]);return i!=null&&qa(e,i,r),r}function Xa(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`nextPageToken`]);i!=null&&f(n,[`nextPageToken`],i);let a=p(e,[`_self`]);if(a!=null){let e=nn(a);Array.isArray(e)&&(e=e.map(e=>$a(e))),f(n,[`models`],e)}return n}function Za(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`nextPageToken`]);i!=null&&f(n,[`nextPageToken`],i);let a=p(e,[`_self`]);if(a!=null){let e=nn(a);Array.isArray(e)&&(e=e.map(e=>eo(e))),f(n,[`models`],e)}return n}function Qa(e,t){let n={},r=p(e,[`maskMode`]);r!=null&&f(n,[`maskMode`],r);let i=p(e,[`segmentationClasses`]);i!=null&&f(n,[`maskClasses`],i);let a=p(e,[`maskDilation`]);return a!=null&&f(n,[`dilation`],a),n}function $a(e,t){let n={},r=p(e,[`name`]);r!=null&&f(n,[`name`],r);let i=p(e,[`displayName`]);i!=null&&f(n,[`displayName`],i);let a=p(e,[`description`]);a!=null&&f(n,[`description`],a);let o=p(e,[`version`]);o!=null&&f(n,[`version`],o);let s=p(e,[`_self`]);s!=null&&f(n,[`tunedModelInfo`],bo(s));let c=p(e,[`inputTokenLimit`]);c!=null&&f(n,[`inputTokenLimit`],c);let l=p(e,[`outputTokenLimit`]);l!=null&&f(n,[`outputTokenLimit`],l);let u=p(e,[`supportedGenerationMethods`]);u!=null&&f(n,[`supportedActions`],u);let d=p(e,[`temperature`]);d!=null&&f(n,[`temperature`],d);let m=p(e,[`maxTemperature`]);m!=null&&f(n,[`maxTemperature`],m);let h=p(e,[`topP`]);h!=null&&f(n,[`topP`],h);let g=p(e,[`topK`]);g!=null&&f(n,[`topK`],g);let _=p(e,[`thinking`]);return _!=null&&f(n,[`thinking`],_),n}function eo(e,t){let n={},r=p(e,[`name`]);r!=null&&f(n,[`name`],r);let i=p(e,[`displayName`]);i!=null&&f(n,[`displayName`],i);let a=p(e,[`description`]);a!=null&&f(n,[`description`],a);let o=p(e,[`versionId`]);o!=null&&f(n,[`version`],o);let s=p(e,[`deployedModels`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>ia(e))),f(n,[`endpoints`],e)}let c=p(e,[`labels`]);c!=null&&f(n,[`labels`],c);let l=p(e,[`_self`]);l!=null&&f(n,[`tunedModelInfo`],xo(l));let u=p(e,[`defaultCheckpointId`]);u!=null&&f(n,[`defaultCheckpointId`],u);let d=p(e,[`checkpoints`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`checkpoints`],e)}return n}function to(e,t){let n={},r=p(e,[`mediaResolution`]);r!=null&&f(n,[`mediaResolution`],r);let i=p(e,[`codeExecutionResult`]);i!=null&&f(n,[`codeExecutionResult`],i);let a=p(e,[`executableCode`]);a!=null&&f(n,[`executableCode`],a);let o=p(e,[`fileData`]);o!=null&&f(n,[`fileData`],aa(o));let s=p(e,[`functionCall`]);s!=null&&f(n,[`functionCall`],oa(s));let c=p(e,[`functionResponse`]);c!=null&&f(n,[`functionResponse`],c);let l=p(e,[`inlineData`]);l!=null&&f(n,[`inlineData`],Ai(l));let u=p(e,[`text`]);u!=null&&f(n,[`text`],u);let d=p(e,[`thought`]);d!=null&&f(n,[`thought`],d);let m=p(e,[`thoughtSignature`]);m!=null&&f(n,[`thoughtSignature`],m);let h=p(e,[`videoMetadata`]);return h!=null&&f(n,[`videoMetadata`],h),n}function no(e,t){let n={},r=p(e,[`productImage`]);return r!=null&&f(n,[`image`],K(r)),n}function ro(e,t,n){let r={},i=p(e,[`numberOfImages`]);t!==void 0&&i!=null&&f(t,[`parameters`,`sampleCount`],i);let a=p(e,[`baseSteps`]);t!==void 0&&a!=null&&f(t,[`parameters`,`baseSteps`],a);let o=p(e,[`outputGcsUri`]);t!==void 0&&o!=null&&f(t,[`parameters`,`storageUri`],o);let s=p(e,[`seed`]);t!==void 0&&s!=null&&f(t,[`parameters`,`seed`],s);let c=p(e,[`safetyFilterLevel`]);t!==void 0&&c!=null&&f(t,[`parameters`,`safetySetting`],c);let l=p(e,[`personGeneration`]);t!==void 0&&l!=null&&f(t,[`parameters`,`personGeneration`],l);let u=p(e,[`addWatermark`]);t!==void 0&&u!=null&&f(t,[`parameters`,`addWatermark`],u);let d=p(e,[`outputMimeType`]);t!==void 0&&d!=null&&f(t,[`parameters`,`outputOptions`,`mimeType`],d);let m=p(e,[`outputCompressionQuality`]);t!==void 0&&m!=null&&f(t,[`parameters`,`outputOptions`,`compressionQuality`],m);let h=p(e,[`enhancePrompt`]);t!==void 0&&h!=null&&f(t,[`parameters`,`enhancePrompt`],h);let g=p(e,[`labels`]);return t!==void 0&&g!=null&&f(t,[`labels`],g),r}function io(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`source`]);a!=null&&oo(a,r);let o=p(t,[`config`]);return o!=null&&ro(o,r),r}function ao(e,t){let n={},r=p(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Ma(e))),f(n,[`generatedImages`],e)}return n}function oo(e,t,n){let r={},i=p(e,[`prompt`]);t!==void 0&&i!=null&&f(t,[`instances[0]`,`prompt`],i);let a=p(e,[`personImage`]);t!==void 0&&a!=null&&f(t,[`instances[0]`,`personImage`,`image`],K(a));let o=p(e,[`productImages`]);if(t!==void 0&&o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>no(e))),f(t,[`instances[0]`,`productImages`],e)}return r}function so(e,t){let n={},r=p(e,[`referenceImage`]);r!=null&&f(n,[`referenceImage`],K(r));let i=p(e,[`referenceId`]);i!=null&&f(n,[`referenceId`],i);let a=p(e,[`referenceType`]);a!=null&&f(n,[`referenceType`],a);let o=p(e,[`maskImageConfig`]);o!=null&&f(n,[`maskImageConfig`],Qa(o));let s=p(e,[`controlImageConfig`]);s!=null&&f(n,[`controlImageConfig`],Ri(s));let c=p(e,[`styleImageConfig`]);c!=null&&f(n,[`styleImageConfig`],c);let l=p(e,[`subjectImageConfig`]);return l!=null&&f(n,[`subjectImageConfig`],l),n}function co(e,t){let n={},r=p(e,[`safetyAttributes`,`categories`]);r!=null&&f(n,[`categories`],r);let i=p(e,[`safetyAttributes`,`scores`]);i!=null&&f(n,[`scores`],i);let a=p(e,[`contentType`]);return a!=null&&f(n,[`contentType`],a),n}function lo(e,t){let n={},r=p(e,[`safetyAttributes`,`categories`]);r!=null&&f(n,[`categories`],r);let i=p(e,[`safetyAttributes`,`scores`]);i!=null&&f(n,[`scores`],i);let a=p(e,[`contentType`]);return a!=null&&f(n,[`contentType`],a),n}function uo(e,t){let n={},r=p(e,[`category`]);if(r!=null&&f(n,[`category`],r),p(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let i=p(e,[`threshold`]);return i!=null&&f(n,[`threshold`],i),n}function fo(e,t){let n={},r=p(e,[`image`]);return r!=null&&f(n,[`image`],K(r)),n}function po(e,t,n){let r={},i=p(e,[`mode`]);t!==void 0&&i!=null&&f(t,[`parameters`,`mode`],i);let a=p(e,[`maxPredictions`]);t!==void 0&&a!=null&&f(t,[`parameters`,`maxPredictions`],a);let o=p(e,[`confidenceThreshold`]);t!==void 0&&o!=null&&f(t,[`parameters`,`confidenceThreshold`],o);let s=p(e,[`maskDilation`]);t!==void 0&&s!=null&&f(t,[`parameters`,`maskDilation`],s);let c=p(e,[`binaryColorThreshold`]);t!==void 0&&c!=null&&f(t,[`parameters`,`binaryColorThreshold`],c);let l=p(e,[`labels`]);return t!==void 0&&l!=null&&f(t,[`labels`],l),r}function mo(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`source`]);a!=null&&go(a,r);let o=p(t,[`config`]);return o!=null&&po(o,r),r}function ho(e,t){let n={},r=p(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Na(e))),f(n,[`generatedMasks`],e)}return n}function go(e,t,n){let r={},i=p(e,[`prompt`]);t!==void 0&&i!=null&&f(t,[`instances[0]`,`prompt`],i);let a=p(e,[`image`]);t!==void 0&&a!=null&&f(t,[`instances[0]`,`image`],K(a));let o=p(e,[`scribbleImage`]);return t!==void 0&&o!=null&&f(t,[`instances[0]`,`scribble`],fo(o)),r}function _o(e,t){let n={},r=p(e,[`retrievalConfig`]);r!=null&&f(n,[`retrievalConfig`],r);let i=p(e,[`functionCallingConfig`]);return i!=null&&f(n,[`functionCallingConfig`],sa(i)),n}function vo(e,t){let n={};if(p(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=p(e,[`computerUse`]);r!=null&&f(n,[`computerUse`],r);let i=p(e,[`fileSearch`]);i!=null&&f(n,[`fileSearch`],i);let a=p(e,[`googleSearch`]);a!=null&&f(n,[`googleSearch`],Ba(a));let o=p(e,[`codeExecution`]);if(o!=null&&f(n,[`codeExecution`],o),p(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=p(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`functionDeclarations`],e)}let c=p(e,[`googleMaps`]);c!=null&&f(n,[`googleMaps`],za(c));let l=p(e,[`googleSearchRetrieval`]);l!=null&&f(n,[`googleSearchRetrieval`],l);let u=p(e,[`urlContext`]);u!=null&&f(n,[`urlContext`],u);let d=p(e,[`mcpServers`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`mcpServers`],e)}return n}function yo(e,t){let n={},r=p(e,[`retrieval`]);r!=null&&f(n,[`retrieval`],r);let i=p(e,[`computerUse`]);if(i!=null&&f(n,[`computerUse`],i),p(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Vertex AI.`);let a=p(e,[`googleSearch`]);a!=null&&f(n,[`googleSearch`],a);let o=p(e,[`codeExecution`]);o!=null&&f(n,[`codeExecution`],o);let s=p(e,[`enterpriseWebSearch`]);s!=null&&f(n,[`enterpriseWebSearch`],s);let c=p(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>ca(e))),f(n,[`functionDeclarations`],e)}let l=p(e,[`googleMaps`]);l!=null&&f(n,[`googleMaps`],l);let u=p(e,[`googleSearchRetrieval`]);u!=null&&f(n,[`googleSearchRetrieval`],u);let d=p(e,[`urlContext`]);if(d!=null&&f(n,[`urlContext`],d),p(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Vertex AI.`);return n}function bo(e,t){let n={},r=p(e,[`baseModel`]);r!=null&&f(n,[`baseModel`],r);let i=p(e,[`createTime`]);i!=null&&f(n,[`createTime`],i);let a=p(e,[`updateTime`]);return a!=null&&f(n,[`updateTime`],a),n}function xo(e,t){let n={},r=p(e,[`labels`,`google-vertex-llm-tuning-base-model-id`]);r!=null&&f(n,[`baseModel`],r);let i=p(e,[`createTime`]);i!=null&&f(n,[`createTime`],i);let a=p(e,[`updateTime`]);return a!=null&&f(n,[`updateTime`],a),n}function So(e,t,n){let r={},i=p(e,[`displayName`]);t!==void 0&&i!=null&&f(t,[`displayName`],i);let a=p(e,[`description`]);t!==void 0&&a!=null&&f(t,[`description`],a);let o=p(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&f(t,[`defaultCheckpointId`],o),r}function Co(e,t,n){let r={},i=p(e,[`displayName`]);t!==void 0&&i!=null&&f(t,[`displayName`],i);let a=p(e,[`description`]);t!==void 0&&a!=null&&f(t,[`description`],a);let o=p(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&f(t,[`defaultCheckpointId`],o),r}function wo(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`name`],N(e,i));let a=p(t,[`config`]);return a!=null&&So(a,r),r}function To(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`config`]);return a!=null&&Co(a,r),r}function Eo(e,t,n){let r={},i=p(e,[`outputGcsUri`]);t!==void 0&&i!=null&&f(t,[`parameters`,`storageUri`],i);let a=p(e,[`safetyFilterLevel`]);t!==void 0&&a!=null&&f(t,[`parameters`,`safetySetting`],a);let o=p(e,[`personGeneration`]);t!==void 0&&o!=null&&f(t,[`parameters`,`personGeneration`],o);let s=p(e,[`includeRaiReason`]);t!==void 0&&s!=null&&f(t,[`parameters`,`includeRaiReason`],s);let c=p(e,[`outputMimeType`]);t!==void 0&&c!=null&&f(t,[`parameters`,`outputOptions`,`mimeType`],c);let l=p(e,[`outputCompressionQuality`]);t!==void 0&&l!=null&&f(t,[`parameters`,`outputOptions`,`compressionQuality`],l);let u=p(e,[`enhanceInputImage`]);t!==void 0&&u!=null&&f(t,[`parameters`,`upscaleConfig`,`enhanceInputImage`],u);let d=p(e,[`imagePreservationFactor`]);t!==void 0&&d!=null&&f(t,[`parameters`,`upscaleConfig`,`imagePreservationFactor`],d);let m=p(e,[`labels`]);t!==void 0&&m!=null&&f(t,[`labels`],m);let h=p(e,[`numberOfImages`]);t!==void 0&&h!=null&&f(t,[`parameters`,`sampleCount`],h);let g=p(e,[`mode`]);return t!==void 0&&g!=null&&f(t,[`parameters`,`mode`],g),r}function Do(e,t,n){let r={},i=p(t,[`model`]);i!=null&&f(r,[`_url`,`model`],N(e,i));let a=p(t,[`image`]);a!=null&&f(r,[`instances[0]`,`image`],K(a));let o=p(t,[`upscaleFactor`]);o!=null&&f(r,[`parameters`,`upscaleConfig`,`upscaleFactor`],o);let s=p(t,[`config`]);return s!=null&&Eo(s,r),r}function Oo(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Ma(e))),f(n,[`generatedImages`],e)}return n}function ko(e,t){let n={},r=p(e,[`uri`]);r!=null&&f(n,[`uri`],r);let i=p(e,[`encodedVideo`]);i!=null&&f(n,[`videoBytes`],z(i));let a=p(e,[`encoding`]);return a!=null&&f(n,[`mimeType`],a),n}function Ao(e,t){let n={},r=p(e,[`gcsUri`]);r!=null&&f(n,[`uri`],r);let i=p(e,[`bytesBase64Encoded`]);i!=null&&f(n,[`videoBytes`],z(i));let a=p(e,[`mimeType`]);return a!=null&&f(n,[`mimeType`],a),n}function jo(e,t){let n={},r=p(e,[`image`]);r!=null&&f(n,[`_self`],K(r));let i=p(e,[`maskMode`]);return i!=null&&f(n,[`maskMode`],i),n}function Mo(e,t){let n={},r=p(e,[`image`]);r!=null&&f(n,[`image`],Ga(r));let i=p(e,[`referenceType`]);return i!=null&&f(n,[`referenceType`],i),n}function No(e,t){let n={},r=p(e,[`image`]);r!=null&&f(n,[`image`],K(r));let i=p(e,[`referenceType`]);return i!=null&&f(n,[`referenceType`],i),n}function Po(e,t){let n={},r=p(e,[`uri`]);r!=null&&f(n,[`uri`],r);let i=p(e,[`videoBytes`]);i!=null&&f(n,[`encodedVideo`],z(i));let a=p(e,[`mimeType`]);return a!=null&&f(n,[`encoding`],a),n}function Fo(e,t){let n={},r=p(e,[`uri`]);r!=null&&f(n,[`gcsUri`],r);let i=p(e,[`videoBytes`]);i!=null&&f(n,[`bytesBase64Encoded`],z(i));let a=p(e,[`mimeType`]);return a!=null&&f(n,[`mimeType`],a),n}
86
+ /**
87
+ * @license
88
+ * Copyright 2025 Google LLC
89
+ * SPDX-License-Identifier: Apache-2.0
90
+ */
91
+ function Io(e,t){let n={},r=p(e,[`displayName`]);return t!==void 0&&r!=null&&f(t,[`displayName`],r),n}function Lo(e){let t={},n=p(e,[`config`]);return n!=null&&Io(n,t),t}function Ro(e,t){let n={},r=p(e,[`force`]);return t!==void 0&&r!=null&&f(t,[`_query`,`force`],r),n}function zo(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`_url`,`name`],n);let r=p(e,[`config`]);return r!=null&&Ro(r,t),t}function Bo(e){let t={},n=p(e,[`name`]);return n!=null&&f(t,[`_url`,`name`],n),t}function Vo(e,t){let n={},r=p(e,[`customMetadata`]);if(t!==void 0&&r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`customMetadata`],e)}let i=p(e,[`chunkingConfig`]);return t!==void 0&&i!=null&&f(t,[`chunkingConfig`],i),n}function Ho(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`name`],n);let r=p(e,[`metadata`]);r!=null&&f(t,[`metadata`],r);let i=p(e,[`done`]);i!=null&&f(t,[`done`],i);let a=p(e,[`error`]);a!=null&&f(t,[`error`],a);let o=p(e,[`response`]);return o!=null&&f(t,[`response`],Wo(o)),t}function Uo(e){let t={},n=p(e,[`fileSearchStoreName`]);n!=null&&f(t,[`_url`,`file_search_store_name`],n);let r=p(e,[`fileName`]);r!=null&&f(t,[`fileName`],r);let i=p(e,[`config`]);return i!=null&&Vo(i,t),t}function Wo(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`parent`]);r!=null&&f(t,[`parent`],r);let i=p(e,[`documentName`]);return i!=null&&f(t,[`documentName`],i),t}function Go(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);return t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i),n}function Ko(e){let t={},n=p(e,[`config`]);return n!=null&&Go(n,t),t}function qo(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`fileSearchStores`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`fileSearchStores`],e)}return t}function Jo(e,t){let n={},r=p(e,[`mimeType`]);t!==void 0&&r!=null&&f(t,[`mimeType`],r);let i=p(e,[`displayName`]);t!==void 0&&i!=null&&f(t,[`displayName`],i);let a=p(e,[`customMetadata`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`customMetadata`],e)}let o=p(e,[`chunkingConfig`]);return t!==void 0&&o!=null&&f(t,[`chunkingConfig`],o),n}function Yo(e){let t={},n=p(e,[`fileSearchStoreName`]);n!=null&&f(t,[`_url`,`file_search_store_name`],n);let r=p(e,[`config`]);return r!=null&&Jo(r,t),t}function Xo(e){let t={},n=p(e,[`sdkHttpResponse`]);return n!=null&&f(t,[`sdkHttpResponse`],n),t}
92
+ /**
93
+ * @license
94
+ * Copyright 2025 Google LLC
95
+ * SPDX-License-Identifier: Apache-2.0
96
+ */
97
+ const Zo=`x-goog-api-client`,Qo=[408,429,500,502,503,504];var $o=class{constructor(e){this.clientOptions=Object.assign({},e),this.customBaseUrl=e.httpOptions?.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));let t={};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.`);let n=e.project&&e.location||!!e.apiKey;this.customBaseUrl&&!n?(t.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey||this.clientOptions.location===`global`?t.baseUrl=`https://aiplatform.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(t.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),t.apiVersion=this.clientOptions.apiVersion??`v1beta1`}else{if(!this.clientOptions.apiKey)throw new Yr({message:`API key must be set when using the Gemini API.`,status:403});t.apiVersion=this.clientOptions.apiVersion??`v1beta`,t.baseUrl=`https://generativelanguage.googleapis.com/`}t.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=t,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(t,e.httpOptions))}isVertexAI(){return this.clientOptions.vertexai??!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){let e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw Error(`API version is not set.`)}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw Error(`Base URL is not set.`)}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw Error(`Headers are not set.`)}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw Error(`HTTP options are not correctly set.`);let t=[e.baseUrl.endsWith(`/`)?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==``&&t.push(e.apiVersion),t.join(`/`)}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let e=this.getBaseUrl(),t=new URL(e);return t.protocol=t.protocol==`http:`?`ws`:`wss`,t.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw Error(`HTTP options are not correctly set.`)}constructUrl(e,t,n){let r=[this.getRequestUrlInternal(t)];return n&&r.push(this.getBaseResourcePath()),e!==``&&r.push(e),new URL(`${r.join(`/`)}`)}shouldPrependVertexProjectPath(e,t){return!(t.baseUrl&&t.baseUrlResourceScope===De.COLLECTION||this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith(`projects/`)||e.httpMethod===`GET`&&e.path.startsWith(`publishers/google/models`))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),r=this.constructUrl(e.path,t,n);if(e.queryParams)for(let[t,n]of Object.entries(e.queryParams))r.searchParams.append(t,String(n));let i={};if(e.httpMethod===`GET`){if(e.body&&e.body!==`{}`)throw Error(`Request body should be empty for GET request, but got non empty request body`)}else i.body=e.body;return i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString(),e.abortSignal),this.unaryApiCall(r,i,e.httpMethod)}patchHttpOptions(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of Object.entries(t))typeof r==`object`?n[e]=Object.assign(Object.assign({},n[e]),r):r!==void 0&&(n[e]=r);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e,t),r=this.constructUrl(e.path,t,n);(!r.searchParams.has(`alt`)||r.searchParams.get(`alt`)!==`sse`)&&r.searchParams.set(`alt`,`sse`);let i={};return i.body=e.body,i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString(),e.abortSignal),this.streamApiCall(r,i,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,n,r){if(t&&t.timeout||r){let n=new AbortController,i=n.signal;if(t.timeout&&t?.timeout>0){let e=setTimeout(()=>n.abort(),t.timeout);e&&typeof e.unref==`function`&&e.unref()}r&&r.addEventListener(`abort`,()=>{n.abort()}),e.signal=i}return t&&t.extraBody!==null&&ts(e,t.extraBody),e.headers=await this.getHeadersInternal(t,n),e}async unaryApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await es(e),new it(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}async streamApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await es(e),this.processStreamResponse(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}processStreamResponse(e){return W(this,arguments,function*(){let t=(e?.body)?.getReader(),n=new TextDecoder(`utf-8`);if(!t)throw Error(`Response body is empty`);try{let r=``,i=[`
98
+
99
+ `,`\r\r`,`\r
100
+ \r
101
+ `];for(;;){let{done:a,value:o}=yield U(t.read());if(a){if(r.trim().length>0)throw Error(`Incomplete JSON segment at the end`);break}let s=n.decode(o,{stream:!0});try{let e=JSON.parse(s);if(`error`in e){let t=JSON.parse(JSON.stringify(e.error)),n=t.status,r=t.code,i=`got status: ${n}. ${JSON.stringify(e)}`;if(r>=400&&r<600)throw new Yr({message:i,status:r})}}catch(e){if(e.name===`ApiError`)throw e}r+=s;let c=-1,l=0;for(;;){c=-1,l=0;for(let e of i){let t=r.indexOf(e);t!==-1&&(c===-1||t<c)&&(c=t,l=e.length)}if(c===-1)break;let t=r.substring(0,c);r=r.substring(c+l);let n=t.trim();if(n.startsWith(`data:`)){let t=n.substring(5).trim();try{yield yield U(new it(new Response(t,{headers:e?.headers,status:e?.status,statusText:e?.statusText})))}catch(e){throw Error(`exception parsing stream chunk ${t}. ${e}`)}}}}}finally{t.releaseLock()}})}async apiCall(e,t){if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions)return fetch(e,t);let n=this.clientOptions.httpOptions.retryOptions;return(0,s.default)(async()=>{let n=await fetch(e,t);if(n.ok)return n;throw Qo.includes(n.status)?Error(`Retryable HTTP Error: ${n.statusText}`):new s.AbortError(`Non-retryable exception ${n.statusText} sending request`)},{retries:(n.attempts??5)-1})}getDefaultHeaders(){let e={},t=`google-genai-sdk/1.43.0 `+this.clientOptions.userAgentExtra;return e[`User-Agent`]=t,e[Zo]=t,e[`Content-Type`]=`application/json`,e}async getHeadersInternal(e,t){let n=new Headers;if(e&&e.headers){for(let[t,r]of Object.entries(e.headers))n.append(t,r);e.timeout&&e.timeout>0&&n.append(`X-Server-Timeout`,String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(n,t),n}getFileName(e){let t=``;return typeof e==`string`&&(t=e.replace(/[/\\]+$/,``),t=t.split(/[/\\]/).pop()??``),t}async uploadFile(e,t){let n={};t!=null&&(n.mimeType=t.mimeType,n.name=t.name,n.displayName=t.displayName),n.name&&!n.name.startsWith(`files/`)&&(n.name=`files/${n.name}`);let r=this.clientOptions.uploader,i=await r.stat(e);n.sizeBytes=String(i.size);let a=t?.mimeType??i.type;if(a===void 0||a===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);n.mimeType=a;let o={file:n},s=this.getFileName(e),c=d(`upload/v1beta/files`,o._url),l=await this.fetchUploadUrl(c,n.sizeBytes,n.mimeType,s,o,t?.httpOptions);return r.upload(e,l,this)}async uploadFileToFileSearchStore(e,t,n){let r=this.clientOptions.uploader,i=await r.stat(t),a=String(i.size),o=n?.mimeType??i.type;if(o===void 0||o===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);let s=`upload/v1beta/${e}:uploadToFileSearchStore`,c=this.getFileName(t),l={};n!=null&&Jo(n,l);let u=await this.fetchUploadUrl(s,a,o,c,l,n?.httpOptions);return r.uploadToFileSearchStore(t,u,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,t,n,r,i,a){let o={};o=a||{apiVersion:``,headers:Object.assign({"Content-Type":`application/json`,"X-Goog-Upload-Protocol":`resumable`,"X-Goog-Upload-Command":`start`,"X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${n}`},r?{"X-Goog-Upload-File-Name":r}:{})};let s=await this.request({path:e,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:o});if(!s||!s?.headers)throw Error(`Server did not return an HttpResponse or the returned HttpResponse did not have headers.`);let c=s?.headers?.[`x-goog-upload-url`];if(c===void 0)throw Error(`Failed to get upload url. Server did not return the x-google-upload-url in the headers`);return c}};async function es(e){if(e===void 0)throw Error(`response is undefined`);if(!e.ok){let t=e.status,n;n=e.headers.get(`content-type`)?.includes(`application/json`)?await e.json():{error:{message:await e.text(),code:e.status,status:e.statusText}};let r=JSON.stringify(n);throw t>=400&&t<600?new Yr({message:r,status:t}):Error(r)}}function ts(e,t){if(!t||Object.keys(t).length===0)return;if(e.body instanceof Blob){console.warn(`includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.`);return}let n={};if(typeof e.body==`string`&&e.body.length>0)try{let t=JSON.parse(e.body);if(typeof t==`object`&&t&&!Array.isArray(t))n=t;else{console.warn(`includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.`);return}}catch{console.warn(`includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.`);return}function r(e,t){let n=Object.assign({},e);for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let i=t[e],a=n[e];i&&typeof i==`object`&&!Array.isArray(i)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=r(a,i):(a&&i&&typeof a!=typeof i&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${e}". Original type: ${typeof a}, New type: ${typeof i}. Overwriting.`),n[e]=i)}return n}let i=r(n,t);e.body=JSON.stringify(i)}function ns(e){for(let t of e)if(is(t)||typeof t==`object`&&`inputSchema`in t)return!0;return!1}function rs(e){e[Zo]=((e[Zo]??``)+` mcp_used/unknown`).trimStart()}function is(e){return typeof e==`object`&&!!e&&e instanceof os}function as(e){return W(this,arguments,function*(e,t=100){let n,r=0;for(;r<t;){let t=yield U(e.listTools({cursor:n}));for(let e of t.tools)yield yield U(e),r++;if(!t.nextCursor)break;n=t.nextCursor}})}var os=class e{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(t,n){return new e(t,n)}async initialize(){var e,t,n,r;if(this.mcpTools.length>0)return;let i={},a=[];for(let l of this.mcpClients)try{for(var o=!0,s=(t=void 0,G(as(l))),c;c=await s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;a.push(e);let t=e.name;if(i[t])throw Error(`Duplicate function name ${t} found in MCP tools. Please ensure function names are unique.`);i[t]=l}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&await n.call(s)}finally{if(t)throw t.error}}this.mcpTools=a,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),on(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let n of e)if(n.name in this.functionNameToMcpClient){let e=this.functionNameToMcpClient[n.name],r;this.config.timeout&&(r={timeout:this.config.timeout});let i=await e.callTool({name:n.name,arguments:n.args},void 0,r);t.push({functionResponse:{name:n.name,response:i.isError?{error:i}:i}})}return t}};
102
+ /**
103
+ * @license
104
+ * Copyright 2025 Google LLC
105
+ * SPDX-License-Identifier: Apache-2.0
106
+ */
107
+ async function ss(e,t,n){let r=new jt,i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(r,i),t(r)}var cs=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){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 t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r=ds(this.apiClient.getDefaultHeaders()),i=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.BidiGenerateMusic?key=${this.apiClient.getApiKey()}`,a=()=>{},o=new Promise(e=>{a=e}),s=e.callbacks,c=function(){a({})},l=this.apiClient,u={onopen:c,onmessage:e=>{ss(l,s.onmessage,e)},onerror:s?.onerror??function(e){},onclose:s?.onclose??function(e){}},d=this.webSocketFactory.create(i,us(r),u);d.connect(),await o;let f={setup:{model:N(this.apiClient,e.model)}};return d.send(JSON.stringify(f)),new ls(d,this.apiClient)}},ls=class{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw Error(`Weighted prompts must be set and contain at least one entry.`);let t=bi(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||={};let t=yi(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){let t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(rt.PLAY)}pause(){this.sendPlaybackControl(rt.PAUSE)}stop(){this.sendPlaybackControl(rt.STOP)}resetContext(){this.sendPlaybackControl(rt.RESET_CONTEXT)}close(){this.conn.close()}};function us(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function ds(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}async function fs(e,t,n){let r=new At,i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?new TextDecoder().decode(n.data):n.data;let a=JSON.parse(i);if(e.isVertexAI()){let e=Ci(a);Object.assign(r,e)}else Object.assign(r,a);t(r)}var ps=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new cs(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){if(e.config&&e.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 t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r,i=this.apiClient.getHeaders();e.config&&e.config.tools&&ns(e.config.tools)&&rs(i);let a=_s(i);if(this.apiClient.isVertexAI()){let e=this.apiClient.getProject(),i=this.apiClient.getLocation(),o=this.apiClient.getApiKey(),s=!!e&&!!i||!!o;this.apiClient.getCustomBaseUrl()&&!s?r=t:(r=`${t}/ws/google.cloud.aiplatform.${n}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(a,r))}else{let e=this.apiClient.getApiKey(),i=`BidiGenerateContent`,a=`key`;e?.startsWith(`auth_tokens/`)&&(console.warn(`Warning: Ephemeral token support is experimental and may change in future versions.`),n!==`v1alpha`&&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.`),i=`BidiGenerateContentConstrained`,a=`access_token`),r=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.${i}?${a}=${e}`}let o=()=>{},s=new Promise(e=>{o=e}),c=e.callbacks,l=function(){var e;(e=c?.onopen)==null||e.call(c),o({})},u=this.apiClient,d={onopen:l,onmessage:e=>{fs(u,c.onmessage,e)},onerror:c?.onerror??function(e){},onclose:c?.onclose??function(e){}},f=this.webSocketFactory.create(r,gs(a),d);f.connect(),await s;let p=N(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&p.startsWith(`publishers/`)){let e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(p=`projects/${e}/locations/${t}/`+p)}let m={};this.apiClient.isVertexAI()&&e.config?.responseModalities===void 0&&(e.config===void 0?e.config={responseModalities:[be.AUDIO]}:e.config.responseModalities=[be.AUDIO]),e.config?.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 h=e.config?.tools??[],g=[];for(let e of h)if(this.isCallableTool(e)){let t=e;g.push(await t.tool())}else g.push(e);g.length>0&&(e.config.tools=g);let _={model:p,config:e.config,callbacks:e.callbacks};return m=this.apiClient.isVertexAI()?vi(this.apiClient,_):_i(this.apiClient,_),delete m.config,f.send(JSON.stringify(m)),new hs(f,this.apiClient)}isCallableTool(e){return`callTool`in e&&typeof e.callTool==`function`}};const ms={turnComplete:!0};var hs=class{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(t.turns!==null&&t.turns!==void 0){let n=[];try{n=F(t.turns),e.isVertexAI()||(n=n.map(e=>Li(e)))}catch{throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(t.functionResponses==null||(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],n.length===0))throw Error(`functionResponses is required.`);for(let t of n){if(typeof t!=`object`||!t||!(`name`in t)||!(`response`in t))throw Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!(`id`in t))throw Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},ms),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:Si(e)}:{realtimeInput:xi(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(e.functionResponses==null)throw Error(`Tool response parameters are required.`);let t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}};function gs(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function _s(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}function vs(e){if(e?.automaticFunctionCalling?.disable)return!0;let t=!1;for(let n of e?.tools??[])if(q(n)){t=!0;break}if(!t)return!0;let n=e?.automaticFunctionCalling?.maximumRemoteCalls;return n&&(n<0||!Number.isInteger(n))||n==0?(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:`,n),!0):!1}function q(e){return`callTool`in e&&typeof e.callTool==`function`}function ys(e){return(e.config?.tools)?.some(e=>q(e))??!1}function bs(e){let t=[];return e?.config?.tools&&e.config.tools.forEach((e,n)=>{if(q(e))return;let r=e;r.functionDeclarations&&r.functionDeclarations.length>0&&t.push(n)}),t}function xs(e){return!e?.automaticFunctionCalling?.ignoreCallHistory}
108
+ /**
109
+ * @license
110
+ * Copyright 2025 Google LLC
111
+ * SPDX-License-Identifier: Apache-2.0
112
+ */
113
+ var Ss=class extends u{constructor(e){super(),this.apiClient=e,this.embedContent=async e=>{if(!this.apiClient.isVertexAI())return await this.embedContentInternal(e);if(e.model.includes(`gemini`)&&e.model!==`gemini-embedding-001`||e.model.includes(`maas`)){let t=F(e.contents);if(t.length>1)throw Error(`The embedContent API for this model only supports one content at a time.`);let n=Object.assign(Object.assign({},e),{content:t[0],embeddingApiType:je.EMBED_CONTENT});return await this.embedContentInternal(n)}else{let t=Object.assign(Object.assign({},e),{embeddingApiType:je.PREDICT});return await this.embedContentInternal(t)}},this.generateContent=async e=>{let t=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!ys(e)||vs(e.config))return await this.generateContentInternal(t);let n=bs(e);if(n.length>0){let e=n.map(e=>`tools[${e}]`).join(`, `);throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let r,i,a=F(t.contents),o=t.config?.automaticFunctionCalling?.maximumRemoteCalls??10,s=0;for(;s<o&&(r=await this.generateContentInternal(t),!(!r.functionCalls||r.functionCalls.length===0));){let n=r.candidates[0].content,o=[];for(let t of e.config?.tools??[])if(q(t)){let e=await t.callTool(r.functionCalls);o.push(...e)}s++,i={role:`user`,parts:o},t.contents=F(t.contents),t.contents.push(n),t.contents.push(i),xs(t.config)&&(a.push(n),a.push(i))}return xs(t.config)&&(r.automaticFunctionCallingHistory=a),r},this.generateContentStream=async e=>{if(this.maybeMoveToResponseJsonSchem(e),vs(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let t=bs(e);if(t.length>0){let e=t.map(e=>`tools[${e}]`).join(`, `);throw Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let n=e?.config?.toolConfig?.functionCallingConfig?.streamFunctionCallArguments,r=e?.config?.automaticFunctionCalling?.disable;if(n&&!r)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(e)},this.generateImages=async e=>await this.generateImagesInternal(e).then(e=>{let t,n=[];if(e?.generatedImages)for(let r of e.generatedImages)r&&r?.safetyAttributes&&r?.safetyAttributes?.contentType===`Positive Prompt`?t=r?.safetyAttributes:n.push(r);let r;return r=t?{generatedImages:n,positivePromptSafetyAttributes:t,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:n,sdkHttpResponse:e.sdkHttpResponse},r}),this.list=async e=>{let t={config:Object.assign(Object.assign({},{queryBase:!0}),e?.config)};if(this.apiClient.isVertexAI()&&!t.config.queryBase){if(t.config?.filter)throw Error(`Filtering tuned models list for Vertex AI is not currently supported`);t.config.filter=`labels.tune-type:*`}return new H(V.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(t),t)},this.editImage=async e=>{let t={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};return e.referenceImages&&e.referenceImages&&(t.referenceImages=e.referenceImages.map(e=>e.toReferenceImageAPI())),await this.editImageInternal(t)},this.upscaleImage=async e=>{let t={numberOfImages:1,mode:`upscale`};e.config&&(t=Object.assign(Object.assign({},t),e.config));let n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{if((e.prompt||e.image||e.video)&&e.source)throw Error(`Source and prompt/image/video are mutually exclusive. Please only use source.`);return this.apiClient.isVertexAI()||(e.video?.uri&&e.video?.videoBytes?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:e.source?.video?.uri&&e.source?.video?.videoBytes&&(e.source.video={uri:e.source.video.uri,mimeType:e.source.video.mimeType})),await this.generateVideosInternal(e)}}maybeMoveToResponseJsonSchem(e){e.config&&e.config.responseSchema&&(e.config.responseJsonSchema||Object.keys(e.config.responseSchema).includes(`$schema`)&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema))}async processParamsMaybeAddMcpUsage(e){let t=e.config?.tools;if(!t)return e;let n=await Promise.all(t.map(async e=>q(e)?await e.tool():e)),r={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:n})};if(r.config.tools=n,e.config&&e.config.tools&&ns(e.config.tools)){let t=e.config.httpOptions?.headers??{},n=Object.assign({},t);Object.keys(n).length===0&&(n=this.apiClient.getDefaultHeaders()),rs(n),r.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:n})}return r}async initAfcToolsMap(e){let t=new Map;for(let n of e.config?.tools??[])if(q(n)){let e=n,r=await e.tool();for(let n of r.functionDeclarations??[]){if(!n.name)throw Error(`Function declaration name is required.`);if(t.has(n.name))throw Error(`Duplicate tool declaration name: ${n.name}`);t.set(n.name,e)}}return t}async processAfcStream(e){let t=e.config?.automaticFunctionCalling?.maximumRemoteCalls??10,n=!1,r=0,i=await this.initAfcToolsMap(e);return(function(e,i,a){return W(this,arguments,function*(){for(var o,s,c,l;r<t;){n&&=(r++,!1);let p=yield U(e.processParamsMaybeAddMcpUsage(a)),m=yield U(e.generateContentStreamInternal(p)),h=[],g=[];try{for(var u=!0,d=(s=void 0,G(m)),f;f=yield U(d.next()),o=f.done,!o;u=!0){l=f.value,u=!1;let e=l;if(yield yield U(e),e.candidates&&e.candidates[0]?.content){g.push(e.candidates[0].content);for(let n of e.candidates[0].content.parts??[])if(r<t&&n.functionCall){if(!n.functionCall.name)throw Error(`Function call name was not returned by the model.`);if(i.has(n.functionCall.name)){let e=yield U(i.get(n.functionCall.name).callTool([n.functionCall]));h.push(...e)}else throw Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${i.keys()}, mising tool: ${n.functionCall.name}`)}}}}catch(e){s={error:e}}finally{try{!u&&!o&&(c=d.return)&&(yield U(c.call(d)))}finally{if(s)throw s.error}}if(h.length>0){n=!0;let e=new at;e.candidates=[{content:{role:`user`,parts:h}}],yield yield U(e);let t=[];t.push(...g),t.push({role:`user`,parts:h}),a.contents=F(a.contents).concat(t)}else break}})})(this,i,e)}async generateContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=fa(this.apiClient,e);return n=d(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ma(e),n=new at;return Object.assign(n,t),n})}else{let i=da(this.apiClient,e);return n=d(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=pa(e),n=new at;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=fa(this.apiClient,e);return n=d(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(t){return W(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=G(t),c;c=yield U(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=ma(yield U(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new at;Object.assign(r,n),yield yield U(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield U(i.call(s)))}finally{if(r)throw r.error}}})})}else{let i=da(this.apiClient,e);return n=d(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(t){return W(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=G(t),c;c=yield U(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=pa(yield U(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new at;Object.assign(r,n),yield yield U(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield U(i.call(s)))}finally{if(r)throw r.error}}})})}}async embedContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ta(this.apiClient,e,e);return n=d(dn(e.model)?`{model}:embedContent`:`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(t=>{let n=ra(t,e),r=new ot;return Object.assign(r,n),r})}else{let i=ea(this.apiClient,e);return n=d(`{model}:batchEmbedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=na(e),n=new ot;return Object.assign(n,t),n})}}async generateImagesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=va(this.apiClient,e);return n=d(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ba(e),n=new st;return Object.assign(n,t),n})}else{let i=_a(this.apiClient,e);return n=d(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ya(e),n=new st;return Object.assign(n,t),n})}}async editImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Xi(this.apiClient,e);return n=d(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Zi(e),n=new ct;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async upscaleImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Do(this.apiClient,e);return n=d(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Oo(e),n=new lt;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async recontextImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=io(this.apiClient,e);return n=d(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=ao(e),n=new ut;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async segmentImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=mo(this.apiClient,e);return n=d(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=ho(e),n=new dt;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ra(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>eo(e))}else{let i=La(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>$a(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ya(this.apiClient,e);return n=d(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Za(e),n=new ft;return Object.assign(n,t),n})}else{let i=Ja(this.apiClient,e);return n=d(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Xa(e),n=new ft;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=To(this.apiClient,e);return n=d(`{model}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>eo(e))}else{let i=wo(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>$a(e))}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ki(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ji(e),n=new pt;return Object.assign(n,t),n})}else{let i=Gi(this.apiClient,e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=qi(e),n=new pt;return Object.assign(n,t),n})}}async countTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Hi(this.apiClient,e);return n=d(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Wi(e),n=new mt;return Object.assign(n,t),n})}else{let i=Vi(this.apiClient,e);return n=d(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ui(e),n=new mt;return Object.assign(n,t),n})}}async computeTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ni(this.apiClient,e);return n=d(`{model}:computeTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Pi(e),n=new ht;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async generateVideosInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ea(this.apiClient,e);return n=d(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=wa(e),n=new gt;return Object.assign(n,t),n})}else{let i=Ta(this.apiClient,e);return n=d(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Ca(e),n=new gt;return Object.assign(n,t),n})}}},Cs=class extends u{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}else{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}else{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=T(e);return n=d(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}else{let i=w(e);return n=d(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}}async fetchPredictVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_(e);return n=d(`{resourceName}:fetchPredictOperation`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}else throw Error(`This method is only supported by the Vertex AI.`)}};
114
+ /**
115
+ * @license
116
+ * Copyright 2025 Google LLC
117
+ * SPDX-License-Identifier: Apache-2.0
118
+ */
119
+ function ws(e){let t={},n=p(e,[`data`]);if(n!=null&&f(t,[`data`],n),p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function Ts(e){let t={},n=p(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ps(e))),f(t,[`parts`],e)}let r=p(e,[`role`]);return r!=null&&f(t,[`role`],r),t}function Es(e,t,n){let r={},i=p(t,[`expireTime`]);n!==void 0&&i!=null&&f(n,[`expireTime`],i);let a=p(t,[`newSessionExpireTime`]);n!==void 0&&a!=null&&f(n,[`newSessionExpireTime`],a);let o=p(t,[`uses`]);n!==void 0&&o!=null&&f(n,[`uses`],o);let s=p(t,[`liveConnectConstraints`]);n!==void 0&&s!=null&&f(n,[`bidiGenerateContentSetup`],Ns(e,s));let c=p(t,[`lockAdditionalFields`]);return n!==void 0&&c!=null&&f(n,[`fieldMask`],c),r}function Ds(e,t){let n={},r=p(t,[`config`]);return r!=null&&f(n,[`config`],Es(e,r,n)),n}function Os(e){let t={};if(p(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=p(e,[`fileUri`]);n!=null&&f(t,[`fileUri`],n);let r=p(e,[`mimeType`]);return r!=null&&f(t,[`mimeType`],r),t}function ks(e){let t={},n=p(e,[`id`]);n!=null&&f(t,[`id`],n);let r=p(e,[`args`]);r!=null&&f(t,[`args`],r);let i=p(e,[`name`]);if(i!=null&&f(t,[`name`],i),p(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(p(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function As(e){let t={};if(p(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=p(e,[`enableWidget`]);return n!=null&&f(t,[`enableWidget`],n),t}function js(e){let t={},n=p(e,[`searchTypes`]);if(n!=null&&f(t,[`searchTypes`],n),p(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(p(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let r=p(e,[`timeRangeFilter`]);return r!=null&&f(t,[`timeRangeFilter`],r),t}function Ms(e,t){let n={},r=p(e,[`generationConfig`]);t!==void 0&&r!=null&&f(t,[`setup`,`generationConfig`],r);let i=p(e,[`responseModalities`]);t!==void 0&&i!=null&&f(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=p(e,[`temperature`]);t!==void 0&&a!=null&&f(t,[`setup`,`generationConfig`,`temperature`],a);let o=p(e,[`topP`]);t!==void 0&&o!=null&&f(t,[`setup`,`generationConfig`,`topP`],o);let s=p(e,[`topK`]);t!==void 0&&s!=null&&f(t,[`setup`,`generationConfig`,`topK`],s);let c=p(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&f(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=p(e,[`mediaResolution`]);t!==void 0&&l!=null&&f(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=p(e,[`seed`]);t!==void 0&&u!=null&&f(t,[`setup`,`generationConfig`,`seed`],u);let d=p(e,[`speechConfig`]);t!==void 0&&d!=null&&f(t,[`setup`,`generationConfig`,`speechConfig`],Jt(d));let m=p(e,[`thinkingConfig`]);t!==void 0&&m!=null&&f(t,[`setup`,`generationConfig`,`thinkingConfig`],m);let h=p(e,[`enableAffectiveDialog`]);t!==void 0&&h!=null&&f(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],h);let g=p(e,[`systemInstruction`]);t!==void 0&&g!=null&&f(t,[`setup`,`systemInstruction`],Ts(P(g)));let _=p(e,[`tools`]);if(t!==void 0&&_!=null){let e=L(_);Array.isArray(e)&&(e=e.map(e=>Is(I(e)))),f(t,[`setup`,`tools`],e)}let v=p(e,[`sessionResumption`]);t!==void 0&&v!=null&&f(t,[`setup`,`sessionResumption`],Fs(v));let y=p(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&f(t,[`setup`,`inputAudioTranscription`],y);let b=p(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&f(t,[`setup`,`outputAudioTranscription`],b);let x=p(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&f(t,[`setup`,`realtimeInputConfig`],x);let S=p(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&f(t,[`setup`,`contextWindowCompression`],S);let C=p(e,[`proactivity`]);if(t!==void 0&&C!=null&&f(t,[`setup`,`proactivity`],C),p(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);return n}function Ns(e,t){let n={},r=p(t,[`model`]);r!=null&&f(n,[`setup`,`model`],N(e,r));let i=p(t,[`config`]);return i!=null&&f(n,[`config`],Ms(i,n)),n}function Ps(e){let t={},n=p(e,[`mediaResolution`]);n!=null&&f(t,[`mediaResolution`],n);let r=p(e,[`codeExecutionResult`]);r!=null&&f(t,[`codeExecutionResult`],r);let i=p(e,[`executableCode`]);i!=null&&f(t,[`executableCode`],i);let a=p(e,[`fileData`]);a!=null&&f(t,[`fileData`],Os(a));let o=p(e,[`functionCall`]);o!=null&&f(t,[`functionCall`],ks(o));let s=p(e,[`functionResponse`]);s!=null&&f(t,[`functionResponse`],s);let c=p(e,[`inlineData`]);c!=null&&f(t,[`inlineData`],ws(c));let l=p(e,[`text`]);l!=null&&f(t,[`text`],l);let u=p(e,[`thought`]);u!=null&&f(t,[`thought`],u);let d=p(e,[`thoughtSignature`]);d!=null&&f(t,[`thoughtSignature`],d);let m=p(e,[`videoMetadata`]);return m!=null&&f(t,[`videoMetadata`],m),t}function Fs(e){let t={},n=p(e,[`handle`]);if(n!=null&&f(t,[`handle`],n),p(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function Is(e){let t={};if(p(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=p(e,[`computerUse`]);n!=null&&f(t,[`computerUse`],n);let r=p(e,[`fileSearch`]);r!=null&&f(t,[`fileSearch`],r);let i=p(e,[`googleSearch`]);i!=null&&f(t,[`googleSearch`],js(i));let a=p(e,[`codeExecution`]);if(a!=null&&f(t,[`codeExecution`],a),p(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let o=p(e,[`functionDeclarations`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`functionDeclarations`],e)}let s=p(e,[`googleMaps`]);s!=null&&f(t,[`googleMaps`],As(s));let c=p(e,[`googleSearchRetrieval`]);c!=null&&f(t,[`googleSearchRetrieval`],c);let l=p(e,[`urlContext`]);l!=null&&f(t,[`urlContext`],l);let u=p(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`mcpServers`],e)}return t}
120
+ /**
121
+ * @license
122
+ * Copyright 2025 Google LLC
123
+ * SPDX-License-Identifier: Apache-2.0
124
+ */
125
+ function Ls(e){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];if(typeof r==`object`&&r&&Object.keys(r).length>0){let e=Object.keys(r).map(e=>`${n}.${e}`);t.push(...e)}else t.push(n)}return t.join(`,`)}function Rs(e,t){let n=null,r=e.bidiGenerateContentSetup;if(typeof r==`object`&&r&&`setup`in r){let t=r.setup;typeof t==`object`&&t?(e.bidiGenerateContentSetup=t,n=t):delete e.bidiGenerateContentSetup}else r!==void 0&&delete e.bidiGenerateContentSetup;let i=e.fieldMask;if(n){let r=Ls(n);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)r?e.fieldMask=r:delete e.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){let t=[`temperature`,`topK`,`topP`,`maxOutputTokens`,`responseModalities`,`seed`,`speechConfig`],n=[];i.length>0&&(n=i.map(e=>t.includes(e)?`generationConfig.${e}`:e));let a=[];r&&a.push(r),n.length>0&&a.push(...n),a.length>0?e.fieldMask=a.join(`,`):delete e.fieldMask}else delete e.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(`,`):delete e.fieldMask;return e}var zs=class extends u{constructor(e){super(),this.apiClient=e}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`The client.tokens.create method is only supported by the Gemini Developer API.`);{let i=Ds(this.apiClient,e);n=d(`auth_tokens`,i._url),r=i._query,delete i.config,delete i._url,delete i._query;let a=Rs(i,e.config);return t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(a),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}};
126
+ /**
127
+ * @license
128
+ * Copyright 2025 Google LLC
129
+ * SPDX-License-Identifier: Apache-2.0
130
+ */
131
+ function Bs(e,t){let n={},r=p(e,[`force`]);return t!==void 0&&r!=null&&f(t,[`_query`,`force`],r),n}function Vs(e){let t={},n=p(e,[`name`]);n!=null&&f(t,[`_url`,`name`],n);let r=p(e,[`config`]);return r!=null&&Bs(r,t),t}function Hs(e){let t={},n=p(e,[`name`]);return n!=null&&f(t,[`_url`,`name`],n),t}function Us(e,t){let n={},r=p(e,[`pageSize`]);t!==void 0&&r!=null&&f(t,[`_query`,`pageSize`],r);let i=p(e,[`pageToken`]);return t!==void 0&&i!=null&&f(t,[`_query`,`pageToken`],i),n}function Ws(e){let t={},n=p(e,[`parent`]);n!=null&&f(t,[`_url`,`parent`],n);let r=p(e,[`config`]);return r!=null&&Us(r,t),t}function Gs(e){let t={},n=p(e,[`sdkHttpResponse`]);n!=null&&f(t,[`sdkHttpResponse`],n);let r=p(e,[`nextPageToken`]);r!=null&&f(t,[`nextPageToken`],r);let i=p(e,[`documents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),f(t,[`documents`],e)}return t}
132
+ /**
133
+ * @license
134
+ * Copyright 2025 Google LLC
135
+ * SPDX-License-Identifier: Apache-2.0
136
+ */
137
+ var Ks=class extends u{constructor(e){super(),this.apiClient=e,this.list=async e=>new H(V.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Hs(e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=Vs(e);t=d(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Ws(e);return n=d(`{parent}/documents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Gs(e),n=new xt;return Object.assign(n,t),n})}}},qs=class extends u{constructor(e,t=new Ks(e)){super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new H(V.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw Error(`Vertex AI does not support uploading files to a file search store.`);return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Lo(e);return n=d(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Bo(e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=zo(e);t=d(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Ko(e);return n=d(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=qo(e),n=new St;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Yo(e);return n=d(`upload/v1beta/{file_search_store_name}:uploadToFileSearchStore`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Xo(e),n=new Ct;return Object.assign(n,t),n})}}async importFile(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Uo(e);return n=d(`{file_search_store_name}:importFile`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Ho(e),n=new wt;return Object.assign(n,t),n})}}};
138
+ /**
139
+ * @license
140
+ * Copyright 2025 Google LLC
141
+ * SPDX-License-Identifier: Apache-2.0
142
+ */
143
+ let Js=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Js=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};const Ys=()=>Js();
144
+ /**
145
+ * @license
146
+ * Copyright 2025 Google LLC
147
+ * SPDX-License-Identifier: Apache-2.0
148
+ */
149
+ function Xs(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const Zs=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};
150
+ /**
151
+ * @license
152
+ * Copyright 2025 Google LLC
153
+ * SPDX-License-Identifier: Apache-2.0
154
+ */
155
+ var J=class extends Error{},Y=class e extends J{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.error=n}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new $s({message:r,cause:Zs(n)});let a=n;return t===400?new tc(t,a,r,i):t===401?new nc(t,a,r,i):t===403?new rc(t,a,r,i):t===404?new ic(t,a,r,i):t===409?new ac(t,a,r,i):t===422?new oc(t,a,r,i):t===429?new sc(t,a,r,i):t>=500?new cc(t,a,r,i):new e(t,a,r,i)}},Qs=class extends Y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},$s=class extends Y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ec=class extends $s{constructor({message:e}={}){super({message:e??`Request timed out.`})}},tc=class extends Y{},nc=class extends Y{},rc=class extends Y{},ic=class extends Y{},ac=class extends Y{},oc=class extends Y{},sc=class extends Y{},cc=class extends Y{};
156
+ /**
157
+ * @license
158
+ * Copyright 2025 Google LLC
159
+ * SPDX-License-Identifier: Apache-2.0
160
+ */
161
+ const lc=/^[a-z][a-z0-9+.-]*:/i,uc=e=>lc.test(e);let dc=e=>(dc=Array.isArray,dc(e));const fc=dc;function pc(e){if(!e)return!0;for(let t in e)return!1;return!0}function mc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const hc=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new J(`${e} must be an integer`);if(t<0)throw new J(`${e} must be a positive integer`);return t},gc=e=>{try{return JSON.parse(e)}catch{return}},_c=e=>new Promise(t=>setTimeout(t,e)),X=`0.0.1`;
162
+ /**
163
+ * @license
164
+ * Copyright 2025 Google LLC
165
+ * SPDX-License-Identifier: Apache-2.0
166
+ */
167
+ function vc(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}const yc=()=>{let e=vc();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":X,"X-Stainless-OS":Sc(Deno.build.os),"X-Stainless-Arch":xc(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":X,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":X,"X-Stainless-OS":Sc(globalThis.process.platform??`unknown`),"X-Stainless-Arch":xc(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=bc();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":X,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":X,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function bc(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}const xc=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Sc=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`);let Cc;const wc=()=>Cc??=yc();
168
+ /**
169
+ * @license
170
+ * Copyright 2025 Google LLC
171
+ * SPDX-License-Identifier: Apache-2.0
172
+ */
173
+ function Tc(){if(typeof fetch<`u`)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`")}function Ec(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Dc(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ec({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.call(t)}})}function Oc(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function kc(e){var t;if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await(t=e[Symbol.asyncIterator]()).return?.call(t);return}let n=e.getReader(),r=n.cancel();n.releaseLock(),await r}
174
+ /**
175
+ * @license
176
+ * Copyright 2025 Google LLC
177
+ * SPDX-License-Identifier: Apache-2.0
178
+ */
179
+ const Ac=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)}),jc=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}};function Mc(e,t,n){return jc(),new File(e,t??`unknown_file`,n)}function Nc(e){return(typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``).split(/[\\/]/).pop()||void 0}const Pc=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,Fc=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,Ic=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&Fc(e),Lc=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`;async function Rc(e,t,n){if(jc(),e=await e,Ic(e))return e instanceof File?e:Mc([await e.arrayBuffer()],e.name);if(Lc(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),Mc(await zc(r),t,n)}let r=await zc(e);if(t||=Nc(e),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n=Object.assign(Object.assign({},n),{type:e}))}return Mc(r,t,n)}async function zc(e){var t,n,r,i;let a=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)a.push(e);else if(Fc(e))a.push(e instanceof Blob?e:await e.arrayBuffer());else if(Pc(e))try{for(var o=!0,s=G(e),c;c=await s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;a.push(...await zc(e))}}catch(e){n={error:e}}finally{try{!o&&!t&&(r=s.return)&&await r.call(s)}finally{if(n)throw n.error}}else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${Bc(e)}`)}return a}function Bc(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}
180
+ /**
181
+ * @license
182
+ * Copyright 2025 Google LLC
183
+ * SPDX-License-Identifier: Apache-2.0
184
+ */
185
+ var Vc=class{constructor(e){this._client=e}};Vc._key=[];
186
+ /**
187
+ * @license
188
+ * Copyright 2025 Google LLC
189
+ * SPDX-License-Identifier: Apache-2.0
190
+ */
191
+ function Hc(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Uc=Object.freeze(Object.create(null)),Wc=((e=Hc)=>(function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??Uc)??Uc)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],s=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=s.exec(o))!==null;){let e=c[0].startsWith(`/`),t=+!!e,n=e?c[0].slice(1):c[0];i.push({start:c.index+t,length:n.length,error:`Value "${n}" can\'t be safely passed as a path parameter`})}if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new J(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
192
+ `)}\n${a}\n${t}`)}return a}))(Hc);
193
+ /**
194
+ * @license
195
+ * Copyright 2025 Google LLC
196
+ * SPDX-License-Identifier: Apache-2.0
197
+ */
198
+ var Gc=class extends Vc{create(e,t){let{api_version:n=this._client.apiVersion}=e,r=Vr(e,[`api_version`]);if(`model`in r&&`agent_config`in r)throw new J("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if(`agent`in r&&`generation_config`in r)throw new J("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(Wc`/${n}/interactions`,Object.assign(Object.assign({body:r},t),{stream:e.stream??!1}))}delete(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.delete(Wc`/${r}/interactions/${e}`,n)}cancel(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.post(Wc`/${r}/interactions/${e}/cancel`,n)}get(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion}=r,a=Vr(r,[`api_version`]);return this._client.get(Wc`/${i}/interactions/${e}`,Object.assign(Object.assign({query:a},n),{stream:t?.stream??!1}))}};Gc._key=Object.freeze([`interactions`]);var Kc=class extends Gc{};
199
+ /**
200
+ * @license
201
+ * Copyright 2025 Google LLC
202
+ * SPDX-License-Identifier: Apache-2.0
203
+ */
204
+ function qc(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}let Jc;function Yc(e){let t;return(Jc??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Xc;function Zc(e){let t;return(Xc??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}
205
+ /**
206
+ * @license
207
+ * Copyright 2025 Google LLC
208
+ * SPDX-License-Identifier: Apache-2.0
209
+ */
210
+ var Qc=class{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Yc(e):e;this.buffer=qc([this.buffer,t]);let n=[],r;for(;(r=$c(this.buffer,this.carriageReturnIndex))!=null;){if(r.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=r.index;continue}if(this.carriageReturnIndex!=null&&(r.index!==this.carriageReturnIndex+1||r.carriage)){n.push(Zc(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}let e=this.carriageReturnIndex===null?r.preceding:r.preceding-1,t=Zc(this.buffer.subarray(0,e));n.push(t),this.buffer=this.buffer.subarray(r.index),this.carriageReturnIndex=null}return n}flush(){return this.buffer.length?this.decode(`
211
+ `):[]}};Qc.NEWLINE_CHARS=new Set([`
212
+ `,`\r`]),Qc.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function $c(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function el(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}
213
+ /**
214
+ * @license
215
+ * Copyright 2025 Google LLC
216
+ * SPDX-License-Identifier: Apache-2.0
217
+ */
218
+ const tl={off:0,error:200,warn:300,info:400,debug:500},nl=(e,t,n)=>{if(e){if(mc(tl,e))return e;Z(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(tl))}`)}};function rl(){}function il(e,t,n){return!t||tl[e]>tl[n]?rl:t[e].bind(t)}const al={error:rl,warn:rl,info:rl,debug:rl};let ol=new WeakMap;function Z(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return al;let r=ol.get(t);if(r&&r[0]===n)return r[1];let i={error:il(`error`,t,n),warn:il(`warn`,t,n),info:il(`info`,t,n),debug:il(`debug`,t,n)};return ol.set(t,[n,i]),i}const Q=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-goog-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);
219
+ /**
220
+ * @license
221
+ * Copyright 2025 Google LLC
222
+ * SPDX-License-Identifier: Apache-2.0
223
+ */
224
+ var sl=class e{constructor(e,t,n){this.iterator=e,this.controller=t,this.client=n}static fromSSEResponse(t,n,r){let i=!1,a=r?Z(r):console;function o(){return W(this,arguments,function*(){var e,r,o,s;if(i)throw new J("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let c=!1;try{try{for(var l=!0,u=G(cl(t,n)),d;d=yield U(u.next()),e=d.done,!e;l=!0){s=d.value,l=!1;let e=s;if(!c)if(e.data.startsWith(`[DONE]`)){c=!0;continue}else try{yield yield U(JSON.parse(e.data))}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}}}catch(e){r={error:e}}finally{try{!l&&!e&&(o=u.return)&&(yield U(o.call(u)))}finally{if(r)throw r.error}}c=!0}catch(e){if(Xs(e))return yield U(void 0);throw e}finally{c||n.abort()}})}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;function a(){return W(this,arguments,function*(){var e,n,r,i;let a=new Qc,o=Oc(t);try{for(var s=!0,c=G(o),l;l=yield U(c.next()),e=l.done,!e;s=!0){i=l.value,s=!1;let e=i;for(let t of a.decode(e))yield yield U(t)}}catch(e){n={error:e}}finally{try{!s&&!e&&(r=c.return)&&(yield U(r.call(c)))}finally{if(n)throw n.error}}for(let e of a.flush())yield yield U(e)})}function o(){return W(this,arguments,function*(){var e,t,r,o;if(i)throw new J("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let s=!1;try{try{for(var c=!0,l=G(a()),u;u=yield U(l.next()),e=u.done,!e;c=!0){o=u.value,c=!1;let e=o;s||e&&(yield yield U(JSON.parse(e)))}}catch(e){t={error:e}}finally{try{!c&&!e&&(r=l.return)&&(yield U(r.call(l)))}finally{if(t)throw t.error}}s=!0}catch(e){if(Xs(e))return yield U(void 0);throw e}finally{s||n.abort()}})}return new e(o,n,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,this.client),new e(()=>i(n),this.controller,this.client)]}toReadableStream(){let e=this,t;return Ec({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Yc(JSON.stringify(n)+`
225
+ `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.call(t)}})}};function cl(e,t){return W(this,arguments,function*(){var n,r,i,a;if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new J(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new J(`Attempted to iterate over a response with no body`);let o=new ul,s=new Qc,c=Oc(e.body);try{for(var l=!0,u=G(ll(c)),d;d=yield U(u.next()),n=d.done,!n;l=!0){a=d.value,l=!1;let e=a;for(let t of s.decode(e)){let e=o.decode(t);e&&(yield yield U(e))}}}catch(e){r={error:e}}finally{try{!l&&!n&&(i=u.return)&&(yield U(i.call(u)))}finally{if(r)throw r.error}}for(let e of s.flush()){let t=o.decode(e);t&&(yield yield U(t))}})}function ll(e){return W(this,arguments,function*(){var t,n,r,i;let a=new Uint8Array;try{for(var o=!0,s=G(e),c;c=yield U(s.next()),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;if(e==null)continue;let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Yc(e):e,n=new Uint8Array(a.length+t.length);n.set(a),n.set(t,a.length),a=n;let r;for(;(r=el(a))!==-1;)yield yield U(a.slice(0,r)),a=a.slice(r)}}catch(e){n={error:e}}finally{try{!o&&!t&&(r=s.return)&&(yield U(r.call(s)))}finally{if(n)throw n.error}}a.length>0&&(yield yield U(a))})}var ul=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
226
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=dl(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function dl(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}
227
+ /**
228
+ * @license
229
+ * Copyright 2025 Google LLC
230
+ * SPDX-License-Identifier: Apache-2.0
231
+ */
232
+ async function fl(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return Z(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):sl.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=(n.headers.get(`content-type`)?.split(`;`)[0])?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:await n.json():await n.text()})();return Z(e).debug(`[${r}] response parsed`,Q({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}
233
+ /**
234
+ * @license
235
+ * Copyright 2025 Google LLC
236
+ * SPDX-License-Identifier: Apache-2.0
237
+ */
238
+ var pl=class e extends Promise{constructor(e,t,n=fl){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,this.client=e}_thenUnwrap(t){return new e(this.client,this.responsePromise,async(e,n)=>t(await this.parseResponse(e,n),n))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t}}parse(){return this.parsedPromise||=this.responsePromise.then(e=>this.parseResponse(this.client,e)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};
239
+ /**
240
+ * @license
241
+ * Copyright 2025 Google LLC
242
+ * SPDX-License-Identifier: Apache-2.0
243
+ */
244
+ const ml=Symbol(`brand.privateNullableHeaders`);function*hl(e){if(!e)return;if(ml in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():fc(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=fc(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}const gl=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of hl(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[ml]:!0,values:t,nulls:n}},_l=e=>{var t;if(globalThis.process!==void 0)return({}?.[e])?.trim()??void 0;if(globalThis.Deno!==void 0)return(((t=globalThis.Deno.env)?.get)?.call(t,e))?.trim()};
245
+ /**
246
+ * @license
247
+ * Copyright 2025 Google LLC
248
+ * SPDX-License-Identifier: Apache-2.0
249
+ */
250
+ var vl,yl=class e{constructor(t){var{baseURL:n=_l(`GEMINI_NEXT_GEN_API_BASE_URL`),apiKey:r=_l(`GEMINI_API_KEY`)??null,apiVersion:i=`v1beta`}=t,a=Vr(t,[`baseURL`,`apiKey`,`apiVersion`]);let o=Object.assign(Object.assign({apiKey:r,apiVersion:i},a),{baseURL:n||`https://generativelanguage.googleapis.com`});this.baseURL=o.baseURL,this.timeout=o.timeout??e.DEFAULT_TIMEOUT,this.logger=o.logger??console;let s=`warn`;this.logLevel=s,this.logLevel=nl(o.logLevel,`ClientOptions.logLevel`,this)??nl(_l(`GEMINI_NEXT_GEN_API_LOG`),`process.env['GEMINI_NEXT_GEN_API_LOG']`,this)??s,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??Tc(),this.encoder=Ac,this._options=o,this.apiKey=r,this.apiVersion=i,this.clientAdapter=o.clientAdapter}withOptions(e){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}),e))}baseURLOverridden(){return this.baseURL!==`https://generativelanguage.googleapis.com`}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.has(`authorization`)||e.has(`x-goog-api-key`))&&!(this.apiKey&&e.get(`x-goog-api-key`))&&!t.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(e){let t=gl([e.headers]);if(!(t.values.has(`authorization`)||t.values.has(`x-goog-api-key`))){if(this.apiKey)return gl([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return gl([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new J(`Cannot stringify type ${typeof t}; 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 ${X}`}defaultIdempotencyKey(){return`stainless-node-retry-${Ys()}`}makeStatusError(e,t,n,r){return Y.generate(e,t,n,r)}buildURL(e,t,n){let r=!this.baseURLOverridden()&&n||this.baseURL,i=uc(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery();return pc(a)||(t=Object.assign(Object.assign({},a),t)),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){let t=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${t}`}}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>Object.assign({method:e,path:t},n)))}request(e,t=null){return new pl(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(Z(this).debug(`[${c}] sending request`,Q({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new Qs;let d=new AbortController,f=await this.fetchWithTimeout(o,a,s,d).catch(Zs),p=Date.now();if(f instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new Qs;let i=Xs(f)||/timed? ?out/i.test(String(f)+(`cause`in f?String(f.cause):``));if(t)return Z(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),Z(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,Q({retryOfRequestLogID:n,url:o,durationMs:p-u,message:f.message})),this.retryRequest(r,t,n??c);throw Z(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),Z(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,Q({retryOfRequestLogID:n,url:o,durationMs:p-u,message:f.message})),i?new ec:new $s({cause:f})}let m=`[${c}${l}] ${a.method} ${o} ${f.ok?`succeeded`:`failed`} with status ${f.status} in ${p-u}ms`;if(!f.ok){let e=await this.shouldRetry(f);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await kc(f.body),Z(this).info(`${m} - ${e}`),Z(this).debug(`[${c}] response error (${e})`,Q({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:p-u})),this.retryRequest(r,t,n??c,f.headers)}let i=e?`error; no more retries left`:`error; not retryable`;Z(this).info(`${m} - ${i}`);let a=await f.text().catch(e=>Zs(e).message),o=gc(a),s=o?void 0:a;throw Z(this).debug(`[${c}] response error (${i})`,Q({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(f.status,o,s,f.headers)}return Z(this).info(m),Z(this).debug(`[${c}] response start`,Q({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:p-u})),{response:f,options:r,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:u}}async fetchWithTimeout(e,t,n,r){let i=t||{},{signal:a,method:o}=i,s=Vr(i,[`signal`,`method`]),c=this._makeAbort(r);a&&a.addEventListener(`abort`,c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&s.body instanceof globalThis.ReadableStream||typeof s.body==`object`&&s.body!==null&&Symbol.asyncIterator in s.body,d=Object.assign(Object.assign(Object.assign({signal:r.signal},u?{duplex:`half`}:{}),{method:`GET`}),s);o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(!(i&&0<=i&&i<60*1e3)){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await _c(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n=Object.assign({},e),{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&hc(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n}),u=await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:r,headers:u},n.signal&&{signal:n.signal}),globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`}),l&&{body:l}),this.fetchOptions??{}),n.fetchOptions??{}),url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=await this.authHeaders(e),o=gl([i,Object.assign(Object.assign({Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),wc()),this._options.defaultHeaders,n,e.headers,a]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=gl([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:Dc(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:this.encoder({body:e,headers:n})}};yl.DEFAULT_TIMEOUT=6e4;var $=class extends yl{constructor(){super(...arguments),this.interactions=new Kc(this)}};vl=$,$.GeminiNextGenAPIClient=vl,$.GeminiNextGenAPIClientError=J,$.APIError=Y,$.APIConnectionError=$s,$.APIConnectionTimeoutError=ec,$.APIUserAbortError=Qs,$.NotFoundError=ic,$.ConflictError=ac,$.RateLimitError=sc,$.BadRequestError=tc,$.AuthenticationError=nc,$.InternalServerError=cc,$.PermissionDeniedError=rc,$.UnprocessableEntityError=oc,$.toFile=Rc,$.Interactions=Kc;
251
+ /**
252
+ * @license
253
+ * Copyright 2025 Google LLC
254
+ * SPDX-License-Identifier: Apache-2.0
255
+ */
256
+ function bl(e,t){let n={},r=p(e,[`name`]);return r!=null&&f(n,[`_url`,`name`],r),n}function xl(e,t){let n={},r=p(e,[`name`]);return r!=null&&f(n,[`_url`,`name`],r),n}function Sl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);return r!=null&&f(n,[`sdkHttpResponse`],r),n}function Cl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);return r!=null&&f(n,[`sdkHttpResponse`],r),n}function wl(e,t,n){let r={};if(p(e,[`validationDataset`])!==void 0)throw Error(`validationDataset parameter is not supported in Gemini API.`);let i=p(e,[`tunedModelDisplayName`]);if(t!==void 0&&i!=null&&f(t,[`displayName`],i),p(e,[`description`])!==void 0)throw Error(`description parameter is not supported in Gemini API.`);let a=p(e,[`epochCount`]);t!==void 0&&a!=null&&f(t,[`tuningTask`,`hyperparameters`,`epochCount`],a);let o=p(e,[`learningRateMultiplier`]);if(o!=null&&f(r,[`tuningTask`,`hyperparameters`,`learningRateMultiplier`],o),p(e,[`exportLastCheckpointOnly`])!==void 0)throw Error(`exportLastCheckpointOnly parameter is not supported in Gemini API.`);if(p(e,[`preTunedModelCheckpointId`])!==void 0)throw Error(`preTunedModelCheckpointId parameter is not supported in Gemini API.`);if(p(e,[`adapterSize`])!==void 0)throw Error(`adapterSize parameter is not supported in Gemini API.`);if(p(e,[`tuningMode`])!==void 0)throw Error(`tuningMode parameter is not supported in Gemini API.`);if(p(e,[`customBaseModel`])!==void 0)throw Error(`customBaseModel parameter is not supported in Gemini API.`);let s=p(e,[`batchSize`]);t!==void 0&&s!=null&&f(t,[`tuningTask`,`hyperparameters`,`batchSize`],s);let c=p(e,[`learningRate`]);if(t!==void 0&&c!=null&&f(t,[`tuningTask`,`hyperparameters`,`learningRate`],c),p(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);if(p(e,[`beta`])!==void 0)throw Error(`beta parameter is not supported in Gemini API.`);if(p(e,[`baseTeacherModel`])!==void 0)throw Error(`baseTeacherModel parameter is not supported in Gemini API.`);if(p(e,[`tunedTeacherModelSource`])!==void 0)throw Error(`tunedTeacherModelSource parameter is not supported in Gemini API.`);if(p(e,[`sftLossWeightMultiplier`])!==void 0)throw Error(`sftLossWeightMultiplier parameter is not supported in Gemini API.`);if(p(e,[`outputUri`])!==void 0)throw Error(`outputUri parameter is not supported in Gemini API.`);if(p(e,[`encryptionSpec`])!==void 0)throw Error(`encryptionSpec parameter is not supported in Gemini API.`);return r}function Tl(e,t,n){let r={},i=p(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=p(e,[`validationDataset`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`],Hl(n))}else if(i===`PREFERENCE_TUNING`){let n=p(e,[`validationDataset`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`],Hl(n))}else if(i===`DISTILLATION`){let n=p(e,[`validationDataset`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`],Hl(n))}let a=p(e,[`tunedModelDisplayName`]);t!==void 0&&a!=null&&f(t,[`tunedModelDisplayName`],a);let o=p(e,[`description`]);t!==void 0&&o!=null&&f(t,[`description`],o);let s=p(n,[`config`,`method`]);if(s===void 0&&(s=`SUPERVISED_FINE_TUNING`),s===`SUPERVISED_FINE_TUNING`){let n=p(e,[`epochCount`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`PREFERENCE_TUNING`){let n=p(e,[`epochCount`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`DISTILLATION`){let n=p(e,[`epochCount`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`,`hyperParameters`,`epochCount`],n)}let c=p(n,[`config`,`method`]);if(c===void 0&&(c=`SUPERVISED_FINE_TUNING`),c===`SUPERVISED_FINE_TUNING`){let n=p(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`PREFERENCE_TUNING`){let n=p(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`DISTILLATION`){let n=p(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}let l=p(n,[`config`,`method`]);if(l===void 0&&(l=`SUPERVISED_FINE_TUNING`),l===`SUPERVISED_FINE_TUNING`){let n=p(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`exportLastCheckpointOnly`],n)}else if(l===`PREFERENCE_TUNING`){let n=p(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`,`exportLastCheckpointOnly`],n)}else if(l===`DISTILLATION`){let n=p(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`,`exportLastCheckpointOnly`],n)}let u=p(n,[`config`,`method`]);if(u===void 0&&(u=`SUPERVISED_FINE_TUNING`),u===`SUPERVISED_FINE_TUNING`){let n=p(e,[`adapterSize`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`PREFERENCE_TUNING`){let n=p(e,[`adapterSize`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`DISTILLATION`){let n=p(e,[`adapterSize`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`,`hyperParameters`,`adapterSize`],n)}let d=p(n,[`config`,`method`]);if(d===void 0&&(d=`SUPERVISED_FINE_TUNING`),d===`SUPERVISED_FINE_TUNING`){let n=p(e,[`tuningMode`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`tuningMode`],n)}let m=p(e,[`customBaseModel`]);t!==void 0&&m!=null&&f(t,[`customBaseModel`],m);let h=p(n,[`config`,`method`]);if(h===void 0&&(h=`SUPERVISED_FINE_TUNING`),h===`SUPERVISED_FINE_TUNING`){let n=p(e,[`batchSize`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`hyperParameters`,`batchSize`],n)}let g=p(n,[`config`,`method`]);if(g===void 0&&(g=`SUPERVISED_FINE_TUNING`),g===`SUPERVISED_FINE_TUNING`){let n=p(e,[`learningRate`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRate`],n)}let _=p(e,[`labels`]);t!==void 0&&_!=null&&f(t,[`labels`],_);let v=p(e,[`beta`]);t!==void 0&&v!=null&&f(t,[`preferenceOptimizationSpec`,`hyperParameters`,`beta`],v);let y=p(e,[`baseTeacherModel`]);t!==void 0&&y!=null&&f(t,[`distillationSpec`,`baseTeacherModel`],y);let b=p(e,[`tunedTeacherModelSource`]);t!==void 0&&b!=null&&f(t,[`distillationSpec`,`tunedTeacherModelSource`],b);let x=p(e,[`sftLossWeightMultiplier`]);t!==void 0&&x!=null&&f(t,[`distillationSpec`,`hyperParameters`,`sftLossWeightMultiplier`],x);let S=p(e,[`outputUri`]);t!==void 0&&S!=null&&f(t,[`outputUri`],S);let C=p(e,[`encryptionSpec`]);return t!==void 0&&C!=null&&f(t,[`encryptionSpec`],C),r}function El(e,t){let n={},r=p(e,[`baseModel`]);r!=null&&f(n,[`baseModel`],r);let i=p(e,[`preTunedModel`]);i!=null&&f(n,[`preTunedModel`],i);let a=p(e,[`trainingDataset`]);a!=null&&Ll(a);let o=p(e,[`config`]);return o!=null&&wl(o,n),n}function Dl(e,t){let n={},r=p(e,[`baseModel`]);r!=null&&f(n,[`baseModel`],r);let i=p(e,[`preTunedModel`]);i!=null&&f(n,[`preTunedModel`],i);let a=p(e,[`trainingDataset`]);a!=null&&Rl(a,n,t);let o=p(e,[`config`]);return o!=null&&Tl(o,n,t),n}function Ol(e,t){let n={},r=p(e,[`name`]);return r!=null&&f(n,[`_url`,`name`],r),n}function kl(e,t){let n={},r=p(e,[`name`]);return r!=null&&f(n,[`_url`,`name`],r),n}function Al(e,t,n){let r={},i=p(e,[`pageSize`]);t!==void 0&&i!=null&&f(t,[`_query`,`pageSize`],i);let a=p(e,[`pageToken`]);t!==void 0&&a!=null&&f(t,[`_query`,`pageToken`],a);let o=p(e,[`filter`]);return t!==void 0&&o!=null&&f(t,[`_query`,`filter`],o),r}function jl(e,t,n){let r={},i=p(e,[`pageSize`]);t!==void 0&&i!=null&&f(t,[`_query`,`pageSize`],i);let a=p(e,[`pageToken`]);t!==void 0&&a!=null&&f(t,[`_query`,`pageToken`],a);let o=p(e,[`filter`]);return t!==void 0&&o!=null&&f(t,[`_query`,`filter`],o),r}function Ml(e,t){let n={},r=p(e,[`config`]);return r!=null&&Al(r,n),n}function Nl(e,t){let n={},r=p(e,[`config`]);return r!=null&&jl(r,n),n}function Pl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`nextPageToken`]);i!=null&&f(n,[`nextPageToken`],i);let a=p(e,[`tunedModels`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>zl(e))),f(n,[`tuningJobs`],e)}return n}function Fl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`nextPageToken`]);i!=null&&f(n,[`nextPageToken`],i);let a=p(e,[`tuningJobs`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>Bl(e))),f(n,[`tuningJobs`],e)}return n}function Il(e,t){let n={},r=p(e,[`name`]);r!=null&&f(n,[`model`],r);let i=p(e,[`name`]);return i!=null&&f(n,[`endpoint`],i),n}function Ll(e,t){let n={};if(p(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(p(e,[`vertexDatasetResource`])!==void 0)throw Error(`vertexDatasetResource parameter is not supported in Gemini API.`);let r=p(e,[`examples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),f(n,[`examples`,`examples`],e)}return n}function Rl(e,t,n){let r={},i=p(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=p(e,[`gcsUri`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(i===`PREFERENCE_TUNING`){let n=p(e,[`gcsUri`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(i===`DISTILLATION`){let n=p(e,[`gcsUri`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`,`promptDatasetUri`],n)}let a=p(n,[`config`,`method`]);if(a===void 0&&(a=`SUPERVISED_FINE_TUNING`),a===`SUPERVISED_FINE_TUNING`){let n=p(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&f(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(a===`PREFERENCE_TUNING`){let n=p(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&f(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(a===`DISTILLATION`){let n=p(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&f(t,[`distillationSpec`,`promptDatasetUri`],n)}if(p(e,[`examples`])!==void 0)throw Error(`examples parameter is not supported in Vertex AI.`);return r}function zl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`name`]);i!=null&&f(n,[`name`],i);let a=p(e,[`state`]);a!=null&&f(n,[`state`],Xt(a));let o=p(e,[`createTime`]);o!=null&&f(n,[`createTime`],o);let s=p(e,[`tuningTask`,`startTime`]);s!=null&&f(n,[`startTime`],s);let c=p(e,[`tuningTask`,`completeTime`]);c!=null&&f(n,[`endTime`],c);let l=p(e,[`updateTime`]);l!=null&&f(n,[`updateTime`],l);let u=p(e,[`description`]);u!=null&&f(n,[`description`],u);let d=p(e,[`baseModel`]);d!=null&&f(n,[`baseModel`],d);let m=p(e,[`_self`]);return m!=null&&f(n,[`tunedModel`],Il(m)),n}function Bl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`name`]);i!=null&&f(n,[`name`],i);let a=p(e,[`state`]);a!=null&&f(n,[`state`],Xt(a));let o=p(e,[`createTime`]);o!=null&&f(n,[`createTime`],o);let s=p(e,[`startTime`]);s!=null&&f(n,[`startTime`],s);let c=p(e,[`endTime`]);c!=null&&f(n,[`endTime`],c);let l=p(e,[`updateTime`]);l!=null&&f(n,[`updateTime`],l);let u=p(e,[`error`]);u!=null&&f(n,[`error`],u);let d=p(e,[`description`]);d!=null&&f(n,[`description`],d);let m=p(e,[`baseModel`]);m!=null&&f(n,[`baseModel`],m);let h=p(e,[`tunedModel`]);h!=null&&f(n,[`tunedModel`],h);let g=p(e,[`preTunedModel`]);g!=null&&f(n,[`preTunedModel`],g);let _=p(e,[`supervisedTuningSpec`]);_!=null&&f(n,[`supervisedTuningSpec`],_);let v=p(e,[`preferenceOptimizationSpec`]);v!=null&&f(n,[`preferenceOptimizationSpec`],v);let y=p(e,[`distillationSpec`]);y!=null&&f(n,[`distillationSpec`],y);let b=p(e,[`tuningDataStats`]);b!=null&&f(n,[`tuningDataStats`],b);let x=p(e,[`encryptionSpec`]);x!=null&&f(n,[`encryptionSpec`],x);let S=p(e,[`partnerModelTuningSpec`]);S!=null&&f(n,[`partnerModelTuningSpec`],S);let C=p(e,[`customBaseModel`]);C!=null&&f(n,[`customBaseModel`],C);let w=p(e,[`experiment`]);w!=null&&f(n,[`experiment`],w);let T=p(e,[`labels`]);T!=null&&f(n,[`labels`],T);let E=p(e,[`outputUri`]);E!=null&&f(n,[`outputUri`],E);let D=p(e,[`pipelineJob`]);D!=null&&f(n,[`pipelineJob`],D);let O=p(e,[`serviceAccount`]);O!=null&&f(n,[`serviceAccount`],O);let k=p(e,[`tunedModelDisplayName`]);k!=null&&f(n,[`tunedModelDisplayName`],k);let A=p(e,[`veoTuningSpec`]);return A!=null&&f(n,[`veoTuningSpec`],A),n}function Vl(e,t){let n={},r=p(e,[`sdkHttpResponse`]);r!=null&&f(n,[`sdkHttpResponse`],r);let i=p(e,[`name`]);i!=null&&f(n,[`name`],i);let a=p(e,[`metadata`]);a!=null&&f(n,[`metadata`],a);let o=p(e,[`done`]);o!=null&&f(n,[`done`],o);let s=p(e,[`error`]);return s!=null&&f(n,[`error`],s),n}function Hl(e,t){let n={},r=p(e,[`gcsUri`]);r!=null&&f(n,[`validationDatasetUri`],r);let i=p(e,[`vertexDatasetResource`]);return i!=null&&f(n,[`validationDatasetUri`],i),n}
257
+ /**
258
+ * @license
259
+ * Copyright 2025 Google LLC
260
+ * SPDX-License-Identifier: Apache-2.0
261
+ */
262
+ var Ul=class extends u{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new H(V.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.get=async e=>await this.getInternal(e),this.tune=async e=>{if(this.apiClient.isVertexAI())if(e.baseModel.startsWith(`projects/`)){let t={tunedModelName:e.baseModel};e.config?.preTunedModelCheckpointId&&(t.checkpointId=e.config.preTunedModelCheckpointId);let n=Object.assign(Object.assign({},e),{preTunedModel:t});return n.baseModel=void 0,await this.tuneInternal(n)}else{let t=Object.assign({},e);return await this.tuneInternal(t)}else{let t=Object.assign({},e),n=await this.tuneMldevInternal(t),r=``;return n.metadata!==void 0&&n.metadata.tunedModel!==void 0?r=n.metadata.tunedModel:n.name!==void 0&&n.name.includes(`/operations/`)&&(r=n.name.split(`/operations/`)[0]),{name:r,state:we.JOB_STATE_QUEUED}}}}async getInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=kl(e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Bl(e))}else{let i=Ol(e);return n=d(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>zl(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Nl(e);return n=d(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Fl(e),n=new _t;return Object.assign(n,t),n})}else{let i=Ml(e);return n=d(`tunedModels`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Pl(e),n=new _t;return Object.assign(n,t),n})}}async cancel(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=xl(e);return n=d(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Cl(e),n=new vt;return Object.assign(n,t),n})}else{let i=bl(e);return n=d(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Sl(e),n=new vt;return Object.assign(n,t),n})}}async tuneInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Dl(e,e);return n=d(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Bl(e))}else throw Error(`This method is only supported by the Vertex AI.`)}async tuneMldevInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=El(e);return n=d(`tunedModels`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Vl(e))}}},Wl=class{async download(e,t){throw Error(`Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.`)}};const Gl=`x-goog-upload-status`;async function Kl(e,t,n){let r=await Jl(e,t,n),i=await r?.json();if(r?.headers?.[Gl]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);return i.file}async function ql(e,t,n){let r=await Jl(e,t,n),i=await r?.json();if(r?.headers?.[Gl]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);let a=O(i),o=new Mt;return Object.assign(o,a),o}async function Jl(e,t,n){let r=0,i=0,a=new it(new Response),o=`upload`;for(r=e.size;i<r;){let s=Math.min(8388608,r-i),c=e.slice(i,i+s);i+s>=r&&(o+=`, finalize`);let l=0,u=1e3;for(;l<3&&(a=await n.request({path:``,body:c,httpMethod:`POST`,httpOptions:{apiVersion:``,baseUrl:t,headers:{"X-Goog-Upload-Command":o,"X-Goog-Upload-Offset":String(i),"Content-Length":String(s)}}}),!a?.headers?.[Gl]);)l++,await Xl(u),u*=2;if(i+=s,a?.headers?.[Gl]!==`active`)break;if(r<=i)throw Error(`All content has been uploaded, but the upload status is not finalized.`)}return a}async function Yl(e){return{size:e.size,type:e.type}}function Xl(e){return new Promise(t=>setTimeout(t,e))}var Zl=class{async upload(e,t,n){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Kl(e,t,n)}async uploadToFileSearchStore(e,t,n){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await ql(e,t,n)}async stat(e){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Yl(e)}},Ql=class{create(e,t,n){return new $l(e,t,n)}},$l=class{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),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(e){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.send(e)}close(){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.close()}};
263
+ /**
264
+ * @license
265
+ * Copyright 2025 Google LLC
266
+ * SPDX-License-Identifier: Apache-2.0
267
+ */
268
+ const eu=`x-goog-api-key`;var tu=class{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(e.get(eu)===null){if(this.apiKey.startsWith(`auth_tokens/`))throw Error(`Ephemeral tokens are only supported by the live API.`);if(!this.apiKey)throw Error(`API key is missing. Please provide a valid API key.`);e.append(eu,this.apiKey)}}},nu=class{get interactions(){if(this._interactions!==void 0)return this._interactions;console.warn(`GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.`);let e=this.httpOptions;e?.extraBody&&console.warn(`GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.`);let t=new $({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:e?.timeout,maxRetries:e?.retryOptions?.attempts});return this._interactions=t.interactions,this._interactions}constructor(e){if(e.apiKey==null)throw Error(`An API Key must be set when running in a browser`);if(e.project||e.location)throw Error(`Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.`);this.vertexai=e.vertexai??!1,this.apiKey=e.apiKey;let t=l(e.httpOptions,e.vertexai,void 0,void 0);t&&(e.httpOptions?e.httpOptions.baseUrl=t:e.httpOptions={baseUrl:t}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let n=new tu(this.apiKey);this.apiClient=new $o({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new Zl,downloader:new Wl}),this.models=new Ss(this.apiClient),this.live=new ps(this.apiClient,n,new Ql),this.batches=new sr(this.apiClient),this.chats=new qr(this.models,this.apiClient),this.caches=new Br(this.apiClient),this.files=new oi(this.apiClient),this.operations=new Cs(this.apiClient),this.authTokens=new zs(this.apiClient),this.tunings=new Ul(this.apiClient),this.fileSearchStores=new qs(this.apiClient)}};function ru(e){return e.thought===!0}function iu(e,t){return typeof t==`string`&&t.length>0?t:e}const au=/^[A-Za-z0-9+/]+={0,2}$/;function ou(e){return!e||e.length%4!=0?!1:au.test(e)}function su(e,t){return e&&ou(t)?t:void 0}function cu(e){return e.startsWith(`claude-`)||e.startsWith(`gpt-oss-`)}function lu(e){let t=e.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(t)return Number.parseInt(t[1],10)}function uu(e){let t=lu(e);return t===void 0?!0:t>=3}function du(e,t){let i=[],a=n(t.messages,e,t=>cu(e.id)?t.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64):t);for(let t of a)if(t.role===`user`)if(typeof t.content==`string`)i.push({role:`user`,parts:[{text:r(t.content)}]});else{let e=t.content.map(e=>e.type===`text`?{text:r(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}});if(e.length===0)continue;i.push({role:`user`,parts:e})}else if(t.role===`assistant`){let n=[],a=t.provider===e.provider&&t.model===e.id;for(let i of t.content)if(i.type===`text`){if(!i.text||i.text.trim()===``)continue;let e=su(a,i.textSignature);n.push({text:r(i.text),...e&&{thoughtSignature:e}})}else if(i.type===`thinking`){if(!i.thinking||i.thinking.trim()===``)continue;if(a){let e=su(a,i.thinkingSignature);n.push({thought:!0,text:r(i.thinking),...e&&{thoughtSignature:e}})}else n.push({text:r(i.thinking)})}else if(i.type===`toolCall`){let t=su(a,i.thoughtSignature),r={functionCall:{name:i.name,args:i.arguments??{},...cu(e.id)?{id:i.id}:{}},...t&&{thoughtSignature:t}};n.push(r)}if(n.length===0)continue;i.push({role:`model`,parts:n})}else if(t.role===`toolResult`){let n=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
269
+ `),a=e.input.includes(`image`)?t.content.filter(e=>e.type===`image`):[],o=n.length>0,s=a.length>0,c=uu(e.id),l=o?r(n):s?`(see attached image)`:``,u=a.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),d=cu(e.id),f={functionResponse:{name:t.toolName,response:t.isError?{error:l}:{output:l},...s&&c&&{parts:u},...d?{id:t.toolCallId}:{}}},p=i[i.length-1];p?.role===`user`&&p.parts?.some(e=>e.functionResponse)?p.parts.push(f):i.push({role:`user`,parts:[f]}),s&&!c&&i.push({role:`user`,parts:[{text:`Tool result image:`},...u]})}return i}const fu=new Set([`$schema`,`$id`,`$anchor`,`$dynamicAnchor`,`$vocabulary`,`$comment`,`$defs`,`definitions`]);function pu(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={};for(let[n,r]of Object.entries(e))fu.has(n)||(t[n]=pu(r));return t}function mu(e,t=!1){if(e.length!==0)return[{functionDeclarations:e.map(e=>({name:e.name,description:e.description,...t?{parameters:pu(e.parameters)}:{parametersJsonSchema:e.parameters}}))}]}function hu(e){switch(e){case`auto`:return ue.AUTO;case`none`:return ue.NONE;case`any`:return ue.ANY;default:return ue.AUTO}}function gu(e){switch(e){case M.STOP:return`stop`;case M.MAX_TOKENS:return`length`;case M.BLOCKLIST:case M.PROHIBITED_CONTENT:case M.SPII:case M.SAFETY:case M.IMAGE_SAFETY:case M.IMAGE_PROHIBITED_CONTENT:case M.IMAGE_RECITATION:case M.IMAGE_OTHER:case M.RECITATION:case M.FINISH_REASON_UNSPECIFIED:case M.OTHER:case M.LANGUAGE:case M.MALFORMED_FUNCTION_CALL:case M.UNEXPECTED_TOOL_CALL:case M.NO_IMAGE:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}export{hu as a,De as c,gu as i,de as l,mu as n,iu as o,ru as r,nu as s,du as t};