@cravern/bpmn-flow-designer 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +3 -0
- package/dist/index.js +12037 -0
- package/dist/index.umd.js +241 -0
- package/dist/src/index.d.ts +1 -0
- package/package.json +18 -2
- package/App.tsx +0 -441
- package/index.html +0 -60
- package/index.tsx +0 -16
- package/metadata.json +0 -5
- package/tsconfig.json +0 -21
- package/vite.config.ts +0 -23
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
(function(fe,J){typeof exports=="object"&&typeof module<"u"?J(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],J):(fe=typeof globalThis<"u"?globalThis:fe||self,J(fe.BpmfFlowDesigner={},fe.React))})(this,(function(fe,J){"use strict";var Oe={exports:{}},De={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Ut;function Ki(){if(Ut)return De;Ut=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,o,l){var a=null;if(l!==void 0&&(a=""+l),o.key!==void 0&&(a=""+o.key),"key"in o){l={};for(var u in o)u!=="key"&&(l[u]=o[u])}else l=o;return o=l.ref,{$$typeof:i,type:n,key:a,ref:o!==void 0?o:null,props:l}}return De.Fragment=e,De.jsx=t,De.jsxs=t,De}var Le={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var bt;function Xi(){return bt||(bt=1,process.env.NODE_ENV!=="production"&&(function(){function i(y){if(y==null)return null;if(typeof y=="function")return y.$$typeof===Q?null:y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case E:return"Fragment";case w:return"Profiler";case I:return"StrictMode";case M:return"Suspense";case k:return"SuspenseList";case B:return"Activity"}if(typeof y=="object")switch(typeof y.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),y.$$typeof){case v:return"Portal";case F:return y.displayName||"Context";case N:return(y._context.displayName||"Context")+".Consumer";case x:var U=y.render;return y=y.displayName,y||(y=U.displayName||U.name||"",y=y!==""?"ForwardRef("+y+")":"ForwardRef"),y;case O:return U=y.displayName||null,U!==null?U:i(y.type)||"Memo";case L:U=y._payload,y=y._init;try{return i(y(U))}catch{}}return null}function e(y){return""+y}function t(y){try{e(y);var U=!1}catch{U=!0}if(U){U=console;var H=U.error,Y=typeof Symbol=="function"&&Symbol.toStringTag&&y[Symbol.toStringTag]||y.constructor.name||"Object";return H.call(U,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Y),e(y)}}function n(y){if(y===E)return"<>";if(typeof y=="object"&&y!==null&&y.$$typeof===L)return"<...>";try{var U=i(y);return U?"<"+U+">":"<...>"}catch{return"<...>"}}function o(){var y=Pe.A;return y===null?null:y.getOwner()}function l(){return Error("react-stack-top-frame")}function a(y){if($e.call(y,"key")){var U=Object.getOwnPropertyDescriptor(y,"key").get;if(U&&U.isReactWarning)return!1}return y.key!==void 0}function u(y,U){function H(){Ji||(Ji=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",U))}H.isReactWarning=!0,Object.defineProperty(y,"key",{get:H,configurable:!0})}function d(){var y=i(this.type);return Wi[y]||(Wi[y]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),y=this.props.ref,y!==void 0?y:null}function c(y,U,H,Y,at,Vt){var z=H.ref;return y={$$typeof:g,type:y,key:U,props:H,_owner:Y},(z!==void 0?z:null)!==null?Object.defineProperty(y,"ref",{enumerable:!1,get:d}):Object.defineProperty(y,"ref",{enumerable:!1,value:null}),y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(y,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(y,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:at}),Object.defineProperty(y,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Vt}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y}function f(y,U,H,Y,at,Vt){var z=U.children;if(z!==void 0)if(Y)if(ne(z)){for(Y=0;Y<z.length;Y++)p(z[Y]);Object.freeze&&Object.freeze(z)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(z);if($e.call(U,"key")){z=i(y);var ke=Object.keys(U).filter(function(zf){return zf!=="key"});Y=0<ke.length?"{key: someKey, "+ke.join(": ..., ")+": ...}":"{key: someKey}",Zi[z+Y]||(ke=0<ke.length?"{"+ke.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,Y,z,ke,z),Zi[z+Y]=!0)}if(z=null,H!==void 0&&(t(H),z=""+H),a(U)&&(t(U.key),z=""+U.key),"key"in U){H={};for(var Ft in U)Ft!=="key"&&(H[Ft]=U[Ft])}else H=U;return z&&u(H,typeof y=="function"?y.displayName||y.name||"Unknown":y),c(y,z,H,o(),at,Vt)}function p(y){m(y)?y._store&&(y._store.validated=1):typeof y=="object"&&y!==null&&y.$$typeof===L&&(y._payload.status==="fulfilled"?m(y._payload.value)&&y._payload.value._store&&(y._payload.value._store.validated=1):y._store&&(y._store.validated=1))}function m(y){return typeof y=="object"&&y!==null&&y.$$typeof===g}var h=J,g=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),F=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),Pe=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$e=Object.prototype.hasOwnProperty,ne=Array.isArray,ye=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(y){return y()}};var Ji,Wi={},Yi=h.react_stack_bottom_frame.bind(h,l)(),zi=ye(n(l)),Zi={};Le.Fragment=E,Le.jsx=function(y,U,H){var Y=1e4>Pe.recentlyCreatedOwnerStacks++;return f(y,U,H,!1,Y?Error("react-stack-top-frame"):Yi,Y?ye(n(y)):zi)},Le.jsxs=function(y,U,H){var Y=1e4>Pe.recentlyCreatedOwnerStacks++;return f(y,U,H,!0,Y?Error("react-stack-top-frame"):Yi,Y?ye(n(y)):zi)}})()),Le}var Gt;function Qi(){return Gt||(Gt=1,process.env.NODE_ENV==="production"?Oe.exports=Ki():Oe.exports=Xi()),Oe.exports}var C=Qi();/**
|
|
23
|
+
* @license lucide-react v0.460.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const ji=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Bt=(...i)=>i.filter((e,t,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===t).join(" ").trim();/**
|
|
28
|
+
* @license lucide-react v0.460.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/var eo={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
33
|
+
* @license lucide-react v0.460.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const to=J.forwardRef(({color:i="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:o="",children:l,iconNode:a,...u},d)=>J.createElement("svg",{ref:d,...eo,width:e,height:e,stroke:i,strokeWidth:n?Number(t)*24/Number(e):t,className:Bt("lucide",o),...u},[...a.map(([c,f])=>J.createElement(c,f)),...Array.isArray(l)?l:[l]]));/**
|
|
38
|
+
* @license lucide-react v0.460.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const Z=(i,e)=>{const t=J.forwardRef(({className:n,...o},l)=>J.createElement(to,{ref:l,iconNode:e,className:Bt(`lucide-${ji(i)}`,n),...o}));return t.displayName=`${i}`,t};/**
|
|
43
|
+
* @license lucide-react v0.460.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const no=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
48
|
+
* @license lucide-react v0.460.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const io=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/**
|
|
53
|
+
* @license lucide-react v0.460.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const oo=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
58
|
+
* @license lucide-react v0.460.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const He=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
63
|
+
* @license lucide-react v0.460.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const ro=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
68
|
+
* @license lucide-react v0.460.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const so=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
73
|
+
* @license lucide-react v0.460.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const lo=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
78
|
+
* @license lucide-react v0.460.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const ao=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/**
|
|
83
|
+
* @license lucide-react v0.460.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const uo=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
|
|
88
|
+
* @license lucide-react v0.460.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const co=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
93
|
+
* @license lucide-react v0.460.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const qt=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
|
98
|
+
* @license lucide-react v0.460.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const fo=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
103
|
+
* @license lucide-react v0.460.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const po=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
108
|
+
* @license lucide-react v0.460.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const mo=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
113
|
+
* @license lucide-react v0.460.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const ho=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);var G;(function(i){i.assertEqual=o=>{};function e(o){}i.assertIs=e;function t(o){throw new Error}i.assertNever=t,i.arrayToEnum=o=>{const l={};for(const a of o)l[a]=a;return l},i.getValidEnumValues=o=>{const l=i.objectKeys(o).filter(u=>typeof o[o[u]]!="number"),a={};for(const u of l)a[u]=o[u];return i.objectValues(a)},i.objectValues=o=>i.objectKeys(o).map(function(l){return o[l]}),i.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const l=[];for(const a in o)Object.prototype.hasOwnProperty.call(o,a)&&l.push(a);return l},i.find=(o,l)=>{for(const a of o)if(l(a))return a},i.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,l=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(l)}i.joinValues=n,i.jsonStringifyReplacer=(o,l)=>typeof l=="bigint"?l.toString():l})(G||(G={}));var $t;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})($t||($t={}));const S=G.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),le=i=>{switch(typeof i){case"undefined":return S.undefined;case"string":return S.string;case"number":return Number.isNaN(i)?S.nan:S.number;case"boolean":return S.boolean;case"function":return S.function;case"bigint":return S.bigint;case"symbol":return S.symbol;case"object":return Array.isArray(i)?S.array:i===null?S.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?S.promise:typeof Map<"u"&&i instanceof Map?S.map:typeof Set<"u"&&i instanceof Set?S.set:typeof Date<"u"&&i instanceof Date?S.date:S.object;default:return S.unknown}},T=G.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 se extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(l){return l.message},n={_errors:[]},o=l=>{for(const a of l.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(t(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(t(a))):u[c]=u[c]||{_errors:[]},u=u[c],d++}}};return o(this),n}static assert(e){if(!(e instanceof se))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,G.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const o of this.issues)if(o.path.length>0){const l=o.path[0];t[l]=t[l]||[],t[l].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}se.create=i=>new se(i);const ut=(i,e)=>{let t;switch(i.code){case T.invalid_type:i.received===S.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case T.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,G.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:t=`Unrecognized key(s) in object: ${G.joinValues(i.keys,", ")}`;break;case T.invalid_union:t="Invalid input";break;case T.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${G.joinValues(i.options)}`;break;case T.invalid_enum_value:t=`Invalid enum value. Expected ${G.joinValues(i.options)}, received '${i.received}'`;break;case T.invalid_arguments:t="Invalid function arguments";break;case T.invalid_return_type:t="Invalid function return type";break;case T.invalid_date:t="Invalid date";break;case T.invalid_string:typeof i.validation=="object"?"includes"in i.validation?(t=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${i.validation.position}`)):"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:G.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case T.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="bigint"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`:t="Invalid input";break;case T.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="bigint"?t=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`:t="Invalid input";break;case T.custom:t="Invalid input";break;case T.invalid_intersection_types:t="Intersection results could not be merged";break;case T.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case T.not_finite:t="Number must be finite";break;default:t=e.defaultError,G.assertNever(i)}return{message:t}};let go=ut;function yo(){return go}const vo=i=>{const{data:e,path:t,errorMaps:n,issueData:o}=i,l=[...t,...o.path||[]],a={...o,path:l};if(o.message!==void 0)return{...o,path:l,message:o.message};let u="";const d=n.filter(c=>!!c).slice().reverse();for(const c of d)u=c(a,{data:e,defaultError:u}).message;return{...o,path:l,message:u}};function _(i,e){const t=yo(),n=vo({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,t,t===ut?void 0:ut].filter(o=>!!o)});i.common.issues.push(n)}class K{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const o of t){if(o.status==="aborted")return D;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const o of t){const l=await o.key,a=await o.value;n.push({key:l,value:a})}return K.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const o of t){const{key:l,value:a}=o;if(l.status==="aborted"||a.status==="aborted")return D;l.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),l.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[l.value]=a.value)}return{status:e.value,value:n}}}const D=Object.freeze({status:"aborted"}),Ve=i=>({status:"dirty",value:i}),j=i=>({status:"valid",value:i}),Ot=i=>i.status==="aborted",Ht=i=>i.status==="dirty",ve=i=>i.status==="valid",Je=i=>typeof Promise<"u"&&i instanceof Promise;var A;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(A||(A={}));class ie{constructor(e,t,n,o){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=o}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 Jt=(i,e)=>{if(ve(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new se(i.common.issues);return this._error=t,this._error}}};function V(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:o}=i;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(a,u)=>{const{message:d}=i;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??t??u.defaultError}},description:o}}class b{get description(){return this._def.description}_getType(e){return le(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:le(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new K,ctx:{common:e.parent.common,data:e.data,parsedType:le(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Je(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:le(e)},o=this._parseSync({data:e,path:n.path,parent:n});return Jt(n,o)}"~validate"(e){var n,o;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:le(e)};if(!this["~standard"].async)try{const l=this._parseSync({data:e,path:[],parent:t});return ve(l)?{value:l.value}:{issues:t.common.issues}}catch(l){(o=(n=l==null?void 0:l.message)==null?void 0:n.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(l=>ve(l)?{value:l.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:le(e)},o=this._parse({data:e,path:n.path,parent:n}),l=await(Je(o)?o:Promise.resolve(o));return Jt(n,l)}refine(e,t){const n=o=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(o):t;return this._refinement((o,l)=>{const a=e(o),u=()=>l.addIssue({code:T.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(d=>d?!0:(u(),!1)):a?!0:(u(),!1)})}refinement(e,t){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof t=="function"?t(n,o):t),!1))}_refinement(e){return new Ee({schema:this,typeName:P.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:t=>this["~validate"](t)}}optional(){return ue.create(this,this._def)}nullable(){return xe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this)}promise(){return Ke.create(this,this._def)}or(e){return Ye.create([this,e],this._def)}and(e){return ze.create(this,e,this._def)}transform(e){return new Ee({...V(this._def),schema:this,typeName:P.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new mt({...V(this._def),innerType:this,defaultValue:t,typeName:P.ZodDefault})}brand(){return new qo({typeName:P.ZodBranded,type:this,...V(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ht({...V(this._def),innerType:this,catchValue:t,typeName:P.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return gt.create(this,e)}readonly(){return yt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const To=/^c[^\s-]{8,}$/i,Co=/^[0-9a-z]+$/,_o=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Eo=/^[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,xo=/^[a-z0-9_-]{21}$/i,So=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ao=/^[-+]?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)?)??$/,Mo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Io="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ct;const Ro=/^(?:(?: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])$/,wo=/^(?:(?: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])$/,No=/^(([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]))$/,Po=/^(([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])$/,ko=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Do=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Wt="((\\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])))",Lo=new RegExp(`^${Wt}$`);function Yt(i){let e="[0-5]\\d";i.precision?e=`${e}\\.\\d{${i.precision}}`:i.precision==null&&(e=`${e}(\\.\\d+)?`);const t=i.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Vo(i){return new RegExp(`^${Yt(i)}$`)}function Fo(i){let e=`${Wt}T${Yt(i)}`;const t=[];return t.push(i.local?"Z?":"Z"),i.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Uo(i,e){return!!((e==="v4"||!e)&&Ro.test(i)||(e==="v6"||!e)&&No.test(i))}function bo(i,e){if(!So.test(i))return!1;try{const[t]=i.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function Go(i,e){return!!((e==="v4"||!e)&&wo.test(i)||(e==="v6"||!e)&&Po.test(i))}class oe extends b{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==S.string){const l=this._getOrReturnCtx(e);return _(l,{code:T.invalid_type,expected:S.string,received:l.parsedType}),D}const n=new K;let o;for(const l of this._def.checks)if(l.kind==="min")e.data.length<l.value&&(o=this._getOrReturnCtx(e,o),_(o,{code:T.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),n.dirty());else if(l.kind==="max")e.data.length>l.value&&(o=this._getOrReturnCtx(e,o),_(o,{code:T.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),n.dirty());else if(l.kind==="length"){const a=e.data.length>l.value,u=e.data.length<l.value;(a||u)&&(o=this._getOrReturnCtx(e,o),a?_(o,{code:T.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):u&&_(o,{code:T.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),n.dirty())}else if(l.kind==="email")Mo.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"email",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="emoji")ct||(ct=new RegExp(Io,"u")),ct.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"emoji",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="uuid")Eo.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"uuid",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="nanoid")xo.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"nanoid",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="cuid")To.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"cuid",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="cuid2")Co.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"cuid2",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="ulid")_o.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"ulid",code:T.invalid_string,message:l.message}),n.dirty());else if(l.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),_(o,{validation:"url",code:T.invalid_string,message:l.message}),n.dirty()}else l.kind==="regex"?(l.regex.lastIndex=0,l.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"regex",code:T.invalid_string,message:l.message}),n.dirty())):l.kind==="trim"?e.data=e.data.trim():l.kind==="includes"?e.data.includes(l.value,l.position)||(o=this._getOrReturnCtx(e,o),_(o,{code:T.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),n.dirty()):l.kind==="toLowerCase"?e.data=e.data.toLowerCase():l.kind==="toUpperCase"?e.data=e.data.toUpperCase():l.kind==="startsWith"?e.data.startsWith(l.value)||(o=this._getOrReturnCtx(e,o),_(o,{code:T.invalid_string,validation:{startsWith:l.value},message:l.message}),n.dirty()):l.kind==="endsWith"?e.data.endsWith(l.value)||(o=this._getOrReturnCtx(e,o),_(o,{code:T.invalid_string,validation:{endsWith:l.value},message:l.message}),n.dirty()):l.kind==="datetime"?Fo(l).test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{code:T.invalid_string,validation:"datetime",message:l.message}),n.dirty()):l.kind==="date"?Lo.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{code:T.invalid_string,validation:"date",message:l.message}),n.dirty()):l.kind==="time"?Vo(l).test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{code:T.invalid_string,validation:"time",message:l.message}),n.dirty()):l.kind==="duration"?Ao.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"duration",code:T.invalid_string,message:l.message}),n.dirty()):l.kind==="ip"?Uo(e.data,l.version)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"ip",code:T.invalid_string,message:l.message}),n.dirty()):l.kind==="jwt"?bo(e.data,l.alg)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"jwt",code:T.invalid_string,message:l.message}),n.dirty()):l.kind==="cidr"?Go(e.data,l.version)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"cidr",code:T.invalid_string,message:l.message}),n.dirty()):l.kind==="base64"?ko.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"base64",code:T.invalid_string,message:l.message}),n.dirty()):l.kind==="base64url"?Do.test(e.data)||(o=this._getOrReturnCtx(e,o),_(o,{validation:"base64url",code:T.invalid_string,message:l.message}),n.dirty()):G.assertNever(l);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(o=>e.test(o),{validation:t,code:T.invalid_string,...A.errToObj(n)})}_addCheck(e){return new oe({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...A.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...A.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...A.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...A.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...A.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...A.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...A.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new oe({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new oe({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new oe({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}oe.create=i=>new oe({checks:[],typeName:P.ZodString,coerce:(i==null?void 0:i.coerce)??!1,...V(i)});function Bo(i,e){const t=(i.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=t>n?t:n,l=Number.parseInt(i.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return l%a/10**o}class pe extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==S.number){const l=this._getOrReturnCtx(e);return _(l,{code:T.invalid_type,expected:S.number,received:l.parsedType}),D}let n;const o=new K;for(const l of this._def.checks)l.kind==="int"?G.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:T.invalid_type,expected:"integer",received:"float",message:l.message}),o.dirty()):l.kind==="min"?(l.inclusive?e.data<l.value:e.data<=l.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:T.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),o.dirty()):l.kind==="max"?(l.inclusive?e.data>l.value:e.data>=l.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:T.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),o.dirty()):l.kind==="multipleOf"?Bo(e.data,l.value)!==0&&(n=this._getOrReturnCtx(e,n),_(n,{code:T.not_multiple_of,multipleOf:l.value,message:l.message}),o.dirty()):l.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:T.not_finite,message:l.message}),o.dirty()):G.assertNever(l);return{status:o.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,n,o){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:A.toString(o)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&G.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}pe.create=i=>new pe({checks:[],typeName:P.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...V(i)});class me extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==S.bigint)return this._getInvalidInput(e);let n;const o=new K;for(const l of this._def.checks)l.kind==="min"?(l.inclusive?e.data<l.value:e.data<=l.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:T.too_small,type:"bigint",minimum:l.value,inclusive:l.inclusive,message:l.message}),o.dirty()):l.kind==="max"?(l.inclusive?e.data>l.value:e.data>=l.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:T.too_big,type:"bigint",maximum:l.value,inclusive:l.inclusive,message:l.message}),o.dirty()):l.kind==="multipleOf"?e.data%l.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),_(n,{code:T.not_multiple_of,multipleOf:l.value,message:l.message}),o.dirty()):G.assertNever(l);return{status:o.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return _(t,{code:T.invalid_type,expected:S.bigint,received:t.parsedType}),D}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,n,o){return new me({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:A.toString(o)}]})}_addCheck(e){return new me({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}me.create=i=>new me({checks:[],typeName:P.ZodBigInt,coerce:(i==null?void 0:i.coerce)??!1,...V(i)});class We extends b{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==S.boolean){const n=this._getOrReturnCtx(e);return _(n,{code:T.invalid_type,expected:S.boolean,received:n.parsedType}),D}return j(e.data)}}We.create=i=>new We({typeName:P.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...V(i)});class Te extends b{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==S.date){const l=this._getOrReturnCtx(e);return _(l,{code:T.invalid_type,expected:S.date,received:l.parsedType}),D}if(Number.isNaN(e.data.getTime())){const l=this._getOrReturnCtx(e);return _(l,{code:T.invalid_date}),D}const n=new K;let o;for(const l of this._def.checks)l.kind==="min"?e.data.getTime()<l.value&&(o=this._getOrReturnCtx(e,o),_(o,{code:T.too_small,message:l.message,inclusive:!0,exact:!1,minimum:l.value,type:"date"}),n.dirty()):l.kind==="max"?e.data.getTime()>l.value&&(o=this._getOrReturnCtx(e,o),_(o,{code:T.too_big,message:l.message,inclusive:!0,exact:!1,maximum:l.value,type:"date"}),n.dirty()):G.assertNever(l);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Te({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Te.create=i=>new Te({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:P.ZodDate,...V(i)});class zt extends b{_parse(e){if(this._getType(e)!==S.symbol){const n=this._getOrReturnCtx(e);return _(n,{code:T.invalid_type,expected:S.symbol,received:n.parsedType}),D}return j(e.data)}}zt.create=i=>new zt({typeName:P.ZodSymbol,...V(i)});class Zt extends b{_parse(e){if(this._getType(e)!==S.undefined){const n=this._getOrReturnCtx(e);return _(n,{code:T.invalid_type,expected:S.undefined,received:n.parsedType}),D}return j(e.data)}}Zt.create=i=>new Zt({typeName:P.ZodUndefined,...V(i)});class Kt extends b{_parse(e){if(this._getType(e)!==S.null){const n=this._getOrReturnCtx(e);return _(n,{code:T.invalid_type,expected:S.null,received:n.parsedType}),D}return j(e.data)}}Kt.create=i=>new Kt({typeName:P.ZodNull,...V(i)});class Xt extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}Xt.create=i=>new Xt({typeName:P.ZodAny,...V(i)});class dt extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}dt.create=i=>new dt({typeName:P.ZodUnknown,...V(i)});class ae extends b{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:T.invalid_type,expected:S.never,received:t.parsedType}),D}}ae.create=i=>new ae({typeName:P.ZodNever,...V(i)});class Qt extends b{_parse(e){if(this._getType(e)!==S.undefined){const n=this._getOrReturnCtx(e);return _(n,{code:T.invalid_type,expected:S.void,received:n.parsedType}),D}return j(e.data)}}Qt.create=i=>new Qt({typeName:P.ZodVoid,...V(i)});class re extends b{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),o=this._def;if(t.parsedType!==S.array)return _(t,{code:T.invalid_type,expected:S.array,received:t.parsedType}),D;if(o.exactLength!==null){const a=t.data.length>o.exactLength.value,u=t.data.length<o.exactLength.value;(a||u)&&(_(t,{code:a?T.too_big:T.too_small,minimum:u?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&t.data.length<o.minLength.value&&(_(t,{code:T.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&t.data.length>o.maxLength.value&&(_(t,{code:T.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,u)=>o.type._parseAsync(new ie(t,a,t.path,u)))).then(a=>K.mergeArray(n,a));const l=[...t.data].map((a,u)=>o.type._parseSync(new ie(t,a,t.path,u)));return K.mergeArray(n,l)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}}re.create=(i,e)=>new re({type:i,minLength:null,maxLength:null,exactLength:null,typeName:P.ZodArray,...V(e)});function Ce(i){if(i instanceof W){const e={};for(const t in i.shape){const n=i.shape[t];e[t]=ue.create(Ce(n))}return new W({...i._def,shape:()=>e})}else return i instanceof re?new re({...i._def,type:Ce(i.element)}):i instanceof ue?ue.create(Ce(i.unwrap())):i instanceof xe?xe.create(Ce(i.unwrap())):i instanceof he?he.create(i.items.map(e=>Ce(e))):i}class W extends b{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=G.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==S.object){const c=this._getOrReturnCtx(e);return _(c,{code:T.invalid_type,expected:S.object,received:c.parsedType}),D}const{status:n,ctx:o}=this._processInputParams(e),{shape:l,keys:a}=this._getCached(),u=[];if(!(this._def.catchall instanceof ae&&this._def.unknownKeys==="strip"))for(const c in o.data)a.includes(c)||u.push(c);const d=[];for(const c of a){const f=l[c],p=o.data[c];d.push({key:{status:"valid",value:c},value:f._parse(new ie(o,p,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof ae){const c=this._def.unknownKeys;if(c==="passthrough")for(const f of u)d.push({key:{status:"valid",value:f},value:{status:"valid",value:o.data[f]}});else if(c==="strict")u.length>0&&(_(o,{code:T.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=o.data[f];d.push({key:{status:"valid",value:f},value:c._parse(new ie(o,p,o.path,f)),alwaysSet:f in o.data})}}return o.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=>K.mergeObjectSync(n,c)):K.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new W({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var l,a;const o=((a=(l=this._def).errorMap)==null?void 0:a.call(l,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:A.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new W({...this._def,unknownKeys:"strip"})}passthrough(){return new W({...this._def,unknownKeys:"passthrough"})}extend(e){return new W({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new W({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:P.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new W({...this._def,catchall:e})}pick(e){const t={};for(const n of G.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new W({...this._def,shape:()=>t})}omit(e){const t={};for(const n of G.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new W({...this._def,shape:()=>t})}deepPartial(){return Ce(this)}partial(e){const t={};for(const n of G.objectKeys(this.shape)){const o=this.shape[n];e&&!e[n]?t[n]=o:t[n]=o.optional()}return new W({...this._def,shape:()=>t})}required(e){const t={};for(const n of G.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let l=this.shape[n];for(;l instanceof ue;)l=l._def.innerType;t[n]=l}return new W({...this._def,shape:()=>t})}keyof(){return tn(G.objectKeys(this.shape))}}W.create=(i,e)=>new W({shape:()=>i,unknownKeys:"strip",catchall:ae.create(),typeName:P.ZodObject,...V(e)}),W.strictCreate=(i,e)=>new W({shape:()=>i,unknownKeys:"strict",catchall:ae.create(),typeName:P.ZodObject,...V(e)}),W.lazycreate=(i,e)=>new W({shape:i,unknownKeys:"strip",catchall:ae.create(),typeName:P.ZodObject,...V(e)});class Ye extends b{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function o(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 t.common.issues.push(...u.ctx.common.issues),u.result;const a=l.map(u=>new se(u.ctx.common.issues));return _(t,{code:T.invalid_union,unionErrors:a}),D}if(t.common.async)return Promise.all(n.map(async l=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await l._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(o);{let l;const a=[];for(const d of n){const c={...t,common:{...t.common,issues:[]},parent:null},f=d._parseSync({data:t.data,path:t.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 t.common.issues.push(...l.ctx.common.issues),l.result;const u=a.map(d=>new se(d));return _(t,{code:T.invalid_union,unionErrors:u}),D}}get options(){return this._def.options}}Ye.create=(i,e)=>new Ye({options:i,typeName:P.ZodUnion,...V(e)});function ft(i,e){const t=le(i),n=le(e);if(i===e)return{valid:!0,data:i};if(t===S.object&&n===S.object){const o=G.objectKeys(e),l=G.objectKeys(i).filter(u=>o.indexOf(u)!==-1),a={...i,...e};for(const u of l){const d=ft(i[u],e[u]);if(!d.valid)return{valid:!1};a[u]=d.data}return{valid:!0,data:a}}else if(t===S.array&&n===S.array){if(i.length!==e.length)return{valid:!1};const o=[];for(let l=0;l<i.length;l++){const a=i[l],u=e[l],d=ft(a,u);if(!d.valid)return{valid:!1};o.push(d.data)}return{valid:!0,data:o}}else return t===S.date&&n===S.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class ze extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),o=(l,a)=>{if(Ot(l)||Ot(a))return D;const u=ft(l.value,a.value);return u.valid?((Ht(l)||Ht(a))&&t.dirty(),{status:t.value,value:u.data}):(_(n,{code:T.invalid_intersection_types}),D)};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])=>o(l,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ze.create=(i,e,t)=>new ze({left:i,right:e,typeName:P.ZodIntersection,...V(t)});class he extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==S.array)return _(n,{code:T.invalid_type,expected:S.array,received:n.parsedType}),D;if(n.data.length<this._def.items.length)return _(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&n.data.length>this._def.items.length&&(_(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const l=[...n.data].map((a,u)=>{const d=this._def.items[u]||this._def.rest;return d?d._parse(new ie(n,a,n.path,u)):null}).filter(a=>!!a);return n.common.async?Promise.all(l).then(a=>K.mergeArray(t,a)):K.mergeArray(t,l)}get items(){return this._def.items}rest(e){return new he({...this._def,rest:e})}}he.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new he({items:i,typeName:P.ZodTuple,rest:null,...V(e)})};class Ze extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==S.object)return _(n,{code:T.invalid_type,expected:S.object,received:n.parsedType}),D;const o=[],l=this._def.keyType,a=this._def.valueType;for(const u in n.data)o.push({key:l._parse(new ie(n,u,n.path,u)),value:a._parse(new ie(n,n.data[u],n.path,u)),alwaysSet:u in n.data});return n.common.async?K.mergeObjectAsync(t,o):K.mergeObjectSync(t,o)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof b?new Ze({keyType:e,valueType:t,typeName:P.ZodRecord,...V(n)}):new Ze({keyType:oe.create(),valueType:e,typeName:P.ZodRecord,...V(t)})}}class jt extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==S.map)return _(n,{code:T.invalid_type,expected:S.map,received:n.parsedType}),D;const o=this._def.keyType,l=this._def.valueType,a=[...n.data.entries()].map(([u,d],c)=>({key:o._parse(new ie(n,u,n.path,[c,"key"])),value:l._parse(new ie(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 D;(c.status==="dirty"||f.status==="dirty")&&t.dirty(),u.set(c.value,f.value)}return{status:t.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 D;(c.status==="dirty"||f.status==="dirty")&&t.dirty(),u.set(c.value,f.value)}return{status:t.value,value:u}}}}jt.create=(i,e,t)=>new jt({valueType:e,keyType:i,typeName:P.ZodMap,...V(t)});class Fe extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==S.set)return _(n,{code:T.invalid_type,expected:S.set,received:n.parsedType}),D;const o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(_(n,{code:T.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),t.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(_(n,{code:T.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),t.dirty());const l=this._def.valueType;function a(d){const c=new Set;for(const f of d){if(f.status==="aborted")return D;f.status==="dirty"&&t.dirty(),c.add(f.value)}return{status:t.value,value:c}}const u=[...n.data.values()].map((d,c)=>l._parse(new ie(n,d,n.path,c)));return n.common.async?Promise.all(u).then(d=>a(d)):a(u)}min(e,t){return new Fe({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new Fe({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Fe.create=(i,e)=>new Fe({valueType:i,minSize:null,maxSize:null,typeName:P.ZodSet,...V(e)});class pt extends b{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}pt.create=(i,e)=>new pt({getter:i,typeName:P.ZodLazy,...V(e)});class en extends b{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:T.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}}en.create=(i,e)=>new en({value:i,typeName:P.ZodLiteral,...V(e)});function tn(i,e){return new _e({values:i,typeName:P.ZodEnum,...V(e)})}class _e extends b{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{expected:G.joinValues(n),received:t.parsedType,code:T.invalid_type}),D}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{received:t.data,code:T.invalid_enum_value,options:n}),D}return j(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _e.create(e,{...this._def,...t})}exclude(e,t=this._def){return _e.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}_e.create=tn;class nn extends b{_parse(e){const t=G.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==S.string&&n.parsedType!==S.number){const o=G.objectValues(t);return _(n,{expected:G.joinValues(o),received:n.parsedType,code:T.invalid_type}),D}if(this._cache||(this._cache=new Set(G.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const o=G.objectValues(t);return _(n,{received:n.data,code:T.invalid_enum_value,options:o}),D}return j(e.data)}get enum(){return this._def.values}}nn.create=(i,e)=>new nn({values:i,typeName:P.ZodNativeEnum,...V(e)});class Ke extends b{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==S.promise&&t.common.async===!1)return _(t,{code:T.invalid_type,expected:S.promise,received:t.parsedType}),D;const n=t.parsedType===S.promise?t.data:Promise.resolve(t.data);return j(n.then(o=>this._def.type.parseAsync(o,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ke.create=(i,e)=>new Ke({type:i,typeName:P.ZodPromise,...V(e)});class Ee extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===P.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),o=this._def.effect||null,l={addIssue:a=>{_(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(l.addIssue=l.addIssue.bind(l),o.type==="preprocess"){const a=o.transform(n.data,l);if(n.common.async)return Promise.resolve(a).then(async u=>{if(t.value==="aborted")return D;const d=await this._def.schema._parseAsync({data:u,path:n.path,parent:n});return d.status==="aborted"?D:d.status==="dirty"||t.value==="dirty"?Ve(d.value):d});{if(t.value==="aborted")return D;const u=this._def.schema._parseSync({data:a,path:n.path,parent:n});return u.status==="aborted"?D:u.status==="dirty"||t.value==="dirty"?Ve(u.value):u}}if(o.type==="refinement"){const a=u=>{const d=o.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"?D:(u.status==="dirty"&&t.dirty(),a(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?D:(u.status==="dirty"&&t.dirty(),a(u.value).then(()=>({status:t.value,value:u.value}))))}if(o.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ve(a))return D;const u=o.transform(a.value,l);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ve(a)?Promise.resolve(o.transform(a.value,l)).then(u=>({status:t.value,value:u})):D);G.assertNever(o)}}Ee.create=(i,e,t)=>new Ee({schema:i,typeName:P.ZodEffects,effect:e,...V(t)}),Ee.createWithPreprocess=(i,e,t)=>new Ee({schema:e,effect:{type:"preprocess",transform:i},typeName:P.ZodEffects,...V(t)});class ue extends b{_parse(e){return this._getType(e)===S.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ue.create=(i,e)=>new ue({innerType:i,typeName:P.ZodOptional,...V(e)});class xe extends b{_parse(e){return this._getType(e)===S.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xe.create=(i,e)=>new xe({innerType:i,typeName:P.ZodNullable,...V(e)});class mt extends b{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===S.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}mt.create=(i,e)=>new mt({innerType:i,typeName:P.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...V(e)});class ht extends b{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Je(o)?o.then(l=>({status:"valid",value:l.status==="valid"?l.value:this._def.catchValue({get error(){return new se(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new se(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ht.create=(i,e)=>new ht({innerType:i,typeName:P.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...V(e)});class on extends b{_parse(e){if(this._getType(e)!==S.nan){const n=this._getOrReturnCtx(e);return _(n,{code:T.invalid_type,expected:S.nan,received:n.parsedType}),D}return{status:"valid",value:e.data}}}on.create=i=>new on({typeName:P.ZodNaN,...V(i)});class qo extends b{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class gt extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);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"?D:l.status==="dirty"?(t.dirty(),Ve(l.value)):this._def.out._parseAsync({data:l.value,path:n.path,parent:n})})();{const o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?D:o.status==="dirty"?(t.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,t){return new gt({in:e,out:t,typeName:P.ZodPipeline})}}class yt extends b{_parse(e){const t=this._def.innerType._parse(e),n=o=>(ve(o)&&(o.value=Object.freeze(o.value)),o);return Je(t)?t.then(o=>n(o)):n(t)}unwrap(){return this._def.innerType}}yt.create=(i,e)=>new yt({innerType:i,typeName:P.ZodReadonly,...V(e)});var P;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(P||(P={}));const ge=oe.create,rn=pe.create;me.create;const $o=We.create;Te.create;const sn=dt.create;ae.create;const Ue=re.create,Oo=W.create,Ho=Ye.create;ze.create,he.create;const Jo=Ze.create,Wo=pt.create,Yo=_e.create;Ke.create,ue.create,xe.create;const Se={string:(i=>oe.create({...i,coerce:!0})),number:(i=>pe.create({...i,coerce:!0})),boolean:(i=>We.create({...i,coerce:!0})),bigint:(i=>me.create({...i,coerce:!0})),date:(i=>Te.create({...i,coerce:!0}))};/**
|
|
118
|
+
* @license
|
|
119
|
+
* Copyright 2025 Google LLC
|
|
120
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
121
|
+
*/let zo,Zo;function Ko(){return{geminiUrl:zo,vertexUrl:Zo}}function Xo(i,e,t){var n,o,l;if(!(!((n=i.httpOptions)===null||n===void 0)&&n.baseUrl)){const a=Ko();return i.vertexai?(o=a.vertexUrl)!==null&&o!==void 0?o:e:(l=a.geminiUrl)!==null&&l!==void 0?l:t}return i.httpOptions.baseUrl}/**
|
|
122
|
+
* @license
|
|
123
|
+
* Copyright 2025 Google LLC
|
|
124
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
125
|
+
*/class Ae{}function R(i,e){const t=/\{([^}]+)\}/g;return i.replace(t,(n,o)=>{if(Object.prototype.hasOwnProperty.call(e,o)){const l=e[o];return l!=null?String(l):""}else throw new Error(`Key '${o}' not found in valueMap.`)})}function s(i,e,t){for(let l=0;l<e.length-1;l++){const a=e[l];if(a.endsWith("[]")){const u=a.slice(0,-2);if(!(u in i))if(Array.isArray(t))i[u]=Array.from({length:t.length},()=>({}));else throw new Error(`Value must be a list given an array path ${a}`);if(Array.isArray(i[u])){const d=i[u];if(Array.isArray(t))for(let c=0;c<d.length;c++){const f=d[c];s(f,e.slice(l+1),t[c])}else for(const c of d)s(c,e.slice(l+1),t)}return}else if(a.endsWith("[0]")){const u=a.slice(0,-3);u in i||(i[u]=[{}]);const d=i[u];s(d[0],e.slice(l+1),t);return}(!i[a]||typeof i[a]!="object")&&(i[a]={}),i=i[a]}const n=e[e.length-1],o=i[n];if(o!==void 0){if(!t||typeof t=="object"&&Object.keys(t).length===0||t===o)return;if(typeof o=="object"&&typeof t=="object"&&o!==null&&t!==null)Object.assign(o,t);else throw new Error(`Cannot set value for an existing key. Key: ${n}`)}else i[n]=t}function r(i,e){try{if(e.length===1&&e[0]==="_self")return i;for(let t=0;t<e.length;t++){if(typeof i!="object"||i===null)return;const n=e[t];if(n.endsWith("[]")){const o=n.slice(0,-2);if(o in i){const l=i[o];return Array.isArray(l)?l.map(a=>r(a,e.slice(t+1))):void 0}else return}else i=i[n]}return i}catch(t){if(t instanceof TypeError)return;throw t}}/**
|
|
126
|
+
* @license
|
|
127
|
+
* Copyright 2025 Google LLC
|
|
128
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
129
|
+
*/var ln;(function(i){i.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(ln||(ln={}));var an;(function(i){i.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",i.PYTHON="PYTHON"})(an||(an={}));var ee;(function(i){i.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL"})(ee||(ee={}));var un;(function(i){i.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",i.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",i.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",i.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",i.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",i.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(un||(un={}));var cn;(function(i){i.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",i.SEVERITY="SEVERITY",i.PROBABILITY="PROBABILITY"})(cn||(cn={}));var dn;(function(i){i.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE",i.OFF="OFF"})(dn||(dn={}));var fn;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(fn||(fn={}));var pn;(function(i){i.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",i.NO_AUTH="NO_AUTH",i.API_KEY_AUTH="API_KEY_AUTH",i.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",i.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",i.OAUTH="OAUTH",i.OIDC_AUTH="OIDC_AUTH"})(pn||(pn={}));var mn;(function(i){i.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",i.STOP="STOP",i.MAX_TOKENS="MAX_TOKENS",i.SAFETY="SAFETY",i.RECITATION="RECITATION",i.LANGUAGE="LANGUAGE",i.OTHER="OTHER",i.BLOCKLIST="BLOCKLIST",i.PROHIBITED_CONTENT="PROHIBITED_CONTENT",i.SPII="SPII",i.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",i.IMAGE_SAFETY="IMAGE_SAFETY",i.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL"})(mn||(mn={}));var hn;(function(i){i.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",i.NEGLIGIBLE="NEGLIGIBLE",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH"})(hn||(hn={}));var gn;(function(i){i.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",i.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",i.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",i.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",i.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(gn||(gn={}));var yn;(function(i){i.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",i.SAFETY="SAFETY",i.OTHER="OTHER",i.BLOCKLIST="BLOCKLIST",i.PROHIBITED_CONTENT="PROHIBITED_CONTENT"})(yn||(yn={}));var vn;(function(i){i.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",i.ON_DEMAND="ON_DEMAND",i.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(vn||(vn={}));var Xe;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.AUDIO="AUDIO"})(Xe||(Xe={}));var Tn;(function(i){i.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",i.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",i.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",i.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Tn||(Tn={}));var vt;(function(i){i.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",i.JOB_STATE_QUEUED="JOB_STATE_QUEUED",i.JOB_STATE_PENDING="JOB_STATE_PENDING",i.JOB_STATE_RUNNING="JOB_STATE_RUNNING",i.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",i.JOB_STATE_FAILED="JOB_STATE_FAILED",i.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",i.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",i.JOB_STATE_PAUSED="JOB_STATE_PAUSED",i.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",i.JOB_STATE_UPDATING="JOB_STATE_UPDATING",i.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(vt||(vt={}));var Cn;(function(i){i.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",i.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",i.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",i.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",i.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",i.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",i.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Cn||(Cn={}));var _n;(function(i){i.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",i.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",i.BALANCED="BALANCED",i.PRIORITIZE_COST="PRIORITIZE_COST"})(_n||(_n={}));var En;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.BLOCKING="BLOCKING",i.NON_BLOCKING="NON_BLOCKING"})(En||(En={}));var xn;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(xn||(xn={}));var Sn;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.AUTO="AUTO",i.ANY="ANY",i.NONE="NONE"})(Sn||(Sn={}));var An;(function(i){i.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",i.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",i.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR"})(An||(An={}));var Mn;(function(i){i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE"})(Mn||(Mn={}));var In;(function(i){i.DONT_ALLOW="DONT_ALLOW",i.ALLOW_ADULT="ALLOW_ADULT",i.ALLOW_ALL="ALLOW_ALL"})(In||(In={}));var Rn;(function(i){i.auto="auto",i.en="en",i.ja="ja",i.ko="ko",i.hi="hi"})(Rn||(Rn={}));var wn;(function(i){i.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",i.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",i.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",i.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",i.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(wn||(wn={}));var Nn;(function(i){i.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",i.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",i.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",i.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Nn||(Nn={}));var Pn;(function(i){i.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",i.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",i.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",i.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Pn||(Pn={}));var kn;(function(i){i.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",i.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",i.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",i.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",i.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",i.EDIT_MODE_STYLE="EDIT_MODE_STYLE",i.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",i.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(kn||(kn={}));var Dn;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.PROCESSING="PROCESSING",i.ACTIVE="ACTIVE",i.FAILED="FAILED"})(Dn||(Dn={}));var Ln;(function(i){i.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",i.UPLOADED="UPLOADED",i.GENERATED="GENERATED"})(Ln||(Ln={}));var Vn;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.VIDEO="VIDEO",i.AUDIO="AUDIO",i.DOCUMENT="DOCUMENT"})(Vn||(Vn={}));var Fn;(function(i){i.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",i.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",i.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Fn||(Fn={}));var Un;(function(i){i.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",i.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",i.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(Un||(Un={}));var bn;(function(i){i.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",i.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",i.NO_INTERRUPTION="NO_INTERRUPTION"})(bn||(bn={}));var Gn;(function(i){i.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",i.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",i.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(Gn||(Gn={}));var Bn;(function(i){i.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",i.SILENT="SILENT",i.WHEN_IDLE="WHEN_IDLE",i.INTERRUPT="INTERRUPT"})(Bn||(Bn={}));var qn;(function(i){i.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",i.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",i.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",i.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",i.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",i.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",i.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",i.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",i.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",i.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",i.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",i.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",i.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(qn||(qn={}));var Me;(function(i){i.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",i.PLAY="PLAY",i.PAUSE="PAUSE",i.STOP="STOP",i.RESET_CONTEXT="RESET_CONTEXT"})(Me||(Me={}));class be{get text(){var e,t,n,o,l,a,u,d;if(((o=(n=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||n===void 0?void 0:n.parts)===null||o===void 0?void 0:o.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 e,t,n,o,l,a,u,d;if(((o=(n=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||n===void 0?void 0:n.parts)===null||o===void 0?void 0:o.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 e,t,n,o,l,a,u,d;if(((o=(n=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||n===void 0?void 0:n.parts)===null||o===void 0?void 0:o.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==null?void 0:c.length)!==0)return c}get executableCode(){var e,t,n,o,l,a,u,d,c;if(((o=(n=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||n===void 0?void 0:n.parts)===null||o===void 0?void 0:o.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==null?void 0:f.length)!==0)return(c=f==null?void 0:f[0])===null||c===void 0?void 0:c.code}get codeExecutionResult(){var e,t,n,o,l,a,u,d,c;if(((o=(n=(t=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.content)===null||n===void 0?void 0:n.parts)===null||o===void 0?void 0:o.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==null?void 0:f.length)!==0)return(c=f==null?void 0:f[0])===null||c===void 0?void 0:c.output}}class $n{}class On{}class Qo{}class jo{}class Hn{}class Jn{}class Wn{}class er{}class Yn{}class zn{}class Zn{}class tr{}class Tt{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class nr{}class ir{}class or{get text(){var e,t,n;let o="",l=!1;const a=[];for(const u of(n=(t=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||t===void 0?void 0:t.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,o+=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?o:void 0}get data(){var e,t,n;let o="";const l=[];for(const a of(n=(t=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||t===void 0?void 0:t.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"&&(o+=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.`),o.length>0?btoa(o):void 0}}class rr{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}/**
|
|
130
|
+
* @license
|
|
131
|
+
* Copyright 2025 Google LLC
|
|
132
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
133
|
+
*/function q(i,e){if(!e||typeof e!="string")throw new Error("model is required and must be a string");if(i.isVertexAI()){if(e.startsWith("publishers/")||e.startsWith("projects/")||e.startsWith("models/"))return e;if(e.indexOf("/")>=0){const t=e.split("/",2);return`publishers/${t[0]}/models/${t[1]}`}else return`publishers/google/models/${e}`}else return e.startsWith("models/")||e.startsWith("tunedModels/")?e:`models/${e}`}function Kn(i,e){const t=q(i,e);return t?t.startsWith("publishers/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/${t}`:t.startsWith("models/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/publishers/google/${t}`:t:""}function Xn(i,e){return Array.isArray(e)?e.map(t=>Qe(i,t)):[Qe(i,e)]}function Qe(i,e){if(typeof e=="object"&&e!==null)return e;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function sr(i,e){const t=Qe(i,e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function lr(i,e){const t=Qe(i,e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function Qn(i,e){if(e==null)throw new Error("PartUnion is required");if(typeof e=="object")return e;if(typeof e=="string")return{text:e};throw new Error(`Unsupported part type: ${typeof e}`)}function jn(i,e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("PartListUnion is required");return Array.isArray(e)?e.map(t=>Qn(i,t)):[Qn(i,e)]}function Ct(i){return i!=null&&typeof i=="object"&&"parts"in i&&Array.isArray(i.parts)}function ei(i){return i!=null&&typeof i=="object"&&"functionCall"in i}function ti(i){return i!=null&&typeof i=="object"&&"functionResponse"in i}function X(i,e){if(e==null)throw new Error("ContentUnion is required");return Ct(e)?e:{role:"user",parts:jn(i,e)}}function ni(i,e){if(!e)return[];if(i.isVertexAI()&&Array.isArray(e))return e.flatMap(t=>{const n=X(i,t);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]});if(i.isVertexAI()){const t=X(i,e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]}return Array.isArray(e)?e.map(t=>X(i,t)):[X(i,e)]}function te(i,e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("contents are required");if(!Array.isArray(e)){if(ei(e)||ti(e))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[X(i,e)]}const t=[],n=[],o=Ct(e[0]);for(const l of e){const a=Ct(l);if(a!=o)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(a)t.push(l);else{if(ei(l)||ti(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 o||t.push({role:"user",parts:jn(i,n)}),t}const ar=new Set(["type","format","title","description","default","items","minItems","maxItems","enum","properties","required","minProperties","maxProperties","minimum","maximum","minLength","maxLength","pattern","anyOf","propertyOrdering"]),ii=Yo(["string","number","integer","object","array","boolean","null"]),ur=Ho([ii,Ue(ii)]);function cr(i=!0){const e=Wo(()=>{const t=Oo({type:ur.optional(),format:ge().optional(),title:ge().optional(),description:ge().optional(),default:sn().optional(),items:e.optional(),minItems:Se.string().optional(),maxItems:Se.string().optional(),enum:Ue(sn()).optional(),properties:Jo(ge(),e).optional(),required:Ue(ge()).optional(),minProperties:Se.string().optional(),maxProperties:Se.string().optional(),propertyOrdering:Ue(ge()).optional(),minimum:rn().optional(),maximum:rn().optional(),minLength:Se.string().optional(),maxLength:Se.string().optional(),pattern:ge().optional(),anyOf:Ue(e).optional(),additionalProperties:$o().optional()});return i?t.strict():t});return e}function dr(i,e){i.includes("null")&&(e.nullable=!0);const t=i.filter(n=>n!=="null");if(t.length===1)e.type=Object.keys(ee).includes(t[0].toUpperCase())?ee[t[0].toUpperCase()]:ee.TYPE_UNSPECIFIED;else{e.anyOf=[];for(const n of t)e.anyOf.push({type:Object.keys(ee).includes(n.toUpperCase())?ee[n.toUpperCase()]:ee.TYPE_UNSPECIFIED})}}function Ie(i){const e={},t=["items"],n=["anyOf"],o=["properties"];if(i.type&&i.anyOf)throw new Error("type and anyOf cannot be both populated.");const l=i.anyOf;l!=null&&l.length==2&&(l[0].type==="null"?(e.nullable=!0,i=l[1]):l[1].type==="null"&&(e.nullable=!0,i=l[0])),i.type instanceof Array&&dr(i.type,e);for(const[a,u]of Object.entries(i))if(u!=null)if(a=="type"){if(u==="null")throw new Error("type: null can not be the only possible type for the field.");if(u instanceof Array)continue;e.type=Object.keys(ee).includes(u.toUpperCase())?u.toUpperCase():ee.TYPE_UNSPECIFIED}else if(t.includes(a))e[a]=Ie(u);else if(n.includes(a)){const d=[];for(const c of u){if(c.type=="null"){e.nullable=!0;continue}d.push(Ie(c))}e[a]=d}else if(o.includes(a)){const d={};for(const[c,f]of Object.entries(u))d[c]=Ie(f);e[a]=d}else{if(a==="additionalProperties")continue;e[a]=u}return e}function je(i,e){if(Object.keys(e).includes("$schema")){delete e.$schema;const t=cr().parse(e);return Ie(t)}else return Ie(e)}function oi(i,e){if(typeof e=="object")return e;if(typeof e=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw new Error(`Unsupported speechConfig type: ${typeof e}`)}function _t(i,e){if("multiSpeakerVoiceConfig"in e)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function Ge(i,e){if(e.functionDeclarations)for(const t of e.functionDeclarations)t.parameters&&(t.parameters=je(i,t.parameters)),t.response&&(t.response=je(i,t.response));return e}function Be(i,e){if(e==null)throw new Error("tools is required");if(!Array.isArray(e))throw new Error("tools is required and must be an array of Tools");const t=[];for(const n of e)t.push(n);return t}function fr(i,e,t,n=1){const o=!e.startsWith(`${t}/`)&&e.split("/").length===n;return i.isVertexAI()?e.startsWith("projects/")?e:e.startsWith("locations/")?`projects/${i.getProject()}/${e}`:e.startsWith(`${t}/`)?`projects/${i.getProject()}/locations/${i.getLocation()}/${e}`:o?`projects/${i.getProject()}/locations/${i.getLocation()}/${t}/${e}`:e:o?`${t}/${e}`:e}function ce(i,e){if(typeof e!="string")throw new Error("name must be a string");return fr(i,e,"cachedContents")}function ri(i,e){switch(e){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return e}}function de(i,e){if(typeof e!="string")throw new Error("fromImageBytes must be a string");return e}function pr(i){return i!=null&&typeof i=="object"&&"name"in i}function mr(i){return i!=null&&typeof i=="object"&&"video"in i}function hr(i){return i!=null&&typeof i=="object"&&"uri"in i}function si(i,e){var t;let n;if(pr(e)&&(n=e.name),!(hr(e)&&(n=e.uri,n===void 0))&&!(mr(e)&&(n=(t=e.video)===null||t===void 0?void 0:t.uri,n===void 0))){if(typeof e=="string"&&(n=e),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 li(i,e){let t;return i.isVertexAI()?t=e?"publishers/google/models":"models":t=e?"models":"tunedModels",t}function ai(i,e){for(const t of["models","tunedModels","publisherModels"])if(gr(e,t))return e[t];return[]}function gr(i,e){return i!==null&&typeof i=="object"&&e in i}function yr(i,e={}){const t=i,n={name:t.name,description:t.description,parameters:Ie(et(t.inputSchema))};return e.behavior&&(n.behavior=e.behavior),{functionDeclarations:[n]}}function vr(i,e={}){const t=[],n=new Set;for(const o of i){const l=o.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=yr(o,e);a.functionDeclarations&&t.push(...a.functionDeclarations)}return{functionDeclarations:t}}function Tr(i){const e=[];for(const t of i)e.push(et(t));return e}function Cr(i){const e={};for(const[t,n]of Object.entries(i)){const o=n;e[t]=et(o)}return e}function et(i){const e=new Set(["items"]),t=new Set(["anyOf"]),n=new Set(["properties"]),o={};for(const[l,a]of Object.entries(i))if(e.has(l))o[l]=et(a);else if(t.has(l))o[l]=Tr(a);else if(n.has(l))o[l]=Cr(a);else if(l==="type"){const u=a.toUpperCase();o[l]=Object.keys(ee).includes(u)?u:ee.TYPE_UNSPECIFIED}else ar.has(l)&&(o[l]=a);return o}/**
|
|
134
|
+
* @license
|
|
135
|
+
* Copyright 2025 Google LLC
|
|
136
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
137
|
+
*/function _r(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Er(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function xr(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["fileUri"]);n!=null&&s(t,["fileUri"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function Sr(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],_r(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Er(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],xr(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function ui(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Sr(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function Ar(i,e){const t={},n=r(e,["behavior"]);n!=null&&s(t,["behavior"],n);const o=r(e,["description"]);o!=null&&s(t,["description"],o);const l=r(e,["name"]);l!=null&&s(t,["name"],l);const a=r(e,["parameters"]);a!=null&&s(t,["parameters"],a);const u=r(e,["response"]);return u!=null&&s(t,["response"],u),t}function Mr(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function Ir(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],Mr(i,n)),t}function Rr(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function wr(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],Rr(i,n)),t}function Nr(){return{}}function Pr(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>Ar(i,c))),s(t,["functionDeclarations"],d)}if(r(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=r(e,["googleSearch"]);o!=null&&s(t,["googleSearch"],Ir(i,o));const l=r(e,["googleSearchRetrieval"]);if(l!=null&&s(t,["googleSearchRetrieval"],wr(i,l)),r(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(r(e,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");r(e,["urlContext"])!=null&&s(t,["urlContext"],Nr());const u=r(e,["codeExecution"]);return u!=null&&s(t,["codeExecution"],u),t}function kr(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["allowedFunctionNames"]);return o!=null&&s(t,["allowedFunctionNames"],o),t}function Dr(i,e){const t={},n=r(e,["latitude"]);n!=null&&s(t,["latitude"],n);const o=r(e,["longitude"]);return o!=null&&s(t,["longitude"],o),t}function Lr(i,e){const t={},n=r(e,["latLng"]);n!=null&&s(t,["latLng"],Dr(i,n));const o=r(e,["languageCode"]);return o!=null&&s(t,["languageCode"],o),t}function Vr(i,e){const t={},n=r(e,["functionCallingConfig"]);n!=null&&s(t,["functionCallingConfig"],kr(i,n));const o=r(e,["retrievalConfig"]);return o!=null&&s(t,["retrievalConfig"],Lr(i,o)),t}function Fr(i,e,t){const n={},o=r(e,["ttl"]);t!==void 0&&o!=null&&s(t,["ttl"],o);const l=r(e,["expireTime"]);t!==void 0&&l!=null&&s(t,["expireTime"],l);const a=r(e,["displayName"]);t!==void 0&&a!=null&&s(t,["displayName"],a);const u=r(e,["contents"]);if(t!==void 0&&u!=null){let p=te(i,u);Array.isArray(p)&&(p=p.map(m=>ui(i,m))),s(t,["contents"],p)}const d=r(e,["systemInstruction"]);t!==void 0&&d!=null&&s(t,["systemInstruction"],ui(i,X(i,d)));const c=r(e,["tools"]);if(t!==void 0&&c!=null){let p=c;Array.isArray(p)&&(p=p.map(m=>Pr(i,m))),s(t,["tools"],p)}const f=r(e,["toolConfig"]);if(t!==void 0&&f!=null&&s(t,["toolConfig"],Vr(i,f)),r(e,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function Ur(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["model"],Kn(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],Fr(i,o,t)),t}function br(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],ce(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Gr(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],ce(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Br(i,e,t){const n={},o=r(e,["ttl"]);t!==void 0&&o!=null&&s(t,["ttl"],o);const l=r(e,["expireTime"]);return t!==void 0&&l!=null&&s(t,["expireTime"],l),n}function qr(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],ce(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],Br(i,o,t)),t}function $r(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);return t!==void 0&&l!=null&&s(t,["_query","pageToken"],l),n}function Or(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],$r(i,n,t)),t}function Hr(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Jr(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["data"]);o!=null&&s(t,["data"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Wr(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["fileUri"]);o!=null&&s(t,["fileUri"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Yr(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Hr(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Jr(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],Wr(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function ci(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Yr(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function zr(i,e){const t={};if(r(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=r(e,["description"]);n!=null&&s(t,["description"],n);const o=r(e,["name"]);o!=null&&s(t,["name"],o);const l=r(e,["parameters"]);l!=null&&s(t,["parameters"],l);const a=r(e,["response"]);return a!=null&&s(t,["response"],a),t}function Zr(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function Kr(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],Zr(i,n)),t}function Xr(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function Qr(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],Xr(i,n)),t}function jr(){return{}}function es(i,e){const t={},n=r(e,["apiKeyString"]);return n!=null&&s(t,["apiKeyString"],n),t}function ts(i,e){const t={},n=r(e,["apiKeyConfig"]);n!=null&&s(t,["apiKeyConfig"],es(i,n));const o=r(e,["authType"]);o!=null&&s(t,["authType"],o);const l=r(e,["googleServiceAccountConfig"]);l!=null&&s(t,["googleServiceAccountConfig"],l);const a=r(e,["httpBasicAuthConfig"]);a!=null&&s(t,["httpBasicAuthConfig"],a);const u=r(e,["oauthConfig"]);u!=null&&s(t,["oauthConfig"],u);const d=r(e,["oidcConfig"]);return d!=null&&s(t,["oidcConfig"],d),t}function ns(i,e){const t={},n=r(e,["authConfig"]);return n!=null&&s(t,["authConfig"],ts(i,n)),t}function is(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>zr(i,p))),s(t,["functionDeclarations"],f)}const o=r(e,["retrieval"]);o!=null&&s(t,["retrieval"],o);const l=r(e,["googleSearch"]);l!=null&&s(t,["googleSearch"],Kr(i,l));const a=r(e,["googleSearchRetrieval"]);a!=null&&s(t,["googleSearchRetrieval"],Qr(i,a)),r(e,["enterpriseWebSearch"])!=null&&s(t,["enterpriseWebSearch"],jr());const d=r(e,["googleMaps"]);if(d!=null&&s(t,["googleMaps"],ns(i,d)),r(e,["urlContext"])!==void 0)throw new Error("urlContext parameter is not supported in Vertex AI.");const c=r(e,["codeExecution"]);return c!=null&&s(t,["codeExecution"],c),t}function os(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["allowedFunctionNames"]);return o!=null&&s(t,["allowedFunctionNames"],o),t}function rs(i,e){const t={},n=r(e,["latitude"]);n!=null&&s(t,["latitude"],n);const o=r(e,["longitude"]);return o!=null&&s(t,["longitude"],o),t}function ss(i,e){const t={},n=r(e,["latLng"]);n!=null&&s(t,["latLng"],rs(i,n));const o=r(e,["languageCode"]);return o!=null&&s(t,["languageCode"],o),t}function ls(i,e){const t={},n=r(e,["functionCallingConfig"]);n!=null&&s(t,["functionCallingConfig"],os(i,n));const o=r(e,["retrievalConfig"]);return o!=null&&s(t,["retrievalConfig"],ss(i,o)),t}function as(i,e,t){const n={},o=r(e,["ttl"]);t!==void 0&&o!=null&&s(t,["ttl"],o);const l=r(e,["expireTime"]);t!==void 0&&l!=null&&s(t,["expireTime"],l);const a=r(e,["displayName"]);t!==void 0&&a!=null&&s(t,["displayName"],a);const u=r(e,["contents"]);if(t!==void 0&&u!=null){let m=te(i,u);Array.isArray(m)&&(m=m.map(h=>ci(i,h))),s(t,["contents"],m)}const d=r(e,["systemInstruction"]);t!==void 0&&d!=null&&s(t,["systemInstruction"],ci(i,X(i,d)));const c=r(e,["tools"]);if(t!==void 0&&c!=null){let m=c;Array.isArray(m)&&(m=m.map(h=>is(i,h))),s(t,["tools"],m)}const f=r(e,["toolConfig"]);t!==void 0&&f!=null&&s(t,["toolConfig"],ls(i,f));const p=r(e,["kmsKeyName"]);return t!==void 0&&p!=null&&s(t,["encryption_spec","kmsKeyName"],p),n}function us(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["model"],Kn(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],as(i,o,t)),t}function cs(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],ce(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function ds(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],ce(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function fs(i,e,t){const n={},o=r(e,["ttl"]);t!==void 0&&o!=null&&s(t,["ttl"],o);const l=r(e,["expireTime"]);return t!==void 0&&l!=null&&s(t,["expireTime"],l),n}function ps(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],ce(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],fs(i,o,t)),t}function ms(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);return t!==void 0&&l!=null&&s(t,["_query","pageToken"],l),n}function hs(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],ms(i,n,t)),t}function tt(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["displayName"]);o!=null&&s(t,["displayName"],o);const l=r(e,["model"]);l!=null&&s(t,["model"],l);const a=r(e,["createTime"]);a!=null&&s(t,["createTime"],a);const u=r(e,["updateTime"]);u!=null&&s(t,["updateTime"],u);const d=r(e,["expireTime"]);d!=null&&s(t,["expireTime"],d);const c=r(e,["usageMetadata"]);return c!=null&&s(t,["usageMetadata"],c),t}function gs(){return{}}function ys(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["cachedContents"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>tt(i,a))),s(t,["cachedContents"],l)}return t}function nt(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["displayName"]);o!=null&&s(t,["displayName"],o);const l=r(e,["model"]);l!=null&&s(t,["model"],l);const a=r(e,["createTime"]);a!=null&&s(t,["createTime"],a);const u=r(e,["updateTime"]);u!=null&&s(t,["updateTime"],u);const d=r(e,["expireTime"]);d!=null&&s(t,["expireTime"],d);const c=r(e,["usageMetadata"]);return c!=null&&s(t,["usageMetadata"],c),t}function vs(){return{}}function Ts(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["cachedContents"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>nt(i,a))),s(t,["cachedContents"],l)}return t}/**
|
|
138
|
+
* @license
|
|
139
|
+
* Copyright 2025 Google LLC
|
|
140
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
141
|
+
*/var Re;(function(i){i.PAGED_ITEM_BATCH_JOBS="batchJobs",i.PAGED_ITEM_MODELS="models",i.PAGED_ITEM_TUNING_JOBS="tuningJobs",i.PAGED_ITEM_FILES="files",i.PAGED_ITEM_CACHED_CONTENTS="cachedContents"})(Re||(Re={}));class it{constructor(e,t,n,o){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,o)}init(e,t,n){var o,l;this.nameInternal=e,this.pageInternal=t[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=t.nextPageToken),this.paramsInternal=a,this.pageInternalSize=(l=(o=a.config)===null||o===void 0?void 0:o.pageSize)!==null&&l!==void 0?l:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return((e=this.params.config)===null||e===void 0?void 0:e.pageToken)!==void 0}}/**
|
|
142
|
+
* @license
|
|
143
|
+
* Copyright 2025 Google LLC
|
|
144
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
145
|
+
*/class Cs extends Ae{constructor(e){super(),this.apiClient=e,this.list=async(t={})=>new it(Re.PAGED_ITEM_CACHED_CONTENTS,n=>this.listInternal(n),await this.listInternal(t),t)}async create(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=us(this.apiClient,e);return u=R("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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>nt(this.apiClient,f))}else{const c=Ur(this.apiClient,e);return u=R("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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>tt(this.apiClient,f))}}async get(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=cs(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>nt(this.apiClient,f))}else{const c=br(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>tt(this.apiClient,f))}}async delete(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=ds(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(()=>{const f=vs(),p=new zn;return Object.assign(p,f),p})}else{const c=Gr(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(()=>{const f=gs(),p=new zn;return Object.assign(p,f),p})}}async update(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=ps(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>nt(this.apiClient,f))}else{const c=qr(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>tt(this.apiClient,f))}}async listInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=hs(this.apiClient,e);return u=R("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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Ts(this.apiClient,f),m=new Zn;return Object.assign(m,p),m})}else{const c=Or(this.apiClient,e);return u=R("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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=ys(this.apiClient,f),m=new Zn;return Object.assign(m,p),m})}}}function di(i){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&i[e],n=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(i){return this instanceof $?(this.v=i,this):new $(i)}function we(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(i,e||[]),o,l=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(h){return function(g){return Promise.resolve(g).then(h,p)}}function u(h,g){n[h]&&(o[h]=function(v){return new Promise(function(E,I){l.push([h,v,E,I])>1||d(h,v)})},g&&(o[h]=g(o[h])))}function d(h,g){try{c(n[h](g))}catch(v){m(l[0][3],v)}}function c(h){h.value instanceof $?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 qe(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=i[Symbol.asyncIterator],t;return e?e.call(i):(i=typeof di=="function"?di(i):i[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(l){t[l]=i[l]&&function(a){return new Promise(function(u,d){a=i[l](a),o(u,d,a.done,a.value)})}}function o(l,a,u,d){Promise.resolve(d).then(function(c){l({value:c,done:u})},a)}}typeof SuppressedError=="function"&&SuppressedError;/**
|
|
146
|
+
* @license
|
|
147
|
+
* Copyright 2025 Google LLC
|
|
148
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
149
|
+
*/function _s(i){var e;if(i.candidates==null||i.candidates.length===0)return!1;const t=(e=i.candidates[0])===null||e===void 0?void 0:e.content;return t===void 0?!1:fi(t)}function fi(i){if(i.parts===void 0||i.parts.length===0)return!1;for(const e of i.parts)if(e===void 0||Object.keys(e).length===0||!e.thought&&e.text!==void 0&&e.text==="")return!1;return!0}function Es(i){if(i.length!==0){for(const e of i)if(e.role!=="user"&&e.role!=="model")throw new Error(`Role must be user or model, but got ${e.role}.`)}}function pi(i){if(i===void 0||i.length===0)return[];const e=[],t=i.length;let n=0;for(;n<t;)if(i[n].role==="user")e.push(i[n]),n++;else{const o=[];let l=!0;for(;n<t&&i[n].role==="model";)o.push(i[n]),l&&!fi(i[n])&&(l=!1),n++;l?e.push(...o):e.pop()}return e}class xs{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new Ss(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class Ss{constructor(e,t,n,o={},l=[]){this.apiClient=e,this.modelsModule=t,this.model=n,this.config=o,this.history=l,this.sendPromise=Promise.resolve(),Es(l)}async sendMessage(e){var t;await this.sendPromise;const n=X(this.apiClient,e.message),o=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(n),config:(t=e.config)!==null&&t!==void 0?t:this.config});return this.sendPromise=(async()=>{var l,a,u;const d=await o,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()}),o}async sendMessageStream(e){var t;await this.sendPromise;const n=X(this.apiClient,e.message),o=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(n),config:(t=e.config)!==null&&t!==void 0?t:this.config});this.sendPromise=o.then(()=>{}).catch(()=>{});const l=await o;return this.processStreamResponse(l,n)}getHistory(e=!1){const t=e?pi(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){var n,o;return we(this,arguments,function*(){var a,u,d,c;const f=[];try{for(var p=!0,m=qe(e),h;h=yield $(m.next()),a=h.done,!a;p=!0){c=h.value,p=!1;const g=c;if(_s(g)){const v=(o=(n=g.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content;v!==void 0&&f.push(v)}yield yield $(g)}}catch(g){u={error:g}}finally{try{!p&&!a&&(d=m.return)&&(yield $(d.call(m)))}finally{if(u)throw u.error}}this.recordHistory(t,f)})}recordHistory(e,t,n){let o=[];t.length>0&&t.every(l=>l.role!==void 0)?o=t:o.push({role:"model",parts:[]}),n&&n.length>0?this.history.push(...pi(n)):this.history.push(e),this.history.push(...o)}}/**
|
|
150
|
+
* @license
|
|
151
|
+
* Copyright 2025 Google LLC
|
|
152
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
153
|
+
*/function As(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);return t!==void 0&&l!=null&&s(t,["_query","pageToken"],l),n}function Ms(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],As(i,n,t)),t}function Is(i,e){const t={},n=r(e,["details"]);n!=null&&s(t,["details"],n);const o=r(e,["message"]);o!=null&&s(t,["message"],o);const l=r(e,["code"]);return l!=null&&s(t,["code"],l),t}function Rs(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["displayName"]);o!=null&&s(t,["displayName"],o);const l=r(e,["mimeType"]);l!=null&&s(t,["mimeType"],l);const a=r(e,["sizeBytes"]);a!=null&&s(t,["sizeBytes"],a);const u=r(e,["createTime"]);u!=null&&s(t,["createTime"],u);const d=r(e,["expirationTime"]);d!=null&&s(t,["expirationTime"],d);const c=r(e,["updateTime"]);c!=null&&s(t,["updateTime"],c);const f=r(e,["sha256Hash"]);f!=null&&s(t,["sha256Hash"],f);const p=r(e,["uri"]);p!=null&&s(t,["uri"],p);const m=r(e,["downloadUri"]);m!=null&&s(t,["downloadUri"],m);const h=r(e,["state"]);h!=null&&s(t,["state"],h);const g=r(e,["source"]);g!=null&&s(t,["source"],g);const v=r(e,["videoMetadata"]);v!=null&&s(t,["videoMetadata"],v);const E=r(e,["error"]);return E!=null&&s(t,["error"],Is(i,E)),t}function ws(i,e){const t={},n=r(e,["file"]);n!=null&&s(t,["file"],Rs(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Ns(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","file"],si(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Ps(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","file"],si(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function ks(i,e){const t={},n=r(e,["details"]);n!=null&&s(t,["details"],n);const o=r(e,["message"]);o!=null&&s(t,["message"],o);const l=r(e,["code"]);return l!=null&&s(t,["code"],l),t}function Et(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["displayName"]);o!=null&&s(t,["displayName"],o);const l=r(e,["mimeType"]);l!=null&&s(t,["mimeType"],l);const a=r(e,["sizeBytes"]);a!=null&&s(t,["sizeBytes"],a);const u=r(e,["createTime"]);u!=null&&s(t,["createTime"],u);const d=r(e,["expirationTime"]);d!=null&&s(t,["expirationTime"],d);const c=r(e,["updateTime"]);c!=null&&s(t,["updateTime"],c);const f=r(e,["sha256Hash"]);f!=null&&s(t,["sha256Hash"],f);const p=r(e,["uri"]);p!=null&&s(t,["uri"],p);const m=r(e,["downloadUri"]);m!=null&&s(t,["downloadUri"],m);const h=r(e,["state"]);h!=null&&s(t,["state"],h);const g=r(e,["source"]);g!=null&&s(t,["source"],g);const v=r(e,["videoMetadata"]);v!=null&&s(t,["videoMetadata"],v);const E=r(e,["error"]);return E!=null&&s(t,["error"],ks(i,E)),t}function Ds(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["files"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>Et(i,a))),s(t,["files"],l)}return t}function Ls(){return{}}function Vs(){return{}}/**
|
|
154
|
+
* @license
|
|
155
|
+
* Copyright 2025 Google LLC
|
|
156
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
157
|
+
*/class Fs extends Ae{constructor(e){super(),this.apiClient=e,this.list=async(t={})=>new it(Re.PAGED_ITEM_FILES,n=>this.listInternal(n),await this.listInternal(t),t)}async upload(e){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(e.file,e.config).then(t=>Et(this.apiClient,t))}async download(e){await this.apiClient.downloadFile(e)}async listInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ms(this.apiClient,e);return l=R("files",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>{const c=Ds(this.apiClient,d),f=new tr;return Object.assign(f,c),f})}}async createInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=ws(this.apiClient,e);return l=R("upload/v1beta/files",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(()=>{const d=Ls(),c=new nr;return Object.assign(c,d),c})}}async get(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ns(this.apiClient,e);return l=R("files/{file}",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>Et(this.apiClient,d))}}async delete(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=Ps(this.apiClient,e);return l=R("files/{file}",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(()=>{const d=Vs(),c=new ir;return Object.assign(c,d),c})}}}/**
|
|
158
|
+
* @license
|
|
159
|
+
* Copyright 2025 Google LLC
|
|
160
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
161
|
+
*/function Us(i,e){const t={},n=r(e,["voiceName"]);return n!=null&&s(t,["voiceName"],n),t}function bs(i,e){const t={},n=r(e,["voiceName"]);return n!=null&&s(t,["voiceName"],n),t}function mi(i,e){const t={},n=r(e,["prebuiltVoiceConfig"]);return n!=null&&s(t,["prebuiltVoiceConfig"],Us(i,n)),t}function Gs(i,e){const t={},n=r(e,["prebuiltVoiceConfig"]);return n!=null&&s(t,["prebuiltVoiceConfig"],bs(i,n)),t}function Bs(i,e){const t={},n=r(e,["speaker"]);n!=null&&s(t,["speaker"],n);const o=r(e,["voiceConfig"]);return o!=null&&s(t,["voiceConfig"],mi(i,o)),t}function qs(i,e){const t={},n=r(e,["speakerVoiceConfigs"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>Bs(i,l))),s(t,["speakerVoiceConfigs"],o)}return t}function $s(i,e){const t={},n=r(e,["voiceConfig"]);n!=null&&s(t,["voiceConfig"],mi(i,n));const o=r(e,["multiSpeakerVoiceConfig"]);o!=null&&s(t,["multiSpeakerVoiceConfig"],qs(i,o));const l=r(e,["languageCode"]);return l!=null&&s(t,["languageCode"],l),t}function Os(i,e){const t={},n=r(e,["voiceConfig"]);if(n!=null&&s(t,["voiceConfig"],Gs(i,n)),r(e,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const o=r(e,["languageCode"]);return o!=null&&s(t,["languageCode"],o),t}function Hs(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Js(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Ws(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function Ys(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["data"]);o!=null&&s(t,["data"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function zs(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["fileUri"]);n!=null&&s(t,["fileUri"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function Zs(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["fileUri"]);o!=null&&s(t,["fileUri"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Ks(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Hs(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Ws(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],zs(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function Xs(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Js(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Ys(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],Zs(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function Qs(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Ks(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function js(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Xs(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function el(i,e){const t={},n=r(e,["behavior"]);n!=null&&s(t,["behavior"],n);const o=r(e,["description"]);o!=null&&s(t,["description"],o);const l=r(e,["name"]);l!=null&&s(t,["name"],l);const a=r(e,["parameters"]);a!=null&&s(t,["parameters"],a);const u=r(e,["response"]);return u!=null&&s(t,["response"],u),t}function tl(i,e){const t={};if(r(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=r(e,["description"]);n!=null&&s(t,["description"],n);const o=r(e,["name"]);o!=null&&s(t,["name"],o);const l=r(e,["parameters"]);l!=null&&s(t,["parameters"],l);const a=r(e,["response"]);return a!=null&&s(t,["response"],a),t}function nl(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function il(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function ol(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],nl(i,n)),t}function rl(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],il(i,n)),t}function sl(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function ll(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function al(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],sl(i,n)),t}function ul(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],ll(i,n)),t}function cl(){return{}}function dl(i,e){const t={},n=r(e,["apiKeyString"]);return n!=null&&s(t,["apiKeyString"],n),t}function fl(i,e){const t={},n=r(e,["apiKeyConfig"]);n!=null&&s(t,["apiKeyConfig"],dl(i,n));const o=r(e,["authType"]);o!=null&&s(t,["authType"],o);const l=r(e,["googleServiceAccountConfig"]);l!=null&&s(t,["googleServiceAccountConfig"],l);const a=r(e,["httpBasicAuthConfig"]);a!=null&&s(t,["httpBasicAuthConfig"],a);const u=r(e,["oauthConfig"]);u!=null&&s(t,["oauthConfig"],u);const d=r(e,["oidcConfig"]);return d!=null&&s(t,["oidcConfig"],d),t}function pl(i,e){const t={},n=r(e,["authConfig"]);return n!=null&&s(t,["authConfig"],fl(i,n)),t}function ml(){return{}}function hl(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>el(i,c))),s(t,["functionDeclarations"],d)}if(r(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=r(e,["googleSearch"]);o!=null&&s(t,["googleSearch"],ol(i,o));const l=r(e,["googleSearchRetrieval"]);if(l!=null&&s(t,["googleSearchRetrieval"],al(i,l)),r(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(r(e,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");r(e,["urlContext"])!=null&&s(t,["urlContext"],ml());const u=r(e,["codeExecution"]);return u!=null&&s(t,["codeExecution"],u),t}function gl(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>tl(i,p))),s(t,["functionDeclarations"],f)}const o=r(e,["retrieval"]);o!=null&&s(t,["retrieval"],o);const l=r(e,["googleSearch"]);l!=null&&s(t,["googleSearch"],rl(i,l));const a=r(e,["googleSearchRetrieval"]);a!=null&&s(t,["googleSearchRetrieval"],ul(i,a)),r(e,["enterpriseWebSearch"])!=null&&s(t,["enterpriseWebSearch"],cl());const d=r(e,["googleMaps"]);if(d!=null&&s(t,["googleMaps"],pl(i,d)),r(e,["urlContext"])!==void 0)throw new Error("urlContext parameter is not supported in Vertex AI.");const c=r(e,["codeExecution"]);return c!=null&&s(t,["codeExecution"],c),t}function yl(i,e){const t={},n=r(e,["handle"]);if(n!=null&&s(t,["handle"],n),r(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function vl(i,e){const t={},n=r(e,["handle"]);n!=null&&s(t,["handle"],n);const o=r(e,["transparent"]);return o!=null&&s(t,["transparent"],o),t}function hi(){return{}}function gi(){return{}}function Tl(i,e){const t={},n=r(e,["disabled"]);n!=null&&s(t,["disabled"],n);const o=r(e,["startOfSpeechSensitivity"]);o!=null&&s(t,["startOfSpeechSensitivity"],o);const l=r(e,["endOfSpeechSensitivity"]);l!=null&&s(t,["endOfSpeechSensitivity"],l);const a=r(e,["prefixPaddingMs"]);a!=null&&s(t,["prefixPaddingMs"],a);const u=r(e,["silenceDurationMs"]);return u!=null&&s(t,["silenceDurationMs"],u),t}function Cl(i,e){const t={},n=r(e,["disabled"]);n!=null&&s(t,["disabled"],n);const o=r(e,["startOfSpeechSensitivity"]);o!=null&&s(t,["startOfSpeechSensitivity"],o);const l=r(e,["endOfSpeechSensitivity"]);l!=null&&s(t,["endOfSpeechSensitivity"],l);const a=r(e,["prefixPaddingMs"]);a!=null&&s(t,["prefixPaddingMs"],a);const u=r(e,["silenceDurationMs"]);return u!=null&&s(t,["silenceDurationMs"],u),t}function _l(i,e){const t={},n=r(e,["automaticActivityDetection"]);n!=null&&s(t,["automaticActivityDetection"],Tl(i,n));const o=r(e,["activityHandling"]);o!=null&&s(t,["activityHandling"],o);const l=r(e,["turnCoverage"]);return l!=null&&s(t,["turnCoverage"],l),t}function El(i,e){const t={},n=r(e,["automaticActivityDetection"]);n!=null&&s(t,["automaticActivityDetection"],Cl(i,n));const o=r(e,["activityHandling"]);o!=null&&s(t,["activityHandling"],o);const l=r(e,["turnCoverage"]);return l!=null&&s(t,["turnCoverage"],l),t}function xl(i,e){const t={},n=r(e,["targetTokens"]);return n!=null&&s(t,["targetTokens"],n),t}function Sl(i,e){const t={},n=r(e,["targetTokens"]);return n!=null&&s(t,["targetTokens"],n),t}function Al(i,e){const t={},n=r(e,["triggerTokens"]);n!=null&&s(t,["triggerTokens"],n);const o=r(e,["slidingWindow"]);return o!=null&&s(t,["slidingWindow"],xl(i,o)),t}function Ml(i,e){const t={},n=r(e,["triggerTokens"]);n!=null&&s(t,["triggerTokens"],n);const o=r(e,["slidingWindow"]);return o!=null&&s(t,["slidingWindow"],Sl(i,o)),t}function Il(i,e){const t={},n=r(e,["proactiveAudio"]);return n!=null&&s(t,["proactiveAudio"],n),t}function Rl(i,e){const t={},n=r(e,["proactiveAudio"]);return n!=null&&s(t,["proactiveAudio"],n),t}function wl(i,e,t){const n={},o=r(e,["generationConfig"]);t!==void 0&&o!=null&&s(t,["setup","generationConfig"],o);const l=r(e,["responseModalities"]);t!==void 0&&l!=null&&s(t,["setup","generationConfig","responseModalities"],l);const a=r(e,["temperature"]);t!==void 0&&a!=null&&s(t,["setup","generationConfig","temperature"],a);const u=r(e,["topP"]);t!==void 0&&u!=null&&s(t,["setup","generationConfig","topP"],u);const d=r(e,["topK"]);t!==void 0&&d!=null&&s(t,["setup","generationConfig","topK"],d);const c=r(e,["maxOutputTokens"]);t!==void 0&&c!=null&&s(t,["setup","generationConfig","maxOutputTokens"],c);const f=r(e,["mediaResolution"]);t!==void 0&&f!=null&&s(t,["setup","generationConfig","mediaResolution"],f);const p=r(e,["seed"]);t!==void 0&&p!=null&&s(t,["setup","generationConfig","seed"],p);const m=r(e,["speechConfig"]);t!==void 0&&m!=null&&s(t,["setup","generationConfig","speechConfig"],$s(i,_t(i,m)));const h=r(e,["enableAffectiveDialog"]);t!==void 0&&h!=null&&s(t,["setup","generationConfig","enableAffectiveDialog"],h);const g=r(e,["systemInstruction"]);t!==void 0&&g!=null&&s(t,["setup","systemInstruction"],Qs(i,X(i,g)));const v=r(e,["tools"]);if(t!==void 0&&v!=null){let M=Be(i,v);Array.isArray(M)&&(M=M.map(k=>hl(i,Ge(i,k)))),s(t,["setup","tools"],M)}const E=r(e,["sessionResumption"]);t!==void 0&&E!=null&&s(t,["setup","sessionResumption"],yl(i,E));const I=r(e,["inputAudioTranscription"]);t!==void 0&&I!=null&&s(t,["setup","inputAudioTranscription"],hi());const w=r(e,["outputAudioTranscription"]);t!==void 0&&w!=null&&s(t,["setup","outputAudioTranscription"],hi());const N=r(e,["realtimeInputConfig"]);t!==void 0&&N!=null&&s(t,["setup","realtimeInputConfig"],_l(i,N));const F=r(e,["contextWindowCompression"]);t!==void 0&&F!=null&&s(t,["setup","contextWindowCompression"],Al(i,F));const x=r(e,["proactivity"]);return t!==void 0&&x!=null&&s(t,["setup","proactivity"],Il(i,x)),n}function Nl(i,e,t){const n={},o=r(e,["generationConfig"]);t!==void 0&&o!=null&&s(t,["setup","generationConfig"],o);const l=r(e,["responseModalities"]);t!==void 0&&l!=null&&s(t,["setup","generationConfig","responseModalities"],l);const a=r(e,["temperature"]);t!==void 0&&a!=null&&s(t,["setup","generationConfig","temperature"],a);const u=r(e,["topP"]);t!==void 0&&u!=null&&s(t,["setup","generationConfig","topP"],u);const d=r(e,["topK"]);t!==void 0&&d!=null&&s(t,["setup","generationConfig","topK"],d);const c=r(e,["maxOutputTokens"]);t!==void 0&&c!=null&&s(t,["setup","generationConfig","maxOutputTokens"],c);const f=r(e,["mediaResolution"]);t!==void 0&&f!=null&&s(t,["setup","generationConfig","mediaResolution"],f);const p=r(e,["seed"]);t!==void 0&&p!=null&&s(t,["setup","generationConfig","seed"],p);const m=r(e,["speechConfig"]);t!==void 0&&m!=null&&s(t,["setup","generationConfig","speechConfig"],Os(i,_t(i,m)));const h=r(e,["enableAffectiveDialog"]);t!==void 0&&h!=null&&s(t,["setup","generationConfig","enableAffectiveDialog"],h);const g=r(e,["systemInstruction"]);t!==void 0&&g!=null&&s(t,["setup","systemInstruction"],js(i,X(i,g)));const v=r(e,["tools"]);if(t!==void 0&&v!=null){let M=Be(i,v);Array.isArray(M)&&(M=M.map(k=>gl(i,Ge(i,k)))),s(t,["setup","tools"],M)}const E=r(e,["sessionResumption"]);t!==void 0&&E!=null&&s(t,["setup","sessionResumption"],vl(i,E));const I=r(e,["inputAudioTranscription"]);t!==void 0&&I!=null&&s(t,["setup","inputAudioTranscription"],gi());const w=r(e,["outputAudioTranscription"]);t!==void 0&&w!=null&&s(t,["setup","outputAudioTranscription"],gi());const N=r(e,["realtimeInputConfig"]);t!==void 0&&N!=null&&s(t,["setup","realtimeInputConfig"],El(i,N));const F=r(e,["contextWindowCompression"]);t!==void 0&&F!=null&&s(t,["setup","contextWindowCompression"],Ml(i,F));const x=r(e,["proactivity"]);return t!==void 0&&x!=null&&s(t,["setup","proactivity"],Rl(i,x)),n}function Pl(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["setup","model"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],wl(i,o,t)),t}function kl(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["setup","model"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],Nl(i,o,t)),t}function Dl(){return{}}function Ll(){return{}}function Vl(){return{}}function Fl(){return{}}function Ul(i,e){const t={},n=r(e,["media"]);n!=null&&s(t,["mediaChunks"],Xn(i,n));const o=r(e,["audio"]);o!=null&&s(t,["audio"],lr(i,o));const l=r(e,["audioStreamEnd"]);l!=null&&s(t,["audioStreamEnd"],l);const a=r(e,["video"]);a!=null&&s(t,["video"],sr(i,a));const u=r(e,["text"]);return u!=null&&s(t,["text"],u),r(e,["activityStart"])!=null&&s(t,["activityStart"],Dl()),r(e,["activityEnd"])!=null&&s(t,["activityEnd"],Vl()),t}function bl(i,e){const t={},n=r(e,["media"]);if(n!=null&&s(t,["mediaChunks"],Xn(i,n)),r(e,["audio"])!==void 0)throw new Error("audio parameter is not supported in Vertex AI.");const o=r(e,["audioStreamEnd"]);if(o!=null&&s(t,["audioStreamEnd"],o),r(e,["video"])!==void 0)throw new Error("video parameter is not supported in Vertex AI.");if(r(e,["text"])!==void 0)throw new Error("text parameter is not supported in Vertex AI.");return r(e,["activityStart"])!=null&&s(t,["activityStart"],Ll()),r(e,["activityEnd"])!=null&&s(t,["activityEnd"],Fl()),t}function yi(i,e){const t={},n=r(e,["text"]);n!=null&&s(t,["text"],n);const o=r(e,["weight"]);return o!=null&&s(t,["weight"],o),t}function Gl(i,e){const t={},n=r(e,["weightedPrompts"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>yi(i,l))),s(t,["weightedPrompts"],o)}return t}function vi(i,e){const t={},n=r(e,["temperature"]);n!=null&&s(t,["temperature"],n);const o=r(e,["topK"]);o!=null&&s(t,["topK"],o);const l=r(e,["seed"]);l!=null&&s(t,["seed"],l);const a=r(e,["guidance"]);a!=null&&s(t,["guidance"],a);const u=r(e,["bpm"]);u!=null&&s(t,["bpm"],u);const d=r(e,["density"]);d!=null&&s(t,["density"],d);const c=r(e,["brightness"]);c!=null&&s(t,["brightness"],c);const f=r(e,["scale"]);f!=null&&s(t,["scale"],f);const p=r(e,["muteBass"]);p!=null&&s(t,["muteBass"],p);const m=r(e,["muteDrums"]);m!=null&&s(t,["muteDrums"],m);const h=r(e,["onlyBassAndDrums"]);return h!=null&&s(t,["onlyBassAndDrums"],h),t}function Bl(i,e){const t={},n=r(e,["musicGenerationConfig"]);return n!=null&&s(t,["musicGenerationConfig"],vi(i,n)),t}function Ti(i,e){const t={},n=r(e,["model"]);return n!=null&&s(t,["model"],n),t}function Ci(i,e){const t={},n=r(e,["weightedPrompts"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>yi(i,l))),s(t,["weightedPrompts"],o)}return t}function xt(i,e){const t={},n=r(e,["setup"]);n!=null&&s(t,["setup"],Ti(i,n));const o=r(e,["clientContent"]);o!=null&&s(t,["clientContent"],Ci(i,o));const l=r(e,["musicGenerationConfig"]);l!=null&&s(t,["musicGenerationConfig"],vi(i,l));const a=r(e,["playbackControl"]);return a!=null&&s(t,["playbackControl"],a),t}function ql(){return{}}function $l(){return{}}function Ol(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Hl(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Jl(i,e){const t={},n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function Wl(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["data"]);o!=null&&s(t,["data"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Yl(i,e){const t={},n=r(e,["fileUri"]);n!=null&&s(t,["fileUri"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function zl(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["fileUri"]);o!=null&&s(t,["fileUri"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Zl(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Ol(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Jl(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],Yl(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function Kl(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Hl(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Wl(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],zl(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function Xl(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Zl(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function Ql(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Kl(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function _i(i,e){const t={},n=r(e,["text"]);n!=null&&s(t,["text"],n);const o=r(e,["finished"]);return o!=null&&s(t,["finished"],o),t}function Ei(i,e){const t={},n=r(e,["text"]);n!=null&&s(t,["text"],n);const o=r(e,["finished"]);return o!=null&&s(t,["finished"],o),t}function jl(i,e){const t={},n=r(e,["retrievedUrl"]);n!=null&&s(t,["retrievedUrl"],n);const o=r(e,["urlRetrievalStatus"]);return o!=null&&s(t,["urlRetrievalStatus"],o),t}function ea(i,e){const t={},n=r(e,["urlMetadata"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>jl(i,l))),s(t,["urlMetadata"],o)}return t}function ta(i,e){const t={},n=r(e,["modelTurn"]);n!=null&&s(t,["modelTurn"],Xl(i,n));const o=r(e,["turnComplete"]);o!=null&&s(t,["turnComplete"],o);const l=r(e,["interrupted"]);l!=null&&s(t,["interrupted"],l);const a=r(e,["groundingMetadata"]);a!=null&&s(t,["groundingMetadata"],a);const u=r(e,["generationComplete"]);u!=null&&s(t,["generationComplete"],u);const d=r(e,["inputTranscription"]);d!=null&&s(t,["inputTranscription"],_i(i,d));const c=r(e,["outputTranscription"]);c!=null&&s(t,["outputTranscription"],_i(i,c));const f=r(e,["urlContextMetadata"]);return f!=null&&s(t,["urlContextMetadata"],ea(i,f)),t}function na(i,e){const t={},n=r(e,["modelTurn"]);n!=null&&s(t,["modelTurn"],Ql(i,n));const o=r(e,["turnComplete"]);o!=null&&s(t,["turnComplete"],o);const l=r(e,["interrupted"]);l!=null&&s(t,["interrupted"],l);const a=r(e,["groundingMetadata"]);a!=null&&s(t,["groundingMetadata"],a);const u=r(e,["generationComplete"]);u!=null&&s(t,["generationComplete"],u);const d=r(e,["inputTranscription"]);d!=null&&s(t,["inputTranscription"],Ei(i,d));const c=r(e,["outputTranscription"]);return c!=null&&s(t,["outputTranscription"],Ei(i,c)),t}function ia(i,e){const t={},n=r(e,["id"]);n!=null&&s(t,["id"],n);const o=r(e,["args"]);o!=null&&s(t,["args"],o);const l=r(e,["name"]);return l!=null&&s(t,["name"],l),t}function oa(i,e){const t={},n=r(e,["args"]);n!=null&&s(t,["args"],n);const o=r(e,["name"]);return o!=null&&s(t,["name"],o),t}function ra(i,e){const t={},n=r(e,["functionCalls"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>ia(i,l))),s(t,["functionCalls"],o)}return t}function sa(i,e){const t={},n=r(e,["functionCalls"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>oa(i,l))),s(t,["functionCalls"],o)}return t}function la(i,e){const t={},n=r(e,["ids"]);return n!=null&&s(t,["ids"],n),t}function aa(i,e){const t={},n=r(e,["ids"]);return n!=null&&s(t,["ids"],n),t}function ot(i,e){const t={},n=r(e,["modality"]);n!=null&&s(t,["modality"],n);const o=r(e,["tokenCount"]);return o!=null&&s(t,["tokenCount"],o),t}function rt(i,e){const t={},n=r(e,["modality"]);n!=null&&s(t,["modality"],n);const o=r(e,["tokenCount"]);return o!=null&&s(t,["tokenCount"],o),t}function ua(i,e){const t={},n=r(e,["promptTokenCount"]);n!=null&&s(t,["promptTokenCount"],n);const o=r(e,["cachedContentTokenCount"]);o!=null&&s(t,["cachedContentTokenCount"],o);const l=r(e,["responseTokenCount"]);l!=null&&s(t,["responseTokenCount"],l);const a=r(e,["toolUsePromptTokenCount"]);a!=null&&s(t,["toolUsePromptTokenCount"],a);const u=r(e,["thoughtsTokenCount"]);u!=null&&s(t,["thoughtsTokenCount"],u);const d=r(e,["totalTokenCount"]);d!=null&&s(t,["totalTokenCount"],d);const c=r(e,["promptTokensDetails"]);if(c!=null){let h=c;Array.isArray(h)&&(h=h.map(g=>ot(i,g))),s(t,["promptTokensDetails"],h)}const f=r(e,["cacheTokensDetails"]);if(f!=null){let h=f;Array.isArray(h)&&(h=h.map(g=>ot(i,g))),s(t,["cacheTokensDetails"],h)}const p=r(e,["responseTokensDetails"]);if(p!=null){let h=p;Array.isArray(h)&&(h=h.map(g=>ot(i,g))),s(t,["responseTokensDetails"],h)}const m=r(e,["toolUsePromptTokensDetails"]);if(m!=null){let h=m;Array.isArray(h)&&(h=h.map(g=>ot(i,g))),s(t,["toolUsePromptTokensDetails"],h)}return t}function ca(i,e){const t={},n=r(e,["promptTokenCount"]);n!=null&&s(t,["promptTokenCount"],n);const o=r(e,["cachedContentTokenCount"]);o!=null&&s(t,["cachedContentTokenCount"],o);const l=r(e,["candidatesTokenCount"]);l!=null&&s(t,["responseTokenCount"],l);const a=r(e,["toolUsePromptTokenCount"]);a!=null&&s(t,["toolUsePromptTokenCount"],a);const u=r(e,["thoughtsTokenCount"]);u!=null&&s(t,["thoughtsTokenCount"],u);const d=r(e,["totalTokenCount"]);d!=null&&s(t,["totalTokenCount"],d);const c=r(e,["promptTokensDetails"]);if(c!=null){let g=c;Array.isArray(g)&&(g=g.map(v=>rt(i,v))),s(t,["promptTokensDetails"],g)}const f=r(e,["cacheTokensDetails"]);if(f!=null){let g=f;Array.isArray(g)&&(g=g.map(v=>rt(i,v))),s(t,["cacheTokensDetails"],g)}const p=r(e,["candidatesTokensDetails"]);if(p!=null){let g=p;Array.isArray(g)&&(g=g.map(v=>rt(i,v))),s(t,["responseTokensDetails"],g)}const m=r(e,["toolUsePromptTokensDetails"]);if(m!=null){let g=m;Array.isArray(g)&&(g=g.map(v=>rt(i,v))),s(t,["toolUsePromptTokensDetails"],g)}const h=r(e,["trafficType"]);return h!=null&&s(t,["trafficType"],h),t}function da(i,e){const t={},n=r(e,["timeLeft"]);return n!=null&&s(t,["timeLeft"],n),t}function fa(i,e){const t={},n=r(e,["timeLeft"]);return n!=null&&s(t,["timeLeft"],n),t}function pa(i,e){const t={},n=r(e,["newHandle"]);n!=null&&s(t,["newHandle"],n);const o=r(e,["resumable"]);o!=null&&s(t,["resumable"],o);const l=r(e,["lastConsumedClientMessageIndex"]);return l!=null&&s(t,["lastConsumedClientMessageIndex"],l),t}function ma(i,e){const t={},n=r(e,["newHandle"]);n!=null&&s(t,["newHandle"],n);const o=r(e,["resumable"]);o!=null&&s(t,["resumable"],o);const l=r(e,["lastConsumedClientMessageIndex"]);return l!=null&&s(t,["lastConsumedClientMessageIndex"],l),t}function ha(i,e){const t={};r(e,["setupComplete"])!=null&&s(t,["setupComplete"],ql());const o=r(e,["serverContent"]);o!=null&&s(t,["serverContent"],ta(i,o));const l=r(e,["toolCall"]);l!=null&&s(t,["toolCall"],ra(i,l));const a=r(e,["toolCallCancellation"]);a!=null&&s(t,["toolCallCancellation"],la(i,a));const u=r(e,["usageMetadata"]);u!=null&&s(t,["usageMetadata"],ua(i,u));const d=r(e,["goAway"]);d!=null&&s(t,["goAway"],da(i,d));const c=r(e,["sessionResumptionUpdate"]);return c!=null&&s(t,["sessionResumptionUpdate"],pa(i,c)),t}function ga(i,e){const t={};r(e,["setupComplete"])!=null&&s(t,["setupComplete"],$l());const o=r(e,["serverContent"]);o!=null&&s(t,["serverContent"],na(i,o));const l=r(e,["toolCall"]);l!=null&&s(t,["toolCall"],sa(i,l));const a=r(e,["toolCallCancellation"]);a!=null&&s(t,["toolCallCancellation"],aa(i,a));const u=r(e,["usageMetadata"]);u!=null&&s(t,["usageMetadata"],ca(i,u));const d=r(e,["goAway"]);d!=null&&s(t,["goAway"],fa(i,d));const c=r(e,["sessionResumptionUpdate"]);return c!=null&&s(t,["sessionResumptionUpdate"],ma(i,c)),t}function ya(){return{}}function va(i,e){const t={},n=r(e,["text"]);n!=null&&s(t,["text"],n);const o=r(e,["weight"]);return o!=null&&s(t,["weight"],o),t}function Ta(i,e){const t={},n=r(e,["weightedPrompts"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>va(i,l))),s(t,["weightedPrompts"],o)}return t}function Ca(i,e){const t={},n=r(e,["temperature"]);n!=null&&s(t,["temperature"],n);const o=r(e,["topK"]);o!=null&&s(t,["topK"],o);const l=r(e,["seed"]);l!=null&&s(t,["seed"],l);const a=r(e,["guidance"]);a!=null&&s(t,["guidance"],a);const u=r(e,["bpm"]);u!=null&&s(t,["bpm"],u);const d=r(e,["density"]);d!=null&&s(t,["density"],d);const c=r(e,["brightness"]);c!=null&&s(t,["brightness"],c);const f=r(e,["scale"]);f!=null&&s(t,["scale"],f);const p=r(e,["muteBass"]);p!=null&&s(t,["muteBass"],p);const m=r(e,["muteDrums"]);m!=null&&s(t,["muteDrums"],m);const h=r(e,["onlyBassAndDrums"]);return h!=null&&s(t,["onlyBassAndDrums"],h),t}function _a(i,e){const t={},n=r(e,["clientContent"]);n!=null&&s(t,["clientContent"],Ta(i,n));const o=r(e,["musicGenerationConfig"]);return o!=null&&s(t,["musicGenerationConfig"],Ca(i,o)),t}function Ea(i,e){const t={},n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);o!=null&&s(t,["mimeType"],o);const l=r(e,["sourceMetadata"]);return l!=null&&s(t,["sourceMetadata"],_a(i,l)),t}function xa(i,e){const t={},n=r(e,["audioChunks"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>Ea(i,l))),s(t,["audioChunks"],o)}return t}function Sa(i,e){const t={},n=r(e,["text"]);n!=null&&s(t,["text"],n);const o=r(e,["filteredReason"]);return o!=null&&s(t,["filteredReason"],o),t}function Aa(i,e){const t={};r(e,["setupComplete"])!=null&&s(t,["setupComplete"],ya());const o=r(e,["serverContent"]);o!=null&&s(t,["serverContent"],xa(i,o));const l=r(e,["filteredPrompt"]);return l!=null&&s(t,["filteredPrompt"],Sa(i,l)),t}/**
|
|
162
|
+
* @license
|
|
163
|
+
* Copyright 2025 Google LLC
|
|
164
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
165
|
+
*/function Ma(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Ia(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function Ra(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["fileUri"]);n!=null&&s(t,["fileUri"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function wa(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Ma(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Ia(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],Ra(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function st(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>wa(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function Na(i,e){const t={},n=r(e,["anyOf"]);n!=null&&s(t,["anyOf"],n);const o=r(e,["default"]);o!=null&&s(t,["default"],o);const l=r(e,["description"]);l!=null&&s(t,["description"],l);const a=r(e,["enum"]);a!=null&&s(t,["enum"],a);const u=r(e,["example"]);u!=null&&s(t,["example"],u);const d=r(e,["format"]);d!=null&&s(t,["format"],d);const c=r(e,["items"]);c!=null&&s(t,["items"],c);const f=r(e,["maxItems"]);f!=null&&s(t,["maxItems"],f);const p=r(e,["maxLength"]);p!=null&&s(t,["maxLength"],p);const m=r(e,["maxProperties"]);m!=null&&s(t,["maxProperties"],m);const h=r(e,["maximum"]);h!=null&&s(t,["maximum"],h);const g=r(e,["minItems"]);g!=null&&s(t,["minItems"],g);const v=r(e,["minLength"]);v!=null&&s(t,["minLength"],v);const E=r(e,["minProperties"]);E!=null&&s(t,["minProperties"],E);const I=r(e,["minimum"]);I!=null&&s(t,["minimum"],I);const w=r(e,["nullable"]);w!=null&&s(t,["nullable"],w);const N=r(e,["pattern"]);N!=null&&s(t,["pattern"],N);const F=r(e,["properties"]);F!=null&&s(t,["properties"],F);const x=r(e,["propertyOrdering"]);x!=null&&s(t,["propertyOrdering"],x);const M=r(e,["required"]);M!=null&&s(t,["required"],M);const k=r(e,["title"]);k!=null&&s(t,["title"],k);const O=r(e,["type"]);return O!=null&&s(t,["type"],O),t}function Pa(i,e){const t={};if(r(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const n=r(e,["category"]);n!=null&&s(t,["category"],n);const o=r(e,["threshold"]);return o!=null&&s(t,["threshold"],o),t}function ka(i,e){const t={},n=r(e,["behavior"]);n!=null&&s(t,["behavior"],n);const o=r(e,["description"]);o!=null&&s(t,["description"],o);const l=r(e,["name"]);l!=null&&s(t,["name"],l);const a=r(e,["parameters"]);a!=null&&s(t,["parameters"],a);const u=r(e,["response"]);return u!=null&&s(t,["response"],u),t}function Da(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function La(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],Da(i,n)),t}function Va(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function Fa(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],Va(i,n)),t}function Ua(){return{}}function ba(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>ka(i,c))),s(t,["functionDeclarations"],d)}if(r(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=r(e,["googleSearch"]);o!=null&&s(t,["googleSearch"],La(i,o));const l=r(e,["googleSearchRetrieval"]);if(l!=null&&s(t,["googleSearchRetrieval"],Fa(i,l)),r(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(r(e,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");r(e,["urlContext"])!=null&&s(t,["urlContext"],Ua());const u=r(e,["codeExecution"]);return u!=null&&s(t,["codeExecution"],u),t}function Ga(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["allowedFunctionNames"]);return o!=null&&s(t,["allowedFunctionNames"],o),t}function Ba(i,e){const t={},n=r(e,["latitude"]);n!=null&&s(t,["latitude"],n);const o=r(e,["longitude"]);return o!=null&&s(t,["longitude"],o),t}function qa(i,e){const t={},n=r(e,["latLng"]);n!=null&&s(t,["latLng"],Ba(i,n));const o=r(e,["languageCode"]);return o!=null&&s(t,["languageCode"],o),t}function $a(i,e){const t={},n=r(e,["functionCallingConfig"]);n!=null&&s(t,["functionCallingConfig"],Ga(i,n));const o=r(e,["retrievalConfig"]);return o!=null&&s(t,["retrievalConfig"],qa(i,o)),t}function Oa(i,e){const t={},n=r(e,["voiceName"]);return n!=null&&s(t,["voiceName"],n),t}function xi(i,e){const t={},n=r(e,["prebuiltVoiceConfig"]);return n!=null&&s(t,["prebuiltVoiceConfig"],Oa(i,n)),t}function Ha(i,e){const t={},n=r(e,["speaker"]);n!=null&&s(t,["speaker"],n);const o=r(e,["voiceConfig"]);return o!=null&&s(t,["voiceConfig"],xi(i,o)),t}function Ja(i,e){const t={},n=r(e,["speakerVoiceConfigs"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>Ha(i,l))),s(t,["speakerVoiceConfigs"],o)}return t}function Wa(i,e){const t={},n=r(e,["voiceConfig"]);n!=null&&s(t,["voiceConfig"],xi(i,n));const o=r(e,["multiSpeakerVoiceConfig"]);o!=null&&s(t,["multiSpeakerVoiceConfig"],Ja(i,o));const l=r(e,["languageCode"]);return l!=null&&s(t,["languageCode"],l),t}function Ya(i,e){const t={},n=r(e,["includeThoughts"]);n!=null&&s(t,["includeThoughts"],n);const o=r(e,["thinkingBudget"]);return o!=null&&s(t,["thinkingBudget"],o),t}function za(i,e,t){const n={},o=r(e,["systemInstruction"]);t!==void 0&&o!=null&&s(t,["systemInstruction"],st(i,X(i,o)));const l=r(e,["temperature"]);l!=null&&s(n,["temperature"],l);const a=r(e,["topP"]);a!=null&&s(n,["topP"],a);const u=r(e,["topK"]);u!=null&&s(n,["topK"],u);const d=r(e,["candidateCount"]);d!=null&&s(n,["candidateCount"],d);const c=r(e,["maxOutputTokens"]);c!=null&&s(n,["maxOutputTokens"],c);const f=r(e,["stopSequences"]);f!=null&&s(n,["stopSequences"],f);const p=r(e,["responseLogprobs"]);p!=null&&s(n,["responseLogprobs"],p);const m=r(e,["logprobs"]);m!=null&&s(n,["logprobs"],m);const h=r(e,["presencePenalty"]);h!=null&&s(n,["presencePenalty"],h);const g=r(e,["frequencyPenalty"]);g!=null&&s(n,["frequencyPenalty"],g);const v=r(e,["seed"]);v!=null&&s(n,["seed"],v);const E=r(e,["responseMimeType"]);E!=null&&s(n,["responseMimeType"],E);const I=r(e,["responseSchema"]);if(I!=null&&s(n,["responseSchema"],Na(i,je(i,I))),r(e,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(r(e,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const w=r(e,["safetySettings"]);if(t!==void 0&&w!=null){let B=w;Array.isArray(B)&&(B=B.map(Q=>Pa(i,Q))),s(t,["safetySettings"],B)}const N=r(e,["tools"]);if(t!==void 0&&N!=null){let B=Be(i,N);Array.isArray(B)&&(B=B.map(Q=>ba(i,Ge(i,Q)))),s(t,["tools"],B)}const F=r(e,["toolConfig"]);if(t!==void 0&&F!=null&&s(t,["toolConfig"],$a(i,F)),r(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const x=r(e,["cachedContent"]);t!==void 0&&x!=null&&s(t,["cachedContent"],ce(i,x));const M=r(e,["responseModalities"]);M!=null&&s(n,["responseModalities"],M);const k=r(e,["mediaResolution"]);k!=null&&s(n,["mediaResolution"],k);const O=r(e,["speechConfig"]);if(O!=null&&s(n,["speechConfig"],Wa(i,oi(i,O))),r(e,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const L=r(e,["thinkingConfig"]);return L!=null&&s(n,["thinkingConfig"],Ya(i,L)),n}function Si(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);if(o!=null){let a=te(i,o);Array.isArray(a)&&(a=a.map(u=>st(i,u))),s(t,["contents"],a)}const l=r(e,["config"]);return l!=null&&s(t,["generationConfig"],za(i,l,t)),t}function Za(i,e,t){const n={},o=r(e,["taskType"]);t!==void 0&&o!=null&&s(t,["requests[]","taskType"],o);const l=r(e,["title"]);t!==void 0&&l!=null&&s(t,["requests[]","title"],l);const a=r(e,["outputDimensionality"]);if(t!==void 0&&a!=null&&s(t,["requests[]","outputDimensionality"],a),r(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(r(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function Ka(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);o!=null&&s(t,["requests[]","content"],ni(i,o));const l=r(e,["config"]);l!=null&&s(t,["config"],Za(i,l,t));const a=r(e,["model"]);return a!==void 0&&s(t,["requests[]","model"],q(i,a)),t}function Xa(i,e,t){const n={};if(r(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(r(e,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const o=r(e,["numberOfImages"]);t!==void 0&&o!=null&&s(t,["parameters","sampleCount"],o);const l=r(e,["aspectRatio"]);t!==void 0&&l!=null&&s(t,["parameters","aspectRatio"],l);const a=r(e,["guidanceScale"]);if(t!==void 0&&a!=null&&s(t,["parameters","guidanceScale"],a),r(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const u=r(e,["safetyFilterLevel"]);t!==void 0&&u!=null&&s(t,["parameters","safetySetting"],u);const d=r(e,["personGeneration"]);t!==void 0&&d!=null&&s(t,["parameters","personGeneration"],d);const c=r(e,["includeSafetyAttributes"]);t!==void 0&&c!=null&&s(t,["parameters","includeSafetyAttributes"],c);const f=r(e,["includeRaiReason"]);t!==void 0&&f!=null&&s(t,["parameters","includeRaiReason"],f);const p=r(e,["language"]);t!==void 0&&p!=null&&s(t,["parameters","language"],p);const m=r(e,["outputMimeType"]);t!==void 0&&m!=null&&s(t,["parameters","outputOptions","mimeType"],m);const h=r(e,["outputCompressionQuality"]);if(t!==void 0&&h!=null&&s(t,["parameters","outputOptions","compressionQuality"],h),r(e,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(r(e,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function Qa(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["prompt"]);o!=null&&s(t,["instances[0]","prompt"],o);const l=r(e,["config"]);return l!=null&&s(t,["config"],Xa(i,l,t)),t}function ja(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","name"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function eu(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);t!==void 0&&l!=null&&s(t,["_query","pageToken"],l);const a=r(e,["filter"]);t!==void 0&&a!=null&&s(t,["_query","filter"],a);const u=r(e,["queryBase"]);return t!==void 0&&u!=null&&s(t,["_url","models_url"],li(i,u)),n}function tu(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],eu(i,n,t)),t}function nu(i,e,t){const n={},o=r(e,["displayName"]);t!==void 0&&o!=null&&s(t,["displayName"],o);const l=r(e,["description"]);t!==void 0&&l!=null&&s(t,["description"],l);const a=r(e,["defaultCheckpointId"]);return t!==void 0&&a!=null&&s(t,["defaultCheckpointId"],a),n}function iu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","name"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],nu(i,o,t)),t}function ou(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","name"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function ru(i,e){const t={};if(r(e,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(r(e,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(r(e,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function su(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);if(o!=null){let a=te(i,o);Array.isArray(a)&&(a=a.map(u=>st(i,u))),s(t,["contents"],a)}const l=r(e,["config"]);return l!=null&&s(t,["config"],ru(i,l)),t}function lu(i,e){const t={};if(r(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=r(e,["imageBytes"]);n!=null&&s(t,["bytesBase64Encoded"],de(i,n));const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function au(i,e,t){const n={},o=r(e,["numberOfVideos"]);if(t!==void 0&&o!=null&&s(t,["parameters","sampleCount"],o),r(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(r(e,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const l=r(e,["durationSeconds"]);if(t!==void 0&&l!=null&&s(t,["parameters","durationSeconds"],l),r(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const a=r(e,["aspectRatio"]);if(t!==void 0&&a!=null&&s(t,["parameters","aspectRatio"],a),r(e,["resolution"])!==void 0)throw new Error("resolution parameter is not supported in Gemini API.");const u=r(e,["personGeneration"]);if(t!==void 0&&u!=null&&s(t,["parameters","personGeneration"],u),r(e,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const d=r(e,["negativePrompt"]);if(t!==void 0&&d!=null&&s(t,["parameters","negativePrompt"],d),r(e,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");if(r(e,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");return n}function uu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["prompt"]);o!=null&&s(t,["instances[0]","prompt"],o);const l=r(e,["image"]);l!=null&&s(t,["instances[0]","image"],lu(i,l));const a=r(e,["config"]);return a!=null&&s(t,["config"],au(i,a,t)),t}function cu(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function du(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["data"]);o!=null&&s(t,["data"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function fu(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["fileUri"]);o!=null&&s(t,["fileUri"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function pu(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],cu(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],du(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],fu(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function Ne(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>pu(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function mu(i,e){const t={},n=r(e,["anyOf"]);n!=null&&s(t,["anyOf"],n);const o=r(e,["default"]);o!=null&&s(t,["default"],o);const l=r(e,["description"]);l!=null&&s(t,["description"],l);const a=r(e,["enum"]);a!=null&&s(t,["enum"],a);const u=r(e,["example"]);u!=null&&s(t,["example"],u);const d=r(e,["format"]);d!=null&&s(t,["format"],d);const c=r(e,["items"]);c!=null&&s(t,["items"],c);const f=r(e,["maxItems"]);f!=null&&s(t,["maxItems"],f);const p=r(e,["maxLength"]);p!=null&&s(t,["maxLength"],p);const m=r(e,["maxProperties"]);m!=null&&s(t,["maxProperties"],m);const h=r(e,["maximum"]);h!=null&&s(t,["maximum"],h);const g=r(e,["minItems"]);g!=null&&s(t,["minItems"],g);const v=r(e,["minLength"]);v!=null&&s(t,["minLength"],v);const E=r(e,["minProperties"]);E!=null&&s(t,["minProperties"],E);const I=r(e,["minimum"]);I!=null&&s(t,["minimum"],I);const w=r(e,["nullable"]);w!=null&&s(t,["nullable"],w);const N=r(e,["pattern"]);N!=null&&s(t,["pattern"],N);const F=r(e,["properties"]);F!=null&&s(t,["properties"],F);const x=r(e,["propertyOrdering"]);x!=null&&s(t,["propertyOrdering"],x);const M=r(e,["required"]);M!=null&&s(t,["required"],M);const k=r(e,["title"]);k!=null&&s(t,["title"],k);const O=r(e,["type"]);return O!=null&&s(t,["type"],O),t}function hu(i,e){const t={},n=r(e,["featureSelectionPreference"]);return n!=null&&s(t,["featureSelectionPreference"],n),t}function gu(i,e){const t={},n=r(e,["method"]);n!=null&&s(t,["method"],n);const o=r(e,["category"]);o!=null&&s(t,["category"],o);const l=r(e,["threshold"]);return l!=null&&s(t,["threshold"],l),t}function yu(i,e){const t={};if(r(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=r(e,["description"]);n!=null&&s(t,["description"],n);const o=r(e,["name"]);o!=null&&s(t,["name"],o);const l=r(e,["parameters"]);l!=null&&s(t,["parameters"],l);const a=r(e,["response"]);return a!=null&&s(t,["response"],a),t}function vu(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function Tu(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],vu(i,n)),t}function Cu(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function _u(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],Cu(i,n)),t}function Eu(){return{}}function xu(i,e){const t={},n=r(e,["apiKeyString"]);return n!=null&&s(t,["apiKeyString"],n),t}function Su(i,e){const t={},n=r(e,["apiKeyConfig"]);n!=null&&s(t,["apiKeyConfig"],xu(i,n));const o=r(e,["authType"]);o!=null&&s(t,["authType"],o);const l=r(e,["googleServiceAccountConfig"]);l!=null&&s(t,["googleServiceAccountConfig"],l);const a=r(e,["httpBasicAuthConfig"]);a!=null&&s(t,["httpBasicAuthConfig"],a);const u=r(e,["oauthConfig"]);u!=null&&s(t,["oauthConfig"],u);const d=r(e,["oidcConfig"]);return d!=null&&s(t,["oidcConfig"],d),t}function Au(i,e){const t={},n=r(e,["authConfig"]);return n!=null&&s(t,["authConfig"],Su(i,n)),t}function Ai(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let f=n;Array.isArray(f)&&(f=f.map(p=>yu(i,p))),s(t,["functionDeclarations"],f)}const o=r(e,["retrieval"]);o!=null&&s(t,["retrieval"],o);const l=r(e,["googleSearch"]);l!=null&&s(t,["googleSearch"],Tu(i,l));const a=r(e,["googleSearchRetrieval"]);a!=null&&s(t,["googleSearchRetrieval"],_u(i,a)),r(e,["enterpriseWebSearch"])!=null&&s(t,["enterpriseWebSearch"],Eu());const d=r(e,["googleMaps"]);if(d!=null&&s(t,["googleMaps"],Au(i,d)),r(e,["urlContext"])!==void 0)throw new Error("urlContext parameter is not supported in Vertex AI.");const c=r(e,["codeExecution"]);return c!=null&&s(t,["codeExecution"],c),t}function Mu(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["allowedFunctionNames"]);return o!=null&&s(t,["allowedFunctionNames"],o),t}function Iu(i,e){const t={},n=r(e,["latitude"]);n!=null&&s(t,["latitude"],n);const o=r(e,["longitude"]);return o!=null&&s(t,["longitude"],o),t}function Ru(i,e){const t={},n=r(e,["latLng"]);n!=null&&s(t,["latLng"],Iu(i,n));const o=r(e,["languageCode"]);return o!=null&&s(t,["languageCode"],o),t}function wu(i,e){const t={},n=r(e,["functionCallingConfig"]);n!=null&&s(t,["functionCallingConfig"],Mu(i,n));const o=r(e,["retrievalConfig"]);return o!=null&&s(t,["retrievalConfig"],Ru(i,o)),t}function Nu(i,e){const t={},n=r(e,["voiceName"]);return n!=null&&s(t,["voiceName"],n),t}function Pu(i,e){const t={},n=r(e,["prebuiltVoiceConfig"]);return n!=null&&s(t,["prebuiltVoiceConfig"],Nu(i,n)),t}function ku(i,e){const t={},n=r(e,["voiceConfig"]);if(n!=null&&s(t,["voiceConfig"],Pu(i,n)),r(e,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const o=r(e,["languageCode"]);return o!=null&&s(t,["languageCode"],o),t}function Du(i,e){const t={},n=r(e,["includeThoughts"]);n!=null&&s(t,["includeThoughts"],n);const o=r(e,["thinkingBudget"]);return o!=null&&s(t,["thinkingBudget"],o),t}function Lu(i,e,t){const n={},o=r(e,["systemInstruction"]);t!==void 0&&o!=null&&s(t,["systemInstruction"],Ne(i,X(i,o)));const l=r(e,["temperature"]);l!=null&&s(n,["temperature"],l);const a=r(e,["topP"]);a!=null&&s(n,["topP"],a);const u=r(e,["topK"]);u!=null&&s(n,["topK"],u);const d=r(e,["candidateCount"]);d!=null&&s(n,["candidateCount"],d);const c=r(e,["maxOutputTokens"]);c!=null&&s(n,["maxOutputTokens"],c);const f=r(e,["stopSequences"]);f!=null&&s(n,["stopSequences"],f);const p=r(e,["responseLogprobs"]);p!=null&&s(n,["responseLogprobs"],p);const m=r(e,["logprobs"]);m!=null&&s(n,["logprobs"],m);const h=r(e,["presencePenalty"]);h!=null&&s(n,["presencePenalty"],h);const g=r(e,["frequencyPenalty"]);g!=null&&s(n,["frequencyPenalty"],g);const v=r(e,["seed"]);v!=null&&s(n,["seed"],v);const E=r(e,["responseMimeType"]);E!=null&&s(n,["responseMimeType"],E);const I=r(e,["responseSchema"]);I!=null&&s(n,["responseSchema"],mu(i,je(i,I)));const w=r(e,["routingConfig"]);w!=null&&s(n,["routingConfig"],w);const N=r(e,["modelSelectionConfig"]);N!=null&&s(n,["modelConfig"],hu(i,N));const F=r(e,["safetySettings"]);if(t!==void 0&&F!=null){let ne=F;Array.isArray(ne)&&(ne=ne.map(ye=>gu(i,ye))),s(t,["safetySettings"],ne)}const x=r(e,["tools"]);if(t!==void 0&&x!=null){let ne=Be(i,x);Array.isArray(ne)&&(ne=ne.map(ye=>Ai(i,Ge(i,ye)))),s(t,["tools"],ne)}const M=r(e,["toolConfig"]);t!==void 0&&M!=null&&s(t,["toolConfig"],wu(i,M));const k=r(e,["labels"]);t!==void 0&&k!=null&&s(t,["labels"],k);const O=r(e,["cachedContent"]);t!==void 0&&O!=null&&s(t,["cachedContent"],ce(i,O));const L=r(e,["responseModalities"]);L!=null&&s(n,["responseModalities"],L);const B=r(e,["mediaResolution"]);B!=null&&s(n,["mediaResolution"],B);const Q=r(e,["speechConfig"]);Q!=null&&s(n,["speechConfig"],ku(i,oi(i,Q)));const Pe=r(e,["audioTimestamp"]);Pe!=null&&s(n,["audioTimestamp"],Pe);const $e=r(e,["thinkingConfig"]);return $e!=null&&s(n,["thinkingConfig"],Du(i,$e)),n}function Mi(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);if(o!=null){let a=te(i,o);Array.isArray(a)&&(a=a.map(u=>Ne(i,u))),s(t,["contents"],a)}const l=r(e,["config"]);return l!=null&&s(t,["generationConfig"],Lu(i,l,t)),t}function Vu(i,e,t){const n={},o=r(e,["taskType"]);t!==void 0&&o!=null&&s(t,["instances[]","task_type"],o);const l=r(e,["title"]);t!==void 0&&l!=null&&s(t,["instances[]","title"],l);const a=r(e,["outputDimensionality"]);t!==void 0&&a!=null&&s(t,["parameters","outputDimensionality"],a);const u=r(e,["mimeType"]);t!==void 0&&u!=null&&s(t,["instances[]","mimeType"],u);const d=r(e,["autoTruncate"]);return t!==void 0&&d!=null&&s(t,["parameters","autoTruncate"],d),n}function Fu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);o!=null&&s(t,["instances[]","content"],ni(i,o));const l=r(e,["config"]);return l!=null&&s(t,["config"],Vu(i,l,t)),t}function Uu(i,e,t){const n={},o=r(e,["outputGcsUri"]);t!==void 0&&o!=null&&s(t,["parameters","storageUri"],o);const l=r(e,["negativePrompt"]);t!==void 0&&l!=null&&s(t,["parameters","negativePrompt"],l);const a=r(e,["numberOfImages"]);t!==void 0&&a!=null&&s(t,["parameters","sampleCount"],a);const u=r(e,["aspectRatio"]);t!==void 0&&u!=null&&s(t,["parameters","aspectRatio"],u);const d=r(e,["guidanceScale"]);t!==void 0&&d!=null&&s(t,["parameters","guidanceScale"],d);const c=r(e,["seed"]);t!==void 0&&c!=null&&s(t,["parameters","seed"],c);const f=r(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&s(t,["parameters","safetySetting"],f);const p=r(e,["personGeneration"]);t!==void 0&&p!=null&&s(t,["parameters","personGeneration"],p);const m=r(e,["includeSafetyAttributes"]);t!==void 0&&m!=null&&s(t,["parameters","includeSafetyAttributes"],m);const h=r(e,["includeRaiReason"]);t!==void 0&&h!=null&&s(t,["parameters","includeRaiReason"],h);const g=r(e,["language"]);t!==void 0&&g!=null&&s(t,["parameters","language"],g);const v=r(e,["outputMimeType"]);t!==void 0&&v!=null&&s(t,["parameters","outputOptions","mimeType"],v);const E=r(e,["outputCompressionQuality"]);t!==void 0&&E!=null&&s(t,["parameters","outputOptions","compressionQuality"],E);const I=r(e,["addWatermark"]);t!==void 0&&I!=null&&s(t,["parameters","addWatermark"],I);const w=r(e,["enhancePrompt"]);return t!==void 0&&w!=null&&s(t,["parameters","enhancePrompt"],w),n}function bu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["prompt"]);o!=null&&s(t,["instances[0]","prompt"],o);const l=r(e,["config"]);return l!=null&&s(t,["config"],Uu(i,l,t)),t}function St(i,e){const t={},n=r(e,["gcsUri"]);n!=null&&s(t,["gcsUri"],n);const o=r(e,["imageBytes"]);o!=null&&s(t,["bytesBase64Encoded"],de(i,o));const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Gu(i,e){const t={},n=r(e,["maskMode"]);n!=null&&s(t,["maskMode"],n);const o=r(e,["segmentationClasses"]);o!=null&&s(t,["maskClasses"],o);const l=r(e,["maskDilation"]);return l!=null&&s(t,["dilation"],l),t}function Bu(i,e){const t={},n=r(e,["controlType"]);n!=null&&s(t,["controlType"],n);const o=r(e,["enableControlImageComputation"]);return o!=null&&s(t,["computeControl"],o),t}function qu(i,e){const t={},n=r(e,["styleDescription"]);return n!=null&&s(t,["styleDescription"],n),t}function $u(i,e){const t={},n=r(e,["subjectType"]);n!=null&&s(t,["subjectType"],n);const o=r(e,["subjectDescription"]);return o!=null&&s(t,["subjectDescription"],o),t}function Ou(i,e){const t={},n=r(e,["referenceImage"]);n!=null&&s(t,["referenceImage"],St(i,n));const o=r(e,["referenceId"]);o!=null&&s(t,["referenceId"],o);const l=r(e,["referenceType"]);l!=null&&s(t,["referenceType"],l);const a=r(e,["maskImageConfig"]);a!=null&&s(t,["maskImageConfig"],Gu(i,a));const u=r(e,["controlImageConfig"]);u!=null&&s(t,["controlImageConfig"],Bu(i,u));const d=r(e,["styleImageConfig"]);d!=null&&s(t,["styleImageConfig"],qu(i,d));const c=r(e,["subjectImageConfig"]);return c!=null&&s(t,["subjectImageConfig"],$u(i,c)),t}function Hu(i,e,t){const n={},o=r(e,["outputGcsUri"]);t!==void 0&&o!=null&&s(t,["parameters","storageUri"],o);const l=r(e,["negativePrompt"]);t!==void 0&&l!=null&&s(t,["parameters","negativePrompt"],l);const a=r(e,["numberOfImages"]);t!==void 0&&a!=null&&s(t,["parameters","sampleCount"],a);const u=r(e,["aspectRatio"]);t!==void 0&&u!=null&&s(t,["parameters","aspectRatio"],u);const d=r(e,["guidanceScale"]);t!==void 0&&d!=null&&s(t,["parameters","guidanceScale"],d);const c=r(e,["seed"]);t!==void 0&&c!=null&&s(t,["parameters","seed"],c);const f=r(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&s(t,["parameters","safetySetting"],f);const p=r(e,["personGeneration"]);t!==void 0&&p!=null&&s(t,["parameters","personGeneration"],p);const m=r(e,["includeSafetyAttributes"]);t!==void 0&&m!=null&&s(t,["parameters","includeSafetyAttributes"],m);const h=r(e,["includeRaiReason"]);t!==void 0&&h!=null&&s(t,["parameters","includeRaiReason"],h);const g=r(e,["language"]);t!==void 0&&g!=null&&s(t,["parameters","language"],g);const v=r(e,["outputMimeType"]);t!==void 0&&v!=null&&s(t,["parameters","outputOptions","mimeType"],v);const E=r(e,["outputCompressionQuality"]);t!==void 0&&E!=null&&s(t,["parameters","outputOptions","compressionQuality"],E);const I=r(e,["editMode"]);t!==void 0&&I!=null&&s(t,["parameters","editMode"],I);const w=r(e,["baseSteps"]);return t!==void 0&&w!=null&&s(t,["parameters","editConfig","baseSteps"],w),n}function Ju(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["prompt"]);o!=null&&s(t,["instances[0]","prompt"],o);const l=r(e,["referenceImages"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(d=>Ou(i,d))),s(t,["instances[0]","referenceImages"],u)}const a=r(e,["config"]);return a!=null&&s(t,["config"],Hu(i,a,t)),t}function Wu(i,e,t){const n={},o=r(e,["includeRaiReason"]);t!==void 0&&o!=null&&s(t,["parameters","includeRaiReason"],o);const l=r(e,["outputMimeType"]);t!==void 0&&l!=null&&s(t,["parameters","outputOptions","mimeType"],l);const a=r(e,["outputCompressionQuality"]);t!==void 0&&a!=null&&s(t,["parameters","outputOptions","compressionQuality"],a);const u=r(e,["numberOfImages"]);t!==void 0&&u!=null&&s(t,["parameters","sampleCount"],u);const d=r(e,["mode"]);return t!==void 0&&d!=null&&s(t,["parameters","mode"],d),n}function Yu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["image"]);o!=null&&s(t,["instances[0]","image"],St(i,o));const l=r(e,["upscaleFactor"]);l!=null&&s(t,["parameters","upscaleConfig","upscaleFactor"],l);const a=r(e,["config"]);return a!=null&&s(t,["config"],Wu(i,a,t)),t}function zu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","name"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Zu(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);t!==void 0&&l!=null&&s(t,["_query","pageToken"],l);const a=r(e,["filter"]);t!==void 0&&a!=null&&s(t,["_query","filter"],a);const u=r(e,["queryBase"]);return t!==void 0&&u!=null&&s(t,["_url","models_url"],li(i,u)),n}function Ku(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],Zu(i,n,t)),t}function Xu(i,e,t){const n={},o=r(e,["displayName"]);t!==void 0&&o!=null&&s(t,["displayName"],o);const l=r(e,["description"]);t!==void 0&&l!=null&&s(t,["description"],l);const a=r(e,["defaultCheckpointId"]);return t!==void 0&&a!=null&&s(t,["defaultCheckpointId"],a),n}function Qu(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],Xu(i,o,t)),t}function ju(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","name"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function ec(i,e,t){const n={},o=r(e,["systemInstruction"]);t!==void 0&&o!=null&&s(t,["systemInstruction"],Ne(i,X(i,o)));const l=r(e,["tools"]);if(t!==void 0&&l!=null){let u=l;Array.isArray(u)&&(u=u.map(d=>Ai(i,d))),s(t,["tools"],u)}const a=r(e,["generationConfig"]);return t!==void 0&&a!=null&&s(t,["generationConfig"],a),n}function tc(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);if(o!=null){let a=te(i,o);Array.isArray(a)&&(a=a.map(u=>Ne(i,u))),s(t,["contents"],a)}const l=r(e,["config"]);return l!=null&&s(t,["config"],ec(i,l,t)),t}function nc(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["contents"]);if(o!=null){let a=te(i,o);Array.isArray(a)&&(a=a.map(u=>Ne(i,u))),s(t,["contents"],a)}const l=r(e,["config"]);return l!=null&&s(t,["config"],l),t}function ic(i,e,t){const n={},o=r(e,["numberOfVideos"]);t!==void 0&&o!=null&&s(t,["parameters","sampleCount"],o);const l=r(e,["outputGcsUri"]);t!==void 0&&l!=null&&s(t,["parameters","storageUri"],l);const a=r(e,["fps"]);t!==void 0&&a!=null&&s(t,["parameters","fps"],a);const u=r(e,["durationSeconds"]);t!==void 0&&u!=null&&s(t,["parameters","durationSeconds"],u);const d=r(e,["seed"]);t!==void 0&&d!=null&&s(t,["parameters","seed"],d);const c=r(e,["aspectRatio"]);t!==void 0&&c!=null&&s(t,["parameters","aspectRatio"],c);const f=r(e,["resolution"]);t!==void 0&&f!=null&&s(t,["parameters","resolution"],f);const p=r(e,["personGeneration"]);t!==void 0&&p!=null&&s(t,["parameters","personGeneration"],p);const m=r(e,["pubsubTopic"]);t!==void 0&&m!=null&&s(t,["parameters","pubsubTopic"],m);const h=r(e,["negativePrompt"]);t!==void 0&&h!=null&&s(t,["parameters","negativePrompt"],h);const g=r(e,["enhancePrompt"]);t!==void 0&&g!=null&&s(t,["parameters","enhancePrompt"],g);const v=r(e,["generateAudio"]);return t!==void 0&&v!=null&&s(t,["parameters","generateAudio"],v),n}function oc(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["_url","model"],q(i,n));const o=r(e,["prompt"]);o!=null&&s(t,["instances[0]","prompt"],o);const l=r(e,["image"]);l!=null&&s(t,["instances[0]","image"],St(i,l));const a=r(e,["config"]);return a!=null&&s(t,["config"],ic(i,a,t)),t}function rc(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function sc(i,e){const t={},n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function lc(i,e){const t={},n=r(e,["fileUri"]);n!=null&&s(t,["fileUri"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function ac(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],rc(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],sc(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],lc(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function uc(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>ac(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function cc(i,e){const t={},n=r(e,["citationSources"]);return n!=null&&s(t,["citations"],n),t}function dc(i,e){const t={},n=r(e,["retrievedUrl"]);n!=null&&s(t,["retrievedUrl"],n);const o=r(e,["urlRetrievalStatus"]);return o!=null&&s(t,["urlRetrievalStatus"],o),t}function fc(i,e){const t={},n=r(e,["urlMetadata"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>dc(i,l))),s(t,["urlMetadata"],o)}return t}function pc(i,e){const t={},n=r(e,["content"]);n!=null&&s(t,["content"],uc(i,n));const o=r(e,["citationMetadata"]);o!=null&&s(t,["citationMetadata"],cc(i,o));const l=r(e,["tokenCount"]);l!=null&&s(t,["tokenCount"],l);const a=r(e,["finishReason"]);a!=null&&s(t,["finishReason"],a);const u=r(e,["urlContextMetadata"]);u!=null&&s(t,["urlContextMetadata"],fc(i,u));const d=r(e,["avgLogprobs"]);d!=null&&s(t,["avgLogprobs"],d);const c=r(e,["groundingMetadata"]);c!=null&&s(t,["groundingMetadata"],c);const f=r(e,["index"]);f!=null&&s(t,["index"],f);const p=r(e,["logprobsResult"]);p!=null&&s(t,["logprobsResult"],p);const m=r(e,["safetyRatings"]);return m!=null&&s(t,["safetyRatings"],m),t}function Ii(i,e){const t={},n=r(e,["candidates"]);if(n!=null){let u=n;Array.isArray(u)&&(u=u.map(d=>pc(i,d))),s(t,["candidates"],u)}const o=r(e,["modelVersion"]);o!=null&&s(t,["modelVersion"],o);const l=r(e,["promptFeedback"]);l!=null&&s(t,["promptFeedback"],l);const a=r(e,["usageMetadata"]);return a!=null&&s(t,["usageMetadata"],a),t}function mc(i,e){const t={},n=r(e,["values"]);return n!=null&&s(t,["values"],n),t}function hc(){return{}}function gc(i,e){const t={},n=r(e,["embeddings"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>mc(i,a))),s(t,["embeddings"],l)}return r(e,["metadata"])!=null&&s(t,["metadata"],hc()),t}function yc(i,e){const t={},n=r(e,["bytesBase64Encoded"]);n!=null&&s(t,["imageBytes"],de(i,n));const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function Ri(i,e){const t={},n=r(e,["safetyAttributes","categories"]);n!=null&&s(t,["categories"],n);const o=r(e,["safetyAttributes","scores"]);o!=null&&s(t,["scores"],o);const l=r(e,["contentType"]);return l!=null&&s(t,["contentType"],l),t}function vc(i,e){const t={},n=r(e,["_self"]);n!=null&&s(t,["image"],yc(i,n));const o=r(e,["raiFilteredReason"]);o!=null&&s(t,["raiFilteredReason"],o);const l=r(e,["_self"]);return l!=null&&s(t,["safetyAttributes"],Ri(i,l)),t}function Tc(i,e){const t={},n=r(e,["predictions"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>vc(i,a))),s(t,["generatedImages"],l)}const o=r(e,["positivePromptSafetyAttributes"]);return o!=null&&s(t,["positivePromptSafetyAttributes"],Ri(i,o)),t}function Cc(i,e){const t={},n=r(e,["baseModel"]);n!=null&&s(t,["baseModel"],n);const o=r(e,["createTime"]);o!=null&&s(t,["createTime"],o);const l=r(e,["updateTime"]);return l!=null&&s(t,["updateTime"],l),t}function At(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["displayName"]);o!=null&&s(t,["displayName"],o);const l=r(e,["description"]);l!=null&&s(t,["description"],l);const a=r(e,["version"]);a!=null&&s(t,["version"],a);const u=r(e,["_self"]);u!=null&&s(t,["tunedModelInfo"],Cc(i,u));const d=r(e,["inputTokenLimit"]);d!=null&&s(t,["inputTokenLimit"],d);const c=r(e,["outputTokenLimit"]);c!=null&&s(t,["outputTokenLimit"],c);const f=r(e,["supportedGenerationMethods"]);return f!=null&&s(t,["supportedActions"],f),t}function _c(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["_self"]);if(o!=null){let l=ai(i,o);Array.isArray(l)&&(l=l.map(a=>At(i,a))),s(t,["models"],l)}return t}function Ec(){return{}}function xc(i,e){const t={},n=r(e,["totalTokens"]);n!=null&&s(t,["totalTokens"],n);const o=r(e,["cachedContentTokenCount"]);return o!=null&&s(t,["cachedContentTokenCount"],o),t}function Sc(i,e){const t={},n=r(e,["video","uri"]);n!=null&&s(t,["uri"],n);const o=r(e,["video","encodedVideo"]);o!=null&&s(t,["videoBytes"],de(i,o));const l=r(e,["encoding"]);return l!=null&&s(t,["mimeType"],l),t}function Ac(i,e){const t={},n=r(e,["_self"]);return n!=null&&s(t,["video"],Sc(i,n)),t}function Mc(i,e){const t={},n=r(e,["generatedSamples"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>Ac(i,u))),s(t,["generatedVideos"],a)}const o=r(e,["raiMediaFilteredCount"]);o!=null&&s(t,["raiMediaFilteredCount"],o);const l=r(e,["raiMediaFilteredReasons"]);return l!=null&&s(t,["raiMediaFilteredReasons"],l),t}function Ic(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["metadata"]);o!=null&&s(t,["metadata"],o);const l=r(e,["done"]);l!=null&&s(t,["done"],l);const a=r(e,["error"]);a!=null&&s(t,["error"],a);const u=r(e,["response","generateVideoResponse"]);return u!=null&&s(t,["response"],Mc(i,u)),t}function Rc(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function wc(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["data"]);o!=null&&s(t,["data"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Nc(i,e){const t={},n=r(e,["displayName"]);n!=null&&s(t,["displayName"],n);const o=r(e,["fileUri"]);o!=null&&s(t,["fileUri"],o);const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Pc(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Rc(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],wc(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],Nc(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function kc(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Pc(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function Dc(i,e){const t={},n=r(e,["citations"]);return n!=null&&s(t,["citations"],n),t}function Lc(i,e){const t={},n=r(e,["content"]);n!=null&&s(t,["content"],kc(i,n));const o=r(e,["citationMetadata"]);o!=null&&s(t,["citationMetadata"],Dc(i,o));const l=r(e,["finishMessage"]);l!=null&&s(t,["finishMessage"],l);const a=r(e,["finishReason"]);a!=null&&s(t,["finishReason"],a);const u=r(e,["avgLogprobs"]);u!=null&&s(t,["avgLogprobs"],u);const d=r(e,["groundingMetadata"]);d!=null&&s(t,["groundingMetadata"],d);const c=r(e,["index"]);c!=null&&s(t,["index"],c);const f=r(e,["logprobsResult"]);f!=null&&s(t,["logprobsResult"],f);const p=r(e,["safetyRatings"]);return p!=null&&s(t,["safetyRatings"],p),t}function wi(i,e){const t={},n=r(e,["candidates"]);if(n!=null){let c=n;Array.isArray(c)&&(c=c.map(f=>Lc(i,f))),s(t,["candidates"],c)}const o=r(e,["createTime"]);o!=null&&s(t,["createTime"],o);const l=r(e,["responseId"]);l!=null&&s(t,["responseId"],l);const a=r(e,["modelVersion"]);a!=null&&s(t,["modelVersion"],a);const u=r(e,["promptFeedback"]);u!=null&&s(t,["promptFeedback"],u);const d=r(e,["usageMetadata"]);return d!=null&&s(t,["usageMetadata"],d),t}function Vc(i,e){const t={},n=r(e,["truncated"]);n!=null&&s(t,["truncated"],n);const o=r(e,["token_count"]);return o!=null&&s(t,["tokenCount"],o),t}function Fc(i,e){const t={},n=r(e,["values"]);n!=null&&s(t,["values"],n);const o=r(e,["statistics"]);return o!=null&&s(t,["statistics"],Vc(i,o)),t}function Uc(i,e){const t={},n=r(e,["billableCharacterCount"]);return n!=null&&s(t,["billableCharacterCount"],n),t}function bc(i,e){const t={},n=r(e,["predictions[]","embeddings"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Fc(i,a))),s(t,["embeddings"],l)}const o=r(e,["metadata"]);return o!=null&&s(t,["metadata"],Uc(i,o)),t}function Gc(i,e){const t={},n=r(e,["gcsUri"]);n!=null&&s(t,["gcsUri"],n);const o=r(e,["bytesBase64Encoded"]);o!=null&&s(t,["imageBytes"],de(i,o));const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Ni(i,e){const t={},n=r(e,["safetyAttributes","categories"]);n!=null&&s(t,["categories"],n);const o=r(e,["safetyAttributes","scores"]);o!=null&&s(t,["scores"],o);const l=r(e,["contentType"]);return l!=null&&s(t,["contentType"],l),t}function Mt(i,e){const t={},n=r(e,["_self"]);n!=null&&s(t,["image"],Gc(i,n));const o=r(e,["raiFilteredReason"]);o!=null&&s(t,["raiFilteredReason"],o);const l=r(e,["_self"]);l!=null&&s(t,["safetyAttributes"],Ni(i,l));const a=r(e,["prompt"]);return a!=null&&s(t,["enhancedPrompt"],a),t}function Bc(i,e){const t={},n=r(e,["predictions"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>Mt(i,a))),s(t,["generatedImages"],l)}const o=r(e,["positivePromptSafetyAttributes"]);return o!=null&&s(t,["positivePromptSafetyAttributes"],Ni(i,o)),t}function qc(i,e){const t={},n=r(e,["predictions"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>Mt(i,l))),s(t,["generatedImages"],o)}return t}function $c(i,e){const t={},n=r(e,["predictions"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>Mt(i,l))),s(t,["generatedImages"],o)}return t}function Oc(i,e){const t={},n=r(e,["endpoint"]);n!=null&&s(t,["name"],n);const o=r(e,["deployedModelId"]);return o!=null&&s(t,["deployedModelId"],o),t}function Hc(i,e){const t={},n=r(e,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&s(t,["baseModel"],n);const o=r(e,["createTime"]);o!=null&&s(t,["createTime"],o);const l=r(e,["updateTime"]);return l!=null&&s(t,["updateTime"],l),t}function Jc(i,e){const t={},n=r(e,["checkpointId"]);n!=null&&s(t,["checkpointId"],n);const o=r(e,["epoch"]);o!=null&&s(t,["epoch"],o);const l=r(e,["step"]);return l!=null&&s(t,["step"],l),t}function It(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["displayName"]);o!=null&&s(t,["displayName"],o);const l=r(e,["description"]);l!=null&&s(t,["description"],l);const a=r(e,["versionId"]);a!=null&&s(t,["version"],a);const u=r(e,["deployedModels"]);if(u!=null){let m=u;Array.isArray(m)&&(m=m.map(h=>Oc(i,h))),s(t,["endpoints"],m)}const d=r(e,["labels"]);d!=null&&s(t,["labels"],d);const c=r(e,["_self"]);c!=null&&s(t,["tunedModelInfo"],Hc(i,c));const f=r(e,["defaultCheckpointId"]);f!=null&&s(t,["defaultCheckpointId"],f);const p=r(e,["checkpoints"]);if(p!=null){let m=p;Array.isArray(m)&&(m=m.map(h=>Jc(i,h))),s(t,["checkpoints"],m)}return t}function Wc(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["_self"]);if(o!=null){let l=ai(i,o);Array.isArray(l)&&(l=l.map(a=>It(i,a))),s(t,["models"],l)}return t}function Yc(){return{}}function zc(i,e){const t={},n=r(e,["totalTokens"]);return n!=null&&s(t,["totalTokens"],n),t}function Zc(i,e){const t={},n=r(e,["tokensInfo"]);return n!=null&&s(t,["tokensInfo"],n),t}function Kc(i,e){const t={},n=r(e,["gcsUri"]);n!=null&&s(t,["uri"],n);const o=r(e,["bytesBase64Encoded"]);o!=null&&s(t,["videoBytes"],de(i,o));const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function Xc(i,e){const t={},n=r(e,["_self"]);return n!=null&&s(t,["video"],Kc(i,n)),t}function Qc(i,e){const t={},n=r(e,["videos"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>Xc(i,u))),s(t,["generatedVideos"],a)}const o=r(e,["raiMediaFilteredCount"]);o!=null&&s(t,["raiMediaFilteredCount"],o);const l=r(e,["raiMediaFilteredReasons"]);return l!=null&&s(t,["raiMediaFilteredReasons"],l),t}function jc(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["metadata"]);o!=null&&s(t,["metadata"],o);const l=r(e,["done"]);l!=null&&s(t,["done"],l);const a=r(e,["error"]);a!=null&&s(t,["error"],a);const u=r(e,["response"]);return u!=null&&s(t,["response"],Qc(i,u)),t}/**
|
|
166
|
+
* @license
|
|
167
|
+
* Copyright 2025 Google LLC
|
|
168
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
169
|
+
*/const ed="Content-Type",td="X-Server-Timeout",nd="User-Agent",Rt="x-goog-api-client",id="google-genai-sdk/1.3.0",od="v1beta1",rd="v1beta",Pi=/^data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class ki extends Error{constructor(e,t){t?super(e,{cause:t}):super(e,{cause:new Error().stack}),this.message=e,this.name="ClientError"}}class wt extends Error{constructor(e,t){t?super(e,{cause:t}):super(e,{cause:new Error().stack}),this.message=e,this.name="ServerError"}}class sd{constructor(e){var t,n;this.clientOptions=Object.assign(Object.assign({},e),{project:e.project,location:e.location,apiKey:e.apiKey,vertexai:e.vertexai});const o={};this.clientOptions.vertexai?(o.apiVersion=(t=this.clientOptions.apiVersion)!==null&&t!==void 0?t:od,o.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(o.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:rd,o.baseUrl="https://generativelanguage.googleapis.com/"),o.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=o,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(o,e.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var e;return(e=this.clientOptions.vertexai)!==null&&e!==void 0?e:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const n=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==""&&n.push(e.apiVersion),n.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const e=this.getBaseUrl(),t=new URL(e);return t.protocol=t.protocol=="http:"?"ws":"wss",t.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw new Error("HTTP options are not correctly set.")}constructUrl(e,t,n){const o=[this.getRequestUrlInternal(t)];return n&&o.push(this.getBaseResourcePath()),e!==""&&o.push(e),new URL(`${o.join("/")}`)}shouldPrependVertexProjectPath(e){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith("projects/")||e.httpMethod==="GET"&&e.path.startsWith("publishers/google/models"))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const n=this.shouldPrependVertexProjectPath(e),o=this.constructUrl(e.path,t,n);if(e.queryParams)for(const[a,u]of Object.entries(e.queryParams))o.searchParams.append(a,String(u));let l={};if(e.httpMethod==="GET"){if(e.body&&e.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else l.body=e.body;return l=await this.includeExtraHttpOptionsToRequestInit(l,t,e.abortSignal),this.unaryApiCall(o,l,e.httpMethod)}patchHttpOptions(e,t){const n=JSON.parse(JSON.stringify(e));for(const[o,l]of Object.entries(t))typeof l=="object"?n[o]=Object.assign(Object.assign({},n[o]),l):l!==void 0&&(n[o]=l);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));const n=this.shouldPrependVertexProjectPath(e),o=this.constructUrl(e.path,t,n);(!o.searchParams.has("alt")||o.searchParams.get("alt")!=="sse")&&o.searchParams.set("alt","sse");let l={};return l.body=e.body,l=await this.includeExtraHttpOptionsToRequestInit(l,t,e.abortSignal),this.streamApiCall(o,l,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,n){if(t&&t.timeout||n){const o=new AbortController,l=o.signal;t.timeout&&(t==null?void 0:t.timeout)>0&&setTimeout(()=>o.abort(),t.timeout),n&&n.addEventListener("abort",()=>{o.abort()}),e.signal=l}return e.headers=await this.getHeadersInternal(t),e}async unaryApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async o=>(await Di(o),new Tt(o))).catch(o=>{throw o instanceof Error?o:new Error(JSON.stringify(o))})}async streamApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async o=>(await Di(o),this.processStreamResponse(o))).catch(o=>{throw o instanceof Error?o:new Error(JSON.stringify(o))})}processStreamResponse(e){var t;return we(this,arguments,function*(){const o=(t=e==null?void 0:e.body)===null||t===void 0?void 0:t.getReader(),l=new TextDecoder("utf-8");if(!o)throw new Error("Response body is empty");try{let a="";for(;;){const{done:u,value:d}=yield $(o.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,v=`got status: ${h}. ${JSON.stringify(p)}`;if(g>=400&&g<500)throw new ki(v);if(g>=500&&g<600)throw new wt(v)}}catch(p){const m=p;if(m.name==="ClientError"||m.name==="ServerError")throw p}a+=c;let f=a.match(Pi);for(;f;){const p=f[1];try{const m=new Response(p,{headers:e==null?void 0:e.headers,status:e==null?void 0:e.status,statusText:e==null?void 0:e.statusText});yield yield $(new Tt(m)),a=a.slice(f[0].length),f=a.match(Pi)}catch(m){throw new Error(`exception parsing stream chunk ${p}. ${m}`)}}}}finally{o.releaseLock()}})}async apiCall(e,t){return fetch(e,t).catch(n=>{throw new Error(`exception ${n} sending request`)})}getDefaultHeaders(){const e={},t=id+" "+this.clientOptions.userAgentExtra;return e[nd]=t,e[Rt]=t,e[ed]="application/json",e}async getHeadersInternal(e){const t=new Headers;if(e&&e.headers){for(const[n,o]of Object.entries(e.headers))t.append(n,o);e.timeout&&e.timeout>0&&t.append(td,String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(t),t}async uploadFile(e,t){var n;const o={};t!=null&&(o.mimeType=t.mimeType,o.name=t.name,o.displayName=t.displayName),o.name&&!o.name.startsWith("files/")&&(o.name=`files/${o.name}`);const l=this.clientOptions.uploader,a=await l.stat(e);o.sizeBytes=String(a.size);const u=(n=t==null?void 0:t.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.");o.mimeType=u;const d=await this.fetchUploadUrl(o,t);return l.upload(e,d,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,t){var n;let o={};t!=null&&t.httpOptions?o=t.httpOptions:o={apiVersion:"",headers:{"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${e.sizeBytes}`,"X-Goog-Upload-Header-Content-Type":`${e.mimeType}`}};const l={file:e},a=await this.request({path:R("upload/v1beta/files",l._url),body:JSON.stringify(l),httpMethod:"POST",httpOptions:o});if(!a||!(a!=null&&a.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const u=(n=a==null?void 0: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 Di(i){var e;if(i===void 0)throw new wt("response is undefined");if(!i.ok){const t=i.status,n=i.statusText;let o;!((e=i.headers.get("content-type"))===null||e===void 0)&&e.includes("application/json")?o=await i.json():o={error:{message:await i.text(),code:i.status,status:i.statusText}};const l=`got status: ${t} ${n}. ${JSON.stringify(o)}`;throw t>=400&&t<500?new ki(l):t>=500&&t<600?new wt(l):new Error(l)}}/**
|
|
170
|
+
* @license
|
|
171
|
+
* Copyright 2025 Google LLC
|
|
172
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
173
|
+
*/const ld="mcp_used/unknown";function Li(i){for(const e of i)if(Nt(e)||typeof e=="object"&&"inputSchema"in e)return!0;return!1}function Vi(i){var e;const t=(e=i[Rt])!==null&&e!==void 0?e:"";i[Rt]=(t+` ${ld}`).trimStart()}function ad(i){var e,t,n;return(n=(t=(e=i.config)===null||e===void 0?void 0:e.tools)===null||t===void 0?void 0:t.some(o=>Nt(o)))!==null&&n!==void 0?n:!1}function ud(i){var e,t,n;return(n=(t=(e=i.config)===null||e===void 0?void 0:e.tools)===null||t===void 0?void 0:t.some(o=>!Nt(o)))!==null&&n!==void 0?n:!1}function Nt(i){return i!==null&&typeof i=="object"&&i instanceof Pt}function cd(i,e=100){return we(this,arguments,function*(){let n,o=0;for(;o<e;){const l=yield $(i.listTools({cursor:n}));for(const a of l.tools)yield yield $(a),o++;if(!l.nextCursor)break;n=l.nextCursor}})}class Pt{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new Pt(e,t)}async initialize(){var e,t,n,o;if(this.mcpTools.length>0)return;const l={},a=[];for(const f of this.mcpClients)try{for(var u=!0,d=(t=void 0,qe(cd(f))),c;c=await d.next(),e=c.done,!e;u=!0){o=c.value,u=!1;const p=o;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){t={error:p}}finally{try{!u&&!e&&(n=d.return)&&await n.call(d)}finally{if(t)throw t.error}}this.mcpTools=a,this.functionNameToMcpClient=l}async tool(){return await this.initialize(),vr(this.mcpTools,this.config)}async callTool(e){await this.initialize();const t=[];for(const n of e)if(n.name in this.functionNameToMcpClient){const l=await this.functionNameToMcpClient[n.name].callTool({name:n.name,arguments:n.args});t.push({functionResponse:{name:n.name,response:l.isError?{error:l}:l}})}return t}}/**
|
|
174
|
+
* @license
|
|
175
|
+
* Copyright 2025 Google LLC
|
|
176
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
177
|
+
*/async function dd(i,e,t){const n=new rr;let o;t.data instanceof Blob?o=JSON.parse(await t.data.text()):o=JSON.parse(t.data);const l=Aa(i,o);Object.assign(n,l),e(n)}class fd{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){var t,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 o=this.apiClient.getWebsocketBaseUrl(),l=this.apiClient.getApiVersion(),a=hd(this.apiClient.getDefaultHeaders()),u=this.apiClient.getApiKey(),d=`${o}/ws/google.ai.generativelanguage.${l}.GenerativeService.BidiGenerateMusic?key=${u}`;let c=()=>{};const f=new Promise(N=>{c=N}),p=e.callbacks,m=function(){c({})},h=this.apiClient,g={onopen:m,onmessage:N=>{dd(h,p.onmessage,N)},onerror:(t=p==null?void 0:p.onerror)!==null&&t!==void 0?t:function(N){},onclose:(n=p==null?void 0:p.onclose)!==null&&n!==void 0?n:function(N){}},v=this.webSocketFactory.create(d,md(a),g);v.connect(),await f;const E=q(this.apiClient,e.model),I=Ti(this.apiClient,{model:E}),w=xt(this.apiClient,{setup:I});return v.send(JSON.stringify(w)),new pd(v,this.apiClient)}}class pd{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const t=Gl(this.apiClient,e),n=Ci(this.apiClient,t);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||(e.musicGenerationConfig={});const t=Bl(this.apiClient,e),n=xt(this.apiClient,t);this.conn.send(JSON.stringify(n))}sendPlaybackControl(e){const t=xt(this.apiClient,{playbackControl:e});this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(Me.PLAY)}pause(){this.sendPlaybackControl(Me.PAUSE)}stop(){this.sendPlaybackControl(Me.STOP)}resetContext(){this.sendPlaybackControl(Me.RESET_CONTEXT)}close(){this.conn.close()}}function md(i){const e={};return i.forEach((t,n)=>{e[n]=t}),e}function hd(i){const e=new Headers;for(const[t,n]of Object.entries(i))e.append(t,n);return e}/**
|
|
178
|
+
* @license
|
|
179
|
+
* Copyright 2025 Google LLC
|
|
180
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
181
|
+
*/const gd="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function yd(i,e,t){const n=new or;let o;if(t.data instanceof Blob?o=JSON.parse(await t.data.text()):o=JSON.parse(t.data),i.isVertexAI()){const l=ga(i,o);Object.assign(n,l)}else{const l=ha(i,o);Object.assign(n,l)}e(n)}class vd{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new fd(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var t,n,o,l,a,u;const d=this.apiClient.getWebsocketBaseUrl(),c=this.apiClient.getApiVersion();let f;const p=this.apiClient.getDefaultHeaders();e.config&&e.config.tools&&Li(e.config.tools)&&Vi(p);const m=Ed(p);if(this.apiClient.isVertexAI())f=`${d}/ws/google.cloud.aiplatform.${c}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(m);else{const L=this.apiClient.getApiKey();let B="BidiGenerateContent",Q="key";L!=null&&L.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),B="BidiGenerateContentConstrained",Q="access_token"),f=`${d}/ws/google.ai.generativelanguage.${c}.GenerativeService.${B}?${Q}=${L}`}let h=()=>{};const g=new Promise(L=>{h=L}),v=e.callbacks,E=function(){var L;(L=v==null?void 0:v.onopen)===null||L===void 0||L.call(v),h({})},I=this.apiClient,w={onopen:E,onmessage:L=>{yd(I,v.onmessage,L)},onerror:(t=v==null?void 0:v.onerror)!==null&&t!==void 0?t:function(L){},onclose:(n=v==null?void 0:v.onclose)!==null&&n!==void 0?n:function(L){}},N=this.webSocketFactory.create(f,_d(m),w);N.connect(),await g;let F=q(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&F.startsWith("publishers/")){const L=this.apiClient.getProject(),B=this.apiClient.getLocation();F=`projects/${L}/locations/${B}/`+F}let x={};this.apiClient.isVertexAI()&&((o=e.config)===null||o===void 0?void 0:o.responseModalities)===void 0&&(e.config===void 0?e.config={responseModalities:[Xe.AUDIO]}:e.config.responseModalities=[Xe.AUDIO]),!((l=e.config)===null||l===void 0)&&l.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const M=(u=(a=e.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[],k=[];for(const L of M)if(this.isCallableTool(L)){const B=L;k.push(await B.tool())}else k.push(L);k.length>0&&(e.config.tools=k);const O={model:F,config:e.config,callbacks:e.callbacks};return this.apiClient.isVertexAI()?x=kl(this.apiClient,O):x=Pl(this.apiClient,O),delete x.config,N.send(JSON.stringify(x)),new Cd(N,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool=="function"}}const Td={turnComplete:!0};class Cd{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(t.turns!==null&&t.turns!==void 0){let n=[];try{n=te(e,t.turns),e.isVertexAI()?n=n.map(o=>Ne(e,o)):n=n.map(o=>st(e,o))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(t.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(t.functionResponses)?n=t.functionResponses:n=[t.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(!e.isVertexAI()&&!("id"in l))throw new Error(gd)}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Td),e);const t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};this.apiClient.isVertexAI()?t={realtimeInput:bl(this.apiClient,e)}:t={realtimeInput:Ul(this.apiClient,e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(e.functionResponses==null)throw new Error("Tool response parameters are required.");const t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function _d(i){const e={};return i.forEach((t,n)=>{e[n]=t}),e}function Ed(i){const e=new Headers;for(const[t,n]of Object.entries(i))e.append(t,n);return e}/**
|
|
182
|
+
* @license
|
|
183
|
+
* Copyright 2025 Google LLC
|
|
184
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
185
|
+
*/const Fi=10;function Ui(i){var e,t,n;if(!((e=i==null?void 0:i.automaticFunctionCalling)===null||e===void 0)&&e.disable)return!0;let o=!1;for(const a of(t=i==null?void 0:i.tools)!==null&&t!==void 0?t:[])if(lt(a)){o=!0;break}if(!o)return!0;const l=(n=i==null?void 0:i.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 lt(i){return"callTool"in i&&typeof i.callTool=="function"}function bi(i){var e;return!(!((e=i==null?void 0:i.automaticFunctionCalling)===null||e===void 0)&&e.ignoreCallHistory)}/**
|
|
186
|
+
* @license
|
|
187
|
+
* Copyright 2025 Google LLC
|
|
188
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
189
|
+
*/class xd extends Ae{constructor(e){super(),this.apiClient=e,this.generateContent=async t=>{var n,o,l,a,u;const d=await this.processParamsForMcpUsage(t);if(!ad(t)||Ui(t.config))return await this.generateContentInternal(d);if(ud(t))throw new Error("Automatic function calling with CallableTools and Tools is not yet supported.");let c,f;const p=te(this.apiClient,d.contents),m=(l=(o=(n=d.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||o===void 0?void 0:o.maximumRemoteCalls)!==null&&l!==void 0?l:Fi;let h=0;for(;h<m&&(c=await this.generateContentInternal(d),!(!c.functionCalls||c.functionCalls.length===0));){const g=c.candidates[0].content,v=[];for(const E of(u=(a=t.config)===null||a===void 0?void 0:a.tools)!==null&&u!==void 0?u:[])if(lt(E)){const w=await E.callTool(c.functionCalls);v.push(...w)}h++,f={role:"user",parts:v},d.contents=te(this.apiClient,d.contents),d.contents.push(g),d.contents.push(f),bi(d.config)&&(p.push(g),p.push(f))}return bi(d.config)&&(c.automaticFunctionCallingHistory=p),c},this.generateContentStream=async t=>{if(Ui(t.config)){const n=await this.processParamsForMcpUsage(t);return await this.generateContentStreamInternal(n)}else return await this.processAfcStream(t)},this.generateImages=async t=>await this.generateImagesInternal(t).then(n=>{var o;let l;const a=[];if(n!=null&&n.generatedImages)for(const d of n.generatedImages)d&&(d!=null&&d.safetyAttributes)&&((o=d==null?void 0:d.safetyAttributes)===null||o===void 0?void 0:o.contentType)==="Positive Prompt"?l=d==null?void 0:d.safetyAttributes:a.push(d);let u;return l?u={generatedImages:a,positivePromptSafetyAttributes:l}:u={generatedImages:a},u}),this.list=async t=>{var n;const a={config:Object.assign(Object.assign({},{queryBase:!0}),t==null?void 0:t.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 it(Re.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(a),a)},this.editImage=async t=>{const n={model:t.model,prompt:t.prompt,referenceImages:[],config:t.config};return t.referenceImages&&t.referenceImages&&(n.referenceImages=t.referenceImages.map(o=>o.toReferenceImageAPI())),await this.editImageInternal(n)},this.upscaleImage=async t=>{let n={numberOfImages:1,mode:"upscale"};t.config&&(n=Object.assign(Object.assign({},n),t.config));const o={model:t.model,image:t.image,upscaleFactor:t.upscaleFactor,config:n};return await this.upscaleImageInternal(o)}}async processParamsForMcpUsage(e){var t,n,o;const l=(t=e.config)===null||t===void 0?void 0:t.tools;if(!l)return e;const a=await Promise.all(l.map(async d=>lt(d)?await d.tool():d)),u={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:a})};if(u.config.tools=a,e.config&&e.config.tools&&Li(e.config.tools)){const d=(o=(n=e.config.httpOptions)===null||n===void 0?void 0:n.headers)!==null&&o!==void 0?o:{};let c=Object.assign({},d);Object.keys(c).length===0&&(c=this.apiClient.getDefaultHeaders()),Vi(c),u.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:c})}return u}async initAfcToolsMap(e){var t,n,o;const l=new Map;for(const a of(n=(t=e.config)===null||t===void 0?void 0:t.tools)!==null&&n!==void 0?n:[])if(lt(a)){const u=a,d=await u.tool();for(const c of(o=d.functionDeclarations)!==null&&o!==void 0?o:[]){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(e){var t,n,o;const l=(o=(n=(t=e.config)===null||t===void 0?void 0:t.automaticFunctionCalling)===null||n===void 0?void 0:n.maximumRemoteCalls)!==null&&o!==void 0?o:Fi;let a=!1,u=0;const d=await this.initAfcToolsMap(e);return(function(c,f,p){var m,h;return we(this,arguments,function*(){for(var g,v,E,I;u<l;){a&&(u++,a=!1);const x=yield $(c.processParamsForMcpUsage(p)),M=yield $(c.generateContentStreamInternal(x)),k=[],O=[];try{for(var w=!0,N=(v=void 0,qe(M)),F;F=yield $(N.next()),g=F.done,!g;w=!0){I=F.value,w=!1;const L=I;if(yield yield $(L),L.candidates&&(!((m=L.candidates[0])===null||m===void 0)&&m.content)){O.push(L.candidates[0].content);for(const B of(h=L.candidates[0].content.parts)!==null&&h!==void 0?h:[])if(u<l&&B.functionCall){if(!B.functionCall.name)throw new Error("Function call name was not returned by the model.");if(f.has(B.functionCall.name)){const Q=yield $(f.get(B.functionCall.name).callTool([B.functionCall]));k.push(...Q)}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: ${B.functionCall.name}`)}}}}catch(L){v={error:L}}finally{try{!w&&!g&&(E=N.return)&&(yield $(E.call(N)))}finally{if(v)throw v.error}}if(k.length>0){a=!0;const L=new be;L.candidates=[{content:{role:"user",parts:k}}],yield yield $(L);const B=[];B.push(...O),B.push({role:"user",parts:k});const Q=te(c.apiClient,p.contents).concat(B);p.contents=Q}else break}})})(this,d,e)}async generateContentInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Mi(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=wi(this.apiClient,f),m=new be;return Object.assign(m,p),m})}else{const c=Si(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Ii(this.apiClient,f),m=new be;return Object.assign(m,p),m})}}async generateContentStreamInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Mi(this.apiClient,e);u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}),a.then(function(p){return we(this,arguments,function*(){var m,h,g,v;try{for(var E=!0,I=qe(p),w;w=yield $(I.next()),m=w.done,!m;E=!0){v=w.value,E=!1;const F=wi(f,yield $(v.json())),x=new be;Object.assign(x,F),yield yield $(x)}}catch(N){h={error:N}}finally{try{!E&&!m&&(g=I.return)&&(yield $(g.call(I)))}finally{if(h)throw h.error}}})})}else{const c=Si(this.apiClient,e);u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}),a.then(function(p){return we(this,arguments,function*(){var m,h,g,v;try{for(var E=!0,I=qe(p),w;w=yield $(I.next()),m=w.done,!m;E=!0){v=w.value,E=!1;const F=Ii(f,yield $(v.json())),x=new be;Object.assign(x,F),yield yield $(x)}}catch(N){h={error:N}}finally{try{!E&&!m&&(g=I.return)&&(yield $(g.call(I)))}finally{if(h)throw h.error}}})})}}async embedContent(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Fu(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=bc(this.apiClient,f),m=new $n;return Object.assign(m,p),m})}else{const c=Ka(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=gc(this.apiClient,f),m=new $n;return Object.assign(m,p),m})}}async generateImagesInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=bu(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Bc(this.apiClient,f),m=new On;return Object.assign(m,p),m})}else{const c=Qa(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Tc(this.apiClient,f),m=new On;return Object.assign(m,p),m})}}async editImageInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI()){const u=Ju(this.apiClient,e);return l=R("{model}:predict",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>{const c=qc(this.apiClient,d),f=new Qo;return Object.assign(f,c),f})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI()){const u=Yu(this.apiClient,e);return l=R("{model}:predict",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>{const c=$c(this.apiClient,d),f=new jo;return Object.assign(f,c),f})}else throw new Error("This method is only supported by the Vertex AI.")}async get(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=zu(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>It(this.apiClient,f))}else{const c=ja(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>At(this.apiClient,f))}}async listInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Ku(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Wc(this.apiClient,f),m=new Hn;return Object.assign(m,p),m})}else{const c=tu(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=_c(this.apiClient,f),m=new Hn;return Object.assign(m,p),m})}}async update(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Qu(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>It(this.apiClient,f))}else{const c=iu(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>At(this.apiClient,f))}}async delete(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=ju(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(()=>{const f=Yc(),p=new Jn;return Object.assign(p,f),p})}else{const c=ou(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(()=>{const f=Ec(),p=new Jn;return Object.assign(p,f),p})}}async countTokens(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=tc(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=zc(this.apiClient,f),m=new Wn;return Object.assign(m,p),m})}else{const c=su(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=xc(this.apiClient,f),m=new Wn;return Object.assign(m,p),m})}}async computeTokens(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI()){const u=nc(this.apiClient,e);return l=R("{model}:computeTokens",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>{const c=Zc(this.apiClient,d),f=new er;return Object.assign(f,c),f})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideos(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=oc(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>jc(this.apiClient,f))}else{const c=uu(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Ic(this.apiClient,f))}}}/**
|
|
190
|
+
* @license
|
|
191
|
+
* Copyright 2025 Google LLC
|
|
192
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
193
|
+
*/function Sd(i,e){const t={},n=r(e,["operationName"]);n!=null&&s(t,["_url","operationName"],n);const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Ad(i,e){const t={},n=r(e,["operationName"]);n!=null&&s(t,["_url","operationName"],n);const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Md(i,e){const t={},n=r(e,["operationName"]);n!=null&&s(t,["operationName"],n);const o=r(e,["resourceName"]);o!=null&&s(t,["_url","resourceName"],o);const l=r(e,["config"]);return l!=null&&s(t,["config"],l),t}function Id(i,e){const t={},n=r(e,["video","uri"]);n!=null&&s(t,["uri"],n);const o=r(e,["video","encodedVideo"]);o!=null&&s(t,["videoBytes"],de(i,o));const l=r(e,["encoding"]);return l!=null&&s(t,["mimeType"],l),t}function Rd(i,e){const t={},n=r(e,["_self"]);return n!=null&&s(t,["video"],Id(i,n)),t}function wd(i,e){const t={},n=r(e,["generatedSamples"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>Rd(i,u))),s(t,["generatedVideos"],a)}const o=r(e,["raiMediaFilteredCount"]);o!=null&&s(t,["raiMediaFilteredCount"],o);const l=r(e,["raiMediaFilteredReasons"]);return l!=null&&s(t,["raiMediaFilteredReasons"],l),t}function Nd(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["metadata"]);o!=null&&s(t,["metadata"],o);const l=r(e,["done"]);l!=null&&s(t,["done"],l);const a=r(e,["error"]);a!=null&&s(t,["error"],a);const u=r(e,["response","generateVideoResponse"]);return u!=null&&s(t,["response"],wd(i,u)),t}function Pd(i,e){const t={},n=r(e,["gcsUri"]);n!=null&&s(t,["uri"],n);const o=r(e,["bytesBase64Encoded"]);o!=null&&s(t,["videoBytes"],de(i,o));const l=r(e,["mimeType"]);return l!=null&&s(t,["mimeType"],l),t}function kd(i,e){const t={},n=r(e,["_self"]);return n!=null&&s(t,["video"],Pd(i,n)),t}function Dd(i,e){const t={},n=r(e,["videos"]);if(n!=null){let a=n;Array.isArray(a)&&(a=a.map(u=>kd(i,u))),s(t,["generatedVideos"],a)}const o=r(e,["raiMediaFilteredCount"]);o!=null&&s(t,["raiMediaFilteredCount"],o);const l=r(e,["raiMediaFilteredReasons"]);return l!=null&&s(t,["raiMediaFilteredReasons"],l),t}function Gi(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["metadata"]);o!=null&&s(t,["metadata"],o);const l=r(e,["done"]);l!=null&&s(t,["done"],l);const a=r(e,["error"]);a!=null&&s(t,["error"],a);const u=r(e,["response"]);return u!=null&&s(t,["response"],Dd(i,u)),t}/**
|
|
194
|
+
* @license
|
|
195
|
+
* Copyright 2025 Google LLC
|
|
196
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
197
|
+
*/class Ld extends Ae{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){const t=e.operation,n=e.config;if(t.name===void 0||t.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const o=t.name.split("/operations/")[0];let l;return n&&"httpOptions"in n&&(l=n.httpOptions),this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:o,config:{httpOptions:l}})}else return this.getVideosOperationInternal({operationName:t.name,config:n})}async getVideosOperationInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Ad(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>Gi(this.apiClient,f))}else{const c=Sd(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>Nd(this.apiClient,f))}}async fetchPredictVideosOperationInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI()){const u=Md(this.apiClient,e);return l=R("{resourceName}:fetchPredictOperation",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>Gi(this.apiClient,d))}else throw new Error("This method is only supported by the Vertex AI.")}}/**
|
|
198
|
+
* @license
|
|
199
|
+
* Copyright 2025 Google LLC
|
|
200
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
201
|
+
*/function Vd(i,e){const t={},n=r(e,["voiceName"]);return n!=null&&s(t,["voiceName"],n),t}function Bi(i,e){const t={},n=r(e,["prebuiltVoiceConfig"]);return n!=null&&s(t,["prebuiltVoiceConfig"],Vd(i,n)),t}function Fd(i,e){const t={},n=r(e,["speaker"]);n!=null&&s(t,["speaker"],n);const o=r(e,["voiceConfig"]);return o!=null&&s(t,["voiceConfig"],Bi(i,o)),t}function Ud(i,e){const t={},n=r(e,["speakerVoiceConfigs"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>Fd(i,l))),s(t,["speakerVoiceConfigs"],o)}return t}function bd(i,e){const t={},n=r(e,["voiceConfig"]);n!=null&&s(t,["voiceConfig"],Bi(i,n));const o=r(e,["multiSpeakerVoiceConfig"]);o!=null&&s(t,["multiSpeakerVoiceConfig"],Ud(i,o));const l=r(e,["languageCode"]);return l!=null&&s(t,["languageCode"],l),t}function Gd(i,e){const t={},n=r(e,["fps"]);n!=null&&s(t,["fps"],n);const o=r(e,["endOffset"]);o!=null&&s(t,["endOffset"],o);const l=r(e,["startOffset"]);return l!=null&&s(t,["startOffset"],l),t}function Bd(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["data"]);n!=null&&s(t,["data"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function qd(i,e){const t={};if(r(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=r(e,["fileUri"]);n!=null&&s(t,["fileUri"],n);const o=r(e,["mimeType"]);return o!=null&&s(t,["mimeType"],o),t}function $d(i,e){const t={},n=r(e,["videoMetadata"]);n!=null&&s(t,["videoMetadata"],Gd(i,n));const o=r(e,["thought"]);o!=null&&s(t,["thought"],o);const l=r(e,["inlineData"]);l!=null&&s(t,["inlineData"],Bd(i,l));const a=r(e,["fileData"]);a!=null&&s(t,["fileData"],qd(i,a));const u=r(e,["thoughtSignature"]);u!=null&&s(t,["thoughtSignature"],u);const d=r(e,["codeExecutionResult"]);d!=null&&s(t,["codeExecutionResult"],d);const c=r(e,["executableCode"]);c!=null&&s(t,["executableCode"],c);const f=r(e,["functionCall"]);f!=null&&s(t,["functionCall"],f);const p=r(e,["functionResponse"]);p!=null&&s(t,["functionResponse"],p);const m=r(e,["text"]);return m!=null&&s(t,["text"],m),t}function Od(i,e){const t={},n=r(e,["parts"]);if(n!=null){let l=n;Array.isArray(l)&&(l=l.map(a=>$d(i,a))),s(t,["parts"],l)}const o=r(e,["role"]);return o!=null&&s(t,["role"],o),t}function Hd(i,e){const t={},n=r(e,["behavior"]);n!=null&&s(t,["behavior"],n);const o=r(e,["description"]);o!=null&&s(t,["description"],o);const l=r(e,["name"]);l!=null&&s(t,["name"],l);const a=r(e,["parameters"]);a!=null&&s(t,["parameters"],a);const u=r(e,["response"]);return u!=null&&s(t,["response"],u),t}function Jd(i,e){const t={},n=r(e,["startTime"]);n!=null&&s(t,["startTime"],n);const o=r(e,["endTime"]);return o!=null&&s(t,["endTime"],o),t}function Wd(i,e){const t={},n=r(e,["timeRangeFilter"]);return n!=null&&s(t,["timeRangeFilter"],Jd(i,n)),t}function Yd(i,e){const t={},n=r(e,["mode"]);n!=null&&s(t,["mode"],n);const o=r(e,["dynamicThreshold"]);return o!=null&&s(t,["dynamicThreshold"],o),t}function zd(i,e){const t={},n=r(e,["dynamicRetrievalConfig"]);return n!=null&&s(t,["dynamicRetrievalConfig"],Yd(i,n)),t}function Zd(){return{}}function Kd(i,e){const t={},n=r(e,["functionDeclarations"]);if(n!=null){let d=n;Array.isArray(d)&&(d=d.map(c=>Hd(i,c))),s(t,["functionDeclarations"],d)}if(r(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=r(e,["googleSearch"]);o!=null&&s(t,["googleSearch"],Wd(i,o));const l=r(e,["googleSearchRetrieval"]);if(l!=null&&s(t,["googleSearchRetrieval"],zd(i,l)),r(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");if(r(e,["googleMaps"])!==void 0)throw new Error("googleMaps parameter is not supported in Gemini API.");r(e,["urlContext"])!=null&&s(t,["urlContext"],Zd());const u=r(e,["codeExecution"]);return u!=null&&s(t,["codeExecution"],u),t}function Xd(i,e){const t={},n=r(e,["handle"]);if(n!=null&&s(t,["handle"],n),r(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function qi(){return{}}function Qd(i,e){const t={},n=r(e,["disabled"]);n!=null&&s(t,["disabled"],n);const o=r(e,["startOfSpeechSensitivity"]);o!=null&&s(t,["startOfSpeechSensitivity"],o);const l=r(e,["endOfSpeechSensitivity"]);l!=null&&s(t,["endOfSpeechSensitivity"],l);const a=r(e,["prefixPaddingMs"]);a!=null&&s(t,["prefixPaddingMs"],a);const u=r(e,["silenceDurationMs"]);return u!=null&&s(t,["silenceDurationMs"],u),t}function jd(i,e){const t={},n=r(e,["automaticActivityDetection"]);n!=null&&s(t,["automaticActivityDetection"],Qd(i,n));const o=r(e,["activityHandling"]);o!=null&&s(t,["activityHandling"],o);const l=r(e,["turnCoverage"]);return l!=null&&s(t,["turnCoverage"],l),t}function ef(i,e){const t={},n=r(e,["targetTokens"]);return n!=null&&s(t,["targetTokens"],n),t}function tf(i,e){const t={},n=r(e,["triggerTokens"]);n!=null&&s(t,["triggerTokens"],n);const o=r(e,["slidingWindow"]);return o!=null&&s(t,["slidingWindow"],ef(i,o)),t}function nf(i,e){const t={},n=r(e,["proactiveAudio"]);return n!=null&&s(t,["proactiveAudio"],n),t}function of(i,e,t){const n={},o=r(e,["generationConfig"]);t!==void 0&&o!=null&&s(t,["setup","generationConfig"],o);const l=r(e,["responseModalities"]);t!==void 0&&l!=null&&s(t,["setup","generationConfig","responseModalities"],l);const a=r(e,["temperature"]);t!==void 0&&a!=null&&s(t,["setup","generationConfig","temperature"],a);const u=r(e,["topP"]);t!==void 0&&u!=null&&s(t,["setup","generationConfig","topP"],u);const d=r(e,["topK"]);t!==void 0&&d!=null&&s(t,["setup","generationConfig","topK"],d);const c=r(e,["maxOutputTokens"]);t!==void 0&&c!=null&&s(t,["setup","generationConfig","maxOutputTokens"],c);const f=r(e,["mediaResolution"]);t!==void 0&&f!=null&&s(t,["setup","generationConfig","mediaResolution"],f);const p=r(e,["seed"]);t!==void 0&&p!=null&&s(t,["setup","generationConfig","seed"],p);const m=r(e,["speechConfig"]);t!==void 0&&m!=null&&s(t,["setup","generationConfig","speechConfig"],bd(i,_t(i,m)));const h=r(e,["enableAffectiveDialog"]);t!==void 0&&h!=null&&s(t,["setup","generationConfig","enableAffectiveDialog"],h);const g=r(e,["systemInstruction"]);t!==void 0&&g!=null&&s(t,["setup","systemInstruction"],Od(i,X(i,g)));const v=r(e,["tools"]);if(t!==void 0&&v!=null){let M=Be(i,v);Array.isArray(M)&&(M=M.map(k=>Kd(i,Ge(i,k)))),s(t,["setup","tools"],M)}const E=r(e,["sessionResumption"]);t!==void 0&&E!=null&&s(t,["setup","sessionResumption"],Xd(i,E));const I=r(e,["inputAudioTranscription"]);t!==void 0&&I!=null&&s(t,["setup","inputAudioTranscription"],qi());const w=r(e,["outputAudioTranscription"]);t!==void 0&&w!=null&&s(t,["setup","outputAudioTranscription"],qi());const N=r(e,["realtimeInputConfig"]);t!==void 0&&N!=null&&s(t,["setup","realtimeInputConfig"],jd(i,N));const F=r(e,["contextWindowCompression"]);t!==void 0&&F!=null&&s(t,["setup","contextWindowCompression"],tf(i,F));const x=r(e,["proactivity"]);return t!==void 0&&x!=null&&s(t,["setup","proactivity"],nf(i,x)),n}function rf(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["setup","model"],q(i,n));const o=r(e,["config"]);return o!=null&&s(t,["config"],of(i,o,t)),t}function sf(i,e,t){const n={},o=r(e,["expireTime"]);t!==void 0&&o!=null&&s(t,["expireTime"],o);const l=r(e,["newSessionExpireTime"]);t!==void 0&&l!=null&&s(t,["newSessionExpireTime"],l);const a=r(e,["uses"]);t!==void 0&&a!=null&&s(t,["uses"],a);const u=r(e,["liveConnectConstraints"]);t!==void 0&&u!=null&&s(t,["bidiGenerateContentSetup"],rf(i,u));const d=r(e,["lockAdditionalFields"]);return t!==void 0&&d!=null&&s(t,["fieldMask"],d),n}function lf(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],sf(i,n,t)),t}function af(i,e){const t={},n=r(e,["name"]);return n!=null&&s(t,["name"],n),t}/**
|
|
202
|
+
* @license
|
|
203
|
+
* Copyright 2025 Google LLC
|
|
204
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
205
|
+
*/function uf(i){const e=[];for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const n=i[t];if(typeof n=="object"&&n!=null&&Object.keys(n).length>0){const o=Object.keys(n).map(l=>`${t}.${l}`);e.push(...o)}else e.push(t)}return e.join(",")}function cf(i,e){let t=null;const n=i.bidiGenerateContentSetup;if(typeof n=="object"&&n!==null&&"setup"in n){const l=n.setup;typeof l=="object"&&l!==null?(i.bidiGenerateContentSetup=l,t=l):delete i.bidiGenerateContentSetup}else n!==void 0&&delete i.bidiGenerateContentSetup;const o=i.fieldMask;if(t){const l=uf(t);if(Array.isArray(e==null?void 0:e.lockAdditionalFields)&&(e==null?void 0:e.lockAdditionalFields.length)===0)l?i.fieldMask=l:delete i.fieldMask;else if(e!=null&&e.lockAdditionalFields&&e.lockAdditionalFields.length>0&&o!==null&&Array.isArray(o)&&o.length>0){const a=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];o.length>0&&(u=o.map(c=>a.includes(c)?`generationConfig.${c}`:c));const d=[];l&&d.push(l),u.length>0&&d.push(...u),d.length>0?i.fieldMask=d.join(","):delete i.fieldMask}else delete i.fieldMask}else o!==null&&Array.isArray(o)&&o.length>0?i.fieldMask=o.join(","):delete i.fieldMask;return i}class df extends Ae{constructor(e){super(),this.apiClient=e}async create(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=lf(this.apiClient,e);l=R("auth_tokens",u._url),a=u._query,delete u.config,delete u._url,delete u._query;const d=cf(u,e.config);return o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(d),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(c=>c.json()),o.then(c=>af(this.apiClient,c))}}}/**
|
|
206
|
+
* @license
|
|
207
|
+
* Copyright 2025 Google LLC
|
|
208
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
209
|
+
*/function ff(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],n);const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function pf(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);t!==void 0&&l!=null&&s(t,["_query","pageToken"],l);const a=r(e,["filter"]);return t!==void 0&&a!=null&&s(t,["_query","filter"],a),n}function mf(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],pf(i,n,t)),t}function hf(i,e){const t={},n=r(e,["textInput"]);n!=null&&s(t,["textInput"],n);const o=r(e,["output"]);return o!=null&&s(t,["output"],o),t}function gf(i,e){const t={};if(r(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=r(e,["examples"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(l=>hf(i,l))),s(t,["examples","examples"],o)}return t}function yf(i,e,t){const n={};if(r(e,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const o=r(e,["tunedModelDisplayName"]);if(t!==void 0&&o!=null&&s(t,["displayName"],o),r(e,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const l=r(e,["epochCount"]);t!==void 0&&l!=null&&s(t,["tuningTask","hyperparameters","epochCount"],l);const a=r(e,["learningRateMultiplier"]);if(a!=null&&s(n,["tuningTask","hyperparameters","learningRateMultiplier"],a),r(e,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(r(e,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const u=r(e,["batchSize"]);t!==void 0&&u!=null&&s(t,["tuningTask","hyperparameters","batchSize"],u);const d=r(e,["learningRate"]);return t!==void 0&&d!=null&&s(t,["tuningTask","hyperparameters","learningRate"],d),n}function vf(i,e){const t={},n=r(e,["baseModel"]);n!=null&&s(t,["baseModel"],n);const o=r(e,["trainingDataset"]);o!=null&&s(t,["tuningTask","trainingData"],gf(i,o));const l=r(e,["config"]);return l!=null&&s(t,["config"],yf(i,l,t)),t}function Tf(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["_url","name"],n);const o=r(e,["config"]);return o!=null&&s(t,["config"],o),t}function Cf(i,e,t){const n={},o=r(e,["pageSize"]);t!==void 0&&o!=null&&s(t,["_query","pageSize"],o);const l=r(e,["pageToken"]);t!==void 0&&l!=null&&s(t,["_query","pageToken"],l);const a=r(e,["filter"]);return t!==void 0&&a!=null&&s(t,["_query","filter"],a),n}function _f(i,e){const t={},n=r(e,["config"]);return n!=null&&s(t,["config"],Cf(i,n,t)),t}function Ef(i,e,t){const n={},o=r(e,["gcsUri"]);if(t!==void 0&&o!=null&&s(t,["supervisedTuningSpec","trainingDatasetUri"],o),r(e,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return n}function xf(i,e){const t={},n=r(e,["gcsUri"]);return n!=null&&s(t,["validationDatasetUri"],n),t}function Sf(i,e,t){const n={},o=r(e,["validationDataset"]);t!==void 0&&o!=null&&s(t,["supervisedTuningSpec"],xf(i,o));const l=r(e,["tunedModelDisplayName"]);t!==void 0&&l!=null&&s(t,["tunedModelDisplayName"],l);const a=r(e,["description"]);t!==void 0&&a!=null&&s(t,["description"],a);const u=r(e,["epochCount"]);t!==void 0&&u!=null&&s(t,["supervisedTuningSpec","hyperParameters","epochCount"],u);const d=r(e,["learningRateMultiplier"]);t!==void 0&&d!=null&&s(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],d);const c=r(e,["exportLastCheckpointOnly"]);t!==void 0&&c!=null&&s(t,["supervisedTuningSpec","exportLastCheckpointOnly"],c);const f=r(e,["adapterSize"]);if(t!==void 0&&f!=null&&s(t,["supervisedTuningSpec","hyperParameters","adapterSize"],f),r(e,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(r(e,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");return n}function Af(i,e){const t={},n=r(e,["baseModel"]);n!=null&&s(t,["baseModel"],n);const o=r(e,["trainingDataset"]);o!=null&&s(t,["supervisedTuningSpec","trainingDatasetUri"],Ef(i,o,t));const l=r(e,["config"]);return l!=null&&s(t,["config"],Sf(i,l,t)),t}function Mf(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["model"],n);const o=r(e,["name"]);return o!=null&&s(t,["endpoint"],o),t}function $i(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["state"]);o!=null&&s(t,["state"],ri(i,o));const l=r(e,["createTime"]);l!=null&&s(t,["createTime"],l);const a=r(e,["tuningTask","startTime"]);a!=null&&s(t,["startTime"],a);const u=r(e,["tuningTask","completeTime"]);u!=null&&s(t,["endTime"],u);const d=r(e,["updateTime"]);d!=null&&s(t,["updateTime"],d);const c=r(e,["description"]);c!=null&&s(t,["description"],c);const f=r(e,["baseModel"]);f!=null&&s(t,["baseModel"],f);const p=r(e,["_self"]);p!=null&&s(t,["tunedModel"],Mf(i,p));const m=r(e,["distillationSpec"]);m!=null&&s(t,["distillationSpec"],m);const h=r(e,["experiment"]);h!=null&&s(t,["experiment"],h);const g=r(e,["labels"]);g!=null&&s(t,["labels"],g);const v=r(e,["pipelineJob"]);v!=null&&s(t,["pipelineJob"],v);const E=r(e,["serviceAccount"]);E!=null&&s(t,["serviceAccount"],E);const I=r(e,["tunedModelDisplayName"]);return I!=null&&s(t,["tunedModelDisplayName"],I),t}function If(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["tunedModels"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>$i(i,a))),s(t,["tuningJobs"],l)}return t}function Rf(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["metadata"]);o!=null&&s(t,["metadata"],o);const l=r(e,["done"]);l!=null&&s(t,["done"],l);const a=r(e,["error"]);return a!=null&&s(t,["error"],a),t}function wf(i,e){const t={},n=r(e,["checkpointId"]);n!=null&&s(t,["checkpointId"],n);const o=r(e,["epoch"]);o!=null&&s(t,["epoch"],o);const l=r(e,["step"]);l!=null&&s(t,["step"],l);const a=r(e,["endpoint"]);return a!=null&&s(t,["endpoint"],a),t}function Nf(i,e){const t={},n=r(e,["model"]);n!=null&&s(t,["model"],n);const o=r(e,["endpoint"]);o!=null&&s(t,["endpoint"],o);const l=r(e,["checkpoints"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>wf(i,u))),s(t,["checkpoints"],a)}return t}function kt(i,e){const t={},n=r(e,["name"]);n!=null&&s(t,["name"],n);const o=r(e,["state"]);o!=null&&s(t,["state"],ri(i,o));const l=r(e,["createTime"]);l!=null&&s(t,["createTime"],l);const a=r(e,["startTime"]);a!=null&&s(t,["startTime"],a);const u=r(e,["endTime"]);u!=null&&s(t,["endTime"],u);const d=r(e,["updateTime"]);d!=null&&s(t,["updateTime"],d);const c=r(e,["error"]);c!=null&&s(t,["error"],c);const f=r(e,["description"]);f!=null&&s(t,["description"],f);const p=r(e,["baseModel"]);p!=null&&s(t,["baseModel"],p);const m=r(e,["tunedModel"]);m!=null&&s(t,["tunedModel"],Nf(i,m));const h=r(e,["supervisedTuningSpec"]);h!=null&&s(t,["supervisedTuningSpec"],h);const g=r(e,["tuningDataStats"]);g!=null&&s(t,["tuningDataStats"],g);const v=r(e,["encryptionSpec"]);v!=null&&s(t,["encryptionSpec"],v);const E=r(e,["partnerModelTuningSpec"]);E!=null&&s(t,["partnerModelTuningSpec"],E);const I=r(e,["distillationSpec"]);I!=null&&s(t,["distillationSpec"],I);const w=r(e,["experiment"]);w!=null&&s(t,["experiment"],w);const N=r(e,["labels"]);N!=null&&s(t,["labels"],N);const F=r(e,["pipelineJob"]);F!=null&&s(t,["pipelineJob"],F);const x=r(e,["serviceAccount"]);x!=null&&s(t,["serviceAccount"],x);const M=r(e,["tunedModelDisplayName"]);return M!=null&&s(t,["tunedModelDisplayName"],M),t}function Pf(i,e){const t={},n=r(e,["nextPageToken"]);n!=null&&s(t,["nextPageToken"],n);const o=r(e,["tuningJobs"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(a=>kt(i,a))),s(t,["tuningJobs"],l)}return t}/**
|
|
210
|
+
* @license
|
|
211
|
+
* Copyright 2025 Google LLC
|
|
212
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
213
|
+
*/class kf extends Ae{constructor(e){super(),this.apiClient=e,this.get=async t=>await this.getInternal(t),this.list=async(t={})=>new it(Re.PAGED_ITEM_TUNING_JOBS,n=>this.listInternal(n),await this.listInternal(t),t),this.tune=async t=>{if(this.apiClient.isVertexAI())return await this.tuneInternal(t);{const n=await this.tuneMldevInternal(t);let o="";return n.metadata!==void 0&&n.metadata.tunedModel!==void 0?o=n.metadata.tunedModel:n.name!==void 0&&n.name.includes("/operations/")&&(o=n.name.split("/operations/")[0]),{name:o,state:vt.JOB_STATE_QUEUED}}}}async getInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=Tf(this.apiClient,e);return u=R("{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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>kt(this.apiClient,f))}else{const c=ff(this.apiClient,e);return u=R("{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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>$i(this.apiClient,f))}}async listInternal(e){var t,n,o,l;let a,u="",d={};if(this.apiClient.isVertexAI()){const c=_f(this.apiClient,e);return u=R("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:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(f=>f.json()),a.then(f=>{const p=Pf(this.apiClient,f),m=new Yn;return Object.assign(m,p),m})}else{const c=mf(this.apiClient,e);return u=R("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:(o=e.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=e.config)===null||l===void 0?void 0:l.abortSignal}).then(f=>f.json()),a.then(f=>{const p=If(this.apiClient,f),m=new Yn;return Object.assign(m,p),m})}}async tuneInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI()){const u=Af(this.apiClient,e);return l=R("tuningJobs",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>kt(this.apiClient,d))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var t,n;let o,l="",a={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=vf(this.apiClient,e);return l=R("tunedModels",u._url),a=u._query,delete u.config,delete u._url,delete u._query,o=this.apiClient.request({path:l,queryParams:a,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(t=e.config)===null||t===void 0?void 0:t.httpOptions,abortSignal:(n=e.config)===null||n===void 0?void 0:n.abortSignal}).then(d=>d.json()),o.then(d=>Rf(this.apiClient,d))}}}/**
|
|
214
|
+
* @license
|
|
215
|
+
* Copyright 2025 Google LLC
|
|
216
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
217
|
+
*/class Df{async download(e,t){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}const Lf=1024*1024*8,Vf=3,Ff=1e3,Uf=2,Dt="x-goog-upload-status";async function bf(i,e,t){var n,o,l;let a=0,u=0,d=new Tt(new Response),c="upload";for(a=i.size;u<a;){const p=Math.min(Lf,a-u),m=i.slice(u,u+p);u+p>=a&&(c+=", finalize");let h=0,g=Ff;for(;h<Vf&&(d=await t.request({path:"",body:m,httpMethod:"POST",httpOptions:{apiVersion:"",baseUrl:e,headers:{"X-Goog-Upload-Command":c,"X-Goog-Upload-Offset":String(u),"Content-Length":String(p)}}}),!(!((n=d==null?void 0:d.headers)===null||n===void 0)&&n[Dt]));)h++,await Bf(g),g=g*Uf;if(u+=p,((o=d==null?void 0:d.headers)===null||o===void 0?void 0:o[Dt])!=="active")break;if(a<=u)throw new Error("All content has been uploaded, but the upload status is not finalized.")}const f=await(d==null?void 0:d.json());if(((l=d==null?void 0:d.headers)===null||l===void 0?void 0:l[Dt])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return f.file}async function Gf(i){return{size:i.size,type:i.type}}function Bf(i){return new Promise(e=>setTimeout(e,i))}class qf{async upload(e,t,n){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await bf(e,t,n)}async stat(e){if(typeof e=="string")throw new Error("File path is not supported in browser uploader.");return await Gf(e)}}/**
|
|
218
|
+
* @license
|
|
219
|
+
* Copyright 2025 Google LLC
|
|
220
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
221
|
+
*/class $f{create(e,t,n){return new Of(e,t,n)}}class Of{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(e)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/**
|
|
222
|
+
* @license
|
|
223
|
+
* Copyright 2025 Google LLC
|
|
224
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
225
|
+
*/const Oi="x-goog-api-key";class Hf{constructor(e){this.apiKey=e}async addAuthHeaders(e){if(e.get(Oi)===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.");e.append(Oi,this.apiKey)}}}/**
|
|
226
|
+
* @license
|
|
227
|
+
* Copyright 2025 Google LLC
|
|
228
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
229
|
+
*/const Jf="gl-node/";class Wf{constructor(e){var t;if(e.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(e.project||e.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=(t=e.vertexai)!==null&&t!==void 0?t:!1,this.apiKey=e.apiKey;const n=Xo(e,void 0,void 0);n&&(e.httpOptions?e.httpOptions.baseUrl=n:e.httpOptions={baseUrl:n}),this.apiVersion=e.apiVersion;const o=new Hf(this.apiKey);this.apiClient=new sd({auth:o,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:e.httpOptions,userAgentExtra:Jf+"web",uploader:new qf,downloader:new Df}),this.models=new xd(this.apiClient),this.live=new vd(this.apiClient,o,new $f),this.chats=new xs(this.models,this.apiClient),this.caches=new Cs(this.apiClient),this.files=new Fs(this.apiClient),this.operations=new Ld(this.apiClient),this.authTokens=new df(this.apiClient),this.tunings=new kf(this.apiClient)}}const Lt=[{id:"bp1",name:"Order to Cash",capabilities:[{id:"cap1",name:"Order Management",cycles:[{id:"cyc1",name:"Standard Order Processing",type:"cycle",practices:[{id:"pra1",name:"Validate Customer Credit",type:"practice"},{id:"pra3",name:"Check Inventory Availability",type:"practice"}]},{id:"cyc2",name:"Returns Management",type:"cycle",practices:[{id:"pra4",name:"Issue Return Material Auth",type:"practice"}]}]},{id:"cap2",name:"Invoicing & Collections",cycles:[{id:"cyc3",name:"Automated Billing Cycle",type:"cycle",practices:[]}]}]},{id:"bp2",name:"Hire to Retire",capabilities:[{id:"cap3",name:"Talent Acquisition",cycles:[{id:"cyc4",name:"Recruitment Funnel",type:"cycle",practices:[{id:"pra2",name:"Interview Evaluation",type:"practice"},{id:"pra5",name:"Background Verification",type:"practice"}]}]}]}],Hi=`<?xml version="1.0" encoding="UTF-8"?>
|
|
230
|
+
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
|
231
|
+
<bpmn:process id="Process_1" isExecutable="false">
|
|
232
|
+
<bpmn:startEvent id="StartEvent_1" name="Start" />
|
|
233
|
+
</bpmn:process>
|
|
234
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
235
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
|
236
|
+
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
|
237
|
+
<dc:Bounds x="173" y="102" width="36" height="36" />
|
|
238
|
+
</bpmndi:BPMNShape>
|
|
239
|
+
</bpmndi:BPMNPlane>
|
|
240
|
+
</bpmndi:BPMNDiagram>
|
|
241
|
+
</bpmn:definitions>`,Yf=()=>{const[i,e]=J.useState("dashboard"),[t,n]=J.useState(Lt[0].id),[o,l]=J.useState(null),a=J.useRef(null),u=J.useRef(null),[d,c]=J.useState(!0),[f,p]=J.useState(""),[m,h]=J.useState(!1),[g,v]=J.useState("");J.useEffect(()=>{if(i==="designer"&&a.current){const x=setTimeout(()=>{!u.current&&a.current&&(u.current=new BpmnJS({container:a.current}),u.current.importXML(Hi).catch(console.error))},50);return()=>clearTimeout(x)}return()=>{if(u.current){try{u.current.destroy()}catch(x){console.warn("Modeler destruction warning",x)}u.current=null}}},[i]);const E=x=>{l(x),e("designer")},I=()=>{e("dashboard"),l(null),p(""),v(""),h(!1)},w=async()=>{if(u.current)try{const{xml:x}=await u.current.saveXML({format:!0}),M=new Blob([x],{type:"application/xml"}),k=document.createElement("a");k.href=URL.createObjectURL(M),k.download=`${(o==null?void 0:o.name.replace(/\s+/g,"_"))||"process"}.bpmn`,k.click()}catch(x){console.error("Error exporting BPMN",x)}},N=async()=>{if(!(!f.trim()||!u.current)){h(!0),v("Drafting flow...");try{let k=(await new Wf({apiKey:"PLACEHOLDER_API_KEY"}).models.generateContent({model:"gemini-3-flash-preview",contents:`Generate a valid BPMN 2.0 XML for a ${o==null?void 0:o.type} named "${o==null?void 0:o.name}". Specific requirements: "${f}". Return ONLY the raw XML code.`})).text||"";k=k.replace(/^```xml\n/,"").replace(/\n```$/,"").trim(),k.includes("<bpmn:definitions")?(await u.current.importXML(k),v("Import successful!"),p("")):v("Generated invalid XML.")}catch(x){console.error("AI Generation error",x),v("Generation failed.")}finally{h(!1),setTimeout(()=>v(""),3e3)}}},F=(x,M)=>{if(!u.current)return;const k=u.current.get("elementFactory"),O=u.current.get("create");let L=k.createShape({type:M});L&&O.start(x,L)};if(i==="dashboard"){const x=Lt.find(M=>M.id===t);return C.jsxs("div",{className:"min-h-screen bg-slate-50 text-slate-900",children:[C.jsx("header",{className:"bg-white border-b border-slate-200 px-8 py-6",children:C.jsxs("div",{className:"max-w-7xl mx-auto flex justify-between items-center",children:[C.jsxs("div",{children:[C.jsxs("h1",{className:"text-2xl font-bold tracking-tight text-slate-900 flex items-center gap-2",children:[C.jsx(io,{className:"text-indigo-600"}),"Enterprise Blueprint"]}),C.jsx("p",{className:"text-slate-500 text-sm",children:"Organize processes, capabilities, and work cycles."})]}),C.jsxs("button",{className:"bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-indigo-700 transition-colors flex items-center gap-2 shadow-sm",children:[C.jsx(co,{size:18})," New Process"]})]})}),C.jsx("div",{className:"bg-white border-b border-slate-200 sticky top-0 z-10",children:C.jsx("div",{className:"max-w-7xl mx-auto flex gap-8 px-8",children:Lt.map(M=>C.jsx("button",{onClick:()=>n(M.id),className:`py-4 text-sm font-semibold border-b-2 transition-all ${t===M.id?"border-indigo-600 text-indigo-600":"border-transparent text-slate-500 hover:text-slate-700"}`,children:M.name},M.id))})}),C.jsx("main",{className:"max-w-7xl mx-auto p-8",children:C.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:x==null?void 0:x.capabilities.map(M=>C.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden flex flex-col h-fit",children:[C.jsxs("div",{className:"p-6 border-b border-slate-100 bg-slate-50/50",children:[C.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2 text-slate-800",children:[C.jsx(mo,{className:"text-indigo-500 w-5 h-5"}),M.name]}),C.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-widest mt-1 block",children:"Capability"})]}),C.jsxs("div",{className:"p-6 space-y-4",children:[C.jsxs("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-2 flex items-center gap-2",children:[C.jsx(qt,{size:14})," Work Cycles & Practices"]}),C.jsx("div",{className:"space-y-4",children:M.cycles.map(k=>C.jsxs("div",{className:"rounded-xl border border-slate-100 overflow-hidden bg-white shadow-sm",children:[C.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-50/50 group border-b border-slate-100",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx(qt,{size:14,className:"text-indigo-400"}),C.jsx("span",{className:"text-sm font-bold text-slate-800",children:k.name})]}),C.jsx("button",{onClick:()=>E(k),className:"text-[10px] font-bold text-indigo-600 bg-indigo-100 px-2 py-1 rounded hover:bg-indigo-200 transition-colors uppercase tracking-tight",children:"Design Cycle"})]}),C.jsx("div",{className:"p-2 space-y-1",children:k.practices.length>0?k.practices.map(O=>C.jsxs("div",{className:"flex items-center justify-between p-2 pl-4 rounded-lg hover:bg-indigo-50/50 group transition-all",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx(ao,{size:12,className:"text-slate-300"}),C.jsx("span",{className:"text-xs font-medium text-slate-600",children:O.name})]}),C.jsxs("button",{onClick:()=>E(O),className:"text-[10px] font-semibold text-slate-400 opacity-0 group-hover:opacity-100 hover:text-indigo-600 flex items-center gap-1 transition-all",children:["Design Practice ",C.jsx(He,{size:10})]})]},O.id)):C.jsx("div",{className:"py-2 px-4 text-[10px] italic text-slate-400",children:"No practices defined for this cycle."})})]},k.id))})]})]},M.id))})})]})}return C.jsxs("div",{className:"flex h-screen w-full bg-white overflow-hidden text-slate-800",children:[C.jsxs("div",{className:`${d?"w-80":"w-0"} transition-all duration-300 border-r border-slate-200 bg-slate-50 flex flex-col relative z-20 shadow-xl`,children:[d&&C.jsxs("div",{className:"flex-1 flex flex-col p-6 overflow-y-auto w-80",children:[C.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[C.jsx("button",{onClick:x=>{x.preventDefault(),I()},className:"p-2 hover:bg-slate-200 rounded-lg transition-colors mr-1 flex items-center justify-center text-slate-600 hover:text-indigo-600 active:scale-95 cursor-pointer",title:"Back to Dashboard",children:C.jsx(no,{size:18})}),C.jsx("h1",{className:"font-bold text-lg tracking-tight text-slate-900 truncate",children:o==null?void 0:o.name})]}),C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-slate-400 mb-4 flex items-center gap-2",children:"Palette"}),C.jsx("div",{className:"grid grid-cols-1 gap-2",children:[{type:"bpmn:StartEvent",icon:C.jsx(so,{size:18}),label:"Start",color:"bg-green-50 text-green-600"},{type:"bpmn:Task",icon:C.jsx(po,{size:18}),label:"Task",color:"bg-slate-100 text-slate-600"},{type:"bpmn:IntermediateCatchEvent",icon:C.jsx(uo,{size:18}),label:"Event",color:"bg-blue-50 text-blue-600"},{type:"bpmn:EndEvent",icon:C.jsx(ro,{size:18}),label:"End",color:"bg-red-50 text-red-600"}].map(x=>C.jsxs("div",{onMouseDown:M=>F(M,x.type),className:"flex items-center gap-3 p-3 bg-white border border-slate-200 rounded-xl cursor-grab hover:border-indigo-400 hover:shadow-sm transition-all group",children:[C.jsx("div",{className:`p-2 rounded-lg ${x.color}`,children:x.icon}),C.jsx("span",{className:"text-sm font-medium",children:x.label})]},x.type))})]}),C.jsx("hr",{className:"border-slate-200"}),C.jsxs("section",{children:[C.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-slate-400 mb-3 flex items-center gap-2",children:[C.jsx(fo,{className:"w-3 h-3 text-indigo-500"}),"AI Architect"]}),C.jsx("textarea",{className:"w-full h-24 p-3 text-sm border border-slate-300 rounded-xl focus:ring-2 focus:ring-indigo-500 bg-white outline-none resize-none transition-all",placeholder:"Ask AI to draft this process...",value:f,onChange:x=>p(x.target.value)}),C.jsx("button",{onClick:N,disabled:m||!f.trim(),className:"w-full mt-2 bg-indigo-600 hover:bg-indigo-700 disabled:bg-slate-300 text-white font-medium py-2 rounded-xl flex items-center justify-center gap-2 transition-all shadow-md active:scale-95",children:m?"Drafting...":"Generate Flow"}),g&&C.jsx("p",{className:"mt-2 text-[10px] text-center font-medium text-indigo-600",children:g})]}),C.jsx("section",{className:"mt-auto space-y-3 pt-6 border-t border-slate-200",children:C.jsxs("button",{onClick:()=>{u.current&&u.current.importXML(Hi)},className:"w-full flex items-center gap-2 p-2 text-red-500 hover:bg-red-50 rounded-lg text-xs font-medium transition-all",children:[C.jsx(ho,{size:14})," Reset Canvas"]})})]})]}),C.jsx("button",{onClick:()=>c(!d),className:"absolute -right-4 top-1/2 -translate-y-1/2 bg-white border border-slate-200 rounded-full p-1 shadow-md hover:text-indigo-600 transition-all z-50",children:d?C.jsx(oo,{size:20}):C.jsx(He,{size:20})})]}),C.jsxs("div",{className:"flex-1 relative flex flex-col min-w-0",children:[C.jsxs("header",{className:"h-14 border-b border-slate-200 flex items-center justify-between px-6 bg-white/80 backdrop-blur-md z-10",children:[C.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[C.jsx("span",{className:"text-slate-400",children:"Architecture"}),C.jsx(He,{size:12,className:"text-slate-300"}),C.jsx("span",{className:"text-slate-400 uppercase tracking-tighter",children:(o==null?void 0:o.type)==="cycle"?"Cycle":"Practice"}),C.jsx(He,{size:12,className:"text-slate-300"}),C.jsx("span",{className:"text-slate-900 font-bold",children:o==null?void 0:o.name})]}),C.jsx("div",{className:"flex gap-2",children:C.jsxs("button",{onClick:w,className:"text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 px-4 py-2 rounded-lg shadow-sm flex items-center gap-2 transition-all active:scale-95",children:[C.jsx(lo,{size:14})," Export BPMN"]})})]}),C.jsxs("div",{className:"flex-1 relative overflow-hidden bg-white",children:[C.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(#e5e7eb_1px,transparent_1px)] [background-size:24px_24px] pointer-events-none opacity-40"}),C.jsx("div",{ref:a,className:"h-full w-full bpmn-io-style relative"})]})]})]})};fe.BpmfFlowDesigner=Yf,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})}));
|