diff --git "a/assets/index-VJuOeVR8.js" "b/assets/index-VJuOeVR8.js" new file mode 100644--- /dev/null +++ "b/assets/index-VJuOeVR8.js" @@ -0,0 +1,265 @@ +(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 p of d.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&s(p)}).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 sh(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var fr={exports:{}},go={};/** + * @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 qm;function Zy(){if(qm)return go;qm=1;var l=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(s,r,d){var p=null;if(d!==void 0&&(p=""+d),r.key!==void 0&&(p=""+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:p,ref:r!==void 0?r:null,props:d}}return go.Fragment=n,go.jsx=o,go.jsxs=o,go}var Lm;function $y(){return Lm||(Lm=1,fr.exports=Zy()),fr.exports}var _=$y(),dr={exports:{}},he={};/** + * @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 Gm;function Wy(){if(Gm)return he;Gm=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"),p=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"),C=Symbol.iterator;function R(M){return M===null||typeof M!="object"?null:(M=C&&M[C]||M["@@iterator"],typeof M=="function"?M:null)}var L={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},U=Object.assign,k={};function P(M,B,K){this.props=M,this.context=B,this.refs=k,this.updater=K||L}P.prototype.isReactComponent={},P.prototype.setState=function(M,B){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,B,"setState")},P.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function F(){}F.prototype=P.prototype;function z(M,B,K){this.props=M,this.context=B,this.refs=k,this.updater=K||L}var $=z.prototype=new F;$.constructor=z,U($,P.prototype),$.isPureReactComponent=!0;var W=Array.isArray;function ae(){}var O={H:null,A:null,T:null,S:null},Ce=Object.prototype.hasOwnProperty;function le(M,B,K){var Q=K.ref;return{$$typeof:l,type:M,key:B,ref:Q!==void 0?Q:null,props:K}}function ve(M,B){return le(M.type,B,M.props)}function be(M){return typeof M=="object"&&M!==null&&M.$$typeof===l}function Te(M){var B={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(K){return B[K]})}var Oe=/\/+/g;function Ct(M,B){return typeof M=="object"&&M!==null&&M.key!=null?Te(""+M.key):B.toString(36)}function me(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(ae,ae):(M.status="pending",M.then(function(B){M.status==="pending"&&(M.status="fulfilled",M.value=B)},function(B){M.status==="pending"&&(M.status="rejected",M.reason=B)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function q(M,B,K,Q,de){var Ee=typeof M;(Ee==="undefined"||Ee==="boolean")&&(M=null);var De=!1;if(M===null)De=!0;else switch(Ee){case"bigint":case"string":case"number":De=!0;break;case"object":switch(M.$$typeof){case l:case n:De=!0;break;case T:return De=M._init,q(De(M._payload),B,K,Q,de)}}if(De)return de=de(M),De=Q===""?"."+Ct(M,0):Q,W(de)?(K="",De!=null&&(K=De.replace(Oe,"$&/")+"/"),q(de,B,K,"",function(gt){return gt})):de!=null&&(be(de)&&(de=ve(de,K+(de.key==null||M&&M.key===de.key?"":(""+de.key).replace(Oe,"$&/")+"/")+De)),B.push(de)),1;De=0;var ot=Q===""?".":Q+":";if(W(M))for(var te=0;te>>1,qe=q[Ge];if(0>>1;Ger(K,ce))Qr(de,K)?(q[Ge]=de,q[Q]=ce,Ge=Q):(q[Ge]=K,q[B]=ce,Ge=B);else if(Qr(de,ce))q[Ge]=de,q[Q]=ce,Ge=Q;else break e}}return Y}function r(q,Y){var ce=q.sortIndex-Y.sortIndex;return ce!==0?ce:q.id-Y.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 p=Date,g=p.now();l.unstable_now=function(){return p.now()-g}}var y=[],h=[],T=1,S=null,C=3,R=!1,L=!1,U=!1,k=!1,P=typeof setTimeout=="function"?setTimeout:null,F=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function $(q){for(var Y=o(h);Y!==null;){if(Y.callback===null)s(h);else if(Y.startTime<=q)s(h),Y.sortIndex=Y.expirationTime,n(y,Y);else break;Y=o(h)}}function W(q){if(U=!1,$(q),!L)if(o(y)!==null)L=!0,ae||(ae=!0,Te());else{var Y=o(h);Y!==null&&me(W,Y.startTime-q)}}var ae=!1,O=-1,Ce=5,le=-1;function ve(){return k?!0:!(l.unstable_now()-leq&&ve());){var Ge=S.callback;if(typeof Ge=="function"){S.callback=null,C=S.priorityLevel;var qe=Ge(S.expirationTime<=q);if(q=l.unstable_now(),typeof qe=="function"){S.callback=qe,$(q),Y=!0;break t}S===o(y)&&s(y),$(q)}else s(y);S=o(y)}if(S!==null)Y=!0;else{var M=o(h);M!==null&&me(W,M.startTime-q),Y=!1}}break e}finally{S=null,C=ce,R=!1}Y=void 0}}finally{Y?Te():ae=!1}}}var Te;if(typeof z=="function")Te=function(){z(be)};else if(typeof MessageChannel<"u"){var Oe=new MessageChannel,Ct=Oe.port2;Oe.port1.onmessage=be,Te=function(){Ct.postMessage(null)}}else Te=function(){P(be,0)};function me(q,Y){O=P(function(){q(l.unstable_now())},Y)}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(q){q.callback=null},l.unstable_forceFrameRate=function(q){0>q||125Ge?(q.sortIndex=ce,n(h,q),o(y)===null&&q===o(h)&&(U?(F(O),O=-1):U=!0,me(W,ce-Ge))):(q.sortIndex=qe,n(y,q),L||R||(L=!0,ae||(ae=!0,Te()))),q},l.unstable_shouldYield=ve,l.unstable_wrapCallback=function(q){var Y=C;return function(){var ce=C;C=Y;try{return q.apply(this,arguments)}finally{C=ce}}}})(hr)),hr}var Vm;function t0(){return Vm||(Vm=1,pr.exports=e0()),pr.exports}var gr={exports:{}},_t={};/** + * @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 Bm;function n0(){if(Bm)return _t;Bm=1;var l=wr();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(),gr.exports=n0(),gr.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 Pm;function i0(){if(Pm)return yo;Pm=1;var l=t0(),n=wr(),o=l0();function s(e){var t="https://react.dev/errors/"+e;if(1qe||(e.current=Ge[qe],Ge[qe]=null,qe--)}function K(e,t){qe++,Ge[qe]=e.current,e.current=t}var Q=M(null),de=M(null),Ee=M(null),De=M(null);function ot(e,t){switch(K(Ee,t),K(de,e),K(Q,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?lm(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=lm(t),e=im(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}B(Q),K(Q,e)}function te(){B(Q),B(de),B(Ee)}function gt(e){e.memoizedState!==null&&K(De,e);var t=Q.current,i=im(t,e.type);t!==i&&(K(de,e),K(Q,i))}function wn(e){de.current===e&&(B(Q),B(de)),De.current===e&&(B(De),fo._currentValue=ce)}var Si,at;function tn(e){if(Si===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);Si=t&&t[1]||"",at=-1)":-1f||A[a]!==D[f]){var G=` +`+A[a].replace(" at new "," at ");return e.displayName&&G.includes("")&&(G=G.replace("",e.displayName)),G}while(1<=a&&0<=f);break}}}finally{Ei=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?tn(i):""}function Qa(e,t){switch(e.tag){case 26:case 27:case 5:return tn(e.type);case 16:return tn("Lazy");case 13:return e.child!==t&&t!==null?tn("Suspense Fallback"):tn("Suspense");case 19:return tn("SuspenseList");case 0:case 15:return Ci(e.type,!1);case 11:return Ci(e.type.render,!1);case 1:return Ci(e.type,!0);case 31:return tn("Activity");default:return""}}function Nt(e){try{var t="",i=null;do t+=Qa(e,i),i=e,e=e.return;while(e);return t}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var _i=Object.prototype.hasOwnProperty,Ai=l.unstable_scheduleCallback,xi=l.unstable_cancelCallback,Za=l.unstable_shouldYield,$a=l.unstable_requestPaint,xt=l.unstable_now,Eo=l.unstable_getCurrentPriorityLevel,Co=l.unstable_ImmediatePriority,_o=l.unstable_UserBlockingPriority,xl=l.unstable_NormalPriority,Wa=l.unstable_LowPriority,Ao=l.unstable_IdlePriority,J=l.log,j=l.unstable_setDisableYieldValue,fe=null,Z=null;function oe(e){if(typeof J=="function"&&j(e),Z&&typeof Z.setStrictMode=="function")try{Z.setStrictMode(fe,e)}catch{}}var ue=Math.clz32?Math.clz32:tt,We=Math.log,dt=Math.LN2;function tt(e){return e>>>=0,e===0?32:31-(We(e)/dt|0)|0}var Qe=256,pe=262144,Re=4194304;function ze(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 Ze(e,t,i){var a=e.pendingLanes;if(a===0)return 0;var f=0,m=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var E=a&134217727;return E!==0?(a=E&~m,a!==0?f=ze(a):(v&=E,v!==0?f=ze(v):i||(i=E&~e,i!==0&&(f=ze(i))))):(E=a&~m,E!==0?f=ze(E):v!==0?f=ze(v):i||(i=a&~e,i!==0&&(f=ze(i)))),f===0?0:t!==0&&t!==f&&(t&m)===0&&(m=f&-f,i=t&-t,m>=i||m===32&&(i&4194048)!==0)?t:f}function ge(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function He(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 mt(){var e=Re;return Re<<=1,(Re&62914560)===0&&(Re=4194304),e}function sn(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function Pt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ja(e,t,i,a,f,m){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,A=e.expirationTimes,D=e.hiddenUpdates;for(i=v&~i;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Jh=/[\n"\\]/g;function Jt(e){return e.replace(Jh,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function os(e,t,i,a,f,m,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=""+Yt(t)):e.value!==""+Yt(t)&&(e.value=""+Yt(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?as(e,v,Yt(t)):i!=null?as(e,v,Yt(i)):a!=null&&e.removeAttribute("value"),f==null&&m!=null&&(e.defaultChecked=!!m),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+Yt(E):e.removeAttribute("name")}function Zr(e,t,i,a,f,m,v,E){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.type=m),t!=null||i!=null){if(!(m!=="submit"&&m!=="reset"||t!=null)){is(e);return}i=i!=null?""+Yt(i):"",t=t!=null?""+Yt(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),is(e)}function as(e,t,i){t==="number"&&No(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function wl(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"),fs=!1;if(pn)try{var bi={};Object.defineProperty(bi,"passive",{get:function(){fs=!0}}),window.addEventListener("test",bi,bi),window.removeEventListener("test",bi,bi)}catch{fs=!1}var In=null,ds=null,bo=null;function lc(){if(bo)return bo;var e,t=ds,i=t.length,a,f="value"in In?In.value:In.textContent,m=f.length;for(e=0;e=Ui),rc=" ",cc=!1;function fc(e,t){switch(e){case"keyup":return vg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ll=!1;function Sg(e,t){switch(e){case"compositionend":return dc(t);case"keypress":return t.which!==32?null:(cc=!0,rc);case"textInput":return e=t.data,e===rc&&cc?null:e;default:return null}}function Eg(e,t){if(Ll)return e==="compositionend"||!ys&&fc(e,t)?(e=lc(),bo=ds=In=null,Ll=!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=Sc(i)}}function Cc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Cc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _c(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=No(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=No(e.document)}return t}function Ss(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 bg=pn&&"documentMode"in document&&11>=document.documentMode,Gl=null,Es=null,Gi=null,Cs=!1;function Ac(e,t,i){var a=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Cs||Gl==null||Gl!==No(a)||(a=Gl,"selectionStart"in a&&Ss(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}),Gi&&Li(Gi,a)||(Gi=a,a=Ca(Es,"onSelect"),0>=v,f-=v,un=1<<32-ue(t)+f|i<Se?(Me=ie,ie=null):Me=ie.sibling;var Ue=w(N,ie,b[Se],H);if(Ue===null){ie===null&&(ie=Me);break}e&&ie&&Ue.alternate===null&&t(N,ie),x=m(Ue,x,Se),we===null?se=Ue:we.sibling=Ue,we=Ue,ie=Me}if(Se===b.length)return i(N,ie),Ne&&gn(N,Se),se;if(ie===null){for(;SeSe?(Me=ie,ie=null):Me=ie.sibling;var tl=w(N,ie,Ue.value,H);if(tl===null){ie===null&&(ie=Me);break}e&&ie&&tl.alternate===null&&t(N,ie),x=m(tl,x,Se),we===null?se=tl:we.sibling=tl,we=tl,ie=Me}if(Ue.done)return i(N,ie),Ne&&gn(N,Se),se;if(ie===null){for(;!Ue.done;Se++,Ue=b.next())Ue=V(N,Ue.value,H),Ue!==null&&(x=m(Ue,x,Se),we===null?se=Ue:we.sibling=Ue,we=Ue);return Ne&&gn(N,Se),se}for(ie=a(ie);!Ue.done;Se++,Ue=b.next())Ue=I(ie,N,Se,Ue.value,H),Ue!==null&&(e&&Ue.alternate!==null&&ie.delete(Ue.key===null?Se:Ue.key),x=m(Ue,x,Se),we===null?se=Ue:we.sibling=Ue,we=Ue);return e&&ie.forEach(function(Qy){return t(N,Qy)}),Ne&&gn(N,Se),se}function Ye(N,x,b,H){if(typeof b=="object"&&b!==null&&b.type===U&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case R:e:{for(var se=b.key;x!==null;){if(x.key===se){if(se=b.type,se===U){if(x.tag===7){i(N,x.sibling),H=f(x,b.props.children),H.return=N,N=H;break e}}else if(x.elementType===se||typeof se=="object"&&se!==null&&se.$$typeof===Ce&&hl(se)===x.type){i(N,x.sibling),H=f(x,b.props),Pi(H,b),H.return=N,N=H;break e}i(N,x);break}else t(N,x);x=x.sibling}b.type===U?(H=cl(b.props.children,N.mode,H,b.key),H.return=N,N=H):(H=Vo(b.type,b.key,b.props,null,N.mode,H),Pi(H,b),H.return=N,N=H)}return v(N);case L:e:{for(se=b.key;x!==null;){if(x.key===se)if(x.tag===4&&x.stateNode.containerInfo===b.containerInfo&&x.stateNode.implementation===b.implementation){i(N,x.sibling),H=f(x,b.children||[]),H.return=N,N=H;break e}else{i(N,x);break}else t(N,x);x=x.sibling}H=bs(b,N.mode,H),H.return=N,N=H}return v(N);case Ce:return b=hl(b),Ye(N,x,b,H)}if(me(b))return ee(N,x,b,H);if(Te(b)){if(se=Te(b),typeof se!="function")throw Error(s(150));return b=se.call(b),re(N,x,b,H)}if(typeof b.then=="function")return Ye(N,x,Fo(b),H);if(b.$$typeof===z)return Ye(N,x,Po(N,b),H);Ko(N,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,x!==null&&x.tag===6?(i(N,x.sibling),H=f(x,b),H.return=N,N=H):(i(N,x),H=Rs(b,N.mode,H),H.return=N,N=H),v(N)):i(N,x)}return function(N,x,b,H){try{ki=0;var se=Ye(N,x,b,H);return Kl=null,se}catch(ie){if(ie===Fl||ie===Jo)throw ie;var we=Gt(29,ie,null,N.mode);return we.lanes=H,we.return=N,we}finally{}}}var yl=Kc(!0),Xc=Kc(!1),zn=!1;function ks(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ps(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 Vn(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Bn(e,t,i){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Le&2)!==0){var f=a.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),a.pending=t,t=zo(e),wc(e,null,i),t}return Ho(e,a,t,i),zo(e)}function Yi(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,Vr(e,i)}}function Ys(e,t){var i=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,i===a)){var f=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var v={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};m===null?f=m=v:m=m.next=v,i=i.next}while(i!==null);m===null?f=m=t:m=m.next=t}else f=m=t;i={baseState:a.baseState,firstBaseUpdate:f,lastBaseUpdate:m,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 Js=!1;function Ji(){if(Js){var e=Ol;if(e!==null)throw e}}function Oi(e,t,i,a){Js=!1;var f=e.updateQueue;zn=!1;var m=f.firstBaseUpdate,v=f.lastBaseUpdate,E=f.shared.pending;if(E!==null){f.shared.pending=null;var A=E,D=A.next;A.next=null,v===null?m=D:v.next=D,v=A;var G=e.alternate;G!==null&&(G=G.updateQueue,E=G.lastBaseUpdate,E!==v&&(E===null?G.firstBaseUpdate=D:E.next=D,G.lastBaseUpdate=A))}if(m!==null){var V=f.baseState;v=0,G=D=A=null,E=m;do{var w=E.lane&-536870913,I=w!==E.lane;if(I?(xe&w)===w:(a&w)===w){w!==0&&w===Jl&&(Js=!0),G!==null&&(G=G.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var ee=e,re=E;w=t;var Ye=i;switch(re.tag){case 1:if(ee=re.payload,typeof ee=="function"){V=ee.call(Ye,V,w);break e}V=ee;break e;case 3:ee.flags=ee.flags&-65537|128;case 0:if(ee=re.payload,w=typeof ee=="function"?ee.call(Ye,V,w):ee,w==null)break e;V=S({},V,w);break e;case 2:zn=!0}}w=E.callback,w!==null&&(e.flags|=64,I&&(e.flags|=8192),I=f.callbacks,I===null?f.callbacks=[w]:I.push(w))}else I={lane:w,tag:E.tag,payload:E.payload,callback:E.callback,next:null},G===null?(D=G=I,A=V):G=G.next=I,v|=w;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);G===null&&(A=V),f.baseState=A,f.firstBaseUpdate=D,f.lastBaseUpdate=G,m===null&&(f.shared.lanes=0),On|=v,e.lanes=v,e.memoizedState=V}}function Qc(e,t){if(typeof e!="function")throw Error(s(191,e));e.call(t)}function Zc(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;em?m:8;var v=q.T,E={};q.T=E,ru(e,!1,t,i);try{var A=f(),D=q.S;if(D!==null&&D(E,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var G=zg(A,a);Xi(e,t,G,kt(e))}else Xi(e,t,a,kt(e))}catch(V){Xi(e,t,{then:function(){},status:"rejected",reason:V},kt())}finally{Y.p=m,v!==null&&E.types!==null&&(v.types=E.types),q.T=v}}function Jg(){}function su(e,t,i,a){if(e.tag!==5)throw Error(s(476));var f=bf(e).queue;Rf(e,f,t,ce,i===null?Jg:function(){return Df(e),i(a)})}function bf(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:ce},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Df(e){var t=bf(e);t.next===null&&(t=e.alternate.memoizedState),Xi(e,t.next.queue,{},kt())}function uu(){return Tt(fo)}function wf(){return lt().memoizedState}function Uf(){return lt().memoizedState}function Og(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=kt();e=Vn(i);var a=Bn(t,e,i);a!==null&&(qt(a,t,i),Yi(a,t,i)),t={cache:Hs()},e.payload=t;return}t=t.return}}function Fg(e,t,i){var a=kt();i={lane:a,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},la(e)?qf(t,i):(i=Ms(e,t,i,a),i!==null&&(qt(i,e,a),Lf(i,t,a)))}function If(e,t,i){var a=kt();Xi(e,t,i,a)}function Xi(e,t,i,a){var f={lane:a,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(la(e))qf(t,f);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var v=t.lastRenderedState,E=m(v,i);if(f.hasEagerState=!0,f.eagerState=E,Lt(E,v))return Ho(e,t,f,0),Je===null&&Go(),!1}catch{}finally{}if(i=Ms(e,t,f,a),i!==null)return qt(i,e,a),Lf(i,t,a),!0}return!1}function ru(e,t,i,a){if(a={lane:2,revertLane:ku(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},la(e)){if(t)throw Error(s(479))}else t=Ms(e,i,a,2),t!==null&&qt(t,e,2)}function la(e){var t=e.alternate;return e===ye||t!==null&&t===ye}function qf(e,t){Ql=Zo=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function Lf(e,t,i){if((i&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Vr(e,i)}}var Qi={readContext:Tt,use:jo,useCallback:je,useContext:je,useEffect:je,useImperativeHandle:je,useLayoutEffect:je,useInsertionEffect:je,useMemo:je,useReducer:je,useRef:je,useState:je,useDebugValue:je,useDeferredValue:je,useTransition:je,useSyncExternalStore:je,useId:je,useHostTransitionStatus:je,useFormState:je,useActionState:je,useOptimistic:je,useMemoCache:je,useCacheRefresh:je};Qi.useEffectEvent=je;var Gf={readContext:Tt,use:jo,useCallback:function(e,t){return Mt().memoizedState=[e,t===void 0?null:t],e},useContext:Tt,useEffect:Tf,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,ta(4194308,4,_f.bind(null,t,e),i)},useLayoutEffect:function(e,t){return ta(4194308,4,e,t)},useInsertionEffect:function(e,t){ta(4,2,e,t)},useMemo:function(e,t){var i=Mt();t=t===void 0?null:t;var a=e();if(vl){oe(!0);try{e()}finally{oe(!1)}}return i.memoizedState=[a,t],a},useReducer:function(e,t,i){var a=Mt();if(i!==void 0){var f=i(t);if(vl){oe(!0);try{i(t)}finally{oe(!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=Fg.bind(null,ye,e),[a.memoizedState,e]},useRef:function(e){var t=Mt();return e={current:e},t.memoizedState=e},useState:function(e){e=nu(e);var t=e.queue,i=If.bind(null,ye,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:ou,useDeferredValue:function(e,t){var i=Mt();return au(i,e,t)},useTransition:function(){var e=nu(!1);return e=Rf.bind(null,ye,e.queue,!0,!1),Mt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var a=ye,f=Mt();if(Ne){if(i===void 0)throw Error(s(407));i=i()}else{if(i=t(),Je===null)throw Error(s(349));(xe&127)!==0||nf(a,t,i)}f.memoizedState=i;var m={value:i,getSnapshot:t};return f.queue=m,Tf(of.bind(null,a,m,e),[e]),a.flags|=2048,$l(9,{destroy:void 0},lf.bind(null,a,m,i,t),null),i},useId:function(){var e=Mt(),t=Je.identifierPrefix;if(Ne){var i=rn,a=un;i=(a&~(1<<32-ue(a)-1)).toString(32)+i,t="_"+t+"R_"+i,i=$o++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof a.is=="string"?v.createElement("select",{is:a.is}):v.createElement("select"),a.multiple?m.multiple=!0:a.size&&(m.size=a.size);break;default:m=typeof a.is=="string"?v.createElement(f,{is:a.is}):v.createElement(f)}}m[yt]=t,m[Rt]=a;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)m.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=m;e:switch(Et(m,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&&Cn(t)}}return Ke(t),_u(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Cn(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(s(166));if(e=Ee.current,Pl(t)){if(e=t.stateNode,i=t.memoizedProps,a=null,f=vt,f!==null)switch(f.tag){case 27:case 5:a=f.memoizedProps}e[yt]=t,e=!!(e.nodeValue===i||a!==null&&a.suppressHydrationWarning===!0||tm(e.nodeValue,i)),e||Gn(t,!0)}else e=_a(e).createTextNode(a),e[yt]=t,t.stateNode=e}return Ke(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(a=Pl(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[yt]=t}else fl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ke(t),e=!1}else i=Is(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?(zt(t),t):(zt(t),null);if((t.flags&128)!==0)throw Error(s(558))}return Ke(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Pl(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[yt]=t}else fl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ke(t),f=!1}else f=Is(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?(zt(t),t):(zt(t),null)}return zt(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),m=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(m=a.memoizedState.cachePool.pool),m!==f&&(a.flags|=2048)),i!==e&&i&&(t.child.flags|=8192),ua(t,t.updateQueue),Ke(t),null);case 4:return te(),e===null&&Ou(t.stateNode.containerInfo),Ke(t),null;case 10:return vn(t.type),Ke(t),null;case 19:if(B(nt),a=t.memoizedState,a===null)return Ke(t),null;if(f=(t.flags&128)!==0,m=a.rendering,m===null)if(f)$i(a,!1);else{if(et!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(m=Qo(e),m!==null){for(t.flags|=128,$i(a,!1),e=m.updateQueue,t.updateQueue=e,ua(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)Uc(i,e),i=i.sibling;return K(nt,nt.current&1|2),Ne&&gn(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&xt()>ma&&(t.flags|=128,f=!0,$i(a,!1),t.lanes=4194304)}else{if(!f)if(e=Qo(m),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,ua(t,e),$i(a,!0),a.tail===null&&a.tailMode==="hidden"&&!m.alternate&&!Ne)return Ke(t),null}else 2*xt()-a.renderingStartTime>ma&&i!==536870912&&(t.flags|=128,f=!0,$i(a,!1),t.lanes=4194304);a.isBackwards?(m.sibling=t.child,t.child=m):(e=a.last,e!==null?e.sibling=m:t.child=m,a.last=m)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=xt(),e.sibling=null,i=nt.current,K(nt,f?i&1|2:i&1),Ne&&gn(t,a.treeForkCount),e):(Ke(t),null);case 22:case 23:return zt(t),Fs(),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&&(Ke(t),t.subtreeFlags&6&&(t.flags|=8192)):Ke(t),i=t.updateQueue,i!==null&&ua(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&&B(pl),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),vn(st),Ke(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function $g(e,t){switch(ws(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vn(st),te(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return wn(t),null;case 31:if(t.memoizedState!==null){if(zt(t),t.alternate===null)throw Error(s(340));fl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(zt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));fl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(nt),null;case 4:return te(),null;case 10:return vn(t.type),null;case 22:case 23:return zt(t),Fs(),e!==null&&B(pl),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return vn(st),null;case 25:return null;default:return null}}function ad(e,t){switch(ws(t),t.tag){case 3:vn(st),te();break;case 26:case 27:case 5:wn(t);break;case 4:te();break;case 31:t.memoizedState!==null&&zt(t);break;case 13:zt(t);break;case 19:B(nt);break;case 10:vn(t.type);break;case 22:case 23:zt(t),Fs(),e!==null&&B(pl);break;case 24:vn(st)}}function Wi(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 m=i.create,v=i.inst;a=m(),v.destroy=a}i=i.next}while(i!==f)}}catch(E){Be(t,t.return,E)}}function Yn(e,t,i){try{var a=t.updateQueue,f=a!==null?a.lastEffect:null;if(f!==null){var m=f.next;a=m;do{if((a.tag&e)===e){var v=a.inst,E=v.destroy;if(E!==void 0){v.destroy=void 0,f=t;var A=i,D=E;try{D()}catch(G){Be(f,A,G)}}}a=a.next}while(a!==m)}}catch(G){Be(t,t.return,G)}}function sd(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{Zc(t,i)}catch(a){Be(e,e.return,a)}}}function ud(e,t,i){i.props=Tl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(a){Be(e,t,a)}}function ji(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){Be(e,t,f)}}function cn(e,t){var i=e.ref,a=e.refCleanup;if(i!==null)if(typeof a=="function")try{a()}catch(f){Be(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){Be(e,t,f)}else i.current=null}function rd(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){Be(e,e.return,f)}}function Au(e,t,i){try{var a=e.stateNode;Ty(a,e.type,i,t),a[Rt]=t}catch(f){Be(e,e.return,f)}}function cd(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zn(e.type)||e.tag===4}function xu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||cd(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&&Zn(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 Mu(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=mn));else if(a!==4&&(a===27&&Zn(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(Mu(e,t,i),e=e.sibling;e!==null;)Mu(e,t,i),e=e.sibling}function ra(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&&Zn(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(ra(e,t,i),e=e.sibling;e!==null;)ra(e,t,i),e=e.sibling}function fd(e){var t=e.stateNode,i=e.memoizedProps;try{for(var a=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);Et(t,a,i),t[yt]=e,t[Rt]=i}catch(m){Be(e,e.return,m)}}var _n=!1,ct=!1,Nu=!1,dd=typeof WeakSet=="function"?WeakSet:Set,ht=null;function Wg(e,t){if(e=e.containerInfo,Xu=Da,e=_c(e),Ss(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,m=a.focusNode;a=a.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var v=0,E=-1,A=-1,D=0,G=0,V=e,w=null;t:for(;;){for(var I;V!==i||f!==0&&V.nodeType!==3||(E=v+f),V!==m||a!==0&&V.nodeType!==3||(A=v+a),V.nodeType===3&&(v+=V.nodeValue.length),(I=V.firstChild)!==null;)w=V,V=I;for(;;){if(V===e)break t;if(w===i&&++D===f&&(E=v),w===m&&++G===a&&(A=v),(I=V.nextSibling)!==null)break;V=w,w=V.parentNode}V=I}i=E===-1||A===-1?null:{start:E,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(Qu={focusedElem:e,selectionRange:i},Da=!1,ht=t;ht!==null;)if(t=ht,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ht=e;else for(;ht!==null;){switch(t=ht,m=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"))),Et(m,a,i),m[yt]=e,pt(m),a=m;break e;case"link":var v=vm("link","href",f).get(a+(i.href||""));if(v){for(var E=0;EYe&&(v=Ye,Ye=re,re=v);var N=Ec(E,re),x=Ec(E,Ye);if(N&&x&&(I.rangeCount!==1||I.anchorNode!==N.node||I.anchorOffset!==N.offset||I.focusNode!==x.node||I.focusOffset!==x.offset)){var b=V.createRange();b.setStart(N.node,N.offset),I.removeAllRanges(),re>Ye?(I.addRange(b),I.extend(x.node,x.offset)):(b.setEnd(x.node,x.offset),I.addRange(b))}}}}for(V=[],I=E;I=I.parentNode;)I.nodeType===1&&V.push({element:I,left:I.scrollLeft,top:I.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;Ei?32:i,q.T=null,i=qu,qu=null;var m=Kn,v=Rn;if(ft=0,ni=Kn=null,Rn=0,(Le&6)!==0)throw Error(s(331));var E=Le;if(Le|=4,_d(m.current),Sd(m,m.current,v,i),Le=E,oo(0,!1),Z&&typeof Z.onPostCommitFiberRoot=="function")try{Z.onPostCommitFiberRoot(fe,m)}catch{}return!0}finally{Y.p=f,q.T=a,kd(e,t)}}function Yd(e,t,i){t=Ft(i,t),t=mu(e.stateNode,t,2),e=Bn(e,t,2),e!==null&&(Pt(e,2),fn(e))}function Be(e,t,i){if(e.tag===3)Yd(e,e,i);else for(;t!==null;){if(t.tag===3){Yd(t,e,i);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Fn===null||!Fn.has(a))){e=Ft(i,e),i=Jf(2),a=Bn(t,i,2),a!==null&&(Of(i,a,t,e),Pt(a,2),fn(a));break}}t=t.return}}function zu(e,t,i){var a=e.pingCache;if(a===null){a=e.pingCache=new ty;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)||(Du=!0,f.add(i),e=ay.bind(null,e,t,i),t.then(e,e))}function ay(e,t,i){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Je===e&&(xe&i)===i&&(et===4||et===3&&(xe&62914560)===xe&&300>xt()-da?(Le&2)===0&&li(e,0):wu|=i,ti===xe&&(ti=0)),fn(e)}function Jd(e,t){t===0&&(t=mt()),e=rl(e,t),e!==null&&(Pt(e,t),fn(e))}function sy(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),Jd(e,i)}function uy(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),Jd(e,i)}function ry(e,t){return Ai(e,t)}var Ta=null,oi=null,Vu=!1,Sa=!1,Bu=!1,Qn=0;function fn(e){e!==oi&&e.next===null&&(oi===null?Ta=oi=e:oi=oi.next=e),Sa=!0,Vu||(Vu=!0,fy())}function oo(e,t){if(!Bu&&Sa){Bu=!0;do for(var i=!1,a=Ta;a!==null;){if(e!==0){var f=a.pendingLanes;if(f===0)var m=0;else{var v=a.suspendedLanes,E=a.pingedLanes;m=(1<<31-ue(42|e)+1)-1,m&=f&~(v&~E),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(i=!0,Xd(a,m))}else m=xe,m=Ze(a,a===Je?m:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(m&3)===0||ge(a,m)||(i=!0,Xd(a,m));a=a.next}while(i);Bu=!1}}function cy(){Od()}function Od(){Sa=Vu=!1;var e=0;Qn!==0&&Ey()&&(e=Qn);for(var t=xt(),i=null,a=Ta;a!==null;){var f=a.next,m=Fd(a,t);m===0?(a.next=null,i===null?Ta=f:i.next=f,f===null&&(oi=i)):(i=a,(e!==0||(m&3)!==0)&&(Sa=!0)),a=f}ft!==0&&ft!==5||oo(e),Qn!==0&&(Qn=0)}function Fd(e,t){for(var i=e.suspendedLanes,a=e.pingedLanes,f=e.expirationTimes,m=e.pendingLanes&-62914561;0E)break;var G=A.transferSize,V=A.initiatorType;G&&nm(V)&&(A=A.responseEnd,v+=G*(A"u"?null:document;function pm(e,t,i){var a=ai;if(a&&typeof t=="string"&&t){var f=Jt(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),mm.has(f)||(mm.add(f),e={rel:e,crossOrigin:i,href:t},a.querySelector(f)===null&&(t=a.createElement("link"),Et(t,"link",e),pt(t),a.head.appendChild(t)))}}function Dy(e){bn.D(e),pm("dns-prefetch",e,null)}function wy(e,t){bn.C(e,t),pm("preconnect",e,t)}function Uy(e,t,i){bn.L(e,t,i);var a=ai;if(a&&e&&t){var f='link[rel="preload"][as="'+Jt(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+Jt(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+Jt(i.imageSizes)+'"]')):f+='[href="'+Jt(e)+'"]';var m=f;switch(t){case"style":m=si(e);break;case"script":m=ui(e)}Wt.has(m)||(e=S({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),Wt.set(m,e),a.querySelector(f)!==null||t==="style"&&a.querySelector(ro(m))||t==="script"&&a.querySelector(co(m))||(t=a.createElement("link"),Et(t,"link",e),pt(t),a.head.appendChild(t)))}}function Iy(e,t){bn.m(e,t);var i=ai;if(i&&e){var a=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+Jt(a)+'"][href="'+Jt(e)+'"]',m=f;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=ui(e)}if(!Wt.has(m)&&(e=S({rel:"modulepreload",href:e},t),Wt.set(m,e),i.querySelector(f)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(co(m)))return}a=i.createElement("link"),Et(a,"link",e),pt(a),i.head.appendChild(a)}}}function qy(e,t,i){bn.S(e,t,i);var a=ai;if(a&&e){var f=bl(a).hoistableStyles,m=si(e);t=t||"default";var v=f.get(m);if(!v){var E={loading:0,preload:null};if(v=a.querySelector(ro(m)))E.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},i),(i=Wt.get(m))&&nr(e,i);var A=v=a.createElement("link");pt(A),Et(A,"link",e),A._p=new Promise(function(D,G){A.onload=D,A.onerror=G}),A.addEventListener("load",function(){E.loading|=1}),A.addEventListener("error",function(){E.loading|=2}),E.loading|=4,xa(v,t,a)}v={type:"stylesheet",instance:v,count:1,state:E},f.set(m,v)}}}function Ly(e,t){bn.X(e,t);var i=ai;if(i&&e){var a=bl(i).hoistableScripts,f=ui(e),m=a.get(f);m||(m=i.querySelector(co(f)),m||(e=S({src:e,async:!0},t),(t=Wt.get(f))&&lr(e,t),m=i.createElement("script"),pt(m),Et(m,"link",e),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},a.set(f,m))}}function Gy(e,t){bn.M(e,t);var i=ai;if(i&&e){var a=bl(i).hoistableScripts,f=ui(e),m=a.get(f);m||(m=i.querySelector(co(f)),m||(e=S({src:e,async:!0,type:"module"},t),(t=Wt.get(f))&&lr(e,t),m=i.createElement("script"),pt(m),Et(m,"link",e),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},a.set(f,m))}}function hm(e,t,i,a){var f=(f=Ee.current)?Aa(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=si(i.href),i=bl(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=si(i.href);var m=bl(f).hoistableStyles,v=m.get(e);if(v||(f=f.ownerDocument||f,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(e,v),(m=f.querySelector(ro(e)))&&!m._p&&(v.instance=m,v.state.loading=5),Wt.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},Wt.set(e,i),m||Hy(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=ui(i),i=bl(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 si(e){return'href="'+Jt(e)+'"'}function ro(e){return'link[rel="stylesheet"]['+e+"]"}function gm(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Hy(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}),Et(t,"link",i),pt(t),e.head.appendChild(t))}function ui(e){return'[src="'+Jt(e)+'"]'}function co(e){return"script[async]"+e}function ym(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+Jt(i.href)+'"]');if(a)return t.instance=a,pt(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"),pt(a),Et(a,"style",f),xa(a,i.precedence,e),t.instance=a;case"stylesheet":f=si(i.href);var m=e.querySelector(ro(f));if(m)return t.state.loading|=4,t.instance=m,pt(m),m;a=gm(i),(f=Wt.get(f))&&nr(a,f),m=(e.ownerDocument||e).createElement("link"),pt(m);var v=m;return v._p=new Promise(function(E,A){v.onload=E,v.onerror=A}),Et(m,"link",a),t.state.loading|=4,xa(m,i.precedence,e),t.instance=m;case"script":return m=ui(i.src),(f=e.querySelector(co(m)))?(t.instance=f,pt(f),f):(a=i,(f=Wt.get(m))&&(a=S({},i),lr(a,f)),e=e.ownerDocument||e,f=e.createElement("script"),pt(f),Et(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,xa(a,i.precedence,e));return t.instance}function xa(e,t,i){for(var a=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=a.length?a[a.length-1]:null,m=f,v=0;v title"):null)}function zy(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 Sm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Vy(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=si(a.href),m=t.querySelector(ro(f));if(m){t=m._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Na.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=m,pt(m);return}m=t.ownerDocument||t,a=gm(a),(f=Wt.get(f))&&nr(a,f),m=m.createElement("link"),pt(m);var v=m;v._p=new Promise(function(E,A){v.onload=E,v.onerror=A}),Et(m,"link",a),i.instance=m}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,t),(t=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=Na.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var ir=0;function By(e,t){return e.stylesheets&&e.count===0&&ba(e,e.stylesheets),0ir?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(f)}}:null}function Na(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ba(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Ra=null;function ba(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Ra=new Map,t.forEach(ky,e),Ra=null,Na.call(e))}function ky(e,t){if(!(t.state.loading&4)){var i=Ra.get(e);if(i)var a=i.get(null);else{i=new Map,Ra.set(e,i);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),mr.exports=i0(),mr.exports}var a0=o0();const s0=sh(a0),en=({className:l})=>_.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:[_.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),_.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"})]}),u0=({onSubmit:l,isLoading:n})=>{const[o,s]=X.useState(""),r=d=>{d.preventDefault(),l(o.trim())};return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:_.jsxs("div",{className:"bg-gray-850 p-8 rounded-lg shadow-2xl w-full max-w-md border border-gray-700",children:[_.jsx("h2",{className:"text-2xl font-bold text-center text-gray-100 mb-2",children:"GitHub AI Code Editor"}),_.jsx("p",{className:"text-center text-gray-400 mb-6",children:"Enter your Personal Access Token to begin."}),_.jsxs("form",{onSubmit:r,children:[_.jsxs("div",{className:"mb-4",children:[_.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-gray-300 mb-2",children:"GitHub Token"}),_.jsx("input",{id:"token",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})]}),_.jsxs("div",{className:"text-xs text-gray-500 mb-6 space-y-2",children:[_.jsx("p",{children:"Your token is used only for API requests and is not stored."}),_.jsxs("p",{children:["A ",_.jsx("strong",{className:"text-gray-400",children:"classic"})," token with the full ",_.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:"repo"})," scope is required. Fine-grained tokens are not supported."]}),_.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 new classic token here."})]}),_.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?_.jsx(en,{}):"Load Repositories"})]})]})})},uh=l=>_.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:_.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"})}),rh=l=>_.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:_.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"})}),r0=l=>_.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:_.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"})}),c0=l=>_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),f0=l=>_.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",...l,children:[_.jsx("path",{fill:"#4CAF50",d:"M333.321 333.342l74.679-129.321h-149.33l-74.679 129.321z"}),_.jsx("path",{fill:"#FFC107",d:"M129.321 204.021l-74.679 129.321h298.679l74.679-129.321z"}),_.jsx("path",{fill:"#2196F3",d:"M178.679 49.321l-129.33 223.98h149.33l129.33-223.98z"})]}),ch=l=>_.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:_.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"})}),fh=({node:l,repoFullName:n,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedPaths:d,onTogglePath:p})=>{const[g,y]=X.useState(!1),h=l.type==="dir",T=`${n}::${l.path}`,S=U=>{U.stopPropagation(),p(T,h,h?l.children:[])},C=X.useMemo(()=>{if(!h)return d.has(T);const U=_l(l.children).map(k=>`${n}::${k}`);return U.length===0?!1:U.every(k=>d.has(k))},[h,l,d,n]),R=X.useMemo(()=>{if(!h)return!1;const U=_l(l.children).map(P=>`${n}::${P}`);if(U.length===0)return!1;const k=U.filter(P=>d.has(P)).length;return k>0&&kU&&(U.indeterminate=R),onChange:S,onClick:U=>U.stopPropagation()}),_.jsxs("div",{onClick:()=>y(!g),className:"flex items-center flex-grow",children:[g?_.jsx(rh,{className:"w-5 h-5 mr-2 text-indigo-400"}):_.jsx(uh,{className:"w-5 h-5 mr-2 text-indigo-400"}),_.jsx("span",{children:l.name})]})]}),g&&_.jsx("div",{className:"pl-6 border-l border-gray-700 ml-4",children:l.children.map(U=>_.jsx(fh,{node:U,repoFullName:n,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedPaths:d,onTogglePath:p},U.path))})]});const L=r===n&&s===l.path;return _.jsxs("div",{className:"flex items-center p-1.5 group rounded-md",children:[_.jsx("input",{type:"checkbox",className:"form-checkbox h-4 w-4 text-indigo-600 bg-gray-800 border-gray-600 rounded focus:ring-indigo-500 mr-3",checked:C,onChange:S}),_.jsxs("div",{onClick:()=>o(n,l.path),className:`flex items-center rounded-md cursor-pointer flex-grow ${L?"bg-indigo-900 bg-opacity-50":"hover:bg-gray-700"}`,children:[_.jsx(r0,{className:"w-5 h-5 mr-2 text-gray-400"}),_.jsx("span",{className:L?"text-white":"text-gray-300",children:l.name})]})]})},d0=l=>{const{repo:n,tree:o,onFileClick:s,selectedFilePath:r,selectedRepo:d,selectedPaths:p,onToggleRepo:g}=l,y=n.full_name===d,[h,T]=X.useState(y),S=X.useMemo(()=>_l(o).map(U=>`${n.full_name}::${U}`),[o,n.full_name]),C=X.useMemo(()=>S.length===0?!1:S.every(U=>p.has(U)),[S,p]),R=X.useMemo(()=>{if(S.length===0)return!1;const U=S.filter(k=>p.has(k)).length;return U>0&&U{y&&!h&&T(!0)},[y,h]);const L=(U,k,P)=>{const F=new Set(p),z=k?_l(P).map(W=>`${n.full_name}::${W}`):[U];z.every(W=>F.has(W))?z.forEach(W=>F.delete(W)):z.forEach(W=>F.add(W)),l.onSelectionChange(F)};return _.jsxs("div",{className:"mb-2",children:[_.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-700 rounded-md group",children:[_.jsx("input",{type:"checkbox",className:"form-checkbox h-4 w-4 text-indigo-600 bg-gray-800 border-gray-600 rounded focus:ring-indigo-500 mr-3",checked:C,ref:U=>U&&(U.indeterminate=R),onChange:()=>g(n.full_name,o)}),_.jsxs("h3",{className:"text-lg font-semibold cursor-pointer flex items-center flex-grow",onClick:()=>T(!h),children:[h?_.jsx(rh,{className:"w-5 h-5 mr-2"}):_.jsx(uh,{className:"w-5 h-5 mr-2"}),n.full_name]})]}),h&&_.jsx("div",{className:"pl-4 border-l border-gray-700 ml-2",children:o.map(U=>_.jsx(fh,{node:U,repoFullName:n.full_name,onFileClick:s,selectedFilePath:r,selectedRepo:d,selectedPaths:p,onTogglePath:L},U.path))})]})},m0=({fileTree:l,onFileSelect:n,onStartNewProject:o,onImportFromDrive:s,selectedFilePath:r,selectedRepo:d,selectedPaths:p,onSelectionChange:g,onStartBulkEdit:y})=>{const h=(C,R)=>{const L=new Set(p),U=_l(R).map(P=>`${C}::${P}`);U.every(P=>L.has(P))?U.forEach(P=>L.delete(P)):U.forEach(P=>L.add(P)),g(L)},T=()=>{const C=new Set;Object.keys(l).forEach(R=>{const{tree:L}=l[R];_l(L).forEach(U=>C.add(`${R}::${U}`))}),g(C)},S=()=>{g(new Set)};return _.jsxs("div",{className:"p-4 text-gray-300 h-full flex flex-col",children:[_.jsxs("div",{className:"flex-shrink-0",children:[_.jsxs("div",{className:"flex justify-between items-center mb-2",children:[_.jsx("h2",{className:"text-xl font-bold",children:"Repositories"}),_.jsx("div",{className:"flex items-center gap-2",children:_.jsx("button",{onClick:p.size>0?S:T,className:"text-sm text-indigo-400 hover:underline px-2 py-1",children:p.size>0?"Deselect All":"Select All"})})]}),_.jsxs("div",{className:"flex items-center gap-2 mb-4 border-b border-gray-700 pb-2",children:[_.jsxs("button",{onClick:s,className:"flex flex-grow items-center justify-center gap-2 text-sm bg-blue-600 text-white font-semibold py-1 px-3 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-blue-500 transition-colors",title:"Import file from Google Drive",children:[_.jsx(f0,{className:"w-4 h-4"}),"Import"]}),_.jsxs("button",{onClick:o,className:"flex flex-grow items-center justify-center gap-2 text-sm bg-indigo-600 text-white font-semibold py-1 px-3 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-indigo-500 transition-colors",title:"Generate a new project with AI",children:[_.jsx(c0,{className:"w-4 h-4"}),"Project"]})]}),p.size>0&&_.jsx("div",{className:"mb-4",children:_.jsxs("button",{onClick:y,className:"w-full flex items-center justify-center gap-2 text-sm bg-amber-600 text-white font-semibold py-2 px-3 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:[_.jsx(ch,{className:"w-4 h-4"}),"AI Edit Selected (",p.size,")"]})})]}),_.jsx("div",{className:"flex-grow overflow-y-auto",children:Object.keys(l).sort().map(C=>_.jsx(d0,{repo:l[C].repo,tree:l[C].tree,onFileClick:n,selectedFilePath:r,selectedRepo:d,selectedPaths:p,onToggleRepo:h},C))})]})},p0=({onClose:l,onCommit:n,isLoading:o,defaultMessage:s})=>{const[r,d]=X.useState(s);X.useEffect(()=>{d(s)},[s]);const p=async g=>{g.preventDefault(),!(!r.trim()||o)&&await n(r)};return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:_.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:[_.jsx("h2",{className:"text-xl font-bold text-green-400 mb-4",children:"Commit Changes"}),_.jsxs("form",{onSubmit:p,children:[_.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Enter a commit message:"}),_.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}),_.jsxs("div",{className:"flex justify-end gap-4",children:[_.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"}),_.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?_.jsx(en,{}):"Commit"})]})]})]})})},h0=({file:l,isActive:n,onSelect:o,onClose:s})=>{const r=l.content!==l.editedContent,d=l.repoFullName+"::"+l.path,p=l.path.split("/").pop();return _.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:[_.jsx("span",{className:"text-sm font-medium pr-2",children:p}),_.jsxs("div",{className:"flex items-center",children:[r&&_.jsx("div",{className:"w-2 h-2 bg-yellow-400 rounded-full mr-2"}),_.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:"×"})]})]})},g0=({openFiles:l,activeFile:n,onCommit:o,onAiEdit:s,onFileContentChange:r,onCloseFile:d,onSetActiveFile:p,isLoading:g,branches:y,currentBranch:h,onBranchChange:T,onCreateBranch:S,onCreatePullRequest:C})=>{const[R,L]=X.useState(!1),[U,k]=X.useState(""),[P,F]=X.useState(!1),[z,$]=X.useState(!1),[W,ae]=X.useState(""),[O,Ce]=X.useState("");X.useEffect(()=>{if(n){const me=`Update ${n.path}`;ae(me)}},[n]);const le=n?n.editedContent!==n.content:!1,ve=async me=>{!me.trim()||!n||(await o(me),L(!1))},be=async()=>{U.trim()&&(await S(U),k(""),F(!1))},Te=async()=>{W.trim()&&(await C(W,O),$(!1),Ce(""))};if(!n)return _.jsx("div",{className:"flex-grow flex items-center justify-center bg-gray-850 text-gray-500",children:_.jsx("p",{children:"Select a file from the explorer to begin editing."})});const Oe=n.repoFullName+"::"+n.path,Ct=`Update ${n.path}`;return _.jsxs("div",{className:"flex flex-col h-full bg-gray-850 relative",children:[_.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-700 bg-gray-900 flex-wrap gap-2",children:[_.jsxs("div",{children:[_.jsx("h3",{className:"text-md font-semibold text-gray-200",children:n.path}),_.jsx("p",{className:"text-xs text-gray-400",children:n.repoFullName})]}),_.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("select",{id:"branch-select",value:h||"",onChange:me=>T(me.target.value),disabled:g,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:y.map(me=>_.jsx("option",{value:me.name,children:me.name},me.name))}),P?_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("input",{type:"text",value:U,onChange:me=>k(me.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"}),_.jsx("button",{onClick:be,disabled:g||!U.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"}),_.jsx("button",{onClick:()=>F(!1),className:"text-sm bg-gray-600 text-white font-semibold py-1 px-2 rounded hover:bg-gray-700",children:"X"})]}):_.jsx("button",{onClick:()=>F(!0),className:"text-sm text-cyan-400 hover:underline px-3 py-1.5",disabled:g,children:"New Branch"})]}),_.jsx("button",{onClick:()=>L(!0),disabled:g||!le,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"}),h&&h!==n.defaultBranch&&_.jsx("button",{onClick:()=>$(!z),className:"bg-cyan-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-cyan-700 disabled:bg-gray-500",disabled:g,children:z?"Cancel PR":"Create Pull Request"})]})]}),z&&_.jsxs("div",{className:"p-4 bg-gray-800 border-b border-gray-700",children:[_.jsx("h4",{className:"font-semibold mb-2 text-gray-200",children:"New Pull Request"}),_.jsxs("p",{className:"text-xs text-gray-400 mb-2",children:["From ",_.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:h})," into ",_.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:n.defaultBranch})]}),_.jsx("input",{type:"text",value:W,onChange:me=>ae(me.target.value),placeholder:"Pull request 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"}),_.jsx("textarea",{value:O,onChange:me=>Ce(me.target.value),placeholder:"Describe your 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"}),_.jsx("div",{className:"flex gap-2",children:_.jsx("button",{onClick:Te,disabled:g||!W.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:g?_.jsx(en,{className:"h-4 w-4"}):"Submit Pull Request"})})]}),_.jsx("div",{className:"flex border-b border-gray-700 bg-gray-900 overflow-x-auto",children:l.map(me=>_.jsx(h0,{file:me,isActive:me.repoFullName+"::"+me.path===Oe,onSelect:p,onClose:d},me.repoFullName+"::"+me.path))}),_.jsx("div",{className:"flex-grow p-4 overflow-y-auto",children:_.jsx("textarea",{value:n.editedContent,onChange:me=>r(Oe,me.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"},Oe)}),_.jsx("button",{onClick:s,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","aria-label":"Edit with AI",children:_.jsx(ch,{className:"h-6 w-6"})}),R&&_.jsx(p0,{onClose:()=>L(!1),onCommit:ve,isLoading:g,defaultMessage:Ct})]})},y0="https://api.github.com";async function nl(l,n,o={}){const s=await fetch(`${y0}${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 v0(l){let n=[],o=1;const s=100;for(;;){const r=await nl(`/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((p,g)=>{const y=g===r.length-1,h=r.slice(0,g+1).join("/");y?d[p]||(d[p]={type:"file",path:s.path,name:p}):(d[p]||(d[p]={type:"dir",path:h,name:p,children:{}}),d=d[p].children)})});const o=s=>{const r=Object.values(s).map(d=>{if(d.type==="dir"){const p=o(d.children);return{...d,children:p}}return d});return r.sort((d,p)=>d.type!==p.type?d.type==="dir"?-1:1:d.name.localeCompare(p.name)),r};return o(n.children)};async function Ha(l,n,o,s){const{tree:r}=await nl(`/repos/${n}/${o}/git/trees/${s}?recursive=1`,l);return T0(r)}async function ci(l,n,o,s,r){const d=r?`/repos/${n}/${o}/contents/${s}?ref=${r}`:`/repos/${n}/${o}/contents/${s}`,p=await nl(d,l);return{...p,content:atob(p.content)}}async function yr(l,n,o){return nl(`/repos/${n}/${o}/branches?per_page=100`,l)}async function S0(l,n,o,s,r){const d={ref:`refs/heads/${s}`,sha:r};return nl(`/repos/${n}/${o}/git/refs`,l,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"}})}async function E0({token:l,name:n,description:o,isPrivate:s}){return nl("/user/repos",l,{method:"POST",body:JSON.stringify({name:n,description:o,private:s,auto_init:!0}),headers:{"Content-Type":"application/json"}})}function C0(l){return btoa(unescape(encodeURIComponent(l)))}async function fi({token:l,owner:n,repo:o,branch:s,path:r,content:d,message:p,sha:g}){const y={message:p,content:C0(d),...g&&{sha:g},branch:s};return(await nl(`/repos/${n}/${o}/contents/${r}`,l,{method:"PUT",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})).content.sha}async function _0({token:l,owner:n,repo:o,title:s,body:r,head:d,base:p}){const g={title:s,body:r,head:d,base:p};return nl(`/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 A0,x0;function M0(){return{geminiUrl:A0,vertexUrl:x0}}function N0(l,n,o,s){var r,d;if(!(l!=null&&l.baseUrl)){const p=M0();return n?(r=p.vertexUrl)!==null&&r!==void 0?r:o:(d=p.geminiUrl)!==null&&d!==void 0?d:s}return l.baseUrl}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Al{}function ne(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 ${p}`);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 R0(l,n){for(const[o,s]of Object.entries(n)){const r=o.split("."),d=s.split("."),p=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 p=d.slice(0,-2),g=l;if(p in g&&Array.isArray(g[p]))for(const y of g[p])Sr(y,n,o,s+1,r)}else if(d==="*"){if(typeof l=="object"&&l!==null&&!Array.isArray(l)){const p=l,g=Object.keys(p).filter(h=>!h.startsWith("_")&&!r.has(h)),y={};for(const h of g)y[h]=p[h];for(const[h,T]of Object.entries(y)){const S=[];for(const C of o.slice(s))C==="*"?S.push(h):S.push(C);c(p,S,T)}for(const h of g)delete p[h]}}else{const p=l;d in p&&Sr(p[d],n,o,s+1,r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Ur(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 b0(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 D0(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 p=u(l,["response","generateVideoResponse"]);return p!=null&&c(n,["response"],U0(p)),n}function w0(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 p=u(l,["response"]);return p!=null&&c(n,["response"],I0(p)),n}function U0(l){const n={},o=u(l,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>q0(p))),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 I0(l){const n={},o=u(l,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>L0(p))),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 q0(l){const n={},o=u(l,["video"]);return o!=null&&c(n,["video"],z0(o)),n}function L0(l){const n={},o=u(l,["_self"]);return o!=null&&c(n,["video"],V0(o)),n}function G0(l){const n={},o=u(l,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function H0(l){const n={},o=u(l,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function z0(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["encodedVideo"]);s!=null&&c(n,["videoBytes"],Ur(s));const r=u(l,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function V0(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["uri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["videoBytes"],Ur(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 Jm;(function(l){l.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",l.OUTCOME_OK="OUTCOME_OK",l.OUTCOME_FAILED="OUTCOME_FAILED",l.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(Jm||(Jm={}));var Om;(function(l){l.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",l.PYTHON="PYTHON"})(Om||(Om={}));var it;(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"})(it||(it={}));var Fm;(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"})(Fm||(Fm={}));var Km;(function(l){l.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",l.SEVERITY="SEVERITY",l.PROBABILITY="PROBABILITY"})(Km||(Km={}));var Xm;(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"})(Xm||(Xm={}));var Qm;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.MODE_DYNAMIC="MODE_DYNAMIC"})(Qm||(Qm={}));var Zm;(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"})(Zm||(Zm={}));var $m;(function(l){l.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",l.SIMPLE_SEARCH="SIMPLE_SEARCH",l.ELASTIC_SEARCH="ELASTIC_SEARCH"})($m||($m={}));var Wm;(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"})(Wm||(Wm={}));var jm;(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"})(jm||(jm={}));var ep;(function(l){l.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",l.NEGLIGIBLE="NEGLIGIBLE",l.LOW="LOW",l.MEDIUM="MEDIUM",l.HIGH="HIGH"})(ep||(ep={}));var tp;(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"})(tp||(tp={}));var np;(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"})(np||(np={}));var lp;(function(l){l.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",l.ON_DEMAND="ON_DEMAND",l.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(lp||(lp={}));var Pa;(function(l){l.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",l.TEXT="TEXT",l.IMAGE="IMAGE",l.AUDIO="AUDIO"})(Pa||(Pa={}));var ip;(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"})(ip||(ip={}));var Er;(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"})(Er||(Er={}));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 ap;(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"})(ap||(ap={}));var sp;(function(l){l.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",l.TUNING_TASK_I2V="TUNING_TASK_I2V",l.TUNING_TASK_T2V="TUNING_TASK_T2V"})(sp||(sp={}));var up;(function(l){l.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",l.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",l.BALANCED="BALANCED",l.PRIORITIZE_COST="PRIORITIZE_COST"})(up||(up={}));var rp;(function(l){l.UNSPECIFIED="UNSPECIFIED",l.BLOCKING="BLOCKING",l.NON_BLOCKING="NON_BLOCKING"})(rp||(rp={}));var cp;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.MODE_DYNAMIC="MODE_DYNAMIC"})(cp||(cp={}));var fp;(function(l){l.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",l.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(fp||(fp={}));var dp;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.AUTO="AUTO",l.ANY="ANY",l.NONE="NONE",l.VALIDATED="VALIDATED"})(dp||(dp={}));var mp;(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"})(mp||(mp={}));var pp;(function(l){l.DONT_ALLOW="DONT_ALLOW",l.ALLOW_ADULT="ALLOW_ADULT",l.ALLOW_ALL="ALLOW_ALL"})(pp||(pp={}));var hp;(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"})(hp||(hp={}));var gp;(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"})(gp||(gp={}));var yp;(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"})(yp||(yp={}));var vp;(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"})(vp||(vp={}));var Tp;(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"})(Tp||(Tp={}));var Sp;(function(l){l.FOREGROUND="FOREGROUND",l.BACKGROUND="BACKGROUND",l.PROMPT="PROMPT",l.SEMANTIC="SEMANTIC",l.INTERACTIVE="INTERACTIVE"})(Sp||(Sp={}));var Ep;(function(l){l.ASSET="ASSET",l.STYLE="STYLE"})(Ep||(Ep={}));var Cp;(function(l){l.INSERT="INSERT",l.REMOVE="REMOVE",l.REMOVE_STATIC="REMOVE_STATIC",l.OUTPAINT="OUTPAINT"})(Cp||(Cp={}));var _p;(function(l){l.OPTIMIZED="OPTIMIZED",l.LOSSLESS="LOSSLESS"})(_p||(_p={}));var Ap;(function(l){l.STATE_UNSPECIFIED="STATE_UNSPECIFIED",l.PROCESSING="PROCESSING",l.ACTIVE="ACTIVE",l.FAILED="FAILED"})(Ap||(Ap={}));var xp;(function(l){l.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",l.UPLOADED="UPLOADED",l.GENERATED="GENERATED"})(xp||(xp={}));var Mp;(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"})(Mp||(Mp={}));var Np;(function(l){l.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",l.TEXT="TEXT",l.IMAGE="IMAGE",l.VIDEO="VIDEO",l.AUDIO="AUDIO",l.DOCUMENT="DOCUMENT"})(Np||(Np={}));var Rp;(function(l){l.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",l.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",l.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Rp||(Rp={}));var bp;(function(l){l.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",l.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",l.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(bp||(bp={}));var Dp;(function(l){l.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",l.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",l.NO_INTERRUPTION="NO_INTERRUPTION"})(Dp||(Dp={}));var wp;(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"})(wp||(wp={}));var Up;(function(l){l.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",l.SILENT="SILENT",l.WHEN_IDLE="WHEN_IDLE",l.INTERRUPT="INTERRUPT"})(Up||(Up={}));var Ip;(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"})(Ip||(Ip={}));var qp;(function(l){l.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",l.QUALITY="QUALITY",l.DIVERSITY="DIVERSITY",l.VOCALIZATION="VOCALIZATION"})(qp||(qp={}));var di;(function(l){l.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",l.PLAY="PLAY",l.PAUSE="PAUSE",l.STOP="STOP",l.RESET_CONTEXT="RESET_CONTEXT"})(di||(di={}));class Cr{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 vo{get text(){var n,o,s,r,d,p,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 C of(y=(g=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[R,L]of Object.entries(C))R!=="text"&&R!=="thought"&&(L!==null||L!==void 0)&&S.push(R);if(typeof C.text=="string"){if(typeof C.thought=="boolean"&&C.thought)continue;T=!0,h+=C.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,p,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=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[C,R]of Object.entries(S))C!=="inlineData"&&(R!==null||R!==void 0)&&T.push(C);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,p,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=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.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,p,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=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.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,p,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=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.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 Lp{}class Gp{}class B0{}class k0{}class P0{}class Y0{}class Hp{}class zp{}class Vp{}class J0{}class Ya{_fromAPIResponse({apiResponse:n,isVertexAI:o}){const s=new Ya;let r;const d=n;return o?r=w0(d):r=D0(d),Object.assign(s,r),s}}class Bp{}class kp{}class Pp{}class O0{}class F0{}class K0{}class Yp{}class X0{get text(){var n,o,s;let r="",d=!1;const p=[];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&&p.push(y);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;d=!0,r+=g.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),d?r:void 0}get data(){var n,o,s;let r="";const d=[];for(const p 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(p))g!=="inlineData"&&y!==null&&d.push(g);p.inlineData&&typeof p.inlineData.data=="string"&&(r+=atob(p.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 Q0{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 Ie(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 dh(l,n){const o=Ie(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 mh(l){return Array.isArray(l)?l.map(n=>Ja(n)):[Ja(l)]}function Ja(l){if(typeof l=="object"&&l!==null)return l;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof l}`)}function ph(l){const n=Ja(l);if(n.mimeType&&n.mimeType.startsWith("image/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function hh(l){const n=Ja(l);if(n.mimeType&&n.mimeType.startsWith("audio/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function Jp(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 gh(l){if(l==null||Array.isArray(l)&&l.length===0)throw new Error("PartListUnion is required");return Array.isArray(l)?l.map(n=>Jp(n)):[Jp(l)]}function _r(l){return l!=null&&typeof l=="object"&&"parts"in l&&Array.isArray(l.parts)}function Op(l){return l!=null&&typeof l=="object"&&"functionCall"in l}function Fp(l){return l!=null&&typeof l=="object"&&"functionResponse"in l}function At(l){if(l==null)throw new Error("ContentUnion is required");return _r(l)?l:{role:"user",parts:gh(l)}}function Ir(l,n){if(!n)return[];if(l.isVertexAI()&&Array.isArray(n))return n.flatMap(o=>{const s=At(o);return s.parts&&s.parts.length>0&&s.parts[0].text!==void 0?[s.parts[0].text]:[]});if(l.isVertexAI()){const o=At(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=>At(o)):[At(n)]}function jt(l){if(l==null||Array.isArray(l)&&l.length===0)throw new Error("contents are required");if(!Array.isArray(l)){if(Op(l)||Fp(l))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[At(l)]}const n=[],o=[],s=_r(l[0]);for(const r of l){const d=_r(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(Op(r)||Fp(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:gh(o)}),n}function Z0(l,n){l.includes("null")&&(n.nullable=!0);const o=l.filter(s=>s!=="null");if(o.length===1)n.type=Object.values(it).includes(o[0].toUpperCase())?o[0].toUpperCase():it.TYPE_UNSPECIFIED;else{n.anyOf=[];for(const s of o)n.anyOf.push({type:Object.values(it).includes(s.toUpperCase())?s.toUpperCase():it.TYPE_UNSPECIFIED})}}function mi(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&&Z0(l.type,n);for(const[p,g]of Object.entries(l))if(g!=null)if(p=="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(it).includes(g.toUpperCase())?g.toUpperCase():it.TYPE_UNSPECIFIED}else if(o.includes(p))n[p]=mi(g);else if(s.includes(p)){const y=[];for(const h of g){if(h.type=="null"){n.nullable=!0;continue}y.push(mi(h))}n[p]=y}else if(r.includes(p)){const y={};for(const[h,T]of Object.entries(g))y[h]=mi(T);n[p]=y}else{if(p==="additionalProperties")continue;n[p]=g}return n}function qr(l){return mi(l)}function Lr(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 yi(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=mi(n.parameters)),n.response&&(Object.keys(n.response).includes("$schema")?n.responseJsonSchema||(n.responseJsonSchema=n.response,delete n.response):n.response=mi(n.response));return l}function vi(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 $0(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 Dn(l,n){if(typeof n!="string")throw new Error("name must be a string");return $0(l,n,"cachedContents")}function yh(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 ll(l){return Ur(l)}function W0(l){return l!=null&&typeof l=="object"&&"name"in l}function j0(l){return l!=null&&typeof l=="object"&&"video"in l}function ev(l){return l!=null&&typeof l=="object"&&"uri"in l}function vh(l){var n;let o;if(W0(l)&&(o=l.name),!(ev(l)&&(o=l.uri,o===void 0))&&!(j0(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 Th(l,n){let o;return l.isVertexAI()?o=n?"publishers/google/models":"models":o=n?"models":"tunedModels",o}function Sh(l){for(const n of["models","tunedModels","publisherModels"])if(tv(l,n))return l[n];return[]}function tv(l,n){return l!==null&&typeof l=="object"&&n in l}function nv(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 lv(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 p=nv(r,n);p.functionDeclarations&&o.push(...p.functionDeclarations)}return{functionDeclarations:o}}function Eh(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 iv(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 Ch(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 p of r){if(typeof p!="object"||p===null)continue;const y=p.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 Ti(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 _h(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 ov(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(p=>Gv(p))),c(n,["inlinedResponses"],d)}const r=u(l,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>p)),c(n,["inlinedEmbedContentResponses"],d)}return n}function av(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 sv(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 Va(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"],_h(r));const d=u(l,["metadata","createTime"]);d!=null&&c(n,["createTime"],d);const p=u(l,["metadata","endTime"]);p!=null&&c(n,["endTime"],p);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"],ov(Ch(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"],_h(r));const d=u(l,["error"]);d!=null&&c(n,["error"],d);const p=u(l,["createTime"]);p!=null&&c(n,["createTime"],p);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"],uv(S));const C=u(l,["outputConfig"]);return C!=null&&c(n,["dest"],av(Ch(C))),n}function uv(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 rv(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(p=>Lv(l,p))),c(o,["requests","requests"],d)}return o}function cv(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 fv(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 dv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Ti(l,s)),o}function mv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Ti(l,s)),o}function pv(l){const n={},o=u(l,["content"]);o!=null&&c(n,["content"],o);const s=u(l,["citationMetadata"]);s!=null&&c(n,["citationMetadata"],hv(s));const r=u(l,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(l,["finishReason"]);d!=null&&c(n,["finishReason"],d);const p=u(l,["urlContextMetadata"]);p!=null&&c(n,["urlContextMetadata"],p);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 C=S;Array.isArray(C)&&(C=C.map(R=>R)),c(n,["safetyRatings"],C)}return n}function hv(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 Ah(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>Yv(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function gv(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 yv(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"],sv(iv(r))),o}function Kp(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],rv(l,Eh(l,r)));const d=u(n,["config"]);return d!=null&&gv(d,o),o}function vv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],Ie(l,s));const r=u(n,["src"]);r!=null&&c(o,["inputConfig"],cv(Eh(l,r)));const d=u(n,["config"]);return d!=null&&yv(d,o),o}function Tv(l,n){const o={},s=u(l,["displayName"]);return n!==void 0&&s!=null&&c(n,["batch","displayName"],s),o}function Sv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],Nv(l,r));const d=u(n,["config"]);return d!=null&&Tv(d,o),o}function Ev(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Ti(l,s)),o}function Cv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Ti(l,s)),o}function _v(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 Av(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 xv(l,n){const o={},s=u(n,["contents"]);if(s!=null){let d=Ir(l,s);Array.isArray(d)&&(d=d.map(p=>p)),c(o,["requests[]","request","content"],d)}const r=u(n,["config"]);return r!=null&&(c(o,["_self"],Mv(r,o)),R0(o,{"requests[].*":"requests[].request.*"})),o}function Mv(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 Nv(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"],xv(l,r)),o}function Rv(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 bv(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],Ah(At(r)));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const p=u(n,["topP"]);p!=null&&c(s,["topP"],p);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 C=u(n,["logprobs"]);C!=null&&c(s,["logprobs"],C);const R=u(n,["presencePenalty"]);R!=null&&c(s,["presencePenalty"],R);const L=u(n,["frequencyPenalty"]);L!=null&&c(s,["frequencyPenalty"],L);const U=u(n,["seed"]);U!=null&&c(s,["seed"],U);const k=u(n,["responseMimeType"]);k!=null&&c(s,["responseMimeType"],k);const P=u(n,["responseSchema"]);P!=null&&c(s,["responseSchema"],qr(P));const F=u(n,["responseJsonSchema"]);if(F!=null&&c(s,["responseJsonSchema"],F),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 z=u(n,["safetySettings"]);if(o!==void 0&&z!=null){let Te=z;Array.isArray(Te)&&(Te=Te.map(Oe=>Jv(Oe))),c(o,["safetySettings"],Te)}const $=u(n,["tools"]);if(o!==void 0&&$!=null){let Te=vi($);Array.isArray(Te)&&(Te=Te.map(Oe=>Ov(yi(Oe)))),c(o,["tools"],Te)}const W=u(n,["toolConfig"]);if(o!==void 0&&W!=null&&c(o,["toolConfig"],W),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const ae=u(n,["cachedContent"]);o!==void 0&&ae!=null&&c(o,["cachedContent"],Dn(l,ae));const O=u(n,["responseModalities"]);O!=null&&c(s,["responseModalities"],O);const Ce=u(n,["mediaResolution"]);Ce!=null&&c(s,["mediaResolution"],Ce);const le=u(n,["speechConfig"]);if(le!=null&&c(s,["speechConfig"],Lr(le)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const ve=u(n,["thinkingConfig"]);ve!=null&&c(s,["thinkingConfig"],ve);const be=u(n,["imageConfig"]);return be!=null&&c(s,["imageConfig"],be),s}function Dv(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=>pv(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 p=u(l,["responseId"]);p!=null&&c(n,["responseId"],p);const g=u(l,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function wv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Ti(l,s)),o}function Uv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Ti(l,s)),o}function Iv(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 qv(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 Lv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["request","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let g=jt(r);Array.isArray(g)&&(g=g.map(y=>Ah(y))),c(o,["request","contents"],g)}const d=u(n,["metadata"]);d!=null&&c(o,["metadata"],d);const p=u(n,["config"]);return p!=null&&c(o,["request","generationConfig"],bv(l,p,u(o,["request"],{}))),o}function Gv(l){const n={},o=u(l,["response"]);o!=null&&c(n,["response"],Dv(o));const s=u(l,["error"]);return s!=null&&c(n,["error"],s),n}function Hv(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 zv(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 Vv(l){const n={},o=u(l,["config"]);return o!=null&&Hv(o,n),n}function Bv(l){const n={},o=u(l,["config"]);return o!=null&&zv(o,n),n}function kv(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(p=>Va(p))),c(n,["batchJobs"],d)}return n}function Pv(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(p=>Ar(p))),c(n,["batchJobs"],d)}return n}function Yv(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"],fv(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],Rv(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);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 Jv(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 Ov(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"],qv(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"],Iv(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);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 Cl;(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"})(Cl||(Cl={}));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 p={config:{}};!s||Object.keys(s).length===0?p={config:{}}:typeof s=="object"?p=Object.assign({},s):p=s,p.config&&(p.config.pageToken=o.nextPageToken),this.paramsInternal=p,this.pageInternalSize=(d=(r=p.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 Fv extends Al{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(Cl.PAGED_ITEM_BATCH_JOBS,s=>this.listInternal(s),await this.listInternal(o),o)}createInlinedGenerateContentRequest(n){const o=Kp(this.apiClient,n),s=o._url,r=ne("{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 C=S.systemInstruction;delete S.systemInstruction;const R=S.request;R.systemInstruction=C,S.request=R}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),p=this.getBigqueryUri(n);if(d)d.endsWith(".jsonl")?s.dest=`${d.slice(0,-6)}/dest`:s.dest=`${d}_dest_${r}`;else if(p)s.dest=`${p}_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 p,g="",y={};if(this.apiClient.isVertexAI()){const h=vv(this.apiClient,n);return g=ne("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>Ar(T))}else{const h=Kp(this.apiClient,n);return g=ne("{model}:batchGenerateContent",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>Va(T))}}async createEmbeddingsInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=Sv(this.apiClient,n);return d=ne("{model}:asyncBatchEmbedContent",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=>Va(y))}}async get(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Uv(this.apiClient,n);return g=ne("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>Ar(T))}else{const h=wv(this.apiClient,n);return g=ne("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>Va(T))}}async cancel(n){var o,s,r,d;let p="",g={};if(this.apiClient.isVertexAI()){const y=mv(this.apiClient,n);p=ne("batchPredictionJobs/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,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=dv(this.apiClient,n);p=ne("batches/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,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 p,g="",y={};if(this.apiClient.isVertexAI()){const h=Bv(n);return g=ne("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=Pv(T),C=new Yp;return Object.assign(C,S),C})}else{const h=Vv(n);return g=ne("batches",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=kv(T),C=new Yp;return Object.assign(C,S),C})}}async delete(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Cv(this.apiClient,n);return g=ne("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>Av(T))}else{const h=Ev(this.apiClient,n);return g=ne("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>_v(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 Xp(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>pT(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function Xv(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 p=u(l,["contents"]);if(n!==void 0&&p!=null){let T=jt(p);Array.isArray(T)&&(T=T.map(S=>Xp(S))),c(n,["contents"],T)}const g=u(l,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],Xp(At(g)));const y=u(l,["tools"]);if(n!==void 0&&y!=null){let T=y;Array.isArray(T)&&(T=T.map(S=>hT(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 Qv(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 p=u(l,["contents"]);if(n!==void 0&&p!=null){let S=jt(p);Array.isArray(S)&&(S=S.map(C=>C)),c(n,["contents"],S)}const g=u(l,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],At(g));const y=u(l,["tools"]);if(n!==void 0&&y!=null){let S=y;Array.isArray(S)&&(S=S.map(C=>gT(C))),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 Zv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],dh(l,s));const r=u(n,["config"]);return r!=null&&Xv(r,o),o}function $v(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],dh(l,s));const r=u(n,["config"]);return r!=null&&Qv(r,o),o}function Wv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function jv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function eT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function tT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function nT(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 lT(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 p=u(l,["response"]);p!=null&&c(n,["response"],p);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function iT(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function oT(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function aT(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 sT(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 uT(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 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 cT(l){const n={},o=u(l,["config"]);return o!=null&&uT(o,n),n}function fT(l){const n={},o=u(l,["config"]);return o!=null&&rT(o,n),n}function dT(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(p=>p)),c(n,["cachedContents"],d)}return n}function mT(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(p=>p)),c(n,["cachedContents"],d)}return n}function pT(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"],nT(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);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 hT(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"],sT(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"],aT(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);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 gT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(C=>lT(C))),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 p=u(l,["enterpriseWebSearch"]);p!=null&&c(n,["enterpriseWebSearch"],p);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 yT(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 vT(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 TT(l,n){const o={},s=u(n,["name"]);s!=null&&c(o,["_url","name"],Dn(l,s));const r=u(n,["config"]);return r!=null&&yT(r,o),o}function ST(l,n){const o={},s=u(n,["name"]);s!=null&&c(o,["_url","name"],Dn(l,s));const r=u(n,["config"]);return r!=null&&vT(r,o),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class ET extends Al{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new So(Cl.PAGED_ITEM_CACHED_CONTENTS,s=>this.listInternal(s),await this.listInternal(o),o)}async create(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=$v(this.apiClient,n);return g=ne("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>T)}else{const h=Zv(this.apiClient,n);return g=ne("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>T)}}async get(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=oT(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>T)}else{const h=iT(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>T)}}async delete(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=jv(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=tT(T),C=new kp;return Object.assign(C,S),C})}else{const h=Wv(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=eT(T),C=new kp;return Object.assign(C,S),C})}}async update(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=ST(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>T)}else{const h=TT(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>T)}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=fT(n);return g=ne("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=mT(T),C=new Pp;return Object.assign(C,S),C})}else{const h=cT(n);return g=ne("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=dT(T),C=new Pp;return Object.assign(C,S),C})}}}function Qp(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 Xe(l){return this instanceof Xe?(this.v=l,this):new Xe(l)}function pi(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",p),r[Symbol.asyncIterator]=function(){return this},r;function p(R){return function(L){return Promise.resolve(L).then(R,S)}}function g(R,L){s[R]&&(r[R]=function(U){return new Promise(function(k,P){d.push([R,U,k,P])>1||y(R,U)})},L&&(r[R]=L(r[R])))}function y(R,L){try{h(s[R](L))}catch(U){C(d[0][3],U)}}function h(R){R.value instanceof Xe?Promise.resolve(R.value.v).then(T,S):C(d[0][2],R)}function T(R){y("next",R)}function S(R){y("throw",R)}function C(R,L){R(L),d.shift(),d.length&&y(d[0][0],d[0][1])}}function To(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 Qp=="function"?Qp(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(p){return new Promise(function(g,y){p=l[d](p),r(g,y,p.done,p.value)})}}function r(d,p,g,y){Promise.resolve(y).then(function(h){d({value:h,done:g})},p)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function CT(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:xh(o)}function xh(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 _T(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 Zp(l){if(l===void 0||l.length===0)return[];const n=[],o=l.length;let s=0;for(;s{var d,p,g;const y=await r,h=(p=(d=y.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content,T=y.automaticFunctionCallingHistory,S=this.getHistory(!0).length;let C=[];T!=null&&(C=(g=T.slice(S))!==null&&g!==void 0?g:[]);const R=h?[h]:[];this.recordHistory(s,R,C)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(n){var o;await this.sendPromise;const s=At(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?Zp(this.history):this.history;return structuredClone(o)}processStreamResponse(n,o){var s,r;return pi(this,arguments,function*(){var p,g,y,h;const T=[];try{for(var S=!0,C=To(n),R;R=yield Xe(C.next()),p=R.done,!p;S=!0){h=R.value,S=!1;const L=h;if(CT(L)){const U=(r=(s=L.candidates)===null||s===void 0?void 0:s[0])===null||r===void 0?void 0:r.content;U!==void 0&&T.push(U)}yield yield Xe(L)}}catch(L){g={error:L}}finally{try{!S&&!p&&(y=C.return)&&(yield Xe(y.call(C)))}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(...Zp(s)):this.history.push(n),this.history.push(...r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Oa extends Error{constructor(n){super(n.message),this.name="ApiError",this.status=n.status,Object.setPrototypeOf(this,Oa.prototype)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function MT(l){const n={},o=u(l,["file"]);return o!=null&&c(n,["file"],o),n}function NT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function RT(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","file"],vh(o)),n}function bT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function DT(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","file"],vh(o)),n}function wT(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 UT(l){const n={},o=u(l,["config"]);return o!=null&&wT(o,n),n}function IT(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(p=>p)),c(n,["files"],d)}return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class qT extends Al{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new So(Cl.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="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=UT(n);return d=ne("files",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=IT(y),T=new O0;return Object.assign(T,h),T})}}async createInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=MT(n);return d=ne("upload/v1beta/files",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=NT(y),T=new F0;return Object.assign(T,h),T})}}async get(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=DT(n);return d=ne("files/{file}",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=RT(n);return d=ne("files/{file}",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=bT(y),T=new K0;return Object.assign(T,h),T})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Ba(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 LT(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>ZT(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function GT(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 HT(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 p=u(l,["response"]);p!=null&&c(n,["response"],p);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function zT(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 p=u(l,["frequencyPenalty"]);p!=null&&c(n,["frequencyPenalty"],p);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 C=u(l,["responseLogprobs"]);C!=null&&c(n,["responseLogprobs"],C);const R=u(l,["responseMimeType"]);R!=null&&c(n,["responseMimeType"],R);const L=u(l,["responseModalities"]);L!=null&&c(n,["responseModalities"],L);const U=u(l,["responseSchema"]);U!=null&&c(n,["responseSchema"],U);const k=u(l,["routingConfig"]);k!=null&&c(n,["routingConfig"],k);const P=u(l,["seed"]);P!=null&&c(n,["seed"],P);const F=u(l,["speechConfig"]);F!=null&&c(n,["speechConfig"],Mh(F));const z=u(l,["stopSequences"]);z!=null&&c(n,["stopSequences"],z);const $=u(l,["temperature"]);$!=null&&c(n,["temperature"],$);const W=u(l,["thinkingConfig"]);W!=null&&c(n,["thinkingConfig"],W);const ae=u(l,["topK"]);ae!=null&&c(n,["topK"],ae);const O=u(l,["topP"]);return O!=null&&c(n,["topP"],O),n}function VT(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 BT(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 kT(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 p=u(l,["topP"]);n!==void 0&&p!=null&&c(n,["setup","generationConfig","topP"],p);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 C=u(l,["thinkingConfig"]);n!==void 0&&C!=null&&c(n,["setup","generationConfig","thinkingConfig"],C);const R=u(l,["enableAffectiveDialog"]);n!==void 0&&R!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],R);const L=u(l,["systemInstruction"]);n!==void 0&&L!=null&&c(n,["setup","systemInstruction"],LT(At(L)));const U=u(l,["tools"]);if(n!==void 0&&U!=null){let ae=vi(U);Array.isArray(ae)&&(ae=ae.map(O=>WT(yi(O)))),c(n,["setup","tools"],ae)}const k=u(l,["sessionResumption"]);n!==void 0&&k!=null&&c(n,["setup","sessionResumption"],$T(k));const P=u(l,["inputAudioTranscription"]);n!==void 0&&P!=null&&c(n,["setup","inputAudioTranscription"],P);const F=u(l,["outputAudioTranscription"]);n!==void 0&&F!=null&&c(n,["setup","outputAudioTranscription"],F);const z=u(l,["realtimeInputConfig"]);n!==void 0&&z!=null&&c(n,["setup","realtimeInputConfig"],z);const $=u(l,["contextWindowCompression"]);n!==void 0&&$!=null&&c(n,["setup","contextWindowCompression"],$);const W=u(l,["proactivity"]);return n!==void 0&&W!=null&&c(n,["setup","proactivity"],W),o}function PT(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],zT(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 p=u(l,["topP"]);n!==void 0&&p!=null&&c(n,["setup","generationConfig","topP"],p);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"],Mh(Gr(S)));const C=u(l,["thinkingConfig"]);n!==void 0&&C!=null&&c(n,["setup","generationConfig","thinkingConfig"],C);const R=u(l,["enableAffectiveDialog"]);n!==void 0&&R!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],R);const L=u(l,["systemInstruction"]);n!==void 0&&L!=null&&c(n,["setup","systemInstruction"],At(L));const U=u(l,["tools"]);if(n!==void 0&&U!=null){let ae=vi(U);Array.isArray(ae)&&(ae=ae.map(O=>jT(yi(O)))),c(n,["setup","tools"],ae)}const k=u(l,["sessionResumption"]);n!==void 0&&k!=null&&c(n,["setup","sessionResumption"],k);const P=u(l,["inputAudioTranscription"]);n!==void 0&&P!=null&&c(n,["setup","inputAudioTranscription"],P);const F=u(l,["outputAudioTranscription"]);n!==void 0&&F!=null&&c(n,["setup","outputAudioTranscription"],F);const z=u(l,["realtimeInputConfig"]);n!==void 0&&z!=null&&c(n,["setup","realtimeInputConfig"],z);const $=u(l,["contextWindowCompression"]);n!==void 0&&$!=null&&c(n,["setup","contextWindowCompression"],$);const W=u(l,["proactivity"]);return n!==void 0&&W!=null&&c(n,["setup","proactivity"],W),o}function YT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],Ie(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],kT(r,o)),o}function JT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],Ie(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],PT(r,o)),o}function OT(l){const n={},o=u(l,["musicGenerationConfig"]);return o!=null&&c(n,["musicGenerationConfig"],o),n}function FT(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=mh(o);Array.isArray(h)&&(h=h.map(T=>Ba(T))),c(n,["mediaChunks"],h)}const s=u(l,["audio"]);s!=null&&c(n,["audio"],Ba(hh(s)));const r=u(l,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(l,["video"]);d!=null&&c(n,["video"],Ba(ph(d)));const p=u(l,["text"]);p!=null&&c(n,["text"],p);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 XT(l){const n={},o=u(l,["media"]);if(o!=null){let h=mh(o);Array.isArray(h)&&(h=h.map(T=>T)),c(n,["mediaChunks"],h)}const s=u(l,["audio"]);s!=null&&c(n,["audio"],hh(s));const r=u(l,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(l,["video"]);d!=null&&c(n,["video"],ph(d));const p=u(l,["text"]);p!=null&&c(n,["text"],p);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 QT(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 p=u(l,["usageMetadata"]);p!=null&&c(n,["usageMetadata"],eS(p));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 ZT(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"],Ba(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],GT(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);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 $T(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 Mh(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 WT(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"],BT(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"],VT(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);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 jT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(C=>HT(C))),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 p=u(l,["enterpriseWebSearch"]);p!=null&&c(n,["enterpriseWebSearch"],p);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 eS(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 p=u(l,["thoughtsTokenCount"]);p!=null&&c(n,["thoughtsTokenCount"],p);const g=u(l,["totalTokenCount"]);g!=null&&c(n,["totalTokenCount"],g);const y=u(l,["promptTokensDetails"]);if(y!=null){let R=y;Array.isArray(R)&&(R=R.map(L=>L)),c(n,["promptTokensDetails"],R)}const h=u(l,["cacheTokensDetails"]);if(h!=null){let R=h;Array.isArray(R)&&(R=R.map(L=>L)),c(n,["cacheTokensDetails"],R)}const T=u(l,["candidatesTokensDetails"]);if(T!=null){let R=T;Array.isArray(R)&&(R=R.map(L=>L)),c(n,["responseTokensDetails"],R)}const S=u(l,["toolUsePromptTokensDetails"]);if(S!=null){let R=S;Array.isArray(R)&&(R=R.map(L=>L)),c(n,["toolUsePromptTokensDetails"],R)}const C=u(l,["trafficType"]);return C!=null&&c(n,["trafficType"],C),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function tS(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 nS(l){const n={},o=u(l,["content"]);o!=null&&c(n,["content"],o);const s=u(l,["citationMetadata"]);s!=null&&c(n,["citationMetadata"],lS(s));const r=u(l,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(l,["finishReason"]);d!=null&&c(n,["finishReason"],d);const p=u(l,["urlContextMetadata"]);p!=null&&c(n,["urlContextMetadata"],p);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 C=S;Array.isArray(C)&&(C=C.map(R=>R)),c(n,["safetyRatings"],C)}return n}function lS(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 iS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let d=jt(r);Array.isArray(d)&&(d=d.map(p=>p)),c(o,["contents"],d)}return o}function oS(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 aS(l){const n={},o=u(l,["values"]);o!=null&&c(n,["values"],o);const s=u(l,["statistics"]);return s!=null&&c(n,["statistics"],sS(s)),n}function sS(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 Fa(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>dE(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function uS(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 rS(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 cS(l,n){const o={},s=u(l,["systemInstruction"]);n!==void 0&&s!=null&&c(n,["systemInstruction"],At(s));const r=u(l,["tools"]);if(n!==void 0&&r!=null){let p=r;Array.isArray(p)&&(p=p.map(g=>wh(g))),c(n,["tools"],p)}const d=u(l,["generationConfig"]);return n!==void 0&&d!=null&&c(n,["generationConfig"],jS(d)),o}function fS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let p=jt(r);Array.isArray(p)&&(p=p.map(g=>Fa(g))),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&rS(d),o}function dS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let p=jt(r);Array.isArray(p)&&(p=p.map(g=>g)),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&cS(d,o),o}function mS(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 pS(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 hS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],Ie(l,s)),o}function gS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],Ie(l,s)),o}function yS(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function vS(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function TS(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 p=u(l,["aspectRatio"]);n!==void 0&&p!=null&&c(n,["parameters","aspectRatio"],p);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 C=u(l,["includeRaiReason"]);n!==void 0&&C!=null&&c(n,["parameters","includeRaiReason"],C);const R=u(l,["language"]);n!==void 0&&R!=null&&c(n,["parameters","language"],R);const L=u(l,["outputMimeType"]);n!==void 0&&L!=null&&c(n,["parameters","outputOptions","mimeType"],L);const U=u(l,["outputCompressionQuality"]);n!==void 0&&U!=null&&c(n,["parameters","outputOptions","compressionQuality"],U);const k=u(l,["addWatermark"]);n!==void 0&&k!=null&&c(n,["parameters","addWatermark"],k);const P=u(l,["labels"]);n!==void 0&&P!=null&&c(n,["labels"],P);const F=u(l,["editMode"]);n!==void 0&&F!=null&&c(n,["parameters","editMode"],F);const z=u(l,["baseSteps"]);return n!==void 0&&z!=null&&c(n,["parameters","editConfig","baseSteps"],z),o}function SS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(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=>vE(y))),c(o,["instances[0]","referenceImages"],g)}const p=u(n,["config"]);return p!=null&&TS(p,o),o}function ES(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=>Ka(d))),c(n,["generatedImages"],r)}return n}function CS(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 _S(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 p=u(l,["mimeType"]);n!==void 0&&p!=null&&c(n,["instances[]","mimeType"],p);const g=u(l,["autoTruncate"]);return n!==void 0&&g!=null&&c(n,["parameters","autoTruncate"],g),o}function AS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let g=Ir(l,r);Array.isArray(g)&&(g=g.map(y=>y)),c(o,["requests[]","content"],g)}const d=u(n,["config"]);d!=null&&CS(d,o);const p=u(n,["model"]);return p!==void 0&&c(o,["requests[]","model"],Ie(l,p)),o}function xS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let p=Ir(l,r);Array.isArray(p)&&(p=p.map(g=>g)),c(o,["instances[]","content"],p)}const d=u(n,["config"]);return d!=null&&_S(d,o),o}function MS(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(p=>p)),c(n,["embeddings"],d)}const r=u(l,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function NS(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(p=>aS(p))),c(n,["embeddings"],d)}const r=u(l,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function RS(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 bS(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 DS(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 p=u(l,["response"]);p!=null&&c(n,["response"],p);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function wS(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],Fa(At(r)));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const p=u(n,["topP"]);p!=null&&c(s,["topP"],p);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 C=u(n,["logprobs"]);C!=null&&c(s,["logprobs"],C);const R=u(n,["presencePenalty"]);R!=null&&c(s,["presencePenalty"],R);const L=u(n,["frequencyPenalty"]);L!=null&&c(s,["frequencyPenalty"],L);const U=u(n,["seed"]);U!=null&&c(s,["seed"],U);const k=u(n,["responseMimeType"]);k!=null&&c(s,["responseMimeType"],k);const P=u(n,["responseSchema"]);P!=null&&c(s,["responseSchema"],qr(P));const F=u(n,["responseJsonSchema"]);if(F!=null&&c(s,["responseJsonSchema"],F),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 z=u(n,["safetySettings"]);if(o!==void 0&&z!=null){let Te=z;Array.isArray(Te)&&(Te=Te.map(Oe=>TE(Oe))),c(o,["safetySettings"],Te)}const $=u(n,["tools"]);if(o!==void 0&&$!=null){let Te=vi($);Array.isArray(Te)&&(Te=Te.map(Oe=>xE(yi(Oe)))),c(o,["tools"],Te)}const W=u(n,["toolConfig"]);if(o!==void 0&&W!=null&&c(o,["toolConfig"],W),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const ae=u(n,["cachedContent"]);o!==void 0&&ae!=null&&c(o,["cachedContent"],Dn(l,ae));const O=u(n,["responseModalities"]);O!=null&&c(s,["responseModalities"],O);const Ce=u(n,["mediaResolution"]);Ce!=null&&c(s,["mediaResolution"],Ce);const le=u(n,["speechConfig"]);if(le!=null&&c(s,["speechConfig"],Lr(le)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const ve=u(n,["thinkingConfig"]);ve!=null&&c(s,["thinkingConfig"],ve);const be=u(n,["imageConfig"]);return be!=null&&c(s,["imageConfig"],be),s}function US(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],At(r));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const p=u(n,["topP"]);p!=null&&c(s,["topP"],p);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 C=u(n,["logprobs"]);C!=null&&c(s,["logprobs"],C);const R=u(n,["presencePenalty"]);R!=null&&c(s,["presencePenalty"],R);const L=u(n,["frequencyPenalty"]);L!=null&&c(s,["frequencyPenalty"],L);const U=u(n,["seed"]);U!=null&&c(s,["seed"],U);const k=u(n,["responseMimeType"]);k!=null&&c(s,["responseMimeType"],k);const P=u(n,["responseSchema"]);P!=null&&c(s,["responseSchema"],qr(P));const F=u(n,["responseJsonSchema"]);F!=null&&c(s,["responseJsonSchema"],F);const z=u(n,["routingConfig"]);z!=null&&c(s,["routingConfig"],z);const $=u(n,["modelSelectionConfig"]);$!=null&&c(s,["modelConfig"],$);const W=u(n,["safetySettings"]);if(o!==void 0&&W!=null){let q=W;Array.isArray(q)&&(q=q.map(Y=>Y)),c(o,["safetySettings"],q)}const ae=u(n,["tools"]);if(o!==void 0&&ae!=null){let q=vi(ae);Array.isArray(q)&&(q=q.map(Y=>wh(yi(Y)))),c(o,["tools"],q)}const O=u(n,["toolConfig"]);o!==void 0&&O!=null&&c(o,["toolConfig"],O);const Ce=u(n,["labels"]);o!==void 0&&Ce!=null&&c(o,["labels"],Ce);const le=u(n,["cachedContent"]);o!==void 0&&le!=null&&c(o,["cachedContent"],Dn(l,le));const ve=u(n,["responseModalities"]);ve!=null&&c(s,["responseModalities"],ve);const be=u(n,["mediaResolution"]);be!=null&&c(s,["mediaResolution"],be);const Te=u(n,["speechConfig"]);Te!=null&&c(s,["speechConfig"],Dh(Lr(Te)));const Oe=u(n,["audioTimestamp"]);Oe!=null&&c(s,["audioTimestamp"],Oe);const Ct=u(n,["thinkingConfig"]);Ct!=null&&c(s,["thinkingConfig"],Ct);const me=u(n,["imageConfig"]);return me!=null&&c(s,["imageConfig"],me),s}function $p(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let p=jt(r);Array.isArray(p)&&(p=p.map(g=>Fa(g))),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],wS(l,d,o)),o}function Wp(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["contents"]);if(r!=null){let p=jt(r);Array.isArray(p)&&(p=p.map(g=>g)),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],US(l,d,o)),o}function jp(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=>nS(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 p=u(l,["responseId"]);p!=null&&c(n,["responseId"],p);const g=u(l,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function eh(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 p=u(l,["promptFeedback"]);p!=null&&c(n,["promptFeedback"],p);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 IS(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 p=u(l,["safetyFilterLevel"]);n!==void 0&&p!=null&&c(n,["parameters","safetySetting"],p);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 C=u(l,["outputCompressionQuality"]);if(n!==void 0&&C!=null&&c(n,["parameters","outputOptions","compressionQuality"],C),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 R=u(l,["imageSize"]);if(n!==void 0&&R!=null&&c(n,["parameters","sampleImageSize"],R),u(l,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function qS(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 p=u(l,["aspectRatio"]);n!==void 0&&p!=null&&c(n,["parameters","aspectRatio"],p);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 C=u(l,["includeRaiReason"]);n!==void 0&&C!=null&&c(n,["parameters","includeRaiReason"],C);const R=u(l,["language"]);n!==void 0&&R!=null&&c(n,["parameters","language"],R);const L=u(l,["outputMimeType"]);n!==void 0&&L!=null&&c(n,["parameters","outputOptions","mimeType"],L);const U=u(l,["outputCompressionQuality"]);n!==void 0&&U!=null&&c(n,["parameters","outputOptions","compressionQuality"],U);const k=u(l,["addWatermark"]);n!==void 0&&k!=null&&c(n,["parameters","addWatermark"],k);const P=u(l,["labels"]);n!==void 0&&P!=null&&c(n,["labels"],P);const F=u(l,["imageSize"]);n!==void 0&&F!=null&&c(n,["parameters","sampleImageSize"],F);const z=u(l,["enhancePrompt"]);return n!==void 0&&z!=null&&c(n,["parameters","enhancePrompt"],z),o}function LS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&IS(d,o),o}function GS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&qS(d,o),o}function HS(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(p=>QS(p))),c(n,["generatedImages"],d)}const r=u(l,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],Rh(r)),n}function zS(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(p=>Ka(p))),c(n,["generatedImages"],d)}const r=u(l,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],bh(r)),n}function VS(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 p=u(l,["resolution"]);n!==void 0&&p!=null&&c(n,["parameters","resolution"],p);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"],Xa(T));const S=u(l,["referenceImages"]);if(n!==void 0&&S!=null){let C=S;Array.isArray(C)&&(C=C.map(R=>zE(R))),c(n,["instances[0]","referenceImages"],C)}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 BS(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 p=u(l,["durationSeconds"]);n!==void 0&&p!=null&&c(n,["parameters","durationSeconds"],p);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 C=u(l,["negativePrompt"]);n!==void 0&&C!=null&&c(n,["parameters","negativePrompt"],C);const R=u(l,["enhancePrompt"]);n!==void 0&&R!=null&&c(n,["parameters","enhancePrompt"],R);const L=u(l,["generateAudio"]);n!==void 0&&L!=null&&c(n,["parameters","generateAudio"],L);const U=u(l,["lastFrame"]);n!==void 0&&U!=null&&c(n,["instances[0]","lastFrame"],an(U));const k=u(l,["referenceImages"]);if(n!==void 0&&k!=null){let z=k;Array.isArray(z)&&(z=z.map($=>VE($))),c(n,["instances[0]","referenceImages"],z)}const P=u(l,["mask"]);n!==void 0&&P!=null&&c(n,["instances[0]","mask"],HE(P));const F=u(l,["compressionQuality"]);return n!==void 0&&F!=null&&c(n,["parameters","compressionQuality"],F),o}function kS(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 p=u(l,["response","generateVideoResponse"]);return p!=null&&c(n,["response"],OS(p)),n}function PS(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 p=u(l,["response"]);return p!=null&&c(n,["response"],FS(p)),n}function YS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(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"],Xa(d));const p=u(n,["video"]);p!=null&&c(o,["instances[0]","video"],Uh(p));const g=u(n,["source"]);g!=null&&KS(g,o);const y=u(n,["config"]);return y!=null&&VS(y,o),o}function JS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(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"],an(d));const p=u(n,["video"]);p!=null&&c(o,["instances[0]","video"],Ih(p));const g=u(n,["source"]);g!=null&&XS(g,o);const y=u(n,["config"]);return y!=null&&BS(y,o),o}function OS(l){const n={},o=u(l,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>$S(p))),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 FS(l){const n={},o=u(l,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>WS(p))),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"],Xa(r));const d=u(l,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],Uh(d)),o}function XS(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"],an(r));const d=u(l,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],Ih(d)),o}function QS(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["image"],iE(o));const s=u(l,["raiFilteredReason"]);s!=null&&c(n,["raiFilteredReason"],s);const r=u(l,["_self"]);return r!=null&&c(n,["safetyAttributes"],Rh(r)),n}function Ka(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["image"],Nh(o));const s=u(l,["raiFilteredReason"]);s!=null&&c(n,["raiFilteredReason"],s);const r=u(l,["_self"]);r!=null&&c(n,["safetyAttributes"],bh(r));const d=u(l,["prompt"]);return d!=null&&c(n,["enhancedPrompt"],d),n}function ZS(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["mask"],Nh(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 $S(l){const n={},o=u(l,["video"]);return o!=null&&c(n,["video"],LE(o)),n}function WS(l){const n={},o=u(l,["_self"]);return o!=null&&c(n,["video"],GE(o)),n}function jS(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 p=u(l,["frequencyPenalty"]);p!=null&&c(n,["frequencyPenalty"],p);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 C=u(l,["responseLogprobs"]);C!=null&&c(n,["responseLogprobs"],C);const R=u(l,["responseMimeType"]);R!=null&&c(n,["responseMimeType"],R);const L=u(l,["responseModalities"]);L!=null&&c(n,["responseModalities"],L);const U=u(l,["responseSchema"]);U!=null&&c(n,["responseSchema"],U);const k=u(l,["routingConfig"]);k!=null&&c(n,["routingConfig"],k);const P=u(l,["seed"]);P!=null&&c(n,["seed"],P);const F=u(l,["speechConfig"]);F!=null&&c(n,["speechConfig"],Dh(F));const z=u(l,["stopSequences"]);z!=null&&c(n,["stopSequences"],z);const $=u(l,["temperature"]);$!=null&&c(n,["temperature"],$);const W=u(l,["thinkingConfig"]);W!=null&&c(n,["thinkingConfig"],W);const ae=u(l,["topK"]);ae!=null&&c(n,["topK"],ae);const O=u(l,["topP"]);return O!=null&&c(n,["topP"],O),n}function eE(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],Ie(l,s)),o}function tE(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],Ie(l,s)),o}function nE(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 lE(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 iE(l){const n={},o=u(l,["bytesBase64Encoded"]);o!=null&&c(n,["imageBytes"],ll(o));const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function Nh(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["imageBytes"],ll(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function Xa(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"],ll(o));const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function an(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["imageBytes"]);s!=null&&c(n,["bytesBase64Encoded"],ll(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function oE(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 p=u(n,["filter"]);o!==void 0&&p!=null&&c(o,["_query","filter"],p);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],Th(l,g)),s}function aE(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 p=u(n,["filter"]);o!==void 0&&p!=null&&c(o,["_query","filter"],p);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],Th(l,g)),s}function sE(l,n){const o={},s=u(n,["config"]);return s!=null&&oE(l,s,o),o}function uE(l,n){const o={},s=u(n,["config"]);return s!=null&&aE(l,s,o),o}function rE(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=Sh(r);Array.isArray(d)&&(d=d.map(p=>xr(p))),c(n,["models"],d)}return n}function cE(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=Sh(r);Array.isArray(d)&&(d=d.map(p=>Mr(p))),c(n,["models"],d)}return n}function fE(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 xr(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 p=u(l,["_self"]);p!=null&&c(n,["tunedModelInfo"],ME(p));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 Mr(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 p=u(l,["deployedModels"]);if(p!=null){let S=p;Array.isArray(S)&&(S=S.map(C=>RS(C))),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"],NE(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=>C)),c(n,["checkpoints"],S)}return n}function dE(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"],tS(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],bS(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);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 mE(l){const n={},o=u(l,["productImage"]);return o!=null&&c(n,["image"],an(o)),n}function pE(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 p=u(l,["seed"]);n!==void 0&&p!=null&&c(n,["parameters","seed"],p);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 C=u(l,["enhancePrompt"]);n!==void 0&&C!=null&&c(n,["parameters","enhancePrompt"],C);const R=u(l,["labels"]);return n!==void 0&&R!=null&&c(n,["labels"],R),o}function hE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["source"]);r!=null&&yE(r,o);const d=u(n,["config"]);return d!=null&&pE(d,o),o}function gE(l){const n={},o=u(l,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>Ka(r))),c(n,["generatedImages"],s)}return n}function yE(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"],an(r));const d=u(l,["productImages"]);if(n!==void 0&&d!=null){let p=d;Array.isArray(p)&&(p=p.map(g=>mE(g))),c(n,["instances[0]","productImages"],p)}return o}function vE(l){const n={},o=u(l,["referenceImage"]);o!=null&&c(n,["referenceImage"],an(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"],fE(d));const p=u(l,["controlImageConfig"]);p!=null&&c(n,["controlImageConfig"],uS(p));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 Rh(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 bh(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 TE(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 SE(l){const n={},o=u(l,["image"]);return o!=null&&c(n,["image"],an(o)),n}function EE(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 p=u(l,["maskDilation"]);n!==void 0&&p!=null&&c(n,["parameters","maskDilation"],p);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 CE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["source"]);r!=null&&AE(r,o);const d=u(n,["config"]);return d!=null&&EE(d,o),o}function _E(l){const n={},o=u(l,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>ZS(r))),c(n,["generatedMasks"],s)}return n}function AE(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"],an(r));const d=u(l,["scribbleImage"]);return n!==void 0&&d!=null&&c(n,["instances[0]","scribble"],SE(d)),o}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 xE(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"],lE(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"],nE(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);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 wh(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(C=>DS(C))),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 p=u(l,["enterpriseWebSearch"]);p!=null&&c(n,["enterpriseWebSearch"],p);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 ME(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 NE(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 RE(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 bE(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 DE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","name"],Ie(l,s));const r=u(n,["config"]);return r!=null&&RE(r,o),o}function wE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["config"]);return r!=null&&bE(r,o),o}function UE(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 p=u(l,["outputCompressionQuality"]);n!==void 0&&p!=null&&c(n,["parameters","outputOptions","compressionQuality"],p);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 IE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],Ie(l,s));const r=u(n,["image"]);r!=null&&c(o,["instances[0]","image"],an(r));const d=u(n,["upscaleFactor"]);d!=null&&c(o,["parameters","upscaleConfig","upscaleFactor"],d);const p=u(n,["config"]);return p!=null&&UE(p,o),o}function qE(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=>Ka(d))),c(n,["generatedImages"],r)}return n}function LE(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["encodedVideo"]);s!=null&&c(n,["videoBytes"],ll(s));const r=u(l,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function GE(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["uri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["videoBytes"],ll(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function HE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["_self"],an(o));const s=u(l,["maskMode"]);return s!=null&&c(n,["maskMode"],s),n}function zE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["image"],Xa(o));const s=u(l,["referenceType"]);return s!=null&&c(n,["referenceType"],s),n}function VE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["image"],an(o));const s=u(l,["referenceType"]);return s!=null&&c(n,["referenceType"],s),n}function Uh(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["videoBytes"]);s!=null&&c(n,["encodedVideo"],ll(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["encoding"],r),n}function Ih(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["videoBytes"]);s!=null&&c(n,["bytesBase64Encoded"],ll(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 BE="Content-Type",kE="X-Server-Timeout",PE="User-Agent",Nr="x-goog-api-client",YE="1.25.0",JE=`google-genai-sdk/${YE}`,OE="v1beta1",FE="v1beta",th=/^\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:OE,r.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(r.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:FE,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[p,g]of Object.entries(n.queryParams))r.searchParams.append(p,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 p=setTimeout(()=>r.abort(),o.timeout);p&&typeof p.unref=="function"&&p.unref()}s&&s.addEventListener("abort",()=>{r.abort()}),n.signal=d}return o&&o.extraBody!==null&&XE(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 nh(r),new Cr(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 nh(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(n){var o;return pi(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 p="";for(;;){const{done:g,value:y}=yield Xe(r.read());if(g){if(p.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 C=JSON.parse(JSON.stringify(S.error)),R=C.status,L=C.code,U=`got status: ${R}. ${JSON.stringify(S)}`;if(L>=400&&L<600)throw new Oa({message:U,status:L})}}catch(S){if(S.name==="ApiError")throw S}p+=h;let T=p.match(th);for(;T;){const S=T[1];try{const C=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 Xe(new Cr(C)),p=p.slice(T[0].length),T=p.match(th)}catch(C){throw new Error(`exception parsing stream chunk ${S}. ${C}`)}}}}finally{r.releaseLock()}})}async apiCall(n,o){return fetch(n,o).catch(s=>{throw new Error(`exception ${s} sending request`)})}getDefaultHeaders(){const n={},o=JE+" "+this.clientOptions.userAgentExtra;return n[PE]=o,n[Nr]=o,n[BE]="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(kE,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,p=await d.stat(n);r.sizeBytes=String(p.size);const g=(s=o==null?void 0:o.mimeType)!==null&&s!==void 0?s:p.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},p=await this.request({path:ne("upload/v1beta/files",d._url),body:JSON.stringify(d),httpMethod:"POST",httpOptions:r});if(!p||!(p!=null&&p.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const g=(s=p==null?void 0:p.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 nh(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 Oa({message:r,status:o}):new Error(r)}}function XE(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,p){const g=Object.assign({},d);for(const y in p)if(Object.prototype.hasOwnProperty.call(p,y)){const h=p[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 QE="mcp_used/unknown";let ZE=!1;function qh(l){for(const n of l)if($E(n)||typeof n=="object"&&"inputSchema"in n)return!0;return ZE}function Lh(l){var n;const o=(n=l[Nr])!==null&&n!==void 0?n:"";l[Nr]=(o+` ${QE}`).trimStart()}function $E(l){return l!==null&&typeof l=="object"&&l instanceof Hr}function WE(l,n=100){return pi(this,arguments,function*(){let s,r=0;for(;r0)return;const d={},p=[];for(const T of this.mcpClients)try{for(var g=!0,y=(o=void 0,To(WE(T))),h;h=await y.next(),n=h.done,!n;g=!0){r=h.value,g=!1;const S=r;p.push(S);const C=S.name;if(d[C])throw new Error(`Duplicate function name ${C} found in MCP tools. Please ensure function names are unique.`);d[C]=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=p,this.functionNameToMcpClient=d}async tool(){return await this.initialize(),lv(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 p=await r.callTool({name:s.name,arguments:s.args},void 0,d);o.push({functionResponse:{name:s.name,response:p.isError?{error:p}:p}})}return o}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */async function jE(l,n,o){const s=new Q0;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 eC{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(),p=lC(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${r}/ws/google.ai.generativelanguage.${d}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const T=new Promise(z=>{h=z}),S=n.callbacks,C=function(){h({})},R=this.apiClient,L={onopen:C,onmessage:z=>{jE(R,S.onmessage,z)},onerror:(o=S==null?void 0:S.onerror)!==null&&o!==void 0?o:function(z){},onclose:(s=S==null?void 0:S.onclose)!==null&&s!==void 0?s:function(z){}},U=this.webSocketFactory.create(y,nC(p),L);U.connect(),await T;const F={setup:{model:Ie(this.apiClient,n.model)}};return U.send(JSON.stringify(F)),new tC(U,this.apiClient)}}class tC{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=FT(n);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(n){n.musicGenerationConfig||(n.musicGenerationConfig={});const o=OT(n);this.conn.send(JSON.stringify(o))}sendPlaybackControl(n){const o={playbackControl:n};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(di.PLAY)}pause(){this.sendPlaybackControl(di.PAUSE)}stop(){this.sendPlaybackControl(di.STOP)}resetContext(){this.sendPlaybackControl(di.RESET_CONTEXT)}close(){this.conn.close()}}function nC(l){const n={};return l.forEach((o,s)=>{n[s]=o}),n}function lC(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 iC="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function oC(l,n,o){const s=new X0;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 p=QT(d);Object.assign(s,p)}else Object.assign(s,d);n(s)}class aC{constructor(n,o,s){this.apiClient=n,this.auth=o,this.webSocketFactory=s,this.music=new eC(this.apiClient,this.auth,this.webSocketFactory)}async connect(n){var o,s,r,d,p,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&&qh(n.config.tools)&&Lh(S);const C=cC(S);if(this.apiClient.isVertexAI())T=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(C);else{const le=this.apiClient.getApiKey();let ve="BidiGenerateContent",be="key";le!=null&&le.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."),ve="BidiGenerateContentConstrained",be="access_token"),T=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${ve}?${be}=${le}`}let R=()=>{};const L=new Promise(le=>{R=le}),U=n.callbacks,k=function(){var le;(le=U==null?void 0:U.onopen)===null||le===void 0||le.call(U),R({})},P=this.apiClient,F={onopen:k,onmessage:le=>{oC(P,U.onmessage,le)},onerror:(o=U==null?void 0:U.onerror)!==null&&o!==void 0?o:function(le){},onclose:(s=U==null?void 0:U.onclose)!==null&&s!==void 0?s:function(le){}},z=this.webSocketFactory.create(T,rC(C),F);z.connect(),await L;let $=Ie(this.apiClient,n.model);if(this.apiClient.isVertexAI()&&$.startsWith("publishers/")){const le=this.apiClient.getProject(),ve=this.apiClient.getLocation();$=`projects/${le}/locations/${ve}/`+$}let W={};this.apiClient.isVertexAI()&&((r=n.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(n.config===void 0?n.config={responseModalities:[Pa.AUDIO]}:n.config.responseModalities=[Pa.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 ae=(g=(p=n.config)===null||p===void 0?void 0:p.tools)!==null&&g!==void 0?g:[],O=[];for(const le of ae)if(this.isCallableTool(le)){const ve=le;O.push(await ve.tool())}else O.push(le);O.length>0&&(n.config.tools=O);const Ce={model:$,config:n.config,callbacks:n.callbacks};return this.apiClient.isVertexAI()?W=JT(this.apiClient,Ce):W=YT(this.apiClient,Ce),delete W.config,z.send(JSON.stringify(W)),new uC(z,this.apiClient)}isCallableTool(n){return"callTool"in n&&typeof n.callTool=="function"}}const sC={turnComplete:!0};class uC{constructor(n,o){this.conn=n,this.apiClient=o}tLiveClientContent(n,o){if(o.turns!==null&&o.turns!==void 0){let s=[];try{s=jt(o.turns),n.isVertexAI()||(s=s.map(r=>Fa(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(iC)}return{toolResponse:{functionResponses:s}}}sendClientContent(n){n=Object.assign(Object.assign({},sC),n);const o=this.tLiveClientContent(this.apiClient,n);this.conn.send(JSON.stringify(o))}sendRealtimeInput(n){let o={};this.apiClient.isVertexAI()?o={realtimeInput:XT(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 rC(l){const n={};return l.forEach((o,s)=>{n[s]=o}),n}function cC(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 lh=10;function ih(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 p of(o=l==null?void 0:l.tools)!==null&&o!==void 0?o:[])if(hi(p)){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 hi(l){return"callTool"in l&&typeof l.callTool=="function"}function fC(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=>hi(r)))!==null&&s!==void 0?s:!1}function dC(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=>!hi(r)))!==null&&s!==void 0?s:!1}function oh(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 mC extends Al{constructor(n){super(),this.apiClient=n,this.generateContent=async o=>{var s,r,d,p,g;const y=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!fC(o)||ih(o.config))return await this.generateContentInternal(y);if(dC(o))throw new Error("Automatic function calling with CallableTools and Tools is not yet supported.");let h,T;const S=jt(y.contents),C=(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:lh;let R=0;for(;R{if(this.maybeMoveToResponseJsonSchem(o),ih(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 p=[];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:p.push(y);let g;return d?g={generatedImages:p,positivePromptSafetyAttributes:d,sdkHttpResponse:s.sdkHttpResponse}:g={generatedImages:p,sdkHttpResponse:s.sdkHttpResponse},g}),this.list=async o=>{var s;const p={config:Object.assign(Object.assign({},{queryBase:!0}),o==null?void 0:o.config)};if(this.apiClient.isVertexAI()&&!p.config.queryBase){if(!((s=p.config)===null||s===void 0)&&s.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");p.config.filter="labels.tune-type:*"}return new So(Cl.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(p),p)},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,p,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}:!((p=(d=o.source)===null||d===void 0?void 0:d.video)===null||p===void 0)&&p.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 p=await Promise.all(d.map(async y=>hi(y)?await y.tool():y)),g={model:n.model,contents:n.contents,config:Object.assign(Object.assign({},n.config),{tools:p})};if(g.config.tools=p,n.config&&n.config.tools&&qh(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()),Lh(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 p of(s=(o=n.config)===null||o===void 0?void 0:o.tools)!==null&&s!==void 0?s:[])if(hi(p)){const g=p,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:lh;let p=!1,g=0;const y=await this.initAfcToolsMap(n);return(function(h,T,S){var C,R;return pi(this,arguments,function*(){for(var L,U,k,P;g0){p=!0;const le=new vo;le.candidates=[{content:{role:"user",parts:O}}],yield yield Xe(le);const ve=[];ve.push(...Ce),ve.push({role:"user",parts:O});const be=jt(S.contents).concat(ve);S.contents=be}else break}})})(this,y,n)}async generateContentInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Wp(this.apiClient,n);return g=ne("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=eh(T),C=new vo;return Object.assign(C,S),C})}else{const h=$p(this.apiClient,n);return g=ne("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=jp(T),C=new vo;return Object.assign(C,S),C})}}async generateContentStreamInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Wp(this.apiClient,n);return g=ne("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,p=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}),p.then(function(S){return pi(this,arguments,function*(){var C,R,L,U;try{for(var k=!0,P=To(S),F;F=yield Xe(P.next()),C=F.done,!C;k=!0){U=F.value,k=!1;const z=U,$=eh(yield Xe(z.json()));$.sdkHttpResponse={headers:z.headers};const W=new vo;Object.assign(W,$),yield yield Xe(W)}}catch(z){R={error:z}}finally{try{!k&&!C&&(L=P.return)&&(yield Xe(L.call(P)))}finally{if(R)throw R.error}}})})}else{const h=$p(this.apiClient,n);return g=ne("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,p=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}),p.then(function(S){return pi(this,arguments,function*(){var C,R,L,U;try{for(var k=!0,P=To(S),F;F=yield Xe(P.next()),C=F.done,!C;k=!0){U=F.value,k=!1;const z=U,$=jp(yield Xe(z.json()));$.sdkHttpResponse={headers:z.headers};const W=new vo;Object.assign(W,$),yield yield Xe(W)}}catch(z){R={error:z}}finally{try{!k&&!C&&(L=P.return)&&(yield Xe(L.call(P)))}finally{if(R)throw R.error}}})})}}async embedContent(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=xS(this.apiClient,n);return g=ne("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=NS(T),C=new Lp;return Object.assign(C,S),C})}else{const h=AS(this.apiClient,n);return g=ne("{model}:batchEmbedContents",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=MS(T),C=new Lp;return Object.assign(C,S),C})}}async generateImagesInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=GS(this.apiClient,n);return g=ne("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=zS(T),C=new Gp;return Object.assign(C,S),C})}else{const h=LS(this.apiClient,n);return g=ne("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=HS(T),C=new Gp;return Object.assign(C,S),C})}}async editImageInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=SS(this.apiClient,n);return d=ne("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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 B0;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="",p={};if(this.apiClient.isVertexAI()){const g=IE(this.apiClient,n);return d=ne("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=qE(y),T=new k0;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="",p={};if(this.apiClient.isVertexAI()){const g=hE(this.apiClient,n);return d=ne("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=gE(y),T=new P0;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="",p={};if(this.apiClient.isVertexAI()){const g=CE(this.apiClient,n);return d=ne("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=_E(y),T=new Y0;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 p,g="",y={};if(this.apiClient.isVertexAI()){const h=tE(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>Mr(T))}else{const h=eE(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>xr(T))}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=uE(this.apiClient,n);return g=ne("{models_url}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=cE(T),C=new Hp;return Object.assign(C,S),C})}else{const h=sE(this.apiClient,n);return g=ne("{models_url}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=rE(T),C=new Hp;return Object.assign(C,S),C})}}async update(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=wE(this.apiClient,n);return g=ne("{model}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>Mr(T))}else{const h=DE(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>xr(T))}}async delete(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=gS(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=vS(T),C=new zp;return Object.assign(C,S),C})}else{const h=hS(this.apiClient,n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=yS(T),C=new zp;return Object.assign(C,S),C})}}async countTokens(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=dS(this.apiClient,n);return g=ne("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=pS(T),C=new Vp;return Object.assign(C,S),C})}else{const h=fS(this.apiClient,n);return g=ne("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=mS(T),C=new Vp;return Object.assign(C,S),C})}}async computeTokens(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=iS(this.apiClient,n);return d=ne("{model}:computeTokens",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=oS(y),T=new J0;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 p,g="",y={};if(this.apiClient.isVertexAI()){const h=JS(this.apiClient,n);return g=ne("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>{const S=PS(T),C=new Ya;return Object.assign(C,S),C})}else{const h=YS(this.apiClient,n);return g=ne("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,p=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()),p.then(T=>{const S=kS(T),C=new Ya;return Object.assign(C,S),C})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class pC extends Al{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 p=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:p,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 p=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:p,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 p,g="",y={};if(this.apiClient.isVertexAI()){const h=H0(n);return g=ne("{operationName}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p}else{const h=G0(n);return g=ne("{operationName}",h._url),y=h._query,delete h._url,delete h._query,p=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()),p}}async fetchPredictVideosOperationInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=b0(n);return d=ne("{resourceName}:fetchPredictOperation",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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 hC(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 gC(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>AC(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function yC(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 p=u(n,["uses"]);o!==void 0&&p!=null&&c(o,["uses"],p);const g=u(n,["liveConnectConstraints"]);o!==void 0&&g!=null&&c(o,["bidiGenerateContentSetup"],_C(l,g));const y=u(n,["lockAdditionalFields"]);return o!==void 0&&y!=null&&c(o,["fieldMask"],y),s}function vC(l,n){const o={},s=u(n,["config"]);return s!=null&&c(o,["config"],yC(l,s,o)),o}function TC(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 SC(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 EC(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 CC(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 p=u(l,["topP"]);n!==void 0&&p!=null&&c(n,["setup","generationConfig","topP"],p);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 C=u(l,["thinkingConfig"]);n!==void 0&&C!=null&&c(n,["setup","generationConfig","thinkingConfig"],C);const R=u(l,["enableAffectiveDialog"]);n!==void 0&&R!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],R);const L=u(l,["systemInstruction"]);n!==void 0&&L!=null&&c(n,["setup","systemInstruction"],gC(At(L)));const U=u(l,["tools"]);if(n!==void 0&&U!=null){let ae=vi(U);Array.isArray(ae)&&(ae=ae.map(O=>MC(yi(O)))),c(n,["setup","tools"],ae)}const k=u(l,["sessionResumption"]);n!==void 0&&k!=null&&c(n,["setup","sessionResumption"],xC(k));const P=u(l,["inputAudioTranscription"]);n!==void 0&&P!=null&&c(n,["setup","inputAudioTranscription"],P);const F=u(l,["outputAudioTranscription"]);n!==void 0&&F!=null&&c(n,["setup","outputAudioTranscription"],F);const z=u(l,["realtimeInputConfig"]);n!==void 0&&z!=null&&c(n,["setup","realtimeInputConfig"],z);const $=u(l,["contextWindowCompression"]);n!==void 0&&$!=null&&c(n,["setup","contextWindowCompression"],$);const W=u(l,["proactivity"]);return n!==void 0&&W!=null&&c(n,["setup","proactivity"],W),o}function _C(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],Ie(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],CC(r,o)),o}function AC(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"],hC(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],TC(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);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 xC(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 MC(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"],EC(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"],SC(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);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 NC(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 RC(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=NC(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 p=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];r.length>0&&(g=r.map(h=>p.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 bC extends Al{constructor(n){super(),this.apiClient=n}async create(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=vC(this.apiClient,n);d=ne("auth_tokens",g._url),p=g._query,delete g.config,delete g._url,delete g._query;const y=RC(g,n.config);return r=this.apiClient.request({path:d,queryParams:p,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 DC(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function wC(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function UC(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 p=u(l,["batchSize"]);n!==void 0&&p!=null&&c(n,["tuningTask","hyperparameters","batchSize"],p);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 IC(l,n){const o={},s=u(l,["validationDataset"]);n!==void 0&&s!=null&&c(n,["supervisedTuningSpec"],XC(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 p=u(l,["epochCount"]);n!==void 0&&p!=null&&c(n,["supervisedTuningSpec","hyperParameters","epochCount"],p);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 qC(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"],OC(r));const d=u(l,["config"]);return d!=null&&UC(d,n),n}function LC(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"],FC(r,n));const d=u(l,["config"]);return d!=null&&IC(d,n),n}function GC(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function HC(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function zC(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 VC(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 BC(l){const n={},o=u(l,["config"]);return o!=null&&zC(o,n),n}function kC(l){const n={},o=u(l,["config"]);return o!=null&&VC(o,n),n}function PC(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(p=>Gh(p))),c(n,["tuningJobs"],d)}return n}function YC(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(p=>Rr(p))),c(n,["tuningJobs"],d)}return n}function JC(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 OC(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 FC(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 Gh(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"],yh(r));const d=u(l,["createTime"]);d!=null&&c(n,["createTime"],d);const p=u(l,["tuningTask","startTime"]);p!=null&&c(n,["startTime"],p);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"],JC(S));const C=u(l,["customBaseModel"]);C!=null&&c(n,["customBaseModel"],C);const R=u(l,["experiment"]);R!=null&&c(n,["experiment"],R);const L=u(l,["labels"]);L!=null&&c(n,["labels"],L);const U=u(l,["outputUri"]);U!=null&&c(n,["outputUri"],U);const k=u(l,["pipelineJob"]);k!=null&&c(n,["pipelineJob"],k);const P=u(l,["serviceAccount"]);P!=null&&c(n,["serviceAccount"],P);const F=u(l,["tunedModelDisplayName"]);F!=null&&c(n,["tunedModelDisplayName"],F);const z=u(l,["veoTuningSpec"]);return z!=null&&c(n,["veoTuningSpec"],z),n}function Rr(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"],yh(r));const d=u(l,["createTime"]);d!=null&&c(n,["createTime"],d);const p=u(l,["startTime"]);p!=null&&c(n,["startTime"],p);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 C=u(l,["tunedModel"]);C!=null&&c(n,["tunedModel"],C);const R=u(l,["preTunedModel"]);R!=null&&c(n,["preTunedModel"],R);const L=u(l,["supervisedTuningSpec"]);L!=null&&c(n,["supervisedTuningSpec"],L);const U=u(l,["tuningDataStats"]);U!=null&&c(n,["tuningDataStats"],U);const k=u(l,["encryptionSpec"]);k!=null&&c(n,["encryptionSpec"],k);const P=u(l,["partnerModelTuningSpec"]);P!=null&&c(n,["partnerModelTuningSpec"],P);const F=u(l,["customBaseModel"]);F!=null&&c(n,["customBaseModel"],F);const z=u(l,["experiment"]);z!=null&&c(n,["experiment"],z);const $=u(l,["labels"]);$!=null&&c(n,["labels"],$);const W=u(l,["outputUri"]);W!=null&&c(n,["outputUri"],W);const ae=u(l,["pipelineJob"]);ae!=null&&c(n,["pipelineJob"],ae);const O=u(l,["serviceAccount"]);O!=null&&c(n,["serviceAccount"],O);const Ce=u(l,["tunedModelDisplayName"]);Ce!=null&&c(n,["tunedModelDisplayName"],Ce);const le=u(l,["veoTuningSpec"]);return le!=null&&c(n,["veoTuningSpec"],le),n}function KC(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 p=u(l,["error"]);return p!=null&&c(n,["error"],p),n}function XC(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 QC extends Al{constructor(n){super(),this.apiClient=n,this.get=async o=>await this.getInternal(o),this.list=async(o={})=>new So(Cl.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 p="";return d.metadata!==void 0&&d.metadata.tunedModel!==void 0?p=d.metadata.tunedModel:d.name!==void 0&&d.name.includes("/operations/")&&(p=d.name.split("/operations/")[0]),{name:p,state:Er.JOB_STATE_QUEUED}}}}async getInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=HC(n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>Rr(T))}else{const h=GC(n);return g=ne("{name}",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>Gh(T))}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=kC(n);return g=ne("tuningJobs",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=YC(T),C=new Bp;return Object.assign(C,S),C})}else{const h=BC(n);return g=ne("tunedModels",h._url),y=h._query,delete h._url,delete h._query,p=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 C=S;return C.sdkHttpResponse={headers:T.headers},C})),p.then(T=>{const S=PC(T),C=new Bp;return Object.assign(C,S),C})}}async cancel(n){var o,s,r,d;let p="",g={};if(this.apiClient.isVertexAI()){const y=wC(n);p=ne("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,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=DC(n);p=ne("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,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="",p={};if(this.apiClient.isVertexAI()){const g=LC(n);return d=ne("tuningJobs",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=>Rr(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=qC(n);return d=ne("tunedModels",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,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=>KC(y))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class ZC{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 $C=1024*1024*8,WC=3,jC=1e3,e_=2,vr="x-goog-upload-status";async function t_(l,n,o){var s,r,d;let p=0,g=0,y=new Cr(new Response),h="upload";for(p=l.size;g=p&&(h+=", finalize");let R=0,L=jC;for(;RsetTimeout(n,l))}class i_{async upload(n,o,s){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await t_(n,o,s)}async stat(n){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await n_(n)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class o_{create(n,o,s){return new a_(n,o,s)}}class a_{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 ah="x-goog-api-key";class s_{constructor(n){this.apiKey=n}async addAuthHeaders(n){if(n.get(ah)===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(ah,this.apiKey)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const u_="gl-node/";class r_{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=N0(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 s_(this.apiKey);this.apiClient=new KE({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:n.httpOptions,userAgentExtra:u_+"web",uploader:new i_,downloader:new ZC}),this.models=new mC(this.apiClient),this.live=new aC(this.apiClient,r,new o_),this.batches=new Fv(this.apiClient),this.chats=new AT(this.models,this.apiClient),this.caches=new ET(this.apiClient),this.files=new qT(this.apiClient),this.operations=new pC(this.apiClient),this.authTokens=new bC(this.apiClient),this.tunings=new QC(this.apiClient)}}const c_="AIzaSyCl4hPv_njJ9qLytv1QNPE3MmCFZJr9Wgk";let za=null;function zr(){return za||(za=new r_({apiKey:c_}),za)}const f_=[{name:"readFile",parameters:{type:it.OBJECT,description:"Reads the content of a file from the repository.",properties:{filePath:{type:it.STRING,description:"The full path of the file to read, relative to the repository root."}},required:["filePath"]}},{name:"createFile",parameters:{type:it.OBJECT,description:"Creates a new file in the repository with the given content. The file path should be a full path from the repository root. Directories will be created if they do not exist.",properties:{filePath:{type:it.STRING,description:"The full path for the new file."},content:{type:it.STRING,description:"The content of the new file."}},required:["filePath","content"]}},{name:"updateFile",parameters:{type:it.OBJECT,description:"Updates the content of an existing file.",properties:{filePath:{type:it.STRING,description:"The full path of the file to update."},newContent:{type:it.STRING,description:"The new, complete content for the file."}},required:["filePath","newContent"]}}];function d_(){return zr().chats.create({model:"gemini-2.5-flash",config:{systemInstruction:` +You are an expert AI code assistant with agentic capabilities. Your goal is to help the user with their coding tasks by modifying the repository's files. + +You have been provided with a set of tools to interact with the file system: \`readFile\`, \`createFile\`, and \`updateFile\`. + +**Workflow:** +1. **Analyze the Request:** Carefully read the user's instruction, the currently open file's content, and the repository's file tree. +2. **Plan:** Formulate a plan to fulfill the request. You may need to read other files for context before making changes. +3. **Execute:** Use the provided tools to execute your plan. + - Use \`readFile\` to understand existing code in other files. + - Use \`updateFile\` to modify an existing file. + - Use \`createFile\` to add new files. +4. **Feature Expansion Mandate:** After you have successfully completed the user's primary request, you MUST enter a "Feature Expansion" phase. In this phase, you are required to brainstorm and create exactly 5 new files, each containing a new, fully coded feature that is relevant to the original request. Use the \`createFile\` tool for each new feature. Announce that you are starting this phase before you begin. +5. **Respond:** Once you have completed all file operations, including the 5 mandatory new feature files, respond with a concise summary of all the changes you made. Do not respond with a summary until you are completely finished. +`,tools:[{functionDeclarations:f_}]}})}async function m_(l){const n=zr(),o=` +You are a senior software architect. Based on the user's request, create a file and folder structure for a new software project. +Your output MUST be a JSON object that adheres to the provided schema. +Do not include any explanations or markdown. Just the JSON object. +For each file, provide a concise, one-sentence description of its purpose. This description will be used to generate the file's content later. + +User Request: +"${l}" +`,r=(await n.models.generateContent({model:"gemini-2.5-flash",contents:o,config:{responseMimeType:"application/json",responseSchema:{type:it.OBJECT,properties:{files:{type:it.ARRAY,items:{type:it.OBJECT,properties:{path:{type:it.STRING},description:{type:it.STRING}},required:["path","description"]}}},required:["files"]}}})).text.trim();try{const d=JSON.parse(r);if(d&&Array.isArray(d.files))return d;throw new Error("Invalid structure in parsed JSON.")}catch(d){throw console.error("Failed to parse project plan JSON:",r,d),new Error("AI failed to generate a valid project plan.")}}async function Hh(l,n){try{const s=await zr().models.generateContentStream({model:"gemini-2.5-flash",contents:l});for await(const r of s){const d=r.text;d&&n(d)}}catch(o){throw console.error("Error calling Gemini API:",o),o instanceof Error?new Error(`AI request failed: ${o.message}`):new Error("Failed to get response from AI due to an unknown error.")}}async function p_(l,n,o,s){const r=` +You are an expert AI programmer. Your high-level task is: "${l}". +You are currently editing the file at path \`${n}\`. +Its current content is: +--- +${o} +--- + +Based on the high-level task, please generate the new, complete content for this specific file. +Return ONLY the complete code for the file. Do not include any explanations, markdown fences, or other text outside of the code itself. +`;await Hh(r,s)}async function h_(l,n,o,s){const r=` +You are an expert AI programmer. You are building a new project based on the overall goal: "${l}". +Your current task is to generate the complete code for the file at this path: \`${n}\`. +The purpose of this file is: "${o}". + +You are generating this file from scratch. +Return ONLY the complete code for the file. Do not include any explanations, markdown fences, or other text outside of the code itself. +Adhere to best practices for the technologies involved. +If you are generating a package.json, ensure it contains valid JSON. + +--- +Generated Code for \`${n}\`: +`;await Hh(r,s)}const g_="https://www.googleapis.com/auth/drive.readonly";let br=!1,ka=!1,Dr=null,gi=null,Tr={apiKey:"",clientId:""};const y_=l=>new Promise((n,o)=>{if(br){n();return}if(typeof gapi>"u")return o(new Error("gapi client not loaded."));gapi.load("client:picker",()=>{gapi.client.init({apiKey:l,discoveryDocs:["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"]}).then(()=>{br=!0,n()}).catch(o)})}),v_=l=>new Promise((n,o)=>{if(ka&&gi){n();return}if(typeof google>"u")return o(new Error("Google Identity Services not loaded."));try{Dr=google.accounts.oauth2.initTokenClient({client_id:l,scope:g_,callback:s=>{s&&s.access_token?(gi=s,ka=!0,n()):o(new Error("Authentication failed: No access token received."))},error_callback:s=>{o(new Error(`GSI Error: ${s.error||"Unknown error"}`))}}),gi?(ka=!0,n()):Dr.requestAccessToken({prompt:"consent"})}catch(s){o(new Error(`Failed to initialize Google Auth: ${s.message}`))}}),T_=(l,n,o,s)=>{const r=new google.picker.View(google.picker.ViewId.DOCS);new google.picker.PickerBuilder().enableFeature(google.picker.Feature.NAV_HIDDEN).setAppId((o==null?void 0:o.split("-")[0])||"").setOAuthToken(l.access_token).addView(r).setDeveloperKey(n).setCallback(s).build().setVisible(!0)},S_=async l=>(await gapi.client.drive.files.get({fileId:l,alt:"media"})).body,E_=async(l,n)=>{if(!l||!n)throw new Error("Google API Key or Client ID is not provided.");if((Tr.apiKey!==l||Tr.clientId!==n)&&(br=!1,ka=!1,gi=null,Dr=null,Tr={apiKey:l,clientId:n}),await y_(l),await v_(n),!gi)throw new Error("Google authentication failed or was cancelled.");return new Promise((o,s)=>{T_(gi,l,n,async d=>{var p,g;if(d[google.picker.Action.PICKED]){const y=d[google.picker.Response.DOCUMENTS][0],h=y[google.picker.Document.ID],T=y[google.picker.Document.NAME];try{const S=await S_(h);o({name:T,content:S})}catch(S){s(new Error(`Failed to download file: ${((g=(p=S.result)==null?void 0:p.error)==null?void 0:g.message)||S.message}`))}}else d[google.picker.Action.CANCEL]&&s(new Error("Google Picker was cancelled."))})})},C_=({alert:l,onClose:n})=>{if(X.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 _.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:[_.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; + } + `}),_.jsx("p",{children:l.message})]})},__=({onClose:l,onSubmit:n})=>{const[o,s]=X.useState(""),[r,d]=X.useState(""),[p,g]=X.useState(!0),[y,h]=X.useState(!1),[T,S]=X.useState(""),C=async R=>{if(R.preventDefault(),S(""),!(!o.trim()||!r.trim()||y)){h(!0);try{await n(o.trim().replace(/\s+/g,"-"),r,p)}catch(L){S(L instanceof Error?L.message:"An unknown error occurred."),h(!1)}}};return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:_.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:R=>R.stopPropagation(),children:[_.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"New AI Project"}),_.jsx("p",{className:"text-gray-400 mb-6 text-sm",children:"Describe the project you want to build. The AI will create a new repository, plan the file structure, and generate all the necessary code."}),_.jsxs("form",{onSubmit:C,children:[_.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[_.jsxs("div",{className:"md:col-span-2",children:[_.jsx("label",{htmlFor:"repoName",className:"block text-sm font-medium text-gray-300 mb-2",children:"New Repository Name"}),_.jsx("input",{id:"repoName",type:"text",value:o,onChange:R=>s(R.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:"my-new-ai-project",required:!0,autoFocus:!0})]}),_.jsxs("div",{children:[_.jsx("label",{htmlFor:"repoVisibility",className:"block text-sm font-medium text-gray-300 mb-2",children:"Visibility"}),_.jsxs("select",{id:"repoVisibility",value:p?"private":"public",onChange:R=>g(R.target.value==="private"),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",children:[_.jsx("option",{value:"private",children:"Private"}),_.jsx("option",{value:"public",children:"Public"})]})]})]}),_.jsxs("div",{className:"mb-4",children:[_.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"Project Description"}),_.jsx("textarea",{id:"prompt",value:r,onChange:R=>d(R.target.value),placeholder:"e.g., 'A simple to-do list app using React, TypeScript, and Tailwind CSS. It should have a main component to display and add tasks.'",className:"w-full h-40 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none",required:!0})]}),T&&_.jsx("p",{className:"text-red-400 text-sm mb-4",children:T}),_.jsxs("div",{className:"flex justify-end gap-4",children:[_.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:y,children:"Cancel"}),_.jsx("button",{type:"submit",disabled:y||!o.trim()||!r.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-[150px]",children:y?_.jsx(en,{}):"Generate Project"})]})]})]})})},A_=({status:l})=>{switch(l){case"queued":return _.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"generating":return _.jsx(en,{className:"w-4 h-4 text-blue-400"});case"committing":return _.jsx(en,{className:"w-4 h-4 text-yellow-400"});case"success":return _.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 flex-shrink-0",children:"✓"});case"failed":return _.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 flex-shrink-0",children:"!"});default:return null}},x_=({jobs:l,statusMessage:n,onClose:o,isComplete:s})=>{const r=l.filter(y=>y.status==="success"||y.status==="failed").length,d=l.filter(y=>y.status==="success").length,p=l.length>0?r/l.length*100:0,g=l.find(y=>y.status==="generating"||y.status==="committing");return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:_.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-4xl h-[75vh] flex flex-col border border-gray-700",children:[_.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[_.jsx("h2",{className:"text-2xl font-bold text-indigo-400",children:"AI Project Generation"}),s&&_.jsx("button",{onClick:o,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),_.jsxs("div",{className:"mb-4 flex-shrink-0",children:[_.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[_.jsxs("span",{className:"flex items-center gap-2",children:[!s&&_.jsx(en,{className:"h-4 w-4"}),n]}),_.jsx("span",{children:`${d} / ${l.length} files successful`})]}),_.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:_.jsx("div",{className:"bg-indigo-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${p}%`}})})]}),_.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[_.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[_.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Plan"}),_.jsx("ul",{className:"space-y-1",children:l.map(y=>_.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[_.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[_.jsx(A_,{status:y.status}),_.jsx("span",{className:"truncate",title:y.path,children:y.path})]}),y.status==="failed"&&_.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:y.error||"Unknown error",children:"Error"})]},y.id))})]}),_.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[_.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"Live Generation"}),g?_.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[_.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:g.path,children:[g.status==="generating"?"Generating":"Committing",": ",_.jsx("span",{className:"font-bold",children:g.path})]}),_.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:_.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:_.jsx("code",{children:g.content})})})]}):_.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:s?"All files generated.":"Waiting to generate..."})]})]})]})})},M_=({driveFile:l,fileTree:n,branchesByRepo:o,onClose:s,onSubmit:r,isLoading:d,onFetchBranches:p})=>{const g=Object.keys(n).sort(),[y,h]=X.useState(g[0]||""),[T,S]=X.useState(""),[C,R]=X.useState(l.name),[L,U]=X.useState(`feat: Add ${l.name} from Google Drive`);X.useEffect(()=>{R(l.name),U(`feat: Add ${l.name} from Google Drive`)},[l]),X.useEffect(()=>{var z;if(y){const $=(z=n[y])==null?void 0:z.repo;$&&(o[y]||p(y),S($.default_branch))}},[y,n,o,p]);const k=z=>{const $=z.target.value;h($)},P=z=>{z.preventDefault(),!(d||!y||!T||!C.trim()||!L.trim())&&r(y,T,C.trim(),L.trim())},F=o[y]||[];return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:s,children:_.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:z=>z.stopPropagation(),children:[_.jsx("h2",{className:"text-xl font-bold text-blue-400 mb-2",children:"Commit File from Google Drive"}),_.jsxs("p",{className:"text-gray-400 mb-6",children:["Committing: ",_.jsx("span",{className:"font-semibold text-gray-200",children:l.name})]}),_.jsxs("form",{onSubmit:P,children:[_.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[_.jsxs("div",{children:[_.jsx("label",{htmlFor:"repo-select",className:"block text-sm font-medium text-gray-300 mb-2",children:"Repository"}),_.jsx("select",{id:"repo-select",value:y,onChange:k,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-blue-500",children:g.map(z=>_.jsx("option",{value:z,children:z},z))})]}),_.jsxs("div",{children:[_.jsx("label",{htmlFor:"branch-select",className:"block text-sm font-medium text-gray-300 mb-2",children:"Branch"}),_.jsx("select",{id:"branch-select",value:T,onChange:z=>S(z.target.value),disabled:!y||F.length===0,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-blue-500",children:F.map(z=>_.jsx("option",{value:z.name,children:z.name},z.name))})]})]}),_.jsxs("div",{className:"mb-4",children:[_.jsx("label",{htmlFor:"file-path",className:"block text-sm font-medium text-gray-300 mb-2",children:"File Path"}),_.jsx("input",{id:"file-path",type:"text",value:C,onChange:z=>R(z.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-blue-500",placeholder:"path/to/your/file.txt",required:!0})]}),_.jsxs("div",{className:"mb-6",children:[_.jsx("label",{htmlFor:"commit-message",className:"block text-sm font-medium text-gray-300 mb-2",children:"Commit Message"}),_.jsx("input",{id:"commit-message",type:"text",value:L,onChange:z=>U(z.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-blue-500",required:!0})]}),_.jsxs("div",{className:"flex justify-end gap-4",children:[_.jsx("button",{type:"button",onClick:s,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"}),_.jsx("button",{type:"submit",disabled:d||!y||!T||!C.trim()||!L.trim(),className:"px-4 py-2 bg-blue-600 text-white font-semibold rounded-md hover:bg-blue-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:d?_.jsx(en,{}):"Commit to GitHub"})]})]})]})})},N_=({log:l})=>{let n,o="text-gray-300";switch(l.type){case"info":n="â„šī¸",o="text-gray-400";break;case"tool-call":n="đŸ› ī¸",o="text-yellow-400";break;case"tool-result":n="✅",o="text-green-400";break;case"model-response":n="🤖",o="text-indigo-400";break;case"error":n="❌",o="text-red-400";break}return _.jsxs("div",{className:`flex items-start gap-3 p-2 text-sm ${o}`,children:[_.jsx("span",{className:"flex-shrink-0",children:n}),_.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans",children:l.message})]})},R_=({onClose:l,onSubmit:n,agentState:o})=>{const[s,r]=X.useState(""),d=X.useRef(null),p=o.status==="running",g=o.status==="complete"||o.status==="error";X.useEffect(()=>{var T;(T=d.current)==null||T.scrollIntoView({behavior:"smooth"})},[o.logs]);const y=T=>{T.preventDefault(),!(!s.trim()||p)&&n(s)},h=()=>{l()};return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:h,children:_.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-3xl h-[80vh] flex flex-col border border-gray-700",onClick:T=>T.stopPropagation(),children:[_.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"AI Code Agent"}),o.status==="idle"?_.jsxs("form",{onSubmit:y,className:"flex flex-col h-full",children:[_.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Describe the changes you want to make. The AI can read files, and create or update files across the repository to complete your request."}),_.jsx("textarea",{value:s,onChange:T=>r(T.target.value),placeholder:"e.g., 'Refactor the authentication logic into its own service file and update the main App component to use it.'",className:"w-full flex-grow 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}),_.jsxs("div",{className:"flex justify-end gap-4",children:[_.jsx("button",{type:"button",onClick:h,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Cancel"}),_.jsx("button",{type:"submit",disabled:!s.trim(),className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700 disabled:bg-gray-500",children:"Engage Agent"})]})]}):_.jsxs("div",{className:"flex flex-col flex-grow min-h-0",children:[_.jsxs("div",{className:"bg-gray-900 p-4 rounded-md flex-grow overflow-y-auto",children:[o.logs.map((T,S)=>_.jsx(N_,{log:T},S)),p&&_.jsxs("div",{className:"flex items-center gap-2 text-gray-400 p-2",children:[_.jsx(en,{className:"h-4 w-4"}),_.jsx("span",{children:"AI is thinking..."})]}),_.jsx("div",{ref:d})]}),_.jsx("div",{className:"flex justify-end pt-4",children:_.jsx("button",{type:"button",onClick:h,className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700",children:g?"Close":"Close (Agent will continue in background)"})})]})]})})},b_=({fileCount:l,onClose:n,onSubmit:o})=>{const[s,r]=X.useState(""),[d,p]=X.useState(!1),g=async y=>{y.preventDefault(),!(!s.trim()||d)&&(p(!0),await o(s))};return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:n,children:_.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:[_.jsx("h2",{className:"text-xl font-bold text-amber-400 mb-2",children:"Multi-File AI Edit"}),_.jsxs("p",{className:"text-gray-400 mb-4",children:[l," file",l>1?"s":""," selected for editing."]}),_.jsxs("div",{className:"bg-red-900 border border-red-700 text-red-200 p-3 rounded-md mb-6 text-sm",children:[_.jsxs("p",{children:[_.jsx("strong",{children:"Warning:"})," This is an experimental feature. It will:"]}),_.jsxs("ul",{className:"list-disc list-inside mt-2",children:[_.jsxs("li",{children:["Commit changes directly to the ",_.jsx("strong",{children:"current branch"})," for each repository."]}),_.jsxs("li",{children:["Process up to ",_.jsx("strong",{children:"5 files concurrently"})," based on your instruction."]}),_.jsx("li",{children:"This may take a long time and consume significant API resources for a large number of files."})]}),_.jsx("p",{className:"mt-2",children:"It is highly recommended to create a new branch before starting and to review all changes carefully."})]}),_.jsxs("form",{onSubmit:g,children:[_.jsxs("div",{className:"mb-4",children:[_.jsx("label",{htmlFor:"instruction",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Instruction for All Selected Files"}),_.jsx("textarea",{id:"instruction",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})]}),_.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[_.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"}),_.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?_.jsx(en,{}):"Start AI Edit"})]})]})]})})},D_=({status:l})=>{switch(l){case"queued":return _.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"processing":return _.jsx(en,{className:"w-4 h-4 text-blue-400"});case"success":return _.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 flex-shrink-0",children:"✓"});case"skipped":return _.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 flex-shrink-0",children:"-"});case"failed":return _.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 flex-shrink-0",children:"!"});default:return null}},w_=({jobs:l,onClose:n,isComplete:o})=>{const s=l.filter(g=>g.status==="success"||g.status==="skipped"||g.status==="failed").length,r=l.filter(g=>g.status==="success").length,d=l.length>0?s/l.length*100:0,p=l.filter(g=>g.status==="processing");return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:_.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:[_.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[_.jsx("h2",{className:"text-2xl font-bold text-amber-400",children:"AI Bulk Edit Progress"}),o&&_.jsx("button",{onClick:n,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),_.jsxs("div",{className:"mb-4 flex-shrink-0",children:[_.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[_.jsx("span",{children:`Overall Progress (${s} / ${l.length})`}),_.jsxs("span",{children:[r," successful"]})]}),_.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:_.jsx("div",{className:"bg-amber-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${d}%`}})})]}),_.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[_.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[_.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Queue"}),_.jsx("ul",{className:"space-y-1",children:l.map(g=>_.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[_.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[_.jsx(D_,{status:g.status}),_.jsx("span",{className:"truncate",title:g.path,children:g.path})]}),g.status==="failed"&&_.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:g.error||"Unknown error",children:"Error"})]},g.id))})]}),_.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[_.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",p.length," active)"]}),p.length>0?_.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 flex-grow min-h-0",children:p.slice(0,5).map(g=>_.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[_.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:g.path,children:["Processing: ",_.jsx("span",{className:"font-bold",children:g.path.split("::")[1]})]}),_.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:_.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:_.jsx("code",{children:g.content})})})]},g.id))}):_.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:o?"All jobs complete.":"Waiting for next job..."})]})]})]})})},U_=({onClose:l,onSubmit:n})=>{const[o,s]=X.useState(""),[r,d]=X.useState(""),p=g=>{g.preventDefault(),!(!o.trim()||!r.trim())&&n({apiKey:o.trim(),clientId:r.trim()})};return _.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:_.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:[_.jsx("h2",{className:"text-xl font-bold text-blue-400 mb-4",children:"Google Drive API Keys"}),_.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"To import files from Google Drive, provide your own Google Cloud API Key and OAuth 2.0 Client ID."}),_.jsx("p",{className:"text-gray-400 mb-6 text-sm",children:"These keys are not stored and are only used for this session."}),_.jsxs("form",{onSubmit:p,children:[_.jsxs("div",{className:"mb-4",children:[_.jsx("label",{htmlFor:"google-api-key",className:"block text-sm font-medium text-gray-300 mb-2",children:"Google API Key"}),_.jsx("input",{id:"google-api-key",type:"password",value:o,onChange:g=>s(g.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-blue-500",placeholder:"Enter your API Key",required:!0})]}),_.jsxs("div",{className:"mb-6",children:[_.jsx("label",{htmlFor:"google-client-id",className:"block text-sm font-medium text-gray-300 mb-2",children:"Google Client ID"}),_.jsx("input",{id:"google-client-id",type:"password",value:r,onChange:g=>d(g.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-blue-500",placeholder:"Enter your Client ID",required:!0})]}),_.jsx("a",{href:"https://developers.google.com/drive/api/v3/picker#enable-the-api",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-400 hover:underline mb-6 block",children:"How to get these keys?"}),_.jsxs("div",{className:"flex justify-end gap-4",children:[_.jsx("button",{type:"button",onClick:l,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Cancel"}),_.jsx("button",{type:"submit",disabled:!o.trim()||!r.trim(),className:"px-4 py-2 bg-blue-600 text-white font-semibold rounded-md hover:bg-blue-700 disabled:bg-gray-500",children:"Save Keys"})]}),_.jsx("p",{className:"text-xs text-gray-500 mt-4 text-center",children:'After saving, click the "Import from Drive" button again to open the picker.'})]})]})})},_l=l=>{let n=[];for(const o of l)o.type==="file"?n.push(o.path):o.type==="dir"&&(n=n.concat(_l(o.children)));return n};function I_(){const[l,n]=X.useState(null),[o,s]=X.useState({}),[r,d]=X.useState([]),[p,g]=X.useState(null),[y,h]=X.useState(!1),[T,S]=X.useState(""),[C,R]=X.useState(null),[L,U]=X.useState({}),[k,P]=X.useState({}),[F,z]=X.useState(!1),[$,W]=X.useState(!1),[ae,O]=X.useState([]),[Ce,le]=X.useState(""),[ve,be]=X.useState(null),[Te,Oe]=X.useState(!1),[Ct,me]=X.useState({status:"idle",logs:[]}),q=X.useRef(null),[Y,ce]=X.useState(new Set),[Ge,qe]=X.useState(!1),[M,B]=X.useState(!1),[K,Q]=X.useState([]),[de,Ee]=X.useState(null),[De,ot]=X.useState(!1),te=r.find(J=>J.repoFullName+"::"+J.path===p),gt=te?k[te.repoFullName]:null,wn=te?L[te.repoFullName]||[]:[],Si=X.useCallback(async J=>{if(J){n(J),h(!0),S("Fetching repositories...");try{const j=await v0(J),fe={},Z=j.map(async oe=>{S(`Processing ${oe.owner.login}/${oe.name}...`);try{const ue=await Ha(J,oe.owner.login,oe.name,oe.default_branch);fe[oe.full_name]={repo:oe,tree:ue}}catch(ue){console.error(`Failed to fetch tree for ${oe.full_name}`,ue),ue instanceof Error&&ue.message.includes("409")&&(at("error",`Repository ${oe.full_name} is empty.`),fe[oe.full_name]={repo:oe,tree:[]})}});await Promise.all(Z),s(fe),at("success","Successfully loaded all repositories.")}catch(j){console.error(j),n(null),at("error",`Login failed. ${j instanceof Error?j.message:"Please check your token and permissions."}`)}finally{h(!1),S("")}}},[]),at=(J,j)=>{R({type:J,message:j})},tn=X.useCallback(async(J,j,fe)=>{var oe;const Z=`${J}::${j}`;if(r.some(ue=>ue.repoFullName+"::"+ue.path===Z)){g(Z);return}if(l){h(!0),S(`Loading ${j}...`);try{const[ue,We]=J.split("/"),dt=(oe=o[J])==null?void 0:oe.repo;if(!dt)throw new Error("Repository data not found");if(!L[J]){S("Fetching branches...");const Re=await yr(l,ue,We);U(ze=>({...ze,[J]:Re}))}const tt=fe||k[J]||dt.default_branch;P(Re=>({...Re,[J]:tt})),S(`Loading ${j} from branch ${tt}...`);const Qe=await ci(l,ue,We,j,tt),pe={repoFullName:J,path:Qe.path,content:Qe.content,editedContent:Qe.content,sha:Qe.sha,defaultBranch:dt.default_branch};d(Re=>[...Re,pe]),g(Z)}catch(ue){console.error(ue),at("error",`Failed to load file: ${j}`)}finally{h(!1),S("")}}},[l,o,r,L,k]),Ei=X.useCallback(J=>{const j=r.findIndex(Z=>Z.repoFullName+"::"+Z.path===J);if(j===-1)return;const fe=r.filter(Z=>Z.repoFullName+"::"+Z.path!==J);if(d(fe),p===J)if(fe.length===0)g(null);else{const Z=Math.max(0,j-1),oe=fe[Z];g(oe.repoFullName+"::"+oe.path)}},[r,p]),Ci=X.useCallback(J=>{g(J)},[]),Qa=X.useCallback((J,j)=>{d(fe=>fe.map(Z=>Z.repoFullName+"::"+Z.path===J?{...Z,editedContent:j}:Z))},[]),Nt=J=>{me(j=>({...j,logs:[...j.logs,J]}))},_i=async J=>{if(!te||!l)return;me({status:"running",logs:[{type:"info",message:"Starting AI agent..."}]}),q.current=d_();const j=q.current,[fe,Z]=te.repoFullName.split("/"),oe=(tt,Qe="")=>{let pe="";for(const Re of tt)pe+=`${Qe}${Re.name}${Re.type==="dir"?"/":""} +`,Re.type==="dir"&&(pe+=oe(Re.children,Qe+" "));return pe},ue=oe(o[te.repoFullName].tree),We=` +User Instruction: "${J}" + +Current open file: \`${te.path}\` + +Content of \`${te.path}\`: +--- +${te.editedContent} +--- + +Full repository file tree: +--- +${ue} +--- +Now, please analyze the request and begin executing the plan. +`;Nt({type:"info",message:"Sending initial prompt to AI..."});let dt=await j.sendMessage({message:We});for(;;){const tt=dt.functionCalls;if(tt&&tt.length>0){Nt({type:"tool-call",message:`Model wants to call: ${tt.map(pe=>pe.name).join(", ")}`,data:tt});const Qe=[];for(const pe of tt){let Re,ze=null;const Ze=k[te.repoFullName];try{switch(pe.name){case"readFile":{const{filePath:ge}=pe.args;Nt({type:"info",message:`Reading file: ${ge}`}),Re=(await ci(l,fe,Z,ge,Ze)).content;break}case"updateFile":{const{filePath:ge,newContent:He}=pe.args;Nt({type:"info",message:`Updating file: ${ge}`});const mt=await ci(l,fe,Z,ge,Ze);await fi({token:l,owner:fe,repo:Z,branch:Ze,path:ge,content:He,message:`[AI] Update ${ge}`,sha:mt.sha}),Re=`Successfully updated ${ge}.`;const sn=`${te.repoFullName}::${ge}`;if(r.some(Pt=>Pt.repoFullName+"::"+Pt.path===sn)){const Pt=await ci(l,fe,Z,ge,Ze);d(ja=>ja.map(il=>il.repoFullName+"::"+il.path===sn?{...il,content:Pt.content,editedContent:Pt.content,sha:Pt.sha}:il))}break}case"createFile":{const{filePath:ge,content:He}=pe.args;Nt({type:"info",message:`Creating new file: ${ge}`}),await fi({token:l,owner:fe,repo:Z,branch:Ze,path:ge,content:He,message:`[AI] Create ${ge}`}),Re=`Successfully created ${ge}.`;break}default:ze=`Unknown tool: ${pe.name}`}}catch(ge){ze=ge instanceof Error?ge.message:"An unknown error occurred during tool execution."}ze?(Nt({type:"error",message:`Error executing tool ${pe.name}: ${ze}`}),Qe.push({functionResponse:{name:pe.name,response:{error:ze}}})):(Nt({type:"tool-result",message:`Result for ${pe.name}`,data:Re}),Qe.push({functionResponse:{name:pe.name,response:{result:Re}}}))}if(Qe.length>0)dt=await j.sendMessage({parts:Qe});else{Nt({type:"info",message:"Model returned no tool calls to respond to. Ending agent run."});break}}else{Nt({type:"model-response",message:"AI has finished.",data:dt.text}),me(pe=>({...pe,status:"complete"})),Nt({type:"info",message:"Refreshing file explorer..."});const Qe=await Ha(l,fe,Z,k[te.repoFullName]);s(pe=>({...pe,[te.repoFullName]:{...pe[te.repoFullName],tree:Qe}}));break}}},Ai=async J=>{!J.trim()||!te||(Oe(!0),_i(J).catch(j=>{console.error("AI Agent failed:",j),Nt({type:"error",message:`Agent failed: ${j.message}`}),me(fe=>({...fe,status:"error"}))}))},xi=X.useCallback(async J=>{if(!(!l||!te||!gt)){h(!0),S("Committing changes...");try{const[j,fe]=te.repoFullName.split("/");await fi({token:l,owner:j,repo:fe,branch:gt,path:te.path,content:te.editedContent,message:J,sha:te.sha});const Z=await ci(l,j,fe,te.path,gt);d(oe=>oe.map(ue=>ue.repoFullName+"::"+ue.path===p?{...ue,content:Z.content,editedContent:Z.content,sha:Z.sha}:ue)),at("success","Commit successful!")}catch(j){console.error(j),at("error",`Failed to commit changes: ${j.message}`)}finally{h(!1),S("")}}},[l,te,gt,p]),Za=X.useCallback(J=>{if(te){const j=te.repoFullName;P(oe=>({...oe,[j]:J}));const fe=r.filter(oe=>oe.repoFullName===j),Z=r.filter(oe=>oe.repoFullName!==j);d(Z),g(Z[0]?Z[0].repoFullName+"::"+Z[0].path:null),fe.forEach(oe=>{tn(oe.repoFullName,oe.path,J)})}},[te,r,tn]),$a=X.useCallback(async J=>{if(!(!l||!te||!gt)){h(!0),S(`Creating branch ${J}...`);try{const[j,fe]=te.repoFullName.split("/"),Z=wn.find(ue=>ue.name===gt);if(!Z)throw new Error("Base branch not found");await S0(l,j,fe,J,Z.commit.sha);const oe=await yr(l,j,fe);U(ue=>({...ue,[te.repoFullName]:oe})),P(ue=>({...ue,[te.repoFullName]:J})),at("success",`Branch '${J}' created successfully.`)}catch(j){console.error(j),at("error",`Failed to create branch: ${j.message}`)}finally{h(!1),S("")}}},[l,te,gt,wn]),xt=X.useCallback(async(J,j)=>{if(!(!l||!te||!gt)){h(!0),S("Creating pull request...");try{const[fe,Z]=te.repoFullName.split("/"),oe=await _0({token:l,owner:fe,repo:Z,title:J,body:j,head:gt,base:te.defaultBranch});at("success",`Successfully created Pull Request #${oe.number}!`),window.open(oe.html_url,"_blank")}catch(fe){console.error(fe),at("error",`Failed to create pull request: ${fe.message}`)}finally{h(!1),S("")}}},[l,te,gt]),Eo=X.useCallback(async J=>{if(l)try{const j=await Ha(l,J.owner.login,J.name,J.default_branch);s(fe=>({...fe,[J.full_name]:{repo:J,tree:j}}))}catch(j){console.error(`Failed to refresh tree for new repo ${J.full_name}`,j),at("error","Project generated, but failed to refresh file explorer.")}},[l]),Co=X.useCallback(async(J,j,fe)=>{if(!l)return;z(!1),W(!0),O([]);let Z=null;try{le(`Creating repository '${J}'...`),Z=await E0({token:l,name:J,description:j,isPrivate:fe}),at("success",`Repository '${Z.full_name}' created.`),le("Asking AI to plan project structure...");const ue=(await m_(j)).files.map(pe=>({id:pe.path,path:pe.path,description:pe.description,status:"queued",content:"",error:null}));O(ue),le(`Generating ${ue.length} files...`);const We=async pe=>{const Re=ue.find(ge=>ge.id===pe);if(!Re||!l||!Z)return;O(ge=>ge.map(He=>He.id===pe?{...He,status:"generating"}:He));let ze="";const Ze=ge=>{ze+=ge,O(He=>He.map(mt=>mt.id===pe?{...mt,content:ze}:mt))};await h_(j,Re.path,Re.description,Ze),O(ge=>ge.map(He=>He.id===pe?{...He,status:"committing"}:He)),await fi({token:l,owner:Z.owner.login,repo:Z.name,branch:Z.default_branch,path:Re.path,content:ze,message:`[AI] Create ${Re.path}`}),O(ge=>ge.map(He=>He.id===pe?{...He,status:"success"}:He))},dt=5,tt=[...ue],Qe=async()=>{for(;tt.length>0;){const pe=tt.shift();if(pe)try{await We(pe.id)}catch(Re){const ze=Re instanceof Error?Re.message:"An unknown error occurred.";O(Ze=>Ze.map(ge=>ge.id===pe.id?{...ge,status:"failed",error:ze}:ge))}}};await Promise.all(Array(dt).fill(null).map(Qe)),le("Finalizing..."),await Eo(Z),at("success",`Project '${Z.full_name}' generated successfully!`)}catch(oe){const ue=oe instanceof Error?oe.message:"An unknown error occurred.";at("error",`Project generation failed: ${ue}`);return}},[l,Eo]),_o=X.useCallback(async()=>{if(!de){ot(!0);return}h(!0),S("Opening Google Drive...");try{const J=await E_(de.apiKey,de.clientId);be(J)}catch(J){console.error(J);const j=J instanceof Error?J.message:"An unknown error occurred";at("error",`Import failed: ${j}. Please check keys and permissions.`),Ee(null),ot(!0)}finally{h(!1),S("")}},[de]),xl=J=>{Ee(J),ot(!1)},Wa=X.useCallback(async(J,j,fe,Z)=>{if(!(!l||!ve)){h(!0),S("Committing file from Google Drive...");try{const[oe,ue]=J.split("/");await fi({token:l,owner:oe,repo:ue,branch:j,path:fe,content:ve.content,message:Z,sha:void 0}),at("success",`File '${fe}' committed successfully to ${J}.`),be(null);const We=await Ha(l,oe,ue,j);s(dt=>({...dt,[J]:{...dt[J],tree:We}}))}catch(oe){console.error(oe),at("error",`Failed to commit file: ${oe.message}`)}finally{h(!1),S("")}}},[l,ve]),Ao=X.useCallback(async J=>{if(!l||Y.size===0)return;qe(!1);const j=Array.from(Y).map(We=>({id:We,path:We,status:"queued",content:"",error:null}));Q(j),B(!0);const fe=async We=>{const[dt,tt]=We.split("::"),[Qe,pe]=dt.split("/"),Re=k[dt]||o[dt].repo.default_branch;if(!Re){Q(ze=>ze.map(Ze=>Ze.id===We?{...Ze,status:"failed",error:"Could not determine branch."}:Ze));return}try{Q(He=>He.map(mt=>mt.id===We?{...mt,status:"processing"}:mt));const ze=await ci(l,Qe,pe,tt,Re);let Ze="";const ge=He=>{Ze+=He,Q(mt=>mt.map(sn=>sn.id===We?{...sn,content:Ze}:sn))};await p_(J,tt,ze.content,ge),await fi({token:l,owner:Qe,repo:pe,branch:Re,path:tt,content:Ze,message:`[AI] Bulk edit: ${tt}`,sha:ze.sha}),Q(He=>He.map(mt=>mt.id===We?{...mt,status:"success"}:mt))}catch(ze){const Ze=ze instanceof Error?ze.message:"An unknown error occurred.";Q(ge=>ge.map(He=>He.id===We?{...He,status:"failed",error:Ze}:He))}},Z=5,oe=[...j],ue=async()=>{for(;oe.length>0;){const We=oe.shift();We&&await fe(We.id)}};await Promise.all(Array(Z).fill(null).map(ue))},[l,Y,k,o]);return _.jsxs("div",{className:"flex h-screen font-sans",children:[l?_.jsxs(_.Fragment,{children:[_.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:_.jsx(m0,{fileTree:o,onFileSelect:tn,onStartNewProject:()=>z(!0),onImportFromDrive:_o,selectedRepo:te==null?void 0:te.repoFullName,selectedFilePath:te==null?void 0:te.path,selectedPaths:Y,onSelectionChange:ce,onStartBulkEdit:()=>qe(!0)})}),_.jsx("main",{className:"flex-grow h-full",children:_.jsx(g0,{openFiles:r,activeFile:te||null,onCommit:xi,onAiEdit:()=>{me({status:"idle",logs:[]}),Oe(!0)},onFileContentChange:Qa,onCloseFile:Ei,onSetActiveFile:Ci,isLoading:y,branches:wn,currentBranch:gt,onBranchChange:Za,onCreateBranch:$a,onCreatePullRequest:xt})})]}):_.jsx(u0,{onSubmit:Si,isLoading:y}),y&&_.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:[_.jsx("style",{children:` + @keyframes fade-in-down { + 0% { + opacity: 0; + transform: translate(-50%, -20px); + } + 100% { + opacity: 1; + transform: translate(-50%, 0); + } + } + .animate-fade-in-down { + animation: fade-in-down 0.5s ease-out forwards; + } + `}),_.jsx(en,{}),_.jsx("span",{children:T})]}),_.jsx(C_,{alert:C,onClose:()=>R(null)}),F&&_.jsx(__,{onClose:()=>z(!1),onSubmit:Co}),De&&_.jsx(U_,{onClose:()=>ot(!1),onSubmit:xl}),$&&_.jsx(x_,{jobs:ae,statusMessage:Ce,isComplete:!ae.some(J=>J.status==="queued"||J.status==="generating"||J.status==="committing"),onClose:()=>W(!1)}),ve&&_.jsx(M_,{driveFile:ve,fileTree:o,branchesByRepo:L,onClose:()=>be(null),onSubmit:Wa,isLoading:y,onFetchBranches:async J=>{if(!l)return;const[j,fe]=J.split("/"),Z=await yr(l,j,fe);U(oe=>({...oe,[J]:Z}))}}),Te&&_.jsx(R_,{onClose:()=>Oe(!1),onSubmit:Ai,agentState:Ct}),Ge&&_.jsx(b_,{fileCount:Y.size,onClose:()=>qe(!1),onSubmit:Ao}),M&&_.jsx(w_,{jobs:K,isComplete:!K.some(J=>J.status==="queued"||J.status==="processing"),onClose:()=>B(!1)})]})}const zh=document.getElementById("root");if(!zh)throw new Error("Could not find root element to mount to");const q_=s0.createRoot(zh);q_.render(_.jsx(jy.StrictMode,{children:_.jsx(I_,{})}));