(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const c of r)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function o(r){const c={};return r.integrity&&(c.integrity=r.integrity),r.referrerPolicy&&(c.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?c.credentials="include":r.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(r){if(r.ep)return;r.ep=!0;const c=o(r);fetch(r.href,c)}})();function _c(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Xu={exports:{}},Gl={};/** * @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 Eh;function xv(){if(Eh)return Gl;Eh=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(s,r,c){var d=null;if(c!==void 0&&(d=""+c),r.key!==void 0&&(d=""+r.key),"key"in r){c={};for(var h in r)h!=="key"&&(c[h]=r[h])}else c=r;return r=c.ref,{$$typeof:i,type:s,key:d,ref:r!==void 0?r:null,props:c}}return Gl.Fragment=t,Gl.jsx=o,Gl.jsxs=o,Gl}var _h;function Av(){return _h||(_h=1,Xu.exports=xv()),Xu.exports}var S=Av(),$u={exports:{}},Se={};/** * @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 Ch;function Nv(){if(Ch)return Se;Ch=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),_=Symbol.iterator;function x(b){return b===null||typeof b!="object"?null:(b=_&&b[_]||b["@@iterator"],typeof b=="function"?b:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},I=Object.assign,M={};function V(b,B,K){this.props=b,this.context=B,this.refs=M,this.updater=K||w}V.prototype.isReactComponent={},V.prototype.setState=function(b,B){if(typeof b!="object"&&typeof b!="function"&&b!=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,b,B,"setState")},V.prototype.forceUpdate=function(b){this.updater.enqueueForceUpdate(this,b,"forceUpdate")};function $(){}$.prototype=V.prototype;function O(b,B,K){this.props=b,this.context=B,this.refs=M,this.updater=K||w}var J=O.prototype=new $;J.constructor=O,I(J,V.prototype),J.isPureReactComponent=!0;var ne=Array.isArray;function z(){}var X={H:null,A:null,T:null,S:null},ve=Object.prototype.hasOwnProperty;function W(b,B,K){var ee=K.ref;return{$$typeof:i,type:b,key:B,ref:ee!==void 0?ee:null,props:K}}function Ee(b,B){return W(b.type,B,b.props)}function Ne(b){return typeof b=="object"&&b!==null&&b.$$typeof===i}function Ve(b){var B={"=":"=0",":":"=2"};return"$"+b.replace(/[=:]/g,function(K){return B[K]})}var je=/\/+/g;function qe(b,B){return typeof b=="object"&&b!==null&&b.key!=null?Ve(""+b.key):B.toString(36)}function Ye(b){switch(b.status){case"fulfilled":return b.value;case"rejected":throw b.reason;default:switch(typeof b.status=="string"?b.then(z,z):(b.status="pending",b.then(function(B){b.status==="pending"&&(b.status="fulfilled",b.value=B)},function(B){b.status==="pending"&&(b.status="rejected",b.reason=B)})),b.status){case"fulfilled":return b.value;case"rejected":throw b.reason}}throw b}function L(b,B,K,ee,he){var Ae=typeof b;(Ae==="undefined"||Ae==="boolean")&&(b=null);var He=!1;if(b===null)He=!0;else switch(Ae){case"bigint":case"string":case"number":He=!0;break;case"object":switch(b.$$typeof){case i:case t:He=!0;break;case v:return He=b._init,L(He(b._payload),B,K,ee,he)}}if(He)return he=he(b),He=ee===""?"."+qe(b,0):ee,ne(he)?(K="",He!=null&&(K=He.replace(je,"$&/")+"/"),L(he,B,K,"",function(Ei){return Ei})):he!=null&&(Ne(he)&&(he=Ee(he,K+(he.key==null||b&&b.key===he.key?"":(""+he.key).replace(je,"$&/")+"/")+He)),B.push(he)),1;He=0;var At=ee===""?".":ee+":";if(ne(b))for(var ut=0;ut>>1,Ke=L[Me];if(0>>1;Mer(K,le))eer(he,K)?(L[Me]=he,L[ee]=le,Me=ee):(L[Me]=K,L[B]=le,Me=B);else if(eer(he,le))L[Me]=he,L[ee]=le,Me=ee;else break e}}return Y}function r(L,Y){var le=L.sortIndex-Y.sortIndex;return le!==0?le:L.id-Y.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;i.unstable_now=function(){return c.now()}}else{var d=Date,h=d.now();i.unstable_now=function(){return d.now()-h}}var y=[],m=[],v=1,E=null,_=3,x=!1,w=!1,I=!1,M=!1,V=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function J(L){for(var Y=o(m);Y!==null;){if(Y.callback===null)s(m);else if(Y.startTime<=L)s(m),Y.sortIndex=Y.expirationTime,t(y,Y);else break;Y=o(m)}}function ne(L){if(I=!1,J(L),!w)if(o(y)!==null)w=!0,z||(z=!0,Ve());else{var Y=o(m);Y!==null&&Ye(ne,Y.startTime-L)}}var z=!1,X=-1,ve=5,W=-1;function Ee(){return M?!0:!(i.unstable_now()-WL&&Ee());){var Me=E.callback;if(typeof Me=="function"){E.callback=null,_=E.priorityLevel;var Ke=Me(E.expirationTime<=L);if(L=i.unstable_now(),typeof Ke=="function"){E.callback=Ke,J(L),Y=!0;break t}E===o(y)&&s(y),J(L)}else s(y);E=o(y)}if(E!==null)Y=!0;else{var b=o(m);b!==null&&Ye(ne,b.startTime-L),Y=!1}}break e}finally{E=null,_=le,x=!1}Y=void 0}}finally{Y?Ve():z=!1}}}var Ve;if(typeof O=="function")Ve=function(){O(Ne)};else if(typeof MessageChannel<"u"){var je=new MessageChannel,qe=je.port2;je.port1.onmessage=Ne,Ve=function(){qe.postMessage(null)}}else Ve=function(){V(Ne,0)};function Ye(L,Y){X=V(function(){L(i.unstable_now())},Y)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(L){L.callback=null},i.unstable_forceFrameRate=function(L){0>L||125Me?(L.sortIndex=le,t(m,L),o(y)===null&&L===o(m)&&(I?($(X),X=-1):I=!0,Ye(ne,le-Me))):(L.sortIndex=Ke,t(y,L),w||x||(w=!0,z||(z=!0,Ve()))),L},i.unstable_shouldYield=Ee,i.unstable_wrapCallback=function(L){var Y=_;return function(){var le=_;_=Y;try{return L.apply(this,arguments)}finally{_=le}}}})(Wu)),Wu}var Nh;function wv(){return Nh||(Nh=1,Zu.exports=Rv()),Zu.exports}var ju={exports:{}},Dt={};/** * @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 bh;function Mv(){if(bh)return Dt;bh=1;var i=Cc();function t(y){var m="https://react.dev/errors/"+y;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),ju.exports=Mv(),ju.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 wh;function Dv(){if(wh)return Pl;wh=1;var i=wv(),t=Cc(),o=Iv();function s(e){var n="https://react.dev/errors/"+e;if(1Ke||(e.current=Me[Ke],Me[Ke]=null,Ke--)}function K(e,n){Ke++,Me[Ke]=e.current,e.current=n}var ee=b(null),he=b(null),Ae=b(null),He=b(null);function At(e,n){switch(K(Ae,n),K(he,e),K(ee,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Fp(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Fp(n),e=Jp(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}B(ee),K(ee,e)}function ut(){B(ee),B(he),B(Ae)}function Ei(e){e.memoizedState!==null&&K(He,e);var n=ee.current,l=Jp(n,e.type);n!==l&&(K(he,e),K(ee,l))}function pn(e){he.current===e&&(B(ee),B(he)),He.current===e&&(B(He),Il._currentValue=le)}var Bi,qt;function Nn(e){if(Bi===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);Bi=n&&n[1]||"",qt=-1)":-1p||A[a]!==U[p]){var q=` `+A[a].replace(" at new "," at ");return e.displayName&&q.includes("")&&(q=q.replace("",e.displayName)),q}while(1<=a&&0<=p);break}}}finally{Oi=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Nn(l):""}function Fl(e,n){switch(e.tag){case 26:case 27:case 5:return Nn(e.type);case 16:return Nn("Lazy");case 13:return e.child!==n&&n!==null?Nn("Suspense Fallback"):Nn("Suspense");case 19:return Nn("SuspenseList");case 0:case 15:return Fi(e.type,!1);case 11:return Fi(e.type.render,!1);case 1:return Fi(e.type,!0);case 31:return Nn("Activity");default:return""}}function Jl(e){try{var n="",l=null;do n+=Fl(e,l),l=e,e=e.return;while(e);return n}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var Ji=Object.prototype.hasOwnProperty,Oo=i.unstable_scheduleCallback,Yi=i.unstable_cancelCallback,La=i.unstable_shouldYield,Yl=i.unstable_requestPaint,Ut=i.unstable_now,Fo=i.unstable_getCurrentPriorityLevel,Kl=i.unstable_ImmediatePriority,Ki=i.unstable_UserBlockingPriority,Sn=i.unstable_NormalPriority,Ga=i.unstable_LowPriority,Xl=i.unstable_IdlePriority,$l=i.log,Ql=i.unstable_setDisableYieldValue,Ht=null,Mt=null;function Jt(e){if(typeof $l=="function"&&Ql(e),Mt&&typeof Mt.setStrictMode=="function")try{Mt.setStrictMode(Ht,e)}catch{}}var ue=Math.clz32?Math.clz32:Ha,Pa=Math.log,qa=Math.LN2;function Ha(e){return e>>>=0,e===0?32:31-(Pa(e)/qa|0)|0}var Xi=256,$i=262144,Xn=4194304;function bn(e){var n=e&42;if(n!==0)return n;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 Qi(e,n,l){var a=e.pendingLanes;if(a===0)return 0;var p=0,g=e.suspendedLanes,T=e.pingedLanes;e=e.warmLanes;var C=a&134217727;return C!==0?(a=C&~g,a!==0?p=bn(a):(T&=C,T!==0?p=bn(T):l||(l=C&~e,l!==0&&(p=bn(l))))):(C=a&~g,C!==0?p=bn(C):T!==0?p=bn(T):l||(l=a&~e,l!==0&&(p=bn(l)))),p===0?0:n!==0&&n!==p&&(n&g)===0&&(g=p&-p,l=n&-n,g>=l||g===32&&(l&4194048)!==0)?n:p}function $n(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function ka(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 Zl(){var e=Xn;return Xn<<=1,(Xn&62914560)===0&&(Xn=4194304),e}function Jo(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function _i(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Va(e,n,l,a,p,g){var T=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var C=e.entanglements,A=e.expirationTimes,U=e.hiddenUpdates;for(l=T&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var vy=/[\n"\\]/g;function nn(e){return e.replace(vy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Ba(e,n,l,a,p,g,T,C){e.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?e.type=T:e.removeAttribute("type"),n!=null?T==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+pt(n)):e.value!==""+pt(n)&&(e.value=""+pt(n)):T!=="submit"&&T!=="reset"||e.removeAttribute("value"),n!=null?Oa(e,T,pt(n)):l!=null?Oa(e,T,pt(l)):a!=null&&e.removeAttribute("value"),p==null&&g!=null&&(e.defaultChecked=!!g),p!=null&&(e.checked=p&&typeof p!="function"&&typeof p!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?e.name=""+pt(C):e.removeAttribute("name")}function qc(e,n,l,a,p,g,T,C){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){za(e);return}l=l!=null?""+pt(l):"",n=n!=null?""+pt(n):l,C||n===e.value||(e.value=n),e.defaultValue=n}a=a??p,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=C?e.checked:!!a,e.defaultChecked=!!a,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(e.name=T),za(e)}function Oa(e,n,l){n==="number"&&os(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Zi(e,n,l,a){if(e=e.options,n){n={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xa=!1;if(wn)try{var $o={};Object.defineProperty($o,"passive",{get:function(){Xa=!0}}),window.addEventListener("test",$o,$o),window.removeEventListener("test",$o,$o)}catch{Xa=!1}var Zn=null,$a=null,ss=null;function Fc(){if(ss)return ss;var e,n=$a,l=n.length,a,p="value"in Zn?Zn.value:Zn.textContent,g=p.length;for(e=0;e=Wo),Qc=" ",Zc=!1;function Wc(e,n){switch(e){case"keyup":return Yy.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var to=!1;function Xy(e,n){switch(e){case"compositionend":return jc(n);case"keypress":return n.which!==32?null:(Zc=!0,Qc);case"textInput":return e=n.data,e===Qc&&Zc?null:e;default:return null}}function $y(e,n){if(to)return e==="compositionend"||!er&&Wc(e,n)?(e=Fc(),ss=$a=Zn=null,to=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:l,offset:n-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=rf(l)}}function cf(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?cf(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ff(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=os(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=os(e.document)}return n}function ir(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var i0=wn&&"documentMode"in document&&11>=document.documentMode,no=null,or=null,nl=null,lr=!1;function df(e,n,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;lr||no==null||no!==os(a)||(a=no,"selectionStart"in a&&ir(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}),nl&&tl(nl,a)||(nl=a,a=js(or,"onSelect"),0>=T,p-=T,_n=1<<32-ue(n)+p|l<xe?(Ue=oe,oe=null):Ue=oe.sibling;var Be=G(R,oe,D[xe],H);if(Be===null){oe===null&&(oe=Ue);break}e&&oe&&Be.alternate===null&&n(R,oe),N=g(Be,N,xe),ze===null?re=Be:ze.sibling=Be,ze=Be,oe=Ue}if(xe===D.length)return l(R,oe),Pe&&In(R,xe),re;if(oe===null){for(;xexe?(Ue=oe,oe=null):Ue=oe.sibling;var Ti=G(R,oe,Be.value,H);if(Ti===null){oe===null&&(oe=Ue);break}e&&oe&&Ti.alternate===null&&n(R,oe),N=g(Ti,N,xe),ze===null?re=Ti:ze.sibling=Ti,ze=Ti,oe=Ue}if(Be.done)return l(R,oe),Pe&&In(R,xe),re;if(oe===null){for(;!Be.done;xe++,Be=D.next())Be=k(R,Be.value,H),Be!==null&&(N=g(Be,N,xe),ze===null?re=Be:ze.sibling=Be,ze=Be);return Pe&&In(R,xe),re}for(oe=a(oe);!Be.done;xe++,Be=D.next())Be=P(oe,R,xe,Be.value,H),Be!==null&&(e&&Be.alternate!==null&&oe.delete(Be.key===null?xe:Be.key),N=g(Be,N,xe),ze===null?re=Be:ze.sibling=Be,ze=Be);return e&&oe.forEach(function(Cv){return n(R,Cv)}),Pe&&In(R,xe),re}function it(R,N,D,H){if(typeof D=="object"&&D!==null&&D.type===I&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case x:e:{for(var re=D.key;N!==null;){if(N.key===re){if(re=D.type,re===I){if(N.tag===7){l(R,N.sibling),H=p(N,D.props.children),H.return=R,R=H;break e}}else if(N.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===ve&&Di(re)===N.type){l(R,N.sibling),H=p(N,D.props),rl(H,D),H.return=R,R=H;break e}l(R,N);break}else n(R,N);N=N.sibling}D.type===I?(H=bi(D.props.children,R.mode,H,D.key),H.return=R,R=H):(H=gs(D.type,D.key,D.props,null,R.mode,H),rl(H,D),H.return=R,R=H)}return T(R);case w:e:{for(re=D.key;N!==null;){if(N.key===re)if(N.tag===4&&N.stateNode.containerInfo===D.containerInfo&&N.stateNode.implementation===D.implementation){l(R,N.sibling),H=p(N,D.children||[]),H.return=R,R=H;break e}else{l(R,N);break}else n(R,N);N=N.sibling}H=dr(D,R.mode,H),H.return=R,R=H}return T(R);case ve:return D=Di(D),it(R,N,D,H)}if(Ye(D))return te(R,N,D,H);if(Ve(D)){if(re=Ve(D),typeof re!="function")throw Error(s(150));return D=re.call(D),de(R,N,D,H)}if(typeof D.then=="function")return it(R,N,Cs(D),H);if(D.$$typeof===O)return it(R,N,Ts(R,D),H);xs(R,D)}return typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint"?(D=""+D,N!==null&&N.tag===6?(l(R,N.sibling),H=p(N,D),H.return=R,R=H):(l(R,N),H=fr(D,R.mode,H),H.return=R,R=H),T(R)):l(R,N)}return function(R,N,D,H){try{al=0;var re=it(R,N,D,H);return ho=null,re}catch(oe){if(oe===po||oe===Es)throw oe;var ze=Kt(29,oe,null,R.mode);return ze.lanes=H,ze.return=R,ze}finally{}}}var Li=Gf(!0),Pf=Gf(!1),ni=!1;function xr(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ar(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ii(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function oi(e,n,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Je&2)!==0){var p=a.pending;return p===null?n.next=n:(n.next=p.next,p.next=n),a.pending=n,n=ms(e),Tf(e,null,l),n}return hs(e,a,n,l),ms(e)}function ul(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var a=n.lanes;a&=e.pendingLanes,l|=a,n.lanes=l,jl(e,l)}}function Nr(e,n){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var p=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var T={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?p=g=T:g=g.next=T,l=l.next}while(l!==null);g===null?p=g=n:g=g.next=n}else p=g=n;l={baseState:a.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var br=!1;function cl(){if(br){var e=fo;if(e!==null)throw e}}function fl(e,n,l,a){br=!1;var p=e.updateQueue;ni=!1;var g=p.firstBaseUpdate,T=p.lastBaseUpdate,C=p.shared.pending;if(C!==null){p.shared.pending=null;var A=C,U=A.next;A.next=null,T===null?g=U:T.next=U,T=A;var q=e.alternate;q!==null&&(q=q.updateQueue,C=q.lastBaseUpdate,C!==T&&(C===null?q.firstBaseUpdate=U:C.next=U,q.lastBaseUpdate=A))}if(g!==null){var k=p.baseState;T=0,q=U=A=null,C=g;do{var G=C.lane&-536870913,P=G!==C.lane;if(P?(De&G)===G:(a&G)===G){G!==0&&G===co&&(br=!0),q!==null&&(q=q.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var te=e,de=C;G=n;var it=l;switch(de.tag){case 1:if(te=de.payload,typeof te=="function"){k=te.call(it,k,G);break e}k=te;break e;case 3:te.flags=te.flags&-65537|128;case 0:if(te=de.payload,G=typeof te=="function"?te.call(it,k,G):te,G==null)break e;k=E({},k,G);break e;case 2:ni=!0}}G=C.callback,G!==null&&(e.flags|=64,P&&(e.flags|=8192),P=p.callbacks,P===null?p.callbacks=[G]:P.push(G))}else P={lane:G,tag:C.tag,payload:C.payload,callback:C.callback,next:null},q===null?(U=q=P,A=k):q=q.next=P,T|=G;if(C=C.next,C===null){if(C=p.shared.pending,C===null)break;P=C,C=P.next,P.next=null,p.lastBaseUpdate=P,p.shared.pending=null}}while(!0);q===null&&(A=k),p.baseState=A,p.firstBaseUpdate=U,p.lastBaseUpdate=q,g===null&&(p.shared.lanes=0),ui|=T,e.lanes=T,e.memoizedState=k}}function qf(e,n){if(typeof e!="function")throw Error(s(191,e));e.call(n)}function Hf(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;eg?g:8;var T=L.T,C={};L.T=C,Yr(e,!1,n,l);try{var A=p(),U=L.S;if(U!==null&&U(C,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var q=d0(A,a);hl(e,n,q,Wt(e))}else hl(e,n,a,Wt(e))}catch(k){hl(e,n,{then:function(){},status:"rejected",reason:k},Wt())}finally{Y.p=g,T!==null&&C.types!==null&&(T.types=C.types),L.T=T}}function v0(){}function Fr(e,n,l,a){if(e.tag!==5)throw Error(s(476));var p=gd(e).queue;md(e,p,n,le,l===null?v0:function(){return yd(e),l(a)})}function gd(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gn,lastRenderedState:le},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gn,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function yd(e){var n=gd(e);n.next===null&&(n=e.alternate.memoizedState),hl(e,n.next.queue,{},Wt())}function Jr(){return bt(Il)}function vd(){return mt().memoizedState}function Td(){return mt().memoizedState}function T0(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Wt();e=ii(l);var a=oi(n,e,l);a!==null&&(Ft(a,n,l),ul(a,n,l)),n={cache:Sr()},e.payload=n;return}n=n.return}}function S0(e,n,l){var a=Wt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ls(e)?Ed(n,l):(l=ur(e,n,l,a),l!==null&&(Ft(l,e,a),_d(l,n,a)))}function Sd(e,n,l){var a=Wt();hl(e,n,l,a)}function hl(e,n,l,a){var p={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ls(e))Ed(n,p);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var T=n.lastRenderedState,C=g(T,l);if(p.hasEagerState=!0,p.eagerState=C,Yt(C,T))return hs(e,n,p,0),st===null&&ps(),!1}catch{}finally{}if(l=ur(e,n,p,a),l!==null)return Ft(l,e,a),_d(l,n,a),!0}return!1}function Yr(e,n,l,a){if(a={lane:2,revertLane:xu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ls(e)){if(n)throw Error(s(479))}else n=ur(e,l,a,2),n!==null&&Ft(n,e,2)}function Ls(e){var n=e.alternate;return e===Ce||n!==null&&n===Ce}function Ed(e,n){go=bs=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function _d(e,n,l){if((l&4194048)!==0){var a=n.lanes;a&=e.pendingLanes,l|=a,n.lanes=l,jl(e,l)}}var ml={readContext:bt,use:Ms,useCallback:ft,useContext:ft,useEffect:ft,useImperativeHandle:ft,useLayoutEffect:ft,useInsertionEffect:ft,useMemo:ft,useReducer:ft,useRef:ft,useState:ft,useDebugValue:ft,useDeferredValue:ft,useTransition:ft,useSyncExternalStore:ft,useId:ft,useHostTransitionStatus:ft,useFormState:ft,useActionState:ft,useOptimistic:ft,useMemoCache:ft,useCacheRefresh:ft};ml.useEffectEvent=ft;var Cd={readContext:bt,use:Ms,useCallback:function(e,n){return Lt().memoizedState=[e,n===void 0?null:n],e},useContext:bt,useEffect:sd,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,Ds(4194308,4,cd.bind(null,n,e),l)},useLayoutEffect:function(e,n){return Ds(4194308,4,e,n)},useInsertionEffect:function(e,n){Ds(4,2,e,n)},useMemo:function(e,n){var l=Lt();n=n===void 0?null:n;var a=e();if(Gi){Jt(!0);try{e()}finally{Jt(!1)}}return l.memoizedState=[a,n],a},useReducer:function(e,n,l){var a=Lt();if(l!==void 0){var p=l(n);if(Gi){Jt(!0);try{l(n)}finally{Jt(!1)}}}else p=n;return a.memoizedState=a.baseState=p,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:p},a.queue=e,e=e.dispatch=S0.bind(null,Ce,e),[a.memoizedState,e]},useRef:function(e){var n=Lt();return e={current:e},n.memoizedState=e},useState:function(e){e=kr(e);var n=e.queue,l=Sd.bind(null,Ce,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:Br,useDeferredValue:function(e,n){var l=Lt();return Or(l,e,n)},useTransition:function(){var e=kr(!1);return e=md.bind(null,Ce,e.queue,!0,!1),Lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var a=Ce,p=Lt();if(Pe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=n(),st===null)throw Error(s(349));(De&127)!==0||Ff(a,n,l)}p.memoizedState=l;var g={value:l,getSnapshot:n};return p.queue=g,sd(Yf.bind(null,a,g,e),[e]),a.flags|=2048,vo(9,{destroy:void 0},Jf.bind(null,a,g,l,n),null),l},useId:function(){var e=Lt(),n=st.identifierPrefix;if(Pe){var l=Cn,a=_n;l=(a&~(1<<32-ue(a)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Rs++,0<\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof a.is=="string"?T.createElement("select",{is:a.is}):T.createElement("select"),a.multiple?g.multiple=!0:a.size&&(g.size=a.size);break;default:g=typeof a.is=="string"?T.createElement(p,{is:a.is}):T.createElement(p)}}g[St]=n,g[It]=a;e:for(T=n.child;T!==null;){if(T.tag===5||T.tag===6)g.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===n)break e;for(;T.sibling===null;){if(T.return===null||T.return===n)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}n.stateNode=g;e:switch(wt(g,p,a),p){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&qn(n)}}return rt(n),su(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==a&&qn(n);else{if(typeof a!="string"&&n.stateNode===null)throw Error(s(166));if(e=Ae.current,ro(n)){if(e=n.stateNode,l=n.memoizedProps,a=null,p=Nt,p!==null)switch(p.tag){case 27:case 5:a=p.memoizedProps}e[St]=n,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||Bp(e.nodeValue,l)),e||ei(n,!0)}else e=ea(e).createTextNode(a),e[St]=n,n.stateNode=e}return rt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(a=ro(n),l!==null){if(e===null){if(!a)throw Error(s(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(s(557));e[St]=n}else Ri(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;rt(n),e=!1}else l=gr(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?($t(n),n):($t(n),null);if((n.flags&128)!==0)throw Error(s(558))}return rt(n),null;case 13:if(a=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(p=ro(n),a!==null&&a.dehydrated!==null){if(e===null){if(!p)throw Error(s(318));if(p=n.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(s(317));p[St]=n}else Ri(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;rt(n),p=!1}else p=gr(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=p),p=!0;if(!p)return n.flags&256?($t(n),n):($t(n),null)}return $t(n),(n.flags&128)!==0?(n.lanes=l,n):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=n.child,p=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(p=a.alternate.memoizedState.cachePool.pool),g=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(g=a.memoizedState.cachePool.pool),g!==p&&(a.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),ks(n,n.updateQueue),rt(n),null);case 4:return ut(),e===null&&Ru(n.stateNode.containerInfo),rt(n),null;case 10:return Un(n.type),rt(n),null;case 19:if(B(ht),a=n.memoizedState,a===null)return rt(n),null;if(p=(n.flags&128)!==0,g=a.rendering,g===null)if(p)yl(a,!1);else{if(dt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=Ns(e),g!==null){for(n.flags|=128,yl(a,!1),e=g.updateQueue,n.updateQueue=e,ks(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Sf(l,e),l=l.sibling;return K(ht,ht.current&1|2),Pe&&In(n,a.treeForkCount),n.child}e=e.sibling}a.tail!==null&&Ut()>Fs&&(n.flags|=128,p=!0,yl(a,!1),n.lanes=4194304)}else{if(!p)if(e=Ns(g),e!==null){if(n.flags|=128,p=!0,e=e.updateQueue,n.updateQueue=e,ks(n,e),yl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!g.alternate&&!Pe)return rt(n),null}else 2*Ut()-a.renderingStartTime>Fs&&l!==536870912&&(n.flags|=128,p=!0,yl(a,!1),n.lanes=4194304);a.isBackwards?(g.sibling=n.child,n.child=g):(e=a.last,e!==null?e.sibling=g:n.child=g,a.last=g)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=Ut(),e.sibling=null,l=ht.current,K(ht,p?l&1|2:l&1),Pe&&In(n,a.treeForkCount),e):(rt(n),null);case 22:case 23:return $t(n),wr(),a=n.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(n.flags|=8192):a&&(n.flags|=8192),a?(l&536870912)!==0&&(n.flags&128)===0&&(rt(n),n.subtreeFlags&6&&(n.flags|=8192)):rt(n),l=n.updateQueue,l!==null&&ks(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(a=n.memoizedState.cachePool.pool),a!==l&&(n.flags|=2048),e!==null&&B(Ii),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Un(gt),rt(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function A0(e,n){switch(hr(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Un(gt),ut(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return pn(n),null;case 31:if(n.memoizedState!==null){if($t(n),n.alternate===null)throw Error(s(340));Ri()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if($t(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(s(340));Ri()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return B(ht),null;case 4:return ut(),null;case 10:return Un(n.type),null;case 22:case 23:return $t(n),wr(),e!==null&&B(Ii),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return Un(gt),null;case 25:return null;default:return null}}function Kd(e,n){switch(hr(n),n.tag){case 3:Un(gt),ut();break;case 26:case 27:case 5:pn(n);break;case 4:ut();break;case 31:n.memoizedState!==null&&$t(n);break;case 13:$t(n);break;case 19:B(ht);break;case 10:Un(n.type);break;case 22:case 23:$t(n),wr(),e!==null&&B(Ii);break;case 24:Un(gt)}}function vl(e,n){try{var l=n.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var p=a.next;l=p;do{if((l.tag&e)===e){a=void 0;var g=l.create,T=l.inst;a=g(),T.destroy=a}l=l.next}while(l!==p)}}catch(C){We(n,n.return,C)}}function ai(e,n,l){try{var a=n.updateQueue,p=a!==null?a.lastEffect:null;if(p!==null){var g=p.next;a=g;do{if((a.tag&e)===e){var T=a.inst,C=T.destroy;if(C!==void 0){T.destroy=void 0,p=n;var A=l,U=C;try{U()}catch(q){We(p,A,q)}}}a=a.next}while(a!==g)}}catch(q){We(n,n.return,q)}}function Xd(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Hf(n,l)}catch(a){We(e,e.return,a)}}}function $d(e,n,l){l.props=Pi(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){We(e,n,a)}}function Tl(e,n){try{var l=e.ref;if(l!==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 l=="function"?e.refCleanup=l(a):l.current=a}}catch(p){We(e,n,p)}}function xn(e,n){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(p){We(e,n,p)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){We(e,n,p)}else l.current=null}function Qd(e){var n=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(p){We(e,e.return,p)}}function au(e,n,l){try{var a=e.stateNode;K0(a,e.type,l,n),a[It]=n}catch(p){We(e,e.return,p)}}function Zd(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&hi(e.type)||e.tag===4}function ru(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Zd(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&&hi(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 uu(e,n,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=Rn));else if(a!==4&&(a===27&&hi(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(uu(e,n,l),e=e.sibling;e!==null;)uu(e,n,l),e=e.sibling}function Vs(e,n,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(a!==4&&(a===27&&hi(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Vs(e,n,l),e=e.sibling;e!==null;)Vs(e,n,l),e=e.sibling}function Wd(e){var n=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,p=n.attributes;p.length;)n.removeAttributeNode(p[0]);wt(n,a,l),n[St]=e,n[It]=l}catch(g){We(e,e.return,g)}}var Hn=!1,Tt=!1,cu=!1,jd=typeof WeakSet=="function"?WeakSet:Set,_t=null;function N0(e,n){if(e=e.containerInfo,Iu=aa,e=ff(e),ir(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var p=a.anchorOffset,g=a.focusNode;a=a.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var T=0,C=-1,A=-1,U=0,q=0,k=e,G=null;t:for(;;){for(var P;k!==l||p!==0&&k.nodeType!==3||(C=T+p),k!==g||a!==0&&k.nodeType!==3||(A=T+a),k.nodeType===3&&(T+=k.nodeValue.length),(P=k.firstChild)!==null;)G=k,k=P;for(;;){if(k===e)break t;if(G===l&&++U===p&&(C=T),G===g&&++q===a&&(A=T),(P=k.nextSibling)!==null)break;k=G,G=k.parentNode}k=P}l=C===-1||A===-1?null:{start:C,end:A}}else l=null}l=l||{start:0,end:0}}else l=null;for(Du={focusedElem:e,selectionRange:l},aa=!1,_t=n;_t!==null;)if(n=_t,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,_t=e;else for(;_t!==null;){switch(n=_t,g=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),wt(g,a,l),g[St]=e,Le(g),a=g;break e;case"link":var T=lh("link","href",p).get(a+(l.href||""));if(T){for(var C=0;Cit&&(T=it,it=de,de=T);var R=uf(C,de),N=uf(C,it);if(R&&N&&(P.rangeCount!==1||P.anchorNode!==R.node||P.anchorOffset!==R.offset||P.focusNode!==N.node||P.focusOffset!==N.offset)){var D=k.createRange();D.setStart(R.node,R.offset),P.removeAllRanges(),de>it?(P.addRange(D),P.extend(N.node,N.offset)):(D.setEnd(N.node,N.offset),P.addRange(D))}}}}for(k=[],P=C;P=P.parentNode;)P.nodeType===1&&k.push({element:P,left:P.scrollLeft,top:P.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;Cl?32:l,L.T=null,l=yu,yu=null;var g=fi,T=On;if(Et=0,Co=fi=null,On=0,(Je&6)!==0)throw Error(s(331));var C=Je;if(Je|=4,cp(g.current),ap(g,g.current,T,l),Je=C,Al(0,!1),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Ht,g)}catch{}return!0}finally{Y.p=p,L.T=a,Rp(e,n)}}function Mp(e,n,l){n=ln(l,n),n=Qr(e.stateNode,n,2),e=oi(e,n,2),e!==null&&(_i(e,2),An(e))}function We(e,n,l){if(e.tag===3)Mp(e,e,l);else for(;n!==null;){if(n.tag===3){Mp(n,e,l);break}else if(n.tag===1){var a=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(ci===null||!ci.has(a))){e=ln(l,e),l=Id(2),a=oi(n,l,2),a!==null&&(Dd(l,a,n,e),_i(a,2),An(a));break}}n=n.return}}function Eu(e,n,l){var a=e.pingCache;if(a===null){a=e.pingCache=new w0;var p=new Set;a.set(n,p)}else p=a.get(n),p===void 0&&(p=new Set,a.set(n,p));p.has(l)||(pu=!0,p.add(l),e=L0.bind(null,e,n,l),n.then(e,e))}function L0(e,n,l){var a=e.pingCache;a!==null&&a.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,st===e&&(De&l)===l&&(dt===4||dt===3&&(De&62914560)===De&&300>Ut()-Os?(Je&2)===0&&xo(e,0):hu|=l,_o===De&&(_o=0)),An(e)}function Ip(e,n){n===0&&(n=Zl()),e=Ni(e,n),e!==null&&(_i(e,n),An(e))}function G0(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Ip(e,l)}function P0(e,n){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,p=e.memoizedState;p!==null&&(l=p.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(s(314))}a!==null&&a.delete(n),Ip(e,l)}function q0(e,n){return Oo(e,n)}var Qs=null,No=null,_u=!1,Zs=!1,Cu=!1,pi=0;function An(e){e!==No&&e.next===null&&(No===null?Qs=No=e:No=No.next=e),Zs=!0,_u||(_u=!0,k0())}function Al(e,n){if(!Cu&&Zs){Cu=!0;do for(var l=!1,a=Qs;a!==null;){if(e!==0){var p=a.pendingLanes;if(p===0)var g=0;else{var T=a.suspendedLanes,C=a.pingedLanes;g=(1<<31-ue(42|e)+1)-1,g&=p&~(T&~C),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,Gp(a,g))}else g=De,g=Qi(a,a===st?g:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(g&3)===0||$n(a,g)||(l=!0,Gp(a,g));a=a.next}while(l);Cu=!1}}function H0(){Dp()}function Dp(){Zs=_u=!1;var e=0;pi!==0&&$0()&&(e=pi);for(var n=Ut(),l=null,a=Qs;a!==null;){var p=a.next,g=Up(a,n);g===0?(a.next=null,l===null?Qs=p:l.next=p,p===null&&(No=l)):(l=a,(e!==0||(g&3)!==0)&&(Zs=!0)),a=p}Et!==0&&Et!==5||Al(e),pi!==0&&(pi=0)}function Up(e,n){for(var l=e.suspendedLanes,a=e.pingedLanes,p=e.expirationTimes,g=e.pendingLanes&-62914561;0C)break;var q=A.transferSize,k=A.initiatorType;q&&Op(k)&&(A=A.responseEnd,T+=q*(A"u"?null:document;function th(e,n,l){var a=bo;if(a&&typeof n=="string"&&n){var p=nn(n);p='link[rel="'+e+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),eh.has(p)||(eh.add(p),e={rel:e,crossOrigin:l,href:n},a.querySelector(p)===null&&(n=a.createElement("link"),wt(n,"link",e),Le(n),a.head.appendChild(n)))}}function ov(e){Fn.D(e),th("dns-prefetch",e,null)}function lv(e,n){Fn.C(e,n),th("preconnect",e,n)}function sv(e,n,l){Fn.L(e,n,l);var a=bo;if(a&&e&&n){var p='link[rel="preload"][as="'+nn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+nn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+nn(l.imageSizes)+'"]')):p+='[href="'+nn(e)+'"]';var g=p;switch(n){case"style":g=Ro(e);break;case"script":g=wo(e)}fn.has(g)||(e=E({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),fn.set(g,e),a.querySelector(p)!==null||n==="style"&&a.querySelector(wl(g))||n==="script"&&a.querySelector(Ml(g))||(n=a.createElement("link"),wt(n,"link",e),Le(n),a.head.appendChild(n)))}}function av(e,n){Fn.m(e,n);var l=bo;if(l&&e){var a=n&&typeof n.as=="string"?n.as:"script",p='link[rel="modulepreload"][as="'+nn(a)+'"][href="'+nn(e)+'"]',g=p;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=wo(e)}if(!fn.has(g)&&(e=E({rel:"modulepreload",href:e},n),fn.set(g,e),l.querySelector(p)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Ml(g)))return}a=l.createElement("link"),wt(a,"link",e),Le(a),l.head.appendChild(a)}}}function rv(e,n,l){Fn.S(e,n,l);var a=bo;if(a&&e){var p=lt(a).hoistableStyles,g=Ro(e);n=n||"default";var T=p.get(g);if(!T){var C={loading:0,preload:null};if(T=a.querySelector(wl(g)))C.loading=5;else{e=E({rel:"stylesheet",href:e,"data-precedence":n},l),(l=fn.get(g))&&ku(e,l);var A=T=a.createElement("link");Le(A),wt(A,"link",e),A._p=new Promise(function(U,q){A.onload=U,A.onerror=q}),A.addEventListener("load",function(){C.loading|=1}),A.addEventListener("error",function(){C.loading|=2}),C.loading|=4,na(T,n,a)}T={type:"stylesheet",instance:T,count:1,state:C},p.set(g,T)}}}function uv(e,n){Fn.X(e,n);var l=bo;if(l&&e){var a=lt(l).hoistableScripts,p=wo(e),g=a.get(p);g||(g=l.querySelector(Ml(p)),g||(e=E({src:e,async:!0},n),(n=fn.get(p))&&Vu(e,n),g=l.createElement("script"),Le(g),wt(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},a.set(p,g))}}function cv(e,n){Fn.M(e,n);var l=bo;if(l&&e){var a=lt(l).hoistableScripts,p=wo(e),g=a.get(p);g||(g=l.querySelector(Ml(p)),g||(e=E({src:e,async:!0,type:"module"},n),(n=fn.get(p))&&Vu(e,n),g=l.createElement("script"),Le(g),wt(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},a.set(p,g))}}function nh(e,n,l,a){var p=(p=Ae.current)?ta(p):null;if(!p)throw Error(s(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=Ro(l.href),l=lt(p).hoistableStyles,a=l.get(n),a||(a={type:"style",instance:null,count:0,state:null},l.set(n,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=Ro(l.href);var g=lt(p).hoistableStyles,T=g.get(e);if(T||(p=p.ownerDocument||p,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,T),(g=p.querySelector(wl(e)))&&!g._p&&(T.instance=g,T.state.loading=5),fn.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},fn.set(e,l),g||fv(p,e,l,T.state))),n&&a===null)throw Error(s(528,""));return T}if(n&&a!==null)throw Error(s(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=wo(l),l=lt(p).hoistableScripts,a=l.get(n),a||(a={type:"script",instance:null,count:0,state:null},l.set(n,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Ro(e){return'href="'+nn(e)+'"'}function wl(e){return'link[rel="stylesheet"]['+e+"]"}function ih(e){return E({},e,{"data-precedence":e.precedence,precedence:null})}function fv(e,n,l,a){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?a.loading=1:(n=e.createElement("link"),a.preload=n,n.addEventListener("load",function(){return a.loading|=1}),n.addEventListener("error",function(){return a.loading|=2}),wt(n,"link",l),Le(n),e.head.appendChild(n))}function wo(e){return'[src="'+nn(e)+'"]'}function Ml(e){return"script[async]"+e}function oh(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var a=e.querySelector('style[data-href~="'+nn(l.href)+'"]');if(a)return n.instance=a,Le(a),a;var p=E({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),Le(a),wt(a,"style",p),na(a,l.precedence,e),n.instance=a;case"stylesheet":p=Ro(l.href);var g=e.querySelector(wl(p));if(g)return n.state.loading|=4,n.instance=g,Le(g),g;a=ih(l),(p=fn.get(p))&&ku(a,p),g=(e.ownerDocument||e).createElement("link"),Le(g);var T=g;return T._p=new Promise(function(C,A){T.onload=C,T.onerror=A}),wt(g,"link",a),n.state.loading|=4,na(g,l.precedence,e),n.instance=g;case"script":return g=wo(l.src),(p=e.querySelector(Ml(g)))?(n.instance=p,Le(p),p):(a=l,(p=fn.get(g))&&(a=E({},l),Vu(a,p)),e=e.ownerDocument||e,p=e.createElement("script"),Le(p),wt(p,"link",a),e.head.appendChild(p),n.instance=p);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(a=n.instance,n.state.loading|=4,na(a,l.precedence,e));return n.instance}function na(e,n,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=a.length?a[a.length-1]:null,g=p,T=0;T title"):null)}function dv(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function ah(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function pv(e,n,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=Ro(a.href),g=n.querySelector(wl(p));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=oa.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,Le(g);return}g=n.ownerDocument||n,a=ih(a),(p=fn.get(p))&&ku(a,p),g=g.createElement("link"),Le(g);var T=g;T._p=new Promise(function(C,A){T.onload=C,T.onerror=A}),wt(g,"link",a),l.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=oa.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var zu=0;function hv(e,n){return e.stylesheets&&e.count===0&&sa(e,e.stylesheets),0zu?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(p)}}:null}function oa(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)sa(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var la=null;function sa(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,la=new Map,n.forEach(mv,e),la=null,oa.call(e))}function mv(e,n){if(!(n.state.loading&4)){var l=la.get(e);if(l)var a=l.get(null);else{l=new Map,la.set(e,l);for(var p=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),Qu.exports=Dv(),Qu.exports}var Lv=Uv();const Gv=_c(Lv),ot=({className:i})=>S.jsxs("svg",{className:`animate-spin h-5 w-5 text-white ${i}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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"})]}),Pv=({onSubmit:i,isLoading:t})=>{const[o,s]=Q.useState(""),[r,c]=Q.useState("");Q.useEffect(()=>{},[]);const d=h=>{h.preventDefault(),i({githubToken:o.trim(),geminiKey:r.trim()||void 0})};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-8 rounded-lg shadow-2xl w-full max-w-md border border-gray-700",children:[S.jsx("h2",{className:"text-2xl font-bold text-center text-gray-100 mb-2",children:"GitHub AI Code Editor"}),S.jsx("p",{className:"text-center text-gray-400 mb-6",children:"Enter your credentials to begin."}),S.jsxs("form",{onSubmit:d,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"githubToken",className:"block text-sm font-medium text-gray-300 mb-2",children:"GitHub Token"}),S.jsx("input",{id:"githubToken",type:"password",value:o,onChange:h=>s(h.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})]}),S.jsxs("div",{className:"mb-6",children:[S.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Gemini API Key"}),S.jsx("div",{className:"flex items-center gap-3",children:S.jsx("input",{type:"password",value:r,onChange:h=>c(h.target.value),placeholder:"Enter Gemini API key (AIza...)",className:"flex-grow 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"})}),r&&S.jsxs("p",{className:"text-green-400 text-sm mt-1 flex items-center gap-2",children:[S.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),"Key Ready"]})]}),S.jsxs("div",{className:"text-xs text-gray-500 mb-6 space-y-2",children:[S.jsxs("p",{children:["A ",S.jsx("strong",{className:"text-gray-400",children:"classic"})," GitHub token with ",S.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:"repo"})," scope is required."]}),S.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 token here."})]}),S.jsx("button",{type:"submit",disabled:t||!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:t?S.jsx(ot,{}):"Load Repositories"})]})]})})},vg=i=>S.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,...i,children:S.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"})}),Tg=i=>S.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,...i,children:S.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"})}),qv=i=>S.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,...i,children:S.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"})}),xc=i=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.353-.026.715-.026 1.068 0 1.13.094 1.976 1.057 1.976 2.192V7.5M8.25 7.5h7.5M8.25 7.5c0 1.135-.845 2.098-1.976 2.192a48.424 48.424 0 0 1-1.12 0c-1.131-.094-1.976-1.057-1.976-2.192S5.445 5.308 6.576 5.214a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192ZM9.75 9.75c0-1.135.845-2.098 1.976-2.192a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192S13.445 11.85 12.314 11.944a48.424 48.424 0 0 1-1.12 0c-1.131-.094-1.976-1.057-1.976-2.192ZM9.75 9.75c0 1.135-.845 2.098-1.976 2.192a48.424 48.424 0 0 1-1.12 0C5.524 11.85 4.68 10.887 4.68 9.75S5.524 7.65 6.654 7.556a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192Zm0 0h2.52m-2.52 0V3.375c0-1.135.845-2.098 1.976-2.192a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192V9.75m-4.632 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 5.25 12v2.25a2.25 2.25 0 0 0 2.25 2.25H16.5a2.25 2.25 0 0 0 2.25-2.25V12a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027m-9.198 0c-.065.21-.1.433-.1.662v2.25a2.25 2.25 0 0 0 2.25 2.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-2.25c0-.23-.035-.452-.1-.662m-1.246 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 12 6.75v-2.25a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 5.25 4.5v2.25a2.25 2.25 0 0 0 2.25 2.25m13.5 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 16.5 6.75v-2.25a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 9.75 4.5v2.25a2.25 2.25 0 0 0 2.25 2.25m-1.246 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 12 11.25v2.25a2.25 2.25 0 0 0 2.25 2.25h.09a48.566 48.566 0 0 1 1.658-.027A2.25 2.25 0 0 0 18.75 13.5v-2.25a2.25 2.25 0 0 0-2.25-2.25m-2.858 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 9.75 11.25v2.25a2.25 2.25 0 0 0 2.25 2.25h.09a48.566 48.566 0 0 1 1.658-.027A2.25 2.25 0 0 0 16.5 13.5v-2.25a2.25 2.25 0 0 0-2.25-2.25M12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z"})}),Ea=i=>{let t=[];for(const o of i)o.type==="file"?t.push(o.path):o.type==="dir"&&(t=t.concat(Ea(o.children)));return t},Hv=i=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),kv=i=>S.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:[S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.53 16.122a3 3 0 00-3.483 0w-6.036a3 3 0 013.483 0 3 3 0 003.483 0 3 3 0 013.483 0M9.53 16.122a3 3 0 00-3.483 0M9.53 16.122a3 3 0 013.483 0m0 0a3 3 0 013.483 0m0 0a3 3 0 003.483 0m-3.483 0a3 3 0 00-3.483 0m3.483 0a3 3 0 01-3.483 0m-9.75-6.322a3 3 0 013.483 0m0 0a3 3 0 003.483 0m0 0a3 3 0 013.483 0m0 0a3 3 0 003.483 0m-3.483 0a3 3 0 00-3.483 0m3.483 0a3 3 0 01-3.483 0"}),S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 12c0-3.359-2.34-6.14-5.46-6.918-1.217-.27-2.513-.44-3.856-.523a8.705 8.705 0 00-4.33 0c-1.343.083-2.64.253-3.856.523C-2.34 5.86-4.5 8.641-4.5 12c0 3.359 2.34 6.14 5.46 6.918 1.217.27 2.513.44 3.856.523a8.705 8.705 0 004.33 0c1.343-.083 2.64-.253 3.856-.523C17.16 18.14 19.5 15.359 19.5 12z"})]}),Sg=({node:i,repoFullName:t,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedFiles:c,onFileSelection:d,onDirectorySelection:h})=>{const[y,m]=Q.useState(!1),v=Q.useRef(null),E=i.type==="dir";Q.useEffect(()=>{if(E&&v.current){const I=Ea(i.children).map(V=>`${t}::${V}`);if(I.length===0){v.current.indeterminate=!1,v.current.checked=!1;return}const M=I.filter(V=>c.has(V)).length;M>0&&M{if(E)h(i.children,t,I.target.checked);else{const M=`${t}::${i.path}`;d(M,I.target.checked)}};if(E)return S.jsxs("div",{children:[S.jsxs("div",{className:"flex items-center p-1.5 hover:bg-gray-700 rounded-md group",children:[S.jsx("input",{type:"checkbox",ref:v,onChange:_,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),S.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>m(!y),children:[y?S.jsx(Tg,{className:"w-5 h-5 mr-2 text-indigo-400"}):S.jsx(vg,{className:"w-5 h-5 mr-2 text-indigo-400"}),S.jsx("span",{children:i.name})]})]}),y&&S.jsx("div",{className:"pl-6 border-l border-gray-700 ml-4",children:i.children.map(I=>S.jsx(Sg,{node:I,repoFullName:t,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedFiles:c,onFileSelection:d,onDirectorySelection:h},I.path))})]});const x=c.has(`${t}::${i.path}`),w=r===t&&s===i.path;return S.jsxs("div",{className:`flex items-center p-1.5 group rounded-md ${w?"bg-indigo-900 bg-opacity-50":"hover:bg-gray-700"}`,children:[S.jsx("input",{type:"checkbox",checked:x,onChange:_,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),S.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>o(t,i.path),children:[S.jsx(qv,{className:"w-5 h-5 mr-2 text-gray-400"}),S.jsx("span",{className:w?"text-white":"text-gray-300",children:i.name})]})]})},Vv=i=>{const{repo:t,tree:o,onFileClick:s,onStartJellyfish:r,selectedFilePath:c,selectedRepo:d,selectedFiles:h,onFileSelection:y,onDirectorySelection:m}=i,v=t.full_name===d,[E,_]=Q.useState(v);return Q.useEffect(()=>{v&&!E&&_(!0)},[v,E]),S.jsxs("div",{className:"mb-2",children:[S.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-700 rounded-md group",children:[S.jsxs("h3",{className:"text-lg font-semibold cursor-pointer flex items-center flex-grow",onClick:()=>_(!E),children:[E?S.jsx(Tg,{className:"w-5 h-5 mr-2"}):S.jsx(vg,{className:"w-5 h-5 mr-2"}),t.full_name]}),S.jsx("button",{onClick:x=>{x.stopPropagation(),r(t.full_name)},className:"opacity-0 group-hover:opacity-100 p-1 bg-pink-600 rounded hover:bg-pink-500 transition-opacity",title:"Start Jellyfish Swarm (Repository Overhaul)",children:S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 text-white",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"})})})]}),E&&S.jsx("div",{className:"pl-4 border-l border-gray-700 ml-2",children:o.map(x=>S.jsx(Sg,{node:x,repoFullName:t.full_name,onFileClick:s,selectedFilePath:c,selectedRepo:d,selectedFiles:h,onFileSelection:y,onDirectorySelection:m},x.path))})]})},zv=({fileTree:i,onFileSelect:t,onStartMultiEdit:o,onStartNewProject:s,onStartProjectExpansion:r,onStartJellyfish:c,selectedFilePath:d,selectedRepo:h,selectedFiles:y,onFileSelection:m,onDirectorySelection:v})=>S.jsxs("div",{className:"p-4 text-gray-300 h-full flex flex-col",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 border-b border-gray-700 pb-2 flex-shrink-0",children:[S.jsx("h2",{className:"text-xl font-bold",children:"Repositories"}),S.jsxs("button",{onClick:s,className:"flex items-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:[S.jsx(Hv,{className:"w-4 h-4"}),"New AI Project"]})]}),S.jsxs("div",{className:"flex-grow overflow-y-auto",children:[y.size>0&&S.jsxs("div",{className:"mb-4 sticky top-0 bg-gray-900 py-2 z-10 space-y-2",children:[S.jsxs("button",{onClick:o,className:"w-full flex items-center justify-center gap-2 bg-amber-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-amber-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-amber-500 transition-colors",children:[S.jsx(xc,{className:"w-5 h-5"}),"AI Edit ",y.size," Selected File",y.size>1?"s":""]}),S.jsxs("button",{onClick:r,disabled:y.size!==1,className:"w-full flex items-center justify-center gap-2 bg-purple-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-purple-500 transition-colors disabled:bg-gray-600 disabled:cursor-not-allowed",title:y.size!==1?"You must select exactly 1 file to use this feature.":"Expand the project based on this seed file.",children:[S.jsx(kv,{className:"w-5 h-5"}),"Expand Project (Seed)"]})]}),Object.keys(i).sort().map(E=>S.jsx(Vv,{repo:i[E].repo,tree:i[E].tree,onFileClick:t,onStartJellyfish:c,selectedFilePath:d,selectedRepo:h,selectedFiles:y,onFileSelection:m,onDirectorySelection:v},E))]})]}),Bv=({onClose:i,onCommit:t,isLoading:o,defaultMessage:s})=>{const[r,c]=Q.useState(s);Q.useEffect(()=>{c(s)},[s]);const d=async h=>{h.preventDefault(),!(!r.trim()||o)&&await t(r)};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-lg border border-gray-700",onClick:h=>h.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-green-400 mb-4",children:"Commit Changes"}),S.jsxs("form",{onSubmit:d,children:[S.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Enter a commit message:"}),S.jsx("input",{type:"text",value:r,onChange:h=>c(h.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}),S.jsxs("div",{className:"flex justify-end gap-4",children:[S.jsx("button",{type:"button",onClick:i,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"}),S.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?S.jsx(ot,{}):"Commit"})]})]})]})})},Ov=i=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:S.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"})}),Fv=({file:i,isActive:t,onSelect:o,onClose:s})=>{const r=i.content!==i.editedContent,c=i.repoFullName+"::"+i.path,d=i.path.split("/").pop();return S.jsxs("div",{onClick:()=>o(c),className:`flex items-center justify-between p-2 px-4 cursor-pointer border-b-2 ${t?"bg-gray-850 border-indigo-500 text-white":"bg-gray-900 border-transparent text-gray-400 hover:bg-gray-800"}`,children:[S.jsx("span",{className:"text-sm font-medium pr-2",children:d}),S.jsxs("div",{className:"flex items-center",children:[r&&S.jsx("div",{className:"w-2 h-2 bg-yellow-400 rounded-full mr-2"}),S.jsx("button",{onClick:h=>{h.stopPropagation(),s(c)},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:"×"})]})]})},Jv=({openFiles:i,activeFile:t,onCommit:o,onAdvancedAiEdit:s,onSimpleAiEditRequest:r,onFileContentChange:c,onCloseFile:d,onSetActiveFile:h,isLoading:y,branches:m,currentBranch:v,onBranchChange:E,onCreateBranch:_,onCreatePullRequest:x})=>{const[w,I]=Q.useState(!1),[M,V]=Q.useState(""),[$,O]=Q.useState(!1),[J,ne]=Q.useState(!1),[z,X]=Q.useState(""),[ve,W]=Q.useState("");Q.useEffect(()=>{if(t){const L=`Update ${t.path}`;X(L)}},[t]);const Ee=t?t.editedContent!==t.content:!1,Ne=async L=>{!L.trim()||!t||(await o(L),I(!1))},Ve=async()=>{M.trim()&&(await _(M),V(""),O(!1))},je=async()=>{z.trim()&&(await x(z,ve),ne(!1),W(""))};if(!t)return S.jsx("div",{className:"flex-grow flex items-center justify-center bg-gray-850 text-gray-500",children:S.jsx("p",{children:"Select a file from the explorer to begin editing."})});const qe=t.repoFullName+"::"+t.path,Ye=`Update ${t.path}`;return S.jsxs("div",{className:"flex flex-col h-full bg-gray-850 relative",children:[S.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-700 bg-gray-900 flex-wrap gap-2",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-md font-semibold text-gray-200",children:t.path}),S.jsx("p",{className:"text-xs text-gray-400",children:t.repoFullName})]}),S.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{id:"branch-select",value:v||"",onChange:L=>E(L.target.value),disabled:y,className:"bg-gray-800 p-2 rounded-md text-sm border border-gray-700 focus:outline-none focus:ring-2 focus:ring-cyan-500",children:m.map(L=>S.jsx("option",{value:L.name,children:L.name},L.name))}),$?S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx("input",{type:"text",value:M,onChange:L=>V(L.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"}),S.jsx("button",{onClick:Ve,disabled:y||!M.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"}),S.jsx("button",{onClick:()=>O(!1),className:"text-sm bg-gray-600 text-white font-semibold py-1 px-2 rounded hover:bg-gray-700",children:"X"})]}):S.jsx("button",{onClick:()=>O(!0),className:"text-sm text-cyan-400 hover:underline px-3 py-1.5",disabled:y,children:"New Branch"})]}),S.jsx("button",{onClick:()=>I(!0),disabled:y||!Ee,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"}),v&&v!==t.defaultBranch&&S.jsx("button",{onClick:()=>ne(!J),className:"bg-cyan-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-cyan-700 disabled:bg-gray-500",disabled:y,children:J?"Cancel PR":"Create Pull Request"})]})]}),J&&S.jsxs("div",{className:"p-4 bg-gray-800 border-b border-gray-700",children:[S.jsx("h4",{className:"font-semibold mb-2 text-gray-200",children:"New Pull Request"}),S.jsxs("p",{className:"text-xs text-gray-400 mb-2",children:["From ",S.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:v})," into ",S.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:t.defaultBranch})]}),S.jsx("input",{type:"text",value:z,onChange:L=>X(L.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"}),S.jsx("textarea",{value:ve,onChange:L=>W(L.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"}),S.jsx("div",{className:"flex gap-2",children:S.jsx("button",{onClick:je,disabled:y||!z.trim(),className:"text-sm bg-cyan-600 text-white font-semibold py-1 px-2 rounded hover:bg-cyan-700 disabled:bg-gray-500 flex items-center justify-center",children:y?S.jsx(ot,{className:"h-4 w-4"}):"Submit Pull Request"})})]}),S.jsx("div",{className:"flex border-b border-gray-700 bg-gray-900 overflow-x-auto",children:i.map(L=>S.jsx(Fv,{file:L,isActive:L.repoFullName+"::"+L.path===qe,onSelect:h,onClose:d},L.repoFullName+"::"+L.path))}),S.jsx("div",{className:"flex-grow p-4",children:S.jsx("textarea",{value:t.editedContent,onChange:L=>c(qe,L.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"},qe)}),S.jsxs("div",{className:"absolute bottom-6 right-6 flex flex-col gap-3",children:[S.jsx("button",{onClick:s,className:"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",title:"Advanced AI Edit (Repository-Aware)","aria-label":"Advanced Edit with AI",children:S.jsx(Ov,{className:"h-6 w-6"})}),S.jsx("button",{onClick:r,className:"bg-cyan-600 text-white rounded-full p-4 shadow-lg hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-4 focus:ring-offset-gray-850 focus:ring-cyan-500 transition-transform hover:scale-110",title:"Simple AI Edit (Rewrite Active File)","aria-label":"Simple Rewrite with AI",children:S.jsx(xc,{className:"h-6 w-6"})})]}),w&&S.jsx(Bv,{onClose:()=>I(!1),onCommit:Ne,isLoading:y,defaultMessage:Ye})]})},Yv="https://api.github.com";async function tn(i,t,o={}){var r;const s=await fetch(`${Yv}${i}`,{...o,headers:{...o.headers,Authorization:`Bearer ${t}`,Accept:"application/vnd.github.v3+json","X-GitHub-Api-Version":"2022-11-28"}});if(!s.ok){if((r=s.headers.get("content-type"))!=null&&r.includes("text/plain")){const d=await s.text();throw new Error(`GitHub API Error: ${s.status} ${d}`)}const c=await s.json();throw new Error(`GitHub API Error: ${s.status} ${c.message||""}`)}return s.status===204||s.status===201&&!s.body?null:o.headers&&o.headers.Accept==="application/vnd.github.v3.raw"?s.text():s.json()}async function Ih(i){let t=[],o=1;const s=100;for(;;){const r=await tn(`/user/repos?type=owner&per_page=${s}&page=${o}`,i);if(t=t.concat(r),r.length{const t={children:{}};i.forEach(s=>{if(s.type!=="blob")return;const r=s.path.split("/");let c=t.children;r.forEach((d,h)=>{const y=h===r.length-1,m=r.slice(0,h+1).join("/");y?c[d]||(c[d]={type:"file",path:s.path,name:d}):(c[d]||(c[d]={type:"dir",path:m,name:d,children:{}}),c=c[d].children)})});const o=s=>{const r=Object.values(s).map(c=>{if(c.type==="dir"){const d=o(c.children);return{...c,children:d}}return c});return r.sort((c,d)=>c.type!==d.type?c.type==="dir"?-1:1:c.name.localeCompare(d.name)),r};return o(t.children)};async function Dh(i,t,o,s){const{tree:r}=await tn(`/repos/${t}/${o}/git/trees/${s}?recursive=1`,i);return Kv(r)}async function Io(i,t,o,s,r){const c=r?`/repos/${t}/${o}/contents/${s}?ref=${r}`:`/repos/${t}/${o}/contents/${s}`,d=await tn(c,i);return{...d,content:atob(d.content)}}async function ec(i,t,o){return tn(`/repos/${t}/${o}/branches?per_page=100`,i)}async function Xv(i,t,o,s,r){const c={ref:`refs/heads/${s}`,sha:r};return tn(`/repos/${t}/${o}/git/refs`,i,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json"}})}async function $v({token:i,name:t,description:o,isPrivate:s}){return tn("/user/repos",i,{method:"POST",body:JSON.stringify({name:t,description:o,private:s,auto_init:!0}),headers:{"Content-Type":"application/json"}})}function Qv(i){return btoa(unescape(encodeURIComponent(i)))}async function Do({token:i,owner:t,repo:o,branch:s,path:r,content:c,message:d,sha:h}){const y={message:d,content:Qv(c),...h&&{sha:h},branch:s};return(await tn(`/repos/${t}/${o}/contents/${r}`,i,{method:"PUT",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})).content.sha}async function Zv({token:i,owner:t,repo:o,title:s,body:r,head:c,base:d}){const h={title:s,body:r,head:c,base:d};return tn(`/repos/${t}/${o}/pulls`,i,{method:"POST",body:JSON.stringify(h),headers:{"Content-Type":"application/json"}})}async function Wv(i,t,o){return tn(`/repos/${t}/${o}/actions/workflows`,i)}async function jv(i,t,o,s,r){const c={ref:r};return tn(`/repos/${t}/${o}/actions/workflows/${s}/dispatches`,i,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json"}})}async function eT(i,t,o,s,r){return tn(`/repos/${t}/${o}/actions/workflows/${s}/runs?branch=${encodeURIComponent(r)}`,i)}async function tT(i,t,o,s){const r=await tn(`/repos/${t}/${o}/actions/runs/${s}/jobs`,i),c=r.jobs.filter(y=>y.conclusion==="failure"),d=c.length>0?c:r.jobs;let h="";for(const y of d)try{const m=await tn(`/repos/${t}/${o}/actions/jobs/${y.id}/logs`,i,{headers:{Accept:"application/vnd.github.v3.raw"}});h+=` --- LOGS FOR JOB ${y.id} (Conclusion: ${y.conclusion}) --- ${m}`}catch(m){console.error(`Could not fetch logs for job ${y.id}`,m),h+=` --- FAILED TO FETCH LOGS FOR JOB ${y.id} ---`}return h}var ql={exports:{}},tc={},nc,Uh;function nT(){if(Uh)return nc;Uh=1;function i(t,o){typeof o=="boolean"&&(o={forever:o}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=o||{},this._maxRetryTime=o&&o.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}return nc=i,i.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},i.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},i.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var o=new Date().getTime();if(t&&o-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var s=this._timeouts.shift();if(s===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),s=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},s),this._options.unref&&this._timer.unref(),!0},i.prototype.attempt=function(t,o){this._fn=t,o&&(o.timeout&&(this._operationTimeout=o.timeout),o.cb&&(this._operationTimeoutCb=o.cb));var s=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){s._operationTimeoutCb()},s._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},i.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},i.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},i.prototype.start=i.prototype.try,i.prototype.errors=function(){return this._errors},i.prototype.attempts=function(){return this._attempts},i.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},o=null,s=0,r=0;r=s&&(o=c,s=h)}return o},nc}var Lh;function iT(){return Lh||(Lh=1,(function(i){var t=nT();i.operation=function(o){var s=i.timeouts(o);return new t(s,{forever:o&&(o.forever||o.retries===1/0),unref:o&&o.unref,maxRetryTime:o&&o.maxRetryTime})},i.timeouts=function(o){if(o instanceof Array)return[].concat(o);var s={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in o)s[r]=o[r];if(s.minTimeout>s.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var c=[],d=0;d{const m=y.retries-(h-1);return d.attemptNumber=h,d.retriesLeft=m,d},r=d=>t.includes(d),c=(d,h)=>new Promise((y,m)=>{h={onFailedAttempt:()=>{},retries:10,...h};const v=i.operation(h);v.attempt(async E=>{try{y(await d(E))}catch(_){if(!(_ instanceof Error)){m(new TypeError(`Non-error was thrown: "${_}". You should only throw errors.`));return}if(_ instanceof o)v.stop(),m(_.originalError);else if(_ instanceof TypeError&&!r(_.message))v.stop(),m(_);else{s(_,E,h);try{await h.onFailedAttempt(_)}catch(x){m(x);return}v.retry(_)||m(v.mainError())}}})});return ql.exports=c,ql.exports.default=c,ql.exports.AbortError=o,ql.exports}var Eg=lT();const sT=_c(Eg);var aT={};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let rT,uT;function cT(){return{geminiUrl:rT,vertexUrl:uT}}function fT(i,t,o,s){var r,c;if(!(i!=null&&i.baseUrl)){const d=cT();return t?(r=d.vertexUrl)!==null&&r!==void 0?r:o:(c=d.geminiUrl)!==null&&c!==void 0?c:s}return i.baseUrl}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Yn{}function Z(i,t){const o=/\{([^}]+)\}/g;return i.replace(o,(s,r)=>{if(Object.prototype.hasOwnProperty.call(t,r)){const c=t[r];return c!=null?String(c):""}else throw new Error(`Key '${r}' not found in valueMap.`)})}function f(i,t,o){for(let c=0;c({}));else throw new Error(`Value must be a list given an array path ${d}`);if(Array.isArray(i[h])){const y=i[h];if(Array.isArray(o))for(let m=0;mu(h,t.slice(s+1),o)):o}else return o}else i=i[r]}return i}catch(s){if(s instanceof TypeError)return o;throw s}}function dT(i,t){for(const[o,s]of Object.entries(t)){const r=o.split("."),c=s.split("."),d=new Set;let h=-1;for(let y=0;yh)for(let y=h;y=t.length||typeof i!="object"||i===null)return;const c=t[s];if(c.endsWith("[]")){const d=c.slice(0,-2),h=i;if(d in h&&Array.isArray(h[d]))for(const y of h[d])ac(y,t,o,s+1,r)}else if(c==="*"){if(typeof i=="object"&&i!==null&&!Array.isArray(i)){const d=i,h=Object.keys(d).filter(m=>!m.startsWith("_")&&!r.has(m)),y={};for(const m of h)y[m]=d[m];for(const[m,v]of Object.entries(y)){const E=[];for(const _ of o.slice(s))_==="*"?E.push(m):E.push(_);f(d,E,v)}for(const m of h)delete d[m]}}else{const d=i;c in d&&ac(d[c],t,o,s+1,r)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Ac(i){if(typeof i!="string")throw new Error("fromImageBytes must be a string");return i}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function pT(i){const t={},o=u(i,["operationName"]);o!=null&&f(t,["operationName"],o);const s=u(i,["resourceName"]);return s!=null&&f(t,["_url","resourceName"],s),t}function hT(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["metadata"]);s!=null&&f(t,["metadata"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);c!=null&&f(t,["error"],c);const d=u(i,["response","generateVideoResponse"]);return d!=null&&f(t,["response"],gT(d)),t}function mT(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["metadata"]);s!=null&&f(t,["metadata"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);c!=null&&f(t,["error"],c);const d=u(i,["response"]);return d!=null&&f(t,["response"],yT(d)),t}function gT(i){const t={},o=u(i,["generatedSamples"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(d=>vT(d))),f(t,["generatedVideos"],c)}const s=u(i,["raiMediaFilteredCount"]);s!=null&&f(t,["raiMediaFilteredCount"],s);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&f(t,["raiMediaFilteredReasons"],r),t}function yT(i){const t={},o=u(i,["videos"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(d=>TT(d))),f(t,["generatedVideos"],c)}const s=u(i,["raiMediaFilteredCount"]);s!=null&&f(t,["raiMediaFilteredCount"],s);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&f(t,["raiMediaFilteredReasons"],r),t}function vT(i){const t={},o=u(i,["video"]);return o!=null&&f(t,["video"],AT(o)),t}function TT(i){const t={},o=u(i,["_self"]);return o!=null&&f(t,["video"],NT(o)),t}function ST(i){const t={},o=u(i,["operationName"]);return o!=null&&f(t,["_url","operationName"],o),t}function ET(i){const t={},o=u(i,["operationName"]);return o!=null&&f(t,["_url","operationName"],o),t}function _T(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["metadata"]);s!=null&&f(t,["metadata"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);c!=null&&f(t,["error"],c);const d=u(i,["response"]);return d!=null&&f(t,["response"],CT(d)),t}function CT(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["parent"]);s!=null&&f(t,["parent"],s);const r=u(i,["documentName"]);return r!=null&&f(t,["documentName"],r),t}function _g(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["metadata"]);s!=null&&f(t,["metadata"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);c!=null&&f(t,["error"],c);const d=u(i,["response"]);return d!=null&&f(t,["response"],xT(d)),t}function xT(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["parent"]);s!=null&&f(t,["parent"],s);const r=u(i,["documentName"]);return r!=null&&f(t,["documentName"],r),t}function AT(i){const t={},o=u(i,["uri"]);o!=null&&f(t,["uri"],o);const s=u(i,["encodedVideo"]);s!=null&&f(t,["videoBytes"],Ac(s));const r=u(i,["encoding"]);return r!=null&&f(t,["mimeType"],r),t}function NT(i){const t={},o=u(i,["gcsUri"]);o!=null&&f(t,["uri"],o);const s=u(i,["bytesBase64Encoded"]);s!=null&&f(t,["videoBytes"],Ac(s));const r=u(i,["mimeType"]);return r!=null&&f(t,["mimeType"],r),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var qh;(function(i){i.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(qh||(qh={}));var Hh;(function(i){i.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",i.PYTHON="PYTHON"})(Hh||(Hh={}));var kh;(function(i){i.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",i.SILENT="SILENT",i.WHEN_IDLE="WHEN_IDLE",i.INTERRUPT="INTERRUPT"})(kh||(kh={}));var _e;(function(i){i.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL"})(_e||(_e={}));var Vh;(function(i){i.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",i.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",i.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",i.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Vh||(Vh={}));var zh;(function(i){i.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",i.SIMPLE_SEARCH="SIMPLE_SEARCH",i.ELASTIC_SEARCH="ELASTIC_SEARCH"})(zh||(zh={}));var Bh;(function(i){i.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",i.NO_AUTH="NO_AUTH",i.API_KEY_AUTH="API_KEY_AUTH",i.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",i.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",i.OAUTH="OAUTH",i.OIDC_AUTH="OIDC_AUTH"})(Bh||(Bh={}));var Oh;(function(i){i.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",i.HTTP_IN_QUERY="HTTP_IN_QUERY",i.HTTP_IN_HEADER="HTTP_IN_HEADER",i.HTTP_IN_PATH="HTTP_IN_PATH",i.HTTP_IN_BODY="HTTP_IN_BODY",i.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(Oh||(Oh={}));var Fh;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.BLOCKING="BLOCKING",i.NON_BLOCKING="NON_BLOCKING"})(Fh||(Fh={}));var Jh;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(Jh||(Jh={}));var Yh;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.AUTO="AUTO",i.ANY="ANY",i.NONE="NONE",i.VALIDATED="VALIDATED"})(Yh||(Yh={}));var Kh;(function(i){i.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH",i.MINIMAL="MINIMAL"})(Kh||(Kh={}));var Xh;(function(i){i.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",i.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",i.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",i.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",i.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",i.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",i.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",i.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",i.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",i.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",i.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(Xh||(Xh={}));var $h;(function(i){i.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",i.SEVERITY="SEVERITY",i.PROBABILITY="PROBABILITY"})($h||($h={}));var Qh;(function(i){i.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE",i.OFF="OFF"})(Qh||(Qh={}));var Zh;(function(i){i.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",i.STOP="STOP",i.MAX_TOKENS="MAX_TOKENS",i.SAFETY="SAFETY",i.RECITATION="RECITATION",i.LANGUAGE="LANGUAGE",i.OTHER="OTHER",i.BLOCKLIST="BLOCKLIST",i.PROHIBITED_CONTENT="PROHIBITED_CONTENT",i.SPII="SPII",i.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",i.IMAGE_SAFETY="IMAGE_SAFETY",i.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",i.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",i.NO_IMAGE="NO_IMAGE",i.IMAGE_RECITATION="IMAGE_RECITATION",i.IMAGE_OTHER="IMAGE_OTHER"})(Zh||(Zh={}));var Wh;(function(i){i.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",i.NEGLIGIBLE="NEGLIGIBLE",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH"})(Wh||(Wh={}));var jh;(function(i){i.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",i.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",i.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",i.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",i.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(jh||(jh={}));var em;(function(i){i.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",i.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",i.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",i.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",i.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(em||(em={}));var tm;(function(i){i.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",i.SAFETY="SAFETY",i.OTHER="OTHER",i.BLOCKLIST="BLOCKLIST",i.PROHIBITED_CONTENT="PROHIBITED_CONTENT",i.IMAGE_SAFETY="IMAGE_SAFETY",i.MODEL_ARMOR="MODEL_ARMOR",i.JAILBREAK="JAILBREAK"})(tm||(tm={}));var nm;(function(i){i.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",i.ON_DEMAND="ON_DEMAND",i.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(nm||(nm={}));var _a;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.AUDIO="AUDIO"})(_a||(_a={}));var im;(function(i){i.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",i.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",i.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",i.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(im||(im={}));var om;(function(i){i.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",i.TUNING_MODE_FULL="TUNING_MODE_FULL",i.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(om||(om={}));var lm;(function(i){i.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",i.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",i.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",i.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",i.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",i.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",i.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(lm||(lm={}));var rc;(function(i){i.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",i.JOB_STATE_QUEUED="JOB_STATE_QUEUED",i.JOB_STATE_PENDING="JOB_STATE_PENDING",i.JOB_STATE_RUNNING="JOB_STATE_RUNNING",i.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",i.JOB_STATE_FAILED="JOB_STATE_FAILED",i.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",i.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",i.JOB_STATE_PAUSED="JOB_STATE_PAUSED",i.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",i.JOB_STATE_UPDATING="JOB_STATE_UPDATING",i.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(rc||(rc={}));var sm;(function(i){i.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",i.TUNING_TASK_I2V="TUNING_TASK_I2V",i.TUNING_TASK_T2V="TUNING_TASK_T2V",i.TUNING_TASK_R2V="TUNING_TASK_R2V"})(sm||(sm={}));var am;(function(i){i.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",i.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",i.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",i.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",i.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(am||(am={}));var uc;(function(i){i.COLLECTION="COLLECTION"})(uc||(uc={}));var rm;(function(i){i.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",i.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",i.BALANCED="BALANCED",i.PRIORITIZE_COST="PRIORITIZE_COST"})(rm||(rm={}));var um;(function(i){i.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",i.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(um||(um={}));var cm;(function(i){i.PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",i.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",i.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE"})(cm||(cm={}));var Ca;(function(i){i.PREDICT="PREDICT",i.EMBED_CONTENT="EMBED_CONTENT"})(Ca||(Ca={}));var fm;(function(i){i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE"})(fm||(fm={}));var dm;(function(i){i.DONT_ALLOW="DONT_ALLOW",i.ALLOW_ADULT="ALLOW_ADULT",i.ALLOW_ALL="ALLOW_ALL"})(dm||(dm={}));var pm;(function(i){i.auto="auto",i.en="en",i.ja="ja",i.ko="ko",i.hi="hi",i.zh="zh",i.pt="pt",i.es="es"})(pm||(pm={}));var hm;(function(i){i.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",i.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",i.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",i.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",i.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(hm||(hm={}));var mm;(function(i){i.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",i.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",i.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",i.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(mm||(mm={}));var gm;(function(i){i.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",i.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",i.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",i.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(gm||(gm={}));var ym;(function(i){i.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",i.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",i.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",i.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",i.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",i.EDIT_MODE_STYLE="EDIT_MODE_STYLE",i.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",i.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(ym||(ym={}));var vm;(function(i){i.FOREGROUND="FOREGROUND",i.BACKGROUND="BACKGROUND",i.PROMPT="PROMPT",i.SEMANTIC="SEMANTIC",i.INTERACTIVE="INTERACTIVE"})(vm||(vm={}));var Tm;(function(i){i.ASSET="ASSET",i.STYLE="STYLE"})(Tm||(Tm={}));var Sm;(function(i){i.INSERT="INSERT",i.REMOVE="REMOVE",i.REMOVE_STATIC="REMOVE_STATIC",i.OUTPAINT="OUTPAINT"})(Sm||(Sm={}));var Em;(function(i){i.OPTIMIZED="OPTIMIZED",i.LOSSLESS="LOSSLESS"})(Em||(Em={}));var _m;(function(i){i.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",i.PREFERENCE_TUNING="PREFERENCE_TUNING",i.DISTILLATION="DISTILLATION"})(_m||(_m={}));var Cm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.STATE_PENDING="STATE_PENDING",i.STATE_ACTIVE="STATE_ACTIVE",i.STATE_FAILED="STATE_FAILED"})(Cm||(Cm={}));var xm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.PROCESSING="PROCESSING",i.ACTIVE="ACTIVE",i.FAILED="FAILED"})(xm||(xm={}));var Am;(function(i){i.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",i.UPLOADED="UPLOADED",i.GENERATED="GENERATED",i.REGISTERED="REGISTERED"})(Am||(Am={}));var Nm;(function(i){i.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",i.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",i.RESPONSE_REJECTED="RESPONSE_REJECTED",i.NEED_MORE_INPUT="NEED_MORE_INPUT"})(Nm||(Nm={}));var bm;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.VIDEO="VIDEO",i.AUDIO="AUDIO",i.DOCUMENT="DOCUMENT"})(bm||(bm={}));var Rm;(function(i){i.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",i.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",i.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(Rm||(Rm={}));var wm;(function(i){i.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.ACTIVITY_START="ACTIVITY_START",i.ACTIVITY_END="ACTIVITY_END"})(wm||(wm={}));var Mm;(function(i){i.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",i.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",i.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Mm||(Mm={}));var Im;(function(i){i.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",i.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",i.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(Im||(Im={}));var Dm;(function(i){i.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",i.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",i.NO_INTERRUPTION="NO_INTERRUPTION"})(Dm||(Dm={}));var Um;(function(i){i.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",i.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",i.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(Um||(Um={}));var Lm;(function(i){i.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",i.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",i.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",i.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",i.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",i.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",i.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",i.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",i.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",i.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",i.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",i.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",i.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(Lm||(Lm={}));var Gm;(function(i){i.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",i.QUALITY="QUALITY",i.DIVERSITY="DIVERSITY",i.VOCALIZATION="VOCALIZATION"})(Gm||(Gm={}));var Lo;(function(i){i.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",i.PLAY="PLAY",i.PAUSE="PAUSE",i.STOP="STOP",i.RESET_CONTEXT="RESET_CONTEXT"})(Lo||(Lo={}));class cc{constructor(t){const o={};for(const s of t.headers.entries())o[s[0]]=s[1];this.headers=o,this.responseInternal=t}json(){return this.responseInternal.json()}}class Hl{get text(){var t,o,s,r,c,d,h,y;if(((r=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[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 m="",v=!1;const E=[];for(const _ of(y=(h=(d=(c=this.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content)===null||h===void 0?void 0:h.parts)!==null&&y!==void 0?y:[]){for(const[x,w]of Object.entries(_))x!=="text"&&x!=="thought"&&x!=="thoughtSignature"&&(w!==null||w!==void 0)&&E.push(x);if(typeof _.text=="string"){if(typeof _.thought=="boolean"&&_.thought)continue;v=!0,m+=_.text}}return E.length>0&&console.warn(`there are non-text parts ${E} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),v?m:void 0}get data(){var t,o,s,r,c,d,h,y;if(((r=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[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 m="";const v=[];for(const E of(y=(h=(d=(c=this.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content)===null||h===void 0?void 0:h.parts)!==null&&y!==void 0?y:[]){for(const[_,x]of Object.entries(E))_!=="inlineData"&&(x!==null||x!==void 0)&&v.push(_);E.inlineData&&typeof E.inlineData.data=="string"&&(m+=atob(E.inlineData.data))}return v.length>0&&console.warn(`there are non-data parts ${v} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),m.length>0?btoa(m):void 0}get functionCalls(){var t,o,s,r,c,d,h,y;if(((r=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[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 m=(y=(h=(d=(c=this.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content)===null||h===void 0?void 0:h.parts)===null||y===void 0?void 0:y.filter(v=>v.functionCall).map(v=>v.functionCall).filter(v=>v!==void 0);if((m==null?void 0:m.length)!==0)return m}get executableCode(){var t,o,s,r,c,d,h,y,m;if(((r=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[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 v=(y=(h=(d=(c=this.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content)===null||h===void 0?void 0:h.parts)===null||y===void 0?void 0:y.filter(E=>E.executableCode).map(E=>E.executableCode).filter(E=>E!==void 0);if((v==null?void 0:v.length)!==0)return(m=v==null?void 0:v[0])===null||m===void 0?void 0:m.code}get codeExecutionResult(){var t,o,s,r,c,d,h,y,m;if(((r=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[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 v=(y=(h=(d=(c=this.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content)===null||h===void 0?void 0:h.parts)===null||y===void 0?void 0:y.filter(E=>E.codeExecutionResult).map(E=>E.codeExecutionResult).filter(E=>E!==void 0);if((v==null?void 0:v.length)!==0)return(m=v==null?void 0:v[0])===null||m===void 0?void 0:m.output}}class Pm{}class qm{}class bT{}class RT{}class wT{}class MT{}class Hm{}class km{}class Vm{}class IT{}class xa{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const s=new xa;let r;const c=t;return o?r=mT(c):r=hT(c),Object.assign(s,r),s}}class zm{}class Bm{}class Om{}class Fm{}class DT{}class UT{}class LT{}class Nc{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const s=new Nc,c=_T(t);return Object.assign(s,c),s}}class GT{}class PT{}class qT{}class HT{}class Jm{}class kT{get text(){var t,o,s;let r="",c=!1;const d=[];for(const h of(s=(o=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[y,m]of Object.entries(h))y!=="text"&&y!=="thought"&&m!==null&&d.push(y);if(typeof h.text=="string"){if(typeof h.thought=="boolean"&&h.thought)continue;c=!0,r+=h.text}}return d.length>0&&console.warn(`there are non-text parts ${d} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),c?r:void 0}get data(){var t,o,s;let r="";const c=[];for(const d of(s=(o=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[h,y]of Object.entries(d))h!=="inlineData"&&y!==null&&c.push(h);d.inlineData&&typeof d.inlineData.data=="string"&&(r+=atob(d.inlineData.data))}return c.length>0&&console.warn(`there are non-data parts ${c} 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 VT{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class bc{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const s=new bc,c=_g(t);return Object.assign(s,c),s}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Oe(i,t){if(!t||typeof t!="string")throw new Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw new Error("invalid model parameter");if(i.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const o=t.split("/",2);return`publishers/${o[0]}/models/${o[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function Cg(i,t){const o=Oe(i,t);return o?o.startsWith("publishers/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/${o}`:o.startsWith("models/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/publishers/google/${o}`:o:""}function xg(i){return Array.isArray(i)?i.map(t=>Aa(t)):[Aa(i)]}function Aa(i){if(typeof i=="object"&&i!==null)return i;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof i}`)}function Ag(i){const t=Aa(i);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function Ng(i){const t=Aa(i);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function Ym(i){if(i==null)throw new Error("PartUnion is required");if(typeof i=="object")return i;if(typeof i=="string")return{text:i};throw new Error(`Unsupported part type: ${typeof i}`)}function bg(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("PartListUnion is required");return Array.isArray(i)?i.map(t=>Ym(t)):[Ym(i)]}function fc(i){return i!=null&&typeof i=="object"&&"parts"in i&&Array.isArray(i.parts)}function Km(i){return i!=null&&typeof i=="object"&&"functionCall"in i}function Xm(i){return i!=null&&typeof i=="object"&&"functionResponse"in i}function Ct(i){if(i==null)throw new Error("ContentUnion is required");return fc(i)?i:{role:"user",parts:bg(i)}}function Rc(i,t){if(!t)return[];if(i.isVertexAI()&&Array.isArray(t))return t.flatMap(o=>{const s=Ct(o);return s.parts&&s.parts.length>0&&s.parts[0].text!==void 0?[s.parts[0].text]:[]});if(i.isVertexAI()){const o=Ct(t);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]}return Array.isArray(t)?t.map(o=>Ct(o)):[Ct(t)]}function en(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("contents are required");if(!Array.isArray(i)){if(Km(i)||Xm(i))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[Ct(i)]}const t=[],o=[],s=fc(i[0]);for(const r of i){const c=fc(r);if(c!=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(c)t.push(r);else{if(Km(r)||Xm(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||t.push({role:"user",parts:bg(o)}),t}function zT(i,t){i.includes("null")&&(t.nullable=!0);const o=i.filter(s=>s!=="null");if(o.length===1)t.type=Object.values(_e).includes(o[0].toUpperCase())?o[0].toUpperCase():_e.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const s of o)t.anyOf.push({type:Object.values(_e).includes(s.toUpperCase())?s.toUpperCase():_e.TYPE_UNSPECIFIED})}}function Po(i){const t={},o=["items"],s=["anyOf"],r=["properties"];if(i.type&&i.anyOf)throw new Error("type and anyOf cannot be both populated.");const c=i.anyOf;c!=null&&c.length==2&&(c[0].type==="null"?(t.nullable=!0,i=c[1]):c[1].type==="null"&&(t.nullable=!0,i=c[0])),i.type instanceof Array&&zT(i.type,t);for(const[d,h]of Object.entries(i))if(h!=null)if(d=="type"){if(h==="null")throw new Error("type: null can not be the only possible type for the field.");if(h instanceof Array)continue;t.type=Object.values(_e).includes(h.toUpperCase())?h.toUpperCase():_e.TYPE_UNSPECIFIED}else if(o.includes(d))t[d]=Po(h);else if(s.includes(d)){const y=[];for(const m of h){if(m.type=="null"){t.nullable=!0;continue}y.push(Po(m))}t[d]=y}else if(r.includes(d)){const y={};for(const[m,v]of Object.entries(h))y[m]=Po(v);t[d]=y}else{if(d==="additionalProperties")continue;t[d]=h}return t}function wc(i){return Po(i)}function Mc(i){if(typeof i=="object")return i;if(typeof i=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:i}}};throw new Error(`Unsupported speechConfig type: ${typeof i}`)}function Ic(i){if("multiSpeakerVoiceConfig"in i)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return i}function ko(i){if(i.functionDeclarations)for(const t of i.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=Po(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Po(t.response));return i}function Vo(i){if(i==null)throw new Error("tools is required");if(!Array.isArray(i))throw new Error("tools is required and must be an array of Tools");const t=[];for(const o of i)t.push(o);return t}function BT(i,t,o,s=1){const r=!t.startsWith(`${o}/`)&&t.split("/").length===s;return i.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${i.getProject()}/${t}`:t.startsWith(`${o}/`)?`projects/${i.getProject()}/locations/${i.getLocation()}/${t}`:r?`projects/${i.getProject()}/locations/${i.getLocation()}/${o}/${t}`:t:r?`${o}/${t}`:t}function Kn(i,t){if(typeof t!="string")throw new Error("name must be a string");return BT(i,t,"cachedContents")}function Rg(i){switch(i){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 i}}function Si(i){return Ac(i)}function OT(i){return i!=null&&typeof i=="object"&&"name"in i}function FT(i){return i!=null&&typeof i=="object"&&"video"in i}function JT(i){return i!=null&&typeof i=="object"&&"uri"in i}function wg(i){var t;let o;if(OT(i)&&(o=i.name),!(JT(i)&&(o=i.uri,o===void 0))&&!(FT(i)&&(o=(t=i.video)===null||t===void 0?void 0:t.uri,o===void 0))){if(typeof i=="string"&&(o=i),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 Mg(i,t){let o;return i.isVertexAI()?o=t?"publishers/google/models":"models":o=t?"models":"tunedModels",o}function Ig(i){for(const t of["models","tunedModels","publisherModels"])if(YT(i,t))return i[t];return[]}function YT(i,t){return i!==null&&typeof i=="object"&&t in i}function KT(i,t={}){const o=i,s={name:o.name,description:o.description,parametersJsonSchema:o.inputSchema};return o.outputSchema&&(s.responseJsonSchema=o.outputSchema),t.behavior&&(s.behavior=t.behavior),{functionDeclarations:[s]}}function XT(i,t={}){const o=[],s=new Set;for(const r of i){const c=r.name;if(s.has(c))throw new Error(`Duplicate function name ${c} found in MCP tools. Please ensure function names are unique.`);s.add(c);const d=KT(r,t);d.functionDeclarations&&o.push(...d.functionDeclarations)}return{functionDeclarations:o}}function Dg(i,t){let o;if(typeof t=="string")if(i.isVertexAI())if(t.startsWith("gs://"))o={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))o={format:"bigquery",bigqueryUri:t};else throw new Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))o={fileName:t};else throw new Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(i.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");o={inlinedRequests:t}}else o=t;const s=[o.gcsUri,o.bigqueryUri].filter(Boolean).length,r=[o.inlinedRequests,o.fileName].filter(Boolean).length;if(i.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 $T(i){if(typeof i!="string")return i;const t=i;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}function Ug(i){if(typeof i!="object"||i===null)return{};const t=i,o=t.inlinedResponses;if(typeof o!="object"||o===null)return i;const r=o.inlinedResponses;if(!Array.isArray(r)||r.length===0)return i;let c=!1;for(const d of r){if(typeof d!="object"||d===null)continue;const y=d.response;if(typeof y!="object"||y===null)continue;if(y.embedding!==void 0){c=!0;break}}return c&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),i}function zo(i,t){const o=t;if(!i.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 Lg(i){const t=i;return t==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":t==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":t==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":t==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":t==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":t==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":t==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":t}function QT(i){return i.includes("gemini")&&i!=="gemini-embedding-001"||i.includes("maas")}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function ZT(i){const t={},o=u(i,["responsesFile"]);o!=null&&f(t,["fileName"],o);const s=u(i,["inlinedResponses","inlinedResponses"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(d=>IS(d))),f(t,["inlinedResponses"],c)}const r=u(i,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["inlinedEmbedContentResponses"],c)}return t}function WT(i){const t={},o=u(i,["predictionsFormat"]);o!=null&&f(t,["format"],o);const s=u(i,["gcsDestination","outputUriPrefix"]);s!=null&&f(t,["gcsUri"],s);const r=u(i,["bigqueryDestination","outputUri"]);return r!=null&&f(t,["bigqueryUri"],r),t}function jT(i){const t={},o=u(i,["format"]);o!=null&&f(t,["predictionsFormat"],o);const s=u(i,["gcsUri"]);s!=null&&f(t,["gcsDestination","outputUriPrefix"],s);const r=u(i,["bigqueryUri"]);if(r!=null&&f(t,["bigqueryDestination","outputUri"],r),u(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(i,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(u(i,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function Ta(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["metadata","displayName"]);s!=null&&f(t,["displayName"],s);const r=u(i,["metadata","state"]);r!=null&&f(t,["state"],Lg(r));const c=u(i,["metadata","createTime"]);c!=null&&f(t,["createTime"],c);const d=u(i,["metadata","endTime"]);d!=null&&f(t,["endTime"],d);const h=u(i,["metadata","updateTime"]);h!=null&&f(t,["updateTime"],h);const y=u(i,["metadata","model"]);y!=null&&f(t,["model"],y);const m=u(i,["metadata","output"]);return m!=null&&f(t,["dest"],ZT(Ug(m))),t}function dc(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["displayName"]);s!=null&&f(t,["displayName"],s);const r=u(i,["state"]);r!=null&&f(t,["state"],Lg(r));const c=u(i,["error"]);c!=null&&f(t,["error"],c);const d=u(i,["createTime"]);d!=null&&f(t,["createTime"],d);const h=u(i,["startTime"]);h!=null&&f(t,["startTime"],h);const y=u(i,["endTime"]);y!=null&&f(t,["endTime"],y);const m=u(i,["updateTime"]);m!=null&&f(t,["updateTime"],m);const v=u(i,["model"]);v!=null&&f(t,["model"],v);const E=u(i,["inputConfig"]);E!=null&&f(t,["src"],eS(E));const _=u(i,["outputConfig"]);_!=null&&f(t,["dest"],WT(Ug(_)));const x=u(i,["completionStats"]);return x!=null&&f(t,["completionStats"],x),t}function eS(i){const t={},o=u(i,["instancesFormat"]);o!=null&&f(t,["format"],o);const s=u(i,["gcsSource","uris"]);s!=null&&f(t,["gcsUri"],s);const r=u(i,["bigquerySource","inputUri"]);return r!=null&&f(t,["bigqueryUri"],r),t}function tS(i,t){const o={};if(u(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(u(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const s=u(t,["fileName"]);s!=null&&f(o,["fileName"],s);const r=u(t,["inlinedRequests"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>MS(i,d))),f(o,["requests","requests"],c)}return o}function nS(i){const t={},o=u(i,["format"]);o!=null&&f(t,["instancesFormat"],o);const s=u(i,["gcsUri"]);s!=null&&f(t,["gcsSource","uris"],s);const r=u(i,["bigqueryUri"]);if(r!=null&&f(t,["bigquerySource","inputUri"],r),u(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(i,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function iS(i){const t={},o=u(i,["data"]);if(o!=null&&f(t,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function oS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],zo(i,s)),o}function lS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],zo(i,s)),o}function sS(i){const t={},o=u(i,["content"]);o!=null&&f(t,["content"],o);const s=u(i,["citationMetadata"]);s!=null&&f(t,["citationMetadata"],aS(s));const r=u(i,["tokenCount"]);r!=null&&f(t,["tokenCount"],r);const c=u(i,["finishReason"]);c!=null&&f(t,["finishReason"],c);const d=u(i,["groundingMetadata"]);d!=null&&f(t,["groundingMetadata"],d);const h=u(i,["avgLogprobs"]);h!=null&&f(t,["avgLogprobs"],h);const y=u(i,["index"]);y!=null&&f(t,["index"],y);const m=u(i,["logprobsResult"]);m!=null&&f(t,["logprobsResult"],m);const v=u(i,["safetyRatings"]);if(v!=null){let _=v;Array.isArray(_)&&(_=_.map(x=>x)),f(t,["safetyRatings"],_)}const E=u(i,["urlContextMetadata"]);return E!=null&&f(t,["urlContextMetadata"],E),t}function aS(i){const t={},o=u(i,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),f(t,["citations"],s)}return t}function Gg(i){const t={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(c=>HS(c))),f(t,["parts"],r)}const s=u(i,["role"]);return s!=null&&f(t,["role"],s),t}function rS(i,t){const o={},s=u(i,["displayName"]);if(t!==void 0&&s!=null&&f(t,["batch","displayName"],s),u(i,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function uS(i,t){const o={},s=u(i,["displayName"]);t!==void 0&&s!=null&&f(t,["displayName"],s);const r=u(i,["dest"]);return t!==void 0&&r!=null&&f(t,["outputConfig"],jT($T(r))),o}function $m(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["_url","model"],Oe(i,s));const r=u(t,["src"]);r!=null&&f(o,["batch","inputConfig"],tS(i,Dg(i,r)));const c=u(t,["config"]);return c!=null&&rS(c,o),o}function cS(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["model"],Oe(i,s));const r=u(t,["src"]);r!=null&&f(o,["inputConfig"],nS(Dg(i,r)));const c=u(t,["config"]);return c!=null&&uS(c,o),o}function fS(i,t){const o={},s=u(i,["displayName"]);return t!==void 0&&s!=null&&f(t,["batch","displayName"],s),o}function dS(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["_url","model"],Oe(i,s));const r=u(t,["src"]);r!=null&&f(o,["batch","inputConfig"],TS(i,r));const c=u(t,["config"]);return c!=null&&fS(c,o),o}function pS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],zo(i,s)),o}function hS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],zo(i,s)),o}function mS(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["name"]);s!=null&&f(t,["name"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);return c!=null&&f(t,["error"],c),t}function gS(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["name"]);s!=null&&f(t,["name"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);return c!=null&&f(t,["error"],c),t}function yS(i,t){const o={},s=u(t,["contents"]);if(s!=null){let c=Rc(i,s);Array.isArray(c)&&(c=c.map(d=>d)),f(o,["requests[]","request","content"],c)}const r=u(t,["config"]);return r!=null&&(f(o,["_self"],vS(r,o)),dT(o,{"requests[].*":"requests[].request.*"})),o}function vS(i,t){const o={},s=u(i,["taskType"]);t!==void 0&&s!=null&&f(t,["requests[]","taskType"],s);const r=u(i,["title"]);t!==void 0&&r!=null&&f(t,["requests[]","title"],r);const c=u(i,["outputDimensionality"]);if(t!==void 0&&c!=null&&f(t,["requests[]","outputDimensionality"],c),u(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function TS(i,t){const o={},s=u(t,["fileName"]);s!=null&&f(o,["file_name"],s);const r=u(t,["inlinedRequests"]);return r!=null&&f(o,["requests"],yS(i,r)),o}function SS(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&f(t,["fileUri"],o);const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function ES(i){const t={},o=u(i,["id"]);o!=null&&f(t,["id"],o);const s=u(i,["args"]);s!=null&&f(t,["args"],s);const r=u(i,["name"]);if(r!=null&&f(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function _S(i){const t={},o=u(i,["allowedFunctionNames"]);o!=null&&f(t,["allowedFunctionNames"],o);const s=u(i,["mode"]);if(s!=null&&f(t,["mode"],s),u(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function CS(i,t,o){const s={},r=u(t,["systemInstruction"]);o!==void 0&&r!=null&&f(o,["systemInstruction"],Gg(Ct(r)));const c=u(t,["temperature"]);c!=null&&f(s,["temperature"],c);const d=u(t,["topP"]);d!=null&&f(s,["topP"],d);const h=u(t,["topK"]);h!=null&&f(s,["topK"],h);const y=u(t,["candidateCount"]);y!=null&&f(s,["candidateCount"],y);const m=u(t,["maxOutputTokens"]);m!=null&&f(s,["maxOutputTokens"],m);const v=u(t,["stopSequences"]);v!=null&&f(s,["stopSequences"],v);const E=u(t,["responseLogprobs"]);E!=null&&f(s,["responseLogprobs"],E);const _=u(t,["logprobs"]);_!=null&&f(s,["logprobs"],_);const x=u(t,["presencePenalty"]);x!=null&&f(s,["presencePenalty"],x);const w=u(t,["frequencyPenalty"]);w!=null&&f(s,["frequencyPenalty"],w);const I=u(t,["seed"]);I!=null&&f(s,["seed"],I);const M=u(t,["responseMimeType"]);M!=null&&f(s,["responseMimeType"],M);const V=u(t,["responseSchema"]);V!=null&&f(s,["responseSchema"],wc(V));const $=u(t,["responseJsonSchema"]);if($!=null&&f(s,["responseJsonSchema"],$),u(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const O=u(t,["safetySettings"]);if(o!==void 0&&O!=null){let je=O;Array.isArray(je)&&(je=je.map(qe=>kS(qe))),f(o,["safetySettings"],je)}const J=u(t,["tools"]);if(o!==void 0&&J!=null){let je=Vo(J);Array.isArray(je)&&(je=je.map(qe=>zS(ko(qe)))),f(o,["tools"],je)}const ne=u(t,["toolConfig"]);if(o!==void 0&&ne!=null&&f(o,["toolConfig"],VS(ne)),u(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const z=u(t,["cachedContent"]);o!==void 0&&z!=null&&f(o,["cachedContent"],Kn(i,z));const X=u(t,["responseModalities"]);X!=null&&f(s,["responseModalities"],X);const ve=u(t,["mediaResolution"]);ve!=null&&f(s,["mediaResolution"],ve);const W=u(t,["speechConfig"]);if(W!=null&&f(s,["speechConfig"],Mc(W)),u(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Ee=u(t,["thinkingConfig"]);Ee!=null&&f(s,["thinkingConfig"],Ee);const Ne=u(t,["imageConfig"]);Ne!=null&&f(s,["imageConfig"],wS(Ne));const Ve=u(t,["enableEnhancedCivicAnswers"]);if(Ve!=null&&f(s,["enableEnhancedCivicAnswers"],Ve),u(t,["modelArmorConfig"])!==void 0)throw new Error("modelArmorConfig parameter is not supported in Gemini API.");return s}function xS(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(m=>sS(m))),f(t,["candidates"],y)}const r=u(i,["modelVersion"]);r!=null&&f(t,["modelVersion"],r);const c=u(i,["promptFeedback"]);c!=null&&f(t,["promptFeedback"],c);const d=u(i,["responseId"]);d!=null&&f(t,["responseId"],d);const h=u(i,["usageMetadata"]);return h!=null&&f(t,["usageMetadata"],h),t}function AS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],zo(i,s)),o}function NS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],zo(i,s)),o}function bS(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&f(t,["enableWidget"],o),t}function RS(i){const t={},o=u(i,["searchTypes"]);if(o!=null&&f(t,["searchTypes"],o),u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const s=u(i,["timeRangeFilter"]);return s!=null&&f(t,["timeRangeFilter"],s),t}function wS(i){const t={},o=u(i,["aspectRatio"]);o!=null&&f(t,["aspectRatio"],o);const s=u(i,["imageSize"]);if(s!=null&&f(t,["imageSize"],s),u(i,["personGeneration"])!==void 0)throw new Error("personGeneration parameter is not supported in Gemini API.");if(u(i,["prominentPeople"])!==void 0)throw new Error("prominentPeople parameter is not supported in Gemini API.");if(u(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(u(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function MS(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["request","model"],Oe(i,s));const r=u(t,["contents"]);if(r!=null){let h=en(r);Array.isArray(h)&&(h=h.map(y=>Gg(y))),f(o,["request","contents"],h)}const c=u(t,["metadata"]);c!=null&&f(o,["metadata"],c);const d=u(t,["config"]);return d!=null&&f(o,["request","generationConfig"],CS(i,d,u(o,["request"],{}))),o}function IS(i){const t={},o=u(i,["response"]);o!=null&&f(t,["response"],xS(o));const s=u(i,["metadata"]);s!=null&&f(t,["metadata"],s);const r=u(i,["error"]);return r!=null&&f(t,["error"],r),t}function DS(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);if(t!==void 0&&r!=null&&f(t,["_query","pageToken"],r),u(i,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function US(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);t!==void 0&&r!=null&&f(t,["_query","pageToken"],r);const c=u(i,["filter"]);return t!==void 0&&c!=null&&f(t,["_query","filter"],c),o}function LS(i){const t={},o=u(i,["config"]);return o!=null&&DS(o,t),t}function GS(i){const t={},o=u(i,["config"]);return o!=null&&US(o,t),t}function PS(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["operations"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>Ta(d))),f(t,["batchJobs"],c)}return t}function qS(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["batchPredictionJobs"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>dc(d))),f(t,["batchJobs"],c)}return t}function HS(i){const t={},o=u(i,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const s=u(i,["codeExecutionResult"]);s!=null&&f(t,["codeExecutionResult"],s);const r=u(i,["executableCode"]);r!=null&&f(t,["executableCode"],r);const c=u(i,["fileData"]);c!=null&&f(t,["fileData"],SS(c));const d=u(i,["functionCall"]);d!=null&&f(t,["functionCall"],ES(d));const h=u(i,["functionResponse"]);h!=null&&f(t,["functionResponse"],h);const y=u(i,["inlineData"]);y!=null&&f(t,["inlineData"],iS(y));const m=u(i,["text"]);m!=null&&f(t,["text"],m);const v=u(i,["thought"]);v!=null&&f(t,["thought"],v);const E=u(i,["thoughtSignature"]);E!=null&&f(t,["thoughtSignature"],E);const _=u(i,["videoMetadata"]);return _!=null&&f(t,["videoMetadata"],_),t}function kS(i){const t={},o=u(i,["category"]);if(o!=null&&f(t,["category"],o),u(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const s=u(i,["threshold"]);return s!=null&&f(t,["threshold"],s),t}function VS(i){const t={},o=u(i,["retrievalConfig"]);o!=null&&f(t,["retrievalConfig"],o);const s=u(i,["functionCallingConfig"]);return s!=null&&f(t,["functionCallingConfig"],_S(s)),t}function zS(i){const t={};if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=u(i,["computerUse"]);o!=null&&f(t,["computerUse"],o);const s=u(i,["fileSearch"]);s!=null&&f(t,["fileSearch"],s);const r=u(i,["googleSearch"]);r!=null&&f(t,["googleSearch"],RS(r));const c=u(i,["codeExecution"]);if(c!=null&&f(t,["codeExecution"],c),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(i,["functionDeclarations"]);if(d!=null){let E=d;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["functionDeclarations"],E)}const h=u(i,["googleMaps"]);h!=null&&f(t,["googleMaps"],bS(h));const y=u(i,["googleSearchRetrieval"]);y!=null&&f(t,["googleSearchRetrieval"],y);const m=u(i,["urlContext"]);m!=null&&f(t,["urlContext"],m);const v=u(i,["mcpServers"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["mcpServers"],E)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var Jn;(function(i){i.PAGED_ITEM_BATCH_JOBS="batchJobs",i.PAGED_ITEM_MODELS="models",i.PAGED_ITEM_TUNING_JOBS="tuningJobs",i.PAGED_ITEM_FILES="files",i.PAGED_ITEM_CACHED_CONTENTS="cachedContents",i.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",i.PAGED_ITEM_DOCUMENTS="documents"})(Jn||(Jn={}));class zi{constructor(t,o,s,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(t,s,r)}init(t,o,s){var r,c;this.nameInternal=t,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o==null?void 0:o.sdkHttpResponse,this.idxInternal=0;let d={config:{}};!s||Object.keys(s).length===0?d={config:{}}:typeof s=="object"?d=Object.assign({},s):d=s,d.config&&(d.config.pageToken=o.nextPageToken),this.paramsInternal=d,this.pageInternalSize=(c=(r=d.config)===null||r===void 0?void 0:r.pageSize)!==null&&c!==void 0?c:this.pageInternal.length}initNextPage(t){this.init(this.nameInternal,t,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(t){return this.pageInternal[t]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const t=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:t,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const t=await this.requestInternal(this.params);return this.initNextPage(t),this.page}hasNextPage(){var t;return((t=this.params.config)===null||t===void 0?void 0:t.pageToken)!==void 0}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class BS extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new zi(Jn.PAGED_ITEM_BATCH_JOBS,s=>this.listInternal(s),await this.listInternal(o),o),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)}}createInlinedGenerateContentRequest(t){const o=$m(this.apiClient,t),s=o._url,r=Z("{model}:batchGenerateContent",s),h=o.batch.inputConfig.requests,y=h.requests,m=[];for(const v of y){const E=Object.assign({},v);if(E.systemInstruction){const _=E.systemInstruction;delete E.systemInstruction;const x=E.request;x.systemInstruction=_,E.request=x}m.push(E)}return h.requests=m,delete o.config,delete o._url,delete o._query,{path:r,body:o}}getGcsUri(t){if(typeof t=="string")return t.startsWith("gs://")?t:void 0;if(!Array.isArray(t)&&t.gcsUri&&t.gcsUri.length>0)return t.gcsUri[0]}getBigqueryUri(t){if(typeof t=="string")return t.startsWith("bq://")?t:void 0;if(!Array.isArray(t))return t.bigqueryUri}formatDestination(t,o){const s=o?Object.assign({},o):{},r=Date.now().toString();if(s.displayName||(s.displayName=`genaiBatchJob_${r}`),s.dest===void 0){const c=this.getGcsUri(t),d=this.getBigqueryUri(t);if(c)c.endsWith(".jsonl")?s.dest=`${c.slice(0,-6)}/dest`:s.dest=`${c}_dest_${r}`;else if(d)s.dest=`${d}_dest_${r}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return s}async createInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=cS(this.apiClient,t);return h=Z("batchPredictionJobs",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>dc(v))}else{const m=$m(this.apiClient,t);return h=Z("{model}:batchGenerateContent",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>Ta(v))}}async createEmbeddingsInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=dS(this.apiClient,t);return c=Z("{model}:asyncBatchEmbedContent",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>Ta(y))}}async get(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=NS(this.apiClient,t);return h=Z("batchPredictionJobs/{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>dc(v))}else{const m=AS(this.apiClient,t);return h=Z("batches/{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>Ta(v))}}async cancel(t){var o,s,r,c;let d="",h={};if(this.apiClient.isVertexAI()){const y=lS(this.apiClient,t);d=Z("batchPredictionJobs/{name}:cancel",y._url),h=y._query,delete y._url,delete y._query,await this.apiClient.request({path:d,queryParams:h,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal})}else{const y=oS(this.apiClient,t);d=Z("batches/{name}:cancel",y._url),h=y._query,delete y._url,delete y._query,await this.apiClient.request({path:d,queryParams:h,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal})}}async listInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=GS(t);return h=Z("batchPredictionJobs",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=qS(v),_=new Jm;return Object.assign(_,E),_})}else{const m=LS(t);return h=Z("batches",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=PS(v),_=new Jm;return Object.assign(_,E),_})}}async delete(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=hS(this.apiClient,t);return h=Z("batchPredictionJobs/{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>gS(v))}else{const m=pS(this.apiClient,t);return h=Z("batches/{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>mS(v))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function OS(i){const t={},o=u(i,["data"]);if(o!=null&&f(t,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function Qm(i){const t={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(c=>dE(c))),f(t,["parts"],r)}const s=u(i,["role"]);return s!=null&&f(t,["role"],s),t}function FS(i,t){const o={},s=u(i,["ttl"]);t!==void 0&&s!=null&&f(t,["ttl"],s);const r=u(i,["expireTime"]);t!==void 0&&r!=null&&f(t,["expireTime"],r);const c=u(i,["displayName"]);t!==void 0&&c!=null&&f(t,["displayName"],c);const d=u(i,["contents"]);if(t!==void 0&&d!=null){let v=en(d);Array.isArray(v)&&(v=v.map(E=>Qm(E))),f(t,["contents"],v)}const h=u(i,["systemInstruction"]);t!==void 0&&h!=null&&f(t,["systemInstruction"],Qm(Ct(h)));const y=u(i,["tools"]);if(t!==void 0&&y!=null){let v=y;Array.isArray(v)&&(v=v.map(E=>hE(E))),f(t,["tools"],v)}const m=u(i,["toolConfig"]);if(t!==void 0&&m!=null&&f(t,["toolConfig"],pE(m)),u(i,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function JS(i,t){const o={},s=u(i,["ttl"]);t!==void 0&&s!=null&&f(t,["ttl"],s);const r=u(i,["expireTime"]);t!==void 0&&r!=null&&f(t,["expireTime"],r);const c=u(i,["displayName"]);t!==void 0&&c!=null&&f(t,["displayName"],c);const d=u(i,["contents"]);if(t!==void 0&&d!=null){let E=en(d);Array.isArray(E)&&(E=E.map(_=>_)),f(t,["contents"],E)}const h=u(i,["systemInstruction"]);t!==void 0&&h!=null&&f(t,["systemInstruction"],Ct(h));const y=u(i,["tools"]);if(t!==void 0&&y!=null){let E=y;Array.isArray(E)&&(E=E.map(_=>mE(_))),f(t,["tools"],E)}const m=u(i,["toolConfig"]);t!==void 0&&m!=null&&f(t,["toolConfig"],m);const v=u(i,["kmsKeyName"]);return t!==void 0&&v!=null&&f(t,["encryption_spec","kmsKeyName"],v),o}function YS(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["model"],Cg(i,s));const r=u(t,["config"]);return r!=null&&FS(r,o),o}function KS(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["model"],Cg(i,s));const r=u(t,["config"]);return r!=null&&JS(r,o),o}function XS(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],Kn(i,s)),o}function $S(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],Kn(i,s)),o}function QS(i){const t={},o=u(i,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function ZS(i){const t={},o=u(i,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function WS(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&f(t,["fileUri"],o);const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function jS(i){const t={},o=u(i,["id"]);o!=null&&f(t,["id"],o);const s=u(i,["args"]);s!=null&&f(t,["args"],s);const r=u(i,["name"]);if(r!=null&&f(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function eE(i){const t={},o=u(i,["allowedFunctionNames"]);o!=null&&f(t,["allowedFunctionNames"],o);const s=u(i,["mode"]);if(s!=null&&f(t,["mode"],s),u(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function tE(i){const t={},o=u(i,["description"]);o!=null&&f(t,["description"],o);const s=u(i,["name"]);s!=null&&f(t,["name"],s);const r=u(i,["parameters"]);r!=null&&f(t,["parameters"],r);const c=u(i,["parametersJsonSchema"]);c!=null&&f(t,["parametersJsonSchema"],c);const d=u(i,["response"]);d!=null&&f(t,["response"],d);const h=u(i,["responseJsonSchema"]);if(h!=null&&f(t,["responseJsonSchema"],h),u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");return t}function nE(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],Kn(i,s)),o}function iE(i,t){const o={},s=u(t,["name"]);return s!=null&&f(o,["_url","name"],Kn(i,s)),o}function oE(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&f(t,["enableWidget"],o),t}function lE(i){const t={},o=u(i,["searchTypes"]);if(o!=null&&f(t,["searchTypes"],o),u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const s=u(i,["timeRangeFilter"]);return s!=null&&f(t,["timeRangeFilter"],s),t}function sE(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&f(t,["_query","pageToken"],r),o}function aE(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&f(t,["_query","pageToken"],r),o}function rE(i){const t={},o=u(i,["config"]);return o!=null&&sE(o,t),t}function uE(i){const t={},o=u(i,["config"]);return o!=null&&aE(o,t),t}function cE(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["cachedContents"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["cachedContents"],c)}return t}function fE(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["cachedContents"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["cachedContents"],c)}return t}function dE(i){const t={},o=u(i,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const s=u(i,["codeExecutionResult"]);s!=null&&f(t,["codeExecutionResult"],s);const r=u(i,["executableCode"]);r!=null&&f(t,["executableCode"],r);const c=u(i,["fileData"]);c!=null&&f(t,["fileData"],WS(c));const d=u(i,["functionCall"]);d!=null&&f(t,["functionCall"],jS(d));const h=u(i,["functionResponse"]);h!=null&&f(t,["functionResponse"],h);const y=u(i,["inlineData"]);y!=null&&f(t,["inlineData"],OS(y));const m=u(i,["text"]);m!=null&&f(t,["text"],m);const v=u(i,["thought"]);v!=null&&f(t,["thought"],v);const E=u(i,["thoughtSignature"]);E!=null&&f(t,["thoughtSignature"],E);const _=u(i,["videoMetadata"]);return _!=null&&f(t,["videoMetadata"],_),t}function pE(i){const t={},o=u(i,["retrievalConfig"]);o!=null&&f(t,["retrievalConfig"],o);const s=u(i,["functionCallingConfig"]);return s!=null&&f(t,["functionCallingConfig"],eE(s)),t}function hE(i){const t={};if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=u(i,["computerUse"]);o!=null&&f(t,["computerUse"],o);const s=u(i,["fileSearch"]);s!=null&&f(t,["fileSearch"],s);const r=u(i,["googleSearch"]);r!=null&&f(t,["googleSearch"],lE(r));const c=u(i,["codeExecution"]);if(c!=null&&f(t,["codeExecution"],c),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(i,["functionDeclarations"]);if(d!=null){let E=d;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["functionDeclarations"],E)}const h=u(i,["googleMaps"]);h!=null&&f(t,["googleMaps"],oE(h));const y=u(i,["googleSearchRetrieval"]);y!=null&&f(t,["googleSearchRetrieval"],y);const m=u(i,["urlContext"]);m!=null&&f(t,["urlContext"],m);const v=u(i,["mcpServers"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["mcpServers"],E)}return t}function mE(i){const t={},o=u(i,["retrieval"]);o!=null&&f(t,["retrieval"],o);const s=u(i,["computerUse"]);if(s!=null&&f(t,["computerUse"],s),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const r=u(i,["googleSearch"]);r!=null&&f(t,["googleSearch"],r);const c=u(i,["codeExecution"]);c!=null&&f(t,["codeExecution"],c);const d=u(i,["enterpriseWebSearch"]);d!=null&&f(t,["enterpriseWebSearch"],d);const h=u(i,["functionDeclarations"]);if(h!=null){let E=h;Array.isArray(E)&&(E=E.map(_=>tE(_))),f(t,["functionDeclarations"],E)}const y=u(i,["googleMaps"]);y!=null&&f(t,["googleMaps"],y);const m=u(i,["googleSearchRetrieval"]);m!=null&&f(t,["googleSearchRetrieval"],m);const v=u(i,["urlContext"]);if(v!=null&&f(t,["urlContext"],v),u(i,["mcpServers"])!==void 0)throw new Error("mcpServers parameter is not supported in Vertex AI.");return t}function gE(i,t){const o={},s=u(i,["ttl"]);t!==void 0&&s!=null&&f(t,["ttl"],s);const r=u(i,["expireTime"]);return t!==void 0&&r!=null&&f(t,["expireTime"],r),o}function yE(i,t){const o={},s=u(i,["ttl"]);t!==void 0&&s!=null&&f(t,["ttl"],s);const r=u(i,["expireTime"]);return t!==void 0&&r!=null&&f(t,["expireTime"],r),o}function vE(i,t){const o={},s=u(t,["name"]);s!=null&&f(o,["_url","name"],Kn(i,s));const r=u(t,["config"]);return r!=null&&gE(r,o),o}function TE(i,t){const o={},s=u(t,["name"]);s!=null&&f(o,["_url","name"],Kn(i,s));const r=u(t,["config"]);return r!=null&&yE(r,o),o}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class SE extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new zi(Jn.PAGED_ITEM_CACHED_CONTENTS,s=>this.listInternal(s),await this.listInternal(o),o)}async create(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=KS(this.apiClient,t);return h=Z("cachedContents",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>v)}else{const m=YS(this.apiClient,t);return h=Z("cachedContents",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>v)}}async get(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=iE(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>v)}else{const m=nE(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>v)}}async delete(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=$S(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=ZS(v),_=new Om;return Object.assign(_,E),_})}else{const m=XS(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=QS(v),_=new Om;return Object.assign(_,E),_})}}async update(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=TE(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>v)}else{const m=vE(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>v)}}async listInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=uE(t);return h=Z("cachedContents",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=fE(v),_=new Fm;return Object.assign(_,E),_})}else{const m=rE(t);return h=Z("cachedContents",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=cE(v),_=new Fm;return Object.assign(_,E),_})}}}function Na(i,t){var o={};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&t.indexOf(s)<0&&(o[s]=i[s]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(i);r=i.length&&(i=void 0),{value:i&&i[s++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(i){return this instanceof ye?(this.v=i,this):new ye(i)}function yn(i,t,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=o.apply(i,t||[]),r,c=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),h("next"),h("throw"),h("return",d),r[Symbol.asyncIterator]=function(){return this},r;function d(x){return function(w){return Promise.resolve(w).then(x,E)}}function h(x,w){s[x]&&(r[x]=function(I){return new Promise(function(M,V){c.push([x,I,M,V])>1||y(x,I)})},w&&(r[x]=w(r[x])))}function y(x,w){try{m(s[x](w))}catch(I){_(c[0][3],I)}}function m(x){x.value instanceof ye?Promise.resolve(x.value.v).then(v,E):_(c[0][2],x)}function v(x){y("next",x)}function E(x){y("throw",x)}function _(x,w){x(w),c.shift(),c.length&&y(c[0][0],c[0][1])}}function vn(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],o;return t?t.call(i):(i=typeof Zm=="function"?Zm(i):i[Symbol.iterator](),o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o);function s(c){o[c]=i[c]&&function(d){return new Promise(function(h,y){d=i[c](d),r(h,y,d.done,d.value)})}}function r(c,d,h,y){Promise.resolve(y).then(function(m){c({value:m,done:h})},d)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function EE(i){var t;if(i.candidates==null||i.candidates.length===0)return!1;const o=(t=i.candidates[0])===null||t===void 0?void 0:t.content;return o===void 0?!1:Pg(o)}function Pg(i){if(i.parts===void 0||i.parts.length===0)return!1;for(const t of i.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function _E(i){if(i.length!==0){for(const t of i)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function Wm(i){if(i===void 0||i.length===0)return[];const t=[],o=i.length;let s=0;for(;s{var c,d,h;const y=await r,m=(d=(c=y.candidates)===null||c===void 0?void 0:c[0])===null||d===void 0?void 0:d.content,v=y.automaticFunctionCallingHistory,E=this.getHistory(!0).length;let _=[];v!=null&&(_=(h=v.slice(E))!==null&&h!==void 0?h:[]);const x=m?[m]:[];this.recordHistory(s,x,_)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(t){var o;await this.sendPromise;const s=Ct(t.message),r=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(s),config:(o=t.config)!==null&&o!==void 0?o:this.config});this.sendPromise=r.then(()=>{}).catch(()=>{});const c=await r;return this.processStreamResponse(c,s)}getHistory(t=!1){const o=t?Wm(this.history):this.history;return structuredClone(o)}processStreamResponse(t,o){return yn(this,arguments,function*(){var r,c,d,h,y,m;const v=[];try{for(var E=!0,_=vn(t),x;x=yield ye(_.next()),r=x.done,!r;E=!0){h=x.value,E=!1;const w=h;if(EE(w)){const I=(m=(y=w.candidates)===null||y===void 0?void 0:y[0])===null||m===void 0?void 0:m.content;I!==void 0&&v.push(I)}yield yield ye(w)}}catch(w){c={error:w}}finally{try{!E&&!r&&(d=_.return)&&(yield ye(d.call(_)))}finally{if(c)throw c.error}}this.recordHistory(o,v)})}recordHistory(t,o,s){let r=[];o.length>0&&o.every(c=>c.role!==void 0)?r=o:r.push({role:"model",parts:[]}),s&&s.length>0?this.history.push(...Wm(s)):this.history.push(t),this.history.push(...r)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Bl extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,Bl.prototype)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function AE(i){const t={},o=u(i,["file"]);return o!=null&&f(t,["file"],o),t}function NE(i){const t={},o=u(i,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function bE(i){const t={},o=u(i,["name"]);return o!=null&&f(t,["_url","file"],wg(o)),t}function RE(i){const t={},o=u(i,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function wE(i){const t={},o=u(i,["name"]);return o!=null&&f(t,["_url","file"],wg(o)),t}function ME(i){const t={},o=u(i,["uris"]);return o!=null&&f(t,["uris"],o),t}function IE(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&f(t,["_query","pageToken"],r),o}function DE(i){const t={},o=u(i,["config"]);return o!=null&&IE(o,t),t}function UE(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["files"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["files"],c)}return t}function LE(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["files"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(c=>c)),f(t,["files"],r)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class GE extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new zi(Jn.PAGED_ITEM_FILES,s=>this.listInternal(s),await this.listInternal(o),o)}async upload(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(t.file,t.config).then(o=>o)}async download(t){await this.apiClient.downloadFile(t)}async registerFiles(t){throw new Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(t){return this.registerFilesInternal(t)}async listInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=DE(t);return c=Z("files",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const m=UE(y),v=new GT;return Object.assign(v,m),v})}}async createInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=AE(t);return c=Z("upload/v1beta/files",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=NE(y),v=new PT;return Object.assign(v,m),v})}}async get(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=wE(t);return c=Z("files/{file}",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=bE(t);return c=Z("files/{file}",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const m=RE(y),v=new qT;return Object.assign(v,m),v})}}async registerFilesInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=ME(t);return c=Z("files:register",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=LE(y),v=new HT;return Object.assign(v,m),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Sa(i){const t={},o=u(i,["data"]);if(o!=null&&f(t,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function PE(i){const t={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(c=>WE(c))),f(t,["parts"],r)}const s=u(i,["role"]);return s!=null&&f(t,["role"],s),t}function qE(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&f(t,["fileUri"],o);const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function HE(i){const t={},o=u(i,["id"]);o!=null&&f(t,["id"],o);const s=u(i,["args"]);s!=null&&f(t,["args"],s);const r=u(i,["name"]);if(r!=null&&f(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function kE(i){const t={},o=u(i,["description"]);o!=null&&f(t,["description"],o);const s=u(i,["name"]);s!=null&&f(t,["name"],s);const r=u(i,["parameters"]);r!=null&&f(t,["parameters"],r);const c=u(i,["parametersJsonSchema"]);c!=null&&f(t,["parametersJsonSchema"],c);const d=u(i,["response"]);d!=null&&f(t,["response"],d);const h=u(i,["responseJsonSchema"]);if(h!=null&&f(t,["responseJsonSchema"],h),u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");return t}function VE(i){const t={},o=u(i,["modelSelectionConfig"]);o!=null&&f(t,["modelConfig"],o);const s=u(i,["responseJsonSchema"]);s!=null&&f(t,["responseJsonSchema"],s);const r=u(i,["audioTimestamp"]);r!=null&&f(t,["audioTimestamp"],r);const c=u(i,["candidateCount"]);c!=null&&f(t,["candidateCount"],c);const d=u(i,["enableAffectiveDialog"]);d!=null&&f(t,["enableAffectiveDialog"],d);const h=u(i,["frequencyPenalty"]);h!=null&&f(t,["frequencyPenalty"],h);const y=u(i,["logprobs"]);y!=null&&f(t,["logprobs"],y);const m=u(i,["maxOutputTokens"]);m!=null&&f(t,["maxOutputTokens"],m);const v=u(i,["mediaResolution"]);v!=null&&f(t,["mediaResolution"],v);const E=u(i,["presencePenalty"]);E!=null&&f(t,["presencePenalty"],E);const _=u(i,["responseLogprobs"]);_!=null&&f(t,["responseLogprobs"],_);const x=u(i,["responseMimeType"]);x!=null&&f(t,["responseMimeType"],x);const w=u(i,["responseModalities"]);w!=null&&f(t,["responseModalities"],w);const I=u(i,["responseSchema"]);I!=null&&f(t,["responseSchema"],I);const M=u(i,["routingConfig"]);M!=null&&f(t,["routingConfig"],M);const V=u(i,["seed"]);V!=null&&f(t,["seed"],V);const $=u(i,["speechConfig"]);$!=null&&f(t,["speechConfig"],$);const O=u(i,["stopSequences"]);O!=null&&f(t,["stopSequences"],O);const J=u(i,["temperature"]);J!=null&&f(t,["temperature"],J);const ne=u(i,["thinkingConfig"]);ne!=null&&f(t,["thinkingConfig"],ne);const z=u(i,["topK"]);z!=null&&f(t,["topK"],z);const X=u(i,["topP"]);if(X!=null&&f(t,["topP"],X),u(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function zE(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&f(t,["enableWidget"],o),t}function BE(i){const t={},o=u(i,["searchTypes"]);if(o!=null&&f(t,["searchTypes"],o),u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const s=u(i,["timeRangeFilter"]);return s!=null&&f(t,["timeRangeFilter"],s),t}function OE(i,t){const o={},s=u(i,["generationConfig"]);t!==void 0&&s!=null&&f(t,["setup","generationConfig"],s);const r=u(i,["responseModalities"]);t!==void 0&&r!=null&&f(t,["setup","generationConfig","responseModalities"],r);const c=u(i,["temperature"]);t!==void 0&&c!=null&&f(t,["setup","generationConfig","temperature"],c);const d=u(i,["topP"]);t!==void 0&&d!=null&&f(t,["setup","generationConfig","topP"],d);const h=u(i,["topK"]);t!==void 0&&h!=null&&f(t,["setup","generationConfig","topK"],h);const y=u(i,["maxOutputTokens"]);t!==void 0&&y!=null&&f(t,["setup","generationConfig","maxOutputTokens"],y);const m=u(i,["mediaResolution"]);t!==void 0&&m!=null&&f(t,["setup","generationConfig","mediaResolution"],m);const v=u(i,["seed"]);t!==void 0&&v!=null&&f(t,["setup","generationConfig","seed"],v);const E=u(i,["speechConfig"]);t!==void 0&&E!=null&&f(t,["setup","generationConfig","speechConfig"],Ic(E));const _=u(i,["thinkingConfig"]);t!==void 0&&_!=null&&f(t,["setup","generationConfig","thinkingConfig"],_);const x=u(i,["enableAffectiveDialog"]);t!==void 0&&x!=null&&f(t,["setup","generationConfig","enableAffectiveDialog"],x);const w=u(i,["systemInstruction"]);t!==void 0&&w!=null&&f(t,["setup","systemInstruction"],PE(Ct(w)));const I=u(i,["tools"]);if(t!==void 0&&I!=null){let z=Vo(I);Array.isArray(z)&&(z=z.map(X=>e_(ko(X)))),f(t,["setup","tools"],z)}const M=u(i,["sessionResumption"]);t!==void 0&&M!=null&&f(t,["setup","sessionResumption"],jE(M));const V=u(i,["inputAudioTranscription"]);t!==void 0&&V!=null&&f(t,["setup","inputAudioTranscription"],V);const $=u(i,["outputAudioTranscription"]);t!==void 0&&$!=null&&f(t,["setup","outputAudioTranscription"],$);const O=u(i,["realtimeInputConfig"]);t!==void 0&&O!=null&&f(t,["setup","realtimeInputConfig"],O);const J=u(i,["contextWindowCompression"]);t!==void 0&&J!=null&&f(t,["setup","contextWindowCompression"],J);const ne=u(i,["proactivity"]);if(t!==void 0&&ne!=null&&f(t,["setup","proactivity"],ne),u(i,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return o}function FE(i,t){const o={},s=u(i,["generationConfig"]);t!==void 0&&s!=null&&f(t,["setup","generationConfig"],VE(s));const r=u(i,["responseModalities"]);t!==void 0&&r!=null&&f(t,["setup","generationConfig","responseModalities"],r);const c=u(i,["temperature"]);t!==void 0&&c!=null&&f(t,["setup","generationConfig","temperature"],c);const d=u(i,["topP"]);t!==void 0&&d!=null&&f(t,["setup","generationConfig","topP"],d);const h=u(i,["topK"]);t!==void 0&&h!=null&&f(t,["setup","generationConfig","topK"],h);const y=u(i,["maxOutputTokens"]);t!==void 0&&y!=null&&f(t,["setup","generationConfig","maxOutputTokens"],y);const m=u(i,["mediaResolution"]);t!==void 0&&m!=null&&f(t,["setup","generationConfig","mediaResolution"],m);const v=u(i,["seed"]);t!==void 0&&v!=null&&f(t,["setup","generationConfig","seed"],v);const E=u(i,["speechConfig"]);t!==void 0&&E!=null&&f(t,["setup","generationConfig","speechConfig"],Ic(E));const _=u(i,["thinkingConfig"]);t!==void 0&&_!=null&&f(t,["setup","generationConfig","thinkingConfig"],_);const x=u(i,["enableAffectiveDialog"]);t!==void 0&&x!=null&&f(t,["setup","generationConfig","enableAffectiveDialog"],x);const w=u(i,["systemInstruction"]);t!==void 0&&w!=null&&f(t,["setup","systemInstruction"],Ct(w));const I=u(i,["tools"]);if(t!==void 0&&I!=null){let X=Vo(I);Array.isArray(X)&&(X=X.map(ve=>t_(ko(ve)))),f(t,["setup","tools"],X)}const M=u(i,["sessionResumption"]);t!==void 0&&M!=null&&f(t,["setup","sessionResumption"],M);const V=u(i,["inputAudioTranscription"]);t!==void 0&&V!=null&&f(t,["setup","inputAudioTranscription"],V);const $=u(i,["outputAudioTranscription"]);t!==void 0&&$!=null&&f(t,["setup","outputAudioTranscription"],$);const O=u(i,["realtimeInputConfig"]);t!==void 0&&O!=null&&f(t,["setup","realtimeInputConfig"],O);const J=u(i,["contextWindowCompression"]);t!==void 0&&J!=null&&f(t,["setup","contextWindowCompression"],J);const ne=u(i,["proactivity"]);t!==void 0&&ne!=null&&f(t,["setup","proactivity"],ne);const z=u(i,["explicitVadSignal"]);return t!==void 0&&z!=null&&f(t,["setup","explicitVadSignal"],z),o}function JE(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["setup","model"],Oe(i,s));const r=u(t,["config"]);return r!=null&&f(o,["config"],OE(r,o)),o}function YE(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["setup","model"],Oe(i,s));const r=u(t,["config"]);return r!=null&&f(o,["config"],FE(r,o)),o}function KE(i){const t={},o=u(i,["musicGenerationConfig"]);return o!=null&&f(t,["musicGenerationConfig"],o),t}function XE(i){const t={},o=u(i,["weightedPrompts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),f(t,["weightedPrompts"],s)}return t}function $E(i){const t={},o=u(i,["media"]);if(o!=null){let m=xg(o);Array.isArray(m)&&(m=m.map(v=>Sa(v))),f(t,["mediaChunks"],m)}const s=u(i,["audio"]);s!=null&&f(t,["audio"],Sa(Ng(s)));const r=u(i,["audioStreamEnd"]);r!=null&&f(t,["audioStreamEnd"],r);const c=u(i,["video"]);c!=null&&f(t,["video"],Sa(Ag(c)));const d=u(i,["text"]);d!=null&&f(t,["text"],d);const h=u(i,["activityStart"]);h!=null&&f(t,["activityStart"],h);const y=u(i,["activityEnd"]);return y!=null&&f(t,["activityEnd"],y),t}function QE(i){const t={},o=u(i,["media"]);if(o!=null){let m=xg(o);Array.isArray(m)&&(m=m.map(v=>v)),f(t,["mediaChunks"],m)}const s=u(i,["audio"]);s!=null&&f(t,["audio"],Ng(s));const r=u(i,["audioStreamEnd"]);r!=null&&f(t,["audioStreamEnd"],r);const c=u(i,["video"]);c!=null&&f(t,["video"],Ag(c));const d=u(i,["text"]);d!=null&&f(t,["text"],d);const h=u(i,["activityStart"]);h!=null&&f(t,["activityStart"],h);const y=u(i,["activityEnd"]);return y!=null&&f(t,["activityEnd"],y),t}function ZE(i){const t={},o=u(i,["setupComplete"]);o!=null&&f(t,["setupComplete"],o);const s=u(i,["serverContent"]);s!=null&&f(t,["serverContent"],s);const r=u(i,["toolCall"]);r!=null&&f(t,["toolCall"],r);const c=u(i,["toolCallCancellation"]);c!=null&&f(t,["toolCallCancellation"],c);const d=u(i,["usageMetadata"]);d!=null&&f(t,["usageMetadata"],n_(d));const h=u(i,["goAway"]);h!=null&&f(t,["goAway"],h);const y=u(i,["sessionResumptionUpdate"]);y!=null&&f(t,["sessionResumptionUpdate"],y);const m=u(i,["voiceActivityDetectionSignal"]);m!=null&&f(t,["voiceActivityDetectionSignal"],m);const v=u(i,["voiceActivity"]);return v!=null&&f(t,["voiceActivity"],i_(v)),t}function WE(i){const t={},o=u(i,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const s=u(i,["codeExecutionResult"]);s!=null&&f(t,["codeExecutionResult"],s);const r=u(i,["executableCode"]);r!=null&&f(t,["executableCode"],r);const c=u(i,["fileData"]);c!=null&&f(t,["fileData"],qE(c));const d=u(i,["functionCall"]);d!=null&&f(t,["functionCall"],HE(d));const h=u(i,["functionResponse"]);h!=null&&f(t,["functionResponse"],h);const y=u(i,["inlineData"]);y!=null&&f(t,["inlineData"],Sa(y));const m=u(i,["text"]);m!=null&&f(t,["text"],m);const v=u(i,["thought"]);v!=null&&f(t,["thought"],v);const E=u(i,["thoughtSignature"]);E!=null&&f(t,["thoughtSignature"],E);const _=u(i,["videoMetadata"]);return _!=null&&f(t,["videoMetadata"],_),t}function jE(i){const t={},o=u(i,["handle"]);if(o!=null&&f(t,["handle"],o),u(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function e_(i){const t={};if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=u(i,["computerUse"]);o!=null&&f(t,["computerUse"],o);const s=u(i,["fileSearch"]);s!=null&&f(t,["fileSearch"],s);const r=u(i,["googleSearch"]);r!=null&&f(t,["googleSearch"],BE(r));const c=u(i,["codeExecution"]);if(c!=null&&f(t,["codeExecution"],c),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(i,["functionDeclarations"]);if(d!=null){let E=d;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["functionDeclarations"],E)}const h=u(i,["googleMaps"]);h!=null&&f(t,["googleMaps"],zE(h));const y=u(i,["googleSearchRetrieval"]);y!=null&&f(t,["googleSearchRetrieval"],y);const m=u(i,["urlContext"]);m!=null&&f(t,["urlContext"],m);const v=u(i,["mcpServers"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["mcpServers"],E)}return t}function t_(i){const t={},o=u(i,["retrieval"]);o!=null&&f(t,["retrieval"],o);const s=u(i,["computerUse"]);if(s!=null&&f(t,["computerUse"],s),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const r=u(i,["googleSearch"]);r!=null&&f(t,["googleSearch"],r);const c=u(i,["codeExecution"]);c!=null&&f(t,["codeExecution"],c);const d=u(i,["enterpriseWebSearch"]);d!=null&&f(t,["enterpriseWebSearch"],d);const h=u(i,["functionDeclarations"]);if(h!=null){let E=h;Array.isArray(E)&&(E=E.map(_=>kE(_))),f(t,["functionDeclarations"],E)}const y=u(i,["googleMaps"]);y!=null&&f(t,["googleMaps"],y);const m=u(i,["googleSearchRetrieval"]);m!=null&&f(t,["googleSearchRetrieval"],m);const v=u(i,["urlContext"]);if(v!=null&&f(t,["urlContext"],v),u(i,["mcpServers"])!==void 0)throw new Error("mcpServers parameter is not supported in Vertex AI.");return t}function n_(i){const t={},o=u(i,["promptTokenCount"]);o!=null&&f(t,["promptTokenCount"],o);const s=u(i,["cachedContentTokenCount"]);s!=null&&f(t,["cachedContentTokenCount"],s);const r=u(i,["candidatesTokenCount"]);r!=null&&f(t,["responseTokenCount"],r);const c=u(i,["toolUsePromptTokenCount"]);c!=null&&f(t,["toolUsePromptTokenCount"],c);const d=u(i,["thoughtsTokenCount"]);d!=null&&f(t,["thoughtsTokenCount"],d);const h=u(i,["totalTokenCount"]);h!=null&&f(t,["totalTokenCount"],h);const y=u(i,["promptTokensDetails"]);if(y!=null){let x=y;Array.isArray(x)&&(x=x.map(w=>w)),f(t,["promptTokensDetails"],x)}const m=u(i,["cacheTokensDetails"]);if(m!=null){let x=m;Array.isArray(x)&&(x=x.map(w=>w)),f(t,["cacheTokensDetails"],x)}const v=u(i,["candidatesTokensDetails"]);if(v!=null){let x=v;Array.isArray(x)&&(x=x.map(w=>w)),f(t,["responseTokensDetails"],x)}const E=u(i,["toolUsePromptTokensDetails"]);if(E!=null){let x=E;Array.isArray(x)&&(x=x.map(w=>w)),f(t,["toolUsePromptTokensDetails"],x)}const _=u(i,["trafficType"]);return _!=null&&f(t,["trafficType"],_),t}function i_(i){const t={},o=u(i,["type"]);return o!=null&&f(t,["voiceActivityType"],o),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function o_(i,t){const o={},s=u(i,["data"]);if(s!=null&&f(o,["data"],s),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=u(i,["mimeType"]);return r!=null&&f(o,["mimeType"],r),o}function l_(i,t){const o={},s=u(i,["content"]);s!=null&&f(o,["content"],s);const r=u(i,["citationMetadata"]);r!=null&&f(o,["citationMetadata"],s_(r));const c=u(i,["tokenCount"]);c!=null&&f(o,["tokenCount"],c);const d=u(i,["finishReason"]);d!=null&&f(o,["finishReason"],d);const h=u(i,["groundingMetadata"]);h!=null&&f(o,["groundingMetadata"],h);const y=u(i,["avgLogprobs"]);y!=null&&f(o,["avgLogprobs"],y);const m=u(i,["index"]);m!=null&&f(o,["index"],m);const v=u(i,["logprobsResult"]);v!=null&&f(o,["logprobsResult"],v);const E=u(i,["safetyRatings"]);if(E!=null){let x=E;Array.isArray(x)&&(x=x.map(w=>w)),f(o,["safetyRatings"],x)}const _=u(i,["urlContextMetadata"]);return _!=null&&f(o,["urlContextMetadata"],_),o}function s_(i,t){const o={},s=u(i,["citationSources"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(c=>c)),f(o,["citations"],r)}return o}function a_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["contents"]);if(c!=null){let d=en(c);Array.isArray(d)&&(d=d.map(h=>h)),f(s,["contents"],d)}return s}function r_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["tokensInfo"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(o,["tokensInfo"],c)}return o}function u_(i,t){const o={},s=u(i,["values"]);s!=null&&f(o,["values"],s);const r=u(i,["statistics"]);return r!=null&&f(o,["statistics"],c_(r)),o}function c_(i,t){const o={},s=u(i,["truncated"]);s!=null&&f(o,["truncated"],s);const r=u(i,["token_count"]);return r!=null&&f(o,["tokenCount"],r),o}function Ol(i,t){const o={},s=u(i,["parts"]);if(s!=null){let c=s;Array.isArray(c)&&(c=c.map(d=>TC(d))),f(o,["parts"],c)}const r=u(i,["role"]);return r!=null&&f(o,["role"],r),o}function f_(i,t){const o={},s=u(i,["controlType"]);s!=null&&f(o,["controlType"],s);const r=u(i,["enableControlImageComputation"]);return r!=null&&f(o,["computeControl"],r),o}function d_(i,t){const o={};if(u(i,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(u(i,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(u(i,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return o}function p_(i,t,o){const s={},r=u(i,["systemInstruction"]);t!==void 0&&r!=null&&f(t,["systemInstruction"],Ct(r));const c=u(i,["tools"]);if(t!==void 0&&c!=null){let h=c;Array.isArray(h)&&(h=h.map(y=>Vg(y))),f(t,["tools"],h)}const d=u(i,["generationConfig"]);return t!==void 0&&d!=null&&f(t,["generationConfig"],oC(d)),s}function h_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["contents"]);if(c!=null){let h=en(c);Array.isArray(h)&&(h=h.map(y=>Ol(y))),f(s,["contents"],h)}const d=u(t,["config"]);return d!=null&&d_(d),s}function m_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["contents"]);if(c!=null){let h=en(c);Array.isArray(h)&&(h=h.map(y=>y)),f(s,["contents"],h)}const d=u(t,["config"]);return d!=null&&p_(d,s),s}function g_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["totalTokens"]);r!=null&&f(o,["totalTokens"],r);const c=u(i,["cachedContentTokenCount"]);return c!=null&&f(o,["cachedContentTokenCount"],c),o}function y_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["totalTokens"]);return r!=null&&f(o,["totalTokens"],r),o}function v_(i,t,o){const s={},r=u(t,["model"]);return r!=null&&f(s,["_url","name"],Oe(i,r)),s}function T_(i,t,o){const s={},r=u(t,["model"]);return r!=null&&f(s,["_url","name"],Oe(i,r)),s}function S_(i,t){const o={},s=u(i,["sdkHttpResponse"]);return s!=null&&f(o,["sdkHttpResponse"],s),o}function E_(i,t){const o={},s=u(i,["sdkHttpResponse"]);return s!=null&&f(o,["sdkHttpResponse"],s),o}function __(i,t,o){const s={},r=u(i,["outputGcsUri"]);t!==void 0&&r!=null&&f(t,["parameters","storageUri"],r);const c=u(i,["negativePrompt"]);t!==void 0&&c!=null&&f(t,["parameters","negativePrompt"],c);const d=u(i,["numberOfImages"]);t!==void 0&&d!=null&&f(t,["parameters","sampleCount"],d);const h=u(i,["aspectRatio"]);t!==void 0&&h!=null&&f(t,["parameters","aspectRatio"],h);const y=u(i,["guidanceScale"]);t!==void 0&&y!=null&&f(t,["parameters","guidanceScale"],y);const m=u(i,["seed"]);t!==void 0&&m!=null&&f(t,["parameters","seed"],m);const v=u(i,["safetyFilterLevel"]);t!==void 0&&v!=null&&f(t,["parameters","safetySetting"],v);const E=u(i,["personGeneration"]);t!==void 0&&E!=null&&f(t,["parameters","personGeneration"],E);const _=u(i,["includeSafetyAttributes"]);t!==void 0&&_!=null&&f(t,["parameters","includeSafetyAttributes"],_);const x=u(i,["includeRaiReason"]);t!==void 0&&x!=null&&f(t,["parameters","includeRaiReason"],x);const w=u(i,["language"]);t!==void 0&&w!=null&&f(t,["parameters","language"],w);const I=u(i,["outputMimeType"]);t!==void 0&&I!=null&&f(t,["parameters","outputOptions","mimeType"],I);const M=u(i,["outputCompressionQuality"]);t!==void 0&&M!=null&&f(t,["parameters","outputOptions","compressionQuality"],M);const V=u(i,["addWatermark"]);t!==void 0&&V!=null&&f(t,["parameters","addWatermark"],V);const $=u(i,["labels"]);t!==void 0&&$!=null&&f(t,["labels"],$);const O=u(i,["editMode"]);t!==void 0&&O!=null&&f(t,["parameters","editMode"],O);const J=u(i,["baseSteps"]);return t!==void 0&&J!=null&&f(t,["parameters","editConfig","baseSteps"],J),s}function C_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["prompt"]);c!=null&&f(s,["instances[0]","prompt"],c);const d=u(t,["referenceImages"]);if(d!=null){let y=d;Array.isArray(y)&&(y=y.map(m=>AC(m))),f(s,["instances[0]","referenceImages"],y)}const h=u(t,["config"]);return h!=null&&__(h,s),s}function x_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["predictions"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>wa(d))),f(o,["generatedImages"],c)}return o}function A_(i,t,o){const s={},r=u(i,["taskType"]);t!==void 0&&r!=null&&f(t,["requests[]","taskType"],r);const c=u(i,["title"]);t!==void 0&&c!=null&&f(t,["requests[]","title"],c);const d=u(i,["outputDimensionality"]);if(t!==void 0&&d!=null&&f(t,["requests[]","outputDimensionality"],d),u(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return s}function N_(i,t,o){const s={};let r=u(o,["embeddingApiType"]);if(r===void 0&&(r="PREDICT"),r==="PREDICT"){const m=u(i,["taskType"]);t!==void 0&&m!=null&&f(t,["instances[]","task_type"],m)}else if(r==="EMBED_CONTENT"){const m=u(i,["taskType"]);t!==void 0&&m!=null&&f(t,["taskType"],m)}let c=u(o,["embeddingApiType"]);if(c===void 0&&(c="PREDICT"),c==="PREDICT"){const m=u(i,["title"]);t!==void 0&&m!=null&&f(t,["instances[]","title"],m)}else if(c==="EMBED_CONTENT"){const m=u(i,["title"]);t!==void 0&&m!=null&&f(t,["title"],m)}let d=u(o,["embeddingApiType"]);if(d===void 0&&(d="PREDICT"),d==="PREDICT"){const m=u(i,["outputDimensionality"]);t!==void 0&&m!=null&&f(t,["parameters","outputDimensionality"],m)}else if(d==="EMBED_CONTENT"){const m=u(i,["outputDimensionality"]);t!==void 0&&m!=null&&f(t,["outputDimensionality"],m)}let h=u(o,["embeddingApiType"]);if(h===void 0&&(h="PREDICT"),h==="PREDICT"){const m=u(i,["mimeType"]);t!==void 0&&m!=null&&f(t,["instances[]","mimeType"],m)}let y=u(o,["embeddingApiType"]);if(y===void 0&&(y="PREDICT"),y==="PREDICT"){const m=u(i,["autoTruncate"]);t!==void 0&&m!=null&&f(t,["parameters","autoTruncate"],m)}else if(y==="EMBED_CONTENT"){const m=u(i,["autoTruncate"]);t!==void 0&&m!=null&&f(t,["autoTruncate"],m)}return s}function b_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["contents"]);if(c!=null){let m=Rc(i,c);Array.isArray(m)&&(m=m.map(v=>v)),f(s,["requests[]","content"],m)}const d=u(t,["content"]);d!=null&&Ol(Ct(d));const h=u(t,["config"]);h!=null&&A_(h,s);const y=u(t,["model"]);return y!==void 0&&f(s,["requests[]","model"],Oe(i,y)),s}function R_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));let c=u(o,["embeddingApiType"]);if(c===void 0&&(c="PREDICT"),c==="PREDICT"){const y=u(t,["contents"]);if(y!=null){let m=Rc(i,y);Array.isArray(m)&&(m=m.map(v=>v)),f(s,["instances[]","content"],m)}}let d=u(o,["embeddingApiType"]);if(d===void 0&&(d="PREDICT"),d==="EMBED_CONTENT"){const y=u(t,["content"]);y!=null&&f(s,["content"],Ct(y))}const h=u(t,["config"]);return h!=null&&N_(h,s,o),s}function w_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["embeddings"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(h=>h)),f(o,["embeddings"],d)}const c=u(i,["metadata"]);return c!=null&&f(o,["metadata"],c),o}function M_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["predictions[]","embeddings"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(h=>u_(h))),f(o,["embeddings"],d)}const c=u(i,["metadata"]);if(c!=null&&f(o,["metadata"],c),t&&u(t,["embeddingApiType"])==="EMBED_CONTENT"){const d=u(i,["embedding"]),h=u(i,["usageMetadata"]),y=u(i,["truncated"]);if(d){const m={};h&&h.promptTokenCount&&(m.tokenCount=h.promptTokenCount),y&&(m.truncated=y),d.statistics=m,f(o,["embeddings"],[d])}}return o}function I_(i,t){const o={},s=u(i,["endpoint"]);s!=null&&f(o,["name"],s);const r=u(i,["deployedModelId"]);return r!=null&&f(o,["deployedModelId"],r),o}function D_(i,t){const o={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=u(i,["fileUri"]);s!=null&&f(o,["fileUri"],s);const r=u(i,["mimeType"]);return r!=null&&f(o,["mimeType"],r),o}function U_(i,t){const o={},s=u(i,["id"]);s!=null&&f(o,["id"],s);const r=u(i,["args"]);r!=null&&f(o,["args"],r);const c=u(i,["name"]);if(c!=null&&f(o,["name"],c),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return o}function L_(i,t){const o={},s=u(i,["allowedFunctionNames"]);s!=null&&f(o,["allowedFunctionNames"],s);const r=u(i,["mode"]);if(r!=null&&f(o,["mode"],r),u(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return o}function G_(i,t){const o={},s=u(i,["description"]);s!=null&&f(o,["description"],s);const r=u(i,["name"]);r!=null&&f(o,["name"],r);const c=u(i,["parameters"]);c!=null&&f(o,["parameters"],c);const d=u(i,["parametersJsonSchema"]);d!=null&&f(o,["parametersJsonSchema"],d);const h=u(i,["response"]);h!=null&&f(o,["response"],h);const y=u(i,["responseJsonSchema"]);if(y!=null&&f(o,["responseJsonSchema"],y),u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");return o}function P_(i,t,o,s){const r={},c=u(t,["systemInstruction"]);o!==void 0&&c!=null&&f(o,["systemInstruction"],Ol(Ct(c)));const d=u(t,["temperature"]);d!=null&&f(r,["temperature"],d);const h=u(t,["topP"]);h!=null&&f(r,["topP"],h);const y=u(t,["topK"]);y!=null&&f(r,["topK"],y);const m=u(t,["candidateCount"]);m!=null&&f(r,["candidateCount"],m);const v=u(t,["maxOutputTokens"]);v!=null&&f(r,["maxOutputTokens"],v);const E=u(t,["stopSequences"]);E!=null&&f(r,["stopSequences"],E);const _=u(t,["responseLogprobs"]);_!=null&&f(r,["responseLogprobs"],_);const x=u(t,["logprobs"]);x!=null&&f(r,["logprobs"],x);const w=u(t,["presencePenalty"]);w!=null&&f(r,["presencePenalty"],w);const I=u(t,["frequencyPenalty"]);I!=null&&f(r,["frequencyPenalty"],I);const M=u(t,["seed"]);M!=null&&f(r,["seed"],M);const V=u(t,["responseMimeType"]);V!=null&&f(r,["responseMimeType"],V);const $=u(t,["responseSchema"]);$!=null&&f(r,["responseSchema"],wc($));const O=u(t,["responseJsonSchema"]);if(O!=null&&f(r,["responseJsonSchema"],O),u(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const J=u(t,["safetySettings"]);if(o!==void 0&&J!=null){let qe=J;Array.isArray(qe)&&(qe=qe.map(Ye=>NC(Ye))),f(o,["safetySettings"],qe)}const ne=u(t,["tools"]);if(o!==void 0&&ne!=null){let qe=Vo(ne);Array.isArray(qe)&&(qe=qe.map(Ye=>UC(ko(Ye)))),f(o,["tools"],qe)}const z=u(t,["toolConfig"]);if(o!==void 0&&z!=null&&f(o,["toolConfig"],DC(z)),u(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const X=u(t,["cachedContent"]);o!==void 0&&X!=null&&f(o,["cachedContent"],Kn(i,X));const ve=u(t,["responseModalities"]);ve!=null&&f(r,["responseModalities"],ve);const W=u(t,["mediaResolution"]);W!=null&&f(r,["mediaResolution"],W);const Ee=u(t,["speechConfig"]);if(Ee!=null&&f(r,["speechConfig"],Mc(Ee)),u(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Ne=u(t,["thinkingConfig"]);Ne!=null&&f(r,["thinkingConfig"],Ne);const Ve=u(t,["imageConfig"]);Ve!=null&&f(r,["imageConfig"],uC(Ve));const je=u(t,["enableEnhancedCivicAnswers"]);if(je!=null&&f(r,["enableEnhancedCivicAnswers"],je),u(t,["modelArmorConfig"])!==void 0)throw new Error("modelArmorConfig parameter is not supported in Gemini API.");return r}function q_(i,t,o,s){const r={},c=u(t,["systemInstruction"]);o!==void 0&&c!=null&&f(o,["systemInstruction"],Ct(c));const d=u(t,["temperature"]);d!=null&&f(r,["temperature"],d);const h=u(t,["topP"]);h!=null&&f(r,["topP"],h);const y=u(t,["topK"]);y!=null&&f(r,["topK"],y);const m=u(t,["candidateCount"]);m!=null&&f(r,["candidateCount"],m);const v=u(t,["maxOutputTokens"]);v!=null&&f(r,["maxOutputTokens"],v);const E=u(t,["stopSequences"]);E!=null&&f(r,["stopSequences"],E);const _=u(t,["responseLogprobs"]);_!=null&&f(r,["responseLogprobs"],_);const x=u(t,["logprobs"]);x!=null&&f(r,["logprobs"],x);const w=u(t,["presencePenalty"]);w!=null&&f(r,["presencePenalty"],w);const I=u(t,["frequencyPenalty"]);I!=null&&f(r,["frequencyPenalty"],I);const M=u(t,["seed"]);M!=null&&f(r,["seed"],M);const V=u(t,["responseMimeType"]);V!=null&&f(r,["responseMimeType"],V);const $=u(t,["responseSchema"]);$!=null&&f(r,["responseSchema"],wc($));const O=u(t,["responseJsonSchema"]);O!=null&&f(r,["responseJsonSchema"],O);const J=u(t,["routingConfig"]);J!=null&&f(r,["routingConfig"],J);const ne=u(t,["modelSelectionConfig"]);ne!=null&&f(r,["modelConfig"],ne);const z=u(t,["safetySettings"]);if(o!==void 0&&z!=null){let le=z;Array.isArray(le)&&(le=le.map(Me=>Me)),f(o,["safetySettings"],le)}const X=u(t,["tools"]);if(o!==void 0&&X!=null){let le=Vo(X);Array.isArray(le)&&(le=le.map(Me=>Vg(ko(Me)))),f(o,["tools"],le)}const ve=u(t,["toolConfig"]);o!==void 0&&ve!=null&&f(o,["toolConfig"],ve);const W=u(t,["labels"]);o!==void 0&&W!=null&&f(o,["labels"],W);const Ee=u(t,["cachedContent"]);o!==void 0&&Ee!=null&&f(o,["cachedContent"],Kn(i,Ee));const Ne=u(t,["responseModalities"]);Ne!=null&&f(r,["responseModalities"],Ne);const Ve=u(t,["mediaResolution"]);Ve!=null&&f(r,["mediaResolution"],Ve);const je=u(t,["speechConfig"]);je!=null&&f(r,["speechConfig"],Mc(je));const qe=u(t,["audioTimestamp"]);qe!=null&&f(r,["audioTimestamp"],qe);const Ye=u(t,["thinkingConfig"]);Ye!=null&&f(r,["thinkingConfig"],Ye);const L=u(t,["imageConfig"]);if(L!=null&&f(r,["imageConfig"],cC(L)),u(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");const Y=u(t,["modelArmorConfig"]);return o!==void 0&&Y!=null&&f(o,["modelArmorConfig"],Y),r}function jm(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["contents"]);if(c!=null){let h=en(c);Array.isArray(h)&&(h=h.map(y=>Ol(y))),f(s,["contents"],h)}const d=u(t,["config"]);return d!=null&&f(s,["generationConfig"],P_(i,d,s)),s}function eg(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["contents"]);if(c!=null){let h=en(c);Array.isArray(h)&&(h=h.map(y=>y)),f(s,["contents"],h)}const d=u(t,["config"]);return d!=null&&f(s,["generationConfig"],q_(i,d,s)),s}function tg(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["candidates"]);if(r!=null){let m=r;Array.isArray(m)&&(m=m.map(v=>l_(v))),f(o,["candidates"],m)}const c=u(i,["modelVersion"]);c!=null&&f(o,["modelVersion"],c);const d=u(i,["promptFeedback"]);d!=null&&f(o,["promptFeedback"],d);const h=u(i,["responseId"]);h!=null&&f(o,["responseId"],h);const y=u(i,["usageMetadata"]);return y!=null&&f(o,["usageMetadata"],y),o}function ng(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["candidates"]);if(r!=null){let v=r;Array.isArray(v)&&(v=v.map(E=>E)),f(o,["candidates"],v)}const c=u(i,["createTime"]);c!=null&&f(o,["createTime"],c);const d=u(i,["modelVersion"]);d!=null&&f(o,["modelVersion"],d);const h=u(i,["promptFeedback"]);h!=null&&f(o,["promptFeedback"],h);const y=u(i,["responseId"]);y!=null&&f(o,["responseId"],y);const m=u(i,["usageMetadata"]);return m!=null&&f(o,["usageMetadata"],m),o}function H_(i,t,o){const s={};if(u(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(i,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const r=u(i,["numberOfImages"]);t!==void 0&&r!=null&&f(t,["parameters","sampleCount"],r);const c=u(i,["aspectRatio"]);t!==void 0&&c!=null&&f(t,["parameters","aspectRatio"],c);const d=u(i,["guidanceScale"]);if(t!==void 0&&d!=null&&f(t,["parameters","guidanceScale"],d),u(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const h=u(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&f(t,["parameters","safetySetting"],h);const y=u(i,["personGeneration"]);t!==void 0&&y!=null&&f(t,["parameters","personGeneration"],y);const m=u(i,["includeSafetyAttributes"]);t!==void 0&&m!=null&&f(t,["parameters","includeSafetyAttributes"],m);const v=u(i,["includeRaiReason"]);t!==void 0&&v!=null&&f(t,["parameters","includeRaiReason"],v);const E=u(i,["language"]);t!==void 0&&E!=null&&f(t,["parameters","language"],E);const _=u(i,["outputMimeType"]);t!==void 0&&_!=null&&f(t,["parameters","outputOptions","mimeType"],_);const x=u(i,["outputCompressionQuality"]);if(t!==void 0&&x!=null&&f(t,["parameters","outputOptions","compressionQuality"],x),u(i,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(u(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const w=u(i,["imageSize"]);if(t!==void 0&&w!=null&&f(t,["parameters","sampleImageSize"],w),u(i,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return s}function k_(i,t,o){const s={},r=u(i,["outputGcsUri"]);t!==void 0&&r!=null&&f(t,["parameters","storageUri"],r);const c=u(i,["negativePrompt"]);t!==void 0&&c!=null&&f(t,["parameters","negativePrompt"],c);const d=u(i,["numberOfImages"]);t!==void 0&&d!=null&&f(t,["parameters","sampleCount"],d);const h=u(i,["aspectRatio"]);t!==void 0&&h!=null&&f(t,["parameters","aspectRatio"],h);const y=u(i,["guidanceScale"]);t!==void 0&&y!=null&&f(t,["parameters","guidanceScale"],y);const m=u(i,["seed"]);t!==void 0&&m!=null&&f(t,["parameters","seed"],m);const v=u(i,["safetyFilterLevel"]);t!==void 0&&v!=null&&f(t,["parameters","safetySetting"],v);const E=u(i,["personGeneration"]);t!==void 0&&E!=null&&f(t,["parameters","personGeneration"],E);const _=u(i,["includeSafetyAttributes"]);t!==void 0&&_!=null&&f(t,["parameters","includeSafetyAttributes"],_);const x=u(i,["includeRaiReason"]);t!==void 0&&x!=null&&f(t,["parameters","includeRaiReason"],x);const w=u(i,["language"]);t!==void 0&&w!=null&&f(t,["parameters","language"],w);const I=u(i,["outputMimeType"]);t!==void 0&&I!=null&&f(t,["parameters","outputOptions","mimeType"],I);const M=u(i,["outputCompressionQuality"]);t!==void 0&&M!=null&&f(t,["parameters","outputOptions","compressionQuality"],M);const V=u(i,["addWatermark"]);t!==void 0&&V!=null&&f(t,["parameters","addWatermark"],V);const $=u(i,["labels"]);t!==void 0&&$!=null&&f(t,["labels"],$);const O=u(i,["imageSize"]);t!==void 0&&O!=null&&f(t,["parameters","sampleImageSize"],O);const J=u(i,["enhancePrompt"]);return t!==void 0&&J!=null&&f(t,["parameters","enhancePrompt"],J),s}function V_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["prompt"]);c!=null&&f(s,["instances[0]","prompt"],c);const d=u(t,["config"]);return d!=null&&H_(d,s),s}function z_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["prompt"]);c!=null&&f(s,["instances[0]","prompt"],c);const d=u(t,["config"]);return d!=null&&k_(d,s),s}function B_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["predictions"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(h=>eC(h))),f(o,["generatedImages"],d)}const c=u(i,["positivePromptSafetyAttributes"]);return c!=null&&f(o,["positivePromptSafetyAttributes"],Hg(c)),o}function O_(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["predictions"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(h=>wa(h))),f(o,["generatedImages"],d)}const c=u(i,["positivePromptSafetyAttributes"]);return c!=null&&f(o,["positivePromptSafetyAttributes"],kg(c)),o}function F_(i,t,o){const s={},r=u(i,["numberOfVideos"]);if(t!==void 0&&r!=null&&f(t,["parameters","sampleCount"],r),u(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(i,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const c=u(i,["durationSeconds"]);if(t!==void 0&&c!=null&&f(t,["parameters","durationSeconds"],c),u(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const d=u(i,["aspectRatio"]);t!==void 0&&d!=null&&f(t,["parameters","aspectRatio"],d);const h=u(i,["resolution"]);t!==void 0&&h!=null&&f(t,["parameters","resolution"],h);const y=u(i,["personGeneration"]);if(t!==void 0&&y!=null&&f(t,["parameters","personGeneration"],y),u(i,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const m=u(i,["negativePrompt"]);t!==void 0&&m!=null&&f(t,["parameters","negativePrompt"],m);const v=u(i,["enhancePrompt"]);if(t!==void 0&&v!=null&&f(t,["parameters","enhancePrompt"],v),u(i,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const E=u(i,["lastFrame"]);t!==void 0&&E!=null&&f(t,["instances[0]","lastFrame"],Ma(E));const _=u(i,["referenceImages"]);if(t!==void 0&&_!=null){let x=_;Array.isArray(x)&&(x=x.map(w=>YC(w))),f(t,["instances[0]","referenceImages"],x)}if(u(i,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(u(i,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return s}function J_(i,t,o){const s={},r=u(i,["numberOfVideos"]);t!==void 0&&r!=null&&f(t,["parameters","sampleCount"],r);const c=u(i,["outputGcsUri"]);t!==void 0&&c!=null&&f(t,["parameters","storageUri"],c);const d=u(i,["fps"]);t!==void 0&&d!=null&&f(t,["parameters","fps"],d);const h=u(i,["durationSeconds"]);t!==void 0&&h!=null&&f(t,["parameters","durationSeconds"],h);const y=u(i,["seed"]);t!==void 0&&y!=null&&f(t,["parameters","seed"],y);const m=u(i,["aspectRatio"]);t!==void 0&&m!=null&&f(t,["parameters","aspectRatio"],m);const v=u(i,["resolution"]);t!==void 0&&v!=null&&f(t,["parameters","resolution"],v);const E=u(i,["personGeneration"]);t!==void 0&&E!=null&&f(t,["parameters","personGeneration"],E);const _=u(i,["pubsubTopic"]);t!==void 0&&_!=null&&f(t,["parameters","pubsubTopic"],_);const x=u(i,["negativePrompt"]);t!==void 0&&x!=null&&f(t,["parameters","negativePrompt"],x);const w=u(i,["enhancePrompt"]);t!==void 0&&w!=null&&f(t,["parameters","enhancePrompt"],w);const I=u(i,["generateAudio"]);t!==void 0&&I!=null&&f(t,["parameters","generateAudio"],I);const M=u(i,["lastFrame"]);t!==void 0&&M!=null&&f(t,["instances[0]","lastFrame"],Tn(M));const V=u(i,["referenceImages"]);if(t!==void 0&&V!=null){let J=V;Array.isArray(J)&&(J=J.map(ne=>KC(ne))),f(t,["instances[0]","referenceImages"],J)}const $=u(i,["mask"]);t!==void 0&&$!=null&&f(t,["instances[0]","mask"],JC($));const O=u(i,["compressionQuality"]);return t!==void 0&&O!=null&&f(t,["parameters","compressionQuality"],O),s}function Y_(i,t){const o={},s=u(i,["name"]);s!=null&&f(o,["name"],s);const r=u(i,["metadata"]);r!=null&&f(o,["metadata"],r);const c=u(i,["done"]);c!=null&&f(o,["done"],c);const d=u(i,["error"]);d!=null&&f(o,["error"],d);const h=u(i,["response","generateVideoResponse"]);return h!=null&&f(o,["response"],Q_(h)),o}function K_(i,t){const o={},s=u(i,["name"]);s!=null&&f(o,["name"],s);const r=u(i,["metadata"]);r!=null&&f(o,["metadata"],r);const c=u(i,["done"]);c!=null&&f(o,["done"],c);const d=u(i,["error"]);d!=null&&f(o,["error"],d);const h=u(i,["response"]);return h!=null&&f(o,["response"],Z_(h)),o}function X_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["prompt"]);c!=null&&f(s,["instances[0]","prompt"],c);const d=u(t,["image"]);d!=null&&f(s,["instances[0]","image"],Ma(d));const h=u(t,["video"]);h!=null&&f(s,["instances[0]","video"],zg(h));const y=u(t,["source"]);y!=null&&W_(y,s);const m=u(t,["config"]);return m!=null&&F_(m,s),s}function $_(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["prompt"]);c!=null&&f(s,["instances[0]","prompt"],c);const d=u(t,["image"]);d!=null&&f(s,["instances[0]","image"],Tn(d));const h=u(t,["video"]);h!=null&&f(s,["instances[0]","video"],Bg(h));const y=u(t,["source"]);y!=null&&j_(y,s);const m=u(t,["config"]);return m!=null&&J_(m,s),s}function Q_(i,t){const o={},s=u(i,["generatedSamples"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(h=>nC(h))),f(o,["generatedVideos"],d)}const r=u(i,["raiMediaFilteredCount"]);r!=null&&f(o,["raiMediaFilteredCount"],r);const c=u(i,["raiMediaFilteredReasons"]);return c!=null&&f(o,["raiMediaFilteredReasons"],c),o}function Z_(i,t){const o={},s=u(i,["videos"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(h=>iC(h))),f(o,["generatedVideos"],d)}const r=u(i,["raiMediaFilteredCount"]);r!=null&&f(o,["raiMediaFilteredCount"],r);const c=u(i,["raiMediaFilteredReasons"]);return c!=null&&f(o,["raiMediaFilteredReasons"],c),o}function W_(i,t,o){const s={},r=u(i,["prompt"]);t!==void 0&&r!=null&&f(t,["instances[0]","prompt"],r);const c=u(i,["image"]);t!==void 0&&c!=null&&f(t,["instances[0]","image"],Ma(c));const d=u(i,["video"]);return t!==void 0&&d!=null&&f(t,["instances[0]","video"],zg(d)),s}function j_(i,t,o){const s={},r=u(i,["prompt"]);t!==void 0&&r!=null&&f(t,["instances[0]","prompt"],r);const c=u(i,["image"]);t!==void 0&&c!=null&&f(t,["instances[0]","image"],Tn(c));const d=u(i,["video"]);return t!==void 0&&d!=null&&f(t,["instances[0]","video"],Bg(d)),s}function eC(i,t){const o={},s=u(i,["_self"]);s!=null&&f(o,["image"],fC(s));const r=u(i,["raiFilteredReason"]);r!=null&&f(o,["raiFilteredReason"],r);const c=u(i,["_self"]);return c!=null&&f(o,["safetyAttributes"],Hg(c)),o}function wa(i,t){const o={},s=u(i,["_self"]);s!=null&&f(o,["image"],qg(s));const r=u(i,["raiFilteredReason"]);r!=null&&f(o,["raiFilteredReason"],r);const c=u(i,["_self"]);c!=null&&f(o,["safetyAttributes"],kg(c));const d=u(i,["prompt"]);return d!=null&&f(o,["enhancedPrompt"],d),o}function tC(i,t){const o={},s=u(i,["_self"]);s!=null&&f(o,["mask"],qg(s));const r=u(i,["labels"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(o,["labels"],c)}return o}function nC(i,t){const o={},s=u(i,["video"]);return s!=null&&f(o,["video"],OC(s)),o}function iC(i,t){const o={},s=u(i,["_self"]);return s!=null&&f(o,["video"],FC(s)),o}function oC(i,t){const o={},s=u(i,["modelSelectionConfig"]);s!=null&&f(o,["modelConfig"],s);const r=u(i,["responseJsonSchema"]);r!=null&&f(o,["responseJsonSchema"],r);const c=u(i,["audioTimestamp"]);c!=null&&f(o,["audioTimestamp"],c);const d=u(i,["candidateCount"]);d!=null&&f(o,["candidateCount"],d);const h=u(i,["enableAffectiveDialog"]);h!=null&&f(o,["enableAffectiveDialog"],h);const y=u(i,["frequencyPenalty"]);y!=null&&f(o,["frequencyPenalty"],y);const m=u(i,["logprobs"]);m!=null&&f(o,["logprobs"],m);const v=u(i,["maxOutputTokens"]);v!=null&&f(o,["maxOutputTokens"],v);const E=u(i,["mediaResolution"]);E!=null&&f(o,["mediaResolution"],E);const _=u(i,["presencePenalty"]);_!=null&&f(o,["presencePenalty"],_);const x=u(i,["responseLogprobs"]);x!=null&&f(o,["responseLogprobs"],x);const w=u(i,["responseMimeType"]);w!=null&&f(o,["responseMimeType"],w);const I=u(i,["responseModalities"]);I!=null&&f(o,["responseModalities"],I);const M=u(i,["responseSchema"]);M!=null&&f(o,["responseSchema"],M);const V=u(i,["routingConfig"]);V!=null&&f(o,["routingConfig"],V);const $=u(i,["seed"]);$!=null&&f(o,["seed"],$);const O=u(i,["speechConfig"]);O!=null&&f(o,["speechConfig"],O);const J=u(i,["stopSequences"]);J!=null&&f(o,["stopSequences"],J);const ne=u(i,["temperature"]);ne!=null&&f(o,["temperature"],ne);const z=u(i,["thinkingConfig"]);z!=null&&f(o,["thinkingConfig"],z);const X=u(i,["topK"]);X!=null&&f(o,["topK"],X);const ve=u(i,["topP"]);if(ve!=null&&f(o,["topP"],ve),u(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return o}function lC(i,t,o){const s={},r=u(t,["model"]);return r!=null&&f(s,["_url","name"],Oe(i,r)),s}function sC(i,t,o){const s={},r=u(t,["model"]);return r!=null&&f(s,["_url","name"],Oe(i,r)),s}function aC(i,t){const o={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const s=u(i,["enableWidget"]);return s!=null&&f(o,["enableWidget"],s),o}function rC(i,t){const o={},s=u(i,["searchTypes"]);if(s!=null&&f(o,["searchTypes"],s),u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const r=u(i,["timeRangeFilter"]);return r!=null&&f(o,["timeRangeFilter"],r),o}function uC(i,t){const o={},s=u(i,["aspectRatio"]);s!=null&&f(o,["aspectRatio"],s);const r=u(i,["imageSize"]);if(r!=null&&f(o,["imageSize"],r),u(i,["personGeneration"])!==void 0)throw new Error("personGeneration parameter is not supported in Gemini API.");if(u(i,["prominentPeople"])!==void 0)throw new Error("prominentPeople parameter is not supported in Gemini API.");if(u(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(u(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return o}function cC(i,t){const o={},s=u(i,["aspectRatio"]);s!=null&&f(o,["aspectRatio"],s);const r=u(i,["imageSize"]);r!=null&&f(o,["imageSize"],r);const c=u(i,["personGeneration"]);c!=null&&f(o,["personGeneration"],c);const d=u(i,["prominentPeople"]);d!=null&&f(o,["prominentPeople"],d);const h=u(i,["outputMimeType"]);h!=null&&f(o,["imageOutputOptions","mimeType"],h);const y=u(i,["outputCompressionQuality"]);return y!=null&&f(o,["imageOutputOptions","compressionQuality"],y),o}function fC(i,t){const o={},s=u(i,["bytesBase64Encoded"]);s!=null&&f(o,["imageBytes"],Si(s));const r=u(i,["mimeType"]);return r!=null&&f(o,["mimeType"],r),o}function qg(i,t){const o={},s=u(i,["gcsUri"]);s!=null&&f(o,["gcsUri"],s);const r=u(i,["bytesBase64Encoded"]);r!=null&&f(o,["imageBytes"],Si(r));const c=u(i,["mimeType"]);return c!=null&&f(o,["mimeType"],c),o}function Ma(i,t){const o={};if(u(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const s=u(i,["imageBytes"]);s!=null&&f(o,["bytesBase64Encoded"],Si(s));const r=u(i,["mimeType"]);return r!=null&&f(o,["mimeType"],r),o}function Tn(i,t){const o={},s=u(i,["gcsUri"]);s!=null&&f(o,["gcsUri"],s);const r=u(i,["imageBytes"]);r!=null&&f(o,["bytesBase64Encoded"],Si(r));const c=u(i,["mimeType"]);return c!=null&&f(o,["mimeType"],c),o}function dC(i,t,o,s){const r={},c=u(t,["pageSize"]);o!==void 0&&c!=null&&f(o,["_query","pageSize"],c);const d=u(t,["pageToken"]);o!==void 0&&d!=null&&f(o,["_query","pageToken"],d);const h=u(t,["filter"]);o!==void 0&&h!=null&&f(o,["_query","filter"],h);const y=u(t,["queryBase"]);return o!==void 0&&y!=null&&f(o,["_url","models_url"],Mg(i,y)),r}function pC(i,t,o,s){const r={},c=u(t,["pageSize"]);o!==void 0&&c!=null&&f(o,["_query","pageSize"],c);const d=u(t,["pageToken"]);o!==void 0&&d!=null&&f(o,["_query","pageToken"],d);const h=u(t,["filter"]);o!==void 0&&h!=null&&f(o,["_query","filter"],h);const y=u(t,["queryBase"]);return o!==void 0&&y!=null&&f(o,["_url","models_url"],Mg(i,y)),r}function hC(i,t,o){const s={},r=u(t,["config"]);return r!=null&&dC(i,r,s),s}function mC(i,t,o){const s={},r=u(t,["config"]);return r!=null&&pC(i,r,s),s}function gC(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["nextPageToken"]);r!=null&&f(o,["nextPageToken"],r);const c=u(i,["_self"]);if(c!=null){let d=Ig(c);Array.isArray(d)&&(d=d.map(h=>pc(h))),f(o,["models"],d)}return o}function yC(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["nextPageToken"]);r!=null&&f(o,["nextPageToken"],r);const c=u(i,["_self"]);if(c!=null){let d=Ig(c);Array.isArray(d)&&(d=d.map(h=>hc(h))),f(o,["models"],d)}return o}function vC(i,t){const o={},s=u(i,["maskMode"]);s!=null&&f(o,["maskMode"],s);const r=u(i,["segmentationClasses"]);r!=null&&f(o,["maskClasses"],r);const c=u(i,["maskDilation"]);return c!=null&&f(o,["dilation"],c),o}function pc(i,t){const o={},s=u(i,["name"]);s!=null&&f(o,["name"],s);const r=u(i,["displayName"]);r!=null&&f(o,["displayName"],r);const c=u(i,["description"]);c!=null&&f(o,["description"],c);const d=u(i,["version"]);d!=null&&f(o,["version"],d);const h=u(i,["_self"]);h!=null&&f(o,["tunedModelInfo"],LC(h));const y=u(i,["inputTokenLimit"]);y!=null&&f(o,["inputTokenLimit"],y);const m=u(i,["outputTokenLimit"]);m!=null&&f(o,["outputTokenLimit"],m);const v=u(i,["supportedGenerationMethods"]);v!=null&&f(o,["supportedActions"],v);const E=u(i,["temperature"]);E!=null&&f(o,["temperature"],E);const _=u(i,["maxTemperature"]);_!=null&&f(o,["maxTemperature"],_);const x=u(i,["topP"]);x!=null&&f(o,["topP"],x);const w=u(i,["topK"]);w!=null&&f(o,["topK"],w);const I=u(i,["thinking"]);return I!=null&&f(o,["thinking"],I),o}function hc(i,t){const o={},s=u(i,["name"]);s!=null&&f(o,["name"],s);const r=u(i,["displayName"]);r!=null&&f(o,["displayName"],r);const c=u(i,["description"]);c!=null&&f(o,["description"],c);const d=u(i,["versionId"]);d!=null&&f(o,["version"],d);const h=u(i,["deployedModels"]);if(h!=null){let _=h;Array.isArray(_)&&(_=_.map(x=>I_(x))),f(o,["endpoints"],_)}const y=u(i,["labels"]);y!=null&&f(o,["labels"],y);const m=u(i,["_self"]);m!=null&&f(o,["tunedModelInfo"],GC(m));const v=u(i,["defaultCheckpointId"]);v!=null&&f(o,["defaultCheckpointId"],v);const E=u(i,["checkpoints"]);if(E!=null){let _=E;Array.isArray(_)&&(_=_.map(x=>x)),f(o,["checkpoints"],_)}return o}function TC(i,t){const o={},s=u(i,["mediaResolution"]);s!=null&&f(o,["mediaResolution"],s);const r=u(i,["codeExecutionResult"]);r!=null&&f(o,["codeExecutionResult"],r);const c=u(i,["executableCode"]);c!=null&&f(o,["executableCode"],c);const d=u(i,["fileData"]);d!=null&&f(o,["fileData"],D_(d));const h=u(i,["functionCall"]);h!=null&&f(o,["functionCall"],U_(h));const y=u(i,["functionResponse"]);y!=null&&f(o,["functionResponse"],y);const m=u(i,["inlineData"]);m!=null&&f(o,["inlineData"],o_(m));const v=u(i,["text"]);v!=null&&f(o,["text"],v);const E=u(i,["thought"]);E!=null&&f(o,["thought"],E);const _=u(i,["thoughtSignature"]);_!=null&&f(o,["thoughtSignature"],_);const x=u(i,["videoMetadata"]);return x!=null&&f(o,["videoMetadata"],x),o}function SC(i,t){const o={},s=u(i,["productImage"]);return s!=null&&f(o,["image"],Tn(s)),o}function EC(i,t,o){const s={},r=u(i,["numberOfImages"]);t!==void 0&&r!=null&&f(t,["parameters","sampleCount"],r);const c=u(i,["baseSteps"]);t!==void 0&&c!=null&&f(t,["parameters","baseSteps"],c);const d=u(i,["outputGcsUri"]);t!==void 0&&d!=null&&f(t,["parameters","storageUri"],d);const h=u(i,["seed"]);t!==void 0&&h!=null&&f(t,["parameters","seed"],h);const y=u(i,["safetyFilterLevel"]);t!==void 0&&y!=null&&f(t,["parameters","safetySetting"],y);const m=u(i,["personGeneration"]);t!==void 0&&m!=null&&f(t,["parameters","personGeneration"],m);const v=u(i,["addWatermark"]);t!==void 0&&v!=null&&f(t,["parameters","addWatermark"],v);const E=u(i,["outputMimeType"]);t!==void 0&&E!=null&&f(t,["parameters","outputOptions","mimeType"],E);const _=u(i,["outputCompressionQuality"]);t!==void 0&&_!=null&&f(t,["parameters","outputOptions","compressionQuality"],_);const x=u(i,["enhancePrompt"]);t!==void 0&&x!=null&&f(t,["parameters","enhancePrompt"],x);const w=u(i,["labels"]);return t!==void 0&&w!=null&&f(t,["labels"],w),s}function _C(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["source"]);c!=null&&xC(c,s);const d=u(t,["config"]);return d!=null&&EC(d,s),s}function CC(i,t){const o={},s=u(i,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(c=>wa(c))),f(o,["generatedImages"],r)}return o}function xC(i,t,o){const s={},r=u(i,["prompt"]);t!==void 0&&r!=null&&f(t,["instances[0]","prompt"],r);const c=u(i,["personImage"]);t!==void 0&&c!=null&&f(t,["instances[0]","personImage","image"],Tn(c));const d=u(i,["productImages"]);if(t!==void 0&&d!=null){let h=d;Array.isArray(h)&&(h=h.map(y=>SC(y))),f(t,["instances[0]","productImages"],h)}return s}function AC(i,t){const o={},s=u(i,["referenceImage"]);s!=null&&f(o,["referenceImage"],Tn(s));const r=u(i,["referenceId"]);r!=null&&f(o,["referenceId"],r);const c=u(i,["referenceType"]);c!=null&&f(o,["referenceType"],c);const d=u(i,["maskImageConfig"]);d!=null&&f(o,["maskImageConfig"],vC(d));const h=u(i,["controlImageConfig"]);h!=null&&f(o,["controlImageConfig"],f_(h));const y=u(i,["styleImageConfig"]);y!=null&&f(o,["styleImageConfig"],y);const m=u(i,["subjectImageConfig"]);return m!=null&&f(o,["subjectImageConfig"],m),o}function Hg(i,t){const o={},s=u(i,["safetyAttributes","categories"]);s!=null&&f(o,["categories"],s);const r=u(i,["safetyAttributes","scores"]);r!=null&&f(o,["scores"],r);const c=u(i,["contentType"]);return c!=null&&f(o,["contentType"],c),o}function kg(i,t){const o={},s=u(i,["safetyAttributes","categories"]);s!=null&&f(o,["categories"],s);const r=u(i,["safetyAttributes","scores"]);r!=null&&f(o,["scores"],r);const c=u(i,["contentType"]);return c!=null&&f(o,["contentType"],c),o}function NC(i,t){const o={},s=u(i,["category"]);if(s!=null&&f(o,["category"],s),u(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=u(i,["threshold"]);return r!=null&&f(o,["threshold"],r),o}function bC(i,t){const o={},s=u(i,["image"]);return s!=null&&f(o,["image"],Tn(s)),o}function RC(i,t,o){const s={},r=u(i,["mode"]);t!==void 0&&r!=null&&f(t,["parameters","mode"],r);const c=u(i,["maxPredictions"]);t!==void 0&&c!=null&&f(t,["parameters","maxPredictions"],c);const d=u(i,["confidenceThreshold"]);t!==void 0&&d!=null&&f(t,["parameters","confidenceThreshold"],d);const h=u(i,["maskDilation"]);t!==void 0&&h!=null&&f(t,["parameters","maskDilation"],h);const y=u(i,["binaryColorThreshold"]);t!==void 0&&y!=null&&f(t,["parameters","binaryColorThreshold"],y);const m=u(i,["labels"]);return t!==void 0&&m!=null&&f(t,["labels"],m),s}function wC(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["source"]);c!=null&&IC(c,s);const d=u(t,["config"]);return d!=null&&RC(d,s),s}function MC(i,t){const o={},s=u(i,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(c=>tC(c))),f(o,["generatedMasks"],r)}return o}function IC(i,t,o){const s={},r=u(i,["prompt"]);t!==void 0&&r!=null&&f(t,["instances[0]","prompt"],r);const c=u(i,["image"]);t!==void 0&&c!=null&&f(t,["instances[0]","image"],Tn(c));const d=u(i,["scribbleImage"]);return t!==void 0&&d!=null&&f(t,["instances[0]","scribble"],bC(d)),s}function DC(i,t){const o={},s=u(i,["retrievalConfig"]);s!=null&&f(o,["retrievalConfig"],s);const r=u(i,["functionCallingConfig"]);return r!=null&&f(o,["functionCallingConfig"],L_(r)),o}function UC(i,t){const o={};if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(i,["computerUse"]);s!=null&&f(o,["computerUse"],s);const r=u(i,["fileSearch"]);r!=null&&f(o,["fileSearch"],r);const c=u(i,["googleSearch"]);c!=null&&f(o,["googleSearch"],rC(c));const d=u(i,["codeExecution"]);if(d!=null&&f(o,["codeExecution"],d),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const h=u(i,["functionDeclarations"]);if(h!=null){let _=h;Array.isArray(_)&&(_=_.map(x=>x)),f(o,["functionDeclarations"],_)}const y=u(i,["googleMaps"]);y!=null&&f(o,["googleMaps"],aC(y));const m=u(i,["googleSearchRetrieval"]);m!=null&&f(o,["googleSearchRetrieval"],m);const v=u(i,["urlContext"]);v!=null&&f(o,["urlContext"],v);const E=u(i,["mcpServers"]);if(E!=null){let _=E;Array.isArray(_)&&(_=_.map(x=>x)),f(o,["mcpServers"],_)}return o}function Vg(i,t){const o={},s=u(i,["retrieval"]);s!=null&&f(o,["retrieval"],s);const r=u(i,["computerUse"]);if(r!=null&&f(o,["computerUse"],r),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=u(i,["googleSearch"]);c!=null&&f(o,["googleSearch"],c);const d=u(i,["codeExecution"]);d!=null&&f(o,["codeExecution"],d);const h=u(i,["enterpriseWebSearch"]);h!=null&&f(o,["enterpriseWebSearch"],h);const y=u(i,["functionDeclarations"]);if(y!=null){let _=y;Array.isArray(_)&&(_=_.map(x=>G_(x))),f(o,["functionDeclarations"],_)}const m=u(i,["googleMaps"]);m!=null&&f(o,["googleMaps"],m);const v=u(i,["googleSearchRetrieval"]);v!=null&&f(o,["googleSearchRetrieval"],v);const E=u(i,["urlContext"]);if(E!=null&&f(o,["urlContext"],E),u(i,["mcpServers"])!==void 0)throw new Error("mcpServers parameter is not supported in Vertex AI.");return o}function LC(i,t){const o={},s=u(i,["baseModel"]);s!=null&&f(o,["baseModel"],s);const r=u(i,["createTime"]);r!=null&&f(o,["createTime"],r);const c=u(i,["updateTime"]);return c!=null&&f(o,["updateTime"],c),o}function GC(i,t){const o={},s=u(i,["labels","google-vertex-llm-tuning-base-model-id"]);s!=null&&f(o,["baseModel"],s);const r=u(i,["createTime"]);r!=null&&f(o,["createTime"],r);const c=u(i,["updateTime"]);return c!=null&&f(o,["updateTime"],c),o}function PC(i,t,o){const s={},r=u(i,["displayName"]);t!==void 0&&r!=null&&f(t,["displayName"],r);const c=u(i,["description"]);t!==void 0&&c!=null&&f(t,["description"],c);const d=u(i,["defaultCheckpointId"]);return t!==void 0&&d!=null&&f(t,["defaultCheckpointId"],d),s}function qC(i,t,o){const s={},r=u(i,["displayName"]);t!==void 0&&r!=null&&f(t,["displayName"],r);const c=u(i,["description"]);t!==void 0&&c!=null&&f(t,["description"],c);const d=u(i,["defaultCheckpointId"]);return t!==void 0&&d!=null&&f(t,["defaultCheckpointId"],d),s}function HC(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","name"],Oe(i,r));const c=u(t,["config"]);return c!=null&&PC(c,s),s}function kC(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["config"]);return c!=null&&qC(c,s),s}function VC(i,t,o){const s={},r=u(i,["outputGcsUri"]);t!==void 0&&r!=null&&f(t,["parameters","storageUri"],r);const c=u(i,["safetyFilterLevel"]);t!==void 0&&c!=null&&f(t,["parameters","safetySetting"],c);const d=u(i,["personGeneration"]);t!==void 0&&d!=null&&f(t,["parameters","personGeneration"],d);const h=u(i,["includeRaiReason"]);t!==void 0&&h!=null&&f(t,["parameters","includeRaiReason"],h);const y=u(i,["outputMimeType"]);t!==void 0&&y!=null&&f(t,["parameters","outputOptions","mimeType"],y);const m=u(i,["outputCompressionQuality"]);t!==void 0&&m!=null&&f(t,["parameters","outputOptions","compressionQuality"],m);const v=u(i,["enhanceInputImage"]);t!==void 0&&v!=null&&f(t,["parameters","upscaleConfig","enhanceInputImage"],v);const E=u(i,["imagePreservationFactor"]);t!==void 0&&E!=null&&f(t,["parameters","upscaleConfig","imagePreservationFactor"],E);const _=u(i,["labels"]);t!==void 0&&_!=null&&f(t,["labels"],_);const x=u(i,["numberOfImages"]);t!==void 0&&x!=null&&f(t,["parameters","sampleCount"],x);const w=u(i,["mode"]);return t!==void 0&&w!=null&&f(t,["parameters","mode"],w),s}function zC(i,t,o){const s={},r=u(t,["model"]);r!=null&&f(s,["_url","model"],Oe(i,r));const c=u(t,["image"]);c!=null&&f(s,["instances[0]","image"],Tn(c));const d=u(t,["upscaleFactor"]);d!=null&&f(s,["parameters","upscaleConfig","upscaleFactor"],d);const h=u(t,["config"]);return h!=null&&VC(h,s),s}function BC(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["predictions"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>wa(d))),f(o,["generatedImages"],c)}return o}function OC(i,t){const o={},s=u(i,["uri"]);s!=null&&f(o,["uri"],s);const r=u(i,["encodedVideo"]);r!=null&&f(o,["videoBytes"],Si(r));const c=u(i,["encoding"]);return c!=null&&f(o,["mimeType"],c),o}function FC(i,t){const o={},s=u(i,["gcsUri"]);s!=null&&f(o,["uri"],s);const r=u(i,["bytesBase64Encoded"]);r!=null&&f(o,["videoBytes"],Si(r));const c=u(i,["mimeType"]);return c!=null&&f(o,["mimeType"],c),o}function JC(i,t){const o={},s=u(i,["image"]);s!=null&&f(o,["_self"],Tn(s));const r=u(i,["maskMode"]);return r!=null&&f(o,["maskMode"],r),o}function YC(i,t){const o={},s=u(i,["image"]);s!=null&&f(o,["image"],Ma(s));const r=u(i,["referenceType"]);return r!=null&&f(o,["referenceType"],r),o}function KC(i,t){const o={},s=u(i,["image"]);s!=null&&f(o,["image"],Tn(s));const r=u(i,["referenceType"]);return r!=null&&f(o,["referenceType"],r),o}function zg(i,t){const o={},s=u(i,["uri"]);s!=null&&f(o,["uri"],s);const r=u(i,["videoBytes"]);r!=null&&f(o,["encodedVideo"],Si(r));const c=u(i,["mimeType"]);return c!=null&&f(o,["encoding"],c),o}function Bg(i,t){const o={},s=u(i,["uri"]);s!=null&&f(o,["gcsUri"],s);const r=u(i,["videoBytes"]);r!=null&&f(o,["bytesBase64Encoded"],Si(r));const c=u(i,["mimeType"]);return c!=null&&f(o,["mimeType"],c),o}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function XC(i,t){const o={},s=u(i,["displayName"]);return t!==void 0&&s!=null&&f(t,["displayName"],s),o}function $C(i){const t={},o=u(i,["config"]);return o!=null&&XC(o,t),t}function QC(i,t){const o={},s=u(i,["force"]);return t!==void 0&&s!=null&&f(t,["_query","force"],s),o}function ZC(i){const t={},o=u(i,["name"]);o!=null&&f(t,["_url","name"],o);const s=u(i,["config"]);return s!=null&&QC(s,t),t}function WC(i){const t={},o=u(i,["name"]);return o!=null&&f(t,["_url","name"],o),t}function jC(i,t){const o={},s=u(i,["customMetadata"]);if(t!==void 0&&s!=null){let c=s;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["customMetadata"],c)}const r=u(i,["chunkingConfig"]);return t!==void 0&&r!=null&&f(t,["chunkingConfig"],r),o}function ex(i){const t={},o=u(i,["name"]);o!=null&&f(t,["name"],o);const s=u(i,["metadata"]);s!=null&&f(t,["metadata"],s);const r=u(i,["done"]);r!=null&&f(t,["done"],r);const c=u(i,["error"]);c!=null&&f(t,["error"],c);const d=u(i,["response"]);return d!=null&&f(t,["response"],nx(d)),t}function tx(i){const t={},o=u(i,["fileSearchStoreName"]);o!=null&&f(t,["_url","file_search_store_name"],o);const s=u(i,["fileName"]);s!=null&&f(t,["fileName"],s);const r=u(i,["config"]);return r!=null&&jC(r,t),t}function nx(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["parent"]);s!=null&&f(t,["parent"],s);const r=u(i,["documentName"]);return r!=null&&f(t,["documentName"],r),t}function ix(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&f(t,["_query","pageToken"],r),o}function ox(i){const t={},o=u(i,["config"]);return o!=null&&ix(o,t),t}function lx(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["fileSearchStores"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["fileSearchStores"],c)}return t}function Og(i,t){const o={},s=u(i,["mimeType"]);t!==void 0&&s!=null&&f(t,["mimeType"],s);const r=u(i,["displayName"]);t!==void 0&&r!=null&&f(t,["displayName"],r);const c=u(i,["customMetadata"]);if(t!==void 0&&c!=null){let h=c;Array.isArray(h)&&(h=h.map(y=>y)),f(t,["customMetadata"],h)}const d=u(i,["chunkingConfig"]);return t!==void 0&&d!=null&&f(t,["chunkingConfig"],d),o}function sx(i){const t={},o=u(i,["fileSearchStoreName"]);o!=null&&f(t,["_url","file_search_store_name"],o);const s=u(i,["config"]);return s!=null&&Og(s,t),t}function ax(i){const t={},o=u(i,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const rx="Content-Type",ux="X-Server-Timeout",cx="User-Agent",mc="x-goog-api-client",fx="1.43.0",dx=`google-genai-sdk/${fx}`,px="v1beta1",hx="v1beta",mx=5,gx=[408,429,500,502,503,504];class yx{constructor(t){var o,s,r;this.clientOptions=Object.assign({},t),this.customBaseUrl=(o=t.httpOptions)===null||o===void 0?void 0:o.baseUrl,this.clientOptions.vertexai&&(this.clientOptions.project&&this.clientOptions.location?this.clientOptions.apiKey=void 0:this.clientOptions.apiKey&&(this.clientOptions.project=void 0,this.clientOptions.location=void 0));const c={};if(this.clientOptions.vertexai){if(!this.clientOptions.location&&!this.clientOptions.apiKey&&!this.customBaseUrl&&(this.clientOptions.location="global"),!(this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey)&&!this.customBaseUrl)throw new Error("Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.");const h=t.project&&t.location||!!t.apiKey;this.customBaseUrl&&!h?(c.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey||this.clientOptions.location==="global"?c.baseUrl="https://aiplatform.googleapis.com/":this.clientOptions.project&&this.clientOptions.location&&(c.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),c.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:px}else{if(!this.clientOptions.apiKey)throw new Bl({message:"API key must be set when using the Gemini API.",status:403});c.apiVersion=(r=this.clientOptions.apiVersion)!==null&&r!==void 0?r:hx,c.baseUrl="https://generativelanguage.googleapis.com/"}c.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=c,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(c,t.httpOptions))}isVertexAI(){var t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){const t=new Headers;return await this.clientOptions.auth.addAuthHeaders(t),t}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(t){if(!t||t.baseUrl===void 0||t.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const s=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&s.push(t.apiVersion),s.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),o=new URL(t);return o.protocol=o.protocol=="http:"?"ws":"wss",o.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,o,s){const r=[this.getRequestUrlInternal(o)];return s&&r.push(this.getBaseResourcePath()),t!==""&&r.push(t),new URL(`${r.join("/")}`)}shouldPrependVertexProjectPath(t,o){return!(o.baseUrl&&o.baseUrlResourceScope===uc.COLLECTION||this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let o=this.clientOptions.httpOptions;t.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const s=this.shouldPrependVertexProjectPath(t,o),r=this.constructUrl(t.path,o,s);if(t.queryParams)for(const[d,h]of Object.entries(t.queryParams))r.searchParams.append(d,String(h));let c={};if(t.httpMethod==="GET"){if(t.body&&t.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else c.body=t.body;return c=await this.includeExtraHttpOptionsToRequestInit(c,o,r.toString(),t.abortSignal),this.unaryApiCall(r,c,t.httpMethod)}patchHttpOptions(t,o){const s=JSON.parse(JSON.stringify(t));for(const[r,c]of Object.entries(o))typeof c=="object"?s[r]=Object.assign(Object.assign({},s[r]),c):c!==void 0&&(s[r]=c);return s}async requestStream(t){let o=this.clientOptions.httpOptions;t.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const s=this.shouldPrependVertexProjectPath(t,o),r=this.constructUrl(t.path,o,s);(!r.searchParams.has("alt")||r.searchParams.get("alt")!=="sse")&&r.searchParams.set("alt","sse");let c={};return c.body=t.body,c=await this.includeExtraHttpOptionsToRequestInit(c,o,r.toString(),t.abortSignal),this.streamApiCall(r,c,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,o,s,r){if(o&&o.timeout||r){const c=new AbortController,d=c.signal;if(o.timeout&&(o==null?void 0:o.timeout)>0){const h=setTimeout(()=>c.abort(),o.timeout);h&&typeof h.unref=="function"&&h.unref()}r&&r.addEventListener("abort",()=>{c.abort()}),t.signal=d}return o&&o.extraBody!==null&&vx(t,o.extraBody),t.headers=await this.getHeadersInternal(o,s),t}async unaryApiCall(t,o,s){return this.apiCall(t.toString(),Object.assign(Object.assign({},o),{method:s})).then(async r=>(await ig(r),new cc(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}async streamApiCall(t,o,s){return this.apiCall(t.toString(),Object.assign(Object.assign({},o),{method:s})).then(async r=>(await ig(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(t){return yn(this,arguments,function*(){var s;const r=(s=t==null?void 0:t.body)===null||s===void 0?void 0:s.getReader(),c=new TextDecoder("utf-8");if(!r)throw new Error("Response body is empty");try{let d="";const h="data:",y=[` `,"\r\r",`\r \r `];for(;;){const{done:m,value:v}=yield ye(r.read());if(m){if(d.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const E=c.decode(v,{stream:!0});try{const w=JSON.parse(E);if("error"in w){const I=JSON.parse(JSON.stringify(w.error)),M=I.status,V=I.code,$=`got status: ${M}. ${JSON.stringify(w)}`;if(V>=400&&V<600)throw new Bl({message:$,status:V})}}catch(w){if(w.name==="ApiError")throw w}d+=E;let _=-1,x=0;for(;;){_=-1,x=0;for(const M of y){const V=d.indexOf(M);V!==-1&&(_===-1||V<_)&&(_=V,x=M.length)}if(_===-1)break;const w=d.substring(0,_);d=d.substring(_+x);const I=w.trim();if(I.startsWith(h)){const M=I.substring(h.length).trim();try{const V=new Response(M,{headers:t==null?void 0:t.headers,status:t==null?void 0:t.status,statusText:t==null?void 0:t.statusText});yield yield ye(new cc(V))}catch(V){throw new Error(`exception parsing stream chunk ${M}. ${V}`)}}}}}finally{r.releaseLock()}})}async apiCall(t,o){var s;if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions)return fetch(t,o);const r=this.clientOptions.httpOptions.retryOptions;return sT(async()=>{const d=await fetch(t,o);if(d.ok)return d;throw gx.includes(d.status)?new Error(`Retryable HTTP Error: ${d.statusText}`):new Eg.AbortError(`Non-retryable exception ${d.statusText} sending request`)},{retries:((s=r.attempts)!==null&&s!==void 0?s:mx)-1})}getDefaultHeaders(){const t={},o=dx+" "+this.clientOptions.userAgentExtra;return t[cx]=o,t[mc]=o,t[rx]="application/json",t}async getHeadersInternal(t,o){const s=new Headers;if(t&&t.headers){for(const[r,c]of Object.entries(t.headers))s.append(r,c);t.timeout&&t.timeout>0&&s.append(ux,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(s,o),s}getFileName(t){var o;let s="";return typeof t=="string"&&(s=t.replace(/[/\\]+$/,""),s=(o=s.split(/[/\\]/).pop())!==null&&o!==void 0?o:""),s}async uploadFile(t,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 c=this.clientOptions.uploader,d=await c.stat(t);r.sizeBytes=String(d.size);const h=(s=o==null?void 0:o.mimeType)!==null&&s!==void 0?s:d.type;if(h===void 0||h==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");r.mimeType=h;const y={file:r},m=this.getFileName(t),v=Z("upload/v1beta/files",y._url),E=await this.fetchUploadUrl(v,r.sizeBytes,r.mimeType,m,y,o==null?void 0:o.httpOptions);return c.upload(t,E,this)}async uploadFileToFileSearchStore(t,o,s){var r;const c=this.clientOptions.uploader,d=await c.stat(o),h=String(d.size),y=(r=s==null?void 0:s.mimeType)!==null&&r!==void 0?r:d.type;if(y===void 0||y==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const m=`upload/v1beta/${t}:uploadToFileSearchStore`,v=this.getFileName(o),E={};s!=null&&Og(s,E);const _=await this.fetchUploadUrl(m,h,y,v,E,s==null?void 0:s.httpOptions);return c.uploadToFileSearchStore(o,_,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,o,s,r,c,d){var h;let y={};d?y=d:y={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${o}`,"X-Goog-Upload-Header-Content-Type":`${s}`},r?{"X-Goog-Upload-File-Name":r}:{})};const m=await this.request({path:t,body:JSON.stringify(c),httpMethod:"POST",httpOptions:y});if(!m||!(m!=null&&m.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const v=(h=m==null?void 0:m.headers)===null||h===void 0?void 0:h["x-goog-upload-url"];if(v===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return v}}async function ig(i){var t;if(i===void 0)throw new Error("response is undefined");if(!i.ok){const o=i.status;let s;!((t=i.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?s=await i.json():s={error:{message:await i.text(),code:i.status,status:i.statusText}};const r=JSON.stringify(s);throw o>=400&&o<600?new Bl({message:r,status:o}):new Error(r)}}function vx(i,t){if(!t||Object.keys(t).length===0)return;if(i.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 i.body=="string"&&i.body.length>0)try{const c=JSON.parse(i.body);if(typeof c=="object"&&c!==null&&!Array.isArray(c))o=c;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(c,d){const h=Object.assign({},c);for(const y in d)if(Object.prototype.hasOwnProperty.call(d,y)){const m=d[y],v=h[y];m&&typeof m=="object"&&!Array.isArray(m)&&v&&typeof v=="object"&&!Array.isArray(v)?h[y]=s(v,m):(v&&m&&typeof v!=typeof m&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${y}". Original type: ${typeof v}, New type: ${typeof m}. Overwriting.`),h[y]=m)}return h}const r=s(o,t);i.body=JSON.stringify(r)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Tx="mcp_used/unknown";let Sx=!1;function Fg(i){for(const t of i)if(Ex(t)||typeof t=="object"&&"inputSchema"in t)return!0;return Sx}function Jg(i){var t;const o=(t=i[mc])!==null&&t!==void 0?t:"";i[mc]=(o+` ${Tx}`).trimStart()}function Ex(i){return i!==null&&typeof i=="object"&&i instanceof Dc}function _x(i){return yn(this,arguments,function*(o,s=100){let r,c=0;for(;c0)return;const c={},d=[];for(const v of this.mcpClients)try{for(var h=!0,y=(o=void 0,vn(_x(v))),m;m=await y.next(),t=m.done,!t;h=!0){r=m.value,h=!1;const E=r;d.push(E);const _=E.name;if(c[_])throw new Error(`Duplicate function name ${_} found in MCP tools. Please ensure function names are unique.`);c[_]=v}}catch(E){o={error:E}}finally{try{!h&&!t&&(s=y.return)&&await s.call(y)}finally{if(o)throw o.error}}this.mcpTools=d,this.functionNameToMcpClient=c}async tool(){return await this.initialize(),XT(this.mcpTools,this.config)}async callTool(t){await this.initialize();const o=[];for(const s of t)if(s.name in this.functionNameToMcpClient){const r=this.functionNameToMcpClient[s.name];let c;this.config.timeout&&(c={timeout:this.config.timeout});const d=await r.callTool({name:s.name,arguments:s.args},void 0,c);o.push({functionResponse:{name:s.name,response:d.isError?{error:d}:d}})}return o}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function Cx(i,t,o){const s=new VT;let r;o.data instanceof Blob?r=JSON.parse(await o.data.text()):r=JSON.parse(o.data),Object.assign(s,r),t(s)}class xx{constructor(t,o,s){this.apiClient=t,this.auth=o,this.webSocketFactory=s}async connect(t){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(),c=this.apiClient.getApiVersion(),d=bx(this.apiClient.getDefaultHeaders()),h=this.apiClient.getApiKey(),y=`${r}/ws/google.ai.generativelanguage.${c}.GenerativeService.BidiGenerateMusic?key=${h}`;let m=()=>{};const v=new Promise(O=>{m=O}),E=t.callbacks,_=function(){m({})},x=this.apiClient,w={onopen:_,onmessage:O=>{Cx(x,E.onmessage,O)},onerror:(o=E==null?void 0:E.onerror)!==null&&o!==void 0?o:function(O){},onclose:(s=E==null?void 0:E.onclose)!==null&&s!==void 0?s:function(O){}},I=this.webSocketFactory.create(y,Nx(d),w);I.connect(),await v;const $={setup:{model:Oe(this.apiClient,t.model)}};return I.send(JSON.stringify($)),new Ax(I,this.apiClient)}}class Ax{constructor(t,o){this.conn=t,this.apiClient=o}async setWeightedPrompts(t){if(!t.weightedPrompts||Object.keys(t.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const o=XE(t);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const o=KE(t);this.conn.send(JSON.stringify(o))}sendPlaybackControl(t){const o={playbackControl:t};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(Lo.PLAY)}pause(){this.sendPlaybackControl(Lo.PAUSE)}stop(){this.sendPlaybackControl(Lo.STOP)}resetContext(){this.sendPlaybackControl(Lo.RESET_CONTEXT)}close(){this.conn.close()}}function Nx(i){const t={};return i.forEach((o,s)=>{t[s]=o}),t}function bx(i){const t=new Headers;for(const[o,s]of Object.entries(i))t.append(o,s);return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Rx="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function wx(i,t,o){const s=new kT;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 c=JSON.parse(r);if(i.isVertexAI()){const d=ZE(c);Object.assign(s,d)}else Object.assign(s,c);t(s)}class Mx{constructor(t,o,s){this.apiClient=t,this.auth=o,this.webSocketFactory=s,this.music=new xx(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var o,s,r,c,d,h;if(t.config&&t.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(),m=this.apiClient.getApiVersion();let v;const E=this.apiClient.getHeaders();t.config&&t.config.tools&&Fg(t.config.tools)&&Jg(E);const _=Lx(E);if(this.apiClient.isVertexAI()){const W=this.apiClient.getProject(),Ee=this.apiClient.getLocation(),Ne=this.apiClient.getApiKey(),Ve=!!W&&!!Ee||!!Ne;this.apiClient.getCustomBaseUrl()&&!Ve?v=y:(v=`${y}/ws/google.cloud.aiplatform.${m}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(_,v))}else{const W=this.apiClient.getApiKey();let Ee="BidiGenerateContent",Ne="key";W!=null&&W.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),m!=="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."),Ee="BidiGenerateContentConstrained",Ne="access_token"),v=`${y}/ws/google.ai.generativelanguage.${m}.GenerativeService.${Ee}?${Ne}=${W}`}let x=()=>{};const w=new Promise(W=>{x=W}),I=t.callbacks,M=function(){var W;(W=I==null?void 0:I.onopen)===null||W===void 0||W.call(I),x({})},V=this.apiClient,$={onopen:M,onmessage:W=>{wx(V,I.onmessage,W)},onerror:(o=I==null?void 0:I.onerror)!==null&&o!==void 0?o:function(W){},onclose:(s=I==null?void 0:I.onclose)!==null&&s!==void 0?s:function(W){}},O=this.webSocketFactory.create(v,Ux(_),$);O.connect(),await w;let J=Oe(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&J.startsWith("publishers/")){const W=this.apiClient.getProject(),Ee=this.apiClient.getLocation();W&&Ee&&(J=`projects/${W}/locations/${Ee}/`+J)}let ne={};this.apiClient.isVertexAI()&&((r=t.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[_a.AUDIO]}:t.config.responseModalities=[_a.AUDIO]),!((c=t.config)===null||c===void 0)&&c.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 z=(h=(d=t.config)===null||d===void 0?void 0:d.tools)!==null&&h!==void 0?h:[],X=[];for(const W of z)if(this.isCallableTool(W)){const Ee=W;X.push(await Ee.tool())}else X.push(W);X.length>0&&(t.config.tools=X);const ve={model:J,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?ne=YE(this.apiClient,ve):ne=JE(this.apiClient,ve),delete ne.config,O.send(JSON.stringify(ne)),new Dx(O,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const Ix={turnComplete:!0};class Dx{constructor(t,o){this.conn=t,this.apiClient=o}tLiveClientContent(t,o){if(o.turns!==null&&o.turns!==void 0){let s=[];try{s=en(o.turns),t.isVertexAI()||(s=s.map(r=>Ol(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(t,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 c of s){if(typeof c!="object"||c===null||!("name"in c)||!("response"in c))throw new Error(`Could not parse function response, type '${typeof c}'.`);if(!t.isVertexAI()&&!("id"in c))throw new Error(Rx)}return{toolResponse:{functionResponses:s}}}sendClientContent(t){t=Object.assign(Object.assign({},Ix),t);const o=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(o))}sendRealtimeInput(t){let o={};this.apiClient.isVertexAI()?o={realtimeInput:QE(t)}:o={realtimeInput:$E(t)},this.conn.send(JSON.stringify(o))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const o=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(o))}close(){this.conn.close()}}function Ux(i){const t={};return i.forEach((o,s)=>{t[s]=o}),t}function Lx(i){const t=new Headers;for(const[o,s]of Object.entries(i))t.append(o,s);return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const og=10;function lg(i){var t,o,s;if(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let r=!1;for(const d of(o=i==null?void 0:i.tools)!==null&&o!==void 0?o:[])if(qo(d)){r=!0;break}if(!r)return!0;const c=(s=i==null?void 0:i.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls;return c&&(c<0||!Number.isInteger(c))||c==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:",c),!0):!1}function qo(i){return"callTool"in i&&typeof i.callTool=="function"}function Gx(i){var t,o,s;return(s=(o=(t=i.config)===null||t===void 0?void 0:t.tools)===null||o===void 0?void 0:o.some(r=>qo(r)))!==null&&s!==void 0?s:!1}function sg(i){var t;const o=[];return!((t=i==null?void 0:i.config)===null||t===void 0)&&t.tools&&i.config.tools.forEach((s,r)=>{if(qo(s))return;const c=s;c.functionDeclarations&&c.functionDeclarations.length>0&&o.push(r)}),o}function ag(i){var t;return!(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Px extends Yn{constructor(t){super(),this.apiClient=t,this.embedContent=async o=>{if(!this.apiClient.isVertexAI())return await this.embedContentInternal(o);if(o.model.includes("gemini")&&o.model!=="gemini-embedding-001"||o.model.includes("maas")){const r=en(o.contents);if(r.length>1)throw new Error("The embedContent API for this model only supports one content at a time.");const c=Object.assign(Object.assign({},o),{content:r[0],embeddingApiType:Ca.EMBED_CONTENT});return await this.embedContentInternal(c)}else{const r=Object.assign(Object.assign({},o),{embeddingApiType:Ca.PREDICT});return await this.embedContentInternal(r)}},this.generateContent=async o=>{var s,r,c,d,h;const y=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!Gx(o)||lg(o.config))return await this.generateContentInternal(y);const m=sg(o);if(m.length>0){const I=m.map(M=>`tools[${M}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${I}.`)}let v,E;const _=en(y.contents),x=(c=(r=(s=y.config)===null||s===void 0?void 0:s.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&c!==void 0?c:og;let w=0;for(;w{var s,r,c,d,h;if(this.maybeMoveToResponseJsonSchem(o),lg(o.config)){const E=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(E)}const y=sg(o);if(y.length>0){const E=y.map(_=>`tools[${_}]`).join(", ");throw new Error(`Incompatible tools found at ${E}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const m=(c=(r=(s=o==null?void 0:o.config)===null||s===void 0?void 0:s.toolConfig)===null||r===void 0?void 0:r.functionCallingConfig)===null||c===void 0?void 0:c.streamFunctionCallArguments,v=(h=(d=o==null?void 0:o.config)===null||d===void 0?void 0:d.automaticFunctionCalling)===null||h===void 0?void 0:h.disable;if(m&&!v)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(o)},this.generateImages=async o=>await this.generateImagesInternal(o).then(s=>{var r;let c;const d=[];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"?c=y==null?void 0:y.safetyAttributes:d.push(y);let h;return c?h={generatedImages:d,positivePromptSafetyAttributes:c,sdkHttpResponse:s.sdkHttpResponse}:h={generatedImages:d,sdkHttpResponse:s.sdkHttpResponse},h}),this.list=async o=>{var s;const d={config:Object.assign(Object.assign({},{queryBase:!0}),o==null?void 0:o.config)};if(this.apiClient.isVertexAI()&&!d.config.queryBase){if(!((s=d.config)===null||s===void 0)&&s.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");d.config.filter="labels.tune-type:*"}return new zi(Jn.PAGED_ITEM_MODELS,h=>this.listInternal(h),await this.listInternal(d),d)},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,c,d,h,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}:!((d=(c=o.source)===null||c===void 0?void 0:c.video)===null||d===void 0)&&d.uri&&(!((y=(h=o.source)===null||h===void 0?void 0:h.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(t){t.config&&t.config.responseSchema&&(t.config.responseJsonSchema||Object.keys(t.config.responseSchema).includes("$schema")&&(t.config.responseJsonSchema=t.config.responseSchema,delete t.config.responseSchema))}async processParamsMaybeAddMcpUsage(t){var o,s,r;const c=(o=t.config)===null||o===void 0?void 0:o.tools;if(!c)return t;const d=await Promise.all(c.map(async y=>qo(y)?await y.tool():y)),h={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:d})};if(h.config.tools=d,t.config&&t.config.tools&&Fg(t.config.tools)){const y=(r=(s=t.config.httpOptions)===null||s===void 0?void 0:s.headers)!==null&&r!==void 0?r:{};let m=Object.assign({},y);Object.keys(m).length===0&&(m=this.apiClient.getDefaultHeaders()),Jg(m),h.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:m})}return h}async initAfcToolsMap(t){var o,s,r;const c=new Map;for(const d of(s=(o=t.config)===null||o===void 0?void 0:o.tools)!==null&&s!==void 0?s:[])if(qo(d)){const h=d,y=await h.tool();for(const m of(r=y.functionDeclarations)!==null&&r!==void 0?r:[]){if(!m.name)throw new Error("Function declaration name is required.");if(c.has(m.name))throw new Error(`Duplicate tool declaration name: ${m.name}`);c.set(m.name,h)}}return c}async processAfcStream(t){var o,s,r;const c=(r=(s=(o=t.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&r!==void 0?r:og;let d=!1,h=0;const y=await this.initAfcToolsMap(t);return(function(m,v,E){return yn(this,arguments,function*(){for(var _,x,w,I,M,V;h0){d=!0;const W=new Hl;W.candidates=[{content:{role:"user",parts:X}}],yield yield ye(W);const Ee=[];Ee.push(...ve),Ee.push({role:"user",parts:X});const Ne=en(E.contents).concat(Ee);E.contents=Ne}else break}})})(this,y,t)}async generateContentInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=eg(this.apiClient,t);return h=Z("{model}:generateContent",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=ng(v),_=new Hl;return Object.assign(_,E),_})}else{const m=jm(this.apiClient,t);return h=Z("{model}:generateContent",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=tg(v),_=new Hl;return Object.assign(_,E),_})}}async generateContentStreamInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=eg(this.apiClient,t);return h=Z("{model}:streamGenerateContent?alt=sse",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.requestStream({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}),d.then(function(E){return yn(this,arguments,function*(){var _,x,w,I;try{for(var M=!0,V=vn(E),$;$=yield ye(V.next()),_=$.done,!_;M=!0){I=$.value,M=!1;const O=I,J=ng(yield ye(O.json()),t);J.sdkHttpResponse={headers:O.headers};const ne=new Hl;Object.assign(ne,J),yield yield ye(ne)}}catch(O){x={error:O}}finally{try{!M&&!_&&(w=V.return)&&(yield ye(w.call(V)))}finally{if(x)throw x.error}}})})}else{const m=jm(this.apiClient,t);return h=Z("{model}:streamGenerateContent?alt=sse",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.requestStream({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}),d.then(function(E){return yn(this,arguments,function*(){var _,x,w,I;try{for(var M=!0,V=vn(E),$;$=yield ye(V.next()),_=$.done,!_;M=!0){I=$.value,M=!1;const O=I,J=tg(yield ye(O.json()),t);J.sdkHttpResponse={headers:O.headers};const ne=new Hl;Object.assign(ne,J),yield yield ye(ne)}}catch(O){x={error:O}}finally{try{!M&&!_&&(w=V.return)&&(yield ye(w.call(V)))}finally{if(x)throw x.error}}})})}}async embedContentInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=R_(this.apiClient,t,t),v=QT(t.model)?"{model}:embedContent":"{model}:predict";return h=Z(v,m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(E=>E.json().then(_=>{const x=_;return x.sdkHttpResponse={headers:E.headers},x})),d.then(E=>{const _=M_(E,t),x=new Pm;return Object.assign(x,_),x})}else{const m=b_(this.apiClient,t);return h=Z("{model}:batchEmbedContents",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=w_(v),_=new Pm;return Object.assign(_,E),_})}}async generateImagesInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=z_(this.apiClient,t);return h=Z("{model}:predict",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=O_(v),_=new qm;return Object.assign(_,E),_})}else{const m=V_(this.apiClient,t);return h=Z("{model}:predict",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=B_(v),_=new qm;return Object.assign(_,E),_})}}async editImageInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=C_(this.apiClient,t);return c=Z("{model}:predict",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const m=x_(y),v=new bT;return Object.assign(v,m),v})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=zC(this.apiClient,t);return c=Z("{model}:predict",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const m=BC(y),v=new RT;return Object.assign(v,m),v})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=_C(this.apiClient,t);return c=Z("{model}:predict",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=CC(y),v=new wT;return Object.assign(v,m),v})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=wC(this.apiClient,t);return c=Z("{model}:predict",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=MC(y),v=new MT;return Object.assign(v,m),v})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=sC(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>hc(v))}else{const m=lC(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>pc(v))}}async listInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=mC(this.apiClient,t);return h=Z("{models_url}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=yC(v),_=new Hm;return Object.assign(_,E),_})}else{const m=hC(this.apiClient,t);return h=Z("{models_url}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=gC(v),_=new Hm;return Object.assign(_,E),_})}}async update(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=kC(this.apiClient,t);return h=Z("{model}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>hc(v))}else{const m=HC(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>pc(v))}}async delete(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=T_(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=E_(v),_=new km;return Object.assign(_,E),_})}else{const m=v_(this.apiClient,t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=S_(v),_=new km;return Object.assign(_,E),_})}}async countTokens(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=m_(this.apiClient,t);return h=Z("{model}:countTokens",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=y_(v),_=new Vm;return Object.assign(_,E),_})}else{const m=h_(this.apiClient,t);return h=Z("{model}:countTokens",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=g_(v),_=new Vm;return Object.assign(_,E),_})}}async computeTokens(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=a_(this.apiClient,t);return c=Z("{model}:computeTokens",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const m=r_(y),v=new IT;return Object.assign(v,m),v})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=$_(this.apiClient,t);return h=Z("{model}:predictLongRunning",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d.then(v=>{const E=K_(v),_=new xa;return Object.assign(_,E),_})}else{const m=X_(this.apiClient,t);return h=Z("{model}:predictLongRunning",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d.then(v=>{const E=Y_(v),_=new xa;return Object.assign(_,E),_})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class qx extends Yn{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const o=t.operation,s=t.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 c;s&&"httpOptions"in s&&(c=s.httpOptions);const d=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:c}});return o._fromAPIResponse({apiResponse:d,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async get(t){const o=t.operation,s=t.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 c;s&&"httpOptions"in s&&(c=s.httpOptions);const d=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:c}});return o._fromAPIResponse({apiResponse:d,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async getVideosOperationInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=ET(t);return h=Z("{operationName}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),d}else{const m=ST(t);return h=Z("{operationName}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json()),d}}async fetchPredictVideosOperationInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=pT(t);return c=Z("{resourceName}:fetchPredictOperation",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.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 Hx(i){const t={},o=u(i,["data"]);if(o!=null&&f(t,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function kx(i){const t={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(c=>Xx(c))),f(t,["parts"],r)}const s=u(i,["role"]);return s!=null&&f(t,["role"],s),t}function Vx(i,t,o){const s={},r=u(t,["expireTime"]);o!==void 0&&r!=null&&f(o,["expireTime"],r);const c=u(t,["newSessionExpireTime"]);o!==void 0&&c!=null&&f(o,["newSessionExpireTime"],c);const d=u(t,["uses"]);o!==void 0&&d!=null&&f(o,["uses"],d);const h=u(t,["liveConnectConstraints"]);o!==void 0&&h!=null&&f(o,["bidiGenerateContentSetup"],Kx(i,h));const y=u(t,["lockAdditionalFields"]);return o!==void 0&&y!=null&&f(o,["fieldMask"],y),s}function zx(i,t){const o={},s=u(t,["config"]);return s!=null&&f(o,["config"],Vx(i,s,o)),o}function Bx(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&f(t,["fileUri"],o);const s=u(i,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function Ox(i){const t={},o=u(i,["id"]);o!=null&&f(t,["id"],o);const s=u(i,["args"]);s!=null&&f(t,["args"],s);const r=u(i,["name"]);if(r!=null&&f(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function Fx(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&f(t,["enableWidget"],o),t}function Jx(i){const t={},o=u(i,["searchTypes"]);if(o!=null&&f(t,["searchTypes"],o),u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const s=u(i,["timeRangeFilter"]);return s!=null&&f(t,["timeRangeFilter"],s),t}function Yx(i,t){const o={},s=u(i,["generationConfig"]);t!==void 0&&s!=null&&f(t,["setup","generationConfig"],s);const r=u(i,["responseModalities"]);t!==void 0&&r!=null&&f(t,["setup","generationConfig","responseModalities"],r);const c=u(i,["temperature"]);t!==void 0&&c!=null&&f(t,["setup","generationConfig","temperature"],c);const d=u(i,["topP"]);t!==void 0&&d!=null&&f(t,["setup","generationConfig","topP"],d);const h=u(i,["topK"]);t!==void 0&&h!=null&&f(t,["setup","generationConfig","topK"],h);const y=u(i,["maxOutputTokens"]);t!==void 0&&y!=null&&f(t,["setup","generationConfig","maxOutputTokens"],y);const m=u(i,["mediaResolution"]);t!==void 0&&m!=null&&f(t,["setup","generationConfig","mediaResolution"],m);const v=u(i,["seed"]);t!==void 0&&v!=null&&f(t,["setup","generationConfig","seed"],v);const E=u(i,["speechConfig"]);t!==void 0&&E!=null&&f(t,["setup","generationConfig","speechConfig"],Ic(E));const _=u(i,["thinkingConfig"]);t!==void 0&&_!=null&&f(t,["setup","generationConfig","thinkingConfig"],_);const x=u(i,["enableAffectiveDialog"]);t!==void 0&&x!=null&&f(t,["setup","generationConfig","enableAffectiveDialog"],x);const w=u(i,["systemInstruction"]);t!==void 0&&w!=null&&f(t,["setup","systemInstruction"],kx(Ct(w)));const I=u(i,["tools"]);if(t!==void 0&&I!=null){let z=Vo(I);Array.isArray(z)&&(z=z.map(X=>Qx(ko(X)))),f(t,["setup","tools"],z)}const M=u(i,["sessionResumption"]);t!==void 0&&M!=null&&f(t,["setup","sessionResumption"],$x(M));const V=u(i,["inputAudioTranscription"]);t!==void 0&&V!=null&&f(t,["setup","inputAudioTranscription"],V);const $=u(i,["outputAudioTranscription"]);t!==void 0&&$!=null&&f(t,["setup","outputAudioTranscription"],$);const O=u(i,["realtimeInputConfig"]);t!==void 0&&O!=null&&f(t,["setup","realtimeInputConfig"],O);const J=u(i,["contextWindowCompression"]);t!==void 0&&J!=null&&f(t,["setup","contextWindowCompression"],J);const ne=u(i,["proactivity"]);if(t!==void 0&&ne!=null&&f(t,["setup","proactivity"],ne),u(i,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return o}function Kx(i,t){const o={},s=u(t,["model"]);s!=null&&f(o,["setup","model"],Oe(i,s));const r=u(t,["config"]);return r!=null&&f(o,["config"],Yx(r,o)),o}function Xx(i){const t={},o=u(i,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const s=u(i,["codeExecutionResult"]);s!=null&&f(t,["codeExecutionResult"],s);const r=u(i,["executableCode"]);r!=null&&f(t,["executableCode"],r);const c=u(i,["fileData"]);c!=null&&f(t,["fileData"],Bx(c));const d=u(i,["functionCall"]);d!=null&&f(t,["functionCall"],Ox(d));const h=u(i,["functionResponse"]);h!=null&&f(t,["functionResponse"],h);const y=u(i,["inlineData"]);y!=null&&f(t,["inlineData"],Hx(y));const m=u(i,["text"]);m!=null&&f(t,["text"],m);const v=u(i,["thought"]);v!=null&&f(t,["thought"],v);const E=u(i,["thoughtSignature"]);E!=null&&f(t,["thoughtSignature"],E);const _=u(i,["videoMetadata"]);return _!=null&&f(t,["videoMetadata"],_),t}function $x(i){const t={},o=u(i,["handle"]);if(o!=null&&f(t,["handle"],o),u(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function Qx(i){const t={};if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const o=u(i,["computerUse"]);o!=null&&f(t,["computerUse"],o);const s=u(i,["fileSearch"]);s!=null&&f(t,["fileSearch"],s);const r=u(i,["googleSearch"]);r!=null&&f(t,["googleSearch"],Jx(r));const c=u(i,["codeExecution"]);if(c!=null&&f(t,["codeExecution"],c),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(i,["functionDeclarations"]);if(d!=null){let E=d;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["functionDeclarations"],E)}const h=u(i,["googleMaps"]);h!=null&&f(t,["googleMaps"],Fx(h));const y=u(i,["googleSearchRetrieval"]);y!=null&&f(t,["googleSearchRetrieval"],y);const m=u(i,["urlContext"]);m!=null&&f(t,["urlContext"],m);const v=u(i,["mcpServers"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(_=>_)),f(t,["mcpServers"],E)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Zx(i){const t=[];for(const o in i)if(Object.prototype.hasOwnProperty.call(i,o)){const s=i[o];if(typeof s=="object"&&s!=null&&Object.keys(s).length>0){const r=Object.keys(s).map(c=>`${o}.${c}`);t.push(...r)}else t.push(o)}return t.join(",")}function Wx(i,t){let o=null;const s=i.bidiGenerateContentSetup;if(typeof s=="object"&&s!==null&&"setup"in s){const c=s.setup;typeof c=="object"&&c!==null?(i.bidiGenerateContentSetup=c,o=c):delete i.bidiGenerateContentSetup}else s!==void 0&&delete i.bidiGenerateContentSetup;const r=i.fieldMask;if(o){const c=Zx(o);if(Array.isArray(t==null?void 0:t.lockAdditionalFields)&&(t==null?void 0:t.lockAdditionalFields.length)===0)c?i.fieldMask=c:delete i.fieldMask;else if(t!=null&&t.lockAdditionalFields&&t.lockAdditionalFields.length>0&&r!==null&&Array.isArray(r)&&r.length>0){const d=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let h=[];r.length>0&&(h=r.map(m=>d.includes(m)?`generationConfig.${m}`:m));const y=[];c&&y.push(c),h.length>0&&y.push(...h),y.length>0?i.fieldMask=y.join(","):delete i.fieldMask}else delete i.fieldMask}else r!==null&&Array.isArray(r)&&r.length>0?i.fieldMask=r.join(","):delete i.fieldMask;return i}class jx extends Yn{constructor(t){super(),this.apiClient=t}async create(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const h=zx(this.apiClient,t);c=Z("auth_tokens",h._url),d=h._query,delete h.config,delete h._url,delete h._query;const y=Wx(h,t.config);return r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(m=>m.json()),r.then(m=>m)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function eA(i,t){const o={},s=u(i,["force"]);return t!==void 0&&s!=null&&f(t,["_query","force"],s),o}function tA(i){const t={},o=u(i,["name"]);o!=null&&f(t,["_url","name"],o);const s=u(i,["config"]);return s!=null&&eA(s,t),t}function nA(i){const t={},o=u(i,["name"]);return o!=null&&f(t,["_url","name"],o),t}function iA(i,t){const o={},s=u(i,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&f(t,["_query","pageToken"],r),o}function oA(i){const t={},o=u(i,["parent"]);o!=null&&f(t,["_url","parent"],o);const s=u(i,["config"]);return s!=null&&iA(s,t),t}function lA(i){const t={},o=u(i,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const s=u(i,["nextPageToken"]);s!=null&&f(t,["nextPageToken"],s);const r=u(i,["documents"]);if(r!=null){let c=r;Array.isArray(c)&&(c=c.map(d=>d)),f(t,["documents"],c)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class sA extends Yn{constructor(t){super(),this.apiClient=t,this.list=async o=>new zi(Jn.PAGED_ITEM_DOCUMENTS,s=>this.listInternal({parent:o.parent,config:s.config}),await this.listInternal(o),o)}async get(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=nA(t);return c=Z("{name}",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(t){var o,s;let r="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const d=tA(t);r=Z("{name}",d._url),c=d._query,delete d._url,delete d._query,await this.apiClient.request({path:r,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal})}}async listInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=oA(t);return c=Z("{parent}/documents",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=lA(y),v=new DT;return Object.assign(v,m),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class aA extends Yn{constructor(t,o=new sA(t)){super(),this.apiClient=t,this.documents=o,this.list=async(s={})=>new zi(Jn.PAGED_ITEM_FILE_SEARCH_STORES,r=>this.listInternal(r),await this.listInternal(s),s)}async uploadToFileSearchStore(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(t.fileSearchStoreName,t.file,t.config)}async create(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=$C(t);return c=Z("fileSearchStores",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async get(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=WC(t);return c=Z("{name}",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(t){var o,s;let r="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const d=ZC(t);r=Z("{name}",d._url),c=d._query,delete d._url,delete d._query,await this.apiClient.request({path:r,queryParams:c,body:JSON.stringify(d),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal})}}async listInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=ox(t);return c=Z("fileSearchStores",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=lx(y),v=new UT;return Object.assign(v,m),v})}}async uploadToFileSearchStoreInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=sx(t);return c=Z("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=ax(y),v=new LT;return Object.assign(v,m),v})}}async importFile(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=tx(t);return c=Z("{file_search_store_name}:importFile",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const m=ex(y),v=new Nc;return Object.assign(v,m),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let Yg=function(){const{crypto:i}=globalThis;if(i!=null&&i.randomUUID)return Yg=i.randomUUID.bind(i),i.randomUUID();const t=new Uint8Array(1),o=i?()=>i.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^o()&15>>+s/4).toString(16))};const rA=()=>Yg();/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function gc(i){return typeof i=="object"&&i!==null&&("name"in i&&i.name==="AbortError"||"message"in i&&String(i.message).includes("FetchRequestCanceledException"))}const yc=i=>{if(i instanceof Error)return i;if(typeof i=="object"&&i!==null){try{if(Object.prototype.toString.call(i)==="[object Error]"){const t=new Error(i.message,i.cause?{cause:i.cause}:{});return i.stack&&(t.stack=i.stack),i.cause&&!t.cause&&(t.cause=i.cause),i.name&&(t.name=i.name),t}}catch{}try{return new Error(JSON.stringify(i))}catch{}}return new Error(i)};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class dn extends Error{}class Pt extends dn{constructor(t,o,s,r){super(`${Pt.makeMessage(t,o,s)}`),this.status=t,this.headers=r,this.error=o}static makeMessage(t,o,s){const r=o!=null&&o.message?typeof o.message=="string"?o.message:JSON.stringify(o.message):o?JSON.stringify(o):s;return t&&r?`${t} ${r}`:t?`${t} status code (no body)`:r||"(no status code or body)"}static generate(t,o,s,r){if(!t||!r)return new Ia({message:s,cause:yc(o)});const c=o;return t===400?new Xg(t,c,s,r):t===401?new $g(t,c,s,r):t===403?new Qg(t,c,s,r):t===404?new Zg(t,c,s,r):t===409?new Wg(t,c,s,r):t===422?new jg(t,c,s,r):t===429?new ey(t,c,s,r):t>=500?new ty(t,c,s,r):new Pt(t,c,s,r)}}class vc extends Pt{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class Ia extends Pt{constructor({message:t,cause:o}){super(void 0,void 0,t||"Connection error.",void 0),o&&(this.cause=o)}}class Kg extends Ia{constructor({message:t}={}){super({message:t??"Request timed out."})}}class Xg extends Pt{}class $g extends Pt{}class Qg extends Pt{}class Zg extends Pt{}class Wg extends Pt{}class jg extends Pt{}class ey extends Pt{}class ty extends Pt{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const uA=/^[a-z][a-z0-9+.-]*:/i,cA=i=>uA.test(i);let Tc=i=>(Tc=Array.isArray,Tc(i));const fA=Tc;let dA=fA;const rg=dA;function pA(i){if(!i)return!0;for(const t in i)return!1;return!0}function hA(i,t){return Object.prototype.hasOwnProperty.call(i,t)}const mA=(i,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new dn(`${i} must be an integer`);if(t<0)throw new dn(`${i} must be a positive integer`);return t},gA=i=>{try{return JSON.parse(i)}catch{return}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const yA=i=>new Promise(t=>setTimeout(t,i));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Uo="0.0.1";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function vA(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const TA=()=>{var i,t,o,s,r;const c=vA();if(c==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Uo,"X-Stainless-OS":cg(Deno.build.os),"X-Stainless-Arch":ug(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:(t=(i=Deno.version)===null||i===void 0?void 0:i.deno)!==null&&t!==void 0?t:"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Uo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(c==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Uo,"X-Stainless-OS":cg((o=globalThis.process.platform)!==null&&o!==void 0?o:"unknown"),"X-Stainless-Arch":ug((s=globalThis.process.arch)!==null&&s!==void 0?s:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":(r=globalThis.process.version)!==null&&r!==void 0?r:"unknown"};const d=SA();return d?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Uo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${d.browser}`,"X-Stainless-Runtime-Version":d.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Uo,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function SA(){if(typeof navigator>"u"||!navigator)return null;const i=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:o}of i){const s=o.exec(navigator.userAgent);if(s){const r=s[1]||0,c=s[2]||0,d=s[3]||0;return{browser:t,version:`${r}.${c}.${d}`}}}return null}const ug=i=>i==="x32"?"x32":i==="x86_64"||i==="x64"?"x64":i==="arm"?"arm":i==="aarch64"||i==="arm64"?"arm64":i?`other:${i}`:"unknown",cg=i=>(i=i.toLowerCase(),i.includes("ios")?"iOS":i==="android"?"Android":i==="darwin"?"MacOS":i==="win32"?"Windows":i==="freebsd"?"FreeBSD":i==="openbsd"?"OpenBSD":i==="linux"?"Linux":i?`Other:${i}`:"Unknown");let ha;const EA=()=>ha??(ha=TA());/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function _A(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ny(...i){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...i)}function CA(i){let t=Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator]();return ny({start(){},async pull(o){const{done:s,value:r}=await t.next();s?o.close():o.enqueue(r)},async cancel(){var o;await((o=t.return)===null||o===void 0?void 0:o.call(t))}})}function iy(i){if(i[Symbol.asyncIterator])return i;const t=i.getReader();return{async next(){try{const o=await t.read();return o!=null&&o.done&&t.releaseLock(),o}catch(o){throw t.releaseLock(),o}},async return(){const o=t.cancel();return t.releaseLock(),await o,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xA(i){var t,o;if(i===null||typeof i!="object")return;if(i[Symbol.asyncIterator]){await((o=(t=i[Symbol.asyncIterator]()).return)===null||o===void 0?void 0:o.call(t));return}const s=i.getReader(),r=s.cancel();s.releaseLock(),await r}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const AA=({headers:i,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const oy=()=>{var i;if(typeof File>"u"){const{process:t}=globalThis,o=typeof((i=t==null?void 0:t.versions)===null||i===void 0?void 0:i.node)=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(o?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function oc(i,t,o){return oy(),new File(i,t??"unknown_file",o)}function NA(i){return(typeof i=="object"&&i!==null&&("name"in i&&i.name&&String(i.name)||"url"in i&&i.url&&String(i.url)||"filename"in i&&i.filename&&String(i.filename)||"path"in i&&i.path&&String(i.path))||"").split(/[\\/]/).pop()||void 0}const bA=i=>i!=null&&typeof i=="object"&&typeof i[Symbol.asyncIterator]=="function";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const ly=i=>i!=null&&typeof i=="object"&&typeof i.size=="number"&&typeof i.type=="string"&&typeof i.text=="function"&&typeof i.slice=="function"&&typeof i.arrayBuffer=="function",RA=i=>i!=null&&typeof i=="object"&&typeof i.name=="string"&&typeof i.lastModified=="number"&&ly(i),wA=i=>i!=null&&typeof i=="object"&&typeof i.url=="string"&&typeof i.blob=="function";async function MA(i,t,o){if(oy(),i=await i,RA(i))return i instanceof File?i:oc([await i.arrayBuffer()],i.name);if(wA(i)){const r=await i.blob();return t||(t=new URL(i.url).pathname.split(/[\\/]/).pop()),oc(await Sc(r),t,o)}const s=await Sc(i);if(t||(t=NA(i)),!(o!=null&&o.type)){const r=s.find(c=>typeof c=="object"&&"type"in c&&c.type);typeof r=="string"&&(o=Object.assign(Object.assign({},o),{type:r}))}return oc(s,t,o)}async function Sc(i){var t,o,s,r,c;let d=[];if(typeof i=="string"||ArrayBuffer.isView(i)||i instanceof ArrayBuffer)d.push(i);else if(ly(i))d.push(i instanceof Blob?i:await i.arrayBuffer());else if(bA(i))try{for(var h=!0,y=vn(i),m;m=await y.next(),t=m.done,!t;h=!0){r=m.value,h=!1;const v=r;d.push(...await Sc(v))}}catch(v){o={error:v}}finally{try{!h&&!t&&(s=y.return)&&await s.call(y)}finally{if(o)throw o.error}}else{const v=(c=i==null?void 0:i.constructor)===null||c===void 0?void 0:c.name;throw new Error(`Unexpected data type: ${typeof i}${v?`; constructor: ${v}`:""}${IA(i)}`)}return d}function IA(i){return typeof i!="object"||i===null?"":`; props: [${Object.getOwnPropertyNames(i).map(o=>`"${o}"`).join(", ")}]`}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class sy{constructor(t){this._client=t}}sy._key=[];/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function ay(i){return i.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const fg=Object.freeze(Object.create(null)),DA=(i=ay)=>(function(o,...s){if(o.length===1)return o[0];let r=!1;const c=[],d=o.reduce((v,E,_)=>{var x,w,I;/[?#]/.test(E)&&(r=!0);const M=s[_];let V=(r?encodeURIComponent:i)(""+M);return _!==s.length&&(M==null||typeof M=="object"&&M.toString===((I=Object.getPrototypeOf((w=Object.getPrototypeOf((x=M.hasOwnProperty)!==null&&x!==void 0?x:fg))!==null&&w!==void 0?w:fg))===null||I===void 0?void 0:I.toString))&&(V=M+"",c.push({start:v.length+E.length,length:V.length,error:`Value of type ${Object.prototype.toString.call(M).slice(8,-1)} is not a valid path parameter`})),v+E+(_===s.length?"":V)},""),h=d.split(/[?#]/,1)[0],y=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let m;for(;(m=y.exec(h))!==null;){const v=m[0].startsWith("/"),E=v?1:0,_=v?m[0].slice(1):m[0];c.push({start:m.index+E,length:_.length,error:`Value "${_}" can't be safely passed as a path parameter`})}if(c.sort((v,E)=>v.start-E.start),c.length>0){let v=0;const E=c.reduce((_,x)=>{const w=" ".repeat(x.start-v),I="^".repeat(x.length);return v=x.start+x.length,_+w+I},"");throw new dn(`Path parameters result in path with invalid segments: ${c.map(_=>_.error).join(` `)} ${d} ${E}`)}return d}),ma=DA(ay);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class ry extends sy{create(t,o){var s;const{api_version:r=this._client.apiVersion}=t,c=Na(t,["api_version"]);if("model"in c&&"agent_config"in c)throw new dn("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in c&&"generation_config"in c)throw new dn("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(ma`/${r}/interactions`,Object.assign(Object.assign({body:c},o),{stream:(s=t.stream)!==null&&s!==void 0?s:!1}))}delete(t,o={},s){const{api_version:r=this._client.apiVersion}=o??{};return this._client.delete(ma`/${r}/interactions/${t}`,s)}cancel(t,o={},s){const{api_version:r=this._client.apiVersion}=o??{};return this._client.post(ma`/${r}/interactions/${t}/cancel`,s)}get(t,o={},s){var r;const c=o??{},{api_version:d=this._client.apiVersion}=c,h=Na(c,["api_version"]);return this._client.get(ma`/${d}/interactions/${t}`,Object.assign(Object.assign({query:h},s),{stream:(r=o==null?void 0:o.stream)!==null&&r!==void 0?r:!1}))}}ry._key=Object.freeze(["interactions"]);class uy extends ry{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function UA(i){let t=0;for(const r of i)t+=r.length;const o=new Uint8Array(t);let s=0;for(const r of i)o.set(r,s),s+=r.length;return o}let ga;function Uc(i){let t;return(ga??(t=new globalThis.TextEncoder,ga=t.encode.bind(t)))(i)}let ya;function dg(i){let t;return(ya??(t=new globalThis.TextDecoder,ya=t.decode.bind(t)))(i)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Da{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null}decode(t){if(t==null)return[];const o=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?Uc(t):t;this.buffer=UA([this.buffer,o]);const s=[];let r;for(;(r=LA(this.buffer,this.carriageReturnIndex))!=null;){if(r.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=r.index;continue}if(this.carriageReturnIndex!=null&&(r.index!==this.carriageReturnIndex+1||r.carriage)){s.push(dg(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}const c=this.carriageReturnIndex!==null?r.preceding-1:r.preceding,d=dg(this.buffer.subarray(0,c));s.push(d),this.buffer=this.buffer.subarray(r.index),this.carriageReturnIndex=null}return s}flush(){return this.buffer.length?this.decode(` `):[]}}Da.NEWLINE_CHARS=new Set([` `,"\r"]);Da.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function LA(i,t){for(let r=t??0;r{if(i){if(hA(ba,i))return i;Gt(o).warn(`${t} was set to ${JSON.stringify(i)}, expected one of ${JSON.stringify(Object.keys(ba))}`)}};function zl(){}function va(i,t,o){return!t||ba[i]>ba[o]?zl:t[i].bind(t)}const PA={error:zl,warn:zl,info:zl,debug:zl};let hg=new WeakMap;function Gt(i){var t;const o=i.logger,s=(t=i.logLevel)!==null&&t!==void 0?t:"off";if(!o)return PA;const r=hg.get(o);if(r&&r[0]===s)return r[1];const c={error:va("error",o,s),warn:va("warn",o,s),info:va("info",o,s),debug:va("debug",o,s)};return hg.set(o,[s,c]),c}const ki=i=>(i.options&&(i.options=Object.assign({},i.options),delete i.options.headers),i.headers&&(i.headers=Object.fromEntries((i.headers instanceof Headers?[...i.headers]:Object.entries(i.headers)).map(([t,o])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":o]))),"retryOfRequestLogID"in i&&(i.retryOfRequestLogID&&(i.retryOf=i.retryOfRequestLogID),delete i.retryOfRequestLogID),i);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Go{constructor(t,o,s){this.iterator=t,this.controller=o,this.client=s}static fromSSEResponse(t,o,s){let r=!1;const c=s?Gt(s):console;function d(){return yn(this,arguments,function*(){var y,m,v,E;if(r)throw new dn("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let _=!1;try{try{for(var x=!0,w=vn(qA(t,o)),I;I=yield ye(w.next()),y=I.done,!y;x=!0){E=I.value,x=!1;const M=E;if(!_)if(M.data.startsWith("[DONE]")){_=!0;continue}else try{yield yield ye(JSON.parse(M.data))}catch(V){throw c.error("Could not parse message into JSON:",M.data),c.error("From chunk:",M.raw),V}}}catch(M){m={error:M}}finally{try{!x&&!y&&(v=w.return)&&(yield ye(v.call(w)))}finally{if(m)throw m.error}}_=!0}catch(M){if(gc(M))return yield ye(void 0);throw M}finally{_||o.abort()}})}return new Go(d,o,s)}static fromReadableStream(t,o,s){let r=!1;function c(){return yn(this,arguments,function*(){var y,m,v,E;const _=new Da,x=iy(t);try{for(var w=!0,I=vn(x),M;M=yield ye(I.next()),y=M.done,!y;w=!0){E=M.value,w=!1;const V=E;for(const $ of _.decode(V))yield yield ye($)}}catch(V){m={error:V}}finally{try{!w&&!y&&(v=I.return)&&(yield ye(v.call(I)))}finally{if(m)throw m.error}}for(const V of _.flush())yield yield ye(V)})}function d(){return yn(this,arguments,function*(){var y,m,v,E;if(r)throw new dn("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let _=!1;try{try{for(var x=!0,w=vn(c()),I;I=yield ye(w.next()),y=I.done,!y;x=!0){E=I.value,x=!1;const M=E;_||M&&(yield yield ye(JSON.parse(M)))}}catch(M){m={error:M}}finally{try{!x&&!y&&(v=w.return)&&(yield ye(v.call(w)))}finally{if(m)throw m.error}}_=!0}catch(M){if(gc(M))return yield ye(void 0);throw M}finally{_||o.abort()}})}return new Go(d,o,s)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],o=[],s=this.iterator(),r=c=>({next:()=>{if(c.length===0){const d=s.next();t.push(d),o.push(d)}return c.shift()}});return[new Go(()=>r(t),this.controller,this.client),new Go(()=>r(o),this.controller,this.client)]}toReadableStream(){const t=this;let o;return ny({async start(){o=t[Symbol.asyncIterator]()},async pull(s){try{const{value:r,done:c}=await o.next();if(c)return s.close();const d=Uc(JSON.stringify(r)+` `);s.enqueue(d)}catch(r){s.error(r)}},async cancel(){var s;await((s=o.return)===null||s===void 0?void 0:s.call(o))}})}}function qA(i,t){return yn(this,arguments,function*(){var s,r,c,d;if(!i.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new dn("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new dn("Attempted to iterate over a response with no body");const h=new kA,y=new Da,m=iy(i.body);try{for(var v=!0,E=vn(HA(m)),_;_=yield ye(E.next()),s=_.done,!s;v=!0){d=_.value,v=!1;const x=d;for(const w of y.decode(x)){const I=h.decode(w);I&&(yield yield ye(I))}}}catch(x){r={error:x}}finally{try{!v&&!s&&(c=E.return)&&(yield ye(c.call(E)))}finally{if(r)throw r.error}}for(const x of y.flush()){const w=h.decode(x);w&&(yield yield ye(w))}})}function HA(i){return yn(this,arguments,function*(){var o,s,r,c;let d=new Uint8Array;try{for(var h=!0,y=vn(i),m;m=yield ye(y.next()),o=m.done,!o;h=!0){c=m.value,h=!1;const v=c;if(v==null)continue;const E=v instanceof ArrayBuffer?new Uint8Array(v):typeof v=="string"?Uc(v):v;let _=new Uint8Array(d.length+E.length);_.set(d),_.set(E,d.length),d=_;let x;for(;(x=GA(d))!==-1;)yield yield ye(d.slice(0,x)),d=d.slice(x)}}catch(v){s={error:v}}finally{try{!h&&!o&&(r=y.return)&&(yield ye(r.call(y)))}finally{if(s)throw s.error}}d.length>0&&(yield yield ye(d))})}class kA{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const c={event:this.event,data:this.data.join(` `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],c}if(this.chunks.push(t),t.startsWith(":"))return null;let[o,s,r]=VA(t,":");return r.startsWith(" ")&&(r=r.substring(1)),o==="event"?this.event=r:o==="data"&&this.data.push(r),null}}function VA(i,t){const o=i.indexOf(t);return o!==-1?[i.substring(0,o),t,i.substring(o+t.length)]:[i,"",""]}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function zA(i,t){const{response:o,requestLogID:s,retryOfRequestLogID:r,startTime:c}=t,d=await(async()=>{var h;if(t.options.stream)return Gt(i).debug("response",o.status,o.url,o.headers,o.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(o,t.controller,i):Go.fromSSEResponse(o,t.controller,i);if(o.status===204)return null;if(t.options.__binaryResponse)return o;const y=o.headers.get("content-type"),m=(h=y==null?void 0:y.split(";")[0])===null||h===void 0?void 0:h.trim();return(m==null?void 0:m.includes("application/json"))||(m==null?void 0:m.endsWith("+json"))?o.headers.get("content-length")==="0"?void 0:await o.json():await o.text()})();return Gt(i).debug(`[${s}] response parsed`,ki({retryOfRequestLogID:r,url:o.url,status:o.status,body:d,durationMs:Date.now()-c})),d}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Lc extends Promise{constructor(t,o,s=zA){super(r=>{r(null)}),this.responsePromise=o,this.parseResponse=s,this.client=t}_thenUnwrap(t){return new Lc(this.client,this.responsePromise,async(o,s)=>t(await this.parseResponse(o,s),s))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,o]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:o}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,o){return this.parse().then(t,o)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const cy=Symbol("brand.privateNullableHeaders");function*BA(i){if(!i)return;if(cy in i){const{values:s,nulls:r}=i;yield*s.entries();for(const c of r)yield[c,null];return}let t=!1,o;i instanceof Headers?o=i.entries():rg(i)?o=i:(t=!0,o=Object.entries(i??{}));for(let s of o){const r=s[0];if(typeof r!="string")throw new TypeError("expected header name to be a string");const c=rg(s[1])?s[1]:[s[1]];let d=!1;for(const h of c)h!==void 0&&(t&&!d&&(d=!0,yield[r,null]),yield[r,h])}}const kl=i=>{const t=new Headers,o=new Set;for(const s of i){const r=new Set;for(const[c,d]of BA(s)){const h=c.toLowerCase();r.has(h)||(t.delete(c),r.add(h)),d===null?(t.delete(c),o.add(h)):(t.append(c,d),o.delete(h))}}return{[cy]:!0,values:t,nulls:o}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const lc=i=>{var t,o,s,r,c,d;if(typeof globalThis.process<"u")return(s=(o=(t=aT)===null||t===void 0?void 0:t[i])===null||o===void 0?void 0:o.trim())!==null&&s!==void 0?s:void 0;if(typeof globalThis.Deno<"u")return(d=(c=(r=globalThis.Deno.env)===null||r===void 0?void 0:r.get)===null||c===void 0?void 0:c.call(r,i))===null||d===void 0?void 0:d.trim()};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var fy;class Ua{constructor(t){var o,s,r,c,d,h,y,{baseURL:m=lc("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:v=(o=lc("GEMINI_API_KEY"))!==null&&o!==void 0?o:null,apiVersion:E="v1beta"}=t,_=Na(t,["baseURL","apiKey","apiVersion"]);const x=Object.assign(Object.assign({apiKey:v,apiVersion:E},_),{baseURL:m||"https://generativelanguage.googleapis.com"});this.baseURL=x.baseURL,this.timeout=(s=x.timeout)!==null&&s!==void 0?s:Ua.DEFAULT_TIMEOUT,this.logger=(r=x.logger)!==null&&r!==void 0?r:console;const w="warn";this.logLevel=w,this.logLevel=(d=(c=pg(x.logLevel,"ClientOptions.logLevel",this))!==null&&c!==void 0?c:pg(lc("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&d!==void 0?d:w,this.fetchOptions=x.fetchOptions,this.maxRetries=(h=x.maxRetries)!==null&&h!==void 0?h:2,this.fetch=(y=x.fetch)!==null&&y!==void 0?y:_A(),this.encoder=AA,this._options=x,this.apiKey=v,this.apiVersion=E,this.clientAdapter=x.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:o}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!o.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){const o=kl([t.headers]);if(!(o.values.has("authorization")||o.values.has("x-goog-api-key"))){if(this.apiKey)return kl([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return kl([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([o,s])=>typeof s<"u").map(([o,s])=>{if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return`${encodeURIComponent(o)}=${encodeURIComponent(s)}`;if(s===null)return`${encodeURIComponent(o)}=`;throw new dn(`Cannot stringify type ${typeof s}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${Uo}`}defaultIdempotencyKey(){return`stainless-node-retry-${rA()}`}makeStatusError(t,o,s,r){return Pt.generate(t,o,s,r)}buildURL(t,o,s){const r=!this.baseURLOverridden()&&s||this.baseURL,c=cA(t)?new URL(t):new URL(r+(r.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),d=this.defaultQuery();return pA(d)||(o=Object.assign(Object.assign({},d),o)),typeof o=="object"&&o&&!Array.isArray(o)&&(c.search=this.stringifyQuery(o)),c.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){const o=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${o}`}}async prepareRequest(t,{url:o,options:s}){}get(t,o){return this.methodRequest("get",t,o)}post(t,o){return this.methodRequest("post",t,o)}patch(t,o){return this.methodRequest("patch",t,o)}put(t,o){return this.methodRequest("put",t,o)}delete(t,o){return this.methodRequest("delete",t,o)}methodRequest(t,o,s){return this.request(Promise.resolve(s).then(r=>Object.assign({method:t,path:o},r)))}request(t,o=null){return new Lc(this,this.makeRequest(t,o,void 0))}async makeRequest(t,o,s){var r,c,d;const h=await t,y=(r=h.maxRetries)!==null&&r!==void 0?r:this.maxRetries;o==null&&(o=y),await this.prepareOptions(h);const{req:m,url:v,timeout:E}=await this.buildRequest(h,{retryCount:y-o});await this.prepareRequest(m,{url:v,options:h});const _="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),x=s===void 0?"":`, retryOf: ${s}`,w=Date.now();if(Gt(this).debug(`[${_}] sending request`,ki({retryOfRequestLogID:s,method:h.method,url:v,options:h,headers:m.headers})),!((c=h.signal)===null||c===void 0)&&c.aborted)throw new vc;const I=new AbortController,M=await this.fetchWithTimeout(v,m,E,I).catch(yc),V=Date.now();if(M instanceof globalThis.Error){const O=`retrying, ${o} attempts remaining`;if(!((d=h.signal)===null||d===void 0)&&d.aborted)throw new vc;const J=gc(M)||/timed? ?out/i.test(String(M)+("cause"in M?String(M.cause):""));if(o)return Gt(this).info(`[${_}] connection ${J?"timed out":"failed"} - ${O}`),Gt(this).debug(`[${_}] connection ${J?"timed out":"failed"} (${O})`,ki({retryOfRequestLogID:s,url:v,durationMs:V-w,message:M.message})),this.retryRequest(h,o,s??_);throw Gt(this).info(`[${_}] connection ${J?"timed out":"failed"} - error; no more retries left`),Gt(this).debug(`[${_}] connection ${J?"timed out":"failed"} (error; no more retries left)`,ki({retryOfRequestLogID:s,url:v,durationMs:V-w,message:M.message})),J?new Kg:new Ia({cause:M})}const $=`[${_}${x}] ${m.method} ${v} ${M.ok?"succeeded":"failed"} with status ${M.status} in ${V-w}ms`;if(!M.ok){const O=await this.shouldRetry(M);if(o&&O){const W=`retrying, ${o} attempts remaining`;return await xA(M.body),Gt(this).info(`${$} - ${W}`),Gt(this).debug(`[${_}] response error (${W})`,ki({retryOfRequestLogID:s,url:M.url,status:M.status,headers:M.headers,durationMs:V-w})),this.retryRequest(h,o,s??_,M.headers)}const J=O?"error; no more retries left":"error; not retryable";Gt(this).info(`${$} - ${J}`);const ne=await M.text().catch(W=>yc(W).message),z=gA(ne),X=z?void 0:ne;throw Gt(this).debug(`[${_}] response error (${J})`,ki({retryOfRequestLogID:s,url:M.url,status:M.status,headers:M.headers,message:X,durationMs:Date.now()-w})),this.makeStatusError(M.status,z,X,M.headers)}return Gt(this).info($),Gt(this).debug(`[${_}] response start`,ki({retryOfRequestLogID:s,url:M.url,status:M.status,headers:M.headers,durationMs:V-w})),{response:M,options:h,controller:I,requestLogID:_,retryOfRequestLogID:s,startTime:w}}async fetchWithTimeout(t,o,s,r){const c=o||{},{signal:d,method:h}=c,y=Na(c,["signal","method"]),m=this._makeAbort(r);d&&d.addEventListener("abort",m,{once:!0});const v=setTimeout(m,s),E=globalThis.ReadableStream&&y.body instanceof globalThis.ReadableStream||typeof y.body=="object"&&y.body!==null&&Symbol.asyncIterator in y.body,_=Object.assign(Object.assign(Object.assign({signal:r.signal},E?{duplex:"half"}:{}),{method:"GET"}),y);h&&(_.method=h.toUpperCase());try{return await this.fetch.call(void 0,t,_)}finally{clearTimeout(v)}}async shouldRetry(t){const o=t.headers.get("x-should-retry");return o==="true"?!0:o==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,o,s,r){var c;let d;const h=r==null?void 0:r.get("retry-after-ms");if(h){const m=parseFloat(h);Number.isNaN(m)||(d=m)}const y=r==null?void 0:r.get("retry-after");if(y&&!d){const m=parseFloat(y);Number.isNaN(m)?d=Date.parse(y)-Date.now():d=m*1e3}if(!(d&&0<=d&&d<60*1e3)){const m=(c=t.maxRetries)!==null&&c!==void 0?c:this.maxRetries;d=this.calculateDefaultRetryTimeoutMillis(o,m)}return await yA(d),this.makeRequest(t,o-1,s)}calculateDefaultRetryTimeoutMillis(t,o){const c=o-t,d=Math.min(.5*Math.pow(2,c),8),h=1-Math.random()*.25;return d*h*1e3}async buildRequest(t,{retryCount:o=0}={}){var s,r,c;const d=Object.assign({},t),{method:h,path:y,query:m,defaultBaseURL:v}=d,E=this.buildURL(y,m,v);"timeout"in d&&mA("timeout",d.timeout),d.timeout=(s=d.timeout)!==null&&s!==void 0?s:this.timeout;const{bodyHeaders:_,body:x}=this.buildBody({options:d}),w=await this.buildHeaders({options:t,method:h,bodyHeaders:_,retryCount:o});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:h,headers:w},d.signal&&{signal:d.signal}),globalThis.ReadableStream&&x instanceof globalThis.ReadableStream&&{duplex:"half"}),x&&{body:x}),(r=this.fetchOptions)!==null&&r!==void 0?r:{}),(c=d.fetchOptions)!==null&&c!==void 0?c:{}),url:E,timeout:d.timeout}}async buildHeaders({options:t,method:o,bodyHeaders:s,retryCount:r}){let c={};this.idempotencyHeader&&o!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),c[this.idempotencyHeader]=t.idempotencyKey);const d=await this.authHeaders(t);let h=kl([c,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),EA()),this._options.defaultHeaders,s,t.headers,d]);return this.validateHeaders(h),h.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:o}}){if(!t)return{bodyHeaders:void 0,body:void 0};const s=kl([o]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&s.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:CA(t)}:typeof t=="object"&&s.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t)}:this.encoder({body:t,headers:s})}}Ua.DEFAULT_TIMEOUT=6e4;class xt extends Ua{constructor(){super(...arguments),this.interactions=new uy(this)}}fy=xt;xt.GeminiNextGenAPIClient=fy;xt.GeminiNextGenAPIClientError=dn;xt.APIError=Pt;xt.APIConnectionError=Ia;xt.APIConnectionTimeoutError=Kg;xt.APIUserAbortError=vc;xt.NotFoundError=Zg;xt.ConflictError=Wg;xt.RateLimitError=ey;xt.BadRequestError=Xg;xt.AuthenticationError=$g;xt.InternalServerError=ty;xt.PermissionDeniedError=Qg;xt.UnprocessableEntityError=jg;xt.toFile=MA;xt.Interactions=uy;/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function OA(i,t){const o={},s=u(i,["name"]);return s!=null&&f(o,["_url","name"],s),o}function FA(i,t){const o={},s=u(i,["name"]);return s!=null&&f(o,["_url","name"],s),o}function JA(i,t){const o={},s=u(i,["sdkHttpResponse"]);return s!=null&&f(o,["sdkHttpResponse"],s),o}function YA(i,t){const o={},s=u(i,["sdkHttpResponse"]);return s!=null&&f(o,["sdkHttpResponse"],s),o}function KA(i,t,o){const s={};if(u(i,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const r=u(i,["tunedModelDisplayName"]);if(t!==void 0&&r!=null&&f(t,["displayName"],r),u(i,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const c=u(i,["epochCount"]);t!==void 0&&c!=null&&f(t,["tuningTask","hyperparameters","epochCount"],c);const d=u(i,["learningRateMultiplier"]);if(d!=null&&f(s,["tuningTask","hyperparameters","learningRateMultiplier"],d),u(i,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(u(i,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(u(i,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");if(u(i,["tuningMode"])!==void 0)throw new Error("tuningMode parameter is not supported in Gemini API.");if(u(i,["customBaseModel"])!==void 0)throw new Error("customBaseModel parameter is not supported in Gemini API.");const h=u(i,["batchSize"]);t!==void 0&&h!=null&&f(t,["tuningTask","hyperparameters","batchSize"],h);const y=u(i,["learningRate"]);if(t!==void 0&&y!=null&&f(t,["tuningTask","hyperparameters","learningRate"],y),u(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(u(i,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");if(u(i,["baseTeacherModel"])!==void 0)throw new Error("baseTeacherModel parameter is not supported in Gemini API.");if(u(i,["tunedTeacherModelSource"])!==void 0)throw new Error("tunedTeacherModelSource parameter is not supported in Gemini API.");if(u(i,["sftLossWeightMultiplier"])!==void 0)throw new Error("sftLossWeightMultiplier parameter is not supported in Gemini API.");if(u(i,["outputUri"])!==void 0)throw new Error("outputUri parameter is not supported in Gemini API.");if(u(i,["encryptionSpec"])!==void 0)throw new Error("encryptionSpec parameter is not supported in Gemini API.");return s}function XA(i,t,o){const s={};let r=u(o,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const z=u(i,["validationDataset"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec"],sc(z))}else if(r==="PREFERENCE_TUNING"){const z=u(i,["validationDataset"]);t!==void 0&&z!=null&&f(t,["preferenceOptimizationSpec"],sc(z))}else if(r==="DISTILLATION"){const z=u(i,["validationDataset"]);t!==void 0&&z!=null&&f(t,["distillationSpec"],sc(z))}const c=u(i,["tunedModelDisplayName"]);t!==void 0&&c!=null&&f(t,["tunedModelDisplayName"],c);const d=u(i,["description"]);t!==void 0&&d!=null&&f(t,["description"],d);let h=u(o,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const z=u(i,["epochCount"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","hyperParameters","epochCount"],z)}else if(h==="PREFERENCE_TUNING"){const z=u(i,["epochCount"]);t!==void 0&&z!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],z)}else if(h==="DISTILLATION"){const z=u(i,["epochCount"]);t!==void 0&&z!=null&&f(t,["distillationSpec","hyperParameters","epochCount"],z)}let y=u(o,["config","method"]);if(y===void 0&&(y="SUPERVISED_FINE_TUNING"),y==="SUPERVISED_FINE_TUNING"){const z=u(i,["learningRateMultiplier"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],z)}else if(y==="PREFERENCE_TUNING"){const z=u(i,["learningRateMultiplier"]);t!==void 0&&z!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],z)}else if(y==="DISTILLATION"){const z=u(i,["learningRateMultiplier"]);t!==void 0&&z!=null&&f(t,["distillationSpec","hyperParameters","learningRateMultiplier"],z)}let m=u(o,["config","method"]);if(m===void 0&&(m="SUPERVISED_FINE_TUNING"),m==="SUPERVISED_FINE_TUNING"){const z=u(i,["exportLastCheckpointOnly"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","exportLastCheckpointOnly"],z)}else if(m==="PREFERENCE_TUNING"){const z=u(i,["exportLastCheckpointOnly"]);t!==void 0&&z!=null&&f(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],z)}else if(m==="DISTILLATION"){const z=u(i,["exportLastCheckpointOnly"]);t!==void 0&&z!=null&&f(t,["distillationSpec","exportLastCheckpointOnly"],z)}let v=u(o,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const z=u(i,["adapterSize"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","hyperParameters","adapterSize"],z)}else if(v==="PREFERENCE_TUNING"){const z=u(i,["adapterSize"]);t!==void 0&&z!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],z)}else if(v==="DISTILLATION"){const z=u(i,["adapterSize"]);t!==void 0&&z!=null&&f(t,["distillationSpec","hyperParameters","adapterSize"],z)}let E=u(o,["config","method"]);if(E===void 0&&(E="SUPERVISED_FINE_TUNING"),E==="SUPERVISED_FINE_TUNING"){const z=u(i,["tuningMode"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","tuningMode"],z)}const _=u(i,["customBaseModel"]);t!==void 0&&_!=null&&f(t,["customBaseModel"],_);let x=u(o,["config","method"]);if(x===void 0&&(x="SUPERVISED_FINE_TUNING"),x==="SUPERVISED_FINE_TUNING"){const z=u(i,["batchSize"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","hyperParameters","batchSize"],z)}let w=u(o,["config","method"]);if(w===void 0&&(w="SUPERVISED_FINE_TUNING"),w==="SUPERVISED_FINE_TUNING"){const z=u(i,["learningRate"]);t!==void 0&&z!=null&&f(t,["supervisedTuningSpec","hyperParameters","learningRate"],z)}const I=u(i,["labels"]);t!==void 0&&I!=null&&f(t,["labels"],I);const M=u(i,["beta"]);t!==void 0&&M!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","beta"],M);const V=u(i,["baseTeacherModel"]);t!==void 0&&V!=null&&f(t,["distillationSpec","baseTeacherModel"],V);const $=u(i,["tunedTeacherModelSource"]);t!==void 0&&$!=null&&f(t,["distillationSpec","tunedTeacherModelSource"],$);const O=u(i,["sftLossWeightMultiplier"]);t!==void 0&&O!=null&&f(t,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],O);const J=u(i,["outputUri"]);t!==void 0&&J!=null&&f(t,["outputUri"],J);const ne=u(i,["encryptionSpec"]);return t!==void 0&&ne!=null&&f(t,["encryptionSpec"],ne),s}function $A(i,t){const o={},s=u(i,["baseModel"]);s!=null&&f(o,["baseModel"],s);const r=u(i,["preTunedModel"]);r!=null&&f(o,["preTunedModel"],r);const c=u(i,["trainingDataset"]);c!=null&&sN(c);const d=u(i,["config"]);return d!=null&&KA(d,o),o}function QA(i,t){const o={},s=u(i,["baseModel"]);s!=null&&f(o,["baseModel"],s);const r=u(i,["preTunedModel"]);r!=null&&f(o,["preTunedModel"],r);const c=u(i,["trainingDataset"]);c!=null&&aN(c,o,t);const d=u(i,["config"]);return d!=null&&XA(d,o,t),o}function ZA(i,t){const o={},s=u(i,["name"]);return s!=null&&f(o,["_url","name"],s),o}function WA(i,t){const o={},s=u(i,["name"]);return s!=null&&f(o,["_url","name"],s),o}function jA(i,t,o){const s={},r=u(i,["pageSize"]);t!==void 0&&r!=null&&f(t,["_query","pageSize"],r);const c=u(i,["pageToken"]);t!==void 0&&c!=null&&f(t,["_query","pageToken"],c);const d=u(i,["filter"]);return t!==void 0&&d!=null&&f(t,["_query","filter"],d),s}function eN(i,t,o){const s={},r=u(i,["pageSize"]);t!==void 0&&r!=null&&f(t,["_query","pageSize"],r);const c=u(i,["pageToken"]);t!==void 0&&c!=null&&f(t,["_query","pageToken"],c);const d=u(i,["filter"]);return t!==void 0&&d!=null&&f(t,["_query","filter"],d),s}function tN(i,t){const o={},s=u(i,["config"]);return s!=null&&jA(s,o),o}function nN(i,t){const o={},s=u(i,["config"]);return s!=null&&eN(s,o),o}function iN(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["nextPageToken"]);r!=null&&f(o,["nextPageToken"],r);const c=u(i,["tunedModels"]);if(c!=null){let d=c;Array.isArray(d)&&(d=d.map(h=>dy(h))),f(o,["tuningJobs"],d)}return o}function oN(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["nextPageToken"]);r!=null&&f(o,["nextPageToken"],r);const c=u(i,["tuningJobs"]);if(c!=null){let d=c;Array.isArray(d)&&(d=d.map(h=>Ec(h))),f(o,["tuningJobs"],d)}return o}function lN(i,t){const o={},s=u(i,["name"]);s!=null&&f(o,["model"],s);const r=u(i,["name"]);return r!=null&&f(o,["endpoint"],r),o}function sN(i,t){const o={};if(u(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(i,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const s=u(i,["examples"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(c=>c)),f(o,["examples","examples"],r)}return o}function aN(i,t,o){const s={};let r=u(o,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const d=u(i,["gcsUri"]);t!==void 0&&d!=null&&f(t,["supervisedTuningSpec","trainingDatasetUri"],d)}else if(r==="PREFERENCE_TUNING"){const d=u(i,["gcsUri"]);t!==void 0&&d!=null&&f(t,["preferenceOptimizationSpec","trainingDatasetUri"],d)}else if(r==="DISTILLATION"){const d=u(i,["gcsUri"]);t!==void 0&&d!=null&&f(t,["distillationSpec","promptDatasetUri"],d)}let c=u(o,["config","method"]);if(c===void 0&&(c="SUPERVISED_FINE_TUNING"),c==="SUPERVISED_FINE_TUNING"){const d=u(i,["vertexDatasetResource"]);t!==void 0&&d!=null&&f(t,["supervisedTuningSpec","trainingDatasetUri"],d)}else if(c==="PREFERENCE_TUNING"){const d=u(i,["vertexDatasetResource"]);t!==void 0&&d!=null&&f(t,["preferenceOptimizationSpec","trainingDatasetUri"],d)}else if(c==="DISTILLATION"){const d=u(i,["vertexDatasetResource"]);t!==void 0&&d!=null&&f(t,["distillationSpec","promptDatasetUri"],d)}if(u(i,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return s}function dy(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["name"]);r!=null&&f(o,["name"],r);const c=u(i,["state"]);c!=null&&f(o,["state"],Rg(c));const d=u(i,["createTime"]);d!=null&&f(o,["createTime"],d);const h=u(i,["tuningTask","startTime"]);h!=null&&f(o,["startTime"],h);const y=u(i,["tuningTask","completeTime"]);y!=null&&f(o,["endTime"],y);const m=u(i,["updateTime"]);m!=null&&f(o,["updateTime"],m);const v=u(i,["description"]);v!=null&&f(o,["description"],v);const E=u(i,["baseModel"]);E!=null&&f(o,["baseModel"],E);const _=u(i,["_self"]);return _!=null&&f(o,["tunedModel"],lN(_)),o}function Ec(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["name"]);r!=null&&f(o,["name"],r);const c=u(i,["state"]);c!=null&&f(o,["state"],Rg(c));const d=u(i,["createTime"]);d!=null&&f(o,["createTime"],d);const h=u(i,["startTime"]);h!=null&&f(o,["startTime"],h);const y=u(i,["endTime"]);y!=null&&f(o,["endTime"],y);const m=u(i,["updateTime"]);m!=null&&f(o,["updateTime"],m);const v=u(i,["error"]);v!=null&&f(o,["error"],v);const E=u(i,["description"]);E!=null&&f(o,["description"],E);const _=u(i,["baseModel"]);_!=null&&f(o,["baseModel"],_);const x=u(i,["tunedModel"]);x!=null&&f(o,["tunedModel"],x);const w=u(i,["preTunedModel"]);w!=null&&f(o,["preTunedModel"],w);const I=u(i,["supervisedTuningSpec"]);I!=null&&f(o,["supervisedTuningSpec"],I);const M=u(i,["preferenceOptimizationSpec"]);M!=null&&f(o,["preferenceOptimizationSpec"],M);const V=u(i,["distillationSpec"]);V!=null&&f(o,["distillationSpec"],V);const $=u(i,["tuningDataStats"]);$!=null&&f(o,["tuningDataStats"],$);const O=u(i,["encryptionSpec"]);O!=null&&f(o,["encryptionSpec"],O);const J=u(i,["partnerModelTuningSpec"]);J!=null&&f(o,["partnerModelTuningSpec"],J);const ne=u(i,["customBaseModel"]);ne!=null&&f(o,["customBaseModel"],ne);const z=u(i,["experiment"]);z!=null&&f(o,["experiment"],z);const X=u(i,["labels"]);X!=null&&f(o,["labels"],X);const ve=u(i,["outputUri"]);ve!=null&&f(o,["outputUri"],ve);const W=u(i,["pipelineJob"]);W!=null&&f(o,["pipelineJob"],W);const Ee=u(i,["serviceAccount"]);Ee!=null&&f(o,["serviceAccount"],Ee);const Ne=u(i,["tunedModelDisplayName"]);Ne!=null&&f(o,["tunedModelDisplayName"],Ne);const Ve=u(i,["veoTuningSpec"]);return Ve!=null&&f(o,["veoTuningSpec"],Ve),o}function rN(i,t){const o={},s=u(i,["sdkHttpResponse"]);s!=null&&f(o,["sdkHttpResponse"],s);const r=u(i,["name"]);r!=null&&f(o,["name"],r);const c=u(i,["metadata"]);c!=null&&f(o,["metadata"],c);const d=u(i,["done"]);d!=null&&f(o,["done"],d);const h=u(i,["error"]);return h!=null&&f(o,["error"],h),o}function sc(i,t){const o={},s=u(i,["gcsUri"]);s!=null&&f(o,["validationDatasetUri"],s);const r=u(i,["vertexDatasetResource"]);return r!=null&&f(o,["validationDatasetUri"],r),o}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class uN extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new zi(Jn.PAGED_ITEM_TUNING_JOBS,s=>this.listInternal(s),await this.listInternal(o),o),this.get=async o=>await this.getInternal(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 c=Object.assign(Object.assign({},o),{preTunedModel:r});return c.baseModel=void 0,await this.tuneInternal(c)}else{const r=Object.assign({},o);return await this.tuneInternal(r)}else{const r=Object.assign({},o),c=await this.tuneMldevInternal(r);let d="";return c.metadata!==void 0&&c.metadata.tunedModel!==void 0?d=c.metadata.tunedModel:c.name!==void 0&&c.name.includes("/operations/")&&(d=c.name.split("/operations/")[0]),{name:d,state:rc.JOB_STATE_QUEUED}}}}async getInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=WA(t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>Ec(v))}else{const m=ZA(t);return h=Z("{name}",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>dy(v))}}async listInternal(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=nN(t);return h=Z("tuningJobs",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=oN(v),_=new zm;return Object.assign(_,E),_})}else{const m=tN(t);return h=Z("tunedModels",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=iN(v),_=new zm;return Object.assign(_,E),_})}}async cancel(t){var o,s,r,c;let d,h="",y={};if(this.apiClient.isVertexAI()){const m=FA(t);return h=Z("{name}:cancel",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=YA(v),_=new Bm;return Object.assign(_,E),_})}else{const m=OA(t);return h=Z("{name}:cancel",m._url),y=m._query,delete m._url,delete m._query,d=this.apiClient.request({path:h,queryParams:y,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(c=t.config)===null||c===void 0?void 0:c.abortSignal}).then(v=>v.json().then(E=>{const _=E;return _.sdkHttpResponse={headers:v.headers},_})),d.then(v=>{const E=JA(v),_=new Bm;return Object.assign(_,E),_})}}async tuneInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI()){const h=QA(t,t);return c=Z("tuningJobs",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>Ec(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var o,s;let r,c="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const h=$A(t);return c=Z("tunedModels",h._url),d=h._query,delete h._url,delete h._query,r=this.apiClient.request({path:c,queryParams:d,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(m=>{const v=m;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>rN(y))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class cN{async download(t,o){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const fN=1024*1024*8,dN=3,pN=1e3,hN=2,Ra="x-goog-upload-status";async function mN(i,t,o){var s;const r=await py(i,t,o),c=await(r==null?void 0:r.json());if(((s=r==null?void 0:r.headers)===null||s===void 0?void 0:s[Ra])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return c.file}async function gN(i,t,o){var s;const r=await py(i,t,o),c=await(r==null?void 0:r.json());if(((s=r==null?void 0:r.headers)===null||s===void 0?void 0:s[Ra])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const d=_g(c),h=new bc;return Object.assign(h,d),h}async function py(i,t,o){var s,r;let c=0,d=0,h=new cc(new Response),y="upload";for(c=i.size;d=c&&(y+=", finalize");let E=0,_=pN;for(;EsetTimeout(t,i))}class TN{async upload(t,o,s){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await mN(t,o,s)}async uploadToFileSearchStore(t,o,s){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await gN(t,o,s)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await yN(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class SN{create(t,o,s){return new EN(t,o,s)}}class EN{constructor(t,o,s){this.url=t,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(t){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(t)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const mg="x-goog-api-key";class _N{constructor(t){this.apiKey=t}async addAuthHeaders(t,o){if(t.get(mg)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");t.append(mg,this.apiKey)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const CN="gl-node/";class hy{get interactions(){var t;if(this._interactions!==void 0)return this._interactions;console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const o=this.httpOptions;o!=null&&o.extraBody&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const s=new xt({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:o==null?void 0:o.timeout,maxRetries:(t=o==null?void 0:o.retryOptions)===null||t===void 0?void 0:t.attempts});return this._interactions=s.interactions,this._interactions}constructor(t){var o;if(t.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(t.project||t.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(o=t.vertexai)!==null&&o!==void 0?o:!1,this.apiKey=t.apiKey;const s=fT(t.httpOptions,t.vertexai,void 0,void 0);s&&(t.httpOptions?t.httpOptions.baseUrl=s:t.httpOptions={baseUrl:s}),this.apiVersion=t.apiVersion,this.httpOptions=t.httpOptions;const r=new _N(this.apiKey);this.apiClient=new yx({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:CN+"web",uploader:new TN,downloader:new cN}),this.models=new Px(this.apiClient),this.live=new Mx(this.apiClient,r,new SN),this.batches=new BS(this.apiClient),this.chats=new CE(this.models,this.apiClient),this.caches=new SE(this.apiClient),this.files=new GE(this.apiClient),this.operations=new qx(this.apiClient),this.authTokens=new jx(this.apiClient),this.tunings=new uN(this.apiClient),this.fileSearchStores=new aA(this.apiClient)}}const xN=["gemini-3-pro-preview","gemini-2.5-pro","gemini-2.5-flash","gemini-pro-latest","gemini-2.5-flash-lite","gemini-2.5-flash-preview-09-2025","gemini-2.5-flash-lite-preview-09-2025","gemini-2.0-flash-exp","gemini-2.0-flash","gemini-2.0-flash-001"],AN=["gemini-2.0-flash-lite-001","gemini-2.0-flash-lite","gemini-2.0-flash-lite-preview-02-05","gemini-2.0-flash-lite-preview","gemini-exp-1206","gemma-3-1b-it","gemma-3-4b-it","gemma-3-12b-it","gemma-3-27b-it","gemma-3n-e4b-it","gemma-3n-e2b-it"],jt=[...xN,...AN],NN=1e6;let Gc="";const bN=i=>{Gc=i},my=(i,t)=>{let o="",s=NN;const r=i.map(h=>{const v=`--- START OF FILE ${h.path} --- `+h.content+` `;return{...h,fullContent:v,length:v.length}}),c=t?r.find(h=>h.path===t):null,d=r.filter(h=>!t||h.path!==t);c&&c.length<=s&&(o+=c.fullContent,s-=c.length);for(const h of d)if(h.length<=s)o+=h.fullContent,s-=h.length;else break;return o},Vi=i=>{if(!i)return"";let t=i.trim();const o=/^```\w*\s*\n/,s=/\n```$/;return t=t.replace(o,""),t=t.replace(s,""),t.trim()};async function Ho(i,t,o,s){const c=await new hy({apiKey:Gc}).models.generateContentStream({model:i,contents:[{role:"user",parts:[{text:t}]}],config:{temperature:.1,topP:.95,topK:64}});for await(const d of c)d.text&&o(d.text)}async function Bo(i,t,o){const r=await new hy({apiKey:Gc}).models.generateContent({model:i,contents:[{role:"user",parts:[{text:t}]}],config:{responseMimeType:"application/json",responseSchema:o,temperature:0,topP:.95,topK:64}});if(r.text)return JSON.parse(r.text.trim());throw new Error("AI returned an empty response.")}const RN=async(i,t,o,s,r,c)=>{const d=` You are an expert AI programmer. Your task is to modify a file based on a high-level instruction. **CRITICAL RULE: Your entire response must be ONLY the raw source code for the file.** - Do NOT output markdown code fences (like \`\`\`tsx), any explanatory text, or any preamble. - Your response will be saved directly to a file, so it must be 100% valid code. - If the instruction does not require any changes to this specific file, return the original content verbatim. - Ensure the new code is syntactically correct and preserves the overall structure and logic where appropriate. Instruction: "${t}" File Path: "${o}" Original Content: --- ${i} --- `;await Ho(c,d,s)},wN=async(i,t)=>{const o=` You are a 10x software architect. A user wants to create a new project. Your task is to analyze their prompt and generate a file structure and a brief description for each file. - The user prompt is: "${i}" - Based on the prompt, create a logical file structure. - For each file, provide a concise one-sentence description of its purpose. - The output must be a JSON object that adheres to the provided schema. - Only include files that would contain code or text. Do not include directories as separate entries. - Be comprehensive. Create all the necessary files for a basic, runnable version of the described project. `,s={type:_e.OBJECT,properties:{files:{type:_e.ARRAY,description:"A list of files to be created for the project.",items:{type:_e.OBJECT,properties:{path:{type:_e.STRING,description:'The full path of the file, including directories. E.g., "src/components/Button.tsx".'},description:{type:_e.STRING,description:"A concise, one-sentence description of what this file will contain or its purpose."}},required:["path","description"]}}},required:["files"]};return Bo(t,o,s)},gg=async(i,t,o,s,r,c)=>{const d=` You are an expert AI programmer generating code for a new project. The overall project goal is: "${i}" You are creating the file at this path: "${t}" The purpose of this file is: "${o}" Your task is to generate the complete, production-quality code for this single file. **CRITICAL RULE: Your entire response must be ONLY the raw source code for the file.** - Do NOT output markdown code fences (like \`\`\`tsx), any explanatory text, or any preamble. - Your response will be saved directly to a file, so it must be 100% valid code. - The code should be fully functional and align with the file's described purpose within the larger project. `;await Ho(c,d,s)},MN=async(i,t,o)=>{const s=i.map(d=>`--- START OF SEED FILE ${d.path} --- ${d.content} `).join(""),r=` You are a god-tier AI software architect and massive scale project generator. Your task is to take a single seed file and generate a massive project expansion around it. The user's high-level goal is: "${t}" You have been given the content of the SEED FILE. Based on this seed, you must generate a comprehensive plan to create a huge number of new files to build out a complete, production-grade system. **OBJECTIVES:** 1. Analyze the seed file to understand the core domain and patterns. 2. Plan a massive expansion. **Create as many files as possible.** Aim for 50+ new files if the complexity warrants it. Do not hold back. 3. 'filesToCreate': A list of NEW files. Assign an agent index (0-7) to each for parallel creation. 4. 'filesToEdit': **MUST BE EMPTY.** Do not touch the seed file. The seed file is immutable. Your response must be a JSON object adhering to the provided schema. Here is the SEED FILE context: ${s} `,c={type:_e.OBJECT,properties:{filesToEdit:{type:_e.ARRAY,description:"Must be empty. Do not edit the seed file.",items:{type:_e.OBJECT,properties:{path:{type:_e.STRING,description:"Path of the file to edit."},changes:{type:_e.STRING,description:"Detailed, step-by-step instructions for the code modifications."}},required:["path","changes"]}},filesToCreate:{type:_e.ARRAY,description:"A massive list of new files to create.",items:{type:_e.OBJECT,properties:{path:{type:_e.STRING,description:"Full path of the new file to create."},description:{type:_e.STRING,description:"Detailed description of the new file's purpose and content."},agentIndex:{type:_e.NUMBER,description:"Agent index (0-7) assigned to create this file."}},required:["path","description","agentIndex"]}}}};return Bo(o,r,c)},IN=async(i,t,o,s,r)=>{const c=` You are an AI code assistant. Rewrite the following file content based on the user's instruction. **CRITICAL RULE: Your entire response must be ONLY the new, complete file content.** - Do NOT output markdown code fences (e.g., \`\`\`). - The output will be saved directly to a file, so it must be clean. Instruction: "${t}" File Path: "${o}" Original Content: --- ${i} --- `;await Ho(r,c,s)},DN=async(i,t,o,s)=>{const r=my(o,t),c=` You are an autonomous AI software engineer. Your task is to implement a user's request by planning a series of file edits. **CRITICAL DIRECTIVE:** You have complete and unrestricted access to the full source code of every file in the repository, provided below. You MUST use this context to inform your plan. Do not, under any circumstances, claim you cannot see a file or that the code is incomplete. Base your entire plan on the provided code. **User Request:** "${i}" (The user was viewing this file when they made the request: "${t}") **Your Task:** 1. **Reasoning:** First, in a few sentences, explain your plan. Describe which files you will edit and why, outlining your high-level strategy to fulfill the user request. This reasoning is critical for the user to understand your thought process. 2. **filesToEdit:** Second, create a precise list of files to edit. For each file, provide a detailed, step-by-step description of the exact changes needed. This is not the code itself, but a set of instructions for another AI to execute. Be specific. For example, instead of "update the function," say "in the 'handleSubmit' function, add a new 'if' condition to check for 'user.id' before calling the API." Your output must be a single JSON object that strictly follows the provided schema. **These are the existing files in the app:** ${r} `,d={type:_e.OBJECT,properties:{reasoning:{type:_e.STRING,description:"A high-level explanation of your plan, which files you will edit, and why."},filesToEdit:{type:_e.ARRAY,description:"A list of files to modify and the specific changes for each.",items:{type:_e.OBJECT,properties:{path:{type:_e.STRING,description:"Path of the file to edit."},changes:{type:_e.STRING,description:"Detailed, step-by-step instructions for the code modifications."}},required:["path","changes"]}}},required:["reasoning","filesToEdit"]};return Bo(s,c,d)},UN=async(i,t,o,s,r)=>{const c=` You are an expert AI programmer. Your task is to meticulously modify a single file based on a detailed change instruction. **CRITICAL RULE: Your entire response must be ONLY the new, complete, raw source code for the file.** - Do NOT output markdown code fences (like \`\`\`tsx), any explanatory text, or any preamble. - Your response will be saved directly to a file, so it must be 100% valid code. - Follow the instructions exactly to produce the final version of the file. Instruction: "${t}" File Path: "${o}" Original Content: --- ${i} --- `;await Ho(r,c,s)},LN=async(i,t,o,s,r)=>{const c=my(t),d=o.map(m=>`I previously tried to edit "${m.path}" to have this content: --- ${m.newContent} --- `).join(` `),h=` You are an autonomous AI software engineer. Your previous attempt to modify the code resulted in a failed build. Your task is to analyze the build logs, understand the error, and create a NEW plan to fix it. **CRITICAL DIRECTIVE:** You have complete and unrestricted access to the full source code of every file in the repository, provided below. You MUST use this context. Do not claim you cannot see a file or that the code is truncated. Your fix must be based on the actual code provided. **Original User Request:** "${i}" **Build Error Logs:** --- ${s} --- **My Previous (Failed) Edits:** ${d} **Your Corrective Task:** 1. **Analyze & Reason:** Read the build logs and my previous edits. In a few sentences, explain the root cause of the build failure. Then, describe your new plan to fix the code. 2. **filesToEdit:** Create a new, precise list of files to edit to fix the error. For each file, provide a detailed, step-by-step description of the exact changes needed. This plan will completely replace the previous one. If you need to revert a change in one file and edit another, specify both actions. Your output must be a single JSON object that strictly follows the provided schema. **These are the current files in the app (reflecting your previous failed attempt):** ${c} `,y={type:_e.OBJECT,properties:{reasoning:{type:_e.STRING,description:"An analysis of the build failure and a high-level explanation of your new plan to fix it."},filesToEdit:{type:_e.ARRAY,description:"A new list of files to modify and the specific changes for each to fix the build.",items:{type:_e.OBJECT,properties:{path:{type:_e.STRING,description:"Path of the file to edit."},changes:{type:_e.STRING,description:"Detailed, step-by-step instructions for the new code modifications."}},required:["path","changes"]}}},required:["reasoning","filesToEdit"]};return Bo(r,h,y)},GN=async(i,t,o)=>{const s=` You are "The Jellyfish", a hyper-intelligent swarm coordinator. A user has provided an instruction (or a file tree) to overhaul or build a repository. **User Instruction/Tree:** "${i}" **Existing Repository Structure:** ${t.join(` `)} **Your Task:** Create a MASTER PLAN. List EVERY single file that needs to be created or edited to fully realize the user's vision. - If the user pasted a tree, replicate it exactly with appropriate descriptions. - If the user gave an instruction (e.g., "Link it all together"), analyze the existing structure and create a plan to connect/fix/refactor everything. - Be comprehensive. If it's a "Jellyfish" request, it means we want to touch everything that needs touching. Output JSON only. `,r={type:_e.OBJECT,properties:{files:{type:_e.ARRAY,description:"The complete list of files to work on.",items:{type:_e.OBJECT,properties:{path:{type:_e.STRING,description:"File path."},description:{type:_e.STRING,description:"Specific instruction for this file."}},required:["path","description"]}}},required:["files"]};return Bo(o,s,r)},PN=async(i,t,o,s,r,c)=>{c("drafting");let d="";const h=` You are an elite AI developer. Task: Write/Edit code for "${i}". Instruction: "${t}" Context (Other relevant files): ${s.slice(0,5e4)}... (truncated) Original Content: ${o} **CRITICAL:** Output ONLY the code. No markdown fences. `;await Ho(r,h,y=>{d+=y,c("drafting",d)}),d=Vi(d);for(let y=0;y<2;y++){c("critiquing",d);const m=` You are a Senior Code Reviewer. Review this code for "${i}". Instruction was: "${t}" Code: ${d} Check for: 1. Syntax errors. 2. Missing imports or wrong paths (based on context). 3. Logic bugs. 4. Completeness. Output JSON: { "approved": boolean, "critique": string } `,v={type:_e.OBJECT,properties:{approved:{type:_e.BOOLEAN},critique:{type:_e.STRING}},required:["approved","critique"]},E=await Bo(r,m,v);if(E.approved)return d;c("refining",d);let _="";const x=` You are an AI developer. Your previous code was rejected by the reviewer. Critique: "${E.critique}" Previous Code: ${d} Rewrite the code to fix the issues. Output ONLY the code. `;await Ho(r,x,w=>{_+=w,c("refining",_)}),d=Vi(_)}return d},qN=({alert:i,onClose:t})=>{if(Q.useEffect(()=>{if(i){const s=setTimeout(()=>{t()},4e3);return()=>clearTimeout(s)}},[i,t]),!i)return null;const o=i.type==="success"?"bg-green-600":"bg-red-600";return S.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:[S.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; } `}),S.jsx("p",{children:i.message})]})},HN=({fileCount:i,onClose:t,onSubmit:o})=>{const[s,r]=Q.useState(""),[c,d]=Q.useState(!1),h=async y=>{y.preventDefault(),!(!s.trim()||c)&&(d(!0),await o(s))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:t,children:S.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:[S.jsx("h2",{className:"text-xl font-bold text-amber-400 mb-2",children:"Multi-File AI Edit"}),S.jsxs("p",{className:"text-gray-400 mb-4",children:[i," file",i>1?"s":""," selected for editing."]}),S.jsxs("div",{className:"bg-red-900 border border-red-700 text-red-200 p-3 rounded-md mb-6 text-sm",children:[S.jsxs("p",{children:[S.jsx("strong",{children:"Warning:"})," This is an experimental feature. It will:"]}),S.jsxs("ul",{className:"list-disc list-inside mt-2",children:[S.jsxs("li",{children:["Commit changes directly to the ",S.jsx("strong",{children:"current branch"})," for each repository."]}),S.jsx("li",{children:"Process up to 8 files concurrently using a pool of AI workers."}),S.jsx("li",{children:"Each worker starts a new job every 31 seconds to manage rate limits."}),S.jsx("li",{children:"If a file fails, it will automatically retry with a different AI model (including fallback models) until it succeeds."})]}),S.jsx("p",{className:"mt-2",children:"It is highly recommended to create a new branch before starting and to review all changes carefully."})]}),S.jsxs("form",{onSubmit:h,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"instruction",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Instruction for All Selected Files"}),S.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})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:c,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:c||!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:c?S.jsx(ot,{}):"Start AI Edit"})]})]})]})})},kN=({status:i})=>{switch(i){case"queued":return S.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"processing":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"retrying":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.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 S.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 S.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}},VN=({jobs:i,onClose:t,isComplete:o})=>{const s=i.filter(h=>h.status==="success"||h.status==="skipped"||h.status==="failed").length,r=i.filter(h=>h.status==="success").length,c=i.length>0?s/i.length*100:0,d=i.filter(h=>h.status==="processing"||h.status==="retrying");return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.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:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsx("h2",{className:"text-2xl font-bold text-amber-400",children:"AI Bulk Edit Progress"}),o&&S.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsx("span",{children:`Overall Progress (${s} / ${i.length})`}),S.jsxs("span",{children:[r," successful"]})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-amber-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${c}%`}})})]}),S.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Queue"}),S.jsx("ul",{className:"space-y-1",children:i.map(h=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[S.jsx(kN,{status:h.status}),S.jsx("span",{className:"truncate",title:h.path,children:h.path})]}),(h.status==="failed"||h.status==="retrying")&&S.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:h.error||"Unknown error",children:h.error})]},h.id))})]}),S.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",d.length," active)"]}),d.length>0?S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 flex-grow min-h-0",children:d.slice(0,8).map(h=>S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:h.path,children:[h.status==="retrying"?"Retrying":"Processing",": ",S.jsx("span",{className:"font-bold",children:h.path.split("/").pop()})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:h.content})})})]},h.id))}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:o?"All jobs complete.":"Waiting for next job..."})]})]})]})})},zN=({onClose:i,onSubmit:t})=>{const[o,s]=Q.useState(""),[r,c]=Q.useState(""),[d,h]=Q.useState(!0),[y,m]=Q.useState(!1),[v,E]=Q.useState(""),_=async x=>{if(x.preventDefault(),E(""),!(!o.trim()||!r.trim()||y)){m(!0);try{await t(o.trim().replace(/\s+/g,"-"),r,d)}catch(w){E(w instanceof Error?w.message:"An unknown error occurred."),m(!1)}}};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:x=>x.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"New AI Project"}),S.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."}),S.jsxs("form",{onSubmit:_,children:[S.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[S.jsxs("div",{className:"md:col-span-2",children:[S.jsx("label",{htmlFor:"repoName",className:"block text-sm font-medium text-gray-300 mb-2",children:"New Repository Name"}),S.jsx("input",{id:"repoName",type:"text",value:o,onChange:x=>s(x.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})]}),S.jsxs("div",{children:[S.jsx("label",{htmlFor:"repoVisibility",className:"block text-sm font-medium text-gray-300 mb-2",children:"Visibility"}),S.jsxs("select",{id:"repoVisibility",value:d?"private":"public",onChange:x=>h(x.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:[S.jsx("option",{value:"private",children:"Private"}),S.jsx("option",{value:"public",children:"Public"})]})]})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"Project Description"}),S.jsx("textarea",{id:"prompt",value:r,onChange:x=>c(x.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})]}),v&&S.jsx("p",{className:"text-red-400 text-sm mb-4",children:v}),S.jsxs("div",{className:"flex justify-end gap-4",children:[S.jsx("button",{type:"button",onClick:i,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"}),S.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?S.jsx(ot,{}):"Generate Project"})]})]})]})})},BN=({status:i})=>{switch(i){case"queued":return S.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"generating":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"committing":return S.jsx(ot,{className:"w-4 h-4 text-yellow-400"});case"retrying":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.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 S.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}},ON=({jobs:i,statusMessage:t,onClose:o,isComplete:s})=>{const r=i.filter(y=>y.status==="success"||y.status==="failed").length,c=i.filter(y=>y.status==="success").length,d=i.length>0?r/i.length*100:0,h=i.filter(y=>y.status==="generating"||y.status==="committing"||y.status==="retrying");return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.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:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsx("h2",{className:"text-2xl font-bold text-indigo-400",children:"AI Project Generation"}),s&&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"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[!s&&S.jsx(ot,{className:"h-4 w-4"}),t]}),S.jsx("span",{children:`${c} / ${i.length} files successful`})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-indigo-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${d}%`}})})]}),S.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Plan"}),S.jsx("ul",{className:"space-y-1",children:i.map(y=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[S.jsx(BN,{status:y.status}),S.jsx("span",{className:"truncate",title:y.path,children:y.path})]}),(y.status==="failed"||y.status==="retrying")&&S.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:y.error||"Unknown error",children:y.error})]},y.id))})]}),S.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Generation (",h.length," active)"]}),h.length>0?S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 flex-grow min-h-0",children:h.slice(0,8).map(y=>S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:y.path,children:[y.status.charAt(0).toUpperCase()+y.status.slice(1),": ",S.jsx("span",{className:"font-bold",children:y.path})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:y.content})})})]},y.id))}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:s?"All files generated.":"Waiting to generate..."})]})]})]})})},FN=({onClose:i,onSubmit:t})=>{const[o,s]=Q.useState(""),[r,c]=Q.useState(!1),d=async h=>{h.preventDefault(),!(!o.trim()||r)&&(c(!0),await t(o))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:h=>h.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-purple-400 mb-2",children:"Project Expansion (Seed Mode)"}),S.jsxs("p",{className:"text-gray-400 mb-4",children:["You've selected a ",S.jsx("strong",{children:"single seed file"}),". Describe your high-level goal, and the AI will generate a massive amount of ",S.jsx("strong",{children:"new files"})," to expand this project. The seed file itself will not be modified."]}),S.jsxs("form",{onSubmit:d,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Expansion Goal"}),S.jsx("textarea",{id:"prompt",value:o,onChange:h=>s(h.target.value),placeholder:"e.g., 'Add a complete user authentication system with sign-up, login, and profile pages. Also add a dashboard to visualize data from the existing components.'",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-purple-500 resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:r,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:r||!o.trim(),className:"px-6 py-2 bg-purple-600 text-white font-semibold rounded-md hover:bg-purple-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:r?S.jsx(ot,{}):"Unleash Agents"})]})]})]})})},JN=({status:i})=>{switch(i){case"queued":return S.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"generating":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"committing":return S.jsx(ot,{className:"w-4 h-4 text-yellow-400"});case"retrying":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.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 S.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}},yg=({title:i,isActive:t,isComplete:o})=>S.jsxs("div",{className:"flex items-center gap-2",children:[t&&S.jsx(ot,{className:"h-4 w-4"}),o&&S.jsx("div",{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:"✓"}),S.jsx("span",{className:t?"text-purple-300":o?"text-gray-300":"text-gray-500",children:i})]}),YN=({jobs:i,phase:t,onClose:o,isComplete:s})=>{const r=i.filter(m=>m.status==="success"||m.status==="failed").length,c=i.filter(m=>m.status==="success").length,d=i.length>0?r/i.length*100:0,h=i.filter(m=>m.status==="generating"||m.status==="committing"||m.status==="retrying"),y=()=>{switch(t){case"planning":return"Master agent is analyzing the seed file and planning massive expansion...";case"generating":return`Executing plan: ${i.length} file operations...`;case"complete":return"Project expansion complete!";default:return"Initializing..."}};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-7xl h-[90vh] flex flex-col border border-gray-700",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsx("h2",{className:"text-2xl font-bold text-purple-400",children:"AI Project Expansion"}),s&&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"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0 space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-around p-2 bg-gray-900 rounded-md",children:[S.jsx(yg,{title:"1. Planning",isActive:t==="planning",isComplete:["generating","complete"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-4"}),S.jsx(yg,{title:"2. Execution",isActive:t==="generating",isComplete:t==="complete"})]}),S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[t!=="complete"&&S.jsx(ot,{className:"h-4 w-4"}),y()]}),S.jsx("span",{children:`${c} / ${i.length} file operations successful`})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-purple-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${d}%`}})})]}),t==="planning"?S.jsx("div",{className:"flex-grow min-h-0 bg-gray-900 rounded-md p-4 flex items-center justify-center",children:S.jsxs("div",{className:"text-center text-gray-400",children:[S.jsx(ot,{className:"h-8 w-8 mx-auto mb-4"}),S.jsx("p",{children:"Master agent is analyzing the seed file..."}),S.jsx("p",{className:"text-sm text-gray-500",children:"This may take a few moments."})]})}):S.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Execution Plan (",i.length," Operations)"]}),S.jsx("ul",{className:"space-y-1",children:i.map(m=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[S.jsx(JN,{status:m.status}),m.type==="edit"?S.jsx("span",{className:"text-xs font-mono text-yellow-400 bg-yellow-900 px-1.5 py-0.5 rounded flex-shrink-0",children:"[EDIT]"}):S.jsx("span",{className:"text-xs font-mono text-green-400 bg-green-900 px-1.5 py-0.5 rounded flex-shrink-0",children:"[NEW]"}),S.jsx("span",{className:"truncate",title:m.path,children:m.path})]}),(m.status==="failed"||m.status==="retrying")&&S.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:m.error||"Unknown error",children:m.error})]},m.id))})]}),S.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",h.length," active)"]}),h.length>0?S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 flex-grow min-h-0",children:h.slice(0,8).map(m=>S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:m.path,children:["Agent ",m.agentIndex," ",m.status==="generating"?"Generating":"Committing",": ",S.jsx("span",{className:"font-bold",children:m.path.split("/").pop()})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:m.content})})})]},m.id))}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:s?"All jobs complete.":"Waiting for next job..."})]})]})]})})},KN=({onClose:i,onSubmit:t,token:o,repoFullName:s})=>{const[r,c]=Q.useState(""),[d,h]=Q.useState(!1),[y,m]=Q.useState([]),[v,E]=Q.useState(""),[_,x]=Q.useState(!0);Q.useEffect(()=>{(async()=>{if(o&&s)try{x(!0);const[M,V]=s.split("/"),O=(await Wv(o,M,V)).workflows.filter(J=>J.state==="active");m(O),O.length>0&&E(String(O[0].id))}catch(M){console.error("Failed to fetch workflows",M)}finally{x(!1)}})()},[o,s]);const w=async I=>{I.preventDefault(),!(!r.trim()||d||!v)&&(h(!0),await t(r,v))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:I=>I.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"Advanced AI Edit & Test"}),S.jsxs("div",{className:"bg-blue-900 border border-blue-700 text-blue-200 p-4 rounded-md mb-6 text-sm space-y-2",children:[S.jsx("p",{children:S.jsx("strong",{children:"This is a powerful, repository-aware AI agent."})}),S.jsxs("ul",{className:"list-disc list-inside",children:[S.jsx("li",{children:"It analyzes your entire repository for context."}),S.jsx("li",{children:"It can edit multiple files to fulfill your request."}),S.jsxs("li",{children:["It will ",S.jsx("strong",{children:"commit changes and run a GitHub Actions workflow"})," to verify its work."]}),S.jsx("li",{children:"If the build fails, it will analyze the logs and attempt to fix its own mistakes."})]})]}),S.jsxs("form",{onSubmit:w,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"instruction-advanced",className:"block text-sm font-medium text-gray-300 mb-2",children:"Your Request"}),S.jsx("textarea",{id:"instruction-advanced",value:r,onChange:I=>c(I.target.value),placeholder:"e.g., 'Refactor the authentication logic to use a context provider instead of prop drilling.'",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",autoFocus:!0})]}),S.jsxs("div",{className:"mb-6",children:[S.jsx("label",{htmlFor:"workflow-select",className:"block text-sm font-medium text-gray-300 mb-2",children:"Select Workflow for Verification"}),_?S.jsxs("div",{className:"flex items-center gap-2 text-gray-400",children:[S.jsx(ot,{className:"w-4 h-4"}),S.jsx("span",{children:"Loading workflows..."})]}):y.length>0?S.jsx("select",{id:"workflow-select",value:v,onChange:I=>E(I.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",children:y.map(I=>S.jsxs("option",{value:I.id,children:[I.name," (",I.path.split("/").pop(),")"]},I.id))}):S.jsx("p",{className:"text-sm text-yellow-400 bg-yellow-900 p-2 rounded-md",children:"No active GitHub Actions workflows found in this repository."})]}),S.jsxs("div",{className:"flex justify-end gap-4",children:[S.jsx("button",{type:"button",onClick:i,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"}),S.jsx("button",{type:"submit",disabled:d||!r.trim()||!v,className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:d?S.jsx(ot,{}):"Execute & Test"})]})]})]})})},XN=({status:i})=>{switch(i){case"planning":case"editing":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"verifying":return S.jsx(ot,{className:"w-4 h-4 text-yellow-400"});case"committing":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.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 S.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 S.jsx("div",{title:"Pending",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"})}},Vl=({title:i,isActive:t,isComplete:o})=>S.jsxs("div",{className:"flex items-center gap-2",children:[t&&S.jsx(ot,{className:"h-4 w-4"}),o&&S.jsx("div",{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:"✓"}),S.jsx("span",{className:t?"text-indigo-300":o?"text-gray-300":"text-gray-500",children:i})]}),$N=({jobs:i,phase:t,verificationAttempt:o,buildLogs:s,workflowRunUrl:r,aiThought:c,deploymentUrl:d,onClose:h,isComplete:y})=>{const m=i.filter(x=>x.status==="success").length,v=i.length>0?m/i.length*100:0,E=()=>{switch(t){case"analyzing":return"Analyzing repository context...";case"planning":return"AI is creating an edit plan...";case"editing":return`AI is editing ${i.length} file(s)...`;case"committing":return"Committing changes to trigger workflow...";case"triggering_workflow":return"Triggering GitHub Actions workflow...";case"waiting_for_workflow":return`Running CI build (Attempt ${o})...`;case"analyzing_failure":return`Build failed (Attempt ${o}). Analyzing logs for correction...`;case"complete":return"Advanced edit complete and verified!";default:return"Initializing..."}},_=i.find(x=>x.status==="editing")||i.find(x=>x.status==="committing")||i[i.length-1];return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-7xl h-[90vh] flex flex-col border border-gray-700",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-4",children:[S.jsx("h2",{className:"text-2xl font-bold text-indigo-400",children:"Advanced AI Edit & Test"}),r&&S.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-cyan-400 hover:underline",children:"View Workflow Run"})]}),y&&S.jsx("button",{onClick:h,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0 space-y-3",children:[S.jsxs("div",{className:"grid grid-cols-5 items-center justify-around p-2 bg-gray-900 rounded-md text-sm",children:[S.jsx(Vl,{title:"1. Plan",isActive:t==="analyzing"||t==="planning",isComplete:!["idle","analyzing","planning"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Vl,{title:"2. Edit",isActive:t==="editing",isComplete:!["idle","analyzing","planning","editing"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Vl,{title:"3. Commit",isActive:t==="committing",isComplete:!["idle","analyzing","planning","editing","committing"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Vl,{title:"4. Verify (CI)",isActive:t==="triggering_workflow"||t==="waiting_for_workflow"||t==="analyzing_failure",isComplete:t==="complete"}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Vl,{title:"5. Done",isActive:!1,isComplete:t==="complete"})]}),S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsx("span",{className:"flex items-center gap-2",children:E()}),S.jsx("span",{children:`${m} / ${i.length} files committed`})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-indigo-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${v}%`}})})]}),c&&S.jsxs("div",{className:"mb-4 p-4 bg-gray-900 rounded-md border border-gray-700",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-indigo-300 flex items-center gap-2",children:[S.jsx(xc,{className:"w-5 h-5"}),"AI Thought Process"]}),S.jsx("p",{className:"text-gray-300 text-sm whitespace-pre-wrap font-mono",children:c})]}),S.jsxs("div",{className:"grid grid-cols-2 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Affected Files (",i.length,")"]}),S.jsx("ul",{className:"space-y-1 overflow-y-auto",children:i.map(x=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[S.jsx(XN,{status:x.status}),S.jsx("span",{className:"truncate",title:x.path,children:x.path})]}),x.error&&S.jsx("span",{className:"text-yellow-400 text-xs truncate ml-2 cursor-pointer",title:x.error,children:x.error})]},x.id))})]}),S.jsx("div",{className:"bg-gray-900 rounded-md p-4 flex flex-col",children:y&&d?S.jsxs(S.Fragment,{children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-green-400",children:"Live Deployment Preview"}),S.jsxs("div",{className:"bg-yellow-900 border border-yellow-700 text-yellow-200 p-3 rounded-md mb-4 text-sm",children:[S.jsx("p",{children:"GitHub Pages may prevent embedding. If the panel below is blank, please use the direct link."}),S.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:underline font-semibold mt-2 inline-block",children:"Open Live Site in New Tab →"})]}),S.jsx("div",{className:"flex-grow bg-white rounded-md overflow-hidden border-4 border-gray-700",children:S.jsx("iframe",{src:d,title:"Live Deployment",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin"})})]}):t==="analyzing_failure"&&s?S.jsxs(S.Fragment,{children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-red-400",children:"Build Failure Logs"}),S.jsx("div",{className:"bg-black rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words font-mono",children:S.jsx("code",{children:s})})})]}):S.jsxs(S.Fragment,{children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"Live Code Generation"}),_?S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:_.path,children:["Current focus: ",S.jsx("span",{className:"font-bold",children:_.path})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:_.content})})})]}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:S.jsx("p",{children:"Waiting for plan..."})})]})})]})]})})},QN=({onClose:i,onSubmit:t})=>{const[o,s]=Q.useState(""),[r,c]=Q.useState(!1),d=async h=>{h.preventDefault(),!(!o.trim()||r)&&(c(!0),await t(o))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:h=>h.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-cyan-400 mb-4",children:"Simple AI Edit"}),S.jsx("p",{className:"text-gray-400 mb-6 text-sm",children:"Describe how you want to change the current file. The AI will rewrite the file's content directly in the editor. This edit is not automatically committed."}),S.jsxs("form",{onSubmit:d,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"instruction-simple",className:"block text-sm font-medium text-gray-300 mb-2",children:"Instruction"}),S.jsx("textarea",{id:"instruction-simple",value:o,onChange:h=>s(h.target.value),placeholder:"e.g., 'Convert this to an async function and add a try/catch block.'",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-cyan-500 resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:r,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:r||!o.trim(),className:"px-6 py-2 bg-cyan-600 text-white font-semibold rounded-md hover:bg-cyan-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:r?S.jsx(ot,{}):"Rewrite Code"})]})]})]})})},ZN=({onClose:i,onSubmit:t,repoName:o})=>{const[s,r]=Q.useState(""),[c,d]=Q.useState(!1),h=async y=>{y.preventDefault(),!(!s.trim()||c)&&(d(!0),await t(s))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-4xl border border-gray-700",onClick:y=>y.stopPropagation(),children:[S.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[S.jsx("h2",{className:"text-2xl font-bold text-pink-500",children:"Jellyfish Swarm Mode"}),S.jsxs("span",{className:"text-gray-500 text-sm",children:["Target: ",o]})]}),S.jsxs("div",{className:"bg-pink-900/30 border border-pink-700/50 text-pink-100 p-4 rounded-md mb-6 text-sm",children:[S.jsx("h3",{className:"font-bold mb-2",children:"Instructions:"}),S.jsx("p",{className:"mb-2",children:"You can execute a massive, repository-wide overhaul here."}),S.jsxs("ul",{className:"list-disc list-inside space-y-1 text-pink-200",children:[S.jsxs("li",{children:[S.jsx("strong",{children:"Paste a File Tree:"})," If you have a specific structure in mind, paste it below. The swarm will build it."]}),S.jsxs("li",{children:[S.jsx("strong",{children:'"Link it all together":'})," Describe how files should interact. The agents will hop around the code to ensure imports are correct."]}),S.jsxs("li",{children:[S.jsx("strong",{children:"Double & Triple Check:"})," 8 Agents will work in parallel. Each agent will critique its own code and rewrite it until it's perfect."]})]})]}),S.jsxs("form",{onSubmit:h,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"Paste Tree / Instructions"}),S.jsx("textarea",{id:"prompt",value:s,onChange:y=>r(y.target.value),placeholder:`e.g. src/ components/ Header.tsx Footer.tsx utils/ api.ts Instruction: Create these files. Ensure Header uses the api.ts to fetch user data. Link everything together.`,className:"w-full h-64 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-pink-500 font-mono resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:c,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:c||!s.trim(),className:"px-6 py-2 bg-pink-600 text-white font-semibold rounded-md hover:bg-pink-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[150px]",children:c?S.jsx(ot,{}):"Deploy 8 Agents"})]})]})]})})},WN=({job:i})=>{let t="bg-gray-800 border-gray-700",o="Queued";return i.status==="drafting"?(t="bg-blue-900/30 border-blue-500/50",o="Drafting..."):i.status==="critiquing"?(t="bg-yellow-900/30 border-yellow-500/50",o="Critiquing..."):i.status==="refining"?(t="bg-purple-900/30 border-purple-500/50",o="Refining..."):i.status==="finalizing"?(t="bg-green-900/30 border-green-500/50",o="Committing..."):i.status==="success"?(t="bg-green-900/20 border-green-800",o="Done"):i.status==="failed"&&(t="bg-red-900/20 border-red-800",o="Failed"),S.jsxs("div",{className:`p-3 rounded border ${t} flex flex-col h-40 transition-all duration-300`,children:[S.jsxs("div",{className:"flex justify-between items-center mb-2",children:[S.jsx("span",{className:"font-bold text-xs text-gray-300 truncate w-3/4",title:i.path,children:i.path}),S.jsx("span",{className:`text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${i.status==="success"?"bg-green-500 text-black":"bg-gray-700 text-gray-300"}`,children:o})]}),S.jsxs("div",{className:"flex-grow overflow-hidden relative bg-gray-950 rounded p-1 mb-2",children:[S.jsx("pre",{className:"text-[8px] text-gray-500 font-mono leading-tight whitespace-pre-wrap break-all opacity-50",children:i.currentContent||"// Waiting for agent..."}),i.status==="critiquing"&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:S.jsx("span",{className:"text-yellow-400 text-xs font-bold animate-pulse",children:"Reviewing..."})})]}),S.jsxs("div",{className:"flex justify-between items-center text-[10px] text-gray-500",children:[S.jsxs("span",{children:["Cycles: ",i.status==="success"||i.status==="refining"?"2-3":"1"]}),i.status==="refining"&&S.jsx("span",{className:"text-purple-400",children:"Fixing bugs..."})]})]})},jN=({jobs:i,phase:t,onClose:o,isComplete:s})=>{const r=i.filter(h=>h.status==="success"||h.status==="failed").length,c=i.length>0?r/i.length*100:0,d=[...i].sort((h,y)=>{const m=v=>["drafting","critiquing","refining"].includes(v)?0:v==="queued"?1:2;return m(h.status)-m(y.status)});return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-900 p-6 rounded-lg shadow-2xl w-full max-w-7xl h-[95vh] flex flex-col border border-gray-800",children:[S.jsxs("div",{className:"flex justify-between items-center mb-6 flex-shrink-0",children:[S.jsxs("div",{children:[S.jsx("h2",{className:"text-3xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-pink-400 to-purple-500",children:"Jellyfish Swarm"}),S.jsx("p",{className:"text-gray-400 text-sm",children:t==="planning"?"Planning massive overhaul...":"Swarm Active: 8 Concurrent Agents"})]}),s&&S.jsx("button",{onClick:o,className:"px-6 py-2 bg-gray-700 text-white font-semibold rounded-md hover:bg-gray-600 border border-gray-600",children:"Close Mission"})]}),S.jsxs("div",{className:"mb-6 flex-shrink-0",children:[S.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mb-1 uppercase tracking-wider",children:[S.jsx("span",{children:"Total Progress"}),S.jsxs("span",{children:[`${r} / ${i.length}`," Files"]})]}),S.jsx("div",{className:"w-full bg-gray-800 rounded-full h-3 border border-gray-700",children:S.jsx("div",{className:"bg-gradient-to-r from-pink-500 to-purple-600 h-full rounded-full transition-all duration-500 ease-out shadow-[0_0_10px_rgba(236,72,153,0.5)]",style:{width:`${c}%`}})})]}),t==="planning"?S.jsxs("div",{className:"flex-grow flex flex-col items-center justify-center space-y-4",children:[S.jsxs("div",{className:"relative",children:[S.jsx("div",{className:"absolute inset-0 bg-pink-500 blur-xl opacity-20 animate-pulse"}),S.jsx(ot,{className:"h-12 w-12 text-pink-500 relative z-10"})]}),S.jsx("p",{className:"text-pink-200 text-lg animate-pulse",children:"Master Intelligence is analyzing repository structure..."})]}):S.jsx("div",{className:"flex-grow overflow-y-auto pr-2 custom-scrollbar",children:S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-3",children:d.map(h=>S.jsx(WN,{job:h},h.id))})})]})})};function eb(){const[i,t]=Q.useState(null),[o,s]=Q.useState({}),[r,c]=Q.useState([]),[d,h]=Q.useState(null),[y,m]=Q.useState(!1),[v,E]=Q.useState(""),[_,x]=Q.useState(null),[w,I]=Q.useState({}),[M,V]=Q.useState({}),[$,O]=Q.useState(!1),[J,ne]=Q.useState(new Set),[z,X]=Q.useState(!1),[ve,W]=Q.useState([]),[Ee,Ne]=Q.useState(!1),[Ve,je]=Q.useState(!1),[qe,Ye]=Q.useState([]),[L,Y]=Q.useState(""),[le,Me]=Q.useState(!1),[Ke,b]=Q.useState(!1),[B,K]=Q.useState([]),[ee,he]=Q.useState("idle"),[Ae,He]=Q.useState(!1),[At,ut]=Q.useState(!1),[Ei,pn]=Q.useState([]),[Bi,qt]=Q.useState("idle"),[Nn,Oi]=Q.useState(0),[Fi,Fl]=Q.useState(null),[Jl,Ji]=Q.useState(null),[Oo,Yi]=Q.useState(null),[La,Yl]=Q.useState(null),[Ut,Fo]=Q.useState(!1),[Kl,Ki]=Q.useState(!1),[Sn,Ga]=Q.useState(null),[Xl,$l]=Q.useState(!1),[Ql,Ht]=Q.useState([]),[Mt,Jt]=Q.useState("idle"),ue=r.find(j=>j.repoFullName+"::"+j.path===d),Pa=ue?M[ue.repoFullName]:null,qa=ue?w[ue.repoFullName]||[]:[],Ha=Q.useCallback(async j=>{if(j.githubToken){j.geminiKey&&bN(j.geminiKey),t(j.githubToken),m(!0),E("Fetching repositories...");try{const ae=await Ih(j.githubToken),ie={},Te=ae.map(async fe=>{E(`Processing ${fe.owner.login}/${fe.name}...`);try{ie[fe.full_name]={repo:fe,tree:[]};const me=await Dh(j.githubToken,fe.owner.login,fe.name,fe.default_branch);ie[fe.full_name].tree=me;const se=await ec(j.githubToken,fe.owner.login,fe.name);I(ge=>({...ge,[fe.full_name]:se})),V(ge=>({...ge,[fe.full_name]:fe.default_branch}))}catch(me){console.error(`Failed to fetch tree for ${fe.full_name}`,me)}});await Promise.all(Te),s(ie)}catch(ae){console.error(ae),x({type:"error",message:"Failed to load repositories. Check your token."}),t(null)}finally{m(!1),E("")}}},[]),Xi=async(j,ae)=>{var fe;const ie=j+"::"+ae;if(r.find(me=>me.repoFullName+"::"+me.path===ie)){h(ie);return}if(i){m(!0),E(`Opening ${ae}...`);try{const me=(fe=o[j])==null?void 0:fe.repo;if(!me)throw new Error("Repo not found");const se=M[j]||me.default_branch,{content:ge,sha:pe}=await Io(i,me.owner.login,me.name,ae,se),lt={repoFullName:j,path:ae,content:ge,editedContent:ge,sha:pe,defaultBranch:me.default_branch};c(Le=>[...Le,lt]),h(ie)}catch(me){console.error(me),x({type:"error",message:`Failed to open file: ${ae}`})}finally{m(!1),E("")}}},$i=j=>{c(ae=>ae.filter(ie=>ie.repoFullName+"::"+ie.path!==j)),d===j&&h(null)},Xn=(j,ae)=>{c(ie=>ie.map(Te=>Te.repoFullName+"::"+Te.path===j?{...Te,editedContent:ae}:Te))},bn=j=>{h(j)},Qi=async j=>{if(!(!ue||!i)){m(!0),E("Committing changes...");try{const[ae,ie]=ue.repoFullName.split("/"),Te=M[ue.repoFullName]||ue.defaultBranch,fe=await Do({token:i,owner:ae,repo:ie,branch:Te,path:ue.path,content:ue.editedContent,message:j,sha:ue.sha});c(me=>me.map(se=>se.repoFullName+"::"+se.path===d?{...se,content:se.editedContent,sha:fe}:se)),x({type:"success",message:"Changes committed successfully!"})}catch(ae){console.error(ae),x({type:"error",message:"Failed to commit changes."})}finally{m(!1),E("")}}},$n=async j=>{if(!ue||!i)return;const ae=ue.repoFullName;V(ie=>({...ie,[ae]:j})),m(!0);try{const[ie,Te]=ae.split("/"),{content:fe,sha:me}=await Io(i,ie,Te,ue.path,j);c(ge=>ge.map(pe=>pe.repoFullName+"::"+pe.path===d?{...pe,content:fe,editedContent:fe,sha:me}:pe));const se=await Dh(i,ie,Te,j);s(ge=>({...ge,[ae]:{...ge[ae],tree:se}}))}catch(ie){console.error("Error switching branch",ie),x({type:"error",message:"Failed to switch branch/reload file."})}finally{m(!1)}},ka=async j=>{if(!(!ue||!i)){m(!0);try{const[ae,ie]=ue.repoFullName.split("/"),Te=M[ue.repoFullName]||ue.defaultBranch,me=(await ec(i,ae,ie)).find(ge=>ge.name===Te);if(!me)throw new Error("Could not find current branch tip SHA");await Xv(i,ae,ie,j,me.commit.sha);const se=await ec(i,ae,ie);I(ge=>({...ge,[ue.repoFullName]:se})),$n(j),x({type:"success",message:`Branch ${j} created and active.`})}catch(ae){console.error(ae),x({type:"error",message:"Failed to create branch."})}finally{m(!1)}}},Zl=async(j,ae)=>{if(!(!ue||!i)){m(!0);try{const[ie,Te]=ue.repoFullName.split("/"),fe=M[ue.repoFullName],me=ue.defaultBranch,se=await Zv({token:i,owner:ie,repo:Te,title:j,body:ae,head:fe,base:me});x({type:"success",message:`Pull Request #${se.number} created: ${se.html_url}`})}catch(ie){console.error(ie),x({type:"error",message:"Failed to create Pull Request."})}finally{m(!1)}}},Jo=(j,ae)=>{const ie=new Set(J);ae?ie.add(j):ie.delete(j),ne(ie)},_i=(j,ae,ie)=>{const Te=Ea(j),fe=new Set(J);Te.forEach(me=>{const se=`${ae}::${me}`;ie?fe.add(se):fe.delete(se)}),ne(fe)},Va=()=>{J.size!==0&&O(!0)},Wl=async j=>{O(!1),X(!0);const ae=Array.from(J).map(se=>{const[ge,...pe]=se.split("::");return{id:se,repoFullName:ge,path:pe.join("::"),status:"queued",content:"",error:null}});W(ae);const ie=async se=>{if(i){W(ge=>ge.map(pe=>pe.id===se.id?{...pe,status:"processing"}:pe));try{const[ge,pe]=se.repoFullName.split("/"),{content:lt,sha:Le}=await Io(i,ge,pe,se.path,M[se.repoFullName]);let be="";for(const et of jt)try{et!==jt[0]&&W(ke=>ke.map(F=>F.id===se.id?{...F,status:"retrying",error:`Retrying with ${et}...`}:F)),await RN(lt,j,se.path,ke=>{be+=ke,W(F=>F.map(ce=>ce.id===se.id?{...ce,content:be}:ce))},()=>be,et);const Xe=Vi(be);await Do({token:i,owner:ge,repo:pe,branch:M[se.repoFullName]||"main",path:se.path,content:Xe,message:`AI Edit: ${j.slice(0,50)}...`,sha:Le}),W(ke=>ke.map(F=>F.id===se.id?{...F,status:"success"}:F));return}catch(Xe){console.warn(`Model ${et} failed for ${se.path}:`,Xe),be=""}throw new Error("All AI models failed to generate valid code.")}catch(ge){W(pe=>pe.map(lt=>lt.id===se.id?{...lt,status:"failed",error:ge.message}:lt))}}},Te=4;let fe=0;const me=()=>{if(fe>=ae.length)return;const se=ae[fe++];ie(se).finally(()=>me())};for(let se=0;se{Ne(!0)},es=async(j,ae,ie)=>{if(i){Ne(!1),je(!0),Y("Initializing repository..."),Ye([]);try{const Te=await $v({token:i,name:j,description:`AI Generated: ${ae.slice(0,50)}...`,isPrivate:ie});Y(`Repository ${Te.full_name} created. Planning structure...`);let fe=null;for(const be of jt)try{fe=await wN(ae,be);break}catch(et){console.warn("Plan generation failed",et)}if(!fe)throw new Error("Failed to generate project plan.");const me=fe.files.map(be=>({id:be.path,path:be.path,description:be.description,status:"queued",content:"",error:null}));Ye(me),Y("Generating files...");const se=async be=>{Ye(Xe=>Xe.map(ke=>ke.id===be.id?{...ke,status:"generating"}:ke));let et="";try{for(const Xe of jt)try{Xe!==jt[0]&&Ye(F=>F.map(ce=>ce.id===be.id?{...ce,status:"retrying",error:`Retrying with ${Xe}...`}:ce)),await gg(ae,be.path,be.description,F=>{et+=F,Ye(ce=>ce.map(Ge=>Ge.id===be.id?{...Ge,content:et}:Ge))},()=>et,Xe);const ke=Vi(et);Ye(F=>F.map(ce=>ce.id===be.id?{...ce,status:"committing"}:ce)),await Do({token:i,owner:Te.owner.login,repo:Te.name,branch:Te.default_branch,path:be.path,content:ke,message:`AI Create: ${be.path}`}),Ye(F=>F.map(ce=>ce.id===be.id?{...ce,status:"success"}:ce));return}catch(ke){console.warn(`Model ${Xe} failed for ${be.path}:`,ke),et=""}throw new Error("All AI models failed.")}catch(Xe){Ye(ke=>ke.map(F=>F.id===be.id?{...F,status:"failed",error:Xe.message}:F))}},ge=4;let pe=0;const lt=()=>{if(pe>=me.length)return;const be=me[pe++];se(be).finally(()=>lt())};for(let be=0;be{Me(!0)},Ko=async j=>{if(Me(!1),b(!0),he("planning"),K([]),!i||J.size!==1){x({type:"error",message:"Please select exactly one seed file."}),b(!1);return}const ae=Array.from(J)[0],[ie,...Te]=ae.split("::"),fe=Te.join("::"),[me,se]=ie.split("/");try{const{content:ge}=await Io(i,me,se,fe,M[ie]);let pe=null;for(const F of jt)try{pe=await MN([{path:fe,content:ge}],j,F);break}catch(ce){console.warn("Expansion planning failed",ce)}if(!pe)throw new Error("Failed to plan expansion.");const lt=pe.filesToCreate.map(F=>({id:F.path,path:F.path,type:"create",description:F.description,agentIndex:F.agentIndex,status:"queued",content:"",error:null}));K(lt),he("generating");const Le=async F=>{K(Ge=>Ge.map($e=>$e.id===F.id?{...$e,status:"generating"}:$e));let ce="";try{for(const Ge of jt)try{Ge!==jt[0]&&K(Fe=>Fe.map(Ie=>Ie.id===F.id?{...Ie,status:"retrying",error:`Retrying with ${Ge}...`}:Ie)),await gg(j,F.path,F.description,Fe=>{ce+=Fe,K(Ie=>Ie.map(Qe=>Qe.id===F.id?{...Qe,content:ce}:Qe))},()=>ce,Ge);const $e=Vi(ce);K(Fe=>Fe.map(Ie=>Ie.id===F.id?{...Ie,status:"committing"}:Ie)),await Do({token:i,owner:me,repo:se,branch:M[ie]||"main",path:F.path,content:$e,message:`AI Expansion: ${F.path}`}),K(Fe=>Fe.map(Ie=>Ie.id===F.id?{...Ie,status:"success"}:Ie));return}catch($e){console.warn(`Model ${Ge} failed for ${F.path}:`,$e),ce=""}throw new Error("All AI models failed.")}catch(Ge){K($e=>$e.map(Fe=>Fe.id===F.id?{...Fe,status:"failed",error:Ge.message}:Fe))}},be=8;let et=0;const Xe=()=>{if(et>=lt.length)return;const F=lt[et++];Le(F).finally(()=>Xe())};for(let F=0;F{lt.filter(ce=>ce.status==="queued"||ce.status==="generating"||ce.status==="committing"||ce.status==="retrying").length===0&&et>=lt.length&&(he("complete"),clearInterval(ke))},1e3)}catch(ge){console.error(ge),x({type:"error",message:`Expansion failed: ${ge.message}`}),he("complete")}},ts=()=>{He(!0)},ns=async(j,ae)=>{var se,ge;if(He(!1),ut(!0),qt("analyzing"),pn([]),Oi(1),Fl(null),Ji(null),Yi(null),Yl(null),!i||!ue)return;const[ie,Te]=ue.repoFullName.split("/"),fe=M[ue.repoFullName]||ue.defaultBranch,me=async()=>r.map(pe=>({path:pe.path,content:pe.content,sha:pe.sha}));try{let pe=await me(),lt=j,Le=1;const be=3;for(;Le<=be;){Oi(Le),qt(Le===1?"planning":"analyzing_failure");let et=null;for(const F of jt)try{Le===1?et=await DN(lt,ue.path,pe,F):et=await LN(j,pe,[],Fi||"",F);break}catch(ce){console.warn("Planning failed",ce)}if(!et)throw new Error("Failed to generate edit plan.");Yi(et.reasoning);const Xe=et.filesToEdit.map(F=>({id:F.path,path:F.path,status:"planning",content:"",error:null}));pn(Xe),qt("editing");for(const F of et.filesToEdit){const ce=Xe.findIndex(Ie=>Ie.path===F.path);if(ce===-1)continue;pn(Ie=>Ie.map((Qe,pt)=>pt===ce?{...Qe,status:"editing"}:Qe));let Ge=((se=pe.find(Ie=>Ie.path===F.path))==null?void 0:se.content)||"";if(!Ge)try{Ge=(await Io(i,ie,Te,F.path,fe)).content}catch{}let $e="";await UN(Ge,F.changes,F.path,Ie=>{$e+=Ie,pn(Qe=>Qe.map((pt,is)=>is===ce?{...pt,content:$e}:pt))},jt[0]);const Fe=Vi($e);qt("committing"),pn(Ie=>Ie.map((Qe,pt)=>pt===ce?{...Qe,status:"committing"}:Qe)),await Do({token:i,owner:ie,repo:Te,branch:fe,path:F.path,content:Fe,message:`AI Advanced Edit (Attempt ${Le}): ${F.path}`,sha:(ge=pe.find(Ie=>Ie.path===F.path))==null?void 0:ge.sha}),pn(Ie=>Ie.map((Qe,pt)=>pt===ce?{...Qe,status:"success"}:Qe))}qt("triggering_workflow"),await jv(i,ie,Te,ae,fe),qt("waiting_for_workflow"),await new Promise(F=>setTimeout(F,5e3));let ke=null;for(;;){const F=await eT(i,ie,Te,ae,fe);if(F.workflow_runs.length>0&&(ke=F.workflow_runs[0],Ji(ke.html_url),ke.status==="completed"))break;await new Promise(ce=>setTimeout(ce,5e3))}if(ke&&ke.conclusion==="success"){qt("complete"),Yl(`https://${ie}.github.io/${Te}/`);return}else{qt("analyzing_failure");const F=await tT(i,ie,Te,ke.id);Fl(F),Le++}}x({type:"error",message:"Max verification attempts reached. Build still failing."}),qt("complete")}catch(pe){console.error(pe),x({type:"error",message:`Advanced edit failed: ${pe.message}`}),qt("complete")}},En=()=>{Fo(!0)},St=async j=>{if(Fo(!1),!ue||!i)return;const ae=d;try{let ie="";await IN(ue.editedContent,j,ue.path,Te=>{ie+=Te,Xn(ae,ie)},jt[0]),Xn(ae,Vi(ie))}catch(ie){console.error(ie),x({type:"error",message:"AI Edit failed."})}},It=j=>{Ga(j),Ki(!0)},Qn=async j=>{var fe;if(Ki(!1),!Sn||!i)return;$l(!0),Jt("planning"),Ht([]);const[ae,ie]=Sn.split("/"),Te=M[Sn]||"main";try{const me=((fe=o[Sn])==null?void 0:fe.tree)||[],se=Ea(me);let ge=null;for(const F of jt)try{ge=await GN(j,se,F);break}catch(ce){console.warn("Jellyfish planning failed",ce)}if(!ge)throw new Error("Jellyfish could not generate a plan.");const pe=ge.files.map(F=>({id:F.path,path:F.path,description:F.description,status:"queued",currentContent:"",critiqueCount:0,lastCritique:null}));Ht(pe),Jt("swarming");const lt=8;let Le=0;const be=pe.map(F=>`File: ${F.path} - Goal: ${F.description}`).join(` `),et=async F=>{Ht(ce=>ce.map(Ge=>Ge.id===F.id?{...Ge,status:"drafting"}:Ge));try{let ce="";try{ce=(await Io(i,ae,ie,F.path,Te)).content}catch{}const Ge=await PN(F.path,F.description,ce,be,jt[0],($e,Fe)=>{Ht(Ie=>Ie.map(Qe=>Qe.id===F.id?{...Qe,status:$e==="drafting"?"drafting":$e==="critiquing"?"critiquing":"refining",currentContent:Fe||Qe.currentContent}:Qe))});Ht($e=>$e.map(Fe=>Fe.id===F.id?{...Fe,status:"finalizing"}:Fe)),await Do({token:i,owner:ae,repo:ie,branch:Te,path:F.path,content:Ge,message:`Jellyfish Overhaul: ${F.path}`}),Ht($e=>$e.map(Fe=>Fe.id===F.id?{...Fe,status:"success"}:Fe))}catch(ce){console.error(`Jellyfish worker failed on ${F.path}`,ce),Ht(Ge=>Ge.map($e=>$e.id===F.id?{...$e,status:"failed"}:$e))}},Xe=()=>{if(Le>=pe.length)return;const F=pe[Le++];et(F).finally(()=>Xe())};for(let F=0;F{const F=pe.filter(Ge=>["queued","drafting","critiquing","refining","finalizing"].includes(Ge.status)).length,ce=Ql.filter(Ge=>["success","failed"].includes(Ge.status)).length;Ht(Ge=>(Ge.every(Fe=>Fe.status==="success"||Fe.status==="failed")&&Ge.length>0&&(Jt("complete"),clearInterval(ke)),Ge))},2e3)}catch(me){console.error(me),x({type:"error",message:`Jellyfish failed: ${me.message}`}),Jt("complete")}};return i?S.jsxs("div",{className:"flex h-screen bg-gray-950 text-gray-200 font-sans",children:[S.jsx("div",{className:"w-80 border-r border-gray-700 flex flex-col",children:S.jsx(zv,{fileTree:o,onFileSelect:Xi,onStartMultiEdit:Va,onStartNewProject:jl,onStartProjectExpansion:Yo,onStartJellyfish:It,selectedFilePath:ue==null?void 0:ue.path,selectedRepo:ue==null?void 0:ue.repoFullName,selectedFiles:J,onFileSelection:Jo,onDirectorySelection:_i})}),S.jsxs("div",{className:"flex-grow flex flex-col relative",children:[S.jsx(Jv,{openFiles:r,activeFile:ue||null,onCommit:Qi,onAdvancedAiEdit:ts,onSimpleAiEditRequest:En,onFileContentChange:Xn,onCloseFile:$i,onSetActiveFile:bn,isLoading:y,branches:qa,currentBranch:Pa,onBranchChange:$n,onCreateBranch:ka,onCreatePullRequest:Zl}),y&&v&&S.jsx("div",{className:"absolute inset-0 bg-gray-950 bg-opacity-50 flex items-center justify-center z-20",children:S.jsxs("div",{className:"bg-gray-850 p-4 rounded-lg shadow-lg flex items-center gap-3 border border-gray-700",children:[S.jsx(ot,{}),S.jsx("span",{children:v})]})})]}),S.jsx(qN,{alert:_,onClose:()=>x(null)}),$&&S.jsx(HN,{fileCount:J.size,onClose:()=>O(!1),onSubmit:Wl}),z&&S.jsx(VN,{jobs:ve,onClose:()=>X(!1),isComplete:ve.every(j=>j.status==="success"||j.status==="failed"||j.status==="skipped")}),Ee&&S.jsx(zN,{onClose:()=>Ne(!1),onSubmit:es}),Ve&&S.jsx(ON,{jobs:qe,statusMessage:L,onClose:()=>je(!1),isComplete:qe.length>0&&qe.every(j=>["success","failed"].includes(j.status))}),le&&S.jsx(FN,{onClose:()=>Me(!1),onSubmit:Ko}),Ke&&S.jsx(YN,{jobs:B,phase:ee,onClose:()=>b(!1),isComplete:ee==="complete"}),Ae&&ue&&S.jsx(KN,{onClose:()=>He(!1),onSubmit:ns,token:i,repoFullName:ue.repoFullName}),At&&S.jsx($N,{jobs:Ei,phase:Bi,verificationAttempt:Nn,buildLogs:Fi,workflowRunUrl:Jl,aiThought:Oo,deploymentUrl:La,onClose:()=>ut(!1),isComplete:Bi==="complete"}),Ut&&S.jsx(QN,{onClose:()=>Fo(!1),onSubmit:St}),Kl&&S.jsx(ZN,{onClose:()=>Ki(!1),onSubmit:Qn,repoName:Sn||""}),Xl&&S.jsx(jN,{jobs:Ql,phase:Mt,onClose:()=>$l(!1),isComplete:Mt==="complete"})]}):S.jsx(Pv,{onSubmit:Ha,isLoading:y})}const gy=document.getElementById("root");if(!gy)throw new Error("Could not find root element to mount to");const tb=Gv.createRoot(gy);tb.render(S.jsx(bv.StrictMode,{children:S.jsx(eb,{})}));