otherwise-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +193 -0
  2. package/bin/otherwise.js +5 -0
  3. package/frontend/404.html +84 -0
  4. package/frontend/assets/OpenDyslexic3-Bold-CDyRs55Y.ttf +0 -0
  5. package/frontend/assets/OpenDyslexic3-Regular-CIBXa4WE.ttf +0 -0
  6. package/frontend/assets/__vite-browser-external-BIHI7g3E.js +1 -0
  7. package/frontend/assets/conversational-worker-CeKiciGk.js +2929 -0
  8. package/frontend/assets/dictation-worker-D0aYfq8b.js +29 -0
  9. package/frontend/assets/gemini-color-CgSQmmva.png +0 -0
  10. package/frontend/assets/index-BLux5ps4.js +21 -0
  11. package/frontend/assets/index-Blh8_TEM.js +5272 -0
  12. package/frontend/assets/index-BpQ1PuKu.js +18 -0
  13. package/frontend/assets/index-Df737c8w.css +1 -0
  14. package/frontend/assets/index-xaYHL6wb.js +113 -0
  15. package/frontend/assets/ort-wasm-simd-threaded.asyncify-BynIiDiv.wasm +0 -0
  16. package/frontend/assets/ort-wasm-simd-threaded.jsep-B0T3yYHD.wasm +0 -0
  17. package/frontend/assets/transformers-tULNc5V3.js +31 -0
  18. package/frontend/assets/tts-worker-DPJWqT7N.js +2899 -0
  19. package/frontend/assets/voice-mode-worker-GzvIE_uh.js +2927 -0
  20. package/frontend/assets/worker-2d5ABSLU.js +31 -0
  21. package/frontend/banner.png +0 -0
  22. package/frontend/favicon.svg +3 -0
  23. package/frontend/google55e5ec47ee14a5f8.html +1 -0
  24. package/frontend/index.html +234 -0
  25. package/frontend/manifest.json +17 -0
  26. package/frontend/pdf.worker.min.mjs +21 -0
  27. package/frontend/robots.txt +5 -0
  28. package/frontend/sitemap.xml +27 -0
  29. package/package.json +81 -0
  30. package/src/agent/index.js +1066 -0
  31. package/src/agent/location.js +51 -0
  32. package/src/agent/prompt.js +548 -0
  33. package/src/agent/tools.js +4372 -0
  34. package/src/browser/detect.js +68 -0
  35. package/src/browser/session.js +1109 -0
  36. package/src/config.js +137 -0
  37. package/src/email/client.js +503 -0
  38. package/src/index.js +557 -0
  39. package/src/inference/anthropic.js +113 -0
  40. package/src/inference/google.js +373 -0
  41. package/src/inference/index.js +81 -0
  42. package/src/inference/ollama.js +383 -0
  43. package/src/inference/openai.js +140 -0
  44. package/src/inference/openrouter.js +378 -0
  45. package/src/inference/xai.js +200 -0
  46. package/src/logBridge.js +9 -0
  47. package/src/models.js +146 -0
  48. package/src/remote/client.js +225 -0
  49. package/src/scheduler/cron.js +243 -0
  50. package/src/server.js +3876 -0
  51. package/src/storage/db.js +1135 -0
  52. package/src/storage/supabase.js +364 -0
  53. package/src/tunnel/cloudflare.js +241 -0
  54. package/src/ui/components/App.jsx +687 -0
  55. package/src/ui/components/BrowserSelect.jsx +111 -0
  56. package/src/ui/components/FilePicker.jsx +472 -0
  57. package/src/ui/components/Header.jsx +444 -0
  58. package/src/ui/components/HelpPanel.jsx +173 -0
  59. package/src/ui/components/HistoryPanel.jsx +158 -0
  60. package/src/ui/components/MessageList.jsx +235 -0
  61. package/src/ui/components/ModelSelector.jsx +304 -0
  62. package/src/ui/components/PromptInput.jsx +515 -0
  63. package/src/ui/components/StreamingResponse.jsx +134 -0
  64. package/src/ui/components/ThinkingIndicator.jsx +365 -0
  65. package/src/ui/components/ToolExecution.jsx +714 -0
  66. package/src/ui/components/index.js +82 -0
  67. package/src/ui/context/TerminalContext.jsx +150 -0
  68. package/src/ui/context/index.js +13 -0
  69. package/src/ui/hooks/index.js +16 -0
  70. package/src/ui/hooks/useChatState.js +675 -0
  71. package/src/ui/hooks/useCommands.js +280 -0
  72. package/src/ui/hooks/useFileAttachments.js +216 -0
  73. package/src/ui/hooks/useKeyboardShortcuts.js +173 -0
  74. package/src/ui/hooks/useNotifications.js +185 -0
  75. package/src/ui/hooks/useTerminalSize.js +151 -0
  76. package/src/ui/hooks/useWebSocket.js +273 -0
  77. package/src/ui/index.js +94 -0
  78. package/src/ui/ink-runner.js +22 -0
  79. package/src/ui/utils/formatters.js +424 -0
  80. package/src/ui/utils/index.js +6 -0
  81. package/src/ui/utils/markdown.js +166 -0
