diff --git "a/assets/index-BXwPC37o.js" "b/assets/index-BXwPC37o.js" new file mode 100644--- /dev/null +++ "b/assets/index-BXwPC37o.js" @@ -0,0 +1,213 @@ +(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const d of r)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&s(m)}).observe(document,{childList:!0,subtree:!0});function o(r){const d={};return r.integrity&&(d.integrity=r.integrity),r.referrerPolicy&&(d.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?d.credentials="include":r.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function s(r){if(r.ep)return;r.ep=!0;const d=o(r);fetch(r.href,d)}})();function Km(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Qu={exports:{}},no={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var vp;function Jy(){if(vp)return no;vp=1;var l=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(s,r,d){var m=null;if(d!==void 0&&(m=""+d),r.key!==void 0&&(m=""+r.key),"key"in r){d={};for(var g in r)g!=="key"&&(d[g]=r[g])}else d=r;return r=d.ref,{$$typeof:l,type:s,key:m,ref:r!==void 0?r:null,props:d}}return no.Fragment=n,no.jsx=o,no.jsxs=o,no}var Tp;function Oy(){return Tp||(Tp=1,Qu.exports=Jy()),Qu.exports}var R=Oy(),Zu={exports:{}},pe={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Sp;function Fy(){if(Sp)return pe;Sp=1;var l=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),_=Symbol.iterator;function b(M){return M===null||typeof M!="object"?null:(M=_&&M[_]||M["@@iterator"],typeof M=="function"?M:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},V=Object.assign,Y={};function J(M,G,O){this.props=M,this.context=G,this.refs=Y,this.updater=O||z}J.prototype.isReactComponent={},J.prototype.setState=function(M,G){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,G,"setState")},J.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function K(){}K.prototype=J.prototype;function B(M,G,O){this.props=M,this.context=G,this.refs=Y,this.updater=O||z}var ee=B.prototype=new K;ee.constructor=B,V(ee,J.prototype),ee.isPureReactComponent=!0;var le=Array.isArray;function ie(){}var X={H:null,A:null,T:null,S:null},ve=Object.prototype.hasOwnProperty;function W(M,G,O){var Z=O.ref;return{$$typeof:l,type:M,key:G,ref:Z!==void 0?Z:null,props:O}}function Q(M,G){return W(M.type,G,M.props)}function ge(M){return typeof M=="object"&&M!==null&&M.$$typeof===l}function me(M){var G={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(O){return G[O]})}var Ae=/\/+/g;function ut(M,G){return typeof M=="object"&&M!==null&&M.key!=null?me(""+M.key):G.toString(36)}function Xe(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(ie,ie):(M.status="pending",M.then(function(G){M.status==="pending"&&(M.status="fulfilled",M.value=G)},function(G){M.status==="pending"&&(M.status="rejected",M.reason=G)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function w(M,G,O,Z,fe){var P=typeof M;(P==="undefined"||P==="boolean")&&(M=null);var F=!1;if(M===null)F=!0;else switch(P){case"bigint":case"string":case"number":F=!0;break;case"object":switch(M.$$typeof){case l:case n:F=!0;break;case T:return F=M._init,w(F(M._payload),G,O,Z,fe)}}if(F)return fe=fe(M),F=Z===""?"."+ut(M,0):Z,le(fe)?(O="",F!=null&&(O=F.replace(Ae,"$&/")+"/"),w(fe,G,O,"",function(de){return de})):fe!=null&&(ge(fe)&&(fe=Q(fe,O+(fe.key==null||M&&M.key===fe.key?"":(""+fe.key).replace(Ae,"$&/")+"/")+F)),G.push(fe)),1;F=0;var re=Z===""?".":Z+":";if(le(M))for(var $=0;$>>1,Me=w[oe];if(0>>1;oer(O,se))Zr(fe,O)?(w[oe]=fe,w[Z]=se,oe=Z):(w[oe]=O,w[G]=se,oe=G);else if(Zr(fe,se))w[oe]=fe,w[Z]=se,oe=Z;else break e}}return k}function r(w,k){var se=w.sortIndex-k.sortIndex;return se!==0?se:w.id-k.id}if(l.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;l.unstable_now=function(){return d.now()}}else{var m=Date,g=m.now();l.unstable_now=function(){return m.now()-g}}var y=[],h=[],T=1,S=null,_=3,b=!1,z=!1,V=!1,Y=!1,J=typeof setTimeout=="function"?setTimeout:null,K=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate<"u"?setImmediate:null;function ee(w){for(var k=o(h);k!==null;){if(k.callback===null)s(h);else if(k.startTime<=w)s(h),k.sortIndex=k.expirationTime,n(y,k);else break;k=o(h)}}function le(w){if(V=!1,ee(w),!z)if(o(y)!==null)z=!0,ie||(ie=!0,me());else{var k=o(h);k!==null&&Xe(le,k.startTime-w)}}var ie=!1,X=-1,ve=5,W=-1;function Q(){return Y?!0:!(l.unstable_now()-Ww&&Q());){var oe=S.callback;if(typeof oe=="function"){S.callback=null,_=S.priorityLevel;var Me=oe(S.expirationTime<=w);if(w=l.unstable_now(),typeof Me=="function"){S.callback=Me,ee(w),k=!0;break t}S===o(y)&&s(y),ee(w)}else s(y);S=o(y)}if(S!==null)k=!0;else{var M=o(h);M!==null&&Xe(le,M.startTime-w),k=!1}}break e}finally{S=null,_=se,b=!1}k=void 0}}finally{k?me():ie=!1}}}var me;if(typeof B=="function")me=function(){B(ge)};else if(typeof MessageChannel<"u"){var Ae=new MessageChannel,ut=Ae.port2;Ae.port1.onmessage=ge,me=function(){ut.postMessage(null)}}else me=function(){J(ge,0)};function Xe(w,k){X=J(function(){w(l.unstable_now())},k)}l.unstable_IdlePriority=5,l.unstable_ImmediatePriority=1,l.unstable_LowPriority=4,l.unstable_NormalPriority=3,l.unstable_Profiling=null,l.unstable_UserBlockingPriority=2,l.unstable_cancelCallback=function(w){w.callback=null},l.unstable_forceFrameRate=function(w){0>w||125oe?(w.sortIndex=se,n(h,w),o(y)===null&&w===o(h)&&(V?(K(X),X=-1):V=!0,Xe(le,se-oe))):(w.sortIndex=Me,n(y,w),z||b||(z=!0,ie||(ie=!0,me()))),w},l.unstable_shouldYield=Q,l.unstable_wrapCallback=function(w){var k=_;return function(){var se=_;_=k;try{return w.apply(this,arguments)}finally{_=se}}}})(ju)),ju}var Cp;function Qy(){return Cp||(Cp=1,Wu.exports=Ky()),Wu.exports}var er={exports:{}},ct={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ap;function Zy(){if(Ap)return ct;Ap=1;var l=fr();function n(y){var h="https://react.dev/errors/"+y;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),er.exports=Zy(),er.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Rp;function Wy(){if(Rp)return lo;Rp=1;var l=Qy(),n=fr(),o=$y();function s(e){var t="https://react.dev/errors/"+e;if(1Me||(e.current=oe[Me],oe[Me]=null,Me--)}function O(e,t){Me++,oe[Me]=e.current,e.current=t}var Z=M(null),fe=M(null),P=M(null),F=M(null);function re(e,t){switch(O(P,t),O(fe,e),O(Z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Pd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Pd(t),e=kd(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}G(Z),O(Z,e)}function $(){G(Z),G(fe),G(P)}function de(e){e.memoizedState!==null&&O(F,e);var t=Z.current,i=kd(t,e.type);t!==i&&(O(fe,e),O(Z,i))}function Re(e){fe.current===e&&(G(Z),G(fe)),F.current===e&&(G(F),Wi._currentValue=se)}var ke,mt;function je(e){if(ke===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);ke=t&&t[1]||"",mt=-1)":-1f||C[a]!==D[f]){var q=` +`+C[a].replace(" at new "," at ");return e.displayName&&q.includes("")&&(q=q.replace("",e.displayName)),q}while(1<=a&&0<=f);break}}}finally{dt=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?je(i):""}function Yt(e,t){switch(e.tag){case 26:case 27:case 5:return je(e.type);case 16:return je("Lazy");case 13:return e.child!==t&&t!==null?je("Suspense Fallback"):je("Suspense");case 19:return je("SuspenseList");case 0:case 15:return jt(e.type,!1);case 11:return jt(e.type.render,!1);case 1:return jt(e.type,!0);case 31:return je("Activity");default:return""}}function Qn(e){try{var t="",i=null;do t+=Yt(e,i),i=e,e=e.return;while(e);return t}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var vl=Object.prototype.hasOwnProperty,rt=l.unstable_scheduleCallback,nt=l.unstable_cancelCallback,en=l.unstable_shouldYield,En=l.unstable_requestPaint,He=l.unstable_now,_t=l.unstable_getCurrentPriorityLevel,Jt=l.unstable_ImmediatePriority,Tr=l.unstable_UserBlockingPriority,uo=l.unstable_NormalPriority,Mh=l.unstable_LowPriority,Sr=l.unstable_IdlePriority,Rh=l.log,xh=l.unstable_setDisableYieldValue,ci=null,Ct=null;function _n(e){if(typeof Rh=="function"&&xh(e),Ct&&typeof Ct.setStrictMode=="function")try{Ct.setStrictMode(ci,e)}catch{}}var At=Math.clz32?Math.clz32:bh,Nh=Math.log,Dh=Math.LN2;function bh(e){return e>>>=0,e===0?32:31-(Nh(e)/Dh|0)|0}var ro=256,co=262144,fo=4194304;function Zn(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function po(e,t,i){var a=e.pendingLanes;if(a===0)return 0;var f=0,p=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var E=a&134217727;return E!==0?(a=E&~p,a!==0?f=Zn(a):(v&=E,v!==0?f=Zn(v):i||(i=E&~e,i!==0&&(f=Zn(i))))):(E=a&~p,E!==0?f=Zn(E):v!==0?f=Zn(v):i||(i=a&~e,i!==0&&(f=Zn(i)))),f===0?0:t!==0&&t!==f&&(t&p)===0&&(p=f&-f,i=t&-t,p>=i||p===32&&(i&4194048)!==0)?t:f}function fi(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Uh(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Er(){var e=fo;return fo<<=1,(fo&62914560)===0&&(fo=4194304),e}function Ha(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function di(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ih(e,t,i,a,f,p){var v=e.pendingLanes;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=i,e.entangledLanes&=i,e.errorRecoveryDisabledLanes&=i,e.shellSuspendCounter=0;var E=e.entanglements,C=e.expirationTimes,D=e.hiddenUpdates;for(i=v&~i;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var zh=/[\n"\\]/g;function wt(e){return e.replace(zh,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Ya(e,t,i,a,f,p,v,E){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+It(t)):e.value!==""+It(t)&&(e.value=""+It(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?Ja(e,v,It(t)):i!=null?Ja(e,v,It(i)):a!=null&&e.removeAttribute("value"),f==null&&p!=null&&(e.defaultChecked=!!p),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+It(E):e.removeAttribute("name")}function qr(e,t,i,a,f,p,v,E){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),t!=null||i!=null){if(!(p!=="submit"&&p!=="reset"||t!=null)){ka(e);return}i=i!=null?""+It(i):"",t=t!=null?""+It(t):i,E||t===e.value||(e.value=t),e.defaultValue=t}a=a??f,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=E?e.checked:!!a,e.defaultChecked=!!a,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),ka(e)}function Ja(e,t,i){t==="number"&&go(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function Al(e,t,i,a){if(e=e.options,t){t={};for(var f=0;f"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Qa=!1;if(ln)try{var gi={};Object.defineProperty(gi,"passive",{get:function(){Qa=!0}}),window.addEventListener("test",gi,gi),window.removeEventListener("test",gi,gi)}catch{Qa=!1}var An=null,Za=null,vo=null;function Pr(){if(vo)return vo;var e,t=Za,i=t.length,a,f="value"in An?An.value:An.textContent,p=f.length;for(e=0;e=Ti),Xr=" ",Kr=!1;function Qr(e,t){switch(e){case"keyup":return dg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zr(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Nl=!1;function mg(e,t){switch(e){case"compositionend":return Zr(t);case"keypress":return t.which!==32?null:(Kr=!0,Xr);case"textInput":return e=t.data,e===Xr&&Kr?null:e;default:return null}}function hg(e,t){if(Nl)return e==="compositionend"||!ts&&Qr(e,t)?(e=Pr(),vo=Za=An=null,Nl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:i,offset:t-e};e=a}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ic(i)}}function ac(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ac(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function sc(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=go(e.document);t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=go(e.document)}return t}function is(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Cg=ln&&"documentMode"in document&&11>=document.documentMode,Dl=null,os=null,Ci=null,as=!1;function uc(e,t,i){var a=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;as||Dl==null||Dl!==go(a)||(a=Dl,"selectionStart"in a&&is(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Ci&&_i(Ci,a)||(Ci=a,a=fa(os,"onSelect"),0>=v,f-=v,Qt=1<<32-At(t)+f|i<ye?(_e=ne,ne=null):_e=ne.sibling;var Ne=U(x,ne,N[ye],L);if(Ne===null){ne===null&&(ne=_e);break}e&&ne&&Ne.alternate===null&&t(x,ne),A=p(Ne,A,ye),xe===null?ae=Ne:xe.sibling=Ne,xe=Ne,ne=_e}if(ye===N.length)return i(x,ne),Ce&&an(x,ye),ae;if(ne===null){for(;yeye?(_e=ne,ne=null):_e=ne.sibling;var Fn=U(x,ne,Ne.value,L);if(Fn===null){ne===null&&(ne=_e);break}e&&ne&&Fn.alternate===null&&t(x,ne),A=p(Fn,A,ye),xe===null?ae=Fn:xe.sibling=Fn,xe=Fn,ne=_e}if(Ne.done)return i(x,ne),Ce&&an(x,ye),ae;if(ne===null){for(;!Ne.done;ye++,Ne=N.next())Ne=H(x,Ne.value,L),Ne!==null&&(A=p(Ne,A,ye),xe===null?ae=Ne:xe.sibling=Ne,xe=Ne);return Ce&&an(x,ye),ae}for(ne=a(ne);!Ne.done;ye++,Ne=N.next())Ne=I(ne,x,ye,Ne.value,L),Ne!==null&&(e&&Ne.alternate!==null&&ne.delete(Ne.key===null?ye:Ne.key),A=p(Ne,A,ye),xe===null?ae=Ne:xe.sibling=Ne,xe=Ne);return e&&ne.forEach(function(Yy){return t(x,Yy)}),Ce&&an(x,ye),ae}function Le(x,A,N,L){if(typeof N=="object"&&N!==null&&N.type===V&&N.key===null&&(N=N.props.children),typeof N=="object"&&N!==null){switch(N.$$typeof){case b:e:{for(var ae=N.key;A!==null;){if(A.key===ae){if(ae=N.type,ae===V){if(A.tag===7){i(x,A.sibling),L=f(A,N.props.children),L.return=x,x=L;break e}}else if(A.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===ve&&sl(ae)===A.type){i(x,A.sibling),L=f(A,N.props),Di(L,N),L.return=x,x=L;break e}i(x,A);break}else t(x,A);A=A.sibling}N.type===V?(L=nl(N.props.children,x.mode,L,N.key),L.return=x,x=L):(L=No(N.type,N.key,N.props,null,x.mode,L),Di(L,N),L.return=x,x=L)}return v(x);case z:e:{for(ae=N.key;A!==null;){if(A.key===ae)if(A.tag===4&&A.stateNode.containerInfo===N.containerInfo&&A.stateNode.implementation===N.implementation){i(x,A.sibling),L=f(A,N.children||[]),L.return=x,x=L;break e}else{i(x,A);break}else t(x,A);A=A.sibling}L=ps(N,x.mode,L),L.return=x,x=L}return v(x);case ve:return N=sl(N),Le(x,A,N,L)}if(Xe(N))return j(x,A,N,L);if(me(N)){if(ae=me(N),typeof ae!="function")throw Error(s(150));return N=ae.call(N),ue(x,A,N,L)}if(typeof N.then=="function")return Le(x,A,Lo(N),L);if(N.$$typeof===B)return Le(x,A,Uo(x,N),L);Go(x,N)}return typeof N=="string"&&N!==""||typeof N=="number"||typeof N=="bigint"?(N=""+N,A!==null&&A.tag===6?(i(x,A.sibling),L=f(A,N),L.return=x,x=L):(i(x,A),L=ds(N,x.mode,L),L.return=x,x=L),v(x)):i(x,A)}return function(x,A,N,L){try{Ni=0;var ae=Le(x,A,N,L);return Bl=null,ae}catch(ne){if(ne===Vl||ne===wo)throw ne;var xe=Rt(29,ne,null,x.mode);return xe.lanes=L,xe.return=x,xe}finally{}}}var rl=Uc(!0),Ic=Uc(!1),Dn=!1;function Ms(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Rs(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bn(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Un(e,t,i){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(be&2)!==0){var f=a.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),a.pending=t,t=xo(e),hc(e,null,i),t}return Ro(e,a,t,i),xo(e)}function bi(e,t,i){if(t=t.updateQueue,t!==null&&(t=t.shared,(i&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Cr(e,i)}}function xs(e,t){var i=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,i===a)){var f=null,p=null;if(i=i.firstBaseUpdate,i!==null){do{var v={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};p===null?f=p=v:p=p.next=v,i=i.next}while(i!==null);p===null?f=p=t:p=p.next=t}else f=p=t;i={baseState:a.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:a.shared,callbacks:a.callbacks},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=t:e.next=t,i.lastBaseUpdate=t}var Ns=!1;function Ui(){if(Ns){var e=zl;if(e!==null)throw e}}function Ii(e,t,i,a){Ns=!1;var f=e.updateQueue;Dn=!1;var p=f.firstBaseUpdate,v=f.lastBaseUpdate,E=f.shared.pending;if(E!==null){f.shared.pending=null;var C=E,D=C.next;C.next=null,v===null?p=D:v.next=D,v=C;var q=e.alternate;q!==null&&(q=q.updateQueue,E=q.lastBaseUpdate,E!==v&&(E===null?q.firstBaseUpdate=D:E.next=D,q.lastBaseUpdate=C))}if(p!==null){var H=f.baseState;v=0,q=D=C=null,E=p;do{var U=E.lane&-536870913,I=U!==E.lane;if(I?(Ee&U)===U:(a&U)===U){U!==0&&U===Hl&&(Ns=!0),q!==null&&(q=q.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var j=e,ue=E;U=t;var Le=i;switch(ue.tag){case 1:if(j=ue.payload,typeof j=="function"){H=j.call(Le,H,U);break e}H=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=ue.payload,U=typeof j=="function"?j.call(Le,H,U):j,U==null)break e;H=S({},H,U);break e;case 2:Dn=!0}}U=E.callback,U!==null&&(e.flags|=64,I&&(e.flags|=8192),I=f.callbacks,I===null?f.callbacks=[U]:I.push(U))}else I={lane:U,tag:E.tag,payload:E.payload,callback:E.callback,next:null},q===null?(D=q=I,C=H):q=q.next=I,v|=U;if(E=E.next,E===null){if(E=f.shared.pending,E===null)break;I=E,E=I.next,I.next=null,f.lastBaseUpdate=I,f.shared.pending=null}}while(!0);q===null&&(C=H),f.baseState=C,f.firstBaseUpdate=D,f.lastBaseUpdate=q,p===null&&(f.shared.lanes=0),Gn|=v,e.lanes=v,e.memoizedState=H}}function wc(e,t){if(typeof e!="function")throw Error(s(191,e));e.call(t)}function qc(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;ep?p:8;var v=w.T,E={};w.T=E,Xs(e,!1,t,i);try{var C=f(),D=w.S;if(D!==null&&D(E,C),C!==null&&typeof C=="object"&&typeof C.then=="function"){var q=Ig(C,a);Li(e,t,q,Ut(e))}else Li(e,t,a,Ut(e))}catch(H){Li(e,t,{then:function(){},status:"rejected",reason:H},Ut())}finally{k.p=p,v!==null&&E.types!==null&&(v.types=E.types),w.T=v}}function zg(){}function Os(e,t,i,a){if(e.tag!==5)throw Error(s(476));var f=pf(e).queue;df(e,f,t,se,i===null?zg:function(){return mf(e),i(a)})}function pf(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cn,lastRenderedState:se},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cn,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function mf(e){var t=pf(e);t.next===null&&(t=e.alternate.memoizedState),Li(e,t.next.queue,{},Ut())}function Fs(){return ot(Wi)}function hf(){return Fe().memoizedState}function gf(){return Fe().memoizedState}function Vg(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=Ut();e=bn(i);var a=Un(t,e,i);a!==null&&(Et(a,t,i),bi(a,t,i)),t={cache:Es()},e.payload=t;return}t=t.return}}function Bg(e,t,i){var a=Ut();i={lane:a,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Fo(e)?vf(t,i):(i=cs(e,t,i,a),i!==null&&(Et(i,e,a),Tf(i,t,a)))}function yf(e,t,i){var a=Ut();Li(e,t,i,a)}function Li(e,t,i,a){var f={lane:a,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Fo(e))vf(t,f);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=t.lastRenderedReducer,p!==null))try{var v=t.lastRenderedState,E=p(v,i);if(f.hasEagerState=!0,f.eagerState=E,Mt(E,v))return Ro(e,t,f,0),Ge===null&&Mo(),!1}catch{}finally{}if(i=cs(e,t,f,a),i!==null)return Et(i,e,a),Tf(i,t,a),!0}return!1}function Xs(e,t,i,a){if(a={lane:2,revertLane:Mu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Fo(e)){if(t)throw Error(s(479))}else t=cs(e,i,a,2),t!==null&&Et(t,e,2)}function Fo(e){var t=e.alternate;return e===he||t!==null&&t===he}function vf(e,t){kl=Vo=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function Tf(e,t,i){if((i&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Cr(e,i)}}var Gi={readContext:ot,use:ko,useCallback:Ye,useContext:Ye,useEffect:Ye,useImperativeHandle:Ye,useLayoutEffect:Ye,useInsertionEffect:Ye,useMemo:Ye,useReducer:Ye,useRef:Ye,useState:Ye,useDebugValue:Ye,useDeferredValue:Ye,useTransition:Ye,useSyncExternalStore:Ye,useId:Ye,useHostTransitionStatus:Ye,useFormState:Ye,useActionState:Ye,useOptimistic:Ye,useMemoCache:Ye,useCacheRefresh:Ye};Gi.useEffectEvent=Ye;var Sf={readContext:ot,use:ko,useCallback:function(e,t){return pt().memoizedState=[e,t===void 0?null:t],e},useContext:ot,useEffect:nf,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,Jo(4194308,4,sf.bind(null,t,e),i)},useLayoutEffect:function(e,t){return Jo(4194308,4,e,t)},useInsertionEffect:function(e,t){Jo(4,2,e,t)},useMemo:function(e,t){var i=pt();t=t===void 0?null:t;var a=e();if(cl){_n(!0);try{e()}finally{_n(!1)}}return i.memoizedState=[a,t],a},useReducer:function(e,t,i){var a=pt();if(i!==void 0){var f=i(t);if(cl){_n(!0);try{i(t)}finally{_n(!1)}}}else f=t;return a.memoizedState=a.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},a.queue=e,e=e.dispatch=Bg.bind(null,he,e),[a.memoizedState,e]},useRef:function(e){var t=pt();return e={current:e},t.memoizedState=e},useState:function(e){e=Bs(e);var t=e.queue,i=yf.bind(null,he,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:Ys,useDeferredValue:function(e,t){var i=pt();return Js(i,e,t)},useTransition:function(){var e=Bs(!1);return e=df.bind(null,he,e.queue,!0,!1),pt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var a=he,f=pt();if(Ce){if(i===void 0)throw Error(s(407));i=i()}else{if(i=t(),Ge===null)throw Error(s(349));(Ee&127)!==0||Bc(a,t,i)}f.memoizedState=i;var p={value:i,getSnapshot:t};return f.queue=p,nf(kc.bind(null,a,p,e),[e]),a.flags|=2048,Jl(9,{destroy:void 0},Pc.bind(null,a,p,i,t),null),i},useId:function(){var e=pt(),t=Ge.identifierPrefix;if(Ce){var i=Zt,a=Qt;i=(a&~(1<<32-At(a)-1)).toString(32)+i,t="_"+t+"R_"+i,i=Bo++,0<\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof a.is=="string"?v.createElement("select",{is:a.is}):v.createElement("select"),a.multiple?p.multiple=!0:a.size&&(p.size=a.size);break;default:p=typeof a.is=="string"?v.createElement(f,{is:a.is}):v.createElement(f)}}p[lt]=t,p[ht]=a;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)p.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=p;e:switch(st(p,f,a),f){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&dn(t)}}return Ve(t),su(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&dn(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(s(166));if(e=P.current,Ll(t)){if(e=t.stateNode,i=t.memoizedProps,a=null,f=it,f!==null)switch(f.tag){case 27:case 5:a=f.memoizedProps}e[lt]=t,e=!!(e.nodeValue===i||a!==null&&a.suppressHydrationWarning===!0||Vd(e.nodeValue,i)),e||xn(t,!0)}else e=da(e).createTextNode(a),e[lt]=t,t.stateNode=e}return Ve(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(a=Ll(t),i!==null){if(e===null){if(!a)throw Error(s(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(s(557));e[lt]=t}else ll(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ve(t),e=!1}else i=ys(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?(Nt(t),t):(Nt(t),null);if((t.flags&128)!==0)throw Error(s(558))}return Ve(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Ll(t),a!==null&&a.dehydrated!==null){if(e===null){if(!f)throw Error(s(318));if(f=t.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(s(317));f[lt]=t}else ll(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ve(t),f=!1}else f=ys(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?(Nt(t),t):(Nt(t),null)}return Nt(t),(t.flags&128)!==0?(t.lanes=i,t):(i=a!==null,e=e!==null&&e.memoizedState!==null,i&&(a=t.child,f=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(f=a.alternate.memoizedState.cachePool.pool),p=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(p=a.memoizedState.cachePool.pool),p!==f&&(a.flags|=2048)),i!==e&&i&&(t.child.flags|=8192),$o(t,t.updateQueue),Ve(t),null);case 4:return $(),e===null&&Du(t.stateNode.containerInfo),Ve(t),null;case 10:return un(t.type),Ve(t),null;case 19:if(G(Oe),a=t.memoizedState,a===null)return Ve(t),null;if(f=(t.flags&128)!==0,p=a.rendering,p===null)if(f)zi(a,!1);else{if(Je!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(p=zo(e),p!==null){for(t.flags|=128,zi(a,!1),e=p.updateQueue,t.updateQueue=e,$o(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)gc(i,e),i=i.sibling;return O(Oe,Oe.current&1|2),Ce&&an(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&He()>na&&(t.flags|=128,f=!0,zi(a,!1),t.lanes=4194304)}else{if(!f)if(e=zo(p),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,$o(t,e),zi(a,!0),a.tail===null&&a.tailMode==="hidden"&&!p.alternate&&!Ce)return Ve(t),null}else 2*He()-a.renderingStartTime>na&&i!==536870912&&(t.flags|=128,f=!0,zi(a,!1),t.lanes=4194304);a.isBackwards?(p.sibling=t.child,t.child=p):(e=a.last,e!==null?e.sibling=p:t.child=p,a.last=p)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=He(),e.sibling=null,i=Oe.current,O(Oe,f?i&1|2:i&1),Ce&&an(t,a.treeForkCount),e):(Ve(t),null);case 22:case 23:return Nt(t),bs(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(i&536870912)!==0&&(t.flags&128)===0&&(Ve(t),t.subtreeFlags&6&&(t.flags|=8192)):Ve(t),i=t.updateQueue,i!==null&&$o(t,i.retryQueue),i=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==i&&(t.flags|=2048),e!==null&&G(al),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),un(Ke),Ve(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function Og(e,t){switch(hs(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return un(Ke),$(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Re(t),null;case 31:if(t.memoizedState!==null){if(Nt(t),t.alternate===null)throw Error(s(340));ll()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Nt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));ll()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return G(Oe),null;case 4:return $(),null;case 10:return un(t.type),null;case 22:case 23:return Nt(t),bs(),e!==null&&G(al),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return un(Ke),null;case 25:return null;default:return null}}function Jf(e,t){switch(hs(t),t.tag){case 3:un(Ke),$();break;case 26:case 27:case 5:Re(t);break;case 4:$();break;case 31:t.memoizedState!==null&&Nt(t);break;case 13:Nt(t);break;case 19:G(Oe);break;case 10:un(t.type);break;case 22:case 23:Nt(t),bs(),e!==null&&G(al);break;case 24:un(Ke)}}function Vi(e,t){try{var i=t.updateQueue,a=i!==null?i.lastEffect:null;if(a!==null){var f=a.next;i=f;do{if((i.tag&e)===e){a=void 0;var p=i.create,v=i.inst;a=p(),v.destroy=a}i=i.next}while(i!==f)}}catch(E){Ie(t,t.return,E)}}function qn(e,t,i){try{var a=t.updateQueue,f=a!==null?a.lastEffect:null;if(f!==null){var p=f.next;a=p;do{if((a.tag&e)===e){var v=a.inst,E=v.destroy;if(E!==void 0){v.destroy=void 0,f=t;var C=i,D=E;try{D()}catch(q){Ie(f,C,q)}}}a=a.next}while(a!==p)}}catch(q){Ie(t,t.return,q)}}function Of(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{qc(t,i)}catch(a){Ie(e,e.return,a)}}}function Ff(e,t,i){i.props=fl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(a){Ie(e,t,a)}}function Bi(e,t){try{var i=e.ref;if(i!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof i=="function"?e.refCleanup=i(a):i.current=a}}catch(f){Ie(e,t,f)}}function $t(e,t){var i=e.ref,a=e.refCleanup;if(i!==null)if(typeof a=="function")try{a()}catch(f){Ie(e,t,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(f){Ie(e,t,f)}else i.current=null}function Xf(e){var t=e.type,i=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":i.autoFocus&&a.focus();break e;case"img":i.src?a.src=i.src:i.srcSet&&(a.srcset=i.srcSet)}}catch(f){Ie(e,e.return,f)}}function uu(e,t,i){try{var a=e.stateNode;py(a,e.type,i,t),a[ht]=t}catch(f){Ie(e,e.return,f)}}function Kf(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Pn(e.type)||e.tag===4}function ru(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Pn(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cu(e,t,i){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(e,t):(t=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,t.appendChild(e),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=nn));else if(a!==4&&(a===27&&Pn(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(cu(e,t,i),e=e.sibling;e!==null;)cu(e,t,i),e=e.sibling}function Wo(e,t,i){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?i.insertBefore(e,t):i.appendChild(e);else if(a!==4&&(a===27&&Pn(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(Wo(e,t,i),e=e.sibling;e!==null;)Wo(e,t,i),e=e.sibling}function Qf(e){var t=e.stateNode,i=e.memoizedProps;try{for(var a=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);st(t,a,i),t[lt]=e,t[ht]=i}catch(p){Ie(e,e.return,p)}}var pn=!1,$e=!1,fu=!1,Zf=typeof WeakSet=="function"?WeakSet:Set,tt=null;function Fg(e,t){if(e=e.containerInfo,Iu=Ta,e=sc(e),is(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var a=i.getSelection&&i.getSelection();if(a&&a.rangeCount!==0){i=a.anchorNode;var f=a.anchorOffset,p=a.focusNode;a=a.focusOffset;try{i.nodeType,p.nodeType}catch{i=null;break e}var v=0,E=-1,C=-1,D=0,q=0,H=e,U=null;t:for(;;){for(var I;H!==i||f!==0&&H.nodeType!==3||(E=v+f),H!==p||a!==0&&H.nodeType!==3||(C=v+a),H.nodeType===3&&(v+=H.nodeValue.length),(I=H.firstChild)!==null;)U=H,H=I;for(;;){if(H===e)break t;if(U===i&&++D===f&&(E=v),U===p&&++q===a&&(C=v),(I=H.nextSibling)!==null)break;H=U,U=H.parentNode}H=I}i=E===-1||C===-1?null:{start:E,end:C}}else i=null}i=i||{start:0,end:0}}else i=null;for(wu={focusedElem:e,selectionRange:i},Ta=!1,tt=t;tt!==null;)if(t=tt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,tt=e;else for(;tt!==null;){switch(t=tt,p=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(i=0;i title"))),st(p,a,i),p[lt]=e,et(p),a=p;break e;case"link":var v=np("link","href",f).get(a+(i.href||""));if(v){for(var E=0;ELe&&(v=Le,Le=ue,ue=v);var x=oc(E,ue),A=oc(E,Le);if(x&&A&&(I.rangeCount!==1||I.anchorNode!==x.node||I.anchorOffset!==x.offset||I.focusNode!==A.node||I.focusOffset!==A.offset)){var N=H.createRange();N.setStart(x.node,x.offset),I.removeAllRanges(),ue>Le?(I.addRange(N),I.extend(A.node,A.offset)):(N.setEnd(A.node,A.offset),I.addRange(N))}}}}for(H=[],I=E;I=I.parentNode;)I.nodeType===1&&H.push({element:I,left:I.scrollLeft,top:I.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;Ei?32:i,w.T=null,i=vu,vu=null;var p=zn,v=vn;if(We=0,Ql=zn=null,vn=0,(be&6)!==0)throw Error(s(331));var E=be;if(be|=4,sd(p.current),id(p,p.current,v,i),be=E,Fi(0,!1),Ct&&typeof Ct.onPostCommitFiberRoot=="function")try{Ct.onPostCommitFiberRoot(ci,p)}catch{}return!0}finally{k.p=f,w.T=a,Md(e,t)}}function xd(e,t,i){t=Lt(i,t),t=$s(e.stateNode,t,2),e=Un(e,t,2),e!==null&&(di(e,2),Wt(e))}function Ie(e,t,i){if(e.tag===3)xd(e,e,i);else for(;t!==null;){if(t.tag===3){xd(t,e,i);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Hn===null||!Hn.has(a))){e=Lt(i,e),i=Nf(2),a=Un(t,i,2),a!==null&&(Df(i,a,t,e),di(a,2),Wt(a));break}}t=t.return}}function _u(e,t,i){var a=e.pingCache;if(a===null){a=e.pingCache=new Qg;var f=new Set;a.set(t,f)}else f=a.get(t),f===void 0&&(f=new Set,a.set(t,f));f.has(i)||(mu=!0,f.add(i),e=ey.bind(null,e,t,i),t.then(e,e))}function ey(e,t,i){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Ge===e&&(Ee&i)===i&&(Je===4||Je===3&&(Ee&62914560)===Ee&&300>He()-ta?(be&2)===0&&Zl(e,0):hu|=i,Kl===Ee&&(Kl=0)),Wt(e)}function Nd(e,t){t===0&&(t=Er()),e=tl(e,t),e!==null&&(di(e,t),Wt(e))}function ty(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),Nd(e,i)}function ny(e,t){var i=0;switch(e.tag){case 31:case 13:var a=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(s(314))}a!==null&&a.delete(t),Nd(e,i)}function ly(e,t){return rt(e,t)}var ua=null,Wl=null,Cu=!1,ra=!1,Au=!1,Bn=0;function Wt(e){e!==Wl&&e.next===null&&(Wl===null?ua=Wl=e:Wl=Wl.next=e),ra=!0,Cu||(Cu=!0,oy())}function Fi(e,t){if(!Au&&ra){Au=!0;do for(var i=!1,a=ua;a!==null;){if(e!==0){var f=a.pendingLanes;if(f===0)var p=0;else{var v=a.suspendedLanes,E=a.pingedLanes;p=(1<<31-At(42|e)+1)-1,p&=f&~(v&~E),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(i=!0,Id(a,p))}else p=Ee,p=po(a,a===Ge?p:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(p&3)===0||fi(a,p)||(i=!0,Id(a,p));a=a.next}while(i);Au=!1}}function iy(){Dd()}function Dd(){ra=Cu=!1;var e=0;Bn!==0&&hy()&&(e=Bn);for(var t=He(),i=null,a=ua;a!==null;){var f=a.next,p=bd(a,t);p===0?(a.next=null,i===null?ua=f:i.next=f,f===null&&(Wl=i)):(i=a,(e!==0||(p&3)!==0)&&(ra=!0)),a=f}We!==0&&We!==5||Fi(e),Bn!==0&&(Bn=0)}function bd(e,t){for(var i=e.suspendedLanes,a=e.pingedLanes,f=e.expirationTimes,p=e.pendingLanes&-62914561;0E)break;var q=C.transferSize,H=C.initiatorType;q&&Bd(H)&&(C=C.responseEnd,v+=q*(C"u"?null:document;function Wd(e,t,i){var a=jl;if(a&&typeof t=="string"&&t){var f=wt(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),$d.has(f)||($d.add(f),e={rel:e,crossOrigin:i,href:t},a.querySelector(f)===null&&(t=a.createElement("link"),st(t,"link",e),et(t),a.head.appendChild(t)))}}function Ay(e){Tn.D(e),Wd("dns-prefetch",e,null)}function My(e,t){Tn.C(e,t),Wd("preconnect",e,t)}function Ry(e,t,i){Tn.L(e,t,i);var a=jl;if(a&&e&&t){var f='link[rel="preload"][as="'+wt(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+wt(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+wt(i.imageSizes)+'"]')):f+='[href="'+wt(e)+'"]';var p=f;switch(t){case"style":p=ei(e);break;case"script":p=ti(e)}Pt.has(p)||(e=S({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),Pt.set(p,e),a.querySelector(f)!==null||t==="style"&&a.querySelector(Zi(p))||t==="script"&&a.querySelector($i(p))||(t=a.createElement("link"),st(t,"link",e),et(t),a.head.appendChild(t)))}}function xy(e,t){Tn.m(e,t);var i=jl;if(i&&e){var a=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+wt(a)+'"][href="'+wt(e)+'"]',p=f;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=ti(e)}if(!Pt.has(p)&&(e=S({rel:"modulepreload",href:e},t),Pt.set(p,e),i.querySelector(f)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector($i(p)))return}a=i.createElement("link"),st(a,"link",e),et(a),i.head.appendChild(a)}}}function Ny(e,t,i){Tn.S(e,t,i);var a=jl;if(a&&e){var f=_l(a).hoistableStyles,p=ei(e);t=t||"default";var v=f.get(p);if(!v){var E={loading:0,preload:null};if(v=a.querySelector(Zi(p)))E.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},i),(i=Pt.get(p))&&Bu(e,i);var C=v=a.createElement("link");et(C),st(C,"link",e),C._p=new Promise(function(D,q){C.onload=D,C.onerror=q}),C.addEventListener("load",function(){E.loading|=1}),C.addEventListener("error",function(){E.loading|=2}),E.loading|=4,ma(v,t,a)}v={type:"stylesheet",instance:v,count:1,state:E},f.set(p,v)}}}function Dy(e,t){Tn.X(e,t);var i=jl;if(i&&e){var a=_l(i).hoistableScripts,f=ti(e),p=a.get(f);p||(p=i.querySelector($i(f)),p||(e=S({src:e,async:!0},t),(t=Pt.get(f))&&Pu(e,t),p=i.createElement("script"),et(p),st(p,"link",e),i.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},a.set(f,p))}}function by(e,t){Tn.M(e,t);var i=jl;if(i&&e){var a=_l(i).hoistableScripts,f=ti(e),p=a.get(f);p||(p=i.querySelector($i(f)),p||(e=S({src:e,async:!0,type:"module"},t),(t=Pt.get(f))&&Pu(e,t),p=i.createElement("script"),et(p),st(p,"link",e),i.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},a.set(f,p))}}function jd(e,t,i,a){var f=(f=P.current)?pa(f):null;if(!f)throw Error(s(446));switch(e){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(t=ei(i.href),i=_l(f).hoistableStyles,a=i.get(t),a||(a={type:"style",instance:null,count:0,state:null},i.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){e=ei(i.href);var p=_l(f).hoistableStyles,v=p.get(e);if(v||(f=f.ownerDocument||f,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,v),(p=f.querySelector(Zi(e)))&&!p._p&&(v.instance=p,v.state.loading=5),Pt.has(e)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Pt.set(e,i),p||Uy(f,e,i,v.state))),t&&a===null)throw Error(s(528,""));return v}if(t&&a!==null)throw Error(s(529,""));return null;case"script":return t=i.async,i=i.src,typeof i=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=ti(i),i=_l(f).hoistableScripts,a=i.get(t),a||(a={type:"script",instance:null,count:0,state:null},i.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,e))}}function ei(e){return'href="'+wt(e)+'"'}function Zi(e){return'link[rel="stylesheet"]['+e+"]"}function ep(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Uy(e,t,i,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),st(t,"link",i),et(t),e.head.appendChild(t))}function ti(e){return'[src="'+wt(e)+'"]'}function $i(e){return"script[async]"+e}function tp(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+wt(i.href)+'"]');if(a)return t.instance=a,et(a),a;var f=S({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),et(a),st(a,"style",f),ma(a,i.precedence,e),t.instance=a;case"stylesheet":f=ei(i.href);var p=e.querySelector(Zi(f));if(p)return t.state.loading|=4,t.instance=p,et(p),p;a=ep(i),(f=Pt.get(f))&&Bu(a,f),p=(e.ownerDocument||e).createElement("link"),et(p);var v=p;return v._p=new Promise(function(E,C){v.onload=E,v.onerror=C}),st(p,"link",a),t.state.loading|=4,ma(p,i.precedence,e),t.instance=p;case"script":return p=ti(i.src),(f=e.querySelector($i(p)))?(t.instance=f,et(f),f):(a=i,(f=Pt.get(p))&&(a=S({},i),Pu(a,f)),e=e.ownerDocument||e,f=e.createElement("script"),et(f),st(f,"link",a),e.head.appendChild(f),t.instance=f);case"void":return null;default:throw Error(s(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,ma(a,i.precedence,e));return t.instance}function ma(e,t,i){for(var a=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=a.length?a[a.length-1]:null,p=f,v=0;v title"):null)}function Iy(e,t,i){if(i===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function ip(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function wy(e,t,i,a){if(i.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var f=ei(a.href),p=t.querySelector(Zi(f));if(p){t=p._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ga.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=p,et(p);return}p=t.ownerDocument||t,a=ep(a),(f=Pt.get(f))&&Bu(a,f),p=p.createElement("link"),et(p);var v=p;v._p=new Promise(function(E,C){v.onload=E,v.onerror=C}),st(p,"link",a),i.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,t),(t=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=ga.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var ku=0;function qy(e,t){return e.stylesheets&&e.count===0&&va(e,e.stylesheets),0ku?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(f)}}:null}function ga(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)va(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ya=null;function va(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ya=new Map,t.forEach(Ly,e),ya=null,ga.call(e))}function Ly(e,t){if(!(t.state.loading&4)){var i=ya.get(e);if(i)var a=i.get(null);else{i=new Map,ya.set(e,i);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),$u.exports=Wy(),$u.exports}var e0=jy();const t0=Km(e0),hl=({className:l})=>R.jsxs("svg",{className:`animate-spin h-5 w-5 text-white ${l}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[R.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),R.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),n0=({onSubmit:l,isLoading:n})=>{const[o,s]=ce.useState(""),r=d=>{d.preventDefault(),l(o.trim())};return R.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:R.jsxs("div",{className:"bg-gray-850 p-8 rounded-lg shadow-2xl w-full max-w-md border border-gray-700",children:[R.jsx("h2",{className:"text-2xl font-bold text-center text-gray-100 mb-2",children:"Citibank Demo Business"}),R.jsx("p",{className:"text-center text-gray-400 mb-1",children:"Code Platform"}),R.jsx("p",{className:"text-center text-gray-400 mb-6",children:"Enter GitHub PAT to begin."}),R.jsxs("form",{onSubmit:r,children:[R.jsxs("div",{className:"mb-4",children:[R.jsx("label",{htmlFor:"token-input",className:"block text-sm font-medium text-gray-300 mb-2",children:"GitHub Token"}),R.jsx("input",{id:"token-input",type:"password",value:o,onChange:d=>s(d.target.value),className:"w-full px-3 py-2 bg-gray-900 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"ghp_...",required:!0})]}),R.jsxs("div",{className:"text-xs text-gray-500 mb-6 space-y-2",children:[R.jsx("p",{children:"Token is used for API requests and is not stored."}),R.jsxs("p",{children:["A ",R.jsx("strong",{className:"text-gray-400",children:"classic"})," token with full ",R.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:"repo"})," scope is required."]}),R.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo",target:"_blank",rel:"noopener noreferrer",className:"text-indigo-400 hover:text-indigo-300 underline",children:"Create a classic token here."})]}),R.jsx("button",{type:"submit",disabled:n||!o,className:"w-full bg-indigo-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-850 focus:ring-indigo-500 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center",children:n?R.jsx(hl,{}):"Load Repositories"})]})]})})},Qm=l=>R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...l,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),Zm=l=>R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...l,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19a2 2 0 01-2-2V7a2 2 0 012-2h4l2 2h4a2 2 0 012 2v1M5 19h14a2 2 0 002-2v-5a2 2 0 00-2-2H9a2 2 0 00-2 2v5a2 2 0 01-2 2z"})}),l0=l=>R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...l,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),i0=l=>R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.353-.026.715-.026 1.068 0 1.13.094 1.976 1.057 1.976 2.192V7.5M8.25 7.5h7.5M8.25 7.5c0 1.135-.845 2.098-1.976 2.192a48.424 48.424 0 0 1-1.12 0c-1.131-.094-1.976-1.057-1.976-2.192S5.445 5.308 6.576 5.214a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192ZM9.75 9.75c0-1.135.845-2.098 1.976-2.192a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192S13.445 11.85 12.314 11.944a48.424 48.424 0 0 1-1.12 0c-1.131-.094-1.976-1.057-1.976-2.192ZM9.75 9.75c0 1.135-.845 2.098-1.976 2.192a48.424 48.424 0 0 1-1.12 0C5.524 11.85 4.68 10.887 4.68 9.75S5.524 7.65 6.654 7.556a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192Zm0 0h2.52m-2.52 0V3.375c0-1.135.845-2.098 1.976-2.192a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192V9.75m-4.632 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 5.25 12v2.25a2.25 2.25 0 0 0 2.25 2.25H16.5a2.25 2.25 0 0 0 2.25-2.25V12a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027m-9.198 0c-.065.21-.1.433-.1.662v2.25a2.25 2.25 0 0 0 2.25 2.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-2.25c0-.23-.035-.452-.1-.662m-1.246 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 12 6.75v-2.25a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 5.25 4.5v2.25a2.25 2.25 0 0 0 2.25 2.25m13.5 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 16.5 6.75v-2.25a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 9.75 4.5v2.25a2.25 2.25 0 0 0 2.25 2.25m-1.246 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 12 11.25v2.25a2.25 2.25 0 0 0 2.25 2.25h.09a48.566 48.566 0 0 1 1.658-.027A2.25 2.25 0 0 0 18.75 13.5v-2.25a2.25 2.25 0 0 0-2.25-2.25m-2.858 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 9.75 11.25v2.25a2.25 2.25 0 0 0 2.25 2.25h.09a48.566 48.566 0 0 1 1.658-.027A2.25 2.25 0 0 0 16.5 13.5v-2.25a2.25 2.25 0 0 0-2.25-2.25M12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z"})}),$m=({node:l,repoId:n,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedFiles:d,onFileSelection:m,onDirectorySelection:g})=>{const[y,h]=ce.useState(!1),T=ce.useRef(null),S=l.type==="dir";ce.useEffect(()=>{if(S&&T.current){const V=vr(l.children).map(J=>`${n}::${J}`);if(V.length===0){T.current.indeterminate=!1,T.current.checked=!1;return}const Y=V.filter(J=>d.has(J)).length;Y>0&&Y{if(S)g(l.children,n,V.target.checked);else{const Y=`${n}::${l.path}`;m(Y,V.target.checked)}};if(S)return R.jsxs("div",{children:[R.jsxs("div",{className:"flex items-center p-1.5 hover:bg-gray-700 rounded-md group",children:[R.jsx("input",{type:"checkbox",ref:T,onChange:_,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),R.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>h(!y),children:[y?R.jsx(Zm,{className:"w-5 h-5 mr-2 text-indigo-400"}):R.jsx(Qm,{className:"w-5 h-5 mr-2 text-indigo-400"}),R.jsx("span",{children:l.name})]})]}),y&&R.jsx("div",{className:"pl-6 border-l border-gray-700 ml-4",children:l.children.map(V=>R.jsx($m,{node:V,repoId:n,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedFiles:d,onFileSelection:m,onDirectorySelection:g},V.path))})]});const b=d.has(`${n}::${l.path}`),z=r===n&&s===l.path;return R.jsxs("div",{className:`flex items-center p-1.5 group rounded-md ${z?"bg-indigo-900 bg-opacity-50":"hover:bg-gray-700"}`,children:[R.jsx("input",{type:"checkbox",checked:b,onChange:_,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),R.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>o(n,l.path),children:[R.jsx(l0,{className:"w-5 h-5 mr-2 text-gray-400"}),R.jsx("span",{className:z?"text-white":"text-gray-300",children:l.name})]})]})},o0=l=>{const{repo:n,tree:o,onFileClick:s,selectedFilePath:r,selectedRepo:d,selectedFiles:m,onFileSelection:g,onDirectorySelection:y}=l,h=n.full_name===d,[T,S]=ce.useState(h);return ce.useEffect(()=>{h&&!T&&S(!0)},[h,T]),R.jsxs("div",{className:"mb-2",children:[R.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-gray-700 rounded-md group",children:R.jsxs("h3",{className:"text-lg font-semibold cursor-pointer flex items-center flex-grow",onClick:()=>S(!T),children:[T?R.jsx(Zm,{className:"w-5 h-5 mr-2"}):R.jsx(Qm,{className:"w-5 h-5 mr-2"}),n.full_name]})}),T&&R.jsx("div",{className:"pl-4 border-l border-gray-700 ml-2",children:o.map(_=>R.jsx($m,{node:_,repoId:n.full_name,onFileClick:s,selectedFilePath:r,selectedRepo:d,selectedFiles:m,onFileSelection:g,onDirectorySelection:y},_.path))})]})},a0=({fsTree:l,onFileSelect:n,onStartMultiEdit:o,selectedFilePath:s,selectedRepo:r,selectedFiles:d,onFileSelection:m,onDirectorySelection:g})=>R.jsxs("div",{className:"p-4 text-gray-300",children:[R.jsx("div",{className:"flex justify-between items-center mb-4 border-b border-gray-700 pb-2",children:R.jsx("h2",{className:"text-xl font-bold",children:"Repositories"})}),d.size>0&&R.jsx("div",{className:"mb-4 sticky top-0 bg-gray-900 py-2 z-10",children:R.jsxs("button",{onClick:o,className:"w-full flex items-center justify-center gap-2 bg-amber-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-amber-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-amber-500 transition-colors",children:[R.jsx(i0,{className:"w-5 h-5"}),"AI Edit ",d.size," File",d.size>1?"s":""]})}),Object.keys(l).sort().map(y=>R.jsx(o0,{repo:l[y].repo,tree:l[y].tree,onFileClick:n,selectedFilePath:s,selectedRepo:r,selectedFiles:d,onFileSelection:m,onDirectorySelection:g},y))]}),s0=({onClose:l,onSubmit:n,isLoading:o})=>{const[s,r]=ce.useState(""),d=async m=>{m.preventDefault(),!(!s.trim()||o)&&(await n(s),l())};return R.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:R.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-lg border border-gray-700",onClick:m=>m.stopPropagation(),children:[R.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"AI Assistant"}),R.jsxs("form",{onSubmit:d,children:[R.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Describe the changes to be made:"}),R.jsx("textarea",{value:s,onChange:m=>r(m.target.value),placeholder:"e.g., 'Refactor this to use async/await'",className:"w-full h-40 bg-gray-900 p-3 rounded-md mb-4 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none",autoFocus:!0}),R.jsxs("div",{className:"flex justify-end gap-4",children:[R.jsx("button",{type:"button",onClick:l,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:o,children:"Cancel"}),R.jsx("button",{type:"submit",disabled:o||!s.trim(),className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:o?R.jsx(hl,{}):"Generate Edit"})]})]})]})})},u0=({onClose:l,onCommit:n,isLoading:o,defaultMessage:s})=>{const[r,d]=ce.useState(s);ce.useEffect(()=>{d(s)},[s]);const m=async g=>{g.preventDefault(),!(!r.trim()||o)&&await n(r)};return R.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:R.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-lg border border-gray-700",onClick:g=>g.stopPropagation(),children:[R.jsx("h2",{className:"text-xl font-bold text-green-400 mb-4",children:"Commit Changes"}),R.jsxs("form",{onSubmit:m,children:[R.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Enter a commit message:"}),R.jsx("input",{type:"text",value:r,onChange:g=>d(g.target.value),className:"w-full bg-gray-900 p-3 rounded-md mb-4 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-green-500",autoFocus:!0}),R.jsxs("div",{className:"flex justify-end gap-4",children:[R.jsx("button",{type:"button",onClick:l,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:o,children:"Cancel"}),R.jsx("button",{type:"submit",disabled:o||!r.trim(),className:"px-4 py-2 bg-green-600 text-white font-semibold rounded-md hover:bg-green-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:o?R.jsx(hl,{}):"Commit"})]})]})]})})},r0=l=>R.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.898 20.562L16.5 21.75l-.398-1.188a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.188-.398a2.25 2.25 0 001.423-1.423L16.5 15.75l.398 1.188a2.25 2.25 0 001.423 1.423L19.5 18.75l-1.188.398a2.25 2.25 0 00-1.423 1.423z"})}),c0=({file:l,isActive:n,onSelect:o,onClose:s})=>{const r=l.content!==l.edited,d=l.repoId+"::"+l.path,m=l.path.split("/").pop();return R.jsxs("div",{onClick:()=>o(d),className:`flex items-center justify-between p-2 px-4 cursor-pointer border-b-2 ${n?"bg-gray-850 border-indigo-500 text-white":"bg-gray-900 border-transparent text-gray-400 hover:bg-gray-800"}`,children:[R.jsx("span",{className:"text-sm font-medium pr-2",children:m}),R.jsxs("div",{className:"flex items-center",children:[r&&R.jsx("div",{className:"w-2 h-2 bg-yellow-400 rounded-full mr-2"}),R.jsx("button",{onClick:g=>{g.stopPropagation(),s(d)},className:"text-gray-500 hover:text-white rounded-full w-5 h-5 flex items-center justify-center hover:bg-gray-700 text-xs",children:"×"})]})]})},f0=l=>{const{openFiles:n,activeFile:o,onCommit:s,onAiEdit:r,onFileContentChange:d,onCloseFile:m,onSetActiveFile:g,isLoading:y,branches:h,currentBranch:T,onBranchChange:S,onCreateBranch:_,onCreatePullRequest:b}=l,[z,V]=ce.useState(!1),[Y,J]=ce.useState(!1),[K,B]=ce.useState(""),[ee,le]=ce.useState(!1),[ie,X]=ce.useState(!1),[ve,W]=ce.useState(""),[Q,ge]=ce.useState("");ce.useEffect(()=>{o&&W(`Update ${o.path}`)},[o]);const me=o?o.edited!==o.content:!1,Ae=async oe=>{if(!oe.trim()||!o)return;const Me=o.repoId+"::"+o.path;let M="";d(Me,"");const G=Z=>{M+=Z,d(Me,M)};await r(o.content,oe,G);const O=M.replace(/^```(?:\w*\n)?/,"").replace(/\n?```$/,"").trim();d(Me,O||M)},ut=async oe=>{!oe.trim()||!o||(await s(oe),J(!1))},Xe=async()=>{K.trim()&&(await _(K),B(""),le(!1))},w=async()=>{ve.trim()&&(await b(ve,Q),X(!1),ge(""))};if(!o)return R.jsx("div",{className:"flex-grow flex items-center justify-center bg-gray-850 text-gray-500",children:R.jsx("p",{children:"Select a file to begin editing."})});const k=o.repoId+"::"+o.path,se=`Update ${o.path}`;return R.jsxs("div",{className:"flex flex-col h-full bg-gray-850 relative",children:[R.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-700 bg-gray-900 flex-wrap gap-2",children:[R.jsxs("div",{children:[R.jsx("h3",{className:"text-md font-semibold text-gray-200",children:o.path}),R.jsx("p",{className:"text-xs text-gray-400",children:o.repoId})]}),R.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[R.jsxs("div",{className:"flex items-center gap-2",children:[R.jsx("select",{id:"branch-sel",value:T||"",onChange:oe=>S(oe.target.value),disabled:y,className:"bg-gray-800 p-2 rounded-md text-sm border border-gray-700 focus:outline-none focus:ring-2 focus:ring-cyan-500",children:h.map(oe=>R.jsx("option",{value:oe.name,children:oe.name},oe.name))}),ee?R.jsxs("div",{className:"flex gap-2 items-center",children:[R.jsx("input",{type:"text",value:K,onChange:oe=>B(oe.target.value),placeholder:"new-branch-name",className:"bg-gray-800 p-2 rounded-md text-sm border border-gray-700 focus:outline-none focus:ring-2 focus:ring-cyan-500"}),R.jsx("button",{onClick:Xe,disabled:y||!K.trim(),className:"text-sm bg-cyan-600 text-white font-semibold py-1 px-2 rounded hover:bg-cyan-700 disabled:bg-gray-500",children:"Create"}),R.jsx("button",{onClick:()=>le(!1),className:"text-sm bg-gray-600 text-white font-semibold py-1 px-2 rounded hover:bg-gray-700",children:"X"})]}):R.jsx("button",{onClick:()=>le(!0),className:"text-sm text-cyan-400 hover:underline px-3 py-1.5",disabled:y,children:"New Branch"})]}),R.jsx("button",{onClick:()=>J(!0),disabled:y||!me,className:"bg-green-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-green-700 disabled:bg-gray-500 disabled:cursor-not-allowed",children:"Commit Active File"}),T&&T!==o.defaultBranch&&R.jsx("button",{onClick:()=>X(!ie),className:"bg-cyan-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-cyan-700 disabled:bg-gray-500",disabled:y,children:ie?"Cancel PR":"Create Pull Request"})]})]}),ie&&R.jsxs("div",{className:"p-4 bg-gray-800 border-b border-gray-700",children:[R.jsx("h4",{className:"font-semibold mb-2 text-gray-200",children:"New Pull Request"}),R.jsxs("p",{className:"text-xs text-gray-400 mb-2",children:["From ",R.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:T})," into ",R.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:o.defaultBranch})]}),R.jsx("input",{type:"text",value:ve,onChange:oe=>W(oe.target.value),placeholder:"PR title",className:"w-full bg-gray-900 p-2 rounded-md mb-2 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-cyan-500"}),R.jsx("textarea",{value:Q,onChange:oe=>ge(oe.target.value),placeholder:"Describe changes...",className:"w-full h-24 bg-gray-900 p-2 rounded-md mb-2 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-cyan-500 resize-none"}),R.jsx("div",{className:"flex gap-2",children:R.jsx("button",{onClick:w,disabled:y||!ve.trim(),className:"text-sm bg-cyan-600 text-white font-semibold py-1 px-2 rounded hover:bg-cyan-700 disabled:bg-gray-500 flex items-center justify-center",children:y?R.jsx(hl,{className:"h-4 w-4"}):"Submit PR"})})]}),R.jsx("div",{className:"flex border-b border-gray-700 bg-gray-900 overflow-x-auto",children:n.map(oe=>R.jsx(c0,{file:oe,isActive:oe.repoId+"::"+oe.path===k,onSelect:g,onClose:m},oe.repoId+"::"+oe.path))}),R.jsx("div",{className:"flex-grow p-4",children:R.jsx("textarea",{value:o.edited,onChange:oe=>d(k,oe.target.value),className:"w-full h-full border border-gray-700 rounded-md bg-gray-950 text-gray-200 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-indigo-500",spellCheck:"false"},k)}),R.jsx("button",{onClick:()=>V(!0),"aria-label":"Edit with AI",className:"absolute bottom-6 right-6 bg-indigo-600 text-white rounded-full p-4 shadow-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-4 focus:ring-offset-gray-850 focus:ring-indigo-500 transition-transform hover:scale-110",children:R.jsx(r0,{className:"h-6 w-6"})}),z&&R.jsx(s0,{onClose:()=>V(!1),onSubmit:Ae,isLoading:y}),Y&&R.jsx(u0,{onClose:()=>J(!1),onCommit:ut,isLoading:y,defaultMessage:se})]})},d0="https://api.github.com";async function gl(l,n,o={}){const s=await fetch(`${d0}${l}`,{...o,headers:{...o.headers,Authorization:`Bearer ${n}`,Accept:"application/vnd.github.v3+json","X-GitHub-Api-Version":"2022-11-28"}});if(!s.ok){const r=await s.json();throw new Error(`GitHub API Error: ${s.status} ${r.message||""}`)}return s.status===204||s.status===201&&!s.body?null:s.json()}async function p0(l){let n=[],o=1;const s=100;for(;;){const r=await gl(`/user/repos?type=owner&per_page=${s}&page=${o}`,l);if(n=n.concat(r),r.length{const n={children:{}};l.forEach(s=>{if(s.type!=="blob")return;const r=s.path.split("/");let d=n.children;r.forEach((m,g)=>{const y=g===r.length-1,h=r.slice(0,g+1).join("/");y?d[m]||(d[m]={type:"file",path:s.path,name:m}):(d[m]||(d[m]={type:"dir",path:h,name:m,children:{}}),d=d[m].children)})});const o=s=>{const r=Object.values(s).map(d=>d.type==="dir"?{...d,children:o(d.children)}:d);return r.sort((d,m)=>d.type!==m.type?d.type==="dir"?-1:1:d.name.localeCompare(m.name)),r};return o(n.children)};async function h0(l,n,o,s){const{tree:r}=await gl(`/repos/${n}/${o}/git/trees/${s}?recursive=1`,l);return m0(r)}async function Ra(l,n,o,s,r){const d=r?`/repos/${n}/${o}/contents/${s}?ref=${r}`:`/repos/${n}/${o}/contents/${s}`,m=await gl(d,l);return{...m,content:atob(m.content)}}async function Np(l,n,o){return gl(`/repos/${n}/${o}/branches?per_page=100`,l)}async function g0(l,n,o,s,r){return gl(`/repos/${n}/${o}/git/refs`,l,{method:"POST",body:JSON.stringify({ref:`refs/heads/${s}`,sha:r}),headers:{"Content-Type":"application/json"}})}function y0(l){return btoa(unescape(encodeURIComponent(l)))}async function Dp({token:l,owner:n,repo:o,branch:s,path:r,content:d,message:m,sha:g}){const y={message:m,content:y0(d),sha:g,branch:s};return(await gl(`/repos/${n}/${o}/contents/${r}`,l,{method:"PUT",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})).content.sha}async function v0({token:l,owner:n,repo:o,title:s,body:r,head:d,base:m}){const g={title:s,body:r,head:d,base:m};return gl(`/repos/${n}/${o}/pulls`,l,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json"}})}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */let T0,S0;function E0(){return{geminiUrl:T0,vertexUrl:S0}}function _0(l,n,o,s){var r,d;if(!(l!=null&&l.baseUrl)){const m=E0();return n?(r=m.vertexUrl)!==null&&r!==void 0?r:o:(d=m.geminiUrl)!==null&&d!==void 0?d:s}return l.baseUrl}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class yl{}function te(l,n){const o=/\{([^}]+)\}/g;return l.replace(o,(s,r)=>{if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];return d!=null?String(d):""}else throw new Error(`Key '${r}' not found in valueMap.`)})}function c(l,n,o){for(let d=0;d({}));else throw new Error(`Value must be a list given an array path ${m}`);if(Array.isArray(l[g])){const y=l[g];if(Array.isArray(o))for(let h=0;hu(g,n.slice(s+1),o)):o}else return o}else l=l[r]}return l}catch(s){if(s instanceof TypeError)return o;throw s}}function C0(l,n){for(const[o,s]of Object.entries(n)){const r=o.split("."),d=s.split("."),m=new Set;let g=-1;for(let y=0;yg)for(let y=g;y=n.length||typeof l!="object"||l===null)return;const d=n[s];if(d.endsWith("[]")){const m=d.slice(0,-2),g=l;if(m in g&&Array.isArray(g[m]))for(const y of g[m])nr(y,n,o,s+1,r)}else if(d==="*"){if(typeof l=="object"&&l!==null&&!Array.isArray(l)){const m=l,g=Object.keys(m).filter(h=>!h.startsWith("_")&&!r.has(h)),y={};for(const h of g)y[h]=m[h];for(const[h,T]of Object.entries(y)){const S=[];for(const _ of o.slice(s))_==="*"?S.push(h):S.push(_);c(m,S,T)}for(const h of g)delete m[h]}}else{const m=l;d in m&&nr(m[d],n,o,s+1,r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function dr(l){if(typeof l!="string")throw new Error("fromImageBytes must be a string");return l}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function A0(l){const n={},o=u(l,["operationName"]);o!=null&&c(n,["operationName"],o);const s=u(l,["resourceName"]);return s!=null&&c(n,["_url","resourceName"],s),n}function M0(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const m=u(l,["response","generateVideoResponse"]);return m!=null&&c(n,["response"],x0(m)),n}function R0(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const m=u(l,["response"]);return m!=null&&c(n,["response"],N0(m)),n}function x0(l){const n={},o=u(l,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>D0(m))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function N0(l){const n={},o=u(l,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>b0(m))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function D0(l){const n={},o=u(l,["video"]);return o!=null&&c(n,["video"],w0(o)),n}function b0(l){const n={},o=u(l,["_self"]);return o!=null&&c(n,["video"],q0(o)),n}function U0(l){const n={},o=u(l,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function I0(l){const n={},o=u(l,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function w0(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["encodedVideo"]);s!=null&&c(n,["videoBytes"],dr(s));const r=u(l,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function q0(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["uri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["videoBytes"],dr(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var bp;(function(l){l.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",l.OUTCOME_OK="OUTCOME_OK",l.OUTCOME_FAILED="OUTCOME_FAILED",l.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(bp||(bp={}));var Up;(function(l){l.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",l.PYTHON="PYTHON"})(Up||(Up={}));var Xn;(function(l){l.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",l.STRING="STRING",l.NUMBER="NUMBER",l.INTEGER="INTEGER",l.BOOLEAN="BOOLEAN",l.ARRAY="ARRAY",l.OBJECT="OBJECT",l.NULL="NULL"})(Xn||(Xn={}));var Ip;(function(l){l.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",l.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",l.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",l.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",l.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",l.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",l.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",l.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",l.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",l.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"})(Ip||(Ip={}));var wp;(function(l){l.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",l.SEVERITY="SEVERITY",l.PROBABILITY="PROBABILITY"})(wp||(wp={}));var qp;(function(l){l.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",l.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",l.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",l.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",l.BLOCK_NONE="BLOCK_NONE",l.OFF="OFF"})(qp||(qp={}));var Lp;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.MODE_DYNAMIC="MODE_DYNAMIC"})(Lp||(Lp={}));var Gp;(function(l){l.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",l.NO_AUTH="NO_AUTH",l.API_KEY_AUTH="API_KEY_AUTH",l.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",l.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",l.OAUTH="OAUTH",l.OIDC_AUTH="OIDC_AUTH"})(Gp||(Gp={}));var Hp;(function(l){l.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",l.SIMPLE_SEARCH="SIMPLE_SEARCH",l.ELASTIC_SEARCH="ELASTIC_SEARCH"})(Hp||(Hp={}));var zp;(function(l){l.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",l.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",l.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",l.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",l.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(zp||(zp={}));var Vp;(function(l){l.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",l.STOP="STOP",l.MAX_TOKENS="MAX_TOKENS",l.SAFETY="SAFETY",l.RECITATION="RECITATION",l.LANGUAGE="LANGUAGE",l.OTHER="OTHER",l.BLOCKLIST="BLOCKLIST",l.PROHIBITED_CONTENT="PROHIBITED_CONTENT",l.SPII="SPII",l.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",l.IMAGE_SAFETY="IMAGE_SAFETY",l.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",l.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",l.NO_IMAGE="NO_IMAGE"})(Vp||(Vp={}));var Bp;(function(l){l.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",l.NEGLIGIBLE="NEGLIGIBLE",l.LOW="LOW",l.MEDIUM="MEDIUM",l.HIGH="HIGH"})(Bp||(Bp={}));var Pp;(function(l){l.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",l.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",l.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",l.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",l.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Pp||(Pp={}));var kp;(function(l){l.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",l.SAFETY="SAFETY",l.OTHER="OTHER",l.BLOCKLIST="BLOCKLIST",l.PROHIBITED_CONTENT="PROHIBITED_CONTENT",l.IMAGE_SAFETY="IMAGE_SAFETY"})(kp||(kp={}));var Yp;(function(l){l.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",l.ON_DEMAND="ON_DEMAND",l.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Yp||(Yp={}));var ba;(function(l){l.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",l.TEXT="TEXT",l.IMAGE="IMAGE",l.AUDIO="AUDIO"})(ba||(ba={}));var Jp;(function(l){l.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",l.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",l.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",l.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Jp||(Jp={}));var lr;(function(l){l.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",l.JOB_STATE_QUEUED="JOB_STATE_QUEUED",l.JOB_STATE_PENDING="JOB_STATE_PENDING",l.JOB_STATE_RUNNING="JOB_STATE_RUNNING",l.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",l.JOB_STATE_FAILED="JOB_STATE_FAILED",l.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",l.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",l.JOB_STATE_PAUSED="JOB_STATE_PAUSED",l.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",l.JOB_STATE_UPDATING="JOB_STATE_UPDATING",l.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(lr||(lr={}));var Op;(function(l){l.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",l.TUNING_MODE_FULL="TUNING_MODE_FULL",l.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Op||(Op={}));var Fp;(function(l){l.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",l.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",l.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",l.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",l.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",l.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",l.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Fp||(Fp={}));var Xp;(function(l){l.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",l.TUNING_TASK_I2V="TUNING_TASK_I2V",l.TUNING_TASK_T2V="TUNING_TASK_T2V"})(Xp||(Xp={}));var Kp;(function(l){l.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",l.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",l.BALANCED="BALANCED",l.PRIORITIZE_COST="PRIORITIZE_COST"})(Kp||(Kp={}));var Qp;(function(l){l.UNSPECIFIED="UNSPECIFIED",l.BLOCKING="BLOCKING",l.NON_BLOCKING="NON_BLOCKING"})(Qp||(Qp={}));var Zp;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.MODE_DYNAMIC="MODE_DYNAMIC"})(Zp||(Zp={}));var $p;(function(l){l.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",l.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})($p||($p={}));var Wp;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.AUTO="AUTO",l.ANY="ANY",l.NONE="NONE",l.VALIDATED="VALIDATED"})(Wp||(Wp={}));var jp;(function(l){l.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",l.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",l.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",l.BLOCK_NONE="BLOCK_NONE"})(jp||(jp={}));var em;(function(l){l.DONT_ALLOW="DONT_ALLOW",l.ALLOW_ADULT="ALLOW_ADULT",l.ALLOW_ALL="ALLOW_ALL"})(em||(em={}));var tm;(function(l){l.auto="auto",l.en="en",l.ja="ja",l.ko="ko",l.hi="hi",l.zh="zh",l.pt="pt",l.es="es"})(tm||(tm={}));var nm;(function(l){l.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",l.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",l.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",l.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",l.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(nm||(nm={}));var lm;(function(l){l.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",l.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",l.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",l.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(lm||(lm={}));var im;(function(l){l.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",l.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",l.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",l.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(im||(im={}));var om;(function(l){l.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",l.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",l.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",l.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",l.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",l.EDIT_MODE_STYLE="EDIT_MODE_STYLE",l.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",l.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(om||(om={}));var am;(function(l){l.FOREGROUND="FOREGROUND",l.BACKGROUND="BACKGROUND",l.PROMPT="PROMPT",l.SEMANTIC="SEMANTIC",l.INTERACTIVE="INTERACTIVE"})(am||(am={}));var sm;(function(l){l.ASSET="ASSET",l.STYLE="STYLE"})(sm||(sm={}));var um;(function(l){l.INSERT="INSERT",l.REMOVE="REMOVE",l.REMOVE_STATIC="REMOVE_STATIC",l.OUTPAINT="OUTPAINT"})(um||(um={}));var rm;(function(l){l.OPTIMIZED="OPTIMIZED",l.LOSSLESS="LOSSLESS"})(rm||(rm={}));var cm;(function(l){l.STATE_UNSPECIFIED="STATE_UNSPECIFIED",l.PROCESSING="PROCESSING",l.ACTIVE="ACTIVE",l.FAILED="FAILED"})(cm||(cm={}));var fm;(function(l){l.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",l.UPLOADED="UPLOADED",l.GENERATED="GENERATED"})(fm||(fm={}));var dm;(function(l){l.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",l.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",l.RESPONSE_REJECTED="RESPONSE_REJECTED",l.NEED_MORE_INPUT="NEED_MORE_INPUT"})(dm||(dm={}));var pm;(function(l){l.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",l.TEXT="TEXT",l.IMAGE="IMAGE",l.VIDEO="VIDEO",l.AUDIO="AUDIO",l.DOCUMENT="DOCUMENT"})(pm||(pm={}));var mm;(function(l){l.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",l.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",l.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(mm||(mm={}));var hm;(function(l){l.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",l.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",l.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(hm||(hm={}));var gm;(function(l){l.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",l.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",l.NO_INTERRUPTION="NO_INTERRUPTION"})(gm||(gm={}));var ym;(function(l){l.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",l.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",l.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(ym||(ym={}));var vm;(function(l){l.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",l.SILENT="SILENT",l.WHEN_IDLE="WHEN_IDLE",l.INTERRUPT="INTERRUPT"})(vm||(vm={}));var Tm;(function(l){l.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",l.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",l.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",l.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",l.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",l.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",l.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",l.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",l.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",l.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",l.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",l.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",l.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(Tm||(Tm={}));var Sm;(function(l){l.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",l.QUALITY="QUALITY",l.DIVERSITY="DIVERSITY",l.VOCALIZATION="VOCALIZATION"})(Sm||(Sm={}));var li;(function(l){l.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",l.PLAY="PLAY",l.PAUSE="PAUSE",l.STOP="STOP",l.RESET_CONTEXT="RESET_CONTEXT"})(li||(li={}));class ir{constructor(n){const o={};for(const s of n.headers.entries())o[s[0]]=s[1];this.headers=o,this.responseInternal=n}json(){return this.responseInternal.json()}}class io{get text(){var n,o,s,r,d,m,g,y;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.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 h="",T=!1;const S=[];for(const _ of(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[b,z]of Object.entries(_))b!=="text"&&b!=="thought"&&(z!==null||z!==void 0)&&S.push(b);if(typeof _.text=="string"){if(typeof _.thought=="boolean"&&_.thought)continue;T=!0,h+=_.text}}return S.length>0&&console.warn(`there are non-text parts ${S} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),T?h:void 0}get data(){var n,o,s,r,d,m,g,y;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.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 h="";const T=[];for(const S of(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[_,b]of Object.entries(S))_!=="inlineData"&&(b!==null||b!==void 0)&&T.push(_);S.inlineData&&typeof S.inlineData.data=="string"&&(h+=atob(S.inlineData.data))}return T.length>0&&console.warn(`there are non-data parts ${T} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),h.length>0?btoa(h):void 0}get functionCalls(){var n,o,s,r,d,m,g,y;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.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 h=(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(T=>T.functionCall).map(T=>T.functionCall).filter(T=>T!==void 0);if((h==null?void 0:h.length)!==0)return h}get executableCode(){var n,o,s,r,d,m,g,y,h;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.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 T=(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(S=>S.executableCode).map(S=>S.executableCode).filter(S=>S!==void 0);if((T==null?void 0:T.length)!==0)return(h=T==null?void 0:T[0])===null||h===void 0?void 0:h.code}get codeExecutionResult(){var n,o,s,r,d,m,g,y,h;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.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 T=(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(S=>S.codeExecutionResult).map(S=>S.codeExecutionResult).filter(S=>S!==void 0);if((T==null?void 0:T.length)!==0)return(h=T==null?void 0:T[0])===null||h===void 0?void 0:h.output}}class Em{}class _m{}class L0{}class G0{}class H0{}class z0{}class Cm{}class Am{}class Mm{}class V0{}class Ua{_fromAPIResponse({apiResponse:n,isVertexAI:o}){const s=new Ua;let r;const d=n;return o?r=R0(d):r=M0(d),Object.assign(s,r),s}}class Rm{}class xm{}class Nm{}class B0{}class P0{}class k0{}class Dm{}class Y0{get text(){var n,o,s;let r="",d=!1;const m=[];for(const g of(s=(o=(n=this.serverContent)===null||n===void 0?void 0:n.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[y,h]of Object.entries(g))y!=="text"&&y!=="thought"&&h!==null&&m.push(y);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;d=!0,r+=g.text}}return m.length>0&&console.warn(`there are non-text parts ${m} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),d?r:void 0}get data(){var n,o,s;let r="";const d=[];for(const m of(s=(o=(n=this.serverContent)===null||n===void 0?void 0:n.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[g,y]of Object.entries(m))g!=="inlineData"&&y!==null&&d.push(g);m.inlineData&&typeof m.inlineData.data=="string"&&(r+=atob(m.inlineData.data))}return d.length>0&&console.warn(`there are non-data parts ${d} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),r.length>0?btoa(r):void 0}}class J0{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function De(l,n){if(!n||typeof n!="string")throw new Error("model is required and must be a string");if(l.isVertexAI()){if(n.startsWith("publishers/")||n.startsWith("projects/")||n.startsWith("models/"))return n;if(n.indexOf("/")>=0){const o=n.split("/",2);return`publishers/${o[0]}/models/${o[1]}`}else return`publishers/google/models/${n}`}else return n.startsWith("models/")||n.startsWith("tunedModels/")?n:`models/${n}`}function Wm(l,n){const o=De(l,n);return o?o.startsWith("publishers/")&&l.isVertexAI()?`projects/${l.getProject()}/locations/${l.getLocation()}/${o}`:o.startsWith("models/")&&l.isVertexAI()?`projects/${l.getProject()}/locations/${l.getLocation()}/publishers/google/${o}`:o:""}function jm(l){return Array.isArray(l)?l.map(n=>Ia(n)):[Ia(l)]}function Ia(l){if(typeof l=="object"&&l!==null)return l;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof l}`)}function eh(l){const n=Ia(l);if(n.mimeType&&n.mimeType.startsWith("image/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function th(l){const n=Ia(l);if(n.mimeType&&n.mimeType.startsWith("audio/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function bm(l){if(l==null)throw new Error("PartUnion is required");if(typeof l=="object")return l;if(typeof l=="string")return{text:l};throw new Error(`Unsupported part type: ${typeof l}`)}function nh(l){if(l==null||Array.isArray(l)&&l.length===0)throw new Error("PartListUnion is required");return Array.isArray(l)?l.map(n=>bm(n)):[bm(l)]}function or(l){return l!=null&&typeof l=="object"&&"parts"in l&&Array.isArray(l.parts)}function Um(l){return l!=null&&typeof l=="object"&&"functionCall"in l}function Im(l){return l!=null&&typeof l=="object"&&"functionResponse"in l}function ft(l){if(l==null)throw new Error("ContentUnion is required");return or(l)?l:{role:"user",parts:nh(l)}}function pr(l,n){if(!n)return[];if(l.isVertexAI()&&Array.isArray(n))return n.flatMap(o=>{const s=ft(o);return s.parts&&s.parts.length>0&&s.parts[0].text!==void 0?[s.parts[0].text]:[]});if(l.isVertexAI()){const o=ft(n);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]}return Array.isArray(n)?n.map(o=>ft(o)):[ft(n)]}function kt(l){if(l==null||Array.isArray(l)&&l.length===0)throw new Error("contents are required");if(!Array.isArray(l)){if(Um(l)||Im(l))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[ft(l)]}const n=[],o=[],s=or(l[0]);for(const r of l){const d=or(r);if(d!=s)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(d)n.push(r);else{if(Um(r)||Im(r))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");o.push(r)}}return s||n.push({role:"user",parts:nh(o)}),n}function O0(l,n){l.includes("null")&&(n.nullable=!0);const o=l.filter(s=>s!=="null");if(o.length===1)n.type=Object.values(Xn).includes(o[0].toUpperCase())?o[0].toUpperCase():Xn.TYPE_UNSPECIFIED;else{n.anyOf=[];for(const s of o)n.anyOf.push({type:Object.values(Xn).includes(s.toUpperCase())?s.toUpperCase():Xn.TYPE_UNSPECIFIED})}}function ii(l){const n={},o=["items"],s=["anyOf"],r=["properties"];if(l.type&&l.anyOf)throw new Error("type and anyOf cannot be both populated.");const d=l.anyOf;d!=null&&d.length==2&&(d[0].type==="null"?(n.nullable=!0,l=d[1]):d[1].type==="null"&&(n.nullable=!0,l=d[0])),l.type instanceof Array&&O0(l.type,n);for(const[m,g]of Object.entries(l))if(g!=null)if(m=="type"){if(g==="null")throw new Error("type: null can not be the only possible type for the field.");if(g instanceof Array)continue;n.type=Object.values(Xn).includes(g.toUpperCase())?g.toUpperCase():Xn.TYPE_UNSPECIFIED}else if(o.includes(m))n[m]=ii(g);else if(s.includes(m)){const y=[];for(const h of g){if(h.type=="null"){n.nullable=!0;continue}y.push(ii(h))}n[m]=y}else if(r.includes(m)){const y={};for(const[h,T]of Object.entries(g))y[h]=ii(T);n[m]=y}else{if(m==="additionalProperties")continue;n[m]=g}return n}function mr(l){return ii(l)}function hr(l){if(typeof l=="object")return l;if(typeof l=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:l}}};throw new Error(`Unsupported speechConfig type: ${typeof l}`)}function gr(l){if("multiSpeakerVoiceConfig"in l)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return l}function si(l){if(l.functionDeclarations)for(const n of l.functionDeclarations)n.parameters&&(Object.keys(n.parameters).includes("$schema")?n.parametersJsonSchema||(n.parametersJsonSchema=n.parameters,delete n.parameters):n.parameters=ii(n.parameters)),n.response&&(Object.keys(n.response).includes("$schema")?n.responseJsonSchema||(n.responseJsonSchema=n.response,delete n.response):n.response=ii(n.response));return l}function ui(l){if(l==null)throw new Error("tools is required");if(!Array.isArray(l))throw new Error("tools is required and must be an array of Tools");const n=[];for(const o of l)n.push(o);return n}function F0(l,n,o,s=1){const r=!n.startsWith(`${o}/`)&&n.split("/").length===s;return l.isVertexAI()?n.startsWith("projects/")?n:n.startsWith("locations/")?`projects/${l.getProject()}/${n}`:n.startsWith(`${o}/`)?`projects/${l.getProject()}/locations/${l.getLocation()}/${n}`:r?`projects/${l.getProject()}/locations/${l.getLocation()}/${o}/${n}`:n:r?`${o}/${n}`:n}function Sn(l,n){if(typeof n!="string")throw new Error("name must be a string");return F0(l,n,"cachedContents")}function lh(l){switch(l){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 l}}function Kn(l){return dr(l)}function X0(l){return l!=null&&typeof l=="object"&&"name"in l}function K0(l){return l!=null&&typeof l=="object"&&"video"in l}function Q0(l){return l!=null&&typeof l=="object"&&"uri"in l}function ih(l){var n;let o;if(X0(l)&&(o=l.name),!(Q0(l)&&(o=l.uri,o===void 0))&&!(K0(l)&&(o=(n=l.video)===null||n===void 0?void 0:n.uri,o===void 0))){if(typeof l=="string"&&(o=l),o===void 0)throw new Error("Could not extract file name from the provided input.");if(o.startsWith("https://")){const r=o.split("files/")[1].match(/[a-z0-9]+/);if(r===null)throw new Error(`Could not extract file name from URI ${o}`);o=r[0]}else o.startsWith("files/")&&(o=o.split("files/")[1]);return o}}function oh(l,n){let o;return l.isVertexAI()?o=n?"publishers/google/models":"models":o=n?"models":"tunedModels",o}function ah(l){for(const n of["models","tunedModels","publisherModels"])if(Z0(l,n))return l[n];return[]}function Z0(l,n){return l!==null&&typeof l=="object"&&n in l}function $0(l,n={}){const o=l,s={name:o.name,description:o.description,parametersJsonSchema:o.inputSchema};return o.outputSchema&&(s.responseJsonSchema=o.outputSchema),n.behavior&&(s.behavior=n.behavior),{functionDeclarations:[s]}}function W0(l,n={}){const o=[],s=new Set;for(const r of l){const d=r.name;if(s.has(d))throw new Error(`Duplicate function name ${d} found in MCP tools. Please ensure function names are unique.`);s.add(d);const m=$0(r,n);m.functionDeclarations&&o.push(...m.functionDeclarations)}return{functionDeclarations:o}}function sh(l,n){let o;if(typeof n=="string")if(l.isVertexAI())if(n.startsWith("gs://"))o={format:"jsonl",gcsUri:[n]};else if(n.startsWith("bq://"))o={format:"bigquery",bigqueryUri:n};else throw new Error(`Unsupported string source for Vertex AI: ${n}`);else if(n.startsWith("files/"))o={fileName:n};else throw new Error(`Unsupported string source for Gemini API: ${n}`);else if(Array.isArray(n)){if(l.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");o={inlinedRequests:n}}else o=n;const s=[o.gcsUri,o.bigqueryUri].filter(Boolean).length,r=[o.inlinedRequests,o.fileName].filter(Boolean).length;if(l.isVertexAI()){if(r>0||s!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(s>0||r!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return o}function j0(l){if(typeof l!="string")return l;const n=l;if(n.startsWith("gs://"))return{format:"jsonl",gcsUri:n};if(n.startsWith("bq://"))return{format:"bigquery",bigqueryUri:n};throw new Error(`Unsupported destination: ${n}`)}function uh(l){if(typeof l!="object"||l===null)return{};const n=l,o=n.inlinedResponses;if(typeof o!="object"||o===null)return l;const r=o.inlinedResponses;if(!Array.isArray(r)||r.length===0)return l;let d=!1;for(const m of r){if(typeof m!="object"||m===null)continue;const y=m.response;if(typeof y!="object"||y===null)continue;if(y.embedding!==void 0){d=!0;break}}return d&&(n.inlinedEmbedContentResponses=n.inlinedResponses,delete n.inlinedResponses),l}function ri(l,n){const o=n;if(!l.isVertexAI()){if(/batches\/[^/]+$/.test(o))return o.split("/").pop();throw new Error(`Invalid batch job name: ${o}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(o))return o.split("/").pop();if(/^\d+$/.test(o))return o;throw new Error(`Invalid batch job name: ${o}.`)}function rh(l){const n=l;return n==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":n==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":n==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":n==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":n==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":n==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":n==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function ev(l){const n={},o=u(l,["responsesFile"]);o!=null&&c(n,["fileName"],o);const s=u(l,["inlinedResponses","inlinedResponses"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(m=>Uv(m))),c(n,["inlinedResponses"],d)}const r=u(l,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["inlinedEmbedContentResponses"],d)}return n}function tv(l){const n={},o=u(l,["predictionsFormat"]);o!=null&&c(n,["format"],o);const s=u(l,["gcsDestination","outputUriPrefix"]);s!=null&&c(n,["gcsUri"],s);const r=u(l,["bigqueryDestination","outputUri"]);return r!=null&&c(n,["bigqueryUri"],r),n}function nv(l){const n={},o=u(l,["format"]);o!=null&&c(n,["predictionsFormat"],o);const s=u(l,["gcsUri"]);s!=null&&c(n,["gcsDestination","outputUriPrefix"],s);const r=u(l,["bigqueryUri"]);if(r!=null&&c(n,["bigqueryDestination","outputUri"],r),u(l,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(l,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(u(l,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return n}function Na(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata","displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["metadata","state"]);r!=null&&c(n,["state"],rh(r));const d=u(l,["metadata","createTime"]);d!=null&&c(n,["createTime"],d);const m=u(l,["metadata","endTime"]);m!=null&&c(n,["endTime"],m);const g=u(l,["metadata","updateTime"]);g!=null&&c(n,["updateTime"],g);const y=u(l,["metadata","model"]);y!=null&&c(n,["model"],y);const h=u(l,["metadata","output"]);return h!=null&&c(n,["dest"],ev(uh(h))),n}function ar(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["state"]);r!=null&&c(n,["state"],rh(r));const d=u(l,["error"]);d!=null&&c(n,["error"],d);const m=u(l,["createTime"]);m!=null&&c(n,["createTime"],m);const g=u(l,["startTime"]);g!=null&&c(n,["startTime"],g);const y=u(l,["endTime"]);y!=null&&c(n,["endTime"],y);const h=u(l,["updateTime"]);h!=null&&c(n,["updateTime"],h);const T=u(l,["model"]);T!=null&&c(n,["model"],T);const S=u(l,["inputConfig"]);S!=null&&c(n,["src"],lv(S));const _=u(l,["outputConfig"]);return _!=null&&c(n,["dest"],tv(uh(_))),n}function lv(l){const n={},o=u(l,["instancesFormat"]);o!=null&&c(n,["format"],o);const s=u(l,["gcsSource","uris"]);s!=null&&c(n,["gcsUri"],s);const r=u(l,["bigquerySource","inputUri"]);return r!=null&&c(n,["bigqueryUri"],r),n}function iv(l,n){const o={};if(u(n,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(u(n,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(n,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const s=u(n,["fileName"]);s!=null&&c(o,["fileName"],s);const r=u(n,["inlinedRequests"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>bv(l,m))),c(o,["requests","requests"],d)}return o}function ov(l){const n={},o=u(l,["format"]);o!=null&&c(n,["instancesFormat"],o);const s=u(l,["gcsUri"]);s!=null&&c(n,["gcsSource","uris"],s);const r=u(l,["bigqueryUri"]);if(r!=null&&c(n,["bigquerySource","inputUri"],r),u(l,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(l,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return n}function av(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function sv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],ri(l,s)),o}function uv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],ri(l,s)),o}function rv(l){const n={},o=u(l,["content"]);o!=null&&c(n,["content"],o);const s=u(l,["citationMetadata"]);s!=null&&c(n,["citationMetadata"],cv(s));const r=u(l,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(l,["finishReason"]);d!=null&&c(n,["finishReason"],d);const m=u(l,["urlContextMetadata"]);m!=null&&c(n,["urlContextMetadata"],m);const g=u(l,["avgLogprobs"]);g!=null&&c(n,["avgLogprobs"],g);const y=u(l,["groundingMetadata"]);y!=null&&c(n,["groundingMetadata"],y);const h=u(l,["index"]);h!=null&&c(n,["index"],h);const T=u(l,["logprobsResult"]);T!=null&&c(n,["logprobsResult"],T);const S=u(l,["safetyRatings"]);if(S!=null){let _=S;Array.isArray(_)&&(_=_.map(b=>b)),c(n,["safetyRatings"],_)}return n}function cv(l){const n={},o=u(l,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["citations"],s)}return n}function ch(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>zv(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function fv(l,n){const o={},s=u(l,["displayName"]);if(n!==void 0&&s!=null&&c(n,["batch","displayName"],s),u(l,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function dv(l,n){const o={},s=u(l,["displayName"]);n!==void 0&&s!=null&&c(n,["displayName"],s);const r=u(l,["dest"]);return n!==void 0&&r!=null&&c(n,["outputConfig"],nv(j0(r))),o}function wm(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],iv(l,sh(l,r)));const d=u(n,["config"]);return d!=null&&fv(d,o),o}function pv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],De(l,s));const r=u(n,["src"]);r!=null&&c(o,["inputConfig"],ov(sh(l,r)));const d=u(n,["config"]);return d!=null&&dv(d,o),o}function mv(l,n){const o={},s=u(l,["displayName"]);return n!==void 0&&s!=null&&c(n,["batch","displayName"],s),o}function hv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],_v(l,r));const d=u(n,["config"]);return d!=null&&mv(d,o),o}function gv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],ri(l,s)),o}function yv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],ri(l,s)),o}function vv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);return d!=null&&c(n,["error"],d),n}function Tv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);return d!=null&&c(n,["error"],d),n}function Sv(l,n){const o={},s=u(n,["contents"]);if(s!=null){let d=pr(l,s);Array.isArray(d)&&(d=d.map(m=>m)),c(o,["requests[]","request","content"],d)}const r=u(n,["config"]);return r!=null&&(c(o,["_self"],Ev(r,o)),C0(o,{"requests[].*":"requests[].request.*"})),o}function Ev(l,n){const o={},s=u(l,["taskType"]);n!==void 0&&s!=null&&c(n,["requests[]","taskType"],s);const r=u(l,["title"]);n!==void 0&&r!=null&&c(n,["requests[]","title"],r);const d=u(l,["outputDimensionality"]);if(n!==void 0&&d!=null&&c(n,["requests[]","outputDimensionality"],d),u(l,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(l,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function _v(l,n){const o={},s=u(n,["fileName"]);s!=null&&c(o,["file_name"],s);const r=u(n,["inlinedRequests"]);return r!=null&&c(o,["requests"],Sv(l,r)),o}function Cv(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function Av(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],ch(ft(r)));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const m=u(n,["topP"]);m!=null&&c(s,["topP"],m);const g=u(n,["topK"]);g!=null&&c(s,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const T=u(n,["stopSequences"]);T!=null&&c(s,["stopSequences"],T);const S=u(n,["responseLogprobs"]);S!=null&&c(s,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(s,["logprobs"],_);const b=u(n,["presencePenalty"]);b!=null&&c(s,["presencePenalty"],b);const z=u(n,["frequencyPenalty"]);z!=null&&c(s,["frequencyPenalty"],z);const V=u(n,["seed"]);V!=null&&c(s,["seed"],V);const Y=u(n,["responseMimeType"]);Y!=null&&c(s,["responseMimeType"],Y);const J=u(n,["responseSchema"]);J!=null&&c(s,["responseSchema"],mr(J));const K=u(n,["responseJsonSchema"]);if(K!=null&&c(s,["responseJsonSchema"],K),u(n,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(n,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const B=u(n,["safetySettings"]);if(o!==void 0&&B!=null){let me=B;Array.isArray(me)&&(me=me.map(Ae=>Vv(Ae))),c(o,["safetySettings"],me)}const ee=u(n,["tools"]);if(o!==void 0&&ee!=null){let me=ui(ee);Array.isArray(me)&&(me=me.map(Ae=>Bv(si(Ae)))),c(o,["tools"],me)}const le=u(n,["toolConfig"]);if(o!==void 0&&le!=null&&c(o,["toolConfig"],le),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const ie=u(n,["cachedContent"]);o!==void 0&&ie!=null&&c(o,["cachedContent"],Sn(l,ie));const X=u(n,["responseModalities"]);X!=null&&c(s,["responseModalities"],X);const ve=u(n,["mediaResolution"]);ve!=null&&c(s,["mediaResolution"],ve);const W=u(n,["speechConfig"]);if(W!=null&&c(s,["speechConfig"],hr(W)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Q=u(n,["thinkingConfig"]);Q!=null&&c(s,["thinkingConfig"],Q);const ge=u(n,["imageConfig"]);return ge!=null&&c(s,["imageConfig"],ge),s}function Mv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(h=>rv(h))),c(n,["candidates"],y)}const r=u(l,["modelVersion"]);r!=null&&c(n,["modelVersion"],r);const d=u(l,["promptFeedback"]);d!=null&&c(n,["promptFeedback"],d);const m=u(l,["responseId"]);m!=null&&c(n,["responseId"],m);const g=u(l,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function Rv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],ri(l,s)),o}function xv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],ri(l,s)),o}function Nv(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function Dv(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function bv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["request","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let g=kt(r);Array.isArray(g)&&(g=g.map(y=>ch(y))),c(o,["request","contents"],g)}const d=u(n,["metadata"]);d!=null&&c(o,["metadata"],d);const m=u(n,["config"]);return m!=null&&c(o,["request","generationConfig"],Av(l,m,u(o,["request"],{}))),o}function Uv(l){const n={},o=u(l,["response"]);o!=null&&c(n,["response"],Mv(o));const s=u(l,["error"]);return s!=null&&c(n,["error"],s),n}function Iv(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);if(n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),u(l,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function wv(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(l,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function qv(l){const n={},o=u(l,["config"]);return o!=null&&Iv(o,n),n}function Lv(l){const n={},o=u(l,["config"]);return o!=null&&wv(o,n),n}function Gv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["operations"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>Na(m))),c(n,["batchJobs"],d)}return n}function Hv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["batchPredictionJobs"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>ar(m))),c(n,["batchJobs"],d)}return n}function zv(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],av(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],Cv(d));const m=u(l,["thoughtSignature"]);m!=null&&c(n,["thoughtSignature"],m);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function Vv(l){const n={};if(u(l,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=u(l,["category"]);o!=null&&c(n,["category"],o);const s=u(l,["threshold"]);return s!=null&&c(n,["threshold"],s),n}function Bv(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],Dv(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],Nv(d));const m=u(l,["urlContext"]);m!=null&&c(n,["urlContext"],m);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var ml;(function(l){l.PAGED_ITEM_BATCH_JOBS="batchJobs",l.PAGED_ITEM_MODELS="models",l.PAGED_ITEM_TUNING_JOBS="tuningJobs",l.PAGED_ITEM_FILES="files",l.PAGED_ITEM_CACHED_CONTENTS="cachedContents"})(ml||(ml={}));class so{constructor(n,o,s,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(n,s,r)}init(n,o,s){var r,d;this.nameInternal=n,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o==null?void 0:o.sdkHttpResponse,this.idxInternal=0;let m={config:{}};!s||Object.keys(s).length===0?m={config:{}}:typeof s=="object"?m=Object.assign({},s):m=s,m.config&&(m.config.pageToken=o.nextPageToken),this.paramsInternal=m,this.pageInternalSize=(d=(r=m.config)===null||r===void 0?void 0:r.pageSize)!==null&&d!==void 0?d:this.pageInternal.length}initNextPage(n){this.init(this.nameInternal,n,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(n){return this.pageInternal[n]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const n=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:n,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const n=await this.requestInternal(this.params);return this.initNextPage(n),this.page}hasNextPage(){var n;return((n=this.params.config)===null||n===void 0?void 0:n.pageToken)!==void 0}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Pv extends yl{constructor(n){super(),this.apiClient=n,this.create=async o=>(this.apiClient.isVertexAI()&&(o.config=this.formatDestination(o.src,o.config)),this.createInternal(o)),this.createEmbeddings=async o=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(o)},this.list=async(o={})=>new so(ml.PAGED_ITEM_BATCH_JOBS,s=>this.listInternal(s),await this.listInternal(o),o)}createInlinedGenerateContentRequest(n){const o=wm(this.apiClient,n),s=o._url,r=te("{model}:batchGenerateContent",s),g=o.batch.inputConfig.requests,y=g.requests,h=[];for(const T of y){const S=Object.assign({},T);if(S.systemInstruction){const _=S.systemInstruction;delete S.systemInstruction;const b=S.request;b.systemInstruction=_,S.request=b}h.push(S)}return g.requests=h,delete o.config,delete o._url,delete o._query,{path:r,body:o}}getGcsUri(n){if(typeof n=="string")return n.startsWith("gs://")?n:void 0;if(!Array.isArray(n)&&n.gcsUri&&n.gcsUri.length>0)return n.gcsUri[0]}getBigqueryUri(n){if(typeof n=="string")return n.startsWith("bq://")?n:void 0;if(!Array.isArray(n))return n.bigqueryUri}formatDestination(n,o){const s=o?Object.assign({},o):{},r=Date.now().toString();if(s.displayName||(s.displayName=`genaiBatchJob_${r}`),s.dest===void 0){const d=this.getGcsUri(n),m=this.getBigqueryUri(n);if(d)d.endsWith(".jsonl")?s.dest=`${d.slice(0,-6)}/dest`:s.dest=`${d}_dest_${r}`;else if(m)s.dest=`${m}_dest_${r}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return s}async createInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=pv(this.apiClient,n);return g=te("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>ar(T))}else{const h=wm(this.apiClient,n);return g=te("{model}:batchGenerateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>Na(T))}}async createEmbeddingsInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=hv(this.apiClient,n);return d=te("{model}:asyncBatchEmbedContent",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>Na(y))}}async get(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=xv(this.apiClient,n);return g=te("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>ar(T))}else{const h=Rv(this.apiClient,n);return g=te("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>Na(T))}}async cancel(n){var o,s,r,d;let m="",g={};if(this.apiClient.isVertexAI()){const y=uv(this.apiClient,n);m=te("batchPredictionJobs/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal})}else{const y=sv(this.apiClient,n);m=te("batches/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal})}}async listInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Lv(n);return g=te("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=Hv(T),_=new Dm;return Object.assign(_,S),_})}else{const h=qv(n);return g=te("batches",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=Gv(T),_=new Dm;return Object.assign(_,S),_})}}async delete(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=yv(this.apiClient,n);return g=te("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>Tv(T))}else{const h=gv(this.apiClient,n);return g=te("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>vv(T))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function kv(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function qm(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>rT(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function Yv(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);n!==void 0&&r!=null&&c(n,["expireTime"],r);const d=u(l,["displayName"]);n!==void 0&&d!=null&&c(n,["displayName"],d);const m=u(l,["contents"]);if(n!==void 0&&m!=null){let T=kt(m);Array.isArray(T)&&(T=T.map(S=>qm(S))),c(n,["contents"],T)}const g=u(l,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],qm(ft(g)));const y=u(l,["tools"]);if(n!==void 0&&y!=null){let T=y;Array.isArray(T)&&(T=T.map(S=>cT(S))),c(n,["tools"],T)}const h=u(l,["toolConfig"]);if(n!==void 0&&h!=null&&c(n,["toolConfig"],h),u(l,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function Jv(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);n!==void 0&&r!=null&&c(n,["expireTime"],r);const d=u(l,["displayName"]);n!==void 0&&d!=null&&c(n,["displayName"],d);const m=u(l,["contents"]);if(n!==void 0&&m!=null){let S=kt(m);Array.isArray(S)&&(S=S.map(_=>_)),c(n,["contents"],S)}const g=u(l,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],ft(g));const y=u(l,["tools"]);if(n!==void 0&&y!=null){let S=y;Array.isArray(S)&&(S=S.map(_=>fT(_))),c(n,["tools"],S)}const h=u(l,["toolConfig"]);n!==void 0&&h!=null&&c(n,["toolConfig"],h);const T=u(l,["kmsKeyName"]);return n!==void 0&&T!=null&&c(n,["encryption_spec","kmsKeyName"],T),o}function Ov(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],Wm(l,s));const r=u(n,["config"]);return r!=null&&Yv(r,o),o}function Fv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],Wm(l,s));const r=u(n,["config"]);return r!=null&&Jv(r,o),o}function Xv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Sn(l,s)),o}function Kv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Sn(l,s)),o}function Qv(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function Zv(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function $v(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function Wv(l){const n={};if(u(l,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(l,["description"]);o!=null&&c(n,["description"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(l,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const m=u(l,["response"]);m!=null&&c(n,["response"],m);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function jv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Sn(l,s)),o}function eT(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Sn(l,s)),o}function tT(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function nT(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function lT(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function iT(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function oT(l){const n={},o=u(l,["config"]);return o!=null&&lT(o,n),n}function aT(l){const n={},o=u(l,["config"]);return o!=null&&iT(o,n),n}function sT(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["cachedContents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["cachedContents"],d)}return n}function uT(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["cachedContents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["cachedContents"],d)}return n}function rT(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],kv(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],$v(d));const m=u(l,["thoughtSignature"]);m!=null&&c(n,["thoughtSignature"],m);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function cT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],nT(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],tT(d));const m=u(l,["urlContext"]);m!=null&&c(n,["urlContext"],m);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}function fT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>Wv(_))),c(n,["functionDeclarations"],S)}const s=u(l,["retrieval"]);s!=null&&c(n,["retrieval"],s);const r=u(l,["googleSearch"]);r!=null&&c(n,["googleSearch"],r);const d=u(l,["googleSearchRetrieval"]);d!=null&&c(n,["googleSearchRetrieval"],d);const m=u(l,["enterpriseWebSearch"]);m!=null&&c(n,["enterpriseWebSearch"],m);const g=u(l,["googleMaps"]);g!=null&&c(n,["googleMaps"],g);const y=u(l,["urlContext"]);y!=null&&c(n,["urlContext"],y);const h=u(l,["computerUse"]);h!=null&&c(n,["computerUse"],h);const T=u(l,["codeExecution"]);return T!=null&&c(n,["codeExecution"],T),n}function dT(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);return n!==void 0&&r!=null&&c(n,["expireTime"],r),o}function pT(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);return n!==void 0&&r!=null&&c(n,["expireTime"],r),o}function mT(l,n){const o={},s=u(n,["name"]);s!=null&&c(o,["_url","name"],Sn(l,s));const r=u(n,["config"]);return r!=null&&dT(r,o),o}function hT(l,n){const o={},s=u(n,["name"]);s!=null&&c(o,["_url","name"],Sn(l,s));const r=u(n,["config"]);return r!=null&&pT(r,o),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class gT extends yl{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new so(ml.PAGED_ITEM_CACHED_CONTENTS,s=>this.listInternal(s),await this.listInternal(o),o)}async create(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Fv(this.apiClient,n);return g=te("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>T)}else{const h=Ov(this.apiClient,n);return g=te("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>T)}}async get(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=eT(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>T)}else{const h=jv(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>T)}}async delete(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Kv(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=Zv(T),_=new xm;return Object.assign(_,S),_})}else{const h=Xv(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=Qv(T),_=new xm;return Object.assign(_,S),_})}}async update(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=hT(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>T)}else{const h=mT(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>T)}}async listInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=aT(n);return g=te("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=uT(T),_=new Nm;return Object.assign(_,S),_})}else{const h=oT(n);return g=te("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=sT(T),_=new Nm;return Object.assign(_,S),_})}}}function Lm(l){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&l[n],s=0;if(o)return o.call(l);if(l&&typeof l.length=="number")return{next:function(){return l&&s>=l.length&&(l=void 0),{value:l&&l[s++],done:!l}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Be(l){return this instanceof Be?(this.v=l,this):new Be(l)}function oi(l,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=o.apply(l,n||[]),r,d=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",m),r[Symbol.asyncIterator]=function(){return this},r;function m(b){return function(z){return Promise.resolve(z).then(b,S)}}function g(b,z){s[b]&&(r[b]=function(V){return new Promise(function(Y,J){d.push([b,V,Y,J])>1||y(b,V)})},z&&(r[b]=z(r[b])))}function y(b,z){try{h(s[b](z))}catch(V){_(d[0][3],V)}}function h(b){b.value instanceof Be?Promise.resolve(b.value.v).then(T,S):_(d[0][2],b)}function T(b){y("next",b)}function S(b){y("throw",b)}function _(b,z){b(z),d.shift(),d.length&&y(d[0][0],d[0][1])}}function ao(l){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=l[Symbol.asyncIterator],o;return n?n.call(l):(l=typeof Lm=="function"?Lm(l):l[Symbol.iterator](),o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o);function s(d){o[d]=l[d]&&function(m){return new Promise(function(g,y){m=l[d](m),r(g,y,m.done,m.value)})}}function r(d,m,g,y){Promise.resolve(y).then(function(h){d({value:h,done:g})},m)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function yT(l){var n;if(l.candidates==null||l.candidates.length===0)return!1;const o=(n=l.candidates[0])===null||n===void 0?void 0:n.content;return o===void 0?!1:fh(o)}function fh(l){if(l.parts===void 0||l.parts.length===0)return!1;for(const n of l.parts)if(n===void 0||Object.keys(n).length===0)return!1;return!0}function vT(l){if(l.length!==0){for(const n of l)if(n.role!=="user"&&n.role!=="model")throw new Error(`Role must be user or model, but got ${n.role}.`)}}function Gm(l){if(l===void 0||l.length===0)return[];const n=[],o=l.length;let s=0;for(;s{var d,m,g;const y=await r,h=(m=(d=y.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content,T=y.automaticFunctionCallingHistory,S=this.getHistory(!0).length;let _=[];T!=null&&(_=(g=T.slice(S))!==null&&g!==void 0?g:[]);const b=h?[h]:[];this.recordHistory(s,b,_)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(n){var o;await this.sendPromise;const s=ft(n.message),r=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(s),config:(o=n.config)!==null&&o!==void 0?o:this.config});this.sendPromise=r.then(()=>{}).catch(()=>{});const d=await r;return this.processStreamResponse(d,s)}getHistory(n=!1){const o=n?Gm(this.history):this.history;return structuredClone(o)}processStreamResponse(n,o){var s,r;return oi(this,arguments,function*(){var m,g,y,h;const T=[];try{for(var S=!0,_=ao(n),b;b=yield Be(_.next()),m=b.done,!m;S=!0){h=b.value,S=!1;const z=h;if(yT(z)){const V=(r=(s=z.candidates)===null||s===void 0?void 0:s[0])===null||r===void 0?void 0:r.content;V!==void 0&&T.push(V)}yield yield Be(z)}}catch(z){g={error:z}}finally{try{!S&&!m&&(y=_.return)&&(yield Be(y.call(_)))}finally{if(g)throw g.error}}this.recordHistory(o,T)})}recordHistory(n,o,s){let r=[];o.length>0&&o.every(d=>d.role!==void 0)?r=o:r.push({role:"model",parts:[]}),s&&s.length>0?this.history.push(...Gm(s)):this.history.push(n),this.history.push(...r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class wa extends Error{constructor(n){super(n.message),this.name="ApiError",this.status=n.status,Object.setPrototypeOf(this,wa.prototype)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function ET(l){const n={},o=u(l,["file"]);return o!=null&&c(n,["file"],o),n}function _T(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function CT(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","file"],ih(o)),n}function AT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function MT(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","file"],ih(o)),n}function RT(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function xT(l){const n={},o=u(l,["config"]);return o!=null&&RT(o,n),n}function NT(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["files"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["files"],d)}return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class DT extends yl{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new so(ml.PAGED_ITEM_FILES,s=>this.listInternal(s),await this.listInternal(o),o)}async upload(n){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(n.file,n.config).then(o=>o)}async download(n){await this.apiClient.downloadFile(n)}async listInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=xT(n);return d=te("files",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=NT(y),T=new B0;return Object.assign(T,h),T})}}async createInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=ET(n);return d=te("upload/v1beta/files",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const h=_T(y),T=new P0;return Object.assign(T,h),T})}}async get(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=MT(n);return d=te("files/{file}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=CT(n);return d=te("files/{file}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=AT(y),T=new k0;return Object.assign(T,h),T})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Da(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function bT(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>OT(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function UT(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function IT(l){const n={};if(u(l,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(l,["description"]);o!=null&&c(n,["description"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(l,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const m=u(l,["response"]);m!=null&&c(n,["response"],m);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function wT(l){const n={},o=u(l,["modelSelectionConfig"]);o!=null&&c(n,["modelConfig"],o);const s=u(l,["audioTimestamp"]);s!=null&&c(n,["audioTimestamp"],s);const r=u(l,["candidateCount"]);r!=null&&c(n,["candidateCount"],r);const d=u(l,["enableAffectiveDialog"]);d!=null&&c(n,["enableAffectiveDialog"],d);const m=u(l,["frequencyPenalty"]);m!=null&&c(n,["frequencyPenalty"],m);const g=u(l,["logprobs"]);g!=null&&c(n,["logprobs"],g);const y=u(l,["maxOutputTokens"]);y!=null&&c(n,["maxOutputTokens"],y);const h=u(l,["mediaResolution"]);h!=null&&c(n,["mediaResolution"],h);const T=u(l,["presencePenalty"]);T!=null&&c(n,["presencePenalty"],T);const S=u(l,["responseJsonSchema"]);S!=null&&c(n,["responseJsonSchema"],S);const _=u(l,["responseLogprobs"]);_!=null&&c(n,["responseLogprobs"],_);const b=u(l,["responseMimeType"]);b!=null&&c(n,["responseMimeType"],b);const z=u(l,["responseModalities"]);z!=null&&c(n,["responseModalities"],z);const V=u(l,["responseSchema"]);V!=null&&c(n,["responseSchema"],V);const Y=u(l,["routingConfig"]);Y!=null&&c(n,["routingConfig"],Y);const J=u(l,["seed"]);J!=null&&c(n,["seed"],J);const K=u(l,["speechConfig"]);K!=null&&c(n,["speechConfig"],dh(K));const B=u(l,["stopSequences"]);B!=null&&c(n,["stopSequences"],B);const ee=u(l,["temperature"]);ee!=null&&c(n,["temperature"],ee);const le=u(l,["thinkingConfig"]);le!=null&&c(n,["thinkingConfig"],le);const ie=u(l,["topK"]);ie!=null&&c(n,["topK"],ie);const X=u(l,["topP"]);return X!=null&&c(n,["topP"],X),n}function qT(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function LT(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function GT(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],s);const r=u(l,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(l,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const m=u(l,["topP"]);n!==void 0&&m!=null&&c(n,["setup","generationConfig","topP"],m);const g=u(l,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(l,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(l,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const T=u(l,["seed"]);n!==void 0&&T!=null&&c(n,["setup","generationConfig","seed"],T);const S=u(l,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],gr(S));const _=u(l,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const b=u(l,["enableAffectiveDialog"]);n!==void 0&&b!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],b);const z=u(l,["systemInstruction"]);n!==void 0&&z!=null&&c(n,["setup","systemInstruction"],bT(ft(z)));const V=u(l,["tools"]);if(n!==void 0&&V!=null){let ie=ui(V);Array.isArray(ie)&&(ie=ie.map(X=>XT(si(X)))),c(n,["setup","tools"],ie)}const Y=u(l,["sessionResumption"]);n!==void 0&&Y!=null&&c(n,["setup","sessionResumption"],FT(Y));const J=u(l,["inputAudioTranscription"]);n!==void 0&&J!=null&&c(n,["setup","inputAudioTranscription"],J);const K=u(l,["outputAudioTranscription"]);n!==void 0&&K!=null&&c(n,["setup","outputAudioTranscription"],K);const B=u(l,["realtimeInputConfig"]);n!==void 0&&B!=null&&c(n,["setup","realtimeInputConfig"],B);const ee=u(l,["contextWindowCompression"]);n!==void 0&&ee!=null&&c(n,["setup","contextWindowCompression"],ee);const le=u(l,["proactivity"]);return n!==void 0&&le!=null&&c(n,["setup","proactivity"],le),o}function HT(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],wT(s));const r=u(l,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(l,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const m=u(l,["topP"]);n!==void 0&&m!=null&&c(n,["setup","generationConfig","topP"],m);const g=u(l,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(l,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(l,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const T=u(l,["seed"]);n!==void 0&&T!=null&&c(n,["setup","generationConfig","seed"],T);const S=u(l,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],dh(gr(S)));const _=u(l,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const b=u(l,["enableAffectiveDialog"]);n!==void 0&&b!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],b);const z=u(l,["systemInstruction"]);n!==void 0&&z!=null&&c(n,["setup","systemInstruction"],ft(z));const V=u(l,["tools"]);if(n!==void 0&&V!=null){let ie=ui(V);Array.isArray(ie)&&(ie=ie.map(X=>KT(si(X)))),c(n,["setup","tools"],ie)}const Y=u(l,["sessionResumption"]);n!==void 0&&Y!=null&&c(n,["setup","sessionResumption"],Y);const J=u(l,["inputAudioTranscription"]);n!==void 0&&J!=null&&c(n,["setup","inputAudioTranscription"],J);const K=u(l,["outputAudioTranscription"]);n!==void 0&&K!=null&&c(n,["setup","outputAudioTranscription"],K);const B=u(l,["realtimeInputConfig"]);n!==void 0&&B!=null&&c(n,["setup","realtimeInputConfig"],B);const ee=u(l,["contextWindowCompression"]);n!==void 0&&ee!=null&&c(n,["setup","contextWindowCompression"],ee);const le=u(l,["proactivity"]);return n!==void 0&&le!=null&&c(n,["setup","proactivity"],le),o}function zT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],De(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],GT(r,o)),o}function VT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],De(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],HT(r,o)),o}function BT(l){const n={},o=u(l,["musicGenerationConfig"]);return o!=null&&c(n,["musicGenerationConfig"],o),n}function PT(l){const n={},o=u(l,["weightedPrompts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["weightedPrompts"],s)}return n}function kT(l){const n={},o=u(l,["media"]);if(o!=null){let h=jm(o);Array.isArray(h)&&(h=h.map(T=>Da(T))),c(n,["mediaChunks"],h)}const s=u(l,["audio"]);s!=null&&c(n,["audio"],Da(th(s)));const r=u(l,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(l,["video"]);d!=null&&c(n,["video"],Da(eh(d)));const m=u(l,["text"]);m!=null&&c(n,["text"],m);const g=u(l,["activityStart"]);g!=null&&c(n,["activityStart"],g);const y=u(l,["activityEnd"]);return y!=null&&c(n,["activityEnd"],y),n}function YT(l){const n={},o=u(l,["media"]);if(o!=null){let h=jm(o);Array.isArray(h)&&(h=h.map(T=>T)),c(n,["mediaChunks"],h)}const s=u(l,["audio"]);s!=null&&c(n,["audio"],th(s));const r=u(l,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(l,["video"]);d!=null&&c(n,["video"],eh(d));const m=u(l,["text"]);m!=null&&c(n,["text"],m);const g=u(l,["activityStart"]);g!=null&&c(n,["activityStart"],g);const y=u(l,["activityEnd"]);return y!=null&&c(n,["activityEnd"],y),n}function JT(l){const n={},o=u(l,["setupComplete"]);o!=null&&c(n,["setupComplete"],o);const s=u(l,["serverContent"]);s!=null&&c(n,["serverContent"],s);const r=u(l,["toolCall"]);r!=null&&c(n,["toolCall"],r);const d=u(l,["toolCallCancellation"]);d!=null&&c(n,["toolCallCancellation"],d);const m=u(l,["usageMetadata"]);m!=null&&c(n,["usageMetadata"],QT(m));const g=u(l,["goAway"]);g!=null&&c(n,["goAway"],g);const y=u(l,["sessionResumptionUpdate"]);return y!=null&&c(n,["sessionResumptionUpdate"],y),n}function OT(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],Da(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],UT(d));const m=u(l,["thoughtSignature"]);m!=null&&c(n,["thoughtSignature"],m);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function FT(l){const n={},o=u(l,["handle"]);if(o!=null&&c(n,["handle"],o),u(l,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return n}function dh(l){const n={},o=u(l,["voiceConfig"]);if(o!=null&&c(n,["voiceConfig"],o),u(l,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const s=u(l,["languageCode"]);return s!=null&&c(n,["languageCode"],s),n}function XT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],LT(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],qT(d));const m=u(l,["urlContext"]);m!=null&&c(n,["urlContext"],m);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}function KT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>IT(_))),c(n,["functionDeclarations"],S)}const s=u(l,["retrieval"]);s!=null&&c(n,["retrieval"],s);const r=u(l,["googleSearch"]);r!=null&&c(n,["googleSearch"],r);const d=u(l,["googleSearchRetrieval"]);d!=null&&c(n,["googleSearchRetrieval"],d);const m=u(l,["enterpriseWebSearch"]);m!=null&&c(n,["enterpriseWebSearch"],m);const g=u(l,["googleMaps"]);g!=null&&c(n,["googleMaps"],g);const y=u(l,["urlContext"]);y!=null&&c(n,["urlContext"],y);const h=u(l,["computerUse"]);h!=null&&c(n,["computerUse"],h);const T=u(l,["codeExecution"]);return T!=null&&c(n,["codeExecution"],T),n}function QT(l){const n={},o=u(l,["promptTokenCount"]);o!=null&&c(n,["promptTokenCount"],o);const s=u(l,["cachedContentTokenCount"]);s!=null&&c(n,["cachedContentTokenCount"],s);const r=u(l,["candidatesTokenCount"]);r!=null&&c(n,["responseTokenCount"],r);const d=u(l,["toolUsePromptTokenCount"]);d!=null&&c(n,["toolUsePromptTokenCount"],d);const m=u(l,["thoughtsTokenCount"]);m!=null&&c(n,["thoughtsTokenCount"],m);const g=u(l,["totalTokenCount"]);g!=null&&c(n,["totalTokenCount"],g);const y=u(l,["promptTokensDetails"]);if(y!=null){let b=y;Array.isArray(b)&&(b=b.map(z=>z)),c(n,["promptTokensDetails"],b)}const h=u(l,["cacheTokensDetails"]);if(h!=null){let b=h;Array.isArray(b)&&(b=b.map(z=>z)),c(n,["cacheTokensDetails"],b)}const T=u(l,["candidatesTokensDetails"]);if(T!=null){let b=T;Array.isArray(b)&&(b=b.map(z=>z)),c(n,["responseTokensDetails"],b)}const S=u(l,["toolUsePromptTokensDetails"]);if(S!=null){let b=S;Array.isArray(b)&&(b=b.map(z=>z)),c(n,["toolUsePromptTokensDetails"],b)}const _=u(l,["trafficType"]);return _!=null&&c(n,["trafficType"],_),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function ZT(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function $T(l){const n={},o=u(l,["content"]);o!=null&&c(n,["content"],o);const s=u(l,["citationMetadata"]);s!=null&&c(n,["citationMetadata"],WT(s));const r=u(l,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(l,["finishReason"]);d!=null&&c(n,["finishReason"],d);const m=u(l,["urlContextMetadata"]);m!=null&&c(n,["urlContextMetadata"],m);const g=u(l,["avgLogprobs"]);g!=null&&c(n,["avgLogprobs"],g);const y=u(l,["groundingMetadata"]);y!=null&&c(n,["groundingMetadata"],y);const h=u(l,["index"]);h!=null&&c(n,["index"],h);const T=u(l,["logprobsResult"]);T!=null&&c(n,["logprobsResult"],T);const S=u(l,["safetyRatings"]);if(S!=null){let _=S;Array.isArray(_)&&(_=_.map(b=>b)),c(n,["safetyRatings"],_)}return n}function WT(l){const n={},o=u(l,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["citations"],s)}return n}function jT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let d=kt(r);Array.isArray(d)&&(d=d.map(m=>m)),c(o,["contents"],d)}return o}function eS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["tokensInfo"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>d)),c(n,["tokensInfo"],r)}return n}function tS(l){const n={},o=u(l,["values"]);o!=null&&c(n,["values"],o);const s=u(l,["statistics"]);return s!=null&&c(n,["statistics"],nS(s)),n}function nS(l){const n={},o=u(l,["truncated"]);o!=null&&c(n,["truncated"],o);const s=u(l,["token_count"]);return s!=null&&c(n,["tokenCount"],s),n}function qa(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>sE(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function lS(l){const n={},o=u(l,["controlType"]);o!=null&&c(n,["controlType"],o);const s=u(l,["enableControlImageComputation"]);return s!=null&&c(n,["computeControl"],s),n}function iS(l){const n={};if(u(l,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(u(l,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(u(l,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return n}function oS(l,n){const o={},s=u(l,["systemInstruction"]);n!==void 0&&s!=null&&c(n,["systemInstruction"],ft(s));const r=u(l,["tools"]);if(n!==void 0&&r!=null){let m=r;Array.isArray(m)&&(m=m.map(g=>yh(g))),c(n,["tools"],m)}const d=u(l,["generationConfig"]);return n!==void 0&&d!=null&&c(n,["generationConfig"],KS(d)),o}function aS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let m=kt(r);Array.isArray(m)&&(m=m.map(g=>qa(g))),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&iS(d),o}function sS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let m=kt(r);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&oS(d,o),o}function uS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["totalTokens"]);s!=null&&c(n,["totalTokens"],s);const r=u(l,["cachedContentTokenCount"]);return r!=null&&c(n,["cachedContentTokenCount"],r),n}function rS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["totalTokens"]);return s!=null&&c(n,["totalTokens"],s),n}function cS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],De(l,s)),o}function fS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],De(l,s)),o}function dS(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function pS(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function mS(l,n){const o={},s=u(l,["outputGcsUri"]);n!==void 0&&s!=null&&c(n,["parameters","storageUri"],s);const r=u(l,["negativePrompt"]);n!==void 0&&r!=null&&c(n,["parameters","negativePrompt"],r);const d=u(l,["numberOfImages"]);n!==void 0&&d!=null&&c(n,["parameters","sampleCount"],d);const m=u(l,["aspectRatio"]);n!==void 0&&m!=null&&c(n,["parameters","aspectRatio"],m);const g=u(l,["guidanceScale"]);n!==void 0&&g!=null&&c(n,["parameters","guidanceScale"],g);const y=u(l,["seed"]);n!==void 0&&y!=null&&c(n,["parameters","seed"],y);const h=u(l,["safetyFilterLevel"]);n!==void 0&&h!=null&&c(n,["parameters","safetySetting"],h);const T=u(l,["personGeneration"]);n!==void 0&&T!=null&&c(n,["parameters","personGeneration"],T);const S=u(l,["includeSafetyAttributes"]);n!==void 0&&S!=null&&c(n,["parameters","includeSafetyAttributes"],S);const _=u(l,["includeRaiReason"]);n!==void 0&&_!=null&&c(n,["parameters","includeRaiReason"],_);const b=u(l,["language"]);n!==void 0&&b!=null&&c(n,["parameters","language"],b);const z=u(l,["outputMimeType"]);n!==void 0&&z!=null&&c(n,["parameters","outputOptions","mimeType"],z);const V=u(l,["outputCompressionQuality"]);n!==void 0&&V!=null&&c(n,["parameters","outputOptions","compressionQuality"],V);const Y=u(l,["addWatermark"]);n!==void 0&&Y!=null&&c(n,["parameters","addWatermark"],Y);const J=u(l,["labels"]);n!==void 0&&J!=null&&c(n,["labels"],J);const K=u(l,["editMode"]);n!==void 0&&K!=null&&c(n,["parameters","editMode"],K);const B=u(l,["baseSteps"]);return n!==void 0&&B!=null&&c(n,["parameters","editConfig","baseSteps"],B),o}function hS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["referenceImages"]);if(d!=null){let g=d;Array.isArray(g)&&(g=g.map(y=>pE(y))),c(o,["instances[0]","referenceImages"],g)}const m=u(n,["config"]);return m!=null&&mS(m,o),o}function gS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>La(d))),c(n,["generatedImages"],r)}return n}function yS(l,n){const o={},s=u(l,["taskType"]);n!==void 0&&s!=null&&c(n,["requests[]","taskType"],s);const r=u(l,["title"]);n!==void 0&&r!=null&&c(n,["requests[]","title"],r);const d=u(l,["outputDimensionality"]);if(n!==void 0&&d!=null&&c(n,["requests[]","outputDimensionality"],d),u(l,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(l,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function vS(l,n){const o={},s=u(l,["taskType"]);n!==void 0&&s!=null&&c(n,["instances[]","task_type"],s);const r=u(l,["title"]);n!==void 0&&r!=null&&c(n,["instances[]","title"],r);const d=u(l,["outputDimensionality"]);n!==void 0&&d!=null&&c(n,["parameters","outputDimensionality"],d);const m=u(l,["mimeType"]);n!==void 0&&m!=null&&c(n,["instances[]","mimeType"],m);const g=u(l,["autoTruncate"]);return n!==void 0&&g!=null&&c(n,["parameters","autoTruncate"],g),o}function TS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let g=pr(l,r);Array.isArray(g)&&(g=g.map(y=>y)),c(o,["requests[]","content"],g)}const d=u(n,["config"]);d!=null&&yS(d,o);const m=u(n,["model"]);return m!==void 0&&c(o,["requests[]","model"],De(l,m)),o}function SS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let m=pr(l,r);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["instances[]","content"],m)}const d=u(n,["config"]);return d!=null&&vS(d,o),o}function ES(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["embeddings"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["embeddings"],d)}const r=u(l,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function _S(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions[]","embeddings"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(m=>tS(m))),c(n,["embeddings"],d)}const r=u(l,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function CS(l){const n={},o=u(l,["endpoint"]);o!=null&&c(n,["name"],o);const s=u(l,["deployedModelId"]);return s!=null&&c(n,["deployedModelId"],s),n}function AS(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function MS(l){const n={};if(u(l,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(l,["description"]);o!=null&&c(n,["description"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(l,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const m=u(l,["response"]);m!=null&&c(n,["response"],m);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function RS(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],qa(ft(r)));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const m=u(n,["topP"]);m!=null&&c(s,["topP"],m);const g=u(n,["topK"]);g!=null&&c(s,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const T=u(n,["stopSequences"]);T!=null&&c(s,["stopSequences"],T);const S=u(n,["responseLogprobs"]);S!=null&&c(s,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(s,["logprobs"],_);const b=u(n,["presencePenalty"]);b!=null&&c(s,["presencePenalty"],b);const z=u(n,["frequencyPenalty"]);z!=null&&c(s,["frequencyPenalty"],z);const V=u(n,["seed"]);V!=null&&c(s,["seed"],V);const Y=u(n,["responseMimeType"]);Y!=null&&c(s,["responseMimeType"],Y);const J=u(n,["responseSchema"]);J!=null&&c(s,["responseSchema"],mr(J));const K=u(n,["responseJsonSchema"]);if(K!=null&&c(s,["responseJsonSchema"],K),u(n,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(n,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const B=u(n,["safetySettings"]);if(o!==void 0&&B!=null){let me=B;Array.isArray(me)&&(me=me.map(Ae=>mE(Ae))),c(o,["safetySettings"],me)}const ee=u(n,["tools"]);if(o!==void 0&&ee!=null){let me=ui(ee);Array.isArray(me)&&(me=me.map(Ae=>SE(si(Ae)))),c(o,["tools"],me)}const le=u(n,["toolConfig"]);if(o!==void 0&&le!=null&&c(o,["toolConfig"],le),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const ie=u(n,["cachedContent"]);o!==void 0&&ie!=null&&c(o,["cachedContent"],Sn(l,ie));const X=u(n,["responseModalities"]);X!=null&&c(s,["responseModalities"],X);const ve=u(n,["mediaResolution"]);ve!=null&&c(s,["mediaResolution"],ve);const W=u(n,["speechConfig"]);if(W!=null&&c(s,["speechConfig"],hr(W)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Q=u(n,["thinkingConfig"]);Q!=null&&c(s,["thinkingConfig"],Q);const ge=u(n,["imageConfig"]);return ge!=null&&c(s,["imageConfig"],ge),s}function xS(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],ft(r));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const m=u(n,["topP"]);m!=null&&c(s,["topP"],m);const g=u(n,["topK"]);g!=null&&c(s,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const T=u(n,["stopSequences"]);T!=null&&c(s,["stopSequences"],T);const S=u(n,["responseLogprobs"]);S!=null&&c(s,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(s,["logprobs"],_);const b=u(n,["presencePenalty"]);b!=null&&c(s,["presencePenalty"],b);const z=u(n,["frequencyPenalty"]);z!=null&&c(s,["frequencyPenalty"],z);const V=u(n,["seed"]);V!=null&&c(s,["seed"],V);const Y=u(n,["responseMimeType"]);Y!=null&&c(s,["responseMimeType"],Y);const J=u(n,["responseSchema"]);J!=null&&c(s,["responseSchema"],mr(J));const K=u(n,["responseJsonSchema"]);K!=null&&c(s,["responseJsonSchema"],K);const B=u(n,["routingConfig"]);B!=null&&c(s,["routingConfig"],B);const ee=u(n,["modelSelectionConfig"]);ee!=null&&c(s,["modelConfig"],ee);const le=u(n,["safetySettings"]);if(o!==void 0&&le!=null){let w=le;Array.isArray(w)&&(w=w.map(k=>k)),c(o,["safetySettings"],w)}const ie=u(n,["tools"]);if(o!==void 0&&ie!=null){let w=ui(ie);Array.isArray(w)&&(w=w.map(k=>yh(si(k)))),c(o,["tools"],w)}const X=u(n,["toolConfig"]);o!==void 0&&X!=null&&c(o,["toolConfig"],X);const ve=u(n,["labels"]);o!==void 0&&ve!=null&&c(o,["labels"],ve);const W=u(n,["cachedContent"]);o!==void 0&&W!=null&&c(o,["cachedContent"],Sn(l,W));const Q=u(n,["responseModalities"]);Q!=null&&c(s,["responseModalities"],Q);const ge=u(n,["mediaResolution"]);ge!=null&&c(s,["mediaResolution"],ge);const me=u(n,["speechConfig"]);me!=null&&c(s,["speechConfig"],gh(hr(me)));const Ae=u(n,["audioTimestamp"]);Ae!=null&&c(s,["audioTimestamp"],Ae);const ut=u(n,["thinkingConfig"]);ut!=null&&c(s,["thinkingConfig"],ut);const Xe=u(n,["imageConfig"]);return Xe!=null&&c(s,["imageConfig"],Xe),s}function Hm(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let m=kt(r);Array.isArray(m)&&(m=m.map(g=>qa(g))),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],RS(l,d,o)),o}function zm(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["contents"]);if(r!=null){let m=kt(r);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],xS(l,d,o)),o}function Vm(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(h=>$T(h))),c(n,["candidates"],y)}const r=u(l,["modelVersion"]);r!=null&&c(n,["modelVersion"],r);const d=u(l,["promptFeedback"]);d!=null&&c(n,["promptFeedback"],d);const m=u(l,["responseId"]);m!=null&&c(n,["responseId"],m);const g=u(l,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function Bm(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["candidates"]);if(s!=null){let h=s;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["candidates"],h)}const r=u(l,["createTime"]);r!=null&&c(n,["createTime"],r);const d=u(l,["modelVersion"]);d!=null&&c(n,["modelVersion"],d);const m=u(l,["promptFeedback"]);m!=null&&c(n,["promptFeedback"],m);const g=u(l,["responseId"]);g!=null&&c(n,["responseId"],g);const y=u(l,["usageMetadata"]);return y!=null&&c(n,["usageMetadata"],y),n}function NS(l,n){const o={};if(u(l,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(l,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const s=u(l,["numberOfImages"]);n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s);const r=u(l,["aspectRatio"]);n!==void 0&&r!=null&&c(n,["parameters","aspectRatio"],r);const d=u(l,["guidanceScale"]);if(n!==void 0&&d!=null&&c(n,["parameters","guidanceScale"],d),u(l,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const m=u(l,["safetyFilterLevel"]);n!==void 0&&m!=null&&c(n,["parameters","safetySetting"],m);const g=u(l,["personGeneration"]);n!==void 0&&g!=null&&c(n,["parameters","personGeneration"],g);const y=u(l,["includeSafetyAttributes"]);n!==void 0&&y!=null&&c(n,["parameters","includeSafetyAttributes"],y);const h=u(l,["includeRaiReason"]);n!==void 0&&h!=null&&c(n,["parameters","includeRaiReason"],h);const T=u(l,["language"]);n!==void 0&&T!=null&&c(n,["parameters","language"],T);const S=u(l,["outputMimeType"]);n!==void 0&&S!=null&&c(n,["parameters","outputOptions","mimeType"],S);const _=u(l,["outputCompressionQuality"]);if(n!==void 0&&_!=null&&c(n,["parameters","outputOptions","compressionQuality"],_),u(l,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(u(l,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const b=u(l,["imageSize"]);if(n!==void 0&&b!=null&&c(n,["parameters","sampleImageSize"],b),u(l,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function DS(l,n){const o={},s=u(l,["outputGcsUri"]);n!==void 0&&s!=null&&c(n,["parameters","storageUri"],s);const r=u(l,["negativePrompt"]);n!==void 0&&r!=null&&c(n,["parameters","negativePrompt"],r);const d=u(l,["numberOfImages"]);n!==void 0&&d!=null&&c(n,["parameters","sampleCount"],d);const m=u(l,["aspectRatio"]);n!==void 0&&m!=null&&c(n,["parameters","aspectRatio"],m);const g=u(l,["guidanceScale"]);n!==void 0&&g!=null&&c(n,["parameters","guidanceScale"],g);const y=u(l,["seed"]);n!==void 0&&y!=null&&c(n,["parameters","seed"],y);const h=u(l,["safetyFilterLevel"]);n!==void 0&&h!=null&&c(n,["parameters","safetySetting"],h);const T=u(l,["personGeneration"]);n!==void 0&&T!=null&&c(n,["parameters","personGeneration"],T);const S=u(l,["includeSafetyAttributes"]);n!==void 0&&S!=null&&c(n,["parameters","includeSafetyAttributes"],S);const _=u(l,["includeRaiReason"]);n!==void 0&&_!=null&&c(n,["parameters","includeRaiReason"],_);const b=u(l,["language"]);n!==void 0&&b!=null&&c(n,["parameters","language"],b);const z=u(l,["outputMimeType"]);n!==void 0&&z!=null&&c(n,["parameters","outputOptions","mimeType"],z);const V=u(l,["outputCompressionQuality"]);n!==void 0&&V!=null&&c(n,["parameters","outputOptions","compressionQuality"],V);const Y=u(l,["addWatermark"]);n!==void 0&&Y!=null&&c(n,["parameters","addWatermark"],Y);const J=u(l,["labels"]);n!==void 0&&J!=null&&c(n,["labels"],J);const K=u(l,["imageSize"]);n!==void 0&&K!=null&&c(n,["parameters","sampleImageSize"],K);const B=u(l,["enhancePrompt"]);return n!==void 0&&B!=null&&c(n,["parameters","enhancePrompt"],B),o}function bS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&NS(d,o),o}function US(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&DS(d,o),o}function IS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(m=>JS(m))),c(n,["generatedImages"],d)}const r=u(l,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],mh(r)),n}function wS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(m=>La(m))),c(n,["generatedImages"],d)}const r=u(l,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],hh(r)),n}function qS(l,n){const o={},s=u(l,["numberOfVideos"]);if(n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s),u(l,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(l,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const r=u(l,["durationSeconds"]);if(n!==void 0&&r!=null&&c(n,["parameters","durationSeconds"],r),u(l,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const d=u(l,["aspectRatio"]);n!==void 0&&d!=null&&c(n,["parameters","aspectRatio"],d);const m=u(l,["resolution"]);n!==void 0&&m!=null&&c(n,["parameters","resolution"],m);const g=u(l,["personGeneration"]);if(n!==void 0&&g!=null&&c(n,["parameters","personGeneration"],g),u(l,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const y=u(l,["negativePrompt"]);n!==void 0&&y!=null&&c(n,["parameters","negativePrompt"],y);const h=u(l,["enhancePrompt"]);if(n!==void 0&&h!=null&&c(n,["parameters","enhancePrompt"],h),u(l,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const T=u(l,["lastFrame"]);n!==void 0&&T!=null&&c(n,["instances[0]","lastFrame"],Ga(T));const S=u(l,["referenceImages"]);if(n!==void 0&&S!=null){let _=S;Array.isArray(_)&&(_=_.map(b=>wE(b))),c(n,["instances[0]","referenceImages"],_)}if(u(l,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(u(l,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return o}function LS(l,n){const o={},s=u(l,["numberOfVideos"]);n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s);const r=u(l,["outputGcsUri"]);n!==void 0&&r!=null&&c(n,["parameters","storageUri"],r);const d=u(l,["fps"]);n!==void 0&&d!=null&&c(n,["parameters","fps"],d);const m=u(l,["durationSeconds"]);n!==void 0&&m!=null&&c(n,["parameters","durationSeconds"],m);const g=u(l,["seed"]);n!==void 0&&g!=null&&c(n,["parameters","seed"],g);const y=u(l,["aspectRatio"]);n!==void 0&&y!=null&&c(n,["parameters","aspectRatio"],y);const h=u(l,["resolution"]);n!==void 0&&h!=null&&c(n,["parameters","resolution"],h);const T=u(l,["personGeneration"]);n!==void 0&&T!=null&&c(n,["parameters","personGeneration"],T);const S=u(l,["pubsubTopic"]);n!==void 0&&S!=null&&c(n,["parameters","pubsubTopic"],S);const _=u(l,["negativePrompt"]);n!==void 0&&_!=null&&c(n,["parameters","negativePrompt"],_);const b=u(l,["enhancePrompt"]);n!==void 0&&b!=null&&c(n,["parameters","enhancePrompt"],b);const z=u(l,["generateAudio"]);n!==void 0&&z!=null&&c(n,["parameters","generateAudio"],z);const V=u(l,["lastFrame"]);n!==void 0&&V!=null&&c(n,["instances[0]","lastFrame"],Kt(V));const Y=u(l,["referenceImages"]);if(n!==void 0&&Y!=null){let B=Y;Array.isArray(B)&&(B=B.map(ee=>qE(ee))),c(n,["instances[0]","referenceImages"],B)}const J=u(l,["mask"]);n!==void 0&&J!=null&&c(n,["instances[0]","mask"],IE(J));const K=u(l,["compressionQuality"]);return n!==void 0&&K!=null&&c(n,["parameters","compressionQuality"],K),o}function GS(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const m=u(l,["response","generateVideoResponse"]);return m!=null&&c(n,["response"],BS(m)),n}function HS(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const m=u(l,["response"]);return m!=null&&c(n,["response"],PS(m)),n}function zS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["image"]);d!=null&&c(o,["instances[0]","image"],Ga(d));const m=u(n,["video"]);m!=null&&c(o,["instances[0]","video"],vh(m));const g=u(n,["source"]);g!=null&&kS(g,o);const y=u(n,["config"]);return y!=null&&qS(y,o),o}function VS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["image"]);d!=null&&c(o,["instances[0]","image"],Kt(d));const m=u(n,["video"]);m!=null&&c(o,["instances[0]","video"],Th(m));const g=u(n,["source"]);g!=null&&YS(g,o);const y=u(n,["config"]);return y!=null&&LS(y,o),o}function BS(l){const n={},o=u(l,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>FS(m))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function PS(l){const n={},o=u(l,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>XS(m))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function kS(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Ga(r));const d=u(l,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],vh(d)),o}function YS(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Kt(r));const d=u(l,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],Th(d)),o}function JS(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["image"],jS(o));const s=u(l,["raiFilteredReason"]);s!=null&&c(n,["raiFilteredReason"],s);const r=u(l,["_self"]);return r!=null&&c(n,["safetyAttributes"],mh(r)),n}function La(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["image"],ph(o));const s=u(l,["raiFilteredReason"]);s!=null&&c(n,["raiFilteredReason"],s);const r=u(l,["_self"]);r!=null&&c(n,["safetyAttributes"],hh(r));const d=u(l,["prompt"]);return d!=null&&c(n,["enhancedPrompt"],d),n}function OS(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["mask"],ph(o));const s=u(l,["labels"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>d)),c(n,["labels"],r)}return n}function FS(l){const n={},o=u(l,["video"]);return o!=null&&c(n,["video"],bE(o)),n}function XS(l){const n={},o=u(l,["_self"]);return o!=null&&c(n,["video"],UE(o)),n}function KS(l){const n={},o=u(l,["modelSelectionConfig"]);o!=null&&c(n,["modelConfig"],o);const s=u(l,["audioTimestamp"]);s!=null&&c(n,["audioTimestamp"],s);const r=u(l,["candidateCount"]);r!=null&&c(n,["candidateCount"],r);const d=u(l,["enableAffectiveDialog"]);d!=null&&c(n,["enableAffectiveDialog"],d);const m=u(l,["frequencyPenalty"]);m!=null&&c(n,["frequencyPenalty"],m);const g=u(l,["logprobs"]);g!=null&&c(n,["logprobs"],g);const y=u(l,["maxOutputTokens"]);y!=null&&c(n,["maxOutputTokens"],y);const h=u(l,["mediaResolution"]);h!=null&&c(n,["mediaResolution"],h);const T=u(l,["presencePenalty"]);T!=null&&c(n,["presencePenalty"],T);const S=u(l,["responseJsonSchema"]);S!=null&&c(n,["responseJsonSchema"],S);const _=u(l,["responseLogprobs"]);_!=null&&c(n,["responseLogprobs"],_);const b=u(l,["responseMimeType"]);b!=null&&c(n,["responseMimeType"],b);const z=u(l,["responseModalities"]);z!=null&&c(n,["responseModalities"],z);const V=u(l,["responseSchema"]);V!=null&&c(n,["responseSchema"],V);const Y=u(l,["routingConfig"]);Y!=null&&c(n,["routingConfig"],Y);const J=u(l,["seed"]);J!=null&&c(n,["seed"],J);const K=u(l,["speechConfig"]);K!=null&&c(n,["speechConfig"],gh(K));const B=u(l,["stopSequences"]);B!=null&&c(n,["stopSequences"],B);const ee=u(l,["temperature"]);ee!=null&&c(n,["temperature"],ee);const le=u(l,["thinkingConfig"]);le!=null&&c(n,["thinkingConfig"],le);const ie=u(l,["topK"]);ie!=null&&c(n,["topK"],ie);const X=u(l,["topP"]);return X!=null&&c(n,["topP"],X),n}function QS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],De(l,s)),o}function ZS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],De(l,s)),o}function $S(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function WS(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function jS(l){const n={},o=u(l,["bytesBase64Encoded"]);o!=null&&c(n,["imageBytes"],Kn(o));const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function ph(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["imageBytes"],Kn(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function Ga(l){const n={};if(u(l,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const o=u(l,["imageBytes"]);o!=null&&c(n,["bytesBase64Encoded"],Kn(o));const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function Kt(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["imageBytes"]);s!=null&&c(n,["bytesBase64Encoded"],Kn(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function eE(l,n,o){const s={},r=u(n,["pageSize"]);o!==void 0&&r!=null&&c(o,["_query","pageSize"],r);const d=u(n,["pageToken"]);o!==void 0&&d!=null&&c(o,["_query","pageToken"],d);const m=u(n,["filter"]);o!==void 0&&m!=null&&c(o,["_query","filter"],m);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],oh(l,g)),s}function tE(l,n,o){const s={},r=u(n,["pageSize"]);o!==void 0&&r!=null&&c(o,["_query","pageSize"],r);const d=u(n,["pageToken"]);o!==void 0&&d!=null&&c(o,["_query","pageToken"],d);const m=u(n,["filter"]);o!==void 0&&m!=null&&c(o,["_query","filter"],m);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],oh(l,g)),s}function nE(l,n){const o={},s=u(n,["config"]);return s!=null&&eE(l,s,o),o}function lE(l,n){const o={},s=u(n,["config"]);return s!=null&&tE(l,s,o),o}function iE(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["_self"]);if(r!=null){let d=ah(r);Array.isArray(d)&&(d=d.map(m=>sr(m))),c(n,["models"],d)}return n}function oE(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["_self"]);if(r!=null){let d=ah(r);Array.isArray(d)&&(d=d.map(m=>ur(m))),c(n,["models"],d)}return n}function aE(l){const n={},o=u(l,["maskMode"]);o!=null&&c(n,["maskMode"],o);const s=u(l,["segmentationClasses"]);s!=null&&c(n,["maskClasses"],s);const r=u(l,["maskDilation"]);return r!=null&&c(n,["dilation"],r),n}function sr(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);r!=null&&c(n,["description"],r);const d=u(l,["version"]);d!=null&&c(n,["version"],d);const m=u(l,["_self"]);m!=null&&c(n,["tunedModelInfo"],EE(m));const g=u(l,["inputTokenLimit"]);g!=null&&c(n,["inputTokenLimit"],g);const y=u(l,["outputTokenLimit"]);y!=null&&c(n,["outputTokenLimit"],y);const h=u(l,["supportedGenerationMethods"]);return h!=null&&c(n,["supportedActions"],h),n}function ur(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);r!=null&&c(n,["description"],r);const d=u(l,["versionId"]);d!=null&&c(n,["version"],d);const m=u(l,["deployedModels"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(_=>CS(_))),c(n,["endpoints"],S)}const g=u(l,["labels"]);g!=null&&c(n,["labels"],g);const y=u(l,["_self"]);y!=null&&c(n,["tunedModelInfo"],_E(y));const h=u(l,["defaultCheckpointId"]);h!=null&&c(n,["defaultCheckpointId"],h);const T=u(l,["checkpoints"]);if(T!=null){let S=T;Array.isArray(S)&&(S=S.map(_=>_)),c(n,["checkpoints"],S)}return n}function sE(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],ZT(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],AS(d));const m=u(l,["thoughtSignature"]);m!=null&&c(n,["thoughtSignature"],m);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function uE(l){const n={},o=u(l,["productImage"]);return o!=null&&c(n,["image"],Kt(o)),n}function rE(l,n){const o={},s=u(l,["numberOfImages"]);n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s);const r=u(l,["baseSteps"]);n!==void 0&&r!=null&&c(n,["parameters","editConfig","baseSteps"],r);const d=u(l,["outputGcsUri"]);n!==void 0&&d!=null&&c(n,["parameters","storageUri"],d);const m=u(l,["seed"]);n!==void 0&&m!=null&&c(n,["parameters","seed"],m);const g=u(l,["safetyFilterLevel"]);n!==void 0&&g!=null&&c(n,["parameters","safetySetting"],g);const y=u(l,["personGeneration"]);n!==void 0&&y!=null&&c(n,["parameters","personGeneration"],y);const h=u(l,["addWatermark"]);n!==void 0&&h!=null&&c(n,["parameters","addWatermark"],h);const T=u(l,["outputMimeType"]);n!==void 0&&T!=null&&c(n,["parameters","outputOptions","mimeType"],T);const S=u(l,["outputCompressionQuality"]);n!==void 0&&S!=null&&c(n,["parameters","outputOptions","compressionQuality"],S);const _=u(l,["enhancePrompt"]);n!==void 0&&_!=null&&c(n,["parameters","enhancePrompt"],_);const b=u(l,["labels"]);return n!==void 0&&b!=null&&c(n,["labels"],b),o}function cE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["source"]);r!=null&&dE(r,o);const d=u(n,["config"]);return d!=null&&rE(d,o),o}function fE(l){const n={},o=u(l,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>La(r))),c(n,["generatedImages"],s)}return n}function dE(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["personImage"]);n!==void 0&&r!=null&&c(n,["instances[0]","personImage","image"],Kt(r));const d=u(l,["productImages"]);if(n!==void 0&&d!=null){let m=d;Array.isArray(m)&&(m=m.map(g=>uE(g))),c(n,["instances[0]","productImages"],m)}return o}function pE(l){const n={},o=u(l,["referenceImage"]);o!=null&&c(n,["referenceImage"],Kt(o));const s=u(l,["referenceId"]);s!=null&&c(n,["referenceId"],s);const r=u(l,["referenceType"]);r!=null&&c(n,["referenceType"],r);const d=u(l,["maskImageConfig"]);d!=null&&c(n,["maskImageConfig"],aE(d));const m=u(l,["controlImageConfig"]);m!=null&&c(n,["controlImageConfig"],lS(m));const g=u(l,["styleImageConfig"]);g!=null&&c(n,["styleImageConfig"],g);const y=u(l,["subjectImageConfig"]);return y!=null&&c(n,["subjectImageConfig"],y),n}function mh(l){const n={},o=u(l,["safetyAttributes","categories"]);o!=null&&c(n,["categories"],o);const s=u(l,["safetyAttributes","scores"]);s!=null&&c(n,["scores"],s);const r=u(l,["contentType"]);return r!=null&&c(n,["contentType"],r),n}function hh(l){const n={},o=u(l,["safetyAttributes","categories"]);o!=null&&c(n,["categories"],o);const s=u(l,["safetyAttributes","scores"]);s!=null&&c(n,["scores"],s);const r=u(l,["contentType"]);return r!=null&&c(n,["contentType"],r),n}function mE(l){const n={};if(u(l,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=u(l,["category"]);o!=null&&c(n,["category"],o);const s=u(l,["threshold"]);return s!=null&&c(n,["threshold"],s),n}function hE(l){const n={},o=u(l,["image"]);return o!=null&&c(n,["image"],Kt(o)),n}function gE(l,n){const o={},s=u(l,["mode"]);n!==void 0&&s!=null&&c(n,["parameters","mode"],s);const r=u(l,["maxPredictions"]);n!==void 0&&r!=null&&c(n,["parameters","maxPredictions"],r);const d=u(l,["confidenceThreshold"]);n!==void 0&&d!=null&&c(n,["parameters","confidenceThreshold"],d);const m=u(l,["maskDilation"]);n!==void 0&&m!=null&&c(n,["parameters","maskDilation"],m);const g=u(l,["binaryColorThreshold"]);n!==void 0&&g!=null&&c(n,["parameters","binaryColorThreshold"],g);const y=u(l,["labels"]);return n!==void 0&&y!=null&&c(n,["labels"],y),o}function yE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["source"]);r!=null&&TE(r,o);const d=u(n,["config"]);return d!=null&&gE(d,o),o}function vE(l){const n={},o=u(l,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>OS(r))),c(n,["generatedMasks"],s)}return n}function TE(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Kt(r));const d=u(l,["scribbleImage"]);return n!==void 0&&d!=null&&c(n,["instances[0]","scribble"],hE(d)),o}function gh(l){const n={},o=u(l,["voiceConfig"]);if(o!=null&&c(n,["voiceConfig"],o),u(l,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const s=u(l,["languageCode"]);return s!=null&&c(n,["languageCode"],s),n}function SE(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],WS(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],$S(d));const m=u(l,["urlContext"]);m!=null&&c(n,["urlContext"],m);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}function yh(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>MS(_))),c(n,["functionDeclarations"],S)}const s=u(l,["retrieval"]);s!=null&&c(n,["retrieval"],s);const r=u(l,["googleSearch"]);r!=null&&c(n,["googleSearch"],r);const d=u(l,["googleSearchRetrieval"]);d!=null&&c(n,["googleSearchRetrieval"],d);const m=u(l,["enterpriseWebSearch"]);m!=null&&c(n,["enterpriseWebSearch"],m);const g=u(l,["googleMaps"]);g!=null&&c(n,["googleMaps"],g);const y=u(l,["urlContext"]);y!=null&&c(n,["urlContext"],y);const h=u(l,["computerUse"]);h!=null&&c(n,["computerUse"],h);const T=u(l,["codeExecution"]);return T!=null&&c(n,["codeExecution"],T),n}function EE(l){const n={},o=u(l,["baseModel"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["createTime"]);s!=null&&c(n,["createTime"],s);const r=u(l,["updateTime"]);return r!=null&&c(n,["updateTime"],r),n}function _E(l){const n={},o=u(l,["labels","google-vertex-llm-tuning-base-model-id"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["createTime"]);s!=null&&c(n,["createTime"],s);const r=u(l,["updateTime"]);return r!=null&&c(n,["updateTime"],r),n}function CE(l,n){const o={},s=u(l,["displayName"]);n!==void 0&&s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);n!==void 0&&r!=null&&c(n,["description"],r);const d=u(l,["defaultCheckpointId"]);return n!==void 0&&d!=null&&c(n,["defaultCheckpointId"],d),o}function AE(l,n){const o={},s=u(l,["displayName"]);n!==void 0&&s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);n!==void 0&&r!=null&&c(n,["description"],r);const d=u(l,["defaultCheckpointId"]);return n!==void 0&&d!=null&&c(n,["defaultCheckpointId"],d),o}function ME(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","name"],De(l,s));const r=u(n,["config"]);return r!=null&&CE(r,o),o}function RE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["config"]);return r!=null&&AE(r,o),o}function xE(l,n){const o={},s=u(l,["outputGcsUri"]);n!==void 0&&s!=null&&c(n,["parameters","storageUri"],s);const r=u(l,["includeRaiReason"]);n!==void 0&&r!=null&&c(n,["parameters","includeRaiReason"],r);const d=u(l,["outputMimeType"]);n!==void 0&&d!=null&&c(n,["parameters","outputOptions","mimeType"],d);const m=u(l,["outputCompressionQuality"]);n!==void 0&&m!=null&&c(n,["parameters","outputOptions","compressionQuality"],m);const g=u(l,["enhanceInputImage"]);n!==void 0&&g!=null&&c(n,["parameters","upscaleConfig","enhanceInputImage"],g);const y=u(l,["imagePreservationFactor"]);n!==void 0&&y!=null&&c(n,["parameters","upscaleConfig","imagePreservationFactor"],y);const h=u(l,["labels"]);n!==void 0&&h!=null&&c(n,["labels"],h);const T=u(l,["numberOfImages"]);n!==void 0&&T!=null&&c(n,["parameters","sampleCount"],T);const S=u(l,["mode"]);return n!==void 0&&S!=null&&c(n,["parameters","mode"],S),o}function NE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],De(l,s));const r=u(n,["image"]);r!=null&&c(o,["instances[0]","image"],Kt(r));const d=u(n,["upscaleFactor"]);d!=null&&c(o,["parameters","upscaleConfig","upscaleFactor"],d);const m=u(n,["config"]);return m!=null&&xE(m,o),o}function DE(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>La(d))),c(n,["generatedImages"],r)}return n}function bE(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["encodedVideo"]);s!=null&&c(n,["videoBytes"],Kn(s));const r=u(l,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function UE(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["uri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["videoBytes"],Kn(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function IE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["_self"],Kt(o));const s=u(l,["maskMode"]);return s!=null&&c(n,["maskMode"],s),n}function wE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["image"],Ga(o));const s=u(l,["referenceType"]);return s!=null&&c(n,["referenceType"],s),n}function qE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["image"],Kt(o));const s=u(l,["referenceType"]);return s!=null&&c(n,["referenceType"],s),n}function vh(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["videoBytes"]);s!=null&&c(n,["encodedVideo"],Kn(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["encoding"],r),n}function Th(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["videoBytes"]);s!=null&&c(n,["bytesBase64Encoded"],Kn(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const LE="Content-Type",GE="X-Server-Timeout",HE="User-Agent",rr="x-goog-api-client",zE="1.25.0",VE=`google-genai-sdk/${zE}`,BE="v1beta1",PE="v1beta",Pm=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class kE{constructor(n){var o,s;this.clientOptions=Object.assign(Object.assign({},n),{project:n.project,location:n.location,apiKey:n.apiKey,vertexai:n.vertexai});const r={};this.clientOptions.vertexai?(r.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:BE,r.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(r.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:PE,r.baseUrl="https://generativelanguage.googleapis.com/"),r.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=r,n.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(r,n.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 n;return(n=this.clientOptions.vertexai)!==null&&n!==void 0?n:!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(n){if(!n||n.baseUrl===void 0||n.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const s=[n.baseUrl.endsWith("/")?n.baseUrl.slice(0,-1):n.baseUrl];return n.apiVersion&&n.apiVersion!==""&&s.push(n.apiVersion),s.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const n=this.getBaseUrl(),o=new URL(n);return o.protocol=o.protocol=="http:"?"ws":"wss",o.toString()}setBaseUrl(n){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=n;else throw new Error("HTTP options are not correctly set.")}constructUrl(n,o,s){const r=[this.getRequestUrlInternal(o)];return s&&r.push(this.getBaseResourcePath()),n!==""&&r.push(n),new URL(`${r.join("/")}`)}shouldPrependVertexProjectPath(n){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||n.path.startsWith("projects/")||n.httpMethod==="GET"&&n.path.startsWith("publishers/google/models"))}async request(n){let o=this.clientOptions.httpOptions;n.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,n.httpOptions));const s=this.shouldPrependVertexProjectPath(n),r=this.constructUrl(n.path,o,s);if(n.queryParams)for(const[m,g]of Object.entries(n.queryParams))r.searchParams.append(m,String(g));let d={};if(n.httpMethod==="GET"){if(n.body&&n.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else d.body=n.body;return d=await this.includeExtraHttpOptionsToRequestInit(d,o,n.abortSignal),this.unaryApiCall(r,d,n.httpMethod)}patchHttpOptions(n,o){const s=JSON.parse(JSON.stringify(n));for(const[r,d]of Object.entries(o))typeof d=="object"?s[r]=Object.assign(Object.assign({},s[r]),d):d!==void 0&&(s[r]=d);return s}async requestStream(n){let o=this.clientOptions.httpOptions;n.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,n.httpOptions));const s=this.shouldPrependVertexProjectPath(n),r=this.constructUrl(n.path,o,s);(!r.searchParams.has("alt")||r.searchParams.get("alt")!=="sse")&&r.searchParams.set("alt","sse");let d={};return d.body=n.body,d=await this.includeExtraHttpOptionsToRequestInit(d,o,n.abortSignal),this.streamApiCall(r,d,n.httpMethod)}async includeExtraHttpOptionsToRequestInit(n,o,s){if(o&&o.timeout||s){const r=new AbortController,d=r.signal;if(o.timeout&&(o==null?void 0:o.timeout)>0){const m=setTimeout(()=>r.abort(),o.timeout);m&&typeof m.unref=="function"&&m.unref()}s&&s.addEventListener("abort",()=>{r.abort()}),n.signal=d}return o&&o.extraBody!==null&&YE(n,o.extraBody),n.headers=await this.getHeadersInternal(o),n}async unaryApiCall(n,o,s){return this.apiCall(n.toString(),Object.assign(Object.assign({},o),{method:s})).then(async r=>(await km(r),new ir(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}async streamApiCall(n,o,s){return this.apiCall(n.toString(),Object.assign(Object.assign({},o),{method:s})).then(async r=>(await km(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(n){var o;return oi(this,arguments,function*(){const r=(o=n==null?void 0:n.body)===null||o===void 0?void 0:o.getReader(),d=new TextDecoder("utf-8");if(!r)throw new Error("Response body is empty");try{let m="";for(;;){const{done:g,value:y}=yield Be(r.read());if(g){if(m.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const h=d.decode(y,{stream:!0});try{const S=JSON.parse(h);if("error"in S){const _=JSON.parse(JSON.stringify(S.error)),b=_.status,z=_.code,V=`got status: ${b}. ${JSON.stringify(S)}`;if(z>=400&&z<600)throw new wa({message:V,status:z})}}catch(S){if(S.name==="ApiError")throw S}m+=h;let T=m.match(Pm);for(;T;){const S=T[1];try{const _=new Response(S,{headers:n==null?void 0:n.headers,status:n==null?void 0:n.status,statusText:n==null?void 0:n.statusText});yield yield Be(new ir(_)),m=m.slice(T[0].length),T=m.match(Pm)}catch(_){throw new Error(`exception parsing stream chunk ${S}. ${_}`)}}}}finally{r.releaseLock()}})}async apiCall(n,o){return fetch(n,o).catch(s=>{throw new Error(`exception ${s} sending request`)})}getDefaultHeaders(){const n={},o=VE+" "+this.clientOptions.userAgentExtra;return n[HE]=o,n[rr]=o,n[LE]="application/json",n}async getHeadersInternal(n){const o=new Headers;if(n&&n.headers){for(const[s,r]of Object.entries(n.headers))o.append(s,r);n.timeout&&n.timeout>0&&o.append(GE,String(Math.ceil(n.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(o),o}async uploadFile(n,o){var s;const r={};o!=null&&(r.mimeType=o.mimeType,r.name=o.name,r.displayName=o.displayName),r.name&&!r.name.startsWith("files/")&&(r.name=`files/${r.name}`);const d=this.clientOptions.uploader,m=await d.stat(n);r.sizeBytes=String(m.size);const g=(s=o==null?void 0:o.mimeType)!==null&&s!==void 0?s:m.type;if(g===void 0||g==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");r.mimeType=g;const y=await this.fetchUploadUrl(r,o);return d.upload(n,y,this)}async downloadFile(n){await this.clientOptions.downloader.download(n,this)}async fetchUploadUrl(n,o){var s;let r={};o!=null&&o.httpOptions?r=o.httpOptions:r={apiVersion:"",headers:{"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${n.sizeBytes}`,"X-Goog-Upload-Header-Content-Type":`${n.mimeType}`}};const d={file:n},m=await this.request({path:te("upload/v1beta/files",d._url),body:JSON.stringify(d),httpMethod:"POST",httpOptions:r});if(!m||!(m!=null&&m.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const g=(s=m==null?void 0:m.headers)===null||s===void 0?void 0:s["x-goog-upload-url"];if(g===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return g}}async function km(l){var n;if(l===void 0)throw new Error("response is undefined");if(!l.ok){const o=l.status;let s;!((n=l.headers.get("content-type"))===null||n===void 0)&&n.includes("application/json")?s=await l.json():s={error:{message:await l.text(),code:l.status,status:l.statusText}};const r=JSON.stringify(s);throw o>=400&&o<600?new wa({message:r,status:o}):new Error(r)}}function YE(l,n){if(!n||Object.keys(n).length===0)return;if(l.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let o={};if(typeof l.body=="string"&&l.body.length>0)try{const d=JSON.parse(l.body);if(typeof d=="object"&&d!==null&&!Array.isArray(d))o=d;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function s(d,m){const g=Object.assign({},d);for(const y in m)if(Object.prototype.hasOwnProperty.call(m,y)){const h=m[y],T=g[y];h&&typeof h=="object"&&!Array.isArray(h)&&T&&typeof T=="object"&&!Array.isArray(T)?g[y]=s(T,h):(T&&h&&typeof T!=typeof h&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${y}". Original type: ${typeof T}, New type: ${typeof h}. Overwriting.`),g[y]=h)}return g}const r=s(o,n);l.body=JSON.stringify(r)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const JE="mcp_used/unknown";let OE=!1;function Sh(l){for(const n of l)if(FE(n)||typeof n=="object"&&"inputSchema"in n)return!0;return OE}function Eh(l){var n;const o=(n=l[rr])!==null&&n!==void 0?n:"";l[rr]=(o+` ${JE}`).trimStart()}function FE(l){return l!==null&&typeof l=="object"&&l instanceof yr}function XE(l,n=100){return oi(this,arguments,function*(){let s,r=0;for(;r0)return;const d={},m=[];for(const T of this.mcpClients)try{for(var g=!0,y=(o=void 0,ao(XE(T))),h;h=await y.next(),n=h.done,!n;g=!0){r=h.value,g=!1;const S=r;m.push(S);const _=S.name;if(d[_])throw new Error(`Duplicate function name ${_} found in MCP tools. Please ensure function names are unique.`);d[_]=T}}catch(S){o={error:S}}finally{try{!g&&!n&&(s=y.return)&&await s.call(y)}finally{if(o)throw o.error}}this.mcpTools=m,this.functionNameToMcpClient=d}async tool(){return await this.initialize(),W0(this.mcpTools,this.config)}async callTool(n){await this.initialize();const o=[];for(const s of n)if(s.name in this.functionNameToMcpClient){const r=this.functionNameToMcpClient[s.name];let d;this.config.timeout&&(d={timeout:this.config.timeout});const m=await r.callTool({name:s.name,arguments:s.args},void 0,d);o.push({functionResponse:{name:s.name,response:m.isError?{error:m}:m}})}return o}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */async function KE(l,n,o){const s=new J0;let r;o.data instanceof Blob?r=JSON.parse(await o.data.text()):r=JSON.parse(o.data),Object.assign(s,r),n(s)}class QE{constructor(n,o,s){this.apiClient=n,this.auth=o,this.webSocketFactory=s}async connect(n){var o,s;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 r=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion(),m=WE(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${r}/ws/google.ai.generativelanguage.${d}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const T=new Promise(B=>{h=B}),S=n.callbacks,_=function(){h({})},b=this.apiClient,z={onopen:_,onmessage:B=>{KE(b,S.onmessage,B)},onerror:(o=S==null?void 0:S.onerror)!==null&&o!==void 0?o:function(B){},onclose:(s=S==null?void 0:S.onclose)!==null&&s!==void 0?s:function(B){}},V=this.webSocketFactory.create(y,$E(m),z);V.connect(),await T;const K={setup:{model:De(this.apiClient,n.model)}};return V.send(JSON.stringify(K)),new ZE(V,this.apiClient)}}class ZE{constructor(n,o){this.conn=n,this.apiClient=o}async setWeightedPrompts(n){if(!n.weightedPrompts||Object.keys(n.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const o=PT(n);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(n){n.musicGenerationConfig||(n.musicGenerationConfig={});const o=BT(n);this.conn.send(JSON.stringify(o))}sendPlaybackControl(n){const o={playbackControl:n};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(li.PLAY)}pause(){this.sendPlaybackControl(li.PAUSE)}stop(){this.sendPlaybackControl(li.STOP)}resetContext(){this.sendPlaybackControl(li.RESET_CONTEXT)}close(){this.conn.close()}}function $E(l){const n={};return l.forEach((o,s)=>{n[s]=o}),n}function WE(l){const n=new Headers;for(const[o,s]of Object.entries(l))n.append(o,s);return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const jE="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function e_(l,n,o){const s=new Y0;let r;o.data instanceof Blob?r=await o.data.text():o.data instanceof ArrayBuffer?r=new TextDecoder().decode(o.data):r=o.data;const d=JSON.parse(r);if(l.isVertexAI()){const m=JT(d);Object.assign(s,m)}else Object.assign(s,d);n(s)}class t_{constructor(n,o,s){this.apiClient=n,this.auth=o,this.webSocketFactory=s,this.music=new QE(this.apiClient,this.auth,this.webSocketFactory)}async connect(n){var o,s,r,d,m,g;if(n.config&&n.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const y=this.apiClient.getWebsocketBaseUrl(),h=this.apiClient.getApiVersion();let T;const S=this.apiClient.getHeaders();n.config&&n.config.tools&&Sh(n.config.tools)&&Eh(S);const _=o_(S);if(this.apiClient.isVertexAI())T=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(_);else{const W=this.apiClient.getApiKey();let Q="BidiGenerateContent",ge="key";W!=null&&W.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),h!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),Q="BidiGenerateContentConstrained",ge="access_token"),T=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${Q}?${ge}=${W}`}let b=()=>{};const z=new Promise(W=>{b=W}),V=n.callbacks,Y=function(){var W;(W=V==null?void 0:V.onopen)===null||W===void 0||W.call(V),b({})},J=this.apiClient,K={onopen:Y,onmessage:W=>{e_(J,V.onmessage,W)},onerror:(o=V==null?void 0:V.onerror)!==null&&o!==void 0?o:function(W){},onclose:(s=V==null?void 0:V.onclose)!==null&&s!==void 0?s:function(W){}},B=this.webSocketFactory.create(T,i_(_),K);B.connect(),await z;let ee=De(this.apiClient,n.model);if(this.apiClient.isVertexAI()&&ee.startsWith("publishers/")){const W=this.apiClient.getProject(),Q=this.apiClient.getLocation();ee=`projects/${W}/locations/${Q}/`+ee}let le={};this.apiClient.isVertexAI()&&((r=n.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(n.config===void 0?n.config={responseModalities:[ba.AUDIO]}:n.config.responseModalities=[ba.AUDIO]),!((d=n.config)===null||d===void 0)&&d.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 ie=(g=(m=n.config)===null||m===void 0?void 0:m.tools)!==null&&g!==void 0?g:[],X=[];for(const W of ie)if(this.isCallableTool(W)){const Q=W;X.push(await Q.tool())}else X.push(W);X.length>0&&(n.config.tools=X);const ve={model:ee,config:n.config,callbacks:n.callbacks};return this.apiClient.isVertexAI()?le=VT(this.apiClient,ve):le=zT(this.apiClient,ve),delete le.config,B.send(JSON.stringify(le)),new l_(B,this.apiClient)}isCallableTool(n){return"callTool"in n&&typeof n.callTool=="function"}}const n_={turnComplete:!0};class l_{constructor(n,o){this.conn=n,this.apiClient=o}tLiveClientContent(n,o){if(o.turns!==null&&o.turns!==void 0){let s=[];try{s=kt(o.turns),n.isVertexAI()||(s=s.map(r=>qa(r)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof o.turns}'`)}return{clientContent:{turns:s,turnComplete:o.turnComplete}}}return{clientContent:{turnComplete:o.turnComplete}}}tLiveClienttToolResponse(n,o){let s=[];if(o.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(o.functionResponses)?s=o.functionResponses:s=[o.functionResponses],s.length===0)throw new Error("functionResponses is required.");for(const d of s){if(typeof d!="object"||d===null||!("name"in d)||!("response"in d))throw new Error(`Could not parse function response, type '${typeof d}'.`);if(!n.isVertexAI()&&!("id"in d))throw new Error(jE)}return{toolResponse:{functionResponses:s}}}sendClientContent(n){n=Object.assign(Object.assign({},n_),n);const o=this.tLiveClientContent(this.apiClient,n);this.conn.send(JSON.stringify(o))}sendRealtimeInput(n){let o={};this.apiClient.isVertexAI()?o={realtimeInput:YT(n)}:o={realtimeInput:kT(n)},this.conn.send(JSON.stringify(o))}sendToolResponse(n){if(n.functionResponses==null)throw new Error("Tool response parameters are required.");const o=this.tLiveClienttToolResponse(this.apiClient,n);this.conn.send(JSON.stringify(o))}close(){this.conn.close()}}function i_(l){const n={};return l.forEach((o,s)=>{n[s]=o}),n}function o_(l){const n=new Headers;for(const[o,s]of Object.entries(l))n.append(o,s);return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const Ym=10;function Jm(l){var n,o,s;if(!((n=l==null?void 0:l.automaticFunctionCalling)===null||n===void 0)&&n.disable)return!0;let r=!1;for(const m of(o=l==null?void 0:l.tools)!==null&&o!==void 0?o:[])if(ai(m)){r=!0;break}if(!r)return!0;const d=(s=l==null?void 0:l.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls;return d&&(d<0||!Number.isInteger(d))||d==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:",d),!0):!1}function ai(l){return"callTool"in l&&typeof l.callTool=="function"}function a_(l){var n,o,s;return(s=(o=(n=l.config)===null||n===void 0?void 0:n.tools)===null||o===void 0?void 0:o.some(r=>ai(r)))!==null&&s!==void 0?s:!1}function s_(l){var n,o,s;return(s=(o=(n=l.config)===null||n===void 0?void 0:n.tools)===null||o===void 0?void 0:o.some(r=>!ai(r)))!==null&&s!==void 0?s:!1}function Om(l){var n;return!(!((n=l==null?void 0:l.automaticFunctionCalling)===null||n===void 0)&&n.ignoreCallHistory)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class u_ extends yl{constructor(n){super(),this.apiClient=n,this.generateContent=async o=>{var s,r,d,m,g;const y=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!a_(o)||Jm(o.config))return await this.generateContentInternal(y);if(s_(o))throw new Error("Automatic function calling with CallableTools and Tools is not yet supported.");let h,T;const S=kt(y.contents),_=(d=(r=(s=y.config)===null||s===void 0?void 0:s.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&d!==void 0?d:Ym;let b=0;for(;b<_&&(h=await this.generateContentInternal(y),!(!h.functionCalls||h.functionCalls.length===0));){const z=h.candidates[0].content,V=[];for(const Y of(g=(m=o.config)===null||m===void 0?void 0:m.tools)!==null&&g!==void 0?g:[])if(ai(Y)){const K=await Y.callTool(h.functionCalls);V.push(...K)}b++,T={role:"user",parts:V},y.contents=kt(y.contents),y.contents.push(z),y.contents.push(T),Om(y.config)&&(S.push(z),S.push(T))}return Om(y.config)&&(h.automaticFunctionCallingHistory=S),h},this.generateContentStream=async o=>{if(this.maybeMoveToResponseJsonSchem(o),Jm(o.config)){const s=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(s)}else return await this.processAfcStream(o)},this.generateImages=async o=>await this.generateImagesInternal(o).then(s=>{var r;let d;const m=[];if(s!=null&&s.generatedImages)for(const y of s.generatedImages)y&&(y!=null&&y.safetyAttributes)&&((r=y==null?void 0:y.safetyAttributes)===null||r===void 0?void 0:r.contentType)==="Positive Prompt"?d=y==null?void 0:y.safetyAttributes:m.push(y);let g;return d?g={generatedImages:m,positivePromptSafetyAttributes:d,sdkHttpResponse:s.sdkHttpResponse}:g={generatedImages:m,sdkHttpResponse:s.sdkHttpResponse},g}),this.list=async o=>{var s;const m={config:Object.assign(Object.assign({},{queryBase:!0}),o==null?void 0:o.config)};if(this.apiClient.isVertexAI()&&!m.config.queryBase){if(!((s=m.config)===null||s===void 0)&&s.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");m.config.filter="labels.tune-type:*"}return new so(ml.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(m),m)},this.editImage=async o=>{const s={model:o.model,prompt:o.prompt,referenceImages:[],config:o.config};return o.referenceImages&&o.referenceImages&&(s.referenceImages=o.referenceImages.map(r=>r.toReferenceImageAPI())),await this.editImageInternal(s)},this.upscaleImage=async o=>{let s={numberOfImages:1,mode:"upscale"};o.config&&(s=Object.assign(Object.assign({},s),o.config));const r={model:o.model,image:o.image,upscaleFactor:o.upscaleFactor,config:s};return await this.upscaleImageInternal(r)},this.generateVideos=async o=>{var s,r,d,m,g,y;if((o.prompt||o.image||o.video)&&o.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((s=o.video)===null||s===void 0)&&s.uri&&(!((r=o.video)===null||r===void 0)&&r.videoBytes)?o.video={uri:o.video.uri,mimeType:o.video.mimeType}:!((m=(d=o.source)===null||d===void 0?void 0:d.video)===null||m===void 0)&&m.uri&&(!((y=(g=o.source)===null||g===void 0?void 0:g.video)===null||y===void 0)&&y.videoBytes)&&(o.source.video={uri:o.source.video.uri,mimeType:o.source.video.mimeType})),await this.generateVideosInternal(o)}}maybeMoveToResponseJsonSchem(n){n.config&&n.config.responseSchema&&(n.config.responseJsonSchema||Object.keys(n.config.responseSchema).includes("$schema")&&(n.config.responseJsonSchema=n.config.responseSchema,delete n.config.responseSchema))}async processParamsMaybeAddMcpUsage(n){var o,s,r;const d=(o=n.config)===null||o===void 0?void 0:o.tools;if(!d)return n;const m=await Promise.all(d.map(async y=>ai(y)?await y.tool():y)),g={model:n.model,contents:n.contents,config:Object.assign(Object.assign({},n.config),{tools:m})};if(g.config.tools=m,n.config&&n.config.tools&&Sh(n.config.tools)){const y=(r=(s=n.config.httpOptions)===null||s===void 0?void 0:s.headers)!==null&&r!==void 0?r:{};let h=Object.assign({},y);Object.keys(h).length===0&&(h=this.apiClient.getDefaultHeaders()),Eh(h),g.config.httpOptions=Object.assign(Object.assign({},n.config.httpOptions),{headers:h})}return g}async initAfcToolsMap(n){var o,s,r;const d=new Map;for(const m of(s=(o=n.config)===null||o===void 0?void 0:o.tools)!==null&&s!==void 0?s:[])if(ai(m)){const g=m,y=await g.tool();for(const h of(r=y.functionDeclarations)!==null&&r!==void 0?r:[]){if(!h.name)throw new Error("Function declaration name is required.");if(d.has(h.name))throw new Error(`Duplicate tool declaration name: ${h.name}`);d.set(h.name,g)}}return d}async processAfcStream(n){var o,s,r;const d=(r=(s=(o=n.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&r!==void 0?r:Ym;let m=!1,g=0;const y=await this.initAfcToolsMap(n);return(function(h,T,S){var _,b;return oi(this,arguments,function*(){for(var z,V,Y,J;g0){m=!0;const W=new io;W.candidates=[{content:{role:"user",parts:X}}],yield yield Be(W);const Q=[];Q.push(...ve),Q.push({role:"user",parts:X});const ge=kt(S.contents).concat(Q);S.contents=ge}else break}})})(this,y,n)}async generateContentInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=zm(this.apiClient,n);return g=te("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=Bm(T),_=new io;return Object.assign(_,S),_})}else{const h=Hm(this.apiClient,n);return g=te("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=Vm(T),_=new io;return Object.assign(_,S),_})}}async generateContentStreamInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=zm(this.apiClient,n);return g=te("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}),m.then(function(S){return oi(this,arguments,function*(){var _,b,z,V;try{for(var Y=!0,J=ao(S),K;K=yield Be(J.next()),_=K.done,!_;Y=!0){V=K.value,Y=!1;const B=V,ee=Bm(yield Be(B.json()));ee.sdkHttpResponse={headers:B.headers};const le=new io;Object.assign(le,ee),yield yield Be(le)}}catch(B){b={error:B}}finally{try{!Y&&!_&&(z=J.return)&&(yield Be(z.call(J)))}finally{if(b)throw b.error}}})})}else{const h=Hm(this.apiClient,n);return g=te("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}),m.then(function(S){return oi(this,arguments,function*(){var _,b,z,V;try{for(var Y=!0,J=ao(S),K;K=yield Be(J.next()),_=K.done,!_;Y=!0){V=K.value,Y=!1;const B=V,ee=Vm(yield Be(B.json()));ee.sdkHttpResponse={headers:B.headers};const le=new io;Object.assign(le,ee),yield yield Be(le)}}catch(B){b={error:B}}finally{try{!Y&&!_&&(z=J.return)&&(yield Be(z.call(J)))}finally{if(b)throw b.error}}})})}}async embedContent(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=SS(this.apiClient,n);return g=te("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=_S(T),_=new Em;return Object.assign(_,S),_})}else{const h=TS(this.apiClient,n);return g=te("{model}:batchEmbedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=ES(T),_=new Em;return Object.assign(_,S),_})}}async generateImagesInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=US(this.apiClient,n);return g=te("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=wS(T),_=new _m;return Object.assign(_,S),_})}else{const h=bS(this.apiClient,n);return g=te("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=IS(T),_=new _m;return Object.assign(_,S),_})}}async editImageInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=hS(this.apiClient,n);return d=te("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=gS(y),T=new L0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=NE(this.apiClient,n);return d=te("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=DE(y),T=new G0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=cE(this.apiClient,n);return d=te("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const h=fE(y),T=new H0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=yE(this.apiClient,n);return d=te("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const h=vE(y),T=new z0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async get(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ZS(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>ur(T))}else{const h=QS(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>sr(T))}}async listInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=lE(this.apiClient,n);return g=te("{models_url}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=oE(T),_=new Cm;return Object.assign(_,S),_})}else{const h=nE(this.apiClient,n);return g=te("{models_url}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=iE(T),_=new Cm;return Object.assign(_,S),_})}}async update(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=RE(this.apiClient,n);return g=te("{model}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>ur(T))}else{const h=ME(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>sr(T))}}async delete(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=fS(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=pS(T),_=new Am;return Object.assign(_,S),_})}else{const h=cS(this.apiClient,n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=dS(T),_=new Am;return Object.assign(_,S),_})}}async countTokens(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=sS(this.apiClient,n);return g=te("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=rS(T),_=new Mm;return Object.assign(_,S),_})}else{const h=aS(this.apiClient,n);return g=te("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=uS(T),_=new Mm;return Object.assign(_,S),_})}}async computeTokens(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=jT(this.apiClient,n);return d=te("{model}:computeTokens",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=eS(y),T=new V0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=VS(this.apiClient,n);return g=te("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m.then(T=>{const S=HS(T),_=new Ua;return Object.assign(_,S),_})}else{const h=zS(this.apiClient,n);return g=te("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m.then(T=>{const S=GS(T),_=new Ua;return Object.assign(_,S),_})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class r_ extends yl{constructor(n){super(),this.apiClient=n}async getVideosOperation(n){const o=n.operation,s=n.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=o.name.split("/operations/")[0];let d;s&&"httpOptions"in s&&(d=s.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:m,isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:r,isVertexAI:!1})}}async get(n){const o=n.operation,s=n.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=o.name.split("/operations/")[0];let d;s&&"httpOptions"in s&&(d=s.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:m,isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:r,isVertexAI:!1})}}async getVideosOperationInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=I0(n);return g=te("{operationName}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),m}else{const h=U0(n);return g=te("{operationName}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),m}}async fetchPredictVideosOperationInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=A0(n);return d=te("{resourceName}:fetchPredictOperation",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r}else throw new Error("This method is only supported by the Vertex AI.")}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function c_(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function f_(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>T_(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function d_(l,n,o){const s={},r=u(n,["expireTime"]);o!==void 0&&r!=null&&c(o,["expireTime"],r);const d=u(n,["newSessionExpireTime"]);o!==void 0&&d!=null&&c(o,["newSessionExpireTime"],d);const m=u(n,["uses"]);o!==void 0&&m!=null&&c(o,["uses"],m);const g=u(n,["liveConnectConstraints"]);o!==void 0&&g!=null&&c(o,["bidiGenerateContentSetup"],v_(l,g));const y=u(n,["lockAdditionalFields"]);return o!==void 0&&y!=null&&c(o,["fieldMask"],y),s}function p_(l,n){const o={},s=u(n,["config"]);return s!=null&&c(o,["config"],d_(l,s,o)),o}function m_(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function h_(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function g_(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function y_(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],s);const r=u(l,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(l,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const m=u(l,["topP"]);n!==void 0&&m!=null&&c(n,["setup","generationConfig","topP"],m);const g=u(l,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(l,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(l,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const T=u(l,["seed"]);n!==void 0&&T!=null&&c(n,["setup","generationConfig","seed"],T);const S=u(l,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],gr(S));const _=u(l,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const b=u(l,["enableAffectiveDialog"]);n!==void 0&&b!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],b);const z=u(l,["systemInstruction"]);n!==void 0&&z!=null&&c(n,["setup","systemInstruction"],f_(ft(z)));const V=u(l,["tools"]);if(n!==void 0&&V!=null){let ie=ui(V);Array.isArray(ie)&&(ie=ie.map(X=>E_(si(X)))),c(n,["setup","tools"],ie)}const Y=u(l,["sessionResumption"]);n!==void 0&&Y!=null&&c(n,["setup","sessionResumption"],S_(Y));const J=u(l,["inputAudioTranscription"]);n!==void 0&&J!=null&&c(n,["setup","inputAudioTranscription"],J);const K=u(l,["outputAudioTranscription"]);n!==void 0&&K!=null&&c(n,["setup","outputAudioTranscription"],K);const B=u(l,["realtimeInputConfig"]);n!==void 0&&B!=null&&c(n,["setup","realtimeInputConfig"],B);const ee=u(l,["contextWindowCompression"]);n!==void 0&&ee!=null&&c(n,["setup","contextWindowCompression"],ee);const le=u(l,["proactivity"]);return n!==void 0&&le!=null&&c(n,["setup","proactivity"],le),o}function v_(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],De(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],y_(r,o)),o}function T_(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],c_(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],m_(d));const m=u(l,["thoughtSignature"]);m!=null&&c(n,["thoughtSignature"],m);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function S_(l){const n={},o=u(l,["handle"]);if(o!=null&&c(n,["handle"],o),u(l,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return n}function E_(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],g_(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],h_(d));const m=u(l,["urlContext"]);m!=null&&c(n,["urlContext"],m);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function __(l){const n=[];for(const o in l)if(Object.prototype.hasOwnProperty.call(l,o)){const s=l[o];if(typeof s=="object"&&s!=null&&Object.keys(s).length>0){const r=Object.keys(s).map(d=>`${o}.${d}`);n.push(...r)}else n.push(o)}return n.join(",")}function C_(l,n){let o=null;const s=l.bidiGenerateContentSetup;if(typeof s=="object"&&s!==null&&"setup"in s){const d=s.setup;typeof d=="object"&&d!==null?(l.bidiGenerateContentSetup=d,o=d):delete l.bidiGenerateContentSetup}else s!==void 0&&delete l.bidiGenerateContentSetup;const r=l.fieldMask;if(o){const d=__(o);if(Array.isArray(n==null?void 0:n.lockAdditionalFields)&&(n==null?void 0:n.lockAdditionalFields.length)===0)d?l.fieldMask=d:delete l.fieldMask;else if(n!=null&&n.lockAdditionalFields&&n.lockAdditionalFields.length>0&&r!==null&&Array.isArray(r)&&r.length>0){const m=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];r.length>0&&(g=r.map(h=>m.includes(h)?`generationConfig.${h}`:h));const y=[];d&&y.push(d),g.length>0&&y.push(...g),y.length>0?l.fieldMask=y.join(","):delete l.fieldMask}else delete l.fieldMask}else r!==null&&Array.isArray(r)&&r.length>0?l.fieldMask=r.join(","):delete l.fieldMask;return l}class A_ extends yl{constructor(n){super(),this.apiClient=n}async create(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=p_(this.apiClient,n);d=te("auth_tokens",g._url),m=g._query,delete g.config,delete g._url,delete g._query;const y=C_(g,n.config);return r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),r.then(h=>h)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function M_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function R_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function x_(l,n){const o={};if(u(l,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const s=u(l,["tunedModelDisplayName"]);if(n!==void 0&&s!=null&&c(n,["displayName"],s),u(l,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const r=u(l,["epochCount"]);n!==void 0&&r!=null&&c(n,["tuningTask","hyperparameters","epochCount"],r);const d=u(l,["learningRateMultiplier"]);if(d!=null&&c(o,["tuningTask","hyperparameters","learningRateMultiplier"],d),u(l,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(u(l,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(u(l,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const m=u(l,["batchSize"]);n!==void 0&&m!=null&&c(n,["tuningTask","hyperparameters","batchSize"],m);const g=u(l,["learningRate"]);if(n!==void 0&&g!=null&&c(n,["tuningTask","hyperparameters","learningRate"],g),u(l,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");return o}function N_(l,n){const o={},s=u(l,["validationDataset"]);n!==void 0&&s!=null&&c(n,["supervisedTuningSpec"],Y_(s,o));const r=u(l,["tunedModelDisplayName"]);n!==void 0&&r!=null&&c(n,["tunedModelDisplayName"],r);const d=u(l,["description"]);n!==void 0&&d!=null&&c(n,["description"],d);const m=u(l,["epochCount"]);n!==void 0&&m!=null&&c(n,["supervisedTuningSpec","hyperParameters","epochCount"],m);const g=u(l,["learningRateMultiplier"]);n!==void 0&&g!=null&&c(n,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],g);const y=u(l,["exportLastCheckpointOnly"]);n!==void 0&&y!=null&&c(n,["supervisedTuningSpec","exportLastCheckpointOnly"],y);const h=u(l,["adapterSize"]);if(n!==void 0&&h!=null&&c(n,["supervisedTuningSpec","hyperParameters","adapterSize"],h),u(l,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(u(l,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const T=u(l,["labels"]);return n!==void 0&&T!=null&&c(n,["labels"],T),o}function D_(l){const n={},o=u(l,["baseModel"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["preTunedModel"]);s!=null&&c(n,["preTunedModel"],s);const r=u(l,["trainingDataset"]);r!=null&&c(n,["tuningTask","trainingData"],B_(r));const d=u(l,["config"]);return d!=null&&x_(d,n),n}function b_(l){const n={},o=u(l,["baseModel"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["preTunedModel"]);s!=null&&c(n,["preTunedModel"],s);const r=u(l,["trainingDataset"]);r!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],P_(r,n));const d=u(l,["config"]);return d!=null&&N_(d,n),n}function U_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function I_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function w_(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(l,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function q_(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(l,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function L_(l){const n={},o=u(l,["config"]);return o!=null&&w_(o,n),n}function G_(l){const n={},o=u(l,["config"]);return o!=null&&q_(o,n),n}function H_(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["tunedModels"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>_h(m))),c(n,["tuningJobs"],d)}return n}function z_(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["tuningJobs"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>cr(m))),c(n,["tuningJobs"],d)}return n}function V_(l){const n={},o=u(l,["name"]);o!=null&&c(n,["model"],o);const s=u(l,["name"]);return s!=null&&c(n,["endpoint"],s),n}function B_(l){const n={};if(u(l,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(l,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const o=u(l,["examples"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["examples","examples"],s)}return n}function P_(l,n){const o={},s=u(l,["gcsUri"]);n!==void 0&&s!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],s);const r=u(l,["vertexDatasetResource"]);if(n!==void 0&&r!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],r),u(l,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return o}function _h(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["state"]);r!=null&&c(n,["state"],lh(r));const d=u(l,["createTime"]);d!=null&&c(n,["createTime"],d);const m=u(l,["tuningTask","startTime"]);m!=null&&c(n,["startTime"],m);const g=u(l,["tuningTask","completeTime"]);g!=null&&c(n,["endTime"],g);const y=u(l,["updateTime"]);y!=null&&c(n,["updateTime"],y);const h=u(l,["description"]);h!=null&&c(n,["description"],h);const T=u(l,["baseModel"]);T!=null&&c(n,["baseModel"],T);const S=u(l,["_self"]);S!=null&&c(n,["tunedModel"],V_(S));const _=u(l,["customBaseModel"]);_!=null&&c(n,["customBaseModel"],_);const b=u(l,["experiment"]);b!=null&&c(n,["experiment"],b);const z=u(l,["labels"]);z!=null&&c(n,["labels"],z);const V=u(l,["outputUri"]);V!=null&&c(n,["outputUri"],V);const Y=u(l,["pipelineJob"]);Y!=null&&c(n,["pipelineJob"],Y);const J=u(l,["serviceAccount"]);J!=null&&c(n,["serviceAccount"],J);const K=u(l,["tunedModelDisplayName"]);K!=null&&c(n,["tunedModelDisplayName"],K);const B=u(l,["veoTuningSpec"]);return B!=null&&c(n,["veoTuningSpec"],B),n}function cr(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["state"]);r!=null&&c(n,["state"],lh(r));const d=u(l,["createTime"]);d!=null&&c(n,["createTime"],d);const m=u(l,["startTime"]);m!=null&&c(n,["startTime"],m);const g=u(l,["endTime"]);g!=null&&c(n,["endTime"],g);const y=u(l,["updateTime"]);y!=null&&c(n,["updateTime"],y);const h=u(l,["error"]);h!=null&&c(n,["error"],h);const T=u(l,["description"]);T!=null&&c(n,["description"],T);const S=u(l,["baseModel"]);S!=null&&c(n,["baseModel"],S);const _=u(l,["tunedModel"]);_!=null&&c(n,["tunedModel"],_);const b=u(l,["preTunedModel"]);b!=null&&c(n,["preTunedModel"],b);const z=u(l,["supervisedTuningSpec"]);z!=null&&c(n,["supervisedTuningSpec"],z);const V=u(l,["tuningDataStats"]);V!=null&&c(n,["tuningDataStats"],V);const Y=u(l,["encryptionSpec"]);Y!=null&&c(n,["encryptionSpec"],Y);const J=u(l,["partnerModelTuningSpec"]);J!=null&&c(n,["partnerModelTuningSpec"],J);const K=u(l,["customBaseModel"]);K!=null&&c(n,["customBaseModel"],K);const B=u(l,["experiment"]);B!=null&&c(n,["experiment"],B);const ee=u(l,["labels"]);ee!=null&&c(n,["labels"],ee);const le=u(l,["outputUri"]);le!=null&&c(n,["outputUri"],le);const ie=u(l,["pipelineJob"]);ie!=null&&c(n,["pipelineJob"],ie);const X=u(l,["serviceAccount"]);X!=null&&c(n,["serviceAccount"],X);const ve=u(l,["tunedModelDisplayName"]);ve!=null&&c(n,["tunedModelDisplayName"],ve);const W=u(l,["veoTuningSpec"]);return W!=null&&c(n,["veoTuningSpec"],W),n}function k_(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["metadata"]);r!=null&&c(n,["metadata"],r);const d=u(l,["done"]);d!=null&&c(n,["done"],d);const m=u(l,["error"]);return m!=null&&c(n,["error"],m),n}function Y_(l,n){const o={},s=u(l,["gcsUri"]);s!=null&&c(o,["validationDatasetUri"],s);const r=u(l,["vertexDatasetResource"]);return n!==void 0&&r!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],r),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class J_ extends yl{constructor(n){super(),this.apiClient=n,this.get=async o=>await this.getInternal(o),this.list=async(o={})=>new so(ml.PAGED_ITEM_TUNING_JOBS,s=>this.listInternal(s),await this.listInternal(o),o),this.tune=async o=>{var s;if(this.apiClient.isVertexAI())if(o.baseModel.startsWith("projects/")){const r={tunedModelName:o.baseModel};!((s=o.config)===null||s===void 0)&&s.preTunedModelCheckpointId&&(r.checkpointId=o.config.preTunedModelCheckpointId);const d=Object.assign(Object.assign({},o),{preTunedModel:r});return d.baseModel=void 0,await this.tuneInternal(d)}else{const r=Object.assign({},o);return await this.tuneInternal(r)}else{const r=Object.assign({},o),d=await this.tuneMldevInternal(r);let m="";return d.metadata!==void 0&&d.metadata.tunedModel!==void 0?m=d.metadata.tunedModel:d.name!==void 0&&d.name.includes("/operations/")&&(m=d.name.split("/operations/")[0]),{name:m,state:lr.JOB_STATE_QUEUED}}}}async getInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=I_(n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>cr(T))}else{const h=U_(n);return g=te("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>_h(T))}}async listInternal(n){var o,s,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=G_(n);return g=te("tuningJobs",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=z_(T),_=new Rm;return Object.assign(_,S),_})}else{const h=L_(n);return g=te("tunedModels",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),m.then(T=>{const S=H_(T),_=new Rm;return Object.assign(_,S),_})}}async cancel(n){var o,s,r,d;let m="",g={};if(this.apiClient.isVertexAI()){const y=R_(n);m=te("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal})}else{const y=M_(n);m=te("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal})}}async tuneInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=b_(n);return d=te("tuningJobs",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>cr(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(n){var o,s;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=D_(n);return d=te("tunedModels",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>k_(y))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class O_{async download(n,o){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const F_=1024*1024*8,X_=3,K_=1e3,Q_=2,tr="x-goog-upload-status";async function Z_(l,n,o){var s,r,d;let m=0,g=0,y=new ir(new Response),h="upload";for(m=l.size;g=m&&(h+=", finalize");let b=0,z=K_;for(;bsetTimeout(n,l))}class j_{async upload(n,o,s){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await Z_(n,o,s)}async stat(n){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await $_(n)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class eC{create(n,o,s){return new tC(n,o,s)}}class tC{constructor(n,o,s){this.url=n,this.headers=o,this.callbacks=s}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(n){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(n)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const Fm="x-goog-api-key";class nC{constructor(n){this.apiKey=n}async addAuthHeaders(n){if(n.get(Fm)===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.");n.append(Fm,this.apiKey)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const lC="gl-node/";class iC{constructor(n){var o;if(n.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(n.project||n.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=(o=n.vertexai)!==null&&o!==void 0?o:!1,this.apiKey=n.apiKey;const s=_0(n.httpOptions,n.vertexai,void 0,void 0);s&&(n.httpOptions?n.httpOptions.baseUrl=s:n.httpOptions={baseUrl:s}),this.apiVersion=n.apiVersion;const r=new nC(this.apiKey);this.apiClient=new kE({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:n.httpOptions,userAgentExtra:lC+"web",uploader:new j_,downloader:new O_}),this.models=new u_(this.apiClient),this.live=new t_(this.apiClient,r,new eC),this.batches=new Pv(this.apiClient),this.chats=new TT(this.models,this.apiClient),this.caches=new gT(this.apiClient),this.files=new DT(this.apiClient),this.operations=new r_(this.apiClient),this.authTokens=new A_(this.apiClient),this.tunings=new J_(this.apiClient)}}const oC="PLACEHOLDER_API_KEY",Xm=["gemini-2.5-flash","gemini-2.5-pro","gemma-2-9b-it"],oo=9;let xa=null;function aC(){return xa||(xa=new iC({apiKey:oC}),xa)}async function Ch(l,n){const o=aC();let s=null;for(let r=0;rsetTimeout(g,500))}}throw console.error("All AI generation attempts have failed."),s?new Error(`AI request failed after ${oo} attempts: ${s.message}`):new Error(`Failed to get AI response after ${oo} attempts.`)}async function sC(l,n,o){const s=` +You are a senior code assistant. Your task is to modify the code based on the user's instruction. +Return ONLY the complete, updated code block. Do not add explanations, introductory text, or markdown fences. + +Instruction: +${n} + +--- +Original Code: +${l} +--- +Updated Code: +`;await Ch(s,o)}async function uC(l,n,o,s){const r=` +You are an expert AI programmer executing a high-level directive on a codebase. +For the file at \`${o}\`, apply this overall instruction: "${n}" + +Your task is to enhance and expand this file based on the instruction. +- Add relevant new features, classes, and functions to substantially increase the file's content and value. +- Do NOT change or remove existing import statements. +- All new top-level functions, classes, or variables MUST be exported. +- Your changes should respect the repository's architecture and be able to interact with other modules. +- Strictly adhere to the coding style and language of the original file. + +Return ONLY the complete, updated code for this file. Do not include explanations or markdown fences. + +--- +Original Code from \`${o}\`: +${l} +--- +Updated Code: +`;await Ch(r,s)}const rC=({alert:l,onClose:n})=>{if(ce.useEffect(()=>{if(l){const s=setTimeout(n,4e3);return()=>clearTimeout(s)}},[l,n]),!l)return null;const o=l.type==="success"?"bg-green-600":"bg-red-600";return R.jsxs("div",{className:`fixed top-5 right-5 ${o} text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-fade-in-down`,children:[R.jsx("style",{children:` + @keyframes fade-in-down { + 0% { opacity: 0; transform: translateY(-20px); } + 100% { opacity: 1; transform: translateY(0); } + } + .animate-fade-in-down { animation: fade-in-down 0.5s ease-out forwards; } + `}),R.jsx("p",{children:l.msg})]})},cC=({fileCount:l,onClose:n,onSubmit:o})=>{const[s,r]=ce.useState(""),[d,m]=ce.useState(!1),g=async y=>{y.preventDefault(),!(!s.trim()||d)&&(m(!0),await o(s))};return R.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:n,children:R.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:y=>y.stopPropagation(),children:[R.jsx("h2",{className:"text-xl font-bold text-amber-400 mb-2",children:"Multi-File AI Edit"}),R.jsxs("p",{className:"text-gray-400 mb-4",children:[l," file",l>1?"s":""," selected."]}),R.jsxs("div",{className:"bg-red-900 border border-red-700 text-red-200 p-3 rounded-md mb-6 text-sm",children:[R.jsxs("p",{children:[R.jsx("strong",{children:"Warning:"})," This experimental feature will commit changes directly to the ",R.jsx("strong",{children:"current branch"})," for each repo. It processes up to ",R.jsx("strong",{children:"5 files concurrently"}),". This may take time and consume API resources."]}),R.jsx("p",{className:"mt-2",children:"It is highly recommended to create a new branch before starting and to review all changes."})]}),R.jsxs("form",{onSubmit:g,children:[R.jsxs("div",{className:"mb-4",children:[R.jsx("label",{htmlFor:"instruction-area",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Instruction for All Files"}),R.jsx("textarea",{id:"instruction-area",value:s,onChange:y=>r(y.target.value),placeholder:"e.g., 'Refactor all selected components to use functional components and hooks.'",className:"w-full h-32 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-amber-500 resize-none",autoFocus:!0})]}),R.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[R.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:d,children:"Cancel"}),R.jsx("button",{type:"submit",disabled:d||!s.trim(),className:"px-6 py-2 bg-amber-600 text-white font-semibold rounded-md hover:bg-amber-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:d?R.jsx(hl,{}):"Start AI Edit"})]})]})]})})},fC=({status:l})=>{switch(l){case"queued":return R.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 shrink-0"});case"processing":return R.jsx(hl,{className:"w-4 h-4 text-blue-400"});case"success":return R.jsx("div",{title:"Success",className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold shrink-0",children:"✓"});case"skipped":return R.jsx("div",{title:"Skipped",className:"w-4 h-4 rounded-full bg-yellow-500 flex items-center justify-center text-black text-xs font-bold shrink-0",children:"-"});case"failed":return R.jsx("div",{title:"Failed",className:"w-4 h-4 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold shrink-0",children:"!"});default:return null}},dC=({jobs:l,onClose:n,isComplete:o})=>{const s=l.filter(g=>["success","skipped","failed"].includes(g.status)).length,r=l.filter(g=>g.status==="success").length,d=l.length>0?s/l.length*100:0,m=l.filter(g=>g.status==="processing");return R.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:R.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-6xl h-[90vh] flex flex-col border border-gray-700",children:[R.jsxs("div",{className:"flex justify-between items-center mb-4 shrink-0",children:[R.jsx("h2",{className:"text-2xl font-bold text-amber-400",children:"AI Bulk Edit Progress"}),o&&R.jsx("button",{onClick:n,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),R.jsxs("div",{className:"mb-4 shrink-0",children:[R.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[R.jsx("span",{children:`Overall Progress (${s} / ${l.length})`}),R.jsxs("span",{children:[r," successful"]})]}),R.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:R.jsx("div",{className:"bg-amber-500 h-2.5 rounded-full transition-all duration-300",style:{width:`${d}%`}})})]}),R.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[R.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[R.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Queue"}),R.jsx("ul",{className:"space-y-1",children:l.map(g=>R.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[R.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[R.jsx(fC,{status:g.status}),R.jsx("span",{className:"truncate",title:g.path,children:g.path})]}),g.status==="failed"&&R.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:g.error||"",children:"Error"})]},g.id))})]}),R.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[R.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",m.length," active)"]}),m.length>0?R.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 flex-grow min-h-0",children:m.slice(0,5).map(g=>R.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[R.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:g.path,children:["Processing: ",R.jsx("span",{className:"font-bold",children:g.path.split("/").pop()})]}),R.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:R.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:R.jsx("code",{children:g.content})})})]},g.id))}):R.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:o?"All jobs complete.":"Waiting for next job..."})]})]})]})})},vr=l=>{let n=[];for(const o of l)o.type==="file"?n.push(o.path):o.type==="dir"&&(n=n.concat(vr(o.children)));return n};function pC(){const[l,n]=ce.useState(null),[o,s]=ce.useState({}),[r,d]=ce.useState([]),[m,g]=ce.useState(null),[y,h]=ce.useState(!1),[T,S]=ce.useState(""),[_,b]=ce.useState(null),[z,V]=ce.useState({}),[Y,J]=ce.useState({}),[K,B]=ce.useState(!1),[ee,le]=ce.useState(new Set),[ie,X]=ce.useState(!1),[ve,W]=ce.useState([]),Q=r.find(P=>P.repoId+"::"+P.path===m),ge=Q?Y[Q.repoId]:null,me=Q?z[Q.repoId]||[]:[],Ae=(P,F)=>{b({type:P,msg:F})},ut=ce.useCallback(async P=>{if(P){n(P),h(!0),S("Fetching repos...");try{const F=await p0(P),re={},$=F.map(async de=>{S(`Processing ${de.full_name}...`);try{re[de.full_name]={repo:de,tree:[]};const Re=await h0(P,de.owner.login,de.name,de.default_branch);re[de.full_name].tree=Re}catch(Re){console.error(`Tree fetch failed for ${de.full_name}`,Re)}});await Promise.all($),s(re),Ae("success","Repos loaded.")}catch(F){console.error(F),n(null),Ae("error",`Login failed: ${F instanceof Error?F.message:"Check token."}`)}finally{h(!1),S("")}}},[]),Xe=ce.useCallback(async(P,F,re)=>{var de;const $=`${P}::${F}`;if(r.some(Re=>Re.repoId+"::"+Re.path===$)){g($);return}if(l){h(!0),S(`Loading ${F}...`);try{const[Re,ke]=P.split("/"),mt=(de=o[P])==null?void 0:de.repo;if(!mt)throw new Error("Repo data not found");if(!z[P]){S("Fetching branches...");const Yt=await Np(l,Re,ke);V(Qn=>({...Qn,[P]:Yt}))}const je=re||Y[P]||mt.default_branch;J(Yt=>({...Yt,[P]:je})),S(`Loading ${F} from ${je}...`);const dt=await Ra(l,Re,ke,F,je),jt={repoId:P,path:dt.path,content:dt.content,edited:dt.content,sha:dt.sha,defaultBranch:mt.default_branch};d(Yt=>[...Yt,jt]),g($)}catch(Re){console.error(Re),Ae("error",`Failed to load file: ${F}`)}finally{h(!1),S("")}}},[l,o,r,z,Y]),w=ce.useCallback(P=>{const F=r.findIndex($=>$.repoId+"::"+$.path===P);if(F===-1)return;const re=r.filter($=>$.repoId+"::"+$.path!==P);if(d(re),m===P){const $=Math.max(0,F-1),de=re.length>0?re[$]:null;g(de?de.repoId+"::"+de.path:null)}},[r,m]),k=ce.useCallback((P,F)=>{d(re=>re.map($=>$.repoId+"::"+$.path===P?{...$,edited:F}:$))},[]),se=ce.useCallback(async(P,F,re)=>{h(!0),S("AI is editing...");try{await sC(P,F,re),Ae("success","AI edit complete.")}catch($){console.error("AI Edit Error:",$);const de=$ instanceof Error?$.message:"An unknown AI error occurred.";Ae("error",`AI Error: ${de}`)}finally{h(!1),S("")}},[]),oe=ce.useCallback(async P=>{if(!(!l||!Q||!ge)){h(!0),S("Committing...");try{const[F,re]=Q.repoId.split("/");await Dp({token:l,owner:F,repo:re,branch:ge,path:Q.path,content:Q.edited,message:P,sha:Q.sha});const $=await Ra(l,F,re,Q.path,ge);d(de=>de.map(Re=>Re.repoId+"::"+Re.path===m?{...Re,content:$.content,edited:$.content,sha:$.sha}:Re)),Ae("success","Commit successful!")}catch(F){console.error(F),Ae("error",`Commit failed: ${F.message}`)}finally{h(!1),S("")}}},[l,Q,ge,m]),Me=ce.useCallback(P=>{if(Q){const F=Q.repoId;J(de=>({...de,[F]:P}));const re=r.filter(de=>de.repoId===F),$=r.filter(de=>de.repoId!==F);d($),g($[0]?$[0].repoId+"::"+$[0].path:null),re.forEach(de=>Xe(de.repoId,de.path,P))}},[Q,r,Xe]),M=ce.useCallback(async P=>{if(!(!l||!Q||!ge)){h(!0),S(`Creating branch ${P}...`);try{const[F,re]=Q.repoId.split("/"),$=me.find(Re=>Re.name===ge);if(!$)throw new Error("Base branch not found");await g0(l,F,re,P,$.commit.sha);const de=await Np(l,F,re);V(Re=>({...Re,[Q.repoId]:de})),J(Re=>({...Re,[Q.repoId]:P})),Ae("success",`Branch '${P}' created.`)}catch(F){console.error(F),Ae("error",`Branch creation failed: ${F.message}`)}finally{h(!1),S("")}}},[l,Q,ge,me]),G=ce.useCallback(async(P,F)=>{if(!(!l||!Q||!ge)){h(!0),S("Creating pull request...");try{const[re,$]=Q.repoId.split("/"),de=await v0({token:l,owner:re,repo:$,title:P,body:F,head:ge,base:Q.defaultBranch});Ae("success",`PR #${de.number} created!`),window.open(de.html_url,"_blank")}catch(re){console.error(re),Ae("error",`PR creation failed: ${re.message}`)}finally{h(!1),S("")}}},[l,Q,ge]),O=ce.useCallback((P,F)=>{le(re=>{const $=new Set(re);return F?$.add(P):$.delete(P),$})},[]),Z=ce.useCallback((P,F,re)=>{const $=vr(P);le(de=>{const Re=new Set(de);for(const ke of $){const mt=`${F}::${ke}`;re?Re.add(mt):Re.delete(mt)}return Re})},[]),fe=ce.useCallback(async P=>{if(!l||ee.size===0)return;B(!1);const F=Array.from(ee).map(ke=>{const[mt,je]=ke.split("::");return{id:ke,repoId:mt,path:je,status:"queued",content:"",error:null}});W(F),X(!0),le(new Set);const re=async ke=>{var vl;W(rt=>rt.map(nt=>nt.id===ke?{...nt,status:"processing"}:nt));const mt=F.find(rt=>rt.id===ke);if(!mt||!l)return;const{repoId:je,path:dt}=mt,[jt,Yt]=je.split("/"),Qn=(vl=o[je])==null?void 0:vl.repo;if(!Qn){W(rt=>rt.map(nt=>nt.id===ke?{...nt,status:"failed",error:"Repo data missing"}:nt));return}try{const rt=Y[je]||Qn.default_branch,nt=await Ra(l,jt,Yt,dt,rt);let en="";if(await uC(nt.content,P,dt,He=>{en+=He,W(_t=>_t.map(Jt=>Jt.id===ke?{...Jt,content:en}:Jt))}),en.trim()===nt.content.trim()||en.trim()===""){W(He=>He.map(_t=>_t.id===ke?{..._t,status:"skipped"}:_t));return}await Dp({token:l,owner:jt,repo:Yt,branch:rt,path:dt,content:en,message:`[AI] Edit: ${dt}`,sha:nt.sha}),W(He=>He.map(_t=>_t.id===ke?{..._t,status:"success"}:_t));const En=`${je}::${dt}`;if(r.some(He=>He.repoId+"::"+He.path===En)){const He=await Ra(l,jt,Yt,dt,rt);d(_t=>_t.map(Jt=>Jt.repoId+"::"+Jt.path===En?{...Jt,content:He.content,edited:He.content,sha:He.sha}:Jt))}}catch(rt){const nt=rt instanceof Error?rt.message:"Unknown error.";W(en=>en.map(En=>En.id===ke?{...En,status:"failed",error:nt}:En))}},$=5,de=[...F],Re=async()=>{for(;de.length>0;){const ke=de.shift();ke&&await re(ke.id)}};await Promise.all(Array($).fill(null).map(Re)),Ae("success","Multi-file edit complete.")},[l,ee,o,Y,r]);return R.jsxs("div",{className:"flex h-screen font-sans",children:[l?R.jsxs(R.Fragment,{children:[R.jsx("aside",{className:"w-1/4 max-w-sm min-w-[300px] bg-gray-900 overflow-y-auto border-r border-gray-700 h-full",children:R.jsx(a0,{fsTree:o,onFileSelect:Xe,onStartMultiEdit:()=>B(!0),selectedRepo:Q==null?void 0:Q.repoId,selectedFilePath:Q==null?void 0:Q.path,selectedFiles:ee,onFileSelection:O,onDirectorySelection:Z})}),R.jsx("main",{className:"flex-grow h-full",children:R.jsx(f0,{openFiles:r,activeFile:Q||null,onCommit:oe,onAiEdit:se,onFileContentChange:k,onCloseFile:w,onSetActiveFile:g,isLoading:y,branches:me,currentBranch:ge,onBranchChange:Me,onCreateBranch:M,onCreatePullRequest:G})})]}):R.jsx(n0,{onSubmit:ut,isLoading:y}),y&&!ie&&R.jsxs("div",{className:"fixed top-5 left-1/2 -translate-x-1/2 bg-gray-800 text-white px-6 py-3 rounded-lg shadow-lg z-50 flex items-center gap-4 animate-fade-in-down",children:[R.jsx("style",{children:".animate-fade-in-down { animation: fade-in-down 0.5s ease-out forwards; } @keyframes fade-in-down { 0% { opacity: 0; transform: translate(-50%, -20px); } 100% { opacity: 1; transform: translate(-50%, 0); } }"}),R.jsx(hl,{}),R.jsx("p",{children:T})]}),_&&R.jsx(rC,{alert:_,onClose:()=>b(null)}),K&&R.jsx(cC,{fileCount:ee.size,onClose:()=>B(!1),onSubmit:fe}),ie&&R.jsx(dC,{jobs:ve,onClose:()=>X(!1),isComplete:!ve.some(P=>P.status==="processing"||P.status==="queued")})]})}const Ah=document.getElementById("root");if(!Ah)throw new Error("Could not find root element to mount to");const mC=t0.createRoot(Ah);mC.render(R.jsx(Xy.StrictMode,{children:R.jsx(pC,{})}));