sliccy 6.78.1 → 6.78.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.
- package/dist/node-server/cloud-status.d.ts +9 -0
- package/dist/node-server/cloud-status.js +9 -1
- package/dist/ui/.vite/manifest.json +215 -227
- package/dist/ui/assets/{account-store-DFPhEmuH.js → account-store-Bwe7JMH-.js} +1 -1
- package/dist/ui/assets/{account-store-CqA9SSU8.js → account-store-Ch65aCFb.js} +1 -1
- package/dist/ui/assets/{adobe-DxnLH0tB.js → adobe-Bz9Td5du.js} +1 -1
- package/dist/ui/assets/{adobe-C9LIkjuB.js → adobe-DsgfMMl7.js} +1 -1
- package/dist/ui/assets/anthropic-messages-BX4DpK10.js +39 -0
- package/dist/ui/assets/anthropic-messages-C-orWG7m.js +39 -0
- package/dist/ui/assets/{apply-layout-Ba_t-LU-.js → apply-layout-CFIXh5fS.js} +1 -1
- package/dist/ui/assets/{apps-yLGS328q.js → apps-Cs8oR4Lg.js} +1 -1
- package/dist/ui/assets/azure-openai-Cm4-SPmb.js +18 -0
- package/dist/ui/assets/azure-openai-V4ydKR70.js +18 -0
- package/dist/ui/assets/{azure-openai-responses-eJTO6o5G.js → azure-openai-responses-C2LleG-4.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-qqQXNCHy.js → azure-openai-responses-Df9YPxyp.js} +1 -1
- package/dist/ui/assets/bedrock-camp-B0KF_4RS.js +1 -0
- package/dist/ui/assets/bedrock-camp-qpZqnqLa.js +2 -0
- package/dist/ui/assets/{browser-BAL8RehA.js → browser-2rCVqcqy.js} +1 -1
- package/dist/ui/assets/{cerebras-CO_bCsX2.js → cerebras-C51m3zHq.js} +1 -1
- package/dist/ui/assets/{cerebras-Bjmz0nDq.js → cerebras-Cr72hzB7.js} +1 -1
- package/dist/ui/assets/{connect-surface-CKT9YR66.js → connect-surface-BgLFvMBr.js} +1 -1
- package/dist/ui/assets/constrained-sampling-BNmnoM-i.js +1 -0
- package/dist/ui/assets/constrained-sampling-Zzx2ko9x.js +1 -0
- package/dist/ui/assets/dist-DTAqvnM4.js +18 -0
- package/dist/ui/assets/{ensure-speech-assets-DDGWBTuw.js → ensure-speech-assets-DvFwJX-M.js} +1 -1
- package/dist/ui/assets/es-BDNIRkLU.js +51 -0
- package/dist/ui/assets/esptool-operations-BmdosN6N.js +13 -0
- package/dist/ui/assets/{esptool-operations-CDJhOTdU.js → esptool-operations-CbgLIJzi.js} +4 -4
- package/dist/ui/assets/{fs-BGYdXvQe.js → fs-CHduR_z-.js} +2 -2
- package/dist/ui/assets/{fs-BgcV7gMH.js → fs-CrXC-O2d.js} +1 -1
- package/dist/ui/assets/{github-CWDyelVA.js → github-BGfSga5-.js} +1 -1
- package/dist/ui/assets/{github-DigiqZkc.js → github-BIU4tpUD.js} +2 -2
- package/dist/ui/assets/{github-copilot-D3QxDFpn.js → github-copilot-D9Lwnwqf.js} +1 -1
- package/dist/ui/assets/{github-copilot-BUvhiBqo.js → github-copilot-DVH5IrYn.js} +1 -1
- package/dist/ui/assets/{github-install-J_iRe0Qn.js → github-install-BdNHZlYI.js} +1 -1
- package/dist/ui/assets/{github-zip-DA7KS0q8.js → github-zip-CpmjWt7A.js} +1 -1
- package/dist/ui/assets/google-generative-ai-C9uw7Zks.js +1 -0
- package/dist/ui/assets/google-generative-ai-DHBc1oKV.js +1 -0
- package/dist/ui/assets/google-shared-BMJ_JErv.js +11 -0
- package/dist/ui/assets/google-shared-YqcyR4cm.js +371 -0
- package/dist/ui/assets/google-vertex-BaT3InWy.js +1 -0
- package/dist/ui/assets/google-vertex-DX8CfGr6.js +1 -0
- package/dist/ui/assets/icons-ZLR7gmJ4.js +1 -0
- package/dist/ui/assets/{installer-CyaKvN2m.js → installer-DW4F27JY.js} +1 -1
- package/dist/ui/assets/{js-realm-worker-BnUM21eR.js → js-realm-worker-MY0pjZ9h.js} +4 -4
- package/dist/ui/assets/{kernel-worker-yw857ueT.js → kernel-worker-BKxUtfmY.js} +300 -300
- package/dist/ui/assets/{legacy-api-aliases-C2CCsk4u.js → legacy-api-aliases-CsTVszvY.js} +1 -1
- package/dist/ui/assets/{legacy-api-aliases-qI5FdR49.js → legacy-api-aliases-nSD9C16V.js} +1 -1
- package/dist/ui/assets/{local-llm-BGW1wtLE.js → local-llm-D1NRQkzz.js} +1 -1
- package/dist/ui/assets/{local-llm-COK65VbN.js → local-llm-HqLsF79p.js} +1 -1
- package/dist/ui/assets/{main-E8Y9fUEO.js → main-BAZcY8aY.js} +3 -3
- package/dist/ui/assets/mistral-conversations-BXo-tb0V.js +4 -0
- package/dist/ui/assets/mistral-conversations-Ck257tvp.js +4 -0
- package/dist/ui/assets/{mount-D8qNPn6f.js → mount-DG1bfETF.js} +2 -2
- package/dist/ui/assets/{mount-BRFa6t-4.js → mount-M6zAHrfJ.js} +1 -1
- package/dist/ui/assets/{mount-recovery-CHVRcxtq.js → mount-recovery-_TjykwtG.js} +1 -1
- package/dist/ui/assets/{new-session-BGczu0FG.js → new-session--SSmR5Ga.js} +2 -2
- package/dist/ui/assets/{oauth-bootstrap-4fK_96El.js → oauth-bootstrap-BsYaFcYA.js} +2 -2
- package/dist/ui/assets/openai-CjBvzZcB.js +17 -0
- package/dist/ui/assets/openai-ZcrxEOGB.js +17 -0
- package/dist/ui/assets/{openai-codex-C8wVJf5e.js → openai-codex-C5laLxy5.js} +1 -1
- package/dist/ui/assets/{openai-codex-B81Bro8k.js → openai-codex-ChaoxQtS.js} +1 -1
- package/dist/ui/assets/openai-codex-responses-BQzefg3i.js +7 -0
- package/dist/ui/assets/openai-codex-responses-JtcU5b3J.js +7 -0
- package/dist/ui/assets/openai-completions-D-HjYi8x.js +5 -0
- package/dist/ui/assets/openai-completions-QMfwfjiE.js +5 -0
- package/dist/ui/assets/openai-responses-BVHnEPuG.js +1 -0
- package/dist/ui/assets/openai-responses-Ca0oWhbv.js +1 -0
- package/dist/ui/assets/openai-responses-shared-DhnqxYC9.js +10 -0
- package/dist/ui/assets/openai-responses-shared-DxcsuzHF.js +10 -0
- package/dist/ui/assets/{openrouter-DNcyWZsw.js → openrouter-5bo3AK5r.js} +1 -1
- package/dist/ui/assets/{openrouter-BReb0eBy.js → openrouter-BglEF0gx.js} +1 -1
- package/dist/ui/assets/{openrouter-images-CeBDTy7a.js → openrouter-images-C93KT7V_.js} +1 -1
- package/dist/ui/assets/{openrouter-images-JzygwjVz.js → openrouter-images-CiM-JPBO.js} +1 -1
- package/dist/ui/assets/{openrouter-models-BVfLgK5R.js → openrouter-models-BhgPe74G.js} +1 -1
- package/dist/ui/assets/{openrouter-models-Ds9BfRxR.js → openrouter-models-DYeJmDu6.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-CdzR0HLG.js → openrouter-oauth-B_qwkZyM.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-DtQkXo85.js → openrouter-oauth-lWgqXvCt.js} +1 -1
- package/dist/ui/assets/openrouter.models-DEX-YTLI.js +1 -0
- package/dist/ui/assets/openrouter.models-gbjkpjE_.js +1 -0
- package/dist/ui/assets/{panel-rpc-handlers-B6g2obdo.js → panel-rpc-handlers-DOaYtEJ2.js} +2 -2
- package/dist/ui/assets/{panelize-shell-BZuH5tPw.js → panelize-shell-BiuM5F3-.js} +1 -1
- package/dist/ui/assets/pdfjs-BspLIDsM.js +100 -0
- package/dist/ui/assets/pi-user-agent-6Rm79QmC.js +1 -0
- package/dist/ui/assets/pi-user-agent-BlGZrXbX.js +1 -0
- package/dist/ui/assets/{provider-BnYcq1I8.js → provider-D5-Ws4A3.js} +1 -1
- package/dist/ui/assets/{provider-O2Fsi2E6.js → provider-DGKy0rlK.js} +2 -2
- package/dist/ui/assets/{provider-settings-CHVLgGD4.js → provider-settings-BkIna1v7.js} +1 -1
- package/dist/ui/assets/{provider-settings-B4ty6gIx.js → provider-settings-DrEGQ7ef.js} +1 -1
- package/dist/ui/assets/provider-store-access-BK4wRKW6.js +1 -0
- package/dist/ui/assets/{provider-store-access-DO8lATOK.js → provider-store-access-Dr5cJrix.js} +2 -2
- package/dist/ui/assets/{providers-UBBok802.js → providers-B9Tcuh9N.js} +1 -1
- package/dist/ui/assets/{providers-DTdEhTSN.js → providers-DiWgfJHV.js} +2 -2
- package/dist/ui/assets/{quick-llm-CmyRUCMf.js → quick-llm-CSEzJrdv.js} +1 -1
- package/dist/ui/assets/{recovery-screen-_f8iC-Fq.js → recovery-screen-BAeZAnd3.js} +1 -1
- package/dist/ui/assets/{redirect-uri-CMVLNgtY.js → redirect-uri-BmNItvHl.js} +1 -1
- package/dist/ui/assets/{session-freezer-CvPl-bDp.js → session-freezer-BU7ggIXE.js} +3 -3
- package/dist/ui/assets/{setup-feature-flags-remote-CHIJc86J.js → setup-feature-flags-remote-B7CMO8xS.js} +1 -1
- package/dist/ui/assets/{setup-standalone-prelude-DUERSTfj.js → setup-standalone-prelude-Dg0BO-ug.js} +1 -1
- package/dist/ui/assets/{setup-sudo-D2RYRZR7.js → setup-sudo-w0slorYi.js} +2 -2
- package/dist/ui/assets/{skills-BFj_C0zu.js → skills-Qu2Xx97d.js} +1 -1
- package/dist/ui/assets/slicc-version-BJsqUhbP.js +1 -0
- package/dist/ui/assets/{sprinkle-manager-BMj0BniN.js → sprinkle-manager-2UUakPAV.js} +1 -1
- package/dist/ui/assets/src-Cj-AoUM3.js +2 -0
- package/dist/ui/assets/{src-jZxFomYR.js → src-DDn9o2XK.js} +1 -1
- package/dist/ui/assets/{store-PIfsltkW.js → store-BY8jHah-.js} +1 -1
- package/dist/ui/assets/{store-B_azjzWK.js → store-DLe-z7qR.js} +1 -1
- package/dist/ui/assets/{sudo-B_q1NKKG.js → sudo-B-8VnvDn.js} +1 -1
- package/dist/ui/assets/{sync-dialog-BXZHMjrc.js → sync-dialog-ACgl0n-p.js} +1 -1
- package/dist/ui/assets/{telemetry-DeLkquP_.js → telemetry-BVzuNdvW.js} +1 -1
- package/dist/ui/assets/{telemetry-BugxTkxX.js → telemetry-BwapcULJ.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-DPiDPtcB.js → upgrade-detection-Bsw9PDXL.js} +1 -1
- package/dist/ui/assets/{wc-attach-C4L2GyF0.js → wc-attach-BsqldTbU.js} +2 -2
- package/dist/ui/assets/{wc-extension-BO9vRQwT.js → wc-extension-DYDuh0JO.js} +2 -2
- package/dist/ui/assets/{wc-follower-CZfJ2TtN.js → wc-follower-ww51bVZi.js} +3 -3
- package/dist/ui/assets/{wc-live-Bs4FhY5U.js → wc-live-B-tu9Zmf.js} +5 -5
- package/dist/ui/assets/{wc-nav-CxJPwpP-.js → wc-nav-DTKff66m.js} +2 -2
- package/dist/ui/assets/{wc-onboarding-Da7hSB-p.js → wc-onboarding-W9IFk-VE.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-Dxzwmbbc.js → wc-placeholder-BHMU_r6O.js} +2 -2
- package/dist/ui/assets/{wc-settings-LBH0HADM.js → wc-settings-DXjEjm0D.js} +2 -2
- package/dist/ui/assets/wc-shell-Csh9APE_.js +119 -0
- package/dist/ui/assets/{wc-sprinkles-kW8sZ7l_.js → wc-sprinkles-DzajqLC2.js} +2 -2
- package/dist/ui/assets/{wc-tray-Z8PDTCsn.js → wc-tray-DNQ32Rxm.js} +2 -2
- package/dist/ui/assets/{xai-grok-Bj6T-qsO.js → xai-grok-Bjjeqaxc.js} +1 -1
- package/dist/ui/assets/{xai-grok-CNmzJXMK.js → xai-grok-D9twjPSS.js} +1 -1
- package/dist/ui/index.html +9 -9
- package/dist/ui/lucide-icons.js +1788 -1707
- package/dist/ui/packages/webapp/index.html +9 -9
- package/package.json +10 -10
- package/dist/ui/assets/anthropic-messages-DzEs7DmW.js +0 -39
- package/dist/ui/assets/anthropic-messages-EYoOyCX6.js +0 -39
- package/dist/ui/assets/azure-openai-BjzhxW0m.js +0 -18
- package/dist/ui/assets/azure-openai-Cv0yG7CG.js +0 -18
- package/dist/ui/assets/bedrock-camp-BfNg24Ce.js +0 -1
- package/dist/ui/assets/bedrock-camp-C8bCNVSq.js +0 -2
- package/dist/ui/assets/completionchunk-CVTjxyMe.js +0 -65
- package/dist/ui/assets/completionchunk-CksvMkXE.js +0 -65
- package/dist/ui/assets/constrained-sampling-DafcjXU6.js +0 -1
- package/dist/ui/assets/dist-CZvQ4trc.js +0 -15
- package/dist/ui/assets/es-D8T2ybXa.js +0 -53
- package/dist/ui/assets/esptool-operations-3FBbK-fD.js +0 -13
- package/dist/ui/assets/google-generative-ai-C9Is_VVN.js +0 -1
- package/dist/ui/assets/google-generative-ai-u7R_TH9o.js +0 -1
- package/dist/ui/assets/google-shared-BPNUreTT.js +0 -371
- package/dist/ui/assets/google-shared-Cde0njMr.js +0 -11
- package/dist/ui/assets/google-vertex-DzrD0kHC.js +0 -1
- package/dist/ui/assets/google-vertex-bmq-ZPFH.js +0 -1
- package/dist/ui/assets/icons-DtQGhvkp.js +0 -1
- package/dist/ui/assets/mistral-conversations-BKWQGrhA.js +0 -8
- package/dist/ui/assets/mistral-conversations-CunWHeDt.js +0 -7
- package/dist/ui/assets/openai-DQxsE__c.js +0 -16
- package/dist/ui/assets/openai-DehfWK3N.js +0 -16
- package/dist/ui/assets/openai-codex-responses-8wXA5Dto.js +0 -7
- package/dist/ui/assets/openai-codex-responses-CeLTmOkk.js +0 -7
- package/dist/ui/assets/openai-completions-CfjF1o-N.js +0 -5
- package/dist/ui/assets/openai-completions-q2lvopuz.js +0 -5
- package/dist/ui/assets/openai-responses-B7rl8DAX.js +0 -1
- package/dist/ui/assets/openai-responses-Cpj4YO2E.js +0 -1
- package/dist/ui/assets/openai-responses-shared-B_T0yMQn.js +0 -10
- package/dist/ui/assets/openai-responses-shared-iNFeCdoC.js +0 -10
- package/dist/ui/assets/openrouter.models-CrhNqqEN.js +0 -1
- package/dist/ui/assets/openrouter.models-DkPWoMvu.js +0 -1
- package/dist/ui/assets/otel-BVv11zKU.js +0 -3
- package/dist/ui/assets/otel-BZA5WuO2.js +0 -3
- package/dist/ui/assets/pdfjs-CRuE4vGw.js +0 -54
- package/dist/ui/assets/provider-store-access-DojveU92.js +0 -1
- package/dist/ui/assets/slicc-version-C2rv26Z3.js +0 -1
- package/dist/ui/assets/src-C9oNvq2b.js +0 -2
- package/dist/ui/assets/wc-shell-DXji2EMu.js +0 -117
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./transform-messages-N_eMsP2M.js";import{t as r}from"./provider-retry-C8PJzY_l.js";import{t as i}from"./sanitize-unicode-DmIE6hZJ.js";import{i as a,o}from"./constrained-sampling-Zzx2ko9x.js";var s=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}})),c=t((e=>{var t=s();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: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}}})),l=t(((e,t)=>{t.exports=c()})),u=e(t(((e,t)=>{var n=l(),r=[`Failed to fetch`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`],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}},a=(e,t,n)=>{let r=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},o=e=>r.includes(e),s=(e,t)=>new Promise((r,s)=>{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)){s(TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));return}if(e instanceof i)c.stop(),s(e.originalError);else if(e instanceof TypeError&&!o(e.message))c.stop(),s(e);else{a(e,n,t);try{await t.onFailedAttempt(e)}catch(e){s(e);return}c.retry(e)||s(c.mainError())}}})});t.exports=s,t.exports.default=s,t.exports.AbortError=i}))(),1),d=void 0,f=void 0;function p(){return{geminiUrl:d,vertexUrl:f}}function m(e,t,n,r){if(!e?.baseUrl){let e=p();return t?e.vertexUrl??n:e.geminiUrl??r}return e.baseUrl}var h=class{};function g(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return e==null?``:String(e)}throw Error(`Key '${n}' not found in valueMap.`)})}function _(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];_(a,t.slice(r+1),n[e])}else for(let e of i)_(e,t.slice(r+1),n)}return}if(i.endsWith(`[0]`)){let a=i.slice(0,-3);a in e||(e[a]=[{}]);let o=e[a];_(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 v(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=>v(e,t.slice(r+1),n)):n}return n}e=e[i]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function y(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)}b(e,t,i,0,a)}}function b(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])b(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);_(t,a,i)}for(let e of a)delete t[e]}}else{let o=e;a in o&&b(o[a],t,n,r+1,i)}}function x(e){if(typeof e!=`string`)throw Error(`fromImageBytes must be a string`);return e}function S(e){let t={},n=v(e,[`operationName`]);n!=null&&_(t,[`operationName`],n);let r=v(e,[`resourceName`]);return r!=null&&_(t,[`_url`,`resourceName`],r),t}function C(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`metadata`]);r!=null&&_(t,[`metadata`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);a!=null&&_(t,[`error`],a);let o=v(e,[`response`,`generateVideoResponse`]);return o!=null&&_(t,[`response`],T(o)),t}function w(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`metadata`]);r!=null&&_(t,[`metadata`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);a!=null&&_(t,[`error`],a);let o=v(e,[`response`]);return o!=null&&_(t,[`response`],E(o)),t}function T(e){let t={},n=v(e,[`generatedSamples`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>D(e))),_(t,[`generatedVideos`],e)}let r=v(e,[`raiMediaFilteredCount`]);r!=null&&_(t,[`raiMediaFilteredCount`],r);let i=v(e,[`raiMediaFilteredReasons`]);return i!=null&&_(t,[`raiMediaFilteredReasons`],i),t}function E(e){let t={},n=v(e,[`videos`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>O(e))),_(t,[`generatedVideos`],e)}let r=v(e,[`raiMediaFilteredCount`]);r!=null&&_(t,[`raiMediaFilteredCount`],r);let i=v(e,[`raiMediaFilteredReasons`]);return i!=null&&_(t,[`raiMediaFilteredReasons`],i),t}function D(e){let t={},n=v(e,[`video`]);return n!=null&&_(t,[`video`],ne(n)),t}function O(e){let t={},n=v(e,[`_self`]);return n!=null&&_(t,[`video`],re(n)),t}function k(e){let t={},n=v(e,[`operationName`]);return n!=null&&_(t,[`_url`,`operationName`],n),t}function A(e){let t={},n=v(e,[`operationName`]);return n!=null&&_(t,[`_url`,`operationName`],n),t}function j(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`metadata`]);r!=null&&_(t,[`metadata`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);a!=null&&_(t,[`error`],a);let o=v(e,[`response`]);return o!=null&&_(t,[`response`],M(o)),t}function M(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`parent`]);r!=null&&_(t,[`parent`],r);let i=v(e,[`documentName`]);return i!=null&&_(t,[`documentName`],i),t}function ee(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`metadata`]);r!=null&&_(t,[`metadata`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);a!=null&&_(t,[`error`],a);let o=v(e,[`response`]);return o!=null&&_(t,[`response`],te(o)),t}function te(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`parent`]);r!=null&&_(t,[`parent`],r);let i=v(e,[`documentName`]);return i!=null&&_(t,[`documentName`],i),t}function ne(e){let t={},n=v(e,[`uri`]);n!=null&&_(t,[`uri`],n);let r=v(e,[`encodedVideo`]);r!=null&&_(t,[`videoBytes`],x(r));let i=v(e,[`encoding`]);return i!=null&&_(t,[`mimeType`],i),t}function re(e){let t={},n=v(e,[`gcsUri`]);n!=null&&_(t,[`uri`],n);let r=v(e,[`bytesBase64Encoded`]);r!=null&&_(t,[`videoBytes`],x(r));let i=v(e,[`mimeType`]);return i!=null&&_(t,[`mimeType`],i),t}var ie;(function(e){e.LANGUAGE_UNSPECIFIED=`LANGUAGE_UNSPECIFIED`,e.PYTHON=`PYTHON`})(ie||={});var ae;(function(e){e.OUTCOME_UNSPECIFIED=`OUTCOME_UNSPECIFIED`,e.OUTCOME_OK=`OUTCOME_OK`,e.OUTCOME_FAILED=`OUTCOME_FAILED`,e.OUTCOME_DEADLINE_EXCEEDED=`OUTCOME_DEADLINE_EXCEEDED`})(ae||={});var oe;(function(e){e.SCHEDULING_UNSPECIFIED=`SCHEDULING_UNSPECIFIED`,e.SILENT=`SILENT`,e.WHEN_IDLE=`WHEN_IDLE`,e.INTERRUPT=`INTERRUPT`})(oe||={});var N;(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`})(N||={});var se;(function(e){e.ENVIRONMENT_UNSPECIFIED=`ENVIRONMENT_UNSPECIFIED`,e.ENVIRONMENT_BROWSER=`ENVIRONMENT_BROWSER`})(se||={});var ce;(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`})(ce||={});var le;(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`})(le||={});var ue;(function(e){e.API_SPEC_UNSPECIFIED=`API_SPEC_UNSPECIFIED`,e.SIMPLE_SEARCH=`SIMPLE_SEARCH`,e.ELASTIC_SEARCH=`ELASTIC_SEARCH`})(ue||={});var de;(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`})(de||={});var fe;(function(e){e.UNSPECIFIED=`UNSPECIFIED`,e.BLOCKING=`BLOCKING`,e.NON_BLOCKING=`NON_BLOCKING`})(fe||={});var pe;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.MODE_DYNAMIC=`MODE_DYNAMIC`})(pe||={});var me;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.AUTO=`AUTO`,e.ANY=`ANY`,e.NONE=`NONE`,e.VALIDATED=`VALIDATED`})(me||={});var he;(function(e){e.THINKING_LEVEL_UNSPECIFIED=`THINKING_LEVEL_UNSPECIFIED`,e.MINIMAL=`MINIMAL`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(he||={});var ge;(function(e){e.DONT_ALLOW=`DONT_ALLOW`,e.ALLOW_ADULT=`ALLOW_ADULT`,e.ALLOW_ALL=`ALLOW_ALL`})(ge||={});var _e;(function(e){e.PROMINENT_PEOPLE_UNSPECIFIED=`PROMINENT_PEOPLE_UNSPECIFIED`,e.ALLOW_PROMINENT_PEOPLE=`ALLOW_PROMINENT_PEOPLE`,e.BLOCK_PROMINENT_PEOPLE=`BLOCK_PROMINENT_PEOPLE`})(_e||={});var ve;(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`})(ve||={});var ye;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED=`HARM_BLOCK_METHOD_UNSPECIFIED`,e.SEVERITY=`SEVERITY`,e.PROBABILITY=`PROBABILITY`})(ye||={});var be;(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`})(be||={});var P;(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`})(P||={});var xe;(function(e){e.HARM_PROBABILITY_UNSPECIFIED=`HARM_PROBABILITY_UNSPECIFIED`,e.NEGLIGIBLE=`NEGLIGIBLE`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(xe||={});var Se;(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`})(Se||={});var Ce;(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`})(Ce||={});var we;(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`})(we||={});var Te;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED=`TRAFFIC_TYPE_UNSPECIFIED`,e.ON_DEMAND=`ON_DEMAND`,e.ON_DEMAND_PRIORITY=`ON_DEMAND_PRIORITY`,e.ON_DEMAND_FLEX=`ON_DEMAND_FLEX`,e.PROVISIONED_THROUGHPUT=`PROVISIONED_THROUGHPUT`})(Te||={});var Ee;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.AUDIO=`AUDIO`,e.VIDEO=`VIDEO`})(Ee||={});var De;(function(e){e.MODEL_STAGE_UNSPECIFIED=`MODEL_STAGE_UNSPECIFIED`,e.UNSTABLE_EXPERIMENTAL=`UNSTABLE_EXPERIMENTAL`,e.EXPERIMENTAL=`EXPERIMENTAL`,e.PREVIEW=`PREVIEW`,e.STABLE=`STABLE`,e.LEGACY=`LEGACY`,e.DEPRECATED=`DEPRECATED`,e.RETIRED=`RETIRED`})(De||={});var Oe;(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`})(Oe||={});var ke;(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`})(ke||={});var Ae;(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`})(Ae||={});var je;(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`})(je||={});var Me;(function(e){e.TUNING_JOB_STATE_UNSPECIFIED=`TUNING_JOB_STATE_UNSPECIFIED`,e.TUNING_JOB_STATE_WAITING_FOR_QUOTA=`TUNING_JOB_STATE_WAITING_FOR_QUOTA`,e.TUNING_JOB_STATE_PROCESSING_DATASET=`TUNING_JOB_STATE_PROCESSING_DATASET`,e.TUNING_JOB_STATE_WAITING_FOR_CAPACITY=`TUNING_JOB_STATE_WAITING_FOR_CAPACITY`,e.TUNING_JOB_STATE_TUNING=`TUNING_JOB_STATE_TUNING`,e.TUNING_JOB_STATE_POST_PROCESSING=`TUNING_JOB_STATE_POST_PROCESSING`})(Me||={});var Ne;(function(e){e.AGGREGATION_METRIC_UNSPECIFIED=`AGGREGATION_METRIC_UNSPECIFIED`,e.AVERAGE=`AVERAGE`,e.MODE=`MODE`,e.STANDARD_DEVIATION=`STANDARD_DEVIATION`,e.VARIANCE=`VARIANCE`,e.MINIMUM=`MINIMUM`,e.MAXIMUM=`MAXIMUM`,e.MEDIAN=`MEDIAN`,e.PERCENTILE_P90=`PERCENTILE_P90`,e.PERCENTILE_P95=`PERCENTILE_P95`,e.PERCENTILE_P99=`PERCENTILE_P99`})(Ne||={});var Pe;(function(e){e.PAIRWISE_CHOICE_UNSPECIFIED=`PAIRWISE_CHOICE_UNSPECIFIED`,e.BASELINE=`BASELINE`,e.CANDIDATE=`CANDIDATE`,e.TIE=`TIE`})(Pe||={});var Fe;(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`})(Fe||={});var Ie;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.STATE_PENDING=`STATE_PENDING`,e.STATE_ACTIVE=`STATE_ACTIVE`,e.STATE_FAILED=`STATE_FAILED`})(Ie||={});var Le;(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`})(Le||={});var Re;(function(e){e.TOOL_TYPE_UNSPECIFIED=`TOOL_TYPE_UNSPECIFIED`,e.GOOGLE_SEARCH_WEB=`GOOGLE_SEARCH_WEB`,e.GOOGLE_SEARCH_IMAGE=`GOOGLE_SEARCH_IMAGE`,e.URL_CONTEXT=`URL_CONTEXT`,e.GOOGLE_MAPS=`GOOGLE_MAPS`,e.FILE_SEARCH=`FILE_SEARCH`})(Re||={});var ze;(function(e){e.COLLECTION=`COLLECTION`})(ze||={});var Be;(function(e){e.UNSPECIFIED=`unspecified`,e.FLEX=`flex`,e.STANDARD=`standard`,e.PRIORITY=`priority`})(Be||={});var Ve;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED=`FEATURE_SELECTION_PREFERENCE_UNSPECIFIED`,e.PRIORITIZE_QUALITY=`PRIORITIZE_QUALITY`,e.BALANCED=`BALANCED`,e.PRIORITIZE_COST=`PRIORITIZE_COST`})(Ve||={});var He;(function(e){e.PREDICT=`PREDICT`,e.EMBED_CONTENT=`EMBED_CONTENT`})(He||={});var Ue;(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`})(Ue||={});var We;(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`})(We||={});var Ge;(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`})(Ge||={});var Ke;(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`})(Ke||={});var qe;(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`})(qe||={});var Je;(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`})(Je||={});var Ye;(function(e){e.FOREGROUND=`FOREGROUND`,e.BACKGROUND=`BACKGROUND`,e.PROMPT=`PROMPT`,e.SEMANTIC=`SEMANTIC`,e.INTERACTIVE=`INTERACTIVE`})(Ye||={});var Xe;(function(e){e.ASSET=`ASSET`,e.STYLE=`STYLE`})(Xe||={});var Ze;(function(e){e.INSERT=`INSERT`,e.REMOVE=`REMOVE`,e.REMOVE_STATIC=`REMOVE_STATIC`,e.OUTPAINT=`OUTPAINT`})(Ze||={});var Qe;(function(e){e.OPTIMIZED=`OPTIMIZED`,e.LOSSLESS=`LOSSLESS`})(Qe||={});var $e;(function(e){e.CROP=`CROP`,e.PAD=`PAD`})($e||={});var et;(function(e){e.SUPERVISED_FINE_TUNING=`SUPERVISED_FINE_TUNING`,e.PREFERENCE_TUNING=`PREFERENCE_TUNING`,e.DISTILLATION=`DISTILLATION`})(et||={});var tt;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.PROCESSING=`PROCESSING`,e.ACTIVE=`ACTIVE`,e.FAILED=`FAILED`})(tt||={});var nt;(function(e){e.SOURCE_UNSPECIFIED=`SOURCE_UNSPECIFIED`,e.UPLOADED=`UPLOADED`,e.GENERATED=`GENERATED`,e.REGISTERED=`REGISTERED`})(nt||={});var rt;(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`,e.PROHIBITED_INPUT_CONTENT=`PROHIBITED_INPUT_CONTENT`,e.IMAGE_PROHIBITED_INPUT_CONTENT=`IMAGE_PROHIBITED_INPUT_CONTENT`,e.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED=`INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED`,e.INPUT_IMAGE_CELEBRITY=`INPUT_IMAGE_CELEBRITY`,e.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED=`INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED`,e.INPUT_TEXT_NCII_PROHIBITED=`INPUT_TEXT_NCII_PROHIBITED`,e.INPUT_OTHER=`INPUT_OTHER`,e.INPUT_IP_PROHIBITED=`INPUT_IP_PROHIBITED`,e.BLOCKLIST=`BLOCKLIST`,e.UNSAFE_PROMPT_FOR_IMAGE_GENERATION=`UNSAFE_PROMPT_FOR_IMAGE_GENERATION`,e.GENERATED_IMAGE_SAFETY=`GENERATED_IMAGE_SAFETY`,e.GENERATED_CONTENT_SAFETY=`GENERATED_CONTENT_SAFETY`,e.GENERATED_AUDIO_SAFETY=`GENERATED_AUDIO_SAFETY`,e.GENERATED_VIDEO_SAFETY=`GENERATED_VIDEO_SAFETY`,e.GENERATED_CONTENT_PROHIBITED=`GENERATED_CONTENT_PROHIBITED`,e.GENERATED_CONTENT_BLOCKLIST=`GENERATED_CONTENT_BLOCKLIST`,e.GENERATED_IMAGE_PROHIBITED=`GENERATED_IMAGE_PROHIBITED`,e.GENERATED_IMAGE_CELEBRITY=`GENERATED_IMAGE_CELEBRITY`,e.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER=`GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER`,e.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE=`GENERATED_IMAGE_IDENTIFIABLE_PEOPLE`,e.GENERATED_IMAGE_MINORS=`GENERATED_IMAGE_MINORS`,e.OUTPUT_IMAGE_IP_PROHIBITED=`OUTPUT_IMAGE_IP_PROHIBITED`,e.GENERATED_OTHER=`GENERATED_OTHER`,e.MAX_REGENERATION_REACHED=`MAX_REGENERATION_REACHED`})(rt||={});var it;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.VIDEO=`VIDEO`,e.AUDIO=`AUDIO`,e.DOCUMENT=`DOCUMENT`})(it||={});var at;(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`})(at||={});var ot;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.ACTIVITY_START=`ACTIVITY_START`,e.ACTIVITY_END=`ACTIVITY_END`})(ot||={});var st;(function(e){e.START_SENSITIVITY_UNSPECIFIED=`START_SENSITIVITY_UNSPECIFIED`,e.START_SENSITIVITY_HIGH=`START_SENSITIVITY_HIGH`,e.START_SENSITIVITY_LOW=`START_SENSITIVITY_LOW`})(st||={});var ct;(function(e){e.END_SENSITIVITY_UNSPECIFIED=`END_SENSITIVITY_UNSPECIFIED`,e.END_SENSITIVITY_HIGH=`END_SENSITIVITY_HIGH`,e.END_SENSITIVITY_LOW=`END_SENSITIVITY_LOW`})(ct||={});var lt;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED=`ACTIVITY_HANDLING_UNSPECIFIED`,e.START_OF_ACTIVITY_INTERRUPTS=`START_OF_ACTIVITY_INTERRUPTS`,e.NO_INTERRUPTION=`NO_INTERRUPTION`})(lt||={});var ut;(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`,e.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO=`TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO`})(ut||={});var dt;(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`})(dt||={});var ft;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED=`MUSIC_GENERATION_MODE_UNSPECIFIED`,e.QUALITY=`QUALITY`,e.DIVERSITY=`DIVERSITY`,e.VOCALIZATION=`VOCALIZATION`})(ft||={});var pt;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED=`PLAYBACK_CONTROL_UNSPECIFIED`,e.PLAY=`PLAY`,e.PAUSE=`PAUSE`,e.STOP=`STOP`,e.RESET_CONTEXT=`RESET_CONTEXT`})(pt||={});var mt=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()}},ht=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}},gt=class{},_t=class{},vt=class{},yt=class{},bt=class{},xt=class{},St=class{},Ct=class{},wt=class{},Tt=class{},Et=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i,a=t;return i=n?w(a):C(a),Object.assign(r,i),r}},Dt=class{},Ot=class{},kt=class{},At=class{},jt=class{},Mt=class{},Nt=class{},Pt=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=j(t);return Object.assign(r,i),r}},Ft=class{},It=class{},Lt=class{},Rt=class{},zt=class{},Bt=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}},Vt=class{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}},Ht=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=ee(t);return Object.assign(r,i),r}};function F(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]}`}return`publishers/google/models/${t}`}return t.startsWith(`models/`)||t.startsWith(`tunedModels/`)?t:`models/${t}`}function Ut(e,t){let n=F(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 Wt(e){return Array.isArray(e)?e.map(e=>Gt(e)):[Gt(e)]}function Gt(e){if(typeof e==`object`&&e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function Kt(e){let t=Gt(e);if(t.mimeType&&t.mimeType.startsWith(`image/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function qt(e){let t=Gt(e);if(t.mimeType&&t.mimeType.startsWith(`audio/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Jt(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 Yt(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`PartListUnion is required`);return Array.isArray(e)?e.map(e=>Jt(e)):[Jt(e)]}function Xt(e){return typeof e==`object`&&!!e&&`parts`in e&&Array.isArray(e.parts)}function Zt(e){return typeof e==`object`&&!!e&&`functionCall`in e}function Qt(e){return typeof e==`object`&&!!e&&`functionResponse`in e}function I(e){if(e==null)throw Error(`ContentUnion is required`);return Xt(e)?e:{role:`user`,parts:Yt(e)}}function $t(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=I(e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=I(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=>I(e)):[I(t)]}function L(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`contents are required`);if(!Array.isArray(e)){if(Zt(e)||Qt(e))throw Error(`To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them`);return[I(e)]}let t=[],n=[],r=Xt(e[0]);for(let i of e){let e=Xt(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(Zt(i)||Qt(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:Yt(n)}),t}function en(e,t){e.includes(`null`)&&(t.nullable=!0);let n=e.filter(e=>e!==`null`);if(n.length===1)t.type=Object.values(N).includes(n[0].toUpperCase())?n[0].toUpperCase():N.TYPE_UNSPECIFIED;else{t.anyOf=[];for(let e of n)t.anyOf.push({type:Object.values(N).includes(e.toUpperCase())?e.toUpperCase():N.TYPE_UNSPECIFIED})}}function R(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&&en(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(N).includes(o.toUpperCase())?o.toUpperCase():N.TYPE_UNSPECIFIED}else if(n.includes(a))t[a]=R(o);else if(r.includes(a)){let e=[];for(let n of o){if(n.type==`null`){t.nullable=!0;continue}e.push(R(n))}t[a]=e}else if(i.includes(a)){let e={};for(let[t,n]of Object.entries(o))e[t]=R(n);t[a]=e}else{if(a===`additionalProperties`)continue;t[a]=o}return t}function tn(e){return R(e)}function nn(e){if(typeof e==`object`)return e;if(typeof e==`string`)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function rn(e){if(`multiSpeakerVoiceConfig`in e)throw Error(`multiSpeakerVoiceConfig is not supported in the live API.`);return e}function an(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=R(t.parameters)),t.response&&(Object.keys(t.response).includes(`$schema`)?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=R(t.response));return e}function on(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 sn(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 z(e,t){if(typeof t!=`string`)throw Error(`name must be a string`);return sn(e,t,`cachedContents`)}function cn(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 B(e){return x(e)}function ln(e){return typeof e==`object`&&!!e&&`name`in e}function un(e){return typeof e==`object`&&!!e&&`video`in e}function dn(e){return typeof e==`object`&&!!e&&`uri`in e}function fn(e){let t;if(ln(e)&&(t=e.name),!(dn(e)&&(t=e.uri,t===void 0))&&!(un(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 pn(e,t){let n;return n=e.isVertexAI()?t?`publishers/google/models`:`models`:t?`models`:`tunedModels`,n}function mn(e){for(let t of[`models`,`tunedModels`,`publisherModels`])if(hn(e,t))return e[t];return[]}function hn(e,t){return typeof e==`object`&&!!e&&t in e}function gn(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 _n(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=gn(i,t);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function vn(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 if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(t))n={format:`vertex-dataset`,vertexDatasetName: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,n.vertexDatasetName].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`, `bigqueryUri`, or `vertexDatasetName` 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 yn(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 bn(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 xn(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 Sn(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 Cn(e){return e.includes(`gemini`)&&e!==`gemini-embedding-001`||e.includes(`maas`)}function wn(e){let t={},n=v(e,[`apiKey`]);if(n!=null&&_(t,[`apiKey`],n),v(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(v(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(v(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(v(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(v(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(v(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function Tn(e){let t={},n=v(e,[`responsesFile`]);n!=null&&_(t,[`fileName`],n);let r=v(e,[`inlinedResponses`,`inlinedResponses`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>lr(e))),_(t,[`inlinedResponses`],e)}let i=v(e,[`inlinedEmbedContentResponses`,`inlinedResponses`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`inlinedEmbedContentResponses`],e)}return t}function En(e){let t={},n=v(e,[`predictionsFormat`]);n!=null&&_(t,[`format`],n);let r=v(e,[`gcsDestination`,`outputUriPrefix`]);r!=null&&_(t,[`gcsUri`],r);let i=v(e,[`bigqueryDestination`,`outputUri`]);i!=null&&_(t,[`bigqueryUri`],i);let a=v(e,[`vertexMultimodalDatasetDestination`]);return a!=null&&_(t,[`vertexDataset`],br(a)),t}function Dn(e){let t={},n=v(e,[`format`]);n!=null&&_(t,[`predictionsFormat`],n);let r=v(e,[`gcsUri`]);r!=null&&_(t,[`gcsDestination`,`outputUriPrefix`],r);let i=v(e,[`bigqueryUri`]);if(i!=null&&_(t,[`bigqueryDestination`,`outputUri`],i),v(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`inlinedResponses`])!==void 0)throw Error(`inlinedResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`inlinedEmbedContentResponses`])!==void 0)throw Error(`inlinedEmbedContentResponses parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let a=v(e,[`vertexDataset`]);return a!=null&&_(t,[`vertexMultimodalDatasetDestination`],xr(a)),t}function On(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`metadata`,`displayName`]);r!=null&&_(t,[`displayName`],r);let i=v(e,[`metadata`,`state`]);i!=null&&_(t,[`state`],Sn(i));let a=v(e,[`metadata`,`createTime`]);a!=null&&_(t,[`createTime`],a);let o=v(e,[`metadata`,`endTime`]);o!=null&&_(t,[`endTime`],o);let s=v(e,[`metadata`,`updateTime`]);s!=null&&_(t,[`updateTime`],s);let c=v(e,[`metadata`,`model`]);c!=null&&_(t,[`model`],c);let l=v(e,[`metadata`,`output`]);return l!=null&&_(t,[`dest`],Tn(bn(l))),t}function kn(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`displayName`]);r!=null&&_(t,[`displayName`],r);let i=v(e,[`state`]);i!=null&&_(t,[`state`],Sn(i));let a=v(e,[`error`]);a!=null&&_(t,[`error`],a);let o=v(e,[`createTime`]);o!=null&&_(t,[`createTime`],o);let s=v(e,[`startTime`]);s!=null&&_(t,[`startTime`],s);let c=v(e,[`endTime`]);c!=null&&_(t,[`endTime`],c);let l=v(e,[`updateTime`]);l!=null&&_(t,[`updateTime`],l);let u=v(e,[`model`]);u!=null&&_(t,[`model`],u);let d=v(e,[`inputConfig`]);d!=null&&_(t,[`src`],An(d));let f=v(e,[`outputConfig`]);f!=null&&_(t,[`dest`],En(bn(f)));let p=v(e,[`completionStats`]);p!=null&&_(t,[`completionStats`],p);let m=v(e,[`outputInfo`]);return m!=null&&_(t,[`outputInfo`],m),t}function An(e){let t={},n=v(e,[`instancesFormat`]);n!=null&&_(t,[`format`],n);let r=v(e,[`gcsSource`,`uris`]);r!=null&&_(t,[`gcsUri`],r);let i=v(e,[`bigquerySource`,`inputUri`]);i!=null&&_(t,[`bigqueryUri`],i);let a=v(e,[`vertexMultimodalDatasetSource`,`datasetName`]);return a!=null&&_(t,[`vertexDatasetName`],a),t}function jn(e,t){let n={};if(v(t,[`format`])!==void 0)throw Error(`format parameter is not supported in Gemini API.`);if(v(t,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(v(t,[`bigqueryUri`])!==void 0)throw Error(`bigqueryUri parameter is not supported in Gemini API.`);let r=v(t,[`fileName`]);r!=null&&_(n,[`fileName`],r);let i=v(t,[`inlinedRequests`]);if(i!=null){let t=i;Array.isArray(t)&&(t=t.map(t=>cr(e,t))),_(n,[`requests`,`requests`],t)}if(v(t,[`vertexDatasetName`])!==void 0)throw Error(`vertexDatasetName parameter is not supported in Gemini API.`);return n}function Mn(e){let t={},n=v(e,[`format`]);n!=null&&_(t,[`instancesFormat`],n);let r=v(e,[`gcsUri`]);r!=null&&_(t,[`gcsSource`,`uris`],r);let i=v(e,[`bigqueryUri`]);if(i!=null&&_(t,[`bigquerySource`,`inputUri`],i),v(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`inlinedRequests`])!==void 0)throw Error(`inlinedRequests parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let a=v(e,[`vertexDatasetName`]);return a!=null&&_(t,[`vertexMultimodalDatasetSource`,`datasetName`],a),t}function Nn(e){let t={},n=v(e,[`data`]);if(n!=null&&_(t,[`data`],n),v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function Pn(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],xn(e,r)),n}function Fn(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],xn(e,r)),n}function In(e){let t={},n=v(e,[`content`]);n!=null&&_(t,[`content`],n);let r=v(e,[`citationMetadata`]);r!=null&&_(t,[`citationMetadata`],Ln(r));let i=v(e,[`tokenCount`]);i!=null&&_(t,[`tokenCount`],i);let a=v(e,[`finishReason`]);a!=null&&_(t,[`finishReason`],a);let o=v(e,[`groundingMetadata`]);o!=null&&_(t,[`groundingMetadata`],o);let s=v(e,[`avgLogprobs`]);s!=null&&_(t,[`avgLogprobs`],s);let c=v(e,[`index`]);c!=null&&_(t,[`index`],c);let l=v(e,[`logprobsResult`]);l!=null&&_(t,[`logprobsResult`],l);let u=v(e,[`safetyRatings`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`safetyRatings`],e)}let d=v(e,[`urlContextMetadata`]);return d!=null&&_(t,[`urlContextMetadata`],d),t}function Ln(e){let t={},n=v(e,[`citationSources`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`citations`],e)}return t}function Rn(e){let t={},n=v(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>gr(e))),_(t,[`parts`],e)}let r=v(e,[`role`]);return r!=null&&_(t,[`role`],r),t}function zn(e,t){let n={},r=v(e,[`displayName`]);if(t!==void 0&&r!=null&&_(t,[`batch`,`displayName`],r),v(e,[`dest`])!==void 0)throw Error(`dest parameter is not supported in Gemini API.`);let i=v(e,[`webhookConfig`]);return t!==void 0&&i!=null&&_(t,[`batch`,`webhookConfig`],i),n}function Bn(e,t){let n={},r=v(e,[`displayName`]);t!==void 0&&r!=null&&_(t,[`displayName`],r);let i=v(e,[`dest`]);if(t!==void 0&&i!=null&&_(t,[`outputConfig`],Dn(yn(i))),v(e,[`webhookConfig`])!==void 0)throw Error(`webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Vn(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`_url`,`model`],F(e,r));let i=v(t,[`src`]);i!=null&&_(n,[`batch`,`inputConfig`],jn(e,vn(e,i)));let a=v(t,[`config`]);return a!=null&&zn(a,n),n}function Hn(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`model`],F(e,r));let i=v(t,[`src`]);i!=null&&_(n,[`inputConfig`],Mn(vn(e,i)));let a=v(t,[`config`]);return a!=null&&Bn(a,n),n}function Un(e,t){let n={},r=v(e,[`displayName`]);return t!==void 0&&r!=null&&_(t,[`batch`,`displayName`],r),n}function Wn(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`_url`,`model`],F(e,r));let i=v(t,[`src`]);i!=null&&_(n,[`batch`,`inputConfig`],Zn(e,i));let a=v(t,[`config`]);return a!=null&&Un(a,n),n}function Gn(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],xn(e,r)),n}function Kn(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],xn(e,r)),n}function qn(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`name`]);r!=null&&_(t,[`name`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);return a!=null&&_(t,[`error`],a),t}function Jn(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`name`]);r!=null&&_(t,[`name`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);return a!=null&&_(t,[`error`],a),t}function Yn(e,t){let n={},r=v(t,[`contents`]);if(r!=null){let t=$t(e,r);Array.isArray(t)&&(t=t.map(e=>e)),_(n,[`requests[]`,`request`,`content`],t)}let i=v(t,[`config`]);return i!=null&&(_(n,[`_self`],Xn(i,n)),y(n,{"requests[].*":`requests[].request.*`})),n}function Xn(e,t){let n={},r=v(e,[`taskType`]);t!==void 0&&r!=null&&_(t,[`requests[]`,`taskType`],r);let i=v(e,[`title`]);t!==void 0&&i!=null&&_(t,[`requests[]`,`title`],i);let a=v(e,[`outputDimensionality`]);if(t!==void 0&&a!=null&&_(t,[`requests[]`,`outputDimensionality`],a),v(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(v(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);if(v(e,[`documentOcr`])!==void 0)throw Error(`documentOcr parameter is not supported in Gemini API.`);if(v(e,[`audioTrackExtraction`])!==void 0)throw Error(`audioTrackExtraction parameter is not supported in Gemini API.`);return n}function Zn(e,t){let n={},r=v(t,[`fileName`]);r!=null&&_(n,[`file_name`],r);let i=v(t,[`inlinedRequests`]);return i!=null&&_(n,[`requests`],Yn(e,i)),n}function Qn(e){let t={};if(v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=v(e,[`fileUri`]);n!=null&&_(t,[`fileUri`],n);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function $n(e){let t={},n=v(e,[`id`]);n!=null&&_(t,[`id`],n);let r=v(e,[`args`]);r!=null&&_(t,[`args`],r);let i=v(e,[`name`]);if(i!=null&&_(t,[`name`],i),v(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(v(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function er(e){let t={},n=v(e,[`allowedFunctionNames`]);n!=null&&_(t,[`allowedFunctionNames`],n);let r=v(e,[`mode`]);if(r!=null&&_(t,[`mode`],r),v(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function tr(e,t,n){let r={},i=v(t,[`systemInstruction`]);n!==void 0&&i!=null&&_(n,[`systemInstruction`],Rn(I(i)));let a=v(t,[`temperature`]);a!=null&&_(r,[`temperature`],a);let o=v(t,[`topP`]);o!=null&&_(r,[`topP`],o);let s=v(t,[`topK`]);s!=null&&_(r,[`topK`],s);let c=v(t,[`candidateCount`]);c!=null&&_(r,[`candidateCount`],c);let l=v(t,[`maxOutputTokens`]);l!=null&&_(r,[`maxOutputTokens`],l);let u=v(t,[`stopSequences`]);u!=null&&_(r,[`stopSequences`],u);let d=v(t,[`responseLogprobs`]);d!=null&&_(r,[`responseLogprobs`],d);let f=v(t,[`logprobs`]);f!=null&&_(r,[`logprobs`],f);let p=v(t,[`presencePenalty`]);p!=null&&_(r,[`presencePenalty`],p);let m=v(t,[`frequencyPenalty`]);m!=null&&_(r,[`frequencyPenalty`],m);let h=v(t,[`seed`]);h!=null&&_(r,[`seed`],h);let g=v(t,[`responseMimeType`]);g!=null&&_(r,[`responseMimeType`],g);let y=v(t,[`responseSchema`]);y!=null&&_(r,[`responseSchema`],tn(y));let b=v(t,[`responseJsonSchema`]);if(b!=null&&_(r,[`responseJsonSchema`],b),v(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(v(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let x=v(t,[`safetySettings`]);if(n!==void 0&&x!=null){let e=x;Array.isArray(e)&&(e=e.map(e=>_r(e))),_(n,[`safetySettings`],e)}let S=v(t,[`tools`]);if(n!==void 0&&S!=null){let e=on(S);Array.isArray(e)&&(e=e.map(e=>yr(an(e)))),_(n,[`tools`],e)}let C=v(t,[`toolConfig`]);if(n!==void 0&&C!=null&&_(n,[`toolConfig`],vr(C)),v(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let w=v(t,[`cachedContent`]);n!==void 0&&w!=null&&_(n,[`cachedContent`],z(e,w));let T=v(t,[`responseModalities`]);T!=null&&_(r,[`responseModalities`],T);let E=v(t,[`mediaResolution`]);E!=null&&_(r,[`mediaResolution`],E);let D=v(t,[`speechConfig`]);if(D!=null&&_(r,[`speechConfig`],nn(D)),v(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let O=v(t,[`thinkingConfig`]);O!=null&&_(r,[`thinkingConfig`],O);let k=v(t,[`imageConfig`]);k!=null&&_(r,[`imageConfig`],sr(k));let A=v(t,[`enableEnhancedCivicAnswers`]);if(A!=null&&_(r,[`enableEnhancedCivicAnswers`],A),v(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is not supported in Gemini API.`);let j=v(t,[`serviceTier`]);return n!==void 0&&j!=null&&_(n,[`serviceTier`],j),r}function nr(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>In(e))),_(t,[`candidates`],e)}let i=v(e,[`modelVersion`]);i!=null&&_(t,[`modelVersion`],i);let a=v(e,[`promptFeedback`]);a!=null&&_(t,[`promptFeedback`],a);let o=v(e,[`responseId`]);o!=null&&_(t,[`responseId`],o);let s=v(e,[`usageMetadata`]);s!=null&&_(t,[`usageMetadata`],s);let c=v(e,[`modelStatus`]);return c!=null&&_(t,[`modelStatus`],c),t}function rr(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],xn(e,r)),n}function ir(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],xn(e,r)),n}function ar(e){let t={},n=v(e,[`authConfig`]);n!=null&&_(t,[`authConfig`],wn(n));let r=v(e,[`enableWidget`]);return r!=null&&_(t,[`enableWidget`],r),t}function or(e){let t={},n=v(e,[`searchTypes`]);if(n!=null&&_(t,[`searchTypes`],n),v(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(v(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=v(e,[`timeRangeFilter`]);return r!=null&&_(t,[`timeRangeFilter`],r),t}function sr(e){let t={},n=v(e,[`aspectRatio`]);n!=null&&_(t,[`aspectRatio`],n);let r=v(e,[`imageSize`]);if(r!=null&&_(t,[`imageSize`],r),v(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is not supported in Gemini API.`);if(v(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is not supported in Gemini API.`);if(v(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(v(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);if(v(e,[`imageOutputOptions`])!==void 0)throw Error(`imageOutputOptions parameter is not supported in Gemini API.`);return t}function cr(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`request`,`model`],F(e,r));let i=v(t,[`contents`]);if(i!=null){let e=L(i);Array.isArray(e)&&(e=e.map(e=>Rn(e))),_(n,[`request`,`contents`],e)}let a=v(t,[`metadata`]);a!=null&&_(n,[`metadata`],a);let o=v(t,[`config`]);return o!=null&&_(n,[`request`,`generationConfig`],tr(e,o,v(n,[`request`],{}))),n}function lr(e){let t={},n=v(e,[`response`]);n!=null&&_(t,[`response`],nr(n));let r=v(e,[`metadata`]);r!=null&&_(t,[`metadata`],r);let i=v(e,[`error`]);return i!=null&&_(t,[`error`],i),t}function ur(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);if(t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i),v(e,[`filter`])!==void 0)throw Error(`filter parameter is not supported in Gemini API.`);return n}function dr(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i);let a=v(e,[`filter`]);return t!==void 0&&a!=null&&_(t,[`_query`,`filter`],a),n}function fr(e){let t={},n=v(e,[`config`]);return n!=null&&ur(n,t),t}function pr(e){let t={},n=v(e,[`config`]);return n!=null&&dr(n,t),t}function mr(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`operations`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>On(e))),_(t,[`batchJobs`],e)}return t}function hr(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`batchPredictionJobs`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>kn(e))),_(t,[`batchJobs`],e)}return t}function gr(e){let t={},n=v(e,[`mediaResolution`]);n!=null&&_(t,[`mediaResolution`],n);let r=v(e,[`codeExecutionResult`]);r!=null&&_(t,[`codeExecutionResult`],r);let i=v(e,[`executableCode`]);i!=null&&_(t,[`executableCode`],i);let a=v(e,[`fileData`]);a!=null&&_(t,[`fileData`],Qn(a));let o=v(e,[`functionCall`]);o!=null&&_(t,[`functionCall`],$n(o));let s=v(e,[`functionResponse`]);s!=null&&_(t,[`functionResponse`],s);let c=v(e,[`inlineData`]);c!=null&&_(t,[`inlineData`],Nn(c));let l=v(e,[`text`]);l!=null&&_(t,[`text`],l);let u=v(e,[`thought`]);u!=null&&_(t,[`thought`],u);let d=v(e,[`thoughtSignature`]);d!=null&&_(t,[`thoughtSignature`],d);let f=v(e,[`videoMetadata`]);f!=null&&_(t,[`videoMetadata`],f);let p=v(e,[`toolCall`]);p!=null&&_(t,[`toolCall`],p);let m=v(e,[`toolResponse`]);m!=null&&_(t,[`toolResponse`],m);let h=v(e,[`partMetadata`]);return h!=null&&_(t,[`partMetadata`],h),t}function _r(e){let t={},n=v(e,[`category`]);if(n!=null&&_(t,[`category`],n),v(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=v(e,[`threshold`]);return r!=null&&_(t,[`threshold`],r),t}function vr(e){let t={},n=v(e,[`retrievalConfig`]);n!=null&&_(t,[`retrievalConfig`],n);let r=v(e,[`functionCallingConfig`]);r!=null&&_(t,[`functionCallingConfig`],er(r));let i=v(e,[`includeServerSideToolInvocations`]);return i!=null&&_(t,[`includeServerSideToolInvocations`],i),t}function yr(e){let t={};if(v(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=v(e,[`computerUse`]);n!=null&&_(t,[`computerUse`],n);let r=v(e,[`fileSearch`]);r!=null&&_(t,[`fileSearch`],r);let i=v(e,[`googleSearch`]);i!=null&&_(t,[`googleSearch`],or(i));let a=v(e,[`googleMaps`]);a!=null&&_(t,[`googleMaps`],ar(a));let o=v(e,[`codeExecution`]);if(o!=null&&_(t,[`codeExecution`],o),v(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=v(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`functionDeclarations`],e)}let c=v(e,[`googleSearchRetrieval`]);if(c!=null&&_(t,[`googleSearchRetrieval`],c),v(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=v(e,[`urlContext`]);l!=null&&_(t,[`urlContext`],l);let u=v(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`mcpServers`],e)}return t}function br(e){let t={},n=v(e,[`bigqueryDestination`,`outputUri`]);n!=null&&_(t,[`bigqueryDestination`],n);let r=v(e,[`displayName`]);return r!=null&&_(t,[`displayName`],r),t}function xr(e){let t={},n=v(e,[`bigqueryDestination`]);n!=null&&_(t,[`bigqueryDestination`,`outputUri`],n);let r=v(e,[`displayName`]);return r!=null&&_(t,[`displayName`],r),t}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 h{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(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support batches.createEmbeddings.`);return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){let t=Vn(this.apiClient,e),n=t._url,r=g(`{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)n.dest=t.endsWith(`.jsonl`)?`${t.slice(0,-6)}/dest`:`${t}_dest_${r}`;else if(i)n.dest=`${i}_dest_${r}`;else throw Error(`Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.`)}return n}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Hn(this.apiClient,e);return n=g(`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=>kn(e))}{let i=Vn(this.apiClient,e);return n=g(`{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=>On(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=Wn(this.apiClient,e);return n=g(`{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=>On(e))}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ir(this.apiClient,e);return n=g(`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=>kn(e))}{let i=rr(this.apiClient,e);return n=g(`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=>On(e))}}async cancel(e){let t=``,n={};if(this.apiClient.isVertexAI()){let r=Fn(this.apiClient,e);t=g(`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=Pn(this.apiClient,e);t=g(`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=pr(e);return n=g(`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=hr(e),n=new zt;return Object.assign(n,t),n})}{let i=fr(e);return n=g(`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=mr(e),n=new zt;return Object.assign(n,t),n})}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Kn(this.apiClient,e);return n=g(`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=>Jn(e))}{let i=Gn(this.apiClient,e);return n=g(`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=>qn(e))}}};function Cr(e){let t={},n=v(e,[`apiKey`]);if(n!=null&&_(t,[`apiKey`],n),v(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(v(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(v(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(v(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(v(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(v(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function wr(e){let t={},n=v(e,[`data`]);if(n!=null&&_(t,[`data`],n),v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function Tr(e){let t={},n=v(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Yr(e))),_(t,[`parts`],e)}let r=v(e,[`role`]);return r!=null&&_(t,[`role`],r),t}function Er(e){let t={},n=v(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Xr(e))),_(t,[`parts`],e)}let r=v(e,[`role`]);return r!=null&&_(t,[`role`],r),t}function Dr(e,t){let n={},r=v(e,[`ttl`]);t!==void 0&&r!=null&&_(t,[`ttl`],r);let i=v(e,[`expireTime`]);t!==void 0&&i!=null&&_(t,[`expireTime`],i);let a=v(e,[`displayName`]);t!==void 0&&a!=null&&_(t,[`displayName`],a);let o=v(e,[`contents`]);if(t!==void 0&&o!=null){let e=L(o);Array.isArray(e)&&(e=e.map(e=>Tr(e))),_(t,[`contents`],e)}let s=v(e,[`systemInstruction`]);t!==void 0&&s!=null&&_(t,[`systemInstruction`],Tr(I(s)));let c=v(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>$r(e))),_(t,[`tools`],e)}let l=v(e,[`toolConfig`]);if(t!==void 0&&l!=null&&_(t,[`toolConfig`],Zr(l)),v(e,[`kmsKeyName`])!==void 0)throw Error(`kmsKeyName parameter is not supported in Gemini API.`);return n}function Or(e,t){let n={},r=v(e,[`ttl`]);t!==void 0&&r!=null&&_(t,[`ttl`],r);let i=v(e,[`expireTime`]);t!==void 0&&i!=null&&_(t,[`expireTime`],i);let a=v(e,[`displayName`]);t!==void 0&&a!=null&&_(t,[`displayName`],a);let o=v(e,[`contents`]);if(t!==void 0&&o!=null){let e=L(o);Array.isArray(e)&&(e=e.map(e=>Er(e))),_(t,[`contents`],e)}let s=v(e,[`systemInstruction`]);t!==void 0&&s!=null&&_(t,[`systemInstruction`],Er(I(s)));let c=v(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>ei(e))),_(t,[`tools`],e)}let l=v(e,[`toolConfig`]);t!==void 0&&l!=null&&_(t,[`toolConfig`],Qr(l));let u=v(e,[`kmsKeyName`]);return t!==void 0&&u!=null&&_(t,[`encryption_spec`,`kmsKeyName`],u),n}function kr(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`model`],Ut(e,r));let i=v(t,[`config`]);return i!=null&&Dr(i,n),n}function Ar(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`model`],Ut(e,r));let i=v(t,[`config`]);return i!=null&&Or(i,n),n}function jr(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],z(e,r)),n}function Mr(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],z(e,r)),n}function Nr(e){let t={},n=v(e,[`sdkHttpResponse`]);return n!=null&&_(t,[`sdkHttpResponse`],n),t}function Pr(e){let t={},n=v(e,[`sdkHttpResponse`]);return n!=null&&_(t,[`sdkHttpResponse`],n),t}function Fr(e){let t={};if(v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=v(e,[`fileUri`]);n!=null&&_(t,[`fileUri`],n);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function Ir(e){let t={},n=v(e,[`id`]);n!=null&&_(t,[`id`],n);let r=v(e,[`args`]);r!=null&&_(t,[`args`],r);let i=v(e,[`name`]);if(i!=null&&_(t,[`name`],i),v(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(v(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Lr(e){let t={},n=v(e,[`allowedFunctionNames`]);n!=null&&_(t,[`allowedFunctionNames`],n);let r=v(e,[`mode`]);if(r!=null&&_(t,[`mode`],r),v(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function Rr(e){let t={},n=v(e,[`description`]);n!=null&&_(t,[`description`],n);let r=v(e,[`name`]);r!=null&&_(t,[`name`],r);let i=v(e,[`parameters`]);i!=null&&_(t,[`parameters`],i);let a=v(e,[`parametersJsonSchema`]);a!=null&&_(t,[`parametersJsonSchema`],a);let o=v(e,[`response`]);o!=null&&_(t,[`response`],o);let s=v(e,[`responseJsonSchema`]);if(s!=null&&_(t,[`responseJsonSchema`],s),v(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function zr(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],z(e,r)),n}function Br(e,t){let n={},r=v(t,[`name`]);return r!=null&&_(n,[`_url`,`name`],z(e,r)),n}function Vr(e){let t={},n=v(e,[`authConfig`]);n!=null&&_(t,[`authConfig`],Cr(n));let r=v(e,[`enableWidget`]);return r!=null&&_(t,[`enableWidget`],r),t}function Hr(e){let t={},n=v(e,[`searchTypes`]);if(n!=null&&_(t,[`searchTypes`],n),v(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(v(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=v(e,[`timeRangeFilter`]);return r!=null&&_(t,[`timeRangeFilter`],r),t}function Ur(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);return t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i),n}function Wr(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);return t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i),n}function Gr(e){let t={},n=v(e,[`config`]);return n!=null&&Ur(n,t),t}function Kr(e){let t={},n=v(e,[`config`]);return n!=null&&Wr(n,t),t}function qr(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`cachedContents`],e)}return t}function Jr(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`cachedContents`],e)}return t}function Yr(e){let t={},n=v(e,[`mediaResolution`]);n!=null&&_(t,[`mediaResolution`],n);let r=v(e,[`codeExecutionResult`]);r!=null&&_(t,[`codeExecutionResult`],r);let i=v(e,[`executableCode`]);i!=null&&_(t,[`executableCode`],i);let a=v(e,[`fileData`]);a!=null&&_(t,[`fileData`],Fr(a));let o=v(e,[`functionCall`]);o!=null&&_(t,[`functionCall`],Ir(o));let s=v(e,[`functionResponse`]);s!=null&&_(t,[`functionResponse`],s);let c=v(e,[`inlineData`]);c!=null&&_(t,[`inlineData`],wr(c));let l=v(e,[`text`]);l!=null&&_(t,[`text`],l);let u=v(e,[`thought`]);u!=null&&_(t,[`thought`],u);let d=v(e,[`thoughtSignature`]);d!=null&&_(t,[`thoughtSignature`],d);let f=v(e,[`videoMetadata`]);f!=null&&_(t,[`videoMetadata`],f);let p=v(e,[`toolCall`]);p!=null&&_(t,[`toolCall`],p);let m=v(e,[`toolResponse`]);m!=null&&_(t,[`toolResponse`],m);let h=v(e,[`partMetadata`]);return h!=null&&_(t,[`partMetadata`],h),t}function Xr(e){let t={},n=v(e,[`mediaResolution`]);n!=null&&_(t,[`mediaResolution`],n);let r=v(e,[`codeExecutionResult`]);r!=null&&_(t,[`codeExecutionResult`],r);let i=v(e,[`executableCode`]);i!=null&&_(t,[`executableCode`],i);let a=v(e,[`fileData`]);a!=null&&_(t,[`fileData`],a);let o=v(e,[`functionCall`]);o!=null&&_(t,[`functionCall`],o);let s=v(e,[`functionResponse`]);s!=null&&_(t,[`functionResponse`],s);let c=v(e,[`inlineData`]);c!=null&&_(t,[`inlineData`],c);let l=v(e,[`text`]);l!=null&&_(t,[`text`],l);let u=v(e,[`thought`]);u!=null&&_(t,[`thought`],u);let d=v(e,[`thoughtSignature`]);d!=null&&_(t,[`thoughtSignature`],d);let f=v(e,[`videoMetadata`]);if(f!=null&&_(t,[`videoMetadata`],f),v(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Zr(e){let t={},n=v(e,[`retrievalConfig`]);n!=null&&_(t,[`retrievalConfig`],n);let r=v(e,[`functionCallingConfig`]);r!=null&&_(t,[`functionCallingConfig`],Lr(r));let i=v(e,[`includeServerSideToolInvocations`]);return i!=null&&_(t,[`includeServerSideToolInvocations`],i),t}function Qr(e){let t={},n=v(e,[`retrievalConfig`]);n!=null&&_(t,[`retrievalConfig`],n);let r=v(e,[`functionCallingConfig`]);if(r!=null&&_(t,[`functionCallingConfig`],r),v(e,[`includeServerSideToolInvocations`])!==void 0)throw Error(`includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function $r(e){let t={};if(v(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=v(e,[`computerUse`]);n!=null&&_(t,[`computerUse`],n);let r=v(e,[`fileSearch`]);r!=null&&_(t,[`fileSearch`],r);let i=v(e,[`googleSearch`]);i!=null&&_(t,[`googleSearch`],Hr(i));let a=v(e,[`googleMaps`]);a!=null&&_(t,[`googleMaps`],Vr(a));let o=v(e,[`codeExecution`]);if(o!=null&&_(t,[`codeExecution`],o),v(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=v(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`functionDeclarations`],e)}let c=v(e,[`googleSearchRetrieval`]);if(c!=null&&_(t,[`googleSearchRetrieval`],c),v(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=v(e,[`urlContext`]);l!=null&&_(t,[`urlContext`],l);let u=v(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`mcpServers`],e)}return t}function ei(e){let t={},n=v(e,[`retrieval`]);n!=null&&_(t,[`retrieval`],n);let r=v(e,[`computerUse`]);if(r!=null&&_(t,[`computerUse`],r),v(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let i=v(e,[`googleSearch`]);i!=null&&_(t,[`googleSearch`],i);let a=v(e,[`googleMaps`]);a!=null&&_(t,[`googleMaps`],a);let o=v(e,[`codeExecution`]);o!=null&&_(t,[`codeExecution`],o);let s=v(e,[`enterpriseWebSearch`]);s!=null&&_(t,[`enterpriseWebSearch`],s);let c=v(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Rr(e))),_(t,[`functionDeclarations`],e)}let l=v(e,[`googleSearchRetrieval`]);l!=null&&_(t,[`googleSearchRetrieval`],l);let u=v(e,[`parallelAiSearch`]);u!=null&&_(t,[`parallelAiSearch`],u);let d=v(e,[`urlContext`]);if(d!=null&&_(t,[`urlContext`],d),v(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function ti(e,t){let n={},r=v(e,[`ttl`]);t!==void 0&&r!=null&&_(t,[`ttl`],r);let i=v(e,[`expireTime`]);return t!==void 0&&i!=null&&_(t,[`expireTime`],i),n}function ni(e,t){let n={},r=v(e,[`ttl`]);t!==void 0&&r!=null&&_(t,[`ttl`],r);let i=v(e,[`expireTime`]);return t!==void 0&&i!=null&&_(t,[`expireTime`],i),n}function ri(e,t){let n={},r=v(t,[`name`]);r!=null&&_(n,[`_url`,`name`],z(e,r));let i=v(t,[`config`]);return i!=null&&ti(i,n),n}function ii(e,t){let n={},r=v(t,[`name`]);r!=null&&_(n,[`_url`,`name`],z(e,r));let i=v(t,[`config`]);return i!=null&&ni(i,n),n}var ai=class extends h{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=Ar(this.apiClient,e);return n=g(`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)}{let i=kr(this.apiClient,e);return n=g(`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=Br(this.apiClient,e);return n=g(`{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)}{let i=zr(this.apiClient,e);return n=g(`{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=Mr(this.apiClient,e);return n=g(`{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=Pr(e),n=new kt;return Object.assign(n,t),n})}{let i=jr(this.apiClient,e);return n=g(`{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=Nr(e),n=new kt;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ii(this.apiClient,e);return n=g(`{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)}{let i=ri(this.apiClient,e);return n=g(`{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=g(`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 At;return Object.assign(n,t),n})}{let i=Gr(e);return n=g(`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=qr(e),n=new At;return Object.assign(n,t),n})}}};function U(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 oi(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 W(e){return this instanceof W?(this.v=e,this):new W(e)}function G(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 W?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 K(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof oi==`function`?oi(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)}}function si(e){if(e.candidates==null||e.candidates.length===0)return!1;let t=e.candidates[0]?.content;return t!==void 0&&ci(t)}function ci(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 li(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 ui(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&&!ci(e[r])&&(a=!1),r++;a?t.push(...i):t.pop()}return t}var di=class{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new fi(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}},fi=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(),li(i)}async sendMessage(e){await this.sendPromise;let t=I(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=I(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?ui(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){return G(this,arguments,function*(){var n,r,i,a;let o=[];try{for(var s=!0,c=K(e),l;l=yield W(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;if(si(e)){let t=e.candidates?.[0]?.content;t!==void 0&&o.push(t)}yield yield W(e)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield W(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(...ui(n)):this.history.push(e),this.history.push(...r)}},pi=class e extends Error{constructor(t){super(t.message),this.name=`ApiError`,this.status=t.status,Object.setPrototypeOf(this,e.prototype)}};function mi(e){let t={},n=v(e,[`file`]);return n!=null&&_(t,[`file`],n),t}function hi(e){let t={},n=v(e,[`sdkHttpResponse`]);return n!=null&&_(t,[`sdkHttpResponse`],n),t}function gi(e){let t={},n=v(e,[`name`]);return n!=null&&_(t,[`_url`,`file`],fn(n)),t}function _i(e){let t={},n=v(e,[`sdkHttpResponse`]);return n!=null&&_(t,[`sdkHttpResponse`],n),t}function vi(e){let t={},n=v(e,[`name`]);return n!=null&&_(t,[`_url`,`file`],fn(n)),t}function yi(e){let t={},n=v(e,[`uris`]);return n!=null&&_(t,[`uris`],n),t}function bi(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);return t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i),n}function xi(e){let t={},n=v(e,[`config`]);return n!=null&&bi(n,t),t}function Si(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`files`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`files`],e)}return t}function Ci(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`files`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`files`],e)}return t}var wi=class extends h{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(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files. You can share files through a GCS bucket.`);return this.apiClient.uploadFile(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=xi(e);return n=g(`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=Si(e),n=new Ft;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=mi(e);return n=g(`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=hi(e),n=new It;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=vi(e);return n=g(`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=gi(e);return n=g(`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=_i(e),n=new Lt;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=yi(e);return n=g(`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=Ci(e),n=new Rt;return Object.assign(n,t),n})}}};function Ti(e){let t={};if(v(e,[`languageCodes`])!==void 0)throw Error(`languageCodes parameter is not supported in Gemini API.`);return t}function Ei(e){let t={},n=v(e,[`apiKey`]);if(n!=null&&_(t,[`apiKey`],n),v(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(v(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(v(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(v(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(v(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(v(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function Di(e){let t={},n=v(e,[`data`]);if(n!=null&&_(t,[`data`],n),v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function Oi(e){let t={},n=v(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Gi(e))),_(t,[`parts`],e)}let r=v(e,[`role`]);return r!=null&&_(t,[`role`],r),t}function ki(e){let t={},n=v(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ki(e))),_(t,[`parts`],e)}let r=v(e,[`role`]);return r!=null&&_(t,[`role`],r),t}function Ai(e){let t={};if(v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=v(e,[`fileUri`]);n!=null&&_(t,[`fileUri`],n);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function ji(e){let t={},n=v(e,[`id`]);n!=null&&_(t,[`id`],n);let r=v(e,[`args`]);r!=null&&_(t,[`args`],r);let i=v(e,[`name`]);if(i!=null&&_(t,[`name`],i),v(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(v(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Mi(e){let t={},n=v(e,[`description`]);n!=null&&_(t,[`description`],n);let r=v(e,[`name`]);r!=null&&_(t,[`name`],r);let i=v(e,[`parameters`]);i!=null&&_(t,[`parameters`],i);let a=v(e,[`parametersJsonSchema`]);a!=null&&_(t,[`parametersJsonSchema`],a);let o=v(e,[`response`]);o!=null&&_(t,[`response`],o);let s=v(e,[`responseJsonSchema`]);if(s!=null&&_(t,[`responseJsonSchema`],s),v(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Ni(e){let t={},n=v(e,[`modelSelectionConfig`]);n!=null&&_(t,[`modelConfig`],n);let r=v(e,[`responseJsonSchema`]);r!=null&&_(t,[`responseJsonSchema`],r);let i=v(e,[`audioTimestamp`]);i!=null&&_(t,[`audioTimestamp`],i);let a=v(e,[`candidateCount`]);a!=null&&_(t,[`candidateCount`],a);let o=v(e,[`enableAffectiveDialog`]);o!=null&&_(t,[`enableAffectiveDialog`],o);let s=v(e,[`frequencyPenalty`]);s!=null&&_(t,[`frequencyPenalty`],s);let c=v(e,[`logprobs`]);c!=null&&_(t,[`logprobs`],c);let l=v(e,[`maxOutputTokens`]);l!=null&&_(t,[`maxOutputTokens`],l);let u=v(e,[`mediaResolution`]);u!=null&&_(t,[`mediaResolution`],u);let d=v(e,[`presencePenalty`]);d!=null&&_(t,[`presencePenalty`],d);let f=v(e,[`responseLogprobs`]);f!=null&&_(t,[`responseLogprobs`],f);let p=v(e,[`responseMimeType`]);p!=null&&_(t,[`responseMimeType`],p);let m=v(e,[`responseModalities`]);m!=null&&_(t,[`responseModalities`],m);let h=v(e,[`responseSchema`]);h!=null&&_(t,[`responseSchema`],h);let g=v(e,[`routingConfig`]);g!=null&&_(t,[`routingConfig`],g);let y=v(e,[`seed`]);y!=null&&_(t,[`seed`],y);let b=v(e,[`speechConfig`]);b!=null&&_(t,[`speechConfig`],b);let x=v(e,[`stopSequences`]);x!=null&&_(t,[`stopSequences`],x);let S=v(e,[`temperature`]);S!=null&&_(t,[`temperature`],S);let C=v(e,[`thinkingConfig`]);C!=null&&_(t,[`thinkingConfig`],C);let w=v(e,[`topK`]);w!=null&&_(t,[`topK`],w);let T=v(e,[`topP`]);if(T!=null&&_(t,[`topP`],T),v(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Pi(e){let t={},n=v(e,[`authConfig`]);n!=null&&_(t,[`authConfig`],Ei(n));let r=v(e,[`enableWidget`]);return r!=null&&_(t,[`enableWidget`],r),t}function Fi(e){let t={},n=v(e,[`searchTypes`]);if(n!=null&&_(t,[`searchTypes`],n),v(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(v(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=v(e,[`timeRangeFilter`]);return r!=null&&_(t,[`timeRangeFilter`],r),t}function Ii(e,t){let n={},r=v(e,[`generationConfig`]);t!==void 0&&r!=null&&_(t,[`setup`,`generationConfig`],r);let i=v(e,[`responseModalities`]);t!==void 0&&i!=null&&_(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=v(e,[`temperature`]);t!==void 0&&a!=null&&_(t,[`setup`,`generationConfig`,`temperature`],a);let o=v(e,[`topP`]);t!==void 0&&o!=null&&_(t,[`setup`,`generationConfig`,`topP`],o);let s=v(e,[`topK`]);t!==void 0&&s!=null&&_(t,[`setup`,`generationConfig`,`topK`],s);let c=v(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&_(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=v(e,[`mediaResolution`]);t!==void 0&&l!=null&&_(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=v(e,[`seed`]);t!==void 0&&u!=null&&_(t,[`setup`,`generationConfig`,`seed`],u);let d=v(e,[`speechConfig`]);t!==void 0&&d!=null&&_(t,[`setup`,`generationConfig`,`speechConfig`],rn(d));let f=v(e,[`thinkingConfig`]);t!==void 0&&f!=null&&_(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=v(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&_(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=v(e,[`systemInstruction`]);t!==void 0&&m!=null&&_(t,[`setup`,`systemInstruction`],Oi(I(m)));let h=v(e,[`tools`]);if(t!==void 0&&h!=null){let e=on(h);Array.isArray(e)&&(e=e.map(e=>Yi(an(e)))),_(t,[`setup`,`tools`],e)}let g=v(e,[`sessionResumption`]);t!==void 0&&g!=null&&_(t,[`setup`,`sessionResumption`],Ji(g));let y=v(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&_(t,[`setup`,`inputAudioTranscription`],Ti(y));let b=v(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&_(t,[`setup`,`outputAudioTranscription`],Ti(b));let x=v(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&_(t,[`setup`,`realtimeInputConfig`],x);let S=v(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&_(t,[`setup`,`contextWindowCompression`],S);let C=v(e,[`proactivity`]);if(t!==void 0&&C!=null&&_(t,[`setup`,`proactivity`],C),v(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);let w=v(e,[`avatarConfig`]);t!==void 0&&w!=null&&_(t,[`setup`,`avatarConfig`],w);let T=v(e,[`safetySettings`]);if(t!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>qi(e))),_(t,[`setup`,`safetySettings`],e)}return n}function Li(e,t){let n={},r=v(e,[`generationConfig`]);t!==void 0&&r!=null&&_(t,[`setup`,`generationConfig`],Ni(r));let i=v(e,[`responseModalities`]);t!==void 0&&i!=null&&_(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=v(e,[`temperature`]);t!==void 0&&a!=null&&_(t,[`setup`,`generationConfig`,`temperature`],a);let o=v(e,[`topP`]);t!==void 0&&o!=null&&_(t,[`setup`,`generationConfig`,`topP`],o);let s=v(e,[`topK`]);t!==void 0&&s!=null&&_(t,[`setup`,`generationConfig`,`topK`],s);let c=v(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&_(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=v(e,[`mediaResolution`]);t!==void 0&&l!=null&&_(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=v(e,[`seed`]);t!==void 0&&u!=null&&_(t,[`setup`,`generationConfig`,`seed`],u);let d=v(e,[`speechConfig`]);t!==void 0&&d!=null&&_(t,[`setup`,`generationConfig`,`speechConfig`],rn(d));let f=v(e,[`thinkingConfig`]);t!==void 0&&f!=null&&_(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=v(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&_(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=v(e,[`systemInstruction`]);t!==void 0&&m!=null&&_(t,[`setup`,`systemInstruction`],ki(I(m)));let h=v(e,[`tools`]);if(t!==void 0&&h!=null){let e=on(h);Array.isArray(e)&&(e=e.map(e=>Xi(an(e)))),_(t,[`setup`,`tools`],e)}let g=v(e,[`sessionResumption`]);t!==void 0&&g!=null&&_(t,[`setup`,`sessionResumption`],g);let y=v(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&_(t,[`setup`,`inputAudioTranscription`],y);let b=v(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&_(t,[`setup`,`outputAudioTranscription`],b);let x=v(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&_(t,[`setup`,`realtimeInputConfig`],x);let S=v(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&_(t,[`setup`,`contextWindowCompression`],S);let C=v(e,[`proactivity`]);t!==void 0&&C!=null&&_(t,[`setup`,`proactivity`],C);let w=v(e,[`explicitVadSignal`]);t!==void 0&&w!=null&&_(t,[`setup`,`explicitVadSignal`],w);let T=v(e,[`avatarConfig`]);t!==void 0&&T!=null&&_(t,[`setup`,`avatarConfig`],T);let E=v(e,[`safetySettings`]);if(t!==void 0&&E!=null){let e=E;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`setup`,`safetySettings`],e)}return n}function Ri(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`setup`,`model`],F(e,r));let i=v(t,[`config`]);return i!=null&&_(n,[`config`],Ii(i,n)),n}function zi(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`setup`,`model`],F(e,r));let i=v(t,[`config`]);return i!=null&&_(n,[`config`],Li(i,n)),n}function Bi(e){let t={},n=v(e,[`musicGenerationConfig`]);return n!=null&&_(t,[`musicGenerationConfig`],n),t}function Vi(e){let t={},n=v(e,[`weightedPrompts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`weightedPrompts`],e)}return t}function Hi(e){let t={},n=v(e,[`media`]);if(n!=null){let e=Wt(n);Array.isArray(e)&&(e=e.map(e=>Di(e))),_(t,[`mediaChunks`],e)}let r=v(e,[`audio`]);r!=null&&_(t,[`audio`],Di(qt(r)));let i=v(e,[`audioStreamEnd`]);i!=null&&_(t,[`audioStreamEnd`],i);let a=v(e,[`video`]);a!=null&&_(t,[`video`],Di(Kt(a)));let o=v(e,[`text`]);o!=null&&_(t,[`text`],o);let s=v(e,[`activityStart`]);s!=null&&_(t,[`activityStart`],s);let c=v(e,[`activityEnd`]);return c!=null&&_(t,[`activityEnd`],c),t}function Ui(e){let t={},n=v(e,[`media`]);if(n!=null){let e=Wt(n);Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`mediaChunks`],e)}let r=v(e,[`audio`]);r!=null&&_(t,[`audio`],qt(r));let i=v(e,[`audioStreamEnd`]);i!=null&&_(t,[`audioStreamEnd`],i);let a=v(e,[`video`]);a!=null&&_(t,[`video`],Kt(a));let o=v(e,[`text`]);o!=null&&_(t,[`text`],o);let s=v(e,[`activityStart`]);s!=null&&_(t,[`activityStart`],s);let c=v(e,[`activityEnd`]);return c!=null&&_(t,[`activityEnd`],c),t}function Wi(e){let t={},n=v(e,[`setupComplete`]);n!=null&&_(t,[`setupComplete`],n);let r=v(e,[`serverContent`]);r!=null&&_(t,[`serverContent`],r);let i=v(e,[`toolCall`]);i!=null&&_(t,[`toolCall`],i);let a=v(e,[`toolCallCancellation`]);a!=null&&_(t,[`toolCallCancellation`],a);let o=v(e,[`usageMetadata`]);o!=null&&_(t,[`usageMetadata`],Zi(o));let s=v(e,[`goAway`]);s!=null&&_(t,[`goAway`],s);let c=v(e,[`sessionResumptionUpdate`]);c!=null&&_(t,[`sessionResumptionUpdate`],c);let l=v(e,[`voiceActivityDetectionSignal`]);l!=null&&_(t,[`voiceActivityDetectionSignal`],l);let u=v(e,[`voiceActivity`]);return u!=null&&_(t,[`voiceActivity`],Qi(u)),t}function Gi(e){let t={},n=v(e,[`mediaResolution`]);n!=null&&_(t,[`mediaResolution`],n);let r=v(e,[`codeExecutionResult`]);r!=null&&_(t,[`codeExecutionResult`],r);let i=v(e,[`executableCode`]);i!=null&&_(t,[`executableCode`],i);let a=v(e,[`fileData`]);a!=null&&_(t,[`fileData`],Ai(a));let o=v(e,[`functionCall`]);o!=null&&_(t,[`functionCall`],ji(o));let s=v(e,[`functionResponse`]);s!=null&&_(t,[`functionResponse`],s);let c=v(e,[`inlineData`]);c!=null&&_(t,[`inlineData`],Di(c));let l=v(e,[`text`]);l!=null&&_(t,[`text`],l);let u=v(e,[`thought`]);u!=null&&_(t,[`thought`],u);let d=v(e,[`thoughtSignature`]);d!=null&&_(t,[`thoughtSignature`],d);let f=v(e,[`videoMetadata`]);f!=null&&_(t,[`videoMetadata`],f);let p=v(e,[`toolCall`]);p!=null&&_(t,[`toolCall`],p);let m=v(e,[`toolResponse`]);m!=null&&_(t,[`toolResponse`],m);let h=v(e,[`partMetadata`]);return h!=null&&_(t,[`partMetadata`],h),t}function Ki(e){let t={},n=v(e,[`mediaResolution`]);n!=null&&_(t,[`mediaResolution`],n);let r=v(e,[`codeExecutionResult`]);r!=null&&_(t,[`codeExecutionResult`],r);let i=v(e,[`executableCode`]);i!=null&&_(t,[`executableCode`],i);let a=v(e,[`fileData`]);a!=null&&_(t,[`fileData`],a);let o=v(e,[`functionCall`]);o!=null&&_(t,[`functionCall`],o);let s=v(e,[`functionResponse`]);s!=null&&_(t,[`functionResponse`],s);let c=v(e,[`inlineData`]);c!=null&&_(t,[`inlineData`],c);let l=v(e,[`text`]);l!=null&&_(t,[`text`],l);let u=v(e,[`thought`]);u!=null&&_(t,[`thought`],u);let d=v(e,[`thoughtSignature`]);d!=null&&_(t,[`thoughtSignature`],d);let f=v(e,[`videoMetadata`]);if(f!=null&&_(t,[`videoMetadata`],f),v(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function qi(e){let t={},n=v(e,[`category`]);if(n!=null&&_(t,[`category`],n),v(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=v(e,[`threshold`]);return r!=null&&_(t,[`threshold`],r),t}function Ji(e){let t={},n=v(e,[`handle`]);if(n!=null&&_(t,[`handle`],n),v(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function Yi(e){let t={};if(v(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=v(e,[`computerUse`]);n!=null&&_(t,[`computerUse`],n);let r=v(e,[`fileSearch`]);r!=null&&_(t,[`fileSearch`],r);let i=v(e,[`googleSearch`]);i!=null&&_(t,[`googleSearch`],Fi(i));let a=v(e,[`googleMaps`]);a!=null&&_(t,[`googleMaps`],Pi(a));let o=v(e,[`codeExecution`]);if(o!=null&&_(t,[`codeExecution`],o),v(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=v(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`functionDeclarations`],e)}let c=v(e,[`googleSearchRetrieval`]);if(c!=null&&_(t,[`googleSearchRetrieval`],c),v(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=v(e,[`urlContext`]);l!=null&&_(t,[`urlContext`],l);let u=v(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`mcpServers`],e)}return t}function Xi(e){let t={},n=v(e,[`retrieval`]);n!=null&&_(t,[`retrieval`],n);let r=v(e,[`computerUse`]);if(r!=null&&_(t,[`computerUse`],r),v(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let i=v(e,[`googleSearch`]);i!=null&&_(t,[`googleSearch`],i);let a=v(e,[`googleMaps`]);a!=null&&_(t,[`googleMaps`],a);let o=v(e,[`codeExecution`]);o!=null&&_(t,[`codeExecution`],o);let s=v(e,[`enterpriseWebSearch`]);s!=null&&_(t,[`enterpriseWebSearch`],s);let c=v(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Mi(e))),_(t,[`functionDeclarations`],e)}let l=v(e,[`googleSearchRetrieval`]);l!=null&&_(t,[`googleSearchRetrieval`],l);let u=v(e,[`parallelAiSearch`]);u!=null&&_(t,[`parallelAiSearch`],u);let d=v(e,[`urlContext`]);if(d!=null&&_(t,[`urlContext`],d),v(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return t}function Zi(e){let t={},n=v(e,[`promptTokenCount`]);n!=null&&_(t,[`promptTokenCount`],n);let r=v(e,[`cachedContentTokenCount`]);r!=null&&_(t,[`cachedContentTokenCount`],r);let i=v(e,[`candidatesTokenCount`]);i!=null&&_(t,[`responseTokenCount`],i);let a=v(e,[`toolUsePromptTokenCount`]);a!=null&&_(t,[`toolUsePromptTokenCount`],a);let o=v(e,[`thoughtsTokenCount`]);o!=null&&_(t,[`thoughtsTokenCount`],o);let s=v(e,[`totalTokenCount`]);s!=null&&_(t,[`totalTokenCount`],s);let c=v(e,[`promptTokensDetails`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`promptTokensDetails`],e)}let l=v(e,[`cacheTokensDetails`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`cacheTokensDetails`],e)}let u=v(e,[`candidatesTokensDetails`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`responseTokensDetails`],e)}let d=v(e,[`toolUsePromptTokensDetails`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`toolUsePromptTokensDetails`],e)}let f=v(e,[`trafficType`]);return f!=null&&_(t,[`trafficType`],f),t}function Qi(e){let t={},n=v(e,[`type`]);return n!=null&&_(t,[`voiceActivityType`],n),t}function $i(e,t){let n={},r=v(e,[`apiKey`]);if(r!=null&&_(n,[`apiKey`],r),v(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(v(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(v(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(v(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(v(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(v(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return n}function ea(e,t){let n={},r=v(e,[`data`]);if(r!=null&&_(n,[`data`],r),v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let i=v(e,[`mimeType`]);return i!=null&&_(n,[`mimeType`],i),n}function ta(e,t){let n={},r=v(e,[`content`]);r!=null&&_(n,[`content`],r);let i=v(e,[`citationMetadata`]);i!=null&&_(n,[`citationMetadata`],na(i));let a=v(e,[`tokenCount`]);a!=null&&_(n,[`tokenCount`],a);let o=v(e,[`finishReason`]);o!=null&&_(n,[`finishReason`],o);let s=v(e,[`groundingMetadata`]);s!=null&&_(n,[`groundingMetadata`],s);let c=v(e,[`avgLogprobs`]);c!=null&&_(n,[`avgLogprobs`],c);let l=v(e,[`index`]);l!=null&&_(n,[`index`],l);let u=v(e,[`logprobsResult`]);u!=null&&_(n,[`logprobsResult`],u);let d=v(e,[`safetyRatings`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`safetyRatings`],e)}let f=v(e,[`urlContextMetadata`]);return f!=null&&_(n,[`urlContextMetadata`],f),n}function na(e,t){let n={},r=v(e,[`citationSources`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`citations`],e)}return n}function ra(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`contents`]);if(a!=null){let e=L(a);Array.isArray(e)&&(e=e.map(e=>ca(e))),_(r,[`contents`],e)}return r}function ia(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`tokensInfo`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`tokensInfo`],e)}return n}function aa(e,t){let n={},r=v(e,[`values`]);r!=null&&_(n,[`values`],r);let i=v(e,[`statistics`]);return i!=null&&_(n,[`statistics`],oa(i)),n}function oa(e,t){let n={},r=v(e,[`truncated`]);r!=null&&_(n,[`truncated`],r);let i=v(e,[`token_count`]);return i!=null&&_(n,[`tokenCount`],i),n}function sa(e,t){let n={},r=v(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Do(e))),_(n,[`parts`],e)}let i=v(e,[`role`]);return i!=null&&_(n,[`role`],i),n}function ca(e,t){let n={},r=v(e,[`parts`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Oo(e))),_(n,[`parts`],e)}let i=v(e,[`role`]);return i!=null&&_(n,[`role`],i),n}function la(e,t){let n={},r=v(e,[`controlType`]);r!=null&&_(n,[`controlType`],r);let i=v(e,[`enableControlImageComputation`]);return i!=null&&_(n,[`computeControl`],i),n}function ua(e,t){let n={};if(v(e,[`systemInstruction`])!==void 0)throw Error(`systemInstruction parameter is not supported in Gemini API.`);if(v(e,[`tools`])!==void 0)throw Error(`tools parameter is not supported in Gemini API.`);if(v(e,[`generationConfig`])!==void 0)throw Error(`generationConfig parameter is not supported in Gemini API.`);return n}function da(e,t,n){let r={},i=v(e,[`systemInstruction`]);t!==void 0&&i!=null&&_(t,[`systemInstruction`],ca(I(i)));let a=v(e,[`tools`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>Ko(e))),_(t,[`tools`],e)}let o=v(e,[`generationConfig`]);return t!==void 0&&o!=null&&_(t,[`generationConfig`],so(o)),r}function fa(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`contents`]);if(a!=null){let e=L(a);Array.isArray(e)&&(e=e.map(e=>sa(e))),_(r,[`contents`],e)}let o=v(t,[`config`]);return o!=null&&ua(o),r}function pa(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`contents`]);if(a!=null){let e=L(a);Array.isArray(e)&&(e=e.map(e=>ca(e))),_(r,[`contents`],e)}let o=v(t,[`config`]);return o!=null&&da(o,r),r}function ma(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`totalTokens`]);i!=null&&_(n,[`totalTokens`],i);let a=v(e,[`cachedContentTokenCount`]);return a!=null&&_(n,[`cachedContentTokenCount`],a),n}function ha(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`totalTokens`]);return i!=null&&_(n,[`totalTokens`],i),n}function ga(e,t,n){let r={},i=v(t,[`model`]);return i!=null&&_(r,[`_url`,`name`],F(e,i)),r}function _a(e,t,n){let r={},i=v(t,[`model`]);return i!=null&&_(r,[`_url`,`name`],F(e,i)),r}function va(e,t){let n={},r=v(e,[`sdkHttpResponse`]);return r!=null&&_(n,[`sdkHttpResponse`],r),n}function ya(e,t){let n={},r=v(e,[`sdkHttpResponse`]);return r!=null&&_(n,[`sdkHttpResponse`],r),n}function ba(e,t,n){let r={},i=v(e,[`outputGcsUri`]);t!==void 0&&i!=null&&_(t,[`parameters`,`storageUri`],i);let a=v(e,[`negativePrompt`]);t!==void 0&&a!=null&&_(t,[`parameters`,`negativePrompt`],a);let o=v(e,[`numberOfImages`]);t!==void 0&&o!=null&&_(t,[`parameters`,`sampleCount`],o);let s=v(e,[`aspectRatio`]);t!==void 0&&s!=null&&_(t,[`parameters`,`aspectRatio`],s);let c=v(e,[`guidanceScale`]);t!==void 0&&c!=null&&_(t,[`parameters`,`guidanceScale`],c);let l=v(e,[`seed`]);t!==void 0&&l!=null&&_(t,[`parameters`,`seed`],l);let u=v(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&_(t,[`parameters`,`safetySetting`],u);let d=v(e,[`personGeneration`]);t!==void 0&&d!=null&&_(t,[`parameters`,`personGeneration`],d);let f=v(e,[`includeSafetyAttributes`]);t!==void 0&&f!=null&&_(t,[`parameters`,`includeSafetyAttributes`],f);let p=v(e,[`includeRaiReason`]);t!==void 0&&p!=null&&_(t,[`parameters`,`includeRaiReason`],p);let m=v(e,[`language`]);t!==void 0&&m!=null&&_(t,[`parameters`,`language`],m);let h=v(e,[`outputMimeType`]);t!==void 0&&h!=null&&_(t,[`parameters`,`outputOptions`,`mimeType`],h);let g=v(e,[`outputCompressionQuality`]);t!==void 0&&g!=null&&_(t,[`parameters`,`outputOptions`,`compressionQuality`],g);let y=v(e,[`addWatermark`]);t!==void 0&&y!=null&&_(t,[`parameters`,`addWatermark`],y);let b=v(e,[`labels`]);t!==void 0&&b!=null&&_(t,[`labels`],b);let x=v(e,[`editMode`]);t!==void 0&&x!=null&&_(t,[`parameters`,`editMode`],x);let S=v(e,[`baseSteps`]);return t!==void 0&&S!=null&&_(t,[`parameters`,`editConfig`,`baseSteps`],S),r}function xa(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`prompt`]);a!=null&&_(r,[`instances[0]`,`prompt`],a);let o=v(t,[`referenceImages`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>Po(e))),_(r,[`instances[0]`,`referenceImages`],e)}let s=v(t,[`config`]);return s!=null&&ba(s,r),r}function Sa(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ro(e))),_(n,[`generatedImages`],e)}return n}function Ca(e,t,n){let r={},i=v(e,[`taskType`]);t!==void 0&&i!=null&&_(t,[`requests[]`,`taskType`],i);let a=v(e,[`title`]);t!==void 0&&a!=null&&_(t,[`requests[]`,`title`],a);let o=v(e,[`outputDimensionality`]);if(t!==void 0&&o!=null&&_(t,[`requests[]`,`outputDimensionality`],o),v(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(v(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);if(v(e,[`documentOcr`])!==void 0)throw Error(`documentOcr parameter is not supported in Gemini API.`);if(v(e,[`audioTrackExtraction`])!==void 0)throw Error(`audioTrackExtraction parameter is not supported in Gemini API.`);return r}function wa(e,t,n){let r={},i=v(n,[`embeddingApiType`]);if(i===void 0&&(i=`PREDICT`),i===`PREDICT`){let n=v(e,[`taskType`]);t!==void 0&&n!=null&&_(t,[`instances[]`,`task_type`],n)}else if(i===`EMBED_CONTENT`){let n=v(e,[`taskType`]);t!==void 0&&n!=null&&_(t,[`embedContentConfig`,`taskType`],n)}let a=v(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=v(e,[`title`]);t!==void 0&&n!=null&&_(t,[`instances[]`,`title`],n)}else if(a===`EMBED_CONTENT`){let n=v(e,[`title`]);t!==void 0&&n!=null&&_(t,[`embedContentConfig`,`title`],n)}let o=v(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`PREDICT`){let n=v(e,[`outputDimensionality`]);t!==void 0&&n!=null&&_(t,[`parameters`,`outputDimensionality`],n)}else if(o===`EMBED_CONTENT`){let n=v(e,[`outputDimensionality`]);t!==void 0&&n!=null&&_(t,[`embedContentConfig`,`outputDimensionality`],n)}let s=v(n,[`embeddingApiType`]);if(s===void 0&&(s=`PREDICT`),s===`PREDICT`){let n=v(e,[`mimeType`]);t!==void 0&&n!=null&&_(t,[`instances[]`,`mimeType`],n)}let c=v(n,[`embeddingApiType`]);if(c===void 0&&(c=`PREDICT`),c===`PREDICT`){let n=v(e,[`autoTruncate`]);t!==void 0&&n!=null&&_(t,[`parameters`,`autoTruncate`],n)}else if(c===`EMBED_CONTENT`){let n=v(e,[`autoTruncate`]);t!==void 0&&n!=null&&_(t,[`embedContentConfig`,`autoTruncate`],n)}let l=v(n,[`embeddingApiType`]);if(l===void 0&&(l=`PREDICT`),l===`EMBED_CONTENT`){let n=v(e,[`documentOcr`]);t!==void 0&&n!=null&&_(t,[`embedContentConfig`,`documentOcr`],n)}let u=v(n,[`embeddingApiType`]);if(u===void 0&&(u=`PREDICT`),u===`EMBED_CONTENT`){let n=v(e,[`audioTrackExtraction`]);t!==void 0&&n!=null&&_(t,[`embedContentConfig`,`audioTrackExtraction`],n)}return r}function Ta(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`contents`]);if(a!=null){let t=$t(e,a);Array.isArray(t)&&(t=t.map(e=>e)),_(r,[`requests[]`,`content`],t)}let o=v(t,[`content`]);o!=null&&sa(I(o));let s=v(t,[`config`]);s!=null&&Ca(s,r);let c=v(t,[`model`]);return c!==void 0&&_(r,[`requests[]`,`model`],F(e,c)),r}function Ea(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(n,[`embeddingApiType`]);if(a===void 0&&(a=`PREDICT`),a===`PREDICT`){let n=v(t,[`contents`]);if(n!=null){let t=$t(e,n);Array.isArray(t)&&(t=t.map(e=>e)),_(r,[`instances[]`,`content`],t)}}let o=v(n,[`embeddingApiType`]);if(o===void 0&&(o=`PREDICT`),o===`EMBED_CONTENT`){let e=v(t,[`content`]);e!=null&&_(r,[`content`],ca(I(e)))}let s=v(t,[`config`]);return s!=null&&wa(s,r,n),r}function Da(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`embeddings`],e)}let a=v(e,[`metadata`]);return a!=null&&_(n,[`metadata`],a),n}function Oa(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`predictions[]`,`embeddings`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>aa(e))),_(n,[`embeddings`],e)}let a=v(e,[`metadata`]);if(a!=null&&_(n,[`metadata`],a),t&&v(t,[`embeddingApiType`])===`EMBED_CONTENT`){let t=v(e,[`embedding`]),r=v(e,[`usageMetadata`]),i=v(e,[`truncated`]);if(t){let e={};r&&r.promptTokenCount&&(e.tokenCount=r.promptTokenCount),i&&(e.truncated=i),t.statistics=e,_(n,[`embeddings`],[t])}}return n}function ka(e,t){let n={},r=v(e,[`endpoint`]);r!=null&&_(n,[`name`],r);let i=v(e,[`deployedModelId`]);return i!=null&&_(n,[`deployedModelId`],i),n}function Aa(e,t){let n={};if(v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=v(e,[`fileUri`]);r!=null&&_(n,[`fileUri`],r);let i=v(e,[`mimeType`]);return i!=null&&_(n,[`mimeType`],i),n}function ja(e,t){let n={},r=v(e,[`id`]);r!=null&&_(n,[`id`],r);let i=v(e,[`args`]);i!=null&&_(n,[`args`],i);let a=v(e,[`name`]);if(a!=null&&_(n,[`name`],a),v(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(v(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return n}function Ma(e,t){let n={},r=v(e,[`allowedFunctionNames`]);r!=null&&_(n,[`allowedFunctionNames`],r);let i=v(e,[`mode`]);if(i!=null&&_(n,[`mode`],i),v(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return n}function Na(e,t){let n={},r=v(e,[`description`]);r!=null&&_(n,[`description`],r);let i=v(e,[`name`]);i!=null&&_(n,[`name`],i);let a=v(e,[`parameters`]);a!=null&&_(n,[`parameters`],a);let o=v(e,[`parametersJsonSchema`]);o!=null&&_(n,[`parametersJsonSchema`],o);let s=v(e,[`response`]);s!=null&&_(n,[`response`],s);let c=v(e,[`responseJsonSchema`]);if(c!=null&&_(n,[`responseJsonSchema`],c),v(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Pa(e,t,n,r){let i={},a=v(t,[`systemInstruction`]);n!==void 0&&a!=null&&_(n,[`systemInstruction`],sa(I(a)));let o=v(t,[`temperature`]);o!=null&&_(i,[`temperature`],o);let s=v(t,[`topP`]);s!=null&&_(i,[`topP`],s);let c=v(t,[`topK`]);c!=null&&_(i,[`topK`],c);let l=v(t,[`candidateCount`]);l!=null&&_(i,[`candidateCount`],l);let u=v(t,[`maxOutputTokens`]);u!=null&&_(i,[`maxOutputTokens`],u);let d=v(t,[`stopSequences`]);d!=null&&_(i,[`stopSequences`],d);let f=v(t,[`responseLogprobs`]);f!=null&&_(i,[`responseLogprobs`],f);let p=v(t,[`logprobs`]);p!=null&&_(i,[`logprobs`],p);let m=v(t,[`presencePenalty`]);m!=null&&_(i,[`presencePenalty`],m);let h=v(t,[`frequencyPenalty`]);h!=null&&_(i,[`frequencyPenalty`],h);let g=v(t,[`seed`]);g!=null&&_(i,[`seed`],g);let y=v(t,[`responseMimeType`]);y!=null&&_(i,[`responseMimeType`],y);let b=v(t,[`responseSchema`]);b!=null&&_(i,[`responseSchema`],tn(b));let x=v(t,[`responseJsonSchema`]);if(x!=null&&_(i,[`responseJsonSchema`],x),v(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(v(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let S=v(t,[`safetySettings`]);if(n!==void 0&&S!=null){let e=S;Array.isArray(e)&&(e=e.map(e=>Lo(e))),_(n,[`safetySettings`],e)}let C=v(t,[`tools`]);if(n!==void 0&&C!=null){let e=on(C);Array.isArray(e)&&(e=e.map(e=>Go(an(e)))),_(n,[`tools`],e)}let w=v(t,[`toolConfig`]);if(n!==void 0&&w!=null&&_(n,[`toolConfig`],Uo(w)),v(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let T=v(t,[`cachedContent`]);n!==void 0&&T!=null&&_(n,[`cachedContent`],z(e,T));let E=v(t,[`responseModalities`]);E!=null&&_(i,[`responseModalities`],E);let D=v(t,[`mediaResolution`]);D!=null&&_(i,[`mediaResolution`],D);let O=v(t,[`speechConfig`]);if(O!=null&&_(i,[`speechConfig`],nn(O)),v(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let k=v(t,[`thinkingConfig`]);k!=null&&_(i,[`thinkingConfig`],k);let A=v(t,[`imageConfig`]);A!=null&&_(i,[`imageConfig`],po(A));let j=v(t,[`enableEnhancedCivicAnswers`]);if(j!=null&&_(i,[`enableEnhancedCivicAnswers`],j),v(t,[`modelArmorConfig`])!==void 0)throw Error(`modelArmorConfig parameter is not supported in Gemini API.`);let M=v(t,[`serviceTier`]);return n!==void 0&&M!=null&&_(n,[`serviceTier`],M),i}function Fa(e,t,n,r){let i={},a=v(t,[`systemInstruction`]);n!==void 0&&a!=null&&_(n,[`systemInstruction`],ca(I(a)));let o=v(t,[`temperature`]);o!=null&&_(i,[`temperature`],o);let s=v(t,[`topP`]);s!=null&&_(i,[`topP`],s);let c=v(t,[`topK`]);c!=null&&_(i,[`topK`],c);let l=v(t,[`candidateCount`]);l!=null&&_(i,[`candidateCount`],l);let u=v(t,[`maxOutputTokens`]);u!=null&&_(i,[`maxOutputTokens`],u);let d=v(t,[`stopSequences`]);d!=null&&_(i,[`stopSequences`],d);let f=v(t,[`responseLogprobs`]);f!=null&&_(i,[`responseLogprobs`],f);let p=v(t,[`logprobs`]);p!=null&&_(i,[`logprobs`],p);let m=v(t,[`presencePenalty`]);m!=null&&_(i,[`presencePenalty`],m);let h=v(t,[`frequencyPenalty`]);h!=null&&_(i,[`frequencyPenalty`],h);let g=v(t,[`seed`]);g!=null&&_(i,[`seed`],g);let y=v(t,[`responseMimeType`]);y!=null&&_(i,[`responseMimeType`],y);let b=v(t,[`responseSchema`]);b!=null&&_(i,[`responseSchema`],tn(b));let x=v(t,[`responseJsonSchema`]);x!=null&&_(i,[`responseJsonSchema`],x);let S=v(t,[`routingConfig`]);S!=null&&_(i,[`routingConfig`],S);let C=v(t,[`modelSelectionConfig`]);C!=null&&_(i,[`modelConfig`],C);let w=v(t,[`safetySettings`]);if(n!==void 0&&w!=null){let e=w;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`safetySettings`],e)}let T=v(t,[`tools`]);if(n!==void 0&&T!=null){let e=on(T);Array.isArray(e)&&(e=e.map(e=>Ko(an(e)))),_(n,[`tools`],e)}let E=v(t,[`toolConfig`]);n!==void 0&&E!=null&&_(n,[`toolConfig`],Wo(E));let D=v(t,[`labels`]);n!==void 0&&D!=null&&_(n,[`labels`],D);let O=v(t,[`cachedContent`]);n!==void 0&&O!=null&&_(n,[`cachedContent`],z(e,O));let k=v(t,[`responseModalities`]);k!=null&&_(i,[`responseModalities`],k);let A=v(t,[`mediaResolution`]);A!=null&&_(i,[`mediaResolution`],A);let j=v(t,[`speechConfig`]);j!=null&&_(i,[`speechConfig`],nn(j));let M=v(t,[`audioTimestamp`]);M!=null&&_(i,[`audioTimestamp`],M);let ee=v(t,[`thinkingConfig`]);ee!=null&&_(i,[`thinkingConfig`],ee);let te=v(t,[`imageConfig`]);if(te!=null&&_(i,[`imageConfig`],mo(te)),v(t,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let ne=v(t,[`modelArmorConfig`]);n!==void 0&&ne!=null&&_(n,[`modelArmorConfig`],ne);let re=v(t,[`serviceTier`]);return n!==void 0&&re!=null&&_(n,[`serviceTier`],re),i}function Ia(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`contents`]);if(a!=null){let e=L(a);Array.isArray(e)&&(e=e.map(e=>sa(e))),_(r,[`contents`],e)}let o=v(t,[`config`]);return o!=null&&_(r,[`generationConfig`],Pa(e,o,r)),r}function La(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`contents`]);if(a!=null){let e=L(a);Array.isArray(e)&&(e=e.map(e=>ca(e))),_(r,[`contents`],e)}let o=v(t,[`config`]);return o!=null&&_(r,[`generationConfig`],Fa(e,o,r)),r}function Ra(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ta(e))),_(n,[`candidates`],e)}let a=v(e,[`modelVersion`]);a!=null&&_(n,[`modelVersion`],a);let o=v(e,[`promptFeedback`]);o!=null&&_(n,[`promptFeedback`],o);let s=v(e,[`responseId`]);s!=null&&_(n,[`responseId`],s);let c=v(e,[`usageMetadata`]);c!=null&&_(n,[`usageMetadata`],c);let l=v(e,[`modelStatus`]);return l!=null&&_(n,[`modelStatus`],l),n}function za(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`candidates`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`candidates`],e)}let a=v(e,[`createTime`]);a!=null&&_(n,[`createTime`],a);let o=v(e,[`modelVersion`]);o!=null&&_(n,[`modelVersion`],o);let s=v(e,[`promptFeedback`]);s!=null&&_(n,[`promptFeedback`],s);let c=v(e,[`responseId`]);c!=null&&_(n,[`responseId`],c);let l=v(e,[`usageMetadata`]);return l!=null&&_(n,[`usageMetadata`],l),n}function Ba(e,t,n){let r={};if(v(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(v(e,[`negativePrompt`])!==void 0)throw Error(`negativePrompt parameter is not supported in Gemini API.`);let i=v(e,[`numberOfImages`]);t!==void 0&&i!=null&&_(t,[`parameters`,`sampleCount`],i);let a=v(e,[`aspectRatio`]);t!==void 0&&a!=null&&_(t,[`parameters`,`aspectRatio`],a);let o=v(e,[`guidanceScale`]);if(t!==void 0&&o!=null&&_(t,[`parameters`,`guidanceScale`],o),v(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let s=v(e,[`safetyFilterLevel`]);t!==void 0&&s!=null&&_(t,[`parameters`,`safetySetting`],s);let c=v(e,[`personGeneration`]);t!==void 0&&c!=null&&_(t,[`parameters`,`personGeneration`],c);let l=v(e,[`includeSafetyAttributes`]);t!==void 0&&l!=null&&_(t,[`parameters`,`includeSafetyAttributes`],l);let u=v(e,[`includeRaiReason`]);t!==void 0&&u!=null&&_(t,[`parameters`,`includeRaiReason`],u);let d=v(e,[`language`]);t!==void 0&&d!=null&&_(t,[`parameters`,`language`],d);let f=v(e,[`outputMimeType`]);t!==void 0&&f!=null&&_(t,[`parameters`,`outputOptions`,`mimeType`],f);let p=v(e,[`outputCompressionQuality`]);if(t!==void 0&&p!=null&&_(t,[`parameters`,`outputOptions`,`compressionQuality`],p),v(e,[`addWatermark`])!==void 0)throw Error(`addWatermark parameter is not supported in Gemini API.`);if(v(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let m=v(e,[`imageSize`]);if(t!==void 0&&m!=null&&_(t,[`parameters`,`sampleImageSize`],m),v(e,[`enhancePrompt`])!==void 0)throw Error(`enhancePrompt parameter is not supported in Gemini API.`);return r}function Va(e,t,n){let r={},i=v(e,[`outputGcsUri`]);t!==void 0&&i!=null&&_(t,[`parameters`,`storageUri`],i);let a=v(e,[`negativePrompt`]);t!==void 0&&a!=null&&_(t,[`parameters`,`negativePrompt`],a);let o=v(e,[`numberOfImages`]);t!==void 0&&o!=null&&_(t,[`parameters`,`sampleCount`],o);let s=v(e,[`aspectRatio`]);t!==void 0&&s!=null&&_(t,[`parameters`,`aspectRatio`],s);let c=v(e,[`guidanceScale`]);t!==void 0&&c!=null&&_(t,[`parameters`,`guidanceScale`],c);let l=v(e,[`seed`]);t!==void 0&&l!=null&&_(t,[`parameters`,`seed`],l);let u=v(e,[`safetyFilterLevel`]);t!==void 0&&u!=null&&_(t,[`parameters`,`safetySetting`],u);let d=v(e,[`personGeneration`]);t!==void 0&&d!=null&&_(t,[`parameters`,`personGeneration`],d);let f=v(e,[`includeSafetyAttributes`]);t!==void 0&&f!=null&&_(t,[`parameters`,`includeSafetyAttributes`],f);let p=v(e,[`includeRaiReason`]);t!==void 0&&p!=null&&_(t,[`parameters`,`includeRaiReason`],p);let m=v(e,[`language`]);t!==void 0&&m!=null&&_(t,[`parameters`,`language`],m);let h=v(e,[`outputMimeType`]);t!==void 0&&h!=null&&_(t,[`parameters`,`outputOptions`,`mimeType`],h);let g=v(e,[`outputCompressionQuality`]);t!==void 0&&g!=null&&_(t,[`parameters`,`outputOptions`,`compressionQuality`],g);let y=v(e,[`addWatermark`]);t!==void 0&&y!=null&&_(t,[`parameters`,`addWatermark`],y);let b=v(e,[`labels`]);t!==void 0&&b!=null&&_(t,[`labels`],b);let x=v(e,[`imageSize`]);t!==void 0&&x!=null&&_(t,[`parameters`,`sampleImageSize`],x);let S=v(e,[`enhancePrompt`]);return t!==void 0&&S!=null&&_(t,[`parameters`,`enhancePrompt`],S),r}function Ha(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`prompt`]);a!=null&&_(r,[`instances[0]`,`prompt`],a);let o=v(t,[`config`]);return o!=null&&Ba(o,r),r}function Ua(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`prompt`]);a!=null&&_(r,[`instances[0]`,`prompt`],a);let o=v(t,[`config`]);return o!=null&&Va(o,r),r}function Wa(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>no(e))),_(n,[`generatedImages`],e)}let a=v(e,[`positivePromptSafetyAttributes`]);return a!=null&&_(n,[`positivePromptSafetyAttributes`],Fo(a)),n}function Ga(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ro(e))),_(n,[`generatedImages`],e)}let a=v(e,[`positivePromptSafetyAttributes`]);return a!=null&&_(n,[`positivePromptSafetyAttributes`],Io(a)),n}function Ka(e,t,n){let r={},i=v(e,[`numberOfVideos`]);if(t!==void 0&&i!=null&&_(t,[`parameters`,`sampleCount`],i),v(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(v(e,[`fps`])!==void 0)throw Error(`fps parameter is not supported in Gemini API.`);let a=v(e,[`durationSeconds`]);if(t!==void 0&&a!=null&&_(t,[`parameters`,`durationSeconds`],a),v(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let o=v(e,[`aspectRatio`]);t!==void 0&&o!=null&&_(t,[`parameters`,`aspectRatio`],o);let s=v(e,[`resolution`]);t!==void 0&&s!=null&&_(t,[`parameters`,`resolution`],s);let c=v(e,[`personGeneration`]);if(t!==void 0&&c!=null&&_(t,[`parameters`,`personGeneration`],c),v(e,[`pubsubTopic`])!==void 0)throw Error(`pubsubTopic parameter is not supported in Gemini API.`);let l=v(e,[`negativePrompt`]);t!==void 0&&l!=null&&_(t,[`parameters`,`negativePrompt`],l);let u=v(e,[`enhancePrompt`]);if(t!==void 0&&u!=null&&_(t,[`parameters`,`enhancePrompt`],u),v(e,[`generateAudio`])!==void 0)throw Error(`generateAudio parameter is not supported in Gemini API.`);let d=v(e,[`lastFrame`]);t!==void 0&&d!=null&&_(t,[`instances[0]`,`lastFrame`],_o(d));let f=v(e,[`referenceImages`]);if(t!==void 0&&f!=null){let e=f;Array.isArray(e)&&(e=e.map(e=>as(e))),_(t,[`instances[0]`,`referenceImages`],e)}if(v(e,[`mask`])!==void 0)throw Error(`mask parameter is not supported in Gemini API.`);if(v(e,[`compressionQuality`])!==void 0)throw Error(`compressionQuality parameter is not supported in Gemini API.`);if(v(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let p=v(e,[`webhookConfig`]);if(t!==void 0&&p!=null&&_(t,[`webhookConfig`],p),v(e,[`resizeMode`])!==void 0)throw Error(`resizeMode parameter is not supported in Gemini API.`);return r}function qa(e,t,n){let r={},i=v(e,[`numberOfVideos`]);t!==void 0&&i!=null&&_(t,[`parameters`,`sampleCount`],i);let a=v(e,[`outputGcsUri`]);t!==void 0&&a!=null&&_(t,[`parameters`,`storageUri`],a);let o=v(e,[`fps`]);t!==void 0&&o!=null&&_(t,[`parameters`,`fps`],o);let s=v(e,[`durationSeconds`]);t!==void 0&&s!=null&&_(t,[`parameters`,`durationSeconds`],s);let c=v(e,[`seed`]);t!==void 0&&c!=null&&_(t,[`parameters`,`seed`],c);let l=v(e,[`aspectRatio`]);t!==void 0&&l!=null&&_(t,[`parameters`,`aspectRatio`],l);let u=v(e,[`resolution`]);t!==void 0&&u!=null&&_(t,[`parameters`,`resolution`],u);let d=v(e,[`personGeneration`]);t!==void 0&&d!=null&&_(t,[`parameters`,`personGeneration`],d);let f=v(e,[`pubsubTopic`]);t!==void 0&&f!=null&&_(t,[`parameters`,`pubsubTopic`],f);let p=v(e,[`negativePrompt`]);t!==void 0&&p!=null&&_(t,[`parameters`,`negativePrompt`],p);let m=v(e,[`enhancePrompt`]);t!==void 0&&m!=null&&_(t,[`parameters`,`enhancePrompt`],m);let h=v(e,[`generateAudio`]);t!==void 0&&h!=null&&_(t,[`parameters`,`generateAudio`],h);let g=v(e,[`lastFrame`]);t!==void 0&&g!=null&&_(t,[`instances[0]`,`lastFrame`],q(g));let y=v(e,[`referenceImages`]);if(t!==void 0&&y!=null){let e=y;Array.isArray(e)&&(e=e.map(e=>os(e))),_(t,[`instances[0]`,`referenceImages`],e)}let b=v(e,[`mask`]);t!==void 0&&b!=null&&_(t,[`instances[0]`,`mask`],is(b));let x=v(e,[`compressionQuality`]);t!==void 0&&x!=null&&_(t,[`parameters`,`compressionQuality`],x);let S=v(e,[`labels`]);if(t!==void 0&&S!=null&&_(t,[`labels`],S),v(e,[`webhookConfig`])!==void 0)throw Error(`webhookConfig parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let C=v(e,[`resizeMode`]);return t!==void 0&&C!=null&&_(t,[`parameters`,`resizeMode`],C),r}function Ja(e,t){let n={},r=v(e,[`name`]);r!=null&&_(n,[`name`],r);let i=v(e,[`metadata`]);i!=null&&_(n,[`metadata`],i);let a=v(e,[`done`]);a!=null&&_(n,[`done`],a);let o=v(e,[`error`]);o!=null&&_(n,[`error`],o);let s=v(e,[`response`,`generateVideoResponse`]);return s!=null&&_(n,[`response`],Qa(s)),n}function Ya(e,t){let n={},r=v(e,[`name`]);r!=null&&_(n,[`name`],r);let i=v(e,[`metadata`]);i!=null&&_(n,[`metadata`],i);let a=v(e,[`done`]);a!=null&&_(n,[`done`],a);let o=v(e,[`error`]);o!=null&&_(n,[`error`],o);let s=v(e,[`response`]);return s!=null&&_(n,[`response`],$a(s)),n}function Xa(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`prompt`]);a!=null&&_(r,[`instances[0]`,`prompt`],a);let o=v(t,[`image`]);o!=null&&_(r,[`instances[0]`,`image`],_o(o));let s=v(t,[`video`]);s!=null&&_(r,[`instances[0]`,`video`],ss(s));let c=v(t,[`source`]);c!=null&&eo(c,r);let l=v(t,[`config`]);return l!=null&&Ka(l,r),r}function Za(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`prompt`]);a!=null&&_(r,[`instances[0]`,`prompt`],a);let o=v(t,[`image`]);o!=null&&_(r,[`instances[0]`,`image`],q(o));let s=v(t,[`video`]);s!=null&&_(r,[`instances[0]`,`video`],cs(s));let c=v(t,[`source`]);c!=null&&to(c,r);let l=v(t,[`config`]);return l!=null&&qa(l,r),r}function Qa(e,t){let n={},r=v(e,[`generatedSamples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>ao(e))),_(n,[`generatedVideos`],e)}let i=v(e,[`raiMediaFilteredCount`]);i!=null&&_(n,[`raiMediaFilteredCount`],i);let a=v(e,[`raiMediaFilteredReasons`]);return a!=null&&_(n,[`raiMediaFilteredReasons`],a),n}function $a(e,t){let n={},r=v(e,[`videos`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>oo(e))),_(n,[`generatedVideos`],e)}let i=v(e,[`raiMediaFilteredCount`]);i!=null&&_(n,[`raiMediaFilteredCount`],i);let a=v(e,[`raiMediaFilteredReasons`]);return a!=null&&_(n,[`raiMediaFilteredReasons`],a),n}function eo(e,t,n){let r={},i=v(e,[`prompt`]);t!==void 0&&i!=null&&_(t,[`instances[0]`,`prompt`],i);let a=v(e,[`image`]);t!==void 0&&a!=null&&_(t,[`instances[0]`,`image`],_o(a));let o=v(e,[`video`]);return t!==void 0&&o!=null&&_(t,[`instances[0]`,`video`],ss(o)),r}function to(e,t,n){let r={},i=v(e,[`prompt`]);t!==void 0&&i!=null&&_(t,[`instances[0]`,`prompt`],i);let a=v(e,[`image`]);t!==void 0&&a!=null&&_(t,[`instances[0]`,`image`],q(a));let o=v(e,[`video`]);return t!==void 0&&o!=null&&_(t,[`instances[0]`,`video`],cs(o)),r}function no(e,t){let n={},r=v(e,[`_self`]);r!=null&&_(n,[`image`],ho(r));let i=v(e,[`raiFilteredReason`]);i!=null&&_(n,[`raiFilteredReason`],i);let a=v(e,[`_self`]);return a!=null&&_(n,[`safetyAttributes`],Fo(a)),n}function ro(e,t){let n={},r=v(e,[`_self`]);r!=null&&_(n,[`image`],go(r));let i=v(e,[`raiFilteredReason`]);i!=null&&_(n,[`raiFilteredReason`],i);let a=v(e,[`_self`]);a!=null&&_(n,[`safetyAttributes`],Io(a));let o=v(e,[`prompt`]);return o!=null&&_(n,[`enhancedPrompt`],o),n}function io(e,t){let n={},r=v(e,[`_self`]);r!=null&&_(n,[`mask`],go(r));let i=v(e,[`labels`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`labels`],e)}return n}function ao(e,t){let n={},r=v(e,[`video`]);return r!=null&&_(n,[`video`],ns(r)),n}function oo(e,t){let n={},r=v(e,[`_self`]);return r!=null&&_(n,[`video`],rs(r)),n}function so(e,t){let n={},r=v(e,[`modelSelectionConfig`]);r!=null&&_(n,[`modelConfig`],r);let i=v(e,[`responseJsonSchema`]);i!=null&&_(n,[`responseJsonSchema`],i);let a=v(e,[`audioTimestamp`]);a!=null&&_(n,[`audioTimestamp`],a);let o=v(e,[`candidateCount`]);o!=null&&_(n,[`candidateCount`],o);let s=v(e,[`enableAffectiveDialog`]);s!=null&&_(n,[`enableAffectiveDialog`],s);let c=v(e,[`frequencyPenalty`]);c!=null&&_(n,[`frequencyPenalty`],c);let l=v(e,[`logprobs`]);l!=null&&_(n,[`logprobs`],l);let u=v(e,[`maxOutputTokens`]);u!=null&&_(n,[`maxOutputTokens`],u);let d=v(e,[`mediaResolution`]);d!=null&&_(n,[`mediaResolution`],d);let f=v(e,[`presencePenalty`]);f!=null&&_(n,[`presencePenalty`],f);let p=v(e,[`responseLogprobs`]);p!=null&&_(n,[`responseLogprobs`],p);let m=v(e,[`responseMimeType`]);m!=null&&_(n,[`responseMimeType`],m);let h=v(e,[`responseModalities`]);h!=null&&_(n,[`responseModalities`],h);let g=v(e,[`responseSchema`]);g!=null&&_(n,[`responseSchema`],g);let y=v(e,[`routingConfig`]);y!=null&&_(n,[`routingConfig`],y);let b=v(e,[`seed`]);b!=null&&_(n,[`seed`],b);let x=v(e,[`speechConfig`]);x!=null&&_(n,[`speechConfig`],x);let S=v(e,[`stopSequences`]);S!=null&&_(n,[`stopSequences`],S);let C=v(e,[`temperature`]);C!=null&&_(n,[`temperature`],C);let w=v(e,[`thinkingConfig`]);w!=null&&_(n,[`thinkingConfig`],w);let T=v(e,[`topK`]);T!=null&&_(n,[`topK`],T);let E=v(e,[`topP`]);if(E!=null&&_(n,[`topP`],E),v(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function co(e,t,n){let r={},i=v(t,[`model`]);return i!=null&&_(r,[`_url`,`name`],F(e,i)),r}function lo(e,t,n){let r={},i=v(t,[`model`]);return i!=null&&_(r,[`_url`,`name`],F(e,i)),r}function uo(e,t){let n={},r=v(e,[`authConfig`]);r!=null&&_(n,[`authConfig`],$i(r));let i=v(e,[`enableWidget`]);return i!=null&&_(n,[`enableWidget`],i),n}function fo(e,t){let n={},r=v(e,[`searchTypes`]);if(r!=null&&_(n,[`searchTypes`],r),v(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(v(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let i=v(e,[`timeRangeFilter`]);return i!=null&&_(n,[`timeRangeFilter`],i),n}function po(e,t){let n={},r=v(e,[`aspectRatio`]);r!=null&&_(n,[`aspectRatio`],r);let i=v(e,[`imageSize`]);if(i!=null&&_(n,[`imageSize`],i),v(e,[`personGeneration`])!==void 0)throw Error(`personGeneration parameter is not supported in Gemini API.`);if(v(e,[`prominentPeople`])!==void 0)throw Error(`prominentPeople parameter is not supported in Gemini API.`);if(v(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(v(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);if(v(e,[`imageOutputOptions`])!==void 0)throw Error(`imageOutputOptions parameter is not supported in Gemini API.`);return n}function mo(e,t){let n={},r=v(e,[`aspectRatio`]);r!=null&&_(n,[`aspectRatio`],r);let i=v(e,[`imageSize`]);i!=null&&_(n,[`imageSize`],i);let a=v(e,[`personGeneration`]);a!=null&&_(n,[`personGeneration`],a);let o=v(e,[`prominentPeople`]);o!=null&&_(n,[`prominentPeople`],o);let s=v(e,[`outputMimeType`]);s!=null&&_(n,[`imageOutputOptions`,`mimeType`],s);let c=v(e,[`outputCompressionQuality`]);c!=null&&_(n,[`imageOutputOptions`,`compressionQuality`],c);let l=v(e,[`imageOutputOptions`]);return l!=null&&_(n,[`imageOutputOptions`],l),n}function ho(e,t){let n={},r=v(e,[`bytesBase64Encoded`]);r!=null&&_(n,[`imageBytes`],B(r));let i=v(e,[`mimeType`]);return i!=null&&_(n,[`mimeType`],i),n}function go(e,t){let n={},r=v(e,[`gcsUri`]);r!=null&&_(n,[`gcsUri`],r);let i=v(e,[`bytesBase64Encoded`]);i!=null&&_(n,[`imageBytes`],B(i));let a=v(e,[`mimeType`]);return a!=null&&_(n,[`mimeType`],a),n}function _o(e,t){let n={};if(v(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);let r=v(e,[`imageBytes`]);r!=null&&_(n,[`bytesBase64Encoded`],B(r));let i=v(e,[`mimeType`]);return i!=null&&_(n,[`mimeType`],i),n}function q(e,t){let n={},r=v(e,[`gcsUri`]);r!=null&&_(n,[`gcsUri`],r);let i=v(e,[`imageBytes`]);i!=null&&_(n,[`bytesBase64Encoded`],B(i));let a=v(e,[`mimeType`]);return a!=null&&_(n,[`mimeType`],a),n}function vo(e,t,n,r){let i={},a=v(t,[`pageSize`]);n!==void 0&&a!=null&&_(n,[`_query`,`pageSize`],a);let o=v(t,[`pageToken`]);n!==void 0&&o!=null&&_(n,[`_query`,`pageToken`],o);let s=v(t,[`filter`]);n!==void 0&&s!=null&&_(n,[`_query`,`filter`],s);let c=v(t,[`queryBase`]);return n!==void 0&&c!=null&&_(n,[`_url`,`models_url`],pn(e,c)),i}function yo(e,t,n,r){let i={},a=v(t,[`pageSize`]);n!==void 0&&a!=null&&_(n,[`_query`,`pageSize`],a);let o=v(t,[`pageToken`]);n!==void 0&&o!=null&&_(n,[`_query`,`pageToken`],o);let s=v(t,[`filter`]);n!==void 0&&s!=null&&_(n,[`_query`,`filter`],s);let c=v(t,[`queryBase`]);return n!==void 0&&c!=null&&_(n,[`_url`,`models_url`],pn(e,c)),i}function bo(e,t,n){let r={},i=v(t,[`config`]);return i!=null&&vo(e,i,r),r}function xo(e,t,n){let r={},i=v(t,[`config`]);return i!=null&&yo(e,i,r),r}function So(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`nextPageToken`]);i!=null&&_(n,[`nextPageToken`],i);let a=v(e,[`_self`]);if(a!=null){let e=mn(a);Array.isArray(e)&&(e=e.map(e=>To(e))),_(n,[`models`],e)}return n}function Co(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`nextPageToken`]);i!=null&&_(n,[`nextPageToken`],i);let a=v(e,[`_self`]);if(a!=null){let e=mn(a);Array.isArray(e)&&(e=e.map(e=>Eo(e))),_(n,[`models`],e)}return n}function wo(e,t){let n={},r=v(e,[`maskMode`]);r!=null&&_(n,[`maskMode`],r);let i=v(e,[`segmentationClasses`]);i!=null&&_(n,[`maskClasses`],i);let a=v(e,[`maskDilation`]);return a!=null&&_(n,[`dilation`],a),n}function To(e,t){let n={},r=v(e,[`name`]);r!=null&&_(n,[`name`],r);let i=v(e,[`displayName`]);i!=null&&_(n,[`displayName`],i);let a=v(e,[`description`]);a!=null&&_(n,[`description`],a);let o=v(e,[`version`]);o!=null&&_(n,[`version`],o);let s=v(e,[`_self`]);s!=null&&_(n,[`tunedModelInfo`],qo(s));let c=v(e,[`inputTokenLimit`]);c!=null&&_(n,[`inputTokenLimit`],c);let l=v(e,[`outputTokenLimit`]);l!=null&&_(n,[`outputTokenLimit`],l);let u=v(e,[`supportedGenerationMethods`]);u!=null&&_(n,[`supportedActions`],u);let d=v(e,[`temperature`]);d!=null&&_(n,[`temperature`],d);let f=v(e,[`maxTemperature`]);f!=null&&_(n,[`maxTemperature`],f);let p=v(e,[`topP`]);p!=null&&_(n,[`topP`],p);let m=v(e,[`topK`]);m!=null&&_(n,[`topK`],m);let h=v(e,[`thinking`]);return h!=null&&_(n,[`thinking`],h),n}function Eo(e,t){let n={},r=v(e,[`name`]);r!=null&&_(n,[`name`],r);let i=v(e,[`displayName`]);i!=null&&_(n,[`displayName`],i);let a=v(e,[`description`]);a!=null&&_(n,[`description`],a);let o=v(e,[`versionId`]);o!=null&&_(n,[`version`],o);let s=v(e,[`deployedModels`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>ka(e))),_(n,[`endpoints`],e)}let c=v(e,[`labels`]);c!=null&&_(n,[`labels`],c);let l=v(e,[`_self`]);l!=null&&_(n,[`tunedModelInfo`],Jo(l));let u=v(e,[`defaultCheckpointId`]);u!=null&&_(n,[`defaultCheckpointId`],u);let d=v(e,[`checkpoints`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`checkpoints`],e)}return n}function Do(e,t){let n={},r=v(e,[`mediaResolution`]);r!=null&&_(n,[`mediaResolution`],r);let i=v(e,[`codeExecutionResult`]);i!=null&&_(n,[`codeExecutionResult`],i);let a=v(e,[`executableCode`]);a!=null&&_(n,[`executableCode`],a);let o=v(e,[`fileData`]);o!=null&&_(n,[`fileData`],Aa(o));let s=v(e,[`functionCall`]);s!=null&&_(n,[`functionCall`],ja(s));let c=v(e,[`functionResponse`]);c!=null&&_(n,[`functionResponse`],c);let l=v(e,[`inlineData`]);l!=null&&_(n,[`inlineData`],ea(l));let u=v(e,[`text`]);u!=null&&_(n,[`text`],u);let d=v(e,[`thought`]);d!=null&&_(n,[`thought`],d);let f=v(e,[`thoughtSignature`]);f!=null&&_(n,[`thoughtSignature`],f);let p=v(e,[`videoMetadata`]);p!=null&&_(n,[`videoMetadata`],p);let m=v(e,[`toolCall`]);m!=null&&_(n,[`toolCall`],m);let h=v(e,[`toolResponse`]);h!=null&&_(n,[`toolResponse`],h);let g=v(e,[`partMetadata`]);return g!=null&&_(n,[`partMetadata`],g),n}function Oo(e,t){let n={},r=v(e,[`mediaResolution`]);r!=null&&_(n,[`mediaResolution`],r);let i=v(e,[`codeExecutionResult`]);i!=null&&_(n,[`codeExecutionResult`],i);let a=v(e,[`executableCode`]);a!=null&&_(n,[`executableCode`],a);let o=v(e,[`fileData`]);o!=null&&_(n,[`fileData`],o);let s=v(e,[`functionCall`]);s!=null&&_(n,[`functionCall`],s);let c=v(e,[`functionResponse`]);c!=null&&_(n,[`functionResponse`],c);let l=v(e,[`inlineData`]);l!=null&&_(n,[`inlineData`],l);let u=v(e,[`text`]);u!=null&&_(n,[`text`],u);let d=v(e,[`thought`]);d!=null&&_(n,[`thought`],d);let f=v(e,[`thoughtSignature`]);f!=null&&_(n,[`thoughtSignature`],f);let p=v(e,[`videoMetadata`]);if(p!=null&&_(n,[`videoMetadata`],p),v(e,[`toolCall`])!==void 0)throw Error(`toolCall parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`toolResponse`])!==void 0)throw Error(`toolResponse parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);if(v(e,[`partMetadata`])!==void 0)throw Error(`partMetadata parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function ko(e,t){let n={},r=v(e,[`productImage`]);return r!=null&&_(n,[`image`],q(r)),n}function Ao(e,t,n){let r={},i=v(e,[`numberOfImages`]);t!==void 0&&i!=null&&_(t,[`parameters`,`sampleCount`],i);let a=v(e,[`baseSteps`]);t!==void 0&&a!=null&&_(t,[`parameters`,`baseSteps`],a);let o=v(e,[`outputGcsUri`]);t!==void 0&&o!=null&&_(t,[`parameters`,`storageUri`],o);let s=v(e,[`seed`]);t!==void 0&&s!=null&&_(t,[`parameters`,`seed`],s);let c=v(e,[`safetyFilterLevel`]);t!==void 0&&c!=null&&_(t,[`parameters`,`safetySetting`],c);let l=v(e,[`personGeneration`]);t!==void 0&&l!=null&&_(t,[`parameters`,`personGeneration`],l);let u=v(e,[`addWatermark`]);t!==void 0&&u!=null&&_(t,[`parameters`,`addWatermark`],u);let d=v(e,[`outputMimeType`]);t!==void 0&&d!=null&&_(t,[`parameters`,`outputOptions`,`mimeType`],d);let f=v(e,[`outputCompressionQuality`]);t!==void 0&&f!=null&&_(t,[`parameters`,`outputOptions`,`compressionQuality`],f);let p=v(e,[`enhancePrompt`]);t!==void 0&&p!=null&&_(t,[`parameters`,`enhancePrompt`],p);let m=v(e,[`labels`]);return t!==void 0&&m!=null&&_(t,[`labels`],m),r}function jo(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`source`]);a!=null&&No(a,r);let o=v(t,[`config`]);return o!=null&&Ao(o,r),r}function Mo(e,t){let n={},r=v(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>ro(e))),_(n,[`generatedImages`],e)}return n}function No(e,t,n){let r={},i=v(e,[`prompt`]);t!==void 0&&i!=null&&_(t,[`instances[0]`,`prompt`],i);let a=v(e,[`personImage`]);t!==void 0&&a!=null&&_(t,[`instances[0]`,`personImage`,`image`],q(a));let o=v(e,[`productImages`]);if(t!==void 0&&o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>ko(e))),_(t,[`instances[0]`,`productImages`],e)}return r}function Po(e,t){let n={},r=v(e,[`referenceImage`]);r!=null&&_(n,[`referenceImage`],q(r));let i=v(e,[`referenceId`]);i!=null&&_(n,[`referenceId`],i);let a=v(e,[`referenceType`]);a!=null&&_(n,[`referenceType`],a);let o=v(e,[`maskImageConfig`]);o!=null&&_(n,[`maskImageConfig`],wo(o));let s=v(e,[`controlImageConfig`]);s!=null&&_(n,[`controlImageConfig`],la(s));let c=v(e,[`styleImageConfig`]);c!=null&&_(n,[`styleImageConfig`],c);let l=v(e,[`subjectImageConfig`]);return l!=null&&_(n,[`subjectImageConfig`],l),n}function Fo(e,t){let n={},r=v(e,[`safetyAttributes`,`categories`]);r!=null&&_(n,[`categories`],r);let i=v(e,[`safetyAttributes`,`scores`]);i!=null&&_(n,[`scores`],i);let a=v(e,[`contentType`]);return a!=null&&_(n,[`contentType`],a),n}function Io(e,t){let n={},r=v(e,[`safetyAttributes`,`categories`]);r!=null&&_(n,[`categories`],r);let i=v(e,[`safetyAttributes`,`scores`]);i!=null&&_(n,[`scores`],i);let a=v(e,[`contentType`]);return a!=null&&_(n,[`contentType`],a),n}function Lo(e,t){let n={},r=v(e,[`category`]);if(r!=null&&_(n,[`category`],r),v(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let i=v(e,[`threshold`]);return i!=null&&_(n,[`threshold`],i),n}function Ro(e,t){let n={},r=v(e,[`image`]);return r!=null&&_(n,[`image`],q(r)),n}function zo(e,t,n){let r={},i=v(e,[`mode`]);t!==void 0&&i!=null&&_(t,[`parameters`,`mode`],i);let a=v(e,[`maxPredictions`]);t!==void 0&&a!=null&&_(t,[`parameters`,`maxPredictions`],a);let o=v(e,[`confidenceThreshold`]);t!==void 0&&o!=null&&_(t,[`parameters`,`confidenceThreshold`],o);let s=v(e,[`maskDilation`]);t!==void 0&&s!=null&&_(t,[`parameters`,`maskDilation`],s);let c=v(e,[`binaryColorThreshold`]);t!==void 0&&c!=null&&_(t,[`parameters`,`binaryColorThreshold`],c);let l=v(e,[`labels`]);return t!==void 0&&l!=null&&_(t,[`labels`],l),r}function Bo(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`source`]);a!=null&&Ho(a,r);let o=v(t,[`config`]);return o!=null&&zo(o,r),r}function Vo(e,t){let n={},r=v(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>io(e))),_(n,[`generatedMasks`],e)}return n}function Ho(e,t,n){let r={},i=v(e,[`prompt`]);t!==void 0&&i!=null&&_(t,[`instances[0]`,`prompt`],i);let a=v(e,[`image`]);t!==void 0&&a!=null&&_(t,[`instances[0]`,`image`],q(a));let o=v(e,[`scribbleImage`]);return t!==void 0&&o!=null&&_(t,[`instances[0]`,`scribble`],Ro(o)),r}function Uo(e,t){let n={},r=v(e,[`retrievalConfig`]);r!=null&&_(n,[`retrievalConfig`],r);let i=v(e,[`functionCallingConfig`]);i!=null&&_(n,[`functionCallingConfig`],Ma(i));let a=v(e,[`includeServerSideToolInvocations`]);return a!=null&&_(n,[`includeServerSideToolInvocations`],a),n}function Wo(e,t){let n={},r=v(e,[`retrievalConfig`]);r!=null&&_(n,[`retrievalConfig`],r);let i=v(e,[`functionCallingConfig`]);if(i!=null&&_(n,[`functionCallingConfig`],i),v(e,[`includeServerSideToolInvocations`])!==void 0)throw Error(`includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function Go(e,t){let n={};if(v(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=v(e,[`computerUse`]);r!=null&&_(n,[`computerUse`],r);let i=v(e,[`fileSearch`]);i!=null&&_(n,[`fileSearch`],i);let a=v(e,[`googleSearch`]);a!=null&&_(n,[`googleSearch`],fo(a));let o=v(e,[`googleMaps`]);o!=null&&_(n,[`googleMaps`],uo(o));let s=v(e,[`codeExecution`]);if(s!=null&&_(n,[`codeExecution`],s),v(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let c=v(e,[`functionDeclarations`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`functionDeclarations`],e)}let l=v(e,[`googleSearchRetrieval`]);if(l!=null&&_(n,[`googleSearchRetrieval`],l),v(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let u=v(e,[`urlContext`]);u!=null&&_(n,[`urlContext`],u);let d=v(e,[`mcpServers`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`mcpServers`],e)}return n}function Ko(e,t){let n={},r=v(e,[`retrieval`]);r!=null&&_(n,[`retrieval`],r);let i=v(e,[`computerUse`]);if(i!=null&&_(n,[`computerUse`],i),v(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);let a=v(e,[`googleSearch`]);a!=null&&_(n,[`googleSearch`],a);let o=v(e,[`googleMaps`]);o!=null&&_(n,[`googleMaps`],o);let s=v(e,[`codeExecution`]);s!=null&&_(n,[`codeExecution`],s);let c=v(e,[`enterpriseWebSearch`]);c!=null&&_(n,[`enterpriseWebSearch`],c);let l=v(e,[`functionDeclarations`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>Na(e))),_(n,[`functionDeclarations`],e)}let u=v(e,[`googleSearchRetrieval`]);u!=null&&_(n,[`googleSearchRetrieval`],u);let d=v(e,[`parallelAiSearch`]);d!=null&&_(n,[`parallelAiSearch`],d);let f=v(e,[`urlContext`]);if(f!=null&&_(n,[`urlContext`],f),v(e,[`mcpServers`])!==void 0)throw Error(`mcpServers parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return n}function qo(e,t){let n={},r=v(e,[`baseModel`]);r!=null&&_(n,[`baseModel`],r);let i=v(e,[`createTime`]);i!=null&&_(n,[`createTime`],i);let a=v(e,[`updateTime`]);return a!=null&&_(n,[`updateTime`],a),n}function Jo(e,t){let n={},r=v(e,[`labels`,`google-vertex-llm-tuning-base-model-id`]);r!=null&&_(n,[`baseModel`],r);let i=v(e,[`createTime`]);i!=null&&_(n,[`createTime`],i);let a=v(e,[`updateTime`]);return a!=null&&_(n,[`updateTime`],a),n}function Yo(e,t,n){let r={},i=v(e,[`displayName`]);t!==void 0&&i!=null&&_(t,[`displayName`],i);let a=v(e,[`description`]);t!==void 0&&a!=null&&_(t,[`description`],a);let o=v(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&_(t,[`defaultCheckpointId`],o),r}function Xo(e,t,n){let r={},i=v(e,[`displayName`]);t!==void 0&&i!=null&&_(t,[`displayName`],i);let a=v(e,[`description`]);t!==void 0&&a!=null&&_(t,[`description`],a);let o=v(e,[`defaultCheckpointId`]);return t!==void 0&&o!=null&&_(t,[`defaultCheckpointId`],o),r}function Zo(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`name`],F(e,i));let a=v(t,[`config`]);return a!=null&&Yo(a,r),r}function Qo(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`config`]);return a!=null&&Xo(a,r),r}function $o(e,t,n){let r={},i=v(e,[`outputGcsUri`]);t!==void 0&&i!=null&&_(t,[`parameters`,`storageUri`],i);let a=v(e,[`safetyFilterLevel`]);t!==void 0&&a!=null&&_(t,[`parameters`,`safetySetting`],a);let o=v(e,[`personGeneration`]);t!==void 0&&o!=null&&_(t,[`parameters`,`personGeneration`],o);let s=v(e,[`includeRaiReason`]);t!==void 0&&s!=null&&_(t,[`parameters`,`includeRaiReason`],s);let c=v(e,[`outputMimeType`]);t!==void 0&&c!=null&&_(t,[`parameters`,`outputOptions`,`mimeType`],c);let l=v(e,[`outputCompressionQuality`]);t!==void 0&&l!=null&&_(t,[`parameters`,`outputOptions`,`compressionQuality`],l);let u=v(e,[`enhanceInputImage`]);t!==void 0&&u!=null&&_(t,[`parameters`,`upscaleConfig`,`enhanceInputImage`],u);let d=v(e,[`imagePreservationFactor`]);t!==void 0&&d!=null&&_(t,[`parameters`,`upscaleConfig`,`imagePreservationFactor`],d);let f=v(e,[`labels`]);t!==void 0&&f!=null&&_(t,[`labels`],f);let p=v(e,[`numberOfImages`]);t!==void 0&&p!=null&&_(t,[`parameters`,`sampleCount`],p);let m=v(e,[`mode`]);return t!==void 0&&m!=null&&_(t,[`parameters`,`mode`],m),r}function es(e,t,n){let r={},i=v(t,[`model`]);i!=null&&_(r,[`_url`,`model`],F(e,i));let a=v(t,[`image`]);a!=null&&_(r,[`instances[0]`,`image`],q(a));let o=v(t,[`upscaleFactor`]);o!=null&&_(r,[`parameters`,`upscaleConfig`,`upscaleFactor`],o);let s=v(t,[`config`]);return s!=null&&$o(s,r),r}function ts(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`predictions`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>ro(e))),_(n,[`generatedImages`],e)}return n}function ns(e,t){let n={},r=v(e,[`uri`]);r!=null&&_(n,[`uri`],r);let i=v(e,[`encodedVideo`]);i!=null&&_(n,[`videoBytes`],B(i));let a=v(e,[`encoding`]);return a!=null&&_(n,[`mimeType`],a),n}function rs(e,t){let n={},r=v(e,[`gcsUri`]);r!=null&&_(n,[`uri`],r);let i=v(e,[`bytesBase64Encoded`]);i!=null&&_(n,[`videoBytes`],B(i));let a=v(e,[`mimeType`]);return a!=null&&_(n,[`mimeType`],a),n}function is(e,t){let n={},r=v(e,[`image`]);r!=null&&_(n,[`_self`],q(r));let i=v(e,[`maskMode`]);return i!=null&&_(n,[`maskMode`],i),n}function as(e,t){let n={},r=v(e,[`image`]);r!=null&&_(n,[`image`],_o(r));let i=v(e,[`referenceType`]);return i!=null&&_(n,[`referenceType`],i),n}function os(e,t){let n={},r=v(e,[`image`]);r!=null&&_(n,[`image`],q(r));let i=v(e,[`referenceType`]);return i!=null&&_(n,[`referenceType`],i),n}function ss(e,t){let n={},r=v(e,[`uri`]);r!=null&&_(n,[`uri`],r);let i=v(e,[`videoBytes`]);i!=null&&_(n,[`encodedVideo`],B(i));let a=v(e,[`mimeType`]);return a!=null&&_(n,[`encoding`],a),n}function cs(e,t){let n={},r=v(e,[`uri`]);r!=null&&_(n,[`gcsUri`],r);let i=v(e,[`videoBytes`]);i!=null&&_(n,[`bytesBase64Encoded`],B(i));let a=v(e,[`mimeType`]);return a!=null&&_(n,[`mimeType`],a),n}function ls(e,t,n){let r={},i=v(t,[`displayName`]);n!==void 0&&i!=null&&_(n,[`displayName`],i);let a=v(t,[`embeddingModel`]);return n!==void 0&&a!=null&&_(n,[`embeddingModel`],F(e,a)),r}function us(e,t){let n={},r=v(t,[`config`]);return r!=null&&ls(e,r,n),n}function ds(e,t){let n={},r=v(e,[`force`]);return t!==void 0&&r!=null&&_(t,[`_query`,`force`],r),n}function fs(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`_url`,`name`],n);let r=v(e,[`config`]);return r!=null&&ds(r,t),t}function ps(e){let t={},n=v(e,[`name`]);return n!=null&&_(t,[`_url`,`name`],n),t}function ms(e,t){let n={},r=v(e,[`customMetadata`]);if(t!==void 0&&r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`customMetadata`],e)}let i=v(e,[`chunkingConfig`]);return t!==void 0&&i!=null&&_(t,[`chunkingConfig`],i),n}function hs(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`name`],n);let r=v(e,[`metadata`]);r!=null&&_(t,[`metadata`],r);let i=v(e,[`done`]);i!=null&&_(t,[`done`],i);let a=v(e,[`error`]);a!=null&&_(t,[`error`],a);let o=v(e,[`response`]);return o!=null&&_(t,[`response`],_s(o)),t}function gs(e){let t={},n=v(e,[`fileSearchStoreName`]);n!=null&&_(t,[`_url`,`file_search_store_name`],n);let r=v(e,[`fileName`]);r!=null&&_(t,[`fileName`],r);let i=v(e,[`config`]);return i!=null&&ms(i,t),t}function _s(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`parent`]);r!=null&&_(t,[`parent`],r);let i=v(e,[`documentName`]);return i!=null&&_(t,[`documentName`],i),t}function vs(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);return t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i),n}function ys(e){let t={},n=v(e,[`config`]);return n!=null&&vs(n,t),t}function bs(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`fileSearchStores`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`fileSearchStores`],e)}return t}function xs(e,t){let n={},r=v(e,[`mimeType`]);t!==void 0&&r!=null&&_(t,[`mimeType`],r);let i=v(e,[`displayName`]);t!==void 0&&i!=null&&_(t,[`displayName`],i);let a=v(e,[`customMetadata`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`customMetadata`],e)}let o=v(e,[`chunkingConfig`]);return t!==void 0&&o!=null&&_(t,[`chunkingConfig`],o),n}function Ss(e){let t={},n=v(e,[`fileSearchStoreName`]);n!=null&&_(t,[`_url`,`file_search_store_name`],n);let r=v(e,[`config`]);return r!=null&&xs(r,t),t}function Cs(e){let t={},n=v(e,[`sdkHttpResponse`]);return n!=null&&_(t,[`sdkHttpResponse`],n),t}var ws=`Content-Type`,Ts=`X-Server-Timeout`,Es=`User-Agent`,Ds=`x-goog-api-client`,Os=`google-genai-sdk/1.52.0`,ks=`v1beta1`,As=`v1beta`,js=new Set([`us`,`eu`]),Ms=5,Ns=[408,429,500,502,503,504],Ps=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&&js.has(this.clientOptions.location)?t.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(t.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),t.apiVersion=this.clientOptions.apiVersion??ks}else this.clientOptions.apiKey||console.warn(`API key should be set when using the Gemini API.`),t.apiVersion=this.clientOptions.apiVersion??As,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===ze.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&&Is(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 Fs(e),new mt(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 Fs(e),this.processStreamResponse(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}processStreamResponse(e){return G(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=[`
|
|
2
|
+
|
|
3
|
+
`,`\r\r`,`\r
|
|
4
|
+
\r
|
|
5
|
+
`];for(;;){let{done:a,value:o}=yield W(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 pi({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 W(new mt(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,u.default)(async()=>{let n=await fetch(e,t);if(n.ok)return n;throw Ns.includes(n.status)?Error(`Retryable HTTP Error: ${n.statusText}`):new u.AbortError(`Non-retryable exception ${n.statusText} sending request`)},{retries:(n.attempts??Ms)-1})}getDefaultHeaders(){let e={},t=Os+` `+this.clientOptions.userAgentExtra;return e[Es]=t,e[Ds]=t,e[ws]=`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(Ts,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=g(`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&&xs(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 Fs(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 pi({message:r,status:t}):Error(r)}}function Is(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)}var Ls=`mcp_used/unknown`,Rs=!1;function zs(e){for(let t of e)if(Vs(t)||typeof t==`object`&&`inputSchema`in t)return!0;return Rs}function Bs(e){e[Ds]=((e[Ds]??``)+` ${Ls}`).trimStart()}function Vs(e){return typeof e==`object`&&!!e&&e instanceof Us}function Hs(e){return G(this,arguments,function*(e,t=100){let n,r=0;for(;r<t;){let t=yield W(e.listTools({cursor:n}));for(let e of t.tools)yield yield W(e),r++;if(!t.nextCursor)break;n=t.nextCursor}})}var Us=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,K(Hs(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(),_n(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}};async function Ws(e,t,n){let r=new Vt,i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(r,i),t(r)}var Gs=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=Js(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=>{Ws(l,s.onmessage,e)},onerror:s?.onerror??function(e){},onclose:s?.onclose??function(e){}},d=this.webSocketFactory.create(i,qs(r),u);d.connect(),await o;let f={setup:{model:F(this.apiClient,e.model)}};return d.send(JSON.stringify(f)),new Ks(d,this.apiClient)}},Ks=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=Vi(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||={};let t=Bi(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){let t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(pt.PLAY)}pause(){this.sendPlaybackControl(pt.PAUSE)}stop(){this.sendPlaybackControl(pt.STOP)}resetContext(){this.sendPlaybackControl(pt.RESET_CONTEXT)}close(){this.conn.close()}};function qs(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function Js(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}var Ys="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function Xs(e,t,n){let r=new Bt,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=Wi(a);Object.assign(r,e)}else Object.assign(r,a);t(r)}var Zs=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new Gs(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&&zs(e.config.tools)&&Bs(i);let a=tc(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=>{Xs(u,c.onmessage,e)},onerror:c?.onerror??function(e){},onclose:c?.onclose??function(e){}},f=this.webSocketFactory.create(r,ec(a),d);f.connect(),await s;let p=F(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:[Ee.AUDIO]}:e.config.responseModalities=[Ee.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()?zi(this.apiClient,_):Ri(this.apiClient,_),delete m.config,f.send(JSON.stringify(m)),new $s(f,this.apiClient)}isCallableTool(e){return`callTool`in e&&typeof e.callTool==`function`}},Qs={turnComplete:!0},$s=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=L(t.turns),e.isVertexAI()||(n=n.map(e=>sa(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(Ys)}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Qs),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:Ui(e)}:{realtimeInput:Hi(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 ec(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function tc(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}var nc=10;function rc(e){if(e?.automaticFunctionCalling?.disable)return!0;let t=!1;for(let n of e?.tools??[])if(ic(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 ic(e){return`callTool`in e&&typeof e.callTool==`function`}function ac(e){return(e.config?.tools)?.some(e=>ic(e))??!1}function oc(e){let t=[];return e?.config?.tools&&e.config.tools.forEach((e,n)=>{if(ic(e))return;let r=e;r.functionDeclarations&&r.functionDeclarations.length>0&&t.push(n)}),t}function sc(e){return!e?.automaticFunctionCalling?.ignoreCallHistory}var cc=class extends h{constructor(e){super(),this.apiClient=e,this.embedContent=async e=>{if(!this.apiClient.isVertexAI())return e.model.includes(`gemini-embedding-2`)&&(e.contents=L(e.contents)),await this.embedContentInternal(e);if(e.model.includes(`gemini`)&&e.model!==`gemini-embedding-001`||e.model.includes(`maas`)){let t=L(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:He.EMBED_CONTENT});return await this.embedContentInternal(n)}{let t=Object.assign(Object.assign({},e),{embeddingApiType:He.PREDICT});return await this.embedContentInternal(t)}},this.generateContent=async e=>{let t=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!ac(e)||rc(e.config))return await this.generateContentInternal(t);let n=oc(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=L(t.contents),o=t.config?.automaticFunctionCalling?.maximumRemoteCalls??nc,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(ic(t)){let e=await t.callTool(r.functionCalls);o.push(...e)}s++,i={role:`user`,parts:o},t.contents=L(t.contents),t.contents.push(n),t.contents.push(i),sc(t.config)&&(a.push(n),a.push(i))}return sc(t.config)&&(r.automaticFunctionCallingHistory=a),r},this.generateContentStream=async e=>{if(this.maybeMoveToResponseJsonSchem(e),rc(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let t=oc(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 Gemini Enterprise Agent Platform (previously known as 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=>ic(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&&zs(e.config.tools)){let t=e.config.httpOptions?.headers??{},n=Object.assign({},t);Object.keys(n).length===0&&(n=this.apiClient.getDefaultHeaders()),Bs(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(ic(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??nc,n=!1,r=0,i=await this.initAfcToolsMap(e);return(function(e,i,a){return G(this,arguments,function*(){for(var o,s,c,l;r<t;){n&&=(r++,!1);let p=yield W(e.processParamsMaybeAddMcpUsage(a)),m=yield W(e.generateContentStreamInternal(p)),h=[],g=[];try{for(var u=!0,d=(s=void 0,K(m)),f;f=yield W(d.next()),o=f.done,!o;u=!0){l=f.value,u=!1;let e=l;if(yield yield W(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 W(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 W(c.call(d)))}finally{if(s)throw s.error}}if(h.length>0){n=!0;let e=new ht;e.candidates=[{content:{role:`user`,parts:h}}],yield yield W(e);let t=[];t.push(...g),t.push({role:`user`,parts:h}),a.contents=L(a.contents).concat(t)}else break}})})(this,i,e)}async generateContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=La(this.apiClient,e);return n=g(`{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=za(e),n=new ht;return Object.assign(n,t),n})}{let i=Ia(this.apiClient,e);return n=g(`{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=Ra(e),n=new ht;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=La(this.apiClient,e);return n=g(`{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 G(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=K(t),c;c=yield W(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=za(yield W(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new ht;Object.assign(r,n),yield yield W(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield W(i.call(s)))}finally{if(r)throw r.error}}})})}{let i=Ia(this.apiClient,e);return n=g(`{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 G(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=K(t),c;c=yield W(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a,n=Ra(yield W(t.json()),e);n.sdkHttpResponse={headers:t.headers};let r=new ht;Object.assign(r,n),yield yield W(r)}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield W(i.call(s)))}finally{if(r)throw r.error}}})})}}async embedContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ea(this.apiClient,e,e);return n=g(Cn(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=Oa(t,e),r=new gt;return Object.assign(r,n),r})}{let i=Ta(this.apiClient,e);return n=g(`{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=Da(e),n=new gt;return Object.assign(n,t),n})}}async generateImagesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ua(this.apiClient,e);return n=g(`{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=Ga(e),n=new _t;return Object.assign(n,t),n})}{let i=Ha(this.apiClient,e);return n=g(`{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=Wa(e),n=new _t;return Object.assign(n,t),n})}}async editImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=xa(this.apiClient,e);return n=g(`{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=Sa(e),n=new vt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async upscaleImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=es(this.apiClient,e);return n=g(`{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=ts(e),n=new yt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async recontextImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=jo(this.apiClient,e);return n=g(`{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=Mo(e),n=new bt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async segmentImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Bo(this.apiClient,e);return n=g(`{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=Vo(e),n=new xt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=lo(this.apiClient,e);return n=g(`{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))}{let i=co(this.apiClient,e);return n=g(`{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=>To(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=xo(this.apiClient,e);return n=g(`{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=Co(e),n=new St;return Object.assign(n,t),n})}{let i=bo(this.apiClient,e);return n=g(`{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=So(e),n=new St;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Qo(this.apiClient,e);return n=g(`{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))}{let i=Zo(this.apiClient,e);return n=g(`{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=>To(e))}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=_a(this.apiClient,e);return n=g(`{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=ya(e),n=new Ct;return Object.assign(n,t),n})}{let i=ga(this.apiClient,e);return n=g(`{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=va(e),n=new Ct;return Object.assign(n,t),n})}}async countTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=pa(this.apiClient,e);return n=g(`{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=ha(e),n=new wt;return Object.assign(n,t),n})}{let i=fa(this.apiClient,e);return n=g(`{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=ma(e),n=new wt;return Object.assign(n,t),n})}}async computeTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ra(this.apiClient,e);return n=g(`{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=ia(e),n=new Tt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async generateVideosInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Za(this.apiClient,e);return n=g(`{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=Ya(e),n=new Et;return Object.assign(n,t),n})}{let i=Xa(this.apiClient,e);return n=g(`{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=Ja(e),n=new Et;return Object.assign(n,t),n})}}},lc=class extends h{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})}{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})}{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=A(e);return n=g(`{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}{let i=k(e);return n=g(`{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=S(e);return n=g(`{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}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}};function uc(e){let t={};if(v(e,[`languageCodes`])!==void 0)throw Error(`languageCodes parameter is not supported in Gemini API.`);return t}function dc(e){let t={},n=v(e,[`apiKey`]);if(n!=null&&_(t,[`apiKey`],n),v(e,[`apiKeyConfig`])!==void 0)throw Error(`apiKeyConfig parameter is not supported in Gemini API.`);if(v(e,[`authType`])!==void 0)throw Error(`authType parameter is not supported in Gemini API.`);if(v(e,[`googleServiceAccountConfig`])!==void 0)throw Error(`googleServiceAccountConfig parameter is not supported in Gemini API.`);if(v(e,[`httpBasicAuthConfig`])!==void 0)throw Error(`httpBasicAuthConfig parameter is not supported in Gemini API.`);if(v(e,[`oauthConfig`])!==void 0)throw Error(`oauthConfig parameter is not supported in Gemini API.`);if(v(e,[`oidcConfig`])!==void 0)throw Error(`oidcConfig parameter is not supported in Gemini API.`);return t}function fc(e){let t={},n=v(e,[`data`]);if(n!=null&&_(t,[`data`],n),v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function pc(e){let t={},n=v(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Sc(e))),_(t,[`parts`],e)}let r=v(e,[`role`]);return r!=null&&_(t,[`role`],r),t}function mc(e,t,n){let r={},i=v(t,[`expireTime`]);n!==void 0&&i!=null&&_(n,[`expireTime`],i);let a=v(t,[`newSessionExpireTime`]);n!==void 0&&a!=null&&_(n,[`newSessionExpireTime`],a);let o=v(t,[`uses`]);n!==void 0&&o!=null&&_(n,[`uses`],o);let s=v(t,[`liveConnectConstraints`]);n!==void 0&&s!=null&&_(n,[`bidiGenerateContentSetup`],xc(e,s));let c=v(t,[`lockAdditionalFields`]);return n!==void 0&&c!=null&&_(n,[`fieldMask`],c),r}function hc(e,t){let n={},r=v(t,[`config`]);return r!=null&&_(n,[`config`],mc(e,r,n)),n}function gc(e){let t={};if(v(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=v(e,[`fileUri`]);n!=null&&_(t,[`fileUri`],n);let r=v(e,[`mimeType`]);return r!=null&&_(t,[`mimeType`],r),t}function _c(e){let t={},n=v(e,[`id`]);n!=null&&_(t,[`id`],n);let r=v(e,[`args`]);r!=null&&_(t,[`args`],r);let i=v(e,[`name`]);if(i!=null&&_(t,[`name`],i),v(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(v(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function vc(e){let t={},n=v(e,[`authConfig`]);n!=null&&_(t,[`authConfig`],dc(n));let r=v(e,[`enableWidget`]);return r!=null&&_(t,[`enableWidget`],r),t}function yc(e){let t={},n=v(e,[`searchTypes`]);if(n!=null&&_(t,[`searchTypes`],n),v(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);if(v(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);let r=v(e,[`timeRangeFilter`]);return r!=null&&_(t,[`timeRangeFilter`],r),t}function bc(e,t){let n={},r=v(e,[`generationConfig`]);t!==void 0&&r!=null&&_(t,[`setup`,`generationConfig`],r);let i=v(e,[`responseModalities`]);t!==void 0&&i!=null&&_(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=v(e,[`temperature`]);t!==void 0&&a!=null&&_(t,[`setup`,`generationConfig`,`temperature`],a);let o=v(e,[`topP`]);t!==void 0&&o!=null&&_(t,[`setup`,`generationConfig`,`topP`],o);let s=v(e,[`topK`]);t!==void 0&&s!=null&&_(t,[`setup`,`generationConfig`,`topK`],s);let c=v(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&_(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=v(e,[`mediaResolution`]);t!==void 0&&l!=null&&_(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=v(e,[`seed`]);t!==void 0&&u!=null&&_(t,[`setup`,`generationConfig`,`seed`],u);let d=v(e,[`speechConfig`]);t!==void 0&&d!=null&&_(t,[`setup`,`generationConfig`,`speechConfig`],rn(d));let f=v(e,[`thinkingConfig`]);t!==void 0&&f!=null&&_(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=v(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&_(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=v(e,[`systemInstruction`]);t!==void 0&&m!=null&&_(t,[`setup`,`systemInstruction`],pc(I(m)));let h=v(e,[`tools`]);if(t!==void 0&&h!=null){let e=on(h);Array.isArray(e)&&(e=e.map(e=>Tc(an(e)))),_(t,[`setup`,`tools`],e)}let g=v(e,[`sessionResumption`]);t!==void 0&&g!=null&&_(t,[`setup`,`sessionResumption`],wc(g));let y=v(e,[`inputAudioTranscription`]);t!==void 0&&y!=null&&_(t,[`setup`,`inputAudioTranscription`],uc(y));let b=v(e,[`outputAudioTranscription`]);t!==void 0&&b!=null&&_(t,[`setup`,`outputAudioTranscription`],uc(b));let x=v(e,[`realtimeInputConfig`]);t!==void 0&&x!=null&&_(t,[`setup`,`realtimeInputConfig`],x);let S=v(e,[`contextWindowCompression`]);t!==void 0&&S!=null&&_(t,[`setup`,`contextWindowCompression`],S);let C=v(e,[`proactivity`]);if(t!==void 0&&C!=null&&_(t,[`setup`,`proactivity`],C),v(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);let w=v(e,[`avatarConfig`]);t!==void 0&&w!=null&&_(t,[`setup`,`avatarConfig`],w);let T=v(e,[`safetySettings`]);if(t!==void 0&&T!=null){let e=T;Array.isArray(e)&&(e=e.map(e=>Cc(e))),_(t,[`setup`,`safetySettings`],e)}return n}function xc(e,t){let n={},r=v(t,[`model`]);r!=null&&_(n,[`setup`,`model`],F(e,r));let i=v(t,[`config`]);return i!=null&&_(n,[`config`],bc(i,n)),n}function Sc(e){let t={},n=v(e,[`mediaResolution`]);n!=null&&_(t,[`mediaResolution`],n);let r=v(e,[`codeExecutionResult`]);r!=null&&_(t,[`codeExecutionResult`],r);let i=v(e,[`executableCode`]);i!=null&&_(t,[`executableCode`],i);let a=v(e,[`fileData`]);a!=null&&_(t,[`fileData`],gc(a));let o=v(e,[`functionCall`]);o!=null&&_(t,[`functionCall`],_c(o));let s=v(e,[`functionResponse`]);s!=null&&_(t,[`functionResponse`],s);let c=v(e,[`inlineData`]);c!=null&&_(t,[`inlineData`],fc(c));let l=v(e,[`text`]);l!=null&&_(t,[`text`],l);let u=v(e,[`thought`]);u!=null&&_(t,[`thought`],u);let d=v(e,[`thoughtSignature`]);d!=null&&_(t,[`thoughtSignature`],d);let f=v(e,[`videoMetadata`]);f!=null&&_(t,[`videoMetadata`],f);let p=v(e,[`toolCall`]);p!=null&&_(t,[`toolCall`],p);let m=v(e,[`toolResponse`]);m!=null&&_(t,[`toolResponse`],m);let h=v(e,[`partMetadata`]);return h!=null&&_(t,[`partMetadata`],h),t}function Cc(e){let t={},n=v(e,[`category`]);if(n!=null&&_(t,[`category`],n),v(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=v(e,[`threshold`]);return r!=null&&_(t,[`threshold`],r),t}function wc(e){let t={},n=v(e,[`handle`]);if(n!=null&&_(t,[`handle`],n),v(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function Tc(e){let t={};if(v(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let n=v(e,[`computerUse`]);n!=null&&_(t,[`computerUse`],n);let r=v(e,[`fileSearch`]);r!=null&&_(t,[`fileSearch`],r);let i=v(e,[`googleSearch`]);i!=null&&_(t,[`googleSearch`],yc(i));let a=v(e,[`googleMaps`]);a!=null&&_(t,[`googleMaps`],vc(a));let o=v(e,[`codeExecution`]);if(o!=null&&_(t,[`codeExecution`],o),v(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=v(e,[`functionDeclarations`]);if(s!=null){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`functionDeclarations`],e)}let c=v(e,[`googleSearchRetrieval`]);if(c!=null&&_(t,[`googleSearchRetrieval`],c),v(e,[`parallelAiSearch`])!==void 0)throw Error(`parallelAiSearch parameter is not supported in Gemini API.`);let l=v(e,[`urlContext`]);l!=null&&_(t,[`urlContext`],l);let u=v(e,[`mcpServers`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`mcpServers`],e)}return t}function Ec(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 Dc(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=Ec(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 Oc=class extends h{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=hc(this.apiClient,e);n=g(`auth_tokens`,i._url),r=i._query,delete i.config,delete i._url,delete i._query;let a=Dc(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)}}};function kc(e,t){let n={},r=v(e,[`force`]);return t!==void 0&&r!=null&&_(t,[`_query`,`force`],r),n}function Ac(e){let t={},n=v(e,[`name`]);n!=null&&_(t,[`_url`,`name`],n);let r=v(e,[`config`]);return r!=null&&kc(r,t),t}function jc(e){let t={},n=v(e,[`name`]);return n!=null&&_(t,[`_url`,`name`],n),t}function Mc(e,t){let n={},r=v(e,[`pageSize`]);t!==void 0&&r!=null&&_(t,[`_query`,`pageSize`],r);let i=v(e,[`pageToken`]);return t!==void 0&&i!=null&&_(t,[`_query`,`pageToken`],i),n}function Nc(e){let t={},n=v(e,[`parent`]);n!=null&&_(t,[`_url`,`parent`],n);let r=v(e,[`config`]);return r!=null&&Mc(r,t),t}function Pc(e){let t={},n=v(e,[`sdkHttpResponse`]);n!=null&&_(t,[`sdkHttpResponse`],n);let r=v(e,[`nextPageToken`]);r!=null&&_(t,[`nextPageToken`],r);let i=v(e,[`documents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),_(t,[`documents`],e)}return t}var Fc=class extends h{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=jc(e);return n=g(`{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=Ac(e);t=g(`{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=Nc(e);return n=g(`{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=Pc(e),n=new jt;return Object.assign(n,t),n})}}},Ic=class extends h{constructor(e,t=new Fc(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(`Gemini Enterprise Agent Platform (previously known as Vertex AI) does not support uploading files to a file search store.`);return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async downloadMedia(e,t){if(this.apiClient.isVertexAI())throw Error(`This method is only supported in the Gemini Developer client.`);let n=new URL(e,`http://dummy.com`),r=n.pathname;if(r.startsWith(`/`)&&(r=r.slice(1)),!r.includes(`/media/`))throw Error(`Invalid uri format: ${e}. Expected to contain /media/`);let i={};n.searchParams.forEach((e,t)=>{i[t]=e}),i.alt=`media`;let a=Object.assign({},t?.httpOptions),o=await this.apiClient.request({path:r,httpMethod:`GET`,queryParams:i,httpOptions:a});if(o instanceof mt){let e=await o.responseInternal.arrayBuffer();return new Uint8Array(e)}throw Error(`Unexpected response type from downloadMedia`)}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=us(this.apiClient,e);return n=g(`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=ps(e);return n=g(`{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=fs(e);t=g(`{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=ys(e);return n=g(`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=bs(e),n=new Mt;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=Ss(e);return n=g(`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=Cs(e),n=new Nt;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=gs(e);return n=g(`{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=hs(e),n=new Pt;return Object.assign(n,t),n})}}},Lc=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Lc=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))},Rc=()=>Lc();function zc(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var Bc=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)},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 Hc({message:r,cause:Bc(n)});let a=n;return t===400?new Wc(t,a,r,i):t===401?new Gc(t,a,r,i):t===403?new Kc(t,a,r,i):t===404?new qc(t,a,r,i):t===409?new Jc(t,a,r,i):t===422?new Yc(t,a,r,i):t===429?new Xc(t,a,r,i):t>=500?new Zc(t,a,r,i):new e(t,a,r,i)}},Vc=class extends Y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},Hc=class extends Y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Uc=class extends Hc{constructor({message:e}={}){super({message:e??`Request timed out.`})}},Wc=class extends Y{},Gc=class extends Y{},Kc=class extends Y{},qc=class extends Y{},Jc=class extends Y{},Yc=class extends Y{},Xc=class extends Y{},Zc=class extends Y{},Qc=/^[a-z][a-z0-9+.-]*:/i,$c=e=>Qc.test(e),el=e=>(el=Array.isArray,el(e)),tl=el;function nl(e){if(!e)return!0;for(let t in e)return!1;return!0}function rl(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var il=(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},al=e=>{try{return JSON.parse(e)}catch{return}},ol=e=>new Promise(t=>setTimeout(t,e));function sl(){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 cl(...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 ll(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return cl({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 ul(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 dl(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}var fl=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function pl(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(`&`)}var ml=`0.0.1`,hl=()=>{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 gl(e,t,n){return hl(),new File(e,t??`unknown_file`,n)}function _l(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}var vl=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,yl=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`,bl=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&yl(e),xl=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`;async function Sl(e,t,n){if(hl(),e=await e,bl(e))return e instanceof File?e:gl([await e.arrayBuffer()],e.name);if(xl(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),gl(await Cl(r),t,n)}let r=await Cl(e);if(t||=_l(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 gl(r,t,n)}async function Cl(e){var t,n,r,i;let a=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)a.push(e);else if(yl(e))a.push(e instanceof Blob?e:await e.arrayBuffer());else if(vl(e))try{for(var o=!0,s=K(e),c;c=await s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;a.push(...await Cl(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}`:``}${wl(e)}`)}return a}function wl(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var Tl=class{constructor(e){this._client=e}};Tl._key=[];function El(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Dl=Object.freeze(Object.create(null)),X=((e=El)=>(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??Dl)??Dl)?.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(`
|
|
6
|
+
`)}\n${a}\n${t}`)}return a}))(El),Ol=class extends Tl{create(e,t){let{api_version:n=this._client.apiVersion}=e,r=U(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(X`/${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(X`/${r}/interactions/${e}`,n)}cancel(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.post(X`/${r}/interactions/${e}/cancel`,n)}get(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion}=r,a=U(r,[`api_version`]);return this._client.get(X`/${i}/interactions/${e}`,Object.assign(Object.assign({query:a},n),{stream:t?.stream??!1}))}};Ol._key=Object.freeze([`interactions`]);var kl=class extends Ol{},Al=class extends Tl{create(e,t){let{api_version:n=this._client.apiVersion}=e,r=U(e,[`api_version`]);return this._client.post(X`/${n}/webhooks`,Object.assign({body:r},t))}update(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion,update_mask:a}=r,o=U(r,[`api_version`,`update_mask`]);return this._client.patch(X`/${i}/webhooks/${e}`,Object.assign({query:{update_mask:a},body:o},n))}list(e={},t){let n=e??{},{api_version:r=this._client.apiVersion}=n,i=U(n,[`api_version`]);return this._client.get(X`/${r}/webhooks`,Object.assign({query:i},t))}delete(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.delete(X`/${r}/webhooks/${e}`,n)}get(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.get(X`/${r}/webhooks/${e}`,n)}ping(e,t=void 0,n){let{api_version:r=this._client.apiVersion,body:i}=t??{};return this._client.post(X`/${r}/webhooks/${e}:ping`,Object.assign({body:i},n))}rotateSigningSecret(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion}=r,a=U(r,[`api_version`]);return this._client.post(X`/${i}/webhooks/${e}:rotateSigningSecret`,Object.assign({body:a},n))}};Al._key=Object.freeze([`webhooks`]);var jl=class extends Al{};function Ml(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}var Nl;function Pl(e){let t;return(Nl??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Fl;function Il(e){let t;return(Fl??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Ll=class{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null,this.searchIndex=0}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Pl(e):e;this.buffer=Ml([this.buffer,t]);let n=[],r;for(;(r=Rl(this.buffer,this.carriageReturnIndex??this.searchIndex))!=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(Il(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null,this.searchIndex=0;continue}let e=this.carriageReturnIndex===null?r.preceding:r.preceding-1,t=Il(this.buffer.subarray(0,e));n.push(t),this.buffer=this.buffer.subarray(r.index),this.carriageReturnIndex=null,this.searchIndex=0}return this.searchIndex=Math.max(0,this.buffer.length-1),n}flush(){return this.buffer.length?this.decode(`
|
|
7
|
+
`):[]}};Ll.NEWLINE_CHARS=new Set([`
|
|
8
|
+
`,`\r`]),Ll.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Rl(e,t){let n=t??0,r=e.indexOf(10,n),i=e.indexOf(13,n);if(r===-1&&i===-1)return null;let a;return a=r!==-1&&i!==-1?Math.min(r,i):r===-1?i:r,e[a]===10?{preceding:a,index:a+1,carriage:!1}:{preceding:a,index:a+1,carriage:!0}}var zl={off:0,error:200,warn:300,info:400,debug:500},Bl=(e,t,n)=>{if(e){if(rl(zl,e))return e;Z(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(zl))}`)}};function Vl(){}function Hl(e,t,n){return!t||zl[e]>zl[n]?Vl:t[e].bind(t)}var Ul={error:Vl,warn:Vl,info:Vl,debug:Vl},Wl=new WeakMap;function Z(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Ul;let r=Wl.get(t);if(r&&r[0]===n)return r[1];let i={error:Hl(`error`,t,n),warn:Hl(`warn`,t,n),info:Hl(`info`,t,n),debug:Hl(`debug`,t,n)};return Wl.set(t,[n,i]),i}var 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),Gl=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 G(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=K(Kl(t,n)),d;d=yield W(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}try{yield yield W(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 W(o.call(u)))}finally{if(r)throw r.error}}c=!0}catch(e){if(zc(e))return yield W(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 G(this,arguments,function*(){var e,n,r,i;let a=new Ll,o=ul(t);try{for(var s=!0,c=K(o),l;l=yield W(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 W(t)}}catch(e){n={error:e}}finally{try{!s&&!e&&(r=c.return)&&(yield W(r.call(c)))}finally{if(n)throw n.error}}for(let e of a.flush())yield yield W(e)})}function o(){return G(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=K(a()),u;u=yield W(l.next()),e=u.done,!e;c=!0){o=u.value,c=!1;let e=o;s||e&&(yield yield W(JSON.parse(e)))}}catch(e){t={error:e}}finally{try{!c&&!e&&(r=l.return)&&(yield W(r.call(l)))}finally{if(t)throw t.error}}s=!0}catch(e){if(zc(e))return yield W(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 cl({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=Pl(JSON.stringify(n)+`
|
|
9
|
+
`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.call(t)}})}};function Kl(e,t){return G(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 Jl,s=new Ll,c=ul(e.body);try{for(var l=!0,u=K(ql(c)),d;d=yield W(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 W(e))}}}catch(e){r={error:e}}finally{try{!l&&!n&&(i=u.return)&&(yield W(i.call(u)))}finally{if(r)throw r.error}}for(let e of s.flush()){let t=o.decode(e);t&&(yield yield W(t))}})}function ql(e){return G(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=K(e),s;s=yield W(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let e=i;e!=null&&(yield yield W(e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Pl(e):e))}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield W(r.call(o)))}finally{if(n)throw n.error}}})}var Jl=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(`
|
|
10
|
+
`),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]=Yl(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function Yl(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}async function Xl(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):Gl.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}var Zl=class e extends Promise{constructor(e,t,n=Xl){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)}},Ql=Symbol(`brand.privateNullableHeaders`);function*$l(e){if(!e)return;if(Ql 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():tl(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=tl(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])}}var eu=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of $l(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{[Ql]:!0,values:t,nulls:n}},tu=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()||void 0},nu,ru=class e{constructor(t){var{baseURL:n=tu(`GEMINI_NEXT_GEN_API_BASE_URL`),apiKey:r=tu(`GEMINI_API_KEY`)??null,apiVersion:i=`v1beta`}=t,a=U(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=Bl(o.logLevel,`ClientOptions.logLevel`,this)??Bl(tu(`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??sl(),this.encoder=fl,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=eu([e.headers]);if(!(t.values.has(`authorization`)||t.values.has(`x-goog-api-key`))){if(this.apiKey)return eu([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter&&this.clientAdapter.isVertexAI())return eu([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return pl(e)}getUserAgent(){return`${this.constructor.name}/JS ${ml}`}defaultIdempotencyKey(){return`stainless-node-retry-${Rc()}`}makeStatusError(e,t,n,r){return Y.generate(e,t,n,r)}buildURL(e,t,n){let r=!this.baseURLOverridden()&&n||this.baseURL,i=$c(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!nl(a)||!nl(o))&&(t=Object.assign(Object.assign(Object.assign({},o),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 Zl(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 Vc;let d=new AbortController,f=await this.fetchWithTimeout(o,a,s,d).catch(Bc),p=Date.now();if(f instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new Vc;let i=zc(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 Uc:new Hc({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 dl(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=>Bc(e).message),o=al(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=U(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===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await ol(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&&il(`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=eu([i,{Accept:`application/json`,"User-Agent":this.getUserAgent()},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=eu([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:ll(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})}};ru.DEFAULT_TIMEOUT=6e4;var $=class extends ru{constructor(){super(...arguments),this.interactions=new kl(this),this.webhooks=new jl(this)}};nu=$,$.GeminiNextGenAPIClient=nu,$.GeminiNextGenAPIClientError=J,$.APIError=Y,$.APIConnectionError=Hc,$.APIConnectionTimeoutError=Uc,$.APIUserAbortError=Vc,$.NotFoundError=qc,$.ConflictError=Jc,$.RateLimitError=Xc,$.BadRequestError=Wc,$.AuthenticationError=Gc,$.InternalServerError=Zc,$.PermissionDeniedError=Kc,$.UnprocessableEntityError=Yc,$.toFile=Sl,$.Interactions=kl,$.Webhooks=jl;function iu(e,t){let n={},r=v(e,[`name`]);return r!=null&&_(n,[`_url`,`name`],r),n}function au(e,t){let n={},r=v(e,[`name`]);return r!=null&&_(n,[`_url`,`name`],r),n}function ou(e,t){let n={},r=v(e,[`sdkHttpResponse`]);return r!=null&&_(n,[`sdkHttpResponse`],r),n}function su(e,t){let n={},r=v(e,[`sdkHttpResponse`]);return r!=null&&_(n,[`sdkHttpResponse`],r),n}function cu(e,t,n){let r={};if(v(e,[`validationDataset`])!==void 0)throw Error(`validationDataset parameter is not supported in Gemini API.`);let i=v(e,[`tunedModelDisplayName`]);if(t!==void 0&&i!=null&&_(t,[`displayName`],i),v(e,[`description`])!==void 0)throw Error(`description parameter is not supported in Gemini API.`);let a=v(e,[`epochCount`]);t!==void 0&&a!=null&&_(t,[`tuningTask`,`hyperparameters`,`epochCount`],a);let o=v(e,[`learningRateMultiplier`]);if(o!=null&&_(r,[`tuningTask`,`hyperparameters`,`learningRateMultiplier`],o),v(e,[`exportLastCheckpointOnly`])!==void 0)throw Error(`exportLastCheckpointOnly parameter is not supported in Gemini API.`);if(v(e,[`preTunedModelCheckpointId`])!==void 0)throw Error(`preTunedModelCheckpointId parameter is not supported in Gemini API.`);if(v(e,[`adapterSize`])!==void 0)throw Error(`adapterSize parameter is not supported in Gemini API.`);if(v(e,[`tuningMode`])!==void 0)throw Error(`tuningMode parameter is not supported in Gemini API.`);if(v(e,[`customBaseModel`])!==void 0)throw Error(`customBaseModel parameter is not supported in Gemini API.`);let s=v(e,[`batchSize`]);t!==void 0&&s!=null&&_(t,[`tuningTask`,`hyperparameters`,`batchSize`],s);let c=v(e,[`learningRate`]);if(t!==void 0&&c!=null&&_(t,[`tuningTask`,`hyperparameters`,`learningRate`],c),v(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);if(v(e,[`beta`])!==void 0)throw Error(`beta parameter is not supported in Gemini API.`);if(v(e,[`baseTeacherModel`])!==void 0)throw Error(`baseTeacherModel parameter is not supported in Gemini API.`);if(v(e,[`tunedTeacherModelSource`])!==void 0)throw Error(`tunedTeacherModelSource parameter is not supported in Gemini API.`);if(v(e,[`sftLossWeightMultiplier`])!==void 0)throw Error(`sftLossWeightMultiplier parameter is not supported in Gemini API.`);if(v(e,[`outputUri`])!==void 0)throw Error(`outputUri parameter is not supported in Gemini API.`);if(v(e,[`encryptionSpec`])!==void 0)throw Error(`encryptionSpec parameter is not supported in Gemini API.`);return r}function lu(e,t,n){let r={},i=v(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=v(e,[`validationDataset`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`],Cu(n))}else if(i===`PREFERENCE_TUNING`){let n=v(e,[`validationDataset`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`],Cu(n))}else if(i===`DISTILLATION`){let n=v(e,[`validationDataset`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`],Cu(n))}let a=v(e,[`tunedModelDisplayName`]);t!==void 0&&a!=null&&_(t,[`tunedModelDisplayName`],a);let o=v(e,[`description`]);t!==void 0&&o!=null&&_(t,[`description`],o);let s=v(n,[`config`,`method`]);if(s===void 0&&(s=`SUPERVISED_FINE_TUNING`),s===`SUPERVISED_FINE_TUNING`){let n=v(e,[`epochCount`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`PREFERENCE_TUNING`){let n=v(e,[`epochCount`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`DISTILLATION`){let n=v(e,[`epochCount`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`hyperParameters`,`epochCount`],n)}let c=v(n,[`config`,`method`]);if(c===void 0&&(c=`SUPERVISED_FINE_TUNING`),c===`SUPERVISED_FINE_TUNING`){let n=v(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`PREFERENCE_TUNING`){let n=v(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`DISTILLATION`){let n=v(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}let l=v(n,[`config`,`method`]);if(l===void 0&&(l=`SUPERVISED_FINE_TUNING`),l===`SUPERVISED_FINE_TUNING`){let n=v(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`exportLastCheckpointOnly`],n)}else if(l===`PREFERENCE_TUNING`){let n=v(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`,`exportLastCheckpointOnly`],n)}else if(l===`DISTILLATION`){let n=v(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`exportLastCheckpointOnly`],n)}let u=v(n,[`config`,`method`]);if(u===void 0&&(u=`SUPERVISED_FINE_TUNING`),u===`SUPERVISED_FINE_TUNING`){let n=v(e,[`adapterSize`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`PREFERENCE_TUNING`){let n=v(e,[`adapterSize`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`DISTILLATION`){let n=v(e,[`adapterSize`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`hyperParameters`,`adapterSize`],n)}let d=v(n,[`config`,`method`]);if(d===void 0&&(d=`SUPERVISED_FINE_TUNING`),d===`SUPERVISED_FINE_TUNING`){let n=v(e,[`tuningMode`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`tuningMode`],n)}else if(d===`DISTILLATION`){let n=v(e,[`tuningMode`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`tuningMode`],n)}let f=v(e,[`customBaseModel`]);t!==void 0&&f!=null&&_(t,[`customBaseModel`],f);let p=v(n,[`config`,`method`]);if(p===void 0&&(p=`SUPERVISED_FINE_TUNING`),p===`SUPERVISED_FINE_TUNING`){let n=v(e,[`batchSize`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`hyperParameters`,`batchSize`],n)}else if(p===`DISTILLATION`){let n=v(e,[`batchSize`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`hyperParameters`,`batchSize`],n)}let m=v(n,[`config`,`method`]);if(m===void 0&&(m=`SUPERVISED_FINE_TUNING`),m===`SUPERVISED_FINE_TUNING`){let n=v(e,[`learningRate`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRate`],n)}else if(m===`DISTILLATION`){let n=v(e,[`learningRate`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`hyperParameters`,`learningRate`],n)}let h=v(e,[`labels`]);t!==void 0&&h!=null&&_(t,[`labels`],h);let g=v(e,[`beta`]);t!==void 0&&g!=null&&_(t,[`preferenceOptimizationSpec`,`hyperParameters`,`beta`],g);let y=v(e,[`baseTeacherModel`]);t!==void 0&&y!=null&&_(t,[`distillationSpec`,`baseTeacherModel`],y);let b=v(e,[`tunedTeacherModelSource`]);t!==void 0&&b!=null&&_(t,[`distillationSpec`,`tunedTeacherModelSource`],b);let x=v(e,[`sftLossWeightMultiplier`]);t!==void 0&&x!=null&&_(t,[`distillationSpec`,`hyperParameters`,`sftLossWeightMultiplier`],x);let S=v(e,[`outputUri`]);t!==void 0&&S!=null&&_(t,[`outputUri`],S);let C=v(e,[`encryptionSpec`]);return t!==void 0&&C!=null&&_(t,[`encryptionSpec`],C),r}function uu(e,t){let n={},r=v(e,[`baseModel`]);r!=null&&_(n,[`baseModel`],r);let i=v(e,[`preTunedModel`]);i!=null&&_(n,[`preTunedModel`],i);let a=v(e,[`trainingDataset`]);a!=null&&vu(a);let o=v(e,[`config`]);return o!=null&&cu(o,n),n}function du(e,t){let n={},r=v(e,[`baseModel`]);r!=null&&_(n,[`baseModel`],r);let i=v(e,[`preTunedModel`]);i!=null&&_(n,[`preTunedModel`],i);let a=v(e,[`trainingDataset`]);a!=null&&yu(a,n,t);let o=v(e,[`config`]);return o!=null&&lu(o,n,t),n}function fu(e,t){let n={},r=v(e,[`name`]);return r!=null&&_(n,[`_url`,`name`],r),n}function pu(e,t){let n={},r=v(e,[`name`]);return r!=null&&_(n,[`_url`,`name`],r),n}function mu(e,t,n){let r={},i=v(e,[`pageSize`]);t!==void 0&&i!=null&&_(t,[`_query`,`pageSize`],i);let a=v(e,[`pageToken`]);t!==void 0&&a!=null&&_(t,[`_query`,`pageToken`],a);let o=v(e,[`filter`]);return t!==void 0&&o!=null&&_(t,[`_query`,`filter`],o),r}function hu(e,t){let n={},r=v(e,[`config`]);return r!=null&&mu(r,n),n}function gu(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`nextPageToken`]);i!=null&&_(n,[`nextPageToken`],i);let a=v(e,[`tuningJobs`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>xu(e))),_(n,[`tuningJobs`],e)}return n}function _u(e,t){let n={},r=v(e,[`name`]);r!=null&&_(n,[`model`],r);let i=v(e,[`name`]);return i!=null&&_(n,[`endpoint`],i),n}function vu(e,t){let n={};if(v(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(v(e,[`vertexDatasetResource`])!==void 0)throw Error(`vertexDatasetResource parameter is not supported in Gemini API.`);let r=v(e,[`examples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`examples`,`examples`],e)}return n}function yu(e,t,n){let r={},i=v(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=v(e,[`gcsUri`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(i===`PREFERENCE_TUNING`){let n=v(e,[`gcsUri`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(i===`DISTILLATION`){let n=v(e,[`gcsUri`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`promptDatasetUri`],n)}let a=v(n,[`config`,`method`]);if(a===void 0&&(a=`SUPERVISED_FINE_TUNING`),a===`SUPERVISED_FINE_TUNING`){let n=v(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&_(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(a===`PREFERENCE_TUNING`){let n=v(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&_(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}else if(a===`DISTILLATION`){let n=v(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&_(t,[`distillationSpec`,`promptDatasetUri`],n)}if(v(e,[`examples`])!==void 0)throw Error(`examples parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).`);return r}function bu(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`name`]);i!=null&&_(n,[`name`],i);let a=v(e,[`state`]);a!=null&&_(n,[`state`],cn(a));let o=v(e,[`createTime`]);o!=null&&_(n,[`createTime`],o);let s=v(e,[`tuningTask`,`startTime`]);s!=null&&_(n,[`startTime`],s);let c=v(e,[`tuningTask`,`completeTime`]);c!=null&&_(n,[`endTime`],c);let l=v(e,[`updateTime`]);l!=null&&_(n,[`updateTime`],l);let u=v(e,[`description`]);u!=null&&_(n,[`description`],u);let d=v(e,[`baseModel`]);d!=null&&_(n,[`baseModel`],d);let f=v(e,[`_self`]);return f!=null&&_(n,[`tunedModel`],_u(f)),n}function xu(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`name`]);i!=null&&_(n,[`name`],i);let a=v(e,[`state`]);a!=null&&_(n,[`state`],cn(a));let o=v(e,[`createTime`]);o!=null&&_(n,[`createTime`],o);let s=v(e,[`startTime`]);s!=null&&_(n,[`startTime`],s);let c=v(e,[`endTime`]);c!=null&&_(n,[`endTime`],c);let l=v(e,[`updateTime`]);l!=null&&_(n,[`updateTime`],l);let u=v(e,[`error`]);u!=null&&_(n,[`error`],u);let d=v(e,[`description`]);d!=null&&_(n,[`description`],d);let f=v(e,[`baseModel`]);f!=null&&_(n,[`baseModel`],f);let p=v(e,[`tunedModel`]);p!=null&&_(n,[`tunedModel`],p);let m=v(e,[`preTunedModel`]);m!=null&&_(n,[`preTunedModel`],m);let h=v(e,[`supervisedTuningSpec`]);h!=null&&_(n,[`supervisedTuningSpec`],h);let g=v(e,[`preferenceOptimizationSpec`]);g!=null&&_(n,[`preferenceOptimizationSpec`],g);let y=v(e,[`distillationSpec`]);y!=null&&_(n,[`distillationSpec`],y);let b=v(e,[`tuningDataStats`]);b!=null&&_(n,[`tuningDataStats`],b);let x=v(e,[`encryptionSpec`]);x!=null&&_(n,[`encryptionSpec`],x);let S=v(e,[`partnerModelTuningSpec`]);S!=null&&_(n,[`partnerModelTuningSpec`],S);let C=v(e,[`customBaseModel`]);C!=null&&_(n,[`customBaseModel`],C);let w=v(e,[`evaluateDatasetRuns`]);if(w!=null){let e=w;Array.isArray(e)&&(e=e.map(e=>e)),_(n,[`evaluateDatasetRuns`],e)}let T=v(e,[`experiment`]);T!=null&&_(n,[`experiment`],T);let E=v(e,[`fullFineTuningSpec`]);E!=null&&_(n,[`fullFineTuningSpec`],E);let D=v(e,[`labels`]);D!=null&&_(n,[`labels`],D);let O=v(e,[`outputUri`]);O!=null&&_(n,[`outputUri`],O);let k=v(e,[`pipelineJob`]);k!=null&&_(n,[`pipelineJob`],k);let A=v(e,[`serviceAccount`]);A!=null&&_(n,[`serviceAccount`],A);let j=v(e,[`tunedModelDisplayName`]);j!=null&&_(n,[`tunedModelDisplayName`],j);let M=v(e,[`tuningJobState`]);M!=null&&_(n,[`tuningJobState`],M);let ee=v(e,[`veoTuningSpec`]);ee!=null&&_(n,[`veoTuningSpec`],ee);let te=v(e,[`distillationSamplingSpec`]);te!=null&&_(n,[`distillationSamplingSpec`],te);let ne=v(e,[`tuningJobMetadata`]);return ne!=null&&_(n,[`tuningJobMetadata`],ne),n}function Su(e,t){let n={},r=v(e,[`sdkHttpResponse`]);r!=null&&_(n,[`sdkHttpResponse`],r);let i=v(e,[`name`]);i!=null&&_(n,[`name`],i);let a=v(e,[`metadata`]);a!=null&&_(n,[`metadata`],a);let o=v(e,[`done`]);o!=null&&_(n,[`done`],o);let s=v(e,[`error`]);return s!=null&&_(n,[`error`],s),n}function Cu(e,t){let n={},r=v(e,[`gcsUri`]);r!=null&&_(n,[`validationDatasetUri`],r);let i=v(e,[`vertexDatasetResource`]);return i!=null&&_(n,[`validationDatasetUri`],i),n}var wu=class extends h{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)}{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:je.JOB_STATE_QUEUED}}}}async getInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=pu(e);return n=g(`{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=>xu(e))}{let i=fu(e);return n=g(`{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=>bu(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=hu(e);return n=g(`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=gu(e),n=new Dt;return Object.assign(n,t),n})}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).`)}async cancel(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=au(e);return n=g(`{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=su(e),n=new Ot;return Object.assign(n,t),n})}{let i=iu(e);return n=g(`{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=ou(e),n=new Ot;return Object.assign(n,t),n})}}async tuneInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=du(e,e);return n=g(`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=>xu(e))}throw Error(`This method is only supported by the Gemini Enterprise Agent Platform (previously known as 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=uu(e);return n=g(`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=>Su(e))}}},Tu=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.`)}},Eu=8388608,Du=3,Ou=1e3,ku=2,Au=`x-goog-upload-status`;async function ju(e,t,n,r){let i=await Nu(e,t,n,r),a=await i?.json();if(i?.headers?.[Au]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);return a.file}async function Mu(e,t,n,r){let i=await Nu(e,t,n,r),a=await i?.json();if(i?.headers?.[Au]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);let o=ee(a),s=new Ht;return Object.assign(s,o),s}async function Nu(e,t,n,r){let i=t,a=r?.baseUrl||n.clientOptions.httpOptions?.baseUrl;if(a){let e=new URL(a),n=new URL(t);n.protocol=e.protocol,n.host=e.host,n.port=e.port,i=n.toString()}let o=0,s=0,c=new mt(new Response),l=`upload`;for(o=e.size;s<o;){let t=Math.min(Eu,o-s),a=e.slice(s,s+t);s+t>=o&&(l+=`, finalize`);let u=0,d=Ou;for(;u<Du;){let e=Object.assign(Object.assign({},r?.headers||{}),{"X-Goog-Upload-Command":l,"X-Goog-Upload-Offset":String(s),"Content-Length":String(t)});if(c=await n.request({path:``,body:a,httpMethod:`POST`,httpOptions:Object.assign(Object.assign({},r),{apiVersion:``,baseUrl:i,headers:e})}),c?.headers?.[Au])break;u++,await Fu(d),d*=ku}if(s+=t,c?.headers?.[Au]!==`active`)break;if(o<=s)throw Error(`All content has been uploaded, but the upload status is not finalized.`)}return c}async function Pu(e){return{size:e.size,type:e.type}}function Fu(e){return new Promise(t=>setTimeout(t,e))}var Iu=class{async upload(e,t,n,r){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await ju(e,t,n,r)}async uploadToFileSearchStore(e,t,n,r){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Mu(e,t,n,r)}async stat(e){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Pu(e)}},Lu=class{create(e,t,n){return new Ru(e,t,n)}},Ru=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()}},zu=`x-goog-api-key`,Bu=class{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(e.get(zu)===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(zu,this.apiKey)}}},Vu=class{getNextGenClient(){let e=this.httpOptions;if(this._nextGenClient===void 0){let e=this.httpOptions;this._nextGenClient=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 e?.extraBody&&console.warn(`GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.`),this._nextGenClient}get interactions(){return this._interactions===void 0?(console.warn(`GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.`),this._interactions=this.getNextGenClient().interactions,this._interactions):this._interactions}get webhooks(){return this._webhooks===void 0&&(this._webhooks=this.getNextGenClient().webhooks),this._webhooks}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=m(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 Bu(this.apiKey);this.apiClient=new Ps({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new Iu,downloader:new Tu}),this.models=new cc(this.apiClient),this.live=new Zs(this.apiClient,n,new Lu),this.batches=new Sr(this.apiClient),this.chats=new di(this.models,this.apiClient),this.caches=new ai(this.apiClient),this.files=new wi(this.apiClient),this.operations=new lc(this.apiClient),this.authTokens=new Oc(this.apiClient),this.tunings=new wu(this.apiClient),this.fileSearchStores=new Ic(this.apiClient)}};function Hu(e){return e.thought===!0}function Uu(e,t){return typeof t==`string`&&t.length>0?t:e}var Wu=/^[A-Za-z0-9+/]+={0,2}$/;function Gu(e){return!e||e.length%4!=0?!1:Wu.test(e)}function Ku(e,t){return e&&Gu(t)?t:void 0}function qu(e){let t=Ju(e);return e.startsWith(`claude-`)||e.startsWith(`gpt-oss-`)||t!==void 0&&t>=3}function Ju(e){let t=e.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(t)return Number.parseInt(t[1],10)}function Yu(e){let t=Ju(e);return t===void 0||t>=3}function Xu(e,t){let r=[],a=n(t.messages,e,t=>qu(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`)r.push({role:`user`,parts:[{text:i(t.content)}]});else{let e=t.content.map(e=>e.type===`text`?{text:i(e.text)}:{inlineData:{mimeType:e.mimeType,data:e.data}});if(e.length===0)continue;r.push({role:`user`,parts:e})}else if(t.role===`assistant`){let n=[],a=t.provider===e.provider&&t.model===e.id;for(let r of t.content)if(r.type===`text`){let e=Ku(a,r.textSignature);if((!r.text||r.text.trim()===``)&&!e)continue;n.push({text:i(r.text),...e&&{thoughtSignature:e}})}else if(r.type===`thinking`)if(a){let e=Ku(a,r.thinkingSignature);if((!r.thinking||r.thinking.trim()===``)&&!e)continue;n.push({thought:!0,text:i(r.thinking),...e&&{thoughtSignature:e}})}else{if(!r.thinking||r.thinking.trim()===``)continue;n.push({text:i(r.thinking)})}else if(r.type===`toolCall`){let t=Ku(a,r.thoughtSignature),i={functionCall:{name:r.name,args:r.arguments??{},...qu(e.id)?{id:r.id}:{}},...t&&{thoughtSignature:t}};n.push(i)}if(n.length===0)continue;r.push({role:`model`,parts:n})}else if(t.role===`toolResult`){let n=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
11
|
+
`),a=e.input.includes(`image`)?t.content.filter(e=>e.type===`image`):[],o=n.length>0,s=a.length>0,c=Yu(e.id),l=o?i(n):s?`(see attached image)`:``,u=a.map(e=>({inlineData:{mimeType:e.mimeType,data:e.data}})),d=qu(e.id),f={functionResponse:{name:t.toolName,response:t.isError?{error:l}:{output:l},...s&&c&&{parts:u},...d?{id:t.toolCallId}:{}}},p=r[r.length-1];p?.role===`user`&&p.parts?.some(e=>e.functionResponse)?p.parts.push(f):r.push({role:`user`,parts:[f]}),s&&!c&&r.push({role:`user`,parts:[{text:`Tool result image:`},...u]})}return r}var Zu=new Set([`$schema`,`$id`,`$anchor`,`$dynamicAnchor`,`$vocabulary`,`$comment`,`$defs`,`definitions`]);function Qu(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={};for(let[n,r]of Object.entries(e))Zu.has(n)||(t[n]=Qu(r));return t}function $u(e,t=!1,n=!0){if(e.length!==0)return[{functionDeclarations:e.map(e=>{let r=o(e,n),i=a(e,r);return{name:e.name,description:e.description,...t?{parameters:Qu(i)}:{parametersJsonSchema:i}}})}]}function ed(e){let t=Ju(e);return t!==void 0&&t>=3}function td(e){switch(e){case`auto`:return me.AUTO;case`none`:return me.NONE;case`any`:return me.ANY;default:return me.AUTO}}function nd(e,t,n){let r=e.some(e=>o(e,n)===!0);return t===`none`||t===`any`?td(t):r?me.VALIDATED:t?td(t):void 0}function rd(e){switch(e){case P.STOP:return`stop`;case P.MAX_TOKENS:return`length`;case P.BLOCKLIST:case P.PROHIBITED_CONTENT:case P.SPII:case P.SAFETY:case P.IMAGE_SAFETY:case P.IMAGE_PROHIBITED_CONTENT:case P.IMAGE_RECITATION:case P.IMAGE_OTHER:case P.RECITATION:case P.FINISH_REASON_UNSPECIFIED:case P.OTHER:case P.LANGUAGE:case P.MALFORMED_FUNCTION_CALL:case P.UNEXPECTED_TOOL_CALL:case P.NO_IMAGE:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}function id(e,t){return r(async()=>{try{return await e()}catch(e){throw e instanceof Error&&`status`in e&&!(`headers`in e)&&(e.headers=void 0),e}},{maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,signal:t?.signal})}export{nd as a,ed as c,he as d,rd as i,Vu as l,$u as n,Uu as o,Hu as r,id as s,Xu as t,ze as u};
|