@@ -0,0 +1,113 @@
1
+ var L;(function(o){o.assertEqual=i=>{};function t(i){}o.assertIs=t;function e(i){throw new Error}o.assertNever=e,o.arrayToEnum=i=>{const l={};for(const a of i)l[a]=a;return l},o.getValidEnumValues=i=>{const l=o.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),a={};for(const u of l)a[u]=i[u];return o.objectValues(a)},o.objectValues=i=>o.objectKeys(i).map(function(l){return i[l]}),o.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const l=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&l.push(a);return l},o.find=(i,l)=>{for(const a of i)if(l(a))return a},o.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,l=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(l)}o.joinValues=n,o.jsonStringifyReplacer=(i,l)=>typeof l=="bigint"?l.toString():l})(L||(L={}));var Tt;(function(o){o.mergeShapes=(t,e)=>({...t,...e})})(Tt||(Tt={}));const C=L.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ee=o=>{switch(typeof o){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN(o)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(o)?C.array:o===null?C.null:o.then&&typeof o.then=="function"&&o.catch&&typeof o.catch=="function"?C.promise:typeof Map<"u"&&o instanceof Map?C.map:typeof Set<"u"&&o instanceof Set?C.set:typeof Date<"u"&&o instanceof Date?C.date:C.object;default:return C.unknown}},v=L.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Q extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(l){return l.message},n={_errors:[]},i=l=>{for(const a of l.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(e(a));else{let u=n,d=0;for(;d<a.path.length;){const c=a.path[d];d===a.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(e(a))):u[c]=u[c]||{_errors:[]},u=u[c],d++}}};return i(this),n}static assert(t){if(!(t instanceof Q))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},n=[];for(const i of this.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:e}}get formErrors(){return this.flatten()}}Q.create=o=>new Q(o);const Ke=(o,t)=>{let e;switch(o.code){case v.invalid_type:o.received===C.undefined?e="Required":e=`Expected ${o.expected}, received ${o.received}`;break;case v.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(o.expected,L.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:e=`Unrecognized key(s) in object: ${L.joinValues(o.keys,", ")}`;break;case v.invalid_union:e="Invalid input";break;case v.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${L.joinValues(o.options)}`;break;case v.invalid_enum_value:e=`Invalid enum value. Expected ${L.joinValues(o.options)}, received '${o.received}'`;break;case v.invalid_arguments:e="Invalid function arguments";break;case v.invalid_return_type:e="Invalid function return type";break;case v.invalid_date:e="Invalid date";break;case v.invalid_string:typeof o.validation=="object"?"includes"in o.validation?(e=`Invalid input: must include "${o.validation.includes}"`,typeof o.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${o.validation.position}`)):"startsWith"in o.validation?e=`Invalid input: must start with "${o.validation.startsWith}"`:"endsWith"in o.validation?e=`Invalid input: must end with "${o.validation.endsWith}"`:L.assertNever(o.validation):o.validation!=="regex"?e=`Invalid ${o.validation}`:e="Invalid";break;case v.too_small:o.type==="array"?e=`Array must contain ${o.exact?"exactly":o.inclusive?"at least":"more than"} ${o.minimum} element(s)`:o.type==="string"?e=`String must contain ${o.exact?"exactly":o.inclusive?"at least":"over"} ${o.minimum} character(s)`:o.type==="number"?e=`Number must be ${o.exact?"exactly equal to ":o.inclusive?"greater than or equal to ":"greater than "}${o.minimum}`:o.type==="date"?e=`Date must be ${o.exact?"exactly equal to ":o.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(o.minimum))}`:e="Invalid input";break;case v.too_big:o.type==="array"?e=`Array must contain ${o.exact?"exactly":o.inclusive?"at most":"less than"} ${o.maximum} element(s)`:o.type==="string"?e=`String must contain ${o.exact?"exactly":o.inclusive?"at most":"under"} ${o.maximum} character(s)`:o.type==="number"?e=`Number must be ${o.exact?"exactly":o.inclusive?"less than or equal to":"less than"} ${o.maximum}`:o.type==="bigint"?e=`BigInt must be ${o.exact?"exactly":o.inclusive?"less than or equal to":"less than"} ${o.maximum}`:o.type==="date"?e=`Date must be ${o.exact?"exactly":o.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(o.maximum))}`:e="Invalid input";break;case v.custom:e="Invalid input";break;case v.invalid_intersection_types:e="Intersection results could not be merged";break;case v.not_multiple_of:e=`Number must be a multiple of ${o.multipleOf}`;break;case v.not_finite:e="Number must be finite";break;default:e=t.defaultError,L.assertNever(o)}return{message:e}};let Eo=Ke;function So(){return Eo}const Ao=o=>{const{data:t,path:e,errorMaps:n,issueData:i}=o,l=[...e,...i.path||[]],a={...i,path:l};if(i.message!==void 0)return{...i,path:l,message:i.message};let u="";const d=n.filter(c=>!!c).slice().reverse();for(const c of d)u=c(a,{data:t,defaultError:u}).message;return{...i,path:l,message:u}};function T(o,t){const e=So(),n=Ao({issueData:t,data:o.data,path:o.path,errorMaps:[o.common.contextualErrorMap,o.schemaErrorMap,e,e===Ke?void 0:Ke].filter(i=>!!i)});o.common.issues.push(n)}class H{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const n=[];for(const i of e){if(i.status==="aborted")return M;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,e){const n=[];for(const i of e){const l=await i.key,a=await i.value;n.push({key:l,value:a})}return H.mergeObjectSync(t,n)}static mergeObjectSync(t,e){const n={};for(const i of e){const{key:l,value:a}=i;if(l.status==="aborted"||a.status==="aborted")return M;l.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),l.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[l.value]=a.value)}return{status:t.value,value:n}}}const M=Object.freeze({status:"aborted"}),Ee=o=>({status:"dirty",value:o}),O=o=>({status:"valid",value:o}),Ct=o=>o.status==="aborted",_t=o=>o.status==="dirty",pe=o=>o.status==="valid",De=o=>typeof Promise<"u"&&o instanceof Promise;var E;(function(o){o.errToObj=t=>typeof t=="string"?{message:t}:t||{},o.toString=t=>typeof t=="string"?t:t?.message})(E||(E={}));class z{constructor(t,e,n,i){this._cachedPath=[],this.parent=t,this.data=e,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Et=(o,t)=>{if(pe(t))return{success:!0,data:t.value};if(!o.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new Q(o.common.issues);return this._error=e,this._error}}};function P(o){if(!o)return{};const{errorMap:t,invalid_type_error:e,required_error:n,description:i}=o;if(t&&(e||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,u)=>{const{message:d}=o;return a.code==="invalid_enum_value"?{message:d??u.defaultError}:typeof u.data>"u"?{message:d??n??u.defaultError}:a.code!=="invalid_type"?{message:u.defaultError}:{message:d??e??u.defaultError}},description:i}}class D{get description(){return this._def.description}_getType(t){return ee(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:ee(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new H,ctx:{common:t.parent.common,data:t.data,parsedType:ee(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(De(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const n=this.safeParse(t,e);if(n.success)return n.data;throw n.error}safeParse(t,e){const n={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ee(t)},i=this._parseSync({data:t,path:n.path,parent:n});return Et(n,i)}"~validate"(t){const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ee(t)};if(!this["~standard"].async)try{const n=this._parseSync({data:t,path:[],parent:e});return pe(n)?{value:n.value}:{issues:e.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(n=>pe(n)?{value:n.value}:{issues:e.common.issues})}async parseAsync(t,e){const n=await this.safeParseAsync(t,e);if(n.success)return n.data;throw n.error}async safeParseAsync(t,e){const n={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ee(t)},i=this._parse({data:t,path:n.path,parent:n}),l=await(De(i)?i:Promise.resolve(i));return Et(n,l)}refine(t,e){const n=i=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(i):e;return this._refinement((i,l)=>{const a=t(i),u=()=>l.addIssue({code:v.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(d=>d?!0:(u(),!1)):a?!0:(u(),!1)})}refinement(t,e){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof e=="function"?e(n,i):e),!1))}_refinement(t){return new ge({schema:this,typeName:I.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return te.create(this,this._def)}nullable(){return ye.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this)}promise(){return Ge.create(this,this._def)}or(t){return Le.create([this,t],this._def)}and(t){return Fe.create(this,t,this._def)}transform(t){return new ge({...P(this._def),schema:this,typeName:I.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new je({...P(this._def),innerType:this,defaultValue:e,typeName:I.ZodDefault})}brand(){return new Yo({typeName:I.ZodBranded,type:this,...P(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new et({...P(this._def),innerType:this,catchValue:e,typeName:I.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return ft.create(this,t)}readonly(){return tt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Io=/^c[^\s-]{8,}$/i,Mo=/^[0-9a-z]+$/,xo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ro=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Po=/^[a-z0-9_-]{21}$/i,wo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,No=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ko=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Do="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ye;const Vo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Lo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Fo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Uo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Go=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Zn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Bo=new RegExp(`^${Zn}$`);function Kn(o){let t="[0-5]\\d";o.precision?t=`${t}\\.\\d{${o.precision}}`:o.precision==null&&(t=`${t}(\\.\\d+)?`);const e=o.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function $o(o){return new RegExp(`^${Kn(o)}$`)}function bo(o){let t=`${Zn}T${Kn(o)}`;const e=[];return e.push(o.local?"Z?":"Z"),o.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function Ho(o,t){return!!((t==="v4"||!t)&&Vo.test(o)||(t==="v6"||!t)&&Fo.test(o))}function Jo(o,t){if(!wo.test(o))return!1;try{const[e]=o.split("."),n=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function Oo(o,t){return!!((t==="v4"||!t)&&Lo.test(o)||(t==="v6"||!t)&&Uo.test(o))}class Y extends D{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==C.string){const l=this._getOrReturnCtx(t);return T(l,{code:v.invalid_type,expected:C.string,received:l.parsedType}),M}const n=new H;let i;for(const l of this._def.checks)if(l.kind==="min")t.data.length<l.value&&(i=this._getOrReturnCtx(t,i),T(i,{code:v.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),n.dirty());else if(l.kind==="max")t.data.length>l.value&&(i=this._getOrReturnCtx(t,i),T(i,{code:v.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),n.dirty());else if(l.kind==="length"){const a=t.data.length>l.value,u=t.data.length<l.value;(a||u)&&(i=this._getOrReturnCtx(t,i),a?T(i,{code:v.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):u&&T(i,{code:v.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),n.dirty())}else if(l.kind==="email")ko.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"email",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="emoji")Ye||(Ye=new RegExp(Do,"u")),Ye.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"emoji",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="uuid")Ro.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"uuid",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="nanoid")Po.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"nanoid",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="cuid")Io.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"cuid",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="cuid2")Mo.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"cuid2",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="ulid")xo.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"ulid",code:v.invalid_string,message:l.message}),n.dirty());else if(l.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),T(i,{validation:"url",code:v.invalid_string,message:l.message}),n.dirty()}else l.kind==="regex"?(l.regex.lastIndex=0,l.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"regex",code:v.invalid_string,message:l.message}),n.dirty())):l.kind==="trim"?t.data=t.data.trim():l.kind==="includes"?t.data.includes(l.value,l.position)||(i=this._getOrReturnCtx(t,i),T(i,{code:v.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),n.dirty()):l.kind==="toLowerCase"?t.data=t.data.toLowerCase():l.kind==="toUpperCase"?t.data=t.data.toUpperCase():l.kind==="startsWith"?t.data.startsWith(l.value)||(i=this._getOrReturnCtx(t,i),T(i,{code:v.invalid_string,validation:{startsWith:l.value},message:l.message}),n.dirty()):l.kind==="endsWith"?t.data.endsWith(l.value)||(i=this._getOrReturnCtx(t,i),T(i,{code:v.invalid_string,validation:{endsWith:l.value},message:l.message}),n.dirty()):l.kind==="datetime"?bo(l).test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{code:v.invalid_string,validation:"datetime",message:l.message}),n.dirty()):l.kind==="date"?Bo.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{code:v.invalid_string,validation:"date",message:l.message}),n.dirty()):l.kind==="time"?$o(l).test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{code:v.invalid_string,validation:"time",message:l.message}),n.dirty()):l.kind==="duration"?No.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"duration",code:v.invalid_string,message:l.message}),n.dirty()):l.kind==="ip"?Ho(t.data,l.version)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"ip",code:v.invalid_string,message:l.message}),n.dirty()):l.kind==="jwt"?Jo(t.data,l.alg)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"jwt",code:v.invalid_string,message:l.message}),n.dirty()):l.kind==="cidr"?Oo(t.data,l.version)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"cidr",code:v.invalid_string,message:l.message}),n.dirty()):l.kind==="base64"?Go.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"base64",code:v.invalid_string,message:l.message}),n.dirty()):l.kind==="base64url"?qo.test(t.data)||(i=this._getOrReturnCtx(t,i),T(i,{validation:"base64url",code:v.invalid_string,message:l.message}),n.dirty()):L.assertNever(l);return{status:n.value,value:t.data}}_regex(t,e,n){return this.refinement(i=>t.test(i),{validation:e,code:v.invalid_string,...E.errToObj(n)})}_addCheck(t){return new Y({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...E.errToObj(t)})}url(t){return this._addCheck({kind:"url",...E.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...E.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...E.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...E.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...E.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...E.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...E.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...E.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...E.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...E.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...E.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...E.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...E.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...E.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...E.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...E.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e?.position,...E.errToObj(e?.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...E.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...E.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...E.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...E.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...E.errToObj(e)})}nonempty(t){return this.min(1,E.errToObj(t))}trim(){return new Y({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Y({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Y({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Y.create=o=>new Y({checks:[],typeName:I.ZodString,coerce:o?.coerce??!1,...P(o)});function Wo(o,t){const e=(o.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=e>n?e:n,l=Number.parseInt(o.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return l%a/10**i}class se extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==C.number){const l=this._getOrReturnCtx(t);return T(l,{code:v.invalid_type,expected:C.number,received:l.parsedType}),M}let n;const i=new H;for(const l of this._def.checks)l.kind==="int"?L.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),T(n,{code:v.invalid_type,expected:"integer",received:"float",message:l.message}),i.dirty()):l.kind==="min"?(l.inclusive?t.data<l.value:t.data<=l.value)&&(n=this._getOrReturnCtx(t,n),T(n,{code:v.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),i.dirty()):l.kind==="max"?(l.inclusive?t.data>l.value:t.data>=l.value)&&(n=this._getOrReturnCtx(t,n),T(n,{code:v.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),i.dirty()):l.kind==="multipleOf"?Wo(t.data,l.value)!==0&&(n=this._getOrReturnCtx(t,n),T(n,{code:v.not_multiple_of,multipleOf:l.value,message:l.message}),i.dirty()):l.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),T(n,{code:v.not_finite,message:l.message}),i.dirty()):L.assertNever(l);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,E.toString(e))}gt(t,e){return this.setLimit("min",t,!1,E.toString(e))}lte(t,e){return this.setLimit("max",t,!0,E.toString(e))}lt(t,e){return this.setLimit("max",t,!1,E.toString(e))}setLimit(t,e,n,i){return new se({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:n,message:E.toString(i)}]})}_addCheck(t){return new se({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:E.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:E.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:E.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:E.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:E.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:E.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:E.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:E.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:E.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&L.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(e===null||n.value>e)&&(e=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(e)&&Number.isFinite(t)}}se.create=o=>new se({checks:[],typeName:I.ZodNumber,coerce:o?.coerce||!1,...P(o)});class re extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==C.bigint)return this._getInvalidInput(t);let n;const i=new H;for(const l of this._def.checks)l.kind==="min"?(l.inclusive?t.data<l.value:t.data<=l.value)&&(n=this._getOrReturnCtx(t,n),T(n,{code:v.too_small,type:"bigint",minimum:l.value,inclusive:l.inclusive,message:l.message}),i.dirty()):l.kind==="max"?(l.inclusive?t.data>l.value:t.data>=l.value)&&(n=this._getOrReturnCtx(t,n),T(n,{code:v.too_big,type:"bigint",maximum:l.value,inclusive:l.inclusive,message:l.message}),i.dirty()):l.kind==="multipleOf"?t.data%l.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),T(n,{code:v.not_multiple_of,multipleOf:l.value,message:l.message}),i.dirty()):L.assertNever(l);return{status:i.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return T(e,{code:v.invalid_type,expected:C.bigint,received:e.parsedType}),M}gte(t,e){return this.setLimit("min",t,!0,E.toString(e))}gt(t,e){return this.setLimit("min",t,!1,E.toString(e))}lte(t,e){return this.setLimit("max",t,!0,E.toString(e))}lt(t,e){return this.setLimit("max",t,!1,E.toString(e))}setLimit(t,e,n,i){return new re({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:n,message:E.toString(i)}]})}_addCheck(t){return new re({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:E.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:E.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:E.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:E.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:E.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}re.create=o=>new re({checks:[],typeName:I.ZodBigInt,coerce:o?.coerce??!1,...P(o)});class Ve extends D{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==C.boolean){const n=this._getOrReturnCtx(t);return T(n,{code:v.invalid_type,expected:C.boolean,received:n.parsedType}),M}return O(t.data)}}Ve.create=o=>new Ve({typeName:I.ZodBoolean,coerce:o?.coerce||!1,...P(o)});class me extends D{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==C.date){const l=this._getOrReturnCtx(t);return T(l,{code:v.invalid_type,expected:C.date,received:l.parsedType}),M}if(Number.isNaN(t.data.getTime())){const l=this._getOrReturnCtx(t);return T(l,{code:v.invalid_date}),M}const n=new H;let i;for(const l of this._def.checks)l.kind==="min"?t.data.getTime()<l.value&&(i=this._getOrReturnCtx(t,i),T(i,{code:v.too_small,message:l.message,inclusive:!0,exact:!1,minimum:l.value,type:"date"}),n.dirty()):l.kind==="max"?t.data.getTime()>l.value&&(i=this._getOrReturnCtx(t,i),T(i,{code:v.too_big,message:l.message,inclusive:!0,exact:!1,maximum:l.value,type:"date"}),n.dirty()):L.assertNever(l);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new me({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:E.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:E.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}me.create=o=>new me({checks:[],coerce:o?.coerce||!1,typeName:I.ZodDate,...P(o)});class St extends D{_parse(t){if(this._getType(t)!==C.symbol){const n=this._getOrReturnCtx(t);return T(n,{code:v.invalid_type,expected:C.symbol,received:n.parsedType}),M}return O(t.data)}}St.create=o=>new St({typeName:I.ZodSymbol,...P(o)});class At extends D{_parse(t){if(this._getType(t)!==C.undefined){const n=this._getOrReturnCtx(t);return T(n,{code:v.invalid_type,expected:C.undefined,received:n.parsedType}),M}return O(t.data)}}At.create=o=>new At({typeName:I.ZodUndefined,...P(o)});class It extends D{_parse(t){if(this._getType(t)!==C.null){const n=this._getOrReturnCtx(t);return T(n,{code:v.invalid_type,expected:C.null,received:n.parsedType}),M}return O(t.data)}}It.create=o=>new It({typeName:I.ZodNull,...P(o)});class Mt extends D{constructor(){super(...arguments),this._any=!0}_parse(t){return O(t.data)}}Mt.create=o=>new Mt({typeName:I.ZodAny,...P(o)});class ze extends D{constructor(){super(...arguments),this._unknown=!0}_parse(t){return O(t.data)}}ze.create=o=>new ze({typeName:I.ZodUnknown,...P(o)});class ne extends D{_parse(t){const e=this._getOrReturnCtx(t);return T(e,{code:v.invalid_type,expected:C.never,received:e.parsedType}),M}}ne.create=o=>new ne({typeName:I.ZodNever,...P(o)});class xt extends D{_parse(t){if(this._getType(t)!==C.undefined){const n=this._getOrReturnCtx(t);return T(n,{code:v.invalid_type,expected:C.void,received:n.parsedType}),M}return O(t.data)}}xt.create=o=>new xt({typeName:I.ZodVoid,...P(o)});class K extends D{_parse(t){const{ctx:e,status:n}=this._processInputParams(t),i=this._def;if(e.parsedType!==C.array)return T(e,{code:v.invalid_type,expected:C.array,received:e.parsedType}),M;if(i.exactLength!==null){const a=e.data.length>i.exactLength.value,u=e.data.length<i.exactLength.value;(a||u)&&(T(e,{code:a?v.too_big:v.too_small,minimum:u?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&e.data.length<i.minLength.value&&(T(e,{code:v.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&e.data.length>i.maxLength.value&&(T(e,{code:v.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),e.common.async)return Promise.all([...e.data].map((a,u)=>i.type._parseAsync(new z(e,a,e.path,u)))).then(a=>H.mergeArray(n,a));const l=[...e.data].map((a,u)=>i.type._parseSync(new z(e,a,e.path,u)));return H.mergeArray(n,l)}get element(){return this._def.type}min(t,e){return new K({...this._def,minLength:{value:t,message:E.toString(e)}})}max(t,e){return new K({...this._def,maxLength:{value:t,message:E.toString(e)}})}length(t,e){return new K({...this._def,exactLength:{value:t,message:E.toString(e)}})}nonempty(t){return this.min(1,t)}}K.create=(o,t)=>new K({type:o,minLength:null,maxLength:null,exactLength:null,typeName:I.ZodArray,...P(t)});function ue(o){if(o instanceof B){const t={};for(const e in o.shape){const n=o.shape[e];t[e]=te.create(ue(n))}return new B({...o._def,shape:()=>t})}else return o instanceof K?new K({...o._def,type:ue(o.element)}):o instanceof te?te.create(ue(o.unwrap())):o instanceof ye?ye.create(ue(o.unwrap())):o instanceof le?le.create(o.items.map(t=>ue(t))):o}class B extends D{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=L.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==C.object){const c=this._getOrReturnCtx(t);return T(c,{code:v.invalid_type,expected:C.object,received:c.parsedType}),M}const{status:n,ctx:i}=this._processInputParams(t),{shape:l,keys:a}=this._getCached(),u=[];if(!(this._def.catchall instanceof ne&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||u.push(c);const d=[];for(const c of a){const f=l[c],p=i.data[c];d.push({key:{status:"valid",value:c},value:f._parse(new z(i,p,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ne){const c=this._def.unknownKeys;if(c==="passthrough")for(const f of u)d.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(c==="strict")u.length>0&&(T(i,{code:v.unrecognized_keys,keys:u}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const f of u){const p=i.data[f];d.push({key:{status:"valid",value:f},value:c._parse(new z(i,p,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const f of d){const p=await f.key,m=await f.value;c.push({key:p,value:m,alwaysSet:f.alwaysSet})}return c}).then(c=>H.mergeObjectSync(n,c)):H.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(t){return E.errToObj,new B({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,n)=>{const i=this._def.errorMap?.(e,n).message??n.defaultError;return e.code==="unrecognized_keys"?{message:E.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new B({...this._def,unknownKeys:"strip"})}passthrough(){return new B({...this._def,unknownKeys:"passthrough"})}extend(t){return new B({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new B({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:I.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new B({...this._def,catchall:t})}pick(t){const e={};for(const n of L.objectKeys(t))t[n]&&this.shape[n]&&(e[n]=this.shape[n]);return new B({...this._def,shape:()=>e})}omit(t){const e={};for(const n of L.objectKeys(this.shape))t[n]||(e[n]=this.shape[n]);return new B({...this._def,shape:()=>e})}deepPartial(){return ue(this)}partial(t){const e={};for(const n of L.objectKeys(this.shape)){const i=this.shape[n];t&&!t[n]?e[n]=i:e[n]=i.optional()}return new B({...this._def,shape:()=>e})}required(t){const e={};for(const n of L.objectKeys(this.shape))if(t&&!t[n])e[n]=this.shape[n];else{let l=this.shape[n];for(;l instanceof te;)l=l._def.innerType;e[n]=l}return new B({...this._def,shape:()=>e})}keyof(){return zn(L.objectKeys(this.shape))}}B.create=(o,t)=>new B({shape:()=>o,unknownKeys:"strip",catchall:ne.create(),typeName:I.ZodObject,...P(t)});B.strictCreate=(o,t)=>new B({shape:()=>o,unknownKeys:"strict",catchall:ne.create(),typeName:I.ZodObject,...P(t)});B.lazycreate=(o,t)=>new B({shape:o,unknownKeys:"strip",catchall:ne.create(),typeName:I.ZodObject,...P(t)});class Le extends D{_parse(t){const{ctx:e}=this._processInputParams(t),n=this._def.options;function i(l){for(const u of l)if(u.result.status==="valid")return u.result;for(const u of l)if(u.result.status==="dirty")return e.common.issues.push(...u.ctx.common.issues),u.result;const a=l.map(u=>new Q(u.ctx.common.issues));return T(e,{code:v.invalid_union,unionErrors:a}),M}if(e.common.async)return Promise.all(n.map(async l=>{const a={...e,common:{...e.common,issues:[]},parent:null};return{result:await l._parseAsync({data:e.data,path:e.path,parent:a}),ctx:a}})).then(i);{let l;const a=[];for(const d of n){const c={...e,common:{...e.common,issues:[]},parent:null},f=d._parseSync({data:e.data,path:e.path,parent:c});if(f.status==="valid")return f;f.status==="dirty"&&!l&&(l={result:f,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(l)return e.common.issues.push(...l.ctx.common.issues),l.result;const u=a.map(d=>new Q(d));return T(e,{code:v.invalid_union,unionErrors:u}),M}}get options(){return this._def.options}}Le.create=(o,t)=>new Le({options:o,typeName:I.ZodUnion,...P(t)});function Xe(o,t){const e=ee(o),n=ee(t);if(o===t)return{valid:!0,data:o};if(e===C.object&&n===C.object){const i=L.objectKeys(t),l=L.objectKeys(o).filter(u=>i.indexOf(u)!==-1),a={...o,...t};for(const u of l){const d=Xe(o[u],t[u]);if(!d.valid)return{valid:!1};a[u]=d.data}return{valid:!0,data:a}}else if(e===C.array&&n===C.array){if(o.length!==t.length)return{valid:!1};const i=[];for(let l=0;l<o.length;l++){const a=o[l],u=t[l],d=Xe(a,u);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return e===C.date&&n===C.date&&+o==+t?{valid:!0,data:o}:{valid:!1}}class Fe extends D{_parse(t){const{status:e,ctx:n}=this._processInputParams(t),i=(l,a)=>{if(Ct(l)||Ct(a))return M;const u=Xe(l.value,a.value);return u.valid?((_t(l)||_t(a))&&e.dirty(),{status:e.value,value:u.data}):(T(n,{code:v.invalid_intersection_types}),M)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([l,a])=>i(l,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Fe.create=(o,t,e)=>new Fe({left:o,right:t,typeName:I.ZodIntersection,...P(e)});class le extends D{_parse(t){const{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==C.array)return T(n,{code:v.invalid_type,expected:C.array,received:n.parsedType}),M;if(n.data.length<this._def.items.length)return T(n,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),M;!this._def.rest&&n.data.length>this._def.items.length&&(T(n,{code:v.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const l=[...n.data].map((a,u)=>{const d=this._def.items[u]||this._def.rest;return d?d._parse(new z(n,a,n.path,u)):null}).filter(a=>!!a);return n.common.async?Promise.all(l).then(a=>H.mergeArray(e,a)):H.mergeArray(e,l)}get items(){return this._def.items}rest(t){return new le({...this._def,rest:t})}}le.create=(o,t)=>{if(!Array.isArray(o))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new le({items:o,typeName:I.ZodTuple,rest:null,...P(t)})};class Ue extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==C.object)return T(n,{code:v.invalid_type,expected:C.object,received:n.parsedType}),M;const i=[],l=this._def.keyType,a=this._def.valueType;for(const u in n.data)i.push({key:l._parse(new z(n,u,n.path,u)),value:a._parse(new z(n,n.data[u],n.path,u)),alwaysSet:u in n.data});return n.common.async?H.mergeObjectAsync(e,i):H.mergeObjectSync(e,i)}get element(){return this._def.valueType}static create(t,e,n){return e instanceof D?new Ue({keyType:t,valueType:e,typeName:I.ZodRecord,...P(n)}):new Ue({keyType:Y.create(),valueType:t,typeName:I.ZodRecord,...P(e)})}}class Rt extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==C.map)return T(n,{code:v.invalid_type,expected:C.map,received:n.parsedType}),M;const i=this._def.keyType,l=this._def.valueType,a=[...n.data.entries()].map(([u,d],c)=>({key:i._parse(new z(n,u,n.path,[c,"key"])),value:l._parse(new z(n,d,n.path,[c,"value"]))}));if(n.common.async){const u=new Map;return Promise.resolve().then(async()=>{for(const d of a){const c=await d.key,f=await d.value;if(c.status==="aborted"||f.status==="aborted")return M;(c.status==="dirty"||f.status==="dirty")&&e.dirty(),u.set(c.value,f.value)}return{status:e.value,value:u}})}else{const u=new Map;for(const d of a){const c=d.key,f=d.value;if(c.status==="aborted"||f.status==="aborted")return M;(c.status==="dirty"||f.status==="dirty")&&e.dirty(),u.set(c.value,f.value)}return{status:e.value,value:u}}}}Rt.create=(o,t,e)=>new Rt({valueType:t,keyType:o,typeName:I.ZodMap,...P(e)});class Ie extends D{_parse(t){const{status:e,ctx:n}=this._processInputParams(t);if(n.parsedType!==C.set)return T(n,{code:v.invalid_type,expected:C.set,received:n.parsedType}),M;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(T(n,{code:v.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),e.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(T(n,{code:v.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),e.dirty());const l=this._def.valueType;function a(d){const c=new Set;for(const f of d){if(f.status==="aborted")return M;f.status==="dirty"&&e.dirty(),c.add(f.value)}return{status:e.value,value:c}}const u=[...n.data.values()].map((d,c)=>l._parse(new z(n,d,n.path,c)));return n.common.async?Promise.all(u).then(d=>a(d)):a(u)}min(t,e){return new Ie({...this._def,minSize:{value:t,message:E.toString(e)}})}max(t,e){return new Ie({...this._def,maxSize:{value:t,message:E.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}Ie.create=(o,t)=>new Ie({valueType:o,minSize:null,maxSize:null,typeName:I.ZodSet,...P(t)});class Qe extends D{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Qe.create=(o,t)=>new Qe({getter:o,typeName:I.ZodLazy,...P(t)});class Pt extends D{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return T(e,{received:e.data,code:v.invalid_literal,expected:this._def.value}),M}return{status:"valid",value:t.data}}get value(){return this._def.value}}Pt.create=(o,t)=>new Pt({value:o,typeName:I.ZodLiteral,...P(t)});function zn(o,t){return new he({values:o,typeName:I.ZodEnum,...P(t)})}class he extends D{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),n=this._def.values;return T(e,{expected:L.joinValues(n),received:e.parsedType,code:v.invalid_type}),M}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),n=this._def.values;return T(e,{received:e.data,code:v.invalid_enum_value,options:n}),M}return O(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return he.create(t,{...this._def,...e})}exclude(t,e=this._def){return he.create(this.options.filter(n=>!t.includes(n)),{...this._def,...e})}}he.create=zn;class wt extends D{_parse(t){const e=L.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==C.string&&n.parsedType!==C.number){const i=L.objectValues(e);return T(n,{expected:L.joinValues(i),received:n.parsedType,code:v.invalid_type}),M}if(this._cache||(this._cache=new Set(L.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=L.objectValues(e);return T(n,{received:n.data,code:v.invalid_enum_value,options:i}),M}return O(t.data)}get enum(){return this._def.values}}wt.create=(o,t)=>new wt({values:o,typeName:I.ZodNativeEnum,...P(t)});class Ge extends D{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==C.promise&&e.common.async===!1)return T(e,{code:v.invalid_type,expected:C.promise,received:e.parsedType}),M;const n=e.parsedType===C.promise?e.data:Promise.resolve(e.data);return O(n.then(i=>this._def.type.parseAsync(i,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Ge.create=(o,t)=>new Ge({type:o,typeName:I.ZodPromise,...P(t)});class ge extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===I.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:n}=this._processInputParams(t),i=this._def.effect||null,l={addIssue:a=>{T(n,a),a.fatal?e.abort():e.dirty()},get path(){return n.path}};if(l.addIssue=l.addIssue.bind(l),i.type==="preprocess"){const a=i.transform(n.data,l);if(n.common.async)return Promise.resolve(a).then(async u=>{if(e.value==="aborted")return M;const d=await this._def.schema._parseAsync({data:u,path:n.path,parent:n});return d.status==="aborted"?M:d.status==="dirty"||e.value==="dirty"?Ee(d.value):d});{if(e.value==="aborted")return M;const u=this._def.schema._parseSync({data:a,path:n.path,parent:n});return u.status==="aborted"?M:u.status==="dirty"||e.value==="dirty"?Ee(u.value):u}}if(i.type==="refinement"){const a=u=>{const d=i.refinement(u,l);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(n.common.async===!1){const u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?M:(u.status==="dirty"&&e.dirty(),a(u.value),{status:e.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?M:(u.status==="dirty"&&e.dirty(),a(u.value).then(()=>({status:e.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!pe(a))return M;const u=i.transform(a.value,l);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>pe(a)?Promise.resolve(i.transform(a.value,l)).then(u=>({status:e.value,value:u})):M);L.assertNever(i)}}ge.create=(o,t,e)=>new ge({schema:o,typeName:I.ZodEffects,effect:t,...P(e)});ge.createWithPreprocess=(o,t,e)=>new ge({schema:t,effect:{type:"preprocess",transform:o},typeName:I.ZodEffects,...P(e)});class te extends D{_parse(t){return this._getType(t)===C.undefined?O(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}te.create=(o,t)=>new te({innerType:o,typeName:I.ZodOptional,...P(t)});class ye extends D{_parse(t){return this._getType(t)===C.null?O(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ye.create=(o,t)=>new ye({innerType:o,typeName:I.ZodNullable,...P(t)});class je extends D{_parse(t){const{ctx:e}=this._processInputParams(t);let n=e.data;return e.parsedType===C.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}je.create=(o,t)=>new je({innerType:o,typeName:I.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...P(t)});class et extends D{_parse(t){const{ctx:e}=this._processInputParams(t),n={...e,common:{...e.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return De(i)?i.then(l=>({status:"valid",value:l.status==="valid"?l.value:this._def.catchValue({get error(){return new Q(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Q(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}et.create=(o,t)=>new et({innerType:o,typeName:I.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...P(t)});class Nt extends D{_parse(t){if(this._getType(t)!==C.nan){const n=this._getOrReturnCtx(t);return T(n,{code:v.invalid_type,expected:C.nan,received:n.parsedType}),M}return{status:"valid",value:t.data}}}Nt.create=o=>new Nt({typeName:I.ZodNaN,...P(o)});class Yo extends D{_parse(t){const{ctx:e}=this._processInputParams(t),n=e.data;return this._def.type._parse({data:n,path:e.path,parent:e})}unwrap(){return this._def.type}}class ft extends D{_parse(t){const{status:e,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const l=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?M:l.status==="dirty"?(e.dirty(),Ee(l.value)):this._def.out._parseAsync({data:l.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?M:i.status==="dirty"?(e.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,e){return new ft({in:t,out:e,typeName:I.ZodPipeline})}}class tt extends D{_parse(t){const e=this._def.innerType._parse(t),n=i=>(pe(i)&&(i.value=Object.freeze(i.value)),i);return De(e)?e.then(i=>n(i)):n(e)}unwrap(){return this._def.innerType}}tt.create=(o,t)=>new tt({innerType:o,typeName:I.ZodReadonly,...P(t)});var I;(function(o){o.ZodString="ZodString",o.ZodNumber="ZodNumber",o.ZodNaN="ZodNaN",o.ZodBigInt="ZodBigInt",o.ZodBoolean="ZodBoolean",o.ZodDate="ZodDate",o.ZodSymbol="ZodSymbol",o.ZodUndefined="ZodUndefined",o.ZodNull="ZodNull",o.ZodAny="ZodAny",o.ZodUnknown="ZodUnknown",o.ZodNever="ZodNever",o.ZodVoid="ZodVoid",o.ZodArray="ZodArray",o.ZodObject="ZodObject",o.ZodUnion="ZodUnion",o.ZodDiscriminatedUnion="ZodDiscriminatedUnion",o.ZodIntersection="ZodIntersection",o.ZodTuple="ZodTuple",o.ZodRecord="ZodRecord",o.ZodMap="ZodMap",o.ZodSet="ZodSet",o.ZodFunction="ZodFunction",o.ZodLazy="ZodLazy",o.ZodLiteral="ZodLiteral",o.ZodEnum="ZodEnum",o.ZodEffects="ZodEffects",o.ZodNativeEnum="ZodNativeEnum",o.ZodOptional="ZodOptional",o.ZodNullable="ZodNullable",o.ZodDefault="ZodDefault",o.ZodCatch="ZodCatch",o.ZodPromise="ZodPromise",o.ZodBranded="ZodBranded",o.ZodPipeline="ZodPipeline",o.ZodReadonly="ZodReadonly"})(I||(I={}));const ie=Y.create,kt=se.create;re.create;const Zo=Ve.create;me.create;const Dt=ze.create;ne.create;const Se=K.create,Ko=B.create,zo=Le.create;Fe.create;le.create;const Xo=Ue.create,Qo=Qe.create,jo=he.create;Ge.create;te.create;ye.create;const ae={string:o=>Y.create({...o,coerce:!0}),number:o=>se.create({...o,coerce:!0}),boolean:o=>Ve.create({...o,coerce:!0}),bigint:o=>re.create({...o,coerce:!0}),date:o=>me.create({...o,coerce:!0})};/**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */let ei,ti;function ni(){return{geminiUrl:ei,vertexUrl:ti}}function oi(o,t,e){var n,i,l;if(!(!((n=o.httpOptions)===null||n===void 0)&&n.baseUrl)){const a=ni();return o.vertexai?(i=a.vertexUrl)!==null&&i!==void 0?i:t:(l=a.geminiUrl)!==null&&l!==void 0?l:e}return o.httpOptions.baseUrl}/**
6
+ * @license
7
+ * Copyright 2025 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */class Te{}function S(o,t){const e=/\{([^}]+)\}/g;return o.replace(e,(n,i)=>{if(Object.prototype.hasOwnProperty.call(t,i)){const l=t[i];return l!=null?String(l):""}else throw new Error(`Key '${i}' not found in valueMap.`)})}function r(o,t,e){for(let l=0;l<t.length-1;l++){const a=t[l];if(a.endsWith("[]")){const u=a.slice(0,-2);if(!(u in o))if(Array.isArray(e))o[u]=Array.from({length:e.length},()=>({}));else throw new Error(`Value must be a list given an array path ${a}`);if(Array.isArray(o[u])){const d=o[u];if(Array.isArray(e))for(let c=0;c<d.length;c++){const f=d[c];r(f,t.slice(l+1),e[c])}else for(const c of d)r(c,t.slice(l+1),e)}return}else if(a.endsWith("[0]")){const u=a.slice(0,-3);u in o||(o[u]=[{}]);const d=o[u];r(d[0],t.slice(l+1),e);return}(!o[a]||typeof o[a]!="object")&&(o[a]={}),o=o[a]}const n=t[t.length-1],i=o[n];if(i!==void 0){if(!e||typeof e=="object"&&Object.keys(e).length===0||e===i)return;if(typeof i=="object"&&typeof e=="object"&&i!==null&&e!==null)Object.assign(i,e);else throw new Error(`Cannot set value for an existing key. Key: ${n}`)}else o[n]=e}function s(o,t){try{if(t.length===1&&t[0]==="_self")return o;for(let e=0;e<t.length;e++){if(typeof o!="object"||o===null)return;const n=t[e];if(n.endsWith("[]")){const i=n.slice(0,-2);if(i in o){const l=o[i];return Array.isArray(l)?l.map(a=>s(a,t.slice(e+1))):void 0}else return}else o=o[n]}return o}catch(e){if(e instanceof TypeError)return;throw e}}/**
10
+ * @license
11
+ * Copyright 2025 Google LLC
12
+ * SPDX-License-Identifier: Apache-2.0
13
+ */var Vt;(function(o){o.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",o.OUTCOME_OK="OUTCOME_OK",o.OUTCOME_FAILED="OUTCOME_FAILED",o.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(Vt||(Vt={}));var Lt;(function(o){o.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",o.PYTHON="PYTHON"})(Lt||(Lt={}));var Z;(function(o){o.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",o.STRING="STRING",o.NUMBER="NUMBER",o.INTEGER="INTEGER",o.BOOLEAN="BOOLEAN",o.ARRAY="ARRAY",o.OBJECT="OBJECT",o.NULL="NULL"})(Z||(Z={}));var Ft;(function(o){o.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",o.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",o.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",o.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",o.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",o.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(Ft||(Ft={}));var Ut;(function(o){o.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",o.SEVERITY="SEVERITY",o.PROBABILITY="PROBABILITY"})(Ut||(Ut={}));var Gt;(function(o){o.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",o.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",o.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",o.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",o.BLOCK_NONE="BLOCK_NONE",o.OFF="OFF"})(Gt||(Gt={}));var qt;(function(o){o.MODE_UNSPECIFIED="MODE_UNSPECIFIED",o.MODE_DYNAMIC="MODE_DYNAMIC"})(qt||(qt={}));var Bt;(function(o){o.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",o.NO_AUTH="NO_AUTH",o.API_KEY_AUTH="API_KEY_AUTH",o.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",o.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",o.OAUTH="OAUTH",o.OIDC_AUTH="OIDC_AUTH"})(Bt||(Bt={}));var $t;(function(o){o.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",o.STOP="STOP",o.MAX_TOKENS="MAX_TOKENS",o.SAFETY="SAFETY",o.RECITATION="RECITATION",o.LANGUAGE="LANGUAGE",o.OTHER="OTHER",o.BLOCKLIST="BLOCKLIST",o.PROHIBITED_CONTENT="PROHIBITED_CONTENT",o.SPII="SPII",o.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",o.IMAGE_SAFETY="IMAGE_SAFETY",o.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL"})($t||($t={}));var bt;(function(o){o.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",o.NEGLIGIBLE="NEGLIGIBLE",o.LOW="LOW",o.MEDIUM="MEDIUM",o.HIGH="HIGH"})(bt||(bt={}));var Ht;(function(o){o.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",o.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",o.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",o.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",o.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Ht||(Ht={}));var Jt;(function(o){o.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",o.SAFETY="SAFETY",o.OTHER="OTHER",o.BLOCKLIST="BLOCKLIST",o.PROHIBITED_CONTENT="PROHIBITED_CONTENT"})(Jt||(Jt={}));var Ot;(function(o){o.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",o.ON_DEMAND="ON_DEMAND",o.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Ot||(Ot={}));var qe;(function(o){o.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",o.TEXT="TEXT",o.IMAGE="IMAGE",o.AUDIO="AUDIO"})(qe||(qe={}));var Wt;(function(o){o.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",o.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",o.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",o.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Wt||(Wt={}));var nt;(function(o){o.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",o.JOB_STATE_QUEUED="JOB_STATE_QUEUED",o.JOB_STATE_PENDING="JOB_STATE_PENDING",o.JOB_STATE_RUNNING="JOB_STATE_RUNNING",o.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",o.JOB_STATE_FAILED="JOB_STATE_FAILED",o.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",o.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",o.JOB_STATE_PAUSED="JOB_STATE_PAUSED",o.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",o.JOB_STATE_UPDATING="JOB_STATE_UPDATING",o.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(nt||(nt={}));var Yt;(function(o){o.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",o.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",o.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",o.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",o.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",o.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",o.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Yt||(Yt={}));var Zt;(function(o){o.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",o.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",o.BALANCED="BALANCED",o.PRIORITIZE_COST="PRIORITIZE_COST"})(Zt||(Zt={}));var Kt;(function(o){o.UNSPECIFIED="UNSPECIFIED",o.BLOCKING="BLOCKING",o.NON_BLOCKING="NON_BLOCKING"})(Kt||(Kt={}));var zt;(function(o){o.MODE_UNSPECIFIED="MODE_UNSPECIFIED",o.MODE_DYNAMIC="MODE_DYNAMIC"})(zt||(zt={}));var Xt;(function(o){o.MODE_UNSPECIFIED="MODE_UNSPECIFIED",o.AUTO="AUTO",o.ANY="ANY",o.NONE="NONE"})(Xt||(Xt={}));var Qt;(function(o){o.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",o.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",o.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR"})(Qt||(Qt={}));var jt;(function(o){o.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",o.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",o.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",o.BLOCK_NONE="BLOCK_NONE"})(jt||(jt={}));var en;(function(o){o.DONT_ALLOW="DONT_ALLOW",o.ALLOW_ADULT="ALLOW_ADULT",o.ALLOW_ALL="ALLOW_ALL"})(en||(en={}));var tn;(function(o){o.auto="auto",o.en="en",o.ja="ja",o.ko="ko",o.hi="hi"})(tn||(tn={}));var nn;(function(o){o.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",o.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",o.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",o.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",o.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(nn||(nn={}));var on;(function(o){o.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",o.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",o.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",o.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(on||(on={}));var sn;(function(o){o.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",o.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",o.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",o.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(sn||(sn={}));var rn;(function(o){o.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",o.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",o.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",o.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",o.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",o.EDIT_MODE_STYLE="EDIT_MODE_STYLE",o.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",o.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(rn||(rn={}));var ln;(function(o){o.STATE_UNSPECIFIED="STATE_UNSPECIFIED",o.PROCESSING="PROCESSING",o.ACTIVE="ACTIVE",o.FAILED="FAILED"})(ln||(ln={}));var an;(function(o){o.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",o.UPLOADED="UPLOADED",o.GENERATED="GENERATED"})(an||(an={}));var un;(function(o){o.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",o.TEXT="TEXT",o.IMAGE="IMAGE",o.VIDEO="VIDEO",o.AUDIO="AUDIO",o.DOCUMENT="DOCUMENT"})(un||(un={}));var cn;(function(o){o.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",o.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",o.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(cn||(cn={}));var dn;(function(o){o.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",o.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",o.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(dn||(dn={}));var fn;(function(o){o.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",o.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",o.NO_INTERRUPTION="NO_INTERRUPTION"})(fn||(fn={}));var pn;(function(o){o.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",o.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",o.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(pn||(pn={}));var mn;(function(o){o.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",o.SILENT="SILENT",o.WHEN_IDLE="WHEN_IDLE",o.INTERRUPT="INTERRUPT"})(mn||(mn={}));var hn;(function(o){o.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",o.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",o.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",o.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",o.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",o.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",o.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",o.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",o.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",o.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",o.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",o.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",o.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(hn||(hn={}));var ce;(function(o){o.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",o.PLAY="PLAY",o.PAUSE="PAUSE",o.STOP="STOP",o.RESET_CONTEXT="RESET_CONTEXT"})(ce||(ce={}));class _e{get text(){var t,e,n,i,l,a,u,d;if(((i=(n=(e=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||e===void 0?void 0:e.content)===null||n===void 0?void 0:n.parts)===null||i===void 0?void 0:i.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 c="",f=!1;const p=[];for(const m of(d=(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&&d!==void 0?d:[]){for(const[h,g]of Object.entries(m))h!=="text"&&h!=="thought"&&(g!==null||g!==void 0)&&p.push(h);if(typeof m.text=="string"){if(typeof m.thought=="boolean"&&m.thought)continue;f=!0,c+=m.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?c:void 0}get data(){var t,e,n,i,l,a,u,d;if(((i=(n=(e=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||e===void 0?void 0:e.content)===null||n===void 0?void 0:n.parts)===null||i===void 0?void 0:i.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 c="";const f=[];for(const p of(d=(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&&d!==void 0?d:[]){for(const[m,h]of Object.entries(p))m!=="inlineData"&&(h!==null||h!==void 0)&&f.push(m);p.inlineData&&typeof p.inlineData.data=="string"&&(c+=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.`),c.length>0?btoa(c):void 0}get functionCalls(){var t,e,n,i,l,a,u,d;if(((i=(n=(e=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||e===void 0?void 0:e.content)===null||n===void 0?void 0:n.parts)===null||i===void 0?void 0:i.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 c=(d=(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||d===void 0?void 0:d.filter(f=>f.functionCall).map(f=>f.functionCall).filter(f=>f!==void 0);if(c?.length!==0)return c}get executableCode(){var t,e,n,i,l,a,u,d,c;if(((i=(n=(e=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||e===void 0?void 0:e.content)===null||n===void 0?void 0:n.parts)===null||i===void 0?void 0:i.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=(d=(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||d===void 0?void 0:d.filter(p=>p.executableCode).map(p=>p.executableCode).filter(p=>p!==void 0);if(f?.length!==0)return(c=f?.[0])===null||c===void 0?void 0:c.code}get codeExecutionResult(){var t,e,n,i,l,a,u,d,c;if(((i=(n=(e=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||e===void 0?void 0:e.content)===null||n===void 0?void 0:n.parts)===null||i===void 0?void 0:i.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=(d=(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||d===void 0?void 0:d.filter(p=>p.codeExecutionResult).map(p=>p.codeExecutionResult).filter(p=>p!==void 0);if(f?.length!==0)return(c=f?.[0])===null||c===void 0?void 0:c.output}}class gn{}class yn{}class ii{}class si{}class vn{}class Tn{}class Cn{}class ri{}class _n{}class En{}class Sn{}class li{}class ot{constructor(t){const e={};for(const n of t.headers.entries())e[n[0]]=n[1];this.headers=e,this.responseInternal=t}json(){return this.responseInternal.json()}}class ai{}class ui{}class ci{get text(){var t,e,n;let i="",l=!1;const a=[];for(const u of(n=(e=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||e===void 0?void 0:e.parts)!==null&&n!==void 0?n:[]){for(const[d,c]of Object.entries(u))d!=="text"&&d!=="thought"&&c!==null&&a.push(d);if(typeof u.text=="string"){if(typeof u.thought=="boolean"&&u.thought)continue;l=!0,i+=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?i:void 0}get data(){var t,e,n;let i="";const l=[];for(const a of(n=(e=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||e===void 0?void 0:e.parts)!==null&&n!==void 0?n:[]){for(const[u,d]of Object.entries(a))u!=="inlineData"&&d!==null&&l.push(u);a.inlineData&&typeof a.inlineData.data=="string"&&(i+=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.`),i.length>0?btoa(i):void 0}}class di{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}/**
14
+ * @license
15
+ * Copyright 2025 Google LLC
16
+ * SPDX-License-Identifier: Apache-2.0
17
+ */function G(o,t){if(!t||typeof t!="string")throw new Error("model is required and must be a string");if(o.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const e=t.split("/",2);return`publishers/${e[0]}/models/${e[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function Xn(o,t){const e=G(o,t);return e?e.startsWith("publishers/")&&o.isVertexAI()?`projects/${o.getProject()}/locations/${o.getLocation()}/${e}`:e.startsWith("models/")&&o.isVertexAI()?`projects/${o.getProject()}/locations/${o.getLocation()}/publishers/google/${e}`:e:""}function Qn(o,t){return Array.isArray(t)?t.map(e=>Be(o,e)):[Be(o,t)]}function Be(o,t){if(typeof t=="object"&&t!==null)return t;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof t}`)}function fi(o,t){const e=Be(o,t);if(e.mimeType&&e.mimeType.startsWith("image/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function pi(o,t){const e=Be(o,t);if(e.mimeType&&e.mimeType.startsWith("audio/"))return e;throw new Error(`Unsupported mime type: ${e.mimeType}`)}function An(o,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 jn(o,t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("PartListUnion is required");return Array.isArray(t)?t.map(e=>An(o,e)):[An(o,t)]}function it(o){return o!=null&&typeof o=="object"&&"parts"in o&&Array.isArray(o.parts)}function In(o){return o!=null&&typeof o=="object"&&"functionCall"in o}function Mn(o){return o!=null&&typeof o=="object"&&"functionResponse"in o}function b(o,t){if(t==null)throw new Error("ContentUnion is required");return it(t)?t:{role:"user",parts:jn(o,t)}}function eo(o,t){if(!t)return[];if(o.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{const n=b(o,e);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]});if(o.isVertexAI()){const e=b(o,t);return e.parts&&e.parts.length>0&&e.parts[0].text!==void 0?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>b(o,e)):[b(o,t)]}function W(o,t){if(t==null||Array.isArray(t)&&t.length===0)throw new Error("contents are required");if(!Array.isArray(t)){if(In(t)||Mn(t))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[b(o,t)]}const e=[],n=[],i=it(t[0]);for(const l of t){const a=it(l);if(a!=i)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(a)e.push(l);else{if(In(l)||Mn(l))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(l)}}return i||e.push({role:"user",parts:jn(o,n)}),e}const mi=new Set(["type","format","title","description","default","items","minItems","maxItems","enum","properties","required","minProperties","maxProperties","minimum","maximum","minLength","maxLength","pattern","anyOf","propertyOrdering"]),xn=jo(["string","number","integer","object","array","boolean","null"]),hi=zo([xn,Se(xn)]);function gi(o=!0){const t=Qo(()=>{const e=Ko({type:hi.optional(),format:ie().optional(),title:ie().optional(),description:ie().optional(),default:Dt().optional(),items:t.optional(),minItems:ae.string().optional(),maxItems:ae.string().optional(),enum:Se(Dt()).optional(),properties:Xo(ie(),t).optional(),required:Se(ie()).optional(),minProperties:ae.string().optional(),maxProperties:ae.string().optional(),propertyOrdering:Se(ie()).optional(),minimum:kt().optional(),maximum:kt().optional(),minLength:ae.string().optional(),maxLength:ae.string().optional(),pattern:ie().optional(),anyOf:Se(t).optional(),additionalProperties:Zo().optional()});return o?e.strict():e});return t}function yi(o,t){o.includes("null")&&(t.nullable=!0);const e=o.filter(n=>n!=="null");if(e.length===1)t.type=Object.values(Z).includes(e[0].toUpperCase())?e[0].toUpperCase():Z.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const n of e)t.anyOf.push({type:Object.values(Z).includes(n.toUpperCase())?n.toUpperCase():Z.TYPE_UNSPECIFIED})}}function de(o){const t={},e=["items"],n=["anyOf"],i=["properties"];if(o.type&&o.anyOf)throw new Error("type and anyOf cannot be both populated.");const l=o.anyOf;l!=null&&l.length==2&&(l[0].type==="null"?(t.nullable=!0,o=l[1]):l[1].type==="null"&&(t.nullable=!0,o=l[0])),o.type instanceof Array&&yi(o.type,t);for(const[a,u]of Object.entries(o))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;t.type=Object.values(Z).includes(u.toUpperCase())?u.toUpperCase():Z.TYPE_UNSPECIFIED}else if(e.includes(a))t[a]=de(u);else if(n.includes(a)){const d=[];for(const c of u){if(c.type=="null"){t.nullable=!0;continue}d.push(de(c))}t[a]=d}else if(i.includes(a)){const d={};for(const[c,f]of Object.entries(u))d[c]=de(f);t[a]=d}else{if(a==="additionalProperties")continue;t[a]=u}return t}function $e(o,t){if(Object.keys(t).includes("$schema")){delete t.$schema;const e=gi().parse(t);return de(e)}else return de(t)}function to(o,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 pt(o,t){if("multiSpeakerVoiceConfig"in t)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return t}function Me(o,t){if(t.functionDeclarations)for(const e of t.functionDeclarations)e.parameters&&(e.parameters=$e(o,e.parameters)),e.response&&(e.response=$e(o,e.response));return t}function xe(o,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 vi(o,t,e,n=1){const i=!t.startsWith(`${e}/`)&&t.split("/").length===n;return o.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${o.getProject()}/${t}`:t.startsWith(`${e}/`)?`projects/${o.getProject()}/locations/${o.getLocation()}/${t}`:i?`projects/${o.getProject()}/locations/${o.getLocation()}/${e}/${t}`:t:i?`${e}/${t}`:t}function oe(o,t){if(typeof t!="string")throw new Error("name must be a string");return vi(o,t,"cachedContents")}function no(o,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 j(o,t){if(typeof t!="string")throw new Error("fromImageBytes must be a string");return t}function Ti(o){return o!=null&&typeof o=="object"&&"name"in o}function Ci(o){return o!=null&&typeof o=="object"&&"video"in o}function _i(o){return o!=null&&typeof o=="object"&&"uri"in o}function oo(o,t){var e;let n;if(Ti(t)&&(n=t.name),!(_i(t)&&(n=t.uri,n===void 0))&&!(Ci(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 l=n.split("files/")[1].match(/[a-z0-9]+/);if(l===null)throw new Error(`Could not extract file name from URI ${n}`);n=l[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}function io(o,t){let e;return o.isVertexAI()?e=t?"publishers/google/models":"models":e=t?"models":"tunedModels",e}function so(o,t){for(const e of["models","tunedModels","publisherModels"])if(Ei(t,e))return t[e];return[]}function Ei(o,t){return o!==null&&typeof o=="object"&&t in o}function Si(o,t={}){const e=o,n={name:e.name,description:e.description,parameters:de(be(e.inputSchema))};return t.behavior&&(n.behavior=t.behavior),{functionDeclarations:[n]}}function Ai(o,t={}){const e=[],n=new Set;for(const i of o){const l=i.name;if(n.has(l))throw new Error(`Duplicate function name ${l} found in MCP tools. Please ensure function names are unique.`);n.add(l);const a=Si(i,t);a.functionDeclarations&&e.push(...a.functionDeclarations)}return{functionDeclarations:e}}function Ii(o){const t=[];for(const e of o)t.push(be(e));return t}function Mi(o){const t={};for(const[e,n]of Object.entries(o)){const i=n;t[e]=be(i)}return t}function be(o){const t=new Set(["items"]),e=new Set(["anyOf"]),n=new Set(["properties"]),i={};for(const[l,a]of Object.entries(o))if(t.has(l))i[l]=be(a);else if(e.has(l))i[l]=Ii(a);else if(n.has(l))i[l]=Mi(a);else if(l==="type"){const u=a.toUpperCase();i[l]=Object.values(Z).includes(u)?u:Z.TYPE_UNSPECIFIED}else mi.has(l)&&(i[l]=a);return i}/**
18
+ * @license
19
+ * Copyright 2025 Google LLC
20
+ * SPDX-License-Identifier: Apache-2.0
21
+ */function xi(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function Ri(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function Pi(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function wi(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],xi(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],Ri(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],Pi(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function Rn(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>wi(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function Ni(o,t){const e={},n=s(t,["behavior"]);n!=null&&r(e,["behavior"],n);const i=s(t,["description"]);i!=null&&r(e,["description"],i);const l=s(t,["name"]);l!=null&&r(e,["name"],l);const a=s(t,["parameters"]);a!=null&&r(e,["parameters"],a);const u=s(t,["response"]);return u!=null&&r(e,["response"],u),e}function ki(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function Di(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],ki(o,n)),e}function Vi(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function Li(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],Vi(o,n)),e}function Fi(){return{}}function Ui(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>Ni(o,c))),r(e,["functionDeclarations"],d)}if(s(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const i=s(t,["googleSearch"]);i!=null&&r(e,["googleSearch"],Di(o,i));const l=s(t,["googleSearchRetrieval"]);if(l!=null&&r(e,["googleSearchRetrieval"],Li(o,l)),s(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(s(t,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");s(t,["urlContext"])!=null&&r(e,["urlContext"],Fi());const u=s(t,["codeExecution"]);return u!=null&&r(e,["codeExecution"],u),e}function Gi(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["allowedFunctionNames"]);return i!=null&&r(e,["allowedFunctionNames"],i),e}function qi(o,t){const e={},n=s(t,["latitude"]);n!=null&&r(e,["latitude"],n);const i=s(t,["longitude"]);return i!=null&&r(e,["longitude"],i),e}function Bi(o,t){const e={},n=s(t,["latLng"]);n!=null&&r(e,["latLng"],qi(o,n));const i=s(t,["languageCode"]);return i!=null&&r(e,["languageCode"],i),e}function $i(o,t){const e={},n=s(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],Gi(o,n));const i=s(t,["retrievalConfig"]);return i!=null&&r(e,["retrievalConfig"],Bi(o,i)),e}function bi(o,t,e){const n={},i=s(t,["ttl"]);e!==void 0&&i!=null&&r(e,["ttl"],i);const l=s(t,["expireTime"]);e!==void 0&&l!=null&&r(e,["expireTime"],l);const a=s(t,["displayName"]);e!==void 0&&a!=null&&r(e,["displayName"],a);const u=s(t,["contents"]);if(e!==void 0&&u!=null){let p=W(o,u);Array.isArray(p)&&(p=p.map(m=>Rn(o,m))),r(e,["contents"],p)}const d=s(t,["systemInstruction"]);e!==void 0&&d!=null&&r(e,["systemInstruction"],Rn(o,b(o,d)));const c=s(t,["tools"]);if(e!==void 0&&c!=null){let p=c;Array.isArray(p)&&(p=p.map(m=>Ui(o,m))),r(e,["tools"],p)}const f=s(t,["toolConfig"]);if(e!==void 0&&f!=null&&r(e,["toolConfig"],$i(o,f)),s(t,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function Hi(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["model"],Xn(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],bi(o,i,e)),e}function Ji(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],oe(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Oi(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],oe(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Wi(o,t,e){const n={},i=s(t,["ttl"]);e!==void 0&&i!=null&&r(e,["ttl"],i);const l=s(t,["expireTime"]);return e!==void 0&&l!=null&&r(e,["expireTime"],l),n}function Yi(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],oe(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],Wi(o,i,e)),e}function Zi(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);return e!==void 0&&l!=null&&r(e,["_query","pageToken"],l),n}function Ki(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],Zi(o,n,e)),e}function zi(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function Xi(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["data"]);i!=null&&r(e,["data"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function Qi(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["fileUri"]);i!=null&&r(e,["fileUri"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function ji(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],zi(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],Xi(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],Qi(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function Pn(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>ji(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function es(o,t){const e={};if(s(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=s(t,["description"]);n!=null&&r(e,["description"],n);const i=s(t,["name"]);i!=null&&r(e,["name"],i);const l=s(t,["parameters"]);l!=null&&r(e,["parameters"],l);const a=s(t,["response"]);return a!=null&&r(e,["response"],a),e}function ts(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function ns(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],ts(o,n)),e}function os(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function is(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],os(o,n)),e}function ss(){return{}}function rs(o,t){const e={},n=s(t,["apiKeyString"]);return n!=null&&r(e,["apiKeyString"],n),e}function ls(o,t){const e={},n=s(t,["apiKeyConfig"]);n!=null&&r(e,["apiKeyConfig"],rs(o,n));const i=s(t,["authType"]);i!=null&&r(e,["authType"],i);const l=s(t,["googleServiceAccountConfig"]);l!=null&&r(e,["googleServiceAccountConfig"],l);const a=s(t,["httpBasicAuthConfig"]);a!=null&&r(e,["httpBasicAuthConfig"],a);const u=s(t,["oauthConfig"]);u!=null&&r(e,["oauthConfig"],u);const d=s(t,["oidcConfig"]);return d!=null&&r(e,["oidcConfig"],d),e}function as(o,t){const e={},n=s(t,["authConfig"]);return n!=null&&r(e,["authConfig"],ls(o,n)),e}function us(){return{}}function cs(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(m=>es(o,m))),r(e,["functionDeclarations"],p)}const i=s(t,["retrieval"]);i!=null&&r(e,["retrieval"],i);const l=s(t,["googleSearch"]);l!=null&&r(e,["googleSearch"],ns(o,l));const a=s(t,["googleSearchRetrieval"]);a!=null&&r(e,["googleSearchRetrieval"],is(o,a)),s(t,["enterpriseWebSearch"])!=null&&r(e,["enterpriseWebSearch"],ss());const d=s(t,["googleMaps"]);d!=null&&r(e,["googleMaps"],as(o,d)),s(t,["urlContext"])!=null&&r(e,["urlContext"],us());const f=s(t,["codeExecution"]);return f!=null&&r(e,["codeExecution"],f),e}function ds(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["allowedFunctionNames"]);return i!=null&&r(e,["allowedFunctionNames"],i),e}function fs(o,t){const e={},n=s(t,["latitude"]);n!=null&&r(e,["latitude"],n);const i=s(t,["longitude"]);return i!=null&&r(e,["longitude"],i),e}function ps(o,t){const e={},n=s(t,["latLng"]);n!=null&&r(e,["latLng"],fs(o,n));const i=s(t,["languageCode"]);return i!=null&&r(e,["languageCode"],i),e}function ms(o,t){const e={},n=s(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],ds(o,n));const i=s(t,["retrievalConfig"]);return i!=null&&r(e,["retrievalConfig"],ps(o,i)),e}function hs(o,t,e){const n={},i=s(t,["ttl"]);e!==void 0&&i!=null&&r(e,["ttl"],i);const l=s(t,["expireTime"]);e!==void 0&&l!=null&&r(e,["expireTime"],l);const a=s(t,["displayName"]);e!==void 0&&a!=null&&r(e,["displayName"],a);const u=s(t,["contents"]);if(e!==void 0&&u!=null){let m=W(o,u);Array.isArray(m)&&(m=m.map(h=>Pn(o,h))),r(e,["contents"],m)}const d=s(t,["systemInstruction"]);e!==void 0&&d!=null&&r(e,["systemInstruction"],Pn(o,b(o,d)));const c=s(t,["tools"]);if(e!==void 0&&c!=null){let m=c;Array.isArray(m)&&(m=m.map(h=>cs(o,h))),r(e,["tools"],m)}const f=s(t,["toolConfig"]);e!==void 0&&f!=null&&r(e,["toolConfig"],ms(o,f));const p=s(t,["kmsKeyName"]);return e!==void 0&&p!=null&&r(e,["encryption_spec","kmsKeyName"],p),n}function gs(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["model"],Xn(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],hs(o,i,e)),e}function ys(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],oe(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function vs(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],oe(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Ts(o,t,e){const n={},i=s(t,["ttl"]);e!==void 0&&i!=null&&r(e,["ttl"],i);const l=s(t,["expireTime"]);return e!==void 0&&l!=null&&r(e,["expireTime"],l),n}function Cs(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],oe(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],Ts(o,i,e)),e}function _s(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);return e!==void 0&&l!=null&&r(e,["_query","pageToken"],l),n}function Es(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],_s(o,n,e)),e}function we(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["displayName"]);i!=null&&r(e,["displayName"],i);const l=s(t,["model"]);l!=null&&r(e,["model"],l);const a=s(t,["createTime"]);a!=null&&r(e,["createTime"],a);const u=s(t,["updateTime"]);u!=null&&r(e,["updateTime"],u);const d=s(t,["expireTime"]);d!=null&&r(e,["expireTime"],d);const c=s(t,["usageMetadata"]);return c!=null&&r(e,["usageMetadata"],c),e}function Ss(){return{}}function As(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["cachedContents"]);if(i!=null){let l=i;Array.isArray(l)&&(l=l.map(a=>we(o,a))),r(e,["cachedContents"],l)}return e}function Ne(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["displayName"]);i!=null&&r(e,["displayName"],i);const l=s(t,["model"]);l!=null&&r(e,["model"],l);const a=s(t,["createTime"]);a!=null&&r(e,["createTime"],a);const u=s(t,["updateTime"]);u!=null&&r(e,["updateTime"],u);const d=s(t,["expireTime"]);d!=null&&r(e,["expireTime"],d);const c=s(t,["usageMetadata"]);return c!=null&&r(e,["usageMetadata"],c),e}function Is(){return{}}function Ms(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["cachedContents"]);if(i!=null){let l=i;Array.isArray(l)&&(l=l.map(a=>Ne(o,a))),r(e,["cachedContents"],l)}return e}/**
22
+ * @license
23
+ * Copyright 2025 Google LLC
24
+ * SPDX-License-Identifier: Apache-2.0
25
+ */var ve;(function(o){o.PAGED_ITEM_BATCH_JOBS="batchJobs",o.PAGED_ITEM_MODELS="models",o.PAGED_ITEM_TUNING_JOBS="tuningJobs",o.PAGED_ITEM_FILES="files",o.PAGED_ITEM_CACHED_CONTENTS="cachedContents"})(ve||(ve={}));class He{constructor(t,e,n,i){this.pageInternal=[],this.paramsInternal={},this.requestInternal=e,this.init(t,n,i)}init(t,e,n){var i,l;this.nameInternal=t,this.pageInternal=e[this.nameInternal]||[],this.idxInternal=0;let a={config:{}};n?typeof n=="object"?a=Object.assign({},n):a=n:a={config:{}},a.config&&(a.config.pageToken=e.nextPageToken),this.paramsInternal=a,this.pageInternalSize=(l=(i=a.config)===null||i===void 0?void 0:i.pageSize)!==null&&l!==void 0?l:this.pageInternal.length}initNextPage(t){this.init(this.nameInternal,t,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(t){return this.pageInternal[t]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const t=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:t,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const t=await this.requestInternal(this.params);return this.initNextPage(t),this.page}hasNextPage(){var t;return((t=this.params.config)===null||t===void 0?void 0:t.pageToken)!==void 0}}/**
26
+ * @license
27
+ * Copyright 2025 Google LLC
28
+ * SPDX-License-Identifier: Apache-2.0
29
+ */class xs extends Te{constructor(t){super(),this.apiClient=t,this.list=async(e={})=>new He(ve.PAGED_ITEM_CACHED_CONTENTS,n=>this.listInternal(n),await this.listInternal(e),e)}async create(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=gs(this.apiClient,t);return u=S("cachedContents",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>Ne(this.apiClient,f))}else{const c=Hi(this.apiClient,t);return u=S("cachedContents",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>we(this.apiClient,f))}}async get(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=ys(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>Ne(this.apiClient,f))}else{const c=Ji(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>we(this.apiClient,f))}}async delete(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=vs(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(()=>{const f=Is(),p=new En;return Object.assign(p,f),p})}else{const c=Oi(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(()=>{const f=Ss(),p=new En;return Object.assign(p,f),p})}}async update(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Cs(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>Ne(this.apiClient,f))}else{const c=Yi(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>we(this.apiClient,f))}}async listInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Es(this.apiClient,t);return u=S("cachedContents",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Ms(this.apiClient,f),m=new Sn;return Object.assign(m,p),m})}else{const c=Ki(this.apiClient,t);return u=S("cachedContents",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=As(this.apiClient,f),m=new Sn;return Object.assign(m,p),m})}}}function wn(o){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&o[t],n=0;if(e)return e.call(o);if(o&&typeof o.length=="number")return{next:function(){return o&&n>=o.length&&(o=void 0),{value:o&&o[n++],done:!o}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function q(o){return this instanceof q?(this.v=o,this):new q(o)}function fe(o,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(o,t||[]),i,l=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(h){return function(g){return Promise.resolve(g).then(h,p)}}function u(h,g){n[h]&&(i[h]=function(y){return new Promise(function(_,A){l.push([h,y,_,A])>1||d(h,y)})},g&&(i[h]=g(i[h])))}function d(h,g){try{c(n[h](g))}catch(y){m(l[0][3],y)}}function c(h){h.value instanceof q?Promise.resolve(h.value.v).then(f,p):m(l[0][2],h)}function f(h){d("next",h)}function p(h){d("throw",h)}function m(h,g){h(g),l.shift(),l.length&&d(l[0][0],l[0][1])}}function Ae(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=o[Symbol.asyncIterator],e;return t?t.call(o):(o=typeof wn=="function"?wn(o):o[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(l){e[l]=o[l]&&function(a){return new Promise(function(u,d){a=o[l](a),i(u,d,a.done,a.value)})}}function i(l,a,u,d){Promise.resolve(d).then(function(c){l({value:c,done:u})},a)}}/**
30
+ * @license
31
+ * Copyright 2025 Google LLC
32
+ * SPDX-License-Identifier: Apache-2.0
33
+ */function Rs(o){var t;if(o.candidates==null||o.candidates.length===0)return!1;const e=(t=o.candidates[0])===null||t===void 0?void 0:t.content;return e===void 0?!1:ro(e)}function ro(o){if(o.parts===void 0||o.parts.length===0)return!1;for(const t of o.parts)if(t===void 0||Object.keys(t).length===0||!t.thought&&t.text!==void 0&&t.text==="")return!1;return!0}function Ps(o){if(o.length!==0){for(const t of o)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function Nn(o){if(o===void 0||o.length===0)return[];const t=[],e=o.length;let n=0;for(;n<e;)if(o[n].role==="user")t.push(o[n]),n++;else{const i=[];let l=!0;for(;n<e&&o[n].role==="model";)i.push(o[n]),l&&!ro(o[n])&&(l=!1),n++;l?t.push(...i):t.pop()}return t}class ws{constructor(t,e){this.modelsModule=t,this.apiClient=e}create(t){return new Ns(this.apiClient,this.modelsModule,t.model,t.config,structuredClone(t.history))}}class Ns{constructor(t,e,n,i={},l=[]){this.apiClient=t,this.modelsModule=e,this.model=n,this.config=i,this.history=l,this.sendPromise=Promise.resolve(),Ps(l)}async sendMessage(t){var e;await this.sendPromise;const n=b(this.apiClient,t.message),i=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(n),config:(e=t.config)!==null&&e!==void 0?e:this.config});return this.sendPromise=(async()=>{var l,a,u;const d=await i,c=(a=(l=d.candidates)===null||l===void 0?void 0:l[0])===null||a===void 0?void 0:a.content,f=d.automaticFunctionCallingHistory,p=this.getHistory(!0).length;let m=[];f!=null&&(m=(u=f.slice(p))!==null&&u!==void 0?u:[]);const h=c?[c]:[];this.recordHistory(n,h,m)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),i}async sendMessageStream(t){var e;await this.sendPromise;const n=b(this.apiClient,t.message),i=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(n),config:(e=t.config)!==null&&e!==void 0?e:this.config});this.sendPromise=i.then(()=>{}).catch(()=>{});const l=await i;return this.processStreamResponse(l,n)}getHistory(t=!1){const e=t?Nn(this.history):this.history;return structuredClone(e)}processStreamResponse(t,e){var n,i;return fe(this,arguments,function*(){var a,u,d,c;const f=[];try{for(var p=!0,m=Ae(t),h;h=yield q(m.next()),a=h.done,!a;p=!0){c=h.value,p=!1;const g=c;if(Rs(g)){const y=(i=(n=g.candidates)===null||n===void 0?void 0:n[0])===null||i===void 0?void 0:i.content;y!==void 0&&f.push(y)}yield yield q(g)}}catch(g){u={error:g}}finally{try{!p&&!a&&(d=m.return)&&(yield q(d.call(m)))}finally{if(u)throw u.error}}this.recordHistory(e,f)})}recordHistory(t,e,n){let i=[];e.length>0&&e.every(l=>l.role!==void 0)?i=e:i.push({role:"model",parts:[]}),n&&n.length>0?this.history.push(...Nn(n)):this.history.push(t),this.history.push(...i)}}/**
34
+ * @license
35
+ * Copyright 2025 Google LLC
36
+ * SPDX-License-Identifier: Apache-2.0
37
+ */function ks(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);return e!==void 0&&l!=null&&r(e,["_query","pageToken"],l),n}function Ds(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],ks(o,n,e)),e}function Vs(o,t){const e={},n=s(t,["details"]);n!=null&&r(e,["details"],n);const i=s(t,["message"]);i!=null&&r(e,["message"],i);const l=s(t,["code"]);return l!=null&&r(e,["code"],l),e}function Ls(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["displayName"]);i!=null&&r(e,["displayName"],i);const l=s(t,["mimeType"]);l!=null&&r(e,["mimeType"],l);const a=s(t,["sizeBytes"]);a!=null&&r(e,["sizeBytes"],a);const u=s(t,["createTime"]);u!=null&&r(e,["createTime"],u);const d=s(t,["expirationTime"]);d!=null&&r(e,["expirationTime"],d);const c=s(t,["updateTime"]);c!=null&&r(e,["updateTime"],c);const f=s(t,["sha256Hash"]);f!=null&&r(e,["sha256Hash"],f);const p=s(t,["uri"]);p!=null&&r(e,["uri"],p);const m=s(t,["downloadUri"]);m!=null&&r(e,["downloadUri"],m);const h=s(t,["state"]);h!=null&&r(e,["state"],h);const g=s(t,["source"]);g!=null&&r(e,["source"],g);const y=s(t,["videoMetadata"]);y!=null&&r(e,["videoMetadata"],y);const _=s(t,["error"]);return _!=null&&r(e,["error"],Vs(o,_)),e}function Fs(o,t){const e={},n=s(t,["file"]);n!=null&&r(e,["file"],Ls(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Us(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","file"],oo(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Gs(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","file"],oo(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function qs(o,t){const e={},n=s(t,["details"]);n!=null&&r(e,["details"],n);const i=s(t,["message"]);i!=null&&r(e,["message"],i);const l=s(t,["code"]);return l!=null&&r(e,["code"],l),e}function st(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["displayName"]);i!=null&&r(e,["displayName"],i);const l=s(t,["mimeType"]);l!=null&&r(e,["mimeType"],l);const a=s(t,["sizeBytes"]);a!=null&&r(e,["sizeBytes"],a);const u=s(t,["createTime"]);u!=null&&r(e,["createTime"],u);const d=s(t,["expirationTime"]);d!=null&&r(e,["expirationTime"],d);const c=s(t,["updateTime"]);c!=null&&r(e,["updateTime"],c);const f=s(t,["sha256Hash"]);f!=null&&r(e,["sha256Hash"],f);const p=s(t,["uri"]);p!=null&&r(e,["uri"],p);const m=s(t,["downloadUri"]);m!=null&&r(e,["downloadUri"],m);const h=s(t,["state"]);h!=null&&r(e,["state"],h);const g=s(t,["source"]);g!=null&&r(e,["source"],g);const y=s(t,["videoMetadata"]);y!=null&&r(e,["videoMetadata"],y);const _=s(t,["error"]);return _!=null&&r(e,["error"],qs(o,_)),e}function Bs(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["files"]);if(i!=null){let l=i;Array.isArray(l)&&(l=l.map(a=>st(o,a))),r(e,["files"],l)}return e}function $s(){return{}}function bs(){return{}}/**
38
+ * @license
39
+ * Copyright 2025 Google LLC
40
+ * SPDX-License-Identifier: Apache-2.0
41
+ */class Hs extends Te{constructor(t){super(),this.apiClient=t,this.list=async(e={})=>new He(ve.PAGED_ITEM_FILES,n=>this.listInternal(n),await this.listInternal(e),e)}async upload(t){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(t.file,t.config).then(e=>st(this.apiClient,e))}async download(t){await this.apiClient.downloadFile(t)}async listInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ds(this.apiClient,t);return l=S("files",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>{const c=Bs(this.apiClient,d),f=new li;return Object.assign(f,c),f})}}async createInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Fs(this.apiClient,t);return l=S("upload/v1beta/files",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(()=>{const d=$s(),c=new ai;return Object.assign(c,d),c})}}async get(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Us(this.apiClient,t);return l=S("files/{file}",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>st(this.apiClient,d))}}async delete(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Gs(this.apiClient,t);return l=S("files/{file}",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(()=>{const d=bs(),c=new ui;return Object.assign(c,d),c})}}}/**
42
+ * @license
43
+ * Copyright 2025 Google LLC
44
+ * SPDX-License-Identifier: Apache-2.0
45
+ */function Js(o,t){const e={},n=s(t,["voiceName"]);return n!=null&&r(e,["voiceName"],n),e}function Os(o,t){const e={},n=s(t,["voiceName"]);return n!=null&&r(e,["voiceName"],n),e}function lo(o,t){const e={},n=s(t,["prebuiltVoiceConfig"]);return n!=null&&r(e,["prebuiltVoiceConfig"],Js(o,n)),e}function Ws(o,t){const e={},n=s(t,["prebuiltVoiceConfig"]);return n!=null&&r(e,["prebuiltVoiceConfig"],Os(o,n)),e}function Ys(o,t){const e={},n=s(t,["speaker"]);n!=null&&r(e,["speaker"],n);const i=s(t,["voiceConfig"]);return i!=null&&r(e,["voiceConfig"],lo(o,i)),e}function Zs(o,t){const e={},n=s(t,["speakerVoiceConfigs"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>Ys(o,l))),r(e,["speakerVoiceConfigs"],i)}return e}function Ks(o,t){const e={},n=s(t,["voiceConfig"]);n!=null&&r(e,["voiceConfig"],lo(o,n));const i=s(t,["multiSpeakerVoiceConfig"]);i!=null&&r(e,["multiSpeakerVoiceConfig"],Zs(o,i));const l=s(t,["languageCode"]);return l!=null&&r(e,["languageCode"],l),e}function zs(o,t){const e={},n=s(t,["voiceConfig"]);if(n!=null&&r(e,["voiceConfig"],Ws(o,n)),s(t,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const i=s(t,["languageCode"]);return i!=null&&r(e,["languageCode"],i),e}function Xs(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function Qs(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function js(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function er(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["data"]);i!=null&&r(e,["data"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function tr(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function nr(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["fileUri"]);i!=null&&r(e,["fileUri"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function or(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Xs(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],js(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],tr(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function ir(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Qs(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],er(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],nr(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function sr(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>or(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function rr(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>ir(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function lr(o,t){const e={},n=s(t,["behavior"]);n!=null&&r(e,["behavior"],n);const i=s(t,["description"]);i!=null&&r(e,["description"],i);const l=s(t,["name"]);l!=null&&r(e,["name"],l);const a=s(t,["parameters"]);a!=null&&r(e,["parameters"],a);const u=s(t,["response"]);return u!=null&&r(e,["response"],u),e}function ar(o,t){const e={};if(s(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=s(t,["description"]);n!=null&&r(e,["description"],n);const i=s(t,["name"]);i!=null&&r(e,["name"],i);const l=s(t,["parameters"]);l!=null&&r(e,["parameters"],l);const a=s(t,["response"]);return a!=null&&r(e,["response"],a),e}function ur(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function cr(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function dr(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],ur(o,n)),e}function fr(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],cr(o,n)),e}function pr(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function mr(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function hr(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],pr(o,n)),e}function gr(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],mr(o,n)),e}function yr(){return{}}function vr(o,t){const e={},n=s(t,["apiKeyString"]);return n!=null&&r(e,["apiKeyString"],n),e}function Tr(o,t){const e={},n=s(t,["apiKeyConfig"]);n!=null&&r(e,["apiKeyConfig"],vr(o,n));const i=s(t,["authType"]);i!=null&&r(e,["authType"],i);const l=s(t,["googleServiceAccountConfig"]);l!=null&&r(e,["googleServiceAccountConfig"],l);const a=s(t,["httpBasicAuthConfig"]);a!=null&&r(e,["httpBasicAuthConfig"],a);const u=s(t,["oauthConfig"]);u!=null&&r(e,["oauthConfig"],u);const d=s(t,["oidcConfig"]);return d!=null&&r(e,["oidcConfig"],d),e}function Cr(o,t){const e={},n=s(t,["authConfig"]);return n!=null&&r(e,["authConfig"],Tr(o,n)),e}function _r(){return{}}function Er(){return{}}function Sr(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>lr(o,c))),r(e,["functionDeclarations"],d)}if(s(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const i=s(t,["googleSearch"]);i!=null&&r(e,["googleSearch"],dr(o,i));const l=s(t,["googleSearchRetrieval"]);if(l!=null&&r(e,["googleSearchRetrieval"],hr(o,l)),s(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(s(t,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");s(t,["urlContext"])!=null&&r(e,["urlContext"],_r());const u=s(t,["codeExecution"]);return u!=null&&r(e,["codeExecution"],u),e}function Ar(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(m=>ar(o,m))),r(e,["functionDeclarations"],p)}const i=s(t,["retrieval"]);i!=null&&r(e,["retrieval"],i);const l=s(t,["googleSearch"]);l!=null&&r(e,["googleSearch"],fr(o,l));const a=s(t,["googleSearchRetrieval"]);a!=null&&r(e,["googleSearchRetrieval"],gr(o,a)),s(t,["enterpriseWebSearch"])!=null&&r(e,["enterpriseWebSearch"],yr());const d=s(t,["googleMaps"]);d!=null&&r(e,["googleMaps"],Cr(o,d)),s(t,["urlContext"])!=null&&r(e,["urlContext"],Er());const f=s(t,["codeExecution"]);return f!=null&&r(e,["codeExecution"],f),e}function Ir(o,t){const e={},n=s(t,["handle"]);if(n!=null&&r(e,["handle"],n),s(t,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return e}function Mr(o,t){const e={},n=s(t,["handle"]);n!=null&&r(e,["handle"],n);const i=s(t,["transparent"]);return i!=null&&r(e,["transparent"],i),e}function kn(){return{}}function Dn(){return{}}function xr(o,t){const e={},n=s(t,["disabled"]);n!=null&&r(e,["disabled"],n);const i=s(t,["startOfSpeechSensitivity"]);i!=null&&r(e,["startOfSpeechSensitivity"],i);const l=s(t,["endOfSpeechSensitivity"]);l!=null&&r(e,["endOfSpeechSensitivity"],l);const a=s(t,["prefixPaddingMs"]);a!=null&&r(e,["prefixPaddingMs"],a);const u=s(t,["silenceDurationMs"]);return u!=null&&r(e,["silenceDurationMs"],u),e}function Rr(o,t){const e={},n=s(t,["disabled"]);n!=null&&r(e,["disabled"],n);const i=s(t,["startOfSpeechSensitivity"]);i!=null&&r(e,["startOfSpeechSensitivity"],i);const l=s(t,["endOfSpeechSensitivity"]);l!=null&&r(e,["endOfSpeechSensitivity"],l);const a=s(t,["prefixPaddingMs"]);a!=null&&r(e,["prefixPaddingMs"],a);const u=s(t,["silenceDurationMs"]);return u!=null&&r(e,["silenceDurationMs"],u),e}function Pr(o,t){const e={},n=s(t,["automaticActivityDetection"]);n!=null&&r(e,["automaticActivityDetection"],xr(o,n));const i=s(t,["activityHandling"]);i!=null&&r(e,["activityHandling"],i);const l=s(t,["turnCoverage"]);return l!=null&&r(e,["turnCoverage"],l),e}function wr(o,t){const e={},n=s(t,["automaticActivityDetection"]);n!=null&&r(e,["automaticActivityDetection"],Rr(o,n));const i=s(t,["activityHandling"]);i!=null&&r(e,["activityHandling"],i);const l=s(t,["turnCoverage"]);return l!=null&&r(e,["turnCoverage"],l),e}function Nr(o,t){const e={},n=s(t,["targetTokens"]);return n!=null&&r(e,["targetTokens"],n),e}function kr(o,t){const e={},n=s(t,["targetTokens"]);return n!=null&&r(e,["targetTokens"],n),e}function Dr(o,t){const e={},n=s(t,["triggerTokens"]);n!=null&&r(e,["triggerTokens"],n);const i=s(t,["slidingWindow"]);return i!=null&&r(e,["slidingWindow"],Nr(o,i)),e}function Vr(o,t){const e={},n=s(t,["triggerTokens"]);n!=null&&r(e,["triggerTokens"],n);const i=s(t,["slidingWindow"]);return i!=null&&r(e,["slidingWindow"],kr(o,i)),e}function Lr(o,t){const e={},n=s(t,["proactiveAudio"]);return n!=null&&r(e,["proactiveAudio"],n),e}function Fr(o,t){const e={},n=s(t,["proactiveAudio"]);return n!=null&&r(e,["proactiveAudio"],n),e}function Ur(o,t,e){const n={},i=s(t,["generationConfig"]);e!==void 0&&i!=null&&r(e,["setup","generationConfig"],i);const l=s(t,["responseModalities"]);e!==void 0&&l!=null&&r(e,["setup","generationConfig","responseModalities"],l);const a=s(t,["temperature"]);e!==void 0&&a!=null&&r(e,["setup","generationConfig","temperature"],a);const u=s(t,["topP"]);e!==void 0&&u!=null&&r(e,["setup","generationConfig","topP"],u);const d=s(t,["topK"]);e!==void 0&&d!=null&&r(e,["setup","generationConfig","topK"],d);const c=s(t,["maxOutputTokens"]);e!==void 0&&c!=null&&r(e,["setup","generationConfig","maxOutputTokens"],c);const f=s(t,["mediaResolution"]);e!==void 0&&f!=null&&r(e,["setup","generationConfig","mediaResolution"],f);const p=s(t,["seed"]);e!==void 0&&p!=null&&r(e,["setup","generationConfig","seed"],p);const m=s(t,["speechConfig"]);e!==void 0&&m!=null&&r(e,["setup","generationConfig","speechConfig"],Ks(o,pt(o,m)));const h=s(t,["enableAffectiveDialog"]);e!==void 0&&h!=null&&r(e,["setup","generationConfig","enableAffectiveDialog"],h);const g=s(t,["systemInstruction"]);e!==void 0&&g!=null&&r(e,["setup","systemInstruction"],sr(o,b(o,g)));const y=s(t,["tools"]);if(e!==void 0&&y!=null){let V=xe(o,y);Array.isArray(V)&&(V=V.map(U=>Sr(o,Me(o,U)))),r(e,["setup","tools"],V)}const _=s(t,["sessionResumption"]);e!==void 0&&_!=null&&r(e,["setup","sessionResumption"],Ir(o,_));const A=s(t,["inputAudioTranscription"]);e!==void 0&&A!=null&&r(e,["setup","inputAudioTranscription"],kn());const x=s(t,["outputAudioTranscription"]);e!==void 0&&x!=null&&r(e,["setup","outputAudioTranscription"],kn());const R=s(t,["realtimeInputConfig"]);e!==void 0&&R!=null&&r(e,["setup","realtimeInputConfig"],Pr(o,R));const N=s(t,["contextWindowCompression"]);e!==void 0&&N!=null&&r(e,["setup","contextWindowCompression"],Dr(o,N));const k=s(t,["proactivity"]);return e!==void 0&&k!=null&&r(e,["setup","proactivity"],Lr(o,k)),n}function Gr(o,t,e){const n={},i=s(t,["generationConfig"]);e!==void 0&&i!=null&&r(e,["setup","generationConfig"],i);const l=s(t,["responseModalities"]);e!==void 0&&l!=null&&r(e,["setup","generationConfig","responseModalities"],l);const a=s(t,["temperature"]);e!==void 0&&a!=null&&r(e,["setup","generationConfig","temperature"],a);const u=s(t,["topP"]);e!==void 0&&u!=null&&r(e,["setup","generationConfig","topP"],u);const d=s(t,["topK"]);e!==void 0&&d!=null&&r(e,["setup","generationConfig","topK"],d);const c=s(t,["maxOutputTokens"]);e!==void 0&&c!=null&&r(e,["setup","generationConfig","maxOutputTokens"],c);const f=s(t,["mediaResolution"]);e!==void 0&&f!=null&&r(e,["setup","generationConfig","mediaResolution"],f);const p=s(t,["seed"]);e!==void 0&&p!=null&&r(e,["setup","generationConfig","seed"],p);const m=s(t,["speechConfig"]);e!==void 0&&m!=null&&r(e,["setup","generationConfig","speechConfig"],zs(o,pt(o,m)));const h=s(t,["enableAffectiveDialog"]);e!==void 0&&h!=null&&r(e,["setup","generationConfig","enableAffectiveDialog"],h);const g=s(t,["systemInstruction"]);e!==void 0&&g!=null&&r(e,["setup","systemInstruction"],rr(o,b(o,g)));const y=s(t,["tools"]);if(e!==void 0&&y!=null){let V=xe(o,y);Array.isArray(V)&&(V=V.map(U=>Ar(o,Me(o,U)))),r(e,["setup","tools"],V)}const _=s(t,["sessionResumption"]);e!==void 0&&_!=null&&r(e,["setup","sessionResumption"],Mr(o,_));const A=s(t,["inputAudioTranscription"]);e!==void 0&&A!=null&&r(e,["setup","inputAudioTranscription"],Dn());const x=s(t,["outputAudioTranscription"]);e!==void 0&&x!=null&&r(e,["setup","outputAudioTranscription"],Dn());const R=s(t,["realtimeInputConfig"]);e!==void 0&&R!=null&&r(e,["setup","realtimeInputConfig"],wr(o,R));const N=s(t,["contextWindowCompression"]);e!==void 0&&N!=null&&r(e,["setup","contextWindowCompression"],Vr(o,N));const k=s(t,["proactivity"]);return e!==void 0&&k!=null&&r(e,["setup","proactivity"],Fr(o,k)),n}function qr(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["setup","model"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],Ur(o,i,e)),e}function Br(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["setup","model"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],Gr(o,i,e)),e}function $r(){return{}}function br(){return{}}function Hr(){return{}}function Jr(){return{}}function Or(o,t){const e={},n=s(t,["media"]);n!=null&&r(e,["mediaChunks"],Qn(o,n));const i=s(t,["audio"]);i!=null&&r(e,["audio"],pi(o,i));const l=s(t,["audioStreamEnd"]);l!=null&&r(e,["audioStreamEnd"],l);const a=s(t,["video"]);a!=null&&r(e,["video"],fi(o,a));const u=s(t,["text"]);return u!=null&&r(e,["text"],u),s(t,["activityStart"])!=null&&r(e,["activityStart"],$r()),s(t,["activityEnd"])!=null&&r(e,["activityEnd"],Hr()),e}function Wr(o,t){const e={},n=s(t,["media"]);if(n!=null&&r(e,["mediaChunks"],Qn(o,n)),s(t,["audio"])!==void 0)throw new Error("audio parameter is not supported in Vertex AI.");const i=s(t,["audioStreamEnd"]);if(i!=null&&r(e,["audioStreamEnd"],i),s(t,["video"])!==void 0)throw new Error("video parameter is not supported in Vertex AI.");if(s(t,["text"])!==void 0)throw new Error("text parameter is not supported in Vertex AI.");return s(t,["activityStart"])!=null&&r(e,["activityStart"],br()),s(t,["activityEnd"])!=null&&r(e,["activityEnd"],Jr()),e}function ao(o,t){const e={},n=s(t,["text"]);n!=null&&r(e,["text"],n);const i=s(t,["weight"]);return i!=null&&r(e,["weight"],i),e}function Yr(o,t){const e={},n=s(t,["weightedPrompts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>ao(o,l))),r(e,["weightedPrompts"],i)}return e}function uo(o,t){const e={},n=s(t,["temperature"]);n!=null&&r(e,["temperature"],n);const i=s(t,["topK"]);i!=null&&r(e,["topK"],i);const l=s(t,["seed"]);l!=null&&r(e,["seed"],l);const a=s(t,["guidance"]);a!=null&&r(e,["guidance"],a);const u=s(t,["bpm"]);u!=null&&r(e,["bpm"],u);const d=s(t,["density"]);d!=null&&r(e,["density"],d);const c=s(t,["brightness"]);c!=null&&r(e,["brightness"],c);const f=s(t,["scale"]);f!=null&&r(e,["scale"],f);const p=s(t,["muteBass"]);p!=null&&r(e,["muteBass"],p);const m=s(t,["muteDrums"]);m!=null&&r(e,["muteDrums"],m);const h=s(t,["onlyBassAndDrums"]);return h!=null&&r(e,["onlyBassAndDrums"],h),e}function Zr(o,t){const e={},n=s(t,["musicGenerationConfig"]);return n!=null&&r(e,["musicGenerationConfig"],uo(o,n)),e}function co(o,t){const e={},n=s(t,["model"]);return n!=null&&r(e,["model"],n),e}function fo(o,t){const e={},n=s(t,["weightedPrompts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>ao(o,l))),r(e,["weightedPrompts"],i)}return e}function rt(o,t){const e={},n=s(t,["setup"]);n!=null&&r(e,["setup"],co(o,n));const i=s(t,["clientContent"]);i!=null&&r(e,["clientContent"],fo(o,i));const l=s(t,["musicGenerationConfig"]);l!=null&&r(e,["musicGenerationConfig"],uo(o,l));const a=s(t,["playbackControl"]);return a!=null&&r(e,["playbackControl"],a),e}function Kr(){return{}}function zr(){return{}}function Xr(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function Qr(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function jr(o,t){const e={},n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function el(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["data"]);i!=null&&r(e,["data"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function tl(o,t){const e={},n=s(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function nl(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["fileUri"]);i!=null&&r(e,["fileUri"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function ol(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Xr(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],jr(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],tl(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function il(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Qr(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],el(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],nl(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function sl(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>ol(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function rl(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>il(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function Vn(o,t){const e={},n=s(t,["text"]);n!=null&&r(e,["text"],n);const i=s(t,["finished"]);return i!=null&&r(e,["finished"],i),e}function Ln(o,t){const e={},n=s(t,["text"]);n!=null&&r(e,["text"],n);const i=s(t,["finished"]);return i!=null&&r(e,["finished"],i),e}function ll(o,t){const e={},n=s(t,["retrievedUrl"]);n!=null&&r(e,["retrievedUrl"],n);const i=s(t,["urlRetrievalStatus"]);return i!=null&&r(e,["urlRetrievalStatus"],i),e}function al(o,t){const e={},n=s(t,["urlMetadata"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>ll(o,l))),r(e,["urlMetadata"],i)}return e}function ul(o,t){const e={},n=s(t,["modelTurn"]);n!=null&&r(e,["modelTurn"],sl(o,n));const i=s(t,["turnComplete"]);i!=null&&r(e,["turnComplete"],i);const l=s(t,["interrupted"]);l!=null&&r(e,["interrupted"],l);const a=s(t,["groundingMetadata"]);a!=null&&r(e,["groundingMetadata"],a);const u=s(t,["generationComplete"]);u!=null&&r(e,["generationComplete"],u);const d=s(t,["inputTranscription"]);d!=null&&r(e,["inputTranscription"],Vn(o,d));const c=s(t,["outputTranscription"]);c!=null&&r(e,["outputTranscription"],Vn(o,c));const f=s(t,["urlContextMetadata"]);return f!=null&&r(e,["urlContextMetadata"],al(o,f)),e}function cl(o,t){const e={},n=s(t,["modelTurn"]);n!=null&&r(e,["modelTurn"],rl(o,n));const i=s(t,["turnComplete"]);i!=null&&r(e,["turnComplete"],i);const l=s(t,["interrupted"]);l!=null&&r(e,["interrupted"],l);const a=s(t,["groundingMetadata"]);a!=null&&r(e,["groundingMetadata"],a);const u=s(t,["generationComplete"]);u!=null&&r(e,["generationComplete"],u);const d=s(t,["inputTranscription"]);d!=null&&r(e,["inputTranscription"],Ln(o,d));const c=s(t,["outputTranscription"]);return c!=null&&r(e,["outputTranscription"],Ln(o,c)),e}function dl(o,t){const e={},n=s(t,["id"]);n!=null&&r(e,["id"],n);const i=s(t,["args"]);i!=null&&r(e,["args"],i);const l=s(t,["name"]);return l!=null&&r(e,["name"],l),e}function fl(o,t){const e={},n=s(t,["args"]);n!=null&&r(e,["args"],n);const i=s(t,["name"]);return i!=null&&r(e,["name"],i),e}function pl(o,t){const e={},n=s(t,["functionCalls"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>dl(o,l))),r(e,["functionCalls"],i)}return e}function ml(o,t){const e={},n=s(t,["functionCalls"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>fl(o,l))),r(e,["functionCalls"],i)}return e}function hl(o,t){const e={},n=s(t,["ids"]);return n!=null&&r(e,["ids"],n),e}function gl(o,t){const e={},n=s(t,["ids"]);return n!=null&&r(e,["ids"],n),e}function Re(o,t){const e={},n=s(t,["modality"]);n!=null&&r(e,["modality"],n);const i=s(t,["tokenCount"]);return i!=null&&r(e,["tokenCount"],i),e}function Pe(o,t){const e={},n=s(t,["modality"]);n!=null&&r(e,["modality"],n);const i=s(t,["tokenCount"]);return i!=null&&r(e,["tokenCount"],i),e}function yl(o,t){const e={},n=s(t,["promptTokenCount"]);n!=null&&r(e,["promptTokenCount"],n);const i=s(t,["cachedContentTokenCount"]);i!=null&&r(e,["cachedContentTokenCount"],i);const l=s(t,["responseTokenCount"]);l!=null&&r(e,["responseTokenCount"],l);const a=s(t,["toolUsePromptTokenCount"]);a!=null&&r(e,["toolUsePromptTokenCount"],a);const u=s(t,["thoughtsTokenCount"]);u!=null&&r(e,["thoughtsTokenCount"],u);const d=s(t,["totalTokenCount"]);d!=null&&r(e,["totalTokenCount"],d);const c=s(t,["promptTokensDetails"]);if(c!=null){let h=c;Array.isArray(h)&&(h=h.map(g=>Re(o,g))),r(e,["promptTokensDetails"],h)}const f=s(t,["cacheTokensDetails"]);if(f!=null){let h=f;Array.isArray(h)&&(h=h.map(g=>Re(o,g))),r(e,["cacheTokensDetails"],h)}const p=s(t,["responseTokensDetails"]);if(p!=null){let h=p;Array.isArray(h)&&(h=h.map(g=>Re(o,g))),r(e,["responseTokensDetails"],h)}const m=s(t,["toolUsePromptTokensDetails"]);if(m!=null){let h=m;Array.isArray(h)&&(h=h.map(g=>Re(o,g))),r(e,["toolUsePromptTokensDetails"],h)}return e}function vl(o,t){const e={},n=s(t,["promptTokenCount"]);n!=null&&r(e,["promptTokenCount"],n);const i=s(t,["cachedContentTokenCount"]);i!=null&&r(e,["cachedContentTokenCount"],i);const l=s(t,["candidatesTokenCount"]);l!=null&&r(e,["responseTokenCount"],l);const a=s(t,["toolUsePromptTokenCount"]);a!=null&&r(e,["toolUsePromptTokenCount"],a);const u=s(t,["thoughtsTokenCount"]);u!=null&&r(e,["thoughtsTokenCount"],u);const d=s(t,["totalTokenCount"]);d!=null&&r(e,["totalTokenCount"],d);const c=s(t,["promptTokensDetails"]);if(c!=null){let g=c;Array.isArray(g)&&(g=g.map(y=>Pe(o,y))),r(e,["promptTokensDetails"],g)}const f=s(t,["cacheTokensDetails"]);if(f!=null){let g=f;Array.isArray(g)&&(g=g.map(y=>Pe(o,y))),r(e,["cacheTokensDetails"],g)}const p=s(t,["candidatesTokensDetails"]);if(p!=null){let g=p;Array.isArray(g)&&(g=g.map(y=>Pe(o,y))),r(e,["responseTokensDetails"],g)}const m=s(t,["toolUsePromptTokensDetails"]);if(m!=null){let g=m;Array.isArray(g)&&(g=g.map(y=>Pe(o,y))),r(e,["toolUsePromptTokensDetails"],g)}const h=s(t,["trafficType"]);return h!=null&&r(e,["trafficType"],h),e}function Tl(o,t){const e={},n=s(t,["timeLeft"]);return n!=null&&r(e,["timeLeft"],n),e}function Cl(o,t){const e={},n=s(t,["timeLeft"]);return n!=null&&r(e,["timeLeft"],n),e}function _l(o,t){const e={},n=s(t,["newHandle"]);n!=null&&r(e,["newHandle"],n);const i=s(t,["resumable"]);i!=null&&r(e,["resumable"],i);const l=s(t,["lastConsumedClientMessageIndex"]);return l!=null&&r(e,["lastConsumedClientMessageIndex"],l),e}function El(o,t){const e={},n=s(t,["newHandle"]);n!=null&&r(e,["newHandle"],n);const i=s(t,["resumable"]);i!=null&&r(e,["resumable"],i);const l=s(t,["lastConsumedClientMessageIndex"]);return l!=null&&r(e,["lastConsumedClientMessageIndex"],l),e}function Sl(o,t){const e={};s(t,["setupComplete"])!=null&&r(e,["setupComplete"],Kr());const i=s(t,["serverContent"]);i!=null&&r(e,["serverContent"],ul(o,i));const l=s(t,["toolCall"]);l!=null&&r(e,["toolCall"],pl(o,l));const a=s(t,["toolCallCancellation"]);a!=null&&r(e,["toolCallCancellation"],hl(o,a));const u=s(t,["usageMetadata"]);u!=null&&r(e,["usageMetadata"],yl(o,u));const d=s(t,["goAway"]);d!=null&&r(e,["goAway"],Tl(o,d));const c=s(t,["sessionResumptionUpdate"]);return c!=null&&r(e,["sessionResumptionUpdate"],_l(o,c)),e}function Al(o,t){const e={};s(t,["setupComplete"])!=null&&r(e,["setupComplete"],zr());const i=s(t,["serverContent"]);i!=null&&r(e,["serverContent"],cl(o,i));const l=s(t,["toolCall"]);l!=null&&r(e,["toolCall"],ml(o,l));const a=s(t,["toolCallCancellation"]);a!=null&&r(e,["toolCallCancellation"],gl(o,a));const u=s(t,["usageMetadata"]);u!=null&&r(e,["usageMetadata"],vl(o,u));const d=s(t,["goAway"]);d!=null&&r(e,["goAway"],Cl(o,d));const c=s(t,["sessionResumptionUpdate"]);return c!=null&&r(e,["sessionResumptionUpdate"],El(o,c)),e}function Il(){return{}}function Ml(o,t){const e={},n=s(t,["text"]);n!=null&&r(e,["text"],n);const i=s(t,["weight"]);return i!=null&&r(e,["weight"],i),e}function xl(o,t){const e={},n=s(t,["weightedPrompts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>Ml(o,l))),r(e,["weightedPrompts"],i)}return e}function Rl(o,t){const e={},n=s(t,["temperature"]);n!=null&&r(e,["temperature"],n);const i=s(t,["topK"]);i!=null&&r(e,["topK"],i);const l=s(t,["seed"]);l!=null&&r(e,["seed"],l);const a=s(t,["guidance"]);a!=null&&r(e,["guidance"],a);const u=s(t,["bpm"]);u!=null&&r(e,["bpm"],u);const d=s(t,["density"]);d!=null&&r(e,["density"],d);const c=s(t,["brightness"]);c!=null&&r(e,["brightness"],c);const f=s(t,["scale"]);f!=null&&r(e,["scale"],f);const p=s(t,["muteBass"]);p!=null&&r(e,["muteBass"],p);const m=s(t,["muteDrums"]);m!=null&&r(e,["muteDrums"],m);const h=s(t,["onlyBassAndDrums"]);return h!=null&&r(e,["onlyBassAndDrums"],h),e}function Pl(o,t){const e={},n=s(t,["clientContent"]);n!=null&&r(e,["clientContent"],xl(o,n));const i=s(t,["musicGenerationConfig"]);return i!=null&&r(e,["musicGenerationConfig"],Rl(o,i)),e}function wl(o,t){const e={},n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);i!=null&&r(e,["mimeType"],i);const l=s(t,["sourceMetadata"]);return l!=null&&r(e,["sourceMetadata"],Pl(o,l)),e}function Nl(o,t){const e={},n=s(t,["audioChunks"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>wl(o,l))),r(e,["audioChunks"],i)}return e}function kl(o,t){const e={},n=s(t,["text"]);n!=null&&r(e,["text"],n);const i=s(t,["filteredReason"]);return i!=null&&r(e,["filteredReason"],i),e}function Dl(o,t){const e={};s(t,["setupComplete"])!=null&&r(e,["setupComplete"],Il());const i=s(t,["serverContent"]);i!=null&&r(e,["serverContent"],Nl(o,i));const l=s(t,["filteredPrompt"]);return l!=null&&r(e,["filteredPrompt"],kl(o,l)),e}/**
46
+ * @license
47
+ * Copyright 2025 Google LLC
48
+ * SPDX-License-Identifier: Apache-2.0
49
+ */function Vl(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function Ll(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function Fl(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function Ul(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Vl(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],Ll(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],Fl(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function Je(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Ul(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function Gl(o,t){const e={},n=s(t,["anyOf"]);n!=null&&r(e,["anyOf"],n);const i=s(t,["default"]);i!=null&&r(e,["default"],i);const l=s(t,["description"]);l!=null&&r(e,["description"],l);const a=s(t,["enum"]);a!=null&&r(e,["enum"],a);const u=s(t,["example"]);u!=null&&r(e,["example"],u);const d=s(t,["format"]);d!=null&&r(e,["format"],d);const c=s(t,["items"]);c!=null&&r(e,["items"],c);const f=s(t,["maxItems"]);f!=null&&r(e,["maxItems"],f);const p=s(t,["maxLength"]);p!=null&&r(e,["maxLength"],p);const m=s(t,["maxProperties"]);m!=null&&r(e,["maxProperties"],m);const h=s(t,["maximum"]);h!=null&&r(e,["maximum"],h);const g=s(t,["minItems"]);g!=null&&r(e,["minItems"],g);const y=s(t,["minLength"]);y!=null&&r(e,["minLength"],y);const _=s(t,["minProperties"]);_!=null&&r(e,["minProperties"],_);const A=s(t,["minimum"]);A!=null&&r(e,["minimum"],A);const x=s(t,["nullable"]);x!=null&&r(e,["nullable"],x);const R=s(t,["pattern"]);R!=null&&r(e,["pattern"],R);const N=s(t,["properties"]);N!=null&&r(e,["properties"],N);const k=s(t,["propertyOrdering"]);k!=null&&r(e,["propertyOrdering"],k);const V=s(t,["required"]);V!=null&&r(e,["required"],V);const U=s(t,["title"]);U!=null&&r(e,["title"],U);const $=s(t,["type"]);return $!=null&&r(e,["type"],$),e}function ql(o,t){const e={};if(s(t,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const n=s(t,["category"]);n!=null&&r(e,["category"],n);const i=s(t,["threshold"]);return i!=null&&r(e,["threshold"],i),e}function Bl(o,t){const e={},n=s(t,["behavior"]);n!=null&&r(e,["behavior"],n);const i=s(t,["description"]);i!=null&&r(e,["description"],i);const l=s(t,["name"]);l!=null&&r(e,["name"],l);const a=s(t,["parameters"]);a!=null&&r(e,["parameters"],a);const u=s(t,["response"]);return u!=null&&r(e,["response"],u),e}function $l(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function bl(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],$l(o,n)),e}function Hl(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function Jl(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],Hl(o,n)),e}function Ol(){return{}}function Wl(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>Bl(o,c))),r(e,["functionDeclarations"],d)}if(s(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const i=s(t,["googleSearch"]);i!=null&&r(e,["googleSearch"],bl(o,i));const l=s(t,["googleSearchRetrieval"]);if(l!=null&&r(e,["googleSearchRetrieval"],Jl(o,l)),s(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(s(t,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");s(t,["urlContext"])!=null&&r(e,["urlContext"],Ol());const u=s(t,["codeExecution"]);return u!=null&&r(e,["codeExecution"],u),e}function Yl(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["allowedFunctionNames"]);return i!=null&&r(e,["allowedFunctionNames"],i),e}function Zl(o,t){const e={},n=s(t,["latitude"]);n!=null&&r(e,["latitude"],n);const i=s(t,["longitude"]);return i!=null&&r(e,["longitude"],i),e}function Kl(o,t){const e={},n=s(t,["latLng"]);n!=null&&r(e,["latLng"],Zl(o,n));const i=s(t,["languageCode"]);return i!=null&&r(e,["languageCode"],i),e}function zl(o,t){const e={},n=s(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],Yl(o,n));const i=s(t,["retrievalConfig"]);return i!=null&&r(e,["retrievalConfig"],Kl(o,i)),e}function Xl(o,t){const e={},n=s(t,["voiceName"]);return n!=null&&r(e,["voiceName"],n),e}function po(o,t){const e={},n=s(t,["prebuiltVoiceConfig"]);return n!=null&&r(e,["prebuiltVoiceConfig"],Xl(o,n)),e}function Ql(o,t){const e={},n=s(t,["speaker"]);n!=null&&r(e,["speaker"],n);const i=s(t,["voiceConfig"]);return i!=null&&r(e,["voiceConfig"],po(o,i)),e}function jl(o,t){const e={},n=s(t,["speakerVoiceConfigs"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>Ql(o,l))),r(e,["speakerVoiceConfigs"],i)}return e}function ea(o,t){const e={},n=s(t,["voiceConfig"]);n!=null&&r(e,["voiceConfig"],po(o,n));const i=s(t,["multiSpeakerVoiceConfig"]);i!=null&&r(e,["multiSpeakerVoiceConfig"],jl(o,i));const l=s(t,["languageCode"]);return l!=null&&r(e,["languageCode"],l),e}function ta(o,t){const e={},n=s(t,["includeThoughts"]);n!=null&&r(e,["includeThoughts"],n);const i=s(t,["thinkingBudget"]);return i!=null&&r(e,["thinkingBudget"],i),e}function na(o,t,e){const n={},i=s(t,["systemInstruction"]);e!==void 0&&i!=null&&r(e,["systemInstruction"],Je(o,b(o,i)));const l=s(t,["temperature"]);l!=null&&r(n,["temperature"],l);const a=s(t,["topP"]);a!=null&&r(n,["topP"],a);const u=s(t,["topK"]);u!=null&&r(n,["topK"],u);const d=s(t,["candidateCount"]);d!=null&&r(n,["candidateCount"],d);const c=s(t,["maxOutputTokens"]);c!=null&&r(n,["maxOutputTokens"],c);const f=s(t,["stopSequences"]);f!=null&&r(n,["stopSequences"],f);const p=s(t,["responseLogprobs"]);p!=null&&r(n,["responseLogprobs"],p);const m=s(t,["logprobs"]);m!=null&&r(n,["logprobs"],m);const h=s(t,["presencePenalty"]);h!=null&&r(n,["presencePenalty"],h);const g=s(t,["frequencyPenalty"]);g!=null&&r(n,["frequencyPenalty"],g);const y=s(t,["seed"]);y!=null&&r(n,["seed"],y);const _=s(t,["responseMimeType"]);_!=null&&r(n,["responseMimeType"],_);const A=s(t,["responseSchema"]);if(A!=null&&r(n,["responseSchema"],Gl(o,$e(o,A))),s(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(s(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const x=s(t,["safetySettings"]);if(e!==void 0&&x!=null){let F=x;Array.isArray(F)&&(F=F.map(J=>ql(o,J))),r(e,["safetySettings"],F)}const R=s(t,["tools"]);if(e!==void 0&&R!=null){let F=xe(o,R);Array.isArray(F)&&(F=F.map(J=>Wl(o,Me(o,J)))),r(e,["tools"],F)}const N=s(t,["toolConfig"]);if(e!==void 0&&N!=null&&r(e,["toolConfig"],zl(o,N)),s(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const k=s(t,["cachedContent"]);e!==void 0&&k!=null&&r(e,["cachedContent"],oe(o,k));const V=s(t,["responseModalities"]);V!=null&&r(n,["responseModalities"],V);const U=s(t,["mediaResolution"]);U!=null&&r(n,["mediaResolution"],U);const $=s(t,["speechConfig"]);if($!=null&&r(n,["speechConfig"],ea(o,to(o,$))),s(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const w=s(t,["thinkingConfig"]);return w!=null&&r(n,["thinkingConfig"],ta(o,w)),n}function Fn(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);if(i!=null){let a=W(o,i);Array.isArray(a)&&(a=a.map(u=>Je(o,u))),r(e,["contents"],a)}const l=s(t,["config"]);return l!=null&&r(e,["generationConfig"],na(o,l,e)),e}function oa(o,t,e){const n={},i=s(t,["taskType"]);e!==void 0&&i!=null&&r(e,["requests[]","taskType"],i);const l=s(t,["title"]);e!==void 0&&l!=null&&r(e,["requests[]","title"],l);const a=s(t,["outputDimensionality"]);if(e!==void 0&&a!=null&&r(e,["requests[]","outputDimensionality"],a),s(t,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(s(t,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function ia(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);i!=null&&r(e,["requests[]","content"],eo(o,i));const l=s(t,["config"]);l!=null&&r(e,["config"],oa(o,l,e));const a=s(t,["model"]);return a!==void 0&&r(e,["requests[]","model"],G(o,a)),e}function sa(o,t,e){const n={};if(s(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(s(t,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const i=s(t,["numberOfImages"]);e!==void 0&&i!=null&&r(e,["parameters","sampleCount"],i);const l=s(t,["aspectRatio"]);e!==void 0&&l!=null&&r(e,["parameters","aspectRatio"],l);const a=s(t,["guidanceScale"]);if(e!==void 0&&a!=null&&r(e,["parameters","guidanceScale"],a),s(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const u=s(t,["safetyFilterLevel"]);e!==void 0&&u!=null&&r(e,["parameters","safetySetting"],u);const d=s(t,["personGeneration"]);e!==void 0&&d!=null&&r(e,["parameters","personGeneration"],d);const c=s(t,["includeSafetyAttributes"]);e!==void 0&&c!=null&&r(e,["parameters","includeSafetyAttributes"],c);const f=s(t,["includeRaiReason"]);e!==void 0&&f!=null&&r(e,["parameters","includeRaiReason"],f);const p=s(t,["language"]);e!==void 0&&p!=null&&r(e,["parameters","language"],p);const m=s(t,["outputMimeType"]);e!==void 0&&m!=null&&r(e,["parameters","outputOptions","mimeType"],m);const h=s(t,["outputCompressionQuality"]);if(e!==void 0&&h!=null&&r(e,["parameters","outputOptions","compressionQuality"],h),s(t,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(s(t,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function ra(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["prompt"]);i!=null&&r(e,["instances[0]","prompt"],i);const l=s(t,["config"]);return l!=null&&r(e,["config"],sa(o,l,e)),e}function la(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","name"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function aa(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);e!==void 0&&l!=null&&r(e,["_query","pageToken"],l);const a=s(t,["filter"]);e!==void 0&&a!=null&&r(e,["_query","filter"],a);const u=s(t,["queryBase"]);return e!==void 0&&u!=null&&r(e,["_url","models_url"],io(o,u)),n}function ua(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],aa(o,n,e)),e}function ca(o,t,e){const n={},i=s(t,["displayName"]);e!==void 0&&i!=null&&r(e,["displayName"],i);const l=s(t,["description"]);e!==void 0&&l!=null&&r(e,["description"],l);const a=s(t,["defaultCheckpointId"]);return e!==void 0&&a!=null&&r(e,["defaultCheckpointId"],a),n}function da(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","name"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],ca(o,i,e)),e}function fa(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","name"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function pa(o,t){const e={};if(s(t,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(s(t,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(s(t,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return e}function ma(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);if(i!=null){let a=W(o,i);Array.isArray(a)&&(a=a.map(u=>Je(o,u))),r(e,["contents"],a)}const l=s(t,["config"]);return l!=null&&r(e,["config"],pa(o,l)),e}function ha(o,t){const e={};if(s(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=s(t,["imageBytes"]);n!=null&&r(e,["bytesBase64Encoded"],j(o,n));const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function ga(o,t,e){const n={},i=s(t,["numberOfVideos"]);if(e!==void 0&&i!=null&&r(e,["parameters","sampleCount"],i),s(t,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(s(t,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const l=s(t,["durationSeconds"]);if(e!==void 0&&l!=null&&r(e,["parameters","durationSeconds"],l),s(t,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const a=s(t,["aspectRatio"]);if(e!==void 0&&a!=null&&r(e,["parameters","aspectRatio"],a),s(t,["resolution"])!==void 0)throw new Error("resolution parameter is not supported in Gemini API.");const u=s(t,["personGeneration"]);if(e!==void 0&&u!=null&&r(e,["parameters","personGeneration"],u),s(t,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const d=s(t,["negativePrompt"]);e!==void 0&&d!=null&&r(e,["parameters","negativePrompt"],d);const c=s(t,["enhancePrompt"]);if(e!==void 0&&c!=null&&r(e,["parameters","enhancePrompt"],c),s(t,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");if(s(t,["lastFrame"])!==void 0)throw new Error("lastFrame parameter is not supported in Gemini API.");return n}function ya(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["prompt"]);i!=null&&r(e,["instances[0]","prompt"],i);const l=s(t,["image"]);if(l!=null&&r(e,["instances[0]","image"],ha(o,l)),s(t,["video"])!==void 0)throw new Error("video parameter is not supported in Gemini API.");const a=s(t,["config"]);return a!=null&&r(e,["config"],ga(o,a,e)),e}function va(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function Ta(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["data"]);i!=null&&r(e,["data"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function Ca(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["fileUri"]);i!=null&&r(e,["fileUri"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function _a(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],va(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],Ta(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],Ca(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function Ce(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>_a(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function Ea(o,t){const e={},n=s(t,["anyOf"]);n!=null&&r(e,["anyOf"],n);const i=s(t,["default"]);i!=null&&r(e,["default"],i);const l=s(t,["description"]);l!=null&&r(e,["description"],l);const a=s(t,["enum"]);a!=null&&r(e,["enum"],a);const u=s(t,["example"]);u!=null&&r(e,["example"],u);const d=s(t,["format"]);d!=null&&r(e,["format"],d);const c=s(t,["items"]);c!=null&&r(e,["items"],c);const f=s(t,["maxItems"]);f!=null&&r(e,["maxItems"],f);const p=s(t,["maxLength"]);p!=null&&r(e,["maxLength"],p);const m=s(t,["maxProperties"]);m!=null&&r(e,["maxProperties"],m);const h=s(t,["maximum"]);h!=null&&r(e,["maximum"],h);const g=s(t,["minItems"]);g!=null&&r(e,["minItems"],g);const y=s(t,["minLength"]);y!=null&&r(e,["minLength"],y);const _=s(t,["minProperties"]);_!=null&&r(e,["minProperties"],_);const A=s(t,["minimum"]);A!=null&&r(e,["minimum"],A);const x=s(t,["nullable"]);x!=null&&r(e,["nullable"],x);const R=s(t,["pattern"]);R!=null&&r(e,["pattern"],R);const N=s(t,["properties"]);N!=null&&r(e,["properties"],N);const k=s(t,["propertyOrdering"]);k!=null&&r(e,["propertyOrdering"],k);const V=s(t,["required"]);V!=null&&r(e,["required"],V);const U=s(t,["title"]);U!=null&&r(e,["title"],U);const $=s(t,["type"]);return $!=null&&r(e,["type"],$),e}function Sa(o,t){const e={},n=s(t,["featureSelectionPreference"]);return n!=null&&r(e,["featureSelectionPreference"],n),e}function Aa(o,t){const e={},n=s(t,["method"]);n!=null&&r(e,["method"],n);const i=s(t,["category"]);i!=null&&r(e,["category"],i);const l=s(t,["threshold"]);return l!=null&&r(e,["threshold"],l),e}function Ia(o,t){const e={};if(s(t,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=s(t,["description"]);n!=null&&r(e,["description"],n);const i=s(t,["name"]);i!=null&&r(e,["name"],i);const l=s(t,["parameters"]);l!=null&&r(e,["parameters"],l);const a=s(t,["response"]);return a!=null&&r(e,["response"],a),e}function Ma(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function xa(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],Ma(o,n)),e}function Ra(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function Pa(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],Ra(o,n)),e}function wa(){return{}}function Na(o,t){const e={},n=s(t,["apiKeyString"]);return n!=null&&r(e,["apiKeyString"],n),e}function ka(o,t){const e={},n=s(t,["apiKeyConfig"]);n!=null&&r(e,["apiKeyConfig"],Na(o,n));const i=s(t,["authType"]);i!=null&&r(e,["authType"],i);const l=s(t,["googleServiceAccountConfig"]);l!=null&&r(e,["googleServiceAccountConfig"],l);const a=s(t,["httpBasicAuthConfig"]);a!=null&&r(e,["httpBasicAuthConfig"],a);const u=s(t,["oauthConfig"]);u!=null&&r(e,["oauthConfig"],u);const d=s(t,["oidcConfig"]);return d!=null&&r(e,["oidcConfig"],d),e}function Da(o,t){const e={},n=s(t,["authConfig"]);return n!=null&&r(e,["authConfig"],ka(o,n)),e}function Va(){return{}}function mo(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let p=n;Array.isArray(p)&&(p=p.map(m=>Ia(o,m))),r(e,["functionDeclarations"],p)}const i=s(t,["retrieval"]);i!=null&&r(e,["retrieval"],i);const l=s(t,["googleSearch"]);l!=null&&r(e,["googleSearch"],xa(o,l));const a=s(t,["googleSearchRetrieval"]);a!=null&&r(e,["googleSearchRetrieval"],Pa(o,a)),s(t,["enterpriseWebSearch"])!=null&&r(e,["enterpriseWebSearch"],wa());const d=s(t,["googleMaps"]);d!=null&&r(e,["googleMaps"],Da(o,d)),s(t,["urlContext"])!=null&&r(e,["urlContext"],Va());const f=s(t,["codeExecution"]);return f!=null&&r(e,["codeExecution"],f),e}function La(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["allowedFunctionNames"]);return i!=null&&r(e,["allowedFunctionNames"],i),e}function Fa(o,t){const e={},n=s(t,["latitude"]);n!=null&&r(e,["latitude"],n);const i=s(t,["longitude"]);return i!=null&&r(e,["longitude"],i),e}function Ua(o,t){const e={},n=s(t,["latLng"]);n!=null&&r(e,["latLng"],Fa(o,n));const i=s(t,["languageCode"]);return i!=null&&r(e,["languageCode"],i),e}function Ga(o,t){const e={},n=s(t,["functionCallingConfig"]);n!=null&&r(e,["functionCallingConfig"],La(o,n));const i=s(t,["retrievalConfig"]);return i!=null&&r(e,["retrievalConfig"],Ua(o,i)),e}function qa(o,t){const e={},n=s(t,["voiceName"]);return n!=null&&r(e,["voiceName"],n),e}function Ba(o,t){const e={},n=s(t,["prebuiltVoiceConfig"]);return n!=null&&r(e,["prebuiltVoiceConfig"],qa(o,n)),e}function $a(o,t){const e={},n=s(t,["voiceConfig"]);if(n!=null&&r(e,["voiceConfig"],Ba(o,n)),s(t,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const i=s(t,["languageCode"]);return i!=null&&r(e,["languageCode"],i),e}function ba(o,t){const e={},n=s(t,["includeThoughts"]);n!=null&&r(e,["includeThoughts"],n);const i=s(t,["thinkingBudget"]);return i!=null&&r(e,["thinkingBudget"],i),e}function Ha(o,t,e){const n={},i=s(t,["systemInstruction"]);e!==void 0&&i!=null&&r(e,["systemInstruction"],Ce(o,b(o,i)));const l=s(t,["temperature"]);l!=null&&r(n,["temperature"],l);const a=s(t,["topP"]);a!=null&&r(n,["topP"],a);const u=s(t,["topK"]);u!=null&&r(n,["topK"],u);const d=s(t,["candidateCount"]);d!=null&&r(n,["candidateCount"],d);const c=s(t,["maxOutputTokens"]);c!=null&&r(n,["maxOutputTokens"],c);const f=s(t,["stopSequences"]);f!=null&&r(n,["stopSequences"],f);const p=s(t,["responseLogprobs"]);p!=null&&r(n,["responseLogprobs"],p);const m=s(t,["logprobs"]);m!=null&&r(n,["logprobs"],m);const h=s(t,["presencePenalty"]);h!=null&&r(n,["presencePenalty"],h);const g=s(t,["frequencyPenalty"]);g!=null&&r(n,["frequencyPenalty"],g);const y=s(t,["seed"]);y!=null&&r(n,["seed"],y);const _=s(t,["responseMimeType"]);_!=null&&r(n,["responseMimeType"],_);const A=s(t,["responseSchema"]);A!=null&&r(n,["responseSchema"],Ea(o,$e(o,A)));const x=s(t,["routingConfig"]);x!=null&&r(n,["routingConfig"],x);const R=s(t,["modelSelectionConfig"]);R!=null&&r(n,["modelConfig"],Sa(o,R));const N=s(t,["safetySettings"]);if(e!==void 0&&N!=null){let X=N;Array.isArray(X)&&(X=X.map(We=>Aa(o,We))),r(e,["safetySettings"],X)}const k=s(t,["tools"]);if(e!==void 0&&k!=null){let X=xe(o,k);Array.isArray(X)&&(X=X.map(We=>mo(o,Me(o,We)))),r(e,["tools"],X)}const V=s(t,["toolConfig"]);e!==void 0&&V!=null&&r(e,["toolConfig"],Ga(o,V));const U=s(t,["labels"]);e!==void 0&&U!=null&&r(e,["labels"],U);const $=s(t,["cachedContent"]);e!==void 0&&$!=null&&r(e,["cachedContent"],oe(o,$));const w=s(t,["responseModalities"]);w!=null&&r(n,["responseModalities"],w);const F=s(t,["mediaResolution"]);F!=null&&r(n,["mediaResolution"],F);const J=s(t,["speechConfig"]);J!=null&&r(n,["speechConfig"],$a(o,to(o,J)));const yt=s(t,["audioTimestamp"]);yt!=null&&r(n,["audioTimestamp"],yt);const vt=s(t,["thinkingConfig"]);return vt!=null&&r(n,["thinkingConfig"],ba(o,vt)),n}function Un(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);if(i!=null){let a=W(o,i);Array.isArray(a)&&(a=a.map(u=>Ce(o,u))),r(e,["contents"],a)}const l=s(t,["config"]);return l!=null&&r(e,["generationConfig"],Ha(o,l,e)),e}function Ja(o,t,e){const n={},i=s(t,["taskType"]);e!==void 0&&i!=null&&r(e,["instances[]","task_type"],i);const l=s(t,["title"]);e!==void 0&&l!=null&&r(e,["instances[]","title"],l);const a=s(t,["outputDimensionality"]);e!==void 0&&a!=null&&r(e,["parameters","outputDimensionality"],a);const u=s(t,["mimeType"]);e!==void 0&&u!=null&&r(e,["instances[]","mimeType"],u);const d=s(t,["autoTruncate"]);return e!==void 0&&d!=null&&r(e,["parameters","autoTruncate"],d),n}function Oa(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);i!=null&&r(e,["instances[]","content"],eo(o,i));const l=s(t,["config"]);return l!=null&&r(e,["config"],Ja(o,l,e)),e}function Wa(o,t,e){const n={},i=s(t,["outputGcsUri"]);e!==void 0&&i!=null&&r(e,["parameters","storageUri"],i);const l=s(t,["negativePrompt"]);e!==void 0&&l!=null&&r(e,["parameters","negativePrompt"],l);const a=s(t,["numberOfImages"]);e!==void 0&&a!=null&&r(e,["parameters","sampleCount"],a);const u=s(t,["aspectRatio"]);e!==void 0&&u!=null&&r(e,["parameters","aspectRatio"],u);const d=s(t,["guidanceScale"]);e!==void 0&&d!=null&&r(e,["parameters","guidanceScale"],d);const c=s(t,["seed"]);e!==void 0&&c!=null&&r(e,["parameters","seed"],c);const f=s(t,["safetyFilterLevel"]);e!==void 0&&f!=null&&r(e,["parameters","safetySetting"],f);const p=s(t,["personGeneration"]);e!==void 0&&p!=null&&r(e,["parameters","personGeneration"],p);const m=s(t,["includeSafetyAttributes"]);e!==void 0&&m!=null&&r(e,["parameters","includeSafetyAttributes"],m);const h=s(t,["includeRaiReason"]);e!==void 0&&h!=null&&r(e,["parameters","includeRaiReason"],h);const g=s(t,["language"]);e!==void 0&&g!=null&&r(e,["parameters","language"],g);const y=s(t,["outputMimeType"]);e!==void 0&&y!=null&&r(e,["parameters","outputOptions","mimeType"],y);const _=s(t,["outputCompressionQuality"]);e!==void 0&&_!=null&&r(e,["parameters","outputOptions","compressionQuality"],_);const A=s(t,["addWatermark"]);e!==void 0&&A!=null&&r(e,["parameters","addWatermark"],A);const x=s(t,["enhancePrompt"]);return e!==void 0&&x!=null&&r(e,["parameters","enhancePrompt"],x),n}function Ya(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["prompt"]);i!=null&&r(e,["instances[0]","prompt"],i);const l=s(t,["config"]);return l!=null&&r(e,["config"],Wa(o,l,e)),e}function Oe(o,t){const e={},n=s(t,["gcsUri"]);n!=null&&r(e,["gcsUri"],n);const i=s(t,["imageBytes"]);i!=null&&r(e,["bytesBase64Encoded"],j(o,i));const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function Za(o,t){const e={},n=s(t,["maskMode"]);n!=null&&r(e,["maskMode"],n);const i=s(t,["segmentationClasses"]);i!=null&&r(e,["maskClasses"],i);const l=s(t,["maskDilation"]);return l!=null&&r(e,["dilation"],l),e}function Ka(o,t){const e={},n=s(t,["controlType"]);n!=null&&r(e,["controlType"],n);const i=s(t,["enableControlImageComputation"]);return i!=null&&r(e,["computeControl"],i),e}function za(o,t){const e={},n=s(t,["styleDescription"]);return n!=null&&r(e,["styleDescription"],n),e}function Xa(o,t){const e={},n=s(t,["subjectType"]);n!=null&&r(e,["subjectType"],n);const i=s(t,["subjectDescription"]);return i!=null&&r(e,["subjectDescription"],i),e}function Qa(o,t){const e={},n=s(t,["referenceImage"]);n!=null&&r(e,["referenceImage"],Oe(o,n));const i=s(t,["referenceId"]);i!=null&&r(e,["referenceId"],i);const l=s(t,["referenceType"]);l!=null&&r(e,["referenceType"],l);const a=s(t,["maskImageConfig"]);a!=null&&r(e,["maskImageConfig"],Za(o,a));const u=s(t,["controlImageConfig"]);u!=null&&r(e,["controlImageConfig"],Ka(o,u));const d=s(t,["styleImageConfig"]);d!=null&&r(e,["styleImageConfig"],za(o,d));const c=s(t,["subjectImageConfig"]);return c!=null&&r(e,["subjectImageConfig"],Xa(o,c)),e}function ja(o,t,e){const n={},i=s(t,["outputGcsUri"]);e!==void 0&&i!=null&&r(e,["parameters","storageUri"],i);const l=s(t,["negativePrompt"]);e!==void 0&&l!=null&&r(e,["parameters","negativePrompt"],l);const a=s(t,["numberOfImages"]);e!==void 0&&a!=null&&r(e,["parameters","sampleCount"],a);const u=s(t,["aspectRatio"]);e!==void 0&&u!=null&&r(e,["parameters","aspectRatio"],u);const d=s(t,["guidanceScale"]);e!==void 0&&d!=null&&r(e,["parameters","guidanceScale"],d);const c=s(t,["seed"]);e!==void 0&&c!=null&&r(e,["parameters","seed"],c);const f=s(t,["safetyFilterLevel"]);e!==void 0&&f!=null&&r(e,["parameters","safetySetting"],f);const p=s(t,["personGeneration"]);e!==void 0&&p!=null&&r(e,["parameters","personGeneration"],p);const m=s(t,["includeSafetyAttributes"]);e!==void 0&&m!=null&&r(e,["parameters","includeSafetyAttributes"],m);const h=s(t,["includeRaiReason"]);e!==void 0&&h!=null&&r(e,["parameters","includeRaiReason"],h);const g=s(t,["language"]);e!==void 0&&g!=null&&r(e,["parameters","language"],g);const y=s(t,["outputMimeType"]);e!==void 0&&y!=null&&r(e,["parameters","outputOptions","mimeType"],y);const _=s(t,["outputCompressionQuality"]);e!==void 0&&_!=null&&r(e,["parameters","outputOptions","compressionQuality"],_);const A=s(t,["editMode"]);e!==void 0&&A!=null&&r(e,["parameters","editMode"],A);const x=s(t,["baseSteps"]);return e!==void 0&&x!=null&&r(e,["parameters","editConfig","baseSteps"],x),n}function eu(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["prompt"]);i!=null&&r(e,["instances[0]","prompt"],i);const l=s(t,["referenceImages"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(d=>Qa(o,d))),r(e,["instances[0]","referenceImages"],u)}const a=s(t,["config"]);return a!=null&&r(e,["config"],ja(o,a,e)),e}function tu(o,t,e){const n={},i=s(t,["includeRaiReason"]);e!==void 0&&i!=null&&r(e,["parameters","includeRaiReason"],i);const l=s(t,["outputMimeType"]);e!==void 0&&l!=null&&r(e,["parameters","outputOptions","mimeType"],l);const a=s(t,["outputCompressionQuality"]);e!==void 0&&a!=null&&r(e,["parameters","outputOptions","compressionQuality"],a);const u=s(t,["numberOfImages"]);e!==void 0&&u!=null&&r(e,["parameters","sampleCount"],u);const d=s(t,["mode"]);return e!==void 0&&d!=null&&r(e,["parameters","mode"],d),n}function nu(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["image"]);i!=null&&r(e,["instances[0]","image"],Oe(o,i));const l=s(t,["upscaleFactor"]);l!=null&&r(e,["parameters","upscaleConfig","upscaleFactor"],l);const a=s(t,["config"]);return a!=null&&r(e,["config"],tu(o,a,e)),e}function ou(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","name"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function iu(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);e!==void 0&&l!=null&&r(e,["_query","pageToken"],l);const a=s(t,["filter"]);e!==void 0&&a!=null&&r(e,["_query","filter"],a);const u=s(t,["queryBase"]);return e!==void 0&&u!=null&&r(e,["_url","models_url"],io(o,u)),n}function su(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],iu(o,n,e)),e}function ru(o,t,e){const n={},i=s(t,["displayName"]);e!==void 0&&i!=null&&r(e,["displayName"],i);const l=s(t,["description"]);e!==void 0&&l!=null&&r(e,["description"],l);const a=s(t,["defaultCheckpointId"]);return e!==void 0&&a!=null&&r(e,["defaultCheckpointId"],a),n}function lu(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],ru(o,i,e)),e}function au(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","name"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function uu(o,t,e){const n={},i=s(t,["systemInstruction"]);e!==void 0&&i!=null&&r(e,["systemInstruction"],Ce(o,b(o,i)));const l=s(t,["tools"]);if(e!==void 0&&l!=null){let u=l;Array.isArray(u)&&(u=u.map(d=>mo(o,d))),r(e,["tools"],u)}const a=s(t,["generationConfig"]);return e!==void 0&&a!=null&&r(e,["generationConfig"],a),n}function cu(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);if(i!=null){let a=W(o,i);Array.isArray(a)&&(a=a.map(u=>Ce(o,u))),r(e,["contents"],a)}const l=s(t,["config"]);return l!=null&&r(e,["config"],uu(o,l,e)),e}function du(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["contents"]);if(i!=null){let a=W(o,i);Array.isArray(a)&&(a=a.map(u=>Ce(o,u))),r(e,["contents"],a)}const l=s(t,["config"]);return l!=null&&r(e,["config"],l),e}function fu(o,t){const e={},n=s(t,["uri"]);n!=null&&r(e,["gcsUri"],n);const i=s(t,["videoBytes"]);i!=null&&r(e,["bytesBase64Encoded"],j(o,i));const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function pu(o,t,e){const n={},i=s(t,["numberOfVideos"]);e!==void 0&&i!=null&&r(e,["parameters","sampleCount"],i);const l=s(t,["outputGcsUri"]);e!==void 0&&l!=null&&r(e,["parameters","storageUri"],l);const a=s(t,["fps"]);e!==void 0&&a!=null&&r(e,["parameters","fps"],a);const u=s(t,["durationSeconds"]);e!==void 0&&u!=null&&r(e,["parameters","durationSeconds"],u);const d=s(t,["seed"]);e!==void 0&&d!=null&&r(e,["parameters","seed"],d);const c=s(t,["aspectRatio"]);e!==void 0&&c!=null&&r(e,["parameters","aspectRatio"],c);const f=s(t,["resolution"]);e!==void 0&&f!=null&&r(e,["parameters","resolution"],f);const p=s(t,["personGeneration"]);e!==void 0&&p!=null&&r(e,["parameters","personGeneration"],p);const m=s(t,["pubsubTopic"]);e!==void 0&&m!=null&&r(e,["parameters","pubsubTopic"],m);const h=s(t,["negativePrompt"]);e!==void 0&&h!=null&&r(e,["parameters","negativePrompt"],h);const g=s(t,["enhancePrompt"]);e!==void 0&&g!=null&&r(e,["parameters","enhancePrompt"],g);const y=s(t,["generateAudio"]);e!==void 0&&y!=null&&r(e,["parameters","generateAudio"],y);const _=s(t,["lastFrame"]);return e!==void 0&&_!=null&&r(e,["instances[0]","lastFrame"],Oe(o,_)),n}function mu(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["_url","model"],G(o,n));const i=s(t,["prompt"]);i!=null&&r(e,["instances[0]","prompt"],i);const l=s(t,["image"]);l!=null&&r(e,["instances[0]","image"],Oe(o,l));const a=s(t,["video"]);a!=null&&r(e,["instances[0]","video"],fu(o,a));const u=s(t,["config"]);return u!=null&&r(e,["config"],pu(o,u,e)),e}function hu(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function gu(o,t){const e={},n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function yu(o,t){const e={},n=s(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function vu(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],hu(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],gu(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],yu(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function Tu(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>vu(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function Cu(o,t){const e={},n=s(t,["citationSources"]);return n!=null&&r(e,["citations"],n),e}function _u(o,t){const e={},n=s(t,["retrievedUrl"]);n!=null&&r(e,["retrievedUrl"],n);const i=s(t,["urlRetrievalStatus"]);return i!=null&&r(e,["urlRetrievalStatus"],i),e}function Eu(o,t){const e={},n=s(t,["urlMetadata"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>_u(o,l))),r(e,["urlMetadata"],i)}return e}function Su(o,t){const e={},n=s(t,["content"]);n!=null&&r(e,["content"],Tu(o,n));const i=s(t,["citationMetadata"]);i!=null&&r(e,["citationMetadata"],Cu(o,i));const l=s(t,["tokenCount"]);l!=null&&r(e,["tokenCount"],l);const a=s(t,["finishReason"]);a!=null&&r(e,["finishReason"],a);const u=s(t,["urlContextMetadata"]);u!=null&&r(e,["urlContextMetadata"],Eu(o,u));const d=s(t,["avgLogprobs"]);d!=null&&r(e,["avgLogprobs"],d);const c=s(t,["groundingMetadata"]);c!=null&&r(e,["groundingMetadata"],c);const f=s(t,["index"]);f!=null&&r(e,["index"],f);const p=s(t,["logprobsResult"]);p!=null&&r(e,["logprobsResult"],p);const m=s(t,["safetyRatings"]);return m!=null&&r(e,["safetyRatings"],m),e}function Gn(o,t){const e={},n=s(t,["candidates"]);if(n!=null){let u=n;Array.isArray(u)&&(u=u.map(d=>Su(o,d))),r(e,["candidates"],u)}const i=s(t,["modelVersion"]);i!=null&&r(e,["modelVersion"],i);const l=s(t,["promptFeedback"]);l!=null&&r(e,["promptFeedback"],l);const a=s(t,["usageMetadata"]);return a!=null&&r(e,["usageMetadata"],a),e}function Au(o,t){const e={},n=s(t,["values"]);return n!=null&&r(e,["values"],n),e}function Iu(){return{}}function Mu(o,t){const e={},n=s(t,["embeddings"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Au(o,a))),r(e,["embeddings"],l)}return s(t,["metadata"])!=null&&r(e,["metadata"],Iu()),e}function xu(o,t){const e={},n=s(t,["bytesBase64Encoded"]);n!=null&&r(e,["imageBytes"],j(o,n));const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function ho(o,t){const e={},n=s(t,["safetyAttributes","categories"]);n!=null&&r(e,["categories"],n);const i=s(t,["safetyAttributes","scores"]);i!=null&&r(e,["scores"],i);const l=s(t,["contentType"]);return l!=null&&r(e,["contentType"],l),e}function Ru(o,t){const e={},n=s(t,["_self"]);n!=null&&r(e,["image"],xu(o,n));const i=s(t,["raiFilteredReason"]);i!=null&&r(e,["raiFilteredReason"],i);const l=s(t,["_self"]);return l!=null&&r(e,["safetyAttributes"],ho(o,l)),e}function Pu(o,t){const e={},n=s(t,["predictions"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Ru(o,a))),r(e,["generatedImages"],l)}const i=s(t,["positivePromptSafetyAttributes"]);return i!=null&&r(e,["positivePromptSafetyAttributes"],ho(o,i)),e}function wu(o,t){const e={},n=s(t,["baseModel"]);n!=null&&r(e,["baseModel"],n);const i=s(t,["createTime"]);i!=null&&r(e,["createTime"],i);const l=s(t,["updateTime"]);return l!=null&&r(e,["updateTime"],l),e}function lt(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["displayName"]);i!=null&&r(e,["displayName"],i);const l=s(t,["description"]);l!=null&&r(e,["description"],l);const a=s(t,["version"]);a!=null&&r(e,["version"],a);const u=s(t,["_self"]);u!=null&&r(e,["tunedModelInfo"],wu(o,u));const d=s(t,["inputTokenLimit"]);d!=null&&r(e,["inputTokenLimit"],d);const c=s(t,["outputTokenLimit"]);c!=null&&r(e,["outputTokenLimit"],c);const f=s(t,["supportedGenerationMethods"]);return f!=null&&r(e,["supportedActions"],f),e}function Nu(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["_self"]);if(i!=null){let l=so(o,i);Array.isArray(l)&&(l=l.map(a=>lt(o,a))),r(e,["models"],l)}return e}function ku(){return{}}function Du(o,t){const e={},n=s(t,["totalTokens"]);n!=null&&r(e,["totalTokens"],n);const i=s(t,["cachedContentTokenCount"]);return i!=null&&r(e,["cachedContentTokenCount"],i),e}function Vu(o,t){const e={},n=s(t,["video","uri"]);n!=null&&r(e,["uri"],n);const i=s(t,["video","encodedVideo"]);i!=null&&r(e,["videoBytes"],j(o,i));const l=s(t,["encoding"]);return l!=null&&r(e,["mimeType"],l),e}function Lu(o,t){const e={},n=s(t,["_self"]);return n!=null&&r(e,["video"],Vu(o,n)),e}function Fu(o,t){const e={},n=s(t,["generatedSamples"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>Lu(o,u))),r(e,["generatedVideos"],a)}const i=s(t,["raiMediaFilteredCount"]);i!=null&&r(e,["raiMediaFilteredCount"],i);const l=s(t,["raiMediaFilteredReasons"]);return l!=null&&r(e,["raiMediaFilteredReasons"],l),e}function Uu(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["metadata"]);i!=null&&r(e,["metadata"],i);const l=s(t,["done"]);l!=null&&r(e,["done"],l);const a=s(t,["error"]);a!=null&&r(e,["error"],a);const u=s(t,["response","generateVideoResponse"]);return u!=null&&r(e,["response"],Fu(o,u)),e}function Gu(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function qu(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["data"]);i!=null&&r(e,["data"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function Bu(o,t){const e={},n=s(t,["displayName"]);n!=null&&r(e,["displayName"],n);const i=s(t,["fileUri"]);i!=null&&r(e,["fileUri"],i);const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function $u(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Gu(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],qu(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],Bu(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function bu(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>$u(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function Hu(o,t){const e={},n=s(t,["citations"]);return n!=null&&r(e,["citations"],n),e}function Ju(o,t){const e={},n=s(t,["retrievedUrl"]);n!=null&&r(e,["retrievedUrl"],n);const i=s(t,["urlRetrievalStatus"]);return i!=null&&r(e,["urlRetrievalStatus"],i),e}function Ou(o,t){const e={},n=s(t,["urlMetadata"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>Ju(o,l))),r(e,["urlMetadata"],i)}return e}function Wu(o,t){const e={},n=s(t,["content"]);n!=null&&r(e,["content"],bu(o,n));const i=s(t,["citationMetadata"]);i!=null&&r(e,["citationMetadata"],Hu(o,i));const l=s(t,["finishMessage"]);l!=null&&r(e,["finishMessage"],l);const a=s(t,["finishReason"]);a!=null&&r(e,["finishReason"],a);const u=s(t,["urlContextMetadata"]);u!=null&&r(e,["urlContextMetadata"],Ou(o,u));const d=s(t,["avgLogprobs"]);d!=null&&r(e,["avgLogprobs"],d);const c=s(t,["groundingMetadata"]);c!=null&&r(e,["groundingMetadata"],c);const f=s(t,["index"]);f!=null&&r(e,["index"],f);const p=s(t,["logprobsResult"]);p!=null&&r(e,["logprobsResult"],p);const m=s(t,["safetyRatings"]);return m!=null&&r(e,["safetyRatings"],m),e}function qn(o,t){const e={},n=s(t,["candidates"]);if(n!=null){let c=n;Array.isArray(c)&&(c=c.map(f=>Wu(o,f))),r(e,["candidates"],c)}const i=s(t,["createTime"]);i!=null&&r(e,["createTime"],i);const l=s(t,["responseId"]);l!=null&&r(e,["responseId"],l);const a=s(t,["modelVersion"]);a!=null&&r(e,["modelVersion"],a);const u=s(t,["promptFeedback"]);u!=null&&r(e,["promptFeedback"],u);const d=s(t,["usageMetadata"]);return d!=null&&r(e,["usageMetadata"],d),e}function Yu(o,t){const e={},n=s(t,["truncated"]);n!=null&&r(e,["truncated"],n);const i=s(t,["token_count"]);return i!=null&&r(e,["tokenCount"],i),e}function Zu(o,t){const e={},n=s(t,["values"]);n!=null&&r(e,["values"],n);const i=s(t,["statistics"]);return i!=null&&r(e,["statistics"],Yu(o,i)),e}function Ku(o,t){const e={},n=s(t,["billableCharacterCount"]);return n!=null&&r(e,["billableCharacterCount"],n),e}function zu(o,t){const e={},n=s(t,["predictions[]","embeddings"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Zu(o,a))),r(e,["embeddings"],l)}const i=s(t,["metadata"]);return i!=null&&r(e,["metadata"],Ku(o,i)),e}function Xu(o,t){const e={},n=s(t,["gcsUri"]);n!=null&&r(e,["gcsUri"],n);const i=s(t,["bytesBase64Encoded"]);i!=null&&r(e,["imageBytes"],j(o,i));const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function go(o,t){const e={},n=s(t,["safetyAttributes","categories"]);n!=null&&r(e,["categories"],n);const i=s(t,["safetyAttributes","scores"]);i!=null&&r(e,["scores"],i);const l=s(t,["contentType"]);return l!=null&&r(e,["contentType"],l),e}function mt(o,t){const e={},n=s(t,["_self"]);n!=null&&r(e,["image"],Xu(o,n));const i=s(t,["raiFilteredReason"]);i!=null&&r(e,["raiFilteredReason"],i);const l=s(t,["_self"]);l!=null&&r(e,["safetyAttributes"],go(o,l));const a=s(t,["prompt"]);return a!=null&&r(e,["enhancedPrompt"],a),e}function Qu(o,t){const e={},n=s(t,["predictions"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>mt(o,a))),r(e,["generatedImages"],l)}const i=s(t,["positivePromptSafetyAttributes"]);return i!=null&&r(e,["positivePromptSafetyAttributes"],go(o,i)),e}function ju(o,t){const e={},n=s(t,["predictions"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>mt(o,l))),r(e,["generatedImages"],i)}return e}function ec(o,t){const e={},n=s(t,["predictions"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>mt(o,l))),r(e,["generatedImages"],i)}return e}function tc(o,t){const e={},n=s(t,["endpoint"]);n!=null&&r(e,["name"],n);const i=s(t,["deployedModelId"]);return i!=null&&r(e,["deployedModelId"],i),e}function nc(o,t){const e={},n=s(t,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&r(e,["baseModel"],n);const i=s(t,["createTime"]);i!=null&&r(e,["createTime"],i);const l=s(t,["updateTime"]);return l!=null&&r(e,["updateTime"],l),e}function oc(o,t){const e={},n=s(t,["checkpointId"]);n!=null&&r(e,["checkpointId"],n);const i=s(t,["epoch"]);i!=null&&r(e,["epoch"],i);const l=s(t,["step"]);return l!=null&&r(e,["step"],l),e}function at(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["displayName"]);i!=null&&r(e,["displayName"],i);const l=s(t,["description"]);l!=null&&r(e,["description"],l);const a=s(t,["versionId"]);a!=null&&r(e,["version"],a);const u=s(t,["deployedModels"]);if(u!=null){let m=u;Array.isArray(m)&&(m=m.map(h=>tc(o,h))),r(e,["endpoints"],m)}const d=s(t,["labels"]);d!=null&&r(e,["labels"],d);const c=s(t,["_self"]);c!=null&&r(e,["tunedModelInfo"],nc(o,c));const f=s(t,["defaultCheckpointId"]);f!=null&&r(e,["defaultCheckpointId"],f);const p=s(t,["checkpoints"]);if(p!=null){let m=p;Array.isArray(m)&&(m=m.map(h=>oc(o,h))),r(e,["checkpoints"],m)}return e}function ic(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["_self"]);if(i!=null){let l=so(o,i);Array.isArray(l)&&(l=l.map(a=>at(o,a))),r(e,["models"],l)}return e}function sc(){return{}}function rc(o,t){const e={},n=s(t,["totalTokens"]);return n!=null&&r(e,["totalTokens"],n),e}function lc(o,t){const e={},n=s(t,["tokensInfo"]);return n!=null&&r(e,["tokensInfo"],n),e}function ac(o,t){const e={},n=s(t,["gcsUri"]);n!=null&&r(e,["uri"],n);const i=s(t,["bytesBase64Encoded"]);i!=null&&r(e,["videoBytes"],j(o,i));const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function uc(o,t){const e={},n=s(t,["_self"]);return n!=null&&r(e,["video"],ac(o,n)),e}function cc(o,t){const e={},n=s(t,["videos"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>uc(o,u))),r(e,["generatedVideos"],a)}const i=s(t,["raiMediaFilteredCount"]);i!=null&&r(e,["raiMediaFilteredCount"],i);const l=s(t,["raiMediaFilteredReasons"]);return l!=null&&r(e,["raiMediaFilteredReasons"],l),e}function dc(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["metadata"]);i!=null&&r(e,["metadata"],i);const l=s(t,["done"]);l!=null&&r(e,["done"],l);const a=s(t,["error"]);a!=null&&r(e,["error"],a);const u=s(t,["response"]);return u!=null&&r(e,["response"],cc(o,u)),e}/**
50
+ * @license
51
+ * Copyright 2025 Google LLC
52
+ * SPDX-License-Identifier: Apache-2.0
53
+ */const fc="Content-Type",pc="X-Server-Timeout",mc="User-Agent",ut="x-goog-api-client",hc="1.5.1",gc=`google-genai-sdk/${hc}`,yc="v1beta1",vc="v1beta",Bn=/^data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class yo extends Error{constructor(t,e){e?super(t,{cause:e}):super(t,{cause:new Error().stack}),this.message=t,this.name="ClientError"}}class ct extends Error{constructor(t,e){e?super(t,{cause:e}):super(t,{cause:new Error().stack}),this.message=t,this.name="ServerError"}}class Tc{constructor(t){var e,n;this.clientOptions=Object.assign(Object.assign({},t),{project:t.project,location:t.location,apiKey:t.apiKey,vertexai:t.vertexai});const i={};this.clientOptions.vertexai?(i.apiVersion=(e=this.clientOptions.apiVersion)!==null&&e!==void 0?e:yc,i.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(i.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:vc,i.baseUrl="https://generativelanguage.googleapis.com/"),i.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=i,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(i,t.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 t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}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(t){if(!t||t.baseUrl===void 0||t.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const n=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&n.push(t.apiVersion),n.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),e=new URL(t);return e.protocol=e.protocol=="http:"?"ws":"wss",e.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,e,n){const i=[this.getRequestUrlInternal(e)];return n&&i.push(this.getBaseResourcePath()),t!==""&&i.push(t),new URL(`${i.join("/")}`)}shouldPrependVertexProjectPath(t){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let e=this.clientOptions.httpOptions;t.httpOptions&&(e=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const n=this.shouldPrependVertexProjectPath(t),i=this.constructUrl(t.path,e,n);if(t.queryParams)for(const[a,u]of Object.entries(t.queryParams))i.searchParams.append(a,String(u));let l={};if(t.httpMethod==="GET"){if(t.body&&t.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else l.body=t.body;return l=await this.includeExtraHttpOptionsToRequestInit(l,e,t.abortSignal),this.unaryApiCall(i,l,t.httpMethod)}patchHttpOptions(t,e){const n=JSON.parse(JSON.stringify(t));for(const[i,l]of Object.entries(e))typeof l=="object"?n[i]=Object.assign(Object.assign({},n[i]),l):l!==void 0&&(n[i]=l);return n}async requestStream(t){let e=this.clientOptions.httpOptions;t.httpOptions&&(e=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const n=this.shouldPrependVertexProjectPath(t),i=this.constructUrl(t.path,e,n);(!i.searchParams.has("alt")||i.searchParams.get("alt")!=="sse")&&i.searchParams.set("alt","sse");let l={};return l.body=t.body,l=await this.includeExtraHttpOptionsToRequestInit(l,e,t.abortSignal),this.streamApiCall(i,l,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,e,n){if(e&&e.timeout||n){const i=new AbortController,l=i.signal;e.timeout&&e?.timeout>0&&setTimeout(()=>i.abort(),e.timeout),n&&n.addEventListener("abort",()=>{i.abort()}),t.signal=l}return t.headers=await this.getHeadersInternal(e),t}async unaryApiCall(t,e,n){return this.apiCall(t.toString(),Object.assign(Object.assign({},e),{method:n})).then(async i=>(await $n(i),new ot(i))).catch(i=>{throw i instanceof Error?i:new Error(JSON.stringify(i))})}async streamApiCall(t,e,n){return this.apiCall(t.toString(),Object.assign(Object.assign({},e),{method:n})).then(async i=>(await $n(i),this.processStreamResponse(i))).catch(i=>{throw i instanceof Error?i:new Error(JSON.stringify(i))})}processStreamResponse(t){var e;return fe(this,arguments,function*(){const i=(e=t?.body)===null||e===void 0?void 0:e.getReader(),l=new TextDecoder("utf-8");if(!i)throw new Error("Response body is empty");try{let a="";for(;;){const{done:u,value:d}=yield q(i.read());if(u){if(a.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const c=l.decode(d);try{const p=JSON.parse(c);if("error"in p){const m=JSON.parse(JSON.stringify(p.error)),h=m.status,g=m.code,y=`got status: ${h}. ${JSON.stringify(p)}`;if(g>=400&&g<500)throw new yo(y);if(g>=500&&g<600)throw new ct(y)}}catch(p){const m=p;if(m.name==="ClientError"||m.name==="ServerError")throw p}a+=c;let f=a.match(Bn);for(;f;){const p=f[1];try{const m=new Response(p,{headers:t?.headers,status:t?.status,statusText:t?.statusText});yield yield q(new ot(m)),a=a.slice(f[0].length),f=a.match(Bn)}catch(m){throw new Error(`exception parsing stream chunk ${p}. ${m}`)}}}}finally{i.releaseLock()}})}async apiCall(t,e){return fetch(t,e).catch(n=>{throw new Error(`exception ${n} sending request`)})}getDefaultHeaders(){const t={},e=gc+" "+this.clientOptions.userAgentExtra;return t[mc]=e,t[ut]=e,t[fc]="application/json",t}async getHeadersInternal(t){const e=new Headers;if(t&&t.headers){for(const[n,i]of Object.entries(t.headers))e.append(n,i);t.timeout&&t.timeout>0&&e.append(pc,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(e),e}async uploadFile(t,e){var n;const i={};e!=null&&(i.mimeType=e.mimeType,i.name=e.name,i.displayName=e.displayName),i.name&&!i.name.startsWith("files/")&&(i.name=`files/${i.name}`);const l=this.clientOptions.uploader,a=await l.stat(t);i.sizeBytes=String(a.size);const u=(n=e?.mimeType)!==null&&n!==void 0?n:a.type;if(u===void 0||u==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");i.mimeType=u;const d=await this.fetchUploadUrl(i,e);return l.upload(t,d,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,e){var n;let i={};e?.httpOptions?i=e.httpOptions:i={apiVersion:"",headers:{"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${t.sizeBytes}`,"X-Goog-Upload-Header-Content-Type":`${t.mimeType}`}};const l={file:t},a=await this.request({path:S("upload/v1beta/files",l._url),body:JSON.stringify(l),httpMethod:"POST",httpOptions:i});if(!a||!a?.headers)throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const u=(n=a?.headers)===null||n===void 0?void 0:n["x-goog-upload-url"];if(u===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return u}}async function $n(o){var t;if(o===void 0)throw new ct("response is undefined");if(!o.ok){const e=o.status,n=o.statusText;let i;!((t=o.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?i=await o.json():i={error:{message:await o.text(),code:o.status,status:o.statusText}};const l=`got status: ${e} ${n}. ${JSON.stringify(i)}`;throw e>=400&&e<500?new yo(l):e>=500&&e<600?new ct(l):new Error(l)}}/**
54
+ * @license
55
+ * Copyright 2025 Google LLC
56
+ * SPDX-License-Identifier: Apache-2.0
57
+ */const Cc="mcp_used/unknown";function vo(o){for(const t of o)if(ht(t)||typeof t=="object"&&"inputSchema"in t)return!0;return!1}function To(o){var t;const e=(t=o[ut])!==null&&t!==void 0?t:"";o[ut]=(e+` ${Cc}`).trimStart()}function _c(o){var t,e,n;return(n=(e=(t=o.config)===null||t===void 0?void 0:t.tools)===null||e===void 0?void 0:e.some(i=>ht(i)))!==null&&n!==void 0?n:!1}function Ec(o){var t,e,n;return(n=(e=(t=o.config)===null||t===void 0?void 0:t.tools)===null||e===void 0?void 0:e.some(i=>!ht(i)))!==null&&n!==void 0?n:!1}function ht(o){return o!==null&&typeof o=="object"&&o instanceof gt}function Sc(o,t=100){return fe(this,arguments,function*(){let n,i=0;for(;i<t;){const l=yield q(o.listTools({cursor:n}));for(const a of l.tools)yield yield q(a),i++;if(!l.nextCursor)break;n=l.nextCursor}})}class gt{constructor(t=[],e){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=t,this.config=e}static create(t,e){return new gt(t,e)}async initialize(){var t,e,n,i;if(this.mcpTools.length>0)return;const l={},a=[];for(const f of this.mcpClients)try{for(var u=!0,d=(e=void 0,Ae(Sc(f))),c;c=await d.next(),t=c.done,!t;u=!0){i=c.value,u=!1;const p=i;a.push(p);const m=p.name;if(l[m])throw new Error(`Duplicate function name ${m} found in MCP tools. Please ensure function names are unique.`);l[m]=f}}catch(p){e={error:p}}finally{try{!u&&!t&&(n=d.return)&&await n.call(d)}finally{if(e)throw e.error}}this.mcpTools=a,this.functionNameToMcpClient=l}async tool(){return await this.initialize(),Ai(this.mcpTools,this.config)}async callTool(t){await this.initialize();const e=[];for(const n of t)if(n.name in this.functionNameToMcpClient){const i=this.functionNameToMcpClient[n.name];let l;this.config.timeout&&(l={timeout:this.config.timeout});const a=await i.callTool({name:n.name,arguments:n.args},void 0,l);e.push({functionResponse:{name:n.name,response:a.isError?{error:a}:a}})}return e}}/**
58
+ * @license
59
+ * Copyright 2025 Google LLC
60
+ * SPDX-License-Identifier: Apache-2.0
61
+ */async function Ac(o,t,e){const n=new di;let i;e.data instanceof Blob?i=JSON.parse(await e.data.text()):i=JSON.parse(e.data);const l=Dl(o,i);Object.assign(n,l),t(n)}class Ic{constructor(t,e,n){this.apiClient=t,this.auth=e,this.webSocketFactory=n}async connect(t){var e,n;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const i=this.apiClient.getWebsocketBaseUrl(),l=this.apiClient.getApiVersion(),a=Rc(this.apiClient.getDefaultHeaders()),u=this.apiClient.getApiKey(),d=`${i}/ws/google.ai.generativelanguage.${l}.GenerativeService.BidiGenerateMusic?key=${u}`;let c=()=>{};const f=new Promise(R=>{c=R}),p=t.callbacks,m=function(){c({})},h=this.apiClient,g={onopen:m,onmessage:R=>{Ac(h,p.onmessage,R)},onerror:(e=p?.onerror)!==null&&e!==void 0?e:function(R){},onclose:(n=p?.onclose)!==null&&n!==void 0?n:function(R){}},y=this.webSocketFactory.create(d,xc(a),g);y.connect(),await f;const _=G(this.apiClient,t.model),A=co(this.apiClient,{model:_}),x=rt(this.apiClient,{setup:A});return y.send(JSON.stringify(x)),new Mc(y,this.apiClient)}}class Mc{constructor(t,e){this.conn=t,this.apiClient=e}async setWeightedPrompts(t){if(!t.weightedPrompts||Object.keys(t.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const e=Yr(this.apiClient,t),n=fo(this.apiClient,e);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const e=Zr(this.apiClient,t),n=rt(this.apiClient,e);this.conn.send(JSON.stringify(n))}sendPlaybackControl(t){const e=rt(this.apiClient,{playbackControl:t});this.conn.send(JSON.stringify(e))}play(){this.sendPlaybackControl(ce.PLAY)}pause(){this.sendPlaybackControl(ce.PAUSE)}stop(){this.sendPlaybackControl(ce.STOP)}resetContext(){this.sendPlaybackControl(ce.RESET_CONTEXT)}close(){this.conn.close()}}function xc(o){const t={};return o.forEach((e,n)=>{t[n]=e}),t}function Rc(o){const t=new Headers;for(const[e,n]of Object.entries(o))t.append(e,n);return t}/**
62
+ * @license
63
+ * Copyright 2025 Google LLC
64
+ * SPDX-License-Identifier: Apache-2.0
65
+ */const Pc="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function wc(o,t,e){const n=new ci;let i;if(e.data instanceof Blob?i=JSON.parse(await e.data.text()):i=JSON.parse(e.data),o.isVertexAI()){const l=Al(o,i);Object.assign(n,l)}else{const l=Sl(o,i);Object.assign(n,l)}t(n)}class Nc{constructor(t,e,n){this.apiClient=t,this.auth=e,this.webSocketFactory=n,this.music=new Ic(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var e,n,i,l,a,u;const d=this.apiClient.getWebsocketBaseUrl(),c=this.apiClient.getApiVersion();let f;const p=this.apiClient.getDefaultHeaders();t.config&&t.config.tools&&vo(t.config.tools)&&To(p);const m=Lc(p);if(this.apiClient.isVertexAI())f=`${d}/ws/google.cloud.aiplatform.${c}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(m);else{const w=this.apiClient.getApiKey();let F="BidiGenerateContent",J="key";w?.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),F="BidiGenerateContentConstrained",J="access_token"),f=`${d}/ws/google.ai.generativelanguage.${c}.GenerativeService.${F}?${J}=${w}`}let h=()=>{};const g=new Promise(w=>{h=w}),y=t.callbacks,_=function(){var w;(w=y?.onopen)===null||w===void 0||w.call(y),h({})},A=this.apiClient,x={onopen:_,onmessage:w=>{wc(A,y.onmessage,w)},onerror:(e=y?.onerror)!==null&&e!==void 0?e:function(w){},onclose:(n=y?.onclose)!==null&&n!==void 0?n:function(w){}},R=this.webSocketFactory.create(f,Vc(m),x);R.connect(),await g;let N=G(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&N.startsWith("publishers/")){const w=this.apiClient.getProject(),F=this.apiClient.getLocation();N=`projects/${w}/locations/${F}/`+N}let k={};this.apiClient.isVertexAI()&&((i=t.config)===null||i===void 0?void 0:i.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[qe.AUDIO]}:t.config.responseModalities=[qe.AUDIO]),!((l=t.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 V=(u=(a=t.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[],U=[];for(const w of V)if(this.isCallableTool(w)){const F=w;U.push(await F.tool())}else U.push(w);U.length>0&&(t.config.tools=U);const $={model:N,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?k=Br(this.apiClient,$):k=qr(this.apiClient,$),delete k.config,R.send(JSON.stringify(k)),new Dc(R,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const kc={turnComplete:!0};class Dc{constructor(t,e){this.conn=t,this.apiClient=e}tLiveClientContent(t,e){if(e.turns!==null&&e.turns!==void 0){let n=[];try{n=W(t,e.turns),t.isVertexAI()?n=n.map(i=>Ce(t,i)):n=n.map(i=>Je(t,i))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof e.turns}'`)}return{clientContent:{turns:n,turnComplete:e.turnComplete}}}return{clientContent:{turnComplete:e.turnComplete}}}tLiveClienttToolResponse(t,e){let n=[];if(e.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(e.functionResponses)?n=e.functionResponses:n=[e.functionResponses],n.length===0)throw new Error("functionResponses is required.");for(const l of n){if(typeof l!="object"||l===null||!("name"in l)||!("response"in l))throw new Error(`Could not parse function response, type '${typeof l}'.`);if(!t.isVertexAI()&&!("id"in l))throw new Error(Pc)}return{toolResponse:{functionResponses:n}}}sendClientContent(t){t=Object.assign(Object.assign({},kc),t);const e=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(e))}sendRealtimeInput(t){let e={};this.apiClient.isVertexAI()?e={realtimeInput:Wr(this.apiClient,t)}:e={realtimeInput:Or(this.apiClient,t)},this.conn.send(JSON.stringify(e))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const e=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(e))}close(){this.conn.close()}}function Vc(o){const t={};return o.forEach((e,n)=>{t[n]=e}),t}function Lc(o){const t=new Headers;for(const[e,n]of Object.entries(o))t.append(e,n);return t}/**
66
+ * @license
67
+ * Copyright 2025 Google LLC
68
+ * SPDX-License-Identifier: Apache-2.0
69
+ */const bn=10;function Hn(o){var t,e,n;if(!((t=o?.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let i=!1;for(const a of(e=o?.tools)!==null&&e!==void 0?e:[])if(ke(a)){i=!0;break}if(!i)return!0;const l=(n=o?.automaticFunctionCalling)===null||n===void 0?void 0:n.maximumRemoteCalls;return l&&(l<0||!Number.isInteger(l))||l==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",l),!0):!1}function ke(o){return"callTool"in o&&typeof o.callTool=="function"}function Jn(o){var t;return!(!((t=o?.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}/**
70
+ * @license
71
+ * Copyright 2025 Google LLC
72
+ * SPDX-License-Identifier: Apache-2.0
73
+ */class Fc extends Te{constructor(t){super(),this.apiClient=t,this.generateContent=async e=>{var n,i,l,a,u;const d=await this.processParamsForMcpUsage(e);if(!_c(e)||Hn(e.config))return await this.generateContentInternal(d);if(Ec(e))throw new Error("Automatic function calling with CallableTools and Tools is not yet supported.");let c,f;const p=W(this.apiClient,d.contents),m=(l=(i=(n=d.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||i===void 0?void 0:i.maximumRemoteCalls)!==null&&l!==void 0?l:bn;let h=0;for(;h<m&&(c=await this.generateContentInternal(d),!(!c.functionCalls||c.functionCalls.length===0));){const g=c.candidates[0].content,y=[];for(const _ of(u=(a=e.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[])if(ke(_)){const x=await _.callTool(c.functionCalls);y.push(...x)}h++,f={role:"user",parts:y},d.contents=W(this.apiClient,d.contents),d.contents.push(g),d.contents.push(f),Jn(d.config)&&(p.push(g),p.push(f))}return Jn(d.config)&&(c.automaticFunctionCallingHistory=p),c},this.generateContentStream=async e=>{if(Hn(e.config)){const n=await this.processParamsForMcpUsage(e);return await this.generateContentStreamInternal(n)}else return await this.processAfcStream(e)},this.generateImages=async e=>await this.generateImagesInternal(e).then(n=>{var i;let l;const a=[];if(n?.generatedImages)for(const d of n.generatedImages)d&&d?.safetyAttributes&&((i=d?.safetyAttributes)===null||i===void 0?void 0:i.contentType)==="Positive Prompt"?l=d?.safetyAttributes:a.push(d);let u;return l?u={generatedImages:a,positivePromptSafetyAttributes:l}:u={generatedImages:a},u}),this.list=async e=>{var n;const a={config:Object.assign(Object.assign({},{queryBase:!0}),e?.config)};if(this.apiClient.isVertexAI()&&!a.config.queryBase){if(!((n=a.config)===null||n===void 0)&&n.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");a.config.filter="labels.tune-type:*"}return new He(ve.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(a),a)},this.editImage=async e=>{const n={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};return e.referenceImages&&e.referenceImages&&(n.referenceImages=e.referenceImages.map(i=>i.toReferenceImageAPI())),await this.editImageInternal(n)},this.upscaleImage=async e=>{let n={numberOfImages:1,mode:"upscale"};e.config&&(n=Object.assign(Object.assign({},n),e.config));const i={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:n};return await this.upscaleImageInternal(i)}}async processParamsForMcpUsage(t){var e,n,i;const l=(e=t.config)===null||e===void 0?void 0:e.tools;if(!l)return t;const a=await Promise.all(l.map(async d=>ke(d)?await d.tool():d)),u={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:a})};if(u.config.tools=a,t.config&&t.config.tools&&vo(t.config.tools)){const d=(i=(n=t.config.httpOptions)===null||n===void 0?void 0:n.headers)!==null&&i!==void 0?i:{};let c=Object.assign({},d);Object.keys(c).length===0&&(c=this.apiClient.getDefaultHeaders()),To(c),u.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:c})}return u}async initAfcToolsMap(t){var e,n,i;const l=new Map;for(const a of(n=(e=t.config)===null||e===void 0?void 0:e.tools)!==null&&n!==void 0?n:[])if(ke(a)){const u=a,d=await u.tool();for(const c of(i=d.functionDeclarations)!==null&&i!==void 0?i:[]){if(!c.name)throw new Error("Function declaration name is required.");if(l.has(c.name))throw new Error(`Duplicate tool declaration name: ${c.name}`);l.set(c.name,u)}}return l}async processAfcStream(t){var e,n,i;const l=(i=(n=(e=t.config)===null||e===void 0?void 0:e.automaticFunctionCalling)===null||n===void 0?void 0:n.maximumRemoteCalls)!==null&&i!==void 0?i:bn;let a=!1,u=0;const d=await this.initAfcToolsMap(t);return function(c,f,p){var m,h;return fe(this,arguments,function*(){for(var g,y,_,A;u<l;){a&&(u++,a=!1);const k=yield q(c.processParamsForMcpUsage(p)),V=yield q(c.generateContentStreamInternal(k)),U=[],$=[];try{for(var x=!0,R=(y=void 0,Ae(V)),N;N=yield q(R.next()),g=N.done,!g;x=!0){A=N.value,x=!1;const w=A;if(yield yield q(w),w.candidates&&(!((m=w.candidates[0])===null||m===void 0)&&m.content)){$.push(w.candidates[0].content);for(const F of(h=w.candidates[0].content.parts)!==null&&h!==void 0?h:[])if(u<l&&F.functionCall){if(!F.functionCall.name)throw new Error("Function call name was not returned by the model.");if(f.has(F.functionCall.name)){const J=yield q(f.get(F.functionCall.name).callTool([F.functionCall]));U.push(...J)}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: ${F.functionCall.name}`)}}}}catch(w){y={error:w}}finally{try{!x&&!g&&(_=R.return)&&(yield q(_.call(R)))}finally{if(y)throw y.error}}if(U.length>0){a=!0;const w=new _e;w.candidates=[{content:{role:"user",parts:U}}],yield yield q(w);const F=[];F.push(...$),F.push({role:"user",parts:U});const J=W(c.apiClient,p.contents).concat(F);p.contents=J}else break}})}(this,d,t)}async generateContentInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Un(this.apiClient,t);return u=S("{model}:generateContent",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=qn(this.apiClient,f),m=new _e;return Object.assign(m,p),m})}else{const c=Fn(this.apiClient,t);return u=S("{model}:generateContent",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Gn(this.apiClient,f),m=new _e;return Object.assign(m,p),m})}}async generateContentStreamInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Un(this.apiClient,t);u=S("{model}:streamGenerateContent?alt=sse",c._url),d=c._query,delete c.config,delete c._url,delete c._query;const f=this.apiClient;return a=f.requestStream({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}),a.then(function(p){return fe(this,arguments,function*(){var m,h,g,y;try{for(var _=!0,A=Ae(p),x;x=yield q(A.next()),m=x.done,!m;_=!0){y=x.value,_=!1;const N=qn(f,yield q(y.json())),k=new _e;Object.assign(k,N),yield yield q(k)}}catch(R){h={error:R}}finally{try{!_&&!m&&(g=A.return)&&(yield q(g.call(A)))}finally{if(h)throw h.error}}})})}else{const c=Fn(this.apiClient,t);u=S("{model}:streamGenerateContent?alt=sse",c._url),d=c._query,delete c.config,delete c._url,delete c._query;const f=this.apiClient;return a=f.requestStream({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}),a.then(function(p){return fe(this,arguments,function*(){var m,h,g,y;try{for(var _=!0,A=Ae(p),x;x=yield q(A.next()),m=x.done,!m;_=!0){y=x.value,_=!1;const N=Gn(f,yield q(y.json())),k=new _e;Object.assign(k,N),yield yield q(k)}}catch(R){h={error:R}}finally{try{!_&&!m&&(g=A.return)&&(yield q(g.call(A)))}finally{if(h)throw h.error}}})})}}async embedContent(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Oa(this.apiClient,t);return u=S("{model}:predict",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=zu(this.apiClient,f),m=new gn;return Object.assign(m,p),m})}else{const c=ia(this.apiClient,t);return u=S("{model}:batchEmbedContents",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Mu(this.apiClient,f),m=new gn;return Object.assign(m,p),m})}}async generateImagesInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Ya(this.apiClient,t);return u=S("{model}:predict",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Qu(this.apiClient,f),m=new yn;return Object.assign(m,p),m})}else{const c=ra(this.apiClient,t);return u=S("{model}:predict",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Pu(this.apiClient,f),m=new yn;return Object.assign(m,p),m})}}async editImageInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI()){const u=eu(this.apiClient,t);return l=S("{model}:predict",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>{const c=ju(this.apiClient,d),f=new ii;return Object.assign(f,c),f})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI()){const u=nu(this.apiClient,t);return l=S("{model}:predict",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>{const c=ec(this.apiClient,d),f=new si;return Object.assign(f,c),f})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=ou(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>at(this.apiClient,f))}else{const c=la(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>lt(this.apiClient,f))}}async listInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=su(this.apiClient,t);return u=S("{models_url}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=ic(this.apiClient,f),m=new vn;return Object.assign(m,p),m})}else{const c=ua(this.apiClient,t);return u=S("{models_url}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Nu(this.apiClient,f),m=new vn;return Object.assign(m,p),m})}}async update(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=lu(this.apiClient,t);return u=S("{model}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>at(this.apiClient,f))}else{const c=da(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>lt(this.apiClient,f))}}async delete(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=au(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(()=>{const f=sc(),p=new Tn;return Object.assign(p,f),p})}else{const c=fa(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(()=>{const f=ku(),p=new Tn;return Object.assign(p,f),p})}}async countTokens(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=cu(this.apiClient,t);return u=S("{model}:countTokens",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=rc(this.apiClient,f),m=new Cn;return Object.assign(m,p),m})}else{const c=ma(this.apiClient,t);return u=S("{model}:countTokens",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Du(this.apiClient,f),m=new Cn;return Object.assign(m,p),m})}}async computeTokens(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI()){const u=du(this.apiClient,t);return l=S("{model}:computeTokens",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>{const c=lc(this.apiClient,d),f=new ri;return Object.assign(f,c),f})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideos(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=mu(this.apiClient,t);return u=S("{model}:predictLongRunning",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>dc(this.apiClient,f))}else{const c=ya(this.apiClient,t);return u=S("{model}:predictLongRunning",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Uu(this.apiClient,f))}}}/**
74
+ * @license
75
+ * Copyright 2025 Google LLC
76
+ * SPDX-License-Identifier: Apache-2.0
77
+ */function Uc(o,t){const e={},n=s(t,["operationName"]);n!=null&&r(e,["_url","operationName"],n);const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Gc(o,t){const e={},n=s(t,["operationName"]);n!=null&&r(e,["_url","operationName"],n);const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function qc(o,t){const e={},n=s(t,["operationName"]);n!=null&&r(e,["operationName"],n);const i=s(t,["resourceName"]);i!=null&&r(e,["_url","resourceName"],i);const l=s(t,["config"]);return l!=null&&r(e,["config"],l),e}function Bc(o,t){const e={},n=s(t,["video","uri"]);n!=null&&r(e,["uri"],n);const i=s(t,["video","encodedVideo"]);i!=null&&r(e,["videoBytes"],j(o,i));const l=s(t,["encoding"]);return l!=null&&r(e,["mimeType"],l),e}function $c(o,t){const e={},n=s(t,["_self"]);return n!=null&&r(e,["video"],Bc(o,n)),e}function bc(o,t){const e={},n=s(t,["generatedSamples"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>$c(o,u))),r(e,["generatedVideos"],a)}const i=s(t,["raiMediaFilteredCount"]);i!=null&&r(e,["raiMediaFilteredCount"],i);const l=s(t,["raiMediaFilteredReasons"]);return l!=null&&r(e,["raiMediaFilteredReasons"],l),e}function Hc(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["metadata"]);i!=null&&r(e,["metadata"],i);const l=s(t,["done"]);l!=null&&r(e,["done"],l);const a=s(t,["error"]);a!=null&&r(e,["error"],a);const u=s(t,["response","generateVideoResponse"]);return u!=null&&r(e,["response"],bc(o,u)),e}function Jc(o,t){const e={},n=s(t,["gcsUri"]);n!=null&&r(e,["uri"],n);const i=s(t,["bytesBase64Encoded"]);i!=null&&r(e,["videoBytes"],j(o,i));const l=s(t,["mimeType"]);return l!=null&&r(e,["mimeType"],l),e}function Oc(o,t){const e={},n=s(t,["_self"]);return n!=null&&r(e,["video"],Jc(o,n)),e}function Wc(o,t){const e={},n=s(t,["videos"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>Oc(o,u))),r(e,["generatedVideos"],a)}const i=s(t,["raiMediaFilteredCount"]);i!=null&&r(e,["raiMediaFilteredCount"],i);const l=s(t,["raiMediaFilteredReasons"]);return l!=null&&r(e,["raiMediaFilteredReasons"],l),e}function On(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["metadata"]);i!=null&&r(e,["metadata"],i);const l=s(t,["done"]);l!=null&&r(e,["done"],l);const a=s(t,["error"]);a!=null&&r(e,["error"],a);const u=s(t,["response"]);return u!=null&&r(e,["response"],Wc(o,u)),e}/**
78
+ * @license
79
+ * Copyright 2025 Google LLC
80
+ * SPDX-License-Identifier: Apache-2.0
81
+ */class Yc extends Te{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const e=t.operation,n=t.config;if(e.name===void 0||e.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const i=e.name.split("/operations/")[0];let l;return n&&"httpOptions"in n&&(l=n.httpOptions),this.fetchPredictVideosOperationInternal({operationName:e.name,resourceName:i,config:{httpOptions:l}})}else return this.getVideosOperationInternal({operationName:e.name,config:n})}async getVideosOperationInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Gc(this.apiClient,t);return u=S("{operationName}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>On(this.apiClient,f))}else{const c=Uc(this.apiClient,t);return u=S("{operationName}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Hc(this.apiClient,f))}}async fetchPredictVideosOperationInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI()){const u=qc(this.apiClient,t);return l=S("{resourceName}:fetchPredictOperation",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>On(this.apiClient,d))}else throw new Error("This method is only supported by the Vertex AI.")}}/**
82
+ * @license
83
+ * Copyright 2025 Google LLC
84
+ * SPDX-License-Identifier: Apache-2.0
85
+ */function Zc(o,t){const e={},n=s(t,["voiceName"]);return n!=null&&r(e,["voiceName"],n),e}function Co(o,t){const e={},n=s(t,["prebuiltVoiceConfig"]);return n!=null&&r(e,["prebuiltVoiceConfig"],Zc(o,n)),e}function Kc(o,t){const e={},n=s(t,["speaker"]);n!=null&&r(e,["speaker"],n);const i=s(t,["voiceConfig"]);return i!=null&&r(e,["voiceConfig"],Co(o,i)),e}function zc(o,t){const e={},n=s(t,["speakerVoiceConfigs"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>Kc(o,l))),r(e,["speakerVoiceConfigs"],i)}return e}function Xc(o,t){const e={},n=s(t,["voiceConfig"]);n!=null&&r(e,["voiceConfig"],Co(o,n));const i=s(t,["multiSpeakerVoiceConfig"]);i!=null&&r(e,["multiSpeakerVoiceConfig"],zc(o,i));const l=s(t,["languageCode"]);return l!=null&&r(e,["languageCode"],l),e}function Qc(o,t){const e={},n=s(t,["fps"]);n!=null&&r(e,["fps"],n);const i=s(t,["endOffset"]);i!=null&&r(e,["endOffset"],i);const l=s(t,["startOffset"]);return l!=null&&r(e,["startOffset"],l),e}function jc(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["data"]);n!=null&&r(e,["data"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function ed(o,t){const e={};if(s(t,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=s(t,["fileUri"]);n!=null&&r(e,["fileUri"],n);const i=s(t,["mimeType"]);return i!=null&&r(e,["mimeType"],i),e}function td(o,t){const e={},n=s(t,["videoMetadata"]);n!=null&&r(e,["videoMetadata"],Qc(o,n));const i=s(t,["thought"]);i!=null&&r(e,["thought"],i);const l=s(t,["inlineData"]);l!=null&&r(e,["inlineData"],jc(o,l));const a=s(t,["fileData"]);a!=null&&r(e,["fileData"],ed(o,a));const u=s(t,["thoughtSignature"]);u!=null&&r(e,["thoughtSignature"],u);const d=s(t,["codeExecutionResult"]);d!=null&&r(e,["codeExecutionResult"],d);const c=s(t,["executableCode"]);c!=null&&r(e,["executableCode"],c);const f=s(t,["functionCall"]);f!=null&&r(e,["functionCall"],f);const p=s(t,["functionResponse"]);p!=null&&r(e,["functionResponse"],p);const m=s(t,["text"]);return m!=null&&r(e,["text"],m),e}function nd(o,t){const e={},n=s(t,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>td(o,a))),r(e,["parts"],l)}const i=s(t,["role"]);return i!=null&&r(e,["role"],i),e}function od(o,t){const e={},n=s(t,["behavior"]);n!=null&&r(e,["behavior"],n);const i=s(t,["description"]);i!=null&&r(e,["description"],i);const l=s(t,["name"]);l!=null&&r(e,["name"],l);const a=s(t,["parameters"]);a!=null&&r(e,["parameters"],a);const u=s(t,["response"]);return u!=null&&r(e,["response"],u),e}function id(o,t){const e={},n=s(t,["startTime"]);n!=null&&r(e,["startTime"],n);const i=s(t,["endTime"]);return i!=null&&r(e,["endTime"],i),e}function sd(o,t){const e={},n=s(t,["timeRangeFilter"]);return n!=null&&r(e,["timeRangeFilter"],id(o,n)),e}function rd(o,t){const e={},n=s(t,["mode"]);n!=null&&r(e,["mode"],n);const i=s(t,["dynamicThreshold"]);return i!=null&&r(e,["dynamicThreshold"],i),e}function ld(o,t){const e={},n=s(t,["dynamicRetrievalConfig"]);return n!=null&&r(e,["dynamicRetrievalConfig"],rd(o,n)),e}function ad(){return{}}function ud(o,t){const e={},n=s(t,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>od(o,c))),r(e,["functionDeclarations"],d)}if(s(t,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const i=s(t,["googleSearch"]);i!=null&&r(e,["googleSearch"],sd(o,i));const l=s(t,["googleSearchRetrieval"]);if(l!=null&&r(e,["googleSearchRetrieval"],ld(o,l)),s(t,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(s(t,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");s(t,["urlContext"])!=null&&r(e,["urlContext"],ad());const u=s(t,["codeExecution"]);return u!=null&&r(e,["codeExecution"],u),e}function cd(o,t){const e={},n=s(t,["handle"]);if(n!=null&&r(e,["handle"],n),s(t,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return e}function Wn(){return{}}function dd(o,t){const e={},n=s(t,["disabled"]);n!=null&&r(e,["disabled"],n);const i=s(t,["startOfSpeechSensitivity"]);i!=null&&r(e,["startOfSpeechSensitivity"],i);const l=s(t,["endOfSpeechSensitivity"]);l!=null&&r(e,["endOfSpeechSensitivity"],l);const a=s(t,["prefixPaddingMs"]);a!=null&&r(e,["prefixPaddingMs"],a);const u=s(t,["silenceDurationMs"]);return u!=null&&r(e,["silenceDurationMs"],u),e}function fd(o,t){const e={},n=s(t,["automaticActivityDetection"]);n!=null&&r(e,["automaticActivityDetection"],dd(o,n));const i=s(t,["activityHandling"]);i!=null&&r(e,["activityHandling"],i);const l=s(t,["turnCoverage"]);return l!=null&&r(e,["turnCoverage"],l),e}function pd(o,t){const e={},n=s(t,["targetTokens"]);return n!=null&&r(e,["targetTokens"],n),e}function md(o,t){const e={},n=s(t,["triggerTokens"]);n!=null&&r(e,["triggerTokens"],n);const i=s(t,["slidingWindow"]);return i!=null&&r(e,["slidingWindow"],pd(o,i)),e}function hd(o,t){const e={},n=s(t,["proactiveAudio"]);return n!=null&&r(e,["proactiveAudio"],n),e}function gd(o,t,e){const n={},i=s(t,["generationConfig"]);e!==void 0&&i!=null&&r(e,["setup","generationConfig"],i);const l=s(t,["responseModalities"]);e!==void 0&&l!=null&&r(e,["setup","generationConfig","responseModalities"],l);const a=s(t,["temperature"]);e!==void 0&&a!=null&&r(e,["setup","generationConfig","temperature"],a);const u=s(t,["topP"]);e!==void 0&&u!=null&&r(e,["setup","generationConfig","topP"],u);const d=s(t,["topK"]);e!==void 0&&d!=null&&r(e,["setup","generationConfig","topK"],d);const c=s(t,["maxOutputTokens"]);e!==void 0&&c!=null&&r(e,["setup","generationConfig","maxOutputTokens"],c);const f=s(t,["mediaResolution"]);e!==void 0&&f!=null&&r(e,["setup","generationConfig","mediaResolution"],f);const p=s(t,["seed"]);e!==void 0&&p!=null&&r(e,["setup","generationConfig","seed"],p);const m=s(t,["speechConfig"]);e!==void 0&&m!=null&&r(e,["setup","generationConfig","speechConfig"],Xc(o,pt(o,m)));const h=s(t,["enableAffectiveDialog"]);e!==void 0&&h!=null&&r(e,["setup","generationConfig","enableAffectiveDialog"],h);const g=s(t,["systemInstruction"]);e!==void 0&&g!=null&&r(e,["setup","systemInstruction"],nd(o,b(o,g)));const y=s(t,["tools"]);if(e!==void 0&&y!=null){let V=xe(o,y);Array.isArray(V)&&(V=V.map(U=>ud(o,Me(o,U)))),r(e,["setup","tools"],V)}const _=s(t,["sessionResumption"]);e!==void 0&&_!=null&&r(e,["setup","sessionResumption"],cd(o,_));const A=s(t,["inputAudioTranscription"]);e!==void 0&&A!=null&&r(e,["setup","inputAudioTranscription"],Wn());const x=s(t,["outputAudioTranscription"]);e!==void 0&&x!=null&&r(e,["setup","outputAudioTranscription"],Wn());const R=s(t,["realtimeInputConfig"]);e!==void 0&&R!=null&&r(e,["setup","realtimeInputConfig"],fd(o,R));const N=s(t,["contextWindowCompression"]);e!==void 0&&N!=null&&r(e,["setup","contextWindowCompression"],md(o,N));const k=s(t,["proactivity"]);return e!==void 0&&k!=null&&r(e,["setup","proactivity"],hd(o,k)),n}function yd(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["setup","model"],G(o,n));const i=s(t,["config"]);return i!=null&&r(e,["config"],gd(o,i,e)),e}function vd(o,t,e){const n={},i=s(t,["expireTime"]);e!==void 0&&i!=null&&r(e,["expireTime"],i);const l=s(t,["newSessionExpireTime"]);e!==void 0&&l!=null&&r(e,["newSessionExpireTime"],l);const a=s(t,["uses"]);e!==void 0&&a!=null&&r(e,["uses"],a);const u=s(t,["liveConnectConstraints"]);e!==void 0&&u!=null&&r(e,["bidiGenerateContentSetup"],yd(o,u));const d=s(t,["lockAdditionalFields"]);return e!==void 0&&d!=null&&r(e,["fieldMask"],d),n}function Td(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],vd(o,n,e)),e}function Cd(o,t){const e={},n=s(t,["name"]);return n!=null&&r(e,["name"],n),e}/**
86
+ * @license
87
+ * Copyright 2025 Google LLC
88
+ * SPDX-License-Identifier: Apache-2.0
89
+ */function _d(o){const t=[];for(const e in o)if(Object.prototype.hasOwnProperty.call(o,e)){const n=o[e];if(typeof n=="object"&&n!=null&&Object.keys(n).length>0){const i=Object.keys(n).map(l=>`${e}.${l}`);t.push(...i)}else t.push(e)}return t.join(",")}function Ed(o,t){let e=null;const n=o.bidiGenerateContentSetup;if(typeof n=="object"&&n!==null&&"setup"in n){const l=n.setup;typeof l=="object"&&l!==null?(o.bidiGenerateContentSetup=l,e=l):delete o.bidiGenerateContentSetup}else n!==void 0&&delete o.bidiGenerateContentSetup;const i=o.fieldMask;if(e){const l=_d(e);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)l?o.fieldMask=l:delete o.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){const a=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];i.length>0&&(u=i.map(c=>a.includes(c)?`generationConfig.${c}`:c));const d=[];l&&d.push(l),u.length>0&&d.push(...u),d.length>0?o.fieldMask=d.join(","):delete o.fieldMask}else delete o.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?o.fieldMask=i.join(","):delete o.fieldMask;return o}class Sd extends Te{constructor(t){super(),this.apiClient=t}async create(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=Td(this.apiClient,t);l=S("auth_tokens",u._url),a=u._query,delete u.config,delete u._url,delete u._query;const d=Ed(u,t.config);return i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(c=>c.json()),i.then(c=>Cd(this.apiClient,c))}}}/**
90
+ * @license
91
+ * Copyright 2025 Google LLC
92
+ * SPDX-License-Identifier: Apache-2.0
93
+ */function Ad(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],n);const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function Id(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);e!==void 0&&l!=null&&r(e,["_query","pageToken"],l);const a=s(t,["filter"]);return e!==void 0&&a!=null&&r(e,["_query","filter"],a),n}function Md(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],Id(o,n,e)),e}function xd(o,t){const e={},n=s(t,["textInput"]);n!=null&&r(e,["textInput"],n);const i=s(t,["output"]);return i!=null&&r(e,["output"],i),e}function Rd(o,t){const e={};if(s(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=s(t,["examples"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(l=>xd(o,l))),r(e,["examples","examples"],i)}return e}function Pd(o,t,e){const n={};if(s(t,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const i=s(t,["tunedModelDisplayName"]);if(e!==void 0&&i!=null&&r(e,["displayName"],i),s(t,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const l=s(t,["epochCount"]);e!==void 0&&l!=null&&r(e,["tuningTask","hyperparameters","epochCount"],l);const a=s(t,["learningRateMultiplier"]);if(a!=null&&r(n,["tuningTask","hyperparameters","learningRateMultiplier"],a),s(t,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(s(t,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const u=s(t,["batchSize"]);e!==void 0&&u!=null&&r(e,["tuningTask","hyperparameters","batchSize"],u);const d=s(t,["learningRate"]);return e!==void 0&&d!=null&&r(e,["tuningTask","hyperparameters","learningRate"],d),n}function wd(o,t){const e={},n=s(t,["baseModel"]);n!=null&&r(e,["baseModel"],n);const i=s(t,["trainingDataset"]);i!=null&&r(e,["tuningTask","trainingData"],Rd(o,i));const l=s(t,["config"]);return l!=null&&r(e,["config"],Pd(o,l,e)),e}function Nd(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["_url","name"],n);const i=s(t,["config"]);return i!=null&&r(e,["config"],i),e}function kd(o,t,e){const n={},i=s(t,["pageSize"]);e!==void 0&&i!=null&&r(e,["_query","pageSize"],i);const l=s(t,["pageToken"]);e!==void 0&&l!=null&&r(e,["_query","pageToken"],l);const a=s(t,["filter"]);return e!==void 0&&a!=null&&r(e,["_query","filter"],a),n}function Dd(o,t){const e={},n=s(t,["config"]);return n!=null&&r(e,["config"],kd(o,n,e)),e}function Vd(o,t,e){const n={},i=s(t,["gcsUri"]);if(e!==void 0&&i!=null&&r(e,["supervisedTuningSpec","trainingDatasetUri"],i),s(t,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return n}function Ld(o,t){const e={},n=s(t,["gcsUri"]);return n!=null&&r(e,["validationDatasetUri"],n),e}function Fd(o,t,e){const n={},i=s(t,["validationDataset"]);e!==void 0&&i!=null&&r(e,["supervisedTuningSpec"],Ld(o,i));const l=s(t,["tunedModelDisplayName"]);e!==void 0&&l!=null&&r(e,["tunedModelDisplayName"],l);const a=s(t,["description"]);e!==void 0&&a!=null&&r(e,["description"],a);const u=s(t,["epochCount"]);e!==void 0&&u!=null&&r(e,["supervisedTuningSpec","hyperParameters","epochCount"],u);const d=s(t,["learningRateMultiplier"]);e!==void 0&&d!=null&&r(e,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],d);const c=s(t,["exportLastCheckpointOnly"]);e!==void 0&&c!=null&&r(e,["supervisedTuningSpec","exportLastCheckpointOnly"],c);const f=s(t,["adapterSize"]);if(e!==void 0&&f!=null&&r(e,["supervisedTuningSpec","hyperParameters","adapterSize"],f),s(t,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(s(t,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");return n}function Ud(o,t){const e={},n=s(t,["baseModel"]);n!=null&&r(e,["baseModel"],n);const i=s(t,["trainingDataset"]);i!=null&&r(e,["supervisedTuningSpec","trainingDatasetUri"],Vd(o,i,e));const l=s(t,["config"]);return l!=null&&r(e,["config"],Fd(o,l,e)),e}function Gd(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["model"],n);const i=s(t,["name"]);return i!=null&&r(e,["endpoint"],i),e}function _o(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["state"]);i!=null&&r(e,["state"],no(o,i));const l=s(t,["createTime"]);l!=null&&r(e,["createTime"],l);const a=s(t,["tuningTask","startTime"]);a!=null&&r(e,["startTime"],a);const u=s(t,["tuningTask","completeTime"]);u!=null&&r(e,["endTime"],u);const d=s(t,["updateTime"]);d!=null&&r(e,["updateTime"],d);const c=s(t,["description"]);c!=null&&r(e,["description"],c);const f=s(t,["baseModel"]);f!=null&&r(e,["baseModel"],f);const p=s(t,["_self"]);p!=null&&r(e,["tunedModel"],Gd(o,p));const m=s(t,["distillationSpec"]);m!=null&&r(e,["distillationSpec"],m);const h=s(t,["experiment"]);h!=null&&r(e,["experiment"],h);const g=s(t,["labels"]);g!=null&&r(e,["labels"],g);const y=s(t,["pipelineJob"]);y!=null&&r(e,["pipelineJob"],y);const _=s(t,["serviceAccount"]);_!=null&&r(e,["serviceAccount"],_);const A=s(t,["tunedModelDisplayName"]);return A!=null&&r(e,["tunedModelDisplayName"],A),e}function qd(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["tunedModels"]);if(i!=null){let l=i;Array.isArray(l)&&(l=l.map(a=>_o(o,a))),r(e,["tuningJobs"],l)}return e}function Bd(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["metadata"]);i!=null&&r(e,["metadata"],i);const l=s(t,["done"]);l!=null&&r(e,["done"],l);const a=s(t,["error"]);return a!=null&&r(e,["error"],a),e}function $d(o,t){const e={},n=s(t,["checkpointId"]);n!=null&&r(e,["checkpointId"],n);const i=s(t,["epoch"]);i!=null&&r(e,["epoch"],i);const l=s(t,["step"]);l!=null&&r(e,["step"],l);const a=s(t,["endpoint"]);return a!=null&&r(e,["endpoint"],a),e}function bd(o,t){const e={},n=s(t,["model"]);n!=null&&r(e,["model"],n);const i=s(t,["endpoint"]);i!=null&&r(e,["endpoint"],i);const l=s(t,["checkpoints"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>$d(o,u))),r(e,["checkpoints"],a)}return e}function dt(o,t){const e={},n=s(t,["name"]);n!=null&&r(e,["name"],n);const i=s(t,["state"]);i!=null&&r(e,["state"],no(o,i));const l=s(t,["createTime"]);l!=null&&r(e,["createTime"],l);const a=s(t,["startTime"]);a!=null&&r(e,["startTime"],a);const u=s(t,["endTime"]);u!=null&&r(e,["endTime"],u);const d=s(t,["updateTime"]);d!=null&&r(e,["updateTime"],d);const c=s(t,["error"]);c!=null&&r(e,["error"],c);const f=s(t,["description"]);f!=null&&r(e,["description"],f);const p=s(t,["baseModel"]);p!=null&&r(e,["baseModel"],p);const m=s(t,["tunedModel"]);m!=null&&r(e,["tunedModel"],bd(o,m));const h=s(t,["supervisedTuningSpec"]);h!=null&&r(e,["supervisedTuningSpec"],h);const g=s(t,["tuningDataStats"]);g!=null&&r(e,["tuningDataStats"],g);const y=s(t,["encryptionSpec"]);y!=null&&r(e,["encryptionSpec"],y);const _=s(t,["partnerModelTuningSpec"]);_!=null&&r(e,["partnerModelTuningSpec"],_);const A=s(t,["distillationSpec"]);A!=null&&r(e,["distillationSpec"],A);const x=s(t,["experiment"]);x!=null&&r(e,["experiment"],x);const R=s(t,["labels"]);R!=null&&r(e,["labels"],R);const N=s(t,["pipelineJob"]);N!=null&&r(e,["pipelineJob"],N);const k=s(t,["serviceAccount"]);k!=null&&r(e,["serviceAccount"],k);const V=s(t,["tunedModelDisplayName"]);return V!=null&&r(e,["tunedModelDisplayName"],V),e}function Hd(o,t){const e={},n=s(t,["nextPageToken"]);n!=null&&r(e,["nextPageToken"],n);const i=s(t,["tuningJobs"]);if(i!=null){let l=i;Array.isArray(l)&&(l=l.map(a=>dt(o,a))),r(e,["tuningJobs"],l)}return e}/**
94
+ * @license
95
+ * Copyright 2025 Google LLC
96
+ * SPDX-License-Identifier: Apache-2.0
97
+ */class Jd extends Te{constructor(t){super(),this.apiClient=t,this.get=async e=>await this.getInternal(e),this.list=async(e={})=>new He(ve.PAGED_ITEM_TUNING_JOBS,n=>this.listInternal(n),await this.listInternal(e),e),this.tune=async e=>{if(this.apiClient.isVertexAI())return await this.tuneInternal(e);{const n=await this.tuneMldevInternal(e);let i="";return n.metadata!==void 0&&n.metadata.tunedModel!==void 0?i=n.metadata.tunedModel:n.name!==void 0&&n.name.includes("/operations/")&&(i=n.name.split("/operations/")[0]),{name:i,state:nt.JOB_STATE_QUEUED}}}}async getInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Nd(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>dt(this.apiClient,f))}else{const c=Ad(this.apiClient,t);return u=S("{name}",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>_o(this.apiClient,f))}}async listInternal(t){var e,n,i,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Dd(this.apiClient,t);return u=S("tuningJobs",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Hd(this.apiClient,f),m=new _n;return Object.assign(m,p),m})}else{const c=Md(this.apiClient,t);return u=S("tunedModels",c._url),d=c._query,delete c.config,delete c._url,delete c._query,a=this.apiClient.request({path:u,queryParams:d,body:JSON.stringify(c),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=qd(this.apiClient,f),m=new _n;return Object.assign(m,p),m})}}async tuneInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI()){const u=Ud(this.apiClient,t);return l=S("tuningJobs",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>dt(this.apiClient,d))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var e,n;let i,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=wd(this.apiClient,t);return l=S("tunedModels",u._url),a=u._query,delete u.config,delete u._url,delete u._query,i=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(e=t.config)===null||e===void 0?void 0:e.httpOptions,abortSignal:(n=t.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),i.then(d=>Bd(this.apiClient,d))}}}/**
98
+ * @license
99
+ * Copyright 2025 Google LLC
100
+ * SPDX-License-Identifier: Apache-2.0
101
+ */class Od{async download(t,e){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}const Wd=1024*1024*8,Yd=3,Zd=1e3,Kd=2,Ze="x-goog-upload-status";async function zd(o,t,e){var n,i,l;let a=0,u=0,d=new ot(new Response),c="upload";for(a=o.size;u<a;){const p=Math.min(Wd,a-u),m=o.slice(u,u+p);u+p>=a&&(c+=", finalize");let h=0,g=Zd;for(;h<Yd&&(d=await e.request({path:"",body:m,httpMethod:"POST",httpOptions:{apiVersion:"",baseUrl:t,headers:{"X-Goog-Upload-Command":c,"X-Goog-Upload-Offset":String(u),"Content-Length":String(p)}}}),!(!((n=d?.headers)===null||n===void 0)&&n[Ze]));)h++,await Qd(g),g=g*Kd;if(u+=p,((i=d?.headers)===null||i===void 0?void 0:i[Ze])!=="active")break;if(a<=u)throw new Error("All content has been uploaded, but the upload status is not finalized.")}const f=await d?.json();if(((l=d?.headers)===null||l===void 0?void 0:l[Ze])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return f.file}async function Xd(o){return{size:o.size,type:o.type}}function Qd(o){return new Promise(t=>setTimeout(t,o))}class jd{async upload(t,e,n){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await zd(t,e,n)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await Xd(t)}}/**
102
+ * @license
103
+ * Copyright 2025 Google LLC
104
+ * SPDX-License-Identifier: Apache-2.0
105
+ */class ef{create(t,e,n){return new tf(t,e,n)}}class tf{constructor(t,e,n){this.url=t,this.headers=e,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(t){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(t)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/**
106
+ * @license
107
+ * Copyright 2025 Google LLC
108
+ * SPDX-License-Identifier: Apache-2.0
109
+ */const Yn="x-goog-api-key";class nf{constructor(t){this.apiKey=t}async addAuthHeaders(t){if(t.get(Yn)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");t.append(Yn,this.apiKey)}}}/**
110
+ * @license
111
+ * Copyright 2025 Google LLC
112
+ * SPDX-License-Identifier: Apache-2.0
113
+ */const of="gl-node/";class sf{constructor(t){var e;if(t.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(t.project||t.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(e=t.vertexai)!==null&&e!==void 0?e:!1,this.apiKey=t.apiKey;const n=oi(t,void 0,void 0);n&&(t.httpOptions?t.httpOptions.baseUrl=n:t.httpOptions={baseUrl:n}),this.apiVersion=t.apiVersion;const i=new nf(this.apiKey);this.apiClient=new Tc({auth:i,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:t.httpOptions,userAgentExtra:of+"web",uploader:new jd,downloader:new Od}),this.models=new Fc(this.apiClient),this.live=new Nc(this.apiClient,i,new ef),this.chats=new ws(this.models,this.apiClient),this.caches=new xs(this.apiClient),this.files=new Hs(this.apiClient),this.operations=new Yc(this.apiClient),this.authTokens=new Sd(this.apiClient),this.tunings=new Jd(this.apiClient)}}export{fn as ActivityHandling,Yt as AdapterSize,Bt as AuthType,Kt as Behavior,Jt as BlockedReason,xs as Caches,Ns as Chat,ws as Chats,ri as ComputeTokensResponse,on as ControlReferenceType,Cn as CountTokensResponse,ai as CreateFileResponse,En as DeleteCachedContentResponse,ui as DeleteFileResponse,Tn as DeleteModelResponse,zt as DynamicRetrievalConfigMode,ii as EditImageResponse,rn as EditMode,gn as EmbedContentResponse,dn as EndSensitivity,Zt as FeatureSelectionPreference,an as FileSource,ln as FileState,Hs as Files,$t as FinishReason,Xt as FunctionCallingConfigMode,mn as FunctionResponseScheduling,_e as GenerateContentResponse,yn as GenerateImagesResponse,sf as GoogleGenAI,Ut as HarmBlockMethod,Gt as HarmBlockThreshold,Ft as HarmCategory,bt as HarmProbability,Ht as HarmSeverity,ot as HttpResponse,tn as ImagePromptLanguage,nt as JobState,Lt as Language,Sn as ListCachedContentsResponse,li as ListFilesResponse,vn as ListModelsResponse,_n as ListTuningJobsResponse,Nc as Live,ce as LiveMusicPlaybackControl,di as LiveMusicServerMessage,ci as LiveServerMessage,nn as MaskReferenceMode,un as MediaModality,Wt as MediaResolution,qe as Modality,qt as Mode,Fc as Models,Yc as Operations,Vt as Outcome,ve as PagedItem,He as Pager,en as PersonGeneration,jt as SafetyFilterLevel,hn as Scale,Dc as Session,cn as StartSensitivity,sn as SubjectReferenceType,Sd as Tokens,Ot as TrafficType,pn as TurnCoverage,Z as Type,si as UpscaleImageResponse,Qt as UrlRetrievalStatus};