swerasty_editor 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(ee,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],m):(ee=typeof globalThis<"u"?globalThis:ee||self,m(ee.MyReactLibrary={},ee.jsxRuntime,ee.React))})(this,function(ee,m,w){"use strict";const ft=w.forwardRef(({onHistoryChange:t},e)=>{const n=w.useRef(null),o=w.useRef(null),[s,l]=w.useState(!1),[a,u]=w.useState(!1),c=w.useRef(null),[d,f]=w.useState([]),[p,h]=w.useState(-1),g=w.useCallback(()=>{const _=n.current,v=c.current;if(!_||!v||_.width===0||_.height===0)return;const S=v.getImageData(0,0,_.width,_.height),x=d.slice(0,p+1);f([...x,S]),h(x.length)},[d,p]);w.useEffect(()=>{t==null||t({canUndo:p>0,canRedo:p<d.length-1})},[d,p,t]),w.useEffect(()=>{if(typeof window>"u")return;const _=n.current,v=o.current;if(!_||!v)return;c.current=_.getContext("2d");const S=new ResizeObserver(x=>{var R;const{width:P,height:M}=x[0].contentRect;if(P===0||M===0)return;let b=null;_.width>0&&_.height>0&&(b=((R=c.current)==null?void 0:R.getImageData(0,0,_.width,_.height))||null),_.width=P,_.height=M;const A=c.current;if(A&&(A.lineCap="round",A.strokeStyle="#000",A.lineWidth=2,b&&A.putImageData(b,0,0)),d.length===0){const F=A==null?void 0:A.getImageData(0,0,P,M);F&&(f([F]),h(0))}});return S.observe(v),()=>{S.disconnect()}},[]);const y=_=>{const v=n.current;if(!v)return{offsetX:0,offsetY:0};const S=v.getBoundingClientRect(),x="touches"in _?_.touches[0].clientX:_.clientX,P="touches"in _?_.touches[0].clientY:_.clientY;return{offsetX:x-S.left,offsetY:P-S.top}},C=_=>{_.preventDefault();const v=c.current;if(!v)return;const{offsetX:S,offsetY:x}=y(_);v.beginPath(),v.moveTo(S,x),l(!0),u(!0)},T=()=>{const _=c.current;!_||!s||(_.closePath(),l(!1),g())},E=_=>{if(!s||!c.current)return;_.preventDefault();const{offsetX:v,offsetY:S}=y(_);c.current.lineTo(v,S),c.current.stroke()};return w.useImperativeHandle(e,()=>({clear(){const _=c.current,v=n.current;if(_&&v&&v.width>0&&v.height>0){_.clearRect(0,0,v.width,v.height),u(!1);const S=_.getImageData(0,0,v.width,v.height);f([S]),h(0)}},undo(){var _;if(p>0){const v=p-1;h(v);const S=d[v];(_=c.current)==null||_.putImageData(S,0,0),u(v>0)}},redo(){var _;if(p<d.length-1){const v=p+1;h(v);const S=d[v];(_=c.current)==null||_.putImageData(S,0,0),u(!0)}},getTrimmedImageData(){const _=n.current,v=c.current;if(!a||!_||!v||_.width===0||_.height===0)return null;const S=_.width,x=_.height,M=v.getImageData(0,0,S,x).data;let b=S,A=x,R=0,F=0;for(let q=0;q<x;q++)for(let K=0;K<S;K++)M[(S*q+K)*4+3]>0&&(b=Math.min(b,K),A=Math.min(A,q),R=Math.max(R,K),F=Math.max(F,q));if(b===S)return null;const D=15;b=Math.max(0,b-D),A=Math.max(0,A-D),R=Math.min(S,R+D),F=Math.min(x,F+D);const U=R-b,V=F-A,N=document.createElement("canvas");N.width=U,N.height=V;const G=N.getContext("2d");return G?(G.drawImage(_,b,A,U,V,0,0,U,V),N.toDataURL("image/png")):null}})),m.jsx("div",{ref:o,className:"absolute inset-0 w-full h-full",children:m.jsx("canvas",{ref:n,onMouseDown:C,onMouseUp:T,onMouseMove:E,onMouseLeave:T,onTouchStart:C,onTouchEnd:T,onTouchMove:E,className:"w-full h-full",style:{cursor:"crosshair",touchAction:"none"}})})});ft.displayName="Canvas";/**
1
+ (function(te,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],m):(te=typeof globalThis<"u"?globalThis:te||self,m(te.MyReactLibrary={},te.jsxRuntime,te.React))})(this,function(te,m,w){"use strict";const ft=w.forwardRef(({onHistoryChange:t},e)=>{const n=w.useRef(null),o=w.useRef(null),[s,l]=w.useState(!1),[a,u]=w.useState(!1),c=w.useRef(null),[d,f]=w.useState([]),[p,h]=w.useState(-1),g=w.useCallback(()=>{const _=n.current,v=c.current;if(!_||!v||_.width===0||_.height===0)return;const S=v.getImageData(0,0,_.width,_.height),x=d.slice(0,p+1);f([...x,S]),h(x.length)},[d,p]);w.useEffect(()=>{t==null||t({canUndo:p>0,canRedo:p<d.length-1})},[d,p,t]),w.useEffect(()=>{if(typeof window>"u")return;const _=n.current,v=o.current;if(!_||!v)return;c.current=_.getContext("2d");const S=new ResizeObserver(x=>{var R;const{width:P,height:M}=x[0].contentRect;if(P===0||M===0)return;let b=null;_.width>0&&_.height>0&&(b=((R=c.current)==null?void 0:R.getImageData(0,0,_.width,_.height))||null),_.width=P,_.height=M;const A=c.current;if(A&&(A.lineCap="round",A.strokeStyle="#000",A.lineWidth=2,b&&A.putImageData(b,0,0)),d.length===0){const F=A==null?void 0:A.getImageData(0,0,P,M);F&&(f([F]),h(0))}});return S.observe(v),()=>{S.disconnect()}},[]);const y=_=>{const v=n.current;if(!v)return{offsetX:0,offsetY:0};const S=v.getBoundingClientRect(),x="touches"in _?_.touches[0].clientX:_.clientX,P="touches"in _?_.touches[0].clientY:_.clientY;return{offsetX:x-S.left,offsetY:P-S.top}},C=_=>{_.preventDefault();const v=c.current;if(!v)return;const{offsetX:S,offsetY:x}=y(_);v.beginPath(),v.moveTo(S,x),l(!0),u(!0)},T=()=>{const _=c.current;!_||!s||(_.closePath(),l(!1),g())},E=_=>{if(!s||!c.current)return;_.preventDefault();const{offsetX:v,offsetY:S}=y(_);c.current.lineTo(v,S),c.current.stroke()};return w.useImperativeHandle(e,()=>({clear(){const _=c.current,v=n.current;if(_&&v&&v.width>0&&v.height>0){_.clearRect(0,0,v.width,v.height),u(!1);const S=_.getImageData(0,0,v.width,v.height);f([S]),h(0)}},undo(){var _;if(p>0){const v=p-1;h(v);const S=d[v];(_=c.current)==null||_.putImageData(S,0,0),u(v>0)}},redo(){var _;if(p<d.length-1){const v=p+1;h(v);const S=d[v];(_=c.current)==null||_.putImageData(S,0,0),u(!0)}},getTrimmedImageData(){const _=n.current,v=c.current;if(!a||!_||!v||_.width===0||_.height===0)return null;const S=_.width,x=_.height,M=v.getImageData(0,0,S,x).data;let b=S,A=x,R=0,F=0;for(let q=0;q<x;q++)for(let z=0;z<S;z++)M[(S*q+z)*4+3]>0&&(b=Math.min(b,z),A=Math.min(A,q),R=Math.max(R,z),F=Math.max(F,q));if(b===S)return null;const D=15;b=Math.max(0,b-D),A=Math.max(0,A-D),R=Math.min(S,R+D),F=Math.min(x,F+D);const U=R-b,V=F-A,N=document.createElement("canvas");N.width=U,N.height=V;const G=N.getContext("2d");return G?(G.drawImage(_,b,A,U,V,0,0,U,V),N.toDataURL("image/png")):null}})),m.jsx("div",{ref:o,className:"absolute inset-0 w-full h-full",children:m.jsx("canvas",{ref:n,onMouseDown:C,onMouseUp:T,onMouseMove:E,onMouseLeave:T,onTouchStart:C,onTouchEnd:T,onTouchMove:E,className:"w-full h-full",style:{cursor:"crosshair",touchAction:"none"}})})});ft.displayName="Canvas";/**
2
2
  * @license
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
@@ -6,7 +6,7 @@
6
6
  * @license
7
7
  * Copyright 2025 Google LLC
8
8
  * SPDX-License-Identifier: Apache-2.0
9
- */class Q{}function I(t,e){const n=/\{([^}]+)\}/g;return t.replace(n,(o,s)=>{if(Object.prototype.hasOwnProperty.call(e,s)){const l=e[s];return l!=null?String(l):""}else throw new Error(`Key '${s}' not found in valueMap.`)})}function r(t,e,n){for(let l=0;l<e.length-1;l++){const a=e[l];if(a.endsWith("[]")){const u=a.slice(0,-2);if(!(u in t))if(Array.isArray(n))t[u]=Array.from({length:n.length},()=>({}));else throw new Error(`Value must be a list given an array path ${a}`);if(Array.isArray(t[u])){const c=t[u];if(Array.isArray(n))for(let d=0;d<c.length;d++){const f=c[d];r(f,e.slice(l+1),n[d])}else for(const d of c)r(d,e.slice(l+1),n)}return}else if(a.endsWith("[0]")){const u=a.slice(0,-3);u in t||(t[u]=[{}]);const c=t[u];r(c[0],e.slice(l+1),n);return}(!t[a]||typeof t[a]!="object")&&(t[a]={}),t=t[a]}const o=e[e.length-1],s=t[o];if(s!==void 0){if(!n||typeof n=="object"&&Object.keys(n).length===0||n===s)return;if(typeof s=="object"&&typeof n=="object"&&s!==null&&n!==null)Object.assign(s,n);else throw new Error(`Cannot set value for an existing key. Key: ${o}`)}else o==="_self"&&typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.assign(t,n):t[o]=n}function i(t,e,n=void 0){try{if(e.length===1&&e[0]==="_self")return t;for(let o=0;o<e.length;o++){if(typeof t!="object"||t===null)return n;const s=e[o];if(s.endsWith("[]")){const l=s.slice(0,-2);if(l in t){const a=t[l];return Array.isArray(a)?a.map(u=>i(u,e.slice(o+1),n)):n}else return n}else t=t[s]}return t}catch(o){if(o instanceof TypeError)return n;throw o}}function ei(t,e){for(const[n,o]of Object.entries(e)){const s=n.split("."),l=o.split("."),a=new Set;let u=-1;for(let c=0;c<s.length;c++)if(s[c]==="*"){u=c;break}if(u!==-1&&l.length>u)for(let c=u;c<l.length;c++){const d=l[c];d!=="*"&&!d.endsWith("[]")&&!d.endsWith("[0]")&&a.add(d)}Ve(t,s,l,0,a)}}function Ve(t,e,n,o,s){if(o>=e.length||typeof t!="object"||t===null)return;const l=e[o];if(l.endsWith("[]")){const a=l.slice(0,-2),u=t;if(a in u&&Array.isArray(u[a]))for(const c of u[a])Ve(c,e,n,o+1,s)}else if(l==="*"){if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const a=t,u=Object.keys(a).filter(d=>!d.startsWith("_")&&!s.has(d)),c={};for(const d of u)c[d]=a[d];for(const[d,f]of Object.entries(c)){const p=[];for(const h of n.slice(o))h==="*"?p.push(d):p.push(h);r(a,p,f)}for(const d of u)delete a[d]}}else{const a=t;l in a&&Ve(a[l],e,n,o+1,s)}}/**
9
+ */class Z{}function I(t,e){const n=/\{([^}]+)\}/g;return t.replace(n,(o,s)=>{if(Object.prototype.hasOwnProperty.call(e,s)){const l=e[s];return l!=null?String(l):""}else throw new Error(`Key '${s}' not found in valueMap.`)})}function r(t,e,n){for(let l=0;l<e.length-1;l++){const a=e[l];if(a.endsWith("[]")){const u=a.slice(0,-2);if(!(u in t))if(Array.isArray(n))t[u]=Array.from({length:n.length},()=>({}));else throw new Error(`Value must be a list given an array path ${a}`);if(Array.isArray(t[u])){const c=t[u];if(Array.isArray(n))for(let d=0;d<c.length;d++){const f=c[d];r(f,e.slice(l+1),n[d])}else for(const d of c)r(d,e.slice(l+1),n)}return}else if(a.endsWith("[0]")){const u=a.slice(0,-3);u in t||(t[u]=[{}]);const c=t[u];r(c[0],e.slice(l+1),n);return}(!t[a]||typeof t[a]!="object")&&(t[a]={}),t=t[a]}const o=e[e.length-1],s=t[o];if(s!==void 0){if(!n||typeof n=="object"&&Object.keys(n).length===0||n===s)return;if(typeof s=="object"&&typeof n=="object"&&s!==null&&n!==null)Object.assign(s,n);else throw new Error(`Cannot set value for an existing key. Key: ${o}`)}else o==="_self"&&typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.assign(t,n):t[o]=n}function i(t,e,n=void 0){try{if(e.length===1&&e[0]==="_self")return t;for(let o=0;o<e.length;o++){if(typeof t!="object"||t===null)return n;const s=e[o];if(s.endsWith("[]")){const l=s.slice(0,-2);if(l in t){const a=t[l];return Array.isArray(a)?a.map(u=>i(u,e.slice(o+1),n)):n}else return n}else t=t[s]}return t}catch(o){if(o instanceof TypeError)return n;throw o}}function ei(t,e){for(const[n,o]of Object.entries(e)){const s=n.split("."),l=o.split("."),a=new Set;let u=-1;for(let c=0;c<s.length;c++)if(s[c]==="*"){u=c;break}if(u!==-1&&l.length>u)for(let c=u;c<l.length;c++){const d=l[c];d!=="*"&&!d.endsWith("[]")&&!d.endsWith("[0]")&&a.add(d)}Ve(t,s,l,0,a)}}function Ve(t,e,n,o,s){if(o>=e.length||typeof t!="object"||t===null)return;const l=e[o];if(l.endsWith("[]")){const a=l.slice(0,-2),u=t;if(a in u&&Array.isArray(u[a]))for(const c of u[a])Ve(c,e,n,o+1,s)}else if(l==="*"){if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const a=t,u=Object.keys(a).filter(d=>!d.startsWith("_")&&!s.has(d)),c={};for(const d of u)c[d]=a[d];for(const[d,f]of Object.entries(c)){const p=[];for(const h of n.slice(o))h==="*"?p.push(d):p.push(h);r(a,p,f)}for(const d of u)delete a[d]}}else{const a=t;l in a&&Ve(a[l],e,n,o+1,s)}}/**
10
10
  * @license
11
11
  * Copyright 2025 Google LLC
12
12
  * SPDX-License-Identifier: Apache-2.0
@@ -18,35 +18,35 @@
18
18
  * @license
19
19
  * Copyright 2025 Google LLC
20
20
  * SPDX-License-Identifier: Apache-2.0
21
- */var ht;(function(t){t.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(ht||(ht={}));var mt;(function(t){t.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",t.PYTHON="PYTHON"})(mt||(mt={}));var gt;(function(t){t.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",t.SILENT="SILENT",t.WHEN_IDLE="WHEN_IDLE",t.INTERRUPT="INTERRUPT"})(gt||(gt={}));var te;(function(t){t.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",t.STRING="STRING",t.NUMBER="NUMBER",t.INTEGER="INTEGER",t.BOOLEAN="BOOLEAN",t.ARRAY="ARRAY",t.OBJECT="OBJECT",t.NULL="NULL"})(te||(te={}));var yt;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(yt||(yt={}));var Tt;(function(t){t.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",t.SIMPLE_SEARCH="SIMPLE_SEARCH",t.ELASTIC_SEARCH="ELASTIC_SEARCH"})(Tt||(Tt={}));var _t;(function(t){t.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",t.NO_AUTH="NO_AUTH",t.API_KEY_AUTH="API_KEY_AUTH",t.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",t.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",t.OAUTH="OAUTH",t.OIDC_AUTH="OIDC_AUTH"})(_t||(_t={}));var Et;(function(t){t.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",t.HTTP_IN_QUERY="HTTP_IN_QUERY",t.HTTP_IN_HEADER="HTTP_IN_HEADER",t.HTTP_IN_PATH="HTTP_IN_PATH",t.HTTP_IN_BODY="HTTP_IN_BODY",t.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(Et||(Et={}));var Ct;(function(t){t.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",t.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",t.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",t.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Ct||(Ct={}));var vt;(function(t){t.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH",t.MINIMAL="MINIMAL"})(vt||(vt={}));var St;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",t.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",t.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",t.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",t.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(St||(St={}));var It;(function(t){t.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",t.SEVERITY="SEVERITY",t.PROBABILITY="PROBABILITY"})(It||(It={}));var At;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE",t.OFF="OFF"})(At||(At={}));var xt;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.OTHER="OTHER",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.IMAGE_SAFETY="IMAGE_SAFETY",t.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",t.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",t.NO_IMAGE="NO_IMAGE",t.IMAGE_RECITATION="IMAGE_RECITATION",t.IMAGE_OTHER="IMAGE_OTHER"})(xt||(xt={}));var wt;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(wt||(wt={}));var Nt;(function(t){t.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",t.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",t.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",t.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",t.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Nt||(Nt={}));var Mt;(function(t){t.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",t.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",t.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",t.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",t.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Mt||(Mt={}));var Pt;(function(t){t.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"})(Pt||(Pt={}));var Rt;(function(t){t.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",t.ON_DEMAND="ON_DEMAND",t.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Rt||(Rt={}));var _e;(function(t){t.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",t.TEXT="TEXT",t.IMAGE="IMAGE",t.AUDIO="AUDIO"})(_e||(_e={}));var kt;(function(t){t.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",t.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",t.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",t.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(kt||(kt={}));var Dt;(function(t){t.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",t.TUNING_MODE_FULL="TUNING_MODE_FULL",t.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Dt||(Dt={}));var bt;(function(t){t.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",t.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",t.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",t.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",t.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",t.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",t.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(bt||(bt={}));var He;(function(t){t.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",t.JOB_STATE_QUEUED="JOB_STATE_QUEUED",t.JOB_STATE_PENDING="JOB_STATE_PENDING",t.JOB_STATE_RUNNING="JOB_STATE_RUNNING",t.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",t.JOB_STATE_FAILED="JOB_STATE_FAILED",t.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",t.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",t.JOB_STATE_PAUSED="JOB_STATE_PAUSED",t.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",t.JOB_STATE_UPDATING="JOB_STATE_UPDATING",t.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(He||(He={}));var Ut;(function(t){t.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",t.TUNING_TASK_I2V="TUNING_TASK_I2V",t.TUNING_TASK_T2V="TUNING_TASK_T2V",t.TUNING_TASK_R2V="TUNING_TASK_R2V"})(Ut||(Ut={}));var Lt;(function(t){t.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",t.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",t.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",t.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",t.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(Lt||(Lt={}));var Ft;(function(t){t.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",t.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",t.BALANCED="BALANCED",t.PRIORITIZE_COST="PRIORITIZE_COST"})(Ft||(Ft={}));var Gt;(function(t){t.UNSPECIFIED="UNSPECIFIED",t.BLOCKING="BLOCKING",t.NON_BLOCKING="NON_BLOCKING"})(Gt||(Gt={}));var Vt;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Vt||(Vt={}));var qt;(function(t){t.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",t.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(qt||(qt={}));var Ht;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE",t.VALIDATED="VALIDATED"})(Ht||(Ht={}));var Bt;(function(t){t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(Bt||(Bt={}));var Jt;(function(t){t.DONT_ALLOW="DONT_ALLOW",t.ALLOW_ADULT="ALLOW_ADULT",t.ALLOW_ALL="ALLOW_ALL"})(Jt||(Jt={}));var $t;(function(t){t.auto="auto",t.en="en",t.ja="ja",t.ko="ko",t.hi="hi",t.zh="zh",t.pt="pt",t.es="es"})($t||($t={}));var Wt;(function(t){t.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",t.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",t.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",t.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",t.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Wt||(Wt={}));var Yt;(function(t){t.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",t.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",t.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",t.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Yt||(Yt={}));var Kt;(function(t){t.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",t.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",t.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",t.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Kt||(Kt={}));var zt;(function(t){t.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",t.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",t.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",t.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",t.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",t.EDIT_MODE_STYLE="EDIT_MODE_STYLE",t.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",t.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(zt||(zt={}));var Ot;(function(t){t.FOREGROUND="FOREGROUND",t.BACKGROUND="BACKGROUND",t.PROMPT="PROMPT",t.SEMANTIC="SEMANTIC",t.INTERACTIVE="INTERACTIVE"})(Ot||(Ot={}));var Xt;(function(t){t.ASSET="ASSET",t.STYLE="STYLE"})(Xt||(Xt={}));var Qt;(function(t){t.INSERT="INSERT",t.REMOVE="REMOVE",t.REMOVE_STATIC="REMOVE_STATIC",t.OUTPAINT="OUTPAINT"})(Qt||(Qt={}));var Zt;(function(t){t.OPTIMIZED="OPTIMIZED",t.LOSSLESS="LOSSLESS"})(Zt||(Zt={}));var jt;(function(t){t.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",t.PREFERENCE_TUNING="PREFERENCE_TUNING"})(jt||(jt={}));var en;(function(t){t.STATE_UNSPECIFIED="STATE_UNSPECIFIED",t.STATE_PENDING="STATE_PENDING",t.STATE_ACTIVE="STATE_ACTIVE",t.STATE_FAILED="STATE_FAILED"})(en||(en={}));var tn;(function(t){t.STATE_UNSPECIFIED="STATE_UNSPECIFIED",t.PROCESSING="PROCESSING",t.ACTIVE="ACTIVE",t.FAILED="FAILED"})(tn||(tn={}));var nn;(function(t){t.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",t.UPLOADED="UPLOADED",t.GENERATED="GENERATED"})(nn||(nn={}));var on;(function(t){t.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.RESPONSE_REJECTED="RESPONSE_REJECTED",t.NEED_MORE_INPUT="NEED_MORE_INPUT"})(on||(on={}));var sn;(function(t){t.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",t.TEXT="TEXT",t.IMAGE="IMAGE",t.VIDEO="VIDEO",t.AUDIO="AUDIO",t.DOCUMENT="DOCUMENT"})(sn||(sn={}));var rn;(function(t){t.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",t.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",t.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(rn||(rn={}));var ln;(function(t){t.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",t.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",t.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(ln||(ln={}));var an;(function(t){t.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",t.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",t.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(an||(an={}));var un;(function(t){t.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",t.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",t.NO_INTERRUPTION="NO_INTERRUPTION"})(un||(un={}));var dn;(function(t){t.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",t.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",t.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(dn||(dn={}));var cn;(function(t){t.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",t.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",t.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",t.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",t.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",t.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",t.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",t.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",t.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",t.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",t.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",t.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",t.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(cn||(cn={}));var fn;(function(t){t.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",t.QUALITY="QUALITY",t.DIVERSITY="DIVERSITY",t.VOCALIZATION="VOCALIZATION"})(fn||(fn={}));var le;(function(t){t.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",t.PLAY="PLAY",t.PAUSE="PAUSE",t.STOP="STOP",t.RESET_CONTEXT="RESET_CONTEXT"})(le||(le={}));class Be{constructor(e){const n={};for(const o of e.headers.entries())n[o[0]]=o[1];this.headers=n,this.responseInternal=e}json(){return this.responseInternal.json()}}class me{get text(){var e,n,o,s,l,a,u,c;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let d="",f=!1;const p=[];for(const h of(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)!==null&&c!==void 0?c:[]){for(const[g,y]of Object.entries(h))g!=="text"&&g!=="thought"&&g!=="thoughtSignature"&&(y!==null||y!==void 0)&&p.push(g);if(typeof h.text=="string"){if(typeof h.thought=="boolean"&&h.thought)continue;f=!0,d+=h.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),f?d:void 0}get data(){var e,n,o,s,l,a,u,c;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let d="";const f=[];for(const p of(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)!==null&&c!==void 0?c:[]){for(const[h,g]of Object.entries(p))h!=="inlineData"&&(g!==null||g!==void 0)&&f.push(h);p.inlineData&&typeof p.inlineData.data=="string"&&(d+=atob(p.inlineData.data))}return f.length>0&&console.warn(`there are non-data parts ${f} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}get functionCalls(){var e,n,o,s,l,a,u,c;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const d=(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)===null||c===void 0?void 0:c.filter(f=>f.functionCall).map(f=>f.functionCall).filter(f=>f!==void 0);if((d==null?void 0:d.length)!==0)return d}get executableCode(){var e,n,o,s,l,a,u,c,d;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const f=(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)===null||c===void 0?void 0:c.filter(p=>p.executableCode).map(p=>p.executableCode).filter(p=>p!==void 0);if((f==null?void 0:f.length)!==0)return(d=f==null?void 0:f[0])===null||d===void 0?void 0:d.code}get codeExecutionResult(){var e,n,o,s,l,a,u,c,d;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const f=(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)===null||c===void 0?void 0:c.filter(p=>p.codeExecutionResult).map(p=>p.codeExecutionResult).filter(p=>p!==void 0);if((f==null?void 0:f.length)!==0)return(d=f==null?void 0:f[0])===null||d===void 0?void 0:d.output}}class pn{}class hn{}class mi{}class gi{}class yi{}class Ti{}class mn{}class gn{}class yn{}class _i{}class Ee{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const o=new Ee;let s;const l=e;return n?s=oi(l):s=ni(l),Object.assign(o,s),o}}class Tn{}class _n{}class En{}class Cn{}class Ei{}class Ci{}class vi{}class Je{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const o=new Je,l=di(e);return Object.assign(o,l),o}}class Si{}class Ii{}class Ai{}class vn{}class xi{get text(){var e,n,o;let s="",l=!1;const a=[];for(const u of(o=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&o!==void 0?o:[]){for(const[c,d]of Object.entries(u))c!=="text"&&c!=="thought"&&d!==null&&a.push(c);if(typeof u.text=="string"){if(typeof u.thought=="boolean"&&u.thought)continue;l=!0,s+=u.text}}return a.length>0&&console.warn(`there are non-text parts ${a} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),l?s:void 0}get data(){var e,n,o;let s="";const l=[];for(const a of(o=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&o!==void 0?o:[]){for(const[u,c]of Object.entries(a))u!=="inlineData"&&c!==null&&l.push(u);a.inlineData&&typeof a.inlineData.data=="string"&&(s+=atob(a.inlineData.data))}return l.length>0&&console.warn(`there are non-data parts ${l} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),s.length>0?btoa(s):void 0}}class wi{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class $e{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const o=new $e,l=pt(e);return Object.assign(o,l),o}}/**
21
+ */var ht;(function(t){t.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",t.OUTCOME_OK="OUTCOME_OK",t.OUTCOME_FAILED="OUTCOME_FAILED",t.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(ht||(ht={}));var mt;(function(t){t.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",t.PYTHON="PYTHON"})(mt||(mt={}));var gt;(function(t){t.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",t.SILENT="SILENT",t.WHEN_IDLE="WHEN_IDLE",t.INTERRUPT="INTERRUPT"})(gt||(gt={}));var ne;(function(t){t.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",t.STRING="STRING",t.NUMBER="NUMBER",t.INTEGER="INTEGER",t.BOOLEAN="BOOLEAN",t.ARRAY="ARRAY",t.OBJECT="OBJECT",t.NULL="NULL"})(ne||(ne={}));var yt;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(yt||(yt={}));var Tt;(function(t){t.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",t.SIMPLE_SEARCH="SIMPLE_SEARCH",t.ELASTIC_SEARCH="ELASTIC_SEARCH"})(Tt||(Tt={}));var _t;(function(t){t.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",t.NO_AUTH="NO_AUTH",t.API_KEY_AUTH="API_KEY_AUTH",t.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",t.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",t.OAUTH="OAUTH",t.OIDC_AUTH="OIDC_AUTH"})(_t||(_t={}));var Et;(function(t){t.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",t.HTTP_IN_QUERY="HTTP_IN_QUERY",t.HTTP_IN_HEADER="HTTP_IN_HEADER",t.HTTP_IN_PATH="HTTP_IN_PATH",t.HTTP_IN_BODY="HTTP_IN_BODY",t.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(Et||(Et={}));var Ct;(function(t){t.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",t.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",t.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",t.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Ct||(Ct={}));var vt;(function(t){t.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH",t.MINIMAL="MINIMAL"})(vt||(vt={}));var St;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",t.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",t.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",t.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",t.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(St||(St={}));var It;(function(t){t.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",t.SEVERITY="SEVERITY",t.PROBABILITY="PROBABILITY"})(It||(It={}));var At;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE",t.OFF="OFF"})(At||(At={}));var xt;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.OTHER="OTHER",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.IMAGE_SAFETY="IMAGE_SAFETY",t.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",t.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",t.NO_IMAGE="NO_IMAGE",t.IMAGE_RECITATION="IMAGE_RECITATION",t.IMAGE_OTHER="IMAGE_OTHER"})(xt||(xt={}));var wt;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(wt||(wt={}));var Nt;(function(t){t.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",t.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",t.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",t.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",t.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Nt||(Nt={}));var Mt;(function(t){t.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",t.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",t.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",t.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",t.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Mt||(Mt={}));var Pt;(function(t){t.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"})(Pt||(Pt={}));var Rt;(function(t){t.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",t.ON_DEMAND="ON_DEMAND",t.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Rt||(Rt={}));var _e;(function(t){t.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",t.TEXT="TEXT",t.IMAGE="IMAGE",t.AUDIO="AUDIO"})(_e||(_e={}));var kt;(function(t){t.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",t.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",t.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",t.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(kt||(kt={}));var Dt;(function(t){t.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",t.TUNING_MODE_FULL="TUNING_MODE_FULL",t.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Dt||(Dt={}));var bt;(function(t){t.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",t.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",t.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",t.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",t.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",t.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",t.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(bt||(bt={}));var He;(function(t){t.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",t.JOB_STATE_QUEUED="JOB_STATE_QUEUED",t.JOB_STATE_PENDING="JOB_STATE_PENDING",t.JOB_STATE_RUNNING="JOB_STATE_RUNNING",t.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",t.JOB_STATE_FAILED="JOB_STATE_FAILED",t.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",t.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",t.JOB_STATE_PAUSED="JOB_STATE_PAUSED",t.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",t.JOB_STATE_UPDATING="JOB_STATE_UPDATING",t.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(He||(He={}));var Ut;(function(t){t.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",t.TUNING_TASK_I2V="TUNING_TASK_I2V",t.TUNING_TASK_T2V="TUNING_TASK_T2V",t.TUNING_TASK_R2V="TUNING_TASK_R2V"})(Ut||(Ut={}));var Lt;(function(t){t.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",t.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",t.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",t.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",t.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(Lt||(Lt={}));var Ft;(function(t){t.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",t.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",t.BALANCED="BALANCED",t.PRIORITIZE_COST="PRIORITIZE_COST"})(Ft||(Ft={}));var Gt;(function(t){t.UNSPECIFIED="UNSPECIFIED",t.BLOCKING="BLOCKING",t.NON_BLOCKING="NON_BLOCKING"})(Gt||(Gt={}));var Vt;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(Vt||(Vt={}));var qt;(function(t){t.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",t.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(qt||(qt={}));var Ht;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE",t.VALIDATED="VALIDATED"})(Ht||(Ht={}));var Bt;(function(t){t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(Bt||(Bt={}));var Jt;(function(t){t.DONT_ALLOW="DONT_ALLOW",t.ALLOW_ADULT="ALLOW_ADULT",t.ALLOW_ALL="ALLOW_ALL"})(Jt||(Jt={}));var $t;(function(t){t.auto="auto",t.en="en",t.ja="ja",t.ko="ko",t.hi="hi",t.zh="zh",t.pt="pt",t.es="es"})($t||($t={}));var Wt;(function(t){t.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",t.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",t.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",t.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",t.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Wt||(Wt={}));var Yt;(function(t){t.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",t.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",t.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",t.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Yt||(Yt={}));var Kt;(function(t){t.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",t.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",t.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",t.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Kt||(Kt={}));var zt;(function(t){t.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",t.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",t.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",t.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",t.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",t.EDIT_MODE_STYLE="EDIT_MODE_STYLE",t.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",t.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(zt||(zt={}));var Ot;(function(t){t.FOREGROUND="FOREGROUND",t.BACKGROUND="BACKGROUND",t.PROMPT="PROMPT",t.SEMANTIC="SEMANTIC",t.INTERACTIVE="INTERACTIVE"})(Ot||(Ot={}));var Xt;(function(t){t.ASSET="ASSET",t.STYLE="STYLE"})(Xt||(Xt={}));var Qt;(function(t){t.INSERT="INSERT",t.REMOVE="REMOVE",t.REMOVE_STATIC="REMOVE_STATIC",t.OUTPAINT="OUTPAINT"})(Qt||(Qt={}));var Zt;(function(t){t.OPTIMIZED="OPTIMIZED",t.LOSSLESS="LOSSLESS"})(Zt||(Zt={}));var jt;(function(t){t.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",t.PREFERENCE_TUNING="PREFERENCE_TUNING"})(jt||(jt={}));var en;(function(t){t.STATE_UNSPECIFIED="STATE_UNSPECIFIED",t.STATE_PENDING="STATE_PENDING",t.STATE_ACTIVE="STATE_ACTIVE",t.STATE_FAILED="STATE_FAILED"})(en||(en={}));var tn;(function(t){t.STATE_UNSPECIFIED="STATE_UNSPECIFIED",t.PROCESSING="PROCESSING",t.ACTIVE="ACTIVE",t.FAILED="FAILED"})(tn||(tn={}));var nn;(function(t){t.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",t.UPLOADED="UPLOADED",t.GENERATED="GENERATED"})(nn||(nn={}));var on;(function(t){t.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.RESPONSE_REJECTED="RESPONSE_REJECTED",t.NEED_MORE_INPUT="NEED_MORE_INPUT"})(on||(on={}));var sn;(function(t){t.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",t.TEXT="TEXT",t.IMAGE="IMAGE",t.VIDEO="VIDEO",t.AUDIO="AUDIO",t.DOCUMENT="DOCUMENT"})(sn||(sn={}));var rn;(function(t){t.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",t.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",t.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(rn||(rn={}));var ln;(function(t){t.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",t.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",t.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(ln||(ln={}));var an;(function(t){t.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",t.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",t.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(an||(an={}));var un;(function(t){t.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",t.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",t.NO_INTERRUPTION="NO_INTERRUPTION"})(un||(un={}));var dn;(function(t){t.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",t.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",t.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(dn||(dn={}));var cn;(function(t){t.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",t.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",t.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",t.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",t.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",t.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",t.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",t.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",t.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",t.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",t.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",t.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",t.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(cn||(cn={}));var fn;(function(t){t.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",t.QUALITY="QUALITY",t.DIVERSITY="DIVERSITY",t.VOCALIZATION="VOCALIZATION"})(fn||(fn={}));var le;(function(t){t.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",t.PLAY="PLAY",t.PAUSE="PAUSE",t.STOP="STOP",t.RESET_CONTEXT="RESET_CONTEXT"})(le||(le={}));class Be{constructor(e){const n={};for(const o of e.headers.entries())n[o[0]]=o[1];this.headers=n,this.responseInternal=e}json(){return this.responseInternal.json()}}class me{get text(){var e,n,o,s,l,a,u,c;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let d="",f=!1;const p=[];for(const h of(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)!==null&&c!==void 0?c:[]){for(const[g,y]of Object.entries(h))g!=="text"&&g!=="thought"&&g!=="thoughtSignature"&&(y!==null||y!==void 0)&&p.push(g);if(typeof h.text=="string"){if(typeof h.thought=="boolean"&&h.thought)continue;f=!0,d+=h.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),f?d:void 0}get data(){var e,n,o,s,l,a,u,c;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let d="";const f=[];for(const p of(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)!==null&&c!==void 0?c:[]){for(const[h,g]of Object.entries(p))h!=="inlineData"&&(g!==null||g!==void 0)&&f.push(h);p.inlineData&&typeof p.inlineData.data=="string"&&(d+=atob(p.inlineData.data))}return f.length>0&&console.warn(`there are non-data parts ${f} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}get functionCalls(){var e,n,o,s,l,a,u,c;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const d=(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)===null||c===void 0?void 0:c.filter(f=>f.functionCall).map(f=>f.functionCall).filter(f=>f!==void 0);if((d==null?void 0:d.length)!==0)return d}get executableCode(){var e,n,o,s,l,a,u,c,d;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const f=(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)===null||c===void 0?void 0:c.filter(p=>p.executableCode).map(p=>p.executableCode).filter(p=>p!==void 0);if((f==null?void 0:f.length)!==0)return(d=f==null?void 0:f[0])===null||d===void 0?void 0:d.code}get codeExecutionResult(){var e,n,o,s,l,a,u,c,d;if(((s=(o=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||o===void 0?void 0:o.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const f=(c=(u=(a=(l=this.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content)===null||u===void 0?void 0:u.parts)===null||c===void 0?void 0:c.filter(p=>p.codeExecutionResult).map(p=>p.codeExecutionResult).filter(p=>p!==void 0);if((f==null?void 0:f.length)!==0)return(d=f==null?void 0:f[0])===null||d===void 0?void 0:d.output}}class pn{}class hn{}class mi{}class gi{}class yi{}class Ti{}class mn{}class gn{}class yn{}class _i{}class Ee{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const o=new Ee;let s;const l=e;return n?s=oi(l):s=ni(l),Object.assign(o,s),o}}class Tn{}class _n{}class En{}class Cn{}class Ei{}class Ci{}class vi{}class Je{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const o=new Je,l=di(e);return Object.assign(o,l),o}}class Si{}class Ii{}class Ai{}class vn{}class xi{get text(){var e,n,o;let s="",l=!1;const a=[];for(const u of(o=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&o!==void 0?o:[]){for(const[c,d]of Object.entries(u))c!=="text"&&c!=="thought"&&d!==null&&a.push(c);if(typeof u.text=="string"){if(typeof u.thought=="boolean"&&u.thought)continue;l=!0,s+=u.text}}return a.length>0&&console.warn(`there are non-text parts ${a} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),l?s:void 0}get data(){var e,n,o;let s="";const l=[];for(const a of(o=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&o!==void 0?o:[]){for(const[u,c]of Object.entries(a))u!=="inlineData"&&c!==null&&l.push(u);a.inlineData&&typeof a.inlineData.data=="string"&&(s+=atob(a.inlineData.data))}return l.length>0&&console.warn(`there are non-data parts ${l} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),s.length>0?btoa(s):void 0}}class wi{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class $e{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const o=new $e,l=pt(e);return Object.assign(o,l),o}}/**
22
22
  * @license
23
23
  * Copyright 2025 Google LLC
24
24
  * SPDX-License-Identifier: Apache-2.0
25
- */function L(t,e){if(!e||typeof e!="string")throw new Error("model is required and must be a string");if(e.includes("..")||e.includes("?")||e.includes("&"))throw new Error("invalid model parameter");if(t.isVertexAI()){if(e.startsWith("publishers/")||e.startsWith("projects/")||e.startsWith("models/"))return e;if(e.indexOf("/")>=0){const n=e.split("/",2);return`publishers/${n[0]}/models/${n[1]}`}else return`publishers/google/models/${e}`}else return e.startsWith("models/")||e.startsWith("tunedModels/")?e:`models/${e}`}function Sn(t,e){const n=L(t,e);return n?n.startsWith("publishers/")&&t.isVertexAI()?`projects/${t.getProject()}/locations/${t.getLocation()}/${n}`:n.startsWith("models/")&&t.isVertexAI()?`projects/${t.getProject()}/locations/${t.getLocation()}/publishers/google/${n}`:n:""}function In(t){return Array.isArray(t)?t.map(e=>Ce(e)):[Ce(t)]}function Ce(t){if(typeof t=="object"&&t!==null)return t;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof t}`)}function An(t){const e=Ce(t);if(e.mimeType&&e.mimeType.startsWith("image/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function xn(t){const e=Ce(t);if(e.mimeType&&e.mimeType.startsWith("audio/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function wn(t){if(t==null)throw new Error("PartUnion is required");if(typeof t=="object")return t;if(typeof t=="string")return{text:t};throw new Error(`Unsupported part type: ${typeof t}`)}function Nn(t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("PartListUnion is required");return Array.isArray(t)?t.map(e=>wn(e)):[wn(t)]}function We(t){return t!=null&&typeof t=="object"&&"parts"in t&&Array.isArray(t.parts)}function Mn(t){return t!=null&&typeof t=="object"&&"functionCall"in t}function Pn(t){return t!=null&&typeof t=="object"&&"functionResponse"in t}function B(t){if(t==null)throw new Error("ContentUnion is required");return We(t)?t:{role:"user",parts:Nn(t)}}function Ye(t,e){if(!e)return[];if(t.isVertexAI()&&Array.isArray(e))return e.flatMap(n=>{const o=B(n);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]});if(t.isVertexAI()){const n=B(e);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]}return Array.isArray(e)?e.map(n=>B(n)):[B(e)]}function W(t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("contents are required");if(!Array.isArray(t)){if(Mn(t)||Pn(t))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[B(t)]}const e=[],n=[],o=We(t[0]);for(const s of t){const l=We(s);if(l!=o)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(l)e.push(s);else{if(Mn(s)||Pn(s))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");n.push(s)}}return o||e.push({role:"user",parts:Nn(n)}),e}function Ni(t,e){t.includes("null")&&(e.nullable=!0);const n=t.filter(o=>o!=="null");if(n.length===1)e.type=Object.values(te).includes(n[0].toUpperCase())?n[0].toUpperCase():te.TYPE_UNSPECIFIED;else{e.anyOf=[];for(const o of n)e.anyOf.push({type:Object.values(te).includes(o.toUpperCase())?o.toUpperCase():te.TYPE_UNSPECIFIED})}}function ae(t){const e={},n=["items"],o=["anyOf"],s=["properties"];if(t.type&&t.anyOf)throw new Error("type and anyOf cannot be both populated.");const l=t.anyOf;l!=null&&l.length==2&&(l[0].type==="null"?(e.nullable=!0,t=l[1]):l[1].type==="null"&&(e.nullable=!0,t=l[0])),t.type instanceof Array&&Ni(t.type,e);for(const[a,u]of Object.entries(t))if(u!=null)if(a=="type"){if(u==="null")throw new Error("type: null can not be the only possible type for the field.");if(u instanceof Array)continue;e.type=Object.values(te).includes(u.toUpperCase())?u.toUpperCase():te.TYPE_UNSPECIFIED}else if(n.includes(a))e[a]=ae(u);else if(o.includes(a)){const c=[];for(const d of u){if(d.type=="null"){e.nullable=!0;continue}c.push(ae(d))}e[a]=c}else if(s.includes(a)){const c={};for(const[d,f]of Object.entries(u))c[d]=ae(f);e[a]=c}else{if(a==="additionalProperties")continue;e[a]=u}return e}function Ke(t){return ae(t)}function ze(t){if(typeof t=="object")return t;if(typeof t=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:t}}};throw new Error(`Unsupported speechConfig type: ${typeof t}`)}function Oe(t){if("multiSpeakerVoiceConfig"in t)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return t}function ue(t){if(t.functionDeclarations)for(const e of t.functionDeclarations)e.parameters&&(Object.keys(e.parameters).includes("$schema")?e.parametersJsonSchema||(e.parametersJsonSchema=e.parameters,delete e.parameters):e.parameters=ae(e.parameters)),e.response&&(Object.keys(e.response).includes("$schema")?e.responseJsonSchema||(e.responseJsonSchema=e.response,delete e.response):e.response=ae(e.response));return t}function de(t){if(t==null)throw new Error("tools is required");if(!Array.isArray(t))throw new Error("tools is required and must be an array of Tools");const e=[];for(const n of t)e.push(n);return e}function Mi(t,e,n,o=1){const s=!e.startsWith(`${n}/`)&&e.split("/").length===o;return t.isVertexAI()?e.startsWith("projects/")?e:e.startsWith("locations/")?`projects/${t.getProject()}/${e}`:e.startsWith(`${n}/`)?`projects/${t.getProject()}/locations/${t.getLocation()}/${e}`:s?`projects/${t.getProject()}/locations/${t.getLocation()}/${n}/${e}`:e:s?`${n}/${e}`:e}function Z(t,e){if(typeof e!="string")throw new Error("name must be a string");return Mi(t,e,"cachedContents")}function Rn(t){switch(t){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return t}}function ne(t){return qe(t)}function Pi(t){return t!=null&&typeof t=="object"&&"name"in t}function Ri(t){return t!=null&&typeof t=="object"&&"video"in t}function ki(t){return t!=null&&typeof t=="object"&&"uri"in t}function kn(t){var e;let n;if(Pi(t)&&(n=t.name),!(ki(t)&&(n=t.uri,n===void 0))&&!(Ri(t)&&(n=(e=t.video)===null||e===void 0?void 0:e.uri,n===void 0))){if(typeof t=="string"&&(n=t),n===void 0)throw new Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){const s=n.split("files/")[1].match(/[a-z0-9]+/);if(s===null)throw new Error(`Could not extract file name from URI ${n}`);n=s[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}function Dn(t,e){let n;return t.isVertexAI()?n=e?"publishers/google/models":"models":n=e?"models":"tunedModels",n}function bn(t){for(const e of["models","tunedModels","publisherModels"])if(Di(t,e))return t[e];return[]}function Di(t,e){return t!==null&&typeof t=="object"&&e in t}function bi(t,e={}){const n=t,o={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(o.responseJsonSchema=n.outputSchema),e.behavior&&(o.behavior=e.behavior),{functionDeclarations:[o]}}function Ui(t,e={}){const n=[],o=new Set;for(const s of t){const l=s.name;if(o.has(l))throw new Error(`Duplicate function name ${l} found in MCP tools. Please ensure function names are unique.`);o.add(l);const a=bi(s,e);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function Un(t,e){let n;if(typeof e=="string")if(t.isVertexAI())if(e.startsWith("gs://"))n={format:"jsonl",gcsUri:[e]};else if(e.startsWith("bq://"))n={format:"bigquery",bigqueryUri:e};else throw new Error(`Unsupported string source for Vertex AI: ${e}`);else if(e.startsWith("files/"))n={fileName:e};else throw new Error(`Unsupported string source for Gemini API: ${e}`);else if(Array.isArray(e)){if(t.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:e}}else n=e;const o=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,s=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(t.isVertexAI()){if(s>0||o!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(o>0||s!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function Li(t){if(typeof t!="string")return t;const e=t;if(e.startsWith("gs://"))return{format:"jsonl",gcsUri:e};if(e.startsWith("bq://"))return{format:"bigquery",bigqueryUri:e};throw new Error(`Unsupported destination: ${e}`)}function Ln(t){if(typeof t!="object"||t===null)return{};const e=t,n=e.inlinedResponses;if(typeof n!="object"||n===null)return t;const s=n.inlinedResponses;if(!Array.isArray(s)||s.length===0)return t;let l=!1;for(const a of s){if(typeof a!="object"||a===null)continue;const c=a.response;if(typeof c!="object"||c===null)continue;if(c.embedding!==void 0){l=!0;break}}return l&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),t}function ce(t,e){const n=e;if(!t.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split("/").pop();throw new Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split("/").pop();if(/^\d+$/.test(n))return n;throw new Error(`Invalid batch job name: ${n}.`)}function Fn(t){const e=t;return e==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":e==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":e==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":e==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":e==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":e==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":e==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":e}/**
25
+ */function L(t,e){if(!e||typeof e!="string")throw new Error("model is required and must be a string");if(e.includes("..")||e.includes("?")||e.includes("&"))throw new Error("invalid model parameter");if(t.isVertexAI()){if(e.startsWith("publishers/")||e.startsWith("projects/")||e.startsWith("models/"))return e;if(e.indexOf("/")>=0){const n=e.split("/",2);return`publishers/${n[0]}/models/${n[1]}`}else return`publishers/google/models/${e}`}else return e.startsWith("models/")||e.startsWith("tunedModels/")?e:`models/${e}`}function Sn(t,e){const n=L(t,e);return n?n.startsWith("publishers/")&&t.isVertexAI()?`projects/${t.getProject()}/locations/${t.getLocation()}/${n}`:n.startsWith("models/")&&t.isVertexAI()?`projects/${t.getProject()}/locations/${t.getLocation()}/publishers/google/${n}`:n:""}function In(t){return Array.isArray(t)?t.map(e=>Ce(e)):[Ce(t)]}function Ce(t){if(typeof t=="object"&&t!==null)return t;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof t}`)}function An(t){const e=Ce(t);if(e.mimeType&&e.mimeType.startsWith("image/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function xn(t){const e=Ce(t);if(e.mimeType&&e.mimeType.startsWith("audio/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function wn(t){if(t==null)throw new Error("PartUnion is required");if(typeof t=="object")return t;if(typeof t=="string")return{text:t};throw new Error(`Unsupported part type: ${typeof t}`)}function Nn(t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("PartListUnion is required");return Array.isArray(t)?t.map(e=>wn(e)):[wn(t)]}function We(t){return t!=null&&typeof t=="object"&&"parts"in t&&Array.isArray(t.parts)}function Mn(t){return t!=null&&typeof t=="object"&&"functionCall"in t}function Pn(t){return t!=null&&typeof t=="object"&&"functionResponse"in t}function B(t){if(t==null)throw new Error("ContentUnion is required");return We(t)?t:{role:"user",parts:Nn(t)}}function Ye(t,e){if(!e)return[];if(t.isVertexAI()&&Array.isArray(e))return e.flatMap(n=>{const o=B(n);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]});if(t.isVertexAI()){const n=B(e);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]}return Array.isArray(e)?e.map(n=>B(n)):[B(e)]}function Y(t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("contents are required");if(!Array.isArray(t)){if(Mn(t)||Pn(t))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[B(t)]}const e=[],n=[],o=We(t[0]);for(const s of t){const l=We(s);if(l!=o)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(l)e.push(s);else{if(Mn(s)||Pn(s))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");n.push(s)}}return o||e.push({role:"user",parts:Nn(n)}),e}function Ni(t,e){t.includes("null")&&(e.nullable=!0);const n=t.filter(o=>o!=="null");if(n.length===1)e.type=Object.values(ne).includes(n[0].toUpperCase())?n[0].toUpperCase():ne.TYPE_UNSPECIFIED;else{e.anyOf=[];for(const o of n)e.anyOf.push({type:Object.values(ne).includes(o.toUpperCase())?o.toUpperCase():ne.TYPE_UNSPECIFIED})}}function ae(t){const e={},n=["items"],o=["anyOf"],s=["properties"];if(t.type&&t.anyOf)throw new Error("type and anyOf cannot be both populated.");const l=t.anyOf;l!=null&&l.length==2&&(l[0].type==="null"?(e.nullable=!0,t=l[1]):l[1].type==="null"&&(e.nullable=!0,t=l[0])),t.type instanceof Array&&Ni(t.type,e);for(const[a,u]of Object.entries(t))if(u!=null)if(a=="type"){if(u==="null")throw new Error("type: null can not be the only possible type for the field.");if(u instanceof Array)continue;e.type=Object.values(ne).includes(u.toUpperCase())?u.toUpperCase():ne.TYPE_UNSPECIFIED}else if(n.includes(a))e[a]=ae(u);else if(o.includes(a)){const c=[];for(const d of u){if(d.type=="null"){e.nullable=!0;continue}c.push(ae(d))}e[a]=c}else if(s.includes(a)){const c={};for(const[d,f]of Object.entries(u))c[d]=ae(f);e[a]=c}else{if(a==="additionalProperties")continue;e[a]=u}return e}function Ke(t){return ae(t)}function ze(t){if(typeof t=="object")return t;if(typeof t=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:t}}};throw new Error(`Unsupported speechConfig type: ${typeof t}`)}function Oe(t){if("multiSpeakerVoiceConfig"in t)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return t}function ue(t){if(t.functionDeclarations)for(const e of t.functionDeclarations)e.parameters&&(Object.keys(e.parameters).includes("$schema")?e.parametersJsonSchema||(e.parametersJsonSchema=e.parameters,delete e.parameters):e.parameters=ae(e.parameters)),e.response&&(Object.keys(e.response).includes("$schema")?e.responseJsonSchema||(e.responseJsonSchema=e.response,delete e.response):e.response=ae(e.response));return t}function de(t){if(t==null)throw new Error("tools is required");if(!Array.isArray(t))throw new Error("tools is required and must be an array of Tools");const e=[];for(const n of t)e.push(n);return e}function Mi(t,e,n,o=1){const s=!e.startsWith(`${n}/`)&&e.split("/").length===o;return t.isVertexAI()?e.startsWith("projects/")?e:e.startsWith("locations/")?`projects/${t.getProject()}/${e}`:e.startsWith(`${n}/`)?`projects/${t.getProject()}/locations/${t.getLocation()}/${e}`:s?`projects/${t.getProject()}/locations/${t.getLocation()}/${n}/${e}`:e:s?`${n}/${e}`:e}function j(t,e){if(typeof e!="string")throw new Error("name must be a string");return Mi(t,e,"cachedContents")}function Rn(t){switch(t){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return t}}function oe(t){return qe(t)}function Pi(t){return t!=null&&typeof t=="object"&&"name"in t}function Ri(t){return t!=null&&typeof t=="object"&&"video"in t}function ki(t){return t!=null&&typeof t=="object"&&"uri"in t}function kn(t){var e;let n;if(Pi(t)&&(n=t.name),!(ki(t)&&(n=t.uri,n===void 0))&&!(Ri(t)&&(n=(e=t.video)===null||e===void 0?void 0:e.uri,n===void 0))){if(typeof t=="string"&&(n=t),n===void 0)throw new Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){const s=n.split("files/")[1].match(/[a-z0-9]+/);if(s===null)throw new Error(`Could not extract file name from URI ${n}`);n=s[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}function Dn(t,e){let n;return t.isVertexAI()?n=e?"publishers/google/models":"models":n=e?"models":"tunedModels",n}function bn(t){for(const e of["models","tunedModels","publisherModels"])if(Di(t,e))return t[e];return[]}function Di(t,e){return t!==null&&typeof t=="object"&&e in t}function bi(t,e={}){const n=t,o={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(o.responseJsonSchema=n.outputSchema),e.behavior&&(o.behavior=e.behavior),{functionDeclarations:[o]}}function Ui(t,e={}){const n=[],o=new Set;for(const s of t){const l=s.name;if(o.has(l))throw new Error(`Duplicate function name ${l} found in MCP tools. Please ensure function names are unique.`);o.add(l);const a=bi(s,e);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function Un(t,e){let n;if(typeof e=="string")if(t.isVertexAI())if(e.startsWith("gs://"))n={format:"jsonl",gcsUri:[e]};else if(e.startsWith("bq://"))n={format:"bigquery",bigqueryUri:e};else throw new Error(`Unsupported string source for Vertex AI: ${e}`);else if(e.startsWith("files/"))n={fileName:e};else throw new Error(`Unsupported string source for Gemini API: ${e}`);else if(Array.isArray(e)){if(t.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:e}}else n=e;const o=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,s=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(t.isVertexAI()){if(s>0||o!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(o>0||s!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function Li(t){if(typeof t!="string")return t;const e=t;if(e.startsWith("gs://"))return{format:"jsonl",gcsUri:e};if(e.startsWith("bq://"))return{format:"bigquery",bigqueryUri:e};throw new Error(`Unsupported destination: ${e}`)}function Ln(t){if(typeof t!="object"||t===null)return{};const e=t,n=e.inlinedResponses;if(typeof n!="object"||n===null)return t;const s=n.inlinedResponses;if(!Array.isArray(s)||s.length===0)return t;let l=!1;for(const a of s){if(typeof a!="object"||a===null)continue;const c=a.response;if(typeof c!="object"||c===null)continue;if(c.embedding!==void 0){l=!0;break}}return l&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),t}function ce(t,e){const n=e;if(!t.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split("/").pop();throw new Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split("/").pop();if(/^\d+$/.test(n))return n;throw new Error(`Invalid batch job name: ${n}.`)}function Fn(t){const e=t;return e==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":e==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":e==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":e==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":e==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":e==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":e==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":e}/**
26
26
  * @license
27
27
  * Copyright 2025 Google LLC
28
28
  * SPDX-License-Identifier: Apache-2.0
29
- */function Fi(t){const e={},n=i(t,["responsesFile"]);n!=null&&r(e,["fileName"],n);const o=i(t,["inlinedResponses","inlinedResponses"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>ys(a))),r(e,["inlinedResponses"],l)}const s=i(t,["inlinedEmbedContentResponses","inlinedResponses"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["inlinedEmbedContentResponses"],l)}return e}function Gi(t){const e={},n=i(t,["predictionsFormat"]);n!=null&&r(e,["format"],n);const o=i(t,["gcsDestination","outputUriPrefix"]);o!=null&&r(e,["gcsUri"],o);const s=i(t,["bigqueryDestination","outputUri"]);return s!=null&&r(e,["bigqueryUri"],s),e}function Vi(t){const e={},n=i(t,["format"]);n!=null&&r(e,["predictionsFormat"],n);const o=i(t,["gcsUri"]);o!=null&&r(e,["gcsDestination","outputUriPrefix"],o);const s=i(t,["bigqueryUri"]);if(s!=null&&r(e,["bigqueryDestination","outputUri"],s),i(t,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(i(t,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(i(t,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return e}function ve(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["metadata","displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["metadata","state"]);s!=null&&r(e,["state"],Fn(s));const l=i(t,["metadata","createTime"]);l!=null&&r(e,["createTime"],l);const a=i(t,["metadata","endTime"]);a!=null&&r(e,["endTime"],a);const u=i(t,["metadata","updateTime"]);u!=null&&r(e,["updateTime"],u);const c=i(t,["metadata","model"]);c!=null&&r(e,["model"],c);const d=i(t,["metadata","output"]);return d!=null&&r(e,["dest"],Fi(Ln(d))),e}function Xe(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["state"]);s!=null&&r(e,["state"],Fn(s));const l=i(t,["error"]);l!=null&&r(e,["error"],l);const a=i(t,["createTime"]);a!=null&&r(e,["createTime"],a);const u=i(t,["startTime"]);u!=null&&r(e,["startTime"],u);const c=i(t,["endTime"]);c!=null&&r(e,["endTime"],c);const d=i(t,["updateTime"]);d!=null&&r(e,["updateTime"],d);const f=i(t,["model"]);f!=null&&r(e,["model"],f);const p=i(t,["inputConfig"]);p!=null&&r(e,["src"],qi(p));const h=i(t,["outputConfig"]);h!=null&&r(e,["dest"],Gi(Ln(h)));const g=i(t,["completionStats"]);return g!=null&&r(e,["completionStats"],g),e}function qi(t){const e={},n=i(t,["instancesFormat"]);n!=null&&r(e,["format"],n);const o=i(t,["gcsSource","uris"]);o!=null&&r(e,["gcsUri"],o);const s=i(t,["bigquerySource","inputUri"]);return s!=null&&r(e,["bigqueryUri"],s),e}function Hi(t,e){const n={};if(i(e,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(i(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(i(e,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const o=i(e,["fileName"]);o!=null&&r(n,["fileName"],o);const s=i(e,["inlinedRequests"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>gs(t,a))),r(n,["requests","requests"],l)}return n}function Bi(t){const e={},n=i(t,["format"]);n!=null&&r(e,["instancesFormat"],n);const o=i(t,["gcsUri"]);o!=null&&r(e,["gcsSource","uris"],o);const s=i(t,["bigqueryUri"]);if(s!=null&&r(e,["bigquerySource","inputUri"],s),i(t,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(i(t,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return e}function Ji(t){const e={},n=i(t,["data"]);if(n!=null&&r(e,["data"],n),i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function $i(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function Wi(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function Yi(t){const e={},n=i(t,["content"]);n!=null&&r(e,["content"],n);const o=i(t,["citationMetadata"]);o!=null&&r(e,["citationMetadata"],Ki(o));const s=i(t,["tokenCount"]);s!=null&&r(e,["tokenCount"],s);const l=i(t,["finishReason"]);l!=null&&r(e,["finishReason"],l);const a=i(t,["avgLogprobs"]);a!=null&&r(e,["avgLogprobs"],a);const u=i(t,["groundingMetadata"]);u!=null&&r(e,["groundingMetadata"],u);const c=i(t,["index"]);c!=null&&r(e,["index"],c);const d=i(t,["logprobsResult"]);d!=null&&r(e,["logprobsResult"],d);const f=i(t,["safetyRatings"]);if(f!=null){let h=f;Array.isArray(h)&&(h=h.map(g=>g)),r(e,["safetyRatings"],h)}const p=i(t,["urlContextMetadata"]);return p!=null&&r(e,["urlContextMetadata"],p),e}function Ki(t){const e={},n=i(t,["citationSources"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>s)),r(e,["citations"],o)}return e}function Gn(t){const e={},n=i(t,["parts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(l=>Is(l))),r(e,["parts"],s)}const o=i(t,["role"]);return o!=null&&r(e,["role"],o),e}function zi(t,e){const n={},o=i(t,["displayName"]);if(e!==void 0&&o!=null&&r(e,["batch","displayName"],o),i(t,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return n}function Oi(t,e){const n={},o=i(t,["displayName"]);e!==void 0&&o!=null&&r(e,["displayName"],o);const s=i(t,["dest"]);return e!==void 0&&s!=null&&r(e,["outputConfig"],Vi(Li(s))),n}function Vn(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["src"]);s!=null&&r(n,["batch","inputConfig"],Hi(t,Un(t,s)));const l=i(e,["config"]);return l!=null&&zi(l,n),n}function Xi(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["model"],L(t,o));const s=i(e,["src"]);s!=null&&r(n,["inputConfig"],Bi(Un(t,s)));const l=i(e,["config"]);return l!=null&&Oi(l,n),n}function Qi(t,e){const n={},o=i(t,["displayName"]);return e!==void 0&&o!=null&&r(e,["batch","displayName"],o),n}function Zi(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["src"]);s!=null&&r(n,["batch","inputConfig"],ss(t,s));const l=i(e,["config"]);return l!=null&&Qi(l,n),n}function ji(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function es(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function ts(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);return l!=null&&r(e,["error"],l),e}function ns(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);return l!=null&&r(e,["error"],l),e}function os(t,e){const n={},o=i(e,["contents"]);if(o!=null){let l=Ye(t,o);Array.isArray(l)&&(l=l.map(a=>a)),r(n,["requests[]","request","content"],l)}const s=i(e,["config"]);return s!=null&&(r(n,["_self"],is(s,n)),ei(n,{"requests[].*":"requests[].request.*"})),n}function is(t,e){const n={},o=i(t,["taskType"]);e!==void 0&&o!=null&&r(e,["requests[]","taskType"],o);const s=i(t,["title"]);e!==void 0&&s!=null&&r(e,["requests[]","title"],s);const l=i(t,["outputDimensionality"]);if(e!==void 0&&l!=null&&r(e,["requests[]","outputDimensionality"],l),i(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(i(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function ss(t,e){const n={},o=i(e,["fileName"]);o!=null&&r(n,["file_name"],o);const s=i(e,["inlinedRequests"]);return s!=null&&r(n,["requests"],os(t,s)),n}function rs(t){const e={};if(i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=i(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function ls(t){const e={},n=i(t,["id"]);n!=null&&r(e,["id"],n);const o=i(t,["args"]);o!=null&&r(e,["args"],o);const s=i(t,["name"]);if(s!=null&&r(e,["name"],s),i(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(i(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function as(t){const e={},n=i(t,["mode"]);n!=null&&r(e,["mode"],n);const o=i(t,["allowedFunctionNames"]);if(o!=null&&r(e,["allowedFunctionNames"],o),i(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function us(t,e,n){const o={},s=i(e,["systemInstruction"]);n!==void 0&&s!=null&&r(n,["systemInstruction"],Gn(B(s)));const l=i(e,["temperature"]);l!=null&&r(o,["temperature"],l);const a=i(e,["topP"]);a!=null&&r(o,["topP"],a);const u=i(e,["topK"]);u!=null&&r(o,["topK"],u);const c=i(e,["candidateCount"]);c!=null&&r(o,["candidateCount"],c);const d=i(e,["maxOutputTokens"]);d!=null&&r(o,["maxOutputTokens"],d);const f=i(e,["stopSequences"]);f!=null&&r(o,["stopSequences"],f);const p=i(e,["responseLogprobs"]);p!=null&&r(o,["responseLogprobs"],p);const h=i(e,["logprobs"]);h!=null&&r(o,["logprobs"],h);const g=i(e,["presencePenalty"]);g!=null&&r(o,["presencePenalty"],g);const y=i(e,["frequencyPenalty"]);y!=null&&r(o,["frequencyPenalty"],y);const C=i(e,["seed"]);C!=null&&r(o,["seed"],C);const T=i(e,["responseMimeType"]);T!=null&&r(o,["responseMimeType"],T);const E=i(e,["responseSchema"]);E!=null&&r(o,["responseSchema"],Ke(E));const _=i(e,["responseJsonSchema"]);if(_!=null&&r(o,["responseJsonSchema"],_),i(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(i(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const v=i(e,["safetySettings"]);if(n!==void 0&&v!=null){let U=v;Array.isArray(U)&&(U=U.map(V=>As(V))),r(n,["safetySettings"],U)}const S=i(e,["tools"]);if(n!==void 0&&S!=null){let U=de(S);Array.isArray(U)&&(U=U.map(V=>ws(ue(V)))),r(n,["tools"],U)}const x=i(e,["toolConfig"]);if(n!==void 0&&x!=null&&r(n,["toolConfig"],xs(x)),i(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const P=i(e,["cachedContent"]);n!==void 0&&P!=null&&r(n,["cachedContent"],Z(t,P));const M=i(e,["responseModalities"]);M!=null&&r(o,["responseModalities"],M);const b=i(e,["mediaResolution"]);b!=null&&r(o,["mediaResolution"],b);const A=i(e,["speechConfig"]);if(A!=null&&r(o,["speechConfig"],ze(A)),i(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const R=i(e,["thinkingConfig"]);R!=null&&r(o,["thinkingConfig"],R);const F=i(e,["imageConfig"]);F!=null&&r(o,["imageConfig"],ms(F));const D=i(e,["enableEnhancedCivicAnswers"]);return D!=null&&r(o,["enableEnhancedCivicAnswers"],D),o}function ds(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["candidates"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(d=>Yi(d))),r(e,["candidates"],c)}const s=i(t,["modelVersion"]);s!=null&&r(e,["modelVersion"],s);const l=i(t,["promptFeedback"]);l!=null&&r(e,["promptFeedback"],l);const a=i(t,["responseId"]);a!=null&&r(e,["responseId"],a);const u=i(t,["usageMetadata"]);return u!=null&&r(e,["usageMetadata"],u),e}function cs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function fs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function ps(t){const e={};if(i(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=i(t,["enableWidget"]);return n!=null&&r(e,["enableWidget"],n),e}function hs(t){const e={};if(i(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(i(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=i(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],n),e}function ms(t){const e={},n=i(t,["aspectRatio"]);n!=null&&r(e,["aspectRatio"],n);const o=i(t,["imageSize"]);if(o!=null&&r(e,["imageSize"],o),i(t,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(i(t,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return e}function gs(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["request","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let u=W(s);Array.isArray(u)&&(u=u.map(c=>Gn(c))),r(n,["request","contents"],u)}const l=i(e,["metadata"]);l!=null&&r(n,["metadata"],l);const a=i(e,["config"]);return a!=null&&r(n,["request","generationConfig"],us(t,a,i(n,["request"],{}))),n}function ys(t){const e={},n=i(t,["response"]);n!=null&&r(e,["response"],ds(n));const o=i(t,["error"]);return o!=null&&r(e,["error"],o),e}function Ts(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);if(e!==void 0&&s!=null&&r(e,["_query","pageToken"],s),i(t,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return n}function _s(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);e!==void 0&&s!=null&&r(e,["_query","pageToken"],s);const l=i(t,["filter"]);return e!==void 0&&l!=null&&r(e,["_query","filter"],l),n}function Es(t){const e={},n=i(t,["config"]);return n!=null&&Ts(n,e),e}function Cs(t){const e={},n=i(t,["config"]);return n!=null&&_s(n,e),e}function vs(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["operations"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>ve(a))),r(e,["batchJobs"],l)}return e}function Ss(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["batchPredictionJobs"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>Xe(a))),r(e,["batchJobs"],l)}return e}function Is(t){const e={},n=i(t,["mediaResolution"]);n!=null&&r(e,["mediaResolution"],n);const o=i(t,["codeExecutionResult"]);o!=null&&r(e,["codeExecutionResult"],o);const s=i(t,["executableCode"]);s!=null&&r(e,["executableCode"],s);const l=i(t,["fileData"]);l!=null&&r(e,["fileData"],rs(l));const a=i(t,["functionCall"]);a!=null&&r(e,["functionCall"],ls(a));const u=i(t,["functionResponse"]);u!=null&&r(e,["functionResponse"],u);const c=i(t,["inlineData"]);c!=null&&r(e,["inlineData"],Ji(c));const d=i(t,["text"]);d!=null&&r(e,["text"],d);const f=i(t,["thought"]);f!=null&&r(e,["thought"],f);const p=i(t,["thoughtSignature"]);p!=null&&r(e,["thoughtSignature"],p);const h=i(t,["videoMetadata"]);return h!=null&&r(e,["videoMetadata"],h),e}function As(t){const e={},n=i(t,["category"]);if(n!=null&&r(e,["category"],n),i(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=i(t,["threshold"]);return o!=null&&r(e,["threshold"],o),e}function xs(t){const e={},n=i(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],as(n));const o=i(t,["retrievalConfig"]);return o!=null&&r(e,["retrievalConfig"],o),e}function ws(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>p)),r(e,["functionDeclarations"],f)}if(i(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=i(t,["googleSearchRetrieval"]);o!=null&&r(e,["googleSearchRetrieval"],o);const s=i(t,["computerUse"]);s!=null&&r(e,["computerUse"],s);const l=i(t,["fileSearch"]);l!=null&&r(e,["fileSearch"],l);const a=i(t,["codeExecution"]);if(a!=null&&r(e,["codeExecution"],a),i(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=i(t,["googleMaps"]);u!=null&&r(e,["googleMaps"],ps(u));const c=i(t,["googleSearch"]);c!=null&&r(e,["googleSearch"],hs(c));const d=i(t,["urlContext"]);return d!=null&&r(e,["urlContext"],d),e}/**
29
+ */function Fi(t){const e={},n=i(t,["responsesFile"]);n!=null&&r(e,["fileName"],n);const o=i(t,["inlinedResponses","inlinedResponses"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>ys(a))),r(e,["inlinedResponses"],l)}const s=i(t,["inlinedEmbedContentResponses","inlinedResponses"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["inlinedEmbedContentResponses"],l)}return e}function Gi(t){const e={},n=i(t,["predictionsFormat"]);n!=null&&r(e,["format"],n);const o=i(t,["gcsDestination","outputUriPrefix"]);o!=null&&r(e,["gcsUri"],o);const s=i(t,["bigqueryDestination","outputUri"]);return s!=null&&r(e,["bigqueryUri"],s),e}function Vi(t){const e={},n=i(t,["format"]);n!=null&&r(e,["predictionsFormat"],n);const o=i(t,["gcsUri"]);o!=null&&r(e,["gcsDestination","outputUriPrefix"],o);const s=i(t,["bigqueryUri"]);if(s!=null&&r(e,["bigqueryDestination","outputUri"],s),i(t,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(i(t,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(i(t,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return e}function ve(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["metadata","displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["metadata","state"]);s!=null&&r(e,["state"],Fn(s));const l=i(t,["metadata","createTime"]);l!=null&&r(e,["createTime"],l);const a=i(t,["metadata","endTime"]);a!=null&&r(e,["endTime"],a);const u=i(t,["metadata","updateTime"]);u!=null&&r(e,["updateTime"],u);const c=i(t,["metadata","model"]);c!=null&&r(e,["model"],c);const d=i(t,["metadata","output"]);return d!=null&&r(e,["dest"],Fi(Ln(d))),e}function Xe(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["state"]);s!=null&&r(e,["state"],Fn(s));const l=i(t,["error"]);l!=null&&r(e,["error"],l);const a=i(t,["createTime"]);a!=null&&r(e,["createTime"],a);const u=i(t,["startTime"]);u!=null&&r(e,["startTime"],u);const c=i(t,["endTime"]);c!=null&&r(e,["endTime"],c);const d=i(t,["updateTime"]);d!=null&&r(e,["updateTime"],d);const f=i(t,["model"]);f!=null&&r(e,["model"],f);const p=i(t,["inputConfig"]);p!=null&&r(e,["src"],qi(p));const h=i(t,["outputConfig"]);h!=null&&r(e,["dest"],Gi(Ln(h)));const g=i(t,["completionStats"]);return g!=null&&r(e,["completionStats"],g),e}function qi(t){const e={},n=i(t,["instancesFormat"]);n!=null&&r(e,["format"],n);const o=i(t,["gcsSource","uris"]);o!=null&&r(e,["gcsUri"],o);const s=i(t,["bigquerySource","inputUri"]);return s!=null&&r(e,["bigqueryUri"],s),e}function Hi(t,e){const n={};if(i(e,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(i(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(i(e,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const o=i(e,["fileName"]);o!=null&&r(n,["fileName"],o);const s=i(e,["inlinedRequests"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>gs(t,a))),r(n,["requests","requests"],l)}return n}function Bi(t){const e={},n=i(t,["format"]);n!=null&&r(e,["instancesFormat"],n);const o=i(t,["gcsUri"]);o!=null&&r(e,["gcsSource","uris"],o);const s=i(t,["bigqueryUri"]);if(s!=null&&r(e,["bigquerySource","inputUri"],s),i(t,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(i(t,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return e}function Ji(t){const e={},n=i(t,["data"]);if(n!=null&&r(e,["data"],n),i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function $i(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function Wi(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function Yi(t){const e={},n=i(t,["content"]);n!=null&&r(e,["content"],n);const o=i(t,["citationMetadata"]);o!=null&&r(e,["citationMetadata"],Ki(o));const s=i(t,["tokenCount"]);s!=null&&r(e,["tokenCount"],s);const l=i(t,["finishReason"]);l!=null&&r(e,["finishReason"],l);const a=i(t,["avgLogprobs"]);a!=null&&r(e,["avgLogprobs"],a);const u=i(t,["groundingMetadata"]);u!=null&&r(e,["groundingMetadata"],u);const c=i(t,["index"]);c!=null&&r(e,["index"],c);const d=i(t,["logprobsResult"]);d!=null&&r(e,["logprobsResult"],d);const f=i(t,["safetyRatings"]);if(f!=null){let h=f;Array.isArray(h)&&(h=h.map(g=>g)),r(e,["safetyRatings"],h)}const p=i(t,["urlContextMetadata"]);return p!=null&&r(e,["urlContextMetadata"],p),e}function Ki(t){const e={},n=i(t,["citationSources"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>s)),r(e,["citations"],o)}return e}function Gn(t){const e={},n=i(t,["parts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(l=>Is(l))),r(e,["parts"],s)}const o=i(t,["role"]);return o!=null&&r(e,["role"],o),e}function zi(t,e){const n={},o=i(t,["displayName"]);if(e!==void 0&&o!=null&&r(e,["batch","displayName"],o),i(t,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return n}function Oi(t,e){const n={},o=i(t,["displayName"]);e!==void 0&&o!=null&&r(e,["displayName"],o);const s=i(t,["dest"]);return e!==void 0&&s!=null&&r(e,["outputConfig"],Vi(Li(s))),n}function Vn(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["src"]);s!=null&&r(n,["batch","inputConfig"],Hi(t,Un(t,s)));const l=i(e,["config"]);return l!=null&&zi(l,n),n}function Xi(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["model"],L(t,o));const s=i(e,["src"]);s!=null&&r(n,["inputConfig"],Bi(Un(t,s)));const l=i(e,["config"]);return l!=null&&Oi(l,n),n}function Qi(t,e){const n={},o=i(t,["displayName"]);return e!==void 0&&o!=null&&r(e,["batch","displayName"],o),n}function Zi(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["src"]);s!=null&&r(n,["batch","inputConfig"],ss(t,s));const l=i(e,["config"]);return l!=null&&Qi(l,n),n}function ji(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function es(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function ts(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);return l!=null&&r(e,["error"],l),e}function ns(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);return l!=null&&r(e,["error"],l),e}function os(t,e){const n={},o=i(e,["contents"]);if(o!=null){let l=Ye(t,o);Array.isArray(l)&&(l=l.map(a=>a)),r(n,["requests[]","request","content"],l)}const s=i(e,["config"]);return s!=null&&(r(n,["_self"],is(s,n)),ei(n,{"requests[].*":"requests[].request.*"})),n}function is(t,e){const n={},o=i(t,["taskType"]);e!==void 0&&o!=null&&r(e,["requests[]","taskType"],o);const s=i(t,["title"]);e!==void 0&&s!=null&&r(e,["requests[]","title"],s);const l=i(t,["outputDimensionality"]);if(e!==void 0&&l!=null&&r(e,["requests[]","outputDimensionality"],l),i(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(i(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function ss(t,e){const n={},o=i(e,["fileName"]);o!=null&&r(n,["file_name"],o);const s=i(e,["inlinedRequests"]);return s!=null&&r(n,["requests"],os(t,s)),n}function rs(t){const e={};if(i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=i(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function ls(t){const e={},n=i(t,["id"]);n!=null&&r(e,["id"],n);const o=i(t,["args"]);o!=null&&r(e,["args"],o);const s=i(t,["name"]);if(s!=null&&r(e,["name"],s),i(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(i(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function as(t){const e={},n=i(t,["mode"]);n!=null&&r(e,["mode"],n);const o=i(t,["allowedFunctionNames"]);if(o!=null&&r(e,["allowedFunctionNames"],o),i(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function us(t,e,n){const o={},s=i(e,["systemInstruction"]);n!==void 0&&s!=null&&r(n,["systemInstruction"],Gn(B(s)));const l=i(e,["temperature"]);l!=null&&r(o,["temperature"],l);const a=i(e,["topP"]);a!=null&&r(o,["topP"],a);const u=i(e,["topK"]);u!=null&&r(o,["topK"],u);const c=i(e,["candidateCount"]);c!=null&&r(o,["candidateCount"],c);const d=i(e,["maxOutputTokens"]);d!=null&&r(o,["maxOutputTokens"],d);const f=i(e,["stopSequences"]);f!=null&&r(o,["stopSequences"],f);const p=i(e,["responseLogprobs"]);p!=null&&r(o,["responseLogprobs"],p);const h=i(e,["logprobs"]);h!=null&&r(o,["logprobs"],h);const g=i(e,["presencePenalty"]);g!=null&&r(o,["presencePenalty"],g);const y=i(e,["frequencyPenalty"]);y!=null&&r(o,["frequencyPenalty"],y);const C=i(e,["seed"]);C!=null&&r(o,["seed"],C);const T=i(e,["responseMimeType"]);T!=null&&r(o,["responseMimeType"],T);const E=i(e,["responseSchema"]);E!=null&&r(o,["responseSchema"],Ke(E));const _=i(e,["responseJsonSchema"]);if(_!=null&&r(o,["responseJsonSchema"],_),i(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(i(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const v=i(e,["safetySettings"]);if(n!==void 0&&v!=null){let U=v;Array.isArray(U)&&(U=U.map(V=>As(V))),r(n,["safetySettings"],U)}const S=i(e,["tools"]);if(n!==void 0&&S!=null){let U=de(S);Array.isArray(U)&&(U=U.map(V=>ws(ue(V)))),r(n,["tools"],U)}const x=i(e,["toolConfig"]);if(n!==void 0&&x!=null&&r(n,["toolConfig"],xs(x)),i(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const P=i(e,["cachedContent"]);n!==void 0&&P!=null&&r(n,["cachedContent"],j(t,P));const M=i(e,["responseModalities"]);M!=null&&r(o,["responseModalities"],M);const b=i(e,["mediaResolution"]);b!=null&&r(o,["mediaResolution"],b);const A=i(e,["speechConfig"]);if(A!=null&&r(o,["speechConfig"],ze(A)),i(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const R=i(e,["thinkingConfig"]);R!=null&&r(o,["thinkingConfig"],R);const F=i(e,["imageConfig"]);F!=null&&r(o,["imageConfig"],ms(F));const D=i(e,["enableEnhancedCivicAnswers"]);return D!=null&&r(o,["enableEnhancedCivicAnswers"],D),o}function ds(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["candidates"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(d=>Yi(d))),r(e,["candidates"],c)}const s=i(t,["modelVersion"]);s!=null&&r(e,["modelVersion"],s);const l=i(t,["promptFeedback"]);l!=null&&r(e,["promptFeedback"],l);const a=i(t,["responseId"]);a!=null&&r(e,["responseId"],a);const u=i(t,["usageMetadata"]);return u!=null&&r(e,["usageMetadata"],u),e}function cs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function fs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],ce(t,o)),n}function ps(t){const e={};if(i(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=i(t,["enableWidget"]);return n!=null&&r(e,["enableWidget"],n),e}function hs(t){const e={};if(i(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(i(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=i(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],n),e}function ms(t){const e={},n=i(t,["aspectRatio"]);n!=null&&r(e,["aspectRatio"],n);const o=i(t,["imageSize"]);if(o!=null&&r(e,["imageSize"],o),i(t,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(i(t,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return e}function gs(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["request","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let u=Y(s);Array.isArray(u)&&(u=u.map(c=>Gn(c))),r(n,["request","contents"],u)}const l=i(e,["metadata"]);l!=null&&r(n,["metadata"],l);const a=i(e,["config"]);return a!=null&&r(n,["request","generationConfig"],us(t,a,i(n,["request"],{}))),n}function ys(t){const e={},n=i(t,["response"]);n!=null&&r(e,["response"],ds(n));const o=i(t,["error"]);return o!=null&&r(e,["error"],o),e}function Ts(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);if(e!==void 0&&s!=null&&r(e,["_query","pageToken"],s),i(t,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return n}function _s(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);e!==void 0&&s!=null&&r(e,["_query","pageToken"],s);const l=i(t,["filter"]);return e!==void 0&&l!=null&&r(e,["_query","filter"],l),n}function Es(t){const e={},n=i(t,["config"]);return n!=null&&Ts(n,e),e}function Cs(t){const e={},n=i(t,["config"]);return n!=null&&_s(n,e),e}function vs(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["operations"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>ve(a))),r(e,["batchJobs"],l)}return e}function Ss(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["batchPredictionJobs"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>Xe(a))),r(e,["batchJobs"],l)}return e}function Is(t){const e={},n=i(t,["mediaResolution"]);n!=null&&r(e,["mediaResolution"],n);const o=i(t,["codeExecutionResult"]);o!=null&&r(e,["codeExecutionResult"],o);const s=i(t,["executableCode"]);s!=null&&r(e,["executableCode"],s);const l=i(t,["fileData"]);l!=null&&r(e,["fileData"],rs(l));const a=i(t,["functionCall"]);a!=null&&r(e,["functionCall"],ls(a));const u=i(t,["functionResponse"]);u!=null&&r(e,["functionResponse"],u);const c=i(t,["inlineData"]);c!=null&&r(e,["inlineData"],Ji(c));const d=i(t,["text"]);d!=null&&r(e,["text"],d);const f=i(t,["thought"]);f!=null&&r(e,["thought"],f);const p=i(t,["thoughtSignature"]);p!=null&&r(e,["thoughtSignature"],p);const h=i(t,["videoMetadata"]);return h!=null&&r(e,["videoMetadata"],h),e}function As(t){const e={},n=i(t,["category"]);if(n!=null&&r(e,["category"],n),i(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=i(t,["threshold"]);return o!=null&&r(e,["threshold"],o),e}function xs(t){const e={},n=i(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],as(n));const o=i(t,["retrievalConfig"]);return o!=null&&r(e,["retrievalConfig"],o),e}function ws(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>p)),r(e,["functionDeclarations"],f)}if(i(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=i(t,["googleSearchRetrieval"]);o!=null&&r(e,["googleSearchRetrieval"],o);const s=i(t,["computerUse"]);s!=null&&r(e,["computerUse"],s);const l=i(t,["fileSearch"]);l!=null&&r(e,["fileSearch"],l);const a=i(t,["codeExecution"]);if(a!=null&&r(e,["codeExecution"],a),i(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=i(t,["googleMaps"]);u!=null&&r(e,["googleMaps"],ps(u));const c=i(t,["googleSearch"]);c!=null&&r(e,["googleSearch"],hs(c));const d=i(t,["urlContext"]);return d!=null&&r(e,["urlContext"],d),e}/**
30
30
  * @license
31
31
  * Copyright 2025 Google LLC
32
32
  * SPDX-License-Identifier: Apache-2.0
33
- */var j;(function(t){t.PAGED_ITEM_BATCH_JOBS="batchJobs",t.PAGED_ITEM_MODELS="models",t.PAGED_ITEM_TUNING_JOBS="tuningJobs",t.PAGED_ITEM_FILES="files",t.PAGED_ITEM_CACHED_CONTENTS="cachedContents",t.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",t.PAGED_ITEM_DOCUMENTS="documents"})(j||(j={}));class oe{constructor(e,n,o,s){this.pageInternal=[],this.paramsInternal={},this.requestInternal=n,this.init(e,o,s)}init(e,n,o){var s,l;this.nameInternal=e,this.pageInternal=n[this.nameInternal]||[],this.sdkHttpResponseInternal=n==null?void 0:n.sdkHttpResponse,this.idxInternal=0;let a={config:{}};!o||Object.keys(o).length===0?a={config:{}}:typeof o=="object"?a=Object.assign({},o):a=o,a.config&&(a.config.pageToken=n.nextPageToken),this.paramsInternal=a,this.pageInternalSize=(l=(s=a.config)===null||s===void 0?void 0:s.pageSize)!==null&&l!==void 0?l:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return((e=this.params.config)===null||e===void 0?void 0:e.pageToken)!==void 0}}/**
33
+ */var ee;(function(t){t.PAGED_ITEM_BATCH_JOBS="batchJobs",t.PAGED_ITEM_MODELS="models",t.PAGED_ITEM_TUNING_JOBS="tuningJobs",t.PAGED_ITEM_FILES="files",t.PAGED_ITEM_CACHED_CONTENTS="cachedContents",t.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",t.PAGED_ITEM_DOCUMENTS="documents"})(ee||(ee={}));class ie{constructor(e,n,o,s){this.pageInternal=[],this.paramsInternal={},this.requestInternal=n,this.init(e,o,s)}init(e,n,o){var s,l;this.nameInternal=e,this.pageInternal=n[this.nameInternal]||[],this.sdkHttpResponseInternal=n==null?void 0:n.sdkHttpResponse,this.idxInternal=0;let a={config:{}};!o||Object.keys(o).length===0?a={config:{}}:typeof o=="object"?a=Object.assign({},o):a=o,a.config&&(a.config.pageToken=n.nextPageToken),this.paramsInternal=a,this.pageInternalSize=(l=(s=a.config)===null||s===void 0?void 0:s.pageSize)!==null&&l!==void 0?l:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return((e=this.params.config)===null||e===void 0?void 0:e.pageToken)!==void 0}}/**
34
34
  * @license
35
35
  * Copyright 2025 Google LLC
36
36
  * SPDX-License-Identifier: Apache-2.0
37
- */class Ns extends Q{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new oe(j.PAGED_ITEM_BATCH_JOBS,o=>this.listInternal(o),await this.listInternal(n),n),this.create=async n=>(this.apiClient.isVertexAI()&&(n.config=this.formatDestination(n.src,n.config)),this.createInternal(n)),this.createEmbeddings=async n=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(n)}}createInlinedGenerateContentRequest(e){const n=Vn(this.apiClient,e),o=n._url,s=I("{model}:batchGenerateContent",o),u=n.batch.inputConfig.requests,c=u.requests,d=[];for(const f of c){const p=Object.assign({},f);if(p.systemInstruction){const h=p.systemInstruction;delete p.systemInstruction;const g=p.request;g.systemInstruction=h,p.request=g}d.push(p)}return u.requests=d,delete n.config,delete n._url,delete n._query,{path:s,body:n}}getGcsUri(e){if(typeof e=="string")return e.startsWith("gs://")?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e=="string")return e.startsWith("bq://")?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,n){const o=n?Object.assign({},n):{},s=Date.now().toString();if(o.displayName||(o.displayName=`genaiBatchJob_${s}`),o.dest===void 0){const l=this.getGcsUri(e),a=this.getBigqueryUri(e);if(l)l.endsWith(".jsonl")?o.dest=`${l.slice(0,-6)}/dest`:o.dest=`${l}_dest_${s}`;else if(a)o.dest=`${a}_dest_${s}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return o}async createInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Xi(this.apiClient,e);return u=I("batchPredictionJobs",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Xe(f))}else{const d=Vn(this.apiClient,e);return u=I("{model}:batchGenerateContent",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>ve(f))}}async createEmbeddingsInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Zi(this.apiClient,e);return l=I("{model}:asyncBatchEmbedContent",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>ve(c))}}async get(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=fs(this.apiClient,e);return u=I("batchPredictionJobs/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Xe(f))}else{const d=cs(this.apiClient,e);return u=I("batches/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>ve(f))}}async cancel(e){var n,o,s,l;let a="",u={};if(this.apiClient.isVertexAI()){const c=Wi(this.apiClient,e);a=I("batchPredictionJobs/{name}:cancel",c._url),u=c._query,delete c._url,delete c._query,await this.apiClient.request({path:a,queryParams:u,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}else{const c=$i(this.apiClient,e);a=I("batches/{name}:cancel",c._url),u=c._query,delete c._url,delete c._query,await this.apiClient.request({path:a,queryParams:u,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal})}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Cs(e);return u=I("batchPredictionJobs",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Ss(f),h=new vn;return Object.assign(h,p),h})}else{const d=Es(e);return u=I("batches",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=vs(f),h=new vn;return Object.assign(h,p),h})}}async delete(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=es(this.apiClient,e);return u=I("batchPredictionJobs/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>ns(f))}else{const d=ji(this.apiClient,e);return u=I("batches/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>ts(f))}}}/**
37
+ */class Ns extends Z{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new ie(ee.PAGED_ITEM_BATCH_JOBS,o=>this.listInternal(o),await this.listInternal(n),n),this.create=async n=>(this.apiClient.isVertexAI()&&(n.config=this.formatDestination(n.src,n.config)),this.createInternal(n)),this.createEmbeddings=async n=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(n)}}createInlinedGenerateContentRequest(e){const n=Vn(this.apiClient,e),o=n._url,s=I("{model}:batchGenerateContent",o),u=n.batch.inputConfig.requests,c=u.requests,d=[];for(const f of c){const p=Object.assign({},f);if(p.systemInstruction){const h=p.systemInstruction;delete p.systemInstruction;const g=p.request;g.systemInstruction=h,p.request=g}d.push(p)}return u.requests=d,delete n.config,delete n._url,delete n._query,{path:s,body:n}}getGcsUri(e){if(typeof e=="string")return e.startsWith("gs://")?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e=="string")return e.startsWith("bq://")?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,n){const o=n?Object.assign({},n):{},s=Date.now().toString();if(o.displayName||(o.displayName=`genaiBatchJob_${s}`),o.dest===void 0){const l=this.getGcsUri(e),a=this.getBigqueryUri(e);if(l)l.endsWith(".jsonl")?o.dest=`${l.slice(0,-6)}/dest`:o.dest=`${l}_dest_${s}`;else if(a)o.dest=`${a}_dest_${s}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return o}async createInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Xi(this.apiClient,e);return u=I("batchPredictionJobs",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Xe(f))}else{const d=Vn(this.apiClient,e);return u=I("{model}:batchGenerateContent",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>ve(f))}}async createEmbeddingsInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Zi(this.apiClient,e);return l=I("{model}:asyncBatchEmbedContent",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>ve(c))}}async get(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=fs(this.apiClient,e);return u=I("batchPredictionJobs/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Xe(f))}else{const d=cs(this.apiClient,e);return u=I("batches/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>ve(f))}}async cancel(e){var n,o,s,l;let a="",u={};if(this.apiClient.isVertexAI()){const c=Wi(this.apiClient,e);a=I("batchPredictionJobs/{name}:cancel",c._url),u=c._query,delete c._url,delete c._query,await this.apiClient.request({path:a,queryParams:u,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}else{const c=$i(this.apiClient,e);a=I("batches/{name}:cancel",c._url),u=c._query,delete c._url,delete c._query,await this.apiClient.request({path:a,queryParams:u,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal})}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Cs(e);return u=I("batchPredictionJobs",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Ss(f),h=new vn;return Object.assign(h,p),h})}else{const d=Es(e);return u=I("batches",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=vs(f),h=new vn;return Object.assign(h,p),h})}}async delete(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=es(this.apiClient,e);return u=I("batchPredictionJobs/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>ns(f))}else{const d=ji(this.apiClient,e);return u=I("batches/{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>ts(f))}}}/**
38
38
  * @license
39
39
  * Copyright 2025 Google LLC
40
40
  * SPDX-License-Identifier: Apache-2.0
41
- */function Ms(t){const e={},n=i(t,["data"]);if(n!=null&&r(e,["data"],n),i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function qn(t){const e={},n=i(t,["parts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(l=>Zs(l))),r(e,["parts"],s)}const o=i(t,["role"]);return o!=null&&r(e,["role"],o),e}function Ps(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);e!==void 0&&s!=null&&r(e,["expireTime"],s);const l=i(t,["displayName"]);e!==void 0&&l!=null&&r(e,["displayName"],l);const a=i(t,["contents"]);if(e!==void 0&&a!=null){let f=W(a);Array.isArray(f)&&(f=f.map(p=>qn(p))),r(e,["contents"],f)}const u=i(t,["systemInstruction"]);e!==void 0&&u!=null&&r(e,["systemInstruction"],qn(B(u)));const c=i(t,["tools"]);if(e!==void 0&&c!=null){let f=c;Array.isArray(f)&&(f=f.map(p=>er(p))),r(e,["tools"],f)}const d=i(t,["toolConfig"]);if(e!==void 0&&d!=null&&r(e,["toolConfig"],js(d)),i(t,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function Rs(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);e!==void 0&&s!=null&&r(e,["expireTime"],s);const l=i(t,["displayName"]);e!==void 0&&l!=null&&r(e,["displayName"],l);const a=i(t,["contents"]);if(e!==void 0&&a!=null){let p=W(a);Array.isArray(p)&&(p=p.map(h=>h)),r(e,["contents"],p)}const u=i(t,["systemInstruction"]);e!==void 0&&u!=null&&r(e,["systemInstruction"],B(u));const c=i(t,["tools"]);if(e!==void 0&&c!=null){let p=c;Array.isArray(p)&&(p=p.map(h=>tr(h))),r(e,["tools"],p)}const d=i(t,["toolConfig"]);e!==void 0&&d!=null&&r(e,["toolConfig"],d);const f=i(t,["kmsKeyName"]);return e!==void 0&&f!=null&&r(e,["encryption_spec","kmsKeyName"],f),n}function ks(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["model"],Sn(t,o));const s=i(e,["config"]);return s!=null&&Ps(s,n),n}function Ds(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["model"],Sn(t,o));const s=i(e,["config"]);return s!=null&&Rs(s,n),n}function bs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],Z(t,o)),n}function Us(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],Z(t,o)),n}function Ls(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function Fs(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function Gs(t){const e={};if(i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=i(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function Vs(t){const e={},n=i(t,["id"]);n!=null&&r(e,["id"],n);const o=i(t,["args"]);o!=null&&r(e,["args"],o);const s=i(t,["name"]);if(s!=null&&r(e,["name"],s),i(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(i(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function qs(t){const e={},n=i(t,["mode"]);n!=null&&r(e,["mode"],n);const o=i(t,["allowedFunctionNames"]);if(o!=null&&r(e,["allowedFunctionNames"],o),i(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function Hs(t){const e={};if(i(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=i(t,["description"]);n!=null&&r(e,["description"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["parameters"]);s!=null&&r(e,["parameters"],s);const l=i(t,["parametersJsonSchema"]);l!=null&&r(e,["parametersJsonSchema"],l);const a=i(t,["response"]);a!=null&&r(e,["response"],a);const u=i(t,["responseJsonSchema"]);return u!=null&&r(e,["responseJsonSchema"],u),e}function Bs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],Z(t,o)),n}function Js(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],Z(t,o)),n}function $s(t){const e={};if(i(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=i(t,["enableWidget"]);return n!=null&&r(e,["enableWidget"],n),e}function Ws(t){const e={};if(i(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(i(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=i(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],n),e}function Ys(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);return e!==void 0&&s!=null&&r(e,["_query","pageToken"],s),n}function Ks(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);return e!==void 0&&s!=null&&r(e,["_query","pageToken"],s),n}function zs(t){const e={},n=i(t,["config"]);return n!=null&&Ys(n,e),e}function Os(t){const e={},n=i(t,["config"]);return n!=null&&Ks(n,e),e}function Xs(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["cachedContents"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["cachedContents"],l)}return e}function Qs(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["cachedContents"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["cachedContents"],l)}return e}function Zs(t){const e={},n=i(t,["mediaResolution"]);n!=null&&r(e,["mediaResolution"],n);const o=i(t,["codeExecutionResult"]);o!=null&&r(e,["codeExecutionResult"],o);const s=i(t,["executableCode"]);s!=null&&r(e,["executableCode"],s);const l=i(t,["fileData"]);l!=null&&r(e,["fileData"],Gs(l));const a=i(t,["functionCall"]);a!=null&&r(e,["functionCall"],Vs(a));const u=i(t,["functionResponse"]);u!=null&&r(e,["functionResponse"],u);const c=i(t,["inlineData"]);c!=null&&r(e,["inlineData"],Ms(c));const d=i(t,["text"]);d!=null&&r(e,["text"],d);const f=i(t,["thought"]);f!=null&&r(e,["thought"],f);const p=i(t,["thoughtSignature"]);p!=null&&r(e,["thoughtSignature"],p);const h=i(t,["videoMetadata"]);return h!=null&&r(e,["videoMetadata"],h),e}function js(t){const e={},n=i(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],qs(n));const o=i(t,["retrievalConfig"]);return o!=null&&r(e,["retrievalConfig"],o),e}function er(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>p)),r(e,["functionDeclarations"],f)}if(i(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=i(t,["googleSearchRetrieval"]);o!=null&&r(e,["googleSearchRetrieval"],o);const s=i(t,["computerUse"]);s!=null&&r(e,["computerUse"],s);const l=i(t,["fileSearch"]);l!=null&&r(e,["fileSearch"],l);const a=i(t,["codeExecution"]);if(a!=null&&r(e,["codeExecution"],a),i(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=i(t,["googleMaps"]);u!=null&&r(e,["googleMaps"],$s(u));const c=i(t,["googleSearch"]);c!=null&&r(e,["googleSearch"],Ws(c));const d=i(t,["urlContext"]);return d!=null&&r(e,["urlContext"],d),e}function tr(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(h=>Hs(h))),r(e,["functionDeclarations"],p)}const o=i(t,["retrieval"]);o!=null&&r(e,["retrieval"],o);const s=i(t,["googleSearchRetrieval"]);s!=null&&r(e,["googleSearchRetrieval"],s);const l=i(t,["computerUse"]);if(l!=null&&r(e,["computerUse"],l),i(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=i(t,["codeExecution"]);a!=null&&r(e,["codeExecution"],a);const u=i(t,["enterpriseWebSearch"]);u!=null&&r(e,["enterpriseWebSearch"],u);const c=i(t,["googleMaps"]);c!=null&&r(e,["googleMaps"],c);const d=i(t,["googleSearch"]);d!=null&&r(e,["googleSearch"],d);const f=i(t,["urlContext"]);return f!=null&&r(e,["urlContext"],f),e}function nr(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);return e!==void 0&&s!=null&&r(e,["expireTime"],s),n}function or(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);return e!==void 0&&s!=null&&r(e,["expireTime"],s),n}function ir(t,e){const n={},o=i(e,["name"]);o!=null&&r(n,["_url","name"],Z(t,o));const s=i(e,["config"]);return s!=null&&nr(s,n),n}function sr(t,e){const n={},o=i(e,["name"]);o!=null&&r(n,["_url","name"],Z(t,o));const s=i(e,["config"]);return s!=null&&or(s,n),n}/**
41
+ */function Ms(t){const e={},n=i(t,["data"]);if(n!=null&&r(e,["data"],n),i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function qn(t){const e={},n=i(t,["parts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(l=>Zs(l))),r(e,["parts"],s)}const o=i(t,["role"]);return o!=null&&r(e,["role"],o),e}function Ps(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);e!==void 0&&s!=null&&r(e,["expireTime"],s);const l=i(t,["displayName"]);e!==void 0&&l!=null&&r(e,["displayName"],l);const a=i(t,["contents"]);if(e!==void 0&&a!=null){let f=Y(a);Array.isArray(f)&&(f=f.map(p=>qn(p))),r(e,["contents"],f)}const u=i(t,["systemInstruction"]);e!==void 0&&u!=null&&r(e,["systemInstruction"],qn(B(u)));const c=i(t,["tools"]);if(e!==void 0&&c!=null){let f=c;Array.isArray(f)&&(f=f.map(p=>er(p))),r(e,["tools"],f)}const d=i(t,["toolConfig"]);if(e!==void 0&&d!=null&&r(e,["toolConfig"],js(d)),i(t,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function Rs(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);e!==void 0&&s!=null&&r(e,["expireTime"],s);const l=i(t,["displayName"]);e!==void 0&&l!=null&&r(e,["displayName"],l);const a=i(t,["contents"]);if(e!==void 0&&a!=null){let p=Y(a);Array.isArray(p)&&(p=p.map(h=>h)),r(e,["contents"],p)}const u=i(t,["systemInstruction"]);e!==void 0&&u!=null&&r(e,["systemInstruction"],B(u));const c=i(t,["tools"]);if(e!==void 0&&c!=null){let p=c;Array.isArray(p)&&(p=p.map(h=>tr(h))),r(e,["tools"],p)}const d=i(t,["toolConfig"]);e!==void 0&&d!=null&&r(e,["toolConfig"],d);const f=i(t,["kmsKeyName"]);return e!==void 0&&f!=null&&r(e,["encryption_spec","kmsKeyName"],f),n}function ks(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["model"],Sn(t,o));const s=i(e,["config"]);return s!=null&&Ps(s,n),n}function Ds(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["model"],Sn(t,o));const s=i(e,["config"]);return s!=null&&Rs(s,n),n}function bs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],j(t,o)),n}function Us(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],j(t,o)),n}function Ls(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function Fs(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function Gs(t){const e={};if(i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=i(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function Vs(t){const e={},n=i(t,["id"]);n!=null&&r(e,["id"],n);const o=i(t,["args"]);o!=null&&r(e,["args"],o);const s=i(t,["name"]);if(s!=null&&r(e,["name"],s),i(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(i(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function qs(t){const e={},n=i(t,["mode"]);n!=null&&r(e,["mode"],n);const o=i(t,["allowedFunctionNames"]);if(o!=null&&r(e,["allowedFunctionNames"],o),i(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function Hs(t){const e={};if(i(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=i(t,["description"]);n!=null&&r(e,["description"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["parameters"]);s!=null&&r(e,["parameters"],s);const l=i(t,["parametersJsonSchema"]);l!=null&&r(e,["parametersJsonSchema"],l);const a=i(t,["response"]);a!=null&&r(e,["response"],a);const u=i(t,["responseJsonSchema"]);return u!=null&&r(e,["responseJsonSchema"],u),e}function Bs(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],j(t,o)),n}function Js(t,e){const n={},o=i(e,["name"]);return o!=null&&r(n,["_url","name"],j(t,o)),n}function $s(t){const e={};if(i(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=i(t,["enableWidget"]);return n!=null&&r(e,["enableWidget"],n),e}function Ws(t){const e={};if(i(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(i(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=i(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],n),e}function Ys(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);return e!==void 0&&s!=null&&r(e,["_query","pageToken"],s),n}function Ks(t,e){const n={},o=i(t,["pageSize"]);e!==void 0&&o!=null&&r(e,["_query","pageSize"],o);const s=i(t,["pageToken"]);return e!==void 0&&s!=null&&r(e,["_query","pageToken"],s),n}function zs(t){const e={},n=i(t,["config"]);return n!=null&&Ys(n,e),e}function Os(t){const e={},n=i(t,["config"]);return n!=null&&Ks(n,e),e}function Xs(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["cachedContents"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["cachedContents"],l)}return e}function Qs(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["cachedContents"]);if(s!=null){let l=s;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["cachedContents"],l)}return e}function Zs(t){const e={},n=i(t,["mediaResolution"]);n!=null&&r(e,["mediaResolution"],n);const o=i(t,["codeExecutionResult"]);o!=null&&r(e,["codeExecutionResult"],o);const s=i(t,["executableCode"]);s!=null&&r(e,["executableCode"],s);const l=i(t,["fileData"]);l!=null&&r(e,["fileData"],Gs(l));const a=i(t,["functionCall"]);a!=null&&r(e,["functionCall"],Vs(a));const u=i(t,["functionResponse"]);u!=null&&r(e,["functionResponse"],u);const c=i(t,["inlineData"]);c!=null&&r(e,["inlineData"],Ms(c));const d=i(t,["text"]);d!=null&&r(e,["text"],d);const f=i(t,["thought"]);f!=null&&r(e,["thought"],f);const p=i(t,["thoughtSignature"]);p!=null&&r(e,["thoughtSignature"],p);const h=i(t,["videoMetadata"]);return h!=null&&r(e,["videoMetadata"],h),e}function js(t){const e={},n=i(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],qs(n));const o=i(t,["retrievalConfig"]);return o!=null&&r(e,["retrievalConfig"],o),e}function er(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>p)),r(e,["functionDeclarations"],f)}if(i(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=i(t,["googleSearchRetrieval"]);o!=null&&r(e,["googleSearchRetrieval"],o);const s=i(t,["computerUse"]);s!=null&&r(e,["computerUse"],s);const l=i(t,["fileSearch"]);l!=null&&r(e,["fileSearch"],l);const a=i(t,["codeExecution"]);if(a!=null&&r(e,["codeExecution"],a),i(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=i(t,["googleMaps"]);u!=null&&r(e,["googleMaps"],$s(u));const c=i(t,["googleSearch"]);c!=null&&r(e,["googleSearch"],Ws(c));const d=i(t,["urlContext"]);return d!=null&&r(e,["urlContext"],d),e}function tr(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(h=>Hs(h))),r(e,["functionDeclarations"],p)}const o=i(t,["retrieval"]);o!=null&&r(e,["retrieval"],o);const s=i(t,["googleSearchRetrieval"]);s!=null&&r(e,["googleSearchRetrieval"],s);const l=i(t,["computerUse"]);if(l!=null&&r(e,["computerUse"],l),i(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=i(t,["codeExecution"]);a!=null&&r(e,["codeExecution"],a);const u=i(t,["enterpriseWebSearch"]);u!=null&&r(e,["enterpriseWebSearch"],u);const c=i(t,["googleMaps"]);c!=null&&r(e,["googleMaps"],c);const d=i(t,["googleSearch"]);d!=null&&r(e,["googleSearch"],d);const f=i(t,["urlContext"]);return f!=null&&r(e,["urlContext"],f),e}function nr(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);return e!==void 0&&s!=null&&r(e,["expireTime"],s),n}function or(t,e){const n={},o=i(t,["ttl"]);e!==void 0&&o!=null&&r(e,["ttl"],o);const s=i(t,["expireTime"]);return e!==void 0&&s!=null&&r(e,["expireTime"],s),n}function ir(t,e){const n={},o=i(e,["name"]);o!=null&&r(n,["_url","name"],j(t,o));const s=i(e,["config"]);return s!=null&&nr(s,n),n}function sr(t,e){const n={},o=i(e,["name"]);o!=null&&r(n,["_url","name"],j(t,o));const s=i(e,["config"]);return s!=null&&or(s,n),n}/**
42
42
  * @license
43
43
  * Copyright 2025 Google LLC
44
44
  * SPDX-License-Identifier: Apache-2.0
45
- */class rr extends Q{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new oe(j.PAGED_ITEM_CACHED_CONTENTS,o=>this.listInternal(o),await this.listInternal(n),n)}async create(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Ds(this.apiClient,e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>f)}else{const d=ks(this.apiClient,e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>f)}}async get(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Js(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>f)}else{const d=Bs(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>f)}}async delete(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Us(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Fs(f),h=new En;return Object.assign(h,p),h})}else{const d=bs(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Ls(f),h=new En;return Object.assign(h,p),h})}}async update(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=sr(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>f)}else{const d=ir(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>f)}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Os(e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Qs(f),h=new Cn;return Object.assign(h,p),h})}else{const d=zs(e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Xs(f),h=new Cn;return Object.assign(h,p),h})}}}function Se(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function Hn(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(t){return this instanceof k?(this.v=t,this):new k(t)}function z(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(t,e||[]),s,l=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(g){return function(y){return Promise.resolve(y).then(g,p)}}function u(g,y){o[g]&&(s[g]=function(C){return new Promise(function(T,E){l.push([g,C,T,E])>1||c(g,C)})},y&&(s[g]=y(s[g])))}function c(g,y){try{d(o[g](y))}catch(C){h(l[0][3],C)}}function d(g){g.value instanceof k?Promise.resolve(g.value.v).then(f,p):h(l[0][2],g)}function f(g){c("next",g)}function p(g){c("throw",g)}function h(g,y){g(y),l.shift(),l.length&&c(l[0][0],l[0][1])}}function O(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hn=="function"?Hn(t):t[Symbol.iterator](),n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n);function o(l){n[l]=t[l]&&function(a){return new Promise(function(u,c){a=t[l](a),s(u,c,a.done,a.value)})}}function s(l,a,u,c){Promise.resolve(c).then(function(d){l({value:d,done:u})},a)}}typeof SuppressedError=="function"&&SuppressedError;/**
45
+ */class rr extends Z{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new ie(ee.PAGED_ITEM_CACHED_CONTENTS,o=>this.listInternal(o),await this.listInternal(n),n)}async create(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Ds(this.apiClient,e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>f)}else{const d=ks(this.apiClient,e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>f)}}async get(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Js(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>f)}else{const d=Bs(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>f)}}async delete(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Us(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Fs(f),h=new En;return Object.assign(h,p),h})}else{const d=bs(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Ls(f),h=new En;return Object.assign(h,p),h})}}async update(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=sr(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>f)}else{const d=ir(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>f)}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Os(e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Qs(f),h=new Cn;return Object.assign(h,p),h})}else{const d=zs(e);return u=I("cachedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Xs(f),h=new Cn;return Object.assign(h,p),h})}}}function Se(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function Hn(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(t){return this instanceof k?(this.v=t,this):new k(t)}function O(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(t,e||[]),s,l=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),s[Symbol.asyncIterator]=function(){return this},s;function a(g){return function(y){return Promise.resolve(y).then(g,p)}}function u(g,y){o[g]&&(s[g]=function(C){return new Promise(function(T,E){l.push([g,C,T,E])>1||c(g,C)})},y&&(s[g]=y(s[g])))}function c(g,y){try{d(o[g](y))}catch(C){h(l[0][3],C)}}function d(g){g.value instanceof k?Promise.resolve(g.value.v).then(f,p):h(l[0][2],g)}function f(g){c("next",g)}function p(g){c("throw",g)}function h(g,y){g(y),l.shift(),l.length&&c(l[0][0],l[0][1])}}function X(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof Hn=="function"?Hn(t):t[Symbol.iterator](),n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n);function o(l){n[l]=t[l]&&function(a){return new Promise(function(u,c){a=t[l](a),s(u,c,a.done,a.value)})}}function s(l,a,u,c){Promise.resolve(c).then(function(d){l({value:d,done:u})},a)}}typeof SuppressedError=="function"&&SuppressedError;/**
46
46
  * @license
47
47
  * Copyright 2025 Google LLC
48
48
  * SPDX-License-Identifier: Apache-2.0
49
- */function lr(t){var e;if(t.candidates==null||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;return n===void 0?!1:Bn(n)}function Bn(t){if(t.parts===void 0||t.parts.length===0)return!1;for(const e of t.parts)if(e===void 0||Object.keys(e).length===0)return!1;return!0}function ar(t){if(t.length!==0){for(const e of t)if(e.role!=="user"&&e.role!=="model")throw new Error(`Role must be user or model, but got ${e.role}.`)}}function Jn(t){if(t===void 0||t.length===0)return[];const e=[],n=t.length;let o=0;for(;o<n;)if(t[o].role==="user")e.push(t[o]),o++;else{const s=[];let l=!0;for(;o<n&&t[o].role==="model";)s.push(t[o]),l&&!Bn(t[o])&&(l=!1),o++;l?e.push(...s):e.pop()}return e}class ur{constructor(e,n){this.modelsModule=e,this.apiClient=n}create(e){return new dr(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class dr{constructor(e,n,o,s={},l=[]){this.apiClient=e,this.modelsModule=n,this.model=o,this.config=s,this.history=l,this.sendPromise=Promise.resolve(),ar(l)}async sendMessage(e){var n;await this.sendPromise;const o=B(e.message),s=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(o),config:(n=e.config)!==null&&n!==void 0?n:this.config});return this.sendPromise=(async()=>{var l,a,u;const c=await s,d=(a=(l=c.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content,f=c.automaticFunctionCallingHistory,p=this.getHistory(!0).length;let h=[];f!=null&&(h=(u=f.slice(p))!==null&&u!==void 0?u:[]);const g=d?[d]:[];this.recordHistory(o,g,h)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),s}async sendMessageStream(e){var n;await this.sendPromise;const o=B(e.message),s=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(o),config:(n=e.config)!==null&&n!==void 0?n:this.config});this.sendPromise=s.then(()=>{}).catch(()=>{});const l=await s;return this.processStreamResponse(l,o)}getHistory(e=!1){const n=e?Jn(this.history):this.history;return structuredClone(n)}processStreamResponse(e,n){return z(this,arguments,function*(){var s,l,a,u,c,d;const f=[];try{for(var p=!0,h=O(e),g;g=yield k(h.next()),s=g.done,!s;p=!0){u=g.value,p=!1;const y=u;if(lr(y)){const C=(d=(c=y.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content;C!==void 0&&f.push(C)}yield yield k(y)}}catch(y){l={error:y}}finally{try{!p&&!s&&(a=h.return)&&(yield k(a.call(h)))}finally{if(l)throw l.error}}this.recordHistory(n,f)})}recordHistory(e,n,o){let s=[];n.length>0&&n.every(l=>l.role!==void 0)?s=n:s.push({role:"model",parts:[]}),o&&o.length>0?this.history.push(...Jn(o)):this.history.push(e),this.history.push(...s)}}/**
49
+ */function lr(t){var e;if(t.candidates==null||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;return n===void 0?!1:Bn(n)}function Bn(t){if(t.parts===void 0||t.parts.length===0)return!1;for(const e of t.parts)if(e===void 0||Object.keys(e).length===0)return!1;return!0}function ar(t){if(t.length!==0){for(const e of t)if(e.role!=="user"&&e.role!=="model")throw new Error(`Role must be user or model, but got ${e.role}.`)}}function Jn(t){if(t===void 0||t.length===0)return[];const e=[],n=t.length;let o=0;for(;o<n;)if(t[o].role==="user")e.push(t[o]),o++;else{const s=[];let l=!0;for(;o<n&&t[o].role==="model";)s.push(t[o]),l&&!Bn(t[o])&&(l=!1),o++;l?e.push(...s):e.pop()}return e}class ur{constructor(e,n){this.modelsModule=e,this.apiClient=n}create(e){return new dr(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class dr{constructor(e,n,o,s={},l=[]){this.apiClient=e,this.modelsModule=n,this.model=o,this.config=s,this.history=l,this.sendPromise=Promise.resolve(),ar(l)}async sendMessage(e){var n;await this.sendPromise;const o=B(e.message),s=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(o),config:(n=e.config)!==null&&n!==void 0?n:this.config});return this.sendPromise=(async()=>{var l,a,u;const c=await s,d=(a=(l=c.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content,f=c.automaticFunctionCallingHistory,p=this.getHistory(!0).length;let h=[];f!=null&&(h=(u=f.slice(p))!==null&&u!==void 0?u:[]);const g=d?[d]:[];this.recordHistory(o,g,h)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),s}async sendMessageStream(e){var n;await this.sendPromise;const o=B(e.message),s=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(o),config:(n=e.config)!==null&&n!==void 0?n:this.config});this.sendPromise=s.then(()=>{}).catch(()=>{});const l=await s;return this.processStreamResponse(l,o)}getHistory(e=!1){const n=e?Jn(this.history):this.history;return structuredClone(n)}processStreamResponse(e,n){return O(this,arguments,function*(){var s,l,a,u,c,d;const f=[];try{for(var p=!0,h=X(e),g;g=yield k(h.next()),s=g.done,!s;p=!0){u=g.value,p=!1;const y=u;if(lr(y)){const C=(d=(c=y.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content;C!==void 0&&f.push(C)}yield yield k(y)}}catch(y){l={error:y}}finally{try{!p&&!s&&(a=h.return)&&(yield k(a.call(h)))}finally{if(l)throw l.error}}this.recordHistory(n,f)})}recordHistory(e,n,o){let s=[];n.length>0&&n.every(l=>l.role!==void 0)?s=n:s.push({role:"model",parts:[]}),o&&o.length>0?this.history.push(...Jn(o)):this.history.push(e),this.history.push(...s)}}/**
50
50
  * @license
51
51
  * Copyright 2025 Google LLC
52
52
  * SPDX-License-Identifier: Apache-2.0
@@ -58,7 +58,7 @@
58
58
  * @license
59
59
  * Copyright 2025 Google LLC
60
60
  * SPDX-License-Identifier: Apache-2.0
61
- */class _r extends Q{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new oe(j.PAGED_ITEM_FILES,o=>this.listInternal(o),await this.listInternal(n),n)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(e.file,e.config).then(n=>n)}async download(e){await this.apiClient.downloadFile(e)}async listInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=yr(e);return l=I("files",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=Tr(c),f=new Si;return Object.assign(f,d),f})}}async createInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=cr(e);return l=I("upload/v1beta/files",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=fr(c),f=new Ii;return Object.assign(f,d),f})}}async get(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=mr(e);return l=I("files/{file}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async delete(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=pr(e);return l=I("files/{file}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=hr(c),f=new Ai;return Object.assign(f,d),f})}}}/**
61
+ */class _r extends Z{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new ie(ee.PAGED_ITEM_FILES,o=>this.listInternal(o),await this.listInternal(n),n)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(e.file,e.config).then(n=>n)}async download(e){await this.apiClient.downloadFile(e)}async listInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=yr(e);return l=I("files",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=Tr(c),f=new Si;return Object.assign(f,d),f})}}async createInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=cr(e);return l=I("upload/v1beta/files",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=fr(c),f=new Ii;return Object.assign(f,d),f})}}async get(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=mr(e);return l=I("files/{file}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async delete(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=pr(e);return l=I("files/{file}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=hr(c),f=new Ai;return Object.assign(f,d),f})}}}/**
62
62
  * @license
63
63
  * Copyright 2025 Google LLC
64
64
  * SPDX-License-Identifier: Apache-2.0
@@ -66,7 +66,7 @@
66
66
  * @license
67
67
  * Copyright 2025 Google LLC
68
68
  * SPDX-License-Identifier: Apache-2.0
69
- */function Hr(t){const e={},n=i(t,["data"]);if(n!=null&&r(e,["data"],n),i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function Br(t){const e={},n=i(t,["content"]);n!=null&&r(e,["content"],n);const o=i(t,["citationMetadata"]);o!=null&&r(e,["citationMetadata"],Jr(o));const s=i(t,["tokenCount"]);s!=null&&r(e,["tokenCount"],s);const l=i(t,["finishReason"]);l!=null&&r(e,["finishReason"],l);const a=i(t,["avgLogprobs"]);a!=null&&r(e,["avgLogprobs"],a);const u=i(t,["groundingMetadata"]);u!=null&&r(e,["groundingMetadata"],u);const c=i(t,["index"]);c!=null&&r(e,["index"],c);const d=i(t,["logprobsResult"]);d!=null&&r(e,["logprobsResult"],d);const f=i(t,["safetyRatings"]);if(f!=null){let h=f;Array.isArray(h)&&(h=h.map(g=>g)),r(e,["safetyRatings"],h)}const p=i(t,["urlContextMetadata"]);return p!=null&&r(e,["urlContextMetadata"],p),e}function Jr(t){const e={},n=i(t,["citationSources"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>s)),r(e,["citations"],o)}return e}function $r(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let l=W(s);Array.isArray(l)&&(l=l.map(a=>a)),r(n,["contents"],l)}return n}function Wr(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["tokensInfo"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>l)),r(e,["tokensInfo"],s)}return e}function Yr(t){const e={},n=i(t,["values"]);n!=null&&r(e,["values"],n);const o=i(t,["statistics"]);return o!=null&&r(e,["statistics"],Kr(o)),e}function Kr(t){const e={},n=i(t,["truncated"]);n!=null&&r(e,["truncated"],n);const o=i(t,["token_count"]);return o!=null&&r(e,["tokenCount"],o),e}function xe(t){const e={},n=i(t,["parts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(l=>na(l))),r(e,["parts"],s)}const o=i(t,["role"]);return o!=null&&r(e,["role"],o),e}function zr(t){const e={},n=i(t,["controlType"]);n!=null&&r(e,["controlType"],n);const o=i(t,["enableControlImageComputation"]);return o!=null&&r(e,["computeControl"],o),e}function Or(t){const e={};if(i(t,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(i(t,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(i(t,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return e}function Xr(t,e){const n={},o=i(t,["systemInstruction"]);e!==void 0&&o!=null&&r(e,["systemInstruction"],B(o));const s=i(t,["tools"]);if(e!==void 0&&s!=null){let a=s;Array.isArray(a)&&(a=a.map(u=>Qn(u))),r(e,["tools"],a)}const l=i(t,["generationConfig"]);return e!==void 0&&l!=null&&r(e,["generationConfig"],Hl(l)),n}function Qr(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=W(s);Array.isArray(a)&&(a=a.map(u=>xe(u))),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&Or(l),n}function Zr(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=W(s);Array.isArray(a)&&(a=a.map(u=>u)),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&Xr(l,n),n}function jr(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["totalTokens"]);o!=null&&r(e,["totalTokens"],o);const s=i(t,["cachedContentTokenCount"]);return s!=null&&r(e,["cachedContentTokenCount"],s),e}function el(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["totalTokens"]);return o!=null&&r(e,["totalTokens"],o),e}function tl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function nl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function ol(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function il(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function sl(t,e){const n={},o=i(t,["outputGcsUri"]);e!==void 0&&o!=null&&r(e,["parameters","storageUri"],o);const s=i(t,["negativePrompt"]);e!==void 0&&s!=null&&r(e,["parameters","negativePrompt"],s);const l=i(t,["numberOfImages"]);e!==void 0&&l!=null&&r(e,["parameters","sampleCount"],l);const a=i(t,["aspectRatio"]);e!==void 0&&a!=null&&r(e,["parameters","aspectRatio"],a);const u=i(t,["guidanceScale"]);e!==void 0&&u!=null&&r(e,["parameters","guidanceScale"],u);const c=i(t,["seed"]);e!==void 0&&c!=null&&r(e,["parameters","seed"],c);const d=i(t,["safetyFilterLevel"]);e!==void 0&&d!=null&&r(e,["parameters","safetySetting"],d);const f=i(t,["personGeneration"]);e!==void 0&&f!=null&&r(e,["parameters","personGeneration"],f);const p=i(t,["includeSafetyAttributes"]);e!==void 0&&p!=null&&r(e,["parameters","includeSafetyAttributes"],p);const h=i(t,["includeRaiReason"]);e!==void 0&&h!=null&&r(e,["parameters","includeRaiReason"],h);const g=i(t,["language"]);e!==void 0&&g!=null&&r(e,["parameters","language"],g);const y=i(t,["outputMimeType"]);e!==void 0&&y!=null&&r(e,["parameters","outputOptions","mimeType"],y);const C=i(t,["outputCompressionQuality"]);e!==void 0&&C!=null&&r(e,["parameters","outputOptions","compressionQuality"],C);const T=i(t,["addWatermark"]);e!==void 0&&T!=null&&r(e,["parameters","addWatermark"],T);const E=i(t,["labels"]);e!==void 0&&E!=null&&r(e,["labels"],E);const _=i(t,["editMode"]);e!==void 0&&_!=null&&r(e,["parameters","editMode"],_);const v=i(t,["baseSteps"]);return e!==void 0&&v!=null&&r(e,["parameters","editConfig","baseSteps"],v),n}function rl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["referenceImages"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(c=>aa(c))),r(n,["instances[0]","referenceImages"],u)}const a=i(e,["config"]);return a!=null&&sl(a,n),n}function ll(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>we(l))),r(e,["generatedImages"],s)}return e}function al(t,e){const n={},o=i(t,["taskType"]);e!==void 0&&o!=null&&r(e,["requests[]","taskType"],o);const s=i(t,["title"]);e!==void 0&&s!=null&&r(e,["requests[]","title"],s);const l=i(t,["outputDimensionality"]);if(e!==void 0&&l!=null&&r(e,["requests[]","outputDimensionality"],l),i(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(i(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function ul(t,e){const n={},o=i(t,["taskType"]);e!==void 0&&o!=null&&r(e,["instances[]","task_type"],o);const s=i(t,["title"]);e!==void 0&&s!=null&&r(e,["instances[]","title"],s);const l=i(t,["outputDimensionality"]);e!==void 0&&l!=null&&r(e,["parameters","outputDimensionality"],l);const a=i(t,["mimeType"]);e!==void 0&&a!=null&&r(e,["instances[]","mimeType"],a);const u=i(t,["autoTruncate"]);return e!==void 0&&u!=null&&r(e,["parameters","autoTruncate"],u),n}function dl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let u=Ye(t,s);Array.isArray(u)&&(u=u.map(c=>c)),r(n,["requests[]","content"],u)}const l=i(e,["config"]);l!=null&&al(l,n);const a=i(e,["model"]);return a!==void 0&&r(n,["requests[]","model"],L(t,a)),n}function cl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=Ye(t,s);Array.isArray(a)&&(a=a.map(u=>u)),r(n,["instances[]","content"],a)}const l=i(e,["config"]);return l!=null&&ul(l,n),n}function fl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["embeddings"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["embeddings"],l)}const s=i(t,["metadata"]);return s!=null&&r(e,["metadata"],s),e}function pl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions[]","embeddings"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>Yr(a))),r(e,["embeddings"],l)}const s=i(t,["metadata"]);return s!=null&&r(e,["metadata"],s),e}function hl(t){const e={},n=i(t,["endpoint"]);n!=null&&r(e,["name"],n);const o=i(t,["deployedModelId"]);return o!=null&&r(e,["deployedModelId"],o),e}function ml(t){const e={};if(i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=i(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function gl(t){const e={},n=i(t,["id"]);n!=null&&r(e,["id"],n);const o=i(t,["args"]);o!=null&&r(e,["args"],o);const s=i(t,["name"]);if(s!=null&&r(e,["name"],s),i(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(i(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function yl(t){const e={},n=i(t,["mode"]);n!=null&&r(e,["mode"],n);const o=i(t,["allowedFunctionNames"]);if(o!=null&&r(e,["allowedFunctionNames"],o),i(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function Tl(t){const e={};if(i(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=i(t,["description"]);n!=null&&r(e,["description"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["parameters"]);s!=null&&r(e,["parameters"],s);const l=i(t,["parametersJsonSchema"]);l!=null&&r(e,["parametersJsonSchema"],l);const a=i(t,["response"]);a!=null&&r(e,["response"],a);const u=i(t,["responseJsonSchema"]);return u!=null&&r(e,["responseJsonSchema"],u),e}function _l(t,e,n){const o={},s=i(e,["systemInstruction"]);n!==void 0&&s!=null&&r(n,["systemInstruction"],xe(B(s)));const l=i(e,["temperature"]);l!=null&&r(o,["temperature"],l);const a=i(e,["topP"]);a!=null&&r(o,["topP"],a);const u=i(e,["topK"]);u!=null&&r(o,["topK"],u);const c=i(e,["candidateCount"]);c!=null&&r(o,["candidateCount"],c);const d=i(e,["maxOutputTokens"]);d!=null&&r(o,["maxOutputTokens"],d);const f=i(e,["stopSequences"]);f!=null&&r(o,["stopSequences"],f);const p=i(e,["responseLogprobs"]);p!=null&&r(o,["responseLogprobs"],p);const h=i(e,["logprobs"]);h!=null&&r(o,["logprobs"],h);const g=i(e,["presencePenalty"]);g!=null&&r(o,["presencePenalty"],g);const y=i(e,["frequencyPenalty"]);y!=null&&r(o,["frequencyPenalty"],y);const C=i(e,["seed"]);C!=null&&r(o,["seed"],C);const T=i(e,["responseMimeType"]);T!=null&&r(o,["responseMimeType"],T);const E=i(e,["responseSchema"]);E!=null&&r(o,["responseSchema"],Ke(E));const _=i(e,["responseJsonSchema"]);if(_!=null&&r(o,["responseJsonSchema"],_),i(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(i(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const v=i(e,["safetySettings"]);if(n!==void 0&&v!=null){let U=v;Array.isArray(U)&&(U=U.map(V=>ua(V))),r(n,["safetySettings"],U)}const S=i(e,["tools"]);if(n!==void 0&&S!=null){let U=de(S);Array.isArray(U)&&(U=U.map(V=>ga(ue(V)))),r(n,["tools"],U)}const x=i(e,["toolConfig"]);if(n!==void 0&&x!=null&&r(n,["toolConfig"],ma(x)),i(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const P=i(e,["cachedContent"]);n!==void 0&&P!=null&&r(n,["cachedContent"],Z(t,P));const M=i(e,["responseModalities"]);M!=null&&r(o,["responseModalities"],M);const b=i(e,["mediaResolution"]);b!=null&&r(o,["mediaResolution"],b);const A=i(e,["speechConfig"]);if(A!=null&&r(o,["speechConfig"],ze(A)),i(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const R=i(e,["thinkingConfig"]);R!=null&&r(o,["thinkingConfig"],R);const F=i(e,["imageConfig"]);F!=null&&r(o,["imageConfig"],Yl(F));const D=i(e,["enableEnhancedCivicAnswers"]);return D!=null&&r(o,["enableEnhancedCivicAnswers"],D),o}function El(t,e,n){const o={},s=i(e,["systemInstruction"]);n!==void 0&&s!=null&&r(n,["systemInstruction"],B(s));const l=i(e,["temperature"]);l!=null&&r(o,["temperature"],l);const a=i(e,["topP"]);a!=null&&r(o,["topP"],a);const u=i(e,["topK"]);u!=null&&r(o,["topK"],u);const c=i(e,["candidateCount"]);c!=null&&r(o,["candidateCount"],c);const d=i(e,["maxOutputTokens"]);d!=null&&r(o,["maxOutputTokens"],d);const f=i(e,["stopSequences"]);f!=null&&r(o,["stopSequences"],f);const p=i(e,["responseLogprobs"]);p!=null&&r(o,["responseLogprobs"],p);const h=i(e,["logprobs"]);h!=null&&r(o,["logprobs"],h);const g=i(e,["presencePenalty"]);g!=null&&r(o,["presencePenalty"],g);const y=i(e,["frequencyPenalty"]);y!=null&&r(o,["frequencyPenalty"],y);const C=i(e,["seed"]);C!=null&&r(o,["seed"],C);const T=i(e,["responseMimeType"]);T!=null&&r(o,["responseMimeType"],T);const E=i(e,["responseSchema"]);E!=null&&r(o,["responseSchema"],Ke(E));const _=i(e,["responseJsonSchema"]);_!=null&&r(o,["responseJsonSchema"],_);const v=i(e,["routingConfig"]);v!=null&&r(o,["routingConfig"],v);const S=i(e,["modelSelectionConfig"]);S!=null&&r(o,["modelConfig"],S);const x=i(e,["safetySettings"]);if(n!==void 0&&x!=null){let G=x;Array.isArray(G)&&(G=G.map(q=>q)),r(n,["safetySettings"],G)}const P=i(e,["tools"]);if(n!==void 0&&P!=null){let G=de(P);Array.isArray(G)&&(G=G.map(q=>Qn(ue(q)))),r(n,["tools"],G)}const M=i(e,["toolConfig"]);n!==void 0&&M!=null&&r(n,["toolConfig"],M);const b=i(e,["labels"]);n!==void 0&&b!=null&&r(n,["labels"],b);const A=i(e,["cachedContent"]);n!==void 0&&A!=null&&r(n,["cachedContent"],Z(t,A));const R=i(e,["responseModalities"]);R!=null&&r(o,["responseModalities"],R);const F=i(e,["mediaResolution"]);F!=null&&r(o,["mediaResolution"],F);const D=i(e,["speechConfig"]);D!=null&&r(o,["speechConfig"],ze(D));const U=i(e,["audioTimestamp"]);U!=null&&r(o,["audioTimestamp"],U);const V=i(e,["thinkingConfig"]);V!=null&&r(o,["thinkingConfig"],V);const N=i(e,["imageConfig"]);if(N!=null&&r(o,["imageConfig"],Kl(N)),i(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return o}function $n(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=W(s);Array.isArray(a)&&(a=a.map(u=>xe(u))),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&r(n,["generationConfig"],_l(t,l,n)),n}function Wn(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=W(s);Array.isArray(a)&&(a=a.map(u=>u)),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&r(n,["generationConfig"],El(t,l,n)),n}function Yn(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["candidates"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(d=>Br(d))),r(e,["candidates"],c)}const s=i(t,["modelVersion"]);s!=null&&r(e,["modelVersion"],s);const l=i(t,["promptFeedback"]);l!=null&&r(e,["promptFeedback"],l);const a=i(t,["responseId"]);a!=null&&r(e,["responseId"],a);const u=i(t,["usageMetadata"]);return u!=null&&r(e,["usageMetadata"],u),e}function Kn(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["candidates"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(f=>f)),r(e,["candidates"],d)}const s=i(t,["createTime"]);s!=null&&r(e,["createTime"],s);const l=i(t,["modelVersion"]);l!=null&&r(e,["modelVersion"],l);const a=i(t,["promptFeedback"]);a!=null&&r(e,["promptFeedback"],a);const u=i(t,["responseId"]);u!=null&&r(e,["responseId"],u);const c=i(t,["usageMetadata"]);return c!=null&&r(e,["usageMetadata"],c),e}function Cl(t,e){const n={};if(i(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(i(t,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const o=i(t,["numberOfImages"]);e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o);const s=i(t,["aspectRatio"]);e!==void 0&&s!=null&&r(e,["parameters","aspectRatio"],s);const l=i(t,["guidanceScale"]);if(e!==void 0&&l!=null&&r(e,["parameters","guidanceScale"],l),i(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const a=i(t,["safetyFilterLevel"]);e!==void 0&&a!=null&&r(e,["parameters","safetySetting"],a);const u=i(t,["personGeneration"]);e!==void 0&&u!=null&&r(e,["parameters","personGeneration"],u);const c=i(t,["includeSafetyAttributes"]);e!==void 0&&c!=null&&r(e,["parameters","includeSafetyAttributes"],c);const d=i(t,["includeRaiReason"]);e!==void 0&&d!=null&&r(e,["parameters","includeRaiReason"],d);const f=i(t,["language"]);e!==void 0&&f!=null&&r(e,["parameters","language"],f);const p=i(t,["outputMimeType"]);e!==void 0&&p!=null&&r(e,["parameters","outputOptions","mimeType"],p);const h=i(t,["outputCompressionQuality"]);if(e!==void 0&&h!=null&&r(e,["parameters","outputOptions","compressionQuality"],h),i(t,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(i(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const g=i(t,["imageSize"]);if(e!==void 0&&g!=null&&r(e,["parameters","sampleImageSize"],g),i(t,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function vl(t,e){const n={},o=i(t,["outputGcsUri"]);e!==void 0&&o!=null&&r(e,["parameters","storageUri"],o);const s=i(t,["negativePrompt"]);e!==void 0&&s!=null&&r(e,["parameters","negativePrompt"],s);const l=i(t,["numberOfImages"]);e!==void 0&&l!=null&&r(e,["parameters","sampleCount"],l);const a=i(t,["aspectRatio"]);e!==void 0&&a!=null&&r(e,["parameters","aspectRatio"],a);const u=i(t,["guidanceScale"]);e!==void 0&&u!=null&&r(e,["parameters","guidanceScale"],u);const c=i(t,["seed"]);e!==void 0&&c!=null&&r(e,["parameters","seed"],c);const d=i(t,["safetyFilterLevel"]);e!==void 0&&d!=null&&r(e,["parameters","safetySetting"],d);const f=i(t,["personGeneration"]);e!==void 0&&f!=null&&r(e,["parameters","personGeneration"],f);const p=i(t,["includeSafetyAttributes"]);e!==void 0&&p!=null&&r(e,["parameters","includeSafetyAttributes"],p);const h=i(t,["includeRaiReason"]);e!==void 0&&h!=null&&r(e,["parameters","includeRaiReason"],h);const g=i(t,["language"]);e!==void 0&&g!=null&&r(e,["parameters","language"],g);const y=i(t,["outputMimeType"]);e!==void 0&&y!=null&&r(e,["parameters","outputOptions","mimeType"],y);const C=i(t,["outputCompressionQuality"]);e!==void 0&&C!=null&&r(e,["parameters","outputOptions","compressionQuality"],C);const T=i(t,["addWatermark"]);e!==void 0&&T!=null&&r(e,["parameters","addWatermark"],T);const E=i(t,["labels"]);e!==void 0&&E!=null&&r(e,["labels"],E);const _=i(t,["imageSize"]);e!==void 0&&_!=null&&r(e,["parameters","sampleImageSize"],_);const v=i(t,["enhancePrompt"]);return e!==void 0&&v!=null&&r(e,["parameters","enhancePrompt"],v),n}function Sl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["config"]);return l!=null&&Cl(l,n),n}function Il(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["config"]);return l!=null&&vl(l,n),n}function Al(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>Fl(a))),r(e,["generatedImages"],l)}const s=i(t,["positivePromptSafetyAttributes"]);return s!=null&&r(e,["positivePromptSafetyAttributes"],On(s)),e}function xl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>we(a))),r(e,["generatedImages"],l)}const s=i(t,["positivePromptSafetyAttributes"]);return s!=null&&r(e,["positivePromptSafetyAttributes"],Xn(s)),e}function wl(t,e){const n={},o=i(t,["numberOfVideos"]);if(e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o),i(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(i(t,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const s=i(t,["durationSeconds"]);if(e!==void 0&&s!=null&&r(e,["parameters","durationSeconds"],s),i(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const l=i(t,["aspectRatio"]);e!==void 0&&l!=null&&r(e,["parameters","aspectRatio"],l);const a=i(t,["resolution"]);e!==void 0&&a!=null&&r(e,["parameters","resolution"],a);const u=i(t,["personGeneration"]);if(e!==void 0&&u!=null&&r(e,["parameters","personGeneration"],u),i(t,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const c=i(t,["negativePrompt"]);e!==void 0&&c!=null&&r(e,["parameters","negativePrompt"],c);const d=i(t,["enhancePrompt"]);if(e!==void 0&&d!=null&&r(e,["parameters","enhancePrompt"],d),i(t,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const f=i(t,["lastFrame"]);e!==void 0&&f!=null&&r(e,["instances[0]","lastFrame"],Ne(f));const p=i(t,["referenceImages"]);if(e!==void 0&&p!=null){let h=p;Array.isArray(h)&&(h=h.map(g=>Ma(g))),r(e,["instances[0]","referenceImages"],h)}if(i(t,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(i(t,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return n}function Nl(t,e){const n={},o=i(t,["numberOfVideos"]);e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o);const s=i(t,["outputGcsUri"]);e!==void 0&&s!=null&&r(e,["parameters","storageUri"],s);const l=i(t,["fps"]);e!==void 0&&l!=null&&r(e,["parameters","fps"],l);const a=i(t,["durationSeconds"]);e!==void 0&&a!=null&&r(e,["parameters","durationSeconds"],a);const u=i(t,["seed"]);e!==void 0&&u!=null&&r(e,["parameters","seed"],u);const c=i(t,["aspectRatio"]);e!==void 0&&c!=null&&r(e,["parameters","aspectRatio"],c);const d=i(t,["resolution"]);e!==void 0&&d!=null&&r(e,["parameters","resolution"],d);const f=i(t,["personGeneration"]);e!==void 0&&f!=null&&r(e,["parameters","personGeneration"],f);const p=i(t,["pubsubTopic"]);e!==void 0&&p!=null&&r(e,["parameters","pubsubTopic"],p);const h=i(t,["negativePrompt"]);e!==void 0&&h!=null&&r(e,["parameters","negativePrompt"],h);const g=i(t,["enhancePrompt"]);e!==void 0&&g!=null&&r(e,["parameters","enhancePrompt"],g);const y=i(t,["generateAudio"]);e!==void 0&&y!=null&&r(e,["parameters","generateAudio"],y);const C=i(t,["lastFrame"]);e!==void 0&&C!=null&&r(e,["instances[0]","lastFrame"],X(C));const T=i(t,["referenceImages"]);if(e!==void 0&&T!=null){let v=T;Array.isArray(v)&&(v=v.map(S=>Pa(S))),r(e,["instances[0]","referenceImages"],v)}const E=i(t,["mask"]);e!==void 0&&E!=null&&r(e,["instances[0]","mask"],Na(E));const _=i(t,["compressionQuality"]);return e!==void 0&&_!=null&&r(e,["parameters","compressionQuality"],_),n}function Ml(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["metadata"]);o!=null&&r(e,["metadata"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);l!=null&&r(e,["error"],l);const a=i(t,["response","generateVideoResponse"]);return a!=null&&r(e,["response"],Dl(a)),e}function Pl(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["metadata"]);o!=null&&r(e,["metadata"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);l!=null&&r(e,["error"],l);const a=i(t,["response"]);return a!=null&&r(e,["response"],bl(a)),e}function Rl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["image"]);l!=null&&r(n,["instances[0]","image"],Ne(l));const a=i(e,["video"]);a!=null&&r(n,["instances[0]","video"],Zn(a));const u=i(e,["source"]);u!=null&&Ul(u,n);const c=i(e,["config"]);return c!=null&&wl(c,n),n}function kl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["image"]);l!=null&&r(n,["instances[0]","image"],X(l));const a=i(e,["video"]);a!=null&&r(n,["instances[0]","video"],jn(a));const u=i(e,["source"]);u!=null&&Ll(u,n);const c=i(e,["config"]);return c!=null&&Nl(c,n),n}function Dl(t){const e={},n=i(t,["generatedSamples"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Vl(a))),r(e,["generatedVideos"],l)}const o=i(t,["raiMediaFilteredCount"]);o!=null&&r(e,["raiMediaFilteredCount"],o);const s=i(t,["raiMediaFilteredReasons"]);return s!=null&&r(e,["raiMediaFilteredReasons"],s),e}function bl(t){const e={},n=i(t,["videos"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>ql(a))),r(e,["generatedVideos"],l)}const o=i(t,["raiMediaFilteredCount"]);o!=null&&r(e,["raiMediaFilteredCount"],o);const s=i(t,["raiMediaFilteredReasons"]);return s!=null&&r(e,["raiMediaFilteredReasons"],s),e}function Ul(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["image"]);e!==void 0&&s!=null&&r(e,["instances[0]","image"],Ne(s));const l=i(t,["video"]);return e!==void 0&&l!=null&&r(e,["instances[0]","video"],Zn(l)),n}function Ll(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["image"]);e!==void 0&&s!=null&&r(e,["instances[0]","image"],X(s));const l=i(t,["video"]);return e!==void 0&&l!=null&&r(e,["instances[0]","video"],jn(l)),n}function Fl(t){const e={},n=i(t,["_self"]);n!=null&&r(e,["image"],zl(n));const o=i(t,["raiFilteredReason"]);o!=null&&r(e,["raiFilteredReason"],o);const s=i(t,["_self"]);return s!=null&&r(e,["safetyAttributes"],On(s)),e}function we(t){const e={},n=i(t,["_self"]);n!=null&&r(e,["image"],zn(n));const o=i(t,["raiFilteredReason"]);o!=null&&r(e,["raiFilteredReason"],o);const s=i(t,["_self"]);s!=null&&r(e,["safetyAttributes"],Xn(s));const l=i(t,["prompt"]);return l!=null&&r(e,["enhancedPrompt"],l),e}function Gl(t){const e={},n=i(t,["_self"]);n!=null&&r(e,["mask"],zn(n));const o=i(t,["labels"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>l)),r(e,["labels"],s)}return e}function Vl(t){const e={},n=i(t,["video"]);return n!=null&&r(e,["video"],xa(n)),e}function ql(t){const e={},n=i(t,["_self"]);return n!=null&&r(e,["video"],wa(n)),e}function Hl(t){const e={},n=i(t,["modelSelectionConfig"]);n!=null&&r(e,["modelConfig"],n);const o=i(t,["responseJsonSchema"]);o!=null&&r(e,["responseJsonSchema"],o);const s=i(t,["audioTimestamp"]);s!=null&&r(e,["audioTimestamp"],s);const l=i(t,["candidateCount"]);l!=null&&r(e,["candidateCount"],l);const a=i(t,["enableAffectiveDialog"]);a!=null&&r(e,["enableAffectiveDialog"],a);const u=i(t,["frequencyPenalty"]);u!=null&&r(e,["frequencyPenalty"],u);const c=i(t,["logprobs"]);c!=null&&r(e,["logprobs"],c);const d=i(t,["maxOutputTokens"]);d!=null&&r(e,["maxOutputTokens"],d);const f=i(t,["mediaResolution"]);f!=null&&r(e,["mediaResolution"],f);const p=i(t,["presencePenalty"]);p!=null&&r(e,["presencePenalty"],p);const h=i(t,["responseLogprobs"]);h!=null&&r(e,["responseLogprobs"],h);const g=i(t,["responseMimeType"]);g!=null&&r(e,["responseMimeType"],g);const y=i(t,["responseModalities"]);y!=null&&r(e,["responseModalities"],y);const C=i(t,["responseSchema"]);C!=null&&r(e,["responseSchema"],C);const T=i(t,["routingConfig"]);T!=null&&r(e,["routingConfig"],T);const E=i(t,["seed"]);E!=null&&r(e,["seed"],E);const _=i(t,["speechConfig"]);_!=null&&r(e,["speechConfig"],_);const v=i(t,["stopSequences"]);v!=null&&r(e,["stopSequences"],v);const S=i(t,["temperature"]);S!=null&&r(e,["temperature"],S);const x=i(t,["thinkingConfig"]);x!=null&&r(e,["thinkingConfig"],x);const P=i(t,["topK"]);P!=null&&r(e,["topK"],P);const M=i(t,["topP"]);if(M!=null&&r(e,["topP"],M),i(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return e}function Bl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function Jl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function $l(t){const e={};if(i(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=i(t,["enableWidget"]);return n!=null&&r(e,["enableWidget"],n),e}function Wl(t){const e={};if(i(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(i(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=i(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],n),e}function Yl(t){const e={},n=i(t,["aspectRatio"]);n!=null&&r(e,["aspectRatio"],n);const o=i(t,["imageSize"]);if(o!=null&&r(e,["imageSize"],o),i(t,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(i(t,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return e}function Kl(t){const e={},n=i(t,["aspectRatio"]);n!=null&&r(e,["aspectRatio"],n);const o=i(t,["imageSize"]);o!=null&&r(e,["imageSize"],o);const s=i(t,["outputMimeType"]);s!=null&&r(e,["imageOutputOptions","mimeType"],s);const l=i(t,["outputCompressionQuality"]);return l!=null&&r(e,["imageOutputOptions","compressionQuality"],l),e}function zl(t){const e={},n=i(t,["bytesBase64Encoded"]);n!=null&&r(e,["imageBytes"],ne(n));const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function zn(t){const e={},n=i(t,["gcsUri"]);n!=null&&r(e,["gcsUri"],n);const o=i(t,["bytesBase64Encoded"]);o!=null&&r(e,["imageBytes"],ne(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}function Ne(t){const e={};if(i(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=i(t,["imageBytes"]);n!=null&&r(e,["bytesBase64Encoded"],ne(n));const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function X(t){const e={},n=i(t,["gcsUri"]);n!=null&&r(e,["gcsUri"],n);const o=i(t,["imageBytes"]);o!=null&&r(e,["bytesBase64Encoded"],ne(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}function Ol(t,e,n){const o={},s=i(e,["pageSize"]);n!==void 0&&s!=null&&r(n,["_query","pageSize"],s);const l=i(e,["pageToken"]);n!==void 0&&l!=null&&r(n,["_query","pageToken"],l);const a=i(e,["filter"]);n!==void 0&&a!=null&&r(n,["_query","filter"],a);const u=i(e,["queryBase"]);return n!==void 0&&u!=null&&r(n,["_url","models_url"],Dn(t,u)),o}function Xl(t,e,n){const o={},s=i(e,["pageSize"]);n!==void 0&&s!=null&&r(n,["_query","pageSize"],s);const l=i(e,["pageToken"]);n!==void 0&&l!=null&&r(n,["_query","pageToken"],l);const a=i(e,["filter"]);n!==void 0&&a!=null&&r(n,["_query","filter"],a);const u=i(e,["queryBase"]);return n!==void 0&&u!=null&&r(n,["_url","models_url"],Dn(t,u)),o}function Ql(t,e){const n={},o=i(e,["config"]);return o!=null&&Ol(t,o,n),n}function Zl(t,e){const n={},o=i(e,["config"]);return o!=null&&Xl(t,o,n),n}function jl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["_self"]);if(s!=null){let l=bn(s);Array.isArray(l)&&(l=l.map(a=>Qe(a))),r(e,["models"],l)}return e}function ea(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["_self"]);if(s!=null){let l=bn(s);Array.isArray(l)&&(l=l.map(a=>Ze(a))),r(e,["models"],l)}return e}function ta(t){const e={},n=i(t,["maskMode"]);n!=null&&r(e,["maskMode"],n);const o=i(t,["segmentationClasses"]);o!=null&&r(e,["maskClasses"],o);const s=i(t,["maskDilation"]);return s!=null&&r(e,["dilation"],s),e}function Qe(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);s!=null&&r(e,["description"],s);const l=i(t,["version"]);l!=null&&r(e,["version"],l);const a=i(t,["_self"]);a!=null&&r(e,["tunedModelInfo"],ya(a));const u=i(t,["inputTokenLimit"]);u!=null&&r(e,["inputTokenLimit"],u);const c=i(t,["outputTokenLimit"]);c!=null&&r(e,["outputTokenLimit"],c);const d=i(t,["supportedGenerationMethods"]);d!=null&&r(e,["supportedActions"],d);const f=i(t,["temperature"]);f!=null&&r(e,["temperature"],f);const p=i(t,["maxTemperature"]);p!=null&&r(e,["maxTemperature"],p);const h=i(t,["topP"]);h!=null&&r(e,["topP"],h);const g=i(t,["topK"]);g!=null&&r(e,["topK"],g);const y=i(t,["thinking"]);return y!=null&&r(e,["thinking"],y),e}function Ze(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);s!=null&&r(e,["description"],s);const l=i(t,["versionId"]);l!=null&&r(e,["version"],l);const a=i(t,["deployedModels"]);if(a!=null){let p=a;Array.isArray(p)&&(p=p.map(h=>hl(h))),r(e,["endpoints"],p)}const u=i(t,["labels"]);u!=null&&r(e,["labels"],u);const c=i(t,["_self"]);c!=null&&r(e,["tunedModelInfo"],Ta(c));const d=i(t,["defaultCheckpointId"]);d!=null&&r(e,["defaultCheckpointId"],d);const f=i(t,["checkpoints"]);if(f!=null){let p=f;Array.isArray(p)&&(p=p.map(h=>h)),r(e,["checkpoints"],p)}return e}function na(t){const e={},n=i(t,["mediaResolution"]);n!=null&&r(e,["mediaResolution"],n);const o=i(t,["codeExecutionResult"]);o!=null&&r(e,["codeExecutionResult"],o);const s=i(t,["executableCode"]);s!=null&&r(e,["executableCode"],s);const l=i(t,["fileData"]);l!=null&&r(e,["fileData"],ml(l));const a=i(t,["functionCall"]);a!=null&&r(e,["functionCall"],gl(a));const u=i(t,["functionResponse"]);u!=null&&r(e,["functionResponse"],u);const c=i(t,["inlineData"]);c!=null&&r(e,["inlineData"],Hr(c));const d=i(t,["text"]);d!=null&&r(e,["text"],d);const f=i(t,["thought"]);f!=null&&r(e,["thought"],f);const p=i(t,["thoughtSignature"]);p!=null&&r(e,["thoughtSignature"],p);const h=i(t,["videoMetadata"]);return h!=null&&r(e,["videoMetadata"],h),e}function oa(t){const e={},n=i(t,["productImage"]);return n!=null&&r(e,["image"],X(n)),e}function ia(t,e){const n={},o=i(t,["numberOfImages"]);e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o);const s=i(t,["baseSteps"]);e!==void 0&&s!=null&&r(e,["parameters","baseSteps"],s);const l=i(t,["outputGcsUri"]);e!==void 0&&l!=null&&r(e,["parameters","storageUri"],l);const a=i(t,["seed"]);e!==void 0&&a!=null&&r(e,["parameters","seed"],a);const u=i(t,["safetyFilterLevel"]);e!==void 0&&u!=null&&r(e,["parameters","safetySetting"],u);const c=i(t,["personGeneration"]);e!==void 0&&c!=null&&r(e,["parameters","personGeneration"],c);const d=i(t,["addWatermark"]);e!==void 0&&d!=null&&r(e,["parameters","addWatermark"],d);const f=i(t,["outputMimeType"]);e!==void 0&&f!=null&&r(e,["parameters","outputOptions","mimeType"],f);const p=i(t,["outputCompressionQuality"]);e!==void 0&&p!=null&&r(e,["parameters","outputOptions","compressionQuality"],p);const h=i(t,["enhancePrompt"]);e!==void 0&&h!=null&&r(e,["parameters","enhancePrompt"],h);const g=i(t,["labels"]);return e!==void 0&&g!=null&&r(e,["labels"],g),n}function sa(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["source"]);s!=null&&la(s,n);const l=i(e,["config"]);return l!=null&&ia(l,n),n}function ra(t){const e={},n=i(t,["predictions"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>we(s))),r(e,["generatedImages"],o)}return e}function la(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["personImage"]);e!==void 0&&s!=null&&r(e,["instances[0]","personImage","image"],X(s));const l=i(t,["productImages"]);if(e!==void 0&&l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>oa(u))),r(e,["instances[0]","productImages"],a)}return n}function aa(t){const e={},n=i(t,["referenceImage"]);n!=null&&r(e,["referenceImage"],X(n));const o=i(t,["referenceId"]);o!=null&&r(e,["referenceId"],o);const s=i(t,["referenceType"]);s!=null&&r(e,["referenceType"],s);const l=i(t,["maskImageConfig"]);l!=null&&r(e,["maskImageConfig"],ta(l));const a=i(t,["controlImageConfig"]);a!=null&&r(e,["controlImageConfig"],zr(a));const u=i(t,["styleImageConfig"]);u!=null&&r(e,["styleImageConfig"],u);const c=i(t,["subjectImageConfig"]);return c!=null&&r(e,["subjectImageConfig"],c),e}function On(t){const e={},n=i(t,["safetyAttributes","categories"]);n!=null&&r(e,["categories"],n);const o=i(t,["safetyAttributes","scores"]);o!=null&&r(e,["scores"],o);const s=i(t,["contentType"]);return s!=null&&r(e,["contentType"],s),e}function Xn(t){const e={},n=i(t,["safetyAttributes","categories"]);n!=null&&r(e,["categories"],n);const o=i(t,["safetyAttributes","scores"]);o!=null&&r(e,["scores"],o);const s=i(t,["contentType"]);return s!=null&&r(e,["contentType"],s),e}function ua(t){const e={},n=i(t,["category"]);if(n!=null&&r(e,["category"],n),i(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=i(t,["threshold"]);return o!=null&&r(e,["threshold"],o),e}function da(t){const e={},n=i(t,["image"]);return n!=null&&r(e,["image"],X(n)),e}function ca(t,e){const n={},o=i(t,["mode"]);e!==void 0&&o!=null&&r(e,["parameters","mode"],o);const s=i(t,["maxPredictions"]);e!==void 0&&s!=null&&r(e,["parameters","maxPredictions"],s);const l=i(t,["confidenceThreshold"]);e!==void 0&&l!=null&&r(e,["parameters","confidenceThreshold"],l);const a=i(t,["maskDilation"]);e!==void 0&&a!=null&&r(e,["parameters","maskDilation"],a);const u=i(t,["binaryColorThreshold"]);e!==void 0&&u!=null&&r(e,["parameters","binaryColorThreshold"],u);const c=i(t,["labels"]);return e!==void 0&&c!=null&&r(e,["labels"],c),n}function fa(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["source"]);s!=null&&ha(s,n);const l=i(e,["config"]);return l!=null&&ca(l,n),n}function pa(t){const e={},n=i(t,["predictions"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>Gl(s))),r(e,["generatedMasks"],o)}return e}function ha(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["image"]);e!==void 0&&s!=null&&r(e,["instances[0]","image"],X(s));const l=i(t,["scribbleImage"]);return e!==void 0&&l!=null&&r(e,["instances[0]","scribble"],da(l)),n}function ma(t){const e={},n=i(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],yl(n));const o=i(t,["retrievalConfig"]);return o!=null&&r(e,["retrievalConfig"],o),e}function ga(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>p)),r(e,["functionDeclarations"],f)}if(i(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=i(t,["googleSearchRetrieval"]);o!=null&&r(e,["googleSearchRetrieval"],o);const s=i(t,["computerUse"]);s!=null&&r(e,["computerUse"],s);const l=i(t,["fileSearch"]);l!=null&&r(e,["fileSearch"],l);const a=i(t,["codeExecution"]);if(a!=null&&r(e,["codeExecution"],a),i(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=i(t,["googleMaps"]);u!=null&&r(e,["googleMaps"],$l(u));const c=i(t,["googleSearch"]);c!=null&&r(e,["googleSearch"],Wl(c));const d=i(t,["urlContext"]);return d!=null&&r(e,["urlContext"],d),e}function Qn(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(h=>Tl(h))),r(e,["functionDeclarations"],p)}const o=i(t,["retrieval"]);o!=null&&r(e,["retrieval"],o);const s=i(t,["googleSearchRetrieval"]);s!=null&&r(e,["googleSearchRetrieval"],s);const l=i(t,["computerUse"]);if(l!=null&&r(e,["computerUse"],l),i(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=i(t,["codeExecution"]);a!=null&&r(e,["codeExecution"],a);const u=i(t,["enterpriseWebSearch"]);u!=null&&r(e,["enterpriseWebSearch"],u);const c=i(t,["googleMaps"]);c!=null&&r(e,["googleMaps"],c);const d=i(t,["googleSearch"]);d!=null&&r(e,["googleSearch"],d);const f=i(t,["urlContext"]);return f!=null&&r(e,["urlContext"],f),e}function ya(t){const e={},n=i(t,["baseModel"]);n!=null&&r(e,["baseModel"],n);const o=i(t,["createTime"]);o!=null&&r(e,["createTime"],o);const s=i(t,["updateTime"]);return s!=null&&r(e,["updateTime"],s),e}function Ta(t){const e={},n=i(t,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&r(e,["baseModel"],n);const o=i(t,["createTime"]);o!=null&&r(e,["createTime"],o);const s=i(t,["updateTime"]);return s!=null&&r(e,["updateTime"],s),e}function _a(t,e){const n={},o=i(t,["displayName"]);e!==void 0&&o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);e!==void 0&&s!=null&&r(e,["description"],s);const l=i(t,["defaultCheckpointId"]);return e!==void 0&&l!=null&&r(e,["defaultCheckpointId"],l),n}function Ea(t,e){const n={},o=i(t,["displayName"]);e!==void 0&&o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);e!==void 0&&s!=null&&r(e,["description"],s);const l=i(t,["defaultCheckpointId"]);return e!==void 0&&l!=null&&r(e,["defaultCheckpointId"],l),n}function Ca(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","name"],L(t,o));const s=i(e,["config"]);return s!=null&&_a(s,n),n}function va(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["config"]);return s!=null&&Ea(s,n),n}function Sa(t,e){const n={},o=i(t,["outputGcsUri"]);e!==void 0&&o!=null&&r(e,["parameters","storageUri"],o);const s=i(t,["safetyFilterLevel"]);e!==void 0&&s!=null&&r(e,["parameters","safetySetting"],s);const l=i(t,["personGeneration"]);e!==void 0&&l!=null&&r(e,["parameters","personGeneration"],l);const a=i(t,["includeRaiReason"]);e!==void 0&&a!=null&&r(e,["parameters","includeRaiReason"],a);const u=i(t,["outputMimeType"]);e!==void 0&&u!=null&&r(e,["parameters","outputOptions","mimeType"],u);const c=i(t,["outputCompressionQuality"]);e!==void 0&&c!=null&&r(e,["parameters","outputOptions","compressionQuality"],c);const d=i(t,["enhanceInputImage"]);e!==void 0&&d!=null&&r(e,["parameters","upscaleConfig","enhanceInputImage"],d);const f=i(t,["imagePreservationFactor"]);e!==void 0&&f!=null&&r(e,["parameters","upscaleConfig","imagePreservationFactor"],f);const p=i(t,["labels"]);e!==void 0&&p!=null&&r(e,["labels"],p);const h=i(t,["numberOfImages"]);e!==void 0&&h!=null&&r(e,["parameters","sampleCount"],h);const g=i(t,["mode"]);return e!==void 0&&g!=null&&r(e,["parameters","mode"],g),n}function Ia(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["image"]);s!=null&&r(n,["instances[0]","image"],X(s));const l=i(e,["upscaleFactor"]);l!=null&&r(n,["parameters","upscaleConfig","upscaleFactor"],l);const a=i(e,["config"]);return a!=null&&Sa(a,n),n}function Aa(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>we(l))),r(e,["generatedImages"],s)}return e}function xa(t){const e={},n=i(t,["uri"]);n!=null&&r(e,["uri"],n);const o=i(t,["encodedVideo"]);o!=null&&r(e,["videoBytes"],ne(o));const s=i(t,["encoding"]);return s!=null&&r(e,["mimeType"],s),e}function wa(t){const e={},n=i(t,["gcsUri"]);n!=null&&r(e,["uri"],n);const o=i(t,["bytesBase64Encoded"]);o!=null&&r(e,["videoBytes"],ne(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}function Na(t){const e={},n=i(t,["image"]);n!=null&&r(e,["_self"],X(n));const o=i(t,["maskMode"]);return o!=null&&r(e,["maskMode"],o),e}function Ma(t){const e={},n=i(t,["image"]);n!=null&&r(e,["image"],Ne(n));const o=i(t,["referenceType"]);return o!=null&&r(e,["referenceType"],o),e}function Pa(t){const e={},n=i(t,["image"]);n!=null&&r(e,["image"],X(n));const o=i(t,["referenceType"]);return o!=null&&r(e,["referenceType"],o),e}function Zn(t){const e={},n=i(t,["uri"]);n!=null&&r(e,["uri"],n);const o=i(t,["videoBytes"]);o!=null&&r(e,["encodedVideo"],ne(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["encoding"],s),e}function jn(t){const e={},n=i(t,["uri"]);n!=null&&r(e,["gcsUri"],n);const o=i(t,["videoBytes"]);o!=null&&r(e,["bytesBase64Encoded"],ne(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}/**
69
+ */function Hr(t){const e={},n=i(t,["data"]);if(n!=null&&r(e,["data"],n),i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function Br(t){const e={},n=i(t,["content"]);n!=null&&r(e,["content"],n);const o=i(t,["citationMetadata"]);o!=null&&r(e,["citationMetadata"],Jr(o));const s=i(t,["tokenCount"]);s!=null&&r(e,["tokenCount"],s);const l=i(t,["finishReason"]);l!=null&&r(e,["finishReason"],l);const a=i(t,["avgLogprobs"]);a!=null&&r(e,["avgLogprobs"],a);const u=i(t,["groundingMetadata"]);u!=null&&r(e,["groundingMetadata"],u);const c=i(t,["index"]);c!=null&&r(e,["index"],c);const d=i(t,["logprobsResult"]);d!=null&&r(e,["logprobsResult"],d);const f=i(t,["safetyRatings"]);if(f!=null){let h=f;Array.isArray(h)&&(h=h.map(g=>g)),r(e,["safetyRatings"],h)}const p=i(t,["urlContextMetadata"]);return p!=null&&r(e,["urlContextMetadata"],p),e}function Jr(t){const e={},n=i(t,["citationSources"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>s)),r(e,["citations"],o)}return e}function $r(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let l=Y(s);Array.isArray(l)&&(l=l.map(a=>a)),r(n,["contents"],l)}return n}function Wr(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["tokensInfo"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>l)),r(e,["tokensInfo"],s)}return e}function Yr(t){const e={},n=i(t,["values"]);n!=null&&r(e,["values"],n);const o=i(t,["statistics"]);return o!=null&&r(e,["statistics"],Kr(o)),e}function Kr(t){const e={},n=i(t,["truncated"]);n!=null&&r(e,["truncated"],n);const o=i(t,["token_count"]);return o!=null&&r(e,["tokenCount"],o),e}function xe(t){const e={},n=i(t,["parts"]);if(n!=null){let s=n;Array.isArray(s)&&(s=s.map(l=>na(l))),r(e,["parts"],s)}const o=i(t,["role"]);return o!=null&&r(e,["role"],o),e}function zr(t){const e={},n=i(t,["controlType"]);n!=null&&r(e,["controlType"],n);const o=i(t,["enableControlImageComputation"]);return o!=null&&r(e,["computeControl"],o),e}function Or(t){const e={};if(i(t,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(i(t,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(i(t,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return e}function Xr(t,e){const n={},o=i(t,["systemInstruction"]);e!==void 0&&o!=null&&r(e,["systemInstruction"],B(o));const s=i(t,["tools"]);if(e!==void 0&&s!=null){let a=s;Array.isArray(a)&&(a=a.map(u=>Qn(u))),r(e,["tools"],a)}const l=i(t,["generationConfig"]);return e!==void 0&&l!=null&&r(e,["generationConfig"],Hl(l)),n}function Qr(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=Y(s);Array.isArray(a)&&(a=a.map(u=>xe(u))),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&Or(l),n}function Zr(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=Y(s);Array.isArray(a)&&(a=a.map(u=>u)),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&Xr(l,n),n}function jr(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["totalTokens"]);o!=null&&r(e,["totalTokens"],o);const s=i(t,["cachedContentTokenCount"]);return s!=null&&r(e,["cachedContentTokenCount"],s),e}function el(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["totalTokens"]);return o!=null&&r(e,["totalTokens"],o),e}function tl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function nl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function ol(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function il(t){const e={},n=i(t,["sdkHttpResponse"]);return n!=null&&r(e,["sdkHttpResponse"],n),e}function sl(t,e){const n={},o=i(t,["outputGcsUri"]);e!==void 0&&o!=null&&r(e,["parameters","storageUri"],o);const s=i(t,["negativePrompt"]);e!==void 0&&s!=null&&r(e,["parameters","negativePrompt"],s);const l=i(t,["numberOfImages"]);e!==void 0&&l!=null&&r(e,["parameters","sampleCount"],l);const a=i(t,["aspectRatio"]);e!==void 0&&a!=null&&r(e,["parameters","aspectRatio"],a);const u=i(t,["guidanceScale"]);e!==void 0&&u!=null&&r(e,["parameters","guidanceScale"],u);const c=i(t,["seed"]);e!==void 0&&c!=null&&r(e,["parameters","seed"],c);const d=i(t,["safetyFilterLevel"]);e!==void 0&&d!=null&&r(e,["parameters","safetySetting"],d);const f=i(t,["personGeneration"]);e!==void 0&&f!=null&&r(e,["parameters","personGeneration"],f);const p=i(t,["includeSafetyAttributes"]);e!==void 0&&p!=null&&r(e,["parameters","includeSafetyAttributes"],p);const h=i(t,["includeRaiReason"]);e!==void 0&&h!=null&&r(e,["parameters","includeRaiReason"],h);const g=i(t,["language"]);e!==void 0&&g!=null&&r(e,["parameters","language"],g);const y=i(t,["outputMimeType"]);e!==void 0&&y!=null&&r(e,["parameters","outputOptions","mimeType"],y);const C=i(t,["outputCompressionQuality"]);e!==void 0&&C!=null&&r(e,["parameters","outputOptions","compressionQuality"],C);const T=i(t,["addWatermark"]);e!==void 0&&T!=null&&r(e,["parameters","addWatermark"],T);const E=i(t,["labels"]);e!==void 0&&E!=null&&r(e,["labels"],E);const _=i(t,["editMode"]);e!==void 0&&_!=null&&r(e,["parameters","editMode"],_);const v=i(t,["baseSteps"]);return e!==void 0&&v!=null&&r(e,["parameters","editConfig","baseSteps"],v),n}function rl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["referenceImages"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(c=>aa(c))),r(n,["instances[0]","referenceImages"],u)}const a=i(e,["config"]);return a!=null&&sl(a,n),n}function ll(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>we(l))),r(e,["generatedImages"],s)}return e}function al(t,e){const n={},o=i(t,["taskType"]);e!==void 0&&o!=null&&r(e,["requests[]","taskType"],o);const s=i(t,["title"]);e!==void 0&&s!=null&&r(e,["requests[]","title"],s);const l=i(t,["outputDimensionality"]);if(e!==void 0&&l!=null&&r(e,["requests[]","outputDimensionality"],l),i(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(i(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function ul(t,e){const n={},o=i(t,["taskType"]);e!==void 0&&o!=null&&r(e,["instances[]","task_type"],o);const s=i(t,["title"]);e!==void 0&&s!=null&&r(e,["instances[]","title"],s);const l=i(t,["outputDimensionality"]);e!==void 0&&l!=null&&r(e,["parameters","outputDimensionality"],l);const a=i(t,["mimeType"]);e!==void 0&&a!=null&&r(e,["instances[]","mimeType"],a);const u=i(t,["autoTruncate"]);return e!==void 0&&u!=null&&r(e,["parameters","autoTruncate"],u),n}function dl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let u=Ye(t,s);Array.isArray(u)&&(u=u.map(c=>c)),r(n,["requests[]","content"],u)}const l=i(e,["config"]);l!=null&&al(l,n);const a=i(e,["model"]);return a!==void 0&&r(n,["requests[]","model"],L(t,a)),n}function cl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=Ye(t,s);Array.isArray(a)&&(a=a.map(u=>u)),r(n,["instances[]","content"],a)}const l=i(e,["config"]);return l!=null&&ul(l,n),n}function fl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["embeddings"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>a)),r(e,["embeddings"],l)}const s=i(t,["metadata"]);return s!=null&&r(e,["metadata"],s),e}function pl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions[]","embeddings"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>Yr(a))),r(e,["embeddings"],l)}const s=i(t,["metadata"]);return s!=null&&r(e,["metadata"],s),e}function hl(t){const e={},n=i(t,["endpoint"]);n!=null&&r(e,["name"],n);const o=i(t,["deployedModelId"]);return o!=null&&r(e,["deployedModelId"],o),e}function ml(t){const e={};if(i(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=i(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function gl(t){const e={},n=i(t,["id"]);n!=null&&r(e,["id"],n);const o=i(t,["args"]);o!=null&&r(e,["args"],o);const s=i(t,["name"]);if(s!=null&&r(e,["name"],s),i(t,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(i(t,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return e}function yl(t){const e={},n=i(t,["mode"]);n!=null&&r(e,["mode"],n);const o=i(t,["allowedFunctionNames"]);if(o!=null&&r(e,["allowedFunctionNames"],o),i(t,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return e}function Tl(t){const e={};if(i(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=i(t,["description"]);n!=null&&r(e,["description"],n);const o=i(t,["name"]);o!=null&&r(e,["name"],o);const s=i(t,["parameters"]);s!=null&&r(e,["parameters"],s);const l=i(t,["parametersJsonSchema"]);l!=null&&r(e,["parametersJsonSchema"],l);const a=i(t,["response"]);a!=null&&r(e,["response"],a);const u=i(t,["responseJsonSchema"]);return u!=null&&r(e,["responseJsonSchema"],u),e}function _l(t,e,n){const o={},s=i(e,["systemInstruction"]);n!==void 0&&s!=null&&r(n,["systemInstruction"],xe(B(s)));const l=i(e,["temperature"]);l!=null&&r(o,["temperature"],l);const a=i(e,["topP"]);a!=null&&r(o,["topP"],a);const u=i(e,["topK"]);u!=null&&r(o,["topK"],u);const c=i(e,["candidateCount"]);c!=null&&r(o,["candidateCount"],c);const d=i(e,["maxOutputTokens"]);d!=null&&r(o,["maxOutputTokens"],d);const f=i(e,["stopSequences"]);f!=null&&r(o,["stopSequences"],f);const p=i(e,["responseLogprobs"]);p!=null&&r(o,["responseLogprobs"],p);const h=i(e,["logprobs"]);h!=null&&r(o,["logprobs"],h);const g=i(e,["presencePenalty"]);g!=null&&r(o,["presencePenalty"],g);const y=i(e,["frequencyPenalty"]);y!=null&&r(o,["frequencyPenalty"],y);const C=i(e,["seed"]);C!=null&&r(o,["seed"],C);const T=i(e,["responseMimeType"]);T!=null&&r(o,["responseMimeType"],T);const E=i(e,["responseSchema"]);E!=null&&r(o,["responseSchema"],Ke(E));const _=i(e,["responseJsonSchema"]);if(_!=null&&r(o,["responseJsonSchema"],_),i(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(i(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const v=i(e,["safetySettings"]);if(n!==void 0&&v!=null){let U=v;Array.isArray(U)&&(U=U.map(V=>ua(V))),r(n,["safetySettings"],U)}const S=i(e,["tools"]);if(n!==void 0&&S!=null){let U=de(S);Array.isArray(U)&&(U=U.map(V=>ga(ue(V)))),r(n,["tools"],U)}const x=i(e,["toolConfig"]);if(n!==void 0&&x!=null&&r(n,["toolConfig"],ma(x)),i(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const P=i(e,["cachedContent"]);n!==void 0&&P!=null&&r(n,["cachedContent"],j(t,P));const M=i(e,["responseModalities"]);M!=null&&r(o,["responseModalities"],M);const b=i(e,["mediaResolution"]);b!=null&&r(o,["mediaResolution"],b);const A=i(e,["speechConfig"]);if(A!=null&&r(o,["speechConfig"],ze(A)),i(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const R=i(e,["thinkingConfig"]);R!=null&&r(o,["thinkingConfig"],R);const F=i(e,["imageConfig"]);F!=null&&r(o,["imageConfig"],Yl(F));const D=i(e,["enableEnhancedCivicAnswers"]);return D!=null&&r(o,["enableEnhancedCivicAnswers"],D),o}function El(t,e,n){const o={},s=i(e,["systemInstruction"]);n!==void 0&&s!=null&&r(n,["systemInstruction"],B(s));const l=i(e,["temperature"]);l!=null&&r(o,["temperature"],l);const a=i(e,["topP"]);a!=null&&r(o,["topP"],a);const u=i(e,["topK"]);u!=null&&r(o,["topK"],u);const c=i(e,["candidateCount"]);c!=null&&r(o,["candidateCount"],c);const d=i(e,["maxOutputTokens"]);d!=null&&r(o,["maxOutputTokens"],d);const f=i(e,["stopSequences"]);f!=null&&r(o,["stopSequences"],f);const p=i(e,["responseLogprobs"]);p!=null&&r(o,["responseLogprobs"],p);const h=i(e,["logprobs"]);h!=null&&r(o,["logprobs"],h);const g=i(e,["presencePenalty"]);g!=null&&r(o,["presencePenalty"],g);const y=i(e,["frequencyPenalty"]);y!=null&&r(o,["frequencyPenalty"],y);const C=i(e,["seed"]);C!=null&&r(o,["seed"],C);const T=i(e,["responseMimeType"]);T!=null&&r(o,["responseMimeType"],T);const E=i(e,["responseSchema"]);E!=null&&r(o,["responseSchema"],Ke(E));const _=i(e,["responseJsonSchema"]);_!=null&&r(o,["responseJsonSchema"],_);const v=i(e,["routingConfig"]);v!=null&&r(o,["routingConfig"],v);const S=i(e,["modelSelectionConfig"]);S!=null&&r(o,["modelConfig"],S);const x=i(e,["safetySettings"]);if(n!==void 0&&x!=null){let G=x;Array.isArray(G)&&(G=G.map(q=>q)),r(n,["safetySettings"],G)}const P=i(e,["tools"]);if(n!==void 0&&P!=null){let G=de(P);Array.isArray(G)&&(G=G.map(q=>Qn(ue(q)))),r(n,["tools"],G)}const M=i(e,["toolConfig"]);n!==void 0&&M!=null&&r(n,["toolConfig"],M);const b=i(e,["labels"]);n!==void 0&&b!=null&&r(n,["labels"],b);const A=i(e,["cachedContent"]);n!==void 0&&A!=null&&r(n,["cachedContent"],j(t,A));const R=i(e,["responseModalities"]);R!=null&&r(o,["responseModalities"],R);const F=i(e,["mediaResolution"]);F!=null&&r(o,["mediaResolution"],F);const D=i(e,["speechConfig"]);D!=null&&r(o,["speechConfig"],ze(D));const U=i(e,["audioTimestamp"]);U!=null&&r(o,["audioTimestamp"],U);const V=i(e,["thinkingConfig"]);V!=null&&r(o,["thinkingConfig"],V);const N=i(e,["imageConfig"]);if(N!=null&&r(o,["imageConfig"],Kl(N)),i(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return o}function $n(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=Y(s);Array.isArray(a)&&(a=a.map(u=>xe(u))),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&r(n,["generationConfig"],_l(t,l,n)),n}function Wn(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["contents"]);if(s!=null){let a=Y(s);Array.isArray(a)&&(a=a.map(u=>u)),r(n,["contents"],a)}const l=i(e,["config"]);return l!=null&&r(n,["generationConfig"],El(t,l,n)),n}function Yn(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["candidates"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(d=>Br(d))),r(e,["candidates"],c)}const s=i(t,["modelVersion"]);s!=null&&r(e,["modelVersion"],s);const l=i(t,["promptFeedback"]);l!=null&&r(e,["promptFeedback"],l);const a=i(t,["responseId"]);a!=null&&r(e,["responseId"],a);const u=i(t,["usageMetadata"]);return u!=null&&r(e,["usageMetadata"],u),e}function Kn(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["candidates"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(f=>f)),r(e,["candidates"],d)}const s=i(t,["createTime"]);s!=null&&r(e,["createTime"],s);const l=i(t,["modelVersion"]);l!=null&&r(e,["modelVersion"],l);const a=i(t,["promptFeedback"]);a!=null&&r(e,["promptFeedback"],a);const u=i(t,["responseId"]);u!=null&&r(e,["responseId"],u);const c=i(t,["usageMetadata"]);return c!=null&&r(e,["usageMetadata"],c),e}function Cl(t,e){const n={};if(i(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(i(t,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const o=i(t,["numberOfImages"]);e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o);const s=i(t,["aspectRatio"]);e!==void 0&&s!=null&&r(e,["parameters","aspectRatio"],s);const l=i(t,["guidanceScale"]);if(e!==void 0&&l!=null&&r(e,["parameters","guidanceScale"],l),i(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const a=i(t,["safetyFilterLevel"]);e!==void 0&&a!=null&&r(e,["parameters","safetySetting"],a);const u=i(t,["personGeneration"]);e!==void 0&&u!=null&&r(e,["parameters","personGeneration"],u);const c=i(t,["includeSafetyAttributes"]);e!==void 0&&c!=null&&r(e,["parameters","includeSafetyAttributes"],c);const d=i(t,["includeRaiReason"]);e!==void 0&&d!=null&&r(e,["parameters","includeRaiReason"],d);const f=i(t,["language"]);e!==void 0&&f!=null&&r(e,["parameters","language"],f);const p=i(t,["outputMimeType"]);e!==void 0&&p!=null&&r(e,["parameters","outputOptions","mimeType"],p);const h=i(t,["outputCompressionQuality"]);if(e!==void 0&&h!=null&&r(e,["parameters","outputOptions","compressionQuality"],h),i(t,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(i(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const g=i(t,["imageSize"]);if(e!==void 0&&g!=null&&r(e,["parameters","sampleImageSize"],g),i(t,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function vl(t,e){const n={},o=i(t,["outputGcsUri"]);e!==void 0&&o!=null&&r(e,["parameters","storageUri"],o);const s=i(t,["negativePrompt"]);e!==void 0&&s!=null&&r(e,["parameters","negativePrompt"],s);const l=i(t,["numberOfImages"]);e!==void 0&&l!=null&&r(e,["parameters","sampleCount"],l);const a=i(t,["aspectRatio"]);e!==void 0&&a!=null&&r(e,["parameters","aspectRatio"],a);const u=i(t,["guidanceScale"]);e!==void 0&&u!=null&&r(e,["parameters","guidanceScale"],u);const c=i(t,["seed"]);e!==void 0&&c!=null&&r(e,["parameters","seed"],c);const d=i(t,["safetyFilterLevel"]);e!==void 0&&d!=null&&r(e,["parameters","safetySetting"],d);const f=i(t,["personGeneration"]);e!==void 0&&f!=null&&r(e,["parameters","personGeneration"],f);const p=i(t,["includeSafetyAttributes"]);e!==void 0&&p!=null&&r(e,["parameters","includeSafetyAttributes"],p);const h=i(t,["includeRaiReason"]);e!==void 0&&h!=null&&r(e,["parameters","includeRaiReason"],h);const g=i(t,["language"]);e!==void 0&&g!=null&&r(e,["parameters","language"],g);const y=i(t,["outputMimeType"]);e!==void 0&&y!=null&&r(e,["parameters","outputOptions","mimeType"],y);const C=i(t,["outputCompressionQuality"]);e!==void 0&&C!=null&&r(e,["parameters","outputOptions","compressionQuality"],C);const T=i(t,["addWatermark"]);e!==void 0&&T!=null&&r(e,["parameters","addWatermark"],T);const E=i(t,["labels"]);e!==void 0&&E!=null&&r(e,["labels"],E);const _=i(t,["imageSize"]);e!==void 0&&_!=null&&r(e,["parameters","sampleImageSize"],_);const v=i(t,["enhancePrompt"]);return e!==void 0&&v!=null&&r(e,["parameters","enhancePrompt"],v),n}function Sl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["config"]);return l!=null&&Cl(l,n),n}function Il(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["config"]);return l!=null&&vl(l,n),n}function Al(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>Fl(a))),r(e,["generatedImages"],l)}const s=i(t,["positivePromptSafetyAttributes"]);return s!=null&&r(e,["positivePromptSafetyAttributes"],On(s)),e}function xl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>we(a))),r(e,["generatedImages"],l)}const s=i(t,["positivePromptSafetyAttributes"]);return s!=null&&r(e,["positivePromptSafetyAttributes"],Xn(s)),e}function wl(t,e){const n={},o=i(t,["numberOfVideos"]);if(e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o),i(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(i(t,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const s=i(t,["durationSeconds"]);if(e!==void 0&&s!=null&&r(e,["parameters","durationSeconds"],s),i(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const l=i(t,["aspectRatio"]);e!==void 0&&l!=null&&r(e,["parameters","aspectRatio"],l);const a=i(t,["resolution"]);e!==void 0&&a!=null&&r(e,["parameters","resolution"],a);const u=i(t,["personGeneration"]);if(e!==void 0&&u!=null&&r(e,["parameters","personGeneration"],u),i(t,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const c=i(t,["negativePrompt"]);e!==void 0&&c!=null&&r(e,["parameters","negativePrompt"],c);const d=i(t,["enhancePrompt"]);if(e!==void 0&&d!=null&&r(e,["parameters","enhancePrompt"],d),i(t,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const f=i(t,["lastFrame"]);e!==void 0&&f!=null&&r(e,["instances[0]","lastFrame"],Ne(f));const p=i(t,["referenceImages"]);if(e!==void 0&&p!=null){let h=p;Array.isArray(h)&&(h=h.map(g=>Ma(g))),r(e,["instances[0]","referenceImages"],h)}if(i(t,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(i(t,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return n}function Nl(t,e){const n={},o=i(t,["numberOfVideos"]);e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o);const s=i(t,["outputGcsUri"]);e!==void 0&&s!=null&&r(e,["parameters","storageUri"],s);const l=i(t,["fps"]);e!==void 0&&l!=null&&r(e,["parameters","fps"],l);const a=i(t,["durationSeconds"]);e!==void 0&&a!=null&&r(e,["parameters","durationSeconds"],a);const u=i(t,["seed"]);e!==void 0&&u!=null&&r(e,["parameters","seed"],u);const c=i(t,["aspectRatio"]);e!==void 0&&c!=null&&r(e,["parameters","aspectRatio"],c);const d=i(t,["resolution"]);e!==void 0&&d!=null&&r(e,["parameters","resolution"],d);const f=i(t,["personGeneration"]);e!==void 0&&f!=null&&r(e,["parameters","personGeneration"],f);const p=i(t,["pubsubTopic"]);e!==void 0&&p!=null&&r(e,["parameters","pubsubTopic"],p);const h=i(t,["negativePrompt"]);e!==void 0&&h!=null&&r(e,["parameters","negativePrompt"],h);const g=i(t,["enhancePrompt"]);e!==void 0&&g!=null&&r(e,["parameters","enhancePrompt"],g);const y=i(t,["generateAudio"]);e!==void 0&&y!=null&&r(e,["parameters","generateAudio"],y);const C=i(t,["lastFrame"]);e!==void 0&&C!=null&&r(e,["instances[0]","lastFrame"],Q(C));const T=i(t,["referenceImages"]);if(e!==void 0&&T!=null){let v=T;Array.isArray(v)&&(v=v.map(S=>Pa(S))),r(e,["instances[0]","referenceImages"],v)}const E=i(t,["mask"]);e!==void 0&&E!=null&&r(e,["instances[0]","mask"],Na(E));const _=i(t,["compressionQuality"]);return e!==void 0&&_!=null&&r(e,["parameters","compressionQuality"],_),n}function Ml(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["metadata"]);o!=null&&r(e,["metadata"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);l!=null&&r(e,["error"],l);const a=i(t,["response","generateVideoResponse"]);return a!=null&&r(e,["response"],Dl(a)),e}function Pl(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["metadata"]);o!=null&&r(e,["metadata"],o);const s=i(t,["done"]);s!=null&&r(e,["done"],s);const l=i(t,["error"]);l!=null&&r(e,["error"],l);const a=i(t,["response"]);return a!=null&&r(e,["response"],bl(a)),e}function Rl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["image"]);l!=null&&r(n,["instances[0]","image"],Ne(l));const a=i(e,["video"]);a!=null&&r(n,["instances[0]","video"],Zn(a));const u=i(e,["source"]);u!=null&&Ul(u,n);const c=i(e,["config"]);return c!=null&&wl(c,n),n}function kl(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["prompt"]);s!=null&&r(n,["instances[0]","prompt"],s);const l=i(e,["image"]);l!=null&&r(n,["instances[0]","image"],Q(l));const a=i(e,["video"]);a!=null&&r(n,["instances[0]","video"],jn(a));const u=i(e,["source"]);u!=null&&Ll(u,n);const c=i(e,["config"]);return c!=null&&Nl(c,n),n}function Dl(t){const e={},n=i(t,["generatedSamples"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Vl(a))),r(e,["generatedVideos"],l)}const o=i(t,["raiMediaFilteredCount"]);o!=null&&r(e,["raiMediaFilteredCount"],o);const s=i(t,["raiMediaFilteredReasons"]);return s!=null&&r(e,["raiMediaFilteredReasons"],s),e}function bl(t){const e={},n=i(t,["videos"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>ql(a))),r(e,["generatedVideos"],l)}const o=i(t,["raiMediaFilteredCount"]);o!=null&&r(e,["raiMediaFilteredCount"],o);const s=i(t,["raiMediaFilteredReasons"]);return s!=null&&r(e,["raiMediaFilteredReasons"],s),e}function Ul(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["image"]);e!==void 0&&s!=null&&r(e,["instances[0]","image"],Ne(s));const l=i(t,["video"]);return e!==void 0&&l!=null&&r(e,["instances[0]","video"],Zn(l)),n}function Ll(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["image"]);e!==void 0&&s!=null&&r(e,["instances[0]","image"],Q(s));const l=i(t,["video"]);return e!==void 0&&l!=null&&r(e,["instances[0]","video"],jn(l)),n}function Fl(t){const e={},n=i(t,["_self"]);n!=null&&r(e,["image"],zl(n));const o=i(t,["raiFilteredReason"]);o!=null&&r(e,["raiFilteredReason"],o);const s=i(t,["_self"]);return s!=null&&r(e,["safetyAttributes"],On(s)),e}function we(t){const e={},n=i(t,["_self"]);n!=null&&r(e,["image"],zn(n));const o=i(t,["raiFilteredReason"]);o!=null&&r(e,["raiFilteredReason"],o);const s=i(t,["_self"]);s!=null&&r(e,["safetyAttributes"],Xn(s));const l=i(t,["prompt"]);return l!=null&&r(e,["enhancedPrompt"],l),e}function Gl(t){const e={},n=i(t,["_self"]);n!=null&&r(e,["mask"],zn(n));const o=i(t,["labels"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>l)),r(e,["labels"],s)}return e}function Vl(t){const e={},n=i(t,["video"]);return n!=null&&r(e,["video"],xa(n)),e}function ql(t){const e={},n=i(t,["_self"]);return n!=null&&r(e,["video"],wa(n)),e}function Hl(t){const e={},n=i(t,["modelSelectionConfig"]);n!=null&&r(e,["modelConfig"],n);const o=i(t,["responseJsonSchema"]);o!=null&&r(e,["responseJsonSchema"],o);const s=i(t,["audioTimestamp"]);s!=null&&r(e,["audioTimestamp"],s);const l=i(t,["candidateCount"]);l!=null&&r(e,["candidateCount"],l);const a=i(t,["enableAffectiveDialog"]);a!=null&&r(e,["enableAffectiveDialog"],a);const u=i(t,["frequencyPenalty"]);u!=null&&r(e,["frequencyPenalty"],u);const c=i(t,["logprobs"]);c!=null&&r(e,["logprobs"],c);const d=i(t,["maxOutputTokens"]);d!=null&&r(e,["maxOutputTokens"],d);const f=i(t,["mediaResolution"]);f!=null&&r(e,["mediaResolution"],f);const p=i(t,["presencePenalty"]);p!=null&&r(e,["presencePenalty"],p);const h=i(t,["responseLogprobs"]);h!=null&&r(e,["responseLogprobs"],h);const g=i(t,["responseMimeType"]);g!=null&&r(e,["responseMimeType"],g);const y=i(t,["responseModalities"]);y!=null&&r(e,["responseModalities"],y);const C=i(t,["responseSchema"]);C!=null&&r(e,["responseSchema"],C);const T=i(t,["routingConfig"]);T!=null&&r(e,["routingConfig"],T);const E=i(t,["seed"]);E!=null&&r(e,["seed"],E);const _=i(t,["speechConfig"]);_!=null&&r(e,["speechConfig"],_);const v=i(t,["stopSequences"]);v!=null&&r(e,["stopSequences"],v);const S=i(t,["temperature"]);S!=null&&r(e,["temperature"],S);const x=i(t,["thinkingConfig"]);x!=null&&r(e,["thinkingConfig"],x);const P=i(t,["topK"]);P!=null&&r(e,["topK"],P);const M=i(t,["topP"]);if(M!=null&&r(e,["topP"],M),i(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return e}function Bl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function Jl(t,e){const n={},o=i(e,["model"]);return o!=null&&r(n,["_url","name"],L(t,o)),n}function $l(t){const e={};if(i(t,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=i(t,["enableWidget"]);return n!=null&&r(e,["enableWidget"],n),e}function Wl(t){const e={};if(i(t,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(i(t,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=i(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],n),e}function Yl(t){const e={},n=i(t,["aspectRatio"]);n!=null&&r(e,["aspectRatio"],n);const o=i(t,["imageSize"]);if(o!=null&&r(e,["imageSize"],o),i(t,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(i(t,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return e}function Kl(t){const e={},n=i(t,["aspectRatio"]);n!=null&&r(e,["aspectRatio"],n);const o=i(t,["imageSize"]);o!=null&&r(e,["imageSize"],o);const s=i(t,["outputMimeType"]);s!=null&&r(e,["imageOutputOptions","mimeType"],s);const l=i(t,["outputCompressionQuality"]);return l!=null&&r(e,["imageOutputOptions","compressionQuality"],l),e}function zl(t){const e={},n=i(t,["bytesBase64Encoded"]);n!=null&&r(e,["imageBytes"],oe(n));const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function zn(t){const e={},n=i(t,["gcsUri"]);n!=null&&r(e,["gcsUri"],n);const o=i(t,["bytesBase64Encoded"]);o!=null&&r(e,["imageBytes"],oe(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}function Ne(t){const e={};if(i(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=i(t,["imageBytes"]);n!=null&&r(e,["bytesBase64Encoded"],oe(n));const o=i(t,["mimeType"]);return o!=null&&r(e,["mimeType"],o),e}function Q(t){const e={},n=i(t,["gcsUri"]);n!=null&&r(e,["gcsUri"],n);const o=i(t,["imageBytes"]);o!=null&&r(e,["bytesBase64Encoded"],oe(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}function Ol(t,e,n){const o={},s=i(e,["pageSize"]);n!==void 0&&s!=null&&r(n,["_query","pageSize"],s);const l=i(e,["pageToken"]);n!==void 0&&l!=null&&r(n,["_query","pageToken"],l);const a=i(e,["filter"]);n!==void 0&&a!=null&&r(n,["_query","filter"],a);const u=i(e,["queryBase"]);return n!==void 0&&u!=null&&r(n,["_url","models_url"],Dn(t,u)),o}function Xl(t,e,n){const o={},s=i(e,["pageSize"]);n!==void 0&&s!=null&&r(n,["_query","pageSize"],s);const l=i(e,["pageToken"]);n!==void 0&&l!=null&&r(n,["_query","pageToken"],l);const a=i(e,["filter"]);n!==void 0&&a!=null&&r(n,["_query","filter"],a);const u=i(e,["queryBase"]);return n!==void 0&&u!=null&&r(n,["_url","models_url"],Dn(t,u)),o}function Ql(t,e){const n={},o=i(e,["config"]);return o!=null&&Ol(t,o,n),n}function Zl(t,e){const n={},o=i(e,["config"]);return o!=null&&Xl(t,o,n),n}function jl(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["_self"]);if(s!=null){let l=bn(s);Array.isArray(l)&&(l=l.map(a=>Qe(a))),r(e,["models"],l)}return e}function ea(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["nextPageToken"]);o!=null&&r(e,["nextPageToken"],o);const s=i(t,["_self"]);if(s!=null){let l=bn(s);Array.isArray(l)&&(l=l.map(a=>Ze(a))),r(e,["models"],l)}return e}function ta(t){const e={},n=i(t,["maskMode"]);n!=null&&r(e,["maskMode"],n);const o=i(t,["segmentationClasses"]);o!=null&&r(e,["maskClasses"],o);const s=i(t,["maskDilation"]);return s!=null&&r(e,["dilation"],s),e}function Qe(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);s!=null&&r(e,["description"],s);const l=i(t,["version"]);l!=null&&r(e,["version"],l);const a=i(t,["_self"]);a!=null&&r(e,["tunedModelInfo"],ya(a));const u=i(t,["inputTokenLimit"]);u!=null&&r(e,["inputTokenLimit"],u);const c=i(t,["outputTokenLimit"]);c!=null&&r(e,["outputTokenLimit"],c);const d=i(t,["supportedGenerationMethods"]);d!=null&&r(e,["supportedActions"],d);const f=i(t,["temperature"]);f!=null&&r(e,["temperature"],f);const p=i(t,["maxTemperature"]);p!=null&&r(e,["maxTemperature"],p);const h=i(t,["topP"]);h!=null&&r(e,["topP"],h);const g=i(t,["topK"]);g!=null&&r(e,["topK"],g);const y=i(t,["thinking"]);return y!=null&&r(e,["thinking"],y),e}function Ze(t){const e={},n=i(t,["name"]);n!=null&&r(e,["name"],n);const o=i(t,["displayName"]);o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);s!=null&&r(e,["description"],s);const l=i(t,["versionId"]);l!=null&&r(e,["version"],l);const a=i(t,["deployedModels"]);if(a!=null){let p=a;Array.isArray(p)&&(p=p.map(h=>hl(h))),r(e,["endpoints"],p)}const u=i(t,["labels"]);u!=null&&r(e,["labels"],u);const c=i(t,["_self"]);c!=null&&r(e,["tunedModelInfo"],Ta(c));const d=i(t,["defaultCheckpointId"]);d!=null&&r(e,["defaultCheckpointId"],d);const f=i(t,["checkpoints"]);if(f!=null){let p=f;Array.isArray(p)&&(p=p.map(h=>h)),r(e,["checkpoints"],p)}return e}function na(t){const e={},n=i(t,["mediaResolution"]);n!=null&&r(e,["mediaResolution"],n);const o=i(t,["codeExecutionResult"]);o!=null&&r(e,["codeExecutionResult"],o);const s=i(t,["executableCode"]);s!=null&&r(e,["executableCode"],s);const l=i(t,["fileData"]);l!=null&&r(e,["fileData"],ml(l));const a=i(t,["functionCall"]);a!=null&&r(e,["functionCall"],gl(a));const u=i(t,["functionResponse"]);u!=null&&r(e,["functionResponse"],u);const c=i(t,["inlineData"]);c!=null&&r(e,["inlineData"],Hr(c));const d=i(t,["text"]);d!=null&&r(e,["text"],d);const f=i(t,["thought"]);f!=null&&r(e,["thought"],f);const p=i(t,["thoughtSignature"]);p!=null&&r(e,["thoughtSignature"],p);const h=i(t,["videoMetadata"]);return h!=null&&r(e,["videoMetadata"],h),e}function oa(t){const e={},n=i(t,["productImage"]);return n!=null&&r(e,["image"],Q(n)),e}function ia(t,e){const n={},o=i(t,["numberOfImages"]);e!==void 0&&o!=null&&r(e,["parameters","sampleCount"],o);const s=i(t,["baseSteps"]);e!==void 0&&s!=null&&r(e,["parameters","baseSteps"],s);const l=i(t,["outputGcsUri"]);e!==void 0&&l!=null&&r(e,["parameters","storageUri"],l);const a=i(t,["seed"]);e!==void 0&&a!=null&&r(e,["parameters","seed"],a);const u=i(t,["safetyFilterLevel"]);e!==void 0&&u!=null&&r(e,["parameters","safetySetting"],u);const c=i(t,["personGeneration"]);e!==void 0&&c!=null&&r(e,["parameters","personGeneration"],c);const d=i(t,["addWatermark"]);e!==void 0&&d!=null&&r(e,["parameters","addWatermark"],d);const f=i(t,["outputMimeType"]);e!==void 0&&f!=null&&r(e,["parameters","outputOptions","mimeType"],f);const p=i(t,["outputCompressionQuality"]);e!==void 0&&p!=null&&r(e,["parameters","outputOptions","compressionQuality"],p);const h=i(t,["enhancePrompt"]);e!==void 0&&h!=null&&r(e,["parameters","enhancePrompt"],h);const g=i(t,["labels"]);return e!==void 0&&g!=null&&r(e,["labels"],g),n}function sa(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["source"]);s!=null&&la(s,n);const l=i(e,["config"]);return l!=null&&ia(l,n),n}function ra(t){const e={},n=i(t,["predictions"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>we(s))),r(e,["generatedImages"],o)}return e}function la(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["personImage"]);e!==void 0&&s!=null&&r(e,["instances[0]","personImage","image"],Q(s));const l=i(t,["productImages"]);if(e!==void 0&&l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>oa(u))),r(e,["instances[0]","productImages"],a)}return n}function aa(t){const e={},n=i(t,["referenceImage"]);n!=null&&r(e,["referenceImage"],Q(n));const o=i(t,["referenceId"]);o!=null&&r(e,["referenceId"],o);const s=i(t,["referenceType"]);s!=null&&r(e,["referenceType"],s);const l=i(t,["maskImageConfig"]);l!=null&&r(e,["maskImageConfig"],ta(l));const a=i(t,["controlImageConfig"]);a!=null&&r(e,["controlImageConfig"],zr(a));const u=i(t,["styleImageConfig"]);u!=null&&r(e,["styleImageConfig"],u);const c=i(t,["subjectImageConfig"]);return c!=null&&r(e,["subjectImageConfig"],c),e}function On(t){const e={},n=i(t,["safetyAttributes","categories"]);n!=null&&r(e,["categories"],n);const o=i(t,["safetyAttributes","scores"]);o!=null&&r(e,["scores"],o);const s=i(t,["contentType"]);return s!=null&&r(e,["contentType"],s),e}function Xn(t){const e={},n=i(t,["safetyAttributes","categories"]);n!=null&&r(e,["categories"],n);const o=i(t,["safetyAttributes","scores"]);o!=null&&r(e,["scores"],o);const s=i(t,["contentType"]);return s!=null&&r(e,["contentType"],s),e}function ua(t){const e={},n=i(t,["category"]);if(n!=null&&r(e,["category"],n),i(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=i(t,["threshold"]);return o!=null&&r(e,["threshold"],o),e}function da(t){const e={},n=i(t,["image"]);return n!=null&&r(e,["image"],Q(n)),e}function ca(t,e){const n={},o=i(t,["mode"]);e!==void 0&&o!=null&&r(e,["parameters","mode"],o);const s=i(t,["maxPredictions"]);e!==void 0&&s!=null&&r(e,["parameters","maxPredictions"],s);const l=i(t,["confidenceThreshold"]);e!==void 0&&l!=null&&r(e,["parameters","confidenceThreshold"],l);const a=i(t,["maskDilation"]);e!==void 0&&a!=null&&r(e,["parameters","maskDilation"],a);const u=i(t,["binaryColorThreshold"]);e!==void 0&&u!=null&&r(e,["parameters","binaryColorThreshold"],u);const c=i(t,["labels"]);return e!==void 0&&c!=null&&r(e,["labels"],c),n}function fa(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["source"]);s!=null&&ha(s,n);const l=i(e,["config"]);return l!=null&&ca(l,n),n}function pa(t){const e={},n=i(t,["predictions"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(s=>Gl(s))),r(e,["generatedMasks"],o)}return e}function ha(t,e){const n={},o=i(t,["prompt"]);e!==void 0&&o!=null&&r(e,["instances[0]","prompt"],o);const s=i(t,["image"]);e!==void 0&&s!=null&&r(e,["instances[0]","image"],Q(s));const l=i(t,["scribbleImage"]);return e!==void 0&&l!=null&&r(e,["instances[0]","scribble"],da(l)),n}function ma(t){const e={},n=i(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],yl(n));const o=i(t,["retrievalConfig"]);return o!=null&&r(e,["retrievalConfig"],o),e}function ga(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>p)),r(e,["functionDeclarations"],f)}if(i(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=i(t,["googleSearchRetrieval"]);o!=null&&r(e,["googleSearchRetrieval"],o);const s=i(t,["computerUse"]);s!=null&&r(e,["computerUse"],s);const l=i(t,["fileSearch"]);l!=null&&r(e,["fileSearch"],l);const a=i(t,["codeExecution"]);if(a!=null&&r(e,["codeExecution"],a),i(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=i(t,["googleMaps"]);u!=null&&r(e,["googleMaps"],$l(u));const c=i(t,["googleSearch"]);c!=null&&r(e,["googleSearch"],Wl(c));const d=i(t,["urlContext"]);return d!=null&&r(e,["urlContext"],d),e}function Qn(t){const e={},n=i(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(h=>Tl(h))),r(e,["functionDeclarations"],p)}const o=i(t,["retrieval"]);o!=null&&r(e,["retrieval"],o);const s=i(t,["googleSearchRetrieval"]);s!=null&&r(e,["googleSearchRetrieval"],s);const l=i(t,["computerUse"]);if(l!=null&&r(e,["computerUse"],l),i(t,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const a=i(t,["codeExecution"]);a!=null&&r(e,["codeExecution"],a);const u=i(t,["enterpriseWebSearch"]);u!=null&&r(e,["enterpriseWebSearch"],u);const c=i(t,["googleMaps"]);c!=null&&r(e,["googleMaps"],c);const d=i(t,["googleSearch"]);d!=null&&r(e,["googleSearch"],d);const f=i(t,["urlContext"]);return f!=null&&r(e,["urlContext"],f),e}function ya(t){const e={},n=i(t,["baseModel"]);n!=null&&r(e,["baseModel"],n);const o=i(t,["createTime"]);o!=null&&r(e,["createTime"],o);const s=i(t,["updateTime"]);return s!=null&&r(e,["updateTime"],s),e}function Ta(t){const e={},n=i(t,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&r(e,["baseModel"],n);const o=i(t,["createTime"]);o!=null&&r(e,["createTime"],o);const s=i(t,["updateTime"]);return s!=null&&r(e,["updateTime"],s),e}function _a(t,e){const n={},o=i(t,["displayName"]);e!==void 0&&o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);e!==void 0&&s!=null&&r(e,["description"],s);const l=i(t,["defaultCheckpointId"]);return e!==void 0&&l!=null&&r(e,["defaultCheckpointId"],l),n}function Ea(t,e){const n={},o=i(t,["displayName"]);e!==void 0&&o!=null&&r(e,["displayName"],o);const s=i(t,["description"]);e!==void 0&&s!=null&&r(e,["description"],s);const l=i(t,["defaultCheckpointId"]);return e!==void 0&&l!=null&&r(e,["defaultCheckpointId"],l),n}function Ca(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","name"],L(t,o));const s=i(e,["config"]);return s!=null&&_a(s,n),n}function va(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["config"]);return s!=null&&Ea(s,n),n}function Sa(t,e){const n={},o=i(t,["outputGcsUri"]);e!==void 0&&o!=null&&r(e,["parameters","storageUri"],o);const s=i(t,["safetyFilterLevel"]);e!==void 0&&s!=null&&r(e,["parameters","safetySetting"],s);const l=i(t,["personGeneration"]);e!==void 0&&l!=null&&r(e,["parameters","personGeneration"],l);const a=i(t,["includeRaiReason"]);e!==void 0&&a!=null&&r(e,["parameters","includeRaiReason"],a);const u=i(t,["outputMimeType"]);e!==void 0&&u!=null&&r(e,["parameters","outputOptions","mimeType"],u);const c=i(t,["outputCompressionQuality"]);e!==void 0&&c!=null&&r(e,["parameters","outputOptions","compressionQuality"],c);const d=i(t,["enhanceInputImage"]);e!==void 0&&d!=null&&r(e,["parameters","upscaleConfig","enhanceInputImage"],d);const f=i(t,["imagePreservationFactor"]);e!==void 0&&f!=null&&r(e,["parameters","upscaleConfig","imagePreservationFactor"],f);const p=i(t,["labels"]);e!==void 0&&p!=null&&r(e,["labels"],p);const h=i(t,["numberOfImages"]);e!==void 0&&h!=null&&r(e,["parameters","sampleCount"],h);const g=i(t,["mode"]);return e!==void 0&&g!=null&&r(e,["parameters","mode"],g),n}function Ia(t,e){const n={},o=i(e,["model"]);o!=null&&r(n,["_url","model"],L(t,o));const s=i(e,["image"]);s!=null&&r(n,["instances[0]","image"],Q(s));const l=i(e,["upscaleFactor"]);l!=null&&r(n,["parameters","upscaleConfig","upscaleFactor"],l);const a=i(e,["config"]);return a!=null&&Sa(a,n),n}function Aa(t){const e={},n=i(t,["sdkHttpResponse"]);n!=null&&r(e,["sdkHttpResponse"],n);const o=i(t,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(l=>we(l))),r(e,["generatedImages"],s)}return e}function xa(t){const e={},n=i(t,["uri"]);n!=null&&r(e,["uri"],n);const o=i(t,["encodedVideo"]);o!=null&&r(e,["videoBytes"],oe(o));const s=i(t,["encoding"]);return s!=null&&r(e,["mimeType"],s),e}function wa(t){const e={},n=i(t,["gcsUri"]);n!=null&&r(e,["uri"],n);const o=i(t,["bytesBase64Encoded"]);o!=null&&r(e,["videoBytes"],oe(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}function Na(t){const e={},n=i(t,["image"]);n!=null&&r(e,["_self"],Q(n));const o=i(t,["maskMode"]);return o!=null&&r(e,["maskMode"],o),e}function Ma(t){const e={},n=i(t,["image"]);n!=null&&r(e,["image"],Ne(n));const o=i(t,["referenceType"]);return o!=null&&r(e,["referenceType"],o),e}function Pa(t){const e={},n=i(t,["image"]);n!=null&&r(e,["image"],Q(n));const o=i(t,["referenceType"]);return o!=null&&r(e,["referenceType"],o),e}function Zn(t){const e={},n=i(t,["uri"]);n!=null&&r(e,["uri"],n);const o=i(t,["videoBytes"]);o!=null&&r(e,["encodedVideo"],oe(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["encoding"],s),e}function jn(t){const e={},n=i(t,["uri"]);n!=null&&r(e,["gcsUri"],n);const o=i(t,["videoBytes"]);o!=null&&r(e,["bytesBase64Encoded"],oe(o));const s=i(t,["mimeType"]);return s!=null&&r(e,["mimeType"],s),e}/**
70
70
  * @license
71
71
  * Copyright 2025 Google LLC
72
72
  * SPDX-License-Identifier: Apache-2.0
@@ -74,7 +74,7 @@
74
74
  * @license
75
75
  * Copyright 2025 Google LLC
76
76
  * SPDX-License-Identifier: Apache-2.0
77
- */const Wa="Content-Type",Ya="X-Server-Timeout",Ka="User-Agent",je="x-goog-api-client",za="google-genai-sdk/1.34.0",Oa="v1beta1",Xa="v1beta";class Qa{constructor(e){var n,o;this.clientOptions=Object.assign(Object.assign({},e),{project:e.project,location:e.location,apiKey:e.apiKey,vertexai:e.vertexai});const s={};this.clientOptions.vertexai?(s.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:Oa,s.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(s.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:Xa,s.baseUrl="https://generativelanguage.googleapis.com/"),s.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=s,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(s,e.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var e;return(e=this.clientOptions.vertexai)!==null&&e!==void 0?e:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}async getAuthHeaders(){const e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const o=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==""&&o.push(e.apiVersion),o.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const e=this.getBaseUrl(),n=new URL(e);return n.protocol=n.protocol=="http:"?"ws":"wss",n.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw new Error("HTTP options are not correctly set.")}constructUrl(e,n,o){const s=[this.getRequestUrlInternal(n)];return o&&s.push(this.getBaseResourcePath()),e!==""&&s.push(e),new URL(`${s.join("/")}`)}shouldPrependVertexProjectPath(e){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith("projects/")||e.httpMethod==="GET"&&e.path.startsWith("publishers/google/models"))}async request(e){let n=this.clientOptions.httpOptions;e.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const o=this.shouldPrependVertexProjectPath(e),s=this.constructUrl(e.path,n,o);if(e.queryParams)for(const[a,u]of Object.entries(e.queryParams))s.searchParams.append(a,String(u));let l={};if(e.httpMethod==="GET"){if(e.body&&e.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else l.body=e.body;return l=await this.includeExtraHttpOptionsToRequestInit(l,n,s.toString(),e.abortSignal),this.unaryApiCall(s,l,e.httpMethod)}patchHttpOptions(e,n){const o=JSON.parse(JSON.stringify(e));for(const[s,l]of Object.entries(n))typeof l=="object"?o[s]=Object.assign(Object.assign({},o[s]),l):l!==void 0&&(o[s]=l);return o}async requestStream(e){let n=this.clientOptions.httpOptions;e.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const o=this.shouldPrependVertexProjectPath(e),s=this.constructUrl(e.path,n,o);(!s.searchParams.has("alt")||s.searchParams.get("alt")!=="sse")&&s.searchParams.set("alt","sse");let l={};return l.body=e.body,l=await this.includeExtraHttpOptionsToRequestInit(l,n,s.toString(),e.abortSignal),this.streamApiCall(s,l,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,n,o,s){if(n&&n.timeout||s){const l=new AbortController,a=l.signal;if(n.timeout&&(n==null?void 0:n.timeout)>0){const u=setTimeout(()=>l.abort(),n.timeout);u&&typeof u.unref=="function"&&u.unref()}s&&s.addEventListener("abort",()=>{l.abort()}),e.signal=a}return n&&n.extraBody!==null&&Za(e,n.extraBody),e.headers=await this.getHeadersInternal(n,o),e}async unaryApiCall(e,n,o){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:o})).then(async s=>(await to(s),new Be(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}async streamApiCall(e,n,o){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:o})).then(async s=>(await to(s),this.processStreamResponse(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}processStreamResponse(e){return z(this,arguments,function*(){var o;const s=(o=e==null?void 0:e.body)===null||o===void 0?void 0:o.getReader(),l=new TextDecoder("utf-8");if(!s)throw new Error("Response body is empty");try{let a="";const u="data:",c=[`
77
+ */const Wa="Content-Type",Ya="X-Server-Timeout",Ka="User-Agent",je="x-goog-api-client",za="google-genai-sdk/1.34.0",Oa="v1beta1",Xa="v1beta";class Qa{constructor(e){var n,o;this.clientOptions=Object.assign(Object.assign({},e),{project:e.project,location:e.location,apiKey:e.apiKey,vertexai:e.vertexai});const s={};this.clientOptions.vertexai?(s.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:Oa,s.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(s.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:Xa,s.baseUrl="https://generativelanguage.googleapis.com/"),s.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=s,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(s,e.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var e;return(e=this.clientOptions.vertexai)!==null&&e!==void 0?e:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}async getAuthHeaders(){const e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const o=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==""&&o.push(e.apiVersion),o.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const e=this.getBaseUrl(),n=new URL(e);return n.protocol=n.protocol=="http:"?"ws":"wss",n.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw new Error("HTTP options are not correctly set.")}constructUrl(e,n,o){const s=[this.getRequestUrlInternal(n)];return o&&s.push(this.getBaseResourcePath()),e!==""&&s.push(e),new URL(`${s.join("/")}`)}shouldPrependVertexProjectPath(e){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith("projects/")||e.httpMethod==="GET"&&e.path.startsWith("publishers/google/models"))}async request(e){let n=this.clientOptions.httpOptions;e.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const o=this.shouldPrependVertexProjectPath(e),s=this.constructUrl(e.path,n,o);if(e.queryParams)for(const[a,u]of Object.entries(e.queryParams))s.searchParams.append(a,String(u));let l={};if(e.httpMethod==="GET"){if(e.body&&e.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else l.body=e.body;return l=await this.includeExtraHttpOptionsToRequestInit(l,n,s.toString(),e.abortSignal),this.unaryApiCall(s,l,e.httpMethod)}patchHttpOptions(e,n){const o=JSON.parse(JSON.stringify(e));for(const[s,l]of Object.entries(n))typeof l=="object"?o[s]=Object.assign(Object.assign({},o[s]),l):l!==void 0&&(o[s]=l);return o}async requestStream(e){let n=this.clientOptions.httpOptions;e.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const o=this.shouldPrependVertexProjectPath(e),s=this.constructUrl(e.path,n,o);(!s.searchParams.has("alt")||s.searchParams.get("alt")!=="sse")&&s.searchParams.set("alt","sse");let l={};return l.body=e.body,l=await this.includeExtraHttpOptionsToRequestInit(l,n,s.toString(),e.abortSignal),this.streamApiCall(s,l,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,n,o,s){if(n&&n.timeout||s){const l=new AbortController,a=l.signal;if(n.timeout&&(n==null?void 0:n.timeout)>0){const u=setTimeout(()=>l.abort(),n.timeout);u&&typeof u.unref=="function"&&u.unref()}s&&s.addEventListener("abort",()=>{l.abort()}),e.signal=a}return n&&n.extraBody!==null&&Za(e,n.extraBody),e.headers=await this.getHeadersInternal(n,o),e}async unaryApiCall(e,n,o){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:o})).then(async s=>(await to(s),new Be(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}async streamApiCall(e,n,o){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:o})).then(async s=>(await to(s),this.processStreamResponse(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}processStreamResponse(e){return O(this,arguments,function*(){var o;const s=(o=e==null?void 0:e.body)===null||o===void 0?void 0:o.getReader(),l=new TextDecoder("utf-8");if(!s)throw new Error("Response body is empty");try{let a="";const u="data:",c=[`
78
78
 
79
79
  `,"\r\r",`\r
80
80
  \r
@@ -82,7 +82,7 @@
82
82
  * @license
83
83
  * Copyright 2025 Google LLC
84
84
  * SPDX-License-Identifier: Apache-2.0
85
- */const ja="mcp_used/unknown";let eu=!1;function no(t){for(const e of t)if(tu(e)||typeof e=="object"&&"inputSchema"in e)return!0;return eu}function oo(t){var e;const n=(e=t[je])!==null&&e!==void 0?e:"";t[je]=(n+` ${ja}`).trimStart()}function tu(t){return t!==null&&typeof t=="object"&&t instanceof et}function nu(t){return z(this,arguments,function*(n,o=100){let s,l=0;for(;l<o;){const a=yield k(n.listTools({cursor:s}));for(const u of a.tools)yield yield k(u),l++;if(!a.nextCursor)break;s=a.nextCursor}})}class et{constructor(e=[],n){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=n}static create(e,n){return new et(e,n)}async initialize(){var e,n,o,s;if(this.mcpTools.length>0)return;const l={},a=[];for(const f of this.mcpClients)try{for(var u=!0,c=(n=void 0,O(nu(f))),d;d=await c.next(),e=d.done,!e;u=!0){s=d.value,u=!1;const p=s;a.push(p);const h=p.name;if(l[h])throw new Error(`Duplicate function name ${h} found in MCP tools. Please ensure function names are unique.`);l[h]=f}}catch(p){n={error:p}}finally{try{!u&&!e&&(o=c.return)&&await o.call(c)}finally{if(n)throw n.error}}this.mcpTools=a,this.functionNameToMcpClient=l}async tool(){return await this.initialize(),Ui(this.mcpTools,this.config)}async callTool(e){await this.initialize();const n=[];for(const o of e)if(o.name in this.functionNameToMcpClient){const s=this.functionNameToMcpClient[o.name];let l;this.config.timeout&&(l={timeout:this.config.timeout});const a=await s.callTool({name:o.name,arguments:o.args},void 0,l);n.push({functionResponse:{name:o.name,response:a.isError?{error:a}:a}})}return n}}/**
85
+ */const ja="mcp_used/unknown";let eu=!1;function no(t){for(const e of t)if(tu(e)||typeof e=="object"&&"inputSchema"in e)return!0;return eu}function oo(t){var e;const n=(e=t[je])!==null&&e!==void 0?e:"";t[je]=(n+` ${ja}`).trimStart()}function tu(t){return t!==null&&typeof t=="object"&&t instanceof et}function nu(t){return O(this,arguments,function*(n,o=100){let s,l=0;for(;l<o;){const a=yield k(n.listTools({cursor:s}));for(const u of a.tools)yield yield k(u),l++;if(!a.nextCursor)break;s=a.nextCursor}})}class et{constructor(e=[],n){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=n}static create(e,n){return new et(e,n)}async initialize(){var e,n,o,s;if(this.mcpTools.length>0)return;const l={},a=[];for(const f of this.mcpClients)try{for(var u=!0,c=(n=void 0,X(nu(f))),d;d=await c.next(),e=d.done,!e;u=!0){s=d.value,u=!1;const p=s;a.push(p);const h=p.name;if(l[h])throw new Error(`Duplicate function name ${h} found in MCP tools. Please ensure function names are unique.`);l[h]=f}}catch(p){n={error:p}}finally{try{!u&&!e&&(o=c.return)&&await o.call(c)}finally{if(n)throw n.error}}this.mcpTools=a,this.functionNameToMcpClient=l}async tool(){return await this.initialize(),Ui(this.mcpTools,this.config)}async callTool(e){await this.initialize();const n=[];for(const o of e)if(o.name in this.functionNameToMcpClient){const s=this.functionNameToMcpClient[o.name];let l;this.config.timeout&&(l={timeout:this.config.timeout});const a=await s.callTool({name:o.name,arguments:o.args},void 0,l);n.push({functionResponse:{name:o.name,response:a.isError?{error:a}:a}})}return n}}/**
86
86
  * @license
87
87
  * Copyright 2025 Google LLC
88
88
  * SPDX-License-Identifier: Apache-2.0
@@ -90,7 +90,7 @@
90
90
  * @license
91
91
  * Copyright 2025 Google LLC
92
92
  * SPDX-License-Identifier: Apache-2.0
93
- */const au="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function uu(t,e,n){const o=new xi;let s;n.data instanceof Blob?s=await n.data.text():n.data instanceof ArrayBuffer?s=new TextDecoder().decode(n.data):s=n.data;const l=JSON.parse(s);if(t.isVertexAI()){const a=Ur(l);Object.assign(o,a)}else Object.assign(o,l);e(o)}class du{constructor(e,n,o){this.apiClient=e,this.auth=n,this.webSocketFactory=o,this.music=new iu(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var n,o,s,l,a,u;if(e.config&&e.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 c=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion();let f;const p=this.apiClient.getHeaders();e.config&&e.config.tools&&no(e.config.tools)&&oo(p);const h=hu(p);if(this.apiClient.isVertexAI())f=`${c}/ws/google.cloud.aiplatform.${d}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(h,f);else{const A=this.apiClient.getApiKey();let R="BidiGenerateContent",F="key";A!=null&&A.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),d!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),R="BidiGenerateContentConstrained",F="access_token"),f=`${c}/ws/google.ai.generativelanguage.${d}.GenerativeService.${R}?${F}=${A}`}let g=()=>{};const y=new Promise(A=>{g=A}),C=e.callbacks,T=function(){var A;(A=C==null?void 0:C.onopen)===null||A===void 0||A.call(C),g({})},E=this.apiClient,_={onopen:T,onmessage:A=>{uu(E,C.onmessage,A)},onerror:(n=C==null?void 0:C.onerror)!==null&&n!==void 0?n:function(A){},onclose:(o=C==null?void 0:C.onclose)!==null&&o!==void 0?o:function(A){}},v=this.webSocketFactory.create(f,pu(h),_);v.connect(),await y;let S=L(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&S.startsWith("publishers/")){const A=this.apiClient.getProject(),R=this.apiClient.getLocation();S=`projects/${A}/locations/${R}/`+S}let x={};this.apiClient.isVertexAI()&&((s=e.config)===null||s===void 0?void 0:s.responseModalities)===void 0&&(e.config===void 0?e.config={responseModalities:[_e.AUDIO]}:e.config.responseModalities=[_e.AUDIO]),!((l=e.config)===null||l===void 0)&&l.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 P=(u=(a=e.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[],M=[];for(const A of P)if(this.isCallableTool(A)){const R=A;M.push(await R.tool())}else M.push(A);M.length>0&&(e.config.tools=M);const b={model:S,config:e.config,callbacks:e.callbacks};return this.apiClient.isVertexAI()?x=Pr(this.apiClient,b):x=Mr(this.apiClient,b),delete x.config,v.send(JSON.stringify(x)),new fu(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool=="function"}}const cu={turnComplete:!0};class fu{constructor(e,n){this.conn=e,this.apiClient=n}tLiveClientContent(e,n){if(n.turns!==null&&n.turns!==void 0){let o=[];try{o=W(n.turns),e.isVertexAI()||(o=o.map(s=>xe(s)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof n.turns}'`)}return{clientContent:{turns:o,turnComplete:n.turnComplete}}}return{clientContent:{turnComplete:n.turnComplete}}}tLiveClienttToolResponse(e,n){let o=[];if(n.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(n.functionResponses)?o=n.functionResponses:o=[n.functionResponses],o.length===0)throw new Error("functionResponses is required.");for(const l of o){if(typeof l!="object"||l===null||!("name"in l)||!("response"in l))throw new Error(`Could not parse function response, type '${typeof l}'.`);if(!e.isVertexAI()&&!("id"in l))throw new Error(au)}return{toolResponse:{functionResponses:o}}}sendClientContent(e){e=Object.assign(Object.assign({},cu),e);const n=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(n))}sendRealtimeInput(e){let n={};this.apiClient.isVertexAI()?n={realtimeInput:br(e)}:n={realtimeInput:Dr(e)},this.conn.send(JSON.stringify(n))}sendToolResponse(e){if(e.functionResponses==null)throw new Error("Tool response parameters are required.");const n=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(n))}close(){this.conn.close()}}function pu(t){const e={};return t.forEach((n,o)=>{e[o]=n}),e}function hu(t){const e=new Headers;for(const[n,o]of Object.entries(t))e.append(n,o);return e}/**
93
+ */const au="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function uu(t,e,n){const o=new xi;let s;n.data instanceof Blob?s=await n.data.text():n.data instanceof ArrayBuffer?s=new TextDecoder().decode(n.data):s=n.data;const l=JSON.parse(s);if(t.isVertexAI()){const a=Ur(l);Object.assign(o,a)}else Object.assign(o,l);e(o)}class du{constructor(e,n,o){this.apiClient=e,this.auth=n,this.webSocketFactory=o,this.music=new iu(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var n,o,s,l,a,u;if(e.config&&e.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 c=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion();let f;const p=this.apiClient.getHeaders();e.config&&e.config.tools&&no(e.config.tools)&&oo(p);const h=hu(p);if(this.apiClient.isVertexAI())f=`${c}/ws/google.cloud.aiplatform.${d}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(h,f);else{const A=this.apiClient.getApiKey();let R="BidiGenerateContent",F="key";A!=null&&A.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),d!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),R="BidiGenerateContentConstrained",F="access_token"),f=`${c}/ws/google.ai.generativelanguage.${d}.GenerativeService.${R}?${F}=${A}`}let g=()=>{};const y=new Promise(A=>{g=A}),C=e.callbacks,T=function(){var A;(A=C==null?void 0:C.onopen)===null||A===void 0||A.call(C),g({})},E=this.apiClient,_={onopen:T,onmessage:A=>{uu(E,C.onmessage,A)},onerror:(n=C==null?void 0:C.onerror)!==null&&n!==void 0?n:function(A){},onclose:(o=C==null?void 0:C.onclose)!==null&&o!==void 0?o:function(A){}},v=this.webSocketFactory.create(f,pu(h),_);v.connect(),await y;let S=L(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&S.startsWith("publishers/")){const A=this.apiClient.getProject(),R=this.apiClient.getLocation();S=`projects/${A}/locations/${R}/`+S}let x={};this.apiClient.isVertexAI()&&((s=e.config)===null||s===void 0?void 0:s.responseModalities)===void 0&&(e.config===void 0?e.config={responseModalities:[_e.AUDIO]}:e.config.responseModalities=[_e.AUDIO]),!((l=e.config)===null||l===void 0)&&l.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 P=(u=(a=e.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[],M=[];for(const A of P)if(this.isCallableTool(A)){const R=A;M.push(await R.tool())}else M.push(A);M.length>0&&(e.config.tools=M);const b={model:S,config:e.config,callbacks:e.callbacks};return this.apiClient.isVertexAI()?x=Pr(this.apiClient,b):x=Mr(this.apiClient,b),delete x.config,v.send(JSON.stringify(x)),new fu(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool=="function"}}const cu={turnComplete:!0};class fu{constructor(e,n){this.conn=e,this.apiClient=n}tLiveClientContent(e,n){if(n.turns!==null&&n.turns!==void 0){let o=[];try{o=Y(n.turns),e.isVertexAI()||(o=o.map(s=>xe(s)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof n.turns}'`)}return{clientContent:{turns:o,turnComplete:n.turnComplete}}}return{clientContent:{turnComplete:n.turnComplete}}}tLiveClienttToolResponse(e,n){let o=[];if(n.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(n.functionResponses)?o=n.functionResponses:o=[n.functionResponses],o.length===0)throw new Error("functionResponses is required.");for(const l of o){if(typeof l!="object"||l===null||!("name"in l)||!("response"in l))throw new Error(`Could not parse function response, type '${typeof l}'.`);if(!e.isVertexAI()&&!("id"in l))throw new Error(au)}return{toolResponse:{functionResponses:o}}}sendClientContent(e){e=Object.assign(Object.assign({},cu),e);const n=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(n))}sendRealtimeInput(e){let n={};this.apiClient.isVertexAI()?n={realtimeInput:br(e)}:n={realtimeInput:Dr(e)},this.conn.send(JSON.stringify(n))}sendToolResponse(e){if(e.functionResponses==null)throw new Error("Tool response parameters are required.");const n=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(n))}close(){this.conn.close()}}function pu(t){const e={};return t.forEach((n,o)=>{e[o]=n}),e}function hu(t){const e=new Headers;for(const[n,o]of Object.entries(t))e.append(n,o);return e}/**
94
94
  * @license
95
95
  * Copyright 2025 Google LLC
96
96
  * SPDX-License-Identifier: Apache-2.0
@@ -98,11 +98,11 @@
98
98
  * @license
99
99
  * Copyright 2025 Google LLC
100
100
  * SPDX-License-Identifier: Apache-2.0
101
- */class gu extends Q{constructor(e){super(),this.apiClient=e,this.generateContent=async n=>{var o,s,l,a,u;const c=await this.processParamsMaybeAddMcpUsage(n);if(this.maybeMoveToResponseJsonSchem(n),!mu(n)||so(n.config))return await this.generateContentInternal(c);const d=ro(n);if(d.length>0){const C=d.map(T=>`tools[${T}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${C}.`)}let f,p;const h=W(c.contents),g=(l=(s=(o=c.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&l!==void 0?l:io;let y=0;for(;y<g&&(f=await this.generateContentInternal(c),!(!f.functionCalls||f.functionCalls.length===0));){const C=f.candidates[0].content,T=[];for(const E of(u=(a=n.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[])if(fe(E)){const v=await E.callTool(f.functionCalls);T.push(...v)}y++,p={role:"user",parts:T},c.contents=W(c.contents),c.contents.push(C),c.contents.push(p),lo(c.config)&&(h.push(C),h.push(p))}return lo(c.config)&&(f.automaticFunctionCallingHistory=h),f},this.generateContentStream=async n=>{var o,s,l,a,u;if(this.maybeMoveToResponseJsonSchem(n),so(n.config)){const p=await this.processParamsMaybeAddMcpUsage(n);return await this.generateContentStreamInternal(p)}const c=ro(n);if(c.length>0){const p=c.map(h=>`tools[${h}]`).join(", ");throw new Error(`Incompatible tools found at ${p}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const d=(l=(s=(o=n==null?void 0:n.config)===null||o===void 0?void 0:o.toolConfig)===null||s===void 0?void 0:s.functionCallingConfig)===null||l===void 0?void 0:l.streamFunctionCallArguments,f=(u=(a=n==null?void 0:n.config)===null||a===void 0?void 0:a.automaticFunctionCalling)===null||u===void 0?void 0:u.disable;if(d&&!f)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(n)},this.generateImages=async n=>await this.generateImagesInternal(n).then(o=>{var s;let l;const a=[];if(o!=null&&o.generatedImages)for(const c of o.generatedImages)c&&(c!=null&&c.safetyAttributes)&&((s=c==null?void 0:c.safetyAttributes)===null||s===void 0?void 0:s.contentType)==="Positive Prompt"?l=c==null?void 0:c.safetyAttributes:a.push(c);let u;return l?u={generatedImages:a,positivePromptSafetyAttributes:l,sdkHttpResponse:o.sdkHttpResponse}:u={generatedImages:a,sdkHttpResponse:o.sdkHttpResponse},u}),this.list=async n=>{var o;const a={config:Object.assign(Object.assign({},{queryBase:!0}),n==null?void 0:n.config)};if(this.apiClient.isVertexAI()&&!a.config.queryBase){if(!((o=a.config)===null||o===void 0)&&o.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");a.config.filter="labels.tune-type:*"}return new oe(j.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(a),a)},this.editImage=async n=>{const o={model:n.model,prompt:n.prompt,referenceImages:[],config:n.config};return n.referenceImages&&n.referenceImages&&(o.referenceImages=n.referenceImages.map(s=>s.toReferenceImageAPI())),await this.editImageInternal(o)},this.upscaleImage=async n=>{let o={numberOfImages:1,mode:"upscale"};n.config&&(o=Object.assign(Object.assign({},o),n.config));const s={model:n.model,image:n.image,upscaleFactor:n.upscaleFactor,config:o};return await this.upscaleImageInternal(s)},this.generateVideos=async n=>{var o,s,l,a,u,c;if((n.prompt||n.image||n.video)&&n.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((o=n.video)===null||o===void 0)&&o.uri&&(!((s=n.video)===null||s===void 0)&&s.videoBytes)?n.video={uri:n.video.uri,mimeType:n.video.mimeType}:!((a=(l=n.source)===null||l===void 0?void 0:l.video)===null||a===void 0)&&a.uri&&(!((c=(u=n.source)===null||u===void 0?void 0:u.video)===null||c===void 0)&&c.videoBytes)&&(n.source.video={uri:n.source.video.uri,mimeType:n.source.video.mimeType})),await this.generateVideosInternal(n)}}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 n,o,s;const l=(n=e.config)===null||n===void 0?void 0:n.tools;if(!l)return e;const a=await Promise.all(l.map(async c=>fe(c)?await c.tool():c)),u={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:a})};if(u.config.tools=a,e.config&&e.config.tools&&no(e.config.tools)){const c=(s=(o=e.config.httpOptions)===null||o===void 0?void 0:o.headers)!==null&&s!==void 0?s:{};let d=Object.assign({},c);Object.keys(d).length===0&&(d=this.apiClient.getDefaultHeaders()),oo(d),u.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:d})}return u}async initAfcToolsMap(e){var n,o,s;const l=new Map;for(const a of(o=(n=e.config)===null||n===void 0?void 0:n.tools)!==null&&o!==void 0?o:[])if(fe(a)){const u=a,c=await u.tool();for(const d of(s=c.functionDeclarations)!==null&&s!==void 0?s:[]){if(!d.name)throw new Error("Function declaration name is required.");if(l.has(d.name))throw new Error(`Duplicate tool declaration name: ${d.name}`);l.set(d.name,u)}}return l}async processAfcStream(e){var n,o,s;const l=(s=(o=(n=e.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||o===void 0?void 0:o.maximumRemoteCalls)!==null&&s!==void 0?s:io;let a=!1,u=0;const c=await this.initAfcToolsMap(e);return function(d,f,p){return z(this,arguments,function*(){for(var h,g,y,C,T,E;u<l;){a&&(u++,a=!1);const x=yield k(d.processParamsMaybeAddMcpUsage(p)),P=yield k(d.generateContentStreamInternal(x)),M=[],b=[];try{for(var _=!0,v=(g=void 0,O(P)),S;S=yield k(v.next()),h=S.done,!h;_=!0){C=S.value,_=!1;const A=C;if(yield yield k(A),A.candidates&&(!((T=A.candidates[0])===null||T===void 0)&&T.content)){b.push(A.candidates[0].content);for(const R of(E=A.candidates[0].content.parts)!==null&&E!==void 0?E:[])if(u<l&&R.functionCall){if(!R.functionCall.name)throw new Error("Function call name was not returned by the model.");if(f.has(R.functionCall.name)){const F=yield k(f.get(R.functionCall.name).callTool([R.functionCall]));M.push(...F)}else throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${f.keys()}, mising tool: ${R.functionCall.name}`)}}}}catch(A){g={error:A}}finally{try{!_&&!h&&(y=v.return)&&(yield k(y.call(v)))}finally{if(g)throw g.error}}if(M.length>0){a=!0;const A=new me;A.candidates=[{content:{role:"user",parts:M}}],yield yield k(A);const R=[];R.push(...b),R.push({role:"user",parts:M});const F=W(p.contents).concat(R);p.contents=F}else break}})}(this,c,e)}async generateContentInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Wn(this.apiClient,e);return u=I("{model}:generateContent",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Kn(f),h=new me;return Object.assign(h,p),h})}else{const d=$n(this.apiClient,e);return u=I("{model}:generateContent",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Yn(f),h=new me;return Object.assign(h,p),h})}}async generateContentStreamInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Wn(this.apiClient,e);return u=I("{model}:streamGenerateContent?alt=sse",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.requestStream({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}),a.then(function(p){return z(this,arguments,function*(){var h,g,y,C;try{for(var T=!0,E=O(p),_;_=yield k(E.next()),h=_.done,!h;T=!0){C=_.value,T=!1;const v=C,S=Kn(yield k(v.json()));S.sdkHttpResponse={headers:v.headers};const x=new me;Object.assign(x,S),yield yield k(x)}}catch(v){g={error:v}}finally{try{!T&&!h&&(y=E.return)&&(yield k(y.call(E)))}finally{if(g)throw g.error}}})})}else{const d=$n(this.apiClient,e);return u=I("{model}:streamGenerateContent?alt=sse",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.requestStream({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}),a.then(function(p){return z(this,arguments,function*(){var h,g,y,C;try{for(var T=!0,E=O(p),_;_=yield k(E.next()),h=_.done,!h;T=!0){C=_.value,T=!1;const v=C,S=Yn(yield k(v.json()));S.sdkHttpResponse={headers:v.headers};const x=new me;Object.assign(x,S),yield yield k(x)}}catch(v){g={error:v}}finally{try{!T&&!h&&(y=E.return)&&(yield k(y.call(E)))}finally{if(g)throw g.error}}})})}}async embedContent(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=cl(this.apiClient,e);return u=I("{model}:predict",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=pl(f),h=new pn;return Object.assign(h,p),h})}else{const d=dl(this.apiClient,e);return u=I("{model}:batchEmbedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=fl(f),h=new pn;return Object.assign(h,p),h})}}async generateImagesInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Il(this.apiClient,e);return u=I("{model}:predict",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=xl(f),h=new hn;return Object.assign(h,p),h})}else{const d=Sl(this.apiClient,e);return u=I("{model}:predict",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Al(f),h=new hn;return Object.assign(h,p),h})}}async editImageInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=rl(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=ll(c),f=new mi;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=Ia(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=Aa(c),f=new gi;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=sa(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=ra(c),f=new yi;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=fa(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=pa(c),f=new Ti;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async get(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Jl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Ze(f))}else{const d=Bl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Qe(f))}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Zl(this.apiClient,e);return u=I("{models_url}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=ea(f),h=new mn;return Object.assign(h,p),h})}else{const d=Ql(this.apiClient,e);return u=I("{models_url}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=jl(f),h=new mn;return Object.assign(h,p),h})}}async update(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=va(this.apiClient,e);return u=I("{model}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Ze(f))}else{const d=Ca(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Qe(f))}}async delete(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=nl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=il(f),h=new gn;return Object.assign(h,p),h})}else{const d=tl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=ol(f),h=new gn;return Object.assign(h,p),h})}}async countTokens(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Zr(this.apiClient,e);return u=I("{model}:countTokens",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=el(f),h=new yn;return Object.assign(h,p),h})}else{const d=Qr(this.apiClient,e);return u=I("{model}:countTokens",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=jr(f),h=new yn;return Object.assign(h,p),h})}}async computeTokens(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=$r(this.apiClient,e);return l=I("{model}:computeTokens",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=Wr(c),f=new _i;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=kl(this.apiClient,e);return u=I("{model}:predictLongRunning",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Pl(f),h=new Ee;return Object.assign(h,p),h})}else{const d=Rl(this.apiClient,e);return u=I("{model}:predictLongRunning",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Ml(f),h=new Ee;return Object.assign(h,p),h})}}}/**
101
+ */class gu extends Z{constructor(e){super(),this.apiClient=e,this.generateContent=async n=>{var o,s,l,a,u;const c=await this.processParamsMaybeAddMcpUsage(n);if(this.maybeMoveToResponseJsonSchem(n),!mu(n)||so(n.config))return await this.generateContentInternal(c);const d=ro(n);if(d.length>0){const C=d.map(T=>`tools[${T}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${C}.`)}let f,p;const h=Y(c.contents),g=(l=(s=(o=c.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&l!==void 0?l:io;let y=0;for(;y<g&&(f=await this.generateContentInternal(c),!(!f.functionCalls||f.functionCalls.length===0));){const C=f.candidates[0].content,T=[];for(const E of(u=(a=n.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[])if(fe(E)){const v=await E.callTool(f.functionCalls);T.push(...v)}y++,p={role:"user",parts:T},c.contents=Y(c.contents),c.contents.push(C),c.contents.push(p),lo(c.config)&&(h.push(C),h.push(p))}return lo(c.config)&&(f.automaticFunctionCallingHistory=h),f},this.generateContentStream=async n=>{var o,s,l,a,u;if(this.maybeMoveToResponseJsonSchem(n),so(n.config)){const p=await this.processParamsMaybeAddMcpUsage(n);return await this.generateContentStreamInternal(p)}const c=ro(n);if(c.length>0){const p=c.map(h=>`tools[${h}]`).join(", ");throw new Error(`Incompatible tools found at ${p}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const d=(l=(s=(o=n==null?void 0:n.config)===null||o===void 0?void 0:o.toolConfig)===null||s===void 0?void 0:s.functionCallingConfig)===null||l===void 0?void 0:l.streamFunctionCallArguments,f=(u=(a=n==null?void 0:n.config)===null||a===void 0?void 0:a.automaticFunctionCalling)===null||u===void 0?void 0:u.disable;if(d&&!f)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(n)},this.generateImages=async n=>await this.generateImagesInternal(n).then(o=>{var s;let l;const a=[];if(o!=null&&o.generatedImages)for(const c of o.generatedImages)c&&(c!=null&&c.safetyAttributes)&&((s=c==null?void 0:c.safetyAttributes)===null||s===void 0?void 0:s.contentType)==="Positive Prompt"?l=c==null?void 0:c.safetyAttributes:a.push(c);let u;return l?u={generatedImages:a,positivePromptSafetyAttributes:l,sdkHttpResponse:o.sdkHttpResponse}:u={generatedImages:a,sdkHttpResponse:o.sdkHttpResponse},u}),this.list=async n=>{var o;const a={config:Object.assign(Object.assign({},{queryBase:!0}),n==null?void 0:n.config)};if(this.apiClient.isVertexAI()&&!a.config.queryBase){if(!((o=a.config)===null||o===void 0)&&o.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");a.config.filter="labels.tune-type:*"}return new ie(ee.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(a),a)},this.editImage=async n=>{const o={model:n.model,prompt:n.prompt,referenceImages:[],config:n.config};return n.referenceImages&&n.referenceImages&&(o.referenceImages=n.referenceImages.map(s=>s.toReferenceImageAPI())),await this.editImageInternal(o)},this.upscaleImage=async n=>{let o={numberOfImages:1,mode:"upscale"};n.config&&(o=Object.assign(Object.assign({},o),n.config));const s={model:n.model,image:n.image,upscaleFactor:n.upscaleFactor,config:o};return await this.upscaleImageInternal(s)},this.generateVideos=async n=>{var o,s,l,a,u,c;if((n.prompt||n.image||n.video)&&n.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((o=n.video)===null||o===void 0)&&o.uri&&(!((s=n.video)===null||s===void 0)&&s.videoBytes)?n.video={uri:n.video.uri,mimeType:n.video.mimeType}:!((a=(l=n.source)===null||l===void 0?void 0:l.video)===null||a===void 0)&&a.uri&&(!((c=(u=n.source)===null||u===void 0?void 0:u.video)===null||c===void 0)&&c.videoBytes)&&(n.source.video={uri:n.source.video.uri,mimeType:n.source.video.mimeType})),await this.generateVideosInternal(n)}}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 n,o,s;const l=(n=e.config)===null||n===void 0?void 0:n.tools;if(!l)return e;const a=await Promise.all(l.map(async c=>fe(c)?await c.tool():c)),u={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:a})};if(u.config.tools=a,e.config&&e.config.tools&&no(e.config.tools)){const c=(s=(o=e.config.httpOptions)===null||o===void 0?void 0:o.headers)!==null&&s!==void 0?s:{};let d=Object.assign({},c);Object.keys(d).length===0&&(d=this.apiClient.getDefaultHeaders()),oo(d),u.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:d})}return u}async initAfcToolsMap(e){var n,o,s;const l=new Map;for(const a of(o=(n=e.config)===null||n===void 0?void 0:n.tools)!==null&&o!==void 0?o:[])if(fe(a)){const u=a,c=await u.tool();for(const d of(s=c.functionDeclarations)!==null&&s!==void 0?s:[]){if(!d.name)throw new Error("Function declaration name is required.");if(l.has(d.name))throw new Error(`Duplicate tool declaration name: ${d.name}`);l.set(d.name,u)}}return l}async processAfcStream(e){var n,o,s;const l=(s=(o=(n=e.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||o===void 0?void 0:o.maximumRemoteCalls)!==null&&s!==void 0?s:io;let a=!1,u=0;const c=await this.initAfcToolsMap(e);return function(d,f,p){return O(this,arguments,function*(){for(var h,g,y,C,T,E;u<l;){a&&(u++,a=!1);const x=yield k(d.processParamsMaybeAddMcpUsage(p)),P=yield k(d.generateContentStreamInternal(x)),M=[],b=[];try{for(var _=!0,v=(g=void 0,X(P)),S;S=yield k(v.next()),h=S.done,!h;_=!0){C=S.value,_=!1;const A=C;if(yield yield k(A),A.candidates&&(!((T=A.candidates[0])===null||T===void 0)&&T.content)){b.push(A.candidates[0].content);for(const R of(E=A.candidates[0].content.parts)!==null&&E!==void 0?E:[])if(u<l&&R.functionCall){if(!R.functionCall.name)throw new Error("Function call name was not returned by the model.");if(f.has(R.functionCall.name)){const F=yield k(f.get(R.functionCall.name).callTool([R.functionCall]));M.push(...F)}else throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${f.keys()}, mising tool: ${R.functionCall.name}`)}}}}catch(A){g={error:A}}finally{try{!_&&!h&&(y=v.return)&&(yield k(y.call(v)))}finally{if(g)throw g.error}}if(M.length>0){a=!0;const A=new me;A.candidates=[{content:{role:"user",parts:M}}],yield yield k(A);const R=[];R.push(...b),R.push({role:"user",parts:M});const F=Y(p.contents).concat(R);p.contents=F}else break}})}(this,c,e)}async generateContentInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Wn(this.apiClient,e);return u=I("{model}:generateContent",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Kn(f),h=new me;return Object.assign(h,p),h})}else{const d=$n(this.apiClient,e);return u=I("{model}:generateContent",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Yn(f),h=new me;return Object.assign(h,p),h})}}async generateContentStreamInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Wn(this.apiClient,e);return u=I("{model}:streamGenerateContent?alt=sse",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.requestStream({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}),a.then(function(p){return O(this,arguments,function*(){var h,g,y,C;try{for(var T=!0,E=X(p),_;_=yield k(E.next()),h=_.done,!h;T=!0){C=_.value,T=!1;const v=C,S=Kn(yield k(v.json()));S.sdkHttpResponse={headers:v.headers};const x=new me;Object.assign(x,S),yield yield k(x)}}catch(v){g={error:v}}finally{try{!T&&!h&&(y=E.return)&&(yield k(y.call(E)))}finally{if(g)throw g.error}}})})}else{const d=$n(this.apiClient,e);return u=I("{model}:streamGenerateContent?alt=sse",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.requestStream({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}),a.then(function(p){return O(this,arguments,function*(){var h,g,y,C;try{for(var T=!0,E=X(p),_;_=yield k(E.next()),h=_.done,!h;T=!0){C=_.value,T=!1;const v=C,S=Yn(yield k(v.json()));S.sdkHttpResponse={headers:v.headers};const x=new me;Object.assign(x,S),yield yield k(x)}}catch(v){g={error:v}}finally{try{!T&&!h&&(y=E.return)&&(yield k(y.call(E)))}finally{if(g)throw g.error}}})})}}async embedContent(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=cl(this.apiClient,e);return u=I("{model}:predict",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=pl(f),h=new pn;return Object.assign(h,p),h})}else{const d=dl(this.apiClient,e);return u=I("{model}:batchEmbedContents",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=fl(f),h=new pn;return Object.assign(h,p),h})}}async generateImagesInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Il(this.apiClient,e);return u=I("{model}:predict",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=xl(f),h=new hn;return Object.assign(h,p),h})}else{const d=Sl(this.apiClient,e);return u=I("{model}:predict",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Al(f),h=new hn;return Object.assign(h,p),h})}}async editImageInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=rl(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=ll(c),f=new mi;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=Ia(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=Aa(c),f=new gi;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=sa(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=ra(c),f=new yi;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=fa(this.apiClient,e);return l=I("{model}:predict",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=pa(c),f=new Ti;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async get(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Jl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Ze(f))}else{const d=Bl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Qe(f))}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Zl(this.apiClient,e);return u=I("{models_url}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=ea(f),h=new mn;return Object.assign(h,p),h})}else{const d=Ql(this.apiClient,e);return u=I("{models_url}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=jl(f),h=new mn;return Object.assign(h,p),h})}}async update(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=va(this.apiClient,e);return u=I("{model}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>Ze(f))}else{const d=Ca(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Qe(f))}}async delete(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=nl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=il(f),h=new gn;return Object.assign(h,p),h})}else{const d=tl(this.apiClient,e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=ol(f),h=new gn;return Object.assign(h,p),h})}}async countTokens(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Zr(this.apiClient,e);return u=I("{model}:countTokens",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=el(f),h=new yn;return Object.assign(h,p),h})}else{const d=Qr(this.apiClient,e);return u=I("{model}:countTokens",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=jr(f),h=new yn;return Object.assign(h,p),h})}}async computeTokens(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=$r(this.apiClient,e);return l=I("{model}:computeTokens",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>{const d=Wr(c),f=new _i;return Object.assign(f,d),f})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=kl(this.apiClient,e);return u=I("{model}:predictLongRunning",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Pl(f),h=new Ee;return Object.assign(h,p),h})}else{const d=Rl(this.apiClient,e);return u=I("{model}:predictLongRunning",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Ml(f),h=new Ee;return Object.assign(h,p),h})}}}/**
102
102
  * @license
103
103
  * Copyright 2025 Google LLC
104
104
  * SPDX-License-Identifier: Apache-2.0
105
- */class yu extends Q{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){const n=e.operation,o=e.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=n.name.split("/operations/")[0];let l;o&&"httpOptions"in o&&(l=o.httpOptions);const a=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:s,config:{httpOptions:l}});return n._fromAPIResponse({apiResponse:a,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:n.name,config:o});return n._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async get(e){const n=e.operation,o=e.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=n.name.split("/operations/")[0];let l;o&&"httpOptions"in o&&(l=o.httpOptions);const a=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:s,config:{httpOptions:l}});return n._fromAPIResponse({apiResponse:a,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:n.name,config:o});return n._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async getVideosOperationInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=ui(e);return u=I("{operationName}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a}else{const d=ai(e);return u=I("{operationName}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a}}async fetchPredictVideosOperationInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=ti(e);return l=I("{resourceName}:fetchPredictOperation",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s}else throw new Error("This method is only supported by the Vertex AI.")}}/**
105
+ */class yu extends Z{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){const n=e.operation,o=e.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=n.name.split("/operations/")[0];let l;o&&"httpOptions"in o&&(l=o.httpOptions);const a=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:s,config:{httpOptions:l}});return n._fromAPIResponse({apiResponse:a,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:n.name,config:o});return n._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async get(e){const n=e.operation,o=e.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=n.name.split("/operations/")[0];let l;o&&"httpOptions"in o&&(l=o.httpOptions);const a=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:s,config:{httpOptions:l}});return n._fromAPIResponse({apiResponse:a,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:n.name,config:o});return n._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async getVideosOperationInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=ui(e);return u=I("{operationName}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json()),a}else{const d=ai(e);return u=I("{operationName}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a}}async fetchPredictVideosOperationInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=ti(e);return l=I("{resourceName}:fetchPredictOperation",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s}else throw new Error("This method is only supported by the Vertex AI.")}}/**
106
106
  * @license
107
107
  * Copyright 2025 Google LLC
108
108
  * SPDX-License-Identifier: Apache-2.0
@@ -110,7 +110,7 @@
110
110
  * @license
111
111
  * Copyright 2025 Google LLC
112
112
  * SPDX-License-Identifier: Apache-2.0
113
- */function Ru(t){const e=[];for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const o=t[n];if(typeof o=="object"&&o!=null&&Object.keys(o).length>0){const s=Object.keys(o).map(l=>`${n}.${l}`);e.push(...s)}else e.push(n)}return e.join(",")}function ku(t,e){let n=null;const o=t.bidiGenerateContentSetup;if(typeof o=="object"&&o!==null&&"setup"in o){const l=o.setup;typeof l=="object"&&l!==null?(t.bidiGenerateContentSetup=l,n=l):delete t.bidiGenerateContentSetup}else o!==void 0&&delete t.bidiGenerateContentSetup;const s=t.fieldMask;if(n){const l=Ru(n);if(Array.isArray(e==null?void 0:e.lockAdditionalFields)&&(e==null?void 0:e.lockAdditionalFields.length)===0)l?t.fieldMask=l:delete t.fieldMask;else if(e!=null&&e.lockAdditionalFields&&e.lockAdditionalFields.length>0&&s!==null&&Array.isArray(s)&&s.length>0){const a=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];s.length>0&&(u=s.map(d=>a.includes(d)?`generationConfig.${d}`:d));const c=[];l&&c.push(l),u.length>0&&c.push(...u),c.length>0?t.fieldMask=c.join(","):delete t.fieldMask}else delete t.fieldMask}else s!==null&&Array.isArray(s)&&s.length>0?t.fieldMask=s.join(","):delete t.fieldMask;return t}class Du extends Q{constructor(e){super(),this.apiClient=e}async create(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=Cu(this.apiClient,e);l=I("auth_tokens",u._url),a=u._query,delete u.config,delete u._url,delete u._query;const c=ku(u,e.config);return s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(d=>d.json()),s.then(d=>d)}}}/**
113
+ */function Ru(t){const e=[];for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const o=t[n];if(typeof o=="object"&&o!=null&&Object.keys(o).length>0){const s=Object.keys(o).map(l=>`${n}.${l}`);e.push(...s)}else e.push(n)}return e.join(",")}function ku(t,e){let n=null;const o=t.bidiGenerateContentSetup;if(typeof o=="object"&&o!==null&&"setup"in o){const l=o.setup;typeof l=="object"&&l!==null?(t.bidiGenerateContentSetup=l,n=l):delete t.bidiGenerateContentSetup}else o!==void 0&&delete t.bidiGenerateContentSetup;const s=t.fieldMask;if(n){const l=Ru(n);if(Array.isArray(e==null?void 0:e.lockAdditionalFields)&&(e==null?void 0:e.lockAdditionalFields.length)===0)l?t.fieldMask=l:delete t.fieldMask;else if(e!=null&&e.lockAdditionalFields&&e.lockAdditionalFields.length>0&&s!==null&&Array.isArray(s)&&s.length>0){const a=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];s.length>0&&(u=s.map(d=>a.includes(d)?`generationConfig.${d}`:d));const c=[];l&&c.push(l),u.length>0&&c.push(...u),c.length>0?t.fieldMask=c.join(","):delete t.fieldMask}else delete t.fieldMask}else s!==null&&Array.isArray(s)&&s.length>0?t.fieldMask=s.join(","):delete t.fieldMask;return t}class Du extends Z{constructor(e){super(),this.apiClient=e}async create(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=Cu(this.apiClient,e);l=I("auth_tokens",u._url),a=u._query,delete u.config,delete u._url,delete u._query;const c=ku(u,e.config);return s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(d=>d.json()),s.then(d=>d)}}}/**
114
114
  * @license
115
115
  * Copyright 2025 Google LLC
116
116
  * SPDX-License-Identifier: Apache-2.0
@@ -118,11 +118,11 @@
118
118
  * @license
119
119
  * Copyright 2025 Google LLC
120
120
  * SPDX-License-Identifier: Apache-2.0
121
- */class qu extends Q{constructor(e){super(),this.apiClient=e,this.list=async n=>new oe(j.PAGED_ITEM_DOCUMENTS,o=>this.listInternal({parent:n.parent,config:o.config}),await this.listInternal(n),n)}async get(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Lu(e);return l=I("{name}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async delete(e){var n,o;let s="",l={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const a=Uu(e);s=I("{name}",a._url),l=a._query,delete a._url,delete a._query,await this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Gu(e);return l=I("{parent}/documents",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=Vu(c),f=new Ei;return Object.assign(f,d),f})}}}/**
121
+ */class qu extends Z{constructor(e){super(),this.apiClient=e,this.list=async n=>new ie(ee.PAGED_ITEM_DOCUMENTS,o=>this.listInternal({parent:n.parent,config:o.config}),await this.listInternal(n),n)}async get(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Lu(e);return l=I("{name}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async delete(e){var n,o;let s="",l={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const a=Uu(e);s=I("{name}",a._url),l=a._query,delete a._url,delete a._query,await this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Gu(e);return l=I("{parent}/documents",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=Vu(c),f=new Ei;return Object.assign(f,d),f})}}}/**
122
122
  * @license
123
123
  * Copyright 2025 Google LLC
124
124
  * SPDX-License-Identifier: Apache-2.0
125
- */class Hu extends Q{constructor(e,n=new qu(e)){super(),this.apiClient=e,this.documents=n,this.list=async(o={})=>new oe(j.PAGED_ITEM_FILE_SEARCH_STORES,s=>this.listInternal(s),await this.listInternal(o),o)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=ka(e);return l=I("fileSearchStores",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async get(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ua(e);return l=I("{name}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async delete(e){var n,o;let s="",l={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const a=ba(e);s=I("{name}",a._url),l=a._query,delete a._url,delete a._query,await this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ha(e);return l=I("fileSearchStores",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=Ba(c),f=new Ci;return Object.assign(f,d),f})}}async uploadToFileSearchStoreInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ja(e);return l=I("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=$a(c),f=new vi;return Object.assign(f,d),f})}}async importFile(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ga(e);return l=I("{file_search_store_name}:importFile",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=Fa(c),f=new Je;return Object.assign(f,d),f})}}}/**
125
+ */class Hu extends Z{constructor(e,n=new qu(e)){super(),this.apiClient=e,this.documents=n,this.list=async(o={})=>new ie(ee.PAGED_ITEM_FILE_SEARCH_STORES,s=>this.listInternal(s),await this.listInternal(o),o)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=ka(e);return l=I("fileSearchStores",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async get(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ua(e);return l=I("{name}",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>c)}}async delete(e){var n,o;let s="",l={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const a=ba(e);s=I("{name}",a._url),l=a._query,delete a._url,delete a._query,await this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ha(e);return l=I("fileSearchStores",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=Ba(c),f=new Ci;return Object.assign(f,d),f})}}async uploadToFileSearchStoreInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ja(e);return l=I("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=$a(c),f=new vi;return Object.assign(f,d),f})}}async importFile(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ga(e);return l=I("{file_search_store_name}:importFile",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json()),s.then(c=>{const d=Fa(c),f=new Je;return Object.assign(f,d),f})}}}/**
126
126
  * @license
127
127
  * Copyright 2025 Google LLC
128
128
  * SPDX-License-Identifier: Apache-2.0
@@ -134,11 +134,11 @@
134
134
  * @license
135
135
  * Copyright 2025 Google LLC
136
136
  * SPDX-License-Identifier: Apache-2.0
137
- */class Y extends Error{}class J extends Y{constructor(e,n,o,s){super(`${J.makeMessage(e,n,o)}`),this.status=e,this.headers=s,this.error=n}static makeMessage(e,n,o){const s=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):o;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,n,o,s){if(!e||!s)return new Me({message:o,cause:nt(n)});const l=n;return e===400?new co(e,l,o,s):e===401?new fo(e,l,o,s):e===403?new po(e,l,o,s):e===404?new ho(e,l,o,s):e===409?new mo(e,l,o,s):e===422?new go(e,l,o,s):e===429?new yo(e,l,o,s):e>=500?new To(e,l,o,s):new J(e,l,o,s)}}class ot extends J{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Me extends J{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class uo extends Me{constructor({message:e}={}){super({message:e??"Request timed out."})}}class co extends J{}class fo extends J{}class po extends J{}class ho extends J{}class mo extends J{}class go extends J{}class yo extends J{}class To extends J{}/**
137
+ */class K extends Error{}class J extends K{constructor(e,n,o,s){super(`${J.makeMessage(e,n,o)}`),this.status=e,this.headers=s,this.error=n}static makeMessage(e,n,o){const s=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):o;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,n,o,s){if(!e||!s)return new Me({message:o,cause:nt(n)});const l=n;return e===400?new co(e,l,o,s):e===401?new fo(e,l,o,s):e===403?new po(e,l,o,s):e===404?new ho(e,l,o,s):e===409?new mo(e,l,o,s):e===422?new go(e,l,o,s):e===429?new yo(e,l,o,s):e>=500?new To(e,l,o,s):new J(e,l,o,s)}}class ot extends J{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class Me extends J{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class uo extends Me{constructor({message:e}={}){super({message:e??"Request timed out."})}}class co extends J{}class fo extends J{}class po extends J{}class ho extends J{}class mo extends J{}class go extends J{}class yo extends J{}class To extends J{}/**
138
138
  * @license
139
139
  * Copyright 2025 Google LLC
140
140
  * SPDX-License-Identifier: Apache-2.0
141
- */const Ju=/^[a-z][a-z0-9+.-]*:/i,$u=t=>Ju.test(t);let it=t=>(it=Array.isArray,it(t));const _o=it;function Wu(t){if(!t)return!0;for(const e in t)return!1;return!0}function Yu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const Ku=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new Y(`${t} must be an integer`);if(e<0)throw new Y(`${t} must be a positive integer`);return e},zu=t=>{try{return JSON.parse(t)}catch{return}};/**
141
+ */const Ju=/^[a-z][a-z0-9+.-]*:/i,$u=t=>Ju.test(t);let it=t=>(it=Array.isArray,it(t));const _o=it;function Wu(t){if(!t)return!0;for(const e in t)return!1;return!0}function Yu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const Ku=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new K(`${t} must be an integer`);if(e<0)throw new K(`${t} must be a positive integer`);return e},zu=t=>{try{return JSON.parse(t)}catch{return}};/**
142
142
  * @license
143
143
  * Copyright 2025 Google LLC
144
144
  * SPDX-License-Identifier: Apache-2.0
@@ -166,7 +166,7 @@
166
166
  * @license
167
167
  * Copyright 2025 Google LLC
168
168
  * SPDX-License-Identifier: Apache-2.0
169
- */const Ao=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",rd=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Ao(t),ld=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function ad(t,e,n){if(Io(),t=await t,rd(t))return t instanceof File?t:st([await t.arrayBuffer()],t.name);if(ld(t)){const s=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),st(await rt(s),e,n)}const o=await rt(t);if(e||(e=id(t)),!(n!=null&&n.type)){const s=o.find(l=>typeof l=="object"&&"type"in l&&l.type);typeof s=="string"&&(n=Object.assign(Object.assign({},n),{type:s}))}return st(o,e,n)}async function rt(t){var e,n,o,s,l;let a=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)a.push(t);else if(Ao(t))a.push(t instanceof Blob?t:await t.arrayBuffer());else if(sd(t))try{for(var u=!0,c=O(t),d;d=await c.next(),e=d.done,!e;u=!0){s=d.value,u=!1;const f=s;a.push(...await rt(f))}}catch(f){n={error:f}}finally{try{!u&&!e&&(o=c.return)&&await o.call(c)}finally{if(n)throw n.error}}else{const f=(l=t==null?void 0:t.constructor)===null||l===void 0?void 0:l.name;throw new Error(`Unexpected data type: ${typeof t}${f?`; constructor: ${f}`:""}${ud(t)}`)}return a}function ud(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}/**
169
+ */const Ao=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",rd=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Ao(t),ld=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function ad(t,e,n){if(Io(),t=await t,rd(t))return t instanceof File?t:st([await t.arrayBuffer()],t.name);if(ld(t)){const s=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),st(await rt(s),e,n)}const o=await rt(t);if(e||(e=id(t)),!(n!=null&&n.type)){const s=o.find(l=>typeof l=="object"&&"type"in l&&l.type);typeof s=="string"&&(n=Object.assign(Object.assign({},n),{type:s}))}return st(o,e,n)}async function rt(t){var e,n,o,s,l;let a=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)a.push(t);else if(Ao(t))a.push(t instanceof Blob?t:await t.arrayBuffer());else if(sd(t))try{for(var u=!0,c=X(t),d;d=await c.next(),e=d.done,!e;u=!0){s=d.value,u=!1;const f=s;a.push(...await rt(f))}}catch(f){n={error:f}}finally{try{!u&&!e&&(o=c.return)&&await o.call(c)}finally{if(n)throw n.error}}else{const f=(l=t==null?void 0:t.constructor)===null||l===void 0?void 0:l.name;throw new Error(`Unexpected data type: ${typeof t}${f?`; constructor: ${f}`:""}${ud(t)}`)}return a}function ud(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}/**
170
170
  * @license
171
171
  * Copyright 2025 Google LLC
172
172
  * SPDX-License-Identifier: Apache-2.0
@@ -174,7 +174,7 @@
174
174
  * @license
175
175
  * Copyright 2025 Google LLC
176
176
  * SPDX-License-Identifier: Apache-2.0
177
- */function wo(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const No=Object.freeze(Object.create(null)),Re=((t=wo)=>function(n,...o){if(n.length===1)return n[0];let s=!1;const l=[],a=n.reduce((f,p,h)=>{var g,y,C;/[?#]/.test(p)&&(s=!0);const T=o[h];let E=(s?encodeURIComponent:t)(""+T);return h!==o.length&&(T==null||typeof T=="object"&&T.toString===((C=Object.getPrototypeOf((y=Object.getPrototypeOf((g=T.hasOwnProperty)!==null&&g!==void 0?g:No))!==null&&y!==void 0?y:No))===null||C===void 0?void 0:C.toString))&&(E=T+"",l.push({start:f.length+p.length,length:E.length,error:`Value of type ${Object.prototype.toString.call(T).slice(8,-1)} is not a valid path parameter`})),f+p+(h===o.length?"":E)},""),u=a.split(/[?#]/,1)[0],c=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let d;for(;(d=c.exec(u))!==null;)l.push({start:d.index,length:d[0].length,error:`Value "${d[0]}" can't be safely passed as a path parameter`});if(l.sort((f,p)=>f.start-p.start),l.length>0){let f=0;const p=l.reduce((h,g)=>{const y=" ".repeat(g.start-f),C="^".repeat(g.length);return f=g.start+g.length,h+y+C},"");throw new Y(`Path parameters result in path with invalid segments:
177
+ */function wo(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const No=Object.freeze(Object.create(null)),Re=((t=wo)=>function(n,...o){if(n.length===1)return n[0];let s=!1;const l=[],a=n.reduce((f,p,h)=>{var g,y,C;/[?#]/.test(p)&&(s=!0);const T=o[h];let E=(s?encodeURIComponent:t)(""+T);return h!==o.length&&(T==null||typeof T=="object"&&T.toString===((C=Object.getPrototypeOf((y=Object.getPrototypeOf((g=T.hasOwnProperty)!==null&&g!==void 0?g:No))!==null&&y!==void 0?y:No))===null||C===void 0?void 0:C.toString))&&(E=T+"",l.push({start:f.length+p.length,length:E.length,error:`Value of type ${Object.prototype.toString.call(T).slice(8,-1)} is not a valid path parameter`})),f+p+(h===o.length?"":E)},""),u=a.split(/[?#]/,1)[0],c=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let d;for(;(d=c.exec(u))!==null;)l.push({start:d.index,length:d[0].length,error:`Value "${d[0]}" can't be safely passed as a path parameter`});if(l.sort((f,p)=>f.start-p.start),l.length>0){let f=0;const p=l.reduce((h,g)=>{const y=" ".repeat(g.start-f),C="^".repeat(g.length);return f=g.start+g.length,h+y+C},"");throw new K(`Path parameters result in path with invalid segments:
178
178
  ${l.map(h=>h.error).join(`
179
179
  `)}
180
180
  ${a}
@@ -182,7 +182,7 @@ ${p}`)}return a})(wo);/**
182
182
  * @license
183
183
  * Copyright 2025 Google LLC
184
184
  * SPDX-License-Identifier: Apache-2.0
185
- */class Mo extends xo{create(e,n){var o;const{api_version:s=this._client.apiVersion}=e,l=Se(e,["api_version"]);if("model"in l&&"agent_config"in l)throw new Y("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in l&&"generation_config"in l)throw new Y("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(Re`/${s}/interactions`,Object.assign(Object.assign({body:l},n),{stream:(o=e.stream)!==null&&o!==void 0?o:!1}))}delete(e,n={},o){const{api_version:s=this._client.apiVersion}=n??{};return this._client.delete(Re`/${s}/interactions/${e}`,o)}cancel(e,n={},o){const{api_version:s=this._client.apiVersion}=n??{};return this._client.post(Re`/${s}/interactions/${e}/cancel`,o)}get(e,n={},o){var s;const l=n??{},{api_version:a=this._client.apiVersion}=l,u=Se(l,["api_version"]);return this._client.get(Re`/${a}/interactions/${e}`,Object.assign(Object.assign({query:u},o),{stream:(s=n==null?void 0:n.stream)!==null&&s!==void 0?s:!1}))}}Mo._key=Object.freeze(["interactions"]);class Po extends Mo{}/**
185
+ */class Mo extends xo{create(e,n){var o;const{api_version:s=this._client.apiVersion}=e,l=Se(e,["api_version"]);if("model"in l&&"agent_config"in l)throw new K("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in l&&"generation_config"in l)throw new K("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(Re`/${s}/interactions`,Object.assign(Object.assign({body:l},n),{stream:(o=e.stream)!==null&&o!==void 0?o:!1}))}delete(e,n={},o){const{api_version:s=this._client.apiVersion}=n??{};return this._client.delete(Re`/${s}/interactions/${e}`,o)}cancel(e,n={},o){const{api_version:s=this._client.apiVersion}=n??{};return this._client.post(Re`/${s}/interactions/${e}/cancel`,o)}get(e,n={},o){var s;const l=n??{},{api_version:a=this._client.apiVersion}=l,u=Se(l,["api_version"]);return this._client.get(Re`/${a}/interactions/${e}`,Object.assign(Object.assign({query:u},o),{stream:(s=n==null?void 0:n.stream)!==null&&s!==void 0?s:!1}))}}Mo._key=Object.freeze(["interactions"]);class Po extends Mo{}/**
186
186
  * @license
187
187
  * Copyright 2025 Google LLC
188
188
  * SPDX-License-Identifier: Apache-2.0
@@ -196,17 +196,17 @@ ${p}`)}return a})(wo);/**
196
196
  * @license
197
197
  * Copyright 2025 Google LLC
198
198
  * SPDX-License-Identifier: Apache-2.0
199
- */const Ue={off:0,error:200,warn:300,info:400,debug:500},ko=(t,e,n)=>{if(t){if(Yu(Ue,t))return t;$(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(Ue))}`)}};function ge(){}function Le(t,e,n){return!e||Ue[t]>Ue[n]?ge:e[t].bind(e)}const pd={error:ge,warn:ge,info:ge,debug:ge};let Do=new WeakMap;function $(t){var e;const n=t.logger,o=(e=t.logLevel)!==null&&e!==void 0?e:"off";if(!n)return pd;const s=Do.get(n);if(s&&s[0]===o)return s[1];const l={error:Le("error",n,o),warn:Le("warn",n,o),info:Le("info",n,o),debug:Le("debug",n,o)};return Do.set(n,[o,l]),l}const ie=t=>(t.options&&(t.options=Object.assign({},t.options),delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="x-goog-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);/**
199
+ */const Ue={off:0,error:200,warn:300,info:400,debug:500},ko=(t,e,n)=>{if(t){if(Yu(Ue,t))return t;$(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(Ue))}`)}};function ge(){}function Le(t,e,n){return!e||Ue[t]>Ue[n]?ge:e[t].bind(e)}const pd={error:ge,warn:ge,info:ge,debug:ge};let Do=new WeakMap;function $(t){var e;const n=t.logger,o=(e=t.logLevel)!==null&&e!==void 0?e:"off";if(!n)return pd;const s=Do.get(n);if(s&&s[0]===o)return s[1];const l={error:Le("error",n,o),warn:Le("warn",n,o),info:Le("info",n,o),debug:Le("debug",n,o)};return Do.set(n,[o,l]),l}const se=t=>(t.options&&(t.options=Object.assign({},t.options),delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="x-goog-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);/**
200
200
  * @license
201
201
  * Copyright 2025 Google LLC
202
202
  * SPDX-License-Identifier: Apache-2.0
203
- */class he{constructor(e,n,o){this.iterator=e,this.controller=n,this.client=o}static fromSSEResponse(e,n,o){let s=!1;const l=o?$(o):console;function a(){return z(this,arguments,function*(){var c,d,f,p;if(s)throw new Y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let h=!1;try{try{for(var g=!0,y=O(hd(e,n)),C;C=yield k(y.next()),c=C.done,!c;g=!0){p=C.value,g=!1;const T=p;if(!h)if(T.data.startsWith("[DONE]")){h=!0;continue}else try{yield yield k(JSON.parse(T.data))}catch(E){throw l.error("Could not parse message into JSON:",T.data),l.error("From chunk:",T.raw),E}}}catch(T){d={error:T}}finally{try{!g&&!c&&(f=y.return)&&(yield k(f.call(y)))}finally{if(d)throw d.error}}h=!0}catch(T){if(tt(T))return yield k(void 0);throw T}finally{h||n.abort()}})}return new he(a,n,o)}static fromReadableStream(e,n,o){let s=!1;function l(){return z(this,arguments,function*(){var c,d,f,p;const h=new be,g=So(e);try{for(var y=!0,C=O(g),T;T=yield k(C.next()),c=T.done,!c;y=!0){p=T.value,y=!1;const E=p;for(const _ of h.decode(E))yield yield k(_)}}catch(E){d={error:E}}finally{try{!y&&!c&&(f=C.return)&&(yield k(f.call(C)))}finally{if(d)throw d.error}}for(const E of h.flush())yield yield k(E)})}function a(){return z(this,arguments,function*(){var c,d,f,p;if(s)throw new Y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let h=!1;try{try{for(var g=!0,y=O(l()),C;C=yield k(y.next()),c=C.done,!c;g=!0){p=C.value,g=!1;const T=p;h||T&&(yield yield k(JSON.parse(T)))}}catch(T){d={error:T}}finally{try{!g&&!c&&(f=y.return)&&(yield k(f.call(y)))}finally{if(d)throw d.error}}h=!0}catch(T){if(tt(T))return yield k(void 0);throw T}finally{h||n.abort()}})}return new he(a,n,o)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],n=[],o=this.iterator(),s=l=>({next:()=>{if(l.length===0){const a=o.next();e.push(a),n.push(a)}return l.shift()}});return[new he(()=>s(e),this.controller,this.client),new he(()=>s(n),this.controller,this.client)]}toReadableStream(){const e=this;let n;return vo({async start(){n=e[Symbol.asyncIterator]()},async pull(o){try{const{value:s,done:l}=await n.next();if(l)return o.close();const a=lt(JSON.stringify(s)+`
204
- `);o.enqueue(a)}catch(s){o.error(s)}},async cancel(){var o;await((o=n.return)===null||o===void 0?void 0:o.call(n))}})}}function hd(t,e){return z(this,arguments,function*(){var o,s,l,a;if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new Y("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new Y("Attempted to iterate over a response with no body");const u=new gd,c=new be,d=So(t.body);try{for(var f=!0,p=O(md(d)),h;h=yield k(p.next()),o=h.done,!o;f=!0){a=h.value,f=!1;const g=a;for(const y of c.decode(g)){const C=u.decode(y);C&&(yield yield k(C))}}}catch(g){s={error:g}}finally{try{!f&&!o&&(l=p.return)&&(yield k(l.call(p)))}finally{if(s)throw s.error}}for(const g of c.flush()){const y=u.decode(g);y&&(yield yield k(y))}})}function md(t){return z(this,arguments,function*(){var n,o,s,l;let a=new Uint8Array;try{for(var u=!0,c=O(t),d;d=yield k(c.next()),n=d.done,!n;u=!0){l=d.value,u=!1;const f=l;if(f==null)continue;const p=f instanceof ArrayBuffer?new Uint8Array(f):typeof f=="string"?lt(f):f;let h=new Uint8Array(a.length+p.length);h.set(a),h.set(p,a.length),a=h;let g;for(;(g=fd(a))!==-1;)yield yield k(a.slice(0,g)),a=a.slice(g)}}catch(f){o={error:f}}finally{try{!u&&!n&&(s=c.return)&&(yield k(s.call(c)))}finally{if(o)throw o.error}}a.length>0&&(yield yield k(a))})}class gd{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const l={event:this.event,data:this.data.join(`
203
+ */class he{constructor(e,n,o){this.iterator=e,this.controller=n,this.client=o}static fromSSEResponse(e,n,o){let s=!1;const l=o?$(o):console;function a(){return O(this,arguments,function*(){var c,d,f,p;if(s)throw new K("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let h=!1;try{try{for(var g=!0,y=X(hd(e,n)),C;C=yield k(y.next()),c=C.done,!c;g=!0){p=C.value,g=!1;const T=p;if(!h)if(T.data.startsWith("[DONE]")){h=!0;continue}else try{yield yield k(JSON.parse(T.data))}catch(E){throw l.error("Could not parse message into JSON:",T.data),l.error("From chunk:",T.raw),E}}}catch(T){d={error:T}}finally{try{!g&&!c&&(f=y.return)&&(yield k(f.call(y)))}finally{if(d)throw d.error}}h=!0}catch(T){if(tt(T))return yield k(void 0);throw T}finally{h||n.abort()}})}return new he(a,n,o)}static fromReadableStream(e,n,o){let s=!1;function l(){return O(this,arguments,function*(){var c,d,f,p;const h=new be,g=So(e);try{for(var y=!0,C=X(g),T;T=yield k(C.next()),c=T.done,!c;y=!0){p=T.value,y=!1;const E=p;for(const _ of h.decode(E))yield yield k(_)}}catch(E){d={error:E}}finally{try{!y&&!c&&(f=C.return)&&(yield k(f.call(C)))}finally{if(d)throw d.error}}for(const E of h.flush())yield yield k(E)})}function a(){return O(this,arguments,function*(){var c,d,f,p;if(s)throw new K("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let h=!1;try{try{for(var g=!0,y=X(l()),C;C=yield k(y.next()),c=C.done,!c;g=!0){p=C.value,g=!1;const T=p;h||T&&(yield yield k(JSON.parse(T)))}}catch(T){d={error:T}}finally{try{!g&&!c&&(f=y.return)&&(yield k(f.call(y)))}finally{if(d)throw d.error}}h=!0}catch(T){if(tt(T))return yield k(void 0);throw T}finally{h||n.abort()}})}return new he(a,n,o)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],n=[],o=this.iterator(),s=l=>({next:()=>{if(l.length===0){const a=o.next();e.push(a),n.push(a)}return l.shift()}});return[new he(()=>s(e),this.controller,this.client),new he(()=>s(n),this.controller,this.client)]}toReadableStream(){const e=this;let n;return vo({async start(){n=e[Symbol.asyncIterator]()},async pull(o){try{const{value:s,done:l}=await n.next();if(l)return o.close();const a=lt(JSON.stringify(s)+`
204
+ `);o.enqueue(a)}catch(s){o.error(s)}},async cancel(){var o;await((o=n.return)===null||o===void 0?void 0:o.call(n))}})}}function hd(t,e){return O(this,arguments,function*(){var o,s,l,a;if(!t.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new K("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new K("Attempted to iterate over a response with no body");const u=new gd,c=new be,d=So(t.body);try{for(var f=!0,p=X(md(d)),h;h=yield k(p.next()),o=h.done,!o;f=!0){a=h.value,f=!1;const g=a;for(const y of c.decode(g)){const C=u.decode(y);C&&(yield yield k(C))}}}catch(g){s={error:g}}finally{try{!f&&!o&&(l=p.return)&&(yield k(l.call(p)))}finally{if(s)throw s.error}}for(const g of c.flush()){const y=u.decode(g);y&&(yield yield k(y))}})}function md(t){return O(this,arguments,function*(){var n,o,s,l;let a=new Uint8Array;try{for(var u=!0,c=X(t),d;d=yield k(c.next()),n=d.done,!n;u=!0){l=d.value,u=!1;const f=l;if(f==null)continue;const p=f instanceof ArrayBuffer?new Uint8Array(f):typeof f=="string"?lt(f):f;let h=new Uint8Array(a.length+p.length);h.set(a),h.set(p,a.length),a=h;let g;for(;(g=fd(a))!==-1;)yield yield k(a.slice(0,g)),a=a.slice(g)}}catch(f){o={error:f}}finally{try{!u&&!n&&(s=c.return)&&(yield k(s.call(c)))}finally{if(o)throw o.error}}a.length>0&&(yield yield k(a))})}class gd{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const l={event:this.event,data:this.data.join(`
205
205
  `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],l}if(this.chunks.push(e),e.startsWith(":"))return null;let[n,o,s]=yd(e,":");return s.startsWith(" ")&&(s=s.substring(1)),n==="event"?this.event=s:n==="data"&&this.data.push(s),null}}function yd(t,e){const n=t.indexOf(e);return n!==-1?[t.substring(0,n),e,t.substring(n+e.length)]:[t,"",""]}/**
206
206
  * @license
207
207
  * Copyright 2025 Google LLC
208
208
  * SPDX-License-Identifier: Apache-2.0
209
- */async function Td(t,e){const{response:n,requestLogID:o,retryOfRequestLogID:s,startTime:l}=e,a=await(async()=>{var u;if(e.options.stream)return $(t).debug("response",n.status,n.url,n.headers,n.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(n,e.controller,t):he.fromSSEResponse(n,e.controller,t);if(n.status===204)return null;if(e.options.__binaryResponse)return n;const c=n.headers.get("content-type"),d=(u=c==null?void 0:c.split(";")[0])===null||u===void 0?void 0:u.trim();return(d==null?void 0:d.includes("application/json"))||(d==null?void 0:d.endsWith("+json"))?await n.json():await n.text()})();return $(t).debug(`[${o}] response parsed`,ie({retryOfRequestLogID:s,url:n.url,status:n.status,body:a,durationMs:Date.now()-l})),a}/**
209
+ */async function Td(t,e){const{response:n,requestLogID:o,retryOfRequestLogID:s,startTime:l}=e,a=await(async()=>{var u;if(e.options.stream)return $(t).debug("response",n.status,n.url,n.headers,n.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(n,e.controller,t):he.fromSSEResponse(n,e.controller,t);if(n.status===204)return null;if(e.options.__binaryResponse)return n;const c=n.headers.get("content-type"),d=(u=c==null?void 0:c.split(";")[0])===null||u===void 0?void 0:u.trim();return(d==null?void 0:d.includes("application/json"))||(d==null?void 0:d.endsWith("+json"))?await n.json():await n.text()})();return $(t).debug(`[${o}] response parsed`,se({retryOfRequestLogID:s,url:n.url,status:n.status,body:a,durationMs:Date.now()-l})),a}/**
210
210
  * @license
211
211
  * Copyright 2025 Google LLC
212
212
  * SPDX-License-Identifier: Apache-2.0
@@ -222,7 +222,7 @@ ${p}`)}return a})(wo);/**
222
222
  * @license
223
223
  * Copyright 2025 Google LLC
224
224
  * SPDX-License-Identifier: Apache-2.0
225
- */var Uo;class Fe{constructor(e){var n,o,s,l,a,u,c,{baseURL:d=ut("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:f=(n=ut("GEMINI_API_KEY"))!==null&&n!==void 0?n:null,apiVersion:p="v1beta"}=e,h=Se(e,["baseURL","apiKey","apiVersion"]);const g=Object.assign(Object.assign({apiKey:f,apiVersion:p},h),{baseURL:d||"https://generativelanguage.googleapis.com"});this.baseURL=g.baseURL,this.timeout=(o=g.timeout)!==null&&o!==void 0?o:Fe.DEFAULT_TIMEOUT,this.logger=(s=g.logger)!==null&&s!==void 0?s:console;const y="warn";this.logLevel=y,this.logLevel=(a=(l=ko(g.logLevel,"ClientOptions.logLevel",this))!==null&&l!==void 0?l:ko(ut("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&a!==void 0?a:y,this.fetchOptions=g.fetchOptions,this.maxRetries=(u=g.maxRetries)!==null&&u!==void 0?u:2,this.fetch=(c=g.fetch)!==null&&c!==void 0?c:ed(),this.encoder=od,this._options=g,this.apiKey=f,this.apiVersion=p,this.clientAdapter=g.clientAdapter}withOptions(e){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),e))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:n}){if(!(e.has("authorization")||e.has("x-goog-api-key"))&&!(this.apiKey&&e.get("x-goog-api-key"))&&!n.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(e){const n=ye([e.headers]);if(!(n.values.has("authorization")||n.values.has("x-goog-api-key"))){if(this.apiKey)return ye([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return ye([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return Object.entries(e).filter(([n,o])=>typeof o<"u").map(([n,o])=>{if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return`${encodeURIComponent(n)}=${encodeURIComponent(o)}`;if(o===null)return`${encodeURIComponent(n)}=`;throw new Y(`Cannot stringify type ${typeof o}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${pe}`}defaultIdempotencyKey(){return`stainless-node-retry-${Bu()}`}makeStatusError(e,n,o,s){return J.generate(e,n,o,s)}buildURL(e,n,o){const s=!this.baseURLOverridden()&&o||this.baseURL,l=$u(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),a=this.defaultQuery();return Wu(a)||(n=Object.assign(Object.assign({},a),n)),typeof n=="object"&&n&&!Array.isArray(n)&&(l.search=this.stringifyQuery(n)),l.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){const n=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${n}`}}async prepareRequest(e,{url:n,options:o}){}get(e,n){return this.methodRequest("get",e,n)}post(e,n){return this.methodRequest("post",e,n)}patch(e,n){return this.methodRequest("patch",e,n)}put(e,n){return this.methodRequest("put",e,n)}delete(e,n){return this.methodRequest("delete",e,n)}methodRequest(e,n,o){return this.request(Promise.resolve(o).then(s=>Object.assign({method:e,path:n},s)))}request(e,n=null){return new at(this,this.makeRequest(e,n,void 0))}async makeRequest(e,n,o){var s,l,a;const u=await e,c=(s=u.maxRetries)!==null&&s!==void 0?s:this.maxRetries;n==null&&(n=c),await this.prepareOptions(u);const{req:d,url:f,timeout:p}=await this.buildRequest(u,{retryCount:c-n});await this.prepareRequest(d,{url:f,options:u});const h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),g=o===void 0?"":`, retryOf: ${o}`,y=Date.now();if($(this).debug(`[${h}] sending request`,ie({retryOfRequestLogID:o,method:u.method,url:f,options:u,headers:d.headers})),!((l=u.signal)===null||l===void 0)&&l.aborted)throw new ot;const C=new AbortController,T=await this.fetchWithTimeout(f,d,p,C).catch(nt),E=Date.now();if(T instanceof globalThis.Error){const v=`retrying, ${n} attempts remaining`;if(!((a=u.signal)===null||a===void 0)&&a.aborted)throw new ot;const S=tt(T)||/timed? ?out/i.test(String(T)+("cause"in T?String(T.cause):""));if(n)return $(this).info(`[${h}] connection ${S?"timed out":"failed"} - ${v}`),$(this).debug(`[${h}] connection ${S?"timed out":"failed"} (${v})`,ie({retryOfRequestLogID:o,url:f,durationMs:E-y,message:T.message})),this.retryRequest(u,n,o??h);throw $(this).info(`[${h}] connection ${S?"timed out":"failed"} - error; no more retries left`),$(this).debug(`[${h}] connection ${S?"timed out":"failed"} (error; no more retries left)`,ie({retryOfRequestLogID:o,url:f,durationMs:E-y,message:T.message})),S?new uo:new Me({cause:T})}const _=`[${h}${g}] ${d.method} ${f} ${T.ok?"succeeded":"failed"} with status ${T.status} in ${E-y}ms`;if(!T.ok){const v=await this.shouldRetry(T);if(n&&v){const A=`retrying, ${n} attempts remaining`;return await nd(T.body),$(this).info(`${_} - ${A}`),$(this).debug(`[${h}] response error (${A})`,ie({retryOfRequestLogID:o,url:T.url,status:T.status,headers:T.headers,durationMs:E-y})),this.retryRequest(u,n,o??h,T.headers)}const S=v?"error; no more retries left":"error; not retryable";$(this).info(`${_} - ${S}`);const x=await T.text().catch(A=>nt(A).message),P=zu(x),M=P?void 0:x;throw $(this).debug(`[${h}] response error (${S})`,ie({retryOfRequestLogID:o,url:T.url,status:T.status,headers:T.headers,message:M,durationMs:Date.now()-y})),this.makeStatusError(T.status,P,M,T.headers)}return $(this).info(_),$(this).debug(`[${h}] response start`,ie({retryOfRequestLogID:o,url:T.url,status:T.status,headers:T.headers,durationMs:E-y})),{response:T,options:u,controller:C,requestLogID:h,retryOfRequestLogID:o,startTime:y}}async fetchWithTimeout(e,n,o,s){const l=n||{},{signal:a,method:u}=l,c=Se(l,["signal","method"]);a&&a.addEventListener("abort",()=>s.abort());const d=setTimeout(()=>s.abort(),o),f=globalThis.ReadableStream&&c.body instanceof globalThis.ReadableStream||typeof c.body=="object"&&c.body!==null&&Symbol.asyncIterator in c.body,p=Object.assign(Object.assign(Object.assign({signal:s.signal},f?{duplex:"half"}:{}),{method:"GET"}),c);u&&(p.method=u.toUpperCase());try{return await this.fetch.call(void 0,e,p)}finally{clearTimeout(d)}}async shouldRetry(e){const n=e.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,n,o,s){var l;let a;const u=s==null?void 0:s.get("retry-after-ms");if(u){const d=parseFloat(u);Number.isNaN(d)||(a=d)}const c=s==null?void 0:s.get("retry-after");if(c&&!a){const d=parseFloat(c);Number.isNaN(d)?a=Date.parse(c)-Date.now():a=d*1e3}if(!(a&&0<=a&&a<60*1e3)){const d=(l=e.maxRetries)!==null&&l!==void 0?l:this.maxRetries;a=this.calculateDefaultRetryTimeoutMillis(n,d)}return await Ou(a),this.makeRequest(e,n-1,o)}calculateDefaultRetryTimeoutMillis(e,n){const l=n-e,a=Math.min(.5*Math.pow(2,l),8),u=1-Math.random()*.25;return a*u*1e3}async buildRequest(e,{retryCount:n=0}={}){var o,s,l;const a=Object.assign({},e),{method:u,path:c,query:d,defaultBaseURL:f}=a,p=this.buildURL(c,d,f);"timeout"in a&&Ku("timeout",a.timeout),a.timeout=(o=a.timeout)!==null&&o!==void 0?o:this.timeout;const{bodyHeaders:h,body:g}=this.buildBody({options:a}),y=await this.buildHeaders({options:e,method:u,bodyHeaders:h,retryCount:n});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:u,headers:y},a.signal&&{signal:a.signal}),globalThis.ReadableStream&&g instanceof globalThis.ReadableStream&&{duplex:"half"}),g&&{body:g}),(s=this.fetchOptions)!==null&&s!==void 0?s:{}),(l=a.fetchOptions)!==null&&l!==void 0?l:{}),url:p,timeout:a.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:o,retryCount:s}){let l={};this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),l[this.idempotencyHeader]=e.idempotencyKey);const a=await this.authHeaders(e);let u=ye([l,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),ju()),this._options.defaultHeaders,o,e.headers,a]);return this.validateHeaders(u),u.values}buildBody({options:{body:e,headers:n}}){if(!e)return{bodyHeaders:void 0,body:void 0};const o=ye([n]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&o.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:td(e)}:this.encoder({body:e,headers:o})}}Fe.DEFAULT_TIMEOUT=6e4;class H extends Fe{constructor(){super(...arguments),this.interactions=new Po(this)}}Uo=H,H.GeminiNextGenAPIClient=Uo,H.GeminiNextGenAPIClientError=Y,H.APIError=J,H.APIConnectionError=Me,H.APIConnectionTimeoutError=uo,H.APIUserAbortError=ot,H.NotFoundError=ho,H.ConflictError=mo,H.RateLimitError=yo,H.BadRequestError=co,H.AuthenticationError=fo,H.InternalServerError=To,H.PermissionDeniedError=po,H.UnprocessableEntityError=go,H.toFile=ad,H.Interactions=Po;/**
225
+ */var Uo;class Fe{constructor(e){var n,o,s,l,a,u,c,{baseURL:d=ut("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:f=(n=ut("GEMINI_API_KEY"))!==null&&n!==void 0?n:null,apiVersion:p="v1beta"}=e,h=Se(e,["baseURL","apiKey","apiVersion"]);const g=Object.assign(Object.assign({apiKey:f,apiVersion:p},h),{baseURL:d||"https://generativelanguage.googleapis.com"});this.baseURL=g.baseURL,this.timeout=(o=g.timeout)!==null&&o!==void 0?o:Fe.DEFAULT_TIMEOUT,this.logger=(s=g.logger)!==null&&s!==void 0?s:console;const y="warn";this.logLevel=y,this.logLevel=(a=(l=ko(g.logLevel,"ClientOptions.logLevel",this))!==null&&l!==void 0?l:ko(ut("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&a!==void 0?a:y,this.fetchOptions=g.fetchOptions,this.maxRetries=(u=g.maxRetries)!==null&&u!==void 0?u:2,this.fetch=(c=g.fetch)!==null&&c!==void 0?c:ed(),this.encoder=od,this._options=g,this.apiKey=f,this.apiVersion=p,this.clientAdapter=g.clientAdapter}withOptions(e){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),e))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:n}){if(!(e.has("authorization")||e.has("x-goog-api-key"))&&!(this.apiKey&&e.get("x-goog-api-key"))&&!n.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(e){const n=ye([e.headers]);if(!(n.values.has("authorization")||n.values.has("x-goog-api-key"))){if(this.apiKey)return ye([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return ye([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return Object.entries(e).filter(([n,o])=>typeof o<"u").map(([n,o])=>{if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return`${encodeURIComponent(n)}=${encodeURIComponent(o)}`;if(o===null)return`${encodeURIComponent(n)}=`;throw new K(`Cannot stringify type ${typeof o}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${pe}`}defaultIdempotencyKey(){return`stainless-node-retry-${Bu()}`}makeStatusError(e,n,o,s){return J.generate(e,n,o,s)}buildURL(e,n,o){const s=!this.baseURLOverridden()&&o||this.baseURL,l=$u(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),a=this.defaultQuery();return Wu(a)||(n=Object.assign(Object.assign({},a),n)),typeof n=="object"&&n&&!Array.isArray(n)&&(l.search=this.stringifyQuery(n)),l.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){const n=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${n}`}}async prepareRequest(e,{url:n,options:o}){}get(e,n){return this.methodRequest("get",e,n)}post(e,n){return this.methodRequest("post",e,n)}patch(e,n){return this.methodRequest("patch",e,n)}put(e,n){return this.methodRequest("put",e,n)}delete(e,n){return this.methodRequest("delete",e,n)}methodRequest(e,n,o){return this.request(Promise.resolve(o).then(s=>Object.assign({method:e,path:n},s)))}request(e,n=null){return new at(this,this.makeRequest(e,n,void 0))}async makeRequest(e,n,o){var s,l,a;const u=await e,c=(s=u.maxRetries)!==null&&s!==void 0?s:this.maxRetries;n==null&&(n=c),await this.prepareOptions(u);const{req:d,url:f,timeout:p}=await this.buildRequest(u,{retryCount:c-n});await this.prepareRequest(d,{url:f,options:u});const h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),g=o===void 0?"":`, retryOf: ${o}`,y=Date.now();if($(this).debug(`[${h}] sending request`,se({retryOfRequestLogID:o,method:u.method,url:f,options:u,headers:d.headers})),!((l=u.signal)===null||l===void 0)&&l.aborted)throw new ot;const C=new AbortController,T=await this.fetchWithTimeout(f,d,p,C).catch(nt),E=Date.now();if(T instanceof globalThis.Error){const v=`retrying, ${n} attempts remaining`;if(!((a=u.signal)===null||a===void 0)&&a.aborted)throw new ot;const S=tt(T)||/timed? ?out/i.test(String(T)+("cause"in T?String(T.cause):""));if(n)return $(this).info(`[${h}] connection ${S?"timed out":"failed"} - ${v}`),$(this).debug(`[${h}] connection ${S?"timed out":"failed"} (${v})`,se({retryOfRequestLogID:o,url:f,durationMs:E-y,message:T.message})),this.retryRequest(u,n,o??h);throw $(this).info(`[${h}] connection ${S?"timed out":"failed"} - error; no more retries left`),$(this).debug(`[${h}] connection ${S?"timed out":"failed"} (error; no more retries left)`,se({retryOfRequestLogID:o,url:f,durationMs:E-y,message:T.message})),S?new uo:new Me({cause:T})}const _=`[${h}${g}] ${d.method} ${f} ${T.ok?"succeeded":"failed"} with status ${T.status} in ${E-y}ms`;if(!T.ok){const v=await this.shouldRetry(T);if(n&&v){const A=`retrying, ${n} attempts remaining`;return await nd(T.body),$(this).info(`${_} - ${A}`),$(this).debug(`[${h}] response error (${A})`,se({retryOfRequestLogID:o,url:T.url,status:T.status,headers:T.headers,durationMs:E-y})),this.retryRequest(u,n,o??h,T.headers)}const S=v?"error; no more retries left":"error; not retryable";$(this).info(`${_} - ${S}`);const x=await T.text().catch(A=>nt(A).message),P=zu(x),M=P?void 0:x;throw $(this).debug(`[${h}] response error (${S})`,se({retryOfRequestLogID:o,url:T.url,status:T.status,headers:T.headers,message:M,durationMs:Date.now()-y})),this.makeStatusError(T.status,P,M,T.headers)}return $(this).info(_),$(this).debug(`[${h}] response start`,se({retryOfRequestLogID:o,url:T.url,status:T.status,headers:T.headers,durationMs:E-y})),{response:T,options:u,controller:C,requestLogID:h,retryOfRequestLogID:o,startTime:y}}async fetchWithTimeout(e,n,o,s){const l=n||{},{signal:a,method:u}=l,c=Se(l,["signal","method"]);a&&a.addEventListener("abort",()=>s.abort());const d=setTimeout(()=>s.abort(),o),f=globalThis.ReadableStream&&c.body instanceof globalThis.ReadableStream||typeof c.body=="object"&&c.body!==null&&Symbol.asyncIterator in c.body,p=Object.assign(Object.assign(Object.assign({signal:s.signal},f?{duplex:"half"}:{}),{method:"GET"}),c);u&&(p.method=u.toUpperCase());try{return await this.fetch.call(void 0,e,p)}finally{clearTimeout(d)}}async shouldRetry(e){const n=e.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,n,o,s){var l;let a;const u=s==null?void 0:s.get("retry-after-ms");if(u){const d=parseFloat(u);Number.isNaN(d)||(a=d)}const c=s==null?void 0:s.get("retry-after");if(c&&!a){const d=parseFloat(c);Number.isNaN(d)?a=Date.parse(c)-Date.now():a=d*1e3}if(!(a&&0<=a&&a<60*1e3)){const d=(l=e.maxRetries)!==null&&l!==void 0?l:this.maxRetries;a=this.calculateDefaultRetryTimeoutMillis(n,d)}return await Ou(a),this.makeRequest(e,n-1,o)}calculateDefaultRetryTimeoutMillis(e,n){const l=n-e,a=Math.min(.5*Math.pow(2,l),8),u=1-Math.random()*.25;return a*u*1e3}async buildRequest(e,{retryCount:n=0}={}){var o,s,l;const a=Object.assign({},e),{method:u,path:c,query:d,defaultBaseURL:f}=a,p=this.buildURL(c,d,f);"timeout"in a&&Ku("timeout",a.timeout),a.timeout=(o=a.timeout)!==null&&o!==void 0?o:this.timeout;const{bodyHeaders:h,body:g}=this.buildBody({options:a}),y=await this.buildHeaders({options:e,method:u,bodyHeaders:h,retryCount:n});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:u,headers:y},a.signal&&{signal:a.signal}),globalThis.ReadableStream&&g instanceof globalThis.ReadableStream&&{duplex:"half"}),g&&{body:g}),(s=this.fetchOptions)!==null&&s!==void 0?s:{}),(l=a.fetchOptions)!==null&&l!==void 0?l:{}),url:p,timeout:a.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:o,retryCount:s}){let l={};this.idempotencyHeader&&n!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),l[this.idempotencyHeader]=e.idempotencyKey);const a=await this.authHeaders(e);let u=ye([l,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),ju()),this._options.defaultHeaders,o,e.headers,a]);return this.validateHeaders(u),u.values}buildBody({options:{body:e,headers:n}}){if(!e)return{bodyHeaders:void 0,body:void 0};const o=ye([n]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&o.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:td(e)}:this.encoder({body:e,headers:o})}}Fe.DEFAULT_TIMEOUT=6e4;class H extends Fe{constructor(){super(...arguments),this.interactions=new Po(this)}}Uo=H,H.GeminiNextGenAPIClient=Uo,H.GeminiNextGenAPIClientError=K,H.APIError=J,H.APIConnectionError=Me,H.APIConnectionTimeoutError=uo,H.APIUserAbortError=ot,H.NotFoundError=ho,H.ConflictError=mo,H.RateLimitError=yo,H.BadRequestError=co,H.AuthenticationError=fo,H.InternalServerError=To,H.PermissionDeniedError=po,H.UnprocessableEntityError=go,H.toFile=ad,H.Interactions=Po;/**
226
226
  * @license
227
227
  * Copyright 2025 Google LLC
228
228
  * SPDX-License-Identifier: Apache-2.0
@@ -230,7 +230,7 @@ ${p}`)}return a})(wo);/**
230
230
  * @license
231
231
  * Copyright 2025 Google LLC
232
232
  * SPDX-License-Identifier: Apache-2.0
233
- */class qd extends Q{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new oe(j.PAGED_ITEM_TUNING_JOBS,o=>this.listInternal(o),await this.listInternal(n),n),this.get=async n=>await this.getInternal(n),this.tune=async n=>{var o;if(this.apiClient.isVertexAI())if(n.baseModel.startsWith("projects/")){const s={tunedModelName:n.baseModel};!((o=n.config)===null||o===void 0)&&o.preTunedModelCheckpointId&&(s.checkpointId=n.config.preTunedModelCheckpointId);const l=Object.assign(Object.assign({},n),{preTunedModel:s});return l.baseModel=void 0,await this.tuneInternal(l)}else{const s=Object.assign({},n);return await this.tuneInternal(s)}else{const s=Object.assign({},n),l=await this.tuneMldevInternal(s);let a="";return l.metadata!==void 0&&l.metadata.tunedModel!==void 0?a=l.metadata.tunedModel:l.name!==void 0&&l.name.includes("/operations/")&&(a=l.name.split("/operations/")[0]),{name:a,state:He.JOB_STATE_QUEUED}}}}async getInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Md(e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>dt(f))}else{const d=Nd(e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>Lo(f))}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Dd(e);return u=I("tuningJobs",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Ud(f),h=new Tn;return Object.assign(h,p),h})}else{const d=kd(e);return u=I("tunedModels",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=bd(f),h=new Tn;return Object.assign(h,p),h})}}async cancel(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Cd(e);return u=I("{name}:cancel",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Sd(f),h=new _n;return Object.assign(h,p),h})}else{const d=Ed(e);return u=I("{name}:cancel",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=vd(f),h=new _n;return Object.assign(h,p),h})}}async tuneInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=wd(e,e);return l=I("tuningJobs",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>dt(c))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=xd(e);return l=I("tunedModels",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>Vd(c))}}}/**
233
+ */class qd extends Z{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new ie(ee.PAGED_ITEM_TUNING_JOBS,o=>this.listInternal(o),await this.listInternal(n),n),this.get=async n=>await this.getInternal(n),this.tune=async n=>{var o;if(this.apiClient.isVertexAI())if(n.baseModel.startsWith("projects/")){const s={tunedModelName:n.baseModel};!((o=n.config)===null||o===void 0)&&o.preTunedModelCheckpointId&&(s.checkpointId=n.config.preTunedModelCheckpointId);const l=Object.assign(Object.assign({},n),{preTunedModel:s});return l.baseModel=void 0,await this.tuneInternal(l)}else{const s=Object.assign({},n);return await this.tuneInternal(s)}else{const s=Object.assign({},n),l=await this.tuneMldevInternal(s);let a="";return l.metadata!==void 0&&l.metadata.tunedModel!==void 0?a=l.metadata.tunedModel:l.name!==void 0&&l.name.includes("/operations/")&&(a=l.name.split("/operations/")[0]),{name:a,state:He.JOB_STATE_QUEUED}}}}async getInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Md(e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>dt(f))}else{const d=Nd(e);return u=I("{name}",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>Lo(f))}}async listInternal(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Dd(e);return u=I("tuningJobs",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Ud(f),h=new Tn;return Object.assign(h,p),h})}else{const d=kd(e);return u=I("tunedModels",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"GET",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=bd(f),h=new Tn;return Object.assign(h,p),h})}}async cancel(e){var n,o,s,l;let a,u="",c={};if(this.apiClient.isVertexAI()){const d=Cd(e);return u=I("{name}:cancel",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=Sd(f),h=new _n;return Object.assign(h,p),h})}else{const d=Ed(e);return u=I("{name}:cancel",d._url),c=d._query,delete d._url,delete d._query,a=this.apiClient.request({path:u,queryParams:c,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(s=e.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json().then(p=>{const h=p;return h.sdkHttpResponse={headers:f.headers},h})),a.then(f=>{const p=vd(f),h=new _n;return Object.assign(h,p),h})}}async tuneInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI()){const u=wd(e,e);return l=I("tuningJobs",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>dt(c))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var n,o;let s,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=xd(e);return l=I("tunedModels",u._url),a=u._query,delete u._url,delete u._query,s=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then(c=>c.json().then(d=>{const f=d;return f.sdkHttpResponse={headers:c.headers},f})),s.then(c=>Vd(c))}}}/**
234
234
  * @license
235
235
  * Copyright 2025 Google LLC
236
236
  * SPDX-License-Identifier: Apache-2.0
@@ -274,39 +274,69 @@ Example: For an image showing 'x squared', your literal output must be: x^2`},a=
274
274
  *
275
275
  * This source code is licensed under the ISC license.
276
276
  * See the LICENSE file in the root directory of this source tree.
277
- */const se=(t,e)=>{const n=w.forwardRef(({className:o,...s},l)=>w.createElement(gc,{ref:l,iconNode:e,className:Wo(`lucide-${fc($o(t))}`,`lucide-${t}`,o),...s}));return n.displayName=$o(t),n};/**
277
+ */const W=(t,e)=>{const n=w.forwardRef(({className:o,...s},l)=>w.createElement(gc,{ref:l,iconNode:e,className:Wo(`lucide-${fc($o(t))}`,`lucide-${t}`,o),...s}));return n.displayName=$o(t),n};/**
278
278
  * @license lucide-react v0.562.0 - ISC
279
279
  *
280
280
  * This source code is licensed under the ISC license.
281
281
  * See the LICENSE file in the root directory of this source tree.
282
- */const yc=se("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
282
+ */const yc=W("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/**
283
283
  * @license lucide-react v0.562.0 - ISC
284
284
  *
285
285
  * This source code is licensed under the ISC license.
286
286
  * See the LICENSE file in the root directory of this source tree.
287
- */const Tc=se("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
287
+ */const Tc=W("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
288
288
  * @license lucide-react v0.562.0 - ISC
289
289
  *
290
290
  * This source code is licensed under the ISC license.
291
291
  * See the LICENSE file in the root directory of this source tree.
292
- */const _c=se("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
292
+ */const _c=W("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
293
293
  * @license lucide-react v0.562.0 - ISC
294
294
  *
295
295
  * This source code is licensed under the ISC license.
296
296
  * See the LICENSE file in the root directory of this source tree.
297
- */const Ec=se("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
297
+ */const Ec=W("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]);/**
298
298
  * @license lucide-react v0.562.0 - ISC
299
299
  *
300
300
  * This source code is licensed under the ISC license.
301
301
  * See the LICENSE file in the root directory of this source tree.
302
- */const Cc=se("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
302
+ */const Cc=W("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);/**
303
303
  * @license lucide-react v0.562.0 - ISC
304
304
  *
305
305
  * This source code is licensed under the ISC license.
306
306
  * See the LICENSE file in the root directory of this source tree.
307
- */const vc=se("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
307
+ */const vc=W("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
308
308
  * @license lucide-react v0.562.0 - ISC
309
309
  *
310
310
  * This source code is licensed under the ISC license.
311
311
  * See the LICENSE file in the root directory of this source tree.
312
- */const Sc=se("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ic=({isOpen:t,onClose:e,onInsert:n,apiKey:o=""})=>{const s=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(!1),[c,d]=w.useState(null),[f,p]=w.useState(""),[h,g]=w.useState("keyboard"),[y,C]=w.useState("math"),[T,E]=w.useState(!1),[_,v]=w.useState(!1),[S,x]=w.useState(""),[P,M]=w.useState(!1);w.useEffect(()=>{if(h==="keyboard"&&f.trim()&&window.katex)try{const D=window.katex.renderToString(f,{throwOnError:!0,displayMode:!1,output:"mathml"});x(D),M(!0)}catch{x('<span class="text-red-500 text-xs">Invalid formula syntax</span>'),M(!1)}else x(""),M(!1)},[f,h]);const b=D=>{C(D),D==="chem"&&g("keyboard")},A=w.useCallback(()=>{var D;(D=s.current)==null||D.clear(),p(""),d(null),u(!1)},[]),R=w.useCallback(D=>{const U=l.current;if(!U){p(q=>q+D);return}const V=U.selectionStart,N=U.selectionEnd,G=f.substring(0,V)+D+f.substring(N);p(G),setTimeout(()=>{U.focus(),U.selectionStart=U.selectionEnd=V+D.length},0)},[f]),F=w.useCallback(async()=>{var U,V;if(!o){d("Please configure your Gemini API key in the main editor.");return}const D=(U=s.current)==null?void 0:U.getTrimmedImageData();if(!D){d("Draw a formula on the pad first.");return}u(!0),d(null);try{const N=D.split(",")[1],G=await nc(N,o);R(G),g("keyboard"),(V=s.current)==null||V.clear()}catch(N){d(N.message||"AI recognition failed.")}finally{u(!1)}},[o,R]);return t?m.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md p-4 animate-in fade-in duration-200",children:m.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl flex flex-col w-full max-w-4xl h-[600px] border border-slate-200 overflow-hidden",onClick:D=>D.stopPropagation(),children:[m.jsxs("header",{className:"px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50",children:[m.jsxs("div",{className:"flex items-center gap-6",children:[m.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"AI Formula Pad"}),m.jsxs("div",{className:"flex bg-slate-200 p-1 rounded-lg",children:[m.jsx("button",{onClick:()=>b("math"),className:`px-4 py-1 text-xs font-semibold rounded-md transition-all ${y==="math"?"bg-white shadow text-blue-600":"text-slate-500"}`,children:"Math"}),m.jsx("button",{onClick:()=>b("chem"),className:`px-4 py-1 text-xs font-semibold rounded-md transition-all ${y==="chem"?"bg-white shadow text-blue-600":"text-slate-500"}`,children:"Chemistry"})]})]}),m.jsx("button",{onClick:e,className:"p-2 hover:bg-slate-200 rounded-full text-slate-400 hover:text-slate-600 transition-colors",children:m.jsx(Sc,{size:20})})]}),m.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[m.jsxs("div",{className:"w-16 border-r border-slate-100 flex flex-col items-center py-6 gap-4 bg-slate-50/30",children:[m.jsx("button",{onClick:()=>g("keyboard"),className:`p-3 rounded-xl transition-all ${h==="keyboard"?"bg-blue-600 text-white shadow-lg":"text-slate-400 hover:text-slate-600"}`,children:m.jsx(yc,{size:24})}),y==="math"&&m.jsx("button",{onClick:()=>g("handwriting"),className:`p-3 rounded-xl transition-all ${h==="handwriting"?"bg-blue-600 text-white shadow-lg":"text-slate-400 hover:text-slate-600"}`,children:m.jsx(_c,{size:24})})]}),m.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m.jsx("div",{className:"shrink-0",children:h==="keyboard"&&(y==="math"?m.jsx(lc,{onInsert:R}):m.jsx(cc,{onInsert:R}))}),m.jsx("div",{className:"flex-1 p-6 relative bg-slate-50/20",children:h==="keyboard"?m.jsxs("div",{className:"h-full flex flex-col gap-4",children:[m.jsx("textarea",{ref:l,value:f,onChange:D=>p(D.target.value),className:"flex-1 w-full p-6 border border-slate-200 rounded-xl shadow-inner focus:outline-none focus:ring-2 focus:ring-blue-500/10 font-mono text-xl text-slate-800",placeholder:`Enter LaTeX for ${y}...`}),m.jsx("div",{className:"h-20 bg-white border border-slate-100 rounded-xl flex items-center justify-center p-4 shadow-sm overflow-auto",children:S?m.jsx("div",{dangerouslySetInnerHTML:{__html:S}}):m.jsx("span",{className:"text-slate-300 italic",children:"Preview will appear here"})})]}):m.jsxs("div",{className:"h-full border border-slate-200 bg-white rounded-2xl shadow-inner overflow-hidden relative",children:[m.jsx(ft,{ref:s,onHistoryChange:D=>{E(D.canUndo),v(D.canRedo)}}),m.jsxs("div",{className:"absolute top-4 right-4 flex flex-col gap-2",children:[m.jsx("button",{onClick:()=>{var D;return(D=s.current)==null?void 0:D.undo()},disabled:!T,className:"p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50",children:m.jsx(Ec,{size:18})}),m.jsx("button",{onClick:()=>{var D;return(D=s.current)==null?void 0:D.redo()},disabled:!_,className:"p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50",children:m.jsx(Cc,{size:18})}),m.jsx("button",{onClick:A,className:"p-2 bg-white border border-slate-200 rounded-lg shadow-sm text-red-500 hover:bg-red-50",children:m.jsx(vc,{size:18})})]}),m.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-4",children:m.jsxs("button",{onClick:F,disabled:a,className:"px-8 py-2.5 bg-blue-600 text-white rounded-full font-bold shadow-xl hover:bg-blue-700 transition flex items-center gap-2 disabled:bg-slate-400",children:[a?m.jsx(Tc,{className:"animate-spin",size:18}):null,a?"Processing...":"Recognize Drawing"]})})]})})]})]}),m.jsxs("footer",{className:"px-6 py-4 border-t border-slate-100 flex justify-between items-center bg-slate-50/50",children:[c&&m.jsx("span",{className:"text-sm font-medium text-red-500 animate-pulse",children:c}),m.jsxs("div",{className:"ml-auto flex gap-3",children:[m.jsx("button",{onClick:e,className:"px-6 py-2 text-slate-600 font-semibold hover:bg-slate-200 rounded-xl transition",children:"Cancel"}),m.jsx("button",{onClick:()=>{n(S),e()},disabled:!P,className:"px-8 py-2 bg-slate-900 text-white font-bold rounded-xl shadow-lg disabled:opacity-40 hover:bg-slate-800 transition",children:"Insert Into Editor"})]})]})]})}):null},Ac=({isOpen:t,onClose:e,onInsert:n})=>{const[o,s]=w.useState(3),[l,a]=w.useState(3);if(!t)return null;const u=()=>{o>0&&l>0&&n(o,l)};return m.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm",onClick:e,children:m.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 w-full max-w-sm",onClick:c=>c.stopPropagation(),children:[m.jsx("h3",{className:"text-lg font-semibold text-gray-800 mb-4",children:"Insert Table"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"rows",className:"block text-sm font-medium text-gray-700 mb-1",children:"Rows"}),m.jsx("input",{type:"number",id:"rows",value:o,onChange:c=>s(Math.max(1,parseInt(c.target.value,10))),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 text-black"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"cols",className:"block text-sm font-medium text-gray-700 mb-1",children:"Columns"}),m.jsx("input",{type:"number",id:"cols",value:l,onChange:c=>a(Math.max(1,parseInt(c.target.value,10))),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 text-black"})]})]}),m.jsxs("div",{className:"mt-6 flex justify-end space-x-3",children:[m.jsx("button",{onClick:e,className:"px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition",children:"Cancel"}),m.jsx("button",{onClick:u,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition",children:"Insert"})]})]})})},xc=({onOpenHandwritingModal:t,onApplyStyle:e,onUndo:n,onRedo:o,canUndo:s,canRedo:l,apiKey:a})=>{const[u,c]=w.useState(!1),[d,f]=w.useState(!1),[p,h]=w.useState(7),g=w.useRef(null),y=w.useRef([]),C=w.useRef(null),[T,E]=w.useState(!1);w.useEffect(()=>{a!==""&&a&&E(!0)},[a]);const _=w.useMemo(()=>[{id:"font",priority:1},{id:"history",priority:2},{id:"formatting",priority:3},{id:"colors",priority:4},{id:"lists",priority:5},{id:"media",priority:6},{id:"handwriting",priority:7}],[]);w.useEffect(()=>{const N=g.current;if(!N)return;const G=new ResizeObserver(q=>{const re=q[0].contentRect.width-50;let Te=0,Ko=0;for(let ct=0;ct<y.current.length;ct++){const zo=y.current[ct];if(zo){const Oo=zo.getBoundingClientRect().width+8;if(Te+Oo<=re)Te+=Oo,Ko++;else break}}h(Math.max(1,Ko))});return G.observe(N),()=>G.disconnect()},[]);const v=N=>{var q;const G=(q=N.target.files)==null?void 0:q[0];if(G){const K=new FileReader;K.onload=re=>{var Te;return e("insertImage",(Te=re.target)==null?void 0:Te.result)},K.readAsDataURL(G)}N.target.value=""},S=(N,G)=>{let q='<table style="width:100%; border-collapse: collapse; border: 1px solid black;"><tbody>';for(let K=0;K<N;K++){q+="<tr>";for(let re=0;re<G;re++)q+='<td style="border: 1px solid black; padding: 5px;"><p><br></p></td>';q+="</tr>"}q+="</tbody></table><p><br></p>",e("insertHTML",q),c(!1)},x=()=>m.jsxs("div",{ref:N=>y.current[0]=N,className:"flex items-center gap-2 shrink-0",children:[m.jsxs("select",{onChange:N=>e("fontName",N.target.value),defaultValue:"Arial",className:"bg-white border border-gray-300 rounded px-2 py-1 text-xs text-black outline-none focus:ring-1 focus:ring-blue-500 min-w-[80px]",children:[m.jsx("option",{value:"Arial",children:"Arial"}),m.jsx("option",{value:"Verdana",children:"Verdana"}),m.jsx("option",{value:"Georgia",children:"Georgia"})]}),m.jsxs("select",{onChange:N=>e("fontSize",N.target.value),defaultValue:"3",className:"bg-white border border-gray-300 rounded px-2 py-1 text-xs text-black outline-none focus:ring-1 focus:ring-blue-500",children:[m.jsx("option",{value:"1",children:"S"}),m.jsx("option",{value:"3",children:"M"}),m.jsx("option",{value:"5",children:"L"})]})]}),P=()=>m.jsxs("div",{ref:N=>y.current[1]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{onClick:n,disabled:!s,className:"p-1.5 hover:bg-gray-100 disabled:opacity-30 border-r border-gray-200",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})})}),m.jsx("button",{onClick:o,disabled:!l,className:"p-1.5 hover:bg-gray-100 disabled:opacity-30",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})})]}),M=()=>m.jsxs("div",{ref:N=>y.current[2]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{onClick:()=>e("bold"),className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx("b",{className:"text-black",children:"B"})}),m.jsx("button",{onClick:()=>e("italic"),className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx("i",{className:"text-black",children:"I"})}),m.jsx("button",{onClick:()=>e("underline"),className:"p-1.5 hover:bg-gray-100",children:m.jsx("u",{className:"text-black",children:"U"})})]}),b=()=>m.jsxs("div",{ref:N=>y.current[3]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsxs("label",{className:"p-1.5 hover:bg-gray-100 border-r border-gray-200 cursor-pointer relative",children:[m.jsx("span",{className:"text-xs font-bold text-black",children:"A"}),m.jsx("input",{type:"color",onInput:N=>e("foreColor",N.target.value),className:"opacity-0 absolute inset-0 cursor-pointer"})]}),m.jsxs("label",{className:"p-1.5 hover:bg-gray-100 cursor-pointer relative",children:[m.jsx("svg",{className:"w-4 h-4 text-black",fill:"currentColor",viewBox:"0 0 20 20",children:m.jsx("path",{d:"M4 13L10 3L16 13H4Z"})}),m.jsx("input",{type:"color",onInput:N=>e("backColor",N.target.value),className:"opacity-0 absolute inset-0 cursor-pointer"})]})]}),A=()=>m.jsxs("div",{ref:N=>y.current[4]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{onClick:()=>e("insertOrderedList"),className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 6h16M4 12h16M4 18h16"})})}),m.jsx("button",{onClick:()=>e("insertUnorderedList"),className:"p-1.5 hover:bg-gray-100",children:m.jsxs("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 6h16M4 12h16M4 18h16"}),m.jsx("circle",{cx:"2",cy:"6",r:"1"})]})})]}),R=()=>m.jsxs("div",{ref:N=>y.current[5]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{onClick:()=>{var N;return(N=C.current)==null?void 0:N.click()},className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),m.jsx("button",{onClick:()=>c(!0),className:"p-1.5 hover:bg-gray-100",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M3 6h18M3 12h18M3 18h18M8 3v18m8-18v18"})})})]}),F=()=>m.jsx("div",{ref:N=>y.current[6]=N,className:"shrink-0",children:m.jsx("button",{onClick:t,className:"p-2 bg-blue-50 border border-blue-200 hover:bg-blue-100 text-blue-700 rounded flex items-center transition-colors shadow-sm",children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M3 12h2l4 8 4-16h6"}),m.jsx("path",{d:"m17 8 4 4"}),m.jsx("path",{d:"m21 8-4 4"})]})})}),D=N=>{switch(N){case"font":return m.jsx(x,{},"font");case"history":return m.jsx(P,{},"history");case"formatting":return m.jsx(M,{},"formatting");case"colors":return m.jsx(b,{},"colors");case"lists":return m.jsx(A,{},"lists");case"media":return m.jsx(R,{},"media");case"handwriting":return m.jsx(F,{},"handwriting");default:return null}},U=_.slice(0,p),V=_.slice(p);return m.jsxs("div",{className:"relative",children:[m.jsxs("div",{ref:g,className:"bg-gray-50 p-2 flex items-center gap-3 border-b border-gray-200 rounded-t-lg overflow-hidden flex-nowrap",children:[m.jsxs("div",{className:"absolute top-0 left-0 invisible pointer-events-none flex gap-3 whitespace-nowrap",children:[m.jsx(x,{}),m.jsx(P,{}),m.jsx(M,{}),m.jsx(b,{}),m.jsx(A,{}),m.jsx(R,{}),T&&m.jsx(F,{})]}),m.jsx("div",{className:"flex items-center gap-3 flex-nowrap",children:U.map(N=>D(N.id))}),V.length>0&&m.jsxs("div",{className:"ml-auto relative shrink-0",children:[m.jsx("button",{onClick:()=>f(!d),className:`p-1.5 rounded hover:bg-gray-200 transition-colors ${d?"bg-gray-200":""}`,children:m.jsx("svg",{className:"w-5 h-5 text-gray-600",fill:"currentColor",viewBox:"0 0 20 20",children:m.jsx("path",{d:"M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM18 10a2 2 0 11-4 0 2 2 0 014 0z"})})}),d&&m.jsx("div",{className:"absolute right-0 mt-2 bg-white border border-gray-200 shadow-xl rounded-lg p-3 z-50 flex flex-col gap-4 min-w-[200px]",children:V.map(N=>m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-tighter",children:N.id}),m.jsx("div",{onClick:G=>G.stopPropagation(),children:D(N.id)})]},N.id))})]})]}),m.jsx("input",{type:"file",ref:C,onChange:v,accept:"image/*",className:"hidden"}),m.jsx(Ac,{isOpen:u,onClose:()=>c(!1),onInsert:S}),d&&m.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>f(!1)})]})},Yo=w.forwardRef(({initialContent:t="",onChange:e,apiKey:n},o)=>{const s=w.useRef(null),[l,a]=w.useState(!1),[u,c]=w.useState([t]),[d,f]=w.useState(0),p=d>0,h=d<u.length-1,g=w.useCallback(E=>{if(E===u[d])return;const _=u.slice(0,d+1);_.push(E),_.length>50&&_.shift(),c(_),f(_.length-1),e==null||e(E)},[u,d,e]);w.useImperativeHandle(o,()=>({getContent:()=>{var E;return((E=s.current)==null?void 0:E.innerHTML)||""},setContent:E=>{s.current&&(s.current.innerHTML=E,g(E))}})),w.useEffect(()=>{s.current&&t&&!s.current.innerHTML&&(s.current.innerHTML=t)},[t]);const y=(E,_)=>{var v,S;(v=s.current)==null||v.focus(),document.execCommand(E,!1,_),g(((S=s.current)==null?void 0:S.innerHTML)||"")},C=()=>{if(p){const E=d-1;f(E),s.current&&(s.current.innerHTML=u[E],e==null||e(u[E]))}},T=()=>{if(h){const E=d+1;f(E),s.current&&(s.current.innerHTML=u[E],e==null||e(u[E]))}};return m.jsxs("div",{className:"w-full max-w-5xl bg-white shadow-xl border border-slate-200 flex flex-col transition-all duration-300",children:[m.jsx(xc,{onApplyStyle:y,onOpenHandwritingModal:()=>a(!0),onUndo:C,onRedo:T,canUndo:p,canRedo:h,apiKey:n}),m.jsx("div",{ref:s,contentEditable:!0,onInput:()=>{var E;return g(((E=s.current)==null?void 0:E.innerHTML)||"")},className:"flex-1 p-4 outline-none prose prose-slate prose-lg max-w-none max-h-[200px] overflow-scroll prose-headings:font-bold prose-a:text-blue-600 prose-img:rounded-xl prose-table:border border-slate-100 bg-white",style:{fontVariantLigatures:"common-ligatures"}}),l&&m.jsx(Ic,{isOpen:l,onClose:()=>a(!1),onInsert:E=>{var _,v;(_=s.current)==null||_.focus(),document.execCommand("insertHTML",!1,`<span contenteditable="false" class="math-container inline-block mx-1 align-middle">${E}</span>&nbsp;`),g(((v=s.current)==null?void 0:v.innerHTML)||"")},apiKey:n})]})});Yo.displayName="Editor",ee.Editor=Yo,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})});
312
+ */const Sc=W("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);/**
313
+ * @license lucide-react v0.562.0 - ISC
314
+ *
315
+ * This source code is licensed under the ISC license.
316
+ * See the LICENSE file in the root directory of this source tree.
317
+ */const Ic=W("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
318
+ * @license lucide-react v0.562.0 - ISC
319
+ *
320
+ * This source code is licensed under the ISC license.
321
+ * See the LICENSE file in the root directory of this source tree.
322
+ */const Ac=W("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
323
+ * @license lucide-react v0.562.0 - ISC
324
+ *
325
+ * This source code is licensed under the ISC license.
326
+ * See the LICENSE file in the root directory of this source tree.
327
+ */const xc=W("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
328
+ * @license lucide-react v0.562.0 - ISC
329
+ *
330
+ * This source code is licensed under the ISC license.
331
+ * See the LICENSE file in the root directory of this source tree.
332
+ */const wc=W("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
333
+ * @license lucide-react v0.562.0 - ISC
334
+ *
335
+ * This source code is licensed under the ISC license.
336
+ * See the LICENSE file in the root directory of this source tree.
337
+ */const Nc=W("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
338
+ * @license lucide-react v0.562.0 - ISC
339
+ *
340
+ * This source code is licensed under the ISC license.
341
+ * See the LICENSE file in the root directory of this source tree.
342
+ */const Mc=W("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Pc=({isOpen:t,onClose:e,onInsert:n,apiKey:o=""})=>{const s=w.useRef(null),l=w.useRef(null),[a,u]=w.useState(!1),[c,d]=w.useState(null),[f,p]=w.useState(""),[h,g]=w.useState("keyboard"),[y,C]=w.useState("math"),[T,E]=w.useState(!1),[_,v]=w.useState(!1),[S,x]=w.useState(""),[P,M]=w.useState(!1);w.useEffect(()=>{if(h==="keyboard"&&f.trim()&&window.katex)try{const D=window.katex.renderToString(f,{throwOnError:!0,displayMode:!1,output:"mathml"});x(D),M(!0)}catch{x('<span class="text-red-500 text-xs">Invalid formula syntax</span>'),M(!1)}else x(""),M(!1)},[f,h]);const b=D=>{C(D),D==="chem"&&g("keyboard")},A=w.useCallback(()=>{var D;(D=s.current)==null||D.clear(),p(""),d(null),u(!1)},[]),R=w.useCallback(D=>{const U=l.current;if(!U){p(q=>q+D);return}const V=U.selectionStart,N=U.selectionEnd,G=f.substring(0,V)+D+f.substring(N);p(G),setTimeout(()=>{U.focus(),U.selectionStart=U.selectionEnd=V+D.length},0)},[f]),F=w.useCallback(async()=>{var U,V;if(!o){d("Please configure your Gemini API key in the main editor.");return}const D=(U=s.current)==null?void 0:U.getTrimmedImageData();if(!D){d("Draw a formula on the pad first.");return}u(!0),d(null);try{const N=D.split(",")[1],G=await nc(N,o);R(G),g("keyboard"),(V=s.current)==null||V.clear()}catch(N){d(N.message||"AI recognition failed.")}finally{u(!1)}},[o,R]);return t?m.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md p-4 animate-in fade-in duration-200",children:m.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl flex flex-col w-full max-w-4xl h-[600px] border border-slate-200 overflow-hidden",onClick:D=>D.stopPropagation(),children:[m.jsxs("header",{className:"px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50",children:[m.jsxs("div",{className:"flex items-center gap-6",children:[m.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"AI Formula Pad"}),m.jsxs("div",{className:"flex bg-slate-200 p-1 rounded-lg",children:[m.jsx("button",{onClick:()=>b("math"),className:`px-4 py-1 text-xs font-semibold rounded-md transition-all ${y==="math"?"bg-white shadow text-blue-600":"text-slate-500"}`,children:"Math"}),m.jsx("button",{onClick:()=>b("chem"),className:`px-4 py-1 text-xs font-semibold rounded-md transition-all ${y==="chem"?"bg-white shadow text-blue-600":"text-slate-500"}`,children:"Chemistry"})]})]}),m.jsx("button",{title:"Close",onClick:e,className:"p-2 hover:bg-slate-200 rounded-full text-slate-400 hover:text-slate-600 transition-colors",children:m.jsx(Mc,{size:20})})]}),m.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[m.jsxs("div",{className:"w-16 border-r border-slate-100 flex flex-col items-center py-6 gap-4 bg-slate-50/30",children:[m.jsx("button",{onClick:()=>g("keyboard"),className:`p-3 rounded-xl transition-all ${h==="keyboard"?"bg-blue-600 text-white shadow-lg":"text-slate-400 hover:text-slate-600"}`,children:m.jsx(_c,{size:24})}),y==="math"&&m.jsx("button",{onClick:()=>g("handwriting"),className:`p-3 rounded-xl transition-all ${h==="handwriting"?"bg-blue-600 text-white shadow-lg":"text-slate-400 hover:text-slate-600"}`,children:m.jsx(Ic,{size:24})})]}),m.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m.jsx("div",{className:"shrink-0",children:h==="keyboard"&&(y==="math"?m.jsx(lc,{onInsert:R}):m.jsx(cc,{onInsert:R}))}),m.jsx("div",{className:"flex-1 p-6 relative bg-slate-50/20",children:h==="keyboard"?m.jsxs("div",{className:"h-full flex flex-col gap-4",children:[m.jsx("textarea",{ref:l,value:f,onChange:D=>p(D.target.value),className:"flex-1 w-full p-6 border border-slate-200 rounded-xl shadow-inner focus:outline-none focus:ring-2 focus:ring-blue-500/10 font-mono text-xl text-slate-800",placeholder:`Enter LaTeX for ${y}...`}),m.jsx("div",{className:"h-20 bg-white border border-slate-100 rounded-xl flex items-center justify-center p-4 shadow-sm overflow-auto",children:S?m.jsx("div",{dangerouslySetInnerHTML:{__html:S}}):m.jsx("span",{className:"text-slate-300 italic",children:"Preview will appear here"})})]}):m.jsxs("div",{className:"h-full border border-slate-200 bg-white rounded-2xl shadow-inner overflow-hidden relative",children:[m.jsx(ft,{ref:s,onHistoryChange:D=>{E(D.canUndo),v(D.canRedo)}}),m.jsxs("div",{className:"absolute top-4 right-4 flex flex-col gap-2",children:[m.jsx("button",{onClick:()=>{var D;return(D=s.current)==null?void 0:D.undo()},disabled:!T,className:"p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50",children:m.jsx(Ac,{size:18})}),m.jsx("button",{onClick:()=>{var D;return(D=s.current)==null?void 0:D.redo()},disabled:!_,className:"p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50",children:m.jsx(xc,{size:18})}),m.jsx("button",{onClick:A,className:"p-2 bg-white border border-slate-200 rounded-lg shadow-sm text-red-500 hover:bg-red-50",children:m.jsx(Nc,{size:18})})]}),m.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-4",children:m.jsxs("button",{onClick:F,disabled:a,className:"px-8 py-2.5 bg-blue-600 text-white rounded-full font-bold shadow-xl hover:bg-blue-700 transition flex items-center gap-2 disabled:bg-slate-400",children:[a?m.jsx(vc,{className:"animate-spin",size:18}):null,a?"Processing...":"Recognize Drawing"]})})]})})]})]}),m.jsxs("footer",{className:"px-6 py-4 border-t border-slate-100 flex justify-between items-center bg-slate-50/50",children:[c&&m.jsx("span",{className:"text-sm font-medium text-red-500 animate-pulse",children:c}),m.jsxs("div",{className:"ml-auto flex gap-3",children:[m.jsx("button",{onClick:e,className:"px-6 py-2 text-slate-600 font-semibold hover:bg-slate-200 rounded-xl transition",children:"Cancel"}),m.jsx("button",{onClick:()=>{n(S),e()},disabled:!P,className:"px-8 py-2 bg-slate-900 text-white font-bold rounded-xl shadow-lg disabled:opacity-40 hover:bg-slate-800 transition",children:"Insert Into Editor"})]})]})]})}):null},Rc=({isOpen:t,onClose:e,onInsert:n})=>{const[o,s]=w.useState(3),[l,a]=w.useState(3);if(!t)return null;const u=()=>{o>0&&l>0&&n(o,l)};return m.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm",onClick:e,children:m.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 w-full max-w-sm",onClick:c=>c.stopPropagation(),children:[m.jsx("h3",{className:"text-lg font-semibold text-gray-800 mb-4",children:"Insert Table"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"rows",className:"block text-sm font-medium text-gray-700 mb-1",children:"Rows"}),m.jsx("input",{type:"number",id:"rows",value:o,onChange:c=>s(Math.max(1,parseInt(c.target.value,10))),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 text-black"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"cols",className:"block text-sm font-medium text-gray-700 mb-1",children:"Columns"}),m.jsx("input",{type:"number",id:"cols",value:l,onChange:c=>a(Math.max(1,parseInt(c.target.value,10))),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 text-black"})]})]}),m.jsxs("div",{className:"mt-6 flex justify-end space-x-3",children:[m.jsx("button",{title:"Cancel and discard",onClick:e,className:"px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition",children:"Cancel"}),m.jsx("button",{onClick:u,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition",children:"Insert"})]})]})})},kc=({onOpenHandwritingModal:t,onApplyStyle:e,onUndo:n,onRedo:o,canUndo:s,canRedo:l,apiKey:a})=>{const[u,c]=w.useState(!1),[d,f]=w.useState(!1),[p,h]=w.useState(7),g=w.useRef(null),y=w.useRef([]),C=w.useRef(null),[T,E]=w.useState(!1);w.useEffect(()=>{a!==""&&a&&E(!0)},[a]);const _=w.useMemo(()=>[{id:"font",priority:1},{id:"history",priority:2},{id:"formatting",priority:3},{id:"colors",priority:4},{id:"lists",priority:5},{id:"media",priority:6},{id:"handwriting",priority:7}],[]);w.useEffect(()=>{const N=g.current;if(!N)return;const G=new ResizeObserver(q=>{const re=q[0].contentRect.width-50;let Te=0,Ko=0;for(let ct=0;ct<y.current.length;ct++){const zo=y.current[ct];if(zo){const Oo=zo.getBoundingClientRect().width+8;if(Te+Oo<=re)Te+=Oo,Ko++;else break}}h(Math.max(1,Ko))});return G.observe(N),()=>G.disconnect()},[]);const v=N=>{var q;const G=(q=N.target.files)==null?void 0:q[0];if(G){const z=new FileReader;z.onload=re=>{var Te;return e("insertImage",(Te=re.target)==null?void 0:Te.result)},z.readAsDataURL(G)}N.target.value=""},S=(N,G)=>{let q='<table style="width:100%; border-collapse: collapse; border: 1px solid black;"><tbody>';for(let z=0;z<N;z++){q+="<tr>";for(let re=0;re<G;re++)q+='<td style="border: 1px solid black; padding: 5px;"><p><br></p></td>';q+="</tr>"}q+="</tbody></table><p><br></p>",e("insertHTML",q),c(!1)},x=()=>m.jsxs("div",{ref:N=>y.current[0]=N,className:"flex items-center gap-2 shrink-0",children:[m.jsxs("select",{title:"Font Family",onChange:N=>e("fontName",N.target.value),defaultValue:"Arial",className:"bg-white border border-gray-300 rounded px-2 py-1 text-xs text-black outline-none focus:ring-1 focus:ring-blue-500 min-w-[80px]",children:[m.jsx("option",{value:"Arial",children:"Arial"}),m.jsx("option",{value:"Verdana",children:"Verdana"}),m.jsx("option",{value:"Georgia",children:"Georgia"})]}),m.jsxs("select",{title:"Font Size",onChange:N=>e("fontSize",N.target.value),defaultValue:"3",className:"bg-white border border-gray-300 rounded px-2 py-1 text-xs text-black outline-none focus:ring-1 focus:ring-blue-500",children:[m.jsx("option",{value:"1",children:"S"}),m.jsx("option",{value:"3",children:"M"}),m.jsx("option",{value:"5",children:"L"})]})]}),P=()=>m.jsxs("div",{ref:N=>y.current[1]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{title:"Undo",onClick:n,disabled:!s,className:"p-1.5 hover:bg-gray-100 disabled:opacity-30 border-r border-gray-200",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})})}),m.jsx("button",{title:"Redo",onClick:o,disabled:!l,className:"p-1.5 hover:bg-gray-100 disabled:opacity-30",children:m.jsx("svg",{className:"w-4 h-4 text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})})]}),M=()=>m.jsxs("div",{ref:N=>y.current[2]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{title:"Bold",onClick:()=>e("bold"),className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx("b",{className:"text-black",children:"B"})}),m.jsx("button",{title:"Italic",onClick:()=>e("italic"),className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx("i",{className:"text-black",children:"I"})}),m.jsx("button",{title:"Underline",onClick:()=>e("underline"),className:"p-1.5 hover:bg-gray-100",children:m.jsx("u",{className:"text-black",children:"U"})})]}),b=()=>m.jsxs("div",{ref:N=>y.current[3]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsxs("label",{className:"p-1.5 hover:bg-gray-100 border-r border-gray-200 cursor-pointer relative",children:[m.jsx(Sc,{size:18,className:"text-slate-600"}),m.jsx("input",{type:"color",onInput:N=>e("foreColor",N.target.value),className:"opacity-0 absolute inset-0 cursor-pointer"})]}),m.jsxs("label",{className:"p-1.5 hover:bg-gray-100 cursor-pointer relative",children:[m.jsx(yc,{size:18,className:"text-slate-600"}),m.jsx("input",{type:"color",onInput:N=>e("backColor",N.target.value),className:"opacity-0 absolute inset-0 cursor-pointer"})]})]}),A=()=>m.jsxs("div",{ref:N=>y.current[4]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{title:"Ordered List",onClick:()=>e("insertOrderedList"),className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx(Ec,{size:18})}),m.jsx("button",{title:"Unordered List",onClick:()=>e("insertUnorderedList"),className:"p-1.5 hover:bg-gray-100",children:m.jsx(Cc,{size:18})})]}),R=()=>m.jsxs("div",{ref:N=>y.current[5]=N,className:"flex bg-white border border-gray-300 rounded overflow-hidden shrink-0",children:[m.jsx("button",{title:"Upload Image",onClick:()=>{var N;return(N=C.current)==null?void 0:N.click()},className:"p-1.5 hover:bg-gray-100 border-r border-gray-200",children:m.jsx(Tc,{size:18})}),m.jsx("button",{title:"Insert Table",onClick:()=>c(!0),className:"p-1.5 hover:bg-gray-100",children:m.jsx(wc,{size:18})})]}),F=()=>m.jsx("div",{ref:N=>y.current[6]=N,className:"shrink-0",children:m.jsx("button",{title:"Handwriting Math Pad",onClick:t,className:"p-2 bg-blue-50 border border-blue-200 hover:bg-blue-100 text-blue-700 rounded flex items-center transition-colors shadow-sm",children:m.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("path",{d:"M3 12h2l4 8 4-16h6"}),m.jsx("path",{d:"m17 8 4 4"}),m.jsx("path",{d:"m21 8-4 4"})]})})}),D=N=>{switch(N){case"font":return m.jsx(x,{},"font");case"history":return m.jsx(P,{},"history");case"formatting":return m.jsx(M,{},"formatting");case"colors":return m.jsx(b,{},"colors");case"lists":return m.jsx(A,{},"lists");case"media":return m.jsx(R,{},"media");case"handwriting":return m.jsx(F,{},"handwriting");default:return null}},U=_.slice(0,p),V=_.slice(p);return m.jsxs("div",{className:"relative",children:[m.jsxs("div",{ref:g,className:"bg-gray-50 p-2 flex items-center gap-3 border-b border-gray-200 rounded-t-lg flex-nowrap overflow-visible",children:[m.jsxs("div",{className:"absolute top-0 left-0 invisible pointer-events-none flex gap-3 whitespace-nowrap overflow-hidden",children:[m.jsx(x,{}),m.jsx(P,{}),m.jsx(M,{}),m.jsx(b,{}),m.jsx(A,{}),m.jsx(R,{}),T&&m.jsx(F,{})]}),m.jsx("div",{className:"flex items-center gap-3 flex-nowrap overflow-hidden",children:U.map(N=>D(N.id))}),V.length>0&&m.jsxs("div",{className:"ml-auto relative shrink-0",children:[m.jsx("button",{title:"More Tools",onClick:()=>f(!d),className:`p-1.5 rounded hover:bg-gray-200 transition-colors ${d?"bg-gray-200":""}`,children:m.jsx("svg",{className:"w-5 h-5 text-gray-600",fill:"currentColor",viewBox:"0 0 20 20",children:m.jsx("path",{d:"M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM18 10a2 2 0 11-4 0 2 2 0 014 0z"})})}),d&&m.jsx("div",{className:"absolute right-0 mt-2 bg-white border border-gray-200 shadow-2xl rounded-lg p-3 z-[100] flex flex-col gap-4 min-w-[200px] ring-1 ring-black ring-opacity-5",children:V.map(N=>m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-tighter",children:N.id}),m.jsx("div",{onClick:G=>G.stopPropagation(),children:D(N.id)})]},N.id))})]})]}),m.jsx("input",{type:"file",ref:C,onChange:v,accept:"image/*",className:"hidden"}),m.jsx(Rc,{isOpen:u,onClose:()=>c(!1),onInsert:S}),d&&m.jsx("div",{className:"fixed inset-0 z-[90]",onClick:()=>f(!1)})]})},Yo=w.forwardRef(({initialContent:t="",onChange:e,apiKey:n},o)=>{const s=w.useRef(null),[l,a]=w.useState(!1),[u,c]=w.useState([t]),[d,f]=w.useState(0),p=d>0,h=d<u.length-1,g=w.useCallback(E=>{if(E===u[d])return;const _=u.slice(0,d+1);_.push(E),_.length>50&&_.shift(),c(_),f(_.length-1),e==null||e(E)},[u,d,e]);w.useImperativeHandle(o,()=>({getContent:()=>{var E;return((E=s.current)==null?void 0:E.innerHTML)||""},setContent:E=>{s.current&&(s.current.innerHTML=E,g(E))}})),w.useEffect(()=>{s.current&&t&&!s.current.innerHTML&&(s.current.innerHTML=t)},[t]);const y=(E,_)=>{var v,S;(v=s.current)==null||v.focus(),document.execCommand(E,!1,_),g(((S=s.current)==null?void 0:S.innerHTML)||"")},C=()=>{if(p){const E=d-1;f(E),s.current&&(s.current.innerHTML=u[E],e==null||e(u[E]))}},T=()=>{if(h){const E=d+1;f(E),s.current&&(s.current.innerHTML=u[E],e==null||e(u[E]))}};return m.jsxs("div",{className:"w-full max-w-5xl bg-white shadow-xl border border-slate-200 flex flex-col transition-all duration-300",children:[m.jsx("div",{className:"relative z-20",children:m.jsx(kc,{onApplyStyle:y,onOpenHandwritingModal:()=>a(!0),onUndo:C,onRedo:T,canUndo:p,canRedo:h,apiKey:n})}),m.jsx("div",{ref:s,contentEditable:!0,onInput:()=>{var E;return g(((E=s.current)==null?void 0:E.innerHTML)||"")},className:"flex-1 p-4 outline-none prose prose-slate prose-lg max-w-none max-h-[200px] overflow-scroll prose-headings:font-bold prose-a:text-blue-600 prose-img:rounded-xl prose-table:border border-slate-100 bg-white",style:{fontVariantLigatures:"common-ligatures"}}),l&&m.jsx(Pc,{isOpen:l,onClose:()=>a(!1),onInsert:E=>{var _,v;(_=s.current)==null||_.focus(),document.execCommand("insertHTML",!1,`<span contenteditable="false" class="math-container inline-block mx-1 align-middle">${E}</span>&nbsp;`),g(((v=s.current)==null?void 0:v.innerHTML)||"")},apiKey:n})]})});Yo.displayName="Editor",te.Editor=Yo,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});