@omniyat/aimodule 1.0.6 → 1.0.9

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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("file-type");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y={},v={exports:{}},E={};function T(){return i||(i=1,e=E,t=function(){if(o)return n;function e(e,t){"boolean"==typeof t&&(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))}return o=1,n=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.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(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},n),this._options.unref&&this._timer.unref(),!0},e.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)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var i=this._errors[o],r=i.message,s=(e[r]||0)+1;e[r]=s,s>=n&&(t=i,n=s)}return t},n}(),e.operation=function(n){var o=e.timeouts(n);return new t(o,{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 new Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<t.retries;i++)o.push(this.createTimeout(i,t));return e&&e.forever&&!o.length&&o.push(this.createTimeout(i,t)),o.sort(function(e,t){return e-t}),o},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},e.wrap=function(t,n,o){if(n instanceof Array&&(o=n,n=null),!o)for(var i in o=[],t)"function"==typeof t[i]&&o.push(i);for(var r=0;r<o.length;r++){var s=o[r],l=t[s];t[s]=function(o){var i=e.operation(n),r=Array.prototype.slice.call(arguments,1),s=r.pop();r.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),s.apply(this,arguments))}),i.attempt(function(){o.apply(t,r)})}.bind(t,l),t[s].options=n}}),E;var e,t}function I(){return s?r:(s=1,r=T())}function _(){if(l)return v.exports;l=1;const e=I(),t=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class n extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const o=(o,i)=>new Promise((r,s)=>{i={onFailedAttempt:()=>{},retries:10,...i};const l=e.operation(i);l.attempt(async e=>{try{r(await o(e))}catch(o){if(!(o instanceof Error))return void s(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));if(o instanceof n)l.stop(),s(o.originalError);else if(o instanceof TypeError&&(a=o.message,!t.includes(a)))l.stop(),s(o);else{((e,t,n)=>{const o=n.retries-(t-1);e.attemptNumber=t,e.retriesLeft=o})(o,e,i);try{await i.onFailedAttempt(o)}catch(e){return void s(e)}l.retry(o)||s(l.mainError())}}var a})});return v.exports=o,v.exports.default=o,v.exports.AbortError=n,v.exports}function S(){return a||(a=1,function(e){var t,n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y,v,E,T,I,S,A,C,O,b,R,w,N,P,M,D,U,x,L,k,q,G,F,H,j,V,B,J,Y,$,K,W,z,X,Q,Z,ee,te,ne,oe,ie,re,se=_();
1
+ "use strict";var e=require("file-type");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y={},v={exports:{}},E={};function T(){return i||(i=1,e=E,t=function(){if(o)return n;function e(e,t){"boolean"==typeof t&&(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))}return o=1,n=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.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(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},n),this._options.unref&&this._timer.unref(),!0},e.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)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var i=this._errors[o],r=i.message,s=(e[r]||0)+1;e[r]=s,s>=n&&(t=i,n=s)}return t},n}(),e.operation=function(n){var o=e.timeouts(n);return new t(o,{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 new Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<t.retries;i++)o.push(this.createTimeout(i,t));return e&&e.forever&&!o.length&&o.push(this.createTimeout(i,t)),o.sort(function(e,t){return e-t}),o},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},e.wrap=function(t,n,o){if(n instanceof Array&&(o=n,n=null),!o)for(var i in o=[],t)"function"==typeof t[i]&&o.push(i);for(var r=0;r<o.length;r++){var s=o[r],l=t[s];t[s]=function(o){var i=e.operation(n),r=Array.prototype.slice.call(arguments,1),s=r.pop();r.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),s.apply(this,arguments))}),i.attempt(function(){o.apply(t,r)})}.bind(t,l),t[s].options=n}}),E;var e,t}function I(){return s?r:(s=1,r=T())}function _(){if(l)return v.exports;l=1;const e=I(),t=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class n extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const o=(o,i)=>new Promise((r,s)=>{i={onFailedAttempt:()=>{},retries:10,...i};const l=e.operation(i);l.attempt(async e=>{try{r(await o(e))}catch(o){if(!(o instanceof Error))return void s(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));if(o instanceof n)l.stop(),s(o.originalError);else if(o instanceof TypeError&&(a=o.message,!t.includes(a)))l.stop(),s(o);else{((e,t,n)=>{const o=n.retries-(t-1);e.attemptNumber=t,e.retriesLeft=o})(o,e,i);try{await i.onFailedAttempt(o)}catch(e){return void s(e)}l.retry(o)||s(l.mainError())}}var a})});return v.exports=o,v.exports.default=o,v.exports.AbortError=n,v.exports}function S(){return a||(a=1,function(e){var t,n,o,i,r,s,l,a,u,c,p,d,h,f,m,g,y,v,E,T,I,S,A,C,O,b,R,w,N,P,M,D,U,x,L,k,q,G,F,H,j,V,B,J,$,Y,K,W,z,X,Q,Z,ee,te,ne,oe,ie,re,se=_();
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2025 Google LLC
@@ -24,7 +24,7 @@ class le{}function ae(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.pro
24
24
  * @license
25
25
  * Copyright 2025 Google LLC
26
26
  * SPDX-License-Identifier: Apache-2.0
27
- */(n));return t}(e))),ue(t,["generatedVideos"],e)}const o=ce(e,["raiMediaFilteredCount"]);null!=o&&ue(t,["raiMediaFilteredCount"],o);const i=ce(e,["raiMediaFilteredReasons"]);null!=i&&ue(t,["raiMediaFilteredReasons"],i);return t}(s)),t}function me(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}function ge(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}e.Outcome=void 0,(t=e.Outcome||(e.Outcome={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",e.Language=void 0,(n=e.Language||(e.Language={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON",e.FunctionResponseScheduling=void 0,(o=e.FunctionResponseScheduling||(e.FunctionResponseScheduling={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",o.SILENT="SILENT",o.WHEN_IDLE="WHEN_IDLE",o.INTERRUPT="INTERRUPT",e.Type=void 0,(i=e.Type||(e.Type={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL",e.ApiSpec=void 0,(r=e.ApiSpec||(e.ApiSpec={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",r.SIMPLE_SEARCH="SIMPLE_SEARCH",r.ELASTIC_SEARCH="ELASTIC_SEARCH",e.AuthType=void 0,(s=e.AuthType||(e.AuthType={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",s.NO_AUTH="NO_AUTH",s.API_KEY_AUTH="API_KEY_AUTH",s.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",s.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",s.OAUTH="OAUTH",s.OIDC_AUTH="OIDC_AUTH",e.HttpElementLocation=void 0,(l=e.HttpElementLocation||(e.HttpElementLocation={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",l.HTTP_IN_QUERY="HTTP_IN_QUERY",l.HTTP_IN_HEADER="HTTP_IN_HEADER",l.HTTP_IN_PATH="HTTP_IN_PATH",l.HTTP_IN_BODY="HTTP_IN_BODY",l.HTTP_IN_COOKIE="HTTP_IN_COOKIE",e.PhishBlockThreshold=void 0,(a=e.PhishBlockThreshold||(e.PhishBlockThreshold={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",a.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",a.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",a.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",a.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",a.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",a.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",e.Behavior=void 0,(u=e.Behavior||(e.Behavior={})).UNSPECIFIED="UNSPECIFIED",u.BLOCKING="BLOCKING",u.NON_BLOCKING="NON_BLOCKING",e.DynamicRetrievalConfigMode=void 0,(c=e.DynamicRetrievalConfigMode||(e.DynamicRetrievalConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",c.MODE_DYNAMIC="MODE_DYNAMIC",e.FunctionCallingConfigMode=void 0,(p=e.FunctionCallingConfigMode||(e.FunctionCallingConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",p.AUTO="AUTO",p.ANY="ANY",p.NONE="NONE",p.VALIDATED="VALIDATED",e.ThinkingLevel=void 0,(d=e.ThinkingLevel||(e.ThinkingLevel={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",d.LOW="LOW",d.MEDIUM="MEDIUM",d.HIGH="HIGH",d.MINIMAL="MINIMAL",e.HarmCategory=void 0,(h=e.HarmCategory||(e.HarmCategory={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",h.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",h.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",h.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",h.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",h.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",h.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",h.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",h.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",e.HarmBlockMethod=void 0,(f=e.HarmBlockMethod||(e.HarmBlockMethod={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",f.SEVERITY="SEVERITY",f.PROBABILITY="PROBABILITY",e.HarmBlockThreshold=void 0,(m=e.HarmBlockThreshold||(e.HarmBlockThreshold={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",m.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",m.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",m.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",m.BLOCK_NONE="BLOCK_NONE",m.OFF="OFF",e.FinishReason=void 0,(g=e.FinishReason||(e.FinishReason={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",g.STOP="STOP",g.MAX_TOKENS="MAX_TOKENS",g.SAFETY="SAFETY",g.RECITATION="RECITATION",g.LANGUAGE="LANGUAGE",g.OTHER="OTHER",g.BLOCKLIST="BLOCKLIST",g.PROHIBITED_CONTENT="PROHIBITED_CONTENT",g.SPII="SPII",g.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",g.IMAGE_SAFETY="IMAGE_SAFETY",g.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",g.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",g.NO_IMAGE="NO_IMAGE",g.IMAGE_RECITATION="IMAGE_RECITATION",g.IMAGE_OTHER="IMAGE_OTHER",e.HarmProbability=void 0,(y=e.HarmProbability||(e.HarmProbability={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",y.NEGLIGIBLE="NEGLIGIBLE",y.LOW="LOW",y.MEDIUM="MEDIUM",y.HIGH="HIGH",e.HarmSeverity=void 0,(v=e.HarmSeverity||(e.HarmSeverity={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",v.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",v.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",v.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",v.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",e.UrlRetrievalStatus=void 0,(E=e.UrlRetrievalStatus||(e.UrlRetrievalStatus={})).URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",E.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",E.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",E.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",E.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE",e.BlockedReason=void 0,(T=e.BlockedReason||(e.BlockedReason={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",T.SAFETY="SAFETY",T.OTHER="OTHER",T.BLOCKLIST="BLOCKLIST",T.PROHIBITED_CONTENT="PROHIBITED_CONTENT",T.IMAGE_SAFETY="IMAGE_SAFETY",T.MODEL_ARMOR="MODEL_ARMOR",T.JAILBREAK="JAILBREAK",e.TrafficType=void 0,(I=e.TrafficType||(e.TrafficType={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",I.ON_DEMAND="ON_DEMAND",I.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",e.Modality=void 0,(S=e.Modality||(e.Modality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",S.TEXT="TEXT",S.IMAGE="IMAGE",S.AUDIO="AUDIO",e.MediaResolution=void 0,(A=e.MediaResolution||(e.MediaResolution={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",A.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",A.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",A.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.TuningMode=void 0,(C=e.TuningMode||(e.TuningMode={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",C.TUNING_MODE_FULL="TUNING_MODE_FULL",C.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",e.AdapterSize=void 0,(O=e.AdapterSize||(e.AdapterSize={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",O.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",O.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",O.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",O.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",O.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",O.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",e.JobState=void 0,(b=e.JobState||(e.JobState={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",b.JOB_STATE_QUEUED="JOB_STATE_QUEUED",b.JOB_STATE_PENDING="JOB_STATE_PENDING",b.JOB_STATE_RUNNING="JOB_STATE_RUNNING",b.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",b.JOB_STATE_FAILED="JOB_STATE_FAILED",b.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",b.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",b.JOB_STATE_PAUSED="JOB_STATE_PAUSED",b.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",b.JOB_STATE_UPDATING="JOB_STATE_UPDATING",b.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",e.TuningTask=void 0,(R=e.TuningTask||(e.TuningTask={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",R.TUNING_TASK_I2V="TUNING_TASK_I2V",R.TUNING_TASK_T2V="TUNING_TASK_T2V",R.TUNING_TASK_R2V="TUNING_TASK_R2V",e.PartMediaResolutionLevel=void 0,(w=e.PartMediaResolutionLevel||(e.PartMediaResolutionLevel={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",w.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",w.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",w.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",w.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",e.ResourceScope=void 0,(e.ResourceScope||(e.ResourceScope={})).COLLECTION="COLLECTION",e.FeatureSelectionPreference=void 0,(N=e.FeatureSelectionPreference||(e.FeatureSelectionPreference={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",N.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",N.BALANCED="BALANCED",N.PRIORITIZE_COST="PRIORITIZE_COST",e.Environment=void 0,(P=e.Environment||(e.Environment={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",P.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",e.EmbeddingApiType=void 0,(M=e.EmbeddingApiType||(e.EmbeddingApiType={})).PREDICT="PREDICT",M.EMBED_CONTENT="EMBED_CONTENT",e.SafetyFilterLevel=void 0,(D=e.SafetyFilterLevel||(e.SafetyFilterLevel={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",D.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",D.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",D.BLOCK_NONE="BLOCK_NONE",e.PersonGeneration=void 0,(U=e.PersonGeneration||(e.PersonGeneration={})).DONT_ALLOW="DONT_ALLOW",U.ALLOW_ADULT="ALLOW_ADULT",U.ALLOW_ALL="ALLOW_ALL",e.ImagePromptLanguage=void 0,(x=e.ImagePromptLanguage||(e.ImagePromptLanguage={})).auto="auto",x.en="en",x.ja="ja",x.ko="ko",x.hi="hi",x.zh="zh",x.pt="pt",x.es="es",e.MaskReferenceMode=void 0,(L=e.MaskReferenceMode||(e.MaskReferenceMode={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",L.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",L.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",L.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",L.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",e.ControlReferenceType=void 0,(k=e.ControlReferenceType||(e.ControlReferenceType={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",k.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",k.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",k.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",e.SubjectReferenceType=void 0,(q=e.SubjectReferenceType||(e.SubjectReferenceType={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",q.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",q.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",q.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",e.EditMode=void 0,(G=e.EditMode||(e.EditMode={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",G.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",G.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",G.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",G.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",G.EDIT_MODE_STYLE="EDIT_MODE_STYLE",G.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",G.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",e.SegmentMode=void 0,(F=e.SegmentMode||(e.SegmentMode={})).FOREGROUND="FOREGROUND",F.BACKGROUND="BACKGROUND",F.PROMPT="PROMPT",F.SEMANTIC="SEMANTIC",F.INTERACTIVE="INTERACTIVE",e.VideoGenerationReferenceType=void 0,(H=e.VideoGenerationReferenceType||(e.VideoGenerationReferenceType={})).ASSET="ASSET",H.STYLE="STYLE",e.VideoGenerationMaskMode=void 0,(j=e.VideoGenerationMaskMode||(e.VideoGenerationMaskMode={})).INSERT="INSERT",j.REMOVE="REMOVE",j.REMOVE_STATIC="REMOVE_STATIC",j.OUTPAINT="OUTPAINT",e.VideoCompressionQuality=void 0,(V=e.VideoCompressionQuality||(e.VideoCompressionQuality={})).OPTIMIZED="OPTIMIZED",V.LOSSLESS="LOSSLESS",e.TuningMethod=void 0,(B=e.TuningMethod||(e.TuningMethod={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",B.PREFERENCE_TUNING="PREFERENCE_TUNING",B.DISTILLATION="DISTILLATION",e.DocumentState=void 0,(J=e.DocumentState||(e.DocumentState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",J.STATE_PENDING="STATE_PENDING",J.STATE_ACTIVE="STATE_ACTIVE",J.STATE_FAILED="STATE_FAILED",e.FileState=void 0,(Y=e.FileState||(e.FileState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",Y.PROCESSING="PROCESSING",Y.ACTIVE="ACTIVE",Y.FAILED="FAILED",e.FileSource=void 0,($=e.FileSource||(e.FileSource={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",$.UPLOADED="UPLOADED",$.GENERATED="GENERATED",$.REGISTERED="REGISTERED",e.TurnCompleteReason=void 0,(K=e.TurnCompleteReason||(e.TurnCompleteReason={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",K.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",K.RESPONSE_REJECTED="RESPONSE_REJECTED",K.NEED_MORE_INPUT="NEED_MORE_INPUT",e.MediaModality=void 0,(W=e.MediaModality||(e.MediaModality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",W.TEXT="TEXT",W.IMAGE="IMAGE",W.VIDEO="VIDEO",W.AUDIO="AUDIO",W.DOCUMENT="DOCUMENT",e.VadSignalType=void 0,(z=e.VadSignalType||(e.VadSignalType={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",z.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",z.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",e.VoiceActivityType=void 0,(X=e.VoiceActivityType||(e.VoiceActivityType={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",X.ACTIVITY_START="ACTIVITY_START",X.ACTIVITY_END="ACTIVITY_END",e.StartSensitivity=void 0,(Q=e.StartSensitivity||(e.StartSensitivity={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",Q.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",Q.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",e.EndSensitivity=void 0,(Z=e.EndSensitivity||(e.EndSensitivity={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",Z.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",Z.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",e.ActivityHandling=void 0,(ee=e.ActivityHandling||(e.ActivityHandling={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",ee.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",ee.NO_INTERRUPTION="NO_INTERRUPTION",e.TurnCoverage=void 0,(te=e.TurnCoverage||(e.TurnCoverage={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",te.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",te.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",e.Scale=void 0,(ne=e.Scale||(e.Scale={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",ne.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",ne.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",ne.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",ne.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",ne.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",ne.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",ne.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",ne.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",ne.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",ne.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",ne.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",ne.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",e.MusicGenerationMode=void 0,(oe=e.MusicGenerationMode||(e.MusicGenerationMode={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",oe.QUALITY="QUALITY",oe.DIVERSITY="DIVERSITY",oe.VOCALIZATION="VOCALIZATION",e.LiveMusicPlaybackControl=void 0,(ie=e.LiveMusicPlaybackControl||(e.LiveMusicPlaybackControl={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",ie.PLAY="PLAY",ie.PAUSE="PAUSE",ie.STOP="STOP",ie.RESET_CONTEXT="RESET_CONTEXT";function ye(e){return{text:e}}function ve(e){return"object"==typeof e&&null!==e&&("fileData"in e||"text"in e||"functionCall"in e||"functionResponse"in e||"inlineData"in e||"videoMetadata"in e||"codeExecutionResult"in e||"executableCode"in e)}function Ee(e){const t=[];if("string"==typeof e)t.push(ye(e));else if(ve(e))t.push(e);else{if(!Array.isArray(e))throw new Error("partOrString must be a Part object, string, or array");if(0===e.length)throw new Error("partOrString cannot be an empty array");for(const n of e)if("string"==typeof n)t.push(ye(n));else{if(!ve(n))throw new Error("element in PartUnion must be a Part object or string");t.push(n)}}return t}class Te{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class Ie{get text(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let a="",u=!1;const c=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"text"===t||"thought"===t||"thoughtSignature"===t||null===n&&void 0===n||c.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,a+=e.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?a:void 0}get data(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let a="";const u=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"inlineData"===t||null===n&&void 0===n||u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(a+=atob(e.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),a.length>0?btoa(a):void 0}get functionCalls(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const a=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);return 0!==(null==a?void 0:a.length)?a:void 0}get executableCode(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.code:void 0}get codeExecutionResult(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.output:void 0}}class _e{}class Se{}class Ae{}class Ce{}class Oe{}class be{}class Re{}class we{}class Ne{}class Pe{}class Me{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Me;let o;const i=e;return o=t?fe(i):he(i),Object.assign(n,o),n}}class De{}class Ue{}class xe{}class Le{}class ke{}class qe{}class Ge{}class Fe{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Fe,o=me(e);return Object.assign(n,o),n}}class He{}class je{}class Ve{}class Be{}class Je{}class Ye{get text(){var e,t,n;let o="",i=!1;const r=[];for(const s of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(s))"text"!==e&&"thought"!==e&&null!==t&&r.push(e);if("string"==typeof s.text){if("boolean"==typeof s.thought&&s.thought)continue;i=!0,o+=s.text}}return r.length>0&&console.warn(`there are non-text parts ${r} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),i?o:void 0}get data(){var e,t,n;let o="";const i=[];for(const r of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(r))"inlineData"!==e&&null!==t&&i.push(e);r.inlineData&&"string"==typeof r.inlineData.data&&(o+=atob(r.inlineData.data))}return i.length>0&&console.warn(`there are non-data parts ${i} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),o.length>0?btoa(o):void 0}}class $e{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Ke{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Ke,o=ge(e);return Object.assign(n,o),n}}
27
+ */(n));return t}(e))),ue(t,["generatedVideos"],e)}const o=ce(e,["raiMediaFilteredCount"]);null!=o&&ue(t,["raiMediaFilteredCount"],o);const i=ce(e,["raiMediaFilteredReasons"]);null!=i&&ue(t,["raiMediaFilteredReasons"],i);return t}(s)),t}function me(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}function ge(e){const t={},n=ce(e,["name"]);null!=n&&ue(t,["name"],n);const o=ce(e,["metadata"]);null!=o&&ue(t,["metadata"],o);const i=ce(e,["done"]);null!=i&&ue(t,["done"],i);const r=ce(e,["error"]);null!=r&&ue(t,["error"],r);const s=ce(e,["response"]);return null!=s&&ue(t,["response"],function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["parent"]);null!=o&&ue(t,["parent"],o);const i=ce(e,["documentName"]);null!=i&&ue(t,["documentName"],i);return t}(s)),t}e.Outcome=void 0,(t=e.Outcome||(e.Outcome={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",e.Language=void 0,(n=e.Language||(e.Language={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON",e.FunctionResponseScheduling=void 0,(o=e.FunctionResponseScheduling||(e.FunctionResponseScheduling={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",o.SILENT="SILENT",o.WHEN_IDLE="WHEN_IDLE",o.INTERRUPT="INTERRUPT",e.Type=void 0,(i=e.Type||(e.Type={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL",e.ApiSpec=void 0,(r=e.ApiSpec||(e.ApiSpec={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",r.SIMPLE_SEARCH="SIMPLE_SEARCH",r.ELASTIC_SEARCH="ELASTIC_SEARCH",e.AuthType=void 0,(s=e.AuthType||(e.AuthType={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",s.NO_AUTH="NO_AUTH",s.API_KEY_AUTH="API_KEY_AUTH",s.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",s.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",s.OAUTH="OAUTH",s.OIDC_AUTH="OIDC_AUTH",e.HttpElementLocation=void 0,(l=e.HttpElementLocation||(e.HttpElementLocation={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",l.HTTP_IN_QUERY="HTTP_IN_QUERY",l.HTTP_IN_HEADER="HTTP_IN_HEADER",l.HTTP_IN_PATH="HTTP_IN_PATH",l.HTTP_IN_BODY="HTTP_IN_BODY",l.HTTP_IN_COOKIE="HTTP_IN_COOKIE",e.PhishBlockThreshold=void 0,(a=e.PhishBlockThreshold||(e.PhishBlockThreshold={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",a.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",a.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",a.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",a.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",a.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",a.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",e.Behavior=void 0,(u=e.Behavior||(e.Behavior={})).UNSPECIFIED="UNSPECIFIED",u.BLOCKING="BLOCKING",u.NON_BLOCKING="NON_BLOCKING",e.DynamicRetrievalConfigMode=void 0,(c=e.DynamicRetrievalConfigMode||(e.DynamicRetrievalConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",c.MODE_DYNAMIC="MODE_DYNAMIC",e.FunctionCallingConfigMode=void 0,(p=e.FunctionCallingConfigMode||(e.FunctionCallingConfigMode={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",p.AUTO="AUTO",p.ANY="ANY",p.NONE="NONE",p.VALIDATED="VALIDATED",e.ThinkingLevel=void 0,(d=e.ThinkingLevel||(e.ThinkingLevel={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",d.LOW="LOW",d.MEDIUM="MEDIUM",d.HIGH="HIGH",d.MINIMAL="MINIMAL",e.HarmCategory=void 0,(h=e.HarmCategory||(e.HarmCategory={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",h.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",h.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",h.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",h.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",h.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",h.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",h.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",h.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",h.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",e.HarmBlockMethod=void 0,(f=e.HarmBlockMethod||(e.HarmBlockMethod={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",f.SEVERITY="SEVERITY",f.PROBABILITY="PROBABILITY",e.HarmBlockThreshold=void 0,(m=e.HarmBlockThreshold||(e.HarmBlockThreshold={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",m.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",m.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",m.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",m.BLOCK_NONE="BLOCK_NONE",m.OFF="OFF",e.FinishReason=void 0,(g=e.FinishReason||(e.FinishReason={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",g.STOP="STOP",g.MAX_TOKENS="MAX_TOKENS",g.SAFETY="SAFETY",g.RECITATION="RECITATION",g.LANGUAGE="LANGUAGE",g.OTHER="OTHER",g.BLOCKLIST="BLOCKLIST",g.PROHIBITED_CONTENT="PROHIBITED_CONTENT",g.SPII="SPII",g.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",g.IMAGE_SAFETY="IMAGE_SAFETY",g.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",g.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",g.NO_IMAGE="NO_IMAGE",g.IMAGE_RECITATION="IMAGE_RECITATION",g.IMAGE_OTHER="IMAGE_OTHER",e.HarmProbability=void 0,(y=e.HarmProbability||(e.HarmProbability={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",y.NEGLIGIBLE="NEGLIGIBLE",y.LOW="LOW",y.MEDIUM="MEDIUM",y.HIGH="HIGH",e.HarmSeverity=void 0,(v=e.HarmSeverity||(e.HarmSeverity={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",v.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",v.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",v.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",v.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",e.UrlRetrievalStatus=void 0,(E=e.UrlRetrievalStatus||(e.UrlRetrievalStatus={})).URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",E.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",E.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",E.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",E.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE",e.BlockedReason=void 0,(T=e.BlockedReason||(e.BlockedReason={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",T.SAFETY="SAFETY",T.OTHER="OTHER",T.BLOCKLIST="BLOCKLIST",T.PROHIBITED_CONTENT="PROHIBITED_CONTENT",T.IMAGE_SAFETY="IMAGE_SAFETY",T.MODEL_ARMOR="MODEL_ARMOR",T.JAILBREAK="JAILBREAK",e.TrafficType=void 0,(I=e.TrafficType||(e.TrafficType={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",I.ON_DEMAND="ON_DEMAND",I.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",e.Modality=void 0,(S=e.Modality||(e.Modality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",S.TEXT="TEXT",S.IMAGE="IMAGE",S.AUDIO="AUDIO",e.MediaResolution=void 0,(A=e.MediaResolution||(e.MediaResolution={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",A.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",A.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",A.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.TuningMode=void 0,(C=e.TuningMode||(e.TuningMode={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",C.TUNING_MODE_FULL="TUNING_MODE_FULL",C.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",e.AdapterSize=void 0,(O=e.AdapterSize||(e.AdapterSize={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",O.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",O.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",O.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",O.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",O.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",O.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",e.JobState=void 0,(b=e.JobState||(e.JobState={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",b.JOB_STATE_QUEUED="JOB_STATE_QUEUED",b.JOB_STATE_PENDING="JOB_STATE_PENDING",b.JOB_STATE_RUNNING="JOB_STATE_RUNNING",b.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",b.JOB_STATE_FAILED="JOB_STATE_FAILED",b.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",b.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",b.JOB_STATE_PAUSED="JOB_STATE_PAUSED",b.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",b.JOB_STATE_UPDATING="JOB_STATE_UPDATING",b.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",e.TuningTask=void 0,(R=e.TuningTask||(e.TuningTask={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",R.TUNING_TASK_I2V="TUNING_TASK_I2V",R.TUNING_TASK_T2V="TUNING_TASK_T2V",R.TUNING_TASK_R2V="TUNING_TASK_R2V",e.PartMediaResolutionLevel=void 0,(w=e.PartMediaResolutionLevel||(e.PartMediaResolutionLevel={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",w.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",w.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",w.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",w.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",e.ResourceScope=void 0,(e.ResourceScope||(e.ResourceScope={})).COLLECTION="COLLECTION",e.FeatureSelectionPreference=void 0,(N=e.FeatureSelectionPreference||(e.FeatureSelectionPreference={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",N.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",N.BALANCED="BALANCED",N.PRIORITIZE_COST="PRIORITIZE_COST",e.Environment=void 0,(P=e.Environment||(e.Environment={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",P.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",e.EmbeddingApiType=void 0,(M=e.EmbeddingApiType||(e.EmbeddingApiType={})).PREDICT="PREDICT",M.EMBED_CONTENT="EMBED_CONTENT",e.SafetyFilterLevel=void 0,(D=e.SafetyFilterLevel||(e.SafetyFilterLevel={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",D.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",D.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",D.BLOCK_NONE="BLOCK_NONE",e.PersonGeneration=void 0,(U=e.PersonGeneration||(e.PersonGeneration={})).DONT_ALLOW="DONT_ALLOW",U.ALLOW_ADULT="ALLOW_ADULT",U.ALLOW_ALL="ALLOW_ALL",e.ImagePromptLanguage=void 0,(x=e.ImagePromptLanguage||(e.ImagePromptLanguage={})).auto="auto",x.en="en",x.ja="ja",x.ko="ko",x.hi="hi",x.zh="zh",x.pt="pt",x.es="es",e.MaskReferenceMode=void 0,(L=e.MaskReferenceMode||(e.MaskReferenceMode={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",L.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",L.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",L.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",L.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",e.ControlReferenceType=void 0,(k=e.ControlReferenceType||(e.ControlReferenceType={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",k.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",k.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",k.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",e.SubjectReferenceType=void 0,(q=e.SubjectReferenceType||(e.SubjectReferenceType={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",q.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",q.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",q.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",e.EditMode=void 0,(G=e.EditMode||(e.EditMode={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",G.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",G.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",G.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",G.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",G.EDIT_MODE_STYLE="EDIT_MODE_STYLE",G.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",G.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",e.SegmentMode=void 0,(F=e.SegmentMode||(e.SegmentMode={})).FOREGROUND="FOREGROUND",F.BACKGROUND="BACKGROUND",F.PROMPT="PROMPT",F.SEMANTIC="SEMANTIC",F.INTERACTIVE="INTERACTIVE",e.VideoGenerationReferenceType=void 0,(H=e.VideoGenerationReferenceType||(e.VideoGenerationReferenceType={})).ASSET="ASSET",H.STYLE="STYLE",e.VideoGenerationMaskMode=void 0,(j=e.VideoGenerationMaskMode||(e.VideoGenerationMaskMode={})).INSERT="INSERT",j.REMOVE="REMOVE",j.REMOVE_STATIC="REMOVE_STATIC",j.OUTPAINT="OUTPAINT",e.VideoCompressionQuality=void 0,(V=e.VideoCompressionQuality||(e.VideoCompressionQuality={})).OPTIMIZED="OPTIMIZED",V.LOSSLESS="LOSSLESS",e.TuningMethod=void 0,(B=e.TuningMethod||(e.TuningMethod={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",B.PREFERENCE_TUNING="PREFERENCE_TUNING",B.DISTILLATION="DISTILLATION",e.DocumentState=void 0,(J=e.DocumentState||(e.DocumentState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",J.STATE_PENDING="STATE_PENDING",J.STATE_ACTIVE="STATE_ACTIVE",J.STATE_FAILED="STATE_FAILED",e.FileState=void 0,($=e.FileState||(e.FileState={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",$.PROCESSING="PROCESSING",$.ACTIVE="ACTIVE",$.FAILED="FAILED",e.FileSource=void 0,(Y=e.FileSource||(e.FileSource={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",Y.UPLOADED="UPLOADED",Y.GENERATED="GENERATED",Y.REGISTERED="REGISTERED",e.TurnCompleteReason=void 0,(K=e.TurnCompleteReason||(e.TurnCompleteReason={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",K.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",K.RESPONSE_REJECTED="RESPONSE_REJECTED",K.NEED_MORE_INPUT="NEED_MORE_INPUT",e.MediaModality=void 0,(W=e.MediaModality||(e.MediaModality={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",W.TEXT="TEXT",W.IMAGE="IMAGE",W.VIDEO="VIDEO",W.AUDIO="AUDIO",W.DOCUMENT="DOCUMENT",e.VadSignalType=void 0,(z=e.VadSignalType||(e.VadSignalType={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",z.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",z.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",e.VoiceActivityType=void 0,(X=e.VoiceActivityType||(e.VoiceActivityType={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",X.ACTIVITY_START="ACTIVITY_START",X.ACTIVITY_END="ACTIVITY_END",e.StartSensitivity=void 0,(Q=e.StartSensitivity||(e.StartSensitivity={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",Q.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",Q.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",e.EndSensitivity=void 0,(Z=e.EndSensitivity||(e.EndSensitivity={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",Z.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",Z.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",e.ActivityHandling=void 0,(ee=e.ActivityHandling||(e.ActivityHandling={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",ee.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",ee.NO_INTERRUPTION="NO_INTERRUPTION",e.TurnCoverage=void 0,(te=e.TurnCoverage||(e.TurnCoverage={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",te.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",te.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",e.Scale=void 0,(ne=e.Scale||(e.Scale={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",ne.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",ne.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",ne.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",ne.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",ne.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",ne.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",ne.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",ne.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",ne.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",ne.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",ne.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",ne.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",e.MusicGenerationMode=void 0,(oe=e.MusicGenerationMode||(e.MusicGenerationMode={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",oe.QUALITY="QUALITY",oe.DIVERSITY="DIVERSITY",oe.VOCALIZATION="VOCALIZATION",e.LiveMusicPlaybackControl=void 0,(ie=e.LiveMusicPlaybackControl||(e.LiveMusicPlaybackControl={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",ie.PLAY="PLAY",ie.PAUSE="PAUSE",ie.STOP="STOP",ie.RESET_CONTEXT="RESET_CONTEXT";function ye(e){return{text:e}}function ve(e){return"object"==typeof e&&null!==e&&("fileData"in e||"text"in e||"functionCall"in e||"functionResponse"in e||"inlineData"in e||"videoMetadata"in e||"codeExecutionResult"in e||"executableCode"in e)}function Ee(e){const t=[];if("string"==typeof e)t.push(ye(e));else if(ve(e))t.push(e);else{if(!Array.isArray(e))throw new Error("partOrString must be a Part object, string, or array");if(0===e.length)throw new Error("partOrString cannot be an empty array");for(const n of e)if("string"==typeof n)t.push(ye(n));else{if(!ve(n))throw new Error("element in PartUnion must be a Part object or string");t.push(n)}}return t}class Te{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class Ie{get text(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let a="",u=!1;const c=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"text"===t||"thought"===t||"thoughtSignature"===t||null===n&&void 0===n||c.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,a+=e.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?a:void 0}get data(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let a="";const u=[];for(const e of null!==(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)&&void 0!==l?l:[]){for(const[t,n]of Object.entries(e))"inlineData"===t||null===n&&void 0===n||u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(a+=atob(e.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),a.length>0?btoa(a):void 0}get functionCalls(){var e,t,n,o,i,r,s,l;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const a=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);return 0!==(null==a?void 0:a.length)?a:void 0}get executableCode(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.code:void 0}get codeExecutionResult(){var e,t,n,o,i,r,s,l,a;if(0===(null===(o=null===(n=null===(t=null===(e=this.candidates)||void 0===e?void 0:e[0])||void 0===t?void 0:t.content)||void 0===n?void 0:n.parts)||void 0===o?void 0:o.length))return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const u=null===(l=null===(s=null===(r=null===(i=this.candidates)||void 0===i?void 0:i[0])||void 0===r?void 0:r.content)||void 0===s?void 0:s.parts)||void 0===l?void 0:l.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);return 0!==(null==u?void 0:u.length)?null===(a=null==u?void 0:u[0])||void 0===a?void 0:a.output:void 0}}class _e{}class Se{}class Ae{}class Ce{}class Oe{}class be{}class Re{}class we{}class Ne{}class Pe{}class Me{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Me;let o;const i=e;return o=t?fe(i):he(i),Object.assign(n,o),n}}class De{}class Ue{}class xe{}class Le{}class ke{}class qe{}class Ge{}class Fe{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Fe,o=me(e);return Object.assign(n,o),n}}class He{}class je{}class Ve{}class Be{}class Je{}class $e{get text(){var e,t,n;let o="",i=!1;const r=[];for(const s of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(s))"text"!==e&&"thought"!==e&&null!==t&&r.push(e);if("string"==typeof s.text){if("boolean"==typeof s.thought&&s.thought)continue;i=!0,o+=s.text}}return r.length>0&&console.warn(`there are non-text parts ${r} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),i?o:void 0}get data(){var e,t,n;let o="";const i=[];for(const r of null!==(n=null===(t=null===(e=this.serverContent)||void 0===e?void 0:e.modelTurn)||void 0===t?void 0:t.parts)&&void 0!==n?n:[]){for(const[e,t]of Object.entries(r))"inlineData"!==e&&null!==t&&i.push(e);r.inlineData&&"string"==typeof r.inlineData.data&&(o+=atob(r.inlineData.data))}return i.length>0&&console.warn(`there are non-data parts ${i} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),o.length>0?btoa(o):void 0}}class Ye{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Ke{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){const n=new Ke,o=ge(e);return Object.assign(n,o),n}}
28
28
  /**
29
29
  * @license
30
30
  * Copyright 2025 Google LLC
@@ -50,12 +50,12 @@ function bt(e){const t={},n=ce(e,["responsesFile"]);null!=n&&ue(t,["fileName"],n
50
50
  * @license
51
51
  * Copyright 2025 Google LLC
52
52
  * SPDX-License-Identifier: Apache-2.0
53
- */function Ft(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],function(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Ht(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>Ft(e))),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],Ft(st(s)));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);null!=n&&ue(t,["enableWidget"],n);return t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);null!=n&&ue(t,["timeRangeFilter"],n);return t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);if(void 0!==t&&null!=a&&ue(t,["toolConfig"],function(e){const t={},n=ce(e,["retrievalConfig"]);null!=n&&ue(t,["retrievalConfig"],n);const o=ce(e,["functionCallingConfig"]);null!=o&&ue(t,["functionCallingConfig"],function(e){const t={},n=ce(e,["allowedFunctionNames"]);null!=n&&ue(t,["allowedFunctionNames"],n);const o=ce(e,["mode"]);null!=o&&ue(t,["mode"],o);if(void 0!==ce(e,["streamFunctionCallArguments"]))throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(o));return t}(a)),void 0!==ce(e,["kmsKeyName"]))throw new Error("kmsKeyName parameter is not supported in Gemini API.");return{}}function jt(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],st(s));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);null!=l&&ue(t,["responseJsonSchema"],l);if(void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);void 0!==t&&null!=a&&ue(t,["toolConfig"],a);const u=ce(e,["kmsKeyName"]);return void 0!==t&&null!=u&&ue(t,["encryption_spec","kmsKeyName"],u),{}}function Vt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Bt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Jt(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}function Yt(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}
53
+ */function Ft(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],function(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Ht(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>Ft(e))),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],Ft(st(s)));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);null!=n&&ue(t,["enableWidget"],n);return t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);null!=n&&ue(t,["timeRangeFilter"],n);return t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);if(void 0!==t&&null!=a&&ue(t,["toolConfig"],function(e){const t={},n=ce(e,["retrievalConfig"]);null!=n&&ue(t,["retrievalConfig"],n);const o=ce(e,["functionCallingConfig"]);null!=o&&ue(t,["functionCallingConfig"],function(e){const t={},n=ce(e,["allowedFunctionNames"]);null!=n&&ue(t,["allowedFunctionNames"],n);const o=ce(e,["mode"]);null!=o&&ue(t,["mode"],o);if(void 0!==ce(e,["streamFunctionCallArguments"]))throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(o));return t}(a)),void 0!==ce(e,["kmsKeyName"]))throw new Error("kmsKeyName parameter is not supported in Gemini API.");return{}}function jt(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o);const i=ce(e,["displayName"]);void 0!==t&&null!=i&&ue(t,["displayName"],i);const r=ce(e,["contents"]);if(void 0!==t&&null!=r){let e=at(r);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["contents"],e)}const s=ce(e,["systemInstruction"]);void 0!==t&&null!=s&&ue(t,["systemInstruction"],st(s));const l=ce(e,["tools"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);null!=l&&ue(t,["responseJsonSchema"],l);if(void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(e))),ue(t,["tools"],e)}const a=ce(e,["toolConfig"]);void 0!==t&&null!=a&&ue(t,["toolConfig"],a);const u=ce(e,["kmsKeyName"]);return void 0!==t&&null!=u&&ue(t,["encryption_spec","kmsKeyName"],u),{}}function Vt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Bt(e){const t={},n=ce(e,["config"]);return null!=n&&function(e,t){const n=ce(e,["pageSize"]);void 0!==t&&null!=n&&ue(t,["_query","pageSize"],n);const o=ce(e,["pageToken"]);void 0!==t&&null!=o&&ue(t,["_query","pageToken"],o)}(n,t),t}function Jt(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}function $t(e,t){const n={},o=ce(t,["name"]);null!=o&&ue(n,["_url","name"],mt(e,o));const i=ce(t,["config"]);return null!=i&&function(e,t){const n=ce(e,["ttl"]);void 0!==t&&null!=n&&ue(t,["ttl"],n);const o=ce(e,["expireTime"]);void 0!==t&&null!=o&&ue(t,["expireTime"],o)}(i,n),n}
54
54
  /**
55
55
  * @license
56
56
  * Copyright 2025 Google LLC
57
57
  * SPDX-License-Identifier: Apache-2.0
58
- */class $t extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(t),t)}async create(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&jt(i,n),n}(this.apiClient,e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&Ht(i,n),n}(this.apiClient,e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Yt(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=Jt(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Bt(e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}{const t=Vt(e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}}}function Kt(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function Wt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function zt(e){return this instanceof zt?(this.v=e,this):new zt(e)}function Xt(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,i=n.apply(e,t||[]),r=[];return o=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){i[e]&&(o[e]=function(t){return new Promise(function(n,o){r.push([e,t,n,o])>1||l(e,t)})},t&&(o[e]=t(o[e])))}function l(e,t){try{(n=i[e](t)).value instanceof zt?Promise.resolve(n.value.v).then(a,u):c(r[0][2],n)}catch(e){c(r[0][3],e)}var n}function a(e){l("next",e)}function u(e){l("throw",e)}function c(e,t){e(t),r.shift(),r.length&&l(r[0][0],r[0][1])}}function Qt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Wt(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise(function(o,i){(function(e,t,n,o){Promise.resolve(o).then(function(t){e({value:t,done:n})},t)})(o,i,(t=e[n](t)).done,t.value)})}}}
58
+ */class Yt extends le{constructor(t){super(),this.apiClient=t,this.list=async(t={})=>new qt(e.PagedItem.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(t),t)}async create(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&jt(i,n),n}(this.apiClient,e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["model"],ze(e,o));const i=ce(t,["config"]);return null!=i&&Ht(i,n),n}(this.apiClient,e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["name"]);return null!=o&&ue(n,["_url","name"],mt(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new xe;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=$t(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>e)}{const t=Jt(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>e)}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Bt(e);return s=ae("cachedContents",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}{const t=Vt(e);return s=ae("cachedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cachedContents"],e)}return t}(e),n=new Le;return Object.assign(n,t),n})}}}function Kt(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function Wt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function zt(e){return this instanceof zt?(this.v=e,this):new zt(e)}function Xt(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,i=n.apply(e,t||[]),r=[];return o=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){i[e]&&(o[e]=function(t){return new Promise(function(n,o){r.push([e,t,n,o])>1||l(e,t)})},t&&(o[e]=t(o[e])))}function l(e,t){try{(n=i[e](t)).value instanceof zt?Promise.resolve(n.value.v).then(a,u):c(r[0][2],n)}catch(e){c(r[0][3],e)}var n}function a(e){l("next",e)}function u(e){l("throw",e)}function c(e,t){e(t),r.shift(),r.length&&l(r[0][0],r[0][1])}}function Qt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Wt(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise(function(o,i){(function(e,t,n,o){Promise.resolve(o).then(function(t){e({value:t,done:n})},t)})(o,i,(t=e[n](t)).done,t.value)})}}}
59
59
  /**
60
60
  * @license
61
61
  * Copyright 2025 Google LLC
@@ -140,7 +140,7 @@ function Nn(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e
140
140
  * @license
141
141
  * Copyright 2025 Google LLC
142
142
  * SPDX-License-Identifier: Apache-2.0
143
- */const Jn=/^[a-z][a-z0-9+.-]*:/i;let Yn=e=>(Yn=Array.isArray,Yn(e));const $n=Yn;const Kn="0.0.1";const Wn=()=>{var e,t,n,o,i;const r="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(Deno.build.os),"X-Stainless-Arch":zn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:null!==(t=null===(e=Deno.version)||void 0===e?void 0:e.deno)&&void 0!==t?t:"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(null!==(n=globalThis.process.platform)&&void 0!==n?n:"unknown"),"X-Stainless-Arch":zn(null!==(o=globalThis.process.arch)&&void 0!==o?o:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":null!==(i=globalThis.process.version)&&void 0!==i?i:"unknown"};const s=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return s?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${s.browser}`,"X-Stainless-Runtime-Version":s.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const zn=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Xn=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Qn;function Zn(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function eo(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Zn({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){var e;await(null===(e=t.return)||void 0===e?void 0:e.call(t))}})}function to(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return(null==e?void 0:e.done)&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}
143
+ */const Jn=/^[a-z][a-z0-9+.-]*:/i;let $n=e=>($n=Array.isArray,$n(e));const Yn=$n;const Kn="0.0.1";const Wn=()=>{var e,t,n,o,i;const r="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(Deno.build.os),"X-Stainless-Arch":zn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:null!==(t=null===(e=Deno.version)||void 0===e?void 0:e.deno)&&void 0!==t?t:"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===r)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":Xn(null!==(n=globalThis.process.platform)&&void 0!==n?n:"unknown"),"X-Stainless-Arch":zn(null!==(o=globalThis.process.arch)&&void 0!==o?o:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":null!==(i=globalThis.process.version)&&void 0!==i?i:"unknown"};const s=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const e=n.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return s?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${s.browser}`,"X-Stainless-Runtime-Version":s.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Kn,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const zn=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",Xn=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let Qn;function Zn(...e){const t=globalThis.ReadableStream;if(void 0===t)throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function eo(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Zn({start(){},async pull(e){const{done:n,value:o}=await t.next();n?e.close():e.enqueue(o)},async cancel(){var e;await(null===(e=t.return)||void 0===e?void 0:e.call(t))}})}function to(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return(null==e?void 0:e.done)&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}
144
144
  /**
145
145
  * @license
146
146
  * Copyright 2025 Google LLC
@@ -208,7 +208,7 @@ class ho extends lo{create(e,t){var n;const{api_version:o=this._client.apiVersio
208
208
  * @license
209
209
  * Copyright 2025 Google LLC
210
210
  * SPDX-License-Identifier: Apache-2.0
211
- */const Uo=Symbol("brand.privateNullableHeaders");function*xo(e){if(!e)return;if(Uo in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():$n(e)?t=e:(n=!0,t=Object.entries(null!=e?e:{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=$n(e[1])?e[1]:[e[1]];let i=!1;for(const e of o)void 0!==e&&(n&&!i&&(i=!0,yield[t,null]),yield[t,e])}}const Lo=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[i,r]of xo(o)){const o=i.toLowerCase();e.has(o)||(t.delete(i),e.add(o)),null===r?(t.delete(i),n.add(o)):(t.append(i,r),n.delete(o))}}return{[Uo]:!0,values:t,nulls:n}},ko=e=>{var t,n,o,i,r,s;return void 0!==globalThis.process?null!==(o=null===(n=null===(t=globalThis.process.env)||void 0===t?void 0:t[e])||void 0===n?void 0:n.trim())&&void 0!==o?o:void 0:void 0!==globalThis.Deno?null===(s=null===(r=null===(i=globalThis.Deno.env)||void 0===i?void 0:i.get)||void 0===r?void 0:r.call(i,e))||void 0===s?void 0:s.trim():void 0};
211
+ */const Uo=Symbol("brand.privateNullableHeaders");function*xo(e){if(!e)return;if(Uo in e){const{values:t,nulls:n}=e;yield*t.entries();for(const e of n)yield[e,null];return}let t,n=!1;e instanceof Headers?t=e.entries():Yn(e)?t=e:(n=!0,t=Object.entries(null!=e?e:{}));for(let e of t){const t=e[0];if("string"!=typeof t)throw new TypeError("expected header name to be a string");const o=Yn(e[1])?e[1]:[e[1]];let i=!1;for(const e of o)void 0!==e&&(n&&!i&&(i=!0,yield[t,null]),yield[t,e])}}const Lo=e=>{const t=new Headers,n=new Set;for(const o of e){const e=new Set;for(const[i,r]of xo(o)){const o=i.toLowerCase();e.has(o)||(t.delete(i),e.add(o)),null===r?(t.delete(i),n.add(o)):(t.append(i,r),n.delete(o))}}return{[Uo]:!0,values:t,nulls:n}},ko=e=>{var t,n,o,i,r,s;return void 0!==globalThis.process?null!==(o=null===(n=null===(t=globalThis.process.env)||void 0===t?void 0:t[e])||void 0===n?void 0:n.trim())&&void 0!==o?o:void 0:void 0!==globalThis.Deno?null===(s=null===(r=null===(i=globalThis.Deno.env)||void 0===i?void 0:i.get)||void 0===r?void 0:r.call(i,e))||void 0===s?void 0:s.trim():void 0};
212
212
  /**
213
213
  * @license
214
214
  * Copyright 2025 Google LLC
@@ -231,7 +231,7 @@ function(){if("undefined"!=typeof fetch)return fetch;throw new Error("`fetch` is
231
231
  * Copyright 2025 Google LLC
232
232
  * SPDX-License-Identifier: Apache-2.0
233
233
  */
234
- function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}function jo(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],Ho(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Vo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],n);const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],jo(st(h)));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);return null!=n&&ue(t,["enableWidget"],n),t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);return null!=n&&ue(t,["timeRangeFilter"],n),t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],function(e){const t={},n=ce(e,["handle"]);null!=n&&ue(t,["handle"],n);if(void 0!==ce(e,["transparent"]))throw new Error("transparent parameter is not supported in Gemini API.");return t}(m));const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);if(void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T),void 0!==ce(e,["explicitVadSignal"]))throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return{}}function Bo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],function(e){const t={},n=ce(e,["modelSelectionConfig"]);null!=n&&ue(t,["modelConfig"],n);const o=ce(e,["responseJsonSchema"]);null!=o&&ue(t,["responseJsonSchema"],o);const i=ce(e,["audioTimestamp"]);null!=i&&ue(t,["audioTimestamp"],i);const r=ce(e,["candidateCount"]);null!=r&&ue(t,["candidateCount"],r);const s=ce(e,["enableAffectiveDialog"]);null!=s&&ue(t,["enableAffectiveDialog"],s);const l=ce(e,["frequencyPenalty"]);null!=l&&ue(t,["frequencyPenalty"],l);const a=ce(e,["logprobs"]);null!=a&&ue(t,["logprobs"],a);const u=ce(e,["maxOutputTokens"]);null!=u&&ue(t,["maxOutputTokens"],u);const c=ce(e,["mediaResolution"]);null!=c&&ue(t,["mediaResolution"],c);const p=ce(e,["presencePenalty"]);null!=p&&ue(t,["presencePenalty"],p);const d=ce(e,["responseLogprobs"]);null!=d&&ue(t,["responseLogprobs"],d);const h=ce(e,["responseMimeType"]);null!=h&&ue(t,["responseMimeType"],h);const f=ce(e,["responseModalities"]);null!=f&&ue(t,["responseModalities"],f);const m=ce(e,["responseSchema"]);null!=m&&ue(t,["responseSchema"],m);const g=ce(e,["routingConfig"]);null!=g&&ue(t,["routingConfig"],g);const y=ce(e,["seed"]);null!=y&&ue(t,["seed"],y);const v=ce(e,["speechConfig"]);null!=v&&ue(t,["speechConfig"],v);const E=ce(e,["stopSequences"]);null!=E&&ue(t,["stopSequences"],E);const T=ce(e,["temperature"]);null!=T&&ue(t,["temperature"],T);const I=ce(e,["thinkingConfig"]);null!=I&&ue(t,["thinkingConfig"],I);const _=ce(e,["topK"]);null!=_&&ue(t,["topK"],_);const S=ce(e,["topP"]);if(null!=S&&ue(t,["topP"],S),void 0!==ce(e,["enableEnhancedCivicAnswers"]))throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}(n));const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],st(h));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);if(null!=l&&ue(t,["responseJsonSchema"],l),void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],m);const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T);const I=ce(e,["explicitVadSignal"]);return void 0!==t&&null!=I&&ue(t,["setup","explicitVadSignal"],I),{}}function Jo(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>Ho(e))),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],Ho(et(o)));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ho(Ze(r)));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function Yo(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],et(o));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ze(r));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function $o(e){const t={},n=ce(e,["setupComplete"]);null!=n&&ue(t,["setupComplete"],n);const o=ce(e,["serverContent"]);null!=o&&ue(t,["serverContent"],o);const i=ce(e,["toolCall"]);null!=i&&ue(t,["toolCall"],i);const r=ce(e,["toolCallCancellation"]);null!=r&&ue(t,["toolCallCancellation"],r);const s=ce(e,["usageMetadata"]);null!=s&&ue(t,["usageMetadata"],function(e){const t={},n=ce(e,["promptTokenCount"]);null!=n&&ue(t,["promptTokenCount"],n);const o=ce(e,["cachedContentTokenCount"]);null!=o&&ue(t,["cachedContentTokenCount"],o);const i=ce(e,["candidatesTokenCount"]);null!=i&&ue(t,["responseTokenCount"],i);const r=ce(e,["toolUsePromptTokenCount"]);null!=r&&ue(t,["toolUsePromptTokenCount"],r);const s=ce(e,["thoughtsTokenCount"]);null!=s&&ue(t,["thoughtsTokenCount"],s);const l=ce(e,["totalTokenCount"]);null!=l&&ue(t,["totalTokenCount"],l);const a=ce(e,["promptTokensDetails"]);if(null!=a){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["promptTokensDetails"],e)}const u=ce(e,["cacheTokensDetails"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cacheTokensDetails"],e)}const c=ce(e,["candidatesTokensDetails"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["responseTokensDetails"],e)}const p=ce(e,["toolUsePromptTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["toolUsePromptTokensDetails"],e)}const d=ce(e,["trafficType"]);null!=d&&ue(t,["trafficType"],d);return t}(s));const l=ce(e,["goAway"]);null!=l&&ue(t,["goAway"],l);const a=ce(e,["sessionResumptionUpdate"]);null!=a&&ue(t,["sessionResumptionUpdate"],a);const u=ce(e,["voiceActivityDetectionSignal"]);null!=u&&ue(t,["voiceActivityDetectionSignal"],u);const c=ce(e,["voiceActivity"]);return null!=c&&ue(t,["voiceActivity"],function(e){const t={},n=ce(e,["type"]);null!=n&&ue(t,["voiceActivityType"],n);return t}
234
+ function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const o=ce(e,["mimeType"]);return null!=o&&ue(t,["mimeType"],o),t}function jo(e){const t={},n=ce(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["mediaResolution"]);null!=n&&ue(t,["mediaResolution"],n);const o=ce(e,["codeExecutionResult"]);null!=o&&ue(t,["codeExecutionResult"],o);const i=ce(e,["executableCode"]);null!=i&&ue(t,["executableCode"],i);const r=ce(e,["fileData"]);null!=r&&ue(t,["fileData"],function(e){const t={};if(void 0!==ce(e,["displayName"]))throw new Error("displayName parameter is not supported in Gemini API.");const n=ce(e,["fileUri"]);null!=n&&ue(t,["fileUri"],n);const o=ce(e,["mimeType"]);null!=o&&ue(t,["mimeType"],o);return t}(r));const s=ce(e,["functionCall"]);null!=s&&ue(t,["functionCall"],function(e){const t={},n=ce(e,["id"]);null!=n&&ue(t,["id"],n);const o=ce(e,["args"]);null!=o&&ue(t,["args"],o);const i=ce(e,["name"]);null!=i&&ue(t,["name"],i);if(void 0!==ce(e,["partialArgs"]))throw new Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==ce(e,["willContinue"]))throw new Error("willContinue parameter is not supported in Gemini API.");return t}(s));const l=ce(e,["functionResponse"]);null!=l&&ue(t,["functionResponse"],l);const a=ce(e,["inlineData"]);null!=a&&ue(t,["inlineData"],Ho(a));const u=ce(e,["text"]);null!=u&&ue(t,["text"],u);const c=ce(e,["thought"]);null!=c&&ue(t,["thought"],c);const p=ce(e,["thoughtSignature"]);null!=p&&ue(t,["thoughtSignature"],p);const d=ce(e,["videoMetadata"]);null!=d&&ue(t,["videoMetadata"],d);return t}(e))),ue(t,["parts"],e)}const o=ce(e,["role"]);return null!=o&&ue(t,["role"],o),t}function Vo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],n);const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],jo(st(h)));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={};if(void 0!==ce(e,["retrieval"]))throw new Error("retrieval parameter is not supported in Gemini API.");const n=ce(e,["computerUse"]);null!=n&&ue(t,["computerUse"],n);const o=ce(e,["fileSearch"]);null!=o&&ue(t,["fileSearch"],o);const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);if(void 0!==ce(e,["enterpriseWebSearch"]))throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const r=ce(e,["functionDeclarations"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["functionDeclarations"],e)}const s=ce(e,["googleMaps"]);null!=s&&ue(t,["googleMaps"],function(e){const t={};if(void 0!==ce(e,["authConfig"]))throw new Error("authConfig parameter is not supported in Gemini API.");const n=ce(e,["enableWidget"]);return null!=n&&ue(t,["enableWidget"],n),t}(s));const l=ce(e,["googleSearch"]);null!=l&&ue(t,["googleSearch"],function(e){const t={};if(void 0!==ce(e,["excludeDomains"]))throw new Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==ce(e,["blockingConfidence"]))throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=ce(e,["timeRangeFilter"]);return null!=n&&ue(t,["timeRangeFilter"],n),t}(l));const a=ce(e,["googleSearchRetrieval"]);null!=a&&ue(t,["googleSearchRetrieval"],a);const u=ce(e,["urlContext"]);null!=u&&ue(t,["urlContext"],u);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],function(e){const t={},n=ce(e,["handle"]);null!=n&&ue(t,["handle"],n);if(void 0!==ce(e,["transparent"]))throw new Error("transparent parameter is not supported in Gemini API.");return t}(m));const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);if(void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T),void 0!==ce(e,["explicitVadSignal"]))throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return{}}function Bo(e,t){const n=ce(e,["generationConfig"]);void 0!==t&&null!=n&&ue(t,["setup","generationConfig"],function(e){const t={},n=ce(e,["modelSelectionConfig"]);null!=n&&ue(t,["modelConfig"],n);const o=ce(e,["responseJsonSchema"]);null!=o&&ue(t,["responseJsonSchema"],o);const i=ce(e,["audioTimestamp"]);null!=i&&ue(t,["audioTimestamp"],i);const r=ce(e,["candidateCount"]);null!=r&&ue(t,["candidateCount"],r);const s=ce(e,["enableAffectiveDialog"]);null!=s&&ue(t,["enableAffectiveDialog"],s);const l=ce(e,["frequencyPenalty"]);null!=l&&ue(t,["frequencyPenalty"],l);const a=ce(e,["logprobs"]);null!=a&&ue(t,["logprobs"],a);const u=ce(e,["maxOutputTokens"]);null!=u&&ue(t,["maxOutputTokens"],u);const c=ce(e,["mediaResolution"]);null!=c&&ue(t,["mediaResolution"],c);const p=ce(e,["presencePenalty"]);null!=p&&ue(t,["presencePenalty"],p);const d=ce(e,["responseLogprobs"]);null!=d&&ue(t,["responseLogprobs"],d);const h=ce(e,["responseMimeType"]);null!=h&&ue(t,["responseMimeType"],h);const f=ce(e,["responseModalities"]);null!=f&&ue(t,["responseModalities"],f);const m=ce(e,["responseSchema"]);null!=m&&ue(t,["responseSchema"],m);const g=ce(e,["routingConfig"]);null!=g&&ue(t,["routingConfig"],g);const y=ce(e,["seed"]);null!=y&&ue(t,["seed"],y);const v=ce(e,["speechConfig"]);null!=v&&ue(t,["speechConfig"],v);const E=ce(e,["stopSequences"]);null!=E&&ue(t,["stopSequences"],E);const T=ce(e,["temperature"]);null!=T&&ue(t,["temperature"],T);const I=ce(e,["thinkingConfig"]);null!=I&&ue(t,["thinkingConfig"],I);const _=ce(e,["topK"]);null!=_&&ue(t,["topK"],_);const S=ce(e,["topP"]);if(null!=S&&ue(t,["topP"],S),void 0!==ce(e,["enableEnhancedCivicAnswers"]))throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}(n));const o=ce(e,["responseModalities"]);void 0!==t&&null!=o&&ue(t,["setup","generationConfig","responseModalities"],o);const i=ce(e,["temperature"]);void 0!==t&&null!=i&&ue(t,["setup","generationConfig","temperature"],i);const r=ce(e,["topP"]);void 0!==t&&null!=r&&ue(t,["setup","generationConfig","topP"],r);const s=ce(e,["topK"]);void 0!==t&&null!=s&&ue(t,["setup","generationConfig","topK"],s);const l=ce(e,["maxOutputTokens"]);void 0!==t&&null!=l&&ue(t,["setup","generationConfig","maxOutputTokens"],l);const a=ce(e,["mediaResolution"]);void 0!==t&&null!=a&&ue(t,["setup","generationConfig","mediaResolution"],a);const u=ce(e,["seed"]);void 0!==t&&null!=u&&ue(t,["setup","generationConfig","seed"],u);const c=ce(e,["speechConfig"]);void 0!==t&&null!=c&&ue(t,["setup","generationConfig","speechConfig"],dt(c));const p=ce(e,["thinkingConfig"]);void 0!==t&&null!=p&&ue(t,["setup","generationConfig","thinkingConfig"],p);const d=ce(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&ue(t,["setup","generationConfig","enableAffectiveDialog"],d);const h=ce(e,["systemInstruction"]);void 0!==t&&null!=h&&ue(t,["setup","systemInstruction"],st(h));const f=ce(e,["tools"]);if(void 0!==t&&null!=f){let e=ft(f);Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["retrieval"]);null!=n&&ue(t,["retrieval"],n);const o=ce(e,["computerUse"]);null!=o&&ue(t,["computerUse"],o);if(void 0!==ce(e,["fileSearch"]))throw new Error("fileSearch parameter is not supported in Vertex AI.");const i=ce(e,["codeExecution"]);null!=i&&ue(t,["codeExecution"],i);const r=ce(e,["enterpriseWebSearch"]);null!=r&&ue(t,["enterpriseWebSearch"],r);const s=ce(e,["functionDeclarations"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>function(e){const t={},n=ce(e,["description"]);null!=n&&ue(t,["description"],n);const o=ce(e,["name"]);null!=o&&ue(t,["name"],o);const i=ce(e,["parameters"]);null!=i&&ue(t,["parameters"],i);const r=ce(e,["parametersJsonSchema"]);null!=r&&ue(t,["parametersJsonSchema"],r);const s=ce(e,["response"]);null!=s&&ue(t,["response"],s);const l=ce(e,["responseJsonSchema"]);if(null!=l&&ue(t,["responseJsonSchema"],l),void 0!==ce(e,["behavior"]))throw new Error("behavior parameter is not supported in Vertex AI.");return t}(e))),ue(t,["functionDeclarations"],e)}const l=ce(e,["googleMaps"]);null!=l&&ue(t,["googleMaps"],l);const a=ce(e,["googleSearch"]);null!=a&&ue(t,["googleSearch"],a);const u=ce(e,["googleSearchRetrieval"]);null!=u&&ue(t,["googleSearchRetrieval"],u);const c=ce(e,["urlContext"]);null!=c&&ue(t,["urlContext"],c);return t}(ht(e)))),ue(t,["setup","tools"],e)}const m=ce(e,["sessionResumption"]);void 0!==t&&null!=m&&ue(t,["setup","sessionResumption"],m);const g=ce(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&ue(t,["setup","inputAudioTranscription"],g);const y=ce(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&ue(t,["setup","outputAudioTranscription"],y);const v=ce(e,["realtimeInputConfig"]);void 0!==t&&null!=v&&ue(t,["setup","realtimeInputConfig"],v);const E=ce(e,["contextWindowCompression"]);void 0!==t&&null!=E&&ue(t,["setup","contextWindowCompression"],E);const T=ce(e,["proactivity"]);void 0!==t&&null!=T&&ue(t,["setup","proactivity"],T);const I=ce(e,["explicitVadSignal"]);return void 0!==t&&null!=I&&ue(t,["setup","explicitVadSignal"],I),{}}function Jo(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>Ho(e))),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],Ho(et(o)));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ho(Ze(r)));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function $o(e){const t={},n=ce(e,["media"]);if(null!=n){let e=Xe(n);Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["mediaChunks"],e)}const o=ce(e,["audio"]);null!=o&&ue(t,["audio"],et(o));const i=ce(e,["audioStreamEnd"]);null!=i&&ue(t,["audioStreamEnd"],i);const r=ce(e,["video"]);null!=r&&ue(t,["video"],Ze(r));const s=ce(e,["text"]);null!=s&&ue(t,["text"],s);const l=ce(e,["activityStart"]);null!=l&&ue(t,["activityStart"],l);const a=ce(e,["activityEnd"]);return null!=a&&ue(t,["activityEnd"],a),t}function Yo(e){const t={},n=ce(e,["setupComplete"]);null!=n&&ue(t,["setupComplete"],n);const o=ce(e,["serverContent"]);null!=o&&ue(t,["serverContent"],o);const i=ce(e,["toolCall"]);null!=i&&ue(t,["toolCall"],i);const r=ce(e,["toolCallCancellation"]);null!=r&&ue(t,["toolCallCancellation"],r);const s=ce(e,["usageMetadata"]);null!=s&&ue(t,["usageMetadata"],function(e){const t={},n=ce(e,["promptTokenCount"]);null!=n&&ue(t,["promptTokenCount"],n);const o=ce(e,["cachedContentTokenCount"]);null!=o&&ue(t,["cachedContentTokenCount"],o);const i=ce(e,["candidatesTokenCount"]);null!=i&&ue(t,["responseTokenCount"],i);const r=ce(e,["toolUsePromptTokenCount"]);null!=r&&ue(t,["toolUsePromptTokenCount"],r);const s=ce(e,["thoughtsTokenCount"]);null!=s&&ue(t,["thoughtsTokenCount"],s);const l=ce(e,["totalTokenCount"]);null!=l&&ue(t,["totalTokenCount"],l);const a=ce(e,["promptTokensDetails"]);if(null!=a){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["promptTokensDetails"],e)}const u=ce(e,["cacheTokensDetails"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["cacheTokensDetails"],e)}const c=ce(e,["candidatesTokensDetails"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["responseTokensDetails"],e)}const p=ce(e,["toolUsePromptTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["toolUsePromptTokensDetails"],e)}const d=ce(e,["trafficType"]);null!=d&&ue(t,["trafficType"],d);return t}(s));const l=ce(e,["goAway"]);null!=l&&ue(t,["goAway"],l);const a=ce(e,["sessionResumptionUpdate"]);null!=a&&ue(t,["sessionResumptionUpdate"],a);const u=ce(e,["voiceActivityDetectionSignal"]);null!=u&&ue(t,["voiceActivityDetectionSignal"],u);const c=ce(e,["voiceActivity"]);return null!=c&&ue(t,["voiceActivity"],function(e){const t={},n=ce(e,["type"]);null!=n&&ue(t,["voiceActivityType"],n);return t}
235
235
  /**
236
236
  * @license
237
237
  * Copyright 2025 Google LLC
@@ -252,17 +252,17 @@ function Ho(e){const t={},n=ce(e,["data"]);if(null!=n&&ue(t,["data"],n),void 0!=
252
252
  * Copyright 2025 Google LLC
253
253
  * SPDX-License-Identifier: Apache-2.0
254
254
  */
255
- async function(e,t,n){const o=new $e;let i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(o,i),t(o)}(0,u.onmessage,e)},onerror:null!==(t=null==u?void 0:u.onerror)&&void 0!==t?t:function(e){},onclose:null!==(n=null==u?void 0:u.onclose)&&void 0!==n?n:function(e){}}),p=this.webSocketFactory.create(s,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(r),c);p.connect(),await a;const d={setup:{model:We(this.apiClient,e.model)}};return p.send(JSON.stringify(d)),new Vi(p,this.apiClient)}}class Vi{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||0===Object.keys(e.weightedPrompts).length)throw new Error("Weighted prompts must be set and contain at least one entry.");const t=function(e){const t={},n=ce(e,["weightedPrompts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const t=function(e){const t={},n=ce(e,["musicGenerationConfig"]);return null!=n&&ue(t,["musicGenerationConfig"],n),t}(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){const t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PLAY)}pause(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PAUSE)}stop(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.STOP)}resetContext(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.RESET_CONTEXT)}close(){this.conn.close()}}class Bi{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new ji(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var n,o,i,r,s,l;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const a=this.apiClient.getWebsocketBaseUrl(),u=this.apiClient.getApiVersion();let c;const p=this.apiClient.getHeaders();t.config&&t.config.tools&&ki(t.config.tools)&&qi(p);const d=function(e){const t=new Headers;for(const[n,o]of Object.entries(e))t.append(n,o);return t}
255
+ async function(e,t,n){const o=new Ye;let i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(o,i),t(o)}(0,u.onmessage,e)},onerror:null!==(t=null==u?void 0:u.onerror)&&void 0!==t?t:function(e){},onclose:null!==(n=null==u?void 0:u.onclose)&&void 0!==n?n:function(e){}}),p=this.webSocketFactory.create(s,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(r),c);p.connect(),await a;const d={setup:{model:We(this.apiClient,e.model)}};return p.send(JSON.stringify(d)),new Vi(p,this.apiClient)}}class Vi{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||0===Object.keys(e.weightedPrompts).length)throw new Error("Weighted prompts must be set and contain at least one entry.");const t=function(e){const t={},n=ce(e,["weightedPrompts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const t=function(e){const t={},n=ce(e,["musicGenerationConfig"]);return null!=n&&ue(t,["musicGenerationConfig"],n),t}(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){const t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PLAY)}pause(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.PAUSE)}stop(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.STOP)}resetContext(){this.sendPlaybackControl(e.LiveMusicPlaybackControl.RESET_CONTEXT)}close(){this.conn.close()}}class Bi{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new ji(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var n,o,i,r,s,l;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const a=this.apiClient.getWebsocketBaseUrl(),u=this.apiClient.getApiVersion();let c;const p=this.apiClient.getHeaders();t.config&&t.config.tools&&ki(t.config.tools)&&qi(p);const d=function(e){const t=new Headers;for(const[n,o]of Object.entries(e))t.append(n,o);return t}
256
256
  /**
257
257
  * @license
258
258
  * Copyright 2025 Google LLC
259
259
  * SPDX-License-Identifier: Apache-2.0
260
- */(p);if(this.apiClient.isVertexAI()){const e=this.apiClient.getProject(),t=this.apiClient.getLocation(),n=this.apiClient.getApiKey(),o=!!e&&!!t||!!n;this.apiClient.getCustomBaseUrl()&&!o?c=a:(c=`${a}/ws/google.cloud.aiplatform.${u}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(d,c))}else{const e=this.apiClient.getApiKey();let t="BidiGenerateContent",n="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==u&&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."),t="BidiGenerateContentConstrained",n="access_token"),c=`${a}/ws/google.ai.generativelanguage.${u}.GenerativeService.${t}?${n}=${e}`}let h=()=>{};const f=new Promise(e=>{h=e}),m=t.callbacks,g=this.apiClient,y={onopen:function(){var e;null===(e=null==m?void 0:m.onopen)||void 0===e||e.call(m),h({})},onmessage:e=>{!async function(e,t,n){const o=new Ye;let i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?(new TextDecoder).decode(n.data):n.data;const r=JSON.parse(i);if(e.isVertexAI()){const e=$o(r);Object.assign(o,e)}else{const e=r;Object.assign(o,e)}t(o)}(g,m.onmessage,e)},onerror:null!==(n=null==m?void 0:m.onerror)&&void 0!==n?n:function(e){},onclose:null!==(o=null==m?void 0:m.onclose)&&void 0!==o?o:function(e){}},v=this.webSocketFactory.create(c,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(d),y);v.connect(),await f;let E=We(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&E.startsWith("publishers/")){const e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(E=`projects/${e}/locations/${t}/`+E)}let T={};this.apiClient.isVertexAI()&&void 0===(null===(i=t.config)||void 0===i?void 0:i.responseModalities)&&(void 0===t.config?t.config={responseModalities:[e.Modality.AUDIO]}:t.config.responseModalities=[e.Modality.AUDIO]),(null===(r=t.config)||void 0===r?void 0:r.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).");const I=null!==(l=null===(s=t.config)||void 0===s?void 0:s.tools)&&void 0!==l?l:[],_=[];for(const e of I)if(this.isCallableTool(e)){const t=e;_.push(await t.tool())}else _.push(e);_.length>0&&(t.config.tools=_);const S={model:E,config:t.config,callbacks:t.callbacks};return T=this.apiClient.isVertexAI()?function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Bo(i,n)),n}(this.apiClient,S):function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Vo(i,n)),n}(this.apiClient,S),delete T.config,v.send(JSON.stringify(T)),new Yi(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}const Ji={turnComplete:!0};class Yi{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let n=[];try{n=at(t.turns),e.isVertexAI()||(n=n.map(e=>zo(e)))}catch(e){throw new 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(null==t.functionResponses)throw new Error("functionResponses is required.");if(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],0===n.length)throw new Error("functionResponses is required.");for(const t of n){if("object"!=typeof t||null===t||!("name"in t)||!("response"in t))throw new Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!("id"in t))throw new Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Ji),e);const t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:Yo(e)}:{realtimeInput:Jo(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(null==e.functionResponses)throw new Error("Tool response parameters are required.");const t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function $i(e){var t,n,o;if(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.disable)return!0;let i=!1;for(const t of null!==(n=null==e?void 0:e.tools)&&void 0!==n?n:[])if(Ki(t)){i=!0;break}if(!i)return!0;const r=null===(o=null==e?void 0:e.automaticFunctionCalling)||void 0===o?void 0:o.maximumRemoteCalls;return!!(r&&(r<0||!Number.isInteger(r))||0==r)&&(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:",r),!0)}function Ki(e){return"callTool"in e&&"function"==typeof e.callTool}function Wi(e){var t;const n=[];return(null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.tools)?(e.config.tools.forEach((e,t)=>{if(Ki(e))return;const o=e;o.functionDeclarations&&o.functionDeclarations.length>0&&n.push(t)}),n):n}function zi(e){var t;return!(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.ignoreCallHistory)}
260
+ */(p);if(this.apiClient.isVertexAI()){const e=this.apiClient.getProject(),t=this.apiClient.getLocation(),n=this.apiClient.getApiKey(),o=!!e&&!!t||!!n;this.apiClient.getCustomBaseUrl()&&!o?c=a:(c=`${a}/ws/google.cloud.aiplatform.${u}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(d,c))}else{const e=this.apiClient.getApiKey();let t="BidiGenerateContent",n="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==u&&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."),t="BidiGenerateContentConstrained",n="access_token"),c=`${a}/ws/google.ai.generativelanguage.${u}.GenerativeService.${t}?${n}=${e}`}let h=()=>{};const f=new Promise(e=>{h=e}),m=t.callbacks,g=this.apiClient,y={onopen:function(){var e;null===(e=null==m?void 0:m.onopen)||void 0===e||e.call(m),h({})},onmessage:e=>{!async function(e,t,n){const o=new $e;let i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?(new TextDecoder).decode(n.data):n.data;const r=JSON.parse(i);if(e.isVertexAI()){const e=Yo(r);Object.assign(o,e)}else{const e=r;Object.assign(o,e)}t(o)}(g,m.onmessage,e)},onerror:null!==(n=null==m?void 0:m.onerror)&&void 0!==n?n:function(e){},onclose:null!==(o=null==m?void 0:m.onclose)&&void 0!==o?o:function(e){}},v=this.webSocketFactory.create(c,function(e){const t={};return e.forEach((e,n)=>{t[n]=e}),t}(d),y);v.connect(),await f;let E=We(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&E.startsWith("publishers/")){const e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(E=`projects/${e}/locations/${t}/`+E)}let T={};this.apiClient.isVertexAI()&&void 0===(null===(i=t.config)||void 0===i?void 0:i.responseModalities)&&(void 0===t.config?t.config={responseModalities:[e.Modality.AUDIO]}:t.config.responseModalities=[e.Modality.AUDIO]),(null===(r=t.config)||void 0===r?void 0:r.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).");const I=null!==(l=null===(s=t.config)||void 0===s?void 0:s.tools)&&void 0!==l?l:[],_=[];for(const e of I)if(this.isCallableTool(e)){const t=e;_.push(await t.tool())}else _.push(e);_.length>0&&(t.config.tools=_);const S={model:E,config:t.config,callbacks:t.callbacks};return T=this.apiClient.isVertexAI()?function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Bo(i,n)),n}(this.apiClient,S):function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["setup","model"],We(e,o));const i=ce(t,["config"]);return null!=i&&ue(n,["config"],Vo(i,n)),n}(this.apiClient,S),delete T.config,v.send(JSON.stringify(T)),new $i(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}const Ji={turnComplete:!0};class $i{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let n=[];try{n=at(t.turns),e.isVertexAI()||(n=n.map(e=>zo(e)))}catch(e){throw new 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(null==t.functionResponses)throw new Error("functionResponses is required.");if(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],0===n.length)throw new Error("functionResponses is required.");for(const t of n){if("object"!=typeof t||null===t||!("name"in t)||!("response"in t))throw new Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!("id"in t))throw new Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Ji),e);const t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:$o(e)}:{realtimeInput:Jo(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(null==e.functionResponses)throw new Error("Tool response parameters are required.");const t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function Yi(e){var t,n,o;if(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.disable)return!0;let i=!1;for(const t of null!==(n=null==e?void 0:e.tools)&&void 0!==n?n:[])if(Ki(t)){i=!0;break}if(!i)return!0;const r=null===(o=null==e?void 0:e.automaticFunctionCalling)||void 0===o?void 0:o.maximumRemoteCalls;return!!(r&&(r<0||!Number.isInteger(r))||0==r)&&(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:",r),!0)}function Ki(e){return"callTool"in e&&"function"==typeof e.callTool}function Wi(e){var t;const n=[];return(null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.tools)?(e.config.tools.forEach((e,t)=>{if(Ki(e))return;const o=e;o.functionDeclarations&&o.functionDeclarations.length>0&&n.push(t)}),n):n}function zi(e){var t;return!(null===(t=null==e?void 0:e.automaticFunctionCalling)||void 0===t?void 0:t.ignoreCallHistory)}
261
261
  /**
262
262
  * @license
263
263
  * Copyright 2025 Google LLC
264
264
  * SPDX-License-Identifier: Apache-2.0
265
- */class Xi extends le{constructor(t){super(),this.apiClient=t,this.embedContent=async t=>{if(!this.apiClient.isVertexAI())return await this.embedContentInternal(t);if(t.model.includes("gemini")&&"gemini-embedding-001"!==t.model||t.model.includes("maas")){const n=at(t.contents);if(n.length>1)throw new Error("The embedContent API for this model only supports one content at a time.");const o=Object.assign(Object.assign({},t),{content:n[0],embeddingApiType:e.EmbeddingApiType.EMBED_CONTENT});return await this.embedContentInternal(o)}{const n=Object.assign(Object.assign({},t),{embeddingApiType:e.EmbeddingApiType.PREDICT});return await this.embedContentInternal(n)}},this.generateContent=async e=>{var t,n,o,i,r;const s=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!function(e){var t,n,o;return null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.tools)||void 0===n?void 0:n.some(e=>Ki(e)))&&void 0!==o&&o}(e)||$i(e.config))return await this.generateContentInternal(s);const l=Wi(e);if(l.length>0){const e=l.map(e=>`tools[${e}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let a,u;const c=at(s.contents),p=null!==(o=null===(n=null===(t=s.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let d=0;for(;d<p&&(a=await this.generateContentInternal(s),a.functionCalls&&0!==a.functionCalls.length);){const t=a.candidates[0].content,n=[];for(const t of null!==(r=null===(i=e.config)||void 0===i?void 0:i.tools)&&void 0!==r?r:[])if(Ki(t)){const e=t,o=await e.callTool(a.functionCalls);n.push(...o)}d++,u={role:"user",parts:n},s.contents=at(s.contents),s.contents.push(t),s.contents.push(u),zi(s.config)&&(c.push(t),c.push(u))}return zi(s.config)&&(a.automaticFunctionCallingHistory=c),a},this.generateContentStream=async e=>{var t,n,o,i,r;if(this.maybeMoveToResponseJsonSchem(e),$i(e.config)){const t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}const s=Wi(e);if(s.length>0){const e=s.map(e=>`tools[${e}]`).join(", ");throw new Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const l=null===(o=null===(n=null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.toolConfig)||void 0===n?void 0:n.functionCallingConfig)||void 0===o?void 0:o.streamFunctionCallArguments,a=null===(r=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.automaticFunctionCalling)||void 0===r?void 0:r.disable;if(l&&!a)throw new 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=>{var t;let n;const o=[];if(null==e?void 0:e.generatedImages)for(const i of e.generatedImages)i&&(null==i?void 0:i.safetyAttributes)&&"Positive Prompt"===(null===(t=null==i?void 0:i.safetyAttributes)||void 0===t?void 0:t.contentType)?n=null==i?void 0:i.safetyAttributes:o.push(i);let i;return i=n?{generatedImages:o,positivePromptSafetyAttributes:n,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:o,sdkHttpResponse:e.sdkHttpResponse},i}),this.list=async t=>{var n;const o={config:Object.assign(Object.assign({},{queryBase:!0}),null==t?void 0:t.config)};if(this.apiClient.isVertexAI()&&!o.config.queryBase){if(null===(n=o.config)||void 0===n?void 0:n.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");o.config.filter="labels.tune-type:*"}return new qt(e.PagedItem.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(o),o)},this.editImage=async e=>{const 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));const n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{var t,n,o,i,r,s;if((e.prompt||e.image||e.video)&&e.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||((null===(t=e.video)||void 0===t?void 0:t.uri)&&(null===(n=e.video)||void 0===n?void 0:n.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null===(i=null===(o=e.source)||void 0===o?void 0:o.video)||void 0===i?void 0:i.uri)&&(null===(s=null===(r=e.source)||void 0===r?void 0:r.video)||void 0===s?void 0:s.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){var t,n,o;const i=null===(t=e.config)||void 0===t?void 0:t.tools;if(!i)return e;const r=await Promise.all(i.map(async e=>{if(Ki(e)){const t=e;return await t.tool()}return e})),s={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:r})};if(s.config.tools=r,e.config&&e.config.tools&&ki(e.config.tools)){const t=null!==(o=null===(n=e.config.httpOptions)||void 0===n?void 0:n.headers)&&void 0!==o?o:{};let i=Object.assign({},t);0===Object.keys(i).length&&(i=this.apiClient.getDefaultHeaders()),qi(i),s.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:i})}return s}async initAfcToolsMap(e){var t,n,o;const i=new Map;for(const r of null!==(n=null===(t=e.config)||void 0===t?void 0:t.tools)&&void 0!==n?n:[])if(Ki(r)){const e=r,t=await e.tool();for(const n of null!==(o=t.functionDeclarations)&&void 0!==o?o:[]){if(!n.name)throw new Error("Function declaration name is required.");if(i.has(n.name))throw new Error(`Duplicate tool declaration name: ${n.name}`);i.set(n.name,e)}}return i}async processAfcStream(e){var t,n,o;const i=null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let r=!1,s=0;return function(e,t,n){return Xt(this,arguments,function*(){for(var o,l,a,u,c,p;s<i;){r&&(s++,r=!1);const m=yield zt(e.processParamsMaybeAddMcpUsage(n)),g=yield zt(e.generateContentStreamInternal(m)),y=[],v=[];try{for(var d,h=!0,f=(l=void 0,Qt(g));!(o=(d=yield zt(f.next())).done);h=!0){u=d.value,h=!1;const e=u;if(yield yield zt(e),e.candidates&&(null===(c=e.candidates[0])||void 0===c?void 0:c.content)){v.push(e.candidates[0].content);for(const n of null!==(p=e.candidates[0].content.parts)&&void 0!==p?p:[])if(s<i&&n.functionCall){if(!n.functionCall.name)throw new Error("Function call name was not returned by the model.");if(!t.has(n.functionCall.name))throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${t.keys()}, mising tool: ${n.functionCall.name}`);{const e=yield zt(t.get(n.functionCall.name).callTool([n.functionCall]));y.push(...e)}}}}}catch(e){l={error:e}}finally{try{h||o||!(a=f.return)||(yield zt(a.call(f)))}finally{if(l)throw l.error}}if(!(y.length>0))break;{r=!0;const e=new Ie;e.candidates=[{content:{role:"user",parts:y}}],yield yield zt(e);const t=[];t.push(...v),t.push({role:"user",parts:y});const o=at(n.contents).concat(t);n.contents=o}}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);return s=ae("{model}:generateContent",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=li(e),n=new Ie;return Object.assign(n,t),n})}{const t=ii(this.apiClient,e);return s=ae("{model}:generateContent",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=si(e),n=new Ie;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",o._url),l=o._query,delete o._url,delete o._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=li(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}{const t=ii(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",t._url),l=t._query,delete t._url,delete t._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=si(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}}async embedContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ti(this.apiClient,e,e);return s=ae((a=e.model).includes("gemini")&&"gemini-embedding-001"!==a||a.includes("maas")?"{model}:embedContent":"{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(t=>{const n=function(e,t){const n={},o=ce(e,["sdkHttpResponse"]);null!=o&&ue(n,["sdkHttpResponse"],o);const i=ce(e,["predictions[]","embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>Wo(e))),ue(n,["embeddings"],e)}const r=ce(e,["metadata"]);if(null!=r&&ue(n,["metadata"],r),t&&"EMBED_CONTENT"===ce(t,["embeddingApiType"])){const t=ce(e,["embedding"]),o=ce(e,["usageMetadata"]),i=ce(e,["truncated"]);if(t){const e={};o&&o.promptTokenCount&&(e.tokenCount=o.promptTokenCount),i&&(e.truncated=i),t.statistics=e,ue(n,["embeddings"],[t])}}return n}(t,e),o=new _e;return Object.assign(o,n),o})}{const t=ei(this.apiClient,e);return s=ae("{model}:batchEmbedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["embeddings"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["embeddings"],e)}const i=ce(e,["metadata"]);return null!=i&&ue(t,["metadata"],i),t}(e),n=new _e;return Object.assign(n,t),n})}var a}async generateImagesInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ui(this.apiClient,e);return s=ae("{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}const i=ce(e,["positivePromptSafetyAttributes"]);return null!=i&&ue(t,["positivePromptSafetyAttributes"],bi(i)),t}(e),n=new Se;return Object.assign(n,t),n})}{const t=ai(this.apiClient,e);return s=ae("{model}:predict",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=ci(e),n=new Se;return Object.assign(n,t),n})}}async editImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Zo(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ae;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Di(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ce;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ci(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Oe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ri(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=wi(e),n=new be;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=_i(this.apiClient,e);return s=ae("{models_url}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Ai(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}{const t=Ii(this.apiClient,e);return s=ae("{models_url}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Si(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Mi(this.apiClient,e);return s=ae("{model}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=Pi(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}}async countTokens(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}const r=ce(t,["config"]);return null!=r&&Xo(r,n),n}(this.apiClient,e);return s=ae("{model}:countTokens",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);return null!=o&&ue(t,["totalTokens"],o),t}(e),n=new Ne;return Object.assign(n,t),n})}{const t=Qo(this.apiClient,e);return s=ae("{model}:countTokens",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);null!=o&&ue(t,["totalTokens"],o);const i=ce(e,["cachedContentTokenCount"]);return null!=i&&ue(t,["cachedContentTokenCount"],i),t}(e),n=new Ne;return Object.assign(n,t),n})}}async computeTokens(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}return n}(this.apiClient,e);return i=ae("{model}:computeTokens",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["tokensInfo"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["tokensInfo"],e)}return t}(e),n=new Pe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=gi(this.apiClient,e);return s=ae("{model}:predictLongRunning",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>{const t=fi(e),n=new Me;return Object.assign(n,t),n})}{const t=mi(this.apiClient,e);return s=ae("{model}:predictLongRunning",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>{const t=hi(e),n=new Me;return Object.assign(n,t),n})}}}
265
+ */class Xi extends le{constructor(t){super(),this.apiClient=t,this.embedContent=async t=>{if(!this.apiClient.isVertexAI())return await this.embedContentInternal(t);if(t.model.includes("gemini")&&"gemini-embedding-001"!==t.model||t.model.includes("maas")){const n=at(t.contents);if(n.length>1)throw new Error("The embedContent API for this model only supports one content at a time.");const o=Object.assign(Object.assign({},t),{content:n[0],embeddingApiType:e.EmbeddingApiType.EMBED_CONTENT});return await this.embedContentInternal(o)}{const n=Object.assign(Object.assign({},t),{embeddingApiType:e.EmbeddingApiType.PREDICT});return await this.embedContentInternal(n)}},this.generateContent=async e=>{var t,n,o,i,r;const s=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!function(e){var t,n,o;return null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.tools)||void 0===n?void 0:n.some(e=>Ki(e)))&&void 0!==o&&o}(e)||Yi(e.config))return await this.generateContentInternal(s);const l=Wi(e);if(l.length>0){const e=l.map(e=>`tools[${e}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let a,u;const c=at(s.contents),p=null!==(o=null===(n=null===(t=s.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let d=0;for(;d<p&&(a=await this.generateContentInternal(s),a.functionCalls&&0!==a.functionCalls.length);){const t=a.candidates[0].content,n=[];for(const t of null!==(r=null===(i=e.config)||void 0===i?void 0:i.tools)&&void 0!==r?r:[])if(Ki(t)){const e=t,o=await e.callTool(a.functionCalls);n.push(...o)}d++,u={role:"user",parts:n},s.contents=at(s.contents),s.contents.push(t),s.contents.push(u),zi(s.config)&&(c.push(t),c.push(u))}return zi(s.config)&&(a.automaticFunctionCallingHistory=c),a},this.generateContentStream=async e=>{var t,n,o,i,r;if(this.maybeMoveToResponseJsonSchem(e),Yi(e.config)){const t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}const s=Wi(e);if(s.length>0){const e=s.map(e=>`tools[${e}]`).join(", ");throw new Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const l=null===(o=null===(n=null===(t=null==e?void 0:e.config)||void 0===t?void 0:t.toolConfig)||void 0===n?void 0:n.functionCallingConfig)||void 0===o?void 0:o.streamFunctionCallArguments,a=null===(r=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.automaticFunctionCalling)||void 0===r?void 0:r.disable;if(l&&!a)throw new 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=>{var t;let n;const o=[];if(null==e?void 0:e.generatedImages)for(const i of e.generatedImages)i&&(null==i?void 0:i.safetyAttributes)&&"Positive Prompt"===(null===(t=null==i?void 0:i.safetyAttributes)||void 0===t?void 0:t.contentType)?n=null==i?void 0:i.safetyAttributes:o.push(i);let i;return i=n?{generatedImages:o,positivePromptSafetyAttributes:n,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:o,sdkHttpResponse:e.sdkHttpResponse},i}),this.list=async t=>{var n;const o={config:Object.assign(Object.assign({},{queryBase:!0}),null==t?void 0:t.config)};if(this.apiClient.isVertexAI()&&!o.config.queryBase){if(null===(n=o.config)||void 0===n?void 0:n.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");o.config.filter="labels.tune-type:*"}return new qt(e.PagedItem.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(o),o)},this.editImage=async e=>{const 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));const n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{var t,n,o,i,r,s;if((e.prompt||e.image||e.video)&&e.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||((null===(t=e.video)||void 0===t?void 0:t.uri)&&(null===(n=e.video)||void 0===n?void 0:n.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null===(i=null===(o=e.source)||void 0===o?void 0:o.video)||void 0===i?void 0:i.uri)&&(null===(s=null===(r=e.source)||void 0===r?void 0:r.video)||void 0===s?void 0:s.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){var t,n,o;const i=null===(t=e.config)||void 0===t?void 0:t.tools;if(!i)return e;const r=await Promise.all(i.map(async e=>{if(Ki(e)){const t=e;return await t.tool()}return e})),s={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:r})};if(s.config.tools=r,e.config&&e.config.tools&&ki(e.config.tools)){const t=null!==(o=null===(n=e.config.httpOptions)||void 0===n?void 0:n.headers)&&void 0!==o?o:{};let i=Object.assign({},t);0===Object.keys(i).length&&(i=this.apiClient.getDefaultHeaders()),qi(i),s.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:i})}return s}async initAfcToolsMap(e){var t,n,o;const i=new Map;for(const r of null!==(n=null===(t=e.config)||void 0===t?void 0:t.tools)&&void 0!==n?n:[])if(Ki(r)){const e=r,t=await e.tool();for(const n of null!==(o=t.functionDeclarations)&&void 0!==o?o:[]){if(!n.name)throw new Error("Function declaration name is required.");if(i.has(n.name))throw new Error(`Duplicate tool declaration name: ${n.name}`);i.set(n.name,e)}}return i}async processAfcStream(e){var t,n,o;const i=null!==(o=null===(n=null===(t=e.config)||void 0===t?void 0:t.automaticFunctionCalling)||void 0===n?void 0:n.maximumRemoteCalls)&&void 0!==o?o:10;let r=!1,s=0;return function(e,t,n){return Xt(this,arguments,function*(){for(var o,l,a,u,c,p;s<i;){r&&(s++,r=!1);const m=yield zt(e.processParamsMaybeAddMcpUsage(n)),g=yield zt(e.generateContentStreamInternal(m)),y=[],v=[];try{for(var d,h=!0,f=(l=void 0,Qt(g));!(o=(d=yield zt(f.next())).done);h=!0){u=d.value,h=!1;const e=u;if(yield yield zt(e),e.candidates&&(null===(c=e.candidates[0])||void 0===c?void 0:c.content)){v.push(e.candidates[0].content);for(const n of null!==(p=e.candidates[0].content.parts)&&void 0!==p?p:[])if(s<i&&n.functionCall){if(!n.functionCall.name)throw new Error("Function call name was not returned by the model.");if(!t.has(n.functionCall.name))throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${t.keys()}, mising tool: ${n.functionCall.name}`);{const e=yield zt(t.get(n.functionCall.name).callTool([n.functionCall]));y.push(...e)}}}}}catch(e){l={error:e}}finally{try{h||o||!(a=f.return)||(yield zt(a.call(f)))}finally{if(l)throw l.error}}if(!(y.length>0))break;{r=!0;const e=new Ie;e.candidates=[{content:{role:"user",parts:y}}],yield yield zt(e);const t=[];t.push(...v),t.push({role:"user",parts:y});const o=at(n.contents).concat(t);n.contents=o}}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);return s=ae("{model}:generateContent",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=li(e),n=new Ie;return Object.assign(n,t),n})}{const t=ii(this.apiClient,e);return s=ae("{model}:generateContent",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=si(e),n=new Ie;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ri(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",o._url),l=o._query,delete o._url,delete o._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=li(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}{const t=ii(this.apiClient,e);s=ae("{model}:streamGenerateContent?alt=sse",t._url),l=t._query,delete t._url,delete t._query;return r=this.apiClient.requestStream({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}),r.then(function(e){return Xt(this,arguments,function*(){var t,n,o,i;try{for(var r,s=!0,l=Qt(e);!(t=(r=yield zt(l.next())).done);s=!0){i=r.value,s=!1;const e=i,t=si(yield zt(e.json()));t.sdkHttpResponse={headers:e.headers};const n=new Ie;Object.assign(n,t),yield yield zt(n)}}catch(e){n={error:e}}finally{try{s||t||!(o=l.return)||(yield zt(o.call(l)))}finally{if(n)throw n.error}}})})}}async embedContentInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ti(this.apiClient,e,e);return s=ae((a=e.model).includes("gemini")&&"gemini-embedding-001"!==a||a.includes("maas")?"{model}:embedContent":"{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(t=>{const n=function(e,t){const n={},o=ce(e,["sdkHttpResponse"]);null!=o&&ue(n,["sdkHttpResponse"],o);const i=ce(e,["predictions[]","embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>Wo(e))),ue(n,["embeddings"],e)}const r=ce(e,["metadata"]);if(null!=r&&ue(n,["metadata"],r),t&&"EMBED_CONTENT"===ce(t,["embeddingApiType"])){const t=ce(e,["embedding"]),o=ce(e,["usageMetadata"]),i=ce(e,["truncated"]);if(t){const e={};o&&o.promptTokenCount&&(e.tokenCount=o.promptTokenCount),i&&(e.truncated=i),t.statistics=e,ue(n,["embeddings"],[t])}}return n}(t,e),o=new _e;return Object.assign(o,n),o})}{const t=ei(this.apiClient,e);return s=ae("{model}:batchEmbedContents",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["embeddings"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["embeddings"],e)}const i=ce(e,["metadata"]);return null!=i&&ue(t,["metadata"],i),t}(e),n=new _e;return Object.assign(n,t),n})}var a}async generateImagesInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=ui(this.apiClient,e);return s=ae("{model}:predict",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}const i=ce(e,["positivePromptSafetyAttributes"]);return null!=i&&ue(t,["positivePromptSafetyAttributes"],bi(i)),t}(e),n=new Se;return Object.assign(n,t),n})}{const t=ai(this.apiClient,e);return s=ae("{model}:predict",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=ci(e),n=new Se;return Object.assign(n,t),n})}}async editImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Zo(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ae;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Di(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["predictions"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Ce;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ci(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=function(e){const t={},n=ce(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>yi(e))),ue(t,["generatedImages"],e)}return t}(e),n=new Oe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=Ri(this.apiClient,e);return i=ae("{model}:predict",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),o.then(e=>{const t=wi(e),n=new be;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async get(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async listInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=_i(this.apiClient,e);return s=ae("{models_url}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Ai(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}{const t=Ii(this.apiClient,e);return s=ae("{models_url}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"GET",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["nextPageToken"]);null!=o&&ue(t,["nextPageToken"],o);const i=ce(e,["_self"]);if(null!=i){let e=Tt(i);Array.isArray(e)&&(e=e.map(e=>Si(e))),ue(t,["models"],e)}return t}(e),n=new Re;return Object.assign(n,t),n})}}async update(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=Mi(this.apiClient,e);return s=ae("{model}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"PATCH",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>Ai(e))}{const t=Pi(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"PATCH",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>Si(e))}}async delete(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}{const t=function(e,t){const n={},o=ce(t,["model"]);return null!=o&&ue(n,["_url","name"],We(e,o)),n}(this.apiClient,e);return s=ae("{name}",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"DELETE",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);return null!=n&&ue(t,["sdkHttpResponse"],n),t}(e),n=new we;return Object.assign(n,t),n})}}async countTokens(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}const r=ce(t,["config"]);return null!=r&&Xo(r,n),n}(this.apiClient,e);return s=ae("{model}:countTokens",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);return null!=o&&ue(t,["totalTokens"],o),t}(e),n=new Ne;return Object.assign(n,t),n})}{const t=Qo(this.apiClient,e);return s=ae("{model}:countTokens",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),r.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["totalTokens"]);null!=o&&ue(t,["totalTokens"],o);const i=ce(e,["cachedContentTokenCount"]);return null!=i&&ue(t,["cachedContentTokenCount"],i),t}(e),n=new Ne;return Object.assign(n,t),n})}}async computeTokens(e){var t,n;let o,i="",r={};if(this.apiClient.isVertexAI()){const s=function(e,t){const n={},o=ce(t,["model"]);null!=o&&ue(n,["_url","model"],We(e,o));const i=ce(t,["contents"]);if(null!=i){let e=at(i);Array.isArray(e)&&(e=e.map(e=>e)),ue(n,["contents"],e)}return n}(this.apiClient,e);return i=ae("{model}:computeTokens",s._url),r=s._query,delete s._url,delete s._query,o=this.apiClient.request({path:i,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json().then(t=>{const n=t;return n.sdkHttpResponse={headers:e.headers},n})),o.then(e=>{const t=function(e){const t={},n=ce(e,["sdkHttpResponse"]);null!=n&&ue(t,["sdkHttpResponse"],n);const o=ce(e,["tokensInfo"]);if(null!=o){let e=o;Array.isArray(e)&&(e=e.map(e=>e)),ue(t,["tokensInfo"],e)}return t}(e),n=new Pe;return Object.assign(n,t),n})}throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var t,n,o,i;let r,s="",l={};if(this.apiClient.isVertexAI()){const o=gi(this.apiClient,e);return s=ae("{model}:predictLongRunning",o._url),l=o._query,delete o._url,delete o._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null===(t=e.config)||void 0===t?void 0:t.httpOptions,abortSignal:null===(n=e.config)||void 0===n?void 0:n.abortSignal}).then(e=>e.json()),r.then(e=>{const t=fi(e),n=new Me;return Object.assign(n,t),n})}{const t=mi(this.apiClient,e);return s=ae("{model}:predictLongRunning",t._url),l=t._query,delete t._url,delete t._query,r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null===(o=e.config)||void 0===o?void 0:o.httpOptions,abortSignal:null===(i=e.config)||void 0===i?void 0:i.abortSignal}).then(e=>e.json()),r.then(e=>{const t=hi(e),n=new Me;return Object.assign(n,t),n})}}}
266
266
  /**
267
267
  * @license
268
268
  * Copyright 2025 Google LLC
@@ -297,4 +297,4 @@ async function(e,t,n){const o=new $e;let i;i=n.data instanceof Blob?JSON.parse(a
297
297
  * @license
298
298
  * Copyright 2025 Google LLC
299
299
  * SPDX-License-Identifier: Apache-2.0
300
- */e.ApiError=pn,e.Batches=Gt,e.Caches=$t,e.CancelTuningJobResponse=Ue,e.Chat=on,e.Chats=nn,e.ComputeTokensResponse=Pe,e.ContentReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTENT",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.ControlReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTROL",referenceImage:this.referenceImage,referenceId:this.referenceId,controlImageConfig:this.config}}},e.CountTokensResponse=Ne,e.CreateFileResponse=je,e.DeleteCachedContentResponse=xe,e.DeleteFileResponse=Ve,e.DeleteModelResponse=we,e.EditImageResponse=Ae,e.EmbedContentResponse=_e,e.Files=An,e.FunctionResponse=class{},e.FunctionResponseBlob=class{},e.FunctionResponseFileData=class{},e.FunctionResponsePart=class{},e.GenerateContentResponse=Ie,e.GenerateContentResponsePromptFeedback=class{},e.GenerateContentResponseUsageMetadata=class{},e.GenerateImagesResponse=Se,e.GenerateVideosOperation=Me,e.GenerateVideosResponse=class{},e.GoogleGenAI=class{get interactions(){var e;if(void 0!==this._interactions)return this._interactions;if(console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."),this.vertexai)throw new Error("This version of the GenAI SDK does not support Vertex AI API for interactions.");const t=this.httpOptions;(null==t?void 0:t.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new Fo({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==t?void 0:t.timeout,maxRetries:null===(e=null==t?void 0:t.retryOptions)||void 0===e?void 0:e.attempts});return this._interactions=n.interactions,this._interactions}constructor(e){var t;if(null==e.apiKey)throw new Error(`An API Key must be set when running in an unspecified environment.\n + ${gn().message}`);this.vertexai=null!==(t=e.vertexai)&&void 0!==t&&t,this.apiKey=e.apiKey,this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const n=new dr(this.apiKey);this.apiClient=new fn({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/cross",uploader:new En,downloader:new yn}),this.models=new Xi(this.apiClient),this.live=new Bi(this.apiClient,n,new _n),this.chats=new nn(this.models,this.apiClient),this.batches=new Gt(this.apiClient),this.caches=new $t(this.apiClient),this.files=new An(this.apiClient),this.operations=new Qi(this.apiClient),this.authTokens=new nr(this.apiClient),this.tunings=new cr(this.apiClient),this.fileSearchStores=new Rn(this.apiClient)}},e.HttpResponse=Te,e.ImportFileOperation=Fe,e.ImportFileResponse=class{},e.InlinedEmbedContentResponse=class{},e.InlinedResponse=class{},e.ListBatchJobsResponse=Je,e.ListCachedContentsResponse=Le,e.ListDocumentsResponse=ke,e.ListFileSearchStoresResponse=qe,e.ListFilesResponse=He,e.ListModelsResponse=Re,e.ListTuningJobsResponse=De,e.Live=Bi,e.LiveClientToolResponse=class{},e.LiveMusicServerMessage=$e,e.LiveSendToolResponseParameters=class{constructor(){this.functionResponses=[]}},e.LiveServerMessage=Ye,e.MaskReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_MASK",referenceImage:this.referenceImage,referenceId:this.referenceId,maskImageConfig:this.config}}},e.Models=Xi,e.Operations=Qi,e.Pager=qt,e.RawReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_RAW",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.RecontextImageResponse=Oe,e.RegisterFilesResponse=Be,e.ReplayResponse=class{},e.SegmentImageResponse=be,e.Session=Yi,e.SingleEmbedContentResponse=class{},e.StyleReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_STYLE",referenceImage:this.referenceImage,referenceId:this.referenceId,styleImageConfig:this.config}}},e.SubjectReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_SUBJECT",referenceImage:this.referenceImage,referenceId:this.referenceId,subjectImageConfig:this.config}}},e.Tokens=nr,e.UploadToFileSearchStoreOperation=Ke,e.UploadToFileSearchStoreResponse=class{},e.UploadToFileSearchStoreResumableResponse=Ge,e.UpscaleImageResponse=Ce,e.createFunctionResponsePartFromBase64=function(e,t){return{inlineData:{data:e,mimeType:t}}},e.createFunctionResponsePartFromUri=function(e,t){return{fileData:{fileUri:e,mimeType:t}}},e.createModelContent=function(e){return{role:"model",parts:Ee(e)}},e.createPartFromBase64=function(e,t,n){return Object.assign({inlineData:{data:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createPartFromCodeExecutionResult=function(e,t){return{codeExecutionResult:{outcome:e,output:t}}},e.createPartFromExecutableCode=function(e,t){return{executableCode:{code:e,language:t}}},e.createPartFromFunctionCall=function(e,t){return{functionCall:{name:e,args:t}}},e.createPartFromFunctionResponse=function(e,t,n,o=[]){return{functionResponse:Object.assign({id:e,name:t,response:n},o.length>0&&{parts:o})}},e.createPartFromText=ye,e.createPartFromUri=function(e,t,n){return Object.assign({fileData:{fileUri:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createUserContent=function(e){return{role:"user",parts:Ee(e)}},e.mcpToTool=function(...e){if(Li=!0,0===e.length)throw new Error("No MCP clients provided");const t=e[e.length-1];return null!==(n=t)&&"object"==typeof n&&"listTools"in n&&"function"==typeof n.listTools?Hi.create(e,{}):Hi.create(e.slice(0,e.length-1),t);var n},e.setDefaultBaseUrls=function(e){e.geminiUrl,e.vertexUrl}}(y)),y}function A(){if(c)return u;return c=1,u={getExtractionPrompt:function(){return'\nRôle :\nTu es un agent d\'extraction de données OCR haute précision, spécialisé exclusivement dans les factures du secteur automobile (garages, concessions, centres de réparation).\nDirectives de sortie strictes :\nTon analyse doit être binaire : soit un objet JSON, soit le mot null.\nNe produis AUCUN texte avant ou après le JSON (pas de "Voici le résultat", pas de blocs de code Markdown ```json).\nSi le texte fourni n\'est pas une facture automobile identifiable, réponds uniquement : null.\nSchéma JSON cible :\n{\n "reference": string | null,\n "date": "YYYY-MM-DD" | null,\n "supplier": string | null,\n "customer": string | null,\n "totalAmount": number | null,\n "currency": "ISO_CODE" | null,\n "address": string | null,\n "items": [\n {\n "description": string,\n "quantity": number | null,\n "unitPrice": number | null,\n "totalPrice": number | null,\n "category": "carrosserie" | "depannage" | "entretien_preventif" | "reparation_curative" | "diagnostic_electronique" | "autre"\n }\n ],\n "taxAmount": number | null,\n "language": "ISO_639-1" | null\n}\nLogique de classification des items (Priorité absolue) :\nClasse chaque ligne de service/pièce selon ces mots-clés :\ncarrosserie : peinture, tôle, choc, débosselage, redressage, aile, pare-chocs.\ndepannage : remorquage, assistance, transport véhicule, batterie (si dépannage sur place).\nentretien_preventif : vidange, révision, remplacement filtres (air/huile/habitacle), niveaux, bougies.\nreparation_curative : freinage (plaquettes/disques), embrayage, distribution, cardan, amortisseurs, moteur, boîte de vitesse.\ndiagnostic_electronique : passage valise, lecture codes défaut, programmation, reset voyant.\nautre : frais de dossier, recyclage déchets, main d\'œuvre non spécifiée.\nRègles de formatage des données :\nNombres : Utilise exclusivement le point . comme séparateur décimal. Pas de séparateur de milliers.\nDates : Normalise impérativement au format YYYY-MM-DD.\nDevise : Utilise le code ISO 4217 (ex: EUR, MAD, USD).\nIntégrité : Si une valeur est incertaine ou absente, utilise null. Ne devine jamais une information.\n'},getTasksCreationPrompt:function(e,t){return`\n CONTEXTE: Creation de tâches dans une solution de fleet management system.\n Tu es le responsable de park en maintenance de flottes(automobiles, camions, vehicules). \n Les taches sont le moyen de communiquer entre les personnes impliquées dans la gestion de resolution de l'intervention.\n Tu reçois les signalement des chauffeurs sur l'état de leurs véhicules. \n\n À partir de l'intervention, génère un tableau JSON de tâches détaillées et structurées.\n Tu pourrais recevoir un audio ou une photo descriptive de l'intervention ou de la panne.\n Il faudra les analyser pour en extraire des informations utiles à la création des tâches.\n Genere uniquement des taches principales relatives à la resolution de l'intervention.'\n \n **Titre :** ${e}\n **Description :** ${t}\n Réponds UNIQUEMENT avec un tableau JSON valide (sans markdown, sans explication), en suivant exactement ce format :\n [\n {\n "title": "Titre de la tâche",\n "description": "Description détaillée",\n "category": "catégorie de la tache(exemple: mécanique, electric, pneumatique,..)"\n }\n ]`},cleanJsonResponse:function(e){return e.replace(/```json/g,"").replace(/```/g,"").trim()},getMimeType:function(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",mp3:"audio/mpeg",wav:"audio/wav"}[e.replace(".","").toLowerCase()]},safeParseJSON:function(e){if(!e)return null;let t=e.replace(/```json/gi,"").replace(/```/g,"").trim();if("null"===t)return null;const n=t.match(/\{[\s\S]*\}/);return n?(t=n[0],t=t.replace(/,\s*([\]}])/g,"$1"),t=t.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,""),JSON.parse(t)):null}}}var C=t(function(){if(g)return m;g=1;const{GoogleGenAI:t}=S(),{extractFromBase64:n}=function(){if(d)return p;d=1;const{fromBuffer:t}=e,{getExtractionPrompt:n}=A(),{safeParseJSON:o}=A(),{Type:i}=S();return p={extractFromBase64:async function(e,r,s){if(!s)return null;if(!e)throw new Error("InvoiceExtractor not initialized. Call init() first.");let l,a=s;const u=s.match(/^data:(.*);base64,(.*)$/);if(u)l=u[1],a=u[2];else{const e=Buffer.from(s,"base64"),n=await t(e);if(!n)throw new Error("Unable to detect file type");l=n.mime}const c=await e.models.generateContent({model:r,contents:[{role:"user",parts:[{inlineData:{mimeType:l,data:a}},{text:n()}]}],config:{responseMimeType:"application/json",responseSchema:{type:i.OBJECT,properties:{reference:{type:i.STRING,nullable:!0},date:{type:i.STRING,nullable:!0},supplier:{type:i.STRING,nullable:!0},customer:{type:i.STRING,nullable:!0},totalAmount:{type:i.NUMBER,nullable:!0},currency:{type:i.STRING,nullable:!0},address:{type:i.STRING,nullable:!0},taxAmount:{type:i.NUMBER,nullable:!0},language:{type:i.STRING,nullable:!0},items:{type:i.ARRAY,items:{type:i.OBJECT,properties:{description:{type:i.STRING},quantity:{type:i.NUMBER,nullable:!0},unitPrice:{type:i.NUMBER,nullable:!0},totalPrice:{type:i.NUMBER,nullable:!0},category:{type:i.STRING,enum:["carrosserie","depannage","entretien_preventif","reparation_curative","diagnostic_electronique","autre"]}}}}}}}});return c?.text?o(c.text):null}}}(),{generateTasks:o}=function(){if(f)return h;f=1;const{cleanJsonResponse:e,getMimeType:t,getTasksCreationPrompt:n}=A();return h={generateTasks:async function(o,i,r,s,l,a){if(!r||!s)throw new Error("Le titre et la description sont obligatoires.");if(!o)throw new Error("TasksGenerator not initialized. Call init() first.");const u=[];l&&u.push({inlineData:{mimeType:t(l.extension),data:Buffer.from(l.buffer).toString("base64")}}),a&&u.push({inlineData:{mimeType:t(a.extension),data:Buffer.from(a.buffer).toString("base64")}}),u.push({text:n(r,s)});const c=await o.models.generateContent({model:i,contents:[{role:"user",parts:u}],generationConfig:{maxOutputTokens:2048,temperature:.2}}),p=c.candidates?.[0]?.content?.parts?.[0]?.text?.trim();if(!p)throw new Error("Réponse vide du modèle.");const d=JSON.parse(e(p));if(!Array.isArray(d))throw new Error("La réponse n'est pas un tableau JSON.");return d}}}();return m=new class{#e;#t;init({apiKey:e,model:n}={}){const o=e??process.env.AI_API_KEY,i=n??process.env.AI_MODEL??"gemini-2.5-flash";if(!o)throw new Error("API key is required. Provide it via init() or AI_API_KEY env variable.");return this.#e=new t({apiKey:o}),this.#t=i,this}extract(e){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return n(this.#e,this.#t,e)}generateTasks(e,t,n,i){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return o(this.#e,this.#t,e,t,n,i)}}}());module.exports=C;
300
+ */e.ApiError=pn,e.Batches=Gt,e.Caches=Yt,e.CancelTuningJobResponse=Ue,e.Chat=on,e.Chats=nn,e.ComputeTokensResponse=Pe,e.ContentReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTENT",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.ControlReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_CONTROL",referenceImage:this.referenceImage,referenceId:this.referenceId,controlImageConfig:this.config}}},e.CountTokensResponse=Ne,e.CreateFileResponse=je,e.DeleteCachedContentResponse=xe,e.DeleteFileResponse=Ve,e.DeleteModelResponse=we,e.EditImageResponse=Ae,e.EmbedContentResponse=_e,e.Files=An,e.FunctionResponse=class{},e.FunctionResponseBlob=class{},e.FunctionResponseFileData=class{},e.FunctionResponsePart=class{},e.GenerateContentResponse=Ie,e.GenerateContentResponsePromptFeedback=class{},e.GenerateContentResponseUsageMetadata=class{},e.GenerateImagesResponse=Se,e.GenerateVideosOperation=Me,e.GenerateVideosResponse=class{},e.GoogleGenAI=class{get interactions(){var e;if(void 0!==this._interactions)return this._interactions;if(console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."),this.vertexai)throw new Error("This version of the GenAI SDK does not support Vertex AI API for interactions.");const t=this.httpOptions;(null==t?void 0:t.extraBody)&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const n=new Fo({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:null==t?void 0:t.timeout,maxRetries:null===(e=null==t?void 0:t.retryOptions)||void 0===e?void 0:e.attempts});return this._interactions=n.interactions,this._interactions}constructor(e){var t;if(null==e.apiKey)throw new Error(`An API Key must be set when running in an unspecified environment.\n + ${gn().message}`);this.vertexai=null!==(t=e.vertexai)&&void 0!==t&&t,this.apiKey=e.apiKey,this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const n=new dr(this.apiKey);this.apiClient=new fn({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/cross",uploader:new En,downloader:new yn}),this.models=new Xi(this.apiClient),this.live=new Bi(this.apiClient,n,new _n),this.chats=new nn(this.models,this.apiClient),this.batches=new Gt(this.apiClient),this.caches=new Yt(this.apiClient),this.files=new An(this.apiClient),this.operations=new Qi(this.apiClient),this.authTokens=new nr(this.apiClient),this.tunings=new cr(this.apiClient),this.fileSearchStores=new Rn(this.apiClient)}},e.HttpResponse=Te,e.ImportFileOperation=Fe,e.ImportFileResponse=class{},e.InlinedEmbedContentResponse=class{},e.InlinedResponse=class{},e.ListBatchJobsResponse=Je,e.ListCachedContentsResponse=Le,e.ListDocumentsResponse=ke,e.ListFileSearchStoresResponse=qe,e.ListFilesResponse=He,e.ListModelsResponse=Re,e.ListTuningJobsResponse=De,e.Live=Bi,e.LiveClientToolResponse=class{},e.LiveMusicServerMessage=Ye,e.LiveSendToolResponseParameters=class{constructor(){this.functionResponses=[]}},e.LiveServerMessage=$e,e.MaskReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_MASK",referenceImage:this.referenceImage,referenceId:this.referenceId,maskImageConfig:this.config}}},e.Models=Xi,e.Operations=Qi,e.Pager=qt,e.RawReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_RAW",referenceImage:this.referenceImage,referenceId:this.referenceId}}},e.RecontextImageResponse=Oe,e.RegisterFilesResponse=Be,e.ReplayResponse=class{},e.SegmentImageResponse=be,e.Session=$i,e.SingleEmbedContentResponse=class{},e.StyleReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_STYLE",referenceImage:this.referenceImage,referenceId:this.referenceId,styleImageConfig:this.config}}},e.SubjectReferenceImage=class{toReferenceImageAPI(){return{referenceType:"REFERENCE_TYPE_SUBJECT",referenceImage:this.referenceImage,referenceId:this.referenceId,subjectImageConfig:this.config}}},e.Tokens=nr,e.UploadToFileSearchStoreOperation=Ke,e.UploadToFileSearchStoreResponse=class{},e.UploadToFileSearchStoreResumableResponse=Ge,e.UpscaleImageResponse=Ce,e.createFunctionResponsePartFromBase64=function(e,t){return{inlineData:{data:e,mimeType:t}}},e.createFunctionResponsePartFromUri=function(e,t){return{fileData:{fileUri:e,mimeType:t}}},e.createModelContent=function(e){return{role:"model",parts:Ee(e)}},e.createPartFromBase64=function(e,t,n){return Object.assign({inlineData:{data:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createPartFromCodeExecutionResult=function(e,t){return{codeExecutionResult:{outcome:e,output:t}}},e.createPartFromExecutableCode=function(e,t){return{executableCode:{code:e,language:t}}},e.createPartFromFunctionCall=function(e,t){return{functionCall:{name:e,args:t}}},e.createPartFromFunctionResponse=function(e,t,n,o=[]){return{functionResponse:Object.assign({id:e,name:t,response:n},o.length>0&&{parts:o})}},e.createPartFromText=ye,e.createPartFromUri=function(e,t,n){return Object.assign({fileData:{fileUri:e,mimeType:t}},n&&{mediaResolution:{level:n}})},e.createUserContent=function(e){return{role:"user",parts:Ee(e)}},e.mcpToTool=function(...e){if(Li=!0,0===e.length)throw new Error("No MCP clients provided");const t=e[e.length-1];return null!==(n=t)&&"object"==typeof n&&"listTools"in n&&"function"==typeof n.listTools?Hi.create(e,{}):Hi.create(e.slice(0,e.length-1),t);var n},e.setDefaultBaseUrls=function(e){e.geminiUrl,e.vertexUrl}}(y)),y}function A(){if(c)return u;c=1;const{fromBuffer:t}=e;return u={getExtractionPrompt:function(){return'\nRôle :\nTu es un agent d\'extraction de données OCR haute précision, spécialisé exclusivement dans les factures du secteur automobile (garages, concessions, centres de réparation).\nDirectives de sortie strictes :\nTon analyse doit être binaire : soit un objet JSON, soit le mot null.\nNe produis AUCUN texte avant ou après le JSON (pas de "Voici le résultat", pas de blocs de code Markdown ```json).\nSi le texte fourni n\'est pas une facture automobile identifiable, réponds uniquement : null.\nSchéma JSON cible :\n{\n "reference": string | null,\n "date": "YYYY-MM-DD" | null,\n "supplier": string | null,\n "customer": string | null,\n "totalAmount": number | null,\n "currency": "ISO_CODE" | null,\n "address": string | null,\n "items": [\n {\n "description": string,\n "quantity": number | null,\n "unitPrice": number | null,\n "totalPrice": number | null,\n "category": "carrosserie" | "depannage" | "entretien_preventif" | "reparation_curative" | "diagnostic_electronique" | "autre"\n }\n ],\n "taxAmount": number | null,\n "language": "ISO_639-1" | null\n}\nLogique de classification des items (Priorité absolue) :\nClasse chaque ligne de service/pièce selon ces mots-clés :\ncarrosserie : peinture, tôle, choc, débosselage, redressage, aile, pare-chocs.\ndepannage : remorquage, assistance, transport véhicule, batterie (si dépannage sur place).\nentretien_preventif : vidange, révision, remplacement filtres (air/huile/habitacle), niveaux, bougies.\nreparation_curative : freinage (plaquettes/disques), embrayage, distribution, cardan, amortisseurs, moteur, boîte de vitesse.\ndiagnostic_electronique : passage valise, lecture codes défaut, programmation, reset voyant.\nautre : frais de dossier, recyclage déchets, main d\'œuvre non spécifiée.\nRègles de formatage des données :\nNombres : Utilise exclusivement le point . comme séparateur décimal. Pas de séparateur de milliers.\nDates : Normalise impérativement au format YYYY-MM-DD.\nDevise : Utilise le code ISO 4217 (ex: EUR, MAD, USD).\nIntégrité : Si une valeur est incertaine ou absente, utilise null. Ne devine jamais une information.\n'},getTasksCreationPrompt:function({driverName:e,brand:t,model:n,firstCirculationDate:o,licensePlate:i,mileage:r,lastInterventionDate:s=null,interventionType:l,interventionDescription:a,attachments:u=[]}){return`\nCONTEXTE:\nTu es un expert en maintenance de flottes automobiles.\nTu génères des tâches opérationnelles TECHNIQUES et PRÉCISES pour résoudre une intervention sur un véhicule.\n\nACTEURS DISPONIBLES:\n- Chauffeur : conduit et remet le véhicule\n- Responsable de parc : supervise et valide les interventions\n- Mécanicien : réalise les interventions techniques\n- Garage : structure physique de réparation\n- Admin : gestion documentaire et système\n\nRÈGLES STRICTES:\n1. Génère UNIQUEMENT les tâches techniques directement liées aux problèmes décrits.\n2. Chaque tâche doit être SPÉCIFIQUE à la panne/intervention décrite, pas générique.\n3. Les tâches administratives (devis, approbation) ne sont à inclure QUE si l'intervention est complexe ou coûteuse.\n4. Évite les doublons : une tâche "diagnostic" ne doit pas être répétée dans "réparation".\n5. Maximum 5 à 6 tâches. Priorise les actions techniques concrètes.\n6. Le champ "description" doit mentionner les éléments techniques précis issus de la description de l'intervention (ex: type de panne, organe concerné).\n7. Ne jamais inventer ou extrapoler des données non fournies (ex: kilométrage de révision).\n\n---\n\nDEMANDE D'INTERVENTION:\n\nConducteur / Demandeur : ${e}\n\nVéhicule\n - Marque : ${t}\n - Modèle : ${n}\n - 1ère mise en circulation : ${o}\n - Immatriculation : ${i}\n - Kilométrage actuel : ${r} km\n ${s?`- Dernière intervention : ${s}`:""}\n\nIntervention\n - Type : ${l}\n - Description précise : ${a}\n ${u.length>0?`- Pièces jointes : ${u.join(", ")} Si des images ou audios sont fournis :\n- Analyse-les attentivement\n- Identifie les anomalies visibles (image) ou décrites (audio)\n- Utilise ces informations pour enrichir les tâches techniques\n- Ne te base pas uniquement sur le texte si des indices supplémentaires sont présents`:""}\n\n---\n\nFORMAT DE RÉPONSE:\nRéponds UNIQUEMENT avec un tableau JSON valide.\nSans markdown, sans explication, sans texte avant ou après.\n\n[\n {\n "title": "Titre court, technique et spécifique à la panne",\n "description": "Action concrète que l'acteur doit réaliser, avec les éléments techniques précis de la panne (organe, symptôme, opération attendue)",\n "category": "Catégorie technique précise (ex: Freinage, Moteur, Entretien périodique, Électronique...)",\n "acteur": "Acteur exact parmi la liste",\n "order": 1\n }\n]\n`},cleanJsonResponse:function(e){return e.replace(/```json/g,"").replace(/```/g,"").trim()},parseBase64:async function(e){let n,o=e;const i=e.match(/^data:(.*);base64,(.*)$/);if(i)n=i[1],o=i[2];else{const o=Buffer.from(e,"base64"),i=await t(o);if(!i)throw new Error("Unable to detect file type");n=i.mime}return{mimeType:n,cleanBase64:o}},safeParseJSON:function(e){if(!e)return null;let t=e.replace(/```json/gi,"").replace(/```/g,"").trim();if("null"===t)return null;const n=t.match(/\{[\s\S]*\}/);return n?(t=n[0],t=t.replace(/,\s*([\]}])/g,"$1"),t=t.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,""),JSON.parse(t)):null}}}var C=t(function(){if(g)return m;g=1;const{GoogleGenAI:e}=S(),{extractFromBase64:t}=function(){if(d)return p;d=1;const{getExtractionPrompt:e,safeParseJSON:t,parseBase64:n}=A(),{Type:o}=S();return p={extractFromBase64:async function(i,r,s){if(!s)return null;if(!i)throw new Error("InvoiceExtractor not initialized. Call init() first.");const{mimeType:l,cleanBase64:a}=await n(s),u=await i.models.generateContent({model:r,contents:[{role:"user",parts:[{inlineData:{mimeType:l,data:a}},{text:e()}]}],config:{responseMimeType:"application/json",responseSchema:{type:o.OBJECT,properties:{reference:{type:o.STRING,nullable:!0},date:{type:o.STRING,nullable:!0},supplier:{type:o.STRING,nullable:!0},customer:{type:o.STRING,nullable:!0},totalAmount:{type:o.NUMBER,nullable:!0},currency:{type:o.STRING,nullable:!0},address:{type:o.STRING,nullable:!0},taxAmount:{type:o.NUMBER,nullable:!0},language:{type:o.STRING,nullable:!0},items:{type:o.ARRAY,items:{type:o.OBJECT,properties:{description:{type:o.STRING},quantity:{type:o.NUMBER,nullable:!0},unitPrice:{type:o.NUMBER,nullable:!0},totalPrice:{type:o.NUMBER,nullable:!0},category:{type:o.STRING,enum:["carrosserie","depannage","entretien_preventif","reparation_curative","diagnostic_electronique","autre"]}}}}}}}});return u?.text?t(u.text):null}}}(),{generateTasks:n}=function(){if(f)return h;f=1;const{cleanJsonResponse:e,getTasksCreationPrompt:t,parseBase64:n}=A();return h={generateTasks:async function(o,i,r,s,l){if(!r?.driverName||!r?.interventionDescription)throw new Error("Le nom du conducteur et la description de l'intervention sont obligatoires.");if(!o)throw new Error("TasksGenerator not initialized. Call init() first.");const a=[];if(s){const{mimeType:e,cleanBase64:t}=await n(s);a.push({inlineData:{mimeType:e,data:t}})}if(l){const{mimeType:e,cleanBase64:t}=await n(l);a.push({inlineData:{mimeType:e,data:t}})}a.push({text:t(r)});const u=await o.models.generateContent({model:i,contents:[{role:"user",parts:a}],generationConfig:{maxOutputTokens:2048,temperature:.2}}),c=u.candidates?.[0]?.content?.parts?.[0]?.text?.trim();if(!c)throw new Error("Réponse vide du modèle.");const p=JSON.parse(e(c));if(!Array.isArray(p))throw new Error("La réponse n'est pas un tableau JSON.");return p}}}();return m=new class{#e;#t;init({apiKey:t,model:n}={}){const o=t??process.env.AI_API_KEY,i=n??process.env.AI_MODEL??"gemini-2.5-flash";if(!o)throw new Error("API key is required. Provide it via init() or AI_API_KEY env variable.");return this.#e=new e({apiKey:o}),this.#t=i,this}extract(e){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return t(this.#e,this.#t,e)}generateTasks(e,t,o){if(!this.#e)throw new Error("AiModule not initialized. Call init() first.");return n(this.#e,this.#t,e,t,o)}}}());module.exports=C;